sd: sdhci: Implement basic vendor specific register support
v2 cover sd: sdhci: Implement basic vendor specific register support
The Linux kernel's IMX code now uses vendor specific commands. This results in endless warnings when booting the Linux kernel.
sdhci-esdhc-imx 2194000.usdhc: esdhc_wait_for_card_clock_gate_off:
card clock still not gate off in 100us!.
Implement support for the vendor specific command implemented in IMX SDHCI hardware to be able to avoid this warning.
Patch 1/2 implements vendor specific command support in the SDHCI core code. At this time, only IMX vendor command support is implemented, but the implementation is written with expandability in mind.
Patch 2/2 enables IMX SDHCI vendor extensions for all affected emulations.
v2:
- Added Reviewed-by: and Tested-by: tags to patch 1/2
- Added missing error checks to patch 2/2
- Added Tested-by: tag to patch 2/2
----------------------------------------------------------------
Guenter Roeck (2):
sd: sdhci: Implement basic vendor specific register support
hw: arm: Set vendor property for IMX SDHCI emulations
hw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/fsl-imx6ul.c | 2 ++ hw/arm/fsl-imx7.c | 2 ++ hw/sd/sdhci-internal.h | 5 +++++ hw/sd/sdhci.c | 18 +++++++++++++++++- include/hw/sd/sdhci.h | 5 +++++ 7 files changed, 43 insertions(+), 1 deletion(-)
PATCH v2 1/2 sd: sdhci: Implement basic vendor specific register support
The Linux kernel's IMX code now uses vendor specific commands. This results in endless warnings when booting the Linux kernel.
sdhci-esdhc-imx 2194000.usdhc: esdhc_wait_for_card_clock_gate_off:
card clock still not gate off in 100us!.
Implement support for the vendor specific command implemented in IMX hardware to be able to avoid this warning.
---
v2: Added Philippe's Tested-by: and Reviewed-by: tags
hw/sd/sdhci-internal.h | 5 +++++ hw/sd/sdhci.c | 18 +++++++++++++++++- include/hw/sd/sdhci.h | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-)
hw/sd/sdhci-internal.h +5 -0
@@ -75,6 +75,7 @@#define SDHC_CMD_INHIBIT 0x00000001#define SDHC_DATA_INHIBIT 0x00000002#define SDHC_DAT_LINE_ACTIVE 0x00000004 +#define SDHC_IMX_CLOCK_GATE_OFF 0x00000080#define SDHC_DOING_WRITE 0x00000100#define SDHC_DOING_READ 0x00000200#define SDHC_SPACE_AVAILABLE 0x00000400
@@ -289,7 +290,10 @@ extern const VMStateDescription sdhci_vmstate;#define ESDHC_MIX_CTRL 0x48 +#define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_IMX_FRC_SDCLK_ON (1 << 8) +#define ESDHC_DLL_CTRL 0x60#define ESDHC_TUNING_CTRL 0xcc
@@ -326,6 +330,7 @@ extern const VMStateDescription sdhci_vmstate;#define DEFINE_SDHCI_COMMON_PROPERTIES (_state) \ DEFINE_PROP_UINT8("sd-spec-version", _state, sd_spec_version, 2), \ DEFINE_PROP_UINT8("uhs", _state, uhs_mode, UHS_NOT_SUPPORTED), \ + DEFINE_PROP_UINT8("vendor", _state, vendor, SDHCI_VENDOR_NONE), \ \/* Capabilities registers provide information on supported * features of this specific host controller implementation */ \
hw/sd/sdhci.c +17 -1
@@ -1569,11 +1569,13 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size) }break ; +case ESDHC_VENDOR_SPEC : + ret = s->vendor_spec; +break ;case ESDHC_DLL_CTRL :case ESDHC_TUNE_CTRL_STATUS :case ESDHC_UNDOCUMENTED_REG27 :case ESDHC_TUNING_CTRL : -case ESDHC_VENDOR_SPEC :case ESDHC_MIX_CTRL :case ESDHC_WTMK_LVL : ret =0 ;
@@ -1596,7 +1598,21 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)case ESDHC_UNDOCUMENTED_REG27 :case ESDHC_TUNING_CTRL :case ESDHC_WTMK_LVL : +break ; +case ESDHC_VENDOR_SPEC : + s->vendor_spec = value; +switch (s->vendor) { +case SDHCI_VENDOR_IMX : +if (value &ESDHC_IMX_FRC_SDCLK_ON ) { + s->prnsts &= ~SDHC_IMX_CLOCK_GATE_OFF ; + }else { + s->prnsts |=SDHC_IMX_CLOCK_GATE_OFF ; + } +break ; +default : +break ; + }break ;case SDHC_HOSTCTL :
include/hw/sd/sdhci.h +5 -0
@@ -74,6 +74,7 @@ typedef struct SDHCIState {uint16_t acmd12errsts;/* Auto CMD12 error status register */ uint16_t hostctl2;/* Host Control 2 */ uint64_t admasysaddr;/* ADMA System Address Register */ +uint16_t vendor_spec;/* Vendor specific register */ /* Read-only registers */ uint64_t capareg;/* Capabilities Register */
@@ -96,8 +97,12 @@ typedef struct SDHCIState {uint32_t quirks;uint8_t sd_spec_version;uint8_t uhs_mode; +uint8_t vendor;/* For vendor specific functionality */ } SDHCIState; +#define SDHCI_VENDOR_NONE 0 +#define SDHCI_VENDOR_IMX 1 +/* * Controller does not provide transfer-complete interrupt when not * busy.
Signature · 1 line
2.17.1
PATCH v2 2/2 hw: arm: Set vendor property for IMX SDHCI emulations
In reply to Guenter RoeckSet vendor property to IMX to enable IMX specific functionality in sdhci code.
---
v2: Added missing error checks
Added Philippe's Tested-by: tag
hw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/fsl-imx6ul.c | 2 ++ hw/arm/fsl-imx7.c | 2 ++ 4 files changed, 16 insertions(+)
hw/arm/fsl-imx25.c +6 -0
@@ -274,6 +274,12 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) &err);object_property_set_uint (OBJECT (&s->esdhc[i]),IMX25_ESDHC_CAPABILITIES ,"capareg" , &err); +object_property_set_uint (OBJECT (&s->esdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->esdhc[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
hw/arm/fsl-imx6.c +6 -0
@@ -350,6 +350,12 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) &err);object_property_set_uint (OBJECT (&s->esdhc[i]),IMX6_ESDHC_CAPABILITIES ,"capareg" , &err); +object_property_set_uint (OBJECT (&s->esdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->esdhc[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
hw/arm/fsl-imx6ul.c +2 -0
@@ -505,6 +505,8 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)FSL_IMX6UL_USDHC2_IRQ , }; +object_property_set_uint (OBJECT (&s->usdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &error_abort);object_property_set_bool (OBJECT (&s->usdhc[i]), true,"realized" , &error_abort);
hw/arm/fsl-imx7.c +2 -0
@@ -416,6 +416,8 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)FSL_IMX7_USDHC3_IRQ , }; +object_property_set_uint (OBJECT (&s->usdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &error_abort);object_property_set_bool (OBJECT (&s->usdhc[i]), true,"realized" , &error_abort);
Signature · 1 line
2.17.1
Re: [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations
Quoted 68 lines · Guenter Roeck
Set vendor property to IMX to enable IMX specific functionality in sdhci code.
Signed-off-by Guenter Roeck <[email protected]>---
v2: Added missing error checks
Added Philippe's Tested-by: taghw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/fsl-imx6ul.c | 2 ++ hw/arm/fsl-imx7.c | 2 ++ 4 files changed, 16 insertions(+)hw/arm/fsl-imx25.c +6
-0@@ -274,6 +274,12 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) &err);object_property_set_uint (OBJECT (&s->esdhc[i]),IMX25_ESDHC_CAPABILITIES ,"capareg" , &err); +object_property_set_uint (OBJECT (&s->esdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->esdhc[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);hw/arm/fsl-imx6.c +6
-0@@ -350,6 +350,12 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) &err);object_property_set_uint (OBJECT (&s->esdhc[i]),IMX6_ESDHC_CAPABILITIES ,"capareg" , &err); +object_property_set_uint (OBJECT (&s->esdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->esdhc[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);hw/arm/fsl-imx6ul.c +2
-0@@ -505,6 +505,8 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)FSL_IMX6UL_USDHC2_IRQ , }; +object_property_set_uint (OBJECT (&s->usdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &error_abort);object_property_set_bool (OBJECT (&s->usdhc[i]), true,"realized" , &error_abort);hw/arm/fsl-imx7.c +0
-0
hw/arm/fsl-imx7.c static void fsl_imx7_realize(DeviceState *dev, Error **errp) · line 423
Quoted 8 lines
hw/arm/fsl-imx7.c +2
-0@@ -416,6 +416,8 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)FSL_IMX7_USDHC3_IRQ , }; +object_property_set_uint (OBJECT (&s->usdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &error_abort);object_property_set_bool (OBJECT (&s->usdhc[i]), true,"realized" , &error_abort);
Re: [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations
In reply to Guenter RoeckQuoted 21 lines · Guenter Roeck
Set vendor property to IMX to enable IMX specific functionality in sdhci code.
Signed-off-by Guenter Roeck <[email protected]>---
v2: Added missing error checks
Added Philippe's Tested-by: taghw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/fsl-imx6ul.c | 2 ++ hw/arm/fsl-imx7.c | 2 ++ 4 files changed, 16 insertions(+)hw/arm/fsl-imx25.c +0
-0
hw/arm/fsl-imx25.c static void fsl_imx25_realize(DeviceState *dev, Error **errp) · line 282
Quoted 9 lines
hw/arm/fsl-imx25.c +6
-0@@ -274,6 +274,12 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) &err);object_property_set_uint (OBJECT (&s->esdhc[i]),IMX25_ESDHC_CAPABILITIES ,"capareg" , &err); +object_property_set_uint (OBJECT (&s->esdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &err); +if (err) { +error_propagate (errp, err); +return ; + }
The existing error handling in this function is wrong -- for multiple calls that take a pointer to a local Error*, the check-and-error_propagate() has to be done after each call, it can't be rolled up into a single check after all the calls. (see include/qapi/error.h for the patterns that are valid).
On the other hand this change is correct-in-itself so I guess it isn't making the problem worse...
thanks
-- PMM
Re: [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations
Quoted 29 lines · Peter Maydell
Quoted 28 lines · Guenter Roeck
Set vendor property to IMX to enable IMX specific functionality in sdhci code.
Signed-off-by Guenter Roeck <[email protected]>---
v2: Added missing error checks
Added Philippe's Tested-by: taghw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/fsl-imx6ul.c | 2 ++ hw/arm/fsl-imx7.c | 2 ++ 4 files changed, 16 insertions(+)hw/arm/fsl-imx25.c +4
-0@@ -274,6 +274,12 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) &err);object_property_set_uint (OBJECT (&s->esdhc[i]),IMX25_ESDHC_CAPABILITIES ,"capareg" , &err); +object_property_set_uint (OBJECT (&s->esdhc[i]),SDHCI_VENDOR_IMX , +"vendor" , &err); +if (err) { +error_propagate (errp, err);
Quoted 9 lines
hw/arm/fsl-imx25.c static void fsl_imx25_realize(DeviceState *dev, Error **errp) · line 282
Quoted 2 lines
hw/arm/fsl-imx25.c +2
-0+return ; + }The existing error handling in this function is wrong -- for multiple calls that take a pointer to a local Error*, the check-and-error_propagate() has to be done after each call, it can't be rolled up into a single check after all the calls. (see
include/qapi/error.hfor the patterns that are valid).
A fix for that problem was submitted by Philippe:
https://www.mail-archive.com/[email protected]/msg695544.html
Thanks,
Guenter
Peter Maydell
AppliedQuoted 14 lines · Guenter Roeck
The Linux kernel's IMX code now uses vendor specific commands. This results in endless warnings when booting the Linux kernel.
sdhci-esdhc-imx 2194000.usdhc:
esdhc_wait_for_card_clock_gate_off:
card clock still not gate off in 100us!.Implement support for the vendor specific command implemented in IMX SDHCI hardware to be able to avoid this warning.
Patch 1/2 implements vendor specific command support in the SDHCI core code. At this time, only IMX vendor command support is implemented, but the implementation is written with expandability in mind.
Quoted 6 lines
Patch 2/2 enables IMX SDHCI vendor extensions for all affected emulations.
v2:
- Added Reviewed-by: and Tested-by: tags to patch 1/2
- Added missing error checks to patch 2/2
- Added Tested-by: tag to patch 2/2
Applied to target-arm.next, thanks.
-- PMM