2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 ********************************************************************
25 * Lots of code copied from:
27 * m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series.
28 * (C) 1999-2000 Magnus Damm <damm@bitsmart.com>
30 * "The ExCA standard specifies that socket controllers should provide
31 * two IO and five memory windows per socket, which can be independently
32 * configured and positioned in the host address space and mapped to
33 * arbitrary segments of card address space. " - David A Hinds. 1999
35 * This controller does _not_ meet the ExCA standard.
37 * m8xx pcmcia controller brief info:
38 * + 8 windows (attrib, mem, i/o)
39 * + up to two slots (SLOT_A and SLOT_B)
40 * + inputpins, outputpins, event and mask registers.
41 * - no offset register. sigh.
43 * Because of the lacking offset register we must map the whole card.
44 * We assign each memory window PCMCIA_MEM_WIN_SIZE address space.
45 * Make sure there is (PCMCIA_MEM_WIN_SIZE * PCMCIA_MEM_WIN_NO
46 * * PCMCIA_SOCKETS_NO) bytes at PCMCIA_MEM_WIN_BASE.
47 * The i/o windows are dynamically allocated at PCMCIA_IO_WIN_BASE.
48 * They are maximum 64KByte each...
60 #include <cmd_pcmcia.h>
61 #if defined(CONFIG_IDE_8xx_PCCARD) && defined(CONFIG_8xx)
64 #if defined(CONFIG_LWMON)
68 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
69 ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD))
73 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
74 static int pcmcia_off (void);
75 static int hardware_disable(int slot);
77 static int hardware_enable (int slot);
78 static int voltage_set(int slot, int vcc, int vpp);
79 #ifdef CONFIG_IDE_8xx_PCCARD
80 static void print_funcid (int func);
81 static void print_fixed (volatile uchar *p);
82 static int identify (volatile uchar *p);
83 static int check_ide_device (int slot);
84 #endif /* CONFIG_IDE_8xx_PCCARD */
86 static u_int m8xx_get_graycode(u_int size);
88 static u_int m8xx_get_speed(u_int ns, u_int is_io);
91 /* -------------------------------------------------------------------- */
93 /* look up table for pgcrx registers */
95 static u_int *pcmcia_pgcrx[2] = {
96 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
97 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
100 #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
102 const char *indent = "\t ";
104 /* -------------------------------------------------------------------- */
106 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
108 int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
113 printf ("Usage: pinit {on | off}\n");
116 if (strcmp(argv[1],"on") == 0) {
117 rcode = pcmcia_on ();
118 } else if (strcmp(argv[1],"off") == 0) {
119 rcode = pcmcia_off ();
121 printf ("Usage: pinit {on | off}\n");
127 #endif /* CFG_CMD_PCMCIA */
129 /* -------------------------------------------------------------------- */
131 #if defined(CONFIG_LWMON)
132 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
134 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
145 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
147 /* intialize the fixed memory windows */
148 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
149 base = CFG_PCMCIA_MEM_ADDR;
151 if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
152 printf ("Cannot set window size to 0x%08x\n",
153 CFG_PCMCIA_MEM_SIZE);
157 slotbit = PCMCIA_SLOT_x;
158 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
161 #if (PCMCIA_SOCKETS_NO == 2)
162 if (i == 4) /* Another slot starting from win 4 */
163 slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
166 #ifdef CONFIG_IDE_8xx_PCCARD
168 case 0: { /* map attribute memory */
169 win->or = ( PCMCIA_BSIZE_64M
174 | CFG_PCMCIA_TIMING );
178 case 1: { /* map I/O window for data reg */
179 win->or = ( PCMCIA_BSIZE_1K
184 | CFG_PCMCIA_TIMING );
188 case 2: { /* map I/O window for cmd/ctrl reg block */
189 win->or = ( PCMCIA_BSIZE_1K
194 | CFG_PCMCIA_TIMING );
197 #endif /* CONFIG_IDE_8xx_PCCARD */
198 default: /* set to not valid */
203 debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
204 i, win->br, win->or);
205 base += CFG_PCMCIA_MEM_SIZE;
209 for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
210 /* turn off voltage */
211 if ((rc = voltage_set(slot, 0, 0)))
214 /* Enable external hardware */
215 if ((rc = hardware_enable(slot)))
218 #ifdef CONFIG_IDE_8xx_PCCARD
219 if ((rc = check_ide_device(i)))
226 /* -------------------------------------------------------------------- */
228 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
230 static int pcmcia_off (void)
235 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
237 /* clear interrupt state, and disable interrupts */
238 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
239 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
241 /* turn off interrupt and disable CxOE */
242 PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
244 /* turn off memory windows */
245 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
247 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
248 /* disable memory window */
253 /* turn off voltage */
254 voltage_set(_slot_, 0, 0);
256 /* disable external hardware */
257 printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
258 hardware_disable(_slot_);
262 #endif /* CFG_CMD_PCMCIA */
264 /* -------------------------------------------------------------------- */
266 #ifdef CONFIG_IDE_8xx_PCCARD
268 #define MAX_TUPEL_SZ 512
269 #define MAX_FEATURES 4
271 int ide_devices_found;
272 static int check_ide_device (int slot)
274 volatile uchar *ident = NULL;
275 volatile uchar *feature_p[MAX_FEATURES];
276 volatile uchar *p, *start, *addr;
280 ushort config_base = 0;
284 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
285 CFG_PCMCIA_MEM_SIZE * (slot * 4));
286 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
288 start = p = (volatile uchar *) addr;
290 while ((p - start) < MAX_TUPEL_SZ) {
294 if (code == 0xFF) { /* End of chain */
299 #if defined(DEBUG) && (DEBUG > 1)
300 { volatile uchar *q = p;
301 printf ("\nTuple code %02x length %d\n\tData:",
304 for (i = 0; i < len; ++i) {
305 printf (" %02x", *q);
315 /* Fix for broken SanDisk which may have 0x80 bit set */
319 if (n_features < MAX_FEATURES)
320 feature_p[n_features++] = p;
323 config_base = (*(p+6) << 8) + (*(p+4));
324 debug ("\n## Config_base = %04x ###\n", config_base);
331 found = identify (ident);
333 if (func_id != ((uchar)~0)) {
334 print_funcid (func_id);
336 if (func_id == CISTPL_FUNCID_FIXED)
339 return (1); /* no disk drive */
342 for (i=0; i<n_features; ++i) {
343 print_fixed (feature_p[i]);
347 printf ("unknown card type\n");
351 ide_devices_found |= (1 << slot);
353 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
354 *((uchar *)(addr + config_base)) = 1;
358 #endif /* CONFIG_IDE_8xx_PCCARD */
360 /* -------------------------------------------------------------------- */
363 /* -------------------------------------------------------------------- */
364 /* board specific stuff: */
365 /* voltage_set(), hardware_enable() and hardware_disable() */
366 /* -------------------------------------------------------------------- */
368 /* -------------------------------------------------------------------- */
369 /* RPX Boards from Embedded Planet */
370 /* -------------------------------------------------------------------- */
372 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
374 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
375 * SYPCR is write once only, therefore must the slowest memory be faster
376 * than the bus monitor or we will get a machine check due to the bus timeout.
379 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
381 #undef PCMCIA_BMT_LIMIT
382 #define PCMCIA_BMT_LIMIT (6*8)
384 static int voltage_set(int slot, int vcc, int vpp)
390 case 33: reg |= BCSR1_PCVCTL4; break;
391 case 50: reg |= BCSR1_PCVCTL5; break;
400 reg |= BCSR1_PCVCTL6;
405 reg |= BCSR1_PCVCTL7;
412 /* first, turn off all power */
414 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
415 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
417 /* enable new powersettings */
419 *((uint *)RPX_CSR_ADDR) |= reg;
424 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
425 static int hardware_enable (int slot)
427 return 0; /* No hardware to enable */
429 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
430 static int hardware_disable(int slot)
432 return 0; /* No hardware to disable */
434 #endif /* CFG_CMD_PCMCIA */
435 #endif /* CONFIG_RPXCLASSIC */
437 /* -------------------------------------------------------------------- */
438 /* (F)ADS Boards from Motorola */
439 /* -------------------------------------------------------------------- */
441 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
444 #define PCMCIA_BOARD_MSG "ADS"
445 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
447 #define PCMCIA_BOARD_MSG "FADS"
450 static int voltage_set(int slot, int vcc, int vpp)
455 case 0: reg = 0; break;
456 case 50: reg = 1; break;
457 case 120: reg = 2; break;
462 case 0: reg = 0; break;
464 case 50: reg = BCSR1_PCCVCCON; break;
467 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
468 case 50: reg = BCSR1_PCCVCC1; break;
473 /* first, turn off all power */
476 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
479 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
481 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
483 /* enable new powersettings */
486 *((uint *)BCSR1) &= ~reg;
489 *((uint *)BCSR1) |= reg;
492 *((uint *)BCSR1) |= reg << 20;
497 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
499 static int hardware_enable(int slot)
501 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
505 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
506 static int hardware_disable(int slot)
508 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
511 #endif /* CFG_CMD_PCMCIA */
515 /* -------------------------------------------------------------------- */
516 /* TQM8xxL Boards by TQ Components */
517 /* SC8xx Boards by SinoVee Microsystems */
518 /* -------------------------------------------------------------------- */
520 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)
522 #if defined(CONFIG_TQM8xxL)
523 #define PCMCIA_BOARD_MSG "TQM8xxL"
525 #if defined(CONFIG_SVM_SC8xx)
526 #define PCMCIA_BOARD_MSG "SC8xx"
529 static int hardware_enable(int slot)
531 volatile immap_t *immap;
532 volatile cpm8xx_t *cp;
533 volatile pcmconf8xx_t *pcmp;
534 volatile sysconf8xx_t *sysp;
537 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
541 immap = (immap_t *)CFG_IMMR;
542 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
543 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
544 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
547 * Configure SIUMCR to enable PCMCIA port B
548 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
550 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
552 /* clear interrupt state, and disable interrupts */
553 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
554 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
557 * Disable interrupts, DMA, and PCMCIA buffers
558 * (isolate the interface) and assert RESET signal
560 debug ("Disable PCMCIA buffers and assert RESET\n");
562 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
563 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
564 PCMCIA_PGCRX(_slot_) = reg;
568 * Configure Port C pins for
569 * 5 Volts Enable and 3 Volts enable
571 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
572 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
573 /* remove all power */
575 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
578 * Make sure there is a card in the slot, then configure the interface.
581 debug ("[%d] %s: PIPR(%p)=0x%x\n",
582 __LINE__,__FUNCTION__,
583 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
584 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
585 printf (" No Card found\n");
592 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
593 reg = pcmp->pcmc_pipr;
594 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
596 (reg&PCMCIA_VS1(slot))?"n":"ff",
597 (reg&PCMCIA_VS2(slot))?"n":"ff");
598 if ((reg & mask) == mask) {
599 immap->im_ioport.iop_pcdat |= 0x0004;
600 puts (" 5.0V card found: ");
602 immap->im_ioport.iop_pcdat |= 0x0002;
603 puts (" 3.3V card found: ");
605 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
607 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
608 cp->cp_pbdir &= ~(0x0020 | 0x0010);
609 cp->cp_pbpar &= ~(0x0020 | 0x0010);
613 debug ("Enable PCMCIA buffers and stop RESET\n");
614 reg = PCMCIA_PGCRX(_slot_);
615 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
616 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
617 PCMCIA_PGCRX(_slot_) = reg;
619 udelay(250000); /* some cards need >150 ms to come up :-( */
621 debug ("# hardware_enable done\n");
628 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
629 static int hardware_disable(int slot)
631 volatile immap_t *immap;
632 volatile pcmconf8xx_t *pcmp;
635 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
637 immap = (immap_t *)CFG_IMMR;
638 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
640 /* remove all power */
641 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
643 debug ("Disable PCMCIA buffers and assert RESET\n");
645 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
646 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
647 PCMCIA_PGCRX(_slot_) = reg;
653 #endif /* CFG_CMD_PCMCIA */
657 static int voltage_set(int slot, int vcc, int vpp)
659 volatile immap_t *immap;
660 volatile pcmconf8xx_t *pcmp;
663 debug ("voltage_set: "
665 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
666 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
668 immap = (immap_t *)CFG_IMMR;
669 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
671 * Disable PCMCIA buffers (isolate the interface)
672 * and assert RESET signal
674 debug ("Disable PCMCIA buffers and assert RESET\n");
675 reg = PCMCIA_PGCRX(_slot_);
676 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
677 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
678 PCMCIA_PGCRX(_slot_) = reg;
682 * Configure Port C pins for
683 * 5 Volts Enable and 3 Volts enable,
686 debug ("PCMCIA power OFF\n");
687 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
688 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
689 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
694 case 33: reg |= 0x0002; break;
695 case 50: reg |= 0x0004; break;
699 /* Checking supported voltages */
701 debug ("PIPR: 0x%x --> %s\n",
703 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
705 immap->im_ioport.iop_pcdat |= reg;
706 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
708 debug ("PCMCIA powered at %sV\n",
709 (reg&0x0004) ? "5.0" : "3.3");
711 debug ("PCMCIA powered down\n");
715 debug ("Enable PCMCIA buffers and stop RESET\n");
716 reg = PCMCIA_PGCRX(_slot_);
717 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
718 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
719 PCMCIA_PGCRX(_slot_) = reg;
722 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
730 /* -------------------------------------------------------------------- */
732 /* -------------------------------------------------------------------- */
734 #if defined(CONFIG_LWMON)
736 #define PCMCIA_BOARD_MSG "LWMON"
738 /* #define's for MAX1604 Power Switch */
739 #define MAX1604_OP_SUS 0x80
740 #define MAX1604_VCCBON 0x40
741 #define MAX1604_VCC_35 0x20
742 #define MAX1604_VCCBHIZ 0x10
743 #define MAX1604_VPPBON 0x08
744 #define MAX1604_VPPBPBPGM 0x04
745 #define MAX1604_VPPBHIZ 0x02
748 static int hardware_enable(int slot)
750 volatile immap_t *immap;
751 volatile cpm8xx_t *cp;
752 volatile pcmconf8xx_t *pcmp;
753 volatile sysconf8xx_t *sysp;
758 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
760 /* Switch on PCMCIA port in PIC register 0x60 */
761 reg = pic_read (0x60);
762 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
764 /* reg |= 0x08; Vpp not needed */
765 pic_write (0x60, reg);
767 reg = pic_read (0x60);
768 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
772 immap = (immap_t *)CFG_IMMR;
773 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
774 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
775 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
778 * Configure SIUMCR to enable PCMCIA port B
779 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
781 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
783 /* clear interrupt state, and disable interrupts */
784 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
785 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
788 * Disable interrupts, DMA, and PCMCIA buffers
789 * (isolate the interface) and assert RESET signal
791 debug ("Disable PCMCIA buffers and assert RESET\n");
793 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
794 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
795 PCMCIA_PGCRX(_slot_) = reg;
799 * Make sure there is a card in the slot, then configure the interface.
802 debug ("[%d] %s: PIPR(%p)=0x%x\n",
803 __LINE__,__FUNCTION__,
804 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
805 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
806 printf (" No Card found\n");
813 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
814 reg = pcmp->pcmc_pipr;
815 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
817 (reg&PCMCIA_VS1(slot))?"n":"ff",
818 (reg&PCMCIA_VS2(slot))?"n":"ff");
819 if ((reg & mask) == mask) {
820 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
821 puts (" 5.0V card found: ");
823 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
824 puts (" 3.3V card found: ");
828 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
829 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
830 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
834 debug ("Enable PCMCIA buffers and stop RESET\n");
835 reg = PCMCIA_PGCRX(_slot_);
836 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
837 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
838 PCMCIA_PGCRX(_slot_) = reg;
840 udelay(250000); /* some cards need >150 ms to come up :-( */
842 debug ("# hardware_enable done\n");
849 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
850 static int hardware_disable(int slot)
852 volatile immap_t *immap;
853 volatile pcmconf8xx_t *pcmp;
857 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
859 immap = (immap_t *)CFG_IMMR;
860 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
862 /* remove all power, put output in high impedance state */
863 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
864 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
865 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
867 /* Configure PCMCIA General Control Register */
868 debug ("Disable PCMCIA buffers and assert RESET\n");
870 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
871 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
872 PCMCIA_PGCRX(_slot_) = reg;
874 /* Switch off PCMCIA port in PIC register 0x60 */
875 reg = pic_read (0x60);
876 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
879 pic_write (0x60, reg);
881 reg = pic_read (0x60);
882 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
888 #endif /* CFG_CMD_PCMCIA */
892 static int voltage_set(int slot, int vcc, int vpp)
894 volatile immap_t *immap;
895 volatile pcmconf8xx_t *pcmp;
899 debug ("voltage_set: "
901 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
902 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
904 immap = (immap_t *)CFG_IMMR;
905 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
907 * Disable PCMCIA buffers (isolate the interface)
908 * and assert RESET signal
910 debug ("Disable PCMCIA buffers and assert RESET\n");
911 reg = PCMCIA_PGCRX(_slot_);
912 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
913 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
914 PCMCIA_PGCRX(_slot_) = reg;
918 * Turn off all power (switch to high impedance)
920 debug ("PCMCIA power OFF\n");
921 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
922 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
923 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
928 case 33: val = MAX1604_VCC_35; break;
933 /* Checking supported voltages */
935 debug ("PIPR: 0x%x --> %s\n",
937 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
939 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
941 debug ("PCMCIA powered at %sV\n",
942 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
944 debug ("PCMCIA powered down\n");
948 debug ("Enable PCMCIA buffers and stop RESET\n");
949 reg = PCMCIA_PGCRX(_slot_);
950 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
951 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
952 PCMCIA_PGCRX(_slot_) = reg;
955 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
962 /* -------------------------------------------------------------------- */
963 /* GTH board by Corelatus AB */
964 /* -------------------------------------------------------------------- */
965 #if defined(CONFIG_GTH)
967 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
969 static int voltage_set (int slot, int vcc, int vpp)
974 static int hardware_enable (int slot)
976 volatile immap_t *immap;
977 volatile cpm8xx_t *cp;
978 volatile pcmconf8xx_t *pcmp;
979 volatile sysconf8xx_t *sysp;
982 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
984 immap = (immap_t *) CFG_IMMR;
985 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
986 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
987 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
989 /* clear interrupt state, and disable interrupts */
990 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
991 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
994 * Disable interrupts, DMA, and PCMCIA buffers
995 * (isolate the interface) and assert RESET signal
997 debug ("Disable PCMCIA buffers and assert RESET\n");
999 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1000 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1001 PCMCIA_PGCRX (_slot_) = reg;
1005 * Make sure there is a card in the slot,
1006 * then configure the interface.
1009 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1010 __LINE__, __FUNCTION__,
1011 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1012 if (pcmp->pcmc_pipr & 0x98000000) {
1013 printf (" No Card found\n");
1017 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1018 reg = pcmp->pcmc_pipr;
1019 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1021 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1022 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1024 debug ("Enable PCMCIA buffers and stop RESET\n");
1025 reg = PCMCIA_PGCRX (_slot_);
1026 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1027 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1028 PCMCIA_PGCRX (_slot_) = reg;
1030 udelay (250000); /* some cards need >150 ms to come up :-( */
1032 debug ("# hardware_enable done\n");
1036 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1037 static int hardware_disable(int slot)
1039 return 0; /* No hardware to disable */
1041 #endif /* CFG_CMD_PCMCIA */
1042 #endif /* CONFIG_GTH */
1044 /* -------------------------------------------------------------------- */
1045 /* ICU862 Boards by Cambridge Broadband Ltd. */
1046 /* -------------------------------------------------------------------- */
1048 #if defined(CONFIG_ICU862)
1050 #define PCMCIA_BOARD_MSG "ICU862"
1052 static void cfg_port_B (void);
1054 static int hardware_enable(int slot)
1056 volatile immap_t *immap;
1057 volatile cpm8xx_t *cp;
1058 volatile pcmconf8xx_t *pcmp;
1059 volatile sysconf8xx_t *sysp;
1060 uint reg, pipr, mask;
1063 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1067 immap = (immap_t *)CFG_IMMR;
1068 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1069 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1070 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1072 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1076 * Configure SIUMCR to enable PCMCIA port B
1077 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1079 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1081 /* clear interrupt state, and disable interrupts */
1082 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1083 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1086 * Disable interrupts, DMA, and PCMCIA buffers
1087 * (isolate the interface) and assert RESET signal
1089 debug ("Disable PCMCIA buffers and assert RESET\n");
1091 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1092 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1093 PCMCIA_PGCRX(_slot_) = reg;
1097 * Make sure there is a card in the slot, then configure the interface.
1100 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1101 __LINE__,__FUNCTION__,
1102 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1103 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1104 printf (" No Card found\n");
1109 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1111 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1112 pipr = pcmp->pcmc_pipr;
1113 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1115 (reg&PCMCIA_VS1(slot))?"n":"ff",
1116 (reg&PCMCIA_VS2(slot))?"n":"ff");
1119 if ((pipr & mask) == mask) {
1120 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1121 TPS2205_VCC3); /* 3V off */
1122 reg &= ~(TPS2205_VCC5); /* 5V on */
1123 puts (" 5.0V card found: ");
1125 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1126 TPS2205_VCC5); /* 5V off */
1127 reg &= ~(TPS2205_VCC3); /* 3V on */
1128 puts (" 3.3V card found: ");
1131 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1133 (reg & TPS2205_VCC3) ? "off" : "on",
1134 (reg & TPS2205_VCC5) ? "off" : "on",
1135 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1136 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1140 /* Wait 500 ms; use this to check for over-current */
1141 for (i=0; i<5000; ++i) {
1142 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1143 printf (" *** Overcurrent - Safety shutdown ***\n");
1144 cp->cp_pbdat &= ~(TPS2205_SHDN);
1150 debug ("Enable PCMCIA buffers and stop RESET\n");
1151 reg = PCMCIA_PGCRX(_slot_);
1152 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1153 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1154 PCMCIA_PGCRX(_slot_) = reg;
1156 udelay(250000); /* some cards need >150 ms to come up :-( */
1158 debug ("# hardware_enable done\n");
1165 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1166 static int hardware_disable(int slot)
1168 volatile immap_t *immap;
1169 volatile cpm8xx_t *cp;
1170 volatile pcmconf8xx_t *pcmp;
1173 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1175 immap = (immap_t *)CFG_IMMR;
1176 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1177 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1180 cp->cp_pbdat &= ~(TPS2205_SHDN);
1182 /* Configure PCMCIA General Control Register */
1183 debug ("Disable PCMCIA buffers and assert RESET\n");
1185 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1186 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1187 PCMCIA_PGCRX(_slot_) = reg;
1193 #endif /* CFG_CMD_PCMCIA */
1197 static int voltage_set(int slot, int vcc, int vpp)
1199 volatile immap_t *immap;
1200 volatile cpm8xx_t *cp;
1201 volatile pcmconf8xx_t *pcmp;
1204 debug ("voltage_set: "
1206 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1207 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1209 immap = (immap_t *)CFG_IMMR;
1210 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1211 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1213 * Disable PCMCIA buffers (isolate the interface)
1214 * and assert RESET signal
1216 debug ("Disable PCMCIA buffers and assert RESET\n");
1217 reg = PCMCIA_PGCRX(_slot_);
1218 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1219 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1220 PCMCIA_PGCRX(_slot_) = reg;
1224 * Configure Port C pins for
1225 * 5 Volts Enable and 3 Volts enable,
1226 * Turn all power pins to Hi-Z
1228 debug ("PCMCIA power OFF\n");
1229 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1234 case 0: break; /* Switch off */
1235 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1236 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1240 /* Checking supported voltages */
1242 debug ("PIPR: 0x%x --> %s\n",
1244 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1252 if ((reg & TPS2205_VCC3) == 0) {
1254 } else if ((reg & TPS2205_VCC5) == 0) {
1259 printf ("PCMCIA powered %s\n", s);
1264 debug ("Enable PCMCIA buffers and stop RESET\n");
1265 reg = PCMCIA_PGCRX(_slot_);
1266 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1267 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1268 PCMCIA_PGCRX(_slot_) = reg;
1271 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1276 static void cfg_port_B (void)
1278 volatile immap_t *immap;
1279 volatile cpm8xx_t *cp;
1282 immap = (immap_t *)CFG_IMMR;
1283 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1286 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1288 * Switch off all voltages, assert shutdown
1291 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1292 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1293 TPS2205_SHDN); /* enable switch */
1296 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1298 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1299 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1301 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1302 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1308 /* -------------------------------------------------------------------- */
1309 /* C2MON Boards by TTTech Computertechnik AG */
1310 /* -------------------------------------------------------------------- */
1312 #if defined(CONFIG_C2MON)
1314 #define PCMCIA_BOARD_MSG "C2MON"
1316 static void cfg_ports (void);
1318 static int hardware_enable(int slot)
1320 volatile immap_t *immap;
1321 volatile cpm8xx_t *cp;
1322 volatile pcmconf8xx_t *pcmp;
1323 volatile sysconf8xx_t *sysp;
1324 uint reg, pipr, mask;
1328 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1332 immap = (immap_t *)CFG_IMMR;
1333 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1334 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1335 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1337 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1341 * Configure SIUMCR to enable PCMCIA port B
1342 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1344 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1346 /* clear interrupt state, and disable interrupts */
1347 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1348 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1351 * Disable interrupts, DMA, and PCMCIA buffers
1352 * (isolate the interface) and assert RESET signal
1354 debug ("Disable PCMCIA buffers and assert RESET\n");
1356 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1357 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1358 PCMCIA_PGCRX(_slot_) = reg;
1362 * Make sure there is a card in the slot, then configure the interface.
1365 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1366 __LINE__,__FUNCTION__,
1367 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1368 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1369 printf (" No Card found\n");
1374 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1376 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1377 pipr = pcmp->pcmc_pipr;
1378 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1380 (reg&PCMCIA_VS1(slot))?"n":"ff",
1381 (reg&PCMCIA_VS2(slot))?"n":"ff");
1383 sreg = immap->im_ioport.iop_pcdat;
1384 if ((pipr & mask) == mask) {
1385 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1386 TPS2211_VCCD1); /* 5V on */
1387 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1388 puts (" 5.0V card found: ");
1390 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1391 TPS2211_VCCD0); /* 3V on */
1392 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1393 puts (" 3.3V card found: ");
1396 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1398 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1399 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1402 immap->im_ioport.iop_pcdat = sreg;
1404 /* Wait 500 ms; use this to check for over-current */
1405 for (i=0; i<5000; ++i) {
1406 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1407 printf (" *** Overcurrent - Safety shutdown ***\n");
1408 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1414 debug ("Enable PCMCIA buffers and stop RESET\n");
1415 reg = PCMCIA_PGCRX(_slot_);
1416 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1417 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1418 PCMCIA_PGCRX(_slot_) = reg;
1420 udelay(250000); /* some cards need >150 ms to come up :-( */
1422 debug ("# hardware_enable done\n");
1429 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1430 static int hardware_disable(int slot)
1432 volatile immap_t *immap;
1433 volatile cpm8xx_t *cp;
1434 volatile pcmconf8xx_t *pcmp;
1437 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1439 immap = (immap_t *)CFG_IMMR;
1440 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1442 /* Configure PCMCIA General Control Register */
1443 debug ("Disable PCMCIA buffers and assert RESET\n");
1445 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1446 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1447 PCMCIA_PGCRX(_slot_) = reg;
1449 /* ALl voltages off / Hi-Z */
1450 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1451 TPS2211_VCCD0 | TPS2211_VCCD1 );
1457 #endif /* CFG_CMD_PCMCIA */
1461 static int voltage_set(int slot, int vcc, int vpp)
1463 volatile immap_t *immap;
1464 volatile cpm8xx_t *cp;
1465 volatile pcmconf8xx_t *pcmp;
1469 debug ("voltage_set: "
1471 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1472 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1474 immap = (immap_t *)CFG_IMMR;
1475 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1476 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1478 * Disable PCMCIA buffers (isolate the interface)
1479 * and assert RESET signal
1481 debug ("Disable PCMCIA buffers and assert RESET\n");
1482 reg = PCMCIA_PGCRX(_slot_);
1483 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1484 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1485 PCMCIA_PGCRX(_slot_) = reg;
1489 * Configure Port C pins for
1490 * 5 Volts Enable and 3 Volts enable,
1491 * Turn all power pins to Hi-Z
1493 debug ("PCMCIA power OFF\n");
1494 cfg_ports (); /* Enables switch, but all in Hi-Z */
1496 sreg = immap->im_ioport.iop_pcdat;
1497 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1500 case 0: break; /* Switch off */
1501 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1502 sreg &= ~TPS2211_VCCD1;
1504 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1505 sreg |= TPS2211_VCCD1;
1510 /* Checking supported voltages */
1512 debug ("PIPR: 0x%x --> %s\n",
1514 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1516 immap->im_ioport.iop_pcdat = sreg;
1522 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1524 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1529 printf ("PCMCIA powered %s\n", s);
1534 debug ("Enable PCMCIA buffers and stop RESET\n");
1535 reg = PCMCIA_PGCRX(_slot_);
1536 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1537 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1538 PCMCIA_PGCRX(_slot_) = reg;
1541 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1546 static void cfg_ports (void)
1548 volatile immap_t *immap;
1549 volatile cpm8xx_t *cp;
1552 immap = (immap_t *)CFG_IMMR;
1553 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1556 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1558 * Switch off all voltages, assert shutdown
1560 sreg = immap->im_ioport.iop_pcdat;
1561 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1562 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1563 immap->im_ioport.iop_pcdat = sreg;
1565 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1566 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1568 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1569 immap->im_ioport.iop_pcpar,
1570 immap->im_ioport.iop_pcdir,
1571 immap->im_ioport.iop_pcdat);
1574 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1576 * Over-Current Input only
1578 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1579 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1581 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1582 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1587 /* -------------------------------------------------------------------- */
1588 /* MBX board from Morotola */
1589 /* -------------------------------------------------------------------- */
1591 #if defined( CONFIG_MBX )
1592 #include <../board/mbx8xx/csr.h>
1594 /* A lot of this has been taken from the RPX code in this file it works from me.
1595 I have added the voltage selection for the MBX board. */
1597 /* MBX voltage bit in control register #2 */
1598 #define CR2_VPP12 ((uchar)0x10)
1599 #define CR2_VPPVDD ((uchar)0x20)
1600 #define CR2_VDD5 ((uchar)0x40)
1601 #define CR2_VDD3 ((uchar)0x80)
1603 #define PCMCIA_BOARD_MSG "MBX860"
1605 static int voltage_set (int slot, int vcc, int vpp)
1609 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1610 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1643 /* first, turn off all power */
1644 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1646 /* enable new powersettings */
1648 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1653 static int hardware_enable (int slot)
1655 volatile immap_t *immap;
1656 volatile cpm8xx_t *cp;
1657 volatile pcmconf8xx_t *pcmp;
1658 volatile sysconf8xx_t *sysp;
1661 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1666 immap = (immap_t *) CFG_IMMR;
1667 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1668 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1669 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1671 /* clear interrupt state, and disable interrupts */
1672 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1673 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1676 * Disable interrupts, DMA, and PCMCIA buffers
1677 * (isolate the interface) and assert RESET signal
1679 debug ("Disable PCMCIA buffers and assert RESET\n");
1681 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1682 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1683 PCMCIA_PGCRX (_slot_) = reg;
1686 /* remove all power */
1687 voltage_set (slot, 0, 0);
1689 * Make sure there is a card in the slot, then configure the interface.
1692 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1693 __LINE__,__FUNCTION__,
1694 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1695 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1696 printf (" No Card found\n");
1703 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1704 reg = pcmp->pcmc_pipr;
1705 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1706 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1707 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1709 if ((reg & mask) == mask) {
1710 voltage_set (_slot_, 50, 0);
1711 printf (" 5.0V card found: ");
1713 voltage_set (_slot_, 33, 0);
1714 printf (" 3.3V card found: ");
1717 debug ("Enable PCMCIA buffers and stop RESET\n");
1718 reg = PCMCIA_PGCRX (_slot_);
1719 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1720 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1721 PCMCIA_PGCRX (_slot_) = reg;
1723 udelay (250000); /* some cards need >150 ms to come up :-( */
1725 debug ("# hardware_enable done\n");
1730 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1731 static int hardware_disable (int slot)
1733 return 0; /* No hardware to disable */
1735 #endif /* CFG_CMD_PCMCIA */
1736 #endif /* CONFIG_MBX */
1737 /* -------------------------------------------------------------------- */
1739 /* -------------------------------------------------------------------- */
1741 #if defined(CONFIG_R360MPI)
1743 #define PCMCIA_BOARD_MSG "R360MPI"
1746 static int hardware_enable(int slot)
1748 volatile immap_t *immap;
1749 volatile cpm8xx_t *cp;
1750 volatile pcmconf8xx_t *pcmp;
1751 volatile sysconf8xx_t *sysp;
1754 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1758 immap = (immap_t *)CFG_IMMR;
1759 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1760 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1761 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1764 * Configure SIUMCR to enable PCMCIA port B
1765 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1767 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1769 /* clear interrupt state, and disable interrupts */
1770 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1771 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1774 * Disable interrupts, DMA, and PCMCIA buffers
1775 * (isolate the interface) and assert RESET signal
1777 debug ("Disable PCMCIA buffers and assert RESET\n");
1779 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1780 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1781 PCMCIA_PGCRX(_slot_) = reg;
1785 * Configure Ports A, B & C pins for
1786 * 5 Volts Enable and 3 Volts enable
1788 immap->im_ioport.iop_pcpar &= ~(0x0400);
1789 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1790 immap->im_ioport.iop_pcdir |= 0x0400;*/
1792 immap->im_ioport.iop_papar &= ~(0x0200);/*
1793 immap->im_ioport.iop_padir |= 0x0200;*/
1795 immap->im_ioport.iop_pbpar &= ~(0xC000);
1796 immap->im_ioport.iop_pbdir &= ~(0xC000);
1798 /* remove all power */
1800 immap->im_ioport.iop_pcdat |= 0x0400;
1801 immap->im_ioport.iop_padat |= 0x0200;
1804 * Make sure there is a card in the slot, then configure the interface.
1807 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1808 __LINE__,__FUNCTION__,
1809 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1810 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1811 printf (" No Card found\n");
1818 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1819 reg = pcmp->pcmc_pipr;
1820 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1822 (reg&PCMCIA_VS1(slot))?"n":"ff",
1823 (reg&PCMCIA_VS2(slot))?"n":"ff");
1824 if ((reg & mask) == mask) {
1825 immap->im_ioport.iop_pcdat &= ~(0x4000);
1826 puts (" 5.0V card found: ");
1828 immap->im_ioport.iop_padat &= ~(0x0002);
1829 puts (" 3.3V card found: ");
1831 immap->im_ioport.iop_pcdir |= 0x0400;
1832 immap->im_ioport.iop_padir |= 0x0200;
1834 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
1835 cp->cp_pbdir &= ~(0x0020 | 0x0010);
1836 cp->cp_pbpar &= ~(0x0020 | 0x0010);
1839 debug ("Enable PCMCIA buffers and stop RESET\n");
1840 reg = PCMCIA_PGCRX(_slot_);
1841 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1842 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1843 PCMCIA_PGCRX(_slot_) = reg;
1845 udelay(250000); /* some cards need >150 ms to come up :-( */
1847 debug ("# hardware_enable done\n");
1854 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1855 static int hardware_disable(int slot)
1857 volatile immap_t *immap;
1858 volatile pcmconf8xx_t *pcmp;
1861 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1863 immap = (immap_t *)CFG_IMMR;
1864 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1866 /* remove all power */
1867 immap->im_ioport.iop_pcdat |= 0x0400;
1868 immap->im_ioport.iop_padat |= 0x0200;
1870 /* Configure PCMCIA General Control Register */
1871 debug ("Disable PCMCIA buffers and assert RESET\n");
1873 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1874 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1875 PCMCIA_PGCRX(_slot_) = reg;
1881 #endif /* CFG_CMD_PCMCIA */
1885 static int voltage_set(int slot, int vcc, int vpp)
1887 volatile immap_t *immap;
1888 volatile pcmconf8xx_t *pcmp;
1891 debug ("voltage_set: "
1893 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1894 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1896 immap = (immap_t *)CFG_IMMR;
1897 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1899 * Disable PCMCIA buffers (isolate the interface)
1900 * and assert RESET signal
1902 debug ("Disable PCMCIA buffers and assert RESET\n");
1903 reg = PCMCIA_PGCRX(_slot_);
1904 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1905 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1906 PCMCIA_PGCRX(_slot_) = reg;
1910 * Configure Ports A & C pins for
1911 * 5 Volts Enable and 3 Volts enable,
1912 * Turn off all power
1914 debug ("PCMCIA power OFF\n");
1915 immap->im_ioport.iop_pcpar &= ~(0x0400);
1916 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1917 immap->im_ioport.iop_pcdir |= 0x0400;*/
1919 immap->im_ioport.iop_papar &= ~(0x0200);/*
1920 immap->im_ioport.iop_padir |= 0x0200;*/
1922 immap->im_ioport.iop_pcdat |= 0x0400;
1923 immap->im_ioport.iop_padat |= 0x0200;
1928 case 33: reg |= 0x0200; break;
1929 case 50: reg |= 0x0400; break;
1933 /* Checking supported voltages */
1935 debug ("PIPR: 0x%x --> %s\n",
1937 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1940 immap->im_ioport.iop_pcdat &= !reg;
1942 immap->im_ioport.iop_padat &= !reg;
1943 immap->im_ioport.iop_pcdir |= 0x0200;
1944 immap->im_ioport.iop_padir |= 0x0400;
1946 debug ("PCMCIA powered at %sV\n",
1947 (reg&0x0400) ? "5.0" : "3.3");
1949 debug ("PCMCIA powered down\n");
1953 debug ("Enable PCMCIA buffers and stop RESET\n");
1954 reg = PCMCIA_PGCRX(_slot_);
1955 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1956 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1957 PCMCIA_PGCRX(_slot_) = reg;
1960 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1965 #endif /* R360MPI */
1967 /* -------------------------------------------------------------------- */
1969 /* -------------------------------------------------------------------- */
1970 #if defined(CONFIG_KUP4K)
1972 #define PCMCIA_BOARD_MSG "KUP4K"
1974 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
1976 static int hardware_enable(int slot)
1978 volatile immap_t *immap;
1979 volatile cpm8xx_t *cp;
1980 volatile pcmconf8xx_t *pcmp;
1981 volatile sysconf8xx_t *sysp;
1984 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1988 immap = (immap_t *)CFG_IMMR;
1989 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1990 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1991 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1994 * Configure SIUMCR to enable PCMCIA port B
1995 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1997 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1999 /* clear interrupt state, and disable interrupts */
2000 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2001 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2004 * Disable interrupts, DMA, and PCMCIA buffers
2005 * (isolate the interface) and assert RESET signal
2007 debug ("Disable PCMCIA buffers and assert RESET\n");
2009 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2010 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2011 PCMCIA_PGCRX(slot) = reg;
2015 * Configure Port B pins for
2018 if (slot) { /* Slot A is built-in */
2019 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2020 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2021 /* remove all power */
2022 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2025 * Make sure there is a card in the slot, then configure the interface.
2028 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2029 __LINE__,__FUNCTION__,
2030 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2031 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2032 printf (" No Card found\n");
2039 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2040 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2041 reg = pcmp->pcmc_pipr;
2042 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2044 (reg&PCMCIA_VS1(slot))?"n":"ff",
2045 (reg&PCMCIA_VS2(slot))?"n":"ff");
2046 if ((reg & mask) == mask) {
2047 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2050 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2051 puts (" 3.3V card found: ");
2054 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2055 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2056 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2059 debug ("Enable PCMCIA buffers and stop RESET\n");
2060 reg = PCMCIA_PGCRX(slot);
2061 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2062 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2063 PCMCIA_PGCRX(slot) = reg;
2065 udelay(250000); /* some cards need >150 ms to come up :-( */
2067 debug ("# hardware_enable done\n");
2074 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2075 static int hardware_disable(int slot)
2077 volatile immap_t *immap;
2078 volatile cpm8xx_t *cp;
2079 volatile pcmconf8xx_t *pcmp;
2082 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2084 immap = (immap_t *)CFG_IMMR;
2085 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2086 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2088 /* remove all power */
2090 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2092 /* Configure PCMCIA General Control Register */
2093 debug ("Disable PCMCIA buffers and assert RESET\n");
2095 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2096 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2097 PCMCIA_PGCRX(slot) = reg;
2103 #endif /* CFG_CMD_PCMCIA */
2107 static int voltage_set(int slot, int vcc, int vpp)
2109 volatile immap_t *immap;
2110 volatile cpm8xx_t *cp;
2111 volatile pcmconf8xx_t *pcmp;
2114 debug ("voltage_set: " \
2116 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2117 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2119 if (!slot) /* Slot A is not configurable */
2122 immap = (immap_t *)CFG_IMMR;
2123 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2124 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2127 * Disable PCMCIA buffers (isolate the interface)
2128 * and assert RESET signal
2130 debug ("Disable PCMCIA buffers and assert RESET\n");
2131 reg = PCMCIA_PGCRX(slot);
2132 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2133 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2134 PCMCIA_PGCRX(slot) = reg;
2137 debug ("PCMCIA power OFF\n");
2139 * Configure Port B pins for
2142 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2143 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2144 /* remove all power */
2145 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2150 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2151 debug ("PCMCIA powered at 3.3V\n");
2154 debug ("PCMCIA: 5Volt vcc not supported\n");
2157 puts("PCMCIA: vcc not supported");
2161 /* Checking supported voltages */
2163 debug ("PIPR: 0x%x --> %s\n",
2165 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2166 ? "only 5 V --> NOT SUPPORTED"
2170 debug ("Enable PCMCIA buffers and stop RESET\n");
2171 reg = PCMCIA_PGCRX(slot);
2172 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2173 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2174 PCMCIA_PGCRX(slot) = reg;
2177 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2188 /* -------------------------------------------------------------------- */
2189 /* End of Board Specific Stuff */
2190 /* -------------------------------------------------------------------- */
2193 /* -------------------------------------------------------------------- */
2194 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2195 /* -------------------------------------------------------------------- */
2198 * Search this table to see if the windowsize is
2202 #define M8XX_SIZES_NO 32
2204 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2205 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2206 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2207 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2208 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2210 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2211 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2212 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2213 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2216 /* -------------------------------------------------------------------- */
2218 static u_int m8xx_get_graycode(u_int size)
2222 for (k = 0; k < M8XX_SIZES_NO; k++) {
2223 if(m8xx_size_to_gray[k] == size)
2227 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2233 /* -------------------------------------------------------------------- */
2236 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2238 u_int reg, clocks, psst, psl, psht;
2243 * We get called with IO maps setup to 0ns
2244 * if not specified by the user.
2245 * They should be 255ns.
2251 ns = 100; /* fast memory if 0 */
2255 * In PSST, PSL, PSHT fields we tell the controller
2256 * timing parameters in CLKOUT clock cycles.
2257 * CLKOUT is the same as GCLK2_50.
2260 /* how we want to adjust the timing - in percent */
2262 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2264 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2265 clocks = (clocks * ADJ) / (100*1000);
2267 if(clocks >= PCMCIA_BMT_LIMIT) {
2268 DEBUG(0, "Max access time limit reached\n");
2269 clocks = PCMCIA_BMT_LIMIT-1;
2272 psst = clocks / 7; /* setup time */
2273 psht = clocks / 7; /* hold time */
2274 psl = (clocks * 5) / 7; /* strobe length */
2276 psst += clocks - (psst + psht + psl);
2286 /* -------------------------------------------------------------------- */
2288 #ifdef CONFIG_IDE_8xx_PCCARD
2289 static void print_funcid (int func)
2293 case CISTPL_FUNCID_MULTI:
2294 puts (" Multi-Function");
2296 case CISTPL_FUNCID_MEMORY:
2299 case CISTPL_FUNCID_SERIAL:
2300 puts (" Serial Port");
2302 case CISTPL_FUNCID_PARALLEL:
2303 puts (" Parallel Port");
2305 case CISTPL_FUNCID_FIXED:
2306 puts (" Fixed Disk");
2308 case CISTPL_FUNCID_VIDEO:
2309 puts (" Video Adapter");
2311 case CISTPL_FUNCID_NETWORK:
2312 puts (" Network Adapter");
2314 case CISTPL_FUNCID_AIMS:
2315 puts (" AIMS Card");
2317 case CISTPL_FUNCID_SCSI:
2318 puts (" SCSI Adapter");
2326 #endif /* CONFIG_IDE_8xx_PCCARD */
2328 /* -------------------------------------------------------------------- */
2330 #ifdef CONFIG_IDE_8xx_PCCARD
2331 static void print_fixed (volatile uchar *p)
2339 case CISTPL_FUNCE_IDE_IFACE:
2340 { uchar iface = *(p+2);
2342 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2343 puts (" interface ");
2346 case CISTPL_FUNCE_IDE_MASTER:
2347 case CISTPL_FUNCE_IDE_SLAVE:
2348 { uchar f1 = *(p+2);
2351 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2353 if (f1 & CISTPL_IDE_UNIQUE)
2356 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2358 if (f2 & CISTPL_IDE_HAS_SLEEP)
2361 if (f2 & CISTPL_IDE_HAS_STANDBY)
2362 puts (" [standby]");
2364 if (f2 & CISTPL_IDE_HAS_IDLE)
2367 if (f2 & CISTPL_IDE_LOW_POWER)
2368 puts (" [low power]");
2370 if (f2 & CISTPL_IDE_REG_INHIBIT)
2371 puts (" [reg inhibit]");
2373 if (f2 & CISTPL_IDE_HAS_INDEX)
2376 if (f2 & CISTPL_IDE_IOIS16)
2384 #endif /* CONFIG_IDE_8xx_PCCARD */
2386 /* -------------------------------------------------------------------- */
2388 #ifdef CONFIG_IDE_8xx_PCCARD
2390 #define MAX_IDENT_CHARS 64
2391 #define MAX_IDENT_FIELDS 4
2393 static uchar *known_cards[] = {
2398 static int identify (volatile uchar *p)
2400 uchar id_str[MAX_IDENT_CHARS];
2407 return (0); /* Don't know */
2412 for (i=0; i<=4 && !done; ++i, p+=2) {
2413 while ((data = *p) != '\0') {
2419 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2429 while (--t > id_str) {
2438 for (card=known_cards; *card; ++card) {
2439 debug ("## Compare against \"%s\"\n", *card);
2440 if (strcmp(*card, id_str) == 0) { /* found! */
2441 debug ("## CARD FOUND ##\n");
2446 return (0); /* don't know */
2448 #endif /* CONFIG_IDE_8xx_PCCARD */
2450 /* -------------------------------------------------------------------- */
2452 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */