GPIO: Add GPIO support for the ACCES 104-IDIO-16
Subsystems (2)
PATCH 1/1 GPIO: Add GPIO support for the ACCES 104-IDIO-16
The ACCES 104-IDIO-16 family of PC/104 utility boards feature 16 optically isolated inputs and 16 optically isolated FET solid state outputs. This driver provides GPIO support for these 32 channels of digital I/O. Change-of-State detection interrupts are not supported.
GPIO 0-15 correspond to digital outputs 0-15, while GPIO 16-31 correspond to digital inputs 0-15.
--- drivers/gpio/Kconfig | 14 ++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-104-idio-16.c | 154 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 drivers/gpio/gpio-104-idio-16.c
drivers/gpio/Kconfig +14 -0
@@ -684,6 +684,20 @@ config GPIO_SX150X endmenu +menu "ISA GPIO expanders" + +menuconfig GPIO_104_IDIO_16 + tristate "ACCES 104-IDIO-16 GPIO support" + help + Enables GPIO support for the ACCES 104-IDIO-16 family. + +config 104_IDIO_16_BASE + hex "ACCES 104-IDIO-16 base address" + depends on GPIO_104_IDIO_16 + default 0x000 + +endmenu + menu "MFD GPIO expanders" config GPIO_ADP5520
drivers/gpio/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o # Device drivers. Generally keep list sorted alphabetically obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o +obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o
drivers/gpio/gpio-104-idio-16.c new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
2.4.9
kbuild test robot
build botconfig: microblaze-allmodconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x…
Hi William,
[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]
config: microblaze-allmodconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=microblaze
All error/warnings (new ones prefixed by >>):
ERROR: "isa_io_base" [drivers/net/wan/lmc/lmc.ko] undefined!
ERROR: "isa_io_base" [drivers/net/wan/farsync.ko] undefined!
ERROR: "isa_io_base" [drivers/net/irda/vlsi_ir.ko] undefined!
ERROR: "isa_io_base" [drivers/net/irda/donauboe.ko] undefined!
ERROR: "isa_io_base" [drivers/net/hamradio/yam.ko] undefined!
ERROR: "isa_io_base" [drivers/net/hamradio/baycom_ser_hdx.ko] undefined!
ERROR: "isa_io_base" [drivers/net/hamradio/baycom_ser_fdx.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/via/via-rhine.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/ti/tlan.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/sis/sis900.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/sis/sis190.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/intel/e1000/e1000.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/hp/hp100.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/dec/tulip/de4x5.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/amd/pcnet32.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/8390/ne2k-pci.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/8390/8390.ko] undefined!
ERROR: "isa_io_base" [drivers/net/ethernet/3com/3c59x.ko] undefined!
ERROR: "isa_io_base" [drivers/net/can/sja1000/sja1000_isa.ko] undefined!
ERROR: "isa_io_base" [drivers/net/can/cc770/cc770_isa.ko] undefined!
ERROR: "isa_io_base" [drivers/net/arcnet/com90xx.ko] undefined!
ERROR: "isa_io_base" [drivers/net/arcnet/com90io.ko] undefined!
ERROR: "isa_io_base" [drivers/net/arcnet/com20020.ko] undefined!
ERROR: "isa_io_base" [drivers/net/arcnet/com20020-pci.ko] undefined!
ERROR: "isa_io_base" [drivers/misc/altera-stapl/altera-stapl.ko] undefined!
ERROR: "isa_io_base" [drivers/message/fusion/mptbase.ko] undefined!
ERROR: "isa_io_base" [drivers/media/radio/radio-maxiradio.ko] undefined!
ERROR: "isa_io_base" [drivers/media/pci/dm1105/dm1105.ko] undefined!
ERROR: "isa_io_base" [drivers/leds/leds-ot200.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hysdn/hysdn.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hisax/hisax_fcpcipnp.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hisax/hisax.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hisax/hfc4s8s_l1.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/mISDN/w6692.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/mISDN/speedfax.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/mISDN/netjet.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/mISDN/mISDNinfineon.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/mISDN/hfcmulti.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/mISDN/avmfritz.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/eicon/divas.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/avm/b1pci.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/avm/b1dma.ko] undefined!
ERROR: "isa_io_base" [drivers/isdn/hardware/avm/b1.ko] undefined!
ERROR: "isa_io_base" [drivers/input/touchscreen/mk712.ko] undefined!
ERROR: "isa_io_base" [drivers/input/serio/pcips2.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/tmdc.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/sidewinder.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/joydump.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/interact.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/guillemot.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/grip_mp.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/grip.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/gf2k.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/cobra.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/analog.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/adi.ko] undefined!
ERROR: "isa_io_base" [drivers/input/joystick/a3d.ko] undefined!
ERROR: "isa_io_base" [drivers/input/gameport/ns558.ko] undefined!
ERROR: "isa_io_base" [drivers/input/gameport/lightning.ko] undefined!
ERROR: "isa_io_base" [drivers/input/gameport/gameport.ko] undefined!
ERROR: "isa_io_base" [drivers/input/gameport/fm801-gp.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-viapro.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-via.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-sis96x.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-sis630.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-sis5595.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-piix4.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-parport-light.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-nforce2.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-isch.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-i801.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-amd8111.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-amd756.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-ali15x3.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-ali1563.ko] undefined!
ERROR: "isa_io_base" [drivers/i2c/busses/i2c-ali1535.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/w83627hf.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/w83627ehf.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/vt8231.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/vt1211.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/via686a.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/smsc47m1.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/smsc47b397.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/sis5595.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/sch56xx-common.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/pc87427.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/pc87360.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/nct6775.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/nct6683.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/it87.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/f71882fg.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/f71805f.ko] undefined!
ERROR: "isa_io_base" [drivers/hwmon/dme1737.ko] undefined!
ERROR: "isa_io_base" [drivers/gpu/drm/qxl/qxl.ko] undefined!
ERROR: "isa_io_base" [drivers/gpu/drm/cirrus/cirrus.ko] undefined!
ERROR: "isa_io_base" [drivers/gpu/drm/bochs/bochs-drm.ko] undefined!
ERROR: "isa_io_base" [drivers/gpio/gpio-vx855.ko] undefined!
ERROR: "isa_io_base" [drivers/gpio/gpio-ts5500.ko] undefined!
ERROR: "isa_io_base" [drivers/gpio/gpio-sch311x.ko] undefined!
ERROR: "isa_io_base" [drivers/gpio/gpio-amd8111.ko] undefined!
>> ERROR: "isa_io_base" [drivers/gpio/gpio-104-idio-16.ko] undefined!
ERROR: "isa_io_base" [drivers/char/tpm/tpm_atmel.ko] undefined!
ERROR: "isa_io_base" [drivers/char/ipmi/ipmi_si.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/on26.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/on20.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/ktti.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/kbic.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/frpw.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/friq.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/fit3.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/fit2.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/epia.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/epat.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/dstr.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/comm.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/bpck6.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/bpck.ko] undefined!
ERROR: "isa_io_base" [drivers/block/paride/aten.ko] undefined!
ERROR: "isa_io_base" [drivers/atm/zatm.ko] undefined!
ERROR: "isa_io_base" [drivers/atm/horizon.ko] undefined!
ERROR: "isa_io_base" [drivers/atm/ambassador.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/pata_sc1200.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/pata_pdc202xx_old.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/pata_optidma.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/pata_legacy.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/pata_hpt3x2n.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/pata_hpt37x.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/pata_cypress.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/pata_cmd64x.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/pata_artop.ko] undefined!
ERROR: "isa_io_base" [drivers/ata/libata.ko] undefined!
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 1 line · William Breathitt Gray
The ACCES 104-IDIO-16 family of PC/104 utility boards
Sounds like a PC104 keyboard :D
Quoted 4 lines
feature 16
optically isolated inputs and 16 optically isolated FET solid state outputs. This driver provides GPIO support for these 32 channels of digital I/O. Change-of-State detection interrupts are not supported.
So it has IRQ support but it's not supported yet I take it.
Quoted 6 lines
GPIO 0-15 correspond to digital outputs 0-15, while GPIO 16-31 correspond to digital inputs 0-15.
Signed-off-by William Breathitt Gray <[email protected]>+menu "ISA GPIO expanders"
Interesting submenu. I guess it is proper to have so OK.
Add:
depends on PCI
As they all will need that, I guess?
drivers/gpio/Kconfig config GPIO_SX150X · line 697
Quoted 9 lines
drivers/gpio/Kconfig +9
-0+menuconfig GPIO_104_IDIO_16 + tristate "ACCES 104-IDIO-16 GPIO support" + help + Enables GPIO support for the ACCES 104-IDIO-16 family. + +config 104_IDIO_16_BASE + hex "ACCES 104-IDIO-16 base address" + depends on GPIO_104_IDIO_16 + default 0x000
This can't be right. PCI devices have their config space for a reason I'm told. On other platforms we use device tree or ACPI to set this up but PCI is either hotplug or wrong I think.
The driver is full of ISA style inb/outb stuff, I get all confused. Why is this not using the PCI infrastructure?
Involving Björn Helgås for a comment on this.
Quoted 1 line
+#include <
linux/gpio.h>
Only
#include <linux/gpio/driver.h>
drivers/gpio/gpio-104-idio-16.c line 25
Quoted 11 lines
drivers/gpio/gpio-104-idio-16.c new file +11
-0+#include <linux/io.h> +#include <linux/ioport.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/printk.h> +#include <linux/spinlock.h> + +struct a_104_idio_16_gpio { +struct gpio_chip chip; +spinlock_t lock; +unsigned base;
Isn't this void __iomem *base?
Review
Quoted 2 lines
(quoted diff) +2
-0+ unsigned data; +};
kerneldoc this.
drivers/gpio/gpio-104-idio-16.c line 39
Quoted 9 lines
drivers/gpio/gpio-104-idio-16.c new file +9
-0+static void __exit a_104_idio_16_exit(void); +static int a_104_idio_16_gpio_direction_input (struct gpio_chip *chip, +unsigned offset); +static int a_104_idio_16_gpio_direction_output (struct gpio_chip *chip, +unsigned offset,int value); +static int a_104_idio_16_gpio_get (struct gpio_chip *chip,unsigned offset); +static void a_104_idio_16_gpio_set (struct gpio_chip *chip,unsigned offset, +int value); +static int __init a_104_idio_16_init (void );
Re-arrange code to avoid forward declarations please.
Quoted 1 line
+static const unsigned
A_104_IDIO_16_EXTENT= 8;
Looks like it could be a #define A_104_IDIO_16_EXTENT 8
drivers/gpio/gpio-104-idio-16.c line 55
Quoted 13 lines
drivers/gpio/gpio-104-idio-16.c new file +13
-0+static struct a_104_idio_16_gpio gp = { + .chip = { + .label ="104-IDIO-16 GPIO" , + .owner =THIS_MODULE , + .base =-1 , + .ngpio =32 , + .direction_input = a_104_idio_16_gpio_direction_input, + .direction_output = a_104_idio_16_gpio_direction_output, + .get = a_104_idio_16_gpio_get, + .set = a_104_idio_16_gpio_set + }, + .base =CONFIG_104_IDIO_16_BASE +};
So if you put this *below* the functions you need not forward-declare them.
drivers/gpio/gpio-104-idio-16.c line 61
Quoted 5 lines
drivers/gpio/gpio-104-idio-16.c new file +5
-0+static void __exit a_104_idio_16_exit(void) +{ +pr_info ("104-idio-16: Exiting 104-idio-16 module\n" ); + +gpiochip_remove (&gp.chip);
Where is that &gp.chip? Not in this file. Nor should you use any globals.
Does this driver even compile?
drivers/gpio/gpio-104-idio-16.c line 84
Quoted 7 lines
drivers/gpio/gpio-104-idio-16.c new file +7
-0+static int a_104_idio_16_gpio_get (struct gpio_chip *chip,unsigned offset) +{ +struct a_104_idio_16_gpio *a104i16gp =to_a104i16gp (chip); +const unsigned BIT_MASK =1U << (offset-16 ); + +if (offset <16 ) +return 0 ;
Always return 0, why? Is that really correct?
drivers/gpio/gpio-104-idio-16.c line 135
Quoted 3 lines
drivers/gpio/gpio-104-idio-16.c new file +3
-0+static int __init a_104_idio_16_init (void ) + spin_lock_init(&gp.lock); + err = gpiochip_add(&gp.chip);
This gp global again. ReadDocumentation/driver-model/design-patterns.txt
Please.
Yours,
Linus Walleij
Hi William and Linus,
Quoted 19 lines · Linus Walleij
Quoted 1 line · William Breathitt Gray
The ACCES 104-IDIO-16 family of PC/104 utility boards
Sounds like a PC104 keyboard :D
Quoted 4 lines
feature 16
optically isolated inputs and 16 optically isolated FET solid state outputs. This driver provides GPIO support for these 32 channels of digital I/O. Change-of-State detection interrupts are not supported.So it has IRQ support but it's not supported yet I take it.
Quoted 4 lines
GPIO 0-15 correspond to digital outputs 0-15, while GPIO 16-31 correspond to digital inputs 0-15.
Signed-off-by William Breathitt Gray <[email protected]>
Quoted 8 lines
Quoted 1 line
+menu "ISA GPIO expanders"
Interesting submenu. I guess it is proper to have so OK.
Add:
depends on PCIAs they all will need that, I guess?
Why do they need PCI? I don't see any PCI interfaces used here.
Quoted 14 lines
drivers/gpio/Kconfig config GPIO_SX150X · line 697
Quoted 9 lines
drivers/gpio/Kconfig +9
-0+menuconfig GPIO_104_IDIO_16 + tristate "ACCES 104-IDIO-16 GPIO support" + help + Enables GPIO support for the ACCES 104-IDIO-16 family. + +config 104_IDIO_16_BASE + hex "ACCES 104-IDIO-16 base address" + depends on GPIO_104_IDIO_16 + default 0x000This can't be right. PCI devices have their config space for a reason I'm told. On other platforms we use device tree or ACPI to set this up but PCI is either hotplug or wrong I think.
Quoted 2 lines
The driver is full of ISA style inb/outb stuff, I get all confused. Why is this not using the PCI infrastructure?
I'm really not familiar with PC/104, but wikipedia claims it only uses ISA. Apparently PCI/104-Plus, PCI-104, PCI/104-Express, and PCIe/104 *do* have PCI and/or PCIe, but it looks like the base PC/104 does not.
Bjorn
Quoted 6 lines · Bjorn Helgaas
I'm really not familiar with PC/104, but wikipedia claims it only uses ISA. Apparently PCI/104-Plus, PCI-104, PCI/104-Express, and PCIe/104 *do* have PCI and/or PCIe, but it looks like the base PC/104 does not.
Bjorn
This is correct: PC/104 is only ISA. The ACCES 104-IDIO-16 board is a PC/104 stackable GPIO board, whose port address is configured via physical jumper switches on the board; it is not "hotpluggable." For this reason, the CONFIG_104_IDIO_16_BASE option should be set to the same port address physically configured on the board.
- William
Quoted 6 lines · Linus Walleij
drivers/gpio/gpio-104-idio-16.c line 25
Quoted 4 lines
drivers/gpio/gpio-104-idio-16.c new file +4
-0+struct a_104_idio_16_gpio { +struct gpio_chip chip; +spinlock_t lock; +unsigned base;Isn't this void
__iomem*base?
The 'base' member is used to hold the I/O port base address passed to the inb/outb functions for port-mapped I/O operations. Since the addresses are not dereferenced, I don't believe an __iomem pointer would be correct.
Quoted 3 lines
Quoted 1 line
+static const unsigned
A_104_IDIO_16_EXTENT= 8;Looks like it could be a #define
A_104_IDIO_16_EXTENT8
I used a const variable for the benefit of type-safety; I assumed the compiler would optimize it. What is the advantage of a #define constant?
Quoted 8 lines
drivers/gpio/gpio-104-idio-16.c line 61
Quoted 5 lines
drivers/gpio/gpio-104-idio-16.c new file +5
-0+static void __exit a_104_idio_16_exit(void) +{ +pr_info ("104-idio-16: Exiting 104-idio-16 module\n" ); + +gpiochip_remove (&gp.chip);Where is that &gp.chip? Not in this file. Nor should you use any globals.
I agree that using a global data structure isn't good practice, but I'm not sure how else to expose the gpio_chip structure in the respective module _init and _exit functions since they have void parameter lists. Would it be more appropriate to use the platform device API in this situation to avoid the global data structure?
Quoted 9 lines
drivers/gpio/gpio-104-idio-16.c line 84
Quoted 7 lines
drivers/gpio/gpio-104-idio-16.c new file +7
-0+static int a_104_idio_16_gpio_get (struct gpio_chip *chip,unsigned offset) +{ +struct a_104_idio_16_gpio *a104i16gp =to_a104i16gp (chip); +const unsigned BIT_MASK =1U << (offset-16 ); + +if (offset <16 ) +return 0 ;Always return 0, why? Is that really correct?
GPIO 0-15 are output-only. The kerneldoc for 'struct gpio_chip' states that for output signals the get function should return the value actually sensed, or zero. Since I cannot sense the output signals, I return zero in these cases. Is this behavior correct?
- William
Quoted 7 lines · William Breathitt Gray
Quoted 3 lines · Bjorn Helgaas
I'm really not familiar with PC/104, but wikipedia claims it only uses ISA. Apparently PCI/104-Plus, PCI-104, PCI/104-Express, and PCIe/104 *do* have PCI and/or PCIe, but it looks like the base PC/104 does not.
This is correct: PC/104 is only ISA.
OK then let's drop that confusing "PCI GPIO expanders" menu.
Maybe "ISA GPIO cards" or similar is more apropriate.
Quoted 5 lines
The ACCES 104-IDIO-16 board is a
PC/104 stackable GPIO board, whose port address is configured via physical jumper switches on the board; it is not "hotpluggable." For this reason, theCONFIG_104_IDIO_16_BASEoption should be set to the same port address physically configured on the board.
I think the pattern in the kernel is to support such configuration for ISA is with module parameters, not with compile-time constants. So switch that base to use a module parameter.
Yours,
Linus Walleij
Quoted 11 lines · William Breathitt Gray
Quoted 6 lines · Linus Walleij
drivers/gpio/gpio-104-idio-16.c line 25
Quoted 4 lines
drivers/gpio/gpio-104-idio-16.c new file +4
-0+struct a_104_idio_16_gpio { +struct gpio_chip chip; +spinlock_t lock; +unsigned base;Isn't this void
__iomem*base?The 'base' member is used to hold the I/O port base address passed to the inb/outb functions for port-mapped I/O operations. Since the addresses are not dereferenced, I don't believe an
__iomempointer would be correct.
You're right, sorry I was confused.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+static const unsigned
A_104_IDIO_16_EXTENT= 8;Looks like it could be a #define
A_104_IDIO_16_EXTENT8I used a const variable for the benefit of type-safety; I assumed the compiler would optimize it. What is the advantage of a #define constant?
Usually we use #define's for compile-time constants.
Quoted 8 lines
Quoted 7 lines
drivers/gpio/gpio-104-idio-16.c line 61
Quoted 5 lines
drivers/gpio/gpio-104-idio-16.c new file +5
-0+static void __exit a_104_idio_16_exit(void) +{ +pr_info ("104-idio-16: Exiting 104-idio-16 module\n" ); + +gpiochip_remove (&gp.chip);Where is that &gp.chip? Not in this file. Nor should you use any globals.
Quoted 5 lines
I agree that using a global data structure isn't good practice, but I'm not sure how else to expose the
gpio_chipstructure in the respective module_initand_exitfunctions since they have void parameter lists. Would it be more appropriate to use the platform device API in this situation to avoid the global data structure?
It depends where your device is spawn. If there is a natural place to instantiate the platform device like from a MFD or PCI driver or something then yes.
Quoted 10 lines
Quoted 9 lines
drivers/gpio/gpio-104-idio-16.c line 84
Quoted 7 lines
drivers/gpio/gpio-104-idio-16.c new file +7
-0+static int a_104_idio_16_gpio_get (struct gpio_chip *chip,unsigned offset) +{ +struct a_104_idio_16_gpio *a104i16gp =to_a104i16gp (chip); +const unsigned BIT_MASK =1U << (offset-16 ); + +if (offset <16 ) +return 0 ;Always return 0, why? Is that really correct?
Quoted 4 lines
GPIO 0-15 are output-only. The kerneldoc for 'struct
gpio_chip' states that for output signals the get function should return the value actually sensed, or zero. Since I cannot sense the output signals, I return zero in these cases. Is this behavior correct?
I guess, we recently augmented the gpiolib core so you can actually return an error code as -ENODEV here. No strong preference though. Maybe I should have...
Yours,
Linus Walleij