blob: 6049f60a88132b36400c301109910dee326d26af [file] [log] [blame]
Tim Nordelld40f3f12010-09-27 16:05:47 +00001/*
2 * linux/arch/arm/mach-omap2/board-omap3logic.c
3 *
4 * Copyright (C) 2010 Li-Pro.Net
5 * Stephan Linz <linz@li-pro.net>
6 *
Ashwin Bihari44bb3192012-05-09 14:19:15 -07007 * Copyright (C) 2010-2012 Logic Product Development, Inc.
Tim Nordelld40f3f12010-09-27 16:05:47 +00008 * Peter Barada <peter.barada@logicpd.com>
Ashwin Bihari44bb3192012-05-09 14:19:15 -07009 * Ashwin BIhari <ashwin.bihari@logicpd.com>
Tim Nordelld40f3f12010-09-27 16:05:47 +000010 *
11 * Modified from Beagle, EVM, and RX51
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 */
17
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
21#include <linux/delay.h>
22#include <linux/err.h>
23#include <linux/clk.h>
24#include <linux/io.h>
25#include <linux/gpio.h>
26
Russ Dill5b3689f2012-03-23 02:21:37 -070027#include <linux/regulator/fixed.h>
Tim Nordelld40f3f12010-09-27 16:05:47 +000028#include <linux/regulator/machine.h>
29
30#include <linux/i2c/twl.h>
Tim Nordell84302812010-09-27 16:05:48 +000031#include <linux/mmc/host.h>
Kishon Vijay Abraham I51482be2013-02-06 18:58:50 +053032#include <linux/usb/phy.h>
Tim Nordelld40f3f12010-09-27 16:05:47 +000033
Tim Nordelld40f3f12010-09-27 16:05:47 +000034#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37
Tony Lindgrendbc04162012-08-31 10:59:07 -070038#include "common.h"
39#include "mux.h"
40#include "hsmmc.h"
41#include "control.h"
42#include "common-board-devices.h"
Tony Lindgren6832c952012-10-17 11:21:34 -070043#include "gpmc.h"
44#include "gpmc-smsc911x.h"
Tony Lindgrendbc04162012-08-31 10:59:07 -070045
Tim Nordelld40f3f12010-09-27 16:05:47 +000046#define OMAP3LOGIC_SMSC911X_CS 1
47
48#define OMAP3530_LV_SOM_MMC_GPIO_CD 110
49#define OMAP3530_LV_SOM_MMC_GPIO_WP 126
50#define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ 152
51
52#define OMAP3_TORPEDO_MMC_GPIO_CD 127
53#define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ 129
54
Oleg Drokin786b01a2011-06-06 18:57:07 +000055static struct regulator_consumer_supply omap3logic_vmmc1_supply[] = {
56 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
Tim Nordelld40f3f12010-09-27 16:05:47 +000057};
58
59/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
60static struct regulator_init_data omap3logic_vmmc1 = {
61 .constraints = {
62 .name = "VMMC1",
63 .min_uV = 1850000,
64 .max_uV = 3150000,
65 .valid_modes_mask = REGULATOR_MODE_NORMAL
66 | REGULATOR_MODE_STANDBY,
67 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
68 | REGULATOR_CHANGE_MODE
69 | REGULATOR_CHANGE_STATUS,
70 },
Oleg Drokin786b01a2011-06-06 18:57:07 +000071 .num_consumer_supplies = ARRAY_SIZE(omap3logic_vmmc1_supply),
72 .consumer_supplies = omap3logic_vmmc1_supply,
Tim Nordelld40f3f12010-09-27 16:05:47 +000073};
74
75static struct twl4030_gpio_platform_data omap3logic_gpio_data = {
Tim Nordelld40f3f12010-09-27 16:05:47 +000076 .use_leds = true,
77 .pullups = BIT(1),
78 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8)
79 | BIT(13) | BIT(15) | BIT(16) | BIT(17),
80};
81
Ashwin Bihari44bb3192012-05-09 14:19:15 -070082static struct twl4030_usb_data omap3logic_usb_data = {
83 .usb_mode = T2_USB_MODE_ULPI,
84};
85
86
Tim Nordelld40f3f12010-09-27 16:05:47 +000087static struct twl4030_platform_data omap3logic_twldata = {
Tim Nordelld40f3f12010-09-27 16:05:47 +000088 /* platform_data for children goes here */
89 .gpio = &omap3logic_gpio_data,
Tim Nordell84302812010-09-27 16:05:48 +000090 .vmmc1 = &omap3logic_vmmc1,
Ashwin Bihari44bb3192012-05-09 14:19:15 -070091 .usb = &omap3logic_usb_data,
Tim Nordelld40f3f12010-09-27 16:05:47 +000092};
93
Tim Nordelld40f3f12010-09-27 16:05:47 +000094static int __init omap3logic_i2c_init(void)
95{
Mike Rapoportfbd80712011-04-25 01:09:06 +030096 omap3_pmic_init("twl4030", &omap3logic_twldata);
Tim Nordelld40f3f12010-09-27 16:05:47 +000097 return 0;
98}
99
Tim Nordell84302812010-09-27 16:05:48 +0000100static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
101 {
102 .name = "external",
103 .mmc = 1,
104 .caps = MMC_CAP_4_BIT_DATA,
105 .gpio_cd = -EINVAL,
106 .gpio_wp = -EINVAL,
107 },
108 {} /* Terminator */
109};
110
111static void __init board_mmc_init(void)
112{
113 if (machine_is_omap3530_lv_som()) {
114 /* OMAP3530 LV SOM board */
115 board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD;
116 board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP;
117 omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT);
118 omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT);
119 } else if (machine_is_omap3_torpedo()) {
120 /* OMAP3 Torpedo board */
121 board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD;
122 omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT);
123 } else {
124 /* unsupported board */
125 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
126 return;
127 }
128
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800129 omap_hsmmc_init(board_mmc_info);
Tim Nordell84302812010-09-27 16:05:48 +0000130}
131
Tim Nordell26428b52010-09-27 16:05:50 +0000132static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
133 .cs = OMAP3LOGIC_SMSC911X_CS,
134 .gpio_irq = -EINVAL,
135 .gpio_reset = -EINVAL,
Tim Nordell26428b52010-09-27 16:05:50 +0000136};
137
138/* TODO/FIXME (comment by Peter Barada, LogicPD):
139 * Fix the PBIAS voltage for Torpedo MMC1 pins that
140 * are used for other needs (IRQs, etc). */
141static void omap3torpedo_fix_pbias_voltage(void)
142{
143 u16 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
144 u32 reg;
145
146 if (machine_is_omap3_torpedo())
147 {
148 /* Set the bias for the pin */
149 reg = omap_ctrl_readl(control_pbias_offset);
150
151 reg &= ~OMAP343X_PBIASLITEPWRDNZ1;
152 omap_ctrl_writel(reg, control_pbias_offset);
153
154 /* 100ms delay required for PBIAS configuration */
155 msleep(100);
156
157 reg |= OMAP343X_PBIASLITEVMODE1;
158 reg |= OMAP343X_PBIASLITEPWRDNZ1;
159 omap_ctrl_writel(reg | 0x300, control_pbias_offset);
160 }
161}
162
163static inline void __init board_smsc911x_init(void)
164{
165 if (machine_is_omap3530_lv_som()) {
166 /* OMAP3530 LV SOM board */
167 board_smsc911x_data.gpio_irq =
168 OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ;
169 omap_mux_init_signal("gpio_152", OMAP_PIN_INPUT);
170 } else if (machine_is_omap3_torpedo()) {
171 /* OMAP3 Torpedo board */
172 board_smsc911x_data.gpio_irq = OMAP3_TORPEDO_SMSC911X_GPIO_IRQ;
173 omap_mux_init_signal("gpio_129", OMAP_PIN_INPUT);
174 } else {
175 /* unsupported board */
176 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
177 return;
178 }
179
180 gpmc_smsc911x_init(&board_smsc911x_data);
181}
182
Tim Nordell26428b52010-09-27 16:05:50 +0000183#ifdef CONFIG_OMAP_MUX
184static struct omap_board_mux board_mux[] __initdata = {
Ashwin Bihari44bb3192012-05-09 14:19:15 -0700185 /* mUSB */
186 OMAP3_MUX(HSUSB0_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
187 OMAP3_MUX(HSUSB0_STP, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT),
188 OMAP3_MUX(HSUSB0_DIR, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
189 OMAP3_MUX(HSUSB0_NXT, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
190 OMAP3_MUX(HSUSB0_DATA0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
191 OMAP3_MUX(HSUSB0_DATA1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
192 OMAP3_MUX(HSUSB0_DATA2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
193 OMAP3_MUX(HSUSB0_DATA3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
194 OMAP3_MUX(HSUSB0_DATA4, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
195 OMAP3_MUX(HSUSB0_DATA5, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
196 OMAP3_MUX(HSUSB0_DATA6, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
197 OMAP3_MUX(HSUSB0_DATA7, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
198
Tim Nordell26428b52010-09-27 16:05:50 +0000199 { .reg_offset = OMAP_MUX_TERMINATOR },
200};
Tim Nordell26428b52010-09-27 16:05:50 +0000201#endif
202
Russ Dill5b3689f2012-03-23 02:21:37 -0700203static struct regulator_consumer_supply dummy_supplies[] = {
204 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
205 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
206};
207
Tim Nordelld40f3f12010-09-27 16:05:47 +0000208static void __init omap3logic_init(void)
209{
Russ Dill5b3689f2012-03-23 02:21:37 -0700210 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
Tim Nordell26428b52010-09-27 16:05:50 +0000211 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
212 omap3torpedo_fix_pbias_voltage();
Tim Nordelld40f3f12010-09-27 16:05:47 +0000213 omap3logic_i2c_init();
214 omap_serial_init();
Tony Lindgrena4ca9db2011-08-22 23:57:23 -0700215 omap_sdrc_init(NULL, NULL);
Tim Nordell84302812010-09-27 16:05:48 +0000216 board_mmc_init();
Tim Nordell26428b52010-09-27 16:05:50 +0000217 board_smsc911x_init();
218
Kishon Vijay Abraham I51482be2013-02-06 18:58:50 +0530219 usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
Ashwin Bihari44bb3192012-05-09 14:19:15 -0700220 usb_musb_init(NULL);
221
Tim Nordelld40f3f12010-09-27 16:05:47 +0000222 /* Ensure SDRC pins are mux'd for self-refresh */
223 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
224 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
225}
226
227MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board")
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400228 .atag_offset = 0x100,
Alexafbb1892012-03-05 11:08:35 -0800229 .reserve = omap_reserve,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000230 .map_io = omap3_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700231 .init_early = omap35xx_init_early,
Tony Lindgren741e3a82011-05-17 03:51:26 -0700232 .init_irq = omap3_init_irq,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000233 .init_machine = omap3logic_init,
Shawn Guobbd707a2012-04-26 16:06:50 +0800234 .init_late = omap35xx_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700235 .init_time = omap3_sync32k_timer_init,
Paul Walmsley187e3e02012-10-29 20:56:12 -0600236 .restart = omap3xxx_restart,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000237MACHINE_END
238
239MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board")
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400240 .atag_offset = 0x100,
Alexafbb1892012-03-05 11:08:35 -0800241 .reserve = omap_reserve,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000242 .map_io = omap3_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700243 .init_early = omap35xx_init_early,
Tony Lindgren741e3a82011-05-17 03:51:26 -0700244 .init_irq = omap3_init_irq,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000245 .init_machine = omap3logic_init,
Shawn Guobbd707a2012-04-26 16:06:50 +0800246 .init_late = omap35xx_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700247 .init_time = omap3_sync32k_timer_init,
Paul Walmsley187e3e02012-10-29 20:56:12 -0600248 .restart = omap3xxx_restart,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000249MACHINE_END