1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-omap1/board-palmz71.c
5 * Modified from board-generic.c
7 * Support for the Palm Zire71 PDA.
9 * Original version : Laurent Gonzalez
11 * Modified for zire71 : Marek Vasut
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 #include <linux/platform_data/keypad-omap.h>
32 #include <linux/omap-dma.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
45 #define PALMZ71_USBDETECT_GPIO 0
46 #define PALMZ71_PENIRQ_GPIO 6
47 #define PALMZ71_MMC_WP_GPIO 8
48 #define PALMZ71_HDQ_GPIO 11
50 #define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)
51 #define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)
52 #define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
53 #define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
55 static const unsigned int palmz71_keymap[] = {
66 KEY(0, 2, KEY_CAMERA),
69 static const struct matrix_keymap_data palmz71_keymap_data = {
70 .keymap = palmz71_keymap,
71 .keymap_size = ARRAY_SIZE(palmz71_keymap),
74 static struct omap_kp_platform_data palmz71_kp_data = {
77 .keymap_data = &palmz71_keymap_data,
82 static struct resource palmz71_kp_resources[] = {
84 .start = INT_KEYBOARD,
86 .flags = IORESOURCE_IRQ,
90 static struct platform_device palmz71_kp_device = {
91 .name = "omap-keypad",
94 .platform_data = &palmz71_kp_data,
96 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
97 .resource = palmz71_kp_resources,
100 static struct mtd_partition palmz71_rom_partitions[] = {
101 /* PalmOS "Small ROM", contains the bootloader and the debugger */
106 .mask_flags = MTD_WRITEABLE,
108 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
113 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
114 * 0x7b0000 bytes in the English-only ("enUS") version.
117 .mask_flags = MTD_WRITEABLE,
121 static struct physmap_flash_data palmz71_rom_data = {
123 .set_vpp = omap1_set_vpp,
124 .parts = palmz71_rom_partitions,
125 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
128 static struct resource palmz71_rom_resource = {
129 .start = OMAP_CS0_PHYS,
130 .end = OMAP_CS0_PHYS + SZ_8M - 1,
131 .flags = IORESOURCE_MEM,
134 static struct platform_device palmz71_rom_device = {
135 .name = "physmap-flash",
138 .platform_data = &palmz71_rom_data,
141 .resource = &palmz71_rom_resource,
144 static struct platform_device palmz71_lcd_device = {
145 .name = "lcd_palmz71",
149 static struct platform_device palmz71_spi_device = {
150 .name = "spi_palmz71",
154 static struct omap_backlight_config palmz71_backlight_config = {
155 .default_intensity = 0xa0,
158 static struct platform_device palmz71_backlight_device = {
162 .platform_data = &palmz71_backlight_config,
166 static struct platform_device *devices[] __initdata = {
171 &palmz71_backlight_device,
175 palmz71_get_pendown_state(void)
177 return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
180 static const struct ads7846_platform_data palmz71_ts_info = {
182 .vref_delay_usecs = 100, /* internal, no capacitor */
185 .get_pendown_state = palmz71_get_pendown_state,
188 static struct spi_board_info __initdata palmz71_boardinfo[] = { {
189 /* MicroWire (bus 2) CS0 has an ads7846e */
190 .modalias = "ads7846",
191 .platform_data = &palmz71_ts_info,
192 .max_speed_hz = 120000 /* max sample rate at 3V */
193 * 26 /* command + data + overhead */,
198 static struct omap_usb_config palmz71_usb_config __initdata = {
199 .register_dev = 1, /* Mini-B only receptacle */
204 static const struct omap_lcd_config palmz71_lcd_config __initconst = {
205 .ctrl_name = "internal",
209 palmz71_powercable(int irq, void *dev_id)
211 if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
212 printk(KERN_INFO "PM: Power cable connected\n");
213 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
214 IRQ_TYPE_EDGE_FALLING);
216 printk(KERN_INFO "PM: Power cable disconnected\n");
217 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
218 IRQ_TYPE_EDGE_RISING);
224 omap_mpu_wdt_mode(int mode)
227 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
229 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
230 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
235 palmz71_gpio_setup(int early)
238 /* Only set GPIO1 so we have a working serial */
239 gpio_direction_output(1, 1);
241 /* Set MMC/SD host WP pin as input */
242 if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
243 printk(KERN_ERR "Could not reserve WP GPIO!\n");
246 gpio_direction_input(PALMZ71_MMC_WP_GPIO);
248 /* Monitor the Power-cable-connected signal */
249 if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
251 "Could not reserve cable signal GPIO!\n");
254 gpio_direction_input(PALMZ71_USBDETECT_GPIO);
255 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
256 palmz71_powercable, 0, "palmz71-cable", NULL))
258 "IRQ request for power cable failed!\n");
259 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
264 omap_palmz71_init(void)
266 /* mux pins for uarts */
267 omap_cfg_reg(UART1_TX);
268 omap_cfg_reg(UART1_RTS);
269 omap_cfg_reg(UART2_TX);
270 omap_cfg_reg(UART2_RTS);
271 omap_cfg_reg(UART3_TX);
272 omap_cfg_reg(UART3_RX);
274 palmz71_gpio_setup(1);
275 omap_mpu_wdt_mode(0);
277 platform_add_devices(devices, ARRAY_SIZE(devices));
279 palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
280 spi_register_board_info(palmz71_boardinfo,
281 ARRAY_SIZE(palmz71_boardinfo));
282 omap1_usb_init(&palmz71_usb_config);
284 omap_register_i2c_bus(1, 100, NULL, 0);
285 palmz71_gpio_setup(0);
287 omapfb_set_lcd_config(&palmz71_lcd_config);
290 MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
291 .atag_offset = 0x100,
292 .map_io = omap15xx_map_io,
293 .init_early = omap1_init_early,
294 .init_irq = omap1_init_irq,
295 .handle_irq = omap1_handle_irq,
296 .init_machine = omap_palmz71_init,
297 .init_late = omap1_init_late,
298 .init_time = omap1_timer_init,
299 .restart = omap1_restart,