* [U-Boot] [PATCH v2] i2c: muxes: pca954x: Add support for GPIO reset line
@ 2017-09-11 18:19 Moritz Fischer
2017-09-12 4:27 ` Heiko Schocher
2017-09-12 12:30 ` Simon Glass
0 siblings, 2 replies; 4+ messages in thread
From: Moritz Fischer @ 2017-09-11 18:19 UTC (permalink / raw)
To: u-boot
This commit adds support for GPIO reset lines matching the
common linux "reset-gpios" devicetree binding.
Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
---
Changes from v1:
- Simon's feedback on ifdef vs IS_ENABLED()
---
drivers/i2c/muxes/pca954x.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
index 383f72f552..7dee12166d 100644
--- a/drivers/i2c/muxes/pca954x.c
+++ b/drivers/i2c/muxes/pca954x.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 - 2016 Xilinx, Inc.
+ * Copyright (C) 2017 National Instruments Corp
* Written by Michal Simek
*
* SPDX-License-Identifier: GPL-2.0+
@@ -9,7 +10,8 @@
#include <dm.h>
#include <errno.h>
#include <i2c.h>
-#include <asm/gpio.h>
+
+#include <asm-generic/gpio.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +32,9 @@ struct chip_desc {
struct pca954x_priv {
u32 addr; /* I2C mux address */
u32 width; /* I2C mux width - number of busses */
+#ifdef CONFIG_DM_GPIO
+ struct gpio_desc gpio_mux_reset;
+#endif /* CONFIG_DM_GPIO */
};
static const struct chip_desc chips[] = {
@@ -105,10 +110,45 @@ static int pca954x_ofdata_to_platdata(struct udevice *dev)
return 0;
}
+static int pca954x_probe(struct udevice *dev)
+{
+ if (IS_ENABLED(CONFIG_DM_GPIO)) {
+ struct pca954x_priv *priv = dev_get_priv(dev);
+ int err;
+
+ err = gpio_request_by_name(dev, "reset-gpios", 0,
+ &priv->gpio_mux_reset, GPIOD_IS_OUT);
+
+ /* it's optional so only bail if we get a real error */
+ if (err && (err != -ENOENT))
+ return err;
+
+ /* dm will take care of polarity */
+ if (dm_gpio_is_valid(&priv->gpio_mux_reset))
+ dm_gpio_set_value(&priv->gpio_mux_reset, 0);
+ }
+
+ return 0;
+}
+
+static int pca954x_remove(struct udevice *dev)
+{
+ if (IS_ENABLED(CONFIG_DM_GPIO)) {
+ struct pca954x_priv *priv = dev_get_priv(dev);
+
+ if (dm_gpio_is_valid(&priv->gpio_mux_reset))
+ dm_gpio_free(dev, &priv->gpio_mux_reset);
+ }
+
+ return 0;
+}
+
U_BOOT_DRIVER(pca954x) = {
.name = "pca954x",
.id = UCLASS_I2C_MUX,
.of_match = pca954x_ids,
+ .probe = pca954x_probe,
+ .remove = pca954x_remove,
.ops = &pca954x_ops,
.ofdata_to_platdata = pca954x_ofdata_to_platdata,
.priv_auto_alloc_size = sizeof(struct pca954x_priv),
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] i2c: muxes: pca954x: Add support for GPIO reset line
2017-09-11 18:19 [U-Boot] [PATCH v2] i2c: muxes: pca954x: Add support for GPIO reset line Moritz Fischer
@ 2017-09-12 4:27 ` Heiko Schocher
2017-09-12 10:14 ` Heiko Schocher
2017-09-12 12:30 ` Simon Glass
1 sibling, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2017-09-12 4:27 UTC (permalink / raw)
To: u-boot
Hello Moritz,
Am 11.09.2017 um 20:19 schrieb Moritz Fischer:
> This commit adds support for GPIO reset lines matching the
> common linux "reset-gpios" devicetree binding.
>
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
> ---
>
> Changes from v1:
> - Simon's feedback on ifdef vs IS_ENABLED()
>
> ---
> drivers/i2c/muxes/pca954x.c | 42 +++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 41 insertions(+), 1 deletion(-)
Reviewed-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] i2c: muxes: pca954x: Add support for GPIO reset line
2017-09-12 4:27 ` Heiko Schocher
@ 2017-09-12 10:14 ` Heiko Schocher
0 siblings, 0 replies; 4+ messages in thread
From: Heiko Schocher @ 2017-09-12 10:14 UTC (permalink / raw)
To: u-boot
Hallo Moritz,
Am 12.09.2017 um 06:27 schrieb Heiko Schocher:
> Hello Moritz,
>
> Am 11.09.2017 um 20:19 schrieb Moritz Fischer:
>> This commit adds support for GPIO reset lines matching the
>> common linux "reset-gpios" devicetree binding.
>>
>> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
>> ---
>>
>> Changes from v1:
>> - Simon's feedback on ifdef vs IS_ENABLED()
>>
>> ---
>> drivers/i2c/muxes/pca954x.c | 42 +++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 41 insertions(+), 1 deletion(-)
>
> Reviewed-by: Heiko Schocher <hs@denx.de>
Hmm.. your patch
http://patchwork.ozlabs.org/patch/812541/
breaks the mvebu travis build, see:
https://travis-ci.org/hsdenx/u-boot-i2c/jobs/274457946
for example:
arm: + turris_omnia
+drivers/i2c/muxes/pca954x.c: In function ?pca954x_probe?:
+drivers/i2c/muxes/pca954x.c:120:10: error: ?struct pca954x_priv? has no member named ?gpio_mux_reset?
+ &priv->gpio_mux_reset, GPIOD_IS_OUT);
+ ^~
but your patch seems to do it correct:
+ if (IS_ENABLED(CONFIG_DM_GPIO)) {
Hmm... I know Simon suggested exactly this change ... but this seems
to produce errors here ... when I look into the ".config" file after
"make turris_omnia_defconfig"
I see:
# CONFIG_DM_GPIO is not set
Hmm... using
#ifdef CONFIG_DM_GPIO
instead "if (IS_ENABLED(CONFIG_DM_GPIO)) {" and it compiles clean.
So it seems we have a problem here with "IS_ENABLED()" ...
@Simon, Masahiro: any ideas?
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] i2c: muxes: pca954x: Add support for GPIO reset line
2017-09-11 18:19 [U-Boot] [PATCH v2] i2c: muxes: pca954x: Add support for GPIO reset line Moritz Fischer
2017-09-12 4:27 ` Heiko Schocher
@ 2017-09-12 12:30 ` Simon Glass
1 sibling, 0 replies; 4+ messages in thread
From: Simon Glass @ 2017-09-12 12:30 UTC (permalink / raw)
To: u-boot
On 11 September 2017 at 12:19, Moritz Fischer <moritz.fischer@ettus.com> wrote:
> This commit adds support for GPIO reset lines matching the
> common linux "reset-gpios" devicetree binding.
>
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
> ---
>
> Changes from v1:
> - Simon's feedback on ifdef vs IS_ENABLED()
>
> ---
> drivers/i2c/muxes/pca954x.c | 42 +++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
> index 383f72f552..7dee12166d 100644
> --- a/drivers/i2c/muxes/pca954x.c
> +++ b/drivers/i2c/muxes/pca954x.c
> @@ -1,5 +1,6 @@
> /*
> * Copyright (C) 2015 - 2016 Xilinx, Inc.
> + * Copyright (C) 2017 National Instruments Corp
> * Written by Michal Simek
> *
> * SPDX-License-Identifier: GPL-2.0+
> @@ -9,7 +10,8 @@
> #include <dm.h>
> #include <errno.h>
> #include <i2c.h>
> -#include <asm/gpio.h>
> +
> +#include <asm-generic/gpio.h>
>
> DECLARE_GLOBAL_DATA_PTR;
>
> @@ -30,6 +32,9 @@ struct chip_desc {
> struct pca954x_priv {
> u32 addr; /* I2C mux address */
> u32 width; /* I2C mux width - number of busses */
> +#ifdef CONFIG_DM_GPIO
> + struct gpio_desc gpio_mux_reset;
> +#endif /* CONFIG_DM_GPIO */
You should drop the #ifdef here.
Otherwise:
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-12 12:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-11 18:19 [U-Boot] [PATCH v2] i2c: muxes: pca954x: Add support for GPIO reset line Moritz Fischer
2017-09-12 4:27 ` Heiko Schocher
2017-09-12 10:14 ` Heiko Schocher
2017-09-12 12:30 ` Simon Glass
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.