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 #if defined(CONFIG_IDE_8xx_PCCARD) && defined(CONFIG_8xx)
63 #if defined(CONFIG_LWMON)
67 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
68 ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD))
72 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
73 static int pcmcia_off (void);
78 extern int i82365_init (void);
79 extern void i82365_exit (void);
81 #else /* ! CONFIG_I82365 */
83 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
84 static int hardware_disable(int slot);
86 static int hardware_enable (int slot);
87 static int voltage_set(int slot, int vcc, int vpp);
90 static u_int m8xx_get_graycode(u_int size);
91 #endif /* CONFIG_I82365 */
93 static u_int m8xx_get_speed(u_int ns, u_int is_io);
96 /* -------------------------------------------------------------------- */
98 /* look up table for pgcrx registers */
100 static u_int *pcmcia_pgcrx[2] = {
101 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
102 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
105 #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
107 #endif /* CONFIG_I82365 */
109 #ifdef CONFIG_IDE_8xx_PCCARD
110 static void print_funcid (int func);
111 static void print_fixed (volatile uchar *p);
112 static int identify (volatile uchar *p);
113 static int check_ide_device (int slot);
114 #endif /* CONFIG_IDE_8xx_PCCARD */
116 const char *indent = "\t ";
118 /* -------------------------------------------------------------------- */
120 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
122 int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
127 printf ("Usage: pinit {on | off}\n");
130 if (strcmp(argv[1],"on") == 0) {
131 rcode = pcmcia_on ();
132 } else if (strcmp(argv[1],"off") == 0) {
133 rcode = pcmcia_off ();
135 printf ("Usage: pinit {on | off}\n");
141 #endif /* CFG_CMD_PCMCIA */
143 /* -------------------------------------------------------------------- */
150 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
156 rc = check_ide_device(0);
163 #if defined(CONFIG_LWMON)
164 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
166 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
177 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
179 /* intialize the fixed memory windows */
180 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
181 base = CFG_PCMCIA_MEM_ADDR;
183 if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
184 printf ("Cannot set window size to 0x%08x\n",
185 CFG_PCMCIA_MEM_SIZE);
189 slotbit = PCMCIA_SLOT_x;
190 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
193 #if (PCMCIA_SOCKETS_NO == 2)
194 if (i == 4) /* Another slot starting from win 4 */
195 slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
198 #ifdef CONFIG_IDE_8xx_PCCARD
200 case 0: { /* map attribute memory */
201 win->or = ( PCMCIA_BSIZE_64M
206 | CFG_PCMCIA_TIMING );
210 case 1: { /* map I/O window for data reg */
211 win->or = ( PCMCIA_BSIZE_1K
216 | CFG_PCMCIA_TIMING );
220 case 2: { /* map I/O window for cmd/ctrl reg block */
221 win->or = ( PCMCIA_BSIZE_1K
226 | CFG_PCMCIA_TIMING );
229 #endif /* CONFIG_IDE_8xx_PCCARD */
230 default: /* set to not valid */
235 debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
236 i, win->br, win->or);
237 base += CFG_PCMCIA_MEM_SIZE;
241 for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
242 /* turn off voltage */
243 if ((rc = voltage_set(slot, 0, 0)))
246 /* Enable external hardware */
247 if ((rc = hardware_enable(slot)))
250 #ifdef CONFIG_IDE_8xx_PCCARD
251 if ((rc = check_ide_device(i)))
257 #endif /* CONFIG_I82365 */
259 /* -------------------------------------------------------------------- */
261 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
264 static int pcmcia_off (void)
266 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
273 static int pcmcia_off (void)
278 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
280 /* clear interrupt state, and disable interrupts */
281 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
282 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
284 /* turn off interrupt and disable CxOE */
285 PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
287 /* turn off memory windows */
288 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
290 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
291 /* disable memory window */
296 /* turn off voltage */
297 voltage_set(_slot_, 0, 0);
299 /* disable external hardware */
300 printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
301 hardware_disable(_slot_);
304 #endif /* CONFIG_I82365 */
306 #endif /* CFG_CMD_PCMCIA */
308 /* -------------------------------------------------------------------- */
310 #ifdef CONFIG_IDE_8xx_PCCARD
312 #define MAX_TUPEL_SZ 512
313 #define MAX_FEATURES 4
315 int ide_devices_found;
316 static int check_ide_device (int slot)
318 volatile uchar *ident = NULL;
319 volatile uchar *feature_p[MAX_FEATURES];
320 volatile uchar *p, *start, *addr;
324 ushort config_base = 0;
328 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
329 CFG_PCMCIA_MEM_SIZE * (slot * 4));
330 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
332 start = p = (volatile uchar *) addr;
334 while ((p - start) < MAX_TUPEL_SZ) {
338 if (code == 0xFF) { /* End of chain */
343 #if defined(DEBUG) && (DEBUG > 1)
344 { volatile uchar *q = p;
345 printf ("\nTuple code %02x length %d\n\tData:",
348 for (i = 0; i < len; ++i) {
349 printf (" %02x", *q);
359 /* Fix for broken SanDisk which may have 0x80 bit set */
363 if (n_features < MAX_FEATURES)
364 feature_p[n_features++] = p;
367 config_base = (*(p+6) << 8) + (*(p+4));
368 debug ("\n## Config_base = %04x ###\n", config_base);
375 found = identify (ident);
377 if (func_id != ((uchar)~0)) {
378 print_funcid (func_id);
380 if (func_id == CISTPL_FUNCID_FIXED)
383 return (1); /* no disk drive */
386 for (i=0; i<n_features; ++i) {
387 print_fixed (feature_p[i]);
391 printf ("unknown card type\n");
395 ide_devices_found |= (1 << slot);
397 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
398 *((uchar *)(addr + config_base)) = 1;
402 #endif /* CONFIG_IDE_8xx_PCCARD */
404 /* -------------------------------------------------------------------- */
407 /* -------------------------------------------------------------------- */
408 /* board specific stuff: */
409 /* voltage_set(), hardware_enable() and hardware_disable() */
410 /* -------------------------------------------------------------------- */
412 /* -------------------------------------------------------------------- */
413 /* RPX Boards from Embedded Planet */
414 /* -------------------------------------------------------------------- */
416 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
418 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
419 * SYPCR is write once only, therefore must the slowest memory be faster
420 * than the bus monitor or we will get a machine check due to the bus timeout.
423 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
425 #undef PCMCIA_BMT_LIMIT
426 #define PCMCIA_BMT_LIMIT (6*8)
428 static int voltage_set(int slot, int vcc, int vpp)
434 case 33: reg |= BCSR1_PCVCTL4; break;
435 case 50: reg |= BCSR1_PCVCTL5; break;
444 reg |= BCSR1_PCVCTL6;
449 reg |= BCSR1_PCVCTL7;
456 /* first, turn off all power */
458 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
459 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
461 /* enable new powersettings */
463 *((uint *)RPX_CSR_ADDR) |= reg;
468 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
469 static int hardware_enable (int slot)
471 return 0; /* No hardware to enable */
473 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
474 static int hardware_disable(int slot)
476 return 0; /* No hardware to disable */
478 #endif /* CFG_CMD_PCMCIA */
479 #endif /* CONFIG_RPXCLASSIC */
481 /* -------------------------------------------------------------------- */
482 /* (F)ADS Boards from Motorola */
483 /* -------------------------------------------------------------------- */
485 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
488 #define PCMCIA_BOARD_MSG "ADS"
489 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
491 #define PCMCIA_BOARD_MSG "FADS"
494 static int voltage_set(int slot, int vcc, int vpp)
499 case 0: reg = 0; break;
500 case 50: reg = 1; break;
501 case 120: reg = 2; break;
506 case 0: reg = 0; break;
508 case 50: reg = BCSR1_PCCVCCON; break;
511 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
512 case 50: reg = BCSR1_PCCVCC1; break;
517 /* first, turn off all power */
520 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
523 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
525 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
527 /* enable new powersettings */
530 *((uint *)BCSR1) &= ~reg;
533 *((uint *)BCSR1) |= reg;
536 *((uint *)BCSR1) |= reg << 20;
541 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
543 static int hardware_enable(int slot)
545 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
549 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
550 static int hardware_disable(int slot)
552 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
555 #endif /* CFG_CMD_PCMCIA */
559 /* -------------------------------------------------------------------- */
560 /* TQM8xxL Boards by TQ Components */
561 /* SC8xx Boards by SinoVee Microsystems */
562 /* -------------------------------------------------------------------- */
564 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)
566 #if defined(CONFIG_TQM8xxL)
567 #define PCMCIA_BOARD_MSG "TQM8xxL"
569 #if defined(CONFIG_SVM_SC8xx)
570 #define PCMCIA_BOARD_MSG "SC8xx"
573 static int hardware_enable(int slot)
575 volatile immap_t *immap;
576 volatile cpm8xx_t *cp;
577 volatile pcmconf8xx_t *pcmp;
578 volatile sysconf8xx_t *sysp;
581 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
585 immap = (immap_t *)CFG_IMMR;
586 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
587 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
588 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
591 * Configure SIUMCR to enable PCMCIA port B
592 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
594 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
596 /* clear interrupt state, and disable interrupts */
597 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
598 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
601 * Disable interrupts, DMA, and PCMCIA buffers
602 * (isolate the interface) and assert RESET signal
604 debug ("Disable PCMCIA buffers and assert RESET\n");
606 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
607 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
608 PCMCIA_PGCRX(_slot_) = reg;
612 * Configure Port C pins for
613 * 5 Volts Enable and 3 Volts enable
615 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
616 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
617 /* remove all power */
619 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
622 * Make sure there is a card in the slot, then configure the interface.
625 debug ("[%d] %s: PIPR(%p)=0x%x\n",
626 __LINE__,__FUNCTION__,
627 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
628 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
629 printf (" No Card found\n");
636 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
637 reg = pcmp->pcmc_pipr;
638 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
640 (reg&PCMCIA_VS1(slot))?"n":"ff",
641 (reg&PCMCIA_VS2(slot))?"n":"ff");
642 if ((reg & mask) == mask) {
643 immap->im_ioport.iop_pcdat |= 0x0004;
644 puts (" 5.0V card found: ");
646 immap->im_ioport.iop_pcdat |= 0x0002;
647 puts (" 3.3V card found: ");
649 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
651 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
652 cp->cp_pbdir &= ~(0x0020 | 0x0010);
653 cp->cp_pbpar &= ~(0x0020 | 0x0010);
657 debug ("Enable PCMCIA buffers and stop RESET\n");
658 reg = PCMCIA_PGCRX(_slot_);
659 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
660 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
661 PCMCIA_PGCRX(_slot_) = reg;
663 udelay(250000); /* some cards need >150 ms to come up :-( */
665 debug ("# hardware_enable done\n");
671 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
672 static int hardware_disable(int slot)
674 volatile immap_t *immap;
675 volatile pcmconf8xx_t *pcmp;
678 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
680 immap = (immap_t *)CFG_IMMR;
681 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
683 /* remove all power */
684 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
686 debug ("Disable PCMCIA buffers and assert RESET\n");
688 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
689 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
690 PCMCIA_PGCRX(_slot_) = reg;
696 #endif /* CFG_CMD_PCMCIA */
699 static int voltage_set(int slot, int vcc, int vpp)
701 volatile immap_t *immap;
702 volatile pcmconf8xx_t *pcmp;
705 debug ("voltage_set: "
707 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
708 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
710 immap = (immap_t *)CFG_IMMR;
711 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
713 * Disable PCMCIA buffers (isolate the interface)
714 * and assert RESET signal
716 debug ("Disable PCMCIA buffers and assert RESET\n");
717 reg = PCMCIA_PGCRX(_slot_);
718 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
719 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
720 PCMCIA_PGCRX(_slot_) = reg;
724 * Configure Port C pins for
725 * 5 Volts Enable and 3 Volts enable,
728 debug ("PCMCIA power OFF\n");
729 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
730 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
731 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
736 case 33: reg |= 0x0002; break;
737 case 50: reg |= 0x0004; break;
741 /* Checking supported voltages */
743 debug ("PIPR: 0x%x --> %s\n",
745 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
747 immap->im_ioport.iop_pcdat |= reg;
748 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
750 debug ("PCMCIA powered at %sV\n",
751 (reg&0x0004) ? "5.0" : "3.3");
753 debug ("PCMCIA powered down\n");
757 debug ("Enable PCMCIA buffers and stop RESET\n");
758 reg = PCMCIA_PGCRX(_slot_);
759 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
760 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
761 PCMCIA_PGCRX(_slot_) = reg;
764 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
772 /* -------------------------------------------------------------------- */
774 /* -------------------------------------------------------------------- */
776 #if defined(CONFIG_LWMON)
778 #define PCMCIA_BOARD_MSG "LWMON"
780 /* #define's for MAX1604 Power Switch */
781 #define MAX1604_OP_SUS 0x80
782 #define MAX1604_VCCBON 0x40
783 #define MAX1604_VCC_35 0x20
784 #define MAX1604_VCCBHIZ 0x10
785 #define MAX1604_VPPBON 0x08
786 #define MAX1604_VPPBPBPGM 0x04
787 #define MAX1604_VPPBHIZ 0x02
790 static int hardware_enable(int slot)
792 volatile immap_t *immap;
793 volatile cpm8xx_t *cp;
794 volatile pcmconf8xx_t *pcmp;
795 volatile sysconf8xx_t *sysp;
800 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
802 /* Switch on PCMCIA port in PIC register 0x60 */
803 reg = pic_read (0x60);
804 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
806 /* reg |= 0x08; Vpp not needed */
807 pic_write (0x60, reg);
809 reg = pic_read (0x60);
810 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
814 immap = (immap_t *)CFG_IMMR;
815 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
816 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
817 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
820 * Configure SIUMCR to enable PCMCIA port B
821 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
823 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
825 /* clear interrupt state, and disable interrupts */
826 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
827 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
830 * Disable interrupts, DMA, and PCMCIA buffers
831 * (isolate the interface) and assert RESET signal
833 debug ("Disable PCMCIA buffers and assert RESET\n");
835 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
836 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
837 PCMCIA_PGCRX(_slot_) = reg;
841 * Make sure there is a card in the slot, then configure the interface.
844 debug ("[%d] %s: PIPR(%p)=0x%x\n",
845 __LINE__,__FUNCTION__,
846 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
847 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
848 printf (" No Card found\n");
855 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
856 reg = pcmp->pcmc_pipr;
857 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
859 (reg&PCMCIA_VS1(slot))?"n":"ff",
860 (reg&PCMCIA_VS2(slot))?"n":"ff");
861 if ((reg & mask) == mask) {
862 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
863 puts (" 5.0V card found: ");
865 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
866 puts (" 3.3V card found: ");
870 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
871 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
872 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
876 debug ("Enable PCMCIA buffers and stop RESET\n");
877 reg = PCMCIA_PGCRX(_slot_);
878 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
879 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
880 PCMCIA_PGCRX(_slot_) = reg;
882 udelay(250000); /* some cards need >150 ms to come up :-( */
884 debug ("# hardware_enable done\n");
890 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
891 static int hardware_disable(int slot)
893 volatile immap_t *immap;
894 volatile pcmconf8xx_t *pcmp;
898 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
900 immap = (immap_t *)CFG_IMMR;
901 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
903 /* remove all power, put output in high impedance state */
904 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
905 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
906 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
908 /* Configure PCMCIA General Control Register */
909 debug ("Disable PCMCIA buffers and assert RESET\n");
911 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
912 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
913 PCMCIA_PGCRX(_slot_) = reg;
915 /* Switch off PCMCIA port in PIC register 0x60 */
916 reg = pic_read (0x60);
917 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
920 pic_write (0x60, reg);
922 reg = pic_read (0x60);
923 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
929 #endif /* CFG_CMD_PCMCIA */
932 static int voltage_set(int slot, int vcc, int vpp)
934 volatile immap_t *immap;
935 volatile pcmconf8xx_t *pcmp;
939 debug ("voltage_set: "
941 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
942 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
944 immap = (immap_t *)CFG_IMMR;
945 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
947 * Disable PCMCIA buffers (isolate the interface)
948 * and assert RESET signal
950 debug ("Disable PCMCIA buffers and assert RESET\n");
951 reg = PCMCIA_PGCRX(_slot_);
952 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
953 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
954 PCMCIA_PGCRX(_slot_) = reg;
958 * Turn off all power (switch to high impedance)
960 debug ("PCMCIA power OFF\n");
961 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
962 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
963 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
968 case 33: val = MAX1604_VCC_35; break;
973 /* Checking supported voltages */
975 debug ("PIPR: 0x%x --> %s\n",
977 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
979 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
981 debug ("PCMCIA powered at %sV\n",
982 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
984 debug ("PCMCIA powered down\n");
988 debug ("Enable PCMCIA buffers and stop RESET\n");
989 reg = PCMCIA_PGCRX(_slot_);
990 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
991 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
992 PCMCIA_PGCRX(_slot_) = reg;
995 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1002 /* -------------------------------------------------------------------- */
1003 /* GTH board by Corelatus AB */
1004 /* -------------------------------------------------------------------- */
1005 #if defined(CONFIG_GTH)
1007 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
1009 static int voltage_set (int slot, int vcc, int vpp)
1014 static int hardware_enable (int slot)
1016 volatile immap_t *immap;
1017 volatile cpm8xx_t *cp;
1018 volatile pcmconf8xx_t *pcmp;
1019 volatile sysconf8xx_t *sysp;
1022 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
1024 immap = (immap_t *) CFG_IMMR;
1025 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1026 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1027 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1029 /* clear interrupt state, and disable interrupts */
1030 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1031 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1034 * Disable interrupts, DMA, and PCMCIA buffers
1035 * (isolate the interface) and assert RESET signal
1037 debug ("Disable PCMCIA buffers and assert RESET\n");
1039 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1040 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1041 PCMCIA_PGCRX (_slot_) = reg;
1045 * Make sure there is a card in the slot,
1046 * then configure the interface.
1049 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1050 __LINE__, __FUNCTION__,
1051 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1052 if (pcmp->pcmc_pipr & 0x98000000) {
1053 printf (" No Card found\n");
1057 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1058 reg = pcmp->pcmc_pipr;
1059 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1061 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1062 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1064 debug ("Enable PCMCIA buffers and stop RESET\n");
1065 reg = PCMCIA_PGCRX (_slot_);
1066 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1067 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1068 PCMCIA_PGCRX (_slot_) = reg;
1070 udelay (250000); /* some cards need >150 ms to come up :-( */
1072 debug ("# hardware_enable done\n");
1076 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1077 static int hardware_disable(int slot)
1079 return 0; /* No hardware to disable */
1081 #endif /* CFG_CMD_PCMCIA */
1082 #endif /* CONFIG_GTH */
1084 /* -------------------------------------------------------------------- */
1085 /* ICU862 Boards by Cambridge Broadband Ltd. */
1086 /* -------------------------------------------------------------------- */
1088 #if defined(CONFIG_ICU862)
1090 #define PCMCIA_BOARD_MSG "ICU862"
1092 static void cfg_port_B (void);
1094 static int hardware_enable(int slot)
1096 volatile immap_t *immap;
1097 volatile cpm8xx_t *cp;
1098 volatile pcmconf8xx_t *pcmp;
1099 volatile sysconf8xx_t *sysp;
1100 uint reg, pipr, mask;
1103 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1107 immap = (immap_t *)CFG_IMMR;
1108 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1109 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1110 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1112 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1116 * Configure SIUMCR to enable PCMCIA port B
1117 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1119 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1121 /* clear interrupt state, and disable interrupts */
1122 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1123 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1126 * Disable interrupts, DMA, and PCMCIA buffers
1127 * (isolate the interface) and assert RESET signal
1129 debug ("Disable PCMCIA buffers and assert RESET\n");
1131 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1132 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1133 PCMCIA_PGCRX(_slot_) = reg;
1137 * Make sure there is a card in the slot, then configure the interface.
1140 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1141 __LINE__,__FUNCTION__,
1142 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1143 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1144 printf (" No Card found\n");
1149 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1151 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1152 pipr = pcmp->pcmc_pipr;
1153 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1155 (reg&PCMCIA_VS1(slot))?"n":"ff",
1156 (reg&PCMCIA_VS2(slot))?"n":"ff");
1159 if ((pipr & mask) == mask) {
1160 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1161 TPS2205_VCC3); /* 3V off */
1162 reg &= ~(TPS2205_VCC5); /* 5V on */
1163 puts (" 5.0V card found: ");
1165 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1166 TPS2205_VCC5); /* 5V off */
1167 reg &= ~(TPS2205_VCC3); /* 3V on */
1168 puts (" 3.3V card found: ");
1171 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1173 (reg & TPS2205_VCC3) ? "off" : "on",
1174 (reg & TPS2205_VCC5) ? "off" : "on",
1175 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1176 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1180 /* Wait 500 ms; use this to check for over-current */
1181 for (i=0; i<5000; ++i) {
1182 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1183 printf (" *** Overcurrent - Safety shutdown ***\n");
1184 cp->cp_pbdat &= ~(TPS2205_SHDN);
1190 debug ("Enable PCMCIA buffers and stop RESET\n");
1191 reg = PCMCIA_PGCRX(_slot_);
1192 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1193 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1194 PCMCIA_PGCRX(_slot_) = reg;
1196 udelay(250000); /* some cards need >150 ms to come up :-( */
1198 debug ("# hardware_enable done\n");
1204 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1205 static int hardware_disable(int slot)
1207 volatile immap_t *immap;
1208 volatile cpm8xx_t *cp;
1209 volatile pcmconf8xx_t *pcmp;
1212 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1214 immap = (immap_t *)CFG_IMMR;
1215 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1216 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1219 cp->cp_pbdat &= ~(TPS2205_SHDN);
1221 /* Configure PCMCIA General Control Register */
1222 debug ("Disable PCMCIA buffers and assert RESET\n");
1224 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1225 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1226 PCMCIA_PGCRX(_slot_) = reg;
1232 #endif /* CFG_CMD_PCMCIA */
1235 static int voltage_set(int slot, int vcc, int vpp)
1237 volatile immap_t *immap;
1238 volatile cpm8xx_t *cp;
1239 volatile pcmconf8xx_t *pcmp;
1242 debug ("voltage_set: "
1244 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1245 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1247 immap = (immap_t *)CFG_IMMR;
1248 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1249 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1251 * Disable PCMCIA buffers (isolate the interface)
1252 * and assert RESET signal
1254 debug ("Disable PCMCIA buffers and assert RESET\n");
1255 reg = PCMCIA_PGCRX(_slot_);
1256 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1257 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1258 PCMCIA_PGCRX(_slot_) = reg;
1262 * Configure Port C pins for
1263 * 5 Volts Enable and 3 Volts enable,
1264 * Turn all power pins to Hi-Z
1266 debug ("PCMCIA power OFF\n");
1267 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1272 case 0: break; /* Switch off */
1273 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1274 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1278 /* Checking supported voltages */
1280 debug ("PIPR: 0x%x --> %s\n",
1282 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1290 if ((reg & TPS2205_VCC3) == 0) {
1292 } else if ((reg & TPS2205_VCC5) == 0) {
1297 printf ("PCMCIA powered %s\n", s);
1302 debug ("Enable PCMCIA buffers and stop RESET\n");
1303 reg = PCMCIA_PGCRX(_slot_);
1304 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1305 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1306 PCMCIA_PGCRX(_slot_) = reg;
1309 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1314 static void cfg_port_B (void)
1316 volatile immap_t *immap;
1317 volatile cpm8xx_t *cp;
1320 immap = (immap_t *)CFG_IMMR;
1321 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1324 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1326 * Switch off all voltages, assert shutdown
1329 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1330 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1331 TPS2205_SHDN); /* enable switch */
1334 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1336 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1337 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1339 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1340 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1346 /* -------------------------------------------------------------------- */
1347 /* C2MON Boards by TTTech Computertechnik AG */
1348 /* -------------------------------------------------------------------- */
1350 #if defined(CONFIG_C2MON)
1352 #define PCMCIA_BOARD_MSG "C2MON"
1354 static void cfg_ports (void);
1356 static int hardware_enable(int slot)
1358 volatile immap_t *immap;
1359 volatile cpm8xx_t *cp;
1360 volatile pcmconf8xx_t *pcmp;
1361 volatile sysconf8xx_t *sysp;
1362 uint reg, pipr, mask;
1366 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1370 immap = (immap_t *)CFG_IMMR;
1371 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1372 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1373 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1375 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1379 * Configure SIUMCR to enable PCMCIA port B
1380 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1382 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1384 /* clear interrupt state, and disable interrupts */
1385 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1386 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1389 * Disable interrupts, DMA, and PCMCIA buffers
1390 * (isolate the interface) and assert RESET signal
1392 debug ("Disable PCMCIA buffers and assert RESET\n");
1394 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1395 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1396 PCMCIA_PGCRX(_slot_) = reg;
1400 * Make sure there is a card in the slot, then configure the interface.
1403 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1404 __LINE__,__FUNCTION__,
1405 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1406 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1407 printf (" No Card found\n");
1412 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1414 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1415 pipr = pcmp->pcmc_pipr;
1416 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1418 (reg&PCMCIA_VS1(slot))?"n":"ff",
1419 (reg&PCMCIA_VS2(slot))?"n":"ff");
1421 sreg = immap->im_ioport.iop_pcdat;
1422 if ((pipr & mask) == mask) {
1423 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1424 TPS2211_VCCD1); /* 5V on */
1425 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1426 puts (" 5.0V card found: ");
1428 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1429 TPS2211_VCCD0); /* 3V on */
1430 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1431 puts (" 3.3V card found: ");
1434 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1436 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1437 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1440 immap->im_ioport.iop_pcdat = sreg;
1442 /* Wait 500 ms; use this to check for over-current */
1443 for (i=0; i<5000; ++i) {
1444 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1445 printf (" *** Overcurrent - Safety shutdown ***\n");
1446 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1452 debug ("Enable PCMCIA buffers and stop RESET\n");
1453 reg = PCMCIA_PGCRX(_slot_);
1454 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1455 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1456 PCMCIA_PGCRX(_slot_) = reg;
1458 udelay(250000); /* some cards need >150 ms to come up :-( */
1460 debug ("# hardware_enable done\n");
1466 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1467 static int hardware_disable(int slot)
1469 volatile immap_t *immap;
1470 volatile cpm8xx_t *cp;
1471 volatile pcmconf8xx_t *pcmp;
1474 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1476 immap = (immap_t *)CFG_IMMR;
1477 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1479 /* Configure PCMCIA General Control Register */
1480 debug ("Disable PCMCIA buffers and assert RESET\n");
1482 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1483 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1484 PCMCIA_PGCRX(_slot_) = reg;
1486 /* ALl voltages off / Hi-Z */
1487 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1488 TPS2211_VCCD0 | TPS2211_VCCD1 );
1494 #endif /* CFG_CMD_PCMCIA */
1497 static int voltage_set(int slot, int vcc, int vpp)
1499 volatile immap_t *immap;
1500 volatile cpm8xx_t *cp;
1501 volatile pcmconf8xx_t *pcmp;
1505 debug ("voltage_set: "
1507 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1508 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1510 immap = (immap_t *)CFG_IMMR;
1511 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1512 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1514 * Disable PCMCIA buffers (isolate the interface)
1515 * and assert RESET signal
1517 debug ("Disable PCMCIA buffers and assert RESET\n");
1518 reg = PCMCIA_PGCRX(_slot_);
1519 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1520 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1521 PCMCIA_PGCRX(_slot_) = reg;
1525 * Configure Port C pins for
1526 * 5 Volts Enable and 3 Volts enable,
1527 * Turn all power pins to Hi-Z
1529 debug ("PCMCIA power OFF\n");
1530 cfg_ports (); /* Enables switch, but all in Hi-Z */
1532 sreg = immap->im_ioport.iop_pcdat;
1533 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1536 case 0: break; /* Switch off */
1537 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1538 sreg &= ~TPS2211_VCCD1;
1540 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1541 sreg |= TPS2211_VCCD1;
1546 /* Checking supported voltages */
1548 debug ("PIPR: 0x%x --> %s\n",
1550 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1552 immap->im_ioport.iop_pcdat = sreg;
1558 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1560 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1565 printf ("PCMCIA powered %s\n", s);
1570 debug ("Enable PCMCIA buffers and stop RESET\n");
1571 reg = PCMCIA_PGCRX(_slot_);
1572 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1573 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1574 PCMCIA_PGCRX(_slot_) = reg;
1577 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1582 static void cfg_ports (void)
1584 volatile immap_t *immap;
1585 volatile cpm8xx_t *cp;
1588 immap = (immap_t *)CFG_IMMR;
1589 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1592 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1594 * Switch off all voltages, assert shutdown
1596 sreg = immap->im_ioport.iop_pcdat;
1597 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1598 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1599 immap->im_ioport.iop_pcdat = sreg;
1601 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1602 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1604 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1605 immap->im_ioport.iop_pcpar,
1606 immap->im_ioport.iop_pcdir,
1607 immap->im_ioport.iop_pcdat);
1610 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1612 * Over-Current Input only
1614 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1615 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1617 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1618 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1623 /* -------------------------------------------------------------------- */
1624 /* MBX board from Morotola */
1625 /* -------------------------------------------------------------------- */
1627 #if defined( CONFIG_MBX )
1628 #include <../board/mbx8xx/csr.h>
1630 /* A lot of this has been taken from the RPX code in this file it works from me.
1631 I have added the voltage selection for the MBX board. */
1633 /* MBX voltage bit in control register #2 */
1634 #define CR2_VPP12 ((uchar)0x10)
1635 #define CR2_VPPVDD ((uchar)0x20)
1636 #define CR2_VDD5 ((uchar)0x40)
1637 #define CR2_VDD3 ((uchar)0x80)
1639 #define PCMCIA_BOARD_MSG "MBX860"
1641 static int voltage_set (int slot, int vcc, int vpp)
1645 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1646 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1679 /* first, turn off all power */
1680 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1682 /* enable new powersettings */
1684 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1689 static int hardware_enable (int slot)
1691 volatile immap_t *immap;
1692 volatile cpm8xx_t *cp;
1693 volatile pcmconf8xx_t *pcmp;
1694 volatile sysconf8xx_t *sysp;
1697 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1702 immap = (immap_t *) CFG_IMMR;
1703 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1704 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1705 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1707 /* clear interrupt state, and disable interrupts */
1708 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1709 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1712 * Disable interrupts, DMA, and PCMCIA buffers
1713 * (isolate the interface) and assert RESET signal
1715 debug ("Disable PCMCIA buffers and assert RESET\n");
1717 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1718 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1719 PCMCIA_PGCRX (_slot_) = reg;
1722 /* remove all power */
1723 voltage_set (slot, 0, 0);
1725 * Make sure there is a card in the slot, then configure the interface.
1728 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1729 __LINE__,__FUNCTION__,
1730 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1731 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1732 printf (" No Card found\n");
1739 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1740 reg = pcmp->pcmc_pipr;
1741 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1742 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1743 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1745 if ((reg & mask) == mask) {
1746 voltage_set (_slot_, 50, 0);
1747 printf (" 5.0V card found: ");
1749 voltage_set (_slot_, 33, 0);
1750 printf (" 3.3V card found: ");
1753 debug ("Enable PCMCIA buffers and stop RESET\n");
1754 reg = PCMCIA_PGCRX (_slot_);
1755 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1756 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1757 PCMCIA_PGCRX (_slot_) = reg;
1759 udelay (250000); /* some cards need >150 ms to come up :-( */
1761 debug ("# hardware_enable done\n");
1766 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1767 static int hardware_disable (int slot)
1769 return 0; /* No hardware to disable */
1771 #endif /* CFG_CMD_PCMCIA */
1772 #endif /* CONFIG_MBX */
1773 /* -------------------------------------------------------------------- */
1775 /* -------------------------------------------------------------------- */
1777 #if defined(CONFIG_R360MPI)
1779 #define PCMCIA_BOARD_MSG "R360MPI"
1782 static int hardware_enable(int slot)
1784 volatile immap_t *immap;
1785 volatile cpm8xx_t *cp;
1786 volatile pcmconf8xx_t *pcmp;
1787 volatile sysconf8xx_t *sysp;
1790 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1794 immap = (immap_t *)CFG_IMMR;
1795 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1796 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1797 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1800 * Configure SIUMCR to enable PCMCIA port B
1801 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1803 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1805 /* clear interrupt state, and disable interrupts */
1806 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1807 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1810 * Disable interrupts, DMA, and PCMCIA buffers
1811 * (isolate the interface) and assert RESET signal
1813 debug ("Disable PCMCIA buffers and assert RESET\n");
1815 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1816 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1817 PCMCIA_PGCRX(_slot_) = reg;
1821 * Configure Ports A, B & C pins for
1822 * 5 Volts Enable and 3 Volts enable
1824 immap->im_ioport.iop_pcpar &= ~(0x0400);
1825 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1826 immap->im_ioport.iop_pcdir |= 0x0400;*/
1828 immap->im_ioport.iop_papar &= ~(0x0200);/*
1829 immap->im_ioport.iop_padir |= 0x0200;*/
1831 immap->im_ioport.iop_pbpar &= ~(0xC000);
1832 immap->im_ioport.iop_pbdir &= ~(0xC000);
1834 /* remove all power */
1836 immap->im_ioport.iop_pcdat |= 0x0400;
1837 immap->im_ioport.iop_padat |= 0x0200;
1840 * Make sure there is a card in the slot, then configure the interface.
1843 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1844 __LINE__,__FUNCTION__,
1845 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1846 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1847 printf (" No Card found\n");
1854 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1855 reg = pcmp->pcmc_pipr;
1856 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1858 (reg&PCMCIA_VS1(slot))?"n":"ff",
1859 (reg&PCMCIA_VS2(slot))?"n":"ff");
1860 if ((reg & mask) == mask) {
1861 immap->im_ioport.iop_pcdat &= ~(0x4000);
1862 puts (" 5.0V card found: ");
1864 immap->im_ioport.iop_padat &= ~(0x0002);
1865 puts (" 3.3V card found: ");
1867 immap->im_ioport.iop_pcdir |= 0x0400;
1868 immap->im_ioport.iop_padir |= 0x0200;
1870 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
1871 cp->cp_pbdir &= ~(0x0020 | 0x0010);
1872 cp->cp_pbpar &= ~(0x0020 | 0x0010);
1875 debug ("Enable PCMCIA buffers and stop RESET\n");
1876 reg = PCMCIA_PGCRX(_slot_);
1877 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1878 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1879 PCMCIA_PGCRX(_slot_) = reg;
1881 udelay(250000); /* some cards need >150 ms to come up :-( */
1883 debug ("# hardware_enable done\n");
1889 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1890 static int hardware_disable(int slot)
1892 volatile immap_t *immap;
1893 volatile pcmconf8xx_t *pcmp;
1896 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1898 immap = (immap_t *)CFG_IMMR;
1899 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1901 /* remove all power */
1902 immap->im_ioport.iop_pcdat |= 0x0400;
1903 immap->im_ioport.iop_padat |= 0x0200;
1905 /* Configure PCMCIA General Control Register */
1906 debug ("Disable PCMCIA buffers and assert RESET\n");
1908 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1909 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1910 PCMCIA_PGCRX(_slot_) = reg;
1916 #endif /* CFG_CMD_PCMCIA */
1919 static int voltage_set(int slot, int vcc, int vpp)
1921 volatile immap_t *immap;
1922 volatile pcmconf8xx_t *pcmp;
1925 debug ("voltage_set: "
1927 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1928 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1930 immap = (immap_t *)CFG_IMMR;
1931 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1933 * Disable PCMCIA buffers (isolate the interface)
1934 * and assert RESET signal
1936 debug ("Disable PCMCIA buffers and assert RESET\n");
1937 reg = PCMCIA_PGCRX(_slot_);
1938 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1939 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1940 PCMCIA_PGCRX(_slot_) = reg;
1944 * Configure Ports A & C pins for
1945 * 5 Volts Enable and 3 Volts enable,
1946 * Turn off all power
1948 debug ("PCMCIA power OFF\n");
1949 immap->im_ioport.iop_pcpar &= ~(0x0400);
1950 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1951 immap->im_ioport.iop_pcdir |= 0x0400;*/
1953 immap->im_ioport.iop_papar &= ~(0x0200);/*
1954 immap->im_ioport.iop_padir |= 0x0200;*/
1956 immap->im_ioport.iop_pcdat |= 0x0400;
1957 immap->im_ioport.iop_padat |= 0x0200;
1962 case 33: reg |= 0x0200; break;
1963 case 50: reg |= 0x0400; break;
1967 /* Checking supported voltages */
1969 debug ("PIPR: 0x%x --> %s\n",
1971 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1974 immap->im_ioport.iop_pcdat &= !reg;
1976 immap->im_ioport.iop_padat &= !reg;
1977 immap->im_ioport.iop_pcdir |= 0x0200;
1978 immap->im_ioport.iop_padir |= 0x0400;
1980 debug ("PCMCIA powered at %sV\n",
1981 (reg&0x0400) ? "5.0" : "3.3");
1983 debug ("PCMCIA powered down\n");
1987 debug ("Enable PCMCIA buffers and stop RESET\n");
1988 reg = PCMCIA_PGCRX(_slot_);
1989 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1990 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1991 PCMCIA_PGCRX(_slot_) = reg;
1994 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1999 #endif /* R360MPI */
2001 /* -------------------------------------------------------------------- */
2003 /* -------------------------------------------------------------------- */
2004 #if defined(CONFIG_KUP4K)
2006 #define PCMCIA_BOARD_MSG "KUP4K"
2008 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
2010 static int hardware_enable(int slot)
2012 volatile immap_t *immap;
2013 volatile cpm8xx_t *cp;
2014 volatile pcmconf8xx_t *pcmp;
2015 volatile sysconf8xx_t *sysp;
2018 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2022 immap = (immap_t *)CFG_IMMR;
2023 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2024 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2025 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2028 * Configure SIUMCR to enable PCMCIA port B
2029 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2031 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2033 /* clear interrupt state, and disable interrupts */
2034 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2035 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2038 * Disable interrupts, DMA, and PCMCIA buffers
2039 * (isolate the interface) and assert RESET signal
2041 debug ("Disable PCMCIA buffers and assert RESET\n");
2043 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2044 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2045 PCMCIA_PGCRX(slot) = reg;
2049 * Configure Port B pins for
2052 if (slot) { /* Slot A is built-in */
2053 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2054 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2055 /* remove all power */
2056 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2059 * Make sure there is a card in the slot, then configure the interface.
2062 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2063 __LINE__,__FUNCTION__,
2064 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2065 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2066 printf (" No Card found\n");
2073 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2074 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2075 reg = pcmp->pcmc_pipr;
2076 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2078 (reg&PCMCIA_VS1(slot))?"n":"ff",
2079 (reg&PCMCIA_VS2(slot))?"n":"ff");
2080 if ((reg & mask) == mask) {
2081 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2084 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2085 puts (" 3.3V card found: ");
2088 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2089 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2090 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2093 debug ("Enable PCMCIA buffers and stop RESET\n");
2094 reg = PCMCIA_PGCRX(slot);
2095 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2096 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2097 PCMCIA_PGCRX(slot) = reg;
2099 udelay(250000); /* some cards need >150 ms to come up :-( */
2101 debug ("# hardware_enable done\n");
2107 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2108 static int hardware_disable(int slot)
2110 volatile immap_t *immap;
2111 volatile cpm8xx_t *cp;
2112 volatile pcmconf8xx_t *pcmp;
2115 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2117 immap = (immap_t *)CFG_IMMR;
2118 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2119 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2121 /* remove all power */
2123 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2125 /* Configure PCMCIA General Control Register */
2126 debug ("Disable PCMCIA buffers and assert RESET\n");
2128 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2129 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2130 PCMCIA_PGCRX(slot) = reg;
2136 #endif /* CFG_CMD_PCMCIA */
2139 static int voltage_set(int slot, int vcc, int vpp)
2141 volatile immap_t *immap;
2142 volatile cpm8xx_t *cp;
2143 volatile pcmconf8xx_t *pcmp;
2146 debug ("voltage_set: " \
2148 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2149 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2151 if (!slot) /* Slot A is not configurable */
2154 immap = (immap_t *)CFG_IMMR;
2155 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2156 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2159 * Disable PCMCIA buffers (isolate the interface)
2160 * and assert RESET signal
2162 debug ("Disable PCMCIA buffers and assert RESET\n");
2163 reg = PCMCIA_PGCRX(slot);
2164 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2165 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2166 PCMCIA_PGCRX(slot) = reg;
2169 debug ("PCMCIA power OFF\n");
2171 * Configure Port B pins for
2174 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2175 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2176 /* remove all power */
2177 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2182 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2183 debug ("PCMCIA powered at 3.3V\n");
2186 debug ("PCMCIA: 5Volt vcc not supported\n");
2189 puts("PCMCIA: vcc not supported");
2193 /* Checking supported voltages */
2195 debug ("PIPR: 0x%x --> %s\n",
2197 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2198 ? "only 5 V --> NOT SUPPORTED"
2202 debug ("Enable PCMCIA buffers and stop RESET\n");
2203 reg = PCMCIA_PGCRX(slot);
2204 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2205 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2206 PCMCIA_PGCRX(slot) = reg;
2209 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2217 /* -------------------------------------------------------------------- */
2218 /* End of Board Specific Stuff */
2219 /* -------------------------------------------------------------------- */
2222 /* -------------------------------------------------------------------- */
2223 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2224 /* -------------------------------------------------------------------- */
2227 * Search this table to see if the windowsize is
2231 #define M8XX_SIZES_NO 32
2233 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2234 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2235 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2236 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2237 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2239 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2240 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2241 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2242 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2245 /* -------------------------------------------------------------------- */
2247 #ifndef CONFIG_I82365
2249 static u_int m8xx_get_graycode(u_int size)
2253 for (k = 0; k < M8XX_SIZES_NO; k++) {
2254 if(m8xx_size_to_gray[k] == size)
2258 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2264 #endif /* CONFIG_I82365 */
2266 /* -------------------------------------------------------------------- */
2269 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2271 u_int reg, clocks, psst, psl, psht;
2276 * We get called with IO maps setup to 0ns
2277 * if not specified by the user.
2278 * They should be 255ns.
2284 ns = 100; /* fast memory if 0 */
2288 * In PSST, PSL, PSHT fields we tell the controller
2289 * timing parameters in CLKOUT clock cycles.
2290 * CLKOUT is the same as GCLK2_50.
2293 /* how we want to adjust the timing - in percent */
2295 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2297 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2298 clocks = (clocks * ADJ) / (100*1000);
2300 if(clocks >= PCMCIA_BMT_LIMIT) {
2301 DEBUG(0, "Max access time limit reached\n");
2302 clocks = PCMCIA_BMT_LIMIT-1;
2305 psst = clocks / 7; /* setup time */
2306 psht = clocks / 7; /* hold time */
2307 psl = (clocks * 5) / 7; /* strobe length */
2309 psst += clocks - (psst + psht + psl);
2319 /* -------------------------------------------------------------------- */
2321 #ifdef CONFIG_IDE_8xx_PCCARD
2322 static void print_funcid (int func)
2326 case CISTPL_FUNCID_MULTI:
2327 puts (" Multi-Function");
2329 case CISTPL_FUNCID_MEMORY:
2332 case CISTPL_FUNCID_SERIAL:
2333 puts (" Serial Port");
2335 case CISTPL_FUNCID_PARALLEL:
2336 puts (" Parallel Port");
2338 case CISTPL_FUNCID_FIXED:
2339 puts (" Fixed Disk");
2341 case CISTPL_FUNCID_VIDEO:
2342 puts (" Video Adapter");
2344 case CISTPL_FUNCID_NETWORK:
2345 puts (" Network Adapter");
2347 case CISTPL_FUNCID_AIMS:
2348 puts (" AIMS Card");
2350 case CISTPL_FUNCID_SCSI:
2351 puts (" SCSI Adapter");
2359 #endif /* CONFIG_IDE_8xx_PCCARD */
2361 /* -------------------------------------------------------------------- */
2363 #ifdef CONFIG_IDE_8xx_PCCARD
2364 static void print_fixed (volatile uchar *p)
2372 case CISTPL_FUNCE_IDE_IFACE:
2373 { uchar iface = *(p+2);
2375 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2376 puts (" interface ");
2379 case CISTPL_FUNCE_IDE_MASTER:
2380 case CISTPL_FUNCE_IDE_SLAVE:
2381 { uchar f1 = *(p+2);
2384 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2386 if (f1 & CISTPL_IDE_UNIQUE)
2389 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2391 if (f2 & CISTPL_IDE_HAS_SLEEP)
2394 if (f2 & CISTPL_IDE_HAS_STANDBY)
2395 puts (" [standby]");
2397 if (f2 & CISTPL_IDE_HAS_IDLE)
2400 if (f2 & CISTPL_IDE_LOW_POWER)
2401 puts (" [low power]");
2403 if (f2 & CISTPL_IDE_REG_INHIBIT)
2404 puts (" [reg inhibit]");
2406 if (f2 & CISTPL_IDE_HAS_INDEX)
2409 if (f2 & CISTPL_IDE_IOIS16)
2417 #endif /* CONFIG_IDE_8xx_PCCARD */
2419 /* -------------------------------------------------------------------- */
2421 #ifdef CONFIG_IDE_8xx_PCCARD
2423 #define MAX_IDENT_CHARS 64
2424 #define MAX_IDENT_FIELDS 4
2426 static uchar *known_cards[] = {
2431 static int identify (volatile uchar *p)
2433 uchar id_str[MAX_IDENT_CHARS];
2440 return (0); /* Don't know */
2445 for (i=0; i<=4 && !done; ++i, p+=2) {
2446 while ((data = *p) != '\0') {
2452 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2462 while (--t > id_str) {
2471 for (card=known_cards; *card; ++card) {
2472 debug ("## Compare against \"%s\"\n", *card);
2473 if (strcmp(*card, id_str) == 0) { /* found! */
2474 debug ("## CARD FOUND ##\n");
2479 return (0); /* don't know */
2481 #endif /* CONFIG_IDE_8xx_PCCARD */
2483 /* -------------------------------------------------------------------- */
2485 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
2487 /**************************************************/
2489 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2490 cmd_tbl_t U_BOOT_CMD(PINIT) = MK_CMD_ENTRY(
2491 "pinit", 2, 1, do_pinit,
2492 "pinit - PCMCIA sub-system\n",
2493 "on - power on PCMCIA socket\n"
2494 "pinit off - power off PCMCIA socket\n"