blob: 89b201526c8a0d76450a4c5500e731a326eff7e7 [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
20 *
21 */
22
23#include <common.h>
24#include <config.h>
25#include <pcmcia.h>
26#include <asm/io.h>
27
28#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
29#define CONFIG_PCMCIA
30#endif
31
32#if (CONFIG_COMMANDS & CFG_CMD_IDE)
33#define CONFIG_PCMCIA
34#endif
35
36#if defined(CONFIG_PCMCIA) \
37 && (defined(CONFIG_MARUBUN_PCCARD))
38
39/* MR-SHPC-01 register */
40#define MRSHPC_MODE (CFG_MARUBUN_MRSHPC + 4)
41#define MRSHPC_OPTION (CFG_MARUBUN_MRSHPC + 6)
42#define MRSHPC_CSR (CFG_MARUBUN_MRSHPC + 8)
43#define MRSHPC_ISR (CFG_MARUBUN_MRSHPC + 10)
44#define MRSHPC_ICR (CFG_MARUBUN_MRSHPC + 12)
45#define MRSHPC_CPWCR (CFG_MARUBUN_MRSHPC + 14)
46#define MRSHPC_MW0CR1 (CFG_MARUBUN_MRSHPC + 16)
47#define MRSHPC_MW1CR1 (CFG_MARUBUN_MRSHPC + 18)
48#define MRSHPC_IOWCR1 (CFG_MARUBUN_MRSHPC + 20)
49#define MRSHPC_MW0CR2 (CFG_MARUBUN_MRSHPC + 22)
50#define MRSHPC_MW1CR2 (CFG_MARUBUN_MRSHPC + 24)
51#define MRSHPC_IOWCR2 (CFG_MARUBUN_MRSHPC + 26)
52#define MRSHPC_CDCR (CFG_MARUBUN_MRSHPC + 28)
53#define MRSHPC_PCIC_INFO (CFG_MARUBUN_MRSHPC + 30)
54
55int pcmcia_on (void)
56{
57 printf("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
58
59 /* Init */
60 outw( 0x0000 , MRSHPC_MODE );
61
62 if ((inw(MRSHPC_CSR) & 0x000c) == 0){ /* if card detect is true */
63 if ((inw(MRSHPC_CSR) & 0x0080) == 0){
64 outw(0x0674 ,MRSHPC_CPWCR); /* Card Vcc is 3.3v? */
65 }else{
66 outw(0x0678 ,MRSHPC_CPWCR); /* Card Vcc is 5V */
67 }
68 udelay( 100000 ); /* wait for power on */
69 }else{
70 return 1;
71 }
72 /*
73 * PC-Card window open
74 * flag == COMMON/ATTRIBUTE/IO
75 */
76 /* common window open */
77 outw(0x8a84,MRSHPC_MW0CR1); /* window 0xb8400000 */
78 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
79 outw(0x0b00,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 1 */
80 else
81 outw(0x0300,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 0 */
82
83 /* attribute window open */
84 outw(0x8a85,MRSHPC_MW1CR1); /* window 0xb8500000 */
85 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
86 outw(0x0a00,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 1 */
87 else
88 outw(0x0200,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 0 */
89
90 /* I/O window open */
91 outw(0x8a86,MRSHPC_IOWCR1); /* I/O window 0xb8600000 */
92 outw(0x0008,MRSHPC_CDCR); /* I/O card mode */
93 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
94 outw(0x0a00,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 1 */
95 else
96 outw(0x0200,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 0 */
97
98 outw(0x0000,MRSHPC_ISR);
99 outw(0x2000,MRSHPC_ICR);
100 outb(0x00,(CFG_MARUBUN_MW2 + 0x206));
101 outb(0x42,(CFG_MARUBUN_MW2 + 0x200));
102
103 return 0;
104}
105
106int pcmcia_off (void)
107{
108 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
109
110 return 0;
111}
112
113#endif /* CONFIG_MARUBUN_PCCARD */