]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/mach-omap1/board-nokia770.c
Merge branch 'lpc32xx/core' of git://git.antcom.de/linux-2.6 into next/soc
[karo-tx-linux.git] / arch / arm / mach-omap1 / board-nokia770.c
1 /*
2  * linux/arch/arm/mach-omap1/board-nokia770.c
3  *
4  * Modified from board-generic.c
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #include <linux/gpio.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/mutex.h>
14 #include <linux/platform_device.h>
15 #include <linux/input.h>
16 #include <linux/clk.h>
17 #include <linux/omapfb.h>
18
19 #include <linux/spi/spi.h>
20 #include <linux/spi/ads7846.h>
21 #include <linux/workqueue.h>
22 #include <linux/delay.h>
23
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27
28 #include <plat/mux.h>
29 #include <plat/keypad.h>
30 #include <plat/lcd_mipid.h>
31 #include <plat/mmc.h>
32 #include <plat/clock.h>
33
34 #include <mach/hardware.h>
35 #include <mach/usb.h>
36
37 #include "common.h"
38
39 #define ADS7846_PENDOWN_GPIO    15
40
41 static const unsigned int nokia770_keymap[] = {
42         KEY(1, 0, GROUP_0 | KEY_UP),
43         KEY(2, 0, GROUP_1 | KEY_F5),
44         KEY(0, 1, GROUP_0 | KEY_LEFT),
45         KEY(1, 1, GROUP_0 | KEY_ENTER),
46         KEY(2, 1, GROUP_0 | KEY_RIGHT),
47         KEY(0, 2, GROUP_1 | KEY_ESC),
48         KEY(1, 2, GROUP_0 | KEY_DOWN),
49         KEY(2, 2, GROUP_1 | KEY_F4),
50         KEY(0, 3, GROUP_2 | KEY_F7),
51         KEY(1, 3, GROUP_2 | KEY_F8),
52         KEY(2, 3, GROUP_2 | KEY_F6),
53 };
54
55 static struct resource nokia770_kp_resources[] = {
56         [0] = {
57                 .start  = INT_KEYBOARD,
58                 .end    = INT_KEYBOARD,
59                 .flags  = IORESOURCE_IRQ,
60         },
61 };
62
63 static const struct matrix_keymap_data nokia770_keymap_data = {
64         .keymap         = nokia770_keymap,
65         .keymap_size    = ARRAY_SIZE(nokia770_keymap),
66 };
67
68 static struct omap_kp_platform_data nokia770_kp_data = {
69         .rows           = 8,
70         .cols           = 8,
71         .keymap_data    = &nokia770_keymap_data,
72         .delay          = 4,
73 };
74
75 static struct platform_device nokia770_kp_device = {
76         .name           = "omap-keypad",
77         .id             = -1,
78         .dev            = {
79                 .platform_data = &nokia770_kp_data,
80         },
81         .num_resources  = ARRAY_SIZE(nokia770_kp_resources),
82         .resource       = nokia770_kp_resources,
83 };
84
85 static struct platform_device *nokia770_devices[] __initdata = {
86         &nokia770_kp_device,
87 };
88
89 static void mipid_shutdown(struct mipid_platform_data *pdata)
90 {
91         if (pdata->nreset_gpio != -1) {
92                 printk(KERN_INFO "shutdown LCD\n");
93                 gpio_set_value(pdata->nreset_gpio, 0);
94                 msleep(120);
95         }
96 }
97
98 static struct mipid_platform_data nokia770_mipid_platform_data = {
99         .shutdown = mipid_shutdown,
100 };
101
102 static struct omap_lcd_config nokia770_lcd_config __initdata = {
103         .ctrl_name      = "hwa742",
104 };
105
106 static void __init mipid_dev_init(void)
107 {
108         nokia770_mipid_platform_data.nreset_gpio = 13;
109         nokia770_mipid_platform_data.data_lines = 16;
110
111         omapfb_set_lcd_config(&nokia770_lcd_config);
112 }
113
114 static void __init ads7846_dev_init(void)
115 {
116         if (gpio_request(ADS7846_PENDOWN_GPIO, "ADS7846 pendown") < 0)
117                 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
118 }
119
120 static int ads7846_get_pendown_state(void)
121 {
122         return !gpio_get_value(ADS7846_PENDOWN_GPIO);
123 }
124
125 static struct ads7846_platform_data nokia770_ads7846_platform_data __initdata = {
126         .x_max          = 0x0fff,
127         .y_max          = 0x0fff,
128         .x_plate_ohms   = 180,
129         .pressure_max   = 255,
130         .debounce_max   = 10,
131         .debounce_tol   = 3,
132         .debounce_rep   = 1,
133         .get_pendown_state      = ads7846_get_pendown_state,
134 };
135
136 static struct spi_board_info nokia770_spi_board_info[] __initdata = {
137         [0] = {
138                 .modalias       = "lcd_mipid",
139                 .bus_num        = 2,
140                 .chip_select    = 3,
141                 .max_speed_hz   = 12000000,
142                 .platform_data  = &nokia770_mipid_platform_data,
143         },
144         [1] = {
145                 .modalias       = "ads7846",
146                 .bus_num        = 2,
147                 .chip_select    = 0,
148                 .max_speed_hz   = 2500000,
149                 .platform_data  = &nokia770_ads7846_platform_data,
150         },
151 };
152
153 static void __init hwa742_dev_init(void)
154 {
155         clk_add_alias("hwa_sys_ck", NULL, "bclk", NULL);
156 }
157
158 /* assume no Mini-AB port */
159
160 static struct omap_usb_config nokia770_usb_config __initdata = {
161         .otg            = 1,
162         .register_host  = 1,
163         .register_dev   = 1,
164         .hmc_mode       = 16,
165         .pins[0]        = 6,
166 };
167
168 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
169
170 #define NOKIA770_GPIO_MMC_POWER         41
171 #define NOKIA770_GPIO_MMC_SWITCH        23
172
173 static int nokia770_mmc_set_power(struct device *dev, int slot, int power_on,
174                                 int vdd)
175 {
176         gpio_set_value(NOKIA770_GPIO_MMC_POWER, power_on);
177         return 0;
178 }
179
180 static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
181 {
182         return gpio_get_value(NOKIA770_GPIO_MMC_SWITCH);
183 }
184
185 static struct omap_mmc_platform_data nokia770_mmc2_data = {
186         .nr_slots                       = 1,
187         .max_freq                       = 12000000,
188         .slots[0]       = {
189                 .set_power              = nokia770_mmc_set_power,
190                 .get_cover_state        = nokia770_mmc_get_cover_state,
191                 .ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
192                 .name                   = "mmcblk",
193         },
194 };
195
196 static struct omap_mmc_platform_data *nokia770_mmc_data[OMAP16XX_NR_MMC];
197
198 static void __init nokia770_mmc_init(void)
199 {
200         int ret;
201
202         ret = gpio_request(NOKIA770_GPIO_MMC_POWER, "MMC power");
203         if (ret < 0)
204                 return;
205         gpio_direction_output(NOKIA770_GPIO_MMC_POWER, 0);
206
207         ret = gpio_request(NOKIA770_GPIO_MMC_SWITCH, "MMC cover");
208         if (ret < 0) {
209                 gpio_free(NOKIA770_GPIO_MMC_POWER);
210                 return;
211         }
212         gpio_direction_input(NOKIA770_GPIO_MMC_SWITCH);
213
214         /* Only the second MMC controller is used */
215         nokia770_mmc_data[1] = &nokia770_mmc2_data;
216         omap1_init_mmc(nokia770_mmc_data, OMAP16XX_NR_MMC);
217 }
218
219 #else
220 static inline void nokia770_mmc_init(void)
221 {
222 }
223 #endif
224
225 static void __init omap_nokia770_init(void)
226 {
227         /* On Nokia 770, the SleepX signal is masked with an
228          * MPUIO line by default.  It has to be unmasked for it
229          * to become functional */
230
231         /* SleepX mask direction */
232         omap_writew((omap_readw(0xfffb5008) & ~2), 0xfffb5008);
233         /* Unmask SleepX signal */
234         omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
235
236         platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
237         nokia770_spi_board_info[1].irq = gpio_to_irq(15);
238         spi_register_board_info(nokia770_spi_board_info,
239                                 ARRAY_SIZE(nokia770_spi_board_info));
240         omap_serial_init();
241         omap_register_i2c_bus(1, 100, NULL, 0);
242         hwa742_dev_init();
243         ads7846_dev_init();
244         mipid_dev_init();
245         omap1_usb_init(&nokia770_usb_config);
246         nokia770_mmc_init();
247 }
248
249 MACHINE_START(NOKIA770, "Nokia 770")
250         .atag_offset    = 0x100,
251         .map_io         = omap16xx_map_io,
252         .init_early     = omap1_init_early,
253         .reserve        = omap_reserve,
254         .init_irq       = omap1_init_irq,
255         .init_machine   = omap_nokia770_init,
256         .init_late      = omap1_init_late,
257         .timer          = &omap1_timer,
258         .restart        = omap1_restart,
259 MACHINE_END