blob: 4f240760d4aa0c1a9a8c6955849f644584aea646 [file] [log] [blame]
Thomas Gleixner1d0ea062019-05-29 16:57:46 -07001// SPDX-License-Identifier: GPL-2.0-only
Eric Miao01215e32009-03-20 13:33:49 +08002/*
3 * linux/arch/arm/mach-mmp/ttc_dkb.c
4 *
5 * Support for the Marvell PXA910-based TTC_DKB Development Platform.
Eric Miao01215e32009-03-20 13:33:49 +08006 */
7
8#include <linux/init.h>
9#include <linux/kernel.h>
10#include <linux/platform_device.h>
Haojian Zhuangd6587c32009-09-23 01:57:35 +080011#include <linux/mtd/mtd.h>
12#include <linux/mtd/partitions.h>
13#include <linux/mtd/onenand.h>
Haojian Zhuang0bd86962010-09-08 09:42:42 -040014#include <linux/interrupt.h>
Vivien Didelot58774572013-08-29 15:24:14 -040015#include <linux/platform_data/pca953x.h>
Haojian Zhuange04eb142011-04-01 10:39:28 +080016#include <linux/gpio.h>
Haojian Zhuangb8f649f2013-04-09 18:12:04 +080017#include <linux/gpio-pxa.h>
Chao Xief4466942012-05-07 11:24:00 +080018#include <linux/mfd/88pm860x.h>
Neil Zhang673eef92012-05-03 14:19:14 +080019#include <linux/platform_data/mv_usb.h>
Zhou Zhu74a014f2013-02-21 16:42:21 -080020#include <linux/spi/spi.h>
21#include <linux/delay.h>
Eric Miao01215e32009-03-20 13:33:49 +080022
23#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
Haojian Zhuangd6587c32009-09-23 01:57:35 +080025#include <asm/mach/flash.h>
Arnd Bergmannb501fd72014-04-15 20:38:32 +020026#include "addr-map.h"
27#include "mfp-pxa910.h"
28#include "pxa910.h"
29#include "irqs.h"
30#include "regs-usb.h"
Eric Miao01215e32009-03-20 13:33:49 +080031
32#include "common.h"
33
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +080034#define TTCDKB_GPIO_EXT0(x) (MMP_NR_BUILTIN_GPIO + ((x < 0) ? 0 : \
Haojian Zhuange04eb142011-04-01 10:39:28 +080035 ((x < 16) ? x : 15)))
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +080036#define TTCDKB_GPIO_EXT1(x) (MMP_NR_BUILTIN_GPIO + 16 + ((x < 0) ? 0 : \
Haojian Zhuange04eb142011-04-01 10:39:28 +080037 ((x < 16) ? x : 15)))
38
39/*
40 * 16 board interrupts -- MAX7312 GPIO expander
41 * 16 board interrupts -- PCA9575 GPIO expander
42 * 24 board interrupts -- 88PM860x PMIC
43 */
Rob Herring8661fb92012-01-03 16:50:40 -060044#define TTCDKB_NR_IRQS (MMP_NR_IRQS + 16 + 16 + 24)
Haojian Zhuang0bd86962010-09-08 09:42:42 -040045
Eric Miao01215e32009-03-20 13:33:49 +080046static unsigned long ttc_dkb_pin_config[] __initdata = {
47 /* UART2 */
48 GPIO47_UART2_RXD,
49 GPIO48_UART2_TXD,
Haojian Zhuangd6587c32009-09-23 01:57:35 +080050
51 /* DFI */
52 DF_IO0_ND_IO0,
53 DF_IO1_ND_IO1,
54 DF_IO2_ND_IO2,
55 DF_IO3_ND_IO3,
56 DF_IO4_ND_IO4,
57 DF_IO5_ND_IO5,
58 DF_IO6_ND_IO6,
59 DF_IO7_ND_IO7,
60 DF_IO8_ND_IO8,
61 DF_IO9_ND_IO9,
62 DF_IO10_ND_IO10,
63 DF_IO11_ND_IO11,
64 DF_IO12_ND_IO12,
65 DF_IO13_ND_IO13,
66 DF_IO14_ND_IO14,
67 DF_IO15_ND_IO15,
68 DF_nCS0_SM_nCS2_nCS0,
69 DF_ALE_SM_WEn_ND_ALE,
70 DF_CLE_SM_OEn_ND_CLE,
71 DF_WEn_DF_WEn,
72 DF_REn_DF_REn,
73 DF_RDY0_DF_RDY0,
74};
75
Haojian Zhuangb8f649f2013-04-09 18:12:04 +080076static struct pxa_gpio_platform_data pxa910_gpio_pdata = {
77 .irq_base = MMP_GPIO_TO_IRQ(0),
78};
79
Haojian Zhuangd6587c32009-09-23 01:57:35 +080080static struct mtd_partition ttc_dkb_onenand_partitions[] = {
81 {
82 .name = "bootloader",
83 .offset = 0,
84 .size = SZ_1M,
85 .mask_flags = MTD_WRITEABLE,
86 }, {
87 .name = "reserved",
88 .offset = MTDPART_OFS_APPEND,
89 .size = SZ_128K,
90 .mask_flags = MTD_WRITEABLE,
91 }, {
92 .name = "reserved",
93 .offset = MTDPART_OFS_APPEND,
94 .size = SZ_8M,
95 .mask_flags = MTD_WRITEABLE,
96 }, {
97 .name = "kernel",
98 .offset = MTDPART_OFS_APPEND,
99 .size = (SZ_2M + SZ_1M),
100 .mask_flags = 0,
101 }, {
102 .name = "filesystem",
103 .offset = MTDPART_OFS_APPEND,
Stephen Boyd3f8e2882011-07-26 18:45:54 +0100104 .size = SZ_32M + SZ_16M,
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800105 .mask_flags = 0,
106 }
107};
108
Haojian Zhuangd6223872009-11-20 10:57:16 -0500109static struct onenand_platform_data ttc_dkb_onenand_info = {
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800110 .parts = ttc_dkb_onenand_partitions,
111 .nr_parts = ARRAY_SIZE(ttc_dkb_onenand_partitions),
112};
113
114static struct resource ttc_dkb_resource_onenand[] = {
115 [0] = {
116 .start = SMC_CS0_PHYS_BASE,
117 .end = SMC_CS0_PHYS_BASE + SZ_1M,
118 .flags = IORESOURCE_MEM,
119 },
120};
121
122static struct platform_device ttc_dkb_device_onenand = {
123 .name = "onenand-flash",
124 .id = -1,
125 .resource = ttc_dkb_resource_onenand,
126 .num_resources = ARRAY_SIZE(ttc_dkb_resource_onenand),
127 .dev = {
128 .platform_data = &ttc_dkb_onenand_info,
129 },
130};
131
132static struct platform_device *ttc_dkb_devices[] = {
Haojian Zhuang157d2642011-10-17 20:37:52 +0800133 &pxa910_device_gpio,
Haojian Zhuang4128e272012-02-23 23:37:33 +0800134 &pxa910_device_rtc,
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800135 &ttc_dkb_device_onenand,
Eric Miao01215e32009-03-20 13:33:49 +0800136};
137
Haojian Zhuange04eb142011-04-01 10:39:28 +0800138static struct pca953x_platform_data max7312_data[] = {
139 {
140 .gpio_base = TTCDKB_GPIO_EXT0(0),
Rob Herring8661fb92012-01-03 16:50:40 -0600141 .irq_base = MMP_NR_IRQS,
Haojian Zhuange04eb142011-04-01 10:39:28 +0800142 },
143};
144
Chao Xief4466942012-05-07 11:24:00 +0800145static struct pm860x_platform_data ttc_dkb_pm8607_info = {
146 .irq_base = IRQ_BOARD_START,
147};
148
Haojian Zhuange04eb142011-04-01 10:39:28 +0800149static struct i2c_board_info ttc_dkb_i2c_info[] = {
150 {
Chao Xief4466942012-05-07 11:24:00 +0800151 .type = "88PM860x",
152 .addr = 0x34,
153 .platform_data = &ttc_dkb_pm8607_info,
154 .irq = IRQ_PXA910_PMIC_INT,
155 },
156 {
Haojian Zhuange04eb142011-04-01 10:39:28 +0800157 .type = "max7312",
158 .addr = 0x23,
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +0800159 .irq = MMP_GPIO_TO_IRQ(80),
Haojian Zhuange04eb142011-04-01 10:39:28 +0800160 .platform_data = &max7312_data,
161 },
162};
163
Arnd Bergmann35240802014-03-12 15:29:22 +0100164#if IS_ENABLED(CONFIG_USB_SUPPORT)
165#if IS_ENABLED(CONFIG_USB_MV_UDC) || IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
Neil Zhang673eef92012-05-03 14:19:14 +0800166
Neil Zhang673eef92012-05-03 14:19:14 +0800167static struct mv_usb_platform_data ttc_usb_pdata = {
Neil Zhang673eef92012-05-03 14:19:14 +0800168 .vbus = NULL,
169 .mode = MV_USB_MODE_OTG,
170 .otg_force_a_bus_req = 1,
171 .phy_init = pxa_usb_phy_init,
172 .phy_deinit = pxa_usb_phy_deinit,
173 .set_vbus = NULL,
174};
175#endif
176#endif
177
Miquel Raynal349dfe62018-02-19 23:35:52 +0100178#if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
Miquel Raynal75765942018-02-19 23:35:54 +0100179static struct pxa3xx_nand_platform_data dkb_nand_info = {};
Lei Wen0f74da32012-07-30 21:59:41 +0800180#endif
181
Arnd Bergmann35240802014-03-12 15:29:22 +0100182#if IS_ENABLED(CONFIG_MMP_DISP)
Zhou Zhu74a014f2013-02-21 16:42:21 -0800183/* path config */
184#define CFG_IOPADMODE(iopad) (iopad) /* 0x0 ~ 0xd */
185#define SCLK_SOURCE_SELECT(x) (x << 30) /* 0x0 ~ 0x3 */
186/* link config */
187#define CFG_DUMBMODE(mode) (mode << 28) /* 0x0 ~ 0x6*/
Zhou Zhu74a014f2013-02-21 16:42:21 -0800188static struct mmp_mach_path_config dkb_disp_config[] = {
189 [0] = {
190 .name = "mmp-parallel",
191 .overlay_num = 2,
192 .output_type = PATH_OUT_PARALLEL,
193 .path_config = CFG_IOPADMODE(0x1)
194 | SCLK_SOURCE_SELECT(0x1),
Jett.Zhou7ebdc782013-09-13 14:59:46 +0800195 .link_config = CFG_DUMBMODE(0x2),
Zhou Zhu74a014f2013-02-21 16:42:21 -0800196 },
197};
198
199static struct mmp_mach_plat_info dkb_disp_info = {
200 .name = "mmp-disp",
201 .clk_name = "disp0",
202 .path_num = 1,
203 .paths = dkb_disp_config,
204};
205
206static struct mmp_buffer_driver_mach_info dkb_fb_info = {
207 .name = "mmp-fb",
208 .path_name = "mmp-parallel",
209 .overlay_id = 0,
210 .dmafetch_id = 1,
211 .default_pixfmt = PIXFMT_RGB565,
212};
213
214static void dkb_tpo_panel_power(int on)
215{
216 int err;
217 u32 spi_reset = mfp_to_gpio(MFP_PIN_GPIO106);
218
219 if (on) {
220 err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
221 if (err) {
222 pr_err("failed to request GPIO for TPO LCD RESET\n");
223 return;
224 }
225 gpio_direction_output(spi_reset, 0);
226 udelay(100);
227 gpio_set_value(spi_reset, 1);
228 gpio_free(spi_reset);
229 } else {
230 err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
231 if (err) {
232 pr_err("failed to request LCD RESET gpio\n");
233 return;
234 }
235 gpio_set_value(spi_reset, 0);
236 gpio_free(spi_reset);
237 }
238}
239
240static struct mmp_mach_panel_info dkb_tpo_panel_info = {
241 .name = "tpo-hvga",
242 .plat_path_name = "mmp-parallel",
243 .plat_set_onoff = dkb_tpo_panel_power,
244};
245
246static struct spi_board_info spi_board_info[] __initdata = {
247 {
248 .modalias = "tpo-hvga",
249 .platform_data = &dkb_tpo_panel_info,
250 .bus_num = 5,
251 }
252};
253
254static void __init add_disp(void)
255{
256 pxa_register_device(&pxa910_device_disp,
257 &dkb_disp_info, sizeof(dkb_disp_info));
258 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
259 pxa_register_device(&pxa910_device_fb,
260 &dkb_fb_info, sizeof(dkb_fb_info));
261 pxa_register_device(&pxa910_device_panel,
262 &dkb_tpo_panel_info, sizeof(dkb_tpo_panel_info));
263}
264#endif
265
Eric Miao01215e32009-03-20 13:33:49 +0800266static void __init ttc_dkb_init(void)
267{
268 mfp_config(ARRAY_AND_SIZE(ttc_dkb_pin_config));
269
270 /* on-chip devices */
271 pxa910_add_uart(1);
Miquel Raynal349dfe62018-02-19 23:35:52 +0100272#if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
Lei Wen0f74da32012-07-30 21:59:41 +0800273 pxa910_add_nand(&dkb_nand_info);
274#endif
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800275
276 /* off-chip devices */
Haojian Zhuange04eb142011-04-01 10:39:28 +0800277 pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info));
Haojian Zhuangb8f649f2013-04-09 18:12:04 +0800278 platform_device_add_data(&pxa910_device_gpio, &pxa910_gpio_pdata,
279 sizeof(struct pxa_gpio_platform_data));
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800280 platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
Neil Zhang673eef92012-05-03 14:19:14 +0800281
Arnd Bergmann5d3e11c2018-12-10 21:43:02 +0100282#if IS_ENABLED(CONFIG_USB_SUPPORT)
Lubomir Rintele47feed2018-11-28 18:53:22 +0100283#if IS_ENABLED(CONFIG_PHY_PXA_USB)
284 platform_device_register(&pxa168_device_usb_phy);
285#endif
286
Arnd Bergmann35240802014-03-12 15:29:22 +0100287#if IS_ENABLED(CONFIG_USB_MV_UDC)
Neil Zhang673eef92012-05-03 14:19:14 +0800288 pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
289 platform_device_register(&pxa168_device_u2o);
290#endif
291
Arnd Bergmann35240802014-03-12 15:29:22 +0100292#if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
Neil Zhang673eef92012-05-03 14:19:14 +0800293 pxa168_device_u2oehci.dev.platform_data = &ttc_usb_pdata;
294 platform_device_register(&pxa168_device_u2oehci);
295#endif
296
Arnd Bergmann35240802014-03-12 15:29:22 +0100297#if IS_ENABLED(CONFIG_USB_MV_OTG)
Neil Zhang673eef92012-05-03 14:19:14 +0800298 pxa168_device_u2ootg.dev.platform_data = &ttc_usb_pdata;
299 platform_device_register(&pxa168_device_u2ootg);
300#endif
Arnd Bergmann5d3e11c2018-12-10 21:43:02 +0100301#endif
Zhou Zhu74a014f2013-02-21 16:42:21 -0800302
Arnd Bergmann35240802014-03-12 15:29:22 +0100303#if IS_ENABLED(CONFIG_MMP_DISP)
Zhou Zhu74a014f2013-02-21 16:42:21 -0800304 add_disp();
305#endif
Eric Miao01215e32009-03-20 13:33:49 +0800306}
307
308MACHINE_START(TTC_DKB, "PXA910-based TTC_DKB Development Platform")
Eric Miao80228872010-07-15 17:50:13 +0800309 .map_io = mmp_map_io,
Haojian Zhuang0bd86962010-09-08 09:42:42 -0400310 .nr_irqs = TTCDKB_NR_IRQS,
Eric Miao01215e32009-03-20 13:33:49 +0800311 .init_irq = pxa910_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700312 .init_time = pxa910_timer_init,
Eric Miao01215e32009-03-20 13:33:49 +0800313 .init_machine = ttc_dkb_init,
Russell King9854a382011-11-05 15:40:09 +0000314 .restart = mmp_restart,
Eric Miao01215e32009-03-20 13:33:49 +0800315MACHINE_END