Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 1 | /* |
| 2 | * TI DaVinci EVM board support |
| 3 | * |
| 4 | * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com> |
| 5 | * |
| 6 | * 2007 (c) MontaVista Software, Inc. This file is licensed under |
| 7 | * the terms of the GNU General Public License version 2. This program |
| 8 | * is licensed "as is" without any warranty of any kind, whether express |
| 9 | * or implied. |
| 10 | */ |
| 11 | #include <linux/kernel.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 12 | #include <linux/init.h> |
| 13 | #include <linux/dma-mapping.h> |
| 14 | #include <linux/platform_device.h> |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 15 | #include <linux/gpio.h> |
Linus Walleij | e535376 | 2017-12-20 13:17:49 +0100 | [diff] [blame] | 16 | #include <linux/gpio/machine.h> |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 17 | #include <linux/i2c.h> |
Wolfram Sang | b6480fa | 2017-05-21 23:57:26 +0200 | [diff] [blame] | 18 | #include <linux/platform_data/pcf857x.h> |
Vivien Didelot | 25f73ed | 2013-09-27 15:06:28 -0400 | [diff] [blame] | 19 | #include <linux/platform_data/at24.h> |
Sekhar Nori | 9411ac0 | 2018-04-18 15:02:46 +0530 | [diff] [blame] | 20 | #include <linux/platform_data/gpio-davinci.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 21 | #include <linux/mtd/mtd.h> |
Boris Brezillon | d4092d7 | 2017-08-04 17:29:10 +0200 | [diff] [blame] | 22 | #include <linux/mtd/rawnand.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 23 | #include <linux/mtd/partitions.h> |
| 24 | #include <linux/mtd/physmap.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 25 | #include <linux/phy.h> |
| 26 | #include <linux/clk.h> |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 27 | #include <linux/videodev2.h> |
Hans Verkuil | 3686408 | 2012-10-01 11:39:46 -0300 | [diff] [blame] | 28 | #include <linux/v4l2-dv-timings.h> |
Paul Gortmaker | dc28094 | 2011-07-31 16:17:29 -0400 | [diff] [blame] | 29 | #include <linux/export.h> |
Ulf Hansson | f46f335 | 2017-01-13 14:14:03 +0100 | [diff] [blame] | 30 | #include <linux/leds.h> |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 31 | |
Mauro Carvalho Chehab | b5dcee2 | 2015-11-10 12:01:44 -0200 | [diff] [blame] | 32 | #include <media/i2c/tvp514x.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 33 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 35 | #include <asm/mach/arch.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 36 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 37 | #include <mach/common.h> |
Arnd Bergmann | ec2a083 | 2012-08-24 15:11:34 +0200 | [diff] [blame] | 38 | #include <linux/platform_data/i2c-davinci.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 39 | #include <mach/serial.h> |
| 40 | #include <mach/mux.h> |
Arnd Bergmann | ec2a083 | 2012-08-24 15:11:34 +0200 | [diff] [blame] | 41 | #include <linux/platform_data/mtd-davinci.h> |
| 42 | #include <linux/platform_data/mmc-davinci.h> |
| 43 | #include <linux/platform_data/usb-davinci.h> |
| 44 | #include <linux/platform_data/mtd-davinci-aemif.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 45 | |
Manjunath Hadli | 39c6d2d | 2011-12-21 19:13:35 +0530 | [diff] [blame] | 46 | #include "davinci.h" |
| 47 | |
Sekhar Nori | f6f9758 | 2012-01-21 02:48:17 +0530 | [diff] [blame] | 48 | #define DM644X_EVM_PHY_ID "davinci_mdio-0:01" |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 49 | #define LXT971_PHY_ID (0x001378e2) |
| 50 | #define LXT971_PHY_MASK (0xfffffff0) |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 51 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 52 | static struct mtd_partition davinci_evm_norflash_partitions[] = { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 53 | /* bootloader (UBL, U-Boot, etc) in first 5 sectors */ |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 54 | { |
| 55 | .name = "bootloader", |
| 56 | .offset = 0, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 57 | .size = 5 * SZ_64K, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 58 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 59 | }, |
| 60 | /* bootloader params in the next 1 sectors */ |
| 61 | { |
| 62 | .name = "params", |
| 63 | .offset = MTDPART_OFS_APPEND, |
| 64 | .size = SZ_64K, |
| 65 | .mask_flags = 0, |
| 66 | }, |
| 67 | /* kernel */ |
| 68 | { |
| 69 | .name = "kernel", |
| 70 | .offset = MTDPART_OFS_APPEND, |
| 71 | .size = SZ_2M, |
| 72 | .mask_flags = 0 |
| 73 | }, |
| 74 | /* file system */ |
| 75 | { |
| 76 | .name = "filesystem", |
| 77 | .offset = MTDPART_OFS_APPEND, |
| 78 | .size = MTDPART_SIZ_FULL, |
| 79 | .mask_flags = 0 |
| 80 | } |
| 81 | }; |
| 82 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 83 | static struct physmap_flash_data davinci_evm_norflash_data = { |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 84 | .width = 2, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 85 | .parts = davinci_evm_norflash_partitions, |
| 86 | .nr_parts = ARRAY_SIZE(davinci_evm_norflash_partitions), |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | /* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF |
| 90 | * limits addresses to 16M, so using addresses past 16M will wrap */ |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 91 | static struct resource davinci_evm_norflash_resource = { |
Sergei Shtylyov | 7034217 | 2010-04-16 21:29:11 +0400 | [diff] [blame] | 92 | .start = DM644X_ASYNC_EMIF_DATA_CE0_BASE, |
| 93 | .end = DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 94 | .flags = IORESOURCE_MEM, |
| 95 | }; |
| 96 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 97 | static struct platform_device davinci_evm_norflash_device = { |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 98 | .name = "physmap-flash", |
| 99 | .id = 0, |
| 100 | .dev = { |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 101 | .platform_data = &davinci_evm_norflash_data, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 102 | }, |
| 103 | .num_resources = 1, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 104 | .resource = &davinci_evm_norflash_resource, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 105 | }; |
| 106 | |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 107 | /* DM644x EVM includes a 64 MByte small-page NAND flash (16K blocks). |
| 108 | * It may used instead of the (default) NOR chip to boot, using TI's |
| 109 | * tools to install the secondary boot loader (UBL) and U-Boot. |
| 110 | */ |
Kevin Hilman | 28552c2 | 2010-02-25 15:36:38 -0800 | [diff] [blame] | 111 | static struct mtd_partition davinci_evm_nandflash_partition[] = { |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 112 | /* Bootloader layout depends on whose u-boot is installed, but we |
| 113 | * can hide all the details. |
| 114 | * - block 0 for u-boot environment ... in mainline u-boot |
| 115 | * - block 1 for UBL (plus up to four backup copies in blocks 2..5) |
| 116 | * - blocks 6...? for u-boot |
| 117 | * - blocks 16..23 for u-boot environment ... in TI's u-boot |
| 118 | */ |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 119 | { |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 120 | .name = "bootloader", |
| 121 | .offset = 0, |
| 122 | .size = SZ_256K + SZ_128K, |
| 123 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 124 | }, |
| 125 | /* Kernel */ |
| 126 | { |
| 127 | .name = "kernel", |
| 128 | .offset = MTDPART_OFS_APPEND, |
| 129 | .size = SZ_4M, |
| 130 | .mask_flags = 0, |
| 131 | }, |
| 132 | /* File system (older GIT kernels started this on the 5MB mark) */ |
| 133 | { |
| 134 | .name = "filesystem", |
| 135 | .offset = MTDPART_OFS_APPEND, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 136 | .size = MTDPART_SIZ_FULL, |
| 137 | .mask_flags = 0, |
| 138 | } |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 139 | /* A few blocks at end hold a flash BBT ... created by TI's CCS |
| 140 | * using flashwriter_nand.out, but ignored by TI's versions of |
| 141 | * Linux and u-boot. We boot faster by using them. |
| 142 | */ |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 143 | }; |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 144 | |
Sekhar Nori | fe69c82 | 2010-08-09 15:46:37 +0530 | [diff] [blame] | 145 | static struct davinci_aemif_timing davinci_evm_nandflash_timing = { |
| 146 | .wsetup = 20, |
| 147 | .wstrobe = 40, |
| 148 | .whold = 20, |
| 149 | .rsetup = 10, |
| 150 | .rstrobe = 40, |
| 151 | .rhold = 10, |
| 152 | .ta = 40, |
| 153 | }; |
| 154 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 155 | static struct davinci_nand_pdata davinci_evm_nandflash_data = { |
Bartosz Golaszewski | 040c6a0 | 2018-04-30 10:24:48 +0200 | [diff] [blame] | 156 | .core_chipsel = 0, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 157 | .parts = davinci_evm_nandflash_partition, |
| 158 | .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition), |
| 159 | .ecc_mode = NAND_ECC_HW, |
Sekhar Nori | acd3635 | 2013-08-16 14:43:48 +0530 | [diff] [blame] | 160 | .ecc_bits = 1, |
Brian Norris | bb9ebd4e | 2011-05-31 16:31:23 -0700 | [diff] [blame] | 161 | .bbt_options = NAND_BBT_USE_FLASH, |
Sekhar Nori | fe69c82 | 2010-08-09 15:46:37 +0530 | [diff] [blame] | 162 | .timing = &davinci_evm_nandflash_timing, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | static struct resource davinci_evm_nandflash_resource[] = { |
| 166 | { |
Sergei Shtylyov | 7034217 | 2010-04-16 21:29:11 +0400 | [diff] [blame] | 167 | .start = DM644X_ASYNC_EMIF_DATA_CE0_BASE, |
| 168 | .end = DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 169 | .flags = IORESOURCE_MEM, |
| 170 | }, { |
Sergei Shtylyov | 7034217 | 2010-04-16 21:29:11 +0400 | [diff] [blame] | 171 | .start = DM644X_ASYNC_EMIF_CONTROL_BASE, |
| 172 | .end = DM644X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 173 | .flags = IORESOURCE_MEM, |
| 174 | }, |
| 175 | }; |
| 176 | |
| 177 | static struct platform_device davinci_evm_nandflash_device = { |
| 178 | .name = "davinci_nand", |
| 179 | .id = 0, |
| 180 | .dev = { |
| 181 | .platform_data = &davinci_evm_nandflash_data, |
| 182 | }, |
| 183 | .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource), |
| 184 | .resource = davinci_evm_nandflash_resource, |
| 185 | }; |
| 186 | |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 187 | static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 188 | |
| 189 | static struct platform_device davinci_fb_device = { |
| 190 | .name = "davincifb", |
| 191 | .id = -1, |
| 192 | .dev = { |
| 193 | .dma_mask = &davinci_fb_dma_mask, |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 194 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 195 | }, |
| 196 | .num_resources = 0, |
| 197 | }; |
| 198 | |
Manjunath Hadli | 314d738 | 2011-12-21 19:13:38 +0530 | [diff] [blame] | 199 | static struct tvp514x_platform_data dm644xevm_tvp5146_pdata = { |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 200 | .clk_polarity = 0, |
| 201 | .hs_polarity = 1, |
| 202 | .vs_polarity = 1 |
| 203 | }; |
| 204 | |
| 205 | #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL) |
| 206 | /* Inputs available at the TVP5146 */ |
Manjunath Hadli | 314d738 | 2011-12-21 19:13:38 +0530 | [diff] [blame] | 207 | static struct v4l2_input dm644xevm_tvp5146_inputs[] = { |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 208 | { |
| 209 | .index = 0, |
| 210 | .name = "Composite", |
| 211 | .type = V4L2_INPUT_TYPE_CAMERA, |
| 212 | .std = TVP514X_STD_ALL, |
| 213 | }, |
| 214 | { |
| 215 | .index = 1, |
| 216 | .name = "S-Video", |
| 217 | .type = V4L2_INPUT_TYPE_CAMERA, |
| 218 | .std = TVP514X_STD_ALL, |
| 219 | }, |
| 220 | }; |
| 221 | |
| 222 | /* |
| 223 | * this is the route info for connecting each input to decoder |
| 224 | * ouput that goes to vpfe. There is a one to one correspondence |
| 225 | * with tvp5146_inputs |
| 226 | */ |
Manjunath Hadli | 314d738 | 2011-12-21 19:13:38 +0530 | [diff] [blame] | 227 | static struct vpfe_route dm644xevm_tvp5146_routes[] = { |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 228 | { |
| 229 | .input = INPUT_CVBS_VI2B, |
| 230 | .output = OUTPUT_10BIT_422_EMBEDDED_SYNC, |
| 231 | }, |
| 232 | { |
| 233 | .input = INPUT_SVIDEO_VI2C_VI1C, |
| 234 | .output = OUTPUT_10BIT_422_EMBEDDED_SYNC, |
| 235 | }, |
| 236 | }; |
| 237 | |
Manjunath Hadli | 314d738 | 2011-12-21 19:13:38 +0530 | [diff] [blame] | 238 | static struct vpfe_subdev_info dm644xevm_vpfe_sub_devs[] = { |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 239 | { |
| 240 | .name = "tvp5146", |
| 241 | .grp_id = 0, |
Manjunath Hadli | 314d738 | 2011-12-21 19:13:38 +0530 | [diff] [blame] | 242 | .num_inputs = ARRAY_SIZE(dm644xevm_tvp5146_inputs), |
| 243 | .inputs = dm644xevm_tvp5146_inputs, |
| 244 | .routes = dm644xevm_tvp5146_routes, |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 245 | .can_route = 1, |
| 246 | .ccdc_if_params = { |
| 247 | .if_type = VPFE_BT656, |
| 248 | .hdpol = VPFE_PINPOL_POSITIVE, |
| 249 | .vdpol = VPFE_PINPOL_POSITIVE, |
| 250 | }, |
| 251 | .board_info = { |
| 252 | I2C_BOARD_INFO("tvp5146", 0x5d), |
Manjunath Hadli | 314d738 | 2011-12-21 19:13:38 +0530 | [diff] [blame] | 253 | .platform_data = &dm644xevm_tvp5146_pdata, |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 254 | }, |
| 255 | }, |
| 256 | }; |
| 257 | |
Manjunath Hadli | 314d738 | 2011-12-21 19:13:38 +0530 | [diff] [blame] | 258 | static struct vpfe_config dm644xevm_capture_cfg = { |
| 259 | .num_subdevs = ARRAY_SIZE(dm644xevm_vpfe_sub_devs), |
Vaibhav Hiremath | 077639f | 2009-10-13 15:08:54 +0000 | [diff] [blame] | 260 | .i2c_adapter_id = 1, |
Manjunath Hadli | 314d738 | 2011-12-21 19:13:38 +0530 | [diff] [blame] | 261 | .sub_devs = dm644xevm_vpfe_sub_devs, |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 262 | .card_name = "DM6446 EVM", |
| 263 | .ccdc = "DM6446 CCDC", |
| 264 | }; |
| 265 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 266 | static struct platform_device rtc_dev = { |
| 267 | .name = "rtc_davinci_evm", |
| 268 | .id = -1, |
| 269 | }; |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 270 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 271 | /*----------------------------------------------------------------------*/ |
Arnd Bergmann | 8e58041 | 2016-02-01 21:35:58 +0100 | [diff] [blame] | 272 | #ifdef CONFIG_I2C |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 273 | /* |
| 274 | * I2C GPIO expanders |
| 275 | */ |
| 276 | |
| 277 | #define PCF_Uxx_BASE(x) (DAVINCI_N_GPIO + ((x) * 8)) |
| 278 | |
| 279 | |
| 280 | /* U2 -- LEDs */ |
| 281 | |
| 282 | static struct gpio_led evm_leds[] = { |
| 283 | { .name = "DS8", .active_low = 1, |
| 284 | .default_trigger = "heartbeat", }, |
| 285 | { .name = "DS7", .active_low = 1, }, |
| 286 | { .name = "DS6", .active_low = 1, }, |
| 287 | { .name = "DS5", .active_low = 1, }, |
| 288 | { .name = "DS4", .active_low = 1, }, |
| 289 | { .name = "DS3", .active_low = 1, }, |
| 290 | { .name = "DS2", .active_low = 1, |
| 291 | .default_trigger = "mmc0", }, |
| 292 | { .name = "DS1", .active_low = 1, |
Stephan Linz | e580822 | 2016-06-10 07:59:59 +0200 | [diff] [blame] | 293 | .default_trigger = "disk-activity", }, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | static const struct gpio_led_platform_data evm_led_data = { |
| 297 | .num_leds = ARRAY_SIZE(evm_leds), |
| 298 | .leds = evm_leds, |
| 299 | }; |
| 300 | |
| 301 | static struct platform_device *evm_led_dev; |
| 302 | |
| 303 | static int |
| 304 | evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 305 | { |
| 306 | struct gpio_led *leds = evm_leds; |
| 307 | int status; |
| 308 | |
| 309 | while (ngpio--) { |
| 310 | leds->gpio = gpio++; |
| 311 | leds++; |
| 312 | } |
| 313 | |
| 314 | /* what an extremely annoying way to be forced to handle |
| 315 | * device unregistration ... |
| 316 | */ |
| 317 | evm_led_dev = platform_device_alloc("leds-gpio", 0); |
| 318 | platform_device_add_data(evm_led_dev, |
| 319 | &evm_led_data, sizeof evm_led_data); |
| 320 | |
| 321 | evm_led_dev->dev.parent = &client->dev; |
| 322 | status = platform_device_add(evm_led_dev); |
| 323 | if (status < 0) { |
| 324 | platform_device_put(evm_led_dev); |
| 325 | evm_led_dev = NULL; |
| 326 | } |
| 327 | return status; |
| 328 | } |
| 329 | |
| 330 | static int |
| 331 | evm_led_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 332 | { |
| 333 | if (evm_led_dev) { |
| 334 | platform_device_unregister(evm_led_dev); |
| 335 | evm_led_dev = NULL; |
| 336 | } |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | static struct pcf857x_platform_data pcf_data_u2 = { |
| 341 | .gpio_base = PCF_Uxx_BASE(0), |
| 342 | .setup = evm_led_setup, |
| 343 | .teardown = evm_led_teardown, |
| 344 | }; |
| 345 | |
| 346 | |
| 347 | /* U18 - A/V clock generator and user switch */ |
| 348 | |
| 349 | static int sw_gpio; |
| 350 | |
| 351 | static ssize_t |
| 352 | sw_show(struct device *d, struct device_attribute *a, char *buf) |
| 353 | { |
| 354 | char *s = gpio_get_value_cansleep(sw_gpio) ? "on\n" : "off\n"; |
| 355 | |
| 356 | strcpy(buf, s); |
| 357 | return strlen(s); |
| 358 | } |
| 359 | |
| 360 | static DEVICE_ATTR(user_sw, S_IRUGO, sw_show, NULL); |
| 361 | |
| 362 | static int |
| 363 | evm_u18_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 364 | { |
| 365 | int status; |
| 366 | |
| 367 | /* export dip switch option */ |
| 368 | sw_gpio = gpio + 7; |
| 369 | status = gpio_request(sw_gpio, "user_sw"); |
| 370 | if (status == 0) |
| 371 | status = gpio_direction_input(sw_gpio); |
| 372 | if (status == 0) |
| 373 | status = device_create_file(&client->dev, &dev_attr_user_sw); |
| 374 | else |
| 375 | gpio_free(sw_gpio); |
| 376 | if (status != 0) |
| 377 | sw_gpio = -EINVAL; |
| 378 | |
| 379 | /* audio PLL: 48 kHz (vs 44.1 or 32), single rate (vs double) */ |
| 380 | gpio_request(gpio + 3, "pll_fs2"); |
| 381 | gpio_direction_output(gpio + 3, 0); |
| 382 | |
| 383 | gpio_request(gpio + 2, "pll_fs1"); |
| 384 | gpio_direction_output(gpio + 2, 0); |
| 385 | |
| 386 | gpio_request(gpio + 1, "pll_sr"); |
| 387 | gpio_direction_output(gpio + 1, 0); |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | static int |
| 393 | evm_u18_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 394 | { |
| 395 | gpio_free(gpio + 1); |
| 396 | gpio_free(gpio + 2); |
| 397 | gpio_free(gpio + 3); |
| 398 | |
| 399 | if (sw_gpio > 0) { |
| 400 | device_remove_file(&client->dev, &dev_attr_user_sw); |
| 401 | gpio_free(sw_gpio); |
| 402 | } |
| 403 | return 0; |
| 404 | } |
| 405 | |
| 406 | static struct pcf857x_platform_data pcf_data_u18 = { |
| 407 | .gpio_base = PCF_Uxx_BASE(1), |
| 408 | .n_latch = (1 << 3) | (1 << 2) | (1 << 1), |
| 409 | .setup = evm_u18_setup, |
| 410 | .teardown = evm_u18_teardown, |
| 411 | }; |
| 412 | |
| 413 | |
| 414 | /* U35 - various I/O signals used to manage USB, CF, ATA, etc */ |
| 415 | |
| 416 | static int |
| 417 | evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 418 | { |
| 419 | /* p0 = nDRV_VBUS (initial: don't supply it) */ |
| 420 | gpio_request(gpio + 0, "nDRV_VBUS"); |
| 421 | gpio_direction_output(gpio + 0, 1); |
| 422 | |
| 423 | /* p1 = VDDIMX_EN */ |
| 424 | gpio_request(gpio + 1, "VDDIMX_EN"); |
| 425 | gpio_direction_output(gpio + 1, 1); |
| 426 | |
| 427 | /* p2 = VLYNQ_EN */ |
| 428 | gpio_request(gpio + 2, "VLYNQ_EN"); |
| 429 | gpio_direction_output(gpio + 2, 1); |
| 430 | |
| 431 | /* p3 = n3V3_CF_RESET (initial: stay in reset) */ |
| 432 | gpio_request(gpio + 3, "nCF_RESET"); |
| 433 | gpio_direction_output(gpio + 3, 0); |
| 434 | |
| 435 | /* (p4 unused) */ |
| 436 | |
| 437 | /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */ |
| 438 | gpio_request(gpio + 5, "WLAN_RESET"); |
| 439 | gpio_direction_output(gpio + 5, 1); |
| 440 | |
| 441 | /* p6 = nATA_SEL (initial: select) */ |
| 442 | gpio_request(gpio + 6, "nATA_SEL"); |
| 443 | gpio_direction_output(gpio + 6, 0); |
| 444 | |
| 445 | /* p7 = nCF_SEL (initial: deselect) */ |
| 446 | gpio_request(gpio + 7, "nCF_SEL"); |
| 447 | gpio_direction_output(gpio + 7, 1); |
| 448 | |
| 449 | return 0; |
| 450 | } |
| 451 | |
| 452 | static int |
| 453 | evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 454 | { |
| 455 | gpio_free(gpio + 7); |
| 456 | gpio_free(gpio + 6); |
| 457 | gpio_free(gpio + 5); |
| 458 | gpio_free(gpio + 3); |
| 459 | gpio_free(gpio + 2); |
| 460 | gpio_free(gpio + 1); |
| 461 | gpio_free(gpio + 0); |
| 462 | return 0; |
| 463 | } |
| 464 | |
| 465 | static struct pcf857x_platform_data pcf_data_u35 = { |
| 466 | .gpio_base = PCF_Uxx_BASE(2), |
| 467 | .setup = evm_u35_setup, |
| 468 | .teardown = evm_u35_teardown, |
| 469 | }; |
| 470 | |
| 471 | /*----------------------------------------------------------------------*/ |
| 472 | |
| 473 | /* Most of this EEPROM is unused, but U-Boot uses some data: |
| 474 | * - 0x7f00, 6 bytes Ethernet Address |
| 475 | * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL) |
| 476 | * - ... newer boards may have more |
| 477 | */ |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 478 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 479 | static struct at24_platform_data eeprom_info = { |
| 480 | .byte_len = (256*1024) / 8, |
| 481 | .page_size = 64, |
| 482 | .flags = AT24_FLAG_ADDR16, |
Mark A. Greer | b14dc0f | 2009-04-15 12:41:27 -0700 | [diff] [blame] | 483 | .setup = davinci_get_mac_addr, |
| 484 | .context = (void *)0x7f00, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 485 | }; |
| 486 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 487 | /* |
| 488 | * MSP430 supports RTC, card detection, input from IR remote, and |
| 489 | * a bit more. It triggers interrupts on GPIO(7) from pressing |
| 490 | * buttons on the IR remote, and for card detect switches. |
| 491 | */ |
| 492 | static struct i2c_client *dm6446evm_msp; |
| 493 | |
| 494 | static int dm6446evm_msp_probe(struct i2c_client *client, |
| 495 | const struct i2c_device_id *id) |
| 496 | { |
| 497 | dm6446evm_msp = client; |
| 498 | return 0; |
| 499 | } |
| 500 | |
| 501 | static int dm6446evm_msp_remove(struct i2c_client *client) |
| 502 | { |
| 503 | dm6446evm_msp = NULL; |
| 504 | return 0; |
| 505 | } |
| 506 | |
| 507 | static const struct i2c_device_id dm6446evm_msp_ids[] = { |
| 508 | { "dm6446evm_msp", 0, }, |
| 509 | { /* end of list */ }, |
| 510 | }; |
| 511 | |
| 512 | static struct i2c_driver dm6446evm_msp_driver = { |
| 513 | .driver.name = "dm6446evm_msp", |
| 514 | .id_table = dm6446evm_msp_ids, |
| 515 | .probe = dm6446evm_msp_probe, |
| 516 | .remove = dm6446evm_msp_remove, |
| 517 | }; |
| 518 | |
| 519 | static int dm6444evm_msp430_get_pins(void) |
| 520 | { |
| 521 | static const char txbuf[2] = { 2, 4, }; |
| 522 | char buf[4]; |
| 523 | struct i2c_msg msg[2] = { |
| 524 | { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 525 | .flags = 0, |
| 526 | .len = 2, |
| 527 | .buf = (void __force *)txbuf, |
| 528 | }, |
| 529 | { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 530 | .flags = I2C_M_RD, |
| 531 | .len = 4, |
| 532 | .buf = buf, |
| 533 | }, |
| 534 | }; |
| 535 | int status; |
| 536 | |
| 537 | if (!dm6446evm_msp) |
| 538 | return -ENXIO; |
| 539 | |
Wei Yongjun | 9ad9023 | 2012-09-10 04:49:23 +0000 | [diff] [blame] | 540 | msg[0].addr = dm6446evm_msp->addr; |
| 541 | msg[1].addr = dm6446evm_msp->addr; |
| 542 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 543 | /* Command 4 == get input state, returns port 2 and port3 data |
| 544 | * S Addr W [A] len=2 [A] cmd=4 [A] |
| 545 | * RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P |
| 546 | */ |
| 547 | status = i2c_transfer(dm6446evm_msp->adapter, msg, 2); |
| 548 | if (status < 0) |
| 549 | return status; |
| 550 | |
Andy Shevchenko | d1a31e9 | 2015-10-01 16:13:05 +0300 | [diff] [blame] | 551 | dev_dbg(&dm6446evm_msp->dev, "PINS: %4ph\n", buf); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 552 | |
| 553 | return (buf[3] << 8) | buf[2]; |
| 554 | } |
| 555 | |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 556 | static int dm6444evm_mmc_get_cd(int module) |
| 557 | { |
| 558 | int status = dm6444evm_msp430_get_pins(); |
| 559 | |
| 560 | return (status < 0) ? status : !(status & BIT(1)); |
| 561 | } |
| 562 | |
| 563 | static int dm6444evm_mmc_get_ro(int module) |
| 564 | { |
| 565 | int status = dm6444evm_msp430_get_pins(); |
| 566 | |
| 567 | return (status < 0) ? status : status & BIT(6 + 8); |
| 568 | } |
| 569 | |
| 570 | static struct davinci_mmc_config dm6446evm_mmc_config = { |
| 571 | .get_cd = dm6444evm_mmc_get_cd, |
| 572 | .get_ro = dm6444evm_mmc_get_ro, |
| 573 | .wires = 4, |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 574 | }; |
| 575 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 576 | static struct i2c_board_info __initdata i2c_info[] = { |
| 577 | { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 578 | I2C_BOARD_INFO("dm6446evm_msp", 0x23), |
| 579 | }, |
| 580 | { |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 581 | I2C_BOARD_INFO("pcf8574", 0x38), |
| 582 | .platform_data = &pcf_data_u2, |
| 583 | }, |
| 584 | { |
| 585 | I2C_BOARD_INFO("pcf8574", 0x39), |
| 586 | .platform_data = &pcf_data_u18, |
| 587 | }, |
| 588 | { |
| 589 | I2C_BOARD_INFO("pcf8574", 0x3a), |
| 590 | .platform_data = &pcf_data_u35, |
| 591 | }, |
| 592 | { |
| 593 | I2C_BOARD_INFO("24c256", 0x50), |
| 594 | .platform_data = &eeprom_info, |
| 595 | }, |
Chaithrika U S | 1a7ff8f | 2009-08-25 15:20:05 +0300 | [diff] [blame] | 596 | { |
| 597 | I2C_BOARD_INFO("tlv320aic33", 0x1b), |
| 598 | }, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 599 | }; |
| 600 | |
Sekhar Nori | 9411ac0 | 2018-04-18 15:02:46 +0530 | [diff] [blame] | 601 | #define DM644X_I2C_SDA_PIN GPIO_TO_PIN(2, 12) |
| 602 | #define DM644X_I2C_SCL_PIN GPIO_TO_PIN(2, 11) |
| 603 | |
Linus Walleij | e535376 | 2017-12-20 13:17:49 +0100 | [diff] [blame] | 604 | static struct gpiod_lookup_table i2c_recovery_gpiod_table = { |
Sekhar Nori | 9411ac0 | 2018-04-18 15:02:46 +0530 | [diff] [blame] | 605 | .dev_id = "i2c_davinci.1", |
Linus Walleij | e535376 | 2017-12-20 13:17:49 +0100 | [diff] [blame] | 606 | .table = { |
Sekhar Nori | 9411ac0 | 2018-04-18 15:02:46 +0530 | [diff] [blame] | 607 | GPIO_LOOKUP("davinci_gpio.0", DM644X_I2C_SDA_PIN, "sda", |
Linus Walleij | e535376 | 2017-12-20 13:17:49 +0100 | [diff] [blame] | 608 | GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), |
Sekhar Nori | 9411ac0 | 2018-04-18 15:02:46 +0530 | [diff] [blame] | 609 | GPIO_LOOKUP("davinci_gpio.0", DM644X_I2C_SCL_PIN, "scl", |
Linus Walleij | e535376 | 2017-12-20 13:17:49 +0100 | [diff] [blame] | 610 | GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), |
| 611 | }, |
| 612 | }; |
| 613 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 614 | /* The msp430 uses a slow bitbanged I2C implementation (ergo 20 KHz), |
| 615 | * which requires 100 usec of idle bus after i2c writes sent to it. |
| 616 | */ |
| 617 | static struct davinci_i2c_platform_data i2c_pdata = { |
| 618 | .bus_freq = 20 /* kHz */, |
| 619 | .bus_delay = 100 /* usec */, |
Linus Walleij | e535376 | 2017-12-20 13:17:49 +0100 | [diff] [blame] | 620 | .gpio_recovery = true, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 621 | }; |
| 622 | |
| 623 | static void __init evm_init_i2c(void) |
| 624 | { |
Linus Walleij | e535376 | 2017-12-20 13:17:49 +0100 | [diff] [blame] | 625 | gpiod_add_lookup_table(&i2c_recovery_gpiod_table); |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 626 | davinci_init_i2c(&i2c_pdata); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 627 | i2c_add_driver(&dm6446evm_msp_driver); |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 628 | i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); |
| 629 | } |
Arnd Bergmann | 8e58041 | 2016-02-01 21:35:58 +0100 | [diff] [blame] | 630 | #endif |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 631 | |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 632 | #define VENC_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL) |
| 633 | |
| 634 | /* venc standard timings */ |
| 635 | static struct vpbe_enc_mode_info dm644xevm_enc_std_timing[] = { |
| 636 | { |
| 637 | .name = "ntsc", |
| 638 | .timings_type = VPBE_ENC_STD, |
Lad, Prabhakar | 89cdbba | 2013-04-12 07:46:19 -0300 | [diff] [blame] | 639 | .std_id = V4L2_STD_NTSC, |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 640 | .interlaced = 1, |
| 641 | .xres = 720, |
| 642 | .yres = 480, |
| 643 | .aspect = {11, 10}, |
| 644 | .fps = {30000, 1001}, |
| 645 | .left_margin = 0x79, |
| 646 | .upper_margin = 0x10, |
| 647 | }, |
| 648 | { |
| 649 | .name = "pal", |
| 650 | .timings_type = VPBE_ENC_STD, |
Lad, Prabhakar | 89cdbba | 2013-04-12 07:46:19 -0300 | [diff] [blame] | 651 | .std_id = V4L2_STD_PAL, |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 652 | .interlaced = 1, |
| 653 | .xres = 720, |
| 654 | .yres = 576, |
| 655 | .aspect = {54, 59}, |
| 656 | .fps = {25, 1}, |
| 657 | .left_margin = 0x7e, |
| 658 | .upper_margin = 0x16, |
| 659 | }, |
| 660 | }; |
| 661 | |
| 662 | /* venc dv preset timings */ |
| 663 | static struct vpbe_enc_mode_info dm644xevm_enc_preset_timing[] = { |
| 664 | { |
| 665 | .name = "480p59_94", |
Hans Verkuil | ef2d41b | 2013-02-15 15:06:28 -0300 | [diff] [blame] | 666 | .timings_type = VPBE_ENC_DV_TIMINGS, |
Hans Verkuil | 3686408 | 2012-10-01 11:39:46 -0300 | [diff] [blame] | 667 | .dv_timings = V4L2_DV_BT_CEA_720X480P59_94, |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 668 | .interlaced = 0, |
| 669 | .xres = 720, |
| 670 | .yres = 480, |
| 671 | .aspect = {1, 1}, |
| 672 | .fps = {5994, 100}, |
| 673 | .left_margin = 0x80, |
| 674 | .upper_margin = 0x20, |
| 675 | }, |
| 676 | { |
| 677 | .name = "576p50", |
Hans Verkuil | ef2d41b | 2013-02-15 15:06:28 -0300 | [diff] [blame] | 678 | .timings_type = VPBE_ENC_DV_TIMINGS, |
Hans Verkuil | 3686408 | 2012-10-01 11:39:46 -0300 | [diff] [blame] | 679 | .dv_timings = V4L2_DV_BT_CEA_720X576P50, |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 680 | .interlaced = 0, |
| 681 | .xres = 720, |
| 682 | .yres = 576, |
| 683 | .aspect = {1, 1}, |
| 684 | .fps = {50, 1}, |
| 685 | .left_margin = 0x7e, |
| 686 | .upper_margin = 0x30, |
| 687 | }, |
| 688 | }; |
| 689 | |
| 690 | /* |
| 691 | * The outputs available from VPBE + encoders. Keep the order same |
| 692 | * as that of encoders. First those from venc followed by that from |
| 693 | * encoders. Index in the output refers to index on a particular encoder. |
| 694 | * Driver uses this index to pass it to encoder when it supports more |
| 695 | * than one output. Userspace applications use index of the array to |
| 696 | * set an output. |
| 697 | */ |
| 698 | static struct vpbe_output dm644xevm_vpbe_outputs[] = { |
| 699 | { |
| 700 | .output = { |
| 701 | .index = 0, |
| 702 | .name = "Composite", |
| 703 | .type = V4L2_OUTPUT_TYPE_ANALOG, |
| 704 | .std = VENC_STD_ALL, |
| 705 | .capabilities = V4L2_OUT_CAP_STD, |
| 706 | }, |
Lad, Prabhakar | caff80c | 2012-11-20 07:30:36 -0300 | [diff] [blame] | 707 | .subdev_name = DM644X_VPBE_VENC_SUBDEV_NAME, |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 708 | .default_mode = "ntsc", |
| 709 | .num_modes = ARRAY_SIZE(dm644xevm_enc_std_timing), |
| 710 | .modes = dm644xevm_enc_std_timing, |
| 711 | }, |
| 712 | { |
| 713 | .output = { |
| 714 | .index = 1, |
| 715 | .name = "Component", |
| 716 | .type = V4L2_OUTPUT_TYPE_ANALOG, |
Lad, Prabhakar | e32087b | 2012-10-03 02:25:42 -0300 | [diff] [blame] | 717 | .capabilities = V4L2_OUT_CAP_DV_TIMINGS, |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 718 | }, |
Lad, Prabhakar | caff80c | 2012-11-20 07:30:36 -0300 | [diff] [blame] | 719 | .subdev_name = DM644X_VPBE_VENC_SUBDEV_NAME, |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 720 | .default_mode = "480p59_94", |
| 721 | .num_modes = ARRAY_SIZE(dm644xevm_enc_preset_timing), |
| 722 | .modes = dm644xevm_enc_preset_timing, |
| 723 | }, |
| 724 | }; |
| 725 | |
| 726 | static struct vpbe_config dm644xevm_display_cfg = { |
| 727 | .module_name = "dm644x-vpbe-display", |
| 728 | .i2c_adapter_id = 1, |
| 729 | .osd = { |
Lad, Prabhakar | caff80c | 2012-11-20 07:30:36 -0300 | [diff] [blame] | 730 | .module_name = DM644X_VPBE_OSD_SUBDEV_NAME, |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 731 | }, |
| 732 | .venc = { |
Lad, Prabhakar | caff80c | 2012-11-20 07:30:36 -0300 | [diff] [blame] | 733 | .module_name = DM644X_VPBE_VENC_SUBDEV_NAME, |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 734 | }, |
| 735 | .num_outputs = ARRAY_SIZE(dm644xevm_vpbe_outputs), |
| 736 | .outputs = dm644xevm_vpbe_outputs, |
| 737 | }; |
| 738 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 739 | static struct platform_device *davinci_evm_devices[] __initdata = { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 740 | &davinci_fb_device, |
| 741 | &rtc_dev, |
| 742 | }; |
| 743 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 744 | static void __init |
| 745 | davinci_evm_map_io(void) |
| 746 | { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 747 | dm644x_init(); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 748 | } |
| 749 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 750 | static int davinci_phy_fixup(struct phy_device *phydev) |
| 751 | { |
| 752 | unsigned int control; |
| 753 | /* CRITICAL: Fix for increasing PHY signal drive strength for |
| 754 | * TX lockup issue. On DaVinci EVM, the Intel LXT971 PHY |
| 755 | * signal strength was low causing TX to fail randomly. The |
| 756 | * fix is to Set bit 11 (Increased MII drive strength) of PHY |
| 757 | * register 26 (Digital Config register) on this phy. */ |
| 758 | control = phy_read(phydev, 26); |
| 759 | phy_write(phydev, 26, (control | 0x800)); |
| 760 | return 0; |
| 761 | } |
| 762 | |
Sekhar Nori | 28d4d1d | 2017-03-22 19:21:01 +0100 | [diff] [blame] | 763 | #define HAS_ATA (IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \ |
| 764 | IS_ENABLED(CONFIG_PATA_BK3710)) |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 765 | |
Lad, Prabhakar | a0a56db | 2013-04-01 12:43:44 +0530 | [diff] [blame] | 766 | #define HAS_NOR IS_ENABLED(CONFIG_MTD_PHYSMAP) |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 767 | |
Lad, Prabhakar | a0a56db | 2013-04-01 12:43:44 +0530 | [diff] [blame] | 768 | #define HAS_NAND IS_ENABLED(CONFIG_MTD_NAND_DAVINCI) |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 769 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 770 | static __init void davinci_evm_init(void) |
| 771 | { |
Philip Avinash | 834acb2 | 2013-08-18 10:49:02 +0530 | [diff] [blame] | 772 | int ret; |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 773 | struct clk *aemif_clk; |
Mark A. Greer | 972412b | 2009-04-15 12:40:56 -0700 | [diff] [blame] | 774 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 775 | |
Sekhar Nori | 8e730c7 | 2018-04-06 18:08:20 +0530 | [diff] [blame] | 776 | dm644x_init_devices(); |
| 777 | |
Philip Avinash | 834acb2 | 2013-08-18 10:49:02 +0530 | [diff] [blame] | 778 | ret = dm644x_gpio_register(); |
| 779 | if (ret) |
| 780 | pr_warn("%s: GPIO init failed: %d\n", __func__, ret); |
| 781 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 782 | aemif_clk = clk_get(NULL, "aemif"); |
m-karicheri2@ti.com | b6f1ffe | 2012-08-02 16:53:48 +0000 | [diff] [blame] | 783 | clk_prepare_enable(aemif_clk); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 784 | |
| 785 | if (HAS_ATA) { |
| 786 | if (HAS_NAND || HAS_NOR) |
Joe Perches | a7ca2bc | 2014-10-31 17:51:51 -0700 | [diff] [blame] | 787 | pr_warn("WARNING: both IDE and Flash are enabled, but they share AEMIF pins\n" |
| 788 | "\tDisable IDE for NAND/NOR support\n"); |
Sergei Shtylyov | 7a9978a | 2010-04-21 18:11:33 +0400 | [diff] [blame] | 789 | davinci_init_ide(); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 790 | } else if (HAS_NAND || HAS_NOR) { |
| 791 | davinci_cfg_reg(DM644X_HPIEN_DISABLE); |
| 792 | davinci_cfg_reg(DM644X_ATAEN_DISABLE); |
| 793 | |
| 794 | /* only one device will be jumpered and detected */ |
| 795 | if (HAS_NAND) { |
| 796 | platform_device_register(&davinci_evm_nandflash_device); |
Ivan Khoronzhuk | 67f5185 | 2014-01-30 13:03:40 +0200 | [diff] [blame] | 797 | |
| 798 | if (davinci_aemif_setup(&davinci_evm_nandflash_device)) |
Joe Perches | a7ca2bc | 2014-10-31 17:51:51 -0700 | [diff] [blame] | 799 | pr_warn("%s: Cannot configure AEMIF\n", |
Ivan Khoronzhuk | 67f5185 | 2014-01-30 13:03:40 +0200 | [diff] [blame] | 800 | __func__); |
| 801 | |
Arnd Bergmann | 8e58041 | 2016-02-01 21:35:58 +0100 | [diff] [blame] | 802 | #ifdef CONFIG_I2C |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 803 | evm_leds[7].default_trigger = "nand-disk"; |
Arnd Bergmann | 8e58041 | 2016-02-01 21:35:58 +0100 | [diff] [blame] | 804 | #endif |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 805 | if (HAS_NOR) |
Joe Perches | a7ca2bc | 2014-10-31 17:51:51 -0700 | [diff] [blame] | 806 | pr_warn("WARNING: both NAND and NOR flash are enabled; disable one of them.\n"); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 807 | } else if (HAS_NOR) |
| 808 | platform_device_register(&davinci_evm_norflash_device); |
| 809 | } |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 810 | |
| 811 | platform_add_devices(davinci_evm_devices, |
| 812 | ARRAY_SIZE(davinci_evm_devices)); |
Arnd Bergmann | 8e58041 | 2016-02-01 21:35:58 +0100 | [diff] [blame] | 813 | #ifdef CONFIG_I2C |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 814 | evm_init_i2c(); |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 815 | davinci_setup_mmc(0, &dm6446evm_mmc_config); |
Arnd Bergmann | 8e58041 | 2016-02-01 21:35:58 +0100 | [diff] [blame] | 816 | #endif |
Manjunath Hadli | d5be5f5 | 2012-02-23 15:17:46 +0530 | [diff] [blame] | 817 | dm644x_init_video(&dm644xevm_capture_cfg, &dm644xevm_display_cfg); |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 818 | |
Manjunathappa, Prakash | fcf7157 | 2013-06-19 14:45:42 +0530 | [diff] [blame] | 819 | davinci_serial_init(dm644x_serial_device); |
Petr Kulhavy | 6bce5ef | 2016-05-09 15:59:48 +0200 | [diff] [blame] | 820 | dm644x_init_asp(); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 821 | |
Sergei Shtylyov | 60d97a8 | 2011-03-13 20:06:59 +0000 | [diff] [blame] | 822 | /* irlml6401 switches over 1A, in under 8 msec */ |
| 823 | davinci_setup_usb(1000, 8); |
| 824 | |
Arnd Bergmann | 4bbef1d | 2014-03-13 17:50:35 +0100 | [diff] [blame] | 825 | if (IS_BUILTIN(CONFIG_PHYLIB)) { |
| 826 | soc_info->emac_pdata->phy_id = DM644X_EVM_PHY_ID; |
| 827 | /* Register the fixup for PHY on DaVinci */ |
| 828 | phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, |
| 829 | davinci_phy_fixup); |
| 830 | } |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 831 | } |
| 832 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 833 | MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM") |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 834 | /* Maintainer: MontaVista Software <source@mvista.com> */ |
Nicolas Pitre | e7e5601 | 2011-07-05 22:38:11 -0400 | [diff] [blame] | 835 | .atag_offset = 0x100, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 836 | .map_io = davinci_evm_map_io, |
Cyril Chemparathy | bd80894 | 2010-05-07 17:06:37 -0400 | [diff] [blame] | 837 | .init_irq = davinci_irq_init, |
David Lechner | 96c0817 | 2018-01-19 21:20:22 -0600 | [diff] [blame] | 838 | .init_time = dm644x_init_time, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 839 | .init_machine = davinci_evm_init, |
Shawn Guo | 3aa3e84 | 2012-04-26 09:45:39 +0800 | [diff] [blame] | 840 | .init_late = davinci_init_late, |
Nicolas Pitre | f68deab | 2011-07-05 22:28:08 -0400 | [diff] [blame] | 841 | .dma_zone_size = SZ_128M, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 842 | MACHINE_END |