xref: /openbmc/linux/arch/arm/mach-omap1/board-palmte.c (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
23179a019STony Lindgren /*
33179a019STony Lindgren  * linux/arch/arm/mach-omap1/board-palmte.c
43179a019STony Lindgren  *
53179a019STony Lindgren  * Modified from board-generic.c
63179a019STony Lindgren  *
73179a019STony Lindgren  * Support for the Palm Tungsten E PDA.
83179a019STony Lindgren  *
93179a019STony Lindgren  * Original version : Laurent Gonzalez
103179a019STony Lindgren  *
116cbdc8c5SSimon Arlott  * Maintainers : http://palmtelinux.sf.net
123179a019STony Lindgren  *                palmtelinux-developpers@lists.sf.net
133179a019STony Lindgren  *
14d7730cc0SAndrzej Zaborowski  * Copyright (c) 2006 Andrzej Zaborowski  <balrog@zabor.org>
153179a019STony Lindgren  */
16*4c40db62SLinus Walleij #include <linux/gpio/machine.h>
17*4c40db62SLinus Walleij #include <linux/gpio/consumer.h>
183179a019STony Lindgren #include <linux/kernel.h>
193179a019STony Lindgren #include <linux/init.h>
20c3695015SAndrzej Zaborowski #include <linux/input.h>
213179a019STony Lindgren #include <linux/platform_device.h>
22c3695015SAndrzej Zaborowski #include <linux/mtd/mtd.h>
23c3695015SAndrzej Zaborowski #include <linux/mtd/partitions.h>
24561b036aSLadislav Michl #include <linux/mtd/physmap.h>
25c3695015SAndrzej Zaborowski #include <linux/spi/spi.h>
26c3695015SAndrzej Zaborowski #include <linux/interrupt.h>
27d7730cc0SAndrzej Zaborowski #include <linux/apm-emulation.h>
28ddba6c7fSTomi Valkeinen #include <linux/omapfb.h>
297e0a9e62SArnd Bergmann #include <linux/omap-dma.h>
307e0a9e62SArnd Bergmann #include <linux/platform_data/keypad-omap.h>
31cc012729SIgor Grinberg #include <linux/platform_data/omap1_bl.h>
323179a019STony Lindgren 
333179a019STony Lindgren #include <asm/mach-types.h>
343179a019STony Lindgren #include <asm/mach/arch.h>
353179a019STony Lindgren #include <asm/mach/map.h>
363179a019STony Lindgren 
377e0a9e62SArnd Bergmann #include "tc.h"
38100f9638SArnd Bergmann #include "flash.h"
397e0a9e62SArnd Bergmann #include "mux.h"
407e0a9e62SArnd Bergmann #include "hardware.h"
41e8e77e97SArnd Bergmann #include "usb.h"
421e6755f5SAaro Koskinen #include "mmc.h"
434e65331cSTony Lindgren #include "common.h"
443179a019STony Lindgren 
45b2830810STony Lindgren #define PALMTE_USBDETECT_GPIO	0
46b2830810STony Lindgren #define PALMTE_USB_OR_DC_GPIO	1
47b2830810STony Lindgren #define PALMTE_TSC_GPIO		4
48b2830810STony Lindgren #define PALMTE_PINTDAV_GPIO	6
49b2830810STony Lindgren #define PALMTE_MMC_WP_GPIO	8
50b2830810STony Lindgren #define PALMTE_MMC_POWER_GPIO	9
51b2830810STony Lindgren #define PALMTE_HDQ_GPIO		11
52b2830810STony Lindgren #define PALMTE_HEADPHONES_GPIO	14
53b2830810STony Lindgren #define PALMTE_SPEAKER_GPIO	15
54b2830810STony Lindgren #define PALMTE_DC_GPIO		OMAP_MPUIO(2)
55b2830810STony Lindgren #define PALMTE_MMC_SWITCH_GPIO	OMAP_MPUIO(4)
56b2830810STony Lindgren #define PALMTE_MMC1_GPIO	OMAP_MPUIO(6)
57b2830810STony Lindgren #define PALMTE_MMC2_GPIO	OMAP_MPUIO(7)
58b2830810STony Lindgren #define PALMTE_MMC3_GPIO	OMAP_MPUIO(11)
59b2830810STony Lindgren 
60da1f026bSJanusz Krzysztofik static const unsigned int palmte_keymap[] = {
61d7730cc0SAndrzej Zaborowski 	KEY(0, 0, KEY_F1),		/* Calendar */
62da1f026bSJanusz Krzysztofik 	KEY(1, 0, KEY_F2),		/* Contacts */
63da1f026bSJanusz Krzysztofik 	KEY(2, 0, KEY_F3),		/* Tasks List */
64da1f026bSJanusz Krzysztofik 	KEY(3, 0, KEY_F4),		/* Note Pad */
65da1f026bSJanusz Krzysztofik 	KEY(4, 0, KEY_POWER),
66da1f026bSJanusz Krzysztofik 	KEY(0, 1, KEY_LEFT),
67c3695015SAndrzej Zaborowski 	KEY(1, 1, KEY_DOWN),
68da1f026bSJanusz Krzysztofik 	KEY(2, 1, KEY_UP),
69da1f026bSJanusz Krzysztofik 	KEY(3, 1, KEY_RIGHT),
70da1f026bSJanusz Krzysztofik 	KEY(4, 1, KEY_ENTER),
71da1f026bSJanusz Krzysztofik };
72da1f026bSJanusz Krzysztofik 
73da1f026bSJanusz Krzysztofik static const struct matrix_keymap_data palmte_keymap_data = {
74da1f026bSJanusz Krzysztofik 	.keymap		= palmte_keymap,
75da1f026bSJanusz Krzysztofik 	.keymap_size	= ARRAY_SIZE(palmte_keymap),
76c3695015SAndrzej Zaborowski };
77c3695015SAndrzej Zaborowski 
78c3695015SAndrzej Zaborowski static struct omap_kp_platform_data palmte_kp_data = {
79c3695015SAndrzej Zaborowski 	.rows	= 8,
80c3695015SAndrzej Zaborowski 	.cols	= 8,
81da1f026bSJanusz Krzysztofik 	.keymap_data = &palmte_keymap_data,
82da1f026bSJanusz Krzysztofik 	.rep	= true,
83c3695015SAndrzej Zaborowski 	.delay	= 12,
84c3695015SAndrzej Zaborowski };
85c3695015SAndrzej Zaborowski 
86c3695015SAndrzej Zaborowski static struct resource palmte_kp_resources[] = {
87c3695015SAndrzej Zaborowski 	[0]	= {
88c3695015SAndrzej Zaborowski 		.start	= INT_KEYBOARD,
89c3695015SAndrzej Zaborowski 		.end	= INT_KEYBOARD,
90c3695015SAndrzej Zaborowski 		.flags	= IORESOURCE_IRQ,
91c3695015SAndrzej Zaborowski 	},
92c3695015SAndrzej Zaborowski };
93c3695015SAndrzej Zaborowski 
94c3695015SAndrzej Zaborowski static struct platform_device palmte_kp_device = {
95c3695015SAndrzej Zaborowski 	.name		= "omap-keypad",
96c3695015SAndrzej Zaborowski 	.id		= -1,
97c3695015SAndrzej Zaborowski 	.dev		= {
98c3695015SAndrzej Zaborowski 		.platform_data	= &palmte_kp_data,
99c3695015SAndrzej Zaborowski 	},
100c3695015SAndrzej Zaborowski 	.num_resources	= ARRAY_SIZE(palmte_kp_resources),
101c3695015SAndrzej Zaborowski 	.resource	= palmte_kp_resources,
102c3695015SAndrzej Zaborowski };
103c3695015SAndrzej Zaborowski 
104c3695015SAndrzej Zaborowski static struct mtd_partition palmte_rom_partitions[] = {
105c3695015SAndrzej Zaborowski 	/* PalmOS "Small ROM", contains the bootloader and the debugger */
106c3695015SAndrzej Zaborowski 	{
107c3695015SAndrzej Zaborowski 		.name		= "smallrom",
108c3695015SAndrzej Zaborowski 		.offset		= 0,
109c3695015SAndrzej Zaborowski 		.size		= 0xa000,
110c3695015SAndrzej Zaborowski 		.mask_flags	= MTD_WRITEABLE,
111c3695015SAndrzej Zaborowski 	},
112c3695015SAndrzej Zaborowski 	/* PalmOS "Big ROM", a filesystem with all the OS code and data */
113c3695015SAndrzej Zaborowski 	{
114c3695015SAndrzej Zaborowski 		.name		= "bigrom",
115c3695015SAndrzej Zaborowski 		.offset		= SZ_128K,
116c3695015SAndrzej Zaborowski 		/*
117c3695015SAndrzej Zaborowski 		 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
118c3695015SAndrzej Zaborowski 		 * 0x7b0000 bytes in the English-only ("enUS") version.
119c3695015SAndrzej Zaborowski 		 */
120c3695015SAndrzej Zaborowski 		.size		= 0x7b0000,
121c3695015SAndrzej Zaborowski 		.mask_flags	= MTD_WRITEABLE,
122c3695015SAndrzej Zaborowski 	},
123c3695015SAndrzej Zaborowski };
124c3695015SAndrzej Zaborowski 
125561b036aSLadislav Michl static struct physmap_flash_data palmte_rom_data = {
126c3695015SAndrzej Zaborowski 	.width		= 2,
127561b036aSLadislav Michl 	.set_vpp	= omap1_set_vpp,
128c3695015SAndrzej Zaborowski 	.parts		= palmte_rom_partitions,
129c3695015SAndrzej Zaborowski 	.nr_parts	= ARRAY_SIZE(palmte_rom_partitions),
130c3695015SAndrzej Zaborowski };
131c3695015SAndrzej Zaborowski 
132c3695015SAndrzej Zaborowski static struct resource palmte_rom_resource = {
133c3695015SAndrzej Zaborowski 	.start		= OMAP_CS0_PHYS,
134c3695015SAndrzej Zaborowski 	.end		= OMAP_CS0_PHYS + SZ_8M - 1,
135c3695015SAndrzej Zaborowski 	.flags		= IORESOURCE_MEM,
136c3695015SAndrzej Zaborowski };
137c3695015SAndrzej Zaborowski 
138c3695015SAndrzej Zaborowski static struct platform_device palmte_rom_device = {
139561b036aSLadislav Michl 	.name		= "physmap-flash",
140c3695015SAndrzej Zaborowski 	.id		= -1,
141c3695015SAndrzej Zaborowski 	.dev		= {
142c3695015SAndrzej Zaborowski 		.platform_data	= &palmte_rom_data,
143c3695015SAndrzej Zaborowski 	},
144c3695015SAndrzej Zaborowski 	.num_resources	= 1,
145c3695015SAndrzej Zaborowski 	.resource	= &palmte_rom_resource,
146c3695015SAndrzej Zaborowski };
147c3695015SAndrzej Zaborowski 
1489b6553cdSTony Lindgren static struct platform_device palmte_lcd_device = {
1499b6553cdSTony Lindgren 	.name		= "lcd_palmte",
1509b6553cdSTony Lindgren 	.id		= -1,
1519b6553cdSTony Lindgren };
1529b6553cdSTony Lindgren 
153c3695015SAndrzej Zaborowski static struct omap_backlight_config palmte_backlight_config = {
154c3695015SAndrzej Zaborowski 	.default_intensity	= 0xa0,
155c3695015SAndrzej Zaborowski };
156c3695015SAndrzej Zaborowski 
157c3695015SAndrzej Zaborowski static struct platform_device palmte_backlight_device = {
158c3695015SAndrzej Zaborowski 	.name		= "omap-bl",
159c3695015SAndrzej Zaborowski 	.id		= -1,
160c3695015SAndrzej Zaborowski 	.dev		= {
161c3695015SAndrzej Zaborowski 		.platform_data	= &palmte_backlight_config,
162c3695015SAndrzej Zaborowski 	},
163c3695015SAndrzej Zaborowski };
164c3695015SAndrzej Zaborowski 
165d7730cc0SAndrzej Zaborowski static struct platform_device *palmte_devices[] __initdata = {
166c3695015SAndrzej Zaborowski 	&palmte_rom_device,
167c3695015SAndrzej Zaborowski 	&palmte_kp_device,
1689b6553cdSTony Lindgren 	&palmte_lcd_device,
169c3695015SAndrzej Zaborowski 	&palmte_backlight_device,
1709b6553cdSTony Lindgren };
1719b6553cdSTony Lindgren 
1723179a019STony Lindgren static struct omap_usb_config palmte_usb_config __initdata = {
173c3695015SAndrzej Zaborowski 	.register_dev	= 1,	/* Mini-B only receptacle */
1743179a019STony Lindgren 	.hmc_mode	= 0,
175c3695015SAndrzej Zaborowski 	.pins[0]	= 2,
1763179a019STony Lindgren };
1773179a019STony Lindgren 
178d25c70cfSBhumika Goyal static const struct omap_lcd_config palmte_lcd_config __initconst = {
1793179a019STony Lindgren 	.ctrl_name	= "internal",
1803179a019STony Lindgren };
1813179a019STony Lindgren 
182c3695015SAndrzej Zaborowski static struct spi_board_info palmte_spi_info[] __initdata = {
183c3695015SAndrzej Zaborowski 	{
184c3695015SAndrzej Zaborowski 		.modalias	= "tsc2102",
185c3695015SAndrzej Zaborowski 		.bus_num	= 2,	/* uWire (officially) */
186c3695015SAndrzej Zaborowski 		.chip_select	= 0,	/* As opposed to 3 */
187c3695015SAndrzej Zaborowski 		.max_speed_hz	= 8000000,
188c3695015SAndrzej Zaborowski 	},
189c3695015SAndrzej Zaborowski };
190c3695015SAndrzej Zaborowski 
1911e6755f5SAaro Koskinen #if IS_ENABLED(CONFIG_MMC_OMAP)
1921e6755f5SAaro Koskinen 
1931e6755f5SAaro Koskinen static struct omap_mmc_platform_data _palmte_mmc_config = {
1941e6755f5SAaro Koskinen 	.nr_slots			= 1,
1951e6755f5SAaro Koskinen 	.slots[0]			= {
1961e6755f5SAaro Koskinen 		.ocr_mask		= MMC_VDD_32_33|MMC_VDD_33_34,
1971e6755f5SAaro Koskinen 		.name			= "mmcblk",
1981e6755f5SAaro Koskinen 	},
1991e6755f5SAaro Koskinen };
2001e6755f5SAaro Koskinen 
2011e6755f5SAaro Koskinen static struct omap_mmc_platform_data *palmte_mmc_config[OMAP15XX_NR_MMC] = {
2021e6755f5SAaro Koskinen 	[0] = &_palmte_mmc_config,
2031e6755f5SAaro Koskinen };
2041e6755f5SAaro Koskinen 
palmte_mmc_init(void)2051e6755f5SAaro Koskinen static void palmte_mmc_init(void)
2061e6755f5SAaro Koskinen {
2071e6755f5SAaro Koskinen 	omap1_init_mmc(palmte_mmc_config, OMAP15XX_NR_MMC);
2081e6755f5SAaro Koskinen }
2091e6755f5SAaro Koskinen 
2101e6755f5SAaro Koskinen #else /* CONFIG_MMC_OMAP */
2111e6755f5SAaro Koskinen 
palmte_mmc_init(void)2121e6755f5SAaro Koskinen static void palmte_mmc_init(void)
2131e6755f5SAaro Koskinen {
2141e6755f5SAaro Koskinen }
2151e6755f5SAaro Koskinen 
2161e6755f5SAaro Koskinen #endif /* CONFIG_MMC_OMAP */
2171e6755f5SAaro Koskinen 
218*4c40db62SLinus Walleij static struct gpiod_lookup_table palmte_irq_gpio_table = {
219*4c40db62SLinus Walleij 	.dev_id = NULL,
220*4c40db62SLinus Walleij 	.table = {
221*4c40db62SLinus Walleij 		/* GPIO used for TSC2102 PINTDAV IRQ */
222*4c40db62SLinus Walleij 		GPIO_LOOKUP("gpio-0-15", PALMTE_PINTDAV_GPIO, "tsc2102_irq",
223*4c40db62SLinus Walleij 			    GPIO_ACTIVE_HIGH),
224*4c40db62SLinus Walleij 		/* GPIO used for USB or DC input detection */
225*4c40db62SLinus Walleij 		GPIO_LOOKUP("gpio-0-15", PALMTE_USB_OR_DC_GPIO, "usb_dc_irq",
226*4c40db62SLinus Walleij 			    GPIO_ACTIVE_HIGH),
227*4c40db62SLinus Walleij 		{ }
228*4c40db62SLinus Walleij 	},
229*4c40db62SLinus Walleij };
230*4c40db62SLinus Walleij 
omap_palmte_init(void)231c3695015SAndrzej Zaborowski static void __init omap_palmte_init(void)
2323179a019STony Lindgren {
233*4c40db62SLinus Walleij 	struct gpio_desc *d;
234*4c40db62SLinus Walleij 
235c33da3a8SJanusz Krzysztofik 	/* mux pins for uarts */
236c33da3a8SJanusz Krzysztofik 	omap_cfg_reg(UART1_TX);
237c33da3a8SJanusz Krzysztofik 	omap_cfg_reg(UART1_RTS);
238c33da3a8SJanusz Krzysztofik 	omap_cfg_reg(UART2_TX);
239c33da3a8SJanusz Krzysztofik 	omap_cfg_reg(UART2_RTS);
240c33da3a8SJanusz Krzysztofik 	omap_cfg_reg(UART3_TX);
241c33da3a8SJanusz Krzysztofik 	omap_cfg_reg(UART3_RX);
242c33da3a8SJanusz Krzysztofik 
243d7730cc0SAndrzej Zaborowski 	platform_add_devices(palmte_devices, ARRAY_SIZE(palmte_devices));
244c3695015SAndrzej Zaborowski 
245*4c40db62SLinus Walleij 	gpiod_add_lookup_table(&palmte_irq_gpio_table);
246*4c40db62SLinus Walleij 	d = gpiod_get(NULL, "tsc2102_irq", GPIOD_IN);
247*4c40db62SLinus Walleij 	if (IS_ERR(d))
248*4c40db62SLinus Walleij 		pr_err("Unable to get TSC2102 IRQ GPIO descriptor\n");
249*4c40db62SLinus Walleij 	else
250*4c40db62SLinus Walleij 		palmte_spi_info[0].irq = gpiod_to_irq(d);
251c3695015SAndrzej Zaborowski 	spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info));
252*4c40db62SLinus Walleij 
253*4c40db62SLinus Walleij 	/* We are getting this just to set it up as input */
254*4c40db62SLinus Walleij 	d = gpiod_get(NULL, "usb_dc_irq", GPIOD_IN);
255*4c40db62SLinus Walleij 	if (IS_ERR(d))
256*4c40db62SLinus Walleij 		pr_err("Unable to get USB/DC IRQ GPIO descriptor\n");
257*4c40db62SLinus Walleij 	else
258*4c40db62SLinus Walleij 		gpiod_put(d);
259*4c40db62SLinus Walleij 
260c3695015SAndrzej Zaborowski 	omap_serial_init();
261dd0cdd88STony Lindgren 	omap1_usb_init(&palmte_usb_config);
2621ed16a86SJarkko Nikula 	omap_register_i2c_bus(1, 100, NULL, 0);
263ddba6c7fSTomi Valkeinen 
264ddba6c7fSTomi Valkeinen 	omapfb_set_lcd_config(&palmte_lcd_config);
2651e6755f5SAaro Koskinen 	palmte_mmc_init();
2663179a019STony Lindgren }
2673179a019STony Lindgren 
2683179a019STony Lindgren MACHINE_START(OMAP_PALMTE, "OMAP310 based Palm Tungsten E")
269246e389dSNicolas Pitre 	.atag_offset	= 0x100,
2709a99b142SArnd Bergmann 	.map_io		= omap1_map_io,
2717b88e62fSTony Lindgren 	.init_early     = omap1_init_early,
2727b88e62fSTony Lindgren 	.init_irq	= omap1_init_irq,
273c3695015SAndrzej Zaborowski 	.init_machine	= omap_palmte_init,
27482c3bd03SShawn Guo 	.init_late	= omap1_init_late,
2756bb27d73SStephen Warren 	.init_time	= omap1_timer_init,
276baa95883SRussell King 	.restart	= omap1_restart,
2773179a019STony Lindgren MACHINE_END
278