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> |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/dma-mapping.h> |
| 15 | #include <linux/platform_device.h> |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 16 | #include <linux/gpio.h> |
| 17 | #include <linux/leds.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 18 | #include <linux/memory.h> |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 19 | |
| 20 | #include <linux/i2c.h> |
| 21 | #include <linux/i2c/pcf857x.h> |
| 22 | #include <linux/i2c/at24.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 23 | #include <linux/etherdevice.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 24 | #include <linux/mtd/mtd.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 25 | #include <linux/mtd/nand.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 26 | #include <linux/mtd/partitions.h> |
| 27 | #include <linux/mtd/physmap.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 28 | #include <linux/io.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 29 | #include <linux/phy.h> |
| 30 | #include <linux/clk.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 31 | |
| 32 | #include <asm/setup.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 33 | #include <asm/mach-types.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 34 | |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/map.h> |
| 37 | #include <asm/mach/flash.h> |
| 38 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 39 | #include <mach/dm644x.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 40 | #include <mach/common.h> |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 41 | #include <mach/i2c.h> |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 42 | #include <mach/serial.h> |
| 43 | #include <mach/mux.h> |
| 44 | #include <mach/psc.h> |
| 45 | #include <mach/nand.h> |
| 46 | |
| 47 | #define DM644X_EVM_PHY_MASK (0x2) |
| 48 | #define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */ |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 49 | |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 50 | #define DAVINCI_CFC_ATA_BASE 0x01C66000 |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 51 | |
| 52 | #define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000 |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 53 | #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 54 | #define DAVINCI_ASYNC_EMIF_DATA_CE1_BASE 0x04000000 |
| 55 | #define DAVINCI_ASYNC_EMIF_DATA_CE2_BASE 0x06000000 |
| 56 | #define DAVINCI_ASYNC_EMIF_DATA_CE3_BASE 0x08000000 |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 57 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 58 | #define LXT971_PHY_ID (0x001378e2) |
| 59 | #define LXT971_PHY_MASK (0xfffffff0) |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 60 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 61 | static struct mtd_partition davinci_evm_norflash_partitions[] = { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 62 | /* bootloader (UBL, U-Boot, etc) in first 5 sectors */ |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 63 | { |
| 64 | .name = "bootloader", |
| 65 | .offset = 0, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 66 | .size = 5 * SZ_64K, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 67 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 68 | }, |
| 69 | /* bootloader params in the next 1 sectors */ |
| 70 | { |
| 71 | .name = "params", |
| 72 | .offset = MTDPART_OFS_APPEND, |
| 73 | .size = SZ_64K, |
| 74 | .mask_flags = 0, |
| 75 | }, |
| 76 | /* kernel */ |
| 77 | { |
| 78 | .name = "kernel", |
| 79 | .offset = MTDPART_OFS_APPEND, |
| 80 | .size = SZ_2M, |
| 81 | .mask_flags = 0 |
| 82 | }, |
| 83 | /* file system */ |
| 84 | { |
| 85 | .name = "filesystem", |
| 86 | .offset = MTDPART_OFS_APPEND, |
| 87 | .size = MTDPART_SIZ_FULL, |
| 88 | .mask_flags = 0 |
| 89 | } |
| 90 | }; |
| 91 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 92 | static struct physmap_flash_data davinci_evm_norflash_data = { |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 93 | .width = 2, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 94 | .parts = davinci_evm_norflash_partitions, |
| 95 | .nr_parts = ARRAY_SIZE(davinci_evm_norflash_partitions), |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | /* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF |
| 99 | * limits addresses to 16M, so using addresses past 16M will wrap */ |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 100 | static struct resource davinci_evm_norflash_resource = { |
| 101 | .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE, |
| 102 | .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 103 | .flags = IORESOURCE_MEM, |
| 104 | }; |
| 105 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 106 | static struct platform_device davinci_evm_norflash_device = { |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 107 | .name = "physmap-flash", |
| 108 | .id = 0, |
| 109 | .dev = { |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 110 | .platform_data = &davinci_evm_norflash_data, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 111 | }, |
| 112 | .num_resources = 1, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 113 | .resource = &davinci_evm_norflash_resource, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 114 | }; |
| 115 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 116 | struct mtd_partition davinci_evm_nandflash_partition[] = { |
| 117 | /* 5 MB space at the beginning for bootloader and kernel */ |
| 118 | { |
| 119 | .name = "NAND filesystem", |
| 120 | .offset = 5 * SZ_1M, |
| 121 | .size = MTDPART_SIZ_FULL, |
| 122 | .mask_flags = 0, |
| 123 | } |
| 124 | }; |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 125 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 126 | static struct davinci_nand_pdata davinci_evm_nandflash_data = { |
| 127 | .parts = davinci_evm_nandflash_partition, |
| 128 | .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition), |
| 129 | .ecc_mode = NAND_ECC_HW, |
| 130 | }; |
| 131 | |
| 132 | static struct resource davinci_evm_nandflash_resource[] = { |
| 133 | { |
| 134 | .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE, |
| 135 | .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1, |
| 136 | .flags = IORESOURCE_MEM, |
| 137 | }, { |
| 138 | .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE, |
| 139 | .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1, |
| 140 | .flags = IORESOURCE_MEM, |
| 141 | }, |
| 142 | }; |
| 143 | |
| 144 | static struct platform_device davinci_evm_nandflash_device = { |
| 145 | .name = "davinci_nand", |
| 146 | .id = 0, |
| 147 | .dev = { |
| 148 | .platform_data = &davinci_evm_nandflash_data, |
| 149 | }, |
| 150 | .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource), |
| 151 | .resource = davinci_evm_nandflash_resource, |
| 152 | }; |
| 153 | |
| 154 | static u64 davinci_fb_dma_mask = DMA_32BIT_MASK; |
| 155 | |
| 156 | static struct platform_device davinci_fb_device = { |
| 157 | .name = "davincifb", |
| 158 | .id = -1, |
| 159 | .dev = { |
| 160 | .dma_mask = &davinci_fb_dma_mask, |
| 161 | .coherent_dma_mask = DMA_32BIT_MASK, |
| 162 | }, |
| 163 | .num_resources = 0, |
| 164 | }; |
| 165 | |
| 166 | static struct platform_device rtc_dev = { |
| 167 | .name = "rtc_davinci_evm", |
| 168 | .id = -1, |
| 169 | }; |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 170 | |
| 171 | static struct resource ide_resources[] = { |
| 172 | { |
| 173 | .start = DAVINCI_CFC_ATA_BASE, |
| 174 | .end = DAVINCI_CFC_ATA_BASE + 0x7ff, |
| 175 | .flags = IORESOURCE_MEM, |
| 176 | }, |
| 177 | { |
| 178 | .start = IRQ_IDE, |
| 179 | .end = IRQ_IDE, |
| 180 | .flags = IORESOURCE_IRQ, |
| 181 | }, |
| 182 | }; |
| 183 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 184 | static u64 ide_dma_mask = DMA_32BIT_MASK; |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 185 | |
| 186 | static struct platform_device ide_dev = { |
| 187 | .name = "palm_bk3710", |
| 188 | .id = -1, |
| 189 | .resource = ide_resources, |
| 190 | .num_resources = ARRAY_SIZE(ide_resources), |
| 191 | .dev = { |
| 192 | .dma_mask = &ide_dma_mask, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 193 | .coherent_dma_mask = DMA_32BIT_MASK, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 194 | }, |
| 195 | }; |
| 196 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 197 | /*----------------------------------------------------------------------*/ |
| 198 | |
| 199 | /* |
| 200 | * I2C GPIO expanders |
| 201 | */ |
| 202 | |
| 203 | #define PCF_Uxx_BASE(x) (DAVINCI_N_GPIO + ((x) * 8)) |
| 204 | |
| 205 | |
| 206 | /* U2 -- LEDs */ |
| 207 | |
| 208 | static struct gpio_led evm_leds[] = { |
| 209 | { .name = "DS8", .active_low = 1, |
| 210 | .default_trigger = "heartbeat", }, |
| 211 | { .name = "DS7", .active_low = 1, }, |
| 212 | { .name = "DS6", .active_low = 1, }, |
| 213 | { .name = "DS5", .active_low = 1, }, |
| 214 | { .name = "DS4", .active_low = 1, }, |
| 215 | { .name = "DS3", .active_low = 1, }, |
| 216 | { .name = "DS2", .active_low = 1, |
| 217 | .default_trigger = "mmc0", }, |
| 218 | { .name = "DS1", .active_low = 1, |
| 219 | .default_trigger = "ide-disk", }, |
| 220 | }; |
| 221 | |
| 222 | static const struct gpio_led_platform_data evm_led_data = { |
| 223 | .num_leds = ARRAY_SIZE(evm_leds), |
| 224 | .leds = evm_leds, |
| 225 | }; |
| 226 | |
| 227 | static struct platform_device *evm_led_dev; |
| 228 | |
| 229 | static int |
| 230 | evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 231 | { |
| 232 | struct gpio_led *leds = evm_leds; |
| 233 | int status; |
| 234 | |
| 235 | while (ngpio--) { |
| 236 | leds->gpio = gpio++; |
| 237 | leds++; |
| 238 | } |
| 239 | |
| 240 | /* what an extremely annoying way to be forced to handle |
| 241 | * device unregistration ... |
| 242 | */ |
| 243 | evm_led_dev = platform_device_alloc("leds-gpio", 0); |
| 244 | platform_device_add_data(evm_led_dev, |
| 245 | &evm_led_data, sizeof evm_led_data); |
| 246 | |
| 247 | evm_led_dev->dev.parent = &client->dev; |
| 248 | status = platform_device_add(evm_led_dev); |
| 249 | if (status < 0) { |
| 250 | platform_device_put(evm_led_dev); |
| 251 | evm_led_dev = NULL; |
| 252 | } |
| 253 | return status; |
| 254 | } |
| 255 | |
| 256 | static int |
| 257 | evm_led_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 258 | { |
| 259 | if (evm_led_dev) { |
| 260 | platform_device_unregister(evm_led_dev); |
| 261 | evm_led_dev = NULL; |
| 262 | } |
| 263 | return 0; |
| 264 | } |
| 265 | |
| 266 | static struct pcf857x_platform_data pcf_data_u2 = { |
| 267 | .gpio_base = PCF_Uxx_BASE(0), |
| 268 | .setup = evm_led_setup, |
| 269 | .teardown = evm_led_teardown, |
| 270 | }; |
| 271 | |
| 272 | |
| 273 | /* U18 - A/V clock generator and user switch */ |
| 274 | |
| 275 | static int sw_gpio; |
| 276 | |
| 277 | static ssize_t |
| 278 | sw_show(struct device *d, struct device_attribute *a, char *buf) |
| 279 | { |
| 280 | char *s = gpio_get_value_cansleep(sw_gpio) ? "on\n" : "off\n"; |
| 281 | |
| 282 | strcpy(buf, s); |
| 283 | return strlen(s); |
| 284 | } |
| 285 | |
| 286 | static DEVICE_ATTR(user_sw, S_IRUGO, sw_show, NULL); |
| 287 | |
| 288 | static int |
| 289 | evm_u18_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 290 | { |
| 291 | int status; |
| 292 | |
| 293 | /* export dip switch option */ |
| 294 | sw_gpio = gpio + 7; |
| 295 | status = gpio_request(sw_gpio, "user_sw"); |
| 296 | if (status == 0) |
| 297 | status = gpio_direction_input(sw_gpio); |
| 298 | if (status == 0) |
| 299 | status = device_create_file(&client->dev, &dev_attr_user_sw); |
| 300 | else |
| 301 | gpio_free(sw_gpio); |
| 302 | if (status != 0) |
| 303 | sw_gpio = -EINVAL; |
| 304 | |
| 305 | /* audio PLL: 48 kHz (vs 44.1 or 32), single rate (vs double) */ |
| 306 | gpio_request(gpio + 3, "pll_fs2"); |
| 307 | gpio_direction_output(gpio + 3, 0); |
| 308 | |
| 309 | gpio_request(gpio + 2, "pll_fs1"); |
| 310 | gpio_direction_output(gpio + 2, 0); |
| 311 | |
| 312 | gpio_request(gpio + 1, "pll_sr"); |
| 313 | gpio_direction_output(gpio + 1, 0); |
| 314 | |
| 315 | return 0; |
| 316 | } |
| 317 | |
| 318 | static int |
| 319 | evm_u18_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 320 | { |
| 321 | gpio_free(gpio + 1); |
| 322 | gpio_free(gpio + 2); |
| 323 | gpio_free(gpio + 3); |
| 324 | |
| 325 | if (sw_gpio > 0) { |
| 326 | device_remove_file(&client->dev, &dev_attr_user_sw); |
| 327 | gpio_free(sw_gpio); |
| 328 | } |
| 329 | return 0; |
| 330 | } |
| 331 | |
| 332 | static struct pcf857x_platform_data pcf_data_u18 = { |
| 333 | .gpio_base = PCF_Uxx_BASE(1), |
| 334 | .n_latch = (1 << 3) | (1 << 2) | (1 << 1), |
| 335 | .setup = evm_u18_setup, |
| 336 | .teardown = evm_u18_teardown, |
| 337 | }; |
| 338 | |
| 339 | |
| 340 | /* U35 - various I/O signals used to manage USB, CF, ATA, etc */ |
| 341 | |
| 342 | static int |
| 343 | evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 344 | { |
| 345 | /* p0 = nDRV_VBUS (initial: don't supply it) */ |
| 346 | gpio_request(gpio + 0, "nDRV_VBUS"); |
| 347 | gpio_direction_output(gpio + 0, 1); |
| 348 | |
| 349 | /* p1 = VDDIMX_EN */ |
| 350 | gpio_request(gpio + 1, "VDDIMX_EN"); |
| 351 | gpio_direction_output(gpio + 1, 1); |
| 352 | |
| 353 | /* p2 = VLYNQ_EN */ |
| 354 | gpio_request(gpio + 2, "VLYNQ_EN"); |
| 355 | gpio_direction_output(gpio + 2, 1); |
| 356 | |
| 357 | /* p3 = n3V3_CF_RESET (initial: stay in reset) */ |
| 358 | gpio_request(gpio + 3, "nCF_RESET"); |
| 359 | gpio_direction_output(gpio + 3, 0); |
| 360 | |
| 361 | /* (p4 unused) */ |
| 362 | |
| 363 | /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */ |
| 364 | gpio_request(gpio + 5, "WLAN_RESET"); |
| 365 | gpio_direction_output(gpio + 5, 1); |
| 366 | |
| 367 | /* p6 = nATA_SEL (initial: select) */ |
| 368 | gpio_request(gpio + 6, "nATA_SEL"); |
| 369 | gpio_direction_output(gpio + 6, 0); |
| 370 | |
| 371 | /* p7 = nCF_SEL (initial: deselect) */ |
| 372 | gpio_request(gpio + 7, "nCF_SEL"); |
| 373 | gpio_direction_output(gpio + 7, 1); |
| 374 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 375 | /* irlml6401 switches over 1A, in under 8 msec; |
| 376 | * now it can be managed by nDRV_VBUS ... |
| 377 | */ |
David Brownell | 34f32c9 | 2009-02-20 13:45:17 -0800 | [diff] [blame] | 378 | setup_usb(500, 8); |
| 379 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | static int |
| 384 | evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c) |
| 385 | { |
| 386 | gpio_free(gpio + 7); |
| 387 | gpio_free(gpio + 6); |
| 388 | gpio_free(gpio + 5); |
| 389 | gpio_free(gpio + 3); |
| 390 | gpio_free(gpio + 2); |
| 391 | gpio_free(gpio + 1); |
| 392 | gpio_free(gpio + 0); |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | static struct pcf857x_platform_data pcf_data_u35 = { |
| 397 | .gpio_base = PCF_Uxx_BASE(2), |
| 398 | .setup = evm_u35_setup, |
| 399 | .teardown = evm_u35_teardown, |
| 400 | }; |
| 401 | |
| 402 | /*----------------------------------------------------------------------*/ |
| 403 | |
| 404 | /* Most of this EEPROM is unused, but U-Boot uses some data: |
| 405 | * - 0x7f00, 6 bytes Ethernet Address |
| 406 | * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL) |
| 407 | * - ... newer boards may have more |
| 408 | */ |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 409 | static struct memory_accessor *at24_mem_acc; |
| 410 | |
| 411 | static void at24_setup(struct memory_accessor *mem_acc, void *context) |
| 412 | { |
| 413 | DECLARE_MAC_BUF(mac_str); |
| 414 | char mac_addr[6]; |
| 415 | |
| 416 | at24_mem_acc = mem_acc; |
| 417 | |
| 418 | /* Read MAC addr from EEPROM */ |
| 419 | if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, 6) == 6) { |
| 420 | printk(KERN_INFO "Read MAC addr from EEPROM: %s\n", |
| 421 | print_mac(mac_str, mac_addr)); |
| 422 | } |
| 423 | } |
| 424 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 425 | static struct at24_platform_data eeprom_info = { |
| 426 | .byte_len = (256*1024) / 8, |
| 427 | .page_size = 64, |
| 428 | .flags = AT24_FLAG_ADDR16, |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 429 | .setup = at24_setup, |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 430 | }; |
| 431 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 432 | int dm6446evm_eeprom_read(void *buf, off_t off, size_t count) |
| 433 | { |
| 434 | if (at24_mem_acc) |
| 435 | return at24_mem_acc->read(at24_mem_acc, buf, off, count); |
| 436 | return -ENODEV; |
| 437 | } |
| 438 | EXPORT_SYMBOL(dm6446evm_eeprom_read); |
| 439 | |
| 440 | int dm6446evm_eeprom_write(void *buf, off_t off, size_t count) |
| 441 | { |
| 442 | if (at24_mem_acc) |
| 443 | return at24_mem_acc->write(at24_mem_acc, buf, off, count); |
| 444 | return -ENODEV; |
| 445 | } |
| 446 | EXPORT_SYMBOL(dm6446evm_eeprom_write); |
| 447 | |
| 448 | /* |
| 449 | * MSP430 supports RTC, card detection, input from IR remote, and |
| 450 | * a bit more. It triggers interrupts on GPIO(7) from pressing |
| 451 | * buttons on the IR remote, and for card detect switches. |
| 452 | */ |
| 453 | static struct i2c_client *dm6446evm_msp; |
| 454 | |
| 455 | static int dm6446evm_msp_probe(struct i2c_client *client, |
| 456 | const struct i2c_device_id *id) |
| 457 | { |
| 458 | dm6446evm_msp = client; |
| 459 | return 0; |
| 460 | } |
| 461 | |
| 462 | static int dm6446evm_msp_remove(struct i2c_client *client) |
| 463 | { |
| 464 | dm6446evm_msp = NULL; |
| 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | static const struct i2c_device_id dm6446evm_msp_ids[] = { |
| 469 | { "dm6446evm_msp", 0, }, |
| 470 | { /* end of list */ }, |
| 471 | }; |
| 472 | |
| 473 | static struct i2c_driver dm6446evm_msp_driver = { |
| 474 | .driver.name = "dm6446evm_msp", |
| 475 | .id_table = dm6446evm_msp_ids, |
| 476 | .probe = dm6446evm_msp_probe, |
| 477 | .remove = dm6446evm_msp_remove, |
| 478 | }; |
| 479 | |
| 480 | static int dm6444evm_msp430_get_pins(void) |
| 481 | { |
| 482 | static const char txbuf[2] = { 2, 4, }; |
| 483 | char buf[4]; |
| 484 | struct i2c_msg msg[2] = { |
| 485 | { |
| 486 | .addr = dm6446evm_msp->addr, |
| 487 | .flags = 0, |
| 488 | .len = 2, |
| 489 | .buf = (void __force *)txbuf, |
| 490 | }, |
| 491 | { |
| 492 | .addr = dm6446evm_msp->addr, |
| 493 | .flags = I2C_M_RD, |
| 494 | .len = 4, |
| 495 | .buf = buf, |
| 496 | }, |
| 497 | }; |
| 498 | int status; |
| 499 | |
| 500 | if (!dm6446evm_msp) |
| 501 | return -ENXIO; |
| 502 | |
| 503 | /* Command 4 == get input state, returns port 2 and port3 data |
| 504 | * S Addr W [A] len=2 [A] cmd=4 [A] |
| 505 | * RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P |
| 506 | */ |
| 507 | status = i2c_transfer(dm6446evm_msp->adapter, msg, 2); |
| 508 | if (status < 0) |
| 509 | return status; |
| 510 | |
| 511 | dev_dbg(&dm6446evm_msp->dev, |
| 512 | "PINS: %02x %02x %02x %02x\n", |
| 513 | buf[0], buf[1], buf[2], buf[3]); |
| 514 | |
| 515 | return (buf[3] << 8) | buf[2]; |
| 516 | } |
| 517 | |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 518 | static struct i2c_board_info __initdata i2c_info[] = { |
| 519 | { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 520 | I2C_BOARD_INFO("dm6446evm_msp", 0x23), |
| 521 | }, |
| 522 | { |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 523 | I2C_BOARD_INFO("pcf8574", 0x38), |
| 524 | .platform_data = &pcf_data_u2, |
| 525 | }, |
| 526 | { |
| 527 | I2C_BOARD_INFO("pcf8574", 0x39), |
| 528 | .platform_data = &pcf_data_u18, |
| 529 | }, |
| 530 | { |
| 531 | I2C_BOARD_INFO("pcf8574", 0x3a), |
| 532 | .platform_data = &pcf_data_u35, |
| 533 | }, |
| 534 | { |
| 535 | I2C_BOARD_INFO("24c256", 0x50), |
| 536 | .platform_data = &eeprom_info, |
| 537 | }, |
| 538 | /* ALSO: |
| 539 | * - tvl320aic33 audio codec (0x1b) |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 540 | * - tvp5146 video decoder (0x5d) |
| 541 | */ |
| 542 | }; |
| 543 | |
| 544 | /* The msp430 uses a slow bitbanged I2C implementation (ergo 20 KHz), |
| 545 | * which requires 100 usec of idle bus after i2c writes sent to it. |
| 546 | */ |
| 547 | static struct davinci_i2c_platform_data i2c_pdata = { |
| 548 | .bus_freq = 20 /* kHz */, |
| 549 | .bus_delay = 100 /* usec */, |
| 550 | }; |
| 551 | |
| 552 | static void __init evm_init_i2c(void) |
| 553 | { |
| 554 | davinci_init_i2c(&i2c_pdata); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 555 | i2c_add_driver(&dm6446evm_msp_driver); |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 556 | i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); |
| 557 | } |
| 558 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 559 | static struct platform_device *davinci_evm_devices[] __initdata = { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 560 | &davinci_fb_device, |
| 561 | &rtc_dev, |
| 562 | }; |
| 563 | |
| 564 | static struct davinci_uart_config uart_config __initdata = { |
| 565 | .enabled_uarts = (1 << 0), |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 566 | }; |
| 567 | |
| 568 | static void __init |
| 569 | davinci_evm_map_io(void) |
| 570 | { |
| 571 | davinci_map_common_io(); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 572 | dm644x_init(); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 573 | } |
| 574 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 575 | static int davinci_phy_fixup(struct phy_device *phydev) |
| 576 | { |
| 577 | unsigned int control; |
| 578 | /* CRITICAL: Fix for increasing PHY signal drive strength for |
| 579 | * TX lockup issue. On DaVinci EVM, the Intel LXT971 PHY |
| 580 | * signal strength was low causing TX to fail randomly. The |
| 581 | * fix is to Set bit 11 (Increased MII drive strength) of PHY |
| 582 | * register 26 (Digital Config register) on this phy. */ |
| 583 | control = phy_read(phydev, 26); |
| 584 | phy_write(phydev, 26, (control | 0x800)); |
| 585 | return 0; |
| 586 | } |
| 587 | |
| 588 | #if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \ |
| 589 | defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE) |
| 590 | #define HAS_ATA 1 |
| 591 | #else |
| 592 | #define HAS_ATA 0 |
| 593 | #endif |
| 594 | |
| 595 | #if defined(CONFIG_MTD_PHYSMAP) || \ |
| 596 | defined(CONFIG_MTD_PHYSMAP_MODULE) |
| 597 | #define HAS_NOR 1 |
| 598 | #else |
| 599 | #define HAS_NOR 0 |
| 600 | #endif |
| 601 | |
| 602 | #if defined(CONFIG_MTD_NAND_DAVINCI) || \ |
| 603 | defined(CONFIG_MTD_NAND_DAVINCI_MODULE) |
| 604 | #define HAS_NAND 1 |
| 605 | #else |
| 606 | #define HAS_NAND 0 |
| 607 | #endif |
| 608 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 609 | static __init void davinci_evm_init(void) |
| 610 | { |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 611 | struct clk *aemif_clk; |
| 612 | |
| 613 | aemif_clk = clk_get(NULL, "aemif"); |
| 614 | clk_enable(aemif_clk); |
| 615 | |
| 616 | if (HAS_ATA) { |
| 617 | if (HAS_NAND || HAS_NOR) |
| 618 | pr_warning("WARNING: both IDE and Flash are " |
| 619 | "enabled, but they share AEMIF pins.\n" |
| 620 | "\tDisable IDE for NAND/NOR support.\n"); |
| 621 | davinci_cfg_reg(DM644X_HPIEN_DISABLE); |
| 622 | davinci_cfg_reg(DM644X_ATAEN); |
| 623 | davinci_cfg_reg(DM644X_HDIREN); |
| 624 | platform_device_register(&ide_dev); |
| 625 | } else if (HAS_NAND || HAS_NOR) { |
| 626 | davinci_cfg_reg(DM644X_HPIEN_DISABLE); |
| 627 | davinci_cfg_reg(DM644X_ATAEN_DISABLE); |
| 628 | |
| 629 | /* only one device will be jumpered and detected */ |
| 630 | if (HAS_NAND) { |
| 631 | platform_device_register(&davinci_evm_nandflash_device); |
| 632 | evm_leds[7].default_trigger = "nand-disk"; |
| 633 | if (HAS_NOR) |
| 634 | pr_warning("WARNING: both NAND and NOR flash " |
| 635 | "are enabled; disable one of them.\n"); |
| 636 | } else if (HAS_NOR) |
| 637 | platform_device_register(&davinci_evm_norflash_device); |
| 638 | } |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 639 | |
| 640 | platform_add_devices(davinci_evm_devices, |
| 641 | ARRAY_SIZE(davinci_evm_devices)); |
David Brownell | 7bff3c4 | 2008-09-07 23:43:02 -0700 | [diff] [blame] | 642 | evm_init_i2c(); |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 643 | |
| 644 | davinci_serial_init(&uart_config); |
| 645 | |
| 646 | /* Register the fixup for PHY on DaVinci */ |
| 647 | phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, |
| 648 | davinci_phy_fixup); |
| 649 | |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | static __init void davinci_evm_irq_init(void) |
| 653 | { |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 654 | davinci_irq_init(); |
| 655 | } |
| 656 | |
Kevin Hilman | d0e47fb | 2009-04-14 11:30:11 -0500 | [diff] [blame^] | 657 | MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM") |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 658 | /* Maintainer: MontaVista Software <source@mvista.com> */ |
| 659 | .phys_io = IO_PHYS, |
Kevin Hilman | ac7643e | 2008-09-15 04:09:14 -0700 | [diff] [blame] | 660 | .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc, |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 661 | .boot_params = (DAVINCI_DDR_BASE + 0x100), |
| 662 | .map_io = davinci_evm_map_io, |
| 663 | .init_irq = davinci_evm_irq_init, |
| 664 | .timer = &davinci_timer, |
| 665 | .init_machine = davinci_evm_init, |
| 666 | MACHINE_END |