diff -ur old/drivers/gpu/drm/i915/i915_drv.h linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/gpu/drm/i915/i915_drv.h --- old/drivers/gpu/drm/i915/i915_drv.h 2014-11-24 16:07:51.597050369 -0800 +++ linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/gpu/drm/i915/i915_drv.h 2014-11-24 16:08:28.199423974 -0800 @@ -2223,6 +2223,7 @@ bool disable_vtd_wa; int use_mmio_flip; bool mmio_debug; + bool force_backlight_pmic; }; extern struct i915_params i915 __read_mostly; diff -ur old/drivers/gpu/drm/i915/i915_params.c linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/gpu/drm/i915/i915_params.c --- old/drivers/gpu/drm/i915/i915_params.c 2014-11-24 16:07:51.590050297 -0800 +++ linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/gpu/drm/i915/i915_params.c 2014-11-24 16:08:28.200423985 -0800 @@ -51,6 +51,7 @@ .disable_vtd_wa = 0, .use_mmio_flip = 0, .mmio_debug = 0, + .force_backlight_pmic = 0, }; module_param_named(modeset, i915.modeset, int, 0400); @@ -173,3 +174,7 @@ MODULE_PARM_DESC(mmio_debug, "Enable the MMIO debug code (default: false). This may negatively " "affect performance."); + +module_param_named(force_backlight_pmic, i915.force_backlight_pmic, bool, 0600); +MODULE_PARM_DESC(force_backlight_pmic, + "Force backlight adjusting through pmic (default: false)."); diff -ur old/drivers/gpu/drm/i915/intel_dsi.c linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/gpu/drm/i915/intel_dsi.c --- old/drivers/gpu/drm/i915/intel_dsi.c 2014-11-24 16:07:51.590050297 -0800 +++ linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/gpu/drm/i915/intel_dsi.c 2014-11-24 16:08:14.207281155 -0800 @@ -140,6 +140,8 @@ struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); + struct intel_connector *intel_connector = + &intel_dsi->attached_connector->base; int pipe = intel_crtc->pipe; u32 temp; @@ -163,6 +165,8 @@ I915_WRITE(MIPI_PORT_CTRL(pipe), temp | DPI_ENABLE); POSTING_READ(MIPI_PORT_CTRL(pipe)); } + + intel_panel_enable_backlight(intel_connector); } static void intel_dsi_pre_enable(struct intel_encoder *encoder) @@ -237,6 +241,8 @@ struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); + struct intel_connector *intel_connector = + &intel_dsi->attached_connector->base; int pipe = intel_crtc->pipe; u32 temp; @@ -253,6 +259,8 @@ msleep(2); } + intel_panel_disable_backlight(intel_connector); + /* Panel commands can be sent when clock is in LP11 */ I915_WRITE(MIPI_DEVICE_READY(pipe), 0x0); @@ -670,6 +678,7 @@ DRM_DEBUG_KMS("\n"); intel_panel_fini(&intel_connector->panel); + intel_panel_destroy_backlight(connector); drm_connector_cleanup(connector); kfree(connector); } @@ -786,6 +795,7 @@ fixed_mode->type |= DRM_MODE_TYPE_PREFERRED; intel_panel_init(&intel_connector->panel, fixed_mode, NULL); + intel_panel_setup_backlight(connector); return; diff -ur old/drivers/gpu/drm/i915/intel_panel.c linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/gpu/drm/i915/intel_panel.c --- old/drivers/gpu/drm/i915/intel_panel.c 2014-11-24 16:07:51.590050297 -0800 +++ linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/gpu/drm/i915/intel_panel.c 2014-11-24 16:08:28.200423985 -0800 @@ -31,6 +31,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include "intel_drv.h" void @@ -532,6 +533,11 @@ return _vlv_get_backlight(dev, pipe); } +static u32 vlv_pmic_get_backlight(struct intel_connector *connector) +{ + return intel_soc_pmic_readb(0x4E); +} + static u32 intel_panel_get_backlight(struct intel_connector *connector) { struct drm_device *dev = connector->base.dev; @@ -607,6 +613,11 @@ I915_WRITE(VLV_BLC_PWM_CTL(pipe), tmp | level); } +static void vlv_pmic_set_backlight(struct intel_connector *connector, u32 level) +{ + intel_soc_pmic_writeb(0x4E, level); +} + static void intel_panel_actually_set_backlight(struct intel_connector *connector, u32 level) { @@ -726,6 +737,14 @@ I915_WRITE(VLV_BLC_PWM_CTL2(pipe), tmp & ~BLM_PWM_ENABLE); } +static void vlv_pmic_disable_backlight(struct intel_connector *connector) +{ + intel_panel_actually_set_backlight(connector, 0); + + intel_soc_pmic_writeb(0x51, 0x00); + intel_soc_pmic_writeb(0x4B, 0x7F); +} + void intel_panel_disable_backlight(struct intel_connector *connector) { struct drm_device *dev = connector->base.dev; @@ -930,6 +949,17 @@ I915_WRITE(VLV_BLC_PWM_CTL2(pipe), ctl2 | BLM_PWM_ENABLE); } +static void vlv_pmic_enable_backlight(struct intel_connector *connector) +{ + struct intel_panel *panel = &connector->panel; + + intel_soc_pmic_writeb(0x4B, 0xFF); + intel_soc_pmic_writeb(0x4E, 0xFF); + intel_soc_pmic_writeb(0x51, 0x01); + + intel_panel_actually_set_backlight(connector, panel->backlight.level); +} + void intel_panel_enable_backlight(struct intel_connector *connector) { struct drm_device *dev = connector->base.dev; @@ -1273,6 +1303,20 @@ return 0; } +static int vlv_pmic_setup_backlight(struct intel_connector *connector) +{ + struct intel_panel *panel = &connector->panel; + + printk("vlv_pmic_setup_backlight\n"); + panel->backlight.present = 1; + panel->backlight.min = 0x00; + panel->backlight.max = 0xFF; + panel->backlight.level = 20; + panel->backlight.enabled = 1; + + return 0; +} + int intel_panel_setup_backlight(struct drm_connector *connector) { struct drm_device *dev = connector->dev; @@ -1342,11 +1386,19 @@ dev_priv->display.set_backlight = pch_set_backlight; dev_priv->display.get_backlight = pch_get_backlight; } else if (IS_VALLEYVIEW(dev)) { - dev_priv->display.setup_backlight = vlv_setup_backlight; - dev_priv->display.enable_backlight = vlv_enable_backlight; - dev_priv->display.disable_backlight = vlv_disable_backlight; - dev_priv->display.set_backlight = vlv_set_backlight; - dev_priv->display.get_backlight = vlv_get_backlight; + if (i915.force_backlight_pmic) { + dev_priv->display.setup_backlight = vlv_pmic_setup_backlight; + dev_priv->display.enable_backlight = vlv_pmic_enable_backlight; + dev_priv->display.disable_backlight = vlv_pmic_disable_backlight; + dev_priv->display.set_backlight = vlv_pmic_set_backlight; + dev_priv->display.get_backlight = vlv_pmic_get_backlight; + } else { + dev_priv->display.setup_backlight = vlv_setup_backlight; + dev_priv->display.enable_backlight = vlv_enable_backlight; + dev_priv->display.disable_backlight = vlv_disable_backlight; + dev_priv->display.set_backlight = vlv_set_backlight; + dev_priv->display.get_backlight = vlv_get_backlight; + } } else if (IS_GEN4(dev)) { dev_priv->display.setup_backlight = i965_setup_backlight; dev_priv->display.enable_backlight = i965_enable_backlight; diff -ur old/drivers/mfd/intel_soc_pmic_core.c linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/mfd/intel_soc_pmic_core.c --- old/drivers/mfd/intel_soc_pmic_core.c 2014-11-24 16:07:51.844052890 -0800 +++ linux-3.18.0-0.rc6.git0.1.1awb.x86_64/drivers/mfd/intel_soc_pmic_core.c 2014-11-24 16:08:14.207281155 -0800 @@ -26,6 +26,8 @@ #include #include "intel_soc_pmic_core.h" +static struct intel_soc_pmic *pmic_hack = NULL; + /* * On some boards the PMIC interrupt may come from a GPIO line. * Try to lookup the ACPI table and see if such connection exists. If not, @@ -64,6 +66,7 @@ config = (struct intel_soc_pmic_config *)id->driver_data; pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL); + pmic_hack = pmic; dev_set_drvdata(dev, pmic); pmic->regmap = devm_regmap_init_i2c(i2c, config->regmap_config); @@ -135,6 +138,38 @@ } #endif +int intel_soc_pmic_readb(int reg) +{ + int ret; + unsigned int val; + + if (!pmic_hack) { + ret = -EIO; + } else { + ret = regmap_read(pmic_hack->regmap, reg, &val); + if (!ret) { + ret = val; + } + } + + return ret; +} +EXPORT_SYMBOL(intel_soc_pmic_readb); + +int intel_soc_pmic_writeb(int reg, u8 val) +{ + int ret; + + if (!pmic_hack) { + ret = -EIO; + } else { + ret = regmap_write(pmic_hack->regmap, reg, val); + } + return ret; +} +EXPORT_SYMBOL(intel_soc_pmic_writeb); + + static SIMPLE_DEV_PM_OPS(intel_soc_pmic_pm_ops, intel_soc_pmic_suspend, intel_soc_pmic_resume); diff -ur old/include/linux/mfd/intel_soc_pmic.h linux-3.18.0-0.rc6.git0.1.1awb.x86_64/include/linux/mfd/intel_soc_pmic.h --- old/include/linux/mfd/intel_soc_pmic.h 2014-11-24 16:07:46.912002548 -0800 +++ linux-3.18.0-0.rc6.git0.1.1awb.x86_64/include/linux/mfd/intel_soc_pmic.h 2014-11-24 16:08:14.207281155 -0800 @@ -27,4 +27,8 @@ struct regmap_irq_chip_data *irq_chip_data; }; +int intel_soc_pmic_readb(int reg); +int intel_soc_pmic_writeb(int reg, u8 val); + + #endif /* __INTEL_SOC_PMIC_H__ */