usb: dwc3: gadget: fix ep->maxburst for ep0
[linux-2.6.git] / drivers / video / atmel_lcdfb.c
index 59654e2..d99505b 100644 (file)
 #include <linux/delay.h>
 #include <linux/backlight.h>
 #include <linux/gfp.h>
+#include <linux/module.h>
 
 #include <mach/board.h>
 #include <mach/cpu.h>
-#include <mach/gpio.h>
+#include <asm/gpio.h>
 
 #include <video/atmel_lcdc.h>
 
@@ -39,7 +40,8 @@
                                         | FBINFO_HWACCEL_YPAN)
 
 static inline void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
-                                       struct fb_var_screeninfo *var)
+                                       struct fb_var_screeninfo *var,
+                                       struct fb_info *info)
 {
 
 }
@@ -50,14 +52,16 @@ static inline void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
                                        | FBINFO_HWACCEL_YPAN)
 
 static void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
-                                    struct fb_var_screeninfo *var)
+                                    struct fb_var_screeninfo *var,
+                                    struct fb_info *info)
 {
        u32 dma2dcfg;
        u32 pixeloff;
 
-       pixeloff = (var->xoffset * var->bits_per_pixel) & 0x1f;
+       pixeloff = (var->xoffset * info->var.bits_per_pixel) & 0x1f;
 
-       dma2dcfg = ((var->xres_virtual - var->xres) * var->bits_per_pixel) / 8;
+       dma2dcfg = (info->var.xres_virtual - info->var.xres)
+                * info->var.bits_per_pixel / 8;
        dma2dcfg |= pixeloff << ATMEL_LCDC_PIXELOFF_OFFSET;
        lcdc_writel(sinfo, ATMEL_LCDC_DMA2DCFG, dma2dcfg);
 
@@ -96,8 +100,11 @@ static int atmel_bl_update_status(struct backlight_device *bl)
                brightness = 0;
 
        lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, brightness);
-       lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR,
+       if (contrast_ctr & ATMEL_LCDC_POL_POSITIVE)
+               lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR,
                        brightness ? contrast_ctr : 0);
+       else
+               lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, contrast_ctr);
 
        bl->props.fb_blank = bl->props.power = sinfo->bl_power = power;
 
@@ -127,6 +134,7 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo)
                return;
 
        memset(&props, 0, sizeof(struct backlight_properties));
+       props.type = BACKLIGHT_RAW;
        props.max_brightness = 0xff;
        bl = backlight_device_register("backlight", &sinfo->pdev->dev, sinfo,
                                       &atmel_lcdc_bl_ops, &props);
@@ -248,14 +256,14 @@ static void atmel_lcdfb_update_dma(struct fb_info *info,
        unsigned long dma_addr;
 
        dma_addr = (fix->smem_start + var->yoffset * fix->line_length
-                   + var->xoffset * var->bits_per_pixel / 8);
+                   + var->xoffset * info->var.bits_per_pixel / 8);
 
        dma_addr &= ~3UL;
 
        /* Set framebuffer DMA base address and pixel offset */
        lcdc_writel(sinfo, ATMEL_LCDC_DMABADDR1, dma_addr);
 
-       atmel_lcdfb_update_dma2d(sinfo, var);
+       atmel_lcdfb_update_dma2d(sinfo, var, info);
 }
 
 static inline void atmel_lcdfb_free_video_memory(struct atmel_lcdfb_info *sinfo)
@@ -413,24 +421,18 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
                var->red.length = var->green.length = var->blue.length
                        = var->bits_per_pixel;
                break;
-       case 15:
        case 16:
                if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
                        /* RGB:565 mode */
                        var->red.offset = 11;
                        var->blue.offset = 0;
-                       var->green.length = 6;
-               } else if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB555) {
-                       var->red.offset = 10;
-                       var->blue.offset = 0;
-                       var->green.length = 5;
                } else {
-                       /* BGR:555 mode */
+                       /* BGR:565 mode */
                        var->red.offset = 0;
-                       var->blue.offset = 10;
-                       var->green.length = 5;
+                       var->blue.offset = 11;
                }
                var->green.offset = 5;
+               var->green.length = 6;
                var->red.length = var->blue.length = 5;
                break;
        case 32:
@@ -636,7 +638,7 @@ static inline unsigned int chan_to_field(unsigned int chan, const struct fb_bitf
  *     magnitude which needs to be scaled in this function for the hardware.
  *     Things to take into consideration are how many color registers, if
  *     any, are supported with the current color visual. With truecolor mode
- *     no color palettes are supported. Here a psuedo palette is created
+ *     no color palettes are supported. Here a pseudo palette is created
  *     which we store the value in pseudo_palette in struct fb_info. For
  *     pseudocolor mode we have a limited color palette. To deal with this
  *     we can program what color is displayed for a particular pixel value.
@@ -677,14 +679,30 @@ static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red,
 
        case FB_VISUAL_PSEUDOCOLOR:
                if (regno < 256) {
-                       val  = ((red   >> 11) & 0x001f);
-                       val |= ((green >>  6) & 0x03e0);
-                       val |= ((blue  >>  1) & 0x7c00);
-
-                       /*
-                        * TODO: intensity bit. Maybe something like
-                        *   ~(red[10] ^ green[10] ^ blue[10]) & 1
-                        */
+                       if (cpu_is_at91sam9261() || cpu_is_at91sam9263()
+                           || cpu_is_at91sam9rl()) {
+                               /* old style I+BGR:555 */
+                               val  = ((red   >> 11) & 0x001f);
+                               val |= ((green >>  6) & 0x03e0);
+                               val |= ((blue  >>  1) & 0x7c00);
+
+                               /*
+                                * TODO: intensity bit. Maybe something like
+                                *   ~(red[10] ^ green[10] ^ blue[10]) & 1
+                                */
+                       } else {
+                               /* new style BGR:565 / RGB:565 */
+                               if (sinfo->lcd_wiring_mode ==
+                                   ATMEL_LCDC_WIRING_RGB) {
+                                       val  = ((blue >> 11) & 0x001f);
+                                       val |= ((red  >>  0) & 0xf800);
+                               } else {
+                                       val  = ((red  >> 11) & 0x001f);
+                                       val |= ((blue >>  0) & 0xf800);
+                               }
+
+                               val |= ((green >>  5) & 0x07e0);
+                       }
 
                        lcdc_writel(sinfo, ATMEL_LCDC_LUT(regno), val);
                        ret = 0;
@@ -905,7 +923,7 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
        if (map) {
                /* use a pre-allocated memory buffer */
                info->fix.smem_start = map->start;
-               info->fix.smem_len = map->end - map->start + 1;
+               info->fix.smem_len = resource_size(map);
                if (!request_mem_region(info->fix.smem_start,
                                        info->fix.smem_len, pdev->name)) {
                        ret = -EBUSY;
@@ -931,7 +949,7 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
 
        /* LCDC registers */
        info->fix.mmio_start = regs->start;
-       info->fix.mmio_len = regs->end - regs->start + 1;
+       info->fix.mmio_len = resource_size(regs);
 
        if (!request_mem_region(info->fix.mmio_start,
                                info->fix.mmio_len, pdev->name)) {
@@ -1084,7 +1102,7 @@ static int atmel_lcdfb_suspend(struct platform_device *pdev, pm_message_t mesg)
         */
        lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL);
 
-       sinfo->saved_lcdcon = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
+       sinfo->saved_lcdcon = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_CTR);
        lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, 0);
        if (sinfo->atmel_lcdfb_power_control)
                sinfo->atmel_lcdfb_power_control(0);