2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 ********************************************************************
25 * Lots of code copied from:
27 * m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series.
28 * (C) 1999-2000 Magnus Damm <damm@bitsmart.com>
30 * "The ExCA standard specifies that socket controllers should provide
31 * two IO and five memory windows per socket, which can be independently
32 * configured and positioned in the host address space and mapped to
33 * arbitrary segments of card address space. " - David A Hinds. 1999
35 * This controller does _not_ meet the ExCA standard.
37 * m8xx pcmcia controller brief info:
38 * + 8 windows (attrib, mem, i/o)
39 * + up to two slots (SLOT_A and SLOT_B)
40 * + inputpins, outputpins, event and mask registers.
41 * - no offset register. sigh.
43 * Because of the lacking offset register we must map the whole card.
44 * We assign each memory window PCMCIA_MEM_WIN_SIZE address space.
45 * Make sure there is (PCMCIA_MEM_WIN_SIZE * PCMCIA_MEM_WIN_NO
46 * * PCMCIA_SOCKETS_NO) bytes at PCMCIA_MEM_WIN_BASE.
47 * The i/o windows are dynamically allocated at PCMCIA_IO_WIN_BASE.
48 * They are maximum 64KByte each...
60 #if defined(CONFIG_8xx)
63 #if defined(CONFIG_LWMON)
67 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
68 ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD))
72 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
73 static int pcmcia_off (void);
78 extern int i82365_init (void);
79 extern void i82365_exit (void);
81 #else /* ! CONFIG_I82365 */
83 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
84 static int hardware_disable(int slot);
86 static int hardware_enable (int slot);
87 static int voltage_set(int slot, int vcc, int vpp);
90 static u_int m8xx_get_graycode(u_int size);
91 #endif /* CONFIG_I82365 */
93 static u_int m8xx_get_speed(u_int ns, u_int is_io);
96 /* -------------------------------------------------------------------- */
98 /* look up table for pgcrx registers */
100 static u_int *pcmcia_pgcrx[2] = {
101 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
102 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
105 #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
107 #endif /* CONFIG_I82365 */
109 #ifdef CONFIG_IDE_8xx_PCCARD
110 static void print_funcid (int func);
111 static void print_fixed (volatile uchar *p);
112 static int identify (volatile uchar *p);
113 static int check_ide_device (int slot);
114 #endif /* CONFIG_IDE_8xx_PCCARD */
116 const char *indent = "\t ";
118 /* -------------------------------------------------------------------- */
120 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
122 int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
127 printf ("Usage: pinit {on | off}\n");
130 if (strcmp(argv[1],"on") == 0) {
131 rcode = pcmcia_on ();
132 } else if (strcmp(argv[1],"off") == 0) {
133 rcode = pcmcia_off ();
135 printf ("Usage: pinit {on | off}\n");
141 #endif /* CFG_CMD_PCMCIA */
143 /* -------------------------------------------------------------------- */
150 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
156 rc = check_ide_device(0);
163 #if defined(CONFIG_LWMON) || defined(CONFIG_NSCU)
164 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
166 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
177 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
179 /* intialize the fixed memory windows */
180 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
181 base = CFG_PCMCIA_MEM_ADDR;
183 if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
184 printf ("Cannot set window size to 0x%08x\n",
185 CFG_PCMCIA_MEM_SIZE);
189 slotbit = PCMCIA_SLOT_x;
190 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
193 #if (PCMCIA_SOCKETS_NO == 2)
194 if (i == 4) /* Another slot starting from win 4 */
195 slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
198 #ifdef CONFIG_IDE_8xx_PCCARD
200 case 0: { /* map attribute memory */
201 win->or = ( PCMCIA_BSIZE_64M
206 | CFG_PCMCIA_TIMING );
210 case 1: { /* map I/O window for data reg */
211 win->or = ( PCMCIA_BSIZE_1K
216 | CFG_PCMCIA_TIMING );
220 case 2: { /* map I/O window for cmd/ctrl reg block */
221 win->or = ( PCMCIA_BSIZE_1K
226 | CFG_PCMCIA_TIMING );
229 #endif /* CONFIG_IDE_8xx_PCCARD */
230 #ifdef CONFIG_BMS2003
231 case 3: { /* map I/O window for 4xUART data/ctrl */
233 win->or = ( PCMCIA_BSIZE_256K
238 | CFG_PCMCIA_TIMING );
241 #endif /* CONFIG_BMS2003 */
242 default: /* set to not valid */
247 debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
248 i, win->br, win->or);
249 base += CFG_PCMCIA_MEM_SIZE;
253 for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
254 /* turn off voltage */
255 if ((rc = voltage_set(slot, 0, 0)))
258 /* Enable external hardware */
259 if ((rc = hardware_enable(slot)))
262 #ifdef CONFIG_IDE_8xx_PCCARD
263 if ((rc = check_ide_device(i)))
269 #endif /* CONFIG_I82365 */
271 /* -------------------------------------------------------------------- */
273 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
276 static int pcmcia_off (void)
278 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
285 static int pcmcia_off (void)
290 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
292 /* clear interrupt state, and disable interrupts */
293 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
294 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
296 /* turn off interrupt and disable CxOE */
297 PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
299 /* turn off memory windows */
300 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
302 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
303 /* disable memory window */
308 /* turn off voltage */
309 voltage_set(_slot_, 0, 0);
311 /* disable external hardware */
312 printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
313 hardware_disable(_slot_);
316 #endif /* CONFIG_I82365 */
318 #endif /* CFG_CMD_PCMCIA */
320 /* -------------------------------------------------------------------- */
322 #ifdef CONFIG_IDE_8xx_PCCARD
324 #define MAX_TUPEL_SZ 512
325 #define MAX_FEATURES 4
327 int ide_devices_found;
328 static int check_ide_device (int slot)
330 volatile uchar *ident = NULL;
331 volatile uchar *feature_p[MAX_FEATURES];
332 volatile uchar *p, *start, *addr;
336 ushort config_base = 0;
340 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
341 CFG_PCMCIA_MEM_SIZE * (slot * 4));
342 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
344 start = p = (volatile uchar *) addr;
346 while ((p - start) < MAX_TUPEL_SZ) {
350 if (code == 0xFF) { /* End of chain */
355 #if defined(DEBUG) && (DEBUG > 1)
356 { volatile uchar *q = p;
357 printf ("\nTuple code %02x length %d\n\tData:",
360 for (i = 0; i < len; ++i) {
361 printf (" %02x", *q);
371 /* Fix for broken SanDisk which may have 0x80 bit set */
375 if (n_features < MAX_FEATURES)
376 feature_p[n_features++] = p;
379 config_base = (*(p+6) << 8) + (*(p+4));
380 debug ("\n## Config_base = %04x ###\n", config_base);
387 found = identify (ident);
389 if (func_id != ((uchar)~0)) {
390 print_funcid (func_id);
392 if (func_id == CISTPL_FUNCID_FIXED)
395 return (1); /* no disk drive */
398 for (i=0; i<n_features; ++i) {
399 print_fixed (feature_p[i]);
403 printf ("unknown card type\n");
407 ide_devices_found |= (1 << slot);
409 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
410 *((uchar *)(addr + config_base)) = 1;
414 #endif /* CONFIG_IDE_8xx_PCCARD */
416 /* -------------------------------------------------------------------- */
419 /* -------------------------------------------------------------------- */
420 /* board specific stuff: */
421 /* voltage_set(), hardware_enable() and hardware_disable() */
422 /* -------------------------------------------------------------------- */
424 /* -------------------------------------------------------------------- */
425 /* RPX Boards from Embedded Planet */
426 /* -------------------------------------------------------------------- */
428 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
430 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
431 * SYPCR is write once only, therefore must the slowest memory be faster
432 * than the bus monitor or we will get a machine check due to the bus timeout.
435 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
437 #undef PCMCIA_BMT_LIMIT
438 #define PCMCIA_BMT_LIMIT (6*8)
440 static int voltage_set(int slot, int vcc, int vpp)
446 case 33: reg |= BCSR1_PCVCTL4; break;
447 case 50: reg |= BCSR1_PCVCTL5; break;
456 reg |= BCSR1_PCVCTL6;
461 reg |= BCSR1_PCVCTL7;
468 /* first, turn off all power */
470 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
471 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
473 /* enable new powersettings */
475 *((uint *)RPX_CSR_ADDR) |= reg;
480 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
481 static int hardware_enable (int slot)
483 return 0; /* No hardware to enable */
485 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
486 static int hardware_disable(int slot)
488 return 0; /* No hardware to disable */
490 #endif /* CFG_CMD_PCMCIA */
491 #endif /* CONFIG_RPXCLASSIC */
493 /* -------------------------------------------------------------------- */
494 /* (F)ADS Boards from Motorola */
495 /* -------------------------------------------------------------------- */
497 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
500 #define PCMCIA_BOARD_MSG "ADS"
501 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
503 #define PCMCIA_BOARD_MSG "FADS"
506 static int voltage_set(int slot, int vcc, int vpp)
511 case 0: reg = 0; break;
512 case 50: reg = 1; break;
513 case 120: reg = 2; break;
518 case 0: reg = 0; break;
520 case 50: reg = BCSR1_PCCVCCON; break;
523 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
524 case 50: reg = BCSR1_PCCVCC1; break;
529 /* first, turn off all power */
532 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
535 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
537 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
539 /* enable new powersettings */
542 *((uint *)BCSR1) &= ~reg;
545 *((uint *)BCSR1) |= reg;
548 *((uint *)BCSR1) |= reg << 20;
553 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
555 static int hardware_enable(int slot)
557 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
561 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
562 static int hardware_disable(int slot)
564 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
567 #endif /* CFG_CMD_PCMCIA */
571 /* -------------------------------------------------------------------- */
572 /* TQM8xxL Boards by TQ Components */
573 /* SC8xx Boards by SinoVee Microsystems */
574 /* -------------------------------------------------------------------- */
576 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)
578 #if defined(CONFIG_TQM8xxL)
579 #define PCMCIA_BOARD_MSG "TQM8xxL"
581 #if defined(CONFIG_SVM_SC8xx)
582 #define PCMCIA_BOARD_MSG "SC8xx"
585 static int hardware_enable(int slot)
587 volatile immap_t *immap;
588 volatile cpm8xx_t *cp;
589 volatile pcmconf8xx_t *pcmp;
590 volatile sysconf8xx_t *sysp;
593 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
597 immap = (immap_t *)CFG_IMMR;
598 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
599 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
600 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
603 * Configure SIUMCR to enable PCMCIA port B
604 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
606 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
608 /* clear interrupt state, and disable interrupts */
609 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
610 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
613 * Disable interrupts, DMA, and PCMCIA buffers
614 * (isolate the interface) and assert RESET signal
616 debug ("Disable PCMCIA buffers and assert RESET\n");
618 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
620 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
622 PCMCIA_PGCRX(slot) = reg;
625 #ifndef CONFIG_BMS2003
628 * Configure Port C pins for
629 * 5 Volts Enable and 3 Volts enable
631 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
632 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
633 /* remove all power */
635 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
637 #else /* CONFIG_BMS2003 */
639 * Configure Port B pins for
640 * 5 Volts Enable and 3 Volts enable
642 immap->im_cpm.cp_pbpar &= ~(0x00000300);
644 /* remove all power */
645 immap->im_cpm.cp_pbdat |= 0x00000300;
646 #endif /* CONFIG_BMS2003 */
649 * Make sure there is a card in the slot, then configure the interface.
652 debug ("[%d] %s: PIPR(%p)=0x%x\n",
653 __LINE__,__FUNCTION__,
654 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
655 #ifndef CONFIG_BMS2003
656 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
658 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
659 #endif /* CONFIG_BMS2003 */
660 printf (" No Card found\n");
667 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
668 reg = pcmp->pcmc_pipr;
669 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
671 (reg&PCMCIA_VS1(slot))?"n":"ff",
672 (reg&PCMCIA_VS2(slot))?"n":"ff");
674 if ((reg & mask) == mask) {
675 #ifndef CONFIG_BMS2003
676 immap->im_ioport.iop_pcdat |= 0x0004;
678 immap->im_cpm.cp_pbdat &= ~(0x0000100);
679 #endif /* CONFIG_BMS2003 */
680 puts (" 5.0V card found: ");
682 #ifndef CONFIG_BMS2003
683 immap->im_ioport.iop_pcdat |= 0x0002;
685 immap->im_cpm.cp_pbdat &= ~(0x0000200);
686 #endif /* CONFIG_BMS2003 */
687 puts (" 3.3V card found: ");
689 #ifndef CONFIG_BMS2003
690 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
692 immap->im_cpm.cp_pbdir |= 0x00000300;
693 #endif /* CONFIG_BMS2003 */
695 if ((reg & mask) == mask) {
696 puts (" 5.0V card found: ");
698 puts (" 3.3V card found: ");
702 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
703 cp->cp_pbdir &= ~(0x0020 | 0x0010);
704 cp->cp_pbpar &= ~(0x0020 | 0x0010);
708 debug ("Enable PCMCIA buffers and stop RESET\n");
709 reg = PCMCIA_PGCRX(slot);
710 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
712 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
714 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
716 PCMCIA_PGCRX(slot) = reg;
718 udelay(250000); /* some cards need >150 ms to come up :-( */
720 debug ("# hardware_enable done\n");
726 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
727 static int hardware_disable(int slot)
729 volatile immap_t *immap;
730 volatile pcmconf8xx_t *pcmp;
733 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
735 immap = (immap_t *)CFG_IMMR;
736 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
738 #ifndef CONFIG_BMS2003
740 /* remove all power */
741 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
743 #else /* CONFIG_BMS2003 */
744 immap->im_cpm.cp_pbdat |= 0x00000300;
745 #endif /* CONFIG_BMS2003 */
747 debug ("Disable PCMCIA buffers and assert RESET\n");
749 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
751 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
753 PCMCIA_PGCRX(slot) = reg;
759 #endif /* CFG_CMD_PCMCIA */
762 static int voltage_set(int slot, int vcc, int vpp)
767 static int voltage_set(int slot, int vcc, int vpp)
769 volatile immap_t *immap;
770 volatile pcmconf8xx_t *pcmp;
773 debug ("voltage_set: "
775 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
776 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
778 immap = (immap_t *)CFG_IMMR;
779 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
781 * Disable PCMCIA buffers (isolate the interface)
782 * and assert RESET signal
784 debug ("Disable PCMCIA buffers and assert RESET\n");
785 reg = PCMCIA_PGCRX(slot);
786 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
788 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
790 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
792 PCMCIA_PGCRX(slot) = reg;
795 #ifndef CONFIG_BMS2003
797 * Configure Port C pins for
798 * 5 Volts Enable and 3 Volts enable,
801 debug ("PCMCIA power OFF\n");
802 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
803 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
804 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
809 case 33: reg |= 0x0002; break;
810 case 50: reg |= 0x0004; break;
813 #else /* CONFIG_BMS2003 */
815 * Configure Port B pins for
816 * 5 Volts Enable and 3 Volts enable,
819 debug ("PCMCIA power OFF\n");
820 immap->im_cpm.cp_pbpar &= ~(0x00000300);
821 /* remove all power */
823 immap->im_cpm.cp_pbdat |= 0x00000300;
828 case 33: reg |= 0x00000200; break;
829 case 50: reg |= 0x00000100; break;
832 #endif /* CONFIG_BMS2003 */
834 /* Checking supported voltages */
836 debug ("PIPR: 0x%x --> %s\n",
838 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
840 #ifndef CONFIG_BMS2003
841 immap->im_ioport.iop_pcdat |= reg;
842 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
844 immap->im_cpm.cp_pbdat &= !reg;
845 immap->im_cpm.cp_pbdir |= 0x00000300;
846 #endif /* CONFIG_BMS2003 */
848 #ifndef CONFIG_BMS2003
849 debug ("PCMCIA powered at %sV\n",
850 (reg&0x0004) ? "5.0" : "3.3");
852 debug ("PCMCIA powered at %sV\n",
853 (reg&0x00000200) ? "5.0" : "3.3");
854 #endif /* CONFIG_BMS2003 */
856 debug ("PCMCIA powered down\n");
860 debug ("Enable PCMCIA buffers and stop RESET\n");
861 reg = PCMCIA_PGCRX(slot);
862 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
864 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
866 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
868 PCMCIA_PGCRX(slot) = reg;
871 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
880 /* -------------------------------------------------------------------- */
882 /* -------------------------------------------------------------------- */
884 #if defined(CONFIG_LWMON)
886 #define PCMCIA_BOARD_MSG "LWMON"
888 /* #define's for MAX1604 Power Switch */
889 #define MAX1604_OP_SUS 0x80
890 #define MAX1604_VCCBON 0x40
891 #define MAX1604_VCC_35 0x20
892 #define MAX1604_VCCBHIZ 0x10
893 #define MAX1604_VPPBON 0x08
894 #define MAX1604_VPPBPBPGM 0x04
895 #define MAX1604_VPPBHIZ 0x02
898 static int hardware_enable(int slot)
900 volatile immap_t *immap;
901 volatile cpm8xx_t *cp;
902 volatile pcmconf8xx_t *pcmp;
903 volatile sysconf8xx_t *sysp;
908 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
910 /* Switch on PCMCIA port in PIC register 0x60 */
911 reg = pic_read (0x60);
912 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
914 /* reg |= 0x08; Vpp not needed */
915 pic_write (0x60, reg);
917 reg = pic_read (0x60);
918 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
922 immap = (immap_t *)CFG_IMMR;
923 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
924 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
925 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
928 * Configure SIUMCR to enable PCMCIA port B
929 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
931 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
933 /* clear interrupt state, and disable interrupts */
934 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
935 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
938 * Disable interrupts, DMA, and PCMCIA buffers
939 * (isolate the interface) and assert RESET signal
941 debug ("Disable PCMCIA buffers and assert RESET\n");
943 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
944 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
945 PCMCIA_PGCRX(_slot_) = reg;
949 * Make sure there is a card in the slot, then configure the interface.
952 debug ("[%d] %s: PIPR(%p)=0x%x\n",
953 __LINE__,__FUNCTION__,
954 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
955 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
956 printf (" No Card found\n");
963 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
964 reg = pcmp->pcmc_pipr;
965 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
967 (reg&PCMCIA_VS1(slot))?"n":"ff",
968 (reg&PCMCIA_VS2(slot))?"n":"ff");
969 if ((reg & mask) == mask) {
970 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
971 puts (" 5.0V card found: ");
973 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
974 puts (" 3.3V card found: ");
978 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
979 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
980 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
984 debug ("Enable PCMCIA buffers and stop RESET\n");
985 reg = PCMCIA_PGCRX(_slot_);
986 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
987 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
988 PCMCIA_PGCRX(_slot_) = reg;
990 udelay(250000); /* some cards need >150 ms to come up :-( */
992 debug ("# hardware_enable done\n");
998 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
999 static int hardware_disable(int slot)
1001 volatile immap_t *immap;
1002 volatile pcmconf8xx_t *pcmp;
1006 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1008 immap = (immap_t *)CFG_IMMR;
1009 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1011 /* remove all power, put output in high impedance state */
1012 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1013 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1014 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1016 /* Configure PCMCIA General Control Register */
1017 debug ("Disable PCMCIA buffers and assert RESET\n");
1019 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1020 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1021 PCMCIA_PGCRX(_slot_) = reg;
1023 /* Switch off PCMCIA port in PIC register 0x60 */
1024 reg = pic_read (0x60);
1025 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1028 pic_write (0x60, reg);
1030 reg = pic_read (0x60);
1031 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1037 #endif /* CFG_CMD_PCMCIA */
1040 static int voltage_set(int slot, int vcc, int vpp)
1042 volatile immap_t *immap;
1043 volatile pcmconf8xx_t *pcmp;
1047 debug ("voltage_set: "
1049 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1050 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1052 immap = (immap_t *)CFG_IMMR;
1053 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1055 * Disable PCMCIA buffers (isolate the interface)
1056 * and assert RESET signal
1058 debug ("Disable PCMCIA buffers and assert RESET\n");
1059 reg = PCMCIA_PGCRX(_slot_);
1060 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1061 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1062 PCMCIA_PGCRX(_slot_) = reg;
1066 * Turn off all power (switch to high impedance)
1068 debug ("PCMCIA power OFF\n");
1069 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1070 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1071 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1076 case 33: val = MAX1604_VCC_35; break;
1081 /* Checking supported voltages */
1083 debug ("PIPR: 0x%x --> %s\n",
1085 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1087 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1089 debug ("PCMCIA powered at %sV\n",
1090 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
1092 debug ("PCMCIA powered down\n");
1096 debug ("Enable PCMCIA buffers and stop RESET\n");
1097 reg = PCMCIA_PGCRX(_slot_);
1098 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1099 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1100 PCMCIA_PGCRX(_slot_) = reg;
1103 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1110 /* -------------------------------------------------------------------- */
1111 /* GTH board by Corelatus AB */
1112 /* -------------------------------------------------------------------- */
1113 #if defined(CONFIG_GTH)
1115 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
1117 static int voltage_set (int slot, int vcc, int vpp)
1122 static int hardware_enable (int slot)
1124 volatile immap_t *immap;
1125 volatile cpm8xx_t *cp;
1126 volatile pcmconf8xx_t *pcmp;
1127 volatile sysconf8xx_t *sysp;
1130 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
1132 immap = (immap_t *) CFG_IMMR;
1133 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1134 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1135 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1137 /* clear interrupt state, and disable interrupts */
1138 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1139 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1142 * Disable interrupts, DMA, and PCMCIA buffers
1143 * (isolate the interface) and assert RESET signal
1145 debug ("Disable PCMCIA buffers and assert RESET\n");
1147 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1148 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1149 PCMCIA_PGCRX (_slot_) = reg;
1153 * Make sure there is a card in the slot,
1154 * then configure the interface.
1157 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1158 __LINE__, __FUNCTION__,
1159 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1160 if (pcmp->pcmc_pipr & 0x98000000) {
1161 printf (" No Card found\n");
1165 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1166 reg = pcmp->pcmc_pipr;
1167 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1169 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1170 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1172 debug ("Enable PCMCIA buffers and stop RESET\n");
1173 reg = PCMCIA_PGCRX (_slot_);
1174 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1175 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1176 PCMCIA_PGCRX (_slot_) = reg;
1178 udelay (250000); /* some cards need >150 ms to come up :-( */
1180 debug ("# hardware_enable done\n");
1184 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1185 static int hardware_disable(int slot)
1187 return 0; /* No hardware to disable */
1189 #endif /* CFG_CMD_PCMCIA */
1190 #endif /* CONFIG_GTH */
1192 /* -------------------------------------------------------------------- */
1193 /* ICU862 Boards by Cambridge Broadband Ltd. */
1194 /* -------------------------------------------------------------------- */
1196 #if defined(CONFIG_ICU862)
1198 #define PCMCIA_BOARD_MSG "ICU862"
1200 static void cfg_port_B (void);
1202 static int hardware_enable(int slot)
1204 volatile immap_t *immap;
1205 volatile cpm8xx_t *cp;
1206 volatile pcmconf8xx_t *pcmp;
1207 volatile sysconf8xx_t *sysp;
1208 uint reg, pipr, mask;
1211 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1215 immap = (immap_t *)CFG_IMMR;
1216 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1217 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1218 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1220 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1224 * Configure SIUMCR to enable PCMCIA port B
1225 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1227 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1229 /* clear interrupt state, and disable interrupts */
1230 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1231 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1234 * Disable interrupts, DMA, and PCMCIA buffers
1235 * (isolate the interface) and assert RESET signal
1237 debug ("Disable PCMCIA buffers and assert RESET\n");
1239 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1240 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1241 PCMCIA_PGCRX(_slot_) = reg;
1245 * Make sure there is a card in the slot, then configure the interface.
1248 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1249 __LINE__,__FUNCTION__,
1250 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1251 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1252 printf (" No Card found\n");
1257 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1259 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1260 pipr = pcmp->pcmc_pipr;
1261 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1263 (reg&PCMCIA_VS1(slot))?"n":"ff",
1264 (reg&PCMCIA_VS2(slot))?"n":"ff");
1267 if ((pipr & mask) == mask) {
1268 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1269 TPS2205_VCC3); /* 3V off */
1270 reg &= ~(TPS2205_VCC5); /* 5V on */
1271 puts (" 5.0V card found: ");
1273 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1274 TPS2205_VCC5); /* 5V off */
1275 reg &= ~(TPS2205_VCC3); /* 3V on */
1276 puts (" 3.3V card found: ");
1279 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1281 (reg & TPS2205_VCC3) ? "off" : "on",
1282 (reg & TPS2205_VCC5) ? "off" : "on",
1283 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1284 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1288 /* Wait 500 ms; use this to check for over-current */
1289 for (i=0; i<5000; ++i) {
1290 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1291 printf (" *** Overcurrent - Safety shutdown ***\n");
1292 cp->cp_pbdat &= ~(TPS2205_SHDN);
1298 debug ("Enable PCMCIA buffers and stop RESET\n");
1299 reg = PCMCIA_PGCRX(_slot_);
1300 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1301 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1302 PCMCIA_PGCRX(_slot_) = reg;
1304 udelay(250000); /* some cards need >150 ms to come up :-( */
1306 debug ("# hardware_enable done\n");
1312 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1313 static int hardware_disable(int slot)
1315 volatile immap_t *immap;
1316 volatile cpm8xx_t *cp;
1317 volatile pcmconf8xx_t *pcmp;
1320 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1322 immap = (immap_t *)CFG_IMMR;
1323 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1324 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1327 cp->cp_pbdat &= ~(TPS2205_SHDN);
1329 /* Configure PCMCIA General Control Register */
1330 debug ("Disable PCMCIA buffers and assert RESET\n");
1332 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1333 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1334 PCMCIA_PGCRX(_slot_) = reg;
1340 #endif /* CFG_CMD_PCMCIA */
1343 static int voltage_set(int slot, int vcc, int vpp)
1345 volatile immap_t *immap;
1346 volatile cpm8xx_t *cp;
1347 volatile pcmconf8xx_t *pcmp;
1350 debug ("voltage_set: "
1352 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1353 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1355 immap = (immap_t *)CFG_IMMR;
1356 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1357 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1359 * Disable PCMCIA buffers (isolate the interface)
1360 * and assert RESET signal
1362 debug ("Disable PCMCIA buffers and assert RESET\n");
1363 reg = PCMCIA_PGCRX(_slot_);
1364 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1365 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1366 PCMCIA_PGCRX(_slot_) = reg;
1370 * Configure Port C pins for
1371 * 5 Volts Enable and 3 Volts enable,
1372 * Turn all power pins to Hi-Z
1374 debug ("PCMCIA power OFF\n");
1375 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1380 case 0: break; /* Switch off */
1381 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1382 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1386 /* Checking supported voltages */
1388 debug ("PIPR: 0x%x --> %s\n",
1390 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1398 if ((reg & TPS2205_VCC3) == 0) {
1400 } else if ((reg & TPS2205_VCC5) == 0) {
1405 printf ("PCMCIA powered %s\n", s);
1410 debug ("Enable PCMCIA buffers and stop RESET\n");
1411 reg = PCMCIA_PGCRX(_slot_);
1412 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1413 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1414 PCMCIA_PGCRX(_slot_) = reg;
1417 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1422 static void cfg_port_B (void)
1424 volatile immap_t *immap;
1425 volatile cpm8xx_t *cp;
1428 immap = (immap_t *)CFG_IMMR;
1429 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1432 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1434 * Switch off all voltages, assert shutdown
1437 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1438 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1439 TPS2205_SHDN); /* enable switch */
1442 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1444 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1445 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1447 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1448 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1454 /* -------------------------------------------------------------------- */
1455 /* C2MON Boards by TTTech Computertechnik AG */
1456 /* -------------------------------------------------------------------- */
1458 #if defined(CONFIG_C2MON)
1460 #define PCMCIA_BOARD_MSG "C2MON"
1462 static void cfg_ports (void);
1464 static int hardware_enable(int slot)
1466 volatile immap_t *immap;
1467 volatile cpm8xx_t *cp;
1468 volatile pcmconf8xx_t *pcmp;
1469 volatile sysconf8xx_t *sysp;
1470 uint reg, pipr, mask;
1474 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1478 immap = (immap_t *)CFG_IMMR;
1479 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1480 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1481 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1483 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1487 * Configure SIUMCR to enable PCMCIA port B
1488 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1490 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1492 /* clear interrupt state, and disable interrupts */
1493 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1494 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1497 * Disable interrupts, DMA, and PCMCIA buffers
1498 * (isolate the interface) and assert RESET signal
1500 debug ("Disable PCMCIA buffers and assert RESET\n");
1502 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1503 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1504 PCMCIA_PGCRX(_slot_) = reg;
1508 * Make sure there is a card in the slot, then configure the interface.
1511 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1512 __LINE__,__FUNCTION__,
1513 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1514 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1515 printf (" No Card found\n");
1520 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1522 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1523 pipr = pcmp->pcmc_pipr;
1524 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1526 (reg&PCMCIA_VS1(slot))?"n":"ff",
1527 (reg&PCMCIA_VS2(slot))?"n":"ff");
1529 sreg = immap->im_ioport.iop_pcdat;
1530 if ((pipr & mask) == mask) {
1531 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1532 TPS2211_VCCD1); /* 5V on */
1533 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1534 puts (" 5.0V card found: ");
1536 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1537 TPS2211_VCCD0); /* 3V on */
1538 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1539 puts (" 3.3V card found: ");
1542 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1544 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1545 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1548 immap->im_ioport.iop_pcdat = sreg;
1550 /* Wait 500 ms; use this to check for over-current */
1551 for (i=0; i<5000; ++i) {
1552 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1553 printf (" *** Overcurrent - Safety shutdown ***\n");
1554 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1560 debug ("Enable PCMCIA buffers and stop RESET\n");
1561 reg = PCMCIA_PGCRX(_slot_);
1562 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1563 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1564 PCMCIA_PGCRX(_slot_) = reg;
1566 udelay(250000); /* some cards need >150 ms to come up :-( */
1568 debug ("# hardware_enable done\n");
1574 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1575 static int hardware_disable(int slot)
1577 volatile immap_t *immap;
1578 volatile cpm8xx_t *cp;
1579 volatile pcmconf8xx_t *pcmp;
1582 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1584 immap = (immap_t *)CFG_IMMR;
1585 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1587 /* Configure PCMCIA General Control Register */
1588 debug ("Disable PCMCIA buffers and assert RESET\n");
1590 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1591 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1592 PCMCIA_PGCRX(_slot_) = reg;
1594 /* ALl voltages off / Hi-Z */
1595 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1596 TPS2211_VCCD0 | TPS2211_VCCD1 );
1602 #endif /* CFG_CMD_PCMCIA */
1605 static int voltage_set(int slot, int vcc, int vpp)
1607 volatile immap_t *immap;
1608 volatile cpm8xx_t *cp;
1609 volatile pcmconf8xx_t *pcmp;
1613 debug ("voltage_set: "
1615 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1616 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1618 immap = (immap_t *)CFG_IMMR;
1619 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1620 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1622 * Disable PCMCIA buffers (isolate the interface)
1623 * and assert RESET signal
1625 debug ("Disable PCMCIA buffers and assert RESET\n");
1626 reg = PCMCIA_PGCRX(_slot_);
1627 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1628 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1629 PCMCIA_PGCRX(_slot_) = reg;
1633 * Configure Port C pins for
1634 * 5 Volts Enable and 3 Volts enable,
1635 * Turn all power pins to Hi-Z
1637 debug ("PCMCIA power OFF\n");
1638 cfg_ports (); /* Enables switch, but all in Hi-Z */
1640 sreg = immap->im_ioport.iop_pcdat;
1641 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1644 case 0: break; /* Switch off */
1645 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1646 sreg &= ~TPS2211_VCCD1;
1648 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1649 sreg |= TPS2211_VCCD1;
1654 /* Checking supported voltages */
1656 debug ("PIPR: 0x%x --> %s\n",
1658 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1660 immap->im_ioport.iop_pcdat = sreg;
1666 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1668 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1673 printf ("PCMCIA powered %s\n", s);
1678 debug ("Enable PCMCIA buffers and stop 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;
1685 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1690 static void cfg_ports (void)
1692 volatile immap_t *immap;
1693 volatile cpm8xx_t *cp;
1696 immap = (immap_t *)CFG_IMMR;
1697 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1700 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1702 * Switch off all voltages, assert shutdown
1704 sreg = immap->im_ioport.iop_pcdat;
1705 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1706 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1707 immap->im_ioport.iop_pcdat = sreg;
1709 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1710 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1712 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1713 immap->im_ioport.iop_pcpar,
1714 immap->im_ioport.iop_pcdir,
1715 immap->im_ioport.iop_pcdat);
1718 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1720 * Over-Current Input only
1722 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1723 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1725 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1726 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1731 /* -------------------------------------------------------------------- */
1732 /* MBX board from Morotola */
1733 /* -------------------------------------------------------------------- */
1735 #if defined( CONFIG_MBX )
1736 #include <../board/mbx8xx/csr.h>
1738 /* A lot of this has been taken from the RPX code in this file it works from me.
1739 I have added the voltage selection for the MBX board. */
1741 /* MBX voltage bit in control register #2 */
1742 #define CR2_VPP12 ((uchar)0x10)
1743 #define CR2_VPPVDD ((uchar)0x20)
1744 #define CR2_VDD5 ((uchar)0x40)
1745 #define CR2_VDD3 ((uchar)0x80)
1747 #define PCMCIA_BOARD_MSG "MBX860"
1749 static int voltage_set (int slot, int vcc, int vpp)
1753 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1754 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1787 /* first, turn off all power */
1788 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1790 /* enable new powersettings */
1792 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1797 static int hardware_enable (int slot)
1799 volatile immap_t *immap;
1800 volatile cpm8xx_t *cp;
1801 volatile pcmconf8xx_t *pcmp;
1802 volatile sysconf8xx_t *sysp;
1805 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1810 immap = (immap_t *) CFG_IMMR;
1811 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1812 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1813 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1815 /* clear interrupt state, and disable interrupts */
1816 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1817 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1820 * Disable interrupts, DMA, and PCMCIA buffers
1821 * (isolate the interface) and assert RESET signal
1823 debug ("Disable PCMCIA buffers and assert RESET\n");
1825 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1826 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1827 PCMCIA_PGCRX (_slot_) = reg;
1830 /* remove all power */
1831 voltage_set (slot, 0, 0);
1833 * Make sure there is a card in the slot, then configure the interface.
1836 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1837 __LINE__,__FUNCTION__,
1838 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1839 #ifndef CONFIG_BMS2003
1840 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1842 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
1843 #endif /* CONFIG_BMS2003 */
1844 printf (" No Card found\n");
1851 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1852 reg = pcmp->pcmc_pipr;
1853 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1854 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1855 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1857 if ((reg & mask) == mask) {
1858 voltage_set (_slot_, 50, 0);
1859 printf (" 5.0V card found: ");
1861 voltage_set (_slot_, 33, 0);
1862 printf (" 3.3V card found: ");
1865 debug ("Enable PCMCIA buffers and stop RESET\n");
1866 reg = PCMCIA_PGCRX (_slot_);
1867 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1868 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1869 PCMCIA_PGCRX (_slot_) = reg;
1871 udelay (250000); /* some cards need >150 ms to come up :-( */
1873 debug ("# hardware_enable done\n");
1878 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1879 static int hardware_disable (int slot)
1881 return 0; /* No hardware to disable */
1883 #endif /* CFG_CMD_PCMCIA */
1884 #endif /* CONFIG_MBX */
1885 /* -------------------------------------------------------------------- */
1887 /* -------------------------------------------------------------------- */
1889 #if defined(CONFIG_R360MPI)
1891 #define PCMCIA_BOARD_MSG "R360MPI"
1894 static int hardware_enable(int slot)
1896 volatile immap_t *immap;
1897 volatile cpm8xx_t *cp;
1898 volatile pcmconf8xx_t *pcmp;
1899 volatile sysconf8xx_t *sysp;
1902 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1906 immap = (immap_t *)CFG_IMMR;
1907 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1908 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1909 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1912 * Configure SIUMCR to enable PCMCIA port B
1913 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1915 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1917 /* clear interrupt state, and disable interrupts */
1918 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1919 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1922 * Disable interrupts, DMA, and PCMCIA buffers
1923 * (isolate the interface) and assert RESET signal
1925 debug ("Disable PCMCIA buffers and assert RESET\n");
1927 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1928 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1929 PCMCIA_PGCRX(_slot_) = reg;
1933 * Configure Ports A, B & C pins for
1934 * 5 Volts Enable and 3 Volts enable
1936 immap->im_ioport.iop_pcpar &= ~(0x0400);
1937 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1938 immap->im_ioport.iop_pcdir |= 0x0400;*/
1940 immap->im_ioport.iop_papar &= ~(0x0200);/*
1941 immap->im_ioport.iop_padir |= 0x0200;*/
1943 immap->im_ioport.iop_pbpar &= ~(0xC000);
1944 immap->im_ioport.iop_pbdir &= ~(0xC000);
1946 /* remove all power */
1948 immap->im_ioport.iop_pcdat |= 0x0400;
1949 immap->im_ioport.iop_padat |= 0x0200;
1952 * Make sure there is a card in the slot, then configure the interface.
1955 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1956 __LINE__,__FUNCTION__,
1957 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1958 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1959 printf (" No Card found\n");
1966 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1967 reg = pcmp->pcmc_pipr;
1968 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1970 (reg&PCMCIA_VS1(slot))?"n":"ff",
1971 (reg&PCMCIA_VS2(slot))?"n":"ff");
1972 if ((reg & mask) == mask) {
1973 immap->im_ioport.iop_pcdat &= ~(0x4000);
1974 puts (" 5.0V card found: ");
1976 immap->im_ioport.iop_padat &= ~(0x0002);
1977 puts (" 3.3V card found: ");
1979 immap->im_ioport.iop_pcdir |= 0x0400;
1980 immap->im_ioport.iop_padir |= 0x0200;
1982 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
1983 cp->cp_pbdir &= ~(0x0020 | 0x0010);
1984 cp->cp_pbpar &= ~(0x0020 | 0x0010);
1987 debug ("Enable PCMCIA buffers and stop RESET\n");
1988 reg = PCMCIA_PGCRX(_slot_);
1989 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1990 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1991 PCMCIA_PGCRX(_slot_) = reg;
1993 udelay(250000); /* some cards need >150 ms to come up :-( */
1995 debug ("# hardware_enable done\n");
2001 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2002 static int hardware_disable(int slot)
2004 volatile immap_t *immap;
2005 volatile pcmconf8xx_t *pcmp;
2008 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2010 immap = (immap_t *)CFG_IMMR;
2011 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2013 /* remove all power */
2014 immap->im_ioport.iop_pcdat |= 0x0400;
2015 immap->im_ioport.iop_padat |= 0x0200;
2017 /* Configure PCMCIA General Control Register */
2018 debug ("Disable PCMCIA buffers and assert RESET\n");
2020 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2021 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2022 PCMCIA_PGCRX(_slot_) = reg;
2028 #endif /* CFG_CMD_PCMCIA */
2031 static int voltage_set(int slot, int vcc, int vpp)
2033 volatile immap_t *immap;
2034 volatile pcmconf8xx_t *pcmp;
2037 debug ("voltage_set: "
2039 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2040 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2042 immap = (immap_t *)CFG_IMMR;
2043 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2045 * Disable PCMCIA buffers (isolate the interface)
2046 * and assert RESET signal
2048 debug ("Disable PCMCIA buffers and assert RESET\n");
2049 reg = PCMCIA_PGCRX(_slot_);
2050 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2051 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2052 PCMCIA_PGCRX(_slot_) = reg;
2056 * Configure Ports A & C pins for
2057 * 5 Volts Enable and 3 Volts enable,
2058 * Turn off all power
2060 debug ("PCMCIA power OFF\n");
2061 immap->im_ioport.iop_pcpar &= ~(0x0400);
2062 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2063 immap->im_ioport.iop_pcdir |= 0x0400;*/
2065 immap->im_ioport.iop_papar &= ~(0x0200);/*
2066 immap->im_ioport.iop_padir |= 0x0200;*/
2068 immap->im_ioport.iop_pcdat |= 0x0400;
2069 immap->im_ioport.iop_padat |= 0x0200;
2074 case 33: reg |= 0x0200; break;
2075 case 50: reg |= 0x0400; break;
2079 /* Checking supported voltages */
2081 debug ("PIPR: 0x%x --> %s\n",
2083 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
2086 immap->im_ioport.iop_pcdat &= !reg;
2088 immap->im_ioport.iop_padat &= !reg;
2089 immap->im_ioport.iop_pcdir |= 0x0200;
2090 immap->im_ioport.iop_padir |= 0x0400;
2092 debug ("PCMCIA powered at %sV\n",
2093 (reg&0x0400) ? "5.0" : "3.3");
2095 debug ("PCMCIA powered down\n");
2099 debug ("Enable PCMCIA buffers and stop RESET\n");
2100 reg = PCMCIA_PGCRX(_slot_);
2101 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2102 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2103 PCMCIA_PGCRX(_slot_) = reg;
2106 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2111 #endif /* R360MPI */
2113 /* -------------------------------------------------------------------- */
2115 /* -------------------------------------------------------------------- */
2116 #if defined(CONFIG_KUP4K)
2118 #define PCMCIA_BOARD_MSG "KUP4K"
2120 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
2122 static int hardware_enable(int slot)
2124 volatile immap_t *immap;
2125 volatile cpm8xx_t *cp;
2126 volatile pcmconf8xx_t *pcmp;
2127 volatile sysconf8xx_t *sysp;
2130 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2134 immap = (immap_t *)CFG_IMMR;
2135 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2136 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2137 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2140 * Configure SIUMCR to enable PCMCIA port B
2141 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2143 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2145 /* clear interrupt state, and disable interrupts */
2146 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2147 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2150 * Disable interrupts, DMA, and PCMCIA buffers
2151 * (isolate the interface) and assert RESET signal
2153 debug ("Disable PCMCIA buffers and assert RESET\n");
2155 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2156 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2157 PCMCIA_PGCRX(slot) = reg;
2161 * Configure Port B pins for
2164 if (slot) { /* Slot A is built-in */
2165 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2166 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2167 /* remove all power */
2168 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2171 * Make sure there is a card in the slot, then configure the interface.
2174 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2175 __LINE__,__FUNCTION__,
2176 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2177 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2178 printf (" No Card found\n");
2185 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2186 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2187 reg = pcmp->pcmc_pipr;
2188 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2190 (reg&PCMCIA_VS1(slot))?"n":"ff",
2191 (reg&PCMCIA_VS2(slot))?"n":"ff");
2192 if ((reg & mask) == mask) {
2193 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2196 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2197 puts (" 3.3V card found: ");
2200 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2201 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2202 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2205 debug ("Enable PCMCIA buffers and stop RESET\n");
2206 reg = PCMCIA_PGCRX(slot);
2207 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2208 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2209 PCMCIA_PGCRX(slot) = reg;
2211 udelay(250000); /* some cards need >150 ms to come up :-( */
2213 debug ("# hardware_enable done\n");
2219 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2220 static int hardware_disable(int slot)
2222 volatile immap_t *immap;
2223 volatile cpm8xx_t *cp;
2224 volatile pcmconf8xx_t *pcmp;
2227 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2229 immap = (immap_t *)CFG_IMMR;
2230 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2231 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2233 /* remove all power */
2235 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2237 /* Configure PCMCIA General Control Register */
2238 debug ("Disable PCMCIA buffers and assert RESET\n");
2240 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2241 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2242 PCMCIA_PGCRX(slot) = reg;
2248 #endif /* CFG_CMD_PCMCIA */
2251 static int voltage_set(int slot, int vcc, int vpp)
2253 volatile immap_t *immap;
2254 volatile cpm8xx_t *cp;
2255 volatile pcmconf8xx_t *pcmp;
2258 debug ("voltage_set: " \
2260 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2261 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2263 if (!slot) /* Slot A is not configurable */
2266 immap = (immap_t *)CFG_IMMR;
2267 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2268 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2271 * Disable PCMCIA buffers (isolate the interface)
2272 * and assert RESET signal
2274 debug ("Disable PCMCIA buffers and assert RESET\n");
2275 reg = PCMCIA_PGCRX(slot);
2276 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2277 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2278 PCMCIA_PGCRX(slot) = reg;
2281 debug ("PCMCIA power OFF\n");
2283 * Configure Port B pins for
2286 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2287 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2288 /* remove all power */
2289 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2294 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2295 debug ("PCMCIA powered at 3.3V\n");
2298 debug ("PCMCIA: 5Volt vcc not supported\n");
2301 puts("PCMCIA: vcc not supported");
2305 /* Checking supported voltages */
2307 debug ("PIPR: 0x%x --> %s\n",
2309 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2310 ? "only 5 V --> NOT SUPPORTED"
2314 debug ("Enable PCMCIA buffers and stop RESET\n");
2315 reg = PCMCIA_PGCRX(slot);
2316 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2317 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2318 PCMCIA_PGCRX(slot) = reg;
2321 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2329 /* -------------------------------------------------------------------- */
2330 /* End of Board Specific Stuff */
2331 /* -------------------------------------------------------------------- */
2334 /* -------------------------------------------------------------------- */
2335 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2336 /* -------------------------------------------------------------------- */
2339 * Search this table to see if the windowsize is
2343 #define M8XX_SIZES_NO 32
2345 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2346 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2347 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2348 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2349 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2351 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2352 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2353 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2354 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2357 /* -------------------------------------------------------------------- */
2359 #ifndef CONFIG_I82365
2361 static u_int m8xx_get_graycode(u_int size)
2365 for (k = 0; k < M8XX_SIZES_NO; k++) {
2366 if(m8xx_size_to_gray[k] == size)
2370 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2376 #endif /* CONFIG_I82365 */
2378 /* -------------------------------------------------------------------- */
2381 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2383 u_int reg, clocks, psst, psl, psht;
2388 * We get called with IO maps setup to 0ns
2389 * if not specified by the user.
2390 * They should be 255ns.
2396 ns = 100; /* fast memory if 0 */
2400 * In PSST, PSL, PSHT fields we tell the controller
2401 * timing parameters in CLKOUT clock cycles.
2402 * CLKOUT is the same as GCLK2_50.
2405 /* how we want to adjust the timing - in percent */
2407 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2409 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2410 clocks = (clocks * ADJ) / (100*1000);
2412 if(clocks >= PCMCIA_BMT_LIMIT) {
2413 DEBUG(0, "Max access time limit reached\n");
2414 clocks = PCMCIA_BMT_LIMIT-1;
2417 psst = clocks / 7; /* setup time */
2418 psht = clocks / 7; /* hold time */
2419 psl = (clocks * 5) / 7; /* strobe length */
2421 psst += clocks - (psst + psht + psl);
2431 /* -------------------------------------------------------------------- */
2433 #ifdef CONFIG_IDE_8xx_PCCARD
2434 static void print_funcid (int func)
2438 case CISTPL_FUNCID_MULTI:
2439 puts (" Multi-Function");
2441 case CISTPL_FUNCID_MEMORY:
2444 case CISTPL_FUNCID_SERIAL:
2445 puts (" Serial Port");
2447 case CISTPL_FUNCID_PARALLEL:
2448 puts (" Parallel Port");
2450 case CISTPL_FUNCID_FIXED:
2451 puts (" Fixed Disk");
2453 case CISTPL_FUNCID_VIDEO:
2454 puts (" Video Adapter");
2456 case CISTPL_FUNCID_NETWORK:
2457 puts (" Network Adapter");
2459 case CISTPL_FUNCID_AIMS:
2460 puts (" AIMS Card");
2462 case CISTPL_FUNCID_SCSI:
2463 puts (" SCSI Adapter");
2471 #endif /* CONFIG_IDE_8xx_PCCARD */
2473 /* -------------------------------------------------------------------- */
2475 #ifdef CONFIG_IDE_8xx_PCCARD
2476 static void print_fixed (volatile uchar *p)
2484 case CISTPL_FUNCE_IDE_IFACE:
2485 { uchar iface = *(p+2);
2487 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2488 puts (" interface ");
2491 case CISTPL_FUNCE_IDE_MASTER:
2492 case CISTPL_FUNCE_IDE_SLAVE:
2493 { uchar f1 = *(p+2);
2496 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2498 if (f1 & CISTPL_IDE_UNIQUE)
2501 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2503 if (f2 & CISTPL_IDE_HAS_SLEEP)
2506 if (f2 & CISTPL_IDE_HAS_STANDBY)
2507 puts (" [standby]");
2509 if (f2 & CISTPL_IDE_HAS_IDLE)
2512 if (f2 & CISTPL_IDE_LOW_POWER)
2513 puts (" [low power]");
2515 if (f2 & CISTPL_IDE_REG_INHIBIT)
2516 puts (" [reg inhibit]");
2518 if (f2 & CISTPL_IDE_HAS_INDEX)
2521 if (f2 & CISTPL_IDE_IOIS16)
2529 #endif /* CONFIG_IDE_8xx_PCCARD */
2531 /* -------------------------------------------------------------------- */
2533 #ifdef CONFIG_IDE_8xx_PCCARD
2535 #define MAX_IDENT_CHARS 64
2536 #define MAX_IDENT_FIELDS 4
2538 static uchar *known_cards[] = {
2543 static int identify (volatile uchar *p)
2545 uchar id_str[MAX_IDENT_CHARS];
2552 return (0); /* Don't know */
2557 for (i=0; i<=4 && !done; ++i, p+=2) {
2558 while ((data = *p) != '\0') {
2564 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2574 while (--t > id_str) {
2583 for (card=known_cards; *card; ++card) {
2584 debug ("## Compare against \"%s\"\n", *card);
2585 if (strcmp(*card, id_str) == 0) { /* found! */
2586 debug ("## CARD FOUND ##\n");
2591 return (0); /* don't know */
2593 #endif /* CONFIG_IDE_8xx_PCCARD */
2595 /* -------------------------------------------------------------------- */
2597 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
2599 /**************************************************/
2601 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2603 pinit, 2, 1, do_pinit,
2604 "pinit - PCMCIA sub-system\n",
2605 "on - power on PCMCIA socket\n"
2606 "pinit off - power off PCMCIA socket\n"