History log of /linux-master/drivers/platform/chrome/cros_typec_switch.c
Revision Date Author Comments
# ea4bad2b 27-Sep-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

platform/chrome: cros_typec_switch: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230927081040.2198742-8-u.kleine-koenig@pengutronix.de
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>


# c9f9c6c8 08-May-2023 Prashant Malani <pmalani@chromium.org>

platform/chrome: cros_typec_switch: Add Pin D support

The ChromeOS EC's mux interface allows us to specify whether the port
should be configured for Pin Assignment D in DisplayPort alternate mode
(i.e 2 lanes USB + 2 lanes DP). Update the function that determines mux
state to account for Pin Assignment D and return the appropriate mux
setting.

Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20230508183428.1893357-1-pmalani@chromium.org


# dc70234c 21-Mar-2023 Liang He <windhl@126.com>

platform/chrome: cros_typec_switch: Add missing fwnode_handle_put()

In cros_typec_register_switches(), we should add fwnode_handle_put()
when break out of the iteration device_for_each_child_node()
as it will automatically increase and decrease the refcounter.

Fixes: affc804c44c8 ("platform/chrome: cros_typec_switch: Add switch driver")
Signed-off-by: Liang He <windhl@126.com>
Link: https://lore.kernel.org/r/20230322041657.1857001-1-windhl@126.com
Signed-off-by: Prashant Malani <pmalani@chromium.org>


# 441529be 03-Jan-2023 Prashant Malani <pmalani@chromium.org>

platform/chrome: cros_typec_switch: Check for retimer flag

Not all ports have retimers. Only register a retimer switch if the
"retimer-switch" property is present for that port's mux
device.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20230104060846.112216-2-pmalani@chromium.org


# ef9c00db 03-Jan-2023 Prashant Malani <pmalani@chromium.org>

platform/chrome: cros_typec_switch: Use fwnode* prop check

Using device_property_present() multiple times on an ACPI device
leads to kernel panics on Chromebook systems. This happens when there
is > 1 boolean property in an ACPI device which is created dynamically
by the BIOS as part of SSDT[1] on Chromebook systems

Since fwnode_* can handle simple device tree properties equally
well, switch to using the fwnode_property_present() function
version. This will avoid panics and make the usage consistent
when we introduce a check for the 2nd property in a subsequent patch.

[1] https://wiki.osdev.org/SSDT

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20230104060846.112216-1-pmalani@chromium.org


# 20dfb747 30-Aug-2022 Stephen Boyd <swboyd@chromium.org>

platform/chrome: cros_typec_switch: Inline DRV_NAME

This macro is only used one place, let's inline it instead to save a
line or two.

Cc: Prashant Malani <pmalani@chromium.org>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Prashant Malani <pmalani@chromium.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220830225831.2362403-5-swboyd@chromium.org


# dc22a33e 30-Aug-2022 Stephen Boyd <swboyd@chromium.org>

platform/chrome: cros_typec_switch: Use PTR_ERR_OR_ZERO() to simplify

Use the standard error pointer macro to shorten the code and simplify.

Cc: Prashant Malani <pmalani@chromium.org>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Prashant Malani <pmalani@chromium.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220830225831.2362403-4-swboyd@chromium.org


# bbb5fb85 30-Aug-2022 Stephen Boyd <swboyd@chromium.org>

platform/chrome: cros_typec_switch: Remove impossible condition

The type of 'index' is unsigned long long, which can't possibly be less
than zero. Remove the impossible check.

Cc: Prashant Malani <pmalani@chromium.org>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Prashant Malani <pmalani@chromium.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220830225831.2362403-3-swboyd@chromium.org


# 8dab6a59 30-Aug-2022 Stephen Boyd <swboyd@chromium.org>

platform/chrome: cros_typec_switch: Add missing newline on printk

We need a newline here to ensure the next printk starts fresh.

Cc: Prashant Malani <pmalani@chromium.org>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Fixes: affc804c44c8 ("platform/chrome: cros_typec_switch: Add switch driver")
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Prashant Malani <pmalani@chromium.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220830225831.2362403-2-swboyd@chromium.org


# 9e6e0516 16-Aug-2022 Prashant Malani <pmalani@chromium.org>

platform/chrome: cros_typec_switch: Register mode switches

Register mode switch devices for Type-C connectors, when they are
specified by firmware. These control Type-C configuration for any USB
Type-C mode switches (sometimes known as "muxes") which are controlled
by the ChromeOS EC.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220816214857.2088914-6-pmalani@chromium.org


# cf6c7672 16-Aug-2022 Prashant Malani <pmalani@chromium.org>

platform/chrome: cros_typec_switch: Add event check

The ChromeOS EC updates Type-C status events when mux set requests from
the Application Processor (AP) are completed. Add a check to the
flow of configuring muxes to look for this status done bit, so that
the driver is aware that the mux set completed successfully or not.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220816214857.2088914-5-pmalani@chromium.org


# d4536a21 16-Aug-2022 Prashant Malani <pmalani@chromium.org>

platform/chrome: cros_typec_switch: Set EC retimer

Invoke ChromeOS EC host commands to set EC-controlled retimer switches
to the state the Type-C framework instructs.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220816214857.2088914-4-pmalani@chromium.org


# affc804c 16-Aug-2022 Prashant Malani <pmalani@chromium.org>

platform/chrome: cros_typec_switch: Add switch driver

Introduce a driver to configure USB Type-C mode switches and retimers
which are controlled by the ChromeOS EC (Embedded Controller).
This allows Type-C port drivers, as well as alternate mode drivers to
configure their relevant mode switches and retimers according to the
Type-C state they want to achieve.

ACPI devices with ID GOOG001A will bind to this driver.

Currently, we only register a retimer switch with a stub set function.
Subsequent patches will implement the host command set functionality,
and introduce mode switches.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220816214857.2088914-3-pmalani@chromium.org