]>
Commit | Line | Data |
---|---|---|
d006af40 AF |
1 | From e71075202707e044a28604bd929fd6f7a89adeae Mon Sep 17 00:00:00 2001 |
2 | From: Robert Nelson <robertcnelson@gmail.com> | |
3 | Date: Mon, 21 Jan 2013 11:47:02 -0600 | |
4 | Subject: [PATCH 02/10] Beagle: expansion: add zippy | |
5 | ||
6 | v2: add #include <linux/regulator/fixed.h> | |
7 | build fix from Pantelis Antoniou <panto@antoniou-consulting.com> | |
8 | ||
9 | Signed-off-by: Robert Nelson <robertcnelson@gmail.com> | |
10 | --- | |
11 | arch/arm/mach-omap2/board-omap3beagle.c | 164 +++++++++++++++++++++++++++++-- | |
12 | 1 file changed, 158 insertions(+), 6 deletions(-) | |
13 | ||
14 | diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c | |
15 | index 4e6e767..b3685ed 100644 | |
16 | --- a/arch/arm/mach-omap2/board-omap3beagle.c | |
17 | +++ b/arch/arm/mach-omap2/board-omap3beagle.c | |
18 | @@ -37,6 +37,7 @@ | |
19 | #include <linux/usb/nop-usb-xceiv.h> | |
20 | ||
21 | #include <linux/regulator/machine.h> | |
22 | +#include <linux/regulator/fixed.h> | |
23 | #include <linux/i2c/twl.h> | |
24 | ||
25 | #include <asm/mach-types.h> | |
26 | @@ -195,6 +196,86 @@ static void __init omap3_beagle_init_rev(void) | |
27 | ||
28 | char expansionboard_name[16]; | |
29 | ||
30 | +enum { | |
31 | + EXPANSION_MMC_NONE = 0, | |
32 | + EXPANSION_MMC_ZIPPY, | |
33 | + EXPANSION_MMC_WIFI, | |
34 | +}; | |
35 | + | |
36 | +enum { | |
37 | + EXPANSION_I2C_NONE = 0, | |
38 | + EXPANSION_I2C_ZIPPY, | |
39 | +}; | |
40 | + | |
41 | +static struct { | |
42 | + int mmc_settings; | |
43 | + int i2c_settings; | |
44 | +} expansion_config = { | |
45 | + .mmc_settings = EXPANSION_MMC_NONE, | |
46 | + .i2c_settings = EXPANSION_I2C_NONE, | |
47 | +}; | |
48 | + | |
49 | +//rcn-ee: this is just a fake regulator, the zippy hardware provides 3.3/1.8 with jumper.. | |
50 | +static struct fixed_voltage_config beagle_vzippy = { | |
51 | + .supply_name = "vzippy", | |
52 | + .microvolts = 3300000, /* 3.3V */ | |
53 | + .startup_delay = 70000, /* 70ms */ | |
54 | + .enable_high = 1, | |
55 | + .enabled_at_boot = 0, | |
56 | + .init_data = &beagle_vmmc2, | |
57 | +}; | |
58 | + | |
59 | +static struct platform_device omap_zippy_device = { | |
60 | + .name = "reg-fixed-voltage", | |
61 | + .id = 1, | |
62 | + .dev = { | |
63 | + .platform_data = &beagle_vzippy, | |
64 | + }, | |
65 | +}; | |
66 | + | |
67 | +#define OMAP3BEAGLE_GPIO_ZIPPY_MMC_WP 141 | |
68 | +#define OMAP3BEAGLE_GPIO_ZIPPY_MMC_CD 162 | |
69 | + | |
70 | +#if IS_ENABLED(CONFIG_ENC28J60) | |
71 | +#include <linux/platform_data/spi-omap2-mcspi.h> | |
72 | +#include <linux/spi/spi.h> | |
73 | + | |
74 | +#define OMAP3BEAGLE_GPIO_ENC28J60_IRQ 157 | |
75 | + | |
76 | +static struct omap2_mcspi_device_config enc28j60_spi_chip_info = { | |
77 | + .turbo_mode = 0, | |
78 | +}; | |
79 | + | |
80 | +static struct spi_board_info omap3beagle_zippy_spi_board_info[] __initdata = { | |
81 | + { | |
82 | + .modalias = "enc28j60", | |
83 | + .bus_num = 4, | |
84 | + .chip_select = 0, | |
85 | + .max_speed_hz = 20000000, | |
86 | + .controller_data = &enc28j60_spi_chip_info, | |
87 | + }, | |
88 | +}; | |
89 | + | |
90 | +static void __init omap3beagle_enc28j60_init(void) | |
91 | +{ | |
92 | + if ((gpio_request(OMAP3BEAGLE_GPIO_ENC28J60_IRQ, "ENC28J60_IRQ") == 0) && | |
93 | + (gpio_direction_input(OMAP3BEAGLE_GPIO_ENC28J60_IRQ) == 0)) { | |
94 | + gpio_export(OMAP3BEAGLE_GPIO_ENC28J60_IRQ, 0); | |
95 | + omap3beagle_zippy_spi_board_info[0].irq = gpio_to_irq(OMAP3BEAGLE_GPIO_ENC28J60_IRQ); | |
96 | + irq_set_irq_type(omap3beagle_zippy_spi_board_info[0].irq, IRQ_TYPE_EDGE_FALLING); | |
97 | + } else { | |
98 | + pr_err("Beagle expansionboard: could not obtain gpio for ENC28J60_IRQ\n"); | |
99 | + return; | |
100 | + } | |
101 | + | |
102 | + spi_register_board_info(omap3beagle_zippy_spi_board_info, | |
103 | + ARRAY_SIZE(omap3beagle_zippy_spi_board_info)); | |
104 | +} | |
105 | + | |
106 | +#else | |
107 | +static inline void __init omap3beagle_enc28j60_init(void) { return; } | |
108 | +#endif | |
109 | + | |
110 | static struct mtd_partition omap3beagle_nand_partitions[] = { | |
111 | /* All the partition sizes are listed in terms of NAND block size */ | |
112 | { | |
113 | @@ -271,6 +352,23 @@ static struct omap2_hsmmc_info mmc[] = { | |
114 | {} /* Terminator */ | |
115 | }; | |
116 | ||
117 | +static struct omap2_hsmmc_info mmc_zippy[] = { | |
118 | + { | |
119 | + .mmc = 1, | |
120 | + .caps = MMC_CAP_4_BIT_DATA, | |
121 | + .gpio_wp = -EINVAL, | |
122 | + .deferred = true, | |
123 | + }, | |
124 | + { | |
125 | + .mmc = 2, | |
126 | + .caps = MMC_CAP_4_BIT_DATA, | |
127 | + .gpio_wp = OMAP3BEAGLE_GPIO_ZIPPY_MMC_WP, | |
128 | + .gpio_cd = OMAP3BEAGLE_GPIO_ZIPPY_MMC_CD, | |
129 | + .transceiver = true, | |
130 | + .deferred = true, | |
131 | + }, | |
132 | + {} /* Terminator */ | |
133 | +}; | |
134 | static struct regulator_consumer_supply beagle_vmmc1_supply[] = { | |
135 | REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"), | |
136 | }; | |
137 | @@ -301,10 +399,21 @@ static int beagle_twl_gpio_setup(struct device *dev, | |
138 | { | |
139 | int r; | |
140 | ||
141 | - mmc[0].gpio_wp = beagle_config.mmc1_gpio_wp; | |
142 | - /* gpio + 0 is "mmc0_cd" (input/IRQ) */ | |
143 | - mmc[0].gpio_cd = gpio + 0; | |
144 | - omap_hsmmc_late_init(mmc); | |
145 | + switch (expansion_config.mmc_settings) { | |
146 | + case EXPANSION_MMC_ZIPPY: | |
147 | + mmc_zippy[0].gpio_wp = beagle_config.mmc1_gpio_wp; | |
148 | + /* gpio + 0 is "mmc0_cd" (input/IRQ) */ | |
149 | + mmc_zippy[0].gpio_cd = gpio + 0; | |
150 | + | |
151 | + omap_hsmmc_late_init(mmc_zippy); | |
152 | + break; | |
153 | + default: | |
154 | + mmc[0].gpio_wp = beagle_config.mmc1_gpio_wp; | |
155 | + /* gpio + 0 is "mmc0_cd" (input/IRQ) */ | |
156 | + mmc[0].gpio_cd = gpio + 0; | |
157 | + | |
158 | + omap_hsmmc_late_init(mmc); | |
159 | + } | |
160 | ||
161 | /* | |
162 | * TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active | |
163 | @@ -396,6 +505,14 @@ static struct i2c_board_info __initdata beagle_i2c_eeprom[] = { | |
164 | }, | |
165 | }; | |
166 | ||
167 | +static struct i2c_board_info __initdata zippy_i2c2_rtc[] = { | |
168 | +#if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE) | |
169 | + { | |
170 | + I2C_BOARD_INFO("ds1307", 0x68), | |
171 | + }, | |
172 | +#endif | |
173 | +}; | |
174 | + | |
175 | static int __init omap3_beagle_i2c_init(void) | |
176 | { | |
177 | omap3_pmic_get_config(&beagle_twldata, | |
178 | @@ -406,6 +523,15 @@ static int __init omap3_beagle_i2c_init(void) | |
179 | beagle_twldata.vpll2->constraints.name = "VDVI"; | |
180 | ||
181 | omap3_pmic_init("twl4030", &beagle_twldata); | |
182 | + | |
183 | + switch (expansion_config.i2c_settings) { | |
184 | + case EXPANSION_I2C_ZIPPY: | |
185 | + omap_register_i2c_bus(2, 400, zippy_i2c2_rtc, ARRAY_SIZE(zippy_i2c2_rtc)); | |
186 | + break; | |
187 | + default: | |
188 | + omap_register_i2c_bus(2, 400, NULL, 0); | |
189 | + } | |
190 | + | |
191 | /* Bus 3 is attached to the DVI port where devices like the pico DLP | |
192 | * projector don't work reliably with 400kHz */ | |
193 | omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom)); | |
194 | @@ -548,10 +674,30 @@ static void __init omap3_beagle_init(void) | |
195 | omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); | |
196 | omap3_beagle_init_rev(); | |
197 | ||
198 | + if (!strcmp(expansionboard_name, "zippy")) | |
199 | + { | |
200 | + pr_info("Beagle expansionboard: initializing zippy mmc\n"); | |
201 | + platform_device_register(&omap_zippy_device); | |
202 | + | |
203 | + expansion_config.i2c_settings = EXPANSION_I2C_ZIPPY; | |
204 | + expansion_config.mmc_settings = EXPANSION_MMC_ZIPPY; | |
205 | + | |
206 | + omap_mux_init_gpio(OMAP3BEAGLE_GPIO_ZIPPY_MMC_WP, OMAP_PIN_INPUT); | |
207 | + omap_mux_init_gpio(OMAP3BEAGLE_GPIO_ZIPPY_MMC_CD, OMAP_PIN_INPUT); | |
208 | + } | |
209 | + | |
210 | if (gpio_is_valid(beagle_config.mmc1_gpio_wp)) | |
211 | omap_mux_init_gpio(beagle_config.mmc1_gpio_wp, OMAP_PIN_INPUT); | |
212 | - mmc[0].caps = beagle_config.mmc_caps; | |
213 | - omap_hsmmc_init(mmc); | |
214 | + | |
215 | + switch (expansion_config.mmc_settings) { | |
216 | + case EXPANSION_MMC_ZIPPY: | |
217 | + mmc_zippy[0].caps = beagle_config.mmc_caps; | |
218 | + omap_hsmmc_init(mmc_zippy); | |
219 | + break; | |
220 | + default: | |
221 | + mmc[0].caps = beagle_config.mmc_caps; | |
222 | + omap_hsmmc_init(mmc); | |
223 | + } | |
224 | ||
225 | omap3_beagle_i2c_init(); | |
226 | ||
227 | @@ -566,6 +712,12 @@ static void __init omap3_beagle_init(void) | |
228 | omap_sdrc_init(mt46h32m32lf6_sdrc_params, | |
229 | mt46h32m32lf6_sdrc_params); | |
230 | ||
231 | + if (!strcmp(expansionboard_name, "zippy")) | |
232 | + { | |
233 | + pr_info("Beagle expansionboard: initializing enc28j60\n"); | |
234 | + omap3beagle_enc28j60_init(); | |
235 | + } | |
236 | + | |
237 | usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb"); | |
238 | usb_musb_init(NULL); | |
239 | ||
240 | -- | |
241 | 1.7.10.4 | |
242 |