sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / pcmcia / pxa2xx_hx4700.c
blob7dfef3ee5b53d3bc1327f379783ee4f2d1ff3b73
1 /*
2 * Copyright (C) 2012 Paul Parsons <lost.distance@yahoo.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #include <linux/module.h>
10 #include <linux/platform_device.h>
11 #include <linux/err.h>
12 #include <linux/gpio.h>
13 #include <linux/irq.h>
15 #include <asm/mach-types.h>
16 #include <mach/hx4700.h>
18 #include "soc_common.h"
20 static struct gpio gpios[] = {
21 { GPIO114_HX4700_CF_RESET, GPIOF_OUT_INIT_LOW, "CF reset" },
22 { EGPIO4_CF_3V3_ON, GPIOF_OUT_INIT_LOW, "CF 3.3V enable" },
25 static int hx4700_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
27 int ret;
29 ret = gpio_request_array(gpios, ARRAY_SIZE(gpios));
30 if (ret)
31 goto out;
34 * IRQ type must be set before soc_pcmcia_hw_init() calls request_irq().
35 * The asic3 default IRQ type is level trigger low level detect, exactly
36 * the the signal present on GPIOD4_CF_nCD when a CF card is inserted.
37 * If the IRQ type is not changed, the asic3 interrupt handler will loop
38 * repeatedly because it is unable to clear the level trigger interrupt.
40 irq_set_irq_type(gpio_to_irq(GPIOD4_CF_nCD), IRQ_TYPE_EDGE_BOTH);
42 skt->stat[SOC_STAT_CD].gpio = GPIOD4_CF_nCD;
43 skt->stat[SOC_STAT_CD].name = "PCMCIA CD";
44 skt->stat[SOC_STAT_RDY].gpio = GPIO60_HX4700_CF_RNB;
45 skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
47 out:
48 return ret;
51 static void hx4700_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
53 gpio_free_array(gpios, ARRAY_SIZE(gpios));
56 static void hx4700_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
57 struct pcmcia_state *state)
59 state->vs_3v = 1;
60 state->vs_Xv = 0;
63 static int hx4700_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
64 const socket_state_t *state)
66 switch (state->Vcc) {
67 case 0:
68 gpio_set_value(EGPIO4_CF_3V3_ON, 0);
69 break;
70 case 33:
71 gpio_set_value(EGPIO4_CF_3V3_ON, 1);
72 break;
73 default:
74 printk(KERN_ERR "pcmcia: Unsupported Vcc: %d\n", state->Vcc);
75 return -EINVAL;
78 gpio_set_value(GPIO114_HX4700_CF_RESET, (state->flags & SS_RESET) != 0);
80 return 0;
83 static struct pcmcia_low_level hx4700_pcmcia_ops = {
84 .owner = THIS_MODULE,
85 .nr = 1,
86 .hw_init = hx4700_pcmcia_hw_init,
87 .hw_shutdown = hx4700_pcmcia_hw_shutdown,
88 .socket_state = hx4700_pcmcia_socket_state,
89 .configure_socket = hx4700_pcmcia_configure_socket,
92 static struct platform_device *hx4700_pcmcia_device;
94 static int __init hx4700_pcmcia_init(void)
96 struct platform_device *pdev;
98 if (!machine_is_h4700())
99 return -ENODEV;
101 pdev = platform_device_register_data(NULL, "pxa2xx-pcmcia", -1,
102 &hx4700_pcmcia_ops, sizeof(hx4700_pcmcia_ops));
103 if (IS_ERR(pdev))
104 return PTR_ERR(pdev);
106 hx4700_pcmcia_device = pdev;
108 return 0;
111 static void __exit hx4700_pcmcia_exit(void)
113 platform_device_unregister(hx4700_pcmcia_device);
116 module_init(hx4700_pcmcia_init);
117 module_exit(hx4700_pcmcia_exit);
119 MODULE_AUTHOR("Paul Parsons <lost.distance@yahoo.com>");
120 MODULE_DESCRIPTION("HP iPAQ hx4700 PCMCIA driver");
121 MODULE_LICENSE("GPL");