blob: 0a387106acb0ebd3bb4c835e54dfac7d89bac1b9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/pcmcia/sa1100_jornada720.c
3 *
4 * Jornada720 PCMCIA specific routines
5 *
6 */
7#include <linux/module.h>
8#include <linux/kernel.h>
9#include <linux/sched.h>
10#include <linux/device.h>
11#include <linux/errno.h>
12#include <linux/init.h>
13
14#include <asm/hardware.h>
15#include <asm/hardware/sa1111.h>
16#include <asm/mach-types.h>
17
18#include "sa1111_generic.h"
19
20#define SOCKET0_POWER GPIO_GPIO0
21#define SOCKET0_3V GPIO_GPIO2
22#define SOCKET1_POWER (GPIO_GPIO1 | GPIO_GPIO3)
23#warning *** Does SOCKET1_3V actually do anything?
24#define SOCKET1_3V GPIO_GPIO3
25
26static int jornada720_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
27{
28 /*
29 * What is all this crap for?
30 */
31 GRER |= 0x00000002;
32 /* Set GPIO_A<3:1> to be outputs for PCMCIA/CF power controller: */
33 PA_DDR = 0;
34 PA_DWR = 0;
35 PA_SDR = 0;
36 PA_SSR = 0;
37
38 PB_DDR = 0;
39 PB_DWR = 0x01;
40 PB_SDR = 0;
41 PB_SSR = 0;
42
43 PC_DDR = 0x88;
44 PC_DWR = 0x20;
45 PC_SDR = 0;
46 PC_SSR = 0;
47
48 return sa1111_pcmcia_hw_init(skt);
49}
50
51static int
52jornada720_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
53{
54 unsigned int pa_dwr_mask, pa_dwr_set;
55 int ret;
56
57printk("%s(): config socket %d vcc %d vpp %d\n", __FUNCTION__,
58 skt->nr, state->Vcc, state->Vpp);
59
60 switch (skt->nr) {
61 case 0:
62 pa_dwr_mask = SOCKET0_POWER | SOCKET0_3V;
63
64 switch (state->Vcc) {
65 default:
66 case 0: pa_dwr_set = 0; break;
67 case 33: pa_dwr_set = SOCKET0_POWER | SOCKET0_3V; break;
68 case 50: pa_dwr_set = SOCKET0_POWER; break;
69 }
70 break;
71
72 case 1:
73 pa_dwr_mask = SOCKET1_POWER;
74
75 switch (state->Vcc) {
76 default:
77 case 0: pa_dwr_set = 0; break;
78 case 33: pa_dwr_set = SOCKET1_POWER; break;
79 case 50: pa_dwr_set = SOCKET1_POWER; break;
80 }
81 break;
82
83 default:
84 return -1;
85 }
86
87 if (state->Vpp != state->Vcc && state->Vpp != 0) {
88 printk(KERN_ERR "%s(): slot cannot support VPP %u\n",
89 __FUNCTION__, state->Vpp);
90 return -1;
91 }
92
93 ret = sa1111_pcmcia_configure_socket(skt, state);
94 if (ret == 0) {
95 unsigned long flags;
96
97 local_irq_save(flags);
98 PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
99 local_irq_restore(flags);
100 }
101
102 return ret;
103}
104
105static struct pcmcia_low_level jornada720_pcmcia_ops = {
106 .owner = THIS_MODULE,
107 .hw_init = jornada720_pcmcia_hw_init,
108 .hw_shutdown = sa1111_pcmcia_hw_shutdown,
109 .socket_state = sa1111_pcmcia_socket_state,
110 .configure_socket = jornada720_pcmcia_configure_socket,
111
112 .socket_init = sa1111_pcmcia_socket_init,
113 .socket_suspend = sa1111_pcmcia_socket_suspend,
114};
115
116int __init pcmcia_jornada720_init(struct device *dev)
117{
118 int ret = -ENODEV;
119
120 if (machine_is_jornada720())
121 ret = sa11xx_drv_pcmcia_probe(dev, &jornada720_pcmcia_ops, 0, 2);
122
123 return ret;
124}