diff mbox

[v3,1/3] acpi: lpss: call pwm_add_table() for bsw pwm device

Message ID 20170122152415.10374-1-hdegoede@redhat.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Hans de Goede Jan. 22, 2017, 3:24 p.m. UTC
On x86 we do not have devicetree to link the pwm controller and
the display controller together. So someone needs to call
pwm_add_table() to create the link, so that the i915 driver's
pwm_get(dev, "pwm_backlight") call returns the lpss' pwm0.

The pwm subsystem does not want to have pwm_add_table() calls
directly in pwm drivers (this leads to probe ordering issues),
so lets do it here since the acpi-lpss code is always builtin.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/acpi_lpss.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Hans de Goede Jan. 22, 2017, 3:25 p.m. UTC | #1
Hi,

Ugh I somehow ended up typing "git send-email HEAD~3"
instead of "git send-email HEAD~" don't know where my
mind wandered of to. Sorry, please ignore I'll resend
just patch 3/3 which is the one I intended to send.

Regards,

Hans


On 22-01-17 16:24, Hans de Goede wrote:
> On x86 we do not have devicetree to link the pwm controller and
> the display controller together. So someone needs to call
> pwm_add_table() to create the link, so that the i915 driver's
> pwm_get(dev, "pwm_backlight") call returns the lpss' pwm0.
>
> The pwm subsystem does not want to have pwm_add_table() calls
> directly in pwm drivers (this leads to probe ordering issues),
> so lets do it here since the acpi-lpss code is always builtin.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/acpi/acpi_lpss.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index 8ea836c..1b4bcf6 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -20,6 +20,7 @@
>  #include <linux/platform_data/clk-lpss.h>
>  #include <linux/pm_domain.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/pwm.h>
>  #include <linux/delay.h>
>
>  #include "internal.h"
> @@ -154,6 +155,17 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
>  	writel(0, pdata->mmio_base + LPSS_I2C_ENABLE);
>  }
>
> +/* BSW PWM used for backlight control by the i915 driver */
> +static struct pwm_lookup bsw_pwm_lookup[] = {
> +	PWM_LOOKUP("80862288:00", 0, "0000:00:02.0", "pwm_backlight", 0,
> +		   PWM_POLARITY_NORMAL),
> +};
> +
> +static void bsw_pwm_setup(struct lpss_private_data *pdata)
> +{
> +	pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup));
> +}
> +
>  static const struct lpss_device_desc lpt_dev_desc = {
>  	.flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
>  	.prv_offset = 0x800,
> @@ -191,6 +203,7 @@ static const struct lpss_device_desc byt_pwm_dev_desc = {
>
>  static const struct lpss_device_desc bsw_pwm_dev_desc = {
>  	.flags = LPSS_SAVE_CTX | LPSS_NO_D3_DELAY,
> +	.setup = bsw_pwm_setup,
>  };
>
>  static const struct lpss_device_desc byt_uart_dev_desc = {
>
Andy Shevchenko Jan. 30, 2017, 10:21 p.m. UTC | #2
On Sun, Jan 22, 2017 at 5:24 PM, Hans de Goede <hdegoede@redhat.com> wrote:
> On x86 we do not have devicetree to link the pwm controller and
> the display controller together. So someone needs to call
> pwm_add_table() to create the link, so that the i915 driver's
> pwm_get(dev, "pwm_backlight") call returns the lpss' pwm0.
>
> The pwm subsystem does not want to have pwm_add_table() calls
> directly in pwm drivers (this leads to probe ordering issues),
> so lets do it here since the acpi-lpss code is always builtin.

Hans, just to be sure, the device you have is using LPSS pwm for backlight.
Since I just recall that on some (Baytrail) models we have PMIC
(Crystal Cove) that responsible for PWM for backlight.
And we have no PMIC driver in kernel for CherryTrail (Dollar Cove).
Hans de Goede Jan. 31, 2017, 8:29 a.m. UTC | #3
Hi,

On 30-01-17 23:21, Andy Shevchenko wrote:
> On Sun, Jan 22, 2017 at 5:24 PM, Hans de Goede <hdegoede@redhat.com> wrote:
>> On x86 we do not have devicetree to link the pwm controller and
>> the display controller together. So someone needs to call
>> pwm_add_table() to create the link, so that the i915 driver's
>> pwm_get(dev, "pwm_backlight") call returns the lpss' pwm0.
>>
>> The pwm subsystem does not want to have pwm_add_table() calls
>> directly in pwm drivers (this leads to probe ordering issues),
>> so lets do it here since the acpi-lpss code is always builtin.
>
> Hans, just to be sure, the device you have is using LPSS pwm for backlight.

Correct, I've 2 cherrytrail tablets and one mini laptop, the 2 tablets
both use LPSS for backlight, the mini laptop just arrived and I
still need to put Linux on it.

> Since I just recall that on some (Baytrail) models we have PMIC
> (Crystal Cove) that responsible for PWM for backlight.
> And we have no PMIC driver in kernel for CherryTrail (Dollar Cove).

Right, on baytrail the pwm_crc driver is used which AFAIK is
for CRystal Cove.

Regards,

Hans
diff mbox

Patch

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 8ea836c..1b4bcf6 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -20,6 +20,7 @@ 
 #include <linux/platform_data/clk-lpss.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
+#include <linux/pwm.h>
 #include <linux/delay.h>
 
 #include "internal.h"
@@ -154,6 +155,17 @@  static void byt_i2c_setup(struct lpss_private_data *pdata)
 	writel(0, pdata->mmio_base + LPSS_I2C_ENABLE);
 }
 
+/* BSW PWM used for backlight control by the i915 driver */
+static struct pwm_lookup bsw_pwm_lookup[] = {
+	PWM_LOOKUP("80862288:00", 0, "0000:00:02.0", "pwm_backlight", 0,
+		   PWM_POLARITY_NORMAL),
+};
+
+static void bsw_pwm_setup(struct lpss_private_data *pdata)
+{
+	pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup));
+}
+
 static const struct lpss_device_desc lpt_dev_desc = {
 	.flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
 	.prv_offset = 0x800,
@@ -191,6 +203,7 @@  static const struct lpss_device_desc byt_pwm_dev_desc = {
 
 static const struct lpss_device_desc bsw_pwm_dev_desc = {
 	.flags = LPSS_SAVE_CTX | LPSS_NO_D3_DELAY,
+	.setup = bsw_pwm_setup,
 };
 
 static const struct lpss_device_desc byt_uart_dev_desc = {