blob: 45f01d2c3a7a0c812c06d134cbd829f2277f11d6 [file] [log] [blame]
Marek Vasutec70e8a2006-12-06 17:13:57 -08001/*
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/kernel.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
21#include <linux/notifier.h>
22#include <linux/clk.h>
23#include <linux/irq.h>
24#include <linux/input.h>
25#include <linux/interrupt.h>
26#include <linux/mtd/mtd.h>
27#include <linux/mtd/partitions.h>
Ladislav Michl561b0362010-02-15 10:03:32 -080028#include <linux/mtd/physmap.h>
Marek Vasutec70e8a2006-12-06 17:13:57 -080029
Russell Kinga09e64f2008-08-05 16:14:15 +010030#include <mach/hardware.h>
Marek Vasutec70e8a2006-12-06 17:13:57 -080031#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
Marek Vasutec70e8a2006-12-06 17:13:57 -080034
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/gpio.h>
Ladislav Michl561b0362010-02-15 10:03:32 -080036#include <plat/flash.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070037#include <plat/mux.h>
38#include <plat/usb.h>
39#include <plat/dma.h>
40#include <plat/tc.h>
41#include <plat/board.h>
42#include <plat/irda.h>
43#include <plat/keypad.h>
44#include <plat/common.h>
45#include <plat/omap-alsa.h>
Marek Vasutec70e8a2006-12-06 17:13:57 -080046
Marek Vasutec70e8a2006-12-06 17:13:57 -080047#include <linux/spi/spi.h>
48#include <linux/spi/ads7846.h>
49
Tony Lindgrenb2830812009-03-23 18:07:35 -070050#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
Marek Vasutec70e8a2006-12-06 17:13:57 -080060static void __init
61omap_palmz71_init_irq(void)
62{
63 omap1_init_common_hw();
64 omap_init_irq();
Marek Vasutec70e8a2006-12-06 17:13:57 -080065}
66
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000067static const unsigned int palmz71_keymap[] = {
Marek Vasutec70e8a2006-12-06 17:13:57 -080068 KEY(0, 0, KEY_F1),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000069 KEY(1, 0, KEY_F2),
70 KEY(2, 0, KEY_F3),
71 KEY(3, 0, KEY_F4),
72 KEY(4, 0, KEY_POWER),
73 KEY(0, 1, KEY_LEFT),
Marek Vasutec70e8a2006-12-06 17:13:57 -080074 KEY(1, 1, KEY_DOWN),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000075 KEY(2, 1, KEY_UP),
76 KEY(3, 1, KEY_RIGHT),
77 KEY(4, 1, KEY_ENTER),
78 KEY(0, 2, KEY_CAMERA),
79};
80
81static const struct matrix_keymap_data palmz71_keymap_data = {
82 .keymap = palmz71_keymap,
83 .keymap_size = ARRAY_SIZE(palmz71_keymap),
Marek Vasutec70e8a2006-12-06 17:13:57 -080084};
85
86static struct omap_kp_platform_data palmz71_kp_data = {
87 .rows = 8,
88 .cols = 8,
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000089 .keymap_data = &palmz71_keymap_data,
90 .rep = true,
Marek Vasutec70e8a2006-12-06 17:13:57 -080091 .delay = 80,
92};
93
94static struct resource palmz71_kp_resources[] = {
95 [0] = {
96 .start = INT_KEYBOARD,
97 .end = INT_KEYBOARD,
98 .flags = IORESOURCE_IRQ,
99 },
100};
101
102static struct platform_device palmz71_kp_device = {
103 .name = "omap-keypad",
104 .id = -1,
105 .dev = {
106 .platform_data = &palmz71_kp_data,
107 },
108 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
109 .resource = palmz71_kp_resources,
110};
111
112static struct mtd_partition palmz71_rom_partitions[] = {
113 /* PalmOS "Small ROM", contains the bootloader and the debugger */
114 {
115 .name = "smallrom",
116 .offset = 0,
117 .size = 0xa000,
118 .mask_flags = MTD_WRITEABLE,
119 },
120 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
121 {
122 .name = "bigrom",
123 .offset = SZ_128K,
124 /*
125 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
126 * 0x7b0000 bytes in the English-only ("enUS") version.
127 */
128 .size = 0x7b0000,
129 .mask_flags = MTD_WRITEABLE,
130 },
131};
132
Ladislav Michl561b0362010-02-15 10:03:32 -0800133static struct physmap_flash_data palmz71_rom_data = {
Marek Vasutec70e8a2006-12-06 17:13:57 -0800134 .width = 2,
Ladislav Michl561b0362010-02-15 10:03:32 -0800135 .set_vpp = omap1_set_vpp,
Marek Vasutec70e8a2006-12-06 17:13:57 -0800136 .parts = palmz71_rom_partitions,
137 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
138};
139
140static struct resource palmz71_rom_resource = {
141 .start = OMAP_CS0_PHYS,
142 .end = OMAP_CS0_PHYS + SZ_8M - 1,
143 .flags = IORESOURCE_MEM,
144};
145
146static struct platform_device palmz71_rom_device = {
Ladislav Michl561b0362010-02-15 10:03:32 -0800147 .name = "physmap-flash",
Marek Vasutec70e8a2006-12-06 17:13:57 -0800148 .id = -1,
149 .dev = {
150 .platform_data = &palmz71_rom_data,
151 },
152 .num_resources = 1,
153 .resource = &palmz71_rom_resource,
154};
155
156static struct platform_device palmz71_lcd_device = {
157 .name = "lcd_palmz71",
158 .id = -1,
159};
160
161static struct omap_irda_config palmz71_irda_config = {
162 .transceiver_cap = IR_SIRMODE,
163 .rx_channel = OMAP_DMA_UART3_RX,
164 .tx_channel = OMAP_DMA_UART3_TX,
165 .dest_start = UART3_THR,
166 .src_start = UART3_RHR,
167 .tx_trigger = 0,
168 .rx_trigger = 0,
169};
170
171static struct resource palmz71_irda_resources[] = {
172 [0] = {
173 .start = INT_UART3,
174 .end = INT_UART3,
175 .flags = IORESOURCE_IRQ,
176 },
177};
178
179static struct platform_device palmz71_irda_device = {
180 .name = "omapirda",
181 .id = -1,
182 .dev = {
183 .platform_data = &palmz71_irda_config,
184 },
185 .num_resources = ARRAY_SIZE(palmz71_irda_resources),
186 .resource = palmz71_irda_resources,
187};
188
189static struct platform_device palmz71_spi_device = {
190 .name = "spi_palmz71",
191 .id = -1,
192};
193
Marek Vasutec70e8a2006-12-06 17:13:57 -0800194static struct omap_backlight_config palmz71_backlight_config = {
195 .default_intensity = 0xa0,
196};
197
198static struct platform_device palmz71_backlight_device = {
199 .name = "omap-bl",
200 .id = -1,
201 .dev = {
202 .platform_data = &palmz71_backlight_config,
203 },
204};
205
206static struct platform_device *devices[] __initdata = {
207 &palmz71_rom_device,
208 &palmz71_kp_device,
Marek Vasutec70e8a2006-12-06 17:13:57 -0800209 &palmz71_lcd_device,
210 &palmz71_irda_device,
211 &palmz71_spi_device,
212 &palmz71_backlight_device,
213};
214
215static int
216palmz71_get_pendown_state(void)
217{
David Brownell0b84b5c2008-12-10 17:35:25 -0800218 return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800219}
220
221static const struct ads7846_platform_data palmz71_ts_info = {
222 .model = 7846,
223 .vref_delay_usecs = 100, /* internal, no capacitor */
224 .x_plate_ohms = 419,
225 .y_plate_ohms = 486,
226 .get_pendown_state = palmz71_get_pendown_state,
227};
228
229static struct spi_board_info __initdata palmz71_boardinfo[] = { {
230 /* MicroWire (bus 2) CS0 has an ads7846e */
231 .modalias = "ads7846",
232 .platform_data = &palmz71_ts_info,
233 .irq = OMAP_GPIO_IRQ(PALMZ71_PENIRQ_GPIO),
234 .max_speed_hz = 120000 /* max sample rate at 3V */
235 * 26 /* command + data + overhead */,
236 .bus_num = 2,
237 .chip_select = 0,
238} };
239
240static struct omap_usb_config palmz71_usb_config __initdata = {
241 .register_dev = 1, /* Mini-B only receptacle */
242 .hmc_mode = 0,
243 .pins[0] = 2,
244};
245
Marek Vasutec70e8a2006-12-06 17:13:57 -0800246static struct omap_lcd_config palmz71_lcd_config __initdata = {
247 .ctrl_name = "internal",
248};
249
Tony Lindgrene27a93a2007-12-18 20:58:32 -0800250static struct omap_board_config_kernel palmz71_config[] __initdata = {
Marek Vasutec70e8a2006-12-06 17:13:57 -0800251 {OMAP_TAG_LCD, &palmz71_lcd_config},
Marek Vasutec70e8a2006-12-06 17:13:57 -0800252};
253
254static irqreturn_t
255palmz71_powercable(int irq, void *dev_id)
256{
David Brownell0b84b5c2008-12-10 17:35:25 -0800257 if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
Marek Vasutec70e8a2006-12-06 17:13:57 -0800258 printk(KERN_INFO "PM: Power cable connected\n");
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100259 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
260 IRQ_TYPE_EDGE_FALLING);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800261 } else {
262 printk(KERN_INFO "PM: Power cable disconnected\n");
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100263 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
264 IRQ_TYPE_EDGE_RISING);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800265 }
266 return IRQ_HANDLED;
267}
268
269static void __init
270omap_mpu_wdt_mode(int mode)
271{
272 if (mode)
273 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
274 else {
275 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
276 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
277 }
278}
279
280static void __init
281palmz71_gpio_setup(int early)
282{
283 if (early) {
284 /* Only set GPIO1 so we have a working serial */
David Brownelle918edf2008-12-10 17:35:26 -0800285 gpio_direction_output(1, 1);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800286 } else {
287 /* Set MMC/SD host WP pin as input */
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -0800288 if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
Marek Vasutec70e8a2006-12-06 17:13:57 -0800289 printk(KERN_ERR "Could not reserve WP GPIO!\n");
290 return;
291 }
David Brownell40e39252008-12-10 17:35:26 -0800292 gpio_direction_input(PALMZ71_MMC_WP_GPIO);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800293
294 /* Monitor the Power-cable-connected signal */
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -0800295 if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
Marek Vasutec70e8a2006-12-06 17:13:57 -0800296 printk(KERN_ERR
297 "Could not reserve cable signal GPIO!\n");
298 return;
299 }
David Brownell40e39252008-12-10 17:35:26 -0800300 gpio_direction_input(PALMZ71_USBDETECT_GPIO);
David Brownell15f74b02008-12-10 17:35:26 -0800301 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
Marek Vasutec70e8a2006-12-06 17:13:57 -0800302 palmz71_powercable, IRQF_SAMPLE_RANDOM,
303 "palmz71-cable", 0))
304 printk(KERN_ERR
305 "IRQ request for power cable failed!\n");
David Brownell15f74b02008-12-10 17:35:26 -0800306 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), 0);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800307 }
308}
309
310static void __init
311omap_palmz71_init(void)
312{
Janusz Krzysztofikc33da3a2009-10-22 14:47:42 -0700313 /* mux pins for uarts */
314 omap_cfg_reg(UART1_TX);
315 omap_cfg_reg(UART1_RTS);
316 omap_cfg_reg(UART2_TX);
317 omap_cfg_reg(UART2_RTS);
318 omap_cfg_reg(UART3_TX);
319 omap_cfg_reg(UART3_RX);
320
Marek Vasutec70e8a2006-12-06 17:13:57 -0800321 palmz71_gpio_setup(1);
322 omap_mpu_wdt_mode(0);
323
324 omap_board_config = palmz71_config;
325 omap_board_config_size = ARRAY_SIZE(palmz71_config);
326
327 platform_add_devices(devices, ARRAY_SIZE(devices));
328
329 spi_register_board_info(palmz71_boardinfo,
330 ARRAY_SIZE(palmz71_boardinfo));
Tony Lindgrendd0cdd82010-07-05 16:31:30 +0300331 omap1_usb_init(&palmz71_usb_config);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800332 omap_serial_init();
Jarkko Nikula1ed16a82007-11-07 06:54:32 +0200333 omap_register_i2c_bus(1, 100, NULL, 0);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800334 palmz71_gpio_setup(0);
335}
336
337static void __init
338omap_palmz71_map_io(void)
339{
340 omap1_map_common_io();
341}
342
343MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
Russell King71ee7da2010-05-23 10:18:16 +0100344 .boot_params = 0x10000100,
345 .map_io = omap_palmz71_map_io,
346 .reserve = omap_reserve,
347 .init_irq = omap_palmz71_init_irq,
348 .init_machine = omap_palmz71_init,
349 .timer = &omap_timer,
Marek Vasutec70e8a2006-12-06 17:13:57 -0800350MACHINE_END