]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'fbdev/for-next'
authorThierry Reding <treding@nvidia.com>
Thu, 24 Oct 2013 12:36:54 +0000 (14:36 +0200)
committerThierry Reding <treding@nvidia.com>
Thu, 24 Oct 2013 12:36:54 +0000 (14:36 +0200)
123 files changed:
Documentation/devicetree/bindings/video/atmel,lcdc.txt [new file with mode: 0644]
arch/arm/mach-at91/at91sam9261_devices.c
arch/arm/mach-at91/at91sam9263_devices.c
arch/arm/mach-at91/at91sam9g45_devices.c
arch/arm/mach-at91/at91sam9rl_devices.c
arch/arm/mach-at91/board-sam9261ek.c
arch/arm/mach-at91/board-sam9263ek.c
arch/arm/mach-at91/board-sam9m10g45ek.c
arch/arm/mach-at91/board-sam9rlek.c
arch/arm/mach-at91/board.h
arch/arm/mach-mmp/ttc_dkb.c
arch/avr32/boards/atngw100/evklcd10x.c
arch/avr32/boards/atngw100/mrmt.c
arch/avr32/boards/atstk1000/atstk1000.h
arch/avr32/boards/atstk1000/setup.c
arch/avr32/boards/favr-32/setup.c
arch/avr32/boards/hammerhead/setup.c
arch/avr32/boards/merisc/display.c
arch/avr32/boards/mimc200/setup.c
arch/avr32/mach-at32ap/at32ap700x.c
arch/avr32/mach-at32ap/include/mach/board.h
drivers/video/Kconfig
drivers/video/amba-clcd.c
drivers/video/amifb.c
drivers/video/arkfb.c
drivers/video/atmel_lcdfb.c
drivers/video/aty/aty128fb.c
drivers/video/aty/atyfb_base.c
drivers/video/aty/radeon_base.c
drivers/video/aty/radeon_pm.c
drivers/video/aty/radeonfb.h
drivers/video/au1100fb.c
drivers/video/au1200fb.c
drivers/video/backlight/l4f00242t03.c
drivers/video/backlight/tosa_lcd.c
drivers/video/bf54x-lq043fb.c
drivers/video/bfin-t350mcqb-fb.c
drivers/video/broadsheetfb.c
drivers/video/bw2.c
drivers/video/carminefb.c
drivers/video/cg14.c
drivers/video/cg3.c
drivers/video/cg6.c
drivers/video/cirrusfb.c
drivers/video/cobalt_lcdfb.c
drivers/video/cyber2000fb.c
drivers/video/da8xx-fb.c
drivers/video/ep93xx-fb.c
drivers/video/ffb.c
drivers/video/geode/gx1fb_core.c
drivers/video/geode/gxfb_core.c
drivers/video/geode/lxfb_core.c
drivers/video/grvga.c
drivers/video/hecubafb.c
drivers/video/hyperv_fb.c
drivers/video/i740fb.c
drivers/video/i810/i810_main.c
drivers/video/imxfb.c
drivers/video/intelfb/intelfbdrv.c
drivers/video/jz4740_fb.c
drivers/video/kyro/fbdev.c
drivers/video/leo.c
drivers/video/matrox/matroxfb_maven.c
drivers/video/mb862xx/mb862xxfbdrv.c
drivers/video/mbx/mbxfb.c
drivers/video/metronomefb.c
drivers/video/mmp/fb/mmpfb.c
drivers/video/mmp/hw/mmp_ctrl.c
drivers/video/mmp/hw/mmp_ctrl.h
drivers/video/mx3fb.c
drivers/video/neofb.c
drivers/video/nuc900fb.c
drivers/video/omap/hwa742.c
drivers/video/omap/omapfb_main.c
drivers/video/omap2/dss/Makefile
drivers/video/omap2/dss/core.c
drivers/video/omap2/dss/dispc.c
drivers/video/omap2/dss/dss.h
drivers/video/omap2/dss/dss_features.c
drivers/video/omap2/dss/dss_features.h
drivers/video/omap2/dss/hdmi.c [deleted file]
drivers/video/omap2/dss/hdmi.h [new file with mode: 0644]
drivers/video/omap2/dss/hdmi4.c [new file with mode: 0644]
drivers/video/omap2/dss/hdmi4_core.c [moved from drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c with 55% similarity]
drivers/video/omap2/dss/hdmi4_core.h [moved from drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h with 51% similarity]
drivers/video/omap2/dss/hdmi_common.c [new file with mode: 0644]
drivers/video/omap2/dss/hdmi_phy.c [new file with mode: 0644]
drivers/video/omap2/dss/hdmi_pll.c [new file with mode: 0644]
drivers/video/omap2/dss/hdmi_wp.c [new file with mode: 0644]
drivers/video/omap2/dss/ti_hdmi.h [deleted file]
drivers/video/p9100.c
drivers/video/platinumfb.c
drivers/video/pm2fb.c
drivers/video/pm3fb.c
drivers/video/pxa168fb.c
drivers/video/pxafb.c
drivers/video/riva/fbdev.c
drivers/video/s1d13xxxfb.c
drivers/video/s3c-fb.c
drivers/video/s3c2410fb.c
drivers/video/s3fb.c
drivers/video/sa1100fb.c
drivers/video/savage/savagefb_driver.c
drivers/video/sh_mobile_hdmi.c
drivers/video/simplefb.c
drivers/video/sis/sis_main.c
drivers/video/smscufx.c
drivers/video/ssd1307fb.c
drivers/video/sunxvr1000.c
drivers/video/tcx.c
drivers/video/tdfxfb.c
drivers/video/tmiofb.c
drivers/video/tridentfb.c
drivers/video/udlfb.c
drivers/video/uvesafb.c
drivers/video/vfb.c
drivers/video/vt8623fb.c
drivers/video/w100fb.c
drivers/video/wm8505fb.c
drivers/video/wmt_ge_rops.c
drivers/video/xilinxfb.c
include/video/atmel_lcdc.h
include/video/mmp_disp.h

diff --git a/Documentation/devicetree/bindings/video/atmel,lcdc.txt b/Documentation/devicetree/bindings/video/atmel,lcdc.txt
new file mode 100644 (file)
index 0000000..1ec175e
--- /dev/null
@@ -0,0 +1,75 @@
+Atmel LCDC Framebuffer
+-----------------------------------------------------
+
+Required properties:
+- compatible :
+       "atmel,at91sam9261-lcdc" , 
+       "atmel,at91sam9263-lcdc" ,
+       "atmel,at91sam9g10-lcdc" ,
+       "atmel,at91sam9g45-lcdc" ,
+       "atmel,at91sam9g45es-lcdc" ,
+       "atmel,at91sam9rl-lcdc" ,
+       "atmel,at32ap-lcdc"
+- reg : Should contain 1 register ranges(address and length)
+- interrupts : framebuffer controller interrupt
+- display: a phandle pointing to the display node
+
+Required nodes:
+- display: a display node is required to initialize the lcd panel
+       This should be in the board dts.
+- default-mode: a videomode within the display with timing parameters
+       as specified below.
+
+Example:
+
+       fb0: fb@0x00500000 {
+               compatible = "atmel,at91sam9g45-lcdc";
+               reg = <0x00500000 0x1000>;
+               interrupts = <23 3 0>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_fb>;
+               display = <&display0>;
+               status = "okay";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+       };
+
+Atmel LCDC Display
+-----------------------------------------------------
+Required properties (as per of_videomode_helper):
+
+ - atmel,dmacon: dma controler configuration
+ - atmel,lcdcon2: lcd controler configuration
+ - atmel,guard-time: lcd guard time (Delay in frame periods)
+ - bits-per-pixel: lcd panel bit-depth.
+
+Optional properties (as per of_videomode_helper):
+ - atmel,lcdcon-backlight: enable backlight
+ - atmel,lcd-wiring-mode: lcd wiring mode "RGB" or "BRG"
+ - atmel,power-control-gpio: gpio to power on or off the LCD (as many as needed)
+
+Example:
+       display0: display {
+               bits-per-pixel = <32>;
+               atmel,lcdcon-backlight;
+               atmel,dmacon = <0x1>;
+               atmel,lcdcon2 = <0x80008002>;
+               atmel,guard-time = <9>;
+               atmel,lcd-wiring-mode = <1>;
+
+               display-timings {
+                       native-mode = <&timing0>;
+                       timing0: timing0 {
+                               clock-frequency = <9000000>;
+                               hactive = <480>;
+                               vactive = <272>;
+                               hback-porch = <1>;
+                               hfront-porch = <1>;
+                               vback-porch = <40>;
+                               vfront-porch = <1>;
+                               hsync-len = <45>;
+                               vsync-len = <1>;
+                       };
+               };
+       };
index 629ea5fc95cf74e2cf72a145d3ea80c4d98aa4b3..b2a34740146aaab4d3af99b741979c670be6402e 100644 (file)
@@ -465,7 +465,7 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
 
 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
 static u64 lcdc_dmamask = DMA_BIT_MASK(32);
-static struct atmel_lcdfb_info lcdc_data;
+static struct atmel_lcdfb_pdata lcdc_data;
 
 static struct resource lcdc_resources[] = {
        [0] = {
@@ -498,7 +498,7 @@ static struct platform_device at91_lcdc_device = {
        .num_resources  = ARRAY_SIZE(lcdc_resources),
 };
 
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
+void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data)
 {
        if (!data) {
                return;
@@ -559,7 +559,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
        platform_device_register(&at91_lcdc_device);
 }
 #else
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
+void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) {}
 #endif
 
 
index 858c8aac2daf06328ed99de3b56987647f81b33d..4aeadddbc18108918b883150bef49b3a770eeb42 100644 (file)
@@ -832,7 +832,7 @@ void __init at91_add_device_can(struct at91_can_data *data) {}
 
 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
 static u64 lcdc_dmamask = DMA_BIT_MASK(32);
-static struct atmel_lcdfb_info lcdc_data;
+static struct atmel_lcdfb_pdata lcdc_data;
 
 static struct resource lcdc_resources[] = {
        [0] = {
@@ -859,7 +859,7 @@ static struct platform_device at91_lcdc_device = {
        .num_resources  = ARRAY_SIZE(lcdc_resources),
 };
 
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
+void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data)
 {
        if (!data)
                return;
@@ -891,7 +891,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
        platform_device_register(&at91_lcdc_device);
 }
 #else
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
+void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) {}
 #endif
 
 
index acb703e13331e2a9931bb321d7c1f9f71d550f11..cb36fa872d305d6f22b9133d48d3bdaaa678789d 100644 (file)
@@ -965,7 +965,7 @@ void __init at91_add_device_isi(struct isi_platform_data *data,
 
 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
 static u64 lcdc_dmamask = DMA_BIT_MASK(32);
-static struct atmel_lcdfb_info lcdc_data;
+static struct atmel_lcdfb_pdata lcdc_data;
 
 static struct resource lcdc_resources[] = {
        [0] = {
@@ -991,7 +991,7 @@ static struct platform_device at91_lcdc_device = {
        .num_resources  = ARRAY_SIZE(lcdc_resources),
 };
 
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
+void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data)
 {
        if (!data)
                return;
@@ -1037,7 +1037,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
        platform_device_register(&at91_lcdc_device);
 }
 #else
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
+void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) {}
 #endif
 
 
index 352468f265a9616bb411fecc503a13a933e926b2..a698bdab2cce682fee2983e0942d5bc2126139e4 100644 (file)
@@ -498,7 +498,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
 
 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
 static u64 lcdc_dmamask = DMA_BIT_MASK(32);
-static struct atmel_lcdfb_info lcdc_data;
+static struct atmel_lcdfb_pdata lcdc_data;
 
 static struct resource lcdc_resources[] = {
        [0] = {
@@ -525,7 +525,7 @@ static struct platform_device at91_lcdc_device = {
        .num_resources  = ARRAY_SIZE(lcdc_resources),
 };
 
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
+void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data)
 {
        if (!data) {
                return;
@@ -557,7 +557,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
        platform_device_register(&at91_lcdc_device);
 }
 #else
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
+void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) {}
 #endif
 
 
index d3437624ca4e213092132bd6a16195e8668a9d7e..473546b9408bf087a6b1a38950a9cf2157b3497f 100644 (file)
@@ -389,7 +389,7 @@ static struct fb_monspecs at91fb_default_stn_monspecs = {
                                        | ATMEL_LCDC_IFWIDTH_4 \
                                        | ATMEL_LCDC_SCANMOD_SINGLE)
 
-static void at91_lcdc_stn_power_control(int on)
+static void at91_lcdc_stn_power_control(struct atmel_lcdfb_pdata *pdata, int on)
 {
        /* backlight */
        if (on) {       /* power up */
@@ -401,7 +401,7 @@ static void at91_lcdc_stn_power_control(int on)
        }
 }
 
-static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {
        .default_bpp                    = 1,
        .default_dmacon                 = ATMEL_LCDC_DMAEN,
        .default_lcdcon2                = AT91SAM9261_DEFAULT_STN_LCDCON2,
@@ -445,7 +445,7 @@ static struct fb_monspecs at91fb_default_tft_monspecs = {
                                        | ATMEL_LCDC_DISTYPE_TFT    \
                                        | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
 
-static void at91_lcdc_tft_power_control(int on)
+static void at91_lcdc_tft_power_control(struct atmel_lcdfb_pdata *pdata, int on)
 {
        if (on)
                at91_set_gpio_value(AT91_PIN_PA12, 0);  /* power up */
@@ -453,7 +453,7 @@ static void at91_lcdc_tft_power_control(int on)
                at91_set_gpio_value(AT91_PIN_PA12, 1);  /* power down */
 }
 
-static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {
        .lcdcon_is_backlight            = true,
        .default_bpp                    = 16,
        .default_dmacon                 = ATMEL_LCDC_DMAEN,
@@ -465,7 +465,7 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
 #endif
 
 #else
-static struct atmel_lcdfb_info __initdata ek_lcdc_data;
+static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;
 #endif
 
 
index 947e134ac4c3996700a6b075d24ab5afbeb2dc3f..2f931915c80c8d2f9a6c9059cf2e6eb07d2093a7 100644 (file)
@@ -275,13 +275,13 @@ static struct fb_monspecs at91fb_default_monspecs = {
                                        | ATMEL_LCDC_DISTYPE_TFT \
                                        | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
 
-static void at91_lcdc_power_control(int on)
+static void at91_lcdc_power_control(struct atmel_lcdfb_pdata *pdata, int on)
 {
        at91_set_gpio_value(AT91_PIN_PA30, on);
 }
 
 /* Driver datas */
-static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {
        .lcdcon_is_backlight            = true,
        .default_bpp                    = 16,
        .default_dmacon                 = ATMEL_LCDC_DMAEN,
@@ -292,7 +292,7 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
 };
 
 #else
-static struct atmel_lcdfb_info __initdata ek_lcdc_data;
+static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;
 #endif
 
 
index 2a94896a1375029b8eb34e030981480ad35acd10..ef39078c8ce214973352a22055421d7404cb4952 100644 (file)
@@ -284,7 +284,7 @@ static struct fb_monspecs at91fb_default_monspecs = {
                                        | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
 
 /* Driver datas */
-static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {
        .lcdcon_is_backlight            = true,
        .default_bpp                    = 32,
        .default_dmacon                 = ATMEL_LCDC_DMAEN,
@@ -295,7 +295,7 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
 };
 
 #else
-static struct atmel_lcdfb_info __initdata ek_lcdc_data;
+static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;
 #endif
 
 
index aa265dcf212875651da778e9213177b7e41803de..604eecf6cd70d03b57c34e6a2736f9feceb5be98 100644 (file)
@@ -170,7 +170,7 @@ static struct fb_monspecs at91fb_default_monspecs = {
                                        | ATMEL_LCDC_DISTYPE_TFT \
                                        | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
 
-static void at91_lcdc_power_control(int on)
+static void at91_lcdc_power_control(struct atmel_lcdfb_pdata *pdata, int on)
 {
        if (on)
                at91_set_gpio_value(AT91_PIN_PC1, 0);   /* power up */
@@ -179,7 +179,7 @@ static void at91_lcdc_power_control(int on)
 }
 
 /* Driver datas */
-static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {
        .lcdcon_is_backlight            = true,
        .default_bpp                    = 16,
        .default_dmacon                 = ATMEL_LCDC_DMAEN,
@@ -191,7 +191,7 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
 };
 
 #else
-static struct atmel_lcdfb_info __initdata ek_lcdc_data;
+static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;
 #endif
 
 
index 4a234fb2ab3b80d73dbdfa6bafc1cf7a08253287..6c08b341167d308df456eb1a0e79b4f10b5a9e00 100644 (file)
@@ -107,8 +107,8 @@ extern void __init at91_add_device_pwm(u32 mask);
 extern void __init at91_add_device_ssc(unsigned id, unsigned pins);
 
  /* LCD Controller */
-struct atmel_lcdfb_info;
-extern void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data);
+struct atmel_lcdfb_pdata;
+extern void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data);
 
  /* AC97 */
 extern void __init at91_add_device_ac97(struct ac97c_platform_data *data);
index 702232996c8c36ffc3b86e01d58807c2561c1282..cfadd974f5ce060942b02a9eff015d322a381d82 100644 (file)
@@ -191,7 +191,6 @@ static struct pxa3xx_nand_platform_data dkb_nand_info = {
 #define SCLK_SOURCE_SELECT(x)  (x << 30) /* 0x0 ~ 0x3 */
 /* link config */
 #define CFG_DUMBMODE(mode)     (mode << 28) /* 0x0 ~ 0x6*/
-#define CFG_GRA_SWAPRB(x)      (x << 0) /* 1: rbswap enabled */
 static struct mmp_mach_path_config dkb_disp_config[] = {
        [0] = {
                .name = "mmp-parallel",
@@ -199,8 +198,7 @@ static struct mmp_mach_path_config dkb_disp_config[] = {
                .output_type = PATH_OUT_PARALLEL,
                .path_config = CFG_IOPADMODE(0x1)
                        | SCLK_SOURCE_SELECT(0x1),
-               .link_config = CFG_DUMBMODE(0x2)
-                       | CFG_GRA_SWAPRB(0x1),
+               .link_config = CFG_DUMBMODE(0x2),
        },
 };
 
index 20388750d56447ee92324ee50cadfc0dacb5c89b..64919b0da7aa53a5464a4dff92452c5aa94b46b1 100644 (file)
@@ -58,7 +58,7 @@ static struct fb_monspecs __initdata atevklcd10x_default_monspecs = {
        .dclkmax                = 28330000,
 };
 
-static struct atmel_lcdfb_info __initdata atevklcd10x_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata atevklcd10x_lcdc_data = {
        .default_bpp            = 16,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
@@ -96,7 +96,7 @@ static struct fb_monspecs __initdata atevklcd10x_default_monspecs = {
        .dclkmax                = 7000000,
 };
 
-static struct atmel_lcdfb_info __initdata atevklcd10x_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata atevklcd10x_lcdc_data = {
        .default_bpp            = 16,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
@@ -134,7 +134,7 @@ static struct fb_monspecs __initdata atevklcd10x_default_monspecs = {
        .dclkmax                = 6400000,
 };
 
-static struct atmel_lcdfb_info __initdata atevklcd10x_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata atevklcd10x_lcdc_data = {
        .default_bpp            = 16,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
@@ -145,7 +145,7 @@ static struct atmel_lcdfb_info __initdata atevklcd10x_lcdc_data = {
 };
 #endif
 
-static void atevklcd10x_lcdc_power_control(int on)
+static void atevklcd10x_lcdc_power_control(struct atmel_lcdfb_pdata *pdata, int on)
 {
        gpio_set_value(GPIO_PIN_PB(15), on);
 }
index 7de083d19b7ee0b5cf9f63a14f953b7311a1564e..1ba09e4c02b14d08c1bc0211866e43c1aec5735f 100644 (file)
@@ -83,7 +83,7 @@ static struct fb_monspecs __initdata lcd_fb_default_monspecs = {
        .dclkmax                = 9260000,
 };
 
-static struct atmel_lcdfb_info __initdata rmt_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata rmt_lcdc_data = {
        .default_bpp            = 24,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
@@ -126,7 +126,7 @@ static struct fb_monspecs __initdata lcd_fb_default_monspecs = {
        .dclkmax                = 9260000,
 };
 
-static struct atmel_lcdfb_info __initdata rmt_lcdc_data = {
+static struct atmel_lcdfb_pdata __initdata rmt_lcdc_data = {
        .default_bpp            = 24,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
index 9392d3252865a6886025167fe151e7356acf8f64..653cc09e536c7555272b2d2988f6db67ffa61ce9 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef __ARCH_AVR32_BOARDS_ATSTK1000_ATSTK1000_H
 #define __ARCH_AVR32_BOARDS_ATSTK1000_ATSTK1000_H
 
-extern struct atmel_lcdfb_info atstk1000_lcdc_data;
+extern struct atmel_lcdfb_pdata atstk1000_lcdc_data;
 
 void atstk1000_setup_j2_leds(void);
 
index 2d6b560115d9fa19c250f52a0a6e7c27bea27e81..b6b88f5e0b43a6d1e8c330e512021ec27935e7d5 100644 (file)
@@ -55,7 +55,7 @@ static struct fb_monspecs __initdata atstk1000_default_monspecs = {
        .dclkmax                = 30000000,
 };
 
-struct atmel_lcdfb_info __initdata atstk1000_lcdc_data = {
+struct atmel_lcdfb_pdata __initdata atstk1000_lcdc_data = {
        .default_bpp            = 24,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
index 27bd6fbe21cb5f76253ad88f50f4a12c13f9778e..7b1f2cd854008c16117cf5c39c06f4bd2115a9fa 100644 (file)
@@ -125,7 +125,7 @@ static struct fb_monspecs __initdata favr32_default_monspecs = {
        .dclkmax                = 28000000,
 };
 
-struct atmel_lcdfb_info __initdata favr32_lcdc_data = {
+struct atmel_lcdfb_pdata __initdata favr32_lcdc_data = {
        .default_bpp            = 16,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
index 9d1efd1cd42534076307d59c1444a663c3b8764d..dc0e317f2ecdddc62c23939dd0863749c4491de8 100644 (file)
@@ -77,7 +77,7 @@ static struct fb_monspecs __initdata hammerhead_hda350t_monspecs = {
        .dclkmax                = 10000000,
 };
 
-struct atmel_lcdfb_info __initdata hammerhead_lcdc_data = {
+struct atmel_lcdfb_pdata __initdata hammerhead_lcdc_data = {
        .default_bpp            = 24,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
index 85a543cd4abcf26c3e517975029b8b694f197999..e7683ee7ed408d8ebe46930bf9ee4cb6a0885e91 100644 (file)
@@ -45,7 +45,7 @@ static struct fb_monspecs merisc_fb_monspecs = {
        .dclkmax        = 30000000,
 };
 
-struct atmel_lcdfb_info merisc_lcdc_data = {
+struct atmel_lcdfb_pdata merisc_lcdc_data = {
        .default_bpp            = 24,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
index 05358aa5ef7d210ed42d2bb6f68be48b3fa4c690..1cb8e9cc5cfaedb6d00ed8e589393531c37bf4ed 100644 (file)
@@ -8,7 +8,7 @@
  * published by the Free Software Foundation.
  */
 
-extern struct atmel_lcdfb_info mimc200_lcdc_data;
+extern struct atmel_lcdfb_pdata mimc200_lcdc_data;
 
 #include <linux/clk.h>
 #include <linux/etherdevice.h>
@@ -71,7 +71,7 @@ static struct fb_monspecs __initdata mimc200_default_monspecs = {
        .dclkmax                = 25200000,
 };
 
-struct atmel_lcdfb_info __initdata mimc200_lcdc_data = {
+struct atmel_lcdfb_pdata __initdata mimc200_lcdc_data = {
        .default_bpp            = 16,
        .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
        .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
index a68f3cf7c3c1bda0f3d02dc8d45672a4f3db0793..a1f4d1e91b522e03f486b41759a1b25a2d44e36f 100644 (file)
@@ -1439,7 +1439,7 @@ fail:
  *  LCDC
  * -------------------------------------------------------------------- */
 #if defined(CONFIG_CPU_AT32AP7000) || defined(CONFIG_CPU_AT32AP7002)
-static struct atmel_lcdfb_info atmel_lcdfb0_data;
+static struct atmel_lcdfb_pdata atmel_lcdfb0_data;
 static struct resource atmel_lcdfb0_resource[] = {
        {
                .start          = 0xff000000,
@@ -1467,12 +1467,12 @@ static struct clk atmel_lcdfb0_pixclk = {
 };
 
 struct platform_device *__init
-at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
+at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_pdata *data,
                     unsigned long fbmem_start, unsigned long fbmem_len,
                     u64 pin_mask)
 {
        struct platform_device *pdev;
-       struct atmel_lcdfb_info *info;
+       struct atmel_lcdfb_pdata *info;
        struct fb_monspecs *monspecs;
        struct fb_videomode *modedb;
        unsigned int modedb_size;
@@ -1529,7 +1529,7 @@ at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
        }
 
        info = pdev->dev.platform_data;
-       memcpy(info, data, sizeof(struct atmel_lcdfb_info));
+       memcpy(info, data, sizeof(struct atmel_lcdfb_pdata));
        info->default_monspecs = monspecs;
 
        pdev->name = "at32ap-lcdfb";
index d485b0391357cab467faefab4e07ba20e0aad2ac..f1a316d52c738b0bac6653c876c3c7c817f28a66 100644 (file)
@@ -44,9 +44,9 @@ struct platform_device *
 at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n);
 void at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b, unsigned int n);
 
-struct atmel_lcdfb_info;
+struct atmel_lcdfb_pdata;
 struct platform_device *
-at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
+at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_pdata *data,
                     unsigned long fbmem_start, unsigned long fbmem_len,
                     u64 pin_mask);
 
index a312f048656f76f017c2a730836762cadd1e8553..4f2e1b35eb385046af6343290aca9870258922c0 100644 (file)
@@ -996,6 +996,8 @@ config FB_ATMEL
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
+       select FB_MODE_HELPERS
+       select VIDEOMODE_HELPERS
        help
          This enables support for the AT91/AT32 LCD Controller.
 
index afe4702a5528a0ea9675cdabfce8ee4243e3799a..14d6b3793e0a7a22e81ac3e6cbe1a60e5861d2d4 100644 (file)
@@ -545,7 +545,7 @@ static int clcdfb_register(struct clcd_fb *fb)
 
 static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id)
 {
-       struct clcd_board *board = dev->dev.platform_data;
+       struct clcd_board *board = dev_get_platdata(&dev->dev);
        struct clcd_fb *fb;
        int ret;
 
@@ -599,8 +599,6 @@ static int clcdfb_remove(struct amba_device *dev)
 {
        struct clcd_fb *fb = amba_get_drvdata(dev);
 
-       amba_set_drvdata(dev, NULL);
-
        clcdfb_disable(fb);
        unregister_framebuffer(&fb->fb);
        if (fb->fb.cmap.len)
index a6780eecff0e6aefb864c737ad12a2d9ee8e928a..8ab304d1c855be48fb6972295a8cd51cb6abe118 100644 (file)
@@ -3748,7 +3748,6 @@ default_chipset:
        return 0;
 
 unset_drvdata:
-       dev_set_drvdata(&pdev->dev, NULL);
        fb_dealloc_cmap(&info->cmap);
 free_irq:
        free_irq(IRQ_AMIGA_COPPER, info->par);
@@ -3768,7 +3767,6 @@ static int __exit amifb_remove(struct platform_device *pdev)
        struct fb_info *info = dev_get_drvdata(&pdev->dev);
 
        unregister_framebuffer(info);
-       dev_set_drvdata(&pdev->dev, NULL);
        fb_dealloc_cmap(&info->cmap);
        free_irq(IRQ_AMIGA_COPPER, info->par);
        custom.dmacon = DMAF_ALL | DMAF_MASTER;
index 94a51f1ef904d55515fb56d02570eb86502e3e01..15dd5423d64a0a38f29a7b0d8b047e2a5f726e07 100644 (file)
@@ -1048,7 +1048,7 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
        rc = register_framebuffer(info);
        if (rc < 0) {
-               dev_err(info->device, "cannot register framebugger\n");
+               dev_err(info->device, "cannot register framebuffer\n");
                goto err_reg_fb;
        }
 
@@ -1108,7 +1108,6 @@ static void ark_pci_remove(struct pci_dev *dev)
                pci_release_regions(dev);
 /*             pci_disable_device(dev); */
 
-               pci_set_drvdata(dev, NULL);
                framebuffer_release(info);
        }
 }
index 088511a58a269abc2126f90969a08f3d75a5b22c..8521051cf946f0025a9cab15e4f8f880ac841016 100644 (file)
 #include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/platform_data/atmel.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <video/of_display_timing.h>
+#include <video/videomode.h>
 
 #include <mach/cpu.h>
 #include <asm/gpio.h>
 
 #include <video/atmel_lcdc.h>
 
+struct atmel_lcdfb_config {
+       bool have_alt_pixclock;
+       bool have_hozval;
+       bool have_intensity_bit;
+};
+
+ /* LCD Controller info data structure, stored in device platform_data */
+struct atmel_lcdfb_info {
+       spinlock_t              lock;
+       struct fb_info          *info;
+       void __iomem            *mmio;
+       int                     irq_base;
+       struct work_struct      task;
+
+       unsigned int            smem_len;
+       struct platform_device  *pdev;
+       struct clk              *bus_clk;
+       struct clk              *lcdc_clk;
+
+       struct backlight_device *backlight;
+       u8                      bl_power;
+       u8                      saved_lcdcon;
+
+       u32                     pseudo_palette[16];
+       bool                    have_intensity_bit;
+
+       struct atmel_lcdfb_pdata pdata;
+
+       struct atmel_lcdfb_config *config;
+};
+
+struct atmel_lcdfb_power_ctrl_gpio {
+       int gpio;
+       int active_low;
+
+       struct list_head list;
+};
+
 #define lcdc_readl(sinfo, reg)         __raw_readl((sinfo)->mmio+(reg))
 #define lcdc_writel(sinfo, reg, val)   __raw_writel((val), (sinfo)->mmio+(reg))
 
 #define ATMEL_LCDC_DMA_BURST_LEN       8       /* words */
 #define ATMEL_LCDC_FIFO_SIZE           512     /* words */
 
-struct atmel_lcdfb_config {
-       bool have_alt_pixclock;
-       bool have_hozval;
-       bool have_intensity_bit;
-};
-
 static struct atmel_lcdfb_config at91sam9261_config = {
        .have_hozval            = true,
        .have_intensity_bit     = true,
@@ -248,18 +285,27 @@ static void exit_backlight(struct atmel_lcdfb_info *sinfo)
 
 static void init_contrast(struct atmel_lcdfb_info *sinfo)
 {
+       struct atmel_lcdfb_pdata *pdata = &sinfo->pdata;
+
        /* contrast pwm can be 'inverted' */
-       if (sinfo->lcdcon_pol_negative)
+       if (pdata->lcdcon_pol_negative)
                        contrast_ctr &= ~(ATMEL_LCDC_POL_POSITIVE);
 
        /* have some default contrast/backlight settings */
        lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, contrast_ctr);
        lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, ATMEL_LCDC_CVAL_DEFAULT);
 
-       if (sinfo->lcdcon_is_backlight)
+       if (pdata->lcdcon_is_backlight)
                init_backlight(sinfo);
 }
 
+static inline void atmel_lcdfb_power_control(struct atmel_lcdfb_info *sinfo, int on)
+{
+       struct atmel_lcdfb_pdata *pdata = &sinfo->pdata;
+
+       if (pdata->atmel_lcdfb_power_control)
+               pdata->atmel_lcdfb_power_control(pdata, on);
+}
 
 static struct fb_fix_screeninfo atmel_lcdfb_fix __initdata = {
        .type           = FB_TYPE_PACKED_PIXELS,
@@ -299,9 +345,11 @@ static unsigned long compute_hozval(struct atmel_lcdfb_info *sinfo,
 
 static void atmel_lcdfb_stop_nowait(struct atmel_lcdfb_info *sinfo)
 {
+       struct atmel_lcdfb_pdata *pdata = &sinfo->pdata;
+
        /* Turn off the LCD controller and the DMA controller */
        lcdc_writel(sinfo, ATMEL_LCDC_PWRCON,
-                       sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET);
+                       pdata->guard_time << ATMEL_LCDC_GUARDT_OFFSET);
 
        /* Wait for the LCDC core to become idle */
        while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY)
@@ -321,9 +369,11 @@ static void atmel_lcdfb_stop(struct atmel_lcdfb_info *sinfo)
 
 static void atmel_lcdfb_start(struct atmel_lcdfb_info *sinfo)
 {
-       lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon);
+       struct atmel_lcdfb_pdata *pdata = &sinfo->pdata;
+
+       lcdc_writel(sinfo, ATMEL_LCDC_DMACON, pdata->default_dmacon);
        lcdc_writel(sinfo, ATMEL_LCDC_PWRCON,
-               (sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET)
+               (pdata->guard_time << ATMEL_LCDC_GUARDT_OFFSET)
                | ATMEL_LCDC_PWR);
 }
 
@@ -424,6 +474,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
 {
        struct device *dev = info->device;
        struct atmel_lcdfb_info *sinfo = info->par;
+       struct atmel_lcdfb_pdata *pdata = &sinfo->pdata;
        unsigned long clk_value_khz;
 
        clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000;
@@ -510,7 +561,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
                else
                        var->green.length = 6;
 
-               if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
+               if (pdata->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
                        /* RGB:5X5 mode */
                        var->red.offset = var->green.length + 5;
                        var->blue.offset = 0;
@@ -527,7 +578,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
                var->transp.length = 8;
                /* fall through */
        case 24:
-               if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
+               if (pdata->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
                        /* RGB:888 mode */
                        var->red.offset = 16;
                        var->blue.offset = 0;
@@ -576,6 +627,7 @@ static void atmel_lcdfb_reset(struct atmel_lcdfb_info *sinfo)
 static int atmel_lcdfb_set_par(struct fb_info *info)
 {
        struct atmel_lcdfb_info *sinfo = info->par;
+       struct atmel_lcdfb_pdata *pdata = &sinfo->pdata;
        unsigned long hozval_linesz;
        unsigned long value;
        unsigned long clk_value_khz;
@@ -637,7 +689,7 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
 
 
        /* Initialize control register 2 */
-       value = sinfo->default_lcdcon2;
+       value = pdata->default_lcdcon2;
 
        if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT))
                value |= ATMEL_LCDC_INVLINE_INVERTED;
@@ -741,6 +793,7 @@ static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red,
                             unsigned int transp, struct fb_info *info)
 {
        struct atmel_lcdfb_info *sinfo = info->par;
+       struct atmel_lcdfb_pdata *pdata = &sinfo->pdata;
        unsigned int val;
        u32 *pal;
        int ret = 1;
@@ -777,8 +830,7 @@ static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red,
                                 */
                        } else {
                                /* new style BGR:565 / RGB:565 */
-                               if (sinfo->lcd_wiring_mode ==
-                                   ATMEL_LCDC_WIRING_RGB) {
+                               if (pdata->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
                                        val  = ((blue >> 11) & 0x001f);
                                        val |= ((red  >>  0) & 0xf800);
                                } else {
@@ -912,16 +964,187 @@ static void atmel_lcdfb_stop_clock(struct atmel_lcdfb_info *sinfo)
        clk_disable_unprepare(sinfo->lcdc_clk);
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id atmel_lcdfb_dt_ids[] = {
+       { .compatible = "atmel,at91sam9261-lcdc" , .data = &at91sam9261_config, },
+       { .compatible = "atmel,at91sam9263-lcdc" , .data = &at91sam9263_config, },
+       { .compatible = "atmel,at91sam9g10-lcdc" , .data = &at91sam9g10_config, },
+       { .compatible = "atmel,at91sam9g45-lcdc" , .data = &at91sam9g45_config, },
+       { .compatible = "atmel,at91sam9g45es-lcdc" , .data = &at91sam9g45es_config, },
+       { .compatible = "atmel,at91sam9rl-lcdc" , .data = &at91sam9rl_config, },
+       { .compatible = "atmel,at32ap-lcdc" , .data = &at32ap_config, },
+       { /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, atmel_lcdfb_dt_ids);
+
+static const char *atmel_lcdfb_wiring_modes[] = {
+       [ATMEL_LCDC_WIRING_BGR] = "BRG",
+       [ATMEL_LCDC_WIRING_RGB] = "RGB",
+};
+
+const int atmel_lcdfb_get_of_wiring_modes(struct device_node *np)
+{
+       const char *mode;
+       int err, i;
+
+       err = of_property_read_string(np, "atmel,lcd-wiring-mode", &mode);
+       if (err < 0)
+               return ATMEL_LCDC_WIRING_BGR;
+
+       for (i = 0; i < ARRAY_SIZE(atmel_lcdfb_wiring_modes); i++)
+               if (!strcasecmp(mode, atmel_lcdfb_wiring_modes[i]))
+                       return i;
+
+       return -ENODEV;
+}
+
+static void atmel_lcdfb_power_control_gpio(struct atmel_lcdfb_pdata *pdata, int on)
+{
+       struct atmel_lcdfb_power_ctrl_gpio *og;
+
+       list_for_each_entry(og, &pdata->pwr_gpios, list)
+               gpio_set_value(og->gpio, on);
+}
+
+static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo)
+{
+       struct fb_info *info = sinfo->info;
+       struct atmel_lcdfb_pdata *pdata = &sinfo->pdata;
+       struct fb_var_screeninfo *var = &info->var;
+       struct device *dev = &sinfo->pdev->dev;
+       struct device_node *np =dev->of_node;
+       struct device_node *display_np;
+       struct device_node *timings_np;
+       struct display_timings *timings;
+       enum of_gpio_flags flags;
+       struct atmel_lcdfb_power_ctrl_gpio *og;
+       bool is_gpio_power = false;
+       int ret = -ENOENT;
+       int i, gpio;
+
+       sinfo->config = (struct atmel_lcdfb_config*)
+               of_match_device(atmel_lcdfb_dt_ids, dev)->data;
+
+       display_np = of_parse_phandle(np, "display", 0);
+       if (!display_np) {
+               dev_err(dev, "failed to find display phandle\n");
+               return -ENOENT;
+       }
+
+       ret = of_property_read_u32(display_np, "bits-per-pixel", &var->bits_per_pixel);
+       if (ret < 0) {
+               dev_err(dev, "failed to get property bits-per-pixel\n");
+               goto put_display_node;
+       }
+
+       ret = of_property_read_u32(display_np, "atmel,guard-time", &pdata->guard_time);
+       if (ret < 0) {
+               dev_err(dev, "failed to get property atmel,guard-time\n");
+               goto put_display_node;
+       }
+
+       ret = of_property_read_u32(display_np, "atmel,lcdcon2", &pdata->default_lcdcon2);
+       if (ret < 0) {
+               dev_err(dev, "failed to get property atmel,lcdcon2\n");
+               goto put_display_node;
+       }
+
+       ret = of_property_read_u32(display_np, "atmel,dmacon", &pdata->default_dmacon);
+       if (ret < 0) {
+               dev_err(dev, "failed to get property bits-per-pixel\n");
+               goto put_display_node;
+       }
+
+       ret = -ENOMEM;
+       for (i = 0; i < of_gpio_named_count(display_np, "atmel,power-control-gpio"); i++) {
+               gpio = of_get_named_gpio_flags(display_np, "atmel,power-control-gpio",
+                                              i, &flags);
+               if (gpio < 0)
+                       continue;
+
+               og = devm_kzalloc(dev, sizeof(*og), GFP_KERNEL);
+               if (!og)
+                       goto put_display_node;
+
+               og->gpio = gpio;
+               og->active_low = flags & OF_GPIO_ACTIVE_LOW;
+               is_gpio_power = true;
+               ret = devm_gpio_request(dev, gpio, "lcd-power-control-gpio");
+               if (ret) {
+                       dev_err(dev, "request gpio %d failed\n", gpio);
+                       goto put_display_node;
+               }
+
+               ret = gpio_direction_output(gpio, og->active_low);
+               if (ret) {
+                       dev_err(dev, "set direction output gpio %d failed\n", gpio);
+                       goto put_display_node;
+               }
+       }
+
+       if (is_gpio_power)
+               pdata->atmel_lcdfb_power_control = atmel_lcdfb_power_control_gpio;
+
+       ret = atmel_lcdfb_get_of_wiring_modes(display_np);
+       if (ret < 0) {
+               dev_err(dev, "invalid atmel,lcd-wiring-mode\n");
+               goto put_display_node;
+       }
+       pdata->lcd_wiring_mode = ret;
+
+       pdata->lcdcon_is_backlight = of_property_read_bool(display_np, "atmel,lcdcon-backlight");
+
+       timings = of_get_display_timings(display_np);
+       if (!timings) {
+               dev_err(dev, "failed to get display timings\n");
+               goto put_display_node;
+       }
+
+       timings_np = of_find_node_by_name(display_np, "display-timings");
+       if (!timings_np) {
+               dev_err(dev, "failed to find display-timings node\n");
+               goto put_display_node;
+       }
+
+       for (i = 0; i < of_get_child_count(timings_np); i++) {
+               struct videomode vm;
+               struct fb_videomode fb_vm;
+
+               ret = videomode_from_timings(timings, &vm, i);
+               if (ret < 0)
+                       goto put_timings_node;
+               ret = fb_videomode_from_videomode(&vm, &fb_vm);
+               if (ret < 0)
+                       goto put_timings_node;
+
+               fb_add_videomode(&fb_vm, &info->modelist);
+       }
+
+       return 0;
+
+put_timings_node:
+       of_node_put(timings_np);
+put_display_node:
+       of_node_put(display_np);
+       return ret;
+}
+#else
+static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo)
+{
+       return 0;
+}
+#endif
 
 static int __init atmel_lcdfb_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct fb_info *info;
        struct atmel_lcdfb_info *sinfo;
-       struct atmel_lcdfb_info *pdata_sinfo;
-       struct fb_videomode fbmode;
+       struct atmel_lcdfb_pdata *pdata = NULL;
        struct resource *regs = NULL;
        struct resource *map = NULL;
+       struct fb_modelist *modelist;
        int ret;
 
        dev_dbg(dev, "%s BEGIN\n", __func__);
@@ -934,26 +1157,35 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
        }
 
        sinfo = info->par;
+       sinfo->pdev = pdev;
+       sinfo->info = info;
+
+       INIT_LIST_HEAD(&info->modelist);
 
-       if (dev->platform_data) {
-               pdata_sinfo = (struct atmel_lcdfb_info *)dev->platform_data;
-               sinfo->default_bpp = pdata_sinfo->default_bpp;
-               sinfo->default_dmacon = pdata_sinfo->default_dmacon;
-               sinfo->default_lcdcon2 = pdata_sinfo->default_lcdcon2;
-               sinfo->default_monspecs = pdata_sinfo->default_monspecs;
-               sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control;
-               sinfo->guard_time = pdata_sinfo->guard_time;
-               sinfo->smem_len = pdata_sinfo->smem_len;
-               sinfo->lcdcon_is_backlight = pdata_sinfo->lcdcon_is_backlight;
-               sinfo->lcdcon_pol_negative = pdata_sinfo->lcdcon_pol_negative;
-               sinfo->lcd_wiring_mode = pdata_sinfo->lcd_wiring_mode;
+       if (pdev->dev.of_node) {
+               ret = atmel_lcdfb_of_init(sinfo);
+               if (ret)
+                       goto free_info;
+       } else if (dev_get_platdata(dev)) {
+               struct fb_monspecs *monspecs;
+               int i;
+
+               pdata = dev_get_platdata(dev);
+               monspecs = pdata->default_monspecs;
+               sinfo->pdata = *pdata;
+
+               for (i = 0; i < monspecs->modedb_len; i++)
+                       fb_add_videomode(&monspecs->modedb[i], &info->modelist);
+
+               sinfo->config = atmel_lcdfb_get_config(pdev);
+
+               info->var.bits_per_pixel = pdata->default_bpp ? pdata->default_bpp : 16;
+               memcpy(&info->monspecs, pdata->default_monspecs, sizeof(info->monspecs));
        } else {
                dev_err(dev, "cannot get default configuration\n");
                goto free_info;
        }
-       sinfo->info = info;
-       sinfo->pdev = pdev;
-       sinfo->config = atmel_lcdfb_get_config(pdev);
+
        if (!sinfo->config)
                goto free_info;
 
@@ -962,7 +1194,6 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
        info->pseudo_palette = sinfo->pseudo_palette;
        info->fbops = &atmel_lcdfb_ops;
 
-       memcpy(&info->monspecs, sinfo->default_monspecs, sizeof(info->monspecs));
        info->fix = atmel_lcdfb_fix;
 
        /* Enable LCDC Clocks */
@@ -978,14 +1209,11 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
        }
        atmel_lcdfb_start_clock(sinfo);
 
-       ret = fb_find_mode(&info->var, info, NULL, info->monspecs.modedb,
-                       info->monspecs.modedb_len, info->monspecs.modedb,
-                       sinfo->default_bpp);
-       if (!ret) {
-               dev_err(dev, "no suitable video mode found\n");
-               goto stop_clk;
-       }
+       modelist = list_first_entry(&info->modelist,
+                       struct fb_modelist, list);
+       fb_videomode_to_var(&info->var, &modelist->mode);
 
+       atmel_lcdfb_check_var(&info->var, info);
 
        regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!regs) {
@@ -1069,18 +1297,6 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
                goto unregister_irqs;
        }
 
-       /*
-        * This makes sure that our colour bitfield
-        * descriptors are correctly initialised.
-        */
-       atmel_lcdfb_check_var(&info->var, info);
-
-       ret = fb_set_var(info, &info->var);
-       if (ret) {
-               dev_warn(dev, "unable to set display parameters\n");
-               goto free_cmap;
-       }
-
        dev_set_drvdata(dev, info);
 
        /*
@@ -1092,13 +1308,8 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
                goto reset_drvdata;
        }
 
-       /* add selected videomode to modelist */
-       fb_var_to_videomode(&fbmode, &info->var);
-       fb_add_videomode(&fbmode, &info->modelist);
-
        /* Power up the LCDC screen */
-       if (sinfo->atmel_lcdfb_power_control)
-               sinfo->atmel_lcdfb_power_control(1);
+       atmel_lcdfb_power_control(sinfo, 1);
 
        dev_info(dev, "fb%d: Atmel LCDC at 0x%08lx (mapped at %p), irq %d\n",
                       info->node, info->fix.mmio_start, sinfo->mmio, sinfo->irq_base);
@@ -1107,7 +1318,6 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
 
 reset_drvdata:
        dev_set_drvdata(dev, NULL);
-free_cmap:
        fb_dealloc_cmap(&info->cmap);
 unregister_irqs:
        cancel_work_sync(&sinfo->task);
@@ -1143,15 +1353,16 @@ static int __exit atmel_lcdfb_remove(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct fb_info *info = dev_get_drvdata(dev);
        struct atmel_lcdfb_info *sinfo;
+       struct atmel_lcdfb_pdata *pdata;
 
        if (!info || !info->par)
                return 0;
        sinfo = info->par;
+       pdata = &sinfo->pdata;
 
        cancel_work_sync(&sinfo->task);
        exit_backlight(sinfo);
-       if (sinfo->atmel_lcdfb_power_control)
-               sinfo->atmel_lcdfb_power_control(0);
+       atmel_lcdfb_power_control(sinfo, 0);
        unregister_framebuffer(info);
        atmel_lcdfb_stop_clock(sinfo);
        clk_put(sinfo->lcdc_clk);
@@ -1167,7 +1378,6 @@ static int __exit atmel_lcdfb_remove(struct platform_device *pdev)
                atmel_lcdfb_free_video_memory(sinfo);
        }
 
-       dev_set_drvdata(dev, NULL);
        framebuffer_release(info);
 
        return 0;
@@ -1188,9 +1398,7 @@ static int atmel_lcdfb_suspend(struct platform_device *pdev, pm_message_t mesg)
 
        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);
-
+       atmel_lcdfb_power_control(sinfo, 0);
        atmel_lcdfb_stop(sinfo);
        atmel_lcdfb_stop_clock(sinfo);
 
@@ -1204,8 +1412,7 @@ static int atmel_lcdfb_resume(struct platform_device *pdev)
 
        atmel_lcdfb_start_clock(sinfo);
        atmel_lcdfb_start(sinfo);
-       if (sinfo->atmel_lcdfb_power_control)
-               sinfo->atmel_lcdfb_power_control(1);
+       atmel_lcdfb_power_control(sinfo, 1);
        lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, sinfo->saved_lcdcon);
 
        /* Enable FIFO & DMA errors */
@@ -1228,6 +1435,7 @@ static struct platform_driver atmel_lcdfb_driver = {
        .driver         = {
                .name   = "atmel_lcdfb",
                .owner  = THIS_MODULE,
+               .of_match_table = of_match_ptr(atmel_lcdfb_dt_ids),
        },
 };
 
index a4dfe8cb0a0a1b2cb5022c8e27f23f6b314a8026..b5edb6f08b845fd237f66c5cf9c08cf1fa8c3b7e 100644 (file)
@@ -413,7 +413,6 @@ struct aty128fb_par {
        int blitter_may_be_busy;
        int fifo_slots;                 /* free slots in FIFO (64 max) */
 
-       int     pm_reg;
        int crt_on, lcd_on;
        struct pci_dev *pdev;
        struct fb_info *next;
@@ -2016,7 +2015,6 @@ static int aty128_init(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        aty128_init_engine(par);
 
-       par->pm_reg = pdev->pm_cap;
        par->pdev = pdev;
        par->asleep = 0;
        par->lock_blank = 0;
@@ -2397,7 +2395,7 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
        u32     pmgt;
        struct pci_dev *pdev = par->pdev;
 
-       if (!par->pm_reg)
+       if (!par->pdev->pm_cap)
                return;
                
        /* Set the chip into the appropriate suspend mode (we use D2,
index 9b0f12c5c2842f783501821d7c6bb4a9527f936f..28fafbf864a50e91c7ef13135abec9bb9ca2b407 100644 (file)
@@ -1848,7 +1848,6 @@ static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
 
                        return aty_waitforvblank(par, crtc);
                }
-               break;
 
 #if defined(DEBUG) && defined(CONFIG_FB_ATY_CT)
        case ATYIO_CLKR:
index 1e30b2b3e79f3f0cf939272f9d43ce00d692b1d0..26d80a4486fb3024137ce2d38588f0d9b63d1f09 100644 (file)
@@ -819,11 +819,6 @@ static int radeonfb_check_var (struct fb_var_screeninfo *var, struct fb_info *in
        if (v.xres_virtual < v.xres)
                v.xres = v.xres_virtual;
 
-       if (v.xoffset < 0)
-                v.xoffset = 0;
-        if (v.yoffset < 0)
-                v.yoffset = 0;
-         
         if (v.xoffset > v.xres_virtual - v.xres)
                 v.xoffset = v.xres_virtual - v.xres - 1;
                         
index f7091ece580d6e52c2c7a5d6f4d77492c77cdebb..46a12f1a93c329e18597faac2ccdef015bd19227 100644 (file)
@@ -1427,6 +1427,8 @@ static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo)
        mdelay( 15);
 }
 
+#if defined(CONFIG_PM)
+#if defined(CONFIG_X86) || defined(CONFIG_PPC_PMAC)
 static void radeon_pm_reset_pad_ctlr_strength(struct radeonfb_info *rinfo)
 {
        u32 tmp, tmp2;
@@ -1939,9 +1941,10 @@ static void radeon_reinitialize_M10(struct radeonfb_info *rinfo)
         */
        radeon_pm_m10_enable_lvds_spread_spectrum(rinfo);
 }
+#endif
 
 #ifdef CONFIG_PPC_OF
-
+#ifdef CONFIG_PPC_PMAC
 static void radeon_pm_m9p_reconfigure_mc(struct radeonfb_info *rinfo)
 {
        OUTREG(MC_CNTL, rinfo->save_regs[46]);
@@ -2202,6 +2205,8 @@ static void radeon_reinitialize_M9P(struct radeonfb_info *rinfo)
        radeon_pm_restore_pixel_pll(rinfo);
        radeon_pm_m10_enable_lvds_spread_spectrum(rinfo);
 }
+#endif
+#endif
 
 #if 0 /* Not ready yet */
 static void radeon_reinitialize_QW(struct radeonfb_info *rinfo)
@@ -2515,13 +2520,13 @@ static void radeonfb_whack_power_state(struct radeonfb_info *rinfo, pci_power_t
 
        for (;;) {
                pci_read_config_word(rinfo->pdev,
-                                    rinfo->pm_reg+PCI_PM_CTRL,
+                                    rinfo->pdev->pm_cap + PCI_PM_CTRL,
                                     &pwr_cmd);
-               if (pwr_cmd & 2)
+               if (pwr_cmd & state)
                        break;
-               pwr_cmd = (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | 2;
+               pwr_cmd = (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | state;
                pci_write_config_word(rinfo->pdev,
-                                     rinfo->pm_reg+PCI_PM_CTRL,
+                                     rinfo->pdev->pm_cap + PCI_PM_CTRL,
                                      pwr_cmd);
                msleep(500);
        }
@@ -2532,7 +2537,7 @@ static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
 {
        u32 tmp;
 
-       if (!rinfo->pm_reg)
+       if (!rinfo->pdev->pm_cap)
                return;
 
        /* Set the chip into appropriate suspend mode (we use D2,
@@ -2804,9 +2809,6 @@ static void radeonfb_early_resume(void *data)
 
 void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk, int ignore_devlist, int force_sleep)
 {
-       /* Find PM registers in config space if any*/
-       rinfo->pm_reg = rinfo->pdev->pm_cap;
-
        /* Enable/Disable dynamic clocks: TODO add sysfs access */
        if (rinfo->family == CHIP_FAMILY_RS480)
                rinfo->dynclk = -1;
@@ -2830,7 +2832,7 @@ void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk, int ignore_devlis
         * reason. --BenH
         */
        if (machine_is(powermac) && rinfo->of_node) {
-               if (rinfo->is_mobility && rinfo->pm_reg &&
+               if (rinfo->is_mobility && rinfo->pdev->pm_cap &&
                    rinfo->family <= CHIP_FAMILY_RV250)
                        rinfo->pm_mode |= radeon_pm_d2;
 
index 7351e66c7f54e6d385740838ec4eb6f4c17af613..cb846044f57c075dd3aecf1cbc79b036d4156155 100644 (file)
@@ -342,7 +342,6 @@ struct radeonfb_info {
 
        int                     mtrr_hdl;
 
-       int                     pm_reg;
        u32                     save_regs[100];
        int                     asleep;
        int                     lock_blank;
index a54ccdc4d6618bf4bdcfd5202f3e8489f22cec34..b95bbfc3099767adf42d3288301419a6b92b0111 100644 (file)
@@ -588,7 +588,7 @@ int au1100fb_drv_remove(struct platform_device *dev)
        if (!dev)
                return -ENODEV;
 
-       fbdev = (struct au1100fb_device *) platform_get_drvdata(dev);
+       fbdev = platform_get_drvdata(dev);
 
 #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO)
        au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info);
@@ -660,19 +660,7 @@ static struct platform_driver au1100fb_driver = {
        .suspend        = au1100fb_drv_suspend,
         .resume                = au1100fb_drv_resume,
 };
-
-static int __init au1100fb_load(void)
-{
-       return platform_driver_register(&au1100fb_driver);
-}
-
-static void __exit au1100fb_unload(void)
-{
-       platform_driver_unregister(&au1100fb_driver);
-}
-
-module_init(au1100fb_load);
-module_exit(au1100fb_unload);
+module_platform_driver(au1100fb_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
index 301224ecc9507186e78e9cc14576e7a5316b227d..7a6b4c6f863b5f9910a16c437af3bca6ea0a4389 100644 (file)
@@ -1874,21 +1874,7 @@ static struct platform_driver au1200fb_driver = {
        .probe          = au1200fb_drv_probe,
        .remove         = au1200fb_drv_remove,
 };
-
-/*-------------------------------------------------------------------------*/
-
-static int __init au1200fb_init(void)
-{
-       return platform_driver_register(&au1200fb_driver);
-}
-
-static void __exit au1200fb_cleanup(void)
-{
-       platform_driver_unregister(&au1200fb_driver);
-}
-
-module_init(au1200fb_init);
-module_exit(au1200fb_cleanup);
+module_platform_driver(au1200fb_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
index a35a38c709cf03753a717c8be86d14aae982bcc6..59eebe0b38466476672ef0b1e683fc7f75654d8d 100644 (file)
@@ -244,7 +244,6 @@ static int l4f00242t03_remove(struct spi_device *spi)
 
        l4f00242t03_lcd_power_set(priv->ld, FB_BLANK_POWERDOWN);
        lcd_device_unregister(priv->ld);
-       spi_set_drvdata(spi, NULL);
 
        return 0;
 }
index bf081573e5b5938c7084c8d2206baa2512ff460f..be5d636764bf4bc9b8eec7417c0730dea0914e26 100644 (file)
@@ -198,7 +198,7 @@ static int tosa_lcd_probe(struct spi_device *spi)
        ret = devm_gpio_request_one(&spi->dev, TOSA_GPIO_TG_ON,
                                GPIOF_OUT_INIT_LOW, "tg #pwr");
        if (ret < 0)
-               goto err_gpio_tg;
+               return ret;
 
        mdelay(60);
 
@@ -219,8 +219,6 @@ static int tosa_lcd_probe(struct spi_device *spi)
 
 err_register:
        tosa_lcd_tg_off(data);
-err_gpio_tg:
-       spi_set_drvdata(spi, NULL);
        return ret;
 }
 
@@ -235,8 +233,6 @@ static int tosa_lcd_remove(struct spi_device *spi)
 
        tosa_lcd_tg_off(data);
 
-       spi_set_drvdata(spi, NULL);
-
        return 0;
 }
 
index 87f288bfc58c3464e44645e9264a991d28045895..42b8f9d1101834d3f5fe09dde3b44e23a2e97b74 100644 (file)
@@ -761,19 +761,7 @@ static struct platform_driver bfin_bf54x_driver = {
                   .owner = THIS_MODULE,
                   },
 };
-
-static int __init bfin_bf54x_driver_init(void)
-{
-       return platform_driver_register(&bfin_bf54x_driver);
-}
-
-static void __exit bfin_bf54x_driver_cleanup(void)
-{
-       platform_driver_unregister(&bfin_bf54x_driver);
-}
+module_platform_driver(bfin_bf54x_driver);
 
 MODULE_DESCRIPTION("Blackfin BF54x TFT LCD Driver");
 MODULE_LICENSE("GPL");
-
-module_init(bfin_bf54x_driver_init);
-module_exit(bfin_bf54x_driver_cleanup);
index 48c0c4e38a62a0e4be7bb43c4999e9927247ddc6..b5cf1307a3d9e546cab96fb9bdbc8f662ed88b52 100644 (file)
@@ -664,19 +664,7 @@ static struct platform_driver bfin_t350mcqb_driver = {
                   .owner = THIS_MODULE,
                   },
 };
-
-static int __init bfin_t350mcqb_driver_init(void)
-{
-       return platform_driver_register(&bfin_t350mcqb_driver);
-}
-
-static void __exit bfin_t350mcqb_driver_cleanup(void)
-{
-       platform_driver_unregister(&bfin_t350mcqb_driver);
-}
+module_platform_driver(bfin_t350mcqb_driver);
 
 MODULE_DESCRIPTION("Blackfin TFT LCD Driver");
 MODULE_LICENSE("GPL");
-
-module_init(bfin_t350mcqb_driver_init);
-module_exit(bfin_t350mcqb_driver_cleanup);
index b09701c7943272abc934afd7c6821620d319ac51..393d5a03b34e41e63d569f23b2b54bbeaf719ac5 100644 (file)
@@ -1217,19 +1217,7 @@ static struct platform_driver broadsheetfb_driver = {
                .name   = "broadsheetfb",
        },
 };
-
-static int __init broadsheetfb_init(void)
-{
-       return platform_driver_register(&broadsheetfb_driver);
-}
-
-static void __exit broadsheetfb_exit(void)
-{
-       platform_driver_unregister(&broadsheetfb_driver);
-}
-
-module_init(broadsheetfb_init);
-module_exit(broadsheetfb_exit);
+module_platform_driver(broadsheetfb_driver);
 
 MODULE_DESCRIPTION("fbdev driver for Broadsheet controller");
 MODULE_AUTHOR("Jaya Kumar");
index 60017fc634b57462a92f388f531dbb17efeda235..bc123d6947a490b16b7ce137b7dc26364ed6c5d6 100644 (file)
@@ -363,8 +363,6 @@ static int bw2_remove(struct platform_device *op)
 
        framebuffer_release(info);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 153dd65b0ae80c32ebcbe857cb43fb768820ffb8..b98f709abf528fd1627d6167d7fa63415dade9d5 100644 (file)
@@ -746,7 +746,6 @@ static void carminefb_remove(struct pci_dev *dev)
        iounmap(hw->v_regs);
        release_mem_region(fix.mmio_start, fix.mmio_len);
 
-       pci_set_drvdata(dev, NULL);
        pci_disable_device(dev);
        kfree(hw);
 }
index ed3b8891e0068e25cf0ba7a22b416536b8ff91ee..9626488a69c53762902caca5cee237e1ecf197bd 100644 (file)
@@ -583,8 +583,6 @@ static int cg14_remove(struct platform_device *op)
 
        framebuffer_release(info);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 9f63507ded373621cfa74524fd0f27ddd205cacc..64a89d5747ed1db8f5c36aa01d6b2b31a6c0101c 100644 (file)
@@ -446,8 +446,6 @@ static int cg3_remove(struct platform_device *op)
 
        framebuffer_release(info);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 3545decc748528b4cec5c16369da88a0f6e4469a..f070ec3b0f0a83b6fe342d706d0a1c931c41e6f1 100644 (file)
@@ -839,8 +839,6 @@ static int cg6_remove(struct platform_device *op)
 
        framebuffer_release(info);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 97db3ba8f2377d8cd66c677e68703d03255f76fe..5aab9b9dc2109be565005d77cbfed962046434b3 100644 (file)
@@ -595,11 +595,6 @@ static int cirrusfb_check_var(struct fb_var_screeninfo *var,
                return -EINVAL;
        }
 
-       if (var->xoffset < 0)
-               var->xoffset = 0;
-       if (var->yoffset < 0)
-               var->yoffset = 0;
-
        /* truncate xoffset and yoffset to maximum if too high */
        if (var->xoffset > var->xres_virtual - var->xres)
                var->xoffset = var->xres_virtual - var->xres - 1;
@@ -2159,7 +2154,6 @@ static int cirrusfb_pci_register(struct pci_dev *pdev,
        if (!ret)
                return 0;
 
-       pci_set_drvdata(pdev, NULL);
        iounmap(info->screen_base);
 err_release_legacy:
        if (release_io_ports)
index a9031498e10c9f38b45b39bdfa848a528bd58128..a7b0ab62b97b40b2e76891a0993ba39a6c85c546 100644 (file)
@@ -395,19 +395,7 @@ static struct platform_driver cobalt_lcdfb_driver = {
                .owner  = THIS_MODULE,
        },
 };
-
-static int __init cobalt_lcdfb_init(void)
-{
-       return platform_driver_register(&cobalt_lcdfb_driver);
-}
-
-static void __exit cobalt_lcdfb_exit(void)
-{
-       platform_driver_unregister(&cobalt_lcdfb_driver);
-}
-
-module_init(cobalt_lcdfb_init);
-module_exit(cobalt_lcdfb_exit);
+module_platform_driver(cobalt_lcdfb_driver);
 
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Yoichi Yuasa");
index 57886787ead020687d1f05d40230d62c1db096fa..c824b4223b8302f9e98311fa4584d5f7fcf49a4a 100644 (file)
@@ -1871,11 +1871,6 @@ static void cyberpro_pci_remove(struct pci_dev *dev)
                iounmap(cfb->region);
                cyberpro_free_fb_info(cfb);
 
-               /*
-                * Ensure that the driver data is no longer
-                * valid.
-                */
-               pci_set_drvdata(dev, NULL);
                if (cfb == int_cfb_info)
                        int_cfb_info = NULL;
 
index e030e17a83f296320eadf0013831d4c435344184..90f8a2f04d7aaa10d6a60f000f08c38d9e727227 100644 (file)
@@ -1314,7 +1314,7 @@ static struct fb_ops da8xx_fb_ops = {
 
 static struct fb_videomode *da8xx_fb_get_videomode(struct platform_device *dev)
 {
-       struct da8xx_lcdc_platform_data *fb_pdata = dev->dev.platform_data;
+       struct da8xx_lcdc_platform_data *fb_pdata = dev_get_platdata(&dev->dev);
        struct fb_videomode *lcdc_info;
        int i;
 
@@ -1336,7 +1336,7 @@ static struct fb_videomode *da8xx_fb_get_videomode(struct platform_device *dev)
 static int fb_probe(struct platform_device *device)
 {
        struct da8xx_lcdc_platform_data *fb_pdata =
-                                               device->dev.platform_data;
+                                               dev_get_platdata(&device->dev);
        static struct resource *lcdc_regs;
        struct lcd_ctrl_config *lcd_cfg;
        struct fb_videomode *lcdc_info;
@@ -1548,7 +1548,7 @@ err_pm_runtime_disable:
 }
 
 #ifdef CONFIG_PM
-struct lcdc_context {
+static struct lcdc_context {
        u32 clk_enable;
        u32 ctrl;
        u32 dma_ctrl;
@@ -1663,19 +1663,7 @@ static struct platform_driver da8xx_fb_driver = {
                   .owner = THIS_MODULE,
                   },
 };
-
-static int __init da8xx_fb_init(void)
-{
-       return platform_driver_register(&da8xx_fb_driver);
-}
-
-static void __exit da8xx_fb_cleanup(void)
-{
-       platform_driver_unregister(&da8xx_fb_driver);
-}
-
-module_init(da8xx_fb_init);
-module_exit(da8xx_fb_cleanup);
+module_platform_driver(da8xx_fb_driver);
 
 MODULE_DESCRIPTION("Framebuffer driver for TI da8xx/omap-l1xx");
 MODULE_AUTHOR("Texas Instruments");
index 28a837dfddd1cde2974ced029ebd4900de6204b3..35a0f533f1a2c6c73f9e29eb275b7f9ae18ba25d 100644 (file)
@@ -487,7 +487,7 @@ static void ep93xxfb_dealloc_videomem(struct fb_info *info)
 
 static int ep93xxfb_probe(struct platform_device *pdev)
 {
-       struct ep93xxfb_mach_info *mach_info = pdev->dev.platform_data;
+       struct ep93xxfb_mach_info *mach_info = dev_get_platdata(&pdev->dev);
        struct fb_info *info;
        struct ep93xx_fbi *fbi;
        struct resource *res;
index 6d2744794dd13f779ab6c6b2a6f02595c2017451..4c4ffa61ae264b6b39353b35aeb9666bfa8bdfef 100644 (file)
@@ -1035,8 +1035,6 @@ static int ffb_remove(struct platform_device *op)
 
        framebuffer_release(info);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index ebbaada7b94154c88650575f2f63253da096a387..7551a04f5c317e0147ead120b8ba0099500eb2cc 100644 (file)
@@ -399,7 +399,6 @@ static void gx1fb_remove(struct pci_dev *pdev)
        release_mem_region(gx1_gx_base() + 0x8300, 0x100);
 
        fb_dealloc_cmap(&info->cmap);
-       pci_set_drvdata(pdev, NULL);
 
        framebuffer_release(info);
 }
index 19f0c1add747fa23b8db96160b7ec1765fa75a01..a42d74d6edede2e299d86709d8b0ce8f5d3c62d8 100644 (file)
@@ -471,7 +471,6 @@ static void gxfb_remove(struct pci_dev *pdev)
        pci_release_region(pdev, 1);
 
        fb_dealloc_cmap(&info->cmap);
-       pci_set_drvdata(pdev, NULL);
 
        framebuffer_release(info);
 }
index 4dd7b5566962b59be9061480f80e373bd1bd7233..10de31b21d0a7285944d98d62d44fc90f2a50ad9 100644 (file)
@@ -606,7 +606,6 @@ static void lxfb_remove(struct pci_dev *pdev)
        pci_release_region(pdev, 3);
 
        fb_dealloc_cmap(&info->cmap);
-       pci_set_drvdata(pdev, NULL);
        framebuffer_release(info);
 }
 
index 861109e7de1b574d6d9880ee5b845346299de7a2..c078701f15f6fcfc00a214986233bb3e54ce5aa5 100644 (file)
@@ -496,7 +496,6 @@ static int grvga_probe(struct platform_device *dev)
        return 0;
 
 free_mem:
-       dev_set_drvdata(&dev->dev, NULL);
        if (grvga_fix_addr)
                iounmap((void *)virtual_start);
        else
@@ -530,7 +529,6 @@ static int grvga_remove(struct platform_device *device)
                        kfree((void *)info->screen_base);
 
                framebuffer_release(info);
-               dev_set_drvdata(&device->dev, NULL);
        }
 
        return 0;
@@ -557,19 +555,7 @@ static struct platform_driver grvga_driver = {
        .remove         = grvga_remove,
 };
 
-
-static int __init grvga_init(void)
-{
-       return platform_driver_register(&grvga_driver);
-}
-
-static void __exit grvga_exit(void)
-{
-       platform_driver_unregister(&grvga_driver);
-}
-
-module_init(grvga_init);
-module_exit(grvga_exit);
+module_platform_driver(grvga_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Aeroflex Gaisler");
index 59d23181fdb0f768c927fb38d7a60a257471331e..702b599dc3d61e4ec4debfdcf22adbcd4484dd58 100644 (file)
@@ -305,19 +305,7 @@ static struct platform_driver hecubafb_driver = {
                .name   = "hecubafb",
        },
 };
-
-static int __init hecubafb_init(void)
-{
-       return platform_driver_register(&hecubafb_driver);
-}
-
-static void __exit hecubafb_exit(void)
-{
-       platform_driver_unregister(&hecubafb_driver);
-}
-
-module_init(hecubafb_init);
-module_exit(hecubafb_exit);
+module_platform_driver(hecubafb_driver);
 
 MODULE_DESCRIPTION("fbdev driver for Hecuba/Apollo controller");
 MODULE_AUTHOR("Jaya Kumar");
index 8ac99b87c07e07b9737934fcb380e6ab3f7855f7..130708f96430e2806fa0c4eed32264cd61309995 100644 (file)
@@ -575,6 +575,10 @@ static int hvfb_setcolreg(unsigned regno, unsigned red, unsigned green,
        return 0;
 }
 
+static int hvfb_blank(int blank, struct fb_info *info)
+{
+       return 1;       /* get fb_blank to set the colormap to all black */
+}
 
 static struct fb_ops hvfb_ops = {
        .owner = THIS_MODULE,
@@ -584,6 +588,7 @@ static struct fb_ops hvfb_ops = {
        .fb_fillrect = cfb_fillrect,
        .fb_copyarea = cfb_copyarea,
        .fb_imageblit = cfb_imageblit,
+       .fb_blank = hvfb_blank,
 };
 
 
@@ -795,12 +800,21 @@ static int hvfb_remove(struct hv_device *hdev)
 }
 
 
+static DEFINE_PCI_DEVICE_TABLE(pci_stub_id_table) = {
+       {
+               .vendor      = PCI_VENDOR_ID_MICROSOFT,
+               .device      = PCI_DEVICE_ID_HYPERV_VIDEO,
+       },
+       { /* end of list */ }
+};
+
 static const struct hv_vmbus_device_id id_table[] = {
        /* Synthetic Video Device GUID */
        {HV_SYNTHVID_GUID},
        {}
 };
 
+MODULE_DEVICE_TABLE(pci, pci_stub_id_table);
 MODULE_DEVICE_TABLE(vmbus, id_table);
 
 static struct hv_driver hvfb_drv = {
@@ -810,14 +824,43 @@ static struct hv_driver hvfb_drv = {
        .remove = hvfb_remove,
 };
 
+static int hvfb_pci_stub_probe(struct pci_dev *pdev,
+                              const struct pci_device_id *ent)
+{
+       return 0;
+}
+
+static void hvfb_pci_stub_remove(struct pci_dev *pdev)
+{
+}
+
+static struct pci_driver hvfb_pci_stub_driver = {
+       .name =         KBUILD_MODNAME,
+       .id_table =     pci_stub_id_table,
+       .probe =        hvfb_pci_stub_probe,
+       .remove =       hvfb_pci_stub_remove,
+};
 
 static int __init hvfb_drv_init(void)
 {
-       return vmbus_driver_register(&hvfb_drv);
+       int ret;
+
+       ret = vmbus_driver_register(&hvfb_drv);
+       if (ret != 0)
+               return ret;
+
+       ret = pci_register_driver(&hvfb_pci_stub_driver);
+       if (ret != 0) {
+               vmbus_driver_unregister(&hvfb_drv);
+               return ret;
+       }
+
+       return 0;
 }
 
 static void __exit hvfb_drv_exit(void)
 {
+       pci_unregister_driver(&hvfb_pci_stub_driver);
        vmbus_driver_unregister(&hvfb_drv);
 }
 
index 6c48388189505f4b92fa4746252700e15c1d9235..6501ac1dba0f9fae54ca95984580ba46a8b2e1b6 100644 (file)
@@ -1194,7 +1194,6 @@ static void i740fb_remove(struct pci_dev *dev)
                pci_iounmap(dev, info->screen_base);
                pci_release_regions(dev);
 /*             pci_disable_device(dev); */
-               pci_set_drvdata(dev, NULL);
                framebuffer_release(info);
        }
 }
index 4ce3438ade6f31fc8bac432a468f719d777e7cea..038192ac73694aa8a367b7d5d536c7be9f7c9b57 100644 (file)
@@ -2129,7 +2129,6 @@ static void __exit i810fb_remove_pci(struct pci_dev *dev)
 
        unregister_framebuffer(info);  
        i810fb_release_resource(info, par);
-       pci_set_drvdata(dev, NULL);
        printk("cleanup_module:  unloaded i810 framebuffer device\n");
 }                                                      
 
index 38733ac2b6981682cd318f16f17d2784f64d9962..44ee678481d5680571c7d0cb4b990b128e7c052b 100644 (file)
@@ -755,7 +755,7 @@ static int imxfb_resume(struct platform_device *dev)
 
 static int imxfb_init_fbinfo(struct platform_device *pdev)
 {
-       struct imx_fb_platform_data *pdata = pdev->dev.platform_data;
+       struct imx_fb_platform_data *pdata = dev_get_platdata(&pdev->dev);
        struct fb_info *info = dev_get_drvdata(&pdev->dev);
        struct imxfb_info *fbi = info->par;
        struct device_node *np;
@@ -877,7 +877,7 @@ static int imxfb_probe(struct platform_device *pdev)
        if (!res)
                return -ENODEV;
 
-       pdata = pdev->dev.platform_data;
+       pdata = dev_get_platdata(&pdev->dev);
 
        info = framebuffer_alloc(sizeof(struct imxfb_info), &pdev->dev);
        if (!info)
@@ -1066,7 +1066,7 @@ static int imxfb_remove(struct platform_device *pdev)
 #endif
        unregister_framebuffer(info);
 
-       pdata = pdev->dev.platform_data;
+       pdata = dev_get_platdata(&pdev->dev);
        if (pdata && pdata->exit)
                pdata->exit(fbi->pdev);
 
index 8209e46c5d2875e9cda0de1bb3942212d0b211f9..b847d530471a2f6a421ec3c8ff08822ea95ecbef 100644 (file)
@@ -931,8 +931,6 @@ static void intelfb_pci_unregister(struct pci_dev *pdev)
                return;
 
        cleanup(dinfo);
-
-       pci_set_drvdata(pdev, NULL);
 }
 
 /***************************************************************
index 2c49112fdd6c4166bd040c0bbb6a89e0fcc06fec..87790e9644d08499bf964dc601fce9dae16e27a2 100644 (file)
@@ -99,9 +99,9 @@
 #define JZ_LCD_CTRL_BPP_15_16          0x4
 #define JZ_LCD_CTRL_BPP_18_24          0x5
 
-#define JZ_LCD_CMD_SOF_IRQ BIT(15)
-#define JZ_LCD_CMD_EOF_IRQ BIT(16)
-#define JZ_LCD_CMD_ENABLE_PAL BIT(12)
+#define JZ_LCD_CMD_SOF_IRQ BIT(31)
+#define JZ_LCD_CMD_EOF_IRQ BIT(30)
+#define JZ_LCD_CMD_ENABLE_PAL BIT(28)
 
 #define JZ_LCD_SYNC_MASK 0x3ff
 
@@ -471,7 +471,7 @@ static int jzfb_set_par(struct fb_info *info)
        writel(ctrl, jzfb->base + JZ_REG_LCD_CTRL);
 
        if (!jzfb->is_enabled)
-               clk_disable(jzfb->ldclk);
+               clk_disable_unprepare(jzfb->ldclk);
 
        mutex_unlock(&jzfb->lock);
 
@@ -485,7 +485,7 @@ static void jzfb_enable(struct jzfb *jzfb)
 {
        uint32_t ctrl;
 
-       clk_enable(jzfb->ldclk);
+       clk_prepare_enable(jzfb->ldclk);
 
        jz_gpio_bulk_resume(jz_lcd_ctrl_pins, jzfb_num_ctrl_pins(jzfb));
        jz_gpio_bulk_resume(jz_lcd_data_pins, jzfb_num_data_pins(jzfb));
@@ -514,7 +514,7 @@ static void jzfb_disable(struct jzfb *jzfb)
        jz_gpio_bulk_suspend(jz_lcd_ctrl_pins, jzfb_num_ctrl_pins(jzfb));
        jz_gpio_bulk_suspend(jz_lcd_data_pins, jzfb_num_data_pins(jzfb));
 
-       clk_disable(jzfb->ldclk);
+       clk_disable_unprepare(jzfb->ldclk);
 }
 
 static int jzfb_blank(int blank_mode, struct fb_info *info)
@@ -693,7 +693,7 @@ static int jzfb_probe(struct platform_device *pdev)
 
        fb_alloc_cmap(&fb->cmap, 256, 0);
 
-       clk_enable(jzfb->ldclk);
+       clk_prepare_enable(jzfb->ldclk);
        jzfb->is_enabled = 1;
 
        writel(jzfb->framedesc->next, jzfb->base + JZ_REG_LCD_DA0);
@@ -763,7 +763,7 @@ static int jzfb_suspend(struct device *dev)
 static int jzfb_resume(struct device *dev)
 {
        struct jzfb *jzfb = dev_get_drvdata(dev);
-       clk_enable(jzfb->ldclk);
+       clk_prepare_enable(jzfb->ldclk);
 
        mutex_lock(&jzfb->lock);
        if (jzfb->is_enabled)
@@ -798,18 +798,7 @@ static struct platform_driver jzfb_driver = {
                .pm = JZFB_PM_OPS,
        },
 };
-
-static int __init jzfb_init(void)
-{
-       return platform_driver_register(&jzfb_driver);
-}
-module_init(jzfb_init);
-
-static void __exit jzfb_exit(void)
-{
-       platform_driver_unregister(&jzfb_driver);
-}
-module_exit(jzfb_exit);
+module_platform_driver(jzfb_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
index 6157f74ac600529d66f8d71fa8f6d3d5d95a5e5a..79bfb5c3840974946657730dc05d054fe4f11b6c 100644 (file)
@@ -623,7 +623,6 @@ static int kyrofb_ioctl(struct fb_info *info,
                                "command instead.\n");
                        return -EINVAL;
                }
-               break;
        case KYRO_IOCTL_UVSTRIDE:
                if (copy_to_user(argp, &deviceInfo.ulOverlayUVStride, sizeof(unsigned long)))
                        return -EFAULT;
@@ -779,7 +778,6 @@ static void kyrofb_remove(struct pci_dev *pdev)
 #endif
 
        unregister_framebuffer(info);
-       pci_set_drvdata(pdev, NULL);
        framebuffer_release(info);
 }
 
index b17f5009a4363dab5546c57891c4d2564814737c..c0f61aa37696fde9029ac1e6e3d14460b3e9709b 100644 (file)
@@ -648,8 +648,6 @@ static int leo_remove(struct platform_device *op)
 
        framebuffer_release(info);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index fd2897455696b95092841ac51e3f41066d645b04..ee41a0f276b2eae5fb65b530581438a711963a52 100644 (file)
@@ -1295,19 +1295,7 @@ static struct i2c_driver maven_driver={
        .id_table       = maven_id,
 };
 
-static int __init matroxfb_maven_init(void)
-{
-       return i2c_add_driver(&maven_driver);
-}
-
-static void __exit matroxfb_maven_exit(void)
-{
-       i2c_del_driver(&maven_driver);
-}
-
+module_i2c_driver(maven_driver);
 MODULE_AUTHOR("(c) 1999-2002 Petr Vandrovec <vandrove@vc.cvut.cz>");
 MODULE_DESCRIPTION("Matrox G200/G400 Matrox MGA-TVO driver");
 MODULE_LICENSE("GPL");
-module_init(matroxfb_maven_init);
-module_exit(matroxfb_maven_exit);
-/* we do not have __setup() yet */
index 91c59c9fb082be72d2862aeb88ab47129902aa57..0cd4c33185112f92919a81ff7fc5b5fd33ad5ead 100644 (file)
@@ -781,7 +781,6 @@ rel_reg:
 irqdisp:
        irq_dispose_mapping(par->irq);
 fbrel:
-       dev_set_drvdata(dev, NULL);
        framebuffer_release(info);
        return ret;
 }
@@ -814,7 +813,6 @@ static int of_platform_mb862xx_remove(struct platform_device *ofdev)
        iounmap(par->mmio_base);
        iounmap(par->fb_base);
 
-       dev_set_drvdata(&ofdev->dev, NULL);
        release_mem_region(par->res->start, res_size);
        framebuffer_release(fbi);
        return 0;
@@ -1157,7 +1155,6 @@ static void mb862xx_pci_remove(struct pci_dev *pdev)
 
        device_remove_file(&pdev->dev, &dev_attr_dispregs);
 
-       pci_set_drvdata(pdev, NULL);
        unregister_framebuffer(fbi);
        fb_dealloc_cmap(&fbi->cmap);
 
index 0c1a874ffd2bfd100be9e8f0b77bd6c0a30e90de..f87c4ef10b78717536f4cf0506f3029b871dab57 100644 (file)
@@ -890,7 +890,7 @@ static int mbxfb_probe(struct platform_device *dev)
 
        dev_dbg(&dev->dev, "mbxfb_probe\n");
 
-       pdata = dev->dev.platform_data;
+       pdata = dev_get_platdata(&dev->dev);
        if (!pdata) {
                dev_err(&dev->dev, "platform data is required\n");
                return -EINVAL;
index f30150d71be90bdd31aadbcd87beded46b8ae101..2d7dd8ea43f6b4a04a2515c606b9b789fbb8e491 100644 (file)
@@ -769,23 +769,11 @@ static struct platform_driver metronomefb_driver = {
                .name   = "metronomefb",
        },
 };
-
-static int __init metronomefb_init(void)
-{
-       return platform_driver_register(&metronomefb_driver);
-}
-
-static void __exit metronomefb_exit(void)
-{
-       platform_driver_unregister(&metronomefb_driver);
-}
+module_platform_driver(metronomefb_driver);
 
 module_param(user_wfm_size, uint, 0);
 MODULE_PARM_DESC(user_wfm_size, "Set custom waveform size");
 
-module_init(metronomefb_init);
-module_exit(metronomefb_exit);
-
 MODULE_DESCRIPTION("fbdev driver for Metronome controller");
 MODULE_AUTHOR("Jaya Kumar");
 MODULE_LICENSE("GPL");
index 4ab95b8daed31fbf191523d862f668697806d502..7ab31eb76a8c3530e119589550afff1fde69e580 100644 (file)
@@ -392,12 +392,29 @@ static int var_update(struct fb_info *info)
        return 0;
 }
 
+static void mmpfb_set_win(struct fb_info *info)
+{
+       struct mmpfb_info *fbi = info->par;
+       struct fb_var_screeninfo *var = &info->var;
+       struct mmp_win win;
+       u32 stride;
+
+       memset(&win, 0, sizeof(win));
+       win.xsrc = win.xdst = fbi->mode.xres;
+       win.ysrc = win.ydst = fbi->mode.yres;
+       win.pix_fmt = fbi->pix_fmt;
+       stride = pixfmt_to_stride(win.pix_fmt);
+       win.pitch[0] = var->xres_virtual * stride;
+       win.pitch[1] = win.pitch[2] =
+               (stride == 1) ? (var->xres_virtual >> 1) : 0;
+       mmp_overlay_set_win(fbi->overlay, &win);
+}
+
 static int mmpfb_set_par(struct fb_info *info)
 {
        struct mmpfb_info *fbi = info->par;
        struct fb_var_screeninfo *var = &info->var;
        struct mmp_addr addr;
-       struct mmp_win win;
        struct mmp_mode mode;
        int ret;
 
@@ -409,11 +426,8 @@ static int mmpfb_set_par(struct fb_info *info)
        fbmode_to_mmpmode(&mode, &fbi->mode, fbi->output_fmt);
        mmp_path_set_mode(fbi->path, &mode);
 
-       memset(&win, 0, sizeof(win));
-       win.xsrc = win.xdst = fbi->mode.xres;
-       win.ysrc = win.ydst = fbi->mode.yres;
-       win.pix_fmt = fbi->pix_fmt;
-       mmp_overlay_set_win(fbi->overlay, &win);
+       /* set window related info */
+       mmpfb_set_win(info);
 
        /* set address always */
        memset(&addr, 0, sizeof(addr));
@@ -427,16 +441,12 @@ static int mmpfb_set_par(struct fb_info *info)
 static void mmpfb_power(struct mmpfb_info *fbi, int power)
 {
        struct mmp_addr addr;
-       struct mmp_win win;
        struct fb_var_screeninfo *var = &fbi->fb_info->var;
 
        /* for power on, always set address/window again */
        if (power) {
-               memset(&win, 0, sizeof(win));
-               win.xsrc = win.xdst = fbi->mode.xres;
-               win.ysrc = win.ydst = fbi->mode.yres;
-               win.pix_fmt = fbi->pix_fmt;
-               mmp_overlay_set_win(fbi->overlay, &win);
+               /* set window related info */
+               mmpfb_set_win(fbi->fb_info);
 
                /* set address always */
                memset(&addr, 0, sizeof(addr));
index 6ac755270ab46d1a3ef830c89338c0daab519664..8621a9f2bdcc63b96da033e29e69da099a74c19c 100644 (file)
@@ -53,15 +53,14 @@ static irqreturn_t ctrl_handle_irq(int irq, void *dev_id)
                tmp = readl_relaxed(ctrl->reg_base + SPU_IRQ_ISR);
                if (tmp & isr)
                        writel_relaxed(~isr, ctrl->reg_base + SPU_IRQ_ISR);
-       } while ((isr = readl(ctrl->reg_base + SPU_IRQ_ISR)) & imask);
+       } while ((isr = readl_relaxed(ctrl->reg_base + SPU_IRQ_ISR)) & imask);
 
        return IRQ_HANDLED;
 }
 
 static u32 fmt_to_reg(struct mmp_overlay *overlay, int pix_fmt)
 {
-       u32 link_config = path_to_path_plat(overlay->path)->link_config;
-       u32 rbswap, uvswap = 0, yuvswap = 0,
+       u32 rbswap = 0, uvswap = 0, yuvswap = 0,
                csc_en = 0, val = 0,
                vid = overlay_is_vid(overlay);
 
@@ -71,27 +70,23 @@ static u32 fmt_to_reg(struct mmp_overlay *overlay, int pix_fmt)
        case PIXFMT_RGB888PACK:
        case PIXFMT_RGB888UNPACK:
        case PIXFMT_RGBA888:
-               rbswap = !(link_config & 0x1);
+               rbswap = 1;
                break;
        case PIXFMT_VYUY:
        case PIXFMT_YVU422P:
        case PIXFMT_YVU420P:
-               rbswap = link_config & 0x1;
                uvswap = 1;
                break;
        case PIXFMT_YUYV:
-               rbswap = link_config & 0x1;
                yuvswap = 1;
                break;
        default:
-               rbswap = link_config & 0x1;
                break;
        }
 
        switch (pix_fmt) {
        case PIXFMT_RGB565:
        case PIXFMT_BGR565:
-               val = 0;
                break;
        case PIXFMT_RGB1555:
        case PIXFMT_BGR1555:
@@ -147,17 +142,27 @@ static void dmafetch_set_fmt(struct mmp_overlay *overlay)
 static void overlay_set_win(struct mmp_overlay *overlay, struct mmp_win *win)
 {
        struct lcd_regs *regs = path_regs(overlay->path);
-       u32 pitch;
 
        /* assert win supported */
        memcpy(&overlay->win, win, sizeof(struct mmp_win));
 
        mutex_lock(&overlay->access_ok);
-       pitch = win->xsrc * pixfmt_to_stride(win->pix_fmt);
-       writel_relaxed(pitch, &regs->g_pitch);
-       writel_relaxed((win->ysrc << 16) | win->xsrc, &regs->g_size);
-       writel_relaxed((win->ydst << 16) | win->xdst, &regs->g_size_z);
-       writel_relaxed(0, &regs->g_start);
+
+       if (overlay_is_vid(overlay)) {
+               writel_relaxed(win->pitch[0], &regs->v_pitch_yc);
+               writel_relaxed(win->pitch[2] << 16 |
+                               win->pitch[1], &regs->v_pitch_uv);
+
+               writel_relaxed((win->ysrc << 16) | win->xsrc, &regs->v_size);
+               writel_relaxed((win->ydst << 16) | win->xdst, &regs->v_size_z);
+               writel_relaxed(win->ypos << 16 | win->xpos, &regs->v_start);
+       } else {
+               writel_relaxed(win->pitch[0], &regs->g_pitch);
+
+               writel_relaxed((win->ysrc << 16) | win->xsrc, &regs->g_size);
+               writel_relaxed((win->ydst << 16) | win->xdst, &regs->g_size_z);
+               writel_relaxed(win->ypos << 16 | win->xpos, &regs->g_start);
+       }
 
        dmafetch_set_fmt(overlay);
        mutex_unlock(&overlay->access_ok);
@@ -239,7 +244,13 @@ static int overlay_set_addr(struct mmp_overlay *overlay, struct mmp_addr *addr)
 
        /* FIXME: assert addr supported */
        memcpy(&overlay->addr, addr, sizeof(struct mmp_addr));
-       writel(addr->phys[0], &regs->g_0);
+
+       if (overlay_is_vid(overlay)) {
+               writel_relaxed(addr->phys[0], &regs->v_y0);
+               writel_relaxed(addr->phys[1], &regs->v_u0);
+               writel_relaxed(addr->phys[2], &regs->v_v0);
+       } else
+               writel_relaxed(addr->phys[0], &regs->g_0);
 
        return overlay->addr.phys[0];
 }
@@ -248,7 +259,8 @@ static void path_set_mode(struct mmp_path *path, struct mmp_mode *mode)
 {
        struct lcd_regs *regs = path_regs(path);
        u32 total_x, total_y, vsync_ctrl, tmp, sclk_src, sclk_div,
-               link_config = path_to_path_plat(path)->link_config;
+               link_config = path_to_path_plat(path)->link_config,
+               dsi_rbswap = path_to_path_plat(path)->link_config;
 
        /* FIXME: assert videomode supported */
        memcpy(&path->mode, mode, sizeof(struct mmp_mode));
@@ -263,6 +275,12 @@ static void path_set_mode(struct mmp_path *path, struct mmp_mode *mode)
        tmp |= CFG_DUMB_ENA(1);
        writel_relaxed(tmp, ctrl_regs(path) + intf_ctrl(path->id));
 
+       /* interface rb_swap setting */
+       tmp = readl_relaxed(ctrl_regs(path) + intf_rbswap_ctrl(path->id)) &
+               (~(CFG_INTFRBSWAP_MASK));
+       tmp |= dsi_rbswap & CFG_INTFRBSWAP_MASK;
+       writel_relaxed(tmp, ctrl_regs(path) + intf_rbswap_ctrl(path->id));
+
        writel_relaxed((mode->yres << 16) | mode->xres, &regs->screen_active);
        writel_relaxed((mode->left_margin << 16) | mode->right_margin,
                &regs->screen_h_porch);
@@ -370,20 +388,12 @@ static void path_set_default(struct mmp_path *path)
         * bus arbiter for faster read if not tv path;
         * 2.enable horizontal smooth filter;
         */
-       if (PATH_PN == path->id) {
-               mask = CFG_GRA_HSMOOTH_MASK | CFG_DMA_HSMOOTH_MASK
-                       | CFG_ARBFAST_ENA(1);
-               tmp = readl_relaxed(ctrl_regs(path) + dma_ctrl(0, path->id));
-               tmp |= mask;
-               writel_relaxed(tmp, ctrl_regs(path) + dma_ctrl(0, path->id));
-       } else if (PATH_TV == path->id) {
-               mask = CFG_GRA_HSMOOTH_MASK | CFG_DMA_HSMOOTH_MASK
-                       | CFG_ARBFAST_ENA(1);
-               tmp = readl_relaxed(ctrl_regs(path) + dma_ctrl(0, path->id));
-               tmp &= ~mask;
-               tmp |= CFG_GRA_HSMOOTH_MASK | CFG_DMA_HSMOOTH_MASK;
-               writel_relaxed(tmp, ctrl_regs(path) + dma_ctrl(0, path->id));
-       }
+       mask = CFG_GRA_HSMOOTH_MASK | CFG_DMA_HSMOOTH_MASK | CFG_ARBFAST_ENA(1);
+       tmp = readl_relaxed(ctrl_regs(path) + dma_ctrl(0, path->id));
+       tmp |= mask;
+       if (PATH_TV == path->id)
+               tmp &= ~CFG_ARBFAST_ENA(1);
+       writel_relaxed(tmp, ctrl_regs(path) + dma_ctrl(0, path->id));
 }
 
 static int path_init(struct mmphw_path_plat *path_plat,
@@ -419,6 +429,7 @@ static int path_init(struct mmphw_path_plat *path_plat,
        path_plat->path = path;
        path_plat->path_config = config->path_config;
        path_plat->link_config = config->link_config;
+       path_plat->dsi_rbswap = config->dsi_rbswap;
        path_set_default(path);
 
        kfree(path_info);
index edd2002b0e9909de1bac54ecb8736340f97adcce..53301cfdb1aeb62e3100feb6a21787d4641de241 100644 (file)
@@ -163,6 +163,8 @@ struct lcd_regs {
 
 #define LCD_SCLK(path) ((PATH_PN == path->id) ? LCD_CFG_SCLK_DIV :\
        ((PATH_TV == path->id) ? LCD_TCLK_DIV : LCD_PN2_SCLK_DIV))
+#define intf_rbswap_ctrl(id)   ((id) ? (((id) & 1) ? LCD_TVIF_CTRL : \
+                               PN2_IOPAD_CONTROL) : LCD_TOP_CTRL)
 
 /* dither configure */
 #ifdef CONFIG_CPU_PXA988
@@ -615,6 +617,8 @@ struct lcd_regs {
 #define LCD_SPU_DUMB_CTRL                      0x01B8
 #define         CFG_DUMBMODE(mode)                     ((mode)<<28)
 #define         CFG_DUMBMODE_MASK                      0xF0000000
+#define         CFG_INTFRBSWAP(mode)                   ((mode)<<24)
+#define         CFG_INTFRBSWAP_MASK                    0x0F000000
 #define         CFG_LCDGPIO_O(data)                    ((data)<<20)
 #define         CFG_LCDGPIO_O_MASK                     0x0FF00000
 #define         CFG_LCDGPIO_ENA(gpio)                  ((gpio)<<12)
@@ -1427,6 +1431,7 @@ struct mmphw_path_plat {
        struct mmp_path *path;
        u32 path_config;
        u32 link_config;
+       u32 dsi_rbswap;
 };
 
 /* mmp ctrl describes mmp controller related info */
index cfdb380ec81ea9943c98a26411c18bfe4c0d3c18..804f874d32d38e0fc3546f28683935a2328f03ba 100644 (file)
@@ -1354,7 +1354,7 @@ static struct fb_info *mx3fb_init_fbinfo(struct device *dev, struct fb_ops *ops)
 static int init_fb_chan(struct mx3fb_data *mx3fb, struct idmac_channel *ichan)
 {
        struct device *dev = mx3fb->dev;
-       struct mx3fb_platform_data *mx3fb_pdata = dev->platform_data;
+       struct mx3fb_platform_data *mx3fb_pdata = dev_get_platdata(dev);
        const char *name = mx3fb_pdata->name;
        unsigned int irq;
        struct fb_info *fbi;
@@ -1462,7 +1462,7 @@ static bool chan_filter(struct dma_chan *chan, void *arg)
                return false;
 
        dev = rq->mx3fb->dev;
-       mx3fb_pdata = dev->platform_data;
+       mx3fb_pdata = dev_get_platdata(dev);
 
        return rq->id == chan->chan_id &&
                mx3fb_pdata->dma_dev == chan->device->dev;
index c172a5281f9e6c9369b0cec236e3bbf2abb875ac..2a3e5bd17d48f1d4dc66cb71373a5f4c363c0e45 100644 (file)
@@ -2148,12 +2148,6 @@ static void neofb_remove(struct pci_dev *dev)
                fb_destroy_modedb(info->monspecs.modedb);
                neo_unmap_mmio(info);
                neo_free_fb_info(info);
-
-               /*
-                * Ensure that the driver data is no longer
-                * valid.
-                */
-               pci_set_drvdata(dev, NULL);
        }
 }
 
index 796e5112ceeeb1f139bf947197e96ea2af42ee60..ec32f675466dbb0b18f92dd5922f270a303d7bc9 100644 (file)
@@ -91,7 +91,7 @@ static int nuc900fb_check_var(struct fb_var_screeninfo *var,
                               struct fb_info *info)
 {
        struct nuc900fb_info *fbi = info->par;
-       struct nuc900fb_mach_info *mach_info = fbi->dev->platform_data;
+       struct nuc900fb_mach_info *mach_info = dev_get_platdata(fbi->dev);
        struct nuc900fb_display *display = NULL;
        struct nuc900fb_display *default_display = mach_info->displays +
                                                   mach_info->default_display;
@@ -358,7 +358,7 @@ static inline void modify_gpio(void __iomem *reg,
 static int nuc900fb_init_registers(struct fb_info *info)
 {
        struct nuc900fb_info *fbi = info->par;
-       struct nuc900fb_mach_info *mach_info = fbi->dev->platform_data;
+       struct nuc900fb_mach_info *mach_info = dev_get_platdata(fbi->dev);
        void __iomem *regs = fbi->io;
 
        /*reset the display engine*/
@@ -512,7 +512,7 @@ static int nuc900fb_probe(struct platform_device *pdev)
        int size;
 
        dev_dbg(&pdev->dev, "devinit\n");
-       mach_info = pdev->dev.platform_data;
+       mach_info = dev_get_platdata(&pdev->dev);
        if (mach_info == NULL) {
                dev_err(&pdev->dev,
                        "no platform data for lcd, cannot attach\n");
index f349ee6f0ceafd6ee490835e2931f973f5e4c020..a4ee65b8f9187f8788aec8ae9a92e0169319c38c 100644 (file)
@@ -947,7 +947,7 @@ static int hwa742_init(struct omapfb_device *fbdev, int ext_mode,
        hwa742.extif = fbdev->ext_if;
        hwa742.int_ctrl = fbdev->int_ctrl;
 
-       omapfb_conf = fbdev->dev->platform_data;
+       omapfb_conf = dev_get_platdata(fbdev->dev);
 
        hwa742.sys_ck = clk_get(NULL, "hwa_sys_ck");
 
index d40612c31a989d9437e482496ff52c6f451404d8..e4fc6d9b53718a5b449d7409770b4dce9cf937b2 100644 (file)
@@ -1602,7 +1602,7 @@ static int omapfb_find_ctrl(struct omapfb_device *fbdev)
        char name[17];
        int i;
 
-       conf = fbdev->dev->platform_data;
+       conf = dev_get_platdata(fbdev->dev);
 
        fbdev->ctrl = NULL;
 
@@ -1674,7 +1674,7 @@ static int omapfb_do_probe(struct platform_device *pdev,
                goto cleanup;
        }
 
-       if (pdev->dev.platform_data == NULL) {
+       if (dev_get_platdata(&pdev->dev) == NULL) {
                dev_err(&pdev->dev, "missing platform data\n");
                r = -ENOENT;
                goto cleanup;
index 94832eb06a3dbc35ddfec575d6b1e77eae6d34bf..d3aa91bdd6a8a35b95a840f818d95a5717f9e25d 100644 (file)
@@ -10,5 +10,6 @@ omapdss-$(CONFIG_OMAP2_DSS_RFBI) += rfbi.o
 omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
 omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
 omapdss-$(CONFIG_OMAP2_DSS_DSI) += dsi.o
-omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi.o ti_hdmi_4xxx_ip.o
+omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi4.o hdmi_common.o hdmi_wp.o hdmi_pll.o \
+       hdmi_phy.o hdmi4_core.o
 ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
index 60d3958d04f7b0274b5198907bd0277d9de94e71..ffa45c894cd433820191c74c08b4c2d1b96bffcd 100644 (file)
@@ -266,7 +266,7 @@ static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
        venc_init_platform_driver,
 #endif
 #ifdef CONFIG_OMAP4_DSS_HDMI
-       hdmi_init_platform_driver,
+       hdmi4_init_platform_driver,
 #endif
 };
 
@@ -287,7 +287,7 @@ static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = {
        venc_uninit_platform_driver,
 #endif
 #ifdef CONFIG_OMAP4_DSS_HDMI
-       hdmi_uninit_platform_driver,
+       hdmi4_uninit_platform_driver,
 #endif
 };
 
index 477975009eee87e89c34cc773e2d5a8818f918d6..df4639c4d514c429fd9fb4a838293000a74865e4 100644 (file)
@@ -2352,7 +2352,7 @@ int dispc_ovl_check(enum omap_plane plane, enum omap_channel channel,
 {
        enum omap_overlay_caps caps = dss_feat_get_overlay_caps(plane);
        bool five_taps = true;
-       bool fieldmode = 0;
+       bool fieldmode = false;
        u16 in_height = oi->height;
        u16 in_width = oi->width;
        bool ilace = timings->interlace;
@@ -2365,7 +2365,7 @@ int dispc_ovl_check(enum omap_plane plane, enum omap_channel channel,
        out_height = oi->out_height == 0 ? oi->height : oi->out_height;
 
        if (ilace && oi->height == out_height)
-               fieldmode = 1;
+               fieldmode = true;
 
        if (ilace) {
                if (fieldmode)
@@ -2396,7 +2396,7 @@ static int dispc_ovl_setup_common(enum omap_plane plane,
                bool mem_to_mem)
 {
        bool five_taps = true;
-       bool fieldmode = 0;
+       bool fieldmode = false;
        int r, cconv = 0;
        unsigned offset0, offset1;
        s32 row_inc;
@@ -2417,7 +2417,7 @@ static int dispc_ovl_setup_common(enum omap_plane plane,
        out_height = out_height == 0 ? height : out_height;
 
        if (ilace && height == out_height)
-               fieldmode = 1;
+               fieldmode = true;
 
        if (ilace) {
                if (fieldmode)
index e172531d196bd2f09320af18797560f3bf606d4e..f538e867c0f8c707c596e8a014ff4688ca67b930 100644 (file)
@@ -427,8 +427,8 @@ int venc_init_platform_driver(void) __init;
 void venc_uninit_platform_driver(void) __exit;
 
 /* HDMI */
-int hdmi_init_platform_driver(void) __init;
-void hdmi_uninit_platform_driver(void) __exit;
+int hdmi4_init_platform_driver(void) __init;
+void hdmi4_uninit_platform_driver(void) __exit;
 
 /* RFBI */
 int rfbi_init_platform_driver(void) __init;
index b9cfebb378a27a9fe66c20f00c42ffd425fe5438..f8fd6dbacabcb2092521a1bf81c9d5fc361fb7e7 100644 (file)
@@ -789,50 +789,6 @@ static const struct omap_dss_features omap5_dss_features = {
        .burst_size_unit = 16,
 };
 
-#if defined(CONFIG_OMAP4_DSS_HDMI)
-/* HDMI OMAP4 Functions*/
-static const struct ti_hdmi_ip_ops omap4_hdmi_functions = {
-
-       .video_configure        =       ti_hdmi_4xxx_basic_configure,
-       .phy_enable             =       ti_hdmi_4xxx_phy_enable,
-       .phy_disable            =       ti_hdmi_4xxx_phy_disable,
-       .read_edid              =       ti_hdmi_4xxx_read_edid,
-       .pll_enable             =       ti_hdmi_4xxx_pll_enable,
-       .pll_disable            =       ti_hdmi_4xxx_pll_disable,
-       .video_enable           =       ti_hdmi_4xxx_wp_video_start,
-       .video_disable          =       ti_hdmi_4xxx_wp_video_stop,
-       .dump_wrapper           =       ti_hdmi_4xxx_wp_dump,
-       .dump_core              =       ti_hdmi_4xxx_core_dump,
-       .dump_pll               =       ti_hdmi_4xxx_pll_dump,
-       .dump_phy               =       ti_hdmi_4xxx_phy_dump,
-#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
-       .audio_enable           =       ti_hdmi_4xxx_wp_audio_enable,
-       .audio_disable          =       ti_hdmi_4xxx_wp_audio_disable,
-       .audio_start            =       ti_hdmi_4xxx_audio_start,
-       .audio_stop             =       ti_hdmi_4xxx_audio_stop,
-       .audio_config           =       ti_hdmi_4xxx_audio_config,
-       .audio_get_dma_port     =       ti_hdmi_4xxx_audio_get_dma_port,
-#endif
-
-};
-
-void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data,
-               enum omapdss_version version)
-{
-       switch (version) {
-       case OMAPDSS_VER_OMAP4430_ES1:
-       case OMAPDSS_VER_OMAP4430_ES2:
-       case OMAPDSS_VER_OMAP4:
-               ip_data->ops = &omap4_hdmi_functions;
-               break;
-       default:
-               ip_data->ops = NULL;
-       }
-
-       WARN_ON(ip_data->ops == NULL);
-}
-#endif
-
 /* Functions returning values related to a DSS feature */
 int dss_feat_get_num_mgrs(void)
 {
index 489b9bec4a6d5ceebbc0cc01caaf9b96b7583673..10b0556e135200f02a4d6d2fa1c12f801fc97823 100644 (file)
 #ifndef __OMAP2_DSS_FEATURES_H
 #define __OMAP2_DSS_FEATURES_H
 
-#if defined(CONFIG_OMAP4_DSS_HDMI)
-#include "ti_hdmi.h"
-#endif
-
 #define MAX_DSS_MANAGERS       4
 #define MAX_DSS_OVERLAYS       4
 #define MAX_DSS_LCD_MANAGERS   3
@@ -117,8 +113,4 @@ bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type);
 bool dss_has_feature(enum dss_feat_id id);
 void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end);
 void dss_features_init(enum omapdss_version version);
-#if defined(CONFIG_OMAP4_DSS_HDMI)
-void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data,
-               enum omapdss_version version);
-#endif
 #endif
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
deleted file mode 100644 (file)
index 82a9640..0000000
+++ /dev/null
@@ -1,1184 +0,0 @@
-/*
- * hdmi.c
- *
- * HDMI interface DSS driver setting for TI's OMAP4 family of processor.
- * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
- * Authors: Yong Zhi
- *     Mythri pk <mythripk@ti.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that 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, see <http://www.gnu.org/licenses/>.
- */
-
-#define DSS_SUBSYS_NAME "HDMI"
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/io.h>
-#include <linux/interrupt.h>
-#include <linux/mutex.h>
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/platform_device.h>
-#include <linux/pm_runtime.h>
-#include <linux/clk.h>
-#include <linux/gpio.h>
-#include <linux/regulator/consumer.h>
-#include <video/omapdss.h>
-
-#include "ti_hdmi.h"
-#include "dss.h"
-#include "dss_features.h"
-
-#define HDMI_WP                        0x0
-#define HDMI_CORE_SYS          0x400
-#define HDMI_CORE_AV           0x900
-#define HDMI_PLLCTRL           0x200
-#define HDMI_PHY               0x300
-
-/* HDMI EDID Length move this */
-#define HDMI_EDID_MAX_LENGTH                   256
-#define EDID_TIMING_DESCRIPTOR_SIZE            0x12
-#define EDID_DESCRIPTOR_BLOCK0_ADDRESS         0x36
-#define EDID_DESCRIPTOR_BLOCK1_ADDRESS         0x80
-#define EDID_SIZE_BLOCK0_TIMING_DESCRIPTOR     4
-#define EDID_SIZE_BLOCK1_TIMING_DESCRIPTOR     4
-
-#define HDMI_DEFAULT_REGN 16
-#define HDMI_DEFAULT_REGM2 1
-
-static struct {
-       struct mutex lock;
-       struct platform_device *pdev;
-
-       struct hdmi_ip_data ip_data;
-
-       struct clk *sys_clk;
-       struct regulator *vdda_hdmi_dac_reg;
-
-       bool core_enabled;
-
-       struct omap_dss_device output;
-} hdmi;
-
-/*
- * Logic for the below structure :
- * user enters the CEA or VESA timings by specifying the HDMI/DVI code.
- * There is a correspondence between CEA/VESA timing and code, please
- * refer to section 6.3 in HDMI 1.3 specification for timing code.
- *
- * In the below structure, cea_vesa_timings corresponds to all OMAP4
- * supported CEA and VESA timing values.code_cea corresponds to the CEA
- * code, It is used to get the timing from cea_vesa_timing array.Similarly
- * with code_vesa. Code_index is used for back mapping, that is once EDID
- * is read from the TV, EDID is parsed to find the timing values and then
- * map it to corresponding CEA or VESA index.
- */
-
-static const struct hdmi_config cea_timings[] = {
-       {
-               { 640, 480, 25200, 96, 16, 48, 2, 10, 33,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 1, HDMI_HDMI },
-       },
-       {
-               { 720, 480, 27027, 62, 16, 60, 6, 9, 30,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 2, HDMI_HDMI },
-       },
-       {
-               { 1280, 720, 74250, 40, 110, 220, 5, 5, 20,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 4, HDMI_HDMI },
-       },
-       {
-               { 1920, 540, 74250, 44, 88, 148, 5, 2, 15,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       true, },
-               { 5, HDMI_HDMI },
-       },
-       {
-               { 1440, 240, 27027, 124, 38, 114, 3, 4, 15,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       true, },
-               { 6, HDMI_HDMI },
-       },
-       {
-               { 1920, 1080, 148500, 44, 88, 148, 5, 4, 36,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 16, HDMI_HDMI },
-       },
-       {
-               { 720, 576, 27000, 64, 12, 68, 5, 5, 39,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 17, HDMI_HDMI },
-       },
-       {
-               { 1280, 720, 74250, 40, 440, 220, 5, 5, 20,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 19, HDMI_HDMI },
-       },
-       {
-               { 1920, 540, 74250, 44, 528, 148, 5, 2, 15,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       true, },
-               { 20, HDMI_HDMI },
-       },
-       {
-               { 1440, 288, 27000, 126, 24, 138, 3, 2, 19,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       true, },
-               { 21, HDMI_HDMI },
-       },
-       {
-               { 1440, 576, 54000, 128, 24, 136, 5, 5, 39,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 29, HDMI_HDMI },
-       },
-       {
-               { 1920, 1080, 148500, 44, 528, 148, 5, 4, 36,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 31, HDMI_HDMI },
-       },
-       {
-               { 1920, 1080, 74250, 44, 638, 148, 5, 4, 36,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 32, HDMI_HDMI },
-       },
-       {
-               { 2880, 480, 108108, 248, 64, 240, 6, 9, 30,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 35, HDMI_HDMI },
-       },
-       {
-               { 2880, 576, 108000, 256, 48, 272, 5, 5, 39,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 37, HDMI_HDMI },
-       },
-};
-
-static const struct hdmi_config vesa_timings[] = {
-/* VESA From Here */
-       {
-               { 640, 480, 25175, 96, 16, 48, 2, 11, 31,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 4, HDMI_DVI },
-       },
-       {
-               { 800, 600, 40000, 128, 40, 88, 4, 1, 23,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 9, HDMI_DVI },
-       },
-       {
-               { 848, 480, 33750, 112, 16, 112, 8, 6, 23,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0xE, HDMI_DVI },
-       },
-       {
-               { 1280, 768, 79500, 128, 64, 192, 7, 3, 20,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 0x17, HDMI_DVI },
-       },
-       {
-               { 1280, 800, 83500, 128, 72, 200, 6, 3, 22,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 0x1C, HDMI_DVI },
-       },
-       {
-               { 1360, 768, 85500, 112, 64, 256, 6, 3, 18,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x27, HDMI_DVI },
-       },
-       {
-               { 1280, 960, 108000, 112, 96, 312, 3, 1, 36,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x20, HDMI_DVI },
-       },
-       {
-               { 1280, 1024, 108000, 112, 48, 248, 3, 1, 38,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x23, HDMI_DVI },
-       },
-       {
-               { 1024, 768, 65000, 136, 24, 160, 6, 3, 29,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 0x10, HDMI_DVI },
-       },
-       {
-               { 1400, 1050, 121750, 144, 88, 232, 4, 3, 32,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 0x2A, HDMI_DVI },
-       },
-       {
-               { 1440, 900, 106500, 152, 80, 232, 6, 3, 25,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 0x2F, HDMI_DVI },
-       },
-       {
-               { 1680, 1050, 146250, 176 , 104, 280, 6, 3, 30,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
-                       false, },
-               { 0x3A, HDMI_DVI },
-       },
-       {
-               { 1366, 768, 85500, 143, 70, 213, 3, 3, 24,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x51, HDMI_DVI },
-       },
-       {
-               { 1920, 1080, 148500, 44, 148, 80, 5, 4, 36,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x52, HDMI_DVI },
-       },
-       {
-               { 1280, 768, 68250, 32, 48, 80, 7, 3, 12,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x16, HDMI_DVI },
-       },
-       {
-               { 1400, 1050, 101000, 32, 48, 80, 4, 3, 23,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x29, HDMI_DVI },
-       },
-       {
-               { 1680, 1050, 119000, 32, 48, 80, 6, 3, 21,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x39, HDMI_DVI },
-       },
-       {
-               { 1280, 800, 79500, 32, 48, 80, 6, 3, 14,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x1B, HDMI_DVI },
-       },
-       {
-               { 1280, 720, 74250, 40, 110, 220, 5, 5, 20,
-                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x55, HDMI_DVI },
-       },
-       {
-               { 1920, 1200, 154000, 32, 48, 80, 6, 3, 26,
-                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
-                       false, },
-               { 0x44, HDMI_DVI },
-       },
-};
-
-static int hdmi_runtime_get(void)
-{
-       int r;
-
-       DSSDBG("hdmi_runtime_get\n");
-
-       r = pm_runtime_get_sync(&hdmi.pdev->dev);
-       WARN_ON(r < 0);
-       if (r < 0)
-               return r;
-
-       return 0;
-}
-
-static void hdmi_runtime_put(void)
-{
-       int r;
-
-       DSSDBG("hdmi_runtime_put\n");
-
-       r = pm_runtime_put_sync(&hdmi.pdev->dev);
-       WARN_ON(r < 0 && r != -ENOSYS);
-}
-
-static int hdmi_init_regulator(void)
-{
-       struct regulator *reg;
-
-       if (hdmi.vdda_hdmi_dac_reg != NULL)
-               return 0;
-
-       reg = devm_regulator_get(&hdmi.pdev->dev, "vdda_hdmi_dac");
-
-       /* DT HACK: try VDAC to make omapdss work for o4 sdp/panda */
-       if (IS_ERR(reg))
-               reg = devm_regulator_get(&hdmi.pdev->dev, "VDAC");
-
-       if (IS_ERR(reg)) {
-               DSSERR("can't get VDDA_HDMI_DAC regulator\n");
-               return PTR_ERR(reg);
-       }
-
-       hdmi.vdda_hdmi_dac_reg = reg;
-
-       return 0;
-}
-
-static const struct hdmi_config *hdmi_find_timing(
-                                       const struct hdmi_config *timings_arr,
-                                       int len)
-{
-       int i;
-
-       for (i = 0; i < len; i++) {
-               if (timings_arr[i].cm.code == hdmi.ip_data.cfg.cm.code)
-                       return &timings_arr[i];
-       }
-       return NULL;
-}
-
-static const struct hdmi_config *hdmi_get_timings(void)
-{
-       const struct hdmi_config *arr;
-       int len;
-
-       if (hdmi.ip_data.cfg.cm.mode == HDMI_DVI) {
-               arr = vesa_timings;
-               len = ARRAY_SIZE(vesa_timings);
-       } else {
-               arr = cea_timings;
-               len = ARRAY_SIZE(cea_timings);
-       }
-
-       return hdmi_find_timing(arr, len);
-}
-
-static bool hdmi_timings_compare(struct omap_video_timings *timing1,
-                               const struct omap_video_timings *timing2)
-{
-       int timing1_vsync, timing1_hsync, timing2_vsync, timing2_hsync;
-
-       if ((DIV_ROUND_CLOSEST(timing2->pixel_clock, 1000) ==
-                       DIV_ROUND_CLOSEST(timing1->pixel_clock, 1000)) &&
-               (timing2->x_res == timing1->x_res) &&
-               (timing2->y_res == timing1->y_res)) {
-
-               timing2_hsync = timing2->hfp + timing2->hsw + timing2->hbp;
-               timing1_hsync = timing1->hfp + timing1->hsw + timing1->hbp;
-               timing2_vsync = timing2->vfp + timing2->vsw + timing2->vbp;
-               timing1_vsync = timing2->vfp + timing2->vsw + timing2->vbp;
-
-               DSSDBG("timing1_hsync = %d timing1_vsync = %d"\
-                       "timing2_hsync = %d timing2_vsync = %d\n",
-                       timing1_hsync, timing1_vsync,
-                       timing2_hsync, timing2_vsync);
-
-               if ((timing1_hsync == timing2_hsync) &&
-                       (timing1_vsync == timing2_vsync)) {
-                       return true;
-               }
-       }
-       return false;
-}
-
-static struct hdmi_cm hdmi_get_code(struct omap_video_timings *timing)
-{
-       int i;
-       struct hdmi_cm cm = {-1};
-       DSSDBG("hdmi_get_code\n");
-
-       for (i = 0; i < ARRAY_SIZE(cea_timings); i++) {
-               if (hdmi_timings_compare(timing, &cea_timings[i].timings)) {
-                       cm = cea_timings[i].cm;
-                       goto end;
-               }
-       }
-       for (i = 0; i < ARRAY_SIZE(vesa_timings); i++) {
-               if (hdmi_timings_compare(timing, &vesa_timings[i].timings)) {
-                       cm = vesa_timings[i].cm;
-                       goto end;
-               }
-       }
-
-end:   return cm;
-
-}
-
-static void hdmi_compute_pll(struct omap_dss_device *dssdev, int phy,
-               struct hdmi_pll_info *pi)
-{
-       unsigned long clkin, refclk;
-       u32 mf;
-
-       clkin = clk_get_rate(hdmi.sys_clk) / 10000;
-       /*
-        * Input clock is predivided by N + 1
-        * out put of which is reference clk
-        */
-
-       pi->regn = HDMI_DEFAULT_REGN;
-
-       refclk = clkin / pi->regn;
-
-       pi->regm2 = HDMI_DEFAULT_REGM2;
-
-       /*
-        * multiplier is pixel_clk/ref_clk
-        * Multiplying by 100 to avoid fractional part removal
-        */
-       pi->regm = phy * pi->regm2 / refclk;
-
-       /*
-        * fractional multiplier is remainder of the difference between
-        * multiplier and actual phy(required pixel clock thus should be
-        * multiplied by 2^18(262144) divided by the reference clock
-        */
-       mf = (phy - pi->regm / pi->regm2 * refclk) * 262144;
-       pi->regmf = pi->regm2 * mf / refclk;
-
-       /*
-        * Dcofreq should be set to 1 if required pixel clock
-        * is greater than 1000MHz
-        */
-       pi->dcofreq = phy > 1000 * 100;
-       pi->regsd = ((pi->regm * clkin / 10) / (pi->regn * 250) + 5) / 10;
-
-       /* Set the reference clock to sysclk reference */
-       pi->refsel = HDMI_REFSEL_SYSCLK;
-
-       DSSDBG("M = %d Mf = %d\n", pi->regm, pi->regmf);
-       DSSDBG("range = %d sd = %d\n", pi->dcofreq, pi->regsd);
-}
-
-static int hdmi_power_on_core(struct omap_dss_device *dssdev)
-{
-       int r;
-
-       r = regulator_enable(hdmi.vdda_hdmi_dac_reg);
-       if (r)
-               return r;
-
-       r = hdmi_runtime_get();
-       if (r)
-               goto err_runtime_get;
-
-       /* Make selection of HDMI in DSS */
-       dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
-
-       hdmi.core_enabled = true;
-
-       return 0;
-
-err_runtime_get:
-       regulator_disable(hdmi.vdda_hdmi_dac_reg);
-
-       return r;
-}
-
-static void hdmi_power_off_core(struct omap_dss_device *dssdev)
-{
-       hdmi.core_enabled = false;
-
-       hdmi_runtime_put();
-       regulator_disable(hdmi.vdda_hdmi_dac_reg);
-}
-
-static int hdmi_power_on_full(struct omap_dss_device *dssdev)
-{
-       int r;
-       struct omap_video_timings *p;
-       struct omap_overlay_manager *mgr = hdmi.output.manager;
-       unsigned long phy;
-
-       r = hdmi_power_on_core(dssdev);
-       if (r)
-               return r;
-
-       dss_mgr_disable(mgr);
-
-       p = &hdmi.ip_data.cfg.timings;
-
-       DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res);
-
-       phy = p->pixel_clock;
-
-       hdmi_compute_pll(dssdev, phy, &hdmi.ip_data.pll_data);
-
-       hdmi.ip_data.ops->video_disable(&hdmi.ip_data);
-
-       /* config the PLL and PHY hdmi_set_pll_pwrfirst */
-       r = hdmi.ip_data.ops->pll_enable(&hdmi.ip_data);
-       if (r) {
-               DSSDBG("Failed to lock PLL\n");
-               goto err_pll_enable;
-       }
-
-       r = hdmi.ip_data.ops->phy_enable(&hdmi.ip_data);
-       if (r) {
-               DSSDBG("Failed to start PHY\n");
-               goto err_phy_enable;
-       }
-
-       hdmi.ip_data.ops->video_configure(&hdmi.ip_data);
-
-       /* bypass TV gamma table */
-       dispc_enable_gamma_table(0);
-
-       /* tv size */
-       dss_mgr_set_timings(mgr, p);
-
-       r = hdmi.ip_data.ops->video_enable(&hdmi.ip_data);
-       if (r)
-               goto err_vid_enable;
-
-       r = dss_mgr_enable(mgr);
-       if (r)
-               goto err_mgr_enable;
-
-       return 0;
-
-err_mgr_enable:
-       hdmi.ip_data.ops->video_disable(&hdmi.ip_data);
-err_vid_enable:
-       hdmi.ip_data.ops->phy_disable(&hdmi.ip_data);
-err_phy_enable:
-       hdmi.ip_data.ops->pll_disable(&hdmi.ip_data);
-err_pll_enable:
-       hdmi_power_off_core(dssdev);
-       return -EIO;
-}
-
-static void hdmi_power_off_full(struct omap_dss_device *dssdev)
-{
-       struct omap_overlay_manager *mgr = hdmi.output.manager;
-
-       dss_mgr_disable(mgr);
-
-       hdmi.ip_data.ops->video_disable(&hdmi.ip_data);
-       hdmi.ip_data.ops->phy_disable(&hdmi.ip_data);
-       hdmi.ip_data.ops->pll_disable(&hdmi.ip_data);
-
-       hdmi_power_off_core(dssdev);
-}
-
-static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
-                                       struct omap_video_timings *timings)
-{
-       struct hdmi_cm cm;
-
-       cm = hdmi_get_code(timings);
-       if (cm.code == -1) {
-               return -EINVAL;
-       }
-
-       return 0;
-
-}
-
-static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
-               struct omap_video_timings *timings)
-{
-       struct hdmi_cm cm;
-       const struct hdmi_config *t;
-
-       mutex_lock(&hdmi.lock);
-
-       cm = hdmi_get_code(timings);
-       hdmi.ip_data.cfg.cm = cm;
-
-       t = hdmi_get_timings();
-       if (t != NULL) {
-               hdmi.ip_data.cfg = *t;
-
-               dispc_set_tv_pclk(t->timings.pixel_clock * 1000);
-       }
-
-       mutex_unlock(&hdmi.lock);
-}
-
-static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
-               struct omap_video_timings *timings)
-{
-       const struct hdmi_config *cfg;
-
-       cfg = hdmi_get_timings();
-       if (cfg == NULL)
-               cfg = &vesa_timings[0];
-
-       memcpy(timings, &cfg->timings, sizeof(cfg->timings));
-}
-
-static void hdmi_dump_regs(struct seq_file *s)
-{
-       mutex_lock(&hdmi.lock);
-
-       if (hdmi_runtime_get()) {
-               mutex_unlock(&hdmi.lock);
-               return;
-       }
-
-       hdmi.ip_data.ops->dump_wrapper(&hdmi.ip_data, s);
-       hdmi.ip_data.ops->dump_pll(&hdmi.ip_data, s);
-       hdmi.ip_data.ops->dump_phy(&hdmi.ip_data, s);
-       hdmi.ip_data.ops->dump_core(&hdmi.ip_data, s);
-
-       hdmi_runtime_put();
-       mutex_unlock(&hdmi.lock);
-}
-
-static int read_edid(u8 *buf, int len)
-{
-       int r;
-
-       mutex_lock(&hdmi.lock);
-
-       r = hdmi_runtime_get();
-       BUG_ON(r);
-
-       r = hdmi.ip_data.ops->read_edid(&hdmi.ip_data, buf, len);
-
-       hdmi_runtime_put();
-       mutex_unlock(&hdmi.lock);
-
-       return r;
-}
-
-static int hdmi_display_enable(struct omap_dss_device *dssdev)
-{
-       struct omap_dss_device *out = &hdmi.output;
-       int r = 0;
-
-       DSSDBG("ENTER hdmi_display_enable\n");
-
-       mutex_lock(&hdmi.lock);
-
-       if (out == NULL || out->manager == NULL) {
-               DSSERR("failed to enable display: no output/manager\n");
-               r = -ENODEV;
-               goto err0;
-       }
-
-       r = hdmi_power_on_full(dssdev);
-       if (r) {
-               DSSERR("failed to power on device\n");
-               goto err0;
-       }
-
-       mutex_unlock(&hdmi.lock);
-       return 0;
-
-err0:
-       mutex_unlock(&hdmi.lock);
-       return r;
-}
-
-static void hdmi_display_disable(struct omap_dss_device *dssdev)
-{
-       DSSDBG("Enter hdmi_display_disable\n");
-
-       mutex_lock(&hdmi.lock);
-
-       hdmi_power_off_full(dssdev);
-
-       mutex_unlock(&hdmi.lock);
-}
-
-static int hdmi_core_enable(struct omap_dss_device *dssdev)
-{
-       int r = 0;
-
-       DSSDBG("ENTER omapdss_hdmi_core_enable\n");
-
-       mutex_lock(&hdmi.lock);
-
-       r = hdmi_power_on_core(dssdev);
-       if (r) {
-               DSSERR("failed to power on device\n");
-               goto err0;
-       }
-
-       mutex_unlock(&hdmi.lock);
-       return 0;
-
-err0:
-       mutex_unlock(&hdmi.lock);
-       return r;
-}
-
-static void hdmi_core_disable(struct omap_dss_device *dssdev)
-{
-       DSSDBG("Enter omapdss_hdmi_core_disable\n");
-
-       mutex_lock(&hdmi.lock);
-
-       hdmi_power_off_core(dssdev);
-
-       mutex_unlock(&hdmi.lock);
-}
-
-static int hdmi_get_clocks(struct platform_device *pdev)
-{
-       struct clk *clk;
-
-       clk = devm_clk_get(&pdev->dev, "sys_clk");
-       if (IS_ERR(clk)) {
-               DSSERR("can't get sys_clk\n");
-               return PTR_ERR(clk);
-       }
-
-       hdmi.sys_clk = clk;
-
-       return 0;
-}
-
-#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
-int hdmi_compute_acr(u32 sample_freq, u32 *n, u32 *cts)
-{
-       u32 deep_color;
-       bool deep_color_correct = false;
-       u32 pclk = hdmi.ip_data.cfg.timings.pixel_clock;
-
-       if (n == NULL || cts == NULL)
-               return -EINVAL;
-
-       /* TODO: When implemented, query deep color mode here. */
-       deep_color = 100;
-
-       /*
-        * When using deep color, the default N value (as in the HDMI
-        * specification) yields to an non-integer CTS. Hence, we
-        * modify it while keeping the restrictions described in
-        * section 7.2.1 of the HDMI 1.4a specification.
-        */
-       switch (sample_freq) {
-       case 32000:
-       case 48000:
-       case 96000:
-       case 192000:
-               if (deep_color == 125)
-                       if (pclk == 27027 || pclk == 74250)
-                               deep_color_correct = true;
-               if (deep_color == 150)
-                       if (pclk == 27027)
-                               deep_color_correct = true;
-               break;
-       case 44100:
-       case 88200:
-       case 176400:
-               if (deep_color == 125)
-                       if (pclk == 27027)
-                               deep_color_correct = true;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       if (deep_color_correct) {
-               switch (sample_freq) {
-               case 32000:
-                       *n = 8192;
-                       break;
-               case 44100:
-                       *n = 12544;
-                       break;
-               case 48000:
-                       *n = 8192;
-                       break;
-               case 88200:
-                       *n = 25088;
-                       break;
-               case 96000:
-                       *n = 16384;
-                       break;
-               case 176400:
-                       *n = 50176;
-                       break;
-               case 192000:
-                       *n = 32768;
-                       break;
-               default:
-                       return -EINVAL;
-               }
-       } else {
-               switch (sample_freq) {
-               case 32000:
-                       *n = 4096;
-                       break;
-               case 44100:
-                       *n = 6272;
-                       break;
-               case 48000:
-                       *n = 6144;
-                       break;
-               case 88200:
-                       *n = 12544;
-                       break;
-               case 96000:
-                       *n = 12288;
-                       break;
-               case 176400:
-                       *n = 25088;
-                       break;
-               case 192000:
-                       *n = 24576;
-                       break;
-               default:
-                       return -EINVAL;
-               }
-       }
-       /* Calculate CTS. See HDMI 1.3a or 1.4a specifications */
-       *cts = pclk * (*n / 128) * deep_color / (sample_freq / 10);
-
-       return 0;
-}
-
-static bool hdmi_mode_has_audio(void)
-{
-       if (hdmi.ip_data.cfg.cm.mode == HDMI_HDMI)
-               return true;
-       else
-               return false;
-}
-
-#endif
-
-static int hdmi_connect(struct omap_dss_device *dssdev,
-               struct omap_dss_device *dst)
-{
-       struct omap_overlay_manager *mgr;
-       int r;
-
-       dss_init_hdmi_ip_ops(&hdmi.ip_data, omapdss_get_version());
-
-       r = hdmi_init_regulator();
-       if (r)
-               return r;
-
-       mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
-       if (!mgr)
-               return -ENODEV;
-
-       r = dss_mgr_connect(mgr, dssdev);
-       if (r)
-               return r;
-
-       r = omapdss_output_set_device(dssdev, dst);
-       if (r) {
-               DSSERR("failed to connect output to new device: %s\n",
-                               dst->name);
-               dss_mgr_disconnect(mgr, dssdev);
-               return r;
-       }
-
-       return 0;
-}
-
-static void hdmi_disconnect(struct omap_dss_device *dssdev,
-               struct omap_dss_device *dst)
-{
-       WARN_ON(dst != dssdev->dst);
-
-       if (dst != dssdev->dst)
-               return;
-
-       omapdss_output_unset_device(dssdev);
-
-       if (dssdev->manager)
-               dss_mgr_disconnect(dssdev->manager, dssdev);
-}
-
-static int hdmi_read_edid(struct omap_dss_device *dssdev,
-               u8 *edid, int len)
-{
-       bool need_enable;
-       int r;
-
-       need_enable = hdmi.core_enabled == false;
-
-       if (need_enable) {
-               r = hdmi_core_enable(dssdev);
-               if (r)
-                       return r;
-       }
-
-       r = read_edid(edid, len);
-
-       if (need_enable)
-               hdmi_core_disable(dssdev);
-
-       return r;
-}
-
-#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
-static int hdmi_audio_enable(struct omap_dss_device *dssdev)
-{
-       int r;
-
-       mutex_lock(&hdmi.lock);
-
-       if (!hdmi_mode_has_audio()) {
-               r = -EPERM;
-               goto err;
-       }
-
-
-       r = hdmi.ip_data.ops->audio_enable(&hdmi.ip_data);
-       if (r)
-               goto err;
-
-       mutex_unlock(&hdmi.lock);
-       return 0;
-
-err:
-       mutex_unlock(&hdmi.lock);
-       return r;
-}
-
-static void hdmi_audio_disable(struct omap_dss_device *dssdev)
-{
-       hdmi.ip_data.ops->audio_disable(&hdmi.ip_data);
-}
-
-static int hdmi_audio_start(struct omap_dss_device *dssdev)
-{
-       return hdmi.ip_data.ops->audio_start(&hdmi.ip_data);
-}
-
-static void hdmi_audio_stop(struct omap_dss_device *dssdev)
-{
-       hdmi.ip_data.ops->audio_stop(&hdmi.ip_data);
-}
-
-static bool hdmi_audio_supported(struct omap_dss_device *dssdev)
-{
-       bool r;
-
-       mutex_lock(&hdmi.lock);
-
-       r = hdmi_mode_has_audio();
-
-       mutex_unlock(&hdmi.lock);
-       return r;
-}
-
-static int hdmi_audio_config(struct omap_dss_device *dssdev,
-               struct omap_dss_audio *audio)
-{
-       int r;
-
-       mutex_lock(&hdmi.lock);
-
-       if (!hdmi_mode_has_audio()) {
-               r = -EPERM;
-               goto err;
-       }
-
-       r = hdmi.ip_data.ops->audio_config(&hdmi.ip_data, audio);
-       if (r)
-               goto err;
-
-       mutex_unlock(&hdmi.lock);
-       return 0;
-
-err:
-       mutex_unlock(&hdmi.lock);
-       return r;
-}
-#else
-static int hdmi_audio_enable(struct omap_dss_device *dssdev)
-{
-       return -EPERM;
-}
-
-static void hdmi_audio_disable(struct omap_dss_device *dssdev)
-{
-}
-
-static int hdmi_audio_start(struct omap_dss_device *dssdev)
-{
-       return -EPERM;
-}
-
-static void hdmi_audio_stop(struct omap_dss_device *dssdev)
-{
-}
-
-static bool hdmi_audio_supported(struct omap_dss_device *dssdev)
-{
-       return false;
-}
-
-static int hdmi_audio_config(struct omap_dss_device *dssdev,
-               struct omap_dss_audio *audio)
-{
-       return -EPERM;
-}
-#endif
-
-static const struct omapdss_hdmi_ops hdmi_ops = {
-       .connect                = hdmi_connect,
-       .disconnect             = hdmi_disconnect,
-
-       .enable                 = hdmi_display_enable,
-       .disable                = hdmi_display_disable,
-
-       .check_timings          = hdmi_display_check_timing,
-       .set_timings            = hdmi_display_set_timing,
-       .get_timings            = hdmi_display_get_timings,
-
-       .read_edid              = hdmi_read_edid,
-
-       .audio_enable           = hdmi_audio_enable,
-       .audio_disable          = hdmi_audio_disable,
-       .audio_start            = hdmi_audio_start,
-       .audio_stop             = hdmi_audio_stop,
-       .audio_supported        = hdmi_audio_supported,
-       .audio_config           = hdmi_audio_config,
-};
-
-static void hdmi_init_output(struct platform_device *pdev)
-{
-       struct omap_dss_device *out = &hdmi.output;
-
-       out->dev = &pdev->dev;
-       out->id = OMAP_DSS_OUTPUT_HDMI;
-       out->output_type = OMAP_DISPLAY_TYPE_HDMI;
-       out->name = "hdmi.0";
-       out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
-       out->ops.hdmi = &hdmi_ops;
-       out->owner = THIS_MODULE;
-
-       omapdss_register_output(out);
-}
-
-static void __exit hdmi_uninit_output(struct platform_device *pdev)
-{
-       struct omap_dss_device *out = &hdmi.output;
-
-       omapdss_unregister_output(out);
-}
-
-/* HDMI HW IP initialisation */
-static int omapdss_hdmihw_probe(struct platform_device *pdev)
-{
-       struct resource *res;
-       int r;
-
-       hdmi.pdev = pdev;
-
-       mutex_init(&hdmi.lock);
-       mutex_init(&hdmi.ip_data.lock);
-
-       res = platform_get_resource(hdmi.pdev, IORESOURCE_MEM, 0);
-
-       /* Base address taken from platform */
-       hdmi.ip_data.base_wp = devm_ioremap_resource(&pdev->dev, res);
-       if (IS_ERR(hdmi.ip_data.base_wp))
-               return PTR_ERR(hdmi.ip_data.base_wp);
-
-       hdmi.ip_data.irq = platform_get_irq(pdev, 0);
-       if (hdmi.ip_data.irq < 0) {
-               DSSERR("platform_get_irq failed\n");
-               return -ENODEV;
-       }
-
-       r = hdmi_get_clocks(pdev);
-       if (r) {
-               DSSERR("can't get clocks\n");
-               return r;
-       }
-
-       pm_runtime_enable(&pdev->dev);
-
-       hdmi.ip_data.core_sys_offset = HDMI_CORE_SYS;
-       hdmi.ip_data.core_av_offset = HDMI_CORE_AV;
-       hdmi.ip_data.pll_offset = HDMI_PLLCTRL;
-       hdmi.ip_data.phy_offset = HDMI_PHY;
-
-       hdmi_init_output(pdev);
-
-       dss_debugfs_create_file("hdmi", hdmi_dump_regs);
-
-       return 0;
-}
-
-static int __exit omapdss_hdmihw_remove(struct platform_device *pdev)
-{
-       hdmi_uninit_output(pdev);
-
-       pm_runtime_disable(&pdev->dev);
-
-       return 0;
-}
-
-static int hdmi_runtime_suspend(struct device *dev)
-{
-       clk_disable_unprepare(hdmi.sys_clk);
-
-       dispc_runtime_put();
-
-       return 0;
-}
-
-static int hdmi_runtime_resume(struct device *dev)
-{
-       int r;
-
-       r = dispc_runtime_get();
-       if (r < 0)
-               return r;
-
-       clk_prepare_enable(hdmi.sys_clk);
-
-       return 0;
-}
-
-static const struct dev_pm_ops hdmi_pm_ops = {
-       .runtime_suspend = hdmi_runtime_suspend,
-       .runtime_resume = hdmi_runtime_resume,
-};
-
-static struct platform_driver omapdss_hdmihw_driver = {
-       .probe          = omapdss_hdmihw_probe,
-       .remove         = __exit_p(omapdss_hdmihw_remove),
-       .driver         = {
-               .name   = "omapdss_hdmi",
-               .owner  = THIS_MODULE,
-               .pm     = &hdmi_pm_ops,
-       },
-};
-
-int __init hdmi_init_platform_driver(void)
-{
-       return platform_driver_register(&omapdss_hdmihw_driver);
-}
-
-void __exit hdmi_uninit_platform_driver(void)
-{
-       platform_driver_unregister(&omapdss_hdmihw_driver);
-}
diff --git a/drivers/video/omap2/dss/hdmi.h b/drivers/video/omap2/dss/hdmi.h
new file mode 100644 (file)
index 0000000..b049376
--- /dev/null
@@ -0,0 +1,444 @@
+/*
+ * HDMI driver definition for TI OMAP4 Processor.
+ *
+ * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _HDMI_H
+#define _HDMI_H
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <video/omapdss.h>
+
+#include "dss.h"
+
+/* HDMI Wrapper */
+
+#define HDMI_WP_REVISION                       0x0
+#define HDMI_WP_SYSCONFIG                      0x10
+#define HDMI_WP_IRQSTATUS_RAW                  0x24
+#define HDMI_WP_IRQSTATUS                      0x28
+#define HDMI_WP_IRQENABLE_SET                  0x2C
+#define HDMI_WP_IRQENABLE_CLR                  0x30
+#define HDMI_WP_IRQWAKEEN                      0x34
+#define HDMI_WP_PWR_CTRL                       0x40
+#define HDMI_WP_DEBOUNCE                       0x44
+#define HDMI_WP_VIDEO_CFG                      0x50
+#define HDMI_WP_VIDEO_SIZE                     0x60
+#define HDMI_WP_VIDEO_TIMING_H                 0x68
+#define HDMI_WP_VIDEO_TIMING_V                 0x6C
+#define HDMI_WP_WP_CLK                         0x70
+#define HDMI_WP_AUDIO_CFG                      0x80
+#define HDMI_WP_AUDIO_CFG2                     0x84
+#define HDMI_WP_AUDIO_CTRL                     0x88
+#define HDMI_WP_AUDIO_DATA                     0x8C
+
+/* HDMI WP IRQ flags */
+
+#define HDMI_IRQ_OCP_TIMEOUT                   (1 << 4)
+#define HDMI_IRQ_AUDIO_FIFO_UNDERFLOW          (1 << 8)
+#define HDMI_IRQ_AUDIO_FIFO_OVERFLOW           (1 << 9)
+#define HDMI_IRQ_AUDIO_FIFO_SAMPLE_REQ         (1 << 10)
+#define HDMI_IRQ_VIDEO_VSYNC                   (1 << 16)
+#define HDMI_IRQ_VIDEO_FRAME_DONE              (1 << 17)
+#define HDMI_IRQ_PHY_LINE5V_ASSERT             (1 << 24)
+#define HDMI_IRQ_LINK_CONNECT                  (1 << 25)
+#define HDMI_IRQ_LINK_DISCONNECT               (1 << 26)
+#define HDMI_IRQ_PLL_LOCK                      (1 << 29)
+#define HDMI_IRQ_PLL_UNLOCK                    (1 << 30)
+#define HDMI_IRQ_PLL_RECAL                     (1 << 31)
+
+/* HDMI PLL */
+
+#define PLLCTRL_PLL_CONTROL                    0x0
+#define PLLCTRL_PLL_STATUS                     0x4
+#define PLLCTRL_PLL_GO                         0x8
+#define PLLCTRL_CFG1                           0xC
+#define PLLCTRL_CFG2                           0x10
+#define PLLCTRL_CFG3                           0x14
+#define PLLCTRL_SSC_CFG1                       0x18
+#define PLLCTRL_SSC_CFG2                       0x1C
+#define PLLCTRL_CFG4                           0x20
+
+/* HDMI PHY */
+
+#define HDMI_TXPHY_TX_CTRL                     0x0
+#define HDMI_TXPHY_DIGITAL_CTRL                        0x4
+#define HDMI_TXPHY_POWER_CTRL                  0x8
+#define HDMI_TXPHY_PAD_CFG_CTRL                        0xC
+
+enum hdmi_pll_pwr {
+       HDMI_PLLPWRCMD_ALLOFF = 0,
+       HDMI_PLLPWRCMD_PLLONLY = 1,
+       HDMI_PLLPWRCMD_BOTHON_ALLCLKS = 2,
+       HDMI_PLLPWRCMD_BOTHON_NOPHYCLK = 3
+};
+
+enum hdmi_phy_pwr {
+       HDMI_PHYPWRCMD_OFF = 0,
+       HDMI_PHYPWRCMD_LDOON = 1,
+       HDMI_PHYPWRCMD_TXON = 2
+};
+
+enum hdmi_core_hdmi_dvi {
+       HDMI_DVI = 0,
+       HDMI_HDMI = 1
+};
+
+enum hdmi_clk_refsel {
+       HDMI_REFSEL_PCLK = 0,
+       HDMI_REFSEL_REF1 = 1,
+       HDMI_REFSEL_REF2 = 2,
+       HDMI_REFSEL_SYSCLK = 3
+};
+
+enum hdmi_packing_mode {
+       HDMI_PACK_10b_RGB_YUV444 = 0,
+       HDMI_PACK_24b_RGB_YUV444_YUV422 = 1,
+       HDMI_PACK_20b_YUV422 = 2,
+       HDMI_PACK_ALREADYPACKED = 7
+};
+
+enum hdmi_stereo_channels {
+       HDMI_AUDIO_STEREO_NOCHANNELS = 0,
+       HDMI_AUDIO_STEREO_ONECHANNEL = 1,
+       HDMI_AUDIO_STEREO_TWOCHANNELS = 2,
+       HDMI_AUDIO_STEREO_THREECHANNELS = 3,
+       HDMI_AUDIO_STEREO_FOURCHANNELS = 4
+};
+
+enum hdmi_audio_type {
+       HDMI_AUDIO_TYPE_LPCM = 0,
+       HDMI_AUDIO_TYPE_IEC = 1
+};
+
+enum hdmi_audio_justify {
+       HDMI_AUDIO_JUSTIFY_LEFT = 0,
+       HDMI_AUDIO_JUSTIFY_RIGHT = 1
+};
+
+enum hdmi_audio_sample_order {
+       HDMI_AUDIO_SAMPLE_RIGHT_FIRST = 0,
+       HDMI_AUDIO_SAMPLE_LEFT_FIRST = 1
+};
+
+enum hdmi_audio_samples_perword {
+       HDMI_AUDIO_ONEWORD_ONESAMPLE = 0,
+       HDMI_AUDIO_ONEWORD_TWOSAMPLES = 1
+};
+
+enum hdmi_audio_sample_size {
+       HDMI_AUDIO_SAMPLE_16BITS = 0,
+       HDMI_AUDIO_SAMPLE_24BITS = 1
+};
+
+enum hdmi_audio_transf_mode {
+       HDMI_AUDIO_TRANSF_DMA = 0,
+       HDMI_AUDIO_TRANSF_IRQ = 1
+};
+
+enum hdmi_audio_blk_strt_end_sig {
+       HDMI_AUDIO_BLOCK_SIG_STARTEND_ON = 0,
+       HDMI_AUDIO_BLOCK_SIG_STARTEND_OFF = 1
+};
+
+enum hdmi_core_audio_layout {
+       HDMI_AUDIO_LAYOUT_2CH = 0,
+       HDMI_AUDIO_LAYOUT_8CH = 1
+};
+
+enum hdmi_core_cts_mode {
+       HDMI_AUDIO_CTS_MODE_HW = 0,
+       HDMI_AUDIO_CTS_MODE_SW = 1
+};
+
+enum hdmi_audio_mclk_mode {
+       HDMI_AUDIO_MCLK_128FS = 0,
+       HDMI_AUDIO_MCLK_256FS = 1,
+       HDMI_AUDIO_MCLK_384FS = 2,
+       HDMI_AUDIO_MCLK_512FS = 3,
+       HDMI_AUDIO_MCLK_768FS = 4,
+       HDMI_AUDIO_MCLK_1024FS = 5,
+       HDMI_AUDIO_MCLK_1152FS = 6,
+       HDMI_AUDIO_MCLK_192FS = 7
+};
+
+/* INFOFRAME_AVI_ and INFOFRAME_AUDIO_ definitions */
+enum hdmi_core_infoframe {
+       HDMI_INFOFRAME_AVI_DB1Y_RGB = 0,
+       HDMI_INFOFRAME_AVI_DB1Y_YUV422 = 1,
+       HDMI_INFOFRAME_AVI_DB1Y_YUV444 = 2,
+       HDMI_INFOFRAME_AVI_DB1A_ACTIVE_FORMAT_OFF = 0,
+       HDMI_INFOFRAME_AVI_DB1A_ACTIVE_FORMAT_ON =  1,
+       HDMI_INFOFRAME_AVI_DB1B_NO = 0,
+       HDMI_INFOFRAME_AVI_DB1B_VERT = 1,
+       HDMI_INFOFRAME_AVI_DB1B_HORI = 2,
+       HDMI_INFOFRAME_AVI_DB1B_VERTHORI = 3,
+       HDMI_INFOFRAME_AVI_DB1S_0 = 0,
+       HDMI_INFOFRAME_AVI_DB1S_1 = 1,
+       HDMI_INFOFRAME_AVI_DB1S_2 = 2,
+       HDMI_INFOFRAME_AVI_DB2C_NO = 0,
+       HDMI_INFOFRAME_AVI_DB2C_ITU601 = 1,
+       HDMI_INFOFRAME_AVI_DB2C_ITU709 = 2,
+       HDMI_INFOFRAME_AVI_DB2C_EC_EXTENDED = 3,
+       HDMI_INFOFRAME_AVI_DB2M_NO = 0,
+       HDMI_INFOFRAME_AVI_DB2M_43 = 1,
+       HDMI_INFOFRAME_AVI_DB2M_169 = 2,
+       HDMI_INFOFRAME_AVI_DB2R_SAME = 8,
+       HDMI_INFOFRAME_AVI_DB2R_43 = 9,
+       HDMI_INFOFRAME_AVI_DB2R_169 = 10,
+       HDMI_INFOFRAME_AVI_DB2R_149 = 11,
+       HDMI_INFOFRAME_AVI_DB3ITC_NO = 0,
+       HDMI_INFOFRAME_AVI_DB3ITC_YES = 1,
+       HDMI_INFOFRAME_AVI_DB3EC_XVYUV601 = 0,
+       HDMI_INFOFRAME_AVI_DB3EC_XVYUV709 = 1,
+       HDMI_INFOFRAME_AVI_DB3Q_DEFAULT = 0,
+       HDMI_INFOFRAME_AVI_DB3Q_LR = 1,
+       HDMI_INFOFRAME_AVI_DB3Q_FR = 2,
+       HDMI_INFOFRAME_AVI_DB3SC_NO = 0,
+       HDMI_INFOFRAME_AVI_DB3SC_HORI = 1,
+       HDMI_INFOFRAME_AVI_DB3SC_VERT = 2,
+       HDMI_INFOFRAME_AVI_DB3SC_HORIVERT = 3,
+       HDMI_INFOFRAME_AVI_DB5PR_NO = 0,
+       HDMI_INFOFRAME_AVI_DB5PR_2 = 1,
+       HDMI_INFOFRAME_AVI_DB5PR_3 = 2,
+       HDMI_INFOFRAME_AVI_DB5PR_4 = 3,
+       HDMI_INFOFRAME_AVI_DB5PR_5 = 4,
+       HDMI_INFOFRAME_AVI_DB5PR_6 = 5,
+       HDMI_INFOFRAME_AVI_DB5PR_7 = 6,
+       HDMI_INFOFRAME_AVI_DB5PR_8 = 7,
+       HDMI_INFOFRAME_AVI_DB5PR_9 = 8,
+       HDMI_INFOFRAME_AVI_DB5PR_10 = 9,
+};
+
+struct hdmi_cm {
+       int     code;
+       int     mode;
+};
+
+struct hdmi_video_format {
+       enum hdmi_packing_mode  packing_mode;
+       u32                     y_res;  /* Line per panel */
+       u32                     x_res;  /* pixel per line */
+};
+
+struct hdmi_config {
+       struct omap_video_timings timings;
+       struct hdmi_cm cm;
+};
+
+/* HDMI PLL structure */
+struct hdmi_pll_info {
+       u16 regn;
+       u16 regm;
+       u32 regmf;
+       u16 regm2;
+       u16 regsd;
+       u16 dcofreq;
+       enum hdmi_clk_refsel refsel;
+};
+
+struct hdmi_audio_format {
+       enum hdmi_stereo_channels               stereo_channels;
+       u8                                      active_chnnls_msk;
+       enum hdmi_audio_type                    type;
+       enum hdmi_audio_justify                 justification;
+       enum hdmi_audio_sample_order            sample_order;
+       enum hdmi_audio_samples_perword         samples_per_word;
+       enum hdmi_audio_sample_size             sample_size;
+       enum hdmi_audio_blk_strt_end_sig        en_sig_blk_strt_end;
+};
+
+struct hdmi_audio_dma {
+       u8                              transfer_size;
+       u8                              block_size;
+       enum hdmi_audio_transf_mode     mode;
+       u16                             fifo_threshold;
+};
+
+struct hdmi_core_audio_i2s_config {
+       u8 in_length_bits;
+       u8 justification;
+       u8 sck_edge_mode;
+       u8 vbit;
+       u8 direction;
+       u8 shift;
+       u8 active_sds;
+};
+
+struct hdmi_core_audio_config {
+       struct hdmi_core_audio_i2s_config       i2s_cfg;
+       struct snd_aes_iec958                   *iec60958_cfg;
+       bool                                    fs_override;
+       u32                                     n;
+       u32                                     cts;
+       u32                                     aud_par_busclk;
+       enum hdmi_core_audio_layout             layout;
+       enum hdmi_core_cts_mode                 cts_mode;
+       bool                                    use_mclk;
+       enum hdmi_audio_mclk_mode               mclk_mode;
+       bool                                    en_acr_pkt;
+       bool                                    en_dsd_audio;
+       bool                                    en_parallel_aud_input;
+       bool                                    en_spdif;
+};
+
+/*
+ * Refer to section 8.2 in HDMI 1.3 specification for
+ * details about infoframe databytes
+ */
+struct hdmi_core_infoframe_avi {
+       /* Y0, Y1 rgb,yCbCr */
+       u8      db1_format;
+       /* A0  Active information Present */
+       u8      db1_active_info;
+       /* B0, B1 Bar info data valid */
+       u8      db1_bar_info_dv;
+       /* S0, S1 scan information */
+       u8      db1_scan_info;
+       /* C0, C1 colorimetry */
+       u8      db2_colorimetry;
+       /* M0, M1 Aspect ratio (4:3, 16:9) */
+       u8      db2_aspect_ratio;
+       /* R0...R3 Active format aspect ratio */
+       u8      db2_active_fmt_ar;
+       /* ITC IT content. */
+       u8      db3_itc;
+       /* EC0, EC1, EC2 Extended colorimetry */
+       u8      db3_ec;
+       /* Q1, Q0 Quantization range */
+       u8      db3_q_range;
+       /* SC1, SC0 Non-uniform picture scaling */
+       u8      db3_nup_scaling;
+       /* VIC0..6 Video format identification */
+       u8      db4_videocode;
+       /* PR0..PR3 Pixel repetition factor */
+       u8      db5_pixel_repeat;
+       /* Line number end of top bar */
+       u16     db6_7_line_eoftop;
+       /* Line number start of bottom bar */
+       u16     db8_9_line_sofbottom;
+       /* Pixel number end of left bar */
+       u16     db10_11_pixel_eofleft;
+       /* Pixel number start of right bar */
+       u16     db12_13_pixel_sofright;
+};
+
+struct hdmi_wp_data {
+       void __iomem *base;
+};
+
+struct hdmi_pll_data {
+       void __iomem *base;
+
+       struct hdmi_pll_info info;
+};
+
+struct hdmi_phy_data {
+       void __iomem *base;
+
+       int irq;
+};
+
+struct hdmi_core_data {
+       void __iomem *base;
+
+       struct hdmi_core_infoframe_avi avi_cfg;
+};
+
+static inline void hdmi_write_reg(void __iomem *base_addr, const u16 idx,
+               u32 val)
+{
+       __raw_writel(val, base_addr + idx);
+}
+
+static inline u32 hdmi_read_reg(void __iomem *base_addr, const u16 idx)
+{
+       return __raw_readl(base_addr + idx);
+}
+
+#define REG_FLD_MOD(base, idx, val, start, end) \
+       hdmi_write_reg(base, idx, FLD_MOD(hdmi_read_reg(base, idx),\
+                                                       val, start, end))
+#define REG_GET(base, idx, start, end) \
+       FLD_GET(hdmi_read_reg(base, idx), start, end)
+
+static inline int hdmi_wait_for_bit_change(void __iomem *base_addr,
+               const u16 idx, int b2, int b1, u32 val)
+{
+       u32 t = 0;
+       while (val != REG_GET(base_addr, idx, b2, b1)) {
+               udelay(1);
+               if (t++ > 10000)
+                       return !val;
+       }
+       return val;
+}
+
+/* HDMI wrapper funcs */
+int hdmi_wp_video_start(struct hdmi_wp_data *wp);
+void hdmi_wp_video_stop(struct hdmi_wp_data *wp);
+void hdmi_wp_dump(struct hdmi_wp_data *wp, struct seq_file *s);
+u32 hdmi_wp_get_irqstatus(struct hdmi_wp_data *wp);
+void hdmi_wp_set_irqstatus(struct hdmi_wp_data *wp, u32 irqstatus);
+void hdmi_wp_set_irqenable(struct hdmi_wp_data *wp, u32 mask);
+void hdmi_wp_clear_irqenable(struct hdmi_wp_data *wp, u32 mask);
+int hdmi_wp_set_phy_pwr(struct hdmi_wp_data *wp, enum hdmi_phy_pwr val);
+int hdmi_wp_set_pll_pwr(struct hdmi_wp_data *wp, enum hdmi_pll_pwr val);
+void hdmi_wp_video_config_format(struct hdmi_wp_data *wp,
+               struct hdmi_video_format *video_fmt);
+void hdmi_wp_video_config_interface(struct hdmi_wp_data *wp,
+               struct omap_video_timings *timings);
+void hdmi_wp_video_config_timing(struct hdmi_wp_data *wp,
+               struct omap_video_timings *timings);
+void hdmi_wp_init_vid_fmt_timings(struct hdmi_video_format *video_fmt,
+               struct omap_video_timings *timings, struct hdmi_config *param);
+int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp);
+
+/* HDMI PLL funcs */
+int hdmi_pll_enable(struct hdmi_pll_data *pll, struct hdmi_wp_data *wp);
+void hdmi_pll_disable(struct hdmi_pll_data *pll, struct hdmi_wp_data *wp);
+void hdmi_pll_dump(struct hdmi_pll_data *pll, struct seq_file *s);
+void hdmi_pll_compute(struct hdmi_pll_data *pll, unsigned long clkin, int phy);
+int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll);
+
+/* HDMI PHY funcs */
+int hdmi_phy_enable(struct hdmi_phy_data *phy, struct hdmi_wp_data *wp,
+               struct hdmi_config *cfg);
+void hdmi_phy_disable(struct hdmi_phy_data *phy, struct hdmi_wp_data *wp);
+void hdmi_phy_dump(struct hdmi_phy_data *phy, struct seq_file *s);
+int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy);
+
+/* HDMI common funcs */
+const struct hdmi_config *hdmi_default_timing(void);
+const struct hdmi_config *hdmi_get_timings(int mode, int code);
+struct hdmi_cm hdmi_get_code(struct omap_video_timings *timing);
+
+#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
+int hdmi_compute_acr(u32 pclk, u32 sample_freq, u32 *n, u32 *cts);
+int hdmi_wp_audio_enable(struct hdmi_wp_data *wp, bool enable);
+int hdmi_wp_audio_core_req_enable(struct hdmi_wp_data *wp, bool enable);
+void hdmi_wp_audio_config_format(struct hdmi_wp_data *wp,
+               struct hdmi_audio_format *aud_fmt);
+void hdmi_wp_audio_config_dma(struct hdmi_wp_data *wp,
+               struct hdmi_audio_dma *aud_dma);
+static inline bool hdmi_mode_has_audio(int mode)
+{
+       return mode == HDMI_HDMI ? true : false;
+}
+#endif
+#endif
diff --git a/drivers/video/omap2/dss/hdmi4.c b/drivers/video/omap2/dss/hdmi4.c
new file mode 100644 (file)
index 0000000..e140096
--- /dev/null
@@ -0,0 +1,696 @@
+/*
+ * HDMI interface DSS driver for TI's OMAP4 family of SoCs.
+ * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
+ * Authors: Yong Zhi
+ *     Mythri pk <mythripk@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#define DSS_SUBSYS_NAME "HDMI"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/interrupt.h>
+#include <linux/mutex.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/clk.h>
+#include <linux/gpio.h>
+#include <linux/regulator/consumer.h>
+#include <video/omapdss.h>
+
+#include "hdmi4_core.h"
+#include "dss.h"
+#include "dss_features.h"
+
+static struct {
+       struct mutex lock;
+       struct platform_device *pdev;
+
+       struct hdmi_wp_data     wp;
+       struct hdmi_pll_data    pll;
+       struct hdmi_phy_data    phy;
+       struct hdmi_core_data   core;
+
+       struct hdmi_config cfg;
+
+       struct clk *sys_clk;
+       struct regulator *vdda_hdmi_dac_reg;
+
+       bool core_enabled;
+
+       struct omap_dss_device output;
+} hdmi;
+
+static int hdmi_runtime_get(void)
+{
+       int r;
+
+       DSSDBG("hdmi_runtime_get\n");
+
+       r = pm_runtime_get_sync(&hdmi.pdev->dev);
+       WARN_ON(r < 0);
+       if (r < 0)
+               return r;
+
+       return 0;
+}
+
+static void hdmi_runtime_put(void)
+{
+       int r;
+
+       DSSDBG("hdmi_runtime_put\n");
+
+       r = pm_runtime_put_sync(&hdmi.pdev->dev);
+       WARN_ON(r < 0 && r != -ENOSYS);
+}
+
+static int hdmi_init_regulator(void)
+{
+       struct regulator *reg;
+
+       if (hdmi.vdda_hdmi_dac_reg != NULL)
+               return 0;
+
+       reg = devm_regulator_get(&hdmi.pdev->dev, "vdda_hdmi_dac");
+
+       /* DT HACK: try VDAC to make omapdss work for o4 sdp/panda */
+       if (IS_ERR(reg))
+               reg = devm_regulator_get(&hdmi.pdev->dev, "VDAC");
+
+       if (IS_ERR(reg)) {
+               DSSERR("can't get VDDA_HDMI_DAC regulator\n");
+               return PTR_ERR(reg);
+       }
+
+       hdmi.vdda_hdmi_dac_reg = reg;
+
+       return 0;
+}
+
+static int hdmi_power_on_core(struct omap_dss_device *dssdev)
+{
+       int r;
+
+       r = regulator_enable(hdmi.vdda_hdmi_dac_reg);
+       if (r)
+               return r;
+
+       r = hdmi_runtime_get();
+       if (r)
+               goto err_runtime_get;
+
+       /* Make selection of HDMI in DSS */
+       dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
+
+       hdmi.core_enabled = true;
+
+       return 0;
+
+err_runtime_get:
+       regulator_disable(hdmi.vdda_hdmi_dac_reg);
+
+       return r;
+}
+
+static void hdmi_power_off_core(struct omap_dss_device *dssdev)
+{
+       hdmi.core_enabled = false;
+
+       hdmi_runtime_put();
+       regulator_disable(hdmi.vdda_hdmi_dac_reg);
+}
+
+static int hdmi_power_on_full(struct omap_dss_device *dssdev)
+{
+       int r;
+       struct omap_video_timings *p;
+       struct omap_overlay_manager *mgr = hdmi.output.manager;
+       unsigned long phy;
+
+       r = hdmi_power_on_core(dssdev);
+       if (r)
+               return r;
+
+       dss_mgr_disable(mgr);
+
+       p = &hdmi.cfg.timings;
+
+       DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res);
+
+       phy = p->pixel_clock;
+
+       hdmi_pll_compute(&hdmi.pll, clk_get_rate(hdmi.sys_clk), phy);
+
+       hdmi_wp_video_stop(&hdmi.wp);
+
+       /* config the PLL and PHY hdmi_set_pll_pwrfirst */
+       r = hdmi_pll_enable(&hdmi.pll, &hdmi.wp);
+       if (r) {
+               DSSDBG("Failed to lock PLL\n");
+               goto err_pll_enable;
+       }
+
+       r = hdmi_phy_enable(&hdmi.phy, &hdmi.wp, &hdmi.cfg);
+       if (r) {
+               DSSDBG("Failed to start PHY\n");
+               goto err_phy_enable;
+       }
+
+       hdmi4_configure(&hdmi.core, &hdmi.wp, &hdmi.cfg);
+
+       /* bypass TV gamma table */
+       dispc_enable_gamma_table(0);
+
+       /* tv size */
+       dss_mgr_set_timings(mgr, p);
+
+       r = hdmi_wp_video_start(&hdmi.wp);
+       if (r)
+               goto err_vid_enable;
+
+       r = dss_mgr_enable(mgr);
+       if (r)
+               goto err_mgr_enable;
+
+       return 0;
+
+err_mgr_enable:
+       hdmi_wp_video_stop(&hdmi.wp);
+err_vid_enable:
+       hdmi_phy_disable(&hdmi.phy, &hdmi.wp);
+err_phy_enable:
+       hdmi_pll_disable(&hdmi.pll, &hdmi.wp);
+err_pll_enable:
+       hdmi_power_off_core(dssdev);
+       return -EIO;
+}
+
+static void hdmi_power_off_full(struct omap_dss_device *dssdev)
+{
+       struct omap_overlay_manager *mgr = hdmi.output.manager;
+
+       dss_mgr_disable(mgr);
+
+       hdmi_wp_video_stop(&hdmi.wp);
+       hdmi_phy_disable(&hdmi.phy, &hdmi.wp);
+       hdmi_pll_disable(&hdmi.pll, &hdmi.wp);
+
+       hdmi_power_off_core(dssdev);
+}
+
+static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
+                                       struct omap_video_timings *timings)
+{
+       struct hdmi_cm cm;
+
+       cm = hdmi_get_code(timings);
+       if (cm.code == -1)
+               return -EINVAL;
+
+       return 0;
+
+}
+
+static void hdmi_display_set_timing(struct omap_dss_device *dssdev,
+               struct omap_video_timings *timings)
+{
+       struct hdmi_cm cm;
+       const struct hdmi_config *t;
+
+       mutex_lock(&hdmi.lock);
+
+       cm = hdmi_get_code(timings);
+       hdmi.cfg.cm = cm;
+
+       t = hdmi_get_timings(cm.mode, cm.code);
+       if (t != NULL) {
+               hdmi.cfg = *t;
+
+               dispc_set_tv_pclk(t->timings.pixel_clock * 1000);
+       }
+
+       mutex_unlock(&hdmi.lock);
+}
+
+static void hdmi_display_get_timings(struct omap_dss_device *dssdev,
+               struct omap_video_timings *timings)
+{
+       const struct hdmi_config *cfg;
+       struct hdmi_cm cm = hdmi.cfg.cm;
+
+       cfg = hdmi_get_timings(cm.mode, cm.code);
+       if (cfg == NULL)
+               cfg = hdmi_default_timing();
+
+       memcpy(timings, &cfg->timings, sizeof(cfg->timings));
+}
+
+static void hdmi_dump_regs(struct seq_file *s)
+{
+       mutex_lock(&hdmi.lock);
+
+       if (hdmi_runtime_get()) {
+               mutex_unlock(&hdmi.lock);
+               return;
+       }
+
+       hdmi_wp_dump(&hdmi.wp, s);
+       hdmi_pll_dump(&hdmi.pll, s);
+       hdmi_phy_dump(&hdmi.phy, s);
+       hdmi4_core_dump(&hdmi.core, s);
+
+       hdmi_runtime_put();
+       mutex_unlock(&hdmi.lock);
+}
+
+static int read_edid(u8 *buf, int len)
+{
+       int r;
+
+       mutex_lock(&hdmi.lock);
+
+       r = hdmi_runtime_get();
+       BUG_ON(r);
+
+       r = hdmi4_read_edid(&hdmi.core,  buf, len);
+
+       hdmi_runtime_put();
+       mutex_unlock(&hdmi.lock);
+
+       return r;
+}
+
+static int hdmi_display_enable(struct omap_dss_device *dssdev)
+{
+       struct omap_dss_device *out = &hdmi.output;
+       int r = 0;
+
+       DSSDBG("ENTER hdmi_display_enable\n");
+
+       mutex_lock(&hdmi.lock);
+
+       if (out == NULL || out->manager == NULL) {
+               DSSERR("failed to enable display: no output/manager\n");
+               r = -ENODEV;
+               goto err0;
+       }
+
+       r = hdmi_power_on_full(dssdev);
+       if (r) {
+               DSSERR("failed to power on device\n");
+               goto err0;
+       }
+
+       mutex_unlock(&hdmi.lock);
+       return 0;
+
+err0:
+       mutex_unlock(&hdmi.lock);
+       return r;
+}
+
+static void hdmi_display_disable(struct omap_dss_device *dssdev)
+{
+       DSSDBG("Enter hdmi_display_disable\n");
+
+       mutex_lock(&hdmi.lock);
+
+       hdmi_power_off_full(dssdev);
+
+       mutex_unlock(&hdmi.lock);
+}
+
+static int hdmi_core_enable(struct omap_dss_device *dssdev)
+{
+       int r = 0;
+
+       DSSDBG("ENTER omapdss_hdmi_core_enable\n");
+
+       mutex_lock(&hdmi.lock);
+
+       r = hdmi_power_on_core(dssdev);
+       if (r) {
+               DSSERR("failed to power on device\n");
+               goto err0;
+       }
+
+       mutex_unlock(&hdmi.lock);
+       return 0;
+
+err0:
+       mutex_unlock(&hdmi.lock);
+       return r;
+}
+
+static void hdmi_core_disable(struct omap_dss_device *dssdev)
+{
+       DSSDBG("Enter omapdss_hdmi_core_disable\n");
+
+       mutex_lock(&hdmi.lock);
+
+       hdmi_power_off_core(dssdev);
+
+       mutex_unlock(&hdmi.lock);
+}
+
+static int hdmi_get_clocks(struct platform_device *pdev)
+{
+       struct clk *clk;
+
+       clk = devm_clk_get(&pdev->dev, "sys_clk");
+       if (IS_ERR(clk)) {
+               DSSERR("can't get sys_clk\n");
+               return PTR_ERR(clk);
+       }
+
+       hdmi.sys_clk = clk;
+
+       return 0;
+}
+
+static int hdmi_connect(struct omap_dss_device *dssdev,
+               struct omap_dss_device *dst)
+{
+       struct omap_overlay_manager *mgr;
+       int r;
+
+       r = hdmi_init_regulator();
+       if (r)
+               return r;
+
+       mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
+       if (!mgr)
+               return -ENODEV;
+
+       r = dss_mgr_connect(mgr, dssdev);
+       if (r)
+               return r;
+
+       r = omapdss_output_set_device(dssdev, dst);
+       if (r) {
+               DSSERR("failed to connect output to new device: %s\n",
+                               dst->name);
+               dss_mgr_disconnect(mgr, dssdev);
+               return r;
+       }
+
+       return 0;
+}
+
+static void hdmi_disconnect(struct omap_dss_device *dssdev,
+               struct omap_dss_device *dst)
+{
+       WARN_ON(dst != dssdev->dst);
+
+       if (dst != dssdev->dst)
+               return;
+
+       omapdss_output_unset_device(dssdev);
+
+       if (dssdev->manager)
+               dss_mgr_disconnect(dssdev->manager, dssdev);
+}
+
+static int hdmi_read_edid(struct omap_dss_device *dssdev,
+               u8 *edid, int len)
+{
+       bool need_enable;
+       int r;
+
+       need_enable = hdmi.core_enabled == false;
+
+       if (need_enable) {
+               r = hdmi_core_enable(dssdev);
+               if (r)
+                       return r;
+       }
+
+       r = read_edid(edid, len);
+
+       if (need_enable)
+               hdmi_core_disable(dssdev);
+
+       return r;
+}
+
+#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
+static int hdmi_audio_enable(struct omap_dss_device *dssdev)
+{
+       int r;
+
+       mutex_lock(&hdmi.lock);
+
+       if (!hdmi_mode_has_audio(hdmi.cfg.cm.mode)) {
+               r = -EPERM;
+               goto err;
+       }
+
+       r = hdmi_wp_audio_enable(&hdmi.wp, true);
+       if (r)
+               goto err;
+
+       mutex_unlock(&hdmi.lock);
+       return 0;
+
+err:
+       mutex_unlock(&hdmi.lock);
+       return r;
+}
+
+static void hdmi_audio_disable(struct omap_dss_device *dssdev)
+{
+       hdmi_wp_audio_enable(&hdmi.wp, false);
+}
+
+static int hdmi_audio_start(struct omap_dss_device *dssdev)
+{
+       return hdmi4_audio_start(&hdmi.core, &hdmi.wp);
+}
+
+static void hdmi_audio_stop(struct omap_dss_device *dssdev)
+{
+       hdmi4_audio_stop(&hdmi.core, &hdmi.wp);
+}
+
+static bool hdmi_audio_supported(struct omap_dss_device *dssdev)
+{
+       bool r;
+
+       mutex_lock(&hdmi.lock);
+
+       r = hdmi_mode_has_audio(hdmi.cfg.cm.mode);
+
+       mutex_unlock(&hdmi.lock);
+       return r;
+}
+
+static int hdmi_audio_config(struct omap_dss_device *dssdev,
+               struct omap_dss_audio *audio)
+{
+       int r;
+       u32 pclk = hdmi.cfg.timings.pixel_clock;
+
+       mutex_lock(&hdmi.lock);
+
+       if (!hdmi_mode_has_audio(hdmi.cfg.cm.mode)) {
+               r = -EPERM;
+               goto err;
+       }
+
+       r = hdmi4_audio_config(&hdmi.core, &hdmi.wp, audio, pclk);
+       if (r)
+               goto err;
+
+       mutex_unlock(&hdmi.lock);
+       return 0;
+
+err:
+       mutex_unlock(&hdmi.lock);
+       return r;
+}
+#else
+static int hdmi_audio_enable(struct omap_dss_device *dssdev)
+{
+       return -EPERM;
+}
+
+static void hdmi_audio_disable(struct omap_dss_device *dssdev)
+{
+}
+
+static int hdmi_audio_start(struct omap_dss_device *dssdev)
+{
+       return -EPERM;
+}
+
+static void hdmi_audio_stop(struct omap_dss_device *dssdev)
+{
+}
+
+static bool hdmi_audio_supported(struct omap_dss_device *dssdev)
+{
+       return false;
+}
+
+static int hdmi_audio_config(struct omap_dss_device *dssdev,
+               struct omap_dss_audio *audio)
+{
+       return -EPERM;
+}
+#endif
+
+static const struct omapdss_hdmi_ops hdmi_ops = {
+       .connect                = hdmi_connect,
+       .disconnect             = hdmi_disconnect,
+
+       .enable                 = hdmi_display_enable,
+       .disable                = hdmi_display_disable,
+
+       .check_timings          = hdmi_display_check_timing,
+       .set_timings            = hdmi_display_set_timing,
+       .get_timings            = hdmi_display_get_timings,
+
+       .read_edid              = hdmi_read_edid,
+
+       .audio_enable           = hdmi_audio_enable,
+       .audio_disable          = hdmi_audio_disable,
+       .audio_start            = hdmi_audio_start,
+       .audio_stop             = hdmi_audio_stop,
+       .audio_supported        = hdmi_audio_supported,
+       .audio_config           = hdmi_audio_config,
+};
+
+static void hdmi_init_output(struct platform_device *pdev)
+{
+       struct omap_dss_device *out = &hdmi.output;
+
+       out->dev = &pdev->dev;
+       out->id = OMAP_DSS_OUTPUT_HDMI;
+       out->output_type = OMAP_DISPLAY_TYPE_HDMI;
+       out->name = "hdmi.0";
+       out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
+       out->ops.hdmi = &hdmi_ops;
+       out->owner = THIS_MODULE;
+
+       omapdss_register_output(out);
+}
+
+static void __exit hdmi_uninit_output(struct platform_device *pdev)
+{
+       struct omap_dss_device *out = &hdmi.output;
+
+       omapdss_unregister_output(out);
+}
+
+/* HDMI HW IP initialisation */
+static int omapdss_hdmihw_probe(struct platform_device *pdev)
+{
+       int r;
+
+       hdmi.pdev = pdev;
+
+       mutex_init(&hdmi.lock);
+
+       r = hdmi_wp_init(pdev, &hdmi.wp);
+       if (r)
+               return r;
+
+       r = hdmi_pll_init(pdev, &hdmi.pll);
+       if (r)
+               return r;
+
+       r = hdmi_phy_init(pdev, &hdmi.phy);
+       if (r)
+               return r;
+
+       r = hdmi4_core_init(pdev, &hdmi.core);
+       if (r)
+               return r;
+
+       r = hdmi_get_clocks(pdev);
+       if (r) {
+               DSSERR("can't get clocks\n");
+               return r;
+       }
+
+       pm_runtime_enable(&pdev->dev);
+
+       hdmi_init_output(pdev);
+
+       dss_debugfs_create_file("hdmi", hdmi_dump_regs);
+
+       return 0;
+}
+
+static int __exit omapdss_hdmihw_remove(struct platform_device *pdev)
+{
+       hdmi_uninit_output(pdev);
+
+       pm_runtime_disable(&pdev->dev);
+
+       return 0;
+}
+
+static int hdmi_runtime_suspend(struct device *dev)
+{
+       clk_disable_unprepare(hdmi.sys_clk);
+
+       dispc_runtime_put();
+
+       return 0;
+}
+
+static int hdmi_runtime_resume(struct device *dev)
+{
+       int r;
+
+       r = dispc_runtime_get();
+       if (r < 0)
+               return r;
+
+       clk_prepare_enable(hdmi.sys_clk);
+
+       return 0;
+}
+
+static const struct dev_pm_ops hdmi_pm_ops = {
+       .runtime_suspend = hdmi_runtime_suspend,
+       .runtime_resume = hdmi_runtime_resume,
+};
+
+static struct platform_driver omapdss_hdmihw_driver = {
+       .probe          = omapdss_hdmihw_probe,
+       .remove         = __exit_p(omapdss_hdmihw_remove),
+       .driver         = {
+               .name   = "omapdss_hdmi",
+               .owner  = THIS_MODULE,
+               .pm     = &hdmi_pm_ops,
+       },
+};
+
+int __init hdmi4_init_platform_driver(void)
+{
+       return platform_driver_register(&omapdss_hdmihw_driver);
+}
+
+void __exit hdmi4_uninit_platform_driver(void)
+{
+       platform_driver_unregister(&omapdss_hdmihw_driver);
+}
similarity index 55%
rename from drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c
rename to drivers/video/omap2/dss/hdmi4_core.c
index 3dfe00956a4f156b8c0261c03186efda84187c87..5dd5e5489b419640e7309b8225e7d1d6d885e167 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
 #include <linux/delay.h>
+#include <linux/platform_device.h>
 #include <linux/string.h>
 #include <linux/seq_file.h>
 #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
 #include <sound/asoundef.h>
 #endif
 
-#include "ti_hdmi_4xxx_ip.h"
-#include "dss.h"
+#include "hdmi4_core.h"
 #include "dss_features.h"
 
-#define HDMI_IRQ_LINK_CONNECT          (1 << 25)
-#define HDMI_IRQ_LINK_DISCONNECT       (1 << 26)
+#define HDMI_CORE_AV           0x500
 
-static inline void hdmi_write_reg(void __iomem *base_addr,
-                               const u16 idx, u32 val)
+static inline void __iomem *hdmi_av_base(struct hdmi_core_data *core)
 {
-       __raw_writel(val, base_addr + idx);
+       return core->base + HDMI_CORE_AV;
 }
 
-static inline u32 hdmi_read_reg(void __iomem *base_addr,
-                               const u16 idx)
+static int hdmi_core_ddc_init(struct hdmi_core_data *core)
 {
-       return __raw_readl(base_addr + idx);
-}
-
-static inline void __iomem *hdmi_wp_base(struct hdmi_ip_data *ip_data)
-{
-       return ip_data->base_wp;
-}
-
-static inline void __iomem *hdmi_phy_base(struct hdmi_ip_data *ip_data)
-{
-       return ip_data->base_wp + ip_data->phy_offset;
-}
-
-static inline void __iomem *hdmi_pll_base(struct hdmi_ip_data *ip_data)
-{
-       return ip_data->base_wp + ip_data->pll_offset;
-}
-
-static inline void __iomem *hdmi_av_base(struct hdmi_ip_data *ip_data)
-{
-       return ip_data->base_wp + ip_data->core_av_offset;
-}
-
-static inline void __iomem *hdmi_core_sys_base(struct hdmi_ip_data *ip_data)
-{
-       return ip_data->base_wp + ip_data->core_sys_offset;
-}
-
-static inline int hdmi_wait_for_bit_change(void __iomem *base_addr,
-                               const u16 idx,
-                               int b2, int b1, u32 val)
-{
-       u32 t = 0;
-       while (val != REG_GET(base_addr, idx, b2, b1)) {
-               udelay(1);
-               if (t++ > 10000)
-                       return !val;
-       }
-       return val;
-}
-
-static int hdmi_pll_init(struct hdmi_ip_data *ip_data)
-{
-       u32 r;
-       void __iomem *pll_base = hdmi_pll_base(ip_data);
-       struct hdmi_pll_info *fmt = &ip_data->pll_data;
-
-       /* PLL start always use manual mode */
-       REG_FLD_MOD(pll_base, PLLCTRL_PLL_CONTROL, 0x0, 0, 0);
-
-       r = hdmi_read_reg(pll_base, PLLCTRL_CFG1);
-       r = FLD_MOD(r, fmt->regm, 20, 9); /* CFG1_PLL_REGM */
-       r = FLD_MOD(r, fmt->regn - 1, 8, 1);  /* CFG1_PLL_REGN */
-
-       hdmi_write_reg(pll_base, PLLCTRL_CFG1, r);
-
-       r = hdmi_read_reg(pll_base, PLLCTRL_CFG2);
-
-       r = FLD_MOD(r, 0x0, 12, 12); /* PLL_HIGHFREQ divide by 2 */
-       r = FLD_MOD(r, 0x1, 13, 13); /* PLL_REFEN */
-       r = FLD_MOD(r, 0x0, 14, 14); /* PHY_CLKINEN de-assert during locking */
-       r = FLD_MOD(r, fmt->refsel, 22, 21); /* REFSEL */
-
-       if (fmt->dcofreq) {
-               /* divider programming for frequency beyond 1000Mhz */
-               REG_FLD_MOD(pll_base, PLLCTRL_CFG3, fmt->regsd, 17, 10);
-               r = FLD_MOD(r, 0x4, 3, 1); /* 1000MHz and 2000MHz */
-       } else {
-               r = FLD_MOD(r, 0x2, 3, 1); /* 500MHz and 1000MHz */
-       }
-
-       hdmi_write_reg(pll_base, PLLCTRL_CFG2, r);
-
-       r = hdmi_read_reg(pll_base, PLLCTRL_CFG4);
-       r = FLD_MOD(r, fmt->regm2, 24, 18);
-       r = FLD_MOD(r, fmt->regmf, 17, 0);
-
-       hdmi_write_reg(pll_base, PLLCTRL_CFG4, r);
-
-       /* go now */
-       REG_FLD_MOD(pll_base, PLLCTRL_PLL_GO, 0x1, 0, 0);
-
-       /* wait for bit change */
-       if (hdmi_wait_for_bit_change(pll_base, PLLCTRL_PLL_GO,
-                                                       0, 0, 1) != 1) {
-               pr_err("PLL GO bit not set\n");
-               return -ETIMEDOUT;
-       }
-
-       /* Wait till the lock bit is set in PLL status */
-       if (hdmi_wait_for_bit_change(pll_base,
-                               PLLCTRL_PLL_STATUS, 1, 1, 1) != 1) {
-               pr_err("cannot lock PLL\n");
-               pr_err("CFG1 0x%x\n",
-                       hdmi_read_reg(pll_base, PLLCTRL_CFG1));
-               pr_err("CFG2 0x%x\n",
-                       hdmi_read_reg(pll_base, PLLCTRL_CFG2));
-               pr_err("CFG4 0x%x\n",
-                       hdmi_read_reg(pll_base, PLLCTRL_CFG4));
-               return -ETIMEDOUT;
-       }
-
-       pr_debug("PLL locked!\n");
-
-       return 0;
-}
-
-/* PHY_PWR_CMD */
-static int hdmi_set_phy_pwr(struct hdmi_ip_data *ip_data, enum hdmi_phy_pwr val)
-{
-       /* Return if already the state */
-       if (REG_GET(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL, 5, 4) == val)
-               return 0;
-
-       /* Command for power control of HDMI PHY */
-       REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL, val, 7, 6);
-
-       /* Status of the power control of HDMI PHY */
-       if (hdmi_wait_for_bit_change(hdmi_wp_base(ip_data),
-                               HDMI_WP_PWR_CTRL, 5, 4, val) != val) {
-               pr_err("Failed to set PHY power mode to %d\n", val);
-               return -ETIMEDOUT;
-       }
-
-       return 0;
-}
-
-/* PLL_PWR_CMD */
-static int hdmi_set_pll_pwr(struct hdmi_ip_data *ip_data, enum hdmi_pll_pwr val)
-{
-       /* Command for power control of HDMI PLL */
-       REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL, val, 3, 2);
-
-       /* wait till PHY_PWR_STATUS is set */
-       if (hdmi_wait_for_bit_change(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL,
-                                               1, 0, val) != val) {
-               pr_err("Failed to set PLL_PWR_STATUS\n");
-               return -ETIMEDOUT;
-       }
-
-       return 0;
-}
-
-static int hdmi_pll_reset(struct hdmi_ip_data *ip_data)
-{
-       /* SYSRESET  controlled by power FSM */
-       REG_FLD_MOD(hdmi_pll_base(ip_data), PLLCTRL_PLL_CONTROL, 0x0, 3, 3);
-
-       /* READ 0x0 reset is in progress */
-       if (hdmi_wait_for_bit_change(hdmi_pll_base(ip_data),
-                               PLLCTRL_PLL_STATUS, 0, 0, 1) != 1) {
-               pr_err("Failed to sysreset PLL\n");
-               return -ETIMEDOUT;
-       }
-
-       return 0;
-}
-
-int ti_hdmi_4xxx_pll_enable(struct hdmi_ip_data *ip_data)
-{
-       u16 r = 0;
-
-       r = hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_ALLOFF);
-       if (r)
-               return r;
-
-       r = hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_BOTHON_ALLCLKS);
-       if (r)
-               return r;
-
-       r = hdmi_pll_reset(ip_data);
-       if (r)
-               return r;
-
-       r = hdmi_pll_init(ip_data);
-       if (r)
-               return r;
-
-       return 0;
-}
-
-void ti_hdmi_4xxx_pll_disable(struct hdmi_ip_data *ip_data)
-{
-       hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_ALLOFF);
-}
-
-static irqreturn_t hdmi_irq_handler(int irq, void *data)
-{
-       struct hdmi_ip_data *ip_data = data;
-       void __iomem *wp_base = hdmi_wp_base(ip_data);
-       u32 irqstatus;
-
-       irqstatus = hdmi_read_reg(wp_base, HDMI_WP_IRQSTATUS);
-       hdmi_write_reg(wp_base, HDMI_WP_IRQSTATUS, irqstatus);
-       /* flush posted write */
-       hdmi_read_reg(wp_base, HDMI_WP_IRQSTATUS);
-
-       if ((irqstatus & HDMI_IRQ_LINK_CONNECT) &&
-                       irqstatus & HDMI_IRQ_LINK_DISCONNECT) {
-               /*
-                * If we get both connect and disconnect interrupts at the same
-                * time, turn off the PHY, clear interrupts, and restart, which
-                * raises connect interrupt if a cable is connected, or nothing
-                * if cable is not connected.
-                */
-               hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF);
-
-               hdmi_write_reg(wp_base, HDMI_WP_IRQSTATUS,
-                       HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
-               /* flush posted write */
-               hdmi_read_reg(wp_base, HDMI_WP_IRQSTATUS);
-
-               hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_LDOON);
-       } else if (irqstatus & HDMI_IRQ_LINK_CONNECT) {
-               hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_TXON);
-       } else if (irqstatus & HDMI_IRQ_LINK_DISCONNECT) {
-               hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_LDOON);
-       }
-
-       return IRQ_HANDLED;
-}
-
-int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data)
-{
-       u16 r = 0;
-       void __iomem *phy_base = hdmi_phy_base(ip_data);
-
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_IRQENABLE_CLR,
-                       0xffffffff);
-
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_IRQSTATUS,
-                       HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
-
-       r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_LDOON);
-       if (r)
-               return r;
-
-       /*
-        * Read address 0 in order to get the SCP reset done completed
-        * Dummy access performed to make sure reset is done
-        */
-       hdmi_read_reg(phy_base, HDMI_TXPHY_TX_CTRL);
-
-       /*
-        * Write to phy address 0 to configure the clock
-        * use HFBITCLK write HDMI_TXPHY_TX_CONTROL_FREQOUT field
-        */
-       REG_FLD_MOD(phy_base, HDMI_TXPHY_TX_CTRL, 0x1, 31, 30);
-
-       /* Write to phy address 1 to start HDMI line (TXVALID and TMDSCLKEN) */
-       hdmi_write_reg(phy_base, HDMI_TXPHY_DIGITAL_CTRL, 0xF0000000);
-
-       /* Setup max LDO voltage */
-       REG_FLD_MOD(phy_base, HDMI_TXPHY_POWER_CTRL, 0xB, 3, 0);
-
-       /* Write to phy address 3 to change the polarity control */
-       REG_FLD_MOD(phy_base, HDMI_TXPHY_PAD_CFG_CTRL, 0x1, 27, 27);
-
-       r = request_threaded_irq(ip_data->irq, NULL, hdmi_irq_handler,
-                                IRQF_ONESHOT, "OMAP HDMI", ip_data);
-       if (r) {
-               DSSERR("HDMI IRQ request failed\n");
-               hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF);
-               return r;
-       }
-
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_IRQENABLE_SET,
-                       HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
-
-       return 0;
-}
-
-void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data)
-{
-       free_irq(ip_data->irq, ip_data);
-
-       hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF);
-}
-
-static int hdmi_core_ddc_init(struct hdmi_ip_data *ip_data)
-{
-       void __iomem *base = hdmi_core_sys_base(ip_data);
+       void __iomem *base = core->base;
 
        /* Turn on CLK for DDC */
        REG_FLD_MOD(base, HDMI_CORE_AV_DPD, 0x7, 2, 0);
@@ -370,10 +86,10 @@ static int hdmi_core_ddc_init(struct hdmi_ip_data *ip_data)
        return 0;
 }
 
-static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data,
+static int hdmi_core_ddc_edid(struct hdmi_core_data *core,
                u8 *pedid, int ext)
 {
-       void __iomem *base = hdmi_core_sys_base(ip_data);
+       void __iomem *base = core->base;
        u32 i;
        char checksum;
        u32 offset = 0;
@@ -452,26 +168,25 @@ static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data,
        return 0;
 }
 
-int ti_hdmi_4xxx_read_edid(struct hdmi_ip_data *ip_data,
-                               u8 *edid, int len)
+int hdmi4_read_edid(struct hdmi_core_data *core, u8 *edid, int len)
 {
        int r, l;
 
        if (len < 128)
                return -EINVAL;
 
-       r = hdmi_core_ddc_init(ip_data);
+       r = hdmi_core_ddc_init(core);
        if (r)
                return r;
 
-       r = hdmi_core_ddc_edid(ip_data, edid, 0);
+       r = hdmi_core_ddc_edid(core, edid, 0);
        if (r)
                return r;
 
        l = 128;
 
        if (len >= 128 * 2 && edid[0x7e] > 0) {
-               r = hdmi_core_ddc_edid(ip_data, edid + 0x80, 1);
+               r = hdmi_core_ddc_edid(core, edid + 0x80, 1);
                if (r)
                        return r;
                l += 128;
@@ -508,7 +223,7 @@ static void hdmi_core_init(struct hdmi_core_video_config *video_cfg,
        avi_cfg->db3_nup_scaling = 0;
        avi_cfg->db4_videocode = 0;
        avi_cfg->db5_pixel_repeat = 0;
-       avi_cfg->db6_7_line_eoftop = 0 ;
+       avi_cfg->db6_7_line_eoftop = 0;
        avi_cfg->db8_9_line_sofbottom = 0;
        avi_cfg->db10_11_pixel_eofleft = 0;
        avi_cfg->db12_13_pixel_sofright = 0;
@@ -524,38 +239,39 @@ static void hdmi_core_init(struct hdmi_core_video_config *video_cfg,
        repeat_cfg->generic_pkt_repeat = 0;
 }
 
-static void hdmi_core_powerdown_disable(struct hdmi_ip_data *ip_data)
+static void hdmi_core_powerdown_disable(struct hdmi_core_data *core)
 {
        pr_debug("Enter hdmi_core_powerdown_disable\n");
-       REG_FLD_MOD(hdmi_core_sys_base(ip_data), HDMI_CORE_CTRL1, 0x0, 0, 0);
+       REG_FLD_MOD(core->base, HDMI_CORE_SYS_SYS_CTRL1, 0x0, 0, 0);
 }
 
-static void hdmi_core_swreset_release(struct hdmi_ip_data *ip_data)
+static void hdmi_core_swreset_release(struct hdmi_core_data *core)
 {
        pr_debug("Enter hdmi_core_swreset_release\n");
-       REG_FLD_MOD(hdmi_core_sys_base(ip_data), HDMI_CORE_SYS_SRST, 0x0, 0, 0);
+       REG_FLD_MOD(core->base, HDMI_CORE_SYS_SRST, 0x0, 0, 0);
 }
 
-static void hdmi_core_swreset_assert(struct hdmi_ip_data *ip_data)
+static void hdmi_core_swreset_assert(struct hdmi_core_data *core)
 {
        pr_debug("Enter hdmi_core_swreset_assert\n");
-       REG_FLD_MOD(hdmi_core_sys_base(ip_data), HDMI_CORE_SYS_SRST, 0x1, 0, 0);
+       REG_FLD_MOD(core->base, HDMI_CORE_SYS_SRST, 0x1, 0, 0);
 }
 
 /* HDMI_CORE_VIDEO_CONFIG */
-static void hdmi_core_video_config(struct hdmi_ip_data *ip_data,
+static void hdmi_core_video_config(struct hdmi_core_data *core,
                                struct hdmi_core_video_config *cfg)
 {
        u32 r = 0;
-       void __iomem *core_sys_base = hdmi_core_sys_base(ip_data);
+       void __iomem *core_sys_base = core->base;
+       void __iomem *core_av_base = hdmi_av_base(core);
 
        /* sys_ctrl1 default configuration not tunable */
-       r = hdmi_read_reg(core_sys_base, HDMI_CORE_CTRL1);
-       r = FLD_MOD(r, HDMI_CORE_CTRL1_VEN_FOLLOWVSYNC, 5, 5);
-       r = FLD_MOD(r, HDMI_CORE_CTRL1_HEN_FOLLOWHSYNC, 4, 4);
-       r = FLD_MOD(r, HDMI_CORE_CTRL1_BSEL_24BITBUS, 2, 2);
-       r = FLD_MOD(r, HDMI_CORE_CTRL1_EDGE_RISINGEDGE, 1, 1);
-       hdmi_write_reg(core_sys_base, HDMI_CORE_CTRL1, r);
+       r = hdmi_read_reg(core_sys_base, HDMI_CORE_SYS_SYS_CTRL1);
+       r = FLD_MOD(r, HDMI_CORE_SYS_SYS_CTRL1_VEN_FOLLOWVSYNC, 5, 5);
+       r = FLD_MOD(r, HDMI_CORE_SYS_SYS_CTRL1_HEN_FOLLOWHSYNC, 4, 4);
+       r = FLD_MOD(r, HDMI_CORE_SYS_SYS_CTRL1_BSEL_24BITBUS, 2, 2);
+       r = FLD_MOD(r, HDMI_CORE_SYS_SYS_CTRL1_EDGE_RISINGEDGE, 1, 1);
+       hdmi_write_reg(core_sys_base, HDMI_CORE_SYS_SYS_CTRL1, r);
 
        REG_FLD_MOD(core_sys_base,
                        HDMI_CORE_SYS_VID_ACEN, cfg->ip_bus_width, 7, 6);
@@ -574,23 +290,23 @@ static void hdmi_core_video_config(struct hdmi_ip_data *ip_data,
        hdmi_write_reg(core_sys_base, HDMI_CORE_SYS_VID_MODE, r);
 
        /* HDMI_Ctrl */
-       r = hdmi_read_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_HDMI_CTRL);
+       r = hdmi_read_reg(core_av_base, HDMI_CORE_AV_HDMI_CTRL);
        r = FLD_MOD(r, cfg->deep_color_pkt, 6, 6);
        r = FLD_MOD(r, cfg->pkt_mode, 5, 3);
        r = FLD_MOD(r, cfg->hdmi_dvi, 0, 0);
-       hdmi_write_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_HDMI_CTRL, r);
+       hdmi_write_reg(core_av_base, HDMI_CORE_AV_HDMI_CTRL, r);
 
        /* TMDS_CTRL */
        REG_FLD_MOD(core_sys_base,
                        HDMI_CORE_SYS_TMDS_CTRL, cfg->tclk_sel_clkmult, 6, 5);
 }
 
-static void hdmi_core_aux_infoframe_avi_config(struct hdmi_ip_data *ip_data)
+static void hdmi_core_aux_infoframe_avi_config(struct hdmi_core_data *core)
 {
        u32 val;
        char sum = 0, checksum = 0;
-       void __iomem *av_base = hdmi_av_base(ip_data);
-       struct hdmi_core_infoframe_avi info_avi = ip_data->avi_cfg;
+       void __iomem *av_base = hdmi_av_base(core);
+       struct hdmi_core_infoframe_avi info_avi = core->avi_cfg;
 
        sum += 0x82 + 0x002 + 0x00D;
        hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_TYPE, 0x082);
@@ -661,160 +377,64 @@ static void hdmi_core_aux_infoframe_avi_config(struct hdmi_ip_data *ip_data)
        hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_CHSUM, checksum);
 }
 
-static void hdmi_core_av_packet_config(struct hdmi_ip_data *ip_data,
+static void hdmi_core_av_packet_config(struct hdmi_core_data *core,
                struct hdmi_core_packet_enable_repeat repeat_cfg)
 {
        /* enable/repeat the infoframe */
-       hdmi_write_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_PB_CTRL1,
+       hdmi_write_reg(hdmi_av_base(core), HDMI_CORE_AV_PB_CTRL1,
                (repeat_cfg.audio_pkt << 5) |
                (repeat_cfg.audio_pkt_repeat << 4) |
                (repeat_cfg.avi_infoframe << 1) |
                (repeat_cfg.avi_infoframe_repeat));
 
        /* enable/repeat the packet */
-       hdmi_write_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_PB_CTRL2,
+       hdmi_write_reg(hdmi_av_base(core), HDMI_CORE_AV_PB_CTRL2,
                (repeat_cfg.gen_cntrl_pkt << 3) |
                (repeat_cfg.gen_cntrl_pkt_repeat << 2) |
                (repeat_cfg.generic_pkt << 1) |
                (repeat_cfg.generic_pkt_repeat));
 }
 
-static void hdmi_wp_init(struct omap_video_timings *timings,
-                       struct hdmi_video_format *video_fmt)
-{
-       pr_debug("Enter hdmi_wp_init\n");
-
-       timings->hbp = 0;
-       timings->hfp = 0;
-       timings->hsw = 0;
-       timings->vbp = 0;
-       timings->vfp = 0;
-       timings->vsw = 0;
-
-       video_fmt->packing_mode = HDMI_PACK_10b_RGB_YUV444;
-       video_fmt->y_res = 0;
-       video_fmt->x_res = 0;
-
-}
-
-int ti_hdmi_4xxx_wp_video_start(struct hdmi_ip_data *ip_data)
-{
-       REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, true, 31, 31);
-       return 0;
-}
-
-void ti_hdmi_4xxx_wp_video_stop(struct hdmi_ip_data *ip_data)
-{
-       REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, false, 31, 31);
-}
-
-static void hdmi_wp_video_init_format(struct hdmi_video_format *video_fmt,
-       struct omap_video_timings *timings, struct hdmi_config *param)
-{
-       pr_debug("Enter hdmi_wp_video_init_format\n");
-
-       video_fmt->y_res = param->timings.y_res;
-       video_fmt->x_res = param->timings.x_res;
-
-       timings->hbp = param->timings.hbp;
-       timings->hfp = param->timings.hfp;
-       timings->hsw = param->timings.hsw;
-       timings->vbp = param->timings.vbp;
-       timings->vfp = param->timings.vfp;
-       timings->vsw = param->timings.vsw;
-}
-
-static void hdmi_wp_video_config_format(struct hdmi_ip_data *ip_data,
-               struct hdmi_video_format *video_fmt)
-{
-       u32 l = 0;
-
-       REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG,
-                       video_fmt->packing_mode, 10, 8);
-
-       l |= FLD_VAL(video_fmt->y_res, 31, 16);
-       l |= FLD_VAL(video_fmt->x_res, 15, 0);
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_SIZE, l);
-}
-
-static void hdmi_wp_video_config_interface(struct hdmi_ip_data *ip_data)
-{
-       u32 r;
-       bool vsync_pol, hsync_pol;
-       pr_debug("Enter hdmi_wp_video_config_interface\n");
-
-       vsync_pol = ip_data->cfg.timings.vsync_level == OMAPDSS_SIG_ACTIVE_HIGH;
-       hsync_pol = ip_data->cfg.timings.hsync_level == OMAPDSS_SIG_ACTIVE_HIGH;
-
-       r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG);
-       r = FLD_MOD(r, vsync_pol, 7, 7);
-       r = FLD_MOD(r, hsync_pol, 6, 6);
-       r = FLD_MOD(r, ip_data->cfg.timings.interlace, 3, 3);
-       r = FLD_MOD(r, 1, 1, 0); /* HDMI_TIMING_MASTER_24BIT */
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, r);
-}
-
-static void hdmi_wp_video_config_timing(struct hdmi_ip_data *ip_data,
-               struct omap_video_timings *timings)
-{
-       u32 timing_h = 0;
-       u32 timing_v = 0;
-
-       pr_debug("Enter hdmi_wp_video_config_timing\n");
-
-       timing_h |= FLD_VAL(timings->hbp, 31, 20);
-       timing_h |= FLD_VAL(timings->hfp, 19, 8);
-       timing_h |= FLD_VAL(timings->hsw, 7, 0);
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_TIMING_H, timing_h);
-
-       timing_v |= FLD_VAL(timings->vbp, 31, 20);
-       timing_v |= FLD_VAL(timings->vfp, 19, 8);
-       timing_v |= FLD_VAL(timings->vsw, 7, 0);
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_TIMING_V, timing_v);
-}
-
-void ti_hdmi_4xxx_basic_configure(struct hdmi_ip_data *ip_data)
+void hdmi4_configure(struct hdmi_core_data *core,
+       struct hdmi_wp_data *wp, struct hdmi_config *cfg)
 {
        /* HDMI */
        struct omap_video_timings video_timing;
        struct hdmi_video_format video_format;
        /* HDMI core */
-       struct hdmi_core_infoframe_avi *avi_cfg = &ip_data->avi_cfg;
+       struct hdmi_core_infoframe_avi *avi_cfg = &core->avi_cfg;
        struct hdmi_core_video_config v_core_cfg;
        struct hdmi_core_packet_enable_repeat repeat_cfg;
-       struct hdmi_config *cfg = &ip_data->cfg;
-
-       hdmi_wp_init(&video_timing, &video_format);
 
        hdmi_core_init(&v_core_cfg, avi_cfg, &repeat_cfg);
 
-       hdmi_wp_video_init_format(&video_format, &video_timing, cfg);
+       hdmi_wp_init_vid_fmt_timings(&video_format, &video_timing, cfg);
 
-       hdmi_wp_video_config_timing(ip_data, &video_timing);
+       hdmi_wp_video_config_timing(wp, &video_timing);
 
        /* video config */
        video_format.packing_mode = HDMI_PACK_24b_RGB_YUV444_YUV422;
 
-       hdmi_wp_video_config_format(ip_data, &video_format);
+       hdmi_wp_video_config_format(wp, &video_format);
 
-       hdmi_wp_video_config_interface(ip_data);
+       hdmi_wp_video_config_interface(wp, &video_timing);
 
        /*
         * configure core video part
         * set software reset in the core
         */
-       hdmi_core_swreset_assert(ip_data);
+       hdmi_core_swreset_assert(core);
 
        /* power down off */
-       hdmi_core_powerdown_disable(ip_data);
+       hdmi_core_powerdown_disable(core);
 
        v_core_cfg.pkt_mode = HDMI_PACKETMODE24BITPERPIXEL;
        v_core_cfg.hdmi_dvi = cfg->cm.mode;
 
-       hdmi_core_video_config(ip_data, &v_core_cfg);
+       hdmi_core_video_config(core, &v_core_cfg);
 
        /* release software reset in the core */
-       hdmi_core_swreset_release(ip_data);
+       hdmi_core_swreset_release(core);
 
        /*
         * configure packet
@@ -839,7 +459,7 @@ void ti_hdmi_4xxx_basic_configure(struct hdmi_ip_data *ip_data)
        avi_cfg->db10_11_pixel_eofleft = 0;
        avi_cfg->db12_13_pixel_sofright = 0;
 
-       hdmi_core_aux_infoframe_avi_config(ip_data);
+       hdmi_core_aux_infoframe_avi_config(core);
 
        /* enable/repeat the infoframe */
        repeat_cfg.avi_infoframe = HDMI_PACKETENABLE;
@@ -847,65 +467,30 @@ void ti_hdmi_4xxx_basic_configure(struct hdmi_ip_data *ip_data)
        /* wakeup */
        repeat_cfg.audio_pkt = HDMI_PACKETENABLE;
        repeat_cfg.audio_pkt_repeat = HDMI_PACKETREPEATON;
-       hdmi_core_av_packet_config(ip_data, repeat_cfg);
-}
-
-void ti_hdmi_4xxx_wp_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
-{
-#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r,\
-               hdmi_read_reg(hdmi_wp_base(ip_data), r))
-
-       DUMPREG(HDMI_WP_REVISION);
-       DUMPREG(HDMI_WP_SYSCONFIG);
-       DUMPREG(HDMI_WP_IRQSTATUS_RAW);
-       DUMPREG(HDMI_WP_IRQSTATUS);
-       DUMPREG(HDMI_WP_PWR_CTRL);
-       DUMPREG(HDMI_WP_IRQENABLE_SET);
-       DUMPREG(HDMI_WP_VIDEO_CFG);
-       DUMPREG(HDMI_WP_VIDEO_SIZE);
-       DUMPREG(HDMI_WP_VIDEO_TIMING_H);
-       DUMPREG(HDMI_WP_VIDEO_TIMING_V);
-       DUMPREG(HDMI_WP_WP_CLK);
-       DUMPREG(HDMI_WP_AUDIO_CFG);
-       DUMPREG(HDMI_WP_AUDIO_CFG2);
-       DUMPREG(HDMI_WP_AUDIO_CTRL);
-       DUMPREG(HDMI_WP_AUDIO_DATA);
-}
-
-void ti_hdmi_4xxx_pll_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
-{
-#define DUMPPLL(r) seq_printf(s, "%-35s %08x\n", #r,\
-               hdmi_read_reg(hdmi_pll_base(ip_data), r))
-
-       DUMPPLL(PLLCTRL_PLL_CONTROL);
-       DUMPPLL(PLLCTRL_PLL_STATUS);
-       DUMPPLL(PLLCTRL_PLL_GO);
-       DUMPPLL(PLLCTRL_CFG1);
-       DUMPPLL(PLLCTRL_CFG2);
-       DUMPPLL(PLLCTRL_CFG3);
-       DUMPPLL(PLLCTRL_CFG4);
+       hdmi_core_av_packet_config(core, repeat_cfg);
 }
 
-void ti_hdmi_4xxx_core_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
+void hdmi4_core_dump(struct hdmi_core_data *core, struct seq_file *s)
 {
        int i;
 
 #define CORE_REG(i, name) name(i)
 #define DUMPCORE(r) seq_printf(s, "%-35s %08x\n", #r,\
-               hdmi_read_reg(hdmi_core_sys_base(ip_data), r))
+               hdmi_read_reg(core->base, r))
 #define DUMPCOREAV(r) seq_printf(s, "%-35s %08x\n", #r,\
-               hdmi_read_reg(hdmi_av_base(ip_data), r))
+               hdmi_read_reg(hdmi_av_base(core), r))
 #define DUMPCOREAV2(i, r) seq_printf(s, "%s[%d]%*s %08x\n", #r, i, \
                (i < 10) ? 32 - (int)strlen(#r) : 31 - (int)strlen(#r), " ", \
-               hdmi_read_reg(hdmi_av_base(ip_data), CORE_REG(i, r)))
+               hdmi_read_reg(hdmi_av_base(core), CORE_REG(i, r)))
 
        DUMPCORE(HDMI_CORE_SYS_VND_IDL);
        DUMPCORE(HDMI_CORE_SYS_DEV_IDL);
        DUMPCORE(HDMI_CORE_SYS_DEV_IDH);
        DUMPCORE(HDMI_CORE_SYS_DEV_REV);
        DUMPCORE(HDMI_CORE_SYS_SRST);
-       DUMPCORE(HDMI_CORE_CTRL1);
+       DUMPCORE(HDMI_CORE_SYS_SYS_CTRL1);
        DUMPCORE(HDMI_CORE_SYS_SYS_STAT);
+       DUMPCORE(HDMI_CORE_SYS_SYS_CTRL3);
        DUMPCORE(HDMI_CORE_SYS_DE_DLY);
        DUMPCORE(HDMI_CORE_SYS_DE_CTRL);
        DUMPCORE(HDMI_CORE_SYS_DE_TOP);
@@ -913,14 +498,58 @@ void ti_hdmi_4xxx_core_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
        DUMPCORE(HDMI_CORE_SYS_DE_CNTH);
        DUMPCORE(HDMI_CORE_SYS_DE_LINL);
        DUMPCORE(HDMI_CORE_SYS_DE_LINH_1);
+       DUMPCORE(HDMI_CORE_SYS_HRES_L);
+       DUMPCORE(HDMI_CORE_SYS_HRES_H);
+       DUMPCORE(HDMI_CORE_SYS_VRES_L);
+       DUMPCORE(HDMI_CORE_SYS_VRES_H);
+       DUMPCORE(HDMI_CORE_SYS_IADJUST);
+       DUMPCORE(HDMI_CORE_SYS_POLDETECT);
+       DUMPCORE(HDMI_CORE_SYS_HWIDTH1);
+       DUMPCORE(HDMI_CORE_SYS_HWIDTH2);
+       DUMPCORE(HDMI_CORE_SYS_VWIDTH);
+       DUMPCORE(HDMI_CORE_SYS_VID_CTRL);
        DUMPCORE(HDMI_CORE_SYS_VID_ACEN);
        DUMPCORE(HDMI_CORE_SYS_VID_MODE);
+       DUMPCORE(HDMI_CORE_SYS_VID_BLANK1);
+       DUMPCORE(HDMI_CORE_SYS_VID_BLANK3);
+       DUMPCORE(HDMI_CORE_SYS_VID_BLANK1);
+       DUMPCORE(HDMI_CORE_SYS_DC_HEADER);
+       DUMPCORE(HDMI_CORE_SYS_VID_DITHER);
+       DUMPCORE(HDMI_CORE_SYS_RGB2XVYCC_CT);
+       DUMPCORE(HDMI_CORE_SYS_R2Y_COEFF_LOW);
+       DUMPCORE(HDMI_CORE_SYS_R2Y_COEFF_UP);
+       DUMPCORE(HDMI_CORE_SYS_G2Y_COEFF_LOW);
+       DUMPCORE(HDMI_CORE_SYS_G2Y_COEFF_UP);
+       DUMPCORE(HDMI_CORE_SYS_B2Y_COEFF_LOW);
+       DUMPCORE(HDMI_CORE_SYS_B2Y_COEFF_UP);
+       DUMPCORE(HDMI_CORE_SYS_R2CB_COEFF_LOW);
+       DUMPCORE(HDMI_CORE_SYS_R2CB_COEFF_UP);
+       DUMPCORE(HDMI_CORE_SYS_G2CB_COEFF_LOW);
+       DUMPCORE(HDMI_CORE_SYS_G2CB_COEFF_UP);
+       DUMPCORE(HDMI_CORE_SYS_B2CB_COEFF_LOW);
+       DUMPCORE(HDMI_CORE_SYS_B2CB_COEFF_UP);
+       DUMPCORE(HDMI_CORE_SYS_R2CR_COEFF_LOW);
+       DUMPCORE(HDMI_CORE_SYS_R2CR_COEFF_UP);
+       DUMPCORE(HDMI_CORE_SYS_G2CR_COEFF_LOW);
+       DUMPCORE(HDMI_CORE_SYS_G2CR_COEFF_UP);
+       DUMPCORE(HDMI_CORE_SYS_B2CR_COEFF_LOW);
+       DUMPCORE(HDMI_CORE_SYS_B2CR_COEFF_UP);
+       DUMPCORE(HDMI_CORE_SYS_RGB_OFFSET_LOW);
+       DUMPCORE(HDMI_CORE_SYS_RGB_OFFSET_UP);
+       DUMPCORE(HDMI_CORE_SYS_Y_OFFSET_LOW);
+       DUMPCORE(HDMI_CORE_SYS_Y_OFFSET_UP);
+       DUMPCORE(HDMI_CORE_SYS_CBCR_OFFSET_LOW);
+       DUMPCORE(HDMI_CORE_SYS_CBCR_OFFSET_UP);
        DUMPCORE(HDMI_CORE_SYS_INTR_STATE);
        DUMPCORE(HDMI_CORE_SYS_INTR1);
        DUMPCORE(HDMI_CORE_SYS_INTR2);
        DUMPCORE(HDMI_CORE_SYS_INTR3);
        DUMPCORE(HDMI_CORE_SYS_INTR4);
-       DUMPCORE(HDMI_CORE_SYS_UMASK1);
+       DUMPCORE(HDMI_CORE_SYS_INTR_UNMASK1);
+       DUMPCORE(HDMI_CORE_SYS_INTR_UNMASK2);
+       DUMPCORE(HDMI_CORE_SYS_INTR_UNMASK3);
+       DUMPCORE(HDMI_CORE_SYS_INTR_UNMASK4);
+       DUMPCORE(HDMI_CORE_SYS_INTR_CTRL);
        DUMPCORE(HDMI_CORE_SYS_TMDS_CTRL);
 
        DUMPCORE(HDMI_CORE_DDC_ADDR);
@@ -1009,60 +638,12 @@ void ti_hdmi_4xxx_core_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
        DUMPCOREAV(HDMI_CORE_AV_CEC_ADDR_ID);
 }
 
-void ti_hdmi_4xxx_phy_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
-{
-#define DUMPPHY(r) seq_printf(s, "%-35s %08x\n", #r,\
-               hdmi_read_reg(hdmi_phy_base(ip_data), r))
-
-       DUMPPHY(HDMI_TXPHY_TX_CTRL);
-       DUMPPHY(HDMI_TXPHY_DIGITAL_CTRL);
-       DUMPPHY(HDMI_TXPHY_POWER_CTRL);
-       DUMPPHY(HDMI_TXPHY_PAD_CFG_CTRL);
-}
-
 #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
-static void ti_hdmi_4xxx_wp_audio_config_format(struct hdmi_ip_data *ip_data,
-                                       struct hdmi_audio_format *aud_fmt)
-{
-       u32 r;
-
-       DSSDBG("Enter hdmi_wp_audio_config_format\n");
-
-       r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG);
-       r = FLD_MOD(r, aud_fmt->stereo_channels, 26, 24);
-       r = FLD_MOD(r, aud_fmt->active_chnnls_msk, 23, 16);
-       r = FLD_MOD(r, aud_fmt->en_sig_blk_strt_end, 5, 5);
-       r = FLD_MOD(r, aud_fmt->type, 4, 4);
-       r = FLD_MOD(r, aud_fmt->justification, 3, 3);
-       r = FLD_MOD(r, aud_fmt->sample_order, 2, 2);
-       r = FLD_MOD(r, aud_fmt->samples_per_word, 1, 1);
-       r = FLD_MOD(r, aud_fmt->sample_size, 0, 0);
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG, r);
-}
-
-static void ti_hdmi_4xxx_wp_audio_config_dma(struct hdmi_ip_data *ip_data,
-                                       struct hdmi_audio_dma *aud_dma)
-{
-       u32 r;
-
-       DSSDBG("Enter hdmi_wp_audio_config_dma\n");
-
-       r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG2);
-       r = FLD_MOD(r, aud_dma->transfer_size, 15, 8);
-       r = FLD_MOD(r, aud_dma->block_size, 7, 0);
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG2, r);
-
-       r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CTRL);
-       r = FLD_MOD(r, aud_dma->mode, 9, 9);
-       r = FLD_MOD(r, aud_dma->fifo_threshold, 8, 0);
-       hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CTRL, r);
-}
-
-static void ti_hdmi_4xxx_core_audio_config(struct hdmi_ip_data *ip_data,
+static void hdmi_core_audio_config(struct hdmi_core_data *core,
                                        struct hdmi_core_audio_config *cfg)
 {
        u32 r;
-       void __iomem *av_base = hdmi_av_base(ip_data);
+       void __iomem *av_base = hdmi_av_base(core);
 
        /*
         * Parameters for generation of Audio Clock Recovery packets
@@ -1157,11 +738,11 @@ static void ti_hdmi_4xxx_core_audio_config(struct hdmi_ip_data *ip_data,
        REG_FLD_MOD(av_base, HDMI_CORE_AV_SWAP_I2S, 1, 5, 5);
 }
 
-static void ti_hdmi_4xxx_core_audio_infoframe_cfg(struct hdmi_ip_data *ip_data,
+static void hdmi_core_audio_infoframe_cfg(struct hdmi_core_data *core,
                struct snd_cea_861_aud_if *info_aud)
 {
        u8 sum = 0, checksum = 0;
-       void __iomem *av_base = hdmi_av_base(ip_data);
+       void __iomem *av_base = hdmi_av_base(core);
 
        /*
         * Set audio info frame type, version and length as
@@ -1207,20 +788,20 @@ static void ti_hdmi_4xxx_core_audio_infoframe_cfg(struct hdmi_ip_data *ip_data,
         */
 }
 
-int ti_hdmi_4xxx_audio_config(struct hdmi_ip_data *ip_data,
-               struct omap_dss_audio *audio)
+int hdmi4_audio_config(struct hdmi_core_data *core, struct hdmi_wp_data *wp,
+               struct omap_dss_audio *audio, u32 pclk)
 {
        struct hdmi_audio_format audio_format;
        struct hdmi_audio_dma audio_dma;
-       struct hdmi_core_audio_config core;
+       struct hdmi_core_audio_config acore;
        int err, n, cts, channel_count;
        unsigned int fs_nr;
        bool word_length_16b = false;
 
-       if (!audio || !audio->iec || !audio->cea || !ip_data)
+       if (!audio || !audio->iec || !audio->cea || !core)
                return -EINVAL;
 
-       core.iec60958_cfg = audio->iec;
+       acore.iec60958_cfg = audio->iec;
        /*
         * In the IEC-60958 status word, check if the audio sample word length
         * is 16-bit as several optimizations can be performed in such case.
@@ -1231,22 +812,22 @@ int ti_hdmi_4xxx_audio_config(struct hdmi_ip_data *ip_data,
 
        /* I2S configuration. See Phillips' specification */
        if (word_length_16b)
-               core.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_LEFT;
+               acore.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_LEFT;
        else
-               core.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_RIGHT;
+               acore.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_RIGHT;
        /*
         * The I2S input word length is twice the lenght given in the IEC-60958
         * status word. If the word size is greater than
         * 20 bits, increment by one.
         */
-       core.i2s_cfg.in_length_bits = audio->iec->status[4]
+       acore.i2s_cfg.in_length_bits = audio->iec->status[4]
                & IEC958_AES4_CON_WORDLEN;
        if (audio->iec->status[4] & IEC958_AES4_CON_MAX_WORDLEN_24)
-               core.i2s_cfg.in_length_bits++;
-       core.i2s_cfg.sck_edge_mode = HDMI_AUDIO_I2S_SCK_EDGE_RISING;
-       core.i2s_cfg.vbit = HDMI_AUDIO_I2S_VBIT_FOR_PCM;
-       core.i2s_cfg.direction = HDMI_AUDIO_I2S_MSB_SHIFTED_FIRST;
-       core.i2s_cfg.shift = HDMI_AUDIO_I2S_FIRST_BIT_SHIFT;
+               acore.i2s_cfg.in_length_bits++;
+       acore.i2s_cfg.sck_edge_mode = HDMI_AUDIO_I2S_SCK_EDGE_RISING;
+       acore.i2s_cfg.vbit = HDMI_AUDIO_I2S_VBIT_FOR_PCM;
+       acore.i2s_cfg.direction = HDMI_AUDIO_I2S_MSB_SHIFTED_FIRST;
+       acore.i2s_cfg.shift = HDMI_AUDIO_I2S_FIRST_BIT_SHIFT;
 
        /* convert sample frequency to a number */
        switch (audio->iec->status[3] & IEC958_AES3_CON_FS) {
@@ -1275,23 +856,23 @@ int ti_hdmi_4xxx_audio_config(struct hdmi_ip_data *ip_data,
                return -EINVAL;
        }
 
-       err = hdmi_compute_acr(fs_nr, &n, &cts);
+       err = hdmi_compute_acr(pclk, fs_nr, &n, &cts);
 
        /* Audio clock regeneration settings */
-       core.n = n;
-       core.cts = cts;
+       acore.n = n;
+       acore.cts = cts;
        if (dss_has_feature(FEAT_HDMI_CTS_SWMODE)) {
-               core.aud_par_busclk = 0;
-               core.cts_mode = HDMI_AUDIO_CTS_MODE_SW;
-               core.use_mclk = dss_has_feature(FEAT_HDMI_AUDIO_USE_MCLK);
+               acore.aud_par_busclk = 0;
+               acore.cts_mode = HDMI_AUDIO_CTS_MODE_SW;
+               acore.use_mclk = dss_has_feature(FEAT_HDMI_AUDIO_USE_MCLK);
        } else {
-               core.aud_par_busclk = (((128 * 31) - 1) << 8);
-               core.cts_mode = HDMI_AUDIO_CTS_MODE_HW;
-               core.use_mclk = true;
+               acore.aud_par_busclk = (((128 * 31) - 1) << 8);
+               acore.cts_mode = HDMI_AUDIO_CTS_MODE_HW;
+               acore.use_mclk = true;
        }
 
-       if (core.use_mclk)
-               core.mclk_mode = HDMI_AUDIO_MCLK_128FS;
+       if (acore.use_mclk)
+               acore.mclk_mode = HDMI_AUDIO_MCLK_128FS;
 
        /* Audio channels settings */
        channel_count = (audio->cea->db1_ct_cc &
@@ -1329,25 +910,25 @@ int ti_hdmi_4xxx_audio_config(struct hdmi_ip_data *ip_data,
         */
        if (channel_count == 2) {
                audio_format.stereo_channels = HDMI_AUDIO_STEREO_ONECHANNEL;
-               core.i2s_cfg.active_sds = HDMI_AUDIO_I2S_SD0_EN;
-               core.layout = HDMI_AUDIO_LAYOUT_2CH;
+               acore.i2s_cfg.active_sds = HDMI_AUDIO_I2S_SD0_EN;
+               acore.layout = HDMI_AUDIO_LAYOUT_2CH;
        } else {
                audio_format.stereo_channels = HDMI_AUDIO_STEREO_FOURCHANNELS;
-               core.i2s_cfg.active_sds = HDMI_AUDIO_I2S_SD0_EN |
+               acore.i2s_cfg.active_sds = HDMI_AUDIO_I2S_SD0_EN |
                                HDMI_AUDIO_I2S_SD1_EN | HDMI_AUDIO_I2S_SD2_EN |
                                HDMI_AUDIO_I2S_SD3_EN;
-               core.layout = HDMI_AUDIO_LAYOUT_8CH;
+               acore.layout = HDMI_AUDIO_LAYOUT_8CH;
        }
 
-       core.en_spdif = false;
+       acore.en_spdif = false;
        /* use sample frequency from channel status word */
-       core.fs_override = true;
+       acore.fs_override = true;
        /* enable ACR packets */
-       core.en_acr_pkt = true;
+       acore.en_acr_pkt = true;
        /* disable direct streaming digital audio */
-       core.en_dsd_audio = false;
+       acore.en_dsd_audio = false;
        /* use parallel audio interface */
-       core.en_parallel_aud_input = true;
+       acore.en_parallel_aud_input = true;
 
        /* DMA settings */
        if (word_length_16b)
@@ -1374,49 +955,37 @@ int ti_hdmi_4xxx_audio_config(struct hdmi_ip_data *ip_data,
        audio_format.en_sig_blk_strt_end = HDMI_AUDIO_BLOCK_SIG_STARTEND_ON;
 
        /* configure DMA and audio FIFO format*/
-       ti_hdmi_4xxx_wp_audio_config_dma(ip_data, &audio_dma);
-       ti_hdmi_4xxx_wp_audio_config_format(ip_data, &audio_format);
+       hdmi_wp_audio_config_dma(wp, &audio_dma);
+       hdmi_wp_audio_config_format(wp, &audio_format);
 
        /* configure the core*/
-       ti_hdmi_4xxx_core_audio_config(ip_data, &core);
+       hdmi_core_audio_config(core, &acore);
 
        /* configure CEA 861 audio infoframe*/
-       ti_hdmi_4xxx_core_audio_infoframe_cfg(ip_data, audio->cea);
+       hdmi_core_audio_infoframe_cfg(core, audio->cea);
 
        return 0;
 }
 
-int ti_hdmi_4xxx_wp_audio_enable(struct hdmi_ip_data *ip_data)
+int hdmi4_audio_start(struct hdmi_core_data *core, struct hdmi_wp_data *wp)
 {
-       REG_FLD_MOD(hdmi_wp_base(ip_data),
-                   HDMI_WP_AUDIO_CTRL, true, 31, 31);
-       return 0;
-}
+       REG_FLD_MOD(hdmi_av_base(core),
+                   HDMI_CORE_AV_AUD_MODE, true, 0, 0);
 
-void ti_hdmi_4xxx_wp_audio_disable(struct hdmi_ip_data *ip_data)
-{
-       REG_FLD_MOD(hdmi_wp_base(ip_data),
-                   HDMI_WP_AUDIO_CTRL, false, 31, 31);
-}
+       hdmi_wp_audio_core_req_enable(wp, true);
 
-int ti_hdmi_4xxx_audio_start(struct hdmi_ip_data *ip_data)
-{
-       REG_FLD_MOD(hdmi_av_base(ip_data),
-                   HDMI_CORE_AV_AUD_MODE, true, 0, 0);
-       REG_FLD_MOD(hdmi_wp_base(ip_data),
-                   HDMI_WP_AUDIO_CTRL, true, 30, 30);
        return 0;
 }
 
-void ti_hdmi_4xxx_audio_stop(struct hdmi_ip_data *ip_data)
+void hdmi4_audio_stop(struct hdmi_core_data *core, struct hdmi_wp_data *wp)
 {
-       REG_FLD_MOD(hdmi_av_base(ip_data),
+       REG_FLD_MOD(hdmi_av_base(core),
                    HDMI_CORE_AV_AUD_MODE, false, 0, 0);
-       REG_FLD_MOD(hdmi_wp_base(ip_data),
-                   HDMI_WP_AUDIO_CTRL, false, 30, 30);
+
+       hdmi_wp_audio_core_req_enable(wp, false);
 }
 
-int ti_hdmi_4xxx_audio_get_dma_port(u32 *offset, u32 *size)
+int hdmi4_audio_get_dma_port(u32 *offset, u32 *size)
 {
        if (!offset || !size)
                return -EINVAL;
@@ -1424,4 +993,42 @@ int ti_hdmi_4xxx_audio_get_dma_port(u32 *offset, u32 *size)
        *size = 4;
        return 0;
 }
+
 #endif
+
+#define CORE_OFFSET            0x400
+#define CORE_SIZE              0xc00
+
+int hdmi4_core_init(struct platform_device *pdev, struct hdmi_core_data *core)
+{
+       struct resource *res;
+       struct resource temp_res;
+
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi_core");
+       if (!res) {
+               DSSDBG("can't get CORE mem resource by name\n");
+               /*
+                * if hwmod/DT doesn't have the memory resource information
+                * split into HDMI sub blocks by name, we try again by getting
+                * the platform's first resource. this code will be removed when
+                * the driver can get the mem resources by name
+                */
+               res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+               if (!res) {
+                       DSSERR("can't get CORE mem resource\n");
+                       return -EINVAL;
+               }
+
+               temp_res.start = res->start + CORE_OFFSET;
+               temp_res.end = temp_res.start + CORE_SIZE - 1;
+               res = &temp_res;
+       }
+
+       core->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+       if (!core->base) {
+               DSSERR("can't ioremap CORE\n");
+               return -ENOMEM;
+       }
+
+       return 0;
+}
similarity index 51%
rename from drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h
rename to drivers/video/omap2/dss/hdmi4_core.h
index 6ef2f929a76d7fa59be556adc6aee7141bfb0809..bb646896fa82d6bedc31fa5a73850351e74a605f 100644 (file)
@@ -1,7 +1,5 @@
 /*
- * ti_hdmi_4xxx_ip.h
- *
- * HDMI header definition for DM81xx, DM38xx, TI OMAP4 etc processors.
+ * HDMI header definition for OMAP4 HDMI core IP
  *
  * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
  *
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef _HDMI_TI_4xxx_H_
-#define _HDMI_TI_4xxx_H_
-
-#include <linux/string.h>
-#include <video/omapdss.h>
-#include "ti_hdmi.h"
-
-/* HDMI Wrapper */
+#ifndef _HDMI4_CORE_H_
+#define _HDMI4_CORE_H_
 
-#define HDMI_WP_REVISION                       0x0
-#define HDMI_WP_SYSCONFIG                      0x10
-#define HDMI_WP_IRQSTATUS_RAW                  0x24
-#define HDMI_WP_IRQSTATUS                      0x28
-#define HDMI_WP_PWR_CTRL                       0x40
-#define HDMI_WP_IRQENABLE_SET                  0x2C
-#define HDMI_WP_IRQENABLE_CLR                  0x30
-#define HDMI_WP_VIDEO_CFG                      0x50
-#define HDMI_WP_VIDEO_SIZE                     0x60
-#define HDMI_WP_VIDEO_TIMING_H                 0x68
-#define HDMI_WP_VIDEO_TIMING_V                 0x6C
-#define HDMI_WP_WP_CLK                         0x70
-#define HDMI_WP_AUDIO_CFG                      0x80
-#define HDMI_WP_AUDIO_CFG2                     0x84
-#define HDMI_WP_AUDIO_CTRL                     0x88
-#define HDMI_WP_AUDIO_DATA                     0x8C
+#include "hdmi.h"
 
-/* HDMI IP Core System */
+/* OMAP4 HDMI IP Core System */
 
 #define HDMI_CORE_SYS_VND_IDL                  0x0
 #define HDMI_CORE_SYS_DEV_IDL                  0x8
 #define HDMI_CORE_SYS_DEV_IDH                  0xC
 #define HDMI_CORE_SYS_DEV_REV                  0x10
 #define HDMI_CORE_SYS_SRST                     0x14
-#define HDMI_CORE_CTRL1                                0x20
+#define HDMI_CORE_SYS_SYS_CTRL1                        0x20
 #define HDMI_CORE_SYS_SYS_STAT                 0x24
+#define HDMI_CORE_SYS_SYS_CTRL3                        0x28
+#define HDMI_CORE_SYS_DCTL                     0x34
 #define HDMI_CORE_SYS_DE_DLY                   0xC8
 #define HDMI_CORE_SYS_DE_CTRL                  0xCC
 #define HDMI_CORE_SYS_DE_TOP                   0xD0
 #define HDMI_CORE_SYS_DE_CNTH                  0xDC
 #define HDMI_CORE_SYS_DE_LINL                  0xE0
 #define HDMI_CORE_SYS_DE_LINH_1                        0xE4
+#define HDMI_CORE_SYS_HRES_L                   0xE8
+#define HDMI_CORE_SYS_HRES_H                   0xEC
+#define HDMI_CORE_SYS_VRES_L                   0xF0
+#define HDMI_CORE_SYS_VRES_H                   0xF4
+#define HDMI_CORE_SYS_IADJUST                  0xF8
+#define HDMI_CORE_SYS_POLDETECT                        0xFC
+#define HDMI_CORE_SYS_HWIDTH1                  0x110
+#define HDMI_CORE_SYS_HWIDTH2                  0x114
+#define HDMI_CORE_SYS_VWIDTH                   0x11C
+#define HDMI_CORE_SYS_VID_CTRL                 0x120
 #define HDMI_CORE_SYS_VID_ACEN                 0x124
 #define HDMI_CORE_SYS_VID_MODE                 0x128
+#define HDMI_CORE_SYS_VID_BLANK1               0x12C
+#define HDMI_CORE_SYS_VID_BLANK2               0x130
+#define HDMI_CORE_SYS_VID_BLANK3               0x134
+#define HDMI_CORE_SYS_DC_HEADER                        0x138
+#define HDMI_CORE_SYS_VID_DITHER               0x13C
+#define HDMI_CORE_SYS_RGB2XVYCC_CT             0x140
+#define HDMI_CORE_SYS_R2Y_COEFF_LOW            0x144
+#define HDMI_CORE_SYS_R2Y_COEFF_UP             0x148
+#define HDMI_CORE_SYS_G2Y_COEFF_LOW            0x14C
+#define HDMI_CORE_SYS_G2Y_COEFF_UP             0x150
+#define HDMI_CORE_SYS_B2Y_COEFF_LOW            0x154
+#define HDMI_CORE_SYS_B2Y_COEFF_UP             0x158
+#define HDMI_CORE_SYS_R2CB_COEFF_LOW           0x15C
+#define HDMI_CORE_SYS_R2CB_COEFF_UP            0x160
+#define HDMI_CORE_SYS_G2CB_COEFF_LOW           0x164
+#define HDMI_CORE_SYS_G2CB_COEFF_UP            0x168
+#define HDMI_CORE_SYS_B2CB_COEFF_LOW           0x16C
+#define HDMI_CORE_SYS_B2CB_COEFF_UP            0x170
+#define HDMI_CORE_SYS_R2CR_COEFF_LOW           0x174
+#define HDMI_CORE_SYS_R2CR_COEFF_UP            0x178
+#define HDMI_CORE_SYS_G2CR_COEFF_LOW           0x17C
+#define HDMI_CORE_SYS_G2CR_COEFF_UP            0x180
+#define HDMI_CORE_SYS_B2CR_COEFF_LOW           0x184
+#define HDMI_CORE_SYS_B2CR_COEFF_UP            0x188
+#define HDMI_CORE_SYS_RGB_OFFSET_LOW           0x18C
+#define HDMI_CORE_SYS_RGB_OFFSET_UP            0x190
+#define HDMI_CORE_SYS_Y_OFFSET_LOW             0x194
+#define HDMI_CORE_SYS_Y_OFFSET_UP              0x198
+#define HDMI_CORE_SYS_CBCR_OFFSET_LOW          0x19C
+#define HDMI_CORE_SYS_CBCR_OFFSET_UP           0x1A0
 #define HDMI_CORE_SYS_INTR_STATE               0x1C0
 #define HDMI_CORE_SYS_INTR1                    0x1C4
 #define HDMI_CORE_SYS_INTR2                    0x1C8
 #define HDMI_CORE_SYS_INTR3                    0x1CC
 #define HDMI_CORE_SYS_INTR4                    0x1D0
-#define HDMI_CORE_SYS_UMASK1                   0x1D4
+#define HDMI_CORE_SYS_INTR_UNMASK1             0x1D4
+#define HDMI_CORE_SYS_INTR_UNMASK2             0x1D8
+#define HDMI_CORE_SYS_INTR_UNMASK3             0x1DC
+#define HDMI_CORE_SYS_INTR_UNMASK4             0x1E0
+#define HDMI_CORE_SYS_INTR_CTRL                        0x1E4
 #define HDMI_CORE_SYS_TMDS_CTRL                        0x208
 
-#define HDMI_CORE_CTRL1_VEN_FOLLOWVSYNC        0x1
-#define HDMI_CORE_CTRL1_HEN_FOLLOWHSYNC        0x1
-#define HDMI_CORE_CTRL1_BSEL_24BITBUS  0x1
-#define HDMI_CORE_CTRL1_EDGE_RISINGEDGE        0x1
+/* value definitions for HDMI_CORE_SYS_SYS_CTRL1 fields */
+#define HDMI_CORE_SYS_SYS_CTRL1_VEN_FOLLOWVSYNC        0x1
+#define HDMI_CORE_SYS_SYS_CTRL1_HEN_FOLLOWHSYNC        0x1
+#define HDMI_CORE_SYS_SYS_CTRL1_BSEL_24BITBUS  0x1
+#define HDMI_CORE_SYS_SYS_CTRL1_EDGE_RISINGEDGE        0x1
 
 /* HDMI DDC E-DID */
 #define HDMI_CORE_DDC_ADDR                     0x3B4
 #define HDMI_CORE_AV_GEN_DBYTE_NELEMS          31
 #define HDMI_CORE_AV_GEN2_DBYTE_NELEMS         31
 
-/* PLL */
-
-#define PLLCTRL_PLL_CONTROL                    0x0
-#define PLLCTRL_PLL_STATUS                     0x4
-#define PLLCTRL_PLL_GO                         0x8
-#define PLLCTRL_CFG1                           0xC
-#define PLLCTRL_CFG2                           0x10
-#define PLLCTRL_CFG3                           0x14
-#define PLLCTRL_CFG4                           0x20
-
-/* HDMI PHY */
-
-#define HDMI_TXPHY_TX_CTRL                     0x0
-#define HDMI_TXPHY_DIGITAL_CTRL                        0x4
-#define HDMI_TXPHY_POWER_CTRL                  0x8
-#define HDMI_TXPHY_PAD_CFG_CTRL                        0xC
-
-#define REG_FLD_MOD(base, idx, val, start, end) \
-       hdmi_write_reg(base, idx, FLD_MOD(hdmi_read_reg(base, idx),\
-                                                       val, start, end))
-#define REG_GET(base, idx, start, end) \
-       FLD_GET(hdmi_read_reg(base, idx), start, end)
-
-enum hdmi_phy_pwr {
-       HDMI_PHYPWRCMD_OFF = 0,
-       HDMI_PHYPWRCMD_LDOON = 1,
-       HDMI_PHYPWRCMD_TXON = 2
-};
-
 enum hdmi_core_inputbus_width {
        HDMI_INPUT_8BIT = 0,
        HDMI_INPUT_10BIT = 1,
@@ -229,114 +224,6 @@ enum hdmi_core_packet_ctrl {
        HDMI_PACKETREPEATOFF = 0
 };
 
-/* INFOFRAME_AVI_ and INFOFRAME_AUDIO_ definitions */
-enum hdmi_core_infoframe {
-       HDMI_INFOFRAME_AVI_DB1Y_RGB = 0,
-       HDMI_INFOFRAME_AVI_DB1Y_YUV422 = 1,
-       HDMI_INFOFRAME_AVI_DB1Y_YUV444 = 2,
-       HDMI_INFOFRAME_AVI_DB1A_ACTIVE_FORMAT_OFF = 0,
-       HDMI_INFOFRAME_AVI_DB1A_ACTIVE_FORMAT_ON =  1,
-       HDMI_INFOFRAME_AVI_DB1B_NO = 0,
-       HDMI_INFOFRAME_AVI_DB1B_VERT = 1,
-       HDMI_INFOFRAME_AVI_DB1B_HORI = 2,
-       HDMI_INFOFRAME_AVI_DB1B_VERTHORI = 3,
-       HDMI_INFOFRAME_AVI_DB1S_0 = 0,
-       HDMI_INFOFRAME_AVI_DB1S_1 = 1,
-       HDMI_INFOFRAME_AVI_DB1S_2 = 2,
-       HDMI_INFOFRAME_AVI_DB2C_NO = 0,
-       HDMI_INFOFRAME_AVI_DB2C_ITU601 = 1,
-       HDMI_INFOFRAME_AVI_DB2C_ITU709 = 2,
-       HDMI_INFOFRAME_AVI_DB2C_EC_EXTENDED = 3,
-       HDMI_INFOFRAME_AVI_DB2M_NO = 0,
-       HDMI_INFOFRAME_AVI_DB2M_43 = 1,
-       HDMI_INFOFRAME_AVI_DB2M_169 = 2,
-       HDMI_INFOFRAME_AVI_DB2R_SAME = 8,
-       HDMI_INFOFRAME_AVI_DB2R_43 = 9,
-       HDMI_INFOFRAME_AVI_DB2R_169 = 10,
-       HDMI_INFOFRAME_AVI_DB2R_149 = 11,
-       HDMI_INFOFRAME_AVI_DB3ITC_NO = 0,
-       HDMI_INFOFRAME_AVI_DB3ITC_YES = 1,
-       HDMI_INFOFRAME_AVI_DB3EC_XVYUV601 = 0,
-       HDMI_INFOFRAME_AVI_DB3EC_XVYUV709 = 1,
-       HDMI_INFOFRAME_AVI_DB3Q_DEFAULT = 0,
-       HDMI_INFOFRAME_AVI_DB3Q_LR = 1,
-       HDMI_INFOFRAME_AVI_DB3Q_FR = 2,
-       HDMI_INFOFRAME_AVI_DB3SC_NO = 0,
-       HDMI_INFOFRAME_AVI_DB3SC_HORI = 1,
-       HDMI_INFOFRAME_AVI_DB3SC_VERT = 2,
-       HDMI_INFOFRAME_AVI_DB3SC_HORIVERT = 3,
-       HDMI_INFOFRAME_AVI_DB5PR_NO = 0,
-       HDMI_INFOFRAME_AVI_DB5PR_2 = 1,
-       HDMI_INFOFRAME_AVI_DB5PR_3 = 2,
-       HDMI_INFOFRAME_AVI_DB5PR_4 = 3,
-       HDMI_INFOFRAME_AVI_DB5PR_5 = 4,
-       HDMI_INFOFRAME_AVI_DB5PR_6 = 5,
-       HDMI_INFOFRAME_AVI_DB5PR_7 = 6,
-       HDMI_INFOFRAME_AVI_DB5PR_8 = 7,
-       HDMI_INFOFRAME_AVI_DB5PR_9 = 8,
-       HDMI_INFOFRAME_AVI_DB5PR_10 = 9,
-};
-
-enum hdmi_packing_mode {
-       HDMI_PACK_10b_RGB_YUV444 = 0,
-       HDMI_PACK_24b_RGB_YUV444_YUV422 = 1,
-       HDMI_PACK_20b_YUV422 = 2,
-       HDMI_PACK_ALREADYPACKED = 7
-};
-
-enum hdmi_core_audio_layout {
-       HDMI_AUDIO_LAYOUT_2CH = 0,
-       HDMI_AUDIO_LAYOUT_8CH = 1
-};
-
-enum hdmi_core_cts_mode {
-       HDMI_AUDIO_CTS_MODE_HW = 0,
-       HDMI_AUDIO_CTS_MODE_SW = 1
-};
-
-enum hdmi_stereo_channels {
-       HDMI_AUDIO_STEREO_NOCHANNELS = 0,
-       HDMI_AUDIO_STEREO_ONECHANNEL = 1,
-       HDMI_AUDIO_STEREO_TWOCHANNELS = 2,
-       HDMI_AUDIO_STEREO_THREECHANNELS = 3,
-       HDMI_AUDIO_STEREO_FOURCHANNELS = 4
-};
-
-enum hdmi_audio_type {
-       HDMI_AUDIO_TYPE_LPCM = 0,
-       HDMI_AUDIO_TYPE_IEC = 1
-};
-
-enum hdmi_audio_justify {
-       HDMI_AUDIO_JUSTIFY_LEFT = 0,
-       HDMI_AUDIO_JUSTIFY_RIGHT = 1
-};
-
-enum hdmi_audio_sample_order {
-       HDMI_AUDIO_SAMPLE_RIGHT_FIRST = 0,
-       HDMI_AUDIO_SAMPLE_LEFT_FIRST = 1
-};
-
-enum hdmi_audio_samples_perword {
-       HDMI_AUDIO_ONEWORD_ONESAMPLE = 0,
-       HDMI_AUDIO_ONEWORD_TWOSAMPLES = 1
-};
-
-enum hdmi_audio_sample_size {
-       HDMI_AUDIO_SAMPLE_16BITS = 0,
-       HDMI_AUDIO_SAMPLE_24BITS = 1
-};
-
-enum hdmi_audio_transf_mode {
-       HDMI_AUDIO_TRANSF_DMA = 0,
-       HDMI_AUDIO_TRANSF_IRQ = 1
-};
-
-enum hdmi_audio_blk_strt_end_sig {
-       HDMI_AUDIO_BLOCK_SIG_STARTEND_ON = 0,
-       HDMI_AUDIO_BLOCK_SIG_STARTEND_OFF = 1
-};
-
 enum hdmi_audio_i2s_config {
        HDMI_AUDIO_I2S_MSB_SHIFTED_FIRST = 0,
        HDMI_AUDIO_I2S_LSB_SHIFTED_FIRST = 1,
@@ -352,17 +239,6 @@ enum hdmi_audio_i2s_config {
        HDMI_AUDIO_I2S_SD3_EN = 1 << 3,
 };
 
-enum hdmi_audio_mclk_mode {
-       HDMI_AUDIO_MCLK_128FS = 0,
-       HDMI_AUDIO_MCLK_256FS = 1,
-       HDMI_AUDIO_MCLK_384FS = 2,
-       HDMI_AUDIO_MCLK_512FS = 3,
-       HDMI_AUDIO_MCLK_768FS = 4,
-       HDMI_AUDIO_MCLK_1024FS = 5,
-       HDMI_AUDIO_MCLK_1152FS = 6,
-       HDMI_AUDIO_MCLK_192FS = 7
-};
-
 struct hdmi_core_video_config {
        enum hdmi_core_inputbus_width   ip_bus_width;
        enum hdmi_core_dither_trunc     op_dither_truc;
@@ -383,55 +259,18 @@ struct hdmi_core_packet_enable_repeat {
        u32     generic_pkt_repeat;
 };
 
-struct hdmi_video_format {
-       enum hdmi_packing_mode  packing_mode;
-       u32                     y_res;  /* Line per panel */
-       u32                     x_res;  /* pixel per line */
-};
-
-struct hdmi_audio_format {
-       enum hdmi_stereo_channels               stereo_channels;
-       u8                                      active_chnnls_msk;
-       enum hdmi_audio_type                    type;
-       enum hdmi_audio_justify                 justification;
-       enum hdmi_audio_sample_order            sample_order;
-       enum hdmi_audio_samples_perword         samples_per_word;
-       enum hdmi_audio_sample_size             sample_size;
-       enum hdmi_audio_blk_strt_end_sig        en_sig_blk_strt_end;
-};
-
-struct hdmi_audio_dma {
-       u8                              transfer_size;
-       u8                              block_size;
-       enum hdmi_audio_transf_mode     mode;
-       u16                             fifo_threshold;
-};
-
-struct hdmi_core_audio_i2s_config {
-       u8 in_length_bits;
-       u8 justification;
-       u8 sck_edge_mode;
-       u8 vbit;
-       u8 direction;
-       u8 shift;
-       u8 active_sds;
-};
-
-struct hdmi_core_audio_config {
-       struct hdmi_core_audio_i2s_config       i2s_cfg;
-       struct snd_aes_iec958                   *iec60958_cfg;
-       bool                                    fs_override;
-       u32                                     n;
-       u32                                     cts;
-       u32                                     aud_par_busclk;
-       enum hdmi_core_audio_layout             layout;
-       enum hdmi_core_cts_mode                 cts_mode;
-       bool                                    use_mclk;
-       enum hdmi_audio_mclk_mode               mclk_mode;
-       bool                                    en_acr_pkt;
-       bool                                    en_dsd_audio;
-       bool                                    en_parallel_aud_input;
-       bool                                    en_spdif;
-};
+int hdmi4_read_edid(struct hdmi_core_data *core, u8 *edid, int len);
+void hdmi4_configure(struct hdmi_core_data *core, struct hdmi_wp_data *wp,
+               struct hdmi_config *cfg);
+void hdmi4_core_dump(struct hdmi_core_data *core, struct seq_file *s);
+int hdmi4_core_init(struct platform_device *pdev, struct hdmi_core_data *core);
+
+#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
+int hdmi4_audio_start(struct hdmi_core_data *core, struct hdmi_wp_data *wp);
+void hdmi4_audio_stop(struct hdmi_core_data *core, struct hdmi_wp_data *wp);
+int hdmi4_audio_config(struct hdmi_core_data *core, struct hdmi_wp_data *wp,
+               struct omap_dss_audio *audio, u32 pclk);
+int hdmi4_audio_get_dma_port(u32 *offset, u32 *size);
+#endif
 
 #endif
diff --git a/drivers/video/omap2/dss/hdmi_common.c b/drivers/video/omap2/dss/hdmi_common.c
new file mode 100644 (file)
index 0000000..5586aaa
--- /dev/null
@@ -0,0 +1,423 @@
+
+/*
+ * Logic for the below structure :
+ * user enters the CEA or VESA timings by specifying the HDMI/DVI code.
+ * There is a correspondence between CEA/VESA timing and code, please
+ * refer to section 6.3 in HDMI 1.3 specification for timing code.
+ *
+ * In the below structure, cea_vesa_timings corresponds to all OMAP4
+ * supported CEA and VESA timing values.code_cea corresponds to the CEA
+ * code, It is used to get the timing from cea_vesa_timing array.Similarly
+ * with code_vesa. Code_index is used for back mapping, that is once EDID
+ * is read from the TV, EDID is parsed to find the timing values and then
+ * map it to corresponding CEA or VESA index.
+ */
+
+#include <linux/kernel.h>
+#include <linux/err.h>
+#include <video/omapdss.h>
+
+#include "hdmi.h"
+
+static const struct hdmi_config cea_timings[] = {
+       {
+               { 640, 480, 25200, 96, 16, 48, 2, 10, 33,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 1, HDMI_HDMI },
+       },
+       {
+               { 720, 480, 27027, 62, 16, 60, 6, 9, 30,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 2, HDMI_HDMI },
+       },
+       {
+               { 1280, 720, 74250, 40, 110, 220, 5, 5, 20,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 4, HDMI_HDMI },
+       },
+       {
+               { 1920, 540, 74250, 44, 88, 148, 5, 2, 15,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       true, },
+               { 5, HDMI_HDMI },
+       },
+       {
+               { 1440, 240, 27027, 124, 38, 114, 3, 4, 15,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       true, },
+               { 6, HDMI_HDMI },
+       },
+       {
+               { 1920, 1080, 148500, 44, 88, 148, 5, 4, 36,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 16, HDMI_HDMI },
+       },
+       {
+               { 720, 576, 27000, 64, 12, 68, 5, 5, 39,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 17, HDMI_HDMI },
+       },
+       {
+               { 1280, 720, 74250, 40, 440, 220, 5, 5, 20,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 19, HDMI_HDMI },
+       },
+       {
+               { 1920, 540, 74250, 44, 528, 148, 5, 2, 15,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       true, },
+               { 20, HDMI_HDMI },
+       },
+       {
+               { 1440, 288, 27000, 126, 24, 138, 3, 2, 19,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       true, },
+               { 21, HDMI_HDMI },
+       },
+       {
+               { 1440, 576, 54000, 128, 24, 136, 5, 5, 39,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 29, HDMI_HDMI },
+       },
+       {
+               { 1920, 1080, 148500, 44, 528, 148, 5, 4, 36,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 31, HDMI_HDMI },
+       },
+       {
+               { 1920, 1080, 74250, 44, 638, 148, 5, 4, 36,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 32, HDMI_HDMI },
+       },
+       {
+               { 2880, 480, 108108, 248, 64, 240, 6, 9, 30,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 35, HDMI_HDMI },
+       },
+       {
+               { 2880, 576, 108000, 256, 48, 272, 5, 5, 39,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 37, HDMI_HDMI },
+       },
+};
+
+static const struct hdmi_config vesa_timings[] = {
+/* VESA From Here */
+       {
+               { 640, 480, 25175, 96, 16, 48, 2, 11, 31,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 4, HDMI_DVI },
+       },
+       {
+               { 800, 600, 40000, 128, 40, 88, 4, 1, 23,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 9, HDMI_DVI },
+       },
+       {
+               { 848, 480, 33750, 112, 16, 112, 8, 6, 23,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0xE, HDMI_DVI },
+       },
+       {
+               { 1280, 768, 79500, 128, 64, 192, 7, 3, 20,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 0x17, HDMI_DVI },
+       },
+       {
+               { 1280, 800, 83500, 128, 72, 200, 6, 3, 22,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 0x1C, HDMI_DVI },
+       },
+       {
+               { 1360, 768, 85500, 112, 64, 256, 6, 3, 18,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x27, HDMI_DVI },
+       },
+       {
+               { 1280, 960, 108000, 112, 96, 312, 3, 1, 36,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x20, HDMI_DVI },
+       },
+       {
+               { 1280, 1024, 108000, 112, 48, 248, 3, 1, 38,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x23, HDMI_DVI },
+       },
+       {
+               { 1024, 768, 65000, 136, 24, 160, 6, 3, 29,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 0x10, HDMI_DVI },
+       },
+       {
+               { 1400, 1050, 121750, 144, 88, 232, 4, 3, 32,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 0x2A, HDMI_DVI },
+       },
+       {
+               { 1440, 900, 106500, 152, 80, 232, 6, 3, 25,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 0x2F, HDMI_DVI },
+       },
+       {
+               { 1680, 1050, 146250, 176 , 104, 280, 6, 3, 30,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_LOW,
+                       false, },
+               { 0x3A, HDMI_DVI },
+       },
+       {
+               { 1366, 768, 85500, 143, 70, 213, 3, 3, 24,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x51, HDMI_DVI },
+       },
+       {
+               { 1920, 1080, 148500, 44, 148, 80, 5, 4, 36,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x52, HDMI_DVI },
+       },
+       {
+               { 1280, 768, 68250, 32, 48, 80, 7, 3, 12,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x16, HDMI_DVI },
+       },
+       {
+               { 1400, 1050, 101000, 32, 48, 80, 4, 3, 23,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x29, HDMI_DVI },
+       },
+       {
+               { 1680, 1050, 119000, 32, 48, 80, 6, 3, 21,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x39, HDMI_DVI },
+       },
+       {
+               { 1280, 800, 79500, 32, 48, 80, 6, 3, 14,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x1B, HDMI_DVI },
+       },
+       {
+               { 1280, 720, 74250, 40, 110, 220, 5, 5, 20,
+                       OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x55, HDMI_DVI },
+       },
+       {
+               { 1920, 1200, 154000, 32, 48, 80, 6, 3, 26,
+                       OMAPDSS_SIG_ACTIVE_LOW, OMAPDSS_SIG_ACTIVE_HIGH,
+                       false, },
+               { 0x44, HDMI_DVI },
+       },
+};
+
+const struct hdmi_config *hdmi_default_timing(void)
+{
+       return &vesa_timings[0];
+}
+
+static const struct hdmi_config *hdmi_find_timing(int code,
+                       const struct hdmi_config *timings_arr, int len)
+{
+       int i;
+
+       for (i = 0; i < len; i++) {
+               if (timings_arr[i].cm.code == code)
+                       return &timings_arr[i];
+       }
+
+       return NULL;
+}
+
+const struct hdmi_config *hdmi_get_timings(int mode, int code)
+{
+       const struct hdmi_config *arr;
+       int len;
+
+       if (mode == HDMI_DVI) {
+               arr = vesa_timings;
+               len = ARRAY_SIZE(vesa_timings);
+       } else {
+               arr = cea_timings;
+               len = ARRAY_SIZE(cea_timings);
+       }
+
+       return hdmi_find_timing(code, arr, len);
+}
+
+static bool hdmi_timings_compare(struct omap_video_timings *timing1,
+                       const struct omap_video_timings *timing2)
+{
+       int timing1_vsync, timing1_hsync, timing2_vsync, timing2_hsync;
+
+       if ((DIV_ROUND_CLOSEST(timing2->pixel_clock, 1000) ==
+                       DIV_ROUND_CLOSEST(timing1->pixel_clock, 1000)) &&
+               (timing2->x_res == timing1->x_res) &&
+               (timing2->y_res == timing1->y_res)) {
+
+               timing2_hsync = timing2->hfp + timing2->hsw + timing2->hbp;
+               timing1_hsync = timing1->hfp + timing1->hsw + timing1->hbp;
+               timing2_vsync = timing2->vfp + timing2->vsw + timing2->vbp;
+               timing1_vsync = timing1->vfp + timing1->vsw + timing1->vbp;
+
+               DSSDBG("timing1_hsync = %d timing1_vsync = %d"\
+                       "timing2_hsync = %d timing2_vsync = %d\n",
+                       timing1_hsync, timing1_vsync,
+                       timing2_hsync, timing2_vsync);
+
+               if ((timing1_hsync == timing2_hsync) &&
+                       (timing1_vsync == timing2_vsync)) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+struct hdmi_cm hdmi_get_code(struct omap_video_timings *timing)
+{
+       int i;
+       struct hdmi_cm cm = {-1};
+       DSSDBG("hdmi_get_code\n");
+
+       for (i = 0; i < ARRAY_SIZE(cea_timings); i++) {
+               if (hdmi_timings_compare(timing, &cea_timings[i].timings)) {
+                       cm = cea_timings[i].cm;
+                       goto end;
+               }
+       }
+       for (i = 0; i < ARRAY_SIZE(vesa_timings); i++) {
+               if (hdmi_timings_compare(timing, &vesa_timings[i].timings)) {
+                       cm = vesa_timings[i].cm;
+                       goto end;
+               }
+       }
+
+end:
+       return cm;
+}
+
+#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
+int hdmi_compute_acr(u32 pclk, u32 sample_freq, u32 *n, u32 *cts)
+{
+       u32 deep_color;
+       bool deep_color_correct = false;
+
+       if (n == NULL || cts == NULL)
+               return -EINVAL;
+
+       /* TODO: When implemented, query deep color mode here. */
+       deep_color = 100;
+
+       /*
+        * When using deep color, the default N value (as in the HDMI
+        * specification) yields to an non-integer CTS. Hence, we
+        * modify it while keeping the restrictions described in
+        * section 7.2.1 of the HDMI 1.4a specification.
+        */
+       switch (sample_freq) {
+       case 32000:
+       case 48000:
+       case 96000:
+       case 192000:
+               if (deep_color == 125)
+                       if (pclk == 27027 || pclk == 74250)
+                               deep_color_correct = true;
+               if (deep_color == 150)
+                       if (pclk == 27027)
+                               deep_color_correct = true;
+               break;
+       case 44100:
+       case 88200:
+       case 176400:
+               if (deep_color == 125)
+                       if (pclk == 27027)
+                               deep_color_correct = true;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       if (deep_color_correct) {
+               switch (sample_freq) {
+               case 32000:
+                       *n = 8192;
+                       break;
+               case 44100:
+                       *n = 12544;
+                       break;
+               case 48000:
+                       *n = 8192;
+                       break;
+               case 88200:
+                       *n = 25088;
+                       break;
+               case 96000:
+                       *n = 16384;
+                       break;
+               case 176400:
+                       *n = 50176;
+                       break;
+               case 192000:
+                       *n = 32768;
+                       break;
+               default:
+                       return -EINVAL;
+               }
+       } else {
+               switch (sample_freq) {
+               case 32000:
+                       *n = 4096;
+                       break;
+               case 44100:
+                       *n = 6272;
+                       break;
+               case 48000:
+                       *n = 6144;
+                       break;
+               case 88200:
+                       *n = 12544;
+                       break;
+               case 96000:
+                       *n = 12288;
+                       break;
+               case 176400:
+                       *n = 25088;
+                       break;
+               case 192000:
+                       *n = 24576;
+                       break;
+               default:
+                       return -EINVAL;
+               }
+       }
+       /* Calculate CTS. See HDMI 1.3a or 1.4a specifications */
+       *cts = pclk * (*n / 128) * deep_color / (sample_freq / 10);
+
+       return 0;
+}
+#endif
diff --git a/drivers/video/omap2/dss/hdmi_phy.c b/drivers/video/omap2/dss/hdmi_phy.c
new file mode 100644 (file)
index 0000000..45acb99
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * HDMI PHY
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <video/omapdss.h>
+
+#include "dss.h"
+#include "hdmi.h"
+
+void hdmi_phy_dump(struct hdmi_phy_data *phy, struct seq_file *s)
+{
+#define DUMPPHY(r) seq_printf(s, "%-35s %08x\n", #r,\
+               hdmi_read_reg(phy->base, r))
+
+       DUMPPHY(HDMI_TXPHY_TX_CTRL);
+       DUMPPHY(HDMI_TXPHY_DIGITAL_CTRL);
+       DUMPPHY(HDMI_TXPHY_POWER_CTRL);
+       DUMPPHY(HDMI_TXPHY_PAD_CFG_CTRL);
+}
+
+static irqreturn_t hdmi_irq_handler(int irq, void *data)
+{
+       struct hdmi_wp_data *wp = data;
+       u32 irqstatus;
+
+       irqstatus = hdmi_wp_get_irqstatus(wp);
+       hdmi_wp_set_irqstatus(wp, irqstatus);
+
+       if ((irqstatus & HDMI_IRQ_LINK_CONNECT) &&
+                       irqstatus & HDMI_IRQ_LINK_DISCONNECT) {
+               /*
+                * If we get both connect and disconnect interrupts at the same
+                * time, turn off the PHY, clear interrupts, and restart, which
+                * raises connect interrupt if a cable is connected, or nothing
+                * if cable is not connected.
+                */
+               hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_OFF);
+
+               hdmi_wp_set_irqstatus(wp, HDMI_IRQ_LINK_CONNECT |
+                               HDMI_IRQ_LINK_DISCONNECT);
+
+               hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
+       } else if (irqstatus & HDMI_IRQ_LINK_CONNECT) {
+               hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_TXON);
+       } else if (irqstatus & HDMI_IRQ_LINK_DISCONNECT) {
+               hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
+       }
+
+       return IRQ_HANDLED;
+}
+
+int hdmi_phy_enable(struct hdmi_phy_data *phy, struct hdmi_wp_data *wp,
+                       struct hdmi_config *cfg)
+{
+       u16 r = 0;
+       u32 irqstatus;
+
+       hdmi_wp_clear_irqenable(wp, 0xffffffff);
+
+       irqstatus = hdmi_wp_get_irqstatus(wp);
+       hdmi_wp_set_irqstatus(wp, irqstatus);
+
+       r = hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
+       if (r)
+               return r;
+
+       /*
+        * Read address 0 in order to get the SCP reset done completed
+        * Dummy access performed to make sure reset is done
+        */
+       hdmi_read_reg(phy->base, HDMI_TXPHY_TX_CTRL);
+
+       /*
+        * Write to phy address 0 to configure the clock
+        * use HFBITCLK write HDMI_TXPHY_TX_CONTROL_FREQOUT field
+        */
+       REG_FLD_MOD(phy->base, HDMI_TXPHY_TX_CTRL, 0x1, 31, 30);
+
+       /* Write to phy address 1 to start HDMI line (TXVALID and TMDSCLKEN) */
+       hdmi_write_reg(phy->base, HDMI_TXPHY_DIGITAL_CTRL, 0xF0000000);
+
+       /* Setup max LDO voltage */
+       REG_FLD_MOD(phy->base, HDMI_TXPHY_POWER_CTRL, 0xB, 3, 0);
+
+       /* Write to phy address 3 to change the polarity control */
+       REG_FLD_MOD(phy->base, HDMI_TXPHY_PAD_CFG_CTRL, 0x1, 27, 27);
+
+       r = request_threaded_irq(phy->irq, NULL, hdmi_irq_handler,
+                               IRQF_ONESHOT, "OMAP HDMI", wp);
+       if (r) {
+               DSSERR("HDMI IRQ request failed\n");
+               hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_OFF);
+               return r;
+       }
+
+       hdmi_wp_set_irqenable(wp,
+               HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
+
+       return 0;
+}
+
+void hdmi_phy_disable(struct hdmi_phy_data *phy, struct hdmi_wp_data *wp)
+{
+       free_irq(phy->irq, wp);
+
+       hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_OFF);
+}
+
+#define PHY_OFFSET     0x300
+#define PHY_SIZE       0x100
+
+int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy)
+{
+       struct resource *res;
+       struct resource temp_res;
+
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi_txphy");
+       if (!res) {
+               DSSDBG("can't get PHY mem resource by name\n");
+               /*
+                * if hwmod/DT doesn't have the memory resource information
+                * split into HDMI sub blocks by name, we try again by getting
+                * the platform's first resource. this code will be removed when
+                * the driver can get the mem resources by name
+                */
+               res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+               if (!res) {
+                       DSSERR("can't get PHY mem resource\n");
+                       return -EINVAL;
+               }
+
+               temp_res.start = res->start + PHY_OFFSET;
+               temp_res.end = temp_res.start + PHY_SIZE - 1;
+               res = &temp_res;
+       }
+
+       phy->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+       if (!phy->base) {
+               DSSERR("can't ioremap TX PHY\n");
+               return -ENOMEM;
+       }
+
+       phy->irq = platform_get_irq(pdev, 0);
+       if (phy->irq < 0) {
+               DSSERR("platform_get_irq failed\n");
+               return -ENODEV;
+       }
+
+       return 0;
+}
diff --git a/drivers/video/omap2/dss/hdmi_pll.c b/drivers/video/omap2/dss/hdmi_pll.c
new file mode 100644 (file)
index 0000000..d3e6e78
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * HDMI PLL
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <video/omapdss.h>
+
+#include "dss.h"
+#include "hdmi.h"
+
+#define HDMI_DEFAULT_REGN 16
+#define HDMI_DEFAULT_REGM2 1
+
+void hdmi_pll_dump(struct hdmi_pll_data *pll, struct seq_file *s)
+{
+#define DUMPPLL(r) seq_printf(s, "%-35s %08x\n", #r,\
+               hdmi_read_reg(pll->base, r))
+
+       DUMPPLL(PLLCTRL_PLL_CONTROL);
+       DUMPPLL(PLLCTRL_PLL_STATUS);
+       DUMPPLL(PLLCTRL_PLL_GO);
+       DUMPPLL(PLLCTRL_CFG1);
+       DUMPPLL(PLLCTRL_CFG2);
+       DUMPPLL(PLLCTRL_CFG3);
+       DUMPPLL(PLLCTRL_SSC_CFG1);
+       DUMPPLL(PLLCTRL_SSC_CFG2);
+       DUMPPLL(PLLCTRL_CFG4);
+}
+
+void hdmi_pll_compute(struct hdmi_pll_data *pll, unsigned long clkin, int phy)
+{
+       struct hdmi_pll_info *pi = &pll->info;
+       unsigned long refclk;
+       u32 mf;
+
+       /* use our funky units */
+       clkin /= 10000;
+
+       /*
+        * Input clock is predivided by N + 1
+        * out put of which is reference clk
+        */
+
+       pi->regn = HDMI_DEFAULT_REGN;
+
+       refclk = clkin / pi->regn;
+
+       pi->regm2 = HDMI_DEFAULT_REGM2;
+
+       /*
+        * multiplier is pixel_clk/ref_clk
+        * Multiplying by 100 to avoid fractional part removal
+        */
+       pi->regm = phy * pi->regm2 / refclk;
+
+       /*
+        * fractional multiplier is remainder of the difference between
+        * multiplier and actual phy(required pixel clock thus should be
+        * multiplied by 2^18(262144) divided by the reference clock
+        */
+       mf = (phy - pi->regm / pi->regm2 * refclk) * 262144;
+       pi->regmf = pi->regm2 * mf / refclk;
+
+       /*
+        * Dcofreq should be set to 1 if required pixel clock
+        * is greater than 1000MHz
+        */
+       pi->dcofreq = phy > 1000 * 100;
+       pi->regsd = ((pi->regm * clkin / 10) / (pi->regn * 250) + 5) / 10;
+
+       /* Set the reference clock to sysclk reference */
+       pi->refsel = HDMI_REFSEL_SYSCLK;
+
+       DSSDBG("M = %d Mf = %d\n", pi->regm, pi->regmf);
+       DSSDBG("range = %d sd = %d\n", pi->dcofreq, pi->regsd);
+}
+
+
+static int hdmi_pll_config(struct hdmi_pll_data *pll)
+{
+       u32 r;
+       struct hdmi_pll_info *fmt = &pll->info;
+
+       /* PLL start always use manual mode */
+       REG_FLD_MOD(pll->base, PLLCTRL_PLL_CONTROL, 0x0, 0, 0);
+
+       r = hdmi_read_reg(pll->base, PLLCTRL_CFG1);
+       r = FLD_MOD(r, fmt->regm, 20, 9);       /* CFG1_PLL_REGM */
+       r = FLD_MOD(r, fmt->regn - 1, 8, 1);    /* CFG1_PLL_REGN */
+       hdmi_write_reg(pll->base, PLLCTRL_CFG1, r);
+
+       r = hdmi_read_reg(pll->base, PLLCTRL_CFG2);
+
+       r = FLD_MOD(r, 0x0, 12, 12);    /* PLL_HIGHFREQ divide by 2 */
+       r = FLD_MOD(r, 0x1, 13, 13);    /* PLL_REFEN */
+       r = FLD_MOD(r, 0x0, 14, 14);    /* PHY_CLKINEN de-assert during locking */
+       r = FLD_MOD(r, fmt->refsel, 22, 21);    /* REFSEL */
+
+       if (fmt->dcofreq) {
+               /* divider programming for frequency beyond 1000Mhz */
+               REG_FLD_MOD(pll->base, PLLCTRL_CFG3, fmt->regsd, 17, 10);
+               r = FLD_MOD(r, 0x4, 3, 1);      /* 1000MHz and 2000MHz */
+       } else {
+               r = FLD_MOD(r, 0x2, 3, 1);      /* 500MHz and 1000MHz */
+       }
+
+       hdmi_write_reg(pll->base, PLLCTRL_CFG2, r);
+
+       r = hdmi_read_reg(pll->base, PLLCTRL_CFG4);
+       r = FLD_MOD(r, fmt->regm2, 24, 18);
+       r = FLD_MOD(r, fmt->regmf, 17, 0);
+       hdmi_write_reg(pll->base, PLLCTRL_CFG4, r);
+
+       /* go now */
+       REG_FLD_MOD(pll->base, PLLCTRL_PLL_GO, 0x1, 0, 0);
+
+       /* wait for bit change */
+       if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_GO,
+                       0, 0, 1) != 1) {
+               pr_err("PLL GO bit not set\n");
+               return -ETIMEDOUT;
+       }
+
+       /* Wait till the lock bit is set in PLL status */
+       if (hdmi_wait_for_bit_change(pll->base,
+                       PLLCTRL_PLL_STATUS, 1, 1, 1) != 1) {
+               pr_err("cannot lock PLL\n");
+               pr_err("CFG1 0x%x\n",
+                       hdmi_read_reg(pll->base, PLLCTRL_CFG1));
+               pr_err("CFG2 0x%x\n",
+                       hdmi_read_reg(pll->base, PLLCTRL_CFG2));
+               pr_err("CFG4 0x%x\n",
+                       hdmi_read_reg(pll->base, PLLCTRL_CFG4));
+               return -ETIMEDOUT;
+       }
+
+       pr_debug("PLL locked!\n");
+
+       return 0;
+}
+
+static int hdmi_pll_reset(struct hdmi_pll_data *pll)
+{
+       /* SYSRESET  controlled by power FSM */
+       REG_FLD_MOD(pll->base, PLLCTRL_PLL_CONTROL, 0x0, 3, 3);
+
+       /* READ 0x0 reset is in progress */
+       if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_STATUS, 0, 0, 1)
+                       != 1) {
+               pr_err("Failed to sysreset PLL\n");
+               return -ETIMEDOUT;
+       }
+
+       return 0;
+}
+
+int hdmi_pll_enable(struct hdmi_pll_data *pll, struct hdmi_wp_data *wp)
+{
+       u16 r = 0;
+
+       r = hdmi_wp_set_pll_pwr(wp, HDMI_PLLPWRCMD_ALLOFF);
+       if (r)
+               return r;
+
+       r = hdmi_wp_set_pll_pwr(wp, HDMI_PLLPWRCMD_BOTHON_ALLCLKS);
+       if (r)
+               return r;
+
+       r = hdmi_pll_reset(pll);
+       if (r)
+               return r;
+
+       r = hdmi_pll_config(pll);
+       if (r)
+               return r;
+
+       return 0;
+}
+
+void hdmi_pll_disable(struct hdmi_pll_data *pll, struct hdmi_wp_data *wp)
+{
+       hdmi_wp_set_pll_pwr(wp, HDMI_PLLPWRCMD_ALLOFF);
+}
+
+#define PLL_OFFSET     0x200
+#define PLL_SIZE       0x100
+
+int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll)
+{
+       struct resource *res;
+       struct resource temp_res;
+
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi_pllctrl");
+       if (!res) {
+               DSSDBG("can't get PLL mem resource by name\n");
+               /*
+                * if hwmod/DT doesn't have the memory resource information
+                * split into HDMI sub blocks by name, we try again by getting
+                * the platform's first resource. this code will be removed when
+                * the driver can get the mem resources by name
+                */
+               res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+               if (!res) {
+                       DSSERR("can't get PLL mem resource\n");
+                       return -EINVAL;
+               }
+
+               temp_res.start = res->start + PLL_OFFSET;
+               temp_res.end = temp_res.start + PLL_SIZE - 1;
+               res = &temp_res;
+       }
+
+       pll->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+       if (!pll->base) {
+               DSSERR("can't ioremap PLLCTRL\n");
+               return -ENOMEM;
+       }
+
+       return 0;
+}
diff --git a/drivers/video/omap2/dss/hdmi_wp.c b/drivers/video/omap2/dss/hdmi_wp.c
new file mode 100644 (file)
index 0000000..8151d89
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * HDMI wrapper
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <video/omapdss.h>
+
+#include "dss.h"
+#include "hdmi.h"
+
+void hdmi_wp_dump(struct hdmi_wp_data *wp, struct seq_file *s)
+{
+#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, hdmi_read_reg(wp->base, r))
+
+       DUMPREG(HDMI_WP_REVISION);
+       DUMPREG(HDMI_WP_SYSCONFIG);
+       DUMPREG(HDMI_WP_IRQSTATUS_RAW);
+       DUMPREG(HDMI_WP_IRQSTATUS);
+       DUMPREG(HDMI_WP_IRQENABLE_SET);
+       DUMPREG(HDMI_WP_IRQENABLE_CLR);
+       DUMPREG(HDMI_WP_IRQWAKEEN);
+       DUMPREG(HDMI_WP_PWR_CTRL);
+       DUMPREG(HDMI_WP_DEBOUNCE);
+       DUMPREG(HDMI_WP_VIDEO_CFG);
+       DUMPREG(HDMI_WP_VIDEO_SIZE);
+       DUMPREG(HDMI_WP_VIDEO_TIMING_H);
+       DUMPREG(HDMI_WP_VIDEO_TIMING_V);
+       DUMPREG(HDMI_WP_WP_CLK);
+       DUMPREG(HDMI_WP_AUDIO_CFG);
+       DUMPREG(HDMI_WP_AUDIO_CFG2);
+       DUMPREG(HDMI_WP_AUDIO_CTRL);
+       DUMPREG(HDMI_WP_AUDIO_DATA);
+}
+
+u32 hdmi_wp_get_irqstatus(struct hdmi_wp_data *wp)
+{
+       return hdmi_read_reg(wp->base, HDMI_WP_IRQSTATUS);
+}
+
+void hdmi_wp_set_irqstatus(struct hdmi_wp_data *wp, u32 irqstatus)
+{
+       hdmi_write_reg(wp->base, HDMI_WP_IRQSTATUS, irqstatus);
+       /* flush posted write */
+       hdmi_read_reg(wp->base, HDMI_WP_IRQSTATUS);
+}
+
+void hdmi_wp_set_irqenable(struct hdmi_wp_data *wp, u32 mask)
+{
+       hdmi_write_reg(wp->base, HDMI_WP_IRQENABLE_SET, mask);
+}
+
+void hdmi_wp_clear_irqenable(struct hdmi_wp_data *wp, u32 mask)
+{
+       hdmi_write_reg(wp->base, HDMI_WP_IRQENABLE_CLR, mask);
+}
+
+/* PHY_PWR_CMD */
+int hdmi_wp_set_phy_pwr(struct hdmi_wp_data *wp, enum hdmi_phy_pwr val)
+{
+       /* Return if already the state */
+       if (REG_GET(wp->base, HDMI_WP_PWR_CTRL, 5, 4) == val)
+               return 0;
+
+       /* Command for power control of HDMI PHY */
+       REG_FLD_MOD(wp->base, HDMI_WP_PWR_CTRL, val, 7, 6);
+
+       /* Status of the power control of HDMI PHY */
+       if (hdmi_wait_for_bit_change(wp->base, HDMI_WP_PWR_CTRL, 5, 4, val)
+                       != val) {
+               pr_err("Failed to set PHY power mode to %d\n", val);
+               return -ETIMEDOUT;
+       }
+
+       return 0;
+}
+
+/* PLL_PWR_CMD */
+int hdmi_wp_set_pll_pwr(struct hdmi_wp_data *wp, enum hdmi_pll_pwr val)
+{
+       /* Command for power control of HDMI PLL */
+       REG_FLD_MOD(wp->base, HDMI_WP_PWR_CTRL, val, 3, 2);
+
+       /* wait till PHY_PWR_STATUS is set */
+       if (hdmi_wait_for_bit_change(wp->base, HDMI_WP_PWR_CTRL, 1, 0, val)
+                       != val) {
+               pr_err("Failed to set PLL_PWR_STATUS\n");
+               return -ETIMEDOUT;
+       }
+
+       return 0;
+}
+
+int hdmi_wp_video_start(struct hdmi_wp_data *wp)
+{
+       REG_FLD_MOD(wp->base, HDMI_WP_VIDEO_CFG, true, 31, 31);
+
+       return 0;
+}
+
+void hdmi_wp_video_stop(struct hdmi_wp_data *wp)
+{
+       REG_FLD_MOD(wp->base, HDMI_WP_VIDEO_CFG, false, 31, 31);
+}
+
+void hdmi_wp_video_config_format(struct hdmi_wp_data *wp,
+               struct hdmi_video_format *video_fmt)
+{
+       u32 l = 0;
+
+       REG_FLD_MOD(wp->base, HDMI_WP_VIDEO_CFG, video_fmt->packing_mode,
+               10, 8);
+
+       l |= FLD_VAL(video_fmt->y_res, 31, 16);
+       l |= FLD_VAL(video_fmt->x_res, 15, 0);
+       hdmi_write_reg(wp->base, HDMI_WP_VIDEO_SIZE, l);
+}
+
+void hdmi_wp_video_config_interface(struct hdmi_wp_data *wp,
+               struct omap_video_timings *timings)
+{
+       u32 r;
+       bool vsync_pol, hsync_pol;
+       pr_debug("Enter hdmi_wp_video_config_interface\n");
+
+       vsync_pol = timings->vsync_level == OMAPDSS_SIG_ACTIVE_HIGH;
+       hsync_pol = timings->hsync_level == OMAPDSS_SIG_ACTIVE_HIGH;
+
+       r = hdmi_read_reg(wp->base, HDMI_WP_VIDEO_CFG);
+       r = FLD_MOD(r, vsync_pol, 7, 7);
+       r = FLD_MOD(r, hsync_pol, 6, 6);
+       r = FLD_MOD(r, timings->interlace, 3, 3);
+       r = FLD_MOD(r, 1, 1, 0); /* HDMI_TIMING_MASTER_24BIT */
+       hdmi_write_reg(wp->base, HDMI_WP_VIDEO_CFG, r);
+}
+
+void hdmi_wp_video_config_timing(struct hdmi_wp_data *wp,
+               struct omap_video_timings *timings)
+{
+       u32 timing_h = 0;
+       u32 timing_v = 0;
+
+       pr_debug("Enter hdmi_wp_video_config_timing\n");
+
+       timing_h |= FLD_VAL(timings->hbp, 31, 20);
+       timing_h |= FLD_VAL(timings->hfp, 19, 8);
+       timing_h |= FLD_VAL(timings->hsw, 7, 0);
+       hdmi_write_reg(wp->base, HDMI_WP_VIDEO_TIMING_H, timing_h);
+
+       timing_v |= FLD_VAL(timings->vbp, 31, 20);
+       timing_v |= FLD_VAL(timings->vfp, 19, 8);
+       timing_v |= FLD_VAL(timings->vsw, 7, 0);
+       hdmi_write_reg(wp->base, HDMI_WP_VIDEO_TIMING_V, timing_v);
+}
+
+void hdmi_wp_init_vid_fmt_timings(struct hdmi_video_format *video_fmt,
+               struct omap_video_timings *timings, struct hdmi_config *param)
+{
+       pr_debug("Enter hdmi_wp_video_init_format\n");
+
+       video_fmt->packing_mode = HDMI_PACK_10b_RGB_YUV444;
+       video_fmt->y_res = param->timings.y_res;
+       video_fmt->x_res = param->timings.x_res;
+
+       timings->hbp = param->timings.hbp;
+       timings->hfp = param->timings.hfp;
+       timings->hsw = param->timings.hsw;
+       timings->vbp = param->timings.vbp;
+       timings->vfp = param->timings.vfp;
+       timings->vsw = param->timings.vsw;
+       timings->vsync_level = param->timings.vsync_level;
+       timings->hsync_level = param->timings.hsync_level;
+       timings->interlace = param->timings.interlace;
+}
+
+#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
+void hdmi_wp_audio_config_format(struct hdmi_wp_data *wp,
+               struct hdmi_audio_format *aud_fmt)
+{
+       u32 r;
+
+       DSSDBG("Enter hdmi_wp_audio_config_format\n");
+
+       r = hdmi_read_reg(wp->base, HDMI_WP_AUDIO_CFG);
+       r = FLD_MOD(r, aud_fmt->stereo_channels, 26, 24);
+       r = FLD_MOD(r, aud_fmt->active_chnnls_msk, 23, 16);
+       r = FLD_MOD(r, aud_fmt->en_sig_blk_strt_end, 5, 5);
+       r = FLD_MOD(r, aud_fmt->type, 4, 4);
+       r = FLD_MOD(r, aud_fmt->justification, 3, 3);
+       r = FLD_MOD(r, aud_fmt->sample_order, 2, 2);
+       r = FLD_MOD(r, aud_fmt->samples_per_word, 1, 1);
+       r = FLD_MOD(r, aud_fmt->sample_size, 0, 0);
+       hdmi_write_reg(wp->base, HDMI_WP_AUDIO_CFG, r);
+}
+
+void hdmi_wp_audio_config_dma(struct hdmi_wp_data *wp,
+               struct hdmi_audio_dma *aud_dma)
+{
+       u32 r;
+
+       DSSDBG("Enter hdmi_wp_audio_config_dma\n");
+
+       r = hdmi_read_reg(wp->base, HDMI_WP_AUDIO_CFG2);
+       r = FLD_MOD(r, aud_dma->transfer_size, 15, 8);
+       r = FLD_MOD(r, aud_dma->block_size, 7, 0);
+       hdmi_write_reg(wp->base, HDMI_WP_AUDIO_CFG2, r);
+
+       r = hdmi_read_reg(wp->base, HDMI_WP_AUDIO_CTRL);
+       r = FLD_MOD(r, aud_dma->mode, 9, 9);
+       r = FLD_MOD(r, aud_dma->fifo_threshold, 8, 0);
+       hdmi_write_reg(wp->base, HDMI_WP_AUDIO_CTRL, r);
+}
+
+int hdmi_wp_audio_enable(struct hdmi_wp_data *wp, bool enable)
+{
+       REG_FLD_MOD(wp->base, HDMI_WP_AUDIO_CTRL, enable, 31, 31);
+
+       return 0;
+}
+
+int hdmi_wp_audio_core_req_enable(struct hdmi_wp_data *wp, bool enable)
+{
+       REG_FLD_MOD(wp->base, HDMI_WP_AUDIO_CTRL, enable, 30, 30);
+
+       return 0;
+}
+#endif
+
+#define WP_SIZE        0x200
+
+int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp)
+{
+       struct resource *res;
+       struct resource temp_res;
+
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi_wp");
+       if (!res) {
+               DSSDBG("can't get WP mem resource by name\n");
+               /*
+                * if hwmod/DT doesn't have the memory resource information
+                * split into HDMI sub blocks by name, we try again by getting
+                * the platform's first resource. this code will be removed when
+                * the driver can get the mem resources by name
+                */
+               res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+               if (!res) {
+                       DSSERR("can't get WP mem resource\n");
+                       return -EINVAL;
+               }
+
+               temp_res.start = res->start;
+               temp_res.end = temp_res.start + WP_SIZE - 1;
+               res = &temp_res;
+       }
+
+       wp->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+       if (!wp->base) {
+               DSSERR("can't ioremap HDMI WP\n");
+               return -ENOMEM;
+       }
+
+       return 0;
+}
diff --git a/drivers/video/omap2/dss/ti_hdmi.h b/drivers/video/omap2/dss/ti_hdmi.h
deleted file mode 100644 (file)
index 45215f4..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * ti_hdmi.h
- *
- * HDMI driver definition for TI OMAP4, DM81xx, DM38xx  Processor.
- *
- * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _TI_HDMI_H
-#define _TI_HDMI_H
-
-struct hdmi_ip_data;
-
-enum hdmi_pll_pwr {
-       HDMI_PLLPWRCMD_ALLOFF = 0,
-       HDMI_PLLPWRCMD_PLLONLY = 1,
-       HDMI_PLLPWRCMD_BOTHON_ALLCLKS = 2,
-       HDMI_PLLPWRCMD_BOTHON_NOPHYCLK = 3
-};
-
-enum hdmi_core_hdmi_dvi {
-       HDMI_DVI = 0,
-       HDMI_HDMI = 1
-};
-
-enum hdmi_clk_refsel {
-       HDMI_REFSEL_PCLK = 0,
-       HDMI_REFSEL_REF1 = 1,
-       HDMI_REFSEL_REF2 = 2,
-       HDMI_REFSEL_SYSCLK = 3
-};
-
-struct hdmi_cm {
-       int     code;
-       int     mode;
-};
-
-struct hdmi_config {
-       struct omap_video_timings timings;
-       struct hdmi_cm cm;
-};
-
-/* HDMI PLL structure */
-struct hdmi_pll_info {
-       u16 regn;
-       u16 regm;
-       u32 regmf;
-       u16 regm2;
-       u16 regsd;
-       u16 dcofreq;
-       enum hdmi_clk_refsel refsel;
-};
-
-struct ti_hdmi_ip_ops {
-
-       void (*video_configure)(struct hdmi_ip_data *ip_data);
-
-       int (*phy_enable)(struct hdmi_ip_data *ip_data);
-
-       void (*phy_disable)(struct hdmi_ip_data *ip_data);
-
-       int (*read_edid)(struct hdmi_ip_data *ip_data, u8 *edid, int len);
-
-       int (*pll_enable)(struct hdmi_ip_data *ip_data);
-
-       void (*pll_disable)(struct hdmi_ip_data *ip_data);
-
-       int (*video_enable)(struct hdmi_ip_data *ip_data);
-
-       void (*video_disable)(struct hdmi_ip_data *ip_data);
-
-       void (*dump_wrapper)(struct hdmi_ip_data *ip_data, struct seq_file *s);
-
-       void (*dump_core)(struct hdmi_ip_data *ip_data, struct seq_file *s);
-
-       void (*dump_pll)(struct hdmi_ip_data *ip_data, struct seq_file *s);
-
-       void (*dump_phy)(struct hdmi_ip_data *ip_data, struct seq_file *s);
-
-#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
-       int (*audio_enable)(struct hdmi_ip_data *ip_data);
-
-       void (*audio_disable)(struct hdmi_ip_data *ip_data);
-
-       int (*audio_start)(struct hdmi_ip_data *ip_data);
-
-       void (*audio_stop)(struct hdmi_ip_data *ip_data);
-
-       int (*audio_config)(struct hdmi_ip_data *ip_data,
-               struct omap_dss_audio *audio);
-
-       int (*audio_get_dma_port)(u32 *offset, u32 *size);
-#endif
-
-};
-
-/*
- * Refer to section 8.2 in HDMI 1.3 specification for
- * details about infoframe databytes
- */
-struct hdmi_core_infoframe_avi {
-       /* Y0, Y1 rgb,yCbCr */
-       u8      db1_format;
-       /* A0  Active information Present */
-       u8      db1_active_info;
-       /* B0, B1 Bar info data valid */
-       u8      db1_bar_info_dv;
-       /* S0, S1 scan information */
-       u8      db1_scan_info;
-       /* C0, C1 colorimetry */
-       u8      db2_colorimetry;
-       /* M0, M1 Aspect ratio (4:3, 16:9) */
-       u8      db2_aspect_ratio;
-       /* R0...R3 Active format aspect ratio */
-       u8      db2_active_fmt_ar;
-       /* ITC IT content. */
-       u8      db3_itc;
-       /* EC0, EC1, EC2 Extended colorimetry */
-       u8      db3_ec;
-       /* Q1, Q0 Quantization range */
-       u8      db3_q_range;
-       /* SC1, SC0 Non-uniform picture scaling */
-       u8      db3_nup_scaling;
-       /* VIC0..6 Video format identification */
-       u8      db4_videocode;
-       /* PR0..PR3 Pixel repetition factor */
-       u8      db5_pixel_repeat;
-       /* Line number end of top bar */
-       u16     db6_7_line_eoftop;
-       /* Line number start of bottom bar */
-       u16     db8_9_line_sofbottom;
-       /* Pixel number end of left bar */
-       u16     db10_11_pixel_eofleft;
-       /* Pixel number start of right bar */
-       u16     db12_13_pixel_sofright;
-};
-
-struct hdmi_ip_data {
-       void __iomem    *base_wp;       /* HDMI wrapper */
-       unsigned long   core_sys_offset;
-       unsigned long   core_av_offset;
-       unsigned long   pll_offset;
-       unsigned long   phy_offset;
-       int             irq;
-       const struct ti_hdmi_ip_ops *ops;
-       struct hdmi_config cfg;
-       struct hdmi_pll_info pll_data;
-       struct hdmi_core_infoframe_avi avi_cfg;
-
-       /* ti_hdmi_4xxx_ip private data. These should be in a separate struct */
-       struct mutex lock;
-};
-int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data);
-void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data);
-int ti_hdmi_4xxx_read_edid(struct hdmi_ip_data *ip_data, u8 *edid, int len);
-int ti_hdmi_4xxx_wp_video_start(struct hdmi_ip_data *ip_data);
-void ti_hdmi_4xxx_wp_video_stop(struct hdmi_ip_data *ip_data);
-int ti_hdmi_4xxx_pll_enable(struct hdmi_ip_data *ip_data);
-void ti_hdmi_4xxx_pll_disable(struct hdmi_ip_data *ip_data);
-void ti_hdmi_4xxx_basic_configure(struct hdmi_ip_data *ip_data);
-void ti_hdmi_4xxx_wp_dump(struct hdmi_ip_data *ip_data, struct seq_file *s);
-void ti_hdmi_4xxx_pll_dump(struct hdmi_ip_data *ip_data, struct seq_file *s);
-void ti_hdmi_4xxx_core_dump(struct hdmi_ip_data *ip_data, struct seq_file *s);
-void ti_hdmi_4xxx_phy_dump(struct hdmi_ip_data *ip_data, struct seq_file *s);
-#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
-int hdmi_compute_acr(u32 sample_freq, u32 *n, u32 *cts);
-int ti_hdmi_4xxx_wp_audio_enable(struct hdmi_ip_data *ip_data);
-void ti_hdmi_4xxx_wp_audio_disable(struct hdmi_ip_data *ip_data);
-int ti_hdmi_4xxx_audio_start(struct hdmi_ip_data *ip_data);
-void ti_hdmi_4xxx_audio_stop(struct hdmi_ip_data *ip_data);
-int ti_hdmi_4xxx_audio_config(struct hdmi_ip_data *ip_data,
-               struct omap_dss_audio *audio);
-int ti_hdmi_4xxx_audio_get_dma_port(u32 *offset, u32 *size);
-#endif
-#endif
index 4b23af6e5c2890b41f47fd38a9e88ce2de3ebc9c..367cea8f43f3944301b26c51a4514b6269403106 100644 (file)
@@ -339,8 +339,6 @@ static int p9100_remove(struct platform_device *op)
 
        framebuffer_release(info);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 3d86bac62d3e62214564bf1f336488d6ee819eeb..b644037dd5bc1385634d74aa65feaf415de57d9e 100644 (file)
@@ -639,7 +639,6 @@ static int platinumfb_probe(struct platform_device* odev)
                iounmap(pinfo->frame_buffer);
                iounmap(pinfo->platinum_regs);
                iounmap(pinfo->cmap_regs);
-               dev_set_drvdata(&odev->dev, NULL);
                framebuffer_release(info);
        }
 
index 81354eeab0214e106ae89e1e5ad321afbbf000ce..45d9a3fe35e7919163de63234da3691ba014cd8b 100644 (file)
@@ -1744,7 +1744,6 @@ static void pm2fb_remove(struct pci_dev *pdev)
        iounmap(par->v_regs);
        release_mem_region(fix->mmio_start, fix->mmio_len);
 
-       pci_set_drvdata(pdev, NULL);
        fb_dealloc_cmap(&info->cmap);
        kfree(info->pixmap.addr);
        framebuffer_release(info);
index 7718faa4a73b751d37525d5e775f21e32d4dca64..9c17474340cd97fc8f63104cbe5142471f6d4039 100644 (file)
@@ -1489,7 +1489,6 @@ static void pm3fb_remove(struct pci_dev *dev)
                iounmap(par->v_regs);
                release_mem_region(fix->mmio_start, fix->mmio_len);
 
-               pci_set_drvdata(dev, NULL);
                kfree(info->pixmap.addr);
                framebuffer_release(info);
        }
index aa9bd1f76d60641d4a242829dc5ed89b4e393976..c95b9e46d48ff3a02206e2669b00730816f26932 100644 (file)
@@ -364,7 +364,7 @@ static void set_graphics_start(struct fb_info *info, int xoffset, int yoffset)
 static void set_dumb_panel_control(struct fb_info *info)
 {
        struct pxa168fb_info *fbi = info->par;
-       struct pxa168fb_mach_info *mi = fbi->dev->platform_data;
+       struct pxa168fb_mach_info *mi = dev_get_platdata(fbi->dev);
        u32 x;
 
        /*
@@ -407,7 +407,7 @@ static int pxa168fb_set_par(struct fb_info *info)
        u32 x;
        struct pxa168fb_mach_info *mi;
 
-       mi = fbi->dev->platform_data;
+       mi = dev_get_platdata(fbi->dev);
 
        /*
         * Set additional mode info.
@@ -609,7 +609,7 @@ static int pxa168fb_probe(struct platform_device *pdev)
        struct clk *clk;
        int irq, ret;
 
-       mi = pdev->dev.platform_data;
+       mi = dev_get_platdata(&pdev->dev);
        if (mi == NULL) {
                dev_err(&pdev->dev, "no platform data defined\n");
                return -EINVAL;
index eca2de45f7a62d838f65e8a201aade28869c780b..1ecd9cec292195f80495dfe0e148ca15170b4c9e 100644 (file)
@@ -457,7 +457,7 @@ static int pxafb_adjust_timing(struct pxafb_info *fbi,
 static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
        struct pxafb_info *fbi = (struct pxafb_info *)info;
-       struct pxafb_mach_info *inf = fbi->dev->platform_data;
+       struct pxafb_mach_info *inf = dev_get_platdata(fbi->dev);
        int err;
 
        if (inf->fixed_modes) {
@@ -1230,7 +1230,7 @@ static unsigned int __smart_timing(unsigned time_ns, unsigned long lcd_clk)
 static void setup_smart_timing(struct pxafb_info *fbi,
                                struct fb_var_screeninfo *var)
 {
-       struct pxafb_mach_info *inf = fbi->dev->platform_data;
+       struct pxafb_mach_info *inf = dev_get_platdata(fbi->dev);
        struct pxafb_mode_info *mode = &inf->modes[0];
        unsigned long lclk = clk_get_rate(fbi->clk);
        unsigned t1, t2, t3, t4;
@@ -1258,14 +1258,14 @@ static void setup_smart_timing(struct pxafb_info *fbi,
 static int pxafb_smart_thread(void *arg)
 {
        struct pxafb_info *fbi = arg;
-       struct pxafb_mach_info *inf = fbi->dev->platform_data;
+       struct pxafb_mach_info *inf = dev_get_platdata(fbi->dev);
 
        if (!inf->smart_update) {
                pr_err("%s: not properly initialized, thread terminated\n",
                                __func__);
                return -EINVAL;
        }
-       inf = fbi->dev->platform_data;
+       inf = dev_get_platdata(fbi->dev);
 
        pr_debug("%s(): task starting\n", __func__);
 
@@ -1793,7 +1793,7 @@ static struct pxafb_info *pxafb_init_fbinfo(struct device *dev)
 {
        struct pxafb_info *fbi;
        void *addr;
-       struct pxafb_mach_info *inf = dev->platform_data;
+       struct pxafb_mach_info *inf = dev_get_platdata(dev);
 
        /* Alloc the pxafb_info and pseudo_palette in one step */
        fbi = kmalloc(sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL);
@@ -1855,7 +1855,7 @@ static struct pxafb_info *pxafb_init_fbinfo(struct device *dev)
 #ifdef CONFIG_FB_PXA_PARAMETERS
 static int parse_opt_mode(struct device *dev, const char *this_opt)
 {
-       struct pxafb_mach_info *inf = dev->platform_data;
+       struct pxafb_mach_info *inf = dev_get_platdata(dev);
 
        const char *name = this_opt+5;
        unsigned int namelen = strlen(name);
@@ -1914,7 +1914,7 @@ done:
 
 static int parse_opt(struct device *dev, char *this_opt)
 {
-       struct pxafb_mach_info *inf = dev->platform_data;
+       struct pxafb_mach_info *inf = dev_get_platdata(dev);
        struct pxafb_mode_info *mode = &inf->modes[0];
        char s[64];
 
@@ -2102,7 +2102,7 @@ static int pxafb_probe(struct platform_device *dev)
 
        dev_dbg(&dev->dev, "pxafb_probe\n");
 
-       inf = dev->dev.platform_data;
+       inf = dev_get_platdata(&dev->dev);
        ret = -ENOMEM;
        fbi = NULL;
        if (!inf)
index 9536715b5a1b90f1828451300016e45b90ecb1a9..a5514acd2ac685447a341a2373fc0d55ffbd2018 100644 (file)
@@ -1185,11 +1185,6 @@ static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
        if (rivafb_do_maximize(info, var, nom, den) < 0)
                return -EINVAL;
 
-       if (var->xoffset < 0)
-               var->xoffset = 0;
-       if (var->yoffset < 0)
-               var->yoffset = 0;
-
        /* truncate xoffset and yoffset to maximum if too high */
        if (var->xoffset > var->xres_virtual - var->xres)
                var->xoffset = var->xres_virtual - var->xres - 1;
index 05c2dc3d4bc0ba5e0f0e23f1aa9d69cba8c0bcdb..1399a469f8b03e69ca6afb267a5e9a04de1085fc 100644 (file)
@@ -777,8 +777,8 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
        printk(KERN_INFO "Epson S1D13XXX FB Driver\n");
 
        /* enable platform-dependent hardware glue, if any */
-       if (pdev->dev.platform_data)
-               pdata = pdev->dev.platform_data;
+       if (dev_get_platdata(&pdev->dev))
+               pdata = dev_get_platdata(&pdev->dev);
 
        if (pdata && pdata->platform_init_video)
                pdata->platform_init_video();
@@ -923,8 +923,8 @@ static int s1d13xxxfb_suspend(struct platform_device *dev, pm_message_t state)
        lcd_enable(s1dfb, 0);
        crt_enable(s1dfb, 0);
 
-       if (dev->dev.platform_data)
-               pdata = dev->dev.platform_data;
+       if (dev_get_platdata(&dev->dev))
+               pdata = dev_get_platdata(&dev->dev);
 
 #if 0
        if (!s1dfb->disp_save)
@@ -973,8 +973,8 @@ static int s1d13xxxfb_resume(struct platform_device *dev)
        while ((s1d13xxxfb_readreg(s1dfb, S1DREG_PS_STATUS) & 0x01))
                udelay(10);
 
-       if (dev->dev.platform_data)
-               pdata = dev->dev.platform_data;
+       if (dev_get_platdata(&dev->dev))
+               pdata = dev_get_platdata(&dev->dev);
 
        if (s1dfb->regs_save) {
                /* will write RO regs, *should* get away with it :) */
index 2e7991c7ca088dca9688dd7a8ec13d715c25435f..62acae2694a9968ccbcd3f2773f3be468580a2c6 100644 (file)
@@ -1378,7 +1378,7 @@ static int s3c_fb_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       pd = pdev->dev.platform_data;
+       pd = dev_get_platdata(&pdev->dev);
        if (!pd) {
                dev_err(dev, "no platform data specified\n");
                return -EINVAL;
index 21a32adbb8ead4dde3e423f62108e2111be05533..81af5a63e9e1d524516c90643a975002a8c77c01 100644 (file)
@@ -123,7 +123,7 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var,
                               struct fb_info *info)
 {
        struct s3c2410fb_info *fbi = info->par;
-       struct s3c2410fb_mach_info *mach_info = fbi->dev->platform_data;
+       struct s3c2410fb_mach_info *mach_info = dev_get_platdata(fbi->dev);
        struct s3c2410fb_display *display = NULL;
        struct s3c2410fb_display *default_display = mach_info->displays +
                                                    mach_info->default_display;
@@ -686,7 +686,7 @@ static inline void modify_gpio(void __iomem *reg,
 static int s3c2410fb_init_registers(struct fb_info *info)
 {
        struct s3c2410fb_info *fbi = info->par;
-       struct s3c2410fb_mach_info *mach_info = fbi->dev->platform_data;
+       struct s3c2410fb_mach_info *mach_info = dev_get_platdata(fbi->dev);
        unsigned long flags;
        void __iomem *regs = fbi->io;
        void __iomem *tpal;
@@ -833,7 +833,7 @@ static int s3c24xxfb_probe(struct platform_device *pdev,
        int size;
        u32 lcdcon1;
 
-       mach_info = pdev->dev.platform_data;
+       mach_info = dev_get_platdata(&pdev->dev);
        if (mach_info == NULL) {
                dev_err(&pdev->dev,
                        "no platform data for lcd, cannot attach\n");
index d838ba829459400acc86388cbeda1bab77f57b24..fef655d8fca4320eddc5f05cf2c8026f2c989793 100644 (file)
@@ -1424,7 +1424,6 @@ static void s3_pci_remove(struct pci_dev *dev)
                pci_release_regions(dev);
 /*             pci_disable_device(dev); */
 
-               pci_set_drvdata(dev, NULL);
                framebuffer_release(info);
        }
 }
index de76da0c6429a942ca87e5e73841259371aff4b4..580c444ec301d3c3c58b6ca4ebba2dbb2e608b62 100644 (file)
@@ -1116,7 +1116,7 @@ static struct fb_monspecs monspecs = {
 
 static struct sa1100fb_info *sa1100fb_init_fbinfo(struct device *dev)
 {
-       struct sa1100fb_mach_info *inf = dev->platform_data;
+       struct sa1100fb_mach_info *inf = dev_get_platdata(dev);
        struct sa1100fb_info *fbi;
        unsigned i;
 
@@ -1201,7 +1201,7 @@ static int sa1100fb_probe(struct platform_device *pdev)
        struct resource *res;
        int ret, irq;
 
-       if (!pdev->dev.platform_data) {
+       if (!dev_get_platdata(&pdev->dev)) {
                dev_err(&pdev->dev, "no platform LCD data\n");
                return -EINVAL;
        }
index 741b2395d01e483eb347e398549fbcc3881368d7..4dbf45f3b21a3d6b9bc7287d23bf305f27a0de16 100644 (file)
@@ -2362,12 +2362,6 @@ static void savagefb_remove(struct pci_dev *dev)
                kfree(info->pixmap.addr);
                pci_release_regions(dev);
                framebuffer_release(info);
-
-               /*
-                * Ensure that the driver data is no longer
-                * valid.
-                */
-               pci_set_drvdata(dev, NULL);
        }
 }
 
index bfe4728480fd9fb7909d1845dd50b3b753390a53..5e2845b9f3a8b2da1c09cc24eaee526223648750 100644 (file)
@@ -498,7 +498,7 @@ static void sh_hdmi_video_config(struct sh_hdmi *hdmi)
 static void sh_hdmi_audio_config(struct sh_hdmi *hdmi)
 {
        u8 data;
-       struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
+       struct sh_mobile_hdmi_info *pdata = dev_get_platdata(hdmi->dev);
 
        /*
         * [7:4] L/R data swap control
@@ -815,7 +815,7 @@ static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi,
                unsigned long *hdmi_rate, unsigned long *parent_rate)
 {
        unsigned long target = PICOS2KHZ(mode->pixclock) * 1000, rate_error;
-       struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
+       struct sh_mobile_hdmi_info *pdata = dev_get_platdata(hdmi->dev);
 
        *hdmi_rate = clk_round_rate(hdmi->hdmi_clk, target);
        if ((long)*hdmi_rate < 0)
@@ -1271,7 +1271,7 @@ static void sh_hdmi_htop1_init(struct sh_hdmi *hdmi)
 
 static int __init sh_hdmi_probe(struct platform_device *pdev)
 {
-       struct sh_mobile_hdmi_info *pdata = pdev->dev.platform_data;
+       struct sh_mobile_hdmi_info *pdata = dev_get_platdata(&pdev->dev);
        struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        struct resource *htop1_res;
        int irq = platform_get_irq(pdev, 0), ret;
@@ -1290,7 +1290,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
                }
        }
 
-       hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
+       hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
        if (!hdmi) {
                dev_err(&pdev->dev, "Cannot allocate device data\n");
                return -ENOMEM;
@@ -1304,7 +1304,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
        if (IS_ERR(hdmi->hdmi_clk)) {
                ret = PTR_ERR(hdmi->hdmi_clk);
                dev_err(&pdev->dev, "Unable to get clock: %d\n", ret);
-               goto egetclk;
+               return ret;
        }
 
        /* select register access functions */
@@ -1407,8 +1407,6 @@ ereqreg:
        clk_disable(hdmi->hdmi_clk);
 erate:
        clk_put(hdmi->hdmi_clk);
-egetclk:
-       kfree(hdmi);
 
        return ret;
 }
@@ -1433,7 +1431,6 @@ static int __exit sh_hdmi_remove(struct platform_device *pdev)
                iounmap(hdmi->htop1);
        iounmap(hdmi->base);
        release_mem_region(res->start, resource_size(res));
-       kfree(hdmi);
 
        return 0;
 }
index 8d781061305836c4a68d6aa8801cf979e3734e29..08c764cfeff3564c602bd0e61592317af6d42f65 100644 (file)
@@ -132,7 +132,7 @@ static int simplefb_parse_dt(struct platform_device *pdev,
 static int simplefb_parse_pd(struct platform_device *pdev,
                             struct simplefb_params *params)
 {
-       struct simplefb_platform_data *pd = pdev->dev.platform_data;
+       struct simplefb_platform_data *pd = dev_get_platdata(&pdev->dev);
        int i;
 
        params->width = pd->width;
@@ -167,7 +167,7 @@ static int simplefb_probe(struct platform_device *pdev)
                return -ENODEV;
 
        ret = -ENODEV;
-       if (pdev->dev.platform_data)
+       if (dev_get_platdata(&pdev->dev))
                ret = simplefb_parse_pd(pdev, &params);
        else if (pdev->dev.of_node)
                ret = simplefb_parse_dt(pdev, &params);
@@ -220,6 +220,14 @@ static int simplefb_probe(struct platform_device *pdev)
        }
        info->pseudo_palette = (void *)(info + 1);
 
+       dev_info(&pdev->dev, "framebuffer at 0x%lx, 0x%x bytes, mapped to 0x%p\n",
+                            info->fix.smem_start, info->fix.smem_len,
+                            info->screen_base);
+       dev_info(&pdev->dev, "format=%s, mode=%dx%dx%d, linelength=%d\n",
+                            params.format->name,
+                            info->var.xres, info->var.yres,
+                            info->var.bits_per_pixel, info->fix.line_length);
+
        ret = register_framebuffer(info);
        if (ret < 0) {
                dev_err(&pdev->dev, "Unable to register simplefb: %d\n", ret);
index 977e27927a211ab0fffcd37087f90e0c0fa86e9f..793b40238fcabb3f990a40ef333fa11e963a79e7 100644 (file)
@@ -5994,7 +5994,6 @@ static int sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if(!ivideo->sisvga_enabled) {
                if(pci_enable_device(pdev)) {
                        if(ivideo->nbridge) pci_dev_put(ivideo->nbridge);
-                       pci_set_drvdata(pdev, NULL);
                        framebuffer_release(sis_fb_info);
                        return -EIO;
                }
@@ -6211,7 +6210,6 @@ error_3:  vfree(ivideo->bios_abase);
                        pci_dev_put(ivideo->lpcdev);
                if(ivideo->nbridge)
                        pci_dev_put(ivideo->nbridge);
-               pci_set_drvdata(pdev, NULL);
                if(!ivideo->sisvga_enabled)
                        pci_disable_device(pdev);
                framebuffer_release(sis_fb_info);
@@ -6523,8 +6521,6 @@ static void sisfb_remove(struct pci_dev *pdev)
                mtrr_del(ivideo->mtrr, ivideo->video_base, ivideo->video_size);
 #endif
 
-       pci_set_drvdata(pdev, NULL);
-
        /* If device was disabled when starting, disable
         * it when quitting.
         */
index e188ada2ffd1cf7d72c826dbbb18a134d49b1458..d513ed6a49f2ec3fdf5b9786879d7f65f8e780c0 100644 (file)
@@ -1147,7 +1147,7 @@ static void ufx_free_framebuffer_work(struct work_struct *work)
 
        fb_destroy_modelist(&info->modelist);
 
-       dev->info = 0;
+       dev->info = NULL;
 
        /* Assume info structure is freed after this point */
        framebuffer_release(info);
index 44967c8fef2b5a344d9e6a78e1339e148f2fbd20..f4daa59f0a80bffd9427c957599d47f518c63d57 100644 (file)
@@ -569,7 +569,7 @@ static struct i2c_driver ssd1307fb_driver = {
        .id_table = ssd1307fb_i2c_id,
        .driver = {
                .name = "ssd1307fb",
-               .of_match_table = of_match_ptr(ssd1307fb_of_match),
+               .of_match_table = ssd1307fb_of_match,
                .owner = THIS_MODULE,
        },
 };
index cc6f48bba36be34f167710f0be7ed7e50da601fa..58241b47a96dd29b106ee05a83394f95b11f3bb2 100644 (file)
@@ -186,8 +186,6 @@ static int gfb_remove(struct platform_device *op)
 
         framebuffer_release(info);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index c000852500aa06822f19bb713b5f0b27c94359ab..1f3a3271f3dd41b5f7217643ff4e01063aa32e98 100644 (file)
@@ -498,8 +498,6 @@ static int tcx_remove(struct platform_device *op)
 
        framebuffer_release(info);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 64bc28ba40375cdca47cd3219bba3e61b4a89d70..f761fe375f5b265122817242fb3668feaa495ebe 100644 (file)
@@ -1646,7 +1646,6 @@ static void tdfxfb_remove(struct pci_dev *pdev)
                           pci_resource_len(pdev, 1));
        release_mem_region(pci_resource_start(pdev, 0),
                           pci_resource_len(pdev, 0));
-       pci_set_drvdata(pdev, NULL);
        fb_dealloc_cmap(&info->cmap);
        framebuffer_release(info);
 }
index deb8733f3c70dd3f8e83508b8ff086cbf6cbcdbf..b5b69a6b9dd8dd104f448f5b7cbd0265986bfbd2 100644 (file)
@@ -250,7 +250,7 @@ static irqreturn_t tmiofb_irq(int irq, void *__info)
  */
 static int tmiofb_hw_stop(struct platform_device *dev)
 {
-       struct tmio_fb_data *data = dev->dev.platform_data;
+       struct tmio_fb_data *data = dev_get_platdata(&dev->dev);
        struct fb_info *info = platform_get_drvdata(dev);
        struct tmiofb_par *par = info->par;
 
@@ -311,7 +311,7 @@ static int tmiofb_hw_init(struct platform_device *dev)
  */
 static void tmiofb_hw_mode(struct platform_device *dev)
 {
-       struct tmio_fb_data *data = dev->dev.platform_data;
+       struct tmio_fb_data *data = dev_get_platdata(&dev->dev);
        struct fb_info *info = platform_get_drvdata(dev);
        struct fb_videomode *mode = info->mode;
        struct tmiofb_par *par = info->par;
@@ -557,7 +557,7 @@ static int tmiofb_ioctl(struct fb_info *fbi,
 static struct fb_videomode *
 tmiofb_find_mode(struct fb_info *info, struct fb_var_screeninfo *var)
 {
-       struct tmio_fb_data *data = info->device->platform_data;
+       struct tmio_fb_data *data = dev_get_platdata(info->device);
        struct fb_videomode *best = NULL;
        int i;
 
@@ -577,7 +577,7 @@ static int tmiofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
 
        struct fb_videomode *mode;
-       struct tmio_fb_data *data = info->device->platform_data;
+       struct tmio_fb_data *data = dev_get_platdata(info->device);
 
        mode = tmiofb_find_mode(info, var);
        if (!mode || var->bits_per_pixel > 16)
@@ -678,7 +678,7 @@ static struct fb_ops tmiofb_ops = {
 static int tmiofb_probe(struct platform_device *dev)
 {
        const struct mfd_cell *cell = mfd_get_cell(dev);
-       struct tmio_fb_data *data = dev->dev.platform_data;
+       struct tmio_fb_data *data = dev_get_platdata(&dev->dev);
        struct resource *ccr = platform_get_resource(dev, IORESOURCE_MEM, 1);
        struct resource *lcr = platform_get_resource(dev, IORESOURCE_MEM, 0);
        struct resource *vram = platform_get_resource(dev, IORESOURCE_MEM, 2);
index ab57d387d6b5ffc093407ad9b2a0d55ddb8fe50e..7ed9a227f5eaf006ed5c2a9759ee9db299d114e3 100644 (file)
@@ -1553,7 +1553,6 @@ static void trident_pci_remove(struct pci_dev *dev)
        iounmap(info->screen_base);
        release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
        release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
-       pci_set_drvdata(dev, NULL);
        kfree(info->pixmap.addr);
        fb_dealloc_cmap(&info->cmap);
        framebuffer_release(info);
index d2e5bc3cf9696f4b1ab9785f10ff0a56c102a41a..025f14e30eed27d8f77b6e9c9522be802a77ebc8 100644 (file)
@@ -1166,7 +1166,7 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dev, struct fb_info *info)
        int new_len;
        unsigned char *old_fb = info->screen_base;
        unsigned char *new_fb;
-       unsigned char *new_back = 0;
+       unsigned char *new_back = NULL;
 
        pr_warn("Reallocating framebuffer. Addresses will change!\n");
 
index 7aec6f39fdd5461beb16d700ed201212ba9d1704..676a4b9379d9c95b7d38f5c6f61c0688584a18bd 100644 (file)
@@ -233,8 +233,7 @@ out:
 static void uvesafb_free(struct uvesafb_ktask *task)
 {
        if (task) {
-               if (task->done)
-                       kfree(task->done);
+               kfree(task->done);
                kfree(task);
        }
 }
@@ -1332,8 +1331,8 @@ setmode:
                                FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
        info->fix.line_length = mode->bytes_per_scan_line;
 
-out:   if (crtc != NULL)
-               kfree(crtc);
+out:
+       kfree(crtc);
        uvesafb_free(task);
 
        return err;
@@ -1793,8 +1792,7 @@ out_mode:
        fb_destroy_modedb(info->monspecs.modedb);
        fb_dealloc_cmap(&info->cmap);
 out:
-       if (par->vbe_modes)
-               kfree(par->vbe_modes);
+       kfree(par->vbe_modes);
 
        framebuffer_release(info);
        return err;
@@ -1817,12 +1815,9 @@ static int uvesafb_remove(struct platform_device *dev)
                fb_dealloc_cmap(&info->cmap);
 
                if (par) {
-                       if (par->vbe_modes)
-                               kfree(par->vbe_modes);
-                       if (par->vbe_state_orig)
-                               kfree(par->vbe_state_orig);
-                       if (par->vbe_state_saved)
-                               kfree(par->vbe_state_saved);
+                       kfree(par->vbe_modes);
+                       kfree(par->vbe_state_orig);
+                       kfree(par->vbe_state_saved);
                }
 
                framebuffer_release(info);
index ee5985efa15c83c64d7e22718c22c594e0338f0e..ea2b523f804f17be41fcca523942ba3eb6b4f697 100644 (file)
@@ -390,9 +390,8 @@ static int vfb_pan_display(struct fb_var_screeninfo *var,
                           struct fb_info *info)
 {
        if (var->vmode & FB_VMODE_YWRAP) {
-               if (var->yoffset < 0
-                   || var->yoffset >= info->var.yres_virtual
-                   || var->xoffset)
+               if (var->yoffset >= info->var.yres_virtual ||
+                   var->xoffset)
                        return -EINVAL;
        } else {
                if (var->xoffset + info->var.xres > info->var.xres_virtual ||
index e9557fa014eec0f201b1f91c38970097a37fd5e5..6b424ddd6793b1c4a11bc029ceac6df843763e87 100644 (file)
@@ -829,7 +829,6 @@ static void vt8623_pci_remove(struct pci_dev *dev)
                pci_release_regions(dev);
 /*             pci_disable_device(dev); */
 
-               pci_set_drvdata(dev, NULL);
                framebuffer_release(info);
        }
 }
index 7a299e951f75421a7a4112eae5af284cc977a6ca..2a0437a6d838d22153d5437334dc7171895560a5 100644 (file)
@@ -680,7 +680,7 @@ int w100fb_probe(struct platform_device *pdev)
        par = info->par;
        platform_set_drvdata(pdev, info);
 
-       inf = pdev->dev.platform_data;
+       inf = dev_get_platdata(&pdev->dev);
        par->chip_id = chip_id;
        par->mach = inf;
        par->fastpll_mode = 0;
index 3072f30cad1984d23309a2d3430adc2f60d625f8..2bf618037b13c05f9eb467068c674b7e39bc349a 100644 (file)
@@ -411,7 +411,7 @@ static struct platform_driver wm8505fb_driver = {
        .driver         = {
                .owner  = THIS_MODULE,
                .name   = DRIVER_NAME,
-               .of_match_table = of_match_ptr(wmt_dt_ids),
+               .of_match_table = wmt_dt_ids,
        },
 };
 
index 4aaeb18223bcff371bfac7b9d8653f2c6fdef80b..b0a9f34b2e01b7b45b1a0d86e25889e3f52fc434 100644 (file)
@@ -169,13 +169,13 @@ static struct platform_driver wmt_ge_rops_driver = {
        .driver         = {
                .owner  = THIS_MODULE,
                .name   = "wmt_ge_rops",
-               .of_match_table = of_match_ptr(wmt_dt_ids),
+               .of_match_table = wmt_dt_ids,
        },
 };
 
 module_platform_driver(wmt_ge_rops_driver);
 
-MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com");
+MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com>");
 MODULE_DESCRIPTION("Accelerators for raster operations using "
                   "WonderMedia Graphics Engine");
 MODULE_LICENSE("GPL v2");
index 84c664ea8eb9d014e101f3d22f614352cde306ef..9eedf9673b7f2246eb46c178664a2441d4cc4dcc 100644 (file)
@@ -260,10 +260,9 @@ static int xilinxfb_assign(struct platform_device *pdev,
 
                res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
                drvdata->regs = devm_ioremap_resource(&pdev->dev, res);
-               if (IS_ERR(drvdata->regs)) {
-                       rc = PTR_ERR(drvdata->regs);
-                       goto err_region;
-               }
+               if (IS_ERR(drvdata->regs))
+                       return PTR_ERR(drvdata->regs);
+
                drvdata->regs_phys = res->start;
        }
 
@@ -279,11 +278,7 @@ static int xilinxfb_assign(struct platform_device *pdev,
 
        if (!drvdata->fb_virt) {
                dev_err(dev, "Could not allocate frame buffer memory\n");
-               rc = -ENOMEM;
-               if (drvdata->flags & BUS_ACCESS_FLAG)
-                       goto err_fbmem;
-               else
-                       goto err_region;
+               return -ENOMEM;
        }
 
        /* Clear (turn to black) the framebuffer */
@@ -363,14 +358,6 @@ err_cmap:
        /* Turn off the display */
        xilinx_fb_out32(drvdata, REG_CTRL, 0);
 
-err_fbmem:
-       if (drvdata->flags & BUS_ACCESS_FLAG)
-               devm_iounmap(dev, drvdata->regs);
-
-err_region:
-       kfree(drvdata);
-       dev_set_drvdata(dev, NULL);
-
        return rc;
 }
 
@@ -395,17 +382,12 @@ static int xilinxfb_release(struct device *dev)
        /* Turn off the display */
        xilinx_fb_out32(drvdata, REG_CTRL, 0);
 
-       /* Release the resources, as allocated based on interface */
-       if (drvdata->flags & BUS_ACCESS_FLAG)
-               devm_iounmap(dev, drvdata->regs);
 #ifdef CONFIG_PPC_DCR
-       else
+       /* Release the resources, as allocated based on interface */
+       if (!(drvdata->flags & BUS_ACCESS_FLAG))
                dcr_unmap(drvdata->dcr_host, drvdata->dcr_len);
 #endif
 
-       kfree(drvdata);
-       dev_set_drvdata(dev, NULL);
-
        return 0;
 }
 
@@ -413,7 +395,7 @@ static int xilinxfb_release(struct device *dev)
  * OF bus binding
  */
 
-static int xilinxfb_of_probe(struct platform_device *op)
+static int xilinxfb_of_probe(struct platform_device *pdev)
 {
        const u32 *prop;
        u32 tft_access = 0;
@@ -425,17 +407,15 @@ static int xilinxfb_of_probe(struct platform_device *op)
        pdata = xilinx_fb_default_pdata;
 
        /* Allocate the driver data region */
-       drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
-       if (!drvdata) {
-               dev_err(&op->dev, "Couldn't allocate device private record\n");
+       drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
+       if (!drvdata)
                return -ENOMEM;
-       }
 
        /*
         * To check whether the core is connected directly to DCR or BUS
         * interface and initialize the tft_access accordingly.
         */
-       of_property_read_u32(op->dev.of_node, "xlnx,dcr-splb-slave-if",
+       of_property_read_u32(pdev->dev.of_node, "xlnx,dcr-splb-slave-if",
                             &tft_access);
 
        /*
@@ -453,35 +433,34 @@ static int xilinxfb_of_probe(struct platform_device *op)
                drvdata->dcr_host = dcr_map(op->dev.of_node, start, drvdata->dcr_len);
                if (!DCR_MAP_OK(drvdata->dcr_host)) {
                        dev_err(&op->dev, "invalid DCR address\n");
-                       kfree(drvdata);
                        return -ENODEV;
                }
        }
 #endif
 
-       prop = of_get_property(op->dev.of_node, "phys-size", &size);
+       prop = of_get_property(pdev->dev.of_node, "phys-size", &size);
        if ((prop) && (size >= sizeof(u32)*2)) {
                pdata.screen_width_mm = prop[0];
                pdata.screen_height_mm = prop[1];
        }
 
-       prop = of_get_property(op->dev.of_node, "resolution", &size);
+       prop = of_get_property(pdev->dev.of_node, "resolution", &size);
        if ((prop) && (size >= sizeof(u32)*2)) {
                pdata.xres = prop[0];
                pdata.yres = prop[1];
        }
 
-       prop = of_get_property(op->dev.of_node, "virtual-resolution", &size);
+       prop = of_get_property(pdev->dev.of_node, "virtual-resolution", &size);
        if ((prop) && (size >= sizeof(u32)*2)) {
                pdata.xvirt = prop[0];
                pdata.yvirt = prop[1];
        }
 
-       if (of_find_property(op->dev.of_node, "rotate-display", NULL))
+       if (of_find_property(pdev->dev.of_node, "rotate-display", NULL))
                pdata.rotate_screen = 1;
 
-       dev_set_drvdata(&op->dev, drvdata);
-       return xilinxfb_assign(op, drvdata, &pdata);
+       dev_set_drvdata(&pdev->dev, drvdata);
+       return xilinxfb_assign(pdev, drvdata, &pdata);
 }
 
 static int xilinxfb_of_remove(struct platform_device *op)
index 0f5a2fc69af9971606a1b07185e6f366bf21fbec..c79f3813192675c96ecea7ecd57c41d2fd522422 100644 (file)
 #define ATMEL_LCDC_WIRING_BGR  0
 #define ATMEL_LCDC_WIRING_RGB  1
 
-struct atmel_lcdfb_config;
 
  /* LCD Controller info data structure, stored in device platform_data */
-struct atmel_lcdfb_info {
-       spinlock_t              lock;
-       struct fb_info          *info;
-       void __iomem            *mmio;
-       int                     irq_base;
-       struct work_struct      task;
-
+struct atmel_lcdfb_pdata {
        unsigned int            guard_time;
-       unsigned int            smem_len;
-       struct platform_device  *pdev;
-       struct clk              *bus_clk;
-       struct clk              *lcdc_clk;
-
-#ifdef CONFIG_BACKLIGHT_ATMEL_LCDC
-       struct backlight_device *backlight;
-       u8                      bl_power;
-#endif
        bool                    lcdcon_is_backlight;
        bool                    lcdcon_pol_negative;
-       u8                      saved_lcdcon;
-
        u8                      default_bpp;
        u8                      lcd_wiring_mode;
        unsigned int            default_lcdcon2;
        unsigned int            default_dmacon;
-       void (*atmel_lcdfb_power_control)(int on);
+       void (*atmel_lcdfb_power_control)(struct atmel_lcdfb_pdata *pdata, int on);
        struct fb_monspecs      *default_monspecs;
-       u32                     pseudo_palette[16];
 
-       struct atmel_lcdfb_config *config;
+       struct list_head        pwr_gpios;
 };
 
 #define ATMEL_LCDC_DMABADDR1   0x00
index b9dd1fbb00827d29aff8b3ff5d814d85715a2245..9fd9398368d5845e9e0cf09b8e1276d84927bde3 100644 (file)
@@ -91,6 +91,11 @@ struct mmp_win {
        u16     up_crop;
        u16     bottom_crop;
        int     pix_fmt;
+       /*
+        * pitch[0]: graphics/video layer line length or y pitch
+        * pitch[1]/pitch[2]: video u/v pitch if non-zero
+        */
+       u32     pitch[3];
 };
 
 struct mmp_addr {
@@ -334,6 +339,7 @@ struct mmp_mach_path_config {
        int output_type;
        u32 path_config;
        u32 link_config;
+       u32 dsi_rbswap;
 };
 
 struct mmp_mach_plat_info {