From 4bb6f26b05450777d14aa96e10783066c2503dc2 Mon Sep 17 00:00:00 2001 From: John Klug Date: Wed, 11 Nov 2020 16:17:52 -0600 Subject: Add new BSP submodule for Atmel Processors. --- .../mtcdt/linux-4.9-eeprom-setup-mtcdt.patch | 163 +++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 recipes-kernel/linux/linux-at91-4.9.87/mtcdt/linux-4.9-eeprom-setup-mtcdt.patch (limited to 'recipes-kernel/linux/linux-at91-4.9.87/mtcdt/linux-4.9-eeprom-setup-mtcdt.patch') diff --git a/recipes-kernel/linux/linux-at91-4.9.87/mtcdt/linux-4.9-eeprom-setup-mtcdt.patch b/recipes-kernel/linux/linux-at91-4.9.87/mtcdt/linux-4.9-eeprom-setup-mtcdt.patch new file mode 100644 index 0000000..a738ddd --- /dev/null +++ b/recipes-kernel/linux/linux-at91-4.9.87/mtcdt/linux-4.9-eeprom-setup-mtcdt.patch @@ -0,0 +1,163 @@ +diff -Naru 4.9+gitAUTOINC+29796588eb.orig/arch/arm/mach-at91/at91sam9.c 4.9+gitAUTOINC+29796588eb/arch/arm/mach-at91/at91sam9.c +--- 4.9+gitAUTOINC+29796588eb.orig/arch/arm/mach-at91/at91sam9.c 2018-10-23 11:58:04.826463464 -0500 ++++ 4.9+gitAUTOINC+29796588eb/arch/arm/mach-at91/at91sam9.c 2018-10-23 11:54:56.166469050 -0500 +@@ -14,6 +14,87 @@ + #include + + #include "generic.h" ++#include ++ ++uint8_t mts_id_eeprom[512]; ++ ++EXPORT_SYMBOL(mts_id_eeprom); ++ ++static void mts_id_eeprom_load(struct nvmem_device *nvmem, void *context) ++{ ++ int tmp; ++ ++ memset(mts_id_eeprom, 0, sizeof(mts_id_eeprom)); ++ ++ tmp = nvmem_device_read(nvmem, 0, sizeof(mts_id_eeprom), mts_id_eeprom); ++ if (tmp != sizeof(mts_id_eeprom)) { ++ printk(KERN_ERR "sam9x5: id eeprom read failed: %d\n", tmp); ++ } else { ++ printk(KERN_INFO "sam9x5: read %d bytes from id eeprom\n", tmp); ++ } ++} ++ ++struct mts_eeprom_callback id_eeprom_callback = { ++ .address = 0x56, ++ .index = -1, ++ .setup = mts_id_eeprom_load, ++}; ++ ++#ifdef CONFIG_MTS_NUM_ACCESSORY_PORTS ++#define NUM_AP CONFIG_MTS_NUM_ACCESSORY_PORTS ++#else ++#define NUM_AP 0 ++#endif ++ ++#if NUM_AP > 0 ++ ++uint8_t mts_ap_eeprom[NUM_AP][512]; ++ ++EXPORT_SYMBOL(mts_ap_eeprom); ++ ++static void mts_ap_eeprom_load(struct nvmem_device *nvmem, void *context) ++{ ++ int tmp; ++ int* index = (int*)context; ++ ++ memset(mts_ap_eeprom[*index], 0, sizeof(mts_ap_eeprom[*index])); ++ ++ tmp = macc->read(macc, mts_ap_eeprom[*index], 0, sizeof(mts_ap_eeprom[*index])); ++ tmp = nvmem_device_read(nvmem, 0, sizeof(mts_ap_eeprom[*index]), mts_ap_eeprom[*index]); ++ if (tmp != sizeof(mts_ap_eeprom[*index])) { ++ printk(KERN_INFO "sam9x5: ap%d eeprom read failed: %d\n", *index + 1, tmp); ++ } else { ++ printk(KERN_INFO "sam9x5: read %d bytes from ap%d eeprom\n", tmp, *index + 1); ++ } ++} ++ ++struct mts_eeprom_callback ap1_eeprom_callback = { ++ .address = 0x50, ++ .index = 0, ++ .setup = mts_ap_eeprom_load, ++}; ++ ++struct mts_eeprom_callback ap2_eeprom_callback = { ++ .address = 0x52, ++ .index = 1, ++ .setup = mts_ap_eeprom_load, ++}; ++ ++struct mts_eeprom_callback* mts_eeprom_callback_lookup[] = { ++ &id_eeprom_callback, ++ &ap1_eeprom_callback, ++ &ap2_eeprom_callback, ++ NULL ++}; ++ ++#else ++ ++struct mts_eeprom_callback* mts_eeprom_callback_lookup[] = { ++ &id_eeprom_callback, ++ NULL ++}; ++ ++#endif + + static void __init at91sam9_init(void) + { +Index: linux-3.12.27/drivers/misc/eeprom/at24.c +=================================================================== +--- linux-3.12.27.orig/drivers/misc/eeprom/at24.c 2014-08-26 07:12:26.000000000 -0500 ++++ linux-3.12.27/drivers/misc/eeprom/at24.c 2014-09-23 11:41:52.470331651 -0500 +@@ -24,6 +24,8 @@ + #include + #include + ++#include ++ + /* + * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable. + * Differences between different vendor product lines (like Atmel AT24C or +@@ -473,6 +475,23 @@ + chip->page_size = be32_to_cpup(val); + } + } ++ ++static void at24_get_setup(struct i2c_client *client, ++ struct at24_platform_data *chip) ++{ ++ int i; ++ ++ for (i = 0; mts_eeprom_callback_lookup[i] != NULL; i++) { ++ if (mts_eeprom_callback_lookup[i]->address == client->addr) { ++ printk(KERN_INFO "%s: found a match for eeprom at %X\n", __func__, client->addr); ++ chip->setup = mts_eeprom_callback_lookup[i]->setup; ++ if (mts_eeprom_callback_lookup[i]->index > -1) { ++ chip->context = (void*)&mts_eeprom_callback_lookup[i]->index; ++ } ++ break; ++ } ++ } ++} + #else + static void at24_get_ofdata(struct i2c_client *client, + struct at24_platform_data *chip) +@@ -505,12 +524,14 @@ + * is recommended anyhow. + */ + chip.page_size = 1; ++ chip.setup = NULL; ++ chip.context = NULL; + + /* update chipdata if OF is present */ + at24_get_ofdata(client, &chip); + +- chip.setup = NULL; +- chip.context = NULL; ++ /* see if we have a setup callback */ ++ at24_get_setup(client, &chip); + } + + if (!is_power_of_2(chip.byte_len)) +diff -Naru 4.9+gitAUTOINC+29796588eb.orig/include/linux/mts_at24.h 4.9+gitAUTOINC+29796588eb/include/linux/mts_at24.h +--- 4.9+gitAUTOINC+29796588eb.orig/include/linux/mts_at24.h 1969-12-31 18:00:00.000000000 -0600 ++++ 4.9+gitAUTOINC+29796588eb/include/linux/mts_at24.h 2018-10-23 11:45:29.406485828 -0500 +@@ -0,0 +1,14 @@ ++#ifndef _LINUX_MTSAT24_H ++#define _LINUX_MTSAT24_H ++ ++#include ++ ++struct mts_eeprom_callback { ++ unsigned short address; ++ int index; ++ void (*setup)(struct nvmem_device *, void *context); ++}; ++ ++extern struct mts_eeprom_callback* mts_eeprom_callback_lookup[]; ++ ++#endif /* _LINUX_MTSAT24_H */ -- cgit v1.2.3