blob: 8e8c28104b4543cd0c78ef4b57d728e41010034b [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;
Bartlomiej Zolnierkiewiczd427e832008-06-10 20:56:37 +020045 hw.chipset = ide_generic;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Bartlomiej Zolnierkiewicz59bff5b2008-04-26 17:36:32 +020047 hwif = ide_find_port();
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010048 if (hwif == NULL)
49 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010051 i = hwif->index;
52
Bartlomiej Zolnierkiewiczbf64b7a2008-04-27 15:38:31 +020053 ide_init_port_data(hwif, i);
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010054 ide_init_port_hw(hwif, &hw);
Bartlomiej Zolnierkiewiczac95bee2008-04-26 22:25:14 +020055 hwif->port_ops = NULL;
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010056
57 idx[0] = i;
58
59 ide_device_add(idx, NULL);
60out:
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 return 0;
62}
63
64static int __init bastide_init(void)
65{
Bartlomiej Zolnierkiewiczb81c2262008-04-26 17:36:38 +020066 unsigned long base = BAST_VA_IDEPRI + BAST_IDE_CS;
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 /* 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 Zolnierkiewiczb81c2262008-04-26 17:36:38 +020075 if (!request_mem_region(base, 0x400000, DRV_NAME)) {
76 printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
77 return -EBUSY;
78 }
79
Bartlomiej Zolnierkiewicz7b56a932008-02-11 00:32:14 +010080 bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0);
81 bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1);
82
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 return 0;
84}
85
86module_init(bastide_init);
87
88MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
89MODULE_LICENSE("GPL");
90MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver");