blob: 9b3c141ff51bc575d65f157daf702df4ba6eab89 [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 *
7 * Copyright (C) 2010 Logic Product Development, Inc.
8 * Peter Barada <peter.barada@logicpd.com>
9 *
10 * Modified from Beagle, EVM, and RX51
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/platform_device.h>
20#include <linux/delay.h>
21#include <linux/err.h>
22#include <linux/clk.h>
23#include <linux/io.h>
24#include <linux/gpio.h>
25
Russ Dill5b3689f2012-03-23 02:21:37 -070026#include <linux/regulator/fixed.h>
Tim Nordelld40f3f12010-09-27 16:05:47 +000027#include <linux/regulator/machine.h>
28
29#include <linux/i2c/twl.h>
Tim Nordell84302812010-09-27 16:05:48 +000030#include <linux/mmc/host.h>
Tim Nordelld40f3f12010-09-27 16:05:47 +000031
32#include <mach/hardware.h>
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
36
37#include "mux.h"
Tim Nordell84302812010-09-27 16:05:48 +000038#include "hsmmc.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060039#include "control.h"
Mike Rapoportfbd80712011-04-25 01:09:06 +030040#include "common-board-devices.h"
Tim Nordelld40f3f12010-09-27 16:05:47 +000041
42#include <plat/mux.h>
43#include <plat/board.h>
Tony Lindgren4e653312011-11-10 22:45:17 +010044#include "common.h"
Tim Nordell26428b52010-09-27 16:05:50 +000045#include <plat/gpmc-smsc911x.h>
Tim Nordelld40f3f12010-09-27 16:05:47 +000046#include <plat/gpmc.h>
Tim Nordelld40f3f12010-09-27 16:05:47 +000047#include <plat/sdrc.h>
Tim Nordelld40f3f12010-09-27 16:05:47 +000048
49#define OMAP3LOGIC_SMSC911X_CS 1
50
51#define OMAP3530_LV_SOM_MMC_GPIO_CD 110
52#define OMAP3530_LV_SOM_MMC_GPIO_WP 126
53#define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ 152
54
55#define OMAP3_TORPEDO_MMC_GPIO_CD 127
56#define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ 129
57
Oleg Drokin786b01a2011-06-06 18:57:07 +000058static struct regulator_consumer_supply omap3logic_vmmc1_supply[] = {
59 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
Tim Nordelld40f3f12010-09-27 16:05:47 +000060};
61
62/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
63static struct regulator_init_data omap3logic_vmmc1 = {
64 .constraints = {
65 .name = "VMMC1",
66 .min_uV = 1850000,
67 .max_uV = 3150000,
68 .valid_modes_mask = REGULATOR_MODE_NORMAL
69 | REGULATOR_MODE_STANDBY,
70 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
71 | REGULATOR_CHANGE_MODE
72 | REGULATOR_CHANGE_STATUS,
73 },
Oleg Drokin786b01a2011-06-06 18:57:07 +000074 .num_consumer_supplies = ARRAY_SIZE(omap3logic_vmmc1_supply),
75 .consumer_supplies = omap3logic_vmmc1_supply,
Tim Nordelld40f3f12010-09-27 16:05:47 +000076};
77
78static struct twl4030_gpio_platform_data omap3logic_gpio_data = {
79 .gpio_base = OMAP_MAX_GPIO_LINES,
80 .irq_base = TWL4030_GPIO_IRQ_BASE,
81 .irq_end = TWL4030_GPIO_IRQ_END,
82 .use_leds = true,
83 .pullups = BIT(1),
84 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8)
85 | BIT(13) | BIT(15) | BIT(16) | BIT(17),
86};
87
88static struct twl4030_platform_data omap3logic_twldata = {
89 .irq_base = TWL4030_IRQ_BASE,
90 .irq_end = TWL4030_IRQ_END,
91
92 /* platform_data for children goes here */
93 .gpio = &omap3logic_gpio_data,
Tim Nordell84302812010-09-27 16:05:48 +000094 .vmmc1 = &omap3logic_vmmc1,
Tim Nordelld40f3f12010-09-27 16:05:47 +000095};
96
Tim Nordelld40f3f12010-09-27 16:05:47 +000097static int __init omap3logic_i2c_init(void)
98{
Mike Rapoportfbd80712011-04-25 01:09:06 +030099 omap3_pmic_init("twl4030", &omap3logic_twldata);
Tim Nordelld40f3f12010-09-27 16:05:47 +0000100 return 0;
101}
102
Tim Nordell84302812010-09-27 16:05:48 +0000103static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
104 {
105 .name = "external",
106 .mmc = 1,
107 .caps = MMC_CAP_4_BIT_DATA,
108 .gpio_cd = -EINVAL,
109 .gpio_wp = -EINVAL,
110 },
111 {} /* Terminator */
112};
113
114static void __init board_mmc_init(void)
115{
116 if (machine_is_omap3530_lv_som()) {
117 /* OMAP3530 LV SOM board */
118 board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD;
119 board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP;
120 omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT);
121 omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT);
122 } else if (machine_is_omap3_torpedo()) {
123 /* OMAP3 Torpedo board */
124 board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD;
125 omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT);
126 } else {
127 /* unsupported board */
128 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
129 return;
130 }
131
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800132 omap_hsmmc_init(board_mmc_info);
Tim Nordell84302812010-09-27 16:05:48 +0000133}
134
Tim Nordell26428b52010-09-27 16:05:50 +0000135static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
136 .cs = OMAP3LOGIC_SMSC911X_CS,
137 .gpio_irq = -EINVAL,
138 .gpio_reset = -EINVAL,
Tim Nordell26428b52010-09-27 16:05:50 +0000139};
140
141/* TODO/FIXME (comment by Peter Barada, LogicPD):
142 * Fix the PBIAS voltage for Torpedo MMC1 pins that
143 * are used for other needs (IRQs, etc). */
144static void omap3torpedo_fix_pbias_voltage(void)
145{
146 u16 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
147 u32 reg;
148
149 if (machine_is_omap3_torpedo())
150 {
151 /* Set the bias for the pin */
152 reg = omap_ctrl_readl(control_pbias_offset);
153
154 reg &= ~OMAP343X_PBIASLITEPWRDNZ1;
155 omap_ctrl_writel(reg, control_pbias_offset);
156
157 /* 100ms delay required for PBIAS configuration */
158 msleep(100);
159
160 reg |= OMAP343X_PBIASLITEVMODE1;
161 reg |= OMAP343X_PBIASLITEPWRDNZ1;
162 omap_ctrl_writel(reg | 0x300, control_pbias_offset);
163 }
164}
165
166static inline void __init board_smsc911x_init(void)
167{
168 if (machine_is_omap3530_lv_som()) {
169 /* OMAP3530 LV SOM board */
170 board_smsc911x_data.gpio_irq =
171 OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ;
172 omap_mux_init_signal("gpio_152", OMAP_PIN_INPUT);
173 } else if (machine_is_omap3_torpedo()) {
174 /* OMAP3 Torpedo board */
175 board_smsc911x_data.gpio_irq = OMAP3_TORPEDO_SMSC911X_GPIO_IRQ;
176 omap_mux_init_signal("gpio_129", OMAP_PIN_INPUT);
177 } else {
178 /* unsupported board */
179 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
180 return;
181 }
182
183 gpmc_smsc911x_init(&board_smsc911x_data);
184}
185
Tim Nordell26428b52010-09-27 16:05:50 +0000186#ifdef CONFIG_OMAP_MUX
187static struct omap_board_mux board_mux[] __initdata = {
188 { .reg_offset = OMAP_MUX_TERMINATOR },
189};
Tim Nordell26428b52010-09-27 16:05:50 +0000190#endif
191
Russ Dill5b3689f2012-03-23 02:21:37 -0700192static struct regulator_consumer_supply dummy_supplies[] = {
193 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
194 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
195};
196
Tim Nordelld40f3f12010-09-27 16:05:47 +0000197static void __init omap3logic_init(void)
198{
Russ Dill5b3689f2012-03-23 02:21:37 -0700199 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
Tim Nordell26428b52010-09-27 16:05:50 +0000200 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
201 omap3torpedo_fix_pbias_voltage();
Tim Nordelld40f3f12010-09-27 16:05:47 +0000202 omap3logic_i2c_init();
203 omap_serial_init();
Tony Lindgrena4ca9db2011-08-22 23:57:23 -0700204 omap_sdrc_init(NULL, NULL);
Tim Nordell84302812010-09-27 16:05:48 +0000205 board_mmc_init();
Tim Nordell26428b52010-09-27 16:05:50 +0000206 board_smsc911x_init();
207
Tim Nordelld40f3f12010-09-27 16:05:47 +0000208 /* Ensure SDRC pins are mux'd for self-refresh */
209 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
210 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
211}
212
213MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board")
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400214 .atag_offset = 0x100,
Alexafbb1892012-03-05 11:08:35 -0800215 .reserve = omap_reserve,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000216 .map_io = omap3_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700217 .init_early = omap35xx_init_early,
Tony Lindgren741e3a82011-05-17 03:51:26 -0700218 .init_irq = omap3_init_irq,
Marc Zyngier6b2f55d2011-09-06 10:23:45 +0100219 .handle_irq = omap3_intc_handle_irq,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000220 .init_machine = omap3logic_init,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700221 .timer = &omap3_timer,
Russell Kingbaa95882011-11-05 17:06:28 +0000222 .restart = omap_prcm_restart,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000223MACHINE_END
224
225MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board")
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400226 .atag_offset = 0x100,
Alexafbb1892012-03-05 11:08:35 -0800227 .reserve = omap_reserve,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000228 .map_io = omap3_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700229 .init_early = omap35xx_init_early,
Tony Lindgren741e3a82011-05-17 03:51:26 -0700230 .init_irq = omap3_init_irq,
Marc Zyngier6b2f55d2011-09-06 10:23:45 +0100231 .handle_irq = omap3_intc_handle_irq,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000232 .init_machine = omap3logic_init,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700233 .timer = &omap3_timer,
Russell Kingbaa95882011-11-05 17:06:28 +0000234 .restart = omap_prcm_restart,
Tim Nordelld40f3f12010-09-27 16:05:47 +0000235MACHINE_END