Add sdhci dt caps & caps mask support
v2 cover Add sdhci dt caps & caps mask support
Hi,
This patch series adds support for reading 64-bit dt properties & add support sdhci dt caps & caps mask.
Thanks,
Michal
Changes in v2:
- Moved newly added 64-bit funtion definations & prototypes below 32-bit functions.
T Karthik Reddy (2):
dm: core: Add functions to read 64-bit dt properties
mmc: sdhci: Add support for dt caps & caps mask
drivers/core/ofnode.c | 2 +- drivers/core/read.c | 10 ++++++++++ drivers/mmc/sdhci.c | 23 ++++++++++++++--------- include/dm/ofnode.h | 2 +- include/dm/read.h | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 11 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/2 dm: core: Add functions to read 64-bit dt properties
From: T Karthik Reddy <[email protected]>
This patch adds functions dev_read_u64_default & dev_read_u64 to read unsigned 64-bit values from devicetree.
---
Changes in v2:
- Moved newly added 64-bit funtion definations & prototypes below 32-bit functions.
drivers/core/ofnode.c | 2 +- drivers/core/read.c | 10 ++++++++++ include/dm/ofnode.h | 2 +- include/dm/read.h | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-)
drivers/core/ofnode.c +1 -1
@@ -79,7 +79,7 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp)return 0 ; } -int ofnode_read_u64_default (ofnode node,const char *propname,u64 def) +u64 ofnode_read_u64_default (ofnode node,const char *propname,u64 def) {assert (ofnode_valid (node));ofnode_read_u64 (node, propname, &def);
drivers/core/read.c +10 -0
@@ -44,6 +44,16 @@ int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp)return 0 ; } +int dev_read_u64 (struct udevice *dev,const char *propname,u64 *outp) +{ +return ofnode_read_u64 (dev_ofnode (dev), propname, outp); +} + +u64 dev_read_u64_default (struct udevice *dev,const char *propname,u64 def) +{ +return ofnode_read_u64_default (dev_ofnode (dev), propname, def); +} +const char *dev_read_string (struct udevice *dev,const char *propname) {return ofnode_read_string (dev_ofnode (dev), propname);
include/dm/ofnode.h +1 -1
@@ -254,7 +254,7 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp);* @def: default value to return if the property has no value * @return property value, or @def if not found */ -int ofnode_read_u64_default (ofnode node,const char *propname,u64 def); +u64 ofnode_read_u64_default (ofnode node,const char *propname,u64 def);/** * ofnode_read_string() - Read a string from a property
include/dm/read.h +33 -0
@@ -44,6 +44,7 @@ static inline bool dev_of_valid(struct udevice *dev) }#ifndef CONFIG_DM_DEV_READ_INLINE +/** * dev_read_u32() - read a 32-bit integer from a device's DT property *
@@ -96,6 +97,26 @@ int dev_read_s32_default(struct udevice *dev, const char *propname, int def);*/ int dev_read_u32u (struct udevice *dev,const char *propname,uint *outp); +/** +* dev_read_u64() - read a 64-bit integer from a device's DT property +* +* @dev: device to read DT property from +* @propname: name of the property to read from +* @outp: place to put value (if found) +* @return 0 if OK, -ve on error +*/ +int dev_read_u64 (struct udevice *dev,const char *propname,u64 *outp); + +/** +* dev_read_u64_default() - read a 64-bit integer from a device's DT property +* +* @dev: device to read DT property from +* @propname: name of the property to read from +* @def: default value to return if the property has no value +* @return property value, or @def if not found +*/ +u64 dev_read_u64_default (struct udevice *dev,const char *propname,u64 def); +/** * dev_read_string() - Read a string from a device's DT property *
@@ -601,6 +622,18 @@ static inline int dev_read_u32u(struct udevice *dev,return 0 ; } +static inline int dev_read_u64 (struct udevice *dev, +const char *propname,u64 *outp) +{ +return ofnode_read_u64 (dev_ofnode (dev), propname, outp); +} + +static inline u64 dev_read_u64_default (struct udevice *dev, +const char *propname,u64 def) +{ +return ofnode_read_u64_default (dev_ofnode (dev), propname, def); +} +static inline const char *dev_read_string (struct udevice *dev,const char *propname) {
Signature · 1 line
2.17.1
PATCH v2 1/2 dm: core: Add functions to read 64-bit dt properties
Quoted 14 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch adds functions
dev_read_u64_default&dev_read_u64to read unsigned 64-bit values from devicetree.Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Moved newly added 64-bit funtion definations & prototypes below 32-bit functions.
Quoted 6 lines
drivers/core/ofnode.c | 2 +- drivers/core/read.c | 10 ++++++++++ include/dm/ofnode.h | 2 +- include/dm/read.h | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-)
PATCH v2 1/2 dm: core: Add functions to read 64-bit dt properties
Quoted 16 lines · Bin Meng
Quoted 14 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch adds functions
dev_read_u64_default&dev_read_u64to read unsigned 64-bit values from devicetree.Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Moved newly added 64-bit funtion definations & prototypes below 32-bit functions.
Quoted 8 lines
Quoted 6 lines
drivers/core/ofnode.c | 2 +- drivers/core/read.c | 10 ++++++++++ include/dm/ofnode.h | 2 +- include/dm/read.h | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-)Reviewed-by Bin Meng <[email protected]>
How about adding a few tests for these new functions?
See for example here:
https://gitlab.denx.de/u-boot/custodians/u-boot-dm/commit/63453b90049cef10309f254c35d8a33e1e6552ba
- Simon
PATCH v2 1/2 dm: core: Add functions to read 64-bit dt properties
Quoted 24 lines · Simon Glass
Quoted 23 lines · Bin Meng
Quoted 20 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch adds functions
dev_read_u64_default&dev_read_u64to read unsigned 64-bit values from devicetree.Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Moved newly added 64-bit funtion definations & prototypes below 32-bit functions.drivers/core/ofnode.c | 2 +- drivers/core/read.c | 10 ++++++++++ include/dm/ofnode.h | 2 +- include/dm/read.h | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 1 line
Reviewed-by Bin Meng <[email protected]>How about adding a few tests for these new functions?
See for example here:
https://gitlab.denx.de/u-boot/custodians/u-boot-dm/commit/63453b90049cef10309f254c35d8a33e1e6552ba
It shouldn't be a problem to put some u64 properties and read them back.
Karthik: Can you please take a look at it?
Thanks,
Michal
PATCH v2 1/2 dm: core: Add functions to read 64-bit dt properties
Hi,
Quoted 52 lines
-----Original Message-----
From: Michal Simek <[email protected]>
Sent: Tuesday, September 17, 2019 6:56 PM
To: Simon Glass <[email protected]>; Bin Meng <[email protected]>
Cc: Michal Simek <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; T Karthik Reddy <[email protected]>; git <[email protected]>
Subject: Re: [PATCH v2 1/2] dm: core: Add functions to read 64-bit dt propertiesQuoted 3 lines · Simon Glass
Quoted 2 lines · Bin Meng
On Mon, Sep 2, 2019 at 10:34 PM Michal Simek
Quoted 21 lines · <[email protected]> wrote:
Quoted 21 lines
Quoted 20 lines
From: T Karthik Reddy <[email protected]>
This patch adds functions
dev_read_u64_default&dev_read_u64to read unsigned 64-bit values from devicetree.Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Moved newly added 64-bit funtion definations & prototypes below 32-bit functions.drivers/core/ofnode.c | 2 +- drivers/core/read.c | 10 ++++++++++ include/dm/ofnode.h | 2 +- include/dm/read.h | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-)Quoted 8 lines
Quoted 1 line
Reviewed-by Bin Meng <[email protected]>How about adding a few tests for these new functions?
See for example here:
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitl
ab.denx.de%2Fu-boot%2Fcustodians%2Fu-boot-dm%2Fcommit%2F63453b90049cef
Quoted 1 line
10309f254c35d8a33e1e6552ba&data=02%7C01%7Ctkarthik%40xilinx.co m%7C
Quoted 1 line
3e117e8ac64647d1c85c08d73b72c06e%7C657af505d5df48d08300c31994686c5 c%7C
Quoted 1 line
Quoted 7 lines
0%7C1%7C637043236369808223&sdata=MQJnMjJlj6QHbMQ%2Fz77bXjd BkfiGFXa
Quoted 1 line
YAbnISGTKR3A%3D&reserved=0
It shouldn't be a problem to put some u64 properties and read them back.
Karthik: Can you please take a look at it?
Okay.
Regards
T karthik
Quoted 3 lines
Thanks,
Michal
PATCH v2 2/2 mmc: sdhci: Add support for dt caps & caps mask
In reply to Michal SimekFrom: T Karthik Reddy <[email protected]>
The sdhci capabilities registers can be incorrect. The sdhci-caps-mask and sdhci-caps dt properties specify which bits of the registers are incorrect and what their values should be. This patch makes the sdhci driver use those properties to correct the caps. Also use "dev_read_u64_default" instead of "dev_read_u32_array" for caps mask.
---
Changes in v2: None
drivers/mmc/sdhci.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/mmc/sdhci.c +14 -9
@@ -711,17 +711,19 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, {u32 caps, caps_1 =0 ;#if CONFIG_IS_ENABLED (DM_MMC ) -u32 mask[2 ] = {0 }; -int ret; - ret =dev_read_u32_array (host->mmc->dev,"sdhci-caps-mask" , - mask,2 ); -if (ret && ret !=-1 ) -return ret; - - caps = ~mask[1 ] &sdhci_readl (host,SDHCI_CAPABILITIES ); +u64 dt_caps, dt_caps_mask; + + dt_caps_mask =dev_read_u64_default (host->mmc->dev, +"sdhci-caps-mask" ,0 ); + dt_caps =dev_read_u64_default (host->mmc->dev, +"sdhci-caps" ,0 ); + caps = ~(u32 )dt_caps_mask & +sdhci_readl (host,SDHCI_CAPABILITIES ); + caps |= (u32 )dt_caps;#else caps =sdhci_readl (host,SDHCI_CAPABILITIES );#endif +debug ("%s, caps: 0x%x\n" , __func__, caps);#ifdef CONFIG_MMC_SDHCI_SDMA if (!(caps &SDHCI_CAN_DO_SDMA )) {
@@ -762,10 +764,13 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host,/* Check whether the clock multiplier is supported or not */ if (SDHCI_GET_VERSION (host) >=SDHCI_SPEC_300 ) {#if CONFIG_IS_ENABLED (DM_MMC ) - caps_1 = ~mask[0 ] &sdhci_readl (host,SDHCI_CAPABILITIES_1 ); + caps_1 = ~(u32)(dt_caps_mask >>32 ) & +sdhci_readl (host,SDHCI_CAPABILITIES_1 ); + caps_1 |= (u32)(dt_caps >>32 );#else caps_1 =sdhci_readl (host,SDHCI_CAPABILITIES_1 );#endif +debug ("%s, caps_1: 0x%x\n" , __func__, caps_1); host->clk_mul = (caps_1 &SDHCI_CLOCK_MUL_MASK ) >>SDHCI_CLOCK_MUL_SHIFT ; }
Signature · 1 line
2.17.1