blob: a80b9574865e18f03f5d8292133237ed52711bf0 [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
38 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
39 hw.io_ports[i] = (unsigned long)base;
40 base += 0x20;
41 }
42
43 hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20);
44 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
52 if (hwif->present)
Bartlomiej Zolnierkiewicz93de00f2008-04-18 00:46:24 +020053 ide_unregister(i);
Bartlomiej Zolnierkiewicz2304dc62008-04-18 00:46:24 +020054 else
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010055 ide_init_port_data(hwif, i);
56
57 ide_init_port_hw(hwif, &hw);
Bartlomiej Zolnierkiewiczb81c2262008-04-26 17:36:38 +020058 hwif->mmio = 1;
Bartlomiej Zolnierkiewicz9e016a72008-02-02 19:56:39 +010059 hwif->quirkproc = NULL;
60
61 idx[0] = i;
62
63 ide_device_add(idx, NULL);
64out:
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 return 0;
66}
67
68static int __init bastide_init(void)
69{
Bartlomiej Zolnierkiewiczb81c2262008-04-26 17:36:38 +020070 unsigned long base = BAST_VA_IDEPRI + BAST_IDE_CS;
71
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 /* we can treat the VR1000 and the BAST the same */
73
74 if (!(machine_is_bast() || machine_is_vr1000()))
75 return 0;
76
77 printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n");
78
Bartlomiej Zolnierkiewiczb81c2262008-04-26 17:36:38 +020079 if (!request_mem_region(base, 0x400000, DRV_NAME)) {
80 printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
81 return -EBUSY;
82 }
83
Bartlomiej Zolnierkiewicz7b56a932008-02-11 00:32:14 +010084 bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0);
85 bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1);
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 return 0;
88}
89
90module_init(bastide_init);
91
92MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
93MODULE_LICENSE("GPL");
94MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver");