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>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
38 #include <linux/omap-dma.h>
40 #include <linux/platform_data/keypad-omap.h>
42 #include <mach/hardware.h>
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
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)
57 static const unsigned int palmz71_keymap
[] = {
68 KEY(0, 2, KEY_CAMERA
),
71 static const struct matrix_keymap_data palmz71_keymap_data
= {
72 .keymap
= palmz71_keymap
,
73 .keymap_size
= ARRAY_SIZE(palmz71_keymap
),
76 static struct omap_kp_platform_data palmz71_kp_data
= {
79 .keymap_data
= &palmz71_keymap_data
,
84 static struct resource palmz71_kp_resources
[] = {
86 .start
= INT_KEYBOARD
,
88 .flags
= IORESOURCE_IRQ
,
92 static struct platform_device palmz71_kp_device
= {
93 .name
= "omap-keypad",
96 .platform_data
= &palmz71_kp_data
,
98 .num_resources
= ARRAY_SIZE(palmz71_kp_resources
),
99 .resource
= palmz71_kp_resources
,
102 static struct mtd_partition palmz71_rom_partitions
[] = {
103 /* PalmOS "Small ROM", contains the bootloader and the debugger */
108 .mask_flags
= MTD_WRITEABLE
,
110 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
115 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
116 * 0x7b0000 bytes in the English-only ("enUS") version.
119 .mask_flags
= MTD_WRITEABLE
,
123 static struct physmap_flash_data palmz71_rom_data
= {
125 .set_vpp
= omap1_set_vpp
,
126 .parts
= palmz71_rom_partitions
,
127 .nr_parts
= ARRAY_SIZE(palmz71_rom_partitions
),
130 static struct resource palmz71_rom_resource
= {
131 .start
= OMAP_CS0_PHYS
,
132 .end
= OMAP_CS0_PHYS
+ SZ_8M
- 1,
133 .flags
= IORESOURCE_MEM
,
136 static struct platform_device palmz71_rom_device
= {
137 .name
= "physmap-flash",
140 .platform_data
= &palmz71_rom_data
,
143 .resource
= &palmz71_rom_resource
,
146 static struct platform_device palmz71_lcd_device
= {
147 .name
= "lcd_palmz71",
151 static struct platform_device palmz71_spi_device
= {
152 .name
= "spi_palmz71",
156 static struct omap_backlight_config palmz71_backlight_config
= {
157 .default_intensity
= 0xa0,
160 static struct platform_device palmz71_backlight_device
= {
164 .platform_data
= &palmz71_backlight_config
,
168 static struct platform_device
*devices
[] __initdata
= {
173 &palmz71_backlight_device
,
177 palmz71_get_pendown_state(void)
179 return !gpio_get_value(PALMZ71_PENIRQ_GPIO
);
182 static const struct ads7846_platform_data palmz71_ts_info
= {
184 .vref_delay_usecs
= 100, /* internal, no capacitor */
187 .get_pendown_state
= palmz71_get_pendown_state
,
190 static struct spi_board_info __initdata palmz71_boardinfo
[] = { {
191 /* MicroWire (bus 2) CS0 has an ads7846e */
192 .modalias
= "ads7846",
193 .platform_data
= &palmz71_ts_info
,
194 .max_speed_hz
= 120000 /* max sample rate at 3V */
195 * 26 /* command + data + overhead */,
200 static struct omap_usb_config palmz71_usb_config __initdata
= {
201 .register_dev
= 1, /* Mini-B only receptacle */
206 static const struct omap_lcd_config palmz71_lcd_config __initconst
= {
207 .ctrl_name
= "internal",
211 palmz71_powercable(int irq
, void *dev_id
)
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
);
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
);
226 omap_mpu_wdt_mode(int mode
)
229 omap_writew(0x8000, OMAP_WDT_TIMER_MODE
);
231 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE
);
232 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE
);
237 palmz71_gpio_setup(int early
)
240 /* Only set GPIO1 so we have a working serial */
241 gpio_direction_output(1, 1);
243 /* Set MMC/SD host WP pin as input */
244 if (gpio_request(PALMZ71_MMC_WP_GPIO
, "MMC WP") < 0) {
245 printk(KERN_ERR
"Could not reserve WP GPIO!\n");
248 gpio_direction_input(PALMZ71_MMC_WP_GPIO
);
250 /* Monitor the Power-cable-connected signal */
251 if (gpio_request(PALMZ71_USBDETECT_GPIO
, "USB detect") < 0) {
253 "Could not reserve cable signal GPIO!\n");
256 gpio_direction_input(PALMZ71_USBDETECT_GPIO
);
257 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO
),
258 palmz71_powercable
, 0, "palmz71-cable", NULL
))
260 "IRQ request for power cable failed!\n");
261 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO
), NULL
);
266 omap_palmz71_init(void)
268 /* mux pins for uarts */
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
);
276 palmz71_gpio_setup(1);
277 omap_mpu_wdt_mode(0);
279 platform_add_devices(devices
, ARRAY_SIZE(devices
));
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
);
286 omap_register_i2c_bus(1, 100, NULL
, 0);
287 palmz71_gpio_setup(0);
289 omapfb_set_lcd_config(&palmz71_lcd_config
);
292 MACHINE_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
,