diff mbox series

[v6,4/4] drm/i915/intel_dsi_vbt: Add support for PMIC MIPI sequences

Message ID 20190107111556.4510-5-hdegoede@redhat.com (mailing list archive)
State New, archived
Headers show
Series ACPI/i915: Add support for PMIC MIPI sequence elements | expand

Commit Message

Hans de Goede Jan. 7, 2019, 11:15 a.m. UTC
Add support for PMIC MIPI sequences using the new
intel_soc_pmic_exec_mipi_pmic_seq_element function.

This fixes the DSI LCD panel not lighting up when not initialized by the
GOP (because an external monitor was connected) on GPD win and GPD pocket
devices.

Specifically the LCD panel seems to need GPIO pin 9 on the PMIC to be
driven high, which is done through a PMIC MIPI sequence. Before this commit
if the sequence was not executed by the GOP the pin would stay low causing
the LCD panel to not work. Having the MIPI sequences properly control this
GPIO should also help save some power when the panel is off.

Changes in v2, v3:
-Only changes to other patches in this patch-set

Changes in v4:
-Move decoding of the raw 15 bytes PMIC MIPI sequence element into
 i2c-address, register-address, value and mask into the mipi_exec_pmic()
 function instead of passing the raw data to
 intel_soc_pmic_exec_mipi_pmic_seq_element()

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/i915/intel_dsi_vbt.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

Ville Syrjälä Jan. 7, 2019, 3:31 p.m. UTC | #1
On Mon, Jan 07, 2019 at 12:15:56PM +0100, Hans de Goede wrote:
> Add support for PMIC MIPI sequences using the new
> intel_soc_pmic_exec_mipi_pmic_seq_element function.
> 
> This fixes the DSI LCD panel not lighting up when not initialized by the
> GOP (because an external monitor was connected) on GPD win and GPD pocket
> devices.
> 
> Specifically the LCD panel seems to need GPIO pin 9 on the PMIC to be
> driven high, which is done through a PMIC MIPI sequence. Before this commit
> if the sequence was not executed by the GOP the pin would stay low causing
> the LCD panel to not work. Having the MIPI sequences properly control this
> GPIO should also help save some power when the panel is off.
> 
> Changes in v2, v3:
> -Only changes to other patches in this patch-set
> 
> Changes in v4:
> -Move decoding of the raw 15 bytes PMIC MIPI sequence element into
>  i2c-address, register-address, value and mask into the mipi_exec_pmic()
>  function instead of passing the raw data to
>  intel_soc_pmic_exec_mipi_pmic_seq_element()
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/intel_dsi_vbt.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dsi_vbt.c b/drivers/gpu/drm/i915/intel_dsi_vbt.c
> index 3d1fa1a03a66..240664ef294c 100644
> --- a/drivers/gpu/drm/i915/intel_dsi_vbt.c
> +++ b/drivers/gpu/drm/i915/intel_dsi_vbt.c
> @@ -29,9 +29,11 @@
>  #include <drm/drm_edid.h>
>  #include <drm/i915_drm.h>
>  #include <linux/gpio/consumer.h>
> +#include <linux/mfd/intel_soc_pmic.h>
>  #include <linux/slab.h>
>  #include <video/mipi_display.h>
>  #include <asm/intel-mid.h>
> +#include <asm/unaligned.h>
>  #include "i915_drv.h"
>  #include "intel_drv.h"
>  #include "intel_dsi.h"
> @@ -392,7 +394,25 @@ static const u8 *mipi_exec_spi(struct intel_dsi *intel_dsi, const u8 *data)
>  
>  static const u8 *mipi_exec_pmic(struct intel_dsi *intel_dsi, const u8 *data)
>  {
> -	DRM_DEBUG_KMS("Skipping PMIC element execution\n");
> +#ifdef CONFIG_PMIC_OPREGION
> +	u32 value, mask, reg_address;
> +	u16 i2c_address;
> +	int ret;
> +
> +	/* byte 0 aka PMIC Flag is reserved */
> +	i2c_address	= get_unaligned_le16(data + 1);
> +	reg_address	= get_unaligned_le32(data + 3);
> +	value		= get_unaligned_le32(data + 7);
> +	mask		= get_unaligned_le32(data + 11);
> +
> +	ret = intel_soc_pmic_exec_mipi_pmic_seq_element(i2c_address,
> +							reg_address,
> +							value, mask);
> +	if (ret)
> +		DRM_ERROR("%s failed, error: %d\n", __func__, ret);
> +#else
> +	DRM_ERROR("Your hardware requires CONFIG_PMIC_OPREGION and it is not set\n");
> +#endif
>  
>  	return data + 15;
>  }
> -- 
> 2.20.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hans de Goede Jan. 9, 2019, 9:40 a.m. UTC | #2
Hi,

On 07-01-19 16:31, Ville Syrjälä wrote:
> On Mon, Jan 07, 2019 at 12:15:56PM +0100, Hans de Goede wrote:
>> Add support for PMIC MIPI sequences using the new
>> intel_soc_pmic_exec_mipi_pmic_seq_element function.
>>
>> This fixes the DSI LCD panel not lighting up when not initialized by the
>> GOP (because an external monitor was connected) on GPD win and GPD pocket
>> devices.
>>
>> Specifically the LCD panel seems to need GPIO pin 9 on the PMIC to be
>> driven high, which is done through a PMIC MIPI sequence. Before this commit
>> if the sequence was not executed by the GOP the pin would stay low causing
>> the LCD panel to not work. Having the MIPI sequences properly control this
>> GPIO should also help save some power when the panel is off.
>>
>> Changes in v2, v3:
>> -Only changes to other patches in this patch-set
>>
>> Changes in v4:
>> -Move decoding of the raw 15 bytes PMIC MIPI sequence element into
>>   i2c-address, register-address, value and mask into the mipi_exec_pmic()
>>   function instead of passing the raw data to
>>   intel_soc_pmic_exec_mipi_pmic_seq_element()
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Thank you.

I've pushed this series to drm-intel-next-queued now.

Regards,

Hans



> 
>> ---
>>   drivers/gpu/drm/i915/intel_dsi_vbt.c | 22 +++++++++++++++++++++-
>>   1 file changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_dsi_vbt.c b/drivers/gpu/drm/i915/intel_dsi_vbt.c
>> index 3d1fa1a03a66..240664ef294c 100644
>> --- a/drivers/gpu/drm/i915/intel_dsi_vbt.c
>> +++ b/drivers/gpu/drm/i915/intel_dsi_vbt.c
>> @@ -29,9 +29,11 @@
>>   #include <drm/drm_edid.h>
>>   #include <drm/i915_drm.h>
>>   #include <linux/gpio/consumer.h>
>> +#include <linux/mfd/intel_soc_pmic.h>
>>   #include <linux/slab.h>
>>   #include <video/mipi_display.h>
>>   #include <asm/intel-mid.h>
>> +#include <asm/unaligned.h>
>>   #include "i915_drv.h"
>>   #include "intel_drv.h"
>>   #include "intel_dsi.h"
>> @@ -392,7 +394,25 @@ static const u8 *mipi_exec_spi(struct intel_dsi *intel_dsi, const u8 *data)
>>   
>>   static const u8 *mipi_exec_pmic(struct intel_dsi *intel_dsi, const u8 *data)
>>   {
>> -	DRM_DEBUG_KMS("Skipping PMIC element execution\n");
>> +#ifdef CONFIG_PMIC_OPREGION
>> +	u32 value, mask, reg_address;
>> +	u16 i2c_address;
>> +	int ret;
>> +
>> +	/* byte 0 aka PMIC Flag is reserved */
>> +	i2c_address	= get_unaligned_le16(data + 1);
>> +	reg_address	= get_unaligned_le32(data + 3);
>> +	value		= get_unaligned_le32(data + 7);
>> +	mask		= get_unaligned_le32(data + 11);
>> +
>> +	ret = intel_soc_pmic_exec_mipi_pmic_seq_element(i2c_address,
>> +							reg_address,
>> +							value, mask);
>> +	if (ret)
>> +		DRM_ERROR("%s failed, error: %d\n", __func__, ret);
>> +#else
>> +	DRM_ERROR("Your hardware requires CONFIG_PMIC_OPREGION and it is not set\n");
>> +#endif
>>   
>>   	return data + 15;
>>   }
>> -- 
>> 2.20.1
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/intel_dsi_vbt.c b/drivers/gpu/drm/i915/intel_dsi_vbt.c
index 3d1fa1a03a66..240664ef294c 100644
--- a/drivers/gpu/drm/i915/intel_dsi_vbt.c
+++ b/drivers/gpu/drm/i915/intel_dsi_vbt.c
@@ -29,9 +29,11 @@ 
 #include <drm/drm_edid.h>
 #include <drm/i915_drm.h>
 #include <linux/gpio/consumer.h>
+#include <linux/mfd/intel_soc_pmic.h>
 #include <linux/slab.h>
 #include <video/mipi_display.h>
 #include <asm/intel-mid.h>
+#include <asm/unaligned.h>
 #include "i915_drv.h"
 #include "intel_drv.h"
 #include "intel_dsi.h"
@@ -392,7 +394,25 @@  static const u8 *mipi_exec_spi(struct intel_dsi *intel_dsi, const u8 *data)
 
 static const u8 *mipi_exec_pmic(struct intel_dsi *intel_dsi, const u8 *data)
 {
-	DRM_DEBUG_KMS("Skipping PMIC element execution\n");
+#ifdef CONFIG_PMIC_OPREGION
+	u32 value, mask, reg_address;
+	u16 i2c_address;
+	int ret;
+
+	/* byte 0 aka PMIC Flag is reserved */
+	i2c_address	= get_unaligned_le16(data + 1);
+	reg_address	= get_unaligned_le32(data + 3);
+	value		= get_unaligned_le32(data + 7);
+	mask		= get_unaligned_le32(data + 11);
+
+	ret = intel_soc_pmic_exec_mipi_pmic_seq_element(i2c_address,
+							reg_address,
+							value, mask);
+	if (ret)
+		DRM_ERROR("%s failed, error: %d\n", __func__, ret);
+#else
+	DRM_ERROR("Your hardware requires CONFIG_PMIC_OPREGION and it is not set\n");
+#endif
 
 	return data + 15;
 }