From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-02-09 12:07:41
v2: https://www.spinics.net/lists/devicetree/msg211283.html
This series adds a driver for the GPIO controller used in the Nintendo
Wii game console.
Previous versions of this series included a patch to kernel/resource.c
("resource: Extend the PPC32 reserved memory hack") to work around a
resource allocation problem on PPC32. In this version, I dropped this
patch, because the problem will be solved differently and in a separate
patchset.
I also dropped the dt-bindings patch, because Linus Walleij has already
applied it.
Jonathan Neuschäfer (4):
powerpc: wii: Explicitly configure GPIO owner for poweroff pin
gpio: Add GPIO driver for Nintendo Wii
powerpc: wii.dts: Add ngpios property
powerpc: wii.dts: Add GPIO line names
arch/powerpc/boot/dts/wii.dts | 9 +++
arch/powerpc/platforms/embedded6xx/wii.c | 7 ++
drivers/gpio/Kconfig | 9 +++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-hlwd.c | 115 +++++++++++++++++++++++++++++++
5 files changed, 141 insertions(+)
create mode 100644 drivers/gpio/gpio-hlwd.c
--
2.15.1
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-02-09 12:07:51
The Hollywood chipset's GPIO controller has two sets of registers: One
for access by the PowerPC CPU, and one for access by the ARM coprocessor
(but both are accessible from the PPC because the memory firewall
(AHBPROT) is usually disabled when booting Linux, today).
The wii_power_off function currently assumes that the poweroff GPIO pin
is configured for use via the ARM side, but the upcoming GPIO driver
configures all pins for use via the PPC side, breaking poweroff.
Configure the owner register explicitly in wii_power_off to make
wii_power_off work with and without the new GPIO driver.
I think the Wii can be switched to the generic gpio-poweroff driver,
after the GPIO driver is merged.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
v2, v3:
- no change
---
arch/powerpc/platforms/embedded6xx/wii.c | 7 +++++++
1 file changed, 7 insertions(+)
@@ -177,6 +178,12 @@ static void wii_power_off(void)local_irq_disable();if(hw_gpio){+/*+*settheowneroftheshutdownpintoARM,becauseitis+*accessedthroughtheregistersfortheARM,below+*/+clrbits32(hw_gpio+HW_GPIO_OWNER,HW_GPIO_SHUTDOWN);+/* make sure that the poweroff GPIO is configured as output */setbits32(hw_gpio+HW_GPIO_DIR(1),HW_GPIO_SHUTDOWN);
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-02-09 12:07:59
The Nintendo Wii's chipset (called "Hollywood") has a GPIO controller
that supports a configurable number of pins (up to 32), interrupts, and
some special mechanisms to share the controller between the system's
security processor (an ARM926) and the PowerPC CPU. Pin multiplexing is
not supported.
This patch adds a basic driver for this GPIO controller. Interrupt
support will come in a later patch.
This patch is based on code developed by Albert Herranz and the GameCube
Linux Team, file arch/powerpc/platforms/embedded6xx/hlwd-gpio.c,
available at https://github.com/DeltaResero/GC-Wii-Linux-Kernels, but
has grown quite dissimilar.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Cc: Albert Herranz <redacted>
Cc: Segher Boessenkool <redacted>
<---
v3:
- Do some style cleanups, as suggest by Andy Shevchenko
v2:
- Change hlwd_gpio_driver.driver.name to "gpio-hlwd" to match the
filename (was "hlwd_gpio")
- Remove unnecessary include of linux/of_gpio.h, as suggested by Linus
Walleij.
- Add struct device pointer to context struct to make it possible to use
dev_info(hlwd->dev, "..."), as suggested by Linus Walleij
- Use the GPIO_GENERIC library to reduce code size, as suggested by
Linus Walleij
- Use iowrite32be instead of __raw_writel for big-endian MMIO access, as
suggested by Linus Walleij
- Remove commit message paragraph suggesting to diff against the
original driver, because it's so different now
---
drivers/gpio/Kconfig | 9 ++++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-hlwd.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 125 insertions(+)
create mode 100644 drivers/gpio/gpio-hlwd.c
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-02-09 12:08:14
The Hollywood GPIO controller supports 32 GPIOs, but on the Wii, only 24
are used.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
v2, v3:
- no change
---
arch/powerpc/boot/dts/wii.dts | 1 +
1 file changed, 1 insertion(+)
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-02-09 12:08:15
These are the GPIO line names on a Nintendo Wii, as documented in:
https://wiibrew.org/wiki/Hardware/Hollywood_GPIOs
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
v2, v3:
- no change
---
arch/powerpc/boot/dts/wii.dts | 8 ++++++++
1 file changed, 8 insertions(+)
On Fri, Feb 09, 2018 at 01:07:29PM +0100, Jonathan Neuschäfer wrote:
The Nintendo Wii's chipset (called "Hollywood") has a GPIO controller
that supports a configurable number of pins (up to 32), interrupts, and
some special mechanisms to share the controller between the system's
security processor (an ARM926) and the PowerPC CPU. Pin multiplexing is
not supported.
This patch adds a basic driver for this GPIO controller. Interrupt
support will come in a later patch.
This patch is based on code developed by Albert Herranz and the GameCube
Linux Team, file arch/powerpc/platforms/embedded6xx/hlwd-gpio.c,
available at https://github.com/DeltaResero/GC-Wii-Linux-Kernels, but
has grown quite dissimilar.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Cc: Albert Herranz <redacted>
Cc: Segher Boessenkool <redacted>
Reviewed-by: Segher Boessenkool <redacted>
Looks just fine to me :-)
Segher
From: Andy Shevchenko <hidden> Date: 2018-02-09 15:30:59
On Fri, Feb 9, 2018 at 2:07 PM, Jonathan Neusch=C3=A4fer
[off-list ref] wrote:
The Nintendo Wii's chipset (called "Hollywood") has a GPIO controller
that supports a configurable number of pins (up to 32), interrupts, and
some special mechanisms to share the controller between the system's
security processor (an ARM926) and the PowerPC CPU. Pin multiplexing is
not supported.
This patch adds a basic driver for this GPIO controller. Interrupt
support will come in a later patch.
This patch is based on code developed by Albert Herranz and the GameCube
Linux Team, file arch/powerpc/platforms/embedded6xx/hlwd-gpio.c,
available at https://github.com/DeltaResero/GC-Wii-Linux-Kernels, but
has grown quite dissimilar.
Fine to me, though one comment below.
In any case,
Reviewed-by: Andy Shevchenko <redacted>
Signed-off-by: Jonathan Neusch=C3=A4fer <j.neuschaefer@gmx.net>
Cc: Albert Herranz <redacted>
Cc: Segher Boessenkool <redacted>
<---
v3:
- Do some style cleanups, as suggest by Andy Shevchenko
v2:
- Change hlwd_gpio_driver.driver.name to "gpio-hlwd" to match the
filename (was "hlwd_gpio")
- Remove unnecessary include of linux/of_gpio.h, as suggested by Linus
Walleij.
- Add struct device pointer to context struct to make it possible to use
dev_info(hlwd->dev, "..."), as suggested by Linus Walleij
- Use the GPIO_GENERIC library to reduce code size, as suggested by
Linus Walleij
- Use iowrite32be instead of __raw_writel for big-endian MMIO access, as
suggested by Linus Walleij
- Remove commit message paragraph suggesting to diff against the
original driver, because it's so different now
---
drivers/gpio/Kconfig | 9 ++++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-hlwd.c | 115 +++++++++++++++++++++++++++++++++++++++++=
+ select GPIO_GENERIC
+ help
+ Select this to support the GPIO controller of the Nintendo Wii.
+
+ If unsure, say N.
+
config GPIO_ICH
tristate "Intel ICH GPIO"
depends on PCI && X86
...(and using platform device header I suppose)...
+#include <linux/slab.h>
+
+/*
+ * Register names and offsets courtesy of WiiBrew:
+ * https://wiibrew.org/wiki/Hardware/Hollywood_GPIOs
+ *
+ * Note that for most registers, there are two versions:
+ * - HW_GPIOB_* Is always accessible by the Broadway PowerPC core, but d=
oes
+ * always give access to all GPIO lines
+ * - HW_GPIO_* Is only accessible by the Broadway PowerPC code if the me=
mory
+ * firewall (AHBPROT) in the Hollywood chipset has been configured to =
allow
+ * such access.
+ *
+ * The ownership of each GPIO line can be configured in the HW_GPIO_OWNE=
R
+ * register: A one bit configures the line for access via the HW_GPIOB_*
+ * registers, a zero bit indicates access via HW_GPIO_*. This driver use=
+ * systems where the AHBPROT memory firewall hasn't been configur=
ed to
+ * permit PPC access to HW_GPIO_*.
+ *
+ * Note that this has to happen before bgpio_init reads the
+ * HW_GPIOB_OUT and HW_GPIOB_DIR, because otherwise it reads the =
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-02-09 15:48:21
On Fri, Feb 09, 2018 at 01:07:29PM +0100, Jonathan Neuschäfer wrote:
The Nintendo Wii's chipset (called "Hollywood") has a GPIO controller
that supports a configurable number of pins (up to 32), interrupts, and
some special mechanisms to share the controller between the system's
security processor (an ARM926) and the PowerPC CPU. Pin multiplexing is
not supported.
This patch adds a basic driver for this GPIO controller. Interrupt
support will come in a later patch.
This patch is based on code developed by Albert Herranz and the GameCube
Linux Team, file arch/powerpc/platforms/embedded6xx/hlwd-gpio.c,
available at https://github.com/DeltaResero/GC-Wii-Linux-Kernels, but
has grown quite dissimilar.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Cc: Albert Herranz <redacted>
Cc: Segher Boessenkool <redacted>
<---
Ooops, I just noticed that I broke the separator here. This should be a
normal --- line, obviously.
Jonathan Neuschäfer
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-02-09 16:59:13
On Fri, Feb 09, 2018 at 05:30:55PM +0200, Andy Shevchenko wrote:
On Fri, Feb 9, 2018 at 2:07 PM, Jonathan Neuschäfer
[off-list ref] wrote:
quoted
The Nintendo Wii's chipset (called "Hollywood") has a GPIO controller
that supports a configurable number of pins (up to 32), interrupts, and
some special mechanisms to share the controller between the system's
security processor (an ARM926) and the PowerPC CPU. Pin multiplexing is
not supported.
This patch adds a basic driver for this GPIO controller. Interrupt
support will come in a later patch.
This patch is based on code developed by Albert Herranz and the GameCube
Linux Team, file arch/powerpc/platforms/embedded6xx/hlwd-gpio.c,
available at https://github.com/DeltaResero/GC-Wii-Linux-Kernels, but
has grown quite dissimilar.
Fine to me, though one comment below.
In any case,
Reviewed-by: Andy Shevchenko <redacted>
[ Even if this driver isn't switched to the unified device property API,
I think "depends on OF" would be enough here, because it doesn't use
the code that's guarded by CONFIG_OF_GPIO (gpiolib-of.c), but this
applies to other drivers (e.g. gpio-aspeed, gpio-bcm-kona) as well, so
this would ideally be a bigger cleanup patch. ]
quoted
+ res = of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios);
...if you switch to unified device property API.
I don't think this change is worth making, unless/until the of_property
API is deprecated. I'm rather sure this GPIO controller won't appear in
an ACPI-based system.
Thanks,
Jonathan Neuschäfer
On Fri, Feb 9, 2018 at 1:07 PM, Jonathan Neusch=C3=A4fer
[off-list ref] wrote:
The Nintendo Wii's chipset (called "Hollywood") has a GPIO controller
that supports a configurable number of pins (up to 32), interrupts, and
some special mechanisms to share the controller between the system's
security processor (an ARM926) and the PowerPC CPU. Pin multiplexing is
not supported.
This patch adds a basic driver for this GPIO controller. Interrupt
support will come in a later patch.
This patch is based on code developed by Albert Herranz and the GameCube
Linux Team, file arch/powerpc/platforms/embedded6xx/hlwd-gpio.c,
available at https://github.com/DeltaResero/GC-Wii-Linux-Kernels, but
has grown quite dissimilar.
Signed-off-by: Jonathan Neusch=C3=A4fer <j.neuschaefer@gmx.net>
Cc: Albert Herranz <redacted>
Cc: Segher Boessenkool <redacted>
<---
v3:
- Do some style cleanups, as suggest by Andy Shevchenko
Patch applied to the GPIO tree for v4.17 with all the review tags.
I just folded the changelog into the commit message, for new
drivers it is sometimes useful to keep these around in
git actually.
If any further changes are needed we can just patch on top
of this.
It's a very pretty driver, good work!
Yours,
Linus Walleij
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-02-22 13:08:42
On Thu, Feb 22, 2018 at 01:57:07PM +0100, Linus Walleij wrote:
On Fri, Feb 9, 2018 at 1:07 PM, Jonathan Neuschäfer
[off-list ref] wrote:
quoted
The Nintendo Wii's chipset (called "Hollywood") has a GPIO controller
that supports a configurable number of pins (up to 32), interrupts, and
some special mechanisms to share the controller between the system's
security processor (an ARM926) and the PowerPC CPU. Pin multiplexing is
not supported.
This patch adds a basic driver for this GPIO controller. Interrupt
support will come in a later patch.
This patch is based on code developed by Albert Herranz and the GameCube
Linux Team, file arch/powerpc/platforms/embedded6xx/hlwd-gpio.c,
available at https://github.com/DeltaResero/GC-Wii-Linux-Kernels, but
has grown quite dissimilar.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Cc: Albert Herranz <redacted>
Cc: Segher Boessenkool <redacted>
<---
v3:
- Do some style cleanups, as suggest by Andy Shevchenko
Patch applied to the GPIO tree for v4.17 with all the review tags.
I just folded the changelog into the commit message, for new
drivers it is sometimes useful to keep these around in
git actually.
If any further changes are needed we can just patch on top
of this.
It's a very pretty driver, good work!
From: Michael Ellerman <hidden> Date: 2018-03-31 14:03:54
On Fri, 2018-02-09 at 12:07:28 UTC, =?utf-8?q?Jonathan_Neusch=C3=A4fer?= wrote:
The Hollywood chipset's GPIO controller has two sets of registers: One
for access by the PowerPC CPU, and one for access by the ARM coprocessor
(but both are accessible from the PPC because the memory firewall
(AHBPROT) is usually disabled when booting Linux, today).
The wii_power_off function currently assumes that the poweroff GPIO pin
is configured for use via the ARM side, but the upcoming GPIO driver
configures all pins for use via the PPC side, breaking poweroff.
Configure the owner register explicitly in wii_power_off to make
wii_power_off work with and without the new GPIO driver.
I think the Wii can be switched to the generic gpio-poweroff driver,
after the GPIO driver is merged.
Signed-off-by: Jonathan Neusch��fer <j.neuschaefer@gmx.net>