diff options
-rw-r--r-- | arch/arm/mach-davinci/board-mityomapl138.c | 83 |
1 files changed, 75 insertions, 8 deletions
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c index 0bb5f0ce4fdc..0ea59327dc28 100644 --- a/arch/arm/mach-davinci/board-mityomapl138.c +++ b/arch/arm/mach-davinci/board-mityomapl138.c | |||
@@ -44,38 +44,109 @@ struct factory_config { | |||
44 | 44 | ||
45 | static struct factory_config factory_config; | 45 | static struct factory_config factory_config; |
46 | 46 | ||
47 | struct part_no_info { | ||
48 | const char *part_no; /* part number string of interest */ | ||
49 | int max_freq; /* khz */ | ||
50 | }; | ||
51 | |||
52 | static struct part_no_info mityomapl138_pn_info[] = { | ||
53 | { | ||
54 | .part_no = "L138-C", | ||
55 | .max_freq = 300000, | ||
56 | }, | ||
57 | { | ||
58 | .part_no = "L138-D", | ||
59 | .max_freq = 375000, | ||
60 | }, | ||
61 | { | ||
62 | .part_no = "L138-F", | ||
63 | .max_freq = 456000, | ||
64 | }, | ||
65 | { | ||
66 | .part_no = "1808-C", | ||
67 | .max_freq = 300000, | ||
68 | }, | ||
69 | { | ||
70 | .part_no = "1808-D", | ||
71 | .max_freq = 375000, | ||
72 | }, | ||
73 | { | ||
74 | .part_no = "1808-F", | ||
75 | .max_freq = 456000, | ||
76 | }, | ||
77 | { | ||
78 | .part_no = "1810-D", | ||
79 | .max_freq = 375000, | ||
80 | }, | ||
81 | }; | ||
82 | |||
83 | #ifdef CONFIG_CPU_FREQ | ||
84 | static void mityomapl138_cpufreq_init(const char *partnum) | ||
85 | { | ||
86 | int i, ret; | ||
87 | |||
88 | for (i = 0; partnum && i < ARRAY_SIZE(mityomapl138_pn_info); i++) { | ||
89 | /* | ||
90 | * the part number has additional characters beyond what is | ||
91 | * stored in the table. This information is not needed for | ||
92 | * determining the speed grade, and would require several | ||
93 | * more table entries. Only check the first N characters | ||
94 | * for a match. | ||
95 | */ | ||
96 | if (!strncmp(partnum, mityomapl138_pn_info[i].part_no, | ||
97 | strlen(mityomapl138_pn_info[i].part_no))) { | ||
98 | da850_max_speed = mityomapl138_pn_info[i].max_freq; | ||
99 | break; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | ret = da850_register_cpufreq("pll0_sysclk3"); | ||
104 | if (ret) | ||
105 | pr_warning("cpufreq registration failed: %d\n", ret); | ||
106 | } | ||
107 | #else | ||
108 | static void mityomapl138_cpufreq_init(const char *partnum) { } | ||
109 | #endif | ||
110 | |||
47 | static void read_factory_config(struct memory_accessor *a, void *context) | 111 | static void read_factory_config(struct memory_accessor *a, void *context) |
48 | { | 112 | { |
49 | int ret; | 113 | int ret; |
114 | const char *partnum = NULL; | ||
50 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 115 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
51 | 116 | ||
52 | ret = a->read(a, (char *)&factory_config, 0, sizeof(factory_config)); | 117 | ret = a->read(a, (char *)&factory_config, 0, sizeof(factory_config)); |
53 | if (ret != sizeof(struct factory_config)) { | 118 | if (ret != sizeof(struct factory_config)) { |
54 | pr_warning("MityOMAPL138: Read Factory Config Failed: %d\n", | 119 | pr_warning("MityOMAPL138: Read Factory Config Failed: %d\n", |
55 | ret); | 120 | ret); |
56 | return; | 121 | goto bad_config; |
57 | } | 122 | } |
58 | 123 | ||
59 | if (factory_config.magic != FACTORY_CONFIG_MAGIC) { | 124 | if (factory_config.magic != FACTORY_CONFIG_MAGIC) { |
60 | pr_warning("MityOMAPL138: Factory Config Magic Wrong (%X)\n", | 125 | pr_warning("MityOMAPL138: Factory Config Magic Wrong (%X)\n", |
61 | factory_config.magic); | 126 | factory_config.magic); |
62 | return; | 127 | goto bad_config; |
63 | } | 128 | } |
64 | 129 | ||
65 | if (factory_config.version != FACTORY_CONFIG_VERSION) { | 130 | if (factory_config.version != FACTORY_CONFIG_VERSION) { |
66 | pr_warning("MityOMAPL138: Factory Config Version Wrong (%X)\n", | 131 | pr_warning("MityOMAPL138: Factory Config Version Wrong (%X)\n", |
67 | factory_config.version); | 132 | factory_config.version); |
68 | return; | 133 | goto bad_config; |
69 | } | 134 | } |
70 | 135 | ||
71 | pr_info("MityOMAPL138: Found MAC = %pM\n", factory_config.mac); | 136 | 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)) | 137 | if (is_valid_ether_addr(factory_config.mac)) |
74 | memcpy(soc_info->emac_pdata->mac_addr, | 138 | memcpy(soc_info->emac_pdata->mac_addr, |
75 | factory_config.mac, ETH_ALEN); | 139 | factory_config.mac, ETH_ALEN); |
76 | else | 140 | else |
77 | pr_warning("MityOMAPL138: Invalid MAC found " | 141 | pr_warning("MityOMAPL138: Invalid MAC found " |
78 | "in factory config block\n"); | 142 | "in factory config block\n"); |
143 | |||
144 | partnum = factory_config.partnum; | ||
145 | pr_info("MityOMAPL138: Part Number = %s\n", partnum); | ||
146 | |||
147 | bad_config: | ||
148 | /* default maximum speed is valid for all platforms */ | ||
149 | mityomapl138_cpufreq_init(partnum); | ||
79 | } | 150 | } |
80 | 151 | ||
81 | static struct at24_platform_data mityomapl138_fd_chip = { | 152 | static struct at24_platform_data mityomapl138_fd_chip = { |
@@ -383,10 +454,6 @@ static void __init mityomapl138_init(void) | |||
383 | if (ret) | 454 | if (ret) |
384 | pr_warning("rtc setup failed: %d\n", ret); | 455 | pr_warning("rtc setup failed: %d\n", ret); |
385 | 456 | ||
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(); | 457 | ret = da8xx_register_cpuidle(); |
391 | if (ret) | 458 | if (ret) |
392 | pr_warning("cpuidle registration failed: %d\n", ret); | 459 | pr_warning("cpuidle registration failed: %d\n", ret); |