1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-omap1/board-perseus2.c
5 * Modified from board-generic.c
7 * Original OMAP730 support by Jean Pihet <j-pihet@ti.com>
8 * Updated for 2.6 by Kevin Hilman <kjh@hilman.org>
10 #include <linux/gpio.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/delay.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/platnand.h>
17 #include <linux/mtd/physmap.h>
18 #include <linux/input.h>
19 #include <linux/smc91x.h>
20 #include <linux/omapfb.h>
21 #include <linux/platform_data/keypad-omap.h>
22 #include <linux/soc/ti/omap1-io.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
36 static const unsigned int p2_keymap[] = {
45 KEY(3, 1, KEY_VOLUMEDOWN),
46 KEY(4, 1, KEY_VOLUMEUP),
47 KEY(5, 1, KEY_RECORD),
58 KEY(5, 3, KEY_KPSLASH),
63 KEY(4, 4, KEY_KPASTERISK),
67 static struct smc91x_platdata smc91x_info = {
68 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
69 .leda = RPC_LED_100_10,
70 .ledb = RPC_LED_TX_RX,
73 static struct resource smc91x_resources[] = {
75 .start = H2P2_DBG_FPGA_ETHR_START, /* Physical */
76 .end = H2P2_DBG_FPGA_ETHR_START + 0xf,
77 .flags = IORESOURCE_MEM,
80 .start = INT_7XX_MPU_EXT_NIRQ,
82 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
86 static struct mtd_partition nor_partitions[] = {
87 /* bootloader (U-Boot, etc) in first sector */
92 .mask_flags = MTD_WRITEABLE, /* force read-only */
94 /* bootloader params in the next sector */
97 .offset = MTDPART_OFS_APPEND,
104 .offset = MTDPART_OFS_APPEND,
108 /* rest of flash is a file system */
111 .offset = MTDPART_OFS_APPEND,
112 .size = MTDPART_SIZ_FULL,
117 static struct physmap_flash_data nor_data = {
119 .set_vpp = omap1_set_vpp,
120 .parts = nor_partitions,
121 .nr_parts = ARRAY_SIZE(nor_partitions),
124 static struct resource nor_resource = {
125 .start = OMAP_CS0_PHYS,
126 .end = OMAP_CS0_PHYS + SZ_32M - 1,
127 .flags = IORESOURCE_MEM,
130 static struct platform_device nor_device = {
131 .name = "physmap-flash",
134 .platform_data = &nor_data,
137 .resource = &nor_resource,
140 #define P2_NAND_RB_GPIO_PIN 62
142 static int nand_dev_ready(struct nand_chip *chip)
144 return gpio_get_value(P2_NAND_RB_GPIO_PIN);
147 static struct platform_nand_data nand_data = {
151 .options = NAND_SAMSUNG_LP_OPTIONS,
154 .cmd_ctrl = omap1_nand_cmd_ctl,
155 .dev_ready = nand_dev_ready,
159 static struct resource nand_resource = {
160 .start = OMAP_CS3_PHYS,
161 .end = OMAP_CS3_PHYS + SZ_4K - 1,
162 .flags = IORESOURCE_MEM,
165 static struct platform_device nand_device = {
169 .platform_data = &nand_data,
172 .resource = &nand_resource,
175 static struct platform_device smc91x_device = {
179 .platform_data = &smc91x_info,
181 .num_resources = ARRAY_SIZE(smc91x_resources),
182 .resource = smc91x_resources,
185 static struct resource kp_resources[] = {
187 .start = INT_7XX_MPUIO_KEYPAD,
188 .end = INT_7XX_MPUIO_KEYPAD,
189 .flags = IORESOURCE_IRQ,
193 static const struct matrix_keymap_data p2_keymap_data = {
195 .keymap_size = ARRAY_SIZE(p2_keymap),
198 static struct omap_kp_platform_data kp_data = {
201 .keymap_data = &p2_keymap_data,
206 static struct platform_device kp_device = {
207 .name = "omap-keypad",
210 .platform_data = &kp_data,
212 .num_resources = ARRAY_SIZE(kp_resources),
213 .resource = kp_resources,
216 static struct platform_device *devices[] __initdata = {
223 static const struct omap_lcd_config perseus2_lcd_config __initconst = {
224 .ctrl_name = "internal",
227 static void __init perseus2_init_smc91x(void)
229 __raw_writeb(1, H2P2_DBG_FPGA_LAN_RESET);
231 __raw_writeb(__raw_readb(H2P2_DBG_FPGA_LAN_RESET) & ~1,
232 H2P2_DBG_FPGA_LAN_RESET);
236 static void __init omap_perseus2_init(void)
238 /* Early, board-dependent init */
241 * Hold GSM Reset until needed
243 omap_writew(omap_readw(OMAP7XX_DSP_M_CTL) & ~1, OMAP7XX_DSP_M_CTL);
246 * UARTs -> done automagically by 8250 driver
250 * CSx timings, GPIO Mux ... setup
253 /* Flash: CS0 timings setup */
254 omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_0);
255 omap_writel(0x00000088, OMAP7XX_FLASH_ACFG_0);
258 * Ethernet support through the debug board
261 omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_1);
262 omap_writel(0x00000000, OMAP7XX_FLASH_ACFG_1);
265 * Configure MPU_EXT_NIRQ IO in IO_CONF9 register,
266 * It is used as the Ethernet controller interrupt
268 omap_writel(omap_readl(OMAP7XX_IO_CONF_9) & 0x1FFFFFFF,
271 perseus2_init_smc91x();
273 BUG_ON(gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0);
274 gpio_direction_input(P2_NAND_RB_GPIO_PIN);
276 omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
277 omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
279 /* Mux pins for keypad */
280 omap_cfg_reg(E2_7XX_KBR0);
281 omap_cfg_reg(J7_7XX_KBR1);
282 omap_cfg_reg(E1_7XX_KBR2);
283 omap_cfg_reg(F3_7XX_KBR3);
284 omap_cfg_reg(D2_7XX_KBR4);
285 omap_cfg_reg(C2_7XX_KBC0);
286 omap_cfg_reg(D3_7XX_KBC1);
287 omap_cfg_reg(E4_7XX_KBC2);
288 omap_cfg_reg(F4_7XX_KBC3);
289 omap_cfg_reg(E3_7XX_KBC4);
291 if (IS_ENABLED(CONFIG_SPI_OMAP_UWIRE)) {
292 /* configure pins: MPU_UW_nSCS1, MPU_UW_SDO, MPU_UW_SCLK */
293 int val = omap_readl(OMAP7XX_IO_CONF_9) & ~0x00EEE000;
294 omap_writel(val | 0x00AAA000, OMAP7XX_IO_CONF_9);
297 platform_add_devices(devices, ARRAY_SIZE(devices));
300 omap_register_i2c_bus(1, 100, NULL, 0);
302 omapfb_set_lcd_config(&perseus2_lcd_config);
305 /* Only FPGA needs to be mapped here. All others are done with ioremap */
306 static struct map_desc omap_perseus2_io_desc[] __initdata = {
308 .virtual = H2P2_DBG_FPGA_BASE,
309 .pfn = __phys_to_pfn(H2P2_DBG_FPGA_START),
310 .length = H2P2_DBG_FPGA_SIZE,
315 static void __init omap_perseus2_map_io(void)
318 iotable_init(omap_perseus2_io_desc,
319 ARRAY_SIZE(omap_perseus2_io_desc));
322 MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
323 /* Maintainer: Kevin Hilman <kjh@hilman.org> */
324 .atag_offset = 0x100,
325 .map_io = omap_perseus2_map_io,
326 .init_early = omap1_init_early,
327 .init_irq = omap1_init_irq,
328 .handle_irq = omap1_handle_irq,
329 .init_machine = omap_perseus2_init,
330 .init_late = omap1_init_late,
331 .init_time = omap1_timer_init,
332 .restart = omap1_restart,