From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Lee Jones <lee.jones@linaro.org>,
Linus Walleij <linus.walleij@linaro.org>,
intel-gfx <intel-gfx@lists.freedesktop.org>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH 5/5] drm/i915/dsi: Control panel and backlight enable GPIOs on BYT
Date: Mon, 16 Dec 2019 16:04:27 +0200 [thread overview]
Message-ID: <20191216140427.GT1208@intel.com> (raw)
In-Reply-To: <20191215163810.52356-6-hdegoede@redhat.com>
On Sun, Dec 15, 2019 at 05:38:10PM +0100, Hans de Goede wrote:
> On Bay Trail devices the MIPI power on/off sequences for DSI LCD panels
> do not control the LCD panel- and backlight-enable GPIOs. So far, when
> the VBT indicates we should use the SoC for backlight control, 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 makes the DSI code control the SoC GPIOs for panel- and
> backlight-enable on BYT, when the VBT indicates the SoC should be used
>
> for backlight control. It also ensures that the PWM0 pin is muxed to the
> PWM controller in this case.
>
> This fixes the LCD panel not lighting up on various devices when booted
> with a HDMI monitor connected. This has been tested to fix this on the
> following devices:
>
> Peaq C1010
> Point of View MOBII TAB-P800W
> Point of View MOBII TAB-P1005W
> Terra Pad 1061
> Yours Y8W81
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/gpu/drm/i915/display/intel_dsi.h | 3 +-
> drivers/gpu/drm/i915/display/intel_dsi_vbt.c | 63 ++++++++++++++++++++
> 2 files changed, 65 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dsi.h b/drivers/gpu/drm/i915/display/intel_dsi.h
> index 675771ea91aa..7481a5aa3084 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsi.h
> +++ b/drivers/gpu/drm/i915/display/intel_dsi.h
> @@ -45,8 +45,9 @@ struct intel_dsi {
> struct intel_dsi_host *dsi_hosts[I915_MAX_PORTS];
> intel_wakeref_t io_wakeref[I915_MAX_PORTS];
>
> - /* GPIO Desc for CRC based Panel control */
> + /* GPIO Desc for panel and backlight control */
> struct gpio_desc *gpio_panel;
> + struct gpio_desc *gpio_backlight;
>
> struct intel_connector *attached_connector;
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> index 847f04eec2a1..bd007d4f86e2 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> +++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> @@ -27,6 +27,8 @@
> #include <linux/gpio/consumer.h>
> #include <linux/gpio/machine.h>
> #include <linux/mfd/intel_soc_pmic.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/pinctrl/machine.h>
> #include <linux/slab.h>
>
> #include <asm/intel-mid.h>
> @@ -525,11 +527,15 @@ void intel_dsi_vbt_exec_sequence(struct intel_dsi *intel_dsi,
> {
> if (seq_id == MIPI_SEQ_POWER_ON && intel_dsi->gpio_panel)
> gpiod_set_value_cansleep(intel_dsi->gpio_panel, 1);
> + if (seq_id == MIPI_SEQ_BACKLIGHT_ON && intel_dsi->gpio_backlight)
> + gpiod_set_value_cansleep(intel_dsi->gpio_backlight, 1);
>
> intel_dsi_vbt_exec(intel_dsi, seq_id);
>
> if (seq_id == MIPI_SEQ_POWER_OFF && intel_dsi->gpio_panel)
> gpiod_set_value_cansleep(intel_dsi->gpio_panel, 0);
> + if (seq_id == MIPI_SEQ_BACKLIGHT_OFF && intel_dsi->gpio_backlight)
> + gpiod_set_value_cansleep(intel_dsi->gpio_backlight, 0);
> }
>
> void intel_dsi_msleep(struct intel_dsi *intel_dsi, int msec)
> @@ -688,6 +694,8 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id)
> /*
> * On some BYT/CHT devs some sequences are incomplete and we need to manually
> * control some GPIOs. We need to add a GPIO lookup table before we get these.
> + * If the GOP did not initialize the panel (HDMI inserted) we may need to also
> + * change the pinmux for the SoC's PWM0 pin from GPIO to PWM.
> */
> static struct gpiod_lookup_table pmic_panel_gpio_table = {
> /* Intel GFX is consumer */
> @@ -699,23 +707,68 @@ static struct gpiod_lookup_table pmic_panel_gpio_table = {
> },
> };
>
> +static struct gpiod_lookup_table soc_panel_gpio_table = {
> + .dev_id = "0000:00:02.0",
> + .table = {
> + GPIO_LOOKUP("INT33FC:01", 10, "backlight", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("INT33FC:01", 11, "panel", GPIO_ACTIVE_HIGH),
> + { },
Some kind of indent fail here.
> + },
> +};
> +
> +static const struct pinctrl_map soc_pwm_pinctrl_map[] = {
> + PIN_MAP_MUX_GROUP("0000:00:02.0", "soc_pwm0", "INT33FC:00",
> + "pwm0_grp", "pwm"),
> +};
> +
> void intel_dsi_vbt_gpio_init(struct intel_dsi *intel_dsi, bool panel_is_on)
> {
> struct drm_device *dev = intel_dsi->base.base.dev;
> struct drm_i915_private *dev_priv = to_i915(dev);
> struct mipi_config *mipi_config = dev_priv->vbt.dsi.config;
> enum gpiod_flags flags = panel_is_on ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
> + bool want_backlight_gpio = false;
> + bool want_panel_gpio = false;
> + struct pinctrl *pinctrl;
> + int ret;
>
> if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
> (mipi_config->pwm_blc == PPS_BLC_PMIC)) {
> gpiod_add_lookup_table(&pmic_panel_gpio_table);
> + want_panel_gpio = true;
> + }
> +
> + if (IS_VALLEYVIEW(dev_priv) && mipi_config->pwm_blc == PPS_BLC_SOC) {
> + gpiod_add_lookup_table(&soc_panel_gpio_table);
> + want_panel_gpio = true;
> + want_backlight_gpio = true;
>
> + /* Ensure PWM0 pin is muxed as PWM instead of GPIO */
> + ret = pinctrl_register_mappings(soc_pwm_pinctrl_map, 1);
ARRAY_SIZE()?
> + if (ret)
> + DRM_ERROR("Failed to register pwm0 pinmux mapping\n");
> +
> + pinctrl = devm_pinctrl_get_select(dev->dev, "soc_pwm0");
> + if (IS_ERR(pinctrl))
> + DRM_ERROR("Failed to set pinmux to PWM\n");
> + }
> +
> + if (want_panel_gpio) {
> intel_dsi->gpio_panel = gpiod_get(dev->dev, "panel", flags);
> if (IS_ERR(intel_dsi->gpio_panel)) {
> DRM_ERROR("Failed to own gpio for panel control\n");
> intel_dsi->gpio_panel = NULL;
> }
> }
> +
> + if (want_backlight_gpio) {
> + intel_dsi->gpio_backlight =
> + gpiod_get(dev->dev, "backlight", flags);
> + if (IS_ERR(intel_dsi->gpio_backlight)) {
> + DRM_ERROR("Failed to own gpio for backlight control\n");
> + intel_dsi->gpio_backlight = NULL;
> + }
> + }
> }
>
> void intel_dsi_vbt_gpio_cleanup(struct intel_dsi *intel_dsi)
> @@ -729,7 +782,17 @@ void intel_dsi_vbt_gpio_cleanup(struct intel_dsi *intel_dsi)
> intel_dsi->gpio_panel = NULL;
> }
>
> + if (intel_dsi->gpio_backlight) {
> + gpiod_put(intel_dsi->gpio_backlight);
> + intel_dsi->gpio_backlight = NULL;
> + }
> +
> if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
> (mipi_config->pwm_blc == PPS_BLC_PMIC))
> gpiod_remove_lookup_table(&pmic_panel_gpio_table);
> +
> + if (IS_VALLEYVIEW(dev_priv) && mipi_config->pwm_blc == PPS_BLC_SOC) {
Slightly annoying to have these checks duplicated. Might be cleaner to
have a few helpers that return the correct tables and just use those in
both init and cleanup. OTOH those want_*_gpio flags and the pwm stuff is
would still be a sticking point I suppose. So maybe not cleaner in the
end after all.
Looks all right to me:
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> + pinctrl_unregister_mappings(soc_pwm_pinctrl_map);
> + gpiod_remove_lookup_table(&soc_panel_gpio_table);
> + }
> }
> --
> 2.23.0
--
Ville Syrjälä
Intel
WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
dri-devel@lists.freedesktop.org,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Lee Jones <lee.jones@linaro.org>,
intel-gfx <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 5/5] drm/i915/dsi: Control panel and backlight enable GPIOs on BYT
Date: Mon, 16 Dec 2019 16:04:27 +0200 [thread overview]
Message-ID: <20191216140427.GT1208@intel.com> (raw)
In-Reply-To: <20191215163810.52356-6-hdegoede@redhat.com>
On Sun, Dec 15, 2019 at 05:38:10PM +0100, Hans de Goede wrote:
> On Bay Trail devices the MIPI power on/off sequences for DSI LCD panels
> do not control the LCD panel- and backlight-enable GPIOs. So far, when
> the VBT indicates we should use the SoC for backlight control, 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 makes the DSI code control the SoC GPIOs for panel- and
> backlight-enable on BYT, when the VBT indicates the SoC should be used
>
> for backlight control. It also ensures that the PWM0 pin is muxed to the
> PWM controller in this case.
>
> This fixes the LCD panel not lighting up on various devices when booted
> with a HDMI monitor connected. This has been tested to fix this on the
> following devices:
>
> Peaq C1010
> Point of View MOBII TAB-P800W
> Point of View MOBII TAB-P1005W
> Terra Pad 1061
> Yours Y8W81
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/gpu/drm/i915/display/intel_dsi.h | 3 +-
> drivers/gpu/drm/i915/display/intel_dsi_vbt.c | 63 ++++++++++++++++++++
> 2 files changed, 65 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dsi.h b/drivers/gpu/drm/i915/display/intel_dsi.h
> index 675771ea91aa..7481a5aa3084 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsi.h
> +++ b/drivers/gpu/drm/i915/display/intel_dsi.h
> @@ -45,8 +45,9 @@ struct intel_dsi {
> struct intel_dsi_host *dsi_hosts[I915_MAX_PORTS];
> intel_wakeref_t io_wakeref[I915_MAX_PORTS];
>
> - /* GPIO Desc for CRC based Panel control */
> + /* GPIO Desc for panel and backlight control */
> struct gpio_desc *gpio_panel;
> + struct gpio_desc *gpio_backlight;
>
> struct intel_connector *attached_connector;
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> index 847f04eec2a1..bd007d4f86e2 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> +++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> @@ -27,6 +27,8 @@
> #include <linux/gpio/consumer.h>
> #include <linux/gpio/machine.h>
> #include <linux/mfd/intel_soc_pmic.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/pinctrl/machine.h>
> #include <linux/slab.h>
>
> #include <asm/intel-mid.h>
> @@ -525,11 +527,15 @@ void intel_dsi_vbt_exec_sequence(struct intel_dsi *intel_dsi,
> {
> if (seq_id == MIPI_SEQ_POWER_ON && intel_dsi->gpio_panel)
> gpiod_set_value_cansleep(intel_dsi->gpio_panel, 1);
> + if (seq_id == MIPI_SEQ_BACKLIGHT_ON && intel_dsi->gpio_backlight)
> + gpiod_set_value_cansleep(intel_dsi->gpio_backlight, 1);
>
> intel_dsi_vbt_exec(intel_dsi, seq_id);
>
> if (seq_id == MIPI_SEQ_POWER_OFF && intel_dsi->gpio_panel)
> gpiod_set_value_cansleep(intel_dsi->gpio_panel, 0);
> + if (seq_id == MIPI_SEQ_BACKLIGHT_OFF && intel_dsi->gpio_backlight)
> + gpiod_set_value_cansleep(intel_dsi->gpio_backlight, 0);
> }
>
> void intel_dsi_msleep(struct intel_dsi *intel_dsi, int msec)
> @@ -688,6 +694,8 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id)
> /*
> * On some BYT/CHT devs some sequences are incomplete and we need to manually
> * control some GPIOs. We need to add a GPIO lookup table before we get these.
> + * If the GOP did not initialize the panel (HDMI inserted) we may need to also
> + * change the pinmux for the SoC's PWM0 pin from GPIO to PWM.
> */
> static struct gpiod_lookup_table pmic_panel_gpio_table = {
> /* Intel GFX is consumer */
> @@ -699,23 +707,68 @@ static struct gpiod_lookup_table pmic_panel_gpio_table = {
> },
> };
>
> +static struct gpiod_lookup_table soc_panel_gpio_table = {
> + .dev_id = "0000:00:02.0",
> + .table = {
> + GPIO_LOOKUP("INT33FC:01", 10, "backlight", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("INT33FC:01", 11, "panel", GPIO_ACTIVE_HIGH),
> + { },
Some kind of indent fail here.
> + },
> +};
> +
> +static const struct pinctrl_map soc_pwm_pinctrl_map[] = {
> + PIN_MAP_MUX_GROUP("0000:00:02.0", "soc_pwm0", "INT33FC:00",
> + "pwm0_grp", "pwm"),
> +};
> +
> void intel_dsi_vbt_gpio_init(struct intel_dsi *intel_dsi, bool panel_is_on)
> {
> struct drm_device *dev = intel_dsi->base.base.dev;
> struct drm_i915_private *dev_priv = to_i915(dev);
> struct mipi_config *mipi_config = dev_priv->vbt.dsi.config;
> enum gpiod_flags flags = panel_is_on ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
> + bool want_backlight_gpio = false;
> + bool want_panel_gpio = false;
> + struct pinctrl *pinctrl;
> + int ret;
>
> if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
> (mipi_config->pwm_blc == PPS_BLC_PMIC)) {
> gpiod_add_lookup_table(&pmic_panel_gpio_table);
> + want_panel_gpio = true;
> + }
> +
> + if (IS_VALLEYVIEW(dev_priv) && mipi_config->pwm_blc == PPS_BLC_SOC) {
> + gpiod_add_lookup_table(&soc_panel_gpio_table);
> + want_panel_gpio = true;
> + want_backlight_gpio = true;
>
> + /* Ensure PWM0 pin is muxed as PWM instead of GPIO */
> + ret = pinctrl_register_mappings(soc_pwm_pinctrl_map, 1);
ARRAY_SIZE()?
> + if (ret)
> + DRM_ERROR("Failed to register pwm0 pinmux mapping\n");
> +
> + pinctrl = devm_pinctrl_get_select(dev->dev, "soc_pwm0");
> + if (IS_ERR(pinctrl))
> + DRM_ERROR("Failed to set pinmux to PWM\n");
> + }
> +
> + if (want_panel_gpio) {
> intel_dsi->gpio_panel = gpiod_get(dev->dev, "panel", flags);
> if (IS_ERR(intel_dsi->gpio_panel)) {
> DRM_ERROR("Failed to own gpio for panel control\n");
> intel_dsi->gpio_panel = NULL;
> }
> }
> +
> + if (want_backlight_gpio) {
> + intel_dsi->gpio_backlight =
> + gpiod_get(dev->dev, "backlight", flags);
> + if (IS_ERR(intel_dsi->gpio_backlight)) {
> + DRM_ERROR("Failed to own gpio for backlight control\n");
> + intel_dsi->gpio_backlight = NULL;
> + }
> + }
> }
>
> void intel_dsi_vbt_gpio_cleanup(struct intel_dsi *intel_dsi)
> @@ -729,7 +782,17 @@ void intel_dsi_vbt_gpio_cleanup(struct intel_dsi *intel_dsi)
> intel_dsi->gpio_panel = NULL;
> }
>
> + if (intel_dsi->gpio_backlight) {
> + gpiod_put(intel_dsi->gpio_backlight);
> + intel_dsi->gpio_backlight = NULL;
> + }
> +
> if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
> (mipi_config->pwm_blc == PPS_BLC_PMIC))
> gpiod_remove_lookup_table(&pmic_panel_gpio_table);
> +
> + if (IS_VALLEYVIEW(dev_priv) && mipi_config->pwm_blc == PPS_BLC_SOC) {
Slightly annoying to have these checks duplicated. Might be cleaner to
have a few helpers that return the correct tables and just use those in
both init and cleanup. OTOH those want_*_gpio flags and the pwm stuff is
would still be a sticking point I suppose. So maybe not cleaner in the
end after all.
Looks all right to me:
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> + pinctrl_unregister_mappings(soc_pwm_pinctrl_map);
> + gpiod_remove_lookup_table(&soc_panel_gpio_table);
> + }
> }
> --
> 2.23.0
--
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
dri-devel@lists.freedesktop.org, Lee Jones <lee.jones@linaro.org>,
intel-gfx <intel-gfx@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH 5/5] drm/i915/dsi: Control panel and backlight enable GPIOs on BYT
Date: Mon, 16 Dec 2019 16:04:27 +0200 [thread overview]
Message-ID: <20191216140427.GT1208@intel.com> (raw)
In-Reply-To: <20191215163810.52356-6-hdegoede@redhat.com>
On Sun, Dec 15, 2019 at 05:38:10PM +0100, Hans de Goede wrote:
> On Bay Trail devices the MIPI power on/off sequences for DSI LCD panels
> do not control the LCD panel- and backlight-enable GPIOs. So far, when
> the VBT indicates we should use the SoC for backlight control, 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 makes the DSI code control the SoC GPIOs for panel- and
> backlight-enable on BYT, when the VBT indicates the SoC should be used
>
> for backlight control. It also ensures that the PWM0 pin is muxed to the
> PWM controller in this case.
>
> This fixes the LCD panel not lighting up on various devices when booted
> with a HDMI monitor connected. This has been tested to fix this on the
> following devices:
>
> Peaq C1010
> Point of View MOBII TAB-P800W
> Point of View MOBII TAB-P1005W
> Terra Pad 1061
> Yours Y8W81
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/gpu/drm/i915/display/intel_dsi.h | 3 +-
> drivers/gpu/drm/i915/display/intel_dsi_vbt.c | 63 ++++++++++++++++++++
> 2 files changed, 65 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dsi.h b/drivers/gpu/drm/i915/display/intel_dsi.h
> index 675771ea91aa..7481a5aa3084 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsi.h
> +++ b/drivers/gpu/drm/i915/display/intel_dsi.h
> @@ -45,8 +45,9 @@ struct intel_dsi {
> struct intel_dsi_host *dsi_hosts[I915_MAX_PORTS];
> intel_wakeref_t io_wakeref[I915_MAX_PORTS];
>
> - /* GPIO Desc for CRC based Panel control */
> + /* GPIO Desc for panel and backlight control */
> struct gpio_desc *gpio_panel;
> + struct gpio_desc *gpio_backlight;
>
> struct intel_connector *attached_connector;
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> index 847f04eec2a1..bd007d4f86e2 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> +++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> @@ -27,6 +27,8 @@
> #include <linux/gpio/consumer.h>
> #include <linux/gpio/machine.h>
> #include <linux/mfd/intel_soc_pmic.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/pinctrl/machine.h>
> #include <linux/slab.h>
>
> #include <asm/intel-mid.h>
> @@ -525,11 +527,15 @@ void intel_dsi_vbt_exec_sequence(struct intel_dsi *intel_dsi,
> {
> if (seq_id == MIPI_SEQ_POWER_ON && intel_dsi->gpio_panel)
> gpiod_set_value_cansleep(intel_dsi->gpio_panel, 1);
> + if (seq_id == MIPI_SEQ_BACKLIGHT_ON && intel_dsi->gpio_backlight)
> + gpiod_set_value_cansleep(intel_dsi->gpio_backlight, 1);
>
> intel_dsi_vbt_exec(intel_dsi, seq_id);
>
> if (seq_id == MIPI_SEQ_POWER_OFF && intel_dsi->gpio_panel)
> gpiod_set_value_cansleep(intel_dsi->gpio_panel, 0);
> + if (seq_id == MIPI_SEQ_BACKLIGHT_OFF && intel_dsi->gpio_backlight)
> + gpiod_set_value_cansleep(intel_dsi->gpio_backlight, 0);
> }
>
> void intel_dsi_msleep(struct intel_dsi *intel_dsi, int msec)
> @@ -688,6 +694,8 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id)
> /*
> * On some BYT/CHT devs some sequences are incomplete and we need to manually
> * control some GPIOs. We need to add a GPIO lookup table before we get these.
> + * If the GOP did not initialize the panel (HDMI inserted) we may need to also
> + * change the pinmux for the SoC's PWM0 pin from GPIO to PWM.
> */
> static struct gpiod_lookup_table pmic_panel_gpio_table = {
> /* Intel GFX is consumer */
> @@ -699,23 +707,68 @@ static struct gpiod_lookup_table pmic_panel_gpio_table = {
> },
> };
>
> +static struct gpiod_lookup_table soc_panel_gpio_table = {
> + .dev_id = "0000:00:02.0",
> + .table = {
> + GPIO_LOOKUP("INT33FC:01", 10, "backlight", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("INT33FC:01", 11, "panel", GPIO_ACTIVE_HIGH),
> + { },
Some kind of indent fail here.
> + },
> +};
> +
> +static const struct pinctrl_map soc_pwm_pinctrl_map[] = {
> + PIN_MAP_MUX_GROUP("0000:00:02.0", "soc_pwm0", "INT33FC:00",
> + "pwm0_grp", "pwm"),
> +};
> +
> void intel_dsi_vbt_gpio_init(struct intel_dsi *intel_dsi, bool panel_is_on)
> {
> struct drm_device *dev = intel_dsi->base.base.dev;
> struct drm_i915_private *dev_priv = to_i915(dev);
> struct mipi_config *mipi_config = dev_priv->vbt.dsi.config;
> enum gpiod_flags flags = panel_is_on ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
> + bool want_backlight_gpio = false;
> + bool want_panel_gpio = false;
> + struct pinctrl *pinctrl;
> + int ret;
>
> if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
> (mipi_config->pwm_blc == PPS_BLC_PMIC)) {
> gpiod_add_lookup_table(&pmic_panel_gpio_table);
> + want_panel_gpio = true;
> + }
> +
> + if (IS_VALLEYVIEW(dev_priv) && mipi_config->pwm_blc == PPS_BLC_SOC) {
> + gpiod_add_lookup_table(&soc_panel_gpio_table);
> + want_panel_gpio = true;
> + want_backlight_gpio = true;
>
> + /* Ensure PWM0 pin is muxed as PWM instead of GPIO */
> + ret = pinctrl_register_mappings(soc_pwm_pinctrl_map, 1);
ARRAY_SIZE()?
> + if (ret)
> + DRM_ERROR("Failed to register pwm0 pinmux mapping\n");
> +
> + pinctrl = devm_pinctrl_get_select(dev->dev, "soc_pwm0");
> + if (IS_ERR(pinctrl))
> + DRM_ERROR("Failed to set pinmux to PWM\n");
> + }
> +
> + if (want_panel_gpio) {
> intel_dsi->gpio_panel = gpiod_get(dev->dev, "panel", flags);
> if (IS_ERR(intel_dsi->gpio_panel)) {
> DRM_ERROR("Failed to own gpio for panel control\n");
> intel_dsi->gpio_panel = NULL;
> }
> }
> +
> + if (want_backlight_gpio) {
> + intel_dsi->gpio_backlight =
> + gpiod_get(dev->dev, "backlight", flags);
> + if (IS_ERR(intel_dsi->gpio_backlight)) {
> + DRM_ERROR("Failed to own gpio for backlight control\n");
> + intel_dsi->gpio_backlight = NULL;
> + }
> + }
> }
>
> void intel_dsi_vbt_gpio_cleanup(struct intel_dsi *intel_dsi)
> @@ -729,7 +782,17 @@ void intel_dsi_vbt_gpio_cleanup(struct intel_dsi *intel_dsi)
> intel_dsi->gpio_panel = NULL;
> }
>
> + if (intel_dsi->gpio_backlight) {
> + gpiod_put(intel_dsi->gpio_backlight);
> + intel_dsi->gpio_backlight = NULL;
> + }
> +
> if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
> (mipi_config->pwm_blc == PPS_BLC_PMIC))
> gpiod_remove_lookup_table(&pmic_panel_gpio_table);
> +
> + if (IS_VALLEYVIEW(dev_priv) && mipi_config->pwm_blc == PPS_BLC_SOC) {
Slightly annoying to have these checks duplicated. Might be cleaner to
have a few helpers that return the correct tables and just use those in
both init and cleanup. OTOH those want_*_gpio flags and the pwm stuff is
would still be a sticking point I suppose. So maybe not cleaner in the
end after all.
Looks all right to me:
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> + pinctrl_unregister_mappings(soc_pwm_pinctrl_map);
> + gpiod_remove_lookup_table(&soc_panel_gpio_table);
> + }
> }
> --
> 2.23.0
--
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-12-16 14:04 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-15 16:38 [PATCH 0/5] drm/i915/dsi: Control panel and backlight enable GPIOs from VBT Hans de Goede
2019-12-15 16:38 ` [Intel-gfx] " Hans de Goede
2019-12-15 16:38 ` Hans de Goede
2019-12-15 16:38 ` [PATCH 1/5] pinctrl: Export pinctrl_unregister_mappings Hans de Goede
2019-12-15 16:38 ` [Intel-gfx] " Hans de Goede
2019-12-15 16:38 ` Hans de Goede
2019-12-15 16:38 ` [PATCH 2/5] drm/i915/dsi: Move poking of panel-enable GPIO to intel_dsi_vbt.c Hans de Goede
2019-12-15 16:38 ` [Intel-gfx] " Hans de Goede
2019-12-15 16:38 ` Hans de Goede
2019-12-16 10:27 ` Linus Walleij
2019-12-16 10:27 ` [Intel-gfx] " Linus Walleij
2019-12-16 10:27 ` Linus Walleij
2019-12-16 13:51 ` Ville Syrjälä
2019-12-16 13:51 ` [Intel-gfx] " Ville Syrjälä
2019-12-16 13:51 ` Ville Syrjälä
2019-12-15 16:38 ` [PATCH 3/5] drm/i915/dsi: Init panel-enable GPIO to low when the LCD is initially off Hans de Goede
2019-12-15 16:38 ` [Intel-gfx] " Hans de Goede
2019-12-15 16:38 ` Hans de Goede
2019-12-16 10:28 ` Linus Walleij
2019-12-16 10:28 ` [Intel-gfx] " Linus Walleij
2019-12-16 10:28 ` Linus Walleij
2019-12-16 13:45 ` Ville Syrjälä
2019-12-16 13:45 ` [Intel-gfx] " Ville Syrjälä
2019-12-16 13:45 ` Ville Syrjälä
2019-12-16 13:51 ` Hans de Goede
2019-12-16 13:51 ` [Intel-gfx] " Hans de Goede
2019-12-16 13:51 ` Hans de Goede
2019-12-16 14:14 ` Ville Syrjälä
2019-12-16 14:14 ` [Intel-gfx] " Ville Syrjälä
2019-12-16 14:14 ` Ville Syrjälä
2019-12-16 14:59 ` Hans de Goede
2019-12-16 14:59 ` [Intel-gfx] " Hans de Goede
2019-12-16 14:59 ` Hans de Goede
2019-12-15 16:38 ` [PATCH 4/5] drm/i915/dsi: Move Crystal Cove PMIC panel GPIO lookup from mfd to the i915 driver Hans de Goede
2019-12-15 16:38 ` [Intel-gfx] " Hans de Goede
2019-12-15 16:38 ` Hans de Goede
2019-12-16 10:30 ` Linus Walleij
2019-12-16 10:30 ` [Intel-gfx] " Linus Walleij
2019-12-16 10:30 ` Linus Walleij
2019-12-16 12:16 ` Andy Shevchenko
2019-12-16 12:16 ` [Intel-gfx] " Andy Shevchenko
2019-12-16 12:16 ` Andy Shevchenko
2019-12-16 13:13 ` Hans de Goede
2019-12-16 13:13 ` [Intel-gfx] " Hans de Goede
2019-12-16 13:13 ` Hans de Goede
2019-12-16 13:56 ` Ville Syrjälä
2019-12-16 13:56 ` [Intel-gfx] " Ville Syrjälä
2019-12-16 13:56 ` Ville Syrjälä
2019-12-16 14:16 ` Hans de Goede
2019-12-16 14:16 ` [Intel-gfx] " Hans de Goede
2019-12-16 14:16 ` Hans de Goede
2019-12-15 16:38 ` [PATCH 5/5] drm/i915/dsi: Control panel and backlight enable GPIOs on BYT Hans de Goede
2019-12-15 16:38 ` [Intel-gfx] " Hans de Goede
2019-12-15 16:38 ` Hans de Goede
2019-12-16 10:29 ` Linus Walleij
2019-12-16 10:29 ` [Intel-gfx] " Linus Walleij
2019-12-16 10:29 ` Linus Walleij
2019-12-16 14:04 ` Ville Syrjälä [this message]
2019-12-16 14:04 ` [Intel-gfx] " Ville Syrjälä
2019-12-16 14:04 ` Ville Syrjälä
2019-12-16 14:28 ` Hans de Goede
2019-12-16 14:28 ` [Intel-gfx] " Hans de Goede
2019-12-16 14:28 ` Hans de Goede
2019-12-15 17:11 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/dsi: Control panel and backlight enable GPIOs from VBT Patchwork
2019-12-15 17:32 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2019-12-15 18:55 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2019-12-16 10:26 ` [PATCH 0/5] " Linus Walleij
2019-12-16 10:26 ` [Intel-gfx] " Linus Walleij
2019-12-16 10:26 ` Linus Walleij
2019-12-16 10:59 ` Hans de Goede
2019-12-16 10:59 ` [Intel-gfx] " Hans de Goede
2019-12-16 10:59 ` Hans de Goede
2019-12-16 11:11 ` Hans de Goede
2019-12-16 11:11 ` [Intel-gfx] " Hans de Goede
2019-12-16 11:11 ` Hans de Goede
2019-12-16 12:16 ` Linus Walleij
2019-12-16 12:16 ` [Intel-gfx] " Linus Walleij
2019-12-16 12:16 ` Linus Walleij
2019-12-16 13:25 ` Hans de Goede
2019-12-16 13:25 ` [Intel-gfx] " Hans de Goede
2019-12-16 13:25 ` Hans de Goede
2019-12-16 12:18 ` Andy Shevchenko
2019-12-16 12:18 ` [Intel-gfx] " Andy Shevchenko
2019-12-16 12:18 ` Andy Shevchenko
2019-12-16 16:10 ` Lee Jones
2019-12-16 16:10 ` [Intel-gfx] " Lee Jones
2019-12-16 16:10 ` Lee Jones
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=20191216140427.GT1208@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hdegoede@redhat.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.