platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mark Gross <markgross@kernel.org>, Andy Shevchenko <andy@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>, platform-driver-x86@vger.kernel.org
Subject: [PATCH 2/3] platform/x86: x86-android-tablets: Share lp855x_platform_data between different models
Date: Sat,  1 Apr 2023 17:07:36 +0200	[thread overview]
Message-ID: <20230401150737.597417-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20230401150737.597417-1-hdegoede@redhat.com>

Various Lenovo models use a TI LP8557 LED backlight controller and
the necessary platform_data is the same for the different models.

Currently there are 2 identical copies and the upcoming support for
the Lenovo Yoga Book X90F/L would add a 3th identical copy.

Move to sharing the lp855x_platform_data between different models
to avoid this duplication.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 .../platform/x86/x86-android-tablets/lenovo.c | 37 ++++++++-----------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/platform/x86/x86-android-tablets/lenovo.c b/drivers/platform/x86/x86-android-tablets/lenovo.c
index d9d6dccc53c8..5d217cbbde30 100644
--- a/drivers/platform/x86/x86-android-tablets/lenovo.c
+++ b/drivers/platform/x86/x86-android-tablets/lenovo.c
@@ -24,6 +24,20 @@
 #include "shared-psy-info.h"
 #include "x86-android-tablets.h"
 
+/*
+ * Various Lenovo models use a TI LP8557 LED backlight controller with its PWM
+ * input connected to a PWM output coming from the LCD panel's controller.
+ * The Android kernels have a hack in the i915 driver to write a non-standard
+ * panel specific DSI register to set the duty-cycle of the LCD's PWM output.
+ *
+ * To avoid having to have a similar hack in the mainline kernel program the
+ * LP8557 to directly set the level and use the lp855x_bl driver for control.
+ */
+static struct lp855x_platform_data lenovo_lp8557_pdata = {
+	.device_control = 0x86,
+	.initial_brightness = 128,
+};
+
 /* Lenovo Yoga Book X91F/L Windows tablet needs manual instantiation of the fg client */
 static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __initconst = {
 	{
@@ -72,11 +86,6 @@ static struct x86_gpio_button lenovo_yoga_tab2_830_1050_lid = {
 /* This gets filled by lenovo_yoga_tab2_830_1050_init() */
 static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { };
 
-static struct lp855x_platform_data lenovo_yoga_tab2_830_1050_lp8557_pdata = {
-	.device_control = 0x86,
-	.initial_brightness = 128,
-};
-
 static const struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initconst = {
 	{
 		/* bq24292i battery charger */
@@ -125,7 +134,7 @@ static const struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[]
 			.type = "lp8557",
 			.addr = 0x2c,
 			.dev_name = "lp8557",
-			.platform_data = &lenovo_yoga_tab2_830_1050_lp8557_pdata,
+			.platform_data = &lenovo_lp8557_pdata,
 		},
 		.adapter_path = "\\_SB_.I2C3",
 	},
@@ -343,20 +352,6 @@ static const struct software_node lenovo_yt3_hideep_ts_node = {
 	.properties = lenovo_yt3_hideep_ts_props,
 };
 
-/*
- * The YT3 uses an TI LP8557 LED backlight controller, the LP8557's PWM input is
- * connected to a PWM output coming from the LCD panel's controller. The Android
- * kernel has a hack in the i915 driver to write the non-standard DSI reg 0x51
- * with the desired level to set the duty-cycle of the LCD's PWM output.
- *
- * To avoid having to have a similar hack in the mainline kernel program the
- * LP8557 to directly set the level and use the lp855x_bl driver for control.
- */
-static struct lp855x_platform_data lenovo_yt3_lp8557_pdata = {
-	.device_control = 0x86,
-	.initial_brightness = 128,
-};
-
 static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = {
 	{
 		/* bq27500 fuel-gauge for the flat lipo battery behind the screen */
@@ -414,7 +409,7 @@ static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = {
 			.type = "lp8557",
 			.addr = 0x2c,
 			.dev_name = "lp8557",
-			.platform_data = &lenovo_yt3_lp8557_pdata,
+			.platform_data = &lenovo_lp8557_pdata,
 		},
 		.adapter_path = "\\_SB_.PCI0.I2C1",
 	}
-- 
2.39.1


  reply	other threads:[~2023-04-01 15:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01 15:07 [PATCH 1/3] platform/x86: x86-android-tablets: Use LP8557 in direct mode on both the Yoga 830 and the 1050 Hans de Goede
2023-04-01 15:07 ` Hans de Goede [this message]
2023-04-01 15:07 ` [PATCH 3/3] platform/x86: x86-android-tablets: Add Lenovo Yoga Book X90F/L data Hans de Goede
2023-04-02  6:04   ` Andy Shevchenko
2023-04-06 11:02     ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230401150737.597417-2-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy@kernel.org \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).