Kconfig: Add an I2C_DEVICES device group
cover Kconfig: Add an I2C_DEVICES device group
This patchset adds a new Kconfig "device group" for I2C devices which a user might reasonably want to plug in to an arbitrary i2c bus via the command line. This follows the approach we use for PCI devices:
generally-usable i2c devices have
default y if I2C_DEVICES
and board models with user-accessible i2c buses have
imply I2C_DEVICES
This means that when building a board model that pulls in the device group, the devices are all compiled in and available for use. (Previously they would happen to be present and usable only if some other board that explicitly pulled that device in happened to also be built into the same QEMU binary.)
I have been fairly conservative in marking devices as being in the group and in marking board models as pulling in the group; feel free to suggest changes.
In particular I've only added 'imply I2C_DEVICES' to arm boards. Grepping through Kconfig files I only found the PPC boards e500 and ppc44x that enable some kind of i2c controller anyway.
The immediate motivation here is that the recently added lsm303dlhc magnetometer isn't currently built unless the user manually adds it to their config, because as it happens no boards have it as a hard-wired device.
thanks
-- PMM
Peter Maydell (2):
Kconfig: Add I2C_DEVICES device group
Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus
docs/devel/kconfig.rst | 8 ++++++-- hw/arm/Kconfig | 10 ++++++++++ hw/i2c/Kconfig | 5 +++++ hw/rtc/Kconfig | 2 ++ hw/sensor/Kconfig | 5 +++++ 5 files changed, 28 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
Quoted 18 lines · Peter Maydell
This patchset adds a new
Kconfig"device group" for I2C devices which a user might reasonably want to plug in to an arbitrary i2c bus via the command line. This follows the approach we use for PCI devices:
generally-usable i2c devices have
default y ifI2C_DEVICES
and board models with user-accessible i2c buses have
implyI2C_DEVICESThis means that when building a board model that pulls in the device group, the devices are all compiled in and available for use. (Previously they would happen to be present and usable only if some other board that explicitly pulled that device in happened to also be built into the same QEMU binary.)
I have been fairly conservative in marking devices as being in the group and in marking board models as pulling in the group; feel free to suggest changes.
Quoted 8 lines
In particular I've only added 'imply
I2C_DEVICES' to arm boards. Grepping throughKconfigfiles I only found the PPC boards e500 and ppc44x that enable some kind of i2c controller anyway.The immediate motivation here is that the recently added lsm303dlhc magnetometer isn't currently built unless the user manually adds it to their config, because as it happens no boards have it as a hard-wired device.
Quoted 14 lines
thanks
-- PMMPeter Maydell (2):
Kconfig: AddI2C_DEVICESdevice group
Kconfig: Add 'implyI2C_DEVICES' on boards with available i2c busdocs/devel/kconfig.rst | 8 ++++++-- hw/arm/Kconfig | 10 ++++++++++ hw/i2c/Kconfig | 5 +++++ hw/rtc/Kconfig | 2 ++ hw/sensor/Kconfig | 5 +++++ 5 files changed, 28 insertions(+), 2 deletions(-)
PATCH 1/2 Kconfig: Add I2C_DEVICES device group
In reply to Peter MaydellCurrently there is no way for a board model's Kconfig stanza to say "I have an i2c bus which the user can plug an i2c device into, build all the free-standing i2c devices". The Kconfig mechanism for this is the "device group". Add an I2C_DEVICES group along the same lines as the existing PCI_DEVICES. Simple free-standing i2c devices which a user might plausibly want to be able to plug in on the QEMU commandline should have
default y if I2C_DEVICES
and board models which have an i2c bus that is user-accessible should use
imply I2C_DEVICES
to cause those pluggable devices to be built.
In this commit we mark only a fairly conservative set of i2c devices as belonging to the I2C_DEVICES group: the simple sensors and RTCs (not including PMBus devices or devices which need GPIO lines to be connected).
---
Feel free to suggest other i2c devices that should be marked as in the group; as I say, I erred on the side of not putting devices in the group.
--- docs/devel/kconfig.rst | 8 ++++++-- hw/i2c/Kconfig | 5 +++++ hw/rtc/Kconfig | 2 ++ hw/sensor/Kconfig | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-)
docs/devel/kconfig.rst +6 -2
@@ -192,11 +192,15 @@ declares its dependencies in different ways: no directive and are not used in the Makefile either; they only appear as conditions for ``default y`` directives. - QEMU currently has two device groups, ``PCI_DEVICES`` and - ``TEST_DEVICES``. PCI devices usually have a ``default y if + QEMU currently has three device groups, ``PCI_DEVICES``, ``I2C_DEVICES``, + and ``TEST_DEVICES``. PCI devices usually have a ``default y if PCI_DEVICES`` directive rather than just ``default y``. This lets some boards (notably s390) easily support a subset of PCI devices, for example only VFIO (passthrough) and virtio-pci devices. + ``I2C_DEVICES`` is similar to ``PCI_DEVICES``. It contains i2c devices + that users might reasonably want to plug in to an i2c bus on any + board (and not ones which are very board-specific or that need + to be wired up in a way that can't be done on the command line). ``TEST_DEVICES`` instead is used for devices that are rarely used on production virtual machines, but provide useful hooks to test QEMU or KVM.
hw/i2c/Kconfig +5 -0
@@ -1,6 +1,11 @@ config I2C bool +config I2C_DEVICES + # Device group for i2c devices which can reasonably be user-plugged + # to any board's i2c bus + bool + config SMBUS bool select I2C
hw/rtc/Kconfig +2 -0
@@ -1,10 +1,12 @@ config DS1338 bool depends on I2C + default y if I2C_DEVICES config M41T80 bool depends on I2C + default y if I2C_DEVICES config M48T59 bool
hw/sensor/Kconfig +5 -0
@@ -1,18 +1,22 @@ config TMP105 bool depends on I2C + default y if I2C_DEVICES config TMP421 bool depends on I2C + default y if I2C_DEVICES config DPS310 bool depends on I2C + default y if I2C_DEVICES config EMC141X bool depends on I2C + default y if I2C_DEVICES config ADM1272 bool
@@ -25,3 +29,4 @@ config MAX34451 config LSM303DLHC_MAG bool depends on I2C + default y if I2C_DEVICES
Signature · 1 line
2.25.1
Re: [PATCH 1/2] Kconfig: Add I2C_DEVICES device group
Quoted 13 lines · Peter Maydell
Currently there is no way for a board model's
Kconfigstanza to say "I have an i2c bus which the user can plug an i2c device into, build all the free-standing i2c devices". TheKconfigmechanism for this is the "device group". Add anI2C_DEVICESgroup along the same lines as the existingPCI_DEVICES. Simple free-standing i2c devices which a user might plausibly want to be able to plug in on the QEMU commandline should have
default y ifI2C_DEVICES
and board models which have an i2c bus that is user-accessible should use
implyI2C_DEVICES
to cause those pluggable devices to be built.
Quoted 7 lines
In this commit we mark only a fairly conservative set of i2c devices as belonging to the
I2C_DEVICESgroup: the simple sensors and RTCs (not including PMBus devices or devices which need GPIO lines to be connected).Signed-off-by Peter Maydell <[email protected]>
Quoted 104 lines
---
Feel free to suggest other i2c devices that should be marked as in the group; as I say, I erred on the side of not putting devices in the group.--- docs/devel/kconfig.rst | 8 ++++++-- hw/i2c/Kconfig | 5 +++++ hw/rtc/Kconfig | 2 ++ hw/sensor/Kconfig | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-)docs/devel/kconfig.rst +6
-2@@ -192,11 +192,15 @@ declares its dependencies in different ways: no directive and are not used in the Makefile either; they only appear as conditions for ``default y`` directives. - QEMU currently has two device groups, ``PCI_DEVICES`` and - ``TEST_DEVICES``. PCI devices usually have a ``default y if + QEMU currently has three device groups, ``PCI_DEVICES``, ``I2C_DEVICES``, + and ``TEST_DEVICES``. PCI devices usually have a ``default y if PCI_DEVICES`` directive rather than just ``default y``. This lets some boards (notably s390) easily support a subset of PCI devices, for example only VFIO (passthrough) and virtio-pci devices. + ``I2C_DEVICES`` is similar to ``PCI_DEVICES``. It contains i2c devices + that users might reasonably want to plug in to an i2c bus on any + board (and not ones which are very board-specific or that need + to be wired up in a way that can't be done on the command line). ``TEST_DEVICES`` instead is used for devices that are rarely used on production virtual machines, but provide useful hooks to test QEMUor KVM.
hw/i2c/Kconfig +5
-0@@ -1,6 +1,11 @@ config I2C bool +config I2C_DEVICES + # Device group for i2c devices which can reasonably be user-plugged + # to any board's i2c bus + bool + config SMBUS bool select I2Chw/rtc/Kconfig +2
-0@@ -1,10 +1,12 @@ config DS1338 bool depends on I2C + default y if I2C_DEVICES config M41T80 bool depends on I2C + default y if I2C_DEVICES config M48T59 boolhw/sensor/Kconfig +5
-1@@ -1,18 +1,22 @@ config TMP105 bool depends on I2C + default y if I2C_DEVICES config TMP421 bool depends on I2C + default y if I2C_DEVICES config DPS310 bool depends on I2C + default y if I2C_DEVICES config EMC141X bool depends on I2C + default y if I2C_DEVICES config ADM1272 bool@@ -25,3 +29,4 @@ config MAX34451 config LSM303DLHC_MAG bool depends on I2C + default y if I2C_DEVICES --2.25.1
PATCH 2/2 Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus
In reply to Peter MaydellFor arm boards with an i2c bus which a user could reasonably want to plug arbitrary devices, add 'imply I2C_DEVICES' to the Kconfig stanza.
---
Again, slightly arbitrary but erring on the side of conservative. I leave non-Arm architectures out (afaict only ppc ppc4xx and e500 enable any kind of I2C controller in their Kconfig anyway).
--- hw/arm/Kconfig | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/arm/Kconfig +10 -0
@@ -46,6 +46,7 @@ config DIGIC config EXYNOS4 bool + imply I2C_DEVICES select A9MPCORE select I2C select LAN9118
@@ -184,6 +185,7 @@ config REALVIEW bool imply PCI_DEVICES imply PCI_TESTDEV + imply I2C_DEVICES select SMC91C111 select LAN9118 select A9MPCORE
@@ -229,6 +231,7 @@ config SABRELITE config STELLARIS bool + imply I2C_DEVICES select ARM_V7M select CMSDK_APB_WATCHDOG select I2C
@@ -406,6 +409,7 @@ config NPCM7XX config FSL_IMX25 bool + imply I2C_DEVICES select IMX select IMX_FEC select IMX_I2C
@@ -414,6 +418,7 @@ config FSL_IMX25 config FSL_IMX31 bool + imply I2C_DEVICES select SERIAL select IMX select IMX_I2C
@@ -422,6 +427,7 @@ config FSL_IMX31 config FSL_IMX6 bool + imply I2C_DEVICES select A9MPCORE select IMX select IMX_FEC
@@ -450,6 +456,7 @@ config ASPEED_SOC config MPS2 bool + imply I2C_DEVICES select ARMSSE select LAN9118 select MPS2_FPGAIO
@@ -466,6 +473,7 @@ config FSL_IMX7 bool imply PCI_DEVICES imply TEST_DEVICES + imply I2C_DEVICES select A15MPCORE select PCI select IMX
@@ -481,6 +489,7 @@ config ARM_SMMUV3 config FSL_IMX6UL bool + imply I2C_DEVICES select A15MPCORE select IMX select IMX_FEC
@@ -495,6 +504,7 @@ config MICROBIT config NRF51_SOC bool + imply I2C_DEVICES select I2C select ARM_V7M select UNIMP
Signature · 1 line
2.25.1
Re: [PATCH 2/2] Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus
Quoted 6 lines · Peter Maydell
For arm boards with an i2c bus which a user could reasonably want to plug arbitrary devices, add 'imply
I2C_DEVICES' to theKconfigstanza.Signed-off-by Peter Maydell <[email protected]>
Quoted 97 lines
---
Again, slightly arbitrary but erring on the side of conservative. I leave non-Arm architectures out (afaict only ppc ppc4xx and e500 enable any kind of I2C controller in theirKconfiganyway).--- hw/arm/Kconfig | 10 ++++++++++ 1 file changed, 10 insertions(+)hw/arm/Kconfig +10
-1@@ -46,6 +46,7 @@ config DIGIC config EXYNOS4 bool + imply I2C_DEVICES select A9MPCORE select I2C select LAN9118@@ -184,6 +185,7 @@ config REALVIEW bool imply PCI_DEVICES imply PCI_TESTDEV + imply I2C_DEVICES select SMC91C111 select LAN9118 select A9MPCORE@@ -229,6 +231,7 @@ config SABRELITE config STELLARIS bool + imply I2C_DEVICES select ARM_V7M select CMSDK_APB_WATCHDOG select I2C@@ -406,6 +409,7 @@ config NPCM7XX config FSL_IMX25 bool + imply I2C_DEVICES select IMX select IMX_FEC select IMX_I2C@@ -414,6 +418,7 @@ config FSL_IMX25 config FSL_IMX31 bool + imply I2C_DEVICES select SERIAL select IMX select IMX_I2C@@ -422,6 +427,7 @@ config FSL_IMX31 config FSL_IMX6 bool + imply I2C_DEVICES select A9MPCORE select IMX select IMX_FEC@@ -450,6 +456,7 @@ config ASPEED_SOC config MPS2 bool + imply I2C_DEVICES select ARMSSE select LAN9118 select MPS2_FPGAIO@@ -466,6 +473,7 @@ config FSL_IMX7 bool imply PCI_DEVICES imply TEST_DEVICES + imply I2C_DEVICES select A15MPCORE select PCI select IMX@@ -481,6 +489,7 @@ config ARM_SMMUV3 config FSL_IMX6UL bool + imply I2C_DEVICES select A15MPCORE select IMX select IMX_FEC@@ -495,6 +504,7 @@ config MICROBIT config NRF51_SOC bool + imply I2C_DEVICES select I2C select ARM_V7M select UNIMP --2.25.1
Quoted 10 lines · Peter Maydell
Peter Maydell (2):
Kconfig: AddI2C_DEVICESdevice group
Kconfig: Add 'implyI2C_DEVICES' on boards with available i2c busdocs/devel/kconfig.rst | 8 ++++++-- hw/arm/Kconfig | 10 ++++++++++ hw/i2c/Kconfig | 5 +++++ hw/rtc/Kconfig | 2 ++ hw/sensor/Kconfig | 5 +++++ 5 files changed, 28 insertions(+), 2 deletions(-)
Series: