[PATCH v4 0/6] platform/chrome: Introduce DT hardware prober
Chen-Yu Tsai
wenst at chromium.org
Thu Aug 8 02:59:23 PDT 2024
Hi everyone,
This is v4 of my "of: Introduce hardware prober driver" [1] series.
v4 mainly adds regulator and GPIO support. This part was separately
tested on a MT8186 Voltorb device with a slightly device tree and
an extra entry in the ChromeOS hardware prober.
v2 continued Doug's "of: device: Support 2nd sources of probeable but
undiscoverable devices" [2] series, but follows the scheme suggested by
Rob, marking all second source component device nodes as "fail-needs-probe",
and having a hardware prober driver enable the one of them.
This time I trimmed down the Cc list.
Changes since v3:
- Patch 1 "of: dynamic: Add of_changeset_update_prop_string"
- Use new __of_prop_free() helper (helper was added by Rob in 2024/04)
- Add new line before header declaration
- Patch 2 "regulator: Add regulator_of_get_optional() for pure DT"
- New patch
- Patch 3 "i2c: Introduce OF component probe function"
- Complete kernel-doc
- Return different error if I2C controller is disabled
- Expand comment to explain assumptions and constraints
- Split for-loop finding target node and operations on target node
- Add missing i2c_put_adapter()
- Move prober code to separate file
- Patch 4 "i2c: of-prober: Add GPIO and regulator support"
- New patch
- Patch 5 "platform/chrome: Introduce device tree hardware prober"
- Include linux/init.h
- Rewrite for loop in driver probe function as suggested by Andy
- Make prober driver buildable as module
- Ignore prober errors other than probe deferral
- Patch 6 "arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads as fail"
- Rebased
Patch "arm64: dts: mediatek: mt8173-elm-hana: Add G2touch G7500 touchscreen"
was merged separately and thus removed from this series.
Changes since v2:
- Added of_changeset_update_prop_string()
- Moved generic I2C code to the I2C core
- Moved remaining platform specific code to platform/chrome/
- Switched to of_node_is_available() to check if node is enabled.
- Switched to OF changeset API to update status property
- I2C probe helper function now accepts "struct device *dev" instead to
reduce line length and dereferences
- Moved "ret = 0" to just before for_each_child_of_node(i2c_node, node)
- Depend on rather than select CONFIG_I2C
- Copied machine check to driver init function
- Explicitly mentioned "device tree" or OF in driver name, description
and Kconfig symbol
- Dropped filename from inside the file
- Made loop variable size_t (instead of unsigned int as Andy asked)
- Switched to PLATFORM_DEVID_NONE instead of raw -1
- Switched to standard goto error path pattern in hw_prober_driver_init()
- Dropped device class from status property
Patches removed from v3 and saved for later:
- of: base: Add of_device_is_fail
- of: hw_prober: Support Chromebook SKU ID based component selection
- dt-bindings: arm: mediatek: Remove SKU specific compatibles for Google Krane
- arm64: dts: mediatek: mt8183-kukui: Merge Krane device trees
For the I2C component (touchscreens and trackpads) case from the
original series, the hardware prober driver finds the particular
class of device in the device tree, gets its parent I2C adapter,
and tries to initiate a simple I2C read for each device under that
I2C bus. When it finds one that responds, it considers that one
present, marks it as "okay", and returns, letting the driver core
actually probe the device.
This works fine in most cases since these components are connected
via a ribbon cable and always have the same resources. The prober
will also grab these resources and enable them.
The other case, selecting a display panel to use based on the SKU ID
from the firmware, hit a bit of an issue with fixing the OF graph.
It has been left out since v3.
Patch 1 adds of_changeset_update_prop_string(), as requested by Rob.
Patch 2 adds a function for retrieving regulator supplies solely
using device tree nodes.
Patch 3 implements probing the I2C bus for presence of components as
a helper function in the I2C core.
Patch 4 implements regulator supply and GPIO support for the I2C
component prober.
Patch 5 adds a ChromeOS specific DT hardware prober. This initial
version targets the Hana Chromebooks, probing its I2C trackpads and
touchscreens.
Patch 6 modifies the Hana device tree and marks the touchscreens
and trackpads as "fail-needs-probe", ready for the driver to probe.
Assuming this is acceptable to folks, because there are compile
time dependencies, I think it would be easier for the code bits
(patches 1 through 4) to go through either the OF tree or I2C
tree. Patches 5 and 6 can go through the soc tree via the mediatek
tree.
Thanks
ChenYu
Chen-Yu Tsai (6):
of: dynamic: Add of_changeset_update_prop_string
regulator: Add regulator_of_get_optional() for pure DT regulator
lookup
i2c: Introduce OF component probe function
i2c: of-prober: Add GPIO and regulator support
platform/chrome: Introduce device tree hardware prober
arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads
as fail
.../boot/dts/mediatek/mt8173-elm-hana.dtsi | 13 +
arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 4 +-
drivers/i2c/Makefile | 1 +
drivers/i2c/i2c-core-of-prober.c | 425 ++++++++++++++++++
drivers/of/dynamic.c | 44 ++
drivers/platform/chrome/Kconfig | 11 +
drivers/platform/chrome/Makefile | 1 +
.../platform/chrome/chromeos_of_hw_prober.c | 107 +++++
drivers/regulator/core.c | 81 +++-
drivers/regulator/devres.c | 2 +-
drivers/regulator/internal.h | 2 +-
include/linux/i2c.h | 4 +
include/linux/of.h | 4 +
include/linux/regulator/consumer.h | 8 +
14 files changed, 681 insertions(+), 26 deletions(-)
create mode 100644 drivers/i2c/i2c-core-of-prober.c
create mode 100644 drivers/platform/chrome/chromeos_of_hw_prober.c
--
2.46.0.rc2.264.g509ed76dc8-goog
More information about the linux-arm-kernel
mailing list