2 * (C) Copyright 2000-2004
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)
723 #if defined(CONFIG_TQM8xxL)
724 #define PCMCIA_BOARD_MSG "TQM8xxL"
726 #if defined(CONFIG_SVM_SC8xx)
727 #define PCMCIA_BOARD_MSG "SC8xx"
730 static int hardware_enable(int slot)
732 volatile immap_t *immap;
733 volatile cpm8xx_t *cp;
734 volatile pcmconf8xx_t *pcmp;
735 volatile sysconf8xx_t *sysp;
738 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
742 immap = (immap_t *)CFG_IMMR;
743 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
744 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
745 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
748 * Configure SIUMCR to enable PCMCIA port B
749 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
751 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
753 /* clear interrupt state, and disable interrupts */
754 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
755 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
758 * Disable interrupts, DMA, and PCMCIA buffers
759 * (isolate the interface) and assert RESET signal
761 debug ("Disable PCMCIA buffers and assert RESET\n");
763 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
765 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
767 PCMCIA_PGCRX(slot) = reg;
773 * Configure Port C pins for
774 * 5 Volts Enable and 3 Volts enable
776 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
777 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
778 /* remove all power */
780 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
782 #else /* CONFIG_HMI10 */
784 * Configure Port B pins for
785 * 5 Volts Enable and 3 Volts enable
787 immap->im_cpm.cp_pbpar &= ~(0x00000300);
789 /* remove all power */
790 immap->im_cpm.cp_pbdat |= 0x00000300;
791 #endif /* CONFIG_HMI10 */
794 * Make sure there is a card in the slot, then configure the interface.
797 debug ("[%d] %s: PIPR(%p)=0x%x\n",
798 __LINE__,__FUNCTION__,
799 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
801 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
803 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
804 #endif /* CONFIG_HMI10 */
805 printf (" No Card found\n");
812 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
813 reg = pcmp->pcmc_pipr;
814 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
816 (reg&PCMCIA_VS1(slot))?"n":"ff",
817 (reg&PCMCIA_VS2(slot))?"n":"ff");
819 if ((reg & mask) == mask) {
821 immap->im_ioport.iop_pcdat |= 0x0004;
823 immap->im_cpm.cp_pbdat &= ~(0x0000100);
824 #endif /* CONFIG_HMI10 */
825 puts (" 5.0V card found: ");
828 immap->im_ioport.iop_pcdat |= 0x0002;
830 immap->im_cpm.cp_pbdat &= ~(0x0000200);
831 #endif /* CONFIG_HMI10 */
832 puts (" 3.3V card found: ");
835 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
837 immap->im_cpm.cp_pbdir |= 0x00000300;
838 #endif /* CONFIG_HMI10 */
840 if ((reg & mask) == mask) {
841 puts (" 5.0V card found: ");
843 puts (" 3.3V card found: ");
847 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
848 cp->cp_pbdir &= ~(0x0020 | 0x0010);
849 cp->cp_pbpar &= ~(0x0020 | 0x0010);
853 debug ("Enable PCMCIA buffers and stop RESET\n");
854 reg = PCMCIA_PGCRX(slot);
855 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
857 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
859 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
861 PCMCIA_PGCRX(slot) = reg;
863 udelay(250000); /* some cards need >150 ms to come up :-( */
865 debug ("# hardware_enable done\n");
871 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
872 static int hardware_disable(int slot)
874 volatile immap_t *immap;
875 volatile pcmconf8xx_t *pcmp;
878 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
880 immap = (immap_t *)CFG_IMMR;
881 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
885 /* remove all power */
886 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
888 #else /* CONFIG_HMI10 */
889 immap->im_cpm.cp_pbdat |= 0x00000300;
890 #endif /* CONFIG_HMI10 */
892 debug ("Disable PCMCIA buffers and assert RESET\n");
894 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
896 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
898 PCMCIA_PGCRX(slot) = reg;
904 #endif /* CFG_CMD_PCMCIA */
907 static int voltage_set(int slot, int vcc, int vpp)
912 static int voltage_set(int slot, int vcc, int vpp)
914 volatile immap_t *immap;
915 volatile pcmconf8xx_t *pcmp;
918 debug ("voltage_set: "
920 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
921 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
923 immap = (immap_t *)CFG_IMMR;
924 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
926 * Disable PCMCIA buffers (isolate the interface)
927 * and assert RESET signal
929 debug ("Disable PCMCIA buffers and assert RESET\n");
930 reg = PCMCIA_PGCRX(slot);
931 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
933 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
935 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
937 PCMCIA_PGCRX(slot) = reg;
942 * Configure Port C pins for
943 * 5 Volts Enable and 3 Volts enable,
946 debug ("PCMCIA power OFF\n");
947 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
948 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
949 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
954 case 33: reg |= 0x0002; break;
955 case 50: reg |= 0x0004; break;
958 #else /* CONFIG_HMI10 */
960 * Configure Port B pins for
961 * 5 Volts Enable and 3 Volts enable,
964 debug ("PCMCIA power OFF\n");
965 immap->im_cpm.cp_pbpar &= ~(0x00000300);
966 /* remove all power */
968 immap->im_cpm.cp_pbdat |= 0x00000300;
973 case 33: reg |= 0x00000200; break;
974 case 50: reg |= 0x00000100; break;
977 #endif /* CONFIG_HMI10 */
979 /* Checking supported voltages */
981 debug ("PIPR: 0x%x --> %s\n",
983 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
986 immap->im_ioport.iop_pcdat |= reg;
987 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
989 immap->im_cpm.cp_pbdat &= !reg;
990 immap->im_cpm.cp_pbdir |= 0x00000300;
991 #endif /* CONFIG_HMI10 */
994 debug ("PCMCIA powered at %sV\n",
995 (reg&0x0004) ? "5.0" : "3.3");
997 debug ("PCMCIA powered at %sV\n",
998 (reg&0x00000200) ? "5.0" : "3.3");
999 #endif /* CONFIG_HMI10 */
1001 debug ("PCMCIA powered down\n");
1005 debug ("Enable PCMCIA buffers and stop RESET\n");
1006 reg = PCMCIA_PGCRX(slot);
1007 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1009 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1011 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1013 PCMCIA_PGCRX(slot) = reg;
1016 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1022 #endif /* TQM8xxL */
1025 /* -------------------------------------------------------------------- */
1027 /* -------------------------------------------------------------------- */
1029 #if defined(CONFIG_LWMON)
1031 #define PCMCIA_BOARD_MSG "LWMON"
1033 /* #define's for MAX1604 Power Switch */
1034 #define MAX1604_OP_SUS 0x80
1035 #define MAX1604_VCCBON 0x40
1036 #define MAX1604_VCC_35 0x20
1037 #define MAX1604_VCCBHIZ 0x10
1038 #define MAX1604_VPPBON 0x08
1039 #define MAX1604_VPPBPBPGM 0x04
1040 #define MAX1604_VPPBHIZ 0x02
1043 static int hardware_enable(int slot)
1045 volatile immap_t *immap;
1046 volatile cpm8xx_t *cp;
1047 volatile pcmconf8xx_t *pcmp;
1048 volatile sysconf8xx_t *sysp;
1053 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1055 /* Switch on PCMCIA port in PIC register 0x60 */
1056 reg = pic_read (0x60);
1057 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1059 /* reg |= 0x08; Vpp not needed */
1060 pic_write (0x60, reg);
1062 reg = pic_read (0x60);
1063 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1067 immap = (immap_t *)CFG_IMMR;
1068 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1069 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1070 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1073 * Configure SIUMCR to enable PCMCIA port B
1074 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1076 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1078 /* clear interrupt state, and disable interrupts */
1079 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1080 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1083 * Disable interrupts, DMA, and PCMCIA buffers
1084 * (isolate the interface) and assert RESET signal
1086 debug ("Disable PCMCIA buffers and assert RESET\n");
1088 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1089 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1090 PCMCIA_PGCRX(_slot_) = reg;
1094 * Make sure there is a card in the slot, then configure the interface.
1097 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1098 __LINE__,__FUNCTION__,
1099 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1100 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1101 printf (" No Card found\n");
1108 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1109 reg = pcmp->pcmc_pipr;
1110 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1112 (reg&PCMCIA_VS1(slot))?"n":"ff",
1113 (reg&PCMCIA_VS2(slot))?"n":"ff");
1114 if ((reg & mask) == mask) {
1115 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
1116 puts (" 5.0V card found: ");
1118 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
1119 puts (" 3.3V card found: ");
1123 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
1124 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1125 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1129 debug ("Enable PCMCIA buffers and stop RESET\n");
1130 reg = PCMCIA_PGCRX(_slot_);
1131 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1132 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1133 PCMCIA_PGCRX(_slot_) = reg;
1135 udelay(250000); /* some cards need >150 ms to come up :-( */
1137 debug ("# hardware_enable done\n");
1143 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1144 static int hardware_disable(int slot)
1146 volatile immap_t *immap;
1147 volatile pcmconf8xx_t *pcmp;
1151 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1153 immap = (immap_t *)CFG_IMMR;
1154 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1156 /* remove all power, put output in high impedance state */
1157 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1158 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1159 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1161 /* Configure PCMCIA General Control Register */
1162 debug ("Disable PCMCIA buffers and assert RESET\n");
1164 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1165 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1166 PCMCIA_PGCRX(_slot_) = reg;
1168 /* Switch off PCMCIA port in PIC register 0x60 */
1169 reg = pic_read (0x60);
1170 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1173 pic_write (0x60, reg);
1175 reg = pic_read (0x60);
1176 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1182 #endif /* CFG_CMD_PCMCIA */
1185 static int voltage_set(int slot, int vcc, int vpp)
1187 volatile immap_t *immap;
1188 volatile pcmconf8xx_t *pcmp;
1192 debug ("voltage_set: "
1194 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1195 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1197 immap = (immap_t *)CFG_IMMR;
1198 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1200 * Disable PCMCIA buffers (isolate the interface)
1201 * and assert RESET signal
1203 debug ("Disable PCMCIA buffers and assert RESET\n");
1204 reg = PCMCIA_PGCRX(_slot_);
1205 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1206 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1207 PCMCIA_PGCRX(_slot_) = reg;
1211 * Turn off all power (switch to high impedance)
1213 debug ("PCMCIA power OFF\n");
1214 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1215 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1216 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1221 case 33: val = MAX1604_VCC_35; break;
1226 /* Checking supported voltages */
1228 debug ("PIPR: 0x%x --> %s\n",
1230 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1232 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1234 debug ("PCMCIA powered at %sV\n",
1235 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
1237 debug ("PCMCIA powered down\n");
1241 debug ("Enable PCMCIA buffers and stop RESET\n");
1242 reg = PCMCIA_PGCRX(_slot_);
1243 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1244 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1245 PCMCIA_PGCRX(_slot_) = reg;
1248 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1255 /* -------------------------------------------------------------------- */
1256 /* GTH board by Corelatus AB */
1257 /* -------------------------------------------------------------------- */
1258 #if defined(CONFIG_GTH)
1260 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
1262 static int voltage_set (int slot, int vcc, int vpp)
1267 static int hardware_enable (int slot)
1269 volatile immap_t *immap;
1270 volatile cpm8xx_t *cp;
1271 volatile pcmconf8xx_t *pcmp;
1272 volatile sysconf8xx_t *sysp;
1275 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
1277 immap = (immap_t *) CFG_IMMR;
1278 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1279 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1280 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1282 /* clear interrupt state, and disable interrupts */
1283 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1284 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1287 * Disable interrupts, DMA, and PCMCIA buffers
1288 * (isolate the interface) and assert RESET signal
1290 debug ("Disable PCMCIA buffers and assert RESET\n");
1292 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1293 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1294 PCMCIA_PGCRX (_slot_) = reg;
1298 * Make sure there is a card in the slot,
1299 * then configure the interface.
1302 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1303 __LINE__, __FUNCTION__,
1304 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1305 if (pcmp->pcmc_pipr & 0x98000000) {
1306 printf (" No Card found\n");
1310 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1311 reg = pcmp->pcmc_pipr;
1312 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1314 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1315 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1317 debug ("Enable PCMCIA buffers and stop RESET\n");
1318 reg = PCMCIA_PGCRX (_slot_);
1319 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1320 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1321 PCMCIA_PGCRX (_slot_) = reg;
1323 udelay (250000); /* some cards need >150 ms to come up :-( */
1325 debug ("# hardware_enable done\n");
1329 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1330 static int hardware_disable(int slot)
1332 return 0; /* No hardware to disable */
1334 #endif /* CFG_CMD_PCMCIA */
1335 #endif /* CONFIG_GTH */
1337 /* -------------------------------------------------------------------- */
1338 /* ICU862 Boards by Cambridge Broadband Ltd. */
1339 /* -------------------------------------------------------------------- */
1341 #if defined(CONFIG_ICU862)
1343 #define PCMCIA_BOARD_MSG "ICU862"
1345 static void cfg_port_B (void);
1347 static int hardware_enable(int slot)
1349 volatile immap_t *immap;
1350 volatile cpm8xx_t *cp;
1351 volatile pcmconf8xx_t *pcmp;
1352 volatile sysconf8xx_t *sysp;
1353 uint reg, pipr, mask;
1356 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1360 immap = (immap_t *)CFG_IMMR;
1361 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1362 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1363 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1365 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1369 * Configure SIUMCR to enable PCMCIA port B
1370 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1372 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1374 /* clear interrupt state, and disable interrupts */
1375 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1376 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1379 * Disable interrupts, DMA, and PCMCIA buffers
1380 * (isolate the interface) and assert RESET signal
1382 debug ("Disable PCMCIA buffers and assert RESET\n");
1384 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1385 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1386 PCMCIA_PGCRX(_slot_) = reg;
1390 * Make sure there is a card in the slot, then configure the interface.
1393 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1394 __LINE__,__FUNCTION__,
1395 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1396 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1397 printf (" No Card found\n");
1402 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1404 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1405 pipr = pcmp->pcmc_pipr;
1406 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1408 (reg&PCMCIA_VS1(slot))?"n":"ff",
1409 (reg&PCMCIA_VS2(slot))?"n":"ff");
1412 if ((pipr & mask) == mask) {
1413 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1414 TPS2205_VCC3); /* 3V off */
1415 reg &= ~(TPS2205_VCC5); /* 5V on */
1416 puts (" 5.0V card found: ");
1418 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1419 TPS2205_VCC5); /* 5V off */
1420 reg &= ~(TPS2205_VCC3); /* 3V on */
1421 puts (" 3.3V card found: ");
1424 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1426 (reg & TPS2205_VCC3) ? "off" : "on",
1427 (reg & TPS2205_VCC5) ? "off" : "on",
1428 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1429 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1433 /* Wait 500 ms; use this to check for over-current */
1434 for (i=0; i<5000; ++i) {
1435 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1436 printf (" *** Overcurrent - Safety shutdown ***\n");
1437 cp->cp_pbdat &= ~(TPS2205_SHDN);
1443 debug ("Enable PCMCIA buffers and stop RESET\n");
1444 reg = PCMCIA_PGCRX(_slot_);
1445 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1446 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1447 PCMCIA_PGCRX(_slot_) = reg;
1449 udelay(250000); /* some cards need >150 ms to come up :-( */
1451 debug ("# hardware_enable done\n");
1457 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1458 static int hardware_disable(int slot)
1460 volatile immap_t *immap;
1461 volatile cpm8xx_t *cp;
1462 volatile pcmconf8xx_t *pcmp;
1465 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1467 immap = (immap_t *)CFG_IMMR;
1468 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1469 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1472 cp->cp_pbdat &= ~(TPS2205_SHDN);
1474 /* Configure PCMCIA General Control Register */
1475 debug ("Disable PCMCIA buffers and assert RESET\n");
1477 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1478 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1479 PCMCIA_PGCRX(_slot_) = reg;
1485 #endif /* CFG_CMD_PCMCIA */
1488 static int voltage_set(int slot, int vcc, int vpp)
1490 volatile immap_t *immap;
1491 volatile cpm8xx_t *cp;
1492 volatile pcmconf8xx_t *pcmp;
1495 debug ("voltage_set: "
1497 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1498 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1500 immap = (immap_t *)CFG_IMMR;
1501 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1502 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1504 * Disable PCMCIA buffers (isolate the interface)
1505 * and assert RESET signal
1507 debug ("Disable PCMCIA buffers and assert RESET\n");
1508 reg = PCMCIA_PGCRX(_slot_);
1509 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1510 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1511 PCMCIA_PGCRX(_slot_) = reg;
1515 * Configure Port C pins for
1516 * 5 Volts Enable and 3 Volts enable,
1517 * Turn all power pins to Hi-Z
1519 debug ("PCMCIA power OFF\n");
1520 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1525 case 0: break; /* Switch off */
1526 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1527 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1531 /* Checking supported voltages */
1533 debug ("PIPR: 0x%x --> %s\n",
1535 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1543 if ((reg & TPS2205_VCC3) == 0) {
1545 } else if ((reg & TPS2205_VCC5) == 0) {
1550 printf ("PCMCIA powered %s\n", s);
1555 debug ("Enable PCMCIA buffers and stop RESET\n");
1556 reg = PCMCIA_PGCRX(_slot_);
1557 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1558 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1559 PCMCIA_PGCRX(_slot_) = reg;
1562 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1567 static void cfg_port_B (void)
1569 volatile immap_t *immap;
1570 volatile cpm8xx_t *cp;
1573 immap = (immap_t *)CFG_IMMR;
1574 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1577 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1579 * Switch off all voltages, assert shutdown
1582 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1583 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1584 TPS2205_SHDN); /* enable switch */
1587 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1589 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1590 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1592 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1593 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1599 /* -------------------------------------------------------------------- */
1600 /* C2MON Boards by TTTech Computertechnik AG */
1601 /* -------------------------------------------------------------------- */
1603 #if defined(CONFIG_C2MON)
1605 #define PCMCIA_BOARD_MSG "C2MON"
1607 static void cfg_ports (void);
1609 static int hardware_enable(int slot)
1611 volatile immap_t *immap;
1612 volatile cpm8xx_t *cp;
1613 volatile pcmconf8xx_t *pcmp;
1614 volatile sysconf8xx_t *sysp;
1615 uint reg, pipr, mask;
1619 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1623 immap = (immap_t *)CFG_IMMR;
1624 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1625 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1626 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1628 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1632 * Configure SIUMCR to enable PCMCIA port B
1633 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1635 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1637 /* clear interrupt state, and disable interrupts */
1638 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1639 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1642 * Disable interrupts, DMA, and PCMCIA buffers
1643 * (isolate the interface) and assert RESET signal
1645 debug ("Disable PCMCIA buffers and assert RESET\n");
1647 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1648 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1649 PCMCIA_PGCRX(_slot_) = reg;
1653 * Make sure there is a card in the slot, then configure the interface.
1656 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1657 __LINE__,__FUNCTION__,
1658 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1659 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1660 printf (" No Card found\n");
1665 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1667 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1668 pipr = pcmp->pcmc_pipr;
1669 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1671 (reg&PCMCIA_VS1(slot))?"n":"ff",
1672 (reg&PCMCIA_VS2(slot))?"n":"ff");
1674 sreg = immap->im_ioport.iop_pcdat;
1675 if ((pipr & mask) == mask) {
1676 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1677 TPS2211_VCCD1); /* 5V on */
1678 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1679 puts (" 5.0V card found: ");
1681 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1682 TPS2211_VCCD0); /* 3V on */
1683 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1684 puts (" 3.3V card found: ");
1687 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1689 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1690 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1693 immap->im_ioport.iop_pcdat = sreg;
1695 /* Wait 500 ms; use this to check for over-current */
1696 for (i=0; i<5000; ++i) {
1697 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1698 printf (" *** Overcurrent - Safety shutdown ***\n");
1699 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1705 debug ("Enable PCMCIA buffers and stop RESET\n");
1706 reg = PCMCIA_PGCRX(_slot_);
1707 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1708 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1709 PCMCIA_PGCRX(_slot_) = reg;
1711 udelay(250000); /* some cards need >150 ms to come up :-( */
1713 debug ("# hardware_enable done\n");
1719 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1720 static int hardware_disable(int slot)
1722 volatile immap_t *immap;
1723 volatile cpm8xx_t *cp;
1724 volatile pcmconf8xx_t *pcmp;
1727 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1729 immap = (immap_t *)CFG_IMMR;
1730 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1732 /* Configure PCMCIA General Control Register */
1733 debug ("Disable PCMCIA buffers and assert RESET\n");
1735 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1736 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1737 PCMCIA_PGCRX(_slot_) = reg;
1739 /* ALl voltages off / Hi-Z */
1740 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1741 TPS2211_VCCD0 | TPS2211_VCCD1 );
1747 #endif /* CFG_CMD_PCMCIA */
1750 static int voltage_set(int slot, int vcc, int vpp)
1752 volatile immap_t *immap;
1753 volatile cpm8xx_t *cp;
1754 volatile pcmconf8xx_t *pcmp;
1758 debug ("voltage_set: "
1760 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1761 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1763 immap = (immap_t *)CFG_IMMR;
1764 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1765 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1767 * Disable PCMCIA buffers (isolate the interface)
1768 * and assert RESET signal
1770 debug ("Disable PCMCIA buffers and assert RESET\n");
1771 reg = PCMCIA_PGCRX(_slot_);
1772 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1773 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1774 PCMCIA_PGCRX(_slot_) = reg;
1778 * Configure Port C pins for
1779 * 5 Volts Enable and 3 Volts enable,
1780 * Turn all power pins to Hi-Z
1782 debug ("PCMCIA power OFF\n");
1783 cfg_ports (); /* Enables switch, but all in Hi-Z */
1785 sreg = immap->im_ioport.iop_pcdat;
1786 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1789 case 0: break; /* Switch off */
1790 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1791 sreg &= ~TPS2211_VCCD1;
1793 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1794 sreg |= TPS2211_VCCD1;
1799 /* Checking supported voltages */
1801 debug ("PIPR: 0x%x --> %s\n",
1803 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1805 immap->im_ioport.iop_pcdat = sreg;
1811 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1813 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1818 printf ("PCMCIA powered %s\n", s);
1823 debug ("Enable PCMCIA buffers and stop RESET\n");
1824 reg = PCMCIA_PGCRX(_slot_);
1825 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1826 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1827 PCMCIA_PGCRX(_slot_) = reg;
1830 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1835 static void cfg_ports (void)
1837 volatile immap_t *immap;
1838 volatile cpm8xx_t *cp;
1841 immap = (immap_t *)CFG_IMMR;
1842 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1845 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1847 * Switch off all voltages, assert shutdown
1849 sreg = immap->im_ioport.iop_pcdat;
1850 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1851 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1852 immap->im_ioport.iop_pcdat = sreg;
1854 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1855 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1857 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1858 immap->im_ioport.iop_pcpar,
1859 immap->im_ioport.iop_pcdir,
1860 immap->im_ioport.iop_pcdat);
1863 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1865 * Over-Current Input only
1867 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1868 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1870 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1871 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1876 /* -------------------------------------------------------------------- */
1877 /* MBX board from Morotola */
1878 /* -------------------------------------------------------------------- */
1880 #if defined( CONFIG_MBX )
1881 #include <../board/mbx8xx/csr.h>
1883 /* A lot of this has been taken from the RPX code in this file it works from me.
1884 I have added the voltage selection for the MBX board. */
1886 /* MBX voltage bit in control register #2 */
1887 #define CR2_VPP12 ((uchar)0x10)
1888 #define CR2_VPPVDD ((uchar)0x20)
1889 #define CR2_VDD5 ((uchar)0x40)
1890 #define CR2_VDD3 ((uchar)0x80)
1892 #define PCMCIA_BOARD_MSG "MBX860"
1894 static int voltage_set (int slot, int vcc, int vpp)
1898 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1899 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1932 /* first, turn off all power */
1933 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1935 /* enable new powersettings */
1937 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1942 static int hardware_enable (int slot)
1944 volatile immap_t *immap;
1945 volatile cpm8xx_t *cp;
1946 volatile pcmconf8xx_t *pcmp;
1947 volatile sysconf8xx_t *sysp;
1950 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1955 immap = (immap_t *) CFG_IMMR;
1956 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1957 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1958 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1960 /* clear interrupt state, and disable interrupts */
1961 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1962 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1965 * Disable interrupts, DMA, and PCMCIA buffers
1966 * (isolate the interface) and assert RESET signal
1968 debug ("Disable PCMCIA buffers and assert RESET\n");
1970 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1971 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1972 PCMCIA_PGCRX (_slot_) = reg;
1975 /* remove all power */
1976 voltage_set (slot, 0, 0);
1978 * Make sure there is a card in the slot, then configure the interface.
1981 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1982 __LINE__,__FUNCTION__,
1983 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1984 #ifndef CONFIG_HMI10
1985 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1987 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
1988 #endif /* CONFIG_HMI10 */
1989 printf (" No Card found\n");
1996 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1997 reg = pcmp->pcmc_pipr;
1998 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1999 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
2000 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
2002 if ((reg & mask) == mask) {
2003 voltage_set (_slot_, 50, 0);
2004 printf (" 5.0V card found: ");
2006 voltage_set (_slot_, 33, 0);
2007 printf (" 3.3V card found: ");
2010 debug ("Enable PCMCIA buffers and stop RESET\n");
2011 reg = PCMCIA_PGCRX (_slot_);
2012 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2013 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2014 PCMCIA_PGCRX (_slot_) = reg;
2016 udelay (250000); /* some cards need >150 ms to come up :-( */
2018 debug ("# hardware_enable done\n");
2023 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2024 static int hardware_disable (int slot)
2026 return 0; /* No hardware to disable */
2028 #endif /* CFG_CMD_PCMCIA */
2029 #endif /* CONFIG_MBX */
2030 /* -------------------------------------------------------------------- */
2032 /* -------------------------------------------------------------------- */
2034 #if defined(CONFIG_R360MPI)
2036 #define PCMCIA_BOARD_MSG "R360MPI"
2039 static int hardware_enable(int slot)
2041 volatile immap_t *immap;
2042 volatile cpm8xx_t *cp;
2043 volatile pcmconf8xx_t *pcmp;
2044 volatile sysconf8xx_t *sysp;
2047 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2051 immap = (immap_t *)CFG_IMMR;
2052 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2053 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2054 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2057 * Configure SIUMCR to enable PCMCIA port B
2058 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2060 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2062 /* clear interrupt state, and disable interrupts */
2063 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
2064 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
2067 * Disable interrupts, DMA, and PCMCIA buffers
2068 * (isolate the interface) and assert RESET signal
2070 debug ("Disable PCMCIA buffers and assert RESET\n");
2072 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2073 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2074 PCMCIA_PGCRX(_slot_) = reg;
2078 * Configure Ports A, B & C pins for
2079 * 5 Volts Enable and 3 Volts enable
2081 immap->im_ioport.iop_pcpar &= ~(0x0400);
2082 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2083 immap->im_ioport.iop_pcdir |= 0x0400;*/
2085 immap->im_ioport.iop_papar &= ~(0x0200);/*
2086 immap->im_ioport.iop_padir |= 0x0200;*/
2088 immap->im_ioport.iop_pbpar &= ~(0xC000);
2089 immap->im_ioport.iop_pbdir &= ~(0xC000);
2091 /* remove all power */
2093 immap->im_ioport.iop_pcdat |= 0x0400;
2094 immap->im_ioport.iop_padat |= 0x0200;
2097 * Make sure there is a card in the slot, then configure the interface.
2100 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2101 __LINE__,__FUNCTION__,
2102 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2103 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2104 printf (" No Card found\n");
2111 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2112 reg = pcmp->pcmc_pipr;
2113 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2115 (reg&PCMCIA_VS1(slot))?"n":"ff",
2116 (reg&PCMCIA_VS2(slot))?"n":"ff");
2117 if ((reg & mask) == mask) {
2118 immap->im_ioport.iop_pcdat &= ~(0x4000);
2119 puts (" 5.0V card found: ");
2121 immap->im_ioport.iop_padat &= ~(0x0002);
2122 puts (" 3.3V card found: ");
2124 immap->im_ioport.iop_pcdir |= 0x0400;
2125 immap->im_ioport.iop_padir |= 0x0200;
2127 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2128 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2129 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2132 debug ("Enable PCMCIA buffers and stop RESET\n");
2133 reg = PCMCIA_PGCRX(_slot_);
2134 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2135 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2136 PCMCIA_PGCRX(_slot_) = reg;
2138 udelay(250000); /* some cards need >150 ms to come up :-( */
2140 debug ("# hardware_enable done\n");
2146 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2147 static int hardware_disable(int slot)
2149 volatile immap_t *immap;
2150 volatile pcmconf8xx_t *pcmp;
2153 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2155 immap = (immap_t *)CFG_IMMR;
2156 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2158 /* remove all power */
2159 immap->im_ioport.iop_pcdat |= 0x0400;
2160 immap->im_ioport.iop_padat |= 0x0200;
2162 /* Configure PCMCIA General Control Register */
2163 debug ("Disable PCMCIA buffers and assert RESET\n");
2165 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2166 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2167 PCMCIA_PGCRX(_slot_) = reg;
2173 #endif /* CFG_CMD_PCMCIA */
2176 static int voltage_set(int slot, int vcc, int vpp)
2178 volatile immap_t *immap;
2179 volatile pcmconf8xx_t *pcmp;
2182 debug ("voltage_set: "
2184 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2185 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2187 immap = (immap_t *)CFG_IMMR;
2188 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2190 * Disable PCMCIA buffers (isolate the interface)
2191 * and assert RESET signal
2193 debug ("Disable PCMCIA buffers and assert RESET\n");
2194 reg = PCMCIA_PGCRX(_slot_);
2195 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2196 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2197 PCMCIA_PGCRX(_slot_) = reg;
2201 * Configure Ports A & C pins for
2202 * 5 Volts Enable and 3 Volts enable,
2203 * Turn off all power
2205 debug ("PCMCIA power OFF\n");
2206 immap->im_ioport.iop_pcpar &= ~(0x0400);
2207 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2208 immap->im_ioport.iop_pcdir |= 0x0400;*/
2210 immap->im_ioport.iop_papar &= ~(0x0200);/*
2211 immap->im_ioport.iop_padir |= 0x0200;*/
2213 immap->im_ioport.iop_pcdat |= 0x0400;
2214 immap->im_ioport.iop_padat |= 0x0200;
2219 case 33: reg |= 0x0200; break;
2220 case 50: reg |= 0x0400; break;
2224 /* Checking supported voltages */
2226 debug ("PIPR: 0x%x --> %s\n",
2228 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
2231 immap->im_ioport.iop_pcdat &= !reg;
2233 immap->im_ioport.iop_padat &= !reg;
2234 immap->im_ioport.iop_pcdir |= 0x0200;
2235 immap->im_ioport.iop_padir |= 0x0400;
2237 debug ("PCMCIA powered at %sV\n",
2238 (reg&0x0400) ? "5.0" : "3.3");
2240 debug ("PCMCIA powered down\n");
2244 debug ("Enable PCMCIA buffers and stop RESET\n");
2245 reg = PCMCIA_PGCRX(_slot_);
2246 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2247 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2248 PCMCIA_PGCRX(_slot_) = reg;
2251 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2256 #endif /* R360MPI */
2258 /* -------------------------------------------------------------------- */
2259 /* KUP4K and KUP4X Boards */
2260 /* -------------------------------------------------------------------- */
2261 #if defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
2263 #define PCMCIA_BOARD_MSG "KUP"
2265 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
2267 static int hardware_enable(int slot)
2269 volatile immap_t *immap;
2270 volatile cpm8xx_t *cp;
2271 volatile pcmconf8xx_t *pcmp;
2272 volatile sysconf8xx_t *sysp;
2275 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2279 immap = (immap_t *)CFG_IMMR;
2280 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2281 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2282 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2285 * Configure SIUMCR to enable PCMCIA port B
2286 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2288 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2290 /* clear interrupt state, and disable interrupts */
2291 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2292 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2295 * Disable interrupts, DMA, and PCMCIA buffers
2296 * (isolate the interface) and assert RESET signal
2298 debug ("Disable PCMCIA buffers and assert RESET\n");
2300 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2301 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2302 PCMCIA_PGCRX(slot) = reg;
2306 * Configure Port B pins for
2309 if (slot) { /* Slot A is built-in */
2310 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2311 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2312 /* remove all power */
2313 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2316 * Make sure there is a card in the slot, then configure the interface.
2319 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2320 __LINE__,__FUNCTION__,
2321 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2322 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2323 printf (" No Card found\n");
2330 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2331 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2332 reg = pcmp->pcmc_pipr;
2333 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2335 (reg&PCMCIA_VS1(slot))?"n":"ff",
2336 (reg&PCMCIA_VS2(slot))?"n":"ff");
2337 if ((reg & mask) == mask) {
2338 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2341 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2342 puts (" 3.3V card found: ");
2345 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2346 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2347 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2350 debug ("Enable PCMCIA buffers and stop RESET\n");
2351 reg = PCMCIA_PGCRX(slot);
2352 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2353 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2354 PCMCIA_PGCRX(slot) = reg;
2356 udelay(250000); /* some cards need >150 ms to come up :-( */
2358 debug ("# hardware_enable done\n");
2364 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2365 static int hardware_disable(int slot)
2367 volatile immap_t *immap;
2368 volatile cpm8xx_t *cp;
2369 volatile pcmconf8xx_t *pcmp;
2372 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2374 immap = (immap_t *)CFG_IMMR;
2375 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2376 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2378 /* remove all power */
2380 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2382 /* Configure PCMCIA General Control Register */
2383 debug ("Disable PCMCIA buffers and assert RESET\n");
2385 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2386 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2387 PCMCIA_PGCRX(slot) = reg;
2393 #endif /* CFG_CMD_PCMCIA */
2396 static int voltage_set(int slot, int vcc, int vpp)
2398 volatile immap_t *immap;
2399 volatile cpm8xx_t *cp;
2400 volatile pcmconf8xx_t *pcmp;
2403 debug ("voltage_set: " \
2405 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2406 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2408 if (!slot) /* Slot A is not configurable */
2411 immap = (immap_t *)CFG_IMMR;
2412 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2413 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2416 * Disable PCMCIA buffers (isolate the interface)
2417 * and assert RESET signal
2419 debug ("Disable PCMCIA buffers and assert RESET\n");
2420 reg = PCMCIA_PGCRX(slot);
2421 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2422 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2423 PCMCIA_PGCRX(slot) = reg;
2426 debug ("PCMCIA power OFF\n");
2428 * Configure Port B pins for
2431 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2432 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2433 /* remove all power */
2434 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2439 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2440 debug ("PCMCIA powered at 3.3V\n");
2443 debug ("PCMCIA: 5Volt vcc not supported\n");
2446 puts("PCMCIA: vcc not supported");
2450 /* Checking supported voltages */
2452 debug ("PIPR: 0x%x --> %s\n",
2454 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2455 ? "only 5 V --> NOT SUPPORTED"
2459 debug ("Enable PCMCIA buffers and stop RESET\n");
2460 reg = PCMCIA_PGCRX(slot);
2461 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2462 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2463 PCMCIA_PGCRX(slot) = reg;
2466 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2471 #endif /* KUP4K || KUP4X */
2474 /* -------------------------------------------------------------------- */
2475 /* End of Board Specific Stuff */
2476 /* -------------------------------------------------------------------- */
2479 /* -------------------------------------------------------------------- */
2480 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2481 /* -------------------------------------------------------------------- */
2484 * Search this table to see if the windowsize is
2488 #define M8XX_SIZES_NO 32
2490 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2491 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2492 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2493 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2494 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2496 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2497 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2498 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2499 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2502 /* -------------------------------------------------------------------- */
2504 #if ( ! defined(CONFIG_I82365) && ! defined(CONFIG_PXA_PCMCIA) )
2506 static u_int m8xx_get_graycode(u_int size)
2510 for (k = 0; k < M8XX_SIZES_NO; k++) {
2511 if(m8xx_size_to_gray[k] == size)
2515 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2521 #endif /* CONFIG_I82365 */
2523 /* -------------------------------------------------------------------- */
2526 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2528 u_int reg, clocks, psst, psl, psht;
2533 * We get called with IO maps setup to 0ns
2534 * if not specified by the user.
2535 * They should be 255ns.
2541 ns = 100; /* fast memory if 0 */
2545 * In PSST, PSL, PSHT fields we tell the controller
2546 * timing parameters in CLKOUT clock cycles.
2547 * CLKOUT is the same as GCLK2_50.
2550 /* how we want to adjust the timing - in percent */
2552 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2554 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2555 clocks = (clocks * ADJ) / (100*1000);
2557 if(clocks >= PCMCIA_BMT_LIMIT) {
2558 DEBUG(0, "Max access time limit reached\n");
2559 clocks = PCMCIA_BMT_LIMIT-1;
2562 psst = clocks / 7; /* setup time */
2563 psht = clocks / 7; /* hold time */
2564 psl = (clocks * 5) / 7; /* strobe length */
2566 psst += clocks - (psst + psht + psl);
2576 /* -------------------------------------------------------------------- */
2578 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2579 static void print_funcid (int func)
2583 case CISTPL_FUNCID_MULTI:
2584 puts (" Multi-Function");
2586 case CISTPL_FUNCID_MEMORY:
2589 case CISTPL_FUNCID_SERIAL:
2590 puts (" Serial Port");
2592 case CISTPL_FUNCID_PARALLEL:
2593 puts (" Parallel Port");
2595 case CISTPL_FUNCID_FIXED:
2596 puts (" Fixed Disk");
2598 case CISTPL_FUNCID_VIDEO:
2599 puts (" Video Adapter");
2601 case CISTPL_FUNCID_NETWORK:
2602 puts (" Network Adapter");
2604 case CISTPL_FUNCID_AIMS:
2605 puts (" AIMS Card");
2607 case CISTPL_FUNCID_SCSI:
2608 puts (" SCSI Adapter");
2616 #endif /* CONFIG_IDE_8xx_PCCARD */
2618 /* -------------------------------------------------------------------- */
2620 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2621 static void print_fixed (volatile uchar *p)
2629 case CISTPL_FUNCE_IDE_IFACE:
2630 { uchar iface = *(p+2);
2632 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2633 puts (" interface ");
2636 case CISTPL_FUNCE_IDE_MASTER:
2637 case CISTPL_FUNCE_IDE_SLAVE:
2638 { uchar f1 = *(p+2);
2641 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2643 if (f1 & CISTPL_IDE_UNIQUE)
2646 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2648 if (f2 & CISTPL_IDE_HAS_SLEEP)
2651 if (f2 & CISTPL_IDE_HAS_STANDBY)
2652 puts (" [standby]");
2654 if (f2 & CISTPL_IDE_HAS_IDLE)
2657 if (f2 & CISTPL_IDE_LOW_POWER)
2658 puts (" [low power]");
2660 if (f2 & CISTPL_IDE_REG_INHIBIT)
2661 puts (" [reg inhibit]");
2663 if (f2 & CISTPL_IDE_HAS_INDEX)
2666 if (f2 & CISTPL_IDE_IOIS16)
2674 #endif /* CONFIG_IDE_8xx_PCCARD */
2676 /* -------------------------------------------------------------------- */
2678 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
2680 #define MAX_IDENT_CHARS 64
2681 #define MAX_IDENT_FIELDS 4
2683 static uchar *known_cards[] = {
2684 (uchar *)"ARGOSY PnPIDE D5",
2688 static int identify (volatile uchar *p)
2690 uchar id_str[MAX_IDENT_CHARS];
2697 return (0); /* Don't know */
2702 for (i=0; i<=4 && !done; ++i, p+=2) {
2703 while ((data = *p) != '\0') {
2709 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2719 while (--t > id_str) {
2725 puts ((char *)id_str);
2728 for (card=known_cards; *card; ++card) {
2729 debug ("## Compare against \"%s\"\n", *card);
2730 if (strcmp((char *)*card, (char *)id_str) == 0) { /* found! */
2731 debug ("## CARD FOUND ##\n");
2736 return (0); /* don't know */
2738 #endif /* CONFIG_IDE_8xx_PCCARD */
2740 /* -------------------------------------------------------------------- */
2741 /* NETTA board by Intracom S.A. */
2742 /* -------------------------------------------------------------------- */
2744 #if defined(CONFIG_NETTA)
2746 /* some sane bit macros */
2747 #define _BD(_b) (1U << (31-(_b)))
2748 #define _BDR(_l, _h) (((((1U << (31-(_l))) - 1) << 1) | 1) & ~((1U << (31-(_h))) - 1))
2750 #define _BW(_b) (1U << (15-(_b)))
2751 #define _BWR(_l, _h) (((((1U << (15-(_l))) - 1) << 1) | 1) & ~((1U << (15-(_h))) - 1))
2753 #define _BB(_b) (1U << (7-(_b)))
2754 #define _BBR(_l, _h) (((((1U << (7-(_l))) - 1) << 1) | 1) & ~((1U << (7-(_h))) - 1))
2756 #define _B(_b) _BD(_b)
2757 #define _BR(_l, _h) _BDR(_l, _h)
2759 #define PCMCIA_BOARD_MSG "NETTA"
2761 static const unsigned short vppd_masks[2] = { _BW(14), _BW(15) };
2763 static void cfg_vppd(int no)
2765 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2766 unsigned short mask;
2768 if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
2771 mask = vppd_masks[no];
2773 immap->im_ioport.iop_papar &= ~mask;
2774 immap->im_ioport.iop_paodr &= ~mask;
2775 immap->im_ioport.iop_padir |= mask;
2778 static void set_vppd(int no, int what)
2780 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2781 unsigned short mask;
2783 if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
2786 mask = vppd_masks[no];
2789 immap->im_ioport.iop_padat |= mask;
2791 immap->im_ioport.iop_padat &= ~mask;
2794 static const unsigned short vccd_masks[2] = { _BW(10), _BW(6) };
2796 static void cfg_vccd(int no)
2798 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2799 unsigned short mask;
2801 if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
2804 mask = vccd_masks[no];
2806 immap->im_ioport.iop_papar &= ~mask;
2807 immap->im_ioport.iop_paodr &= ~mask;
2808 immap->im_ioport.iop_padir |= mask;
2811 static void set_vccd(int no, int what)
2813 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2814 unsigned short mask;
2816 if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
2819 mask = vccd_masks[no];
2822 immap->im_ioport.iop_padat |= mask;
2824 immap->im_ioport.iop_padat &= ~mask;
2827 static const unsigned short oc_mask = _BW(8);
2829 static void cfg_oc(void)
2831 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2832 unsigned short mask = oc_mask;
2834 immap->im_ioport.iop_pcdir &= ~mask;
2835 immap->im_ioport.iop_pcso &= ~mask;
2836 immap->im_ioport.iop_pcint &= ~mask;
2837 immap->im_ioport.iop_pcpar &= ~mask;
2840 static int get_oc(void)
2842 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2843 unsigned short mask = oc_mask;
2846 what = !!(immap->im_ioport.iop_pcdat & mask);;
2850 static const unsigned short shdn_mask = _BW(12);
2852 static void cfg_shdn(void)
2854 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2855 unsigned short mask;
2859 immap->im_ioport.iop_papar &= ~mask;
2860 immap->im_ioport.iop_paodr &= ~mask;
2861 immap->im_ioport.iop_padir |= mask;
2864 static void set_shdn(int what)
2866 volatile immap_t *immap = (immap_t *)CFG_IMMR;
2867 unsigned short mask;
2872 immap->im_ioport.iop_padat |= mask;
2874 immap->im_ioport.iop_padat &= ~mask;
2877 static void cfg_ports (void);
2879 static int hardware_enable(int slot)
2881 volatile immap_t *immap;
2882 volatile cpm8xx_t *cp;
2883 volatile pcmconf8xx_t *pcmp;
2884 volatile sysconf8xx_t *sysp;
2885 uint reg, pipr, mask;
2888 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2892 immap = (immap_t *)CFG_IMMR;
2893 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2894 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2895 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2897 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
2900 /* clear interrupt state, and disable interrupts */
2901 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
2902 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
2905 * Disable interrupts, DMA, and PCMCIA buffers
2906 * (isolate the interface) and assert RESET signal
2908 debug ("Disable PCMCIA buffers and assert RESET\n");
2910 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2911 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2912 PCMCIA_PGCRX(_slot_) = reg;
2917 * Make sure there is a card in the slot, then configure the interface.
2920 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2921 __LINE__,__FUNCTION__,
2922 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2923 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2924 printf (" No Card found\n");
2929 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
2931 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2932 pipr = pcmp->pcmc_pipr;
2933 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2935 (reg&PCMCIA_VS1(slot))?"n":"ff",
2936 (reg&PCMCIA_VS2(slot))?"n":"ff");
2938 if ((pipr & mask) == mask) {
2939 set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
2940 set_vccd(0, 0); set_vccd(1, 1); /* 5V on, 3V off */
2941 puts (" 5.0V card found: ");
2943 set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
2944 set_vccd(0, 1); set_vccd(1, 0); /* 5V off, 3V on */
2945 puts (" 3.3V card found: ");
2948 /* Wait 500 ms; use this to check for over-current */
2949 for (i=0; i<5000; ++i) {
2951 printf (" *** Overcurrent - Safety shutdown ***\n");
2952 set_vccd(0, 0); set_vccd(1, 0); /* VAVPP => Hi-Z */
2958 debug ("Enable PCMCIA buffers and stop RESET\n");
2959 reg = PCMCIA_PGCRX(_slot_);
2960 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2961 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2962 PCMCIA_PGCRX(_slot_) = reg;
2964 udelay(250000); /* some cards need >150 ms to come up :-( */
2966 debug ("# hardware_enable done\n");
2972 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2973 static int hardware_disable(int slot)
2975 volatile immap_t *immap;
2976 volatile pcmconf8xx_t *pcmp;
2979 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2981 immap = (immap_t *)CFG_IMMR;
2982 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2984 /* Configure PCMCIA General Control Register */
2985 debug ("Disable PCMCIA buffers and assert RESET\n");
2987 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2988 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2989 PCMCIA_PGCRX(_slot_) = reg;
2991 /* All voltages off / Hi-Z */
2992 set_vppd(0, 1); set_vppd(1, 1);
2993 set_vccd(0, 1); set_vccd(1, 1);
2999 #endif /* CFG_CMD_PCMCIA */
3002 static int voltage_set(int slot, int vcc, int vpp)
3004 volatile immap_t *immap;
3005 volatile cpm8xx_t *cp;
3006 volatile pcmconf8xx_t *pcmp;
3010 debug ("voltage_set: "
3012 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
3013 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
3015 immap = (immap_t *)CFG_IMMR;
3016 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3017 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3019 * Disable PCMCIA buffers (isolate the interface)
3020 * and assert RESET signal
3022 debug ("Disable PCMCIA buffers and assert RESET\n");
3023 reg = PCMCIA_PGCRX(_slot_);
3024 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3025 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
3026 PCMCIA_PGCRX(_slot_) = reg;
3030 * Configure Port C pins for
3031 * 5 Volts Enable and 3 Volts enable,
3032 * Turn all power pins to Hi-Z
3034 debug ("PCMCIA power OFF\n");
3035 cfg_ports (); /* Enables switch, but all in Hi-Z */
3037 sreg = immap->im_ioport.iop_pcdat;
3038 set_vppd(0, 1); set_vppd(1, 1);
3042 break; /* Switch off */
3045 set_vccd(0, 1); set_vccd(1, 0);
3049 set_vccd(0, 0); set_vccd(1, 1);
3056 /* Checking supported voltages */
3058 debug ("PIPR: 0x%x --> %s\n",
3060 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
3063 debug ("Enable PCMCIA buffers and stop RESET\n");
3064 reg = PCMCIA_PGCRX(_slot_);
3065 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3066 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3067 PCMCIA_PGCRX(_slot_) = reg;
3070 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
3075 static void cfg_ports (void)
3077 volatile immap_t *immap;
3078 volatile cpm8xx_t *cp;
3080 immap = (immap_t *)CFG_IMMR;
3081 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3084 cfg_vppd(0); cfg_vppd(1); /* VPPD0,VPPD1 VAVPP => Hi-Z */
3085 cfg_vccd(0); cfg_vccd(1); /* 3V and 5V off */
3090 * Configure Port A for TPS2211 PC-Card Power-Interface Switch
3092 * Switch off all voltages, assert shutdown
3094 set_vppd(0, 1); set_vppd(1, 1);
3095 set_vccd(0, 0); set_vccd(1, 0);
3104 /* -------------------------------------------------------------------- */
3106 /* -------------------------------------------------------------------- */
3108 #if defined(CONFIG_UC100)
3110 #define PCMCIA_BOARD_MSG "UC100"
3113 * Remark: don't turn off OE "__MY_PCMCIA_GCRX_CXOE" on UC100 board.
3114 * This leads to board-hangup! (sr, 8 Dez. 2004)
3117 static void cfg_ports (void);
3119 static int hardware_enable(int slot)
3121 volatile immap_t *immap;
3122 volatile cpm8xx_t *cp;
3123 volatile pcmconf8xx_t *pcmp;
3124 volatile sysconf8xx_t *sysp;
3127 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3131 immap = (immap_t *)CFG_IMMR;
3132 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
3133 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3134 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
3136 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
3140 * Configure SIUMCR to enable PCMCIA port B
3141 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
3143 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
3145 /* clear interrupt state, and disable interrupts */
3146 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
3147 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
3150 * Disable interrupts, DMA, and PCMCIA buffers
3151 * (isolate the interface) and assert RESET signal
3153 debug ("Disable PCMCIA buffers and assert RESET\n");
3155 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3156 PCMCIA_PGCRX(_slot_) = reg;
3160 * Make sure there is a card in the slot, then configure the interface.
3163 debug ("[%d] %s: PIPR(%p)=0x%x\n",
3164 __LINE__,__FUNCTION__,
3165 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
3166 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
3167 printf (" No Card found\n");
3174 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
3175 reg = pcmp->pcmc_pipr;
3176 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
3178 (reg&PCMCIA_VS1(slot))?"n":"ff",
3179 (reg&PCMCIA_VS2(slot))?"n":"ff");
3180 if ((reg & mask) == mask) {
3181 puts (" 5.0V card found: ");
3183 puts (" 3.3V card found: ");
3187 immap->im_ioport.iop_padat |= 0x8000; /* power enable 3.3V */
3191 debug ("Enable PCMCIA buffers and stop 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;
3197 udelay(250000); /* some cards need >150 ms to come up :-( */
3199 debug ("# hardware_enable done\n");
3205 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3206 static int hardware_disable(int slot)
3208 volatile immap_t *immap;
3209 volatile cpm8xx_t *cp;
3210 volatile pcmconf8xx_t *pcmp;
3213 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
3215 immap = (immap_t *)CFG_IMMR;
3216 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3218 /* switch VCC off */
3219 immap->im_ioport.iop_padat &= ~0x8000; /* power disable 3.3V */
3221 /* Configure PCMCIA General Control Register */
3222 debug ("Disable PCMCIA buffers and assert RESET\n");
3224 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3225 PCMCIA_PGCRX(_slot_) = reg;
3231 #endif /* CFG_CMD_PCMCIA */
3234 static int voltage_set(int slot, int vcc, int vpp)
3236 volatile immap_t *immap;
3237 volatile pcmconf8xx_t *pcmp;
3240 debug ("voltage_set: "
3242 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
3243 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
3245 immap = (immap_t *)CFG_IMMR;
3246 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
3248 * Disable PCMCIA buffers (isolate the interface)
3249 * and assert RESET signal
3251 debug ("Disable PCMCIA buffers and assert RESET\n");
3252 reg = PCMCIA_PGCRX(_slot_);
3253 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
3254 PCMCIA_PGCRX(_slot_) = reg;
3258 * Configure Port C pins for
3259 * 5 Volts Enable and 3 Volts enable,
3260 * Turn all power pins to Hi-Z
3262 debug ("PCMCIA power OFF\n");
3263 cfg_ports (); /* Enables switch, but all in Hi-Z */
3265 debug ("Enable PCMCIA buffers and stop RESET\n");
3266 reg = PCMCIA_PGCRX(_slot_);
3267 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
3268 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
3269 PCMCIA_PGCRX(_slot_) = reg;
3272 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
3277 static void cfg_ports (void)
3279 volatile immap_t *immap;
3281 immap = (immap_t *)CFG_IMMR;
3284 * Configure Port A for MAX1602 PC-Card Power-Interface Switch
3286 immap->im_ioport.iop_padat &= ~0x8000; /* set port x output to low */
3287 immap->im_ioport.iop_padir |= 0x8000; /* enable port x as output */
3289 debug ("Set Port A: PAR: %08x DIR: %08x DAT: %08x\n",
3290 immap->im_ioport.iop_papar, immap->im_ioport.iop_padir,
3291 immap->im_ioport.iop_padat);
3297 /* -------------------------------------------------------------------- */
3299 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
3301 /**************************************************/
3303 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
3305 pinit, 2, 1, do_pinit,
3306 "pinit - PCMCIA sub-system\n",
3307 "on - power on PCMCIA socket\n"
3308 "pinit off - power off PCMCIA socket\n"