staging: delete gma500 driver
Greg Kroah-Hartman [Mon, 30 Jan 2012 22:12:59 +0000 (14:12 -0800)]
It's now "properly" merged into the DRM tree in the kernel, so delete
the staging version of the driver as it is far obsolete and broken.

Requested-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

78 files changed:
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/gma500/Kconfig [deleted file]
drivers/staging/gma500/Makefile [deleted file]
drivers/staging/gma500/TODO [deleted file]
drivers/staging/gma500/accel_2d.c [deleted file]
drivers/staging/gma500/backlight.c [deleted file]
drivers/staging/gma500/cdv_device.c [deleted file]
drivers/staging/gma500/cdv_device.h [deleted file]
drivers/staging/gma500/cdv_intel_crt.c [deleted file]
drivers/staging/gma500/cdv_intel_display.c [deleted file]
drivers/staging/gma500/cdv_intel_hdmi.c [deleted file]
drivers/staging/gma500/cdv_intel_lvds.c [deleted file]
drivers/staging/gma500/displays/hdmi.h [deleted file]
drivers/staging/gma500/displays/pyr_cmd.h [deleted file]
drivers/staging/gma500/displays/pyr_vid.h [deleted file]
drivers/staging/gma500/displays/tmd_cmd.h [deleted file]
drivers/staging/gma500/displays/tmd_vid.h [deleted file]
drivers/staging/gma500/displays/tpo_cmd.h [deleted file]
drivers/staging/gma500/displays/tpo_vid.h [deleted file]
drivers/staging/gma500/framebuffer.c [deleted file]
drivers/staging/gma500/framebuffer.h [deleted file]
drivers/staging/gma500/gem.c [deleted file]
drivers/staging/gma500/gem_glue.c [deleted file]
drivers/staging/gma500/gem_glue.h [deleted file]
drivers/staging/gma500/gtt.c [deleted file]
drivers/staging/gma500/gtt.h [deleted file]
drivers/staging/gma500/intel_bios.c [deleted file]
drivers/staging/gma500/intel_bios.h [deleted file]
drivers/staging/gma500/intel_i2c.c [deleted file]
drivers/staging/gma500/intel_opregion.c [deleted file]
drivers/staging/gma500/mdfld_device.c [deleted file]
drivers/staging/gma500/mdfld_dsi_dbi.c [deleted file]
drivers/staging/gma500/mdfld_dsi_dbi.h [deleted file]
drivers/staging/gma500/mdfld_dsi_dbi_dpu.c [deleted file]
drivers/staging/gma500/mdfld_dsi_dbi_dpu.h [deleted file]
drivers/staging/gma500/mdfld_dsi_dpi.c [deleted file]
drivers/staging/gma500/mdfld_dsi_dpi.h [deleted file]
drivers/staging/gma500/mdfld_dsi_output.c [deleted file]
drivers/staging/gma500/mdfld_dsi_output.h [deleted file]
drivers/staging/gma500/mdfld_dsi_pkg_sender.c [deleted file]
drivers/staging/gma500/mdfld_dsi_pkg_sender.h [deleted file]
drivers/staging/gma500/mdfld_intel_display.c [deleted file]
drivers/staging/gma500/mdfld_msic.h [deleted file]
drivers/staging/gma500/mdfld_output.c [deleted file]
drivers/staging/gma500/mdfld_output.h [deleted file]
drivers/staging/gma500/mdfld_pyr_cmd.c [deleted file]
drivers/staging/gma500/mdfld_tmd_vid.c [deleted file]
drivers/staging/gma500/mdfld_tpo_cmd.c [deleted file]
drivers/staging/gma500/mdfld_tpo_vid.c [deleted file]
drivers/staging/gma500/medfield.h [deleted file]
drivers/staging/gma500/mid_bios.c [deleted file]
drivers/staging/gma500/mid_bios.h [deleted file]
drivers/staging/gma500/mmu.c [deleted file]
drivers/staging/gma500/mrst.h [deleted file]
drivers/staging/gma500/mrst_crtc.c [deleted file]
drivers/staging/gma500/mrst_device.c [deleted file]
drivers/staging/gma500/mrst_hdmi.c [deleted file]
drivers/staging/gma500/mrst_hdmi_i2c.c [deleted file]
drivers/staging/gma500/mrst_lvds.c [deleted file]
drivers/staging/gma500/power.c [deleted file]
drivers/staging/gma500/power.h [deleted file]
drivers/staging/gma500/psb_device.c [deleted file]
drivers/staging/gma500/psb_drm.h [deleted file]
drivers/staging/gma500/psb_drv.c [deleted file]
drivers/staging/gma500/psb_drv.h [deleted file]
drivers/staging/gma500/psb_intel_display.c [deleted file]
drivers/staging/gma500/psb_intel_display.h [deleted file]
drivers/staging/gma500/psb_intel_drv.h [deleted file]
drivers/staging/gma500/psb_intel_lvds.c [deleted file]
drivers/staging/gma500/psb_intel_modes.c [deleted file]
drivers/staging/gma500/psb_intel_reg.h [deleted file]
drivers/staging/gma500/psb_intel_sdvo.c [deleted file]
drivers/staging/gma500/psb_intel_sdvo_regs.h [deleted file]
drivers/staging/gma500/psb_irq.c [deleted file]
drivers/staging/gma500/psb_irq.h [deleted file]
drivers/staging/gma500/psb_lid.c [deleted file]
drivers/staging/gma500/psb_reg.h [deleted file]

index 21e2f4b..b31194c 100644 (file)
@@ -120,8 +120,6 @@ source "drivers/staging/cptm1217/Kconfig"
 
 source "drivers/staging/ste_rmi4/Kconfig"
 
-source "drivers/staging/gma500/Kconfig"
-
 source "drivers/staging/mei/Kconfig"
 
 source "drivers/staging/nvec/Kconfig"
index 7c5808d..b5813c4 100644 (file)
@@ -52,7 +52,6 @@ obj-$(CONFIG_FT1000)          += ft1000/
 obj-$(CONFIG_SPEAKUP)          += speakup/
 obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217)      += cptm1217/
 obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4)   += ste_rmi4/
-obj-$(CONFIG_DRM_PSB)          += gma500/
 obj-$(CONFIG_INTEL_MEI)                += mei/
 obj-$(CONFIG_MFD_NVEC)         += nvec/
 obj-$(CONFIG_DRM_OMAP)         += omapdrm/
diff --git a/drivers/staging/gma500/Kconfig b/drivers/staging/gma500/Kconfig
deleted file mode 100644 (file)
index c7a2b3b..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-config DRM_PSB
-       tristate "Intel GMA5/600 KMS Framebuffer"
-       depends on DRM && PCI && X86 && BROKEN
-       select FB_CFB_COPYAREA
-        select FB_CFB_FILLRECT
-        select FB_CFB_IMAGEBLIT
-        select DRM_KMS_HELPER
-        select DRM_TTM
-       help
-         Say yes for an experimental 2D KMS framebuffer driver for the
-         Intel GMA500 ('Poulsbo') and other Intel IMG based graphics
-         devices.
-
-config DRM_PSB_MRST
-       bool "Intel GMA600 support (Experimental)"
-       depends on DRM_PSB
-       help
-         Say yes to include support for GMA600 (Intel Moorestown/Oaktrail)
-         platforms with LVDS ports. HDMI and MIPI are not currently
-         supported.
-
-config DRM_PSB_MFLD
-       bool "Intel Medfield support (Experimental)"
-       depends on DRM_PSB
-       help
-         Say yes to include support for Intel Medfield platforms with MIPI
-         interfaces.
-       
-config DRM_PSB_CDV
-       bool "Intel Cedarview support (Experimental)"
-       depends on DRM_PSB
-       help
-         Say yes to include support for Intel Cedarview platforms
diff --git a/drivers/staging/gma500/Makefile b/drivers/staging/gma500/Makefile
deleted file mode 100644 (file)
index c729868..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-#      KMS driver for the GMA500
-#
-ccflags-y += -Iinclude/drm
-
-psb_gfx-y += gem_glue.o \
-         accel_2d.o \
-         backlight.o \
-         framebuffer.o \
-         gem.o \
-         gtt.o \
-         intel_bios.o \
-         intel_i2c.o \
-         intel_opregion.o \
-         mmu.o \
-         power.o \
-         psb_drv.o \
-         psb_intel_display.o \
-         psb_intel_lvds.o \
-         psb_intel_modes.o \
-         psb_intel_sdvo.o \
-         psb_lid.o \
-         psb_irq.o \
-         psb_device.o \
-         mid_bios.o
-
-psb_gfx-$(CONFIG_DRM_PSB_CDV) +=  cdv_device.o \
-         cdv_intel_crt.o \
-         cdv_intel_display.o \
-         cdv_intel_hdmi.o \
-         cdv_intel_lvds.o
-
-psb_gfx-$(CONFIG_DRM_PSB_MRST) += mrst_device.o \
-         mrst_crtc.o \
-         mrst_lvds.o \
-         mrst_hdmi.o \
-         mrst_hdmi_i2c.o
-
-psb_gfx-$(CONFIG_DRM_PSB_MFLD) += mdfld_device.o \
-         mdfld_output.o \
-         mdfld_pyr_cmd.o \
-         mdfld_tmd_vid.o \
-         mdfld_tpo_cmd.o \
-         mdfld_tpo_vid.o \
-         mdfld_dsi_pkg_sender.o \
-         mdfld_dsi_dpi.o \
-         mdfld_dsi_output.o \
-         mdfld_dsi_dbi.o \
-         mdfld_dsi_dbi_dpu.o \
-         mdfld_intel_display.o
-
-obj-$(CONFIG_DRM_PSB) += psb_gfx.o
diff --git a/drivers/staging/gma500/TODO b/drivers/staging/gma500/TODO
deleted file mode 100644 (file)
index fc83615..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
--      Sort out the power management side. Not important for Poulsbo but
-       matters for Moorestown/Medfield
--      Debug Oaktrail/Moorestown support (single pipe, no BIOS on mrst,
-                                       some other differences)
--      Add 2D acceleration via console and DRM
--      Add scrolling acceleration using the GTT to do remapping on the main
-       framebuffer.
--      HDMI testing
--      Oaktrail HDMI and other features
--      Oaktrail MIPI
--      Medfield needs a lot of further love
-
-As per kernel policy and the in the interest of the safety of various
-kittens there is no support or plans to add hooks for the closed user space
-stuff.
diff --git a/drivers/staging/gma500/accel_2d.c b/drivers/staging/gma500/accel_2d.c
deleted file mode 100644 (file)
index b8f78eb..0000000
+++ /dev/null
@@ -1,414 +0,0 @@
-/**************************************************************************
- * Copyright (c) 2007-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.
- *
- * Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- * develop this driver.
- *
- **************************************************************************/
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/tty.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/fb.h>
-#include <linux/init.h>
-#include <linux/console.h>
-
-#include <drm/drmP.h>
-#include <drm/drm.h>
-#include <drm/drm_crtc.h>
-
-#include "psb_drv.h"
-#include "psb_reg.h"
-#include "framebuffer.h"
-
-/**
- *     psb_spank               -       reset the 2D engine
- *     @dev_priv: our PSB DRM device
- *
- *     Soft reset the graphics engine and then reload the necessary registers.
- *     We use this at initialisation time but it will become relevant for
- *     accelerated X later
- */
-void psb_spank(struct drm_psb_private *dev_priv)
-{
-       PSB_WSGX32(_PSB_CS_RESET_BIF_RESET | _PSB_CS_RESET_DPM_RESET |
-               _PSB_CS_RESET_TA_RESET | _PSB_CS_RESET_USE_RESET |
-               _PSB_CS_RESET_ISP_RESET | _PSB_CS_RESET_TSP_RESET |
-               _PSB_CS_RESET_TWOD_RESET, PSB_CR_SOFT_RESET);
-       PSB_RSGX32(PSB_CR_SOFT_RESET);
-
-       msleep(1);
-
-       PSB_WSGX32(0, PSB_CR_SOFT_RESET);
-       wmb();
-       PSB_WSGX32(PSB_RSGX32(PSB_CR_BIF_CTRL) | _PSB_CB_CTRL_CLEAR_FAULT,
-                  PSB_CR_BIF_CTRL);
-       wmb();
-       (void) PSB_RSGX32(PSB_CR_BIF_CTRL);
-
-       msleep(1);
-       PSB_WSGX32(PSB_RSGX32(PSB_CR_BIF_CTRL) & ~_PSB_CB_CTRL_CLEAR_FAULT,
-                  PSB_CR_BIF_CTRL);
-       (void) PSB_RSGX32(PSB_CR_BIF_CTRL);
-       PSB_WSGX32(dev_priv->gtt.gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
-}
-
-/**
- *     psb2_2d_wait_available  -       wait for FIFO room
- *     @dev_priv: our DRM device
- *     @size: size (in dwords) of the command we want to issue
- *
- *     Wait until there is room to load the FIFO with our data. If the
- *     device is not responding then reset it
- */
-static int psb_2d_wait_available(struct drm_psb_private *dev_priv,
-                         unsigned size)
-{
-       uint32_t avail = PSB_RSGX32(PSB_CR_2D_SOCIF);
-       unsigned long t = jiffies + HZ;
-
-       while (avail < size) {
-               avail = PSB_RSGX32(PSB_CR_2D_SOCIF);
-               if (time_after(jiffies, t)) {
-                       psb_spank(dev_priv);
-                       return -EIO;
-               }
-       }
-       return 0;
-}
-
-/**
- *     psb_2d_submit           -       submit a 2D command
- *     @dev_priv: our DRM device
- *     @cmdbuf: command to issue
- *     @size: length (in dwords)
- *
- *     Issue one or more 2D commands to the accelerator. This needs to be
- *     serialized later when we add the GEM interfaces for acceleration
- */
-static int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf,
-                                                               unsigned size)
-{
-       int ret = 0;
-       int i;
-       unsigned submit_size;
-       unsigned long flags;
-
-       spin_lock_irqsave(&dev_priv->lock_2d, flags);
-       while (size > 0) {
-               submit_size = (size < 0x60) ? size : 0x60;
-               size -= submit_size;
-               ret = psb_2d_wait_available(dev_priv, submit_size);
-               if (ret)
-                       break;
-
-               submit_size <<= 2;
-
-               for (i = 0; i < submit_size; i += 4)
-                       PSB_WSGX32(*cmdbuf++, PSB_SGX_2D_SLAVE_PORT + i);
-
-               (void)PSB_RSGX32(PSB_SGX_2D_SLAVE_PORT + i - 4);
-       }
-       spin_unlock_irqrestore(&dev_priv->lock_2d, flags);
-       return ret;
-}
-
-
-/**
- *     psb_accel_2d_copy_direction     -       compute blit order
- *     @xdir: X direction of move
- *     @ydir: Y direction of move
- *
- *     Compute the correct order setings to ensure that an overlapping blit
- *     correctly copies all the pixels.
- */
-static u32 psb_accel_2d_copy_direction(int xdir, int ydir)
-{
-       if (xdir < 0)
-               return (ydir < 0) ? PSB_2D_COPYORDER_BR2TL :
-                                               PSB_2D_COPYORDER_TR2BL;
-       else
-               return (ydir < 0) ? PSB_2D_COPYORDER_BL2TR :
-                                               PSB_2D_COPYORDER_TL2BR;
-}
-
-/**
- *     psb_accel_2d_copy               -       accelerated 2D copy
- *     @dev_priv: our DRM device
- *     @src_offset in bytes
- *     @src_stride in bytes
- *     @src_format psb 2D format defines
- *     @dst_offset in bytes
- *     @dst_stride in bytes
- *     @dst_format psb 2D format defines
- *     @src_x offset in pixels
- *     @src_y offset in pixels
- *     @dst_x offset in pixels
- *     @dst_y offset in pixels
- *     @size_x of the copied area
- *     @size_y of the copied area
- *
- *     Format and issue a 2D accelerated copy command.
- */
-static int psb_accel_2d_copy(struct drm_psb_private *dev_priv,
-                            uint32_t src_offset, uint32_t src_stride,
-                            uint32_t src_format, uint32_t dst_offset,
-                            uint32_t dst_stride, uint32_t dst_format,
-                            uint16_t src_x, uint16_t src_y,
-                            uint16_t dst_x, uint16_t dst_y,
-                            uint16_t size_x, uint16_t size_y)
-{
-       uint32_t blit_cmd;
-       uint32_t buffer[10];
-       uint32_t *buf;
-       uint32_t direction;
-
-       buf = buffer;
-
-       direction =
-           psb_accel_2d_copy_direction(src_x - dst_x, src_y - dst_y);
-
-       if (direction == PSB_2D_COPYORDER_BR2TL ||
-           direction == PSB_2D_COPYORDER_TR2BL) {
-               src_x += size_x - 1;
-               dst_x += size_x - 1;
-       }
-       if (direction == PSB_2D_COPYORDER_BR2TL ||
-           direction == PSB_2D_COPYORDER_BL2TR) {
-               src_y += size_y - 1;
-               dst_y += size_y - 1;
-       }
-
-       blit_cmd =
-           PSB_2D_BLIT_BH |
-           PSB_2D_ROT_NONE |
-           PSB_2D_DSTCK_DISABLE |
-           PSB_2D_SRCCK_DISABLE |
-           PSB_2D_USE_PAT | PSB_2D_ROP3_SRCCOPY | direction;
-
-       *buf++ = PSB_2D_FENCE_BH;
-       *buf++ =
-           PSB_2D_DST_SURF_BH | dst_format | (dst_stride <<
-                                              PSB_2D_DST_STRIDE_SHIFT);
-       *buf++ = dst_offset;
-       *buf++ =
-           PSB_2D_SRC_SURF_BH | src_format | (src_stride <<
-                                              PSB_2D_SRC_STRIDE_SHIFT);
-       *buf++ = src_offset;
-       *buf++ =
-           PSB_2D_SRC_OFF_BH | (src_x << PSB_2D_SRCOFF_XSTART_SHIFT) |
-           (src_y << PSB_2D_SRCOFF_YSTART_SHIFT);
-       *buf++ = blit_cmd;
-       *buf++ =
-           (dst_x << PSB_2D_DST_XSTART_SHIFT) | (dst_y <<
-                                                 PSB_2D_DST_YSTART_SHIFT);
-       *buf++ =
-           (size_x << PSB_2D_DST_XSIZE_SHIFT) | (size_y <<
-                                                 PSB_2D_DST_YSIZE_SHIFT);
-       *buf++ = PSB_2D_FLUSH_BH;
-
-       return psbfb_2d_submit(dev_priv, buffer, buf - buffer);
-}
-
-/**
- *     psbfb_copyarea_accel    -       copyarea acceleration for /dev/fb
- *     @info: our framebuffer
- *     @a: copyarea parameters from the framebuffer core
- *
- *     Perform a 2D copy via the accelerator
- */
-static void psbfb_copyarea_accel(struct fb_info *info,
-                                const struct fb_copyarea *a)
-{
-       struct psb_fbdev *fbdev = info->par;
-       struct psb_framebuffer *psbfb = &fbdev->pfb;
-       struct drm_device *dev = psbfb->base.dev;
-       struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       uint32_t offset;
-       uint32_t stride;
-       uint32_t src_format;
-       uint32_t dst_format;
-
-       if (!fb)
-               return;
-
-       offset = psbfb->gtt->offset;
-       stride = fb->pitches[0];
-
-       switch (fb->depth) {
-       case 8:
-               src_format = PSB_2D_SRC_332RGB;
-               dst_format = PSB_2D_DST_332RGB;
-               break;
-       case 15:
-               src_format = PSB_2D_SRC_555RGB;
-               dst_format = PSB_2D_DST_555RGB;
-               break;
-       case 16:
-               src_format = PSB_2D_SRC_565RGB;
-               dst_format = PSB_2D_DST_565RGB;
-               break;
-       case 24:
-       case 32:
-               /* this is wrong but since we don't do blending its okay */
-               src_format = PSB_2D_SRC_8888ARGB;
-               dst_format = PSB_2D_DST_8888ARGB;
-               break;
-       default:
-               /* software fallback */
-               cfb_copyarea(info, a);
-               return;
-       }
-
-       if (!gma_power_begin(dev, false)) {
-               cfb_copyarea(info, a);
-               return;
-       }
-       psb_accel_2d_copy(dev_priv,
-                         offset, stride, src_format,
-                         offset, stride, dst_format,
-                         a->sx, a->sy, a->dx, a->dy, a->width, a->height);
-       gma_power_end(dev);
-}
-
-/**
- *     psbfb_copyarea  -       2D copy interface
- *     @info: our framebuffer
- *     @region: region to copy
- *
- *     Copy an area of the framebuffer console either by the accelerator
- *     or directly using the cfb helpers according to the request
- */
-void psbfb_copyarea(struct fb_info *info,
-                          const struct fb_copyarea *region)
-{
-       if (unlikely(info->state != FBINFO_STATE_RUNNING))
-               return;
-
-       /* Avoid the 8 pixel erratum */
-       if (region->width == 8 || region->height == 8 ||
-               (info->flags & FBINFO_HWACCEL_DISABLED))
-               return cfb_copyarea(info, region);
-
-       psbfb_copyarea_accel(info, region);
-}
-
-/**
- *     psbfb_sync      -       synchronize 2D
- *     @info: our framebuffer
- *
- *     Wait for the 2D engine to quiesce so that we can do CPU
- *     access to the framebuffer again
- */
-int psbfb_sync(struct fb_info *info)
-{
-       struct psb_fbdev *fbdev = info->par;
-       struct psb_framebuffer *psbfb = &fbdev->pfb;
-       struct drm_device *dev = psbfb->base.dev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       unsigned long _end = jiffies + DRM_HZ;
-       int busy = 0;
-       unsigned long flags;
-
-       spin_lock_irqsave(&dev_priv->lock_2d, flags);
-       /*
-        * First idle the 2D engine.
-        */
-
-       if ((PSB_RSGX32(PSB_CR_2D_SOCIF) == _PSB_C2_SOCIF_EMPTY) &&
-           ((PSB_RSGX32(PSB_CR_2D_BLIT_STATUS) & _PSB_C2B_STATUS_BUSY) == 0))
-               goto out;
-
-       do {
-               busy = (PSB_RSGX32(PSB_CR_2D_SOCIF) != _PSB_C2_SOCIF_EMPTY);
-               cpu_relax();
-       } while (busy && !time_after_eq(jiffies, _end));
-
-       if (busy)
-               busy = (PSB_RSGX32(PSB_CR_2D_SOCIF) != _PSB_C2_SOCIF_EMPTY);
-       if (busy)
-               goto out;
-
-       do {
-               busy = ((PSB_RSGX32(PSB_CR_2D_BLIT_STATUS) &
-                                               _PSB_C2B_STATUS_BUSY) != 0);
-               cpu_relax();
-       } while (busy && !time_after_eq(jiffies, _end));
-       if (busy)
-               busy = ((PSB_RSGX32(PSB_CR_2D_BLIT_STATUS) &
-                                       _PSB_C2B_STATUS_BUSY) != 0);
-
-out:
-       spin_unlock_irqrestore(&dev_priv->lock_2d, flags);
-       return (busy) ? -EBUSY : 0;
-}
-
-int psb_accel_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct drm_psb_2d_op *op = data;
-       u32 *op_ptr = &op->cmd[0];
-       int i;
-       struct drm_gem_object *obj;
-       struct gtt_range *gtt;
-       int err = -EINVAL;
-
-       if (!dev_priv->ops->accel_2d)
-               return -EOPNOTSUPP;
-       if (op->size > PSB_2D_OP_BUFLEN)
-               return -EINVAL;
-
-       /* The GEM object being used. We need to support separate src/dst/etc
-          in the end but for now keep them all the same */
-       obj = drm_gem_object_lookup(dev, file, op->src);
-       if (obj == NULL)
-               return -ENOENT;
-       gtt = container_of(obj, struct gtt_range, gem);
-
-       if (psb_gtt_pin(gtt) < 0)
-               goto bad_2;
-       for (i = 0; i < op->size; i++, op_ptr++) {
-               u32 r = *op_ptr & 0xF0000000;
-               /* Fill in the GTT offsets for the command buffer */
-               if (r == PSB_2D_SRC_SURF_BH ||
-                       r == PSB_2D_DST_SURF_BH ||
-                       r == PSB_2D_MASK_SURF_BH ||
-                       r == PSB_2D_PAT_SURF_BH) {
-                       i++;
-                       op_ptr++;
-                       if (i == op->size)
-                               goto bad;
-                       if (*op_ptr)
-                               goto bad;
-                       *op_ptr = gtt->offset;
-                       continue;
-               }
-       }
-       psbfb_2d_submit(dev_priv, op->cmd, op->size);
-       err = 0;
-bad:
-       psb_gtt_unpin(gtt);
-bad_2:
-       drm_gem_object_unreference(obj);
-       return err;
-}
diff --git a/drivers/staging/gma500/backlight.c b/drivers/staging/gma500/backlight.c
deleted file mode 100644 (file)
index 2079395..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * GMA500 Backlight Interface
- *
- * Copyright (c) 2009-2011, Intel Corporation.
- *
- * 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.
- *
- * Authors: Eric Knopp
- *
- */
-
-#include "psb_drv.h"
-#include "psb_intel_reg.h"
-#include "psb_intel_drv.h"
-#include "intel_bios.h"
-#include "power.h"
-
-int gma_backlight_init(struct drm_device *dev)
-{
-#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       return dev_priv->ops->backlight_init(dev);
-#else
-       return 0;
-#endif
-}
-
-void gma_backlight_exit(struct drm_device *dev)
-{
-#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       if (dev_priv->backlight_device) {
-               dev_priv->backlight_device->props.brightness = 0;
-               backlight_update_status(dev_priv->backlight_device);
-               backlight_device_unregister(dev_priv->backlight_device);
-       }
-#endif
-}
diff --git a/drivers/staging/gma500/cdv_device.c b/drivers/staging/gma500/cdv_device.c
deleted file mode 100644 (file)
index 8ec10ca..0000000
+++ /dev/null
@@ -1,350 +0,0 @@
-/**************************************************************************
- * 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>
-#include "psb_drm.h"
-#include "psb_drv.h"
-#include "psb_reg.h"
-#include "psb_intel_reg.h"
-#include "intel_bios.h"
-#include "cdv_device.h"
-
-#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;
-       cdv_disable_vga(dev);
-
-       cdv_intel_crt_init(dev, &dev_priv->mode_dev);
-       cdv_intel_lvds_init(dev, &dev_priv->mode_dev);
-
-       /* These bits indicate HDMI not SDVO on CDV, but we don't yet support
-          the HDMI interface */
-       if (REG_READ(SDVOB) & SDVO_DETECTED)
-               cdv_hdmi_init(dev, &dev_priv->mode_dev, SDVOB);
-       if (REG_READ(SDVOC) & SDVO_DETECTED)
-               cdv_hdmi_init(dev, &dev_priv->mode_dev, SDVOC);
-       return 0;
-}
-
-#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-
-/*
- *     Poulsbo Backlight Interfaces
- */
-
-#define BLC_PWM_PRECISION_FACTOR 100   /* 10000000 */
-#define BLC_PWM_FREQ_CALC_CONSTANT 32
-#define MHz 1000000
-
-#define PSB_BLC_PWM_PRECISION_FACTOR    10
-#define PSB_BLC_MAX_PWM_REG_FREQ        0xFFFE
-#define PSB_BLC_MIN_PWM_REG_FREQ        0x2
-
-#define PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR (0xFFFE)
-#define PSB_BACKLIGHT_PWM_CTL_SHIFT    (16)
-
-static int cdv_brightness;
-static struct backlight_device *cdv_backlight_device;
-
-static int cdv_get_brightness(struct backlight_device *bd)
-{
-       /* return locally cached var instead of HW read (due to DPST etc.) */
-       /* FIXME: ideally return actual value in case firmware fiddled with
-          it */
-       return cdv_brightness;
-}
-
-
-static int cdv_backlight_setup(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       unsigned long core_clock;
-       /* u32 bl_max_freq; */
-       /* unsigned long value; */
-       u16 bl_max_freq;
-       uint32_t value;
-       uint32_t blc_pwm_precision_factor;
-
-       /* get bl_max_freq and pol from dev_priv*/
-       if (!dev_priv->lvds_bl) {
-               dev_err(dev->dev, "Has no valid LVDS backlight info\n");
-               return -ENOENT;
-       }
-       bl_max_freq = dev_priv->lvds_bl->freq;
-       blc_pwm_precision_factor = PSB_BLC_PWM_PRECISION_FACTOR;
-
-       core_clock = dev_priv->core_freq;
-
-       value = (core_clock * MHz) / BLC_PWM_FREQ_CALC_CONSTANT;
-       value *= blc_pwm_precision_factor;
-       value /= bl_max_freq;
-       value /= blc_pwm_precision_factor;
-
-       if (value > (unsigned long long)PSB_BLC_MAX_PWM_REG_FREQ ||
-                value < (unsigned long long)PSB_BLC_MIN_PWM_REG_FREQ)
-                               return -ERANGE;
-       else {
-               /* FIXME */
-       }
-       return 0;
-}
-
-static int cdv_set_brightness(struct backlight_device *bd)
-{
-       int level = bd->props.brightness;
-
-       /* Percentage 1-100% being valid */
-       if (level < 1)
-               level = 1;
-
-       /*cdv_intel_lvds_set_brightness(dev, level); FIXME */
-       cdv_brightness = level;
-       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;
-       int ret;
-       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);
-
-       ret = cdv_backlight_setup(dev);
-       if (ret < 0) {
-               backlight_device_unregister(cdv_backlight_device);
-               cdv_backlight_device = NULL;
-               return ret;
-       }
-       cdv_backlight_device->props.brightness = 100;
-       cdv_backlight_device->props.max_brightness = 100;
-       backlight_update_status(cdv_backlight_device);
-       dev_priv->backlight_device = cdv_backlight_device;
-       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.
- */
-
-static inline u32 CDV_MSG_READ32(uint port, uint offset)
-{
-       int mcr = (0x10<<24) | (port << 16) | (offset << 8);
-       uint32_t ret_val = 0;
-       struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
-       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;
-}
-
-static inline void CDV_MSG_WRITE32(uint port, uint offset, u32 value)
-{
-       int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0;
-       struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
-       pci_write_config_dword(pci_root, 0xD4, value);
-       pci_write_config_dword(pci_root, 0xD0, mcr);
-       pci_dev_put(pci_root);
-}
-
-#define PSB_APM_CMD                    0x0
-#define PSB_APM_STS                    0x04
-#define PSB_PM_SSC                     0x20
-#define PSB_PM_SSS                     0x30
-#define PSB_PWRGT_GFX_MASK             0x3
-#define CDV_PWRGT_DISPLAY_CNTR         0x000fc00c
-#define CDV_PWRGT_DISPLAY_STS          0x000fc00c
-
-static void cdv_init_pm(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       u32 pwr_cnt;
-       int i;
-
-       dev_priv->apm_base = CDV_MSG_READ32(PSB_PUNIT_PORT,
-                                                       PSB_APMBA) & 0xFFFF;
-       dev_priv->ospm_base = CDV_MSG_READ32(PSB_PUNIT_PORT,
-                                                       PSB_OSPMBA) & 0xFFFF;
-
-       /* Force power on for now */
-       pwr_cnt = inl(dev_priv->apm_base + PSB_APM_CMD);
-       pwr_cnt &= ~PSB_PWRGT_GFX_MASK;
-
-       outl(pwr_cnt, dev_priv->apm_base + PSB_APM_CMD);
-       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)
-                       break;
-               udelay(10);
-       }
-       pwr_cnt = inl(dev_priv->ospm_base + PSB_PM_SSC);
-       pwr_cnt &= ~CDV_PWRGT_DISPLAY_CNTR;
-       outl(pwr_cnt, dev_priv->ospm_base + PSB_PM_SSC);
-       for (i = 0; i < 5; i++) {
-               u32 pwr_sts = inl(dev_priv->ospm_base + PSB_PM_SSS);
-               if ((pwr_sts & CDV_PWRGT_DISPLAY_STS) == 0)
-                       break;
-               udelay(10);
-       }
-}
-
-/**
- *     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
- *
- *     FIXME: review
- */
-static int cdv_save_display_registers(struct drm_device *dev)
-{
-       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)
-{
-       return 0;
-}
-
-static int cdv_power_down(struct drm_device *dev)
-{
-       return 0;
-}
-
-static int cdv_power_up(struct drm_device *dev)
-{
-       return 0;
-}
-
-/* FIXME ? - shared with Poulsbo */
-static void cdv_get_core_freq(struct drm_device *dev)
-{
-       uint32_t clock;
-       struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       pci_write_config_dword(pci_root, 0xD0, 0xD0050300);
-       pci_read_config_dword(pci_root, 0xD4, &clock);
-       pci_dev_put(pci_root);
-
-       switch (clock & 0x07) {
-       case 0:
-               dev_priv->core_freq = 100;
-               break;
-       case 1:
-               dev_priv->core_freq = 133;
-               break;
-       case 2:
-               dev_priv->core_freq = 150;
-               break;
-       case 3:
-               dev_priv->core_freq = 178;
-               break;
-       case 4:
-               dev_priv->core_freq = 200;
-               break;
-       case 5:
-       case 6:
-       case 7:
-               dev_priv->core_freq = 266;
-       default:
-               dev_priv->core_freq = 0;
-       }
-}
-
-static int cdv_chip_setup(struct drm_device *dev)
-{
-       cdv_get_core_freq(dev);
-       gma_intel_opregion_init(dev);
-       psb_intel_init_bios(dev);
-       return 0;
-}
-
-/* CDV is much like Poulsbo but has MID like SGX offsets and PM */
-
-const struct psb_ops cdv_chip_ops = {
-       .name = "Cedartrail",
-       .accel_2d = 0,
-       .pipes = 2,
-       .sgx_offset = MRST_SGX_OFFSET,
-       .chip_setup = cdv_chip_setup,
-
-       .crtc_helper = &cdv_intel_helper_funcs,
-       .crtc_funcs = &cdv_intel_crtc_funcs,
-
-       .output_init = cdv_output_init,
-
-#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,
-       .power_down = cdv_power_down,
-       .power_up = cdv_power_up,
-};
diff --git a/drivers/staging/gma500/cdv_device.h b/drivers/staging/gma500/cdv_device.h
deleted file mode 100644 (file)
index 2a88b7b..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation
- *
- * 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.
- */
-
-extern const struct drm_crtc_helper_funcs cdv_intel_helper_funcs;
-extern const struct drm_crtc_funcs cdv_intel_crtc_funcs;
-extern void cdv_intel_crt_init(struct drm_device *dev,
-                       struct psb_intel_mode_device *mode_dev);
-extern void cdv_intel_lvds_init(struct drm_device *dev,
-                       struct psb_intel_mode_device *mode_dev);
-extern void cdv_hdmi_init(struct drm_device *dev, struct psb_intel_mode_device *mode_dev,
-                       int reg);
-extern struct drm_display_mode *cdv_intel_crtc_mode_get(struct drm_device *dev,
-                                            struct drm_crtc *crtc);
-
-extern inline void cdv_intel_wait_for_vblank(struct drm_device *dev)
-{
-       /* Wait for 20ms, i.e. one cycle at 50hz. */
-        /* FIXME: msleep ?? */
-       mdelay(20);
-}
-
-
diff --git a/drivers/staging/gma500/cdv_intel_crt.c b/drivers/staging/gma500/cdv_intel_crt.c
deleted file mode 100644 (file)
index efda63b..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright © 2006-2007 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *     Eric Anholt <eric@anholt.net>
- */
-
-#include <linux/i2c.h>
-#include <drm/drmP.h>
-
-#include "intel_bios.h"
-#include "psb_drv.h"
-#include "psb_intel_drv.h"
-#include "psb_intel_reg.h"
-#include "power.h"
-#include <linux/pm_runtime.h>
-
-
-static void cdv_intel_crt_dpms(struct drm_encoder *encoder, int mode)
-{
-       struct drm_device *dev = encoder->dev;
-       u32 temp, reg;
-       reg = ADPA;
-
-       temp = REG_READ(reg);
-       temp &= ~(ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE);
-       temp &= ~ADPA_DAC_ENABLE;
-
-       switch (mode) {
-       case DRM_MODE_DPMS_ON:
-               temp |= ADPA_DAC_ENABLE;
-               break;
-       case DRM_MODE_DPMS_STANDBY:
-               temp |= ADPA_DAC_ENABLE | ADPA_HSYNC_CNTL_DISABLE;
-               break;
-       case DRM_MODE_DPMS_SUSPEND:
-               temp |= ADPA_DAC_ENABLE | ADPA_VSYNC_CNTL_DISABLE;
-               break;
-       case DRM_MODE_DPMS_OFF:
-               temp |= ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE;
-               break;
-       }
-
-       REG_WRITE(reg, temp);
-}
-
-static int cdv_intel_crt_mode_valid(struct drm_connector *connector,
-                               struct drm_display_mode *mode)
-{
-       int max_clock = 0;
-       if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
-               return MODE_NO_DBLESCAN;
-
-       /* The lowest clock for CDV is 20000KHz */
-       if (mode->clock < 20000)
-               return MODE_CLOCK_LOW;
-
-       /* The max clock for CDV is 355 instead of 400 */
-       max_clock = 355000;
-       if (mode->clock > max_clock)
-               return MODE_CLOCK_HIGH;
-
-       if (mode->hdisplay > 1680 || mode->vdisplay > 1050)
-               return MODE_PANEL;
-
-       return MODE_OK;
-}
-
-static bool cdv_intel_crt_mode_fixup(struct drm_encoder *encoder,
-                                struct drm_display_mode *mode,
-                                struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
-static void cdv_intel_crt_mode_set(struct drm_encoder *encoder,
-                              struct drm_display_mode *mode,
-                              struct drm_display_mode *adjusted_mode)
-{
-
-       struct drm_device *dev = encoder->dev;
-       struct drm_crtc *crtc = encoder->crtc;
-       struct psb_intel_crtc *psb_intel_crtc =
-                                       to_psb_intel_crtc(crtc);
-       int dpll_md_reg;
-       u32 adpa, dpll_md;
-       u32 adpa_reg;
-
-       if (psb_intel_crtc->pipe == 0)
-               dpll_md_reg = DPLL_A_MD;
-       else
-               dpll_md_reg = DPLL_B_MD;
-
-       adpa_reg = ADPA;
-
-       /*
-        * Disable separate mode multiplier used when cloning SDVO to CRT
-        * XXX this needs to be adjusted when we really are cloning
-        */
-       {
-               dpll_md = REG_READ(dpll_md_reg);
-               REG_WRITE(dpll_md_reg,
-                          dpll_md & ~DPLL_MD_UDI_MULTIPLIER_MASK);
-       }
-
-       adpa = 0;
-       if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
-               adpa |= ADPA_HSYNC_ACTIVE_HIGH;
-       if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
-               adpa |= ADPA_VSYNC_ACTIVE_HIGH;
-
-       if (psb_intel_crtc->pipe == 0)
-               adpa |= ADPA_PIPE_A_SELECT;
-       else
-               adpa |= ADPA_PIPE_B_SELECT;
-
-       REG_WRITE(adpa_reg, adpa);
-}
-
-
-/**
- * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect CRT presence.
- *
- * \return true if CRT is connected.
- * \return false if CRT is disconnected.
- */
-static bool cdv_intel_crt_detect_hotplug(struct drm_connector *connector,
-                                                               bool force)
-{
-       struct drm_device *dev = connector->dev;
-       u32 hotplug_en;
-       int i, tries = 0, ret = false;
-       u32 adpa_orig;
-
-       /* disable the DAC when doing the hotplug detection */
-
-       adpa_orig = REG_READ(ADPA);
-
-       REG_WRITE(ADPA, adpa_orig & ~(ADPA_DAC_ENABLE));
-
-       /*
-        * On a CDV thep, CRT detect sequence need to be done twice
-        * to get a reliable result.
-        */
-       tries = 2;
-
-       hotplug_en = REG_READ(PORT_HOTPLUG_EN);
-       hotplug_en &= ~(CRT_HOTPLUG_DETECT_MASK);
-       hotplug_en |= CRT_HOTPLUG_FORCE_DETECT;
-
-       hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64;
-       hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50;
-
-       for (i = 0; i < tries ; i++) {
-               unsigned long timeout;
-               /* turn on the FORCE_DETECT */
-               REG_WRITE(PORT_HOTPLUG_EN, hotplug_en);
-               timeout = jiffies + msecs_to_jiffies(1000);
-               /* wait for FORCE_DETECT to go off */
-               do {
-                       if (!(REG_READ(PORT_HOTPLUG_EN) &
-                                       CRT_HOTPLUG_FORCE_DETECT))
-                               break;
-                       msleep(1);
-               } while (time_after(timeout, jiffies));
-       }
-
-       if ((REG_READ(PORT_HOTPLUG_STAT) & CRT_HOTPLUG_MONITOR_MASK) !=
-           CRT_HOTPLUG_MONITOR_NONE)
-               ret = true;
-
-       /* Restore the saved ADPA */
-       REG_WRITE(ADPA, adpa_orig);
-       return ret;
-}
-
-static enum drm_connector_status cdv_intel_crt_detect(
-                               struct drm_connector *connector, bool force)
-{
-       if (cdv_intel_crt_detect_hotplug(connector, force))
-               return connector_status_connected;
-       else
-               return connector_status_disconnected;
-}
-
-static void cdv_intel_crt_destroy(struct drm_connector *connector)
-{
-       struct psb_intel_output *intel_output = to_psb_intel_output(connector);
-
-       psb_intel_i2c_destroy(intel_output->ddc_bus);
-       drm_sysfs_connector_remove(connector);
-       drm_connector_cleanup(connector);
-       kfree(connector);
-}
-
-static int cdv_intel_crt_get_modes(struct drm_connector *connector)
-{
-       struct psb_intel_output *intel_output =
-                               to_psb_intel_output(connector);
-       return psb_intel_ddc_get_modes(intel_output);
-}
-
-static int cdv_intel_crt_set_property(struct drm_connector *connector,
-                                 struct drm_property *property,
-                                 uint64_t value)
-{
-       return 0;
-}
-
-/*
- * Routines for controlling stuff on the analog port
- */
-
-static const struct drm_encoder_helper_funcs cdv_intel_crt_helper_funcs = {
-       .dpms = cdv_intel_crt_dpms,
-       .mode_fixup = cdv_intel_crt_mode_fixup,
-       .prepare = psb_intel_encoder_prepare,
-       .commit = psb_intel_encoder_commit,
-       .mode_set = cdv_intel_crt_mode_set,
-};
-
-static const struct drm_connector_funcs cdv_intel_crt_connector_funcs = {
-       .dpms = drm_helper_connector_dpms,
-       .detect = cdv_intel_crt_detect,
-       .fill_modes = drm_helper_probe_single_connector_modes,
-       .destroy = cdv_intel_crt_destroy,
-       .set_property = cdv_intel_crt_set_property,
-};
-
-static const struct drm_connector_helper_funcs
-                               cdv_intel_crt_connector_helper_funcs = {
-       .mode_valid = cdv_intel_crt_mode_valid,
-       .get_modes = cdv_intel_crt_get_modes,
-       .best_encoder = psb_intel_best_encoder,
-};
-
-static void cdv_intel_crt_enc_destroy(struct drm_encoder *encoder)
-{
-       drm_encoder_cleanup(encoder);
-}
-
-static const struct drm_encoder_funcs cdv_intel_crt_enc_funcs = {
-       .destroy = cdv_intel_crt_enc_destroy,
-};
-
-void cdv_intel_crt_init(struct drm_device *dev,
-                       struct psb_intel_mode_device *mode_dev)
-{
-
-       struct psb_intel_output *psb_intel_output;
-       struct drm_connector *connector;
-       struct drm_encoder *encoder;
-
-       u32 i2c_reg;
-
-       psb_intel_output = kzalloc(sizeof(struct psb_intel_output), GFP_KERNEL);
-       if (!psb_intel_output)
-               return;
-
-       psb_intel_output->mode_dev = mode_dev;
-       connector = &psb_intel_output->base;
-       drm_connector_init(dev, connector,
-               &cdv_intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
-
-       encoder = &psb_intel_output->enc;
-       drm_encoder_init(dev, encoder,
-               &cdv_intel_crt_enc_funcs, DRM_MODE_ENCODER_DAC);
-
-       drm_mode_connector_attach_encoder(&psb_intel_output->base,
-                                         &psb_intel_output->enc);
-
-       /* Set up the DDC bus. */
-       i2c_reg = GPIOA;
-       /* Remove the following code for CDV */
-       /*
-       if (dev_priv->crt_ddc_bus != 0)
-               i2c_reg = dev_priv->crt_ddc_bus;
-       }*/
-       psb_intel_output->ddc_bus = psb_intel_i2c_create(dev,
-                                               i2c_reg, "CRTDDC_A");
-       if (!psb_intel_output->ddc_bus) {
-               dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
-                          "failed.\n");
-               goto failed_ddc;
-       }
-
-       psb_intel_output->type = INTEL_OUTPUT_ANALOG;
-       /*
-       psb_intel_output->clone_mask = (1 << INTEL_ANALOG_CLONE_BIT);
-       psb_intel_output->crtc_mask = (1 << 0) | (1 << 1);
-       */
-       connector->interlace_allowed = 0;
-       connector->doublescan_allowed = 0;
-
-       drm_encoder_helper_add(encoder, &cdv_intel_crt_helper_funcs);
-       drm_connector_helper_add(connector,
-                                       &cdv_intel_crt_connector_helper_funcs);
-
-       drm_sysfs_connector_add(connector);
-
-       return;
-failed_ddc:
-       drm_encoder_cleanup(&psb_intel_output->enc);
-       drm_connector_cleanup(&psb_intel_output->base);
-       kfree(psb_intel_output);
-       return;
-}
diff --git a/drivers/staging/gma500/cdv_intel_display.c b/drivers/staging/gma500/cdv_intel_display.c
deleted file mode 100644 (file)
index c63a327..0000000
+++ /dev/null
@@ -1,1508 +0,0 @@
-/*
- * Copyright © 2006-2011 Intel Corporation
- *
- * 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.
- *
- * Authors:
- *     Eric Anholt <eric@anholt.net>
- */
-
-#include <linux/i2c.h>
-#include <linux/pm_runtime.h>
-
-#include <drm/drmP.h>
-#include "framebuffer.h"
-#include "psb_drv.h"
-#include "psb_intel_drv.h"
-#include "psb_intel_reg.h"
-#include "psb_intel_display.h"
-#include "power.h"
-#include "cdv_device.h"
-
-
-struct cdv_intel_range_t {
-       int min, max;
-};
-
-struct cdv_intel_p2_t {
-       int dot_limit;
-       int p2_slow, p2_fast;
-};
-
-struct cdv_intel_clock_t {
-       /* given values */
-       int n;
-       int m1, m2;
-       int p1, p2;
-       /* derived values */
-       int dot;
-       int vco;
-       int m;
-       int p;
-};
-
-#define INTEL_P2_NUM                 2
-
-struct cdv_intel_limit_t {
-       struct cdv_intel_range_t dot, vco, n, m, m1, m2, p, p1;
-       struct cdv_intel_p2_t p2;
-};
-
-#define CDV_LIMIT_SINGLE_LVDS_96       0
-#define CDV_LIMIT_SINGLE_LVDS_100      1
-#define CDV_LIMIT_DAC_HDMI_27          2
-#define CDV_LIMIT_DAC_HDMI_96          3
-
-static const struct cdv_intel_limit_t cdv_intel_limits[] = {
-       {                       /* CDV_SIGNLE_LVDS_96MHz */
-        .dot = {.min = 20000, .max = 115500},
-        .vco = {.min = 1800000, .max = 3600000},
-        .n = {.min = 2, .max = 6},
-        .m = {.min = 60, .max = 160},
-        .m1 = {.min = 0, .max = 0},
-        .m2 = {.min = 58, .max = 158},
-        .p = {.min = 28, .max = 140},
-        .p1 = {.min = 2, .max = 10},
-        .p2 = {.dot_limit = 200000,
-               .p2_slow = 14, .p2_fast = 14},
-        },
-       {                       /* CDV_SINGLE_LVDS_100MHz */
-        .dot = {.min = 20000, .max = 115500},
-        .vco = {.min = 1800000, .max = 3600000},
-        .n = {.min = 2, .max = 6},
-        .m = {.min = 60, .max = 160},
-        .m1 = {.min = 0, .max = 0},
-        .m2 = {.min = 58, .max = 158},
-        .p = {.min = 28, .max = 140},
-        .p1 = {.min = 2, .max = 10},
-        /* The single-channel range is 25-112Mhz, and dual-channel
-         * is 80-224Mhz.  Prefer single channel as much as possible.
-         */
-        .p2 = {.dot_limit = 200000, .p2_slow = 14, .p2_fast = 14},
-        },
-       {                       /* CDV_DAC_HDMI_27MHz */
-        .dot = {.min = 20000, .max = 400000},
-        .vco = {.min = 1809000, .max = 3564000},
-        .n = {.min = 1, .max = 1},
-        .m = {.min = 67, .max = 132},
-        .m1 = {.min = 0, .max = 0},
-        .m2 = {.min = 65, .max = 130},
-        .p = {.min = 5, .max = 90},
-        .p1 = {.min = 1, .max = 9},
-        .p2 = {.dot_limit = 225000, .p2_slow = 10, .p2_fast = 5},
-        },
-       {                       /* CDV_DAC_HDMI_96MHz */
-        .dot = {.min = 20000, .max = 400000},
-        .vco = {.min = 1800000, .max = 3600000},
-        .n = {.min = 2, .max = 6},
-        .m = {.min = 60, .max = 160},
-        .m1 = {.min = 0, .max = 0},
-        .m2 = {.min = 58, .max = 158},
-        .p = {.min = 5, .max = 100},
-        .p1 = {.min = 1, .max = 10},
-        .p2 = {.dot_limit = 225000, .p2_slow = 10, .p2_fast = 5},
-        },
-};
-
-#define _wait_for(COND, MS, W) ({ \
-       unsigned long timeout__ = jiffies + msecs_to_jiffies(MS);       \
-       int ret__ = 0;                                                  \
-       while (!(COND)) {                                               \
-               if (time_after(jiffies, timeout__)) {                   \
-                       ret__ = -ETIMEDOUT;                             \
-                       break;                                          \
-               }                                                       \
-               if (W && !in_dbg_master())                              \
-                       msleep(W);                                      \
-       }                                                               \
-       ret__;                                                          \
-})
-
-#define wait_for(COND, MS) _wait_for(COND, MS, 1)
-
-
-static int cdv_sb_read(struct drm_device *dev, u32 reg, u32 *val)
-{
-       int ret;
-
-       ret = wait_for((REG_READ(SB_PCKT) & SB_BUSY) == 0, 1000);
-       if (ret) {
-               DRM_ERROR("timeout waiting for SB to idle before read\n");
-               return ret;
-       }
-
-       REG_WRITE(SB_ADDR, reg);
-       REG_WRITE(SB_PCKT,
-                  SET_FIELD(SB_OPCODE_READ, SB_OPCODE) |
-                  SET_FIELD(SB_DEST_DPLL, SB_DEST) |
-                  SET_FIELD(0xf, SB_BYTE_ENABLE));
-
-       ret = wait_for((REG_READ(SB_PCKT) & SB_BUSY) == 0, 1000);
-       if (ret) {
-               DRM_ERROR("timeout waiting for SB to idle after read\n");
-               return ret;
-       }
-
-       *val = REG_READ(SB_DATA);
-
-       return 0;
-}
-
-static int cdv_sb_write(struct drm_device *dev, u32 reg, u32 val)
-{
-       int ret;
-       static bool dpio_debug = true;
-       u32 temp;
-
-       if (dpio_debug) {
-               if (cdv_sb_read(dev, reg, &temp) == 0)
-                       DRM_DEBUG_KMS("0x%08x: 0x%08x (before)\n", reg, temp);
-               DRM_DEBUG_KMS("0x%08x: 0x%08x\n", reg, val);
-       }
-
-       ret = wait_for((REG_READ(SB_PCKT) & SB_BUSY) == 0, 1000);
-       if (ret) {
-               DRM_ERROR("timeout waiting for SB to idle before write\n");
-               return ret;
-       }
-
-       REG_WRITE(SB_ADDR, reg);
-       REG_WRITE(SB_DATA, val);
-       REG_WRITE(SB_PCKT,
-                  SET_FIELD(SB_OPCODE_WRITE, SB_OPCODE) |
-                  SET_FIELD(SB_DEST_DPLL, SB_DEST) |
-                  SET_FIELD(0xf, SB_BYTE_ENABLE));
-
-       ret = wait_for((REG_READ(SB_PCKT) & SB_BUSY) == 0, 1000);
-       if (ret) {
-               DRM_ERROR("timeout waiting for SB to idle after write\n");
-               return ret;
-       }
-
-       if (dpio_debug) {
-               if (cdv_sb_read(dev, reg, &temp) == 0)
-                       DRM_DEBUG_KMS("0x%08x: 0x%08x (after)\n", reg, temp);
-       }
-
-       return 0;
-}
-
-/* Reset the DPIO configuration register.  The BIOS does this at every
- * mode set.
- */
-static void cdv_sb_reset(struct drm_device *dev)
-{
-
-       REG_WRITE(DPIO_CFG, 0);
-       REG_READ(DPIO_CFG);
-       REG_WRITE(DPIO_CFG, DPIO_MODE_SELECT_0 | DPIO_CMN_RESET_N);
-}
-
-/* Unlike most Intel display engines, on Cedarview the DPLL registers
- * are behind this sideband bus.  They must be programmed while the
- * DPLL reference clock is on in the DPLL control register, but before
- * the DPLL is enabled in the DPLL control register.
- */
-static int
-cdv_dpll_set_clock_cdv(struct drm_device *dev, struct drm_crtc *crtc,
-                              struct cdv_intel_clock_t *clock)
-{
-       struct psb_intel_crtc *psb_crtc =
-                               to_psb_intel_crtc(crtc);
-       int pipe = psb_crtc->pipe;
-       u32 m, n_vco, p;
-       int ret = 0;
-       int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
-       u32 ref_value;
-
-       cdv_sb_reset(dev);
-
-       if ((REG_READ(dpll_reg) & DPLL_SYNCLOCK_ENABLE) == 0) {
-               DRM_ERROR("Attempting to set DPLL with refclk disabled\n");
-               return -EBUSY;
-       }
-
-       /* Follow the BIOS and write the REF/SFR Register. Hardcoded value */
-       ref_value = 0x68A701;
-
-       cdv_sb_write(dev, SB_REF_SFR(pipe), ref_value);
-
-       /* We don't know what the other fields of these regs are, so
-        * leave them in place.
-        */
-       ret = cdv_sb_read(dev, SB_M(pipe), &m);
-       if (ret)
-               return ret;
-       m &= ~SB_M_DIVIDER_MASK;
-       m |= ((clock->m2) << SB_M_DIVIDER_SHIFT);
-       ret = cdv_sb_write(dev, SB_M(pipe), m);
-       if (ret)
-               return ret;
-
-       ret = cdv_sb_read(dev, SB_N_VCO(pipe), &n_vco);
-       if (ret)
-               return ret;
-
-       /* Follow the BIOS to program the N_DIVIDER REG */
-       n_vco &= 0xFFFF;
-       n_vco |= 0x107;
-       n_vco &= ~(SB_N_VCO_SEL_MASK |
-                  SB_N_DIVIDER_MASK |
-                  SB_N_CB_TUNE_MASK);
-
-       n_vco |= ((clock->n) << SB_N_DIVIDER_SHIFT);
-
-       if (clock->vco < 2250000) {
-               n_vco |= (2 << SB_N_CB_TUNE_SHIFT);
-               n_vco |= (0 << SB_N_VCO_SEL_SHIFT);
-       } else if (clock->vco < 2750000) {
-               n_vco |= (1 << SB_N_CB_TUNE_SHIFT);
-               n_vco |= (1 << SB_N_VCO_SEL_SHIFT);
-       } else if (clock->vco < 3300000) {
-               n_vco |= (0 << SB_N_CB_TUNE_SHIFT);
-               n_vco |= (2 << SB_N_VCO_SEL_SHIFT);
-       } else {
-               n_vco |= (0 << SB_N_CB_TUNE_SHIFT);
-               n_vco |= (3 << SB_N_VCO_SEL_SHIFT);
-       }
-
-       ret = cdv_sb_write(dev, SB_N_VCO(pipe), n_vco);
-       if (ret)
-               return ret;
-
-       ret = cdv_sb_read(dev, SB_P(pipe), &p);
-       if (ret)
-               return ret;
-       p &= ~(SB_P2_DIVIDER_MASK | SB_P1_DIVIDER_MASK);
-       p |= SET_FIELD(clock->p1, SB_P1_DIVIDER);
-       switch (clock->p2) {
-       case 5:
-               p |= SET_FIELD(SB_P2_5, SB_P2_DIVIDER);
-               break;
-       case 10:
-               p |= SET_FIELD(SB_P2_10, SB_P2_DIVIDER);
-               break;
-       case 14:
-               p |= SET_FIELD(SB_P2_14, SB_P2_DIVIDER);
-               break;
-       case 7:
-               p |= SET_FIELD(SB_P2_7, SB_P2_DIVIDER);
-               break;
-       default:
-               DRM_ERROR("Bad P2 clock: %d\n", clock->p2);
-               return -EINVAL;
-       }
-       ret = cdv_sb_write(dev, SB_P(pipe), p);
-       if (ret)
-               return ret;
-
-       /* always Program the Lane Register for the Pipe A*/
-       if (pipe == 0) {
-               /* Program the Lane0/1 for HDMI B */
-               u32 lane_reg, lane_value;
-
-               lane_reg = PSB_LANE0;
-               cdv_sb_read(dev, lane_reg, &lane_value);
-               lane_value &= ~(LANE_PLL_MASK);
-               lane_value |= LANE_PLL_ENABLE;
-               cdv_sb_write(dev, lane_reg, lane_value);
-
-               lane_reg = PSB_LANE1;
-               cdv_sb_read(dev, lane_reg, &lane_value);
-               lane_value &= ~(LANE_PLL_MASK);
-               lane_value |= LANE_PLL_ENABLE;
-               cdv_sb_write(dev, lane_reg, lane_value);
-
-               /* Program the Lane2/3 for HDMI C */
-               lane_reg = PSB_LANE2;
-               cdv_sb_read(dev, lane_reg, &lane_value);
-               lane_value &= ~(LANE_PLL_MASK);
-               lane_value |= LANE_PLL_ENABLE;
-               cdv_sb_write(dev, lane_reg, lane_value);
-
-               lane_reg = PSB_LANE3;
-               cdv_sb_read(dev, lane_reg, &lane_value);
-               lane_value &= ~(LANE_PLL_MASK);
-               lane_value |= LANE_PLL_ENABLE;
-               cdv_sb_write(dev, lane_reg, lane_value);
-       }
-
-       return 0;
-}
-
-/*
- * Returns whether any output on the specified pipe is of the specified type
- */
-bool cdv_intel_pipe_has_type(struct drm_crtc *crtc, int type)
-{
-       struct drm_device *dev = crtc->dev;
-       struct drm_mode_config *mode_config = &dev->mode_config;
-       struct drm_connector *l_entry;
-
-       list_for_each_entry(l_entry, &mode_config->connector_list, head) {
-               if (l_entry->encoder && l_entry->encoder->crtc == crtc) {
-                       struct psb_intel_output *psb_intel_output =
-                           to_psb_intel_output(l_entry);
-                       if (psb_intel_output->type == type)
-                               return true;
-               }
-       }
-       return false;
-}
-
-static const struct cdv_intel_limit_t *cdv_intel_limit(struct drm_crtc *crtc,
-                                                       int refclk)
-{
-       const struct cdv_intel_limit_t *limit;
-       if (cdv_intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
-               /*
-                * Now only single-channel LVDS is supported on CDV. If it is
-                * incorrect, please add the dual-channel LVDS.
-                */
-               if (refclk == 96000)
-                       limit = &cdv_intel_limits[CDV_LIMIT_SINGLE_LVDS_96];
-               else
-                       limit = &cdv_intel_limits[CDV_LIMIT_SINGLE_LVDS_100];
-       } else {
-               if (refclk == 27000)
-                       limit = &cdv_intel_limits[CDV_LIMIT_DAC_HDMI_27];
-               else
-                       limit = &cdv_intel_limits[CDV_LIMIT_DAC_HDMI_96];
-       }
-       return limit;
-}
-
-/* m1 is reserved as 0 in CDV, n is a ring counter */
-static void cdv_intel_clock(struct drm_device *dev,
-                       int refclk, struct cdv_intel_clock_t *clock)
-{
-       clock->m = clock->m2 + 2;
-       clock->p = clock->p1 * clock->p2;
-       clock->vco = (refclk * clock->m) / clock->n;
-       clock->dot = clock->vco / clock->p;
-}
-
-
-#define INTELPllInvalid(s)   { /* ErrorF (s) */; return false; }
-static bool cdv_intel_PLL_is_valid(struct drm_crtc *crtc,
-                               const struct cdv_intel_limit_t *limit,
-                              struct cdv_intel_clock_t *clock)
-{
-       if (clock->p1 < limit->p1.min || limit->p1.max < clock->p1)
-               INTELPllInvalid("p1 out of range\n");
-       if (clock->p < limit->p.min || limit->p.max < clock->p)
-               INTELPllInvalid("p out of range\n");
-       /* unnecessary to check the range of m(m1/M2)/n again */
-       if (clock->vco < limit->vco.min || limit->vco.max < clock->vco)
-               INTELPllInvalid("vco out of range\n");
-       /* XXX: We may need to be checking "Dot clock"
-        * depending on the multiplier, connector, etc.,
-        * rather than just a single range.
-        */
-       if (clock->dot < limit->dot.min || limit->dot.max < clock->dot)
-               INTELPllInvalid("dot out of range\n");
-
-       return true;
-}
-
-static bool cdv_intel_find_best_PLL(struct drm_crtc *crtc, int target,
-                               int refclk,
-                               struct cdv_intel_clock_t *best_clock)
-{
-       struct drm_device *dev = crtc->dev;
-       struct cdv_intel_clock_t clock;
-       const struct cdv_intel_limit_t *limit = cdv_intel_limit(crtc, refclk);
-       int err = target;
-
-
-       if (cdv_intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) &&
-           (REG_READ(LVDS) & LVDS_PORT_EN) != 0) {
-               /*
-                * For LVDS, if the panel is on, just rely on its current
-                * settings for dual-channel.  We haven't figured out how to
-                * reliably set up different single/dual channel state, if we
-                * even can.
-                */
-               if ((REG_READ(LVDS) & LVDS_CLKB_POWER_MASK) ==
-                   LVDS_CLKB_POWER_UP)
-                       clock.p2 = limit->p2.p2_fast;
-               else
-                       clock.p2 = limit->p2.p2_slow;
-       } else {
-               if (target < limit->p2.dot_limit)
-                       clock.p2 = limit->p2.p2_slow;
-               else
-                       clock.p2 = limit->p2.p2_fast;
-       }
-
-       memset(best_clock, 0, sizeof(*best_clock));
-       clock.m1 = 0;
-       /* m1 is reserved as 0 in CDV, n is a ring counter.
-          So skip the m1 loop */
-       for (clock.n = limit->n.min; clock.n <= limit->n.max; clock.n++) {
-               for (clock.m2 = limit->m2.min; clock.m2 <= limit->m2.max;
-                                            clock.m2++) {
-                       for (clock.p1 = limit->p1.min;
-                                       clock.p1 <= limit->p1.max;
-                                       clock.p1++) {
-                               int this_err;
-
-                               cdv_intel_clock(dev, refclk, &clock);
-
-                               if (!cdv_intel_PLL_is_valid(crtc,
-                                                               limit, &clock))
-                                               continue;
-
-                               this_err = abs(clock.dot - target);
-                               if (this_err < err) {
-                                       *best_clock = clock;
-                                       err = this_err;
-                               }
-                       }
-               }
-       }
-
-       return err != target;
-}
-
-int cdv_intel_pipe_set_base(struct drm_crtc *crtc,
-                           int x, int y, struct drm_framebuffer *old_fb)
-{
-       struct drm_device *dev = crtc->dev;
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb);
-       int pipe = psb_intel_crtc->pipe;
-       unsigned long start, offset;
-       int dspbase = (pipe == 0 ? DSPABASE : DSPBBASE);
-       int dspsurf = (pipe == 0 ? DSPASURF : DSPBSURF);
-       int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE;
-       int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
-       u32 dspcntr;
-       int ret = 0;
-
-       if (!gma_power_begin(dev, true))
-               return 0;
-
-       /* no fb bound */
-       if (!crtc->fb) {
-               dev_err(dev->dev, "No FB bound\n");
-               goto psb_intel_pipe_cleaner;
-       }
-
-
-       /* We are displaying this buffer, make sure it is actually loaded
-          into the GTT */
-       ret = psb_gtt_pin(psbfb->gtt);
-       if (ret < 0)
-               goto psb_intel_pipe_set_base_exit;
-       start = psbfb->gtt->offset;
-       offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8);
-
-       REG_WRITE(dspstride, crtc->fb->pitches[0]);
-
-       dspcntr = REG_READ(dspcntr_reg);
-       dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
-
-       switch (crtc->fb->bits_per_pixel) {
-       case 8:
-               dspcntr |= DISPPLANE_8BPP;
-               break;
-       case 16:
-               if (crtc->fb->depth == 15)
-                       dspcntr |= DISPPLANE_15_16BPP;
-               else
-                       dspcntr |= DISPPLANE_16BPP;
-               break;
-       case 24:
-       case 32:
-               dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
-               break;
-       default:
-               dev_err(dev->dev, "Unknown color depth\n");
-               ret = -EINVAL;
-               goto psb_intel_pipe_set_base_exit;
-       }
-       REG_WRITE(dspcntr_reg, dspcntr);
-
-       dev_dbg(dev->dev,
-               "Writing base %08lX %08lX %d %d\n", start, offset, x, y);
-
-       REG_WRITE(dspbase, offset);
-       REG_READ(dspbase);
-       REG_WRITE(dspsurf, start);
-       REG_READ(dspsurf);
-
-psb_intel_pipe_cleaner:
-       /* If there was a previous display we can now unpin it */
-       if (old_fb)
-               psb_gtt_unpin(to_psb_fb(old_fb)->gtt);
-
-psb_intel_pipe_set_base_exit:
-       gma_power_end(dev);
-       return ret;
-}
-
-/**
- * Sets the power management mode of the pipe and plane.
- *
- * This code should probably grow support for turning the cursor off and back
- * on appropriately at the same time as we're turning the pipe off/on.
- */
-static void cdv_intel_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-       struct drm_device *dev = crtc->dev;
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       int pipe = psb_intel_crtc->pipe;
-       int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
-       int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
-       int dspbase_reg = (pipe == 0) ? DSPABASE : DSPBBASE;
-       int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
-       u32 temp;
-       bool enabled;
-
-       /* XXX: When our outputs are all unaware of DPMS modes other than off
-        * and on, we should map those modes to DRM_MODE_DPMS_OFF in the CRTC.
-        */
-       switch (mode) {
-       case DRM_MODE_DPMS_ON:
-       case DRM_MODE_DPMS_STANDBY:
-       case DRM_MODE_DPMS_SUSPEND:
-               /* Enable the DPLL */
-               temp = REG_READ(dpll_reg);
-               if ((temp & DPLL_VCO_ENABLE) == 0) {
-                       REG_WRITE(dpll_reg, temp);
-                       REG_READ(dpll_reg);
-                       /* Wait for the clocks to stabilize. */
-                       udelay(150);
-                       REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE);
-                       REG_READ(dpll_reg);
-                       /* Wait for the clocks to stabilize. */
-                       udelay(150);
-                       REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE);
-                       REG_READ(dpll_reg);
-                       /* Wait for the clocks to stabilize. */
-                       udelay(150);
-               }
-
-               /* Jim Bish - switch plan and pipe per scott */
-               /* Enable the plane */
-               temp = REG_READ(dspcntr_reg);
-               if ((temp & DISPLAY_PLANE_ENABLE) == 0) {
-                       REG_WRITE(dspcntr_reg,
-                                 temp | DISPLAY_PLANE_ENABLE);
-                       /* Flush the plane changes */
-                       REG_WRITE(dspbase_reg, REG_READ(dspbase_reg));
-               }
-
-               udelay(150);
-
-               /* Enable the pipe */
-               temp = REG_READ(pipeconf_reg);
-               if ((temp & PIPEACONF_ENABLE) == 0)
-                       REG_WRITE(pipeconf_reg, temp | PIPEACONF_ENABLE);
-
-               psb_intel_crtc_load_lut(crtc);
-
-               /* Give the overlay scaler a chance to enable
-                * if it's on this pipe */
-               /* psb_intel_crtc_dpms_video(crtc, true); TODO */
-               break;
-       case DRM_MODE_DPMS_OFF:
-               /* Give the overlay scaler a chance to disable
-                * if it's on this pipe */
-               /* psb_intel_crtc_dpms_video(crtc, FALSE); TODO */
-
-               /* Disable the VGA plane that we never use */
-               REG_WRITE(VGACNTRL, VGA_DISP_DISABLE);
-
-               /* Jim Bish - changed pipe/plane here as well. */
-
-               /* Wait for vblank for the disable to take effect */
-               cdv_intel_wait_for_vblank(dev);
-
-               /* Next, disable display pipes */
-               temp = REG_READ(pipeconf_reg);
-               if ((temp & PIPEACONF_ENABLE) != 0) {
-                       REG_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE);
-                       REG_READ(pipeconf_reg);
-               }
-
-               /* Wait for vblank for the disable to take effect. */
-               cdv_intel_wait_for_vblank(dev);
-
-               udelay(150);
-
-               /* Disable display plane */
-               temp = REG_READ(dspcntr_reg);
-               if ((temp & DISPLAY_PLANE_ENABLE) != 0) {
-                       REG_WRITE(dspcntr_reg,
-                                 temp & ~DISPLAY_PLANE_ENABLE);
-                       /* Flush the plane changes */
-                       REG_WRITE(dspbase_reg, REG_READ(dspbase_reg));
-                       REG_READ(dspbase_reg);
-               }
-
-               temp = REG_READ(dpll_reg);
-               if ((temp & DPLL_VCO_ENABLE) != 0) {
-                       REG_WRITE(dpll_reg, temp & ~DPLL_VCO_ENABLE);
-                       REG_READ(dpll_reg);
-               }
-
-               /* Wait for the clocks to turn off. */
-               udelay(150);
-               break;
-       }
-       enabled = crtc->enabled && mode != DRM_MODE_DPMS_OFF;
-       /*Set FIFO Watermarks*/
-       REG_WRITE(DSPARB, 0x3F3E);
-}
-
-static void cdv_intel_crtc_prepare(struct drm_crtc *crtc)
-{
-       struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
-       crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
-}
-
-static void cdv_intel_crtc_commit(struct drm_crtc *crtc)
-{
-       struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
-       crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
-}
-
-void cdv_intel_encoder_prepare(struct drm_encoder *encoder)
-{
-       struct drm_encoder_helper_funcs *encoder_funcs =
-           encoder->helper_private;
-       /* lvds has its own version of prepare see cdv_intel_lvds_prepare */
-       encoder_funcs->dpms(encoder, DRM_MODE_DPMS_OFF);
-}
-
-void cdv_intel_encoder_commit(struct drm_encoder *encoder)
-{
-       struct drm_encoder_helper_funcs *encoder_funcs =
-           encoder->helper_private;
-       /* lvds has its own version of commit see cdv_intel_lvds_commit */
-       encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON);
-}
-
-static bool cdv_intel_crtc_mode_fixup(struct drm_crtc *crtc,
-                                 struct drm_display_mode *mode,
-                                 struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
-
-/**
- * Return the pipe currently connected to the panel fitter,
- * or -1 if the panel fitter is not present or not in use
- */
-static int cdv_intel_panel_fitter_pipe(struct drm_device *dev)
-{
-       u32 pfit_control;
-
-       pfit_control = REG_READ(PFIT_CONTROL);
-
-       /* See if the panel fitter is in use */
-       if ((pfit_control & PFIT_ENABLE) == 0)
-               return -1;
-       return (pfit_control >> 29) & 0x3;
-}
-
-static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc,
-                              struct drm_display_mode *mode,
-                              struct drm_display_mode *adjusted_mode,
-                              int x, int y,
-                              struct drm_framebuffer *old_fb)
-{
-       struct drm_device *dev = crtc->dev;
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       int pipe = psb_intel_crtc->pipe;
-       int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
-       int dpll_md_reg = (psb_intel_crtc->pipe == 0) ? DPLL_A_MD : DPLL_B_MD;
-       int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
-       int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
-       int htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B;
-       int hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B;
-       int hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B;
-       int vtot_reg = (pipe == 0) ? VTOTAL_A : VTOTAL_B;
-       int vblank_reg = (pipe == 0) ? VBLANK_A : VBLANK_B;
-       int vsync_reg = (pipe == 0) ? VSYNC_A : VSYNC_B;
-       int dspsize_reg = (pipe == 0) ? DSPASIZE : DSPBSIZE;
-       int dsppos_reg = (pipe == 0) ? DSPAPOS : DSPBPOS;
-       int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC;
-       int refclk;
-       struct cdv_intel_clock_t clock;
-       u32 dpll = 0, dspcntr, pipeconf;
-       bool ok, is_sdvo = false, is_dvo = false;
-       bool is_crt = false, is_lvds = false, is_tv = false;
-       bool is_hdmi = false;
-       struct drm_mode_config *mode_config = &dev->mode_config;
-       struct drm_connector *connector;
-
-       list_for_each_entry(connector, &mode_config->connector_list, head) {
-               struct psb_intel_output *psb_intel_output =
-                   to_psb_intel_output(connector);
-
-               if (!connector->encoder
-                   || connector->encoder->crtc != crtc)
-                       continue;
-
-               switch (psb_intel_output->type) {
-               case INTEL_OUTPUT_LVDS:
-                       is_lvds = true;
-                       break;
-               case INTEL_OUTPUT_SDVO:
-                       is_sdvo = true;
-                       break;
-               case INTEL_OUTPUT_DVO:
-                       is_dvo = true;
-                       break;
-               case INTEL_OUTPUT_TVOUT:
-                       is_tv = true;
-                       break;
-               case INTEL_OUTPUT_ANALOG:
-                       is_crt = true;
-                       break;
-               case INTEL_OUTPUT_HDMI:
-                       is_hdmi = true;
-                       break;
-               }
-       }
-
-       refclk = 96000;
-
-       /* Hack selection about ref clk for CRT */
-       /* Select 27MHz as the reference clk for HDMI */
-       if (is_crt || is_hdmi)
-               refclk = 27000;
-
-       drm_mode_debug_printmodeline(adjusted_mode);
-
-       ok = cdv_intel_find_best_PLL(crtc, adjusted_mode->clock, refclk,
-                                &clock);
-       if (!ok) {
-               dev_err(dev->dev, "Couldn't find PLL settings for mode!\n");
-               return 0;
-       }
-
-       dpll = DPLL_VGA_MODE_DIS;
-       if (is_tv) {
-               /* XXX: just matching BIOS for now */
-/*     dpll |= PLL_REF_INPUT_TVCLKINBC; */
-               dpll |= 3;
-       }
-               dpll |= PLL_REF_INPUT_DREFCLK;
-
-       dpll |= DPLL_SYNCLOCK_ENABLE;
-       dpll |= DPLL_VGA_MODE_DIS;
-       if (is_lvds)
-               dpll |= DPLLB_MODE_LVDS;
-       else
-               dpll |= DPLLB_MODE_DAC_SERIAL;
-       /* dpll |= (2 << 11); */
-
-       /* setup pipeconf */
-       pipeconf = REG_READ(pipeconf_reg);
-
-       /* Set up the display plane register */
-       dspcntr = DISPPLANE_GAMMA_ENABLE;
-
-       if (pipe == 0)
-               dspcntr |= DISPPLANE_SEL_PIPE_A;
-       else
-               dspcntr |= DISPPLANE_SEL_PIPE_B;
-
-       dspcntr |= DISPLAY_PLANE_ENABLE;
-       pipeconf |= PIPEACONF_ENABLE;
-
-       REG_WRITE(dpll_reg, dpll | DPLL_VGA_MODE_DIS | DPLL_SYNCLOCK_ENABLE);
-       REG_READ(dpll_reg);
-
-       cdv_dpll_set_clock_cdv(dev, crtc, &clock);
-
-       udelay(150);
-
-
-       /* The LVDS pin pair needs to be on before the DPLLs are enabled.
-        * This is an exception to the general rule that mode_set doesn't turn
-        * things on.
-        */
-       if (is_lvds) {
-               u32 lvds = REG_READ(LVDS);
-
-               lvds |=
-                   LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP |
-                   LVDS_PIPEB_SELECT;
-               /* Set the B0-B3 data pairs corresponding to
-                * whether we're going to
-                * set the DPLLs for dual-channel mode or not.
-                */
-               if (clock.p2 == 7)
-                       lvds |= LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP;
-               else
-                       lvds &= ~(LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP);
-
-               /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP)
-                * appropriately here, but we need to look more
-                * thoroughly into how panels behave in the two modes.
-                */
-
-               REG_WRITE(LVDS, lvds);
-               REG_READ(LVDS);
-       }
-
-       dpll |= DPLL_VCO_ENABLE;
-
-       /* Disable the panel fitter if it was on our pipe */
-       if (cdv_intel_panel_fitter_pipe(dev) == pipe)
-               REG_WRITE(PFIT_CONTROL, 0);
-
-       DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B');
-       drm_mode_debug_printmodeline(mode);
-
-       REG_WRITE(dpll_reg,
-               (REG_READ(dpll_reg) & ~DPLL_LOCK) | DPLL_VCO_ENABLE);
-       REG_READ(dpll_reg);
-       /* Wait for the clocks to stabilize. */
-       udelay(150); /* 42 usec w/o calibration, 110 with.  rounded up. */
-
-       if (!(REG_READ(dpll_reg) & DPLL_LOCK)) {
-               dev_err(dev->dev, "Failed to get DPLL lock\n");
-               return -EBUSY;
-       }
-
-       {
-               int sdvo_pixel_multiply = adjusted_mode->clock / mode->clock;
-               REG_WRITE(dpll_md_reg, (0 << DPLL_MD_UDI_DIVIDER_SHIFT) | ((sdvo_pixel_multiply - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT));
-       }
-
-       REG_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) |
-                 ((adjusted_mode->crtc_htotal - 1) << 16));
-       REG_WRITE(hblank_reg, (adjusted_mode->crtc_hblank_start - 1) |
-                 ((adjusted_mode->crtc_hblank_end - 1) << 16));
-       REG_WRITE(hsync_reg, (adjusted_mode->crtc_hsync_start - 1) |
-                 ((adjusted_mode->crtc_hsync_end - 1) << 16));
-       REG_WRITE(vtot_reg, (adjusted_mode->crtc_vdisplay - 1) |
-                 ((adjusted_mode->crtc_vtotal - 1) << 16));
-       REG_WRITE(vblank_reg, (adjusted_mode->crtc_vblank_start - 1) |
-                 ((adjusted_mode->crtc_vblank_end - 1) << 16));
-       REG_WRITE(vsync_reg, (adjusted_mode->crtc_vsync_start - 1) |
-                 ((adjusted_mode->crtc_vsync_end - 1) << 16));
-       /* pipesrc and dspsize control the size that is scaled from,
-        * which should always be the user's requested size.
-        */
-       REG_WRITE(dspsize_reg,
-                 ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1));
-       REG_WRITE(dsppos_reg, 0);
-       REG_WRITE(pipesrc_reg,
-                 ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
-       REG_WRITE(pipeconf_reg, pipeconf);
-       REG_READ(pipeconf_reg);
-
-       cdv_intel_wait_for_vblank(dev);
-
-       REG_WRITE(dspcntr_reg, dspcntr);
-
-       /* Flush the plane changes */
-       {
-               struct drm_crtc_helper_funcs *crtc_funcs =
-                   crtc->helper_private;
-               crtc_funcs->mode_set_base(crtc, x, y, old_fb);
-       }
-
-       cdv_intel_wait_for_vblank(dev);
-
-       return 0;
-}
-
-/** Loads the palette/gamma unit for the CRTC with the prepared values */
-void cdv_intel_crtc_load_lut(struct drm_crtc *crtc)
-{
-       struct drm_device *dev = crtc->dev;
-       struct drm_psb_private *dev_priv =
-                               (struct drm_psb_private *)dev->dev_private;
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       int palreg = PALETTE_A;
-       int i;
-
-       /* The clocks have to be on to load the palette. */
-       if (!crtc->enabled)
-               return;
-
-       switch (psb_intel_crtc->pipe) {
-       case 0:
-               break;
-       case 1:
-               palreg = PALETTE_B;
-               break;
-       case 2:
-               palreg = PALETTE_C;
-               break;
-       default:
-               dev_err(dev->dev, "Illegal Pipe Number.\n");
-               return;
-       }
-
-       if (gma_power_begin(dev, false)) {
-               for (i = 0; i < 256; i++) {
-                       REG_WRITE(palreg + 4 * i,
-                                 ((psb_intel_crtc->lut_r[i] +
-                                 psb_intel_crtc->lut_adj[i]) << 16) |
-                                 ((psb_intel_crtc->lut_g[i] +
-                                 psb_intel_crtc->lut_adj[i]) << 8) |
-                                 (psb_intel_crtc->lut_b[i] +
-                                 psb_intel_crtc->lut_adj[i]));
-               }
-               gma_power_end(dev);
-       } else {
-               for (i = 0; i < 256; i++) {
-                       dev_priv->save_palette_a[i] =
-                                 ((psb_intel_crtc->lut_r[i] +
-                                 psb_intel_crtc->lut_adj[i]) << 16) |
-                                 ((psb_intel_crtc->lut_g[i] +
-                                 psb_intel_crtc->lut_adj[i]) << 8) |
-                                 (psb_intel_crtc->lut_b[i] +
-                                 psb_intel_crtc->lut_adj[i]);
-               }
-
-       }
-}
-
-/**
- * Save HW states of giving crtc
- */
-static void cdv_intel_crtc_save(struct drm_crtc *crtc)
-{
-       struct drm_device *dev = crtc->dev;
-       /* struct drm_psb_private *dev_priv =
-                       (struct drm_psb_private *)dev->dev_private; */
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state;
-       int pipeA = (psb_intel_crtc->pipe == 0);
-       uint32_t paletteReg;
-       int i;
-
-       if (!crtc_state) {
-               dev_dbg(dev->dev, "No CRTC state found\n");
-               return;
-       }
-
-       crtc_state->saveDSPCNTR = REG_READ(pipeA ? DSPACNTR : DSPBCNTR);
-       crtc_state->savePIPECONF = REG_READ(pipeA ? PIPEACONF : PIPEBCONF);
-       crtc_state->savePIPESRC = REG_READ(pipeA ? PIPEASRC : PIPEBSRC);
-       crtc_state->saveFP0 = REG_READ(pipeA ? FPA0 : FPB0);
-       crtc_state->saveFP1 = REG_READ(pipeA ? FPA1 : FPB1);
-       crtc_state->saveDPLL = REG_READ(pipeA ? DPLL_A : DPLL_B);
-       crtc_state->saveHTOTAL = REG_READ(pipeA ? HTOTAL_A : HTOTAL_B);
-       crtc_state->saveHBLANK = REG_READ(pipeA ? HBLANK_A : HBLANK_B);
-       crtc_state->saveHSYNC = REG_READ(pipeA ? HSYNC_A : HSYNC_B);
-       crtc_state->saveVTOTAL = REG_READ(pipeA ? VTOTAL_A : VTOTAL_B);
-       crtc_state->saveVBLANK = REG_READ(pipeA ? VBLANK_A : VBLANK_B);
-       crtc_state->saveVSYNC = REG_READ(pipeA ? VSYNC_A : VSYNC_B);
-       crtc_state->saveDSPSTRIDE = REG_READ(pipeA ? DSPASTRIDE : DSPBSTRIDE);
-
-       /*NOTE: DSPSIZE DSPPOS only for psb*/
-       crtc_state->saveDSPSIZE = REG_READ(pipeA ? DSPASIZE : DSPBSIZE);
-       crtc_state->saveDSPPOS = REG_READ(pipeA ? DSPAPOS : DSPBPOS);
-
-       crtc_state->saveDSPBASE = REG_READ(pipeA ? DSPABASE : DSPBBASE);
-
-       DRM_DEBUG("(%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n",
-                       crtc_state->saveDSPCNTR,
-                       crtc_state->savePIPECONF,
-                       crtc_state->savePIPESRC,
-                       crtc_state->saveFP0,
-                       crtc_state->saveFP1,
-                       crtc_state->saveDPLL,
-                       crtc_state->saveHTOTAL,
-                       crtc_state->saveHBLANK,
-                       crtc_state->saveHSYNC,
-                       crtc_state->saveVTOTAL,
-                       crtc_state->saveVBLANK,
-                       crtc_state->saveVSYNC,
-                       crtc_state->saveDSPSTRIDE,
-                       crtc_state->saveDSPSIZE,
-                       crtc_state->saveDSPPOS,
-                       crtc_state->saveDSPBASE
-               );
-
-       paletteReg = pipeA ? PALETTE_A : PALETTE_B;
-       for (i = 0; i < 256; ++i)
-               crtc_state->savePalette[i] = REG_READ(paletteReg + (i << 2));
-}
-
-/**
- * Restore HW states of giving crtc
- */
-static void cdv_intel_crtc_restore(struct drm_crtc *crtc)
-{
-       struct drm_device *dev = crtc->dev;
-       /* struct drm_psb_private * dev_priv =
-                               (struct drm_psb_private *)dev->dev_private; */
-       struct psb_intel_crtc *psb_intel_crtc =  to_psb_intel_crtc(crtc);
-       struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state;
-       /* struct drm_crtc_helper_funcs * crtc_funcs = crtc->helper_private; */
-       int pipeA = (psb_intel_crtc->pipe == 0);
-       uint32_t paletteReg;
-       int i;
-
-       if (!crtc_state) {
-               dev_dbg(dev->dev, "No crtc state\n");
-               return;
-       }
-
-       DRM_DEBUG(
-               "current:(%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n",
-               REG_READ(pipeA ? DSPACNTR : DSPBCNTR),
-               REG_READ(pipeA ? PIPEACONF : PIPEBCONF),
-               REG_READ(pipeA ? PIPEASRC : PIPEBSRC),
-               REG_READ(pipeA ? FPA0 : FPB0),
-               REG_READ(pipeA ? FPA1 : FPB1),
-               REG_READ(pipeA ? DPLL_A : DPLL_B),
-               REG_READ(pipeA ? HTOTAL_A : HTOTAL_B),
-               REG_READ(pipeA ? HBLANK_A : HBLANK_B),
-               REG_READ(pipeA ? HSYNC_A : HSYNC_B),
-               REG_READ(pipeA ? VTOTAL_A : VTOTAL_B),
-               REG_READ(pipeA ? VBLANK_A : VBLANK_B),
-               REG_READ(pipeA ? VSYNC_A : VSYNC_B),
-               REG_READ(pipeA ? DSPASTRIDE : DSPBSTRIDE),
-               REG_READ(pipeA ? DSPASIZE : DSPBSIZE),
-               REG_READ(pipeA ? DSPAPOS : DSPBPOS),
-               REG_READ(pipeA ? DSPABASE : DSPBBASE)
-               );
-
-       DRM_DEBUG(
-               "saved: (%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n",
-               crtc_state->saveDSPCNTR,
-               crtc_state->savePIPECONF,
-               crtc_state->savePIPESRC,
-               crtc_state->saveFP0,
-               crtc_state->saveFP1,
-               crtc_state->saveDPLL,
-               crtc_state->saveHTOTAL,
-               crtc_state->saveHBLANK,
-               crtc_state->saveHSYNC,
-               crtc_state->saveVTOTAL,
-               crtc_state->saveVBLANK,
-               crtc_state->saveVSYNC,
-               crtc_state->saveDSPSTRIDE,
-               crtc_state->saveDSPSIZE,
-               crtc_state->saveDSPPOS,
-               crtc_state->saveDSPBASE
-               );
-
-
-       if (crtc_state->saveDPLL & DPLL_VCO_ENABLE) {
-               REG_WRITE(pipeA ? DPLL_A : DPLL_B,
-                       crtc_state->saveDPLL & ~DPLL_VCO_ENABLE);
-               REG_READ(pipeA ? DPLL_A : DPLL_B);
-               DRM_DEBUG("write dpll: %x\n",
-                               REG_READ(pipeA ? DPLL_A : DPLL_B));
-               udelay(150);
-       }
-
-       REG_WRITE(pipeA ? FPA0 : FPB0, crtc_state->saveFP0);
-       REG_READ(pipeA ? FPA0 : FPB0);
-
-       REG_WRITE(pipeA ? FPA1 : FPB1, crtc_state->saveFP1);
-       REG_READ(pipeA ? FPA1 : FPB1);
-
-       REG_WRITE(pipeA ? DPLL_A : DPLL_B, crtc_state->saveDPLL);
-       REG_READ(pipeA ? DPLL_A : DPLL_B);
-       udelay(150);
-
-       REG_WRITE(pipeA ? HTOTAL_A : HTOTAL_B, crtc_state->saveHTOTAL);
-       REG_WRITE(pipeA ? HBLANK_A : HBLANK_B, crtc_state->saveHBLANK);
-       REG_WRITE(pipeA ? HSYNC_A : HSYNC_B, crtc_state->saveHSYNC);
-       REG_WRITE(pipeA ? VTOTAL_A : VTOTAL_B, crtc_state->saveVTOTAL);
-       REG_WRITE(pipeA ? VBLANK_A : VBLANK_B, crtc_state->saveVBLANK);
-       REG_WRITE(pipeA ? VSYNC_A : VSYNC_B, crtc_state->saveVSYNC);
-       REG_WRITE(pipeA ? DSPASTRIDE : DSPBSTRIDE, crtc_state->saveDSPSTRIDE);
-
-       REG_WRITE(pipeA ? DSPASIZE : DSPBSIZE, crtc_state->saveDSPSIZE);
-       REG_WRITE(pipeA ? DSPAPOS : DSPBPOS, crtc_state->saveDSPPOS);
-
-       REG_WRITE(pipeA ? PIPEASRC : PIPEBSRC, crtc_state->savePIPESRC);
-       REG_WRITE(pipeA ? DSPABASE : DSPBBASE, crtc_state->saveDSPBASE);
-       REG_WRITE(pipeA ? PIPEACONF : PIPEBCONF, crtc_state->savePIPECONF);
-
-       cdv_intel_wait_for_vblank(dev);
-
-       REG_WRITE(pipeA ? DSPACNTR : DSPBCNTR, crtc_state->saveDSPCNTR);
-       REG_WRITE(pipeA ? DSPABASE : DSPBBASE, crtc_state->saveDSPBASE);
-
-       cdv_intel_wait_for_vblank(dev);
-
-       paletteReg = pipeA ? PALETTE_A : PALETTE_B;
-       for (i = 0; i < 256; ++i)
-               REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]);
-}
-
-static int cdv_intel_crtc_cursor_set(struct drm_crtc *crtc,
-                                struct drm_file *file_priv,
-                                uint32_t handle,
-                                uint32_t width, uint32_t height)
-{
-       struct drm_device *dev = crtc->dev;
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       int pipe = psb_intel_crtc->pipe;
-       uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR;
-       uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
-       uint32_t temp;
-       size_t addr = 0;
-       struct gtt_range *gt;
-       struct drm_gem_object *obj;
-       int ret;
-
-       /* if we want to turn of the cursor ignore width and height */
-       if (!handle) {
-               /* turn off the cursor */
-               temp = CURSOR_MODE_DISABLE;
-
-               if (gma_power_begin(dev, false)) {
-                       REG_WRITE(control, temp);
-                       REG_WRITE(base, 0);
-                       gma_power_end(dev);
-               }
-
-               /* unpin the old GEM object */
-               if (psb_intel_crtc->cursor_obj) {
-                       gt = container_of(psb_intel_crtc->cursor_obj,
-                                                       struct gtt_range, gem);
-                       psb_gtt_unpin(gt);
-                       drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
-                       psb_intel_crtc->cursor_obj = NULL;
-               }
-
-               return 0;
-       }
-
-       /* Currently we only support 64x64 cursors */
-       if (width != 64 || height != 64) {
-               dev_dbg(dev->dev, "we currently only support 64x64 cursors\n");
-               return -EINVAL;
-       }
-
-       obj = drm_gem_object_lookup(dev, file_priv, handle);
-       if (!obj)
-               return -ENOENT;
-
-       if (obj->size < width * height * 4) {
-               dev_dbg(dev->dev, "buffer is to small\n");
-               return -ENOMEM;
-       }
-
-       gt = container_of(obj, struct gtt_range, gem);
-
-       /* Pin the memory into the GTT */
-       ret = psb_gtt_pin(gt);
-       if (ret) {
-               dev_err(dev->dev, "Can not pin down handle 0x%x\n", handle);
-               return ret;
-       }
-
-       addr = gt->offset;      /* Or resource.start ??? */
-
-       psb_intel_crtc->cursor_addr = addr;
-
-       temp = 0;
-       /* set the pipe for the cursor */
-       temp |= (pipe << 28);
-       temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
-
-       if (gma_power_begin(dev, false)) {
-               REG_WRITE(control, temp);
-               REG_WRITE(base, addr);
-               gma_power_end(dev);
-       }
-
-       /* unpin the old GEM object */
-       if (psb_intel_crtc->cursor_obj) {
-               gt = container_of(psb_intel_crtc->cursor_obj,
-                                                       struct gtt_range, gem);
-               psb_gtt_unpin(gt);
-               drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
-               psb_intel_crtc->cursor_obj = obj;
-       }
-       return 0;
-}
-
-static int cdv_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
-{
-       struct drm_device *dev = crtc->dev;
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       int pipe = psb_intel_crtc->pipe;
-       uint32_t temp = 0;
-       uint32_t adder;
-
-
-       if (x < 0) {
-               temp |= (CURSOR_POS_SIGN << CURSOR_X_SHIFT);
-               x = -x;
-       }
-       if (y < 0) {
-               temp |= (CURSOR_POS_SIGN << CURSOR_Y_SHIFT);
-               y = -y;
-       }
-
-       temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT);
-       temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT);
-
-       adder = psb_intel_crtc->cursor_addr;
-
-       if (gma_power_begin(dev, false)) {
-               REG_WRITE((pipe == 0) ? CURAPOS : CURBPOS, temp);
-               REG_WRITE((pipe == 0) ? CURABASE : CURBBASE, adder);
-               gma_power_end(dev);
-       }
-       return 0;
-}
-
-static void cdv_intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
-                        u16 *green, u16 *blue, uint32_t start, uint32_t size)
-{
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       int i;
-       int end = (start + size > 256) ? 256 : start + size;
-
-       for (i = start; i < end; i++) {
-               psb_intel_crtc->lut_r[i] = red[i] >> 8;
-               psb_intel_crtc->lut_g[i] = green[i] >> 8;
-               psb_intel_crtc->lut_b[i] = blue[i] >> 8;
-       }
-
-       cdv_intel_crtc_load_lut(crtc);
-}
-
-static int cdv_crtc_set_config(struct drm_mode_set *set)
-{
-       int ret = 0;
-       struct drm_device *dev = set->crtc->dev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       if (!dev_priv->rpm_enabled)
-               return drm_crtc_helper_set_config(set);
-
-       pm_runtime_forbid(&dev->pdev->dev);
-
-       ret = drm_crtc_helper_set_config(set);
-
-       pm_runtime_allow(&dev->pdev->dev);
-
-       return ret;
-}
-
-/** Derive the pixel clock for the given refclk and divisors for 8xx chips. */
-
-/* FIXME: why are we using this, should it be cdv_ in this tree ? */
-
-static void i8xx_clock(int refclk, struct cdv_intel_clock_t *clock)
-{
-       clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2);
-       clock->p = clock->p1 * clock->p2;
-       clock->vco = refclk * clock->m / (clock->n + 2);
-       clock->dot = clock->vco / clock->p;
-}
-
-/* Returns the clock of the currently programmed mode of the given pipe. */
-static int cdv_intel_crtc_clock_get(struct drm_device *dev,
-                               struct drm_crtc *crtc)
-{
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       int pipe = psb_intel_crtc->pipe;
-       u32 dpll;
-       u32 fp;
-       struct cdv_intel_clock_t clock;
-       bool is_lvds;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       if (gma_power_begin(dev, false)) {
-               dpll = REG_READ((pipe == 0) ? DPLL_A : DPLL_B);
-               if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
-                       fp = REG_READ((pipe == 0) ? FPA0 : FPB0);
-               else
-                       fp = REG_READ((pipe == 0) ? FPA1 : FPB1);
-               is_lvds = (pipe == 1) && (REG_READ(LVDS) & LVDS_PORT_EN);
-               gma_power_end(dev);
-       } else {
-               dpll = (pipe == 0) ?
-                       dev_priv->saveDPLL_A : dev_priv->saveDPLL_B;
-
-               if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
-                       fp = (pipe == 0) ?
-                               dev_priv->saveFPA0 :
-                               dev_priv->saveFPB0;
-               else
-                       fp = (pipe == 0) ?
-                               dev_priv->saveFPA1 :
-                               dev_priv->saveFPB1;
-
-               is_lvds = (pipe == 1) && (dev_priv->saveLVDS & LVDS_PORT_EN);
-       }
-
-       clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT;
-       clock.m2 = (fp & FP_M2_DIV_MASK) >> FP_M2_DIV_SHIFT;
-       clock.n = (fp & FP_N_DIV_MASK) >> FP_N_DIV_SHIFT;
-
-       if (is_lvds) {
-               clock.p1 =
-                   ffs((dpll &
-                        DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS) >>
-                       DPLL_FPA01_P1_POST_DIV_SHIFT);
-               if (clock.p1 == 0) {
-                       clock.p1 = 4;
-                       dev_err(dev->dev, "PLL %d\n", dpll);
-               }
-               clock.p2 = 14;
-
-               if ((dpll & PLL_REF_INPUT_MASK) ==
-                   PLLB_REF_INPUT_SPREADSPECTRUMIN) {
-                       /* XXX: might not be 66MHz */
-                       i8xx_clock(66000, &clock);
-               } else
-                       i8xx_clock(48000, &clock);
-       } else {
-               if (dpll & PLL_P1_DIVIDE_BY_TWO)
-                       clock.p1 = 2;
-               else {
-                       clock.p1 =
-                           ((dpll &
-                             DPLL_FPA01_P1_POST_DIV_MASK_I830) >>
-                            DPLL_FPA01_P1_POST_DIV_SHIFT) + 2;
-               }
-               if (dpll & PLL_P2_DIVIDE_BY_4)
-                       clock.p2 = 4;
-               else
-                       clock.p2 = 2;
-
-               i8xx_clock(48000, &clock);
-       }
-
-       /* XXX: It would be nice to validate the clocks, but we can't reuse
-        * i830PllIsValid() because it relies on the xf86_config connector
-        * configuration being accurate, which it isn't necessarily.
-        */
-
-       return clock.dot;
-}
-
-/** Returns the currently programmed mode of the given pipe. */
-struct drm_display_mode *cdv_intel_crtc_mode_get(struct drm_device *dev,
-                                            struct drm_crtc *crtc)
-{
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       int pipe = psb_intel_crtc->pipe;
-       struct drm_display_mode *mode;
-       int htot;
-       int hsync;
-       int vtot;
-       int vsync;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       if (gma_power_begin(dev, false)) {
-               htot = REG_READ((pipe == 0) ? HTOTAL_A : HTOTAL_B);
-               hsync = REG_READ((pipe == 0) ? HSYNC_A : HSYNC_B);
-               vtot = REG_READ((pipe == 0) ? VTOTAL_A : VTOTAL_B);
-               vsync = REG_READ((pipe == 0) ? VSYNC_A : VSYNC_B);
-               gma_power_end(dev);
-       } else {
-               htot = (pipe == 0) ?
-                       dev_priv->saveHTOTAL_A : dev_priv->saveHTOTAL_B;
-               hsync = (pipe == 0) ?
-                       dev_priv->saveHSYNC_A : dev_priv->saveHSYNC_B;
-               vtot = (pipe == 0) ?
-                       dev_priv->saveVTOTAL_A : dev_priv->saveVTOTAL_B;
-               vsync = (pipe == 0) ?
-                       dev_priv->saveVSYNC_A : dev_priv->saveVSYNC_B;
-       }
-
-       mode = kzalloc(sizeof(*mode), GFP_KERNEL);
-       if (!mode)
-               return NULL;
-
-       mode->clock = cdv_intel_crtc_clock_get(dev, crtc);
-       mode->hdisplay = (htot & 0xffff) + 1;
-       mode->htotal = ((htot & 0xffff0000) >> 16) + 1;
-       mode->hsync_start = (hsync & 0xffff) + 1;
-       mode->hsync_end = ((hsync & 0xffff0000) >> 16) + 1;
-       mode->vdisplay = (vtot & 0xffff) + 1;
-       mode->vtotal = ((vtot & 0xffff0000) >> 16) + 1;
-       mode->vsync_start = (vsync & 0xffff) + 1;
-       mode->vsync_end = ((vsync & 0xffff0000) >> 16) + 1;
-
-       drm_mode_set_name(mode);
-       drm_mode_set_crtcinfo(mode, 0);
-
-       return mode;
-}
-
-static void cdv_intel_crtc_destroy(struct drm_crtc *crtc)
-{
-       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-
-       kfree(psb_intel_crtc->crtc_state);
-       drm_crtc_cleanup(crtc);
-       kfree(psb_intel_crtc);
-}
-
-const struct drm_crtc_helper_funcs cdv_intel_helper_funcs = {
-       .dpms = cdv_intel_crtc_dpms,
-       .mode_fixup = cdv_intel_crtc_mode_fixup,
-       .mode_set = cdv_intel_crtc_mode_set,
-       .mode_set_base = cdv_intel_pipe_set_base,
-       .prepare = cdv_intel_crtc_prepare,
-       .commit = cdv_intel_crtc_commit,
-};
-
-const struct drm_crtc_funcs cdv_intel_crtc_funcs = {
-       .save = cdv_intel_crtc_save,
-       .restore = cdv_intel_crtc_restore,
-       .cursor_set = cdv_intel_crtc_cursor_set,
-       .cursor_move = cdv_intel_crtc_cursor_move,
-       .gamma_set = cdv_intel_crtc_gamma_set,
-       .set_config = cdv_crtc_set_config,
-       .destroy = cdv_intel_crtc_destroy,
-};
-
-/*
- * Set the default value of cursor control and base register
- * to zero. This is a workaround for h/w defect on oaktrail
- */
-void cdv_intel_cursor_init(struct drm_device *dev, int pipe)
-{
-       uint32_t control;
-       uint32_t base;
-
-       switch (pipe) {
-       case 0:
-               control = CURACNTR;
-               base = CURABASE;
-               break;
-       case 1:
-               control = CURBCNTR;
-               base = CURBBASE;
-               break;
-       case 2:
-               control = CURCCNTR;
-               base = CURCBASE;
-               break;
-       default:
-               return;
-       }
-
-       REG_WRITE(control, 0);
-       REG_WRITE(base, 0);
-}
-
diff --git a/drivers/staging/gma500/cdv_intel_hdmi.c b/drivers/staging/gma500/cdv_intel_hdmi.c
deleted file mode 100644 (file)
index cbca2b0..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright © 2006-2011 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *     jim liu <jim.liu@intel.com>
- *
- * FIXME:
- *     We should probably make this generic and share it with Medfield
- */
-
-#include <drm/drmP.h>
-#include <drm/drm.h>
-#include <drm/drm_crtc.h>
-#include <drm/drm_edid.h>
-#include "psb_intel_drv.h"
-#include "psb_drv.h"
-#include "psb_intel_reg.h"
-#include <linux/pm_runtime.h>
-
-/* hdmi control bits */
-#define HDMI_NULL_PACKETS_DURING_VSYNC (1 << 9)
-#define HDMI_BORDER_ENABLE             (1 << 7)
-#define HDMI_AUDIO_ENABLE              (1 << 6)
-#define HDMI_VSYNC_ACTIVE_HIGH         (1 << 4)
-#define HDMI_HSYNC_ACTIVE_HIGH         (1 << 3)
-/* hdmi-b control bits */
-#define        HDMIB_PIPE_B_SELECT             (1 << 30)
-
-
-struct mid_intel_hdmi_priv {
-       u32 hdmi_reg;
-       u32 save_HDMIB;
-       bool has_hdmi_sink;
-       bool has_hdmi_audio;
-       /* Should set this when detect hotplug */
-       bool hdmi_device_connected;
-       struct mdfld_hdmi_i2c *i2c_bus;
-       struct i2c_adapter *hdmi_i2c_adapter;   /* for control functions */
-       struct drm_device *dev;
-};
-
-static void cdv_hdmi_mode_set(struct drm_encoder *encoder,
-                       struct drm_display_mode *mode,
-                       struct drm_display_mode *adjusted_mode)
-{
-       struct drm_device *dev = encoder->dev;
-       struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
-       struct mid_intel_hdmi_priv *hdmi_priv = output->dev_priv;
-       u32 hdmib;
-       struct drm_crtc *crtc = encoder->crtc;
-       struct psb_intel_crtc *intel_crtc = to_psb_intel_crtc(crtc);
-
-       hdmib = (2 << 10);
-
-       if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
-               hdmib |= HDMI_VSYNC_ACTIVE_HIGH;
-       if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
-               hdmib |= HDMI_HSYNC_ACTIVE_HIGH;
-
-       if (intel_crtc->pipe == 1)
-               hdmib |= HDMIB_PIPE_B_SELECT;
-
-       if (hdmi_priv->has_hdmi_audio) {
-               hdmib |= HDMI_AUDIO_ENABLE;
-               hdmib |= HDMI_NULL_PACKETS_DURING_VSYNC;
-       }
-
-       REG_WRITE(hdmi_priv->hdmi_reg, hdmib);
-       REG_READ(hdmi_priv->hdmi_reg);
-}
-
-static bool cdv_hdmi_mode_fixup(struct drm_encoder *encoder,
-                                 struct drm_display_mode *mode,
-                                 struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
-static void cdv_hdmi_dpms(struct drm_encoder *encoder, int mode)
-{
-       struct drm_device *dev = encoder->dev;
-       struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
-       struct mid_intel_hdmi_priv *hdmi_priv = output->dev_priv;
-       u32 hdmib;
-
-       hdmib = REG_READ(hdmi_priv->hdmi_reg);
-
-       if (mode != DRM_MODE_DPMS_ON)
-               REG_WRITE(hdmi_priv->hdmi_reg, hdmib & ~HDMIB_PORT_EN);
-       else
-               REG_WRITE(hdmi_priv->hdmi_reg, hdmib | HDMIB_PORT_EN);
-       REG_READ(hdmi_priv->hdmi_reg);
-}
-
-static void cdv_hdmi_save(struct drm_connector *connector)
-{
-       struct drm_device *dev = connector->dev;
-       struct psb_intel_output *output = to_psb_intel_output(connector);
-       struct mid_intel_hdmi_priv *hdmi_priv = output->dev_priv;
-
-       hdmi_priv->save_HDMIB = REG_READ(hdmi_priv->hdmi_reg);
-}
-
-static void cdv_hdmi_restore(struct drm_connector *connector)
-{
-       struct drm_device *dev = connector->dev;
-       struct psb_intel_output *output = to_psb_intel_output(connector);
-       struct mid_intel_hdmi_priv *hdmi_priv = output->dev_priv;
-
-       REG_WRITE(hdmi_priv->hdmi_reg, hdmi_priv->save_HDMIB);
-       REG_READ(hdmi_priv->hdmi_reg);
-}
-
-static enum drm_connector_status cdv_hdmi_detect(
-                               struct drm_connector *connector, bool force)
-{
-       struct psb_intel_output *psb_intel_output =
-                                               to_psb_intel_output(connector);
-       struct mid_intel_hdmi_priv *hdmi_priv = psb_intel_output->dev_priv;
-       struct edid *edid = NULL;
-       enum drm_connector_status status = connector_status_disconnected;
-
-       edid = drm_get_edid(&psb_intel_output->base,
-                        psb_intel_output->hdmi_i2c_adapter);
-
-       hdmi_priv->has_hdmi_sink = false;
-       hdmi_priv->has_hdmi_audio = false;
-       if (edid) {
-               if (edid->input & DRM_EDID_INPUT_DIGITAL) {
-                       status = connector_status_connected;
-                       hdmi_priv->has_hdmi_sink =
-                                               drm_detect_hdmi_monitor(edid);
-                       hdmi_priv->has_hdmi_audio =
-                                               drm_detect_monitor_audio(edid);
-               }
-
-               psb_intel_output->base.display_info.raw_edid = NULL;
-               kfree(edid);
-       }
-       return status;
-}
-
-static int cdv_hdmi_set_property(struct drm_connector *connector,
-                                      struct drm_property *property,
-                                      uint64_t value)
-{
-       struct drm_encoder *encoder = connector->encoder;
-
-       if (!strcmp(property->name, "scaling mode") && encoder) {
-               struct psb_intel_crtc *crtc = to_psb_intel_crtc(encoder->crtc);
-               bool centre;
-               uint64_t curValue;
-
-               if (!crtc)
-                       return -1;
-
-               switch (value) {
-               case DRM_MODE_SCALE_FULLSCREEN:
-                       break;
-               case DRM_MODE_SCALE_NO_SCALE:
-                       break;
-               case DRM_MODE_SCALE_ASPECT:
-                       break;
-               default:
-                       return -1;
-               }
-
-               if (drm_connector_property_get_value(connector,
-                                                       property, &curValue))
-                       return -1;
-
-               if (curValue == value)
-                       return 0;
-
-               if (drm_connector_property_set_value(connector,
-                                                       property, value))
-                       return -1;
-
-               centre = (curValue == DRM_MODE_SCALE_NO_SCALE) ||
-                       (value == DRM_MODE_SCALE_NO_SCALE);
-
-               if (crtc->saved_mode.hdisplay != 0 &&
-                   crtc->saved_mode.vdisplay != 0) {
-                       if (centre) {
-                               if (!drm_crtc_helper_set_mode(encoder->crtc, &crtc->saved_mode,
-                                           encoder->crtc->x, encoder->crtc->y, encoder->crtc->fb))
-                                       return -1;
-                       } else {
-                               struct drm_encoder_helper_funcs *helpers
-                                                   = encoder->helper_private;
-                               helpers->mode_set(encoder, &crtc->saved_mode,
-                                            &crtc->saved_adjusted_mode);
-                       }
-               }
-       }
-       return 0;
-}
-
-/*
- * Return the list of HDMI DDC modes if available.
- */
-static int cdv_hdmi_get_modes(struct drm_connector *connector)
-{
-       struct psb_intel_output *psb_intel_output =
-                                       to_psb_intel_output(connector);
-       struct edid *edid = NULL;
-       int ret = 0;
-
-       edid = drm_get_edid(&psb_intel_output->base,
-                        psb_intel_output->hdmi_i2c_adapter);
-       if (edid) {
-               drm_mode_connector_update_edid_property(&psb_intel_output->
-                                                       base, edid);
-               ret = drm_add_edid_modes(&psb_intel_output->base, edid);
-               kfree(edid);
-       }
-       return ret;
-}
-
-static int cdv_hdmi_mode_valid(struct drm_connector *connector,
-                                struct drm_display_mode *mode)
-{
-
-       if (mode->clock > 165000)
-               return MODE_CLOCK_HIGH;
-       if (mode->clock < 20000)
-               return MODE_CLOCK_HIGH;
-
-       /* just in case */
-       if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
-               return MODE_NO_DBLESCAN;
-
-       /* just in case */
-       if (mode->flags & DRM_MODE_FLAG_INTERLACE)
-               return MODE_NO_INTERLACE;
-
-       /*
-        * FIXME: for now we limit the size to 1680x1050 on CDV, otherwise it
-        * will go beyond the stolen memory size allocated to the framebuffer
-        */
-       if (mode->hdisplay > 1680)
-               return MODE_PANEL;
-       if (mode->vdisplay > 1050)
-               return MODE_PANEL;
-       return MODE_OK;
-}
-
-static void cdv_hdmi_destroy(struct drm_connector *connector)
-{
-       struct psb_intel_output *psb_intel_output =
-                                       to_psb_intel_output(connector);
-
-       if (psb_intel_output->ddc_bus)
-               psb_intel_i2c_destroy(psb_intel_output->ddc_bus);
-       drm_sysfs_connector_remove(connector);
-       drm_connector_cleanup(connector);
-       kfree(connector);
-}
-
-static const struct drm_encoder_helper_funcs cdv_hdmi_helper_funcs = {
-       .dpms = cdv_hdmi_dpms,
-       .mode_fixup = cdv_hdmi_mode_fixup,
-       .prepare = psb_intel_encoder_prepare,
-       .mode_set = cdv_hdmi_mode_set,
-       .commit = psb_intel_encoder_commit,
-};
-
-static const struct drm_connector_helper_funcs
-                                       cdv_hdmi_connector_helper_funcs = {
-       .get_modes = cdv_hdmi_get_modes,
-       .mode_valid = cdv_hdmi_mode_valid,
-       .best_encoder = psb_intel_best_encoder,
-};
-
-static const struct drm_connector_funcs cdv_hdmi_connector_funcs = {
-       .dpms = drm_helper_connector_dpms,
-       .save = cdv_hdmi_save,
-       .restore = cdv_hdmi_restore,
-       .detect = cdv_hdmi_detect,
-       .fill_modes = drm_helper_probe_single_connector_modes,
-       .set_property = cdv_hdmi_set_property,
-       .destroy = cdv_hdmi_destroy,
-};
-
-void cdv_hdmi_init(struct drm_device *dev,
-                       struct psb_intel_mode_device *mode_dev, int reg)
-{
-       struct psb_intel_output *psb_intel_output;
-       struct drm_connector *connector;
-       struct drm_encoder *encoder;
-       struct mid_intel_hdmi_priv *hdmi_priv;
-       int ddc_bus;
-
-       psb_intel_output = kzalloc(sizeof(struct psb_intel_output) +
-                              sizeof(struct mid_intel_hdmi_priv), GFP_KERNEL);
-       if (!psb_intel_output)
-               return;
-
-       hdmi_priv = (struct mid_intel_hdmi_priv *)(psb_intel_output + 1);
-       psb_intel_output->mode_dev = mode_dev;
-       connector = &psb_intel_output->base;
-       encoder = &psb_intel_output->enc;
-       drm_connector_init(dev, &psb_intel_output->base,
-                          &cdv_hdmi_connector_funcs,
-                          DRM_MODE_CONNECTOR_DVID);
-
-       drm_encoder_init(dev, &psb_intel_output->enc, &psb_intel_lvds_enc_funcs,
-                        DRM_MODE_ENCODER_TMDS);
-
-       drm_mode_connector_attach_encoder(&psb_intel_output->base,
-                                         &psb_intel_output->enc);
-       psb_intel_output->type = INTEL_OUTPUT_HDMI;
-       hdmi_priv->hdmi_reg = reg;
-       hdmi_priv->has_hdmi_sink = false;
-       psb_intel_output->dev_priv = hdmi_priv;
-
-       drm_encoder_helper_add(encoder, &cdv_hdmi_helper_funcs);
-       drm_connector_helper_add(connector,
-                                &cdv_hdmi_connector_helper_funcs);
-       connector->display_info.subpixel_order = SubPixelHorizontalRGB;
-       connector->interlace_allowed = false;
-       connector->doublescan_allowed = false;
-
-       drm_connector_attach_property(connector,
-           dev->mode_config.scaling_mode_property, DRM_MODE_SCALE_FULLSCREEN);
-
-       switch (reg) {
-       case SDVOB:
-               ddc_bus = GPIOE;
-               break;
-       case SDVOC:
-               ddc_bus = GPIOD;
-               break;
-       default:
-               DRM_ERROR("unknown reg 0x%x for HDMI\n", reg);
-               goto failed_ddc;
-               break;
-       }
-
-       psb_intel_output->ddc_bus = psb_intel_i2c_create(dev,
-                               ddc_bus, (reg == SDVOB) ? "HDMIB" : "HDMIC");
-
-       if (!psb_intel_output->ddc_bus) {
-               dev_err(dev->dev, "No ddc adapter available!\n");
-               goto failed_ddc;
-       }
-       psb_intel_output->hdmi_i2c_adapter =
-                               &(psb_intel_output->ddc_bus->adapter);
-       hdmi_priv->dev = dev;
-       drm_sysfs_connector_add(connector);
-       return;
-
-failed_ddc:
-       drm_encoder_cleanup(&psb_intel_output->enc);
-       drm_connector_cleanup(&psb_intel_output->base);
-       kfree(psb_intel_output);
-}
diff --git a/drivers/staging/gma500/cdv_intel_lvds.c b/drivers/staging/gma500/cdv_intel_lvds.c
deleted file mode 100644 (file)
index 988b2d0..0000000
+++ /dev/null
@@ -1,721 +0,0 @@
-/*
- * Copyright © 2006-2011 Intel Corporation
- *
- * 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.
- *
- * Authors:
- *     Eric Anholt <eric@anholt.net>
- *     Dave Airlie <airlied@linux.ie>
- *     Jesse Barnes <jesse.barnes@intel.com>
- */
-
-#include <linux/i2c.h>
-#include <linux/dmi.h>
-#include <drm/drmP.h>
-
-#include "intel_bios.h"
-#include "psb_drv.h"
-#include "psb_intel_drv.h"
-#include "psb_intel_reg.h"
-#include "power.h"
-#include <linux/pm_runtime.h>
-#include "cdv_device.h"
-
-/**
- * LVDS I2C backlight control macros
- */
-#define BRIGHTNESS_MAX_LEVEL 100
-#define BRIGHTNESS_MASK 0xFF
-#define BLC_I2C_TYPE   0x01
-#define BLC_PWM_TYPT   0x02
-
-#define BLC_POLARITY_NORMAL 0
-#define BLC_POLARITY_INVERSE 1
-
-#define PSB_BLC_MAX_PWM_REG_FREQ       (0xFFFE)
-#define PSB_BLC_MIN_PWM_REG_FREQ       (0x2)
-#define PSB_BLC_PWM_PRECISION_FACTOR   (10)
-#define PSB_BACKLIGHT_PWM_CTL_SHIFT    (16)
-#define PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR (0xFFFE)
-
-struct cdv_intel_lvds_priv {
-       /**
-        * Saved LVDO output states
-        */
-       uint32_t savePP_ON;
-       uint32_t savePP_OFF;
-       uint32_t saveLVDS;
-       uint32_t savePP_CONTROL;
-       uint32_t savePP_CYCLE;
-       uint32_t savePFIT_CONTROL;
-       uint32_t savePFIT_PGM_RATIOS;
-       uint32_t saveBLC_PWM_CTL;
-};
-
-/*
- * Returns the maximum level of the backlight duty cycle field.
- */
-static u32 cdv_intel_lvds_get_max_backlight(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       u32 retval;
-
-       if (gma_power_begin(dev, false)) {
-               retval = ((REG_READ(BLC_PWM_CTL) &
-                         BACKLIGHT_MODULATION_FREQ_MASK) >>
-                         BACKLIGHT_MODULATION_FREQ_SHIFT) * 2;
-
-               gma_power_end(dev);
-       } else
-               retval = ((dev_priv->saveBLC_PWM_CTL &
-                         BACKLIGHT_MODULATION_FREQ_MASK) >>
-                         BACKLIGHT_MODULATION_FREQ_SHIFT) * 2;
-
-       return retval;
-}
-
-/*
- * Set LVDS backlight level by I2C command
- */
-static int cdv_lvds_i2c_set_brightness(struct drm_device *dev,
-                                       unsigned int level)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct psb_intel_i2c_chan *lvds_i2c_bus = dev_priv->lvds_i2c_bus;
-       u8 out_buf[2];
-       unsigned int blc_i2c_brightness;
-
-       struct i2c_msg msgs[] = {
-               {
-                       .addr = lvds_i2c_bus->slave_addr,
-                       .flags = 0,
-                       .len = 2,
-                       .buf = out_buf,
-               }
-       };
-
-       blc_i2c_brightness = BRIGHTNESS_MASK & ((unsigned int)level *
-                            BRIGHTNESS_MASK /
-                            BRIGHTNESS_MAX_LEVEL);
-
-       if (dev_priv->lvds_bl->pol == BLC_POLARITY_INVERSE)
-               blc_i2c_brightness = BRIGHTNESS_MASK - blc_i2c_brightness;
-
-       out_buf[0] = dev_priv->lvds_bl->brightnesscmd;
-       out_buf[1] = (u8)blc_i2c_brightness;
-
-       if (i2c_transfer(&lvds_i2c_bus->adapter, msgs, 1) == 1)
-               return 0;
-
-       DRM_ERROR("I2C transfer error\n");
-       return -1;
-}
-
-
-static int cdv_lvds_pwm_set_brightness(struct drm_device *dev, int level)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       u32 max_pwm_blc;
-       u32 blc_pwm_duty_cycle;
-
-       max_pwm_blc = cdv_intel_lvds_get_max_backlight(dev);
-
-       /*BLC_PWM_CTL Should be initiated while backlight device init*/
-       BUG_ON((max_pwm_blc & PSB_BLC_MAX_PWM_REG_FREQ) == 0);
-
-       blc_pwm_duty_cycle = level * max_pwm_blc / BRIGHTNESS_MAX_LEVEL;
-
-       if (dev_priv->lvds_bl->pol == BLC_POLARITY_INVERSE)
-               blc_pwm_duty_cycle = max_pwm_blc - blc_pwm_duty_cycle;
-
-       blc_pwm_duty_cycle &= PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR;
-       REG_WRITE(BLC_PWM_CTL,
-                 (max_pwm_blc << PSB_BACKLIGHT_PWM_CTL_SHIFT) |
-                 (blc_pwm_duty_cycle));
-
-       return 0;
-}
-
-/*
- * Set LVDS backlight level either by I2C or PWM
- */
-void cdv_intel_lvds_set_brightness(struct drm_device *dev, int level)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       if (!dev_priv->lvds_bl) {
-               DRM_ERROR("NO LVDS Backlight Info\n");
-               return;
-       }
-
-       if (dev_priv->lvds_bl->type == BLC_I2C_TYPE)
-               cdv_lvds_i2c_set_brightness(dev, level);
-       else
-               cdv_lvds_pwm_set_brightness(dev, level);
-}
-
-/**
- * Sets the backlight level.
- *
- * level backlight level, from 0 to cdv_intel_lvds_get_max_backlight().
- */
-static void cdv_intel_lvds_set_backlight(struct drm_device *dev, int level)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       u32 blc_pwm_ctl;
-
-       if (gma_power_begin(dev, false)) {
-               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)));
-               gma_power_end(dev);
-       } else {
-               blc_pwm_ctl = dev_priv->saveBLC_PWM_CTL &
-                               ~BACKLIGHT_DUTY_CYCLE_MASK;
-               dev_priv->saveBLC_PWM_CTL = (blc_pwm_ctl |
-                                       (level << BACKLIGHT_DUTY_CYCLE_SHIFT));
-       }
-}
-
-/**
- * Sets the power state for the panel.
- */
-static void cdv_intel_lvds_set_power(struct drm_device *dev,
-                                struct psb_intel_output *output, bool on)
-{
-       u32 pp_status;
-
-       if (!gma_power_begin(dev, true))
-               return;
-
-       if (on) {
-               REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) |
-                         POWER_TARGET_ON);
-               do {
-                       pp_status = REG_READ(PP_STATUS);
-               } while ((pp_status & PP_ON) == 0);
-
-               cdv_intel_lvds_set_backlight(dev,
-                                        output->
-                                        mode_dev->backlight_duty_cycle);
-       } else {
-               cdv_intel_lvds_set_backlight(dev, 0);
-
-               REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) &
-                         ~POWER_TARGET_ON);
-               do {
-                       pp_status = REG_READ(PP_STATUS);
-               } while (pp_status & PP_ON);
-       }
-       gma_power_end(dev);
-}
-
-static void cdv_intel_lvds_encoder_dpms(struct drm_encoder *encoder, int mode)
-{
-       struct drm_device *dev = encoder->dev;
-       struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
-       if (mode == DRM_MODE_DPMS_ON)
-               cdv_intel_lvds_set_power(dev, output, true);
-       else
-               cdv_intel_lvds_set_power(dev, output, false);
-       /* XXX: We never power down the LVDS pairs. */
-}
-
-static void cdv_intel_lvds_save(struct drm_connector *connector)
-{
-}
-
-static void cdv_intel_lvds_restore(struct drm_connector *connector)
-{
-}
-
-int cdv_intel_lvds_mode_valid(struct drm_connector *connector,
-                                struct drm_display_mode *mode)
-{
-       struct psb_intel_output *psb_intel_output =
-                               to_psb_intel_output(connector);
-       struct drm_display_mode *fixed_mode =
-           psb_intel_output->mode_dev->panel_fixed_mode;
-
-       /* just in case */
-       if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
-               return MODE_NO_DBLESCAN;
-
-       /* just in case */
-       if (mode->flags & DRM_MODE_FLAG_INTERLACE)
-               return MODE_NO_INTERLACE;
-
-       if (fixed_mode) {
-               if (mode->hdisplay > fixed_mode->hdisplay)
-                       return MODE_PANEL;
-               if (mode->vdisplay > fixed_mode->vdisplay)
-                       return MODE_PANEL;
-       }
-       return MODE_OK;
-}
-
-bool cdv_intel_lvds_mode_fixup(struct drm_encoder *encoder,
-                                 struct drm_display_mode *mode,
-                                 struct drm_display_mode *adjusted_mode)
-{
-       struct psb_intel_mode_device *mode_dev =
-           enc_to_psb_intel_output(encoder)->mode_dev;
-       struct drm_device *dev = encoder->dev;
-       struct drm_encoder *tmp_encoder;
-       struct drm_display_mode *panel_fixed_mode = mode_dev->panel_fixed_mode;
-
-       /* Should never happen!! */
-       list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list,
-                           head) {
-               if (tmp_encoder != encoder
-                   && tmp_encoder->crtc == encoder->crtc) {
-                       printk(KERN_ERR "Can't enable LVDS and another "
-                              "encoder on the same pipe\n");
-                       return false;
-               }
-       }
-
-       /*
-        * If we have timings from the BIOS for the panel, put them in
-        * to the adjusted mode.  The CRTC will be set up for this mode,
-        * with the panel scaling set up to source from the H/VDisplay
-        * of the original mode.
-        */
-       if (panel_fixed_mode != NULL) {
-               adjusted_mode->hdisplay = panel_fixed_mode->hdisplay;
-               adjusted_mode->hsync_start = panel_fixed_mode->hsync_start;
-               adjusted_mode->hsync_end = panel_fixed_mode->hsync_end;
-               adjusted_mode->htotal = panel_fixed_mode->htotal;
-               adjusted_mode->vdisplay = panel_fixed_mode->vdisplay;
-               adjusted_mode->vsync_start = panel_fixed_mode->vsync_start;
-               adjusted_mode->vsync_end = panel_fixed_mode->vsync_end;
-               adjusted_mode->vtotal = panel_fixed_mode->vtotal;
-               adjusted_mode->clock = panel_fixed_mode->clock;
-               drm_mode_set_crtcinfo(adjusted_mode,
-                                     CRTC_INTERLACE_HALVE_V);
-       }
-
-       /*
-        * XXX: It would be nice to support lower refresh rates on the
-        * panels to reduce power consumption, and perhaps match the
-        * user's requested refresh rate.
-        */
-
-       return true;
-}
-
-static void cdv_intel_lvds_prepare(struct drm_encoder *encoder)
-{
-       struct drm_device *dev = encoder->dev;
-       struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
-       struct psb_intel_mode_device *mode_dev = output->mode_dev;
-
-       if (!gma_power_begin(dev, true))
-               return;
-
-       mode_dev->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL);
-       mode_dev->backlight_duty_cycle = (mode_dev->saveBLC_PWM_CTL &
-                                         BACKLIGHT_DUTY_CYCLE_MASK);
-
-       cdv_intel_lvds_set_power(dev, output, false);
-
-       gma_power_end(dev);
-}
-
-static void cdv_intel_lvds_commit(struct drm_encoder *encoder)
-{
-       struct drm_device *dev = encoder->dev;
-       struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
-       struct psb_intel_mode_device *mode_dev = output->mode_dev;
-
-       if (mode_dev->backlight_duty_cycle == 0)
-               mode_dev->backlight_duty_cycle =
-                   cdv_intel_lvds_get_max_backlight(dev);
-
-       cdv_intel_lvds_set_power(dev, output, true);
-}
-
-static void cdv_intel_lvds_mode_set(struct drm_encoder *encoder,
-                               struct drm_display_mode *mode,
-                               struct drm_display_mode *adjusted_mode)
-{
-       struct drm_device *dev = encoder->dev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       u32 pfit_control;
-
-       /*
-        * The LVDS pin pair will already have been turned on in the
-        * cdv_intel_crtc_mode_set since it has a large impact on the DPLL
-        * settings.
-        */
-
-       /*
-        * Enable automatic panel scaling so that non-native modes fill the
-        * screen.  Should be enabled before the pipe is enabled, according to
-        * register description and PRM.
-        */
-       if (mode->hdisplay != adjusted_mode->hdisplay ||
-           mode->vdisplay != adjusted_mode->vdisplay)
-               pfit_control = (PFIT_ENABLE | VERT_AUTO_SCALE |
-                               HORIZ_AUTO_SCALE | VERT_INTERP_BILINEAR |
-                               HORIZ_INTERP_BILINEAR);
-       else
-               pfit_control = 0;
-
-       if (dev_priv->lvds_dither)
-               pfit_control |= PANEL_8TO6_DITHER_ENABLE;
-
-       REG_WRITE(PFIT_CONTROL, pfit_control);
-}
-
-/**
- * Detect the LVDS connection.
- *
- * This always returns CONNECTOR_STATUS_CONNECTED.
- * This connector should only have
- * been set up if the LVDS was actually connected anyway.
- */
-static enum drm_connector_status cdv_intel_lvds_detect(
-                               struct drm_connector *connector, bool force)
-{
-       return connector_status_connected;
-}
-
-/**
- * Return the list of DDC modes if available, or the BIOS fixed mode otherwise.
- */
-static int cdv_intel_lvds_get_modes(struct drm_connector *connector)
-{
-       struct drm_device *dev = connector->dev;
-       struct psb_intel_output *psb_intel_output =
-                                       to_psb_intel_output(connector);
-       struct psb_intel_mode_device *mode_dev =
-                                       psb_intel_output->mode_dev;
-       int ret;
-
-       ret = psb_intel_ddc_get_modes(psb_intel_output);
-
-       if (ret)
-               return ret;
-
-       /* Didn't get an EDID, so
-        * Set wide sync ranges so we get all modes
-        * handed to valid_mode for checking
-        */
-       connector->display_info.min_vfreq = 0;
-       connector->display_info.max_vfreq = 200;
-       connector->display_info.min_hfreq = 0;
-       connector->display_info.max_hfreq = 200;
-       if (mode_dev->panel_fixed_mode != NULL) {
-               struct drm_display_mode *mode =
-                   drm_mode_duplicate(dev, mode_dev->panel_fixed_mode);
-               drm_mode_probed_add(connector, mode);
-               return 1;
-       }
-
-       return 0;
-}
-
-/**
- * cdv_intel_lvds_destroy - unregister and free LVDS structures
- * @connector: connector to free
- *
- * Unregister the DDC bus for this connector then free the driver private
- * structure.
- */
-void cdv_intel_lvds_destroy(struct drm_connector *connector)
-{
-       struct psb_intel_output *psb_intel_output =
-                                       to_psb_intel_output(connector);
-
-       if (psb_intel_output->ddc_bus)
-               psb_intel_i2c_destroy(psb_intel_output->ddc_bus);
-       drm_sysfs_connector_remove(connector);
-       drm_connector_cleanup(connector);
-       kfree(connector);
-}
-
-int cdv_intel_lvds_set_property(struct drm_connector *connector,
-                                      struct drm_property *property,
-                                      uint64_t value)
-{
-       struct drm_encoder *encoder = connector->encoder;
-
-       if (!strcmp(property->name, "scaling mode") && encoder) {
-               struct psb_intel_crtc *crtc =
-                                       to_psb_intel_crtc(encoder->crtc);
-               uint64_t curValue;
-
-               if (!crtc)
-                       return -1;
-
-               switch (value) {
-               case DRM_MODE_SCALE_FULLSCREEN:
-                       break;
-               case DRM_MODE_SCALE_NO_SCALE:
-                       break;
-               case DRM_MODE_SCALE_ASPECT:
-                       break;
-               default:
-                       return -1;
-               }
-
-               if (drm_connector_property_get_value(connector,
-                                                    property,
-                                                    &curValue))
-                       return -1;
-
-               if (curValue == value)
-                       return 0;
-
-               if (drm_connector_property_set_value(connector,
-                                                       property,
-                                                       value))
-                       return -1;
-
-               if (crtc->saved_mode.hdisplay != 0 &&
-                   crtc->saved_mode.vdisplay != 0) {
-                       if (!drm_crtc_helper_set_mode(encoder->crtc,
-                                                     &crtc->saved_mode,
-                                                     encoder->crtc->x,
-                                                     encoder->crtc->y,
-                                                     encoder->crtc->fb))
-                               return -1;
-               }
-       } else if (!strcmp(property->name, "backlight") && encoder) {
-               if (drm_connector_property_set_value(connector,
-                                                       property,
-                                                       value))
-                       return -1;
-               else {
-#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-                       struct drm_psb_private *dev_priv =
-                                               encoder->dev->dev_private;
-                       struct backlight_device *bd =
-                                               dev_priv->backlight_device;
-                       bd->props.brightness = value;
-                       backlight_update_status(bd);
-#endif
-               }
-       } else if (!strcmp(property->name, "DPMS") && encoder) {
-               struct drm_encoder_helper_funcs *helpers =
-                                       encoder->helper_private;
-               helpers->dpms(encoder, value);
-       }
-       return 0;
-}
-
-static const struct drm_encoder_helper_funcs
-                                       cdv_intel_lvds_helper_funcs = {
-       .dpms = cdv_intel_lvds_encoder_dpms,
-       .mode_fixup = cdv_intel_lvds_mode_fixup,
-       .prepare = cdv_intel_lvds_prepare,
-       .mode_set = cdv_intel_lvds_mode_set,
-       .commit = cdv_intel_lvds_commit,
-};
-
-static const struct drm_connector_helper_funcs
-                               cdv_intel_lvds_connector_helper_funcs = {
-       .get_modes = cdv_intel_lvds_get_modes,
-       .mode_valid = cdv_intel_lvds_mode_valid,
-       .best_encoder = psb_intel_best_encoder,
-};
-
-static const struct drm_connector_funcs cdv_intel_lvds_connector_funcs = {
-       .dpms = drm_helper_connector_dpms,
-       .save = cdv_intel_lvds_save,
-       .restore = cdv_intel_lvds_restore,
-       .detect = cdv_intel_lvds_detect,
-       .fill_modes = drm_helper_probe_single_connector_modes,
-       .set_property = cdv_intel_lvds_set_property,
-       .destroy = cdv_intel_lvds_destroy,
-};
-
-
-static void cdv_intel_lvds_enc_destroy(struct drm_encoder *encoder)
-{
-       drm_encoder_cleanup(encoder);
-}
-
-const struct drm_encoder_funcs cdv_intel_lvds_enc_funcs = {
-       .destroy = cdv_intel_lvds_enc_destroy,
-};
-
-/**
- * cdv_intel_lvds_init - setup LVDS connectors on this device
- * @dev: drm device
- *
- * Create the connector, register the LVDS DDC bus, and try to figure out what
- * modes we can display on the LVDS panel (if present).
- */
-void cdv_intel_lvds_init(struct drm_device *dev,
-                    struct psb_intel_mode_device *mode_dev)
-{
-       struct psb_intel_output *psb_intel_output;
-       struct cdv_intel_lvds_priv *lvds_priv;
-       struct drm_connector *connector;
-       struct drm_encoder *encoder;
-       struct drm_display_mode *scan;
-       struct drm_crtc *crtc;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       u32 lvds;
-       int pipe;
-
-       psb_intel_output = kzalloc(sizeof(struct psb_intel_output) +
-                       sizeof(struct cdv_intel_lvds_priv), GFP_KERNEL);
-       if (!psb_intel_output)
-               return;
-
-       lvds_priv = (struct cdv_intel_lvds_priv *)(psb_intel_output + 1);
-
-       psb_intel_output->dev_priv = lvds_priv;
-
-       psb_intel_output->mode_dev = mode_dev;
-       connector = &psb_intel_output->base;
-       encoder = &psb_intel_output->enc;
-
-
-       drm_connector_init(dev, &psb_intel_output->base,
-                          &cdv_intel_lvds_connector_funcs,
-                          DRM_MODE_CONNECTOR_LVDS);
-
-       drm_encoder_init(dev, &psb_intel_output->enc,
-                        &cdv_intel_lvds_enc_funcs,
-                        DRM_MODE_ENCODER_LVDS);
-
-
-       drm_mode_connector_attach_encoder(&psb_intel_output->base,
-                                         &psb_intel_output->enc);
-       psb_intel_output->type = INTEL_OUTPUT_LVDS;
-
-       drm_encoder_helper_add(encoder, &cdv_intel_lvds_helper_funcs);
-       drm_connector_helper_add(connector,
-                                &cdv_intel_lvds_connector_helper_funcs);
-       connector->display_info.subpixel_order = SubPixelHorizontalRGB;
-       connector->interlace_allowed = false;
-       connector->doublescan_allowed = false;
-
-       /*Attach connector properties*/
-       drm_connector_attach_property(connector,
-                                     dev->mode_config.scaling_mode_property,
-                                     DRM_MODE_SCALE_FULLSCREEN);
-       drm_connector_attach_property(connector,
-                                     dev_priv->backlight_property,
-                                     BRIGHTNESS_MAX_LEVEL);
-
-       /**
-        * Set up I2C bus
-        * FIXME: distroy i2c_bus when exit
-        */
-       psb_intel_output->i2c_bus = psb_intel_i2c_create(dev,
-                                                        GPIOB,
-                                                        "LVDSBLC_B");
-       if (!psb_intel_output->i2c_bus) {
-               dev_printk(KERN_ERR,
-                       &dev->pdev->dev, "I2C bus registration failed.\n");
-               goto failed_blc_i2c;
-       }
-       psb_intel_output->i2c_bus->slave_addr = 0x2C;
-       dev_priv->lvds_i2c_bus =  psb_intel_output->i2c_bus;
-
-       /*
-        * LVDS discovery:
-        * 1) check for EDID on DDC
-        * 2) check for VBT data
-        * 3) check to see if LVDS is already on
-        *    if none of the above, no panel
-        * 4) make sure lid is open
-        *    if closed, act like it's not there for now
-        */
-
-       /* Set up the DDC bus. */
-       psb_intel_output->ddc_bus = psb_intel_i2c_create(dev,
-                                                        GPIOC,
-                                                        "LVDSDDC_C");
-       if (!psb_intel_output->ddc_bus) {
-               dev_printk(KERN_ERR, &dev->pdev->dev,
-                          "DDC bus registration " "failed.\n");
-               goto failed_ddc;
-       }
-
-       /*
-        * Attempt to get the fixed panel mode from DDC.  Assume that the
-        * preferred mode is the right one.
-        */
-       psb_intel_ddc_get_modes(psb_intel_output);
-       list_for_each_entry(scan, &connector->probed_modes, head) {
-               if (scan->type & DRM_MODE_TYPE_PREFERRED) {
-                       mode_dev->panel_fixed_mode =
-                           drm_mode_duplicate(dev, scan);
-                       goto out;       /* FIXME: check for quirks */
-               }
-       }
-
-       /* Failed to get EDID, what about VBT? do we need this?*/
-       if (dev_priv->lfp_lvds_vbt_mode) {
-               mode_dev->panel_fixed_mode =
-                       drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
-               if (mode_dev->panel_fixed_mode) {
-                       mode_dev->panel_fixed_mode->type |=
-                               DRM_MODE_TYPE_PREFERRED;
-                       goto out;       /* FIXME: check for quirks */
-               }
-       }
-       /*
-        * If we didn't get EDID, try checking if the panel is already turned
-        * on.  If so, assume that whatever is currently programmed is the
-        * correct mode.
-        */
-       lvds = REG_READ(LVDS);
-       pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0;
-       crtc = psb_intel_get_crtc_from_pipe(dev, pipe);
-
-       if (crtc && (lvds & LVDS_PORT_EN)) {
-               mode_dev->panel_fixed_mode =
-                   cdv_intel_crtc_mode_get(dev, crtc);
-               if (mode_dev->panel_fixed_mode) {
-                       mode_dev->panel_fixed_mode->type |=
-                           DRM_MODE_TYPE_PREFERRED;
-                       goto out;       /* FIXME: check for quirks */
-               }
-       }
-
-       /* If we still don't have a mode after all that, give up. */
-       if (!mode_dev->panel_fixed_mode) {
-               DRM_DEBUG
-                       ("Found no modes on the lvds, ignoring the LVDS\n");
-               goto failed_find;
-       }
-
-out:
-       drm_sysfs_connector_add(connector);
-       return;
-
-failed_find:
-       printk(KERN_ERR "Failed find\n");
-       if (psb_intel_output->ddc_bus)
-               psb_intel_i2c_destroy(psb_intel_output->ddc_bus);
-failed_ddc:
-       printk(KERN_ERR "Failed DDC\n");
-       if (psb_intel_output->i2c_bus)
-               psb_intel_i2c_destroy(psb_intel_output->i2c_bus);
-failed_blc_i2c:
-       printk(KERN_ERR "Failed BLC\n");
-       drm_encoder_cleanup(encoder);
-       drm_connector_cleanup(connector);
-       kfree(connector);
-}
diff --git a/drivers/staging/gma500/displays/hdmi.h b/drivers/staging/gma500/displays/hdmi.h
deleted file mode 100644 (file)
index d58ba9b..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c)  2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Thomas Eaton <thomas.g.eaton@intel.com>
- * Scott Rowe <scott.m.rowe@intel.com>
- */
-
-#ifndef HDMI_H
-#define HDMI_H
-
-extern void hdmi_init(struct drm_device *dev);
-
-#endif
diff --git a/drivers/staging/gma500/displays/pyr_cmd.h b/drivers/staging/gma500/displays/pyr_cmd.h
deleted file mode 100644 (file)
index 84bae5c..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c)  2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicensen
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Thomas Eaton <thomas.g.eaton@intel.com>
- * Scott Rowe <scott.m.rowe@intel.com>
- */
-
-#ifndef PYR_CMD_H
-#define PYR_CMD_H
-
-extern void pyr_cmd_init(struct drm_device *dev, struct panel_funcs *p_funcs);
-
-#endif
-
diff --git a/drivers/staging/gma500/displays/pyr_vid.h b/drivers/staging/gma500/displays/pyr_vid.h
deleted file mode 100644 (file)
index ce98860..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c)  2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicensen
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Thomas Eaton <thomas.g.eaton@intel.com>
- * Scott Rowe <scott.m.rowe@intel.com>
-*/
-
-#ifndef PYR_VID_H
-#define PYR_VID_H
-
-extern void pyr_vid_init(struct drm_device *dev, struct panel_funcs *p_funcs);
-extern struct drm_display_mode *pyr_vid_get_config_mode(struct drm_device* dev);
-
-#endif
diff --git a/drivers/staging/gma500/displays/tmd_cmd.h b/drivers/staging/gma500/displays/tmd_cmd.h
deleted file mode 100644 (file)
index 641e85e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c)  2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicensen
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Thomas Eaton <thomas.g.eaton@intel.com>
- * Scott Rowe <scott.m.rowe@intel.com>
- */
-
-#ifndef TMD_CMD_H
-#define TMD_CMD_H
-
-extern void tmd_cmd_init(struct drm_device *dev, struct panel_funcs *p_funcs);
-extern struct drm_display_mode *tmd_cmd_get_config_mode(struct drm_device *dev);
-
-#endif
diff --git a/drivers/staging/gma500/displays/tmd_vid.h b/drivers/staging/gma500/displays/tmd_vid.h
deleted file mode 100644 (file)
index 7a5fa3b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c)  2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicensen
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Thomas Eaton <thomas.g.eaton@intel.com>
- * Scott Rowe <scott.m.rowe@intel.com>
-*/
-
-#ifndef TMD_VID_H
-#define TMD_VID_H
-
-extern void tmd_vid_init(struct drm_device *dev, struct panel_funcs *p_funcs);
-extern struct drm_display_mode *tmd_vid_get_config_mode(struct drm_device *dev);
-
-#endif
diff --git a/drivers/staging/gma500/displays/tpo_cmd.h b/drivers/staging/gma500/displays/tpo_cmd.h
deleted file mode 100644 (file)
index 6105527..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c)  2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicensen
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Thomas Eaton <thomas.g.eaton@intel.com>
- * Scott Rowe <scott.m.rowe@intel.com>
-*/
-
-#ifndef TPO_CMD_H
-#define TPO_CMD_H
-
-extern void tpo_cmd_init(struct drm_device *dev, struct panel_funcs *p_funcs);
-/* extern struct drm_display_mode * */
-/* tpo_cmd_get_config_mode(struct drm_device *dev); */
-
-#endif
diff --git a/drivers/staging/gma500/displays/tpo_vid.h b/drivers/staging/gma500/displays/tpo_vid.h
deleted file mode 100644 (file)
index c24f057..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c)  2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicensen
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Thomas Eaton <thomas.g.eaton@intel.com>
- * Scott Rowe <scott.m.rowe@intel.com>
- */
-
-#ifndef TPO_VID_H
-#define TPO_VID_H
-
-extern void tpo_vid_init(struct drm_device *dev, struct panel_funcs *p_funcs);
-
-#endif
diff --git a/drivers/staging/gma500/framebuffer.c b/drivers/staging/gma500/framebuffer.c
deleted file mode 100644 (file)
index b00761c..0000000
+++ /dev/null
@@ -1,856 +0,0 @@
-/**************************************************************************
- * Copyright (c) 2007-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/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/tty.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/fb.h>
-#include <linux/init.h>
-#include <linux/console.h>
-
-#include <drm/drmP.h>
-#include <drm/drm.h>
-#include <drm/drm_crtc.h>
-#include <drm/drm_fb_helper.h>
-
-#include "psb_drv.h"
-#include "psb_intel_reg.h"
-#include "psb_intel_drv.h"
-#include "framebuffer.h"
-#include "gtt.h"
-
-#include "mdfld_output.h"
-
-static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb);
-static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
-                                             struct drm_file *file_priv,
-                                             unsigned int *handle);
-
-static const struct drm_framebuffer_funcs psb_fb_funcs = {
-       .destroy = psb_user_framebuffer_destroy,
-       .create_handle = psb_user_framebuffer_create_handle,
-};
-
-#define CMAP_TOHW(_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16)
-
-static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
-                          unsigned blue, unsigned transp,
-                          struct fb_info *info)
-{
-       struct psb_fbdev *fbdev = info->par;
-       struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb;
-       uint32_t v;
-
-       if (!fb)
-               return -ENOMEM;
-
-       if (regno > 255)
-               return 1;
-
-       red = CMAP_TOHW(red, info->var.red.length);
-       blue = CMAP_TOHW(blue, info->var.blue.length);
-       green = CMAP_TOHW(green, info->var.green.length);
-       transp = CMAP_TOHW(transp, info->var.transp.length);
-
-       v = (red << info->var.red.offset) |
-           (green << info->var.green.offset) |
-           (blue << info->var.blue.offset) |
-           (transp << info->var.transp.offset);
-
-       if (regno < 16) {
-               switch (fb->bits_per_pixel) {
-               case 16:
-                       ((uint32_t *) info->pseudo_palette)[regno] = v;
-                       break;
-               case 24:
-               case 32:
-                       ((uint32_t *) info->pseudo_palette)[regno] = v;
-                       break;
-               }
-       }
-
-       return 0;
-}
-
-static int psbfb_pan(struct fb_var_screeninfo *var, struct fb_info *info)
-{
-       struct psb_fbdev *fbdev = info->par;
-       struct psb_framebuffer *psbfb = &fbdev->pfb;
-       struct drm_device *dev = psbfb->base.dev;
-
-       /*
-        *      We have to poke our nose in here. The core fb code assumes
-        *      panning is part of the hardware that can be invoked before
-        *      the actual fb is mapped. In our case that isn't quite true.
-        */
-       if (psbfb->gtt->npage)
-               psb_gtt_roll(dev, psbfb->gtt, var->yoffset);
-       return 0;
-}
-
-void psbfb_suspend(struct drm_device *dev)
-{
-       struct drm_framebuffer *fb = 0;
-       struct psb_framebuffer *psbfb = to_psb_fb(fb);
-
-       console_lock();
-       mutex_lock(&dev->mode_config.mutex);
-       list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
-               struct fb_info *info = psbfb->fbdev;
-               fb_set_suspend(info, 1);
-               drm_fb_helper_blank(FB_BLANK_POWERDOWN, info);
-       }
-       mutex_unlock(&dev->mode_config.mutex);
-       console_unlock();
-}
-
-void psbfb_resume(struct drm_device *dev)
-{
-       struct drm_framebuffer *fb = 0;
-       struct psb_framebuffer *psbfb = to_psb_fb(fb);
-
-       console_lock();
-       mutex_lock(&dev->mode_config.mutex);
-       list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
-               struct fb_info *info = psbfb->fbdev;
-               fb_set_suspend(info, 0);
-               drm_fb_helper_blank(FB_BLANK_UNBLANK, info);
-       }
-       mutex_unlock(&dev->mode_config.mutex);
-       console_unlock();
-       drm_helper_disable_unused_functions(dev);
-}
-
-static int psbfb_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
-{
-       struct psb_framebuffer *psbfb = vma->vm_private_data;
-       struct drm_device *dev = psbfb->base.dev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       int page_num;
-       int i;
-       unsigned long address;
-       int ret;
-       unsigned long pfn;
-       /* FIXME: assumes fb at stolen base which may not be true */
-       unsigned long phys_addr = (unsigned long)dev_priv->stolen_base;
-
-       page_num = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
-       address = (unsigned long)vmf->virtual_address;
-
-       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
-       for (i = 0; i < page_num; i++) {
-               pfn = (phys_addr >> PAGE_SHIFT);
-
-               ret = vm_insert_mixed(vma, address, pfn);
-               if (unlikely((ret == -EBUSY) || (ret != 0 && i > 0)))
-                       break;
-               else if (unlikely(ret != 0)) {
-                       ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS;
-                       return ret;
-               }
-               address += PAGE_SIZE;
-               phys_addr += PAGE_SIZE;
-       }
-       return VM_FAULT_NOPAGE;
-}
-
-static void psbfb_vm_open(struct vm_area_struct *vma)
-{
-}
-
-static void psbfb_vm_close(struct vm_area_struct *vma)
-{
-}
-
-static struct vm_operations_struct psbfb_vm_ops = {
-       .fault  = psbfb_vm_fault,
-       .open   = psbfb_vm_open,
-       .close  = psbfb_vm_close
-};
-
-static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
-{
-       struct psb_fbdev *fbdev = info->par;
-       struct psb_framebuffer *psbfb = &fbdev->pfb;
-
-       if (vma->vm_pgoff != 0)
-               return -EINVAL;
-       if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
-               return -EINVAL;
-
-       if (!psbfb->addr_space)
-               psbfb->addr_space = vma->vm_file->f_mapping;
-       /*
-        * If this is a GEM object then info->screen_base is the virtual
-        * kernel remapping of the object. FIXME: Review if this is
-        * suitable for our mmap work
-        */
-       vma->vm_ops = &psbfb_vm_ops;
-       vma->vm_private_data = (void *)psbfb;
-       vma->vm_flags |= VM_RESERVED | VM_IO |
-                                       VM_MIXEDMAP | VM_DONTEXPAND;
-       return 0;
-}
-
-static int psbfb_ioctl(struct fb_info *info, unsigned int cmd,
-                                               unsigned long arg)
-{
-       return -ENOTTY;
-}
-
-static struct fb_ops psbfb_ops = {
-       .owner = THIS_MODULE,
-       .fb_check_var = drm_fb_helper_check_var,
-       .fb_set_par = drm_fb_helper_set_par,
-       .fb_blank = drm_fb_helper_blank,
-       .fb_setcolreg = psbfb_setcolreg,
-       .fb_fillrect = cfb_fillrect,
-       .fb_copyarea = psbfb_copyarea,
-       .fb_imageblit = cfb_imageblit,
-       .fb_mmap = psbfb_mmap,
-       .fb_sync = psbfb_sync,
-       .fb_ioctl = psbfb_ioctl,
-};
-
-static struct fb_ops psbfb_roll_ops = {
-       .owner = THIS_MODULE,
-       .fb_check_var = drm_fb_helper_check_var,
-       .fb_set_par = drm_fb_helper_set_par,
-       .fb_blank = drm_fb_helper_blank,
-       .fb_setcolreg = psbfb_setcolreg,
-       .fb_fillrect = cfb_fillrect,
-       .fb_copyarea = cfb_copyarea,
-       .fb_imageblit = cfb_imageblit,
-       .fb_pan_display = psbfb_pan,
-       .fb_mmap = psbfb_mmap,
-       .fb_sync = psbfb_sync,
-       .fb_ioctl = psbfb_ioctl,
-};
-
-static struct fb_ops psbfb_unaccel_ops = {
-       .owner = THIS_MODULE,
-       .fb_check_var = drm_fb_helper_check_var,
-       .fb_set_par = drm_fb_helper_set_par,
-       .fb_blank = drm_fb_helper_blank,
-       .fb_setcolreg = psbfb_setcolreg,
-       .fb_fillrect = cfb_fillrect,
-       .fb_copyarea = cfb_copyarea,
-       .fb_imageblit = cfb_imageblit,
-       .fb_mmap = psbfb_mmap,
-       .fb_ioctl = psbfb_ioctl,
-};
-
-/**
- *     psb_framebuffer_init    -       initialize a framebuffer
- *     @dev: our DRM device
- *     @fb: framebuffer to set up
- *     @mode_cmd: mode description
- *     @gt: backing object
- *
- *     Configure and fill in the boilerplate for our frame buffer. Return
- *     0 on success or an error code if we fail.
- */
-static int psb_framebuffer_init(struct drm_device *dev,
-                                       struct psb_framebuffer *fb,
-                                       struct drm_mode_fb_cmd2 *mode_cmd,
-                                       struct gtt_range *gt)
-{
-       u32 bpp, depth;
-       int ret;
-
-       drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);
-
-       if (mode_cmd->pitches[0] & 63)
-               return -EINVAL;
-       switch (bpp) {
-       case 8:
-       case 16:
-       case 24:
-       case 32:
-               break;
-       default:
-               return -EINVAL;
-       }
-       ret = drm_framebuffer_init(dev, &fb->base, &psb_fb_funcs);
-       if (ret) {
-               dev_err(dev->dev, "framebuffer init failed: %d\n", ret);
-               return ret;
-       }
-       drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
-       fb->gtt = gt;
-       return 0;
-}
-
-/**
- *     psb_framebuffer_create  -       create a framebuffer backed by gt
- *     @dev: our DRM device
- *     @mode_cmd: the description of the requested mode
- *     @gt: the backing object
- *
- *     Create a framebuffer object backed by the gt, and fill in the
- *     boilerplate required
- *
- *     TODO: review object references
- */
-
-static struct drm_framebuffer *psb_framebuffer_create
-                       (struct drm_device *dev,
-                        struct drm_mode_fb_cmd2 *mode_cmd,
-                        struct gtt_range *gt)
-{
-       struct psb_framebuffer *fb;
-       int ret;
-
-       fb = kzalloc(sizeof(*fb), GFP_KERNEL);
-       if (!fb)
-               return ERR_PTR(-ENOMEM);
-
-       ret = psb_framebuffer_init(dev, fb, mode_cmd, gt);
-       if (ret) {
-               kfree(fb);
-               return ERR_PTR(ret);
-       }
-       return &fb->base;
-}
-
-/**
- *     psbfb_alloc             -       allocate frame buffer memory
- *     @dev: the DRM device
- *     @aligned_size: space needed
- *     @force: fall back to GEM buffers if need be
- *
- *     Allocate the frame buffer. In the usual case we get a GTT range that
- *     is stolen memory backed and life is simple. If there isn't sufficient
- *     stolen memory or the system has no stolen memory we allocate a range
- *     and back it with a GEM object.
- *
- *     In this case the GEM object has no handle.
- */
-static struct gtt_range *psbfb_alloc(struct drm_device *dev,
-                                               int aligned_size, int force)
-{
-       struct gtt_range *backing;
-       /* Begin by trying to use stolen memory backing */
-       backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
-       if (backing) {
-               if (drm_gem_private_object_init(dev,
-                                       &backing->gem, aligned_size) == 0)
-                       return backing;
-               psb_gtt_free_range(dev, backing);
-       }
-       if (!force)
-               return NULL;
-
-       /* Next try using GEM host memory */
-       backing = psb_gtt_alloc_range(dev, aligned_size, "fb(gem)", 0);
-       if (backing == NULL)
-               return NULL;
-
-       /* Now back it with an object */
-       if (drm_gem_object_init(dev, &backing->gem, aligned_size) != 0) {
-               psb_gtt_free_range(dev, backing);
-               return NULL;
-       }
-       return backing;
-}
-
-/**
- *     psbfb_create            -       create a framebuffer
- *     @fbdev: the framebuffer device
- *     @sizes: specification of the layout
- *
- *     Create a framebuffer to the specifications provided
- */
-static int psbfb_create(struct psb_fbdev *fbdev,
-                               struct drm_fb_helper_surface_size *sizes)
-{
-       struct drm_device *dev = fbdev->psb_fb_helper.dev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct fb_info *info;
-       struct drm_framebuffer *fb;
-       struct psb_framebuffer *psbfb = &fbdev->pfb;
-       struct drm_mode_fb_cmd2 mode_cmd;
-       struct device *device = &dev->pdev->dev;
-       int size;
-       int ret;
-       struct gtt_range *backing;
-       int gtt_roll = 1;
-       u32 bpp, depth;
-
-       mode_cmd.width = sizes->surface_width;
-       mode_cmd.height = sizes->surface_height;
-       bpp = sizes->surface_bpp;
-
-       /* No 24bit packed */
-       if (bpp == 24)
-               bpp = 32;
-
-       /* Acceleration via the GTT requires pitch to be 4096 byte aligned 
-          (ie 1024 or 2048 pixels in normal use) */
-       mode_cmd.pitches[0] =  ALIGN(mode_cmd.width * ((bpp + 7) / 8), 4096);
-       depth = sizes->surface_depth;
-
-       size = mode_cmd.pitches[0] * mode_cmd.height;
-       size = ALIGN(size, PAGE_SIZE);
-
-       /* Allocate the framebuffer in the GTT with stolen page backing */
-       backing = psbfb_alloc(dev, size, 0);
-       if (backing == NULL) {
-               /*
-                *      We couldn't get the space we wanted, fall back to the
-                *      display engine requirement instead.  The HW requires
-                *      the pitch to be 64 byte aligned
-                */
-
-               gtt_roll = 0;   /* Don't use GTT accelerated scrolling */
-
-               mode_cmd.pitches[0] =  ALIGN(mode_cmd.width * ((bpp + 7) / 8), 64);
-               depth = sizes->surface_depth;
-
-               size = mode_cmd.pitches[0] * mode_cmd.height;
-               size = ALIGN(size, PAGE_SIZE);
-
-               /* Allocate the framebuffer in the GTT with stolen page
-                  backing when there is room */
-               backing = psbfb_alloc(dev, size, 1);
-               if (backing == NULL)
-                       return -ENOMEM;
-       }
-
-       mutex_lock(&dev->struct_mutex);
-
-       info = framebuffer_alloc(0, device);
-       if (!info) {
-               ret = -ENOMEM;
-               goto out_err1;
-       }
-       info->par = fbdev;
-
-       mode_cmd.pixel_format = drm_mode_legacy_fb_format(bpp, depth);
-
-       ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing);
-       if (ret)
-               goto out_unref;
-
-       fb = &psbfb->base;
-       psbfb->fbdev = info;
-
-       fbdev->psb_fb_helper.fb = fb;
-       fbdev->psb_fb_helper.fbdev = info;
-
-       strcpy(info->fix.id, "psbfb");
-
-       info->flags = FBINFO_DEFAULT;
-       if (gtt_roll) { /* GTT rolling seems best */
-               info->fbops = &psbfb_roll_ops;
-               info->flags |= FBINFO_HWACCEL_YPAN;
-        }
-       else if (dev_priv->ops->accel_2d)       /* 2D engine */
-               info->fbops = &psbfb_ops;
-       else    /* Software */
-               info->fbops = &psbfb_unaccel_ops;
-
-       ret = fb_alloc_cmap(&info->cmap, 256, 0);
-       if (ret) {
-               ret = -ENOMEM;
-               goto out_unref;
-       }
-
-       info->fix.smem_start = dev->mode_config.fb_base;
-       info->fix.smem_len = size;
-       info->fix.ywrapstep = gtt_roll;
-       info->fix.ypanstep = gtt_roll;
-
-       if (backing->stolen) {
-               /* Accessed stolen memory directly */
-               info->screen_base = (char *)dev_priv->vram_addr +
-                                                       backing->offset;
-       } else {
-               /* Pin the pages into the GTT and create a mapping to them */
-               psb_gtt_pin(backing);
-               info->screen_base = vm_map_ram(backing->pages, backing->npage,
-                               -1, PAGE_KERNEL);
-               if (info->screen_base == NULL) {
-                       psb_gtt_unpin(backing);
-                       ret = -ENOMEM;
-                       goto out_unref;
-               }
-               psbfb->vm_map = 1;
-       }
-       info->screen_size = size;
-
-       if (dev_priv->gtt.stolen_size) {
-               info->apertures = alloc_apertures(1);
-               if (!info->apertures) {
-                       ret = -ENOMEM;
-                       goto out_unref;
-               }
-               info->apertures->ranges[0].base = dev->mode_config.fb_base;
-               info->apertures->ranges[0].size = dev_priv->gtt.stolen_size;
-       }
-
-       drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
-       drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper,
-                               sizes->fb_width, sizes->fb_height);
-
-       info->fix.mmio_start = pci_resource_start(dev->pdev, 0);
-       info->fix.mmio_len = pci_resource_len(dev->pdev, 0);
-
-       info->pixmap.size = 64 * 1024;
-       info->pixmap.buf_align = 8;
-       info->pixmap.access_align = 32;
-       info->pixmap.flags = FB_PIXMAP_SYSTEM;
-       info->pixmap.scan_align = 1;
-
-       dev_info(dev->dev, "allocated %dx%d fb\n",
-                                       psbfb->base.width, psbfb->base.height);
-
-       mutex_unlock(&dev->struct_mutex);
-       return 0;
-out_unref:
-       if (backing->stolen)
-               psb_gtt_free_range(dev, backing);
-       else {
-               if (psbfb->vm_map)
-                       vm_unmap_ram(info->screen_base, backing->npage);
-               drm_gem_object_unreference(&backing->gem);
-       }
-out_err1:
-       mutex_unlock(&dev->struct_mutex);
-       psb_gtt_free_range(dev, backing);
-       return ret;
-}
-
-/**
- *     psb_user_framebuffer_create     -       create framebuffer
- *     @dev: our DRM device
- *     @filp: client file
- *     @cmd: mode request
- *
- *     Create a new framebuffer backed by a userspace GEM object
- */
-static struct drm_framebuffer *psb_user_framebuffer_create
-                       (struct drm_device *dev, struct drm_file *filp,
-                        struct drm_mode_fb_cmd2 *cmd)
-{
-       struct gtt_range *r;
-       struct drm_gem_object *obj;
-
-       /*
-        *      Find the GEM object and thus the gtt range object that is
-        *      to back this space
-        */
-       obj = drm_gem_object_lookup(dev, filp, cmd->handles[0]);
-       if (obj == NULL)
-               return ERR_PTR(-ENOENT);
-
-       /* Let the core code do all the work */
-       r = container_of(obj, struct gtt_range, gem);
-       return psb_framebuffer_create(dev, cmd, r);
-}
-
-static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-                                                       u16 blue, int regno)
-{
-}
-
-static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
-                                       u16 *green, u16 *blue, int regno)
-{
-}
-
-static int psbfb_probe(struct drm_fb_helper *helper,
-                               struct drm_fb_helper_surface_size *sizes)
-{
-       struct psb_fbdev *psb_fbdev = (struct psb_fbdev *)helper;
-       int new_fb = 0;
-       int ret;
-
-       if (!helper->fb) {
-               ret = psbfb_create(psb_fbdev, sizes);
-               if (ret)
-                       return ret;
-               new_fb = 1;
-       }
-       return new_fb;
-}
-
-struct drm_fb_helper_funcs psb_fb_helper_funcs = {
-       .gamma_set = psbfb_gamma_set,
-       .gamma_get = psbfb_gamma_get,
-       .fb_probe = psbfb_probe,
-};
-
-int psb_fbdev_destroy(struct drm_device *dev, struct psb_fbdev *fbdev)
-{
-       struct fb_info *info;
-       struct psb_framebuffer *psbfb = &fbdev->pfb;
-
-       if (fbdev->psb_fb_helper.fbdev) {
-               info = fbdev->psb_fb_helper.fbdev;
-
-               /* If this is our base framebuffer then kill any virtual map
-                  for the framebuffer layer and unpin it */
-               if (psbfb->vm_map) {
-                       vm_unmap_ram(info->screen_base, psbfb->gtt->npage);
-                       psb_gtt_unpin(psbfb->gtt);
-               }
-               unregister_framebuffer(info);
-               if (info->cmap.len)
-                       fb_dealloc_cmap(&info->cmap);
-               framebuffer_release(info);
-       }
-       drm_fb_helper_fini(&fbdev->psb_fb_helper);
-       drm_framebuffer_cleanup(&psbfb->base);
-
-       if (psbfb->gtt)
-               drm_gem_object_unreference(&psbfb->gtt->gem);
-       return 0;
-}
-
-int psb_fbdev_init(struct drm_device *dev)
-{
-       struct psb_fbdev *fbdev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       fbdev = kzalloc(sizeof(struct psb_fbdev), GFP_KERNEL);
-       if (!fbdev) {
-               dev_err(dev->dev, "no memory\n");
-               return -ENOMEM;
-       }
-
-       dev_priv->fbdev = fbdev;
-       fbdev->psb_fb_helper.funcs = &psb_fb_helper_funcs;
-
-       drm_fb_helper_init(dev, &fbdev->psb_fb_helper, dev_priv->ops->crtcs,
-                                                       INTELFB_CONN_LIMIT);
-
-       drm_fb_helper_single_add_all_connectors(&fbdev->psb_fb_helper);
-       drm_fb_helper_initial_config(&fbdev->psb_fb_helper, 32);
-       return 0;
-}
-
-void psb_fbdev_fini(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       if (!dev_priv->fbdev)
-               return;
-
-       psb_fbdev_destroy(dev, dev_priv->fbdev);
-       kfree(dev_priv->fbdev);
-       dev_priv->fbdev = NULL;
-}
-
-static void psbfb_output_poll_changed(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct psb_fbdev *fbdev = (struct psb_fbdev *)dev_priv->fbdev;
-       drm_fb_helper_hotplug_event(&fbdev->psb_fb_helper);
-}
-
-/**
- *     psb_user_framebuffer_create_handle - add hamdle to a framebuffer
- *     @fb: framebuffer
- *     @file_priv: our DRM file
- *     @handle: returned handle
- *
- *     Our framebuffer object is a GTT range which also contains a GEM
- *     object. We need to turn it into a handle for userspace. GEM will do
- *     the work for us
- */
-static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
-                                             struct drm_file *file_priv,
-                                             unsigned int *handle)
-{
-       struct psb_framebuffer *psbfb = to_psb_fb(fb);
-       struct gtt_range *r = psbfb->gtt;
-       return drm_gem_handle_create(file_priv, &r->gem, handle);
-}
-
-/**
- *     psb_user_framebuffer_destroy    -       destruct user created fb
- *     @fb: framebuffer
- *
- *     User framebuffers are backed by GEM objects so all we have to do is
- *     clean up a bit and drop the reference, GEM will handle the fallout
- */
-static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-       struct psb_framebuffer *psbfb = to_psb_fb(fb);
-       struct gtt_range *r = psbfb->gtt;
-       struct drm_device *dev = fb->dev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct psb_fbdev *fbdev = dev_priv->fbdev;
-       struct drm_crtc *crtc;
-       int reset = 0;
-
-       /* Should never get stolen memory for a user fb */
-       WARN_ON(r->stolen);
-
-       /* Check if we are erroneously live */
-       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
-               if (crtc->fb == fb)
-                       reset = 1;
-
-       if (reset)
-               /*
-                * Now force a sane response before we permit the DRM CRTC
-                * layer to do stupid things like blank the display. Instead
-                * we reset this framebuffer as if the user had forced a reset.
-                * We must do this before the cleanup so that the DRM layer
-                * doesn't get a chance to stick its oar in where it isn't
-                * wanted.
-                */
-               drm_fb_helper_restore_fbdev_mode(&fbdev->psb_fb_helper);
-
-       /* Let DRM do its clean up */
-       drm_framebuffer_cleanup(fb);
-       /*  We are no longer using the resource in GEM */
-       drm_gem_object_unreference_unlocked(&r->gem);
-       kfree(fb);
-}
-
-static const struct drm_mode_config_funcs psb_mode_funcs = {
-       .fb_create = psb_user_framebuffer_create,
-       .output_poll_changed = psbfb_output_poll_changed,
-};
-
-static int psb_create_backlight_property(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct drm_property *backlight;
-
-       if (dev_priv->backlight_property)
-               return 0;
-
-       backlight = drm_property_create(dev, DRM_MODE_PROP_RANGE,
-                                                       "backlight", 2);
-       backlight->values[0] = 0;
-       backlight->values[1] = 100;
-
-       dev_priv->backlight_property = backlight;
-
-       return 0;
-}
-
-static void psb_setup_outputs(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct drm_connector *connector;
-
-       drm_mode_create_scaling_mode_property(dev);
-       psb_create_backlight_property(dev);
-
-       dev_priv->ops->output_init(dev);
-
-       list_for_each_entry(connector, &dev->mode_config.connector_list,
-                           head) {
-               struct psb_intel_output *psb_intel_output =
-                   to_psb_intel_output(connector);
-               struct drm_encoder *encoder = &psb_intel_output->enc;
-               int crtc_mask = 0, clone_mask = 0;
-
-               /* valid crtcs */
-               switch (psb_intel_output->type) {
-               case INTEL_OUTPUT_ANALOG:
-                       crtc_mask = (1 << 0);
-                       clone_mask = (1 << INTEL_OUTPUT_ANALOG);
-                       break;
-               case INTEL_OUTPUT_SDVO:
-                       crtc_mask = ((1 << 0) | (1 << 1));
-                       clone_mask = (1 << INTEL_OUTPUT_SDVO);
-                       break;
-               case INTEL_OUTPUT_LVDS:
-                       if (IS_MRST(dev))
-                               crtc_mask = (1 << 0);
-                       else
-                               crtc_mask = (1 << 1);
-                       clone_mask = (1 << INTEL_OUTPUT_LVDS);
-                       break;
-               case INTEL_OUTPUT_MIPI:
-                       crtc_mask = (1 << 0);
-                       clone_mask = (1 << INTEL_OUTPUT_MIPI);
-                       break;
-               case INTEL_OUTPUT_MIPI2:
-                       crtc_mask = (1 << 2);
-                       clone_mask = (1 << INTEL_OUTPUT_MIPI2);
-                       break;
-               case INTEL_OUTPUT_HDMI:
-                       /* HDMI on crtc 1 for SoC devices and crtc 0 for
-                           Cedarview. HDMI on Poulsbo is only via external
-                          logic */
-                       if (IS_MFLD(dev) || IS_MRST(dev))
-                               crtc_mask = (1 << 1);
-                       else
-                               crtc_mask = (1 << 0);   /* Cedarview */
-                       clone_mask = (1 << INTEL_OUTPUT_HDMI);
-                       break;
-               }
-               encoder->possible_crtcs = crtc_mask;
-               encoder->possible_clones =
-                   psb_intel_connector_clones(dev, clone_mask);
-       }
-}
-
-void psb_modeset_init(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv =
-           (struct drm_psb_private *) dev->dev_private;
-       struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
-       int i;
-
-       drm_mode_config_init(dev);
-
-       dev->mode_config.min_width = 0;
-       dev->mode_config.min_height = 0;
-
-       dev->mode_config.funcs = (void *) &psb_mode_funcs;
-
-       /* set memory base */
-       /* MRST and PSB should use BAR 2*/
-       pci_read_config_dword(dev->pdev, PSB_BSM, (u32 *)
-                                       &(dev->mode_config.fb_base));
-
-       /* num pipes is 2 for PSB but 1 for Mrst */
-       for (i = 0; i < dev_priv->num_pipe; i++)
-               psb_intel_crtc_init(dev, i, mode_dev);
-
-       dev->mode_config.max_width = 2048;
-       dev->mode_config.max_height = 2048;
-
-       psb_setup_outputs(dev);
-}
-
-void psb_modeset_cleanup(struct drm_device *dev)
-{
-       mutex_lock(&dev->struct_mutex);
-
-       drm_kms_helper_poll_fini(dev);
-       psb_fbdev_fini(dev);
-       drm_mode_config_cleanup(dev);
-
-       mutex_unlock(&dev->struct_mutex);
-}
diff --git a/drivers/staging/gma500/framebuffer.h b/drivers/staging/gma500/framebuffer.h
deleted file mode 100644 (file)
index d1b2289..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Intel Corporation
- *
- * 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.
- *
- * Authors:
- *      Eric Anholt <eric@anholt.net>
- *
- */
-
-#ifndef _FRAMEBUFFER_H_
-#define _FRAMEBUFFER_H_
-
-#include <drm/drmP.h>
-#include <drm/drm_fb_helper.h>
-
-#include "psb_drv.h"
-
-struct psb_framebuffer {
-       struct drm_framebuffer base;
-       struct address_space *addr_space;
-       struct fb_info *fbdev;
-       struct gtt_range *gtt;
-       bool vm_map;            /* True if we must undo a vm_map_ram */
-};
-
-struct psb_fbdev {
-       struct drm_fb_helper psb_fb_helper;
-       struct psb_framebuffer pfb;
-};
-
-#define to_psb_fb(x) container_of(x, struct psb_framebuffer, base)
-
-extern int psb_intel_connector_clones(struct drm_device *dev, int type_mask);
-
-#endif
-
diff --git a/drivers/staging/gma500/gem.c b/drivers/staging/gma500/gem.c
deleted file mode 100644 (file)
index f6433c0..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- *  psb GEM interface
- *
- * Copyright (c) 2011, Intel Corporation.
- *
- * 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.
- *
- * Authors: Alan Cox
- *
- * TODO:
- *     -       we need to work out if the MMU is relevant (eg for
- *             accelerated operations on a GEM object)
- */
-
-#include <drm/drmP.h>
-#include <drm/drm.h>
-#include "psb_drm.h"
-#include "psb_drv.h"
-
-int psb_gem_init_object(struct drm_gem_object *obj)
-{
-       return -EINVAL;
-}
-
-void psb_gem_free_object(struct drm_gem_object *obj)
-{
-       struct gtt_range *gtt = container_of(obj, struct gtt_range, gem);
-       drm_gem_object_release_wrap(obj);
-       /* This must occur last as it frees up the memory of the GEM object */
-       psb_gtt_free_range(obj->dev, gtt);
-}
-
-int psb_gem_get_aperture(struct drm_device *dev, void *data,
-                               struct drm_file *file)
-{
-       return -EINVAL;
-}
-
-/**
- *     psb_gem_dumb_map_gtt    -       buffer mapping for dumb interface
- *     @file: our drm client file
- *     @dev: drm device
- *     @handle: GEM handle to the object (from dumb_create)
- *
- *     Do the necessary setup to allow the mapping of the frame buffer
- *     into user memory. We don't have to do much here at the moment.
- */
-int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
-                        uint32_t handle, uint64_t *offset)
-{
-       int ret = 0;
-       struct drm_gem_object *obj;
-
-       if (!(dev->driver->driver_features & DRIVER_GEM))
-               return -ENODEV;
-
-       mutex_lock(&dev->struct_mutex);
-
-       /* GEM does all our handle to object mapping */
-       obj = drm_gem_object_lookup(dev, file, handle);
-       if (obj == NULL) {
-               ret = -ENOENT;
-               goto unlock;
-       }
-       /* What validation is needed here ? */
-
-       /* Make it mmapable */
-       if (!obj->map_list.map) {
-               ret = gem_create_mmap_offset(obj);
-               if (ret)
-                       goto out;
-       }
-       /* GEM should really work out the hash offsets for us */
-       *offset = (u64)obj->map_list.hash.key << PAGE_SHIFT;
-out:
-       drm_gem_object_unreference(obj);
-unlock:
-       mutex_unlock(&dev->struct_mutex);
-       return ret;
-}
-
-/**
- *     psb_gem_create          -       create a mappable object
- *     @file: the DRM file of the client
- *     @dev: our device
- *     @size: the size requested
- *     @handlep: returned handle (opaque number)
- *
- *     Create a GEM object, fill in the boilerplate and attach a handle to
- *     it so that userspace can speak about it. This does the core work
- *     for the various methods that do/will create GEM objects for things
- */
-static int psb_gem_create(struct drm_file *file,
-       struct drm_device *dev, uint64_t size, uint32_t *handlep)
-{
-       struct gtt_range *r;
-       int ret;
-       u32 handle;
-
-       size = roundup(size, PAGE_SIZE);
-
-       /* Allocate our object - for now a direct gtt range which is not
-          stolen memory backed */
-       r = psb_gtt_alloc_range(dev, size, "gem", 0);
-       if (r == NULL) {
-               dev_err(dev->dev, "no memory for %lld byte GEM object\n", size);
-               return -ENOSPC;
-       }
-       /* Initialize the extra goodies GEM needs to do all the hard work */
-       if (drm_gem_object_init(dev, &r->gem, size) != 0) {
-               psb_gtt_free_range(dev, r);
-               /* GEM doesn't give an error code so use -ENOMEM */
-               dev_err(dev->dev, "GEM init failed for %lld\n", size);
-               return -ENOMEM;
-       }
-       /* Give the object a handle so we can carry it more easily */
-       ret = drm_gem_handle_create(file, &r->gem, &handle);
-       if (ret) {
-               dev_err(dev->dev, "GEM handle failed for %p, %lld\n",
-                                                       &r->gem, size);
-               drm_gem_object_release(&r->gem);
-               psb_gtt_free_range(dev, r);
-               return ret;
-       }
-       /* We have the initial and handle reference but need only one now */
-       drm_gem_object_unreference(&r->gem);
-       *handlep = handle;
-       return 0;
-}
-
-/**
- *     psb_gem_dumb_create     -       create a dumb buffer
- *     @drm_file: our client file
- *     @dev: our device
- *     @args: the requested arguments copied from userspace
- *
- *     Allocate a buffer suitable for use for a frame buffer of the
- *     form described by user space. Give userspace a handle by which
- *     to reference it.
- */
-int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
-                       struct drm_mode_create_dumb *args)
-{
-       args->pitch = ALIGN(args->width * ((args->bpp + 7) / 8), 64);
-       args->size = args->pitch * args->height;
-       return psb_gem_create(file, dev, args->size, &args->handle);
-}
-
-/**
- *     psb_gem_dumb_destroy    -       destroy a dumb buffer
- *     @file: client file
- *     @dev: our DRM device
- *     @handle: the object handle
- *
- *     Destroy a handle that was created via psb_gem_dumb_create, at least
- *     we hope it was created that way. i915 seems to assume the caller
- *     does the checking but that might be worth review ! FIXME
- */
-int psb_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
-                       uint32_t handle)
-{
-       /* No special work needed, drop the reference and see what falls out */
-       return drm_gem_handle_delete(file, handle);
-}
-
-/**
- *     psb_gem_fault           -       pagefault handler for GEM objects
- *     @vma: the VMA of the GEM object
- *     @vmf: fault detail
- *
- *     Invoked when a fault occurs on an mmap of a GEM managed area. GEM
- *     does most of the work for us including the actual map/unmap calls
- *     but we need to do the actual page work.
- *
- *     This code eventually needs to handle faulting objects in and out
- *     of the GTT and repacking it when we run out of space. We can put
- *     that off for now and for our simple uses
- *
- *     The VMA was set up by GEM. In doing so it also ensured that the
- *     vma->vm_private_data points to the GEM object that is backing this
- *     mapping.
- */
-int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
-{
-       struct drm_gem_object *obj;
-       struct gtt_range *r;
-       int ret;
-       unsigned long pfn;
-       pgoff_t page_offset;
-       struct drm_device *dev;
-       struct drm_psb_private *dev_priv;
-
-       obj = vma->vm_private_data;     /* GEM object */
-       dev = obj->dev;
-       dev_priv = dev->dev_private;
-
-       r = container_of(obj, struct gtt_range, gem);   /* Get the gtt range */
-
-       /* Make sure we don't parallel update on a fault, nor move or remove
-          something from beneath our feet */
-       mutex_lock(&dev->struct_mutex);
-
-       /* For now the mmap pins the object and it stays pinned. As things
-          stand that will do us no harm */
-       if (r->mmapping == 0) {
-               ret = psb_gtt_pin(r);
-               if (ret < 0) {
-                       dev_err(dev->dev, "gma500: pin failed: %d\n", ret);
-                       goto fail;
-               }
-               r->mmapping = 1;
-       }
-
-       /* Page relative to the VMA start - we must calculate this ourselves
-          because vmf->pgoff is the fake GEM offset */
-       page_offset = ((unsigned long) vmf->virtual_address - vma->vm_start)
-                               >> PAGE_SHIFT;
-
-       /* CPU view of the page, don't go via the GART for CPU writes */
-       if (r->stolen)
-               pfn = (dev_priv->stolen_base + r->offset) >> PAGE_SHIFT;
-       else
-               pfn = page_to_pfn(r->pages[page_offset]);
-       ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn);
-
-fail:
-       mutex_unlock(&dev->struct_mutex);
-       switch (ret) {
-       case 0:
-       case -ERESTARTSYS:
-       case -EINTR:
-               return VM_FAULT_NOPAGE;
-       case -ENOMEM:
-               return VM_FAULT_OOM;
-       default:
-               return VM_FAULT_SIGBUS;
-       }
-}
-
-static int psb_gem_create_stolen(struct drm_file *file, struct drm_device *dev,
-                                               int size, u32 *handle)
-{
-       struct gtt_range *gtt = psb_gtt_alloc_range(dev, size, "gem", 1);
-       if (gtt == NULL)
-               return -ENOMEM;
-       if (drm_gem_private_object_init(dev, &gtt->gem, size) != 0)
-               goto free_gtt;
-       if (drm_gem_handle_create(file, &gtt->gem, handle) == 0)
-               return 0;
-free_gtt:
-       psb_gtt_free_range(dev, gtt);
-       return -ENOMEM;
-}
-
-/*
- *     GEM interfaces for our specific client
- */
-int psb_gem_create_ioctl(struct drm_device *dev, void *data,
-                                       struct drm_file *file)
-{
-       struct drm_psb_gem_create *args = data;
-       int ret;
-       if (args->flags & PSB_GEM_CREATE_STOLEN) {
-               ret = psb_gem_create_stolen(file, dev, args->size,
-                                                       &args->handle);
-               if (ret == 0)
-                       return 0;
-               /* Fall throguh */
-               args->flags &= ~PSB_GEM_CREATE_STOLEN;
-       }
-       return psb_gem_create(file, dev, args->size, &args->handle);
-}
-
-int psb_gem_mmap_ioctl(struct drm_device *dev, void *data,
-                                       struct drm_file *file)
-{
-       struct drm_psb_gem_mmap *args = data;
-       return dev->driver->dumb_map_offset(file, dev,
-                                               args->handle, &args->offset);
-}
-
diff --git a/drivers/staging/gma500/gem_glue.c b/drivers/staging/gma500/gem_glue.c
deleted file mode 100644 (file)
index daac121..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/**************************************************************************
- * 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 <drm/drmP.h>
-#include <drm/drm.h>
-
-void drm_gem_object_release_wrap(struct drm_gem_object *obj)
-{
-       /* Remove the list map if one is present */
-       if (obj->map_list.map) {
-               struct drm_gem_mm *mm = obj->dev->mm_private;
-               struct drm_map_list *list = &obj->map_list;
-               drm_ht_remove_item(&mm->offset_hash, &list->hash);
-               drm_mm_put_block(list->file_offset_node);
-               kfree(list->map);
-               list->map = NULL;
-       }
-       drm_gem_object_release(obj);
-}
-
-/**
- *     gem_create_mmap_offset          -       invent an mmap offset
- *     @obj: our object
- *
- *     Standard implementation of offset generation for mmap as is
- *     duplicated in several drivers. This belongs in GEM.
- */
-int gem_create_mmap_offset(struct drm_gem_object *obj)
-{
-       struct drm_device *dev = obj->dev;
-       struct drm_gem_mm *mm = dev->mm_private;
-       struct drm_map_list *list;
-       struct drm_local_map *map;
-       int ret;
-
-       list = &obj->map_list;
-       list->map = kzalloc(sizeof(struct drm_map_list), GFP_KERNEL);
-       if (list->map == NULL)
-               return -ENOMEM;
-       map = list->map;
-       map->type = _DRM_GEM;
-       map->size = obj->size;
-       map->handle = obj;
-
-       list->file_offset_node = drm_mm_search_free(&mm->offset_manager,
-                                       obj->size / PAGE_SIZE, 0, 0);
-       if (!list->file_offset_node) {
-               dev_err(dev->dev, "failed to allocate offset for bo %d\n",
-                                                               obj->name);
-               ret = -ENOSPC;
-               goto free_it;
-       }
-       list->file_offset_node = drm_mm_get_block(list->file_offset_node,
-                                       obj->size / PAGE_SIZE, 0);
-       if (!list->file_offset_node) {
-               ret = -ENOMEM;
-               goto free_it;
-       }
-       list->hash.key = list->file_offset_node->start;
-       ret = drm_ht_insert_item(&mm->offset_hash, &list->hash);
-       if (ret) {
-               dev_err(dev->dev, "failed to add to map hash\n");
-               goto free_mm;
-       }
-       return 0;
-
-free_mm:
-       drm_mm_put_block(list->file_offset_node);
-free_it:
-       kfree(list->map);
-       list->map = NULL;
-       return ret;
-}
diff --git a/drivers/staging/gma500/gem_glue.h b/drivers/staging/gma500/gem_glue.h
deleted file mode 100644 (file)
index ce5ce30..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-extern void drm_gem_object_release_wrap(struct drm_gem_object *obj);
-extern int gem_create_mmap_offset(struct drm_gem_object *obj);
diff --git a/drivers/staging/gma500/gtt.c b/drivers/staging/gma500/gtt.c
deleted file mode 100644 (file)
index e770bd1..0000000
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Copyright (c) 2007, 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.
- *
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics.com>
- *         Alan Cox <alan@linux.intel.com>
- */
-
-#include <drm/drmP.h>
-#include "psb_drv.h"
-
-
-/*
- *     GTT resource allocator - manage page mappings in GTT space
- */
-
-/**
- *     psb_gtt_mask_pte        -       generate GTT pte entry
- *     @pfn: page number to encode
- *     @type: type of memory in the GTT
- *
- *     Set the GTT entry for the appropriate memory type.
- */
-static inline uint32_t psb_gtt_mask_pte(uint32_t pfn, int type)
-{
-       uint32_t mask = PSB_PTE_VALID;
-
-       if (type & PSB_MMU_CACHED_MEMORY)
-               mask |= PSB_PTE_CACHED;
-       if (type & PSB_MMU_RO_MEMORY)
-               mask |= PSB_PTE_RO;
-       if (type & PSB_MMU_WO_MEMORY)
-               mask |= PSB_PTE_WO;
-
-       return (pfn << PAGE_SHIFT) | mask;
-}
-
-/**
- *     psb_gtt_entry           -       find the GTT entries for a gtt_range
- *     @dev: our DRM device
- *     @r: our GTT range
- *
- *     Given a gtt_range object return the GTT offset of the page table
- *     entries for this gtt_range
- */
-u32 *psb_gtt_entry(struct drm_device *dev, struct gtt_range *r)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       unsigned long offset;
-
-       offset = r->resource.start - dev_priv->gtt_mem->start;
-
-       return dev_priv->gtt_map + (offset >> PAGE_SHIFT);
-}
-
-/**
- *     psb_gtt_insert  -       put an object into the GTT
- *     @dev: our DRM device
- *     @r: our GTT range
- *
- *     Take our preallocated GTT range and insert the GEM object into
- *     the GTT. This is protected via the gtt mutex which the caller
- *     must hold.
- */
-static int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r)
-{
-       u32 *gtt_slot, pte;
-       struct page **pages;
-       int i;
-
-       if (r->pages == NULL) {
-               WARN_ON(1);
-               return -EINVAL;
-       }
-
-       WARN_ON(r->stolen);     /* refcount these maybe ? */
-
-       gtt_slot = psb_gtt_entry(dev, r);
-       pages = r->pages;
-
-       /* Make sure changes are visible to the GPU */
-       set_pages_array_uc(pages, r->npage);
-
-       /* Write our page entries into the GTT itself */
-       for (i = r->roll; i < r->npage; i++) {
-               pte = psb_gtt_mask_pte(page_to_pfn(r->pages[i]), 0);
-               iowrite32(pte, gtt_slot++);
-       }
-       for (i = 0; i < r->roll; i++) {
-               pte = psb_gtt_mask_pte(page_to_pfn(r->pages[i]), 0);
-               iowrite32(pte, gtt_slot++);
-       }
-       /* Make sure all the entries are set before we return */
-       ioread32(gtt_slot - 1);
-
-       return 0;
-}
-
-/**
- *     psb_gtt_remove  -       remove an object from the GTT
- *     @dev: our DRM device
- *     @r: our GTT range
- *
- *     Remove a preallocated GTT range from the GTT. Overwrite all the
- *     page table entries with the dummy page. This is protected via the gtt
- *     mutex which the caller must hold.
- */
-static void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       u32 *gtt_slot, pte;
-       int i;
-
-       WARN_ON(r->stolen);
-
-       gtt_slot = psb_gtt_entry(dev, r);
-       pte = psb_gtt_mask_pte(page_to_pfn(dev_priv->scratch_page), 0);
-
-       for (i = 0; i < r->npage; i++)
-               iowrite32(pte, gtt_slot++);
-       ioread32(gtt_slot - 1);
-       set_pages_array_wb(r->pages, r->npage);
-}
-
-/**
- *     psb_gtt_roll    -       set scrolling position
- *     @dev: our DRM device
- *     @r: the gtt mapping we are using
- *     @roll: roll offset
- *
- *     Roll an existing pinned mapping by moving the pages through the GTT.
- *     This allows us to implement hardware scrolling on the consoles without
- *     a 2D engine
- */
-void psb_gtt_roll(struct drm_device *dev, struct gtt_range *r, int roll)
-{
-       u32 *gtt_slot, pte;
-       int i;
-
-       if (roll >= r->npage) {
-               WARN_ON(1);
-               return;
-       }
-
-       r->roll = roll;
-
-       /* Not currently in the GTT - no worry we will write the mapping at
-          the right position when it gets pinned */
-       if (!r->stolen && !r->in_gart)
-               return;
-
-       gtt_slot = psb_gtt_entry(dev, r);
-
-       for (i = r->roll; i < r->npage; i++) {
-               pte = psb_gtt_mask_pte(page_to_pfn(r->pages[i]), 0);
-               iowrite32(pte, gtt_slot++);
-       }
-       for (i = 0; i < r->roll; i++) {
-               pte = psb_gtt_mask_pte(page_to_pfn(r->pages[i]), 0);
-               iowrite32(pte, gtt_slot++);
-       }
-       ioread32(gtt_slot - 1);
-}
-
-/**
- *     psb_gtt_attach_pages    -       attach and pin GEM pages
- *     @gt: the gtt range
- *
- *     Pin and build an in kernel list of the pages that back our GEM object.
- *     While we hold this the pages cannot be swapped out. This is protected
- *     via the gtt mutex which the caller must hold.
- */
-static int psb_gtt_attach_pages(struct gtt_range *gt)
-{
-       struct inode *inode;
-       struct address_space *mapping;
-       int i;
-       struct page *p;
-       int pages = gt->gem.size / PAGE_SIZE;
-
-       WARN_ON(gt->pages);
-
-       /* This is the shared memory object that backs the GEM resource */
-       inode = gt->gem.filp->f_path.dentry->d_inode;
-       mapping = inode->i_mapping;
-
-       gt->pages = kmalloc(pages * sizeof(struct page *), GFP_KERNEL);
-       if (gt->pages == NULL)
-               return -ENOMEM;
-       gt->npage = pages;
-
-       for (i = 0; i < pages; i++) {
-               /* FIXME: needs updating as per mail from Hugh Dickins */
-               p = read_cache_page_gfp(mapping, i,
-                                       __GFP_COLD | GFP_KERNEL);
-               if (IS_ERR(p))
-                       goto err;
-               gt->pages[i] = p;
-       }
-       return 0;
-
-err:
-       while (i--)
-               page_cache_release(gt->pages[i]);
-       kfree(gt->pages);
-       gt->pages = NULL;
-       return PTR_ERR(p);
-}
-
-/**
- *     psb_gtt_detach_pages    -       attach and pin GEM pages
- *     @gt: the gtt range
- *
- *     Undo the effect of psb_gtt_attach_pages. At this point the pages
- *     must have been removed from the GTT as they could now be paged out
- *     and move bus address. This is protected via the gtt mutex which the
- *     caller must hold.
- */
-static void psb_gtt_detach_pages(struct gtt_range *gt)
-{
-       int i;
-       for (i = 0; i < gt->npage; i++) {
-               /* FIXME: do we need to force dirty */
-               set_page_dirty(gt->pages[i]);
-               page_cache_release(gt->pages[i]);
-       }
-       kfree(gt->pages);
-       gt->pages = NULL;
-}
-
-/**
- *     psb_gtt_pin             -       pin pages into the GTT
- *     @gt: range to pin
- *
- *     Pin a set of pages into the GTT. The pins are refcounted so that
- *     multiple pins need multiple unpins to undo.
- *
- *     Non GEM backed objects treat this as a no-op as they are always GTT
- *     backed objects.
- */
-int psb_gtt_pin(struct gtt_range *gt)
-{
-       int ret = 0;
-       struct drm_device *dev = gt->gem.dev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       mutex_lock(&dev_priv->gtt_mutex);
-
-       if (gt->in_gart == 0 && gt->stolen == 0) {
-               ret = psb_gtt_attach_pages(gt);
-               if (ret < 0)
-                       goto out;
-               ret = psb_gtt_insert(dev, gt);
-               if (ret < 0) {
-                       psb_gtt_detach_pages(gt);
-                       goto out;
-               }
-       }
-       gt->in_gart++;
-out:
-       mutex_unlock(&dev_priv->gtt_mutex);
-       return ret;
-}
-
-/**
- *     psb_gtt_unpin           -       Drop a GTT pin requirement
- *     @gt: range to pin
- *
- *     Undoes the effect of psb_gtt_pin. On the last drop the GEM object
- *     will be removed from the GTT which will also drop the page references
- *     and allow the VM to clean up or page stuff.
- *
- *     Non GEM backed objects treat this as a no-op as they are always GTT
- *     backed objects.
- */
-void psb_gtt_unpin(struct gtt_range *gt)
-{
-       struct drm_device *dev = gt->gem.dev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       mutex_lock(&dev_priv->gtt_mutex);
-
-       WARN_ON(!gt->in_gart);
-
-       gt->in_gart--;
-       if (gt->in_gart == 0 && gt->stolen == 0) {
-               psb_gtt_remove(dev, gt);
-               psb_gtt_detach_pages(gt);
-       }
-       mutex_unlock(&dev_priv->gtt_mutex);
-}
-
-/*
- *     GTT resource allocator - allocate and manage GTT address space
- */
-
-/**
- *     psb_gtt_alloc_range     -       allocate GTT address space
- *     @dev: Our DRM device
- *     @len: length (bytes) of address space required
- *     @name: resource name
- *     @backed: resource should be backed by stolen pages
- *
- *     Ask the kernel core to find us a suitable range of addresses
- *     to use for a GTT mapping.
- *
- *     Returns a gtt_range structure describing the object, or NULL on
- *     error. On successful return the resource is both allocated and marked
- *     as in use.
- */
-struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
-                                               const char *name, int backed)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct gtt_range *gt;
-       struct resource *r = dev_priv->gtt_mem;
-       int ret;
-       unsigned long start, end;
-
-       if (backed) {
-               /* The start of the GTT is the stolen pages */
-               start = r->start;
-               end = r->start + dev_priv->gtt.stolen_size - 1;
-       } else {
-               /* The rest we will use for GEM backed objects */
-               start = r->start + dev_priv->gtt.stolen_size;
-               end = r->end;
-       }
-
-       gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL);
-       if (gt == NULL)
-               return NULL;
-       gt->resource.name = name;
-       gt->stolen = backed;
-       gt->in_gart = backed;
-       gt->roll = 0;
-       /* Ensure this is set for non GEM objects */
-       gt->gem.dev = dev;
-       ret = allocate_resource(dev_priv->gtt_mem, &gt->resource,
-                               len, start, end, PAGE_SIZE, NULL, NULL);
-       if (ret == 0) {
-               gt->offset = gt->resource.start - r->start;
-               return gt;
-       }
-       kfree(gt);
-       return NULL;
-}
-
-/**
- *     psb_gtt_free_range      -       release GTT address space
- *     @dev: our DRM device
- *     @gt: a mapping created with psb_gtt_alloc_range
- *
- *     Release a resource that was allocated with psb_gtt_alloc_range. If the
- *     object has been pinned by mmap users we clean this up here currently.
- */
-void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt)
-{
-       /* Undo the mmap pin if we are destroying the object */
-       if (gt->mmapping) {
-               psb_gtt_unpin(gt);
-               gt->mmapping = 0;
-       }
-       WARN_ON(gt->in_gart && !gt->stolen);
-       release_resource(&gt->resource);
-       kfree(gt);
-}
-
-void psb_gtt_alloc(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       init_rwsem(&dev_priv->gtt.sem);
-}
-
-void psb_gtt_takedown(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       if (dev_priv->gtt_map) {
-               iounmap(dev_priv->gtt_map);
-               dev_priv->gtt_map = NULL;
-       }
-       if (dev_priv->gtt_initialized) {
-               pci_write_config_word(dev->pdev, PSB_GMCH_CTRL,
-                                     dev_priv->gmch_ctrl);
-               PSB_WVDC32(dev_priv->pge_ctl, PSB_PGETBL_CTL);
-               (void) PSB_RVDC32(PSB_PGETBL_CTL);
-       }
-       if (dev_priv->vram_addr)
-               iounmap(dev_priv->gtt_map);
-}
-
-int psb_gtt_init(struct drm_device *dev, int resume)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       unsigned gtt_pages;
-       unsigned long stolen_size, vram_stolen_size;
-       unsigned i, num_pages;
-       unsigned pfn_base;
-       uint32_t vram_pages;
-       uint32_t dvmt_mode = 0;
-       struct psb_gtt *pg;
-
-       int ret = 0;
-       uint32_t pte;
-
-       mutex_init(&dev_priv->gtt_mutex);
-
-       psb_gtt_alloc(dev);
-       pg = &dev_priv->gtt;
-
-       /* Enable the GTT */
-       pci_read_config_word(dev->pdev, PSB_GMCH_CTRL, &dev_priv->gmch_ctrl);
-       pci_write_config_word(dev->pdev, PSB_GMCH_CTRL,
-                             dev_priv->gmch_ctrl | _PSB_GMCH_ENABLED);
-
-       dev_priv->pge_ctl = PSB_RVDC32(PSB_PGETBL_CTL);
-       PSB_WVDC32(dev_priv->pge_ctl | _PSB_PGETBL_ENABLED, PSB_PGETBL_CTL);
-       (void) PSB_RVDC32(PSB_PGETBL_CTL);
-
-       /* The root resource we allocate address space from */
-       dev_priv->gtt_initialized = 1;
-
-       pg->gtt_phys_start = dev_priv->pge_ctl & PAGE_MASK;
-
-       /*
-        *      The video mmu has a hw bug when accessing 0x0D0000000.
-        *      Make gatt start at 0x0e000,0000. This doesn't actually
-        *      matter for us but may do if the video acceleration ever
-        *      gets opened up.
-        */
-       pg->mmu_gatt_start = 0xE0000000;
-
-       pg->gtt_start = pci_resource_start(dev->pdev, PSB_GTT_RESOURCE);
-       gtt_pages = pci_resource_len(dev->pdev, PSB_GTT_RESOURCE)
-                                                               >> PAGE_SHIFT;
-       /* Some CDV firmware doesn't report this currently. In which case the
-          system has 64 gtt pages */
-       if (pg->gtt_start == 0 || gtt_pages == 0) {
-               dev_err(dev->dev, "GTT PCI BAR not initialized.\n");
-               gtt_pages = 64;
-               pg->gtt_start = dev_priv->pge_ctl;
-       }
-
-       pg->gatt_start = pci_resource_start(dev->pdev, PSB_GATT_RESOURCE);
-       pg->gatt_pages = pci_resource_len(dev->pdev, PSB_GATT_RESOURCE)
-                                                               >> PAGE_SHIFT;
-       dev_priv->gtt_mem = &dev->pdev->resource[PSB_GATT_RESOURCE];
-
-       if (pg->gatt_pages == 0 || pg->gatt_start == 0) {
-               static struct resource fudge;   /* Preferably peppermint */
-               /* This can occur on CDV SDV systems. Fudge it in this case.
-                  We really don't care what imaginary space is being allocated
-                  at this point */
-               dev_err(dev->dev, "GATT PCI BAR not initialized.\n");
-               pg->gatt_start = 0x40000000;
-               pg->gatt_pages = (128 * 1024 * 1024) >> PAGE_SHIFT;
-               /* This is a little confusing but in fact the GTT is providing
-                  a view from the GPU into memory and not vice versa. As such
-                  this is really allocating space that is not the same as the
-                  CPU address space on CDV */
-               fudge.start = 0x40000000;
-               fudge.end = 0x40000000 + 128 * 1024 * 1024 - 1;
-               fudge.name = "fudge";
-               fudge.flags = IORESOURCE_MEM;
-               dev_priv->gtt_mem = &fudge;
-       }
-
-       pci_read_config_dword(dev->pdev, PSB_BSM, &dev_priv->stolen_base);
-       vram_stolen_size = pg->gtt_phys_start - dev_priv->stolen_base
-                                                               - PAGE_SIZE;
-
-       stolen_size = vram_stolen_size;
-
-       printk(KERN_INFO "Stolen memory information\n");
-       printk(KERN_INFO "       base in RAM: 0x%x\n", dev_priv->stolen_base);
-       printk(KERN_INFO "       size: %luK, calculated by (GTT RAM base) - (Stolen base), seems wrong\n",
-               vram_stolen_size/1024);
-       dvmt_mode = (dev_priv->gmch_ctrl >> 4) & 0x7;
-       printk(KERN_INFO "      the correct size should be: %dM(dvmt mode=%d)\n",
-               (dvmt_mode == 1) ? 1 : (2 << (dvmt_mode - 1)), dvmt_mode);
-
-       if (resume && (gtt_pages != pg->gtt_pages) &&
-           (stolen_size != pg->stolen_size)) {
-               dev_err(dev->dev, "GTT resume error.\n");
-               ret = -EINVAL;
-               goto out_err;
-       }
-
-       pg->gtt_pages = gtt_pages;
-       pg->stolen_size = stolen_size;
-       dev_priv->vram_stolen_size = vram_stolen_size;
-
-       /*
-        *      Map the GTT and the stolen memory area
-        */
-       dev_priv->gtt_map = ioremap_nocache(pg->gtt_phys_start,
-                                               gtt_pages << PAGE_SHIFT);
-       if (!dev_priv->gtt_map) {
-               dev_err(dev->dev, "Failure to map gtt.\n");
-               ret = -ENOMEM;
-               goto out_err;
-       }
-
-       dev_priv->vram_addr = ioremap_wc(dev_priv->stolen_base, stolen_size);
-       if (!dev_priv->vram_addr) {
-               dev_err(dev->dev, "Failure to map stolen base.\n");
-               ret = -ENOMEM;
-               goto out_err;
-       }
-
-       /*
-        * Insert vram stolen pages into the GTT
-        */
-
-       pfn_base = dev_priv->stolen_base >> PAGE_SHIFT;
-       vram_pages = num_pages = vram_stolen_size >> PAGE_SHIFT;
-       printk(KERN_INFO"Set up %d stolen pages starting at 0x%08x, GTT offset %dK\n",
-               num_pages, pfn_base << PAGE_SHIFT, 0);
-       for (i = 0; i < num_pages; ++i) {
-               pte = psb_gtt_mask_pte(pfn_base + i, 0);
-               iowrite32(pte, dev_priv->gtt_map + i);
-       }
-
-       /*
-        * Init rest of GTT to the scratch page to avoid accidents or scribbles
-        */
-
-       pfn_base = page_to_pfn(dev_priv->scratch_page);
-       pte = psb_gtt_mask_pte(pfn_base, 0);
-       for (; i < gtt_pages; ++i)
-               iowrite32(pte, dev_priv->gtt_map + i);
-
-       (void) ioread32(dev_priv->gtt_map + i - 1);
-       return 0;
-
-out_err:
-       psb_gtt_takedown(dev);
-       return ret;
-}
diff --git a/drivers/staging/gma500/gtt.h b/drivers/staging/gma500/gtt.h
deleted file mode 100644 (file)
index aa17423..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/**************************************************************************
- * Copyright (c) 2007-2008, 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.
- *
- **************************************************************************/
-
-#ifndef _PSB_GTT_H_
-#define _PSB_GTT_H_
-
-#include <drm/drmP.h>
-
-/* This wants cleaning up with respect to the psb_dev and un-needed stuff */
-struct psb_gtt {
-       uint32_t gatt_start;
-       uint32_t mmu_gatt_start;
-       uint32_t gtt_start;
-       uint32_t gtt_phys_start;
-       unsigned gtt_pages;
-       unsigned gatt_pages;
-       unsigned long stolen_size;
-       unsigned long vram_stolen_size;
-       struct rw_semaphore sem;
-};
-
-/* Exported functions */
-extern int psb_gtt_init(struct drm_device *dev, int resume);
-extern void psb_gtt_takedown(struct drm_device *dev);
-
-/* Each gtt_range describes an allocation in the GTT area */
-struct gtt_range {
-       struct resource resource;       /* Resource for our allocation */
-       u32 offset;                     /* GTT offset of our object */
-       struct drm_gem_object gem;      /* GEM high level stuff */
-       int in_gart;                    /* Currently in the GART (ref ct) */
-       bool stolen;                    /* Backed from stolen RAM */
-       bool mmapping;                  /* Is mmappable */
-       struct page **pages;            /* Backing pages if present */
-       int npage;                      /* Number of backing pages */
-       int roll;                       /* Roll applied to the GTT entries */
-};
-
-extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
-                                               const char *name, int backed);
-extern void psb_gtt_kref_put(struct gtt_range *gt);
-extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
-extern int psb_gtt_pin(struct gtt_range *gt);
-extern void psb_gtt_unpin(struct gtt_range *gt);
-extern void psb_gtt_roll(struct drm_device *dev,
-                                       struct gtt_range *gt, int roll);
-
-#endif
diff --git a/drivers/staging/gma500/intel_bios.c b/drivers/staging/gma500/intel_bios.c
deleted file mode 100644 (file)
index 096757f..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright (c) 2006 Intel Corporation
- *
- * 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.
- *
- * Authors:
- *    Eric Anholt <eric@anholt.net>
- *
- */
-#include <drm/drmP.h>
-#include <drm/drm.h>
-#include "psb_drm.h"
-#include "psb_drv.h"
-#include "psb_intel_drv.h"
-#include "psb_intel_reg.h"
-#include "intel_bios.h"
-
-
-static void *find_section(struct bdb_header *bdb, int section_id)
-{
-       u8 *base = (u8 *)bdb;
-       int index = 0;
-       u16 total, current_size;
-       u8 current_id;
-
-       /* skip to first section */
-       index += bdb->header_size;
-       total = bdb->bdb_size;
-
-       /* walk the sections looking for section_id */
-       while (index < total) {
-               current_id = *(base + index);
-               index++;
-               current_size = *((u16 *)(base + index));
-               index += 2;
-               if (current_id == section_id)
-                       return base + index;
-               index += current_size;
-       }
-
-       return NULL;
-}
-
-static void fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode,
-                       struct lvds_dvo_timing *dvo_timing)
-{
-       panel_fixed_mode->hdisplay = (dvo_timing->hactive_hi << 8) |
-               dvo_timing->hactive_lo;
-       panel_fixed_mode->hsync_start = panel_fixed_mode->hdisplay +
-               ((dvo_timing->hsync_off_hi << 8) | dvo_timing->hsync_off_lo);
-       panel_fixed_mode->hsync_end = panel_fixed_mode->hsync_start +
-               dvo_timing->hsync_pulse_width;
-       panel_fixed_mode->htotal = panel_fixed_mode->hdisplay +
-               ((dvo_timing->hblank_hi << 8) | dvo_timing->hblank_lo);
-
-       panel_fixed_mode->vdisplay = (dvo_timing->vactive_hi << 8) |
-               dvo_timing->vactive_lo;
-       panel_fixed_mode->vsync_start = panel_fixed_mode->vdisplay +
-               dvo_timing->vsync_off;
-       panel_fixed_mode->vsync_end = panel_fixed_mode->vsync_start +
-               dvo_timing->vsync_pulse_width;
-       panel_fixed_mode->vtotal = panel_fixed_mode->vdisplay +
-               ((dvo_timing->vblank_hi << 8) | dvo_timing->vblank_lo);
-       panel_fixed_mode->clock = dvo_timing->clock * 10;
-       panel_fixed_mode->type = DRM_MODE_TYPE_PREFERRED;
-
-       /* Some VBTs have bogus h/vtotal values */
-       if (panel_fixed_mode->hsync_end > panel_fixed_mode->htotal)
-               panel_fixed_mode->htotal = panel_fixed_mode->hsync_end + 1;
-       if (panel_fixed_mode->vsync_end > panel_fixed_mode->vtotal)
-               panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1;
-
-       drm_mode_set_name(panel_fixed_mode);
-}
-
-static void parse_backlight_data(struct drm_psb_private *dev_priv,
-                               struct bdb_header *bdb)
-{
-       struct bdb_lvds_backlight *vbt_lvds_bl = NULL;
-       struct bdb_lvds_backlight *lvds_bl;
-       u8 p_type = 0;
-       void *bl_start = NULL;
-       struct bdb_lvds_options *lvds_opts
-                               = find_section(bdb, BDB_LVDS_OPTIONS);
-
-       dev_priv->lvds_bl = NULL;
-
-       if (lvds_opts)
-               p_type = lvds_opts->panel_type;
-       else
-               return;
-
-       bl_start = find_section(bdb, BDB_LVDS_BACKLIGHT);
-       vbt_lvds_bl = (struct bdb_lvds_backlight *)(bl_start + 1) + p_type;
-
-       lvds_bl = kzalloc(sizeof(*vbt_lvds_bl), GFP_KERNEL);
-       if (!lvds_bl) {
-               dev_err(dev_priv->dev->dev, "out of memory for backlight data\n");
-               return;
-       }
-       memcpy(lvds_bl, vbt_lvds_bl, sizeof(*vbt_lvds_bl));
-       dev_priv->lvds_bl = lvds_bl;
-}
-
-/* Try to find integrated panel data */
-static void parse_lfp_panel_data(struct drm_psb_private *dev_priv,
-                           struct bdb_header *bdb)
-{
-       struct bdb_lvds_options *lvds_options;
-       struct bdb_lvds_lfp_data *lvds_lfp_data;
-       struct bdb_lvds_lfp_data_entry *entry;
-       struct lvds_dvo_timing *dvo_timing;
-       struct drm_display_mode *panel_fixed_mode;
-
-       /* Defaults if we can't find VBT info */
-       dev_priv->lvds_dither = 0;
-       dev_priv->lvds_vbt = 0;
-
-       lvds_options = find_section(bdb, BDB_LVDS_OPTIONS);
-       if (!lvds_options)
-               return;
-
-       dev_priv->lvds_dither = lvds_options->pixel_dither;
-       if (lvds_options->panel_type == 0xff)
-               return;
-
-       lvds_lfp_data = find_section(bdb, BDB_LVDS_LFP_DATA);
-       if (!lvds_lfp_data)
-               return;
-
-
-       entry = &lvds_lfp_data->data[lvds_options->panel_type];
-       dvo_timing = &entry->dvo_timing;
-
-       panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode),
-                                     GFP_KERNEL);
-       if (panel_fixed_mode == NULL) {
-               dev_err(dev_priv->dev->dev, "out of memory for fixed panel mode\n");
-               return;
-       }
-
-       dev_priv->lvds_vbt = 1;
-       fill_detail_timing_data(panel_fixed_mode, dvo_timing);
-
-       if (panel_fixed_mode->htotal > 0 && panel_fixed_mode->vtotal > 0) {
-               dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
-               drm_mode_debug_printmodeline(panel_fixed_mode);
-       } else {
-               dev_dbg(dev_priv->dev->dev, "ignoring invalid LVDS VBT\n");
-               dev_priv->lvds_vbt = 0;
-               kfree(panel_fixed_mode);
-       }
-       return;
-}
-
-/* Try to find sdvo panel data */
-static void parse_sdvo_panel_data(struct drm_psb_private *dev_priv,
-                     struct bdb_header *bdb)
-{
-       struct bdb_sdvo_lvds_options *sdvo_lvds_options;
-       struct lvds_dvo_timing *dvo_timing;
-       struct drm_display_mode *panel_fixed_mode;
-
-       dev_priv->sdvo_lvds_vbt_mode = NULL;
-
-       sdvo_lvds_options = find_section(bdb, BDB_SDVO_LVDS_OPTIONS);
-       if (!sdvo_lvds_options)
-               return;
-
-       dvo_timing = find_section(bdb, BDB_SDVO_PANEL_DTDS);
-       if (!dvo_timing)
-               return;
-
-       panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
-
-       if (!panel_fixed_mode)
-               return;
-
-       fill_detail_timing_data(panel_fixed_mode,
-                       dvo_timing + sdvo_lvds_options->panel_type);
-
-       dev_priv->sdvo_lvds_vbt_mode = panel_fixed_mode;
-
-       return;
-}
-
-static void parse_general_features(struct drm_psb_private *dev_priv,
-                      struct bdb_header *bdb)
-{
-       struct bdb_general_features *general;
-
-       /* Set sensible defaults in case we can't find the general block */
-       dev_priv->int_tv_support = 1;
-       dev_priv->int_crt_support = 1;
-
-       general = find_section(bdb, BDB_GENERAL_FEATURES);
-       if (general) {
-               dev_priv->int_tv_support = general->int_tv_support;
-               dev_priv->int_crt_support = general->int_crt_support;
-               dev_priv->lvds_use_ssc = general->enable_ssc;
-
-               if (dev_priv->lvds_use_ssc) {
-                       dev_priv->lvds_ssc_freq
-                               = general->ssc_freq ? 100 : 96;
-               }
-       }
-}
-
-/**
- * psb_intel_init_bios - initialize VBIOS settings & find VBT
- * @dev: DRM device
- *
- * Loads the Video BIOS and checks that the VBT exists.  Sets scratch registers
- * to appropriate values.
- *
- * VBT existence is a sanity check that is relied on by other i830_bios.c code.
- * Note that it would be better to use a BIOS call to get the VBT, as BIOSes may
- * feed an updated VBT back through that, compared to what we'll fetch using
- * this method of groping around in the BIOS data.
- *
- * Returns 0 on success, nonzero on failure.
- */
-bool psb_intel_init_bios(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct pci_dev *pdev = dev->pdev;
-       struct vbt_header *vbt = NULL;
-       struct bdb_header *bdb;
-       u8 __iomem *bios;
-       size_t size;
-       int i;
-
-       bios = pci_map_rom(pdev, &size);
-       if (!bios)
-               return -1;
-
-       /* Scour memory looking for the VBT signature */
-       for (i = 0; i + 4 < size; i++) {
-               if (!memcmp(bios + i, "$VBT", 4)) {
-                       vbt = (struct vbt_header *)(bios + i);
-                       break;
-               }
-       }
-
-       if (!vbt) {
-               dev_err(dev->dev, "VBT signature missing\n");
-               pci_unmap_rom(pdev, bios);
-               return -1;
-       }
-
-       bdb = (struct bdb_header *)(bios + i + vbt->bdb_offset);
-
-       /* Grab useful general definitions */
-       parse_general_features(dev_priv, bdb);
-       parse_lfp_panel_data(dev_priv, bdb);
-       parse_sdvo_panel_data(dev_priv, bdb);
-       parse_backlight_data(dev_priv, bdb);
-
-       pci_unmap_rom(pdev, bios);
-
-       return 0;
-}
-
-/**
- * Destroy and free VBT data
- */
-void psb_intel_destroy_bios(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct drm_display_mode *sdvo_lvds_vbt_mode =
-                               dev_priv->sdvo_lvds_vbt_mode;
-       struct drm_display_mode *lfp_lvds_vbt_mode =
-                               dev_priv->lfp_lvds_vbt_mode;
-       struct bdb_lvds_backlight *lvds_bl =
-                               dev_priv->lvds_bl;
-
-       /*free sdvo panel mode*/
-       if (sdvo_lvds_vbt_mode) {
-               dev_priv->sdvo_lvds_vbt_mode = NULL;
-               kfree(sdvo_lvds_vbt_mode);
-       }
-
-       if (lfp_lvds_vbt_mode) {
-               dev_priv->lfp_lvds_vbt_mode = NULL;
-               kfree(lfp_lvds_vbt_mode);
-       }
-
-       if (lvds_bl) {
-               dev_priv->lvds_bl = NULL;
-               kfree(lvds_bl);
-       }
-}
diff --git a/drivers/staging/gma500/intel_bios.h b/drivers/staging/gma500/intel_bios.h
deleted file mode 100644 (file)
index 70f1bf0..0000000
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Copyright (c) 2006 Intel Corporation
- *
- * 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.
- *
- * Authors:
- *    Eric Anholt <eric@anholt.net>
- *
- */
-
-#ifndef _I830_BIOS_H_
-#define _I830_BIOS_H_
-
-#include <drm/drmP.h>
-
-struct vbt_header {
-       u8 signature[20];               /**< Always starts with 'VBT$' */
-       u16 version;                    /**< decimal */
-       u16 header_size;                /**< in bytes */
-       u16 vbt_size;                   /**< in bytes */
-       u8 vbt_checksum;
-       u8 reserved0;
-       u32 bdb_offset;                 /**< from beginning of VBT */
-       u32 aim_offset[4];              /**< from beginning of VBT */
-} __attribute__((packed));
-
-
-struct bdb_header {
-       u8 signature[16];               /**< Always 'BIOS_DATA_BLOCK' */
-       u16 version;                    /**< decimal */
-       u16 header_size;                /**< in bytes */
-       u16 bdb_size;                   /**< in bytes */
-};
-
-/* strictly speaking, this is a "skip" block, but it has interesting info */
-struct vbios_data {
-       u8 type; /* 0 == desktop, 1 == mobile */
-       u8 relstage;
-       u8 chipset;
-       u8 lvds_present:1;
-       u8 tv_present:1;
-       u8 rsvd2:6; /* finish byte */
-       u8 rsvd3[4];
-       u8 signon[155];
-       u8 copyright[61];
-       u16 code_segment;
-       u8 dos_boot_mode;
-       u8 bandwidth_percent;
-       u8 rsvd4; /* popup memory size */
-       u8 resize_pci_bios;
-       u8 rsvd5; /* is crt already on ddc2 */
-} __attribute__((packed));
-
-/*
- * There are several types of BIOS data blocks (BDBs), each block has
- * an ID and size in the first 3 bytes (ID in first, size in next 2).
- * Known types are listed below.
- */
-#define BDB_GENERAL_FEATURES     1
-#define BDB_GENERAL_DEFINITIONS          2
-#define BDB_OLD_TOGGLE_LIST      3
-#define BDB_MODE_SUPPORT_LIST    4
-#define BDB_GENERIC_MODE_TABLE   5
-#define BDB_EXT_MMIO_REGS        6
-#define BDB_SWF_IO               7
-#define BDB_SWF_MMIO             8
-#define BDB_DOT_CLOCK_TABLE      9
-#define BDB_MODE_REMOVAL_TABLE  10
-#define BDB_CHILD_DEVICE_TABLE  11
-#define BDB_DRIVER_FEATURES     12
-#define BDB_DRIVER_PERSISTENCE  13
-#define BDB_EXT_TABLE_PTRS      14
-#define BDB_DOT_CLOCK_OVERRIDE  15
-#define BDB_DISPLAY_SELECT      16
-/* 17 rsvd */
-#define BDB_DRIVER_ROTATION     18
-#define BDB_DISPLAY_REMOVE      19
-#define BDB_OEM_CUSTOM          20
-#define BDB_EFP_LIST            21 /* workarounds for VGA hsync/vsync */
-#define BDB_SDVO_LVDS_OPTIONS   22
-#define BDB_SDVO_PANEL_DTDS     23
-#define BDB_SDVO_LVDS_PNP_IDS   24
-#define BDB_SDVO_LVDS_POWER_SEQ         25
-#define BDB_TV_OPTIONS          26
-#define BDB_LVDS_OPTIONS        40
-#define BDB_LVDS_LFP_DATA_PTRS  41
-#define BDB_LVDS_LFP_DATA       42
-#define BDB_LVDS_BACKLIGHT      43
-#define BDB_LVDS_POWER          44
-#define BDB_SKIP               254 /* VBIOS private block, ignore */
-
-struct bdb_general_features {
-       /* bits 1 */
-       u8 panel_fitting:2;
-       u8 flexaim:1;
-       u8 msg_enable:1;
-       u8 clear_screen:3;
-       u8 color_flip:1;
-
-       /* bits 2 */
-       u8 download_ext_vbt:1;
-       u8 enable_ssc:1;
-       u8 ssc_freq:1;
-       u8 enable_lfp_on_override:1;
-       u8 disable_ssc_ddt:1;
-       u8 rsvd8:3; /* finish byte */
-
-       /* bits 3 */
-       u8 disable_smooth_vision:1;
-       u8 single_dvi:1;
-       u8 rsvd9:6; /* finish byte */
-
-       /* bits 4 */
-       u8 legacy_monitor_detect;
-
-       /* bits 5 */
-       u8 int_crt_support:1;
-       u8 int_tv_support:1;
-       u8 rsvd11:6; /* finish byte */
-} __attribute__((packed));
-
-struct bdb_general_definitions {
-       /* DDC GPIO */
-       u8 crt_ddc_gmbus_pin;
-
-       /* DPMS bits */
-       u8 dpms_acpi:1;
-       u8 skip_boot_crt_detect:1;
-       u8 dpms_aim:1;
-       u8 rsvd1:5; /* finish byte */
-
-       /* boot device bits */
-       u8 boot_display[2];
-       u8 child_dev_size;
-
-       /* device info */
-       u8 tv_or_lvds_info[33];
-       u8 dev1[33];
-       u8 dev2[33];
-       u8 dev3[33];
-       u8 dev4[33];
-       /* may be another device block here on some platforms */
-};
-
-struct bdb_lvds_options {
-       u8 panel_type;
-       u8 rsvd1;
-       /* LVDS capabilities, stored in a dword */
-       u8 pfit_mode:2;
-       u8 pfit_text_mode_enhanced:1;
-       u8 pfit_gfx_mode_enhanced:1;
-       u8 pfit_ratio_auto:1;
-       u8 pixel_dither:1;
-       u8 lvds_edid:1;
-       u8 rsvd2:1;
-       u8 rsvd4;
-} __attribute__((packed));
-
-struct bdb_lvds_backlight {
-       u8 type:2;
-       u8 pol:1;
-       u8 gpio:3;
-       u8 gmbus:2;
-       u16 freq;
-       u8 minbrightness;
-       u8 i2caddr;
-       u8 brightnesscmd;
-       /*FIXME: more...*/
-} __attribute__((packed));
-
-/* LFP pointer table contains entries to the struct below */
-struct bdb_lvds_lfp_data_ptr {
-       u16 fp_timing_offset; /* offsets are from start of bdb */
-       u8 fp_table_size;
-       u16 dvo_timing_offset;
-       u8 dvo_table_size;
-       u16 panel_pnp_id_offset;
-       u8 pnp_table_size;
-} __attribute__((packed));
-
-struct bdb_lvds_lfp_data_ptrs {
-       u8 lvds_entries; /* followed by one or more lvds_data_ptr structs */
-       struct bdb_lvds_lfp_data_ptr ptr[16];
-} __attribute__((packed));
-
-/* LFP data has 3 blocks per entry */
-struct lvds_fp_timing {
-       u16 x_res;
-       u16 y_res;
-       u32 lvds_reg;
-       u32 lvds_reg_val;
-       u32 pp_on_reg;
-       u32 pp_on_reg_val;
-       u32 pp_off_reg;
-       u32 pp_off_reg_val;
-       u32 pp_cycle_reg;
-       u32 pp_cycle_reg_val;
-       u32 pfit_reg;
-       u32 pfit_reg_val;
-       u16 terminator;
-} __attribute__((packed));
-
-struct lvds_dvo_timing {
-       u16 clock;              /**< In 10khz */
-       u8 hactive_lo;
-       u8 hblank_lo;
-       u8 hblank_hi:4;
-       u8 hactive_hi:4;
-       u8 vactive_lo;
-       u8 vblank_lo;
-       u8 vblank_hi:4;
-       u8 vactive_hi:4;
-       u8 hsync_off_lo;
-       u8 hsync_pulse_width;
-       u8 vsync_pulse_width:4;
-       u8 vsync_off:4;
-       u8 rsvd0:6;
-       u8 hsync_off_hi:2;
-       u8 h_image;
-       u8 v_image;
-       u8 max_hv;
-       u8 h_border;
-       u8 v_border;
-       u8 rsvd1:3;
-       u8 digital:2;
-       u8 vsync_positive:1;
-       u8 hsync_positive:1;
-       u8 rsvd2:1;
-} __attribute__((packed));
-
-struct lvds_pnp_id {
-       u16 mfg_name;
-       u16 product_code;
-       u32 serial;
-       u8 mfg_week;
-       u8 mfg_year;
-} __attribute__((packed));
-
-struct bdb_lvds_lfp_data_entry {
-       struct lvds_fp_timing fp_timing;
-       struct lvds_dvo_timing dvo_timing;
-       struct lvds_pnp_id pnp_id;
-} __attribute__((packed));
-
-struct bdb_lvds_lfp_data {
-       struct bdb_lvds_lfp_data_entry data[16];
-} __attribute__((packed));
-
-struct aimdb_header {
-       char signature[16];
-       char oem_device[20];
-       u16 aimdb_version;
-       u16 aimdb_header_size;
-       u16 aimdb_size;
-} __attribute__((packed));
-
-struct aimdb_block {
-       u8 aimdb_id;
-       u16 aimdb_size;
-} __attribute__((packed));
-
-struct vch_panel_data {
-       u16 fp_timing_offset;
-       u8 fp_timing_size;
-       u16 dvo_timing_offset;
-       u8 dvo_timing_size;
-       u16 text_fitting_offset;
-       u8 text_fitting_size;
-       u16 graphics_fitting_offset;
-       u8 graphics_fitting_size;
-} __attribute__((packed));
-
-struct vch_bdb_22 {
-       struct aimdb_block aimdb_block;
-       struct vch_panel_data panels[16];
-} __attribute__((packed));
-
-struct bdb_sdvo_lvds_options {
-       u8 panel_backlight;
-       u8 h40_set_panel_type;
-       u8 panel_type;
-       u8 ssc_clk_freq;
-       u16 als_low_trip;
-       u16 als_high_trip;
-       u8 sclalarcoeff_tab_row_num;
-       u8 sclalarcoeff_tab_row_size;
-       u8 coefficient[8];
-       u8 panel_misc_bits_1;
-       u8 panel_misc_bits_2;
-       u8 panel_misc_bits_3;
-       u8 panel_misc_bits_4;
-} __attribute__((packed));
-
-
-extern bool psb_intel_init_bios(struct drm_device *dev);
-extern void psb_intel_destroy_bios(struct drm_device *dev);
-
-/*
- * Driver<->VBIOS interaction occurs through scratch bits in
- * GR18 & SWF*.
- */
-
-/* GR18 bits are set on display switch and hotkey events */
-#define GR18_DRIVER_SWITCH_EN  (1<<7) /* 0: VBIOS control, 1: driver control */
-#define GR18_HOTKEY_MASK       0x78 /* See also SWF4 15:0 */
-#define   GR18_HK_NONE         (0x0<<3)
-#define   GR18_HK_LFP_STRETCH  (0x1<<3)
-#define   GR18_HK_TOGGLE_DISP  (0x2<<3)
-#define   GR18_HK_DISP_SWITCH  (0x4<<3) /* see SWF14 15:0 for what to enable */
-#define   GR18_HK_POPUP_DISABLED (0x6<<3)
-#define   GR18_HK_POPUP_ENABLED        (0x7<<3)
-#define   GR18_HK_PFIT         (0x8<<3)
-#define   GR18_HK_APM_CHANGE   (0xa<<3)
-#define   GR18_HK_MULTIPLE     (0xc<<3)
-#define GR18_USER_INT_EN       (1<<2)
-#define GR18_A0000_FLUSH_EN    (1<<1)
-#define GR18_SMM_EN            (1<<0)
-
-/* Set by driver, cleared by VBIOS */
-#define SWF00_YRES_SHIFT       16
-#define SWF00_XRES_SHIFT       0
-#define SWF00_RES_MASK         0xffff
-
-/* Set by VBIOS at boot time and driver at runtime */
-#define SWF01_TV2_FORMAT_SHIFT 8
-#define SWF01_TV1_FORMAT_SHIFT 0
-#define SWF01_TV_FORMAT_MASK   0xffff
-
-#define SWF10_VBIOS_BLC_I2C_EN (1<<29)
-#define SWF10_GTT_OVERRIDE_EN  (1<<28)
-#define SWF10_LFP_DPMS_OVR     (1<<27) /* override DPMS on display switch */
-#define SWF10_ACTIVE_TOGGLE_LIST_MASK (7<<24)
-#define   SWF10_OLD_TOGGLE     0x0
-#define   SWF10_TOGGLE_LIST_1  0x1
-#define   SWF10_TOGGLE_LIST_2  0x2
-#define   SWF10_TOGGLE_LIST_3  0x3
-#define   SWF10_TOGGLE_LIST_4  0x4
-#define SWF10_PANNING_EN       (1<<23)
-#define SWF10_DRIVER_LOADED    (1<<22)
-#define SWF10_EXTENDED_DESKTOP (1<<21)
-#define SWF10_EXCLUSIVE_MODE   (1<<20)
-#define SWF10_OVERLAY_EN       (1<<19)
-#define SWF10_PLANEB_HOLDOFF   (1<<18)
-#define SWF10_PLANEA_HOLDOFF   (1<<17)
-#define SWF10_VGA_HOLDOFF      (1<<16)
-#define SWF10_ACTIVE_DISP_MASK 0xffff
-#define   SWF10_PIPEB_LFP2     (1<<15)
-#define   SWF10_PIPEB_EFP2     (1<<14)
-#define   SWF10_PIPEB_TV2      (1<<13)
-#define   SWF10_PIPEB_CRT2     (1<<12)
-#define   SWF10_PIPEB_LFP      (1<<11)
-#define   SWF10_PIPEB_EFP      (1<<10)
-#define   SWF10_PIPEB_TV       (1<<9)
-#define   SWF10_PIPEB_CRT      (1<<8)
-#define   SWF10_PIPEA_LFP2     (1<<7)
-#define   SWF10_PIPEA_EFP2     (1<<6)
-#define   SWF10_PIPEA_TV2      (1<<5)
-#define   SWF10_PIPEA_CRT2     (1<<4)
-#define   SWF10_PIPEA_LFP      (1<<3)
-#define   SWF10_PIPEA_EFP      (1<<2)
-#define   SWF10_PIPEA_TV       (1<<1)
-#define   SWF10_PIPEA_CRT      (1<<0)
-
-#define SWF11_MEMORY_SIZE_SHIFT        16
-#define SWF11_SV_TEST_EN       (1<<15)
-#define SWF11_IS_AGP           (1<<14)
-#define SWF11_DISPLAY_HOLDOFF  (1<<13)
-#define SWF11_DPMS_REDUCED     (1<<12)
-#define SWF11_IS_VBE_MODE      (1<<11)
-#define SWF11_PIPEB_ACCESS     (1<<10) /* 0 here means pipe a */
-#define SWF11_DPMS_MASK                0x07
-#define   SWF11_DPMS_OFF       (1<<2)
-#define   SWF11_DPMS_SUSPEND   (1<<1)
-#define   SWF11_DPMS_STANDBY   (1<<0)
-#define   SWF11_DPMS_ON                0
-
-#define SWF14_GFX_PFIT_EN      (1<<31)
-#define SWF14_TEXT_PFIT_EN     (1<<30)
-#define SWF14_LID_STATUS_CLOSED        (1<<29) /* 0 here means open */
-#define SWF14_POPUP_EN         (1<<28)
-#define SWF14_DISPLAY_HOLDOFF  (1<<27)
-#define SWF14_DISP_DETECT_EN   (1<<26)
-#define SWF14_DOCKING_STATUS_DOCKED (1<<25) /* 0 here means undocked */
-#define SWF14_DRIVER_STATUS    (1<<24)
-#define SWF14_OS_TYPE_WIN9X    (1<<23)
-#define SWF14_OS_TYPE_WINNT    (1<<22)
-/* 21:19 rsvd */
-#define SWF14_PM_TYPE_MASK     0x00070000
-#define   SWF14_PM_ACPI_VIDEO  (0x4 << 16)
-#define   SWF14_PM_ACPI                (0x3 << 16)
-#define   SWF14_PM_APM_12      (0x2 << 16)
-#define   SWF14_PM_APM_11      (0x1 << 16)
-#define SWF14_HK_REQUEST_MASK  0x0000ffff /* see GR18 6:3 for event type */
-         /* if GR18 indicates a display switch */
-#define   SWF14_DS_PIPEB_LFP2_EN (1<<15)
-#define   SWF14_DS_PIPEB_EFP2_EN (1<<14)
-#define   SWF14_DS_PIPEB_TV2_EN  (1<<13)
-#define   SWF14_DS_PIPEB_CRT2_EN (1<<12)
-#define   SWF14_DS_PIPEB_LFP_EN  (1<<11)
-#define   SWF14_DS_PIPEB_EFP_EN  (1<<10)
-#define   SWF14_DS_PIPEB_TV_EN  (1<<9)
-#define   SWF14_DS_PIPEB_CRT_EN  (1<<8)
-#define   SWF14_DS_PIPEA_LFP2_EN (1<<7)
-#define   SWF14_DS_PIPEA_EFP2_EN (1<<6)
-#define   SWF14_DS_PIPEA_TV2_EN  (1<<5)
-#define   SWF14_DS_PIPEA_CRT2_EN (1<<4)
-#define   SWF14_DS_PIPEA_LFP_EN  (1<<3)
-#define   SWF14_DS_PIPEA_EFP_EN  (1<<2)
-#define   SWF14_DS_PIPEA_TV_EN  (1<<1)
-#define   SWF14_DS_PIPEA_CRT_EN  (1<<0)
-         /* if GR18 indicates a panel fitting request */
-#define   SWF14_PFIT_EN                (1<<0) /* 0 means disable */
-         /* if GR18 indicates an APM change request */
-#define   SWF14_APM_HIBERNATE  0x4
-#define   SWF14_APM_SUSPEND    0x3
-#define   SWF14_APM_STANDBY    0x1
-#define   SWF14_APM_RESTORE    0x0
-
-#endif /* _I830_BIOS_H_ */
diff --git a/drivers/staging/gma500/intel_i2c.c b/drivers/staging/gma500/intel_i2c.c
deleted file mode 100644 (file)
index 51cbf65..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright © 2006-2007 Intel Corporation
- *
- * 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.
- *
- * Authors:
- *     Eric Anholt <eric@anholt.net>
- */
-
-#include <linux/i2c.h>
-#include <linux/i2c-algo-bit.h>
-#include <linux/export.h>
-
-#include "psb_drv.h"
-#include "psb_intel_reg.h"
-
-/*
- * Intel GPIO access functions
- */
-
-#define I2C_RISEFALL_TIME 20
-
-static int get_clock(void *data)
-{
-       struct psb_intel_i2c_chan *chan = data;
-       struct drm_device *dev = chan->drm_dev;
-       u32 val;
-
-       val = REG_READ(chan->reg);
-       return (val & GPIO_CLOCK_VAL_IN) != 0;
-}
-
-static int get_data(void *data)
-{
-       struct psb_intel_i2c_chan *chan = data;
-       struct drm_device *dev = chan->drm_dev;
-       u32 val;
-
-       val = REG_READ(chan->reg);
-       return (val & GPIO_DATA_VAL_IN) != 0;
-}
-
-static void set_clock(void *data, int state_high)
-{
-       struct psb_intel_i2c_chan *chan = data;
-       struct drm_device *dev = chan->drm_dev;
-       u32 reserved = 0, clock_bits;
-
-       /* On most chips, these bits must be preserved in software. */
-       reserved =
-                   REG_READ(chan->reg) & (GPIO_DATA_PULLUP_DISABLE |
-                                          GPIO_CLOCK_PULLUP_DISABLE);
-
-       if (state_high)
-               clock_bits = GPIO_CLOCK_DIR_IN | GPIO_CLOCK_DIR_MASK;
-       else
-               clock_bits = GPIO_CLOCK_DIR_OUT | GPIO_CLOCK_DIR_MASK |
-                   GPIO_CLOCK_VAL_MASK;
-       REG_WRITE(chan->reg, reserved | clock_bits);
-       udelay(I2C_RISEFALL_TIME);      /* wait for the line to change state */
-}
-
-static void set_data(void *data, int state_high)
-{
-       struct psb_intel_i2c_chan *chan = data;
-       struct drm_device *dev = chan->drm_dev;
-       u32 reserved = 0, data_bits;
-
-       /* On most chips, these bits must be preserved in software. */
-       reserved =
-                   REG_READ(chan->reg) & (GPIO_DATA_PULLUP_DISABLE |
-                                          GPIO_CLOCK_PULLUP_DISABLE);
-
-       if (state_high)
-               data_bits = GPIO_DATA_DIR_IN | GPIO_DATA_DIR_MASK;
-       else
-               data_bits =
-                   GPIO_DATA_DIR_OUT | GPIO_DATA_DIR_MASK |
-                   GPIO_DATA_VAL_MASK;
-
-       REG_WRITE(chan->reg, reserved | data_bits);
-       udelay(I2C_RISEFALL_TIME);      /* wait for the line to change state */
-}
-
-/**
- * psb_intel_i2c_create - instantiate an Intel i2c bus using the specified GPIO reg
- * @dev: DRM device
- * @output: driver specific output device
- * @reg: GPIO reg to use
- * @name: name for this bus
- *
- * Creates and registers a new i2c bus with the Linux i2c layer, for use
- * in output probing and control (e.g. DDC or SDVO control functions).
- *
- * Possible values for @reg include:
- *   %GPIOA
- *   %GPIOB
- *   %GPIOC
- *   %GPIOD
- *   %GPIOE
- *   %GPIOF
- *   %GPIOG
- *   %GPIOH
- * see PRM for details on how these different busses are used.
- */
-struct psb_intel_i2c_chan *psb_intel_i2c_create(struct drm_device *dev,
-                                       const u32 reg, const char *name)
-{
-       struct psb_intel_i2c_chan *chan;
-
-       chan = kzalloc(sizeof(struct psb_intel_i2c_chan), GFP_KERNEL);
-       if (!chan)
-               goto out_free;
-
-       chan->drm_dev = dev;
-       chan->reg = reg;
-       snprintf(chan->adapter.name, I2C_NAME_SIZE, "intel drm %s", name);
-       chan->adapter.owner = THIS_MODULE;
-       chan->adapter.algo_data = &chan->algo;
-       chan->adapter.dev.parent = &dev->pdev->dev;
-       chan->algo.setsda = set_data;
-       chan->algo.setscl = set_clock;
-       chan->algo.getsda = get_data;
-       chan->algo.getscl = get_clock;
-       chan->algo.udelay = 20;
-       chan->algo.timeout = usecs_to_jiffies(2200);
-       chan->algo.data = chan;
-
-       i2c_set_adapdata(&chan->adapter, chan);
-
-       if (i2c_bit_add_bus(&chan->adapter))
-               goto out_free;
-
-       /* JJJ:  raise SCL and SDA? */
-       set_data(chan, 1);
-       set_clock(chan, 1);
-       udelay(20);
-
-       return chan;
-
-out_free:
-       kfree(chan);
-       return NULL;
-}
-
-/**
- * psb_intel_i2c_destroy - unregister and free i2c bus resources
- * @output: channel to free
- *
- * Unregister the adapter from the i2c layer, then free the structure.
- */
-void psb_intel_i2c_destroy(struct psb_intel_i2c_chan *chan)
-{
-       if (!chan)
-               return;
-
-       i2c_del_adapter(&chan->adapter);
-       kfree(chan);
-}
diff --git a/drivers/staging/gma500/intel_opregion.c b/drivers/staging/gma500/intel_opregion.c
deleted file mode 100644 (file)
index d946bc1..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * FIXME: resolve with the i915 version
- */
-
-#include "psb_drv.h"
-
-struct opregion_header {
-       u8 signature[16];
-       u32 size;
-       u32 opregion_ver;
-       u8 bios_ver[32];
-       u8 vbios_ver[16];
-       u8 driver_ver[16];
-       u32 mboxes;
-       u8 reserved[164];
-} __packed;
-
-struct opregion_apci {
-       /*FIXME: add it later*/
-} __packed;
-
-struct opregion_swsci {
-       /*FIXME: add it later*/
-} __packed;
-
-struct opregion_acpi {
-       /*FIXME: add it later*/
-} __packed;
-
-int gma_intel_opregion_init(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       u32 opregion_phy;
-       void *base;
-       u32 *lid_state;
-
-       dev_priv->lid_state = NULL;
-
-       pci_read_config_dword(dev->pdev, 0xfc, &opregion_phy);
-       if (opregion_phy == 0)
-               return -ENOTSUPP;
-
-       base = ioremap(opregion_phy, 8*1024);
-       if (!base)
-               return -ENOMEM;
-
-       lid_state = base + 0x01ac;
-
-       dev_priv->lid_state = lid_state;
-       dev_priv->lid_last_state = readl(lid_state);
-       return 0;
-}
-
-int gma_intel_opregion_exit(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       if (dev_priv->lid_state)
-               iounmap(dev_priv->lid_state);
-       return 0;
-}
diff --git a/drivers/staging/gma500/mdfld_device.c b/drivers/staging/gma500/mdfld_device.c
deleted file mode 100644 (file)
index f47aeb7..0000000
+++ /dev/null
@@ -1,714 +0,0 @@
-/**************************************************************************
- * 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>
-#include "psb_reg.h"
-#include "psb_intel_reg.h"
-#include "psb_drm.h"
-#include "psb_drv.h"
-#include "mdfld_output.h"
-#include "mdfld_dsi_output.h"
-#include "mid_bios.h"
-
-/*
- *     Provide the Medfield specific backlight management
- */
-
-#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-
-static int mdfld_brightness;
-struct backlight_device *mdfld_backlight_device;
-
-static int mfld_set_brightness(struct backlight_device *bd)
-{
-       struct drm_device *dev = bl_get_data(mdfld_backlight_device);
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       int level = bd->props.brightness;
-
-       /* Percentage 1-100% being valid */
-       if (level < 1)
-               level = 1;
-
-       if (gma_power_begin(dev, 0)) {
-               /* Calculate and set the brightness value */
-               u32 adjusted_level;
-
-               /* Adjust the backlight level with the percent in
-                * dev_priv->blc_adj2;
-                */
-               adjusted_level = level * dev_priv->blc_adj2;
-               adjusted_level = adjusted_level / 100;
-#if 0
-#ifndef CONFIG_MDFLD_DSI_DPU
-               if(!(dev_priv->dsr_fb_update & MDFLD_DSR_MIPI_CONTROL) && 
-                       (dev_priv->dbi_panel_on || dev_priv->dbi_panel_on2)){
-                       mdfld_dsi_dbi_exit_dsr(dev,MDFLD_DSR_MIPI_CONTROL, 0, 0);
-                       dev_dbg(dev->dev, "Out of DSR before set brightness to %d.\n",adjusted_level);
-               }
-#endif
-               mdfld_dsi_brightness_control(dev, 0, adjusted_level);
-
-               if ((dev_priv->dbi_panel_on2) || (dev_priv->dpi_panel_on2))
-                       mdfld_dsi_brightness_control(dev, 2, adjusted_level);
-#endif
-               gma_power_end(dev);
-       }
-       mdfld_brightness = level;
-       return 0;
-}
-
-int psb_get_brightness(struct backlight_device *bd)
-{
-       /* return locally cached var instead of HW read (due to DPST etc.) */
-       /* FIXME: ideally return actual value in case firmware fiddled with
-          it */
-       return mdfld_brightness;
-}
-
-static const struct backlight_ops mfld_ops = {
-       .get_brightness = psb_get_brightness,
-       .update_status  = mfld_set_brightness,
-};
-
-static int mdfld_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;
-
-       mdfld_backlight_device = backlight_device_register("mfld-bl",
-                                       NULL, (void *)dev, &mfld_ops, &props);
-                                       
-       if (IS_ERR(mdfld_backlight_device))
-               return PTR_ERR(mdfld_backlight_device);
-
-       dev_priv->blc_adj1 = 100;
-       dev_priv->blc_adj2 = 100;
-       mdfld_backlight_device->props.brightness = 100;
-       mdfld_backlight_device->props.max_brightness = 100;
-       backlight_update_status(mdfld_backlight_device);
-       dev_priv->backlight_device = mdfld_backlight_device;
-       return 0;
-}
-
-#endif
-
-/*
- *     Provide the Medfield specific chip logic and low level methods for
- *     power management.
- */
-
-static void mdfld_init_pm(struct drm_device *dev)
-{
-       /* No work needed here yet */
-}
-
-/**
- * mdfld_save_display_registers        -       save registers for pipe
- * @dev: our device
- * @pipe: pipe to save
- *
- * Save the pipe state of the device before we power it off. Keep everything
- * we need to put it back again
- */
-static int mdfld_save_display_registers(struct drm_device *dev, int pipe)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       int i;
-
-       /* register */
-       u32 dpll_reg = MRST_DPLL_A;
-       u32 fp_reg = MRST_FPA0;
-       u32 pipeconf_reg = PIPEACONF;
-       u32 htot_reg = HTOTAL_A;
-       u32 hblank_reg = HBLANK_A;
-       u32 hsync_reg = HSYNC_A;
-       u32 vtot_reg = VTOTAL_A;
-       u32 vblank_reg = VBLANK_A;
-       u32 vsync_reg = VSYNC_A;
-       u32 pipesrc_reg = PIPEASRC;
-       u32 dspstride_reg = DSPASTRIDE;
-       u32 dsplinoff_reg = DSPALINOFF;
-       u32 dsptileoff_reg = DSPATILEOFF;
-       u32 dspsize_reg = DSPASIZE;
-       u32 dsppos_reg = DSPAPOS;
-       u32 dspsurf_reg = DSPASURF;
-       u32 mipi_reg = MIPI;
-       u32 dspcntr_reg = DSPACNTR;
-       u32 dspstatus_reg = PIPEASTAT;
-       u32 palette_reg = PALETTE_A;
-
-       /* pointer to values */
-       u32 *dpll_val = &dev_priv->saveDPLL_A;
-       u32 *fp_val = &dev_priv->saveFPA0;
-       u32 *pipeconf_val = &dev_priv->savePIPEACONF;
-       u32 *htot_val = &dev_priv->saveHTOTAL_A;
-       u32 *hblank_val = &dev_priv->saveHBLANK_A;
-       u32 *hsync_val = &dev_priv->saveHSYNC_A;
-       u32 *vtot_val = &dev_priv->saveVTOTAL_A;
-       u32 *vblank_val = &dev_priv->saveVBLANK_A;
-       u32 *vsync_val = &dev_priv->saveVSYNC_A;
-       u32 *pipesrc_val = &dev_priv->savePIPEASRC;
-       u32 *dspstride_val = &dev_priv->saveDSPASTRIDE;
-       u32 *dsplinoff_val = &dev_priv->saveDSPALINOFF;
-       u32 *dsptileoff_val = &dev_priv->saveDSPATILEOFF;
-       u32 *dspsize_val = &dev_priv->saveDSPASIZE;
-       u32 *dsppos_val = &dev_priv->saveDSPAPOS;
-       u32 *dspsurf_val = &dev_priv->saveDSPASURF;
-       u32 *mipi_val = &dev_priv->saveMIPI;
-       u32 *dspcntr_val = &dev_priv->saveDSPACNTR;
-       u32 *dspstatus_val = &dev_priv->saveDSPASTATUS;
-       u32 *palette_val = dev_priv->save_palette_a;
-
-       switch (pipe) {
-       case 0:
-               break;
-       case 1:
-               /* register */
-               dpll_reg = MDFLD_DPLL_B;
-               fp_reg = MDFLD_DPLL_DIV0;
-               pipeconf_reg = PIPEBCONF;
-               htot_reg = HTOTAL_B;
-               hblank_reg = HBLANK_B;
-               hsync_reg = HSYNC_B;
-               vtot_reg = VTOTAL_B;
-               vblank_reg = VBLANK_B;
-               vsync_reg = VSYNC_B;
-               pipesrc_reg = PIPEBSRC;
-               dspstride_reg = DSPBSTRIDE;
-               dsplinoff_reg = DSPBLINOFF;
-               dsptileoff_reg = DSPBTILEOFF;
-               dspsize_reg = DSPBSIZE;
-               dsppos_reg = DSPBPOS;
-               dspsurf_reg = DSPBSURF;
-               dspcntr_reg = DSPBCNTR;
-               dspstatus_reg = PIPEBSTAT;
-               palette_reg = PALETTE_B;
-
-               /* values */
-               dpll_val = &dev_priv->saveDPLL_B;
-               fp_val = &dev_priv->saveFPB0;
-               pipeconf_val = &dev_priv->savePIPEBCONF;
-               htot_val = &dev_priv->saveHTOTAL_B;
-               hblank_val = &dev_priv->saveHBLANK_B;
-               hsync_val = &dev_priv->saveHSYNC_B;
-               vtot_val = &dev_priv->saveVTOTAL_B;
-               vblank_val = &dev_priv->saveVBLANK_B;
-               vsync_val = &dev_priv->saveVSYNC_B;
-               pipesrc_val = &dev_priv->savePIPEBSRC;
-               dspstride_val = &dev_priv->saveDSPBSTRIDE;
-               dsplinoff_val = &dev_priv->saveDSPBLINOFF;
-               dsptileoff_val = &dev_priv->saveDSPBTILEOFF;
-               dspsize_val = &dev_priv->saveDSPBSIZE;
-               dsppos_val = &dev_priv->saveDSPBPOS;
-               dspsurf_val = &dev_priv->saveDSPBSURF;
-               dspcntr_val = &dev_priv->saveDSPBCNTR;
-               dspstatus_val = &dev_priv->saveDSPBSTATUS;
-               palette_val = dev_priv->save_palette_b;
-               break;
-       case 2:
-               /* register */
-               pipeconf_reg = PIPECCONF;
-               htot_reg = HTOTAL_C;
-               hblank_reg = HBLANK_C;
-               hsync_reg = HSYNC_C;
-               vtot_reg = VTOTAL_C;
-               vblank_reg = VBLANK_C;
-               vsync_reg = VSYNC_C;
-               pipesrc_reg = PIPECSRC;
-               dspstride_reg = DSPCSTRIDE;
-               dsplinoff_reg = DSPCLINOFF;
-               dsptileoff_reg = DSPCTILEOFF;
-               dspsize_reg = DSPCSIZE;
-               dsppos_reg = DSPCPOS;
-               dspsurf_reg = DSPCSURF;
-               mipi_reg = MIPI_C;
-               dspcntr_reg = DSPCCNTR;
-               dspstatus_reg = PIPECSTAT;
-               palette_reg = PALETTE_C;
-
-               /* pointer to values */
-               pipeconf_val = &dev_priv->savePIPECCONF;
-               htot_val = &dev_priv->saveHTOTAL_C;
-               hblank_val = &dev_priv->saveHBLANK_C;
-               hsync_val = &dev_priv->saveHSYNC_C;
-               vtot_val = &dev_priv->saveVTOTAL_C;
-               vblank_val = &dev_priv->saveVBLANK_C;
-               vsync_val = &dev_priv->saveVSYNC_C;
-               pipesrc_val = &dev_priv->savePIPECSRC;
-               dspstride_val = &dev_priv->saveDSPCSTRIDE;
-               dsplinoff_val = &dev_priv->saveDSPCLINOFF;
-               dsptileoff_val = &dev_priv->saveDSPCTILEOFF;
-               dspsize_val = &dev_priv->saveDSPCSIZE;
-               dsppos_val = &dev_priv->saveDSPCPOS;
-               dspsurf_val = &dev_priv->saveDSPCSURF;
-               mipi_val = &dev_priv->saveMIPI_C;
-               dspcntr_val = &dev_priv->saveDSPCCNTR;
-               dspstatus_val = &dev_priv->saveDSPCSTATUS;
-               palette_val = dev_priv->save_palette_c;
-               break;
-       default:
-               DRM_ERROR("%s, invalid pipe number.\n", __func__);
-               return -EINVAL;
-       }
-
-       /* Pipe & plane A info */
-       *dpll_val = PSB_RVDC32(dpll_reg);
-       *fp_val = PSB_RVDC32(fp_reg);
-       *pipeconf_val = PSB_RVDC32(pipeconf_reg);
-       *htot_val = PSB_RVDC32(htot_reg);
-       *hblank_val = PSB_RVDC32(hblank_reg);
-       *hsync_val = PSB_RVDC32(hsync_reg);
-       *vtot_val = PSB_RVDC32(vtot_reg);
-       *vblank_val = PSB_RVDC32(vblank_reg);
-       *vsync_val = PSB_RVDC32(vsync_reg);
-       *pipesrc_val = PSB_RVDC32(pipesrc_reg);
-       *dspstride_val = PSB_RVDC32(dspstride_reg);
-       *dsplinoff_val = PSB_RVDC32(dsplinoff_reg);
-       *dsptileoff_val = PSB_RVDC32(dsptileoff_reg);
-       *dspsize_val = PSB_RVDC32(dspsize_reg);
-       *dsppos_val = PSB_RVDC32(dsppos_reg);
-       *dspsurf_val = PSB_RVDC32(dspsurf_reg);
-       *dspcntr_val = PSB_RVDC32(dspcntr_reg);
-       *dspstatus_val = PSB_RVDC32(dspstatus_reg);
-
-       /*save palette (gamma) */
-       for (i = 0; i < 256; i++)
-               palette_val[i] = PSB_RVDC32(palette_reg + (i<<2));
-
-       if (pipe == 1) {
-               dev_priv->savePFIT_CONTROL = PSB_RVDC32(PFIT_CONTROL);
-               dev_priv->savePFIT_PGM_RATIOS = PSB_RVDC32(PFIT_PGM_RATIOS);
-               dev_priv->saveHDMIPHYMISCCTL = PSB_RVDC32(HDMIPHYMISCCTL);
-               dev_priv->saveHDMIB_CONTROL = PSB_RVDC32(HDMIB_CONTROL);
-               return 0;
-       }
-       *mipi_val = PSB_RVDC32(mipi_reg);
-       return 0;
-}
-
-/**
- * mdfld_save_cursor_overlay_registers -       save cursor overlay info
- * @dev: our device
- *
- * Save the cursor and overlay register state
- */
-static int mdfld_save_cursor_overlay_registers(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       /* Save cursor regs */
-       dev_priv->saveDSPACURSOR_CTRL = PSB_RVDC32(CURACNTR);
-       dev_priv->saveDSPACURSOR_BASE = PSB_RVDC32(CURABASE);
-       dev_priv->saveDSPACURSOR_POS = PSB_RVDC32(CURAPOS);
-
-       dev_priv->saveDSPBCURSOR_CTRL = PSB_RVDC32(CURBCNTR);
-       dev_priv->saveDSPBCURSOR_BASE = PSB_RVDC32(CURBBASE);
-       dev_priv->saveDSPBCURSOR_POS = PSB_RVDC32(CURBPOS);
-
-       dev_priv->saveDSPCCURSOR_CTRL = PSB_RVDC32(CURCCNTR);
-       dev_priv->saveDSPCCURSOR_BASE = PSB_RVDC32(CURCBASE);
-       dev_priv->saveDSPCCURSOR_POS = PSB_RVDC32(CURCPOS);
-
-       /* HW overlay */
-       dev_priv->saveOV_OVADD = PSB_RVDC32(OV_OVADD);
-       dev_priv->saveOV_OGAMC0 = PSB_RVDC32(OV_OGAMC0);
-       dev_priv->saveOV_OGAMC1 = PSB_RVDC32(OV_OGAMC1);
-       dev_priv->saveOV_OGAMC2 = PSB_RVDC32(OV_OGAMC2);
-       dev_priv->saveOV_OGAMC3 = PSB_RVDC32(OV_OGAMC3);
-       dev_priv->saveOV_OGAMC4 = PSB_RVDC32(OV_OGAMC4);
-       dev_priv->saveOV_OGAMC5 = PSB_RVDC32(OV_OGAMC5);
-
-       dev_priv->saveOV_OVADD_C = PSB_RVDC32(OV_OVADD + OV_C_OFFSET);
-       dev_priv->saveOV_OGAMC0_C = PSB_RVDC32(OV_OGAMC0 + OV_C_OFFSET);
-       dev_priv->saveOV_OGAMC1_C = PSB_RVDC32(OV_OGAMC1 + OV_C_OFFSET);
-       dev_priv->saveOV_OGAMC2_C = PSB_RVDC32(OV_OGAMC2 + OV_C_OFFSET);
-       dev_priv->saveOV_OGAMC3_C = PSB_RVDC32(OV_OGAMC3 + OV_C_OFFSET);
-       dev_priv->saveOV_OGAMC4_C = PSB_RVDC32(OV_OGAMC4 + OV_C_OFFSET);
-       dev_priv->saveOV_OGAMC5_C = PSB_RVDC32(OV_OGAMC5 + OV_C_OFFSET);
-
-       return 0;
-}
-/*
- * mdfld_restore_display_registers     -       restore the state of a pipe
- * @dev: our device
- * @pipe: the pipe to restore
- *
- * Restore the state of a pipe to that which was saved by the register save
- * functions.
- */
-static int mdfld_restore_display_registers(struct drm_device *dev, int pipe)
-{
-       /* To get  panel out of ULPS mode */
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct mdfld_dsi_config *dsi_config = NULL;
-       u32 i = 0;
-       u32 dpll = 0;
-       u32 timeout = 0;
-       u32 reg_offset = 0;
-
-       /* register */
-       u32 dpll_reg = MRST_DPLL_A;
-       u32 fp_reg = MRST_FPA0;
-       u32 pipeconf_reg = PIPEACONF;
-       u32 htot_reg = HTOTAL_A;
-       u32 hblank_reg = HBLANK_A;
-       u32 hsync_reg = HSYNC_A;
-       u32 vtot_reg = VTOTAL_A;
-       u32 vblank_reg = VBLANK_A;
-       u32 vsync_reg = VSYNC_A;
-       u32 pipesrc_reg = PIPEASRC;
-       u32 dspstride_reg = DSPASTRIDE;
-       u32 dsplinoff_reg = DSPALINOFF;
-       u32 dsptileoff_reg = DSPATILEOFF;
-       u32 dspsize_reg = DSPASIZE;
-       u32 dsppos_reg = DSPAPOS;
-       u32 dspsurf_reg = DSPASURF;
-       u32 dspstatus_reg = PIPEASTAT;
-       u32 mipi_reg = MIPI;
-       u32 dspcntr_reg = DSPACNTR;
-       u32 palette_reg = PALETTE_A;
-
-       /* values */
-       u32 dpll_val = dev_priv->saveDPLL_A & ~DPLL_VCO_ENABLE;
-       u32 fp_val = dev_priv->saveFPA0;
-       u32 pipeconf_val = dev_priv->savePIPEACONF;
-       u32 htot_val = dev_priv->saveHTOTAL_A;
-       u32 hblank_val = dev_priv->saveHBLANK_A;
-       u32 hsync_val = dev_priv->saveHSYNC_A;
-       u32 vtot_val = dev_priv->saveVTOTAL_A;
-       u32 vblank_val = dev_priv->saveVBLANK_A;
-       u32 vsync_val = dev_priv->saveVSYNC_A;
-       u32 pipesrc_val = dev_priv->savePIPEASRC;
-       u32 dspstride_val = dev_priv->saveDSPASTRIDE;
-       u32 dsplinoff_val = dev_priv->saveDSPALINOFF;
-       u32 dsptileoff_val = dev_priv->saveDSPATILEOFF;
-       u32 dspsize_val = dev_priv->saveDSPASIZE;
-       u32 dsppos_val = dev_priv->saveDSPAPOS;
-       u32 dspsurf_val = dev_priv->saveDSPASURF;
-       u32 dspstatus_val = dev_priv->saveDSPASTATUS;
-       u32 mipi_val = dev_priv->saveMIPI;
-       u32 dspcntr_val = dev_priv->saveDSPACNTR;
-       u32 *palette_val = dev_priv->save_palette_a;
-
-       switch (pipe) {
-       case 0:
-               dsi_config = dev_priv->dsi_configs[0];
-               break;
-       case 1:
-               /* register */
-               dpll_reg = MDFLD_DPLL_B;
-               fp_reg = MDFLD_DPLL_DIV0;
-               pipeconf_reg = PIPEBCONF;
-               htot_reg = HTOTAL_B;
-               hblank_reg = HBLANK_B;
-               hsync_reg = HSYNC_B;
-               vtot_reg = VTOTAL_B;
-               vblank_reg = VBLANK_B;
-               vsync_reg = VSYNC_B;
-               pipesrc_reg = PIPEBSRC;
-               dspstride_reg = DSPBSTRIDE;
-               dsplinoff_reg = DSPBLINOFF;
-               dsptileoff_reg = DSPBTILEOFF;
-               dspsize_reg = DSPBSIZE;
-               dsppos_reg = DSPBPOS;
-               dspsurf_reg = DSPBSURF;
-               dspcntr_reg = DSPBCNTR;
-               palette_reg = PALETTE_B;
-               dspstatus_reg = PIPEBSTAT;
-
-               /* values */
-               dpll_val = dev_priv->saveDPLL_B & ~DPLL_VCO_ENABLE;
-               fp_val = dev_priv->saveFPB0;
-               pipeconf_val = dev_priv->savePIPEBCONF;
-               htot_val = dev_priv->saveHTOTAL_B;
-               hblank_val = dev_priv->saveHBLANK_B;
-               hsync_val = dev_priv->saveHSYNC_B;
-               vtot_val = dev_priv->saveVTOTAL_B;
-               vblank_val = dev_priv->saveVBLANK_B;
-               vsync_val = dev_priv->saveVSYNC_B;
-               pipesrc_val = dev_priv->savePIPEBSRC;
-               dspstride_val = dev_priv->saveDSPBSTRIDE;
-               dsplinoff_val = dev_priv->saveDSPBLINOFF;
-               dsptileoff_val = dev_priv->saveDSPBTILEOFF;
-               dspsize_val = dev_priv->saveDSPBSIZE;
-               dsppos_val = dev_priv->saveDSPBPOS;
-               dspsurf_val = dev_priv->saveDSPBSURF;
-               dspcntr_val = dev_priv->saveDSPBCNTR;
-               dspstatus_val = dev_priv->saveDSPBSTATUS;
-               palette_val = dev_priv->save_palette_b;
-               break;
-       case 2:
-               reg_offset = MIPIC_REG_OFFSET;
-
-               /* register */
-               pipeconf_reg = PIPECCONF;
-               htot_reg = HTOTAL_C;
-               hblank_reg = HBLANK_C;
-               hsync_reg = HSYNC_C;
-               vtot_reg = VTOTAL_C;
-               vblank_reg = VBLANK_C;
-               vsync_reg = VSYNC_C;
-               pipesrc_reg = PIPECSRC;
-               dspstride_reg = DSPCSTRIDE;
-               dsplinoff_reg = DSPCLINOFF;
-               dsptileoff_reg = DSPCTILEOFF;
-               dspsize_reg = DSPCSIZE;
-               dsppos_reg = DSPCPOS;
-               dspsurf_reg = DSPCSURF;
-               mipi_reg = MIPI_C;
-               dspcntr_reg = DSPCCNTR;
-               palette_reg = PALETTE_C;
-               dspstatus_reg = PIPECSTAT;
-
-               /* values */
-               pipeconf_val = dev_priv->savePIPECCONF;
-               htot_val = dev_priv->saveHTOTAL_C;
-               hblank_val = dev_priv->saveHBLANK_C;
-               hsync_val = dev_priv->saveHSYNC_C;
-               vtot_val = dev_priv->saveVTOTAL_C;
-               vblank_val = dev_priv->saveVBLANK_C;
-               vsync_val = dev_priv->saveVSYNC_C;
-               pipesrc_val = dev_priv->savePIPECSRC;
-               dspstride_val = dev_priv->saveDSPCSTRIDE;
-               dsplinoff_val = dev_priv->saveDSPCLINOFF;
-               dsptileoff_val = dev_priv->saveDSPCTILEOFF;
-               dspsize_val = dev_priv->saveDSPCSIZE;
-               dsppos_val = dev_priv->saveDSPCPOS;
-               dspsurf_val = dev_priv->saveDSPCSURF;
-               dspstatus_val = dev_priv->saveDSPCSTATUS;
-               mipi_val = dev_priv->saveMIPI_C;
-               dspcntr_val = dev_priv->saveDSPCCNTR;
-               palette_val = dev_priv->save_palette_c;
-
-               dsi_config = dev_priv->dsi_configs[1];
-               break;
-       default:
-               DRM_ERROR("%s, invalid pipe number.\n", __func__);
-               return -EINVAL;
-       }
-
-       /* Make sure VGA plane is off. it initializes to on after reset!*/
-       PSB_WVDC32(0x80000000, VGACNTRL);
-       if (pipe == 1) {
-               PSB_WVDC32(dpll_val & ~DPLL_VCO_ENABLE, dpll_reg);
-               PSB_RVDC32(dpll_reg);
-
-               PSB_WVDC32(fp_val, fp_reg);
-       } else {
-               dpll = PSB_RVDC32(dpll_reg);
-
-               if (!(dpll & DPLL_VCO_ENABLE)) {
-
-                       /* When ungating power of DPLL, needs to wait 0.5us before enable the VCO */
-                       if (dpll & MDFLD_PWR_GATE_EN) {
-                               dpll &= ~MDFLD_PWR_GATE_EN;
-                               PSB_WVDC32(dpll, dpll_reg);
-                               udelay(500);    /* FIXME: 1 ? */
-                       }
-
-                       PSB_WVDC32(fp_val, fp_reg);
-                       PSB_WVDC32(dpll_val, dpll_reg);
-                       /* FIXME_MDFLD PO - change 500 to 1 after PO */
-                       udelay(500);
-
-                       dpll_val |= DPLL_VCO_ENABLE;
-                       PSB_WVDC32(dpll_val, dpll_reg);
-                       PSB_RVDC32(dpll_reg);
-
-                       /* wait for DSI PLL to lock */
-                       while ((timeout < 20000) && !(PSB_RVDC32(pipeconf_reg) & PIPECONF_DSIPLL_LOCK)) {
-                               udelay(150);
-                               timeout++;
-                       }
-
-                       if (timeout == 20000) {
-                               DRM_ERROR("%s, can't lock DSIPLL.\n",
-                                                       __func__);
-                               return -EINVAL;
-                       }
-               }
-       }
-       /* Restore mode */
-       PSB_WVDC32(htot_val, htot_reg);
-       PSB_WVDC32(hblank_val, hblank_reg);
-       PSB_WVDC32(hsync_val, hsync_reg);
-       PSB_WVDC32(vtot_val, vtot_reg);
-       PSB_WVDC32(vblank_val, vblank_reg);
-       PSB_WVDC32(vsync_val, vsync_reg);
-       PSB_WVDC32(pipesrc_val, pipesrc_reg);
-       PSB_WVDC32(dspstatus_val, dspstatus_reg);
-
-       /* Set up the plane */
-       PSB_WVDC32(dspstride_val, dspstride_reg);
-       PSB_WVDC32(dsplinoff_val, dsplinoff_reg);
-       PSB_WVDC32(dsptileoff_val, dsptileoff_reg);
-       PSB_WVDC32(dspsize_val, dspsize_reg);
-       PSB_WVDC32(dsppos_val, dsppos_reg);
-       PSB_WVDC32(dspsurf_val, dspsurf_reg);
-
-       if (pipe == 1) {
-               PSB_WVDC32(dev_priv->savePFIT_CONTROL, PFIT_CONTROL);
-               PSB_WVDC32(dev_priv->savePFIT_PGM_RATIOS, PFIT_PGM_RATIOS);
-               PSB_WVDC32(dev_priv->saveHDMIPHYMISCCTL, HDMIPHYMISCCTL);
-               PSB_WVDC32(dev_priv->saveHDMIB_CONTROL, HDMIB_CONTROL);
-
-       } else {
-               /* Set up pipe related registers */
-               PSB_WVDC32(mipi_val, mipi_reg);
-               /* Setup MIPI adapter + MIPI IP registers */
-               mdfld_dsi_controller_init(dsi_config, pipe);
-               msleep(20);
-       }
-       /* Enable the plane */
-       PSB_WVDC32(dspcntr_val, dspcntr_reg);
-       msleep(20);
-       /* Enable the pipe */
-       PSB_WVDC32(pipeconf_val, pipeconf_reg);
-
-       for (i = 0; i < 256; i++)
-               PSB_WVDC32(palette_val[i], palette_reg + (i<<2));
-       if (pipe == 1)
-               return 0;
-       if (!mdfld_panel_dpi(dev))
-               mdfld_enable_te(dev, pipe);
-       return 0;
-}
-
-/**
- * mdfld_restore_cursor_overlay_registers      -       restore cursor
- * @dev: our device
- *
- * Restore the cursor and overlay state that was saved earlier
- */
-static int mdfld_restore_cursor_overlay_registers(struct drm_device *dev)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-
-       /* Enable Cursor A */
-       PSB_WVDC32(dev_priv->saveDSPACURSOR_CTRL, CURACNTR);
-       PSB_WVDC32(dev_priv->saveDSPACURSOR_POS, CURAPOS);
-       PSB_WVDC32(dev_priv->saveDSPACURSOR_BASE, CURABASE);
-
-       PSB_WVDC32(dev_priv->saveDSPBCURSOR_CTRL, CURBCNTR);
-       PSB_WVDC32(dev_priv->saveDSPBCURSOR_POS, CURBPOS);
-       PSB_WVDC32(dev_priv->saveDSPBCURSOR_BASE, CURBBASE);
-
-       PSB_WVDC32(dev_priv->saveDSPCCURSOR_CTRL, CURCCNTR);
-       PSB_WVDC32(dev_priv->saveDSPCCURSOR_POS, CURCPOS);
-       PSB_WVDC32(dev_priv->saveDSPCCURSOR_BASE, CURCBASE);
-
-       /* Restore HW overlay */
-       PSB_WVDC32(dev_priv->saveOV_OVADD, OV_OVADD);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC0, OV_OGAMC0);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC1, OV_OGAMC1);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC2, OV_OGAMC2);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC3, OV_OGAMC3);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC4, OV_OGAMC4);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC5, OV_OGAMC5);
-
-       PSB_WVDC32(dev_priv->saveOV_OVADD_C, OV_OVADD + OV_C_OFFSET);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC0_C, OV_OGAMC0 + OV_C_OFFSET);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC1_C, OV_OGAMC1 + OV_C_OFFSET);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC2_C, OV_OGAMC2 + OV_C_OFFSET);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC3_C, OV_OGAMC3 + OV_C_OFFSET);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC4_C, OV_OGAMC4 + OV_C_OFFSET);
-       PSB_WVDC32(dev_priv->saveOV_OGAMC5_C, OV_OGAMC5 + OV_C_OFFSET);
-
-       return 0;
-}
-
-/**
- *     mdfld_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 mdfld_save_registers(struct drm_device *dev)
-{
-       /* FIXME: We need to shut down panels here if using them
-          and once the right bits are merged */
-       mdfld_save_cursor_overlay_registers(dev);
-       mdfld_save_display_registers(dev, 0);
-       mdfld_save_display_registers(dev, 0);
-       mdfld_save_display_registers(dev, 2);
-       mdfld_save_display_registers(dev, 1);
-       mdfld_disable_crtc(dev, 0);
-       mdfld_disable_crtc(dev, 2);
-       mdfld_disable_crtc(dev, 1);
-       return 0;
-}
-
-/**
- *     mdfld_restore_display_registers -       restore lost register state
- *     @dev: our DRM device
- *
- *     Restore register state that was lost during suspend and resume.
- */
-static int mdfld_restore_registers(struct drm_device *dev)
-{
-       mdfld_restore_display_registers(dev, 1);
-       mdfld_restore_display_registers(dev, 0);
-       mdfld_restore_display_registers(dev, 2);
-       mdfld_restore_cursor_overlay_registers(dev);
-       return 0;
-}
-
-static int mdfld_power_down(struct drm_device *dev)
-{
-       /* FIXME */
-       return 0;
-}
-
-static int mdfld_power_up(struct drm_device *dev)
-{
-       /* FIXME */
-       return 0;
-}
-
-const struct psb_ops mdfld_chip_ops = {
-       .name = "Medfield",
-       .accel_2d = 0,
-       .pipes = 3,
-       .crtcs = 2,
-       .sgx_offset = MRST_SGX_OFFSET,
-
-       .chip_setup = mid_chip_setup,
-
-       .crtc_helper = &mdfld_helper_funcs,
-       .crtc_funcs = &mdfld_intel_crtc_funcs,
-
-       .output_init = mdfld_output_init,
-
-#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-       .backlight_init = mdfld_backlight_init,
-#endif
-
-       .init_pm = mdfld_init_pm,
-       .save_regs = mdfld_save_registers,
-       .restore_regs = mdfld_restore_registers,
-       .power_down = mdfld_power_down,
-       .power_up = mdfld_power_up,
-};
-
diff --git a/drivers/staging/gma500/mdfld_dsi_dbi.c b/drivers/staging/gma500/mdfld_dsi_dbi.c
deleted file mode 100644 (file)
index fd211f3..0000000
+++ /dev/null
@@ -1,761 +0,0 @@
-/*
- * Copyright © 2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *  jim liu <jim.liu@intel.com>
- *  Jackie Li<yaodong.li@intel.com>
- */
-
-#include "mdfld_dsi_dbi.h"
-#include "mdfld_dsi_dbi_dpu.h"
-#include "mdfld_dsi_pkg_sender.h"
-
-#include "power.h"
-#include <linux/pm_runtime.h>
-
-int enable_gfx_rtpm;
-
-extern struct drm_device *gpDrmDevice;
-extern int gfxrtdelay;
-int enter_dsr;
-struct mdfld_dsi_dbi_output *gdbi_output;
-extern bool gbgfxsuspended;
-extern int enable_gfx_rtpm;
-extern int gfxrtdelay;
-
-#define MDFLD_DSR_MAX_IDLE_COUNT       2
-
-/*
- * set refreshing area
- */
-int mdfld_dsi_dbi_update_area(struct mdfld_dsi_dbi_output *dbi_output,
-                               u16 x1, u16 y1, u16 x2, u16 y2)
-{
-       struct mdfld_dsi_pkg_sender *sender =
-               mdfld_dsi_encoder_get_pkg_sender(&dbi_output->base);
-       u8 param[4];
-       u8 cmd;
-       int err;
-
-       if (!sender) {
-               WARN_ON(1);
-               return -EINVAL;
-       }
-
-       /* Set column */
-       cmd = DCS_SET_COLUMN_ADDRESS;
-       param[0] = x1 >> 8;
-       param[1] = x1;
-       param[2] = x2 >> 8;
-       param[3] = x2;
-
-       err = mdfld_dsi_send_dcs(sender,
-                                cmd,
-                                param,
-                                4,
-                                CMD_DATA_SRC_SYSTEM_MEM,
-                                MDFLD_DSI_QUEUE_PACKAGE);
-       if (err) {
-               dev_err(sender->dev->dev, "DCS 0x%x sent failed\n", cmd);
-               goto err_out;
-       }
-
-       /* Set page */
-       cmd = DCS_SET_PAGE_ADDRESS;
-       param[0] = y1 >> 8;
-       param[1] = y1;
-       param[2] = y2 >> 8;
-       param[3] = y2;
-
-       err = mdfld_dsi_send_dcs(sender,
-                                cmd,
-                                param,
-                                4,
-                                CMD_DATA_SRC_SYSTEM_MEM,
-                                MDFLD_DSI_QUEUE_PACKAGE);
-       if (err) {
-               dev_err(sender->dev->dev, "DCS 0x%x sent failed\n", cmd);
-               goto err_out;
-       }
-
-       /*update screen*/
-       err = mdfld_dsi_send_dcs(sender,
-                                write_mem_start,
-                                NULL,
-                                0,
-                                CMD_DATA_SRC_PIPE,
-                                MDFLD_DSI_QUEUE_PACKAGE);
-       if (err) {
-               dev_err(sender->dev->dev, "DCS 0x%x sent failed\n", cmd);
-               goto err_out;
-       }
-       mdfld_dsi_cmds_kick_out(sender);
-err_out:
-       return err;
-}
-
-/*
- * set panel's power state
- */
-int mdfld_dsi_dbi_update_power(struct mdfld_dsi_dbi_output *dbi_output,
-                                                               int mode)
-{
-       struct drm_device *dev = dbi_output->dev;
-       struct mdfld_dsi_pkg_sender *sender =
-               mdfld_dsi_encoder_get_pkg_sender(&dbi_output->base);
-       u8 param = 0;
-       u32 err = 0;
-
-       if (!sender) {
-               WARN_ON(1);
-               return -EINVAL;
-       }
-
-       if (mode == DRM_MODE_DPMS_ON) {
-               /* Exit sleep mode */
-               err = mdfld_dsi_send_dcs(sender,
-                                        DCS_EXIT_SLEEP_MODE,
-                                        NULL,
-                                        0,
-                                        CMD_DATA_SRC_SYSTEM_MEM,
-                                        MDFLD_DSI_QUEUE_PACKAGE);
-               if (err) {
-                       dev_err(dev->dev, "DCS 0x%x sent failed\n",
-                                               DCS_EXIT_SLEEP_MODE);
-                       goto power_err;
-               }
-
-               /* Set display on */
-               err = mdfld_dsi_send_dcs(sender,
-                                        DCS_SET_DISPLAY_ON,
-                                        NULL,
-                                        0,
-                                        CMD_DATA_SRC_SYSTEM_MEM,
-                                        MDFLD_DSI_QUEUE_PACKAGE);
-               if (err) {
-                       dev_err(dev->dev, "DCS 0x%x sent failed\n",
-                                                       DCS_SET_DISPLAY_ON);
-                       goto power_err;
-               }
-
-               /* set tear effect on */
-               err = mdfld_dsi_send_dcs(sender,
-                                        DCS_SET_TEAR_ON,
-                                        &param,
-                                        1,
-                                        CMD_DATA_SRC_SYSTEM_MEM,
-                                        MDFLD_DSI_QUEUE_PACKAGE);
-               if (err) {
-                       dev_err(dev->dev, "DCS 0x%x sent failed\n",
-                                                       set_tear_on);
-                       goto power_err;
-               }
-
-               /**
-                * FIXME: remove this later
-                */
-               err = mdfld_dsi_send_dcs(sender,
-                                        DCS_WRITE_MEM_START,
-                                        NULL,
-                                        0,
-                                        CMD_DATA_SRC_PIPE,
-                                        MDFLD_DSI_QUEUE_PACKAGE);
-               if (err) {
-                       dev_err(dev->dev, "DCS 0x%x sent failed\n",
-                                               DCS_WRITE_MEM_START);
-                       goto power_err;
-               }
-       } else {
-               /* Set tear effect off */
-               err = mdfld_dsi_send_dcs(sender,
-                                        DCS_SET_TEAR_OFF,
-                                        NULL,
-                                        0,
-                                        CMD_DATA_SRC_SYSTEM_MEM,
-                                        MDFLD_DSI_QUEUE_PACKAGE);
-               if (err) {
-                       dev_err(dev->dev, "DCS 0x%x sent failed\n",
-                                                       DCS_SET_TEAR_OFF);
-                       goto power_err;
-               }
-
-               /* Turn display off */
-               err = mdfld_dsi_send_dcs(sender,
-                                        DCS_SET_DISPLAY_OFF,
-                                        NULL,
-                                        0,
-                                        CMD_DATA_SRC_SYSTEM_MEM,
-                                        MDFLD_DSI_QUEUE_PACKAGE);
-               if (err) {
-                       dev_err(dev->dev, "DCS 0x%x sent failed\n",
-                                               DCS_SET_DISPLAY_OFF);
-                       goto power_err;
-               }
-
-               /* Now enter sleep mode */
-               err = mdfld_dsi_send_dcs(sender,
-                                        DCS_ENTER_SLEEP_MODE,
-                                        NULL,
-                                        0,
-                                        CMD_DATA_SRC_SYSTEM_MEM,
-                                        MDFLD_DSI_QUEUE_PACKAGE);
-               if (err) {
-                       dev_err(dev->dev, "DCS 0x%x sent failed\n",
-                                                       DCS_ENTER_SLEEP_MODE);
-                       goto power_err;
-               }
-       }
-       mdfld_dsi_cmds_kick_out(sender);
-power_err:
-       return err;
-}
-
-/*
- * send a generic DCS command with a parameter list
- */
-int mdfld_dsi_dbi_send_dcs(struct mdfld_dsi_dbi_output *dbi_output,
-                       u8 dcs,  u8 *param, u32 num, u8 data_src)
-{
-       struct mdfld_dsi_pkg_sender *sender =
-               mdfld_dsi_encoder_get_pkg_sender(&dbi_output->base);
-       int ret;
-
-       if (!sender) {
-               WARN_ON(1);
-               return -EINVAL;
-       }
-
-       ret = mdfld_dsi_send_dcs(sender,
-                                dcs,
-                                param,
-                                num,
-                                data_src,
-                                MDFLD_DSI_SEND_PACKAGE);
-
-       return ret;
-}
-
-/*
- * Enter DSR
- */
-void mdfld_dsi_dbi_enter_dsr(struct mdfld_dsi_dbi_output *dbi_output, int pipe)
-{
-       u32 reg_val;
-       struct drm_device *dev = dbi_output->dev;
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct drm_crtc *crtc = dbi_output->base.base.crtc;
-       struct psb_intel_crtc *psb_crtc = (crtc) ?
-                                       to_psb_intel_crtc(crtc) : NULL;
-       u32 dpll_reg = MRST_DPLL_A;
-       u32 pipeconf_reg = PIPEACONF;
-       u32 dspcntr_reg = DSPACNTR;
-
-       if (!dbi_output)
-               return;
-
-       /* FIXME check if can go */
-       dev_priv->is_in_idle = true;
-
-       gdbi_output = dbi_output;
-       if ((dbi_output->mode_flags & MODE_SETTING_ON_GOING) ||
-               (psb_crtc && psb_crtc->mode_flags & MODE_SETTING_ON_GOING))
-               return;
-
-       if (pipe == 2) {
-               dpll_reg = MRST_DPLL_A;
-               pipeconf_reg = PIPECCONF;
-               dspcntr_reg = DSPCCNTR;
-       }
-
-       if (!gma_power_begin(dev, true)) {
-               dev_err(dev->dev, "hw begin failed\n");
-               return;
-       }
-       /* Disable te interrupts */
-       mdfld_disable_te(dev, pipe);
-
-       /* Disable plane */
-       reg_val = REG_READ(dspcntr_reg);
-       if (!(reg_val & DISPLAY_PLANE_ENABLE)) {
-               REG_WRITE(dspcntr_reg, reg_val & ~DISPLAY_PLANE_ENABLE);
-               REG_READ(dspcntr_reg);
-       }
-
-       /* Disable pipe */
-       reg_val = REG_READ(pipeconf_reg);
-       if (!(reg_val & DISPLAY_PLANE_ENABLE)) {
-               reg_val &= ~DISPLAY_PLANE_ENABLE;
-               reg_val |= (PIPECONF_PLANE_OFF | PIPECONF_CURSOR_OFF);
-               REG_WRITE(pipeconf_reg, reg_val);
-               REG_READ(pipeconf_reg);
-               mdfldWaitForPipeDisable(dev, pipe);
-       }
-
-       /* Disable DPLL */
-       reg_val = REG_READ(dpll_reg);
-       if (!(reg_val & DPLL_VCO_ENABLE)) {
-               reg_val &= ~DPLL_VCO_ENABLE;
-               REG_WRITE(dpll_reg, reg_val);
-               REG_READ(dpll_reg);
-               udelay(500);
-       }
-
-       gma_power_end(dev);
-       dbi_output->mode_flags |= MODE_SETTING_IN_DSR;
-       if (pipe == 2) {
-               enter_dsr = 1;
-               /* pm_schedule_suspend(&dev->pdev->dev, gfxrtdelay); */
-       }
-}
-
-static void mdfld_dbi_output_exit_dsr(struct mdfld_dsi_dbi_output *dbi_output,
-                       int pipe)
-{
-       struct drm_device *dev = dbi_output->dev;
-       struct drm_crtc *crtc = dbi_output->base.base.crtc;
-       struct psb_intel_crtc *psb_crtc = (crtc) ?
-                                       to_psb_intel_crtc(crtc) : NULL;
-       u32 reg_val;
-       u32 dpll_reg = MRST_DPLL_A;
-       u32 pipeconf_reg = PIPEACONF;
-       u32 dspcntr_reg = DSPACNTR;
-       u32 reg_offset = 0;
-
-       /*if mode setting on-going, back off*/
-       if ((dbi_output->mode_flags & MODE_SETTING_ON_GOING) ||
-               (psb_crtc && psb_crtc->mode_flags & MODE_SETTING_ON_GOING))
-               return;
-
-       if (pipe == 2) {
-               dpll_reg = MRST_DPLL_A;
-               pipeconf_reg = PIPECCONF;
-               dspcntr_reg = DSPCCNTR;
-               reg_offset = MIPIC_REG_OFFSET;
-       }
-
-       if (!gma_power_begin(dev, true)) {
-               dev_err(dev->dev, "hw begin failed\n");
-               return;
-       }
-
-       /* Enable DPLL */
-       reg_val = REG_READ(dpll_reg);
-       if (!(reg_val & DPLL_VCO_ENABLE)) {
-               if (reg_val & MDFLD_PWR_GATE_EN) {
-                       reg_val &= ~MDFLD_PWR_GATE_EN;
-                       REG_WRITE(dpll_reg, reg_val);
-                       REG_READ(dpll_reg);
-                       udelay(500);
-               }
-
-               reg_val |= DPLL_VCO_ENABLE;
-               REG_WRITE(dpll_reg, reg_val);
-               REG_READ(dpll_reg);
-               udelay(500);
-
-               /* Add timeout */
-               while (!(REG_READ(pipeconf_reg) & PIPECONF_DSIPLL_LOCK))
-                       cpu_relax();
-       }
-
-       /* Enable pipe */
-       reg_val = REG_READ(pipeconf_reg);
-       if (!(reg_val & PIPEACONF_ENABLE)) {
-               reg_val |= PIPEACONF_ENABLE;
-               REG_WRITE(pipeconf_reg, reg_val);
-               REG_READ(pipeconf_reg);
-               udelay(500);
-               mdfldWaitForPipeEnable(dev, pipe);
-       }
-
-       /* Enable plane */
-       reg_val = REG_READ(dspcntr_reg);
-       if (!(reg_val & DISPLAY_PLANE_ENABLE)) {
-               reg_val |= DISPLAY_PLANE_ENABLE;
-               REG_WRITE(dspcntr_reg, reg_val);
-               REG_READ(dspcntr_reg);
-               udelay(500);
-       }
-
-       /* Enable TE interrupt on this pipe */
-       mdfld_enable_te(dev, pipe);
-       gma_power_end(dev);
-
-       /*clean IN_DSR flag*/
-       dbi_output->mode_flags &= ~MODE_SETTING_IN_DSR;
-}
-
-/*
- * Exit from DSR
- */
-void mdfld_dsi_dbi_exit_dsr(struct drm_device *dev, u32 update_src)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct mdfld_dbi_dsr_info *dsr_info = dev_priv->dbi_dsr_info;
-       struct mdfld_dsi_dbi_output **dbi_output;
-       int i;
-       int pipe;
-
-       /* FIXME can go ? */
-       dev_priv->is_in_idle = false;
-       dbi_output = dsr_info->dbi_outputs;
-
-#ifdef CONFIG_PM_RUNTIME
-        if (!enable_gfx_rtpm) {
-/*                pm_runtime_allow(&gpDrmDevice->pdev->dev); */
-/*             schedule_delayed_work(&rtpm_work, 30 * 1000);*/ /* FIXME: HZ ? */
-       }
-#endif
-
-       /* For each output, exit dsr */
-       for (i = 0; i < dsr_info->dbi_output_num; i++) {
-               /* If panel has been turned off, skip */
-               if (!dbi_output[i] || !dbi_output[i]->dbi_panel_on)
-                       continue;
-               pipe = dbi_output[i]->channel_num ? 2 : 0;
-               enter_dsr = 0;
-               mdfld_dbi_output_exit_dsr(dbi_output[i], pipe);
-       }
-       dev_priv->dsr_fb_update |= update_src;
-}
-
-static bool mdfld_dbi_is_in_dsr(struct drm_device *dev)
-{
-       if (REG_READ(MRST_DPLL_A) & DPLL_VCO_ENABLE)
-               return false;
-       if ((REG_READ(PIPEACONF) & PIPEACONF_ENABLE) ||
-          (REG_READ(PIPECCONF) & PIPEACONF_ENABLE))
-               return false;
-       if ((REG_READ(DSPACNTR) & DISPLAY_PLANE_ENABLE) ||
-          (REG_READ(DSPCCNTR) & DISPLAY_PLANE_ENABLE))
-               return false;
-
-       return true;
-}
-
-/* Periodically update dbi panel */
-void mdfld_dbi_update_panel(struct drm_device *dev, int pipe)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct mdfld_dbi_dsr_info *dsr_info = dev_priv->dbi_dsr_info;
-       struct mdfld_dsi_dbi_output **dbi_outputs;
-       struct mdfld_dsi_dbi_output *dbi_output;
-       int i;
-       int can_enter_dsr = 0;
-       u32 damage_mask;
-
-       dbi_outputs = dsr_info->dbi_outputs;
-       dbi_output = pipe ? dbi_outputs[1] : dbi_outputs[0];
-
-       if (!dbi_output)
-               return;
-