MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / ide / arm / adi-coyote.c
blob3e4a6e8484d90ba5116ce670e95691c27e8123ab
1 /*
2 * drivers/ide/arm/adi-coyote.c
4 * IDE hooks for ADI Engineering Coyote platform
6 * Author: Deepak Saxena <dsaxena@plexity.net>
8 * Copyright 2004 (c) MontaVista, Software, Inc.
9 *
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
15 #include <linux/module.h>
16 #include <linux/slab.h>
17 #include <linux/blkdev.h>
18 #include <linux/errno.h>
19 #include <linux/ide.h>
20 #include <linux/init.h>
22 #include <asm/mach-types.h>
24 static u16 coyote_inw(unsigned long p)
26 return *((volatile u16 *)(COYOTE_IDE_BASE_VIRT + p));
29 static u8 coyote_inb(unsigned long p)
31 return (u8) coyote_inw(p);
34 static void coyote_insw(unsigned long port, void *addr, u32 count)
36 while (count--) {
37 *(u16 *)addr = *(volatile u16 *)(COYOTE_IDE_BASE_VIRT + port);
38 addr += 2;
41 static void coyote_outw(u16 v, unsigned long p)
43 *((volatile u16 *)(COYOTE_IDE_BASE_VIRT + p)) = v;
46 static void coyote_outb(u8 v, unsigned long p)
48 coyote_outw(v, p);
51 static void coyote_outbsync(ide_drive_t *drive, u8 v, unsigned long p)
53 coyote_outw(v, p);
56 static void coyote_outsw(unsigned long port, void *addr, u32 count)
58 while (count--) {
59 *(volatile u16 *)(COYOTE_IDE_BASE_VIRT + (port)) = *(u16 *)addr;
60 addr += 2;
64 static int __init coyote_ide_init(void)
66 int i;
67 struct hwif_s *hwifp;
68 hw_regs_t coyote_ide;
69 ide_ioreg_t reg = (ide_ioreg_t) COYOTE_IDE_DATA_PORT;
71 if(!machine_is_adi_coyote())
72 return -EIO;
74 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
75 coyote_ide.io_ports[i] = reg;
76 reg += 2;
78 coyote_ide.irq = IRQ_COYOTE_IDE;
79 coyote_ide.io_ports[IDE_CONTROL_OFFSET] = COYOTE_IDE_CTRL_PORT;
80 coyote_ide.chipset = ide_generic;
82 printk("Registering IDE HW: %d\n",
83 ide_register_hw(&coyote_ide, &hwifp));
86 * Override the generic functions with our own implementation
88 hwifp->OUTB = coyote_outb;
89 hwifp->OUTBSYNC = coyote_outbsync;
90 hwifp->OUTW = coyote_outw;
91 hwifp->OUTSW = coyote_outsw;
92 hwifp->INB = coyote_inb;
93 hwifp->INW = coyote_inw;
94 hwifp->INSW = coyote_insw;
96 return 0;
99 MODULE_LICENSE("GPL");
100 MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
101 MODULE_DESCRIPTION("ADI Coyote IDE driver");
103 module_init(coyote_ide_init);