Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 1 | /* |
| 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 Zhuang | d6587c3 | 2009-09-23 01:57:35 +0800 | [diff] [blame] | 14 | #include <linux/mtd/mtd.h> |
| 15 | #include <linux/mtd/partitions.h> |
| 16 | #include <linux/mtd/onenand.h> |
Haojian Zhuang | 0bd8696 | 2010-09-08 09:42:42 -0400 | [diff] [blame] | 17 | #include <linux/interrupt.h> |
Haojian Zhuang | e04eb14 | 2011-04-01 10:39:28 +0800 | [diff] [blame] | 18 | #include <linux/i2c/pca953x.h> |
| 19 | #include <linux/gpio.h> |
Chao Xie | f446694 | 2012-05-07 11:24:00 +0800 | [diff] [blame] | 20 | #include <linux/mfd/88pm860x.h> |
Neil Zhang | 673eef9 | 2012-05-03 14:19:14 +0800 | [diff] [blame] | 21 | #include <linux/platform_data/mv_usb.h> |
Zhou Zhu | 74a014f | 2013-02-21 16:42:21 -0800 | [diff] [blame^] | 22 | #include <linux/spi/spi.h> |
| 23 | #include <linux/delay.h> |
Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 24 | |
| 25 | #include <asm/mach-types.h> |
| 26 | #include <asm/mach/arch.h> |
Haojian Zhuang | d6587c3 | 2009-09-23 01:57:35 +0800 | [diff] [blame] | 27 | #include <asm/mach/flash.h> |
Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 28 | #include <mach/addr-map.h> |
| 29 | #include <mach/mfp-pxa910.h> |
| 30 | #include <mach/pxa910.h> |
Haojian Zhuang | 1a8d5fa | 2011-11-08 14:15:59 +0800 | [diff] [blame] | 31 | #include <mach/irqs.h> |
Neil Zhang | 673eef9 | 2012-05-03 14:19:14 +0800 | [diff] [blame] | 32 | #include <mach/regs-usb.h> |
Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 33 | |
| 34 | #include "common.h" |
| 35 | |
Haojian Zhuang | 1a8d5fa | 2011-11-08 14:15:59 +0800 | [diff] [blame] | 36 | #define TTCDKB_GPIO_EXT0(x) (MMP_NR_BUILTIN_GPIO + ((x < 0) ? 0 : \ |
Haojian Zhuang | e04eb14 | 2011-04-01 10:39:28 +0800 | [diff] [blame] | 37 | ((x < 16) ? x : 15))) |
Haojian Zhuang | 1a8d5fa | 2011-11-08 14:15:59 +0800 | [diff] [blame] | 38 | #define TTCDKB_GPIO_EXT1(x) (MMP_NR_BUILTIN_GPIO + 16 + ((x < 0) ? 0 : \ |
Haojian Zhuang | e04eb14 | 2011-04-01 10:39:28 +0800 | [diff] [blame] | 39 | ((x < 16) ? x : 15))) |
| 40 | |
| 41 | /* |
| 42 | * 16 board interrupts -- MAX7312 GPIO expander |
| 43 | * 16 board interrupts -- PCA9575 GPIO expander |
| 44 | * 24 board interrupts -- 88PM860x PMIC |
| 45 | */ |
Rob Herring | 8661fb9 | 2012-01-03 16:50:40 -0600 | [diff] [blame] | 46 | #define TTCDKB_NR_IRQS (MMP_NR_IRQS + 16 + 16 + 24) |
Haojian Zhuang | 0bd8696 | 2010-09-08 09:42:42 -0400 | [diff] [blame] | 47 | |
Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 48 | static unsigned long ttc_dkb_pin_config[] __initdata = { |
| 49 | /* UART2 */ |
| 50 | GPIO47_UART2_RXD, |
| 51 | GPIO48_UART2_TXD, |
Haojian Zhuang | d6587c3 | 2009-09-23 01:57:35 +0800 | [diff] [blame] | 52 | |
| 53 | /* DFI */ |
| 54 | DF_IO0_ND_IO0, |
| 55 | DF_IO1_ND_IO1, |
| 56 | DF_IO2_ND_IO2, |
| 57 | DF_IO3_ND_IO3, |
| 58 | DF_IO4_ND_IO4, |
| 59 | DF_IO5_ND_IO5, |
| 60 | DF_IO6_ND_IO6, |
| 61 | DF_IO7_ND_IO7, |
| 62 | DF_IO8_ND_IO8, |
| 63 | DF_IO9_ND_IO9, |
| 64 | DF_IO10_ND_IO10, |
| 65 | DF_IO11_ND_IO11, |
| 66 | DF_IO12_ND_IO12, |
| 67 | DF_IO13_ND_IO13, |
| 68 | DF_IO14_ND_IO14, |
| 69 | DF_IO15_ND_IO15, |
| 70 | DF_nCS0_SM_nCS2_nCS0, |
| 71 | DF_ALE_SM_WEn_ND_ALE, |
| 72 | DF_CLE_SM_OEn_ND_CLE, |
| 73 | DF_WEn_DF_WEn, |
| 74 | DF_REn_DF_REn, |
| 75 | DF_RDY0_DF_RDY0, |
| 76 | }; |
| 77 | |
| 78 | static struct mtd_partition ttc_dkb_onenand_partitions[] = { |
| 79 | { |
| 80 | .name = "bootloader", |
| 81 | .offset = 0, |
| 82 | .size = SZ_1M, |
| 83 | .mask_flags = MTD_WRITEABLE, |
| 84 | }, { |
| 85 | .name = "reserved", |
| 86 | .offset = MTDPART_OFS_APPEND, |
| 87 | .size = SZ_128K, |
| 88 | .mask_flags = MTD_WRITEABLE, |
| 89 | }, { |
| 90 | .name = "reserved", |
| 91 | .offset = MTDPART_OFS_APPEND, |
| 92 | .size = SZ_8M, |
| 93 | .mask_flags = MTD_WRITEABLE, |
| 94 | }, { |
| 95 | .name = "kernel", |
| 96 | .offset = MTDPART_OFS_APPEND, |
| 97 | .size = (SZ_2M + SZ_1M), |
| 98 | .mask_flags = 0, |
| 99 | }, { |
| 100 | .name = "filesystem", |
| 101 | .offset = MTDPART_OFS_APPEND, |
Stephen Boyd | 3f8e288 | 2011-07-26 18:45:54 +0100 | [diff] [blame] | 102 | .size = SZ_32M + SZ_16M, |
Haojian Zhuang | d6587c3 | 2009-09-23 01:57:35 +0800 | [diff] [blame] | 103 | .mask_flags = 0, |
| 104 | } |
| 105 | }; |
| 106 | |
Haojian Zhuang | d622387 | 2009-11-20 10:57:16 -0500 | [diff] [blame] | 107 | static struct onenand_platform_data ttc_dkb_onenand_info = { |
Haojian Zhuang | d6587c3 | 2009-09-23 01:57:35 +0800 | [diff] [blame] | 108 | .parts = ttc_dkb_onenand_partitions, |
| 109 | .nr_parts = ARRAY_SIZE(ttc_dkb_onenand_partitions), |
| 110 | }; |
| 111 | |
| 112 | static struct resource ttc_dkb_resource_onenand[] = { |
| 113 | [0] = { |
| 114 | .start = SMC_CS0_PHYS_BASE, |
| 115 | .end = SMC_CS0_PHYS_BASE + SZ_1M, |
| 116 | .flags = IORESOURCE_MEM, |
| 117 | }, |
| 118 | }; |
| 119 | |
| 120 | static struct platform_device ttc_dkb_device_onenand = { |
| 121 | .name = "onenand-flash", |
| 122 | .id = -1, |
| 123 | .resource = ttc_dkb_resource_onenand, |
| 124 | .num_resources = ARRAY_SIZE(ttc_dkb_resource_onenand), |
| 125 | .dev = { |
| 126 | .platform_data = &ttc_dkb_onenand_info, |
| 127 | }, |
| 128 | }; |
| 129 | |
| 130 | static struct platform_device *ttc_dkb_devices[] = { |
Haojian Zhuang | 157d264 | 2011-10-17 20:37:52 +0800 | [diff] [blame] | 131 | &pxa910_device_gpio, |
Haojian Zhuang | 4128e27 | 2012-02-23 23:37:33 +0800 | [diff] [blame] | 132 | &pxa910_device_rtc, |
Haojian Zhuang | d6587c3 | 2009-09-23 01:57:35 +0800 | [diff] [blame] | 133 | &ttc_dkb_device_onenand, |
Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 134 | }; |
| 135 | |
Haojian Zhuang | e04eb14 | 2011-04-01 10:39:28 +0800 | [diff] [blame] | 136 | static struct pca953x_platform_data max7312_data[] = { |
| 137 | { |
| 138 | .gpio_base = TTCDKB_GPIO_EXT0(0), |
Rob Herring | 8661fb9 | 2012-01-03 16:50:40 -0600 | [diff] [blame] | 139 | .irq_base = MMP_NR_IRQS, |
Haojian Zhuang | e04eb14 | 2011-04-01 10:39:28 +0800 | [diff] [blame] | 140 | }, |
| 141 | }; |
| 142 | |
Chao Xie | f446694 | 2012-05-07 11:24:00 +0800 | [diff] [blame] | 143 | static struct pm860x_platform_data ttc_dkb_pm8607_info = { |
| 144 | .irq_base = IRQ_BOARD_START, |
| 145 | }; |
| 146 | |
Haojian Zhuang | e04eb14 | 2011-04-01 10:39:28 +0800 | [diff] [blame] | 147 | static struct i2c_board_info ttc_dkb_i2c_info[] = { |
| 148 | { |
Chao Xie | f446694 | 2012-05-07 11:24:00 +0800 | [diff] [blame] | 149 | .type = "88PM860x", |
| 150 | .addr = 0x34, |
| 151 | .platform_data = &ttc_dkb_pm8607_info, |
| 152 | .irq = IRQ_PXA910_PMIC_INT, |
| 153 | }, |
| 154 | { |
Haojian Zhuang | e04eb14 | 2011-04-01 10:39:28 +0800 | [diff] [blame] | 155 | .type = "max7312", |
| 156 | .addr = 0x23, |
Haojian Zhuang | 1a8d5fa | 2011-11-08 14:15:59 +0800 | [diff] [blame] | 157 | .irq = MMP_GPIO_TO_IRQ(80), |
Haojian Zhuang | e04eb14 | 2011-04-01 10:39:28 +0800 | [diff] [blame] | 158 | .platform_data = &max7312_data, |
| 159 | }, |
| 160 | }; |
| 161 | |
Neil Zhang | 673eef9 | 2012-05-03 14:19:14 +0800 | [diff] [blame] | 162 | #ifdef CONFIG_USB_SUPPORT |
| 163 | #if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV_U2O) |
| 164 | |
| 165 | static char *pxa910_usb_clock_name[] = { |
| 166 | [0] = "U2OCLK", |
| 167 | }; |
| 168 | |
| 169 | static struct mv_usb_platform_data ttc_usb_pdata = { |
| 170 | .clknum = 1, |
| 171 | .clkname = pxa910_usb_clock_name, |
| 172 | .vbus = NULL, |
| 173 | .mode = MV_USB_MODE_OTG, |
| 174 | .otg_force_a_bus_req = 1, |
| 175 | .phy_init = pxa_usb_phy_init, |
| 176 | .phy_deinit = pxa_usb_phy_deinit, |
| 177 | .set_vbus = NULL, |
| 178 | }; |
| 179 | #endif |
| 180 | #endif |
| 181 | |
Lei Wen | 0f74da3 | 2012-07-30 21:59:41 +0800 | [diff] [blame] | 182 | #ifdef CONFIG_MTD_NAND_PXA3xx |
| 183 | static struct pxa3xx_nand_platform_data dkb_nand_info = { |
| 184 | .enable_arbiter = 1, |
| 185 | .num_cs = 1, |
| 186 | }; |
| 187 | #endif |
| 188 | |
Zhou Zhu | 74a014f | 2013-02-21 16:42:21 -0800 | [diff] [blame^] | 189 | #ifdef CONFIG_MMP_DISP |
| 190 | /* path config */ |
| 191 | #define CFG_IOPADMODE(iopad) (iopad) /* 0x0 ~ 0xd */ |
| 192 | #define SCLK_SOURCE_SELECT(x) (x << 30) /* 0x0 ~ 0x3 */ |
| 193 | /* link config */ |
| 194 | #define CFG_DUMBMODE(mode) (mode << 28) /* 0x0 ~ 0x6*/ |
| 195 | #define CFG_GRA_SWAPRB(x) (x << 0) /* 1: rbswap enabled */ |
| 196 | static struct mmp_mach_path_config dkb_disp_config[] = { |
| 197 | [0] = { |
| 198 | .name = "mmp-parallel", |
| 199 | .overlay_num = 2, |
| 200 | .output_type = PATH_OUT_PARALLEL, |
| 201 | .path_config = CFG_IOPADMODE(0x1) |
| 202 | | SCLK_SOURCE_SELECT(0x1), |
| 203 | .link_config = CFG_DUMBMODE(0x2) |
| 204 | | CFG_GRA_SWAPRB(0x1), |
| 205 | }, |
| 206 | }; |
| 207 | |
| 208 | static struct mmp_mach_plat_info dkb_disp_info = { |
| 209 | .name = "mmp-disp", |
| 210 | .clk_name = "disp0", |
| 211 | .path_num = 1, |
| 212 | .paths = dkb_disp_config, |
| 213 | }; |
| 214 | |
| 215 | static struct mmp_buffer_driver_mach_info dkb_fb_info = { |
| 216 | .name = "mmp-fb", |
| 217 | .path_name = "mmp-parallel", |
| 218 | .overlay_id = 0, |
| 219 | .dmafetch_id = 1, |
| 220 | .default_pixfmt = PIXFMT_RGB565, |
| 221 | }; |
| 222 | |
| 223 | static void dkb_tpo_panel_power(int on) |
| 224 | { |
| 225 | int err; |
| 226 | u32 spi_reset = mfp_to_gpio(MFP_PIN_GPIO106); |
| 227 | |
| 228 | if (on) { |
| 229 | err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET"); |
| 230 | if (err) { |
| 231 | pr_err("failed to request GPIO for TPO LCD RESET\n"); |
| 232 | return; |
| 233 | } |
| 234 | gpio_direction_output(spi_reset, 0); |
| 235 | udelay(100); |
| 236 | gpio_set_value(spi_reset, 1); |
| 237 | gpio_free(spi_reset); |
| 238 | } else { |
| 239 | err = gpio_request(spi_reset, "TPO_LCD_SPI_RESET"); |
| 240 | if (err) { |
| 241 | pr_err("failed to request LCD RESET gpio\n"); |
| 242 | return; |
| 243 | } |
| 244 | gpio_set_value(spi_reset, 0); |
| 245 | gpio_free(spi_reset); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | static struct mmp_mach_panel_info dkb_tpo_panel_info = { |
| 250 | .name = "tpo-hvga", |
| 251 | .plat_path_name = "mmp-parallel", |
| 252 | .plat_set_onoff = dkb_tpo_panel_power, |
| 253 | }; |
| 254 | |
| 255 | static struct spi_board_info spi_board_info[] __initdata = { |
| 256 | { |
| 257 | .modalias = "tpo-hvga", |
| 258 | .platform_data = &dkb_tpo_panel_info, |
| 259 | .bus_num = 5, |
| 260 | } |
| 261 | }; |
| 262 | |
| 263 | static void __init add_disp(void) |
| 264 | { |
| 265 | pxa_register_device(&pxa910_device_disp, |
| 266 | &dkb_disp_info, sizeof(dkb_disp_info)); |
| 267 | spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); |
| 268 | pxa_register_device(&pxa910_device_fb, |
| 269 | &dkb_fb_info, sizeof(dkb_fb_info)); |
| 270 | pxa_register_device(&pxa910_device_panel, |
| 271 | &dkb_tpo_panel_info, sizeof(dkb_tpo_panel_info)); |
| 272 | } |
| 273 | #endif |
| 274 | |
Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 275 | static void __init ttc_dkb_init(void) |
| 276 | { |
| 277 | mfp_config(ARRAY_AND_SIZE(ttc_dkb_pin_config)); |
| 278 | |
| 279 | /* on-chip devices */ |
| 280 | pxa910_add_uart(1); |
Lei Wen | 0f74da3 | 2012-07-30 21:59:41 +0800 | [diff] [blame] | 281 | #ifdef CONFIG_MTD_NAND_PXA3xx |
| 282 | pxa910_add_nand(&dkb_nand_info); |
| 283 | #endif |
Haojian Zhuang | d6587c3 | 2009-09-23 01:57:35 +0800 | [diff] [blame] | 284 | |
| 285 | /* off-chip devices */ |
Haojian Zhuang | e04eb14 | 2011-04-01 10:39:28 +0800 | [diff] [blame] | 286 | pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info)); |
Haojian Zhuang | d6587c3 | 2009-09-23 01:57:35 +0800 | [diff] [blame] | 287 | platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices)); |
Neil Zhang | 673eef9 | 2012-05-03 14:19:14 +0800 | [diff] [blame] | 288 | |
| 289 | #ifdef CONFIG_USB_MV_UDC |
| 290 | pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata; |
| 291 | platform_device_register(&pxa168_device_u2o); |
| 292 | #endif |
| 293 | |
| 294 | #ifdef CONFIG_USB_EHCI_MV_U2O |
| 295 | pxa168_device_u2oehci.dev.platform_data = &ttc_usb_pdata; |
| 296 | platform_device_register(&pxa168_device_u2oehci); |
| 297 | #endif |
| 298 | |
| 299 | #ifdef CONFIG_USB_MV_OTG |
| 300 | pxa168_device_u2ootg.dev.platform_data = &ttc_usb_pdata; |
| 301 | platform_device_register(&pxa168_device_u2ootg); |
| 302 | #endif |
Zhou Zhu | 74a014f | 2013-02-21 16:42:21 -0800 | [diff] [blame^] | 303 | |
| 304 | #ifdef CONFIG_MMP_DISP |
| 305 | add_disp(); |
| 306 | #endif |
Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | MACHINE_START(TTC_DKB, "PXA910-based TTC_DKB Development Platform") |
Eric Miao | 8022887 | 2010-07-15 17:50:13 +0800 | [diff] [blame] | 310 | .map_io = mmp_map_io, |
Haojian Zhuang | 0bd8696 | 2010-09-08 09:42:42 -0400 | [diff] [blame] | 311 | .nr_irqs = TTCDKB_NR_IRQS, |
Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 312 | .init_irq = pxa910_init_irq, |
| 313 | .timer = &pxa910_timer, |
| 314 | .init_machine = ttc_dkb_init, |
Russell King | 9854a38 | 2011-11-05 15:40:09 +0000 | [diff] [blame] | 315 | .restart = mmp_restart, |
Eric Miao | 01215e3 | 2009-03-20 13:33:49 +0800 | [diff] [blame] | 316 | MACHINE_END |