omap24xx: Fix n810 boot
[openwrt/staging/lynxis.git] / target / linux / omap24xx / patches-3.1 / 310-n810-lcd.patch
1 Index: linux-3.1/arch/arm/mach-omap2/board-n8x0.c
2 ===================================================================
3 --- linux-3.1.orig/arch/arm/mach-omap2/board-n8x0.c 2011-10-30 19:31:22.825292085 +0100
4 +++ linux-3.1/arch/arm/mach-omap2/board-n8x0.c 2011-10-30 19:31:25.817235793 +0100
5 @@ -24,6 +24,7 @@
6 #include <linux/spi/spi.h>
7 #include <linux/usb/musb.h>
8 #include <sound/tlv320aic3x.h>
9 +#include <linux/spi/tsc2005.h>
10
11 #include <asm/mach/arch.h>
12 #include <asm/mach-types.h>
13 @@ -43,6 +44,66 @@ static int slot1_cover_open;
14 static int slot2_cover_open;
15 static struct device *mmc_device;
16
17 +#define RX51_TSC2005_RESET_GPIO 94
18 +#define RX51_TSC2005_IRQ_GPIO 106
19 +
20 +#ifdef CONFIG_TOUCHSCREEN_TSC2005
21 +static struct tsc2005_platform_data tsc2005_config;
22 +static void rx51_tsc2005_set_reset(bool enable)
23 +{
24 + gpio_set_value(RX51_TSC2005_RESET_GPIO, enable);
25 +}
26 +
27 +static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
28 + .turbo_mode = 0,
29 + .single_channel = 1,
30 +};
31 +#endif
32 +
33 +static void __init tsc2005_set_config(void)
34 +{
35 + const struct omap_lcd_config *conf;
36 +
37 + conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
38 + if (conf != NULL) {
39 +#ifdef CONFIG_TOUCHSCREEN_TSC2005
40 + if (strcmp(conf->panel_name, "lph8923") == 0) {
41 + tsc2005_config.ts_x_plate_ohm = 180;
42 + tsc2005_config.ts_pressure_max = 2048;
43 + tsc2005_config.ts_pressure_fudge = 2;
44 + tsc2005_config.ts_x_max = 4096;
45 + tsc2005_config.ts_x_fudge = 4;
46 + tsc2005_config.ts_y_max = 4096;
47 + tsc2005_config.ts_y_fudge = 7;
48 + tsc2005_config.set_reset = rx51_tsc2005_set_reset;
49 + } else if (strcmp(conf->panel_name, "ls041y3") == 0) {
50 + tsc2005_config.ts_x_plate_ohm = 280;
51 + tsc2005_config.ts_pressure_max = 2048;
52 + tsc2005_config.ts_pressure_fudge = 2;
53 + tsc2005_config.ts_x_max = 4096;
54 + tsc2005_config.ts_x_fudge = 4;
55 + tsc2005_config.ts_y_max = 4096;
56 + tsc2005_config.ts_y_fudge = 7;
57 + tsc2005_config.set_reset = rx51_tsc2005_set_reset;
58 + } else {
59 + printk(KERN_ERR "Unknown panel type, set default "
60 + "touchscreen configuration\n");
61 + tsc2005_config.ts_x_plate_ohm = 200;
62 + }
63 +#endif
64 + }
65 +}
66 +
67 +static struct omap2_mcspi_device_config mipid_mcspi_config = {
68 + .turbo_mode = 0,
69 + .single_channel = 1,
70 +};
71 +
72 +extern struct mipid_platform_data n8x0_mipid_platform_data;
73 +
74 +extern void n8x0_mipid_init(void);
75 +extern void n8x0_blizzard_init(void);
76 +
77 #define TUSB6010_ASYNC_CS 1
78 #define TUSB6010_SYNC_CS 4
79 #define TUSB6010_GPIO_INT 58
80 @@ -145,12 +206,29 @@ static struct omap2_mcspi_device_config
81
82 static struct spi_board_info n800_spi_board_info[] __initdata = {
83 {
84 + .modalias = "lcd_mipid",
85 + .bus_num = 1,
86 + .chip_select = 1,
87 + .max_speed_hz = 4000000,
88 + .controller_data= &mipid_mcspi_config,
89 + .platform_data = &n8x0_mipid_platform_data,
90 + },
91 + {
92 .modalias = "p54spi",
93 .bus_num = 2,
94 .chip_select = 0,
95 .max_speed_hz = 48000000,
96 .controller_data = &p54spi_mcspi_config,
97 },
98 + {
99 + .modalias = "tsc2005",
100 + .bus_num = 1,
101 + .chip_select = 0,
102 + .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),
103 + .max_speed_hz = 6000000,
104 + .controller_data = &tsc2005_mcspi_config,
105 + .platform_data = &tsc2005_config,
106 + },
107 };
108
109 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
110 @@ -789,6 +867,7 @@ static void __init n8x0_init_machine(voi
111 n8x0_cbus_init();
112
113 /* FIXME: add n810 spi devices */
114 + tsc2005_set_config();
115 spi_register_board_info(n800_spi_board_info,
116 ARRAY_SIZE(n800_spi_board_info));
117 omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1,
118 @@ -798,6 +877,8 @@ static void __init n8x0_init_machine(voi
119 i2c_register_board_info(2, n810_i2c_board_info_2,
120 ARRAY_SIZE(n810_i2c_board_info_2));
121 board_serial_init();
122 + n8x0_mipid_init();
123 + n8x0_blizzard_init();
124 gpmc_onenand_init(board_onenand_data);
125 n8x0_mmc_init();
126 n8x0_usb_init();
127 Index: linux-3.1/arch/arm/mach-omap2/board-n8x0-lcd.c
128 ===================================================================
129 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
130 +++ linux-3.1/arch/arm/mach-omap2/board-n8x0-lcd.c 2011-10-30 19:31:25.817235793 +0100
131 @@ -0,0 +1,229 @@
132 +/*
133 + * linux/arch/arm/mach-omap2/board-n8x0.c
134 + *
135 + * Copyright (C) 2005-2009 Nokia Corporation
136 + * Author: Juha Yrjola <juha.yrjola@nokia.com>
137 + *
138 + * Modified from mach-omap2/board-generic.c
139 + *
140 + * This program is free software; you can redistribute it and/or modify
141 + * it under the terms of the GNU General Public License version 2 as
142 + * published by the Free Software Foundation.
143 + */
144 +
145 +#include <linux/clk.h>
146 +#include <linux/delay.h>
147 +#include <linux/gpio.h>
148 +#include <linux/omapfb.h>
149 +
150 +#include <plat/lcd_mipid.h>
151 +#include <plat/blizzard.h>
152 +
153 +#include "../../../drivers/cbus/tahvo.h"
154 +
155 +
156 +struct tahvo_pwm_device {
157 + struct device *dev;
158 + int tahvo_7bit_backlight;
159 +};
160 +
161 +static struct tahvo_pwm_device *tahvo_pwm;
162 +
163 +static unsigned int tahvo_pwm_get_backlight_level(struct tahvo_pwm_device *pd)
164 +{
165 + unsigned int mask;
166 +
167 + if (pd->tahvo_7bit_backlight)
168 + mask = 0x7f;
169 + else
170 + mask = 0x0f;
171 + return tahvo_read_reg(pd->dev, TAHVO_REG_LEDPWMR) & mask;
172 +}
173 +
174 +static unsigned int tahvo_pwm_get_max_backlight_level(struct tahvo_pwm_device *pd)
175 +{
176 + if (pd->tahvo_7bit_backlight)
177 + return 0x7f;
178 + return 0x0f;
179 +}
180 +
181 +static void tahvo_pwm_set_backlight_level(struct tahvo_pwm_device *pd, unsigned int level)
182 +{
183 + unsigned int max_level;
184 +
185 + max_level = tahvo_pwm_get_max_backlight_level(pd);
186 + if (level > max_level)
187 + level = max_level;
188 + tahvo_write_reg(pd->dev, TAHVO_REG_LEDPWMR, level);
189 +}
190 +
191 +static int __init n8x0_tahvo_pwm_probe(struct platform_device *pdev)
192 +{
193 + struct tahvo_pwm_device *pd;
194 + unsigned int rev, id;
195 +
196 + pd = kzalloc(sizeof(*pd), GFP_KERNEL);
197 + if (WARN_ON(!pd))
198 + return -ENOMEM;
199 + pd->dev = &pdev->dev;
200 +
201 + rev = tahvo_read_reg(pd->dev, TAHVO_REG_ASICR);
202 + id = (rev >> 8) & 0xff;
203 + if (id == 0x03) {
204 + if ((rev & 0xff) >= 0x50)
205 + pd->tahvo_7bit_backlight = 1;
206 + } else if (id == 0x0b)
207 + pd->tahvo_7bit_backlight = 1;
208 +
209 + dev_set_drvdata(pd->dev, pd);
210 + tahvo_pwm = pd;
211 +}
212 +
213 +static struct platform_driver n8x0_tahvo_pwm_driver = {
214 + .driver = {
215 + .name = "tahvo-pwm",
216 + },
217 +};
218 +
219 +static int __init n8x0_tahvo_pwm_init(void)
220 +{
221 + return platform_driver_probe(&n8x0_tahvo_pwm_driver, n8x0_tahvo_pwm_probe);
222 +}
223 +fs_initcall(n8x0_tahvo_pwm_init);
224 +
225 +static int n8x0_get_backlight_level(struct mipid_platform_data *pdata)
226 +{
227 + return tahvo_pwm_get_backlight_level(tahvo_pwm);
228 +}
229 +
230 +static int n8x0_get_max_backlight_level(struct mipid_platform_data *pdata)
231 +{
232 + return tahvo_pwm_get_max_backlight_level(tahvo_pwm);
233 +}
234 +
235 +static void n8x0_set_backlight_level(struct mipid_platform_data *pdata, int level)
236 +{
237 + tahvo_pwm_set_backlight_level(tahvo_pwm, level);
238 +}
239 +
240 +#define N8X0_BLIZZARD_POWERDOWN_GPIO 15
241 +
242 +// MIPID LCD Panel
243 +
244 +static void mipid_shutdown(struct mipid_platform_data *pdata)
245 +{
246 + if (pdata->nreset_gpio != -1) {
247 + pr_info("shutdown LCD\n");
248 + gpio_set_value(pdata->nreset_gpio, 0);
249 + msleep(120);
250 + }
251 +}
252 +
253 +struct mipid_platform_data n8x0_mipid_platform_data = {
254 + .shutdown = mipid_shutdown,
255 + .get_bklight_level = n8x0_get_backlight_level,
256 + .set_bklight_level = n8x0_set_backlight_level,
257 + .get_bklight_max = n8x0_get_max_backlight_level,
258 +};
259 +
260 +void __init n8x0_mipid_init(void)
261 +{
262 + const struct omap_lcd_config *conf;
263 + int err;
264 +
265 + conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
266 + if (conf != NULL) {
267 + n8x0_mipid_platform_data.nreset_gpio = conf->nreset_gpio;
268 + n8x0_mipid_platform_data.data_lines = conf->data_lines;
269 + if (conf->nreset_gpio != -1) {
270 + err = gpio_request(conf->nreset_gpio, "MIPID nreset");
271 + if (err) {
272 + printk(KERN_ERR "N8x0 MIPID failed to request nreset GPIO %d\n",
273 + conf->nreset_gpio);
274 + } else {
275 + err = gpio_direction_output(conf->nreset_gpio, 1);
276 + if (err) {
277 + printk(KERN_ERR "N8x0 MIPID failed to set nreset GPIO %d\n",
278 + conf->nreset_gpio);
279 + }
280 + }
281 + }
282 + printk(KERN_INFO "N8x0 MIPID config loaded");
283 + }
284 + else
285 + printk(KERN_INFO "N8x0 MIPID config not provided");
286 +}
287 +
288 +
289 +// Epson Blizzard LCD Controller
290 +
291 +static struct {
292 + struct clk *sys_ck;
293 +} blizzard;
294 +
295 +static int blizzard_get_clocks(void)
296 +{
297 + blizzard.sys_ck = clk_get(0, "osc_ck");
298 + if (IS_ERR(blizzard.sys_ck)) {
299 + printk(KERN_ERR "can't get Blizzard clock\n");
300 + return PTR_ERR(blizzard.sys_ck);
301 + }
302 + return 0;
303 +}
304 +
305 +static unsigned long blizzard_get_clock_rate(struct device *dev)
306 +{
307 + return clk_get_rate(blizzard.sys_ck);
308 +}
309 +
310 +static void blizzard_enable_clocks(int enable)
311 +{
312 + if (enable)
313 + clk_enable(blizzard.sys_ck);
314 + else
315 + clk_disable(blizzard.sys_ck);
316 +}
317 +
318 +static void blizzard_power_up(struct device *dev)
319 +{
320 + /* Vcore to 1.475V */
321 + tahvo_set_clear_reg_bits(tahvo_pwm->dev, 0x07, 0, 0xf);
322 + msleep(10);
323 +
324 + blizzard_enable_clocks(1);
325 + gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 1);
326 +}
327 +
328 +static void blizzard_power_down(struct device *dev)
329 +{
330 + gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 0);
331 + blizzard_enable_clocks(0);
332 +
333 + /* Vcore to 1.005V */
334 + tahvo_set_clear_reg_bits(tahvo_pwm->dev, 0x07, 0xf, 0);
335 +}
336 +
337 +static struct blizzard_platform_data n8x0_blizzard_data = {
338 + .power_up = blizzard_power_up,
339 + .power_down = blizzard_power_down,
340 + .get_clock_rate = blizzard_get_clock_rate,
341 + .te_connected = 1,
342 +};
343 +
344 +void __init n8x0_blizzard_init(void)
345 +{
346 + int r;
347 +
348 + r = gpio_request(N8X0_BLIZZARD_POWERDOWN_GPIO, "Blizzard pd");
349 + if (r < 0)
350 + {
351 + printk(KERN_ERR "Can't get N8x0 Blizzard powerdown GPIO %d\n", N8X0_BLIZZARD_POWERDOWN_GPIO);
352 + return;
353 + }
354 + gpio_direction_output(N8X0_BLIZZARD_POWERDOWN_GPIO, 1);
355 +
356 + blizzard_get_clocks();
357 + omapfb_set_ctrl_platform_data(&n8x0_blizzard_data);
358 +
359 + printk(KERN_INFO "N8x0 Blizzard initialized");
360 +}
361 Index: linux-3.1/arch/arm/mach-omap2/Makefile
362 ===================================================================
363 --- linux-3.1.orig/arch/arm/mach-omap2/Makefile 2011-10-30 19:14:57.705562343 +0100
364 +++ linux-3.1/arch/arm/mach-omap2/Makefile 2011-10-30 19:31:25.817235793 +0100
365 @@ -209,6 +209,7 @@ obj-$(CONFIG_MACH_OMAP_3430SDP) += boar
366 hsmmc.o \
367 board-flash.o
368 obj-$(CONFIG_MACH_NOKIA_N8X0) += board-n8x0.o
369 +obj-$(CONFIG_MACH_NOKIA_N8X0) += board-n8x0-lcd.o
370 obj-$(CONFIG_MACH_NOKIA_RM680) += board-rm680.o \
371 sdram-nokia.o \
372 hsmmc.o
373 Index: linux-3.1/arch/arm/mach-omap2/omap_hwmod_2420_data.c
374 ===================================================================
375 --- linux-3.1.orig/arch/arm/mach-omap2/omap_hwmod_2420_data.c 2011-10-30 19:14:57.689562700 +0100
376 +++ linux-3.1/arch/arm/mach-omap2/omap_hwmod_2420_data.c 2011-10-30 19:31:25.817235793 +0100
377 @@ -1181,6 +1181,7 @@ static struct omap_hwmod_ocp_if *omap242
378
379 static struct omap_hwmod omap2420_gpio1_hwmod = {
380 .name = "gpio1",
381 + .flags = HWMOD_INIT_NO_RESET, /* Workaround: Don't reset the n810 MIPID */
382 .flags = HWMOD_CONTROL_OPT_CLKS_IN_RESET,
383 .mpu_irqs = omap2_gpio1_irqs,
384 .main_clk = "gpios_fck",