]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/arm/mach-omap1/board-palmz71.c
ARM: OMAP: PalmZ71 support
[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
29#include <asm/hardware.h>
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
35#include <asm/arch/mcbsp.h>
36#include <asm/arch/gpio.h>
37#include <asm/arch/mux.h>
38#include <asm/arch/usb.h>
39#include <asm/arch/dma.h>
40#include <asm/arch/tc.h>
41#include <asm/arch/board.h>
42#include <asm/arch/irda.h>
43#include <asm/arch/keypad.h>
44#include <asm/arch/common.h>
45#include <asm/arch/omap-alsa.h>
46
47#include <linux/input.h>
48#include <linux/spi/spi.h>
49#include <linux/spi/ads7846.h>
50
51static void __init
52omap_palmz71_init_irq(void)
53{
54 omap1_init_common_hw();
55 omap_init_irq();
56 omap_gpio_init();
57}
58
59static int palmz71_keymap[] = {
60 KEY(0, 0, KEY_F1),
61 KEY(0, 1, KEY_F2),
62 KEY(0, 2, KEY_F3),
63 KEY(0, 3, KEY_F4),
64 KEY(0, 4, KEY_POWER),
65 KEY(1, 0, KEY_LEFT),
66 KEY(1, 1, KEY_DOWN),
67 KEY(1, 2, KEY_UP),
68 KEY(1, 3, KEY_RIGHT),
69 KEY(1, 4, KEY_CENTER),
70 KEY(2, 0, KEY_CAMERA),
71 0,
72};
73
74static struct omap_kp_platform_data palmz71_kp_data = {
75 .rows = 8,
76 .cols = 8,
77 .keymap = palmz71_keymap,
78 .rep = 1,
79 .delay = 80,
80};
81
82static struct resource palmz71_kp_resources[] = {
83 [0] = {
84 .start = INT_KEYBOARD,
85 .end = INT_KEYBOARD,
86 .flags = IORESOURCE_IRQ,
87 },
88};
89
90static struct platform_device palmz71_kp_device = {
91 .name = "omap-keypad",
92 .id = -1,
93 .dev = {
94 .platform_data = &palmz71_kp_data,
95 },
96 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
97 .resource = palmz71_kp_resources,
98};
99
100static struct mtd_partition palmz71_rom_partitions[] = {
101 /* PalmOS "Small ROM", contains the bootloader and the debugger */
102 {
103 .name = "smallrom",
104 .offset = 0,
105 .size = 0xa000,
106 .mask_flags = MTD_WRITEABLE,
107 },
108 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
109 {
110 .name = "bigrom",
111 .offset = SZ_128K,
112 /*
113 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
114 * 0x7b0000 bytes in the English-only ("enUS") version.
115 */
116 .size = 0x7b0000,
117 .mask_flags = MTD_WRITEABLE,
118 },
119};
120
121static struct flash_platform_data palmz71_rom_data = {
122 .map_name = "map_rom",
123 .name = "onboardrom",
124 .width = 2,
125 .parts = palmz71_rom_partitions,
126 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
127};
128
129static struct resource palmz71_rom_resource = {
130 .start = OMAP_CS0_PHYS,
131 .end = OMAP_CS0_PHYS + SZ_8M - 1,
132 .flags = IORESOURCE_MEM,
133};
134
135static struct platform_device palmz71_rom_device = {
136 .name = "omapflash",
137 .id = -1,
138 .dev = {
139 .platform_data = &palmz71_rom_data,
140 },
141 .num_resources = 1,
142 .resource = &palmz71_rom_resource,
143};
144
145static struct platform_device palmz71_lcd_device = {
146 .name = "lcd_palmz71",
147 .id = -1,
148};
149
150static struct omap_irda_config palmz71_irda_config = {
151 .transceiver_cap = IR_SIRMODE,
152 .rx_channel = OMAP_DMA_UART3_RX,
153 .tx_channel = OMAP_DMA_UART3_TX,
154 .dest_start = UART3_THR,
155 .src_start = UART3_RHR,
156 .tx_trigger = 0,
157 .rx_trigger = 0,
158};
159
160static struct resource palmz71_irda_resources[] = {
161 [0] = {
162 .start = INT_UART3,
163 .end = INT_UART3,
164 .flags = IORESOURCE_IRQ,
165 },
166};
167
168static struct platform_device palmz71_irda_device = {
169 .name = "omapirda",
170 .id = -1,
171 .dev = {
172 .platform_data = &palmz71_irda_config,
173 },
174 .num_resources = ARRAY_SIZE(palmz71_irda_resources),
175 .resource = palmz71_irda_resources,
176};
177
178static struct platform_device palmz71_spi_device = {
179 .name = "spi_palmz71",
180 .id = -1,
181};
182
183#define DEFAULT_BITPERSAMPLE 16
184
185static struct omap_mcbsp_reg_cfg mcbsp_regs = {
186 .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
187 .spcr1 = RINTM(3) | RRST,
188 .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
189 RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
190 .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
191 .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
192 XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
193 .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
194 .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
195 .srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
196 .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
197};
198
199static struct omap_alsa_codec_config alsa_config = {
200 .name = "PalmZ71 AIC23",
201 .mcbsp_regs_alsa = &mcbsp_regs,
202 .codec_configure_dev = NULL, /* aic23_configure */
203 .codec_set_samplerate = NULL, /* aic23_set_samplerate */
204 .codec_clock_setup = NULL, /* aic23_clock_setup */
205 .codec_clock_on = NULL, /* aic23_clock_on */
206 .codec_clock_off = NULL, /* aic23_clock_off */
207 .get_default_samplerate = NULL, /* aic23_get_default_samplerate */
208};
209
210static struct platform_device palmz71_mcbsp1_device = {
211 .name = "omap_alsa_mcbsp",
212 .id = 1,
213 .dev = {
214 .platform_data = &alsa_config,
215 },
216};
217
218static struct omap_backlight_config palmz71_backlight_config = {
219 .default_intensity = 0xa0,
220};
221
222static struct platform_device palmz71_backlight_device = {
223 .name = "omap-bl",
224 .id = -1,
225 .dev = {
226 .platform_data = &palmz71_backlight_config,
227 },
228};
229
230static struct platform_device *devices[] __initdata = {
231 &palmz71_rom_device,
232 &palmz71_kp_device,
233 &palmz71_mcbsp1_device,
234 &palmz71_lcd_device,
235 &palmz71_irda_device,
236 &palmz71_spi_device,
237 &palmz71_backlight_device,
238};
239
240static int
241palmz71_get_pendown_state(void)
242{
243 return !omap_get_gpio_datain(PALMZ71_PENIRQ_GPIO);
244}
245
246static const struct ads7846_platform_data palmz71_ts_info = {
247 .model = 7846,
248 .vref_delay_usecs = 100, /* internal, no capacitor */
249 .x_plate_ohms = 419,
250 .y_plate_ohms = 486,
251 .get_pendown_state = palmz71_get_pendown_state,
252};
253
254static struct spi_board_info __initdata palmz71_boardinfo[] = { {
255 /* MicroWire (bus 2) CS0 has an ads7846e */
256 .modalias = "ads7846",
257 .platform_data = &palmz71_ts_info,
258 .irq = OMAP_GPIO_IRQ(PALMZ71_PENIRQ_GPIO),
259 .max_speed_hz = 120000 /* max sample rate at 3V */
260 * 26 /* command + data + overhead */,
261 .bus_num = 2,
262 .chip_select = 0,
263} };
264
265static struct omap_usb_config palmz71_usb_config __initdata = {
266 .register_dev = 1, /* Mini-B only receptacle */
267 .hmc_mode = 0,
268 .pins[0] = 2,
269};
270
271static struct omap_mmc_config palmz71_mmc_config __initdata = {
272 .mmc[0] = {
273 .enabled = 1,
274 .wire4 = 0,
275 .wp_pin = PALMZ71_MMC_WP_GPIO,
276 .power_pin = -1,
277 .switch_pin = PALMZ71_MMC_IN_GPIO,
278 },
279};
280
281static struct omap_lcd_config palmz71_lcd_config __initdata = {
282 .ctrl_name = "internal",
283};
284
285static struct omap_uart_config palmz71_uart_config __initdata = {
286 .enabled_uarts = (1 << 0) | (1 << 1) | (0 << 2),
287};
288
289static struct omap_board_config_kernel palmz71_config[] = {
290 {OMAP_TAG_USB, &palmz71_usb_config},
291 {OMAP_TAG_MMC, &palmz71_mmc_config},
292 {OMAP_TAG_LCD, &palmz71_lcd_config},
293 {OMAP_TAG_UART, &palmz71_uart_config},
294};
295
296static irqreturn_t
297palmz71_powercable(int irq, void *dev_id)
298{
299 if (omap_get_gpio_datain(PALMZ71_USBDETECT_GPIO)) {
300 printk(KERN_INFO "PM: Power cable connected\n");
301 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
302 IRQT_FALLING);
303 } else {
304 printk(KERN_INFO "PM: Power cable disconnected\n");
305 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
306 IRQT_RISING);
307 }
308 return IRQ_HANDLED;
309}
310
311static void __init
312omap_mpu_wdt_mode(int mode)
313{
314 if (mode)
315 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
316 else {
317 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
318 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
319 }
320}
321
322static void __init
323palmz71_gpio_setup(int early)
324{
325 if (early) {
326 /* Only set GPIO1 so we have a working serial */
327 omap_set_gpio_dataout(1, 1);
328 omap_set_gpio_direction(1, 0);
329 } else {
330 /* Set MMC/SD host WP pin as input */
331 if (omap_request_gpio(PALMZ71_MMC_WP_GPIO)) {
332 printk(KERN_ERR "Could not reserve WP GPIO!\n");
333 return;
334 }
335 omap_set_gpio_direction(PALMZ71_MMC_WP_GPIO, 1);
336
337 /* Monitor the Power-cable-connected signal */
338 if (omap_request_gpio(PALMZ71_USBDETECT_GPIO)) {
339 printk(KERN_ERR
340 "Could not reserve cable signal GPIO!\n");
341 return;
342 }
343 omap_set_gpio_direction(PALMZ71_USBDETECT_GPIO, 1);
344 if (request_irq(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
345 palmz71_powercable, IRQF_SAMPLE_RANDOM,
346 "palmz71-cable", 0))
347 printk(KERN_ERR
348 "IRQ request for power cable failed!\n");
349 palmz71_powercable(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO), 0);
350 }
351}
352
353static void __init
354omap_palmz71_init(void)
355{
356 palmz71_gpio_setup(1);
357 omap_mpu_wdt_mode(0);
358
359 omap_board_config = palmz71_config;
360 omap_board_config_size = ARRAY_SIZE(palmz71_config);
361
362 platform_add_devices(devices, ARRAY_SIZE(devices));
363
364 spi_register_board_info(palmz71_boardinfo,
365 ARRAY_SIZE(palmz71_boardinfo));
366 omap_serial_init();
367 palmz71_gpio_setup(0);
368}
369
370static void __init
371omap_palmz71_map_io(void)
372{
373 omap1_map_common_io();
374}
375
376MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
377 .phys_io = 0xfff00000,
378 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
379 .boot_params = 0x10000100,.map_io = omap_palmz71_map_io,
380 .init_irq = omap_palmz71_init_irq,
381 .init_machine = omap_palmz71_init,
382 .timer = &omap_timer,
383MACHINE_END