Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / pcmcia / sa1111_jornada720.c
blob3d4ca87ca76cd58871f4aa33ab72134843baa143
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * drivers/pcmcia/sa1100_jornada720.c
5 * Jornada720 PCMCIA specific routines
7 */
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/device.h>
11 #include <linux/errno.h>
12 #include <linux/init.h>
13 #include <linux/io.h>
15 #include <mach/hardware.h>
16 #include <asm/hardware/sa1111.h>
17 #include <asm/mach-types.h>
19 #include "sa1111_generic.h"
21 /* Does SOCKET1_3V actually do anything? */
22 #define SOCKET0_POWER GPIO_GPIO0
23 #define SOCKET0_3V GPIO_GPIO2
24 #define SOCKET1_POWER (GPIO_GPIO1 | GPIO_GPIO3)
25 #define SOCKET1_3V GPIO_GPIO3
27 static int
28 jornada720_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
30 struct sa1111_pcmcia_socket *s = to_skt(skt);
31 unsigned int pa_dwr_mask, pa_dwr_set;
32 int ret;
34 printk(KERN_INFO "%s(): config socket %d vcc %d vpp %d\n", __func__,
35 skt->nr, state->Vcc, state->Vpp);
37 switch (skt->nr) {
38 case 0:
39 pa_dwr_mask = SOCKET0_POWER | SOCKET0_3V;
41 switch (state->Vcc) {
42 default:
43 case 0:
44 pa_dwr_set = 0;
45 break;
46 case 33:
47 pa_dwr_set = SOCKET0_POWER | SOCKET0_3V;
48 break;
49 case 50:
50 pa_dwr_set = SOCKET0_POWER;
51 break;
53 break;
55 case 1:
56 pa_dwr_mask = SOCKET1_POWER;
58 switch (state->Vcc) {
59 default:
60 case 0:
61 pa_dwr_set = 0;
62 break;
63 case 33:
64 pa_dwr_set = SOCKET1_POWER;
65 break;
66 case 50:
67 pa_dwr_set = SOCKET1_POWER;
68 break;
70 break;
72 default:
73 return -1;
76 if (state->Vpp != state->Vcc && state->Vpp != 0) {
77 printk(KERN_ERR "%s(): slot cannot support VPP %u\n",
78 __func__, state->Vpp);
79 return -EPERM;
82 ret = sa1111_pcmcia_configure_socket(skt, state);
83 if (ret == 0)
84 sa1111_set_io(s->dev, pa_dwr_mask, pa_dwr_set);
86 return ret;
89 static struct pcmcia_low_level jornada720_pcmcia_ops = {
90 .owner = THIS_MODULE,
91 .configure_socket = jornada720_pcmcia_configure_socket,
92 .first = 0,
93 .nr = 2,
96 int pcmcia_jornada720_init(struct sa1111_dev *sadev)
98 unsigned int pin = GPIO_A0 | GPIO_A1 | GPIO_A2 | GPIO_A3;
100 /* Fixme: why messing around with SA11x0's GPIO1? */
101 GRER |= 0x00000002;
103 /* Set GPIO_A<3:1> to be outputs for PCMCIA/CF power controller: */
104 sa1111_set_io_dir(sadev, pin, 0, 0);
105 sa1111_set_io(sadev, pin, 0);
106 sa1111_set_sleep_io(sadev, pin, 0);
108 sa11xx_drv_pcmcia_ops(&jornada720_pcmcia_ops);
109 return sa1111_pcmcia_add(sadev, &jornada720_pcmcia_ops,
110 sa11xx_drv_pcmcia_add_one);