Introduce support for Vortex GPIO pins
Subsystems (4)
v4 cover Introduce support for Vortex GPIO pins
This series of patches add support for the GPIO pins exposed on the southbridge most DM&P's Vortex86 SoCs, using a new GPIO driver plus a MFD driver to automatically load the driver in supported platforms.
Supported SoCs are Vortex86SX/MX/MX+/DX/DX2/DX3, though I have only personally tried with a MX and a DX3.
Marcos Del Sol Vives (3):
gpio: gpio-regmap: add flag to set direction before value
gpio: vortex: add new GPIO device driver
mfd: vortex: implement new driver for Vortex southbridges
MAINTAINERS | 6 ++ drivers/gpio/Kconfig | 13 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-regmap.c | 17 +++- drivers/gpio/gpio-vortex.c | 170 ++++++++++++++++++++++++++++++++++++ drivers/mfd/Kconfig | 9 ++ drivers/mfd/Makefile | 1 + drivers/mfd/vortex-sb.c | 135 ++++++++++++++++++++++++++++ include/linux/gpio/regmap.h | 19 ++++ include/linux/pci_ids.h | 3 + 10 files changed, 373 insertions(+), 1 deletion(-) create mode 100644 drivers/gpio/gpio-vortex.c create mode 100644 drivers/mfd/vortex-sb.c
Signature · 1 line
2.34.1
PATCH v4 1/3 gpio: gpio-regmap: add flag to set direction before value
When configuring a pin as an output, by default the gpio-regmap driver writes first the value and then configures the direction.
The Vortex86 family of SoCs, however, need the direction set before the value, else writes to the data ports are ignored.
This commit adds a new "flags" field plus a flag to reverse that order, allowing the direction to be set before the value.
Also, added a missing error check in gpio_regmap_direction_output().
--- drivers/gpio/gpio-regmap.c | 17 ++++++++++++++++- include/linux/gpio/regmap.h | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/gpio/gpio-regmap.c +16 -1
@@ -31,6 +31,7 @@ struct gpio_regmap {unsigned int reg_clr_base;unsigned int reg_dir_in_base;unsigned int reg_dir_out_base; +unsigned int flags; int (*reg_mask_xlate)(struct gpio_regmap *gpio, unsigned int base, unsigned int offset, unsigned int *reg,
@@ -196,7 +197,20 @@ static int gpio_regmap_direction_input(struct gpio_chip *chip,static int gpio_regmap_direction_output (struct gpio_chip *chip,unsigned int offset,int value) { -gpio_regmap_set (chip, offset, value); +struct gpio_regmap *gpio =gpiochip_get_data (chip); +int ret; + +if (gpio->flags &GPIO_REGMAP_DIR_BEFORE_SET ) { + ret =gpio_regmap_set_direction (chip, offset, true); +if (ret) +return ret; + +return gpio_regmap_set (chip, offset, value); + } + + ret =gpio_regmap_set (chip, offset, value); +if (ret) +return ret;return gpio_regmap_set_direction (chip, offset, true); }
@@ -247,6 +261,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config gpio->reg_clr_base = config->reg_clr_base; gpio->reg_dir_in_base = config->reg_dir_in_base; gpio->reg_dir_out_base = config->reg_dir_out_base; + gpio->flags = config->flags; chip = &gpio->gpio_chip; chip->parent = config->parent;
include/linux/gpio/regmap.h +18 -0
@@ -3,6 +3,8 @@#ifndef _LINUX_GPIO_REGMAP_H#define _LINUX_GPIO_REGMAP_H +#include <linux/bits.h> +struct device ;struct fwnode_handle ;struct gpio_regmap ;
@@ -12,6 +14,19 @@ struct regmap;#define GPIO_REGMAP_ADDR_ZERO ((unsigned int)(-1))#define GPIO_REGMAP_ADDR (addr) ((addr) ? : GPIO_REGMAP_ADDR_ZERO) +/** +* enum gpio_regmap_flags - flags to control GPIO operation +*/ +enum gpio_regmap_flags { +/** +* @GPIO_REGMAP_DIR_BEFORE_SET: when setting a pin as an output, set +* its direction before the value. The output value will be undefined +* for a short time which may have unwanted side effects, but some +* hardware requires this. +*/ +GPIO_REGMAP_DIR_BEFORE_SET =BIT (0 ), +}; +/** * struct gpio_regmap_config - Description of a generic regmap gpio_chip. * @parent: The parent device
@@ -23,6 +38,8 @@ struct regmap;* If not given, the name of the device is used. * @ngpio: (Optional) Number of GPIOs * @names: (Optional) Array of names for gpios +* @flags: (Optional) A bitmask of flags from +* &enum gpio_regmap_flags * @reg_dat_base: (Optional) (in) register base address * @reg_set_base: (Optional) set register base address * @reg_clr_base: (Optional) clear register base address
@@ -68,6 +85,7 @@ struct gpio_regmap_config {const char *label;int ngpio;const char *const *names; +unsigned int flags;unsigned int reg_dat_base;unsigned int reg_set_base;
Signature · 1 line
2.34.1
PATCH v4 2/3 gpio: vortex: add new GPIO device driver
In reply to Marcos Del Sol VivesAdd a new simple GPIO device driver for most DM&P Vortex86 SoCs, implemented according to their programming reference manuals [1][2][3].
Vortex86EX/EX2 use a radically different mechanism of GPIO control and are not supported by this driver.
This is required for detecting the status of the poweroff button and performing the poweroff sequence on ICOP eBox computers.
IRQs are not implemented, as they are only available for ports 0 and 1, none which are accessible on my test machine (an EBOX-3352-GLW).
[1]: https://www.vortex86.com/downloadsStart?serial=Vortex86SX/DX/MXPLUS
[2]: https://www.vortex86.com/downloadsStart?serial=Vortex86DX2
[3]: https://www.vortex86.com/downloadsStart?serial=Vortex86DX3
--- MAINTAINERS | 5 ++ drivers/gpio/Kconfig | 13 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-vortex.c | 170 +++++++++++++++++++++++++++++++++++++ 4 files changed, 189 insertions(+) create mode 100644 drivers/gpio/gpio-vortex.c
MAINTAINERS +5 -0
@@ -26953,6 +26953,11 @@ VOLTAGE AND CURRENT REGULATOR IRQ HELPERS R: Matti Vaittinen <[email protected]> F: drivers/regulator/irq_helpers.c +VORTEX HARDWARE SUPPORT +R: Marcos Del Sol Vives <[email protected]> +S: Maintained +F: drivers/gpio/gpio-vortex.c + VRF M: David Ahern <[email protected]> L: [email protected]
drivers/gpio/Kconfig +13 -0
@@ -1077,6 +1077,19 @@ config GPIO_TS5500 blocks of the TS-5500: DIO1, DIO2 and the LCD port, and the TS-5600 LCD port. +config GPIO_VORTEX + tristate "Vortex SoC GPIO support" + select REGMAP_MMIO + select GPIO_REGMAP + help + Driver to access the 8-bit bidirectional GPIO ports present on DM&P + Vortex86SX/MX/MX+/DX/DX2/DX3 SoCs. + + Vortex86EX-series parts are not supported. + + To compile this driver as a module, choose M here: the module will + be called gpio-vortex. + config GPIO_WINBOND tristate "Winbond Super I/O GPIO support" select ISA_BUS_API
drivers/gpio/Makefile +1 -0
@@ -197,6 +197,7 @@ obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o obj-$(CONFIG_GPIO_VIRTUSER) += gpio-virtuser.o obj-$(CONFIG_GPIO_VIRTIO) += gpio-virtio.o obj-$(CONFIG_GPIO_VISCONTI) += gpio-visconti.o +obj-$(CONFIG_GPIO_VORTEX) += gpio-vortex.o obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o obj-$(CONFIG_GPIO_WCD934X) += gpio-wcd934x.o obj-$(CONFIG_GPIO_WHISKEY_COVE) += gpio-wcove.o
drivers/gpio/gpio-vortex.c new file +170 -0
170 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v4 2/3] gpio: vortex: add new GPIO device driver
Quoted 9 lines · Marcos Del Sol Vives
Add a new simple GPIO device driver for most DM&P Vortex86 SoCs, implemented according to their programming reference manuals [1][2][3].
Vortex86EX/EX2 use a radically different mechanism of GPIO control and are not supported by this driver.
This is required for detecting the status of the poweroff button and performing the poweroff sequence on ICOP eBox computers.
Quoted 8 lines
IRQs are not implemented, as they are only available for ports 0 and 1, none which are accessible on my test machine (an EBOX-3352-GLW).
[1]: https://www.vortex86.com/downloadsStart?serial=Vortex86SX/DX/MXPLUS
[2]: https://www.vortex86.com/downloadsStart?serial=Vortex86DX2
[3]: https://www.vortex86.com/downloadsStart?serial=Vortex86DX3Signed-off-by Marcos Del Sol Vives <[email protected]>
Hi Marcos,
Thank you for taking the time to develop and improve this driver. It can be intimidating to submit patches and interface changes for public review (especially without the help of the hardware company), so I commend your continual efforts.
Regarding this GPIO driver, you've incorporated much of what I had intended to comment on for your v2, so I'm comfortable leaving an Ack for this version here.
However, I do have a couple minor suggestions below if you decide to submit a v5.
MAINTAINERS VOLTAGE AND CURRENT REGULATOR IRQ HELPERS · line 26959
Quoted 4 lines
MAINTAINERS +4
-0+VORTEX HARDWARE SUPPORT +R: Marcos Del Sol Vives <[email protected]> +S: Maintained +F: drivers/gpio/gpio-vortex.c
This driver only covers GPIO support so a better title for this MAINTAINERS entry would be "VORTEX86 GPIO SUPPORT".
drivers/gpio/gpio-vortex.c line 139
Quoted 5 lines
drivers/gpio/gpio-vortex.c new file +5
-0+ rmcfg.reg_bits =8 ; + rmcfg.val_bits =8 ; + rmcfg.io_port = true; + rmcfg.wr_table = &priv->access_table; + rmcfg.rd_table = &priv->access_table;
The direction ports are expected to hold their previous state until they are changed, so perhaps it would be beneficial to enable caching with a rmcfg.cache_type = REGCACHE_FLAT and set a volatile_table which excludes the data port range.
William Breathitt Gray
PATCH v4 3/3 mfd: vortex: implement new driver for Vortex southbridges
In reply to Marcos Del Sol VivesThis new driver loads resources related to southbridges available in DM&P Vortex devices, currently only the GPIO pins.
--- MAINTAINERS | 1 + drivers/mfd/Kconfig | 9 +++ drivers/mfd/Makefile | 1 + drivers/mfd/vortex-sb.c | 135 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 3 + 5 files changed, 149 insertions(+) create mode 100644 drivers/mfd/vortex-sb.c
MAINTAINERS +1 -0
@@ -26957,6 +26957,7 @@ VORTEX HARDWARE SUPPORT R: Marcos Del Sol Vives <[email protected]> S: Maintained F: drivers/gpio/gpio-vortex.c +F: drivers/mfd/vortex-sb.c VRF M: David Ahern <[email protected]>
drivers/mfd/Kconfig +9 -0
@@ -2008,6 +2008,15 @@ config MFD_VX855 VIA VX855/VX875 south bridge. You will need to enable the vx855_spi and/or vx855_gpio drivers for this to do anything useful. +config MFD_VORTEX_SB + tristate "Vortex southbridge" + select MFD_CORE + depends on PCI + help + Say yes here if you want to have support for the southbridge + present on Vortex SoCs. You will need to enable the vortex-gpio + driver for this to do anything useful. + config MFD_ARIZONA select REGMAP select REGMAP_IRQ
drivers/mfd/Makefile +1 -0
@@ -202,6 +202,7 @@ obj-$(CONFIG_MFD_JANZ_CMODIO) += janz-cmodio.o obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o obj-$(CONFIG_MFD_VX855) += vx855.o obj-$(CONFIG_MFD_WL1273_CORE) += wl1273-core.o +obj-$(CONFIG_MFD_VORTEX_SB) += vortex-sb.o si476x-core-y := si476x-cmd.o si476x-prop.o si476x-i2c.o obj-$(CONFIG_MFD_SI476X_CORE) += si476x-core.o
drivers/mfd/vortex-sb.c new file +135 -0
135 lines not on this page · raw message
include/linux/pci_ids.h +3 -0
@@ -2412,6 +2412,9 @@#define PCI_VENDOR_ID_RDC 0x17f3#define PCI_DEVICE_ID_RDC_R6020 0x6020#define PCI_DEVICE_ID_RDC_R6030 0x6030 +#define PCI_DEVICE_ID_RDC_R6031 0x6031 +#define PCI_DEVICE_ID_RDC_R6035 0x6035 +#define PCI_DEVICE_ID_RDC_R6036 0x6036#define PCI_DEVICE_ID_RDC_R6040 0x6040#define PCI_DEVICE_ID_RDC_R6060 0x6060#define PCI_DEVICE_ID_RDC_R6061 0x6061
Signature · 1 line
2.34.1
Lee Jones
maintainerRe: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 63 lines · Marcos Del Sol Vives
This new driver loads resources related to southbridges available in DM&P Vortex devices, currently only the GPIO pins.
Signed-off-by Marcos Del Sol Vives <[email protected]>--- MAINTAINERS | 1 + drivers/mfd/Kconfig | 9 +++ drivers/mfd/Makefile | 1 + drivers/mfd/vortex-sb.c | 135 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 3 + 5 files changed, 149 insertions(+) create mode 100644 drivers/mfd/vortex-sb.cMAINTAINERS +1
-0@@ -26957,6 +26957,7 @@ VORTEX HARDWARE SUPPORT R: Marcos Del Sol Vives <[email protected]> S: Maintained F: drivers/gpio/gpio-vortex.c +F: drivers/mfd/vortex-sb.c VRF M: David Ahern <[email protected]>drivers/mfd/Kconfig +9
-0@@ -2008,6 +2008,15 @@ config MFD_VX855 VIA VX855/VX875 south bridge. You will need to enable the vx855_spi and/or vx855_gpio drivers for this to do anything useful. +config MFD_VORTEX_SB + tristate "Vortex southbridge" + select MFD_CORE + depends on PCI + help + Say yes here if you want to have support for the southbridge + present on Vortex SoCs. You will need to enable the vortex-gpio + driver for this to do anything useful. + config MFD_ARIZONA select REGMAP select REGMAP_IRQdrivers/mfd/Makefile +1
-0@@ -202,6 +202,7 @@ obj-$(CONFIG_MFD_JANZ_CMODIO) += janz-cmodio.o obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o obj-$(CONFIG_MFD_VX855) += vx855.o obj-$(CONFIG_MFD_WL1273_CORE) += wl1273-core.o +obj-$(CONFIG_MFD_VORTEX_SB) += vortex-sb.o si476x-core-y := si476x-cmd.o si476x-prop.o si476x-i2c.o obj-$(CONFIG_MFD_SI476X_CORE) += si476x-core.odrivers/mfd/vortex-sb.c new file +0
-0
drivers/mfd/vortex-sb.c line 3
Quoted 3 lines
drivers/mfd/vortex-sb.c new file +3
-0@@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* MFD southbridge driver for Vortex SoCs
Drop references to MFD.
Call it "Core southbridge ..."
drivers/mfd/vortex-sb.c line 7
Quoted 4 lines
drivers/mfd/vortex-sb.c new file +4
-0+* +* Author: Marcos Del Sol Vives <[email protected]> +* +* Based on the RDC321x MFD driver by Florian Fainelli and Bernhard Loos
Drop this.
drivers/mfd/vortex-sb.c line 14
Quoted 7 lines
drivers/mfd/vortex-sb.c new file +7
-0+*/ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/pci.h> +#include <linux/mfd/core.h>
Alphabetical.
drivers/mfd/vortex-sb.c line 19
Quoted 5 lines
drivers/mfd/vortex-sb.c new file +5
-0+ +struct vortex_southbridge { +const struct mfd_cell *cells; +int n_cells; +};
Why is this needed?
drivers/mfd/vortex-sb.c line 25
Quoted 5 lines
drivers/mfd/vortex-sb.c new file +5
-0+/* Layout for Vortex86DX/MX */ +static const struct resource vortex_dx_gpio_resources[] = { + { + .name ="dat1" , + .start =0x78 ,
Define _all_ magic numbers.
drivers/mfd/vortex-sb.c line 33
Quoted 8 lines
drivers/mfd/vortex-sb.c new file +8
-0+ .end = 0x7C, + .flags = IORESOURCE_IO, + }, { + .name = "dir1", + .start = 0x98, + .end = 0x9C, + .flags = IORESOURCE_IO, + }
Use DEFINE_RES_*() macros.
drivers/mfd/vortex-sb.c line 42
Quoted 9 lines
drivers/mfd/vortex-sb.c new file +9
-0+}; + +static const struct mfd_cell vortex_dx_sb_cells[] = { + { + .name ="vortex-gpio" , + .resources = vortex_dx_gpio_resources, + .num_resources =ARRAY_SIZE (vortex_dx_gpio_resources), + }, +};
It's not an MFD until you have more than one device.
Quoted 19 lines
drivers/mfd/vortex-sb.c new file +19
-0+static const struct vortex_southbridge vortex_dx_sb = { + .cells = vortex_dx_sb_cells, + .n_cells =ARRAY_SIZE (vortex_dx_sb_cells), +}; + +/* Layout for Vortex86DX2/DX3 */ +static const struct resource vortex_dx2_gpio_resources[] = { + { + .name ="dat1" , + .start =0x78 , + .end =0x7C , + .flags =IORESOURCE_IO , + }, { + .name ="dat2" , + .start =0x100 , + .end =0x105 , + .flags =IORESOURCE_IO , + }, { + .name ="dir1" ,
drivers/mfd/vortex-sb.c line 72
Quoted 10 lines
drivers/mfd/vortex-sb.c new file +10
-0+ .start = 0x98, + .end = 0x9D, + .flags = IORESOURCE_IO, + }, { + .name = "dir2", + .start = 0x93, + .end = 0x97, + .flags = IORESOURCE_IO, + } +};
As above.
Quoted 5 lines
drivers/mfd/vortex-sb.c new file +5
-0+static const struct mfd_cell vortex_dx2_sb_cells[] = { + { + .name ="vortex-gpio" , + .resources = vortex_dx2_gpio_resources, + .num_resources =ARRAY_SIZE (vortex_dx2_gpio_resources),
drivers/mfd/vortex-sb.c line 88
Quoted 10 lines
drivers/mfd/vortex-sb.c new file +10
-0+ }, +}; + +static const struct vortex_southbridge vortex_dx2_sb = { + .cells = vortex_dx2_sb_cells, + .n_cells =ARRAY_SIZE (vortex_dx2_sb_cells), +}; + +static int vortex_sb_probe (struct pci_dev *pdev, +const struct pci_device_id *ent)
Why line-feed here and not 2 lines down?
drivers/mfd/vortex-sb.c line 87
Quoted 2 lines
drivers/mfd/vortex-sb.c new file +2
-0+{ +struct vortex_southbridge *priv = (struct vortex_southbridge *) ent->driver_data;
s/priv/ddata/
Quoted 16 lines
drivers/mfd/vortex-sb.c new file +16
-0+int err; + +/* +* In the Vortex86DX3, the southbridge appears twice (on both 00:07.0 +* and 00:07.1). Register only once for .0. +* +* Other Vortex boards (eg Vortex86MX+) have the southbridge exposed +* only once, also at 00:07.0. +*/ +if (PCI_FUNC (pdev->devfn) !=0 ) +return -ENODEV ; + + err =pci_enable_device (pdev); +if (err) { +dev_err (&pdev->dev,"failed to enable device\n" ); +return err;
drivers/mfd/vortex-sb.c line 116
Quoted 10 lines
drivers/mfd/vortex-sb.c new file +10
-0+ } + +return devm_mfd_add_devices (&pdev->dev,PLATFORM_DEVID_NONE , + priv->cells, priv->n_cells, +NULL ,0 ,NULL ); +} + +static const struct pci_device_id vortex_sb_table[] = { +/* Vortex86DX */ + {PCI_DEVICE_DATA (RDC ,R6031 , &vortex_dx_sb) },
We're not passing one initialisation API's data (MFD) through another (PCI).
Pass a device ID (if you don't already have one) and match on that instead.
Quoted 4 lines
drivers/mfd/vortex-sb.c new file +4
-0+/* Vortex86DX2/DX3 */ + { PCI_DEVICE_DATA(RDC, R6035, &vortex_dx2_sb) }, +/* Vortex86MX */ + { PCI_DEVICE_DATA(RDC, R6036, &vortex_dx_sb) },
drivers/mfd/vortex-sb.c line 130
Quoted 10 lines
drivers/mfd/vortex-sb.c new file +10
-0+ {} +}; +MODULE_DEVICE_TABLE (pci, vortex_sb_table); + +static struct pci_driver vortex_sb_driver = { + .name ="vortex-sb" , + .id_table = vortex_sb_table, + .probe = vortex_sb_probe, +}; +
Remove this line.
Quoted 22 lines
drivers/mfd/vortex-sb.c new file +5
-0+module_pci_driver (vortex_sb_driver); + +MODULE_AUTHOR ("Marcos Del Sol Vives <[email protected]>" ); +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("Vortex MFD southbridge driver" );include/linux/pci_ids.h +3
-0@@ -2412,6 +2412,9 @@#define PCI_VENDOR_ID_RDC 0x17f3#define PCI_DEVICE_ID_RDC_R6020 0x6020#define PCI_DEVICE_ID_RDC_R6030 0x6030 +#define PCI_DEVICE_ID_RDC_R6031 0x6031 +#define PCI_DEVICE_ID_RDC_R6035 0x6035 +#define PCI_DEVICE_ID_RDC_R6036 0x6036#define PCI_DEVICE_ID_RDC_R6040 0x6040#define PCI_DEVICE_ID_RDC_R6060 0x6060#define PCI_DEVICE_ID_RDC_R6061 0x6061Signature · 1 line
2.34.1
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 8 lines · Lee Jones
drivers/mfd/vortex-sb.c line 19
Quoted 5 lines
drivers/mfd/vortex-sb.c new file +5
-0+ +struct vortex_southbridge { +const struct mfd_cell *cells; +int n_cells; +};Why is this needed?
To have a variable amount of cells. Currently I am only implementing the GPIO device because it's the most critical (required for device shutdown), but I plan on implementing once this gets merged at least also the watchdog, which is provided by the same southbridge.
Adding support for this is should make adding that simpler.
Quoted 9 lines
drivers/mfd/vortex-sb.c line 42
Quoted 7 lines
drivers/mfd/vortex-sb.c new file +7
-0+static const struct mfd_cell vortex_dx_sb_cells[] = { + { + .name ="vortex-gpio" , + .resources = vortex_dx_gpio_resources, + .num_resources =ARRAY_SIZE (vortex_dx_gpio_resources), + }, +};It's not an MFD until you have more than one device.
Same as above.
Quoted 5 lines
drivers/mfd/vortex-sb.c line 116
Quoted 3 lines
drivers/mfd/vortex-sb.c new file +3
-0+static const struct pci_device_id vortex_sb_table[] = { +/* Vortex86DX */ + {PCI_DEVICE_DATA (RDC ,R6031 , &vortex_dx_sb) },We're not passing one initialisation API's data (MFD) through another (PCI).
Unless I understood you incorrectly, you mean I should not pass MFD cells/ data as private data?
vortex_dx_sb are "struct vortex_southbridge" type, not raw MFD API data.
Lee Jones
maintainerRe: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 10 lines · Marcos Del Sol Vives
Quoted 8 lines · Lee Jones
drivers/mfd/vortex-sb.c line 19
Quoted 5 lines
drivers/mfd/vortex-sb.c new file +5
-0+ +struct vortex_southbridge { +const struct mfd_cell *cells; +int n_cells; +};Why is this needed?
Quoted 6 lines
To have a variable amount of cells. Currently I am only implementing the GPIO device because it's the most critical (required for device shutdown), but I plan on implementing once this gets merged at least also the watchdog, which is provided by the same southbridge.
Adding support for this is should make adding that simpler.
You don't need it. Please find another way to achieve your goal.
Quoted 11 lines
Quoted 9 lines
drivers/mfd/vortex-sb.c line 42
Quoted 7 lines
drivers/mfd/vortex-sb.c new file +7
-0+static const struct mfd_cell vortex_dx_sb_cells[] = { + { + .name ="vortex-gpio" , + .resources = vortex_dx_gpio_resources, + .num_resources =ARRAY_SIZE (vortex_dx_gpio_resources), + }, +};It's not an MFD until you have more than one device.
Same as above.
It will not be accepted with only a single device (SFD?).
Quoted 8 lines
Quoted 5 lines
drivers/mfd/vortex-sb.c line 116
Quoted 3 lines
drivers/mfd/vortex-sb.c new file +3
-0+static const struct pci_device_id vortex_sb_table[] = { +/* Vortex86DX */ + {PCI_DEVICE_DATA (RDC ,R6031 , &vortex_dx_sb) },We're not passing one initialisation API's data (MFD) through another (PCI).
Unless I understood you incorrectly, you mean I should not pass MFD cells/ data as private data?
Right.
Quoted 1 line
vortex_dx_sbare "structvortex_southbridge" type, not raw MFD API data.
I like your style, but nope!
vortex_southbridge contains MFD data and shouldn't exist anyway.
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 5 lines · Lee Jones
Quoted 1 line
vortex_dx_sbare "structvortex_southbridge" type, not raw MFD API data.I like your style, but nope!
vortex_southbridgecontains MFD data and shouldn't exist anyway.
I'm not sure if I follow.
You're suggesting not using driver_data at all and using a big "if" instead, matching manually myself on the correct cells to register against the PCI device ID, instead of relying on PCI matching giving me already the cells structure inside driver_data?
That seems to increase code size and be more error prone for no reason.
Lee Jones
maintainerRe: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 5 lines · Marcos Del Sol Vives
Quoted 4 lines · Lee Jones
Quoted 1 line
vortex_dx_sbare "structvortex_southbridge" type, not raw MFD API data.I like your style, but nope!
Quoted 8 lines
Quoted 1 line
vortex_southbridgecontains MFD data and shouldn't exist anyway.I'm not sure if I follow.
You're suggesting not using
driver_dataat all and using a big "if" instead, matching manually myself on the correct cells to register against the PCI device ID, instead of relying on PCI matching giving me already the cells structure insidedriver_data?
Yes.
Quoted 1 line
That seems to increase code size and be more error prone for no reason.
It may make sense for your use-case, but believe me, I've seen some crazy implementations of this. I found it's easier just to have a no cross contamination of early init APSs rule and call it a day.
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
In reply to Lee JonesQuoted 10 lines · Lee Jones
Quoted 10 lines
Quoted 9 lines
drivers/mfd/vortex-sb.c line 42
Quoted 7 lines
drivers/mfd/vortex-sb.c new file +7
-0+static const struct mfd_cell vortex_dx_sb_cells[] = { + { + .name ="vortex-gpio" , + .resources = vortex_dx_gpio_resources, + .num_resources =ARRAY_SIZE (vortex_dx_gpio_resources), + }, +};It's not an MFD until you have more than one device.
Quoted 4 lines
Quoted 1 line
Same as above.
It will not be accepted with only a single device (SFD?).
I've been working on making all the changes, except this one.
If you prefer, I can either implement the watchdog now, add it on this patch series and thus make it a proper MFD (at the cost of delaying even further the GPIO inclusion), or keep the struct mfd_cell array as a single-element array and implement the watchdog later on another merge request, using that very same array.
I am however not okay with wasting my time rewriting that to bypass the MFD API for this, so I can waste even more time later implementing again the MFD API, just because linguistically one (right now) is technically not "multi".
That seems very unreasonable, specially when it wouldn't be a first since at least these other devices are also using MFD with a single device:
- 88pm800
- 88pm805
- at91-usart
- stw481x
- vx855
- wm8400
- zynqmp (last changed in 2024, so certainly not legacy!)
And probably others since I did not look too deep into it.
Greetings,
Marcos
Lee Jones
maintainerRe: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 11 lines · Marcos Del Sol Vives
Quoted 10 lines · Lee Jones
Quoted 10 lines
Quoted 9 lines
drivers/mfd/vortex-sb.c line 42
Quoted 7 lines
drivers/mfd/vortex-sb.c new file +7
-0+static const struct mfd_cell vortex_dx_sb_cells[] = { + { + .name ="vortex-gpio" , + .resources = vortex_dx_gpio_resources, + .num_resources =ARRAY_SIZE (vortex_dx_gpio_resources), + }, +};It's not an MFD until you have more than one device.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Same as above.
It will not be accepted with only a single device (SFD?).
I've been working on making all the changes, except this one.
If you prefer, I can either implement the watchdog now, add it on this
Yes, please implement the WDT now.
Quoted 9 lines
patch series and thus make it a proper MFD (at the cost of delaying even further the GPIO inclusion), or keep the struct
mfd_cellarray as a single-element array and implement the watchdog later on another merge request, using that very same array.I am however not okay with wasting my time rewriting that to bypass the MFD API for this, so I can waste even more time later implementing again the MFD API, just because linguistically one (right now) is technically not "multi".
I don't get this. If you implement the WDT now, you will be "multi", so what are you protesting against?
Quoted 5 lines
That seems very unreasonable, specially when it wouldn't be a first since at least these other devices are also using MFD with a single device:
- 88pm80
% grep name drivers/mfd/88pm800.c
.name = "88pm80x-rtc", .name = "88pm80x-onkey", .name = "88pm80x-regulator", .name = "88pm800",
Quoted 1 line
- 88pm805
% grep name drivers/mfd/88pm805.c
.name = "88pm80x-codec", .name = "88pm805",
Quoted 1 line
- at91-usart
% grep NAME drivers/mfd/at91-usart.c
MFD_CELL_NAME("at91_usart_spi");
MFD_CELL_NAME("atmel_usart_serial");Quoted 1 line
- stw481x
* Copyright (C) 2013 ST-Ericsson SA
Quoted 1 line
- vx855
* Copyright (C) 2009 VIA Technologies, Inc.
Quoted 1 line
- wm8400
* Copyright 2008 Wolfson Microelectronics PLC.
Quoted 1 line
- zynqmp (last changed in 2024, so certainly not legacy!)
This should _not_ be using the MFD API at all!
Quoted 5 lines
And probably others since I did not look too deep into it.
Greetings,
Marcos
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 5 lines · Lee Jones
Quoted 5 lines
patch series and thus make it a proper MFD (at the cost of delaying even further the GPIO inclusion), or keep the struct
mfd_cellarray as a single-element array and implement the watchdog later on another merge request, using that very same array.
Quoted 7 lines
Quoted 4 lines
I am however not okay with wasting my time rewriting that to bypass the MFD API for this, so I can waste even more time later implementing again the MFD API, just because linguistically one (right now) is technically not "multi".
I don't get this. If you implement the WDT now, you will be "multi", so what are you protesting against?
That GPIO is something required to perform the poweroff sequence, a must for any machine, while WDT is just a "nice to have".
Implementing now the WDT just because of a linguistic preference means delaying something more important in favour of a "nice to have".
Quoted 11 lines
Quoted 5 lines
That seems very unreasonable, specially when it wouldn't be a first since at least these other devices are also using MFD with a single device:
- 88pm80
% grep name
drivers/mfd/88pm800.c.name = "88pm80x-rtc", .name = "88pm80x-onkey", .name = "88pm80x-regulator", .name = "88pm800",
If you open the file, you'll see it uses five single-element arrays.
Quoted 6 lines
Quoted 1 line
- 88pm805
% grep name
drivers/mfd/88pm805.c.name = "88pm80x-codec", .name = "88pm805",
Same as above.
Quoted 5 lines
Quoted 1 line
- at91-usart
% grep NAME
drivers/mfd/at91-usart.cMFD_CELL_NAME("at91_usart_spi"); MFD_CELL_NAME("atmel_usart_serial");
Has two single-element arrays. It registers one or the other, never both (just like my patch does!)
Quoted 4 lines
Quoted 1 line
- stw481x
* Copyright (C) 2013 ST-Ericsson SA
Quoted 8 lines
Quoted 1 line
- vx855
* Copyright (C) 2009 VIA Technologies, Inc.
Quoted 1 line
- wm8400
* Copyright 2008 Wolfson Microelectronics PLC.
To my knowledge the definition of "multi" has not been changed since any of those years.
Lee Jones
maintainerRe: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 11 lines · Marcos Del Sol Vives
Quoted 10 lines · Lee Jones
Quoted 9 lines
patch series and thus make it a proper MFD (at the cost of delaying even further the GPIO inclusion), or keep the struct
mfd_cellarray as a single-element array and implement the watchdog later on another merge request, using that very same array.I am however not okay with wasting my time rewriting that to bypass the MFD API for this, so I can waste even more time later implementing again the MFD API, just because linguistically one (right now) is technically not "multi".
Quoted 8 lines
Quoted 2 lines
I don't get this. If you implement the WDT now, you will be "multi", so what are you protesting against?
That GPIO is something required to perform the poweroff sequence, a must for any machine, while WDT is just a "nice to have".
Implementing now the WDT just because of a linguistic preference means delaying something more important in favour of a "nice to have".
You use the word "delaying" here. What's the rush?
If you only need a GPIO driver, then you don't need the MFD part.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
That seems very unreasonable, specially when it wouldn't be a first since at least these other devices are also using MFD with a single device:
- 88pm80
Quoted 7 lines
Quoted 5 lines
% grep name
drivers/mfd/88pm800.c.name = "88pm80x-rtc", .name = "88pm80x-onkey", .name = "88pm80x-regulator", .name = "88pm800",If you open the file, you'll see it uses five single-element arrays.
Which is fine.
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
- 88pm805
% grep name
drivers/mfd/88pm805.c.name = "88pm80x-codec", .name = "88pm805",Same as above.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
- at91-usart
% grep NAME
drivers/mfd/at91-usart.cMFD_CELL_NAME("at91_usart_spi"); MFD_CELL_NAME("atmel_usart_serial");Has two single-element arrays. It registers one or the other, never both (just like my patch does!)
Fair point.
I guess this is more of a selector than a true concurrent MFD.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
- stw481x
* Copyright (C) 2013 ST-Ericsson SA
Quoted 1 line
- vx855
* Copyright (C) 2009 VIA Technologies, Inc.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
- wm8400
* Copyright 2008 Wolfson Microelectronics PLC.
To my knowledge the definition of "multi" has not been changed since any of those years.
If they were submitted during my tenure, it is likely that they would not have been accepted. Besides, past mistakes is no excuse for making them in the present.
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 10 lines · Lee Jones
Quoted 5 lines
That GPIO is something required to perform the poweroff sequence, a must for any machine, while WDT is just a "nice to have".
Implementing now the WDT just because of a linguistic preference means delaying something more important in favour of a "nice to have".
You use the word "delaying" here. What's the rush?
If you only need a GPIO driver, then you don't need the MFD part.
I would honestly like that my machines can turn off properly and pretty sure others using these platforms would agree on that, as having to yank out the power cable is far from ideal.
Adding WDT would lengthen even further the review process. That ignoring I am doing this as a hobby on my spare time and I'd rather spend my scarce free time implementing the power off driver than the WDT (something I'd do out of completion, I have absolutely no use for a WDT in this machine).
The reason I am using an MFD is that I was asked to back in v2
(https://lore.kernel.org/all/[email protected]/).
I'll be CC'ing him.
I was told to create a southbridge driver that would match on PCI and registered other devices exposed by it as platform drivers. GPIO was the only functionality implemented at the time, and is the only functionality implemented right now. So I simply delivered was I was asked for.
Lee Jones
maintainerRe: [PATCH v4 3/3] mfd: vortex: implement new driver for Vortex southbridges
Quoted 16 lines · Marcos Del Sol Vives
Quoted 10 lines · Lee Jones
Quoted 5 lines
That GPIO is something required to perform the poweroff sequence, a must for any machine, while WDT is just a "nice to have".
Implementing now the WDT just because of a linguistic preference means delaying something more important in favour of a "nice to have".
You use the word "delaying" here. What's the rush?
If you only need a GPIO driver, then you don't need the MFD part.
I would honestly like that my machines can turn off properly and pretty sure others using these platforms would agree on that, as having to yank out the power cable is far from ideal.
Quoted 5 lines
Adding WDT would lengthen even further the review process. That ignoring I am doing this as a hobby on my spare time and I'd rather spend my scarce free time implementing the power off driver than the WDT (something I'd do out of completion, I have absolutely no use for a WDT in this machine).
Then don't implement it. Just have the GPIO driver probe on PCI match.
Quoted 3 lines
The reason I am using an MFD is that I was asked to back in v2
(https://lore.kernel.org/all/[email protected]/).
I'll be CC'ing him.
Andy knows the rules.
Quoted 2 lines
I was told to create a southbridge driver that would match on PCI and registered other devices exposed by it as platform drivers.
PCI => Platform is generally decried by Greg and others.
a) With only one device to register, are you sure you need this?
b) If you have more devices, either add them here or use Aux Bus.
Quoted 3 lines
GPIO was the only functionality implemented at the time, and is the only functionality implemented right now. So I simply delivered was I was asked for.
Signature · 1 line
Lee Jones [李琼斯]