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 static int check_ide_device (int slot)
273 volatile uchar *ident = NULL;
274 volatile uchar *feature_p[MAX_FEATURES];
275 volatile uchar *p, *start, *addr;
279 ushort config_base = 0;
283 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
284 CFG_PCMCIA_MEM_SIZE * (slot * 4));
285 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
287 start = p = (volatile uchar *) addr;
289 while ((p - start) < MAX_TUPEL_SZ) {
293 if (code == 0xFF) { /* End of chain */
298 #if defined(DEBUG) && (DEBUG > 1)
299 { volatile uchar *q = p;
300 printf ("\nTuple code %02x length %d\n\tData:",
303 for (i = 0; i < len; ++i) {
304 printf (" %02x", *q);
314 /* Fix for broken SanDisk which may have 0x80 bit set */
318 if (n_features < MAX_FEATURES)
319 feature_p[n_features++] = p;
322 config_base = (*(p+6) << 8) + (*(p+4));
323 debug ("\n## Config_base = %04x ###\n", config_base);
330 found = identify (ident);
332 if (func_id != ((uchar)~0)) {
333 print_funcid (func_id);
335 if (func_id == CISTPL_FUNCID_FIXED)
338 return (1); /* no disk drive */
341 for (i=0; i<n_features; ++i) {
342 print_fixed (feature_p[i]);
346 printf ("unknown card type\n");
350 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
351 *((uchar *)(addr + config_base)) = 1;
355 #endif /* CONFIG_IDE_8xx_PCCARD */
357 /* -------------------------------------------------------------------- */
360 /* -------------------------------------------------------------------- */
361 /* board specific stuff: */
362 /* voltage_set(), hardware_enable() and hardware_disable() */
363 /* -------------------------------------------------------------------- */
365 /* -------------------------------------------------------------------- */
366 /* RPX Boards from Embedded Planet */
367 /* -------------------------------------------------------------------- */
369 #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
371 /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
372 * SYPCR is write once only, therefore must the slowest memory be faster
373 * than the bus monitor or we will get a machine check due to the bus timeout.
376 #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
378 #undef PCMCIA_BMT_LIMIT
379 #define PCMCIA_BMT_LIMIT (6*8)
381 static int voltage_set(int slot, int vcc, int vpp)
387 case 33: reg |= BCSR1_PCVCTL4; break;
388 case 50: reg |= BCSR1_PCVCTL5; break;
397 reg |= BCSR1_PCVCTL6;
402 reg |= BCSR1_PCVCTL7;
409 /* first, turn off all power */
411 *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
412 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
414 /* enable new powersettings */
416 *((uint *)RPX_CSR_ADDR) |= reg;
421 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
422 static int hardware_enable (int slot)
424 return 0; /* No hardware to enable */
426 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
427 static int hardware_disable(int slot)
429 return 0; /* No hardware to disable */
431 #endif /* CFG_CMD_PCMCIA */
432 #endif /* CONFIG_RPXCLASSIC */
434 /* -------------------------------------------------------------------- */
435 /* (F)ADS Boards from Motorola */
436 /* -------------------------------------------------------------------- */
438 #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
441 #define PCMCIA_BOARD_MSG "ADS"
442 #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
444 #define PCMCIA_BOARD_MSG "FADS"
447 static int voltage_set(int slot, int vcc, int vpp)
452 case 0: reg = 0; break;
453 case 50: reg = 1; break;
454 case 120: reg = 2; break;
459 case 0: reg = 0; break;
461 case 50: reg = BCSR1_PCCVCCON; break;
464 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
465 case 50: reg = BCSR1_PCCVCC1; break;
470 /* first, turn off all power */
473 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
476 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
478 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
480 /* enable new powersettings */
483 *((uint *)BCSR1) &= ~reg;
486 *((uint *)BCSR1) |= reg;
489 *((uint *)BCSR1) |= reg << 20;
494 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
496 static int hardware_enable(int slot)
498 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
502 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
503 static int hardware_disable(int slot)
505 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
508 #endif /* CFG_CMD_PCMCIA */
512 /* -------------------------------------------------------------------- */
513 /* TQM8xxL Boards by TQ Components */
514 /* -------------------------------------------------------------------- */
516 #if defined(CONFIG_TQM8xxL)
518 #define PCMCIA_BOARD_MSG "TQM8xxL"
521 static int hardware_enable(int slot)
523 volatile immap_t *immap;
524 volatile cpm8xx_t *cp;
525 volatile pcmconf8xx_t *pcmp;
526 volatile sysconf8xx_t *sysp;
529 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
533 immap = (immap_t *)CFG_IMMR;
534 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
535 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
536 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
539 * Configure SIUMCR to enable PCMCIA port B
540 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
542 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
544 /* clear interrupt state, and disable interrupts */
545 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
546 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
549 * Disable interrupts, DMA, and PCMCIA buffers
550 * (isolate the interface) and assert RESET signal
552 debug ("Disable PCMCIA buffers and assert RESET\n");
554 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
555 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
556 PCMCIA_PGCRX(_slot_) = reg;
560 * Configure Port C pins for
561 * 5 Volts Enable and 3 Volts enable
563 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
564 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
565 /* remove all power */
567 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
570 * Make sure there is a card in the slot, then configure the interface.
573 debug ("[%d] %s: PIPR(%p)=0x%x\n",
574 __LINE__,__FUNCTION__,
575 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
576 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
577 printf (" No Card found\n");
584 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
585 reg = pcmp->pcmc_pipr;
586 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
588 (reg&PCMCIA_VS1(slot))?"n":"ff",
589 (reg&PCMCIA_VS2(slot))?"n":"ff");
590 if ((reg & mask) == mask) {
591 immap->im_ioport.iop_pcdat |= 0x0004;
592 puts (" 5.0V card found: ");
594 immap->im_ioport.iop_pcdat |= 0x0002;
595 puts (" 3.3V card found: ");
597 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
599 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
600 cp->cp_pbdir &= ~(0x0020 | 0x0010);
601 cp->cp_pbpar &= ~(0x0020 | 0x0010);
605 debug ("Enable PCMCIA buffers and stop RESET\n");
606 reg = PCMCIA_PGCRX(_slot_);
607 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
608 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
609 PCMCIA_PGCRX(_slot_) = reg;
611 udelay(250000); /* some cards need >150 ms to come up :-( */
613 debug ("# hardware_enable done\n");
620 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
621 static int hardware_disable(int slot)
623 volatile immap_t *immap;
624 volatile pcmconf8xx_t *pcmp;
627 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
629 immap = (immap_t *)CFG_IMMR;
630 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
632 /* remove all power */
633 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
635 debug ("Disable PCMCIA buffers and assert RESET\n");
637 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
638 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
639 PCMCIA_PGCRX(_slot_) = reg;
645 #endif /* CFG_CMD_PCMCIA */
649 static int voltage_set(int slot, int vcc, int vpp)
651 volatile immap_t *immap;
652 volatile pcmconf8xx_t *pcmp;
655 debug ("voltage_set: "
657 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
658 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
660 immap = (immap_t *)CFG_IMMR;
661 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
663 * Disable PCMCIA buffers (isolate the interface)
664 * and assert RESET signal
666 debug ("Disable PCMCIA buffers and assert RESET\n");
667 reg = PCMCIA_PGCRX(_slot_);
668 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
669 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
670 PCMCIA_PGCRX(_slot_) = reg;
674 * Configure Port C pins for
675 * 5 Volts Enable and 3 Volts enable,
678 debug ("PCMCIA power OFF\n");
679 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
680 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
681 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
686 case 33: reg |= 0x0002; break;
687 case 50: reg |= 0x0004; break;
691 /* Checking supported voltages */
693 debug ("PIPR: 0x%x --> %s\n",
695 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
697 immap->im_ioport.iop_pcdat |= reg;
698 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
700 debug ("PCMCIA powered at %sV\n",
701 (reg&0x0004) ? "5.0" : "3.3");
703 debug ("PCMCIA powered down\n");
707 debug ("Enable PCMCIA buffers and stop RESET\n");
708 reg = PCMCIA_PGCRX(_slot_);
709 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
710 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
711 PCMCIA_PGCRX(_slot_) = reg;
714 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
722 /* -------------------------------------------------------------------- */
724 /* -------------------------------------------------------------------- */
726 #if defined(CONFIG_LWMON)
728 #define PCMCIA_BOARD_MSG "LWMON"
730 /* #define's for MAX1604 Power Switch */
731 #define MAX1604_OP_SUS 0x80
732 #define MAX1604_VCCBON 0x40
733 #define MAX1604_VCC_35 0x20
734 #define MAX1604_VCCBHIZ 0x10
735 #define MAX1604_VPPBON 0x08
736 #define MAX1604_VPPBPBPGM 0x04
737 #define MAX1604_VPPBHIZ 0x02
740 static int hardware_enable(int slot)
742 volatile immap_t *immap;
743 volatile cpm8xx_t *cp;
744 volatile pcmconf8xx_t *pcmp;
745 volatile sysconf8xx_t *sysp;
750 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
752 /* Switch on PCMCIA port in PIC register 0x60 */
753 reg = pic_read (0x60);
754 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
756 /* reg |= 0x08; Vpp not needed */
757 pic_write (0x60, reg);
759 reg = pic_read (0x60);
760 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
764 immap = (immap_t *)CFG_IMMR;
765 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
766 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
767 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
770 * Configure SIUMCR to enable PCMCIA port B
771 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
773 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
775 /* clear interrupt state, and disable interrupts */
776 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
777 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
780 * Disable interrupts, DMA, and PCMCIA buffers
781 * (isolate the interface) and assert RESET signal
783 debug ("Disable PCMCIA buffers and assert RESET\n");
785 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
786 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
787 PCMCIA_PGCRX(_slot_) = reg;
791 * Make sure there is a card in the slot, then configure the interface.
794 debug ("[%d] %s: PIPR(%p)=0x%x\n",
795 __LINE__,__FUNCTION__,
796 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
797 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
798 printf (" No Card found\n");
805 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
806 reg = pcmp->pcmc_pipr;
807 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
809 (reg&PCMCIA_VS1(slot))?"n":"ff",
810 (reg&PCMCIA_VS2(slot))?"n":"ff");
811 if ((reg & mask) == mask) {
812 val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
813 puts (" 5.0V card found: ");
815 val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
816 puts (" 3.3V card found: ");
820 val |= MAX1604_OP_SUS | MAX1604_VCCBON;
821 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
822 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
826 debug ("Enable PCMCIA buffers and stop RESET\n");
827 reg = PCMCIA_PGCRX(_slot_);
828 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
829 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
830 PCMCIA_PGCRX(_slot_) = reg;
832 udelay(250000); /* some cards need >150 ms to come up :-( */
834 debug ("# hardware_enable done\n");
841 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
842 static int hardware_disable(int slot)
844 volatile immap_t *immap;
845 volatile pcmconf8xx_t *pcmp;
849 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
851 immap = (immap_t *)CFG_IMMR;
852 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
854 /* remove all power, put output in high impedance state */
855 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
856 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
857 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
859 /* Configure PCMCIA General Control Register */
860 debug ("Disable PCMCIA buffers and assert RESET\n");
862 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
863 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
864 PCMCIA_PGCRX(_slot_) = reg;
866 /* Switch off PCMCIA port in PIC register 0x60 */
867 reg = pic_read (0x60);
868 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
871 pic_write (0x60, reg);
873 reg = pic_read (0x60);
874 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
880 #endif /* CFG_CMD_PCMCIA */
884 static int voltage_set(int slot, int vcc, int vpp)
886 volatile immap_t *immap;
887 volatile pcmconf8xx_t *pcmp;
891 debug ("voltage_set: "
893 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
894 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
896 immap = (immap_t *)CFG_IMMR;
897 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
899 * Disable PCMCIA buffers (isolate the interface)
900 * and assert RESET signal
902 debug ("Disable PCMCIA buffers and assert RESET\n");
903 reg = PCMCIA_PGCRX(_slot_);
904 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
905 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
906 PCMCIA_PGCRX(_slot_) = reg;
910 * Turn off all power (switch to high impedance)
912 debug ("PCMCIA power OFF\n");
913 val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
914 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
915 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
920 case 33: val = MAX1604_VCC_35; break;
925 /* Checking supported voltages */
927 debug ("PIPR: 0x%x --> %s\n",
929 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
931 i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
933 debug ("PCMCIA powered at %sV\n",
934 (val & MAX1604_VCC_35) ? "3.3" : "5.0");
936 debug ("PCMCIA powered down\n");
940 debug ("Enable PCMCIA buffers and stop RESET\n");
941 reg = PCMCIA_PGCRX(_slot_);
942 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
943 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
944 PCMCIA_PGCRX(_slot_) = reg;
947 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
954 /* -------------------------------------------------------------------- */
955 /* GTH board by Corelatus AB */
956 /* -------------------------------------------------------------------- */
957 #if defined(CONFIG_GTH)
959 #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
961 static int voltage_set (int slot, int vcc, int vpp)
966 static int hardware_enable (int slot)
968 volatile immap_t *immap;
969 volatile cpm8xx_t *cp;
970 volatile pcmconf8xx_t *pcmp;
971 volatile sysconf8xx_t *sysp;
974 debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
976 immap = (immap_t *) CFG_IMMR;
977 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
978 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
979 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
981 /* clear interrupt state, and disable interrupts */
982 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
983 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
986 * Disable interrupts, DMA, and PCMCIA buffers
987 * (isolate the interface) and assert RESET signal
989 debug ("Disable PCMCIA buffers and assert RESET\n");
991 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
992 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
993 PCMCIA_PGCRX (_slot_) = reg;
997 * Make sure there is a card in the slot,
998 * then configure the interface.
1001 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1002 __LINE__, __FUNCTION__,
1003 &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
1004 if (pcmp->pcmc_pipr & 0x98000000) {
1005 printf (" No Card found\n");
1009 mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
1010 reg = pcmp->pcmc_pipr;
1011 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1013 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1014 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1016 debug ("Enable PCMCIA buffers and stop RESET\n");
1017 reg = PCMCIA_PGCRX (_slot_);
1018 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1019 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1020 PCMCIA_PGCRX (_slot_) = reg;
1022 udelay (250000); /* some cards need >150 ms to come up :-( */
1024 debug ("# hardware_enable done\n");
1028 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1029 static int hardware_disable(int slot)
1031 return 0; /* No hardware to disable */
1033 #endif /* CFG_CMD_PCMCIA */
1034 #endif /* CONFIG_GTH */
1036 /* -------------------------------------------------------------------- */
1037 /* ICU862 Boards by Cambridge Broadband Ltd. */
1038 /* -------------------------------------------------------------------- */
1040 #if defined(CONFIG_ICU862)
1042 #define PCMCIA_BOARD_MSG "ICU862"
1044 static void cfg_port_B (void);
1046 static int hardware_enable(int slot)
1048 volatile immap_t *immap;
1049 volatile cpm8xx_t *cp;
1050 volatile pcmconf8xx_t *pcmp;
1051 volatile sysconf8xx_t *sysp;
1052 uint reg, pipr, mask;
1055 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1059 immap = (immap_t *)CFG_IMMR;
1060 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1061 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1062 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1064 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
1068 * Configure SIUMCR to enable PCMCIA port B
1069 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1071 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1073 /* clear interrupt state, and disable interrupts */
1074 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1075 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1078 * Disable interrupts, DMA, and PCMCIA buffers
1079 * (isolate the interface) and assert RESET signal
1081 debug ("Disable PCMCIA buffers and assert RESET\n");
1083 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1084 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1085 PCMCIA_PGCRX(_slot_) = reg;
1089 * Make sure there is a card in the slot, then configure the interface.
1092 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1093 __LINE__,__FUNCTION__,
1094 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1095 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1096 printf (" No Card found\n");
1101 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1103 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1104 pipr = pcmp->pcmc_pipr;
1105 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1107 (reg&PCMCIA_VS1(slot))?"n":"ff",
1108 (reg&PCMCIA_VS2(slot))?"n":"ff");
1111 if ((pipr & mask) == mask) {
1112 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1113 TPS2205_VCC3); /* 3V off */
1114 reg &= ~(TPS2205_VCC5); /* 5V on */
1115 puts (" 5.0V card found: ");
1117 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1118 TPS2205_VCC5); /* 5V off */
1119 reg &= ~(TPS2205_VCC3); /* 3V on */
1120 puts (" 3.3V card found: ");
1123 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
1125 (reg & TPS2205_VCC3) ? "off" : "on",
1126 (reg & TPS2205_VCC5) ? "off" : "on",
1127 (reg & TPS2205_VPP_PGM) ? "off" : "on",
1128 (reg & TPS2205_VPP_VCC) ? "off" : "on" );
1132 /* Wait 500 ms; use this to check for over-current */
1133 for (i=0; i<5000; ++i) {
1134 if ((cp->cp_pbdat & TPS2205_OC) == 0) {
1135 printf (" *** Overcurrent - Safety shutdown ***\n");
1136 cp->cp_pbdat &= ~(TPS2205_SHDN);
1142 debug ("Enable PCMCIA buffers and stop RESET\n");
1143 reg = PCMCIA_PGCRX(_slot_);
1144 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1145 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1146 PCMCIA_PGCRX(_slot_) = reg;
1148 udelay(250000); /* some cards need >150 ms to come up :-( */
1150 debug ("# hardware_enable done\n");
1157 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1158 static int hardware_disable(int slot)
1160 volatile immap_t *immap;
1161 volatile cpm8xx_t *cp;
1162 volatile pcmconf8xx_t *pcmp;
1165 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1167 immap = (immap_t *)CFG_IMMR;
1168 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1169 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1172 cp->cp_pbdat &= ~(TPS2205_SHDN);
1174 /* Configure PCMCIA General Control Register */
1175 debug ("Disable PCMCIA buffers and assert RESET\n");
1177 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1178 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1179 PCMCIA_PGCRX(_slot_) = reg;
1185 #endif /* CFG_CMD_PCMCIA */
1189 static int voltage_set(int slot, int vcc, int vpp)
1191 volatile immap_t *immap;
1192 volatile cpm8xx_t *cp;
1193 volatile pcmconf8xx_t *pcmp;
1196 debug ("voltage_set: "
1198 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1199 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1201 immap = (immap_t *)CFG_IMMR;
1202 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1203 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1205 * Disable PCMCIA buffers (isolate the interface)
1206 * and assert RESET signal
1208 debug ("Disable PCMCIA buffers and assert RESET\n");
1209 reg = PCMCIA_PGCRX(_slot_);
1210 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1211 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1212 PCMCIA_PGCRX(_slot_) = reg;
1216 * Configure Port C pins for
1217 * 5 Volts Enable and 3 Volts enable,
1218 * Turn all power pins to Hi-Z
1220 debug ("PCMCIA power OFF\n");
1221 cfg_port_B (); /* Enables switch, but all in Hi-Z */
1226 case 0: break; /* Switch off */
1227 case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
1228 case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
1232 /* Checking supported voltages */
1234 debug ("PIPR: 0x%x --> %s\n",
1236 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1244 if ((reg & TPS2205_VCC3) == 0) {
1246 } else if ((reg & TPS2205_VCC5) == 0) {
1251 printf ("PCMCIA powered %s\n", s);
1256 debug ("Enable PCMCIA buffers and stop RESET\n");
1257 reg = PCMCIA_PGCRX(_slot_);
1258 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1259 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1260 PCMCIA_PGCRX(_slot_) = reg;
1263 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1268 static void cfg_port_B (void)
1270 volatile immap_t *immap;
1271 volatile cpm8xx_t *cp;
1274 immap = (immap_t *)CFG_IMMR;
1275 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1278 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
1280 * Switch off all voltages, assert shutdown
1283 reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
1284 TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
1285 TPS2205_SHDN); /* enable switch */
1288 cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
1290 reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
1291 cp->cp_pbdir = reg | TPS2205_OUTPUTS;
1293 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1294 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1300 /* -------------------------------------------------------------------- */
1301 /* C2MON Boards by TTTech Computertechnik AG */
1302 /* -------------------------------------------------------------------- */
1304 #if defined(CONFIG_C2MON)
1306 #define PCMCIA_BOARD_MSG "C2MON"
1308 static void cfg_ports (void);
1310 static int hardware_enable(int slot)
1312 volatile immap_t *immap;
1313 volatile cpm8xx_t *cp;
1314 volatile pcmconf8xx_t *pcmp;
1315 volatile sysconf8xx_t *sysp;
1316 uint reg, pipr, mask;
1320 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1324 immap = (immap_t *)CFG_IMMR;
1325 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1326 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1327 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1329 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
1333 * Configure SIUMCR to enable PCMCIA port B
1334 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1336 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1338 /* clear interrupt state, and disable interrupts */
1339 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1340 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1343 * Disable interrupts, DMA, and PCMCIA buffers
1344 * (isolate the interface) and assert RESET signal
1346 debug ("Disable PCMCIA buffers and assert RESET\n");
1348 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1349 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1350 PCMCIA_PGCRX(_slot_) = reg;
1354 * Make sure there is a card in the slot, then configure the interface.
1357 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1358 __LINE__,__FUNCTION__,
1359 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1360 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1361 printf (" No Card found\n");
1366 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
1368 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1369 pipr = pcmp->pcmc_pipr;
1370 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1372 (reg&PCMCIA_VS1(slot))?"n":"ff",
1373 (reg&PCMCIA_VS2(slot))?"n":"ff");
1375 sreg = immap->im_ioport.iop_pcdat;
1376 if ((pipr & mask) == mask) {
1377 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1378 TPS2211_VCCD1); /* 5V on */
1379 sreg &= ~(TPS2211_VCCD0); /* 3V off */
1380 puts (" 5.0V card found: ");
1382 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
1383 TPS2211_VCCD0); /* 3V on */
1384 sreg &= ~(TPS2211_VCCD1); /* 5V off */
1385 puts (" 3.3V card found: ");
1388 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
1390 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
1391 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
1394 immap->im_ioport.iop_pcdat = sreg;
1396 /* Wait 500 ms; use this to check for over-current */
1397 for (i=0; i<5000; ++i) {
1398 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
1399 printf (" *** Overcurrent - Safety shutdown ***\n");
1400 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
1406 debug ("Enable PCMCIA buffers and stop RESET\n");
1407 reg = PCMCIA_PGCRX(_slot_);
1408 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1409 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1410 PCMCIA_PGCRX(_slot_) = reg;
1412 udelay(250000); /* some cards need >150 ms to come up :-( */
1414 debug ("# hardware_enable done\n");
1421 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1422 static int hardware_disable(int slot)
1424 volatile immap_t *immap;
1425 volatile cpm8xx_t *cp;
1426 volatile pcmconf8xx_t *pcmp;
1429 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1431 immap = (immap_t *)CFG_IMMR;
1432 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1434 /* Configure PCMCIA General Control Register */
1435 debug ("Disable PCMCIA buffers and assert RESET\n");
1437 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1438 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1439 PCMCIA_PGCRX(_slot_) = reg;
1441 /* ALl voltages off / Hi-Z */
1442 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
1443 TPS2211_VCCD0 | TPS2211_VCCD1 );
1449 #endif /* CFG_CMD_PCMCIA */
1453 static int voltage_set(int slot, int vcc, int vpp)
1455 volatile immap_t *immap;
1456 volatile cpm8xx_t *cp;
1457 volatile pcmconf8xx_t *pcmp;
1461 debug ("voltage_set: "
1463 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1464 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1466 immap = (immap_t *)CFG_IMMR;
1467 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1468 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1470 * Disable PCMCIA buffers (isolate the interface)
1471 * and assert RESET signal
1473 debug ("Disable PCMCIA buffers and assert RESET\n");
1474 reg = PCMCIA_PGCRX(_slot_);
1475 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1476 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1477 PCMCIA_PGCRX(_slot_) = reg;
1481 * Configure Port C pins for
1482 * 5 Volts Enable and 3 Volts enable,
1483 * Turn all power pins to Hi-Z
1485 debug ("PCMCIA power OFF\n");
1486 cfg_ports (); /* Enables switch, but all in Hi-Z */
1488 sreg = immap->im_ioport.iop_pcdat;
1489 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
1492 case 0: break; /* Switch off */
1493 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
1494 sreg &= ~TPS2211_VCCD1;
1496 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
1497 sreg |= TPS2211_VCCD1;
1502 /* Checking supported voltages */
1504 debug ("PIPR: 0x%x --> %s\n",
1506 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1508 immap->im_ioport.iop_pcdat = sreg;
1514 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
1516 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
1521 printf ("PCMCIA powered %s\n", s);
1526 debug ("Enable PCMCIA buffers and stop RESET\n");
1527 reg = PCMCIA_PGCRX(_slot_);
1528 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1529 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1530 PCMCIA_PGCRX(_slot_) = reg;
1533 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1538 static void cfg_ports (void)
1540 volatile immap_t *immap;
1541 volatile cpm8xx_t *cp;
1544 immap = (immap_t *)CFG_IMMR;
1545 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1548 * Configure Port C for TPS2211 PC-Card Power-Interface Switch
1550 * Switch off all voltages, assert shutdown
1552 sreg = immap->im_ioport.iop_pcdat;
1553 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
1554 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
1555 immap->im_ioport.iop_pcdat = sreg;
1557 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
1558 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
1560 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
1561 immap->im_ioport.iop_pcpar,
1562 immap->im_ioport.iop_pcdir,
1563 immap->im_ioport.iop_pcdat);
1566 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
1568 * Over-Current Input only
1570 cp->cp_pbpar &= ~(TPS2211_INPUTS);
1571 cp->cp_pbdir &= ~(TPS2211_INPUTS);
1573 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
1574 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
1579 /* -------------------------------------------------------------------- */
1580 /* MBX board from Morotola */
1581 /* -------------------------------------------------------------------- */
1583 #if defined( CONFIG_MBX )
1584 #include <../board/mbx8xx/csr.h>
1586 /* A lot of this has been taken from the RPX code in this file it works from me.
1587 I have added the voltage selection for the MBX board. */
1589 /* MBX voltage bit in control register #2 */
1590 #define CR2_VPP12 ((uchar)0x10)
1591 #define CR2_VPPVDD ((uchar)0x20)
1592 #define CR2_VDD5 ((uchar)0x40)
1593 #define CR2_VDD3 ((uchar)0x80)
1595 #define PCMCIA_BOARD_MSG "MBX860"
1597 static int voltage_set (int slot, int vcc, int vpp)
1601 debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1602 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
1635 /* first, turn off all power */
1636 MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
1638 /* enable new powersettings */
1640 debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
1645 static int hardware_enable (int slot)
1647 volatile immap_t *immap;
1648 volatile cpm8xx_t *cp;
1649 volatile pcmconf8xx_t *pcmp;
1650 volatile sysconf8xx_t *sysp;
1653 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
1658 immap = (immap_t *) CFG_IMMR;
1659 sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
1660 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
1661 cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
1663 /* clear interrupt state, and disable interrupts */
1664 pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
1665 pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
1668 * Disable interrupts, DMA, and PCMCIA buffers
1669 * (isolate the interface) and assert RESET signal
1671 debug ("Disable PCMCIA buffers and assert RESET\n");
1673 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1674 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1675 PCMCIA_PGCRX (_slot_) = reg;
1678 /* remove all power */
1679 voltage_set (slot, 0, 0);
1681 * Make sure there is a card in the slot, then configure the interface.
1684 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1685 __LINE__,__FUNCTION__,
1686 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1687 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1688 printf (" No Card found\n");
1695 mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
1696 reg = pcmp->pcmc_pipr;
1697 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
1698 (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
1699 (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
1701 if ((reg & mask) == mask) {
1702 voltage_set (_slot_, 50, 0);
1703 printf (" 5.0V card found: ");
1705 voltage_set (_slot_, 33, 0);
1706 printf (" 3.3V card found: ");
1709 debug ("Enable PCMCIA buffers and stop RESET\n");
1710 reg = PCMCIA_PGCRX (_slot_);
1711 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1712 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1713 PCMCIA_PGCRX (_slot_) = reg;
1715 udelay (250000); /* some cards need >150 ms to come up :-( */
1717 debug ("# hardware_enable done\n");
1722 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1723 static int hardware_disable (int slot)
1725 return 0; /* No hardware to disable */
1727 #endif /* CFG_CMD_PCMCIA */
1728 #endif /* CONFIG_MBX */
1729 /* -------------------------------------------------------------------- */
1731 /* -------------------------------------------------------------------- */
1733 #if defined(CONFIG_R360MPI)
1735 #define PCMCIA_BOARD_MSG "R360MPI"
1738 static int hardware_enable(int slot)
1740 volatile immap_t *immap;
1741 volatile cpm8xx_t *cp;
1742 volatile pcmconf8xx_t *pcmp;
1743 volatile sysconf8xx_t *sysp;
1746 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1750 immap = (immap_t *)CFG_IMMR;
1751 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1752 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1753 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1756 * Configure SIUMCR to enable PCMCIA port B
1757 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1759 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1761 /* clear interrupt state, and disable interrupts */
1762 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
1763 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
1766 * Disable interrupts, DMA, and PCMCIA buffers
1767 * (isolate the interface) and assert RESET signal
1769 debug ("Disable PCMCIA buffers and assert RESET\n");
1771 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1772 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1773 PCMCIA_PGCRX(_slot_) = reg;
1777 * Configure Ports A, B & C pins for
1778 * 5 Volts Enable and 3 Volts enable
1780 immap->im_ioport.iop_pcpar &= ~(0x0400);
1781 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1782 immap->im_ioport.iop_pcdir |= 0x0400;*/
1784 immap->im_ioport.iop_papar &= ~(0x0200);/*
1785 immap->im_ioport.iop_padir |= 0x0200;*/
1787 immap->im_ioport.iop_pbpar &= ~(0xC000);
1788 immap->im_ioport.iop_pbdir &= ~(0xC000);
1790 /* remove all power */
1792 immap->im_ioport.iop_pcdat |= 0x0400;
1793 immap->im_ioport.iop_padat |= 0x0200;
1796 * Make sure there is a card in the slot, then configure the interface.
1799 debug ("[%d] %s: PIPR(%p)=0x%x\n",
1800 __LINE__,__FUNCTION__,
1801 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
1802 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
1803 printf (" No Card found\n");
1810 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
1811 reg = pcmp->pcmc_pipr;
1812 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
1814 (reg&PCMCIA_VS1(slot))?"n":"ff",
1815 (reg&PCMCIA_VS2(slot))?"n":"ff");
1816 if ((reg & mask) == mask) {
1817 immap->im_ioport.iop_pcdat &= ~(0x4000);
1818 puts (" 5.0V card found: ");
1820 immap->im_ioport.iop_padat &= ~(0x0002);
1821 puts (" 3.3V card found: ");
1823 immap->im_ioport.iop_pcdir |= 0x0400;
1824 immap->im_ioport.iop_padir |= 0x0200;
1826 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
1827 cp->cp_pbdir &= ~(0x0020 | 0x0010);
1828 cp->cp_pbpar &= ~(0x0020 | 0x0010);
1831 debug ("Enable PCMCIA buffers and stop RESET\n");
1832 reg = PCMCIA_PGCRX(_slot_);
1833 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
1834 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
1835 PCMCIA_PGCRX(_slot_) = reg;
1837 udelay(250000); /* some cards need >150 ms to come up :-( */
1839 debug ("# hardware_enable done\n");
1846 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
1847 static int hardware_disable(int slot)
1849 volatile immap_t *immap;
1850 volatile pcmconf8xx_t *pcmp;
1853 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1855 immap = (immap_t *)CFG_IMMR;
1856 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1858 /* remove all power */
1859 immap->im_ioport.iop_pcdat |= 0x0400;
1860 immap->im_ioport.iop_padat |= 0x0200;
1862 /* Configure PCMCIA General Control Register */
1863 debug ("Disable PCMCIA buffers and assert RESET\n");
1865 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1866 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1867 PCMCIA_PGCRX(_slot_) = reg;
1873 #endif /* CFG_CMD_PCMCIA */
1877 static int voltage_set(int slot, int vcc, int vpp)
1879 volatile immap_t *immap;
1880 volatile pcmconf8xx_t *pcmp;
1883 debug ("voltage_set: "
1885 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
1886 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
1888 immap = (immap_t *)CFG_IMMR;
1889 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1891 * Disable PCMCIA buffers (isolate the interface)
1892 * and assert RESET signal
1894 debug ("Disable PCMCIA buffers and assert RESET\n");
1895 reg = PCMCIA_PGCRX(_slot_);
1896 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
1897 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
1898 PCMCIA_PGCRX(_slot_) = reg;
1902 * Configure Ports A & C pins for
1903 * 5 Volts Enable and 3 Volts enable,
1904 * Turn off all power
1906 debug ("PCMCIA power OFF\n");
1907 immap->im_ioport.iop_pcpar &= ~(0x0400);
1908 immap->im_ioport.iop_pcso &= ~(0x0400);/*
1909 immap->im_ioport.iop_pcdir |= 0x0400;*/
1911 immap->im_ioport.iop_papar &= ~(0x0200);/*
1912 immap->im_ioport.iop_padir |= 0x0200;*/
1914 immap->im_ioport.iop_pcdat |= 0x0400;
1915 immap->im_ioport.iop_padat |= 0x0200;
1920 case 33: reg |= 0x0200; break;
1921 case 50: reg |= 0x0400; break;
1925 /* Checking supported voltages */
1927 debug ("PIPR: 0x%x --> %s\n",
1929 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
1932 immap->im_ioport.iop_pcdat &= !reg;
1934 immap->im_ioport.iop_padat &= !reg;
1935 immap->im_ioport.iop_pcdir |= 0x0200;
1936 immap->im_ioport.iop_padir |= 0x0400;
1938 debug ("PCMCIA powered at %sV\n",
1939 (reg&0x0400) ? "5.0" : "3.3");
1941 debug ("PCMCIA powered down\n");
1945 debug ("Enable PCMCIA buffers and stop 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;
1952 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
1957 #endif /* R360MPI */
1959 /* -------------------------------------------------------------------- */
1961 /* -------------------------------------------------------------------- */
1962 #if defined(CONFIG_KUP4K)
1964 #define PCMCIA_BOARD_MSG "KUP4K"
1966 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
1968 static int hardware_enable(int slot)
1970 volatile immap_t *immap;
1971 volatile cpm8xx_t *cp;
1972 volatile pcmconf8xx_t *pcmp;
1973 volatile sysconf8xx_t *sysp;
1976 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
1980 immap = (immap_t *)CFG_IMMR;
1981 sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
1982 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
1983 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
1986 * Configure SIUMCR to enable PCMCIA port B
1987 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
1989 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
1991 /* clear interrupt state, and disable interrupts */
1992 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
1993 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
1996 * Disable interrupts, DMA, and PCMCIA buffers
1997 * (isolate the interface) and assert RESET signal
1999 debug ("Disable PCMCIA buffers and assert RESET\n");
2001 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2002 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2003 PCMCIA_PGCRX(slot) = reg;
2007 * Configure Port B pins for
2010 if (slot) { /* Slot A is built-in */
2011 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2012 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2013 /* remove all power */
2014 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2017 * Make sure there is a card in the slot, then configure the interface.
2020 debug ("[%d] %s: PIPR(%p)=0x%x\n",
2021 __LINE__,__FUNCTION__,
2022 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
2023 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
2024 printf (" No Card found\n");
2031 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
2032 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
2033 reg = pcmp->pcmc_pipr;
2034 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
2036 (reg&PCMCIA_VS1(slot))?"n":"ff",
2037 (reg&PCMCIA_VS2(slot))?"n":"ff");
2038 if ((reg & mask) == mask) {
2039 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
2042 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2043 puts (" 3.3V card found: ");
2046 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
2047 cp->cp_pbdir &= ~(0x0020 | 0x0010);
2048 cp->cp_pbpar &= ~(0x0020 | 0x0010);
2051 debug ("Enable PCMCIA buffers and stop RESET\n");
2052 reg = PCMCIA_PGCRX(slot);
2053 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2054 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2055 PCMCIA_PGCRX(slot) = reg;
2057 udelay(250000); /* some cards need >150 ms to come up :-( */
2059 debug ("# hardware_enable done\n");
2066 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
2067 static int hardware_disable(int slot)
2069 volatile immap_t *immap;
2070 volatile cpm8xx_t *cp;
2071 volatile pcmconf8xx_t *pcmp;
2074 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
2076 immap = (immap_t *)CFG_IMMR;
2077 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2078 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2080 /* remove all power */
2082 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
2084 /* Configure PCMCIA General Control Register */
2085 debug ("Disable PCMCIA buffers and assert RESET\n");
2087 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2088 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2089 PCMCIA_PGCRX(slot) = reg;
2095 #endif /* CFG_CMD_PCMCIA */
2099 static int voltage_set(int slot, int vcc, int vpp)
2101 volatile immap_t *immap;
2102 volatile cpm8xx_t *cp;
2103 volatile pcmconf8xx_t *pcmp;
2106 debug ("voltage_set: " \
2108 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
2109 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
2111 if (!slot) /* Slot A is not configurable */
2114 immap = (immap_t *)CFG_IMMR;
2115 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
2116 cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
2119 * Disable PCMCIA buffers (isolate the interface)
2120 * and assert RESET signal
2122 debug ("Disable PCMCIA buffers and assert RESET\n");
2123 reg = PCMCIA_PGCRX(slot);
2124 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
2125 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
2126 PCMCIA_PGCRX(slot) = reg;
2129 debug ("PCMCIA power OFF\n");
2131 * Configure Port B pins for
2134 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
2135 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
2136 /* remove all power */
2137 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
2142 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
2143 debug ("PCMCIA powered at 3.3V\n");
2146 debug ("PCMCIA: 5Volt vcc not supported\n");
2149 puts("PCMCIA: vcc not supported");
2153 /* Checking supported voltages */
2155 debug ("PIPR: 0x%x --> %s\n",
2157 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
2158 ? "only 5 V --> NOT SUPPORTED"
2162 debug ("Enable PCMCIA buffers and stop RESET\n");
2163 reg = PCMCIA_PGCRX(slot);
2164 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
2165 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
2166 PCMCIA_PGCRX(slot) = reg;
2169 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
2180 /* -------------------------------------------------------------------- */
2181 /* End of Board Specific Stuff */
2182 /* -------------------------------------------------------------------- */
2185 /* -------------------------------------------------------------------- */
2186 /* MPC8xx Specific Stuff - should go to MPC8xx directory */
2187 /* -------------------------------------------------------------------- */
2190 * Search this table to see if the windowsize is
2194 #define M8XX_SIZES_NO 32
2196 static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
2197 { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
2198 0x00000080, 0x00000040, 0x00000010, 0x00000020,
2199 0x00008000, 0x00004000, 0x00001000, 0x00002000,
2200 0x00000100, 0x00000200, 0x00000800, 0x00000400,
2202 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
2203 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
2204 0x00010000, 0x00020000, 0x00080000, 0x00040000,
2205 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
2208 /* -------------------------------------------------------------------- */
2210 static u_int m8xx_get_graycode(u_int size)
2214 for (k = 0; k < M8XX_SIZES_NO; k++) {
2215 if(m8xx_size_to_gray[k] == size)
2219 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
2225 /* -------------------------------------------------------------------- */
2228 static u_int m8xx_get_speed(u_int ns, u_int is_io)
2230 u_int reg, clocks, psst, psl, psht;
2235 * We get called with IO maps setup to 0ns
2236 * if not specified by the user.
2237 * They should be 255ns.
2243 ns = 100; /* fast memory if 0 */
2247 * In PSST, PSL, PSHT fields we tell the controller
2248 * timing parameters in CLKOUT clock cycles.
2249 * CLKOUT is the same as GCLK2_50.
2252 /* how we want to adjust the timing - in percent */
2254 #define ADJ 180 /* 80 % longer accesstime - to be sure */
2256 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
2257 clocks = (clocks * ADJ) / (100*1000);
2259 if(clocks >= PCMCIA_BMT_LIMIT) {
2260 DEBUG(0, "Max access time limit reached\n");
2261 clocks = PCMCIA_BMT_LIMIT-1;
2264 psst = clocks / 7; /* setup time */
2265 psht = clocks / 7; /* hold time */
2266 psl = (clocks * 5) / 7; /* strobe length */
2268 psst += clocks - (psst + psht + psl);
2278 /* -------------------------------------------------------------------- */
2280 #ifdef CONFIG_IDE_8xx_PCCARD
2281 static void print_funcid (int func)
2285 case CISTPL_FUNCID_MULTI:
2286 puts (" Multi-Function");
2288 case CISTPL_FUNCID_MEMORY:
2291 case CISTPL_FUNCID_SERIAL:
2292 puts (" Serial Port");
2294 case CISTPL_FUNCID_PARALLEL:
2295 puts (" Parallel Port");
2297 case CISTPL_FUNCID_FIXED:
2298 puts (" Fixed Disk");
2300 case CISTPL_FUNCID_VIDEO:
2301 puts (" Video Adapter");
2303 case CISTPL_FUNCID_NETWORK:
2304 puts (" Network Adapter");
2306 case CISTPL_FUNCID_AIMS:
2307 puts (" AIMS Card");
2309 case CISTPL_FUNCID_SCSI:
2310 puts (" SCSI Adapter");
2318 #endif /* CONFIG_IDE_8xx_PCCARD */
2320 /* -------------------------------------------------------------------- */
2322 #ifdef CONFIG_IDE_8xx_PCCARD
2323 static void print_fixed (volatile uchar *p)
2331 case CISTPL_FUNCE_IDE_IFACE:
2332 { uchar iface = *(p+2);
2334 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
2335 puts (" interface ");
2338 case CISTPL_FUNCE_IDE_MASTER:
2339 case CISTPL_FUNCE_IDE_SLAVE:
2340 { uchar f1 = *(p+2);
2343 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
2345 if (f1 & CISTPL_IDE_UNIQUE)
2348 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
2350 if (f2 & CISTPL_IDE_HAS_SLEEP)
2353 if (f2 & CISTPL_IDE_HAS_STANDBY)
2354 puts (" [standby]");
2356 if (f2 & CISTPL_IDE_HAS_IDLE)
2359 if (f2 & CISTPL_IDE_LOW_POWER)
2360 puts (" [low power]");
2362 if (f2 & CISTPL_IDE_REG_INHIBIT)
2363 puts (" [reg inhibit]");
2365 if (f2 & CISTPL_IDE_HAS_INDEX)
2368 if (f2 & CISTPL_IDE_IOIS16)
2376 #endif /* CONFIG_IDE_8xx_PCCARD */
2378 /* -------------------------------------------------------------------- */
2380 #ifdef CONFIG_IDE_8xx_PCCARD
2382 #define MAX_IDENT_CHARS 64
2383 #define MAX_IDENT_FIELDS 4
2385 static uchar *known_cards[] = {
2390 static int identify (volatile uchar *p)
2392 uchar id_str[MAX_IDENT_CHARS];
2399 return (0); /* Don't know */
2404 for (i=0; i<=4 && !done; ++i, p+=2) {
2405 while ((data = *p) != '\0') {
2411 if (t == &id_str[MAX_IDENT_CHARS-1]) {
2421 while (--t > id_str) {
2430 for (card=known_cards; *card; ++card) {
2431 debug ("## Compare against \"%s\"\n", *card);
2432 if (strcmp(*card, id_str) == 0) { /* found! */
2433 debug ("## CARD FOUND ##\n");
2438 return (0); /* don't know */
2440 #endif /* CONFIG_IDE_8xx_PCCARD */
2442 /* -------------------------------------------------------------------- */
2444 #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */