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 #include <cmd_pcmcia.h>
61 #if defined(CONFIG_IDE_8xx_PCCARD) && defined(CONFIG_8xx)
64 #if defined(CONFIG_LWMON)
68 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
69 ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD))
73 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
74 static int pcmcia_off (void);
75 static int hardware_disable(int slot);
77 static int hardware_enable (int slot);
78 static int voltage_set(int slot, int vcc, int vpp);
79 #ifdef CONFIG_IDE_8xx_PCCARD
80 static void print_funcid (int func);
81 static void print_fixed (volatile uchar *p);
82 static int identify (volatile uchar *p);
83 static int check_ide_device (int slot);
84 #endif /* CONFIG_IDE_8xx_PCCARD */
86 static u_int m8xx_get_graycode(u_int size);
88 static u_int m8xx_get_speed(u_int ns, u_int is_io);
91 /* ------------------------------------------------------------------------- */
93 /* look up table for pgcrx registers */
95 static u_int *pcmcia_pgcrx[2] = {
96 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
97 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
100 #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
102 const char *indent = "\t ";
104 /* ------------------------------------------------------------------------- */
106 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
108 int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
113 printf ("Usage: pinit {on | off}\n");
116 if (strcmp(argv[1],"on") == 0) {
117 rcode = pcmcia_on ();
118 } else if (strcmp(argv[1],"off") == 0) {
119 rcode = pcmcia_off ();
121 printf ("Usage: pinit {on | off}\n");
127 #endif /* CFG_CMD_PCMCIA */
129 /* ------------------------------------------------------------------------- */
131 #if defined(CONFIG_LWMON)
132 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
134 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
145 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
147 /* intialize the fixed memory windows */
148 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
149 base = CFG_PCMCIA_MEM_ADDR;
151 if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
152 printf ("Cannot set window size to 0x%08x\n",
153 CFG_PCMCIA_MEM_SIZE);
157 slotbit = PCMCIA_SLOT_x;
158 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
161 #if (PCMCIA_SOCKETS_NO == 2)
162 if (i == 4) /* Another slot starting from win 4 */
163 slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
166 #ifdef CONFIG_IDE_8xx_PCCARD
168 case 0: { /* map attribute memory */
169 win->or = ( PCMCIA_BSIZE_64M
174 | CFG_PCMCIA_TIMING );
178 case 1: { /* map I/O window for data reg */
179 win->or = ( PCMCIA_BSIZE_1K
184 | CFG_PCMCIA_TIMING );
188 case 2: { /* map I/O window for command/ctrl reg block */
189 win->or = ( PCMCIA_BSIZE_1K
194 | CFG_PCMCIA_TIMING );
197 #endif /* CONFIG_IDE_8xx_PCCARD */
198 default: /* set to not valid */
203 debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
204 i, win->br, win->or);
205 base += CFG_PCMCIA_MEM_SIZE;
209 for (i = 0, rc = 0, slot = _slot_; i < PCMCIA_SOCKETS_NO; i++, slot = !slot) {
210 /* turn off voltage */
211 if ((rc = voltage_set(slot, 0, 0)))
214 /* Enable external hardware */
215 if ((rc = hardware_enable(slot)))
218 #ifdef CONFIG_IDE_8xx_PCCARD
219 if ((rc = check_ide_device(i)))
226 /* ------------------------------------------------------------------------- */
228 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
230 static int pcmcia_off (void)
235 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
237 /* clear interrupt state, and disable interrupts */
238 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
239 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
241 /* turn off interrupt and disable CxOE */
242 PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
244 /* turn off memory windows */
245 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
247 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
248 /* disable memory window */
253 /* turn off voltage */
254 voltage_set(_slot_, 0, 0);
256 /* disable external hardware */
257 printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
258 hardware_disable(_slot_);
262 #endif /* CFG_CMD_PCMCIA */
264 /* ------------------------------------------------------------------------- */
266 #ifdef CONFIG_IDE_8xx_PCCARD
268 #define MAX_TUPEL_SZ 512
269 #define MAX_FEATURES 4
271 static int check_ide_device (int slot)
273 volatile uchar *ident = NULL;
274 volatile uchar *feature_p[MAX_FEATURES];
275 volatile uchar *p, *start, *addr;
279 ushort config_base = 0;
283 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
284 CFG_PCMCIA_MEM_SIZE * (slot * 4));
285 debug ("PCMCIA MEM: %08X\n", addr);
287 start = p = (volatile uchar *) addr;
289 while ((p - start) < MAX_TUPEL_SZ) {
293 if (code == 0xFF) { /* End of chain */
298 #if defined(DEBUG) && (DEBUG > 1)
299 { volatile uchar *q = p;
300 printf ("\nTuple code %02x length %d\n\tData:",
303 for (i = 0; i < len; ++i) {
304 printf (" %02x", *q);
314 /* Fix for broken SanDisk which may have 0x80 bit set */
318 if (n_features < MAX_FEATURES)
319 feature_p[n_features++] = p;
322 config_base = (*(p+6) << 8) + (*(p+4));
323 debug ("\n## Config_base = %04x ###\n", config_base);
330 found = identify (ident);
332 if (func_id != ((uchar)~0)) {
333 print_funcid (func_id);
335 if (func_id == CISTPL_FUNCID_FIXED)
338 return (1); /* no disk drive */
341 for (i=0; i<n_features; ++i) {
342 print_fixed (feature_p[i]);
346 printf ("unknown card type\n");
350 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
351 *((uchar *)(addr + config_base)) = 1;
355 #endif /* CONFIG_IDE_8xx_PCCARD */
357 /* ------------------------------------------------------------------------- */
360 /* ---------------------------------------------------------------------------- */
361 /* board specific stuff: */
362 /* voltage_set(), hardware_enable() and hardware_disable() */
363 /* ---------------------------------------------------------------------------- */
365 /* ---------------------------------------------------------------------------- */
366 /* RPX Boards from Embedded Planet */
367 /* ---------------------------------------------------------------------------- */
369 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
371 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
372 * SYPCR is write once only, therefore must the slowest memory be faster
373 * than the bus monitor or we will get a machine check due to the bus timeout.
376 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
378 #undef PCMCIA_BMT_LIMIT
379 #define PCMCIA_BMT_LIMIT (6*8)
381 static int voltage_set(int slot, int vcc, int vpp)
387 case 33: reg |= BCSR1_PCVCTL4; break;
388 case 50: reg |= BCSR1_PCVCTL5; break;
397 reg |= BCSR1_PCVCTL6;
402 reg |= BCSR1_PCVCTL7;
409 /* first, turn off all power */
411 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
412 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
414 /* enable new powersettings */
416 *((uint *)RPX_CSR_ADDR) |= reg;
421 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
422 static int hardware_enable (int slot)
424 return 0; /* No hardware to enable */
426 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
427 static int hardware_disable(int slot)
429 return 0; /* No hardware to disable */
431 #endif /* CFG_CMD_PCMCIA */
432 #endif /* CONFIG_RPXCLASSIC */
434 /* ---------------------------------------------------------------------------- */
435 /* (F)ADS Boards from Motorola */
436 /* ---------------------------------------------------------------------------- */
438 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
441 #define PCMCIA_BOARD_MSG "ADS"
442 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
444 #define PCMCIA_BOARD_MSG "FADS"
447 static int voltage_set(int slot, int vcc, int vpp)
452 case 0: reg = 0; break;
453 case 50: reg = 1; break;
454 case 120: reg = 2; break;
459 case 0: reg = 0; break;
461 case 50: reg = BCSR1_PCCVCCON; break;
464 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
465 case 50: reg = BCSR1_PCCVCC1; break;
470 /* first, turn off all power */
473 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
476 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
478 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
480 /* enable new powersettings */
483 *((uint *)BCSR1) &= ~reg;
486 *((uint *)BCSR1) |= reg;
489 *((uint *)BCSR1) |= reg << 20;
494 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
496 static int hardware_enable(int slot)
498 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
502 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
503 static int hardware_disable(int slot)
505 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
508 #endif /* CFG_CMD_PCMCIA */
512 /* ---------------------------------------------------------------------------- */
513 /* TQM8xxL Boards by TQ Components */
514 /* ---------------------------------------------------------------------------- */
516 #if defined(CONFIG_TQM8xxL)
518 #define PCMCIA_BOARD_MSG "TQM8xxL"
521 static int hardware_enable(int slot)
523 volatile immap_t *immap;
524 volatile cpm8xx_t *cp;
525 volatile pcmconf8xx_t *pcmp;
526 volatile sysconf8xx_t *sysp;
529 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
533 immap = (immap_t *)CFG_IMMR;
534 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
535 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
536 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
539 * Configure SIUMCR to enable PCMCIA port B
540 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
542 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
544 /* clear interrupt state, and disable interrupts */
545 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
546 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
548 /* disable interrupts & DMA */
549 PCMCIA_PGCRX(_slot_) = 0;
552 * Disable PCMCIA buffers (isolate the interface)
553 * and assert RESET signal
555 debug ("Disable PCMCIA buffers and assert RESET\n");
556 reg = PCMCIA_PGCRX(_slot_);
557 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
558 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
559 PCMCIA_PGCRX(_slot_) = reg;
563 * Configure Port C pins for
564 * 5 Volts Enable and 3 Volts enable
566 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
567 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
568 /* remove all power */
570 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
573 * Make sure there is a card in the slot, then configure the interface.
576 debug ("[%d] %s: PIPR(%p)=0x%x\n",
577 __LINE__,__FUNCTION__,
578 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
579 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
580 printf (" No Card found\n");
587 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
588 reg = pcmp->pcmc_pipr;
589 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
591 (reg&PCMCIA_VS1(slot))?"n":"ff",
592 (reg&PCMCIA_VS2(slot))?"n":"ff");
593 if ((reg & mask) == mask) {
594 immap->im_ioport.iop_pcdat |= 0x0004;
595 puts (" 5.0V card found: ");
597 immap->im_ioport.iop_pcdat |= 0x0002;
598 puts (" 3.3V card found: ");
600 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
602 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
603 cp->cp_pbdir &= ~(0x0020 | 0x0010);
604 cp->cp_pbpar &= ~(0x0020 | 0x0010);
608 debug ("Enable PCMCIA buffers and stop RESET\n");
609 reg = PCMCIA_PGCRX(_slot_);
610 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
611 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
612 PCMCIA_PGCRX(_slot_) = reg;
614 udelay(250000); /* some cards need >150 ms to come up :-( */
616 debug ("# hardware_enable done\n");
623 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
624 static int hardware_disable(int slot)
626 volatile immap_t *immap;
627 volatile pcmconf8xx_t *pcmp;
630 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
632 immap = (immap_t *)CFG_IMMR;
633 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
635 /* remove all power */
636 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
638 /* Configure PCMCIA General Control Register */
639 PCMCIA_PGCRX(_slot_) = 0;
641 debug ("Disable PCMCIA buffers and assert RESET\n");
642 reg = PCMCIA_PGCRX(_slot_);
643 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
644 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
645 PCMCIA_PGCRX(_slot_) = reg;
651 #endif /* CFG_CMD_PCMCIA */
655 static int voltage_set(int slot, int vcc, int vpp)
657 volatile immap_t *immap;
658 volatile pcmconf8xx_t *pcmp;
661 debug ("voltage_set: "
663 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
664 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
666 immap = (immap_t *)CFG_IMMR;
667 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
669 * Disable PCMCIA buffers (isolate the interface)
670 * and assert RESET signal
672 debug ("Disable PCMCIA buffers and assert RESET\n");
673 reg = PCMCIA_PGCRX(_slot_);
674 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
675 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
676 PCMCIA_PGCRX(_slot_) = reg;
680 * Configure Port C pins for
681 * 5 Volts Enable and 3 Volts enable,
684 debug ("PCMCIA power OFF\n");
685 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
686 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
687 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
692 case 33: reg |= 0x0002; break;
693 case 50: reg |= 0x0004; break;
697 /* Checking supported voltages */
699 debug ("PIPR: 0x%x --> %s\n",
701 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
703 immap->im_ioport.iop_pcdat |= reg;
704 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
706 debug ("PCMCIA powered at %sV\n",
707 (reg&0x0004) ? "5.0" : "3.3");
709 debug ("PCMCIA powered down\n");
713 debug ("Enable PCMCIA buffers and stop RESET\n");
714 reg = PCMCIA_PGCRX(_slot_);
715 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
716 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
717 PCMCIA_PGCRX(_slot_) = reg;
720 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
728 /* ---------------------------------------------------------------------------- */
730 /* ---------------------------------------------------------------------------- */
732 #if defined(CONFIG_LWMON)
734 #define PCMCIA_BOARD_MSG "LWMON"
736 /* #define's for MAX1604 Power Switch */
737 #define MAX1604_OP_SUS 0x80
738 #define MAX1604_VCCBON 0x40
739 #define MAX1604_VCC_35 0x20
740 #define MAX1604_VCCBHIZ 0x10
741 #define MAX1604_VPPBON 0x08
742 #define MAX1604_VPPBPBPGM 0x04
743 #define MAX1604_VPPBHIZ 0x02
746 static int hardware_enable(int slot)
748 volatile immap_t *immap;
749 volatile cpm8xx_t *cp;
750 volatile pcmconf8xx_t *pcmp;
751 volatile sysconf8xx_t *sysp;
756 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
758 /* Switch on PCMCIA port in PIC register 0x60 */
759 reg = pic_read (0x60);
760 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
762 /* reg |= 0x08; Vpp not needed */
763 pic_write (0x60, reg);
765 reg = pic_read (0x60);
766 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
770 immap = (immap_t *)CFG_IMMR;
771 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
772 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
773 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
776 * Configure SIUMCR to enable PCMCIA port B
777 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
779 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
781 /* clear interrupt state, and disable interrupts */
782 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
783 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
785 /* disable interrupts & DMA */
786 PCMCIA_PGCRX(_slot_) = 0;
789 * Disable PCMCIA buffers (isolate the interface)
790 * and assert RESET signal
792 debug ("Disable PCMCIA buffers and assert RESET\n");
793 reg = PCMCIA_PGCRX(_slot_);
794 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
795 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
796 PCMCIA_PGCRX(_slot_) = reg;
800 * Make sure there is a card in the slot, then configure the interface.
803 debug ("[%d] %s: PIPR(%p)=0x%x\n",
804 __LINE__,__FUNCTION__,
805 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
806 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
807 printf (" No Card found\n");
814 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
815 reg = pcmp->pcmc_pipr;
816 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
818 (reg&PCMCIA_VS1(slot))?"n":"ff",
819 (reg&PCMCIA_VS2(slot))?"n":"ff");
820 if ((reg & mask) == mask) {
821 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
822 puts (" 5.0V card found: ");
824 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
825 puts (" 3.3V card found: ");
829 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
830 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
831 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
835 debug ("Enable PCMCIA buffers and stop RESET\n");
836 reg = PCMCIA_PGCRX(_slot_);
837 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
838 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
839 PCMCIA_PGCRX(_slot_) = reg;
841 udelay(250000); /* some cards need >150 ms to come up :-( */
843 debug ("# hardware_enable done\n");
850 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
851 static int hardware_disable(int slot)
853 volatile immap_t *immap;
854 volatile pcmconf8xx_t *pcmp;
858 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
860 immap = (immap_t *)CFG_IMMR;
861 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
863 /* remove all power, put output in high impedance state */
864 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
865 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
866 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
868 /* Configure PCMCIA General Control Register */
869 PCMCIA_PGCRX(_slot_) = 0;
871 debug ("Disable PCMCIA buffers and assert RESET\n");
872 reg = PCMCIA_PGCRX(_slot_);
873 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
874 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
875 PCMCIA_PGCRX(_slot_) = reg;
877 /* Switch off PCMCIA port in PIC register 0x60 */
878 reg = pic_read (0x60);
879 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
882 pic_write (0x60, reg);
884 reg = pic_read (0x60);
885 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
891 #endif /* CFG_CMD_PCMCIA */
895 static int voltage_set(int slot, int vcc, int vpp)
897 volatile immap_t *immap;
898 volatile pcmconf8xx_t *pcmp;
902 debug ("voltage_set: "
904 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
905 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
907 immap = (immap_t *)CFG_IMMR;
908 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
910 * Disable PCMCIA buffers (isolate the interface)
911 * and assert RESET signal
913 debug ("Disable PCMCIA buffers and assert RESET\n");
914 reg = PCMCIA_PGCRX(_slot_);
915 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
916 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
917 PCMCIA_PGCRX(_slot_) = reg;
921 * Turn off all power (switch to high impedance)
923 debug ("PCMCIA power OFF\n");
924 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
925 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
926 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
931 case 33: val = MAX1604_VCC_35; break;
936 /* Checking supported voltages */
938 debug ("PIPR: 0x%x --> %s\n",
940 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
942 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
944 debug ("PCMCIA powered at %sV\n",
945 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
947 debug ("PCMCIA powered down\n");
951 debug ("Enable PCMCIA buffers and stop RESET\n");
952 reg = PCMCIA_PGCRX(_slot_);
953 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
954 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
955 PCMCIA_PGCRX(_slot_) = reg;
958 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
965 /* ---------------------------------------------------------------------------- */
966 /* GTH board by Corelatus AB */
967 /* ---------------------------------------------------------------------------- */
968 #if defined(CONFIG_GTH)
970 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
972 static int voltage_set(int slot, int vcc, int vpp)
977 static int hardware_enable (int slot)
979 volatile immap_t *immap;
980 volatile cpm8xx_t *cp;
981 volatile pcmconf8xx_t *pcmp;
982 volatile sysconf8xx_t *sysp;
985 debug ("hardware_enable: GTH Slot %c\n", 'A'+slot);
987 immap = (immap_t *)CFG_IMMR;
988 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
989 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
990 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
992 /* clear interrupt state, and disable interrupts */
993 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
994 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
996 /* disable interrupts & DMA */
997 PCMCIA_PGCRX(_slot_) = 0;
1000 * Disable PCMCIA buffers (isolate the interface)
1001 * and assert RESET signal
1003 debug ("Disable PCMCIA buffers and assert RESET\n");
1004 reg = PCMCIA_PGCRX(_slot_);
1005 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1006 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1007 PCMCIA_PGCRX(_slot_) = reg;
1011 * Make sure there is a card in the slot, then configure the interface.
1014 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1015 __LINE__,__FUNCTION__,
1016 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1017 if (pcmp->pcmc_pipr & 0x98000000) {
1018 printf (" No Card found\n");
1022 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1023 reg = pcmp->pcmc_pipr;
1024 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1026 (reg&PCMCIA_VS1(slot))?"n":"ff",
1027 (reg&PCMCIA_VS2(slot))?"n":"ff");
1029 debug ("Enable PCMCIA buffers and stop RESET\n");
1030 reg = PCMCIA_PGCRX(_slot_);
1031 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1032 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1033 PCMCIA_PGCRX(_slot_) = reg;
1035 udelay(250000); /* some cards need >150 ms to come up :-( */
1037 debug ("# hardware_enable done\n");
1041 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1042 static int hardware_disable(int slot)
1044 return 0; /* No hardware to disable */
1046 #endif /* CFG_CMD_PCMCIA */
1047 #endif /* CONFIG_GTH */
1049 /* ---------------------------------------------------------------------------- */
1050 /* ICU862 Boards by Cambridge Broadband Ltd. */
1051 /* ---------------------------------------------------------------------------- */
1053 #if defined(CONFIG_ICU862)
1055 #define PCMCIA_BOARD_MSG "ICU862"
1057 static void cfg_port_B (void);
1059 static int hardware_enable(int slot)
1061 volatile immap_t *immap;
1062 volatile cpm8xx_t *cp;
1063 volatile pcmconf8xx_t *pcmp;
1064 volatile sysconf8xx_t *sysp;
1065 uint reg, pipr, mask;
1068 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1072 immap = (immap_t *)CFG_IMMR;
1073 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1074 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1075 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1077 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1081 * Configure SIUMCR to enable PCMCIA port B
1082 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1084 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1086 /* clear interrupt state, and disable interrupts */
1087 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1088 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1090 /* disable interrupts & DMA */
1091 PCMCIA_PGCRX(_slot_) = 0;
1094 * Disable PCMCIA buffers (isolate the interface)
1095 * and assert RESET signal
1097 debug ("Disable PCMCIA buffers and assert RESET\n");
1098 reg = PCMCIA_PGCRX(_slot_);
1099 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1100 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1101 PCMCIA_PGCRX(_slot_) = reg;
1105 * Make sure there is a card in the slot, then configure the interface.
1108 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1109 __LINE__,__FUNCTION__,
1110 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1111 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1112 printf (" No Card found\n");
1117 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1119 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1120 pipr = pcmp->pcmc_pipr;
1121 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1123 (reg&PCMCIA_VS1(slot))?"n":"ff",
1124 (reg&PCMCIA_VS2(slot))?"n":"ff");
1127 if ((pipr & mask) == mask) {
1128 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1129 TPS2205_VCC3); /* 3V off */
1130 reg &= ~(TPS2205_VCC5); /* 5V on */
1131 puts (" 5.0V card found: ");
1133 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1134 TPS2205_VCC5); /* 5V off */
1135 reg &= ~(TPS2205_VCC3); /* 3V on */
1136 puts (" 3.3V card found: ");
1139 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1141 (reg & TPS2205_VCC3) ? "off" : "on",
1142 (reg & TPS2205_VCC5) ? "off" : "on",
1143 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1144 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1148 /* Wait 500 ms; use this to check for over-current */
1149 for (i=0; i<5000; ++i) {
1150 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1151 printf (" *** Overcurrent - Safety shutdown ***\n");
1152 cp->cp_pbdat &= ~(TPS2205_SHDN);
1158 debug ("Enable PCMCIA buffers and stop RESET\n");
1159 reg = PCMCIA_PGCRX(_slot_);
1160 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1161 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1162 PCMCIA_PGCRX(_slot_) = reg;
1164 udelay(250000); /* some cards need >150 ms to come up :-( */
1166 debug ("# hardware_enable done\n");
1173 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1174 static int hardware_disable(int slot)
1176 volatile immap_t *immap;
1177 volatile cpm8xx_t *cp;
1178 volatile pcmconf8xx_t *pcmp;
1181 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1183 immap = (immap_t *)CFG_IMMR;
1184 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1185 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1188 cp->cp_pbdat &= ~(TPS2205_SHDN);
1190 /* Configure PCMCIA General Control Register */
1191 PCMCIA_PGCRX(_slot_) = 0;
1193 debug ("Disable PCMCIA buffers and assert RESET\n");
1194 reg = PCMCIA_PGCRX(_slot_);
1195 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1196 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1197 PCMCIA_PGCRX(_slot_) = reg;
1203 #endif /* CFG_CMD_PCMCIA */
1207 static int voltage_set(int slot, int vcc, int vpp)
1209 volatile immap_t *immap;
1210 volatile cpm8xx_t *cp;
1211 volatile pcmconf8xx_t *pcmp;
1214 debug ("voltage_set: "
1216 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1217 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1219 immap = (immap_t *)CFG_IMMR;
1220 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1221 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1223 * Disable PCMCIA buffers (isolate the interface)
1224 * and assert RESET signal
1226 debug ("Disable PCMCIA buffers and assert RESET\n");
1227 reg = PCMCIA_PGCRX(_slot_);
1228 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1229 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1230 PCMCIA_PGCRX(_slot_) = reg;
1234 * Configure Port C pins for
1235 * 5 Volts Enable and 3 Volts enable,
1236 * Turn all power pins to Hi-Z
1238 debug ("PCMCIA power OFF\n");
1239 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1244 case 0: break; /* Switch off */
1245 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1246 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1250 /* Checking supported voltages */
1252 debug ("PIPR: 0x%x --> %s\n",
1254 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1262 if ((reg & TPS2205_VCC3) == 0) {
1264 } else if ((reg & TPS2205_VCC5) == 0) {
1269 printf ("PCMCIA powered %s\n", s);
1274 debug ("Enable PCMCIA buffers and stop RESET\n");
1275 reg = PCMCIA_PGCRX(_slot_);
1276 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1277 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1278 PCMCIA_PGCRX(_slot_) = reg;
1281 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1286 static void cfg_port_B (void)
1288 volatile immap_t *immap;
1289 volatile cpm8xx_t *cp;
1292 immap = (immap_t *)CFG_IMMR;
1293 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1296 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1298 * Switch off all voltages, assert shutdown
1301 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1302 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1303 TPS2205_SHDN); /* enable switch */
1306 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1308 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1309 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1311 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1312 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1318 /* ---------------------------------------------------------------------------- */
1319 /* C2MON Boards by TTTech Computertechnik AG */
1320 /* ---------------------------------------------------------------------------- */
1322 #if defined(CONFIG_C2MON)
1324 #define PCMCIA_BOARD_MSG "C2MON"
1326 static void cfg_ports (void);
1328 static int hardware_enable(int slot)
1330 volatile immap_t *immap;
1331 volatile cpm8xx_t *cp;
1332 volatile pcmconf8xx_t *pcmp;
1333 volatile sysconf8xx_t *sysp;
1334 uint reg, pipr, mask;
1338 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1342 immap = (immap_t *)CFG_IMMR;
1343 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1344 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1345 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1347 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1351 * Configure SIUMCR to enable PCMCIA port B
1352 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1354 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1356 /* clear interrupt state, and disable interrupts */
1357 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1358 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1360 /* disable interrupts & DMA */
1361 PCMCIA_PGCRX(_slot_) = 0;
1364 * Disable PCMCIA buffers (isolate the interface)
1365 * and assert RESET signal
1367 debug ("Disable PCMCIA buffers and assert RESET\n");
1368 reg = PCMCIA_PGCRX(_slot_);
1369 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1370 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1371 PCMCIA_PGCRX(_slot_) = reg;
1375 * Make sure there is a card in the slot, then configure the interface.
1378 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1379 __LINE__,__FUNCTION__,
1380 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1381 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1382 printf (" No Card found\n");
1387 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1389 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1390 pipr = pcmp->pcmc_pipr;
1391 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1393 (reg&PCMCIA_VS1(slot))?"n":"ff",
1394 (reg&PCMCIA_VS2(slot))?"n":"ff");
1396 sreg = immap->im_ioport.iop_pcdat;
1397 if ((pipr & mask) == mask) {
1398 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1399 TPS2211_VCCD1); /* 5V on */
1400 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1401 puts (" 5.0V card found: ");
1403 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1404 TPS2211_VCCD0); /* 3V on */
1405 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1406 puts (" 3.3V card found: ");
1409 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1411 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1412 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1415 immap->im_ioport.iop_pcdat = sreg;
1417 /* Wait 500 ms; use this to check for over-current */
1418 for (i=0; i<5000; ++i) {
1419 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1420 printf (" *** Overcurrent - Safety shutdown ***\n");
1421 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1427 debug ("Enable PCMCIA buffers and stop RESET\n");
1428 reg = PCMCIA_PGCRX(_slot_);
1429 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1430 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1431 PCMCIA_PGCRX(_slot_) = reg;
1433 udelay(250000); /* some cards need >150 ms to come up :-( */
1435 debug ("# hardware_enable done\n");
1442 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1443 static int hardware_disable(int slot)
1445 volatile immap_t *immap;
1446 volatile cpm8xx_t *cp;
1447 volatile pcmconf8xx_t *pcmp;
1450 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1452 immap = (immap_t *)CFG_IMMR;
1453 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1455 /* Configure PCMCIA General Control Register */
1456 PCMCIA_PGCRX(_slot_) = 0;
1458 debug ("Disable PCMCIA buffers and assert RESET\n");
1459 reg = PCMCIA_PGCRX(_slot_);
1460 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1461 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1462 PCMCIA_PGCRX(_slot_) = reg;
1464 /* ALl voltages off / Hi-Z */
1465 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1466 TPS2211_VCCD0 | TPS2211_VCCD1 );
1472 #endif /* CFG_CMD_PCMCIA */
1476 static int voltage_set(int slot, int vcc, int vpp)
1478 volatile immap_t *immap;
1479 volatile cpm8xx_t *cp;
1480 volatile pcmconf8xx_t *pcmp;
1484 debug ("voltage_set: "
1486 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1487 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1489 immap = (immap_t *)CFG_IMMR;
1490 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1491 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1493 * Disable PCMCIA buffers (isolate the interface)
1494 * and assert RESET signal
1496 debug ("Disable PCMCIA buffers and assert RESET\n");
1497 reg = PCMCIA_PGCRX(_slot_);
1498 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1499 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1500 PCMCIA_PGCRX(_slot_) = reg;
1504 * Configure Port C pins for
1505 * 5 Volts Enable and 3 Volts enable,
1506 * Turn all power pins to Hi-Z
1508 debug ("PCMCIA power OFF\n");
1509 cfg_ports (); /* Enables switch, but all in Hi-Z */
1511 sreg = immap->im_ioport.iop_pcdat;
1512 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1515 case 0: break; /* Switch off */
1516 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1517 sreg &= ~TPS2211_VCCD1;
1519 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1520 sreg |= TPS2211_VCCD1;
1525 /* Checking supported voltages */
1527 debug ("PIPR: 0x%x --> %s\n",
1529 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1531 immap->im_ioport.iop_pcdat = sreg;
1537 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1539 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1544 printf ("PCMCIA powered %s\n", s);
1549 debug ("Enable PCMCIA buffers and stop RESET\n");
1550 reg = PCMCIA_PGCRX(_slot_);
1551 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1552 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1553 PCMCIA_PGCRX(_slot_) = reg;
1556 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1561 static void cfg_ports (void)
1563 volatile immap_t *immap;
1564 volatile cpm8xx_t *cp;
1567 immap = (immap_t *)CFG_IMMR;
1568 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1571 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1573 * Switch off all voltages, assert shutdown
1575 sreg = immap->im_ioport.iop_pcdat;
1576 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1577 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1578 immap->im_ioport.iop_pcdat = sreg;
1580 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1581 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1583 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1584 immap->im_ioport.iop_pcpar,
1585 immap->im_ioport.iop_pcdir,
1586 immap->im_ioport.iop_pcdat);
1589 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1591 * Over-Current Input only
1593 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1594 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1596 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1597 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1602 /* ----------------------------------------------------------------------------
1603 MBX board from Morotola
1604 ---------------------------------------------------------------------------- */
1606 #if defined( CONFIG_MBX )
1607 #include <../board/mbx8xx/csr.h>
1609 /* A lot of this has been taken from the RPX code in this file it works from me.
1610 I have added the voltage selection for the MBX board. */
1612 /* MBX voltage bit in control register #2 */
1613 #define CR2_VPP12 ((uchar)0x10)
1614 #define CR2_VPPVDD ((uchar)0x20)
1615 #define CR2_VDD5 ((uchar)0x40)
1616 #define CR2_VDD3 ((uchar)0x80)
1618 #define PCMCIA_BOARD_MSG "MBX860"
1620 static int voltage_set (int slot, int vcc, int vpp)
1624 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1625 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1658 /* first, turn off all power */
1659 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1661 /* enable new powersettings */
1663 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1668 static int hardware_enable (int slot)
1670 volatile immap_t *immap;
1671 volatile cpm8xx_t *cp;
1672 volatile pcmconf8xx_t *pcmp;
1673 volatile sysconf8xx_t *sysp;
1676 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1681 immap = (immap_t *) CFG_IMMR;
1682 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1683 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1684 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1686 /* clear interrupt state, and disable interrupts */
1687 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1688 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1690 /* disable interrupts & DMA */
1691 PCMCIA_PGCRX (_slot_) = 0;
1694 * Disable PCMCIA buffers (isolate the interface)
1695 * and assert RESET signal
1697 debug ("Disable PCMCIA buffers and assert RESET\n");
1698 reg = PCMCIA_PGCRX (_slot_);
1699 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1700 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1701 PCMCIA_PGCRX (_slot_) = reg;
1704 /* remove all power */
1705 voltage_set (slot, 0, 0);
1707 * Make sure there is a card in the slot, then configure the interface.
1710 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1711 __LINE__,__FUNCTION__,
1712 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1713 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1714 printf (" No Card found\n");
1721 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1722 reg = pcmp->pcmc_pipr;
1723 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1724 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1725 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1727 if ((reg & mask) == mask) {
1728 voltage_set (_slot_, 50, 0);
1729 printf (" 5.0V card found: ");
1731 voltage_set (_slot_, 33, 0);
1732 printf (" 3.3V card found: ");
1735 debug ("Enable PCMCIA buffers and stop RESET\n");
1736 reg = PCMCIA_PGCRX (_slot_);
1737 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1738 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1739 PCMCIA_PGCRX (_slot_) = reg;
1741 udelay (250000); /* some cards need >150 ms to come up :-( */
1743 debug ("# hardware_enable done\n");
1748 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1749 static int hardware_disable (int slot)
1751 return 0; /* No hardware to disable */
1753 #endif /* CFG_CMD_PCMCIA */
1754 #endif /* CONFIG_MBX */
1755 /* ---------------------------------------------------------------------------- */
1757 /* ---------------------------------------------------------------------------- */
1759 #if defined(CONFIG_R360MPI)
1761 #define PCMCIA_BOARD_MSG "R360MPI"
1764 static int hardware_enable(int slot)
1766 volatile immap_t *immap;
1767 volatile cpm8xx_t *cp;
1768 volatile pcmconf8xx_t *pcmp;
1769 volatile sysconf8xx_t *sysp;
1772 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1776 immap = (immap_t *)CFG_IMMR;
1777 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1778 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1779 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1782 * Configure SIUMCR to enable PCMCIA port B
1783 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1785 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1787 /* clear interrupt state, and disable interrupts */
1788 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1789 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1791 /* disable interrupts & DMA */
1792 PCMCIA_PGCRX(_slot_) = 0;
1795 * Disable PCMCIA buffers (isolate the interface)
1796 * and assert RESET signal
1798 debug ("Disable PCMCIA buffers and assert RESET\n");
1799 reg = PCMCIA_PGCRX(_slot_);
1800 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1801 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1802 PCMCIA_PGCRX(_slot_) = reg;
1806 * Configure Ports A, B & C pins for
1807 * 5 Volts Enable and 3 Volts enable
1809 immap->im_ioport.iop_pcpar &= ~(0x0400);
1810 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1811 immap->im_ioport.iop_pcdir |= 0x0400;*/
1813 immap->im_ioport.iop_papar &= ~(0x0200);/*
1814 immap->im_ioport.iop_padir |= 0x0200;*/
1816 immap->im_ioport.iop_pbpar &= ~(0xC000);
1817 immap->im_ioport.iop_pbdir &= ~(0xC000);
1819 /* remove all power */
1821 immap->im_ioport.iop_pcdat |= 0x0400;
1822 immap->im_ioport.iop_padat |= 0x0200;
1825 * Make sure there is a card in the slot, then configure the interface.
1828 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1829 __LINE__,__FUNCTION__,
1830 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1831 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1832 printf (" No Card found\n");
1839 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1840 reg = pcmp->pcmc_pipr;
1841 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1843 (reg&PCMCIA_VS1(slot))?"n":"ff",
1844 (reg&PCMCIA_VS2(slot))?"n":"ff");
1845 if ((reg & mask) == mask) {
1846 immap->im_ioport.iop_pcdat &= ~(0x4000);
1847 puts (" 5.0V card found: ");
1849 immap->im_ioport.iop_padat &= ~(0x0002);
1850 puts (" 3.3V card found: ");
1852 immap->im_ioport.iop_pcdir |= 0x0400;
1853 immap->im_ioport.iop_padir |= 0x0200;
1855 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
1856 cp->cp_pbdir &= ~(0x0020 | 0x0010);
1857 cp->cp_pbpar &= ~(0x0020 | 0x0010);
1860 debug ("Enable PCMCIA buffers and stop RESET\n");
1861 reg = PCMCIA_PGCRX(_slot_);
1862 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1863 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1864 PCMCIA_PGCRX(_slot_) = reg;
1866 udelay(250000); /* some cards need >150 ms to come up :-( */
1868 debug ("# hardware_enable done\n");
1875 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1876 static int hardware_disable(int slot)
1878 volatile immap_t *immap;
1879 volatile pcmconf8xx_t *pcmp;
1882 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1884 immap = (immap_t *)CFG_IMMR;
1885 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1887 /* remove all power */
1888 immap->im_ioport.iop_pcdat |= 0x0400;
1889 immap->im_ioport.iop_padat |= 0x0200;
1891 /* Configure PCMCIA General Control Register */
1892 PCMCIA_PGCRX(_slot_) = 0;
1894 debug ("Disable PCMCIA buffers and assert RESET\n");
1895 reg = PCMCIA_PGCRX(_slot_);
1896 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1897 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1898 PCMCIA_PGCRX(_slot_) = reg;
1904 #endif /* CFG_CMD_PCMCIA */
1908 static int voltage_set(int slot, int vcc, int vpp)
1910 volatile immap_t *immap;
1911 volatile pcmconf8xx_t *pcmp;
1914 debug ("voltage_set: "
1916 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1917 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1919 immap = (immap_t *)CFG_IMMR;
1920 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1922 * Disable PCMCIA buffers (isolate the interface)
1923 * and assert RESET signal
1925 debug ("Disable PCMCIA buffers and assert RESET\n");
1926 reg = PCMCIA_PGCRX(_slot_);
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 & C pins for
1934 * 5 Volts Enable and 3 Volts enable,
1935 * Turn off all power
1937 debug ("PCMCIA power OFF\n");
1938 immap->im_ioport.iop_pcpar &= ~(0x0400);
1939 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1940 immap->im_ioport.iop_pcdir |= 0x0400;*/
1942 immap->im_ioport.iop_papar &= ~(0x0200);/*
1943 immap->im_ioport.iop_padir |= 0x0200;*/
1945 immap->im_ioport.iop_pcdat |= 0x0400;
1946 immap->im_ioport.iop_padat |= 0x0200;
1951 case 33: reg |= 0x0200; break;
1952 case 50: reg |= 0x0400; break;
1956 /* Checking supported voltages */
1958 debug ("PIPR: 0x%x --> %s\n",
1960 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1963 immap->im_ioport.iop_pcdat &= !reg;
1965 immap->im_ioport.iop_padat &= !reg;
1966 immap->im_ioport.iop_pcdir |= 0x0200;
1967 immap->im_ioport.iop_padir |= 0x0400;
1969 debug ("PCMCIA powered at %sV\n",
1970 (reg&0x0400) ? "5.0" : "3.3");
1972 debug ("PCMCIA powered down\n");
1976 debug ("Enable PCMCIA buffers and stop RESET\n");
1977 reg = PCMCIA_PGCRX(_slot_);
1978 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1979 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1980 PCMCIA_PGCRX(_slot_) = reg;
1983 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1988 #endif /* R360MPI */
1990 /* ---------------------------------------------------------------------------- */
1992 /* ---------------------------------------------------------------------------- */
1993 #if defined(CONFIG_KUP4K)
1995 #define PCMCIA_BOARD_MSG "KUP4K"
1997 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
1999 static int hardware_enable(int slot)
2001 volatile immap_t *immap;
2002 volatile cpm8xx_t *cp;
2003 volatile pcmconf8xx_t *pcmp;
2004 volatile sysconf8xx_t *sysp;
2007 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2011 immap = (immap_t *)CFG_IMMR;
2012 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2013 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2014 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2017 * Configure SIUMCR to enable PCMCIA port B
2018 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2020 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2022 /* clear interrupt state, and disable interrupts */
2023 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2024 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2026 /* disable interrupts & DMA */
2027 PCMCIA_PGCRX(slot) = 0;
2030 * Disable PCMCIA buffers (isolate the interface)
2031 * and assert RESET signal
2033 debug ("Disable PCMCIA buffers and assert RESET\n");
2034 reg = PCMCIA_PGCRX(slot);
2035 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2036 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2037 PCMCIA_PGCRX(slot) = reg;
2041 * Configure Port B pins for
2044 if (slot) { /* Slot A is built-in */
2045 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2046 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2047 /* remove all power */
2048 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2051 * Make sure there is a card in the slot, then configure the interface.
2054 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2055 __LINE__,__FUNCTION__,
2056 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2057 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2058 printf (" No Card found\n");
2065 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2066 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2067 reg = pcmp->pcmc_pipr;
2068 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2070 (reg&PCMCIA_VS1(slot))?"n":"ff",
2071 (reg&PCMCIA_VS2(slot))?"n":"ff");
2072 if ((reg & mask) == mask) {
2073 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2076 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2077 puts (" 3.3V card found: ");
2080 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2081 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2082 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2085 debug ("Enable PCMCIA buffers and stop RESET\n");
2086 reg = PCMCIA_PGCRX(slot);
2087 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2088 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2089 PCMCIA_PGCRX(slot) = reg;
2091 udelay(250000); /* some cards need >150 ms to come up :-( */
2093 debug ("# hardware_enable done\n");
2100 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2101 static int hardware_disable(int slot)
2103 volatile immap_t *immap;
2104 volatile cpm8xx_t *cp;
2105 volatile pcmconf8xx_t *pcmp;
2108 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2110 immap = (immap_t *)CFG_IMMR;
2111 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2112 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2114 /* remove all power */
2116 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2118 /* Configure PCMCIA General Control Register */
2119 PCMCIA_PGCRX(slot) = 0;
2121 debug ("Disable PCMCIA buffers and assert RESET\n");
2122 reg = PCMCIA_PGCRX(slot);
2123 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2124 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2125 PCMCIA_PGCRX(slot) = reg;
2131 #endif /* CFG_CMD_PCMCIA */
2135 static int voltage_set(int slot, int vcc, int vpp)
2137 volatile immap_t *immap;
2138 volatile cpm8xx_t *cp;
2139 volatile pcmconf8xx_t *pcmp;
2142 debug ("voltage_set: " \
2144 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2145 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2147 if (!slot) /* Slot A is not configurable */
2150 immap = (immap_t *)CFG_IMMR;
2151 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2152 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2155 * Disable PCMCIA buffers (isolate the interface)
2156 * and assert RESET signal
2158 debug ("Disable PCMCIA buffers and assert RESET\n");
2159 reg = PCMCIA_PGCRX(slot);
2160 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2161 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2162 PCMCIA_PGCRX(slot) = reg;
2165 debug ("PCMCIA power OFF\n");
2167 * Configure Port B pins for
2170 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2171 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2172 /* remove all power */
2173 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2178 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2179 debug ("PCMCIA powered at 3.3V\n");
2182 debug ("PCMCIA: 5Volt vcc not supported\n");
2185 puts("PCMCIA: vcc not supported");
2189 /* Checking supported voltages */
2191 debug ("PIPR: 0x%x --> %s\n",
2193 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2194 ? "only 5 V --> NOT SUPPORTED"
2198 debug ("Enable PCMCIA buffers and stop RESET\n");
2199 reg = PCMCIA_PGCRX(slot);
2200 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2201 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2202 PCMCIA_PGCRX(slot) = reg;
2205 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2216 /* ---------------------------------------------------------------------------- */
2217 /* End of Board Specific Stuff */
2218 /* ---------------------------------------------------------------------------- */
2221 /* ---------------------------------------------------------------------------- */
2222 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2223 /* ---------------------------------------------------------------------------- */
2226 * Search this table to see if the windowsize is
2230 #define M8XX_SIZES_NO 32
2232 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2233 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2234 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2235 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2236 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2238 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2239 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2240 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2241 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2244 /* ---------------------------------------------------------------------------- */
2246 static u_int m8xx_get_graycode(u_int size)
2250 for (k = 0; k < M8XX_SIZES_NO; k++) {
2251 if(m8xx_size_to_gray[k] == size)
2255 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2261 /* ------------------------------------------------------------------------- */
2264 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2266 u_int reg, clocks, psst, psl, psht;
2271 * We get called with IO maps setup to 0ns
2272 * if not specified by the user.
2273 * They should be 255ns.
2279 ns = 100; /* fast memory if 0 */
2283 * In PSST, PSL, PSHT fields we tell the controller
2284 * timing parameters in CLKOUT clock cycles.
2285 * CLKOUT is the same as GCLK2_50.
2288 /* how we want to adjust the timing - in percent */
2290 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2292 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2293 clocks = (clocks * ADJ) / (100*1000);
2295 if(clocks >= PCMCIA_BMT_LIMIT) {
2296 DEBUG(0, "Max access time limit reached\n");
2297 clocks = PCMCIA_BMT_LIMIT-1;
2300 psst = clocks / 7; /* setup time */
2301 psht = clocks / 7; /* hold time */
2302 psl = (clocks * 5) / 7; /* strobe length */
2304 psst += clocks - (psst + psht + psl);
2314 /* ------------------------------------------------------------------------- */
2316 #ifdef CONFIG_IDE_8xx_PCCARD
2317 static void print_funcid (int func)
2321 case CISTPL_FUNCID_MULTI:
2322 puts (" Multi-Function");
2324 case CISTPL_FUNCID_MEMORY:
2327 case CISTPL_FUNCID_SERIAL:
2328 puts (" Serial Port");
2330 case CISTPL_FUNCID_PARALLEL:
2331 puts (" Parallel Port");
2333 case CISTPL_FUNCID_FIXED:
2334 puts (" Fixed Disk");
2336 case CISTPL_FUNCID_VIDEO:
2337 puts (" Video Adapter");
2339 case CISTPL_FUNCID_NETWORK:
2340 puts (" Network Adapter");
2342 case CISTPL_FUNCID_AIMS:
2343 puts (" AIMS Card");
2345 case CISTPL_FUNCID_SCSI:
2346 puts (" SCSI Adapter");
2354 #endif /* CONFIG_IDE_8xx_PCCARD */
2356 /* ------------------------------------------------------------------------- */
2358 #ifdef CONFIG_IDE_8xx_PCCARD
2359 static void print_fixed (volatile uchar *p)
2367 case CISTPL_FUNCE_IDE_IFACE:
2368 { uchar iface = *(p+2);
2370 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2371 puts (" interface ");
2374 case CISTPL_FUNCE_IDE_MASTER:
2375 case CISTPL_FUNCE_IDE_SLAVE:
2376 { uchar f1 = *(p+2);
2379 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2381 if (f1 & CISTPL_IDE_UNIQUE)
2384 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2386 if (f2 & CISTPL_IDE_HAS_SLEEP)
2389 if (f2 & CISTPL_IDE_HAS_STANDBY)
2390 puts (" [standby]");
2392 if (f2 & CISTPL_IDE_HAS_IDLE)
2395 if (f2 & CISTPL_IDE_LOW_POWER)
2396 puts (" [low power]");
2398 if (f2 & CISTPL_IDE_REG_INHIBIT)
2399 puts (" [reg inhibit]");
2401 if (f2 & CISTPL_IDE_HAS_INDEX)
2404 if (f2 & CISTPL_IDE_IOIS16)
2412 #endif /* CONFIG_IDE_8xx_PCCARD */
2414 /* ------------------------------------------------------------------------- */
2416 #ifdef CONFIG_IDE_8xx_PCCARD
2418 #define MAX_IDENT_CHARS 64
2419 #define MAX_IDENT_FIELDS 4
2421 static uchar *known_cards[] = {
2426 static int identify (volatile uchar *p)
2428 uchar id_str[MAX_IDENT_CHARS];
2435 return (0); /* Don't know */
2440 for (i=0; i<=4 && !done; ++i, p+=2) {
2441 while ((data = *p) != '\0') {
2447 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2457 while (--t > id_str) {
2466 for (card=known_cards; *card; ++card) {
2467 debug ("## Compare against \"%s\"\n", *card);
2468 if (strcmp(*card, id_str) == 0) { /* found! */
2469 debug ("## CARD FOUND ##\n");
2474 return (0); /* don't know */
2476 #endif /* CONFIG_IDE_8xx_PCCARD */
2478 /* ------------------------------------------------------------------------- */
2480 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */