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