blob: b2eea6c601a1b2ade2233be5574b07d0a18e74e6 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +09002/*
3 * Marubun MR-SHPC-01 PCMCIA controller device driver
4 *
5 * (c) 2007 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Wolfgang Denk61fb15c52007-12-27 01:52:50 +01006 */
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +09007
8#include <common.h>
9#include <config.h>
10#include <pcmcia.h>
11#include <asm/io.h>
12
Nobuhiro Iwamatsuf91d7ae2008-01-15 17:48:13 +090013#undef CONFIG_PCMCIA
14
15#if defined(CONFIG_CMD_PCMCIA)
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090016#define CONFIG_PCMCIA
17#endif
18
Simon Glassfc843a02017-05-17 03:25:30 -060019#if defined(CONFIG_IDE)
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090020#define CONFIG_PCMCIA
21#endif
22
Jean-Christophe PLAGNIOL-VILLARDc9eff322008-05-18 19:09:50 +020023#if defined(CONFIG_PCMCIA)
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090024
25/* MR-SHPC-01 register */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020026#define MRSHPC_MODE (CONFIG_SYS_MARUBUN_MRSHPC + 4)
27#define MRSHPC_OPTION (CONFIG_SYS_MARUBUN_MRSHPC + 6)
28#define MRSHPC_CSR (CONFIG_SYS_MARUBUN_MRSHPC + 8)
29#define MRSHPC_ISR (CONFIG_SYS_MARUBUN_MRSHPC + 10)
30#define MRSHPC_ICR (CONFIG_SYS_MARUBUN_MRSHPC + 12)
31#define MRSHPC_CPWCR (CONFIG_SYS_MARUBUN_MRSHPC + 14)
32#define MRSHPC_MW0CR1 (CONFIG_SYS_MARUBUN_MRSHPC + 16)
33#define MRSHPC_MW1CR1 (CONFIG_SYS_MARUBUN_MRSHPC + 18)
34#define MRSHPC_IOWCR1 (CONFIG_SYS_MARUBUN_MRSHPC + 20)
35#define MRSHPC_MW0CR2 (CONFIG_SYS_MARUBUN_MRSHPC + 22)
36#define MRSHPC_MW1CR2 (CONFIG_SYS_MARUBUN_MRSHPC + 24)
37#define MRSHPC_IOWCR2 (CONFIG_SYS_MARUBUN_MRSHPC + 26)
38#define MRSHPC_CDCR (CONFIG_SYS_MARUBUN_MRSHPC + 28)
39#define MRSHPC_PCIC_INFO (CONFIG_SYS_MARUBUN_MRSHPC + 30)
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090040
41int pcmcia_on (void)
42{
43 printf("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
44
45 /* Init */
46 outw( 0x0000 , MRSHPC_MODE );
47
48 if ((inw(MRSHPC_CSR) & 0x000c) == 0){ /* if card detect is true */
49 if ((inw(MRSHPC_CSR) & 0x0080) == 0){
50 outw(0x0674 ,MRSHPC_CPWCR); /* Card Vcc is 3.3v? */
51 }else{
52 outw(0x0678 ,MRSHPC_CPWCR); /* Card Vcc is 5V */
53 }
54 udelay( 100000 ); /* wait for power on */
55 }else{
56 return 1;
57 }
58 /*
59 * PC-Card window open
60 * flag == COMMON/ATTRIBUTE/IO
61 */
62 /* common window open */
63 outw(0x8a84,MRSHPC_MW0CR1); /* window 0xb8400000 */
64 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
65 outw(0x0b00,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 1 */
66 else
67 outw(0x0300,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 0 */
Wolfgang Denk61fb15c52007-12-27 01:52:50 +010068
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090069 /* attribute window open */
70 outw(0x8a85,MRSHPC_MW1CR1); /* window 0xb8500000 */
71 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
72 outw(0x0a00,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 1 */
73 else
74 outw(0x0200,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 0 */
Wolfgang Denk61fb15c52007-12-27 01:52:50 +010075
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090076 /* I/O window open */
77 outw(0x8a86,MRSHPC_IOWCR1); /* I/O window 0xb8600000 */
78 outw(0x0008,MRSHPC_CDCR); /* I/O card mode */
79 if ((inw(MRSHPC_CSR) & 0x4000) != 0)
80 outw(0x0a00,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 1 */
81 else
82 outw(0x0200,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 0 */
Wolfgang Denk61fb15c52007-12-27 01:52:50 +010083
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090084 outw(0x0000,MRSHPC_ISR);
85 outw(0x2000,MRSHPC_ICR);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020086 outb(0x00,(CONFIG_SYS_MARUBUN_MW2 + 0x206));
87 outb(0x42,(CONFIG_SYS_MARUBUN_MW2 + 0x200));
Nobuhiro Iwamatsu33ecdc22007-11-25 02:39:31 +090088
89 return 0;
90}
91
92int pcmcia_off (void)
93{
94 printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
95
96 return 0;
97}
98
Jean-Christophe PLAGNIOL-VILLARDc9eff322008-05-18 19:09:50 +020099#endif /* CONFIG_PCMCIA */