Skip to contentSkip to conversation

gpio: driver for the RPi3 GPIO expander

PATCH Superseded Baruch Siach 5 participants 17 messages Jan 16, 2018 – Feb 7, 2018 1 message not in the archive

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover gpio: driver for the RPi3 GPIO expander

The Raspberry Pi 3 has a GPIO expander that controls, among others, the activity LED, and the camera connector GPIOs. The GPIO expander on an I2C bus that is not directly controlled from the ARM core. The VC4 firmware controls the I2C bus, and allows the ARM core to set/get GPIO settings over its mailbox interface.

This series adds support for the RPi3 expander.

The driver is ported from the downstream kernel at
https://github.com/raspberrypi/linux/, branch rpi-4.9.y.

Changes in v3:

* Kconfig tweaks
* Check rpi_exp_gpio_get_polarity() return value
* Redundant header removal
* Redundant platform_set_drvdata() call removal
* Small coding style changes

Changes in v2:

* Driver renamed to gpio-raspberrypi-exp
* Compatible string renamed to "raspberrypi,firmware-gpio"
* Firmware error check
* Smaller tweaks listed in individual patches

Baruch Siach (3):
ARM: bcm2835: sync firmware properties with downstream
dt-bindings: gpio: add raspberry pi GPIO expander binding
ARM: dts: bcm2837-rpi-3-b: add GPIO expander

Dave Stevenson (1):
gpio: raspberrypi-exp: Driver for RPi3 GPIO expander via mailbox
service

 .../bindings/gpio/raspberrypi,firmware-gpio.txt    |  24 ++
 arch/arm/boot/dts/bcm2837-rpi-3-b.dts              |  16 ++
 drivers/gpio/Kconfig                               |   9 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-raspberrypi-exp.c                | 253 +++++++++++++++++++++
 include/soc/bcm2835/raspberrypi-firmware.h         |  18 ++
 6 files changed, 321 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt
 create mode 100644 drivers/gpio/gpio-raspberrypi-exp.c
Signature · 1 line
2.15.1
#1 lore raw

PATCH v3 1/4 ARM: bcm2835: sync firmware properties with downstream

Add latest firmware property tags from the latest Raspberry Pi downstream kernel. This is needed for the GPIO tags, so we can control the GPIO multiplexor lines.

---
v3: Add Stefan's ack

v2: No change

---
 include/soc/bcm2835/raspberrypi-firmware.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/soc/bcm2835/raspberrypi-firmware.h +18 -0
index cb979ad90401..50df5b28d2c9 100644
@@ -63,6 +63,7 @@ enum rpi_firmware_property_tag {
 	RPI_FIRMWARE_GET_MIN_VOLTAGE =                        0x00030008,
 	RPI_FIRMWARE_GET_TURBO =                              0x00030009,
 	RPI_FIRMWARE_GET_MAX_TEMPERATURE =                    0x0003000a,
+	RPI_FIRMWARE_GET_STC =                                0x0003000b,
 	RPI_FIRMWARE_ALLOCATE_MEMORY =                        0x0003000c,
 	RPI_FIRMWARE_LOCK_MEMORY =                            0x0003000d,
 	RPI_FIRMWARE_UNLOCK_MEMORY =                          0x0003000e,
@@ -72,12 +73,22 @@ enum rpi_firmware_property_tag {
 	RPI_FIRMWARE_SET_ENABLE_QPU =                         0x00030012,
 	RPI_FIRMWARE_GET_DISPMANX_RESOURCE_MEM_HANDLE =       0x00030014,
 	RPI_FIRMWARE_GET_EDID_BLOCK =                         0x00030020,
+	RPI_FIRMWARE_GET_CUSTOMER_OTP =                       0x00030021,
 	RPI_FIRMWARE_GET_DOMAIN_STATE =                       0x00030030,
 	RPI_FIRMWARE_SET_CLOCK_STATE =                        0x00038001,
 	RPI_FIRMWARE_SET_CLOCK_RATE =                         0x00038002,
 	RPI_FIRMWARE_SET_VOLTAGE =                            0x00038003,
 	RPI_FIRMWARE_SET_TURBO =                              0x00038009,
+	RPI_FIRMWARE_SET_CUSTOMER_OTP =                       0x00038021,
 	RPI_FIRMWARE_SET_DOMAIN_STATE =                       0x00038030,
+	RPI_FIRMWARE_GET_GPIO_STATE =                         0x00030041,
+	RPI_FIRMWARE_SET_GPIO_STATE =                         0x00038041,
+	RPI_FIRMWARE_SET_SDHOST_CLOCK =                       0x00038042,
+	RPI_FIRMWARE_GET_GPIO_CONFIG =                        0x00030043,
+	RPI_FIRMWARE_SET_GPIO_CONFIG =                        0x00038043,
+	RPI_FIRMWARE_GET_PERIPH_REG =                         0x00030045,
+	RPI_FIRMWARE_SET_PERIPH_REG =                         0x00038045,
+
 
 	/* Dispmanx TAGS */
 	RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE =                   0x00040001,
@@ -91,6 +102,8 @@ enum rpi_firmware_property_tag {
 	RPI_FIRMWARE_FRAMEBUFFER_GET_VIRTUAL_OFFSET =         0x00040009,
 	RPI_FIRMWARE_FRAMEBUFFER_GET_OVERSCAN =               0x0004000a,
 	RPI_FIRMWARE_FRAMEBUFFER_GET_PALETTE =                0x0004000b,
+	RPI_FIRMWARE_FRAMEBUFFER_GET_TOUCHBUF =               0x0004000f,
+	RPI_FIRMWARE_FRAMEBUFFER_GET_GPIOVIRTBUF =            0x00040010,
 	RPI_FIRMWARE_FRAMEBUFFER_RELEASE =                    0x00048001,
 	RPI_FIRMWARE_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT = 0x00044003,
 	RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT =  0x00044004,
@@ -100,6 +113,7 @@ enum rpi_firmware_property_tag {
 	RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_OFFSET =        0x00044009,
 	RPI_FIRMWARE_FRAMEBUFFER_TEST_OVERSCAN =              0x0004400a,
 	RPI_FIRMWARE_FRAMEBUFFER_TEST_PALETTE =               0x0004400b,
+	RPI_FIRMWARE_FRAMEBUFFER_TEST_VSYNC =                 0x0004400e,
 	RPI_FIRMWARE_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT =  0x00048003,
 	RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT =   0x00048004,
 	RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH =                  0x00048005,
@@ -108,6 +122,10 @@ enum rpi_firmware_property_tag {
 	RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET =         0x00048009,
 	RPI_FIRMWARE_FRAMEBUFFER_SET_OVERSCAN =               0x0004800a,
 	RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE =                0x0004800b,
+	RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF =               0x0004801f,
+	RPI_FIRMWARE_FRAMEBUFFER_SET_GPIOVIRTBUF =            0x00048020,
+	RPI_FIRMWARE_FRAMEBUFFER_SET_VSYNC =                  0x0004800e,
+	RPI_FIRMWARE_FRAMEBUFFER_SET_BACKLIGHT =              0x0004800f,
 
 	RPI_FIRMWARE_VCHIQ_INIT =                             0x00048010,
 
Signature · 1 line
2.15.1

A message that is not in the archive (sent off-list or not yet received): cover.1516105893.git.baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org

#3 lore raw

PATCH v3 2/4 dt-bindings: gpio: add raspberry pi GPIO expander binding

The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware over I2C. The firmware mailbox interface allows the ARM core to control the GPIO lines.

---
v3:
* Rename node name.

v2:
* Rename compatible string to raspberrypi,firmware-gpio

---
 .../bindings/gpio/raspberrypi,firmware-gpio.txt    | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt
Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt new file +24 -0
new file mode 100644
index 000000000000..936dc59eba12
@@ -0,0 +1,24 @@
+Raspberry Pi GPIO expander
+
+The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware. The
+firmware exposes a mailbox interface that allows the ARM core to control the
+GPIO lines on the expander.
+
+Required properties:
+
+- compatible : Should be "raspberrypi,firmware-gpio"
+- gpio-controller : Marks the device node as a gpio controller
+- #gpio-cells : Should be two.  The first cell is the pin number, and
+  the second cell is used to specify the gpio polarity:
+  0 = active high
+  1 = active low
+- firmware : Reference to the RPi firmware device node
+
+Example:
+
+expgpio: gpio-expander {
+	compatible = "raspberrypi,firmware-gpio";
+	gpio-controller;
+	#gpio-cells = <2>;
+	firmware = <&firmware>;
+};
Signature · 6 lines
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#4 lore raw

PATCH v3 2/4 dt-bindings: gpio: add raspberry pi GPIO expander binding

Quoted 31 lines · Baruch Siach

The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware over I2C. The firmware mailbox interface allows the ARM core to control the GPIO lines.

---
v3:
* Rename node name.

v2:
* Rename compatible string to raspberrypi,firmware-gpio

---
 .../bindings/gpio/raspberrypi,firmware-gpio.txt    | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt
Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt new file +9 -0
new file mode 100644
index 000000000000..936dc59eba12
@@ -0,0 +1,24 @@
+Raspberry Pi GPIO expander
+
+The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware. The
+firmware exposes a mailbox interface that allows the ARM core to control the
+GPIO lines on the expander.
+
+Required properties:
+
+- compatible : Should be "raspberrypi,firmware-gpio"

Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt new file +10 -0
+- gpio-controller : Marks the device node as a gpio controller
+- #gpio-cells : Should be two.  The first cell is the pin number, and
+  the second cell is used to specify the gpio polarity:
+  0 = active high
+  1 = active low
+- firmware : Reference to the RPi firmware device node
+
+Example:
+
+expgpio: gpio-expander {

Still not right. The correct generic node name is "gpio".

Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt line 23

Quoted 4 lines
Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt new file +4 -0
+	compatible = "raspberrypi,firmware-gpio";
+	gpio-controller;
+	#gpio-cells = <2>;
+	firmware = <&firmware>;

Can you make this a child of the firmware node instead?

Rob

#5 lore raw

PATCH v3 2/4 dt-bindings: gpio: add raspberry pi GPIO expander binding

Hi Rob,

Thanks for reviewing.

Quoted 36 lines · Rob Herring
Quoted 35 lines · Baruch Siach

The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware over I2C. The firmware mailbox interface allows the ARM core to control the GPIO lines.

---
v3:
* Rename node name.

v2:
* Rename compatible string to raspberrypi,firmware-gpio

---
 .../bindings/gpio/raspberrypi,firmware-gpio.txt    | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt
Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt new file +13 -0
new file mode 100644
index 000000000000..936dc59eba12
@@ -0,0 +1,24 @@
+Raspberry Pi GPIO expander
+
+The Raspberry Pi 3 GPIO expander is controlled by the VC4 firmware. The
+firmware exposes a mailbox interface that allows the ARM core to control the
+GPIO lines on the expander.
+
+Required properties:
+
+- compatible : Should be "raspberrypi,firmware-gpio"
+- gpio-controller : Marks the device node as a gpio controller
+- #gpio-cells : Should be two.  The first cell is the pin number, and
+  the second cell is used to specify the gpio polarity:
+  0 = active high
Quoted 8 lines

Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt line 19

Quoted 6 lines
Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt new file +6 -0
+  1 = active low
+- firmware : Reference to the RPi firmware device node
+
+Example:
+
+expgpio: gpio-expander {

Still not right. The correct generic node name is "gpio".

I'll fix that.

Quoted 6 lines

Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt line 23

Quoted 4 lines
Documentation/devicetree/bindings/gpio/raspberrypi,firmware-gpio.txt new file +4 -0
+	compatible = "raspberrypi,firmware-gpio";
+	gpio-controller;
+	#gpio-cells = <2>;
+	firmware = <&firmware>;

Can you make this a child of the firmware node instead?

I guess I can, I'll need to look into it. What is the advantage of that? What about the existing raspberrypi,bcm2835-power[1] node in bcm2835-rpi.dtsi? Should it move under the firmware node as well?

[1] Documentation/devicetree/bindings/soc/bcm/raspberrypi,bcm2835-power.txt

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#6 lore raw

PATCH v3 3/4 gpio: raspberrypi-exp: Driver for RPi3 GPIO expander via mailbox service

In reply to Baruch Siach

From: Dave Stevenson <[email protected]>

Pi3 and Compute Module 3 have a GPIO expander that the VPU communicates with.
There is a mailbox service that now allows control of this expander, so add a kernel driver that can make use of it.

---
v3:
* Tweak Kconfig driver prompt
* Make GPIO_RASPBERRYPI_EXP tristate
* Make COMPILE_TEST independent of RASPBERRYPI_FIRMWARE
* Remove redundant DMA header
* Use less code lines for dev_err()
* Check rpi_exp_gpio_get_polarity() return value
* Remove redundant platform_set_drvdata() call

v2:
* Rename driver to gpio-raspberrypi-exp
* Populate the gpiochip parent device pointer
* Use macro for the mailbox base GPIO number
* Drop linux/gpio.h and GPIOF_DIR_*
* Check and print firmware error value
* Use devm_gpiochip_add_data(); drop .remove
* A few more minor tweaks

---
 drivers/gpio/Kconfig                |   9 ++
 drivers/gpio/Makefile               |   1 +
 drivers/gpio/gpio-raspberrypi-exp.c | 253 ++++++++++++++++++++++++++++++++++++
 3 files changed, 263 insertions(+)
 create mode 100644 drivers/gpio/gpio-raspberrypi-exp.c
drivers/gpio/Kconfig +9 -0
index d6a8e851ad13..2d67b65bfec3 100644
@@ -128,6 +128,15 @@ config GPIO_AXP209
 	help
 	  Say yes to enable GPIO support for the AXP209 PMIC
 
+config GPIO_RASPBERRYPI_EXP
+	tristate "Raspberry Pi 3 GPIO Expander"
+	default RASPBERRYPI_FIRMWARE
+	depends on OF_GPIO
+	depends on (ARCH_BCM2835 && RASPBERRYPI_FIRMWARE) || COMPILE_TEST
+	help
+	  Turn on GPIO support for the expander on Raspberry Pi 3 boards, using
+	  the firmware mailbox to communicate with VideoCore on BCM283x chips.
+
 config GPIO_BCM_KONA
 	bool "Broadcom Kona GPIO"
 	depends on OF_GPIO && (ARCH_BCM_MOBILE || COMPILE_TEST)
drivers/gpio/Makefile +1 -0
index 4bc24febb889..71021b0e71da 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_GPIO_ARIZONA)	+= gpio-arizona.o
 obj-$(CONFIG_GPIO_ATH79)	+= gpio-ath79.o
 obj-$(CONFIG_GPIO_ASPEED)	+= gpio-aspeed.o
 obj-$(CONFIG_GPIO_AXP209)	+= gpio-axp209.o
+obj-$(CONFIG_GPIO_RASPBERRYPI_EXP)	+= gpio-raspberrypi-exp.o
 obj-$(CONFIG_GPIO_BCM_KONA)	+= gpio-bcm-kona.o
 obj-$(CONFIG_GPIO_BD9571MWV)	+= gpio-bd9571mwv.o
 obj-$(CONFIG_GPIO_BRCMSTB)	+= gpio-brcmstb.o
drivers/gpio/gpio-raspberrypi-exp.c new file +253 -0

253 lines not on this page · raw message

Signature · 1 line
2.15.1
#7 lore raw

PATCH v3 3/4 gpio: raspberrypi-exp: Driver for RPi3 GPIO expander via mailbox service

Hi Baruch,

Quoted 79 lines

Baruch Siach <[email protected]> hat am 16. Januar 2018 um 13:45 geschrieben:

From: Dave Stevenson <[email protected]>

Pi3 and Compute Module 3 have a GPIO expander that the VPU communicates with.
There is a mailbox service that now allows control of this expander, so add a kernel driver that can make use of it.

---
v3:
* Tweak Kconfig driver prompt
* Make GPIO_RASPBERRYPI_EXP tristate
* Make COMPILE_TEST independent of RASPBERRYPI_FIRMWARE
* Remove redundant DMA header
* Use less code lines for dev_err()
* Check rpi_exp_gpio_get_polarity() return value
* Remove redundant platform_set_drvdata() call

v2:
* Rename driver to gpio-raspberrypi-exp
* Populate the gpiochip parent device pointer
* Use macro for the mailbox base GPIO number
* Drop linux/gpio.h and GPIOF_DIR_*
* Check and print firmware error value
* Use devm_gpiochip_add_data(); drop .remove
* A few more minor tweaks

---
 drivers/gpio/Kconfig                |   9 ++
 drivers/gpio/Makefile               |   1 +
 drivers/gpio/gpio-raspberrypi-exp.c | 253 ++++++++++++++++++++++++++++++++++++
 3 files changed, 263 insertions(+)
 create mode 100644 drivers/gpio/gpio-raspberrypi-exp.c

...

drivers/gpio/gpio-raspberrypi-exp.c new file +41 -0
+
+static int rpi_exp_gpio_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct device_node *fw_node;
+	struct rpi_firmware *fw;
+	struct rpi_exp_gpio *rpi_gpio;
+
+	fw_node = of_parse_phandle(np, "firmware", 0);
+	if (!fw_node) {
+		dev_err(dev, "Missing firmware node\n");
+		return -ENOENT;
+	}
+
+	fw = rpi_firmware_get(fw_node);
+	if (!fw)
+		return -EPROBE_DEFER;
+
+	rpi_gpio = devm_kzalloc(dev, sizeof(*rpi_gpio), GFP_KERNEL);
+	if (!rpi_gpio)
+		return -ENOMEM;
+
+	rpi_gpio->fw = fw;
+	rpi_gpio->gc.parent = dev;
+	rpi_gpio->gc.label = MODULE_NAME;
+	rpi_gpio->gc.owner = THIS_MODULE;
+	rpi_gpio->gc.of_node = np;
+	rpi_gpio->gc.base = -1;
+	rpi_gpio->gc.ngpio = NUM_GPIO;
+
+	rpi_gpio->gc.direction_input = rpi_exp_gpio_dir_in;
+	rpi_gpio->gc.direction_output = rpi_exp_gpio_dir_out;
+	rpi_gpio->gc.get_direction = rpi_exp_gpio_get_direction;
+	rpi_gpio->gc.get = rpi_exp_gpio_get;
+	rpi_gpio->gc.set = rpi_exp_gpio_set;
+	rpi_gpio->gc.can_sleep = true;
+
+	return devm_gpiochip_add_data(dev, &rpi_gpio->gc, rpi_gpio);
+}
+

drivers/gpio/gpio-raspberrypi-exp.c line 243

Quoted 10 lines
drivers/gpio/gpio-raspberrypi-exp.c new file +10 -0
+static const struct of_device_id rpi_exp_gpio_ids[] = {
+	{ .compatible = "raspberrypi,firmware-gpio" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rpi_exp_gpio_ids);
+
+static struct platform_driver rpi_exp_gpio_driver = {
+	.driver	= {
+		.name		= MODULE_NAME,
+		.owner		= THIS_MODULE,

i assume you got the kbuild test robot mail about this. So please remove this and you can add my

Quoted 18 lines
drivers/gpio/gpio-raspberrypi-exp.c new file +10 -0
+		.of_match_table	= of_match_ptr(rpi_exp_gpio_ids),
+	},
+	.probe	= rpi_exp_gpio_probe,
+};
+module_platform_driver(rpi_exp_gpio_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Dave Stevenson <[email protected]>");
+MODULE_DESCRIPTION("Raspberry Pi 3 expander GPIO driver");
+MODULE_ALIAS("platform:rpi-exp-gpio");
Signature · 7 lines
2.15.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#8 lore raw

PATCH v3 4/4 ARM: dts: bcm2837-rpi-3-b: add GPIO expander

In reply to Baruch Siach

Add a description of the RPi3 GPIO expander that the VC4 firmware controls.

---
v3:
* List GPIO names one per line.

v2:
* Move GPIO expander node out of the soc container
* Rename compatible string
* Add gpio-line-names property

---
 arch/arm/boot/dts/bcm2837-rpi-3-b.dts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm/boot/dts/bcm2837-rpi-3-b.dts +16 -0
index b44b3b5af00d..8cd93425ffe3 100644
@@ -23,6 +23,22 @@
 			gpios = <&gpio 47 0>;
 		};
 	};
+
+	expgpio: gpio-expander {
+		compatible = "raspberrypi,firmware-gpio";
+		gpio-controller;
+		#gpio-cells = <2>;
+		firmware = <&firmware>;
+		gpio-line-names = "BT_ON",
+				  "WL_ON",
+				  "STATUS_LED",
+				  "LAN_RUN",
+				  "HPD_N",
+				  "CAM_GPIO0",
+				  "CAM_GPIO1",
+				  "PWR_LOW_N";
+		status = "okay";
+	};
 };
 
 /* uart0 communicates with the BT module */
Signature · 1 line
2.15.1
#9 lore raw

PATCH v3 4/4 ARM: dts: bcm2837-rpi-3-b: add GPIO expander

Hi Linus,
hi Eric,

Am 16.01.2018 um 13:45 schrieb Baruch Siach:

Quoted 20 lines

Add a description of the RPi3 GPIO expander that the VC4 firmware controls.

---
v3:
* List GPIO names one per line.

v2:
* Move GPIO expander node out of the soc container
* Rename compatible string
* Add gpio-line-names property

---
  arch/arm/boot/dts/bcm2837-rpi-3-b.dts | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
arch/arm/boot/dts/bcm2837-rpi-3-b.dts +0 -0
index b44b3b5af00d..8cd93425ffe3 100644

arch/arm/boot/dts/bcm2837-rpi-3-b.dts line 25

Quoted 3 lines
arch/arm/boot/dts/bcm2837-rpi-3-b.dts +0 -0
@@ -23,6 +23,22 @@
  			gpios = <&gpio 47 0>;
  		};
  	};

i noticed that this patch conflicts with my patch ("ARM: dts: bcm283x:
Use GPIO polarity defines consistently") in linux-next.

How should we proceed?

Quoted 19 lines
arch/arm/boot/dts/bcm2837-rpi-3-b.dts +16 -0
+
+	expgpio: gpio-expander {
+		compatible = "raspberrypi,firmware-gpio";
+		gpio-controller;
+		#gpio-cells = <2>;
+		firmware = <&firmware>;
+		gpio-line-names = "BT_ON",
+				  "WL_ON",
+				  "STATUS_LED",
+				  "LAN_RUN",
+				  "HPD_N",
+				  "CAM_GPIO0",
+				  "CAM_GPIO1",
+				  "PWR_LOW_N";
+		status = "okay";
+	};
  };
 
  /* uart0 communicates with the BT module */
#10 lore raw

PATCH v3 4/4 ARM: dts: bcm2837-rpi-3-b: add GPIO expander

Quoted 36 lines · Stefan Wahren

Hi Linus,
hi Eric,

Am 16.01.2018 um 13:45 schrieb Baruch Siach:

Quoted 23 lines

Add a description of the RPi3 GPIO expander that the VC4 firmware controls.

---
v3:
* List GPIO names one per line.

v2:
* Move GPIO expander node out of the soc container
* Rename compatible string
* Add gpio-line-names property

---
  arch/arm/boot/dts/bcm2837-rpi-3-b.dts | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
arch/arm/boot/dts/bcm2837-rpi-3-b.dts +0 -0
index b44b3b5af00d..8cd93425ffe3 100644

arch/arm/boot/dts/bcm2837-rpi-3-b.dts line 25

Quoted 3 lines
arch/arm/boot/dts/bcm2837-rpi-3-b.dts +0 -0
@@ -23,6 +23,22 @@
                        gpios = <&gpio 47 0>;
                };
        };

i noticed that this patch conflicts with my patch ("ARM: dts: bcm283x: Use GPIO polarity defines consistently") in linux-next.

Quoted 1 line

How should we proceed?

All DTS patches shall be merged through ARM SoC so the conflict should be resolved by whoever sends the pull requests to ARM SoC before sending the pull request.

I think these patches will be for the next kernel anyways, unless Torvalds think we should have an -rc9 this time (because of all the meltdowns and spectres etc you know).

Yours,
Linus Walleij

#12 lore raw

v3 cover gpio: driver for the RPi3 GPIO expander

In reply to Baruch Siach
Quoted 11 lines · Baruch Siach

The Raspberry Pi 3 has a GPIO expander that controls, among others, the activity LED, and the camera connector GPIOs. The GPIO expander on an I2C bus that is not directly controlled from the ARM core. The VC4 firmware controls the I2C bus, and allows the ARM core to set/get GPIO settings over its mailbox interface.

This series adds support for the RPi3 expander.

The driver is ported from the downstream kernel at
https://github.com/raspberrypi/linux/, branch rpi-4.9.y.

Quoted 7 lines

Changes in v3:

* Kconfig tweaks
* Check rpi_exp_gpio_get_polarity() return value
* Redundant header removal
* Redundant platform_set_drvdata() call removal
* Small coding style changes

All is looking pretty good. I see Rob had some last minute comments, but please rebase and repost post v4.16-rc1 so we can get this merged, we need to get this upstream.

Yours,
Linus Walleij

#13 lore raw

v3 cover gpio: driver for the RPi3 GPIO expander

Hi Linus,

Quoted 21 lines · Linus Walleij
Quoted 11 lines · Baruch Siach

The Raspberry Pi 3 has a GPIO expander that controls, among others, the activity LED, and the camera connector GPIOs. The GPIO expander on an I2C bus that is not directly controlled from the ARM core. The VC4 firmware controls the I2C bus, and allows the ARM core to set/get GPIO settings over its mailbox interface.

This series adds support for the RPi3 expander.

The driver is ported from the downstream kernel at
https://github.com/raspberrypi/linux/, branch rpi-4.9.y.

Quoted 7 lines

Changes in v3:

* Kconfig tweaks
* Check rpi_exp_gpio_get_polarity() return value
* Redundant header removal
* Redundant platform_set_drvdata() call removal
* Small coding style changes

Quoted 3 lines

All is looking pretty good. I see Rob had some last minute comments, but please rebase and repost post v4.16-rc1 so we can get this merged, we need to get this upstream.

I was about to send v4 when I saw your email. I based v4 on current LinusT's tree as of e237f98a9c. I guess that affected files will not change before v4.16-rc1, but I can wait a few more days for -rc1.

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
#14 lore raw

v3 cover gpio: driver for the RPi3 GPIO expander

Quoted 22 lines · Baruch Siach
Quoted 21 lines · Linus Walleij
Quoted 18 lines · Baruch Siach

The Raspberry Pi 3 has a GPIO expander that controls, among others, the activity LED, and the camera connector GPIOs. The GPIO expander on an I2C bus that is not directly controlled from the ARM core. The VC4 firmware controls the I2C bus, and allows the ARM core to set/get GPIO settings over its mailbox interface.

This series adds support for the RPi3 expander.

The driver is ported from the downstream kernel at
https://github.com/raspberrypi/linux/, branch rpi-4.9.y.

Changes in v3:

* Kconfig tweaks
* Check rpi_exp_gpio_get_polarity() return value
* Redundant header removal
* Redundant platform_set_drvdata() call removal
* Small coding style changes

Quoted 7 lines
Quoted 3 lines

All is looking pretty good. I see Rob had some last minute comments, but please rebase and repost post v4.16-rc1 so we can get this merged, we need to get this upstream.

I was about to send v4 when I saw your email. I based v4 on current LinusT's tree as of e237f98a9c. I guess that affected files will not change before v4.16-rc1, but I can wait a few more days for -rc1.

It's fine to send if you feel it is ready. I am already queueing stuff for v4.17.

Yours,
Linus Walleij

#15 lore raw

v3 cover gpio: driver for the RPi3 GPIO expander

In reply to Baruch Siach

Hi Baruch,

Am 06.02.2018 um 17:27 schrieb Baruch Siach:

Quoted 23 lines

Hi Linus,

Quoted 20 lines · Linus Walleij
Quoted 18 lines · Baruch Siach

The Raspberry Pi 3 has a GPIO expander that controls, among others, the activity LED, and the camera connector GPIOs. The GPIO expander on an I2C bus that is not directly controlled from the ARM core. The VC4 firmware controls the I2C bus, and allows the ARM core to set/get GPIO settings over its mailbox interface.

This series adds support for the RPi3 expander.

The driver is ported from the downstream kernel at
https://github.com/raspberrypi/linux/, branch rpi-4.9.y.

Changes in v3:

* Kconfig tweaks
* Check rpi_exp_gpio_get_polarity() return value
* Redundant header removal
* Redundant platform_set_drvdata() call removal
* Small coding style changes

Quoted 9 lines
Quoted 3 lines

All is looking pretty good. I see Rob had some last minute comments, but please rebase and repost post v4.16-rc1 so we can get this merged, we need to get this upstream.

I was about to send v4 when I saw your email. I based v4 on current LinusT's tree as of e237f98a9c. I guess that affected files will not change before v4.16-rc1, but I can wait a few more days for -rc1.

baruch

please also address the owner issue in the driver, which was reported by kbuild test robot.

Thanks

Stefan

#16 lore raw

v3 cover gpio: driver for the RPi3 GPIO expander

Hi Stefan,

Quoted 25 lines · Stefan Wahren

Am 06.02.2018 um 17:27 schrieb Baruch Siach:

Quoted 24 lines · Linus Walleij
Quoted 23 lines · Baruch Siach
Quoted 12 lines

The Raspberry Pi 3 has a GPIO expander that controls, among others, the activity LED, and the camera connector GPIOs. The GPIO expander on an I2C bus that is not directly controlled from the ARM core. The VC4 firmware controls the I2C bus, and allows the ARM core to set/get GPIO settings over its mailbox interface.

This series adds support for the RPi3 expander.

The driver is ported from the downstream kernel at
https://github.com/raspberrypi/linux/, branch rpi-4.9.y.

Quoted 7 lines

Changes in v3:

* Kconfig tweaks
* Check rpi_exp_gpio_get_polarity() return value
* Redundant header removal
* Redundant platform_set_drvdata() call removal
* Small coding style changes

All is looking pretty good. I see Rob had some last minute comments, but please rebase and repost post v4.16-rc1 so we can get this merged, we need to get this upstream.

Quoted 6 lines
Quoted 3 lines

I was about to send v4 when I saw your email. I based v4 on current LinusT's tree as of e237f98a9c. I guess that affected files will not change before v4.16-rc1, but I can wait a few more days for -rc1.

please also address the owner issue in the driver, which was reported by kbuild test robot.

I removed the .owner platform_driver field set from v4. The owner field in gpio_chip is still set.

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#17 lore raw

v3 cover gpio: driver for the RPi3 GPIO expander

Am 07.02.2018 um 10:38 schrieb Baruch Siach:

Quoted 28 lines

Hi Stefan,

Quoted 25 lines · Stefan Wahren

Am 06.02.2018 um 17:27 schrieb Baruch Siach:

Quoted 24 lines · Linus Walleij
Quoted 23 lines · Baruch Siach
Quoted 12 lines

The Raspberry Pi 3 has a GPIO expander that controls, among others, the activity LED, and the camera connector GPIOs. The GPIO expander on an I2C bus that is not directly controlled from the ARM core. The VC4 firmware controls the I2C bus, and allows the ARM core to set/get GPIO settings over its mailbox interface.

This series adds support for the RPi3 expander.

The driver is ported from the downstream kernel at
https://github.com/raspberrypi/linux/, branch rpi-4.9.y.

Quoted 7 lines

Changes in v3:

* Kconfig tweaks
* Check rpi_exp_gpio_get_polarity() return value
* Redundant header removal
* Redundant platform_set_drvdata() call removal
* Small coding style changes

All is looking pretty good. I see Rob had some last minute comments, but please rebase and repost post v4.16-rc1 so we can get this merged, we need to get this upstream.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I was about to send v4 when I saw your email. I based v4 on current LinusT's tree as of e237f98a9c. I guess that affected files will not change before v4.16-rc1, but I can wait a few more days for -rc1.

please also address the owner issue in the driver, which was reported by kbuild test robot.

I removed the .owner platform_driver field set from v4. The owner field in gpio_chip is still set.

perfect

Quoted 3 lines

baruch