2021-10-04 11:18:13

by Alexander Stein

[permalink] [raw]
Subject: [PATCH 1/2] dt-bindings: mtd: spi-nor: Add output-driver-strength property

From: Alexander Stein <[email protected]>

This property is for optimizing output voltage impedance and is
specific to each board.

Signed-off-by: Alexander Stein <[email protected]>
---
I checked Micron and Macronix datasheets. Both have similar but not
identical supported values. Also the register locations are different.
For those reasons I decided to specify the Ohms value directly and let
the device specfic driver figure out if it is supported where to write
it to.
BTW: Are the Ohm values and the corresponding register bits standardized
somewhere?

Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
index ed590d7c6e37..7d7f20a741b5 100644
--- a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
+++ b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
@@ -72,6 +72,12 @@ properties:
be used on such systems, to denote the absence of a reliable reset
mechanism.

+ output-driver-strength:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description:
+ Output driver strength in Ohms which optimizes the impedance at Vcc/2
+ output voltage.
+
label: true

partitions:
--
2.25.1


2021-10-04 11:18:31

by Alexander Stein

[permalink] [raw]
Subject: [PATCH 2/2] mtd: spi-nor: micron-st: Add support for output-driver-strength

From: Alexander Stein <[email protected]>

Micron flashes support this by the Bits [2:0] in the Enhanced Volatile
Configuration Register.
Checked datasheets:
- n25q_128mb_3v_65nm.pdf
- mt25t-qljs-L512-xBA-xxT.pdf

Signed-off-by: Alexander Stein <[email protected]>
---
drivers/mtd/spi-nor/micron-st.c | 109 ++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)

diff --git a/drivers/mtd/spi-nor/micron-st.c b/drivers/mtd/spi-nor/micron-st.c
index c224e59820a1..5d5e7fbc24a2 100644
--- a/drivers/mtd/spi-nor/micron-st.c
+++ b/drivers/mtd/spi-nor/micron-st.c
@@ -16,6 +16,11 @@
#define SPINOR_MT_OCT_DTR 0xe7 /* Enable Octal DTR. */
#define SPINOR_MT_EXSPI 0xff /* Enable Extended SPI (default) */

+struct micron_drive_strength {
+ u32 ohms;
+ u8 val;
+};
+
static int spi_nor_micron_octal_dtr_enable(struct spi_nor *nor, bool enable)
{
struct spi_mem_op op;
@@ -255,8 +260,112 @@ static void micron_st_default_init(struct spi_nor *nor)
nor->params->set_4byte_addr_mode = st_micron_set_4byte_addr_mode;
}

+
+/*
+ * Read Micron enhanced volatile configuration register
+ * Return negative if error occurred or configuration register value
+ */
+static int micron_read_evcr(struct spi_nor *nor)
+{
+ int ret;
+
+ if (nor->spimem) {
+ struct spi_mem_op op =
+ SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_EVCR, 1),
+ SPI_MEM_OP_NO_ADDR,
+ SPI_MEM_OP_NO_DUMMY,
+ SPI_MEM_OP_DATA_IN(1, nor->bouncebuf, 1));
+
+ ret = spi_mem_exec_op(nor->spimem, &op);
+ } else {
+ ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RD_EVCR, nor->bouncebuf, 1);
+ }
+
+ if (ret < 0) {
+ dev_err(nor->dev, "error %d reading EVCR\n", ret);
+ return ret;
+ }
+
+ return nor->bouncebuf[0];
+}
+
+/*
+ * Write Micron enhanced volatile configuration register
+ * Return negative if error occurred or configuration register value
+ */
+static int micron_write_evcr(struct spi_nor *nor, u8 evcr)
+{
+ nor->bouncebuf[0] = evcr;
+
+ spi_nor_write_enable(nor);
+
+ if (nor->spimem) {
+ struct spi_mem_op op =
+ SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WD_EVCR, 1),
+ SPI_MEM_OP_NO_ADDR,
+ SPI_MEM_OP_NO_DUMMY,
+ SPI_MEM_OP_DATA_OUT(1, nor->bouncebuf, 1));
+
+ return spi_mem_exec_op(nor->spimem, &op);
+ }
+
+ return nor->controller_ops->write_reg(nor, SPINOR_OP_WD_EVCR, nor->bouncebuf, 1);
+}
+
+/*
+ * Supported values from Enahanced Volatile COnfiguration Register (Bits 2:0)
+ */
+static const struct micron_drive_strength drive_strength_data[] = {
+ { .ohms = 90, .val = 1 },
+ { .ohms = 45, .val = 3 },
+ { .ohms = 20, .val = 5 },
+ { .ohms = 30, .val = 7 },
+};
+
+static struct micron_drive_strength const *micron_st_find_drive_strength_entry(u32 ohms)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(drive_strength_data); i++) {
+ if (ohms == drive_strength_data[i].ohms)
+ return &drive_strength_data[i];
+ }
+ return NULL;
+}
+
+static void micron_st_post_sfdp(struct spi_nor *nor)
+{
+ struct device_node *np = spi_nor_get_flash_node(nor);
+ u32 ohms;
+
+ if (!np)
+ return;
+
+ if (!of_property_read_u32(np, "output-driver-strength", &ohms)) {
+ struct micron_drive_strength const *entry =
+ micron_st_find_drive_strength_entry(ohms);
+
+ if (entry) {
+ int evcrr = micron_read_evcr(nor);
+
+ if (evcrr >= 0) {
+ u8 evcr = (u8)(evcrr & 0xf8) | entry->val;
+
+ micron_write_evcr(nor, evcr);
+ dev_dbg(nor->dev, "%s: EVCR 0x%x\n", __func__,
+ (u32)micron_read_evcr(nor));
+ }
+ } else {
+ dev_warn(nor->dev,
+ "Invalid output-driver-strength property specified: %u",
+ ohms);
+ }
+ }
+}
+
static const struct spi_nor_fixups micron_st_fixups = {
.default_init = micron_st_default_init,
+ .post_sfdp = micron_st_post_sfdp,
};

const struct spi_nor_manufacturer spi_nor_micron = {
--
2.25.1

2021-10-04 11:29:20

by Tudor Ambarus

[permalink] [raw]
Subject: Re: [PATCH 2/2] mtd: spi-nor: micron-st: Add support for output-driver-strength

On 10/4/21 2:15 PM, Alexander Stein wrote:
> [You don't often get email from [email protected]. Learn why this is important at http://aka.ms/LearnAboutSenderIdentification.]
>
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> From: Alexander Stein <[email protected]>
>
> Micron flashes support this by the Bits [2:0] in the Enhanced Volatile
> Configuration Register.
> Checked datasheets:
> - n25q_128mb_3v_65nm.pdf
> - mt25t-qljs-L512-xBA-xxT.pdf
>
> Signed-off-by: Alexander Stein <[email protected]>
> ---

Does the micron flash define the SCCR SFDP map?

2021-10-04 12:20:07

by Tudor Ambarus

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: mtd: spi-nor: Add output-driver-strength property

On 10/4/21 2:15 PM, Alexander Stein wrote:
> [You don't often get email from [email protected]. Learn why this is important at http://aka.ms/LearnAboutSenderIdentification.]
>
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> From: Alexander Stein <[email protected]>
>
> This property is for optimizing output voltage impedance and is
> specific to each board.
>
> Signed-off-by: Alexander Stein <[email protected]>
> ---
> I checked Micron and Macronix datasheets. Both have similar but not
> identical supported values. Also the register locations are different.
> For those reasons I decided to specify the Ohms value directly and let
> the device specfic driver figure out if it is supported where to write
> it to.
> BTW: Are the Ohm values and the corresponding register bits standardized
> somewhere?

Please check JEDEC Standard No. 216D.01, I see a SCCR Map which defines Output
Driver Strength values.

>
> Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
> index ed590d7c6e37..7d7f20a741b5 100644
> --- a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
> +++ b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
> @@ -72,6 +72,12 @@ properties:
> be used on such systems, to denote the absence of a reliable reset
> mechanism.
>
> + output-driver-strength:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description:
> + Output driver strength in Ohms which optimizes the impedance at Vcc/2
> + output voltage.
> +
> label: true
>
> partitions:
> --
> 2.25.1
>

2021-10-05 12:27:45

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: mtd: spi-nor: Add output-driver-strength property

On Mon, 04 Oct 2021 13:15:28 +0200, Alexander Stein wrote:
> From: Alexander Stein <[email protected]>
>
> This property is for optimizing output voltage impedance and is
> specific to each board.
>
> Signed-off-by: Alexander Stein <[email protected]>
> ---
> I checked Micron and Macronix datasheets. Both have similar but not
> identical supported values. Also the register locations are different.
> For those reasons I decided to specify the Ohms value directly and let
> the device specfic driver figure out if it is supported where to write
> it to.
> BTW: Are the Ohm values and the corresponding register bits standardized
> somewhere?
>
> Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 6 ++++++
> 1 file changed, 6 insertions(+)
>

Running 'make dtbs_check' with the schema in this patch gives the
following warnings. Consider if they are expected or the schema is
incorrect. These may not be new warnings.

Note that it is not yet a requirement to have 0 warnings for dtbs_check.
This will change in the future.

Full log is available here: https://patchwork.ozlabs.org/patch/1536062


firmware-flash@0: $nodename:0: 'firmware-flash@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/mmp3-dell-ariel.dt.yaml

Flash@0: $nodename:0: 'Flash@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/nuvoton-npcm750-evb.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-evb.dt.yaml

flash@0: 'at91bootstrap@0', 'bootloader@40000', 'bootloaderenv@140000', 'bootloaderenvred@100000', 'dtb@180000', 'kernel@200000' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/at91-sam9x60ek.dt.yaml
arch/arm/boot/dts/at91-sama5d27_som1_ek.dt.yaml
arch/arm/boot/dts/at91-sama5d2_icp.dt.yaml

flash@0: 'at91bootstrap@0', 'bootloader@40000', 'bootloaderenv@140000', 'bootloaderenvred@100000', 'dtb@180000', 'kernel@200000', 'misc@800000' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/at91-sama5d2_xplained.dt.yaml

flash@0: 'cdns,block-size', 'cdns,page-size', 'cdns,read-delay', 'cdns,tchsh-ns', 'cdns,tsd2d-ns', 'cdns,tshsl-ns', 'cdns,tslch-ns' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dt.yaml
arch/arm64/boot/dts/altera/socfpga_stratix10_socdk_nand.dt.yaml
arch/arm64/boot/dts/intel/socfpga_agilex_socdk.dt.yaml

flash@0: 'cdns,read-delay', 'cdns,tchsh-ns', 'cdns,tsd2d-ns', 'cdns,tshsl-ns', 'cdns,tslch-ns' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm64/boot/dts/ti/k3-am642-evm.dt.yaml
arch/arm64/boot/dts/ti/k3-am642-sk.dt.yaml
arch/arm64/boot/dts/ti/k3-am6528-iot2050-basic.dt.yaml
arch/arm64/boot/dts/ti/k3-am6548-iot2050-advanced.dt.yaml
arch/arm64/boot/dts/ti/k3-am654-base-board.dt.yaml
arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dt.yaml
arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dt.yaml
arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dt.yaml

flash@0: compatible: 'oneOf' conditional failed, one must be fixed:
arch/arm/boot/dts/ls1021a-tsn.dt.yaml

flash@0: 'm25p,default-addr-width' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/bcm953012hr.dt.yaml
arch/arm/boot/dts/bcm953012k.dt.yaml

flash@0: 'mode' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/kirkwood-cloudbox.dt.yaml
arch/arm/boot/dts/kirkwood-d2net.dt.yaml
arch/arm/boot/dts/kirkwood-is2.dt.yaml
arch/arm/boot/dts/kirkwood-mv88f6281gtw-ge.dt.yaml
arch/arm/boot/dts/kirkwood-nas2big.dt.yaml
arch/arm/boot/dts/kirkwood-net2big.dt.yaml
arch/arm/boot/dts/kirkwood-net5big.dt.yaml
arch/arm/boot/dts/kirkwood-ns2.dt.yaml
arch/arm/boot/dts/kirkwood-ns2lite.dt.yaml
arch/arm/boot/dts/kirkwood-ns2max.dt.yaml
arch/arm/boot/dts/kirkwood-ns2mini.dt.yaml
arch/arm/boot/dts/kirkwood-t5325.dt.yaml

flash@0: 'spi-cpha', 'spi-cpol' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm64/boot/dts/freescale/fsl-ls1028a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1028a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1028a-qds.dt.yaml
arch/arm/boot/dts/r8a7742-iwg21d-q7-dbcm-ca.dt.yaml
arch/arm/boot/dts/r8a7742-iwg21d-q7.dt.yaml
arch/arm/boot/dts/r8a7743-iwg20d-q7-dbcm-ca.dt.yaml
arch/arm/boot/dts/r8a7743-iwg20d-q7.dt.yaml
arch/arm/boot/dts/r8a7744-iwg20d-q7-dbcm-ca.dt.yaml
arch/arm/boot/dts/r8a7744-iwg20d-q7.dt.yaml
arch/arm/boot/dts/r8a7745-iwg22d-sodimm-dbhd-ca.dt.yaml
arch/arm/boot/dts/r8a7745-iwg22d-sodimm.dt.yaml
arch/arm/boot/dts/r8a77470-iwg23s-sbc.dt.yaml
arch/arm/boot/dts/r8a7790-lager.dt.yaml
arch/arm/boot/dts/r8a7790-stout.dt.yaml
arch/arm/boot/dts/r8a7791-koelsch.dt.yaml
arch/arm/boot/dts/r8a7792-wheat.dt.yaml
arch/arm/boot/dts/r8a7793-gose.dt.yaml
arch/arm/boot/dts/r8a7794-alt.dt.yaml
arch/arm/boot/dts/r8a7794-silk.dt.yaml

flash@0: 'ti,spi-wdelay' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/da850-lego-ev3.dt.yaml

flash@1: 'spi-cpha', 'spi-cpol' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm64/boot/dts/freescale/fsl-ls1012a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1028a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1028a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1046a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1088a-qds.dt.yaml

flash@2: compatible: 'oneOf' conditional failed, one must be fixed:
arch/arm64/boot/dts/freescale/fsl-ls1012a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1046a-qds.dt.yaml

flash@2: 'spi-cpha', 'spi-cpol' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm64/boot/dts/freescale/fsl-ls1012a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1028a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1028a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1046a-qds.dt.yaml
arch/arm64/boot/dts/freescale/fsl-ls1088a-qds.dt.yaml

flash: 'spi-cpha', 'spi-cpol' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/lpc4357-ea4357-devkit.dt.yaml
arch/arm/boot/dts/lpc4357-myd-lpc4357.dt.yaml

m25p128@0: $nodename:0: 'm25p128@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/kirkwood-rd88f6192.dt.yaml
arch/arm/boot/dts/kirkwood-ts219-6281.dt.yaml
arch/arm/boot/dts/kirkwood-ts219-6282.dt.yaml
arch/arm/boot/dts/kirkwood-ts419-6281.dt.yaml
arch/arm/boot/dts/kirkwood-ts419-6282.dt.yaml

m25p128@0: 'mode' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/kirkwood-rd88f6192.dt.yaml
arch/arm/boot/dts/kirkwood-ts219-6281.dt.yaml
arch/arm/boot/dts/kirkwood-ts219-6282.dt.yaml
arch/arm/boot/dts/kirkwood-ts419-6281.dt.yaml
arch/arm/boot/dts/kirkwood-ts419-6282.dt.yaml

m25p16@0: $nodename:0: 'm25p16@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/kirkwood-b3.dt.yaml

m25p16@0: 'mode' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/kirkwood-b3.dt.yaml

m25p32@1: $nodename:0: 'm25p32@1' does not match '^flash(@.*)?$'
arch/arm/boot/dts/imx50-evk.dt.yaml
arch/arm/boot/dts/imx53-smd.dt.yaml

m25p32@1: compatible: 'oneOf' conditional failed, one must be fixed:
arch/arm/boot/dts/imx53-smd.dt.yaml

m25p40@0: $nodename:0: 'm25p40@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/kirkwood-dreamplug.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lsqvl.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lsvl.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lswsxl.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lswvl.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lswxl.dt.yaml
arch/arm/boot/dts/kirkwood-lschlv2.dt.yaml
arch/arm/boot/dts/kirkwood-lsxhl.dt.yaml

m25p40@0: 'mode' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/kirkwood-dreamplug.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lsqvl.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lsvl.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lswsxl.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lswvl.dt.yaml
arch/arm/boot/dts/kirkwood-linkstation-lswxl.dt.yaml
arch/arm/boot/dts/kirkwood-lschlv2.dt.yaml
arch/arm/boot/dts/kirkwood-lsxhl.dt.yaml

m25p80@0: $nodename:0: 'm25p80@0' does not match '^flash(@.*)?$'
arch/arm64/boot/dts/marvell/armada-3720-db.dt.yaml
arch/arm64/boot/dts/marvell/armada-3720-uDPU.dt.yaml
arch/arm64/boot/dts/qcom/ipq8074-hk01.dt.yaml
arch/arm64/boot/dts/qcom/ipq8074-hk10-c1.dt.yaml
arch/arm64/boot/dts/qcom/ipq8074-hk10-c2.dt.yaml
arch/arm/boot/dts/am335x-phycore-rdk.dt.yaml
arch/arm/boot/dts/am335x-regor-rdk.dt.yaml
arch/arm/boot/dts/am335x-wega-rdk.dt.yaml
arch/arm/boot/dts/am571x-idk.dt.yaml
arch/arm/boot/dts/am572x-idk.dt.yaml
arch/arm/boot/dts/am574x-idk.dt.yaml
arch/arm/boot/dts/at91-vinco.dt.yaml
arch/arm/boot/dts/da850-evm.dt.yaml
arch/arm/boot/dts/imx28-evk.dt.yaml
arch/arm/boot/dts/imx28-m28evk.dt.yaml
arch/arm/boot/dts/imx6dl-aristainetos_4.dt.yaml
arch/arm/boot/dts/imx6dl-aristainetos_7.dt.yaml
arch/arm/boot/dts/imx6dl-dfi-fs700-m60.dt.yaml
arch/arm/boot/dts/imx6dl-nitrogen6x.dt.yaml
arch/arm/boot/dts/imx6dl-rex-basic.dt.yaml
arch/arm/boot/dts/imx6dl-sabreauto.dt.yaml
arch/arm/boot/dts/imx6dl-sabrelite.dt.yaml
arch/arm/boot/dts/imx6dl-sabresd.dt.yaml
arch/arm/boot/dts/imx6q-cm-fx6.dt.yaml
arch/arm/boot/dts/imx6q-dfi-fs700-m60.dt.yaml
arch/arm/boot/dts/imx6q-dmo-edmqmx6.dt.yaml
arch/arm/boot/dts/imx6q-gw5400-a.dt.yaml
arch/arm/boot/dts/imx6q-nitrogen6x.dt.yaml
arch/arm/boot/dts/imx6qp-sabreauto.dt.yaml
arch/arm/boot/dts/imx6qp-sabresd.dt.yaml
arch/arm/boot/dts/imx6q-rex-pro.dt.yaml
arch/arm/boot/dts/imx6q-sabreauto.dt.yaml
arch/arm/boot/dts/imx6q-sabrelite.dt.yaml
arch/arm/boot/dts/imx6q-sabresd.dt.yaml
arch/arm/boot/dts/imx6q-utilite-pro.dt.yaml
arch/arm/boot/dts/imx6sl-evk.dt.yaml
arch/arm/boot/dts/keystone-k2g-evm.dt.yaml
arch/arm/boot/dts/keystone-k2g-ice.dt.yaml
arch/arm/boot/dts/kirkwood-dir665.dt.yaml
arch/arm/boot/dts/kirkwood-ds109.dt.yaml
arch/arm/boot/dts/kirkwood-ds110jv10.dt.yaml
arch/arm/boot/dts/kirkwood-ds111.dt.yaml
arch/arm/boot/dts/kirkwood-ds112.dt.yaml
arch/arm/boot/dts/kirkwood-ds209.dt.yaml
arch/arm/boot/dts/kirkwood-ds210.dt.yaml
arch/arm/boot/dts/kirkwood-ds212.dt.yaml
arch/arm/boot/dts/kirkwood-ds212j.dt.yaml
arch/arm/boot/dts/kirkwood-ds409.dt.yaml
arch/arm/boot/dts/kirkwood-ds409slim.dt.yaml
arch/arm/boot/dts/kirkwood-ds411.dt.yaml
arch/arm/boot/dts/kirkwood-ds411j.dt.yaml
arch/arm/boot/dts/kirkwood-ds411slim.dt.yaml
arch/arm/boot/dts/kirkwood-rs212.dt.yaml
arch/arm/boot/dts/kirkwood-rs409.dt.yaml
arch/arm/boot/dts/kirkwood-rs411.dt.yaml

m25p80@0: 'cdns,read-delay', 'cdns,tchsh-ns', 'cdns,tsd2d-ns', 'cdns,tshsl-ns', 'cdns,tslch-ns' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/keystone-k2g-evm.dt.yaml
arch/arm/boot/dts/keystone-k2g-ice.dt.yaml

m25p80@0: compatible: 'oneOf' conditional failed, one must be fixed:
arch/arm/boot/dts/imx6q-cm-fx6.dt.yaml
arch/arm/boot/dts/imx6q-gw5400-a.dt.yaml
arch/arm/boot/dts/imx6q-utilite-pro.dt.yaml

m25p80@0: 'mode' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/kirkwood-ds109.dt.yaml
arch/arm/boot/dts/kirkwood-ds110jv10.dt.yaml
arch/arm/boot/dts/kirkwood-ds111.dt.yaml
arch/arm/boot/dts/kirkwood-ds112.dt.yaml
arch/arm/boot/dts/kirkwood-ds209.dt.yaml
arch/arm/boot/dts/kirkwood-ds210.dt.yaml
arch/arm/boot/dts/kirkwood-ds212.dt.yaml
arch/arm/boot/dts/kirkwood-ds212j.dt.yaml
arch/arm/boot/dts/kirkwood-ds409.dt.yaml
arch/arm/boot/dts/kirkwood-ds409slim.dt.yaml
arch/arm/boot/dts/kirkwood-ds411.dt.yaml
arch/arm/boot/dts/kirkwood-ds411j.dt.yaml
arch/arm/boot/dts/kirkwood-ds411slim.dt.yaml
arch/arm/boot/dts/kirkwood-rs212.dt.yaml
arch/arm/boot/dts/kirkwood-rs409.dt.yaml
arch/arm/boot/dts/kirkwood-rs411.dt.yaml

m25p80@1: $nodename:0: 'm25p80@1' does not match '^flash(@.*)?$'
arch/arm/boot/dts/imx6dl-aristainetos2_4.dt.yaml
arch/arm/boot/dts/imx6dl-aristainetos2_7.dt.yaml

mx66l51235l@0: $nodename:0: 'mx66l51235l@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/stm32mp157c-ev1.dt.yaml

mx66l51235l@1: $nodename:0: 'mx66l51235l@1' does not match '^flash(@.*)?$'
arch/arm/boot/dts/stm32mp157c-ev1.dt.yaml

n25q032@0: $nodename:0: 'n25q032@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/imx6q-b450v3.dt.yaml
arch/arm/boot/dts/imx6q-b650v3.dt.yaml
arch/arm/boot/dts/imx6q-b850v3.dt.yaml
arch/arm/boot/dts/imx6q-dms-ba16.dt.yaml

n25q256a@0: $nodename:0: 'n25q256a@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/imx6sx-sdb.dt.yaml
arch/arm/boot/dts/imx6sx-sdb-mqs.dt.yaml
arch/arm/boot/dts/imx6sx-sdb-sai.dt.yaml
arch/arm/boot/dts/imx6ul-14x14-evk.dt.yaml
arch/arm/boot/dts/imx6ull-14x14-evk.dt.yaml
arch/arm/boot/dts/imx6ulz-14x14-evk.dt.yaml

n25q256a@2: $nodename:0: 'n25q256a@2' does not match '^flash(@.*)?$'
arch/arm/boot/dts/imx6sx-sdb.dt.yaml
arch/arm/boot/dts/imx6sx-sdb-mqs.dt.yaml
arch/arm/boot/dts/imx6sx-sdb-sai.dt.yaml

s25fl016k@0: $nodename:0: 's25fl016k@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/qcom-ipq8064-rb3011.dt.yaml

s25fl128s@0: $nodename:0: 's25fl128s@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/imx6sx-sdb-reva.dt.yaml

s25fl128s@2: $nodename:0: 's25fl128s@2' does not match '^flash(@.*)?$'
arch/arm/boot/dts/imx6sx-sdb-reva.dt.yaml

s25fl256@0: $nodename:0: 's25fl256@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/am3874-iceboard.dt.yaml

s25fl256@0: 'bootenv@2', 'fs@5', 'fsbl@0', 'ipmi@4', 'kernel@3', 'ssbl@1' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/am3874-iceboard.dt.yaml

spi-flash@0: $nodename:0: 'spi-flash@0' does not match '^flash(@.*)?$'
arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dt.yaml
arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dt.yaml
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dt.yaml
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2-plus.dt.yaml
arch/arm64/boot/dts/amlogic/meson-g12b-s922x-khadas-vim3.dt.yaml
arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dt.yaml
arch/arm64/boot/dts/amlogic/meson-gxl-s905d-libretech-pc.dt.yaml
arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc-v2.dt.yaml
arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dt.yaml
arch/arm64/boot/dts/amlogic/meson-gxm-s912-libretech-pc.dt.yaml
arch/arm64/boot/dts/amlogic/meson-sm1-khadas-vim3l.dt.yaml
arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dt.yaml
arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dt.yaml
arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dt.yaml
arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dt.yaml
arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dt.yaml
arch/arm64/boot/dts/marvell/armada-7040-db.dt.yaml
arch/arm64/boot/dts/marvell/armada-7040-db.dt.yaml
arch/arm64/boot/dts/marvell/armada-8040-db.dt.yaml
arch/arm64/boot/dts/marvell/armada-8040-db.dt.yaml
arch/arm64/boot/dts/marvell/armada-8040-puzzle-m801.dt.yaml
arch/arm64/boot/dts/marvell/cn9130-crb-A.dt.yaml
arch/arm64/boot/dts/marvell/cn9130-crb-B.dt.yaml
arch/arm64/boot/dts/marvell/cn9130-db-B.dt.yaml
arch/arm64/boot/dts/marvell/cn9130-db.dt.yaml
arch/arm64/boot/dts/marvell/cn9131-db-B.dt.yaml
arch/arm64/boot/dts/marvell/cn9131-db-B.dt.yaml
arch/arm64/boot/dts/marvell/cn9131-db.dt.yaml
arch/arm64/boot/dts/marvell/cn9131-db.dt.yaml
arch/arm64/boot/dts/marvell/cn9132-db-B.dt.yaml
arch/arm64/boot/dts/marvell/cn9132-db-B.dt.yaml
arch/arm64/boot/dts/marvell/cn9132-db.dt.yaml
arch/arm64/boot/dts/marvell/cn9132-db.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-damu.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-fennel14.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-fennel-sku1.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-fennel-sku6.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-juniper-sku16.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-kappa.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-kenzo.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-willow-sku0.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-willow-sku1.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-kakadu.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku16.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku272.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku288.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku32.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku0.dt.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dt.yaml
arch/arm64/boot/dts/microchip/sparx5_pcb134.dt.yaml
arch/arm64/boot/dts/microchip/sparx5_pcb134_emmc.dt.yaml
arch/arm64/boot/dts/microchip/sparx5_pcb135.dt.yaml
arch/arm64/boot/dts/microchip/sparx5_pcb135_emmc.dt.yaml
arch/arm/boot/dts/armada-370-db.dt.yaml
arch/arm/boot/dts/armada-370-seagate-personal-cloud-2bay.dt.yaml
arch/arm/boot/dts/armada-370-seagate-personal-cloud.dt.yaml
arch/arm/boot/dts/armada-370-synology-ds213j.dt.yaml
arch/arm/boot/dts/armada-375-db.dt.yaml
arch/arm/boot/dts/armada-385-clearfog-gtr-l8.dt.yaml
arch/arm/boot/dts/armada-385-clearfog-gtr-s4.dt.yaml
arch/arm/boot/dts/armada-385-db-88f6820-amc.dt.yaml
arch/arm/boot/dts/armada-385-db-ap.dt.yaml
arch/arm/boot/dts/armada-385-synology-ds116.dt.yaml
arch/arm/boot/dts/armada-388-clearfog-base.dt.yaml
arch/arm/boot/dts/armada-388-clearfog.dt.yaml
arch/arm/boot/dts/armada-388-clearfog-pro.dt.yaml
arch/arm/boot/dts/armada-388-db.dt.yaml
arch/arm/boot/dts/armada-388-gp.dt.yaml
arch/arm/boot/dts/armada-388-helios4.dt.yaml
arch/arm/boot/dts/armada-388-rd.dt.yaml
arch/arm/boot/dts/armada-398-db.dt.yaml
arch/arm/boot/dts/armada-xp-axpwifiap.dt.yaml
arch/arm/boot/dts/armada-xp-crs305-1g-4s-bit.dt.yaml
arch/arm/boot/dts/armada-xp-crs305-1g-4s.dt.yaml
arch/arm/boot/dts/armada-xp-crs326-24g-2s-bit.dt.yaml
arch/arm/boot/dts/armada-xp-crs326-24g-2s.dt.yaml
arch/arm/boot/dts/armada-xp-crs328-4c-20s-4s-bit.dt.yaml
arch/arm/boot/dts/armada-xp-crs328-4c-20s-4s.dt.yaml
arch/arm/boot/dts/armada-xp-db.dt.yaml
arch/arm/boot/dts/armada-xp-gp.dt.yaml
arch/arm/boot/dts/armada-xp-synology-ds414.dt.yaml
arch/arm/boot/dts/at91-dvk_som60.dt.yaml
arch/arm/boot/dts/imx6ul-kontron-n6310-s-43.dt.yaml
arch/arm/boot/dts/imx6ul-kontron-n6310-s.dt.yaml
arch/arm/boot/dts/sun8i-v3-sl631-imx179.dt.yaml
arch/arm/boot/dts/tegra114-dalmore.dt.yaml
arch/arm/boot/dts/tegra124-jetson-tk1.dt.yaml
arch/arm/boot/dts/tegra124-venice2.dt.yaml
arch/arm/boot/dts/tegra20-trimslice.dt.yaml

spi_flash@0: $nodename:0: 'spi_flash@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/am57xx-cl-som-am57x.dt.yaml
arch/arm/boot/dts/am57xx-sbc-am57x.dt.yaml
arch/arm/boot/dts/at91-sama5d27_wlsom1_ek.dt.yaml

spiflash@0: $nodename:0: 'spiflash@0' does not match '^flash(@.*)?$'
arch/arm64/boot/dts/allwinner/sun50i-h5-libretech-all-h3-it.dt.yaml
arch/arm64/boot/dts/rockchip/rk3328-rock64.dt.yaml
arch/arm64/boot/dts/rockchip/rk3399-gru-bob.dt.yaml
arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dt.yaml
arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet-inx.dt.yaml
arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet-kd.dt.yaml

spi_flash@0: 'at91bootstrap@0', 'bootloader@40000', 'bootloaderenv@140000', 'bootloaderenvred@100000', 'dtb@180000', 'kernel@200000' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/at91-sama5d27_wlsom1_ek.dt.yaml

spi-flash@0: compatible: 'oneOf' conditional failed, one must be fixed:
arch/arm/boot/dts/armada-370-db.dt.yaml

spi-flash@1: $nodename:0: 'spi-flash@1' does not match '^flash(@.*)?$'
arch/arm/boot/dts/armada-385-atl-x530.dt.yaml
arch/arm/boot/dts/tegra30-beaver.dt.yaml
arch/arm/boot/dts/tegra30-cardhu-a02.dt.yaml
arch/arm/boot/dts/tegra30-cardhu-a04.dt.yaml

spi-flash@9: $nodename:0: 'spi-flash@9' does not match '^flash(@.*)?$'
arch/arm64/boot/dts/microchip/sparx5_pcb125.dt.yaml
arch/arm64/boot/dts/microchip/sparx5_pcb134.dt.yaml
arch/arm64/boot/dts/microchip/sparx5_pcb134_emmc.dt.yaml
arch/arm64/boot/dts/microchip/sparx5_pcb135.dt.yaml
arch/arm64/boot/dts/microchip/sparx5_pcb135_emmc.dt.yaml

spi-nor@0: $nodename:0: 'spi-nor@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/armada-385-turris-omnia.dt.yaml
arch/arm/boot/dts/nuvoton-npcm730-gbs.dt.yaml
arch/arm/boot/dts/nuvoton-npcm730-gbs.dt.yaml
arch/arm/boot/dts/nuvoton-npcm730-gsj.dt.yaml
arch/arm/boot/dts/nuvoton-npcm730-kudo.dt.yaml
arch/arm/boot/dts/nuvoton-npcm730-kudo.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-evb.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-evb.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-runbmc-olympus.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-runbmc-olympus.dt.yaml

spi-nor@0: 'partitions@80000000' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/nuvoton-npcm730-gbs.dt.yaml
arch/arm/boot/dts/nuvoton-npcm730-gsj.dt.yaml
arch/arm/boot/dts/nuvoton-npcm730-kudo.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-evb.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-runbmc-olympus.dt.yaml

spi-nor@0: 'partitions@A0000000' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/nuvoton-npcm730-kudo.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-evb.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-runbmc-olympus.dt.yaml

spi-nor@1: $nodename:0: 'spi-nor@1' does not match '^flash(@.*)?$'
arch/arm/boot/dts/nuvoton-npcm730-gbs.dt.yaml
arch/arm/boot/dts/nuvoton-npcm730-kudo.dt.yaml
arch/arm/boot/dts/nuvoton-npcm750-runbmc-olympus.dt.yaml

spi-nor@1: 'npcm,fiu-rx-bus-width', 'partitions@88000000' do not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/nuvoton-npcm750-runbmc-olympus.dt.yaml

spi-nor@1: 'partitions@88000000' does not match any of the regexes: '^otp(-[0-9]+)?$', '^partition@', 'pinctrl-[0-9]+'
arch/arm/boot/dts/nuvoton-npcm730-kudo.dt.yaml

w25q64cvzpig@0: $nodename:0: 'w25q64cvzpig@0' does not match '^flash(@.*)?$'
arch/arm/boot/dts/am437x-cm-t43.dt.yaml
arch/arm/boot/dts/am437x-sbc-t43.dt.yaml

2021-10-08 11:20:33

by Pratyush Yadav

[permalink] [raw]
Subject: Re: [PATCH 2/2] mtd: spi-nor: micron-st: Add support for output-driver-strength

Hi Alexander,

On 04/10/21 01:15PM, Alexander Stein wrote:
> From: Alexander Stein <[email protected]>
>
> Micron flashes support this by the Bits [2:0] in the Enhanced Volatile
> Configuration Register.
> Checked datasheets:
> - n25q_128mb_3v_65nm.pdf
> - mt25t-qljs-L512-xBA-xxT.pdf

What does changing the impedance do? Does it improve latency? If we use
suboptimal impedance, will the flash still keep working correctly?

In other words, you need to justify why this patch is needed.

>
> Signed-off-by: Alexander Stein <[email protected]>
> ---
> drivers/mtd/spi-nor/micron-st.c | 109 ++++++++++++++++++++++++++++++++
> 1 file changed, 109 insertions(+)
>
> diff --git a/drivers/mtd/spi-nor/micron-st.c b/drivers/mtd/spi-nor/micron-st.c
> index c224e59820a1..5d5e7fbc24a2 100644
> --- a/drivers/mtd/spi-nor/micron-st.c
> +++ b/drivers/mtd/spi-nor/micron-st.c
> @@ -16,6 +16,11 @@
> #define SPINOR_MT_OCT_DTR 0xe7 /* Enable Octal DTR. */
> #define SPINOR_MT_EXSPI 0xff /* Enable Extended SPI (default) */
>
> +struct micron_drive_strength {
> + u32 ohms;
> + u8 val;
> +};
> +
> static int spi_nor_micron_octal_dtr_enable(struct spi_nor *nor, bool enable)
> {
> struct spi_mem_op op;
> @@ -255,8 +260,112 @@ static void micron_st_default_init(struct spi_nor *nor)
> nor->params->set_4byte_addr_mode = st_micron_set_4byte_addr_mode;
> }
>
> +
> +/*
> + * Read Micron enhanced volatile configuration register
> + * Return negative if error occurred or configuration register value
> + */
> +static int micron_read_evcr(struct spi_nor *nor)
> +{
> + int ret;
> +
> + if (nor->spimem) {
> + struct spi_mem_op op =
> + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_EVCR, 1),
> + SPI_MEM_OP_NO_ADDR,
> + SPI_MEM_OP_NO_DUMMY,
> + SPI_MEM_OP_DATA_IN(1, nor->bouncebuf, 1));

Are you always guaranteed to be in 1S-1S-1S mode during register write?

I would suggest calling spi_nor_spimem_setup_op() before this so that it
sets up all the buswidths correctly based on nor->reg_proto.

> +
> + ret = spi_mem_exec_op(nor->spimem, &op);
> + } else {
> + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RD_EVCR, nor->bouncebuf, 1);

Split into 2 lines?

> + }
> +
> + if (ret < 0) {
> + dev_err(nor->dev, "error %d reading EVCR\n", ret);
> + return ret;
> + }
> +
> + return nor->bouncebuf[0];
> +}
> +
> +/*
> + * Write Micron enhanced volatile configuration register
> + * Return negative if error occurred or configuration register value
> + */
> +static int micron_write_evcr(struct spi_nor *nor, u8 evcr)
> +{
> + nor->bouncebuf[0] = evcr;
> +
> + spi_nor_write_enable(nor);

Check return code.

> +
> + if (nor->spimem) {
> + struct spi_mem_op op =
> + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WD_EVCR, 1),
> + SPI_MEM_OP_NO_ADDR,
> + SPI_MEM_OP_NO_DUMMY,
> + SPI_MEM_OP_DATA_OUT(1, nor->bouncebuf, 1));

Same as above.

> +
> + return spi_mem_exec_op(nor->spimem, &op);
> + }
> +
> + return nor->controller_ops->write_reg(nor, SPINOR_OP_WD_EVCR, nor->bouncebuf, 1);

Same as above. Split into 2 lines?

> +}
> +
> +/*
> + * Supported values from Enahanced Volatile COnfiguration Register (Bits 2:0)
> + */
> +static const struct micron_drive_strength drive_strength_data[] = {
> + { .ohms = 90, .val = 1 },
> + { .ohms = 45, .val = 3 },
> + { .ohms = 20, .val = 5 },
> + { .ohms = 30, .val = 7 },
> +};
> +
> +static struct micron_drive_strength const *micron_st_find_drive_strength_entry(u32 ohms)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(drive_strength_data); i++) {
> + if (ohms == drive_strength_data[i].ohms)
> + return &drive_strength_data[i];
> + }
> + return NULL;
> +}
> +
> +static void micron_st_post_sfdp(struct spi_nor *nor)
> +{
> + struct device_node *np = spi_nor_get_flash_node(nor);
> + u32 ohms;
> +
> + if (!np)
> + return;
> +
> + if (!of_property_read_u32(np, "output-driver-strength", &ohms)) {
> + struct micron_drive_strength const *entry =
> + micron_st_find_drive_strength_entry(ohms);
> +
> + if (entry) {
> + int evcrr = micron_read_evcr(nor);
> +
> + if (evcrr >= 0) {

This is a bit confusing. Can you instead do:

if (evcrr < 0)
return evcrr;

...

> + u8 evcr = (u8)(evcrr & 0xf8) | entry->val;

Don't use magic numbers. Define a bitmask, preferably using GENMASK().

> +
> + micron_write_evcr(nor, evcr);

Check return code. Do we need to abort flash probe if this fails, or can
we live with it, despite the suboptimal impedance?

> + dev_dbg(nor->dev, "%s: EVCR 0x%x\n", __func__,
> + (u32)micron_read_evcr(nor));
> + }
> + } else {
> + dev_warn(nor->dev,
> + "Invalid output-driver-strength property specified: %u",
> + ohms);
> + }
> + }
> +}
> +
> static const struct spi_nor_fixups micron_st_fixups = {
> .default_init = micron_st_default_init,
> + .post_sfdp = micron_st_post_sfdp,

NACK. Not every Micron flash has the EVCR register. For example, the
Micron MT35 flash family does not have an EVCR and the output drive
strength is programmed in a separate register. Set this only for the
flashes that need this.

> };
>
> const struct spi_nor_manufacturer spi_nor_micron = {
> --
> 2.25.1
>

--
Regards,
Pratyush Yadav
Texas Instruments Inc.

2021-10-12 12:57:00

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: mtd: spi-nor: Add output-driver-strength property

On Mon, Oct 04, 2021 at 01:15:28PM +0200, Alexander Stein wrote:
> From: Alexander Stein <[email protected]>
>
> This property is for optimizing output voltage impedance and is
> specific to each board.
>
> Signed-off-by: Alexander Stein <[email protected]>
> ---
> I checked Micron and Macronix datasheets. Both have similar but not
> identical supported values. Also the register locations are different.
> For those reasons I decided to specify the Ohms value directly and let
> the device specfic driver figure out if it is supported where to write
> it to.
> BTW: Are the Ohm values and the corresponding register bits standardized
> somewhere?
>
> Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
> index ed590d7c6e37..7d7f20a741b5 100644
> --- a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
> +++ b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
> @@ -72,6 +72,12 @@ properties:
> be used on such systems, to denote the absence of a reliable reset
> mechanism.
>
> + output-driver-strength:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description:
> + Output driver strength in Ohms which optimizes the impedance at Vcc/2
> + output voltage.

Use a standard unit suffix.

Though, specifying 'drive strength' in ohms rather than amps is a bit
strange.