Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Jani Nikula" <jani.nikula@linux.intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Mika Westerberg" <mika.westerberg@linux.intel.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Bartosz Golaszewski" <bgolaszewski@baylibre.com>,
	"Linus Walleij" <linus.walleij@linaro.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	dri-devel@lists.freedesktop.org, linux-gpio@vger.kernel.org,
	linux-acpi@vger.kernel.org
Subject: [PATCH 1/2] pinctrl: baytrail: Add GPIO lookup and pinctrl-map for i915 DSI panel ctrl
Date: Fri, 29 Nov 2019 19:58:35 +0100
Message-ID: <20191129185836.2789-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20191129185836.2789-1-hdegoede@redhat.com>

On Bay Trail devices the MIPI power on/off sequences for DSI LCD panels
do not control the LCD panel and backlight GPIOs. So far we have been
relying on these GPIOs being configured as output and driven high by
the Video BIOS (GOP) when it initializes the panel.

This does not work when the device is booted with a HDMI monitor connected
as then the GOP will initialize the HDMI instead of the panel, leaving the
panel black, even though the i915 driver tries to output an image to it.

Likewise on some device-models when the GOP does not initialize the DSI
panel it also leaves the mux of the PWM0 pin in generic GPIO mode instead
of muxing it to the PWM controller.

This commit adds GPIO lookups and a pinctrl-map which the i915 driver can
use to get the panel- and backlight-enable GPIOs and to mux the PWM0 pin
to the PWM controller.

Note it may seem a bit weird to add a pinctrl-map for the i915 driver,
so that it can set the PWM0 pinmux. Doing this from the LPSS PWM driver
would be more logical. But the only thing telling us that the pin should
definitely be muxed to the PWM controller is the VBT to which the PWM
driver does not have access.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 44 ++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 3a6404b6fd7e..a13ca7c672fa 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -9,6 +9,7 @@
 #include <linux/acpi.h>
 #include <linux/bitops.h>
 #include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -1601,6 +1602,39 @@ static const struct acpi_device_id byt_gpio_acpi_match[] = {
 	{ }
 };
 
+/*
+ * On Bay Trail devices with a DSI LCD panel and using the SoC (LPSS) pwm for
+ * backlight control, the i915 driver needs to control the backlight and LCD
+ * enable GPIOs, which are always pin 10 and 11 on the NCORE. Without this
+ * the LCD panel will not light-up when the system is booted with a HDMI cable
+ * inserted and the video BIOS / GOP did not init the LCD because of this.
+ *
+ * Likewise in some cases when a HDMI cable is inserted the firmware does not
+ * even properly mux the PWM0 pin. We add a pinctrl-map for this so that the
+ * i915 driver can fix this. Note that the map is for the i915 device not for
+ * the PWM device. This is a bit weird, but the only thing telling us that
+ * the pin should definitely be muxed to the PWM controller is the VBT bit
+ * which tells the i915 driver to use the SoC's PWM for backlight control.
+ */
+
+static char score_name[32];
+static char ncore_name[32];
+
+static const struct pinctrl_map byt_panel_pwm_pinctrl_map[] = {
+	PIN_MAP_MUX_GROUP("0000:00:02.0", "soc_pwm0", score_name,
+			  "pwm0_grp", "pwm"),
+};
+
+static struct gpiod_lookup_table byt_panel_gpio_table = {
+	.dev_id = "0000:00:02.0",
+	.table = {
+	  /* "soc_" prefix to distuingish these from those on the PMIC */
+	  GPIO_LOOKUP(ncore_name, 10, "soc_backlight_enable", GPIO_ACTIVE_HIGH),
+	  GPIO_LOOKUP(ncore_name, 11, "soc_panel_enable", GPIO_ACTIVE_HIGH),
+	  { },
+	},
+};
+
 static int byt_pinctrl_probe(struct platform_device *pdev)
 {
 	const struct intel_pinctrl_soc_data *soc_data = NULL;
@@ -1651,6 +1685,16 @@ static int byt_pinctrl_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	if (soc_data == &byt_score_soc_data) {
+		strscpy(score_name, dev_name(&pdev->dev), sizeof(score_name));
+		ret = pinctrl_register_mappings(byt_panel_pwm_pinctrl_map, 1);
+		if (ret)
+			dev_err(&pdev->dev, "failed to register pinctrl-map\n");
+	} else if (soc_data == &byt_ncore_soc_data) {
+		strscpy(ncore_name, dev_name(&pdev->dev), sizeof(ncore_name));
+		gpiod_add_lookup_table(&byt_panel_gpio_table);
+	}
+
 	platform_set_drvdata(pdev, vg);
 	pm_runtime_enable(&pdev->dev);
 
-- 
2.23.0


  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-29 18:58 [PATCH 0/2] drm/i915/vlv_dsi: Control panel and backlight enable GPIOs on BYT Hans de Goede
2019-11-29 18:58 ` Hans de Goede [this message]
2019-12-02 11:39   ` [PATCH 1/2] pinctrl: baytrail: Add GPIO lookup and pinctrl-map for i915 DSI panel ctrl Linus Walleij
2019-12-02 13:09   ` Andy Shevchenko
2019-11-29 18:58 ` [PATCH 2/2] drm/i915/vlv_dsi: Control panel and backlight enable GPIOs on BYT Hans de Goede
2019-12-02 11:21   ` Linus Walleij
2019-12-02 11:53     ` Jani Nikula
2019-12-02 15:49       ` Hans de Goede
2019-12-11  0:24         ` Linus Walleij
2019-12-11 17:32           ` Hans de Goede
2019-11-29 20:07 ` [PATCH 0/2] " Andy Shevchenko

Reply instructions:

You may reply publically 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=20191129185836.2789-2-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=ville.syrjala@linux.intel.com \
    /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

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git