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);
79 extern int i82365_init (void);
80 extern void i82365_exit (void);
82 #else /* ! CONFIG_I82365 */
84 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
85 static int hardware_disable(int slot);
87 static int hardware_enable (int slot);
88 static int voltage_set(int slot, int vcc, int vpp);
91 static u_int m8xx_get_graycode(u_int size);
92 #endif /* CONFIG_I82365 */
94 static u_int m8xx_get_speed(u_int ns, u_int is_io);
97 /* -------------------------------------------------------------------- */
99 /* look up table for pgcrx registers */
101 static u_int *pcmcia_pgcrx[2] = {
102 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
103 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
106 #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
108 #endif /* CONFIG_I82365 */
110 #ifdef CONFIG_IDE_8xx_PCCARD
111 static void print_funcid (int func);
112 static void print_fixed (volatile uchar *p);
113 static int identify (volatile uchar *p);
114 static int check_ide_device (int slot);
115 #endif /* CONFIG_IDE_8xx_PCCARD */
117 const char *indent = "\t ";
119 /* -------------------------------------------------------------------- */
121 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
123 int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
128 printf ("Usage: pinit {on | off}\n");
131 if (strcmp(argv[1],"on") == 0) {
132 rcode = pcmcia_on ();
133 } else if (strcmp(argv[1],"off") == 0) {
134 rcode = pcmcia_off ();
136 printf ("Usage: pinit {on | off}\n");
142 #endif /* CFG_CMD_PCMCIA */
144 /* -------------------------------------------------------------------- */
151 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
157 rc = check_ide_device(0);
164 #if defined(CONFIG_LWMON)
165 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
167 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
178 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
180 /* intialize the fixed memory windows */
181 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
182 base = CFG_PCMCIA_MEM_ADDR;
184 if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
185 printf ("Cannot set window size to 0x%08x\n",
186 CFG_PCMCIA_MEM_SIZE);
190 slotbit = PCMCIA_SLOT_x;
191 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
194 #if (PCMCIA_SOCKETS_NO == 2)
195 if (i == 4) /* Another slot starting from win 4 */
196 slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
199 #ifdef CONFIG_IDE_8xx_PCCARD
201 case 0: { /* map attribute memory */
202 win->or = ( PCMCIA_BSIZE_64M
207 | CFG_PCMCIA_TIMING );
211 case 1: { /* map I/O window for data reg */
212 win->or = ( PCMCIA_BSIZE_1K
217 | CFG_PCMCIA_TIMING );
221 case 2: { /* map I/O window for cmd/ctrl reg block */
222 win->or = ( PCMCIA_BSIZE_1K
227 | CFG_PCMCIA_TIMING );
230 #endif /* CONFIG_IDE_8xx_PCCARD */
231 default: /* set to not valid */
236 debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
237 i, win->br, win->or);
238 base += CFG_PCMCIA_MEM_SIZE;
242 for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
243 /* turn off voltage */
244 if ((rc = voltage_set(slot, 0, 0)))
247 /* Enable external hardware */
248 if ((rc = hardware_enable(slot)))
251 #ifdef CONFIG_IDE_8xx_PCCARD
252 if ((rc = check_ide_device(i)))
258 #endif /* CONFIG_I82365 */
260 /* -------------------------------------------------------------------- */
262 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
265 static int pcmcia_off (void)
267 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
274 static int pcmcia_off (void)
279 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
281 /* clear interrupt state, and disable interrupts */
282 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
283 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
285 /* turn off interrupt and disable CxOE */
286 PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
288 /* turn off memory windows */
289 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
291 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
292 /* disable memory window */
297 /* turn off voltage */
298 voltage_set(_slot_, 0, 0);
300 /* disable external hardware */
301 printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
302 hardware_disable(_slot_);
305 #endif /* CONFIG_I82365 */
307 #endif /* CFG_CMD_PCMCIA */
309 /* -------------------------------------------------------------------- */
311 #ifdef CONFIG_IDE_8xx_PCCARD
313 #define MAX_TUPEL_SZ 512
314 #define MAX_FEATURES 4
316 int ide_devices_found;
317 static int check_ide_device (int slot)
319 volatile uchar *ident = NULL;
320 volatile uchar *feature_p[MAX_FEATURES];
321 volatile uchar *p, *start, *addr;
325 ushort config_base = 0;
329 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
330 CFG_PCMCIA_MEM_SIZE * (slot * 4));
331 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
333 start = p = (volatile uchar *) addr;
335 while ((p - start) < MAX_TUPEL_SZ) {
339 if (code == 0xFF) { /* End of chain */
344 #if defined(DEBUG) && (DEBUG > 1)
345 { volatile uchar *q = p;
346 printf ("\nTuple code %02x length %d\n\tData:",
349 for (i = 0; i < len; ++i) {
350 printf (" %02x", *q);
360 /* Fix for broken SanDisk which may have 0x80 bit set */
364 if (n_features < MAX_FEATURES)
365 feature_p[n_features++] = p;
368 config_base = (*(p+6) << 8) + (*(p+4));
369 debug ("\n## Config_base = %04x ###\n", config_base);
376 found = identify (ident);
378 if (func_id != ((uchar)~0)) {
379 print_funcid (func_id);
381 if (func_id == CISTPL_FUNCID_FIXED)
384 return (1); /* no disk drive */
387 for (i=0; i<n_features; ++i) {
388 print_fixed (feature_p[i]);
392 printf ("unknown card type\n");
396 ide_devices_found |= (1 << slot);
398 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
399 *((uchar *)(addr + config_base)) = 1;
403 #endif /* CONFIG_IDE_8xx_PCCARD */
405 /* -------------------------------------------------------------------- */
408 /* -------------------------------------------------------------------- */
409 /* board specific stuff: */
410 /* voltage_set(), hardware_enable() and hardware_disable() */
411 /* -------------------------------------------------------------------- */
413 /* -------------------------------------------------------------------- */
414 /* RPX Boards from Embedded Planet */
415 /* -------------------------------------------------------------------- */
417 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
419 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
420 * SYPCR is write once only, therefore must the slowest memory be faster
421 * than the bus monitor or we will get a machine check due to the bus timeout.
424 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
426 #undef PCMCIA_BMT_LIMIT
427 #define PCMCIA_BMT_LIMIT (6*8)
429 static int voltage_set(int slot, int vcc, int vpp)
435 case 33: reg |= BCSR1_PCVCTL4; break;
436 case 50: reg |= BCSR1_PCVCTL5; break;
445 reg |= BCSR1_PCVCTL6;
450 reg |= BCSR1_PCVCTL7;
457 /* first, turn off all power */
459 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
460 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
462 /* enable new powersettings */
464 *((uint *)RPX_CSR_ADDR) |= reg;
469 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
470 static int hardware_enable (int slot)
472 return 0; /* No hardware to enable */
474 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
475 static int hardware_disable(int slot)
477 return 0; /* No hardware to disable */
479 #endif /* CFG_CMD_PCMCIA */
480 #endif /* CONFIG_RPXCLASSIC */
482 /* -------------------------------------------------------------------- */
483 /* (F)ADS Boards from Motorola */
484 /* -------------------------------------------------------------------- */
486 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
489 #define PCMCIA_BOARD_MSG "ADS"
490 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
492 #define PCMCIA_BOARD_MSG "FADS"
495 static int voltage_set(int slot, int vcc, int vpp)
500 case 0: reg = 0; break;
501 case 50: reg = 1; break;
502 case 120: reg = 2; break;
507 case 0: reg = 0; break;
509 case 50: reg = BCSR1_PCCVCCON; break;
512 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
513 case 50: reg = BCSR1_PCCVCC1; break;
518 /* first, turn off all power */
521 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
524 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
526 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
528 /* enable new powersettings */
531 *((uint *)BCSR1) &= ~reg;
534 *((uint *)BCSR1) |= reg;
537 *((uint *)BCSR1) |= reg << 20;
542 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
544 static int hardware_enable(int slot)
546 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
550 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
551 static int hardware_disable(int slot)
553 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
556 #endif /* CFG_CMD_PCMCIA */
560 /* -------------------------------------------------------------------- */
561 /* TQM8xxL Boards by TQ Components */
562 /* SC8xx Boards by SinoVee Microsystems */
563 /* -------------------------------------------------------------------- */
565 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)
567 #if defined(CONFIG_TQM8xxL)
568 #define PCMCIA_BOARD_MSG "TQM8xxL"
570 #if defined(CONFIG_SVM_SC8xx)
571 #define PCMCIA_BOARD_MSG "SC8xx"
574 static int hardware_enable(int slot)
576 volatile immap_t *immap;
577 volatile cpm8xx_t *cp;
578 volatile pcmconf8xx_t *pcmp;
579 volatile sysconf8xx_t *sysp;
582 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
586 immap = (immap_t *)CFG_IMMR;
587 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
588 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
589 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
592 * Configure SIUMCR to enable PCMCIA port B
593 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
595 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
597 /* clear interrupt state, and disable interrupts */
598 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
599 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
602 * Disable interrupts, DMA, and PCMCIA buffers
603 * (isolate the interface) and assert RESET signal
605 debug ("Disable PCMCIA buffers and assert RESET\n");
607 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
608 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
609 PCMCIA_PGCRX(_slot_) = reg;
613 * Configure Port C pins for
614 * 5 Volts Enable and 3 Volts enable
616 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
617 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
618 /* remove all power */
620 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
623 * Make sure there is a card in the slot, then configure the interface.
626 debug ("[%d] %s: PIPR(%p)=0x%x\n",
627 __LINE__,__FUNCTION__,
628 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
629 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
630 printf (" No Card found\n");
637 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
638 reg = pcmp->pcmc_pipr;
639 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
641 (reg&PCMCIA_VS1(slot))?"n":"ff",
642 (reg&PCMCIA_VS2(slot))?"n":"ff");
643 if ((reg & mask) == mask) {
644 immap->im_ioport.iop_pcdat |= 0x0004;
645 puts (" 5.0V card found: ");
647 immap->im_ioport.iop_pcdat |= 0x0002;
648 puts (" 3.3V card found: ");
650 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
652 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
653 cp->cp_pbdir &= ~(0x0020 | 0x0010);
654 cp->cp_pbpar &= ~(0x0020 | 0x0010);
658 debug ("Enable PCMCIA buffers and stop RESET\n");
659 reg = PCMCIA_PGCRX(_slot_);
660 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
661 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
662 PCMCIA_PGCRX(_slot_) = reg;
664 udelay(250000); /* some cards need >150 ms to come up :-( */
666 debug ("# hardware_enable done\n");
673 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
674 static int hardware_disable(int slot)
676 volatile immap_t *immap;
677 volatile pcmconf8xx_t *pcmp;
680 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
682 immap = (immap_t *)CFG_IMMR;
683 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
685 /* remove all power */
686 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
688 debug ("Disable PCMCIA buffers and assert RESET\n");
690 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
691 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
692 PCMCIA_PGCRX(_slot_) = reg;
698 #endif /* CFG_CMD_PCMCIA */
702 static int voltage_set(int slot, int vcc, int vpp)
704 volatile immap_t *immap;
705 volatile pcmconf8xx_t *pcmp;
708 debug ("voltage_set: "
710 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
711 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
713 immap = (immap_t *)CFG_IMMR;
714 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
716 * Disable PCMCIA buffers (isolate the interface)
717 * and assert RESET signal
719 debug ("Disable PCMCIA buffers and assert RESET\n");
720 reg = PCMCIA_PGCRX(_slot_);
721 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
722 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
723 PCMCIA_PGCRX(_slot_) = reg;
727 * Configure Port C pins for
728 * 5 Volts Enable and 3 Volts enable,
731 debug ("PCMCIA power OFF\n");
732 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
733 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
734 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
739 case 33: reg |= 0x0002; break;
740 case 50: reg |= 0x0004; break;
744 /* Checking supported voltages */
746 debug ("PIPR: 0x%x --> %s\n",
748 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
750 immap->im_ioport.iop_pcdat |= reg;
751 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
753 debug ("PCMCIA powered at %sV\n",
754 (reg&0x0004) ? "5.0" : "3.3");
756 debug ("PCMCIA powered down\n");
760 debug ("Enable PCMCIA buffers and stop RESET\n");
761 reg = PCMCIA_PGCRX(_slot_);
762 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
763 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
764 PCMCIA_PGCRX(_slot_) = reg;
767 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
775 /* -------------------------------------------------------------------- */
777 /* -------------------------------------------------------------------- */
779 #if defined(CONFIG_LWMON)
781 #define PCMCIA_BOARD_MSG "LWMON"
783 /* #define's for MAX1604 Power Switch */
784 #define MAX1604_OP_SUS 0x80
785 #define MAX1604_VCCBON 0x40
786 #define MAX1604_VCC_35 0x20
787 #define MAX1604_VCCBHIZ 0x10
788 #define MAX1604_VPPBON 0x08
789 #define MAX1604_VPPBPBPGM 0x04
790 #define MAX1604_VPPBHIZ 0x02
793 static int hardware_enable(int slot)
795 volatile immap_t *immap;
796 volatile cpm8xx_t *cp;
797 volatile pcmconf8xx_t *pcmp;
798 volatile sysconf8xx_t *sysp;
803 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
805 /* Switch on PCMCIA port in PIC register 0x60 */
806 reg = pic_read (0x60);
807 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
809 /* reg |= 0x08; Vpp not needed */
810 pic_write (0x60, reg);
812 reg = pic_read (0x60);
813 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
817 immap = (immap_t *)CFG_IMMR;
818 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
819 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
820 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
823 * Configure SIUMCR to enable PCMCIA port B
824 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
826 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
828 /* clear interrupt state, and disable interrupts */
829 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
830 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
833 * Disable interrupts, DMA, and PCMCIA buffers
834 * (isolate the interface) and assert RESET signal
836 debug ("Disable PCMCIA buffers and assert RESET\n");
838 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
839 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
840 PCMCIA_PGCRX(_slot_) = reg;
844 * Make sure there is a card in the slot, then configure the interface.
847 debug ("[%d] %s: PIPR(%p)=0x%x\n",
848 __LINE__,__FUNCTION__,
849 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
850 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
851 printf (" No Card found\n");
858 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
859 reg = pcmp->pcmc_pipr;
860 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
862 (reg&PCMCIA_VS1(slot))?"n":"ff",
863 (reg&PCMCIA_VS2(slot))?"n":"ff");
864 if ((reg & mask) == mask) {
865 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
866 puts (" 5.0V card found: ");
868 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
869 puts (" 3.3V card found: ");
873 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
874 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
875 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
879 debug ("Enable PCMCIA buffers and stop RESET\n");
880 reg = PCMCIA_PGCRX(_slot_);
881 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
882 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
883 PCMCIA_PGCRX(_slot_) = reg;
885 udelay(250000); /* some cards need >150 ms to come up :-( */
887 debug ("# hardware_enable done\n");
894 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
895 static int hardware_disable(int slot)
897 volatile immap_t *immap;
898 volatile pcmconf8xx_t *pcmp;
902 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
904 immap = (immap_t *)CFG_IMMR;
905 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
907 /* remove all power, put output in high impedance state */
908 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
909 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
910 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
912 /* Configure PCMCIA General Control Register */
913 debug ("Disable PCMCIA buffers and assert RESET\n");
915 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
916 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
917 PCMCIA_PGCRX(_slot_) = reg;
919 /* Switch off PCMCIA port in PIC register 0x60 */
920 reg = pic_read (0x60);
921 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
924 pic_write (0x60, reg);
926 reg = pic_read (0x60);
927 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
933 #endif /* CFG_CMD_PCMCIA */
937 static int voltage_set(int slot, int vcc, int vpp)
939 volatile immap_t *immap;
940 volatile pcmconf8xx_t *pcmp;
944 debug ("voltage_set: "
946 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
947 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
949 immap = (immap_t *)CFG_IMMR;
950 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
952 * Disable PCMCIA buffers (isolate the interface)
953 * and assert RESET signal
955 debug ("Disable PCMCIA buffers and assert RESET\n");
956 reg = PCMCIA_PGCRX(_slot_);
957 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
958 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
959 PCMCIA_PGCRX(_slot_) = reg;
963 * Turn off all power (switch to high impedance)
965 debug ("PCMCIA power OFF\n");
966 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
967 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
968 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
973 case 33: val = MAX1604_VCC_35; break;
978 /* Checking supported voltages */
980 debug ("PIPR: 0x%x --> %s\n",
982 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
984 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
986 debug ("PCMCIA powered at %sV\n",
987 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
989 debug ("PCMCIA powered down\n");
993 debug ("Enable PCMCIA buffers and stop RESET\n");
994 reg = PCMCIA_PGCRX(_slot_);
995 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
996 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
997 PCMCIA_PGCRX(_slot_) = reg;
1000 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1007 /* -------------------------------------------------------------------- */
1008 /* GTH board by Corelatus AB */
1009 /* -------------------------------------------------------------------- */
1010 #if defined(CONFIG_GTH)
1012 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
1014 static int voltage_set (int slot, int vcc, int vpp)
1019 static int hardware_enable (int slot)
1021 volatile immap_t *immap;
1022 volatile cpm8xx_t *cp;
1023 volatile pcmconf8xx_t *pcmp;
1024 volatile sysconf8xx_t *sysp;
1027 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
1029 immap = (immap_t *) CFG_IMMR;
1030 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1031 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1032 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1034 /* clear interrupt state, and disable interrupts */
1035 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1036 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1039 * Disable interrupts, DMA, and PCMCIA buffers
1040 * (isolate the interface) and assert RESET signal
1042 debug ("Disable PCMCIA buffers and assert RESET\n");
1044 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1045 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1046 PCMCIA_PGCRX (_slot_) = reg;
1050 * Make sure there is a card in the slot,
1051 * then configure the interface.
1054 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1055 __LINE__, __FUNCTION__,
1056 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1057 if (pcmp->pcmc_pipr & 0x98000000) {
1058 printf (" No Card found\n");
1062 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1063 reg = pcmp->pcmc_pipr;
1064 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1066 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1067 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1069 debug ("Enable PCMCIA buffers and stop RESET\n");
1070 reg = PCMCIA_PGCRX (_slot_);
1071 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1072 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1073 PCMCIA_PGCRX (_slot_) = reg;
1075 udelay (250000); /* some cards need >150 ms to come up :-( */
1077 debug ("# hardware_enable done\n");
1081 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1082 static int hardware_disable(int slot)
1084 return 0; /* No hardware to disable */
1086 #endif /* CFG_CMD_PCMCIA */
1087 #endif /* CONFIG_GTH */
1089 /* -------------------------------------------------------------------- */
1090 /* ICU862 Boards by Cambridge Broadband Ltd. */
1091 /* -------------------------------------------------------------------- */
1093 #if defined(CONFIG_ICU862)
1095 #define PCMCIA_BOARD_MSG "ICU862"
1097 static void cfg_port_B (void);
1099 static int hardware_enable(int slot)
1101 volatile immap_t *immap;
1102 volatile cpm8xx_t *cp;
1103 volatile pcmconf8xx_t *pcmp;
1104 volatile sysconf8xx_t *sysp;
1105 uint reg, pipr, mask;
1108 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1112 immap = (immap_t *)CFG_IMMR;
1113 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1114 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1115 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1117 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1121 * Configure SIUMCR to enable PCMCIA port B
1122 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1124 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1126 /* clear interrupt state, and disable interrupts */
1127 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1128 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1131 * Disable interrupts, DMA, and PCMCIA buffers
1132 * (isolate the interface) and assert RESET signal
1134 debug ("Disable PCMCIA buffers and assert RESET\n");
1136 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1137 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1138 PCMCIA_PGCRX(_slot_) = reg;
1142 * Make sure there is a card in the slot, then configure the interface.
1145 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1146 __LINE__,__FUNCTION__,
1147 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1148 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1149 printf (" No Card found\n");
1154 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1156 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1157 pipr = pcmp->pcmc_pipr;
1158 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1160 (reg&PCMCIA_VS1(slot))?"n":"ff",
1161 (reg&PCMCIA_VS2(slot))?"n":"ff");
1164 if ((pipr & mask) == mask) {
1165 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1166 TPS2205_VCC3); /* 3V off */
1167 reg &= ~(TPS2205_VCC5); /* 5V on */
1168 puts (" 5.0V card found: ");
1170 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1171 TPS2205_VCC5); /* 5V off */
1172 reg &= ~(TPS2205_VCC3); /* 3V on */
1173 puts (" 3.3V card found: ");
1176 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1178 (reg & TPS2205_VCC3) ? "off" : "on",
1179 (reg & TPS2205_VCC5) ? "off" : "on",
1180 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1181 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1185 /* Wait 500 ms; use this to check for over-current */
1186 for (i=0; i<5000; ++i) {
1187 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1188 printf (" *** Overcurrent - Safety shutdown ***\n");
1189 cp->cp_pbdat &= ~(TPS2205_SHDN);
1195 debug ("Enable PCMCIA buffers and stop RESET\n");
1196 reg = PCMCIA_PGCRX(_slot_);
1197 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1198 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1199 PCMCIA_PGCRX(_slot_) = reg;
1201 udelay(250000); /* some cards need >150 ms to come up :-( */
1203 debug ("# hardware_enable done\n");
1210 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1211 static int hardware_disable(int slot)
1213 volatile immap_t *immap;
1214 volatile cpm8xx_t *cp;
1215 volatile pcmconf8xx_t *pcmp;
1218 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1220 immap = (immap_t *)CFG_IMMR;
1221 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1222 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1225 cp->cp_pbdat &= ~(TPS2205_SHDN);
1227 /* Configure PCMCIA General Control Register */
1228 debug ("Disable PCMCIA buffers and assert RESET\n");
1230 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1231 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1232 PCMCIA_PGCRX(_slot_) = reg;
1238 #endif /* CFG_CMD_PCMCIA */
1242 static int voltage_set(int slot, int vcc, int vpp)
1244 volatile immap_t *immap;
1245 volatile cpm8xx_t *cp;
1246 volatile pcmconf8xx_t *pcmp;
1249 debug ("voltage_set: "
1251 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1252 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1254 immap = (immap_t *)CFG_IMMR;
1255 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1256 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1258 * Disable PCMCIA buffers (isolate the interface)
1259 * and assert RESET signal
1261 debug ("Disable PCMCIA buffers and assert RESET\n");
1262 reg = PCMCIA_PGCRX(_slot_);
1263 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1264 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1265 PCMCIA_PGCRX(_slot_) = reg;
1269 * Configure Port C pins for
1270 * 5 Volts Enable and 3 Volts enable,
1271 * Turn all power pins to Hi-Z
1273 debug ("PCMCIA power OFF\n");
1274 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1279 case 0: break; /* Switch off */
1280 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1281 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1285 /* Checking supported voltages */
1287 debug ("PIPR: 0x%x --> %s\n",
1289 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1297 if ((reg & TPS2205_VCC3) == 0) {
1299 } else if ((reg & TPS2205_VCC5) == 0) {
1304 printf ("PCMCIA powered %s\n", s);
1309 debug ("Enable PCMCIA buffers and stop RESET\n");
1310 reg = PCMCIA_PGCRX(_slot_);
1311 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1312 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1313 PCMCIA_PGCRX(_slot_) = reg;
1316 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1321 static void cfg_port_B (void)
1323 volatile immap_t *immap;
1324 volatile cpm8xx_t *cp;
1327 immap = (immap_t *)CFG_IMMR;
1328 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1331 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1333 * Switch off all voltages, assert shutdown
1336 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1337 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1338 TPS2205_SHDN); /* enable switch */
1341 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1343 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1344 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1346 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1347 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1353 /* -------------------------------------------------------------------- */
1354 /* C2MON Boards by TTTech Computertechnik AG */
1355 /* -------------------------------------------------------------------- */
1357 #if defined(CONFIG_C2MON)
1359 #define PCMCIA_BOARD_MSG "C2MON"
1361 static void cfg_ports (void);
1363 static int hardware_enable(int slot)
1365 volatile immap_t *immap;
1366 volatile cpm8xx_t *cp;
1367 volatile pcmconf8xx_t *pcmp;
1368 volatile sysconf8xx_t *sysp;
1369 uint reg, pipr, mask;
1373 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1377 immap = (immap_t *)CFG_IMMR;
1378 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1379 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1380 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1382 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1386 * Configure SIUMCR to enable PCMCIA port B
1387 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1389 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1391 /* clear interrupt state, and disable interrupts */
1392 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1393 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1396 * Disable interrupts, DMA, and PCMCIA buffers
1397 * (isolate the interface) and assert RESET signal
1399 debug ("Disable PCMCIA buffers and assert RESET\n");
1401 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1402 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1403 PCMCIA_PGCRX(_slot_) = reg;
1407 * Make sure there is a card in the slot, then configure the interface.
1410 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1411 __LINE__,__FUNCTION__,
1412 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1413 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1414 printf (" No Card found\n");
1419 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1421 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1422 pipr = pcmp->pcmc_pipr;
1423 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1425 (reg&PCMCIA_VS1(slot))?"n":"ff",
1426 (reg&PCMCIA_VS2(slot))?"n":"ff");
1428 sreg = immap->im_ioport.iop_pcdat;
1429 if ((pipr & mask) == mask) {
1430 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1431 TPS2211_VCCD1); /* 5V on */
1432 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1433 puts (" 5.0V card found: ");
1435 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1436 TPS2211_VCCD0); /* 3V on */
1437 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1438 puts (" 3.3V card found: ");
1441 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1443 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1444 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1447 immap->im_ioport.iop_pcdat = sreg;
1449 /* Wait 500 ms; use this to check for over-current */
1450 for (i=0; i<5000; ++i) {
1451 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1452 printf (" *** Overcurrent - Safety shutdown ***\n");
1453 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1459 debug ("Enable PCMCIA buffers and stop RESET\n");
1460 reg = PCMCIA_PGCRX(_slot_);
1461 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1462 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1463 PCMCIA_PGCRX(_slot_) = reg;
1465 udelay(250000); /* some cards need >150 ms to come up :-( */
1467 debug ("# hardware_enable done\n");
1474 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1475 static int hardware_disable(int slot)
1477 volatile immap_t *immap;
1478 volatile cpm8xx_t *cp;
1479 volatile pcmconf8xx_t *pcmp;
1482 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1484 immap = (immap_t *)CFG_IMMR;
1485 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1487 /* Configure PCMCIA General Control Register */
1488 debug ("Disable PCMCIA buffers and assert RESET\n");
1490 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1491 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1492 PCMCIA_PGCRX(_slot_) = reg;
1494 /* ALl voltages off / Hi-Z */
1495 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1496 TPS2211_VCCD0 | TPS2211_VCCD1 );
1502 #endif /* CFG_CMD_PCMCIA */
1506 static int voltage_set(int slot, int vcc, int vpp)
1508 volatile immap_t *immap;
1509 volatile cpm8xx_t *cp;
1510 volatile pcmconf8xx_t *pcmp;
1514 debug ("voltage_set: "
1516 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1517 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1519 immap = (immap_t *)CFG_IMMR;
1520 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1521 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1523 * Disable PCMCIA buffers (isolate the interface)
1524 * and assert RESET signal
1526 debug ("Disable PCMCIA buffers and assert RESET\n");
1527 reg = PCMCIA_PGCRX(_slot_);
1528 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1529 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1530 PCMCIA_PGCRX(_slot_) = reg;
1534 * Configure Port C pins for
1535 * 5 Volts Enable and 3 Volts enable,
1536 * Turn all power pins to Hi-Z
1538 debug ("PCMCIA power OFF\n");
1539 cfg_ports (); /* Enables switch, but all in Hi-Z */
1541 sreg = immap->im_ioport.iop_pcdat;
1542 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1545 case 0: break; /* Switch off */
1546 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1547 sreg &= ~TPS2211_VCCD1;
1549 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1550 sreg |= TPS2211_VCCD1;
1555 /* Checking supported voltages */
1557 debug ("PIPR: 0x%x --> %s\n",
1559 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1561 immap->im_ioport.iop_pcdat = sreg;
1567 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1569 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1574 printf ("PCMCIA powered %s\n", s);
1579 debug ("Enable PCMCIA buffers and stop RESET\n");
1580 reg = PCMCIA_PGCRX(_slot_);
1581 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1582 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1583 PCMCIA_PGCRX(_slot_) = reg;
1586 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1591 static void cfg_ports (void)
1593 volatile immap_t *immap;
1594 volatile cpm8xx_t *cp;
1597 immap = (immap_t *)CFG_IMMR;
1598 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1601 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1603 * Switch off all voltages, assert shutdown
1605 sreg = immap->im_ioport.iop_pcdat;
1606 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1607 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1608 immap->im_ioport.iop_pcdat = sreg;
1610 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1611 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1613 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1614 immap->im_ioport.iop_pcpar,
1615 immap->im_ioport.iop_pcdir,
1616 immap->im_ioport.iop_pcdat);
1619 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1621 * Over-Current Input only
1623 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1624 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1626 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1627 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1632 /* -------------------------------------------------------------------- */
1633 /* MBX board from Morotola */
1634 /* -------------------------------------------------------------------- */
1636 #if defined( CONFIG_MBX )
1637 #include <../board/mbx8xx/csr.h>
1639 /* A lot of this has been taken from the RPX code in this file it works from me.
1640 I have added the voltage selection for the MBX board. */
1642 /* MBX voltage bit in control register #2 */
1643 #define CR2_VPP12 ((uchar)0x10)
1644 #define CR2_VPPVDD ((uchar)0x20)
1645 #define CR2_VDD5 ((uchar)0x40)
1646 #define CR2_VDD3 ((uchar)0x80)
1648 #define PCMCIA_BOARD_MSG "MBX860"
1650 static int voltage_set (int slot, int vcc, int vpp)
1654 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1655 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1688 /* first, turn off all power */
1689 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1691 /* enable new powersettings */
1693 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1698 static int hardware_enable (int slot)
1700 volatile immap_t *immap;
1701 volatile cpm8xx_t *cp;
1702 volatile pcmconf8xx_t *pcmp;
1703 volatile sysconf8xx_t *sysp;
1706 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1711 immap = (immap_t *) CFG_IMMR;
1712 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1713 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1714 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1716 /* clear interrupt state, and disable interrupts */
1717 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1718 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1721 * Disable interrupts, DMA, and PCMCIA buffers
1722 * (isolate the interface) and assert RESET signal
1724 debug ("Disable PCMCIA buffers and assert RESET\n");
1726 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1727 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1728 PCMCIA_PGCRX (_slot_) = reg;
1731 /* remove all power */
1732 voltage_set (slot, 0, 0);
1734 * Make sure there is a card in the slot, then configure the interface.
1737 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1738 __LINE__,__FUNCTION__,
1739 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1740 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1741 printf (" No Card found\n");
1748 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1749 reg = pcmp->pcmc_pipr;
1750 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1751 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1752 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1754 if ((reg & mask) == mask) {
1755 voltage_set (_slot_, 50, 0);
1756 printf (" 5.0V card found: ");
1758 voltage_set (_slot_, 33, 0);
1759 printf (" 3.3V card found: ");
1762 debug ("Enable PCMCIA buffers and stop RESET\n");
1763 reg = PCMCIA_PGCRX (_slot_);
1764 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1765 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1766 PCMCIA_PGCRX (_slot_) = reg;
1768 udelay (250000); /* some cards need >150 ms to come up :-( */
1770 debug ("# hardware_enable done\n");
1775 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1776 static int hardware_disable (int slot)
1778 return 0; /* No hardware to disable */
1780 #endif /* CFG_CMD_PCMCIA */
1781 #endif /* CONFIG_MBX */
1782 /* -------------------------------------------------------------------- */
1784 /* -------------------------------------------------------------------- */
1786 #if defined(CONFIG_R360MPI)
1788 #define PCMCIA_BOARD_MSG "R360MPI"
1791 static int hardware_enable(int slot)
1793 volatile immap_t *immap;
1794 volatile cpm8xx_t *cp;
1795 volatile pcmconf8xx_t *pcmp;
1796 volatile sysconf8xx_t *sysp;
1799 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1803 immap = (immap_t *)CFG_IMMR;
1804 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1805 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1806 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1809 * Configure SIUMCR to enable PCMCIA port B
1810 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1812 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1814 /* clear interrupt state, and disable interrupts */
1815 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1816 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1819 * Disable interrupts, DMA, and PCMCIA buffers
1820 * (isolate the interface) and assert RESET signal
1822 debug ("Disable PCMCIA buffers and assert RESET\n");
1824 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1825 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1826 PCMCIA_PGCRX(_slot_) = reg;
1830 * Configure Ports A, B & C pins for
1831 * 5 Volts Enable and 3 Volts enable
1833 immap->im_ioport.iop_pcpar &= ~(0x0400);
1834 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1835 immap->im_ioport.iop_pcdir |= 0x0400;*/
1837 immap->im_ioport.iop_papar &= ~(0x0200);/*
1838 immap->im_ioport.iop_padir |= 0x0200;*/
1840 immap->im_ioport.iop_pbpar &= ~(0xC000);
1841 immap->im_ioport.iop_pbdir &= ~(0xC000);
1843 /* remove all power */
1845 immap->im_ioport.iop_pcdat |= 0x0400;
1846 immap->im_ioport.iop_padat |= 0x0200;
1849 * Make sure there is a card in the slot, then configure the interface.
1852 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1853 __LINE__,__FUNCTION__,
1854 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1855 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1856 printf (" No Card found\n");
1863 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1864 reg = pcmp->pcmc_pipr;
1865 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1867 (reg&PCMCIA_VS1(slot))?"n":"ff",
1868 (reg&PCMCIA_VS2(slot))?"n":"ff");
1869 if ((reg & mask) == mask) {
1870 immap->im_ioport.iop_pcdat &= ~(0x4000);
1871 puts (" 5.0V card found: ");
1873 immap->im_ioport.iop_padat &= ~(0x0002);
1874 puts (" 3.3V card found: ");
1876 immap->im_ioport.iop_pcdir |= 0x0400;
1877 immap->im_ioport.iop_padir |= 0x0200;
1879 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
1880 cp->cp_pbdir &= ~(0x0020 | 0x0010);
1881 cp->cp_pbpar &= ~(0x0020 | 0x0010);
1884 debug ("Enable PCMCIA buffers and stop RESET\n");
1885 reg = PCMCIA_PGCRX(_slot_);
1886 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1887 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1888 PCMCIA_PGCRX(_slot_) = reg;
1890 udelay(250000); /* some cards need >150 ms to come up :-( */
1892 debug ("# hardware_enable done\n");
1899 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1900 static int hardware_disable(int slot)
1902 volatile immap_t *immap;
1903 volatile pcmconf8xx_t *pcmp;
1906 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1908 immap = (immap_t *)CFG_IMMR;
1909 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1911 /* remove all power */
1912 immap->im_ioport.iop_pcdat |= 0x0400;
1913 immap->im_ioport.iop_padat |= 0x0200;
1915 /* Configure PCMCIA General Control Register */
1916 debug ("Disable PCMCIA buffers and assert RESET\n");
1918 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1919 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1920 PCMCIA_PGCRX(_slot_) = reg;
1926 #endif /* CFG_CMD_PCMCIA */
1930 static int voltage_set(int slot, int vcc, int vpp)
1932 volatile immap_t *immap;
1933 volatile pcmconf8xx_t *pcmp;
1936 debug ("voltage_set: "
1938 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1939 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1941 immap = (immap_t *)CFG_IMMR;
1942 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1944 * Disable PCMCIA buffers (isolate the interface)
1945 * and assert RESET signal
1947 debug ("Disable PCMCIA buffers and assert RESET\n");
1948 reg = PCMCIA_PGCRX(_slot_);
1949 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1950 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1951 PCMCIA_PGCRX(_slot_) = reg;
1955 * Configure Ports A & C pins for
1956 * 5 Volts Enable and 3 Volts enable,
1957 * Turn off all power
1959 debug ("PCMCIA power OFF\n");
1960 immap->im_ioport.iop_pcpar &= ~(0x0400);
1961 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1962 immap->im_ioport.iop_pcdir |= 0x0400;*/
1964 immap->im_ioport.iop_papar &= ~(0x0200);/*
1965 immap->im_ioport.iop_padir |= 0x0200;*/
1967 immap->im_ioport.iop_pcdat |= 0x0400;
1968 immap->im_ioport.iop_padat |= 0x0200;
1973 case 33: reg |= 0x0200; break;
1974 case 50: reg |= 0x0400; break;
1978 /* Checking supported voltages */
1980 debug ("PIPR: 0x%x --> %s\n",
1982 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1985 immap->im_ioport.iop_pcdat &= !reg;
1987 immap->im_ioport.iop_padat &= !reg;
1988 immap->im_ioport.iop_pcdir |= 0x0200;
1989 immap->im_ioport.iop_padir |= 0x0400;
1991 debug ("PCMCIA powered at %sV\n",
1992 (reg&0x0400) ? "5.0" : "3.3");
1994 debug ("PCMCIA powered down\n");
1998 debug ("Enable PCMCIA buffers and stop RESET\n");
1999 reg = PCMCIA_PGCRX(_slot_);
2000 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2001 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2002 PCMCIA_PGCRX(_slot_) = reg;
2005 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2010 #endif /* R360MPI */
2012 /* -------------------------------------------------------------------- */
2014 /* -------------------------------------------------------------------- */
2015 #if defined(CONFIG_KUP4K)
2017 #define PCMCIA_BOARD_MSG "KUP4K"
2019 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
2021 static int hardware_enable(int slot)
2023 volatile immap_t *immap;
2024 volatile cpm8xx_t *cp;
2025 volatile pcmconf8xx_t *pcmp;
2026 volatile sysconf8xx_t *sysp;
2029 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2033 immap = (immap_t *)CFG_IMMR;
2034 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2035 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2036 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2039 * Configure SIUMCR to enable PCMCIA port B
2040 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2042 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2044 /* clear interrupt state, and disable interrupts */
2045 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2046 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2049 * Disable interrupts, DMA, and PCMCIA buffers
2050 * (isolate the interface) and assert RESET signal
2052 debug ("Disable PCMCIA buffers and assert RESET\n");
2054 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2055 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2056 PCMCIA_PGCRX(slot) = reg;
2060 * Configure Port B pins for
2063 if (slot) { /* Slot A is built-in */
2064 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2065 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2066 /* remove all power */
2067 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2070 * Make sure there is a card in the slot, then configure the interface.
2073 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2074 __LINE__,__FUNCTION__,
2075 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2076 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2077 printf (" No Card found\n");
2084 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2085 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2086 reg = pcmp->pcmc_pipr;
2087 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2089 (reg&PCMCIA_VS1(slot))?"n":"ff",
2090 (reg&PCMCIA_VS2(slot))?"n":"ff");
2091 if ((reg & mask) == mask) {
2092 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2095 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2096 puts (" 3.3V card found: ");
2099 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2100 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2101 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2104 debug ("Enable PCMCIA buffers and stop RESET\n");
2105 reg = PCMCIA_PGCRX(slot);
2106 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2107 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2108 PCMCIA_PGCRX(slot) = reg;
2110 udelay(250000); /* some cards need >150 ms to come up :-( */
2112 debug ("# hardware_enable done\n");
2119 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2120 static int hardware_disable(int slot)
2122 volatile immap_t *immap;
2123 volatile cpm8xx_t *cp;
2124 volatile pcmconf8xx_t *pcmp;
2127 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2129 immap = (immap_t *)CFG_IMMR;
2130 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2131 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2133 /* remove all power */
2135 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2137 /* Configure PCMCIA General Control Register */
2138 debug ("Disable PCMCIA buffers and assert RESET\n");
2140 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2141 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2142 PCMCIA_PGCRX(slot) = reg;
2148 #endif /* CFG_CMD_PCMCIA */
2152 static int voltage_set(int slot, int vcc, int vpp)
2154 volatile immap_t *immap;
2155 volatile cpm8xx_t *cp;
2156 volatile pcmconf8xx_t *pcmp;
2159 debug ("voltage_set: " \
2161 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2162 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2164 if (!slot) /* Slot A is not configurable */
2167 immap = (immap_t *)CFG_IMMR;
2168 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2169 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2172 * Disable PCMCIA buffers (isolate the interface)
2173 * and assert RESET signal
2175 debug ("Disable PCMCIA buffers and assert RESET\n");
2176 reg = PCMCIA_PGCRX(slot);
2177 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2178 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2179 PCMCIA_PGCRX(slot) = reg;
2182 debug ("PCMCIA power OFF\n");
2184 * Configure Port B pins for
2187 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2188 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2189 /* remove all power */
2190 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2195 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2196 debug ("PCMCIA powered at 3.3V\n");
2199 debug ("PCMCIA: 5Volt vcc not supported\n");
2202 puts("PCMCIA: vcc not supported");
2206 /* Checking supported voltages */
2208 debug ("PIPR: 0x%x --> %s\n",
2210 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2211 ? "only 5 V --> NOT SUPPORTED"
2215 debug ("Enable PCMCIA buffers and stop RESET\n");
2216 reg = PCMCIA_PGCRX(slot);
2217 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2218 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2219 PCMCIA_PGCRX(slot) = reg;
2222 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2233 /* -------------------------------------------------------------------- */
2234 /* End of Board Specific Stuff */
2235 /* -------------------------------------------------------------------- */
2238 /* -------------------------------------------------------------------- */
2239 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2240 /* -------------------------------------------------------------------- */
2243 * Search this table to see if the windowsize is
2247 #define M8XX_SIZES_NO 32
2249 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2250 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2251 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2252 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2253 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2255 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2256 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2257 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2258 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2261 /* -------------------------------------------------------------------- */
2263 #ifndef CONFIG_I82365
2265 static u_int m8xx_get_graycode(u_int size)
2269 for (k = 0; k < M8XX_SIZES_NO; k++) {
2270 if(m8xx_size_to_gray[k] == size)
2274 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2280 #endif /* CONFIG_I82365 */
2282 /* -------------------------------------------------------------------- */
2285 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2287 u_int reg, clocks, psst, psl, psht;
2292 * We get called with IO maps setup to 0ns
2293 * if not specified by the user.
2294 * They should be 255ns.
2300 ns = 100; /* fast memory if 0 */
2304 * In PSST, PSL, PSHT fields we tell the controller
2305 * timing parameters in CLKOUT clock cycles.
2306 * CLKOUT is the same as GCLK2_50.
2309 /* how we want to adjust the timing - in percent */
2311 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2313 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2314 clocks = (clocks * ADJ) / (100*1000);
2316 if(clocks >= PCMCIA_BMT_LIMIT) {
2317 DEBUG(0, "Max access time limit reached\n");
2318 clocks = PCMCIA_BMT_LIMIT-1;
2321 psst = clocks / 7; /* setup time */
2322 psht = clocks / 7; /* hold time */
2323 psl = (clocks * 5) / 7; /* strobe length */
2325 psst += clocks - (psst + psht + psl);
2335 /* -------------------------------------------------------------------- */
2337 #ifdef CONFIG_IDE_8xx_PCCARD
2338 static void print_funcid (int func)
2342 case CISTPL_FUNCID_MULTI:
2343 puts (" Multi-Function");
2345 case CISTPL_FUNCID_MEMORY:
2348 case CISTPL_FUNCID_SERIAL:
2349 puts (" Serial Port");
2351 case CISTPL_FUNCID_PARALLEL:
2352 puts (" Parallel Port");
2354 case CISTPL_FUNCID_FIXED:
2355 puts (" Fixed Disk");
2357 case CISTPL_FUNCID_VIDEO:
2358 puts (" Video Adapter");
2360 case CISTPL_FUNCID_NETWORK:
2361 puts (" Network Adapter");
2363 case CISTPL_FUNCID_AIMS:
2364 puts (" AIMS Card");
2366 case CISTPL_FUNCID_SCSI:
2367 puts (" SCSI Adapter");
2375 #endif /* CONFIG_IDE_8xx_PCCARD */
2377 /* -------------------------------------------------------------------- */
2379 #ifdef CONFIG_IDE_8xx_PCCARD
2380 static void print_fixed (volatile uchar *p)
2388 case CISTPL_FUNCE_IDE_IFACE:
2389 { uchar iface = *(p+2);
2391 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2392 puts (" interface ");
2395 case CISTPL_FUNCE_IDE_MASTER:
2396 case CISTPL_FUNCE_IDE_SLAVE:
2397 { uchar f1 = *(p+2);
2400 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2402 if (f1 & CISTPL_IDE_UNIQUE)
2405 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2407 if (f2 & CISTPL_IDE_HAS_SLEEP)
2410 if (f2 & CISTPL_IDE_HAS_STANDBY)
2411 puts (" [standby]");
2413 if (f2 & CISTPL_IDE_HAS_IDLE)
2416 if (f2 & CISTPL_IDE_LOW_POWER)
2417 puts (" [low power]");
2419 if (f2 & CISTPL_IDE_REG_INHIBIT)
2420 puts (" [reg inhibit]");
2422 if (f2 & CISTPL_IDE_HAS_INDEX)
2425 if (f2 & CISTPL_IDE_IOIS16)
2433 #endif /* CONFIG_IDE_8xx_PCCARD */
2435 /* -------------------------------------------------------------------- */
2437 #ifdef CONFIG_IDE_8xx_PCCARD
2439 #define MAX_IDENT_CHARS 64
2440 #define MAX_IDENT_FIELDS 4
2442 static uchar *known_cards[] = {
2447 static int identify (volatile uchar *p)
2449 uchar id_str[MAX_IDENT_CHARS];
2456 return (0); /* Don't know */
2461 for (i=0; i<=4 && !done; ++i, p+=2) {
2462 while ((data = *p) != '\0') {
2468 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2478 while (--t > id_str) {
2487 for (card=known_cards; *card; ++card) {
2488 debug ("## Compare against \"%s\"\n", *card);
2489 if (strcmp(*card, id_str) == 0) { /* found! */
2490 debug ("## CARD FOUND ##\n");
2495 return (0); /* don't know */
2497 #endif /* CONFIG_IDE_8xx_PCCARD */
2499 /* -------------------------------------------------------------------- */
2501 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */