1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2012 Paul Parsons <lost.distance@yahoo.com>
6 #include <linux/module.h>
7 #include <linux/platform_device.h>
9 #include <linux/gpio.h>
10 #include <linux/irq.h>
12 #include <asm/mach-types.h>
13 #include <mach/hx4700.h>
15 #include "soc_common.h"
17 static struct gpio gpios[] = {
18 { GPIO114_HX4700_CF_RESET, GPIOF_OUT_INIT_LOW, "CF reset" },
19 { EGPIO4_CF_3V3_ON, GPIOF_OUT_INIT_LOW, "CF 3.3V enable" },
22 static int hx4700_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
26 ret = gpio_request_array(gpios, ARRAY_SIZE(gpios));
31 * IRQ type must be set before soc_pcmcia_hw_init() calls request_irq().
32 * The asic3 default IRQ type is level trigger low level detect, exactly
33 * the the signal present on GPIOD4_CF_nCD when a CF card is inserted.
34 * If the IRQ type is not changed, the asic3 interrupt handler will loop
35 * repeatedly because it is unable to clear the level trigger interrupt.
37 irq_set_irq_type(gpio_to_irq(GPIOD4_CF_nCD), IRQ_TYPE_EDGE_BOTH);
39 skt->stat[SOC_STAT_CD].gpio = GPIOD4_CF_nCD;
40 skt->stat[SOC_STAT_CD].name = "PCMCIA CD";
41 skt->stat[SOC_STAT_RDY].gpio = GPIO60_HX4700_CF_RNB;
42 skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
48 static void hx4700_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
50 gpio_free_array(gpios, ARRAY_SIZE(gpios));
53 static void hx4700_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
54 struct pcmcia_state *state)
60 static int hx4700_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
61 const socket_state_t *state)
65 gpio_set_value(EGPIO4_CF_3V3_ON, 0);
68 gpio_set_value(EGPIO4_CF_3V3_ON, 1);
71 printk(KERN_ERR "pcmcia: Unsupported Vcc: %d\n", state->Vcc);
75 gpio_set_value(GPIO114_HX4700_CF_RESET, (state->flags & SS_RESET) != 0);
80 static struct pcmcia_low_level hx4700_pcmcia_ops = {
83 .hw_init = hx4700_pcmcia_hw_init,
84 .hw_shutdown = hx4700_pcmcia_hw_shutdown,
85 .socket_state = hx4700_pcmcia_socket_state,
86 .configure_socket = hx4700_pcmcia_configure_socket,
89 static struct platform_device *hx4700_pcmcia_device;
91 static int __init hx4700_pcmcia_init(void)
93 struct platform_device *pdev;
95 if (!machine_is_h4700())
98 pdev = platform_device_register_data(NULL, "pxa2xx-pcmcia", -1,
99 &hx4700_pcmcia_ops, sizeof(hx4700_pcmcia_ops));
101 return PTR_ERR(pdev);
103 hx4700_pcmcia_device = pdev;
108 static void __exit hx4700_pcmcia_exit(void)
110 platform_device_unregister(hx4700_pcmcia_device);
113 module_init(hx4700_pcmcia_init);
114 module_exit(hx4700_pcmcia_exit);
116 MODULE_AUTHOR("Paul Parsons <lost.distance@yahoo.com>");
117 MODULE_DESCRIPTION("HP iPAQ hx4700 PCMCIA driver");
118 MODULE_LICENSE("GPL");