blob: 4a0a66815ca0059e39183394a1c73b987e5b9650 [file] [log] [blame]
Brian Swetland495f71d2006-06-26 16:16:03 -07001/*
2 * linux/arch/arm/mach-omap1/board-fsample.c
3 *
4 * Modified from board-perseus2.c
5 *
6 * Original OMAP730 support by Jean Pihet <j-pihet@ti.com>
7 * Updated for 2.6 by Kevin Hilman <kjh@hilman.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
Russell King2f8163b2011-07-26 10:53:52 +010013#include <linux/gpio.h>
Brian Swetland495f71d2006-06-26 16:16:03 -070014#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/delay.h>
18#include <linux/mtd/mtd.h>
Boris Brezillonc7921bb2018-09-07 00:38:46 +020019#include <linux/mtd/platnand.h>
Ladislav Michl561b0362010-02-15 10:03:32 -080020#include <linux/mtd/physmap.h>
Brian Swetland495f71d2006-06-26 16:16:03 -070021#include <linux/input.h>
Ladislav Michl3bc48012009-12-11 16:16:33 -080022#include <linux/smc91x.h>
Tomi Valkeinenddba6c72011-09-20 15:23:13 +030023#include <linux/omapfb.h>
Brian Swetland495f71d2006-06-26 16:16:03 -070024
Brian Swetland495f71d2006-06-26 16:16:03 -070025#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
Brian Swetland495f71d2006-06-26 16:16:03 -070027#include <asm/mach/map.h>
28
Tony Lindgren54b693d2012-10-02 13:39:28 -070029#include <mach/tc.h>
Tony Lindgren70c494c2012-09-19 10:46:56 -070030#include <mach/mux.h>
Arnd Bergmann100f9632015-01-30 10:45:33 +010031#include "flash.h"
Arnd Bergmann22037472012-08-24 15:21:06 +020032#include <linux/platform_data/keypad-omap.h>
Tony Lindgrend9558b12009-03-23 18:07:32 -070033
Tony Lindgren2e3ee9f2012-02-24 10:34:34 -080034#include <mach/hardware.h>
35
36#include "iomap.h"
37#include "common.h"
Tony Lindgren21d182b2012-10-31 14:02:46 -070038#include "fpga.h"
Tony Lindgren2e3ee9f2012-02-24 10:34:34 -080039
Tony Lindgrend9558b12009-03-23 18:07:32 -070040/* fsample is pretty close to p2-sample */
41
42#define fsample_cpld_read(reg) __raw_readb(reg)
43#define fsample_cpld_write(val, reg) __raw_writeb(val, reg)
44
45#define FSAMPLE_CPLD_BASE 0xE8100000
46#define FSAMPLE_CPLD_SIZE SZ_4K
47#define FSAMPLE_CPLD_START 0x05080000
48
49#define FSAMPLE_CPLD_REG_A (FSAMPLE_CPLD_BASE + 0x00)
50#define FSAMPLE_CPLD_SWITCH (FSAMPLE_CPLD_BASE + 0x02)
51#define FSAMPLE_CPLD_UART (FSAMPLE_CPLD_BASE + 0x02)
52#define FSAMPLE_CPLD_REG_B (FSAMPLE_CPLD_BASE + 0x04)
53#define FSAMPLE_CPLD_VERSION (FSAMPLE_CPLD_BASE + 0x06)
54#define FSAMPLE_CPLD_SET_CLR (FSAMPLE_CPLD_BASE + 0x06)
55
56#define FSAMPLE_CPLD_BIT_BT_RESET 0
57#define FSAMPLE_CPLD_BIT_LCD_RESET 1
58#define FSAMPLE_CPLD_BIT_CAM_PWDN 2
59#define FSAMPLE_CPLD_BIT_CHARGER_ENABLE 3
60#define FSAMPLE_CPLD_BIT_SD_MMC_EN 4
61#define FSAMPLE_CPLD_BIT_aGPS_PWREN 5
62#define FSAMPLE_CPLD_BIT_BACKLIGHT 6
63#define FSAMPLE_CPLD_BIT_aGPS_EN_RESET 7
64#define FSAMPLE_CPLD_BIT_aGPS_SLEEPx_N 8
65#define FSAMPLE_CPLD_BIT_OTG_RESET 9
66
67#define fsample_cpld_set(bit) \
68 fsample_cpld_write((((bit) & 15) << 4) | 0x0f, FSAMPLE_CPLD_SET_CLR)
69
70#define fsample_cpld_clear(bit) \
71 fsample_cpld_write(0xf0 | ((bit) & 15), FSAMPLE_CPLD_SET_CLR)
Brian Swetland495f71d2006-06-26 16:16:03 -070072
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000073static const unsigned int fsample_keymap[] = {
74 KEY(0, 0, KEY_UP),
75 KEY(1, 0, KEY_RIGHT),
76 KEY(2, 0, KEY_LEFT),
77 KEY(3, 0, KEY_DOWN),
78 KEY(4, 0, KEY_ENTER),
79 KEY(0, 1, KEY_F10),
80 KEY(1, 1, KEY_SEND),
81 KEY(2, 1, KEY_END),
82 KEY(3, 1, KEY_VOLUMEDOWN),
83 KEY(4, 1, KEY_VOLUMEUP),
84 KEY(5, 1, KEY_RECORD),
85 KEY(0, 2, KEY_F9),
86 KEY(1, 2, KEY_3),
87 KEY(2, 2, KEY_6),
88 KEY(3, 2, KEY_9),
89 KEY(4, 2, KEY_KPDOT),
90 KEY(0, 3, KEY_BACK),
91 KEY(1, 3, KEY_2),
92 KEY(2, 3, KEY_5),
93 KEY(3, 3, KEY_8),
94 KEY(4, 3, KEY_0),
95 KEY(5, 3, KEY_KPSLASH),
96 KEY(0, 4, KEY_HOME),
97 KEY(1, 4, KEY_1),
98 KEY(2, 4, KEY_4),
99 KEY(3, 4, KEY_7),
100 KEY(4, 4, KEY_KPASTERISK),
101 KEY(5, 4, KEY_POWER),
Brian Swetland495f71d2006-06-26 16:16:03 -0700102};
103
Ladislav Michl3bc48012009-12-11 16:16:33 -0800104static struct smc91x_platdata smc91x_info = {
105 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
106 .leda = RPC_LED_100_10,
107 .ledb = RPC_LED_TX_RX,
108};
109
Brian Swetland495f71d2006-06-26 16:16:03 -0700110static struct resource smc91x_resources[] = {
111 [0] = {
112 .start = H2P2_DBG_FPGA_ETHR_START, /* Physical */
113 .end = H2P2_DBG_FPGA_ETHR_START + 0xf,
114 .flags = IORESOURCE_MEM,
115 },
116 [1] = {
Alistair Buxton372b1c32009-09-18 04:09:39 +0100117 .start = INT_7XX_MPU_EXT_NIRQ,
Brian Swetland495f71d2006-06-26 16:16:03 -0700118 .end = 0,
Russell Kinge7b3dc72008-01-14 22:30:10 +0000119 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Brian Swetland495f71d2006-06-26 16:16:03 -0700120 },
121};
122
Tony Lindgrenc2cdaff2010-12-07 16:26:55 -0800123static void __init fsample_init_smc91x(void)
124{
Tony Lindgren4c98dc62012-10-02 12:39:09 -0700125 __raw_writeb(1, H2P2_DBG_FPGA_LAN_RESET);
Tony Lindgrenc2cdaff2010-12-07 16:26:55 -0800126 mdelay(50);
Tony Lindgren4c98dc62012-10-02 12:39:09 -0700127 __raw_writeb(__raw_readb(H2P2_DBG_FPGA_LAN_RESET) & ~1,
Tony Lindgrenc2cdaff2010-12-07 16:26:55 -0800128 H2P2_DBG_FPGA_LAN_RESET);
129 mdelay(50);
130}
131
Brian Swetland495f71d2006-06-26 16:16:03 -0700132static struct mtd_partition nor_partitions[] = {
133 /* bootloader (U-Boot, etc) in first sector */
134 {
135 .name = "bootloader",
136 .offset = 0,
137 .size = SZ_128K,
138 .mask_flags = MTD_WRITEABLE, /* force read-only */
139 },
140 /* bootloader params in the next sector */
141 {
142 .name = "params",
143 .offset = MTDPART_OFS_APPEND,
144 .size = SZ_128K,
145 .mask_flags = 0,
146 },
147 /* kernel */
148 {
149 .name = "kernel",
150 .offset = MTDPART_OFS_APPEND,
151 .size = SZ_2M,
152 .mask_flags = 0
153 },
154 /* rest of flash is a file system */
155 {
156 .name = "rootfs",
157 .offset = MTDPART_OFS_APPEND,
158 .size = MTDPART_SIZ_FULL,
159 .mask_flags = 0
160 },
161};
162
Ladislav Michl561b0362010-02-15 10:03:32 -0800163static struct physmap_flash_data nor_data = {
Brian Swetland495f71d2006-06-26 16:16:03 -0700164 .width = 2,
Ladislav Michl561b0362010-02-15 10:03:32 -0800165 .set_vpp = omap1_set_vpp,
Brian Swetland495f71d2006-06-26 16:16:03 -0700166 .parts = nor_partitions,
167 .nr_parts = ARRAY_SIZE(nor_partitions),
168};
169
170static struct resource nor_resource = {
171 .start = OMAP_CS0_PHYS,
172 .end = OMAP_CS0_PHYS + SZ_32M - 1,
173 .flags = IORESOURCE_MEM,
174};
175
176static struct platform_device nor_device = {
Ladislav Michl561b0362010-02-15 10:03:32 -0800177 .name = "physmap-flash",
Brian Swetland495f71d2006-06-26 16:16:03 -0700178 .id = 0,
179 .dev = {
180 .platform_data = &nor_data,
181 },
182 .num_resources = 1,
183 .resource = &nor_resource,
184};
185
Ladislav Michl414f552a2009-12-11 16:16:33 -0800186#define FSAMPLE_NAND_RB_GPIO_PIN 62
187
Boris Brezillon47bd59e2018-09-06 14:05:13 +0200188static int nand_dev_ready(struct nand_chip *chip)
Ladislav Michl414f552a2009-12-11 16:16:33 -0800189{
190 return gpio_get_value(FSAMPLE_NAND_RB_GPIO_PIN);
191}
192
Ladislav Michl414f552a2009-12-11 16:16:33 -0800193static struct platform_nand_data nand_data = {
194 .chip = {
195 .nr_chips = 1,
196 .chip_offset = 0,
197 .options = NAND_SAMSUNG_LP_OPTIONS,
Ladislav Michl414f552a2009-12-11 16:16:33 -0800198 },
199 .ctrl = {
Paul Walmsley31cde042012-04-13 06:34:31 -0600200 .cmd_ctrl = omap1_nand_cmd_ctl,
Ladislav Michl414f552a2009-12-11 16:16:33 -0800201 .dev_ready = nand_dev_ready,
202 },
Brian Swetland495f71d2006-06-26 16:16:03 -0700203};
204
205static struct resource nand_resource = {
206 .start = OMAP_CS3_PHYS,
207 .end = OMAP_CS3_PHYS + SZ_4K - 1,
208 .flags = IORESOURCE_MEM,
209};
210
211static struct platform_device nand_device = {
Ladislav Michl414f552a2009-12-11 16:16:33 -0800212 .name = "gen_nand",
Brian Swetland495f71d2006-06-26 16:16:03 -0700213 .id = 0,
214 .dev = {
215 .platform_data = &nand_data,
216 },
217 .num_resources = 1,
218 .resource = &nand_resource,
219};
220
221static struct platform_device smc91x_device = {
222 .name = "smc91x",
223 .id = 0,
Ladislav Michl3bc48012009-12-11 16:16:33 -0800224 .dev = {
225 .platform_data = &smc91x_info,
226 },
Brian Swetland495f71d2006-06-26 16:16:03 -0700227 .num_resources = ARRAY_SIZE(smc91x_resources),
228 .resource = smc91x_resources,
229};
230
231static struct resource kp_resources[] = {
232 [0] = {
Alistair Buxton372b1c32009-09-18 04:09:39 +0100233 .start = INT_7XX_MPUIO_KEYPAD,
234 .end = INT_7XX_MPUIO_KEYPAD,
Brian Swetland495f71d2006-06-26 16:16:03 -0700235 .flags = IORESOURCE_IRQ,
236 },
237};
238
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000239static const struct matrix_keymap_data fsample_keymap_data = {
240 .keymap = fsample_keymap,
241 .keymap_size = ARRAY_SIZE(fsample_keymap),
242};
243
Brian Swetland495f71d2006-06-26 16:16:03 -0700244static struct omap_kp_platform_data kp_data = {
Komal Shah4d246072006-09-29 01:59:20 -0700245 .rows = 8,
246 .cols = 8,
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000247 .keymap_data = &fsample_keymap_data,
Komal Shah4d246072006-09-29 01:59:20 -0700248 .delay = 4,
Brian Swetland495f71d2006-06-26 16:16:03 -0700249};
250
251static struct platform_device kp_device = {
252 .name = "omap-keypad",
253 .id = -1,
254 .dev = {
255 .platform_data = &kp_data,
256 },
257 .num_resources = ARRAY_SIZE(kp_resources),
258 .resource = kp_resources,
259};
260
Brian Swetland495f71d2006-06-26 16:16:03 -0700261static struct platform_device *devices[] __initdata = {
262 &nor_device,
263 &nand_device,
264 &smc91x_device,
265 &kp_device,
Brian Swetland495f71d2006-06-26 16:16:03 -0700266};
267
Bhumika Goyald25c70c2017-08-22 11:55:50 +0530268static const struct omap_lcd_config fsample_lcd_config = {
Brian Swetland495f71d2006-06-26 16:16:03 -0700269 .ctrl_name = "internal",
270};
271
Brian Swetland495f71d2006-06-26 16:16:03 -0700272static void __init omap_fsample_init(void)
273{
Brian Swetland495f71d2006-06-26 16:16:03 -0700274 /* Early, board-dependent init */
275
276 /*
277 * Hold GSM Reset until needed
278 */
Alistair Buxtonb51988d2009-09-22 07:34:13 +0100279 omap_writew(omap_readw(OMAP7XX_DSP_M_CTL) & ~1, OMAP7XX_DSP_M_CTL);
Brian Swetland495f71d2006-06-26 16:16:03 -0700280
281 /*
282 * UARTs -> done automagically by 8250 driver
283 */
284
285 /*
286 * CSx timings, GPIO Mux ... setup
287 */
288
289 /* Flash: CS0 timings setup */
Alistair Buxtonb51988d2009-09-22 07:34:13 +0100290 omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_0);
291 omap_writel(0x00000088, OMAP7XX_FLASH_ACFG_0);
Brian Swetland495f71d2006-06-26 16:16:03 -0700292
293 /*
294 * Ethernet support through the debug board
295 * CS1 timings setup
296 */
Alistair Buxtonb51988d2009-09-22 07:34:13 +0100297 omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_1);
298 omap_writel(0x00000000, OMAP7XX_FLASH_ACFG_1);
Brian Swetland495f71d2006-06-26 16:16:03 -0700299
300 /*
301 * Configure MPU_EXT_NIRQ IO in IO_CONF9 register,
302 * It is used as the Ethernet controller interrupt
303 */
Tony Lindgren7b88e622011-10-05 15:14:02 -0700304 omap_writel(omap_readl(OMAP7XX_IO_CONF_9) & 0x1FFFFFFF,
305 OMAP7XX_IO_CONF_9);
306
307 fsample_init_smc91x();
308
Sasha Levin04494102012-11-08 15:23:09 -0500309 BUG_ON(gpio_request(FSAMPLE_NAND_RB_GPIO_PIN, "NAND ready") < 0);
Tony Lindgren7b88e622011-10-05 15:14:02 -0700310 gpio_direction_input(FSAMPLE_NAND_RB_GPIO_PIN);
311
312 omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
313 omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
314
315 /* Mux pins for keypad */
316 omap_cfg_reg(E2_7XX_KBR0);
317 omap_cfg_reg(J7_7XX_KBR1);
318 omap_cfg_reg(E1_7XX_KBR2);
319 omap_cfg_reg(F3_7XX_KBR3);
320 omap_cfg_reg(D2_7XX_KBR4);
321 omap_cfg_reg(C2_7XX_KBC0);
322 omap_cfg_reg(D3_7XX_KBC1);
323 omap_cfg_reg(E4_7XX_KBC2);
324 omap_cfg_reg(F4_7XX_KBC3);
325 omap_cfg_reg(E3_7XX_KBC4);
326
327 platform_add_devices(devices, ARRAY_SIZE(devices));
328
Tony Lindgren7b88e622011-10-05 15:14:02 -0700329 omap_serial_init();
330 omap_register_i2c_bus(1, 100, NULL, 0);
Tomi Valkeinenddba6c72011-09-20 15:23:13 +0300331
332 omapfb_set_lcd_config(&fsample_lcd_config);
Tony Lindgren7b88e622011-10-05 15:14:02 -0700333}
334
335/* Only FPGA needs to be mapped here. All others are done with ioremap */
336static struct map_desc omap_fsample_io_desc[] __initdata = {
337 {
338 .virtual = H2P2_DBG_FPGA_BASE,
339 .pfn = __phys_to_pfn(H2P2_DBG_FPGA_START),
340 .length = H2P2_DBG_FPGA_SIZE,
341 .type = MT_DEVICE
342 },
343 {
344 .virtual = FSAMPLE_CPLD_BASE,
345 .pfn = __phys_to_pfn(FSAMPLE_CPLD_START),
346 .length = FSAMPLE_CPLD_SIZE,
347 .type = MT_DEVICE
348 }
349};
350
351static void __init omap_fsample_map_io(void)
352{
353 omap15xx_map_io();
354 iotable_init(omap_fsample_io_desc,
355 ARRAY_SIZE(omap_fsample_io_desc));
Brian Swetland495f71d2006-06-26 16:16:03 -0700356}
357
358MACHINE_START(OMAP_FSAMPLE, "OMAP730 F-Sample")
359/* Maintainer: Brian Swetland <swetland@google.com> */
Nicolas Pitre246e3892011-07-05 22:38:15 -0400360 .atag_offset = 0x100,
Brian Swetland495f71d2006-06-26 16:16:03 -0700361 .map_io = omap_fsample_map_io,
Tony Lindgren7b88e622011-10-05 15:14:02 -0700362 .init_early = omap1_init_early,
Tony Lindgren7b88e622011-10-05 15:14:02 -0700363 .init_irq = omap1_init_irq,
Tony Lindgrenb6943312015-05-20 09:01:21 -0700364 .handle_irq = omap1_handle_irq,
Brian Swetland495f71d2006-06-26 16:16:03 -0700365 .init_machine = omap_fsample_init,
Shawn Guo82c3bd02012-04-26 13:49:29 +0800366 .init_late = omap1_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700367 .init_time = omap1_timer_init,
Russell Kingbaa95882011-11-05 17:06:28 +0000368 .restart = omap1_restart,
Brian Swetland495f71d2006-06-26 16:16:03 -0700369MACHINE_END