2 * Copyright (C) 2000, 2001 Wolfgang Denk, wd@denx.de
3 * Modified for direct IDE interface
4 * by Thomas Lange, thomas@corelatus.com
5 * Modified for direct IDE interface on 8xx without using the PCMCIA
7 * by Steven.Scholz@imc-berlin.de
8 * Moved out of arch/ppc/kernel/m8xx_setup.c, other minor cleanups
9 * by Mathew Locke <mattl@mvista.com>
12 #include <linux/errno.h>
13 #include <linux/kernel.h>
15 #include <linux/stddef.h>
16 #include <linux/unistd.h>
17 #include <linux/ptrace.h>
18 #include <linux/slab.h>
19 #include <linux/user.h>
20 #include <linux/tty.h>
21 #include <linux/major.h>
22 #include <linux/interrupt.h>
23 #include <linux/reboot.h>
24 #include <linux/init.h>
25 #include <linux/ioport.h>
26 #include <linux/ide.h>
27 #include <linux/bootmem.h>
29 #include <asm/mpc8xx.h>
31 #include <asm/processor.h>
33 #include <asm/pgtable.h>
35 #include <asm/8xx_immap.h>
36 #include <asm/machdep.h>
39 #define DRV_NAME "ide-mpc8xx"
41 static int identify (volatile u8
*p
);
42 static void print_fixed (volatile u8
*p
);
43 static void print_funcid (int func
);
44 static int check_ide_device (unsigned long base
);
46 static void ide_interrupt_ack (void *dev
);
47 static void m8xx_ide_set_pio_mode(ide_drive_t
*drive
, const u8 pio
);
49 typedef struct ide_ioport_desc
{
50 unsigned long base_off
; /* Offset to PCMCIA memory */
51 unsigned long reg_off
[IDE_NR_PORTS
]; /* controller register offsets */
55 ide_ioport_desc_t ioport_dsc
[MAX_HWIFS
] = {
56 #ifdef IDE0_BASE_OFFSET
60 IDE0_ERROR_REG_OFFSET
,
61 IDE0_NSECTOR_REG_OFFSET
,
62 IDE0_SECTOR_REG_OFFSET
,
65 IDE0_SELECT_REG_OFFSET
,
66 IDE0_STATUS_REG_OFFSET
,
67 IDE0_CONTROL_REG_OFFSET
,
72 #ifdef IDE1_BASE_OFFSET
76 IDE1_ERROR_REG_OFFSET
,
77 IDE1_NSECTOR_REG_OFFSET
,
78 IDE1_SECTOR_REG_OFFSET
,
81 IDE1_SELECT_REG_OFFSET
,
82 IDE1_STATUS_REG_OFFSET
,
83 IDE1_CONTROL_REG_OFFSET
,
88 #endif /* IDE1_BASE_OFFSET */
89 #endif /* IDE0_BASE_OFFSET */
92 ide_pio_timings_t ide_pio_clocks
[6];
93 int hold_time
[6] = {30, 20, 15, 10, 10, 10 }; /* PIO Mode 5 with IORDY (nonstandard) */
96 * Warning: only 1 (ONE) PCMCIA slot supported here,
97 * which must be correctly initialized by the firmware (PPCBoot).
99 static int _slot_
= -1; /* will be read from PCMCIA registers */
101 /* Make clock cycles and always round up */
102 #define PCMCIA_MK_CLKS( t, T ) (( (t) * ((T)/1000000) + 999U ) / 1000U )
104 #define M8XX_PCMCIA_CD2(slot) (0x10000000 >> (slot << 4))
105 #define M8XX_PCMCIA_CD1(slot) (0x08000000 >> (slot << 4))
108 * The TQM850L hardware has two pins swapped! Grrrrgh!
110 #ifdef CONFIG_TQM850L
111 #define __MY_PCMCIA_GCRX_CXRESET PCMCIA_GCRX_CXOE
112 #define __MY_PCMCIA_GCRX_CXOE PCMCIA_GCRX_CXRESET
114 #define __MY_PCMCIA_GCRX_CXRESET PCMCIA_GCRX_CXRESET
115 #define __MY_PCMCIA_GCRX_CXOE PCMCIA_GCRX_CXOE
118 #if defined(CONFIG_BLK_DEV_MPC8xx_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
119 #define PCMCIA_SCHLVL IDE0_INTERRUPT /* Status Change Interrupt Level */
120 static int pcmcia_schlvl
= PCMCIA_SCHLVL
;
124 * See include/linux/ide.h for definition of hw_regs_t (p, base)
128 * m8xx_ide_init_ports() for a direct IDE interface _using_
129 * MPC8xx's internal PCMCIA interface
131 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT)
132 static int __init
m8xx_ide_init_ports(hw_regs_t
*hw
, unsigned long data_port
)
134 unsigned long *p
= hw
->io_ports_array
;
141 volatile pcmcia_win_t
*win
;
142 volatile pcmconf8xx_t
*pcmp
;
147 static unsigned long pcmcia_base
= 0;
152 pcmp
= (pcmconf8xx_t
*)(&(((immap_t
*)IMAP_ADDR
)->im_pcmcia
));
156 * Read out PCMCIA registers. Since the reset values
157 * are undefined, we sure hope that they have been
161 /* Scan all registers for valid settings */
162 pcmcia_phy_base
= 0xFFFFFFFF;
164 /* br0 is start of brX and orX regs */
165 win
= (pcmcia_win_t
*) \
166 (&(((immap_t
*)IMAP_ADDR
)->im_pcmcia
.pcmc_pbr0
));
167 for (i
= 0; i
< 8; i
++) {
168 if (win
->or & 1) { /* This bank is marked as valid */
169 if (win
->br
< pcmcia_phy_base
) {
170 pcmcia_phy_base
= win
->br
;
172 if ((win
->br
+ PCMCIA_MEM_SIZE
) > pcmcia_phy_end
) {
173 pcmcia_phy_end
= win
->br
+ PCMCIA_MEM_SIZE
;
175 /* Check which slot that has been defined */
176 _slot_
= (win
->or >> 2) & 1;
182 printk ("PCMCIA slot %c: phys mem %08x...%08x (size %08x)\n",
184 pcmcia_phy_base
, pcmcia_phy_end
,
185 pcmcia_phy_end
- pcmcia_phy_base
);
187 if (!request_mem_region(pcmcia_phy_base
,
188 pcmcia_phy_end
- pcmcia_phy_base
,
190 printk(KERN_ERR
"%s: resources busy\n", DRV_NAME
);
194 pcmcia_base
=(unsigned long)ioremap(pcmcia_phy_base
,
195 pcmcia_phy_end
-pcmcia_phy_base
);
198 printk ("PCMCIA virt base: %08lx\n", pcmcia_base
);
200 /* Compute clock cycles for PIO timings */
201 for (i
=0; i
<6; ++i
) {
202 bd_t
*binfo
= (bd_t
*)__res
;
205 PCMCIA_MK_CLKS (hold_time
[i
],
207 ide_pio_clocks
[i
].setup_time
=
208 PCMCIA_MK_CLKS (ide_pio_timings
[i
].setup_time
,
210 ide_pio_clocks
[i
].active_time
=
211 PCMCIA_MK_CLKS (ide_pio_timings
[i
].active_time
,
213 ide_pio_clocks
[i
].cycle_time
=
214 PCMCIA_MK_CLKS (ide_pio_timings
[i
].cycle_time
,
217 printk ("PIO mode %d timings: %d/%d/%d => %d/%d/%d\n",
219 ide_pio_clocks
[i
].setup_time
,
220 ide_pio_clocks
[i
].active_time
,
221 ide_pio_clocks
[i
].hold_time
,
222 ide_pio_clocks
[i
].cycle_time
,
223 ide_pio_timings
[i
].setup_time
,
224 ide_pio_timings
[i
].active_time
,
225 ide_pio_timings
[i
].hold_time
,
226 ide_pio_timings
[i
].cycle_time
);
232 printk ("PCMCIA slot has not been defined! Using A as default\n");
236 #ifdef CONFIG_IDE_8xx_PCCARD
239 printk ("PIPR = 0x%08X slot %c ==> mask = 0x%X\n",
242 M8XX_PCMCIA_CD1(_slot_
) | M8XX_PCMCIA_CD2(_slot_
) );
245 if (pcmp
->pcmc_pipr
& (M8XX_PCMCIA_CD1(_slot_
)|M8XX_PCMCIA_CD2(_slot_
))) {
246 printk ("No card in slot %c: PIPR=%08x\n",
247 'A' + _slot_
, (u32
) pcmp
->pcmc_pipr
);
248 return -ENODEV
; /* No card in slot */
251 check_ide_device (pcmcia_base
);
253 #endif /* CONFIG_IDE_8xx_PCCARD */
255 base
= pcmcia_base
+ ioport_dsc
[data_port
].base_off
;
257 printk ("base: %08x + %08x = %08x\n",
258 pcmcia_base
, ioport_dsc
[data_port
].base_off
, base
);
261 for (i
= 0; i
< IDE_NR_PORTS
; ++i
) {
263 printk ("port[%d]: %08x + %08x = %08x\n",
266 ioport_dsc
[data_port
].reg_off
[i
],
267 i
, base
+ ioport_dsc
[data_port
].reg_off
[i
]);
269 *p
++ = base
+ ioport_dsc
[data_port
].reg_off
[i
];
272 hw
->irq
= ioport_dsc
[data_port
].irq
;
273 hw
->ack_intr
= (ide_ack_intr_t
*)ide_interrupt_ack
;
275 #ifdef CONFIG_IDE_8xx_PCCARD
280 pgcrx
= &((immap_t
*) IMAP_ADDR
)->im_pcmcia
.pcmc_pgcrb
;
282 pgcrx
= &((immap_t
*) IMAP_ADDR
)->im_pcmcia
.pcmc_pgcra
;
285 reg
|= mk_int_int_mask (pcmcia_schlvl
) << 24;
286 reg
|= mk_int_int_mask (pcmcia_schlvl
) << 16;
289 #endif /* CONFIG_IDE_8xx_PCCARD */
291 /* Enable Harddisk Interrupt,
292 * and make it edge sensitive
294 /* (11-18) Set edge detect for irq, no wakeup from low power mode */
295 ((immap_t
*)IMAP_ADDR
)->im_siu_conf
.sc_siel
|=
296 (0x80000000 >> ioport_dsc
[data_port
].irq
);
298 #ifdef CONFIG_IDE_8xx_PCCARD
299 /* Make sure we don't get garbage irq */
300 ((immap_t
*) IMAP_ADDR
)->im_pcmcia
.pcmc_pscr
= 0xFFFF;
302 /* Enable falling edge irq */
303 pcmp
->pcmc_per
= 0x100000 >> (16 * _slot_
);
304 #endif /* CONFIG_IDE_8xx_PCCARD */
306 hw
->chipset
= ide_generic
;
310 #endif /* CONFIG_IDE_8xx_PCCARD || CONFIG_IDE_8xx_DIRECT */
313 * m8xx_ide_init_ports() for a direct IDE interface _not_ using
314 * MPC8xx's internal PCMCIA interface
316 #if defined(CONFIG_IDE_EXT_DIRECT)
317 static int __init
m8xx_ide_init_ports(hw_regs_t
*hw
, unsigned long data_port
)
319 unsigned long *p
= hw
->io_ports_array
;
324 static unsigned long ide_base
= 0;
332 * - add code to read ORx, BRx
334 ide_phy_base
= CFG_ATA_BASE_ADDR
;
335 ide_phy_end
= CFG_ATA_BASE_ADDR
+ 0x200;
337 printk ("IDE phys mem : %08x...%08x (size %08x)\n",
338 ide_phy_base
, ide_phy_end
,
339 ide_phy_end
- ide_phy_base
);
341 if (!request_mem_region(ide_phy_base
, 0x200, DRV_NAME
)) {
342 printk(KERN_ERR
"%s: resources busy\n", DRV_NAME
);
346 ide_base
=(unsigned long)ioremap(ide_phy_base
,
347 ide_phy_end
-ide_phy_base
);
350 printk ("IDE virt base: %08lx\n", ide_base
);
354 base
= ide_base
+ ioport_dsc
[data_port
].base_off
;
356 printk ("base: %08x + %08x = %08x\n",
357 ide_base
, ioport_dsc
[data_port
].base_off
, base
);
360 for (i
= 0; i
< IDE_NR_PORTS
; ++i
) {
362 printk ("port[%d]: %08x + %08x = %08x\n",
365 ioport_dsc
[data_port
].reg_off
[i
],
366 i
, base
+ ioport_dsc
[data_port
].reg_off
[i
]);
368 *p
++ = base
+ ioport_dsc
[data_port
].reg_off
[i
];
371 /* direct connected IDE drive, i.e. external IRQ */
372 hw
->irq
= ioport_dsc
[data_port
].irq
;
373 hw
->ack_intr
= (ide_ack_intr_t
*)ide_interrupt_ack
;
375 /* Enable Harddisk Interrupt,
376 * and make it edge sensitive
378 /* (11-18) Set edge detect for irq, no wakeup from low power mode */
379 ((immap_t
*) IMAP_ADDR
)->im_siu_conf
.sc_siel
|=
380 (0x80000000 >> ioport_dsc
[data_port
].irq
);
382 hw
->chipset
= ide_generic
;
386 #endif /* CONFIG_IDE_8xx_DIRECT */
389 /* -------------------------------------------------------------------- */
394 #define PCMCIA_SHT(t) ((t & 0x0F)<<16) /* Strobe Hold Time */
395 #define PCMCIA_SST(t) ((t & 0x0F)<<12) /* Strobe Setup Time */
396 #define PCMCIA_SL(t) ((t==32) ? 0 : ((t & 0x1F)<<7)) /* Strobe Length */
399 /* Calculate PIO timings */
400 static void m8xx_ide_set_pio_mode(ide_drive_t
*drive
, const u8 pio
)
402 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT)
403 volatile pcmconf8xx_t
*pcmp
;
404 ulong timing
, mask
, reg
;
406 pcmp
= (pcmconf8xx_t
*)(&(((immap_t
*)IMAP_ADDR
)->im_pcmcia
));
408 mask
= ~(PCMCIA_SHT(0xFF) | PCMCIA_SST(0xFF) | PCMCIA_SL(0xFF));
410 timing
= PCMCIA_SHT(hold_time
[pio
] )
411 | PCMCIA_SST(ide_pio_clocks
[pio
].setup_time
)
412 | PCMCIA_SL (ide_pio_clocks
[pio
].active_time
)
416 printk ("Setting timing bits 0x%08lx in PCMCIA controller\n", timing
);
418 if ((reg
= pcmp
->pcmc_por0
& mask
) != 0)
419 pcmp
->pcmc_por0
= reg
| timing
;
421 if ((reg
= pcmp
->pcmc_por1
& mask
) != 0)
422 pcmp
->pcmc_por1
= reg
| timing
;
424 if ((reg
= pcmp
->pcmc_por2
& mask
) != 0)
425 pcmp
->pcmc_por2
= reg
| timing
;
427 if ((reg
= pcmp
->pcmc_por3
& mask
) != 0)
428 pcmp
->pcmc_por3
= reg
| timing
;
430 if ((reg
= pcmp
->pcmc_por4
& mask
) != 0)
431 pcmp
->pcmc_por4
= reg
| timing
;
433 if ((reg
= pcmp
->pcmc_por5
& mask
) != 0)
434 pcmp
->pcmc_por5
= reg
| timing
;
436 if ((reg
= pcmp
->pcmc_por6
& mask
) != 0)
437 pcmp
->pcmc_por6
= reg
| timing
;
439 if ((reg
= pcmp
->pcmc_por7
& mask
) != 0)
440 pcmp
->pcmc_por7
= reg
| timing
;
442 #elif defined(CONFIG_IDE_EXT_DIRECT)
444 printk("%s[%d] %s: not implemented yet!\n",
445 __FILE__
, __LINE__
, __func__
);
446 #endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */
449 static const struct ide_port_ops m8xx_port_ops
= {
450 .set_pio_mode
= m8xx_ide_set_pio_mode
,
454 ide_interrupt_ack (void *dev
)
456 #ifdef CONFIG_IDE_8xx_PCCARD
459 #if (PCMCIA_SOCKETS_NO == 2)
463 /* get interrupt sources */
465 pscr
= ((volatile immap_t
*)IMAP_ADDR
)->im_pcmcia
.pcmc_pscr
;
466 pipr
= ((volatile immap_t
*)IMAP_ADDR
)->im_pcmcia
.pcmc_pipr
;
469 * report only if both card detect signals are the same
471 * we depend on that CD2 is the bit to the left of CD1...
475 printk("PCMCIA slot has not been defined! Using A as default\n");
479 if(((pipr
& M8XX_PCMCIA_CD2(_slot_
)) >> 1) ^
480 (pipr
& M8XX_PCMCIA_CD1(_slot_
)) ) {
481 printk ("card detect interrupt\n");
483 /* clear the interrupt sources */
484 ((immap_t
*)IMAP_ADDR
)->im_pcmcia
.pcmc_pscr
= pscr
;
486 #else /* ! CONFIG_IDE_8xx_PCCARD */
488 * Only CONFIG_IDE_8xx_PCCARD is using the interrupt of the
489 * MPC8xx's PCMCIA controller, so there is nothing to be done here
490 * for CONFIG_IDE_8xx_DIRECT and CONFIG_IDE_EXT_DIRECT.
491 * The interrupt is handled somewhere else. -- Steven
493 #endif /* CONFIG_IDE_8xx_PCCARD */
501 #define CISTPL_NULL 0x00
502 #define CISTPL_DEVICE 0x01
503 #define CISTPL_LONGLINK_CB 0x02
504 #define CISTPL_INDIRECT 0x03
505 #define CISTPL_CONFIG_CB 0x04
506 #define CISTPL_CFTABLE_ENTRY_CB 0x05
507 #define CISTPL_LONGLINK_MFC 0x06
508 #define CISTPL_BAR 0x07
509 #define CISTPL_PWR_MGMNT 0x08
510 #define CISTPL_EXTDEVICE 0x09
511 #define CISTPL_CHECKSUM 0x10
512 #define CISTPL_LONGLINK_A 0x11
513 #define CISTPL_LONGLINK_C 0x12
514 #define CISTPL_LINKTARGET 0x13
515 #define CISTPL_NO_LINK 0x14
516 #define CISTPL_VERS_1 0x15
517 #define CISTPL_ALTSTR 0x16
518 #define CISTPL_DEVICE_A 0x17
519 #define CISTPL_JEDEC_C 0x18
520 #define CISTPL_JEDEC_A 0x19
521 #define CISTPL_CONFIG 0x1a
522 #define CISTPL_CFTABLE_ENTRY 0x1b
523 #define CISTPL_DEVICE_OC 0x1c
524 #define CISTPL_DEVICE_OA 0x1d
525 #define CISTPL_DEVICE_GEO 0x1e
526 #define CISTPL_DEVICE_GEO_A 0x1f
527 #define CISTPL_MANFID 0x20
528 #define CISTPL_FUNCID 0x21
529 #define CISTPL_FUNCE 0x22
530 #define CISTPL_SWIL 0x23
531 #define CISTPL_END 0xff
534 * CIS Function ID codes
536 #define CISTPL_FUNCID_MULTI 0x00
537 #define CISTPL_FUNCID_MEMORY 0x01
538 #define CISTPL_FUNCID_SERIAL 0x02
539 #define CISTPL_FUNCID_PARALLEL 0x03
540 #define CISTPL_FUNCID_FIXED 0x04
541 #define CISTPL_FUNCID_VIDEO 0x05
542 #define CISTPL_FUNCID_NETWORK 0x06
543 #define CISTPL_FUNCID_AIMS 0x07
544 #define CISTPL_FUNCID_SCSI 0x08
547 * Fixed Disk FUNCE codes
549 #define CISTPL_IDE_INTERFACE 0x01
551 #define CISTPL_FUNCE_IDE_IFACE 0x01
552 #define CISTPL_FUNCE_IDE_MASTER 0x02
553 #define CISTPL_FUNCE_IDE_SLAVE 0x03
555 /* First feature byte */
556 #define CISTPL_IDE_SILICON 0x04
557 #define CISTPL_IDE_UNIQUE 0x08
558 #define CISTPL_IDE_DUAL 0x10
560 /* Second feature byte */
561 #define CISTPL_IDE_HAS_SLEEP 0x01
562 #define CISTPL_IDE_HAS_STANDBY 0x02
563 #define CISTPL_IDE_HAS_IDLE 0x04
564 #define CISTPL_IDE_LOW_POWER 0x08
565 #define CISTPL_IDE_REG_INHIBIT 0x10
566 #define CISTPL_IDE_HAS_INDEX 0x20
567 #define CISTPL_IDE_IOIS16 0x40
570 /* -------------------------------------------------------------------- */
573 #define MAX_TUPEL_SZ 512
574 #define MAX_FEATURES 4
576 static int check_ide_device (unsigned long base
)
578 volatile u8
*ident
= NULL
;
579 volatile u8
*feature_p
[MAX_FEATURES
];
580 volatile u8
*p
, *start
;
584 unsigned short config_base
= 0;
589 printk ("PCMCIA MEM: %08lX\n", base
);
591 start
= p
= (volatile u8
*) base
;
593 while ((p
- start
) < MAX_TUPEL_SZ
) {
597 if (code
== 0xFF) { /* End of chain */
603 { volatile u8
*q
= p
;
604 printk ("\nTuple code %02x length %d\n\tData:",
607 for (i
= 0; i
< len
; ++i
) {
608 printk (" %02x", *q
);
612 #endif /* DEBUG_PCMCIA */
621 if (n_features
< MAX_FEATURES
)
622 feature_p
[n_features
++] = p
;
625 config_base
= (*(p
+6) << 8) + (*(p
+4));
632 found
= identify (ident
);
634 if (func_id
!= ((u8
)~0)) {
635 print_funcid (func_id
);
637 if (func_id
== CISTPL_FUNCID_FIXED
)
640 return (1); /* no disk drive */
643 for (i
=0; i
<n_features
; ++i
) {
644 print_fixed (feature_p
[i
]);
648 printk ("unknown card type\n");
652 /* set level mode irq and I/O mapped device in config reg*/
653 *((u8
*)(base
+ config_base
)) = 0x41;
658 /* ------------------------------------------------------------------------- */
660 static void print_funcid (int func
)
663 case CISTPL_FUNCID_MULTI
:
664 printk (" Multi-Function");
666 case CISTPL_FUNCID_MEMORY
:
669 case CISTPL_FUNCID_SERIAL
:
670 printk (" Serial Port");
672 case CISTPL_FUNCID_PARALLEL
:
673 printk (" Parallel Port");
675 case CISTPL_FUNCID_FIXED
:
676 printk (" Fixed Disk");
678 case CISTPL_FUNCID_VIDEO
:
679 printk (" Video Adapter");
681 case CISTPL_FUNCID_NETWORK
:
682 printk (" Network Adapter");
684 case CISTPL_FUNCID_AIMS
:
685 printk (" AIMS Card");
687 case CISTPL_FUNCID_SCSI
:
688 printk (" SCSI Adapter");
697 /* ------------------------------------------------------------------------- */
699 static void print_fixed (volatile u8
*p
)
705 case CISTPL_FUNCE_IDE_IFACE
:
708 printk ((iface
== CISTPL_IDE_INTERFACE
) ? " IDE" : " unknown");
709 printk (" interface ");
712 case CISTPL_FUNCE_IDE_MASTER
:
713 case CISTPL_FUNCE_IDE_SLAVE
:
717 printk ((f1
& CISTPL_IDE_SILICON
) ? " [silicon]" : " [rotating]");
719 if (f1
& CISTPL_IDE_UNIQUE
)
720 printk (" [unique]");
722 printk ((f1
& CISTPL_IDE_DUAL
) ? " [dual]" : " [single]");
724 if (f2
& CISTPL_IDE_HAS_SLEEP
)
727 if (f2
& CISTPL_IDE_HAS_STANDBY
)
728 printk (" [standby]");
730 if (f2
& CISTPL_IDE_HAS_IDLE
)
733 if (f2
& CISTPL_IDE_LOW_POWER
)
734 printk (" [low power]");
736 if (f2
& CISTPL_IDE_REG_INHIBIT
)
737 printk (" [reg inhibit]");
739 if (f2
& CISTPL_IDE_HAS_INDEX
)
742 if (f2
& CISTPL_IDE_IOIS16
)
743 printk (" [IOis16]");
751 /* ------------------------------------------------------------------------- */
754 #define MAX_IDENT_CHARS 64
755 #define MAX_IDENT_FIELDS 4
757 static u8
*known_cards
[] = {
762 static int identify (volatile u8
*p
)
764 u8 id_str
[MAX_IDENT_CHARS
];
771 return (0); /* Don't know */
776 for (i
=0; i
<=4 && !done
; ++i
, p
+=2) {
777 while ((data
= *p
) != '\0') {
783 if (t
== &id_str
[MAX_IDENT_CHARS
-1]) {
793 while (--t
> id_str
) {
799 printk ("Card ID: %s\n", id_str
);
801 for (card
=known_cards
; *card
; ++card
) {
802 if (strcmp(*card
, id_str
) == 0) { /* found! */
807 return (0); /* don't know */
810 static int __init
mpc8xx_ide_probe(void)
813 u8 idx
[4] = { 0xff, 0xff, 0xff, 0xff };
815 #ifdef IDE0_BASE_OFFSET
816 memset(&hw
, 0, sizeof(hw
));
817 if (!m8xx_ide_init_ports(&hw
, 0)) {
818 ide_hwif_t
*hwif
= ide_find_port();
821 ide_init_port_hw(hwif
, &hw
);
822 hwif
->pio_mask
= ATA_PIO4
;
823 hwif
->port_ops
= &m8xx_port_ops
;
825 idx
[0] = hwif
->index
;
828 #ifdef IDE1_BASE_OFFSET
829 memset(&hw
, 0, sizeof(hw
));
830 if (!m8xx_ide_init_ports(&hw
, 1)) {
831 ide_hwif_t
*mate
= ide_find_port();
834 ide_init_port_hw(mate
, &hw
);
835 mate
->pio_mask
= ATA_PIO4
;
836 mate
->port_ops
= &m8xx_port_ops
;
838 idx
[1] = mate
->index
;
844 ide_device_add(idx
, NULL
);
849 module_init(mpc8xx_ide_probe
);
851 MODULE_LICENSE("GPL");