1 /****************************************************************************/
3 * linux/include/asm-m68knommu/ide.h
5 * Copyright (C) 1994-1996 Linus Torvalds & authors
6 * Copyright (C) 2001 Lineo Inc., davidm@uclinux.org
8 /****************************************************************************/
9 #ifndef _M68KNOMMU_IDE_H
10 #define _M68KNOMMU_IDE_H
13 /****************************************************************************/
15 #include <linux/config.h>
16 #include <linux/interrupt.h>
18 #include <asm/setup.h>
22 /****************************************************************************/
24 * some coldfire specifics
27 #ifdef CONFIG_COLDFIRE
28 #include <asm/coldfire.h>
29 #include <asm/mcfsim.h>
32 * Save some space, only have 1 interface
34 #define MAX_HWIFS 1 /* we only have one interface for now */
36 #ifdef CONFIG_SECUREEDGEMP3
37 #define MCFSIM_LOCALCS MCFSIM_CSCR4
39 #define MCFSIM_LOCALCS MCFSIM_CSCR6
42 #endif /* CONFIG_COLDFIRE */
44 /****************************************************************************/
46 * Fix up things that may not have been provided
50 #define MAX_HWIFS 4 /* same as the other archs */
53 #undef SUPPORT_SLOW_DATA_PORTS
54 #define SUPPORT_SLOW_DATA_PORTS 0
56 #undef SUPPORT_VLB_SYNC
57 #define SUPPORT_VLB_SYNC 0
59 /* this definition is used only on startup .. */
63 #define DBGIDE(fmt,a...)
64 // #define DBGIDE(fmt,a...) printk(fmt, ##a)
65 #define IDE_INLINE __inline__
68 /****************************************************************************/
71 unsigned all : 8; /* all of the bits together */
73 unsigned bit7 : 1; /* always 1 */
74 unsigned lba : 1; /* using LBA instead of CHS */
75 unsigned bit5 : 1; /* always 1 */
76 unsigned unit : 1; /* drive select number, 0 or 1 */
77 unsigned head : 4; /* always zeros here */
82 * our list of ports/irq's for different boards
85 static struct m68k_ide_defaults {
88 } m68k_ide_defaults[MAX_HWIFS] = {
89 #if defined(CONFIG_SECUREEDGEMP3)
90 { ((ide_ioreg_t)0x30800000), 29 },
91 #elif defined(CONFIG_eLIA)
92 { ((ide_ioreg_t)0x30c00000), 29 },
94 { ((ide_ioreg_t)0x0), 0 }
98 /****************************************************************************/
100 static IDE_INLINE int ide_default_irq(ide_ioreg_t base)
104 for (i = 0; i < MAX_HWIFS; i++)
105 if (m68k_ide_defaults[i].base == base)
106 return(m68k_ide_defaults[i].irq);
110 static IDE_INLINE ide_ioreg_t ide_default_io_base(int index)
112 if (index >= 0 && index < MAX_HWIFS)
113 return(m68k_ide_defaults[index].base);
119 * Set up a hw structure for a specified data port, control port and IRQ.
120 * This should follow whatever the default interface uses.
122 static IDE_INLINE void ide_init_hwif_ports(
124 ide_ioreg_t data_port,
125 ide_ioreg_t ctrl_port,
128 ide_ioreg_t reg = data_port;
131 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
132 hw->io_ports[i] = reg;
136 hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
138 hw->io_ports[IDE_CONTROL_OFFSET] = data_port + 0xe;
142 #define ide_init_default_irq(base) ide_default_irq(base)
144 static IDE_INLINE int
147 void (*handler)(int, void *, struct pt_regs *),
152 #ifdef CONFIG_COLDFIRE
155 return(request_irq(irq, handler, flags, device, dev_id));
159 static IDE_INLINE void
160 ide_free_irq(unsigned int irq, void *dev_id)
162 free_irq(irq, dev_id);
166 static IDE_INLINE int
167 ide_check_region(ide_ioreg_t from, unsigned int extent)
173 static IDE_INLINE void
174 ide_request_region(ide_ioreg_t from, unsigned int extent, const char *name)
179 static IDE_INLINE void
180 ide_release_region(ide_ioreg_t from, unsigned int extent)
185 static IDE_INLINE void
186 ide_fix_driveid(struct hd_driveid *id)
188 #ifdef CONFIG_COLDFIRE
190 unsigned short *wp = (unsigned short *) id;
191 int avoid[] = {49, 51, 52, 59, -1 }; /* do not swap these words */
193 /* Need to byte swap shorts, but not char fields */
194 for (i = n = 0; i < sizeof(*id) / sizeof(*wp); i++, wp++) {
199 *wp = ((*wp & 0xff) << 8) | ((*wp >> 8) & 0xff);
201 /* have to word swap the one 32 bit field */
202 id->lba_capacity = ((id->lba_capacity & 0xffff) << 16) |
203 ((id->lba_capacity >> 16) & 0xffff);
208 static IDE_INLINE void
209 ide_release_lock (int *ide_lock)
214 static IDE_INLINE void
217 void (*handler)(int, void *, struct pt_regs *),
223 #define ide_ack_intr(hwif) \
224 ((hwif)->hw.ack_intr ? (hwif)->hw.ack_intr(hwif) : 1)
225 #define ide__sti() __sti()
227 /****************************************************************************/
229 * System specific IO requirements
232 #ifdef CONFIG_COLDFIRE
234 #ifdef CONFIG_SECUREEDGEMP3
236 /* Replace standard IO functions for funky mapping of MP3 board */
242 #define outb(v, a) ide_outb(v, (unsigned long) (a))
243 #define outb_p(v, a) ide_outb(v, (unsigned long) (a))
244 #define inb(a) ide_inb((unsigned long) (a))
245 #define inb_p(a) ide_inb((unsigned long) (a))
247 #define ADDR8_PTR(addr) (((addr) & 0x1) ? (0x8000 + (addr) - 1) : (addr))
248 #define ADDR16_PTR(addr) (addr)
249 #define ADDR32_PTR(addr) (addr)
250 #define SWAP8(w) ((((w) & 0xffff) << 8) | (((w) & 0xffff) >> 8))
251 #define SWAP16(w) (w)
252 #define SWAP32(w) (w)
255 static IDE_INLINE void
256 ide_outb(unsigned int val, unsigned int addr)
258 volatile unsigned short *rp;
260 DBGIDE("%s(val=%x,addr=%x)\n", __FUNCTION__, val, addr);
261 rp = (volatile unsigned short *) ADDR8_PTR(addr);
266 static IDE_INLINE int
267 ide_inb(unsigned int addr)
269 volatile unsigned short *rp, val;
271 DBGIDE("%s(addr=%x)\n", __FUNCTION__, addr);
272 rp = (volatile unsigned short *) ADDR8_PTR(addr);
278 static IDE_INLINE void
279 ide_outw(unsigned int val, unsigned int addr)
281 volatile unsigned short *rp;
283 DBGIDE("%s(val=%x,addr=%x)\n", __FUNCTION__, val, addr);
284 rp = (volatile unsigned short *) ADDR16_PTR(addr);
288 static IDE_INLINE void
289 ide_outsw(unsigned int addr, const void *vbuf, unsigned long len)
291 volatile unsigned short *rp, val;
294 DBGIDE("%s(addr=%x,vbuf=%p,len=%x)\n", __FUNCTION__, addr, vbuf, len);
295 buf = (unsigned short *) vbuf;
296 rp = (volatile unsigned short *) ADDR16_PTR(addr);
297 for (; (len > 0); len--) {
303 static IDE_INLINE int
304 ide_inw(unsigned int addr)
306 volatile unsigned short *rp, val;
308 DBGIDE("%s(addr=%x)\n", __FUNCTION__, addr);
309 rp = (volatile unsigned short *) ADDR16_PTR(addr);
314 static IDE_INLINE void
315 ide_insw(unsigned int addr, void *vbuf, unsigned long len)
317 volatile unsigned short *rp;
318 unsigned short w, *buf;
320 DBGIDE("%s(addr=%x,vbuf=%p,len=%x)\n", __FUNCTION__, addr, vbuf, len);
321 buf = (unsigned short *) vbuf;
322 rp = (volatile unsigned short *) ADDR16_PTR(addr);
323 for (; (len > 0); len--) {
329 static IDE_INLINE void
330 ide_insl(unsigned int addr, void *vbuf, unsigned long len)
332 volatile unsigned long *rp;
333 unsigned long w, *buf;
335 DBGIDE("%s(addr=%x,vbuf=%p,len=%x)\n", __FUNCTION__, addr, vbuf, len);
336 buf = (unsigned long *) vbuf;
337 rp = (volatile unsigned long *) ADDR32_PTR(addr);
338 for (; (len > 0); len--) {
344 static IDE_INLINE void
345 ide_outsl(unsigned int addr, const void *vbuf, unsigned long len)
347 volatile unsigned long *rp, val;
350 DBGIDE("%s(addr=%x,vbuf=%p,len=%x)\n", __FUNCTION__, addr, vbuf, len);
351 buf = (unsigned long *) vbuf;
352 rp = (volatile unsigned long *) ADDR32_PTR(addr);
353 for (; (len > 0); len--) {
361 /* 8/16 bit acesses are controlled by flicking bits in the CS register */
362 #define ACCESS_MODE_16BIT() \
363 *((volatile unsigned short *) (MCF_MBAR + MCFSIM_LOCALCS)) = 0x0080
364 #define ACCESS_MODE_8BIT() \
365 *((volatile unsigned short *) (MCF_MBAR + MCFSIM_LOCALCS)) = 0x0040
368 static IDE_INLINE void
369 ide_outw(unsigned int val, unsigned int addr)
376 static IDE_INLINE void
377 ide_outsw(unsigned int addr, const void *vbuf, unsigned long len)
380 outsw(addr, vbuf, len);
384 static IDE_INLINE int
385 ide_inw(unsigned int addr)
395 static IDE_INLINE void
396 ide_insw(unsigned int addr, void *vbuf, unsigned long len)
399 insw(addr, vbuf, len);
403 static IDE_INLINE void
404 ide_insl(unsigned int addr, void *vbuf, unsigned long len)
407 insl(addr, vbuf, len);
411 static IDE_INLINE void
412 ide_outsl(unsigned int addr, const void *vbuf, unsigned long len)
415 outsl(addr, vbuf, len);
419 #endif /* CONFIG_SECUREEDGEMP3 */
430 #define outw(v, a) ide_outw(v, (unsigned long) (a))
431 #define outw_p(v, a) ide_outw(v, (unsigned long) (a))
432 #define outsw(a, b, n) ide_outsw((unsigned long) (a), b, n)
433 #define inw(a) ide_inw((unsigned long) (a))
434 #define inw_p(a) ide_inw((unsigned long) (a))
435 #define insw(a, b, n) ide_insw((unsigned long) (a), b, n)
436 #define insl(a, b, n) ide_insl((unsigned long) (a), b, n)
437 #define outsl(a, b, n) ide_outsl((unsigned long) (a), b, n)
439 #endif CONFIG_COLDFIRE
441 /****************************************************************************/
442 #endif /* __KERNEL__ */
443 #endif /* _M68KNOMMU_IDE_H */
444 /****************************************************************************/