1 // SPDX-License-Identifier: GPL-2.0
3 * drivers/pcmcia/sa1100_jornada720.c
5 * Jornada720 PCMCIA specific routines
8 #include <linux/module.h>
9 #include <linux/device.h>
10 #include <linux/errno.h>
11 #include <linux/gpio/consumer.h>
12 #include <linux/init.h>
15 #include <mach/hardware.h>
16 #include <asm/mach-types.h>
18 #include "sa1111_generic.h"
21 * Socket 0 power: GPIO A0
22 * Socket 0 3V: GPIO A2
23 * Socket 1 power: GPIO A1 & GPIO A3
24 * Socket 1 3V: GPIO A3
25 * Does Socket 1 3V actually do anything?
32 struct jornada720_data
{
33 struct gpio_desc
*gpio
[J720_GPIO_MAX
];
36 static int jornada720_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
38 struct device
*dev
= skt
->socket
.dev
.parent
;
39 struct jornada720_data
*j
;
41 j
= devm_kzalloc(dev
, sizeof(*j
), GFP_KERNEL
);
45 j
->gpio
[J720_GPIO_PWR
] = devm_gpiod_get(dev
, skt
->nr
? "s1-power" :
46 "s0-power", GPIOD_OUT_LOW
);
47 if (IS_ERR(j
->gpio
[J720_GPIO_PWR
]))
48 return PTR_ERR(j
->gpio
[J720_GPIO_PWR
]);
50 j
->gpio
[J720_GPIO_3V
] = devm_gpiod_get(dev
, skt
->nr
? "s1-3v" :
51 "s0-3v", GPIOD_OUT_LOW
);
52 if (IS_ERR(j
->gpio
[J720_GPIO_3V
]))
53 return PTR_ERR(j
->gpio
[J720_GPIO_3V
]);
61 jornada720_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
, const socket_state_t
*state
)
63 struct jornada720_data
*j
= skt
->driver_data
;
64 DECLARE_BITMAP(values
, J720_GPIO_MAX
) = { 0, };
67 printk(KERN_INFO
"%s(): config socket %d vcc %d vpp %d\n", __func__
,
68 skt
->nr
, state
->Vcc
, state
->Vpp
);
75 __assign_bit(J720_GPIO_PWR
, values
, 0);
76 __assign_bit(J720_GPIO_3V
, values
, 0);
79 __assign_bit(J720_GPIO_PWR
, values
, 1);
80 __assign_bit(J720_GPIO_3V
, values
, 1);
83 __assign_bit(J720_GPIO_PWR
, values
, 1);
84 __assign_bit(J720_GPIO_3V
, values
, 0);
93 __assign_bit(J720_GPIO_PWR
, values
, 0);
94 __assign_bit(J720_GPIO_3V
, values
, 0);
98 __assign_bit(J720_GPIO_PWR
, values
, 1);
99 __assign_bit(J720_GPIO_3V
, values
, 1);
108 if (state
->Vpp
!= state
->Vcc
&& state
->Vpp
!= 0) {
109 printk(KERN_ERR
"%s(): slot cannot support VPP %u\n",
110 __func__
, state
->Vpp
);
114 ret
= sa1111_pcmcia_configure_socket(skt
, state
);
116 ret
= gpiod_set_array_value_cansleep(J720_GPIO_MAX
, j
->gpio
,
122 static struct pcmcia_low_level jornada720_pcmcia_ops
= {
123 .owner
= THIS_MODULE
,
124 .hw_init
= jornada720_pcmcia_hw_init
,
125 .configure_socket
= jornada720_pcmcia_configure_socket
,
130 int pcmcia_jornada720_init(struct sa1111_dev
*sadev
)
132 /* Fixme: why messing around with SA11x0's GPIO1? */
135 sa11xx_drv_pcmcia_ops(&jornada720_pcmcia_ops
);
136 return sa1111_pcmcia_add(sadev
, &jornada720_pcmcia_ops
,
137 sa11xx_drv_pcmcia_add_one
);