1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/delay.h>
15#include <linux/gpio.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/platform_device.h>
19#include <linux/notifier.h>
20#include <linux/clk.h>
21#include <linux/irq.h>
22#include <linux/input.h>
23#include <linux/interrupt.h>
24#include <linux/mtd/mtd.h>
25#include <linux/mtd/partitions.h>
26#include <linux/mtd/physmap.h>
27#include <linux/omapfb.h>
28#include <linux/spi/spi.h>
29#include <linux/spi/ads7846.h>
30#include <linux/platform_data/omap1_bl.h>
31
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35
36#include "flash.h"
37#include <mach/mux.h>
38#include <linux/omap-dma.h>
39#include <mach/tc.h>
40#include <linux/platform_data/keypad-omap.h>
41
42#include <mach/hardware.h>
43#include <mach/usb.h>
44
45#include "common.h"
46
47#define PALMZ71_USBDETECT_GPIO 0
48#define PALMZ71_PENIRQ_GPIO 6
49#define PALMZ71_MMC_WP_GPIO 8
50#define PALMZ71_HDQ_GPIO 11
51
52#define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)
53#define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)
54#define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
55#define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
56
57static const unsigned int palmz71_keymap[] = {
58 KEY(0, 0, KEY_F1),
59 KEY(1, 0, KEY_F2),
60 KEY(2, 0, KEY_F3),
61 KEY(3, 0, KEY_F4),
62 KEY(4, 0, KEY_POWER),
63 KEY(0, 1, KEY_LEFT),
64 KEY(1, 1, KEY_DOWN),
65 KEY(2, 1, KEY_UP),
66 KEY(3, 1, KEY_RIGHT),
67 KEY(4, 1, KEY_ENTER),
68 KEY(0, 2, KEY_CAMERA),
69};
70
71static const struct matrix_keymap_data palmz71_keymap_data = {
72 .keymap = palmz71_keymap,
73 .keymap_size = ARRAY_SIZE(palmz71_keymap),
74};
75
76static struct omap_kp_platform_data palmz71_kp_data = {
77 .rows = 8,
78 .cols = 8,
79 .keymap_data = &palmz71_keymap_data,
80 .rep = true,
81 .delay = 80,
82};
83
84static struct resource palmz71_kp_resources[] = {
85 [0] = {
86 .start = INT_KEYBOARD,
87 .end = INT_KEYBOARD,
88 .flags = IORESOURCE_IRQ,
89 },
90};
91
92static struct platform_device palmz71_kp_device = {
93 .name = "omap-keypad",
94 .id = -1,
95 .dev = {
96 .platform_data = &palmz71_kp_data,
97 },
98 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
99 .resource = palmz71_kp_resources,
100};
101
102static struct mtd_partition palmz71_rom_partitions[] = {
103
104 {
105 .name = "smallrom",
106 .offset = 0,
107 .size = 0xa000,
108 .mask_flags = MTD_WRITEABLE,
109 },
110
111 {
112 .name = "bigrom",
113 .offset = SZ_128K,
114
115
116
117
118 .size = 0x7b0000,
119 .mask_flags = MTD_WRITEABLE,
120 },
121};
122
123static struct physmap_flash_data palmz71_rom_data = {
124 .width = 2,
125 .set_vpp = omap1_set_vpp,
126 .parts = palmz71_rom_partitions,
127 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
128};
129
130static struct resource palmz71_rom_resource = {
131 .start = OMAP_CS0_PHYS,
132 .end = OMAP_CS0_PHYS + SZ_8M - 1,
133 .flags = IORESOURCE_MEM,
134};
135
136static struct platform_device palmz71_rom_device = {
137 .name = "physmap-flash",
138 .id = -1,
139 .dev = {
140 .platform_data = &palmz71_rom_data,
141 },
142 .num_resources = 1,
143 .resource = &palmz71_rom_resource,
144};
145
146static struct platform_device palmz71_lcd_device = {
147 .name = "lcd_palmz71",
148 .id = -1,
149};
150
151static struct platform_device palmz71_spi_device = {
152 .name = "spi_palmz71",
153 .id = -1,
154};
155
156static struct omap_backlight_config palmz71_backlight_config = {
157 .default_intensity = 0xa0,
158};
159
160static struct platform_device palmz71_backlight_device = {
161 .name = "omap-bl",
162 .id = -1,
163 .dev = {
164 .platform_data = &palmz71_backlight_config,
165 },
166};
167
168static struct platform_device *devices[] __initdata = {
169 &palmz71_rom_device,
170 &palmz71_kp_device,
171 &palmz71_lcd_device,
172 &palmz71_spi_device,
173 &palmz71_backlight_device,
174};
175
176static int
177palmz71_get_pendown_state(void)
178{
179 return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
180}
181
182static const struct ads7846_platform_data palmz71_ts_info = {
183 .model = 7846,
184 .vref_delay_usecs = 100,
185 .x_plate_ohms = 419,
186 .y_plate_ohms = 486,
187 .get_pendown_state = palmz71_get_pendown_state,
188};
189
190static struct spi_board_info __initdata palmz71_boardinfo[] = { {
191
192 .modalias = "ads7846",
193 .platform_data = &palmz71_ts_info,
194 .max_speed_hz = 120000
195 * 26 ,
196 .bus_num = 2,
197 .chip_select = 0,
198} };
199
200static struct omap_usb_config palmz71_usb_config __initdata = {
201 .register_dev = 1,
202 .hmc_mode = 0,
203 .pins[0] = 2,
204};
205
206static const struct omap_lcd_config palmz71_lcd_config __initconst = {
207 .ctrl_name = "internal",
208};
209
210static irqreturn_t
211palmz71_powercable(int irq, void *dev_id)
212{
213 if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
214 printk(KERN_INFO "PM: Power cable connected\n");
215 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
216 IRQ_TYPE_EDGE_FALLING);
217 } else {
218 printk(KERN_INFO "PM: Power cable disconnected\n");
219 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
220 IRQ_TYPE_EDGE_RISING);
221 }
222 return IRQ_HANDLED;
223}
224
225static void __init
226omap_mpu_wdt_mode(int mode)
227{
228 if (mode)
229 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
230 else {
231 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
232 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
233 }
234}
235
236static void __init
237palmz71_gpio_setup(int early)
238{
239 if (early) {
240
241 gpio_direction_output(1, 1);
242 } else {
243
244 if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
245 printk(KERN_ERR "Could not reserve WP GPIO!\n");
246 return;
247 }
248 gpio_direction_input(PALMZ71_MMC_WP_GPIO);
249
250
251 if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
252 printk(KERN_ERR
253 "Could not reserve cable signal GPIO!\n");
254 return;
255 }
256 gpio_direction_input(PALMZ71_USBDETECT_GPIO);
257 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
258 palmz71_powercable, 0, "palmz71-cable", NULL))
259 printk(KERN_ERR
260 "IRQ request for power cable failed!\n");
261 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
262 }
263}
264
265static void __init
266omap_palmz71_init(void)
267{
268
269 omap_cfg_reg(UART1_TX);
270 omap_cfg_reg(UART1_RTS);
271 omap_cfg_reg(UART2_TX);
272 omap_cfg_reg(UART2_RTS);
273 omap_cfg_reg(UART3_TX);
274 omap_cfg_reg(UART3_RX);
275
276 palmz71_gpio_setup(1);
277 omap_mpu_wdt_mode(0);
278
279 platform_add_devices(devices, ARRAY_SIZE(devices));
280
281 palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
282 spi_register_board_info(palmz71_boardinfo,
283 ARRAY_SIZE(palmz71_boardinfo));
284 omap1_usb_init(&palmz71_usb_config);
285 omap_serial_init();
286 omap_register_i2c_bus(1, 100, NULL, 0);
287 palmz71_gpio_setup(0);
288
289 omapfb_set_lcd_config(&palmz71_lcd_config);
290}
291
292MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
293 .atag_offset = 0x100,
294 .map_io = omap15xx_map_io,
295 .init_early = omap1_init_early,
296 .init_irq = omap1_init_irq,
297 .handle_irq = omap1_handle_irq,
298 .init_machine = omap_palmz71_init,
299 .init_late = omap1_init_late,
300 .init_time = omap1_timer_init,
301 .restart = omap1_restart,
302MACHINE_END
303