mmc: kona/spear updates
Subsystems (4)
cover mmc: kona/spear updates
Chris,
Here's the latest patches for these fixups. They've been in my build system for a while, and allyesconfig/allmodconfig show no problems.
Probably want to get some acks/tested-bys from people before applying these.
drivers/mmc/host/sdhci-bcm-kona.c | 2 +- drivers/mmc/host/sdhci-spear.c | 191 +++++++++++++++++++---------------------------------------------------------------- include/linux/mmc/sdhci-spear.h | 8 ---- 3 files changed, 45 insertions(+), 156 deletions(-)
Signature · 2 lines
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly improving, and getting towards what was expected from it.
PATCH 1/6 mmc: sdhci-bcm-kona: fix build errors when built-in
sdhci_bcm_kona_remove' referenced in section .data' of drivers/built-in.o: defined in discarded section `.exit.text' of drivers/built-in.o
--- drivers/mmc/host/sdhci-bcm-kona.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-bcm-kona.c +1 -1
@@ -314,7 +314,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)return ret; } -static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev) +static int sdhci_bcm_kona_remove (struct platform_device *pdev) {return sdhci_pltfm_unregister (pdev); }
Signature · 1 line
1.8.3.1
Re: [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in
Quoted 26 lines · Russell King
sdhci_bcm_kona_remove' referenced in section.data' ofdrivers/built-in.o: defined in discarded section `.exit.text' ofdrivers/built-in.oFixes 058feb53666f ("mmc: sdhci-bcm-kona: make linker-section warning go away")Cc Markus Mayer <[email protected]>Cc Christian Daudt <[email protected]>Cc Matt Porter <[email protected]>Cc <[email protected]>Signed-off-by Russell King <[email protected]>--- drivers/mmc/host/sdhci-bcm-kona.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mmc/host/sdhci-bcm-kona.c +1
-2@@ -314,7 +314,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)return ret; } -static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev) +static int sdhci_bcm_kona_remove (struct platform_device *pdev) {return sdhci_pltfm_unregister (pdev); } --
Quoted 2 lines
1.8.3.1
Signature · 2 lines
Markus Mayer Broadcom Landing Team
Re: [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in
In reply to Russell KingQuoted 8 lines · Russell King
sdhci_bcm_kona_remove' referenced in section.data' ofdrivers/built-in.o: defined in discarded section `.exit.text' ofdrivers/built-in.oFixes 058feb53666f ("mmc: sdhci-bcm-kona: make linker-section warning go away")Cc Markus Mayer <[email protected]>Cc Christian Daudt <[email protected]>Cc Matt Porter <[email protected]>Cc <[email protected]>Signed-off-by Russell King <[email protected]>
Quoted 20 lines
--- drivers/mmc/host/sdhci-bcm-kona.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mmc/host/sdhci-bcm-kona.c +1
-1@@ -314,7 +314,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)return ret; } -static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev) +static int sdhci_bcm_kona_remove (struct platform_device *pdev) {return sdhci_pltfm_unregister (pdev); }Signature · 1 line
1.8.3.1
PATCH 2/6 mmc: sdhci-spear: fix error handling paths for DT
In reply to Russell King - ARM LinuxFix the error handling paths for DT and simplify using the devm_* API for clk_get().
--- drivers/mmc/host/sdhci-spear.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-spear.c +3 -6
@@ -131,7 +131,7 @@ static int sdhci_probe(struct platform_device *pdev) }/* clk enable */ - sdhci->clk =clk_get (&pdev->dev,NULL ); + sdhci->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (sdhci->clk)) { ret =PTR_ERR (sdhci->clk);dev_dbg (&pdev->dev,"Error getting clock\n" );
@@ -141,7 +141,7 @@ static int sdhci_probe(struct platform_device *pdev) ret =clk_prepare_enable (sdhci->clk);if (ret) {dev_dbg (&pdev->dev,"Error enabling clock\n" ); - goto put_clk; + goto err; } ret =clk_set_rate (sdhci->clk,50000000 );
@@ -153,7 +153,7 @@ static int sdhci_probe(struct platform_device *pdev) sdhci->data =sdhci_probe_config_dt (pdev);if (IS_ERR (sdhci->data)) {dev_err (&pdev->dev,"DT: Failed to get pdata\n" ); -return -ENODEV ; + goto disable_clk; } }else { sdhci->data =dev_get_platdata (&pdev->dev);
@@ -263,8 +263,6 @@ static int sdhci_probe(struct platform_device *pdev)sdhci_free_host (host); disable_clk:clk_disable_unprepare (sdhci->clk); -put_clk: -clk_put (sdhci->clk); err:dev_err (&pdev->dev,"spear-sdhci probe failed: %d\n" , ret);return ret;
@@ -284,7 +282,6 @@ static int sdhci_remove(struct platform_device *pdev)sdhci_remove_host (host, dead);sdhci_free_host (host);clk_disable_unprepare (sdhci->clk); -clk_put (sdhci->clk);return 0 ; }
Signature · 1 line
1.8.3.1
PATCH 3/6 mmc: sdhci-spear: fix platform_data usage
In reply to Russell King - ARM Linuxsdhci-spear is unsafe should a probe fail or defer, since it overwrites the platform_data with its own driver-private data. It's trivial to fix as SDHCI allows for driver-private data to be appended to its own structure - we just need to arrange the code to allow this.
--- drivers/mmc/host/sdhci-spear.c | 43 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 26 deletions(-)
drivers/mmc/host/sdhci-spear.c +17 -26
@@ -107,6 +107,7 @@ static int sdhci_probe(struct platform_device *pdev)struct sdhci_host *host;struct resource *iomem;struct spear_sdhci *sdhci; +struct device *dev;int ret; iomem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -123,25 +124,28 @@ static int sdhci_probe(struct platform_device *pdev) goto err; } - sdhci =devm_kzalloc (&pdev->dev,sizeof (*sdhci),GFP_KERNEL ); -if (!sdhci) { - ret = -ENOMEM ; + dev = pdev->dev.parent ? pdev->dev.parent : &pdev->dev; + host =sdhci_alloc_host (dev,sizeof (*sdhci)); +if (IS_ERR (host)) { + ret =PTR_ERR (host);dev_dbg (&pdev->dev,"cannot allocate memory for sdhci\n" ); goto err; } + sdhci =sdhci_priv (host); +/* clk enable */ sdhci->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (sdhci->clk)) { ret =PTR_ERR (sdhci->clk);dev_dbg (&pdev->dev,"Error getting clock\n" ); - goto err; + goto err_host; } ret =clk_prepare_enable (sdhci->clk);if (ret) {dev_dbg (&pdev->dev,"Error enabling clock\n" ); - goto err; + goto err_host; } ret =clk_set_rate (sdhci->clk,50000000 );
@@ -159,19 +163,6 @@ static int sdhci_probe(struct platform_device *pdev) sdhci->data =dev_get_platdata (&pdev->dev); } - pdev->dev.platform_data = sdhci; - -if (pdev->dev.parent) - host =sdhci_alloc_host (pdev->dev.parent,0 ); -else - host =sdhci_alloc_host (&pdev->dev,0 ); - -if (IS_ERR (host)) { - ret =PTR_ERR (host); -dev_dbg (&pdev->dev,"error allocating host\n" ); - goto disable_clk; - } - host->hw_name ="sdhci" ; host->ops = &sdhci_pltfm_ops; host->irq =platform_get_irq (pdev,0 );
@@ -182,13 +173,13 @@ static int sdhci_probe(struct platform_device *pdev)if (!host->ioaddr) { ret = -ENOMEM ;dev_dbg (&pdev->dev,"failed to remap registers\n" ); - goto free_host; + goto disable_clk; } ret =sdhci_add_host (host);if (ret) {dev_dbg (&pdev->dev,"error adding host\n" ); - goto free_host; + goto disable_clk; }platform_set_drvdata (pdev, host);
@@ -259,10 +250,10 @@ static int sdhci_probe(struct platform_device *pdev) set_drvdata:sdhci_remove_host (host,1 ); -free_host: -sdhci_free_host (host); disable_clk:clk_disable_unprepare (sdhci->clk); +err_host: +sdhci_free_host (host); err:dev_err (&pdev->dev,"spear-sdhci probe failed: %d\n" , ret);return ret;
@@ -271,7 +262,7 @@ static int sdhci_probe(struct platform_device *pdev)static int sdhci_remove (struct platform_device *pdev) {struct sdhci_host *host =platform_get_drvdata (pdev); -struct spear_sdhci *sdhci =dev_get_platdata (&pdev->dev); +struct spear_sdhci *sdhci =sdhci_priv (host);int dead =0 ;u32 scratch;
@@ -280,8 +271,8 @@ static int sdhci_remove(struct platform_device *pdev) dead =1 ;sdhci_remove_host (host, dead); -sdhci_free_host (host);clk_disable_unprepare (sdhci->clk); +sdhci_free_host (host);return 0 ; }
@@ -290,7 +281,7 @@ static int sdhci_remove(struct platform_device *pdev)static int sdhci_suspend (struct device *dev) {struct sdhci_host *host =dev_get_drvdata (dev); -struct spear_sdhci *sdhci =dev_get_platdata (dev); +struct spear_sdhci *sdhci =sdhci_priv (host);int ret; ret =sdhci_suspend_host (host);
@@ -303,7 +294,7 @@ static int sdhci_suspend(struct device *dev)static int sdhci_resume (struct device *dev) {struct sdhci_host *host =dev_get_drvdata (dev); -struct spear_sdhci *sdhci =dev_get_platdata (dev); +struct spear_sdhci *sdhci =sdhci_priv (host);int ret; ret =clk_enable (sdhci->clk);
Signature · 1 line
1.8.3.1
PATCH 4/6 mmc: sdhci-spear: simplify resource handling
In reply to Russell King - ARM LinuxUse devm_ioremap_resource() to simplify iomem resource handling in the probe path.
--- drivers/mmc/host/sdhci-spear.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-)
drivers/mmc/host/sdhci-spear.c +13 -27
@@ -110,20 +110,6 @@ static int sdhci_probe(struct platform_device *pdev)struct device *dev;int ret; - iomem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!iomem) { - ret = -ENOMEM ; -dev_dbg (&pdev->dev,"memory resource not defined\n" ); - goto err; - } - -if (!devm_request_mem_region (&pdev->dev, iomem->start, -resource_size (iomem),"spear-sdhci" )) { - ret = -EBUSY ; -dev_dbg (&pdev->dev,"cannot request region\n" ); - goto err; - } - dev = pdev->dev.parent ? pdev->dev.parent : &pdev->dev; host =sdhci_alloc_host (dev,sizeof (*sdhci));if (IS_ERR (host)) {
@@ -132,6 +118,19 @@ static int sdhci_probe(struct platform_device *pdev) goto err; } + iomem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + host->ioaddr =devm_ioremap_resource (&pdev->dev, iomem); +if (IS_ERR (host->ioaddr)) { + ret =PTR_ERR (host->ioaddr); +dev_dbg (&pdev->dev,"unable to map iomem: %d\n" , ret); + goto err_host; + } + + host->hw_name ="sdhci" ; + host->ops = &sdhci_pltfm_ops; + host->irq =platform_get_irq (pdev,0 ); + host->quirks =SDHCI_QUIRK_BROKEN_ADMA ; + sdhci =sdhci_priv (host);/* clk enable */
@@ -163,19 +162,6 @@ static int sdhci_probe(struct platform_device *pdev) sdhci->data =dev_get_platdata (&pdev->dev); } - host->hw_name ="sdhci" ; - host->ops = &sdhci_pltfm_ops; - host->irq =platform_get_irq (pdev,0 ); - host->quirks =SDHCI_QUIRK_BROKEN_ADMA ; - - host->ioaddr =devm_ioremap (&pdev->dev, iomem->start, -resource_size (iomem)); -if (!host->ioaddr) { - ret = -ENOMEM ; -dev_dbg (&pdev->dev,"failed to remap registers\n" ); - goto disable_clk; - } - ret =sdhci_add_host (host);if (ret) {dev_dbg (&pdev->dev,"error adding host\n" );
Signature · 1 line
1.8.3.1
PATCH 5/6 mmc: sdhci-spear: remove support for power gpio
In reply to Russell King - ARM LinuxNone of this code is currently used: there are no definitions of struct sdhci_plat_data in arch/arm, neither are there any DT properties which use card_power_gpio/power_active_high/power_always_enb. In any case, slot power control should be rigged up via vmmc and the regulator subsystem in the DT case.
--- drivers/mmc/host/sdhci-spear.c | 32 -------------------------------- include/linux/mmc/sdhci-spear.h | 8 -------- 2 files changed, 40 deletions(-)
drivers/mmc/host/sdhci-spear.c +0 -32
@@ -56,14 +56,6 @@ static irqreturn_t sdhci_gpio_irq(int irq, void *dev_id) gpio_irq_type = val ?IRQF_TRIGGER_LOW :IRQF_TRIGGER_HIGH ;irq_set_irq_type (irq, gpio_irq_type); -if (sdhci->data->card_power_gpio >=0 ) { -if (!sdhci->data->power_always_enb) { -/* if card inserted, give power, otherwise remove it */ - val = sdhci->data->power_active_high ? !val : val ; -gpio_set_value (sdhci->data->card_power_gpio, val); - } - } -/* inform sdhci driver about card insertion/removal */ tasklet_schedule (&host->card_tasklet);
@@ -181,30 +173,6 @@ static int sdhci_probe(struct platform_device *pdev)if (!sdhci->data)return 0 ; -if (sdhci->data->card_power_gpio >=0 ) { -int val =0 ; - - ret =devm_gpio_request (&pdev->dev, - sdhci->data->card_power_gpio,"sdhci" ); -if (ret <0 ) { -dev_dbg (&pdev->dev,"gpio request fail: %d\n" , - sdhci->data->card_power_gpio); - goto set_drvdata; - } - -if (sdhci->data->power_always_enb) - val = sdhci->data->power_active_high; -else - val = !sdhci->data->power_active_high; - - ret =gpio_direction_output (sdhci->data->card_power_gpio, val); -if (ret) { -dev_dbg (&pdev->dev,"gpio set direction fail: %d\n" , - sdhci->data->card_power_gpio); - goto set_drvdata; - } - } -if (sdhci->data->card_int_gpio >=0 ) { ret =devm_gpio_request (&pdev->dev, sdhci->data->card_int_gpio,"sdhci" );
include/linux/mmc/sdhci-spear.h +0 -8
@@ -18,17 +18,9 @@/* * struct sdhci_plat_data: spear sdhci platform data structure * -* @card_power_gpio: gpio pin for enabling/disabling power to sdhci socket -* @power_active_high: if set, enable power to sdhci socket by setting -* card_power_gpio -* @power_always_enb: If set, then enable power on probe, otherwise enable only -* on card insertion and disable on card removal. * card_int_gpio: gpio pin used for card detection */ struct sdhci_plat_data { -int card_power_gpio; -int power_active_high; -int power_always_enb;int card_int_gpio; };
Signature · 1 line
1.8.3.1
PATCH 6/6 mmc: sdhci-spear: use generic card detection gpio support
In reply to Russell King - ARM Linuxsdhci has support for using GPIOs for card detection. If we have a GPIO specified, we can use that directly, without needing our own interrupt handler.
--- drivers/mmc/host/sdhci-spear.c | 79 +++++++++--------------------------------- 1 file changed, 17 insertions(+), 62 deletions(-)
drivers/mmc/host/sdhci-spear.c +17 -62
@@ -27,6 +27,7 @@#include <linux/slab.h> #include <linux/mmc/host.h> #include <linux/mmc/sdhci-spear.h> +#include <linux/mmc/slot-gpio.h> #include <linux/io.h> #include "sdhci.h"
@@ -40,28 +41,6 @@ static const struct sdhci_ops sdhci_pltfm_ops = {/* Nothing to do for now. */ }; -/* gpio card detection interrupt handler */ -static irqreturn_t sdhci_gpio_irq (int irq,void *dev_id) -{ -struct platform_device *pdev = dev_id; -struct sdhci_host *host =platform_get_drvdata (pdev); -struct spear_sdhci *sdhci =dev_get_platdata (&pdev->dev); -unsigned long gpio_irq_type; -int val; - - val =gpio_get_value (sdhci->data->card_int_gpio); - -/* val == 1 -> card removed, val == 0 -> card inserted */ -/* if card removed - set irq for low level, else vice versa */ - gpio_irq_type = val ?IRQF_TRIGGER_LOW :IRQF_TRIGGER_HIGH ; -irq_set_irq_type (irq, gpio_irq_type); - -/* inform sdhci driver about card insertion/removal */ -tasklet_schedule (&host->card_tasklet); - -return IRQ_HANDLED ; -} -#ifdef CONFIG_OF static struct sdhci_plat_data *sdhci_probe_config_dt (struct platform_device *pdev) {
@@ -154,6 +133,22 @@ static int sdhci_probe(struct platform_device *pdev) sdhci->data =dev_get_platdata (&pdev->dev); } +/* +* It is optional to use GPIOs for sdhci card detection. If +* sdhci->data is NULL, then use original sdhci lines otherwise +* GPIO lines. We use the built-in GPIO support for this. +*/ +if (sdhci->data && sdhci->data->card_int_gpio >=0 ) { + ret =mmc_gpio_request_cd (host->mmc, + sdhci->data->card_int_gpio,0 ); +if (ret <0 ) { +dev_dbg (&pdev->dev, +"failed to request card-detect gpio%d\n" , + sdhci->data->card_int_gpio); + goto disable_clk; + } + } + ret =sdhci_add_host (host);if (ret) {dev_dbg (&pdev->dev,"error adding host\n" );
@@ -162,48 +157,8 @@ static int sdhci_probe(struct platform_device *pdev)platform_set_drvdata (pdev, host); -/* -* It is optional to use GPIOs for sdhci Power control & sdhci card -* interrupt detection. If sdhci->data is NULL, then use original sdhci -* lines otherwise GPIO lines. -* If GPIO is selected for power control, then power should be disabled -* after card removal and should be enabled when card insertion -* interrupt occurs -*/ -if (!sdhci->data) -return 0 ; - -if (sdhci->data->card_int_gpio >=0 ) { - ret =devm_gpio_request (&pdev->dev, sdhci->data->card_int_gpio, -"sdhci" ); -if (ret <0 ) { -dev_dbg (&pdev->dev,"gpio request fail: %d\n" , - sdhci->data->card_int_gpio); - goto set_drvdata; - } - - ret =gpio_direction_input (sdhci->data->card_int_gpio); -if (ret) { -dev_dbg (&pdev->dev,"gpio set direction fail: %d\n" , - sdhci->data->card_int_gpio); - goto set_drvdata; - } - ret =devm_request_irq (&pdev->dev, -gpio_to_irq (sdhci->data->card_int_gpio), - sdhci_gpio_irq,IRQF_TRIGGER_LOW , -mmc_hostname (host->mmc), pdev); -if (ret) { -dev_dbg (&pdev->dev,"gpio request irq fail: %d\n" , - sdhci->data->card_int_gpio); - goto set_drvdata; - } - - } -return 0 ; -set_drvdata: -sdhci_remove_host (host,1 ); disable_clk:clk_disable_unprepare (sdhci->clk); err_host:
Signature · 1 line
1.8.3.1
Hi Russell,
Quoted 5 lines · Russell King - ARM Linux
Here's the latest patches for these fixups. They've been in my build system for a while, and allyesconfig/allmodconfig show no problems.
Probably want to get some acks/tested-bys from people before applying these.
Thanks, all pushed to mmc-next.
- Chris.
Signature · 1 line
Chris Ball <[email protected]> <http://printf.net/>