.. | .. |
---|
1 | 1 | /* |
---|
2 | 2 | * Critical Link MityOMAP-L138 SoM |
---|
3 | 3 | * |
---|
4 | | - * Copyright (C) 2010 Critical Link LLC - http://www.criticallink.com |
---|
| 4 | + * Copyright (C) 2010 Critical Link LLC - https://www.criticallink.com |
---|
5 | 5 | * |
---|
6 | 6 | * This file is licensed under the terms of the GNU General Public License |
---|
7 | 7 | * version 2. This program is licensed "as is" without any warranty of |
---|
.. | .. |
---|
14 | 14 | #include <linux/init.h> |
---|
15 | 15 | #include <linux/console.h> |
---|
16 | 16 | #include <linux/platform_device.h> |
---|
| 17 | +#include <linux/property.h> |
---|
17 | 18 | #include <linux/mtd/partitions.h> |
---|
| 19 | +#include <linux/notifier.h> |
---|
| 20 | +#include <linux/nvmem-consumer.h> |
---|
| 21 | +#include <linux/nvmem-provider.h> |
---|
18 | 22 | #include <linux/regulator/machine.h> |
---|
19 | 23 | #include <linux/i2c.h> |
---|
20 | | -#include <linux/platform_data/at24.h> |
---|
21 | 24 | #include <linux/etherdevice.h> |
---|
22 | 25 | #include <linux/spi/spi.h> |
---|
23 | 26 | #include <linux/spi/flash.h> |
---|
.. | .. |
---|
26 | 29 | #include <asm/mach-types.h> |
---|
27 | 30 | #include <asm/mach/arch.h> |
---|
28 | 31 | #include <mach/common.h> |
---|
29 | | -#include "cp_intc.h" |
---|
30 | 32 | #include <mach/da8xx.h> |
---|
31 | 33 | #include <linux/platform_data/mtd-davinci.h> |
---|
32 | 34 | #include <linux/platform_data/mtd-davinci-aemif.h> |
---|
.. | .. |
---|
116 | 118 | static void mityomapl138_cpufreq_init(const char *partnum) { } |
---|
117 | 119 | #endif |
---|
118 | 120 | |
---|
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) |
---|
120 | 123 | { |
---|
121 | 124 | int ret; |
---|
122 | 125 | 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; |
---|
124 | 130 | |
---|
125 | 131 | if (!IS_BUILTIN(CONFIG_NVMEM)) { |
---|
126 | 132 | pr_warn("Factory Config not available without CONFIG_NVMEM\n"); |
---|
.. | .. |
---|
146 | 152 | goto bad_config; |
---|
147 | 153 | } |
---|
148 | 154 | |
---|
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 | | - |
---|
156 | 155 | partnum = factory_config.partnum; |
---|
157 | 156 | pr_info("Part Number = %s\n", partnum); |
---|
158 | 157 | |
---|
159 | 158 | bad_config: |
---|
160 | 159 | /* default maximum speed is valid for all platforms */ |
---|
161 | 160 | mityomapl138_cpufreq_init(partnum); |
---|
| 161 | + |
---|
| 162 | + return NOTIFY_STOP; |
---|
162 | 163 | } |
---|
163 | 164 | |
---|
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 | + { } |
---|
170 | 198 | }; |
---|
171 | 199 | |
---|
172 | 200 | static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = { |
---|
.. | .. |
---|
295 | 323 | }, |
---|
296 | 324 | { |
---|
297 | 325 | I2C_BOARD_INFO("24c02", 0x50), |
---|
298 | | - .platform_data = &mityomapl138_fd_chip, |
---|
| 326 | + .properties = mityomapl138_fd_chip_properties, |
---|
299 | 327 | }, |
---|
300 | 328 | }; |
---|
301 | 329 | |
---|
.. | .. |
---|
404 | 432 | .core_chipsel = 1, |
---|
405 | 433 | .parts = mityomapl138_nandflash_partition, |
---|
406 | 434 | .nr_parts = ARRAY_SIZE(mityomapl138_nandflash_partition), |
---|
407 | | - .ecc_mode = NAND_ECC_HW, |
---|
| 435 | + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, |
---|
408 | 436 | .bbt_options = NAND_BBT_USE_FLASH, |
---|
409 | 437 | .options = NAND_BUSWIDTH_16, |
---|
410 | 438 | .ecc_bits = 1, /* 4 bit mode is not supported with 16 bit NAND */ |
---|
.. | .. |
---|
543 | 571 | |
---|
544 | 572 | davinci_serial_init(da8xx_serial_device); |
---|
545 | 573 | |
---|
| 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 | + |
---|
546 | 578 | ret = da8xx_register_i2c(0, &mityomap_i2c_0_pdata); |
---|
547 | 579 | if (ret) |
---|
548 | 580 | pr_warn("i2c0 registration failed: %d\n", ret); |
---|
.. | .. |
---|
595 | 627 | MACHINE_START(MITYOMAPL138, "MityDSP-L138/MityARM-1808") |
---|
596 | 628 | .atag_offset = 0x100, |
---|
597 | 629 | .map_io = mityomapl138_map_io, |
---|
598 | | - .init_irq = cp_intc_init, |
---|
| 630 | + .init_irq = da850_init_irq, |
---|
599 | 631 | .init_time = da850_init_time, |
---|
600 | 632 | .init_machine = mityomapl138_init, |
---|
601 | 633 | .init_late = davinci_init_late, |
---|