drivers/video/: Spelling fixes
[sfrench/cifs-2.6.git] / drivers / video / sm501fb.c
index 58c0ac733db9871ddad0cc6905f171fab6ee3d36..58f200c69be31378585fa34961439c584ef3a441 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/wait.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/console.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -47,7 +48,7 @@ enum sm501_controller {
        HEAD_PANEL      = 1,
 };
 
-/* SM501 memory adress */
+/* SM501 memory address */
 struct sm501_mem {
        unsigned long    size;
        unsigned long    sm_addr;
@@ -62,6 +63,8 @@ struct sm501fb_info {
        struct resource         *regs_res;      /* registers resource */
        struct sm501_platdata_fb *pdata;        /* our platform data */
 
+       unsigned long            pm_crt_ctrl;   /* pm: crt ctrl save */
+
        int                      irq;
        int                      swap_endian;   /* set to swap rgb=>bgr */
        void __iomem            *regs;          /* remapped registers */
@@ -774,6 +777,11 @@ static int sm501fb_set_par_pnl(struct fb_info *info)
        writel(control, fbi->regs + SM501_DC_PANEL_CONTROL);
        sm501fb_sync_regs(fbi);
 
+       /* ensure the panel interface is not tristated at this point */
+
+       sm501_modify_reg(fbi->dev->parent, SM501_SYSTEM_CONTROL,
+                        0, SM501_SYSCTRL_PANEL_TRISTATE);
+
        /* power the panel up */
        sm501fb_panel_power(fbi, 1);
        return 0;
@@ -989,7 +997,7 @@ static int sm501fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
                        ((info->cmap.green[fg_col] & 0xFC) << 3) |
                        ((info->cmap.blue[fg_col] & 0xF8) >> 3);
 
-               dev_dbg(fbi->dev, "fgcol %08x, bgcol %08x\n", fg, bg);
+               dev_dbg(fbi->dev, "fgcol %08lx, bgcol %08lx\n", fg, bg);
 
                writel(bg, base + SM501_OFF_HWC_COLOR_1_2);
                writel(fg, base + SM501_OFF_HWC_COLOR_3);
@@ -1074,9 +1082,9 @@ static ssize_t sm501fb_crtsrc_store(struct device *dev,
        if (len < 1)
                return -EINVAL;
 
-       if (strnicmp(buf, "crt", sizeof("crt")) == 0)
+       if (strnicmp(buf, "crt", 3) == 0)
                head = HEAD_CRT;
-       else if (strnicmp(buf, "panel", sizeof("panel")) == 0)
+       else if (strnicmp(buf, "panel", 5) == 0)
                head = HEAD_PANEL;
        else
                return -EINVAL;
@@ -1098,7 +1106,7 @@ static ssize_t sm501fb_crtsrc_store(struct device *dev,
        writel(ctrl, info->regs + SM501_DC_CRT_CONTROL);
        sm501fb_sync_regs(info);
 
-       return (head == HEAD_CRT) ? 3 : 5;
+       return len;
 }
 
 /* Prepare the device_attr for registration with sysfs later */
@@ -1687,19 +1695,25 @@ static int sm501fb_suspend_fb(struct sm501fb_info *info,
                goto err_nocursor;
        }
 
+       dev_dbg(info->dev, "suspending screen to %p\n", par->store_fb);
+       dev_dbg(info->dev, "suspending cursor to %p\n", par->store_cursor);
+
        memcpy_fromio(par->store_fb, par->screen.k_addr, par->screen.size);
        memcpy_fromio(par->store_cursor, par->cursor.k_addr, par->cursor.size);
-
        /* blank the relevant interface to ensure unit power minimised */
        (par->ops.fb_blank)(FB_BLANK_POWERDOWN, fbi);
 
+       acquire_console_sem();
+       fb_set_suspend(fbi, 1);
+       release_console_sem();
+
        return 0;
 
  err_nocursor:
        vfree(par->store_fb);
+       par->store_fb = NULL;
 
        return -ENOMEM;
-
 }
 
 static void sm501fb_resume_fb(struct sm501fb_info *info,
@@ -1717,8 +1731,20 @@ static void sm501fb_resume_fb(struct sm501fb_info *info,
 
        /* restore the data */
 
-       memcpy_toio(par->screen.k_addr, par->store_fb, par->screen.size);
-       memcpy_toio(par->cursor.k_addr, par->store_cursor, par->cursor.size);
+       dev_dbg(info->dev, "restoring screen from %p\n", par->store_fb);
+       dev_dbg(info->dev, "restoring cursor from %p\n", par->store_cursor);
+
+       if (par->store_fb)
+               memcpy_toio(par->screen.k_addr, par->store_fb,
+                           par->screen.size);
+
+       if (par->store_cursor)
+               memcpy_toio(par->cursor.k_addr, par->store_cursor,
+                           par->cursor.size);
+
+       acquire_console_sem();
+       fb_set_suspend(fbi, 0);
+       release_console_sem();
 
        vfree(par->store_fb);
        vfree(par->store_cursor);
@@ -1731,6 +1757,9 @@ static int sm501fb_suspend(struct platform_device *pdev, pm_message_t state)
 {
        struct sm501fb_info *info = platform_get_drvdata(pdev);
 
+       /* store crt control to resume with */
+       info->pm_crt_ctrl = readl(info->regs + SM501_DC_CRT_CONTROL);
+
        sm501fb_suspend_fb(info, HEAD_CRT);
        sm501fb_suspend_fb(info, HEAD_PANEL);
 
@@ -1740,12 +1769,24 @@ static int sm501fb_suspend(struct platform_device *pdev, pm_message_t state)
        return 0;
 }
 
+#define SM501_CRT_CTRL_SAVE (SM501_DC_CRT_CONTROL_TVP |        \
+                            SM501_DC_CRT_CONTROL_SEL)
+
+
 static int sm501fb_resume(struct platform_device *pdev)
 {
        struct sm501fb_info *info = platform_get_drvdata(pdev);
+       unsigned long crt_ctrl;
 
        sm501_unit_power(info->dev->parent, SM501_GATE_DISPLAY, 1);
 
+       /* restore the items we want to be saved for crt control */
+
+       crt_ctrl = readl(info->regs + SM501_DC_CRT_CONTROL);
+       crt_ctrl &= ~SM501_CRT_CTRL_SAVE;
+       crt_ctrl |= info->pm_crt_ctrl & SM501_CRT_CTRL_SAVE;
+       writel(crt_ctrl, info->regs + SM501_DC_CRT_CONTROL);
+
        sm501fb_resume_fb(info, HEAD_CRT);
        sm501fb_resume_fb(info, HEAD_PANEL);