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);
90 static u_int m8xx_get_graycode(u_int size);
92 static u_int m8xx_get_speed(u_int ns, u_int is_io);
95 /* -------------------------------------------------------------------- */
97 /* look up table for pgcrx registers */
99 static u_int *pcmcia_pgcrx[2] = {
100 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
101 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
104 #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
106 #endif /* CONFIG_I82365 */
108 #ifdef CONFIG_IDE_8xx_PCCARD
109 static void print_funcid (int func);
110 static void print_fixed (volatile uchar *p);
111 static int identify (volatile uchar *p);
112 static int check_ide_device (int slot);
113 #endif /* CONFIG_IDE_8xx_PCCARD */
115 const char *indent = "\t ";
117 /* -------------------------------------------------------------------- */
119 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
121 int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
126 printf ("Usage: pinit {on | off}\n");
129 if (strcmp(argv[1],"on") == 0) {
130 rcode = pcmcia_on ();
131 } else if (strcmp(argv[1],"off") == 0) {
132 rcode = pcmcia_off ();
134 printf ("Usage: pinit {on | off}\n");
140 #endif /* CFG_CMD_PCMCIA */
142 /* -------------------------------------------------------------------- */
149 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
155 rc = check_ide_device(0);
162 #if defined(CONFIG_LWMON)
163 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
165 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
176 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
178 /* intialize the fixed memory windows */
179 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
180 base = CFG_PCMCIA_MEM_ADDR;
182 if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
183 printf ("Cannot set window size to 0x%08x\n",
184 CFG_PCMCIA_MEM_SIZE);
188 slotbit = PCMCIA_SLOT_x;
189 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
192 #if (PCMCIA_SOCKETS_NO == 2)
193 if (i == 4) /* Another slot starting from win 4 */
194 slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
197 #ifdef CONFIG_IDE_8xx_PCCARD
199 case 0: { /* map attribute memory */
200 win->or = ( PCMCIA_BSIZE_64M
205 | CFG_PCMCIA_TIMING );
209 case 1: { /* map I/O window for data reg */
210 win->or = ( PCMCIA_BSIZE_1K
215 | CFG_PCMCIA_TIMING );
219 case 2: { /* map I/O window for cmd/ctrl reg block */
220 win->or = ( PCMCIA_BSIZE_1K
225 | CFG_PCMCIA_TIMING );
228 #endif /* CONFIG_IDE_8xx_PCCARD */
229 default: /* set to not valid */
234 debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
235 i, win->br, win->or);
236 base += CFG_PCMCIA_MEM_SIZE;
240 for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
241 /* turn off voltage */
242 if ((rc = voltage_set(slot, 0, 0)))
245 /* Enable external hardware */
246 if ((rc = hardware_enable(slot)))
249 #ifdef CONFIG_IDE_8xx_PCCARD
250 if ((rc = check_ide_device(i)))
256 #endif /* CONFIG_I82365 */
258 /* -------------------------------------------------------------------- */
260 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
263 static int pcmcia_off (void)
265 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
272 static int pcmcia_off (void)
277 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
279 /* clear interrupt state, and disable interrupts */
280 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
281 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
283 /* turn off interrupt and disable CxOE */
284 PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
286 /* turn off memory windows */
287 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
289 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
290 /* disable memory window */
295 /* turn off voltage */
296 voltage_set(_slot_, 0, 0);
298 /* disable external hardware */
299 printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
300 hardware_disable(_slot_);
303 #endif /* CONFIG_I82365 */
305 #endif /* CFG_CMD_PCMCIA */
307 /* -------------------------------------------------------------------- */
309 #ifdef CONFIG_IDE_8xx_PCCARD
311 #define MAX_TUPEL_SZ 512
312 #define MAX_FEATURES 4
314 int ide_devices_found;
315 static int check_ide_device (int slot)
317 volatile uchar *ident = NULL;
318 volatile uchar *feature_p[MAX_FEATURES];
319 volatile uchar *p, *start, *addr;
323 ushort config_base = 0;
327 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
328 CFG_PCMCIA_MEM_SIZE * (slot * 4));
329 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
331 start = p = (volatile uchar *) addr;
333 while ((p - start) < MAX_TUPEL_SZ) {
337 if (code == 0xFF) { /* End of chain */
342 #if defined(DEBUG) && (DEBUG > 1)
343 { volatile uchar *q = p;
344 printf ("\nTuple code %02x length %d\n\tData:",
347 for (i = 0; i < len; ++i) {
348 printf (" %02x", *q);
358 /* Fix for broken SanDisk which may have 0x80 bit set */
362 if (n_features < MAX_FEATURES)
363 feature_p[n_features++] = p;
366 config_base = (*(p+6) << 8) + (*(p+4));
367 debug ("\n## Config_base = %04x ###\n", config_base);
374 found = identify (ident);
376 if (func_id != ((uchar)~0)) {
377 print_funcid (func_id);
379 if (func_id == CISTPL_FUNCID_FIXED)
382 return (1); /* no disk drive */
385 for (i=0; i<n_features; ++i) {
386 print_fixed (feature_p[i]);
390 printf ("unknown card type\n");
394 ide_devices_found |= (1 << slot);
396 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
397 *((uchar *)(addr + config_base)) = 1;
401 #endif /* CONFIG_IDE_8xx_PCCARD */
403 /* -------------------------------------------------------------------- */
406 /* -------------------------------------------------------------------- */
407 /* board specific stuff: */
408 /* voltage_set(), hardware_enable() and hardware_disable() */
409 /* -------------------------------------------------------------------- */
411 /* -------------------------------------------------------------------- */
412 /* RPX Boards from Embedded Planet */
413 /* -------------------------------------------------------------------- */
415 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
417 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
418 * SYPCR is write once only, therefore must the slowest memory be faster
419 * than the bus monitor or we will get a machine check due to the bus timeout.
422 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
424 #undef PCMCIA_BMT_LIMIT
425 #define PCMCIA_BMT_LIMIT (6*8)
427 static int voltage_set(int slot, int vcc, int vpp)
433 case 33: reg |= BCSR1_PCVCTL4; break;
434 case 50: reg |= BCSR1_PCVCTL5; break;
443 reg |= BCSR1_PCVCTL6;
448 reg |= BCSR1_PCVCTL7;
455 /* first, turn off all power */
457 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
458 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
460 /* enable new powersettings */
462 *((uint *)RPX_CSR_ADDR) |= reg;
467 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
468 static int hardware_enable (int slot)
470 return 0; /* No hardware to enable */
472 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
473 static int hardware_disable(int slot)
475 return 0; /* No hardware to disable */
477 #endif /* CFG_CMD_PCMCIA */
478 #endif /* CONFIG_RPXCLASSIC */
480 /* -------------------------------------------------------------------- */
481 /* (F)ADS Boards from Motorola */
482 /* -------------------------------------------------------------------- */
484 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
487 #define PCMCIA_BOARD_MSG "ADS"
488 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
490 #define PCMCIA_BOARD_MSG "FADS"
493 static int voltage_set(int slot, int vcc, int vpp)
498 case 0: reg = 0; break;
499 case 50: reg = 1; break;
500 case 120: reg = 2; break;
505 case 0: reg = 0; break;
507 case 50: reg = BCSR1_PCCVCCON; break;
510 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
511 case 50: reg = BCSR1_PCCVCC1; break;
516 /* first, turn off all power */
519 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
522 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
524 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
526 /* enable new powersettings */
529 *((uint *)BCSR1) &= ~reg;
532 *((uint *)BCSR1) |= reg;
535 *((uint *)BCSR1) |= reg << 20;
540 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
542 static int hardware_enable(int slot)
544 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
548 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
549 static int hardware_disable(int slot)
551 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
554 #endif /* CFG_CMD_PCMCIA */
558 /* -------------------------------------------------------------------- */
559 /* TQM8xxL Boards by TQ Components */
560 /* SC8xx Boards by SinoVee Microsystems */
561 /* -------------------------------------------------------------------- */
563 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)
565 #if defined(CONFIG_TQM8xxL)
566 #define PCMCIA_BOARD_MSG "TQM8xxL"
568 #if defined(CONFIG_SVM_SC8xx)
569 #define PCMCIA_BOARD_MSG "SC8xx"
572 static int hardware_enable(int slot)
574 volatile immap_t *immap;
575 volatile cpm8xx_t *cp;
576 volatile pcmconf8xx_t *pcmp;
577 volatile sysconf8xx_t *sysp;
580 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
584 immap = (immap_t *)CFG_IMMR;
585 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
586 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
587 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
590 * Configure SIUMCR to enable PCMCIA port B
591 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
593 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
595 /* clear interrupt state, and disable interrupts */
596 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
597 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
600 * Disable interrupts, DMA, and PCMCIA buffers
601 * (isolate the interface) and assert RESET signal
603 debug ("Disable PCMCIA buffers and assert RESET\n");
605 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
606 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
607 PCMCIA_PGCRX(_slot_) = reg;
611 * Configure Port C pins for
612 * 5 Volts Enable and 3 Volts enable
614 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
615 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
616 /* remove all power */
618 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
621 * Make sure there is a card in the slot, then configure the interface.
624 debug ("[%d] %s: PIPR(%p)=0x%x\n",
625 __LINE__,__FUNCTION__,
626 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
627 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
628 printf (" No Card found\n");
635 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
636 reg = pcmp->pcmc_pipr;
637 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
639 (reg&PCMCIA_VS1(slot))?"n":"ff",
640 (reg&PCMCIA_VS2(slot))?"n":"ff");
641 if ((reg & mask) == mask) {
642 immap->im_ioport.iop_pcdat |= 0x0004;
643 puts (" 5.0V card found: ");
645 immap->im_ioport.iop_pcdat |= 0x0002;
646 puts (" 3.3V card found: ");
648 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
650 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
651 cp->cp_pbdir &= ~(0x0020 | 0x0010);
652 cp->cp_pbpar &= ~(0x0020 | 0x0010);
656 debug ("Enable PCMCIA buffers and stop RESET\n");
657 reg = PCMCIA_PGCRX(_slot_);
658 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
659 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
660 PCMCIA_PGCRX(_slot_) = reg;
662 udelay(250000); /* some cards need >150 ms to come up :-( */
664 debug ("# hardware_enable done\n");
671 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
672 static int hardware_disable(int slot)
674 volatile immap_t *immap;
675 volatile pcmconf8xx_t *pcmp;
678 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
680 immap = (immap_t *)CFG_IMMR;
681 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
683 /* remove all power */
684 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
686 debug ("Disable PCMCIA buffers and assert RESET\n");
688 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
689 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
690 PCMCIA_PGCRX(_slot_) = reg;
696 #endif /* CFG_CMD_PCMCIA */
700 static int voltage_set(int slot, int vcc, int vpp)
702 volatile immap_t *immap;
703 volatile pcmconf8xx_t *pcmp;
706 debug ("voltage_set: "
708 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
709 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
711 immap = (immap_t *)CFG_IMMR;
712 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
714 * Disable PCMCIA buffers (isolate the interface)
715 * and assert RESET signal
717 debug ("Disable PCMCIA buffers and assert RESET\n");
718 reg = PCMCIA_PGCRX(_slot_);
719 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
720 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
721 PCMCIA_PGCRX(_slot_) = reg;
725 * Configure Port C pins for
726 * 5 Volts Enable and 3 Volts enable,
729 debug ("PCMCIA power OFF\n");
730 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
731 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
732 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
737 case 33: reg |= 0x0002; break;
738 case 50: reg |= 0x0004; break;
742 /* Checking supported voltages */
744 debug ("PIPR: 0x%x --> %s\n",
746 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
748 immap->im_ioport.iop_pcdat |= reg;
749 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
751 debug ("PCMCIA powered at %sV\n",
752 (reg&0x0004) ? "5.0" : "3.3");
754 debug ("PCMCIA powered down\n");
758 debug ("Enable PCMCIA buffers and stop RESET\n");
759 reg = PCMCIA_PGCRX(_slot_);
760 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
761 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
762 PCMCIA_PGCRX(_slot_) = reg;
765 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
773 /* -------------------------------------------------------------------- */
775 /* -------------------------------------------------------------------- */
777 #if defined(CONFIG_LWMON)
779 #define PCMCIA_BOARD_MSG "LWMON"
781 /* #define's for MAX1604 Power Switch */
782 #define MAX1604_OP_SUS 0x80
783 #define MAX1604_VCCBON 0x40
784 #define MAX1604_VCC_35 0x20
785 #define MAX1604_VCCBHIZ 0x10
786 #define MAX1604_VPPBON 0x08
787 #define MAX1604_VPPBPBPGM 0x04
788 #define MAX1604_VPPBHIZ 0x02
791 static int hardware_enable(int slot)
793 volatile immap_t *immap;
794 volatile cpm8xx_t *cp;
795 volatile pcmconf8xx_t *pcmp;
796 volatile sysconf8xx_t *sysp;
801 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
803 /* Switch on PCMCIA port in PIC register 0x60 */
804 reg = pic_read (0x60);
805 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
807 /* reg |= 0x08; Vpp not needed */
808 pic_write (0x60, reg);
810 reg = pic_read (0x60);
811 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
815 immap = (immap_t *)CFG_IMMR;
816 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
817 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
818 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
821 * Configure SIUMCR to enable PCMCIA port B
822 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
824 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
826 /* clear interrupt state, and disable interrupts */
827 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
828 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
831 * Disable interrupts, DMA, and PCMCIA buffers
832 * (isolate the interface) and assert RESET signal
834 debug ("Disable PCMCIA buffers and assert RESET\n");
836 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
837 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
838 PCMCIA_PGCRX(_slot_) = reg;
842 * Make sure there is a card in the slot, then configure the interface.
845 debug ("[%d] %s: PIPR(%p)=0x%x\n",
846 __LINE__,__FUNCTION__,
847 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
848 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
849 printf (" No Card found\n");
856 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
857 reg = pcmp->pcmc_pipr;
858 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
860 (reg&PCMCIA_VS1(slot))?"n":"ff",
861 (reg&PCMCIA_VS2(slot))?"n":"ff");
862 if ((reg & mask) == mask) {
863 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
864 puts (" 5.0V card found: ");
866 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
867 puts (" 3.3V card found: ");
871 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
872 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
873 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
877 debug ("Enable PCMCIA buffers and stop RESET\n");
878 reg = PCMCIA_PGCRX(_slot_);
879 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
880 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
881 PCMCIA_PGCRX(_slot_) = reg;
883 udelay(250000); /* some cards need >150 ms to come up :-( */
885 debug ("# hardware_enable done\n");
892 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
893 static int hardware_disable(int slot)
895 volatile immap_t *immap;
896 volatile pcmconf8xx_t *pcmp;
900 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
902 immap = (immap_t *)CFG_IMMR;
903 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
905 /* remove all power, put output in high impedance state */
906 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
907 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
908 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
910 /* Configure PCMCIA General Control Register */
911 debug ("Disable PCMCIA buffers and assert RESET\n");
913 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
914 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
915 PCMCIA_PGCRX(_slot_) = reg;
917 /* Switch off PCMCIA port in PIC register 0x60 */
918 reg = pic_read (0x60);
919 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
922 pic_write (0x60, reg);
924 reg = pic_read (0x60);
925 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
931 #endif /* CFG_CMD_PCMCIA */
935 static int voltage_set(int slot, int vcc, int vpp)
937 volatile immap_t *immap;
938 volatile pcmconf8xx_t *pcmp;
942 debug ("voltage_set: "
944 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
945 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
947 immap = (immap_t *)CFG_IMMR;
948 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
950 * Disable PCMCIA buffers (isolate the interface)
951 * and assert RESET signal
953 debug ("Disable PCMCIA buffers and assert RESET\n");
954 reg = PCMCIA_PGCRX(_slot_);
955 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
956 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
957 PCMCIA_PGCRX(_slot_) = reg;
961 * Turn off all power (switch to high impedance)
963 debug ("PCMCIA power OFF\n");
964 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
965 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
966 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
971 case 33: val = MAX1604_VCC_35; break;
976 /* Checking supported voltages */
978 debug ("PIPR: 0x%x --> %s\n",
980 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
982 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
984 debug ("PCMCIA powered at %sV\n",
985 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
987 debug ("PCMCIA powered down\n");
991 debug ("Enable PCMCIA buffers and stop RESET\n");
992 reg = PCMCIA_PGCRX(_slot_);
993 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
994 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
995 PCMCIA_PGCRX(_slot_) = reg;
998 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1005 /* -------------------------------------------------------------------- */
1006 /* GTH board by Corelatus AB */
1007 /* -------------------------------------------------------------------- */
1008 #if defined(CONFIG_GTH)
1010 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
1012 static int voltage_set (int slot, int vcc, int vpp)
1017 static int hardware_enable (int slot)
1019 volatile immap_t *immap;
1020 volatile cpm8xx_t *cp;
1021 volatile pcmconf8xx_t *pcmp;
1022 volatile sysconf8xx_t *sysp;
1025 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
1027 immap = (immap_t *) CFG_IMMR;
1028 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1029 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1030 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1032 /* clear interrupt state, and disable interrupts */
1033 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1034 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1037 * Disable interrupts, DMA, and PCMCIA buffers
1038 * (isolate the interface) and assert RESET signal
1040 debug ("Disable PCMCIA buffers and assert RESET\n");
1042 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1043 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1044 PCMCIA_PGCRX (_slot_) = reg;
1048 * Make sure there is a card in the slot,
1049 * then configure the interface.
1052 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1053 __LINE__, __FUNCTION__,
1054 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1055 if (pcmp->pcmc_pipr & 0x98000000) {
1056 printf (" No Card found\n");
1060 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1061 reg = pcmp->pcmc_pipr;
1062 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1064 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1065 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1067 debug ("Enable PCMCIA buffers and stop RESET\n");
1068 reg = PCMCIA_PGCRX (_slot_);
1069 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1070 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1071 PCMCIA_PGCRX (_slot_) = reg;
1073 udelay (250000); /* some cards need >150 ms to come up :-( */
1075 debug ("# hardware_enable done\n");
1079 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1080 static int hardware_disable(int slot)
1082 return 0; /* No hardware to disable */
1084 #endif /* CFG_CMD_PCMCIA */
1085 #endif /* CONFIG_GTH */
1087 /* -------------------------------------------------------------------- */
1088 /* ICU862 Boards by Cambridge Broadband Ltd. */
1089 /* -------------------------------------------------------------------- */
1091 #if defined(CONFIG_ICU862)
1093 #define PCMCIA_BOARD_MSG "ICU862"
1095 static void cfg_port_B (void);
1097 static int hardware_enable(int slot)
1099 volatile immap_t *immap;
1100 volatile cpm8xx_t *cp;
1101 volatile pcmconf8xx_t *pcmp;
1102 volatile sysconf8xx_t *sysp;
1103 uint reg, pipr, mask;
1106 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1110 immap = (immap_t *)CFG_IMMR;
1111 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1112 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1113 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1115 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1119 * Configure SIUMCR to enable PCMCIA port B
1120 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1122 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1124 /* clear interrupt state, and disable interrupts */
1125 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1126 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1129 * Disable interrupts, DMA, and PCMCIA buffers
1130 * (isolate the interface) and assert RESET signal
1132 debug ("Disable PCMCIA buffers and assert RESET\n");
1134 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1135 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1136 PCMCIA_PGCRX(_slot_) = reg;
1140 * Make sure there is a card in the slot, then configure the interface.
1143 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1144 __LINE__,__FUNCTION__,
1145 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1146 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1147 printf (" No Card found\n");
1152 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1154 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1155 pipr = pcmp->pcmc_pipr;
1156 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1158 (reg&PCMCIA_VS1(slot))?"n":"ff",
1159 (reg&PCMCIA_VS2(slot))?"n":"ff");
1162 if ((pipr & mask) == mask) {
1163 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1164 TPS2205_VCC3); /* 3V off */
1165 reg &= ~(TPS2205_VCC5); /* 5V on */
1166 puts (" 5.0V card found: ");
1168 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1169 TPS2205_VCC5); /* 5V off */
1170 reg &= ~(TPS2205_VCC3); /* 3V on */
1171 puts (" 3.3V card found: ");
1174 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1176 (reg & TPS2205_VCC3) ? "off" : "on",
1177 (reg & TPS2205_VCC5) ? "off" : "on",
1178 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1179 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1183 /* Wait 500 ms; use this to check for over-current */
1184 for (i=0; i<5000; ++i) {
1185 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1186 printf (" *** Overcurrent - Safety shutdown ***\n");
1187 cp->cp_pbdat &= ~(TPS2205_SHDN);
1193 debug ("Enable PCMCIA buffers and stop 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;
1199 udelay(250000); /* some cards need >150 ms to come up :-( */
1201 debug ("# hardware_enable done\n");
1208 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1209 static int hardware_disable(int slot)
1211 volatile immap_t *immap;
1212 volatile cpm8xx_t *cp;
1213 volatile pcmconf8xx_t *pcmp;
1216 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1218 immap = (immap_t *)CFG_IMMR;
1219 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1220 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1223 cp->cp_pbdat &= ~(TPS2205_SHDN);
1225 /* Configure PCMCIA General Control Register */
1226 debug ("Disable PCMCIA buffers and assert RESET\n");
1228 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1229 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1230 PCMCIA_PGCRX(_slot_) = reg;
1236 #endif /* CFG_CMD_PCMCIA */
1240 static int voltage_set(int slot, int vcc, int vpp)
1242 volatile immap_t *immap;
1243 volatile cpm8xx_t *cp;
1244 volatile pcmconf8xx_t *pcmp;
1247 debug ("voltage_set: "
1249 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1250 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1252 immap = (immap_t *)CFG_IMMR;
1253 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1254 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1256 * Disable PCMCIA buffers (isolate the interface)
1257 * and assert RESET signal
1259 debug ("Disable PCMCIA buffers and assert RESET\n");
1260 reg = PCMCIA_PGCRX(_slot_);
1261 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1262 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1263 PCMCIA_PGCRX(_slot_) = reg;
1267 * Configure Port C pins for
1268 * 5 Volts Enable and 3 Volts enable,
1269 * Turn all power pins to Hi-Z
1271 debug ("PCMCIA power OFF\n");
1272 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1277 case 0: break; /* Switch off */
1278 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1279 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1283 /* Checking supported voltages */
1285 debug ("PIPR: 0x%x --> %s\n",
1287 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1295 if ((reg & TPS2205_VCC3) == 0) {
1297 } else if ((reg & TPS2205_VCC5) == 0) {
1302 printf ("PCMCIA powered %s\n", s);
1307 debug ("Enable PCMCIA buffers and stop RESET\n");
1308 reg = PCMCIA_PGCRX(_slot_);
1309 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1310 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1311 PCMCIA_PGCRX(_slot_) = reg;
1314 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1319 static void cfg_port_B (void)
1321 volatile immap_t *immap;
1322 volatile cpm8xx_t *cp;
1325 immap = (immap_t *)CFG_IMMR;
1326 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1329 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1331 * Switch off all voltages, assert shutdown
1334 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1335 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1336 TPS2205_SHDN); /* enable switch */
1339 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1341 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1342 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1344 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1345 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1351 /* -------------------------------------------------------------------- */
1352 /* C2MON Boards by TTTech Computertechnik AG */
1353 /* -------------------------------------------------------------------- */
1355 #if defined(CONFIG_C2MON)
1357 #define PCMCIA_BOARD_MSG "C2MON"
1359 static void cfg_ports (void);
1361 static int hardware_enable(int slot)
1363 volatile immap_t *immap;
1364 volatile cpm8xx_t *cp;
1365 volatile pcmconf8xx_t *pcmp;
1366 volatile sysconf8xx_t *sysp;
1367 uint reg, pipr, mask;
1371 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1375 immap = (immap_t *)CFG_IMMR;
1376 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1377 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1378 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1380 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1384 * Configure SIUMCR to enable PCMCIA port B
1385 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1387 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1389 /* clear interrupt state, and disable interrupts */
1390 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1391 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1394 * Disable interrupts, DMA, and PCMCIA buffers
1395 * (isolate the interface) and assert RESET signal
1397 debug ("Disable PCMCIA buffers and assert RESET\n");
1399 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1400 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1401 PCMCIA_PGCRX(_slot_) = reg;
1405 * Make sure there is a card in the slot, then configure the interface.
1408 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1409 __LINE__,__FUNCTION__,
1410 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1411 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1412 printf (" No Card found\n");
1417 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1419 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1420 pipr = pcmp->pcmc_pipr;
1421 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1423 (reg&PCMCIA_VS1(slot))?"n":"ff",
1424 (reg&PCMCIA_VS2(slot))?"n":"ff");
1426 sreg = immap->im_ioport.iop_pcdat;
1427 if ((pipr & mask) == mask) {
1428 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1429 TPS2211_VCCD1); /* 5V on */
1430 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1431 puts (" 5.0V card found: ");
1433 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1434 TPS2211_VCCD0); /* 3V on */
1435 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1436 puts (" 3.3V card found: ");
1439 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1441 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1442 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1445 immap->im_ioport.iop_pcdat = sreg;
1447 /* Wait 500 ms; use this to check for over-current */
1448 for (i=0; i<5000; ++i) {
1449 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1450 printf (" *** Overcurrent - Safety shutdown ***\n");
1451 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1457 debug ("Enable PCMCIA buffers and stop RESET\n");
1458 reg = PCMCIA_PGCRX(_slot_);
1459 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1460 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1461 PCMCIA_PGCRX(_slot_) = reg;
1463 udelay(250000); /* some cards need >150 ms to come up :-( */
1465 debug ("# hardware_enable done\n");
1472 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1473 static int hardware_disable(int slot)
1475 volatile immap_t *immap;
1476 volatile cpm8xx_t *cp;
1477 volatile pcmconf8xx_t *pcmp;
1480 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1482 immap = (immap_t *)CFG_IMMR;
1483 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1485 /* Configure PCMCIA General Control Register */
1486 debug ("Disable PCMCIA buffers and assert RESET\n");
1488 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1489 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1490 PCMCIA_PGCRX(_slot_) = reg;
1492 /* ALl voltages off / Hi-Z */
1493 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1494 TPS2211_VCCD0 | TPS2211_VCCD1 );
1500 #endif /* CFG_CMD_PCMCIA */
1504 static int voltage_set(int slot, int vcc, int vpp)
1506 volatile immap_t *immap;
1507 volatile cpm8xx_t *cp;
1508 volatile pcmconf8xx_t *pcmp;
1512 debug ("voltage_set: "
1514 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1515 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1517 immap = (immap_t *)CFG_IMMR;
1518 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1519 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1521 * Disable PCMCIA buffers (isolate the interface)
1522 * and assert RESET signal
1524 debug ("Disable PCMCIA buffers and assert RESET\n");
1525 reg = PCMCIA_PGCRX(_slot_);
1526 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1527 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1528 PCMCIA_PGCRX(_slot_) = reg;
1532 * Configure Port C pins for
1533 * 5 Volts Enable and 3 Volts enable,
1534 * Turn all power pins to Hi-Z
1536 debug ("PCMCIA power OFF\n");
1537 cfg_ports (); /* Enables switch, but all in Hi-Z */
1539 sreg = immap->im_ioport.iop_pcdat;
1540 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1543 case 0: break; /* Switch off */
1544 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1545 sreg &= ~TPS2211_VCCD1;
1547 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1548 sreg |= TPS2211_VCCD1;
1553 /* Checking supported voltages */
1555 debug ("PIPR: 0x%x --> %s\n",
1557 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1559 immap->im_ioport.iop_pcdat = sreg;
1565 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1567 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1572 printf ("PCMCIA powered %s\n", s);
1577 debug ("Enable PCMCIA buffers and stop RESET\n");
1578 reg = PCMCIA_PGCRX(_slot_);
1579 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1580 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1581 PCMCIA_PGCRX(_slot_) = reg;
1584 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1589 static void cfg_ports (void)
1591 volatile immap_t *immap;
1592 volatile cpm8xx_t *cp;
1595 immap = (immap_t *)CFG_IMMR;
1596 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1599 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1601 * Switch off all voltages, assert shutdown
1603 sreg = immap->im_ioport.iop_pcdat;
1604 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1605 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1606 immap->im_ioport.iop_pcdat = sreg;
1608 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1609 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1611 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1612 immap->im_ioport.iop_pcpar,
1613 immap->im_ioport.iop_pcdir,
1614 immap->im_ioport.iop_pcdat);
1617 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1619 * Over-Current Input only
1621 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1622 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1624 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1625 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1630 /* -------------------------------------------------------------------- */
1631 /* MBX board from Morotola */
1632 /* -------------------------------------------------------------------- */
1634 #if defined( CONFIG_MBX )
1635 #include <../board/mbx8xx/csr.h>
1637 /* A lot of this has been taken from the RPX code in this file it works from me.
1638 I have added the voltage selection for the MBX board. */
1640 /* MBX voltage bit in control register #2 */
1641 #define CR2_VPP12 ((uchar)0x10)
1642 #define CR2_VPPVDD ((uchar)0x20)
1643 #define CR2_VDD5 ((uchar)0x40)
1644 #define CR2_VDD3 ((uchar)0x80)
1646 #define PCMCIA_BOARD_MSG "MBX860"
1648 static int voltage_set (int slot, int vcc, int vpp)
1652 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1653 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1686 /* first, turn off all power */
1687 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1689 /* enable new powersettings */
1691 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1696 static int hardware_enable (int slot)
1698 volatile immap_t *immap;
1699 volatile cpm8xx_t *cp;
1700 volatile pcmconf8xx_t *pcmp;
1701 volatile sysconf8xx_t *sysp;
1704 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1709 immap = (immap_t *) CFG_IMMR;
1710 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1711 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1712 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1714 /* clear interrupt state, and disable interrupts */
1715 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1716 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1719 * Disable interrupts, DMA, and PCMCIA buffers
1720 * (isolate the interface) and assert RESET signal
1722 debug ("Disable PCMCIA buffers and assert RESET\n");
1724 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1725 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1726 PCMCIA_PGCRX (_slot_) = reg;
1729 /* remove all power */
1730 voltage_set (slot, 0, 0);
1732 * Make sure there is a card in the slot, then configure the interface.
1735 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1736 __LINE__,__FUNCTION__,
1737 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1738 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1739 printf (" No Card found\n");
1746 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1747 reg = pcmp->pcmc_pipr;
1748 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1749 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1750 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1752 if ((reg & mask) == mask) {
1753 voltage_set (_slot_, 50, 0);
1754 printf (" 5.0V card found: ");
1756 voltage_set (_slot_, 33, 0);
1757 printf (" 3.3V card found: ");
1760 debug ("Enable PCMCIA buffers and stop RESET\n");
1761 reg = PCMCIA_PGCRX (_slot_);
1762 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1763 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1764 PCMCIA_PGCRX (_slot_) = reg;
1766 udelay (250000); /* some cards need >150 ms to come up :-( */
1768 debug ("# hardware_enable done\n");
1773 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1774 static int hardware_disable (int slot)
1776 return 0; /* No hardware to disable */
1778 #endif /* CFG_CMD_PCMCIA */
1779 #endif /* CONFIG_MBX */
1780 /* -------------------------------------------------------------------- */
1782 /* -------------------------------------------------------------------- */
1784 #if defined(CONFIG_R360MPI)
1786 #define PCMCIA_BOARD_MSG "R360MPI"
1789 static int hardware_enable(int slot)
1791 volatile immap_t *immap;
1792 volatile cpm8xx_t *cp;
1793 volatile pcmconf8xx_t *pcmp;
1794 volatile sysconf8xx_t *sysp;
1797 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1801 immap = (immap_t *)CFG_IMMR;
1802 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1803 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1804 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1807 * Configure SIUMCR to enable PCMCIA port B
1808 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1810 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1812 /* clear interrupt state, and disable interrupts */
1813 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1814 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1817 * Disable interrupts, DMA, and PCMCIA buffers
1818 * (isolate the interface) and assert RESET signal
1820 debug ("Disable PCMCIA buffers and assert RESET\n");
1822 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1823 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1824 PCMCIA_PGCRX(_slot_) = reg;
1828 * Configure Ports A, B & C pins for
1829 * 5 Volts Enable and 3 Volts enable
1831 immap->im_ioport.iop_pcpar &= ~(0x0400);
1832 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1833 immap->im_ioport.iop_pcdir |= 0x0400;*/
1835 immap->im_ioport.iop_papar &= ~(0x0200);/*
1836 immap->im_ioport.iop_padir |= 0x0200;*/
1838 immap->im_ioport.iop_pbpar &= ~(0xC000);
1839 immap->im_ioport.iop_pbdir &= ~(0xC000);
1841 /* remove all power */
1843 immap->im_ioport.iop_pcdat |= 0x0400;
1844 immap->im_ioport.iop_padat |= 0x0200;
1847 * Make sure there is a card in the slot, then configure the interface.
1850 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1851 __LINE__,__FUNCTION__,
1852 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1853 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1854 printf (" No Card found\n");
1861 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1862 reg = pcmp->pcmc_pipr;
1863 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1865 (reg&PCMCIA_VS1(slot))?"n":"ff",
1866 (reg&PCMCIA_VS2(slot))?"n":"ff");
1867 if ((reg & mask) == mask) {
1868 immap->im_ioport.iop_pcdat &= ~(0x4000);
1869 puts (" 5.0V card found: ");
1871 immap->im_ioport.iop_padat &= ~(0x0002);
1872 puts (" 3.3V card found: ");
1874 immap->im_ioport.iop_pcdir |= 0x0400;
1875 immap->im_ioport.iop_padir |= 0x0200;
1877 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
1878 cp->cp_pbdir &= ~(0x0020 | 0x0010);
1879 cp->cp_pbpar &= ~(0x0020 | 0x0010);
1882 debug ("Enable PCMCIA buffers and stop RESET\n");
1883 reg = PCMCIA_PGCRX(_slot_);
1884 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1885 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1886 PCMCIA_PGCRX(_slot_) = reg;
1888 udelay(250000); /* some cards need >150 ms to come up :-( */
1890 debug ("# hardware_enable done\n");
1897 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1898 static int hardware_disable(int slot)
1900 volatile immap_t *immap;
1901 volatile pcmconf8xx_t *pcmp;
1904 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1906 immap = (immap_t *)CFG_IMMR;
1907 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1909 /* remove all power */
1910 immap->im_ioport.iop_pcdat |= 0x0400;
1911 immap->im_ioport.iop_padat |= 0x0200;
1913 /* Configure PCMCIA General Control Register */
1914 debug ("Disable PCMCIA buffers and assert RESET\n");
1916 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1917 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1918 PCMCIA_PGCRX(_slot_) = reg;
1924 #endif /* CFG_CMD_PCMCIA */
1928 static int voltage_set(int slot, int vcc, int vpp)
1930 volatile immap_t *immap;
1931 volatile pcmconf8xx_t *pcmp;
1934 debug ("voltage_set: "
1936 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1937 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1939 immap = (immap_t *)CFG_IMMR;
1940 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1942 * Disable PCMCIA buffers (isolate the interface)
1943 * and assert RESET signal
1945 debug ("Disable PCMCIA buffers and assert RESET\n");
1946 reg = PCMCIA_PGCRX(_slot_);
1947 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1948 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1949 PCMCIA_PGCRX(_slot_) = reg;
1953 * Configure Ports A & C pins for
1954 * 5 Volts Enable and 3 Volts enable,
1955 * Turn off all power
1957 debug ("PCMCIA power OFF\n");
1958 immap->im_ioport.iop_pcpar &= ~(0x0400);
1959 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1960 immap->im_ioport.iop_pcdir |= 0x0400;*/
1962 immap->im_ioport.iop_papar &= ~(0x0200);/*
1963 immap->im_ioport.iop_padir |= 0x0200;*/
1965 immap->im_ioport.iop_pcdat |= 0x0400;
1966 immap->im_ioport.iop_padat |= 0x0200;
1971 case 33: reg |= 0x0200; break;
1972 case 50: reg |= 0x0400; break;
1976 /* Checking supported voltages */
1978 debug ("PIPR: 0x%x --> %s\n",
1980 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1983 immap->im_ioport.iop_pcdat &= !reg;
1985 immap->im_ioport.iop_padat &= !reg;
1986 immap->im_ioport.iop_pcdir |= 0x0200;
1987 immap->im_ioport.iop_padir |= 0x0400;
1989 debug ("PCMCIA powered at %sV\n",
1990 (reg&0x0400) ? "5.0" : "3.3");
1992 debug ("PCMCIA powered down\n");
1996 debug ("Enable PCMCIA buffers and stop RESET\n");
1997 reg = PCMCIA_PGCRX(_slot_);
1998 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1999 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2000 PCMCIA_PGCRX(_slot_) = reg;
2003 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2008 #endif /* R360MPI */
2010 /* -------------------------------------------------------------------- */
2012 /* -------------------------------------------------------------------- */
2013 #if defined(CONFIG_KUP4K)
2015 #define PCMCIA_BOARD_MSG "KUP4K"
2017 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
2019 static int hardware_enable(int slot)
2021 volatile immap_t *immap;
2022 volatile cpm8xx_t *cp;
2023 volatile pcmconf8xx_t *pcmp;
2024 volatile sysconf8xx_t *sysp;
2027 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2031 immap = (immap_t *)CFG_IMMR;
2032 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
2033 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2034 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2037 * Configure SIUMCR to enable PCMCIA port B
2038 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
2040 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
2042 /* clear interrupt state, and disable interrupts */
2043 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
2044 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
2047 * Disable interrupts, DMA, and PCMCIA buffers
2048 * (isolate the interface) and assert RESET signal
2050 debug ("Disable PCMCIA buffers and assert RESET\n");
2052 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2053 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2054 PCMCIA_PGCRX(slot) = reg;
2058 * Configure Port B pins for
2061 if (slot) { /* Slot A is built-in */
2062 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2063 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2064 /* remove all power */
2065 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2068 * Make sure there is a card in the slot, then configure the interface.
2071 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2072 __LINE__,__FUNCTION__,
2073 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2074 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2075 printf (" No Card found\n");
2082 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2083 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2084 reg = pcmp->pcmc_pipr;
2085 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2087 (reg&PCMCIA_VS1(slot))?"n":"ff",
2088 (reg&PCMCIA_VS2(slot))?"n":"ff");
2089 if ((reg & mask) == mask) {
2090 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2093 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2094 puts (" 3.3V card found: ");
2097 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2098 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2099 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2102 debug ("Enable PCMCIA buffers and stop RESET\n");
2103 reg = PCMCIA_PGCRX(slot);
2104 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2105 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2106 PCMCIA_PGCRX(slot) = reg;
2108 udelay(250000); /* some cards need >150 ms to come up :-( */
2110 debug ("# hardware_enable done\n");
2117 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2118 static int hardware_disable(int slot)
2120 volatile immap_t *immap;
2121 volatile cpm8xx_t *cp;
2122 volatile pcmconf8xx_t *pcmp;
2125 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2127 immap = (immap_t *)CFG_IMMR;
2128 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2129 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2131 /* remove all power */
2133 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2135 /* Configure PCMCIA General Control Register */
2136 debug ("Disable PCMCIA buffers and assert RESET\n");
2138 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2139 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2140 PCMCIA_PGCRX(slot) = reg;
2146 #endif /* CFG_CMD_PCMCIA */
2150 static int voltage_set(int slot, int vcc, int vpp)
2152 volatile immap_t *immap;
2153 volatile cpm8xx_t *cp;
2154 volatile pcmconf8xx_t *pcmp;
2157 debug ("voltage_set: " \
2159 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2160 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2162 if (!slot) /* Slot A is not configurable */
2165 immap = (immap_t *)CFG_IMMR;
2166 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2167 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2170 * Disable PCMCIA buffers (isolate the interface)
2171 * and assert RESET signal
2173 debug ("Disable PCMCIA buffers and assert RESET\n");
2174 reg = PCMCIA_PGCRX(slot);
2175 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2176 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2177 PCMCIA_PGCRX(slot) = reg;
2180 debug ("PCMCIA power OFF\n");
2182 * Configure Port B pins for
2185 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2186 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2187 /* remove all power */
2188 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2193 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2194 debug ("PCMCIA powered at 3.3V\n");
2197 debug ("PCMCIA: 5Volt vcc not supported\n");
2200 puts("PCMCIA: vcc not supported");
2204 /* Checking supported voltages */
2206 debug ("PIPR: 0x%x --> %s\n",
2208 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2209 ? "only 5 V --> NOT SUPPORTED"
2213 debug ("Enable PCMCIA buffers and stop RESET\n");
2214 reg = PCMCIA_PGCRX(slot);
2215 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2216 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2217 PCMCIA_PGCRX(slot) = reg;
2220 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2231 /* -------------------------------------------------------------------- */
2232 /* End of Board Specific Stuff */
2233 /* -------------------------------------------------------------------- */
2236 /* -------------------------------------------------------------------- */
2237 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2238 /* -------------------------------------------------------------------- */
2241 * Search this table to see if the windowsize is
2245 #define M8XX_SIZES_NO 32
2247 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2248 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2249 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2250 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2251 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2253 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2254 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2255 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2256 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2259 /* -------------------------------------------------------------------- */
2261 static u_int m8xx_get_graycode(u_int size)
2265 for (k = 0; k < M8XX_SIZES_NO; k++) {
2266 if(m8xx_size_to_gray[k] == size)
2270 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2276 /* -------------------------------------------------------------------- */
2279 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2281 u_int reg, clocks, psst, psl, psht;
2286 * We get called with IO maps setup to 0ns
2287 * if not specified by the user.
2288 * They should be 255ns.
2294 ns = 100; /* fast memory if 0 */
2298 * In PSST, PSL, PSHT fields we tell the controller
2299 * timing parameters in CLKOUT clock cycles.
2300 * CLKOUT is the same as GCLK2_50.
2303 /* how we want to adjust the timing - in percent */
2305 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2307 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2308 clocks = (clocks * ADJ) / (100*1000);
2310 if(clocks >= PCMCIA_BMT_LIMIT) {
2311 DEBUG(0, "Max access time limit reached\n");
2312 clocks = PCMCIA_BMT_LIMIT-1;
2315 psst = clocks / 7; /* setup time */
2316 psht = clocks / 7; /* hold time */
2317 psl = (clocks * 5) / 7; /* strobe length */
2319 psst += clocks - (psst + psht + psl);
2329 /* -------------------------------------------------------------------- */
2331 #ifdef CONFIG_IDE_8xx_PCCARD
2332 static void print_funcid (int func)
2336 case CISTPL_FUNCID_MULTI:
2337 puts (" Multi-Function");
2339 case CISTPL_FUNCID_MEMORY:
2342 case CISTPL_FUNCID_SERIAL:
2343 puts (" Serial Port");
2345 case CISTPL_FUNCID_PARALLEL:
2346 puts (" Parallel Port");
2348 case CISTPL_FUNCID_FIXED:
2349 puts (" Fixed Disk");
2351 case CISTPL_FUNCID_VIDEO:
2352 puts (" Video Adapter");
2354 case CISTPL_FUNCID_NETWORK:
2355 puts (" Network Adapter");
2357 case CISTPL_FUNCID_AIMS:
2358 puts (" AIMS Card");
2360 case CISTPL_FUNCID_SCSI:
2361 puts (" SCSI Adapter");
2369 #endif /* CONFIG_IDE_8xx_PCCARD */
2371 /* -------------------------------------------------------------------- */
2373 #ifdef CONFIG_IDE_8xx_PCCARD
2374 static void print_fixed (volatile uchar *p)
2382 case CISTPL_FUNCE_IDE_IFACE:
2383 { uchar iface = *(p+2);
2385 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2386 puts (" interface ");
2389 case CISTPL_FUNCE_IDE_MASTER:
2390 case CISTPL_FUNCE_IDE_SLAVE:
2391 { uchar f1 = *(p+2);
2394 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2396 if (f1 & CISTPL_IDE_UNIQUE)
2399 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2401 if (f2 & CISTPL_IDE_HAS_SLEEP)
2404 if (f2 & CISTPL_IDE_HAS_STANDBY)
2405 puts (" [standby]");
2407 if (f2 & CISTPL_IDE_HAS_IDLE)
2410 if (f2 & CISTPL_IDE_LOW_POWER)
2411 puts (" [low power]");
2413 if (f2 & CISTPL_IDE_REG_INHIBIT)
2414 puts (" [reg inhibit]");
2416 if (f2 & CISTPL_IDE_HAS_INDEX)
2419 if (f2 & CISTPL_IDE_IOIS16)
2427 #endif /* CONFIG_IDE_8xx_PCCARD */
2429 /* -------------------------------------------------------------------- */
2431 #ifdef CONFIG_IDE_8xx_PCCARD
2433 #define MAX_IDENT_CHARS 64
2434 #define MAX_IDENT_FIELDS 4
2436 static uchar *known_cards[] = {
2441 static int identify (volatile uchar *p)
2443 uchar id_str[MAX_IDENT_CHARS];
2450 return (0); /* Don't know */
2455 for (i=0; i<=4 && !done; ++i, p+=2) {
2456 while ((data = *p) != '\0') {
2462 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2472 while (--t > id_str) {
2481 for (card=known_cards; *card; ++card) {
2482 debug ("## Compare against \"%s\"\n", *card);
2483 if (strcmp(*card, id_str) == 0) { /* found! */
2484 debug ("## CARD FOUND ##\n");
2489 return (0); /* don't know */
2491 #endif /* CONFIG_IDE_8xx_PCCARD */
2493 /* -------------------------------------------------------------------- */
2495 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */