Use the ISA bus driver for PC/104 and ISA devices
Subsystems (10)
v2 cover Use the ISA bus driver for PC/104 and ISA devices
Two new ISA bus driver macros are introduced in this patchset:module_isa_driver and max_num_isa_dev.
The module_isa_driver macro is a helper macro for ISA drivers which do not do anything special in module init/exit. This macro is modelled after the module_pci_driver macro and eliminates a lot of module init/exit boilerplate code.
The max_num_isa_dev macro is used to determine the maximum possible number of ISA devices which may be registered in the I/O port address space given the address extent of the ISA devices. This macro is useful for computing the maximum number of elements necessary to hold the base addresses and interrupt line numbers of ISA devices for the respective ISA driver.
Lacking other documentation, I often found myself repeatedly returning to the commit message of the initial commit for drivers/base/isa.c authored by Rene Herman. A verbatim copy of this commit message has been added to Documentation/isa.txt, along with descriptions for the module_isa driver and max_num_isa_dev macros, for posterity.
The Apex Embedded Systems STX104 DAC driver expects to run on an x86 platform. This patchset adds an explicit X86 dependency for the Apex Embedded Systems STX104 DAC driver Kconfig option to prevent building the driver for nonsupported architectures.
Similarly, many PC/104 and ISA devices may also be used on both 32-bit and 64-bit X86 systems. The platform driver had been used to enable support for these devices on 64-bit X86 systems. With the removal of the X86_32 dependency of the ISA Kconfig configuration option, the respective drivers for these devices may now utilize the ISA bus driver without restricting support to only 32-bit X86 systems; the following drivers now utilize the ISA bus driver over the platform driver:
* WinSystems EBC-C384 watchdog timer
* ACCES 104-DIO-48E GPIO driver
* ACCES 104-IDI-48 GPIO driver
* ACCES 104-IDIO-16 GPIO driver
* WinSystems WS16C48 GPIO driver
With the utilization of the ISA bus driver, the GPIO drivers in this patchset may now support multiple devices for each of their respective ISA drivers. A naming convention for module array parameters has been set based on the Apex Embedded Systems STX104 DAC driver.
The "base" array module parameter sets the I/O port base address of each device. The "irq" array module parameter sets the interrupt line number of each device. Each element of the "base" array corresponds to a discrete device; each element of the "irq" array corresponds to the respective device addressed in the respective "base" array element.
Changes in v2:
- Added William Breathitt Gray as maintainer of the relevant ISA bus driver files
- STX104 DAC driver Kconfig option patch now simply adds explicit X86 Kconfig option dependency
- ISA_BUS Kconfig option dependency has been replaced with ISA Kconfig option dependency
William Breathitt Gray (10):
isa: Implement the module_isa_driver macro
isa: Implement the max_num_isa_dev macro
Documentation: Add ISA bus driver documentation
iio: stx104: Add X86 dependency to STX104 Kconfig option
iio: stx104: Utilize the module_isa_driver and max_num_isa_dev macros
watchdog: ebc-c384_wdt: Utilize the ISA bus driver
gpio: 104-dio-48e: Utilize the ISA bus driver
gpio: 104-idi-48: Utilize the ISA bus driver
gpio: 104-idio-16: Utilize the ISA bus driver
gpio: ws16c48: Utilize the ISA bus driver
Documentation/isa.txt | 121 ++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 7 +++ drivers/gpio/Kconfig | 38 +++++++------ drivers/gpio/gpio-104-dio-48e.c | 106 +++++++++++++---------------------- drivers/gpio/gpio-104-idi-48.c | 86 ++++++++++------------------ drivers/gpio/gpio-104-idio-16.c | 85 ++++++++++------------------ drivers/gpio/gpio-ws16c48.c | 88 ++++++++++------------------- drivers/iio/dac/Kconfig | 2 +- drivers/iio/dac/stx104.c | 24 +------- drivers/watchdog/Kconfig | 2 +- drivers/watchdog/ebc-c384_wdt.c | 43 ++++---------- include/linux/isa.h | 32 +++++++++++ 12 files changed, 319 insertions(+), 315 deletions(-) create mode 100644 Documentation/isa.txt
Signature · 1 line
2.7.3
PATCH v2 1/10 isa: Implement the module_isa_driver macro
The module_isa_driver macro is a helper macro for ISA drivers which do not do anything special in module init/exit. This eliminates a lot of boilerplate code. Each module may only use this macro once, and calling it replaces module_init and module_exit.
--- include/linux/isa.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
include/linux/isa.h +21 -0
@@ -36,4 +36,25 @@ static inline void isa_unregister_driver(struct isa_driver *d) }#endif +/** +* module_isa_driver() - Helper macro for registering a ISA driver +* @__isa_driver: isa_driver struct +* @__num_isa_dev: number of devices to register +* +* Helper macro for ISA drivers which do not do anything special in module +* init/exit. This eliminates a lot of boilerplate code. Each module may only +* use this macro once, and calling it replaces module_init and module_exit. +*/ +#define module_isa_driver (__isa_driver, __num_isa_dev) \ +static int __init __isa_driver##_init(void) \ +{ \ + return isa_register_driver(&(__isa_driver), __num_isa_dev); \ +} \ +module_init(__isa_driver##_init); \ +static void __exit __isa_driver##_exit(void) \ +{ \ + isa_unregister_driver(&(__isa_driver)); \ +} \ +module_exit(__isa_driver##_exit); +#endif /* __LINUX_ISA_H */
Signature · 1 line
2.7.3
A message that is not in the archive (sent off-list or not yet received): cover.1462141338.git.vilhelm.gray-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v2 2/10 isa: Implement the max_num_isa_dev macro
max_num_isa_dev is a macro to determine the maximum possible number of ISA devices which may be registered in the I/O port address space given the address extent of the ISA devices.
The highest base address possible for an ISA device is 0x3FF; this results in 1024 possible base addresses. Dividing the number of possible base addresses by the address extent taken by each device results in the maximum number of devices on a system.
--- include/linux/isa.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/isa.h +11 -0
@@ -57,4 +57,15 @@ static void __exit __isa_driver##_exit(void) \ } \ module_exit(__isa_driver##_exit); +/** +* max_num_isa_dev() - Maximum possible number registered of an ISA device +* @__ida_dev_ext: ISA device address extent +* +* The highest base address possible for an ISA device is 0x3FF; this results in +* 1024 possible base addresses. Dividing the number of possible base addresses +* by the address extent taken by each device results in the maximum number of +* devices on a system. +*/ +#define max_num_isa_dev (__isa_dev_ext) (1024 / __isa_dev_ext) +#endif /* __LINUX_ISA_H */
Signature · 6 lines
2.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/10 Documentation: Add ISA bus driver documentation
In reply to a message not in the archiveThis is a verbatim copy of the original commit message of the initial commit of the ISA bus driver authored by Rene Herman. Descriptions of the module_isa_driver macro and max_num_isa_dev macro are provided at the end.
--- Documentation/isa.txt | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 7 +++ 2 files changed, 128 insertions(+) create mode 100644 Documentation/isa.txt
Documentation/isa.txt new file +121 -0
@@ -0,0 +1,121 @@ +ISA Drivers +----------- + +The following text is adapted from the commit message of the initial +commit of the ISA bus driver authored by Rene Herman. + +During the recent "isa drivers using platform devices" discussion it was +pointed out that (ALSA) ISA drivers ran into the problem of not having +the option to fail driver load (device registration rather) upon not +finding their hardware due to a probe() error not being passed up +through the driver model. In the course of that, I suggested a separate +ISA bus might be best; Russell King agreed and suggested this bus could +use the .match() method for the actual device discovery. + +The attached does this. For this old non (generically) discoverable ISA +hardware only the driver itself can do discovery so as a difference with +the platform_bus, this isa_bus also distributes match() up to the +driver. + +As another difference: these devices only exist in the driver model due +to the driver creating them because it might want to drive them, meaning +that all device creation has been made internal as well. + +The usage model this provides is nice, and has been acked from the ALSA +side by Takashi Iwai and Jaroslav Kysela. The ALSA driver module_init's +now (for oldisa-only drivers) become: + +static int __init alsa_card_foo_init(void) +{ + return isa_register_driver(&snd_foo_isa_driver, SNDRV_CARDS); +} + +static void __exit alsa_card_foo_exit(void) +{ + isa_unregister_driver(&snd_foo_isa_driver); +} + +Quite like the other bus models therefore. This removes a lot of +duplicated init code from the ALSA ISA drivers. + +The passed in isa_driver struct is the regular driver struct embedding a +struct device_driver, the normal probe/remove/shutdown/suspend/resume +callbacks, and as indicated that .match callback. + +The "SNDRV_CARDS" you see being passed in is a "unsigned int ndev" +parameter, indicating how many devices to create and call our methods +with. + +The platform_driver callbacks are called with a platform_device param; +the isa_driver callbacks are being called with a "struct device *dev, +unsigned int id" pair directly -- with the device creation completely +internal to the bus it's much cleaner to not leak isa_dev's by passing +them in at all. The id is the only thing we ever want other then the +struct device * anyways, and it makes for nicer code in the callbacks as +well. + +With this additional .match() callback ISA drivers have all options. If +ALSA would want to keep the old non-load behaviour, it could stick all +of the old .probe in .match, which would only keep them registered after +everything was found to be present and accounted for. If it wanted the +behaviour of always loading as it inadvertently did for a bit after the +changeover to platform devices, it could just not provide a .match() and +do everything in .probe() as before. + +If it, as Takashi Iwai already suggested earlier as a way of following +the model from saner buses more closely, wants to load when a later bind +could conceivably succeed, it could use .match() for the prerequisites +(such as checking the user wants the card enabled and that port/irq/dma +values have been passed in) and .probe() for everything else. This is +the nicest model. + +To the code... + +This exports only two functions; isa_{,un}register_driver(). + +isa_register_driver() register's the struct device_driver, and then +loops over the passed in ndev creating devices and registering them. +This causes the bus match method to be called for them, which is: + +int isa_bus_match(struct device *dev, struct device_driver *driver) +{ + struct isa_driver *isa_driver = to_isa_driver(driver); + + if (dev->platform_data == isa_driver) { + if (!isa_driver->match || + isa_driver->match(dev, to_isa_dev(dev)->id)) + return 1; + dev->platform_data = NULL; + } + return 0; +} + +The first thing this does is check if this device is in fact one of this +driver's devices by seeing if the device's platform_data pointer is set +to this driver. Platform devices compare strings, but we don't need to +do that with everything being internal, so isa_register_driver() abuses +dev->platform_data as a isa_driver pointer which we can then check here. +I believe platform_data is available for this, but if rather not, moving +the isa_driver pointer to the private struct isa_dev is ofcourse fine as +well. + +Then, if the the driver did not provide a .match, it matches. If it did, +the driver match() method is called to determine a match. + +If it did _not_ match, dev->platform_data is reset to indicate this to +isa_register_driver which can then unregister the device again. + +If during all this, there's any error, or no devices matched at all +everything is backed out again and the error, or -ENODEV, is returned. + +isa_unregister_driver() just unregisters the matched devices and the +driver itself. + +module_isa_driver is a helper macro for ISA drivers which do not do +anything special in module init/exit. This eliminates a lot of +boilerplate code. Each module may only use this macro once, and calling +it replaces module_init and module_exit. + +max_num_isa_dev is a macro to determine the maximum possible number of +ISA devices which may be registered in the I/O port address space given +the address extent of the ISA devices.
MAINTAINERS +7 -0
@@ -5995,6 +5995,13 @@ F: include/linux/irqdomain.h F: kernel/irq/irqdomain.c F: kernel/irq/msi.c +ISA +M: William Breathitt Gray <[email protected]> +S: Maintained +F: Documentation/isa.txt +F: drivers/base/isa.c +F: include/linux/isa.h + ISAPNP M: Jaroslav Kysela <perex-/Fr2/[email protected]> S: Maintained
Signature · 1 line
2.7.3
PATCH v2 4/10 iio: stx104: Add X86 dependency to STX104 Kconfig option
In reply to a message not in the archiveThe Apex Embedded Systems STX104 DAC driver expects the STX104 device to be I/O port-mapped addressable on an X86 platform. This patch adds an explicit X86 dependency to the STX104 configuration option to prevent building on non-X86 architectures.
--- drivers/iio/dac/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/Kconfig +1 -1
@@ -210,7 +210,7 @@ config MCP4922 config STX104 tristate "Apex Embedded Systems STX104 DAC driver" - depends on ISA + depends on X86 && ISA help Say yes here to build support for the 2-channel DAC on the Apex Embedded Systems STX104 integrated analog PC/104 card. The base port
Signature · 6 lines
2.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 5/10 iio: stx104: Utilize the module_isa_driver and max_num_isa_dev macros
In reply to a message not in the archiveThe Apex Embedded Systems STX104 DAC drivers does not do anything special in module init/exit. This patch eliminates the module init/exit boilerplate code by utilizing the module_isa_driver macro.
Additionally, the max_num_isa_dev macro is utilized to simplify the determination of maximum possible STX104 devices in the system.
--- drivers/iio/dac/stx104.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
drivers/iio/dac/stx104.c +3 -21
@@ -33,16 +33,9 @@ }#define STX104_EXTENT 16 -/** -* The highest base address possible for an ISA device is 0x3FF; this results in -* 1024 possible base addresses. Dividing the number of possible base addresses -* by the address extent taken by each device results in the maximum number of -* devices on a system. -*/ -#define MAX_NUM_STX104 (1024 / STX104_EXTENT) -static unsigned base[MAX_NUM_STX104 ]; -static unsigned num_stx104; +static unsigned int base[max_num_isa_dev (STX104_EXTENT )]; +static unsigned int num_stx104;module_param_array (base, uint, &num_stx104,0 );MODULE_PARM_DESC (base,"Apex Embedded Systems STX104 base addresses" );
@@ -134,18 +127,7 @@ static struct isa_driver stx104_driver = { } }; -static void __exit stx104_exit(void) -{ -isa_unregister_driver (&stx104_driver); -} - -static int __init stx104_init (void ) -{ -return isa_register_driver (&stx104_driver, num_stx104); -} - -module_init (stx104_init); -module_exit (stx104_exit); +module_isa_driver (stx104_driver, num_stx104);MODULE_AUTHOR ("William Breathitt Gray <[email protected]>" );MODULE_DESCRIPTION ("Apex Embedded Systems STX104 DAC driver" );
Signature · 6 lines
2.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 7/10 gpio: 104-dio-48e: Utilize the ISA bus driver
In reply to a message not in the archiveThe ACCES 104-DIO-48E series communicates via the ISA bus. As such, it is more appropriate to use the ISA bus driver over the platform driver to control the ACCES 104-DIO-48E GPIO driver.
This patch also adds support for multiple devices via the base and irq module array parameters. Each element of the base array corresponds to a discrete device; each element of the irq array corresponds to the respective device addressed in the respective base array element.
--- drivers/gpio/Kconfig | 9 ++-- drivers/gpio/gpio-104-dio-48e.c | 106 ++++++++++++++-------------------------- 2 files changed, 43 insertions(+), 72 deletions(-)
drivers/gpio/Kconfig +5 -4
@@ -517,12 +517,13 @@ menu "Port-mapped I/O GPIO drivers" config GPIO_104_DIO_48E tristate "ACCES 104-DIO-48E GPIO support" + depends on ISA select GPIOLIB_IRQCHIP help - Enables GPIO support for the ACCES 104-DIO-48E family. The base port - address for the device may be configured via the dio_48e_base module - parameter. The interrupt line number for the device may be configured - via the dio_48e_irq module parameter. + Enables GPIO support for the ACCES 104-DIO-48E series (104-DIO-48E, + 104-DIO-24E). The base port addresses for the devices may be + configured via the base module parameter. The interrupt line numbers + for the devices may be configured via the irq module parameter. config GPIO_104_IDIO_16 tristate "ACCES 104-IDIO-16 GPIO support"
drivers/gpio/gpio-104-dio-48e.c +38 -68
181 lines not on this page · raw message
Signature · 6 lines
2.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 8/10 gpio: 104-idi-48: Utilize the ISA bus driver
In reply to a message not in the archiveThe ACCES 104-IDI-48 series communicates via the ISA bus. As such, it is more appropriate to use the ISA bus driver over the platform driver to control the ACCES 104-IDI-48 GPIO driver.
This patch also adds support for multiple devices via the base and irq module array parameters. Each element of the base array corresponds to a discrete device; each element of the irq array corresponds to the respective device addressed in the respective base array element.
--- drivers/gpio/Kconfig | 10 +++-- drivers/gpio/gpio-104-idi-48.c | 86 ++++++++++++++---------------------------- 2 files changed, 34 insertions(+), 62 deletions(-)
drivers/gpio/Kconfig +6 -4
@@ -536,12 +536,14 @@ config GPIO_104_IDIO_16 config GPIO_104_IDI_48 tristate "ACCES 104-IDI-48 GPIO support" + depends on ISA select GPIOLIB_IRQCHIP help - Enables GPIO support for the ACCES 104-IDI-48 family. The base port - address for the device may be configured via the idi_48_base module - parameter. The interrupt line number for the device may be configured - via the idi_48_irq module parameter. + Enables GPIO support for the ACCES 104-IDI-48 family (104-IDI-48A, + 104-IDI-48AC, 104-IDI-48B, 104-IDI-48BC). The base port addresses for + the devices may be configured via the base module parameter. The + interrupt line numbers for the devices may be configured via the irq + module parameter. config GPIO_F7188X tristate "F71869, F71869A, F71882FG, F71889F and F81866 GPIO support"
drivers/gpio/gpio-104-idi-48.c +28 -58
155 lines not on this page · raw message
Signature · 6 lines
2.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 9/10 gpio: 104-idio-16: Utilize the ISA bus driver
In reply to a message not in the archiveThe ACCES 104-IDIO-16 series communicates via the ISA bus. As such, it is more appropriate to use the ISA bus driver over the platform driver to control the ACCES 104-IDIO-16 GPIO driver.
This patch also adds support for multiple devices via the base and irq module array parameters. Each element of the base array corresponds to a discrete device; each element of the irq array corresponds to the respective device addressed in the respective base array element.
--- drivers/gpio/Kconfig | 10 +++-- drivers/gpio/gpio-104-idio-16.c | 85 ++++++++++++++--------------------------- 2 files changed, 34 insertions(+), 61 deletions(-)
drivers/gpio/Kconfig +6 -4
@@ -527,12 +527,14 @@ config GPIO_104_DIO_48E config GPIO_104_IDIO_16 tristate "ACCES 104-IDIO-16 GPIO support" + depends on ISA select GPIOLIB_IRQCHIP help - Enables GPIO support for the ACCES 104-IDIO-16 family. The base port - address for the device may be set via the idio_16_base module - parameter. The interrupt line number for the device may be set via the - idio_16_irq module parameter. + Enables GPIO support for the ACCES 104-IDIO-16 family (104-IDIO-16, + 104-IDIO-16E, 104-IDO-16, 104-IDIO-8, 104-IDIO-8E, 104-IDO-8). The + base port addresses for the devices may be configured via the base + module parameter. The interrupt line numbers for the devices may be + configured via the irq module parameter. config GPIO_104_IDI_48 tristate "ACCES 104-IDI-48 GPIO support"
drivers/gpio/gpio-104-idio-16.c +28 -57
155 lines not on this page · raw message
Signature · 6 lines
2.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 6/10 watchdog: ebc-c384_wdt: Utilize the ISA bus driver
In reply to William Breathitt GrayThe WinSystems EBC-C384 watchdog timer is controlled via ISA bus communication. As such, the ISA bus driver is more appropriate than the platform driver for the WinSystems EBC-C384 watchdog timer driver.
--- drivers/watchdog/Kconfig | 2 +- drivers/watchdog/ebc-c384_wdt.c | 43 ++++++++++------------------------------- 2 files changed, 11 insertions(+), 34 deletions(-)
drivers/watchdog/Kconfig +1 -1
@@ -738,7 +738,7 @@ config ALIM7101_WDT config EBC_C384_WDT tristate "WinSystems EBC-C384 Watchdog Timer" - depends on X86 + depends on X86 && ISA select WATCHDOG_CORE help Enables watchdog timer support for the watchdog timer on the
drivers/watchdog/ebc-c384_wdt.c +10 -33
94 lines not on this page · raw message
Signature · 1 line
2.7.3
PATCH v2 10/10 gpio: ws16c48: Utilize the ISA bus driver
In reply to William Breathitt GrayThe WinSystems WS16C48 communicates via the ISA bus. As such, it is more appropriate to use the ISA bus driver over the platform driver to control the WinSystems WS16C48 GPIO driver.
This patch also adds support for multiple devices via the base and irq module array parameters. Each element of the base array corresponds to a discrete device; each element of the irq array corresponds to the respective device addressed in the respective base array element.
--- drivers/gpio/Kconfig | 9 ++--- drivers/gpio/gpio-ws16c48.c | 88 +++++++++++++++------------------------------ 2 files changed, 33 insertions(+), 64 deletions(-)
drivers/gpio/Kconfig +5 -4
@@ -614,12 +614,13 @@ config GPIO_TS5500 config GPIO_WS16C48 tristate "WinSystems WS16C48 GPIO support" + depends on ISA select GPIOLIB_IRQCHIP help - Enables GPIO support for the WinSystems WS16C48. The base port address - for the device may be configured via the ws16c48_base module - parameter. The interrupt line number for the device may be configured - via the ws16c48_irq module parameter. + Enables GPIO support for the WinSystems WS16C48. The base port + addresses for the devices may be configured via the base module + parameter. The interrupt line numbers for the devices may be + configured via the irq module parameter. endmenu
drivers/gpio/gpio-ws16c48.c +28 -60
152 lines not on this page · raw message
Signature · 1 line
2.7.3