drm/panel and i2c-hid: Allow panels and touchscreens to power sequence together
Subsystems (11)
v4 cover drm/panel and i2c-hid: Allow panels and touchscreens to power sequence together
The big motivation for this patch series is mostly described in the patch ("drm/panel: Add a way for other devices to follow panel state"), but to quickly summarize here: for touchscreens that are connected to a panel we need the ability to power sequence the two device together. This is not a new need, but so far we've managed to get by through a combination of inefficiency, added costs, or perhaps just a little bit of brokenness. It's time to do better. This patch series allows us to do better.
Assuming that people think this patch series looks OK, we'll have to figure out the right way to land it. The panel patches and i2c-hid patches will go through very different trees and so either we'll need an Ack from one side or the other or someone to create a tag for the other tree to pull in. This will _probably_ require the true drm-misc maintainers to get involved, not a lowly committer. ;-)
Version 4 of this series adds a new patch that suspends i2c-hid devices at remove time even for non panel-followers to make things consistent. It also attempts to isolate the panel follower code a bit more as per Benjamin's feedback on v3 and adds an item to the DRM todo list as per Maxime's request. As per Maxime's response to my v3 cover letter, I added his Reviewed-by tag to all 10 patches that were part of v3 (but left it off of the new i2c-hid patch in v4).
Version 3 of this series was a long time coming after v2. Maxime and I had a very long discussion trying to figure out if there was a beter way and in the end we didn't find one so he was OK with the series in general [1]. After that got resolved, I tried to resolve Benjamin's feedback but got stuck [2]. Eventually I made my best guess. The end result was a v3 that wasn't that different from v2 but that had a tiny bit more code split out.
Version 2 of this patch series didn't change too much. At a high level:
* I added all the forgotten "static" to functions.
* I've hopefully made the bindings better.
* I've integrated into fw_devlink.
* I cleaned up a few descriptions / comments.
As far as I can tell, as of v4 everyone is on the same page that this patch series looks like a reasonable solution to the problem and we just need to get all the nits fixed and figure out how to land it.
[1] https://lore.kernel.org/r/gkwymmfkdy2p2evz22wmbwgw42ii4wnvmvu64m3bghmj2jhv7x@4mbstjxnagxd
[2] https://lore.kernel.org/r/CAD=FV=VbdeomBGbWhppY+5TOSwt64GWBHga68OXFwsnO4gg4UA@mail.gmail.com
Changes in v4:
- Document further cleanup in the official DRM todo list.
- ("Suspend i2c-hid devices in remove") new for v4.
- Move panel follower alternative checks to wrapper functions.
- Rebase atop ("Suspend i2c-hid devices in remove").
Changes in v3:
- Add is_panel_follower() as a convenience for clients.
- Add "depends on DRM || !DRM" to Kconfig to avoid randconfig error.
- Split more of the panel follower code out of the core.
Changes in v2:
- Move the description to the generic touchscreen.yaml.
- Update the desc to make it clearer it's only for integrated devices.
- Add even more text to the commit message.
- A few comment cleanups.
- ("Add a devlink for panel followers") new for v2.
- i2c_hid_core_initial_power_up() is now static.
- i2c_hid_core_panel_prepared() and ..._unpreparing() are now static.
- ihid_core_panel_prepare_work() is now static.
- Improve documentation for smp_wmb().
Douglas Anderson (11):
dt-bindings: HID: i2c-hid: Add "panel" property to i2c-hid backed
touchscreens
drm/panel: Check for already prepared/enabled in drm_panel drm/panel: Add a way for other devices to follow panel state
of: property: fw_devlink: Add a devlink for panel followers
HID: i2c-hid: Switch to SYSTEM_SLEEP_PM_OPS()
HID: i2c-hid: Rearrange probe() to power things up later
HID: i2c-hid: Make suspend and resume into helper functions
HID: i2c-hid: Suspend i2c-hid devices in remove
HID: i2c-hid: Support being a panel follower
HID: i2c-hid: Do panel follower work on the system_wq
arm64: dts: qcom: sc7180: Link trogdor touchscreens to the panels
.../bindings/input/elan,ekth6915.yaml | 5 + .../bindings/input/goodix,gt7375p.yaml | 5 + .../bindings/input/hid-over-i2c.yaml | 2 + .../input/touchscreen/touchscreen.yaml | 7 + Documentation/gpu/todo.rst | 24 ++ .../boot/dts/qcom/sc7180-trogdor-coachz.dtsi | 1 + .../dts/qcom/sc7180-trogdor-homestar.dtsi | 1 + .../boot/dts/qcom/sc7180-trogdor-lazor.dtsi | 1 + .../boot/dts/qcom/sc7180-trogdor-pompom.dtsi | 1 + .../qcom/sc7180-trogdor-quackingstick.dtsi | 1 + .../dts/qcom/sc7180-trogdor-wormdingler.dtsi | 1 + drivers/gpu/drm/drm_panel.c | 218 ++++++++++- drivers/hid/i2c-hid/Kconfig | 2 + drivers/hid/i2c-hid/i2c-hid-core.c | 349 +++++++++++++----- drivers/of/property.c | 2 + include/drm/drm_panel.h | 94 +++++ 16 files changed, 617 insertions(+), 97 deletions(-)
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 1/11 dt-bindings: HID: i2c-hid: Add "panel" property to i2c-hid backed touchscreens
As talked about in the patch ("drm/panel: Add a way for other devices to follow panel state"), touchscreens that are connected to panels are generally expected to be power sequenced together with the panel they're attached to. Today, nothing provides information allowing you to find out that a touchscreen is connected to a panel. Let's add a phandle for this.
The proerty is added to the generic touchscreen bindings and then enabled in the bindings for the i2c-hid backed devices. This can and should be added for other touchscreens in the future, but for now let's start small.
---
(no changes since v2)
Changes in v2:
- Move the description to the generic touchscreen.yaml.
- Update the desc to make it clearer it's only for integrated devices.
Documentation/devicetree/bindings/input/elan,ekth6915.yaml | 5 +++++ .../devicetree/bindings/input/goodix,gt7375p.yaml | 5 +++++ Documentation/devicetree/bindings/input/hid-over-i2c.yaml | 2 ++ .../devicetree/bindings/input/touchscreen/touchscreen.yaml | 7 +++++++ 4 files changed, 19 insertions(+)
Documentation/devicetree/bindings/input/elan,ekth6915.yaml +5 -0
@@ -13,6 +13,9 @@ description: Supports the Elan eKTH6915 touchscreen controller. This touchscreen controller uses the i2c-hid protocol with a reset GPIO. +allOf: + - $ref: /schemas/input/touchscreen/touchscreen.yaml# + properties: compatible: items:
@@ -24,6 +27,8 @@ properties: interrupts: maxItems: 1 + panel: true + reset-gpios: description: Reset GPIO; not all touchscreens using eKTH6915 hook this up.
Documentation/devicetree/bindings/input/goodix,gt7375p.yaml +5 -0
@@ -14,6 +14,9 @@ description: This touchscreen uses the i2c-hid protocol but has some non-standard power sequencing required. +allOf: + - $ref: /schemas/input/touchscreen/touchscreen.yaml# + properties: compatible: oneOf:
@@ -30,6 +33,8 @@ properties: interrupts: maxItems: 1 + panel: true + reset-gpios: true
Documentation/devicetree/bindings/input/hid-over-i2c.yaml +2 -0
@@ -44,6 +44,8 @@ properties: description: HID descriptor address $ref: /schemas/types.yaml#/definitions/uint32 + panel: true + post-power-on-delay-ms: description: Time required by the device after enabling its regulators or powering it on, before it is ready for communication.
Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml +7 -0
@@ -10,6 +10,13 @@ maintainers: - Dmitry Torokhov <[email protected]> properties: + panel: + description: If this touchscreen is integrally connected to a panel, this + is a reference to that panel. The presence of this reference indicates + that the touchscreen should be power sequenced together with the panel + and that they may share power and/or reset signals. + $ref: /schemas/types.yaml#/definitions/phandle + touchscreen-min-x: description: minimum x coordinate reported $ref: /schemas/types.yaml#/definitions/uint32
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 2/11 drm/panel: Check for already prepared/enabled in drm_panel
In reply to Douglas AndersonIn a whole pile of panel drivers, we have code to make the prepare/unprepare/enable/disable callbacks behave as no-ops if they've already been called. It's silly to have this code duplicated everywhere. Add it to the core instead so that we can eventually delete it from all the drivers. Note: to get some idea of the duplicated code, try:
git grep 'if.*>prepared' -- drivers/gpu/drm/panel
git grep 'if.*>enabled' -- drivers/gpu/drm/panel
NOTE: arguably, the right thing to do here is actually to skip this patch and simply remove all the extra checks from the individual drivers. Perhaps the checks were needed at some point in time in the past but maybe they no longer are? Certainly as we continue transitioning over to "panel_bridge" then we expect there to be much less variety in how these calls are made. When we're called as part of the bridge chain, things should be pretty simple. In fact, there was some discussion in the past about these checks [1], including a discussion about whether the checks were needed and whether the calls ought to be refcounted. At the time, I decided not to mess with it because it felt too risky.
Looking closer at it now, I'm fairly certain that nothing in the existing codebase is expecting these calls to be refcounted. The only real question is whether someone is already doing something to ensure prepare()/unprepare() match and enabled()/disable() match. I would say that, even if there is something else ensuring that things match, there's enough complexity that adding an extra bool and an extra double-check here is a good idea. Let's add a drm_warn() to let people know that it's considered a minor error to take advantage of drm_panel's double-checking but we'll still make things work fine.
We'll also add an entry to the official DRM todo list to remove the now pointless check from the panels after this patch lands and, eventually, fixup anyone who is triggering the new warning.
[1] https://lore.kernel.org/r/20210416153909.v4.27.I502f2a92ddd36c3d28d014dd75e170c2d405a0a5@changeid
---
This has Neil's Ack and Maxime's review and I could commit it to drm-misc-next, but for now I'm holding off to land with the rest of this series since the second drm patch in my series depends on this one.
Once this lands somewhere, I'll take the action item to post patches to delete the now pointless checks in the individual panels.
Changes in v4:
- Document further cleanup in the official DRM todo list.
Documentation/gpu/todo.rst | 24 ++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 49 ++++++++++++++++++++++++++++++++----- include/drm/drm_panel.h | 14 +++++++++++ 3 files changed, 81 insertions(+), 6 deletions(-)
Documentation/gpu/todo.rst +24 -0
@@ -452,6 +452,30 @@ Contact: Thomas Zimmermann <[email protected]> Level: Starter +Clean up checks for already prepared/enabled in panels +------------------------------------------------------ + +In a whole pile of panel drivers, we have code to make the +prepare/unprepare/enable/disable callbacks behave as no-ops if they've already +been called. To get some idea of the duplicated code, try: + git grep 'if.*>prepared' -- drivers/gpu/drm/panel + git grep 'if.*>enabled' -- drivers/gpu/drm/panel + +In the patch ("drm/panel: Check for already prepared/enabled in drm_panel") +we've moved this check to the core. Now we can most definitely remove the +check from the individual panels and save a pile of code. + +In adition to removing the check from the individual panels, it is believed +that even the core shouldn't need this check and that should be considered +an error if other code ever relies on this check. The check in the core +currently prints a warning whenever something is relying on this check with +dev_warn(). After a little while, we likely want to promote this to a +WARN(1) to help encourage folks not to rely on this behavior. + +Contact: Douglas Anderson <[email protected]> + +Level: Starter/Intermediate + Core refactorings =================
drivers/gpu/drm/drm_panel.c +43 -6
89 lines not on this page · raw message
include/drm/drm_panel.h +14 -0
@@ -198,6 +198,20 @@ struct drm_panel {* the panel is powered up. */ bool prepare_prev_first; + +/** +* @prepared: +* +* If true then the panel has been prepared. +*/ +bool prepared; + +/** +* @enabled: +* +* If true then the panel has been enabled. +*/ +bool enabled; }; void drm_panel_init(struct drm_panel *panel, struct device *dev,
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 3/11 drm/panel: Add a way for other devices to follow panel state
In reply to Douglas AndersonThese days, it's fairly common to see panels that have touchscreens attached to them. The panel and the touchscreen can somewhat be thought of as totally separate devices and, historically, this is how Linux has treated them. However, treating them as separate isn't necessarily the best way to model the two devices, it was just that there was no better way. Specifically, there is little practical reason to have the touchscreen powered on when the panel is turned off, but if we model the devices separately we have no way to keep the two devices' power states in sync with each other.
The issue described above makes it sound as if the problem here is just about efficiency. We're wasting power keeping the touchscreen powered up when the screen is off. While that's true, the problem can go deeper. Specifically, hardware designers see that there's no reason to have the touchscreen on while the screen is off and then build hardware assuming that software would never turn the touchscreen on while the screen is off.
In the very simplest case of hardware designs like this, the touchscreen and the panel share some power rails. In most cases, this turns out not to be terrible and is, again, just a little less efficient. Specifically if we tell Linux that the touchscreen and the panel are using the same rails then Linux will keep the rails on when _either_ device is turned on. That ends to work OK-ish, but now if you turn the panel off not only will the touchscreen remain powered, but the power rails for the panel itself won't be switched off, burning extra power.
The above two inefficiencies are _extra_ minor when you consider the fact that laptops rarely spend much time with the screen off. The main use case would be when an external screen (and presumably a power supply) is attached.
Unfortunately, it gets worse from here. On sc7180-trogdor-homestar, for instance, the display's TCON (timing controller) sometimes crashes if you don't power cycle it whenever you stop and restart the video stream (like during a modeset). The touchscreen keeping the power rails on causes real problems. One proposal in the homestar timeframe was to move the touchscreen to an always-on rail, dedicating the main power rail to the panel. That caused _different_ problems as talked about in commit 557e05fa9fdd ("HID: i2c-hid: goodix: Stop tying the reset line to the regulator"). The end result of all of this was to add an extra regulator to the board, increasing cost.
Recently, Cong Yang posted a patch [1] where things are even worse. The panel and touch controller on that system seem even more intimately tied together and really can't be thought of separately.
To address this issue, let's start allowing devices to register themselves as "panel followers". These devices will get called after a panel has been powered on and before a panel is powered off. This makes the panel the primary device in charge of the power state, which matches how userspace uses it.
The panel follower API should be fairly straightforward to use. The current code assumes that panel followers are using device tree and have a "panel" property pointing to the panel to follow. More flexibility and non-DT implementations could be added as needed.
Right now, panel followers can follow the prepare/unprepare functions. There could be arguments made that, instead, they should follow enable/disable. I've chosen prepare/unprepare for now since those functions are guaranteed to power up/power down the panel and it seems better to start the process earlier.
A bit of explaining about why this is a roll-your-own API instead of using something more standard:
1. In standard APIs in Linux, parent devices are automatically powered on when a child needs power. Applying that here, it would mean that we'd force the panel on any time someone was listening to the touchscreen. That, unfortunately, would have broken homestar's need (if we hadn't changed the hardware, as per above) where the panel absolutely needs to be able to power cycle itself. While one could argue that homestar is broken hardware and we shouldn't have the API do backflips for it, _officially_ the eDP timing guidelines agree with homestar's needs and the panel power sequencing diagrams show power going off. It's nice to be able to support this.
2. We could, conceibably, try to add a new flag to device_link causing the parent to be in charge of power. Then we could at least use normal pm_runtime APIs. This sounds great, except that we run into problems with initial probe. As talked about in the later patch ("HID: i2c-hid: Support being a panel follower") the initial power on of a panel follower might need to do things (like add sub-devices) that aren't allowed in a runtime_resume function.
The above complexities explain why this API isn't using common functions. That being said, this patch is very small and self-contained, so if someone was later able to adapt it to using more common APIs while solving the above issues then that could happen in the future.
[1] https://lore.kernel.org/r/20230519032316.3464732-1-yangcong5@huaqin.corp-partner.google.com
---
(no changes since v3)
Changes in v3:
- Add is_panel_follower() as a convenience for clients.
Changes in v2:
- Add even more text to the commit message.
- A few comment cleanups.
drivers/gpu/drm/drm_panel.c | 173 +++++++++++++++++++++++++++++++++++- include/drm/drm_panel.h | 80 +++++++++++++++++ 2 files changed, 249 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_panel.c +169 -4
@@ -58,6 +58,8 @@ void drm_panel_init(struct drm_panel *panel, struct device *dev, const struct drm_panel_funcs *funcs, int connector_type) { INIT_LIST_HEAD(&panel->list); +INIT_LIST_HEAD (&panel->followers); +mutex_init (&panel->follower_lock); panel->dev = dev; panel->funcs = funcs; panel->connector_type = connector_type;
@@ -105,6 +107,7 @@ EXPORT_SYMBOL(drm_panel_remove);*/ int drm_panel_prepare (struct drm_panel *panel) { +struct drm_panel_follower *follower;int ret;if (!panel)
@@ -115,14 +118,27 @@ int drm_panel_prepare(struct drm_panel *panel)return 0 ; } +mutex_lock (&panel->follower_lock); +if (panel->funcs && panel->funcs->prepare) { ret = panel->funcs->prepare (panel);if (ret <0 ) -return ret; + goto exit; } panel->prepared = true; -return 0 ; +list_for_each_entry (follower, &panel->followers, list) { + ret = follower->funcs->panel_prepared (follower); +if (ret <0 ) +dev_info (panel->dev,"%ps failed: %d\n" , + follower->funcs->panel_prepared, ret); + } + + ret =0 ; +exit: +mutex_unlock (&panel->follower_lock); + +return ret; }EXPORT_SYMBOL (drm_panel_prepare);
@@ -139,6 +155,7 @@ EXPORT_SYMBOL(drm_panel_prepare);*/ int drm_panel_unprepare (struct drm_panel *panel) { +struct drm_panel_follower *follower;int ret;if (!panel)
@@ -149,14 +166,27 @@ int drm_panel_unprepare(struct drm_panel *panel)return 0 ; } +mutex_lock (&panel->follower_lock); + +list_for_each_entry (follower, &panel->followers, list) { + ret = follower->funcs->panel_unpreparing (follower); +if (ret <0 ) +dev_info (panel->dev,"%ps failed: %d\n" , + follower->funcs->panel_unpreparing, ret); + } +if (panel->funcs && panel->funcs->unprepare) { ret = panel->funcs->unprepare (panel);if (ret <0 ) -return ret; + goto exit; } panel->prepared = false; -return 0 ; + ret =0 ; +exit: +mutex_unlock (&panel->follower_lock); + +return ret; }EXPORT_SYMBOL (drm_panel_unprepare);
@@ -342,6 +372,141 @@ int of_drm_get_panel_orientation(const struct device_node *np,EXPORT_SYMBOL (of_drm_get_panel_orientation);#endif +/** +* drm_is_panel_follower() - Check if the device is a panel follower +* @dev: The 'struct device' to check +* +* This checks to see if a device needs to be power sequenced together with +* a panel using the panel follower API. +* At the moment panels can only be followed on device tree enabled systems. +* The "panel" property of the follower points to the panel to be followed. +* +* Return: true if we should be power sequenced with a panel; false otherwise. +*/ +bool drm_is_panel_follower (struct device *dev) +{ +/* +* The "panel" property is actually a phandle, but for simplicity we +* don't bother trying to parse it here. We just need to know if the +* property is there. +*/ +return of_property_read_bool (dev->of_node,"panel" ); +} +EXPORT_SYMBOL (drm_is_panel_follower); + +/** +* drm_panel_add_follower() - Register something to follow panel state. +* @follower_dev: The 'struct device' for the follower. +* @follower: The panel follower descriptor for the follower. +* +* A panel follower is called right after preparing the panel and right before +* unpreparing the panel. It's primary intention is to power on an associated +* touchscreen, though it could be used for any similar devices. Multiple +* devices are allowed the follow the same panel. +* +* If a follower is added to a panel that's already been turned on, the +* follower's prepare callback is called right away. +* +* At the moment panels can only be followed on device tree enabled systems. +* The "panel" property of the follower points to the panel to be followed. +* +* Return: 0 or an error code. Note that -ENODEV means that we detected that +* follower_dev is not actually following a panel. The caller may +* choose to ignore this return value if following a panel is optional. +*/ +int drm_panel_add_follower (struct device *follower_dev, +struct drm_panel_follower *follower) +{ +struct device_node *panel_np; +struct drm_panel *panel; +int ret; + + panel_np =of_parse_phandle (follower_dev->of_node,"panel" ,0 ); +if (!panel_np) +return -ENODEV ; + + panel =of_drm_find_panel (panel_np); +of_node_put (panel_np); +if (IS_ERR (panel)) +return PTR_ERR (panel); + +get_device (panel->dev); + follower->panel = panel; + +mutex_lock (&panel->follower_lock); + +list_add_tail (&follower->list, &panel->followers); +if (panel->prepared) { + ret = follower->funcs->panel_prepared (follower); +if (ret <0 ) +dev_info (panel->dev,"%ps failed: %d\n" , + follower->funcs->panel_prepared, ret); + } + +mutex_unlock (&panel->follower_lock); + +return 0 ; +} +EXPORT_SYMBOL (drm_panel_add_follower); + +/** +* drm_panel_remove_follower() - Reverse drm_panel_add_follower(). +* @follower: The panel follower descriptor for the follower. +* +* Undo drm_panel_add_follower(). This includes calling the follower's +* unprepare function if we're removed from a panel that's currently prepared. +* +* Return: 0 or an error code. +*/ +void drm_panel_remove_follower (struct drm_panel_follower *follower) +{ +struct drm_panel *panel = follower->panel; +int ret; + +mutex_lock (&panel->follower_lock); + +if (panel->prepared) { + ret = follower->funcs->panel_unpreparing (follower); +if (ret <0 ) +dev_info (panel->dev,"%ps failed: %d\n" , + follower->funcs->panel_unpreparing, ret); + } +list_del_init (&follower->list); + +mutex_unlock (&panel->follower_lock); + +put_device (panel->dev); +} +EXPORT_SYMBOL (drm_panel_remove_follower); + +static void drm_panel_remove_follower_void (void *follower) +{ +drm_panel_remove_follower (follower); +} + +/** +* devm_drm_panel_add_follower() - devm version of drm_panel_add_follower() +* @follower_dev: The 'struct device' for the follower. +* @follower: The panel follower descriptor for the follower. +* +* Handles calling drm_panel_remove_follower() using devm on the follower_dev. +* +* Return: 0 or an error code. +*/ +int devm_drm_panel_add_follower (struct device *follower_dev, +struct drm_panel_follower *follower) +{ +int ret; + + ret =drm_panel_add_follower (follower_dev, follower); +if (ret) +return ret; + +return devm_add_action_or_reset (follower_dev, + drm_panel_remove_follower_void, follower); +} +EXPORT_SYMBOL (devm_drm_panel_add_follower); +#if IS_REACHABLE (CONFIG_BACKLIGHT_CLASS_DEVICE )/** * drm_panel_of_backlight - use backlight device node for backlight
include/drm/drm_panel.h +80 -0
110 lines not on this page · raw message
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 4/11 of: property: fw_devlink: Add a devlink for panel followers
In reply to Douglas AndersonInform fw_devlink of the fact that a panel follower (like a touchscreen) is effectively a consumer of the panel from the purposes of fw_devlink.
NOTE: this patch isn't required for correctness but instead optimizes probe order / helps avoid deferrals.
---
Since this is so small, I'd presume it's OK for it to go through a DRM tree with the proper Ack. That being said, this patch is just an optimization and thus it could land completely separately from the rest and they could all meet up in mainline.
(no changes since v2)
Changes in v2:
- ("Add a devlink for panel followers") new for v2.
drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/property.c +2 -0
@@ -1266,6 +1266,7 @@ DEFINE_SIMPLE_PROP(pwms, "pwms", "#pwm-cells") DEFINE_SIMPLE_PROP(resets, "resets", "#reset-cells") DEFINE_SIMPLE_PROP(leds, "leds", NULL) DEFINE_SIMPLE_PROP(backlight, "backlight", NULL) +DEFINE_SIMPLE_PROP(panel, "panel", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL)DEFINE_SUFFIX_PROP (gpio,"-gpio" ,"#gpio-cells" )
@@ -1354,6 +1355,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_resets, }, { .parse_prop = parse_leds, }, { .parse_prop = parse_backlight, }, + { .parse_prop = parse_panel, }, { .parse_prop = parse_gpio_compat, }, { .parse_prop = parse_interrupts, }, { .parse_prop = parse_regulators, },
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 5/11 HID: i2c-hid: Switch to SYSTEM_SLEEP_PM_OPS()
In reply to Douglas AndersonThe SYSTEM_SLEEP_PM_OPS() allows us to get rid of '#ifdef CONFIG_PM_SLEEP', as talked about in commit 1a3c7bb08826 ("PM: core:
Add new *_PM_OPS macros, deprecate old ones").
This change is expected to have no functional effect.
---
(no changes since v1)
drivers/hid/i2c-hid/i2c-hid-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/hid/i2c-hid/i2c-hid-core.c +1 -3
@@ -1085,7 +1085,6 @@ void i2c_hid_core_shutdown(struct i2c_client *client) }EXPORT_SYMBOL_GPL (i2c_hid_core_shutdown); -#ifdef CONFIG_PM_SLEEP static int i2c_hid_core_suspend (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);
@@ -1138,10 +1137,9 @@ static int i2c_hid_core_resume(struct device *dev)return hid_driver_reset_resume (hid); } -#endif const struct dev_pm_ops i2c_hid_core_pm = { -SET_SYSTEM_SLEEP_PM_OPS (i2c_hid_core_suspend, i2c_hid_core_resume) +SYSTEM_SLEEP_PM_OPS (i2c_hid_core_suspend, i2c_hid_core_resume) };EXPORT_SYMBOL_GPL (i2c_hid_core_pm);
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 6/11 HID: i2c-hid: Rearrange probe() to power things up later
In reply to Douglas AndersonIn a future patch, we want to change i2c-hid not to necessarily power up the touchscreen during probe. In preparation for that, rearrange the probe function so that we put as much stuff _before_ powering up the device as possible.
This change is expected to have no functional effect.
---
(no changes since v2)
Changes in v2:
- i2c_hid_core_initial_power_up() is now static.
drivers/hid/i2c-hid/i2c-hid-core.c | 124 ++++++++++++++++++----------- 1 file changed, 77 insertions(+), 47 deletions(-)
drivers/hid/i2c-hid/i2c-hid-core.c +77 -47
@@ -855,7 +855,8 @@ static int i2c_hid_init_irq(struct i2c_client *client) irqflags =IRQF_TRIGGER_LOW ; ret =request_threaded_irq (client->irq,NULL , i2c_hid_irq, - irqflags |IRQF_ONESHOT , client->name, ihid); + irqflags |IRQF_ONESHOT |IRQF_NO_AUTOEN , + client->name, ihid);if (ret <0 ) {dev_warn (&client->dev, "Could not register for %s interrupt, irq = %d,"
@@ -940,6 +941,72 @@ static void i2c_hid_core_shutdown_tail(struct i2c_hid *ihid) ihid->ops->shutdown_tail (ihid->ops); } +/** +* i2c_hid_core_initial_power_up() - First time power up of the i2c-hid device. +* @ihid: The ihid object created during probe. +* +* This function is called at probe time. +* +* The initial power on is where we do some basic validation that the device +* exists, where we fetch the HID descriptor, and where we create the actual +* HID devices. +* +* Return: 0 or error code. +*/ +static int i2c_hid_core_initial_power_up (struct i2c_hid *ihid) +{ +struct i2c_client *client = ihid->client; +struct hid_device *hid = ihid->hid; +int ret; + + ret =i2c_hid_core_power_up (ihid); +if (ret) +return ret; + +/* Make sure there is something at this address */ + ret =i2c_smbus_read_byte (client); +if (ret <0 ) { +i2c_hid_dbg (ihid,"nothing at this address: %d\n" , ret); + ret = -ENXIO ; + goto err; + } + + ret =i2c_hid_fetch_hid_descriptor (ihid); +if (ret <0 ) { +dev_err (&client->dev, +"Failed to fetch the HID Descriptor\n" ); + goto err; + } + +enable_irq (client->irq); + + hid->version =le16_to_cpu (ihid->hdesc.bcdVersion); + hid->vendor =le16_to_cpu (ihid->hdesc.wVendorID); + hid->product =le16_to_cpu (ihid->hdesc.wProductID); + + hid->initial_quirks |=i2c_hid_get_dmi_quirks (hid->vendor, + hid->product); + +snprintf (hid->name,sizeof (hid->name),"%s %04X:%04X" , + client->name, (u16 )hid->vendor, (u16 )hid->product); +strscpy (hid->phys,dev_name (&client->dev),sizeof (hid->phys)); + + ihid->quirks =i2c_hid_lookup_quirk (hid->vendor, hid->product); + + ret =hid_add_device (hid); +if (ret) { +if (ret != -ENODEV ) +hid_err (client,"can't add hid device: %d\n" , ret); + goto err; + } + +return 0 ; + +err: +i2c_hid_core_power_down (ihid); +return ret; +} +int i2c_hid_core_probe (struct i2c_client *client,struct i2chid_ops *ops,u16 hid_descriptor_address,u32 quirks) {
@@ -966,16 +1033,10 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,if (!ihid)return -ENOMEM ; - ihid->ops = ops; - - ret =i2c_hid_core_power_up (ihid); -if (ret) -return ret; -i2c_set_clientdata (client, ihid); + ihid->ops = ops; ihid->client = client; - ihid->wHIDDescRegister =cpu_to_le16 (hid_descriptor_address);init_waitqueue_head (&ihid->wait);
@@ -986,28 +1047,12 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,* real computation later. */ ret =i2c_hid_alloc_buffers (ihid,HID_MIN_BUFFER_SIZE );if (ret <0 ) - goto err_powered; - +return ret;device_enable_async_suspend (&client->dev); -/* Make sure there is something at this address */ - ret =i2c_smbus_read_byte (client); -if (ret <0 ) { -i2c_hid_dbg (ihid,"nothing at this address: %d\n" , ret); - ret = -ENXIO ; - goto err_powered; - } - - ret =i2c_hid_fetch_hid_descriptor (ihid); -if (ret <0 ) { -dev_err (&client->dev, -"Failed to fetch the HID Descriptor\n" ); - goto err_powered; - } - ret =i2c_hid_init_irq (client);if (ret <0 ) - goto err_powered; + goto err_buffers_allocated; hid =hid_allocate_device ();if (IS_ERR (hid)) {
@@ -1021,26 +1066,11 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, hid->ll_driver = &i2c_hid_ll_driver; hid->dev.parent = &client->dev; hid->bus =BUS_I2C ; - hid->version =le16_to_cpu (ihid->hdesc.bcdVersion); - hid->vendor =le16_to_cpu (ihid->hdesc.wVendorID); - hid->product =le16_to_cpu (ihid->hdesc.wProductID); - hid->initial_quirks = quirks; - hid->initial_quirks |=i2c_hid_get_dmi_quirks (hid->vendor, - hid->product); - -snprintf (hid->name,sizeof (hid->name),"%s %04X:%04X" , - client->name, (u16 )hid->vendor, (u16 )hid->product); -strscpy (hid->phys,dev_name (&client->dev),sizeof (hid->phys)); - - ihid->quirks =i2c_hid_lookup_quirk (hid->vendor, hid->product); - ret =hid_add_device (hid); -if (ret) { -if (ret != -ENODEV ) -hid_err (client,"can't add hid device: %d\n" , ret); + ret =i2c_hid_core_initial_power_up (ihid); +if (ret) goto err_mem_free; - }return 0 ;
@@ -1050,9 +1080,9 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, err_irq:free_irq (client->irq, ihid); -err_powered: -i2c_hid_core_power_down (ihid); +err_buffers_allocated:i2c_hid_free_buffers (ihid); +return ret; }EXPORT_SYMBOL_GPL (i2c_hid_core_probe);
@@ -1062,6 +1092,8 @@ void i2c_hid_core_remove(struct i2c_client *client)struct i2c_hid *ihid =i2c_get_clientdata (client);struct hid_device *hid; +i2c_hid_core_power_down (ihid); + hid = ihid->hid;hid_destroy_device (hid);
@@ -1069,8 +1101,6 @@ void i2c_hid_core_remove(struct i2c_client *client)if (ihid->bufsize)i2c_hid_free_buffers (ihid); - -i2c_hid_core_power_down (ihid); }EXPORT_SYMBOL_GPL (i2c_hid_core_remove);
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 7/11 HID: i2c-hid: Make suspend and resume into helper functions
In reply to Douglas AndersonIn a future patch we'd like to be able to call the current i2c-hid suspend and resume functions from times other than system suspend. Move the functions higher up in the file and have them take a "struct i2c_hid" to make this simpler. We'll then add tiny wrappers of the functions for use with system suspend.
This change is expected to have no functional effect.
---
(no changes since v1)
drivers/hid/i2c-hid/i2c-hid-core.c | 98 +++++++++++++++++------------- 1 file changed, 56 insertions(+), 42 deletions(-)
drivers/hid/i2c-hid/i2c-hid-core.c +56 -42
@@ -941,6 +941,57 @@ static void i2c_hid_core_shutdown_tail(struct i2c_hid *ihid) ihid->ops->shutdown_tail (ihid->ops); } +static int i2c_hid_core_suspend (struct i2c_hid *ihid) +{ +struct i2c_client *client = ihid->client; +struct hid_device *hid = ihid->hid; +int ret; + + ret =hid_driver_suspend (hid,PMSG_SUSPEND ); +if (ret <0 ) +return ret; + +/* Save some power */ +i2c_hid_set_power (ihid,I2C_HID_PWR_SLEEP ); + +disable_irq (client->irq); + +if (!device_may_wakeup (&client->dev)) +i2c_hid_core_power_down (ihid); + +return 0 ; +} + +static int i2c_hid_core_resume (struct i2c_hid *ihid) +{ +struct i2c_client *client = ihid->client; +struct hid_device *hid = ihid->hid; +int ret; + +if (!device_may_wakeup (&client->dev)) +i2c_hid_core_power_up (ihid); + +enable_irq (client->irq); + +/* Instead of resetting device, simply powers the device on. This +* solves "incomplete reports" on Raydium devices 2386:3118 and +* 2386:4B33 and fixes various SIS touchscreens no longer sending +* data after a suspend/resume. +* +* However some ALPS touchpads generate IRQ storm without reset, so +* let's still reset them here. +*/ +if (ihid->quirks &I2C_HID_QUIRK_RESET_ON_RESUME ) + ret =i2c_hid_hwreset (ihid); +else + ret =i2c_hid_set_power (ihid,I2C_HID_PWR_ON ); + +if (ret) +return ret; + +return hid_driver_reset_resume (hid); +} +/** * i2c_hid_core_initial_power_up() - First time power up of the i2c-hid device. * @ihid: The ihid object created during probe.
@@ -1115,61 +1166,24 @@ void i2c_hid_core_shutdown(struct i2c_client *client) }EXPORT_SYMBOL_GPL (i2c_hid_core_shutdown); -static int i2c_hid_core_suspend (struct device *dev) +static int i2c_hid_core_pm_suspend (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);struct i2c_hid *ihid =i2c_get_clientdata (client); -struct hid_device *hid = ihid->hid; -int ret; - - ret =hid_driver_suspend (hid,PMSG_SUSPEND ); -if (ret <0 ) -return ret; -/* Save some power */ -i2c_hid_set_power (ihid,I2C_HID_PWR_SLEEP ); - -disable_irq (client->irq); - -if (!device_may_wakeup (&client->dev)) -i2c_hid_core_power_down (ihid); - -return 0 ; +return i2c_hid_core_suspend (ihid); } -static int i2c_hid_core_resume (struct device *dev) +static int i2c_hid_core_pm_resume (struct device *dev) { -int ret;struct i2c_client *client =to_i2c_client (dev);struct i2c_hid *ihid =i2c_get_clientdata (client); -struct hid_device *hid = ihid->hid; -if (!device_may_wakeup (&client->dev)) -i2c_hid_core_power_up (ihid); - -enable_irq (client->irq); - -/* Instead of resetting device, simply powers the device on. This -* solves "incomplete reports" on Raydium devices 2386:3118 and -* 2386:4B33 and fixes various SIS touchscreens no longer sending -* data after a suspend/resume. -* -* However some ALPS touchpads generate IRQ storm without reset, so -* let's still reset them here. -*/ -if (ihid->quirks &I2C_HID_QUIRK_RESET_ON_RESUME ) - ret =i2c_hid_hwreset (ihid); -else - ret =i2c_hid_set_power (ihid,I2C_HID_PWR_ON ); - -if (ret) -return ret; - -return hid_driver_reset_resume (hid); +return i2c_hid_core_resume (ihid); }const struct dev_pm_ops i2c_hid_core_pm = { -SYSTEM_SLEEP_PM_OPS (i2c_hid_core_suspend, i2c_hid_core_resume) +SYSTEM_SLEEP_PM_OPS (i2c_hid_core_pm_suspend, i2c_hid_core_pm_resume) };EXPORT_SYMBOL_GPL (i2c_hid_core_pm);
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 8/11 HID: i2c-hid: Suspend i2c-hid devices in remove
In reply to Douglas AndersonIn the i2c-hid remove() function we currently try to power off, depopulate our child device, and free our resources. That's OK, but...
* If the i2c-hid device is on a power rail that can't turn off (either an always-on or a shared power rail) we won't try to put the device in a low power state during remove(). This probably doesn't matter for very many devices but it could be nice in some instances.
* If the i2c-hid device somehow manages to generate an interrupt after we tried to power off it is conceivable that the interrupt could arrive during or after the call to hid_destroy_device() but before the call to free_irq(). That could cause a crash since our IRQ handler isn't expecting it. One could imagine this happening in the case where we couldn't turn off (see the previous bullet) or, possibly, if the interrupt line could glitch shortly after the device powered off.
Let's call the suspend code during remove to avoid these issues. That will put the device into a low power state and also disable interrupts.
Technically, one could consider this a "fix" of commit 4a200c3b9a40 ("HID: i2c-hid: introduce HID over i2c specification implementation"). However, since the above bullet points are more theoretical than problems seen on real systems and since the remove() of an i2c-hid touchscreen isn't terribly likely to be called in production, it's probably not worth the bother of trying to backport it.
---
Changes in v4:
- ("Suspend i2c-hid devices in remove") new for v4.
drivers/hid/i2c-hid/i2c-hid-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hid/i2c-hid/i2c-hid-core.c +4 -4
@@ -941,7 +941,7 @@ static void i2c_hid_core_shutdown_tail(struct i2c_hid *ihid) ihid->ops->shutdown_tail (ihid->ops); } -static int i2c_hid_core_suspend (struct i2c_hid *ihid) +static int i2c_hid_core_suspend (struct i2c_hid *ihid,bool force_poweroff) {struct i2c_client *client = ihid->client;struct hid_device *hid = ihid->hid;
@@ -956,7 +956,7 @@ static int i2c_hid_core_suspend(struct i2c_hid *ihid)disable_irq (client->irq); -if (!device_may_wakeup (&client->dev)) +if (force_poweroff || !device_may_wakeup (&client->dev))i2c_hid_core_power_down (ihid);return 0 ;
@@ -1143,7 +1143,7 @@ void i2c_hid_core_remove(struct i2c_client *client)struct i2c_hid *ihid =i2c_get_clientdata (client);struct hid_device *hid; -i2c_hid_core_power_down (ihid); +i2c_hid_core_suspend (ihid, true); hid = ihid->hid;hid_destroy_device (hid);
@@ -1171,7 +1171,7 @@ static int i2c_hid_core_pm_suspend(struct device *dev)struct i2c_client *client =to_i2c_client (dev);struct i2c_hid *ihid =i2c_get_clientdata (client); -return i2c_hid_core_suspend (ihid); +return i2c_hid_core_suspend (ihid, false); }static int i2c_hid_core_pm_resume (struct device *dev)
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 9/11 HID: i2c-hid: Support being a panel follower
In reply to Douglas AndersonAs talked about in the patch ("drm/panel: Add a way for other devices to follow panel state"), we really want to keep the power states of a touchscreen and the panel it's attached to in sync with each other. In that spirit, add support to i2c-hid to be a panel follower. This will let the i2c-hid driver get informed when the panel is powered on and off. From there we can match the i2c-hid device's power state to that of the panel.
NOTE: this patch specifically _doesn't_ use pm_runtime to keep track of / manage the power state of the i2c-hid device, even though my first instinct said that would be the way to go. Specific problems with using pm_runtime():
* The initial power up couldn't happen in a runtime resume function since it create sub-devices and, apparently, that's not good to do in your resume function.
* Managing our power state with pm_runtime meant fighting to make the right thing happen at system suspend to prevent the system from trying to resume us only to suspend us again. While this might be able to be solved, it added complexity.
Overall the code without pm_runtime() ended up being smaller and easier to understand.
---
Changes in v4:
- Move panel follower alternative checks to wrapper functions.
- Rebase atop ("Suspend i2c-hid devices in remove").
Changes in v3:
- Add "depends on DRM || !DRM" to Kconfig to avoid randconfig error.
- Split more of the panel follower code out of the core.
Changes in v2:
- i2c_hid_core_panel_prepared() and ..._unpreparing() are now static.
drivers/hid/i2c-hid/Kconfig | 2 + drivers/hid/i2c-hid/i2c-hid-core.c | 93 +++++++++++++++++++++++++++++- 2 files changed, 92 insertions(+), 3 deletions(-)
drivers/hid/i2c-hid/Kconfig +2 -0
@@ -70,5 +70,7 @@ config I2C_HID_OF_GOODIX config I2C_HID_CORE tristate + # We need to call into panel code so if DRM=m, this can't be 'y' + depends on DRM || !DRM endif
drivers/hid/i2c-hid/i2c-hid-core.c +90 -3
141 lines not on this page · raw message
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 10/11 HID: i2c-hid: Do panel follower work on the system_wq
In reply to Douglas AndersonTurning on an i2c-hid device can be a slow process. This is why i2c-hid devices use PROBE_PREFER_ASYNCHRONOUS. Unfortunately, when we're a panel follower the i2c-hid power up sequence now blocks the power on of the panel. Let's fix that by scheduling the work on the system_wq.
---
(no changes since v2)
Changes in v2:
- ihid_core_panel_prepare_work() is now static.
- Improve documentation for smp_wmb().
drivers/hid/i2c-hid/i2c-hid-core.c | 50 +++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-)
drivers/hid/i2c-hid/i2c-hid-core.c +46 -4
@@ -110,7 +110,9 @@ struct i2c_hid {struct i2chid_ops *ops;struct drm_panel_follower panel_follower; +struct work_struct panel_follower_prepare_work;bool is_panel_follower; +bool prepare_work_finished; }; static const struct i2c_hid_quirks {
@@ -1062,10 +1064,12 @@ static int __do_i2c_hid_core_initial_power_up(struct i2c_hid *ihid)return ret; } -static int i2c_hid_core_panel_prepared (struct drm_panel_follower *follower) +static void ihid_core_panel_prepare_work (struct work_struct *work) { - struct i2c_hid *ihid = container_of(follower, struct i2c_hid, panel_follower); + struct i2c_hid *ihid = container_of(work, struct i2c_hid, + panel_follower_prepare_work);struct hid_device *hid = ihid->hid; +int ret;/* * hid->version is set on the first power up. If it's still zero then
@@ -1073,15 +1077,52 @@ static int i2c_hid_core_panel_prepared(struct drm_panel_follower *follower)* steps. */ if (!hid->version) -return __do_i2c_hid_core_initial_power_up (ihid); + ret =__do_i2c_hid_core_initial_power_up (ihid); +else + ret =i2c_hid_core_resume (ihid); -return i2c_hid_core_resume (ihid); +if (ret) +dev_warn (&ihid->client->dev,"Power on failed: %d\n" , ret); +else +WRITE_ONCE (ihid->prepare_work_finished, true); + +/* +* The work APIs provide a number of memory ordering guarantees +* including one that says that memory writes before schedule_work() +* are always visible to the work function, but they don't appear to +* guarantee that a write that happened in the work is visible after +* cancel_work_sync(). We'll add a write memory barrier here to match +* with i2c_hid_core_panel_unpreparing() to ensure that our write to +* prepare_work_finished is visible there. +*/ +smp_wmb (); +} + +static int i2c_hid_core_panel_prepared (struct drm_panel_follower *follower) +{ + struct i2c_hid *ihid = container_of(follower, struct i2c_hid, panel_follower); + +/* +* Powering on a touchscreen can be a slow process. Queue the work to +* the system workqueue so we don't block the panel's power up. +*/ +WRITE_ONCE (ihid->prepare_work_finished, false); +schedule_work (&ihid->panel_follower_prepare_work); + +return 0 ; }static int i2c_hid_core_panel_unpreparing (struct drm_panel_follower *follower) { struct i2c_hid *ihid = container_of(follower, struct i2c_hid, panel_follower); +cancel_work_sync (&ihid->panel_follower_prepare_work); + +/* Match with ihid_core_panel_prepare_work() */ +smp_rmb (); +if (!READ_ONCE (ihid->prepare_work_finished)) +return 0 ; +return i2c_hid_core_suspend (ihid, true); }
@@ -1173,6 +1214,7 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,init_waitqueue_head (&ihid->wait);mutex_init (&ihid->reset_lock); +INIT_WORK (&ihid->panel_follower_prepare_work, ihid_core_panel_prepare_work);/* we need to allocate the command buffer without knowing the maximum * size of the reports. Let's use HID_MIN_BUFFER_SIZE, then we do the
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH v4 11/11 arm64: dts: qcom: sc7180: Link trogdor touchscreens to the panels
In reply to Douglas AndersonLet's provide the proper link from the touchscreen to the panel on trogdor devices where the touchscreen support it. This allows the OS to power sequence the touchscreen more properly.
For the most part, this is just expected to marginally improve power consumption while the screen is off. However, in at least one trogdor model (wormdingler) it's suspected that this will fix some behavorial corner cases when the panel power cycles (like for a modeset) without the touchscreen power cycling.
NOTE: some trogdor variants use touchscreens that don't (yet) support linking the touchscreen and the panel. Those variants are left alone.
---
(no changes since v1)
arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-pompom.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi | 1 + 6 files changed, 6 insertions(+)
arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi +1 -0
@@ -104,6 +104,7 @@ ap_ts: touchscreen@5d { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; reset-gpios = <&tlmm 8 GPIO_ACTIVE_LOW>; vdd-supply = <&pp3300_ts>;
arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi +1 -0
@@ -116,6 +116,7 @@ ap_ts: touchscreen@14 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; reset-gpios = <&tlmm 8 GPIO_ACTIVE_LOW>; vdd-supply = <&pp3300_touch>;
arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi +1 -0
@@ -43,6 +43,7 @@ ap_ts: touchscreen@10 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; post-power-on-delay-ms = <20>; hid-descr-addr = <0x0001>;
arch/arm64/boot/dts/qcom/sc7180-trogdor-pompom.dtsi +1 -0
@@ -102,6 +102,7 @@ ap_ts: touchscreen@10 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; post-power-on-delay-ms = <20>; hid-descr-addr = <0x0001>;
arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi +1 -0
@@ -69,6 +69,7 @@ ap_ts: touchscreen@10 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; post-power-on-delay-ms = <20>; hid-descr-addr = <0x0001>;
arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi +1 -0
@@ -123,6 +123,7 @@ ap_ts: touchscreen@1 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_EDGE_FALLING>; + panel = <&panel>; post-power-on-delay-ms = <70>; hid-descr-addr = <0x0001>;
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Re: [PATCH v4 11/11] arm64: dts: qcom: sc7180: Link trogdor touchscreens to the panels
Hi,
Quoted 20 lines · Douglas Anderson
Let's provide the proper link from the touchscreen to the panel on trogdor devices where the touchscreen support it. This allows the OS to power sequence the touchscreen more properly.
For the most part, this is just expected to marginally improve power consumption while the screen is off. However, in at least one trogdor model (wormdingler) it's suspected that this will fix some behavorial corner cases when the panel power cycles (like for a modeset) without the touchscreen power cycling.
NOTE: some trogdor variants use touchscreens that don't (yet) support linking the touchscreen and the panel. Those variants are left alone.
Reviewed-by Maxime Ripard <[email protected]>Signed-off-by Douglas Anderson <[email protected]>---
(no changes since v1)
Quoted 7 lines
arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-pompom.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi | 1 + 6 files changed, 6 insertions(+)
FWIW, this old patch could land any time. All the earlier patches in the series have landed.
-Doug
Quoted 38 lines · Douglas Anderson
The big motivation for this patch series is mostly described in the patch ("drm/panel: Add a way for other devices to follow panel state"), but to quickly summarize here: for touchscreens that are connected to a panel we need the ability to power sequence the two device together. This is not a new need, but so far we've managed to get by through a combination of inefficiency, added costs, or perhaps just a little bit of brokenness. It's time to do better. This patch series allows us to do better.
Assuming that people think this patch series looks OK, we'll have to figure out the right way to land it. The panel patches and i2c-hid patches will go through very different trees and so either we'll need an Ack from one side or the other or someone to create a tag for the other tree to pull in. This will _probably_ require the true drm-misc maintainers to get involved, not a lowly committer. ;-)
Version 4 of this series adds a new patch that suspends i2c-hid devices at remove time even for non panel-followers to make things consistent. It also attempts to isolate the panel follower code a bit more as per Benjamin's feedback on v3 and adds an item to the DRM todo list as per Maxime's request. As per Maxime's response to my v3 cover letter, I added his Reviewed-by tag to all 10 patches that were part of v3 (but left it off of the new i2c-hid patch in v4).
Version 3 of this series was a long time coming after v2. Maxime and I had a very long discussion trying to figure out if there was a beter way and in the end we didn't find one so he was OK with the series in general [1]. After that got resolved, I tried to resolve Benjamin's feedback but got stuck [2]. Eventually I made my best guess. The end result was a v3 that wasn't that different from v2 but that had a tiny bit more code split out.
Version 2 of this patch series didn't change too much. At a high level:
* I added all the forgotten "static" to functions.
* I've hopefully made the bindings better.
* I've integrated intofw_devlink.
* I cleaned up a few descriptions / comments.
Quoted 3 lines
As far as I can tell, as of v4 everyone is on the same page that this patch series looks like a reasonable solution to the problem and we just need to get all the nits fixed and figure out how to land it.
Thanks a lot for the new version. I like it much more on the HID side:
for the HID part:
I wouldn't mind having this series taken from the drm tree if that is easier. i2c-hid is a low patch rate driver, so having it updated through DRM should not be an issue.
In that case:
Cheers,
Benjamin
Quoted 61 lines
[1] https://lore.kernel.org/r/gkwymmfkdy2p2evz22wmbwgw42ii4wnvmvu64m3bghmj2jhv7x@4mbstjxnagxd
[2] https://lore.kernel.org/r/CAD=FV=VbdeomBGbWhppY+5TOSwt64GWBHga68OXFwsnO4gg4UA@mail.gmail.comChanges in v4:
- Document further cleanup in the official DRM todo list.
- ("Suspend i2c-hid devices in remove") new for v4.
- Move panel follower alternative checks to wrapper functions.
- Rebase atop ("Suspend i2c-hid devices in remove").Changes in v3:
- Addis_panel_follower()as a convenience for clients.
- Add "depends on DRM || !DRM" toKconfigto avoid randconfig error.
- Split more of the panel follower code out of the core.Changes in v2:
- Move the description to the generictouchscreen.yaml.
- Update the desc to make it clearer it's only for integrated devices.
- Add even more text to the commit message.
- A few comment cleanups.
- ("Add a devlink for panel followers") new for v2.
-i2c_hid_core_initial_power_up()is now static.
-i2c_hid_core_panel_prepared()and ..._unpreparing() are now static.
-ihid_core_panel_prepare_work()is now static.
- Improve documentation forsmp_wmb().Douglas Anderson (11):
dt-bindings: HID: i2c-hid: Add "panel" property to i2c-hid backed
touchscreens
drm/panel: Check for already prepared/enabled indrm_paneldrm/panel: Add a way for other devices to follow panel state
of: property:fw_devlink: Add a devlink for panel followers
HID: i2c-hid: Switch toSYSTEM_SLEEP_PM_OPS()
HID: i2c-hid: Rearrangeprobe()to power things up later
HID: i2c-hid: Make suspend and resume into helper functions
HID: i2c-hid: Suspend i2c-hid devices in remove
HID: i2c-hid: Support being a panel follower
HID: i2c-hid: Do panel follower work on thesystem_wq
arm64: dts: qcom: sc7180: Link trogdor touchscreens to the panels.../bindings/input/elan,ekth6915.yaml | 5 + .../bindings/input/goodix,gt7375p.yaml | 5 + .../bindings/input/hid-over-i2c.yaml | 2 + .../input/touchscreen/touchscreen.yaml | 7 + Documentation/gpu/todo.rst | 24 ++ .../boot/dts/qcom/sc7180-trogdor-coachz.dtsi | 1 + .../dts/qcom/sc7180-trogdor-homestar.dtsi | 1 + .../boot/dts/qcom/sc7180-trogdor-lazor.dtsi | 1 + .../boot/dts/qcom/sc7180-trogdor-pompom.dtsi | 1 + .../qcom/sc7180-trogdor-quackingstick.dtsi | 1 + .../dts/qcom/sc7180-trogdor-wormdingler.dtsi | 1 + drivers/gpu/drm/drm_panel.c | 218 ++++++++++- drivers/hid/i2c-hid/Kconfig | 2 + drivers/hid/i2c-hid/i2c-hid-core.c | 349 +++++++++++++----- drivers/of/property.c | 2 + include/drm/drm_panel.h | 94 +++++ 16 files changed, 617 insertions(+), 97 deletions(-)Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Hi,
Quoted 47 lines · Benjamin Tissoires
Quoted 38 lines · Douglas Anderson
The big motivation for this patch series is mostly described in the patch ("drm/panel: Add a way for other devices to follow panel state"), but to quickly summarize here: for touchscreens that are connected to a panel we need the ability to power sequence the two device together. This is not a new need, but so far we've managed to get by through a combination of inefficiency, added costs, or perhaps just a little bit of brokenness. It's time to do better. This patch series allows us to do better.
Assuming that people think this patch series looks OK, we'll have to figure out the right way to land it. The panel patches and i2c-hid patches will go through very different trees and so either we'll need an Ack from one side or the other or someone to create a tag for the other tree to pull in. This will _probably_ require the true drm-misc maintainers to get involved, not a lowly committer. ;-)
Version 4 of this series adds a new patch that suspends i2c-hid devices at remove time even for non panel-followers to make things consistent. It also attempts to isolate the panel follower code a bit more as per Benjamin's feedback on v3 and adds an item to the DRM todo list as per Maxime's request. As per Maxime's response to my v3 cover letter, I added his Reviewed-by tag to all 10 patches that were part of v3 (but left it off of the new i2c-hid patch in v4).
Version 3 of this series was a long time coming after v2. Maxime and I had a very long discussion trying to figure out if there was a beter way and in the end we didn't find one so he was OK with the series in general [1]. After that got resolved, I tried to resolve Benjamin's feedback but got stuck [2]. Eventually I made my best guess. The end result was a v3 that wasn't that different from v2 but that had a tiny bit more code split out.
Version 2 of this patch series didn't change too much. At a high level:
* I added all the forgotten "static" to functions.
* I've hopefully made the bindings better.
* I've integrated intofw_devlink.
* I cleaned up a few descriptions / comments.Quoted 3 lines
As far as I can tell, as of v4 everyone is on the same page that this patch series looks like a reasonable solution to the problem and we just need to get all the nits fixed and figure out how to land it.
Thanks a lot for the new version. I like it much more on the HID side:
for the HID part:
Quoted 8 lines
Reviewed-by Benjamin Tissoires <[email protected]>I wouldn't mind having this series taken from the drm tree if that is easier. i2c-hid is a low patch rate driver, so having it updated through DRM should not be an issue.
In that case:
Thanks for your reviews and your help getting this whipped into shape.
Lading through drm makes sense to me. I'm a drm committer, so with your Ack I believe it should be fine for me to land the series (minus the dts) in drm-misc-next. This series has been around for a while, has been reviewed by relevant folks, and the last few changes haven't fundamentally changed anything about the design, so I'm not going to twiddle my thumbs too long. That being said, I'll still plan to wait until early next week (Tuesday?) before landing to allow for any last minute shouts.
Given how drm-misc works [1] and the fact that mainline is currently at v6.5-rc3 (it will be -rc4 when I land it), I'd expect that these commits will find their way into v6.6.
[1] https://drm.pages.freedesktop.org/maintainer-tools/drm-misc.html
Hi,
Quoted 71 lines · Doug Anderson
Hi,
Quoted 47 lines · Benjamin Tissoires
Quoted 38 lines · Douglas Anderson
The big motivation for this patch series is mostly described in the patch ("drm/panel: Add a way for other devices to follow panel state"), but to quickly summarize here: for touchscreens that are connected to a panel we need the ability to power sequence the two device together. This is not a new need, but so far we've managed to get by through a combination of inefficiency, added costs, or perhaps just a little bit of brokenness. It's time to do better. This patch series allows us to do better.
Assuming that people think this patch series looks OK, we'll have to figure out the right way to land it. The panel patches and i2c-hid patches will go through very different trees and so either we'll need an Ack from one side or the other or someone to create a tag for the other tree to pull in. This will _probably_ require the true drm-misc maintainers to get involved, not a lowly committer. ;-)
Version 4 of this series adds a new patch that suspends i2c-hid devices at remove time even for non panel-followers to make things consistent. It also attempts to isolate the panel follower code a bit more as per Benjamin's feedback on v3 and adds an item to the DRM todo list as per Maxime's request. As per Maxime's response to my v3 cover letter, I added his Reviewed-by tag to all 10 patches that were part of v3 (but left it off of the new i2c-hid patch in v4).
Version 3 of this series was a long time coming after v2. Maxime and I had a very long discussion trying to figure out if there was a beter way and in the end we didn't find one so he was OK with the series in general [1]. After that got resolved, I tried to resolve Benjamin's feedback but got stuck [2]. Eventually I made my best guess. The end result was a v3 that wasn't that different from v2 but that had a tiny bit more code split out.
Version 2 of this patch series didn't change too much. At a high level:
* I added all the forgotten "static" to functions.
* I've hopefully made the bindings better.
* I've integrated intofw_devlink.
* I cleaned up a few descriptions / comments.Quoted 3 lines
As far as I can tell, as of v4 everyone is on the same page that this patch series looks like a reasonable solution to the problem and we just need to get all the nits fixed and figure out how to land it.
Thanks a lot for the new version. I like it much more on the HID side:
for the HID part:
Quoted 8 lines
Reviewed-by Benjamin Tissoires <[email protected]>I wouldn't mind having this series taken from the drm tree if that is easier. i2c-hid is a low patch rate driver, so having it updated through DRM should not be an issue.
In that case:
Thanks for your reviews and your help getting this whipped into shape.
Lading through drm makes sense to me. I'm a drm committer, so with your Ack I believe it should be fine for me to land the series (minus the dts) in drm-misc-next. This series has been around for a while, has been reviewed by relevant folks, and the last few changes haven't fundamentally changed anything about the design, so I'm not going to twiddle my thumbs too long. That being said, I'll still plan to wait until early next week (Tuesday?) before landing to allow for any last minute shouts.
Quoted 5 lines
Given how drm-misc works [1] and the fact that mainline is currently at v6.5-rc3 (it will be -rc4 when I land it), I'd expect that these commits will find their way into v6.6.
[1] https://drm.pages.freedesktop.org/maintainer-tools/drm-misc.html
Pushed the first 10 patches to drm-misc-next. Bjorn: whenever it's convenient you could land patch #11 (the device tree change) into the Qualcomm tree.
76edfcf430cc HID: i2c-hid: Do panel follower work on the system_wq 96a37bfd232a HID: i2c-hid: Support being a panel follower 5f8838e9405d HID: i2c-hid: Suspend i2c-hid devices in remove d93d28477222 HID: i2c-hid: Make suspend and resume into helper functions 675cd877c952 HID: i2c-hid: Rearrange probe() to power things up later a889ee12d53d HID: i2c-hid: Switch to SYSTEM_SLEEP_PM_OPS() fbf0ea2da3c7 of: property: fw_devlink: Add a devlink for panel followers de0874165b83 drm/panel: Add a way for other devices to follow panel state d2aacaf07395 drm/panel: Check for already prepared/enabled in drm_panel 2ca376ef18f6 dt-bindings: HID: i2c-hid: Add "panel" property to i2c-hid backed touchscreens
-Doug
Re: (subset) [PATCH v4 00/11] drm/panel and i2c-hid: Allow panels and touchscreens to power sequence together
In reply to Douglas AndersonQuoted 9 lines · Douglas Anderson
The big motivation for this patch series is mostly described in the patch ("drm/panel: Add a way for other devices to follow panel state"), but to quickly summarize here: for touchscreens that are connected to a panel we need the ability to power sequence the two device together. This is not a new need, but so far we've managed to get by through a combination of inefficiency, added costs, or perhaps just a little bit of brokenness. It's time to do better. This patch series allows us to do better.
[...]
Applied, thanks!
[11/11] arm64: dts: qcom: sc7180: Link trogdor touchscreens to the panels
commit: 989aac9dea7fcfc33b5eedc4ae44abbf71460a4d
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>