* mmc: mxs: Use mmc_of_parse
@ 2013-12-05 13:34 Sascha Hauer
2013-12-05 13:34 ` [PATCH 1/6] mmc: Do not call get_cd for non removable cards Sascha Hauer
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-12-05 13:34 UTC (permalink / raw)
To: linux-arm-kernel
We have a generic mmc_of_parse function. Use it in the mxs-mmc driver
to make the code simpler and to parse some new devicetree propeties.
Sascha
----------------------------------------------------------------
Sascha Hauer (6):
mmc: Do not call get_cd for non removable cards
mmc: mxs: use standard flag for non-removable status
mmc: mxs: use standard flag for broken card detection
mmc: mxs: use standard flag for cd inverted
mmc: mxs: use mmc_gpio_get_ro for detecting read-only status
mmc: mxs: use mmc_of_parse to parse devicetree properties
drivers/mmc/core/core.c | 3 ++-
drivers/mmc/host/mxs-mmc.c | 60 ++++++++++++++--------------------------------
2 files changed, 20 insertions(+), 43 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/6] mmc: Do not call get_cd for non removable cards
2013-12-05 13:34 mmc: mxs: Use mmc_of_parse Sascha Hauer
@ 2013-12-05 13:34 ` Sascha Hauer
2013-12-06 8:31 ` Ulf Hansson
2013-12-05 13:34 ` [PATCH 2/6] mmc: mxs: use standard flag for non-removable status Sascha Hauer
` (5 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2013-12-05 13:34 UTC (permalink / raw)
To: linux-arm-kernel
Non removable cards are always present, so do not call get_cd for them.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mmc/core/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 57a2b40..098374b 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2460,7 +2460,8 @@ void mmc_rescan(struct work_struct *work)
*/
mmc_bus_put(host);
- if (host->ops->get_cd && host->ops->get_cd(host) == 0) {
+ if (!(host->caps & MMC_CAP_NONREMOVABLE) && host->ops->get_cd &&
+ host->ops->get_cd(host) == 0) {
mmc_claim_host(host);
mmc_power_off(host);
mmc_release_host(host);
--
1.8.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/6] mmc: mxs: use standard flag for non-removable status
2013-12-05 13:34 mmc: mxs: Use mmc_of_parse Sascha Hauer
2013-12-05 13:34 ` [PATCH 1/6] mmc: Do not call get_cd for non removable cards Sascha Hauer
@ 2013-12-05 13:34 ` Sascha Hauer
2013-12-05 13:34 ` [PATCH 3/6] mmc: mxs: use standard flag for broken card detection Sascha Hauer
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-12-05 13:34 UTC (permalink / raw)
To: linux-arm-kernel
The standard caps already have a MMC_CAP_NONREMOVABLE flag. Use it
rather than a custom non_removable flag.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mmc/host/mxs-mmc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 50fc9df..374fca7 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -73,7 +73,6 @@ struct mxs_mmc_host {
bool wp_inverted;
bool cd_inverted;
bool broken_cd;
- bool non_removable;
};
static int mxs_mmc_get_ro(struct mmc_host *mmc)
@@ -97,7 +96,7 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
struct mxs_mmc_host *host = mmc_priv(mmc);
struct mxs_ssp *ssp = &host->ssp;
- return host->non_removable || host->broken_cd ||
+ return host->broken_cd ||
!(readl(ssp->base + HW_SSP_STATUS(ssp)) &
BM_SSP_STATUS_CARD_DETECT) ^ host->cd_inverted;
}
@@ -654,8 +653,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
else if (bus_width == 8)
mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
host->broken_cd = of_property_read_bool(np, "broken-cd");
- host->non_removable = of_property_read_bool(np, "non-removable");
- if (host->non_removable)
+ if (of_property_read_bool(np, "non-removable"))
mmc->caps |= MMC_CAP_NONREMOVABLE;
host->wp_gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags);
if (flags & OF_GPIO_ACTIVE_LOW)
--
1.8.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/6] mmc: mxs: use standard flag for broken card detection
2013-12-05 13:34 mmc: mxs: Use mmc_of_parse Sascha Hauer
2013-12-05 13:34 ` [PATCH 1/6] mmc: Do not call get_cd for non removable cards Sascha Hauer
2013-12-05 13:34 ` [PATCH 2/6] mmc: mxs: use standard flag for non-removable status Sascha Hauer
@ 2013-12-05 13:34 ` Sascha Hauer
2013-12-05 13:34 ` [PATCH 4/6] mmc: mxs: use standard flag for cd inverted Sascha Hauer
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-12-05 13:34 UTC (permalink / raw)
To: linux-arm-kernel
Use the standard MMC_CAP_NEEDS_POLL flag rather than a custom broken_cd
flag. The original code used to just return true in the card detection
function for broken card detection. The MMC_CAP_NEEDS_POLL works different,
but was introduced for the same purpose, so assume the code works correct
now.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mmc/host/mxs-mmc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 374fca7..02210ce 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -72,7 +72,6 @@ struct mxs_mmc_host {
int wp_gpio;
bool wp_inverted;
bool cd_inverted;
- bool broken_cd;
};
static int mxs_mmc_get_ro(struct mmc_host *mmc)
@@ -96,8 +95,7 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
struct mxs_mmc_host *host = mmc_priv(mmc);
struct mxs_ssp *ssp = &host->ssp;
- return host->broken_cd ||
- !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
+ return !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
BM_SSP_STATUS_CARD_DETECT) ^ host->cd_inverted;
}
@@ -652,7 +650,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
mmc->caps |= MMC_CAP_4_BIT_DATA;
else if (bus_width == 8)
mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
- host->broken_cd = of_property_read_bool(np, "broken-cd");
+ if (of_property_read_bool(np, "broken-cd"))
+ mmc->caps |= MMC_CAP_NEEDS_POLL;
if (of_property_read_bool(np, "non-removable"))
mmc->caps |= MMC_CAP_NONREMOVABLE;
host->wp_gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags);
--
1.8.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/6] mmc: mxs: use standard flag for cd inverted
2013-12-05 13:34 mmc: mxs: Use mmc_of_parse Sascha Hauer
` (2 preceding siblings ...)
2013-12-05 13:34 ` [PATCH 3/6] mmc: mxs: use standard flag for broken card detection Sascha Hauer
@ 2013-12-05 13:34 ` Sascha Hauer
2013-12-05 13:34 ` [PATCH 5/6] mmc: mxs: use mmc_gpio_get_ro for detecting read-only status Sascha Hauer
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-12-05 13:34 UTC (permalink / raw)
To: linux-arm-kernel
We have a MMC_CAP2_CD_ACTIVE_HIGH flag, so use it rather than a custom
driver specific flag.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mmc/host/mxs-mmc.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 02210ce..3dd2f4c 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -71,7 +71,6 @@ struct mxs_mmc_host {
int sdio_irq_en;
int wp_gpio;
bool wp_inverted;
- bool cd_inverted;
};
static int mxs_mmc_get_ro(struct mmc_host *mmc)
@@ -94,9 +93,15 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
struct mxs_ssp *ssp = &host->ssp;
+ int present;
- return !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
- BM_SSP_STATUS_CARD_DETECT) ^ host->cd_inverted;
+ present = !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
+ BM_SSP_STATUS_CARD_DETECT);
+
+ if (mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)
+ present = !present;
+
+ return present;
}
static int mxs_mmc_reset(struct mxs_mmc_host *host)
@@ -658,7 +663,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
if (flags & OF_GPIO_ACTIVE_LOW)
host->wp_inverted = 1;
- host->cd_inverted = of_property_read_bool(np, "cd-inverted");
+ if (of_property_read_bool(np, "cd-inverted"))
+ mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
mmc->f_min = 400000;
mmc->f_max = 288000000;
--
1.8.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/6] mmc: mxs: use mmc_gpio_get_ro for detecting read-only status
2013-12-05 13:34 mmc: mxs: Use mmc_of_parse Sascha Hauer
` (3 preceding siblings ...)
2013-12-05 13:34 ` [PATCH 4/6] mmc: mxs: use standard flag for cd inverted Sascha Hauer
@ 2013-12-05 13:34 ` Sascha Hauer
2013-12-05 13:34 ` [PATCH 6/6] mmc: mxs: use mmc_of_parse to parse devicetree properties Sascha Hauer
2013-12-12 1:39 ` mmc: mxs: Use mmc_of_parse Chris Ball
6 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-12-05 13:34 UTC (permalink / raw)
To: linux-arm-kernel
This also fixes that the read-only gpio was used without being
requested.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mmc/host/mxs-mmc.c | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 3dd2f4c..13016e2 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -38,6 +38,7 @@
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sdio.h>
+#include <linux/mmc/slot-gpio.h>
#include <linux/gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/module.h>
@@ -69,26 +70,8 @@ struct mxs_mmc_host {
unsigned char bus_width;
spinlock_t lock;
int sdio_irq_en;
- int wp_gpio;
- bool wp_inverted;
};
-static int mxs_mmc_get_ro(struct mmc_host *mmc)
-{
- struct mxs_mmc_host *host = mmc_priv(mmc);
- int ret;
-
- if (!gpio_is_valid(host->wp_gpio))
- return -EINVAL;
-
- ret = gpio_get_value(host->wp_gpio);
-
- if (host->wp_inverted)
- ret = !ret;
-
- return ret;
-}
-
static int mxs_mmc_get_cd(struct mmc_host *mmc)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
@@ -551,7 +534,7 @@ static void mxs_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
static const struct mmc_host_ops mxs_mmc_ops = {
.request = mxs_mmc_request,
- .get_ro = mxs_mmc_get_ro,
+ .get_ro = mmc_gpio_get_ro,
.get_cd = mxs_mmc_get_cd,
.set_ios = mxs_mmc_set_ios,
.enable_sdio_irq = mxs_mmc_enable_sdio_irq,
@@ -585,7 +568,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
struct mxs_mmc_host *host;
struct mmc_host *mmc;
struct resource *iores;
- int ret = 0, irq_err;
+ int ret = 0, irq_err, gpio;
struct regulator *reg_vmmc;
enum of_gpio_flags flags;
struct mxs_ssp *ssp;
@@ -659,9 +642,14 @@ static int mxs_mmc_probe(struct platform_device *pdev)
mmc->caps |= MMC_CAP_NEEDS_POLL;
if (of_property_read_bool(np, "non-removable"))
mmc->caps |= MMC_CAP_NONREMOVABLE;
- host->wp_gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags);
- if (flags & OF_GPIO_ACTIVE_LOW)
- host->wp_inverted = 1;
+ gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags);
+ if (gpio_is_valid(gpio)) {
+ ret = mmc_gpio_request_ro(mmc, gpio);
+ if (ret)
+ goto out_clk_disable;
+ if (!(flags & OF_GPIO_ACTIVE_LOW))
+ mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
+ }
if (of_property_read_bool(np, "cd-inverted"))
mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
--
1.8.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/6] mmc: mxs: use mmc_of_parse to parse devicetree properties
2013-12-05 13:34 mmc: mxs: Use mmc_of_parse Sascha Hauer
` (4 preceding siblings ...)
2013-12-05 13:34 ` [PATCH 5/6] mmc: mxs: use mmc_gpio_get_ro for detecting read-only status Sascha Hauer
@ 2013-12-05 13:34 ` Sascha Hauer
2013-12-12 1:39 ` mmc: mxs: Use mmc_of_parse Chris Ball
6 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-12-05 13:34 UTC (permalink / raw)
To: linux-arm-kernel
Use generic helper function. This also adds support for the cd-gpios and
max-frequency devicetree properties.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mmc/host/mxs-mmc.c | 37 +++++++++++--------------------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 13016e2..073e871 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -76,7 +76,11 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
struct mxs_ssp *ssp = &host->ssp;
- int present;
+ int present, ret;
+
+ ret = mmc_gpio_get_cd(mmc);
+ if (ret >= 0)
+ return ret;
present = !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
BM_SSP_STATUS_CARD_DETECT);
@@ -564,15 +568,12 @@ static int mxs_mmc_probe(struct platform_device *pdev)
{
const struct of_device_id *of_id =
of_match_device(mxs_mmc_dt_ids, &pdev->dev);
- struct device_node *np = pdev->dev.of_node;
struct mxs_mmc_host *host;
struct mmc_host *mmc;
struct resource *iores;
- int ret = 0, irq_err, gpio;
+ int ret = 0, irq_err;
struct regulator *reg_vmmc;
- enum of_gpio_flags flags;
struct mxs_ssp *ssp;
- u32 bus_width = 0;
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq_err = platform_get_irq(pdev, 0);
@@ -633,29 +634,13 @@ static int mxs_mmc_probe(struct platform_device *pdev)
mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
- of_property_read_u32(np, "bus-width", &bus_width);
- if (bus_width == 4)
- mmc->caps |= MMC_CAP_4_BIT_DATA;
- else if (bus_width == 8)
- mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
- if (of_property_read_bool(np, "broken-cd"))
- mmc->caps |= MMC_CAP_NEEDS_POLL;
- if (of_property_read_bool(np, "non-removable"))
- mmc->caps |= MMC_CAP_NONREMOVABLE;
- gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags);
- if (gpio_is_valid(gpio)) {
- ret = mmc_gpio_request_ro(mmc, gpio);
- if (ret)
- goto out_clk_disable;
- if (!(flags & OF_GPIO_ACTIVE_LOW))
- mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
- }
-
- if (of_property_read_bool(np, "cd-inverted"))
- mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
-
mmc->f_min = 400000;
mmc->f_max = 288000000;
+
+ ret = mmc_of_parse(mmc);
+ if (ret)
+ goto out_clk_disable;
+
mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
mmc->max_segs = 52;
--
1.8.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 1/6] mmc: Do not call get_cd for non removable cards
2013-12-05 13:34 ` [PATCH 1/6] mmc: Do not call get_cd for non removable cards Sascha Hauer
@ 2013-12-06 8:31 ` Ulf Hansson
0 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2013-12-06 8:31 UTC (permalink / raw)
To: linux-arm-kernel
On 5 December 2013 14:34, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> Non removable cards are always present, so do not call get_cd for them.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> drivers/mmc/core/core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 57a2b40..098374b 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2460,7 +2460,8 @@ void mmc_rescan(struct work_struct *work)
> */
> mmc_bus_put(host);
>
> - if (host->ops->get_cd && host->ops->get_cd(host) == 0) {
> + if (!(host->caps & MMC_CAP_NONREMOVABLE) && host->ops->get_cd &&
> + host->ops->get_cd(host) == 0) {
> mmc_claim_host(host);
> mmc_power_off(host);
> mmc_release_host(host);
> --
> 1.8.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* mmc: mxs: Use mmc_of_parse
2013-12-05 13:34 mmc: mxs: Use mmc_of_parse Sascha Hauer
` (5 preceding siblings ...)
2013-12-05 13:34 ` [PATCH 6/6] mmc: mxs: use mmc_of_parse to parse devicetree properties Sascha Hauer
@ 2013-12-12 1:39 ` Chris Ball
6 siblings, 0 replies; 9+ messages in thread
From: Chris Ball @ 2013-12-12 1:39 UTC (permalink / raw)
To: linux-arm-kernel
Hi Sascha,
On Thu, Dec 05 2013, Sascha Hauer wrote:
> We have a generic mmc_of_parse function. Use it in the mxs-mmc driver
> to make the code simpler and to parse some new devicetree propeties.
Great, thanks for doing this; all six patches pushed to mmc-next for 3.14.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-12-12 1:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05 13:34 mmc: mxs: Use mmc_of_parse Sascha Hauer
2013-12-05 13:34 ` [PATCH 1/6] mmc: Do not call get_cd for non removable cards Sascha Hauer
2013-12-06 8:31 ` Ulf Hansson
2013-12-05 13:34 ` [PATCH 2/6] mmc: mxs: use standard flag for non-removable status Sascha Hauer
2013-12-05 13:34 ` [PATCH 3/6] mmc: mxs: use standard flag for broken card detection Sascha Hauer
2013-12-05 13:34 ` [PATCH 4/6] mmc: mxs: use standard flag for cd inverted Sascha Hauer
2013-12-05 13:34 ` [PATCH 5/6] mmc: mxs: use mmc_gpio_get_ro for detecting read-only status Sascha Hauer
2013-12-05 13:34 ` [PATCH 6/6] mmc: mxs: use mmc_of_parse to parse devicetree properties Sascha Hauer
2013-12-12 1:39 ` mmc: mxs: Use mmc_of_parse Chris Ball
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).