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)
1133 volatile pcmconf8xx_t *pcmp =
1134 (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1136 volatile unsigned char *powerctl =
1137 (volatile unsigned char *)PCMCIA_CTRL;
1140 debug ("voltage_set: " PCMCIA_BOARD_MSG
1141 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1142 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1145 * Disable PCMCIA buffers (isolate the interface)
1146 * and assert RESET signal
1148 debug ("Disable PCMCIA buffers and assert RESET\n");
1149 reg = PCMCIA_PGCRX(slot);
1150 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1151 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1153 PCMCIA_PGCRX(slot) = reg;
1157 * Configure pins for 5 Volts Enable and 3 Volts enable,
1158 * Turn off all power.
1160 debug ("PCMCIA power OFF\n");
1164 case 33: reg = 0x0001; break;
1165 case 50: reg = 0x0002; break;
1169 /* Checking supported voltages */
1171 debug ("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
1172 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1177 debug ("PCMCIA powered at %sV\n", (reg&0x0004) ? "5.0" : "3.3");
1179 debug ("PCMCIA powered down\n");
1183 debug ("Enable PCMCIA buffers and stop RESET\n");
1184 reg = PCMCIA_PGCRX(slot);
1185 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1186 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1188 PCMCIA_PGCRX(slot) = reg;
1191 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
1194 #endif /* CONFIG_VIRTLAB2 */
1196 /* -------------------------------------------------------------------- */
1198 /* -------------------------------------------------------------------- */
1200 #if defined(CONFIG_LWMON)
1202 #define PCMCIA_BOARD_MSG "LWMON"
1204 /* #define's for MAX1604 Power Switch */
1205 #define MAX1604_OP_SUS 0x80
1206 #define MAX1604_VCCBON 0x40
1207 #define MAX1604_VCC_35 0x20
1208 #define MAX1604_VCCBHIZ 0x10
1209 #define MAX1604_VPPBON 0x08
1210 #define MAX1604_VPPBPBPGM 0x04
1211 #define MAX1604_VPPBHIZ 0x02
1214 static int hardware_enable(int slot)
1216 volatile immap_t *immap;
1217 volatile cpm8xx_t *cp;
1218 volatile pcmconf8xx_t *pcmp;
1219 volatile sysconf8xx_t *sysp;
1224 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1226 /* Switch on PCMCIA port in PIC register 0x60 */
1227 reg = pic_read (0x60);
1228 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1230 /* reg |= 0x08; Vpp not needed */
1231 pic_write (0x60, reg);
1233 reg = pic_read (0x60);
1234 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1238 immap = (immap_t *)CFG_IMMR;
1239 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1240 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1241 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1244 * Configure SIUMCR to enable PCMCIA port B
1245 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1247 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1249 /* clear interrupt state, and disable interrupts */
1250 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1251 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1254 * Disable interrupts, DMA, and PCMCIA buffers
1255 * (isolate the interface) and assert RESET signal
1257 debug ("Disable PCMCIA buffers and assert RESET\n");
1259 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1260 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1261 PCMCIA_PGCRX(_slot_) = reg;
1265 * Make sure there is a card in the slot, then configure the interface.
1268 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1269 __LINE__,__FUNCTION__,
1270 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1271 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1272 printf (" No Card found\n");
1279 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1280 reg = pcmp->pcmc_pipr;
1281 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1283 (reg&PCMCIA_VS1(slot))?"n":"ff",
1284 (reg&PCMCIA_VS2(slot))?"n":"ff");
1285 if ((reg & mask) == mask) {
1286 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
1287 puts (" 5.0V card found: ");
1289 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
1290 puts (" 3.3V card found: ");
1294 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
1295 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1296 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1300 debug ("Enable PCMCIA buffers and stop RESET\n");
1301 reg = PCMCIA_PGCRX(_slot_);
1302 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1303 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1304 PCMCIA_PGCRX(_slot_) = reg;
1306 udelay(250000); /* some cards need >150 ms to come up :-( */
1308 debug ("# hardware_enable done\n");
1314 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1315 static int hardware_disable(int slot)
1317 volatile immap_t *immap;
1318 volatile pcmconf8xx_t *pcmp;
1322 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1324 immap = (immap_t *)CFG_IMMR;
1325 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1327 /* remove all power, put output in high impedance state */
1328 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1329 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1330 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1332 /* Configure PCMCIA General Control Register */
1333 debug ("Disable PCMCIA buffers and assert RESET\n");
1335 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1336 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1337 PCMCIA_PGCRX(_slot_) = reg;
1339 /* Switch off PCMCIA port in PIC register 0x60 */
1340 reg = pic_read (0x60);
1341 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1344 pic_write (0x60, reg);
1346 reg = pic_read (0x60);
1347 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1353 #endif /* CFG_CMD_PCMCIA */
1356 static int voltage_set(int slot, int vcc, int vpp)
1358 volatile immap_t *immap;
1359 volatile pcmconf8xx_t *pcmp;
1363 debug ("voltage_set: "
1365 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1366 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1368 immap = (immap_t *)CFG_IMMR;
1369 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1371 * Disable PCMCIA buffers (isolate the interface)
1372 * and assert RESET signal
1374 debug ("Disable PCMCIA buffers and assert RESET\n");
1375 reg = PCMCIA_PGCRX(_slot_);
1376 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1377 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1378 PCMCIA_PGCRX(_slot_) = reg;
1382 * Turn off all power (switch to high impedance)
1384 debug ("PCMCIA power OFF\n");
1385 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1386 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1387 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1392 case 33: val = MAX1604_VCC_35; break;
1397 /* Checking supported voltages */
1399 debug ("PIPR: 0x%x --> %s\n",
1401 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1403 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1405 debug ("PCMCIA powered at %sV\n",
1406 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
1408 debug ("PCMCIA powered down\n");
1412 debug ("Enable PCMCIA buffers and stop RESET\n");
1413 reg = PCMCIA_PGCRX(_slot_);
1414 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1415 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1416 PCMCIA_PGCRX(_slot_) = reg;
1419 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1426 /* -------------------------------------------------------------------- */
1427 /* GTH board by Corelatus AB */
1428 /* -------------------------------------------------------------------- */
1429 #if defined(CONFIG_GTH)
1431 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
1433 static int voltage_set (int slot, int vcc, int vpp)
1438 static int hardware_enable (int slot)
1440 volatile immap_t *immap;
1441 volatile cpm8xx_t *cp;
1442 volatile pcmconf8xx_t *pcmp;
1443 volatile sysconf8xx_t *sysp;
1446 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
1448 immap = (immap_t *) CFG_IMMR;
1449 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1450 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1451 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1453 /* clear interrupt state, and disable interrupts */
1454 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1455 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1458 * Disable interrupts, DMA, and PCMCIA buffers
1459 * (isolate the interface) and assert RESET signal
1461 debug ("Disable PCMCIA buffers and assert RESET\n");
1463 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1464 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1465 PCMCIA_PGCRX (_slot_) = reg;
1469 * Make sure there is a card in the slot,
1470 * then configure the interface.
1473 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1474 __LINE__, __FUNCTION__,
1475 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1476 if (pcmp->pcmc_pipr & 0x98000000) {
1477 printf (" No Card found\n");
1481 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1482 reg = pcmp->pcmc_pipr;
1483 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1485 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1486 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1488 debug ("Enable PCMCIA buffers and stop RESET\n");
1489 reg = PCMCIA_PGCRX (_slot_);
1490 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1491 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1492 PCMCIA_PGCRX (_slot_) = reg;
1494 udelay (250000); /* some cards need >150 ms to come up :-( */
1496 debug ("# hardware_enable done\n");
1500 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1501 static int hardware_disable(int slot)
1503 return 0; /* No hardware to disable */
1505 #endif /* CFG_CMD_PCMCIA */
1506 #endif /* CONFIG_GTH */
1508 /* -------------------------------------------------------------------- */
1509 /* ICU862 Boards by Cambridge Broadband Ltd. */
1510 /* -------------------------------------------------------------------- */
1512 #if defined(CONFIG_ICU862)
1514 #define PCMCIA_BOARD_MSG "ICU862"
1516 static void cfg_port_B (void);
1518 static int hardware_enable(int slot)
1520 volatile immap_t *immap;
1521 volatile cpm8xx_t *cp;
1522 volatile pcmconf8xx_t *pcmp;
1523 volatile sysconf8xx_t *sysp;
1524 uint reg, pipr, mask;
1527 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1531 immap = (immap_t *)CFG_IMMR;
1532 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1533 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1534 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1536 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1540 * Configure SIUMCR to enable PCMCIA port B
1541 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1543 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1545 /* clear interrupt state, and disable interrupts */
1546 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1547 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1550 * Disable interrupts, DMA, and PCMCIA buffers
1551 * (isolate the interface) and assert RESET signal
1553 debug ("Disable PCMCIA buffers and assert RESET\n");
1555 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1556 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1557 PCMCIA_PGCRX(_slot_) = reg;
1561 * Make sure there is a card in the slot, then configure the interface.
1564 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1565 __LINE__,__FUNCTION__,
1566 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1567 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1568 printf (" No Card found\n");
1573 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1575 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1576 pipr = pcmp->pcmc_pipr;
1577 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1579 (reg&PCMCIA_VS1(slot))?"n":"ff",
1580 (reg&PCMCIA_VS2(slot))?"n":"ff");
1583 if ((pipr & mask) == mask) {
1584 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1585 TPS2205_VCC3); /* 3V off */
1586 reg &= ~(TPS2205_VCC5); /* 5V on */
1587 puts (" 5.0V card found: ");
1589 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1590 TPS2205_VCC5); /* 5V off */
1591 reg &= ~(TPS2205_VCC3); /* 3V on */
1592 puts (" 3.3V card found: ");
1595 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1597 (reg & TPS2205_VCC3) ? "off" : "on",
1598 (reg & TPS2205_VCC5) ? "off" : "on",
1599 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1600 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1604 /* Wait 500 ms; use this to check for over-current */
1605 for (i=0; i<5000; ++i) {
1606 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1607 printf (" *** Overcurrent - Safety shutdown ***\n");
1608 cp->cp_pbdat &= ~(TPS2205_SHDN);
1614 debug ("Enable PCMCIA buffers and stop RESET\n");
1615 reg = PCMCIA_PGCRX(_slot_);
1616 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1617 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1618 PCMCIA_PGCRX(_slot_) = reg;
1620 udelay(250000); /* some cards need >150 ms to come up :-( */
1622 debug ("# hardware_enable done\n");
1628 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1629 static int hardware_disable(int slot)
1631 volatile immap_t *immap;
1632 volatile cpm8xx_t *cp;
1633 volatile pcmconf8xx_t *pcmp;
1636 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1638 immap = (immap_t *)CFG_IMMR;
1639 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1640 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1643 cp->cp_pbdat &= ~(TPS2205_SHDN);
1645 /* Configure PCMCIA General Control Register */
1646 debug ("Disable PCMCIA buffers and assert RESET\n");
1648 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1649 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1650 PCMCIA_PGCRX(_slot_) = reg;
1656 #endif /* CFG_CMD_PCMCIA */
1659 static int voltage_set(int slot, int vcc, int vpp)
1661 volatile immap_t *immap;
1662 volatile cpm8xx_t *cp;
1663 volatile pcmconf8xx_t *pcmp;
1666 debug ("voltage_set: "
1668 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1669 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1671 immap = (immap_t *)CFG_IMMR;
1672 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1673 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1675 * Disable PCMCIA buffers (isolate the interface)
1676 * and assert RESET signal
1678 debug ("Disable PCMCIA buffers and assert RESET\n");
1679 reg = PCMCIA_PGCRX(_slot_);
1680 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1681 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1682 PCMCIA_PGCRX(_slot_) = reg;
1686 * Configure Port C pins for
1687 * 5 Volts Enable and 3 Volts enable,
1688 * Turn all power pins to Hi-Z
1690 debug ("PCMCIA power OFF\n");
1691 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1696 case 0: break; /* Switch off */
1697 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1698 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1702 /* Checking supported voltages */
1704 debug ("PIPR: 0x%x --> %s\n",
1706 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1714 if ((reg & TPS2205_VCC3) == 0) {
1716 } else if ((reg & TPS2205_VCC5) == 0) {
1721 printf ("PCMCIA powered %s\n", s);
1726 debug ("Enable PCMCIA buffers and stop RESET\n");
1727 reg = PCMCIA_PGCRX(_slot_);
1728 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1729 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1730 PCMCIA_PGCRX(_slot_) = reg;
1733 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1738 static void cfg_port_B (void)
1740 volatile immap_t *immap;
1741 volatile cpm8xx_t *cp;
1744 immap = (immap_t *)CFG_IMMR;
1745 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1748 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1750 * Switch off all voltages, assert shutdown
1753 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1754 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1755 TPS2205_SHDN); /* enable switch */
1758 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1760 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1761 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1763 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1764 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1770 /* -------------------------------------------------------------------- */
1771 /* C2MON Boards by TTTech Computertechnik AG */
1772 /* -------------------------------------------------------------------- */
1774 #if defined(CONFIG_C2MON)
1776 #define PCMCIA_BOARD_MSG "C2MON"
1778 static void cfg_ports (void);
1780 static int hardware_enable(int slot)
1782 volatile immap_t *immap;
1783 volatile cpm8xx_t *cp;
1784 volatile pcmconf8xx_t *pcmp;
1785 volatile sysconf8xx_t *sysp;
1786 uint reg, pipr, mask;
1790 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1794 immap = (immap_t *)CFG_IMMR;
1795 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1796 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1797 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1799 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1803 * Configure SIUMCR to enable PCMCIA port B
1804 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1806 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1808 /* clear interrupt state, and disable interrupts */
1809 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1810 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1813 * Disable interrupts, DMA, and PCMCIA buffers
1814 * (isolate the interface) and assert RESET signal
1816 debug ("Disable PCMCIA buffers and assert RESET\n");
1818 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1819 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1820 PCMCIA_PGCRX(_slot_) = reg;
1824 * Make sure there is a card in the slot, then configure the interface.
1827 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1828 __LINE__,__FUNCTION__,
1829 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1830 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1831 printf (" No Card found\n");
1836 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1838 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1839 pipr = pcmp->pcmc_pipr;
1840 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1842 (reg&PCMCIA_VS1(slot))?"n":"ff",
1843 (reg&PCMCIA_VS2(slot))?"n":"ff");
1845 sreg = immap->im_ioport.iop_pcdat;
1846 if ((pipr & mask) == mask) {
1847 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1848 TPS2211_VCCD1); /* 5V on */
1849 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1850 puts (" 5.0V card found: ");
1852 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1853 TPS2211_VCCD0); /* 3V on */
1854 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1855 puts (" 3.3V card found: ");
1858 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1860 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1861 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1864 immap->im_ioport.iop_pcdat = sreg;
1866 /* Wait 500 ms; use this to check for over-current */
1867 for (i=0; i<5000; ++i) {
1868 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1869 printf (" *** Overcurrent - Safety shutdown ***\n");
1870 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1876 debug ("Enable PCMCIA buffers and stop RESET\n");
1877 reg = PCMCIA_PGCRX(_slot_);
1878 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1879 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1880 PCMCIA_PGCRX(_slot_) = reg;
1882 udelay(250000); /* some cards need >150 ms to come up :-( */
1884 debug ("# hardware_enable done\n");
1890 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1891 static int hardware_disable(int slot)
1893 volatile immap_t *immap;
1894 volatile cpm8xx_t *cp;
1895 volatile pcmconf8xx_t *pcmp;
1898 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1900 immap = (immap_t *)CFG_IMMR;
1901 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1903 /* Configure PCMCIA General Control Register */
1904 debug ("Disable PCMCIA buffers and assert RESET\n");
1906 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1907 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1908 PCMCIA_PGCRX(_slot_) = reg;
1910 /* ALl voltages off / Hi-Z */
1911 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1912 TPS2211_VCCD0 | TPS2211_VCCD1 );
1918 #endif /* CFG_CMD_PCMCIA */
1921 static int voltage_set(int slot, int vcc, int vpp)
1923 volatile immap_t *immap;
1924 volatile cpm8xx_t *cp;
1925 volatile pcmconf8xx_t *pcmp;
1929 debug ("voltage_set: "
1931 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1932 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1934 immap = (immap_t *)CFG_IMMR;
1935 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1936 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1938 * Disable PCMCIA buffers (isolate the interface)
1939 * and assert RESET signal
1941 debug ("Disable PCMCIA buffers and assert RESET\n");
1942 reg = PCMCIA_PGCRX(_slot_);
1943 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1944 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1945 PCMCIA_PGCRX(_slot_) = reg;
1949 * Configure Port C pins for
1950 * 5 Volts Enable and 3 Volts enable,
1951 * Turn all power pins to Hi-Z
1953 debug ("PCMCIA power OFF\n");
1954 cfg_ports (); /* Enables switch, but all in Hi-Z */
1956 sreg = immap->im_ioport.iop_pcdat;
1957 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1960 case 0: break; /* Switch off */
1961 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1962 sreg &= ~TPS2211_VCCD1;
1964 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1965 sreg |= TPS2211_VCCD1;
1970 /* Checking supported voltages */
1972 debug ("PIPR: 0x%x --> %s\n",
1974 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1976 immap->im_ioport.iop_pcdat = sreg;
1982 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1984 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1989 printf ("PCMCIA powered %s\n", s);
1994 debug ("Enable PCMCIA buffers and stop RESET\n");
1995 reg = PCMCIA_PGCRX(_slot_);
1996 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1997 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1998 PCMCIA_PGCRX(_slot_) = reg;
2001 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2006 static void cfg_ports (void)
2008 volatile immap_t *immap;
2009 volatile cpm8xx_t *cp;
2012 immap = (immap_t *)CFG_IMMR;
2013 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2016 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
2018 * Switch off all voltages, assert shutdown
2020 sreg = immap->im_ioport.iop_pcdat;
2021 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
2022 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
2023 immap->im_ioport.iop_pcdat = sreg;
2025 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
2026 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
2028 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
2029 immap->im_ioport.iop_pcpar,
2030 immap->im_ioport.iop_pcdir,
2031 immap->im_ioport.iop_pcdat);
2034 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
2036 * Over-Current Input only
2038 cp->cp_pbpar &= ~(TPS2211_INPUTS);
2039 cp->cp_pbdir &= ~(TPS2211_INPUTS);
2041 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
2042 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
2047 /* -------------------------------------------------------------------- */
2048 /* MBX board from Morotola */
2049 /* -------------------------------------------------------------------- */
2051 #if defined( CONFIG_MBX )
2052 #include <../board/mbx8xx/csr.h>
2054 /* A lot of this has been taken from the RPX code in this file it works from me.
2055 I have added the voltage selection for the MBX board. */
2057 /* MBX voltage bit in control register #2 */
2058 #define CR2_VPP12 ((uchar)0x10)
2059 #define CR2_VPPVDD ((uchar)0x20)
2060 #define CR2_VDD5 ((uchar)0x40)
2061 #define CR2_VDD3 ((uchar)0x80)
2063 #define PCMCIA_BOARD_MSG "MBX860"
2065 static int voltage_set (int slot, int vcc, int vpp)
2069 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2070 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
2103 /* first, turn off all power */
2104 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
2106 /* enable new powersettings */
2108 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
2113 static int hardware_enable (int slot)
2115 volatile immap_t *immap;
2116 volatile cpm8xx_t *cp;
2117 volatile pcmconf8xx_t *pcmp;
2118 volatile sysconf8xx_t *sysp;
2121 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
2126 immap = (immap_t *) CFG_IMMR;
2127 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
2128 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
2129 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
2131 /* clear interrupt state, and disable interrupts */
2132 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
2133 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
2136 * Disable interrupts, DMA, and PCMCIA buffers
2137 * (isolate the interface) and assert RESET signal
2139 debug ("Disable PCMCIA buffers and assert RESET\n");
2141 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2142 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2143 PCMCIA_PGCRX (_slot_) = reg;
2146 /* remove all power */
2147 voltage_set (slot, 0, 0);
2149 * Make sure there is a card in the slot, then configure the interface.
2152 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2153 __LINE__,__FUNCTION__,
2154 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2155 #ifndef CONFIG_HMI10
2156 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2158 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
2159 #endif /* CONFIG_HMI10 */
2160 printf (" No Card found\n");
2167 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
2168 reg = pcmp->pcmc_pipr;
2169 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
2170 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
2171 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
2173 if ((reg & mask) == mask) {
2174 voltage_set (_slot_, 50, 0);
2175 printf (" 5.0V card found: ");
2177 voltage_set (_slot_, 33, 0);
2178 printf (" 3.3V card found: ");
2181 debug ("Enable PCMCIA buffers and stop RESET\n");
2182 reg = PCMCIA_PGCRX (_slot_);
2183 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2184 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2185 PCMCIA_PGCRX (_slot_) = reg;
2187 udelay (250000); /* some cards need >150 ms to come up :-( */
2189 debug ("# hardware_enable done\n");
2194 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2195 static int hardware_disable (int slot)
2197 return 0; /* No hardware to disable */
2199 #endif /* CFG_CMD_PCMCIA */
2200 #endif /* CONFIG_MBX */
2201 /* -------------------------------------------------------------------- */
2203 /* -------------------------------------------------------------------- */
2205 #if defined(CONFIG_R360MPI)
2207 #define PCMCIA_BOARD_MSG "R360MPI"
2210 static int hardware_enable(int slot)
2212 volatile immap_t *immap;
2213 volatile cpm8xx_t *cp;
2214 volatile pcmconf8xx_t *pcmp;
2215 volatile sysconf8xx_t *sysp;
2218 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2222 immap = (immap_t *)CFG_IMMR;
2223 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2224 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2225 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2228 * Configure SIUMCR to enable PCMCIA port B
2229 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2231 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2233 /* clear interrupt state, and disable interrupts */
2234 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
2235 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
2238 * Disable interrupts, DMA, and PCMCIA buffers
2239 * (isolate the interface) and assert RESET signal
2241 debug ("Disable PCMCIA buffers and assert RESET\n");
2243 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2244 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2245 PCMCIA_PGCRX(_slot_) = reg;
2249 * Configure Ports A, B & C pins for
2250 * 5 Volts Enable and 3 Volts enable
2252 immap->im_ioport.iop_pcpar &= ~(0x0400);
2253 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2254 immap->im_ioport.iop_pcdir |= 0x0400;*/
2256 immap->im_ioport.iop_papar &= ~(0x0200);/*
2257 immap->im_ioport.iop_padir |= 0x0200;*/
2259 immap->im_ioport.iop_pbpar &= ~(0xC000);
2260 immap->im_ioport.iop_pbdir &= ~(0xC000);
2262 /* remove all power */
2264 immap->im_ioport.iop_pcdat |= 0x0400;
2265 immap->im_ioport.iop_padat |= 0x0200;
2268 * Make sure there is a card in the slot, then configure the interface.
2271 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2272 __LINE__,__FUNCTION__,
2273 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2274 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2275 printf (" No Card found\n");
2282 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2283 reg = pcmp->pcmc_pipr;
2284 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2286 (reg&PCMCIA_VS1(slot))?"n":"ff",
2287 (reg&PCMCIA_VS2(slot))?"n":"ff");
2288 if ((reg & mask) == mask) {
2289 immap->im_ioport.iop_pcdat &= ~(0x4000);
2290 puts (" 5.0V card found: ");
2292 immap->im_ioport.iop_padat &= ~(0x0002);
2293 puts (" 3.3V card found: ");
2295 immap->im_ioport.iop_pcdir |= 0x0400;
2296 immap->im_ioport.iop_padir |= 0x0200;
2298 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2299 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2300 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2303 debug ("Enable PCMCIA buffers and stop RESET\n");
2304 reg = PCMCIA_PGCRX(_slot_);
2305 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2306 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2307 PCMCIA_PGCRX(_slot_) = reg;
2309 udelay(250000); /* some cards need >150 ms to come up :-( */
2311 debug ("# hardware_enable done\n");
2317 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2318 static int hardware_disable(int slot)
2320 volatile immap_t *immap;
2321 volatile pcmconf8xx_t *pcmp;
2324 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2326 immap = (immap_t *)CFG_IMMR;
2327 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2329 /* remove all power */
2330 immap->im_ioport.iop_pcdat |= 0x0400;
2331 immap->im_ioport.iop_padat |= 0x0200;
2333 /* Configure PCMCIA General Control Register */
2334 debug ("Disable PCMCIA buffers and assert RESET\n");
2336 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2337 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2338 PCMCIA_PGCRX(_slot_) = reg;
2344 #endif /* CFG_CMD_PCMCIA */
2347 static int voltage_set(int slot, int vcc, int vpp)
2349 volatile immap_t *immap;
2350 volatile pcmconf8xx_t *pcmp;
2353 debug ("voltage_set: "
2355 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2356 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2358 immap = (immap_t *)CFG_IMMR;
2359 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2361 * Disable PCMCIA buffers (isolate the interface)
2362 * and assert RESET signal
2364 debug ("Disable PCMCIA buffers and assert RESET\n");
2365 reg = PCMCIA_PGCRX(_slot_);
2366 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2367 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2368 PCMCIA_PGCRX(_slot_) = reg;
2372 * Configure Ports A & C pins for
2373 * 5 Volts Enable and 3 Volts enable,
2374 * Turn off all power
2376 debug ("PCMCIA power OFF\n");
2377 immap->im_ioport.iop_pcpar &= ~(0x0400);
2378 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2379 immap->im_ioport.iop_pcdir |= 0x0400;*/
2381 immap->im_ioport.iop_papar &= ~(0x0200);/*
2382 immap->im_ioport.iop_padir |= 0x0200;*/
2384 immap->im_ioport.iop_pcdat |= 0x0400;
2385 immap->im_ioport.iop_padat |= 0x0200;
2390 case 33: reg |= 0x0200; break;
2391 case 50: reg |= 0x0400; break;
2395 /* Checking supported voltages */
2397 debug ("PIPR: 0x%x --> %s\n",
2399 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
2402 immap->im_ioport.iop_pcdat &= !reg;
2404 immap->im_ioport.iop_padat &= !reg;
2405 immap->im_ioport.iop_pcdir |= 0x0200;
2406 immap->im_ioport.iop_padir |= 0x0400;
2408 debug ("PCMCIA powered at %sV\n",
2409 (reg&0x0400) ? "5.0" : "3.3");
2411 debug ("PCMCIA powered down\n");
2415 debug ("Enable PCMCIA buffers and stop RESET\n");
2416 reg = PCMCIA_PGCRX(_slot_);
2417 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2418 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2419 PCMCIA_PGCRX(_slot_) = reg;
2422 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2427 #endif /* R360MPI */
2429 /* -------------------------------------------------------------------- */
2430 /* KUP4K and KUP4X Boards */
2431 /* -------------------------------------------------------------------- */
2432 #if defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
2434 #define PCMCIA_BOARD_MSG "KUP"
2436 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
2438 static int hardware_enable(int slot)
2440 volatile immap_t *immap;
2441 volatile cpm8xx_t *cp;
2442 volatile pcmconf8xx_t *pcmp;
2443 volatile sysconf8xx_t *sysp;
2446 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2450 immap = (immap_t *)CFG_IMMR;
2451 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2452 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2453 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2456 * Configure SIUMCR to enable PCMCIA port B
2457 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2459 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2461 /* clear interrupt state, and disable interrupts */
2462 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2463 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2466 * Disable interrupts, DMA, and PCMCIA buffers
2467 * (isolate the interface) and assert RESET signal
2469 debug ("Disable PCMCIA buffers and assert RESET\n");
2471 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2472 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2473 PCMCIA_PGCRX(slot) = reg;
2477 * Configure Port B pins for
2480 if (slot) { /* Slot A is built-in */
2481 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2482 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2483 /* remove all power */
2484 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2487 * Make sure there is a card in the slot, then configure the interface.
2490 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2491 __LINE__,__FUNCTION__,
2492 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2493 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2494 printf (" No Card found\n");
2501 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2502 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2503 reg = pcmp->pcmc_pipr;
2504 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2506 (reg&PCMCIA_VS1(slot))?"n":"ff",
2507 (reg&PCMCIA_VS2(slot))?"n":"ff");
2508 if ((reg & mask) == mask) {
2509 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2512 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2513 puts (" 3.3V card found: ");
2516 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2517 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2518 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2521 debug ("Enable PCMCIA buffers and stop RESET\n");
2522 reg = PCMCIA_PGCRX(slot);
2523 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2524 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2525 PCMCIA_PGCRX(slot) = reg;
2527 udelay(250000); /* some cards need >150 ms to come up :-( */
2529 debug ("# hardware_enable done\n");
2535 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2536 static int hardware_disable(int slot)
2538 volatile immap_t *immap;
2539 volatile cpm8xx_t *cp;
2540 volatile pcmconf8xx_t *pcmp;
2543 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2545 immap = (immap_t *)CFG_IMMR;
2546 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2547 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2549 /* remove all power */
2551 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2553 /* Configure PCMCIA General Control Register */
2554 debug ("Disable PCMCIA buffers and assert RESET\n");
2556 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2557 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2558 PCMCIA_PGCRX(slot) = reg;
2564 #endif /* CFG_CMD_PCMCIA */
2567 static int voltage_set(int slot, int vcc, int vpp)
2569 volatile immap_t *immap;
2570 volatile cpm8xx_t *cp;
2571 volatile pcmconf8xx_t *pcmp;
2574 debug ("voltage_set: " \
2576 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2577 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2579 if (!slot) /* Slot A is not configurable */
2582 immap = (immap_t *)CFG_IMMR;
2583 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2584 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2587 * Disable PCMCIA buffers (isolate the interface)
2588 * and assert RESET signal
2590 debug ("Disable PCMCIA buffers and assert RESET\n");
2591 reg = PCMCIA_PGCRX(slot);
2592 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2593 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2594 PCMCIA_PGCRX(slot) = reg;
2597 debug ("PCMCIA power OFF\n");
2599 * Configure Port B pins for
2602 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2603 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2604 /* remove all power */
2605 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2610 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2611 debug ("PCMCIA powered at 3.3V\n");
2614 debug ("PCMCIA: 5Volt vcc not supported\n");
2617 puts("PCMCIA: vcc not supported");
2621 /* Checking supported voltages */
2623 debug ("PIPR: 0x%x --> %s\n",
2625 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2626 ? "only 5 V --> NOT SUPPORTED"
2630 debug ("Enable PCMCIA buffers and stop RESET\n");
2631 reg = PCMCIA_PGCRX(slot);
2632 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2633 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2634 PCMCIA_PGCRX(slot) = reg;
2637 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2642 #endif /* KUP4K || KUP4X */
2645 /* -------------------------------------------------------------------- */
2646 /* End of Board Specific Stuff */
2647 /* -------------------------------------------------------------------- */
2650 /* -------------------------------------------------------------------- */
2651 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2652 /* -------------------------------------------------------------------- */
2655 * Search this table to see if the windowsize is
2659 #define M8XX_SIZES_NO 32
2661 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2662 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2663 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2664 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2665 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2667 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2668 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2669 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2670 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2673 /* -------------------------------------------------------------------- */
2675 #if ( ! defined(CONFIG_I82365) && ! defined(CONFIG_PXA_PCMCIA) )
2677 static u_int m8xx_get_graycode(u_int size)
2681 for (k = 0; k < M8XX_SIZES_NO; k++) {
2682 if(m8xx_size_to_gray[k] == size)
2686 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2692 #endif /* CONFIG_I82365 */
2694 /* -------------------------------------------------------------------- */
2697 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2699 u_int reg, clocks, psst, psl, psht;
2704 * We get called with IO maps setup to 0ns
2705 * if not specified by the user.
2706 * They should be 255ns.
2712 ns = 100; /* fast memory if 0 */
2716 * In PSST, PSL, PSHT fields we tell the controller
2717 * timing parameters in CLKOUT clock cycles.
2718 * CLKOUT is the same as GCLK2_50.
2721 /* how we want to adjust the timing - in percent */
2723 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2725 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2726 clocks = (clocks * ADJ) / (100*1000);
2728 if(clocks >= PCMCIA_BMT_LIMIT) {
2729 DEBUG(0, "Max access time limit reached\n");
2730 clocks = PCMCIA_BMT_LIMIT-1;
2733 psst = clocks / 7; /* setup time */
2734 psht = clocks / 7; /* hold time */
2735 psl = (clocks * 5) / 7; /* strobe length */
2737 psst += clocks - (psst + psht + psl);
2747 /* -------------------------------------------------------------------- */
2749 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2750 static void print_funcid (int func)
2754 case CISTPL_FUNCID_MULTI:
2755 puts (" Multi-Function");
2757 case CISTPL_FUNCID_MEMORY:
2760 case CISTPL_FUNCID_SERIAL:
2761 puts (" Serial Port");
2763 case CISTPL_FUNCID_PARALLEL:
2764 puts (" Parallel Port");
2766 case CISTPL_FUNCID_FIXED:
2767 puts (" Fixed Disk");
2769 case CISTPL_FUNCID_VIDEO:
2770 puts (" Video Adapter");
2772 case CISTPL_FUNCID_NETWORK:
2773 puts (" Network Adapter");
2775 case CISTPL_FUNCID_AIMS:
2776 puts (" AIMS Card");
2778 case CISTPL_FUNCID_SCSI:
2779 puts (" SCSI Adapter");
2787 #endif /* CONFIG_IDE_8xx_PCCARD */
2789 /* -------------------------------------------------------------------- */
2791 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2792 static void print_fixed (volatile uchar *p)
2800 case CISTPL_FUNCE_IDE_IFACE:
2801 { uchar iface = *(p+2);
2803 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2804 puts (" interface ");
2807 case CISTPL_FUNCE_IDE_MASTER:
2808 case CISTPL_FUNCE_IDE_SLAVE:
2809 { uchar f1 = *(p+2);
2812 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2814 if (f1 & CISTPL_IDE_UNIQUE)
2817 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2819 if (f2 & CISTPL_IDE_HAS_SLEEP)
2822 if (f2 & CISTPL_IDE_HAS_STANDBY)
2823 puts (" [standby]");
2825 if (f2 & CISTPL_IDE_HAS_IDLE)
2828 if (f2 & CISTPL_IDE_LOW_POWER)
2829 puts (" [low power]");
2831 if (f2 & CISTPL_IDE_REG_INHIBIT)
2832 puts (" [reg inhibit]");
2834 if (f2 & CISTPL_IDE_HAS_INDEX)
2837 if (f2 & CISTPL_IDE_IOIS16)
2845 #endif /* CONFIG_IDE_8xx_PCCARD */
2847 /* -------------------------------------------------------------------- */
2849 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2851 #define MAX_IDENT_CHARS 64
2852 #define MAX_IDENT_FIELDS 4
2854 static uchar *known_cards[] = {
2855 (uchar *)"ARGOSY PnPIDE D5",
2859 static int identify (volatile uchar *p)
2861 uchar id_str[MAX_IDENT_CHARS];
2868 return (0); /* Don't know */
2873 for (i=0; i<=4 && !done; ++i, p+=2) {
2874 while ((data = *p) != '\0') {
2880 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2890 while (--t > id_str) {
2896 puts ((char *)id_str);
2899 for (card=known_cards; *card; ++card) {
2900 debug ("## Compare against \"%s\"\n", *card);
2901 if (strcmp((char *)*card, (char *)id_str) == 0) { /* found! */
2902 debug ("## CARD FOUND ##\n");
2907 return (0); /* don't know */
2909 #endif /* CONFIG_IDE_8xx_PCCARD */
2911 /* -------------------------------------------------------------------- */
2912 /* NETTA board by Intracom S.A. */
2913 /* -------------------------------------------------------------------- */
2915 #if defined(CONFIG_NETTA)
2917 /* some sane bit macros */
2918 #define _BD(_b) (1U << (31-(_b)))
2919 #define _BDR(_l, _h) (((((1U << (31-(_l))) - 1) << 1) | 1) & ~((1U << (31-(_h))) - 1))
2921 #define _BW(_b) (1U << (15-(_b)))
2922 #define _BWR(_l, _h) (((((1U << (15-(_l))) - 1) << 1) | 1) & ~((1U << (15-(_h))) - 1))
2924 #define _BB(_b) (1U << (7-(_b)))
2925 #define _BBR(_l, _h) (((((1U << (7-(_l))) - 1) << 1) | 1) & ~((1U << (7-(_h))) - 1))
2927 #define _B(_b) _BD(_b)
2928 #define _BR(_l, _h) _BDR(_l, _h)
2930 #define PCMCIA_BOARD_MSG "NETTA"
2932 static const unsigned short vppd_masks[2] = { _BW(14), _BW(15) };
2934 static void cfg_vppd(int no)
2936 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2937 unsigned short mask;
2939 if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
2942 mask = vppd_masks[no];
2944 immap->im_ioport.iop_papar &= ~mask;
2945 immap->im_ioport.iop_paodr &= ~mask;
2946 immap->im_ioport.iop_padir |= mask;
2949 static void set_vppd(int no, int what)
2951 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2952 unsigned short mask;
2954 if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
2957 mask = vppd_masks[no];
2960 immap->im_ioport.iop_padat |= mask;
2962 immap->im_ioport.iop_padat &= ~mask;
2965 static const unsigned short vccd_masks[2] = { _BW(10), _BW(6) };
2967 static void cfg_vccd(int no)
2969 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2970 unsigned short mask;
2972 if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
2975 mask = vccd_masks[no];
2977 immap->im_ioport.iop_papar &= ~mask;
2978 immap->im_ioport.iop_paodr &= ~mask;
2979 immap->im_ioport.iop_padir |= mask;
2982 static void set_vccd(int no, int what)
2984 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2985 unsigned short mask;
2987 if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
2990 mask = vccd_masks[no];
2993 immap->im_ioport.iop_padat |= mask;
2995 immap->im_ioport.iop_padat &= ~mask;
2998 static const unsigned short oc_mask = _BW(8);
3000 static void cfg_oc(void)
3002 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3003 unsigned short mask = oc_mask;
3005 immap->im_ioport.iop_pcdir &= ~mask;
3006 immap->im_ioport.iop_pcso &= ~mask;
3007 immap->im_ioport.iop_pcint &= ~mask;
3008 immap->im_ioport.iop_pcpar &= ~mask;
3011 static int get_oc(void)
3013 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3014 unsigned short mask = oc_mask;
3017 what = !!(immap->im_ioport.iop_pcdat & mask);;
3021 static const unsigned short shdn_mask = _BW(12);
3023 static void cfg_shdn(void)
3025 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3026 unsigned short mask;
3030 immap->im_ioport.iop_papar &= ~mask;
3031 immap->im_ioport.iop_paodr &= ~mask;
3032 immap->im_ioport.iop_padir |= mask;
3035 static void set_shdn(int what)
3037 volatile immap_t *immap = (immap_t *)CFG_IMMR;
3038 unsigned short mask;
3043 immap->im_ioport.iop_padat |= mask;
3045 immap->im_ioport.iop_padat &= ~mask;
3048 static void cfg_ports (void);
3050 static int hardware_enable(int slot)
3052 volatile immap_t *immap;
3053 volatile cpm8xx_t *cp;
3054 volatile pcmconf8xx_t *pcmp;
3055 volatile sysconf8xx_t *sysp;
3056 uint reg, pipr, mask;
3059 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3063 immap = (immap_t *)CFG_IMMR;
3064 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
3065 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3066 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3068 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
3071 /* clear interrupt state, and disable interrupts */
3072 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
3073 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
3076 * Disable interrupts, DMA, and PCMCIA buffers
3077 * (isolate the interface) and assert RESET signal
3079 debug ("Disable PCMCIA buffers and assert RESET\n");
3081 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3082 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3083 PCMCIA_PGCRX(_slot_) = reg;
3088 * Make sure there is a card in the slot, then configure the interface.
3091 debug ("[%d] %s: PIPR(%p)=0x%x\n",
3092 __LINE__,__FUNCTION__,
3093 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
3094 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
3095 printf (" No Card found\n");
3100 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
3102 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
3103 pipr = pcmp->pcmc_pipr;
3104 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
3106 (reg&PCMCIA_VS1(slot))?"n":"ff",
3107 (reg&PCMCIA_VS2(slot))?"n":"ff");
3109 if ((pipr & mask) == mask) {
3110 set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
3111 set_vccd(0, 0); set_vccd(1, 1); /* 5V on, 3V off */
3112 puts (" 5.0V card found: ");
3114 set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
3115 set_vccd(0, 1); set_vccd(1, 0); /* 5V off, 3V on */
3116 puts (" 3.3V card found: ");
3119 /* Wait 500 ms; use this to check for over-current */
3120 for (i=0; i<5000; ++i) {
3122 printf (" *** Overcurrent - Safety shutdown ***\n");
3123 set_vccd(0, 0); set_vccd(1, 0); /* VAVPP => Hi-Z */
3129 debug ("Enable PCMCIA buffers and stop RESET\n");
3130 reg = PCMCIA_PGCRX(_slot_);
3131 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3132 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3133 PCMCIA_PGCRX(_slot_) = reg;
3135 udelay(250000); /* some cards need >150 ms to come up :-( */
3137 debug ("# hardware_enable done\n");
3143 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3144 static int hardware_disable(int slot)
3146 volatile immap_t *immap;
3147 volatile pcmconf8xx_t *pcmp;
3150 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3152 immap = (immap_t *)CFG_IMMR;
3153 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3155 /* Configure PCMCIA General Control Register */
3156 debug ("Disable PCMCIA buffers and assert RESET\n");
3158 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3159 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3160 PCMCIA_PGCRX(_slot_) = reg;
3162 /* All voltages off / Hi-Z */
3163 set_vppd(0, 1); set_vppd(1, 1);
3164 set_vccd(0, 1); set_vccd(1, 1);
3170 #endif /* CFG_CMD_PCMCIA */
3173 static int voltage_set(int slot, int vcc, int vpp)
3175 volatile immap_t *immap;
3176 volatile cpm8xx_t *cp;
3177 volatile pcmconf8xx_t *pcmp;
3181 debug ("voltage_set: "
3183 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
3184 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
3186 immap = (immap_t *)CFG_IMMR;
3187 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3188 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3190 * Disable PCMCIA buffers (isolate the interface)
3191 * and assert RESET signal
3193 debug ("Disable PCMCIA buffers and assert RESET\n");
3194 reg = PCMCIA_PGCRX(_slot_);
3195 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3196 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3197 PCMCIA_PGCRX(_slot_) = reg;
3201 * Configure Port C pins for
3202 * 5 Volts Enable and 3 Volts enable,
3203 * Turn all power pins to Hi-Z
3205 debug ("PCMCIA power OFF\n");
3206 cfg_ports (); /* Enables switch, but all in Hi-Z */
3208 sreg = immap->im_ioport.iop_pcdat;
3209 set_vppd(0, 1); set_vppd(1, 1);
3213 break; /* Switch off */
3216 set_vccd(0, 1); set_vccd(1, 0);
3220 set_vccd(0, 0); set_vccd(1, 1);
3227 /* Checking supported voltages */
3229 debug ("PIPR: 0x%x --> %s\n",
3231 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
3234 debug ("Enable PCMCIA buffers and stop RESET\n");
3235 reg = PCMCIA_PGCRX(_slot_);
3236 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3237 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3238 PCMCIA_PGCRX(_slot_) = reg;
3241 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
3246 static void cfg_ports (void)
3248 volatile immap_t *immap;
3249 volatile cpm8xx_t *cp;
3251 immap = (immap_t *)CFG_IMMR;
3252 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3255 cfg_vppd(0); cfg_vppd(1); /* VPPD0,VPPD1 VAVPP => Hi-Z */
3256 cfg_vccd(0); cfg_vccd(1); /* 3V and 5V off */
3261 * Configure Port A for TPS2211 PC-Card Power-Interface Switch
3263 * Switch off all voltages, assert shutdown
3265 set_vppd(0, 1); set_vppd(1, 1);
3266 set_vccd(0, 0); set_vccd(1, 0);
3275 /* -------------------------------------------------------------------- */
3277 /* -------------------------------------------------------------------- */
3279 #if defined(CONFIG_UC100)
3281 #define PCMCIA_BOARD_MSG "UC100"
3284 * Remark: don't turn off OE "__MY_PCMCIA_GCRX_CXOE" on UC100 board.
3285 * This leads to board-hangup! (sr, 8 Dez. 2004)
3288 static void cfg_ports (void);
3290 static int hardware_enable(int slot)
3292 volatile immap_t *immap;
3293 volatile cpm8xx_t *cp;
3294 volatile pcmconf8xx_t *pcmp;
3295 volatile sysconf8xx_t *sysp;
3298 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3302 immap = (immap_t *)CFG_IMMR;
3303 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
3304 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3305 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3307 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
3311 * Configure SIUMCR to enable PCMCIA port B
3312 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
3314 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
3316 /* clear interrupt state, and disable interrupts */
3317 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
3318 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
3321 * Disable interrupts, DMA, and PCMCIA buffers
3322 * (isolate the interface) and assert RESET signal
3324 debug ("Disable PCMCIA buffers and assert RESET\n");
3326 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3327 PCMCIA_PGCRX(_slot_) = reg;
3331 * Make sure there is a card in the slot, then configure the interface.
3334 debug ("[%d] %s: PIPR(%p)=0x%x\n",
3335 __LINE__,__FUNCTION__,
3336 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
3337 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
3338 printf (" No Card found\n");
3345 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
3346 reg = pcmp->pcmc_pipr;
3347 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
3349 (reg&PCMCIA_VS1(slot))?"n":"ff",
3350 (reg&PCMCIA_VS2(slot))?"n":"ff");
3351 if ((reg & mask) == mask) {
3352 puts (" 5.0V card found: ");
3354 puts (" 3.3V card found: ");
3358 immap->im_ioport.iop_padat |= 0x8000; /* power enable 3.3V */
3362 debug ("Enable PCMCIA buffers and stop RESET\n");
3363 reg = PCMCIA_PGCRX(_slot_);
3364 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3365 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3366 PCMCIA_PGCRX(_slot_) = reg;
3368 udelay(250000); /* some cards need >150 ms to come up :-( */
3370 debug ("# hardware_enable done\n");
3376 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3377 static int hardware_disable(int slot)
3379 volatile immap_t *immap;
3380 volatile cpm8xx_t *cp;
3381 volatile pcmconf8xx_t *pcmp;
3384 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3386 immap = (immap_t *)CFG_IMMR;
3387 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3389 /* switch VCC off */
3390 immap->im_ioport.iop_padat &= ~0x8000; /* power disable 3.3V */
3392 /* Configure PCMCIA General Control Register */
3393 debug ("Disable PCMCIA buffers and assert RESET\n");
3395 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3396 PCMCIA_PGCRX(_slot_) = reg;
3402 #endif /* CFG_CMD_PCMCIA */
3405 static int voltage_set(int slot, int vcc, int vpp)
3407 volatile immap_t *immap;
3408 volatile pcmconf8xx_t *pcmp;
3411 debug ("voltage_set: "
3413 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
3414 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
3416 immap = (immap_t *)CFG_IMMR;
3417 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3419 * Disable PCMCIA buffers (isolate the interface)
3420 * and assert RESET signal
3422 debug ("Disable PCMCIA buffers and assert RESET\n");
3423 reg = PCMCIA_PGCRX(_slot_);
3424 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3425 PCMCIA_PGCRX(_slot_) = reg;
3429 * Configure Port C pins for
3430 * 5 Volts Enable and 3 Volts enable,
3431 * Turn all power pins to Hi-Z
3433 debug ("PCMCIA power OFF\n");
3434 cfg_ports (); /* Enables switch, but all in Hi-Z */
3436 debug ("Enable PCMCIA buffers and stop RESET\n");
3437 reg = PCMCIA_PGCRX(_slot_);
3438 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3439 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3440 PCMCIA_PGCRX(_slot_) = reg;
3443 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
3448 static void cfg_ports (void)
3450 volatile immap_t *immap;
3452 immap = (immap_t *)CFG_IMMR;
3455 * Configure Port A for MAX1602 PC-Card Power-Interface Switch
3457 immap->im_ioport.iop_padat &= ~0x8000; /* set port x output to low */
3458 immap->im_ioport.iop_padir |= 0x8000; /* enable port x as output */
3460 debug ("Set Port A: PAR: %08x DIR: %08x DAT: %08x\n",
3461 immap->im_ioport.iop_papar, immap->im_ioport.iop_padir,
3462 immap->im_ioport.iop_padat);
3468 /* -------------------------------------------------------------------- */
3470 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
3472 /**************************************************/
3474 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3476 pinit, 2, 1, do_pinit,
3477 "pinit - PCMCIA sub-system\n",
3478 "on - power on PCMCIA socket\n"
3479 "pinit off - power off PCMCIA socket\n"