2011-11-04 02:22:37 +08:00
|
|
|
/**************************************************************************
|
|
|
|
* Copyright (c) 2011, Intel Corporation.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#include <linux/backlight.h>
|
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/drm.h>
|
2012-10-03 01:01:07 +08:00
|
|
|
#include <drm/gma_drm.h>
|
2011-11-04 02:22:37 +08:00
|
|
|
#include "psb_drv.h"
|
|
|
|
#include "psb_reg.h"
|
|
|
|
#include "psb_intel_reg.h"
|
|
|
|
#include "intel_bios.h"
|
|
|
|
#include "cdv_device.h"
|
2014-03-12 05:53:43 +08:00
|
|
|
#include "gma_device.h"
|
2011-11-04 02:22:37 +08:00
|
|
|
|
|
|
|
#define VGA_SR_INDEX 0x3c4
|
|
|
|
#define VGA_SR_DATA 0x3c5
|
|
|
|
|
|
|
|
static void cdv_disable_vga(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
u8 sr1;
|
|
|
|
u32 vga_reg;
|
|
|
|
|
|
|
|
vga_reg = VGACNTRL;
|
|
|
|
|
|
|
|
outb(1, VGA_SR_INDEX);
|
|
|
|
sr1 = inb(VGA_SR_DATA);
|
|
|
|
outb(sr1 | 1<<5, VGA_SR_DATA);
|
|
|
|
udelay(300);
|
|
|
|
|
|
|
|
REG_WRITE(vga_reg, VGA_DISP_DISABLE);
|
|
|
|
REG_READ(vga_reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cdv_output_init(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
2012-04-25 21:38:07 +08:00
|
|
|
|
|
|
|
drm_mode_create_scaling_mode_property(dev);
|
|
|
|
|
2011-11-04 02:22:37 +08:00
|
|
|
cdv_disable_vga(dev);
|
|
|
|
|
|
|
|
cdv_intel_crt_init(dev, &dev_priv->mode_dev);
|
|
|
|
cdv_intel_lvds_init(dev, &dev_priv->mode_dev);
|
|
|
|
|
2012-05-03 22:06:05 +08:00
|
|
|
/* These bits indicate HDMI not SDVO on CDV */
|
2012-08-08 21:55:26 +08:00
|
|
|
if (REG_READ(SDVOB) & SDVO_DETECTED) {
|
2011-11-04 02:22:37 +08:00
|
|
|
cdv_hdmi_init(dev, &dev_priv->mode_dev, SDVOB);
|
2012-08-08 21:55:26 +08:00
|
|
|
if (REG_READ(DP_B) & DP_DETECTED)
|
|
|
|
cdv_intel_dp_init(dev, &dev_priv->mode_dev, DP_B);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (REG_READ(SDVOC) & SDVO_DETECTED) {
|
2011-11-04 02:22:37 +08:00
|
|
|
cdv_hdmi_init(dev, &dev_priv->mode_dev, SDVOC);
|
2012-08-08 21:55:26 +08:00
|
|
|
if (REG_READ(DP_C) & DP_DETECTED)
|
|
|
|
cdv_intel_dp_init(dev, &dev_priv->mode_dev, DP_C);
|
|
|
|
}
|
2011-11-04 02:22:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
|
|
|
|
|
|
|
|
/*
|
2012-05-03 22:06:05 +08:00
|
|
|
* Cedartrail Backlght Interfaces
|
2011-11-04 02:22:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
static struct backlight_device *cdv_backlight_device;
|
|
|
|
|
2012-05-03 22:06:05 +08:00
|
|
|
static int cdv_backlight_combination_mode(struct drm_device *dev)
|
2011-11-04 02:22:37 +08:00
|
|
|
{
|
2012-05-03 22:06:05 +08:00
|
|
|
return REG_READ(BLC_PWM_CTL2) & PWM_LEGACY_MODE;
|
2011-11-04 02:22:37 +08:00
|
|
|
}
|
|
|
|
|
2012-05-03 22:06:05 +08:00
|
|
|
static u32 cdv_get_max_backlight(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
u32 max = REG_READ(BLC_PWM_CTL);
|
|
|
|
|
|
|
|
if (max == 0) {
|
|
|
|
DRM_DEBUG_KMS("LVDS Panel PWM value is 0!\n");
|
|
|
|
/* i915 does this, I believe which means that we should not
|
|
|
|
* smash PWM control as firmware will take control of it. */
|
|
|
|
return 1;
|
2011-11-04 02:22:37 +08:00
|
|
|
}
|
2012-05-03 22:06:05 +08:00
|
|
|
|
|
|
|
max >>= 16;
|
|
|
|
if (cdv_backlight_combination_mode(dev))
|
|
|
|
max *= 0xff;
|
|
|
|
return max;
|
2011-11-04 02:22:37 +08:00
|
|
|
}
|
|
|
|
|
2012-07-17 00:54:03 +08:00
|
|
|
static int cdv_get_brightness(struct backlight_device *bd)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = bl_get_data(bd);
|
|
|
|
u32 val = REG_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
|
|
|
|
|
|
|
|
if (cdv_backlight_combination_mode(dev)) {
|
|
|
|
u8 lbpc;
|
|
|
|
|
|
|
|
val &= ~1;
|
|
|
|
pci_read_config_byte(dev->pdev, 0xF4, &lbpc);
|
|
|
|
val *= lbpc;
|
|
|
|
}
|
|
|
|
return (val * 100)/cdv_get_max_backlight(dev);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-11-04 02:22:37 +08:00
|
|
|
static int cdv_set_brightness(struct backlight_device *bd)
|
|
|
|
{
|
2012-05-03 22:06:05 +08:00
|
|
|
struct drm_device *dev = bl_get_data(bd);
|
2011-11-04 02:22:37 +08:00
|
|
|
int level = bd->props.brightness;
|
2012-05-03 22:06:05 +08:00
|
|
|
u32 blc_pwm_ctl;
|
2011-11-04 02:22:37 +08:00
|
|
|
|
|
|
|
/* Percentage 1-100% being valid */
|
|
|
|
if (level < 1)
|
|
|
|
level = 1;
|
|
|
|
|
2012-07-17 00:54:03 +08:00
|
|
|
level *= cdv_get_max_backlight(dev);
|
|
|
|
level /= 100;
|
|
|
|
|
2012-05-03 22:06:05 +08:00
|
|
|
if (cdv_backlight_combination_mode(dev)) {
|
|
|
|
u32 max = cdv_get_max_backlight(dev);
|
|
|
|
u8 lbpc;
|
|
|
|
|
|
|
|
lbpc = level * 0xfe / max + 1;
|
|
|
|
level /= lbpc;
|
|
|
|
|
|
|
|
pci_write_config_byte(dev->pdev, 0xF4, lbpc);
|
|
|
|
}
|
|
|
|
|
|
|
|
blc_pwm_ctl = REG_READ(BLC_PWM_CTL) & ~BACKLIGHT_DUTY_CYCLE_MASK;
|
|
|
|
REG_WRITE(BLC_PWM_CTL, (blc_pwm_ctl |
|
|
|
|
(level << BACKLIGHT_DUTY_CYCLE_SHIFT)));
|
2011-11-04 02:22:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct backlight_ops cdv_ops = {
|
|
|
|
.get_brightness = cdv_get_brightness,
|
|
|
|
.update_status = cdv_set_brightness,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int cdv_backlight_init(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
struct backlight_properties props;
|
|
|
|
|
|
|
|
memset(&props, 0, sizeof(struct backlight_properties));
|
|
|
|
props.max_brightness = 100;
|
|
|
|
props.type = BACKLIGHT_PLATFORM;
|
|
|
|
|
|
|
|
cdv_backlight_device = backlight_device_register("psb-bl",
|
|
|
|
NULL, (void *)dev, &cdv_ops, &props);
|
|
|
|
if (IS_ERR(cdv_backlight_device))
|
|
|
|
return PTR_ERR(cdv_backlight_device);
|
|
|
|
|
2012-05-03 22:06:05 +08:00
|
|
|
cdv_backlight_device->props.brightness =
|
|
|
|
cdv_get_brightness(cdv_backlight_device);
|
2011-11-04 02:22:37 +08:00
|
|
|
backlight_update_status(cdv_backlight_device);
|
|
|
|
dev_priv->backlight_device = cdv_backlight_device;
|
2012-08-08 21:55:55 +08:00
|
|
|
dev_priv->backlight_enabled = true;
|
2011-11-04 02:22:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Provide the Cedarview specific chip logic and low level methods
|
|
|
|
* for power management
|
|
|
|
*
|
|
|
|
* FIXME: we need to implement the apm/ospm base management bits
|
|
|
|
* for this and the MID devices.
|
|
|
|
*/
|
|
|
|
|
2017-12-19 13:37:44 +08:00
|
|
|
static inline u32 CDV_MSG_READ32(int domain, uint port, uint offset)
|
2011-11-04 02:22:37 +08:00
|
|
|
{
|
|
|
|
int mcr = (0x10<<24) | (port << 16) | (offset << 8);
|
|
|
|
uint32_t ret_val = 0;
|
2017-12-19 13:37:44 +08:00
|
|
|
struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
|
2011-11-04 02:22:37 +08:00
|
|
|
pci_write_config_dword(pci_root, 0xD0, mcr);
|
|
|
|
pci_read_config_dword(pci_root, 0xD4, &ret_val);
|
|
|
|
pci_dev_put(pci_root);
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
2017-12-19 13:37:44 +08:00
|
|
|
static inline void CDV_MSG_WRITE32(int domain, uint port, uint offset,
|
|
|
|
u32 value)
|
2011-11-04 02:22:37 +08:00
|
|
|
{
|
|
|
|
int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
|
2017-12-19 13:37:44 +08:00
|
|
|
struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0);
|
2011-11-04 02:22:37 +08:00
|
|
|
pci_write_config_dword(pci_root, 0xD4, value);
|
|
|
|
pci_write_config_dword(pci_root, 0xD0, mcr);
|
|
|
|
pci_dev_put(pci_root);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PSB_PM_SSC 0x20
|
|
|
|
#define PSB_PM_SSS 0x30
|
2012-03-14 20:00:29 +08:00
|
|
|
#define PSB_PWRGT_GFX_ON 0x02
|
|
|
|
#define PSB_PWRGT_GFX_OFF 0x01
|
|
|
|
#define PSB_PWRGT_GFX_D0 0x00
|
|
|
|
#define PSB_PWRGT_GFX_D3 0x03
|
2011-11-04 02:22:37 +08:00
|
|
|
|
|
|
|
static void cdv_init_pm(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
u32 pwr_cnt;
|
2017-12-19 13:37:44 +08:00
|
|
|
int domain = pci_domain_nr(dev->pdev->bus);
|
2011-11-04 02:22:37 +08:00
|
|
|
int i;
|
|
|
|
|
2017-12-19 13:37:44 +08:00
|
|
|
dev_priv->apm_base = CDV_MSG_READ32(domain, PSB_PUNIT_PORT,
|
2011-11-04 02:22:37 +08:00
|
|
|
PSB_APMBA) & 0xFFFF;
|
2017-12-19 13:37:44 +08:00
|
|
|
dev_priv->ospm_base = CDV_MSG_READ32(domain, PSB_PUNIT_PORT,
|
2011-11-04 02:22:37 +08:00
|
|
|
PSB_OSPMBA) & 0xFFFF;
|
|
|
|
|
2012-03-14 20:00:29 +08:00
|
|
|
/* Power status */
|
2011-11-04 02:22:37 +08:00
|
|
|
pwr_cnt = inl(dev_priv->apm_base + PSB_APM_CMD);
|
|
|
|
|
2012-03-14 20:00:29 +08:00
|
|
|
/* Enable the GPU */
|
|
|
|
pwr_cnt &= ~PSB_PWRGT_GFX_MASK;
|
|
|
|
pwr_cnt |= PSB_PWRGT_GFX_ON;
|
2011-11-04 02:22:37 +08:00
|
|
|
outl(pwr_cnt, dev_priv->apm_base + PSB_APM_CMD);
|
2012-03-14 20:00:29 +08:00
|
|
|
|
|
|
|
/* Wait for the GPU power */
|
2011-11-04 02:22:37 +08:00
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
u32 pwr_sts = inl(dev_priv->apm_base + PSB_APM_STS);
|
|
|
|
if ((pwr_sts & PSB_PWRGT_GFX_MASK) == 0)
|
2012-03-14 20:00:29 +08:00
|
|
|
return;
|
2011-11-04 02:22:37 +08:00
|
|
|
udelay(10);
|
|
|
|
}
|
2012-03-14 20:00:29 +08:00
|
|
|
dev_err(dev->dev, "GPU: power management timed out.\n");
|
2011-11-04 02:22:37 +08:00
|
|
|
}
|
|
|
|
|
2012-04-25 21:38:07 +08:00
|
|
|
static void cdv_errata(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
/* Disable bonus launch.
|
2012-05-03 22:06:05 +08:00
|
|
|
* CPU and GPU competes for memory and display misses updates and
|
|
|
|
* flickers. Worst with dual core, dual displays.
|
2012-04-25 21:38:07 +08:00
|
|
|
*
|
2012-05-03 22:06:05 +08:00
|
|
|
* Fixes were done to Win 7 gfx driver to disable a feature called
|
|
|
|
* Bonus Launch to work around the issue, by degrading
|
|
|
|
* performance.
|
2012-04-25 21:38:07 +08:00
|
|
|
*/
|
2017-12-19 13:37:44 +08:00
|
|
|
CDV_MSG_WRITE32(pci_domain_nr(dev->pdev->bus), 3, 0x30, 0x08027108);
|
2012-04-25 21:38:07 +08:00
|
|
|
}
|
|
|
|
|
2011-11-04 02:22:37 +08:00
|
|
|
/**
|
|
|
|
* cdv_save_display_registers - save registers lost on suspend
|
|
|
|
* @dev: our DRM device
|
|
|
|
*
|
|
|
|
* Save the state we need in order to be able to restore the interface
|
|
|
|
* upon resume from suspend
|
|
|
|
*/
|
|
|
|
static int cdv_save_display_registers(struct drm_device *dev)
|
|
|
|
{
|
2012-03-14 20:00:29 +08:00
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
struct psb_save_area *regs = &dev_priv->regs;
|
|
|
|
struct drm_connector *connector;
|
|
|
|
|
2012-05-11 18:32:31 +08:00
|
|
|
dev_dbg(dev->dev, "Saving GPU registers.\n");
|
2012-03-14 20:00:29 +08:00
|
|
|
|
|
|
|
pci_read_config_byte(dev->pdev, 0xF4, ®s->cdv.saveLBB);
|
|
|
|
|
|
|
|
regs->cdv.saveDSPCLK_GATE_D = REG_READ(DSPCLK_GATE_D);
|
|
|
|
regs->cdv.saveRAMCLK_GATE_D = REG_READ(RAMCLK_GATE_D);
|
|
|
|
|
|
|
|
regs->cdv.saveDSPARB = REG_READ(DSPARB);
|
|
|
|
regs->cdv.saveDSPFW[0] = REG_READ(DSPFW1);
|
|
|
|
regs->cdv.saveDSPFW[1] = REG_READ(DSPFW2);
|
|
|
|
regs->cdv.saveDSPFW[2] = REG_READ(DSPFW3);
|
|
|
|
regs->cdv.saveDSPFW[3] = REG_READ(DSPFW4);
|
|
|
|
regs->cdv.saveDSPFW[4] = REG_READ(DSPFW5);
|
|
|
|
regs->cdv.saveDSPFW[5] = REG_READ(DSPFW6);
|
|
|
|
|
|
|
|
regs->cdv.saveADPA = REG_READ(ADPA);
|
|
|
|
|
|
|
|
regs->cdv.savePP_CONTROL = REG_READ(PP_CONTROL);
|
|
|
|
regs->cdv.savePFIT_PGM_RATIOS = REG_READ(PFIT_PGM_RATIOS);
|
|
|
|
regs->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL);
|
|
|
|
regs->saveBLC_PWM_CTL2 = REG_READ(BLC_PWM_CTL2);
|
|
|
|
regs->cdv.saveLVDS = REG_READ(LVDS);
|
|
|
|
|
|
|
|
regs->cdv.savePFIT_CONTROL = REG_READ(PFIT_CONTROL);
|
|
|
|
|
|
|
|
regs->cdv.savePP_ON_DELAYS = REG_READ(PP_ON_DELAYS);
|
|
|
|
regs->cdv.savePP_OFF_DELAYS = REG_READ(PP_OFF_DELAYS);
|
|
|
|
regs->cdv.savePP_CYCLE = REG_READ(PP_CYCLE);
|
|
|
|
|
|
|
|
regs->cdv.saveVGACNTRL = REG_READ(VGACNTRL);
|
|
|
|
|
|
|
|
regs->cdv.saveIER = REG_READ(PSB_INT_ENABLE_R);
|
|
|
|
regs->cdv.saveIMR = REG_READ(PSB_INT_MASK_R);
|
|
|
|
|
|
|
|
list_for_each_entry(connector, &dev->mode_config.connector_list, head)
|
|
|
|
connector->funcs->dpms(connector, DRM_MODE_DPMS_OFF);
|
|
|
|
|
2011-11-04 02:22:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cdv_restore_display_registers - restore lost register state
|
|
|
|
* @dev: our DRM device
|
|
|
|
*
|
|
|
|
* Restore register state that was lost during suspend and resume.
|
|
|
|
*
|
|
|
|
* FIXME: review
|
|
|
|
*/
|
|
|
|
static int cdv_restore_display_registers(struct drm_device *dev)
|
|
|
|
{
|
2012-03-14 20:00:29 +08:00
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
struct psb_save_area *regs = &dev_priv->regs;
|
|
|
|
struct drm_connector *connector;
|
|
|
|
u32 temp;
|
|
|
|
|
|
|
|
pci_write_config_byte(dev->pdev, 0xF4, regs->cdv.saveLBB);
|
|
|
|
|
|
|
|
REG_WRITE(DSPCLK_GATE_D, regs->cdv.saveDSPCLK_GATE_D);
|
|
|
|
REG_WRITE(RAMCLK_GATE_D, regs->cdv.saveRAMCLK_GATE_D);
|
|
|
|
|
|
|
|
/* BIOS does below anyway */
|
|
|
|
REG_WRITE(DPIO_CFG, 0);
|
|
|
|
REG_WRITE(DPIO_CFG, DPIO_MODE_SELECT_0 | DPIO_CMN_RESET_N);
|
|
|
|
|
|
|
|
temp = REG_READ(DPLL_A);
|
|
|
|
if ((temp & DPLL_SYNCLOCK_ENABLE) == 0) {
|
|
|
|
REG_WRITE(DPLL_A, temp | DPLL_SYNCLOCK_ENABLE);
|
|
|
|
REG_READ(DPLL_A);
|
|
|
|
}
|
|
|
|
|
|
|
|
temp = REG_READ(DPLL_B);
|
|
|
|
if ((temp & DPLL_SYNCLOCK_ENABLE) == 0) {
|
|
|
|
REG_WRITE(DPLL_B, temp | DPLL_SYNCLOCK_ENABLE);
|
|
|
|
REG_READ(DPLL_B);
|
|
|
|
}
|
|
|
|
|
|
|
|
udelay(500);
|
|
|
|
|
|
|
|
REG_WRITE(DSPFW1, regs->cdv.saveDSPFW[0]);
|
|
|
|
REG_WRITE(DSPFW2, regs->cdv.saveDSPFW[1]);
|
|
|
|
REG_WRITE(DSPFW3, regs->cdv.saveDSPFW[2]);
|
|
|
|
REG_WRITE(DSPFW4, regs->cdv.saveDSPFW[3]);
|
|
|
|
REG_WRITE(DSPFW5, regs->cdv.saveDSPFW[4]);
|
|
|
|
REG_WRITE(DSPFW6, regs->cdv.saveDSPFW[5]);
|
|
|
|
|
|
|
|
REG_WRITE(DSPARB, regs->cdv.saveDSPARB);
|
|
|
|
REG_WRITE(ADPA, regs->cdv.saveADPA);
|
|
|
|
|
|
|
|
REG_WRITE(BLC_PWM_CTL2, regs->saveBLC_PWM_CTL2);
|
|
|
|
REG_WRITE(LVDS, regs->cdv.saveLVDS);
|
|
|
|
REG_WRITE(PFIT_CONTROL, regs->cdv.savePFIT_CONTROL);
|
|
|
|
REG_WRITE(PFIT_PGM_RATIOS, regs->cdv.savePFIT_PGM_RATIOS);
|
|
|
|
REG_WRITE(BLC_PWM_CTL, regs->saveBLC_PWM_CTL);
|
|
|
|
REG_WRITE(PP_ON_DELAYS, regs->cdv.savePP_ON_DELAYS);
|
|
|
|
REG_WRITE(PP_OFF_DELAYS, regs->cdv.savePP_OFF_DELAYS);
|
|
|
|
REG_WRITE(PP_CYCLE, regs->cdv.savePP_CYCLE);
|
|
|
|
REG_WRITE(PP_CONTROL, regs->cdv.savePP_CONTROL);
|
|
|
|
|
|
|
|
REG_WRITE(VGACNTRL, regs->cdv.saveVGACNTRL);
|
|
|
|
|
|
|
|
REG_WRITE(PSB_INT_ENABLE_R, regs->cdv.saveIER);
|
|
|
|
REG_WRITE(PSB_INT_MASK_R, regs->cdv.saveIMR);
|
|
|
|
|
|
|
|
/* Fix arbitration bug */
|
2012-04-25 21:38:07 +08:00
|
|
|
cdv_errata(dev);
|
2012-03-14 20:00:29 +08:00
|
|
|
|
|
|
|
drm_mode_config_reset(dev);
|
|
|
|
|
|
|
|
list_for_each_entry(connector, &dev->mode_config.connector_list, head)
|
|
|
|
connector->funcs->dpms(connector, DRM_MODE_DPMS_ON);
|
|
|
|
|
|
|
|
/* Resume the modeset for every activated CRTC */
|
|
|
|
drm_helper_resume_force_mode(dev);
|
2011-11-04 02:22:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cdv_power_down(struct drm_device *dev)
|
|
|
|
{
|
2012-03-14 20:00:29 +08:00
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
u32 pwr_cnt, pwr_mask, pwr_sts;
|
|
|
|
int tries = 5;
|
|
|
|
|
|
|
|
pwr_cnt = inl(dev_priv->apm_base + PSB_APM_CMD);
|
|
|
|
pwr_cnt &= ~PSB_PWRGT_GFX_MASK;
|
|
|
|
pwr_cnt |= PSB_PWRGT_GFX_OFF;
|
|
|
|
pwr_mask = PSB_PWRGT_GFX_MASK;
|
|
|
|
|
|
|
|
outl(pwr_cnt, dev_priv->apm_base + PSB_APM_CMD);
|
|
|
|
|
|
|
|
while (tries--) {
|
|
|
|
pwr_sts = inl(dev_priv->apm_base + PSB_APM_STS);
|
|
|
|
if ((pwr_sts & pwr_mask) == PSB_PWRGT_GFX_D3)
|
|
|
|
return 0;
|
|
|
|
udelay(10);
|
|
|
|
}
|
2011-11-04 02:22:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cdv_power_up(struct drm_device *dev)
|
|
|
|
{
|
2012-03-14 20:00:29 +08:00
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
u32 pwr_cnt, pwr_mask, pwr_sts;
|
|
|
|
int tries = 5;
|
|
|
|
|
|
|
|
pwr_cnt = inl(dev_priv->apm_base + PSB_APM_CMD);
|
|
|
|
pwr_cnt &= ~PSB_PWRGT_GFX_MASK;
|
|
|
|
pwr_cnt |= PSB_PWRGT_GFX_ON;
|
|
|
|
pwr_mask = PSB_PWRGT_GFX_MASK;
|
|
|
|
|
|
|
|
outl(pwr_cnt, dev_priv->apm_base + PSB_APM_CMD);
|
|
|
|
|
|
|
|
while (tries--) {
|
|
|
|
pwr_sts = inl(dev_priv->apm_base + PSB_APM_STS);
|
|
|
|
if ((pwr_sts & pwr_mask) == PSB_PWRGT_GFX_D0)
|
|
|
|
return 0;
|
|
|
|
udelay(10);
|
|
|
|
}
|
2011-11-04 02:22:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-04-25 21:38:32 +08:00
|
|
|
static void cdv_hotplug_work_func(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct drm_psb_private *dev_priv = container_of(work, struct drm_psb_private,
|
|
|
|
hotplug_work);
|
|
|
|
struct drm_device *dev = dev_priv->dev;
|
|
|
|
|
|
|
|
/* Just fire off a uevent and let userspace tell us what to do */
|
|
|
|
drm_helper_hpd_irq_event(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The core driver has received a hotplug IRQ. We are in IRQ context
|
|
|
|
so extract the needed information and kick off queued processing */
|
|
|
|
|
|
|
|
static int cdv_hotplug_event(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
schedule_work(&dev_priv->hotplug_work);
|
|
|
|
REG_WRITE(PORT_HOTPLUG_STAT, REG_READ(PORT_HOTPLUG_STAT));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cdv_hotplug_enable(struct drm_device *dev, bool on)
|
|
|
|
{
|
|
|
|
if (on) {
|
|
|
|
u32 hotplug = REG_READ(PORT_HOTPLUG_EN);
|
|
|
|
hotplug |= HDMIB_HOTPLUG_INT_EN | HDMIC_HOTPLUG_INT_EN |
|
|
|
|
HDMID_HOTPLUG_INT_EN | CRT_HOTPLUG_INT_EN;
|
|
|
|
REG_WRITE(PORT_HOTPLUG_EN, hotplug);
|
|
|
|
} else {
|
|
|
|
REG_WRITE(PORT_HOTPLUG_EN, 0);
|
|
|
|
REG_WRITE(PORT_HOTPLUG_STAT, REG_READ(PORT_HOTPLUG_STAT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-08 21:54:41 +08:00
|
|
|
static const char *force_audio_names[] = {
|
|
|
|
"off",
|
|
|
|
"auto",
|
|
|
|
"on",
|
|
|
|
};
|
|
|
|
|
|
|
|
void cdv_intel_attach_force_audio_property(struct drm_connector *connector)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = connector->dev;
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
struct drm_property *prop;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
prop = dev_priv->force_audio_property;
|
|
|
|
if (prop == NULL) {
|
|
|
|
prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
|
|
|
|
"audio",
|
|
|
|
ARRAY_SIZE(force_audio_names));
|
|
|
|
if (prop == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(force_audio_names); i++)
|
|
|
|
drm_property_add_enum(prop, i, i-1, force_audio_names[i]);
|
|
|
|
|
|
|
|
dev_priv->force_audio_property = prop;
|
|
|
|
}
|
2012-10-12 09:38:23 +08:00
|
|
|
drm_object_attach_property(&connector->base, prop, 0);
|
2012-08-08 21:54:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char *broadcast_rgb_names[] = {
|
|
|
|
"Full",
|
|
|
|
"Limited 16:235",
|
|
|
|
};
|
|
|
|
|
|
|
|
void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = connector->dev;
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
struct drm_property *prop;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
prop = dev_priv->broadcast_rgb_property;
|
|
|
|
if (prop == NULL) {
|
|
|
|
prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
|
|
|
|
"Broadcast RGB",
|
|
|
|
ARRAY_SIZE(broadcast_rgb_names));
|
|
|
|
if (prop == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(broadcast_rgb_names); i++)
|
|
|
|
drm_property_add_enum(prop, i, i, broadcast_rgb_names[i]);
|
|
|
|
|
|
|
|
dev_priv->broadcast_rgb_property = prop;
|
|
|
|
}
|
|
|
|
|
2012-10-12 09:38:23 +08:00
|
|
|
drm_object_attach_property(&connector->base, prop, 0);
|
2012-08-08 21:54:41 +08:00
|
|
|
}
|
|
|
|
|
2012-05-11 18:30:53 +08:00
|
|
|
/* Cedarview */
|
|
|
|
static const struct psb_offset cdv_regmap[2] = {
|
|
|
|
{
|
|
|
|
.fp0 = FPA0,
|
|
|
|
.fp1 = FPA1,
|
|
|
|
.cntr = DSPACNTR,
|
|
|
|
.conf = PIPEACONF,
|
|
|
|
.src = PIPEASRC,
|
|
|
|
.dpll = DPLL_A,
|
2012-05-11 18:31:22 +08:00
|
|
|
.dpll_md = DPLL_A_MD,
|
2012-05-11 18:30:53 +08:00
|
|
|
.htotal = HTOTAL_A,
|
|
|
|
.hblank = HBLANK_A,
|
|
|
|
.hsync = HSYNC_A,
|
|
|
|
.vtotal = VTOTAL_A,
|
|
|
|
.vblank = VBLANK_A,
|
|
|
|
.vsync = VSYNC_A,
|
|
|
|
.stride = DSPASTRIDE,
|
|
|
|
.size = DSPASIZE,
|
|
|
|
.pos = DSPAPOS,
|
|
|
|
.base = DSPABASE,
|
|
|
|
.surf = DSPASURF,
|
|
|
|
.addr = DSPABASE,
|
|
|
|
.status = PIPEASTAT,
|
|
|
|
.linoff = DSPALINOFF,
|
|
|
|
.tileoff = DSPATILEOFF,
|
|
|
|
.palette = PALETTE_A,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.fp0 = FPB0,
|
|
|
|
.fp1 = FPB1,
|
|
|
|
.cntr = DSPBCNTR,
|
|
|
|
.conf = PIPEBCONF,
|
|
|
|
.src = PIPEBSRC,
|
|
|
|
.dpll = DPLL_B,
|
2012-05-11 18:31:22 +08:00
|
|
|
.dpll_md = DPLL_B_MD,
|
2012-05-11 18:30:53 +08:00
|
|
|
.htotal = HTOTAL_B,
|
|
|
|
.hblank = HBLANK_B,
|
|
|
|
.hsync = HSYNC_B,
|
|
|
|
.vtotal = VTOTAL_B,
|
|
|
|
.vblank = VBLANK_B,
|
|
|
|
.vsync = VSYNC_B,
|
|
|
|
.stride = DSPBSTRIDE,
|
|
|
|
.size = DSPBSIZE,
|
|
|
|
.pos = DSPBPOS,
|
|
|
|
.base = DSPBBASE,
|
|
|
|
.surf = DSPBSURF,
|
|
|
|
.addr = DSPBBASE,
|
|
|
|
.status = PIPEBSTAT,
|
|
|
|
.linoff = DSPBLINOFF,
|
|
|
|
.tileoff = DSPBTILEOFF,
|
|
|
|
.palette = PALETTE_B,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-11-04 02:22:37 +08:00
|
|
|
static int cdv_chip_setup(struct drm_device *dev)
|
|
|
|
{
|
2012-04-25 21:38:32 +08:00
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
INIT_WORK(&dev_priv->hotplug_work, cdv_hotplug_work_func);
|
2012-05-11 18:33:03 +08:00
|
|
|
|
|
|
|
if (pci_enable_msi(dev->pdev))
|
|
|
|
dev_warn(dev->dev, "Enabling MSI failed!\n");
|
2012-05-11 18:30:53 +08:00
|
|
|
dev_priv->regmap = cdv_regmap;
|
2014-03-12 05:53:43 +08:00
|
|
|
gma_get_core_freq(dev);
|
2012-05-03 22:06:18 +08:00
|
|
|
psb_intel_opregion_init(dev);
|
2011-11-04 02:22:37 +08:00
|
|
|
psb_intel_init_bios(dev);
|
2012-04-25 21:38:32 +08:00
|
|
|
cdv_hotplug_enable(dev, false);
|
2011-11-04 02:22:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CDV is much like Poulsbo but has MID like SGX offsets and PM */
|
|
|
|
|
|
|
|
const struct psb_ops cdv_chip_ops = {
|
2011-12-29 22:37:03 +08:00
|
|
|
.name = "GMA3600/3650",
|
2011-11-04 02:22:37 +08:00
|
|
|
.accel_2d = 0,
|
|
|
|
.pipes = 2,
|
2011-12-29 22:37:03 +08:00
|
|
|
.crtcs = 2,
|
2012-04-25 21:38:07 +08:00
|
|
|
.hdmi_mask = (1 << 0) | (1 << 1),
|
|
|
|
.lvds_mask = (1 << 1),
|
2013-09-16 23:54:54 +08:00
|
|
|
.sdvo_mask = (1 << 0),
|
2012-05-21 22:27:30 +08:00
|
|
|
.cursor_needs_phys = 0,
|
2011-11-04 02:22:37 +08:00
|
|
|
.sgx_offset = MRST_SGX_OFFSET,
|
|
|
|
.chip_setup = cdv_chip_setup,
|
2012-04-25 21:38:07 +08:00
|
|
|
.errata = cdv_errata,
|
2011-11-04 02:22:37 +08:00
|
|
|
|
|
|
|
.crtc_helper = &cdv_intel_helper_funcs,
|
|
|
|
.crtc_funcs = &cdv_intel_crtc_funcs,
|
2013-07-01 07:42:16 +08:00
|
|
|
.clock_funcs = &cdv_clock_funcs,
|
2011-11-04 02:22:37 +08:00
|
|
|
|
|
|
|
.output_init = cdv_output_init,
|
2012-04-25 21:38:32 +08:00
|
|
|
.hotplug = cdv_hotplug_event,
|
|
|
|
.hotplug_enable = cdv_hotplug_enable,
|
2011-11-04 02:22:37 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
|
|
|
|
.backlight_init = cdv_backlight_init,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
.init_pm = cdv_init_pm,
|
|
|
|
.save_regs = cdv_save_display_registers,
|
|
|
|
.restore_regs = cdv_restore_display_registers,
|
2015-12-04 16:45:53 +08:00
|
|
|
.save_crtc = gma_crtc_save,
|
|
|
|
.restore_crtc = gma_crtc_restore,
|
2011-11-04 02:22:37 +08:00
|
|
|
.power_down = cdv_power_down,
|
|
|
|
.power_up = cdv_power_up,
|
2013-08-15 01:14:17 +08:00
|
|
|
.update_wm = cdv_update_wm,
|
2013-08-15 06:54:44 +08:00
|
|
|
.disable_sr = cdv_disable_sr,
|
2011-11-04 02:22:37 +08:00
|
|
|
};
|