* [PATCH v2 0/2] MIPS: TXx9: Move GPIO setup from .mem_setup() to .arch_init()
@ 2016-09-11 8:48 Geert Uytterhoeven
2016-09-11 8:48 ` [PATCH v2 1/2] MIPS: TXx9: tx39xx: " Geert Uytterhoeven
2016-09-11 8:48 ` [PATCH v2 2/2] MIPS: TXx9: tx49xx: " Geert Uytterhoeven
0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2016-09-11 8:48 UTC (permalink / raw)
To: Ralf Baechle, Atsushi Nemoto; +Cc: linux-mips, linux-gpio, Geert Uytterhoeven
Hi Ralf, Nemoto-san,
After upgrading my good old rbtx4927 from v3.13-rc3 to v4.6-rc3, I
noticed the following warning:
gpiod_direction_output_raw: invalid GPIO
This is caused by the following code in arch/mips/txx9/rbtx4927/setup.c:
static void __init rbtx4927_mem_setup(void)
{
/* TX4927-SIO DTR on (PIO[15]) */
gpio_request(15, "sio-dtr");
returns -EPROBE_DEFER
gpio_direction_output(15, 1);
VALIDATE_DESC triggers the warning.
Note that as of commit 54d77198fdfbc4f0 ("gpio: bail out silently on
NULL descriptors") the warning message is no longer printed, but the
underlying issue is still there.
Nemoto-san pointed out that the GPIO setup may now be done too early,
and that indeed is the case. Hence the following patch series postpones
GPIO setup from .mem_setup() time to .arch_init() time to fix it, for
all TXx9 platforms.
Changes since v1:
- Add Acked-by.
This has been tested on RBTX4927 only.
Thanks!
Geert Uytterhoeven (2):
MIPS: TXx9: tx39xx: Move GPIO setup from .mem_setup() to .arch_init()
MIPS: TXx9: tx49xx: Move GPIO setup from .mem_setup() to .arch_init()
arch/mips/txx9/generic/setup_tx3927.c | 1 -
arch/mips/txx9/generic/setup_tx4927.c | 1 -
arch/mips/txx9/generic/setup_tx4938.c | 1 -
arch/mips/txx9/jmr3927/setup.c | 11 +++++++++--
arch/mips/txx9/rbtx4927/setup.c | 32 ++++++++++++++++++++++----------
arch/mips/txx9/rbtx4938/setup.c | 1 +
6 files changed, 32 insertions(+), 15 deletions(-)
--
1.9.1
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] MIPS: TXx9: tx39xx: Move GPIO setup from .mem_setup() to .arch_init()
2016-09-11 8:48 [PATCH v2 0/2] MIPS: TXx9: Move GPIO setup from .mem_setup() to .arch_init() Geert Uytterhoeven
@ 2016-09-11 8:48 ` Geert Uytterhoeven
2016-09-11 8:48 ` [PATCH v2 2/2] MIPS: TXx9: tx49xx: " Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2016-09-11 8:48 UTC (permalink / raw)
To: Ralf Baechle, Atsushi Nemoto; +Cc: linux-mips, linux-gpio, Geert Uytterhoeven
txx9_gpio_init() calls gpiochip_add_data(), which fails with -ENOMEM as
it is called too early in the boot process. This causes all subsequent
GPIO operations to fail silently.
Postpone all GPIO setup to .arch_init() time to fix this.
Suggested-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
Untested due to lack of hardware.
v2:
- Add Acked-by.
---
arch/mips/txx9/generic/setup_tx3927.c | 1 -
arch/mips/txx9/jmr3927/setup.c | 11 +++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/mips/txx9/generic/setup_tx3927.c b/arch/mips/txx9/generic/setup_tx3927.c
index 110e05c3eb8fb638..d3b83a92cf26c707 100644
--- a/arch/mips/txx9/generic/setup_tx3927.c
+++ b/arch/mips/txx9/generic/setup_tx3927.c
@@ -92,7 +92,6 @@ void __init tx3927_setup(void)
/* PIO */
__raw_writel(0, &tx3927_pioptr->maskcpu);
__raw_writel(0, &tx3927_pioptr->maskext);
- txx9_gpio_init(TX3927_PIO_REG, 0, 16);
conf = read_c0_conf();
if (conf & TX39_CONF_DCE) {
diff --git a/arch/mips/txx9/jmr3927/setup.c b/arch/mips/txx9/jmr3927/setup.c
index 3206f76f300b727a..a455166dc6d44fe7 100644
--- a/arch/mips/txx9/jmr3927/setup.c
+++ b/arch/mips/txx9/jmr3927/setup.c
@@ -142,8 +142,6 @@ static void __init jmr3927_board_init(void)
/* PIO[15:12] connected to LEDs */
__raw_writel(0x0000f000, &tx3927_pioptr->dir);
- gpio_request(11, "dipsw1");
- gpio_request(10, "dipsw2");
jmr3927_pci_setup();
@@ -204,6 +202,14 @@ static void __init jmr3927_device_init(void)
txx9_iocled_init(iocled_base, -1, 8, 1, "green", NULL);
}
+static void __init jmr3927_arch_init(void)
+{
+ txx9_gpio_init(TX3927_PIO_REG, 0, 16);
+
+ gpio_request(11, "dipsw1");
+ gpio_request(10, "dipsw2");
+}
+
struct txx9_board_vec jmr3927_vec __initdata = {
.system = "Toshiba JMR_TX3927",
.prom_init = jmr3927_prom_init,
@@ -211,6 +217,7 @@ struct txx9_board_vec jmr3927_vec __initdata = {
.irq_setup = jmr3927_irq_setup,
.time_init = jmr3927_time_init,
.device_init = jmr3927_device_init,
+ .arch_init = jmr3927_arch_init,
#ifdef CONFIG_PCI
.pci_map_irq = jmr3927_pci_map_irq,
#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] MIPS: TXx9: tx49xx: Move GPIO setup from .mem_setup() to .arch_init()
2016-09-11 8:48 [PATCH v2 0/2] MIPS: TXx9: Move GPIO setup from .mem_setup() to .arch_init() Geert Uytterhoeven
2016-09-11 8:48 ` [PATCH v2 1/2] MIPS: TXx9: tx39xx: " Geert Uytterhoeven
@ 2016-09-11 8:48 ` Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2016-09-11 8:48 UTC (permalink / raw)
To: Ralf Baechle, Atsushi Nemoto; +Cc: linux-mips, linux-gpio, Geert Uytterhoeven
txx9_gpio_init() calls gpiochip_add_data(), which fails with -ENOMEM as
it is called too early in the boot process. This causes all subsequent
GPIO operations to fail silently (before commit 54d77198fdfbc4f0 ("gpio:
bail out silently on NULL descriptors") it printed the error message
"gpiod_direction_output_raw: invalid GPIO" on RBTX49[23]7).
Postpone all GPIO setup to .arch_init() time to fix this.
Suggested-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
Tested on RBTX4927 only. The gpiochip appears under /sys/class/gpio/.
Sent as a single patch, as RBTX4937 is handled by rbtx4927/setup.c, but
uses tx4938_setup().
v2:
- Add Acked-by.
---
arch/mips/txx9/generic/setup_tx4927.c | 1 -
arch/mips/txx9/generic/setup_tx4938.c | 1 -
arch/mips/txx9/rbtx4927/setup.c | 32 ++++++++++++++++++++++----------
arch/mips/txx9/rbtx4938/setup.c | 1 +
4 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/arch/mips/txx9/generic/setup_tx4927.c b/arch/mips/txx9/generic/setup_tx4927.c
index a4664cb6c1e18371..8d8011570b1dbe99 100644
--- a/arch/mips/txx9/generic/setup_tx4927.c
+++ b/arch/mips/txx9/generic/setup_tx4927.c
@@ -215,7 +215,6 @@ void __init tx4927_setup(void)
txx9_tmr_init(TX4927_TMR_REG(i) & 0xfffffffffULL);
/* PIO */
- txx9_gpio_init(TX4927_PIO_REG & 0xfffffffffULL, 0, TX4927_NUM_PIO);
__raw_writel(0, &tx4927_pioptr->maskcpu);
__raw_writel(0, &tx4927_pioptr->maskext);
diff --git a/arch/mips/txx9/generic/setup_tx4938.c b/arch/mips/txx9/generic/setup_tx4938.c
index 58cdb2aba5e1ba72..ba265bf1fd067036 100644
--- a/arch/mips/txx9/generic/setup_tx4938.c
+++ b/arch/mips/txx9/generic/setup_tx4938.c
@@ -241,7 +241,6 @@ void __init tx4938_setup(void)
txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL);
/* PIO */
- txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, TX4938_NUM_PIO);
__raw_writel(0, &tx4938_pioptr->maskcpu);
__raw_writel(0, &tx4938_pioptr->maskext);
diff --git a/arch/mips/txx9/rbtx4927/setup.c b/arch/mips/txx9/rbtx4927/setup.c
index 3c516ef625e57d2d..f5b367e20dff1cfa 100644
--- a/arch/mips/txx9/rbtx4927/setup.c
+++ b/arch/mips/txx9/rbtx4927/setup.c
@@ -52,6 +52,7 @@
#include <linux/leds.h>
#include <asm/io.h>
#include <asm/reboot.h>
+#include <asm/txx9pio.h>
#include <asm/txx9/generic.h>
#include <asm/txx9/pci.h>
#include <asm/txx9/rbtx4927.h>
@@ -151,20 +152,37 @@ static void __init tx4937_pci_setup(void)
}
tx4938_setup_pcierr_irq();
}
+#else
+static inline void tx4927_pci_setup(void) {}
+static inline void tx4937_pci_setup(void) {}
+#endif /* CONFIG_PCI */
+
+static void __init rbtx4927_gpio_init(void)
+{
+ /* TX4927-SIO DTR on (PIO[15]) */
+ gpio_request(15, "sio-dtr");
+ gpio_direction_output(15, 1);
+
+ tx4927_sio_init(0, 0);
+}
static void __init rbtx4927_arch_init(void)
{
+ txx9_gpio_init(TX4927_PIO_REG & 0xfffffffffULL, 0, TX4927_NUM_PIO);
+
+ rbtx4927_gpio_init();
+
tx4927_pci_setup();
}
static void __init rbtx4937_arch_init(void)
{
+ txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, TX4938_NUM_PIO);
+
+ rbtx4927_gpio_init();
+
tx4937_pci_setup();
}
-#else
-#define rbtx4927_arch_init NULL
-#define rbtx4937_arch_init NULL
-#endif /* CONFIG_PCI */
static void toshiba_rbtx4927_restart(char *command)
{
@@ -205,12 +223,6 @@ static void __init rbtx4927_mem_setup(void)
#else
set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET);
#endif
-
- /* TX4927-SIO DTR on (PIO[15]) */
- gpio_request(15, "sio-dtr");
- gpio_direction_output(15, 1);
-
- tx4927_sio_init(0, 0);
}
static void __init rbtx4927_clock_init(void)
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c
index 54de66837103c702..07939ed6b22fdac5 100644
--- a/arch/mips/txx9/rbtx4938/setup.c
+++ b/arch/mips/txx9/rbtx4938/setup.c
@@ -336,6 +336,7 @@ static void __init rbtx4938_mtd_init(void)
static void __init rbtx4938_arch_init(void)
{
+ txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, TX4938_NUM_PIO);
gpiochip_add_data(&rbtx4938_spi_gpio_chip, NULL);
rbtx4938_pci_setup();
rbtx4938_spi_init();
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-11 8:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-11 8:48 [PATCH v2 0/2] MIPS: TXx9: Move GPIO setup from .mem_setup() to .arch_init() Geert Uytterhoeven
2016-09-11 8:48 ` [PATCH v2 1/2] MIPS: TXx9: tx39xx: " Geert Uytterhoeven
2016-09-11 8:48 ` [PATCH v2 2/2] MIPS: TXx9: tx49xx: " Geert Uytterhoeven
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).