2 * (C) Copyright 2000-2006
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...
62 /* -------------------------------------------------------------------- */
64 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || defined(CONFIG_CMD_PCMCIA)
66 extern int pcmcia_on (void);
67 extern int pcmcia_off (void);
69 int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
74 printf ("Usage: pinit {on | off}\n");
77 if (strcmp(argv[1],"on") == 0) {
79 } else if (strcmp(argv[1],"off") == 0) {
80 rcode = pcmcia_off ();
82 printf ("Usage: pinit {on | off}\n");
90 pinit, 2, 0, do_pinit,
91 "pinit - PCMCIA sub-system\n",
92 "on - power on PCMCIA socket\n"
93 "pinit off - power off PCMCIA socket\n"
96 #endif /* CONFIG_COMMANDS & CFG_CMD_PCMCIA */
98 /* -------------------------------------------------------------------- */
100 #undef CHECK_IDE_DEVICE
102 #if ((CONFIG_COMMANDS & CFG_CMD_IDE) || defined(CONFIG_CMD_IDE)) \
103 && defined(CONFIG_IDE_8xx_PCCARD)
104 #define CHECK_IDE_DEVICE
107 #if defined(CONFIG_PXA_PCMCIA)
108 #define CHECK_IDE_DEVICE
111 #ifdef CHECK_IDE_DEVICE
113 int ide_devices_found;
114 static uchar *known_cards[] = {
115 (uchar *)"ARGOSY PnPIDE D5",
119 #define MAX_TUPEL_SZ 512
120 #define MAX_FEATURES 4
122 #define MAX_IDENT_CHARS 64
123 #define MAX_IDENT_FIELDS 4
127 static void print_funcid (int func)
131 case CISTPL_FUNCID_MULTI:
132 puts (" Multi-Function");
134 case CISTPL_FUNCID_MEMORY:
137 case CISTPL_FUNCID_SERIAL:
138 puts (" Serial Port");
140 case CISTPL_FUNCID_PARALLEL:
141 puts (" Parallel Port");
143 case CISTPL_FUNCID_FIXED:
144 puts (" Fixed Disk");
146 case CISTPL_FUNCID_VIDEO:
147 puts (" Video Adapter");
149 case CISTPL_FUNCID_NETWORK:
150 puts (" Network Adapter");
152 case CISTPL_FUNCID_AIMS:
155 case CISTPL_FUNCID_SCSI:
156 puts (" SCSI Adapter");
165 static void print_fixed (volatile uchar *p)
173 case CISTPL_FUNCE_IDE_IFACE:
174 { uchar iface = *(p+2);
176 puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
177 puts (" interface ");
180 case CISTPL_FUNCE_IDE_MASTER:
181 case CISTPL_FUNCE_IDE_SLAVE:
185 puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
187 if (f1 & CISTPL_IDE_UNIQUE)
190 puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
192 if (f2 & CISTPL_IDE_HAS_SLEEP)
195 if (f2 & CISTPL_IDE_HAS_STANDBY)
198 if (f2 & CISTPL_IDE_HAS_IDLE)
201 if (f2 & CISTPL_IDE_LOW_POWER)
202 puts (" [low power]");
204 if (f2 & CISTPL_IDE_REG_INHIBIT)
205 puts (" [reg inhibit]");
207 if (f2 & CISTPL_IDE_HAS_INDEX)
210 if (f2 & CISTPL_IDE_IOIS16)
219 static int identify (volatile uchar *p)
221 uchar id_str[MAX_IDENT_CHARS];
228 return (0); /* Don't know */
233 for (i=0; i<=4 && !done; ++i, p+=2) {
234 while ((data = *p) != '\0') {
240 if (t == &id_str[MAX_IDENT_CHARS-1]) {
250 while (--t > id_str) {
256 puts ((char *)id_str);
259 for (card=known_cards; *card; ++card) {
260 debug ("## Compare against \"%s\"\n", *card);
261 if (strcmp((char *)*card, (char *)id_str) == 0) { /* found! */
262 debug ("## CARD FOUND ##\n");
267 return (0); /* don't know */
270 int check_ide_device (int slot)
272 volatile uchar *ident = NULL;
273 volatile uchar *feature_p[MAX_FEATURES];
274 volatile uchar *p, *start, *addr;
278 ushort config_base = 0;
282 addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
283 CFG_PCMCIA_MEM_SIZE * (slot * 4));
284 debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
286 start = p = (volatile uchar *) addr;
288 while ((p - start) < MAX_TUPEL_SZ) {
292 if (code == 0xFF) { /* End of chain */
297 #if defined(DEBUG) && (DEBUG > 1)
298 { volatile uchar *q = p;
299 printf ("\nTuple code %02x length %d\n\tData:",
302 for (i = 0; i < len; ++i) {
303 printf (" %02x", *q);
313 /* Fix for broken SanDisk which may have 0x80 bit set */
317 if (n_features < MAX_FEATURES)
318 feature_p[n_features++] = p;
321 config_base = (*(p+6) << 8) + (*(p+4));
322 debug ("\n## Config_base = %04x ###\n", config_base);
329 found = identify (ident);
331 if (func_id != ((uchar)~0)) {
332 print_funcid (func_id);
334 if (func_id == CISTPL_FUNCID_FIXED)
337 return (1); /* no disk drive */
340 for (i=0; i<n_features; ++i) {
341 print_fixed (feature_p[i]);
345 printf ("unknown card type\n");
349 ide_devices_found |= (1 << slot);
353 /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
354 *((uchar *)(addr + config_base)) = 1;
357 printf("\n## Config_base = %04x ###\n", config_base);
358 printf("Configuration Option Register: %02x @ %x\n", readb(addr + config_base), addr + config_base);
359 printf("Card Configuration and Status Register: %02x\n", readb(addr + config_base + 2));
360 printf("Pin Replacement Register Register: %02x\n", readb(addr + config_base + 4));
361 printf("Socket and Copy Register: %02x\n", readb(addr + config_base + 6));
366 #endif /* CHECK_IDE_DEVICE */