diff options
Diffstat (limited to 'arch/arm/mach-davinci/board-mityomapl138.c')
-rw-r--r-- | arch/arm/mach-davinci/board-mityomapl138.c | 167 |
1 files changed, 159 insertions, 8 deletions
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c index 0bb5f0ce4fdc..2aa79c54f98e 100644 --- a/arch/arm/mach-davinci/board-mityomapl138.c +++ b/arch/arm/mach-davinci/board-mityomapl138.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/i2c/at24.h> | 18 | #include <linux/i2c/at24.h> |
19 | #include <linux/etherdevice.h> | 19 | #include <linux/etherdevice.h> |
20 | #include <linux/spi/spi.h> | ||
21 | #include <linux/spi/flash.h> | ||
20 | 22 | ||
21 | #include <asm/mach-types.h> | 23 | #include <asm/mach-types.h> |
22 | #include <asm/mach/arch.h> | 24 | #include <asm/mach/arch.h> |
@@ -25,6 +27,7 @@ | |||
25 | #include <mach/da8xx.h> | 27 | #include <mach/da8xx.h> |
26 | #include <mach/nand.h> | 28 | #include <mach/nand.h> |
27 | #include <mach/mux.h> | 29 | #include <mach/mux.h> |
30 | #include <mach/spi.h> | ||
28 | 31 | ||
29 | #define MITYOMAPL138_PHY_ID "0:03" | 32 | #define MITYOMAPL138_PHY_ID "0:03" |
30 | 33 | ||
@@ -44,38 +47,109 @@ struct factory_config { | |||
44 | 47 | ||
45 | static struct factory_config factory_config; | 48 | static struct factory_config factory_config; |
46 | 49 | ||
50 | struct part_no_info { | ||
51 | const char *part_no; /* part number string of interest */ | ||
52 | int max_freq; /* khz */ | ||
53 | }; | ||
54 | |||
55 | static struct part_no_info mityomapl138_pn_info[] = { | ||
56 | { | ||
57 | .part_no = "L138-C", | ||
58 | .max_freq = 300000, | ||
59 | }, | ||
60 | { | ||
61 | .part_no = "L138-D", | ||
62 | .max_freq = 375000, | ||
63 | }, | ||
64 | { | ||
65 | .part_no = "L138-F", | ||
66 | .max_freq = 456000, | ||
67 | }, | ||
68 | { | ||
69 | .part_no = "1808-C", | ||
70 | .max_freq = 300000, | ||
71 | }, | ||
72 | { | ||
73 | .part_no = "1808-D", | ||
74 | .max_freq = 375000, | ||
75 | }, | ||
76 | { | ||
77 | .part_no = "1808-F", | ||
78 | .max_freq = 456000, | ||
79 | }, | ||
80 | { | ||
81 | .part_no = "1810-D", | ||
82 | .max_freq = 375000, | ||
83 | }, | ||
84 | }; | ||
85 | |||
86 | #ifdef CONFIG_CPU_FREQ | ||
87 | static void mityomapl138_cpufreq_init(const char *partnum) | ||
88 | { | ||
89 | int i, ret; | ||
90 | |||
91 | for (i = 0; partnum && i < ARRAY_SIZE(mityomapl138_pn_info); i++) { | ||
92 | /* | ||
93 | * the part number has additional characters beyond what is | ||
94 | * stored in the table. This information is not needed for | ||
95 | * determining the speed grade, and would require several | ||
96 | * more table entries. Only check the first N characters | ||
97 | * for a match. | ||
98 | */ | ||
99 | if (!strncmp(partnum, mityomapl138_pn_info[i].part_no, | ||
100 | strlen(mityomapl138_pn_info[i].part_no))) { | ||
101 | da850_max_speed = mityomapl138_pn_info[i].max_freq; | ||
102 | break; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | ret = da850_register_cpufreq("pll0_sysclk3"); | ||
107 | if (ret) | ||
108 | pr_warning("cpufreq registration failed: %d\n", ret); | ||
109 | } | ||
110 | #else | ||
111 | static void mityomapl138_cpufreq_init(const char *partnum) { } | ||
112 | #endif | ||
113 | |||
47 | static void read_factory_config(struct memory_accessor *a, void *context) | 114 | static void read_factory_config(struct memory_accessor *a, void *context) |
48 | { | 115 | { |
49 | int ret; | 116 | int ret; |
117 | const char *partnum = NULL; | ||
50 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 118 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
51 | 119 | ||
52 | ret = a->read(a, (char *)&factory_config, 0, sizeof(factory_config)); | 120 | ret = a->read(a, (char *)&factory_config, 0, sizeof(factory_config)); |
53 | if (ret != sizeof(struct factory_config)) { | 121 | if (ret != sizeof(struct factory_config)) { |
54 | pr_warning("MityOMAPL138: Read Factory Config Failed: %d\n", | 122 | pr_warning("MityOMAPL138: Read Factory Config Failed: %d\n", |
55 | ret); | 123 | ret); |
56 | return; | 124 | goto bad_config; |
57 | } | 125 | } |
58 | 126 | ||
59 | if (factory_config.magic != FACTORY_CONFIG_MAGIC) { | 127 | if (factory_config.magic != FACTORY_CONFIG_MAGIC) { |
60 | pr_warning("MityOMAPL138: Factory Config Magic Wrong (%X)\n", | 128 | pr_warning("MityOMAPL138: Factory Config Magic Wrong (%X)\n", |
61 | factory_config.magic); | 129 | factory_config.magic); |
62 | return; | 130 | goto bad_config; |
63 | } | 131 | } |
64 | 132 | ||
65 | if (factory_config.version != FACTORY_CONFIG_VERSION) { | 133 | if (factory_config.version != FACTORY_CONFIG_VERSION) { |
66 | pr_warning("MityOMAPL138: Factory Config Version Wrong (%X)\n", | 134 | pr_warning("MityOMAPL138: Factory Config Version Wrong (%X)\n", |
67 | factory_config.version); | 135 | factory_config.version); |
68 | return; | 136 | goto bad_config; |
69 | } | 137 | } |
70 | 138 | ||
71 | pr_info("MityOMAPL138: Found MAC = %pM\n", factory_config.mac); | 139 | pr_info("MityOMAPL138: Found MAC = %pM\n", factory_config.mac); |
72 | pr_info("MityOMAPL138: Part Number = %s\n", factory_config.partnum); | ||
73 | if (is_valid_ether_addr(factory_config.mac)) | 140 | if (is_valid_ether_addr(factory_config.mac)) |
74 | memcpy(soc_info->emac_pdata->mac_addr, | 141 | memcpy(soc_info->emac_pdata->mac_addr, |
75 | factory_config.mac, ETH_ALEN); | 142 | factory_config.mac, ETH_ALEN); |
76 | else | 143 | else |
77 | pr_warning("MityOMAPL138: Invalid MAC found " | 144 | pr_warning("MityOMAPL138: Invalid MAC found " |
78 | "in factory config block\n"); | 145 | "in factory config block\n"); |
146 | |||
147 | partnum = factory_config.partnum; | ||
148 | pr_info("MityOMAPL138: Part Number = %s\n", partnum); | ||
149 | |||
150 | bad_config: | ||
151 | /* default maximum speed is valid for all platforms */ | ||
152 | mityomapl138_cpufreq_init(partnum); | ||
79 | } | 153 | } |
80 | 154 | ||
81 | static struct at24_platform_data mityomapl138_fd_chip = { | 155 | static struct at24_platform_data mityomapl138_fd_chip = { |
@@ -223,6 +297,82 @@ static int __init pmic_tps65023_init(void) | |||
223 | } | 297 | } |
224 | 298 | ||
225 | /* | 299 | /* |
300 | * SPI Devices: | ||
301 | * SPI1_CS0: 8M Flash ST-M25P64-VME6G | ||
302 | */ | ||
303 | static struct mtd_partition spi_flash_partitions[] = { | ||
304 | [0] = { | ||
305 | .name = "ubl", | ||
306 | .offset = 0, | ||
307 | .size = SZ_64K, | ||
308 | .mask_flags = MTD_WRITEABLE, | ||
309 | }, | ||
310 | [1] = { | ||
311 | .name = "u-boot", | ||
312 | .offset = MTDPART_OFS_APPEND, | ||
313 | .size = SZ_512K, | ||
314 | .mask_flags = MTD_WRITEABLE, | ||
315 | }, | ||
316 | [2] = { | ||
317 | .name = "u-boot-env", | ||
318 | .offset = MTDPART_OFS_APPEND, | ||
319 | .size = SZ_64K, | ||
320 | .mask_flags = MTD_WRITEABLE, | ||
321 | }, | ||
322 | [3] = { | ||
323 | .name = "periph-config", | ||
324 | .offset = MTDPART_OFS_APPEND, | ||
325 | .size = SZ_64K, | ||
326 | .mask_flags = MTD_WRITEABLE, | ||
327 | }, | ||
328 | [4] = { | ||
329 | .name = "reserved", | ||
330 | .offset = MTDPART_OFS_APPEND, | ||
331 | .size = SZ_256K + SZ_64K, | ||
332 | }, | ||
333 | [5] = { | ||
334 | .name = "kernel", | ||
335 | .offset = MTDPART_OFS_APPEND, | ||
336 | .size = SZ_2M + SZ_1M, | ||
337 | }, | ||
338 | [6] = { | ||
339 | .name = "fpga", | ||
340 | .offset = MTDPART_OFS_APPEND, | ||
341 | .size = SZ_2M, | ||
342 | }, | ||
343 | [7] = { | ||
344 | .name = "spare", | ||
345 | .offset = MTDPART_OFS_APPEND, | ||
346 | .size = MTDPART_SIZ_FULL, | ||
347 | }, | ||
348 | }; | ||
349 | |||
350 | static struct flash_platform_data mityomapl138_spi_flash_data = { | ||
351 | .name = "m25p80", | ||
352 | .parts = spi_flash_partitions, | ||
353 | .nr_parts = ARRAY_SIZE(spi_flash_partitions), | ||
354 | .type = "m24p64", | ||
355 | }; | ||
356 | |||
357 | static struct davinci_spi_config spi_eprom_config = { | ||
358 | .io_type = SPI_IO_TYPE_DMA, | ||
359 | .c2tdelay = 8, | ||
360 | .t2cdelay = 8, | ||
361 | }; | ||
362 | |||
363 | static struct spi_board_info mityomapl138_spi_flash_info[] = { | ||
364 | { | ||
365 | .modalias = "m25p80", | ||
366 | .platform_data = &mityomapl138_spi_flash_data, | ||
367 | .controller_data = &spi_eprom_config, | ||
368 | .mode = SPI_MODE_0, | ||
369 | .max_speed_hz = 30000000, | ||
370 | .bus_num = 1, | ||
371 | .chip_select = 0, | ||
372 | }, | ||
373 | }; | ||
374 | |||
375 | /* | ||
226 | * MityDSP-L138 includes a 256 MByte large-page NAND flash | 376 | * MityDSP-L138 includes a 256 MByte large-page NAND flash |
227 | * (128K blocks). | 377 | * (128K blocks). |
228 | */ | 378 | */ |
@@ -377,16 +527,17 @@ static void __init mityomapl138_init(void) | |||
377 | 527 | ||
378 | mityomapl138_setup_nand(); | 528 | mityomapl138_setup_nand(); |
379 | 529 | ||
530 | ret = da8xx_register_spi(1, mityomapl138_spi_flash_info, | ||
531 | ARRAY_SIZE(mityomapl138_spi_flash_info)); | ||
532 | if (ret) | ||
533 | pr_warning("spi 1 registration failed: %d\n", ret); | ||
534 | |||
380 | mityomapl138_config_emac(); | 535 | mityomapl138_config_emac(); |
381 | 536 | ||
382 | ret = da8xx_register_rtc(); | 537 | ret = da8xx_register_rtc(); |
383 | if (ret) | 538 | if (ret) |
384 | pr_warning("rtc setup failed: %d\n", ret); | 539 | pr_warning("rtc setup failed: %d\n", ret); |
385 | 540 | ||
386 | ret = da850_register_cpufreq("pll0_sysclk3"); | ||
387 | if (ret) | ||
388 | pr_warning("cpufreq registration failed: %d\n", ret); | ||
389 | |||
390 | ret = da8xx_register_cpuidle(); | 541 | ret = da8xx_register_cpuidle(); |
391 | if (ret) | 542 | if (ret) |
392 | pr_warning("cpuidle registration failed: %d\n", ret); | 543 | pr_warning("cpuidle registration failed: %d\n", ret); |