1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-mmp/ttc_dkb.c
5 * Support for the Marvell PXA910-based TTC_DKB Development Platform.
8 #include <linux/init.h>
9 #include <linux/kernel.h>
10 #include <linux/platform_device.h>
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/mtd/onenand.h>
14 #include <linux/interrupt.h>
15 #include <linux/platform_data/pca953x.h>
16 #include <linux/gpio.h>
17 #include <linux/gpio-pxa.h>
18 #include <linux/mfd/88pm860x.h>
19 #include <linux/platform_data/mv_usb.h>
20 #include <linux/spi/spi.h>
21 #include <linux/delay.h>
23 #include <asm/mach-types.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/flash.h>
27 #include "mfp-pxa910.h"
34 #define TTCDKB_GPIO_EXT0(x) (MMP_NR_BUILTIN_GPIO + ((x < 0) ? 0 : \
36 #define TTCDKB_GPIO_EXT1(x) (MMP_NR_BUILTIN_GPIO + 16 + ((x < 0) ? 0 : \
40 * 16 board interrupts -- MAX7312 GPIO expander
41 * 16 board interrupts -- PCA9575 GPIO expander
42 * 24 board interrupts -- 88PM860x PMIC
44 #define TTCDKB_NR_IRQS (MMP_NR_IRQS + 16 + 16 + 24)
46 static unsigned long ttc_dkb_pin_config
[] __initdata
= {
76 static struct pxa_gpio_platform_data pxa910_gpio_pdata
= {
77 .irq_base
= MMP_GPIO_TO_IRQ(0),
80 static struct mtd_partition ttc_dkb_onenand_partitions
[] = {
85 .mask_flags
= MTD_WRITEABLE
,
88 .offset
= MTDPART_OFS_APPEND
,
90 .mask_flags
= MTD_WRITEABLE
,
93 .offset
= MTDPART_OFS_APPEND
,
95 .mask_flags
= MTD_WRITEABLE
,
98 .offset
= MTDPART_OFS_APPEND
,
99 .size
= (SZ_2M
+ SZ_1M
),
102 .name
= "filesystem",
103 .offset
= MTDPART_OFS_APPEND
,
104 .size
= SZ_32M
+ SZ_16M
,
109 static struct onenand_platform_data ttc_dkb_onenand_info
= {
110 .parts
= ttc_dkb_onenand_partitions
,
111 .nr_parts
= ARRAY_SIZE(ttc_dkb_onenand_partitions
),
114 static struct resource ttc_dkb_resource_onenand
[] = {
116 .start
= SMC_CS0_PHYS_BASE
,
117 .end
= SMC_CS0_PHYS_BASE
+ SZ_1M
,
118 .flags
= IORESOURCE_MEM
,
122 static struct platform_device ttc_dkb_device_onenand
= {
123 .name
= "onenand-flash",
125 .resource
= ttc_dkb_resource_onenand
,
126 .num_resources
= ARRAY_SIZE(ttc_dkb_resource_onenand
),
128 .platform_data
= &ttc_dkb_onenand_info
,
132 static struct platform_device
*ttc_dkb_devices
[] = {
135 &ttc_dkb_device_onenand
,
138 static struct pca953x_platform_data max7312_data
[] = {
140 .gpio_base
= TTCDKB_GPIO_EXT0(0),
141 .irq_base
= MMP_NR_IRQS
,
145 static struct pm860x_platform_data ttc_dkb_pm8607_info
= {
146 .irq_base
= IRQ_BOARD_START
,
149 static struct i2c_board_info ttc_dkb_i2c_info
[] = {
153 .platform_data
= &ttc_dkb_pm8607_info
,
154 .irq
= IRQ_PXA910_PMIC_INT
,
159 .irq
= MMP_GPIO_TO_IRQ(80),
160 .platform_data
= &max7312_data
,
164 #if IS_ENABLED(CONFIG_USB_SUPPORT)
165 #if IS_ENABLED(CONFIG_USB_MV_UDC) || IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
167 static struct mv_usb_platform_data ttc_usb_pdata
= {
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
,
178 #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
179 static struct pxa3xx_nand_platform_data dkb_nand_info
= {};
182 #if IS_ENABLED(CONFIG_MMP_DISP)
184 #define CFG_IOPADMODE(iopad) (iopad) /* 0x0 ~ 0xd */
185 #define SCLK_SOURCE_SELECT(x) (x << 30) /* 0x0 ~ 0x3 */
187 #define CFG_DUMBMODE(mode) (mode << 28) /* 0x0 ~ 0x6*/
188 static struct mmp_mach_path_config dkb_disp_config
[] = {
190 .name
= "mmp-parallel",
192 .output_type
= PATH_OUT_PARALLEL
,
193 .path_config
= CFG_IOPADMODE(0x1)
194 | SCLK_SOURCE_SELECT(0x1),
195 .link_config
= CFG_DUMBMODE(0x2),
199 static struct mmp_mach_plat_info dkb_disp_info
= {
203 .paths
= dkb_disp_config
,
206 static struct mmp_buffer_driver_mach_info dkb_fb_info
= {
208 .path_name
= "mmp-parallel",
211 .default_pixfmt
= PIXFMT_RGB565
,
214 static void dkb_tpo_panel_power(int on
)
217 u32 spi_reset
= mfp_to_gpio(MFP_PIN_GPIO106
);
220 err
= gpio_request(spi_reset
, "TPO_LCD_SPI_RESET");
222 pr_err("failed to request GPIO for TPO LCD RESET\n");
225 gpio_direction_output(spi_reset
, 0);
227 gpio_set_value(spi_reset
, 1);
228 gpio_free(spi_reset
);
230 err
= gpio_request(spi_reset
, "TPO_LCD_SPI_RESET");
232 pr_err("failed to request LCD RESET gpio\n");
235 gpio_set_value(spi_reset
, 0);
236 gpio_free(spi_reset
);
240 static struct mmp_mach_panel_info dkb_tpo_panel_info
= {
242 .plat_path_name
= "mmp-parallel",
243 .plat_set_onoff
= dkb_tpo_panel_power
,
246 static struct spi_board_info spi_board_info
[] __initdata
= {
248 .modalias
= "tpo-hvga",
249 .platform_data
= &dkb_tpo_panel_info
,
254 static void __init
add_disp(void)
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
));
266 static void __init
ttc_dkb_init(void)
268 mfp_config(ARRAY_AND_SIZE(ttc_dkb_pin_config
));
270 /* on-chip devices */
272 #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
273 pxa910_add_nand(&dkb_nand_info
);
276 /* off-chip devices */
277 pxa910_add_twsi(0, NULL
, ARRAY_AND_SIZE(ttc_dkb_i2c_info
));
278 platform_device_add_data(&pxa910_device_gpio
, &pxa910_gpio_pdata
,
279 sizeof(struct pxa_gpio_platform_data
));
280 platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices
));
282 #if IS_ENABLED(CONFIG_USB_SUPPORT)
283 #if IS_ENABLED(CONFIG_PHY_PXA_USB)
284 platform_device_register(&pxa168_device_usb_phy
);
287 #if IS_ENABLED(CONFIG_USB_MV_UDC)
288 pxa168_device_u2o
.dev
.platform_data
= &ttc_usb_pdata
;
289 platform_device_register(&pxa168_device_u2o
);
292 #if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
293 pxa168_device_u2oehci
.dev
.platform_data
= &ttc_usb_pdata
;
294 platform_device_register(&pxa168_device_u2oehci
);
297 #if IS_ENABLED(CONFIG_USB_MV_OTG)
298 pxa168_device_u2ootg
.dev
.platform_data
= &ttc_usb_pdata
;
299 platform_device_register(&pxa168_device_u2ootg
);
303 #if IS_ENABLED(CONFIG_MMP_DISP)
308 MACHINE_START(TTC_DKB
, "PXA910-based TTC_DKB Development Platform")
309 .map_io
= mmp_map_io
,
310 .nr_irqs
= TTCDKB_NR_IRQS
,
311 .init_irq
= pxa910_init_irq
,
312 .init_time
= pxa910_timer_init
,
313 .init_machine
= ttc_dkb_init
,
314 .restart
= mmp_restart
,