omap24xx: Add 3.1 patchset.
[openwrt.git] / target / linux / omap24xx / patches-3.1 / 310-n810-lcd.patch
1 Index: linux-3.1-rc4/arch/arm/mach-omap2/board-n8x0.c
2 ===================================================================
3 --- linux-3.1-rc4.orig/arch/arm/mach-omap2/board-n8x0.c 2011-10-29 20:49:08.122996341 +0200
4 +++ linux-3.1-rc4/arch/arm/mach-omap2/board-n8x0.c      2011-10-29 20:57:46.528713116 +0200
5 @@ -23,6 +23,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 @@ -793,6 +871,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 @@ -802,6 +881,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-rc4/arch/arm/mach-omap2/board-n8x0-lcd.c
128 ===================================================================
129 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
130 +++ linux-3.1-rc4/arch/arm/mach-omap2/board-n8x0-lcd.c  2011-10-29 20:58:54.648257704 +0200
131 @@ -0,0 +1,140 @@
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 +
154 +#define N8X0_BLIZZARD_POWERDOWN_GPIO   15
155 +
156 +// MIPID LCD Panel
157 +
158 +static void mipid_shutdown(struct mipid_platform_data *pdata)
159 +{
160 +       if (pdata->nreset_gpio != -1) {
161 +               pr_info("shutdown LCD\n");
162 +               gpio_set_value(pdata->nreset_gpio, 0);
163 +               msleep(120);
164 +       }
165 +}
166 +
167 +struct mipid_platform_data n8x0_mipid_platform_data = {
168 +       .shutdown = mipid_shutdown,
169 +};
170 +
171 +void __init n8x0_mipid_init(void)
172 +{
173 +       const struct omap_lcd_config *conf;
174 +       int err;
175 +
176 +       conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
177 +       if (conf != NULL) {
178 +               n8x0_mipid_platform_data.nreset_gpio = conf->nreset_gpio;
179 +               n8x0_mipid_platform_data.data_lines = conf->data_lines;
180 +               if (conf->nreset_gpio != -1) {
181 +                       err = gpio_request(conf->nreset_gpio, "MIPID nreset");
182 +                       if (err) {
183 +                               printk(KERN_ERR "N8x0 MIPID failed to request nreset GPIO %d\n",
184 +                                      conf->nreset_gpio);
185 +                       } else {
186 +                               err = gpio_direction_output(conf->nreset_gpio, 1);
187 +                               if (err) {
188 +                                       printk(KERN_ERR "N8x0 MIPID failed to set nreset GPIO %d\n",
189 +                                              conf->nreset_gpio);
190 +                               }
191 +                       }
192 +               }
193 +               printk(KERN_INFO "N8x0 MIPID config loaded");
194 +       }
195 +       else
196 +               printk(KERN_INFO "N8x0 MIPID config not provided");
197 +}
198 +
199 +
200 +// Epson Blizzard LCD Controller
201 +
202 +static struct {
203 +       struct clk *sys_ck;
204 +} blizzard;
205 +
206 +static int blizzard_get_clocks(void)
207 +{
208 +       blizzard.sys_ck = clk_get(0, "osc_ck");
209 +       if (IS_ERR(blizzard.sys_ck)) {
210 +               printk(KERN_ERR "can't get Blizzard clock\n");
211 +               return PTR_ERR(blizzard.sys_ck);
212 +       }
213 +       return 0;
214 +}
215 +
216 +static unsigned long blizzard_get_clock_rate(struct device *dev)
217 +{
218 +       return clk_get_rate(blizzard.sys_ck);
219 +}
220 +
221 +static void blizzard_enable_clocks(int enable)
222 +{
223 +       if (enable)
224 +               clk_enable(blizzard.sys_ck);
225 +       else
226 +               clk_disable(blizzard.sys_ck);
227 +}
228 +
229 +static void blizzard_power_up(struct device *dev)
230 +{
231 +       /* Vcore to 1.475V */
232 +//FIXME        tahvo_set_clear_reg_bits(0x07, 0, 0xf);
233 +       msleep(10);
234 +
235 +       blizzard_enable_clocks(1);
236 +       gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 1);
237 +}
238 +
239 +static void blizzard_power_down(struct device *dev)
240 +{
241 +       gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 0);
242 +       blizzard_enable_clocks(0);
243 +
244 +       /* Vcore to 1.005V */
245 +//FIXME        tahvo_set_clear_reg_bits(0x07, 0xf, 0);
246 +}
247 +
248 +static struct blizzard_platform_data n8x0_blizzard_data = {
249 +       .power_up       = blizzard_power_up,
250 +       .power_down     = blizzard_power_down,
251 +       .get_clock_rate = blizzard_get_clock_rate,
252 +       .te_connected   = 1,
253 +};
254 +
255 +void __init n8x0_blizzard_init(void)
256 +{
257 +       int r;
258 +
259 +       r = gpio_request(N8X0_BLIZZARD_POWERDOWN_GPIO, "Blizzard pd");
260 +       if (r < 0)
261 +       {
262 +               printk(KERN_ERR "Can't get N8x0 Blizzard powerdown GPIO %d\n", N8X0_BLIZZARD_POWERDOWN_GPIO);
263 +               return;
264 +       }
265 +       gpio_direction_output(N8X0_BLIZZARD_POWERDOWN_GPIO, 1);
266 +
267 +       blizzard_get_clocks();
268 +       omapfb_set_ctrl_platform_data(&n8x0_blizzard_data);
269 +
270 +       printk(KERN_INFO "N8x0 Blizzard initialized");
271 +}
272 Index: linux-3.1-rc4/arch/arm/mach-omap2/Makefile
273 ===================================================================
274 --- linux-3.1-rc4.orig/arch/arm/mach-omap2/Makefile     2011-10-29 20:47:55.923162509 +0200
275 +++ linux-3.1-rc4/arch/arm/mach-omap2/Makefile  2011-10-29 20:49:08.130996323 +0200
276 @@ -209,6 +209,7 @@ obj-$(CONFIG_MACH_OMAP_3430SDP)             += boar
277                                            hsmmc.o \
278                                            board-flash.o
279  obj-$(CONFIG_MACH_NOKIA_N8X0)          += board-n8x0.o
280 +obj-$(CONFIG_MACH_NOKIA_N8X0)          += board-n8x0-lcd.o
281  obj-$(CONFIG_MACH_NOKIA_RM680)         += board-rm680.o \
282                                            sdram-nokia.o \
283                                            hsmmc.o
284 Index: linux-3.1-rc4/arch/arm/mach-omap2/omap_hwmod_2420_data.c
285 ===================================================================
286 --- linux-3.1-rc4.orig/arch/arm/mach-omap2/omap_hwmod_2420_data.c       2011-10-29 20:47:55.903162555 +0200
287 +++ linux-3.1-rc4/arch/arm/mach-omap2/omap_hwmod_2420_data.c    2011-10-29 20:49:08.130996323 +0200
288 @@ -1181,6 +1181,7 @@ static struct omap_hwmod_ocp_if *omap242
289  
290  static struct omap_hwmod omap2420_gpio1_hwmod = {
291         .name           = "gpio1",
292 +       .flags          = HWMOD_INIT_NO_RESET, /* Workaround: Don't reset the n810 MIPID */
293         .flags          = HWMOD_CONTROL_OPT_CLKS_IN_RESET,
294         .mpu_irqs       = omap2_gpio1_irqs,
295         .main_clk       = "gpios_fck",