Commit Graph

1058105 Commits

Author SHA1 Message Date
Hans de Goede ee0d44f20d Signed tag for the immutable platform-drivers-x86-int3472 branch
This branch contains 5.16-rc1 + the pending ACPI/i2c, tps68570 platform_data
 and INT3472 driver patches.
 -----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCAAyFiEEuvA7XScYQRpenhd+kuxHeUQDJ9wFAmG6YLQUHGhkZWdvZWRl
 QHJlZGhhdC5jb20ACgkQkuxHeUQDJ9zwGwf8Csb4wXyc3duBlnX/9jO9REDVKTN9
 HhmU2KQm29g10dN2nlFXEOG16xAy8zt3BE7QwniL/R5sUsKTCAEugY8Aqq/4+lFA
 vTU+YR9YqZFmEDGMfDngHeh9ZvSWIJS7IEXthxCkgGVhrd2Wl50jKTjVyq1RIDKv
 a7B4fOhguFv95xRlnXK+yoVUU7zZPWAgxyCqV0E0JEi8aWE8Y483IRCzcDEyJeDa
 HkgZLVwD9l3WQ4uZllVg1q5jfSprHwBa8dFxgcd6mOOYaKowiJ+GjnvnXOto5X72
 zsODBJH15VzfVXF5cAqIvzN6nAFR8Mxieei+21iFyUD/Ps1vfWlodFHH2w==
 =Q1N9
 -----END PGP SIGNATURE-----

Merge tag 'platform-drivers-x86-int3472-1' into review-hans

Signed tag for the immutable platform-drivers-x86-int3472 branch

This branch contains 5.16-rc1 + the pending ACPI/i2c, tps68570 platform_data
and INT3472 driver patches.
2021-12-15 23:00:15 +01:00
Hans de Goede 97c2259ec7 platform/x86: int3472: Deal with probe ordering issues
The clk and regulator frameworks expect clk/regulator consumer-devices
to have info about the consumed clks/regulators described in the device's
fw_node.

To work around this info missing from the ACPI tables on devices where
the int3472 driver is used, the int3472 MFD-cell drivers attach info about
consumers to the clks/regulators when registering these.

This causes problems with the probe ordering wrt drivers for consumers
of these clks/regulators. Since the lookups are only registered when the
provider-driver binds, trying to get these clks/regulators before then
results in a -ENOENT error for clks and a dummy regulator for regulators.

All the sensor ACPI fw-nodes have a _DEP dependency on the INT3472 ACPI
fw-node, so to work around these probe ordering issues the ACPI core /
i2c-code does not instantiate the I2C-clients for any ACPI devices
which have a _DEP dependency on an INT3472 ACPI device until all
_DEP-s are met.

This relies on acpi_dev_clear_dependencies() getting called by the driver
for the _DEP-s when they are ready, add a acpi_dev_clear_dependencies()
call to the discrete.c probe code.

In the tps68470 case calling acpi_dev_clear_dependencies() is already done
by the acpi_gpiochip_add() call done by the driver for the GPIO MFD cell
(The GPIO cell is deliberately the last cell created to make sure the
clk + regulator cells are already instantiated when this happens).

However for proper probe ordering, the clk/regulator cells must not just
be instantiated the must be fully ready (the clks + regulators must be
registered with their subsystems).

Add MODULE_SOFTDEP dependencies for the clk and regulator drivers for
the instantiated MFD-cells so that these are loaded before us and so
that they bind immediately when the platform-devs are instantiated.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-12-hdegoede@redhat.com
2021-12-13 11:44:51 +01:00
Hans de Goede 19d8d6e36b platform/x86: int3472: Pass tps68470_regulator_platform_data to the tps68470-regulator MFD-cell
Pass tps68470_regulator_platform_data to the tps68470-regulator
MFD-cell, specifying the voltages of the various regulators and
tying the regulators to the sensor supplies so that sensors which use
the TPS68470 can find their regulators.

Since the voltages and supply connections are board-specific, this
introduces a DMI matches int3472_tps68470_board_data struct which
contains the necessary per-board info.

This per-board info also includes GPIO lookup information for the
sensor IO lines which may be connected to the tps68470 GPIOs.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-11-hdegoede@redhat.com
2021-12-13 11:44:50 +01:00
Hans de Goede d3d76ae139 platform/x86: int3472: Pass tps68470_clk_platform_data to the tps68470-regulator MFD-cell
Pass tps68470_clk_platform_data to the tps68470-clk MFD-cell,
so that sensors which use the TPS68470 can find their clock.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-10-hdegoede@redhat.com
2021-12-13 11:44:48 +01:00
Hans de Goede 71102bc796 platform/x86: int3472: Add get_sensor_adev_and_name() helper
The discrete.c code is not the only code which needs to lookup the
acpi_device and device-name for the sensor for which the INT3472
ACPI-device is a GPIO/clk/regulator provider.

The tps68470.c code also needs this functionality, so factor this
out into a new get_sensor_adev_and_name() helper.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-9-hdegoede@redhat.com
2021-12-13 11:44:48 +01:00
Hans de Goede a2f9fbc247 platform/x86: int3472: Split into 2 drivers
The intel_skl_int3472.ko module contains 2 separate drivers,
the int3472_discrete platform driver and the int3472_tps68470
I2C-driver.

These 2 drivers contain very little shared code, only
skl_int3472_get_acpi_buffer() and skl_int3472_fill_cldb() are
shared.

Split the module into 2 drivers, linking the little shared code
directly into both.

This will allow us to add soft-module dependencies for the
tps68470 clk, gpio and regulator drivers to the new
intel_skl_int3472_tps68470.ko to help with probe ordering issues
without causing these modules to get loaded on boards which only
use the int3472_discrete platform driver.

While at it also rename the .c and .h files to remove the
cumbersome intel_skl_int3472_ prefix.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-8-hdegoede@redhat.com
2021-12-13 11:44:48 +01:00
Hans de Goede 9dfa374cc6 platform_data: Add linux/platform_data/tps68470.h file
The clk and regulator frameworks expect clk/regulator consumer-devices
to have info about the consumed clks/regulators described in the device's
fw_node.

To work around cases where this info is not present in the firmware tables,
which is often the case on x86/ACPI devices, both frameworks allow the
provider-driver to attach info about consumers to the provider-device
during probe/registration of the provider device.

The TI TPS68470 PMIC is used x86/ACPI devices with the consumer-info
missing from the ACPI tables. Thus the tps68470-clk and tps68470-regulator
drivers must provide the consumer-info at probe time.

Define tps68470_clk_platform_data and tps68470_regulator_platform_data
structs to allow the x86 platform code to pass the necessary consumer info
to these drivers.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-5-hdegoede@redhat.com
2021-12-13 11:44:48 +01:00
Hans de Goede c537be0bfa i2c: acpi: Add i2c_acpi_new_device_by_fwnode() function
Change i2c_acpi_new_device() into i2c_acpi_new_device_by_fwnode() and
add a static inline wrapper providing the old i2c_acpi_new_device()
behavior.

This is necessary because in some cases we may only have access
to the fwnode / acpi_device and not to the matching physical-node
struct device *.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-4-hdegoede@redhat.com
2021-12-13 11:44:47 +01:00
Hans de Goede fb90e58f7c i2c: acpi: Use acpi_dev_ready_for_enumeration() helper
The clk and regulator frameworks expect clk/regulator consumer-devices
to have info about the consumed clks/regulators described in the device's
fw_node.

To work around cases where this info is not present in the firmware tables,
which is often the case on x86/ACPI devices, both frameworks allow the
provider-driver to attach info about consumers to the clks/regulators
when registering these.

This causes problems with the probe ordering wrt drivers for consumers
of these clks/regulators. Since the lookups are only registered when the
provider-driver binds, trying to get these clks/regulators before then
results in a -ENOENT error for clks and a dummy regulator for regulators.

To ensure the correct probe-ordering the ACPI core has code to defer the
enumeration of consumers affected by this until the providers are ready.

Call the new acpi_dev_ready_for_enumeration() helper to avoid
enumerating / instantiating i2c-clients too early.

Acked-by: Wolfram Sang <wsa@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-3-hdegoede@redhat.com
2021-12-13 11:44:47 +01:00
Hans de Goede 9d9bcae47f ACPI: delay enumeration of devices with a _DEP pointing to an INT3472 device
The clk and regulator frameworks expect clk/regulator consumer-devices
to have info about the consumed clks/regulators described in the device's
fw_node.

To work around cases where this info is not present in the firmware tables,
which is often the case on x86/ACPI devices, both frameworks allow the
provider-driver to attach info about consumers to the clks/regulators
when registering these.

This causes problems with the probe ordering wrt drivers for consumers
of these clks/regulators. Since the lookups are only registered when the
provider-driver binds, trying to get these clks/regulators before then
results in a -ENOENT error for clks and a dummy regulator for regulators.

One case where we hit this issue is camera sensors such as e.g. the OV8865
sensor found on the Microsoft Surface Go. The sensor uses clks, regulators
and GPIOs provided by a TPS68470 PMIC which is described in an INT3472
ACPI device. There is special platform code handling this and setting
platform_data with the necessary consumer info on the MFD cells
instantiated for the PMIC under: drivers/platform/x86/intel/int3472.

For this to work properly the ov8865 driver must not bind to the I2C-client
for the OV8865 sensor until after the TPS68470 PMIC gpio, regulator and
clk MFD cells have all been fully setup.

The OV8865 on the Microsoft Surface Go is just one example, all X86
devices using the Intel IPU3 camera block found on recent Intel SoCs
have similar issues where there is an INT3472 HID ACPI-device, which
describes the clks and regulators, and the driver for this INT3472 device
must be fully initialized before the sensor driver (any sensor driver)
binds for things to work properly.

On these devices the ACPI nodes describing the sensors all have a _DEP
dependency on the matching INT3472 ACPI device (there is one per sensor).

This allows solving the probe-ordering problem by delaying the enumeration
(instantiation of the I2C-client in the ov8865 example) of ACPI-devices
which have a _DEP dependency on an INT3472 device.

The new acpi_dev_ready_for_enumeration() helper used for this is also
exported because for devices, which have the enumeration_by_parent flag
set, the parent-driver will do its own scan of child ACPI devices and
it will try to enumerate those during its probe(). Code doing this such
as e.g. the i2c-core-acpi.c code must call this new helper to ensure
that it too delays the enumeration until all the _DEP dependencies are
met on devices which have the new honor_deps flag set.

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-2-hdegoede@redhat.com
2021-12-13 11:44:47 +01:00
Andy Shevchenko 692562abcc platform/x86: hp_accel: Use SIMPLE_DEV_PM_OPS() for PM ops
After the commit 34570a898e ("platform/x86: hp_accel: Remove
_INI method call") there is no need to have separate methods for
resume and restore, hence we may fold them together and use
SIMPLE_DEV_PM_OPS() for PM ops.

While at it, switch to use __maybe_unused attribute.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20211206151521.22578-1-andriy.shevchenko@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-12-07 12:21:01 +01:00
Jarrett Schultz 2724799281 platform: surface: Propagate ACPI Dependency
Since the Surface XBL Driver does not depend on ACPI, the
platform/surface directory as a whole no longer depends on ACPI. With
respect to this, the ACPI dependency is moved into each config that depends
on ACPI individually.

Signed-off-by: Jarrett Schultz <jaschultz@microsoft.com>
Link: https://lore.kernel.org/r/20211202191630.12450-3-jaschultz@microsoft.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-12-07 12:21:01 +01:00
Hans de Goede 1c5ec99891 platform/x86: lenovo-yogabook-wmi: Add support for hall sensor on the back
On the back of the device there is a Hall sensor connected to the
"INT33FF:02" GPIO controller pin 18, which gets triggered when the
device is fully folded into tablet-mode (when the back of the display
touches the back of the keyboard).

Use this to disable both the touch-keyboard and the digitizer when
the tablet is fully folded into tablet-mode.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211128190031.405620-5-hdegoede@redhat.com
2021-12-07 12:21:01 +01:00
Yauhen Kharuzhy c0549b72d9 platform/x86: lenovo-yogabook-wmi: Add driver for Lenovo Yoga Book
Add driver to handle WMI events, control the keyboard backlight and
bind/unbind the keyboard-touch / digitizer driver so that only one
is active at a time.

It may seem a bit weird to handle the toggling of the modes in the
kernel, but the hw actually expects only 1 device to be active
at a time.

Changes by Hans de Goede:
- Whole bunch of cleanups
- Make the kernel do the driver bind/unbind itself instead of
  sending events to userspace and requiring a special userspace
  daemon to deal with this

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Co-developed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211128190031.405620-4-hdegoede@redhat.com
2021-12-07 12:21:00 +01:00
Hans de Goede 8c33915d77 platform/x86: wmi: Add no_notify_data flag to struct wmi_driver
Some WMI implementations do notifies on WMI objects without a _WED method
allow WMI drivers to indicate that _WED should not be called for notifies
on the WMI objects the driver is bound to.

Instead the driver's notify callback will simply be called with a NULL
data argument.

Reported-by: Yauhen Kharuzhy <jekhor@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211128190031.405620-3-hdegoede@redhat.com
2021-12-06 22:33:39 +01:00
Hans de Goede 9918878676 platform/x86: wmi: Fix driver->notify() vs ->probe() race
The driver core sets struct device->driver before calling out
to the bus' probe() method, this leaves a window where an ACPI
notify may happen on the WMI object before the driver's
probe() method has completed running, causing e.g. the
driver's notify() callback to get called with drvdata
not yet being set leading to a NULL pointer deref.

At a check for this to the WMI core, ensuring that the notify()
callback is not called before the driver is ready.

Fixes: 1686f54445 ("platform/x86: wmi: Incorporate acpi_install_notify_handler")
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211128190031.405620-2-hdegoede@redhat.com
2021-12-06 22:33:35 +01:00
Hans de Goede a90b38c586 platform/x86: wmi: Replace read_takes_no_args with a flags field
Replace the wmi_block.read_takes_no_args bool field with
an unsigned long flags field, used together with test_bit()
and friends.

This is a preparation patch for fixing a driver->notify() vs ->probe()
race, which requires atomic flag handling.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211128190031.405620-1-hdegoede@redhat.com
2021-12-06 22:33:22 +01:00
Alex Hung 01e16cb67c platform/x86/intel: hid: add quirk to support Surface Go 3
Similar to other systems Surface Go 3 requires a DMI quirk to enable
5 button array for power and volume buttons.

Buglink: https://github.com/linux-surface/linux-surface/issues/595

Cc: stable@vger.kernel.org
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Link: https://lore.kernel.org/r/20211203212810.2666508-1-alex.hung@canonical.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-12-06 22:27:30 +01:00
Fabrizio Bertocci a602f5111f platform/x86: amd-pmc: Fix s2idle failures on certain AMD laptops
On some AMD hardware laptops, the system fails communicating with the
PMC when entering s2idle and the machine is battery powered.

Hardware description: HP Pavilion Aero Laptop 13-be0097nr
CPU: AMD Ryzen 7 5800U with Radeon Graphics
GPU: 03:00.0 VGA compatible controller [0300]: Advanced Micro Devices,
Inc. [AMD/ATI] Device [1002:1638] (rev c1)

Detailed description of the problem (and investigation) here:
https://gitlab.freedesktop.org/drm/amd/-/issues/1799

Patch is a single line: reduce the polling delay in half, from 100uSec
to 50uSec when waiting for a change in state from the PMC after a
write command operation.

After changing the delay, I did not see a single failure on this
machine (I have this fix for now more than one week and s2idle worked
every single time on battery power).

Cc: stable@vger.kernel.org
Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Signed-off-by: Fabrizio Bertocci <fabriziobertocci@gmail.com>
Link: https://lore.kernel.org/r/CADtzkx7TdfbwtaVEXUdD6YXPey52E-nZVQNs+Z41DTx7gqMqtw@mail.gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-12-02 12:58:26 +01:00
Hans de Goede a274cd66bc platform/x86: touchscreen_dmi: Add TrekStor SurfTab duo W1 touchscreen info
The TrekStor SurfTab duo W1 (ST10432-10b) has a Goodix touchscreen which
has its x-axis mirrored.

Add a quirk to fix this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211124175125.250329-1-hdegoede@redhat.com
2021-12-02 12:58:26 +01:00
Matan Ziv-Av 60a076ea8a platform/x86: lg-laptop: Recognize more models
LG uses 5 instead of 0 in the third digit (second digit after 2019)
of the year string to indicate newer models in the same year.
Handle this case as well.

Signed-off-by: Matan Ziv-Av <matan@svgalib.org>
Link: https://lore.kernel.org/r/c752b3b2-9718-bd9a-732d-e165aa8a1fca@svgalib.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-12-02 12:58:26 +01:00
Yang Li 37f34df84a platform/x86: asus-wmi: remove unneeded semicolon
Eliminate the following coccicheck warning:
./drivers/platform/x86/asus-wmi.c:2386:2-3: Unneeded semicolon

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Link: https://lore.kernel.org/r/1637719332-45224-1-git-send-email-yang.lee@linux.alibaba.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-12-02 12:58:25 +01:00
Hans de Goede e1dbdd2f4a platform/x86: thinkpad_acpi: Add lid_logo_dot to the list of safe LEDs
There have been various bugs / forum threads about allowing control of
the LED in the ThinkPad logo on the lid of various models.

This seems to be something which users want to control and there really
is no reason to require setting CONFIG_THINKPAD_ACPI_UNSAFE_LEDS for this.

The lid-logo-dot is LED number 10, so change the name of the 10th led
from unknown_led2 to lid_logo_dot and add it to the TPACPI_SAFE_LEDS mask.

Link: https://www.reddit.com/r/thinkpad/comments/7n8eyu/thinkpad_led_control_under_gnulinux/
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1943318
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211123210524.266705-2-hdegoede@redhat.com
2021-12-02 12:58:25 +01:00
Hans de Goede e518704d63 platform/x86: thinkpad_acpi: Add LED_RETAIN_AT_SHUTDOWN to led_class_devs
Add the LED_RETAIN_AT_SHUTDOWN flag to the registered led_class_devs so
that the LEDs do not get turned-off when reloading the driver and thus so
that they also stay under default EC control when reloading the driver,
unless explicitly overridden by the user.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211123210524.266705-1-hdegoede@redhat.com
2021-12-02 12:58:25 +01:00
Hans de Goede f3dc3009c2 platform/x86: thinkpad_acpi: Remove unused sensors_pdev_attrs_registered flag
After the recent sysfs-attributes registration cleanups, the
tp_features.sensors_pdev_attrs_registered flag only ever gets set and
never gets read, remove it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211123210424.266607-6-hdegoede@redhat.com
2021-11-25 16:22:50 +01:00
Hans de Goede 526ac103db platform/x86: thinkpad_acpi: Fix the hwmon sysfs-attr showing up in the wrong place
The hwmon sysfs-attr should show up under the hwmon-classdev, not under
the tpacpi_sensors_pdev. Pass the tpacpi_hwmon_groups attr-groups array
to hwmon_device_register_with_groups() instead of setting
tpacpi_hwmon_pdriver.driver.dev_groups to it to fix this.

This also requires moving the hwmon_device_register_with_groups() call to
after the subdriver init functions have run so that the is_visible()
calls will work properly.

Fixes: 79f960e29c ("platform/x86: thinkpad_acpi: Convert platform driver to use dev_groups")
Cc: Len Baker <len.baker@gmx.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211123210424.266607-5-hdegoede@redhat.com
2021-11-25 16:22:50 +01:00
Hans de Goede 5cd689683e platform/x86: thinkpad_acpi: tpacpi_attr_group contains driver attributes not device attrs
Commit 79f960e29c ("platform/x86: thinkpad_acpi: Convert platform driver
to use dev_groups") put the debug_level, interface_version, version and the
THINKPAD_ACPI_DEBUGFACILITIES attributes in a new tpacpi_attr_group and
added those to the tpacpi_groups groups-array which is used to initialize
the driver.dev_groups member.

But before this commit these attributes were registered with
driver_create_file(), so they should be part of the groups-array which is
used to initialize the driver.groups member instead.

And also make the same change for the fan_watchdog hwmon driver attribute.

Fixes: 79f960e29c ("platform/x86: thinkpad_acpi: Convert platform driver to use dev_groups")
Cc: Len Baker <len.baker@gmx.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211123210424.266607-4-hdegoede@redhat.com
2021-11-25 16:22:50 +01:00
Hans de Goede 2f5ad08f3e platform/x86: thinkpad_acpi: Register tpacpi_pdriver after subdriver init
Commit 79f960e29c ("platform/x86: thinkpad_acpi: Convert platform driver
to use dev_groups") introduces the use of driver.dev_groups +
attribute_group.is_visible callbacks replacing the conditional calling of
driver_create_file() for optional attributes.

The is_visible callbacks rely on various tp_features.has_foo flags,
which get set by the subdriver init functions.

But before this fix, thinkpad_acpi_module_init() would call the
subdriver init functions after registering the platform_device and
the tpacpi_pdriver. Which would cause the is_visible callbacks to
get called before the subdriver init functions, which in turn would
cause optional attributes to not get registered at all, even when
the feature is actually present.

Fix this by moving the platform_driver_register(&tpacpi_pdriver) to after
the subdriver init calls; and do the same for the tpacpi_hmon_pdriver.

Fixes: 79f960e29c ("platform/x86: thinkpad_acpi: Convert platform driver to use dev_groups")
Cc: Len Baker <len.baker@gmx.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211123210424.266607-3-hdegoede@redhat.com
2021-11-25 16:21:25 +01:00
Hans de Goede 9105240043 platform/x86: thinkpad_acpi: Restore missing hotkey_tablet_mode and hotkey_radio_sw sysfs-attr
Commit c99ca78d67 ("platform/x86: thinkpad_acpi: Switch to common use
of attributes") removed the conditional adding of the
hotkey_tablet_mode and hotkey_radio_sw sysfs-attributes, replacing this
with a hotkey_attr_is_visible() callback which hides them when the
feature is not present.

But this commit forgot to add these 2 attributes to the default
hotkey_attributes[] set, so they would now never get added at all.

Add the 2 attributes to the default hotkey_attributes[] set so that
they are available on systems with these features once more.

Fixes: c99ca78d67 ("platform/x86: thinkpad_acpi: Switch to common use of attributes")
Cc: Len Baker <len.baker@gmx.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211123210424.266607-2-hdegoede@redhat.com
2021-11-25 16:20:47 +01:00
Hans de Goede 3a0abea60c platform/x86: thinkpad_acpi: Fix thermal_temp_input_attr sorting
Fix thermal_temp_input_attr sorting. Now that we use is_visible,
rather then registering only part of the thermal_temp_input_attr array,
putting attr 0-7 last is no longer needed.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Mark Pearson <mpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211121191129.256713-8-hdegoede@redhat.com
2021-11-25 16:19:07 +01:00
Hans de Goede cb97f5f01d platform/x86: thinkpad_acpi: Remove "goto err_exit" from hotkey_init()
The err_exit label just does a:
 return (res < 0) ? res : -ENODEV;

And res is always < 0 when we go there (hotkey_mask_get() returns
either 0 or -EIO), so the goto-s can simply be replaced with
"return res".

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Mark Pearson <mpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211121191129.256713-7-hdegoede@redhat.com
2021-11-25 16:19:02 +01:00
Hans de Goede 798682e236 platform/x86: thinkpad_acpi: Properly indent code in tpacpi_dytc_profile_init()
The previous refactoring of some code in tpacpi_dytc_profile_init() left
a weirdly indented code-block behind.

Remove the unnecessary '{}' and reduce the indent level one step,
other then changing the indentation the code is completely unchanged.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Mark Pearson <mpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211121191129.256713-6-hdegoede@redhat.com
2021-11-25 16:18:55 +01:00
Hans de Goede 0b0d2fba4f platform/x86: thinkpad_acpi: Cleanup dytc_profile_available
Remove the dytc_profile_available check from dytc_profile_set(),
that function only gets called if the platform_profile_handler was
registered, so the check is not necessary.

Make tpacpi_dytc_profile_init() return -ENODEV when it does not register
the platform_profile() handler this will cause
dytc_profile_driver_data.flags.init to not get set, which in turn will
cause the dytc_profile_exit() call to get skipped.

Together this avoids the need to have the dytc_profile_available
variable at all, since the information is now duplicated in the
dytc_profile_driver_data.flags.init flag.

Note this leaves a weirdly indented code-block behind, this is
deliberately done to make what actually changes in this commit clear.
This will be fixed-up in the next commit.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Mark Pearson <mpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211121191129.256713-5-hdegoede@redhat.com
2021-11-25 16:18:48 +01:00
Hans de Goede 5a47ac0041 platform/x86: thinkpad_acpi: Simplify dytc_version handling
The only reason the proxysensor code needs dytc_version handling is for
proxsensor_attr_is_visible() and that will only ever get called after
all the subdrv init() callbacks have run.

tpacpi_dytc_profile_init() already calls DYTC_CMD_QUERY and is the
primary consumer of dytc_version, so simply let tpacpi_dytc_profile_init()
set dytc_version and remove the now no longer necessary dytc_get_version()
helper and its calls.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Mark Pearson <mpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211121191129.256713-4-hdegoede@redhat.com
2021-11-25 16:18:43 +01:00
Hans de Goede c7e1c782f2 platform/x86: thinkpad_acpi: Make *_init() functions return -ENODEV instead of 1
Make ibm_init_struct.init() callbacks return -ENODEV instead of 1 when
the subdevice / function is not available.

Using -ENODEV clearly states what it going on where as a magic return of
"1" requires a deep dive into the code to figure out what is going on.

This also allows for some cleanups, avoiding the need to translate an
-ENODEV return into "return 1" (which often mistakenly was "return 0").

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Mark Pearson <mpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211121191129.256713-3-hdegoede@redhat.com
2021-11-25 16:18:21 +01:00
Hans de Goede c15f86856b platform/x86: thinkpad_acpi: Accept ibm_init_struct.init() returning -ENODEV
Commit 79f960e29c ("platform/x86: thinkpad_acpi: Convert platform driver
to use dev_groups") accidentally modified tpacpi_kbdlang_init() causing it
to return -ENODEV instead of 0 on machines without kbdlang support
(which are most of them).

ibm_init() sees this -ENODEV as an error causing the entire module to not
load, not good.

Note that technically tpacpi_kbdlang_init() was already buggy before, it
should have returned 1 instead of 0 if the feature is not present.

Rather then fixing tpacpi_kbdlang_init() though, IMHO it is bettter to
just make ibm_init() treat -ENODEV as 1 to fix the issue; and then in
a followup commit also change all the existing "return 1"s from
ibm_init_struct.init() callbacks to "return -ENODEV" as -ENODEV clearly
states what it going on where as a magic return of "1" requires a deep
dive into the code to figure out what is going on.

This will also allow removing some extra ifs to translate -ENODEV to
return 1 in a couple of init() callbacks.

Fixes: 79f960e29c ("platform/x86: thinkpad_acpi: Convert platform driver to use dev_groups")
Cc: Len Baker <len.baker@gmx.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211121191129.256713-2-hdegoede@redhat.com
2021-11-22 13:53:17 +01:00
Hans de Goede ff448bbaac platform/x86: think-lmi: Simplify tlmi_analyze() error handling a bit
Creating the tlmi_pwd_setting structs can only fail with -ENOMEM, set
ret to this once and simplify the error handling a bit.

Tested-by: Mark Pearson <markpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211118114150.271274-2-hdegoede@redhat.com
2021-11-22 13:51:31 +01:00
Hans de Goede 01df1385ec platform/x86: think-lmi: Move kobject_init() call into tlmi_create_auth()
All callers of tlmi_create_auth() also call
kobject_init(&pwd_setting->kobj, &tlmi_pwd_setting_ktype) on the returned
tlmi_pwd_setting struct. Move this into tlmi_create_auth().

Tested-by: Mark Pearson <markpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211118114150.271274-1-hdegoede@redhat.com
2021-11-22 13:51:15 +01:00
Mark Pearson 640a5fa50a platform/x86: think-lmi: Opcode support
Implement Opcode support.
This is available on ThinkCenter and ThinkStations platforms and
gives improved password setting capabilities

Add options to configure System, HDD & NVMe passwords.
HDD & NVMe passwords need a user level (user/master) along with
drive index.

Signed-off-by: Mark Pearson <markpearson@lenovo.com>
Link: https://lore.kernel.org/r/20211117184453.2476-2-markpearson@lenovo.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-18 12:29:30 +01:00
Mark Pearson adca4b6871 Documentation: syfs-class-firmware-attributes: Lenovo Opcode support
Newer Lenovo BIOS's have an opcode GUID support interface which provides
 - improved password setting control
 - ability to set System, hard drive and NVMe passwords

Add the support for these new passwords, and the ability to select
user/master mode and the drive index.

Signed-off-by: Mark Pearson <markpearson@lenovo.com>
Link: https://lore.kernel.org/r/20211117184453.2476-1-markpearson@lenovo.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-18 10:55:22 +01:00
Maximilian Luz b3c3d5881e platform/surface: aggregator_registry: Rename device registration function
Rename the device registration function to better align names with the
newly introduced device removal function.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20211028002243.1586083-4-luzmaximilian@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:54 +01:00
Maximilian Luz acff7091df platform/surface: aggregator_registry: Use generic client removal function
Use generic client removal function introduced in the previous commit
instead of defining our own one.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20211028002243.1586083-3-luzmaximilian@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:54 +01:00
Maximilian Luz 38543b72fb platform/surface: aggregator: Make client device removal more generic
Currently, there are similar functions defined in the Aggregator
Registry and the controller core.

Make client device removal more generic and export it. We can then use
this function later on to remove client devices from device hubs as well
as the controller and avoid re-defining similar things.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20211028002243.1586083-2-luzmaximilian@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:54 +01:00
Luke D. Jones 0f0ac158d2 platform/x86: asus-wmi: Add support for custom fan curves
Add support for custom fan curves found on some ASUS ROG laptops.

These laptops have the ability to set a custom curve for the CPU
and GPU fans via two ACPI methods.

This patch adds two pwm<N> attributes to the hwmon sysfs,
pwm1 for CPU fan, pwm2 for GPU fan. Both are under the hwmon of the
name `asus_custom_fan_curve`. There is no safety check of the set
fan curves - this must be done in userspace.

The fans have settings [1,2,3] under pwm<N>_enable:
1. Enable and write settings out
2. Disable and use factory fan mode
3. Same as 2, additionally restoring default factory curve.

Use of 2 means that the curve the user has set is still stored and
won't be erased, but the laptop will be using its default auto-fan
mode. Re-enabling the manual mode then activates the curves again.

Notes:
- pwm<N>_enable = 0 is an invalid setting.
- pwm is actually a percentage and is scaled on writing to device.

Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20211024033705.5595-2-luke@ljones.dev
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:53 +01:00
Len Baker 79f960e29c platform/x86: thinkpad_acpi: Convert platform driver to use dev_groups
Platform drivers have the option of having the platform core create and
remove any needed sysfs attribute files. So take advantage of that and
refactor the attributes management to avoid to register them "by hand".

Also, due to some attributes are optionals, refactor the code and move
the logic inside the "is_visible" callbacks of the attribute_group
structures.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20211023154036.6800-1-len.baker@gmx.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:53 +01:00
Vincent Bernat d477a907cb platform/x86: thinkpad_acpi: fix documentation for adaptive keyboard
The different values were offset by 1. 0 is for "home mode", 1 for
"web-browser mode", etc. Moreover, the URL to the laptop's user guide
did not work anymore.

Signed-off-by: Vincent Bernat <vincent@bernat.ch>
Link: https://lore.kernel.org/r/20211109195209.176905-1-vincent@bernat.ch
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:53 +01:00
Slark Xiao 39f5329218 platform/x86: thinkpad_acpi: Fix WWAN device disabled issue after S3 deep
When WWAN device wake from S3 deep, under thinkpad platform,
WWAN would be disabled. This disable status could be checked
by command 'nmcli r wwan' or 'rfkill list'.

Issue analysis as below:
  When host resume from S3 deep, thinkpad_acpi driver would
call hotkey_resume() function. Finnaly, it will use
wan_get_status to check the current status of WWAN device.
During this resume progress, wan_get_status would always
return off even WWAN boot up completely.
  In patch V2, Hans said 'sw_state should be unchanged
after a suspend/resume. It's better to drop the
tpacpi_rfk_update_swstate call all together from the
resume path'.
  And it's confimed by Lenovo that GWAN is no longer
 available from WHL generation because the design does not
 match with current pin control.

Signed-off-by: Slark Xiao <slark_xiao@163.com>
Link: https://lore.kernel.org/r/20211108060648.8212-1-slark_xiao@163.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:53 +01:00
Jimmy Wang 1f338954a5 platform/x86: thinkpad_acpi: Add support for dual fan control
This adds dual fan control for P1 / X1 Extreme Gen4

Signed-off-by: Jimmy Wang <jimmy221b@163.com>
Link: https://lore.kernel.org/r/20211105090528.39677-1-jimmy221b@163.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:53 +01:00
Alex Williamson 812fcc6095 platform/x86: think-lmi: Abort probe on analyze failure
A Lenovo ThinkStation S20 (4157CTO BIOS 60KT41AUS) fails to boot on
recent kernels including the think-lmi driver, due to the fact that
errors returned by the tlmi_analyze() function are ignored by
tlmi_probe(), where  tlmi_sysfs_init() is called unconditionally.
This results in making use of an array of already freed, non-null
pointers and other uninitialized globals, causing all sorts of nasty
kobject and memory faults.

Make use of the analyze function return value, free a couple leaked
allocations, and remove the settings_count field, which is incremented
but never consumed.

Fixes: a40cd7ef22 ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Mark Gross <markgross@kernel.org>
Reviewed-by: Mark Pearson <markpearson@lenovo.com>
Link: https://lore.kernel.org/r/163639463588.1330483.15850167112490200219.stgit@omen
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:53 +01:00
Thomas Weißschuh 0f07c023dc platform/x86: dell-wmi-descriptor: disable by default
dell-wmi-descriptor only provides symbols to other drivers.
These drivers already select dell-wmi-descriptor when needed.

This fixes an issue where dell-wmi-descriptor is compiled as a module
with localyesconfig on a non-Dell machine.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20211113080551.61860-1-linux@weissschuh.net
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-11-16 10:56:53 +01:00