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);
164 # define HMI10_FRAM_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(2) | PCMCIA_SL(4))
166 #if defined(CONFIG_LWMON) || defined(CONFIG_NSCU)
167 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
169 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
180 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
182 /* intialize the fixed memory windows */
183 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
184 base = CFG_PCMCIA_MEM_ADDR;
186 if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
187 printf ("Cannot set window size to 0x%08x\n",
188 CFG_PCMCIA_MEM_SIZE);
192 slotbit = PCMCIA_SLOT_x;
193 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
196 #if (PCMCIA_SOCKETS_NO == 2)
197 if (i == 4) /* Another slot starting from win 4 */
198 slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
201 #ifdef CONFIG_IDE_8xx_PCCARD
204 { /* map FRAM area */
205 win->or = ( PCMCIA_BSIZE_256K
210 | HMI10_FRAM_TIMING );
214 case 0: { /* map attribute memory */
215 win->or = ( PCMCIA_BSIZE_64M
220 | CFG_PCMCIA_TIMING );
224 case 1: { /* map I/O window for data reg */
225 win->or = ( PCMCIA_BSIZE_1K
230 | CFG_PCMCIA_TIMING );
234 case 2: { /* map I/O window for cmd/ctrl reg block */
235 win->or = ( PCMCIA_BSIZE_1K
240 | CFG_PCMCIA_TIMING );
243 #endif /* CONFIG_IDE_8xx_PCCARD */
245 case 3: { /* map I/O window for 4xUART data/ctrl */
247 win->or = ( PCMCIA_BSIZE_256K
252 | CFG_PCMCIA_TIMING );
255 #endif /* CONFIG_HMI10 */
256 default: /* set to not valid */
261 debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
262 i, win->br, win->or);
263 base += CFG_PCMCIA_MEM_SIZE;
267 for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
268 /* turn off voltage */
269 if ((rc = voltage_set(slot, 0, 0)))
272 /* Enable external hardware */
273 if ((rc = hardware_enable(slot)))
276 #ifdef CONFIG_IDE_8xx_PCCARD
277 if ((rc = check_ide_device(i)))
283 #endif /* CONFIG_I82365 */
285 /* -------------------------------------------------------------------- */
287 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
290 static int pcmcia_off (void)
292 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
299 static int pcmcia_off (void)
304 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
306 /* clear interrupt state, and disable interrupts */
307 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
308 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
310 /* turn off interrupt and disable CxOE */
311 PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
313 /* turn off memory windows */
314 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
316 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
317 /* disable memory window */
322 /* turn off voltage */
323 voltage_set(_slot_, 0, 0);
325 /* disable external hardware */
326 printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
327 hardware_disable(_slot_);
330 #endif /* CONFIG_I82365 */
332 #endif /* CFG_CMD_PCMCIA */
334 /* -------------------------------------------------------------------- */
336 #ifdef CONFIG_IDE_8xx_PCCARD
338 #define MAX_TUPEL_SZ 512
339 #define MAX_FEATURES 4
341 int ide_devices_found;
342 static int check_ide_device (int slot)
344 volatile uchar *ident = NULL;
345 volatile uchar *feature_p[MAX_FEATURES];
346 volatile uchar *p, *start, *addr;
350 ushort config_base = 0;
354 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
355 CFG_PCMCIA_MEM_SIZE * (slot * 4));
356 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
358 start = p = (volatile uchar *) addr;
360 while ((p - start) < MAX_TUPEL_SZ) {
364 if (code == 0xFF) { /* End of chain */
369 #if defined(DEBUG) && (DEBUG > 1)
370 { volatile uchar *q = p;
371 printf ("\nTuple code %02x length %d\n\tData:",
374 for (i = 0; i < len; ++i) {
375 printf (" %02x", *q);
385 /* Fix for broken SanDisk which may have 0x80 bit set */
389 if (n_features < MAX_FEATURES)
390 feature_p[n_features++] = p;
393 config_base = (*(p+6) << 8) + (*(p+4));
394 debug ("\n## Config_base = %04x ###\n", config_base);
401 found = identify (ident);
403 if (func_id != ((uchar)~0)) {
404 print_funcid (func_id);
406 if (func_id == CISTPL_FUNCID_FIXED)
409 return (1); /* no disk drive */
412 for (i=0; i<n_features; ++i) {
413 print_fixed (feature_p[i]);
417 printf ("unknown card type\n");
421 ide_devices_found |= (1 << slot);
423 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
424 *((uchar *)(addr + config_base)) = 1;
428 #endif /* CONFIG_IDE_8xx_PCCARD */
430 /* -------------------------------------------------------------------- */
433 /* -------------------------------------------------------------------- */
434 /* board specific stuff: */
435 /* voltage_set(), hardware_enable() and hardware_disable() */
436 /* -------------------------------------------------------------------- */
438 /* -------------------------------------------------------------------- */
439 /* RPX Boards from Embedded Planet */
440 /* -------------------------------------------------------------------- */
442 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
444 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
445 * SYPCR is write once only, therefore must the slowest memory be faster
446 * than the bus monitor or we will get a machine check due to the bus timeout.
449 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
451 #undef PCMCIA_BMT_LIMIT
452 #define PCMCIA_BMT_LIMIT (6*8)
454 static int voltage_set(int slot, int vcc, int vpp)
460 case 33: reg |= BCSR1_PCVCTL4; break;
461 case 50: reg |= BCSR1_PCVCTL5; break;
470 reg |= BCSR1_PCVCTL6;
475 reg |= BCSR1_PCVCTL7;
482 /* first, turn off all power */
484 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
485 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
487 /* enable new powersettings */
489 *((uint *)RPX_CSR_ADDR) |= reg;
494 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
495 static int hardware_enable (int slot)
497 return 0; /* No hardware to enable */
499 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
500 static int hardware_disable(int slot)
502 return 0; /* No hardware to disable */
504 #endif /* CFG_CMD_PCMCIA */
505 #endif /* CONFIG_RPXCLASSIC */
507 /* -------------------------------------------------------------------- */
508 /* (F)ADS Boards from Motorola */
509 /* -------------------------------------------------------------------- */
511 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
514 #define PCMCIA_BOARD_MSG "ADS"
515 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
517 #define PCMCIA_BOARD_MSG "FADS"
520 static int voltage_set(int slot, int vcc, int vpp)
525 case 0: reg = 0; break;
526 case 50: reg = 1; break;
527 case 120: reg = 2; break;
532 case 0: reg = 0; break;
534 case 50: reg = BCSR1_PCCVCCON; break;
537 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
538 case 50: reg = BCSR1_PCCVCC1; break;
543 /* first, turn off all power */
546 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
549 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
551 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
553 /* enable new powersettings */
556 *((uint *)BCSR1) &= ~reg;
559 *((uint *)BCSR1) |= reg;
562 *((uint *)BCSR1) |= reg << 20;
567 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
569 static int hardware_enable(int slot)
571 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
575 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
576 static int hardware_disable(int slot)
578 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
581 #endif /* CFG_CMD_PCMCIA */
585 /* -------------------------------------------------------------------- */
586 /* TQM8xxL Boards by TQ Components */
587 /* SC8xx Boards by SinoVee Microsystems */
588 /* -------------------------------------------------------------------- */
590 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)
592 #if defined(CONFIG_TQM8xxL)
593 #define PCMCIA_BOARD_MSG "TQM8xxL"
595 #if defined(CONFIG_SVM_SC8xx)
596 #define PCMCIA_BOARD_MSG "SC8xx"
599 static int hardware_enable(int slot)
601 volatile immap_t *immap;
602 volatile cpm8xx_t *cp;
603 volatile pcmconf8xx_t *pcmp;
604 volatile sysconf8xx_t *sysp;
607 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
611 immap = (immap_t *)CFG_IMMR;
612 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
613 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
614 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
617 * Configure SIUMCR to enable PCMCIA port B
618 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
620 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
622 /* clear interrupt state, and disable interrupts */
623 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
624 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
627 * Disable interrupts, DMA, and PCMCIA buffers
628 * (isolate the interface) and assert RESET signal
630 debug ("Disable PCMCIA buffers and assert RESET\n");
632 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
634 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
636 PCMCIA_PGCRX(slot) = reg;
642 * Configure Port C pins for
643 * 5 Volts Enable and 3 Volts enable
645 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
646 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
647 /* remove all power */
649 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
651 #else /* CONFIG_HMI10 */
653 * Configure Port B pins for
654 * 5 Volts Enable and 3 Volts enable
656 immap->im_cpm.cp_pbpar &= ~(0x00000300);
658 /* remove all power */
659 immap->im_cpm.cp_pbdat |= 0x00000300;
660 #endif /* CONFIG_HMI10 */
663 * Make sure there is a card in the slot, then configure the interface.
666 debug ("[%d] %s: PIPR(%p)=0x%x\n",
667 __LINE__,__FUNCTION__,
668 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
670 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
672 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
673 #endif /* CONFIG_HMI10 */
674 printf (" No Card found\n");
681 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
682 reg = pcmp->pcmc_pipr;
683 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
685 (reg&PCMCIA_VS1(slot))?"n":"ff",
686 (reg&PCMCIA_VS2(slot))?"n":"ff");
688 if ((reg & mask) == mask) {
690 immap->im_ioport.iop_pcdat |= 0x0004;
692 immap->im_cpm.cp_pbdat &= ~(0x0000100);
693 #endif /* CONFIG_HMI10 */
694 puts (" 5.0V card found: ");
697 immap->im_ioport.iop_pcdat |= 0x0002;
699 immap->im_cpm.cp_pbdat &= ~(0x0000200);
700 #endif /* CONFIG_HMI10 */
701 puts (" 3.3V card found: ");
704 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
706 immap->im_cpm.cp_pbdir |= 0x00000300;
707 #endif /* CONFIG_HMI10 */
709 if ((reg & mask) == mask) {
710 puts (" 5.0V card found: ");
712 puts (" 3.3V card found: ");
716 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
717 cp->cp_pbdir &= ~(0x0020 | 0x0010);
718 cp->cp_pbpar &= ~(0x0020 | 0x0010);
722 debug ("Enable PCMCIA buffers and stop RESET\n");
723 reg = PCMCIA_PGCRX(slot);
724 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
726 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
728 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
730 PCMCIA_PGCRX(slot) = reg;
732 udelay(250000); /* some cards need >150 ms to come up :-( */
734 debug ("# hardware_enable done\n");
740 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
741 static int hardware_disable(int slot)
743 volatile immap_t *immap;
744 volatile pcmconf8xx_t *pcmp;
747 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
749 immap = (immap_t *)CFG_IMMR;
750 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
754 /* remove all power */
755 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
757 #else /* CONFIG_HMI10 */
758 immap->im_cpm.cp_pbdat |= 0x00000300;
759 #endif /* CONFIG_HMI10 */
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 #endif /* CFG_CMD_PCMCIA */
776 static int voltage_set(int slot, int vcc, int vpp)
781 static int voltage_set(int slot, int vcc, int vpp)
783 volatile immap_t *immap;
784 volatile pcmconf8xx_t *pcmp;
787 debug ("voltage_set: "
789 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
790 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
792 immap = (immap_t *)CFG_IMMR;
793 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
795 * Disable PCMCIA buffers (isolate the interface)
796 * and assert RESET signal
798 debug ("Disable PCMCIA buffers and assert RESET\n");
799 reg = PCMCIA_PGCRX(slot);
800 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
802 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
804 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
806 PCMCIA_PGCRX(slot) = reg;
811 * Configure Port C pins for
812 * 5 Volts Enable and 3 Volts enable,
815 debug ("PCMCIA power OFF\n");
816 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
817 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
818 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
823 case 33: reg |= 0x0002; break;
824 case 50: reg |= 0x0004; break;
827 #else /* CONFIG_HMI10 */
829 * Configure Port B pins for
830 * 5 Volts Enable and 3 Volts enable,
833 debug ("PCMCIA power OFF\n");
834 immap->im_cpm.cp_pbpar &= ~(0x00000300);
835 /* remove all power */
837 immap->im_cpm.cp_pbdat |= 0x00000300;
842 case 33: reg |= 0x00000200; break;
843 case 50: reg |= 0x00000100; break;
846 #endif /* CONFIG_HMI10 */
848 /* Checking supported voltages */
850 debug ("PIPR: 0x%x --> %s\n",
852 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
855 immap->im_ioport.iop_pcdat |= reg;
856 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
858 immap->im_cpm.cp_pbdat &= !reg;
859 immap->im_cpm.cp_pbdir |= 0x00000300;
860 #endif /* CONFIG_HMI10 */
863 debug ("PCMCIA powered at %sV\n",
864 (reg&0x0004) ? "5.0" : "3.3");
866 debug ("PCMCIA powered at %sV\n",
867 (reg&0x00000200) ? "5.0" : "3.3");
868 #endif /* CONFIG_HMI10 */
870 debug ("PCMCIA powered down\n");
874 debug ("Enable PCMCIA buffers and stop RESET\n");
875 reg = PCMCIA_PGCRX(slot);
876 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
878 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
880 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
882 PCMCIA_PGCRX(slot) = reg;
885 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
894 /* -------------------------------------------------------------------- */
896 /* -------------------------------------------------------------------- */
898 #if defined(CONFIG_LWMON)
900 #define PCMCIA_BOARD_MSG "LWMON"
902 /* #define's for MAX1604 Power Switch */
903 #define MAX1604_OP_SUS 0x80
904 #define MAX1604_VCCBON 0x40
905 #define MAX1604_VCC_35 0x20
906 #define MAX1604_VCCBHIZ 0x10
907 #define MAX1604_VPPBON 0x08
908 #define MAX1604_VPPBPBPGM 0x04
909 #define MAX1604_VPPBHIZ 0x02
912 static int hardware_enable(int slot)
914 volatile immap_t *immap;
915 volatile cpm8xx_t *cp;
916 volatile pcmconf8xx_t *pcmp;
917 volatile sysconf8xx_t *sysp;
922 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
924 /* Switch on PCMCIA port in PIC register 0x60 */
925 reg = pic_read (0x60);
926 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
928 /* reg |= 0x08; Vpp not needed */
929 pic_write (0x60, reg);
931 reg = pic_read (0x60);
932 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
936 immap = (immap_t *)CFG_IMMR;
937 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
938 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
939 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
942 * Configure SIUMCR to enable PCMCIA port B
943 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
945 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
947 /* clear interrupt state, and disable interrupts */
948 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
949 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
952 * Disable interrupts, DMA, and PCMCIA buffers
953 * (isolate the interface) and assert RESET signal
955 debug ("Disable PCMCIA buffers and assert RESET\n");
957 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
958 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
959 PCMCIA_PGCRX(_slot_) = reg;
963 * Make sure there is a card in the slot, then configure the interface.
966 debug ("[%d] %s: PIPR(%p)=0x%x\n",
967 __LINE__,__FUNCTION__,
968 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
969 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
970 printf (" No Card found\n");
977 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
978 reg = pcmp->pcmc_pipr;
979 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
981 (reg&PCMCIA_VS1(slot))?"n":"ff",
982 (reg&PCMCIA_VS2(slot))?"n":"ff");
983 if ((reg & mask) == mask) {
984 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
985 puts (" 5.0V card found: ");
987 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
988 puts (" 3.3V card found: ");
992 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
993 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
994 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
998 debug ("Enable PCMCIA buffers and stop RESET\n");
999 reg = PCMCIA_PGCRX(_slot_);
1000 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1001 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1002 PCMCIA_PGCRX(_slot_) = reg;
1004 udelay(250000); /* some cards need >150 ms to come up :-( */
1006 debug ("# hardware_enable done\n");
1012 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1013 static int hardware_disable(int slot)
1015 volatile immap_t *immap;
1016 volatile pcmconf8xx_t *pcmp;
1020 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1022 immap = (immap_t *)CFG_IMMR;
1023 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1025 /* remove all power, put output in high impedance state */
1026 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1027 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1028 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1030 /* Configure PCMCIA General Control Register */
1031 debug ("Disable PCMCIA buffers and assert RESET\n");
1033 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1034 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1035 PCMCIA_PGCRX(_slot_) = reg;
1037 /* Switch off PCMCIA port in PIC register 0x60 */
1038 reg = pic_read (0x60);
1039 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1042 pic_write (0x60, reg);
1044 reg = pic_read (0x60);
1045 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
1051 #endif /* CFG_CMD_PCMCIA */
1054 static int voltage_set(int slot, int vcc, int vpp)
1056 volatile immap_t *immap;
1057 volatile pcmconf8xx_t *pcmp;
1061 debug ("voltage_set: "
1063 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1064 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1066 immap = (immap_t *)CFG_IMMR;
1067 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1069 * Disable PCMCIA buffers (isolate the interface)
1070 * and assert RESET signal
1072 debug ("Disable PCMCIA buffers and assert RESET\n");
1073 reg = PCMCIA_PGCRX(_slot_);
1074 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1075 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1076 PCMCIA_PGCRX(_slot_) = reg;
1080 * Turn off all power (switch to high impedance)
1082 debug ("PCMCIA power OFF\n");
1083 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
1084 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
1085 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1090 case 33: val = MAX1604_VCC_35; break;
1095 /* Checking supported voltages */
1097 debug ("PIPR: 0x%x --> %s\n",
1099 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1101 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
1103 debug ("PCMCIA powered at %sV\n",
1104 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
1106 debug ("PCMCIA powered down\n");
1110 debug ("Enable PCMCIA buffers and stop RESET\n");
1111 reg = PCMCIA_PGCRX(_slot_);
1112 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1113 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1114 PCMCIA_PGCRX(_slot_) = reg;
1117 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1124 /* -------------------------------------------------------------------- */
1125 /* GTH board by Corelatus AB */
1126 /* -------------------------------------------------------------------- */
1127 #if defined(CONFIG_GTH)
1129 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
1131 static int voltage_set (int slot, int vcc, int vpp)
1136 static int hardware_enable (int slot)
1138 volatile immap_t *immap;
1139 volatile cpm8xx_t *cp;
1140 volatile pcmconf8xx_t *pcmp;
1141 volatile sysconf8xx_t *sysp;
1144 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
1146 immap = (immap_t *) CFG_IMMR;
1147 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1148 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1149 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1151 /* clear interrupt state, and disable interrupts */
1152 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1153 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1156 * Disable interrupts, DMA, and PCMCIA buffers
1157 * (isolate the interface) and assert RESET signal
1159 debug ("Disable PCMCIA buffers and assert RESET\n");
1161 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1162 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1163 PCMCIA_PGCRX (_slot_) = reg;
1167 * Make sure there is a card in the slot,
1168 * then configure the interface.
1171 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1172 __LINE__, __FUNCTION__,
1173 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1174 if (pcmp->pcmc_pipr & 0x98000000) {
1175 printf (" No Card found\n");
1179 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1180 reg = pcmp->pcmc_pipr;
1181 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1183 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1184 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1186 debug ("Enable PCMCIA buffers and stop RESET\n");
1187 reg = PCMCIA_PGCRX (_slot_);
1188 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1189 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1190 PCMCIA_PGCRX (_slot_) = reg;
1192 udelay (250000); /* some cards need >150 ms to come up :-( */
1194 debug ("# hardware_enable done\n");
1198 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1199 static int hardware_disable(int slot)
1201 return 0; /* No hardware to disable */
1203 #endif /* CFG_CMD_PCMCIA */
1204 #endif /* CONFIG_GTH */
1206 /* -------------------------------------------------------------------- */
1207 /* ICU862 Boards by Cambridge Broadband Ltd. */
1208 /* -------------------------------------------------------------------- */
1210 #if defined(CONFIG_ICU862)
1212 #define PCMCIA_BOARD_MSG "ICU862"
1214 static void cfg_port_B (void);
1216 static int hardware_enable(int slot)
1218 volatile immap_t *immap;
1219 volatile cpm8xx_t *cp;
1220 volatile pcmconf8xx_t *pcmp;
1221 volatile sysconf8xx_t *sysp;
1222 uint reg, pipr, mask;
1225 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1229 immap = (immap_t *)CFG_IMMR;
1230 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1231 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1232 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1234 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1238 * Configure SIUMCR to enable PCMCIA port B
1239 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1241 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1243 /* clear interrupt state, and disable interrupts */
1244 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1245 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1248 * Disable interrupts, DMA, and PCMCIA buffers
1249 * (isolate the interface) and assert RESET signal
1251 debug ("Disable PCMCIA buffers and assert RESET\n");
1253 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1254 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1255 PCMCIA_PGCRX(_slot_) = reg;
1259 * Make sure there is a card in the slot, then configure the interface.
1262 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1263 __LINE__,__FUNCTION__,
1264 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1265 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1266 printf (" No Card found\n");
1271 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1273 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1274 pipr = pcmp->pcmc_pipr;
1275 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1277 (reg&PCMCIA_VS1(slot))?"n":"ff",
1278 (reg&PCMCIA_VS2(slot))?"n":"ff");
1281 if ((pipr & mask) == mask) {
1282 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1283 TPS2205_VCC3); /* 3V off */
1284 reg &= ~(TPS2205_VCC5); /* 5V on */
1285 puts (" 5.0V card found: ");
1287 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1288 TPS2205_VCC5); /* 5V off */
1289 reg &= ~(TPS2205_VCC3); /* 3V on */
1290 puts (" 3.3V card found: ");
1293 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1295 (reg & TPS2205_VCC3) ? "off" : "on",
1296 (reg & TPS2205_VCC5) ? "off" : "on",
1297 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1298 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1302 /* Wait 500 ms; use this to check for over-current */
1303 for (i=0; i<5000; ++i) {
1304 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1305 printf (" *** Overcurrent - Safety shutdown ***\n");
1306 cp->cp_pbdat &= ~(TPS2205_SHDN);
1312 debug ("Enable PCMCIA buffers and stop RESET\n");
1313 reg = PCMCIA_PGCRX(_slot_);
1314 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1315 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1316 PCMCIA_PGCRX(_slot_) = reg;
1318 udelay(250000); /* some cards need >150 ms to come up :-( */
1320 debug ("# hardware_enable done\n");
1326 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1327 static int hardware_disable(int slot)
1329 volatile immap_t *immap;
1330 volatile cpm8xx_t *cp;
1331 volatile pcmconf8xx_t *pcmp;
1334 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1336 immap = (immap_t *)CFG_IMMR;
1337 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1338 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1341 cp->cp_pbdat &= ~(TPS2205_SHDN);
1343 /* Configure PCMCIA General Control Register */
1344 debug ("Disable PCMCIA buffers and assert RESET\n");
1346 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1347 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1348 PCMCIA_PGCRX(_slot_) = reg;
1354 #endif /* CFG_CMD_PCMCIA */
1357 static int voltage_set(int slot, int vcc, int vpp)
1359 volatile immap_t *immap;
1360 volatile cpm8xx_t *cp;
1361 volatile pcmconf8xx_t *pcmp;
1364 debug ("voltage_set: "
1366 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1367 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1369 immap = (immap_t *)CFG_IMMR;
1370 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1371 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1373 * Disable PCMCIA buffers (isolate the interface)
1374 * and assert RESET signal
1376 debug ("Disable PCMCIA buffers and assert RESET\n");
1377 reg = PCMCIA_PGCRX(_slot_);
1378 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1379 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1380 PCMCIA_PGCRX(_slot_) = reg;
1384 * Configure Port C pins for
1385 * 5 Volts Enable and 3 Volts enable,
1386 * Turn all power pins to Hi-Z
1388 debug ("PCMCIA power OFF\n");
1389 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1394 case 0: break; /* Switch off */
1395 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1396 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1400 /* Checking supported voltages */
1402 debug ("PIPR: 0x%x --> %s\n",
1404 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1412 if ((reg & TPS2205_VCC3) == 0) {
1414 } else if ((reg & TPS2205_VCC5) == 0) {
1419 printf ("PCMCIA powered %s\n", s);
1424 debug ("Enable PCMCIA buffers and stop RESET\n");
1425 reg = PCMCIA_PGCRX(_slot_);
1426 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1427 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1428 PCMCIA_PGCRX(_slot_) = reg;
1431 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1436 static void cfg_port_B (void)
1438 volatile immap_t *immap;
1439 volatile cpm8xx_t *cp;
1442 immap = (immap_t *)CFG_IMMR;
1443 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1446 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1448 * Switch off all voltages, assert shutdown
1451 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1452 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1453 TPS2205_SHDN); /* enable switch */
1456 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1458 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1459 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1461 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1462 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1468 /* -------------------------------------------------------------------- */
1469 /* C2MON Boards by TTTech Computertechnik AG */
1470 /* -------------------------------------------------------------------- */
1472 #if defined(CONFIG_C2MON)
1474 #define PCMCIA_BOARD_MSG "C2MON"
1476 static void cfg_ports (void);
1478 static int hardware_enable(int slot)
1480 volatile immap_t *immap;
1481 volatile cpm8xx_t *cp;
1482 volatile pcmconf8xx_t *pcmp;
1483 volatile sysconf8xx_t *sysp;
1484 uint reg, pipr, mask;
1488 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1492 immap = (immap_t *)CFG_IMMR;
1493 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1494 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1495 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1497 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1501 * Configure SIUMCR to enable PCMCIA port B
1502 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1504 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1506 /* clear interrupt state, and disable interrupts */
1507 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1508 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1511 * Disable interrupts, DMA, and PCMCIA buffers
1512 * (isolate the interface) and assert RESET signal
1514 debug ("Disable PCMCIA buffers and assert RESET\n");
1516 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1517 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1518 PCMCIA_PGCRX(_slot_) = reg;
1522 * Make sure there is a card in the slot, then configure the interface.
1525 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1526 __LINE__,__FUNCTION__,
1527 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1528 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1529 printf (" No Card found\n");
1534 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1536 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1537 pipr = pcmp->pcmc_pipr;
1538 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1540 (reg&PCMCIA_VS1(slot))?"n":"ff",
1541 (reg&PCMCIA_VS2(slot))?"n":"ff");
1543 sreg = immap->im_ioport.iop_pcdat;
1544 if ((pipr & mask) == mask) {
1545 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1546 TPS2211_VCCD1); /* 5V on */
1547 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1548 puts (" 5.0V card found: ");
1550 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1551 TPS2211_VCCD0); /* 3V on */
1552 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1553 puts (" 3.3V card found: ");
1556 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1558 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1559 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1562 immap->im_ioport.iop_pcdat = sreg;
1564 /* Wait 500 ms; use this to check for over-current */
1565 for (i=0; i<5000; ++i) {
1566 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1567 printf (" *** Overcurrent - Safety shutdown ***\n");
1568 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1574 debug ("Enable PCMCIA buffers and stop RESET\n");
1575 reg = PCMCIA_PGCRX(_slot_);
1576 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1577 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1578 PCMCIA_PGCRX(_slot_) = reg;
1580 udelay(250000); /* some cards need >150 ms to come up :-( */
1582 debug ("# hardware_enable done\n");
1588 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1589 static int hardware_disable(int slot)
1591 volatile immap_t *immap;
1592 volatile cpm8xx_t *cp;
1593 volatile pcmconf8xx_t *pcmp;
1596 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1598 immap = (immap_t *)CFG_IMMR;
1599 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1601 /* Configure PCMCIA General Control Register */
1602 debug ("Disable PCMCIA buffers and assert RESET\n");
1604 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1605 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1606 PCMCIA_PGCRX(_slot_) = reg;
1608 /* ALl voltages off / Hi-Z */
1609 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1610 TPS2211_VCCD0 | TPS2211_VCCD1 );
1616 #endif /* CFG_CMD_PCMCIA */
1619 static int voltage_set(int slot, int vcc, int vpp)
1621 volatile immap_t *immap;
1622 volatile cpm8xx_t *cp;
1623 volatile pcmconf8xx_t *pcmp;
1627 debug ("voltage_set: "
1629 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1630 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1632 immap = (immap_t *)CFG_IMMR;
1633 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1634 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1636 * Disable PCMCIA buffers (isolate the interface)
1637 * and assert RESET signal
1639 debug ("Disable PCMCIA buffers and assert RESET\n");
1640 reg = PCMCIA_PGCRX(_slot_);
1641 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1642 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1643 PCMCIA_PGCRX(_slot_) = reg;
1647 * Configure Port C pins for
1648 * 5 Volts Enable and 3 Volts enable,
1649 * Turn all power pins to Hi-Z
1651 debug ("PCMCIA power OFF\n");
1652 cfg_ports (); /* Enables switch, but all in Hi-Z */
1654 sreg = immap->im_ioport.iop_pcdat;
1655 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1658 case 0: break; /* Switch off */
1659 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1660 sreg &= ~TPS2211_VCCD1;
1662 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1663 sreg |= TPS2211_VCCD1;
1668 /* Checking supported voltages */
1670 debug ("PIPR: 0x%x --> %s\n",
1672 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1674 immap->im_ioport.iop_pcdat = sreg;
1680 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1682 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1687 printf ("PCMCIA powered %s\n", s);
1692 debug ("Enable PCMCIA buffers and stop RESET\n");
1693 reg = PCMCIA_PGCRX(_slot_);
1694 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1695 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1696 PCMCIA_PGCRX(_slot_) = reg;
1699 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1704 static void cfg_ports (void)
1706 volatile immap_t *immap;
1707 volatile cpm8xx_t *cp;
1710 immap = (immap_t *)CFG_IMMR;
1711 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1714 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1716 * Switch off all voltages, assert shutdown
1718 sreg = immap->im_ioport.iop_pcdat;
1719 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1720 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1721 immap->im_ioport.iop_pcdat = sreg;
1723 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1724 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1726 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1727 immap->im_ioport.iop_pcpar,
1728 immap->im_ioport.iop_pcdir,
1729 immap->im_ioport.iop_pcdat);
1732 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1734 * Over-Current Input only
1736 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1737 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1739 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1740 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1745 /* -------------------------------------------------------------------- */
1746 /* MBX board from Morotola */
1747 /* -------------------------------------------------------------------- */
1749 #if defined( CONFIG_MBX )
1750 #include <../board/mbx8xx/csr.h>
1752 /* A lot of this has been taken from the RPX code in this file it works from me.
1753 I have added the voltage selection for the MBX board. */
1755 /* MBX voltage bit in control register #2 */
1756 #define CR2_VPP12 ((uchar)0x10)
1757 #define CR2_VPPVDD ((uchar)0x20)
1758 #define CR2_VDD5 ((uchar)0x40)
1759 #define CR2_VDD3 ((uchar)0x80)
1761 #define PCMCIA_BOARD_MSG "MBX860"
1763 static int voltage_set (int slot, int vcc, int vpp)
1767 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1768 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1801 /* first, turn off all power */
1802 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1804 /* enable new powersettings */
1806 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1811 static int hardware_enable (int slot)
1813 volatile immap_t *immap;
1814 volatile cpm8xx_t *cp;
1815 volatile pcmconf8xx_t *pcmp;
1816 volatile sysconf8xx_t *sysp;
1819 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1824 immap = (immap_t *) CFG_IMMR;
1825 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1826 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1827 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1829 /* clear interrupt state, and disable interrupts */
1830 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1831 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1834 * Disable interrupts, DMA, and PCMCIA buffers
1835 * (isolate the interface) and assert RESET signal
1837 debug ("Disable PCMCIA buffers and assert RESET\n");
1839 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1840 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1841 PCMCIA_PGCRX (_slot_) = reg;
1844 /* remove all power */
1845 voltage_set (slot, 0, 0);
1847 * Make sure there is a card in the slot, then configure the interface.
1850 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1851 __LINE__,__FUNCTION__,
1852 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1853 #ifndef CONFIG_HMI10
1854 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1856 if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
1857 #endif /* CONFIG_HMI10 */
1858 printf (" No Card found\n");
1865 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1866 reg = pcmp->pcmc_pipr;
1867 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1868 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1869 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1871 if ((reg & mask) == mask) {
1872 voltage_set (_slot_, 50, 0);
1873 printf (" 5.0V card found: ");
1875 voltage_set (_slot_, 33, 0);
1876 printf (" 3.3V card found: ");
1879 debug ("Enable PCMCIA buffers and stop RESET\n");
1880 reg = PCMCIA_PGCRX (_slot_);
1881 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1882 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1883 PCMCIA_PGCRX (_slot_) = reg;
1885 udelay (250000); /* some cards need >150 ms to come up :-( */
1887 debug ("# hardware_enable done\n");
1892 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1893 static int hardware_disable (int slot)
1895 return 0; /* No hardware to disable */
1897 #endif /* CFG_CMD_PCMCIA */
1898 #endif /* CONFIG_MBX */
1899 /* -------------------------------------------------------------------- */
1901 /* -------------------------------------------------------------------- */
1903 #if defined(CONFIG_R360MPI)
1905 #define PCMCIA_BOARD_MSG "R360MPI"
1908 static int hardware_enable(int slot)
1910 volatile immap_t *immap;
1911 volatile cpm8xx_t *cp;
1912 volatile pcmconf8xx_t *pcmp;
1913 volatile sysconf8xx_t *sysp;
1916 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1920 immap = (immap_t *)CFG_IMMR;
1921 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1922 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1923 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1926 * Configure SIUMCR to enable PCMCIA port B
1927 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1929 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1931 /* clear interrupt state, and disable interrupts */
1932 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1933 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1936 * Disable interrupts, DMA, and PCMCIA buffers
1937 * (isolate the interface) and assert RESET signal
1939 debug ("Disable PCMCIA buffers and assert RESET\n");
1941 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1942 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1943 PCMCIA_PGCRX(_slot_) = reg;
1947 * Configure Ports A, B & C pins for
1948 * 5 Volts Enable and 3 Volts enable
1950 immap->im_ioport.iop_pcpar &= ~(0x0400);
1951 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1952 immap->im_ioport.iop_pcdir |= 0x0400;*/
1954 immap->im_ioport.iop_papar &= ~(0x0200);/*
1955 immap->im_ioport.iop_padir |= 0x0200;*/
1957 immap->im_ioport.iop_pbpar &= ~(0xC000);
1958 immap->im_ioport.iop_pbdir &= ~(0xC000);
1960 /* remove all power */
1962 immap->im_ioport.iop_pcdat |= 0x0400;
1963 immap->im_ioport.iop_padat |= 0x0200;
1966 * Make sure there is a card in the slot, then configure the interface.
1969 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1970 __LINE__,__FUNCTION__,
1971 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1972 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1973 printf (" No Card found\n");
1980 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1981 reg = pcmp->pcmc_pipr;
1982 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1984 (reg&PCMCIA_VS1(slot))?"n":"ff",
1985 (reg&PCMCIA_VS2(slot))?"n":"ff");
1986 if ((reg & mask) == mask) {
1987 immap->im_ioport.iop_pcdat &= ~(0x4000);
1988 puts (" 5.0V card found: ");
1990 immap->im_ioport.iop_padat &= ~(0x0002);
1991 puts (" 3.3V card found: ");
1993 immap->im_ioport.iop_pcdir |= 0x0400;
1994 immap->im_ioport.iop_padir |= 0x0200;
1996 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
1997 cp->cp_pbdir &= ~(0x0020 | 0x0010);
1998 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2001 debug ("Enable PCMCIA buffers and stop RESET\n");
2002 reg = PCMCIA_PGCRX(_slot_);
2003 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2004 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2005 PCMCIA_PGCRX(_slot_) = reg;
2007 udelay(250000); /* some cards need >150 ms to come up :-( */
2009 debug ("# hardware_enable done\n");
2015 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2016 static int hardware_disable(int slot)
2018 volatile immap_t *immap;
2019 volatile pcmconf8xx_t *pcmp;
2022 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2024 immap = (immap_t *)CFG_IMMR;
2025 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2027 /* remove all power */
2028 immap->im_ioport.iop_pcdat |= 0x0400;
2029 immap->im_ioport.iop_padat |= 0x0200;
2031 /* Configure PCMCIA General Control Register */
2032 debug ("Disable PCMCIA buffers and assert RESET\n");
2034 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2035 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2036 PCMCIA_PGCRX(_slot_) = reg;
2042 #endif /* CFG_CMD_PCMCIA */
2045 static int voltage_set(int slot, int vcc, int vpp)
2047 volatile immap_t *immap;
2048 volatile pcmconf8xx_t *pcmp;
2051 debug ("voltage_set: "
2053 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2054 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2056 immap = (immap_t *)CFG_IMMR;
2057 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2059 * Disable PCMCIA buffers (isolate the interface)
2060 * and assert RESET signal
2062 debug ("Disable PCMCIA buffers and assert RESET\n");
2063 reg = PCMCIA_PGCRX(_slot_);
2064 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2065 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2066 PCMCIA_PGCRX(_slot_) = reg;
2070 * Configure Ports A & C pins for
2071 * 5 Volts Enable and 3 Volts enable,
2072 * Turn off all power
2074 debug ("PCMCIA power OFF\n");
2075 immap->im_ioport.iop_pcpar &= ~(0x0400);
2076 immap->im_ioport.iop_pcso &= ~(0x0400);/*
2077 immap->im_ioport.iop_pcdir |= 0x0400;*/
2079 immap->im_ioport.iop_papar &= ~(0x0200);/*
2080 immap->im_ioport.iop_padir |= 0x0200;*/
2082 immap->im_ioport.iop_pcdat |= 0x0400;
2083 immap->im_ioport.iop_padat |= 0x0200;
2088 case 33: reg |= 0x0200; break;
2089 case 50: reg |= 0x0400; break;
2093 /* Checking supported voltages */
2095 debug ("PIPR: 0x%x --> %s\n",
2097 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
2100 immap->im_ioport.iop_pcdat &= !reg;
2102 immap->im_ioport.iop_padat &= !reg;
2103 immap->im_ioport.iop_pcdir |= 0x0200;
2104 immap->im_ioport.iop_padir |= 0x0400;
2106 debug ("PCMCIA powered at %sV\n",
2107 (reg&0x0400) ? "5.0" : "3.3");
2109 debug ("PCMCIA powered down\n");
2113 debug ("Enable PCMCIA buffers and stop RESET\n");
2114 reg = PCMCIA_PGCRX(_slot_);
2115 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2116 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2117 PCMCIA_PGCRX(_slot_) = reg;
2120 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2125 #endif /* R360MPI */
2127 /* -------------------------------------------------------------------- */
2129 /* -------------------------------------------------------------------- */
2130 #if defined(CONFIG_KUP4K)
2132 #define PCMCIA_BOARD_MSG "KUP4K"
2134 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
2136 static int hardware_enable(int slot)
2138 volatile immap_t *immap;
2139 volatile cpm8xx_t *cp;
2140 volatile pcmconf8xx_t *pcmp;
2141 volatile sysconf8xx_t *sysp;
2144 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2148 immap = (immap_t *)CFG_IMMR;
2149 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2150 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2151 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2154 * Configure SIUMCR to enable PCMCIA port B
2155 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2157 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2159 /* clear interrupt state, and disable interrupts */
2160 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2161 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2164 * Disable interrupts, DMA, and PCMCIA buffers
2165 * (isolate the interface) and assert RESET signal
2167 debug ("Disable PCMCIA buffers and assert RESET\n");
2169 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2170 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2171 PCMCIA_PGCRX(slot) = reg;
2175 * Configure Port B pins for
2178 if (slot) { /* Slot A is built-in */
2179 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2180 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2181 /* remove all power */
2182 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2185 * Make sure there is a card in the slot, then configure the interface.
2188 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2189 __LINE__,__FUNCTION__,
2190 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2191 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2192 printf (" No Card found\n");
2199 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2200 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2201 reg = pcmp->pcmc_pipr;
2202 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2204 (reg&PCMCIA_VS1(slot))?"n":"ff",
2205 (reg&PCMCIA_VS2(slot))?"n":"ff");
2206 if ((reg & mask) == mask) {
2207 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2210 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2211 puts (" 3.3V card found: ");
2214 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2215 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2216 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2219 debug ("Enable PCMCIA buffers and stop RESET\n");
2220 reg = PCMCIA_PGCRX(slot);
2221 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2222 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2223 PCMCIA_PGCRX(slot) = reg;
2225 udelay(250000); /* some cards need >150 ms to come up :-( */
2227 debug ("# hardware_enable done\n");
2233 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2234 static int hardware_disable(int slot)
2236 volatile immap_t *immap;
2237 volatile cpm8xx_t *cp;
2238 volatile pcmconf8xx_t *pcmp;
2241 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2243 immap = (immap_t *)CFG_IMMR;
2244 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2245 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2247 /* remove all power */
2249 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2251 /* Configure PCMCIA General Control Register */
2252 debug ("Disable PCMCIA buffers and assert RESET\n");
2254 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2255 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2256 PCMCIA_PGCRX(slot) = reg;
2262 #endif /* CFG_CMD_PCMCIA */
2265 static int voltage_set(int slot, int vcc, int vpp)
2267 volatile immap_t *immap;
2268 volatile cpm8xx_t *cp;
2269 volatile pcmconf8xx_t *pcmp;
2272 debug ("voltage_set: " \
2274 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2275 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2277 if (!slot) /* Slot A is not configurable */
2280 immap = (immap_t *)CFG_IMMR;
2281 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2282 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2285 * Disable PCMCIA buffers (isolate the interface)
2286 * and assert RESET signal
2288 debug ("Disable PCMCIA buffers and assert RESET\n");
2289 reg = PCMCIA_PGCRX(slot);
2290 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2291 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2292 PCMCIA_PGCRX(slot) = reg;
2295 debug ("PCMCIA power OFF\n");
2297 * Configure Port B pins for
2300 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2301 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2302 /* remove all power */
2303 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2308 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2309 debug ("PCMCIA powered at 3.3V\n");
2312 debug ("PCMCIA: 5Volt vcc not supported\n");
2315 puts("PCMCIA: vcc not supported");
2319 /* Checking supported voltages */
2321 debug ("PIPR: 0x%x --> %s\n",
2323 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2324 ? "only 5 V --> NOT SUPPORTED"
2328 debug ("Enable PCMCIA buffers and stop RESET\n");
2329 reg = PCMCIA_PGCRX(slot);
2330 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2331 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2332 PCMCIA_PGCRX(slot) = reg;
2335 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2343 /* -------------------------------------------------------------------- */
2344 /* End of Board Specific Stuff */
2345 /* -------------------------------------------------------------------- */
2348 /* -------------------------------------------------------------------- */
2349 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2350 /* -------------------------------------------------------------------- */
2353 * Search this table to see if the windowsize is
2357 #define M8XX_SIZES_NO 32
2359 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2360 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2361 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2362 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2363 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2365 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2366 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2367 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2368 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2371 /* -------------------------------------------------------------------- */
2373 #ifndef CONFIG_I82365
2375 static u_int m8xx_get_graycode(u_int size)
2379 for (k = 0; k < M8XX_SIZES_NO; k++) {
2380 if(m8xx_size_to_gray[k] == size)
2384 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2390 #endif /* CONFIG_I82365 */
2392 /* -------------------------------------------------------------------- */
2395 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2397 u_int reg, clocks, psst, psl, psht;
2402 * We get called with IO maps setup to 0ns
2403 * if not specified by the user.
2404 * They should be 255ns.
2410 ns = 100; /* fast memory if 0 */
2414 * In PSST, PSL, PSHT fields we tell the controller
2415 * timing parameters in CLKOUT clock cycles.
2416 * CLKOUT is the same as GCLK2_50.
2419 /* how we want to adjust the timing - in percent */
2421 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2423 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2424 clocks = (clocks * ADJ) / (100*1000);
2426 if(clocks >= PCMCIA_BMT_LIMIT) {
2427 DEBUG(0, "Max access time limit reached\n");
2428 clocks = PCMCIA_BMT_LIMIT-1;
2431 psst = clocks / 7; /* setup time */
2432 psht = clocks / 7; /* hold time */
2433 psl = (clocks * 5) / 7; /* strobe length */
2435 psst += clocks - (psst + psht + psl);
2445 /* -------------------------------------------------------------------- */
2447 #ifdef CONFIG_IDE_8xx_PCCARD
2448 static void print_funcid (int func)
2452 case CISTPL_FUNCID_MULTI:
2453 puts (" Multi-Function");
2455 case CISTPL_FUNCID_MEMORY:
2458 case CISTPL_FUNCID_SERIAL:
2459 puts (" Serial Port");
2461 case CISTPL_FUNCID_PARALLEL:
2462 puts (" Parallel Port");
2464 case CISTPL_FUNCID_FIXED:
2465 puts (" Fixed Disk");
2467 case CISTPL_FUNCID_VIDEO:
2468 puts (" Video Adapter");
2470 case CISTPL_FUNCID_NETWORK:
2471 puts (" Network Adapter");
2473 case CISTPL_FUNCID_AIMS:
2474 puts (" AIMS Card");
2476 case CISTPL_FUNCID_SCSI:
2477 puts (" SCSI Adapter");
2485 #endif /* CONFIG_IDE_8xx_PCCARD */
2487 /* -------------------------------------------------------------------- */
2489 #ifdef CONFIG_IDE_8xx_PCCARD
2490 static void print_fixed (volatile uchar *p)
2498 case CISTPL_FUNCE_IDE_IFACE:
2499 { uchar iface = *(p+2);
2501 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2502 puts (" interface ");
2505 case CISTPL_FUNCE_IDE_MASTER:
2506 case CISTPL_FUNCE_IDE_SLAVE:
2507 { uchar f1 = *(p+2);
2510 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2512 if (f1 & CISTPL_IDE_UNIQUE)
2515 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2517 if (f2 & CISTPL_IDE_HAS_SLEEP)
2520 if (f2 & CISTPL_IDE_HAS_STANDBY)
2521 puts (" [standby]");
2523 if (f2 & CISTPL_IDE_HAS_IDLE)
2526 if (f2 & CISTPL_IDE_LOW_POWER)
2527 puts (" [low power]");
2529 if (f2 & CISTPL_IDE_REG_INHIBIT)
2530 puts (" [reg inhibit]");
2532 if (f2 & CISTPL_IDE_HAS_INDEX)
2535 if (f2 & CISTPL_IDE_IOIS16)
2543 #endif /* CONFIG_IDE_8xx_PCCARD */
2545 /* -------------------------------------------------------------------- */
2547 #ifdef CONFIG_IDE_8xx_PCCARD
2549 #define MAX_IDENT_CHARS 64
2550 #define MAX_IDENT_FIELDS 4
2552 static uchar *known_cards[] = {
2557 static int identify (volatile uchar *p)
2559 uchar id_str[MAX_IDENT_CHARS];
2566 return (0); /* Don't know */
2571 for (i=0; i<=4 && !done; ++i, p+=2) {
2572 while ((data = *p) != '\0') {
2578 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2588 while (--t > id_str) {
2597 for (card=known_cards; *card; ++card) {
2598 debug ("## Compare against \"%s\"\n", *card);
2599 if (strcmp(*card, id_str) == 0) { /* found! */
2600 debug ("## CARD FOUND ##\n");
2605 return (0); /* don't know */
2607 #endif /* CONFIG_IDE_8xx_PCCARD */
2609 /* -------------------------------------------------------------------- */
2611 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
2613 /**************************************************/
2615 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2617 pinit, 2, 1, do_pinit,
2618 "pinit - PCMCIA sub-system\n",
2619 "on - power on PCMCIA socket\n"
2620 "pinit off - power off PCMCIA socket\n"