nvmem: qfprom: Patches for fuse blowing on Qualcomm SoCs
Subsystems (5)
v5 cover nvmem: qfprom: Patches for fuse blowing on Qualcomm SoCs
This series enables blowing of fuses on Qualcomm SoCs by extending the existing qfprom driver with write support.
A few notes:
- Though I don't have any firsthand knowledge of it, it's my understanding that these changes could be used on any Qualcomm SoC. However, it's likely not very useful on most boards because the bootloader protects against this. Thus the write support here is likely only useful with a cooperating bootloader.
- Blowing fuses is truly a one-way process. If you mess around with this and do something wrong you could irreparably brick your chip. You have been warned.
Versions 1 and 2 of this series were posted by Ravi Kumar Bokka. I posted version 3 containing my changes / fixups with his consent. I have left authorship as Ravi but added my own Signed-off-by.
Version 4 is a minor spin over version 3.
Version 5 is an even more minor spin and just bumps up some timings to fix a failure reported by Ravi on one device. I've collected Rob Herring's reviews and (as far as I know) this is ready to land.
Changes in v5:
- QFPROM_FUSE_BLOW_POLL_US 10 => 100
- QFPROM_FUSE_BLOW_TIMEOUT_US 100 => 1000
Changes in v4:
- Maintainer now listed as Srinivas.
- Example under "soc" to get #address-cells and #size-cells.
- Clock name is "core", not "sec".
- Example under "soc" to get #address-cells and #size-cells.
- Only get clock/regulator if all address ranges are provided.
- Don't use optional version of clk_get now.
- Clock name is "core", not "sec".
- Cleaned up error message if couldn't get clock.
- Fixed up minor version mask.
- Use GENMASK to generate masks.
- Clock name is "core", not "sec".
Changes in v3:
- Split conversion to yaml into separate patch new in v3.
- Use 'const' for compatible instead of a 1-entry enum.
- Changed filename to match compatible string.
- Add #address-cells and #size-cells to list of properties.
- Fixed up example.
- Add an extra reg range (at 0x6000 offset for SoCs checked)
- Define two options for reg: 1 item or 4 items.
- No reg-names.
- Add "clocks" and "clock-names" to list of properties.
- Clock is now "sec", not "secclk".
- Add "vcc-supply" to list of properties.
- Fixed up example.
- Don't provide "reset" value for things; just save/restore.
- Use the major/minor version read from 0x6000.
- Reading should still read "corrected", not "raw".
- Added a sysfs knob to allow you to read "raw" instead of "corrected"
- Simplified the SoC data structure.
- No need for quite so many levels of abstraction for clocks/regulator.
- Don't set regulator voltage. Rely on device tree to make sure it's right.
- Properly undo things in the case of failure.
- Don't just keep enabling the regulator over and over again.
- Enable / disable the clock each time
- Polling every 100 us but timing out in 10 us didn't make sense; swap.
- No reason for 100 us to be SoC specific.
- No need for reg-names.
- We shouldn't be creating two separate nvmem devices.
- Name is now 'efuse' to match what schema checker wants.
- Reorganized ranges to match driver/bindings changes.
- Added 4th range as per driver/binding changes.
- No more reg-names as per driver/binding changes.
- Clock name is now just "sec" as per driver/binding changes.
Ravi Kumar Bokka (4):
dt-bindings: nvmem: qfprom: Convert to yaml
dt-bindings: nvmem: Add properties needed for blowing fuses
nvmem: qfprom: Add fuse blowing support
arm64: dts: qcom: sc7180: Add properties to qfprom for fuse blowing
.../bindings/nvmem/qcom,qfprom.yaml | 96 ++++++ .../devicetree/bindings/nvmem/qfprom.txt | 35 -- arch/arm64/boot/dts/qcom/sc7180-idp.dts | 4 + arch/arm64/boot/dts/qcom/sc7180.dtsi | 10 +- drivers/nvmem/qfprom.c | 314 +++++++++++++++++- 5 files changed, 411 insertions(+), 48 deletions(-) create mode 100644 Documentation/devicetree/bindings/nvmem/qcom,qfprom.yaml delete mode 100644 Documentation/devicetree/bindings/nvmem/qfprom.txt
Signature · 1 line
2.27.0.383.g050319c2ae-goog
PATCH v5 1/4 dt-bindings: nvmem: qfprom: Convert to yaml
From: Ravi Kumar Bokka <[email protected]>
This switches the bindings over from txt to yaml.
---
Changes in v5: None
Changes in v4:
- Maintainer now listed as Srinivas.
- Example under "soc" to get #address-cells and #size-cells.
Changes in v3:
- Split conversion to yaml into separate patch new in v3.
- Use 'const' for compatible instead of a 1-entry enum.
- Changed filename to match compatible string.
- Add #address-cells and #size-cells to list of properties.
- Fixed up example.
.../bindings/nvmem/qcom,qfprom.yaml | 50 +++++++++++++++++++ .../devicetree/bindings/nvmem/qfprom.txt | 35 ------------- 2 files changed, 50 insertions(+), 35 deletions(-) create mode 100644 Documentation/devicetree/bindings/nvmem/qcom,qfprom.yaml delete mode 100644 Documentation/devicetree/bindings/nvmem/qfprom.txt
Documentation/devicetree/bindings/nvmem/qcom,qfprom.yaml new file +50 -0
@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/qcom,qfprom.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Technologies Inc, QFPROM Efuse bindings + +maintainers: + - Srinivas Kandagatla <[email protected]> + +allOf: + - $ref: "nvmem.yaml#" + +properties: + compatible: + const: qcom,qfprom + + reg: + items: + - description: The corrected region. + + # Needed if any child nodes are present. + "#address-cells": + const: 1 + "#size-cells": + const: 1 + +required: + - compatible + - reg + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + efuse@784000 { + compatible = "qcom,qfprom"; + reg = <0 0x00784000 0 0x8ff>; + #address-cells = <1>; + #size-cells = <1>; + + hstx-trim-primary@1eb { + reg = <0x1eb 0x1>; + bits = <1 4>; + }; + }; + };
Documentation/devicetree/bindings/nvmem/qfprom.txt deleted +0 -35
@@ -1,35 +0,0 @@ -= Qualcomm QFPROM device tree bindings = - -This binding is intended to represent QFPROM which is found in most QCOM SOCs. - -Required properties: -- compatible: should be "qcom,qfprom" -- reg: Should contain registers location and length - -= Data cells = -Are child nodes of qfprom, bindings of which as described in -bindings/nvmem/nvmem.txt - -Example: - - qfprom: qfprom@700000 { - compatible = "qcom,qfprom"; - reg = <0x00700000 0x8000>; - ... - /* Data cells */ - tsens_calibration: calib@404 { - reg = <0x4404 0x10>; - }; - }; - - -= Data consumers = -Are device nodes which consume nvmem data cells. - -For example: - - tsens { - ... - nvmem-cells = <&tsens_calibration>; - nvmem-cell-names = "calibration"; - };
Signature · 1 line
2.27.0.383.g050319c2ae-goog
PATCH v5 2/4 dt-bindings: nvmem: Add properties needed for blowing fuses
In reply to Douglas AndersonFrom: Ravi Kumar Bokka <[email protected]>
On some systems it's possible to actually blow the fuses in the qfprom from the kernel. Add properties to support that.
NOTE: Whether this is possible depends on the BIOS settings and whether the kernel has permissions here, so not all boards will be able to blow fuses in the kernel.
---
Changes in v5: None
Changes in v4:
- Clock name is "core", not "sec".
- Example under "soc" to get #address-cells and #size-cells.
Changes in v3:
- Add an extra reg range (at 0x6000 offset for SoCs checked)
- Define two options for reg: 1 item or 4 items.
- No reg-names.
- Add "clocks" and "clock-names" to list of properties.
- Clock is now "sec", not "secclk".
- Add "vcc-supply" to list of properties.
- Fixed up example.
.../bindings/nvmem/qcom,qfprom.yaml | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/nvmem/qcom,qfprom.yaml +48 -2
@@ -17,8 +17,27 @@ properties: const: qcom,qfprom reg: - items: - - description: The corrected region. + # If the QFPROM is read-only OS image then only the corrected region + # needs to be provided. If the QFPROM is writable then all 4 regions + # must be provided. + oneOf: + - items: + - description: The corrected region. + - items: + - description: The corrected region. + - description: The raw region. + - description: The config region. + - description: The security control region. + + # Clock must be provided if QFPROM is writable from the OS image. + clocks: + maxItems: 1 + clock-names: + const: core + + # Supply reference must be provided if QFPROM is writable from the OS image. + vcc-supply: + description: Our power supply. # Needed if any child nodes are present. "#address-cells":
@@ -31,6 +50,33 @@ required: - reg examples: + - | + #include <dt-bindings/clock/qcom,gcc-sc7180.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + efuse@784000 { + compatible = "qcom,qfprom"; + reg = <0 0x00784000 0 0x8ff>, + <0 0x00780000 0 0x7a0>, + <0 0x00782000 0 0x100>, + <0 0x00786000 0 0x1fff>; + clocks = <&gcc GCC_SEC_CTRL_CLK_SRC>; + clock-names = "core"; + #address-cells = <1>; + #size-cells = <1>; + + vcc-supply = <&vreg_l11a_1p8>; + + hstx-trim-primary@25b { + reg = <0x25b 0x1>; + bits = <1 3>; + }; + }; + }; + - | soc { #address-cells = <2>;
Signature · 1 line
2.27.0.383.g050319c2ae-goog
PATCH v5 3/4 nvmem: qfprom: Add fuse blowing support
In reply to Douglas AndersonFrom: Ravi Kumar Bokka <[email protected]>
This patch adds support for blowing fuses to the qfprom driver if the required properties are defined in the device tree.
---
Changes in v5:
- QFPROM_FUSE_BLOW_POLL_US 10 => 100
- QFPROM_FUSE_BLOW_TIMEOUT_US 100 => 1000
Changes in v4:
- Only get clock/regulator if all address ranges are provided.
- Don't use optional version of clk_get now.
- Clock name is "core", not "sec".
- Cleaned up error message if couldn't get clock.
- Fixed up minor version mask.
- Use GENMASK to generate masks.
Changes in v3:
- Don't provide "reset" value for things; just save/restore.
- Use the major/minor version read from 0x6000.
- Reading should still read "corrected", not "raw".
- Added a sysfs knob to allow you to read "raw" instead of "corrected"
- Simplified the SoC data structure.
- No need for quite so many levels of abstraction for clocks/regulator.
- Don't set regulator voltage. Rely on device tree to make sure it's right.
- Properly undo things in the case of failure.
- Don't just keep enabling the regulator over and over again.
- Enable / disable the clock each time
- Polling every 100 us but timing out in 10 us didn't make sense; swap.
- No reason for 100 us to be SoC specific.
- No need for reg-names.
- We shouldn't be creating two separate nvmem devices.
drivers/nvmem/qfprom.c | 314 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 303 insertions(+), 11 deletions(-)
drivers/nvmem/qfprom.c +303 -11
@@ -3,57 +3,349 @@* 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/io.h> #include <linux/nvmem-provider.h> #include <linux/platform_device.h> +#include <linux/regulator/consumer.h> + +/* Blow timer clock frequency in Mhz */ +#define QFPROM_BLOW_TIMER_OFFSET 0x03c + +/* Amount of time required to hold charge to blow fuse in micro-seconds */ +#define QFPROM_FUSE_BLOW_POLL_US 100 +#define QFPROM_FUSE_BLOW_TIMEOUT_US 1000 + +#define QFPROM_BLOW_STATUS_OFFSET 0x048 +#define QFPROM_BLOW_STATUS_BUSY 0x1 +#define QFPROM_BLOW_STATUS_READY 0x0 + +#define QFPROM_ACCEL_OFFSET 0x044 + +#define QFPROM_VERSION_OFFSET 0x0 +#define QFPROM_MAJOR_VERSION_SHIFT 28 +#define QFPROM_MAJOR_VERSION_MASK GENMASK(31, QFPROM_MAJOR_VERSION_SHIFT) +#define QFPROM_MINOR_VERSION_SHIFT 16 +#define QFPROM_MINOR_VERSION_MASK GENMASK(27, QFPROM_MINOR_VERSION_SHIFT) + +static bool read_raw_data; +module_param (read_raw_data, bool,0644 ); +MODULE_PARM_DESC (read_raw_data,"Read raw instead of corrected data" ); +/** +* 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. +*/ +struct qfprom_soc_data { +u32 accel_value; +u32 qfprom_blow_timer_value; +u32 qfprom_blow_set_freq; +}; + +/** +* 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 { -void __iomem *base; +void __iomem *qfpraw; +void __iomem *qfpconf; +void __iomem *qfpcorrected; +void __iomem *qfpsecurity; +struct device *dev; +struct clk *secclk; +struct regulator *vcc; +const struct qfprom_soc_data *soc_data; +}; + +/** +* 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 { +unsigned long clk_rate; +u32 accel_val; +u32 timer_val; }; +/** +* 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) +{ +int ret; + + ret =regulator_disable (priv->vcc); +if (ret) +dev_warn (priv->dev,"Failed to disable regulator (ignoring)\n" ); + + ret =clk_set_rate (priv->secclk, old->clk_rate); +if (ret) +dev_warn (priv->dev, +"Failed to set clock rate for disable (ignoring)\n" ); + +clk_disable_unprepare (priv->secclk); + +writel (old->timer_val, priv->qfpconf +QFPROM_BLOW_TIMER_OFFSET ); +writel (old->accel_val, priv->qfpconf +QFPROM_ACCEL_OFFSET ); +} + +/** +* 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) +{ +int ret; + + ret =clk_prepare_enable (priv->secclk); +if (ret) { +dev_err (priv->dev,"Failed to enable clock\n" ); +return ret; + } + + old->clk_rate =clk_get_rate (priv->secclk); + ret =clk_set_rate (priv->secclk, priv->soc_data->qfprom_blow_set_freq); +if (ret) { +dev_err (priv->dev,"Failed to set clock rate for enable\n" ); + goto err_clk_prepared; + } + + ret =regulator_enable (priv->vcc); +if (ret) { +dev_err (priv->dev,"Failed to enable regulator\n" ); + goto err_clk_rate_set; + } + + old->timer_val =readl (priv->qfpconf +QFPROM_BLOW_TIMER_OFFSET ); + old->accel_val =readl (priv->qfpconf +QFPROM_ACCEL_OFFSET ); +writel (priv->soc_data->qfprom_blow_timer_value, + priv->qfpconf +QFPROM_BLOW_TIMER_OFFSET ); +writel (priv->soc_data->accel_value, + priv->qfpconf +QFPROM_ACCEL_OFFSET ); + +return 0 ; + +err_clk_rate_set: +clk_set_rate (priv->secclk, old->clk_rate); +err_clk_prepared: +clk_disable_unprepare (priv->secclk); +return ret; +} + +/** +* qfprom_efuse_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) +{ +struct qfprom_priv *priv = context; +struct qfprom_touched_values old; +int words = bytes /4 ; +u32 *value = _val; +u32 blow_status; +int ret; +int i; + +dev_dbg (priv->dev, +"Writing to raw qfprom region : %#010x of size: %zu\n" , + reg, bytes); + +/* +* The hardware only allows us to write word at a time, but we can +* read byte at a time. Until the nvmem framework allows a separate +* word_size and stride for reading vs. writing, we'll enforce here. +*/ +if (bytes %4 ) { +dev_err (priv->dev, +"%zu is not an integral number of words\n" , bytes); +return -EINVAL ; + } +if (reg %4 ) { +dev_err (priv->dev, +"Invalid offset: %#x. Must be word aligned\n" , reg); +return -EINVAL ; + } + + ret =qfprom_enable_fuse_blowing (priv, &old); +if (ret) +return ret; + + ret =readl_relaxed_poll_timeout ( + priv->qfpconf +QFPROM_BLOW_STATUS_OFFSET , + blow_status, blow_status ==QFPROM_BLOW_STATUS_READY , +QFPROM_FUSE_BLOW_POLL_US ,QFPROM_FUSE_BLOW_TIMEOUT_US ); + +if (ret) { +dev_err (priv->dev, +"Timeout waiting for initial ready; aborting.\n" ); + goto exit_enabled_fuse_blowing; + } + +for (i =0 ; i < words; i++) +writel (value[i], priv->qfpraw + reg + (i *4 )); + + ret =readl_relaxed_poll_timeout ( + priv->qfpconf +QFPROM_BLOW_STATUS_OFFSET , + blow_status, blow_status ==QFPROM_BLOW_STATUS_READY , +QFPROM_FUSE_BLOW_POLL_US ,QFPROM_FUSE_BLOW_TIMEOUT_US ); + +/* Give an error, but not much we can do in this case */ +if (ret) +dev_err (priv->dev,"Timeout waiting for finish.\n" ); + +exit_enabled_fuse_blowing: +qfprom_disable_fuse_blowing (priv, &old); + +return ret; +} +static int qfprom_reg_read (void *context,unsigned int reg,void *_val,size_t bytes) {struct qfprom_priv *priv = context;u8 *val = _val;int i =0 , words = bytes; +void __iomem *base = priv->qfpcorrected; + +if (read_raw_data && priv->qfpraw) + base = priv->qfpraw;while (words--) - *val++ =readb (priv->base + reg + i++); + *val++ =readb (base + reg + i++);return 0 ; } -static struct nvmem_config econfig = { - .name ="qfprom" , - .stride =1 , - .word_size =1 , - .reg_read = qfprom_reg_read, +static const struct qfprom_soc_data qfprom_7_8_data = { + .accel_value =0xD10 , + .qfprom_blow_timer_value =25 , + .qfprom_blow_set_freq =4800000 , };static int qfprom_probe (struct platform_device *pdev) { +struct nvmem_config econfig = { + .name ="qfprom" , + .stride =1 , + .word_size =1 , + .reg_read = qfprom_reg_read, + };struct device *dev = &pdev->dev;struct resource *res;struct nvmem_device *nvmem;struct qfprom_priv *priv; +int ret; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );if (!priv)return -ENOMEM ; +/* The corrected section is always provided */ res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - priv->base =devm_ioremap_resource (dev, res); -if (IS_ERR (priv->base)) -return PTR_ERR (priv->base); + priv->qfpcorrected =devm_ioremap_resource (dev, res); +if (IS_ERR (priv->qfpcorrected)) +return PTR_ERR (priv->qfpcorrected); econfig.size =resource_size (res); econfig.dev = dev; econfig.priv = priv; + priv->dev = dev; + +/* +* If more than one region is provided then the OS has the ability +* to write. +*/ + res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); +if (res) { +u32 version; +int major_version, minor_version; + + priv->qfpraw =devm_ioremap_resource (dev, res); +if (IS_ERR (priv->qfpraw)) +return PTR_ERR (priv->qfpraw); + res =platform_get_resource (pdev,IORESOURCE_MEM ,2 ); + priv->qfpconf =devm_ioremap_resource (dev, res); +if (IS_ERR (priv->qfpconf)) +return PTR_ERR (priv->qfpconf); + res =platform_get_resource (pdev,IORESOURCE_MEM ,3 ); + priv->qfpsecurity =devm_ioremap_resource (dev, res); +if (IS_ERR (priv->qfpsecurity)) +return PTR_ERR (priv->qfpsecurity); + + version =readl (priv->qfpsecurity +QFPROM_VERSION_OFFSET ); + major_version = (version &QFPROM_MAJOR_VERSION_MASK ) >> +QFPROM_MAJOR_VERSION_SHIFT ; + minor_version = (version &QFPROM_MINOR_VERSION_MASK ) >> +QFPROM_MINOR_VERSION_SHIFT ; + +if (major_version ==7 && minor_version ==8 ) + priv->soc_data = &qfprom_7_8_data; + + priv->vcc =devm_regulator_get (&pdev->dev,"vcc" ); +if (IS_ERR (priv->vcc)) +return PTR_ERR (priv->vcc); + + priv->secclk =devm_clk_get (dev,"core" ); +if (IS_ERR (priv->secclk)) { + ret =PTR_ERR (priv->secclk); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Error getting clock: %d\n" , ret); +return ret; + } + +/* Only enable writing if we have SoC data. */ +if (priv->soc_data) + econfig.reg_write = qfprom_reg_write; + } + nvmem =devm_nvmem_register (dev, &econfig);return PTR_ERR_OR_ZERO (nvmem);
Signature · 1 line
2.27.0.383.g050319c2ae-goog
PATCH v5 4/4 arm64: dts: qcom: sc7180: Add properties to qfprom for fuse blowing
In reply to Douglas AndersonFrom: Ravi Kumar Bokka <[email protected]>
This patch adds properties to the qfprom node to enable fuse blowing.
---
Presumably this patch to the device tree file should go through the Qualcomm tree. Now that bindings have been reviewed by Rob it could probably land any time.
Changes in v5: None
Changes in v4:
- Clock name is "core", not "sec".
Changes in v3:
- Name is now 'efuse' to match what schema checker wants.
- Reorganized ranges to match driver/bindings changes.
- Added 4th range as per driver/binding changes.
- No more reg-names as per driver/binding changes.
- Clock name is now just "sec" as per driver/binding changes.
arch/arm64/boot/dts/qcom/sc7180-idp.dts | 4 ++++ arch/arm64/boot/dts/qcom/sc7180.dtsi | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sc7180-idp.dts +4 -0
@@ -287,6 +287,10 @@ vreg_bob: bob { }; }; +&qfprom { + vcc-supply = <&vreg_l11a_1p8>; +}; + &qspi { status = "okay"; pinctrl-names = "default";
arch/arm64/boot/dts/qcom/sc7180.dtsi +8 -2
@@ -498,9 +498,15 @@ gcc: clock-controller@100000 { #power-domain-cells = <1>; }; - qfprom@784000 { + qfprom: efuse@784000 { compatible = "qcom,qfprom"; - reg = <0 0x00784000 0 0x8ff>; + reg = <0 0x00784000 0 0x8ff>, + <0 0x00780000 0 0x7a0>, + <0 0x00782000 0 0x100>, + <0 0x00786000 0 0x1fff>; + + clocks = <&gcc GCC_SEC_CTRL_CLK_SRC>; + clock-names = "core"; #address-cells = <1>; #size-cells = <1>;
Signature · 1 line
2.27.0.383.g050319c2ae-goog
Srinivas,
Quoted 80 lines · Douglas Anderson
This series enables blowing of fuses on Qualcomm SoCs by extending the existing qfprom driver with write support.
A few notes:
- Though I don't have any firsthand knowledge of it, it's my understanding that these changes could be used on any Qualcomm SoC. However, it's likely not very useful on most boards because the bootloader protects against this. Thus the write support here is likely only useful with a cooperating bootloader.
- Blowing fuses is truly a one-way process. If you mess around with this and do something wrong you could irreparably brick your chip. You have been warned.Versions 1 and 2 of this series were posted by Ravi Kumar Bokka. I posted version 3 containing my changes / fixups with his consent. I have left authorship as Ravi but added my own Signed-off-by.
Version 4 is a minor spin over version 3.
Version 5 is an even more minor spin and just bumps up some timings to fix a failure reported by Ravi on one device. I've collected Rob Herring's reviews and (as far as I know) this is ready to land.
Changes in v5:
-QFPROM_FUSE_BLOW_POLL_US10 => 100
-QFPROM_FUSE_BLOW_TIMEOUT_US100 => 1000Changes in v4:
- Maintainer now listed as Srinivas.
- Example under "soc" to get #address-cells and #size-cells.
- Clock name is "core", not "sec".
- Example under "soc" to get #address-cells and #size-cells.
- Only get clock/regulator if all address ranges are provided.
- Don't use optional version ofclk_getnow.
- Clock name is "core", not "sec".
- Cleaned up error message if couldn't get clock.
- Fixed up minor version mask.
- Use GENMASK to generate masks.
- Clock name is "core", not "sec".Changes in v3:
- Split conversion to yaml into separate patch new in v3.
- Use 'const' for compatible instead of a 1-entry enum.
- Changed filename to match compatible string.
- Add #address-cells and #size-cells to list of properties.
- Fixed up example.
- Add an extra reg range (at0x6000offset for SoCs checked)
- Define two options for reg: 1 item or 4 items.
- No reg-names.
- Add "clocks" and "clock-names" to list of properties.
- Clock is now "sec", not "secclk".
- Add "vcc-supply" to list of properties.
- Fixed up example.
- Don't provide "reset" value for things; just save/restore.
- Use the major/minor version read from0x6000.
- Reading should still read "corrected", not "raw".
- Added a sysfs knob to allow you to read "raw" instead of "corrected"
- Simplified the SoC data structure.
- No need for quite so many levels of abstraction for clocks/regulator.
- Don't set regulator voltage. Rely on device tree to make sure it's right.
- Properly undo things in the case of failure.
- Don't just keep enabling the regulator over and over again.
- Enable / disable the clock each time
- Polling every 100 us but timing out in 10 us didn't make sense; swap.
- No reason for 100 us to be SoC specific.
- No need for reg-names.
- We shouldn't be creating two separate nvmem devices.
- Name is now 'efuse' to match what schema checker wants.
- Reorganized ranges to match driver/bindings changes.
- Added 4th range as per driver/binding changes.
- No more reg-names as per driver/binding changes.
- Clock name is now just "sec" as per driver/binding changes.Ravi Kumar Bokka (4):
dt-bindings: nvmem: qfprom: Convert to yaml
dt-bindings: nvmem: Add properties needed for blowing fuses
nvmem: qfprom: Add fuse blowing support
arm64: dts: qcom: sc7180: Add properties to qfprom for fuse blowing
Quoted 6 lines
.../bindings/nvmem/qcom,qfprom.yaml | 96 ++++++ .../devicetree/bindings/nvmem/qfprom.txt | 35 -- arch/arm64/boot/dts/qcom/sc7180-idp.dts | 4 + arch/arm64/boot/dts/qcom/sc7180.dtsi | 10 +- drivers/nvmem/qfprom.c | 314 +++++++++++++++++- 5 files changed, 411 insertions(+), 48 deletions(-)
I know it's a little early to ping and that folks are busy, but I'm getting to a bit of a time crunch to land this driver in the Chrome OS kernel tree. I'd prefer for it to land upstream first so I can pick exactly what landed but if not then I'll just pick what I posted to the mailing list.
Any chance you can give an approximate timeline for when it might land so I can either wait a little while longer or stop waiting and just take what I posted to the lists?
Thanks! :-)
-Doug
Quoted 73 lines · Douglas Anderson
This series enables blowing of fuses on Qualcomm SoCs by extending the existing qfprom driver with write support.
A few notes:
- Though I don't have any firsthand knowledge of it, it's my understanding that these changes could be used on any Qualcomm SoC. However, it's likely not very useful on most boards because the bootloader protects against this. Thus the write support here is likely only useful with a cooperating bootloader.
- Blowing fuses is truly a one-way process. If you mess around with this and do something wrong you could irreparably brick your chip. You have been warned.Versions 1 and 2 of this series were posted by Ravi Kumar Bokka. I posted version 3 containing my changes / fixups with his consent. I have left authorship as Ravi but added my own Signed-off-by.
Version 4 is a minor spin over version 3.
Version 5 is an even more minor spin and just bumps up some timings to fix a failure reported by Ravi on one device. I've collected Rob Herring's reviews and (as far as I know) this is ready to land.
Changes in v5:
-QFPROM_FUSE_BLOW_POLL_US10 => 100
-QFPROM_FUSE_BLOW_TIMEOUT_US100 => 1000Changes in v4:
- Maintainer now listed as Srinivas.
- Example under "soc" to get #address-cells and #size-cells.
- Clock name is "core", not "sec".
- Example under "soc" to get #address-cells and #size-cells.
- Only get clock/regulator if all address ranges are provided.
- Don't use optional version ofclk_getnow.
- Clock name is "core", not "sec".
- Cleaned up error message if couldn't get clock.
- Fixed up minor version mask.
- Use GENMASK to generate masks.
- Clock name is "core", not "sec".Changes in v3:
- Split conversion to yaml into separate patch new in v3.
- Use 'const' for compatible instead of a 1-entry enum.
- Changed filename to match compatible string.
- Add #address-cells and #size-cells to list of properties.
- Fixed up example.
- Add an extra reg range (at0x6000offset for SoCs checked)
- Define two options for reg: 1 item or 4 items.
- No reg-names.
- Add "clocks" and "clock-names" to list of properties.
- Clock is now "sec", not "secclk".
- Add "vcc-supply" to list of properties.
- Fixed up example.
- Don't provide "reset" value for things; just save/restore.
- Use the major/minor version read from0x6000.
- Reading should still read "corrected", not "raw".
- Added a sysfs knob to allow you to read "raw" instead of "corrected"
- Simplified the SoC data structure.
- No need for quite so many levels of abstraction for clocks/regulator.
- Don't set regulator voltage. Rely on device tree to make sure it's right.
- Properly undo things in the case of failure.
- Don't just keep enabling the regulator over and over again.
- Enable / disable the clock each time
- Polling every 100 us but timing out in 10 us didn't make sense; swap.
- No reason for 100 us to be SoC specific.
- No need for reg-names.
- We shouldn't be creating two separate nvmem devices.
- Name is now 'efuse' to match what schema checker wants.
- Reorganized ranges to match driver/bindings changes.
- Added 4th range as per driver/binding changes.
- No more reg-names as per driver/binding changes.
- Clock name is now just "sec" as per driver/binding changes.
Quoted 4 lines
Ravi Kumar Bokka (4):
dt-bindings: nvmem: qfprom: Convert to yaml
dt-bindings: nvmem: Add properties needed for blowing fuses
nvmem: qfprom: Add fuse blowing support
Applied above 3 with merge conflict fixed.
dts patches should go via arm-soc tree, Bjorn could pick that up!
Thanks,
srini
Quoted 11 lines
arm64: dts: qcom: sc7180: Add properties to qfprom for fuse blowing
.../bindings/nvmem/qcom,qfprom.yaml | 96 ++++++ .../devicetree/bindings/nvmem/qfprom.txt | 35 -- arch/arm64/boot/dts/qcom/sc7180-idp.dts | 4 + arch/arm64/boot/dts/qcom/sc7180.dtsi | 10 +- drivers/nvmem/qfprom.c | 314 +++++++++++++++++- 5 files changed, 411 insertions(+), 48 deletions(-)create mode 100644
Documentation/devicetree/bindings/nvmem/qcom,qfprom.yamldelete mode 100644Documentation/devicetree/bindings/nvmem/qfprom.txt