aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/au1200fb.c
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2011-06-10 11:23:02 -0400
committerPaul Mundt <lethal@linux-sh.org>2011-06-15 02:48:59 -0400
commit98707fcc044c2e6120448041bf738d1b134cfaa4 (patch)
tree246f47aa86638bbee3b148e955706721d56e75d5 /drivers/video/au1200fb.c
parentc329f606a23e13fe952768cb9c32ea929ed91480 (diff)
au1200fb: fixup PM
Remove last traces of the unused custom Alchemy PM code, implement suspend/resume callbacks. Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/video/au1200fb.c')
-rw-r--r--drivers/video/au1200fb.c154
1 files changed, 39 insertions, 115 deletions
diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index 442d005e452d..480ecb1b9d0b 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -46,10 +46,6 @@
46#include <asm/mach-au1x00/au1000.h> 46#include <asm/mach-au1x00/au1000.h>
47#include "au1200fb.h" 47#include "au1200fb.h"
48 48
49#ifdef CONFIG_PM
50#include <asm/mach-au1x00/au1xxx_pm.h>
51#endif
52
53#ifndef CONFIG_FB_AU1200_DEVS 49#ifndef CONFIG_FB_AU1200_DEVS
54#define CONFIG_FB_AU1200_DEVS 4 50#define CONFIG_FB_AU1200_DEVS 4
55#endif 51#endif
@@ -205,12 +201,6 @@ struct window_settings {
205extern int board_au1200fb_panel_init (void); 201extern int board_au1200fb_panel_init (void);
206extern int board_au1200fb_panel_shutdown (void); 202extern int board_au1200fb_panel_shutdown (void);
207 203
208#ifdef CONFIG_PM
209int au1200fb_pm_callback(au1xxx_power_dev_t *dev,
210 au1xxx_request_t request, void *data);
211au1xxx_power_dev_t *LCD_pm_dev;
212#endif
213
214/* 204/*
215 * Default window configurations 205 * Default window configurations
216 */ 206 */
@@ -652,25 +642,6 @@ static struct panel_settings known_lcd_panels[] =
652 642
653/********************************************************************/ 643/********************************************************************/
654 644
655#ifdef CONFIG_PM
656static int set_brightness(unsigned int brightness)
657{
658 unsigned int hi1, divider;
659
660 /* limit brightness pwm duty to >= 30/1600 */
661 if (brightness < 30) {
662 brightness = 30;
663 }
664 divider = (lcd->pwmdiv & 0x3FFFF) + 1;
665 hi1 = (lcd->pwmhi >> 16) + 1;
666 hi1 = (((brightness & 0xFF) + 1) * divider >> 8);
667 lcd->pwmhi &= 0xFFFF;
668 lcd->pwmhi |= (hi1 << 16);
669
670 return brightness;
671}
672#endif /* CONFIG_PM */
673
674static int winbpp (unsigned int winctrl1) 645static int winbpp (unsigned int winctrl1)
675{ 646{
676 int bits = 0; 647 int bits = 0;
@@ -1248,10 +1219,6 @@ static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
1248 unsigned long start=0, off; 1219 unsigned long start=0, off;
1249 struct au1200fb_device *fbdev = info->par; 1220 struct au1200fb_device *fbdev = info->par;
1250 1221
1251#ifdef CONFIG_PM
1252 au1xxx_pm_access(LCD_pm_dev);
1253#endif
1254
1255 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) { 1222 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
1256 return -EINVAL; 1223 return -EINVAL;
1257 } 1224 }
@@ -1461,10 +1428,6 @@ static int au1200fb_ioctl(struct fb_info *info, unsigned int cmd,
1461 int plane; 1428 int plane;
1462 int val; 1429 int val;
1463 1430
1464#ifdef CONFIG_PM
1465 au1xxx_pm_access(LCD_pm_dev);
1466#endif
1467
1468 plane = fbinfo2index(info); 1431 plane = fbinfo2index(info);
1469 print_dbg("au1200fb: ioctl %d on plane %d\n", cmd, plane); 1432 print_dbg("au1200fb: ioctl %d on plane %d\n", cmd, plane);
1470 1433
@@ -1622,7 +1585,7 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev)
1622 1585
1623/* AU1200 LCD controller device driver */ 1586/* AU1200 LCD controller device driver */
1624 1587
1625static int au1200fb_drv_probe(struct platform_device *dev) 1588static int __devinit au1200fb_drv_probe(struct platform_device *dev)
1626{ 1589{
1627 struct au1200fb_device *fbdev; 1590 struct au1200fb_device *fbdev;
1628 struct fb_info *fbi = NULL; 1591 struct fb_info *fbi = NULL;
@@ -1633,6 +1596,9 @@ static int au1200fb_drv_probe(struct platform_device *dev)
1633 ret = 0; 1596 ret = 0;
1634 fbdev = NULL; 1597 fbdev = NULL;
1635 1598
1599 /* Kickstart the panel */
1600 au1200_setpanel(panel);
1601
1636 for (plane = 0; plane < CONFIG_FB_AU1200_DEVS; ++plane) { 1602 for (plane = 0; plane < CONFIG_FB_AU1200_DEVS; ++plane) {
1637 bpp = winbpp(win->w[plane].mode_winctrl1); 1603 bpp = winbpp(win->w[plane].mode_winctrl1);
1638 if (win->w[plane].xres == 0) 1604 if (win->w[plane].xres == 0)
@@ -1724,15 +1690,12 @@ failed:
1724 return ret; 1690 return ret;
1725} 1691}
1726 1692
1727static int au1200fb_drv_remove(struct platform_device *dev) 1693static int __devexit au1200fb_drv_remove(struct platform_device *dev)
1728{ 1694{
1729 struct au1200fb_device *fbdev; 1695 struct au1200fb_device *fbdev;
1730 struct fb_info *fbi; 1696 struct fb_info *fbi;
1731 int plane; 1697 int plane;
1732 1698
1733 if (!dev)
1734 return -ENODEV;
1735
1736 /* Turn off the panel */ 1699 /* Turn off the panel */
1737 au1200_setpanel(NULL); 1700 au1200_setpanel(NULL);
1738 1701
@@ -1760,31 +1723,53 @@ static int au1200fb_drv_remove(struct platform_device *dev)
1760} 1723}
1761 1724
1762#ifdef CONFIG_PM 1725#ifdef CONFIG_PM
1763static int au1200fb_drv_suspend(struct platform_device *dev, 1726static int au1200fb_drv_suspend(struct device *dev)
1764 pm_message_t state)
1765{ 1727{
1766 /* TODO */ 1728 au1200_setpanel(NULL);
1729
1730 lcd->outmask = 0;
1731 au_sync();
1732
1767 return 0; 1733 return 0;
1768} 1734}
1769 1735
1770static int au1200fb_drv_resume(struct platform_device *dev) 1736static int au1200fb_drv_resume(struct device *dev)
1771{ 1737{
1772 /* TODO */ 1738 struct fb_info *fbi;
1739 int i;
1740
1741 /* Kickstart the panel */
1742 au1200_setpanel(panel);
1743
1744 for (i = 0; i < CONFIG_FB_AU1200_DEVS; i++) {
1745 fbi = _au1200fb_infos[i];
1746 au1200fb_fb_set_par(fbi);
1747 }
1748
1773 return 0; 1749 return 0;
1774} 1750}
1751
1752static const struct dev_pm_ops au1200fb_pmops = {
1753 .suspend = au1200fb_drv_suspend,
1754 .resume = au1200fb_drv_resume,
1755 .freeze = au1200fb_drv_suspend,
1756 .thaw = au1200fb_drv_resume,
1757};
1758
1759#define AU1200FB_PMOPS (&au1200fb_pmops)
1760
1761#else
1762#define AU1200FB_PMOPS NULL
1775#endif /* CONFIG_PM */ 1763#endif /* CONFIG_PM */
1776 1764
1777static struct platform_driver au1200fb_driver = { 1765static struct platform_driver au1200fb_driver = {
1778 .driver = { 1766 .driver = {
1779 .name = "au1200-lcd", 1767 .name = "au1200-lcd",
1780 .owner = THIS_MODULE, 1768 .owner = THIS_MODULE,
1769 .pm = AU1200FB_PMOPS,
1781 }, 1770 },
1782 .probe = au1200fb_drv_probe, 1771 .probe = au1200fb_drv_probe,
1783 .remove = au1200fb_drv_remove, 1772 .remove = __devexit_p(au1200fb_drv_remove),
1784#ifdef CONFIG_PM
1785 .suspend = au1200fb_drv_suspend,
1786 .resume = au1200fb_drv_resume,
1787#endif
1788}; 1773};
1789 1774
1790/*-------------------------------------------------------------------------*/ 1775/*-------------------------------------------------------------------------*/
@@ -1847,56 +1832,6 @@ static void au1200fb_setup(void)
1847 } 1832 }
1848} 1833}
1849 1834
1850#ifdef CONFIG_PM
1851static int au1200fb_pm_callback(au1xxx_power_dev_t *dev,
1852 au1xxx_request_t request, void *data) {
1853 int retval = -1;
1854 unsigned int d = 0;
1855 unsigned int brightness = 0;
1856
1857 if (request == AU1XXX_PM_SLEEP) {
1858 board_au1200fb_panel_shutdown();
1859 }
1860 else if (request == AU1XXX_PM_WAKEUP) {
1861 if(dev->prev_state == SLEEP_STATE)
1862 {
1863 int plane;
1864 au1200_setpanel(panel);
1865 for (plane = 0; plane < CONFIG_FB_AU1200_DEVS; ++plane) {
1866 struct au1200fb_device *fbdev;
1867 fbdev = &_au1200fb_devices[plane];
1868 au1200fb_fb_set_par(&fbdev->fb_info);
1869 }
1870 }
1871
1872 d = *((unsigned int*)data);
1873 if(d <=10) brightness = 26;
1874 else if(d<=20) brightness = 51;
1875 else if(d<=30) brightness = 77;
1876 else if(d<=40) brightness = 102;
1877 else if(d<=50) brightness = 128;
1878 else if(d<=60) brightness = 153;
1879 else if(d<=70) brightness = 179;
1880 else if(d<=80) brightness = 204;
1881 else if(d<=90) brightness = 230;
1882 else brightness = 255;
1883 set_brightness(brightness);
1884 } else if (request == AU1XXX_PM_GETSTATUS) {
1885 return dev->cur_state;
1886 } else if (request == AU1XXX_PM_ACCESS) {
1887 if (dev->cur_state != SLEEP_STATE)
1888 return retval;
1889 else {
1890 au1200_setpanel(panel);
1891 }
1892 } else if (request == AU1XXX_PM_IDLE) {
1893 } else if (request == AU1XXX_PM_CLEANUP) {
1894 }
1895
1896 return retval;
1897}
1898#endif
1899
1900static int __init au1200fb_init(void) 1835static int __init au1200fb_init(void)
1901{ 1836{
1902 print_info("" DRIVER_DESC ""); 1837 print_info("" DRIVER_DESC "");
@@ -1911,17 +1846,6 @@ static int __init au1200fb_init(void)
1911 printk(DRIVER_NAME ": Panel %d %s\n", panel_index, panel->name); 1846 printk(DRIVER_NAME ": Panel %d %s\n", panel_index, panel->name);
1912 printk(DRIVER_NAME ": Win %d %s\n", window_index, win->name); 1847 printk(DRIVER_NAME ": Win %d %s\n", window_index, win->name);
1913 1848
1914 /* Kickstart the panel, the framebuffers/windows come soon enough */
1915 au1200_setpanel(panel);
1916
1917 #ifdef CONFIG_PM
1918 LCD_pm_dev = new_au1xxx_power_device("LCD", &au1200fb_pm_callback, NULL);
1919 if ( LCD_pm_dev == NULL)
1920 printk(KERN_INFO "Unable to create a power management device entry for the au1200fb.\n");
1921 else
1922 printk(KERN_INFO "Power management device entry for the au1200fb loaded.\n");
1923 #endif
1924
1925 return platform_driver_register(&au1200fb_driver); 1849 return platform_driver_register(&au1200fb_driver);
1926} 1850}
1927 1851