blob: 767dcb23ee1cd18b001d3ec4d750a83099c256bc [file] [log] [blame]
Eric Miao01215e32009-03-20 13:33:49 +08001/*
2 * linux/arch/arm/mach-mmp/ttc_dkb.c
3 *
4 * Support for the Marvell PXA910-based TTC_DKB Development Platform.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * publishhed by the Free Software Foundation.
9 */
10
11#include <linux/init.h>
12#include <linux/kernel.h>
13#include <linux/platform_device.h>
Haojian Zhuangd6587c32009-09-23 01:57:35 +080014#include <linux/mtd/mtd.h>
15#include <linux/mtd/partitions.h>
16#include <linux/mtd/onenand.h>
Haojian Zhuang0bd86962010-09-08 09:42:42 -040017#include <linux/interrupt.h>
Vivien Didelot58774572013-08-29 15:24:14 -040018#include <linux/platform_data/pca953x.h>
Haojian Zhuange04eb142011-04-01 10:39:28 +080019#include <linux/gpio.h>
Haojian Zhuangb8f649f2013-04-09 18:12:04 +080020#include <linux/gpio-pxa.h>
Chao Xief4466942012-05-07 11:24:00 +080021#include <linux/mfd/88pm860x.h>
Neil Zhang673eef92012-05-03 14:19:14 +080022#include <linux/platform_data/mv_usb.h>
Zhou Zhu74a014f2013-02-21 16:42:21 -080023#include <linux/spi/spi.h>
24#include <linux/delay.h>
Eric Miao01215e32009-03-20 13:33:49 +080025
26#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
Haojian Zhuangd6587c32009-09-23 01:57:35 +080028#include <asm/mach/flash.h>
Arnd Bergmannb501fd72014-04-15 20:38:32 +020029#include "addr-map.h"
30#include "mfp-pxa910.h"
31#include "pxa910.h"
32#include "irqs.h"
33#include "regs-usb.h"
Eric Miao01215e32009-03-20 13:33:49 +080034
35#include "common.h"
36
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +080037#define TTCDKB_GPIO_EXT0(x) (MMP_NR_BUILTIN_GPIO + ((x < 0) ? 0 : \
Haojian Zhuange04eb142011-04-01 10:39:28 +080038 ((x < 16) ? x : 15)))
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +080039#define TTCDKB_GPIO_EXT1(x) (MMP_NR_BUILTIN_GPIO + 16 + ((x < 0) ? 0 : \
Haojian Zhuange04eb142011-04-01 10:39:28 +080040 ((x < 16) ? x : 15)))
41
42/*
43 * 16 board interrupts -- MAX7312 GPIO expander
44 * 16 board interrupts -- PCA9575 GPIO expander
45 * 24 board interrupts -- 88PM860x PMIC
46 */
Rob Herring8661fb92012-01-03 16:50:40 -060047#define TTCDKB_NR_IRQS (MMP_NR_IRQS + 16 + 16 + 24)
Haojian Zhuang0bd86962010-09-08 09:42:42 -040048
Eric Miao01215e32009-03-20 13:33:49 +080049static unsigned long ttc_dkb_pin_config[] __initdata = {
50 /* UART2 */
51 GPIO47_UART2_RXD,
52 GPIO48_UART2_TXD,
Haojian Zhuangd6587c32009-09-23 01:57:35 +080053
54 /* DFI */
55 DF_IO0_ND_IO0,
56 DF_IO1_ND_IO1,
57 DF_IO2_ND_IO2,
58 DF_IO3_ND_IO3,
59 DF_IO4_ND_IO4,
60 DF_IO5_ND_IO5,
61 DF_IO6_ND_IO6,
62 DF_IO7_ND_IO7,
63 DF_IO8_ND_IO8,
64 DF_IO9_ND_IO9,
65 DF_IO10_ND_IO10,
66 DF_IO11_ND_IO11,
67 DF_IO12_ND_IO12,
68 DF_IO13_ND_IO13,
69 DF_IO14_ND_IO14,
70 DF_IO15_ND_IO15,
71 DF_nCS0_SM_nCS2_nCS0,
72 DF_ALE_SM_WEn_ND_ALE,
73 DF_CLE_SM_OEn_ND_CLE,
74 DF_WEn_DF_WEn,
75 DF_REn_DF_REn,
76 DF_RDY0_DF_RDY0,
77};
78
Haojian Zhuangb8f649f2013-04-09 18:12:04 +080079static struct pxa_gpio_platform_data pxa910_gpio_pdata = {
80 .irq_base = MMP_GPIO_TO_IRQ(0),
81};
82
Haojian Zhuangd6587c32009-09-23 01:57:35 +080083static struct mtd_partition ttc_dkb_onenand_partitions[] = {
84 {
85 .name = "bootloader",
86 .offset = 0,
87 .size = SZ_1M,
88 .mask_flags = MTD_WRITEABLE,
89 }, {
90 .name = "reserved",
91 .offset = MTDPART_OFS_APPEND,
92 .size = SZ_128K,
93 .mask_flags = MTD_WRITEABLE,
94 }, {
95 .name = "reserved",
96 .offset = MTDPART_OFS_APPEND,
97 .size = SZ_8M,
98 .mask_flags = MTD_WRITEABLE,
99 }, {
100 .name = "kernel",
101 .offset = MTDPART_OFS_APPEND,
102 .size = (SZ_2M + SZ_1M),
103 .mask_flags = 0,
104 }, {
105 .name = "filesystem",
106 .offset = MTDPART_OFS_APPEND,
Stephen Boyd3f8e2882011-07-26 18:45:54 +0100107 .size = SZ_32M + SZ_16M,
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800108 .mask_flags = 0,
109 }
110};
111
Haojian Zhuangd6223872009-11-20 10:57:16 -0500112static struct onenand_platform_data ttc_dkb_onenand_info = {
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800113 .parts = ttc_dkb_onenand_partitions,
114 .nr_parts = ARRAY_SIZE(ttc_dkb_onenand_partitions),
115};
116
117static struct resource ttc_dkb_resource_onenand[] = {
118 [0] = {
119 .start = SMC_CS0_PHYS_BASE,
120 .end = SMC_CS0_PHYS_BASE + SZ_1M,
121 .flags = IORESOURCE_MEM,
122 },
123};
124
125static struct platform_device ttc_dkb_device_onenand = {
126 .name = "onenand-flash",
127 .id = -1,
128 .resource = ttc_dkb_resource_onenand,
129 .num_resources = ARRAY_SIZE(ttc_dkb_resource_onenand),
130 .dev = {
131 .platform_data = &ttc_dkb_onenand_info,
132 },
133};
134
135static struct platform_device *ttc_dkb_devices[] = {
Haojian Zhuang157d2642011-10-17 20:37:52 +0800136 &pxa910_device_gpio,
Haojian Zhuang4128e272012-02-23 23:37:33 +0800137 &pxa910_device_rtc,
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800138 &ttc_dkb_device_onenand,
Eric Miao01215e32009-03-20 13:33:49 +0800139};
140
Haojian Zhuange04eb142011-04-01 10:39:28 +0800141static struct pca953x_platform_data max7312_data[] = {
142 {
143 .gpio_base = TTCDKB_GPIO_EXT0(0),
Rob Herring8661fb92012-01-03 16:50:40 -0600144 .irq_base = MMP_NR_IRQS,
Haojian Zhuange04eb142011-04-01 10:39:28 +0800145 },
146};
147
Chao Xief4466942012-05-07 11:24:00 +0800148static struct pm860x_platform_data ttc_dkb_pm8607_info = {
149 .irq_base = IRQ_BOARD_START,
150};
151
Haojian Zhuange04eb142011-04-01 10:39:28 +0800152static struct i2c_board_info ttc_dkb_i2c_info[] = {
153 {
Chao Xief4466942012-05-07 11:24:00 +0800154 .type = "88PM860x",
155 .addr = 0x34,
156 .platform_data = &ttc_dkb_pm8607_info,
157 .irq = IRQ_PXA910_PMIC_INT,
158 },
159 {
Haojian Zhuange04eb142011-04-01 10:39:28 +0800160 .type = "max7312",
161 .addr = 0x23,
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +0800162 .irq = MMP_GPIO_TO_IRQ(80),
Haojian Zhuange04eb142011-04-01 10:39:28 +0800163 .platform_data = &max7312_data,
164 },
165};
166
Arnd Bergmann35240802014-03-12 15:29:22 +0100167#if IS_ENABLED(CONFIG_USB_SUPPORT)
168#if IS_ENABLED(CONFIG_USB_MV_UDC) || IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
Neil Zhang673eef92012-05-03 14:19:14 +0800169
Neil Zhang673eef92012-05-03 14:19:14 +0800170static struct mv_usb_platform_data ttc_usb_pdata = {
Neil Zhang673eef92012-05-03 14:19:14 +0800171 .vbus = NULL,
172 .mode = MV_USB_MODE_OTG,
173 .otg_force_a_bus_req = 1,
174 .phy_init = pxa_usb_phy_init,
175 .phy_deinit = pxa_usb_phy_deinit,
176 .set_vbus = NULL,
177};
178#endif
179#endif
180
Miquel Raynal349dfe62018-02-19 23:35:52 +0100181#if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
Miquel Raynal75765942018-02-19 23:35:54 +0100182static struct pxa3xx_nand_platform_data dkb_nand_info = {};
Lei Wen0f74da32012-07-30 21:59:41 +0800183#endif
184
Arnd Bergmann35240802014-03-12 15:29:22 +0100185#if IS_ENABLED(CONFIG_MMP_DISP)
Zhou Zhu74a014f2013-02-21 16:42:21 -0800186/* path config */
187#define CFG_IOPADMODE(iopad) (iopad) /* 0x0 ~ 0xd */
188#define SCLK_SOURCE_SELECT(x) (x << 30) /* 0x0 ~ 0x3 */
189/* link config */
190#define CFG_DUMBMODE(mode) (mode << 28) /* 0x0 ~ 0x6*/
Zhou Zhu74a014f2013-02-21 16:42:21 -0800191static struct mmp_mach_path_config dkb_disp_config[] = {
192 [0] = {
193 .name = "mmp-parallel",
194 .overlay_num = 2,
195 .output_type = PATH_OUT_PARALLEL,
196 .path_config = CFG_IOPADMODE(0x1)
197 | SCLK_SOURCE_SELECT(0x1),
Jett.Zhou7ebdc782013-09-13 14:59:46 +0800198 .link_config = CFG_DUMBMODE(0x2),
Zhou Zhu74a014f2013-02-21 16:42:21 -0800199 },
200};
201
202static struct mmp_mach_plat_info dkb_disp_info = {
203 .name = "mmp-disp",
204 .clk_name = "disp0",
205 .path_num = 1,
206 .paths = dkb_disp_config,
207};
208
209static struct mmp_buffer_driver_mach_info dkb_fb_info = {
210 .name = "mmp-fb",
211 .path_name = "mmp-parallel",
212 .overlay_id = 0,
213 .dmafetch_id = 1,
214 .default_pixfmt = PIXFMT_RGB565,
215};
216
217static void dkb_tpo_panel_power(int on)
218{
219 int err;
220 u32 spi_reset = mfp_to_gpio(MFP_PIN_GPIO106);
221
222 if (on) {
223 err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
224 if (err) {
225 pr_err("failed to request GPIO for TPO LCD RESET\n");
226 return;
227 }
228 gpio_direction_output(spi_reset, 0);
229 udelay(100);
230 gpio_set_value(spi_reset, 1);
231 gpio_free(spi_reset);
232 } else {
233 err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
234 if (err) {
235 pr_err("failed to request LCD RESET gpio\n");
236 return;
237 }
238 gpio_set_value(spi_reset, 0);
239 gpio_free(spi_reset);
240 }
241}
242
243static struct mmp_mach_panel_info dkb_tpo_panel_info = {
244 .name = "tpo-hvga",
245 .plat_path_name = "mmp-parallel",
246 .plat_set_onoff = dkb_tpo_panel_power,
247};
248
249static struct spi_board_info spi_board_info[] __initdata = {
250 {
251 .modalias = "tpo-hvga",
252 .platform_data = &dkb_tpo_panel_info,
253 .bus_num = 5,
254 }
255};
256
257static void __init add_disp(void)
258{
259 pxa_register_device(&pxa910_device_disp,
260 &dkb_disp_info, sizeof(dkb_disp_info));
261 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
262 pxa_register_device(&pxa910_device_fb,
263 &dkb_fb_info, sizeof(dkb_fb_info));
264 pxa_register_device(&pxa910_device_panel,
265 &dkb_tpo_panel_info, sizeof(dkb_tpo_panel_info));
266}
267#endif
268
Eric Miao01215e32009-03-20 13:33:49 +0800269static void __init ttc_dkb_init(void)
270{
271 mfp_config(ARRAY_AND_SIZE(ttc_dkb_pin_config));
272
273 /* on-chip devices */
274 pxa910_add_uart(1);
Miquel Raynal349dfe62018-02-19 23:35:52 +0100275#if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
Lei Wen0f74da32012-07-30 21:59:41 +0800276 pxa910_add_nand(&dkb_nand_info);
277#endif
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800278
279 /* off-chip devices */
Haojian Zhuange04eb142011-04-01 10:39:28 +0800280 pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info));
Haojian Zhuangb8f649f2013-04-09 18:12:04 +0800281 platform_device_add_data(&pxa910_device_gpio, &pxa910_gpio_pdata,
282 sizeof(struct pxa_gpio_platform_data));
Haojian Zhuangd6587c32009-09-23 01:57:35 +0800283 platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
Neil Zhang673eef92012-05-03 14:19:14 +0800284
Lubomir Rintele47feed2018-11-28 18:53:22 +0100285#if IS_ENABLED(CONFIG_PHY_PXA_USB)
286 platform_device_register(&pxa168_device_usb_phy);
287#endif
288
Arnd Bergmann35240802014-03-12 15:29:22 +0100289#if IS_ENABLED(CONFIG_USB_MV_UDC)
Neil Zhang673eef92012-05-03 14:19:14 +0800290 pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
291 platform_device_register(&pxa168_device_u2o);
292#endif
293
Arnd Bergmann35240802014-03-12 15:29:22 +0100294#if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
Neil Zhang673eef92012-05-03 14:19:14 +0800295 pxa168_device_u2oehci.dev.platform_data = &ttc_usb_pdata;
296 platform_device_register(&pxa168_device_u2oehci);
297#endif
298
Arnd Bergmann35240802014-03-12 15:29:22 +0100299#if IS_ENABLED(CONFIG_USB_MV_OTG)
Neil Zhang673eef92012-05-03 14:19:14 +0800300 pxa168_device_u2ootg.dev.platform_data = &ttc_usb_pdata;
301 platform_device_register(&pxa168_device_u2ootg);
302#endif
Zhou Zhu74a014f2013-02-21 16:42:21 -0800303
Arnd Bergmann35240802014-03-12 15:29:22 +0100304#if IS_ENABLED(CONFIG_MMP_DISP)
Zhou Zhu74a014f2013-02-21 16:42:21 -0800305 add_disp();
306#endif
Eric Miao01215e32009-03-20 13:33:49 +0800307}
308
309MACHINE_START(TTC_DKB, "PXA910-based TTC_DKB Development Platform")
Eric Miao80228872010-07-15 17:50:13 +0800310 .map_io = mmp_map_io,
Haojian Zhuang0bd86962010-09-08 09:42:42 -0400311 .nr_irqs = TTCDKB_NR_IRQS,
Eric Miao01215e32009-03-20 13:33:49 +0800312 .init_irq = pxa910_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700313 .init_time = pxa910_timer_init,
Eric Miao01215e32009-03-20 13:33:49 +0800314 .init_machine = ttc_dkb_init,
Russell King9854a382011-11-05 15:40:09 +0000315 .restart = mmp_restart,
Eric Miao01215e32009-03-20 13:33:49 +0800316MACHINE_END