blob: 99fe0b4fb97db038b47777693b03dd5fe1f8a0c1 [file] [log] [blame]
Wolfgang Denk50440e72006-07-10 23:07:28 +02001#include <common.h>
2#include <mpc8xx.h>
3#include <pcmcia.h>
4
5#undef CONFIG_PCMCIA
6
Jon Loeliger96892a92007-07-09 18:31:28 -05007#if defined(CONFIG_CMD_PCMCIA)
Wolfgang Denk50440e72006-07-10 23:07:28 +02008#define CONFIG_PCMCIA
9#endif
10
Jon Loeliger96892a92007-07-09 18:31:28 -050011#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
Wolfgang Denk50440e72006-07-10 23:07:28 +020012#define CONFIG_PCMCIA
13#endif
14
15#ifdef CONFIG_PCMCIA
16
17#ifdef CONFIG_ADS
18#define PCMCIA_BOARD_MSG "ADS"
19#else
20#define PCMCIA_BOARD_MSG "FADS"
21#endif
22
23int pcmcia_voltage_set(int slot, int vcc, int vpp)
24{
25 u_long reg = 0;
26
27 switch(vpp) {
28 case 0: reg = 0; break;
29 case 50: reg = 1; break;
30 case 120: reg = 2; break;
31 default: return 1;
32 }
33
34 switch(vcc) {
35 case 0: reg = 0; break;
36#ifdef CONFIG_ADS
37 case 50: reg = BCSR1_PCCVCCON; break;
38#endif
39#ifdef CONFIG_FADS
40 case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
41 case 50: reg = BCSR1_PCCVCC1; break;
42#endif
43 default: return 1;
44 }
45
46 /* first, turn off all power */
47
48#ifdef CONFIG_ADS
49 *((uint *)BCSR1) |= BCSR1_PCCVCCON;
50#endif
51#ifdef CONFIG_FADS
52 *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
53#endif
54 *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
55
56 /* enable new powersettings */
57
58#ifdef CONFIG_ADS
59 *((uint *)BCSR1) &= ~reg;
60#endif
61#ifdef CONFIG_FADS
62 *((uint *)BCSR1) |= reg;
63#endif
64
Wolfgang Denka1be4762008-05-20 16:00:29 +020065 *((uint *)BCSR1) |= reg << 20;
Wolfgang Denk50440e72006-07-10 23:07:28 +020066
67 return 0;
68}
69
70int pcmcia_hardware_enable(int slot)
71{
72 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
73 return 0;
74}
75
Jon Loeliger96892a92007-07-09 18:31:28 -050076#if defined(CONFIG_CMD_PCMCIA)
Wolfgang Denk50440e72006-07-10 23:07:28 +020077int pcmcia_hardware_disable(int slot)
78{
79 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
80 return 0;
81}
Jon Loeliger96892a92007-07-09 18:31:28 -050082#endif
Wolfgang Denk50440e72006-07-10 23:07:28 +020083
84#endif /* CONFIG_PCMCIA */