diff mbox

[v3,10/14] mmc: jz4740: Let the pinctrl driver configure the pins

Message ID 20170125185207.23902-11-paul@crapouillou.net (mailing list archive)
State New, archived
Headers show

Commit Message

Paul Cercueil Jan. 25, 2017, 6:52 p.m. UTC
Now that the JZ4740 and similar SoCs have a pinctrl driver, we rely on
the pins being properly configured before the driver probes.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/jz4740_mmc.c | 45 +++++--------------------------------------
 1 file changed, 5 insertions(+), 40 deletions(-)

v2: Set pin sleep/default state in suspend/resume callbacks
v3: No changes

Comments

kernel test robot Jan. 26, 2017, 6:11 a.m. UTC | #1
Hi Paul,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.10-rc5 next-20170125]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Paul-Cercueil/Ingenic-JZ4740-JZ4780-pinctrl-driver/20170126-030028
config: mips-qi_lb60_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   drivers/mmc/host/jz4740_mmc.c: In function 'jz4740_mmc_set_ios':
>> drivers/mmc/host/jz4740_mmc.c:864:7: error: implicit declaration of function 'gpio_is_valid' [-Werror=implicit-function-declaration]
      if (gpio_is_valid(host->pdata->gpio_power))
          ^~~~~~~~~~~~~
>> drivers/mmc/host/jz4740_mmc.c:865:4: error: implicit declaration of function 'gpio_set_value' [-Werror=implicit-function-declaration]
       gpio_set_value(host->pdata->gpio_power,
       ^~~~~~~~~~~~~~
   drivers/mmc/host/jz4740_mmc.c: In function 'jz4740_mmc_request_gpio':
>> drivers/mmc/host/jz4740_mmc.c:916:8: error: implicit declaration of function 'gpio_request' [-Werror=implicit-function-declaration]
     ret = gpio_request(gpio, name);
           ^~~~~~~~~~~~
>> drivers/mmc/host/jz4740_mmc.c:923:3: error: implicit declaration of function 'gpio_direction_output' [-Werror=implicit-function-declaration]
      gpio_direction_output(gpio, value);
      ^~~~~~~~~~~~~~~~~~~~~
>> drivers/mmc/host/jz4740_mmc.c:925:3: error: implicit declaration of function 'gpio_direction_input' [-Werror=implicit-function-declaration]
      gpio_direction_input(gpio);
      ^~~~~~~~~~~~~~~~~~~~
   drivers/mmc/host/jz4740_mmc.c: In function 'jz4740_mmc_free_gpios':
>> drivers/mmc/host/jz4740_mmc.c:968:3: error: implicit declaration of function 'gpio_free' [-Werror=implicit-function-declaration]
      gpio_free(pdata->gpio_power);
      ^~~~~~~~~
   cc1: some warnings being treated as errors

vim +/gpio_is_valid +864 drivers/mmc/host/jz4740_mmc.c

61bfbdb8 Lars-Peter Clausen 2010-07-15  858  	if (ios->clock)
61bfbdb8 Lars-Peter Clausen 2010-07-15  859  		jz4740_mmc_set_clock_rate(host, ios->clock);
61bfbdb8 Lars-Peter Clausen 2010-07-15  860  
61bfbdb8 Lars-Peter Clausen 2010-07-15  861  	switch (ios->power_mode) {
61bfbdb8 Lars-Peter Clausen 2010-07-15  862  	case MMC_POWER_UP:
61bfbdb8 Lars-Peter Clausen 2010-07-15  863  		jz4740_mmc_reset(host);
61bfbdb8 Lars-Peter Clausen 2010-07-15 @864  		if (gpio_is_valid(host->pdata->gpio_power))
61bfbdb8 Lars-Peter Clausen 2010-07-15 @865  			gpio_set_value(host->pdata->gpio_power,
61bfbdb8 Lars-Peter Clausen 2010-07-15  866  					!host->pdata->power_active_low);
61bfbdb8 Lars-Peter Clausen 2010-07-15  867  		host->cmdat |= JZ_MMC_CMDAT_INIT;
fca9661c Lars-Peter Clausen 2013-05-12  868  		clk_prepare_enable(host->clk);
61bfbdb8 Lars-Peter Clausen 2010-07-15  869  		break;
61bfbdb8 Lars-Peter Clausen 2010-07-15  870  	case MMC_POWER_ON:
61bfbdb8 Lars-Peter Clausen 2010-07-15  871  		break;
61bfbdb8 Lars-Peter Clausen 2010-07-15  872  	default:
61bfbdb8 Lars-Peter Clausen 2010-07-15  873  		if (gpio_is_valid(host->pdata->gpio_power))
61bfbdb8 Lars-Peter Clausen 2010-07-15  874  			gpio_set_value(host->pdata->gpio_power,
61bfbdb8 Lars-Peter Clausen 2010-07-15  875  					host->pdata->power_active_low);
fca9661c Lars-Peter Clausen 2013-05-12  876  		clk_disable_unprepare(host->clk);
61bfbdb8 Lars-Peter Clausen 2010-07-15  877  		break;
61bfbdb8 Lars-Peter Clausen 2010-07-15  878  	}
61bfbdb8 Lars-Peter Clausen 2010-07-15  879  
61bfbdb8 Lars-Peter Clausen 2010-07-15  880  	switch (ios->bus_width) {
61bfbdb8 Lars-Peter Clausen 2010-07-15  881  	case MMC_BUS_WIDTH_1:
61bfbdb8 Lars-Peter Clausen 2010-07-15  882  		host->cmdat &= ~JZ_MMC_CMDAT_BUS_WIDTH_4BIT;
61bfbdb8 Lars-Peter Clausen 2010-07-15  883  		break;
61bfbdb8 Lars-Peter Clausen 2010-07-15  884  	case MMC_BUS_WIDTH_4:
61bfbdb8 Lars-Peter Clausen 2010-07-15  885  		host->cmdat |= JZ_MMC_CMDAT_BUS_WIDTH_4BIT;
61bfbdb8 Lars-Peter Clausen 2010-07-15  886  		break;
61bfbdb8 Lars-Peter Clausen 2010-07-15  887  	default:
61bfbdb8 Lars-Peter Clausen 2010-07-15  888  		break;
61bfbdb8 Lars-Peter Clausen 2010-07-15  889  	}
61bfbdb8 Lars-Peter Clausen 2010-07-15  890  }
61bfbdb8 Lars-Peter Clausen 2010-07-15  891  
61bfbdb8 Lars-Peter Clausen 2010-07-15  892  static void jz4740_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
61bfbdb8 Lars-Peter Clausen 2010-07-15  893  {
61bfbdb8 Lars-Peter Clausen 2010-07-15  894  	struct jz4740_mmc_host *host = mmc_priv(mmc);
61bfbdb8 Lars-Peter Clausen 2010-07-15  895  	jz4740_mmc_set_irq_enabled(host, JZ_MMC_IRQ_SDIO, enable);
61bfbdb8 Lars-Peter Clausen 2010-07-15  896  }
61bfbdb8 Lars-Peter Clausen 2010-07-15  897  
61bfbdb8 Lars-Peter Clausen 2010-07-15  898  static const struct mmc_host_ops jz4740_mmc_ops = {
61bfbdb8 Lars-Peter Clausen 2010-07-15  899  	.request	= jz4740_mmc_request,
bb2f4592 Apelete Seketeli   2014-07-21  900  	.pre_req	= jz4740_mmc_pre_request,
bb2f4592 Apelete Seketeli   2014-07-21  901  	.post_req	= jz4740_mmc_post_request,
61bfbdb8 Lars-Peter Clausen 2010-07-15  902  	.set_ios	= jz4740_mmc_set_ios,
58e300af Lars-Peter Clausen 2013-06-09  903  	.get_ro		= mmc_gpio_get_ro,
58e300af Lars-Peter Clausen 2013-06-09  904  	.get_cd		= mmc_gpio_get_cd,
61bfbdb8 Lars-Peter Clausen 2010-07-15  905  	.enable_sdio_irq = jz4740_mmc_enable_sdio_irq,
61bfbdb8 Lars-Peter Clausen 2010-07-15  906  };
61bfbdb8 Lars-Peter Clausen 2010-07-15  907  
c3be1efd Bill Pemberton     2012-11-19  908  static int jz4740_mmc_request_gpio(struct device *dev, int gpio,
61bfbdb8 Lars-Peter Clausen 2010-07-15  909  	const char *name, bool output, int value)
61bfbdb8 Lars-Peter Clausen 2010-07-15  910  {
61bfbdb8 Lars-Peter Clausen 2010-07-15  911  	int ret;
61bfbdb8 Lars-Peter Clausen 2010-07-15  912  
61bfbdb8 Lars-Peter Clausen 2010-07-15  913  	if (!gpio_is_valid(gpio))
61bfbdb8 Lars-Peter Clausen 2010-07-15  914  		return 0;
61bfbdb8 Lars-Peter Clausen 2010-07-15  915  
61bfbdb8 Lars-Peter Clausen 2010-07-15 @916  	ret = gpio_request(gpio, name);
61bfbdb8 Lars-Peter Clausen 2010-07-15  917  	if (ret) {
61bfbdb8 Lars-Peter Clausen 2010-07-15  918  		dev_err(dev, "Failed to request %s gpio: %d\n", name, ret);
61bfbdb8 Lars-Peter Clausen 2010-07-15  919  		return ret;
61bfbdb8 Lars-Peter Clausen 2010-07-15  920  	}
61bfbdb8 Lars-Peter Clausen 2010-07-15  921  
61bfbdb8 Lars-Peter Clausen 2010-07-15  922  	if (output)
61bfbdb8 Lars-Peter Clausen 2010-07-15 @923  		gpio_direction_output(gpio, value);
61bfbdb8 Lars-Peter Clausen 2010-07-15  924  	else
61bfbdb8 Lars-Peter Clausen 2010-07-15 @925  		gpio_direction_input(gpio);
61bfbdb8 Lars-Peter Clausen 2010-07-15  926  
61bfbdb8 Lars-Peter Clausen 2010-07-15  927  	return 0;
61bfbdb8 Lars-Peter Clausen 2010-07-15  928  }
61bfbdb8 Lars-Peter Clausen 2010-07-15  929  
58e300af Lars-Peter Clausen 2013-06-09  930  static int jz4740_mmc_request_gpios(struct mmc_host *mmc,
58e300af Lars-Peter Clausen 2013-06-09  931  	struct platform_device *pdev)
61bfbdb8 Lars-Peter Clausen 2010-07-15  932  {
61bfbdb8 Lars-Peter Clausen 2010-07-15  933  	struct jz4740_mmc_platform_data *pdata = pdev->dev.platform_data;
58e300af Lars-Peter Clausen 2013-06-09  934  	int ret = 0;
61bfbdb8 Lars-Peter Clausen 2010-07-15  935  
61bfbdb8 Lars-Peter Clausen 2010-07-15  936  	if (!pdata)
61bfbdb8 Lars-Peter Clausen 2010-07-15  937  		return 0;
61bfbdb8 Lars-Peter Clausen 2010-07-15  938  
58e300af Lars-Peter Clausen 2013-06-09  939  	if (!pdata->card_detect_active_low)
58e300af Lars-Peter Clausen 2013-06-09  940  		mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
58e300af Lars-Peter Clausen 2013-06-09  941  	if (!pdata->read_only_active_low)
58e300af Lars-Peter Clausen 2013-06-09  942  		mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
61bfbdb8 Lars-Peter Clausen 2010-07-15  943  
58e300af Lars-Peter Clausen 2013-06-09  944  	if (gpio_is_valid(pdata->gpio_card_detect)) {
214fc309 Laurent Pinchart   2013-08-08  945  		ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect, 0);
61bfbdb8 Lars-Peter Clausen 2010-07-15  946  		if (ret)
61bfbdb8 Lars-Peter Clausen 2010-07-15  947  			return ret;
61bfbdb8 Lars-Peter Clausen 2010-07-15  948  	}
61bfbdb8 Lars-Peter Clausen 2010-07-15  949  
58e300af Lars-Peter Clausen 2013-06-09  950  	if (gpio_is_valid(pdata->gpio_read_only)) {
58e300af Lars-Peter Clausen 2013-06-09  951  		ret = mmc_gpio_request_ro(mmc, pdata->gpio_read_only);
58e300af Lars-Peter Clausen 2013-06-09  952  		if (ret)
58e300af Lars-Peter Clausen 2013-06-09  953  			return ret;
61bfbdb8 Lars-Peter Clausen 2010-07-15  954  	}
61bfbdb8 Lars-Peter Clausen 2010-07-15  955  
58e300af Lars-Peter Clausen 2013-06-09  956  	return jz4740_mmc_request_gpio(&pdev->dev, pdata->gpio_power,
58e300af Lars-Peter Clausen 2013-06-09  957  			"MMC read only", true, pdata->power_active_low);
61bfbdb8 Lars-Peter Clausen 2010-07-15  958  }
61bfbdb8 Lars-Peter Clausen 2010-07-15  959  
61bfbdb8 Lars-Peter Clausen 2010-07-15  960  static void jz4740_mmc_free_gpios(struct platform_device *pdev)
61bfbdb8 Lars-Peter Clausen 2010-07-15  961  {
61bfbdb8 Lars-Peter Clausen 2010-07-15  962  	struct jz4740_mmc_platform_data *pdata = pdev->dev.platform_data;
61bfbdb8 Lars-Peter Clausen 2010-07-15  963  
61bfbdb8 Lars-Peter Clausen 2010-07-15  964  	if (!pdata)
61bfbdb8 Lars-Peter Clausen 2010-07-15  965  		return;
61bfbdb8 Lars-Peter Clausen 2010-07-15  966  
61bfbdb8 Lars-Peter Clausen 2010-07-15  967  	if (gpio_is_valid(pdata->gpio_power))
61bfbdb8 Lars-Peter Clausen 2010-07-15 @968  		gpio_free(pdata->gpio_power);
61bfbdb8 Lars-Peter Clausen 2010-07-15  969  }
61bfbdb8 Lars-Peter Clausen 2010-07-15  970  
c3be1efd Bill Pemberton     2012-11-19  971  static int jz4740_mmc_probe(struct platform_device* pdev)

:::::: The code at line 864 was first introduced by commit
:::::: 61bfbdb856879cff583fe53b2ab6ae907faedee7 MMC: Add support for the controller on JZ4740 SoCs.

:::::: TO: Lars-Peter Clausen <lars@metafoo.de>
:::::: CC: Ralf Baechle <ralf@linux-mips.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Paul Cercueil Jan. 26, 2017, 10:10 a.m. UTC | #2
Hi Kbuild Test Robot,

> 
> drivers/mmc/host/jz4740_mmc.c: In function 'jz4740_mmc_set_ios':
> drivers/mmc/host/jz4740_mmc.c:864:7: error: implicit declaration of 
> function 'gpio_is_valid' [-Werror=implicit-function-declaration]

  if (gpio_is_valid(host->pdata->gpio_power))
  ^~~~~~~~~~~~~

Uuh, I'm sorry about that. Looks like I removed one header too much 
(<linux/gpio.h>).
My fault, lately I was testing with ci20_defconfig which doesn't enable 
this driver.

Should I send a v4?

Apologies,
-Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index 819ad32964fc..b5fec5b7ee7b 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -20,14 +20,13 @@ 
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/scatterlist.h>
 #include <linux/clk.h>
 
 #include <linux/bitops.h>
-#include <linux/gpio.h>
-#include <asm/mach-jz4740/gpio.h>
 #include <asm/cacheflush.h>
 #include <linux/dma-mapping.h>
 #include <linux/dmaengine.h>
@@ -906,15 +905,6 @@  static const struct mmc_host_ops jz4740_mmc_ops = {
 	.enable_sdio_irq = jz4740_mmc_enable_sdio_irq,
 };
 
-static const struct jz_gpio_bulk_request jz4740_mmc_pins[] = {
-	JZ_GPIO_BULK_PIN(MSC_CMD),
-	JZ_GPIO_BULK_PIN(MSC_CLK),
-	JZ_GPIO_BULK_PIN(MSC_DATA0),
-	JZ_GPIO_BULK_PIN(MSC_DATA1),
-	JZ_GPIO_BULK_PIN(MSC_DATA2),
-	JZ_GPIO_BULK_PIN(MSC_DATA3),
-};
-
 static int jz4740_mmc_request_gpio(struct device *dev, int gpio,
 	const char *name, bool output, int value)
 {
@@ -978,15 +968,6 @@  static void jz4740_mmc_free_gpios(struct platform_device *pdev)
 		gpio_free(pdata->gpio_power);
 }
 
-static inline size_t jz4740_mmc_num_pins(struct jz4740_mmc_host *host)
-{
-	size_t num_pins = ARRAY_SIZE(jz4740_mmc_pins);
-	if (host->pdata && host->pdata->data_1bit)
-		num_pins -= 3;
-
-	return num_pins;
-}
-
 static int jz4740_mmc_probe(struct platform_device* pdev)
 {
 	int ret;
@@ -1027,15 +1008,9 @@  static int jz4740_mmc_probe(struct platform_device* pdev)
 		goto err_free_host;
 	}
 
-	ret = jz_gpio_bulk_request(jz4740_mmc_pins, jz4740_mmc_num_pins(host));
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to request mmc pins: %d\n", ret);
-		goto err_free_host;
-	}
-
 	ret = jz4740_mmc_request_gpios(mmc, pdev);
 	if (ret)
-		goto err_gpio_bulk_free;
+		goto err_release_dma;
 
 	mmc->ops = &jz4740_mmc_ops;
 	mmc->f_min = JZ_MMC_CLK_RATE / 128;
@@ -1091,10 +1066,9 @@  static int jz4740_mmc_probe(struct platform_device* pdev)
 	free_irq(host->irq, host);
 err_free_gpios:
 	jz4740_mmc_free_gpios(pdev);
-err_gpio_bulk_free:
+err_release_dma:
 	if (host->use_dma)
 		jz4740_mmc_release_dma_channels(host);
-	jz_gpio_bulk_free(jz4740_mmc_pins, jz4740_mmc_num_pins(host));
 err_free_host:
 	mmc_free_host(mmc);
 
@@ -1114,7 +1088,6 @@  static int jz4740_mmc_remove(struct platform_device *pdev)
 	free_irq(host->irq, host);
 
 	jz4740_mmc_free_gpios(pdev);
-	jz_gpio_bulk_free(jz4740_mmc_pins, jz4740_mmc_num_pins(host));
 
 	if (host->use_dma)
 		jz4740_mmc_release_dma_channels(host);
@@ -1128,20 +1101,12 @@  static int jz4740_mmc_remove(struct platform_device *pdev)
 
 static int jz4740_mmc_suspend(struct device *dev)
 {
-	struct jz4740_mmc_host *host = dev_get_drvdata(dev);
-
-	jz_gpio_bulk_suspend(jz4740_mmc_pins, jz4740_mmc_num_pins(host));
-
-	return 0;
+	return pinctrl_pm_select_sleep_state(dev);
 }
 
 static int jz4740_mmc_resume(struct device *dev)
 {
-	struct jz4740_mmc_host *host = dev_get_drvdata(dev);
-
-	jz_gpio_bulk_resume(jz4740_mmc_pins, jz4740_mmc_num_pins(host));
-
-	return 0;
+	return pinctrl_pm_select_default_state(dev);
 }
 
 static SIMPLE_DEV_PM_OPS(jz4740_mmc_pm_ops, jz4740_mmc_suspend,