blob: d075ba37cd4262be2d8e9e4304e53cc7aadced5e [file] [log] [blame]
Nobuhiro Iwamatsu33ecdc22007-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 Denk61fb15c52007-12-27 01:52:50 +010020 *
21 */
Nobuhiro Iwamatsu33ecdc22007-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 Iwamatsuf91d7ae2008-01-15 17:48:13 +090028#undef CONFIG_PCMCIA
29
30#if defined(CONFIG_CMD_PCMCIA)
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090031#define CONFIG_PCMCIA
32#endif
33
Jean-Christophe PLAGNIOL-VILLARDc9eff322008-05-18 19:09:50 +020034#if defined(CONFIG_CMD_IDE)
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090035#define CONFIG_PCMCIA
36#endif
37
Jean-Christophe PLAGNIOL-VILLARDc9eff322008-05-18 19:09:50 +020038#if defined(CONFIG_PCMCIA)
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090039
40/* MR-SHPC-01 register */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020041#define MRSHPC_MODE (CFG_MARUBUN_MRSHPC + 4)
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090042#define MRSHPC_OPTION (CFG_MARUBUN_MRSHPC + 6)
43#define MRSHPC_CSR (CFG_MARUBUN_MRSHPC + 8)
44#define MRSHPC_ISR (CFG_MARUBUN_MRSHPC + 10)
45#define MRSHPC_ICR (CFG_MARUBUN_MRSHPC + 12)
46#define MRSHPC_CPWCR (CFG_MARUBUN_MRSHPC + 14)
47#define MRSHPC_MW0CR1 (CFG_MARUBUN_MRSHPC + 16)
48#define MRSHPC_MW1CR1 (CFG_MARUBUN_MRSHPC + 18)
49#define MRSHPC_IOWCR1 (CFG_MARUBUN_MRSHPC + 20)
50#define MRSHPC_MW0CR2 (CFG_MARUBUN_MRSHPC + 22)
51#define MRSHPC_MW1CR2 (CFG_MARUBUN_MRSHPC + 24)
52#define MRSHPC_IOWCR2 (CFG_MARUBUN_MRSHPC + 26)
53#define MRSHPC_CDCR (CFG_MARUBUN_MRSHPC + 28)
54#define MRSHPC_PCIC_INFO (CFG_MARUBUN_MRSHPC + 30)
55
56int pcmcia_on (void)
57{
58 printf("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
59
60 /* Init */
61 outw( 0x0000 , MRSHPC_MODE );
62
63 if ((inw(MRSHPC_CSR) & 0x000c) == 0){ /* if card detect is true */
64 if ((inw(MRSHPC_CSR) & 0x0080) == 0){
65 outw(0x0674 ,MRSHPC_CPWCR); /* Card Vcc is 3.3v? */
66 }else{
67 outw(0x0678 ,MRSHPC_CPWCR); /* Card Vcc is 5V */
68 }
69 udelay( 100000 ); /* wait for power on */
70 }else{
71 return 1;
72 }
73 /*
74 * PC-Card window open
75 * flag == COMMON/ATTRIBUTE/IO
76 */
77 /* common window open */
78 outw(0x8a84,MRSHPC_MW0CR1); /* window 0xb8400000 */
79 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
80 outw(0x0b00,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 1 */
81 else
82 outw(0x0300,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 0 */
Wolfgang Denk61fb15c52007-12-27 01:52:50 +010083
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090084 /* attribute window open */
85 outw(0x8a85,MRSHPC_MW1CR1); /* window 0xb8500000 */
86 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
87 outw(0x0a00,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 1 */
88 else
89 outw(0x0200,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 0 */
Wolfgang Denk61fb15c52007-12-27 01:52:50 +010090
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090091 /* I/O window open */
92 outw(0x8a86,MRSHPC_IOWCR1); /* I/O window 0xb8600000 */
93 outw(0x0008,MRSHPC_CDCR); /* I/O card mode */
94 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
95 outw(0x0a00,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 1 */
96 else
97 outw(0x0200,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 0 */
Wolfgang Denk61fb15c52007-12-27 01:52:50 +010098
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090099 outw(0x0000,MRSHPC_ISR);
100 outw(0x2000,MRSHPC_ICR);
101 outb(0x00,(CFG_MARUBUN_MW2 + 0x206));
102 outb(0x42,(CFG_MARUBUN_MW2 + 0x200));
103
104 return 0;
105}
106
107int pcmcia_off (void)
108{
109 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
110
111 return 0;
112}
113
Jean-Christophe PLAGNIOL-VILLARDc9eff322008-05-18 19:09:50 +0200114#endif /* CONFIG_PCMCIA */