2 * (C) Copyright 2000-2006
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_8xx)
63 #if defined(CONFIG_LWMON)
66 #ifdef CONFIG_PXA_PCMCIA
67 #include <asm/arch/pxa-regs.h>
72 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
73 ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD))
77 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
78 static int pcmcia_off (void);
83 extern int i82365_init (void);
84 extern void i82365_exit (void);
86 #else /* ! CONFIG_I82365 */
88 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
89 static int hardware_disable(int slot);
91 static int hardware_enable (int slot);
92 static int voltage_set(int slot, int vcc, int vpp);
94 #if (! defined(CONFIG_I82365)) && (! defined(CONFIG_PXA_PCMCIA))
95 static u_int m8xx_get_graycode(u_int size);
96 #endif /* !CONFIG_I82365, !CONFIG_PXA_PCMCIA */
98 static u_int m8xx_get_speed(u_int ns, u_int is_io);
101 /* -------------------------------------------------------------------- */
103 #ifndef CONFIG_PXA_PCMCIA
105 /* look up table for pgcrx registers */
107 static u_int *pcmcia_pgcrx[2] = {
108 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
109 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
111 #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
113 #endif /* CONFIG_PXA_PCMCIA */
115 #endif /* CONFIG_I82365 */
117 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
118 static void print_funcid (int func);
119 static void print_fixed (volatile uchar *p);
120 static int identify (volatile uchar *p);
121 static int check_ide_device (int slot);
122 #endif /* CONFIG_IDE_8xx_PCCARD, CONFIG_PXA_PCMCIA */
124 const char *indent = "\t ";
126 /* -------------------------------------------------------------------- */
128 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
130 int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
135 printf ("Usage: pinit {on | off}\n");
138 if (strcmp(argv[1],"on") == 0) {
139 rcode = pcmcia_on ();
140 } else if (strcmp(argv[1],"off") == 0) {
141 rcode = pcmcia_off ();
143 printf ("Usage: pinit {on | off}\n");
149 #endif /* CFG_CMD_PCMCIA */
151 /* -------------------------------------------------------------------- */
158 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
163 rc = check_ide_device(0);
170 #ifndef CONFIG_PXA_PCMCIA
173 # define HMI10_FRAM_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(2) | PCMCIA_SL(4))
175 #if defined(CONFIG_LWMON) || defined(CONFIG_NSCU)
176 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
178 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
189 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
191 /* intialize the fixed memory windows */
192 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
193 base = CFG_PCMCIA_MEM_ADDR;
195 if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
196 printf ("Cannot set window size to 0x%08x\n",
197 CFG_PCMCIA_MEM_SIZE);
201 slotbit = PCMCIA_SLOT_x;
202 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
205 #if (PCMCIA_SOCKETS_NO == 2)
206 if (i == 4) /* Another slot starting from win 4 */
207 slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
210 #ifdef CONFIG_IDE_8xx_PCCARD
213 { /* map FRAM area */
214 win->or = ( PCMCIA_BSIZE_256K
219 | HMI10_FRAM_TIMING );
223 case 0: { /* map attribute memory */
224 win->or = ( PCMCIA_BSIZE_64M
229 | CFG_PCMCIA_TIMING );
233 case 1: { /* map I/O window for data reg */
234 win->or = ( PCMCIA_BSIZE_1K
239 | CFG_PCMCIA_TIMING );
243 case 2: { /* map I/O window for cmd/ctrl reg block */
244 win->or = ( PCMCIA_BSIZE_1K
249 | CFG_PCMCIA_TIMING );
252 #endif /* CONFIG_IDE_8xx_PCCARD */
254 case 3: { /* map I/O window for 4xUART data/ctrl */
256 win->or = ( PCMCIA_BSIZE_256K
261 | CFG_PCMCIA_TIMING );
264 #endif /* CONFIG_HMI10 */
265 default: /* set to not valid */
270 debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
271 i, win->br, win->or);
272 base += CFG_PCMCIA_MEM_SIZE;
276 for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
277 /* turn off voltage */
278 if ((rc = voltage_set(slot, 0, 0)))
281 /* Enable external hardware */
282 if ((rc = hardware_enable(slot)))
285 #ifdef CONFIG_IDE_8xx_PCCARD
286 if ((rc = check_ide_device(i)))
293 #endif /* CONFIG_PXA_PCMCIA */
295 #endif /* CONFIG_I82365 */
297 #ifdef CONFIG_PXA_PCMCIA
299 static int hardware_enable (int slot)
301 return 0; /* No hardware to enable */
304 static int hardware_disable(int slot)
306 return 0; /* No hardware to disable */
309 static int voltage_set(int slot, int vcc, int vpp)
314 void msWait(unsigned msVal)
321 unsigned int reg_arr[] = {
322 0x48000028, CFG_MCMEM0_VAL,
323 0x4800002c, CFG_MCMEM1_VAL,
324 0x48000030, CFG_MCATT0_VAL,
325 0x48000034, CFG_MCATT1_VAL,
326 0x48000038, CFG_MCIO0_VAL,
327 0x4800003c, CFG_MCIO1_VAL,
333 #ifdef CONFIG_EXADRON1
335 volatile unsigned int *v_pBCRReg =
336 (volatile unsigned int *) 0x08000000;
339 debug ("%s\n", __FUNCTION__);
343 *((volatile unsigned int *) reg_arr[i++]) |= reg_arr[i++];
346 debug ("%s: programmed mem controller \n", __FUNCTION__);
348 #ifdef CONFIG_EXADRON1
350 /*define useful BCR masks */
351 #define BCR_CF_INIT_VAL 0x00007230
352 #define BCR_CF_PWRON_BUSOFF_RESETOFF_VAL 0x00007231
353 #define BCR_CF_PWRON_BUSOFF_RESETON_VAL 0x00007233
354 #define BCR_CF_PWRON_BUSON_RESETON_VAL 0x00007213
355 #define BCR_CF_PWRON_BUSON_RESETOFF_VAL 0x00007211
357 /* we see from the GPIO bit if the card is present */
358 cardDetect = !(GPLR0 & GPIO_bit (14));
361 printf ("No PCMCIA card found!\n");
364 /* reset the card via the BCR line */
365 *v_pBCRReg = (unsigned) BCR_CF_INIT_VAL;
368 *v_pBCRReg = (unsigned) BCR_CF_PWRON_BUSOFF_RESETOFF_VAL;
371 *v_pBCRReg = (unsigned) BCR_CF_PWRON_BUSOFF_RESETON_VAL;
374 *v_pBCRReg = (unsigned) BCR_CF_PWRON_BUSON_RESETON_VAL;
377 *v_pBCRReg = (unsigned) BCR_CF_PWRON_BUSON_RESETOFF_VAL;
380 /* enable address bus */
382 /* and the first CF slot */
385 #endif /* EXADRON 1 */
387 rc = check_ide_device (0); /* use just slot 0 */
392 #endif /* CONFIG_PXA_PCMCIA */
394 /* -------------------------------------------------------------------- */
396 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
399 static int pcmcia_off (void)
401 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
409 #ifndef CONFIG_PXA_PCMCIA
411 static int pcmcia_off (void)
416 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
418 /* clear interrupt state, and disable interrupts */
419 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
420 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
422 /* turn off interrupt and disable CxOE */
423 PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
425 /* turn off memory windows */
426 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
428 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
429 /* disable memory window */
434 /* turn off voltage */
435 voltage_set(_slot_, 0, 0);
437 /* disable external hardware */
438 printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
439 hardware_disable(_slot_);
443 #endif /* CONFIG_PXA_PCMCIA */
445 #endif /* CONFIG_I82365 */
447 #ifdef CONFIG_PXA_PCMCIA
448 static int pcmcia_off (void)
454 #endif /* CFG_CMD_PCMCIA */
456 /* -------------------------------------------------------------------- */
458 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
460 #define MAX_TUPEL_SZ 512
461 #define MAX_FEATURES 4
463 int ide_devices_found;
464 static int check_ide_device (int slot)
466 volatile uchar *ident = NULL;
467 volatile uchar *feature_p[MAX_FEATURES];
468 volatile uchar *p, *start, *addr;
472 ushort config_base = 0;
476 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
477 CFG_PCMCIA_MEM_SIZE * (slot * 4));
478 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
480 start = p = (volatile uchar *) addr;
482 while ((p - start) < MAX_TUPEL_SZ) {
486 if (code == 0xFF) { /* End of chain */
491 #if defined(DEBUG) && (DEBUG > 1)
492 { volatile uchar *q = p;
493 printf ("\nTuple code %02x length %d\n\tData:",
496 for (i = 0; i < len; ++i) {
497 printf (" %02x", *q);
507 /* Fix for broken SanDisk which may have 0x80 bit set */
511 if (n_features < MAX_FEATURES)
512 feature_p[n_features++] = p;
515 config_base = (*(p+6) << 8) + (*(p+4));
516 debug ("\n## Config_base = %04x ###\n", config_base);
523 found = identify (ident);
525 if (func_id != ((uchar)~0)) {
526 print_funcid (func_id);
528 if (func_id == CISTPL_FUNCID_FIXED)
531 return (1); /* no disk drive */
534 for (i=0; i<n_features; ++i) {
535 print_fixed (feature_p[i]);
539 printf ("unknown card type\n");
543 ide_devices_found |= (1 << slot);
547 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
548 *((uchar *)(addr + config_base)) = 1;
551 printf("\n## Config_base = %04x ###\n", config_base);
552 printf("Configuration Option Register: %02x @ %x\n", readb(addr + config_base), addr + config_base);
553 printf("Card Configuration and Status Register: %02x\n", readb(addr + config_base + 2));
554 printf("Pin Replacement Register Register: %02x\n", readb(addr + config_base + 4));
555 printf("Socket and Copy Register: %02x\n", readb(addr + config_base + 6));
559 #endif /* CONFIG_IDE_8xx_PCCARD */
561 /* -------------------------------------------------------------------- */
564 /* -------------------------------------------------------------------- */
565 /* board specific stuff: */
566 /* voltage_set(), hardware_enable() and hardware_disable() */
567 /* -------------------------------------------------------------------- */
569 /* -------------------------------------------------------------------- */
570 /* RPX Boards from Embedded Planet */
571 /* -------------------------------------------------------------------- */
573 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
575 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
576 * SYPCR is write once only, therefore must the slowest memory be faster
577 * than the bus monitor or we will get a machine check due to the bus timeout.
580 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
582 #undef PCMCIA_BMT_LIMIT
583 #define PCMCIA_BMT_LIMIT (6*8)
585 static int voltage_set(int slot, int vcc, int vpp)
591 case 33: reg |= BCSR1_PCVCTL4; break;
592 case 50: reg |= BCSR1_PCVCTL5; break;
601 reg |= BCSR1_PCVCTL6;
606 reg |= BCSR1_PCVCTL7;
613 /* first, turn off all power */
615 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
616 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
618 /* enable new powersettings */
620 *((uint *)RPX_CSR_ADDR) |= reg;
625 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
626 static int hardware_enable (int slot)
628 return 0; /* No hardware to enable */
630 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
631 static int hardware_disable(int slot)
633 return 0; /* No hardware to disable */
635 #endif /* CFG_CMD_PCMCIA */
636 #endif /* CONFIG_RPXCLASSIC */
638 /* -------------------------------------------------------------------- */
639 /* (F)ADS Boards from Motorola */
640 /* -------------------------------------------------------------------- */
642 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
645 #define PCMCIA_BOARD_MSG "ADS"
646 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
648 #define PCMCIA_BOARD_MSG "FADS"
651 static int voltage_set(int slot, int vcc, int vpp)
656 case 0: reg = 0; break;
657 case 50: reg = 1; break;
658 case 120: reg = 2; break;
663 case 0: reg = 0; break;
665 case 50: reg = BCSR1_PCCVCCON; break;
668 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
669 case 50: reg = BCSR1_PCCVCC1; break;
674 /* first, turn off all power */
677 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
680 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
682 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
684 /* enable new powersettings */
687 *((uint *)BCSR1) &= ~reg;
690 *((uint *)BCSR1) |= reg;
693 *((uint *)BCSR1) |= reg << 20;
698 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
700 static int hardware_enable(int slot)
702 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
706 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
707 static int hardware_disable(int slot)
709 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
712 #endif /* CFG_CMD_PCMCIA */
716 /* -------------------------------------------------------------------- */
717 /* TQM8xxL Boards by TQ Components */
718 /* SC8xx Boards by SinoVee Microsystems */
719 /* -------------------------------------------------------------------- */
721 #if (defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)) \
722 && !defined(CONFIG_VIRTLAB2)
724 #if defined(CONFIG_TQM8xxL)
725 #define PCMCIA_BOARD_MSG "TQM8xxL"
727 #if defined(CONFIG_SVM_SC8xx)
728 #define PCMCIA_BOARD_MSG "SC8xx"
731 static int hardware_enable(int slot)
733 volatile immap_t *immap;
734 volatile cpm8xx_t *cp;
735 volatile pcmconf8xx_t *pcmp;
736 volatile sysconf8xx_t *sysp;
739 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
743 immap = (immap_t *)CFG_IMMR;
744 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
745 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
746 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
749 * Configure SIUMCR to enable PCMCIA port B
750 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
752 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
754 /* clear interrupt state, and disable interrupts */
755 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
756 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
759 * Disable interrupts, DMA, and PCMCIA buffers
760 * (isolate the interface) and assert RESET signal
762 debug ("Disable PCMCIA buffers and assert RESET\n");
764 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
766 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
768 PCMCIA_PGCRX(slot) = reg;
774 * Configure Port C pins for
775 * 5 Volts Enable and 3 Volts enable
777 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
778 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
779 /* remove all power */
781 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
783 #else /* CONFIG_HMI10 */
785 * Configure Port B pins for
786 * 5 Volts Enable and 3 Volts enable
788 immap->im_cpm.cp_pbpar &= ~(0x00000300);
790 /* remove all power */
791 immap->im_cpm.cp_pbdat |= 0x00000300;
792 #endif /* CONFIG_HMI10 */
795 * Make sure there is a card in the slot, then configure the interface.
798 debug ("[%d] %s: PIPR(%p)=0x%x\n",
799 __LINE__,__FUNCTION__,
800 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
802 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
804 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
805 #endif /* CONFIG_HMI10 */
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");
820 if ((reg & mask) == mask) {
822 immap->im_ioport.iop_pcdat |= 0x0004;
824 immap->im_cpm.cp_pbdat &= ~(0x0000100);
825 #endif /* CONFIG_HMI10 */
826 puts (" 5.0V card found: ");
829 immap->im_ioport.iop_pcdat |= 0x0002;
831 immap->im_cpm.cp_pbdat &= ~(0x0000200);
832 #endif /* CONFIG_HMI10 */
833 puts (" 3.3V card found: ");
836 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
838 immap->im_cpm.cp_pbdir |= 0x00000300;
839 #endif /* CONFIG_HMI10 */
841 if ((reg & mask) == mask) {
842 puts (" 5.0V card found: ");
844 puts (" 3.3V card found: ");
848 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
849 cp->cp_pbdir &= ~(0x0020 | 0x0010);
850 cp->cp_pbpar &= ~(0x0020 | 0x0010);
854 debug ("Enable PCMCIA buffers and stop RESET\n");
855 reg = PCMCIA_PGCRX(slot);
856 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
858 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
860 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
862 PCMCIA_PGCRX(slot) = reg;
864 udelay(250000); /* some cards need >150 ms to come up :-( */
866 debug ("# hardware_enable done\n");
872 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
873 static int hardware_disable(int slot)
875 volatile immap_t *immap;
876 volatile pcmconf8xx_t *pcmp;
879 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
881 immap = (immap_t *)CFG_IMMR;
882 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
886 /* remove all power */
887 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
889 #else /* CONFIG_HMI10 */
890 immap->im_cpm.cp_pbdat |= 0x00000300;
891 #endif /* CONFIG_HMI10 */
893 debug ("Disable PCMCIA buffers and assert RESET\n");
895 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
897 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
899 PCMCIA_PGCRX(slot) = reg;
905 #endif /* CFG_CMD_PCMCIA */
908 static int voltage_set(int slot, int vcc, int vpp)
913 static int voltage_set(int slot, int vcc, int vpp)
915 volatile immap_t *immap;
916 volatile pcmconf8xx_t *pcmp;
919 debug ("voltage_set: "
921 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
922 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
924 immap = (immap_t *)CFG_IMMR;
925 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
927 * Disable PCMCIA buffers (isolate the interface)
928 * and assert RESET signal
930 debug ("Disable PCMCIA buffers and assert RESET\n");
931 reg = PCMCIA_PGCRX(slot);
932 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
934 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
936 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
938 PCMCIA_PGCRX(slot) = reg;
943 * Configure Port C pins for
944 * 5 Volts Enable and 3 Volts enable,
947 debug ("PCMCIA power OFF\n");
948 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
949 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
950 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
955 case 33: reg |= 0x0002; break;
956 case 50: reg |= 0x0004; break;
959 #else /* CONFIG_HMI10 */
961 * Configure Port B pins for
962 * 5 Volts Enable and 3 Volts enable,
965 debug ("PCMCIA power OFF\n");
966 immap->im_cpm.cp_pbpar &= ~(0x00000300);
967 /* remove all power */
969 immap->im_cpm.cp_pbdat |= 0x00000300;
974 case 33: reg |= 0x00000200; break;
975 case 50: reg |= 0x00000100; break;
978 #endif /* CONFIG_HMI10 */
980 /* Checking supported voltages */
982 debug ("PIPR: 0x%x --> %s\n",
984 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
987 immap->im_ioport.iop_pcdat |= reg;
988 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
990 immap->im_cpm.cp_pbdat &= !reg;
991 immap->im_cpm.cp_pbdir |= 0x00000300;
992 #endif /* CONFIG_HMI10 */
995 debug ("PCMCIA powered at %sV\n",
996 (reg&0x0004) ? "5.0" : "3.3");
998 debug ("PCMCIA powered at %sV\n",
999 (reg&0x00000200) ? "5.0" : "3.3");
1000 #endif /* CONFIG_HMI10 */
1002 debug ("PCMCIA powered down\n");
1006 debug ("Enable PCMCIA buffers and stop RESET\n");
1007 reg = PCMCIA_PGCRX(slot);
1008 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1010 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1012 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1014 PCMCIA_PGCRX(slot) = reg;
1017 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1023 #endif /* TQM8xxL */
1025 /* -------------------------------------------------------------------- */
1026 /* Virtlab2 Board by TQ Components */
1027 /* -------------------------------------------------------------------- */
1029 #if defined(CONFIG_VIRTLAB2)
1030 #define PCMCIA_BOARD_MSG "Virtlab2"
1032 static int hardware_enable(int slot)
1034 volatile pcmconf8xx_t *pcmp =
1035 (pcmconf8xx_t *)&(((immap_t *)CFG_IMMR)->im_pcmcia);
1036 volatile unsigned char *powerctl =
1037 (volatile unsigned char *)PCMCIA_CTRL;
1038 volatile sysconf8xx_t *sysp =
1039 (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1040 unsigned int reg, mask;
1042 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1047 * Configure SIUMCR to enable PCMCIA port B
1049 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1051 /* clear interrupt state, and disable interrupts */
1052 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
1053 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
1056 * Disable interrupts, DMA, and PCMCIA buffers
1057 * (isolate the interface) and assert RESET signal
1059 debug ("Disable PCMCIA buffers and assert RESET\n");
1060 reg = __MY_PCMCIA_GCRX_CXRESET; /* active high */
1061 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1063 PCMCIA_PGCRX(slot) = reg;
1066 /* remove all power */
1070 * Make sure there is a card in the slot, then configure the interface.
1073 debug ("[%d] %s: PIPR(%p)=0x%x\n", __LINE__,__FUNCTION__,
1074 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1076 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1077 printf (" No Card found\n");
1084 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1085 reg = pcmp->pcmc_pipr;
1086 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1087 (reg&PCMCIA_VS1(slot))?"n":"ff",
1088 (reg&PCMCIA_VS2(slot))?"n":"ff");
1090 if ((reg & mask) == mask) {
1091 *powerctl = 2; /* Enable 5V Vccout */
1092 puts (" 5.0V card found: ");
1094 *powerctl = 1; /* Enable 3.3 V Vccout */
1095 puts (" 3.3V card found: ");
1099 debug ("Enable PCMCIA buffers and stop RESET\n");
1100 reg = PCMCIA_PGCRX(slot);
1101 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1102 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1104 PCMCIA_PGCRX(slot) = reg;
1106 udelay(250000); /* some cards need >150 ms to come up :-( */
1108 debug ("# hardware_enable done\n");
1113 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1114 static int hardware_disable(int slot)
1116 volatile unsigned char *powerctl =
1117 (volatile unsigned char *)PCMCIA_CTRL;
1120 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1122 /* remove all power */
1125 debug ("Disable PCMCIA buffers and assert RESET\n");
1126 reg = __MY_PCMCIA_GCRX_CXRESET; /* active high */
1127 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1129 PCMCIA_PGCRX(slot) = reg;
1137 static int voltage_set(int slot, int vcc, int vpp)
1140 volatile pcmconf8xx_t *pcmp =
1141 (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1143 volatile unsigned char *powerctl =
1144 (volatile unsigned char *)PCMCIA_CTRL;
1147 debug ("voltage_set: " PCMCIA_BOARD_MSG
1148 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1149 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1152 * Disable PCMCIA buffers (isolate the interface)
1153 * and assert RESET signal
1155 debug ("Disable PCMCIA buffers and assert RESET\n");
1156 reg = PCMCIA_PGCRX(slot);
1157 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1158 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1160 PCMCIA_PGCRX(slot) = reg;
1164 * Configure pins for 5 Volts Enable and 3 Volts enable,
1165 * Turn off all power.
1167 debug ("PCMCIA power OFF\n");
1171 case 33: reg = 0x0001; break;
1172 case 50: reg = 0x0002; break;
1176 /* Checking supported voltages */
1178 debug ("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
1179 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1184 debug ("PCMCIA powered at %sV\n", (reg&0x0004) ? "5.0" : "3.3");
1186 debug ("PCMCIA powered down\n");
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 */
1195 PCMCIA_PGCRX(slot) = reg;
1198 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
1201 #endif /* CONFIG_VIRTLAB2 */
1203 /* -------------------------------------------------------------------- */
1205 /* -------------------------------------------------------------------- */
1207 #if defined(CONFIG_LWMON)
1209 #define PCMCIA_BOARD_MSG "LWMON"
1211 /* #define's for MAX1604 Power Switch */
1212 #define MAX1604_OP_SUS 0x80
1213 #define MAX1604_VCCBON 0x40
1214 #define MAX1604_VCC_35 0x20
1215 #define MAX1604_VCCBHIZ 0x10
1216 #define MAX1604_VPPBON 0x08
1217 #define MAX1604_VPPBPBPGM 0x04
1218 #define MAX1604_VPPBHIZ 0x02
1221 static int hardware_enable(int slot)
1223 volatile immap_t *immap;
1224 volatile cpm8xx_t *cp;
1225 volatile pcmconf8xx_t *pcmp;
1226 volatile sysconf8xx_t *sysp;
1231 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1233 /* Switch on PCMCIA port in PIC register 0x60 */
1234 reg = pic_read (0x60);
1235 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1237 /* reg |= 0x08; Vpp not needed */
1238 pic_write (0x60, reg);
1240 reg = pic_read (0x60);
1241 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1245 immap = (immap_t *)CFG_IMMR;
1246 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1247 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1248 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1251 * Configure SIUMCR to enable PCMCIA port B
1252 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1254 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1256 /* clear interrupt state, and disable interrupts */
1257 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1258 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1261 * Disable interrupts, DMA, and PCMCIA buffers
1262 * (isolate the interface) and assert RESET signal
1264 debug ("Disable PCMCIA buffers and assert RESET\n");
1266 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1267 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1268 PCMCIA_PGCRX(_slot_) = reg;
1272 * Make sure there is a card in the slot, then configure the interface.
1275 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1276 __LINE__,__FUNCTION__,
1277 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1278 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1279 printf (" No Card found\n");
1286 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1287 reg = pcmp->pcmc_pipr;
1288 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1290 (reg&PCMCIA_VS1(slot))?"n":"ff",
1291 (reg&PCMCIA_VS2(slot))?"n":"ff");
1292 if ((reg & mask) == mask) {
1293 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
1294 puts (" 5.0V card found: ");
1296 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
1297 puts (" 3.3V card found: ");
1301 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
1302 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1303 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1307 debug ("Enable PCMCIA buffers and stop RESET\n");
1308 reg = PCMCIA_PGCRX(_slot_);
1309 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1310 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1311 PCMCIA_PGCRX(_slot_) = reg;
1313 udelay(250000); /* some cards need >150 ms to come up :-( */
1315 debug ("# hardware_enable done\n");
1321 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1322 static int hardware_disable(int slot)
1324 volatile immap_t *immap;
1325 volatile pcmconf8xx_t *pcmp;
1329 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1331 immap = (immap_t *)CFG_IMMR;
1332 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1334 /* remove all power, put output in high impedance state */
1335 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1336 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1337 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1339 /* Configure PCMCIA General Control Register */
1340 debug ("Disable PCMCIA buffers and assert RESET\n");
1342 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1343 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1344 PCMCIA_PGCRX(_slot_) = reg;
1346 /* Switch off PCMCIA port in PIC register 0x60 */
1347 reg = pic_read (0x60);
1348 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1351 pic_write (0x60, reg);
1353 reg = pic_read (0x60);
1354 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1360 #endif /* CFG_CMD_PCMCIA */
1363 static int voltage_set(int slot, int vcc, int vpp)
1365 volatile immap_t *immap;
1366 volatile pcmconf8xx_t *pcmp;
1370 debug ("voltage_set: "
1372 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1373 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1375 immap = (immap_t *)CFG_IMMR;
1376 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1378 * Disable PCMCIA buffers (isolate the interface)
1379 * and assert RESET signal
1381 debug ("Disable PCMCIA buffers and assert RESET\n");
1382 reg = PCMCIA_PGCRX(_slot_);
1383 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1384 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1385 PCMCIA_PGCRX(_slot_) = reg;
1389 * Turn off all power (switch to high impedance)
1391 debug ("PCMCIA power OFF\n");
1392 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1393 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1394 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1399 case 33: val = MAX1604_VCC_35; break;
1404 /* Checking supported voltages */
1406 debug ("PIPR: 0x%x --> %s\n",
1408 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1410 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1412 debug ("PCMCIA powered at %sV\n",
1413 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
1415 debug ("PCMCIA powered down\n");
1419 debug ("Enable PCMCIA buffers and stop RESET\n");
1420 reg = PCMCIA_PGCRX(_slot_);
1421 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1422 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1423 PCMCIA_PGCRX(_slot_) = reg;
1426 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1433 /* -------------------------------------------------------------------- */
1434 /* GTH board by Corelatus AB */
1435 /* -------------------------------------------------------------------- */
1436 #if defined(CONFIG_GTH)
1438 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
1440 static int voltage_set (int slot, int vcc, int vpp)
1445 static int hardware_enable (int slot)
1447 volatile immap_t *immap;
1448 volatile cpm8xx_t *cp;
1449 volatile pcmconf8xx_t *pcmp;
1450 volatile sysconf8xx_t *sysp;
1453 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
1455 immap = (immap_t *) CFG_IMMR;
1456 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1457 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1458 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1460 /* clear interrupt state, and disable interrupts */
1461 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1462 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1465 * Disable interrupts, DMA, and PCMCIA buffers
1466 * (isolate the interface) and assert RESET signal
1468 debug ("Disable PCMCIA buffers and assert RESET\n");
1470 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1471 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1472 PCMCIA_PGCRX (_slot_) = reg;
1476 * Make sure there is a card in the slot,
1477 * then configure the interface.
1480 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1481 __LINE__, __FUNCTION__,
1482 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1483 if (pcmp->pcmc_pipr & 0x98000000) {
1484 printf (" No Card found\n");
1488 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1489 reg = pcmp->pcmc_pipr;
1490 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1492 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1493 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1495 debug ("Enable PCMCIA buffers and stop RESET\n");
1496 reg = PCMCIA_PGCRX (_slot_);
1497 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1498 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1499 PCMCIA_PGCRX (_slot_) = reg;
1501 udelay (250000); /* some cards need >150 ms to come up :-( */
1503 debug ("# hardware_enable done\n");
1507 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1508 static int hardware_disable(int slot)
1510 return 0; /* No hardware to disable */
1512 #endif /* CFG_CMD_PCMCIA */
1513 #endif /* CONFIG_GTH */
1515 /* -------------------------------------------------------------------- */
1516 /* ICU862 Boards by Cambridge Broadband Ltd. */
1517 /* -------------------------------------------------------------------- */
1519 #if defined(CONFIG_ICU862)
1521 #define PCMCIA_BOARD_MSG "ICU862"
1523 static void cfg_port_B (void);
1525 static int hardware_enable(int slot)
1527 volatile immap_t *immap;
1528 volatile cpm8xx_t *cp;
1529 volatile pcmconf8xx_t *pcmp;
1530 volatile sysconf8xx_t *sysp;
1531 uint reg, pipr, mask;
1534 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1538 immap = (immap_t *)CFG_IMMR;
1539 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1540 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1541 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1543 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1547 * Configure SIUMCR to enable PCMCIA port B
1548 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1550 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1552 /* clear interrupt state, and disable interrupts */
1553 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1554 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1557 * Disable interrupts, DMA, and PCMCIA buffers
1558 * (isolate the interface) and assert RESET signal
1560 debug ("Disable PCMCIA buffers and assert RESET\n");
1562 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1563 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1564 PCMCIA_PGCRX(_slot_) = reg;
1568 * Make sure there is a card in the slot, then configure the interface.
1571 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1572 __LINE__,__FUNCTION__,
1573 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1574 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1575 printf (" No Card found\n");
1580 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1582 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1583 pipr = pcmp->pcmc_pipr;
1584 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1586 (reg&PCMCIA_VS1(slot))?"n":"ff",
1587 (reg&PCMCIA_VS2(slot))?"n":"ff");
1590 if ((pipr & mask) == mask) {
1591 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1592 TPS2205_VCC3); /* 3V off */
1593 reg &= ~(TPS2205_VCC5); /* 5V on */
1594 puts (" 5.0V card found: ");
1596 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1597 TPS2205_VCC5); /* 5V off */
1598 reg &= ~(TPS2205_VCC3); /* 3V on */
1599 puts (" 3.3V card found: ");
1602 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1604 (reg & TPS2205_VCC3) ? "off" : "on",
1605 (reg & TPS2205_VCC5) ? "off" : "on",
1606 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1607 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1611 /* Wait 500 ms; use this to check for over-current */
1612 for (i=0; i<5000; ++i) {
1613 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1614 printf (" *** Overcurrent - Safety shutdown ***\n");
1615 cp->cp_pbdat &= ~(TPS2205_SHDN);
1621 debug ("Enable PCMCIA buffers and stop RESET\n");
1622 reg = PCMCIA_PGCRX(_slot_);
1623 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1624 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1625 PCMCIA_PGCRX(_slot_) = reg;
1627 udelay(250000); /* some cards need >150 ms to come up :-( */
1629 debug ("# hardware_enable done\n");
1635 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1636 static int hardware_disable(int slot)
1638 volatile immap_t *immap;
1639 volatile cpm8xx_t *cp;
1640 volatile pcmconf8xx_t *pcmp;
1643 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1645 immap = (immap_t *)CFG_IMMR;
1646 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1647 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1650 cp->cp_pbdat &= ~(TPS2205_SHDN);
1652 /* Configure PCMCIA General Control Register */
1653 debug ("Disable PCMCIA buffers and assert RESET\n");
1655 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1656 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1657 PCMCIA_PGCRX(_slot_) = reg;
1663 #endif /* CFG_CMD_PCMCIA */
1666 static int voltage_set(int slot, int vcc, int vpp)
1668 volatile immap_t *immap;
1669 volatile cpm8xx_t *cp;
1670 volatile pcmconf8xx_t *pcmp;
1673 debug ("voltage_set: "
1675 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1676 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1678 immap = (immap_t *)CFG_IMMR;
1679 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1680 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1682 * Disable PCMCIA buffers (isolate the interface)
1683 * and assert RESET signal
1685 debug ("Disable PCMCIA buffers and assert RESET\n");
1686 reg = PCMCIA_PGCRX(_slot_);
1687 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1688 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1689 PCMCIA_PGCRX(_slot_) = reg;
1693 * Configure Port C pins for
1694 * 5 Volts Enable and 3 Volts enable,
1695 * Turn all power pins to Hi-Z
1697 debug ("PCMCIA power OFF\n");
1698 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1703 case 0: break; /* Switch off */
1704 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1705 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1709 /* Checking supported voltages */
1711 debug ("PIPR: 0x%x --> %s\n",
1713 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1721 if ((reg & TPS2205_VCC3) == 0) {
1723 } else if ((reg & TPS2205_VCC5) == 0) {
1728 printf ("PCMCIA powered %s\n", s);
1733 debug ("Enable PCMCIA buffers and stop RESET\n");
1734 reg = PCMCIA_PGCRX(_slot_);
1735 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1736 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1737 PCMCIA_PGCRX(_slot_) = reg;
1740 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1745 static void cfg_port_B (void)
1747 volatile immap_t *immap;
1748 volatile cpm8xx_t *cp;
1751 immap = (immap_t *)CFG_IMMR;
1752 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1755 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1757 * Switch off all voltages, assert shutdown
1760 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1761 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1762 TPS2205_SHDN); /* enable switch */
1765 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1767 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1768 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1770 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1771 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1777 /* -------------------------------------------------------------------- */
1778 /* C2MON Boards by TTTech Computertechnik AG */
1779 /* -------------------------------------------------------------------- */
1781 #if defined(CONFIG_C2MON)
1783 #define PCMCIA_BOARD_MSG "C2MON"
1785 static void cfg_ports (void);
1787 static int hardware_enable(int slot)
1789 volatile immap_t *immap;
1790 volatile cpm8xx_t *cp;
1791 volatile pcmconf8xx_t *pcmp;
1792 volatile sysconf8xx_t *sysp;
1793 uint reg, pipr, mask;
1797 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1801 immap = (immap_t *)CFG_IMMR;
1802 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1803 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1804 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1806 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1810 * Configure SIUMCR to enable PCMCIA port B
1811 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1813 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1815 /* clear interrupt state, and disable interrupts */
1816 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1817 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1820 * Disable interrupts, DMA, and PCMCIA buffers
1821 * (isolate the interface) and assert RESET signal
1823 debug ("Disable PCMCIA buffers and assert RESET\n");
1825 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1826 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1827 PCMCIA_PGCRX(_slot_) = reg;
1831 * Make sure there is a card in the slot, then configure the interface.
1834 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1835 __LINE__,__FUNCTION__,
1836 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1837 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1838 printf (" No Card found\n");
1843 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1845 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1846 pipr = pcmp->pcmc_pipr;
1847 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1849 (reg&PCMCIA_VS1(slot))?"n":"ff",
1850 (reg&PCMCIA_VS2(slot))?"n":"ff");
1852 sreg = immap->im_ioport.iop_pcdat;
1853 if ((pipr & mask) == mask) {
1854 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1855 TPS2211_VCCD1); /* 5V on */
1856 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1857 puts (" 5.0V card found: ");
1859 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1860 TPS2211_VCCD0); /* 3V on */
1861 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1862 puts (" 3.3V card found: ");
1865 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1867 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1868 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1871 immap->im_ioport.iop_pcdat = sreg;
1873 /* Wait 500 ms; use this to check for over-current */
1874 for (i=0; i<5000; ++i) {
1875 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1876 printf (" *** Overcurrent - Safety shutdown ***\n");
1877 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1883 debug ("Enable PCMCIA buffers and stop RESET\n");
1884 reg = PCMCIA_PGCRX(_slot_);
1885 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1886 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1887 PCMCIA_PGCRX(_slot_) = reg;
1889 udelay(250000); /* some cards need >150 ms to come up :-( */
1891 debug ("# hardware_enable done\n");
1897 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1898 static int hardware_disable(int slot)
1900 volatile immap_t *immap;
1901 volatile cpm8xx_t *cp;
1902 volatile pcmconf8xx_t *pcmp;
1905 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1907 immap = (immap_t *)CFG_IMMR;
1908 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1910 /* Configure PCMCIA General Control Register */
1911 debug ("Disable PCMCIA buffers and assert RESET\n");
1913 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1914 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1915 PCMCIA_PGCRX(_slot_) = reg;
1917 /* ALl voltages off / Hi-Z */
1918 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1919 TPS2211_VCCD0 | TPS2211_VCCD1 );
1925 #endif /* CFG_CMD_PCMCIA */
1928 static int voltage_set(int slot, int vcc, int vpp)
1930 volatile immap_t *immap;
1931 volatile cpm8xx_t *cp;
1932 volatile pcmconf8xx_t *pcmp;
1936 debug ("voltage_set: "
1938 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1939 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1941 immap = (immap_t *)CFG_IMMR;
1942 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1943 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1945 * Disable PCMCIA buffers (isolate the interface)
1946 * and assert RESET signal
1948 debug ("Disable PCMCIA buffers and assert RESET\n");
1949 reg = PCMCIA_PGCRX(_slot_);
1950 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1951 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1952 PCMCIA_PGCRX(_slot_) = reg;
1956 * Configure Port C pins for
1957 * 5 Volts Enable and 3 Volts enable,
1958 * Turn all power pins to Hi-Z
1960 debug ("PCMCIA power OFF\n");
1961 cfg_ports (); /* Enables switch, but all in Hi-Z */
1963 sreg = immap->im_ioport.iop_pcdat;
1964 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1967 case 0: break; /* Switch off */
1968 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1969 sreg &= ~TPS2211_VCCD1;
1971 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1972 sreg |= TPS2211_VCCD1;
1977 /* Checking supported voltages */
1979 debug ("PIPR: 0x%x --> %s\n",
1981 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1983 immap->im_ioport.iop_pcdat = sreg;
1989 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1991 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1996 printf ("PCMCIA powered %s\n", s);
2001 debug ("Enable PCMCIA buffers and stop RESET\n");
2002 reg = PCMCIA_PGCRX(_slot_);
2003 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2004 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2005 PCMCIA_PGCRX(_slot_) = reg;
2008 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2013 static void cfg_ports (void)
2015 volatile immap_t *immap;
2016 volatile cpm8xx_t *cp;
2019 immap = (immap_t *)CFG_IMMR;
2020 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2023 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
2025 * Switch off all voltages, assert shutdown
2027 sreg = immap->im_ioport.iop_pcdat;
2028 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
2029 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
2030 immap->im_ioport.iop_pcdat = sreg;
2032 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
2033 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
2035 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
2036 immap->im_ioport.iop_pcpar,
2037 immap->im_ioport.iop_pcdir,
2038 immap->im_ioport.iop_pcdat);
2041 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
2043 * Over-Current Input only
2045 cp->cp_pbpar &= ~(TPS2211_INPUTS);
2046 cp->cp_pbdir &= ~(TPS2211_INPUTS);
2048 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
2049 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
2054 /* -------------------------------------------------------------------- */
2055 /* MBX board from Morotola */
2056 /* -------------------------------------------------------------------- */
2058 #if defined( CONFIG_MBX )
2059 #include <../board/mbx8xx/csr.h>
2061 /* A lot of this has been taken from the RPX code in this file it works from me.
2062 I have added the voltage selection for the MBX board. */
2064 /* MBX voltage bit in control register #2 */
2065 #define CR2_VPP12 ((uchar)0x10)
2066 #define CR2_VPPVDD ((uchar)0x20)
2067 #define CR2_VDD5 ((uchar)0x40)
2068 #define CR2_VDD3 ((uchar)0x80)
2070 #define PCMCIA_BOARD_MSG "MBX860"
2072 static int voltage_set (int slot, int vcc, int vpp)
2076 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2077 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
2110 /* first, turn off all power */
2111 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
2113 /* enable new powersettings */
2115 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
2120 static int hardware_enable (int slot)
2122 volatile immap_t *immap;
2123 volatile cpm8xx_t *cp;
2124 volatile pcmconf8xx_t *pcmp;
2125 volatile sysconf8xx_t *sysp;
2128 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
2133 immap = (immap_t *) CFG_IMMR;
2134 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
2135 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
2136 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
2138 /* clear interrupt state, and disable interrupts */
2139 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
2140 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
2143 * Disable interrupts, DMA, and PCMCIA buffers
2144 * (isolate the interface) and assert RESET signal
2146 debug ("Disable PCMCIA buffers and assert RESET\n");
2148 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2149 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2150 PCMCIA_PGCRX (_slot_) = reg;
2153 /* remove all power */
2154 voltage_set (slot, 0, 0);
2156 * Make sure there is a card in the slot, then configure the interface.
2159 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2160 __LINE__,__FUNCTION__,
2161 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2162 #ifndef CONFIG_HMI10
2163 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2165 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
2166 #endif /* CONFIG_HMI10 */
2167 printf (" No Card found\n");
2174 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
2175 reg = pcmp->pcmc_pipr;
2176 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
2177 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
2178 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
2180 if ((reg & mask) == mask) {
2181 voltage_set (_slot_, 50, 0);
2182 printf (" 5.0V card found: ");
2184 voltage_set (_slot_, 33, 0);
2185 printf (" 3.3V card found: ");
2188 debug ("Enable PCMCIA buffers and stop RESET\n");
2189 reg = PCMCIA_PGCRX (_slot_);
2190 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2191 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2192 PCMCIA_PGCRX (_slot_) = reg;
2194 udelay (250000); /* some cards need >150 ms to come up :-( */
2196 debug ("# hardware_enable done\n");
2201 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2202 static int hardware_disable (int slot)
2204 return 0; /* No hardware to disable */
2206 #endif /* CFG_CMD_PCMCIA */
2207 #endif /* CONFIG_MBX */
2208 /* -------------------------------------------------------------------- */
2210 /* -------------------------------------------------------------------- */
2212 #if defined(CONFIG_R360MPI)
2214 #define PCMCIA_BOARD_MSG "R360MPI"
2217 static int hardware_enable(int slot)
2219 volatile immap_t *immap;
2220 volatile cpm8xx_t *cp;
2221 volatile pcmconf8xx_t *pcmp;
2222 volatile sysconf8xx_t *sysp;
2225 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2229 immap = (immap_t *)CFG_IMMR;
2230 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2231 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2232 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2235 * Configure SIUMCR to enable PCMCIA port B
2236 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2238 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2240 /* clear interrupt state, and disable interrupts */
2241 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
2242 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
2245 * Disable interrupts, DMA, and PCMCIA buffers
2246 * (isolate the interface) and assert RESET signal
2248 debug ("Disable PCMCIA buffers and assert RESET\n");
2250 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2251 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2252 PCMCIA_PGCRX(_slot_) = reg;
2256 * Configure Ports A, B & C pins for
2257 * 5 Volts Enable and 3 Volts enable
2259 immap->im_ioport.iop_pcpar &= ~(0x0400);
2260 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2261 immap->im_ioport.iop_pcdir |= 0x0400;*/
2263 immap->im_ioport.iop_papar &= ~(0x0200);/*
2264 immap->im_ioport.iop_padir |= 0x0200;*/
2266 immap->im_ioport.iop_pbpar &= ~(0xC000);
2267 immap->im_ioport.iop_pbdir &= ~(0xC000);
2269 /* remove all power */
2271 immap->im_ioport.iop_pcdat |= 0x0400;
2272 immap->im_ioport.iop_padat |= 0x0200;
2275 * Make sure there is a card in the slot, then configure the interface.
2278 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2279 __LINE__,__FUNCTION__,
2280 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2281 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2282 printf (" No Card found\n");
2289 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2290 reg = pcmp->pcmc_pipr;
2291 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2293 (reg&PCMCIA_VS1(slot))?"n":"ff",
2294 (reg&PCMCIA_VS2(slot))?"n":"ff");
2295 if ((reg & mask) == mask) {
2296 immap->im_ioport.iop_pcdat &= ~(0x4000);
2297 puts (" 5.0V card found: ");
2299 immap->im_ioport.iop_padat &= ~(0x0002);
2300 puts (" 3.3V card found: ");
2302 immap->im_ioport.iop_pcdir |= 0x0400;
2303 immap->im_ioport.iop_padir |= 0x0200;
2305 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2306 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2307 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2310 debug ("Enable PCMCIA buffers and stop RESET\n");
2311 reg = PCMCIA_PGCRX(_slot_);
2312 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2313 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2314 PCMCIA_PGCRX(_slot_) = reg;
2316 udelay(250000); /* some cards need >150 ms to come up :-( */
2318 debug ("# hardware_enable done\n");
2324 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2325 static int hardware_disable(int slot)
2327 volatile immap_t *immap;
2328 volatile pcmconf8xx_t *pcmp;
2331 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2333 immap = (immap_t *)CFG_IMMR;
2334 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2336 /* remove all power */
2337 immap->im_ioport.iop_pcdat |= 0x0400;
2338 immap->im_ioport.iop_padat |= 0x0200;
2340 /* Configure PCMCIA General Control Register */
2341 debug ("Disable PCMCIA buffers and assert RESET\n");
2343 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2344 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2345 PCMCIA_PGCRX(_slot_) = reg;
2351 #endif /* CFG_CMD_PCMCIA */
2354 static int voltage_set(int slot, int vcc, int vpp)
2356 volatile immap_t *immap;
2357 volatile pcmconf8xx_t *pcmp;
2360 debug ("voltage_set: "
2362 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2363 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2365 immap = (immap_t *)CFG_IMMR;
2366 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2368 * Disable PCMCIA buffers (isolate the interface)
2369 * and assert RESET signal
2371 debug ("Disable PCMCIA buffers and assert RESET\n");
2372 reg = PCMCIA_PGCRX(_slot_);
2373 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2374 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2375 PCMCIA_PGCRX(_slot_) = reg;
2379 * Configure Ports A & C pins for
2380 * 5 Volts Enable and 3 Volts enable,
2381 * Turn off all power
2383 debug ("PCMCIA power OFF\n");
2384 immap->im_ioport.iop_pcpar &= ~(0x0400);
2385 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2386 immap->im_ioport.iop_pcdir |= 0x0400;*/
2388 immap->im_ioport.iop_papar &= ~(0x0200);/*
2389 immap->im_ioport.iop_padir |= 0x0200;*/
2391 immap->im_ioport.iop_pcdat |= 0x0400;
2392 immap->im_ioport.iop_padat |= 0x0200;
2397 case 33: reg |= 0x0200; break;
2398 case 50: reg |= 0x0400; break;
2402 /* Checking supported voltages */
2404 debug ("PIPR: 0x%x --> %s\n",
2406 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
2409 immap->im_ioport.iop_pcdat &= !reg;
2411 immap->im_ioport.iop_padat &= !reg;
2412 immap->im_ioport.iop_pcdir |= 0x0200;
2413 immap->im_ioport.iop_padir |= 0x0400;
2415 debug ("PCMCIA powered at %sV\n",
2416 (reg&0x0400) ? "5.0" : "3.3");
2418 debug ("PCMCIA powered down\n");
2422 debug ("Enable PCMCIA buffers and stop RESET\n");
2423 reg = PCMCIA_PGCRX(_slot_);
2424 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2425 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2426 PCMCIA_PGCRX(_slot_) = reg;
2429 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2434 #endif /* R360MPI */
2436 /* -------------------------------------------------------------------- */
2437 /* KUP4K and KUP4X Boards */
2438 /* -------------------------------------------------------------------- */
2439 #if defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
2441 #define PCMCIA_BOARD_MSG "KUP"
2443 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
2445 static int hardware_enable(int slot)
2447 volatile immap_t *immap;
2448 volatile cpm8xx_t *cp;
2449 volatile pcmconf8xx_t *pcmp;
2450 volatile sysconf8xx_t *sysp;
2453 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2457 immap = (immap_t *)CFG_IMMR;
2458 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2459 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2460 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2463 * Configure SIUMCR to enable PCMCIA port B
2464 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2466 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2468 /* clear interrupt state, and disable interrupts */
2469 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2470 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2473 * Disable interrupts, DMA, and PCMCIA buffers
2474 * (isolate the interface) and assert RESET signal
2476 debug ("Disable PCMCIA buffers and assert RESET\n");
2478 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2479 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2480 PCMCIA_PGCRX(slot) = reg;
2484 * Configure Port B pins for
2487 if (slot) { /* Slot A is built-in */
2488 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2489 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2490 /* remove all power */
2491 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2494 * Make sure there is a card in the slot, then configure the interface.
2497 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2498 __LINE__,__FUNCTION__,
2499 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2500 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2501 printf (" No Card found\n");
2508 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2509 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2510 reg = pcmp->pcmc_pipr;
2511 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2513 (reg&PCMCIA_VS1(slot))?"n":"ff",
2514 (reg&PCMCIA_VS2(slot))?"n":"ff");
2515 if ((reg & mask) == mask) {
2516 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2519 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2520 puts (" 3.3V card found: ");
2523 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2524 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2525 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2528 debug ("Enable PCMCIA buffers and stop RESET\n");
2529 reg = PCMCIA_PGCRX(slot);
2530 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2531 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2532 PCMCIA_PGCRX(slot) = reg;
2534 udelay(250000); /* some cards need >150 ms to come up :-( */
2536 debug ("# hardware_enable done\n");
2542 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2543 static int hardware_disable(int slot)
2545 volatile immap_t *immap;
2546 volatile cpm8xx_t *cp;
2547 volatile pcmconf8xx_t *pcmp;
2550 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2552 immap = (immap_t *)CFG_IMMR;
2553 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2554 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2556 /* remove all power */
2558 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2560 /* Configure PCMCIA General Control Register */
2561 debug ("Disable PCMCIA buffers and assert RESET\n");
2563 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2564 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2565 PCMCIA_PGCRX(slot) = reg;
2571 #endif /* CFG_CMD_PCMCIA */
2574 static int voltage_set(int slot, int vcc, int vpp)
2576 volatile immap_t *immap;
2577 volatile cpm8xx_t *cp;
2578 volatile pcmconf8xx_t *pcmp;
2581 debug ("voltage_set: " \
2583 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2584 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2586 if (!slot) /* Slot A is not configurable */
2589 immap = (immap_t *)CFG_IMMR;
2590 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2591 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2594 * Disable PCMCIA buffers (isolate the interface)
2595 * and assert RESET signal
2597 debug ("Disable PCMCIA buffers and assert RESET\n");
2598 reg = PCMCIA_PGCRX(slot);
2599 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2600 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2601 PCMCIA_PGCRX(slot) = reg;
2604 debug ("PCMCIA power OFF\n");
2606 * Configure Port B pins for
2609 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2610 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2611 /* remove all power */
2612 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2617 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2618 debug ("PCMCIA powered at 3.3V\n");
2621 debug ("PCMCIA: 5Volt vcc not supported\n");
2624 puts("PCMCIA: vcc not supported");
2628 /* Checking supported voltages */
2630 debug ("PIPR: 0x%x --> %s\n",
2632 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2633 ? "only 5 V --> NOT SUPPORTED"
2637 debug ("Enable PCMCIA buffers and stop RESET\n");
2638 reg = PCMCIA_PGCRX(slot);
2639 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2640 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2641 PCMCIA_PGCRX(slot) = reg;
2644 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2649 #endif /* KUP4K || KUP4X */
2652 /* -------------------------------------------------------------------- */
2653 /* End of Board Specific Stuff */
2654 /* -------------------------------------------------------------------- */
2657 /* -------------------------------------------------------------------- */
2658 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2659 /* -------------------------------------------------------------------- */
2662 * Search this table to see if the windowsize is
2666 #define M8XX_SIZES_NO 32
2668 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2669 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2670 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2671 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2672 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2674 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2675 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2676 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2677 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2680 /* -------------------------------------------------------------------- */
2682 #if ( ! defined(CONFIG_I82365) && ! defined(CONFIG_PXA_PCMCIA) )
2684 static u_int m8xx_get_graycode(u_int size)
2688 for (k = 0; k < M8XX_SIZES_NO; k++) {
2689 if(m8xx_size_to_gray[k] == size)
2693 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2699 #endif /* CONFIG_I82365 */
2701 /* -------------------------------------------------------------------- */
2704 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2706 u_int reg, clocks, psst, psl, psht;
2711 * We get called with IO maps setup to 0ns
2712 * if not specified by the user.
2713 * They should be 255ns.
2719 ns = 100; /* fast memory if 0 */
2723 * In PSST, PSL, PSHT fields we tell the controller
2724 * timing parameters in CLKOUT clock cycles.
2725 * CLKOUT is the same as GCLK2_50.
2728 /* how we want to adjust the timing - in percent */
2730 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2732 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2733 clocks = (clocks * ADJ) / (100*1000);
2735 if(clocks >= PCMCIA_BMT_LIMIT) {
2736 DEBUG(0, "Max access time limit reached\n");
2737 clocks = PCMCIA_BMT_LIMIT-1;
2740 psst = clocks / 7; /* setup time */
2741 psht = clocks / 7; /* hold time */
2742 psl = (clocks * 5) / 7; /* strobe length */
2744 psst += clocks - (psst + psht + psl);
2754 /* -------------------------------------------------------------------- */
2756 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2757 static void print_funcid (int func)
2761 case CISTPL_FUNCID_MULTI:
2762 puts (" Multi-Function");
2764 case CISTPL_FUNCID_MEMORY:
2767 case CISTPL_FUNCID_SERIAL:
2768 puts (" Serial Port");
2770 case CISTPL_FUNCID_PARALLEL:
2771 puts (" Parallel Port");
2773 case CISTPL_FUNCID_FIXED:
2774 puts (" Fixed Disk");
2776 case CISTPL_FUNCID_VIDEO:
2777 puts (" Video Adapter");
2779 case CISTPL_FUNCID_NETWORK:
2780 puts (" Network Adapter");
2782 case CISTPL_FUNCID_AIMS:
2783 puts (" AIMS Card");
2785 case CISTPL_FUNCID_SCSI:
2786 puts (" SCSI Adapter");
2794 #endif /* CONFIG_IDE_8xx_PCCARD */
2796 /* -------------------------------------------------------------------- */
2798 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2799 static void print_fixed (volatile uchar *p)
2807 case CISTPL_FUNCE_IDE_IFACE:
2808 { uchar iface = *(p+2);
2810 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2811 puts (" interface ");
2814 case CISTPL_FUNCE_IDE_MASTER:
2815 case CISTPL_FUNCE_IDE_SLAVE:
2816 { uchar f1 = *(p+2);
2819 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2821 if (f1 & CISTPL_IDE_UNIQUE)
2824 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2826 if (f2 & CISTPL_IDE_HAS_SLEEP)
2829 if (f2 & CISTPL_IDE_HAS_STANDBY)
2830 puts (" [standby]");
2832 if (f2 & CISTPL_IDE_HAS_IDLE)
2835 if (f2 & CISTPL_IDE_LOW_POWER)
2836 puts (" [low power]");
2838 if (f2 & CISTPL_IDE_REG_INHIBIT)
2839 puts (" [reg inhibit]");
2841 if (f2 & CISTPL_IDE_HAS_INDEX)
2844 if (f2 & CISTPL_IDE_IOIS16)
2852 #endif /* CONFIG_IDE_8xx_PCCARD */
2854 /* -------------------------------------------------------------------- */
2856 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2858 #define MAX_IDENT_CHARS 64
2859 #define MAX_IDENT_FIELDS 4
2861 static uchar *known_cards[] = {
2862 (uchar *)"ARGOSY PnPIDE D5",
2866 static int identify (volatile uchar *p)
2868 uchar id_str[MAX_IDENT_CHARS];
2875 return (0); /* Don't know */
2880 for (i=0; i<=4 && !done; ++i, p+=2) {
2881 while ((data = *p) != '\0') {
2887 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2897 while (--t > id_str) {
2903 puts ((char *)id_str);
2906 for (card=known_cards; *card; ++card) {
2907 debug ("## Compare against \"%s\"\n", *card);
2908 if (strcmp((char *)*card, (char *)id_str) == 0) { /* found! */
2909 debug ("## CARD FOUND ##\n");
2914 return (0); /* don't know */
2916 #endif /* CONFIG_IDE_8xx_PCCARD */
2918 /* -------------------------------------------------------------------- */
2919 /* NETTA board by Intracom S.A. */
2920 /* -------------------------------------------------------------------- */
2922 #if defined(CONFIG_NETTA)
2924 /* some sane bit macros */
2925 #define _BD(_b) (1U << (31-(_b)))
2926 #define _BDR(_l, _h) (((((1U << (31-(_l))) - 1) << 1) | 1) & ~((1U << (31-(_h))) - 1))
2928 #define _BW(_b) (1U << (15-(_b)))
2929 #define _BWR(_l, _h) (((((1U << (15-(_l))) - 1) << 1) | 1) & ~((1U << (15-(_h))) - 1))
2931 #define _BB(_b) (1U << (7-(_b)))
2932 #define _BBR(_l, _h) (((((1U << (7-(_l))) - 1) << 1) | 1) & ~((1U << (7-(_h))) - 1))
2934 #define _B(_b) _BD(_b)
2935 #define _BR(_l, _h) _BDR(_l, _h)
2937 #define PCMCIA_BOARD_MSG "NETTA"
2939 static const unsigned short vppd_masks[2] = { _BW(14), _BW(15) };
2941 static void cfg_vppd(int no)
2943 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2944 unsigned short mask;
2946 if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
2949 mask = vppd_masks[no];
2951 immap->im_ioport.iop_papar &= ~mask;
2952 immap->im_ioport.iop_paodr &= ~mask;
2953 immap->im_ioport.iop_padir |= mask;
2956 static void set_vppd(int no, int what)
2958 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2959 unsigned short mask;
2961 if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
2964 mask = vppd_masks[no];
2967 immap->im_ioport.iop_padat |= mask;
2969 immap->im_ioport.iop_padat &= ~mask;
2972 static const unsigned short vccd_masks[2] = { _BW(10), _BW(6) };
2974 static void cfg_vccd(int no)
2976 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2977 unsigned short mask;
2979 if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
2982 mask = vccd_masks[no];
2984 immap->im_ioport.iop_papar &= ~mask;
2985 immap->im_ioport.iop_paodr &= ~mask;
2986 immap->im_ioport.iop_padir |= mask;
2989 static void set_vccd(int no, int what)
2991 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2992 unsigned short mask;
2994 if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
2997 mask = vccd_masks[no];
3000 immap->im_ioport.iop_padat |= mask;
3002 immap->im_ioport.iop_padat &= ~mask;
3005 static const unsigned short oc_mask = _BW(8);
3007 static void cfg_oc(void)
3009 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3010 unsigned short mask = oc_mask;
3012 immap->im_ioport.iop_pcdir &= ~mask;
3013 immap->im_ioport.iop_pcso &= ~mask;
3014 immap->im_ioport.iop_pcint &= ~mask;
3015 immap->im_ioport.iop_pcpar &= ~mask;
3018 static int get_oc(void)
3020 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3021 unsigned short mask = oc_mask;
3024 what = !!(immap->im_ioport.iop_pcdat & mask);;
3028 static const unsigned short shdn_mask = _BW(12);
3030 static void cfg_shdn(void)
3032 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3033 unsigned short mask;
3037 immap->im_ioport.iop_papar &= ~mask;
3038 immap->im_ioport.iop_paodr &= ~mask;
3039 immap->im_ioport.iop_padir |= mask;
3042 static void set_shdn(int what)
3044 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3045 unsigned short mask;
3050 immap->im_ioport.iop_padat |= mask;
3052 immap->im_ioport.iop_padat &= ~mask;
3055 static void cfg_ports (void);
3057 static int hardware_enable(int slot)
3059 volatile immap_t *immap;
3060 volatile cpm8xx_t *cp;
3061 volatile pcmconf8xx_t *pcmp;
3062 volatile sysconf8xx_t *sysp;
3063 uint reg, pipr, mask;
3066 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3070 immap = (immap_t *)CFG_IMMR;
3071 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
3072 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3073 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3075 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
3078 /* clear interrupt state, and disable interrupts */
3079 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
3080 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
3083 * Disable interrupts, DMA, and PCMCIA buffers
3084 * (isolate the interface) and assert RESET signal
3086 debug ("Disable PCMCIA buffers and assert RESET\n");
3088 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3089 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3090 PCMCIA_PGCRX(_slot_) = reg;
3095 * Make sure there is a card in the slot, then configure the interface.
3098 debug ("[%d] %s: PIPR(%p)=0x%x\n",
3099 __LINE__,__FUNCTION__,
3100 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
3101 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
3102 printf (" No Card found\n");
3107 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
3109 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
3110 pipr = pcmp->pcmc_pipr;
3111 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
3113 (reg&PCMCIA_VS1(slot))?"n":"ff",
3114 (reg&PCMCIA_VS2(slot))?"n":"ff");
3116 if ((pipr & mask) == mask) {
3117 set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
3118 set_vccd(0, 0); set_vccd(1, 1); /* 5V on, 3V off */
3119 puts (" 5.0V card found: ");
3121 set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
3122 set_vccd(0, 1); set_vccd(1, 0); /* 5V off, 3V on */
3123 puts (" 3.3V card found: ");
3126 /* Wait 500 ms; use this to check for over-current */
3127 for (i=0; i<5000; ++i) {
3129 printf (" *** Overcurrent - Safety shutdown ***\n");
3130 set_vccd(0, 0); set_vccd(1, 0); /* VAVPP => Hi-Z */
3136 debug ("Enable PCMCIA buffers and stop RESET\n");
3137 reg = PCMCIA_PGCRX(_slot_);
3138 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3139 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3140 PCMCIA_PGCRX(_slot_) = reg;
3142 udelay(250000); /* some cards need >150 ms to come up :-( */
3144 debug ("# hardware_enable done\n");
3150 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3151 static int hardware_disable(int slot)
3153 volatile immap_t *immap;
3154 volatile pcmconf8xx_t *pcmp;
3157 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3159 immap = (immap_t *)CFG_IMMR;
3160 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3162 /* Configure PCMCIA General Control Register */
3163 debug ("Disable PCMCIA buffers and assert RESET\n");
3165 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3166 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3167 PCMCIA_PGCRX(_slot_) = reg;
3169 /* All voltages off / Hi-Z */
3170 set_vppd(0, 1); set_vppd(1, 1);
3171 set_vccd(0, 1); set_vccd(1, 1);
3177 #endif /* CFG_CMD_PCMCIA */
3180 static int voltage_set(int slot, int vcc, int vpp)
3182 volatile immap_t *immap;
3183 volatile cpm8xx_t *cp;
3184 volatile pcmconf8xx_t *pcmp;
3188 debug ("voltage_set: "
3190 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
3191 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
3193 immap = (immap_t *)CFG_IMMR;
3194 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3195 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3197 * Disable PCMCIA buffers (isolate the interface)
3198 * and assert RESET signal
3200 debug ("Disable PCMCIA buffers and assert RESET\n");
3201 reg = PCMCIA_PGCRX(_slot_);
3202 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3203 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3204 PCMCIA_PGCRX(_slot_) = reg;
3208 * Configure Port C pins for
3209 * 5 Volts Enable and 3 Volts enable,
3210 * Turn all power pins to Hi-Z
3212 debug ("PCMCIA power OFF\n");
3213 cfg_ports (); /* Enables switch, but all in Hi-Z */
3215 sreg = immap->im_ioport.iop_pcdat;
3216 set_vppd(0, 1); set_vppd(1, 1);
3220 break; /* Switch off */
3223 set_vccd(0, 1); set_vccd(1, 0);
3227 set_vccd(0, 0); set_vccd(1, 1);
3234 /* Checking supported voltages */
3236 debug ("PIPR: 0x%x --> %s\n",
3238 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
3241 debug ("Enable PCMCIA buffers and stop RESET\n");
3242 reg = PCMCIA_PGCRX(_slot_);
3243 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3244 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3245 PCMCIA_PGCRX(_slot_) = reg;
3248 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
3253 static void cfg_ports (void)
3255 volatile immap_t *immap;
3256 volatile cpm8xx_t *cp;
3258 immap = (immap_t *)CFG_IMMR;
3259 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3262 cfg_vppd(0); cfg_vppd(1); /* VPPD0,VPPD1 VAVPP => Hi-Z */
3263 cfg_vccd(0); cfg_vccd(1); /* 3V and 5V off */
3268 * Configure Port A for TPS2211 PC-Card Power-Interface Switch
3270 * Switch off all voltages, assert shutdown
3272 set_vppd(0, 1); set_vppd(1, 1);
3273 set_vccd(0, 0); set_vccd(1, 0);
3282 /* -------------------------------------------------------------------- */
3284 /* -------------------------------------------------------------------- */
3286 #if defined(CONFIG_UC100)
3288 #define PCMCIA_BOARD_MSG "UC100"
3291 * Remark: don't turn off OE "__MY_PCMCIA_GCRX_CXOE" on UC100 board.
3292 * This leads to board-hangup! (sr, 8 Dez. 2004)
3295 static void cfg_ports (void);
3297 static int hardware_enable(int slot)
3299 volatile immap_t *immap;
3300 volatile cpm8xx_t *cp;
3301 volatile pcmconf8xx_t *pcmp;
3302 volatile sysconf8xx_t *sysp;
3305 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3309 immap = (immap_t *)CFG_IMMR;
3310 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
3311 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3312 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3314 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
3318 * Configure SIUMCR to enable PCMCIA port B
3319 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
3321 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
3323 /* clear interrupt state, and disable interrupts */
3324 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
3325 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
3328 * Disable interrupts, DMA, and PCMCIA buffers
3329 * (isolate the interface) and assert RESET signal
3331 debug ("Disable PCMCIA buffers and assert RESET\n");
3333 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3334 PCMCIA_PGCRX(_slot_) = reg;
3338 * Make sure there is a card in the slot, then configure the interface.
3341 debug ("[%d] %s: PIPR(%p)=0x%x\n",
3342 __LINE__,__FUNCTION__,
3343 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
3344 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
3345 printf (" No Card found\n");
3352 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
3353 reg = pcmp->pcmc_pipr;
3354 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
3356 (reg&PCMCIA_VS1(slot))?"n":"ff",
3357 (reg&PCMCIA_VS2(slot))?"n":"ff");
3358 if ((reg & mask) == mask) {
3359 puts (" 5.0V card found: ");
3361 puts (" 3.3V card found: ");
3365 immap->im_ioport.iop_padat |= 0x8000; /* power enable 3.3V */
3369 debug ("Enable PCMCIA buffers and stop RESET\n");
3370 reg = PCMCIA_PGCRX(_slot_);
3371 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3372 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3373 PCMCIA_PGCRX(_slot_) = reg;
3375 udelay(250000); /* some cards need >150 ms to come up :-( */
3377 debug ("# hardware_enable done\n");
3383 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3384 static int hardware_disable(int slot)
3386 volatile immap_t *immap;
3387 volatile cpm8xx_t *cp;
3388 volatile pcmconf8xx_t *pcmp;
3391 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3393 immap = (immap_t *)CFG_IMMR;
3394 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3396 /* switch VCC off */
3397 immap->im_ioport.iop_padat &= ~0x8000; /* power disable 3.3V */
3399 /* Configure PCMCIA General Control Register */
3400 debug ("Disable PCMCIA buffers and assert RESET\n");
3402 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3403 PCMCIA_PGCRX(_slot_) = reg;
3409 #endif /* CFG_CMD_PCMCIA */
3412 static int voltage_set(int slot, int vcc, int vpp)
3414 volatile immap_t *immap;
3415 volatile pcmconf8xx_t *pcmp;
3418 debug ("voltage_set: "
3420 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
3421 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
3423 immap = (immap_t *)CFG_IMMR;
3424 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3426 * Disable PCMCIA buffers (isolate the interface)
3427 * and assert RESET signal
3429 debug ("Disable PCMCIA buffers and assert RESET\n");
3430 reg = PCMCIA_PGCRX(_slot_);
3431 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3432 PCMCIA_PGCRX(_slot_) = reg;
3436 * Configure Port C pins for
3437 * 5 Volts Enable and 3 Volts enable,
3438 * Turn all power pins to Hi-Z
3440 debug ("PCMCIA power OFF\n");
3441 cfg_ports (); /* Enables switch, but all in Hi-Z */
3443 debug ("Enable PCMCIA buffers and stop RESET\n");
3444 reg = PCMCIA_PGCRX(_slot_);
3445 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3446 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3447 PCMCIA_PGCRX(_slot_) = reg;
3450 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
3455 static void cfg_ports (void)
3457 volatile immap_t *immap;
3459 immap = (immap_t *)CFG_IMMR;
3462 * Configure Port A for MAX1602 PC-Card Power-Interface Switch
3464 immap->im_ioport.iop_padat &= ~0x8000; /* set port x output to low */
3465 immap->im_ioport.iop_padir |= 0x8000; /* enable port x as output */
3467 debug ("Set Port A: PAR: %08x DIR: %08x DAT: %08x\n",
3468 immap->im_ioport.iop_papar, immap->im_ioport.iop_padir,
3469 immap->im_ioport.iop_padat);
3475 /* -------------------------------------------------------------------- */
3477 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
3479 /**************************************************/
3481 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3483 pinit, 2, 1, do_pinit,
3484 "pinit - PCMCIA sub-system\n",
3485 "on - power on PCMCIA socket\n"
3486 "pinit off - power off PCMCIA socket\n"