* [PATCH 1/2] mmc: Add support for marking hpi as broken through devicetree
@ 2015-03-29 18:09 Hans de Goede
[not found] ` <1427652575-12642-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Hans de Goede @ 2015-03-29 18:09 UTC (permalink / raw)
To: Chris Ball, Ulf Hansson
Cc: Maxime Ripard, linux-mmc-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Hans de Goede
The eMMC on a tablet I've will stop working / communicating as soon as
the kernel executes:
mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_HPI_MGMT, 1,
card->ext_csd.generic_cmd6_time);
There seems to be no way to reliable identify eMMC-s which have a broken
hpi implementation, but at least for eMMC's which are soldered onto a board
we can work around this by specifying that hpi is broken in devicetree.
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
Documentation/devicetree/bindings/mmc/mmc-card.txt | 31 ++++++++++++++++++++++
drivers/mmc/core/mmc.c | 10 ++++++-
2 files changed, 40 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/mmc/mmc-card.txt
diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.txt b/Documentation/devicetree/bindings/mmc/mmc-card.txt
new file mode 100644
index 0000000..0cc67fb
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/mmc-card.txt
@@ -0,0 +1,31 @@
+mmc-card / eMMC bindings
+------------------------
+
+This documents describes the devicetree bindings for a mmc-host controller
+child node describing a mmc-card / an eMMC, see "Use of Function subnodes"
+in mmc.txt
+
+Required properties:
+-compatible : Must be "mmc-card"
+-reg : Must be <0>
+
+Optional properties:
+-broken-hpi : Use this to indicate that the mmc-card has a broken hpi
+ implementation, and that hpi should not be used
+
+Example:
+
+&mmc2 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&mmc2_pins_a>;
+ vmmc-supply = <®_vcc3v3>;
+ bus-width = <8>;
+ non-removable;
+ status = "okay";
+
+ mmmcard: mmccard@0 {
+ reg = <0>;
+ compatible = "mmc-card";
+ broken-hpi;
+ };
+};
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 1d41e85..8d18920 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -11,6 +11,7 @@
*/
#include <linux/err.h>
+#include <linux/of.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/pm_runtime.h>
@@ -336,6 +337,8 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
{
int err = 0, idx;
unsigned int part_size;
+ struct device_node *np = card->dev.of_node;
+ bool broken_hpi = false;
/* Version is coded in the CSD_STRUCTURE byte in the EXT_CSD register */
card->ext_csd.raw_ext_csd_structure = ext_csd[EXT_CSD_STRUCTURE];
@@ -349,6 +352,9 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
}
}
+ if (np && of_device_is_compatible(np, "mmc-card"))
+ broken_hpi = of_property_read_bool(np, "broken-hpi");
+
/*
* The EXT_CSD format is meant to be forward compatible. As long
* as CSD_STRUCTURE does not change, all values for EXT_CSD_REV
@@ -494,7 +500,7 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
}
/* check whether the eMMC card supports HPI */
- if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x1) {
+ if (!broken_hpi && (ext_csd[EXT_CSD_HPI_FEATURES] & 0x1)) {
card->ext_csd.hpi = 1;
if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x2)
card->ext_csd.hpi_cmd = MMC_STOP_TRANSMISSION;
@@ -1251,6 +1257,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
card->ocr = ocr;
card->type = MMC_TYPE_MMC;
card->rca = 1;
+ /* Also gets done by mmc_add_card, but we need early access */
+ card->dev.of_node = mmc_of_find_child_device(host, 0);
memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
}
--
2.3.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ARM: dts: sun5i: Add broken-hpi property for Utoo-P66 eMMC
[not found] ` <1427652575-12642-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2015-03-29 18:09 ` Hans de Goede
2015-03-31 14:47 ` Sergei Shtylyov
2015-03-30 9:14 ` [PATCH 1/2] mmc: Add support for marking hpi as broken through devicetree Ulf Hansson
1 sibling, 1 reply; 5+ messages in thread
From: Hans de Goede @ 2015-03-29 18:09 UTC (permalink / raw)
To: Chris Ball, Ulf Hansson
Cc: Maxime Ripard, linux-mmc-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Hans de Goede
The eMMC on the A13 based Utoo-P66 tablet does not properly support hpi,
and trying to enable it results in the eMMC not working, so add a child-node
describing the eMMC, and set the broken-hpi property on it.
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
arch/arm/boot/dts/sun5i-a13-utoo-p66.dts | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts b/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts
index 6c9f5f3..5b572fa 100644
--- a/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts
+++ b/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts
@@ -150,6 +150,12 @@
bus-width = <8>;
non-removable;
status = "okay";
+
+ mmmcard: mmccard@0 {
+ reg = <0>;
+ compatible = "mmc-card";
+ broken-hpi;
+ };
};
&pio {
--
2.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mmc: Add support for marking hpi as broken through devicetree
[not found] ` <1427652575-12642-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-29 18:09 ` [PATCH 2/2] ARM: dts: sun5i: Add broken-hpi property for Utoo-P66 eMMC Hans de Goede
@ 2015-03-30 9:14 ` Ulf Hansson
[not found] ` <CAPDyKFp8bNYNgNW0u-JCN4ay0UM7JEdkdW48VRsCmu+JWpJgEA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
1 sibling, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2015-03-30 9:14 UTC (permalink / raw)
To: Hans de Goede
Cc: Chris Ball, Maxime Ripard, linux-mmc,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree, linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
On 29 March 2015 at 20:09, Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> The eMMC on a tablet I've will stop working / communicating as soon as
> the kernel executes:
>
> mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> EXT_CSD_HPI_MGMT, 1,
> card->ext_csd.generic_cmd6_time);
>
> There seems to be no way to reliable identify eMMC-s which have a broken
> hpi implementation, but at least for eMMC's which are soldered onto a board
> we can work around this by specifying that hpi is broken in devicetree.
Seems like a reasonable approach!
>
> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> Documentation/devicetree/bindings/mmc/mmc-card.txt | 31 ++++++++++++++++++++++
> drivers/mmc/core/mmc.c | 10 ++++++-
> 2 files changed, 40 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/devicetree/bindings/mmc/mmc-card.txt
>
> diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.txt b/Documentation/devicetree/bindings/mmc/mmc-card.txt
> new file mode 100644
> index 0000000..0cc67fb
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/mmc-card.txt
> @@ -0,0 +1,31 @@
> +mmc-card / eMMC bindings
> +------------------------
> +
> +This documents describes the devicetree bindings for a mmc-host controller
> +child node describing a mmc-card / an eMMC, see "Use of Function subnodes"
> +in mmc.txt
> +
> +Required properties:
> +-compatible : Must be "mmc-card"
> +-reg : Must be <0>
Instead of using a compatible, why can we just use "reg = <0>"?
> +
> +Optional properties:
> +-broken-hpi : Use this to indicate that the mmc-card has a broken hpi
> + implementation, and that hpi should not be used
> +
> +Example:
> +
> +&mmc2 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&mmc2_pins_a>;
> + vmmc-supply = <®_vcc3v3>;
> + bus-width = <8>;
> + non-removable;
> + status = "okay";
> +
> + mmmcard: mmccard@0 {
> + reg = <0>;
> + compatible = "mmc-card";
> + broken-hpi;
> + };
> +};
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 1d41e85..8d18920 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -11,6 +11,7 @@
> */
>
> #include <linux/err.h>
> +#include <linux/of.h>
> #include <linux/slab.h>
> #include <linux/stat.h>
> #include <linux/pm_runtime.h>
> @@ -336,6 +337,8 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
> {
> int err = 0, idx;
> unsigned int part_size;
> + struct device_node *np = card->dev.of_node;
> + bool broken_hpi = false;
>
> /* Version is coded in the CSD_STRUCTURE byte in the EXT_CSD register */
> card->ext_csd.raw_ext_csd_structure = ext_csd[EXT_CSD_STRUCTURE];
> @@ -349,6 +352,9 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
> }
> }
>
> + if (np && of_device_is_compatible(np, "mmc-card"))
> + broken_hpi = of_property_read_bool(np, "broken-hpi");
> +
> /*
> * The EXT_CSD format is meant to be forward compatible. As long
> * as CSD_STRUCTURE does not change, all values for EXT_CSD_REV
> @@ -494,7 +500,7 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
> }
>
> /* check whether the eMMC card supports HPI */
> - if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x1) {
> + if (!broken_hpi && (ext_csd[EXT_CSD_HPI_FEATURES] & 0x1)) {
> card->ext_csd.hpi = 1;
> if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x2)
> card->ext_csd.hpi_cmd = MMC_STOP_TRANSMISSION;
> @@ -1251,6 +1257,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
> card->ocr = ocr;
> card->type = MMC_TYPE_MMC;
> card->rca = 1;
> + /* Also gets done by mmc_add_card, but we need early access */
> + card->dev.of_node = mmc_of_find_child_device(host, 0);
> memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
> }
>
> --
> 2.3.4
>
Kind regards
Uffe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mmc: Add support for marking hpi as broken through devicetree
[not found] ` <CAPDyKFp8bNYNgNW0u-JCN4ay0UM7JEdkdW48VRsCmu+JWpJgEA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-03-30 13:31 ` Hans de Goede
0 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2015-03-30 13:31 UTC (permalink / raw)
To: Ulf Hansson
Cc: Chris Ball, Maxime Ripard, linux-mmc,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree, linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
Hi,
On 30-03-15 11:14, Ulf Hansson wrote:
> On 29 March 2015 at 20:09, Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>> The eMMC on a tablet I've will stop working / communicating as soon as
>> the kernel executes:
>>
>> mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
>> EXT_CSD_HPI_MGMT, 1,
>> card->ext_csd.generic_cmd6_time);
>>
>> There seems to be no way to reliable identify eMMC-s which have a broken
>> hpi implementation, but at least for eMMC's which are soldered onto a board
>> we can work around this by specifying that hpi is broken in devicetree.
>
> Seems like a reasonable approach!
>
>>
>> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>> Documentation/devicetree/bindings/mmc/mmc-card.txt | 31 ++++++++++++++++++++++
>> drivers/mmc/core/mmc.c | 10 ++++++-
>> 2 files changed, 40 insertions(+), 1 deletion(-)
>> create mode 100644 Documentation/devicetree/bindings/mmc/mmc-card.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.txt b/Documentation/devicetree/bindings/mmc/mmc-card.txt
>> new file mode 100644
>> index 0000000..0cc67fb
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mmc/mmc-card.txt
>> @@ -0,0 +1,31 @@
>> +mmc-card / eMMC bindings
>> +------------------------
>> +
>> +This documents describes the devicetree bindings for a mmc-host controller
>> +child node describing a mmc-card / an eMMC, see "Use of Function subnodes"
>> +in mmc.txt
>> +
>> +Required properties:
>> +-compatible : Must be "mmc-card"
>> +-reg : Must be <0>
>
> Instead of using a compatible, why can we just use "reg = <0>"?
Yes we could do that, but using a compatible is sort of the standard way
to ensure that the contents of the node match the same binding rules as
the code parsing the node. e.g. i2c child nodes also have a compatible string,
as does the oob irq info for broadcom sdio wifi cards, which is the one
existing user of mmc host child nodes I'm aware of.
Regards,
Hans
>
>> +
>> +Optional properties:
>> +-broken-hpi : Use this to indicate that the mmc-card has a broken hpi
>> + implementation, and that hpi should not be used
>> +
>> +Example:
>> +
>> +&mmc2 {
>> + pinctrl-names = "default";
>> + pinctrl-0 = <&mmc2_pins_a>;
>> + vmmc-supply = <®_vcc3v3>;
>> + bus-width = <8>;
>> + non-removable;
>> + status = "okay";
>> +
>> + mmmcard: mmccard@0 {
>> + reg = <0>;
>> + compatible = "mmc-card";
>> + broken-hpi;
>> + };
>> +};
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index 1d41e85..8d18920 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -11,6 +11,7 @@
>> */
>>
>> #include <linux/err.h>
>> +#include <linux/of.h>
>> #include <linux/slab.h>
>> #include <linux/stat.h>
>> #include <linux/pm_runtime.h>
>> @@ -336,6 +337,8 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
>> {
>> int err = 0, idx;
>> unsigned int part_size;
>> + struct device_node *np = card->dev.of_node;
>> + bool broken_hpi = false;
>>
>> /* Version is coded in the CSD_STRUCTURE byte in the EXT_CSD register */
>> card->ext_csd.raw_ext_csd_structure = ext_csd[EXT_CSD_STRUCTURE];
>> @@ -349,6 +352,9 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
>> }
>> }
>>
>> + if (np && of_device_is_compatible(np, "mmc-card"))
>> + broken_hpi = of_property_read_bool(np, "broken-hpi");
>> +
>> /*
>> * The EXT_CSD format is meant to be forward compatible. As long
>> * as CSD_STRUCTURE does not change, all values for EXT_CSD_REV
>> @@ -494,7 +500,7 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
>> }
>>
>> /* check whether the eMMC card supports HPI */
>> - if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x1) {
>> + if (!broken_hpi && (ext_csd[EXT_CSD_HPI_FEATURES] & 0x1)) {
>> card->ext_csd.hpi = 1;
>> if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x2)
>> card->ext_csd.hpi_cmd = MMC_STOP_TRANSMISSION;
>> @@ -1251,6 +1257,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
>> card->ocr = ocr;
>> card->type = MMC_TYPE_MMC;
>> card->rca = 1;
>> + /* Also gets done by mmc_add_card, but we need early access */
>> + card->dev.of_node = mmc_of_find_child_device(host, 0);
>> memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
>> }
>>
>> --
>> 2.3.4
>>
>
> Kind regards
> Uffe
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ARM: dts: sun5i: Add broken-hpi property for Utoo-P66 eMMC
2015-03-29 18:09 ` [PATCH 2/2] ARM: dts: sun5i: Add broken-hpi property for Utoo-P66 eMMC Hans de Goede
@ 2015-03-31 14:47 ` Sergei Shtylyov
0 siblings, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2015-03-31 14:47 UTC (permalink / raw)
To: Hans de Goede, Chris Ball, Ulf Hansson
Cc: devicetree, linux-mmc, linux-sunxi, Maxime Ripard,
linux-arm-kernel
Hello.
On 3/29/2015 9:09 PM, Hans de Goede wrote:
> The eMMC on the A13 based Utoo-P66 tablet does not properly support hpi,
> and trying to enable it results in the eMMC not working, so add a child-node
> describing the eMMC, and set the broken-hpi property on it.
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> arch/arm/boot/dts/sun5i-a13-utoo-p66.dts | 6 ++++++
> 1 file changed, 6 insertions(+)
> diff --git a/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts b/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts
> index 6c9f5f3..5b572fa 100644
> --- a/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts
> +++ b/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts
> @@ -150,6 +150,12 @@
> bus-width = <8>;
> non-removable;
> status = "okay";
> +
> + mmmcard: mmccard@0 {
Not "mmcard:"? :-)
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-31 14:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-29 18:09 [PATCH 1/2] mmc: Add support for marking hpi as broken through devicetree Hans de Goede
[not found] ` <1427652575-12642-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-29 18:09 ` [PATCH 2/2] ARM: dts: sun5i: Add broken-hpi property for Utoo-P66 eMMC Hans de Goede
2015-03-31 14:47 ` Sergei Shtylyov
2015-03-30 9:14 ` [PATCH 1/2] mmc: Add support for marking hpi as broken through devicetree Ulf Hansson
[not found] ` <CAPDyKFp8bNYNgNW0u-JCN4ay0UM7JEdkdW48VRsCmu+JWpJgEA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-30 13:31 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).