* [PATCH] mmc: dw_mmc: No bus setup if default pinctrl is used
@ 2013-02-07 18:17 ` Dongjin Kim
0 siblings, 0 replies; 4+ messages in thread
From: Dongjin Kim @ 2013-02-07 18:17 UTC (permalink / raw)
Cc: Dongjin Kim, Thomas Abraham, Linus Walleij, Seungwon Jeon,
Jaehoon Chung, Chris Ball, linux-mmc, linux-kernel
Legacy gpio based bus setup is failed when the bus pins are listed with the
property 'pinctrl-0' and 'pinctrl-names', instead of 'gpios'. The default
pinctrls are handled by device core before probe, no need to configure the
pins again in a device driver.
[ 1.190000] Synopsys Designware Multimedia Card Interface Driver
[ 1.195000] dwmmc_exynos 12550000.mshc: Using PIO mode.
[ 1.200000] dwmmc_exynos 12550000.mshc: DW MMC controller at irq 109, 32 bit host data width, 128 deep fifo
[ 1.210000] dwmmc_exynos 12550000.mshc: invalid gpio: -2
[ 1.215000] dwmmc_exynos: probe of 12550000.mshc failed with error -22
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dongjin Kim <tobetter@gmail.com>
---
drivers/mmc/host/dw_mmc-exynos.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index aafd485..f568c32 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -156,12 +156,19 @@ static int dw_mci_exynos_setup_bus(struct dw_mci *host,
struct device_node *slot_np, u8 bus_width)
{
int idx, gpio, ret;
+ int nr_pins = NUM_PINS(bus_width);
if (!slot_np)
return -EINVAL;
+#if defined(CONFIG_PINCTRL)
+ /* Default pinctrl is used */
+ if (!IS_ERR(host->dev->pins->default_state))
+ nr_pins = 0;
+#endif
+
/* cmd + clock + bus-width pins */
- for (idx = 0; idx < NUM_PINS(bus_width); idx++) {
+ for (idx = 0; idx < nr_pins; idx++) {
gpio = of_get_gpio(slot_np, idx);
if (!gpio_is_valid(gpio)) {
dev_err(host->dev, "invalid gpio: %d\n", gpio);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] mmc: dw_mmc: No bus setup if default pinctrl is used
@ 2013-02-07 18:17 ` Dongjin Kim
0 siblings, 0 replies; 4+ messages in thread
From: Dongjin Kim @ 2013-02-07 18:17 UTC (permalink / raw)
Cc: Dongjin Kim, Thomas Abraham, Linus Walleij, Seungwon Jeon,
Jaehoon Chung, Chris Ball, linux-mmc, linux-kernel
Legacy gpio based bus setup is failed when the bus pins are listed with the
property 'pinctrl-0' and 'pinctrl-names', instead of 'gpios'. The default
pinctrls are handled by device core before probe, no need to configure the
pins again in a device driver.
[ 1.190000] Synopsys Designware Multimedia Card Interface Driver
[ 1.195000] dwmmc_exynos 12550000.mshc: Using PIO mode.
[ 1.200000] dwmmc_exynos 12550000.mshc: DW MMC controller at irq 109, 32 bit host data width, 128 deep fifo
[ 1.210000] dwmmc_exynos 12550000.mshc: invalid gpio: -2
[ 1.215000] dwmmc_exynos: probe of 12550000.mshc failed with error -22
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dongjin Kim <tobetter@gmail.com>
---
drivers/mmc/host/dw_mmc-exynos.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index aafd485..f568c32 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -156,12 +156,19 @@ static int dw_mci_exynos_setup_bus(struct dw_mci *host,
struct device_node *slot_np, u8 bus_width)
{
int idx, gpio, ret;
+ int nr_pins = NUM_PINS(bus_width);
if (!slot_np)
return -EINVAL;
+#if defined(CONFIG_PINCTRL)
+ /* Default pinctrl is used */
+ if (!IS_ERR(host->dev->pins->default_state))
+ nr_pins = 0;
+#endif
+
/* cmd + clock + bus-width pins */
- for (idx = 0; idx < NUM_PINS(bus_width); idx++) {
+ for (idx = 0; idx < nr_pins; idx++) {
gpio = of_get_gpio(slot_np, idx);
if (!gpio_is_valid(gpio)) {
dev_err(host->dev, "invalid gpio: %d\n", gpio);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: dw_mmc: No bus setup if default pinctrl is used
2013-02-07 18:17 ` Dongjin Kim
(?)
@ 2013-02-07 19:03 ` Linus Walleij
2013-02-07 19:49 ` Dongjin Kim
-1 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2013-02-07 19:03 UTC (permalink / raw)
To: Dongjin Kim
Cc: Thomas Abraham, Seungwon Jeon, Jaehoon Chung, Chris Ball,
linux-mmc, linux-kernel
On Thu, Feb 7, 2013 at 7:17 PM, Dongjin Kim <tobetter@gmail.com> wrote:
> Legacy gpio based bus setup is failed when the bus pins are listed with the
> property 'pinctrl-0' and 'pinctrl-names', instead of 'gpios'. The default
> pinctrls are handled by device core before probe, no need to configure the
> pins again in a device driver.
Aha.
> {
> int idx, gpio, ret;
> + int nr_pins = NUM_PINS(bus_width);
>
> if (!slot_np)
> return -EINVAL;
>
> +#if defined(CONFIG_PINCTRL)
> + /* Default pinctrl is used */
> + if (!IS_ERR(host->dev->pins->default_state))
> + nr_pins = 0;
> +#endif
Use:
if (IS_ENABLED(CONFIG_PINCTRL))
nr_pins = 0;
Without ifdefs. Grep kernel for examples.
Read <linux/kconfig.h> for explanations.
Put a comment above this to explain exactly why
you do this.
> +
> /* cmd + clock + bus-width pins */
> - for (idx = 0; idx < NUM_PINS(bus_width); idx++) {
> + for (idx = 0; idx < nr_pins; idx++) {
> gpio = of_get_gpio(slot_np, idx);
> if (!gpio_is_valid(gpio)) {
> dev_err(host->dev, "invalid gpio: %d\n", gpio);
This looks kludgy, is it so that the driver falls back to GPIO
if it cannot use pinctrl? Can't it just depend on CONFIG_PINCTRL
in Kconfig or do you absolutely have to support both cases?
I was under the impression that the Exynos requires pinctrl.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: dw_mmc: No bus setup if default pinctrl is used
2013-02-07 19:03 ` Linus Walleij
@ 2013-02-07 19:49 ` Dongjin Kim
0 siblings, 0 replies; 4+ messages in thread
From: Dongjin Kim @ 2013-02-07 19:49 UTC (permalink / raw)
To: Linus Walleij
Cc: Thomas Abraham, Seungwon Jeon, Jaehoon Chung, Chris Ball,
linux-mmc, linux-kernel
Hi Linus,
Thank you for reviewing.
Initially I also considered to use IS_ENABLED(CONFIG_PINCTRL) and
ignore for-block according to its status. But it would make a certain
board failed if gpios is used for pin configuration rather than
default-pinctrl even if CONFIG_PINCTRL is enabled. Also considered to
add a function on pinctrl.c to return if default-pinctrl is used, and
drop down the for-block according to its status. It could replace the
long and complicaed line, IS_ERR(host->dev->pins->default_state), to
simple one as well. :)
The best is obviously to enable CONFIG_PINCTRL and remove the
for-block, it makes the code more simple. I like to have a comment
from Thomas if have to support both cases, gpios and default-pinctrl.
Best regards,
Dongjin.
On Fri, Feb 8, 2013 at 4:03 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Thu, Feb 7, 2013 at 7:17 PM, Dongjin Kim <tobetter@gmail.com> wrote:
>
>> Legacy gpio based bus setup is failed when the bus pins are listed with the
>> property 'pinctrl-0' and 'pinctrl-names', instead of 'gpios'. The default
>> pinctrls are handled by device core before probe, no need to configure the
>> pins again in a device driver.
>
> Aha.
>
>> {
>> int idx, gpio, ret;
>> + int nr_pins = NUM_PINS(bus_width);
>>
>> if (!slot_np)
>> return -EINVAL;
>>
>> +#if defined(CONFIG_PINCTRL)
>> + /* Default pinctrl is used */
>> + if (!IS_ERR(host->dev->pins->default_state))
>> + nr_pins = 0;
>> +#endif
>
> Use:
>
> if (IS_ENABLED(CONFIG_PINCTRL))
> nr_pins = 0;
>
> Without ifdefs. Grep kernel for examples.
> Read <linux/kconfig.h> for explanations.
>
> Put a comment above this to explain exactly why
> you do this.
>
>> +
>> /* cmd + clock + bus-width pins */
>> - for (idx = 0; idx < NUM_PINS(bus_width); idx++) {
>> + for (idx = 0; idx < nr_pins; idx++) {
>> gpio = of_get_gpio(slot_np, idx);
>> if (!gpio_is_valid(gpio)) {
>> dev_err(host->dev, "invalid gpio: %d\n", gpio);
>
> This looks kludgy, is it so that the driver falls back to GPIO
> if it cannot use pinctrl? Can't it just depend on CONFIG_PINCTRL
> in Kconfig or do you absolutely have to support both cases?
>
> I was under the impression that the Exynos requires pinctrl.
>
> Yours,
> Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-07 19:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 18:17 [PATCH] mmc: dw_mmc: No bus setup if default pinctrl is used Dongjin Kim
2013-02-07 18:17 ` Dongjin Kim
2013-02-07 19:03 ` Linus Walleij
2013-02-07 19:49 ` Dongjin Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.