2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 ********************************************************************
25 * Lots of code copied from:
27 * m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series.
28 * (C) 1999-2000 Magnus Damm <damm@bitsmart.com>
30 * "The ExCA standard specifies that socket controllers should provide
31 * two IO and five memory windows per socket, which can be independently
32 * configured and positioned in the host address space and mapped to
33 * arbitrary segments of card address space. " - David A Hinds. 1999
35 * This controller does _not_ meet the ExCA standard.
37 * m8xx pcmcia controller brief info:
38 * + 8 windows (attrib, mem, i/o)
39 * + up to two slots (SLOT_A and SLOT_B)
40 * + inputpins, outputpins, event and mask registers.
41 * - no offset register. sigh.
43 * Because of the lacking offset register we must map the whole card.
44 * We assign each memory window PCMCIA_MEM_WIN_SIZE address space.
45 * Make sure there is (PCMCIA_MEM_WIN_SIZE * PCMCIA_MEM_WIN_NO
46 * * PCMCIA_SOCKETS_NO) bytes at PCMCIA_MEM_WIN_BASE.
47 * The i/o windows are dynamically allocated at PCMCIA_IO_WIN_BASE.
48 * They are maximum 64KByte each...
60 #include <cmd_pcmcia.h>
61 #if defined(CONFIG_IDE_8xx_PCCARD) && defined(CONFIG_8xx)
64 #if defined(CONFIG_LWMON)
68 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
69 ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD))
73 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
74 static int pcmcia_off (void);
75 static int hardware_disable(int slot);
77 static int hardware_enable (int slot);
78 static int voltage_set(int slot, int vcc, int vpp);
79 #ifdef CONFIG_IDE_8xx_PCCARD
80 static void print_funcid (int func);
81 static void print_fixed (volatile uchar *p);
82 static int identify (volatile uchar *p);
83 static int check_ide_device (int slot);
84 #endif /* CONFIG_IDE_8xx_PCCARD */
86 static u_int m8xx_get_graycode(u_int size);
88 static u_int m8xx_get_speed(u_int ns, u_int is_io);
91 /* -------------------------------------------------------------------- */
93 /* look up table for pgcrx registers */
95 static u_int *pcmcia_pgcrx[2] = {
96 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
97 &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
100 #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
102 const char *indent = "\t ";
104 /* -------------------------------------------------------------------- */
106 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
108 int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
113 printf ("Usage: pinit {on | off}\n");
116 if (strcmp(argv[1],"on") == 0) {
117 rcode = pcmcia_on ();
118 } else if (strcmp(argv[1],"off") == 0) {
119 rcode = pcmcia_off ();
121 printf ("Usage: pinit {on | off}\n");
127 #endif /* CFG_CMD_PCMCIA */
129 /* -------------------------------------------------------------------- */
131 #if defined(CONFIG_LWMON)
132 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
134 # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
145 debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
147 /* intialize the fixed memory windows */
148 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
149 base = CFG_PCMCIA_MEM_ADDR;
151 if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
152 printf ("Cannot set window size to 0x%08x\n",
153 CFG_PCMCIA_MEM_SIZE);
157 slotbit = PCMCIA_SLOT_x;
158 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
161 #if (PCMCIA_SOCKETS_NO == 2)
162 if (i == 4) /* Another slot starting from win 4 */
163 slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
166 #ifdef CONFIG_IDE_8xx_PCCARD
168 case 0: { /* map attribute memory */
169 win->or = ( PCMCIA_BSIZE_64M
174 | CFG_PCMCIA_TIMING );
178 case 1: { /* map I/O window for data reg */
179 win->or = ( PCMCIA_BSIZE_1K
184 | CFG_PCMCIA_TIMING );
188 case 2: { /* map I/O window for cmd/ctrl reg block */
189 win->or = ( PCMCIA_BSIZE_1K
194 | CFG_PCMCIA_TIMING );
197 #endif /* CONFIG_IDE_8xx_PCCARD */
198 default: /* set to not valid */
203 debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
204 i, win->br, win->or);
205 base += CFG_PCMCIA_MEM_SIZE;
209 for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
210 /* turn off voltage */
211 if ((rc = voltage_set(slot, 0, 0)))
214 /* Enable external hardware */
215 if ((rc = hardware_enable(slot)))
218 #ifdef CONFIG_IDE_8xx_PCCARD
219 if ((rc = check_ide_device(i)))
226 /* -------------------------------------------------------------------- */
228 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
230 static int pcmcia_off (void)
235 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
237 /* clear interrupt state, and disable interrupts */
238 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
239 ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
241 /* turn off interrupt and disable CxOE */
242 PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
244 /* turn off memory windows */
245 win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
247 for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
248 /* disable memory window */
253 /* turn off voltage */
254 voltage_set(_slot_, 0, 0);
256 /* disable external hardware */
257 printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
258 hardware_disable(_slot_);
262 #endif /* CFG_CMD_PCMCIA */
264 /* -------------------------------------------------------------------- */
266 #ifdef CONFIG_IDE_8xx_PCCARD
268 #define MAX_TUPEL_SZ 512
269 #define MAX_FEATURES 4
271 int ide_devices_found;
272 static int check_ide_device (int slot)
274 volatile uchar *ident = NULL;
275 volatile uchar *feature_p[MAX_FEATURES];
276 volatile uchar *p, *start, *addr;
280 ushort config_base = 0;
284 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
285 CFG_PCMCIA_MEM_SIZE * (slot * 4));
286 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
288 start = p = (volatile uchar *) addr;
290 while ((p - start) < MAX_TUPEL_SZ) {
294 if (code == 0xFF) { /* End of chain */
299 #if defined(DEBUG) && (DEBUG > 1)
300 { volatile uchar *q = p;
301 printf ("\nTuple code %02x length %d\n\tData:",
304 for (i = 0; i < len; ++i) {
305 printf (" %02x", *q);
315 /* Fix for broken SanDisk which may have 0x80 bit set */
319 if (n_features < MAX_FEATURES)
320 feature_p[n_features++] = p;
323 config_base = (*(p+6) << 8) + (*(p+4));
324 debug ("\n## Config_base = %04x ###\n", config_base);
331 found = identify (ident);
333 if (func_id != ((uchar)~0)) {
334 print_funcid (func_id);
336 if (func_id == CISTPL_FUNCID_FIXED)
339 return (1); /* no disk drive */
342 for (i=0; i<n_features; ++i) {
343 print_fixed (feature_p[i]);
347 printf ("unknown card type\n");
351 ide_devices_found |= (1 << slot);
353 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
354 *((uchar *)(addr + config_base)) = 1;
358 #endif /* CONFIG_IDE_8xx_PCCARD */
360 /* -------------------------------------------------------------------- */
363 /* -------------------------------------------------------------------- */
364 /* board specific stuff: */
365 /* voltage_set(), hardware_enable() and hardware_disable() */
366 /* -------------------------------------------------------------------- */
368 /* -------------------------------------------------------------------- */
369 /* RPX Boards from Embedded Planet */
370 /* -------------------------------------------------------------------- */
372 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
374 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
375 * SYPCR is write once only, therefore must the slowest memory be faster
376 * than the bus monitor or we will get a machine check due to the bus timeout.
379 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
381 #undef PCMCIA_BMT_LIMIT
382 #define PCMCIA_BMT_LIMIT (6*8)
384 static int voltage_set(int slot, int vcc, int vpp)
390 case 33: reg |= BCSR1_PCVCTL4; break;
391 case 50: reg |= BCSR1_PCVCTL5; break;
400 reg |= BCSR1_PCVCTL6;
405 reg |= BCSR1_PCVCTL7;
412 /* first, turn off all power */
414 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
415 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
417 /* enable new powersettings */
419 *((uint *)RPX_CSR_ADDR) |= reg;
424 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
425 static int hardware_enable (int slot)
427 return 0; /* No hardware to enable */
429 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
430 static int hardware_disable(int slot)
432 return 0; /* No hardware to disable */
434 #endif /* CFG_CMD_PCMCIA */
435 #endif /* CONFIG_RPXCLASSIC */
437 /* -------------------------------------------------------------------- */
438 /* (F)ADS Boards from Motorola */
439 /* -------------------------------------------------------------------- */
441 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
444 #define PCMCIA_BOARD_MSG "ADS"
445 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
447 #define PCMCIA_BOARD_MSG "FADS"
450 static int voltage_set(int slot, int vcc, int vpp)
455 case 0: reg = 0; break;
456 case 50: reg = 1; break;
457 case 120: reg = 2; break;
462 case 0: reg = 0; break;
464 case 50: reg = BCSR1_PCCVCCON; break;
467 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
468 case 50: reg = BCSR1_PCCVCC1; break;
473 /* first, turn off all power */
476 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
479 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
481 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
483 /* enable new powersettings */
486 *((uint *)BCSR1) &= ~reg;
489 *((uint *)BCSR1) |= reg;
492 *((uint *)BCSR1) |= reg << 20;
497 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
499 static int hardware_enable(int slot)
501 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
505 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
506 static int hardware_disable(int slot)
508 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
511 #endif /* CFG_CMD_PCMCIA */
515 /* -------------------------------------------------------------------- */
516 /* TQM8xxL Boards by TQ Components */
517 /* -------------------------------------------------------------------- */
519 #if defined(CONFIG_TQM8xxL)
521 #define PCMCIA_BOARD_MSG "TQM8xxL"
524 static int hardware_enable(int slot)
526 volatile immap_t *immap;
527 volatile cpm8xx_t *cp;
528 volatile pcmconf8xx_t *pcmp;
529 volatile sysconf8xx_t *sysp;
532 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
536 immap = (immap_t *)CFG_IMMR;
537 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
538 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
539 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
542 * Configure SIUMCR to enable PCMCIA port B
543 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
545 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
547 /* clear interrupt state, and disable interrupts */
548 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
549 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
552 * Disable interrupts, DMA, and PCMCIA buffers
553 * (isolate the interface) and assert RESET signal
555 debug ("Disable PCMCIA buffers and assert RESET\n");
557 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
558 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
559 PCMCIA_PGCRX(_slot_) = reg;
563 * Configure Port C pins for
564 * 5 Volts Enable and 3 Volts enable
566 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
567 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
568 /* remove all power */
570 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
573 * Make sure there is a card in the slot, then configure the interface.
576 debug ("[%d] %s: PIPR(%p)=0x%x\n",
577 __LINE__,__FUNCTION__,
578 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
579 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
580 printf (" No Card found\n");
587 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
588 reg = pcmp->pcmc_pipr;
589 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
591 (reg&PCMCIA_VS1(slot))?"n":"ff",
592 (reg&PCMCIA_VS2(slot))?"n":"ff");
593 if ((reg & mask) == mask) {
594 immap->im_ioport.iop_pcdat |= 0x0004;
595 puts (" 5.0V card found: ");
597 immap->im_ioport.iop_pcdat |= 0x0002;
598 puts (" 3.3V card found: ");
600 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
602 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
603 cp->cp_pbdir &= ~(0x0020 | 0x0010);
604 cp->cp_pbpar &= ~(0x0020 | 0x0010);
608 debug ("Enable PCMCIA buffers and stop RESET\n");
609 reg = PCMCIA_PGCRX(_slot_);
610 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
611 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
612 PCMCIA_PGCRX(_slot_) = reg;
614 udelay(250000); /* some cards need >150 ms to come up :-( */
616 debug ("# hardware_enable done\n");
623 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
624 static int hardware_disable(int slot)
626 volatile immap_t *immap;
627 volatile pcmconf8xx_t *pcmp;
630 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
632 immap = (immap_t *)CFG_IMMR;
633 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
635 /* remove all power */
636 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
638 debug ("Disable PCMCIA buffers and assert RESET\n");
640 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
641 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
642 PCMCIA_PGCRX(_slot_) = reg;
648 #endif /* CFG_CMD_PCMCIA */
652 static int voltage_set(int slot, int vcc, int vpp)
654 volatile immap_t *immap;
655 volatile pcmconf8xx_t *pcmp;
658 debug ("voltage_set: "
660 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
661 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
663 immap = (immap_t *)CFG_IMMR;
664 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
666 * Disable PCMCIA buffers (isolate the interface)
667 * and assert RESET signal
669 debug ("Disable PCMCIA buffers and assert RESET\n");
670 reg = PCMCIA_PGCRX(_slot_);
671 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
672 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
673 PCMCIA_PGCRX(_slot_) = reg;
677 * Configure Port C pins for
678 * 5 Volts Enable and 3 Volts enable,
681 debug ("PCMCIA power OFF\n");
682 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
683 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
684 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
689 case 33: reg |= 0x0002; break;
690 case 50: reg |= 0x0004; break;
694 /* Checking supported voltages */
696 debug ("PIPR: 0x%x --> %s\n",
698 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
700 immap->im_ioport.iop_pcdat |= reg;
701 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
703 debug ("PCMCIA powered at %sV\n",
704 (reg&0x0004) ? "5.0" : "3.3");
706 debug ("PCMCIA powered down\n");
710 debug ("Enable PCMCIA buffers and stop RESET\n");
711 reg = PCMCIA_PGCRX(_slot_);
712 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
713 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
714 PCMCIA_PGCRX(_slot_) = reg;
717 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
725 /* -------------------------------------------------------------------- */
727 /* -------------------------------------------------------------------- */
729 #if defined(CONFIG_LWMON)
731 #define PCMCIA_BOARD_MSG "LWMON"
733 /* #define's for MAX1604 Power Switch */
734 #define MAX1604_OP_SUS 0x80
735 #define MAX1604_VCCBON 0x40
736 #define MAX1604_VCC_35 0x20
737 #define MAX1604_VCCBHIZ 0x10
738 #define MAX1604_VPPBON 0x08
739 #define MAX1604_VPPBPBPGM 0x04
740 #define MAX1604_VPPBHIZ 0x02
743 static int hardware_enable(int slot)
745 volatile immap_t *immap;
746 volatile cpm8xx_t *cp;
747 volatile pcmconf8xx_t *pcmp;
748 volatile sysconf8xx_t *sysp;
753 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
755 /* Switch on PCMCIA port in PIC register 0x60 */
756 reg = pic_read (0x60);
757 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
759 /* reg |= 0x08; Vpp not needed */
760 pic_write (0x60, reg);
762 reg = pic_read (0x60);
763 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
767 immap = (immap_t *)CFG_IMMR;
768 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
769 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
770 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
773 * Configure SIUMCR to enable PCMCIA port B
774 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
776 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
778 /* clear interrupt state, and disable interrupts */
779 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
780 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
783 * Disable interrupts, DMA, and PCMCIA buffers
784 * (isolate the interface) and assert RESET signal
786 debug ("Disable PCMCIA buffers and assert RESET\n");
788 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
789 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
790 PCMCIA_PGCRX(_slot_) = reg;
794 * Make sure there is a card in the slot, then configure the interface.
797 debug ("[%d] %s: PIPR(%p)=0x%x\n",
798 __LINE__,__FUNCTION__,
799 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
800 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
801 printf (" No Card found\n");
808 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
809 reg = pcmp->pcmc_pipr;
810 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
812 (reg&PCMCIA_VS1(slot))?"n":"ff",
813 (reg&PCMCIA_VS2(slot))?"n":"ff");
814 if ((reg & mask) == mask) {
815 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
816 puts (" 5.0V card found: ");
818 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
819 puts (" 3.3V card found: ");
823 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
824 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
825 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
829 debug ("Enable PCMCIA buffers and stop RESET\n");
830 reg = PCMCIA_PGCRX(_slot_);
831 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
832 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
833 PCMCIA_PGCRX(_slot_) = reg;
835 udelay(250000); /* some cards need >150 ms to come up :-( */
837 debug ("# hardware_enable done\n");
844 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
845 static int hardware_disable(int slot)
847 volatile immap_t *immap;
848 volatile pcmconf8xx_t *pcmp;
852 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
854 immap = (immap_t *)CFG_IMMR;
855 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
857 /* remove all power, put output in high impedance state */
858 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
859 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
860 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
862 /* Configure PCMCIA General Control Register */
863 debug ("Disable PCMCIA buffers and assert RESET\n");
865 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
866 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
867 PCMCIA_PGCRX(_slot_) = reg;
869 /* Switch off PCMCIA port in PIC register 0x60 */
870 reg = pic_read (0x60);
871 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
874 pic_write (0x60, reg);
876 reg = pic_read (0x60);
877 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
883 #endif /* CFG_CMD_PCMCIA */
887 static int voltage_set(int slot, int vcc, int vpp)
889 volatile immap_t *immap;
890 volatile pcmconf8xx_t *pcmp;
894 debug ("voltage_set: "
896 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
897 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
899 immap = (immap_t *)CFG_IMMR;
900 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
902 * Disable PCMCIA buffers (isolate the interface)
903 * and assert RESET signal
905 debug ("Disable PCMCIA buffers and assert RESET\n");
906 reg = PCMCIA_PGCRX(_slot_);
907 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
908 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
909 PCMCIA_PGCRX(_slot_) = reg;
913 * Turn off all power (switch to high impedance)
915 debug ("PCMCIA power OFF\n");
916 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
917 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
918 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
923 case 33: val = MAX1604_VCC_35; break;
928 /* Checking supported voltages */
930 debug ("PIPR: 0x%x --> %s\n",
932 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
934 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
936 debug ("PCMCIA powered at %sV\n",
937 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
939 debug ("PCMCIA powered down\n");
943 debug ("Enable PCMCIA buffers and stop RESET\n");
944 reg = PCMCIA_PGCRX(_slot_);
945 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
946 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
947 PCMCIA_PGCRX(_slot_) = reg;
950 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
957 /* -------------------------------------------------------------------- */
958 /* GTH board by Corelatus AB */
959 /* -------------------------------------------------------------------- */
960 #if defined(CONFIG_GTH)
962 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
964 static int voltage_set (int slot, int vcc, int vpp)
969 static int hardware_enable (int slot)
971 volatile immap_t *immap;
972 volatile cpm8xx_t *cp;
973 volatile pcmconf8xx_t *pcmp;
974 volatile sysconf8xx_t *sysp;
977 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
979 immap = (immap_t *) CFG_IMMR;
980 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
981 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
982 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
984 /* clear interrupt state, and disable interrupts */
985 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
986 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
989 * Disable interrupts, DMA, and PCMCIA buffers
990 * (isolate the interface) and assert RESET signal
992 debug ("Disable PCMCIA buffers and assert RESET\n");
994 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
995 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
996 PCMCIA_PGCRX (_slot_) = reg;
1000 * Make sure there is a card in the slot,
1001 * then configure the interface.
1004 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1005 __LINE__, __FUNCTION__,
1006 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1007 if (pcmp->pcmc_pipr & 0x98000000) {
1008 printf (" No Card found\n");
1012 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1013 reg = pcmp->pcmc_pipr;
1014 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1016 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1017 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1019 debug ("Enable PCMCIA buffers and stop RESET\n");
1020 reg = PCMCIA_PGCRX (_slot_);
1021 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1022 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1023 PCMCIA_PGCRX (_slot_) = reg;
1025 udelay (250000); /* some cards need >150 ms to come up :-( */
1027 debug ("# hardware_enable done\n");
1031 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1032 static int hardware_disable(int slot)
1034 return 0; /* No hardware to disable */
1036 #endif /* CFG_CMD_PCMCIA */
1037 #endif /* CONFIG_GTH */
1039 /* -------------------------------------------------------------------- */
1040 /* ICU862 Boards by Cambridge Broadband Ltd. */
1041 /* -------------------------------------------------------------------- */
1043 #if defined(CONFIG_ICU862)
1045 #define PCMCIA_BOARD_MSG "ICU862"
1047 static void cfg_port_B (void);
1049 static int hardware_enable(int slot)
1051 volatile immap_t *immap;
1052 volatile cpm8xx_t *cp;
1053 volatile pcmconf8xx_t *pcmp;
1054 volatile sysconf8xx_t *sysp;
1055 uint reg, pipr, mask;
1058 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1062 immap = (immap_t *)CFG_IMMR;
1063 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1064 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1065 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1067 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1071 * Configure SIUMCR to enable PCMCIA port B
1072 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1074 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1076 /* clear interrupt state, and disable interrupts */
1077 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1078 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1081 * Disable interrupts, DMA, and PCMCIA buffers
1082 * (isolate the interface) and assert RESET signal
1084 debug ("Disable PCMCIA buffers and assert RESET\n");
1086 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1087 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1088 PCMCIA_PGCRX(_slot_) = reg;
1092 * Make sure there is a card in the slot, then configure the interface.
1095 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1096 __LINE__,__FUNCTION__,
1097 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1098 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1099 printf (" No Card found\n");
1104 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1106 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1107 pipr = pcmp->pcmc_pipr;
1108 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1110 (reg&PCMCIA_VS1(slot))?"n":"ff",
1111 (reg&PCMCIA_VS2(slot))?"n":"ff");
1114 if ((pipr & mask) == mask) {
1115 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1116 TPS2205_VCC3); /* 3V off */
1117 reg &= ~(TPS2205_VCC5); /* 5V on */
1118 puts (" 5.0V card found: ");
1120 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1121 TPS2205_VCC5); /* 5V off */
1122 reg &= ~(TPS2205_VCC3); /* 3V on */
1123 puts (" 3.3V card found: ");
1126 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1128 (reg & TPS2205_VCC3) ? "off" : "on",
1129 (reg & TPS2205_VCC5) ? "off" : "on",
1130 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1131 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1135 /* Wait 500 ms; use this to check for over-current */
1136 for (i=0; i<5000; ++i) {
1137 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1138 printf (" *** Overcurrent - Safety shutdown ***\n");
1139 cp->cp_pbdat &= ~(TPS2205_SHDN);
1145 debug ("Enable PCMCIA buffers and stop RESET\n");
1146 reg = PCMCIA_PGCRX(_slot_);
1147 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1148 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1149 PCMCIA_PGCRX(_slot_) = reg;
1151 udelay(250000); /* some cards need >150 ms to come up :-( */
1153 debug ("# hardware_enable done\n");
1160 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1161 static int hardware_disable(int slot)
1163 volatile immap_t *immap;
1164 volatile cpm8xx_t *cp;
1165 volatile pcmconf8xx_t *pcmp;
1168 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1170 immap = (immap_t *)CFG_IMMR;
1171 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1172 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1175 cp->cp_pbdat &= ~(TPS2205_SHDN);
1177 /* Configure PCMCIA General Control Register */
1178 debug ("Disable PCMCIA buffers and assert RESET\n");
1180 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1181 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1182 PCMCIA_PGCRX(_slot_) = reg;
1188 #endif /* CFG_CMD_PCMCIA */
1192 static int voltage_set(int slot, int vcc, int vpp)
1194 volatile immap_t *immap;
1195 volatile cpm8xx_t *cp;
1196 volatile pcmconf8xx_t *pcmp;
1199 debug ("voltage_set: "
1201 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1202 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1204 immap = (immap_t *)CFG_IMMR;
1205 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1206 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1208 * Disable PCMCIA buffers (isolate the interface)
1209 * and assert RESET signal
1211 debug ("Disable PCMCIA buffers and assert RESET\n");
1212 reg = PCMCIA_PGCRX(_slot_);
1213 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1214 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1215 PCMCIA_PGCRX(_slot_) = reg;
1219 * Configure Port C pins for
1220 * 5 Volts Enable and 3 Volts enable,
1221 * Turn all power pins to Hi-Z
1223 debug ("PCMCIA power OFF\n");
1224 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1229 case 0: break; /* Switch off */
1230 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1231 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1235 /* Checking supported voltages */
1237 debug ("PIPR: 0x%x --> %s\n",
1239 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1247 if ((reg & TPS2205_VCC3) == 0) {
1249 } else if ((reg & TPS2205_VCC5) == 0) {
1254 printf ("PCMCIA powered %s\n", s);
1259 debug ("Enable PCMCIA buffers and stop 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;
1266 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1271 static void cfg_port_B (void)
1273 volatile immap_t *immap;
1274 volatile cpm8xx_t *cp;
1277 immap = (immap_t *)CFG_IMMR;
1278 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1281 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1283 * Switch off all voltages, assert shutdown
1286 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1287 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1288 TPS2205_SHDN); /* enable switch */
1291 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1293 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1294 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1296 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1297 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1303 /* -------------------------------------------------------------------- */
1304 /* C2MON Boards by TTTech Computertechnik AG */
1305 /* -------------------------------------------------------------------- */
1307 #if defined(CONFIG_C2MON)
1309 #define PCMCIA_BOARD_MSG "C2MON"
1311 static void cfg_ports (void);
1313 static int hardware_enable(int slot)
1315 volatile immap_t *immap;
1316 volatile cpm8xx_t *cp;
1317 volatile pcmconf8xx_t *pcmp;
1318 volatile sysconf8xx_t *sysp;
1319 uint reg, pipr, mask;
1323 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1327 immap = (immap_t *)CFG_IMMR;
1328 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1329 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1330 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1332 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1336 * Configure SIUMCR to enable PCMCIA port B
1337 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1339 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1341 /* clear interrupt state, and disable interrupts */
1342 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1343 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1346 * Disable interrupts, DMA, and PCMCIA buffers
1347 * (isolate the interface) and assert RESET signal
1349 debug ("Disable PCMCIA buffers and assert RESET\n");
1351 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1352 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1353 PCMCIA_PGCRX(_slot_) = reg;
1357 * Make sure there is a card in the slot, then configure the interface.
1360 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1361 __LINE__,__FUNCTION__,
1362 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1363 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1364 printf (" No Card found\n");
1369 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1371 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1372 pipr = pcmp->pcmc_pipr;
1373 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1375 (reg&PCMCIA_VS1(slot))?"n":"ff",
1376 (reg&PCMCIA_VS2(slot))?"n":"ff");
1378 sreg = immap->im_ioport.iop_pcdat;
1379 if ((pipr & mask) == mask) {
1380 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1381 TPS2211_VCCD1); /* 5V on */
1382 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1383 puts (" 5.0V card found: ");
1385 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1386 TPS2211_VCCD0); /* 3V on */
1387 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1388 puts (" 3.3V card found: ");
1391 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1393 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1394 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1397 immap->im_ioport.iop_pcdat = sreg;
1399 /* Wait 500 ms; use this to check for over-current */
1400 for (i=0; i<5000; ++i) {
1401 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1402 printf (" *** Overcurrent - Safety shutdown ***\n");
1403 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1409 debug ("Enable PCMCIA buffers and stop RESET\n");
1410 reg = PCMCIA_PGCRX(_slot_);
1411 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1412 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1413 PCMCIA_PGCRX(_slot_) = reg;
1415 udelay(250000); /* some cards need >150 ms to come up :-( */
1417 debug ("# hardware_enable done\n");
1424 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1425 static int hardware_disable(int slot)
1427 volatile immap_t *immap;
1428 volatile cpm8xx_t *cp;
1429 volatile pcmconf8xx_t *pcmp;
1432 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1434 immap = (immap_t *)CFG_IMMR;
1435 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1437 /* Configure PCMCIA General Control Register */
1438 debug ("Disable PCMCIA buffers and assert RESET\n");
1440 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1441 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1442 PCMCIA_PGCRX(_slot_) = reg;
1444 /* ALl voltages off / Hi-Z */
1445 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1446 TPS2211_VCCD0 | TPS2211_VCCD1 );
1452 #endif /* CFG_CMD_PCMCIA */
1456 static int voltage_set(int slot, int vcc, int vpp)
1458 volatile immap_t *immap;
1459 volatile cpm8xx_t *cp;
1460 volatile pcmconf8xx_t *pcmp;
1464 debug ("voltage_set: "
1466 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1467 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1469 immap = (immap_t *)CFG_IMMR;
1470 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1471 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1473 * Disable PCMCIA buffers (isolate the interface)
1474 * and assert RESET signal
1476 debug ("Disable PCMCIA buffers and assert RESET\n");
1477 reg = PCMCIA_PGCRX(_slot_);
1478 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1479 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1480 PCMCIA_PGCRX(_slot_) = reg;
1484 * Configure Port C pins for
1485 * 5 Volts Enable and 3 Volts enable,
1486 * Turn all power pins to Hi-Z
1488 debug ("PCMCIA power OFF\n");
1489 cfg_ports (); /* Enables switch, but all in Hi-Z */
1491 sreg = immap->im_ioport.iop_pcdat;
1492 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1495 case 0: break; /* Switch off */
1496 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1497 sreg &= ~TPS2211_VCCD1;
1499 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1500 sreg |= TPS2211_VCCD1;
1505 /* Checking supported voltages */
1507 debug ("PIPR: 0x%x --> %s\n",
1509 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1511 immap->im_ioport.iop_pcdat = sreg;
1517 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1519 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1524 printf ("PCMCIA powered %s\n", s);
1529 debug ("Enable PCMCIA buffers and stop RESET\n");
1530 reg = PCMCIA_PGCRX(_slot_);
1531 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1532 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1533 PCMCIA_PGCRX(_slot_) = reg;
1536 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1541 static void cfg_ports (void)
1543 volatile immap_t *immap;
1544 volatile cpm8xx_t *cp;
1547 immap = (immap_t *)CFG_IMMR;
1548 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1551 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1553 * Switch off all voltages, assert shutdown
1555 sreg = immap->im_ioport.iop_pcdat;
1556 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1557 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1558 immap->im_ioport.iop_pcdat = sreg;
1560 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1561 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1563 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1564 immap->im_ioport.iop_pcpar,
1565 immap->im_ioport.iop_pcdir,
1566 immap->im_ioport.iop_pcdat);
1569 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1571 * Over-Current Input only
1573 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1574 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1576 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1577 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1582 /* -------------------------------------------------------------------- */
1583 /* MBX board from Morotola */
1584 /* -------------------------------------------------------------------- */
1586 #if defined( CONFIG_MBX )
1587 #include <../board/mbx8xx/csr.h>
1589 /* A lot of this has been taken from the RPX code in this file it works from me.
1590 I have added the voltage selection for the MBX board. */
1592 /* MBX voltage bit in control register #2 */
1593 #define CR2_VPP12 ((uchar)0x10)
1594 #define CR2_VPPVDD ((uchar)0x20)
1595 #define CR2_VDD5 ((uchar)0x40)
1596 #define CR2_VDD3 ((uchar)0x80)
1598 #define PCMCIA_BOARD_MSG "MBX860"
1600 static int voltage_set (int slot, int vcc, int vpp)
1604 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1605 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1638 /* first, turn off all power */
1639 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1641 /* enable new powersettings */
1643 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1648 static int hardware_enable (int slot)
1650 volatile immap_t *immap;
1651 volatile cpm8xx_t *cp;
1652 volatile pcmconf8xx_t *pcmp;
1653 volatile sysconf8xx_t *sysp;
1656 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1661 immap = (immap_t *) CFG_IMMR;
1662 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1663 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1664 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1666 /* clear interrupt state, and disable interrupts */
1667 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1668 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1671 * Disable interrupts, DMA, and PCMCIA buffers
1672 * (isolate the interface) and assert RESET signal
1674 debug ("Disable PCMCIA buffers and assert RESET\n");
1676 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1677 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1678 PCMCIA_PGCRX (_slot_) = reg;
1681 /* remove all power */
1682 voltage_set (slot, 0, 0);
1684 * Make sure there is a card in the slot, then configure the interface.
1687 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1688 __LINE__,__FUNCTION__,
1689 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1690 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1691 printf (" No Card found\n");
1698 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1699 reg = pcmp->pcmc_pipr;
1700 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1701 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1702 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1704 if ((reg & mask) == mask) {
1705 voltage_set (_slot_, 50, 0);
1706 printf (" 5.0V card found: ");
1708 voltage_set (_slot_, 33, 0);
1709 printf (" 3.3V card found: ");
1712 debug ("Enable PCMCIA buffers and stop RESET\n");
1713 reg = PCMCIA_PGCRX (_slot_);
1714 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1715 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1716 PCMCIA_PGCRX (_slot_) = reg;
1718 udelay (250000); /* some cards need >150 ms to come up :-( */
1720 debug ("# hardware_enable done\n");
1725 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1726 static int hardware_disable (int slot)
1728 return 0; /* No hardware to disable */
1730 #endif /* CFG_CMD_PCMCIA */
1731 #endif /* CONFIG_MBX */
1732 /* -------------------------------------------------------------------- */
1734 /* -------------------------------------------------------------------- */
1736 #if defined(CONFIG_R360MPI)
1738 #define PCMCIA_BOARD_MSG "R360MPI"
1741 static int hardware_enable(int slot)
1743 volatile immap_t *immap;
1744 volatile cpm8xx_t *cp;
1745 volatile pcmconf8xx_t *pcmp;
1746 volatile sysconf8xx_t *sysp;
1749 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1753 immap = (immap_t *)CFG_IMMR;
1754 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1755 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1756 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1759 * Configure SIUMCR to enable PCMCIA port B
1760 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1762 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1764 /* clear interrupt state, and disable interrupts */
1765 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1766 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1769 * Disable interrupts, DMA, and PCMCIA buffers
1770 * (isolate the interface) and assert RESET signal
1772 debug ("Disable PCMCIA buffers and assert RESET\n");
1774 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1775 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1776 PCMCIA_PGCRX(_slot_) = reg;
1780 * Configure Ports A, B & C pins for
1781 * 5 Volts Enable and 3 Volts enable
1783 immap->im_ioport.iop_pcpar &= ~(0x0400);
1784 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1785 immap->im_ioport.iop_pcdir |= 0x0400;*/
1787 immap->im_ioport.iop_papar &= ~(0x0200);/*
1788 immap->im_ioport.iop_padir |= 0x0200;*/
1790 immap->im_ioport.iop_pbpar &= ~(0xC000);
1791 immap->im_ioport.iop_pbdir &= ~(0xC000);
1793 /* remove all power */
1795 immap->im_ioport.iop_pcdat |= 0x0400;
1796 immap->im_ioport.iop_padat |= 0x0200;
1799 * Make sure there is a card in the slot, then configure the interface.
1802 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1803 __LINE__,__FUNCTION__,
1804 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1805 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1806 printf (" No Card found\n");
1813 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1814 reg = pcmp->pcmc_pipr;
1815 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1817 (reg&PCMCIA_VS1(slot))?"n":"ff",
1818 (reg&PCMCIA_VS2(slot))?"n":"ff");
1819 if ((reg & mask) == mask) {
1820 immap->im_ioport.iop_pcdat &= ~(0x4000);
1821 puts (" 5.0V card found: ");
1823 immap->im_ioport.iop_padat &= ~(0x0002);
1824 puts (" 3.3V card found: ");
1826 immap->im_ioport.iop_pcdir |= 0x0400;
1827 immap->im_ioport.iop_padir |= 0x0200;
1829 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
1830 cp->cp_pbdir &= ~(0x0020 | 0x0010);
1831 cp->cp_pbpar &= ~(0x0020 | 0x0010);
1834 debug ("Enable PCMCIA buffers and stop RESET\n");
1835 reg = PCMCIA_PGCRX(_slot_);
1836 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1837 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1838 PCMCIA_PGCRX(_slot_) = reg;
1840 udelay(250000); /* some cards need >150 ms to come up :-( */
1842 debug ("# hardware_enable done\n");
1849 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1850 static int hardware_disable(int slot)
1852 volatile immap_t *immap;
1853 volatile pcmconf8xx_t *pcmp;
1856 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1858 immap = (immap_t *)CFG_IMMR;
1859 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1861 /* remove all power */
1862 immap->im_ioport.iop_pcdat |= 0x0400;
1863 immap->im_ioport.iop_padat |= 0x0200;
1865 /* Configure PCMCIA General Control Register */
1866 debug ("Disable PCMCIA buffers and assert RESET\n");
1868 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1869 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1870 PCMCIA_PGCRX(_slot_) = reg;
1876 #endif /* CFG_CMD_PCMCIA */
1880 static int voltage_set(int slot, int vcc, int vpp)
1882 volatile immap_t *immap;
1883 volatile pcmconf8xx_t *pcmp;
1886 debug ("voltage_set: "
1888 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1889 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1891 immap = (immap_t *)CFG_IMMR;
1892 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1894 * Disable PCMCIA buffers (isolate the interface)
1895 * and assert RESET signal
1897 debug ("Disable PCMCIA buffers and assert RESET\n");
1898 reg = PCMCIA_PGCRX(_slot_);
1899 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1900 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1901 PCMCIA_PGCRX(_slot_) = reg;
1905 * Configure Ports A & C pins for
1906 * 5 Volts Enable and 3 Volts enable,
1907 * Turn off all power
1909 debug ("PCMCIA power OFF\n");
1910 immap->im_ioport.iop_pcpar &= ~(0x0400);
1911 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1912 immap->im_ioport.iop_pcdir |= 0x0400;*/
1914 immap->im_ioport.iop_papar &= ~(0x0200);/*
1915 immap->im_ioport.iop_padir |= 0x0200;*/
1917 immap->im_ioport.iop_pcdat |= 0x0400;
1918 immap->im_ioport.iop_padat |= 0x0200;
1923 case 33: reg |= 0x0200; break;
1924 case 50: reg |= 0x0400; break;
1928 /* Checking supported voltages */
1930 debug ("PIPR: 0x%x --> %s\n",
1932 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1935 immap->im_ioport.iop_pcdat &= !reg;
1937 immap->im_ioport.iop_padat &= !reg;
1938 immap->im_ioport.iop_pcdir |= 0x0200;
1939 immap->im_ioport.iop_padir |= 0x0400;
1941 debug ("PCMCIA powered at %sV\n",
1942 (reg&0x0400) ? "5.0" : "3.3");
1944 debug ("PCMCIA powered down\n");
1948 debug ("Enable PCMCIA buffers and stop RESET\n");
1949 reg = PCMCIA_PGCRX(_slot_);
1950 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1951 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1952 PCMCIA_PGCRX(_slot_) = reg;
1955 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1960 #endif /* R360MPI */
1962 /* -------------------------------------------------------------------- */
1964 /* -------------------------------------------------------------------- */
1965 #if defined(CONFIG_KUP4K)
1967 #define PCMCIA_BOARD_MSG "KUP4K"
1969 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
1971 static int hardware_enable(int slot)
1973 volatile immap_t *immap;
1974 volatile cpm8xx_t *cp;
1975 volatile pcmconf8xx_t *pcmp;
1976 volatile sysconf8xx_t *sysp;
1979 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1983 immap = (immap_t *)CFG_IMMR;
1984 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1985 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1986 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1989 * Configure SIUMCR to enable PCMCIA port B
1990 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1992 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1994 /* clear interrupt state, and disable interrupts */
1995 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
1996 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
1999 * Disable interrupts, DMA, and PCMCIA buffers
2000 * (isolate the interface) and assert RESET signal
2002 debug ("Disable PCMCIA buffers and assert RESET\n");
2004 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2005 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2006 PCMCIA_PGCRX(slot) = reg;
2010 * Configure Port B pins for
2013 if (slot) { /* Slot A is built-in */
2014 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2015 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2016 /* remove all power */
2017 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2020 * Make sure there is a card in the slot, then configure the interface.
2023 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2024 __LINE__,__FUNCTION__,
2025 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2026 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2027 printf (" No Card found\n");
2034 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2035 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2036 reg = pcmp->pcmc_pipr;
2037 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2039 (reg&PCMCIA_VS1(slot))?"n":"ff",
2040 (reg&PCMCIA_VS2(slot))?"n":"ff");
2041 if ((reg & mask) == mask) {
2042 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2045 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2046 puts (" 3.3V card found: ");
2049 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2050 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2051 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2054 debug ("Enable PCMCIA buffers and stop RESET\n");
2055 reg = PCMCIA_PGCRX(slot);
2056 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2057 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2058 PCMCIA_PGCRX(slot) = reg;
2060 udelay(250000); /* some cards need >150 ms to come up :-( */
2062 debug ("# hardware_enable done\n");
2069 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2070 static int hardware_disable(int slot)
2072 volatile immap_t *immap;
2073 volatile cpm8xx_t *cp;
2074 volatile pcmconf8xx_t *pcmp;
2077 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2079 immap = (immap_t *)CFG_IMMR;
2080 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2081 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2083 /* remove all power */
2085 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2087 /* Configure PCMCIA General Control Register */
2088 debug ("Disable PCMCIA buffers and assert RESET\n");
2090 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2091 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2092 PCMCIA_PGCRX(slot) = reg;
2098 #endif /* CFG_CMD_PCMCIA */
2102 static int voltage_set(int slot, int vcc, int vpp)
2104 volatile immap_t *immap;
2105 volatile cpm8xx_t *cp;
2106 volatile pcmconf8xx_t *pcmp;
2109 debug ("voltage_set: " \
2111 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2112 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2114 if (!slot) /* Slot A is not configurable */
2117 immap = (immap_t *)CFG_IMMR;
2118 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2119 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2122 * Disable PCMCIA buffers (isolate the interface)
2123 * and assert RESET signal
2125 debug ("Disable PCMCIA buffers and assert RESET\n");
2126 reg = PCMCIA_PGCRX(slot);
2127 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2128 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2129 PCMCIA_PGCRX(slot) = reg;
2132 debug ("PCMCIA power OFF\n");
2134 * Configure Port B pins for
2137 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2138 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2139 /* remove all power */
2140 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2145 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2146 debug ("PCMCIA powered at 3.3V\n");
2149 debug ("PCMCIA: 5Volt vcc not supported\n");
2152 puts("PCMCIA: vcc not supported");
2156 /* Checking supported voltages */
2158 debug ("PIPR: 0x%x --> %s\n",
2160 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2161 ? "only 5 V --> NOT SUPPORTED"
2165 debug ("Enable PCMCIA buffers and stop RESET\n");
2166 reg = PCMCIA_PGCRX(slot);
2167 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2168 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2169 PCMCIA_PGCRX(slot) = reg;
2172 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2183 /* -------------------------------------------------------------------- */
2184 /* End of Board Specific Stuff */
2185 /* -------------------------------------------------------------------- */
2188 /* -------------------------------------------------------------------- */
2189 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2190 /* -------------------------------------------------------------------- */
2193 * Search this table to see if the windowsize is
2197 #define M8XX_SIZES_NO 32
2199 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2200 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2201 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2202 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2203 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2205 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2206 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2207 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2208 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2211 /* -------------------------------------------------------------------- */
2213 static u_int m8xx_get_graycode(u_int size)
2217 for (k = 0; k < M8XX_SIZES_NO; k++) {
2218 if(m8xx_size_to_gray[k] == size)
2222 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2228 /* -------------------------------------------------------------------- */
2231 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2233 u_int reg, clocks, psst, psl, psht;
2238 * We get called with IO maps setup to 0ns
2239 * if not specified by the user.
2240 * They should be 255ns.
2246 ns = 100; /* fast memory if 0 */
2250 * In PSST, PSL, PSHT fields we tell the controller
2251 * timing parameters in CLKOUT clock cycles.
2252 * CLKOUT is the same as GCLK2_50.
2255 /* how we want to adjust the timing - in percent */
2257 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2259 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2260 clocks = (clocks * ADJ) / (100*1000);
2262 if(clocks >= PCMCIA_BMT_LIMIT) {
2263 DEBUG(0, "Max access time limit reached\n");
2264 clocks = PCMCIA_BMT_LIMIT-1;
2267 psst = clocks / 7; /* setup time */
2268 psht = clocks / 7; /* hold time */
2269 psl = (clocks * 5) / 7; /* strobe length */
2271 psst += clocks - (psst + psht + psl);
2281 /* -------------------------------------------------------------------- */
2283 #ifdef CONFIG_IDE_8xx_PCCARD
2284 static void print_funcid (int func)
2288 case CISTPL_FUNCID_MULTI:
2289 puts (" Multi-Function");
2291 case CISTPL_FUNCID_MEMORY:
2294 case CISTPL_FUNCID_SERIAL:
2295 puts (" Serial Port");
2297 case CISTPL_FUNCID_PARALLEL:
2298 puts (" Parallel Port");
2300 case CISTPL_FUNCID_FIXED:
2301 puts (" Fixed Disk");
2303 case CISTPL_FUNCID_VIDEO:
2304 puts (" Video Adapter");
2306 case CISTPL_FUNCID_NETWORK:
2307 puts (" Network Adapter");
2309 case CISTPL_FUNCID_AIMS:
2310 puts (" AIMS Card");
2312 case CISTPL_FUNCID_SCSI:
2313 puts (" SCSI Adapter");
2321 #endif /* CONFIG_IDE_8xx_PCCARD */
2323 /* -------------------------------------------------------------------- */
2325 #ifdef CONFIG_IDE_8xx_PCCARD
2326 static void print_fixed (volatile uchar *p)
2334 case CISTPL_FUNCE_IDE_IFACE:
2335 { uchar iface = *(p+2);
2337 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2338 puts (" interface ");
2341 case CISTPL_FUNCE_IDE_MASTER:
2342 case CISTPL_FUNCE_IDE_SLAVE:
2343 { uchar f1 = *(p+2);
2346 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2348 if (f1 & CISTPL_IDE_UNIQUE)
2351 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2353 if (f2 & CISTPL_IDE_HAS_SLEEP)
2356 if (f2 & CISTPL_IDE_HAS_STANDBY)
2357 puts (" [standby]");
2359 if (f2 & CISTPL_IDE_HAS_IDLE)
2362 if (f2 & CISTPL_IDE_LOW_POWER)
2363 puts (" [low power]");
2365 if (f2 & CISTPL_IDE_REG_INHIBIT)
2366 puts (" [reg inhibit]");
2368 if (f2 & CISTPL_IDE_HAS_INDEX)
2371 if (f2 & CISTPL_IDE_IOIS16)
2379 #endif /* CONFIG_IDE_8xx_PCCARD */
2381 /* -------------------------------------------------------------------- */
2383 #ifdef CONFIG_IDE_8xx_PCCARD
2385 #define MAX_IDENT_CHARS 64
2386 #define MAX_IDENT_FIELDS 4
2388 static uchar *known_cards[] = {
2393 static int identify (volatile uchar *p)
2395 uchar id_str[MAX_IDENT_CHARS];
2402 return (0); /* Don't know */
2407 for (i=0; i<=4 && !done; ++i, p+=2) {
2408 while ((data = *p) != '\0') {
2414 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2424 while (--t > id_str) {
2433 for (card=known_cards; *card; ++card) {
2434 debug ("## Compare against \"%s\"\n", *card);
2435 if (strcmp(*card, id_str) == 0) { /* found! */
2436 debug ("## CARD FOUND ##\n");
2441 return (0); /* don't know */
2443 #endif /* CONFIG_IDE_8xx_PCCARD */
2445 /* -------------------------------------------------------------------- */
2447 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */