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 unsigned int reg, mask;
1040 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1044 /* clear interrupt state, and disable interrupts */
1045 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
1046 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
1049 * Disable interrupts, DMA, and PCMCIA buffers
1050 * (isolate the interface) and assert RESET signal
1052 debug ("Disable PCMCIA buffers and assert RESET\n");
1053 reg = __MY_PCMCIA_GCRX_CXRESET; /* active high */
1054 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1056 PCMCIA_PGCRX(slot) = reg;
1059 /* remove all power */
1063 * Make sure there is a card in the slot, then configure the interface.
1066 debug ("[%d] %s: PIPR(%p)=0x%x\n", __LINE__,__FUNCTION__,
1067 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1069 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1070 printf (" No Card found\n");
1077 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1078 reg = pcmp->pcmc_pipr;
1079 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1080 (reg&PCMCIA_VS1(slot))?"n":"ff",
1081 (reg&PCMCIA_VS2(slot))?"n":"ff");
1083 if ((reg & mask) == mask) {
1084 *powerctl = 2; /* Enable 5V Vccout */
1085 puts (" 5.0V card found: ");
1087 *powerctl = 1; /* Enable 3.3 V Vccout */
1088 puts (" 3.3V card found: ");
1092 debug ("Enable PCMCIA buffers and stop RESET\n");
1093 reg = PCMCIA_PGCRX(slot);
1094 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1095 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1097 PCMCIA_PGCRX(slot) = reg;
1099 udelay(250000); /* some cards need >150 ms to come up :-( */
1101 debug ("# hardware_enable done\n");
1106 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1107 static int hardware_disable(int slot)
1109 volatile unsigned char *powerctl =
1110 (volatile unsigned char *)PCMCIA_CTRL;
1113 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1115 /* remove all power */
1118 debug ("Disable PCMCIA buffers and assert RESET\n");
1119 reg = __MY_PCMCIA_GCRX_CXRESET; /* active high */
1120 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1122 PCMCIA_PGCRX(slot) = reg;
1130 static int voltage_set(int slot, int vcc, int vpp)
1132 volatile pcmconf8xx_t *pcmp =
1133 (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1134 volatile unsigned char *powerctl =
1135 (volatile unsigned char *)PCMCIA_CTRL;
1138 debug ("voltage_set: " PCMCIA_BOARD_MSG
1139 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1140 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1143 * Disable PCMCIA buffers (isolate the interface)
1144 * and assert RESET signal
1146 debug ("Disable PCMCIA buffers and assert RESET\n");
1147 reg = PCMCIA_PGCRX(slot);
1148 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1149 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1151 PCMCIA_PGCRX(slot) = reg;
1155 * Configure pins for 5 Volts Enable and 3 Volts enable,
1156 * Turn off all power.
1158 debug ("PCMCIA power OFF\n");
1162 case 33: reg = 0x0001; break;
1163 case 50: reg = 0x0002; break;
1167 /* Checking supported voltages */
1169 debug ("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
1170 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1175 debug ("PCMCIA powered at %sV\n", (reg&0x0004) ? "5.0" : "3.3");
1177 debug ("PCMCIA powered down\n");
1181 debug ("Enable PCMCIA buffers and stop RESET\n");
1182 reg = PCMCIA_PGCRX(slot);
1183 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1184 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1186 PCMCIA_PGCRX(slot) = reg;
1189 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
1192 #endif /* CONFIG_VIRTLAB2 */
1194 /* -------------------------------------------------------------------- */
1196 /* -------------------------------------------------------------------- */
1198 #if defined(CONFIG_LWMON)
1200 #define PCMCIA_BOARD_MSG "LWMON"
1202 /* #define's for MAX1604 Power Switch */
1203 #define MAX1604_OP_SUS 0x80
1204 #define MAX1604_VCCBON 0x40
1205 #define MAX1604_VCC_35 0x20
1206 #define MAX1604_VCCBHIZ 0x10
1207 #define MAX1604_VPPBON 0x08
1208 #define MAX1604_VPPBPBPGM 0x04
1209 #define MAX1604_VPPBHIZ 0x02
1212 static int hardware_enable(int slot)
1214 volatile immap_t *immap;
1215 volatile cpm8xx_t *cp;
1216 volatile pcmconf8xx_t *pcmp;
1217 volatile sysconf8xx_t *sysp;
1222 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1224 /* Switch on PCMCIA port in PIC register 0x60 */
1225 reg = pic_read (0x60);
1226 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1228 /* reg |= 0x08; Vpp not needed */
1229 pic_write (0x60, reg);
1231 reg = pic_read (0x60);
1232 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1236 immap = (immap_t *)CFG_IMMR;
1237 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1238 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1239 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1242 * Configure SIUMCR to enable PCMCIA port B
1243 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1245 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1247 /* clear interrupt state, and disable interrupts */
1248 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1249 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1252 * Disable interrupts, DMA, and PCMCIA buffers
1253 * (isolate the interface) and assert RESET signal
1255 debug ("Disable PCMCIA buffers and assert RESET\n");
1257 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1258 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1259 PCMCIA_PGCRX(_slot_) = reg;
1263 * Make sure there is a card in the slot, then configure the interface.
1266 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1267 __LINE__,__FUNCTION__,
1268 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1269 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1270 printf (" No Card found\n");
1277 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1278 reg = pcmp->pcmc_pipr;
1279 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1281 (reg&PCMCIA_VS1(slot))?"n":"ff",
1282 (reg&PCMCIA_VS2(slot))?"n":"ff");
1283 if ((reg & mask) == mask) {
1284 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
1285 puts (" 5.0V card found: ");
1287 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
1288 puts (" 3.3V card found: ");
1292 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
1293 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1294 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1298 debug ("Enable PCMCIA buffers and stop RESET\n");
1299 reg = PCMCIA_PGCRX(_slot_);
1300 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1301 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1302 PCMCIA_PGCRX(_slot_) = reg;
1304 udelay(250000); /* some cards need >150 ms to come up :-( */
1306 debug ("# hardware_enable done\n");
1312 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1313 static int hardware_disable(int slot)
1315 volatile immap_t *immap;
1316 volatile pcmconf8xx_t *pcmp;
1320 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1322 immap = (immap_t *)CFG_IMMR;
1323 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1325 /* remove all power, put output in high impedance state */
1326 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1327 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1328 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1330 /* Configure PCMCIA General Control Register */
1331 debug ("Disable PCMCIA buffers and assert RESET\n");
1333 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1334 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1335 PCMCIA_PGCRX(_slot_) = reg;
1337 /* Switch off PCMCIA port in PIC register 0x60 */
1338 reg = pic_read (0x60);
1339 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1342 pic_write (0x60, reg);
1344 reg = pic_read (0x60);
1345 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1351 #endif /* CFG_CMD_PCMCIA */
1354 static int voltage_set(int slot, int vcc, int vpp)
1356 volatile immap_t *immap;
1357 volatile pcmconf8xx_t *pcmp;
1361 debug ("voltage_set: "
1363 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1364 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1366 immap = (immap_t *)CFG_IMMR;
1367 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1369 * Disable PCMCIA buffers (isolate the interface)
1370 * and assert RESET signal
1372 debug ("Disable PCMCIA buffers and assert RESET\n");
1373 reg = PCMCIA_PGCRX(_slot_);
1374 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1375 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1376 PCMCIA_PGCRX(_slot_) = reg;
1380 * Turn off all power (switch to high impedance)
1382 debug ("PCMCIA power OFF\n");
1383 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1384 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1385 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1390 case 33: val = MAX1604_VCC_35; break;
1395 /* Checking supported voltages */
1397 debug ("PIPR: 0x%x --> %s\n",
1399 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1401 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1403 debug ("PCMCIA powered at %sV\n",
1404 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
1406 debug ("PCMCIA powered down\n");
1410 debug ("Enable PCMCIA buffers and stop RESET\n");
1411 reg = PCMCIA_PGCRX(_slot_);
1412 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1413 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1414 PCMCIA_PGCRX(_slot_) = reg;
1417 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1424 /* -------------------------------------------------------------------- */
1425 /* GTH board by Corelatus AB */
1426 /* -------------------------------------------------------------------- */
1427 #if defined(CONFIG_GTH)
1429 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
1431 static int voltage_set (int slot, int vcc, int vpp)
1436 static int hardware_enable (int slot)
1438 volatile immap_t *immap;
1439 volatile cpm8xx_t *cp;
1440 volatile pcmconf8xx_t *pcmp;
1441 volatile sysconf8xx_t *sysp;
1444 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
1446 immap = (immap_t *) CFG_IMMR;
1447 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1448 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1449 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1451 /* clear interrupt state, and disable interrupts */
1452 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1453 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1456 * Disable interrupts, DMA, and PCMCIA buffers
1457 * (isolate the interface) and assert RESET signal
1459 debug ("Disable PCMCIA buffers and assert RESET\n");
1461 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1462 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1463 PCMCIA_PGCRX (_slot_) = reg;
1467 * Make sure there is a card in the slot,
1468 * then configure the interface.
1471 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1472 __LINE__, __FUNCTION__,
1473 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1474 if (pcmp->pcmc_pipr & 0x98000000) {
1475 printf (" No Card found\n");
1479 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1480 reg = pcmp->pcmc_pipr;
1481 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1483 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1484 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1486 debug ("Enable PCMCIA buffers and stop RESET\n");
1487 reg = PCMCIA_PGCRX (_slot_);
1488 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1489 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1490 PCMCIA_PGCRX (_slot_) = reg;
1492 udelay (250000); /* some cards need >150 ms to come up :-( */
1494 debug ("# hardware_enable done\n");
1498 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1499 static int hardware_disable(int slot)
1501 return 0; /* No hardware to disable */
1503 #endif /* CFG_CMD_PCMCIA */
1504 #endif /* CONFIG_GTH */
1506 /* -------------------------------------------------------------------- */
1507 /* ICU862 Boards by Cambridge Broadband Ltd. */
1508 /* -------------------------------------------------------------------- */
1510 #if defined(CONFIG_ICU862)
1512 #define PCMCIA_BOARD_MSG "ICU862"
1514 static void cfg_port_B (void);
1516 static int hardware_enable(int slot)
1518 volatile immap_t *immap;
1519 volatile cpm8xx_t *cp;
1520 volatile pcmconf8xx_t *pcmp;
1521 volatile sysconf8xx_t *sysp;
1522 uint reg, pipr, mask;
1525 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1529 immap = (immap_t *)CFG_IMMR;
1530 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1531 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1532 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1534 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1538 * Configure SIUMCR to enable PCMCIA port B
1539 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1541 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1543 /* clear interrupt state, and disable interrupts */
1544 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1545 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1548 * Disable interrupts, DMA, and PCMCIA buffers
1549 * (isolate the interface) and assert RESET signal
1551 debug ("Disable PCMCIA buffers and assert RESET\n");
1553 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1554 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1555 PCMCIA_PGCRX(_slot_) = reg;
1559 * Make sure there is a card in the slot, then configure the interface.
1562 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1563 __LINE__,__FUNCTION__,
1564 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1565 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1566 printf (" No Card found\n");
1571 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1573 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1574 pipr = pcmp->pcmc_pipr;
1575 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1577 (reg&PCMCIA_VS1(slot))?"n":"ff",
1578 (reg&PCMCIA_VS2(slot))?"n":"ff");
1581 if ((pipr & mask) == mask) {
1582 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1583 TPS2205_VCC3); /* 3V off */
1584 reg &= ~(TPS2205_VCC5); /* 5V on */
1585 puts (" 5.0V card found: ");
1587 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1588 TPS2205_VCC5); /* 5V off */
1589 reg &= ~(TPS2205_VCC3); /* 3V on */
1590 puts (" 3.3V card found: ");
1593 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1595 (reg & TPS2205_VCC3) ? "off" : "on",
1596 (reg & TPS2205_VCC5) ? "off" : "on",
1597 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1598 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1602 /* Wait 500 ms; use this to check for over-current */
1603 for (i=0; i<5000; ++i) {
1604 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1605 printf (" *** Overcurrent - Safety shutdown ***\n");
1606 cp->cp_pbdat &= ~(TPS2205_SHDN);
1612 debug ("Enable PCMCIA buffers and stop RESET\n");
1613 reg = PCMCIA_PGCRX(_slot_);
1614 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1615 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1616 PCMCIA_PGCRX(_slot_) = reg;
1618 udelay(250000); /* some cards need >150 ms to come up :-( */
1620 debug ("# hardware_enable done\n");
1626 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1627 static int hardware_disable(int slot)
1629 volatile immap_t *immap;
1630 volatile cpm8xx_t *cp;
1631 volatile pcmconf8xx_t *pcmp;
1634 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1636 immap = (immap_t *)CFG_IMMR;
1637 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1638 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1641 cp->cp_pbdat &= ~(TPS2205_SHDN);
1643 /* Configure PCMCIA General Control Register */
1644 debug ("Disable PCMCIA buffers and assert RESET\n");
1646 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1647 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1648 PCMCIA_PGCRX(_slot_) = reg;
1654 #endif /* CFG_CMD_PCMCIA */
1657 static int voltage_set(int slot, int vcc, int vpp)
1659 volatile immap_t *immap;
1660 volatile cpm8xx_t *cp;
1661 volatile pcmconf8xx_t *pcmp;
1664 debug ("voltage_set: "
1666 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1667 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1669 immap = (immap_t *)CFG_IMMR;
1670 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1671 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1673 * Disable PCMCIA buffers (isolate the interface)
1674 * and assert RESET signal
1676 debug ("Disable PCMCIA buffers and assert RESET\n");
1677 reg = PCMCIA_PGCRX(_slot_);
1678 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1679 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1680 PCMCIA_PGCRX(_slot_) = reg;
1684 * Configure Port C pins for
1685 * 5 Volts Enable and 3 Volts enable,
1686 * Turn all power pins to Hi-Z
1688 debug ("PCMCIA power OFF\n");
1689 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1694 case 0: break; /* Switch off */
1695 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1696 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1700 /* Checking supported voltages */
1702 debug ("PIPR: 0x%x --> %s\n",
1704 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1712 if ((reg & TPS2205_VCC3) == 0) {
1714 } else if ((reg & TPS2205_VCC5) == 0) {
1719 printf ("PCMCIA powered %s\n", s);
1724 debug ("Enable PCMCIA buffers and stop RESET\n");
1725 reg = PCMCIA_PGCRX(_slot_);
1726 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1727 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1728 PCMCIA_PGCRX(_slot_) = reg;
1731 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1736 static void cfg_port_B (void)
1738 volatile immap_t *immap;
1739 volatile cpm8xx_t *cp;
1742 immap = (immap_t *)CFG_IMMR;
1743 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1746 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1748 * Switch off all voltages, assert shutdown
1751 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1752 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1753 TPS2205_SHDN); /* enable switch */
1756 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1758 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1759 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1761 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1762 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1768 /* -------------------------------------------------------------------- */
1769 /* C2MON Boards by TTTech Computertechnik AG */
1770 /* -------------------------------------------------------------------- */
1772 #if defined(CONFIG_C2MON)
1774 #define PCMCIA_BOARD_MSG "C2MON"
1776 static void cfg_ports (void);
1778 static int hardware_enable(int slot)
1780 volatile immap_t *immap;
1781 volatile cpm8xx_t *cp;
1782 volatile pcmconf8xx_t *pcmp;
1783 volatile sysconf8xx_t *sysp;
1784 uint reg, pipr, mask;
1788 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1792 immap = (immap_t *)CFG_IMMR;
1793 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1794 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1795 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1797 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1801 * Configure SIUMCR to enable PCMCIA port B
1802 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1804 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1806 /* clear interrupt state, and disable interrupts */
1807 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1808 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1811 * Disable interrupts, DMA, and PCMCIA buffers
1812 * (isolate the interface) and assert RESET signal
1814 debug ("Disable PCMCIA buffers and assert RESET\n");
1816 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1817 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1818 PCMCIA_PGCRX(_slot_) = reg;
1822 * Make sure there is a card in the slot, then configure the interface.
1825 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1826 __LINE__,__FUNCTION__,
1827 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1828 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1829 printf (" No Card found\n");
1834 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1836 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1837 pipr = pcmp->pcmc_pipr;
1838 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1840 (reg&PCMCIA_VS1(slot))?"n":"ff",
1841 (reg&PCMCIA_VS2(slot))?"n":"ff");
1843 sreg = immap->im_ioport.iop_pcdat;
1844 if ((pipr & mask) == mask) {
1845 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1846 TPS2211_VCCD1); /* 5V on */
1847 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1848 puts (" 5.0V card found: ");
1850 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1851 TPS2211_VCCD0); /* 3V on */
1852 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1853 puts (" 3.3V card found: ");
1856 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1858 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1859 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1862 immap->im_ioport.iop_pcdat = sreg;
1864 /* Wait 500 ms; use this to check for over-current */
1865 for (i=0; i<5000; ++i) {
1866 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1867 printf (" *** Overcurrent - Safety shutdown ***\n");
1868 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1874 debug ("Enable PCMCIA buffers and stop RESET\n");
1875 reg = PCMCIA_PGCRX(_slot_);
1876 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1877 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1878 PCMCIA_PGCRX(_slot_) = reg;
1880 udelay(250000); /* some cards need >150 ms to come up :-( */
1882 debug ("# hardware_enable done\n");
1888 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1889 static int hardware_disable(int slot)
1891 volatile immap_t *immap;
1892 volatile cpm8xx_t *cp;
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 /* Configure PCMCIA General Control Register */
1902 debug ("Disable PCMCIA buffers and assert RESET\n");
1904 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1905 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1906 PCMCIA_PGCRX(_slot_) = reg;
1908 /* ALl voltages off / Hi-Z */
1909 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1910 TPS2211_VCCD0 | TPS2211_VCCD1 );
1916 #endif /* CFG_CMD_PCMCIA */
1919 static int voltage_set(int slot, int vcc, int vpp)
1921 volatile immap_t *immap;
1922 volatile cpm8xx_t *cp;
1923 volatile pcmconf8xx_t *pcmp;
1927 debug ("voltage_set: "
1929 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1930 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1932 immap = (immap_t *)CFG_IMMR;
1933 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1934 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1936 * Disable PCMCIA buffers (isolate the interface)
1937 * and assert RESET signal
1939 debug ("Disable PCMCIA buffers and assert RESET\n");
1940 reg = PCMCIA_PGCRX(_slot_);
1941 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1942 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1943 PCMCIA_PGCRX(_slot_) = reg;
1947 * Configure Port C pins for
1948 * 5 Volts Enable and 3 Volts enable,
1949 * Turn all power pins to Hi-Z
1951 debug ("PCMCIA power OFF\n");
1952 cfg_ports (); /* Enables switch, but all in Hi-Z */
1954 sreg = immap->im_ioport.iop_pcdat;
1955 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1958 case 0: break; /* Switch off */
1959 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1960 sreg &= ~TPS2211_VCCD1;
1962 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1963 sreg |= TPS2211_VCCD1;
1968 /* Checking supported voltages */
1970 debug ("PIPR: 0x%x --> %s\n",
1972 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1974 immap->im_ioport.iop_pcdat = sreg;
1980 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1982 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1987 printf ("PCMCIA powered %s\n", s);
1992 debug ("Enable PCMCIA buffers and stop RESET\n");
1993 reg = PCMCIA_PGCRX(_slot_);
1994 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1995 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1996 PCMCIA_PGCRX(_slot_) = reg;
1999 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2004 static void cfg_ports (void)
2006 volatile immap_t *immap;
2007 volatile cpm8xx_t *cp;
2010 immap = (immap_t *)CFG_IMMR;
2011 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2014 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
2016 * Switch off all voltages, assert shutdown
2018 sreg = immap->im_ioport.iop_pcdat;
2019 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
2020 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
2021 immap->im_ioport.iop_pcdat = sreg;
2023 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
2024 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
2026 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
2027 immap->im_ioport.iop_pcpar,
2028 immap->im_ioport.iop_pcdir,
2029 immap->im_ioport.iop_pcdat);
2032 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
2034 * Over-Current Input only
2036 cp->cp_pbpar &= ~(TPS2211_INPUTS);
2037 cp->cp_pbdir &= ~(TPS2211_INPUTS);
2039 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
2040 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
2045 /* -------------------------------------------------------------------- */
2046 /* MBX board from Morotola */
2047 /* -------------------------------------------------------------------- */
2049 #if defined( CONFIG_MBX )
2050 #include <../board/mbx8xx/csr.h>
2052 /* A lot of this has been taken from the RPX code in this file it works from me.
2053 I have added the voltage selection for the MBX board. */
2055 /* MBX voltage bit in control register #2 */
2056 #define CR2_VPP12 ((uchar)0x10)
2057 #define CR2_VPPVDD ((uchar)0x20)
2058 #define CR2_VDD5 ((uchar)0x40)
2059 #define CR2_VDD3 ((uchar)0x80)
2061 #define PCMCIA_BOARD_MSG "MBX860"
2063 static int voltage_set (int slot, int vcc, int vpp)
2067 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2068 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
2101 /* first, turn off all power */
2102 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
2104 /* enable new powersettings */
2106 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
2111 static int hardware_enable (int slot)
2113 volatile immap_t *immap;
2114 volatile cpm8xx_t *cp;
2115 volatile pcmconf8xx_t *pcmp;
2116 volatile sysconf8xx_t *sysp;
2119 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
2124 immap = (immap_t *) CFG_IMMR;
2125 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
2126 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
2127 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
2129 /* clear interrupt state, and disable interrupts */
2130 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
2131 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
2134 * Disable interrupts, DMA, and PCMCIA buffers
2135 * (isolate the interface) and assert RESET signal
2137 debug ("Disable PCMCIA buffers and assert RESET\n");
2139 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2140 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2141 PCMCIA_PGCRX (_slot_) = reg;
2144 /* remove all power */
2145 voltage_set (slot, 0, 0);
2147 * Make sure there is a card in the slot, then configure the interface.
2150 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2151 __LINE__,__FUNCTION__,
2152 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2153 #ifndef CONFIG_HMI10
2154 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2156 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
2157 #endif /* CONFIG_HMI10 */
2158 printf (" No Card found\n");
2165 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
2166 reg = pcmp->pcmc_pipr;
2167 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
2168 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
2169 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
2171 if ((reg & mask) == mask) {
2172 voltage_set (_slot_, 50, 0);
2173 printf (" 5.0V card found: ");
2175 voltage_set (_slot_, 33, 0);
2176 printf (" 3.3V card found: ");
2179 debug ("Enable PCMCIA buffers and stop RESET\n");
2180 reg = PCMCIA_PGCRX (_slot_);
2181 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2182 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2183 PCMCIA_PGCRX (_slot_) = reg;
2185 udelay (250000); /* some cards need >150 ms to come up :-( */
2187 debug ("# hardware_enable done\n");
2192 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2193 static int hardware_disable (int slot)
2195 return 0; /* No hardware to disable */
2197 #endif /* CFG_CMD_PCMCIA */
2198 #endif /* CONFIG_MBX */
2199 /* -------------------------------------------------------------------- */
2201 /* -------------------------------------------------------------------- */
2203 #if defined(CONFIG_R360MPI)
2205 #define PCMCIA_BOARD_MSG "R360MPI"
2208 static int hardware_enable(int slot)
2210 volatile immap_t *immap;
2211 volatile cpm8xx_t *cp;
2212 volatile pcmconf8xx_t *pcmp;
2213 volatile sysconf8xx_t *sysp;
2216 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2220 immap = (immap_t *)CFG_IMMR;
2221 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2222 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2223 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2226 * Configure SIUMCR to enable PCMCIA port B
2227 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2229 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2231 /* clear interrupt state, and disable interrupts */
2232 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
2233 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
2236 * Disable interrupts, DMA, and PCMCIA buffers
2237 * (isolate the interface) and assert RESET signal
2239 debug ("Disable PCMCIA buffers and assert RESET\n");
2241 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2242 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2243 PCMCIA_PGCRX(_slot_) = reg;
2247 * Configure Ports A, B & C pins for
2248 * 5 Volts Enable and 3 Volts enable
2250 immap->im_ioport.iop_pcpar &= ~(0x0400);
2251 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2252 immap->im_ioport.iop_pcdir |= 0x0400;*/
2254 immap->im_ioport.iop_papar &= ~(0x0200);/*
2255 immap->im_ioport.iop_padir |= 0x0200;*/
2257 immap->im_ioport.iop_pbpar &= ~(0xC000);
2258 immap->im_ioport.iop_pbdir &= ~(0xC000);
2260 /* remove all power */
2262 immap->im_ioport.iop_pcdat |= 0x0400;
2263 immap->im_ioport.iop_padat |= 0x0200;
2266 * Make sure there is a card in the slot, then configure the interface.
2269 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2270 __LINE__,__FUNCTION__,
2271 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2272 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2273 printf (" No Card found\n");
2280 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2281 reg = pcmp->pcmc_pipr;
2282 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2284 (reg&PCMCIA_VS1(slot))?"n":"ff",
2285 (reg&PCMCIA_VS2(slot))?"n":"ff");
2286 if ((reg & mask) == mask) {
2287 immap->im_ioport.iop_pcdat &= ~(0x4000);
2288 puts (" 5.0V card found: ");
2290 immap->im_ioport.iop_padat &= ~(0x0002);
2291 puts (" 3.3V card found: ");
2293 immap->im_ioport.iop_pcdir |= 0x0400;
2294 immap->im_ioport.iop_padir |= 0x0200;
2296 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2297 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2298 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2301 debug ("Enable PCMCIA buffers and stop RESET\n");
2302 reg = PCMCIA_PGCRX(_slot_);
2303 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2304 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2305 PCMCIA_PGCRX(_slot_) = reg;
2307 udelay(250000); /* some cards need >150 ms to come up :-( */
2309 debug ("# hardware_enable done\n");
2315 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2316 static int hardware_disable(int slot)
2318 volatile immap_t *immap;
2319 volatile pcmconf8xx_t *pcmp;
2322 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2324 immap = (immap_t *)CFG_IMMR;
2325 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2327 /* remove all power */
2328 immap->im_ioport.iop_pcdat |= 0x0400;
2329 immap->im_ioport.iop_padat |= 0x0200;
2331 /* Configure PCMCIA General Control Register */
2332 debug ("Disable PCMCIA buffers and assert RESET\n");
2334 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2335 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2336 PCMCIA_PGCRX(_slot_) = reg;
2342 #endif /* CFG_CMD_PCMCIA */
2345 static int voltage_set(int slot, int vcc, int vpp)
2347 volatile immap_t *immap;
2348 volatile pcmconf8xx_t *pcmp;
2351 debug ("voltage_set: "
2353 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2354 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2356 immap = (immap_t *)CFG_IMMR;
2357 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2359 * Disable PCMCIA buffers (isolate the interface)
2360 * and assert RESET signal
2362 debug ("Disable PCMCIA buffers and assert RESET\n");
2363 reg = PCMCIA_PGCRX(_slot_);
2364 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2365 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2366 PCMCIA_PGCRX(_slot_) = reg;
2370 * Configure Ports A & C pins for
2371 * 5 Volts Enable and 3 Volts enable,
2372 * Turn off all power
2374 debug ("PCMCIA power OFF\n");
2375 immap->im_ioport.iop_pcpar &= ~(0x0400);
2376 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2377 immap->im_ioport.iop_pcdir |= 0x0400;*/
2379 immap->im_ioport.iop_papar &= ~(0x0200);/*
2380 immap->im_ioport.iop_padir |= 0x0200;*/
2382 immap->im_ioport.iop_pcdat |= 0x0400;
2383 immap->im_ioport.iop_padat |= 0x0200;
2388 case 33: reg |= 0x0200; break;
2389 case 50: reg |= 0x0400; break;
2393 /* Checking supported voltages */
2395 debug ("PIPR: 0x%x --> %s\n",
2397 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
2400 immap->im_ioport.iop_pcdat &= !reg;
2402 immap->im_ioport.iop_padat &= !reg;
2403 immap->im_ioport.iop_pcdir |= 0x0200;
2404 immap->im_ioport.iop_padir |= 0x0400;
2406 debug ("PCMCIA powered at %sV\n",
2407 (reg&0x0400) ? "5.0" : "3.3");
2409 debug ("PCMCIA powered down\n");
2413 debug ("Enable PCMCIA buffers and stop RESET\n");
2414 reg = PCMCIA_PGCRX(_slot_);
2415 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2416 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2417 PCMCIA_PGCRX(_slot_) = reg;
2420 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2425 #endif /* R360MPI */
2427 /* -------------------------------------------------------------------- */
2428 /* KUP4K and KUP4X Boards */
2429 /* -------------------------------------------------------------------- */
2430 #if defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
2432 #define PCMCIA_BOARD_MSG "KUP"
2434 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
2436 static int hardware_enable(int slot)
2438 volatile immap_t *immap;
2439 volatile cpm8xx_t *cp;
2440 volatile pcmconf8xx_t *pcmp;
2441 volatile sysconf8xx_t *sysp;
2444 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2448 immap = (immap_t *)CFG_IMMR;
2449 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2450 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2451 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2454 * Configure SIUMCR to enable PCMCIA port B
2455 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2457 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2459 /* clear interrupt state, and disable interrupts */
2460 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2461 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2464 * Disable interrupts, DMA, and PCMCIA buffers
2465 * (isolate the interface) and assert RESET signal
2467 debug ("Disable PCMCIA buffers and assert RESET\n");
2469 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2470 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2471 PCMCIA_PGCRX(slot) = reg;
2475 * Configure Port B pins for
2478 if (slot) { /* Slot A is built-in */
2479 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2480 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2481 /* remove all power */
2482 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2485 * Make sure there is a card in the slot, then configure the interface.
2488 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2489 __LINE__,__FUNCTION__,
2490 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2491 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2492 printf (" No Card found\n");
2499 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2500 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2501 reg = pcmp->pcmc_pipr;
2502 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2504 (reg&PCMCIA_VS1(slot))?"n":"ff",
2505 (reg&PCMCIA_VS2(slot))?"n":"ff");
2506 if ((reg & mask) == mask) {
2507 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2510 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2511 puts (" 3.3V card found: ");
2514 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2515 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2516 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2519 debug ("Enable PCMCIA buffers and stop RESET\n");
2520 reg = PCMCIA_PGCRX(slot);
2521 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2522 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2523 PCMCIA_PGCRX(slot) = reg;
2525 udelay(250000); /* some cards need >150 ms to come up :-( */
2527 debug ("# hardware_enable done\n");
2533 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2534 static int hardware_disable(int slot)
2536 volatile immap_t *immap;
2537 volatile cpm8xx_t *cp;
2538 volatile pcmconf8xx_t *pcmp;
2541 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2543 immap = (immap_t *)CFG_IMMR;
2544 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2545 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2547 /* remove all power */
2549 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2551 /* Configure PCMCIA General Control Register */
2552 debug ("Disable PCMCIA buffers and assert RESET\n");
2554 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2555 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2556 PCMCIA_PGCRX(slot) = reg;
2562 #endif /* CFG_CMD_PCMCIA */
2565 static int voltage_set(int slot, int vcc, int vpp)
2567 volatile immap_t *immap;
2568 volatile cpm8xx_t *cp;
2569 volatile pcmconf8xx_t *pcmp;
2572 debug ("voltage_set: " \
2574 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2575 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2577 if (!slot) /* Slot A is not configurable */
2580 immap = (immap_t *)CFG_IMMR;
2581 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2582 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2585 * Disable PCMCIA buffers (isolate the interface)
2586 * and assert RESET signal
2588 debug ("Disable PCMCIA buffers and assert RESET\n");
2589 reg = PCMCIA_PGCRX(slot);
2590 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2591 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2592 PCMCIA_PGCRX(slot) = reg;
2595 debug ("PCMCIA power OFF\n");
2597 * Configure Port B pins for
2600 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2601 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2602 /* remove all power */
2603 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2608 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2609 debug ("PCMCIA powered at 3.3V\n");
2612 debug ("PCMCIA: 5Volt vcc not supported\n");
2615 puts("PCMCIA: vcc not supported");
2619 /* Checking supported voltages */
2621 debug ("PIPR: 0x%x --> %s\n",
2623 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2624 ? "only 5 V --> NOT SUPPORTED"
2628 debug ("Enable PCMCIA buffers and stop RESET\n");
2629 reg = PCMCIA_PGCRX(slot);
2630 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2631 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2632 PCMCIA_PGCRX(slot) = reg;
2635 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2640 #endif /* KUP4K || KUP4X */
2643 /* -------------------------------------------------------------------- */
2644 /* End of Board Specific Stuff */
2645 /* -------------------------------------------------------------------- */
2648 /* -------------------------------------------------------------------- */
2649 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2650 /* -------------------------------------------------------------------- */
2653 * Search this table to see if the windowsize is
2657 #define M8XX_SIZES_NO 32
2659 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2660 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2661 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2662 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2663 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2665 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2666 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2667 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2668 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2671 /* -------------------------------------------------------------------- */
2673 #if ( ! defined(CONFIG_I82365) && ! defined(CONFIG_PXA_PCMCIA) )
2675 static u_int m8xx_get_graycode(u_int size)
2679 for (k = 0; k < M8XX_SIZES_NO; k++) {
2680 if(m8xx_size_to_gray[k] == size)
2684 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2690 #endif /* CONFIG_I82365 */
2692 /* -------------------------------------------------------------------- */
2695 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2697 u_int reg, clocks, psst, psl, psht;
2702 * We get called with IO maps setup to 0ns
2703 * if not specified by the user.
2704 * They should be 255ns.
2710 ns = 100; /* fast memory if 0 */
2714 * In PSST, PSL, PSHT fields we tell the controller
2715 * timing parameters in CLKOUT clock cycles.
2716 * CLKOUT is the same as GCLK2_50.
2719 /* how we want to adjust the timing - in percent */
2721 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2723 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2724 clocks = (clocks * ADJ) / (100*1000);
2726 if(clocks >= PCMCIA_BMT_LIMIT) {
2727 DEBUG(0, "Max access time limit reached\n");
2728 clocks = PCMCIA_BMT_LIMIT-1;
2731 psst = clocks / 7; /* setup time */
2732 psht = clocks / 7; /* hold time */
2733 psl = (clocks * 5) / 7; /* strobe length */
2735 psst += clocks - (psst + psht + psl);
2745 /* -------------------------------------------------------------------- */
2747 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2748 static void print_funcid (int func)
2752 case CISTPL_FUNCID_MULTI:
2753 puts (" Multi-Function");
2755 case CISTPL_FUNCID_MEMORY:
2758 case CISTPL_FUNCID_SERIAL:
2759 puts (" Serial Port");
2761 case CISTPL_FUNCID_PARALLEL:
2762 puts (" Parallel Port");
2764 case CISTPL_FUNCID_FIXED:
2765 puts (" Fixed Disk");
2767 case CISTPL_FUNCID_VIDEO:
2768 puts (" Video Adapter");
2770 case CISTPL_FUNCID_NETWORK:
2771 puts (" Network Adapter");
2773 case CISTPL_FUNCID_AIMS:
2774 puts (" AIMS Card");
2776 case CISTPL_FUNCID_SCSI:
2777 puts (" SCSI Adapter");
2785 #endif /* CONFIG_IDE_8xx_PCCARD */
2787 /* -------------------------------------------------------------------- */
2789 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2790 static void print_fixed (volatile uchar *p)
2798 case CISTPL_FUNCE_IDE_IFACE:
2799 { uchar iface = *(p+2);
2801 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2802 puts (" interface ");
2805 case CISTPL_FUNCE_IDE_MASTER:
2806 case CISTPL_FUNCE_IDE_SLAVE:
2807 { uchar f1 = *(p+2);
2810 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2812 if (f1 & CISTPL_IDE_UNIQUE)
2815 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2817 if (f2 & CISTPL_IDE_HAS_SLEEP)
2820 if (f2 & CISTPL_IDE_HAS_STANDBY)
2821 puts (" [standby]");
2823 if (f2 & CISTPL_IDE_HAS_IDLE)
2826 if (f2 & CISTPL_IDE_LOW_POWER)
2827 puts (" [low power]");
2829 if (f2 & CISTPL_IDE_REG_INHIBIT)
2830 puts (" [reg inhibit]");
2832 if (f2 & CISTPL_IDE_HAS_INDEX)
2835 if (f2 & CISTPL_IDE_IOIS16)
2843 #endif /* CONFIG_IDE_8xx_PCCARD */
2845 /* -------------------------------------------------------------------- */
2847 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2849 #define MAX_IDENT_CHARS 64
2850 #define MAX_IDENT_FIELDS 4
2852 static uchar *known_cards[] = {
2853 (uchar *)"ARGOSY PnPIDE D5",
2857 static int identify (volatile uchar *p)
2859 uchar id_str[MAX_IDENT_CHARS];
2866 return (0); /* Don't know */
2871 for (i=0; i<=4 && !done; ++i, p+=2) {
2872 while ((data = *p) != '\0') {
2878 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2888 while (--t > id_str) {
2894 puts ((char *)id_str);
2897 for (card=known_cards; *card; ++card) {
2898 debug ("## Compare against \"%s\"\n", *card);
2899 if (strcmp((char *)*card, (char *)id_str) == 0) { /* found! */
2900 debug ("## CARD FOUND ##\n");
2905 return (0); /* don't know */
2907 #endif /* CONFIG_IDE_8xx_PCCARD */
2909 /* -------------------------------------------------------------------- */
2910 /* NETTA board by Intracom S.A. */
2911 /* -------------------------------------------------------------------- */
2913 #if defined(CONFIG_NETTA)
2915 /* some sane bit macros */
2916 #define _BD(_b) (1U << (31-(_b)))
2917 #define _BDR(_l, _h) (((((1U << (31-(_l))) - 1) << 1) | 1) & ~((1U << (31-(_h))) - 1))
2919 #define _BW(_b) (1U << (15-(_b)))
2920 #define _BWR(_l, _h) (((((1U << (15-(_l))) - 1) << 1) | 1) & ~((1U << (15-(_h))) - 1))
2922 #define _BB(_b) (1U << (7-(_b)))
2923 #define _BBR(_l, _h) (((((1U << (7-(_l))) - 1) << 1) | 1) & ~((1U << (7-(_h))) - 1))
2925 #define _B(_b) _BD(_b)
2926 #define _BR(_l, _h) _BDR(_l, _h)
2928 #define PCMCIA_BOARD_MSG "NETTA"
2930 static const unsigned short vppd_masks[2] = { _BW(14), _BW(15) };
2932 static void cfg_vppd(int no)
2934 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2935 unsigned short mask;
2937 if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
2940 mask = vppd_masks[no];
2942 immap->im_ioport.iop_papar &= ~mask;
2943 immap->im_ioport.iop_paodr &= ~mask;
2944 immap->im_ioport.iop_padir |= mask;
2947 static void set_vppd(int no, int what)
2949 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2950 unsigned short mask;
2952 if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
2955 mask = vppd_masks[no];
2958 immap->im_ioport.iop_padat |= mask;
2960 immap->im_ioport.iop_padat &= ~mask;
2963 static const unsigned short vccd_masks[2] = { _BW(10), _BW(6) };
2965 static void cfg_vccd(int no)
2967 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2968 unsigned short mask;
2970 if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
2973 mask = vccd_masks[no];
2975 immap->im_ioport.iop_papar &= ~mask;
2976 immap->im_ioport.iop_paodr &= ~mask;
2977 immap->im_ioport.iop_padir |= mask;
2980 static void set_vccd(int no, int what)
2982 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2983 unsigned short mask;
2985 if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
2988 mask = vccd_masks[no];
2991 immap->im_ioport.iop_padat |= mask;
2993 immap->im_ioport.iop_padat &= ~mask;
2996 static const unsigned short oc_mask = _BW(8);
2998 static void cfg_oc(void)
3000 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3001 unsigned short mask = oc_mask;
3003 immap->im_ioport.iop_pcdir &= ~mask;
3004 immap->im_ioport.iop_pcso &= ~mask;
3005 immap->im_ioport.iop_pcint &= ~mask;
3006 immap->im_ioport.iop_pcpar &= ~mask;
3009 static int get_oc(void)
3011 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3012 unsigned short mask = oc_mask;
3015 what = !!(immap->im_ioport.iop_pcdat & mask);;
3019 static const unsigned short shdn_mask = _BW(12);
3021 static void cfg_shdn(void)
3023 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3024 unsigned short mask;
3028 immap->im_ioport.iop_papar &= ~mask;
3029 immap->im_ioport.iop_paodr &= ~mask;
3030 immap->im_ioport.iop_padir |= mask;
3033 static void set_shdn(int what)
3035 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3036 unsigned short mask;
3041 immap->im_ioport.iop_padat |= mask;
3043 immap->im_ioport.iop_padat &= ~mask;
3046 static void cfg_ports (void);
3048 static int hardware_enable(int slot)
3050 volatile immap_t *immap;
3051 volatile cpm8xx_t *cp;
3052 volatile pcmconf8xx_t *pcmp;
3053 volatile sysconf8xx_t *sysp;
3054 uint reg, pipr, mask;
3057 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3061 immap = (immap_t *)CFG_IMMR;
3062 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
3063 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3064 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3066 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
3069 /* clear interrupt state, and disable interrupts */
3070 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
3071 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
3074 * Disable interrupts, DMA, and PCMCIA buffers
3075 * (isolate the interface) and assert RESET signal
3077 debug ("Disable PCMCIA buffers and assert RESET\n");
3079 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3080 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3081 PCMCIA_PGCRX(_slot_) = reg;
3086 * Make sure there is a card in the slot, then configure the interface.
3089 debug ("[%d] %s: PIPR(%p)=0x%x\n",
3090 __LINE__,__FUNCTION__,
3091 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
3092 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
3093 printf (" No Card found\n");
3098 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
3100 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
3101 pipr = pcmp->pcmc_pipr;
3102 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
3104 (reg&PCMCIA_VS1(slot))?"n":"ff",
3105 (reg&PCMCIA_VS2(slot))?"n":"ff");
3107 if ((pipr & mask) == mask) {
3108 set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
3109 set_vccd(0, 0); set_vccd(1, 1); /* 5V on, 3V off */
3110 puts (" 5.0V card found: ");
3112 set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
3113 set_vccd(0, 1); set_vccd(1, 0); /* 5V off, 3V on */
3114 puts (" 3.3V card found: ");
3117 /* Wait 500 ms; use this to check for over-current */
3118 for (i=0; i<5000; ++i) {
3120 printf (" *** Overcurrent - Safety shutdown ***\n");
3121 set_vccd(0, 0); set_vccd(1, 0); /* VAVPP => Hi-Z */
3127 debug ("Enable PCMCIA buffers and stop RESET\n");
3128 reg = PCMCIA_PGCRX(_slot_);
3129 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3130 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3131 PCMCIA_PGCRX(_slot_) = reg;
3133 udelay(250000); /* some cards need >150 ms to come up :-( */
3135 debug ("# hardware_enable done\n");
3141 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3142 static int hardware_disable(int slot)
3144 volatile immap_t *immap;
3145 volatile pcmconf8xx_t *pcmp;
3148 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3150 immap = (immap_t *)CFG_IMMR;
3151 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3153 /* Configure PCMCIA General Control Register */
3154 debug ("Disable PCMCIA buffers and assert RESET\n");
3156 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3157 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3158 PCMCIA_PGCRX(_slot_) = reg;
3160 /* All voltages off / Hi-Z */
3161 set_vppd(0, 1); set_vppd(1, 1);
3162 set_vccd(0, 1); set_vccd(1, 1);
3168 #endif /* CFG_CMD_PCMCIA */
3171 static int voltage_set(int slot, int vcc, int vpp)
3173 volatile immap_t *immap;
3174 volatile cpm8xx_t *cp;
3175 volatile pcmconf8xx_t *pcmp;
3179 debug ("voltage_set: "
3181 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
3182 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
3184 immap = (immap_t *)CFG_IMMR;
3185 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3186 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3188 * Disable PCMCIA buffers (isolate the interface)
3189 * and assert RESET signal
3191 debug ("Disable PCMCIA buffers and assert RESET\n");
3192 reg = PCMCIA_PGCRX(_slot_);
3193 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3194 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3195 PCMCIA_PGCRX(_slot_) = reg;
3199 * Configure Port C pins for
3200 * 5 Volts Enable and 3 Volts enable,
3201 * Turn all power pins to Hi-Z
3203 debug ("PCMCIA power OFF\n");
3204 cfg_ports (); /* Enables switch, but all in Hi-Z */
3206 sreg = immap->im_ioport.iop_pcdat;
3207 set_vppd(0, 1); set_vppd(1, 1);
3211 break; /* Switch off */
3214 set_vccd(0, 1); set_vccd(1, 0);
3218 set_vccd(0, 0); set_vccd(1, 1);
3225 /* Checking supported voltages */
3227 debug ("PIPR: 0x%x --> %s\n",
3229 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
3232 debug ("Enable PCMCIA buffers and stop RESET\n");
3233 reg = PCMCIA_PGCRX(_slot_);
3234 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3235 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3236 PCMCIA_PGCRX(_slot_) = reg;
3239 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
3244 static void cfg_ports (void)
3246 volatile immap_t *immap;
3247 volatile cpm8xx_t *cp;
3249 immap = (immap_t *)CFG_IMMR;
3250 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3253 cfg_vppd(0); cfg_vppd(1); /* VPPD0,VPPD1 VAVPP => Hi-Z */
3254 cfg_vccd(0); cfg_vccd(1); /* 3V and 5V off */
3259 * Configure Port A for TPS2211 PC-Card Power-Interface Switch
3261 * Switch off all voltages, assert shutdown
3263 set_vppd(0, 1); set_vppd(1, 1);
3264 set_vccd(0, 0); set_vccd(1, 0);
3273 /* -------------------------------------------------------------------- */
3275 /* -------------------------------------------------------------------- */
3277 #if defined(CONFIG_UC100)
3279 #define PCMCIA_BOARD_MSG "UC100"
3282 * Remark: don't turn off OE "__MY_PCMCIA_GCRX_CXOE" on UC100 board.
3283 * This leads to board-hangup! (sr, 8 Dez. 2004)
3286 static void cfg_ports (void);
3288 static int hardware_enable(int slot)
3290 volatile immap_t *immap;
3291 volatile cpm8xx_t *cp;
3292 volatile pcmconf8xx_t *pcmp;
3293 volatile sysconf8xx_t *sysp;
3296 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3300 immap = (immap_t *)CFG_IMMR;
3301 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
3302 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3303 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3305 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
3309 * Configure SIUMCR to enable PCMCIA port B
3310 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
3312 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
3314 /* clear interrupt state, and disable interrupts */
3315 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
3316 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
3319 * Disable interrupts, DMA, and PCMCIA buffers
3320 * (isolate the interface) and assert RESET signal
3322 debug ("Disable PCMCIA buffers and assert RESET\n");
3324 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3325 PCMCIA_PGCRX(_slot_) = reg;
3329 * Make sure there is a card in the slot, then configure the interface.
3332 debug ("[%d] %s: PIPR(%p)=0x%x\n",
3333 __LINE__,__FUNCTION__,
3334 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
3335 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
3336 printf (" No Card found\n");
3343 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
3344 reg = pcmp->pcmc_pipr;
3345 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
3347 (reg&PCMCIA_VS1(slot))?"n":"ff",
3348 (reg&PCMCIA_VS2(slot))?"n":"ff");
3349 if ((reg & mask) == mask) {
3350 puts (" 5.0V card found: ");
3352 puts (" 3.3V card found: ");
3356 immap->im_ioport.iop_padat |= 0x8000; /* power enable 3.3V */
3360 debug ("Enable PCMCIA buffers and stop RESET\n");
3361 reg = PCMCIA_PGCRX(_slot_);
3362 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3363 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3364 PCMCIA_PGCRX(_slot_) = reg;
3366 udelay(250000); /* some cards need >150 ms to come up :-( */
3368 debug ("# hardware_enable done\n");
3374 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3375 static int hardware_disable(int slot)
3377 volatile immap_t *immap;
3378 volatile cpm8xx_t *cp;
3379 volatile pcmconf8xx_t *pcmp;
3382 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3384 immap = (immap_t *)CFG_IMMR;
3385 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3387 /* switch VCC off */
3388 immap->im_ioport.iop_padat &= ~0x8000; /* power disable 3.3V */
3390 /* Configure PCMCIA General Control Register */
3391 debug ("Disable PCMCIA buffers and assert RESET\n");
3393 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3394 PCMCIA_PGCRX(_slot_) = reg;
3400 #endif /* CFG_CMD_PCMCIA */
3403 static int voltage_set(int slot, int vcc, int vpp)
3405 volatile immap_t *immap;
3406 volatile pcmconf8xx_t *pcmp;
3409 debug ("voltage_set: "
3411 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
3412 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
3414 immap = (immap_t *)CFG_IMMR;
3415 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3417 * Disable PCMCIA buffers (isolate the interface)
3418 * and assert RESET signal
3420 debug ("Disable PCMCIA buffers and assert RESET\n");
3421 reg = PCMCIA_PGCRX(_slot_);
3422 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3423 PCMCIA_PGCRX(_slot_) = reg;
3427 * Configure Port C pins for
3428 * 5 Volts Enable and 3 Volts enable,
3429 * Turn all power pins to Hi-Z
3431 debug ("PCMCIA power OFF\n");
3432 cfg_ports (); /* Enables switch, but all in Hi-Z */
3434 debug ("Enable PCMCIA buffers and stop RESET\n");
3435 reg = PCMCIA_PGCRX(_slot_);
3436 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3437 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3438 PCMCIA_PGCRX(_slot_) = reg;
3441 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
3446 static void cfg_ports (void)
3448 volatile immap_t *immap;
3450 immap = (immap_t *)CFG_IMMR;
3453 * Configure Port A for MAX1602 PC-Card Power-Interface Switch
3455 immap->im_ioport.iop_padat &= ~0x8000; /* set port x output to low */
3456 immap->im_ioport.iop_padir |= 0x8000; /* enable port x as output */
3458 debug ("Set Port A: PAR: %08x DIR: %08x DAT: %08x\n",
3459 immap->im_ioport.iop_papar, immap->im_ioport.iop_padir,
3460 immap->im_ioport.iop_padat);
3466 /* -------------------------------------------------------------------- */
3468 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
3470 /**************************************************/
3472 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3474 pinit, 2, 1, do_pinit,
3475 "pinit - PCMCIA sub-system\n",
3476 "on - power on PCMCIA socket\n"
3477 "pinit off - power off PCMCIA socket\n"