2 * H8/300 generic IDE interface
5 #include <linux/init.h>
14 __asm__("mov.b %w1,r1h\n\t" \
23 static void mm_outw(u16 d, unsigned long a)
25 __asm__("mov.b %w0,r2h\n\t"
33 static u16 mm_inw(unsigned long a)
35 register u16 r __asm__("er0");
36 __asm__("mov.w @%1,r2\n\t"
45 static void mm_outsw(unsigned long addr, void *buf, u32 len)
47 unsigned short *bp = (unsigned short *)buf;
48 for (; len > 0; len--, bp++)
49 *(volatile u16 *)addr = bswap(*bp);
52 static void mm_insw(unsigned long addr, void *buf, u32 len)
54 unsigned short *bp = (unsigned short *)buf;
55 for (; len > 0; len--, bp++)
56 *bp = bswap(*(volatile u16 *)addr);
59 static void h8300_input_data(ide_drive_t *drive, struct request *rq,
60 void *buf, unsigned int len)
62 mm_insw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
65 static void h8300_output_data(ide_drive_t *drive, struct request *rq,
66 void *buf, unsigned int len)
68 mm_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
71 #define H8300_IDE_GAP (2)
73 static inline void hw_setup(hw_regs_t *hw)
77 memset(hw, 0, sizeof(hw_regs_t));
78 for (i = 0; i <= 7; i++)
79 hw->io_ports_array[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i;
80 hw->io_ports.ctl_addr = CONFIG_H8300_IDE_ALT;
81 hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ;
82 hw->chipset = ide_generic;
85 static inline void hwif_setup(ide_hwif_t *hwif)
87 default_hwif_iops(hwif);
89 hwif->input_data = h8300_input_data;
90 hwif->output_data = h8300_output_data;
93 hwif->OUTSW = mm_outsw;
100 static int __init h8300_ide_init(void)
105 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
107 if (!request_region(CONFIG_H8300_IDE_BASE, H8300_IDE_GAP*8, "ide-h8300"))
109 if (!request_region(CONFIG_H8300_IDE_ALT, H8300_IDE_GAP, "ide-h8300")) {
110 release_region(CONFIG_H8300_IDE_BASE, H8300_IDE_GAP*8);
116 hwif = ide_find_port();
118 printk(KERN_ERR "ide-h8300: IDE I/F register failed\n");
123 ide_init_port_data(hwif, index);
124 ide_init_port_hw(hwif, &hw);
126 hwif->host_flags = IDE_HFLAG_NO_IO_32BIT;
127 printk(KERN_INFO "ide%d: H8/300 generic IDE interface\n", index);
131 ide_device_add(idx, NULL);
136 printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n");
141 module_init(h8300_ide_init);
143 MODULE_LICENSE("GPL");