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 | 7b56a93 | 2008-02-11 00:32:14 +0100 | [diff] [blame] | 24 | 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] | 25 | { |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 26 | ide_hwif_t *hwif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | hw_regs_t hw; |
| 28 | int i; |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 29 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | memset(&hw, 0, sizeof(hw)); |
| 32 | |
| 33 | base += BAST_IDE_CS; |
| 34 | aux += BAST_IDE_CS; |
| 35 | |
| 36 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { |
| 37 | hw.io_ports[i] = (unsigned long)base; |
| 38 | base += 0x20; |
| 39 | } |
| 40 | |
| 41 | hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20); |
| 42 | hw.irq = irq; |
| 43 | |
Bartlomiej Zolnierkiewicz | 4f0eee4 | 2008-04-18 00:46:21 +0200 | [diff] [blame] | 44 | hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 45 | if (hwif == NULL) |
| 46 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 48 | i = hwif->index; |
| 49 | |
| 50 | if (hwif->present) |
Bartlomiej Zolnierkiewicz | 93de00f | 2008-04-18 00:46:24 +0200 | [diff] [blame] | 51 | ide_unregister(i); |
Bartlomiej Zolnierkiewicz | 2304dc6 | 2008-04-18 00:46:24 +0200 | [diff] [blame^] | 52 | else |
Bartlomiej Zolnierkiewicz | 9e016a7 | 2008-02-02 19:56:39 +0100 | [diff] [blame] | 53 | ide_init_port_data(hwif, i); |
| 54 | |
| 55 | ide_init_port_hw(hwif, &hw); |
| 56 | hwif->quirkproc = NULL; |
| 57 | |
| 58 | idx[0] = i; |
| 59 | |
| 60 | ide_device_add(idx, NULL); |
| 61 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | static int __init bastide_init(void) |
| 66 | { |
| 67 | /* we can treat the VR1000 and the BAST the same */ |
| 68 | |
| 69 | if (!(machine_is_bast() || machine_is_vr1000())) |
| 70 | return 0; |
| 71 | |
| 72 | printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n"); |
| 73 | |
Bartlomiej Zolnierkiewicz | 7b56a93 | 2008-02-11 00:32:14 +0100 | [diff] [blame] | 74 | bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0); |
| 75 | bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1); |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | module_init(bastide_init); |
| 81 | |
| 82 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); |
| 83 | MODULE_LICENSE("GPL"); |
| 84 | MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver"); |