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
6 v2: add #include <linux/regulator/fixed.h>
7 build fix from Pantelis Antoniou <panto@antoniou-consulting.com>
9 Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
11 arch/arm/mach-omap2/board-omap3beagle.c | 164 +++++++++++++++++++++++++++++--
12 1 file changed, 158 insertions(+), 6 deletions(-)
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
19 #include <linux/usb/nop-usb-xceiv.h>
21 #include <linux/regulator/machine.h>
22 +#include <linux/regulator/fixed.h>
23 #include <linux/i2c/twl.h>
25 #include <asm/mach-types.h>
26 @@ -195,6 +196,86 @@ static void __init omap3_beagle_init_rev(void)
28 char expansionboard_name[16];
31 + EXPANSION_MMC_NONE = 0,
32 + EXPANSION_MMC_ZIPPY,
37 + EXPANSION_I2C_NONE = 0,
38 + EXPANSION_I2C_ZIPPY,
44 +} expansion_config = {
45 + .mmc_settings = EXPANSION_MMC_NONE,
46 + .i2c_settings = EXPANSION_I2C_NONE,
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 */
55 + .enabled_at_boot = 0,
56 + .init_data = &beagle_vmmc2,
59 +static struct platform_device omap_zippy_device = {
60 + .name = "reg-fixed-voltage",
63 + .platform_data = &beagle_vzippy,
67 +#define OMAP3BEAGLE_GPIO_ZIPPY_MMC_WP 141
68 +#define OMAP3BEAGLE_GPIO_ZIPPY_MMC_CD 162
70 +#if IS_ENABLED(CONFIG_ENC28J60)
71 +#include <linux/platform_data/spi-omap2-mcspi.h>
72 +#include <linux/spi/spi.h>
74 +#define OMAP3BEAGLE_GPIO_ENC28J60_IRQ 157
76 +static struct omap2_mcspi_device_config enc28j60_spi_chip_info = {
80 +static struct spi_board_info omap3beagle_zippy_spi_board_info[] __initdata = {
82 + .modalias = "enc28j60",
85 + .max_speed_hz = 20000000,
86 + .controller_data = &enc28j60_spi_chip_info,
90 +static void __init omap3beagle_enc28j60_init(void)
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);
98 + pr_err("Beagle expansionboard: could not obtain gpio for ENC28J60_IRQ\n");
102 + spi_register_board_info(omap3beagle_zippy_spi_board_info,
103 + ARRAY_SIZE(omap3beagle_zippy_spi_board_info));
107 +static inline void __init omap3beagle_enc28j60_init(void) { return; }
110 static struct mtd_partition omap3beagle_nand_partitions[] = {
111 /* All the partition sizes are listed in terms of NAND block size */
113 @@ -271,6 +352,23 @@ static struct omap2_hsmmc_info mmc[] = {
117 +static struct omap2_hsmmc_info mmc_zippy[] = {
120 + .caps = MMC_CAP_4_BIT_DATA,
121 + .gpio_wp = -EINVAL,
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,
132 + {} /* Terminator */
134 static struct regulator_consumer_supply beagle_vmmc1_supply[] = {
135 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
137 @@ -301,10 +399,21 @@ static int beagle_twl_gpio_setup(struct device *dev,
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;
151 + omap_hsmmc_late_init(mmc_zippy);
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;
158 + omap_hsmmc_late_init(mmc);
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[] = {
167 +static struct i2c_board_info __initdata zippy_i2c2_rtc[] = {
168 +#if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
170 + I2C_BOARD_INFO("ds1307", 0x68),
175 static int __init omap3_beagle_i2c_init(void)
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";
181 omap3_pmic_init("twl4030", &beagle_twldata);
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));
188 + omap_register_i2c_bus(2, 400, NULL, 0);
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();
198 + if (!strcmp(expansionboard_name, "zippy"))
200 + pr_info("Beagle expansionboard: initializing zippy mmc\n");
201 + platform_device_register(&omap_zippy_device);
203 + expansion_config.i2c_settings = EXPANSION_I2C_ZIPPY;
204 + expansion_config.mmc_settings = EXPANSION_MMC_ZIPPY;
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);
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);
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);
221 + mmc[0].caps = beagle_config.mmc_caps;
222 + omap_hsmmc_init(mmc);
225 omap3_beagle_i2c_init();
227 @@ -566,6 +712,12 @@ static void __init omap3_beagle_init(void)
228 omap_sdrc_init(mt46h32m32lf6_sdrc_params,
229 mt46h32m32lf6_sdrc_params);
231 + if (!strcmp(expansionboard_name, "zippy"))
233 + pr_info("Beagle expansionboard: initializing enc28j60\n");
234 + omap3beagle_enc28j60_init();
237 usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");