Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvmem: an8855: Add support for Airoha AN8855 Switch EFUSE

Add support for Airoha AN8855 Switch EFUSE. These EFUSE might be used
for calibration data for the internal switch PHYs.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://lore.kernel.org/r/20250912131415.303407-6-srini@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christian Marangi and committed by
Greg Kroah-Hartman
e2258cfd ddb095e8

+81
+11
drivers/nvmem/Kconfig
··· 28 28 29 29 # Devices 30 30 31 + config NVMEM_AN8855_EFUSE 32 + tristate "Airoha AN8855 eFuse support" 33 + depends on MFD_AIROHA_AN8855 || COMPILE_TEST 34 + help 35 + Say y here to enable support for reading eFuses on Airoha AN8855 36 + Switch. These are e.g. used to store factory programmed 37 + calibration data required for the PHY. 38 + 39 + This driver can also be built as a module. If so, the module will 40 + be called nvmem-an8855-efuse. 41 + 31 42 config NVMEM_APPLE_EFUSES 32 43 tristate "Apple eFuse support" 33 44 depends on ARCH_APPLE || COMPILE_TEST
+2
drivers/nvmem/Makefile
··· 10 10 obj-y += layouts/ 11 11 12 12 # Devices 13 + obj-$(CONFIG_NVMEM_AN8855_EFUSE) += nvmem-an8855-efuse.o 14 + nvmem-an8855-efuse-y := an8855-efuse.o 13 15 obj-$(CONFIG_NVMEM_APPLE_EFUSES) += nvmem-apple-efuses.o 14 16 nvmem-apple-efuses-y := apple-efuses.o 15 17 obj-$(CONFIG_NVMEM_APPLE_SPMI) += apple_nvmem_spmi.o
+68
drivers/nvmem/an8855-efuse.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Airoha AN8855 Switch EFUSE Driver 4 + */ 5 + 6 + #include <linux/mod_devicetable.h> 7 + #include <linux/module.h> 8 + #include <linux/nvmem-provider.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/regmap.h> 11 + 12 + #define AN8855_EFUSE_CELL 50 13 + 14 + #define AN8855_EFUSE_DATA0 0x1000a500 15 + #define AN8855_EFUSE_R50O GENMASK(30, 24) 16 + 17 + static int an8855_efuse_read(void *context, unsigned int offset, 18 + void *val, size_t bytes) 19 + { 20 + struct regmap *regmap = context; 21 + 22 + return regmap_bulk_read(regmap, AN8855_EFUSE_DATA0 + offset, 23 + val, bytes / sizeof(u32)); 24 + } 25 + 26 + static int an8855_efuse_probe(struct platform_device *pdev) 27 + { 28 + struct nvmem_config an8855_nvmem_config = { 29 + .name = "an8855-efuse", 30 + .size = AN8855_EFUSE_CELL * sizeof(u32), 31 + .stride = sizeof(u32), 32 + .word_size = sizeof(u32), 33 + .reg_read = an8855_efuse_read, 34 + }; 35 + struct device *dev = &pdev->dev; 36 + struct nvmem_device *nvmem; 37 + struct regmap *regmap; 38 + 39 + /* Assign NVMEM priv to MFD regmap */ 40 + regmap = dev_get_regmap(dev->parent, NULL); 41 + if (!regmap) 42 + return -ENOENT; 43 + 44 + an8855_nvmem_config.priv = regmap; 45 + an8855_nvmem_config.dev = dev; 46 + nvmem = devm_nvmem_register(dev, &an8855_nvmem_config); 47 + 48 + return PTR_ERR_OR_ZERO(nvmem); 49 + } 50 + 51 + static const struct of_device_id an8855_efuse_of_match[] = { 52 + { .compatible = "airoha,an8855-efuse", }, 53 + { /* sentinel */ } 54 + }; 55 + MODULE_DEVICE_TABLE(of, an8855_efuse_of_match); 56 + 57 + static struct platform_driver an8855_efuse_driver = { 58 + .probe = an8855_efuse_probe, 59 + .driver = { 60 + .name = "an8855-efuse", 61 + .of_match_table = an8855_efuse_of_match, 62 + }, 63 + }; 64 + module_platform_driver(an8855_efuse_driver); 65 + 66 + MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>"); 67 + MODULE_DESCRIPTION("Driver for AN8855 Switch EFUSE"); 68 + MODULE_LICENSE("GPL");