2011-11-03 19:22:04 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* Copyright (c) 2007-2011, Intel Corporation.
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Copyright (c) 2008, Tungsten Graphics, Inc. Cedar Park, TX., USA.
|
|
|
|
* 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 <drm/drmP.h>
|
|
|
|
#include <drm/drm.h>
|
|
|
|
#include "psb_drv.h"
|
|
|
|
#include "framebuffer.h"
|
|
|
|
#include "psb_reg.h"
|
|
|
|
#include "psb_intel_reg.h"
|
|
|
|
#include "intel_bios.h"
|
|
|
|
#include "mid_bios.h"
|
|
|
|
#include <drm/drm_pciids.h>
|
|
|
|
#include "power.h"
|
|
|
|
#include <linux/cpu.h>
|
|
|
|
#include <linux/notifier.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/pm_runtime.h>
|
|
|
|
#include <acpi/video.h>
|
2011-11-16 13:13:30 +01:00
|
|
|
#include <linux/module.h>
|
2011-11-03 19:22:04 +01:00
|
|
|
|
|
|
|
static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
|
|
|
|
|
|
|
|
static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
|
|
|
|
{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
|
|
|
|
{ 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
|
2011-12-19 22:06:35 +01:00
|
|
|
#if defined(CONFIG_DRM_GMA600)
|
2011-11-03 19:22:04 +01:00
|
|
|
{ 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
|
|
|
|
{ 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
|
|
|
|
{ 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
|
|
|
|
{ 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
|
|
|
|
{ 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
|
|
|
|
{ 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
|
|
|
|
{ 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
|
|
|
|
{ 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
|
2011-12-28 16:16:07 +01:00
|
|
|
/* Atom E620 */
|
|
|
|
{ 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
|
2011-11-03 19:22:04 +01:00
|
|
|
#endif
|
2012-03-08 17:02:20 +01:00
|
|
|
#if defined(CONFIG_DRM_MEDFIELD)
|
|
|
|
{0x8086, 0x0130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
|
|
|
|
{0x8086, 0x0131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
|
|
|
|
{0x8086, 0x0132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
|
|
|
|
{0x8086, 0x0133, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
|
|
|
|
{0x8086, 0x0134, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
|
|
|
|
{0x8086, 0x0135, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
|
|
|
|
{0x8086, 0x0136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
|
|
|
|
{0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
|
|
|
|
#endif
|
2011-12-29 15:37:03 +01:00
|
|
|
#if defined(CONFIG_DRM_GMA3600)
|
2011-11-03 19:22:04 +01:00
|
|
|
{ 0x8086, 0x0be0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0be1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0be2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0be3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0be4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0be5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0be6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0be7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
2012-05-11 12:32:46 +02:00
|
|
|
{ 0x8086, 0x0be8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0be9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0bea, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0beb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0bec, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0bed, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0bee, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
|
|
|
{ 0x8086, 0x0bef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
|
2011-11-03 19:22:04 +01:00
|
|
|
#endif
|
2012-03-08 17:09:19 +01:00
|
|
|
{ 0, }
|
2011-11-03 19:22:04 +01:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, pciidlist);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Standard IOCTLs.
|
|
|
|
*/
|
2013-08-02 19:27:49 +02:00
|
|
|
static const struct drm_ioctl_desc psb_ioctls[] = {
|
2011-11-03 19:22:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static void psb_lastclose(struct drm_device *dev)
|
|
|
|
{
|
2012-12-02 21:55:41 +01:00
|
|
|
int ret;
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
struct psb_fbdev *fbdev = dev_priv->fbdev;
|
|
|
|
|
2012-12-02 01:33:17 +01:00
|
|
|
drm_modeset_lock_all(dev);
|
2012-12-02 21:55:41 +01:00
|
|
|
ret = drm_fb_helper_restore_fbdev_mode(&fbdev->psb_fb_helper);
|
|
|
|
if (ret)
|
|
|
|
DRM_DEBUG("failed to restore crtc mode\n");
|
2012-12-02 01:33:17 +01:00
|
|
|
drm_modeset_unlock_all(dev);
|
2012-12-02 21:55:41 +01:00
|
|
|
|
2011-11-03 19:22:04 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int psb_do_init(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
struct psb_gtt *pg = &dev_priv->gtt;
|
|
|
|
|
|
|
|
uint32_t stolen_gtt;
|
|
|
|
|
|
|
|
if (pg->mmu_gatt_start & 0x0FFFFFFF) {
|
|
|
|
dev_err(dev->dev, "Gatt must be 256M aligned. This is a bug.\n");
|
2014-03-15 22:12:16 +01:00
|
|
|
return -EINVAL;
|
2011-11-03 19:22:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stolen_gtt = (pg->stolen_size >> PAGE_SHIFT) * 4;
|
|
|
|
stolen_gtt = (stolen_gtt + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
|
|
|
stolen_gtt =
|
|
|
|
(stolen_gtt < pg->gtt_pages) ? stolen_gtt : pg->gtt_pages;
|
|
|
|
|
|
|
|
dev_priv->gatt_free_offset = pg->mmu_gatt_start +
|
|
|
|
(stolen_gtt << PAGE_SHIFT) * 1024;
|
|
|
|
|
|
|
|
spin_lock_init(&dev_priv->irqmask_lock);
|
2011-11-29 23:27:10 +01:00
|
|
|
spin_lock_init(&dev_priv->lock_2d);
|
2011-11-03 19:22:04 +01:00
|
|
|
|
|
|
|
PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK0);
|
|
|
|
PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK1);
|
|
|
|
PSB_RSGX32(PSB_CR_BIF_BANK1);
|
2014-01-04 22:11:17 +01:00
|
|
|
|
|
|
|
/* Do not bypass any MMU access, let them pagefault instead */
|
|
|
|
PSB_WSGX32((PSB_RSGX32(PSB_CR_BIF_CTRL) & ~_PSB_MMU_ER_MASK),
|
|
|
|
PSB_CR_BIF_CTRL);
|
|
|
|
PSB_RSGX32(PSB_CR_BIF_CTRL);
|
|
|
|
|
2011-11-03 19:22:04 +01:00
|
|
|
psb_spank(dev_priv);
|
|
|
|
|
|
|
|
/* mmu_gatt ?? */
|
|
|
|
PSB_WSGX32(pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
|
2014-01-04 22:11:17 +01:00
|
|
|
PSB_RSGX32(PSB_CR_BIF_TWOD_REQ_BASE); /* Post */
|
|
|
|
|
2011-11-03 19:22:04 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int psb_driver_unload(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
|
|
|
|
/* Kill vblank etc here */
|
|
|
|
|
|
|
|
|
|
|
|
if (dev_priv) {
|
2012-05-14 13:04:00 +02:00
|
|
|
if (dev_priv->backlight_device)
|
|
|
|
gma_backlight_exit(dev);
|
|
|
|
psb_modeset_cleanup(dev);
|
2011-11-03 19:22:04 +01:00
|
|
|
|
|
|
|
if (dev_priv->ops->chip_teardown)
|
|
|
|
dev_priv->ops->chip_teardown(dev);
|
2012-05-14 13:03:34 +02:00
|
|
|
|
|
|
|
psb_intel_opregion_fini(dev);
|
2011-11-03 19:22:04 +01:00
|
|
|
|
|
|
|
if (dev_priv->pf_pd) {
|
|
|
|
psb_mmu_free_pagedir(dev_priv->pf_pd);
|
|
|
|
dev_priv->pf_pd = NULL;
|
|
|
|
}
|
|
|
|
if (dev_priv->mmu) {
|
|
|
|
struct psb_gtt *pg = &dev_priv->gtt;
|
|
|
|
|
|
|
|
down_read(&pg->sem);
|
|
|
|
psb_mmu_remove_pfn_sequence(
|
|
|
|
psb_mmu_get_default_pd
|
|
|
|
(dev_priv->mmu),
|
|
|
|
pg->mmu_gatt_start,
|
|
|
|
dev_priv->vram_stolen_size >> PAGE_SHIFT);
|
|
|
|
up_read(&pg->sem);
|
|
|
|
psb_mmu_driver_takedown(dev_priv->mmu);
|
|
|
|
dev_priv->mmu = NULL;
|
|
|
|
}
|
|
|
|
psb_gtt_takedown(dev);
|
|
|
|
if (dev_priv->scratch_page) {
|
2012-04-25 15:36:13 +02:00
|
|
|
set_pages_wb(dev_priv->scratch_page, 1);
|
2011-11-03 19:22:04 +01:00
|
|
|
__free_page(dev_priv->scratch_page);
|
|
|
|
dev_priv->scratch_page = NULL;
|
|
|
|
}
|
|
|
|
if (dev_priv->vdc_reg) {
|
|
|
|
iounmap(dev_priv->vdc_reg);
|
|
|
|
dev_priv->vdc_reg = NULL;
|
|
|
|
}
|
|
|
|
if (dev_priv->sgx_reg) {
|
|
|
|
iounmap(dev_priv->sgx_reg);
|
|
|
|
dev_priv->sgx_reg = NULL;
|
|
|
|
}
|
2013-09-16 18:02:40 +02:00
|
|
|
if (dev_priv->aux_reg) {
|
|
|
|
iounmap(dev_priv->aux_reg);
|
|
|
|
dev_priv->aux_reg = NULL;
|
|
|
|
}
|
|
|
|
if (dev_priv->aux_pdev)
|
|
|
|
pci_dev_put(dev_priv->aux_pdev);
|
2011-11-03 19:22:04 +01:00
|
|
|
|
2012-05-14 13:04:00 +02:00
|
|
|
/* Destroy VBT data */
|
|
|
|
psb_intel_destroy_bios(dev);
|
|
|
|
|
2011-11-03 19:22:04 +01:00
|
|
|
kfree(dev_priv);
|
|
|
|
dev->dev_private = NULL;
|
|
|
|
}
|
|
|
|
gma_power_uninit(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
|
|
|
|
{
|
|
|
|
struct drm_psb_private *dev_priv;
|
2013-09-16 18:02:40 +02:00
|
|
|
unsigned long resource_start, resource_len;
|
2011-11-03 19:22:04 +01:00
|
|
|
unsigned long irqflags;
|
|
|
|
int ret = -ENOMEM;
|
|
|
|
struct drm_connector *connector;
|
2013-07-22 17:45:26 +02:00
|
|
|
struct gma_encoder *gma_encoder;
|
2014-01-04 22:11:17 +01:00
|
|
|
struct psb_gtt *pg;
|
2011-11-03 19:22:04 +01:00
|
|
|
|
|
|
|
dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
|
|
|
|
if (dev_priv == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
dev_priv->ops = (struct psb_ops *)chipset;
|
|
|
|
dev_priv->dev = dev;
|
|
|
|
dev->dev_private = (void *) dev_priv;
|
|
|
|
|
2014-01-04 22:11:17 +01:00
|
|
|
pg = &dev_priv->gtt;
|
|
|
|
|
2011-12-19 12:15:29 +01:00
|
|
|
pci_set_master(dev->pdev);
|
|
|
|
|
2011-11-03 19:22:04 +01:00
|
|
|
dev_priv->num_pipe = dev_priv->ops->pipes;
|
|
|
|
|
|
|
|
resource_start = pci_resource_start(dev->pdev, PSB_MMIO_RESOURCE);
|
|
|
|
|
|
|
|
dev_priv->vdc_reg =
|
|
|
|
ioremap(resource_start + PSB_VDC_OFFSET, PSB_VDC_SIZE);
|
|
|
|
if (!dev_priv->vdc_reg)
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
dev_priv->sgx_reg = ioremap(resource_start + dev_priv->ops->sgx_offset,
|
|
|
|
PSB_SGX_SIZE);
|
|
|
|
if (!dev_priv->sgx_reg)
|
|
|
|
goto out_err;
|
|
|
|
|
2013-09-16 18:02:40 +02:00
|
|
|
if (IS_MRST(dev)) {
|
|
|
|
dev_priv->aux_pdev = pci_get_bus_and_slot(0, PCI_DEVFN(3, 0));
|
|
|
|
|
|
|
|
if (dev_priv->aux_pdev) {
|
|
|
|
resource_start = pci_resource_start(dev_priv->aux_pdev,
|
|
|
|
PSB_AUX_RESOURCE);
|
|
|
|
resource_len = pci_resource_len(dev_priv->aux_pdev,
|
|
|
|
PSB_AUX_RESOURCE);
|
|
|
|
dev_priv->aux_reg = ioremap_nocache(resource_start,
|
|
|
|
resource_len);
|
|
|
|
if (!dev_priv->aux_reg)
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
DRM_DEBUG_KMS("Found aux vdc");
|
|
|
|
} else {
|
|
|
|
/* Couldn't find the aux vdc so map to primary vdc */
|
|
|
|
dev_priv->aux_reg = dev_priv->vdc_reg;
|
|
|
|
DRM_DEBUG_KMS("Couldn't find aux pci device");
|
|
|
|
}
|
|
|
|
dev_priv->gmbus_reg = dev_priv->aux_reg;
|
|
|
|
} else {
|
|
|
|
dev_priv->gmbus_reg = dev_priv->vdc_reg;
|
|
|
|
}
|
|
|
|
|
2012-05-03 16:06:18 +02:00
|
|
|
psb_intel_opregion_setup(dev);
|
|
|
|
|
2011-11-03 19:22:04 +01:00
|
|
|
ret = dev_priv->ops->chip_setup(dev);
|
|
|
|
if (ret)
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
/* Init OSPM support */
|
|
|
|
gma_power_init(dev);
|
|
|
|
|
|
|
|
ret = -ENOMEM;
|
|
|
|
|
|
|
|
dev_priv->scratch_page = alloc_page(GFP_DMA32 | __GFP_ZERO);
|
|
|
|
if (!dev_priv->scratch_page)
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
set_pages_uc(dev_priv->scratch_page, 1);
|
|
|
|
|
|
|
|
ret = psb_gtt_init(dev, 0);
|
|
|
|
if (ret)
|
|
|
|
goto out_err;
|
|
|
|
|
2014-01-05 00:27:51 +01:00
|
|
|
dev_priv->mmu = psb_mmu_driver_init(dev, 1, 0, 0);
|
2011-11-03 19:22:04 +01:00
|
|
|
if (!dev_priv->mmu)
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
dev_priv->pf_pd = psb_mmu_alloc_pd(dev_priv->mmu, 1, 0);
|
|
|
|
if (!dev_priv->pf_pd)
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
ret = psb_do_init(dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2014-01-04 22:11:17 +01:00
|
|
|
/* Add stolen memory to SGX MMU */
|
|
|
|
down_read(&pg->sem);
|
|
|
|
ret = psb_mmu_insert_pfn_sequence(psb_mmu_get_default_pd(dev_priv->mmu),
|
|
|
|
dev_priv->stolen_base >> PAGE_SHIFT,
|
|
|
|
pg->gatt_start,
|
|
|
|
pg->stolen_size >> PAGE_SHIFT, 0);
|
|
|
|
up_read(&pg->sem);
|
|
|
|
|
|
|
|
psb_mmu_set_pd_context(psb_mmu_get_default_pd(dev_priv->mmu), 0);
|
|
|
|
psb_mmu_set_pd_context(dev_priv->pf_pd, 1);
|
|
|
|
|
2011-11-03 19:22:04 +01:00
|
|
|
PSB_WSGX32(0x20000000, PSB_CR_PDS_EXEC_BASE);
|
|
|
|
PSB_WSGX32(0x30000000, PSB_CR_BIF_3D_REQ_BASE);
|
|
|
|
|
2012-05-03 16:06:18 +02:00
|
|
|
acpi_video_register();
|
2011-11-03 19:22:04 +01:00
|
|
|
|
|
|
|
ret = drm_vblank_init(dev, dev_priv->num_pipe);
|
|
|
|
if (ret)
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Install interrupt handlers prior to powering off SGX or else we will
|
|
|
|
* crash.
|
|
|
|
*/
|
|
|
|
dev_priv->vdc_irq_mask = 0;
|
|
|
|
dev_priv->pipestat[0] = 0;
|
|
|
|
dev_priv->pipestat[1] = 0;
|
|
|
|
dev_priv->pipestat[2] = 0;
|
|
|
|
spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
|
|
|
|
PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM);
|
|
|
|
PSB_WVDC32(0x00000000, PSB_INT_ENABLE_R);
|
|
|
|
PSB_WVDC32(0xFFFFFFFF, PSB_INT_MASK_R);
|
|
|
|
spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags);
|
2012-05-11 12:33:17 +02:00
|
|
|
|
|
|
|
drm_irq_install(dev);
|
2011-11-03 19:22:04 +01:00
|
|
|
|
2013-10-04 13:53:33 +02:00
|
|
|
dev->vblank_disable_allowed = true;
|
2011-11-03 19:22:04 +01:00
|
|
|
|
|
|
|
dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
|
|
|
|
|
|
|
|
dev->driver->get_vblank_counter = psb_get_vblank_counter;
|
|
|
|
|
2011-12-29 15:38:07 +01:00
|
|
|
psb_modeset_init(dev);
|
|
|
|
psb_fbdev_init(dev);
|
|
|
|
drm_kms_helper_poll_init(dev);
|
2011-11-03 19:22:04 +01:00
|
|
|
|
|
|
|
/* Only add backlight support if we have LVDS output */
|
|
|
|
list_for_each_entry(connector, &dev->mode_config.connector_list,
|
|
|
|
head) {
|
2013-07-22 17:45:26 +02:00
|
|
|
gma_encoder = gma_attached_encoder(connector);
|
2011-11-03 19:22:04 +01:00
|
|
|
|
2013-07-22 17:45:26 +02:00
|
|
|
switch (gma_encoder->type) {
|
2011-11-03 19:22:04 +01:00
|
|
|
case INTEL_OUTPUT_LVDS:
|
|
|
|
case INTEL_OUTPUT_MIPI:
|
|
|
|
ret = gma_backlight_init(dev);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2012-07-16 18:52:45 +02:00
|
|
|
psb_intel_opregion_enable_asle(dev);
|
2011-11-03 19:22:04 +01:00
|
|
|
#if 0
|
|
|
|
/*enable runtime pm at last*/
|
|
|
|
pm_runtime_enable(&dev->pdev->dev);
|
|
|
|
pm_runtime_set_active(&dev->pdev->dev);
|
|
|
|
#endif
|
|
|
|
/*Intel drm driver load is done, continue doing pvr load*/
|
|
|
|
return 0;
|
|
|
|
out_err:
|
|
|
|
psb_driver_unload(dev);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-03-08 17:08:45 +01:00
|
|
|
static int psb_driver_device_is_agp(struct drm_device *dev)
|
2011-11-03 19:22:04 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void get_brightness(struct backlight_device *bd)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
|
|
|
|
if (bd) {
|
|
|
|
bd->props.brightness = bd->ops->get_brightness(bd);
|
|
|
|
backlight_update_status(bd);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int psb_driver_open(struct drm_device *dev, struct drm_file *priv)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void psb_driver_close(struct drm_device *dev, struct drm_file *priv)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
|
|
|
struct drm_file *file_priv = filp->private_data;
|
|
|
|
struct drm_device *dev = file_priv->minor->dev;
|
|
|
|
struct drm_psb_private *dev_priv = dev->dev_private;
|
|
|
|
static unsigned int runtime_allowed;
|
|
|
|
|
|
|
|
if (runtime_allowed == 1 && dev_priv->is_lvds_on) {
|
|
|
|
runtime_allowed++;
|
|
|
|
pm_runtime_allow(&dev->pdev->dev);
|
|
|
|
dev_priv->rpm_enabled = 1;
|
|
|
|
}
|
|
|
|
return drm_ioctl(filp, cmd, arg);
|
|
|
|
/* FIXME: do we need to wrap the other side of this */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* When a client dies:
|
|
|
|
* - Check for and clean up flipped page state
|
|
|
|
*/
|
2012-03-08 17:08:45 +01:00
|
|
|
static void psb_driver_preclose(struct drm_device *dev, struct drm_file *priv)
|
2011-11-03 19:22:04 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void psb_remove(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
|
|
|
drm_put_dev(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct dev_pm_ops psb_pm_ops = {
|
|
|
|
.resume = gma_power_resume,
|
|
|
|
.suspend = gma_power_suspend,
|
2013-04-06 00:45:22 +02:00
|
|
|
.thaw = gma_power_thaw,
|
|
|
|
.freeze = gma_power_freeze,
|
|
|
|
.restore = gma_power_restore,
|
2011-11-03 19:22:04 +01:00
|
|
|
.runtime_suspend = psb_runtime_suspend,
|
|
|
|
.runtime_resume = psb_runtime_resume,
|
|
|
|
.runtime_idle = psb_runtime_idle,
|
|
|
|
};
|
|
|
|
|
2012-05-17 13:27:22 +02:00
|
|
|
static const struct vm_operations_struct psb_gem_vm_ops = {
|
2011-11-03 19:22:04 +01:00
|
|
|
.fault = psb_gem_fault,
|
|
|
|
.open = drm_gem_vm_open,
|
|
|
|
.close = drm_gem_vm_close,
|
|
|
|
};
|
|
|
|
|
2011-11-27 17:08:33 +01:00
|
|
|
static const struct file_operations psb_gem_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = drm_open,
|
|
|
|
.release = drm_release,
|
|
|
|
.unlocked_ioctl = psb_unlocked_ioctl,
|
|
|
|
.mmap = drm_gem_mmap,
|
|
|
|
.poll = drm_poll,
|
|
|
|
.read = drm_read,
|
|
|
|
};
|
|
|
|
|
2011-11-03 19:22:04 +01:00
|
|
|
static struct drm_driver driver = {
|
|
|
|
.driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | \
|
2013-08-08 15:41:25 +02:00
|
|
|
DRIVER_MODESET | DRIVER_GEM ,
|
2011-11-03 19:22:04 +01:00
|
|
|
.load = psb_driver_load,
|
|
|
|
.unload = psb_driver_unload,
|
|
|
|
|
|
|
|
.ioctls = psb_ioctls,
|
|
|
|
.num_ioctls = DRM_ARRAY_SIZE(psb_ioctls),
|
|
|
|
.device_is_agp = psb_driver_device_is_agp,
|
|
|
|
.irq_preinstall = psb_irq_preinstall,
|
|
|
|
.irq_postinstall = psb_irq_postinstall,
|
|
|
|
.irq_uninstall = psb_irq_uninstall,
|
|
|
|
.irq_handler = psb_irq_handler,
|
|
|
|
.enable_vblank = psb_enable_vblank,
|
|
|
|
.disable_vblank = psb_disable_vblank,
|
|
|
|
.get_vblank_counter = psb_get_vblank_counter,
|
|
|
|
.lastclose = psb_lastclose,
|
|
|
|
.open = psb_driver_open,
|
|
|
|
.preclose = psb_driver_preclose,
|
|
|
|
.postclose = psb_driver_close,
|
|
|
|
|
|
|
|
.gem_free_object = psb_gem_free_object,
|
|
|
|
.gem_vm_ops = &psb_gem_vm_ops,
|
|
|
|
.dumb_create = psb_gem_dumb_create,
|
|
|
|
.dumb_map_offset = psb_gem_dumb_map_gtt,
|
2013-07-16 09:12:04 +02:00
|
|
|
.dumb_destroy = drm_gem_dumb_destroy,
|
2011-11-27 17:08:33 +01:00
|
|
|
.fops = &psb_gem_fops,
|
2011-11-03 19:22:04 +01:00
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.desc = DRIVER_DESC,
|
|
|
|
.date = PSB_DRM_DRIVER_DATE,
|
|
|
|
.major = PSB_DRM_DRIVER_MAJOR,
|
|
|
|
.minor = PSB_DRM_DRIVER_MINOR,
|
|
|
|
.patchlevel = PSB_DRM_DRIVER_PATCHLEVEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct pci_driver psb_pci_driver = {
|
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.id_table = pciidlist,
|
|
|
|
.probe = psb_probe,
|
|
|
|
.remove = psb_remove,
|
2012-03-08 17:09:19 +01:00
|
|
|
.driver = {
|
|
|
|
.pm = &psb_pm_ops,
|
|
|
|
}
|
2011-11-03 19:22:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|
|
|
{
|
|
|
|
return drm_get_pci_dev(pdev, ent, &driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init psb_init(void)
|
|
|
|
{
|
|
|
|
return drm_pci_init(&driver, &psb_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit psb_exit(void)
|
|
|
|
{
|
|
|
|
drm_pci_exit(&driver, &psb_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
late_initcall(psb_init);
|
|
|
|
module_exit(psb_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Alan Cox <alan@linux.intel.com> and others");
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE("GPL");
|