0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/init.h>
0009 #include <linux/kernel.h>
0010 #include <linux/platform_device.h>
0011 #include <linux/mtd/mtd.h>
0012 #include <linux/mtd/partitions.h>
0013 #include <linux/mtd/onenand.h>
0014 #include <linux/interrupt.h>
0015 #include <linux/platform_data/pca953x.h>
0016 #include <linux/gpio.h>
0017 #include <linux/gpio-pxa.h>
0018 #include <linux/mfd/88pm860x.h>
0019 #include <linux/platform_data/mv_usb.h>
0020 #include <linux/spi/spi.h>
0021 #include <linux/delay.h>
0022
0023 #include <asm/mach-types.h>
0024 #include <asm/mach/arch.h>
0025 #include <asm/mach/flash.h>
0026 #include "addr-map.h"
0027 #include "mfp-pxa910.h"
0028 #include "pxa910.h"
0029 #include "irqs.h"
0030 #include "regs-usb.h"
0031
0032 #include "common.h"
0033
0034 #define TTCDKB_GPIO_EXT0(x) (MMP_NR_BUILTIN_GPIO + ((x < 0) ? 0 : \
0035 ((x < 16) ? x : 15)))
0036 #define TTCDKB_GPIO_EXT1(x) (MMP_NR_BUILTIN_GPIO + 16 + ((x < 0) ? 0 : \
0037 ((x < 16) ? x : 15)))
0038
0039
0040
0041
0042
0043
0044 #define TTCDKB_NR_IRQS (MMP_NR_IRQS + 16 + 16 + 24)
0045
0046 static unsigned long ttc_dkb_pin_config[] __initdata = {
0047
0048 GPIO47_UART2_RXD,
0049 GPIO48_UART2_TXD,
0050
0051
0052 DF_IO0_ND_IO0,
0053 DF_IO1_ND_IO1,
0054 DF_IO2_ND_IO2,
0055 DF_IO3_ND_IO3,
0056 DF_IO4_ND_IO4,
0057 DF_IO5_ND_IO5,
0058 DF_IO6_ND_IO6,
0059 DF_IO7_ND_IO7,
0060 DF_IO8_ND_IO8,
0061 DF_IO9_ND_IO9,
0062 DF_IO10_ND_IO10,
0063 DF_IO11_ND_IO11,
0064 DF_IO12_ND_IO12,
0065 DF_IO13_ND_IO13,
0066 DF_IO14_ND_IO14,
0067 DF_IO15_ND_IO15,
0068 DF_nCS0_SM_nCS2_nCS0,
0069 DF_ALE_SM_WEn_ND_ALE,
0070 DF_CLE_SM_OEn_ND_CLE,
0071 DF_WEn_DF_WEn,
0072 DF_REn_DF_REn,
0073 DF_RDY0_DF_RDY0,
0074 };
0075
0076 static struct pxa_gpio_platform_data pxa910_gpio_pdata = {
0077 .irq_base = MMP_GPIO_TO_IRQ(0),
0078 };
0079
0080 static struct mtd_partition ttc_dkb_onenand_partitions[] = {
0081 {
0082 .name = "bootloader",
0083 .offset = 0,
0084 .size = SZ_1M,
0085 .mask_flags = MTD_WRITEABLE,
0086 }, {
0087 .name = "reserved",
0088 .offset = MTDPART_OFS_APPEND,
0089 .size = SZ_128K,
0090 .mask_flags = MTD_WRITEABLE,
0091 }, {
0092 .name = "reserved",
0093 .offset = MTDPART_OFS_APPEND,
0094 .size = SZ_8M,
0095 .mask_flags = MTD_WRITEABLE,
0096 }, {
0097 .name = "kernel",
0098 .offset = MTDPART_OFS_APPEND,
0099 .size = (SZ_2M + SZ_1M),
0100 .mask_flags = 0,
0101 }, {
0102 .name = "filesystem",
0103 .offset = MTDPART_OFS_APPEND,
0104 .size = SZ_32M + SZ_16M,
0105 .mask_flags = 0,
0106 }
0107 };
0108
0109 static struct onenand_platform_data ttc_dkb_onenand_info = {
0110 .parts = ttc_dkb_onenand_partitions,
0111 .nr_parts = ARRAY_SIZE(ttc_dkb_onenand_partitions),
0112 };
0113
0114 static struct resource ttc_dkb_resource_onenand[] = {
0115 [0] = {
0116 .start = SMC_CS0_PHYS_BASE,
0117 .end = SMC_CS0_PHYS_BASE + SZ_1M,
0118 .flags = IORESOURCE_MEM,
0119 },
0120 };
0121
0122 static struct platform_device ttc_dkb_device_onenand = {
0123 .name = "onenand-flash",
0124 .id = -1,
0125 .resource = ttc_dkb_resource_onenand,
0126 .num_resources = ARRAY_SIZE(ttc_dkb_resource_onenand),
0127 .dev = {
0128 .platform_data = &ttc_dkb_onenand_info,
0129 },
0130 };
0131
0132 static struct platform_device *ttc_dkb_devices[] = {
0133 &pxa910_device_gpio,
0134 &pxa910_device_rtc,
0135 &ttc_dkb_device_onenand,
0136 };
0137
0138 static struct pca953x_platform_data max7312_data[] = {
0139 {
0140 .gpio_base = TTCDKB_GPIO_EXT0(0),
0141 .irq_base = MMP_NR_IRQS,
0142 },
0143 };
0144
0145 static struct pm860x_platform_data ttc_dkb_pm8607_info = {
0146 .irq_base = IRQ_BOARD_START,
0147 };
0148
0149 static struct i2c_board_info ttc_dkb_i2c_info[] = {
0150 {
0151 .type = "88PM860x",
0152 .addr = 0x34,
0153 .platform_data = &ttc_dkb_pm8607_info,
0154 .irq = IRQ_PXA910_PMIC_INT,
0155 },
0156 {
0157 .type = "max7312",
0158 .addr = 0x23,
0159 .irq = MMP_GPIO_TO_IRQ(80),
0160 .platform_data = &max7312_data,
0161 },
0162 };
0163
0164 #if IS_ENABLED(CONFIG_USB_SUPPORT)
0165 #if IS_ENABLED(CONFIG_USB_MV_UDC) || IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
0166
0167 static struct mv_usb_platform_data ttc_usb_pdata = {
0168 .vbus = NULL,
0169 .mode = MV_USB_MODE_OTG,
0170 .otg_force_a_bus_req = 1,
0171 .phy_init = pxa_usb_phy_init,
0172 .phy_deinit = pxa_usb_phy_deinit,
0173 .set_vbus = NULL,
0174 };
0175 #endif
0176 #endif
0177
0178 #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
0179 static struct pxa3xx_nand_platform_data dkb_nand_info = {};
0180 #endif
0181
0182 #if IS_ENABLED(CONFIG_MMP_DISP)
0183
0184 #define CFG_IOPADMODE(iopad) (iopad)
0185 #define SCLK_SOURCE_SELECT(x) (x << 30)
0186
0187 #define CFG_DUMBMODE(mode) (mode << 28)
0188 static struct mmp_mach_path_config dkb_disp_config[] = {
0189 [0] = {
0190 .name = "mmp-parallel",
0191 .overlay_num = 2,
0192 .output_type = PATH_OUT_PARALLEL,
0193 .path_config = CFG_IOPADMODE(0x1)
0194 | SCLK_SOURCE_SELECT(0x1),
0195 .link_config = CFG_DUMBMODE(0x2),
0196 },
0197 };
0198
0199 static struct mmp_mach_plat_info dkb_disp_info = {
0200 .name = "mmp-disp",
0201 .clk_name = "disp0",
0202 .path_num = 1,
0203 .paths = dkb_disp_config,
0204 };
0205
0206 static struct mmp_buffer_driver_mach_info dkb_fb_info = {
0207 .name = "mmp-fb",
0208 .path_name = "mmp-parallel",
0209 .overlay_id = 0,
0210 .dmafetch_id = 1,
0211 .default_pixfmt = PIXFMT_RGB565,
0212 };
0213
0214 static void dkb_tpo_panel_power(int on)
0215 {
0216 int err;
0217 u32 spi_reset = mfp_to_gpio(MFP_PIN_GPIO106);
0218
0219 if (on) {
0220 err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
0221 if (err) {
0222 pr_err("failed to request GPIO for TPO LCD RESET\n");
0223 return;
0224 }
0225 gpio_direction_output(spi_reset, 0);
0226 udelay(100);
0227 gpio_set_value(spi_reset, 1);
0228 gpio_free(spi_reset);
0229 } else {
0230 err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET");
0231 if (err) {
0232 pr_err("failed to request LCD RESET gpio\n");
0233 return;
0234 }
0235 gpio_set_value(spi_reset, 0);
0236 gpio_free(spi_reset);
0237 }
0238 }
0239
0240 static struct mmp_mach_panel_info dkb_tpo_panel_info = {
0241 .name = "tpo-hvga",
0242 .plat_path_name = "mmp-parallel",
0243 .plat_set_onoff = dkb_tpo_panel_power,
0244 };
0245
0246 static struct spi_board_info spi_board_info[] __initdata = {
0247 {
0248 .modalias = "tpo-hvga",
0249 .platform_data = &dkb_tpo_panel_info,
0250 .bus_num = 5,
0251 }
0252 };
0253
0254 static void __init add_disp(void)
0255 {
0256 mmp_register_device(&pxa910_device_disp,
0257 &dkb_disp_info, sizeof(dkb_disp_info));
0258 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
0259 mmp_register_device(&pxa910_device_fb,
0260 &dkb_fb_info, sizeof(dkb_fb_info));
0261 mmp_register_device(&pxa910_device_panel,
0262 &dkb_tpo_panel_info, sizeof(dkb_tpo_panel_info));
0263 }
0264 #endif
0265
0266 static void __init ttc_dkb_init(void)
0267 {
0268 mfp_config(ARRAY_AND_SIZE(ttc_dkb_pin_config));
0269
0270
0271 pxa910_add_uart(1);
0272 #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
0273 pxa910_add_nand(&dkb_nand_info);
0274 #endif
0275
0276
0277 pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info));
0278 platform_device_add_data(&pxa910_device_gpio, &pxa910_gpio_pdata,
0279 sizeof(struct pxa_gpio_platform_data));
0280 platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
0281
0282 #if IS_ENABLED(CONFIG_USB_SUPPORT)
0283 #if IS_ENABLED(CONFIG_PHY_PXA_USB)
0284 platform_device_register(&pxa168_device_usb_phy);
0285 #endif
0286
0287 #if IS_ENABLED(CONFIG_USB_MV_UDC)
0288 pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
0289 platform_device_register(&pxa168_device_u2o);
0290 #endif
0291
0292 #if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
0293 pxa168_device_u2oehci.dev.platform_data = &ttc_usb_pdata;
0294 platform_device_register(&pxa168_device_u2oehci);
0295 #endif
0296
0297 #if IS_ENABLED(CONFIG_USB_MV_OTG)
0298 pxa168_device_u2ootg.dev.platform_data = &ttc_usb_pdata;
0299 platform_device_register(&pxa168_device_u2ootg);
0300 #endif
0301 #endif
0302
0303 #if IS_ENABLED(CONFIG_MMP_DISP)
0304 add_disp();
0305 #endif
0306 }
0307
0308 MACHINE_START(TTC_DKB, "PXA910-based TTC_DKB Development Platform")
0309 .map_io = mmp_map_io,
0310 .nr_irqs = TTCDKB_NR_IRQS,
0311 .init_irq = pxa910_init_irq,
0312 .init_time = pxa910_timer_init,
0313 .init_machine = ttc_dkb_init,
0314 .restart = mmp_restart,
0315 MACHINE_END