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> |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 16 | #include <linux/i2c.h> |
| 17 | #include <linux/i2c/pcf857x.h> |
| 18 | #include <linux/i2c/at24.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 19 | #include <linux/mtd/mtd.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 20 | #include <linux/mtd/nand.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 21 | #include <linux/mtd/partitions.h> |
| 22 | #include <linux/mtd/physmap.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 23 | #include <linux/phy.h> |
| 24 | #include <linux/clk.h> |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 25 | #include <linux/videodev2.h> |
| 26 | |
| 27 | #include <media/tvp514x.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 28 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 29 | #include <asm/mach-types.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 30 | #include <asm/mach/arch.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 31 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 32 | #include <mach/dm644x.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 33 | #include <mach/common.h> |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 34 | #include <mach/i2c.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 35 | #include <mach/serial.h> |
| 36 | #include <mach/mux.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 37 | #include <mach/nand.h> |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 38 | #include <mach/mmc.h> |
Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame] | 39 | #include <mach/usb.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 40 | |
| 41 | #define DM644X_EVM_PHY_MASK (0x2) |
| 42 | #define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */ |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 43 | |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 44 | #define DAVINCI_CFC_ATA_BASE 0x01C66000 |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 45 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 46 | #define LXT971_PHY_ID (0x001378e2) |
| 47 | #define LXT971_PHY_MASK (0xfffffff0) |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 48 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 49 | static struct mtd_partition davinci_evm_norflash_partitions[] = { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 50 | /* bootloader (UBL, U-Boot, etc) in first 5 sectors */ |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 51 | { |
| 52 | .name = "bootloader", |
| 53 | .offset = 0, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 54 | .size = 5 * SZ_64K, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 55 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 56 | }, |
| 57 | /* bootloader params in the next 1 sectors */ |
| 58 | { |
| 59 | .name = "params", |
| 60 | .offset = MTDPART_OFS_APPEND, |
| 61 | .size = SZ_64K, |
| 62 | .mask_flags = 0, |
| 63 | }, |
| 64 | /* kernel */ |
| 65 | { |
| 66 | .name = "kernel", |
| 67 | .offset = MTDPART_OFS_APPEND, |
| 68 | .size = SZ_2M, |
| 69 | .mask_flags = 0 |
| 70 | }, |
| 71 | /* file system */ |
| 72 | { |
| 73 | .name = "filesystem", |
| 74 | .offset = MTDPART_OFS_APPEND, |
| 75 | .size = MTDPART_SIZ_FULL, |
| 76 | .mask_flags = 0 |
| 77 | } |
| 78 | }; |
| 79 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 80 | static struct physmap_flash_data davinci_evm_norflash_data = { |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 81 | .width = 2, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 82 | .parts = davinci_evm_norflash_partitions, |
| 83 | .nr_parts = ARRAY_SIZE(davinci_evm_norflash_partitions), |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | /* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF |
| 87 | * limits addresses to 16M, so using addresses past 16M will wrap */ |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 88 | static struct resource davinci_evm_norflash_resource = { |
Sergei Shtylyov | 7034217 | 2010-04-16 21:29:11 +0400 | [diff] [blame^] | 89 | .start = DM644X_ASYNC_EMIF_DATA_CE0_BASE, |
| 90 | .end = DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 91 | .flags = IORESOURCE_MEM, |
| 92 | }; |
| 93 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 94 | static struct platform_device davinci_evm_norflash_device = { |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 95 | .name = "physmap-flash", |
| 96 | .id = 0, |
| 97 | .dev = { |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 98 | .platform_data = &davinci_evm_norflash_data, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 99 | }, |
| 100 | .num_resources = 1, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 101 | .resource = &davinci_evm_norflash_resource, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 102 | }; |
| 103 | |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 104 | /* DM644x EVM includes a 64 MByte small-page NAND flash (16K blocks). |
| 105 | * It may used instead of the (default) NOR chip to boot, using TI's |
| 106 | * tools to install the secondary boot loader (UBL) and U-Boot. |
| 107 | */ |
Kevin Hilman | 28552c2 | 2010-02-25 15:36:38 -0800 | [diff] [blame] | 108 | static struct mtd_partition davinci_evm_nandflash_partition[] = { |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 109 | /* Bootloader layout depends on whose u-boot is installed, but we |
| 110 | * can hide all the details. |
| 111 | * - block 0 for u-boot environment ... in mainline u-boot |
| 112 | * - block 1 for UBL (plus up to four backup copies in blocks 2..5) |
| 113 | * - blocks 6...? for u-boot |
| 114 | * - blocks 16..23 for u-boot environment ... in TI's u-boot |
| 115 | */ |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 116 | { |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 117 | .name = "bootloader", |
| 118 | .offset = 0, |
| 119 | .size = SZ_256K + SZ_128K, |
| 120 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 121 | }, |
| 122 | /* Kernel */ |
| 123 | { |
| 124 | .name = "kernel", |
| 125 | .offset = MTDPART_OFS_APPEND, |
| 126 | .size = SZ_4M, |
| 127 | .mask_flags = 0, |
| 128 | }, |
| 129 | /* File system (older GIT kernels started this on the 5MB mark) */ |
| 130 | { |
| 131 | .name = "filesystem", |
| 132 | .offset = MTDPART_OFS_APPEND, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 133 | .size = MTDPART_SIZ_FULL, |
| 134 | .mask_flags = 0, |
| 135 | } |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 136 | /* A few blocks at end hold a flash BBT ... created by TI's CCS |
| 137 | * using flashwriter_nand.out, but ignored by TI's versions of |
| 138 | * Linux and u-boot. We boot faster by using them. |
| 139 | */ |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 140 | }; |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 141 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 142 | static struct davinci_nand_pdata davinci_evm_nandflash_data = { |
| 143 | .parts = davinci_evm_nandflash_partition, |
| 144 | .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition), |
| 145 | .ecc_mode = NAND_ECC_HW, |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 146 | .options = NAND_USE_FLASH_BBT, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | static struct resource davinci_evm_nandflash_resource[] = { |
| 150 | { |
Sergei Shtylyov | 7034217 | 2010-04-16 21:29:11 +0400 | [diff] [blame^] | 151 | .start = DM644X_ASYNC_EMIF_DATA_CE0_BASE, |
| 152 | .end = DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 153 | .flags = IORESOURCE_MEM, |
| 154 | }, { |
Sergei Shtylyov | 7034217 | 2010-04-16 21:29:11 +0400 | [diff] [blame^] | 155 | .start = DM644X_ASYNC_EMIF_CONTROL_BASE, |
| 156 | .end = DM644X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 157 | .flags = IORESOURCE_MEM, |
| 158 | }, |
| 159 | }; |
| 160 | |
| 161 | static struct platform_device davinci_evm_nandflash_device = { |
| 162 | .name = "davinci_nand", |
| 163 | .id = 0, |
| 164 | .dev = { |
| 165 | .platform_data = &davinci_evm_nandflash_data, |
| 166 | }, |
| 167 | .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource), |
| 168 | .resource = davinci_evm_nandflash_resource, |
| 169 | }; |
| 170 | |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 171 | static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 172 | |
| 173 | static struct platform_device davinci_fb_device = { |
| 174 | .name = "davincifb", |
| 175 | .id = -1, |
| 176 | .dev = { |
| 177 | .dma_mask = &davinci_fb_dma_mask, |
David Brownell | 3e9c18e | 2009-04-15 14:19:21 -0500 | [diff] [blame] | 178 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 179 | }, |
| 180 | .num_resources = 0, |
| 181 | }; |
| 182 | |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 183 | static struct tvp514x_platform_data tvp5146_pdata = { |
| 184 | .clk_polarity = 0, |
| 185 | .hs_polarity = 1, |
| 186 | .vs_polarity = 1 |
| 187 | }; |
| 188 | |
| 189 | #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL) |
| 190 | /* Inputs available at the TVP5146 */ |
| 191 | static struct v4l2_input tvp5146_inputs[] = { |
| 192 | { |
| 193 | .index = 0, |
| 194 | .name = "Composite", |
| 195 | .type = V4L2_INPUT_TYPE_CAMERA, |
| 196 | .std = TVP514X_STD_ALL, |
| 197 | }, |
| 198 | { |
| 199 | .index = 1, |
| 200 | .name = "S-Video", |
| 201 | .type = V4L2_INPUT_TYPE_CAMERA, |
| 202 | .std = TVP514X_STD_ALL, |
| 203 | }, |
| 204 | }; |
| 205 | |
| 206 | /* |
| 207 | * this is the route info for connecting each input to decoder |
| 208 | * ouput that goes to vpfe. There is a one to one correspondence |
| 209 | * with tvp5146_inputs |
| 210 | */ |
| 211 | static struct vpfe_route tvp5146_routes[] = { |
| 212 | { |
| 213 | .input = INPUT_CVBS_VI2B, |
| 214 | .output = OUTPUT_10BIT_422_EMBEDDED_SYNC, |
| 215 | }, |
| 216 | { |
| 217 | .input = INPUT_SVIDEO_VI2C_VI1C, |
| 218 | .output = OUTPUT_10BIT_422_EMBEDDED_SYNC, |
| 219 | }, |
| 220 | }; |
| 221 | |
| 222 | static struct vpfe_subdev_info vpfe_sub_devs[] = { |
| 223 | { |
| 224 | .name = "tvp5146", |
| 225 | .grp_id = 0, |
| 226 | .num_inputs = ARRAY_SIZE(tvp5146_inputs), |
| 227 | .inputs = tvp5146_inputs, |
| 228 | .routes = tvp5146_routes, |
| 229 | .can_route = 1, |
| 230 | .ccdc_if_params = { |
| 231 | .if_type = VPFE_BT656, |
| 232 | .hdpol = VPFE_PINPOL_POSITIVE, |
| 233 | .vdpol = VPFE_PINPOL_POSITIVE, |
| 234 | }, |
| 235 | .board_info = { |
| 236 | I2C_BOARD_INFO("tvp5146", 0x5d), |
| 237 | .platform_data = &tvp5146_pdata, |
| 238 | }, |
| 239 | }, |
| 240 | }; |
| 241 | |
| 242 | static struct vpfe_config vpfe_cfg = { |
| 243 | .num_subdevs = ARRAY_SIZE(vpfe_sub_devs), |
Vaibhav Hiremath | 077639f | 2009-10-13 15:08:54 +0000 | [diff] [blame] | 244 | .i2c_adapter_id = 1, |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 245 | .sub_devs = vpfe_sub_devs, |
| 246 | .card_name = "DM6446 EVM", |
| 247 | .ccdc = "DM6446 CCDC", |
| 248 | }; |
| 249 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 250 | static struct platform_device rtc_dev = { |
| 251 | .name = "rtc_davinci_evm", |
| 252 | .id = -1, |
| 253 | }; |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 254 | |
| 255 | static struct resource ide_resources[] = { |
| 256 | { |
| 257 | .start = DAVINCI_CFC_ATA_BASE, |
| 258 | .end = DAVINCI_CFC_ATA_BASE + 0x7ff, |
| 259 | .flags = IORESOURCE_MEM, |
| 260 | }, |
| 261 | { |
| 262 | .start = IRQ_IDE, |
| 263 | .end = IRQ_IDE, |
| 264 | .flags = IORESOURCE_IRQ, |
| 265 | }, |
| 266 | }; |
| 267 | |
Kevin Hilman | a029b70 | 2009-05-07 14:25:48 +0100 | [diff] [blame] | 268 | static u64 ide_dma_mask = DMA_BIT_MASK(32); |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 269 | |
| 270 | static struct platform_device ide_dev = { |
| 271 | .name = "palm_bk3710", |
| 272 | .id = -1, |
| 273 | .resource = ide_resources, |
| 274 | .num_resources = ARRAY_SIZE(ide_resources), |
| 275 | .dev = { |
| 276 | .dma_mask = &ide_dma_mask, |
Kevin Hilman | a029b70 | 2009-05-07 14:25:48 +0100 | [diff] [blame] | 277 | .coherent_dma_mask = DMA_BIT_MASK(32), |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 278 | }, |
| 279 | }; |
| 280 | |
Kevin Hilman | 61aa073 | 2009-07-15 08:47:48 -0700 | [diff] [blame] | 281 | static struct snd_platform_data dm644x_evm_snd_data; |
Chaithrika U S | 25acf55 | 2009-06-05 06:28:08 -0400 | [diff] [blame] | 282 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 283 | /*----------------------------------------------------------------------*/ |
| 284 | |
| 285 | /* |
| 286 | * I2C GPIO expanders |
| 287 | */ |
| 288 | |
| 289 | #define PCF_Uxx_BASE(x) (DAVINCI_N_GPIO + ((x) * 8)) |
| 290 | |
| 291 | |
| 292 | /* U2 -- LEDs */ |
| 293 | |
| 294 | static struct gpio_led evm_leds[] = { |
| 295 | { .name = "DS8", .active_low = 1, |
| 296 | .default_trigger = "heartbeat", }, |
| 297 | { .name = "DS7", .active_low = 1, }, |
| 298 | { .name = "DS6", .active_low = 1, }, |
| 299 | { .name = "DS5", .active_low = 1, }, |
| 300 | { .name = "DS4", .active_low = 1, }, |
| 301 | { .name = "DS3", .active_low = 1, }, |
| 302 | { .name = "DS2", .active_low = 1, |
| 303 | .default_trigger = "mmc0", }, |
| 304 | { .name = "DS1", .active_low = 1, |
| 305 | .default_trigger = "ide-disk", }, |
| 306 | }; |
| 307 | |
| 308 | static const struct gpio_led_platform_data evm_led_data = { |
| 309 | .num_leds = ARRAY_SIZE(evm_leds), |
| 310 | .leds = evm_leds, |
| 311 | }; |
| 312 | |
| 313 | static struct platform_device *evm_led_dev; |
| 314 | |
| 315 | static int |
| 316 | evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 317 | { |
| 318 | struct gpio_led *leds = evm_leds; |
| 319 | int status; |
| 320 | |
| 321 | while (ngpio--) { |
| 322 | leds->gpio = gpio++; |
| 323 | leds++; |
| 324 | } |
| 325 | |
| 326 | /* what an extremely annoying way to be forced to handle |
| 327 | * device unregistration ... |
| 328 | */ |
| 329 | evm_led_dev = platform_device_alloc("leds-gpio", 0); |
| 330 | platform_device_add_data(evm_led_dev, |
| 331 | &evm_led_data, sizeof evm_led_data); |
| 332 | |
| 333 | evm_led_dev->dev.parent = &client->dev; |
| 334 | status = platform_device_add(evm_led_dev); |
| 335 | if (status < 0) { |
| 336 | platform_device_put(evm_led_dev); |
| 337 | evm_led_dev = NULL; |
| 338 | } |
| 339 | return status; |
| 340 | } |
| 341 | |
| 342 | static int |
| 343 | evm_led_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 344 | { |
| 345 | if (evm_led_dev) { |
| 346 | platform_device_unregister(evm_led_dev); |
| 347 | evm_led_dev = NULL; |
| 348 | } |
| 349 | return 0; |
| 350 | } |
| 351 | |
| 352 | static struct pcf857x_platform_data pcf_data_u2 = { |
| 353 | .gpio_base = PCF_Uxx_BASE(0), |
| 354 | .setup = evm_led_setup, |
| 355 | .teardown = evm_led_teardown, |
| 356 | }; |
| 357 | |
| 358 | |
| 359 | /* U18 - A/V clock generator and user switch */ |
| 360 | |
| 361 | static int sw_gpio; |
| 362 | |
| 363 | static ssize_t |
| 364 | sw_show(struct device *d, struct device_attribute *a, char *buf) |
| 365 | { |
| 366 | char *s = gpio_get_value_cansleep(sw_gpio) ? "on\n" : "off\n"; |
| 367 | |
| 368 | strcpy(buf, s); |
| 369 | return strlen(s); |
| 370 | } |
| 371 | |
| 372 | static DEVICE_ATTR(user_sw, S_IRUGO, sw_show, NULL); |
| 373 | |
| 374 | static int |
| 375 | evm_u18_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 376 | { |
| 377 | int status; |
| 378 | |
| 379 | /* export dip switch option */ |
| 380 | sw_gpio = gpio + 7; |
| 381 | status = gpio_request(sw_gpio, "user_sw"); |
| 382 | if (status == 0) |
| 383 | status = gpio_direction_input(sw_gpio); |
| 384 | if (status == 0) |
| 385 | status = device_create_file(&client->dev, &dev_attr_user_sw); |
| 386 | else |
| 387 | gpio_free(sw_gpio); |
| 388 | if (status != 0) |
| 389 | sw_gpio = -EINVAL; |
| 390 | |
| 391 | /* audio PLL: 48 kHz (vs 44.1 or 32), single rate (vs double) */ |
| 392 | gpio_request(gpio + 3, "pll_fs2"); |
| 393 | gpio_direction_output(gpio + 3, 0); |
| 394 | |
| 395 | gpio_request(gpio + 2, "pll_fs1"); |
| 396 | gpio_direction_output(gpio + 2, 0); |
| 397 | |
| 398 | gpio_request(gpio + 1, "pll_sr"); |
| 399 | gpio_direction_output(gpio + 1, 0); |
| 400 | |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | static int |
| 405 | evm_u18_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 406 | { |
| 407 | gpio_free(gpio + 1); |
| 408 | gpio_free(gpio + 2); |
| 409 | gpio_free(gpio + 3); |
| 410 | |
| 411 | if (sw_gpio > 0) { |
| 412 | device_remove_file(&client->dev, &dev_attr_user_sw); |
| 413 | gpio_free(sw_gpio); |
| 414 | } |
| 415 | return 0; |
| 416 | } |
| 417 | |
| 418 | static struct pcf857x_platform_data pcf_data_u18 = { |
| 419 | .gpio_base = PCF_Uxx_BASE(1), |
| 420 | .n_latch = (1 << 3) | (1 << 2) | (1 << 1), |
| 421 | .setup = evm_u18_setup, |
| 422 | .teardown = evm_u18_teardown, |
| 423 | }; |
| 424 | |
| 425 | |
| 426 | /* U35 - various I/O signals used to manage USB, CF, ATA, etc */ |
| 427 | |
| 428 | static int |
| 429 | evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 430 | { |
| 431 | /* p0 = nDRV_VBUS (initial: don't supply it) */ |
| 432 | gpio_request(gpio + 0, "nDRV_VBUS"); |
| 433 | gpio_direction_output(gpio + 0, 1); |
| 434 | |
| 435 | /* p1 = VDDIMX_EN */ |
| 436 | gpio_request(gpio + 1, "VDDIMX_EN"); |
| 437 | gpio_direction_output(gpio + 1, 1); |
| 438 | |
| 439 | /* p2 = VLYNQ_EN */ |
| 440 | gpio_request(gpio + 2, "VLYNQ_EN"); |
| 441 | gpio_direction_output(gpio + 2, 1); |
| 442 | |
| 443 | /* p3 = n3V3_CF_RESET (initial: stay in reset) */ |
| 444 | gpio_request(gpio + 3, "nCF_RESET"); |
| 445 | gpio_direction_output(gpio + 3, 0); |
| 446 | |
| 447 | /* (p4 unused) */ |
| 448 | |
| 449 | /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */ |
| 450 | gpio_request(gpio + 5, "WLAN_RESET"); |
| 451 | gpio_direction_output(gpio + 5, 1); |
| 452 | |
| 453 | /* p6 = nATA_SEL (initial: select) */ |
| 454 | gpio_request(gpio + 6, "nATA_SEL"); |
| 455 | gpio_direction_output(gpio + 6, 0); |
| 456 | |
| 457 | /* p7 = nCF_SEL (initial: deselect) */ |
| 458 | gpio_request(gpio + 7, "nCF_SEL"); |
| 459 | gpio_direction_output(gpio + 7, 1); |
| 460 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 461 | /* irlml6401 switches over 1A, in under 8 msec; |
| 462 | * now it can be managed by nDRV_VBUS ... |
| 463 | */ |
Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame] | 464 | davinci_setup_usb(1000, 8); |
David Brownell | 34f32c9 | 2009-02-20 13:45:17 -0800 | [diff] [blame] | 465 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 466 | return 0; |
| 467 | } |
| 468 | |
| 469 | static int |
| 470 | evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 471 | { |
| 472 | gpio_free(gpio + 7); |
| 473 | gpio_free(gpio + 6); |
| 474 | gpio_free(gpio + 5); |
| 475 | gpio_free(gpio + 3); |
| 476 | gpio_free(gpio + 2); |
| 477 | gpio_free(gpio + 1); |
| 478 | gpio_free(gpio + 0); |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | static struct pcf857x_platform_data pcf_data_u35 = { |
| 483 | .gpio_base = PCF_Uxx_BASE(2), |
| 484 | .setup = evm_u35_setup, |
| 485 | .teardown = evm_u35_teardown, |
| 486 | }; |
| 487 | |
| 488 | /*----------------------------------------------------------------------*/ |
| 489 | |
| 490 | /* Most of this EEPROM is unused, but U-Boot uses some data: |
| 491 | * - 0x7f00, 6 bytes Ethernet Address |
| 492 | * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL) |
| 493 | * - ... newer boards may have more |
| 494 | */ |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 495 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 496 | static struct at24_platform_data eeprom_info = { |
| 497 | .byte_len = (256*1024) / 8, |
| 498 | .page_size = 64, |
| 499 | .flags = AT24_FLAG_ADDR16, |
Mark A. Greer | b14dc0f | 2009-04-15 12:41:27 -0700 | [diff] [blame] | 500 | .setup = davinci_get_mac_addr, |
| 501 | .context = (void *)0x7f00, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 502 | }; |
| 503 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 504 | /* |
| 505 | * MSP430 supports RTC, card detection, input from IR remote, and |
| 506 | * a bit more. It triggers interrupts on GPIO(7) from pressing |
| 507 | * buttons on the IR remote, and for card detect switches. |
| 508 | */ |
| 509 | static struct i2c_client *dm6446evm_msp; |
| 510 | |
| 511 | static int dm6446evm_msp_probe(struct i2c_client *client, |
| 512 | const struct i2c_device_id *id) |
| 513 | { |
| 514 | dm6446evm_msp = client; |
| 515 | return 0; |
| 516 | } |
| 517 | |
| 518 | static int dm6446evm_msp_remove(struct i2c_client *client) |
| 519 | { |
| 520 | dm6446evm_msp = NULL; |
| 521 | return 0; |
| 522 | } |
| 523 | |
| 524 | static const struct i2c_device_id dm6446evm_msp_ids[] = { |
| 525 | { "dm6446evm_msp", 0, }, |
| 526 | { /* end of list */ }, |
| 527 | }; |
| 528 | |
| 529 | static struct i2c_driver dm6446evm_msp_driver = { |
| 530 | .driver.name = "dm6446evm_msp", |
| 531 | .id_table = dm6446evm_msp_ids, |
| 532 | .probe = dm6446evm_msp_probe, |
| 533 | .remove = dm6446evm_msp_remove, |
| 534 | }; |
| 535 | |
| 536 | static int dm6444evm_msp430_get_pins(void) |
| 537 | { |
| 538 | static const char txbuf[2] = { 2, 4, }; |
| 539 | char buf[4]; |
| 540 | struct i2c_msg msg[2] = { |
| 541 | { |
| 542 | .addr = dm6446evm_msp->addr, |
| 543 | .flags = 0, |
| 544 | .len = 2, |
| 545 | .buf = (void __force *)txbuf, |
| 546 | }, |
| 547 | { |
| 548 | .addr = dm6446evm_msp->addr, |
| 549 | .flags = I2C_M_RD, |
| 550 | .len = 4, |
| 551 | .buf = buf, |
| 552 | }, |
| 553 | }; |
| 554 | int status; |
| 555 | |
| 556 | if (!dm6446evm_msp) |
| 557 | return -ENXIO; |
| 558 | |
| 559 | /* Command 4 == get input state, returns port 2 and port3 data |
| 560 | * S Addr W [A] len=2 [A] cmd=4 [A] |
| 561 | * RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P |
| 562 | */ |
| 563 | status = i2c_transfer(dm6446evm_msp->adapter, msg, 2); |
| 564 | if (status < 0) |
| 565 | return status; |
| 566 | |
| 567 | dev_dbg(&dm6446evm_msp->dev, |
| 568 | "PINS: %02x %02x %02x %02x\n", |
| 569 | buf[0], buf[1], buf[2], buf[3]); |
| 570 | |
| 571 | return (buf[3] << 8) | buf[2]; |
| 572 | } |
| 573 | |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 574 | static int dm6444evm_mmc_get_cd(int module) |
| 575 | { |
| 576 | int status = dm6444evm_msp430_get_pins(); |
| 577 | |
| 578 | return (status < 0) ? status : !(status & BIT(1)); |
| 579 | } |
| 580 | |
| 581 | static int dm6444evm_mmc_get_ro(int module) |
| 582 | { |
| 583 | int status = dm6444evm_msp430_get_pins(); |
| 584 | |
| 585 | return (status < 0) ? status : status & BIT(6 + 8); |
| 586 | } |
| 587 | |
| 588 | static struct davinci_mmc_config dm6446evm_mmc_config = { |
| 589 | .get_cd = dm6444evm_mmc_get_cd, |
| 590 | .get_ro = dm6444evm_mmc_get_ro, |
| 591 | .wires = 4, |
| 592 | .version = MMC_CTLR_VERSION_1 |
| 593 | }; |
| 594 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 595 | static struct i2c_board_info __initdata i2c_info[] = { |
| 596 | { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 597 | I2C_BOARD_INFO("dm6446evm_msp", 0x23), |
| 598 | }, |
| 599 | { |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 600 | I2C_BOARD_INFO("pcf8574", 0x38), |
| 601 | .platform_data = &pcf_data_u2, |
| 602 | }, |
| 603 | { |
| 604 | I2C_BOARD_INFO("pcf8574", 0x39), |
| 605 | .platform_data = &pcf_data_u18, |
| 606 | }, |
| 607 | { |
| 608 | I2C_BOARD_INFO("pcf8574", 0x3a), |
| 609 | .platform_data = &pcf_data_u35, |
| 610 | }, |
| 611 | { |
| 612 | I2C_BOARD_INFO("24c256", 0x50), |
| 613 | .platform_data = &eeprom_info, |
| 614 | }, |
Chaithrika U S | 1a7ff8f | 2009-08-25 15:20:05 +0300 | [diff] [blame] | 615 | { |
| 616 | I2C_BOARD_INFO("tlv320aic33", 0x1b), |
| 617 | }, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 618 | }; |
| 619 | |
| 620 | /* The msp430 uses a slow bitbanged I2C implementation (ergo 20 KHz), |
| 621 | * which requires 100 usec of idle bus after i2c writes sent to it. |
| 622 | */ |
| 623 | static struct davinci_i2c_platform_data i2c_pdata = { |
| 624 | .bus_freq = 20 /* kHz */, |
| 625 | .bus_delay = 100 /* usec */, |
Philby John | 00642f6 | 2010-01-11 15:53:31 +0530 | [diff] [blame] | 626 | .sda_pin = 44, |
| 627 | .scl_pin = 43, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 628 | }; |
| 629 | |
| 630 | static void __init evm_init_i2c(void) |
| 631 | { |
| 632 | davinci_init_i2c(&i2c_pdata); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 633 | i2c_add_driver(&dm6446evm_msp_driver); |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 634 | i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); |
| 635 | } |
| 636 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 637 | static struct platform_device *davinci_evm_devices[] __initdata = { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 638 | &davinci_fb_device, |
| 639 | &rtc_dev, |
| 640 | }; |
| 641 | |
| 642 | static struct davinci_uart_config uart_config __initdata = { |
| 643 | .enabled_uarts = (1 << 0), |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 644 | }; |
| 645 | |
| 646 | static void __init |
| 647 | davinci_evm_map_io(void) |
| 648 | { |
Muralidharan Karicheri | ab8e8df | 2009-09-16 11:53:18 -0400 | [diff] [blame] | 649 | /* setup input configuration for VPFE input devices */ |
| 650 | dm644x_set_vpfe_config(&vpfe_cfg); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 651 | dm644x_init(); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 652 | } |
| 653 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 654 | static int davinci_phy_fixup(struct phy_device *phydev) |
| 655 | { |
| 656 | unsigned int control; |
| 657 | /* CRITICAL: Fix for increasing PHY signal drive strength for |
| 658 | * TX lockup issue. On DaVinci EVM, the Intel LXT971 PHY |
| 659 | * signal strength was low causing TX to fail randomly. The |
| 660 | * fix is to Set bit 11 (Increased MII drive strength) of PHY |
| 661 | * register 26 (Digital Config register) on this phy. */ |
| 662 | control = phy_read(phydev, 26); |
| 663 | phy_write(phydev, 26, (control | 0x800)); |
| 664 | return 0; |
| 665 | } |
| 666 | |
| 667 | #if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \ |
| 668 | defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE) |
| 669 | #define HAS_ATA 1 |
| 670 | #else |
| 671 | #define HAS_ATA 0 |
| 672 | #endif |
| 673 | |
| 674 | #if defined(CONFIG_MTD_PHYSMAP) || \ |
| 675 | defined(CONFIG_MTD_PHYSMAP_MODULE) |
| 676 | #define HAS_NOR 1 |
| 677 | #else |
| 678 | #define HAS_NOR 0 |
| 679 | #endif |
| 680 | |
| 681 | #if defined(CONFIG_MTD_NAND_DAVINCI) || \ |
| 682 | defined(CONFIG_MTD_NAND_DAVINCI_MODULE) |
| 683 | #define HAS_NAND 1 |
| 684 | #else |
| 685 | #define HAS_NAND 0 |
| 686 | #endif |
| 687 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 688 | static __init void davinci_evm_init(void) |
| 689 | { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 690 | struct clk *aemif_clk; |
Mark A. Greer | 972412b | 2009-04-15 12:40:56 -0700 | [diff] [blame] | 691 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 692 | |
| 693 | aemif_clk = clk_get(NULL, "aemif"); |
| 694 | clk_enable(aemif_clk); |
| 695 | |
| 696 | if (HAS_ATA) { |
| 697 | if (HAS_NAND || HAS_NOR) |
| 698 | pr_warning("WARNING: both IDE and Flash are " |
| 699 | "enabled, but they share AEMIF pins.\n" |
| 700 | "\tDisable IDE for NAND/NOR support.\n"); |
| 701 | davinci_cfg_reg(DM644X_HPIEN_DISABLE); |
| 702 | davinci_cfg_reg(DM644X_ATAEN); |
| 703 | davinci_cfg_reg(DM644X_HDIREN); |
| 704 | platform_device_register(&ide_dev); |
| 705 | } else if (HAS_NAND || HAS_NOR) { |
| 706 | davinci_cfg_reg(DM644X_HPIEN_DISABLE); |
| 707 | davinci_cfg_reg(DM644X_ATAEN_DISABLE); |
| 708 | |
| 709 | /* only one device will be jumpered and detected */ |
| 710 | if (HAS_NAND) { |
| 711 | platform_device_register(&davinci_evm_nandflash_device); |
| 712 | evm_leds[7].default_trigger = "nand-disk"; |
| 713 | if (HAS_NOR) |
| 714 | pr_warning("WARNING: both NAND and NOR flash " |
| 715 | "are enabled; disable one of them.\n"); |
| 716 | } else if (HAS_NOR) |
| 717 | platform_device_register(&davinci_evm_norflash_device); |
| 718 | } |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 719 | |
| 720 | platform_add_devices(davinci_evm_devices, |
| 721 | ARRAY_SIZE(davinci_evm_devices)); |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 722 | evm_init_i2c(); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 723 | |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 724 | davinci_setup_mmc(0, &dm6446evm_mmc_config); |
| 725 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 726 | davinci_serial_init(&uart_config); |
Chaithrika U S | 25acf55 | 2009-06-05 06:28:08 -0400 | [diff] [blame] | 727 | dm644x_init_asp(&dm644x_evm_snd_data); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 728 | |
Mark A. Greer | 972412b | 2009-04-15 12:40:56 -0700 | [diff] [blame] | 729 | soc_info->emac_pdata->phy_mask = DM644X_EVM_PHY_MASK; |
| 730 | soc_info->emac_pdata->mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY; |
Kevin Hilman | ac7b75b | 2009-05-07 06:19:40 -0700 | [diff] [blame] | 731 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 732 | /* Register the fixup for PHY on DaVinci */ |
| 733 | phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, |
| 734 | davinci_phy_fixup); |
| 735 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | static __init void davinci_evm_irq_init(void) |
| 739 | { |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 740 | davinci_irq_init(); |
| 741 | } |
| 742 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame] | 743 | MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM") |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 744 | /* Maintainer: MontaVista Software <source@mvista.com> */ |
| 745 | .phys_io = IO_PHYS, |
Kevin Hilman | ac7643e | 2008-09-15 04:09:14 -0700 | [diff] [blame] | 746 | .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 747 | .boot_params = (DAVINCI_DDR_BASE + 0x100), |
| 748 | .map_io = davinci_evm_map_io, |
| 749 | .init_irq = davinci_evm_irq_init, |
| 750 | .timer = &davinci_timer, |
| 751 | .init_machine = davinci_evm_init, |
| 752 | MACHINE_END |