USB: serial: ftdi_sio: make process-packet buffer unsigned
[linux/fpc-iii.git] / drivers / pcmcia / pxa2xx_hx4700.c
blob87b6a1639d948d12f6ebfc57bbf629ffed711f26
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2012 Paul Parsons <lost.distance@yahoo.com>
4 */
6 #include <linux/module.h>
7 #include <linux/platform_device.h>
8 #include <linux/err.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)
24 int ret;
26 ret = gpio_request_array(gpios, ARRAY_SIZE(gpios));
27 if (ret)
28 goto out;
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";
44 out:
45 return ret;
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)
56 state->vs_3v = 1;
57 state->vs_Xv = 0;
60 static int hx4700_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
61 const socket_state_t *state)
63 switch (state->Vcc) {
64 case 0:
65 gpio_set_value(EGPIO4_CF_3V3_ON, 0);
66 break;
67 case 33:
68 gpio_set_value(EGPIO4_CF_3V3_ON, 1);
69 break;
70 default:
71 printk(KERN_ERR "pcmcia: Unsupported Vcc: %d\n", state->Vcc);
72 return -EINVAL;
75 gpio_set_value(GPIO114_HX4700_CF_RESET, (state->flags & SS_RESET) != 0);
77 return 0;
80 static struct pcmcia_low_level hx4700_pcmcia_ops = {
81 .owner = THIS_MODULE,
82 .nr = 1,
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())
96 return -ENODEV;
98 pdev = platform_device_register_data(NULL, "pxa2xx-pcmcia", -1,
99 &hx4700_pcmcia_ops, sizeof(hx4700_pcmcia_ops));
100 if (IS_ERR(pdev))
101 return PTR_ERR(pdev);
103 hx4700_pcmcia_device = pdev;
105 return 0;
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");