diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/nand/orion_nand.c | 47 | ||||
-rw-r--r-- | drivers/pcmcia/Kconfig | 2 | ||||
-rw-r--r-- | drivers/pcmcia/Makefile | 1 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_hx4700.c | 121 |
4 files changed, 167 insertions, 4 deletions
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c index 1d3bfb26080c..0f50ef38b87b 100644 --- a/drivers/mtd/nand/orion_nand.c +++ b/drivers/mtd/nand/orion_nand.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/of.h> | ||
16 | #include <linux/mtd/mtd.h> | 17 | #include <linux/mtd/mtd.h> |
17 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/nand.h> |
18 | #include <linux/mtd/partitions.h> | 19 | #include <linux/mtd/partitions.h> |
@@ -74,11 +75,13 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) | |||
74 | static int __init orion_nand_probe(struct platform_device *pdev) | 75 | static int __init orion_nand_probe(struct platform_device *pdev) |
75 | { | 76 | { |
76 | struct mtd_info *mtd; | 77 | struct mtd_info *mtd; |
78 | struct mtd_part_parser_data ppdata = {}; | ||
77 | struct nand_chip *nc; | 79 | struct nand_chip *nc; |
78 | struct orion_nand_data *board; | 80 | struct orion_nand_data *board; |
79 | struct resource *res; | 81 | struct resource *res; |
80 | void __iomem *io_base; | 82 | void __iomem *io_base; |
81 | int ret = 0; | 83 | int ret = 0; |
84 | u32 val = 0; | ||
82 | 85 | ||
83 | nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL); | 86 | nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL); |
84 | if (!nc) { | 87 | if (!nc) { |
@@ -101,7 +104,32 @@ static int __init orion_nand_probe(struct platform_device *pdev) | |||
101 | goto no_res; | 104 | goto no_res; |
102 | } | 105 | } |
103 | 106 | ||
104 | board = pdev->dev.platform_data; | 107 | if (pdev->dev.of_node) { |
108 | board = devm_kzalloc(&pdev->dev, sizeof(struct orion_nand_data), | ||
109 | GFP_KERNEL); | ||
110 | if (!board) { | ||
111 | printk(KERN_ERR "orion_nand: failed to allocate board structure.\n"); | ||
112 | ret = -ENOMEM; | ||
113 | goto no_res; | ||
114 | } | ||
115 | if (!of_property_read_u32(pdev->dev.of_node, "cle", &val)) | ||
116 | board->cle = (u8)val; | ||
117 | else | ||
118 | board->cle = 0; | ||
119 | if (!of_property_read_u32(pdev->dev.of_node, "ale", &val)) | ||
120 | board->ale = (u8)val; | ||
121 | else | ||
122 | board->ale = 1; | ||
123 | if (!of_property_read_u32(pdev->dev.of_node, | ||
124 | "bank-width", &val)) | ||
125 | board->width = (u8)val * 8; | ||
126 | else | ||
127 | board->width = 8; | ||
128 | if (!of_property_read_u32(pdev->dev.of_node, | ||
129 | "chip-delay", &val)) | ||
130 | board->chip_delay = (u8)val; | ||
131 | } else | ||
132 | board = pdev->dev.platform_data; | ||
105 | 133 | ||
106 | mtd->priv = nc; | 134 | mtd->priv = nc; |
107 | mtd->owner = THIS_MODULE; | 135 | mtd->owner = THIS_MODULE; |
@@ -115,6 +143,10 @@ static int __init orion_nand_probe(struct platform_device *pdev) | |||
115 | if (board->chip_delay) | 143 | if (board->chip_delay) |
116 | nc->chip_delay = board->chip_delay; | 144 | nc->chip_delay = board->chip_delay; |
117 | 145 | ||
146 | WARN(board->width > 16, | ||
147 | "%d bit bus width out of range", | ||
148 | board->width); | ||
149 | |||
118 | if (board->width == 16) | 150 | if (board->width == 16) |
119 | nc->options |= NAND_BUSWIDTH_16; | 151 | nc->options |= NAND_BUSWIDTH_16; |
120 | 152 | ||
@@ -129,8 +161,9 @@ static int __init orion_nand_probe(struct platform_device *pdev) | |||
129 | } | 161 | } |
130 | 162 | ||
131 | mtd->name = "orion_nand"; | 163 | mtd->name = "orion_nand"; |
132 | ret = mtd_device_parse_register(mtd, NULL, NULL, board->parts, | 164 | ppdata.of_node = pdev->dev.of_node; |
133 | board->nr_parts); | 165 | ret = mtd_device_parse_register(mtd, NULL, &ppdata, |
166 | board->parts, board->nr_parts); | ||
134 | if (ret) { | 167 | if (ret) { |
135 | nand_release(mtd); | 168 | nand_release(mtd); |
136 | goto no_dev; | 169 | goto no_dev; |
@@ -161,11 +194,19 @@ static int __devexit orion_nand_remove(struct platform_device *pdev) | |||
161 | return 0; | 194 | return 0; |
162 | } | 195 | } |
163 | 196 | ||
197 | #ifdef CONFIG_OF | ||
198 | static struct of_device_id orion_nand_of_match_table[] = { | ||
199 | { .compatible = "mrvl,orion-nand", }, | ||
200 | {}, | ||
201 | }; | ||
202 | #endif | ||
203 | |||
164 | static struct platform_driver orion_nand_driver = { | 204 | static struct platform_driver orion_nand_driver = { |
165 | .remove = __devexit_p(orion_nand_remove), | 205 | .remove = __devexit_p(orion_nand_remove), |
166 | .driver = { | 206 | .driver = { |
167 | .name = "orion_nand", | 207 | .name = "orion_nand", |
168 | .owner = THIS_MODULE, | 208 | .owner = THIS_MODULE, |
209 | .of_match_table = of_match_ptr(orion_nand_of_match_table), | ||
169 | }, | 210 | }, |
170 | }; | 211 | }; |
171 | 212 | ||
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index bba3ab2066ee..8fd255f7ee40 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -217,7 +217,7 @@ config PCMCIA_PXA2XX | |||
217 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ | 217 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ |
218 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ | 218 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ |
219 | || MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \ | 219 | || MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \ |
220 | || MACH_COLIBRI320) | 220 | || MACH_COLIBRI320 || MACH_H4700) |
221 | select PCMCIA_SA1111 if ARCH_LUBBOCK && SA1111 | 221 | select PCMCIA_SA1111 if ARCH_LUBBOCK && SA1111 |
222 | select PCMCIA_SOC_COMMON | 222 | select PCMCIA_SOC_COMMON |
223 | help | 223 | help |
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 47525de6a631..7745b512a87c 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
@@ -69,6 +69,7 @@ pxa2xx-obj-$(CONFIG_MACH_VPAC270) += pxa2xx_vpac270.o | |||
69 | pxa2xx-obj-$(CONFIG_MACH_BALLOON3) += pxa2xx_balloon3.o | 69 | pxa2xx-obj-$(CONFIG_MACH_BALLOON3) += pxa2xx_balloon3.o |
70 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI) += pxa2xx_colibri.o | 70 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI) += pxa2xx_colibri.o |
71 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI320) += pxa2xx_colibri.o | 71 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI320) += pxa2xx_colibri.o |
72 | pxa2xx-obj-$(CONFIG_MACH_H4700) += pxa2xx_hx4700.o | ||
72 | 73 | ||
73 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) | 74 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) |
74 | 75 | ||
diff --git a/drivers/pcmcia/pxa2xx_hx4700.c b/drivers/pcmcia/pxa2xx_hx4700.c new file mode 100644 index 000000000000..7dfef3ee5b53 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_hx4700.c | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Paul Parsons <lost.distance@yahoo.com> | ||
3 | * | ||
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 | */ | ||
8 | |||
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> | ||
14 | |||
15 | #include <asm/mach-types.h> | ||
16 | #include <mach/hx4700.h> | ||
17 | |||
18 | #include "soc_common.h" | ||
19 | |||
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" }, | ||
23 | }; | ||
24 | |||
25 | static int hx4700_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
26 | { | ||
27 | int ret; | ||
28 | |||
29 | ret = gpio_request_array(gpios, ARRAY_SIZE(gpios)); | ||
30 | if (ret) | ||
31 | goto out; | ||
32 | |||
33 | /* | ||
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. | ||
39 | */ | ||
40 | irq_set_irq_type(gpio_to_irq(GPIOD4_CF_nCD), IRQ_TYPE_EDGE_BOTH); | ||
41 | |||
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"; | ||
46 | |||
47 | out: | ||
48 | return ret; | ||
49 | } | ||
50 | |||
51 | static void hx4700_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
52 | { | ||
53 | gpio_free_array(gpios, ARRAY_SIZE(gpios)); | ||
54 | } | ||
55 | |||
56 | static void hx4700_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
57 | struct pcmcia_state *state) | ||
58 | { | ||
59 | state->vs_3v = 1; | ||
60 | state->vs_Xv = 0; | ||
61 | } | ||
62 | |||
63 | static int hx4700_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
64 | const socket_state_t *state) | ||
65 | { | ||
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; | ||
76 | } | ||
77 | |||
78 | gpio_set_value(GPIO114_HX4700_CF_RESET, (state->flags & SS_RESET) != 0); | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
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, | ||
90 | }; | ||
91 | |||
92 | static struct platform_device *hx4700_pcmcia_device; | ||
93 | |||
94 | static int __init hx4700_pcmcia_init(void) | ||
95 | { | ||
96 | struct platform_device *pdev; | ||
97 | |||
98 | if (!machine_is_h4700()) | ||
99 | return -ENODEV; | ||
100 | |||
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); | ||
105 | |||
106 | hx4700_pcmcia_device = pdev; | ||
107 | |||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static void __exit hx4700_pcmcia_exit(void) | ||
112 | { | ||
113 | platform_device_unregister(hx4700_pcmcia_device); | ||
114 | } | ||
115 | |||
116 | module_init(hx4700_pcmcia_init); | ||
117 | module_exit(hx4700_pcmcia_exit); | ||
118 | |||
119 | MODULE_AUTHOR("Paul Parsons <lost.distance@yahoo.com>"); | ||
120 | MODULE_DESCRIPTION("HP iPAQ hx4700 PCMCIA driver"); | ||
121 | MODULE_LICENSE("GPL"); | ||