Loading...
1/*
2 * linux/arch/arm/mach-omap1/board-palmz71.c
3 *
4 * Modified from board-generic.c
5 *
6 * Support for the Palm Zire71 PDA.
7 *
8 * Original version : Laurent Gonzalez
9 *
10 * Modified for zire71 : Marek Vasut
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/delay.h>
18#include <linux/gpio.h>
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h>
22#include <linux/notifier.h>
23#include <linux/clk.h>
24#include <linux/irq.h>
25#include <linux/input.h>
26#include <linux/interrupt.h>
27#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h>
29#include <linux/mtd/physmap.h>
30#include <linux/omapfb.h>
31#include <linux/spi/spi.h>
32#include <linux/spi/ads7846.h>
33#include <linux/platform_data/omap1_bl.h>
34
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/map.h>
38
39#include <mach/flash.h>
40#include <mach/mux.h>
41#include <linux/omap-dma.h>
42#include <mach/tc.h>
43#include <linux/platform_data/keypad-omap.h>
44
45#include <mach/hardware.h>
46#include <mach/usb.h>
47
48#include "common.h"
49
50#define PALMZ71_USBDETECT_GPIO 0
51#define PALMZ71_PENIRQ_GPIO 6
52#define PALMZ71_MMC_WP_GPIO 8
53#define PALMZ71_HDQ_GPIO 11
54
55#define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)
56#define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)
57#define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
58#define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
59
60static const unsigned int palmz71_keymap[] = {
61 KEY(0, 0, KEY_F1),
62 KEY(1, 0, KEY_F2),
63 KEY(2, 0, KEY_F3),
64 KEY(3, 0, KEY_F4),
65 KEY(4, 0, KEY_POWER),
66 KEY(0, 1, KEY_LEFT),
67 KEY(1, 1, KEY_DOWN),
68 KEY(2, 1, KEY_UP),
69 KEY(3, 1, KEY_RIGHT),
70 KEY(4, 1, KEY_ENTER),
71 KEY(0, 2, KEY_CAMERA),
72};
73
74static const struct matrix_keymap_data palmz71_keymap_data = {
75 .keymap = palmz71_keymap,
76 .keymap_size = ARRAY_SIZE(palmz71_keymap),
77};
78
79static struct omap_kp_platform_data palmz71_kp_data = {
80 .rows = 8,
81 .cols = 8,
82 .keymap_data = &palmz71_keymap_data,
83 .rep = true,
84 .delay = 80,
85};
86
87static struct resource palmz71_kp_resources[] = {
88 [0] = {
89 .start = INT_KEYBOARD,
90 .end = INT_KEYBOARD,
91 .flags = IORESOURCE_IRQ,
92 },
93};
94
95static struct platform_device palmz71_kp_device = {
96 .name = "omap-keypad",
97 .id = -1,
98 .dev = {
99 .platform_data = &palmz71_kp_data,
100 },
101 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
102 .resource = palmz71_kp_resources,
103};
104
105static struct mtd_partition palmz71_rom_partitions[] = {
106 /* PalmOS "Small ROM", contains the bootloader and the debugger */
107 {
108 .name = "smallrom",
109 .offset = 0,
110 .size = 0xa000,
111 .mask_flags = MTD_WRITEABLE,
112 },
113 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
114 {
115 .name = "bigrom",
116 .offset = SZ_128K,
117 /*
118 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
119 * 0x7b0000 bytes in the English-only ("enUS") version.
120 */
121 .size = 0x7b0000,
122 .mask_flags = MTD_WRITEABLE,
123 },
124};
125
126static struct physmap_flash_data palmz71_rom_data = {
127 .width = 2,
128 .set_vpp = omap1_set_vpp,
129 .parts = palmz71_rom_partitions,
130 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
131};
132
133static struct resource palmz71_rom_resource = {
134 .start = OMAP_CS0_PHYS,
135 .end = OMAP_CS0_PHYS + SZ_8M - 1,
136 .flags = IORESOURCE_MEM,
137};
138
139static struct platform_device palmz71_rom_device = {
140 .name = "physmap-flash",
141 .id = -1,
142 .dev = {
143 .platform_data = &palmz71_rom_data,
144 },
145 .num_resources = 1,
146 .resource = &palmz71_rom_resource,
147};
148
149static struct platform_device palmz71_lcd_device = {
150 .name = "lcd_palmz71",
151 .id = -1,
152};
153
154static struct platform_device palmz71_spi_device = {
155 .name = "spi_palmz71",
156 .id = -1,
157};
158
159static struct omap_backlight_config palmz71_backlight_config = {
160 .default_intensity = 0xa0,
161};
162
163static struct platform_device palmz71_backlight_device = {
164 .name = "omap-bl",
165 .id = -1,
166 .dev = {
167 .platform_data = &palmz71_backlight_config,
168 },
169};
170
171static struct platform_device *devices[] __initdata = {
172 &palmz71_rom_device,
173 &palmz71_kp_device,
174 &palmz71_lcd_device,
175 &palmz71_spi_device,
176 &palmz71_backlight_device,
177};
178
179static int
180palmz71_get_pendown_state(void)
181{
182 return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
183}
184
185static const struct ads7846_platform_data palmz71_ts_info = {
186 .model = 7846,
187 .vref_delay_usecs = 100, /* internal, no capacitor */
188 .x_plate_ohms = 419,
189 .y_plate_ohms = 486,
190 .get_pendown_state = palmz71_get_pendown_state,
191};
192
193static struct spi_board_info __initdata palmz71_boardinfo[] = { {
194 /* MicroWire (bus 2) CS0 has an ads7846e */
195 .modalias = "ads7846",
196 .platform_data = &palmz71_ts_info,
197 .max_speed_hz = 120000 /* max sample rate at 3V */
198 * 26 /* command + data + overhead */,
199 .bus_num = 2,
200 .chip_select = 0,
201} };
202
203static struct omap_usb_config palmz71_usb_config __initdata = {
204 .register_dev = 1, /* Mini-B only receptacle */
205 .hmc_mode = 0,
206 .pins[0] = 2,
207};
208
209static struct omap_lcd_config palmz71_lcd_config __initdata = {
210 .ctrl_name = "internal",
211};
212
213static irqreturn_t
214palmz71_powercable(int irq, void *dev_id)
215{
216 if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
217 printk(KERN_INFO "PM: Power cable connected\n");
218 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
219 IRQ_TYPE_EDGE_FALLING);
220 } else {
221 printk(KERN_INFO "PM: Power cable disconnected\n");
222 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
223 IRQ_TYPE_EDGE_RISING);
224 }
225 return IRQ_HANDLED;
226}
227
228static void __init
229omap_mpu_wdt_mode(int mode)
230{
231 if (mode)
232 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
233 else {
234 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
235 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
236 }
237}
238
239static void __init
240palmz71_gpio_setup(int early)
241{
242 if (early) {
243 /* Only set GPIO1 so we have a working serial */
244 gpio_direction_output(1, 1);
245 } else {
246 /* Set MMC/SD host WP pin as input */
247 if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
248 printk(KERN_ERR "Could not reserve WP GPIO!\n");
249 return;
250 }
251 gpio_direction_input(PALMZ71_MMC_WP_GPIO);
252
253 /* Monitor the Power-cable-connected signal */
254 if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
255 printk(KERN_ERR
256 "Could not reserve cable signal GPIO!\n");
257 return;
258 }
259 gpio_direction_input(PALMZ71_USBDETECT_GPIO);
260 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
261 palmz71_powercable, 0, "palmz71-cable", NULL))
262 printk(KERN_ERR
263 "IRQ request for power cable failed!\n");
264 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
265 }
266}
267
268static void __init
269omap_palmz71_init(void)
270{
271 /* mux pins for uarts */
272 omap_cfg_reg(UART1_TX);
273 omap_cfg_reg(UART1_RTS);
274 omap_cfg_reg(UART2_TX);
275 omap_cfg_reg(UART2_RTS);
276 omap_cfg_reg(UART3_TX);
277 omap_cfg_reg(UART3_RX);
278
279 palmz71_gpio_setup(1);
280 omap_mpu_wdt_mode(0);
281
282 platform_add_devices(devices, ARRAY_SIZE(devices));
283
284 palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
285 spi_register_board_info(palmz71_boardinfo,
286 ARRAY_SIZE(palmz71_boardinfo));
287 omap1_usb_init(&palmz71_usb_config);
288 omap_serial_init();
289 omap_register_i2c_bus(1, 100, NULL, 0);
290 palmz71_gpio_setup(0);
291
292 omapfb_set_lcd_config(&palmz71_lcd_config);
293}
294
295MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
296 .atag_offset = 0x100,
297 .map_io = omap15xx_map_io,
298 .init_early = omap1_init_early,
299 .init_irq = omap1_init_irq,
300 .init_machine = omap_palmz71_init,
301 .init_late = omap1_init_late,
302 .init_time = omap1_timer_init,
303 .restart = omap1_restart,
304MACHINE_END
1/*
2 * linux/arch/arm/mach-omap1/board-palmz71.c
3 *
4 * Modified from board-generic.c
5 *
6 * Support for the Palm Zire71 PDA.
7 *
8 * Original version : Laurent Gonzalez
9 *
10 * Modified for zire71 : Marek Vasut
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/delay.h>
18#include <linux/gpio.h>
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h>
22#include <linux/notifier.h>
23#include <linux/clk.h>
24#include <linux/irq.h>
25#include <linux/input.h>
26#include <linux/interrupt.h>
27#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h>
29#include <linux/mtd/physmap.h>
30#include <linux/omapfb.h>
31#include <linux/spi/spi.h>
32#include <linux/spi/ads7846.h>
33
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37
38#include <plat/flash.h>
39#include <plat/mux.h>
40#include <plat/usb.h>
41#include <plat/dma.h>
42#include <plat/tc.h>
43#include <plat/board.h>
44#include <plat/irda.h>
45#include <plat/keypad.h>
46
47#include <mach/hardware.h>
48
49#include "common.h"
50
51#define PALMZ71_USBDETECT_GPIO 0
52#define PALMZ71_PENIRQ_GPIO 6
53#define PALMZ71_MMC_WP_GPIO 8
54#define PALMZ71_HDQ_GPIO 11
55
56#define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)
57#define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)
58#define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
59#define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
60
61static const unsigned int palmz71_keymap[] = {
62 KEY(0, 0, KEY_F1),
63 KEY(1, 0, KEY_F2),
64 KEY(2, 0, KEY_F3),
65 KEY(3, 0, KEY_F4),
66 KEY(4, 0, KEY_POWER),
67 KEY(0, 1, KEY_LEFT),
68 KEY(1, 1, KEY_DOWN),
69 KEY(2, 1, KEY_UP),
70 KEY(3, 1, KEY_RIGHT),
71 KEY(4, 1, KEY_ENTER),
72 KEY(0, 2, KEY_CAMERA),
73};
74
75static const struct matrix_keymap_data palmz71_keymap_data = {
76 .keymap = palmz71_keymap,
77 .keymap_size = ARRAY_SIZE(palmz71_keymap),
78};
79
80static struct omap_kp_platform_data palmz71_kp_data = {
81 .rows = 8,
82 .cols = 8,
83 .keymap_data = &palmz71_keymap_data,
84 .rep = true,
85 .delay = 80,
86};
87
88static struct resource palmz71_kp_resources[] = {
89 [0] = {
90 .start = INT_KEYBOARD,
91 .end = INT_KEYBOARD,
92 .flags = IORESOURCE_IRQ,
93 },
94};
95
96static struct platform_device palmz71_kp_device = {
97 .name = "omap-keypad",
98 .id = -1,
99 .dev = {
100 .platform_data = &palmz71_kp_data,
101 },
102 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
103 .resource = palmz71_kp_resources,
104};
105
106static struct mtd_partition palmz71_rom_partitions[] = {
107 /* PalmOS "Small ROM", contains the bootloader and the debugger */
108 {
109 .name = "smallrom",
110 .offset = 0,
111 .size = 0xa000,
112 .mask_flags = MTD_WRITEABLE,
113 },
114 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
115 {
116 .name = "bigrom",
117 .offset = SZ_128K,
118 /*
119 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
120 * 0x7b0000 bytes in the English-only ("enUS") version.
121 */
122 .size = 0x7b0000,
123 .mask_flags = MTD_WRITEABLE,
124 },
125};
126
127static struct physmap_flash_data palmz71_rom_data = {
128 .width = 2,
129 .set_vpp = omap1_set_vpp,
130 .parts = palmz71_rom_partitions,
131 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
132};
133
134static struct resource palmz71_rom_resource = {
135 .start = OMAP_CS0_PHYS,
136 .end = OMAP_CS0_PHYS + SZ_8M - 1,
137 .flags = IORESOURCE_MEM,
138};
139
140static struct platform_device palmz71_rom_device = {
141 .name = "physmap-flash",
142 .id = -1,
143 .dev = {
144 .platform_data = &palmz71_rom_data,
145 },
146 .num_resources = 1,
147 .resource = &palmz71_rom_resource,
148};
149
150static struct platform_device palmz71_lcd_device = {
151 .name = "lcd_palmz71",
152 .id = -1,
153};
154
155static struct omap_irda_config palmz71_irda_config = {
156 .transceiver_cap = IR_SIRMODE,
157 .rx_channel = OMAP_DMA_UART3_RX,
158 .tx_channel = OMAP_DMA_UART3_TX,
159 .dest_start = UART3_THR,
160 .src_start = UART3_RHR,
161 .tx_trigger = 0,
162 .rx_trigger = 0,
163};
164
165static struct resource palmz71_irda_resources[] = {
166 [0] = {
167 .start = INT_UART3,
168 .end = INT_UART3,
169 .flags = IORESOURCE_IRQ,
170 },
171};
172
173static struct platform_device palmz71_irda_device = {
174 .name = "omapirda",
175 .id = -1,
176 .dev = {
177 .platform_data = &palmz71_irda_config,
178 },
179 .num_resources = ARRAY_SIZE(palmz71_irda_resources),
180 .resource = palmz71_irda_resources,
181};
182
183static struct platform_device palmz71_spi_device = {
184 .name = "spi_palmz71",
185 .id = -1,
186};
187
188static struct omap_backlight_config palmz71_backlight_config = {
189 .default_intensity = 0xa0,
190};
191
192static struct platform_device palmz71_backlight_device = {
193 .name = "omap-bl",
194 .id = -1,
195 .dev = {
196 .platform_data = &palmz71_backlight_config,
197 },
198};
199
200static struct platform_device *devices[] __initdata = {
201 &palmz71_rom_device,
202 &palmz71_kp_device,
203 &palmz71_lcd_device,
204 &palmz71_irda_device,
205 &palmz71_spi_device,
206 &palmz71_backlight_device,
207};
208
209static int
210palmz71_get_pendown_state(void)
211{
212 return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
213}
214
215static const struct ads7846_platform_data palmz71_ts_info = {
216 .model = 7846,
217 .vref_delay_usecs = 100, /* internal, no capacitor */
218 .x_plate_ohms = 419,
219 .y_plate_ohms = 486,
220 .get_pendown_state = palmz71_get_pendown_state,
221};
222
223static struct spi_board_info __initdata palmz71_boardinfo[] = { {
224 /* MicroWire (bus 2) CS0 has an ads7846e */
225 .modalias = "ads7846",
226 .platform_data = &palmz71_ts_info,
227 .max_speed_hz = 120000 /* max sample rate at 3V */
228 * 26 /* command + data + overhead */,
229 .bus_num = 2,
230 .chip_select = 0,
231} };
232
233static struct omap_usb_config palmz71_usb_config __initdata = {
234 .register_dev = 1, /* Mini-B only receptacle */
235 .hmc_mode = 0,
236 .pins[0] = 2,
237};
238
239static struct omap_lcd_config palmz71_lcd_config __initdata = {
240 .ctrl_name = "internal",
241};
242
243static irqreturn_t
244palmz71_powercable(int irq, void *dev_id)
245{
246 if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
247 printk(KERN_INFO "PM: Power cable connected\n");
248 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
249 IRQ_TYPE_EDGE_FALLING);
250 } else {
251 printk(KERN_INFO "PM: Power cable disconnected\n");
252 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
253 IRQ_TYPE_EDGE_RISING);
254 }
255 return IRQ_HANDLED;
256}
257
258static void __init
259omap_mpu_wdt_mode(int mode)
260{
261 if (mode)
262 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
263 else {
264 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
265 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
266 }
267}
268
269static void __init
270palmz71_gpio_setup(int early)
271{
272 if (early) {
273 /* Only set GPIO1 so we have a working serial */
274 gpio_direction_output(1, 1);
275 } else {
276 /* Set MMC/SD host WP pin as input */
277 if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
278 printk(KERN_ERR "Could not reserve WP GPIO!\n");
279 return;
280 }
281 gpio_direction_input(PALMZ71_MMC_WP_GPIO);
282
283 /* Monitor the Power-cable-connected signal */
284 if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
285 printk(KERN_ERR
286 "Could not reserve cable signal GPIO!\n");
287 return;
288 }
289 gpio_direction_input(PALMZ71_USBDETECT_GPIO);
290 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
291 palmz71_powercable, IRQF_SAMPLE_RANDOM,
292 "palmz71-cable", NULL))
293 printk(KERN_ERR
294 "IRQ request for power cable failed!\n");
295 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
296 }
297}
298
299static void __init
300omap_palmz71_init(void)
301{
302 /* mux pins for uarts */
303 omap_cfg_reg(UART1_TX);
304 omap_cfg_reg(UART1_RTS);
305 omap_cfg_reg(UART2_TX);
306 omap_cfg_reg(UART2_RTS);
307 omap_cfg_reg(UART3_TX);
308 omap_cfg_reg(UART3_RX);
309
310 palmz71_gpio_setup(1);
311 omap_mpu_wdt_mode(0);
312
313 platform_add_devices(devices, ARRAY_SIZE(devices));
314
315 palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
316 spi_register_board_info(palmz71_boardinfo,
317 ARRAY_SIZE(palmz71_boardinfo));
318 omap1_usb_init(&palmz71_usb_config);
319 omap_serial_init();
320 omap_register_i2c_bus(1, 100, NULL, 0);
321 palmz71_gpio_setup(0);
322
323 omapfb_set_lcd_config(&palmz71_lcd_config);
324}
325
326MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
327 .atag_offset = 0x100,
328 .map_io = omap15xx_map_io,
329 .init_early = omap1_init_early,
330 .reserve = omap_reserve,
331 .init_irq = omap1_init_irq,
332 .init_machine = omap_palmz71_init,
333 .init_late = omap1_init_late,
334 .timer = &omap1_timer,
335 .restart = omap1_restart,
336MACHINE_END