[glsdk/meta-ti-glsdk.git] / recipes-bsp / linux / linux-omap-psp-2.6.32 / 0026-board-overo-add-PM-code-and-sync-with-http-www.sakom.patch
1 From 1f91f7f6dea0268e23d5e3e78b6c8dc5ed245313 Mon Sep 17 00:00:00 2001
2 From: Koen Kooi <koen@dominion.thruhere.net>
3 Date: Sun, 14 Feb 2010 12:52:02 +0100
4 Subject: [PATCH 26/45] board-overo: add PM code and sync with http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=shortlog;h=refs/heads/omap3-2.6.32
6 ---
7 arch/arm/mach-omap2/board-overo.c | 274 ++++++++++++++++++++++++++++++++-----
8 1 files changed, 242 insertions(+), 32 deletions(-)
10 diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
11 index 9c76588..2595f81 100644
12 --- a/arch/arm/mach-omap2/board-overo.c
13 +++ b/arch/arm/mach-omap2/board-overo.c
14 @@ -28,6 +28,7 @@
15 #include <linux/platform_device.h>
16 #include <linux/i2c/twl.h>
17 #include <linux/regulator/machine.h>
18 +#include <linux/spi/spi.h>
20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/nand.h>
22 @@ -40,16 +41,24 @@
24 #include <plat/board.h>
25 #include <plat/common.h>
26 +#include <plat/display.h>
27 #include <mach/gpio.h>
28 #include <plat/gpmc.h>
29 #include <mach/hardware.h>
30 #include <plat/nand.h>
31 +#include <plat/mcspi.h>
32 #include <plat/usb.h>
33 -
34 -#include "mux.h"
35 +#include <plat/clock.h>
36 +#include <plat/omap-pm.h>
37 +
38 #include "sdram-micron-mt46h32m32lf-6.h"
39 #include "mmc-twl4030.h"
41 +#include "mux.h"
42 +
43 +#include "pm.h"
44 +#include "omap3-opp.h"
45 +
46 #define OVERO_GPIO_BT_XGATE 15
47 #define OVERO_GPIO_W2W_NRESET 16
48 #define OVERO_GPIO_PENDOWN 114
49 @@ -95,18 +104,6 @@ static struct ads7846_platform_data ads7846_config = {
50 .keep_vref_on = 1,
51 };
53 -static struct spi_board_info overo_spi_board_info[] __initdata = {
54 - {
55 - .modalias = "ads7846",
56 - .bus_num = 1,
57 - .chip_select = 0,
58 - .max_speed_hz = 1500000,
59 - .controller_data = &ads7846_mcspi_config,
60 - .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
61 - .platform_data = &ads7846_config,
62 - }
63 -};
64 -
65 static void __init overo_ads7846_init(void)
66 {
67 if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
68 @@ -116,9 +113,6 @@ static void __init overo_ads7846_init(void)
69 printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
70 return;
71 }
72 -
73 - spi_register_board_info(overo_spi_board_info,
74 - ARRAY_SIZE(overo_spi_board_info));
75 }
77 #else
78 @@ -234,6 +228,169 @@ static inline void __init overo_init_smsc911x(void)
79 static inline void __init overo_init_smsc911x(void) { return; }
80 #endif
82 +/* DSS */
83 +static int lcd_enabled;
84 +static int dvi_enabled;
85 +
86 +#define OVERO_GPIO_LCD_EN 144
87 +#define OVERO_GPIO_LCD_BL 145
88 +
89 +static void __init overo_display_init(void)
90 +{
91 + if ((gpio_request(OVERO_GPIO_LCD_EN, "OVERO_GPIO_LCD_EN") == 0) &&
92 + (gpio_direction_output(OVERO_GPIO_LCD_EN, 1) == 0))
93 + gpio_export(OVERO_GPIO_LCD_EN, 0);
94 + else
95 + printk(KERN_ERR "could not obtain gpio for "
96 + "OVERO_GPIO_LCD_EN\n");
97 +
98 + if ((gpio_request(OVERO_GPIO_LCD_BL, "OVERO_GPIO_LCD_BL") == 0) &&
99 + (gpio_direction_output(OVERO_GPIO_LCD_BL, 1) == 0))
100 + gpio_export(OVERO_GPIO_LCD_BL, 0);
101 + else
102 + printk(KERN_ERR "could not obtain gpio for "
103 + "OVERO_GPIO_LCD_BL\n");
104 +}
105 +
106 +static int overo_panel_enable_dvi(struct omap_dss_device *dssdev)
107 +{
108 + if (lcd_enabled) {
109 + printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
110 + return -EINVAL;
111 + }
112 + dvi_enabled = 1;
113 +
114 + return 0;
115 +}
116 +
117 +static void overo_panel_disable_dvi(struct omap_dss_device *dssdev)
118 +{
119 + dvi_enabled = 0;
120 +}
121 +
122 +static struct omap_dss_device overo_dvi_device = {
123 + .type = OMAP_DISPLAY_TYPE_DPI,
124 + .name = "dvi",
125 + .driver_name = "generic_panel",
126 + .phy.dpi.data_lines = 24,
127 + .platform_enable = overo_panel_enable_dvi,
128 + .platform_disable = overo_panel_disable_dvi,
129 +};
130 +
131 +static int overo_panel_enable_tv(struct omap_dss_device *dssdev)
132 +{
133 +#define ENABLE_VDAC_DEDICATED 0x03
134 +#define ENABLE_VDAC_DEV_GRP 0x20
135 +
136 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
137 + ENABLE_VDAC_DEDICATED,
138 + TWL4030_VDAC_DEDICATED);
139 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
140 + ENABLE_VDAC_DEV_GRP, TWL4030_VDAC_DEV_GRP);
141 +
142 + return 0;
143 +}
144 +
145 +static void overo_panel_disable_tv(struct omap_dss_device *dssdev)
146 +{
147 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
148 + TWL4030_VDAC_DEDICATED);
149 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
150 + TWL4030_VDAC_DEV_GRP);
151 +}
152 +
153 +static struct omap_dss_device overo_tv_device = {
154 + .name = "tv",
155 + .driver_name = "venc",
156 + .type = OMAP_DISPLAY_TYPE_VENC,
157 + .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
158 + .platform_enable = overo_panel_enable_tv,
159 + .platform_disable = overo_panel_disable_tv,
160 +};
161 +
162 +static int overo_panel_enable_lcd(struct omap_dss_device *dssdev)
163 +{
164 + if (dvi_enabled) {
165 + printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
166 + return -EINVAL;
167 + }
168 +
169 + gpio_set_value(OVERO_GPIO_LCD_EN, 1);
170 + gpio_set_value(OVERO_GPIO_LCD_BL, 1);
171 + lcd_enabled = 1;
172 + return 0;
173 +}
174 +
175 +static void overo_panel_disable_lcd(struct omap_dss_device *dssdev)
176 +{
177 + gpio_set_value(OVERO_GPIO_LCD_EN, 0);
178 + gpio_set_value(OVERO_GPIO_LCD_BL, 0);
179 + lcd_enabled = 0;
180 +}
181 +
182 +#if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
183 + defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
184 +static struct omap_dss_device overo_lcd35_device = {
185 + .type = OMAP_DISPLAY_TYPE_DPI,
186 + .name = "lcd35",
187 + .driver_name = "lgphilips_lb035q02_panel",
188 + .phy.dpi.data_lines = 24,
189 + .panel.recommended_bpp = 16,
190 + .platform_enable = overo_panel_enable_lcd,
191 + .platform_disable = overo_panel_disable_lcd,
192 +};
193 +#endif
194 +
195 +#if defined(CONFIG_PANEL_SAMSUNG_LTE430WQ_F0C) || \
196 + defined(CONFIG_PANEL_SAMSUNG_LTE430WQ_F0C_MODULE)
197 +static struct omap_dss_device overo_lcd43_device = {
198 + .type = OMAP_DISPLAY_TYPE_DPI,
199 + .name = "lcd43",
200 + .driver_name = "samsung_lte_panel",
201 + .phy.dpi.data_lines = 24,
202 + .panel.recommended_bpp = 16,
203 + .platform_enable = overo_panel_enable_lcd,
204 + .platform_disable = overo_panel_disable_lcd,
205 +};
206 +#endif
207 +
208 +static struct omap_dss_device *overo_dss_devices[] = {
209 + &overo_dvi_device,
210 + &overo_tv_device,
211 +#if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
212 + defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
213 + &overo_lcd35_device,
214 +#endif
215 +#if defined(CONFIG_PANEL_SAMSUNG_LTE430WQ_F0C) || \
216 + defined(CONFIG_PANEL_SAMSUNG_LTE430WQ_F0C_MODULE)
217 + &overo_lcd43_device,
218 +#endif
219 +};
220 +
221 +static struct omap_dss_board_info overo_dss_data = {
222 + .num_devices = ARRAY_SIZE(overo_dss_devices),
223 + .devices = overo_dss_devices,
224 + .default_device = &overo_dvi_device,
225 +};
226 +
227 +static struct platform_device overo_dss_device = {
228 + .name = "omapdss",
229 + .id = -1,
230 + .dev = {
231 + .platform_data = &overo_dss_data,
232 + },
233 +};
234 +
235 +static struct regulator_consumer_supply overo_vdda_dac_supply = {
236 + .supply = "vdda_dac",
237 + .dev = &overo_dss_device.dev,
238 +};
239 +
240 +static struct regulator_consumer_supply overo_vdds_dsi_supply = {
241 + .supply = "vdds_dsi",
242 + .dev = &overo_dss_device.dev,
243 +};
244 +
245 static struct mtd_partition overo_nand_partitions[] = {
246 {
247 .name = "xloader",
248 @@ -379,6 +536,37 @@ static struct regulator_init_data overo_vmmc1 = {
249 .consumer_supplies = &overo_vmmc1_supply,
250 };
252 +/* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
253 +static struct regulator_init_data overo_vdac = {
254 + .constraints = {
255 + .min_uV = 1800000,
256 + .max_uV = 1800000,
257 + .valid_modes_mask = REGULATOR_MODE_NORMAL
258 + | REGULATOR_MODE_STANDBY,
259 + .valid_ops_mask = REGULATOR_CHANGE_MODE
260 + | REGULATOR_CHANGE_STATUS,
261 + },
262 + .num_consumer_supplies = 1,
263 + .consumer_supplies = &overo_vdda_dac_supply,
264 +};
265 +
266 +/* VPLL2 for digital video outputs */
267 +static struct regulator_init_data overo_vpll2 = {
268 + .constraints = {
269 + .name = "VDVI",
270 + .min_uV = 1800000,
271 + .max_uV = 1800000,
272 + .valid_modes_mask = REGULATOR_MODE_NORMAL
273 + | REGULATOR_MODE_STANDBY,
274 + .valid_ops_mask = REGULATOR_CHANGE_MODE
275 + | REGULATOR_CHANGE_STATUS,
276 + },
277 + .num_consumer_supplies = 1,
278 + .consumer_supplies = &overo_vdds_dsi_supply,
279 +};
280 +
281 +/* mmc2 (WLAN) and Bluetooth don't use twl4030 regulators */
282 +
283 static struct twl4030_codec_audio_data overo_audio_data = {
284 .audio_mclk = 26000000,
285 };
286 @@ -402,6 +590,8 @@ static struct twl4030_platform_data overo_twldata = {
287 .usb = &overo_usb_data,
288 .codec = &overo_codec_data,
289 .vmmc1 = &overo_vmmc1,
290 + .vdac = &overo_vdac,
291 + .vpll2 = &overo_vpll2,
292 };
294 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
295 @@ -422,31 +612,50 @@ static int __init overo_i2c_init(void)
296 return 0;
297 }
299 -static struct platform_device overo_lcd_device = {
300 - .name = "overo_lcd",
301 - .id = -1,
302 -};
303 -
304 -static struct omap_lcd_config overo_lcd_config __initdata = {
305 - .ctrl_name = "internal",
306 +static struct spi_board_info overo_spi_board_info[] __initdata = {
307 +#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
308 + defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
309 + {
310 + .modalias = "ads7846",
311 + .bus_num = 1,
312 + .chip_select = 0,
313 + .max_speed_hz = 1500000,
314 + .controller_data = &ads7846_mcspi_config,
315 + .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
316 + .platform_data = &ads7846_config,
317 + },
318 +#endif
319 +#if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
320 + defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
321 + {
322 + .modalias = "lgphilips_lb035q02_panel-spi",
323 + .bus_num = 1,
324 + .chip_select = 1,
325 + .max_speed_hz = 500000,
326 + .mode = SPI_MODE_3,
327 + },
328 +#endif
329 };
331 -static struct omap_board_config_kernel overo_config[] __initdata = {
332 - { OMAP_TAG_LCD, &overo_lcd_config },
333 -};
334 +static int __init overo_spi_init(void)
335 +{
336 + overo_ads7846_init();
337 + spi_register_board_info(overo_spi_board_info,
338 + ARRAY_SIZE(overo_spi_board_info));
339 + return 0;
340 +}
342 static void __init overo_init_irq(void)
343 {
344 - omap_board_config = overo_config;
345 - omap_board_config_size = ARRAY_SIZE(overo_config);
346 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
347 - mt46h32m32lf6_sdrc_params, NULL, NULL, NULL);
348 + NULL, omap35x_mpu_rate_table,
349 + omap35x_dsp_rate_table, omap35x_l3_rate_table);
350 omap_init_irq();
351 omap_gpio_init();
352 }
354 static struct platform_device *overo_devices[] __initdata = {
355 - &overo_lcd_device,
356 + &overo_dss_device,
357 };
359 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
360 @@ -477,8 +686,9 @@ static void __init overo_init(void)
361 overo_flash_init();
362 usb_musb_init();
363 usb_ehci_init(&ehci_pdata);
364 - overo_ads7846_init();
365 + overo_spi_init();
366 overo_init_smsc911x();
367 + overo_display_init();
369 /* Ensure SDRC pins are mux'd for self-refresh */
370 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
371 --
372 1.6.6.1