* [PATCH 1/2] Kconfig: Add I2C_DEVICES device group
2022-02-08 15:59 [PATCH 0/2] Kconfig: Add an I2C_DEVICES device group Peter Maydell
@ 2022-02-08 15:59 ` Peter Maydell
2022-02-08 18:03 ` Hao Wu
2022-02-08 15:59 ` [PATCH 2/2] Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus Peter Maydell
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2022-02-08 15:59 UTC (permalink / raw)
To: qemu-arm, qemu-devel
Cc: Paolo Bonzini, Philippe Mathieu-Daudé, Kevin Townsend
Currently 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).
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
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(-)
diff --git a/docs/devel/kconfig.rst b/docs/devel/kconfig.rst
index a1cdbec7512..aa5042f1569 100644
--- a/docs/devel/kconfig.rst
+++ b/docs/devel/kconfig.rst
@@ -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.
diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig
index 8217cb50411..9bb8870517f 100644
--- a/hw/i2c/Kconfig
+++ b/hw/i2c/Kconfig
@@ -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
diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
index f06e133b8a2..730c272bc54 100644
--- a/hw/rtc/Kconfig
+++ b/hw/rtc/Kconfig
@@ -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
diff --git a/hw/sensor/Kconfig b/hw/sensor/Kconfig
index b317f91b7b4..215944decc7 100644
--- a/hw/sensor/Kconfig
+++ b/hw/sensor/Kconfig
@@ -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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] Kconfig: Add I2C_DEVICES device group
2022-02-08 15:59 ` [PATCH 1/2] Kconfig: Add " Peter Maydell
@ 2022-02-08 18:03 ` Hao Wu
0 siblings, 0 replies; 7+ messages in thread
From: Hao Wu @ 2022-02-08 18:03 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-arm, QEMU Developers, Paolo Bonzini,
Philippe Mathieu-Daudé, Kevin Townsend
[-- Attachment #1: Type: text/plain, Size: 4092 bytes --]
On Tue, Feb 8, 2022 at 9:55 AM Peter Maydell <peter.maydell@linaro.org>
wrote:
> Currently 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).
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>
Reviewed-by: Hao Wu <wuhaotsh@google.com>
> ---
> 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(-)
>
> diff --git a/docs/devel/kconfig.rst b/docs/devel/kconfig.rst
> index a1cdbec7512..aa5042f1569 100644
> --- a/docs/devel/kconfig.rst
> +++ b/docs/devel/kconfig.rst
> @@ -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.
> diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig
> index 8217cb50411..9bb8870517f 100644
> --- a/hw/i2c/Kconfig
> +++ b/hw/i2c/Kconfig
> @@ -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
> diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
> index f06e133b8a2..730c272bc54 100644
> --- a/hw/rtc/Kconfig
> +++ b/hw/rtc/Kconfig
> @@ -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
> diff --git a/hw/sensor/Kconfig b/hw/sensor/Kconfig
> index b317f91b7b4..215944decc7 100644
> --- a/hw/sensor/Kconfig
> +++ b/hw/sensor/Kconfig
> @@ -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
>
>
>
[-- Attachment #2: Type: text/html, Size: 5203 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus
2022-02-08 15:59 [PATCH 0/2] Kconfig: Add an I2C_DEVICES device group Peter Maydell
2022-02-08 15:59 ` [PATCH 1/2] Kconfig: Add " Peter Maydell
@ 2022-02-08 15:59 ` Peter Maydell
2022-02-08 18:04 ` Hao Wu
2022-02-08 16:20 ` [PATCH 0/2] Kconfig: Add an I2C_DEVICES device group Paolo Bonzini
2022-02-10 11:19 ` Philippe Mathieu-Daudé via
3 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2022-02-08 15:59 UTC (permalink / raw)
To: qemu-arm, qemu-devel
Cc: Paolo Bonzini, Philippe Mathieu-Daudé, Kevin Townsend
For arm boards with an i2c bus which a user could reasonably
want to plug arbitrary devices, add 'imply I2C_DEVICES' to the
Kconfig stanza.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
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(+)
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 2e0049196d6..6945330030e 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus
2022-02-08 15:59 ` [PATCH 2/2] Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus Peter Maydell
@ 2022-02-08 18:04 ` Hao Wu
0 siblings, 0 replies; 7+ messages in thread
From: Hao Wu @ 2022-02-08 18:04 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-arm, QEMU Developers, Paolo Bonzini,
Philippe Mathieu-Daudé, Kevin Townsend
[-- Attachment #1: Type: text/plain, Size: 2432 bytes --]
On Tue, Feb 8, 2022 at 9:23 AM Peter Maydell <peter.maydell@linaro.org>
wrote:
> For arm boards with an i2c bus which a user could reasonably
> want to plug arbitrary devices, add 'imply I2C_DEVICES' to the
> Kconfig stanza.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>
Reviewed-by: Hao Wu <wuhaotsh@google.com>
> ---
> 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(+)
>
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 2e0049196d6..6945330030e 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -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
>
>
>
[-- Attachment #2: Type: text/html, Size: 3485 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] Kconfig: Add an I2C_DEVICES device group
2022-02-08 15:59 [PATCH 0/2] Kconfig: Add an I2C_DEVICES device group Peter Maydell
2022-02-08 15:59 ` [PATCH 1/2] Kconfig: Add " Peter Maydell
2022-02-08 15:59 ` [PATCH 2/2] Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus Peter Maydell
@ 2022-02-08 16:20 ` Paolo Bonzini
2022-02-10 11:19 ` Philippe Mathieu-Daudé via
3 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2022-02-08 16:20 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel
Cc: Philippe Mathieu-Daudé, Kevin Townsend
On 2/8/22 16:59, Peter Maydell wrote:
> 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.
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> 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(-)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] Kconfig: Add an I2C_DEVICES device group
2022-02-08 15:59 [PATCH 0/2] Kconfig: Add an I2C_DEVICES device group Peter Maydell
` (2 preceding siblings ...)
2022-02-08 16:20 ` [PATCH 0/2] Kconfig: Add an I2C_DEVICES device group Paolo Bonzini
@ 2022-02-10 11:19 ` Philippe Mathieu-Daudé via
3 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-10 11:19 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Paolo Bonzini, Kevin Townsend
On 8/2/22 16:59, Peter Maydell wrote:
> 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(-)
Series:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 7+ messages in thread