nvmem: patches (set 1) for 7.1
Subsystems (5)
[email protected]
maintainercover nvmem: patches (set 1) for 7.1
From: Srinivas Kandagatla <[email protected]>
Hi Greg,
Here are few nvmem patches for 7.1, Could you please queue these for 7.1.
Patches include
- new RK3568, RK3562 and Kaanapali providers
- some code cleanup.
Thanks,
Srini
Felix Gu (1):
nvmem: qnap-mcu-eeprom: Fix struct assignments using commas instead of
semicolons
Finley Xiao (2):
nvmem: rockchip-otp: Add support for RK3568
nvmem: rockchip-otp: Add support for RK3562
Jingyi Wang (1):
dt-bindings: nvmem: qfprom: Add Kaanapali compatible
Jonas Karlman (3):
dt-bindings: nvmem: rockchip,otp: Add compatible for RK3528
nvmem: rockchip-otp: Handle internal word_size in main reg_read op
nvmem: rockchip-otp: Add support for RK3528
Kever Yang (1):
dt-bindings: nvmem: rockchip,otp: Add support for RK3562 and RK3568
Michael Walle (1):
dt-bindings: nvmem: sl28cpld: Drop sa67mcu compatible
.../nvmem/layouts/kontron,sl28-vpd.yaml | 7 +- .../bindings/nvmem/qcom,qfprom.yaml | 1 + .../bindings/nvmem/rockchip,otp.yaml | 83 +++++++-- drivers/nvmem/qnap-mcu-eeprom.c | 8 +- drivers/nvmem/rockchip-otp.c | 161 ++++++++++++++---- 5 files changed, 208 insertions(+), 52 deletions(-)
Signature · 1 line
2.47.3
[email protected]
maintainerPATCH 1/9 dt-bindings: nvmem: qfprom: Add Kaanapali compatible
From: Jingyi Wang <[email protected]>
Document compatible string for the QFPROM on Kaanapali platform.
--- Documentation/devicetree/bindings/nvmem/qcom,qfprom.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/nvmem/qcom,qfprom.yaml +1 -0
@@ -26,6 +26,7 @@ properties: - qcom,ipq8064-qfprom - qcom,ipq8074-qfprom - qcom,ipq9574-qfprom + - qcom,kaanapali-qfprom - qcom,msm8226-qfprom - qcom,msm8916-qfprom - qcom,msm8917-qfprom
Signature · 1 line
2.47.3
[email protected]
maintainerPATCH 2/9 nvmem: qnap-mcu-eeprom: Fix struct assignments using commas instead of semicolons
In reply to [email protected]From: Felix Gu <[email protected]>
The nvcfg struct member assignments were incorrectly using commas instead of semicolons.
--- drivers/nvmem/qnap-mcu-eeprom.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/nvmem/qnap-mcu-eeprom.c +4 -4
@@ -86,10 +86,10 @@ static int qnap_mcu_eeprom_probe(struct platform_device *pdev) nvcfg.read_only = true; nvcfg.root_only = false; nvcfg.reg_read = qnap_mcu_eeprom_read; - nvcfg.size =QNAP_MCU_EEPROM_SIZE , - nvcfg.word_size =1 , - nvcfg.stride =1 , - nvcfg.priv = mcu, + nvcfg.size =QNAP_MCU_EEPROM_SIZE ; + nvcfg.word_size =1 ; + nvcfg.stride =1 ; + nvcfg.priv = mcu; ndev =devm_nvmem_register (&pdev->dev, &nvcfg);if (IS_ERR (ndev))
Signature · 1 line
2.47.3
[email protected]
maintainerPATCH 3/9 dt-bindings: nvmem: sl28cpld: Drop sa67mcu compatible
In reply to [email protected]From: Michael Walle <[email protected]>
I was just informed that this product is discontinued (without being ever released to the market). Pull the plug and let's not waste any more maintainers time and revert commit 4a9b344e90c7 ("dt-bindings: nvmem:
sl28cpld: add sa67mcu compatible").
--- .../bindings/nvmem/layouts/kontron,sl28-vpd.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
Documentation/devicetree/bindings/nvmem/layouts/kontron,sl28-vpd.yaml +1 -6
@@ -19,12 +19,7 @@ select: false properties: compatible: - oneOf: - - items: - - enum: - - kontron,sa67-vpd - - const: kontron,sl28-vpd - - const: kontron,sl28-vpd + const: kontron,sl28-vpd serial-number: type: object
Signature · 1 line
2.47.3
[email protected]
maintainerPATCH 4/9 dt-bindings: nvmem: rockchip,otp: Add support for RK3562 and RK3568
In reply to [email protected]From: Kever Yang <[email protected]>
Add compatible entry for the otp controller in RK3562 and RK3568, add schema for different clock names for new entry.
--- .../bindings/nvmem/rockchip,otp.yaml | 58 +++++++++++++++---- 1 file changed, 48 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml +48 -10
@@ -14,6 +14,8 @@ properties: enum: - rockchip,px30-otp - rockchip,rk3308-otp + - rockchip,rk3562-otp + - rockchip,rk3568-otp - rockchip,rk3576-otp - rockchip,rk3588-otp
@@ -26,19 +28,15 @@ properties: clock-names: minItems: 3 - items: - - const: otp - - const: apb_pclk - - const: phy - - const: arb + maxItems: 4 resets: minItems: 1 - maxItems: 3 + maxItems: 4 reset-names: minItems: 1 - maxItems: 3 + maxItems: 4 required: - compatible
@@ -64,13 +62,44 @@ allOf: clocks: maxItems: 3 clock-names: - maxItems: 3 + items: + - const: otp + - const: apb_pclk + - const: phy resets: maxItems: 1 reset-names: items: - const: phy + - if: + properties: + compatible: + contains: + enum: + - rockchip,rk3562-otp + - rockchip,rk3568-otp + then: + properties: + clocks: + minItems: 4 + maxItems: 4 + clock-names: + items: + - const: otp + - const: apb_pclk + - const: phy + - const: sbpi + resets: + minItems: 4 + maxItems: 4 + reset-names: + items: + - const: otp + - const: apb + - const: phy + - const: sbpi + - if: properties: compatible:
@@ -82,7 +111,10 @@ allOf: clocks: maxItems: 3 clock-names: - maxItems: 3 + items: + - const: otp + - const: apb_pclk + - const: phy resets: minItems: 2 maxItems: 2
@@ -101,10 +133,16 @@ allOf: properties: clocks: minItems: 4 + maxItems: 4 clock-names: - minItems: 4 + items: + - const: otp + - const: apb_pclk + - const: phy + - const: arb resets: minItems: 3 + maxItems: 3 reset-names: items: - const: otp
Signature · 1 line
2.47.3
[email protected]
maintainerPATCH 5/9 dt-bindings: nvmem: rockchip,otp: Add compatible for RK3528
In reply to [email protected]From: Jonas Karlman <[email protected]>
Add compatible string for the OTP controller in RK3528. Compared to the RK3562 and RK3568 the OTP in RK3528 does not have a phy clock or reset.
--- .../bindings/nvmem/rockchip,otp.yaml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+)
Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml +25 -0
@@ -14,6 +14,7 @@ properties: enum: - rockchip,px30-otp - rockchip,rk3308-otp + - rockchip,rk3528-otp - rockchip,rk3562-otp - rockchip,rk3568-otp - rockchip,rk3576-otp
@@ -72,6 +73,30 @@ allOf: items: - const: phy + - if: + properties: + compatible: + contains: + enum: + - rockchip,rk3528-otp + then: + properties: + clocks: + maxItems: 3 + clock-names: + items: + - const: otp + - const: apb_pclk + - const: sbpi + resets: + minItems: 3 + maxItems: 3 + reset-names: + items: + - const: otp + - const: apb + - const: sbpi + - if: properties: compatible:
Signature · 1 line
2.47.3
[email protected]
maintainerPATCH 6/9 nvmem: rockchip-otp: Handle internal word_size in main reg_read op
In reply to [email protected]From: Jonas Karlman <[email protected]>
Rockchip SoCs RK3576 and RK3588 read data from the OTP using 32-bit words instead of normal 8-bit bytes. Similar RK3506, RK3528, RK3562 and RK3568 will read data from OTP using 16-bit words.
The nvmem core stride and word_size cannot fully be used as cells is not always aligned. Continue to report a stride=1 and word_size=1 in nvmem_config and instead handle use of SoC specific word_size internally in the driver.
Move current SoC specific word_size handling from the RK3588 read_reg operation to the main read_reg operation to help simplify the SoC specific read_reg operation and allow code reuse in a future RK3568 reg_read operation.
--- drivers/nvmem/rockchip-otp.c | 72 ++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 32 deletions(-)
drivers/nvmem/rockchip-otp.c +40 -32
@@ -59,7 +59,6 @@#define RK3588_OTPC_AUTO_EN 0x08#define RK3588_OTPC_INT_ST 0x84#define RK3588_OTPC_DOUT0 0x20 -#define RK3588_NBYTES 4#define RK3588_BURST_NUM 1#define RK3588_BURST_SHIFT 8#define RK3588_ADDR_SHIFT 16
@@ -69,6 +68,7 @@struct rockchip_data {int size;int read_offset; +int word_size;const char *const *clks;int num_clks;nvmem_reg_read_t reg_read;
@@ -185,48 +185,28 @@ static int px30_otp_read(void *context, unsigned int offset, }static int rk3588_otp_read (void *context,unsigned int offset, -void *val,size_t bytes) +void *val,size_t count) {struct rockchip_otp *otp = context; -unsigned int addr_start, addr_end, addr_len; -int ret, i =0 ; -u32 data; -u8 *buf; - - addr_start =round_down (offset,RK3588_NBYTES ) /RK3588_NBYTES ; - addr_end =round_up (offset + bytes,RK3588_NBYTES ) /RK3588_NBYTES ; - addr_len = addr_end - addr_start; - addr_start += otp->data->read_offset /RK3588_NBYTES ; - - buf =kzalloc (array_size (addr_len,RK3588_NBYTES ),GFP_KERNEL ); -if (!buf) -return -ENOMEM ; +u32 *buf = val; +int ret; -while (addr_len--) { -writel ((addr_start <<RK3588_ADDR_SHIFT ) | +while (count--) { +writel ((offset++ <<RK3588_ADDR_SHIFT ) | (RK3588_BURST_NUM <<RK3588_BURST_SHIFT ), otp->base +RK3588_OTPC_AUTO_CTRL );writel (RK3588_AUTO_EN , otp->base +RK3588_OTPC_AUTO_EN ); ret =rockchip_otp_wait_status (otp,RK3588_OTPC_INT_ST ,RK3588_RD_DONE ); -if (ret <0 ) { +if (ret) {dev_err (otp->dev,"timeout during read setup\n" ); - goto read_end; +return ret; } - data =readl (otp->base +RK3588_OTPC_DOUT0 ); -memcpy (&buf[i], &data,RK3588_NBYTES ); - - i +=RK3588_NBYTES ; - addr_start++; + *buf++ =readl (otp->base +RK3588_OTPC_DOUT0 ); } -memcpy (val, buf + offset %RK3588_NBYTES , bytes); - -read_end: -kfree (buf); -return ret; }
@@ -234,7 +214,7 @@ static int rockchip_otp_read(void *context, unsigned int offset, void *val, size_t bytes) {struct rockchip_otp *otp = context; -int ret; +int ret, word_size;if (!otp->data || !otp->data->reg_read)return -EINVAL ;
@@ -245,8 +225,34 @@ static int rockchip_otp_read(void *context, unsigned int offset,return ret; } - ret = otp->data->reg_read (context, offset, val, bytes); + offset += otp->data->read_offset; + word_size = otp->data->word_size; + +if (word_size >1 ) { +unsigned int addr_start, addr_end; +size_t count; +u8 *buf; + + addr_start = offset / word_size; + addr_end =DIV_ROUND_UP (offset + bytes, word_size); + count = addr_end - addr_start; + + buf =kzalloc (array_size (count, word_size),GFP_KERNEL ); +if (!buf) { + ret = -ENOMEM ; + goto err; + } + + ret = otp->data->reg_read (context, addr_start, buf, count); +if (!ret) +memcpy (val, buf + (offset % word_size), bytes); + +kfree (buf); + }else { + ret = otp->data->reg_read (context, offset, val, bytes); + } +err:clk_bulk_disable_unprepare (otp->data->num_clks, otp->clks);return ret;
@@ -259,7 +265,7 @@ static struct nvmem_config otp_config = { .type = NVMEM_TYPE_OTP, .read_only = true, .stride = 1, - .word_size = 1, + .word_size = sizeof(u8), .reg_read = rockchip_otp_read, };
@@ -277,6 +283,7 @@ static const struct rockchip_data px30_data = {static const struct rockchip_data rk3576_data = { .size =0x100 , .read_offset =0x700 , + .word_size =sizeof (u32), .clks = px30_otp_clocks, .num_clks =ARRAY_SIZE (px30_otp_clocks), .reg_read = rk3588_otp_read,
@@ -289,6 +296,7 @@ static const char * const rk3588_otp_clocks[] = {static const struct rockchip_data rk3588_data = { .size =0x400 , .read_offset =0xc00 , + .word_size =sizeof (u32), .clks = rk3588_otp_clocks, .num_clks =ARRAY_SIZE (rk3588_otp_clocks), .reg_read = rk3588_otp_read,
Signature · 1 line
2.47.3
[email protected]
maintainerPATCH 7/9 nvmem: rockchip-otp: Add support for RK3568
In reply to [email protected]From: Finley Xiao <[email protected]>
This adds the necessary data for handling otp the rk3568.
--- drivers/nvmem/rockchip-otp.c | 69 ++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
drivers/nvmem/rockchip-otp.c +69 -0
@@ -27,6 +27,7 @@#define OTPC_USER_CTRL 0x0100#define OTPC_USER_ADDR 0x0104#define OTPC_USER_ENABLE 0x0108 +#define OTPC_USER_QP 0x0120#define OTPC_USER_Q 0x0124#define OTPC_INT_STATUS 0x0304#define OTPC_SBPI_CMD0_OFFSET 0x1000
@@ -184,6 +185,58 @@ static int px30_otp_read(void *context, unsigned int offset,return ret; } +static int rk3568_otp_read (void *context,unsigned int offset,void *val, +size_t count) +{ +struct rockchip_otp *otp = context; +u16 *buf = val; +u32 otp_qp; +int ret; + + ret =rockchip_otp_reset (otp); +if (ret) { +dev_err (otp->dev,"failed to reset otp phy\n" ); +return ret; + } + + ret =rockchip_otp_ecc_enable (otp, true); +if (ret) { +dev_err (otp->dev,"rockchip_otp_ecc_enable err\n" ); +return ret; + } + +writel (OTPC_USE_USER |OTPC_USE_USER_MASK , otp->base +OTPC_USER_CTRL ); +udelay (5 ); + +while (count--) { +writel (offset++ |OTPC_USER_ADDR_MASK , + otp->base +OTPC_USER_ADDR ); +writel (OTPC_USER_FSM_ENABLE |OTPC_USER_FSM_ENABLE_MASK , + otp->base +OTPC_USER_ENABLE ); + + ret =rockchip_otp_wait_status (otp,OTPC_INT_STATUS , +OTPC_USER_DONE ); +if (ret) { +dev_err (otp->dev,"timeout during read setup\n" ); + goto read_end; + } + + otp_qp =readl (otp->base +OTPC_USER_QP ); +if (((otp_qp &0xc0 ) ==0xc0 ) || (otp_qp &0x20 )) { + ret = -EIO ; +dev_err (otp->dev,"ecc check error during read setup\n" ); + goto read_end; + } + + *buf++ =readl (otp->base +OTPC_USER_Q ); + } + +read_end: +writel (0x0 |OTPC_USE_USER_MASK , otp->base +OTPC_USER_CTRL ); + +return ret; +} +static int rk3588_otp_read (void *context,unsigned int offset,void *val,size_t count) {
@@ -280,6 +333,18 @@ static const struct rockchip_data px30_data = { .reg_read = px30_otp_read, }; +static const char *const rk3568_otp_clocks[] = { +"otp" ,"apb_pclk" ,"phy" ,"sbpi" , +}; + +static const struct rockchip_data rk3568_data = { + .size =0x80 , + .word_size =sizeof (u16), + .clks = rk3568_otp_clocks, + .num_clks =ARRAY_SIZE (rk3568_otp_clocks), + .reg_read = rk3568_otp_read, +}; +static const struct rockchip_data rk3576_data = { .size =0x100 , .read_offset =0x700 ,
@@ -311,6 +376,10 @@ static const struct of_device_id rockchip_otp_match[] = { .compatible = "rockchip,rk3308-otp", .data = &px30_data, }, + { + .compatible = "rockchip,rk3568-otp", + .data = &rk3568_data, + }, { .compatible = "rockchip,rk3576-otp", .data = &rk3576_data,
Signature · 1 line
2.47.3
[email protected]
maintainerPATCH 8/9 nvmem: rockchip-otp: Add support for RK3562
In reply to [email protected]From: Finley Xiao <[email protected]>
This adds the necessary data for handling otp on the rk3562.
--- drivers/nvmem/rockchip-otp.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvmem/rockchip-otp.c +4 -0
@@ -376,6 +376,10 @@ static const struct of_device_id rockchip_otp_match[] = { .compatible = "rockchip,rk3308-otp", .data = &px30_data, }, + { + .compatible = "rockchip,rk3562-otp", + .data = &rk3568_data, + }, { .compatible = "rockchip,rk3568-otp", .data = &rk3568_data,
Signature · 1 line
2.47.3
[email protected]
maintainerPATCH 9/9 nvmem: rockchip-otp: Add support for RK3528
In reply to [email protected]From: Jonas Karlman <[email protected]>
Add support for the OTP controller in RK3528. The OTPC is similar to the OTPC in RK3562 and RK3568, exept for a missing phy clock and reset.
--- drivers/nvmem/rockchip-otp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/nvmem/rockchip-otp.c +16 -0
@@ -333,6 +333,18 @@ static const struct rockchip_data px30_data = { .reg_read = px30_otp_read, }; +static const char *const rk3528_otp_clocks[] = { +"otp" ,"apb_pclk" ,"sbpi" , +}; + +static const struct rockchip_data rk3528_data = { + .size =0x80 , + .word_size =sizeof (u16), + .clks = rk3528_otp_clocks, + .num_clks =ARRAY_SIZE (rk3528_otp_clocks), + .reg_read = rk3568_otp_read, +}; +static const char *const rk3568_otp_clocks[] = {"otp" ,"apb_pclk" ,"phy" ,"sbpi" , };
@@ -376,6 +388,10 @@ static const struct of_device_id rockchip_otp_match[] = { .compatible = "rockchip,rk3308-otp", .data = &px30_data, }, + { + .compatible = "rockchip,rk3528-otp", + .data = &rk3528_data, + }, { .compatible = "rockchip,rk3562-otp", .data = &rk3568_data,
Signature · 1 line
2.47.3