forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/arch/arm/mach-davinci/board-mityomapl138.c
....@@ -1,7 +1,7 @@
11 /*
22 * Critical Link MityOMAP-L138 SoM
33 *
4
- * Copyright (C) 2010 Critical Link LLC - http://www.criticallink.com
4
+ * Copyright (C) 2010 Critical Link LLC - https://www.criticallink.com
55 *
66 * This file is licensed under the terms of the GNU General Public License
77 * version 2. This program is licensed "as is" without any warranty of
....@@ -14,10 +14,13 @@
1414 #include <linux/init.h>
1515 #include <linux/console.h>
1616 #include <linux/platform_device.h>
17
+#include <linux/property.h>
1718 #include <linux/mtd/partitions.h>
19
+#include <linux/notifier.h>
20
+#include <linux/nvmem-consumer.h>
21
+#include <linux/nvmem-provider.h>
1822 #include <linux/regulator/machine.h>
1923 #include <linux/i2c.h>
20
-#include <linux/platform_data/at24.h>
2124 #include <linux/etherdevice.h>
2225 #include <linux/spi/spi.h>
2326 #include <linux/spi/flash.h>
....@@ -26,7 +29,6 @@
2629 #include <asm/mach-types.h>
2730 #include <asm/mach/arch.h>
2831 #include <mach/common.h>
29
-#include "cp_intc.h"
3032 #include <mach/da8xx.h>
3133 #include <linux/platform_data/mtd-davinci.h>
3234 #include <linux/platform_data/mtd-davinci-aemif.h>
....@@ -116,11 +118,15 @@
116118 static void mityomapl138_cpufreq_init(const char *partnum) { }
117119 #endif
118120
119
-static void read_factory_config(struct nvmem_device *nvmem, void *context)
121
+static int read_factory_config(struct notifier_block *nb,
122
+ unsigned long event, void *data)
120123 {
121124 int ret;
122125 const char *partnum = NULL;
123
- struct davinci_soc_info *soc_info = &davinci_soc_info;
126
+ struct nvmem_device *nvmem = data;
127
+
128
+ if (strcmp(nvmem_dev_name(nvmem), "1-00500") != 0)
129
+ return NOTIFY_DONE;
124130
125131 if (!IS_BUILTIN(CONFIG_NVMEM)) {
126132 pr_warn("Factory Config not available without CONFIG_NVMEM\n");
....@@ -146,27 +152,49 @@
146152 goto bad_config;
147153 }
148154
149
- pr_info("Found MAC = %pM\n", factory_config.mac);
150
- if (is_valid_ether_addr(factory_config.mac))
151
- memcpy(soc_info->emac_pdata->mac_addr,
152
- factory_config.mac, ETH_ALEN);
153
- else
154
- pr_warn("Invalid MAC found in factory config block\n");
155
-
156155 partnum = factory_config.partnum;
157156 pr_info("Part Number = %s\n", partnum);
158157
159158 bad_config:
160159 /* default maximum speed is valid for all platforms */
161160 mityomapl138_cpufreq_init(partnum);
161
+
162
+ return NOTIFY_STOP;
162163 }
163164
164
-static struct at24_platform_data mityomapl138_fd_chip = {
165
- .byte_len = 256,
166
- .page_size = 8,
167
- .flags = AT24_FLAG_READONLY | AT24_FLAG_IRUGO,
168
- .setup = read_factory_config,
169
- .context = NULL,
165
+static struct notifier_block mityomapl138_nvmem_notifier = {
166
+ .notifier_call = read_factory_config,
167
+};
168
+
169
+/*
170
+ * We don't define a cell for factory config as it will be accessed from the
171
+ * board file using the nvmem notifier chain.
172
+ */
173
+static struct nvmem_cell_info mityomapl138_nvmem_cells[] = {
174
+ {
175
+ .name = "macaddr",
176
+ .offset = 0x64,
177
+ .bytes = ETH_ALEN,
178
+ }
179
+};
180
+
181
+static struct nvmem_cell_table mityomapl138_nvmem_cell_table = {
182
+ .nvmem_name = "1-00500",
183
+ .cells = mityomapl138_nvmem_cells,
184
+ .ncells = ARRAY_SIZE(mityomapl138_nvmem_cells),
185
+};
186
+
187
+static struct nvmem_cell_lookup mityomapl138_nvmem_cell_lookup = {
188
+ .nvmem_name = "1-00500",
189
+ .cell_name = "macaddr",
190
+ .dev_id = "davinci_emac.1",
191
+ .con_id = "mac-address",
192
+};
193
+
194
+static const struct property_entry mityomapl138_fd_chip_properties[] = {
195
+ PROPERTY_ENTRY_U32("pagesize", 8),
196
+ PROPERTY_ENTRY_BOOL("read-only"),
197
+ { }
170198 };
171199
172200 static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = {
....@@ -295,7 +323,7 @@
295323 },
296324 {
297325 I2C_BOARD_INFO("24c02", 0x50),
298
- .platform_data = &mityomapl138_fd_chip,
326
+ .properties = mityomapl138_fd_chip_properties,
299327 },
300328 };
301329
....@@ -404,7 +432,7 @@
404432 .core_chipsel = 1,
405433 .parts = mityomapl138_nandflash_partition,
406434 .nr_parts = ARRAY_SIZE(mityomapl138_nandflash_partition),
407
- .ecc_mode = NAND_ECC_HW,
435
+ .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST,
408436 .bbt_options = NAND_BBT_USE_FLASH,
409437 .options = NAND_BUSWIDTH_16,
410438 .ecc_bits = 1, /* 4 bit mode is not supported with 16 bit NAND */
....@@ -543,6 +571,10 @@
543571
544572 davinci_serial_init(da8xx_serial_device);
545573
574
+ nvmem_register_notifier(&mityomapl138_nvmem_notifier);
575
+ nvmem_add_cell_table(&mityomapl138_nvmem_cell_table);
576
+ nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1);
577
+
546578 ret = da8xx_register_i2c(0, &mityomap_i2c_0_pdata);
547579 if (ret)
548580 pr_warn("i2c0 registration failed: %d\n", ret);
....@@ -595,7 +627,7 @@
595627 MACHINE_START(MITYOMAPL138, "MityDSP-L138/MityARM-1808")
596628 .atag_offset = 0x100,
597629 .map_io = mityomapl138_map_io,
598
- .init_irq = cp_intc_init,
630
+ .init_irq = da850_init_irq,
599631 .init_time = da850_init_time,
600632 .init_machine = mityomapl138_init,
601633 .init_late = davinci_init_late,