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