Bartlomiej Zolnierkiewicz | 58f189f | 2008-02-01 23:09:33 +0100 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (c) 2003-2004 Simtec Electronics |
| 3 | * Ben Dooks <ben@simtec.co.uk> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/errno.h> |
| 13 | #include <linux/ide.h> |
| 14 | #include <linux/init.h> |
| 15 | |
| 16 | #include <asm/mach-types.h> |
| 17 | |
| 18 | #include <asm/io.h> |
| 19 | #include <asm/irq.h> |
| 20 | #include <asm/arch/map.h> |
| 21 | #include <asm/arch/bast-map.h> |
| 22 | #include <asm/arch/bast-irq.h> |
| 23 | |
Bartlomiej Zolnierkiewicz | b81c226 | 2008-04-26 17:36:38 +0200 | [diff] [blame] | 24 | #define DRV_NAME "bast-ide" |
| 25 | |
Bartlomiej Zolnierkiewicz | 7b56a93 | 2008-02-11 00:32:14 +0100 | [diff] [blame] | 26 | static int __init bastide_register(unsigned int base, unsigned int aux, int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 28 | ide_hwif_t *hwif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | hw_regs_t hw; |
| 30 | int i; |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 31 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | memset(&hw, 0, sizeof(hw)); |
| 34 | |
| 35 | base += BAST_IDE_CS; |
| 36 | aux += BAST_IDE_CS; |
| 37 | |
Bartlomiej Zolnierkiewicz | 4c3032d | 2008-04-27 15:38:32 +0200 | [diff] [blame] | 38 | for (i = 0; i <= 7; i++) { |
| 39 | hw.io_ports_array[i] = (unsigned long)base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | base += 0x20; |
| 41 | } |
| 42 | |
Bartlomiej Zolnierkiewicz | 4c3032d | 2008-04-27 15:38:32 +0200 | [diff] [blame] | 43 | hw.io_ports.ctl_addr = aux + (6 * 0x20); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | hw.irq = irq; |
Bartlomiej Zolnierkiewicz | d427e83 | 2008-06-10 20:56:37 +0200 | [diff] [blame^] | 45 | hw.chipset = ide_generic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
Bartlomiej Zolnierkiewicz | 59bff5b | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 47 | hwif = ide_find_port(); |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 48 | if (hwif == NULL) |
| 49 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 51 | i = hwif->index; |
| 52 | |
Bartlomiej Zolnierkiewicz | bf64b7a | 2008-04-27 15:38:31 +0200 | [diff] [blame] | 53 | ide_init_port_data(hwif, i); |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 54 | ide_init_port_hw(hwif, &hw); |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 55 | hwif->port_ops = NULL; |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 56 | |
| 57 | idx[0] = i; |
| 58 | |
| 59 | ide_device_add(idx, NULL); |
| 60 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | static int __init bastide_init(void) |
| 65 | { |
Bartlomiej Zolnierkiewicz | b81c226 | 2008-04-26 17:36:38 +0200 | [diff] [blame] | 66 | unsigned long base = BAST_VA_IDEPRI + BAST_IDE_CS; |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | /* we can treat the VR1000 and the BAST the same */ |
| 69 | |
| 70 | if (!(machine_is_bast() || machine_is_vr1000())) |
| 71 | return 0; |
| 72 | |
| 73 | printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n"); |
| 74 | |
Bartlomiej Zolnierkiewicz | b81c226 | 2008-04-26 17:36:38 +0200 | [diff] [blame] | 75 | if (!request_mem_region(base, 0x400000, DRV_NAME)) { |
| 76 | printk(KERN_ERR "%s: resources busy\n", DRV_NAME); |
| 77 | return -EBUSY; |
| 78 | } |
| 79 | |
Bartlomiej Zolnierkiewicz | 7b56a93 | 2008-02-11 00:32:14 +0100 | [diff] [blame] | 80 | bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0); |
| 81 | bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1); |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | module_init(bastide_init); |
| 87 | |
| 88 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); |
| 89 | MODULE_LICENSE("GPL"); |
| 90 | MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver"); |