blob: 2479a6662afaeed4a8bab52f9e202f1f54bd5807 [file] [log] [blame]
Nobuhiro Iwamatsu770395e2007-11-25 02:39:31 +09001/*
2 * Marubun MR-SHPC-01 PCMCIA controller device driver
3 *
4 * (c) 2007 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19 * MA 02111-1307 USA
Wolfgang Denk0a5c2142007-12-27 01:52:50 +010020 *
21 */
Nobuhiro Iwamatsu770395e2007-11-25 02:39:31 +090022
23#include <common.h>
24#include <config.h>
25#include <pcmcia.h>
26#include <asm/io.h>
27
Nobuhiro Iwamatsu74eca5b2008-01-15 17:48:13 +090028#undef CONFIG_PCMCIA
29
30#if defined(CONFIG_CMD_PCMCIA)
Nobuhiro Iwamatsu770395e2007-11-25 02:39:31 +090031#define CONFIG_PCMCIA
32#endif
33
Nobuhiro Iwamatsu74eca5b2008-01-15 17:48:13 +090034#if defined(CONFIG_CMD_IDE)
Nobuhiro Iwamatsu770395e2007-11-25 02:39:31 +090035#define CONFIG_PCMCIA
36#endif
37
38#if defined(CONFIG_PCMCIA) \
Wolfgang Denk0a5c2142007-12-27 01:52:50 +010039 && (defined(CONFIG_MARUBUN_PCCARD))
Nobuhiro Iwamatsu770395e2007-11-25 02:39:31 +090040
41/* MR-SHPC-01 register */
42#define MRSHPC_MODE (CFG_MARUBUN_MRSHPC + 4)
43#define MRSHPC_OPTION (CFG_MARUBUN_MRSHPC + 6)
44#define MRSHPC_CSR (CFG_MARUBUN_MRSHPC + 8)
45#define MRSHPC_ISR (CFG_MARUBUN_MRSHPC + 10)
46#define MRSHPC_ICR (CFG_MARUBUN_MRSHPC + 12)
47#define MRSHPC_CPWCR (CFG_MARUBUN_MRSHPC + 14)
48#define MRSHPC_MW0CR1 (CFG_MARUBUN_MRSHPC + 16)
49#define MRSHPC_MW1CR1 (CFG_MARUBUN_MRSHPC + 18)
50#define MRSHPC_IOWCR1 (CFG_MARUBUN_MRSHPC + 20)
51#define MRSHPC_MW0CR2 (CFG_MARUBUN_MRSHPC + 22)
52#define MRSHPC_MW1CR2 (CFG_MARUBUN_MRSHPC + 24)
53#define MRSHPC_IOWCR2 (CFG_MARUBUN_MRSHPC + 26)
54#define MRSHPC_CDCR (CFG_MARUBUN_MRSHPC + 28)
55#define MRSHPC_PCIC_INFO (CFG_MARUBUN_MRSHPC + 30)
56
57int pcmcia_on (void)
58{
59 printf("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
60
61 /* Init */
62 outw( 0x0000 , MRSHPC_MODE );
63
64 if ((inw(MRSHPC_CSR) & 0x000c) == 0){ /* if card detect is true */
65 if ((inw(MRSHPC_CSR) & 0x0080) == 0){
66 outw(0x0674 ,MRSHPC_CPWCR); /* Card Vcc is 3.3v? */
67 }else{
68 outw(0x0678 ,MRSHPC_CPWCR); /* Card Vcc is 5V */
69 }
70 udelay( 100000 ); /* wait for power on */
71 }else{
72 return 1;
73 }
74 /*
75 * PC-Card window open
76 * flag == COMMON/ATTRIBUTE/IO
77 */
78 /* common window open */
79 outw(0x8a84,MRSHPC_MW0CR1); /* window 0xb8400000 */
80 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
81 outw(0x0b00,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 1 */
82 else
83 outw(0x0300,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 0 */
Wolfgang Denk0a5c2142007-12-27 01:52:50 +010084
Nobuhiro Iwamatsu770395e2007-11-25 02:39:31 +090085 /* attribute window open */
86 outw(0x8a85,MRSHPC_MW1CR1); /* window 0xb8500000 */
87 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
88 outw(0x0a00,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 1 */
89 else
90 outw(0x0200,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 0 */
Wolfgang Denk0a5c2142007-12-27 01:52:50 +010091
Nobuhiro Iwamatsu770395e2007-11-25 02:39:31 +090092 /* I/O window open */
93 outw(0x8a86,MRSHPC_IOWCR1); /* I/O window 0xb8600000 */
94 outw(0x0008,MRSHPC_CDCR); /* I/O card mode */
95 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
96 outw(0x0a00,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 1 */
97 else
98 outw(0x0200,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 0 */
Wolfgang Denk0a5c2142007-12-27 01:52:50 +010099
Nobuhiro Iwamatsu770395e2007-11-25 02:39:31 +0900100 outw(0x0000,MRSHPC_ISR);
101 outw(0x2000,MRSHPC_ICR);
102 outb(0x00,(CFG_MARUBUN_MW2 + 0x206));
103 outb(0x42,(CFG_MARUBUN_MW2 + 0x200));
104
105 return 0;
106}
107
108int pcmcia_off (void)
109{
110 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
111
112 return 0;
113}
114
115#endif /* CONFIG_MARUBUN_PCCARD */