// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2015 Srinivas Kandagatla <[email protected]> */ #include <linux/clk.h> #include <linux/device.h> #include <linux/io.h> #include <linux/iopoll.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/mod_devicetable.h> #include <linux/nvmem-provider.h> #include <linux/platform_device.h> #include <linux/pm_domain.h> #include <linux/pm_runtime.h> #include <linux/property.h> #include <linux/regulator/consumer.h> /* Blow timer clock frequency in Mhz */ #define QFPROM_BLOW_TIMER_OFFSET … /* Amount of time required to hold charge to blow fuse in micro-seconds */ #define QFPROM_FUSE_BLOW_POLL_US … #define QFPROM_FUSE_BLOW_TIMEOUT_US … #define QFPROM_BLOW_STATUS_OFFSET … #define QFPROM_BLOW_STATUS_BUSY … #define QFPROM_BLOW_STATUS_READY … #define QFPROM_ACCEL_OFFSET … #define QFPROM_VERSION_OFFSET … #define QFPROM_MAJOR_VERSION_SHIFT … #define QFPROM_MAJOR_VERSION_MASK … #define QFPROM_MINOR_VERSION_SHIFT … #define QFPROM_MINOR_VERSION_MASK … static bool read_raw_data; module_param(read_raw_data, bool, 0644); MODULE_PARM_DESC(…) …; /** * struct qfprom_soc_data - config that varies from SoC to SoC. * * @accel_value: Should contain qfprom accel value. * @qfprom_blow_timer_value: The timer value of qfprom when doing efuse blow. * @qfprom_blow_set_freq: The frequency required to set when we start the * fuse blowing. * @qfprom_blow_uV: LDO voltage to be set when doing efuse blow */ struct qfprom_soc_data { … }; /** * struct qfprom_priv - structure holding qfprom attributes * * @qfpraw: iomapped memory space for qfprom-efuse raw address space. * @qfpconf: iomapped memory space for qfprom-efuse configuration address * space. * @qfpcorrected: iomapped memory space for qfprom corrected address space. * @qfpsecurity: iomapped memory space for qfprom security control space. * @dev: qfprom device structure. * @secclk: Clock supply. * @vcc: Regulator supply. * @soc_data: Data that for things that varies from SoC to SoC. */ struct qfprom_priv { … }; /** * struct qfprom_touched_values - saved values to restore after blowing * * @clk_rate: The rate the clock was at before blowing. * @accel_val: The value of the accel reg before blowing. * @timer_val: The value of the timer before blowing. */ struct qfprom_touched_values { … }; /** * struct qfprom_soc_compatible_data - Data matched against the SoC * compatible string. * * @keepout: Array of keepout regions for this SoC. * @nkeepout: Number of elements in the keepout array. */ struct qfprom_soc_compatible_data { … }; static const struct nvmem_keepout sc7180_qfprom_keepout[] = …; static const struct qfprom_soc_compatible_data sc7180_qfprom = …; static const struct nvmem_keepout sc7280_qfprom_keepout[] = …; static const struct qfprom_soc_compatible_data sc7280_qfprom = …; /** * qfprom_disable_fuse_blowing() - Undo enabling of fuse blowing. * @priv: Our driver data. * @old: The data that was stashed from before fuse blowing. * * Resets the value of the blow timer, accel register and the clock * and voltage settings. * * Prints messages if there are errors but doesn't return an error code * since there's not much we can do upon failure. */ static void qfprom_disable_fuse_blowing(const struct qfprom_priv *priv, const struct qfprom_touched_values *old) { … } /** * qfprom_enable_fuse_blowing() - Enable fuse blowing. * @priv: Our driver data. * @old: We'll stash stuff here to use when disabling. * * Sets the value of the blow timer, accel register and the clock * and voltage settings. * * Prints messages if there are errors so caller doesn't need to. * * Return: 0 or -err. */ static int qfprom_enable_fuse_blowing(const struct qfprom_priv *priv, struct qfprom_touched_values *old) { … } /** * qfprom_reg_write() - Write to fuses. * @context: Our driver data. * @reg: The offset to write at. * @_val: Pointer to data to write. * @bytes: The number of bytes to write. * * Writes to fuses. WARNING: THIS IS PERMANENT. * * Return: 0 or -err. */ static int qfprom_reg_write(void *context, unsigned int reg, void *_val, size_t bytes) { … } static int qfprom_reg_read(void *context, unsigned int reg, void *_val, size_t bytes) { … } static void qfprom_runtime_disable(void *data) { … } static const struct qfprom_soc_data qfprom_7_8_data = …; static const struct qfprom_soc_data qfprom_7_15_data = …; static int qfprom_probe(struct platform_device *pdev) { … } static const struct of_device_id qfprom_of_match[] = …; MODULE_DEVICE_TABLE(of, qfprom_of_match); static struct platform_driver qfprom_driver = …; module_platform_driver(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;