blob: 7a05895c0be398520a1aec8d8beacb6830ada28c [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>
Russell King2f8163b2011-07-26 10:53:52 +010018#include <linux/gpio.h>
Marek Vasutec70e8a2006-12-06 17:13:57 -080019#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>
Ladislav Michl561b0362010-02-15 10:03:32 -080029#include <linux/mtd/physmap.h>
Tomi Valkeinenddba6c72011-09-20 15:23:13 +030030#include <linux/omapfb.h>
Tony Lindgren2e3ee9f2012-02-24 10:34:34 -080031#include <linux/spi/spi.h>
32#include <linux/spi/ads7846.h>
Igor Grinbergcc012722012-08-29 02:18:54 +030033#include <linux/platform_data/omap1_bl.h>
Marek Vasutec70e8a2006-12-06 17:13:57 -080034
Marek Vasutec70e8a2006-12-06 17:13:57 -080035#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/map.h>
Marek Vasutec70e8a2006-12-06 17:13:57 -080038
Tony Lindgren578fad42012-09-20 11:41:37 -070039#include <mach/flash.h>
Tony Lindgren70c494c2012-09-19 10:46:56 -070040#include <mach/mux.h>
Tony Lindgren45c3eb72012-11-30 08:41:50 -080041#include <linux/omap-dma.h>
Tony Lindgren54b693d2012-10-02 13:39:28 -070042#include <mach/tc.h>
Tony Lindgren2f7cd572012-09-20 11:41:59 -070043#include <mach/irda.h>
Arnd Bergmann22037472012-08-24 15:21:06 +020044#include <linux/platform_data/keypad-omap.h>
Marek Vasutec70e8a2006-12-06 17:13:57 -080045
Tony Lindgren2e3ee9f2012-02-24 10:34:34 -080046#include <mach/hardware.h>
Tony Lindgrenb924b202012-06-04 00:56:15 -070047#include <mach/usb.h>
Tony Lindgren2e3ee9f2012-02-24 10:34:34 -080048
49#include "common.h"
Lokesh Vutla8c4cc002012-10-15 14:01:01 -070050#include "dma.h"
Marek Vasutec70e8a2006-12-06 17:13:57 -080051
Tony Lindgrenb2830812009-03-23 18:07:35 -070052#define PALMZ71_USBDETECT_GPIO 0
53#define PALMZ71_PENIRQ_GPIO 6
54#define PALMZ71_MMC_WP_GPIO 8
55#define PALMZ71_HDQ_GPIO 11
56
57#define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)
58#define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)
59#define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
60#define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
61
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000062static const unsigned int palmz71_keymap[] = {
Marek Vasutec70e8a2006-12-06 17:13:57 -080063 KEY(0, 0, KEY_F1),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000064 KEY(1, 0, KEY_F2),
65 KEY(2, 0, KEY_F3),
66 KEY(3, 0, KEY_F4),
67 KEY(4, 0, KEY_POWER),
68 KEY(0, 1, KEY_LEFT),
Marek Vasutec70e8a2006-12-06 17:13:57 -080069 KEY(1, 1, KEY_DOWN),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000070 KEY(2, 1, KEY_UP),
71 KEY(3, 1, KEY_RIGHT),
72 KEY(4, 1, KEY_ENTER),
73 KEY(0, 2, KEY_CAMERA),
74};
75
76static const struct matrix_keymap_data palmz71_keymap_data = {
77 .keymap = palmz71_keymap,
78 .keymap_size = ARRAY_SIZE(palmz71_keymap),
Marek Vasutec70e8a2006-12-06 17:13:57 -080079};
80
81static struct omap_kp_platform_data palmz71_kp_data = {
82 .rows = 8,
83 .cols = 8,
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000084 .keymap_data = &palmz71_keymap_data,
85 .rep = true,
Marek Vasutec70e8a2006-12-06 17:13:57 -080086 .delay = 80,
87};
88
89static struct resource palmz71_kp_resources[] = {
90 [0] = {
91 .start = INT_KEYBOARD,
92 .end = INT_KEYBOARD,
93 .flags = IORESOURCE_IRQ,
94 },
95};
96
97static struct platform_device palmz71_kp_device = {
98 .name = "omap-keypad",
99 .id = -1,
100 .dev = {
101 .platform_data = &palmz71_kp_data,
102 },
103 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
104 .resource = palmz71_kp_resources,
105};
106
107static struct mtd_partition palmz71_rom_partitions[] = {
108 /* PalmOS "Small ROM", contains the bootloader and the debugger */
109 {
110 .name = "smallrom",
111 .offset = 0,
112 .size = 0xa000,
113 .mask_flags = MTD_WRITEABLE,
114 },
115 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
116 {
117 .name = "bigrom",
118 .offset = SZ_128K,
119 /*
120 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
121 * 0x7b0000 bytes in the English-only ("enUS") version.
122 */
123 .size = 0x7b0000,
124 .mask_flags = MTD_WRITEABLE,
125 },
126};
127
Ladislav Michl561b0362010-02-15 10:03:32 -0800128static struct physmap_flash_data palmz71_rom_data = {
Marek Vasutec70e8a2006-12-06 17:13:57 -0800129 .width = 2,
Ladislav Michl561b0362010-02-15 10:03:32 -0800130 .set_vpp = omap1_set_vpp,
Marek Vasutec70e8a2006-12-06 17:13:57 -0800131 .parts = palmz71_rom_partitions,
132 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
133};
134
135static struct resource palmz71_rom_resource = {
136 .start = OMAP_CS0_PHYS,
137 .end = OMAP_CS0_PHYS + SZ_8M - 1,
138 .flags = IORESOURCE_MEM,
139};
140
141static struct platform_device palmz71_rom_device = {
Ladislav Michl561b0362010-02-15 10:03:32 -0800142 .name = "physmap-flash",
Marek Vasutec70e8a2006-12-06 17:13:57 -0800143 .id = -1,
144 .dev = {
145 .platform_data = &palmz71_rom_data,
146 },
147 .num_resources = 1,
148 .resource = &palmz71_rom_resource,
149};
150
151static struct platform_device palmz71_lcd_device = {
152 .name = "lcd_palmz71",
153 .id = -1,
154};
155
156static struct omap_irda_config palmz71_irda_config = {
157 .transceiver_cap = IR_SIRMODE,
158 .rx_channel = OMAP_DMA_UART3_RX,
159 .tx_channel = OMAP_DMA_UART3_TX,
160 .dest_start = UART3_THR,
161 .src_start = UART3_RHR,
162 .tx_trigger = 0,
163 .rx_trigger = 0,
164};
165
166static struct resource palmz71_irda_resources[] = {
167 [0] = {
168 .start = INT_UART3,
169 .end = INT_UART3,
170 .flags = IORESOURCE_IRQ,
171 },
172};
173
174static struct platform_device palmz71_irda_device = {
175 .name = "omapirda",
176 .id = -1,
177 .dev = {
178 .platform_data = &palmz71_irda_config,
179 },
180 .num_resources = ARRAY_SIZE(palmz71_irda_resources),
181 .resource = palmz71_irda_resources,
182};
183
184static struct platform_device palmz71_spi_device = {
185 .name = "spi_palmz71",
186 .id = -1,
187};
188
Marek Vasutec70e8a2006-12-06 17:13:57 -0800189static struct omap_backlight_config palmz71_backlight_config = {
190 .default_intensity = 0xa0,
191};
192
193static struct platform_device palmz71_backlight_device = {
194 .name = "omap-bl",
195 .id = -1,
196 .dev = {
197 .platform_data = &palmz71_backlight_config,
198 },
199};
200
201static struct platform_device *devices[] __initdata = {
202 &palmz71_rom_device,
203 &palmz71_kp_device,
Marek Vasutec70e8a2006-12-06 17:13:57 -0800204 &palmz71_lcd_device,
205 &palmz71_irda_device,
206 &palmz71_spi_device,
207 &palmz71_backlight_device,
208};
209
210static int
211palmz71_get_pendown_state(void)
212{
David Brownell0b84b5c2008-12-10 17:35:25 -0800213 return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800214}
215
216static const struct ads7846_platform_data palmz71_ts_info = {
217 .model = 7846,
218 .vref_delay_usecs = 100, /* internal, no capacitor */
219 .x_plate_ohms = 419,
220 .y_plate_ohms = 486,
221 .get_pendown_state = palmz71_get_pendown_state,
222};
223
224static struct spi_board_info __initdata palmz71_boardinfo[] = { {
225 /* MicroWire (bus 2) CS0 has an ads7846e */
226 .modalias = "ads7846",
227 .platform_data = &palmz71_ts_info,
Marek Vasutec70e8a2006-12-06 17:13:57 -0800228 .max_speed_hz = 120000 /* max sample rate at 3V */
229 * 26 /* command + data + overhead */,
230 .bus_num = 2,
231 .chip_select = 0,
232} };
233
234static struct omap_usb_config palmz71_usb_config __initdata = {
235 .register_dev = 1, /* Mini-B only receptacle */
236 .hmc_mode = 0,
237 .pins[0] = 2,
238};
239
Marek Vasutec70e8a2006-12-06 17:13:57 -0800240static struct omap_lcd_config palmz71_lcd_config __initdata = {
241 .ctrl_name = "internal",
242};
243
Marek Vasutec70e8a2006-12-06 17:13:57 -0800244static irqreturn_t
245palmz71_powercable(int irq, void *dev_id)
246{
David Brownell0b84b5c2008-12-10 17:35:25 -0800247 if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
Marek Vasutec70e8a2006-12-06 17:13:57 -0800248 printk(KERN_INFO "PM: Power cable connected\n");
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100249 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
250 IRQ_TYPE_EDGE_FALLING);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800251 } else {
252 printk(KERN_INFO "PM: Power cable disconnected\n");
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100253 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
254 IRQ_TYPE_EDGE_RISING);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800255 }
256 return IRQ_HANDLED;
257}
258
259static void __init
260omap_mpu_wdt_mode(int mode)
261{
262 if (mode)
263 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
264 else {
265 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
266 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
267 }
268}
269
270static void __init
271palmz71_gpio_setup(int early)
272{
273 if (early) {
274 /* Only set GPIO1 so we have a working serial */
David Brownelle918edf2008-12-10 17:35:26 -0800275 gpio_direction_output(1, 1);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800276 } else {
277 /* Set MMC/SD host WP pin as input */
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -0800278 if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
Marek Vasutec70e8a2006-12-06 17:13:57 -0800279 printk(KERN_ERR "Could not reserve WP GPIO!\n");
280 return;
281 }
David Brownell40e39252008-12-10 17:35:26 -0800282 gpio_direction_input(PALMZ71_MMC_WP_GPIO);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800283
284 /* Monitor the Power-cable-connected signal */
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -0800285 if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
Marek Vasutec70e8a2006-12-06 17:13:57 -0800286 printk(KERN_ERR
287 "Could not reserve cable signal GPIO!\n");
288 return;
289 }
David Brownell40e39252008-12-10 17:35:26 -0800290 gpio_direction_input(PALMZ71_USBDETECT_GPIO);
David Brownell15f74b02008-12-10 17:35:26 -0800291 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
Theodore Ts'o9863fa62012-07-17 14:04:00 -0400292 palmz71_powercable, 0, "palmz71-cable", NULL))
Marek Vasutec70e8a2006-12-06 17:13:57 -0800293 printk(KERN_ERR
294 "IRQ request for power cable failed!\n");
Paul Walmsleya7022d62012-04-13 06:34:28 -0600295 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800296 }
297}
298
299static void __init
300omap_palmz71_init(void)
301{
Janusz Krzysztofikc33da3a2009-10-22 14:47:42 -0700302 /* 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
Marek Vasutec70e8a2006-12-06 17:13:57 -0800310 palmz71_gpio_setup(1);
311 omap_mpu_wdt_mode(0);
312
Marek Vasutec70e8a2006-12-06 17:13:57 -0800313 platform_add_devices(devices, ARRAY_SIZE(devices));
314
Tarun Kanti DebBarma46a0a542012-03-29 08:41:01 -0700315 palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800316 spi_register_board_info(palmz71_boardinfo,
317 ARRAY_SIZE(palmz71_boardinfo));
Tony Lindgrendd0cdd82010-07-05 16:31:30 +0300318 omap1_usb_init(&palmz71_usb_config);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800319 omap_serial_init();
Jarkko Nikula1ed16a82007-11-07 06:54:32 +0200320 omap_register_i2c_bus(1, 100, NULL, 0);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800321 palmz71_gpio_setup(0);
Tomi Valkeinenddba6c72011-09-20 15:23:13 +0300322
323 omapfb_set_lcd_config(&palmz71_lcd_config);
Marek Vasutec70e8a2006-12-06 17:13:57 -0800324}
325
Marek Vasutec70e8a2006-12-06 17:13:57 -0800326MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
Nicolas Pitre246e3892011-07-05 22:38:15 -0400327 .atag_offset = 0x100,
Tony Lindgren7b88e622011-10-05 15:14:02 -0700328 .map_io = omap15xx_map_io,
329 .init_early = omap1_init_early,
Tony Lindgren7b88e622011-10-05 15:14:02 -0700330 .init_irq = omap1_init_irq,
Russell King71ee7da2010-05-23 10:18:16 +0100331 .init_machine = omap_palmz71_init,
Shawn Guo82c3bd02012-04-26 13:49:29 +0800332 .init_late = omap1_init_late,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700333 .timer = &omap1_timer,
Russell Kingbaa95882011-11-05 17:06:28 +0000334 .restart = omap1_restart,
Marek Vasutec70e8a2006-12-06 17:13:57 -0800335MACHINE_END