blob: 713cef20622e986b3ff0e183861c9c0a8154c697 [file] [log] [blame]
Bartlomiej Zolnierkiewicz58f189f2008-02-01 23:09:33 +01001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * 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 Zolnierkiewiczb81c2262008-04-26 17:36:38 +020024#define DRV_NAME "bast-ide"
25
Bartlomiej Zolnierkiewicz7b56a932008-02-11 00:32:14 +010026static int __init bastide_register(unsigned int base, unsigned int aux, int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070027{
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010028 ide_hwif_t *hwif;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 hw_regs_t hw;
30 int i;
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010031 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33 memset(&hw, 0, sizeof(hw));
34
35 base += BAST_IDE_CS;
36 aux += BAST_IDE_CS;
37
Bartlomiej Zolnierkiewicz4c3032d2008-04-27 15:38:32 +020038 for (i = 0; i <= 7; i++) {
39 hw.io_ports_array[i] = (unsigned long)base;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 base += 0x20;
41 }
42
Bartlomiej Zolnierkiewicz4c3032d2008-04-27 15:38:32 +020043 hw.io_ports.ctl_addr = aux + (6 * 0x20);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 hw.irq = irq;
45
Bartlomiej Zolnierkiewicz59bff5b2008-04-26 17:36:32 +020046 hwif = ide_find_port();
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010047 if (hwif == NULL)
48 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010050 i = hwif->index;
51
Bartlomiej Zolnierkiewiczbf64b7a2008-04-27 15:38:31 +020052 ide_init_port_data(hwif, i);
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010053 ide_init_port_hw(hwif, &hw);
Bartlomiej Zolnierkiewiczac95bee2008-04-26 22:25:14 +020054 hwif->port_ops = NULL;
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010055
56 idx[0] = i;
57
58 ide_device_add(idx, NULL);
59out:
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 return 0;
61}
62
63static int __init bastide_init(void)
64{
Bartlomiej Zolnierkiewiczb81c2262008-04-26 17:36:38 +020065 unsigned long base = BAST_VA_IDEPRI + BAST_IDE_CS;
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 /* 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 Zolnierkiewiczb81c2262008-04-26 17:36:38 +020074 if (!request_mem_region(base, 0x400000, DRV_NAME)) {
75 printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
76 return -EBUSY;
77 }
78
Bartlomiej Zolnierkiewicz7b56a932008-02-11 00:32:14 +010079 bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0);
80 bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1);
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 return 0;
83}
84
85module_init(bastide_init);
86
87MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
88MODULE_LICENSE("GPL");
89MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver");