Commit f9b4a5ce authored by Florian Tobias Schandinat's avatar Florian Tobias Schandinat

Merge branch 'for-next' of git://linuxtv.org/pinchartl/fbdev into fbdev-next

parents afb0499b af89956b
...@@ -229,16 +229,6 @@ static void lcd_backlight_reset(void) ...@@ -229,16 +229,6 @@ static void lcd_backlight_reset(void)
gpio_set_value(GPIO_PORT235, 1); gpio_set_value(GPIO_PORT235, 1);
} }
static void lcd_on(void *board_data, struct fb_info *info)
{
lcd_backlight_on();
}
static void lcd_off(void *board_data)
{
lcd_backlight_reset();
}
/* LCDC0 */ /* LCDC0 */
static const struct fb_videomode lcdc0_modes[] = { static const struct fb_videomode lcdc0_modes[] = {
{ {
...@@ -262,14 +252,14 @@ static struct sh_mobile_lcdc_info lcdc0_info = { ...@@ -262,14 +252,14 @@ static struct sh_mobile_lcdc_info lcdc0_info = {
.interface_type = RGB24, .interface_type = RGB24,
.clock_divider = 1, .clock_divider = 1,
.flags = LCDC_FLAGS_DWPOL, .flags = LCDC_FLAGS_DWPOL,
.lcd_size_cfg.width = 44,
.lcd_size_cfg.height = 79,
.fourcc = V4L2_PIX_FMT_RGB565, .fourcc = V4L2_PIX_FMT_RGB565,
.lcd_cfg = lcdc0_modes, .lcd_modes = lcdc0_modes,
.num_cfg = ARRAY_SIZE(lcdc0_modes), .num_modes = ARRAY_SIZE(lcdc0_modes),
.board_cfg = { .panel_cfg = {
.display_on = lcd_on, .width = 44,
.display_off = lcd_off, .height = 79,
.display_on = lcd_backlight_on,
.display_off = lcd_backlight_reset,
}, },
} }
}; };
......
...@@ -258,8 +258,14 @@ static struct sh_mobile_meram_info meram_info = { ...@@ -258,8 +258,14 @@ static struct sh_mobile_meram_info meram_info = {
static struct resource meram_resources[] = { static struct resource meram_resources[] = {
[0] = { [0] = {
.name = "MERAM", .name = "regs",
.start = 0xe8000000, .start = 0xe8000000,
.end = 0xe807ffff,
.flags = IORESOURCE_MEM,
},
[1] = {
.name = "meram",
.start = 0xe8080000,
.end = 0xe81fffff, .end = 0xe81fffff,
.flags = IORESOURCE_MEM, .flags = IORESOURCE_MEM,
}, },
...@@ -437,82 +443,6 @@ static struct platform_device usb1_host_device = { ...@@ -437,82 +443,6 @@ static struct platform_device usb1_host_device = {
.resource = usb1_host_resources, .resource = usb1_host_resources,
}; };
static const struct fb_videomode ap4evb_lcdc_modes[] = {
{
#ifdef CONFIG_AP4EVB_QHD
.name = "R63302(QHD)",
.xres = 544,
.yres = 961,
.left_margin = 72,
.right_margin = 600,
.hsync_len = 16,
.upper_margin = 8,
.lower_margin = 8,
.vsync_len = 2,
.sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
#else
.name = "WVGA Panel",
.xres = 800,
.yres = 480,
.left_margin = 220,
.right_margin = 110,
.hsync_len = 70,
.upper_margin = 20,
.lower_margin = 5,
.vsync_len = 5,
.sync = 0,
#endif
},
};
static struct sh_mobile_meram_cfg lcd_meram_cfg = {
.icb[0] = {
.marker_icb = 28,
.cache_icb = 24,
.meram_offset = 0x0,
.meram_size = 0x40,
},
.icb[1] = {
.marker_icb = 29,
.cache_icb = 25,
.meram_offset = 0x40,
.meram_size = 0x40,
},
};
static struct sh_mobile_lcdc_info lcdc_info = {
.meram_dev = &meram_info,
.ch[0] = {
.chan = LCDC_CHAN_MAINLCD,
.fourcc = V4L2_PIX_FMT_RGB565,
.lcd_cfg = ap4evb_lcdc_modes,
.num_cfg = ARRAY_SIZE(ap4evb_lcdc_modes),
.meram_cfg = &lcd_meram_cfg,
}
};
static struct resource lcdc_resources[] = {
[0] = {
.name = "LCDC",
.start = 0xfe940000, /* P4-only space */
.end = 0xfe943fff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = intcs_evt2irq(0x580),
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device lcdc_device = {
.name = "sh_mobile_lcdc_fb",
.num_resources = ARRAY_SIZE(lcdc_resources),
.resource = lcdc_resources,
.dev = {
.platform_data = &lcdc_info,
.coherent_dma_mask = ~0,
},
};
/* /*
* QHD display * QHD display
*/ */
...@@ -593,6 +523,8 @@ static struct resource mipidsi0_resources[] = { ...@@ -593,6 +523,8 @@ static struct resource mipidsi0_resources[] = {
}, },
}; };
static struct sh_mobile_lcdc_info lcdc_info;
static struct sh_mipi_dsi_info mipidsi0_info = { static struct sh_mipi_dsi_info mipidsi0_info = {
.data_format = MIPI_RGB888, .data_format = MIPI_RGB888,
.lcd_chan = &lcdc_info.ch[0], .lcd_chan = &lcdc_info.ch[0],
...@@ -619,6 +551,81 @@ static struct platform_device *qhd_devices[] __initdata = { ...@@ -619,6 +551,81 @@ static struct platform_device *qhd_devices[] __initdata = {
}; };
#endif /* CONFIG_AP4EVB_QHD */ #endif /* CONFIG_AP4EVB_QHD */
/* LCDC0 */
static const struct fb_videomode ap4evb_lcdc_modes[] = {
{
#ifdef CONFIG_AP4EVB_QHD
.name = "R63302(QHD)",
.xres = 544,
.yres = 961,
.left_margin = 72,
.right_margin = 600,
.hsync_len = 16,
.upper_margin = 8,
.lower_margin = 8,
.vsync_len = 2,
.sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
#else
.name = "WVGA Panel",
.xres = 800,
.yres = 480,
.left_margin = 220,
.right_margin = 110,
.hsync_len = 70,
.upper_margin = 20,
.lower_margin = 5,
.vsync_len = 5,
.sync = 0,
#endif
},
};
static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
.icb[0] = {
.meram_size = 0x40,
},
.icb[1] = {
.meram_size = 0x40,
},
};
static struct sh_mobile_lcdc_info lcdc_info = {
.meram_dev = &meram_info,
.ch[0] = {
.chan = LCDC_CHAN_MAINLCD,
.fourcc = V4L2_PIX_FMT_RGB565,
.lcd_modes = ap4evb_lcdc_modes,
.num_modes = ARRAY_SIZE(ap4evb_lcdc_modes),
.meram_cfg = &lcd_meram_cfg,
#ifdef CONFIG_AP4EVB_QHD
.tx_dev = &mipidsi0_device,
#endif
}
};
static struct resource lcdc_resources[] = {
[0] = {
.name = "LCDC",
.start = 0xfe940000, /* P4-only space */
.end = 0xfe943fff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = intcs_evt2irq(0x580),
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device lcdc_device = {
.name = "sh_mobile_lcdc_fb",
.num_resources = ARRAY_SIZE(lcdc_resources),
.resource = lcdc_resources,
.dev = {
.platform_data = &lcdc_info,
.coherent_dma_mask = ~0,
},
};
/* FSI */ /* FSI */
#define IRQ_FSI evt2irq(0x1840) #define IRQ_FSI evt2irq(0x1840)
static int __fsi_set_rate(struct clk *clk, long rate, int enable) static int __fsi_set_rate(struct clk *clk, long rate, int enable)
...@@ -798,65 +805,11 @@ static struct platform_device fsi_ak4643_device = { ...@@ -798,65 +805,11 @@ static struct platform_device fsi_ak4643_device = {
}, },
}; };
static struct sh_mobile_meram_cfg hdmi_meram_cfg = { /* LCDC1 */
.icb[0] = {
.marker_icb = 30,
.cache_icb = 26,
.meram_offset = 0x80,
.meram_size = 0x100,
},
.icb[1] = {
.marker_icb = 31,
.cache_icb = 27,
.meram_offset = 0x180,
.meram_size = 0x100,
},
};
static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = {
.clock_source = LCDC_CLK_EXTERNAL,
.meram_dev = &meram_info,
.ch[0] = {
.chan = LCDC_CHAN_MAINLCD,
.fourcc = V4L2_PIX_FMT_RGB565,
.interface_type = RGB24,
.clock_divider = 1,
.flags = LCDC_FLAGS_DWPOL,
.meram_cfg = &hdmi_meram_cfg,
}
};
static struct resource lcdc1_resources[] = {
[0] = {
.name = "LCDC1",
.start = 0xfe944000,
.end = 0xfe947fff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = intcs_evt2irq(0x1780),
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device lcdc1_device = {
.name = "sh_mobile_lcdc_fb",
.num_resources = ARRAY_SIZE(lcdc1_resources),
.resource = lcdc1_resources,
.id = 1,
.dev = {
.platform_data = &sh_mobile_lcdc1_info,
.coherent_dma_mask = ~0,
},
};
static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq, static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq,
unsigned long *parent_freq); unsigned long *parent_freq);
static struct sh_mobile_hdmi_info hdmi_info = { static struct sh_mobile_hdmi_info hdmi_info = {
.lcd_chan = &sh_mobile_lcdc1_info.ch[0],
.lcd_dev = &lcdc1_device.dev,
.flags = HDMI_SND_SRC_SPDIF, .flags = HDMI_SND_SRC_SPDIF,
.clk_optimize_parent = ap4evb_clk_optimize, .clk_optimize_parent = ap4evb_clk_optimize,
}; };
...@@ -885,10 +838,6 @@ static struct platform_device hdmi_device = { ...@@ -885,10 +838,6 @@ static struct platform_device hdmi_device = {
}, },
}; };
static struct platform_device fsi_hdmi_device = {
.name = "sh_fsi2_b_hdmi",
};
static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq, static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq,
unsigned long *parent_freq) unsigned long *parent_freq)
{ {
...@@ -908,6 +857,57 @@ static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq, ...@@ -908,6 +857,57 @@ static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq,
return error; return error;
} }
static const struct sh_mobile_meram_cfg hdmi_meram_cfg = {
.icb[0] = {
.meram_size = 0x100,
},
.icb[1] = {
.meram_size = 0x100,
},
};
static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = {
.clock_source = LCDC_CLK_EXTERNAL,
.meram_dev = &meram_info,
.ch[0] = {
.chan = LCDC_CHAN_MAINLCD,
.fourcc = V4L2_PIX_FMT_RGB565,
.interface_type = RGB24,
.clock_divider = 1,
.flags = LCDC_FLAGS_DWPOL,
.meram_cfg = &hdmi_meram_cfg,
.tx_dev = &hdmi_device,
}
};
static struct resource lcdc1_resources[] = {
[0] = {
.name = "LCDC1",
.start = 0xfe944000,
.end = 0xfe947fff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = intcs_evt2irq(0x1780),
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device lcdc1_device = {
.name = "sh_mobile_lcdc_fb",
.num_resources = ARRAY_SIZE(lcdc1_resources),
.resource = lcdc1_resources,
.id = 1,
.dev = {
.platform_data = &sh_mobile_lcdc1_info,
.coherent_dma_mask = ~0,
},
};
static struct platform_device fsi_hdmi_device = {
.name = "sh_fsi2_b_hdmi",
};
static struct gpio_led ap4evb_leds[] = { static struct gpio_led ap4evb_leds[] = {
{ {
.name = "led4", .name = "led4",
...@@ -1042,9 +1042,9 @@ static struct platform_device *ap4evb_devices[] __initdata = { ...@@ -1042,9 +1042,9 @@ static struct platform_device *ap4evb_devices[] __initdata = {
&fsi_ak4643_device, &fsi_ak4643_device,
&fsi_hdmi_device, &fsi_hdmi_device,
&sh_mmcif_device, &sh_mmcif_device,
&lcdc1_device,
&lcdc_device,
&hdmi_device, &hdmi_device,
&lcdc_device,
&lcdc1_device,
&ceu_device, &ceu_device,
&ap4evb_camera, &ap4evb_camera,
&meram_device, &meram_device,
...@@ -1355,8 +1355,8 @@ static void __init ap4evb_init(void) ...@@ -1355,8 +1355,8 @@ static void __init ap4evb_init(void)
lcdc_info.ch[0].interface_type = RGB24; lcdc_info.ch[0].interface_type = RGB24;
lcdc_info.ch[0].clock_divider = 1; lcdc_info.ch[0].clock_divider = 1;
lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL; lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL;
lcdc_info.ch[0].lcd_size_cfg.width = 44; lcdc_info.ch[0].panel_cfg.width = 44;
lcdc_info.ch[0].lcd_size_cfg.height = 79; lcdc_info.ch[0].panel_cfg.height = 79;
platform_add_devices(qhd_devices, ARRAY_SIZE(qhd_devices)); platform_add_devices(qhd_devices, ARRAY_SIZE(qhd_devices));
...@@ -1397,8 +1397,8 @@ static void __init ap4evb_init(void) ...@@ -1397,8 +1397,8 @@ static void __init ap4evb_init(void)
lcdc_info.ch[0].interface_type = RGB18; lcdc_info.ch[0].interface_type = RGB18;
lcdc_info.ch[0].clock_divider = 3; lcdc_info.ch[0].clock_divider = 3;
lcdc_info.ch[0].flags = 0; lcdc_info.ch[0].flags = 0;
lcdc_info.ch[0].lcd_size_cfg.width = 152; lcdc_info.ch[0].panel_cfg.width = 152;
lcdc_info.ch[0].lcd_size_cfg.height = 91; lcdc_info.ch[0].panel_cfg.height = 91;
/* enable TouchScreen */ /* enable TouchScreen */
irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW); irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
......
...@@ -245,9 +245,9 @@ static struct sh_mobile_lcdc_info lcdc0_info = { ...@@ -245,9 +245,9 @@ static struct sh_mobile_lcdc_info lcdc0_info = {
.interface_type = RGB24, .interface_type = RGB24,
.clock_divider = 5, .clock_divider = 5,
.flags = 0, .flags = 0,
.lcd_cfg = &lcdc0_mode, .lcd_modes = &lcdc0_mode,
.num_cfg = 1, .num_modes = 1,
.lcd_size_cfg = { .panel_cfg = {
.width = 152, .width = 152,
.height = 91, .height = 91,
}, },
......
...@@ -318,8 +318,14 @@ static struct sh_mobile_meram_info mackerel_meram_info = { ...@@ -318,8 +318,14 @@ static struct sh_mobile_meram_info mackerel_meram_info = {
static struct resource meram_resources[] = { static struct resource meram_resources[] = {
[0] = { [0] = {
.name = "MERAM", .name = "regs",
.start = 0xe8000000, .start = 0xe8000000,
.end = 0xe807ffff,
.flags = IORESOURCE_MEM,
},
[1] = {
.name = "meram",
.start = 0xe8080000,
.end = 0xe81fffff, .end = 0xe81fffff,
.flags = IORESOURCE_MEM, .flags = IORESOURCE_MEM,
}, },
...@@ -351,29 +357,23 @@ static struct fb_videomode mackerel_lcdc_modes[] = { ...@@ -351,29 +357,23 @@ static struct fb_videomode mackerel_lcdc_modes[] = {
}, },
}; };
static int mackerel_set_brightness(void *board_data, int brightness) static int mackerel_set_brightness(int brightness)
{ {
gpio_set_value(GPIO_PORT31, brightness); gpio_set_value(GPIO_PORT31, brightness);
return 0; return 0;
} }
static int mackerel_get_brightness(void *board_data) static int mackerel_get_brightness(void)
{ {
return gpio_get_value(GPIO_PORT31); return gpio_get_value(GPIO_PORT31);
} }
static struct sh_mobile_meram_cfg lcd_meram_cfg = { static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
.icb[0] = { .icb[0] = {
.marker_icb = 28,
.cache_icb = 24,
.meram_offset = 0x0,
.meram_size = 0x40, .meram_size = 0x40,
}, },
.icb[1] = { .icb[1] = {
.marker_icb = 29,
.cache_icb = 25,
.meram_offset = 0x40,
.meram_size = 0x40, .meram_size = 0x40,
}, },
}; };
...@@ -384,20 +384,20 @@ static struct sh_mobile_lcdc_info lcdc_info = { ...@@ -384,20 +384,20 @@ static struct sh_mobile_lcdc_info lcdc_info = {
.ch[0] = { .ch[0] = {
.chan = LCDC_CHAN_MAINLCD, .chan = LCDC_CHAN_MAINLCD,
.fourcc = V4L2_PIX_FMT_RGB565, .fourcc = V4L2_PIX_FMT_RGB565,
.lcd_cfg = mackerel_lcdc_modes, .lcd_modes = mackerel_lcdc_modes,
.num_cfg = ARRAY_SIZE(mackerel_lcdc_modes), .num_modes = ARRAY_SIZE(mackerel_lcdc_modes),
.interface_type = RGB24, .interface_type = RGB24,
.clock_divider = 3, .clock_divider = 3,
.flags = 0, .flags = 0,
.lcd_size_cfg.width = 152, .panel_cfg = {
.lcd_size_cfg.height = 91, .width = 152,
.board_cfg = { .height = 91,
.set_brightness = mackerel_set_brightness,
.get_brightness = mackerel_get_brightness,
}, },
.bl_info = { .bl_info = {
.name = "sh_mobile_lcdc_bl", .name = "sh_mobile_lcdc_bl",
.max_brightness = 1, .max_brightness = 1,
.set_brightness = mackerel_set_brightness,
.get_brightness = mackerel_get_brightness,
}, },
.meram_cfg = &lcd_meram_cfg, .meram_cfg = &lcd_meram_cfg,
} }
...@@ -426,21 +426,44 @@ static struct platform_device lcdc_device = { ...@@ -426,21 +426,44 @@ static struct platform_device lcdc_device = {
}, },
}; };
static struct sh_mobile_meram_cfg hdmi_meram_cfg = { /* HDMI */
static struct sh_mobile_hdmi_info hdmi_info = {
.flags = HDMI_SND_SRC_SPDIF,
};
static struct resource hdmi_resources[] = {
[0] = {
.name = "HDMI",
.start = 0xe6be0000,
.end = 0xe6be00ff,
.flags = IORESOURCE_MEM,
},
[1] = {
/* There's also an HDMI interrupt on INTCS @ 0x18e0 */
.start = evt2irq(0x17e0),
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device hdmi_device = {
.name = "sh-mobile-hdmi",
.num_resources = ARRAY_SIZE(hdmi_resources),
.resource = hdmi_resources,
.id = -1,
.dev = {
.platform_data = &hdmi_info,
},
};
static const struct sh_mobile_meram_cfg hdmi_meram_cfg = {
.icb[0] = { .icb[0] = {
.marker_icb = 30,
.cache_icb = 26,
.meram_offset = 0x80,
.meram_size = 0x100, .meram_size = 0x100,
}, },
.icb[1] = { .icb[1] = {
.marker_icb = 31,
.cache_icb = 27,
.meram_offset = 0x180,
.meram_size = 0x100, .meram_size = 0x100,
}, },
}; };
/* HDMI */
static struct sh_mobile_lcdc_info hdmi_lcdc_info = { static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
.meram_dev = &mackerel_meram_info, .meram_dev = &mackerel_meram_info,
.clock_source = LCDC_CLK_EXTERNAL, .clock_source = LCDC_CLK_EXTERNAL,
...@@ -451,6 +474,7 @@ static struct sh_mobile_lcdc_info hdmi_lcdc_info = { ...@@ -451,6 +474,7 @@ static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
.clock_divider = 1, .clock_divider = 1,
.flags = LCDC_FLAGS_DWPOL, .flags = LCDC_FLAGS_DWPOL,
.meram_cfg = &hdmi_meram_cfg, .meram_cfg = &hdmi_meram_cfg,
.tx_dev = &hdmi_device,
} }
}; };
...@@ -478,36 +502,6 @@ static struct platform_device hdmi_lcdc_device = { ...@@ -478,36 +502,6 @@ static struct platform_device hdmi_lcdc_device = {
}, },
}; };
static struct sh_mobile_hdmi_info hdmi_info = {
.lcd_chan = &hdmi_lcdc_info.ch[0],
.lcd_dev = &hdmi_lcdc_device.dev,
.flags = HDMI_SND_SRC_SPDIF,
};
static struct resource hdmi_resources[] = {
[0] = {
.name = "HDMI",
.start = 0xe6be0000,
.end = 0xe6be00ff,
.flags = IORESOURCE_MEM,
},
[1] = {
/* There's also an HDMI interrupt on INTCS @ 0x18e0 */
.start = evt2irq(0x17e0),
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device hdmi_device = {
.name = "sh-mobile-hdmi",
.num_resources = ARRAY_SIZE(hdmi_resources),
.resource = hdmi_resources,
.id = -1,
.dev = {
.platform_data = &hdmi_info,
},
};
static struct platform_device fsi_hdmi_device = { static struct platform_device fsi_hdmi_device = {
.name = "sh_fsi2_b_hdmi", .name = "sh_fsi2_b_hdmi",
}; };
...@@ -1276,8 +1270,8 @@ static struct platform_device *mackerel_devices[] __initdata = { ...@@ -1276,8 +1270,8 @@ static struct platform_device *mackerel_devices[] __initdata = {
&sh_mmcif_device, &sh_mmcif_device,
&ceu_device, &ceu_device,
&mackerel_camera, &mackerel_camera,
&hdmi_lcdc_device,
&hdmi_device, &hdmi_device,
&hdmi_lcdc_device,
&meram_device, &meram_device,
}; };
......
...@@ -157,7 +157,7 @@ static struct platform_device nand_flash_device = { ...@@ -157,7 +157,7 @@ static struct platform_device nand_flash_device = {
#define PORT_DRVCRA 0xA405018A #define PORT_DRVCRA 0xA405018A
#define PORT_DRVCRB 0xA405018C #define PORT_DRVCRB 0xA405018C
static int ap320_wvga_set_brightness(void *board_data, int brightness) static int ap320_wvga_set_brightness(int brightness)
{ {
if (brightness) { if (brightness) {
gpio_set_value(GPIO_PTS3, 0); gpio_set_value(GPIO_PTS3, 0);
...@@ -170,12 +170,12 @@ static int ap320_wvga_set_brightness(void *board_data, int brightness) ...@@ -170,12 +170,12 @@ static int ap320_wvga_set_brightness(void *board_data, int brightness)
return 0; return 0;
} }
static int ap320_wvga_get_brightness(void *board_data) static int ap320_wvga_get_brightness(void)
{ {
return gpio_get_value(GPIO_PTS3); return gpio_get_value(GPIO_PTS3);
} }
static void ap320_wvga_power_on(void *board_data, struct fb_info *info) static void ap320_wvga_power_on(void)
{ {
msleep(100); msleep(100);
...@@ -183,7 +183,7 @@ static void ap320_wvga_power_on(void *board_data, struct fb_info *info) ...@@ -183,7 +183,7 @@ static void ap320_wvga_power_on(void *board_data, struct fb_info *info)
__raw_writew(FPGA_LCDREG_VAL, FPGA_LCDREG); __raw_writew(FPGA_LCDREG_VAL, FPGA_LCDREG);
} }
static void ap320_wvga_power_off(void *board_data) static void ap320_wvga_power_off(void)
{ {
/* ASD AP-320/325 LCD OFF */ /* ASD AP-320/325 LCD OFF */
__raw_writew(0, FPGA_LCDREG); __raw_writew(0, FPGA_LCDREG);
...@@ -211,21 +211,19 @@ static struct sh_mobile_lcdc_info lcdc_info = { ...@@ -211,21 +211,19 @@ static struct sh_mobile_lcdc_info lcdc_info = {
.fourcc = V4L2_PIX_FMT_RGB565, .fourcc = V4L2_PIX_FMT_RGB565,
.interface_type = RGB18, .interface_type = RGB18,
.clock_divider = 1, .clock_divider = 1,
.lcd_cfg = ap325rxa_lcdc_modes, .lcd_modes = ap325rxa_lcdc_modes,
.num_cfg = ARRAY_SIZE(ap325rxa_lcdc_modes), .num_modes = ARRAY_SIZE(ap325rxa_lcdc_modes),
.lcd_size_cfg = { /* 7.0 inch */ .panel_cfg = {
.width = 152, .width = 152, /* 7.0 inch */
.height = 91, .height = 91,
},
.board_cfg = {
.display_on = ap320_wvga_power_on, .display_on = ap320_wvga_power_on,
.display_off = ap320_wvga_power_off, .display_off = ap320_wvga_power_off,
.set_brightness = ap320_wvga_set_brightness,
.get_brightness = ap320_wvga_get_brightness,
}, },
.bl_info = { .bl_info = {
.name = "sh_mobile_lcdc_bl", .name = "sh_mobile_lcdc_bl",
.max_brightness = 1, .max_brightness = 1,
.set_brightness = ap320_wvga_set_brightness,
.get_brightness = ap320_wvga_get_brightness,
}, },
} }
}; };
......
...@@ -310,14 +310,14 @@ static const struct fb_videomode ecovec_dvi_modes[] = { ...@@ -310,14 +310,14 @@ static const struct fb_videomode ecovec_dvi_modes[] = {
}, },
}; };
static int ecovec24_set_brightness(void *board_data, int brightness) static int ecovec24_set_brightness(int brightness)
{ {
gpio_set_value(GPIO_PTR1, brightness); gpio_set_value(GPIO_PTR1, brightness);
return 0; return 0;
} }
static int ecovec24_get_brightness(void *board_data) static int ecovec24_get_brightness(void)
{ {
return gpio_get_value(GPIO_PTR1); return gpio_get_value(GPIO_PTR1);
} }
...@@ -327,17 +327,15 @@ static struct sh_mobile_lcdc_info lcdc_info = { ...@@ -327,17 +327,15 @@ static struct sh_mobile_lcdc_info lcdc_info = {
.interface_type = RGB18, .interface_type = RGB18,
.chan = LCDC_CHAN_MAINLCD, .chan = LCDC_CHAN_MAINLCD,
.fourcc = V4L2_PIX_FMT_RGB565, .fourcc = V4L2_PIX_FMT_RGB565,
.lcd_size_cfg = { /* 7.0 inch */ .panel_cfg = { /* 7.0 inch */
.width = 152, .width = 152,
.height = 91, .height = 91,
}, },
.board_cfg = {
.set_brightness = ecovec24_set_brightness,
.get_brightness = ecovec24_get_brightness,
},
.bl_info = { .bl_info = {
.name = "sh_mobile_lcdc_bl", .name = "sh_mobile_lcdc_bl",
.max_brightness = 1, .max_brightness = 1,
.set_brightness = ecovec24_set_brightness,
.get_brightness = ecovec24_get_brightness,
}, },
} }
}; };
...@@ -1116,8 +1114,8 @@ static int __init arch_setup(void) ...@@ -1116,8 +1114,8 @@ static int __init arch_setup(void)
/* DVI */ /* DVI */
lcdc_info.clock_source = LCDC_CLK_EXTERNAL; lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
lcdc_info.ch[0].clock_divider = 1; lcdc_info.ch[0].clock_divider = 1;
lcdc_info.ch[0].lcd_cfg = ecovec_dvi_modes; lcdc_info.ch[0].lcd_modes = ecovec_dvi_modes;
lcdc_info.ch[0].num_cfg = ARRAY_SIZE(ecovec_dvi_modes); lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_dvi_modes);
gpio_set_value(GPIO_PTA2, 1); gpio_set_value(GPIO_PTA2, 1);
gpio_set_value(GPIO_PTU1, 1); gpio_set_value(GPIO_PTU1, 1);
...@@ -1125,8 +1123,8 @@ static int __init arch_setup(void) ...@@ -1125,8 +1123,8 @@ static int __init arch_setup(void)
/* Panel */ /* Panel */
lcdc_info.clock_source = LCDC_CLK_PERIPHERAL; lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
lcdc_info.ch[0].clock_divider = 2; lcdc_info.ch[0].clock_divider = 2;
lcdc_info.ch[0].lcd_cfg = ecovec_lcd_modes; lcdc_info.ch[0].lcd_modes = ecovec_lcd_modes;
lcdc_info.ch[0].num_cfg = ARRAY_SIZE(ecovec_lcd_modes); lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_lcd_modes);
gpio_set_value(GPIO_PTR1, 1); gpio_set_value(GPIO_PTR1, 1);
......
...@@ -251,8 +251,7 @@ static void display_on(void *sohandle, ...@@ -251,8 +251,7 @@ static void display_on(void *sohandle,
write_memory_start(sohandle, so); write_memory_start(sohandle, so);
} }
int kfr2r09_lcd_setup(void *board_data, void *sohandle, int kfr2r09_lcd_setup(void *sohandle, struct sh_mobile_lcdc_sys_bus_ops *so)
struct sh_mobile_lcdc_sys_bus_ops *so)
{ {
/* power on */ /* power on */
gpio_set_value(GPIO_PTF4, 0); /* PROTECT/ -> L */ gpio_set_value(GPIO_PTF4, 0); /* PROTECT/ -> L */
...@@ -273,8 +272,7 @@ int kfr2r09_lcd_setup(void *board_data, void *sohandle, ...@@ -273,8 +272,7 @@ int kfr2r09_lcd_setup(void *board_data, void *sohandle,
return 0; return 0;
} }
void kfr2r09_lcd_start(void *board_data, void *sohandle, void kfr2r09_lcd_start(void *sohandle, struct sh_mobile_lcdc_sys_bus_ops *so)
struct sh_mobile_lcdc_sys_bus_ops *so)
{ {
write_memory_start(sohandle, so); write_memory_start(sohandle, so);
} }
...@@ -327,12 +325,12 @@ static int kfr2r09_lcd_backlight(int on) ...@@ -327,12 +325,12 @@ static int kfr2r09_lcd_backlight(int on)
return 0; return 0;
} }
void kfr2r09_lcd_on(void *board_data, struct fb_info *info) void kfr2r09_lcd_on(void)
{ {
kfr2r09_lcd_backlight(1); kfr2r09_lcd_backlight(1);
} }
void kfr2r09_lcd_off(void *board_data) void kfr2r09_lcd_off(void)
{ {
kfr2r09_lcd_backlight(0); kfr2r09_lcd_backlight(0);
} }
...@@ -148,13 +148,11 @@ static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = { ...@@ -148,13 +148,11 @@ static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
.interface_type = SYS18, .interface_type = SYS18,
.clock_divider = 6, .clock_divider = 6,
.flags = LCDC_FLAGS_DWPOL, .flags = LCDC_FLAGS_DWPOL,
.lcd_cfg = kfr2r09_lcdc_modes, .lcd_modes = kfr2r09_lcdc_modes,
.num_cfg = ARRAY_SIZE(kfr2r09_lcdc_modes), .num_modes = ARRAY_SIZE(kfr2r09_lcdc_modes),
.lcd_size_cfg = { .panel_cfg = {
.width = 35, .width = 35,
.height = 58, .height = 58,
},
.board_cfg = {
.setup_sys = kfr2r09_lcd_setup, .setup_sys = kfr2r09_lcd_setup,
.start_transfer = kfr2r09_lcd_start, .start_transfer = kfr2r09_lcd_start,
.display_on = kfr2r09_lcd_on, .display_on = kfr2r09_lcd_on,
......
...@@ -113,8 +113,7 @@ static const unsigned short magic3_data[] = { ...@@ -113,8 +113,7 @@ static const unsigned short magic3_data[] = {
0x0010, 0x16B0, 0x0011, 0x0111, 0x0007, 0x0061, 0x0010, 0x16B0, 0x0011, 0x0111, 0x0007, 0x0061,
}; };
int migor_lcd_qvga_setup(void *board_data, void *sohandle, int migor_lcd_qvga_setup(void *sohandle, struct sh_mobile_lcdc_sys_bus_ops *so)
struct sh_mobile_lcdc_sys_bus_ops *so)
{ {
unsigned long xres = 320; unsigned long xres = 320;
unsigned long yres = 240; unsigned long yres = 240;
......
...@@ -246,9 +246,9 @@ static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = { ...@@ -246,9 +246,9 @@ static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = {
.fourcc = V4L2_PIX_FMT_RGB565, .fourcc = V4L2_PIX_FMT_RGB565,
.interface_type = RGB16, .interface_type = RGB16,
.clock_divider = 2, .clock_divider = 2,
.lcd_cfg = migor_lcd_modes, .lcd_modes = migor_lcd_modes,
.num_cfg = ARRAY_SIZE(migor_lcd_modes), .num_modes = ARRAY_SIZE(migor_lcd_modes),
.lcd_size_cfg = { /* 7.0 inch */ .panel_cfg = { /* 7.0 inch */
.width = 152, .width = 152,
.height = 91, .height = 91,
}, },
...@@ -260,13 +260,11 @@ static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = { ...@@ -260,13 +260,11 @@ static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = {
.fourcc = V4L2_PIX_FMT_RGB565, .fourcc = V4L2_PIX_FMT_RGB565,
.interface_type = SYS16A, .interface_type = SYS16A,
.clock_divider = 10, .clock_divider = 10,
.lcd_cfg = migor_lcd_modes, .lcd_modes = migor_lcd_modes,
.num_cfg = ARRAY_SIZE(migor_lcd_modes), .num_modes = ARRAY_SIZE(migor_lcd_modes),
.lcd_size_cfg = { /* 2.4 inch */ .panel_cfg = {
.width = 49, .width = 49, /* 2.4 inch */
.height = 37, .height = 37,
},
.board_cfg = {
.setup_sys = migor_lcd_qvga_setup, .setup_sys = migor_lcd_qvga_setup,
}, },
.sys_bus_cfg = { .sys_bus_cfg = {
......
...@@ -182,12 +182,10 @@ static struct sh_mobile_lcdc_info lcdc_info = { ...@@ -182,12 +182,10 @@ static struct sh_mobile_lcdc_info lcdc_info = {
.chan = LCDC_CHAN_MAINLCD, .chan = LCDC_CHAN_MAINLCD,
.fourcc = V4L2_PIX_FMT_RGB565, .fourcc = V4L2_PIX_FMT_RGB565,
.clock_divider = 1, .clock_divider = 1,
.lcd_size_cfg = { /* 7.0 inch */ .panel_cfg = { /* 7.0 inch */
.width = 152, .width = 152,
.height = 91, .height = 91,
}, },
.board_cfg = {
},
} }
}; };
...@@ -888,12 +886,12 @@ static int __init devices_setup(void) ...@@ -888,12 +886,12 @@ static int __init devices_setup(void)
if (sw & SW41_B) { if (sw & SW41_B) {
/* 720p */ /* 720p */
lcdc_info.ch[0].lcd_cfg = lcdc_720p_modes; lcdc_info.ch[0].lcd_modes = lcdc_720p_modes;
lcdc_info.ch[0].num_cfg = ARRAY_SIZE(lcdc_720p_modes); lcdc_info.ch[0].num_modes = ARRAY_SIZE(lcdc_720p_modes);
} else { } else {
/* VGA */ /* VGA */
lcdc_info.ch[0].lcd_cfg = lcdc_vga_modes; lcdc_info.ch[0].lcd_modes = lcdc_vga_modes;
lcdc_info.ch[0].num_cfg = ARRAY_SIZE(lcdc_vga_modes); lcdc_info.ch[0].num_modes = ARRAY_SIZE(lcdc_vga_modes);
} }
if (sw & SW41_A) { if (sw & SW41_A) {
......
...@@ -4,21 +4,21 @@ ...@@ -4,21 +4,21 @@
#include <video/sh_mobile_lcdc.h> #include <video/sh_mobile_lcdc.h>
#if defined(CONFIG_FB_SH_MOBILE_LCDC) || defined(CONFIG_FB_SH_MOBILE_LCDC_MODULE) #if defined(CONFIG_FB_SH_MOBILE_LCDC) || defined(CONFIG_FB_SH_MOBILE_LCDC_MODULE)
void kfr2r09_lcd_on(void *board_data, struct fb_info *info); void kfr2r09_lcd_on(void);
void kfr2r09_lcd_off(void *board_data); void kfr2r09_lcd_off(void);
int kfr2r09_lcd_setup(void *board_data, void *sys_ops_handle, int kfr2r09_lcd_setup(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops); struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
void kfr2r09_lcd_start(void *board_data, void *sys_ops_handle, void kfr2r09_lcd_start(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops); struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
#else #else
static void kfr2r09_lcd_on(void *board_data) {} static void kfr2r09_lcd_on(void) {}
static void kfr2r09_lcd_off(void *board_data) {} static void kfr2r09_lcd_off(void) {}
static int kfr2r09_lcd_setup(void *board_data, void *sys_ops_handle, static int kfr2r09_lcd_setup(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops) struct sh_mobile_lcdc_sys_bus_ops *sys_ops)
{ {
return -ENODEV; return -ENODEV;
} }
static void kfr2r09_lcd_start(void *board_data, void *sys_ops_handle, static void kfr2r09_lcd_start(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops) struct sh_mobile_lcdc_sys_bus_ops *sys_ops)
{ {
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <video/sh_mobile_lcdc.h> #include <video/sh_mobile_lcdc.h>
int migor_lcd_qvga_setup(void *board_data, void *sys_ops_handle, int migor_lcd_qvga_setup(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops); struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
#endif /* __ASM_SH_MIGOR_H */ #endif /* __ASM_SH_MIGOR_H */
...@@ -2016,6 +2016,7 @@ config FB_SH_MOBILE_HDMI ...@@ -2016,6 +2016,7 @@ config FB_SH_MOBILE_HDMI
config FB_SH_MOBILE_MERAM config FB_SH_MOBILE_MERAM
tristate "SuperH Mobile MERAM read ahead support for LCDC" tristate "SuperH Mobile MERAM read ahead support for LCDC"
depends on FB_SH_MOBILE_LCDC depends on FB_SH_MOBILE_LCDC
select GENERIC_ALLOCATOR
default y default y
---help--- ---help---
Enable MERAM support for the SH-Mobile LCD controller. Enable MERAM support for the SH-Mobile LCD controller.
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <video/sh_mipi_dsi.h> #include <video/sh_mipi_dsi.h>
#include <video/sh_mobile_lcdc.h> #include <video/sh_mobile_lcdc.h>
#include "sh_mobile_lcdcfb.h"
#define SYSCTRL 0x0000 #define SYSCTRL 0x0000
#define SYSCONF 0x0004 #define SYSCONF 0x0004
#define TIMSET 0x0008 #define TIMSET 0x0008
...@@ -50,16 +52,16 @@ ...@@ -50,16 +52,16 @@
#define MAX_SH_MIPI_DSI 2 #define MAX_SH_MIPI_DSI 2
struct sh_mipi { struct sh_mipi {
struct sh_mobile_lcdc_entity entity;
void __iomem *base; void __iomem *base;
void __iomem *linkbase; void __iomem *linkbase;
struct clk *dsit_clk; struct clk *dsit_clk;
struct platform_device *pdev; struct platform_device *pdev;
void *next_board_data;
void (*next_display_on)(void *board_data, struct fb_info *info);
void (*next_display_off)(void *board_data);
}; };
#define to_sh_mipi(e) container_of(e, struct sh_mipi, entity)
static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI]; static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI];
/* Protect the above array */ /* Protect the above array */
...@@ -120,7 +122,7 @@ static void sh_mipi_dsi_enable(struct sh_mipi *mipi, bool enable) ...@@ -120,7 +122,7 @@ static void sh_mipi_dsi_enable(struct sh_mipi *mipi, bool enable)
static void sh_mipi_shutdown(struct platform_device *pdev) static void sh_mipi_shutdown(struct platform_device *pdev)
{ {
struct sh_mipi *mipi = platform_get_drvdata(pdev); struct sh_mipi *mipi = to_sh_mipi(platform_get_drvdata(pdev));
sh_mipi_dsi_enable(mipi, false); sh_mipi_dsi_enable(mipi, false);
} }
...@@ -145,77 +147,77 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi, ...@@ -145,77 +147,77 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
pctype = 0; pctype = 0;
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_24; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_24;
pixfmt = MIPI_DCS_PIXEL_FMT_24BIT; pixfmt = MIPI_DCS_PIXEL_FMT_24BIT;
linelength = ch->lcd_cfg[0].xres * 3; linelength = ch->lcd_modes[0].xres * 3;
yuv = false; yuv = false;
break; break;
case MIPI_RGB565: case MIPI_RGB565:
pctype = 1; pctype = 1;
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_16; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_16;
pixfmt = MIPI_DCS_PIXEL_FMT_16BIT; pixfmt = MIPI_DCS_PIXEL_FMT_16BIT;
linelength = ch->lcd_cfg[0].xres * 2; linelength = ch->lcd_modes[0].xres * 2;
yuv = false; yuv = false;
break; break;
case MIPI_RGB666_LP: case MIPI_RGB666_LP:
pctype = 2; pctype = 2;
datatype = MIPI_DSI_PIXEL_STREAM_3BYTE_18; datatype = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
pixfmt = MIPI_DCS_PIXEL_FMT_24BIT; pixfmt = MIPI_DCS_PIXEL_FMT_24BIT;
linelength = ch->lcd_cfg[0].xres * 3; linelength = ch->lcd_modes[0].xres * 3;
yuv = false; yuv = false;
break; break;
case MIPI_RGB666: case MIPI_RGB666:
pctype = 3; pctype = 3;
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_18; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_18;
pixfmt = MIPI_DCS_PIXEL_FMT_18BIT; pixfmt = MIPI_DCS_PIXEL_FMT_18BIT;
linelength = (ch->lcd_cfg[0].xres * 18 + 7) / 8; linelength = (ch->lcd_modes[0].xres * 18 + 7) / 8;
yuv = false; yuv = false;
break; break;
case MIPI_BGR888: case MIPI_BGR888:
pctype = 8; pctype = 8;
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_24; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_24;
pixfmt = MIPI_DCS_PIXEL_FMT_24BIT; pixfmt = MIPI_DCS_PIXEL_FMT_24BIT;
linelength = ch->lcd_cfg[0].xres * 3; linelength = ch->lcd_modes[0].xres * 3;
yuv = false; yuv = false;
break; break;
case MIPI_BGR565: case MIPI_BGR565:
pctype = 9; pctype = 9;
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_16; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_16;
pixfmt = MIPI_DCS_PIXEL_FMT_16BIT; pixfmt = MIPI_DCS_PIXEL_FMT_16BIT;
linelength = ch->lcd_cfg[0].xres * 2; linelength = ch->lcd_modes[0].xres * 2;
yuv = false; yuv = false;
break; break;
case MIPI_BGR666_LP: case MIPI_BGR666_LP:
pctype = 0xa; pctype = 0xa;
datatype = MIPI_DSI_PIXEL_STREAM_3BYTE_18; datatype = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
pixfmt = MIPI_DCS_PIXEL_FMT_24BIT; pixfmt = MIPI_DCS_PIXEL_FMT_24BIT;
linelength = ch->lcd_cfg[0].xres * 3; linelength = ch->lcd_modes[0].xres * 3;
yuv = false; yuv = false;
break; break;
case MIPI_BGR666: case MIPI_BGR666:
pctype = 0xb; pctype = 0xb;
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_18; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_18;
pixfmt = MIPI_DCS_PIXEL_FMT_18BIT; pixfmt = MIPI_DCS_PIXEL_FMT_18BIT;
linelength = (ch->lcd_cfg[0].xres * 18 + 7) / 8; linelength = (ch->lcd_modes[0].xres * 18 + 7) / 8;
yuv = false; yuv = false;
break; break;
case MIPI_YUYV: case MIPI_YUYV:
pctype = 4; pctype = 4;
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16;
pixfmt = MIPI_DCS_PIXEL_FMT_16BIT; pixfmt = MIPI_DCS_PIXEL_FMT_16BIT;
linelength = ch->lcd_cfg[0].xres * 2; linelength = ch->lcd_modes[0].xres * 2;
yuv = true; yuv = true;
break; break;
case MIPI_UYVY: case MIPI_UYVY:
pctype = 5; pctype = 5;
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16;
pixfmt = MIPI_DCS_PIXEL_FMT_16BIT; pixfmt = MIPI_DCS_PIXEL_FMT_16BIT;
linelength = ch->lcd_cfg[0].xres * 2; linelength = ch->lcd_modes[0].xres * 2;
yuv = true; yuv = true;
break; break;
case MIPI_YUV420_L: case MIPI_YUV420_L:
pctype = 6; pctype = 6;
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12;
pixfmt = MIPI_DCS_PIXEL_FMT_12BIT; pixfmt = MIPI_DCS_PIXEL_FMT_12BIT;
linelength = (ch->lcd_cfg[0].xres * 12 + 7) / 8; linelength = (ch->lcd_modes[0].xres * 12 + 7) / 8;
yuv = true; yuv = true;
break; break;
case MIPI_YUV420: case MIPI_YUV420:
...@@ -223,7 +225,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi, ...@@ -223,7 +225,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12; datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12;
pixfmt = MIPI_DCS_PIXEL_FMT_12BIT; pixfmt = MIPI_DCS_PIXEL_FMT_12BIT;
/* Length of U/V line */ /* Length of U/V line */
linelength = (ch->lcd_cfg[0].xres + 1) / 2; linelength = (ch->lcd_modes[0].xres + 1) / 2;
yuv = true; yuv = true;
break; break;
default: default:
...@@ -292,7 +294,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi, ...@@ -292,7 +294,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
*/ */
iowrite32(0x00000006, mipi->linkbase + DTCTR); iowrite32(0x00000006, mipi->linkbase + DTCTR);
/* VSYNC width = 2 (<< 17) */ /* VSYNC width = 2 (<< 17) */
iowrite32((ch->lcd_cfg[0].vsync_len << pdata->vsynw_offset) | iowrite32((ch->lcd_modes[0].vsync_len << pdata->vsynw_offset) |
(pdata->clksrc << 16) | (pctype << 12) | datatype, (pdata->clksrc << 16) | (pctype << 12) | datatype,
mipi->linkbase + VMCTR1); mipi->linkbase + VMCTR1);
...@@ -326,7 +328,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi, ...@@ -326,7 +328,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
top = linelength << 16; /* RGBLEN */ top = linelength << 16; /* RGBLEN */
bottom = 0x00000001; bottom = 0x00000001;
if (pdata->flags & SH_MIPI_DSI_HSABM) /* HSALEN */ if (pdata->flags & SH_MIPI_DSI_HSABM) /* HSALEN */
bottom = (pdata->lane * ch->lcd_cfg[0].hsync_len) - 10; bottom = (pdata->lane * ch->lcd_modes[0].hsync_len) - 10;
iowrite32(top | bottom , mipi->linkbase + VMLEN1); iowrite32(top | bottom , mipi->linkbase + VMLEN1);
/* /*
...@@ -346,18 +348,18 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi, ...@@ -346,18 +348,18 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
div = 2; div = 2;
if (pdata->flags & SH_MIPI_DSI_HFPBM) { /* HBPLEN */ if (pdata->flags & SH_MIPI_DSI_HFPBM) { /* HBPLEN */
top = ch->lcd_cfg[0].hsync_len + ch->lcd_cfg[0].left_margin; top = ch->lcd_modes[0].hsync_len + ch->lcd_modes[0].left_margin;
top = ((pdata->lane * top / div) - 10) << 16; top = ((pdata->lane * top / div) - 10) << 16;
} }
if (pdata->flags & SH_MIPI_DSI_HBPBM) { /* HFPLEN */ if (pdata->flags & SH_MIPI_DSI_HBPBM) { /* HFPLEN */
bottom = ch->lcd_cfg[0].right_margin; bottom = ch->lcd_modes[0].right_margin;
bottom = (pdata->lane * bottom / div) - 12; bottom = (pdata->lane * bottom / div) - 12;
} }
bpp = linelength / ch->lcd_cfg[0].xres; /* byte / pixel */ bpp = linelength / ch->lcd_modes[0].xres; /* byte / pixel */
if ((pdata->lane / div) > bpp) { if ((pdata->lane / div) > bpp) {
tmp = ch->lcd_cfg[0].xres / bpp; /* output cycle */ tmp = ch->lcd_modes[0].xres / bpp; /* output cycle */
tmp = ch->lcd_cfg[0].xres - tmp; /* (input - output) cycle */ tmp = ch->lcd_modes[0].xres - tmp; /* (input - output) cycle */
delay = (pdata->lane * tmp); delay = (pdata->lane * tmp);
} }
...@@ -392,9 +394,9 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi, ...@@ -392,9 +394,9 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
return 0; return 0;
} }
static void mipi_display_on(void *arg, struct fb_info *info) static int mipi_display_on(struct sh_mobile_lcdc_entity *entity)
{ {
struct sh_mipi *mipi = arg; struct sh_mipi *mipi = to_sh_mipi(entity);
struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data; struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data;
int ret; int ret;
...@@ -410,25 +412,21 @@ static void mipi_display_on(void *arg, struct fb_info *info) ...@@ -410,25 +412,21 @@ static void mipi_display_on(void *arg, struct fb_info *info)
sh_mipi_dsi_enable(mipi, true); sh_mipi_dsi_enable(mipi, true);
if (mipi->next_display_on) return SH_MOBILE_LCDC_DISPLAY_CONNECTED;
mipi->next_display_on(mipi->next_board_data, info);
return;
mipi_display_on_fail1: mipi_display_on_fail1:
pm_runtime_put_sync(&mipi->pdev->dev); pm_runtime_put_sync(&mipi->pdev->dev);
mipi_display_on_fail2: mipi_display_on_fail2:
pdata->set_dot_clock(mipi->pdev, mipi->base, 0); pdata->set_dot_clock(mipi->pdev, mipi->base, 0);
return ret;
} }
static void mipi_display_off(void *arg) static void mipi_display_off(struct sh_mobile_lcdc_entity *entity)
{ {
struct sh_mipi *mipi = arg; struct sh_mipi *mipi = to_sh_mipi(entity);
struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data; struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data;
if (mipi->next_display_off)
mipi->next_display_off(mipi->next_board_data);
sh_mipi_dsi_enable(mipi, false); sh_mipi_dsi_enable(mipi, false);
pdata->set_dot_clock(mipi->pdev, mipi->base, 0); pdata->set_dot_clock(mipi->pdev, mipi->base, 0);
...@@ -436,6 +434,11 @@ static void mipi_display_off(void *arg) ...@@ -436,6 +434,11 @@ static void mipi_display_off(void *arg)
pm_runtime_put_sync(&mipi->pdev->dev); pm_runtime_put_sync(&mipi->pdev->dev);
} }
static const struct sh_mobile_lcdc_entity_ops mipi_ops = {
.display_on = mipi_display_on,
.display_off = mipi_display_off,
};
static int __init sh_mipi_probe(struct platform_device *pdev) static int __init sh_mipi_probe(struct platform_device *pdev)
{ {
struct sh_mipi *mipi; struct sh_mipi *mipi;
...@@ -467,6 +470,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev) ...@@ -467,6 +470,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
goto ealloc; goto ealloc;
} }
mipi->entity.owner = THIS_MODULE;
mipi->entity.ops = &mipi_ops;
if (!request_mem_region(res->start, resource_size(res), pdev->name)) { if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
dev_err(&pdev->dev, "MIPI register region already claimed\n"); dev_err(&pdev->dev, "MIPI register region already claimed\n");
ret = -EBUSY; ret = -EBUSY;
...@@ -521,18 +527,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev) ...@@ -521,18 +527,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
pm_runtime_resume(&pdev->dev); pm_runtime_resume(&pdev->dev);
mutex_unlock(&array_lock); mutex_unlock(&array_lock);
platform_set_drvdata(pdev, mipi); platform_set_drvdata(pdev, &mipi->entity);
/* Save original LCDC callbacks */
mipi->next_board_data = pdata->lcd_chan->board_cfg.board_data;
mipi->next_display_on = pdata->lcd_chan->board_cfg.display_on;
mipi->next_display_off = pdata->lcd_chan->board_cfg.display_off;
/* Set up LCDC callbacks */
pdata->lcd_chan->board_cfg.board_data = mipi;
pdata->lcd_chan->board_cfg.display_on = mipi_display_on;
pdata->lcd_chan->board_cfg.display_off = mipi_display_off;
pdata->lcd_chan->board_cfg.owner = THIS_MODULE;
return 0; return 0;
...@@ -558,10 +553,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev) ...@@ -558,10 +553,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
static int __exit sh_mipi_remove(struct platform_device *pdev) static int __exit sh_mipi_remove(struct platform_device *pdev)
{ {
struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data;
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
struct sh_mipi *mipi = platform_get_drvdata(pdev); struct sh_mipi *mipi = to_sh_mipi(platform_get_drvdata(pdev));
int i, ret; int i, ret;
mutex_lock(&array_lock); mutex_lock(&array_lock);
...@@ -581,11 +575,6 @@ static int __exit sh_mipi_remove(struct platform_device *pdev) ...@@ -581,11 +575,6 @@ static int __exit sh_mipi_remove(struct platform_device *pdev)
if (ret < 0) if (ret < 0)
return ret; return ret;
pdata->lcd_chan->board_cfg.owner = NULL;
pdata->lcd_chan->board_cfg.display_on = NULL;
pdata->lcd_chan->board_cfg.display_off = NULL;
pdata->lcd_chan->board_cfg.board_data = NULL;
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
clk_disable(mipi->dsit_clk); clk_disable(mipi->dsit_clk);
clk_put(mipi->dsit_clk); clk_put(mipi->dsit_clk);
......
...@@ -208,6 +208,8 @@ enum hotplug_state { ...@@ -208,6 +208,8 @@ enum hotplug_state {
}; };
struct sh_hdmi { struct sh_hdmi {
struct sh_mobile_lcdc_entity entity;
void __iomem *base; void __iomem *base;
enum hotplug_state hp_state; /* hot-plug status */ enum hotplug_state hp_state; /* hot-plug status */
u8 preprogrammed_vic; /* use a pre-programmed VIC or u8 preprogrammed_vic; /* use a pre-programmed VIC or
...@@ -217,14 +219,13 @@ struct sh_hdmi { ...@@ -217,14 +219,13 @@ struct sh_hdmi {
u8 edid_blocks; u8 edid_blocks;
struct clk *hdmi_clk; struct clk *hdmi_clk;
struct device *dev; struct device *dev;
struct fb_info *info;
struct mutex mutex; /* Protect the info pointer */
struct delayed_work edid_work; struct delayed_work edid_work;
struct fb_var_screeninfo var; struct fb_videomode mode;
struct fb_monspecs monspec; struct fb_monspecs monspec;
struct notifier_block notifier;
}; };
#define entity_to_sh_hdmi(e) container_of(e, struct sh_hdmi, entity)
static void hdmi_write(struct sh_hdmi *hdmi, u8 data, u8 reg) static void hdmi_write(struct sh_hdmi *hdmi, u8 data, u8 reg)
{ {
iowrite8(data, hdmi->base + reg); iowrite8(data, hdmi->base + reg);
...@@ -290,24 +291,24 @@ static struct snd_soc_codec_driver soc_codec_dev_sh_hdmi = { ...@@ -290,24 +291,24 @@ static struct snd_soc_codec_driver soc_codec_dev_sh_hdmi = {
/* External video parameter settings */ /* External video parameter settings */
static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi) static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi)
{ {
struct fb_var_screeninfo *var = &hdmi->var; struct fb_videomode *mode = &hdmi->mode;
u16 htotal, hblank, hdelay, vtotal, vblank, vdelay, voffset; u16 htotal, hblank, hdelay, vtotal, vblank, vdelay, voffset;
u8 sync = 0; u8 sync = 0;
htotal = var->xres + var->right_margin + var->left_margin + var->hsync_len; htotal = mode->xres + mode->right_margin + mode->left_margin
+ mode->hsync_len;
hdelay = var->hsync_len + var->left_margin; hdelay = mode->hsync_len + mode->left_margin;
hblank = var->right_margin + hdelay; hblank = mode->right_margin + hdelay;
/* /*
* Vertical timing looks a bit different in Figure 18, * Vertical timing looks a bit different in Figure 18,
* but let's try the same first by setting offset = 0 * but let's try the same first by setting offset = 0
*/ */
vtotal = var->yres + var->upper_margin + var->lower_margin + var->vsync_len; vtotal = mode->yres + mode->upper_margin + mode->lower_margin
+ mode->vsync_len;
vdelay = var->vsync_len + var->upper_margin; vdelay = mode->vsync_len + mode->upper_margin;
vblank = var->lower_margin + vdelay; vblank = mode->lower_margin + vdelay;
voffset = min(var->upper_margin / 2, 6U); voffset = min(mode->upper_margin / 2, 6U);
/* /*
* [3]: VSYNC polarity: Positive * [3]: VSYNC polarity: Positive
...@@ -315,14 +316,14 @@ static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi) ...@@ -315,14 +316,14 @@ static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi)
* [1]: Interlace/Progressive: Progressive * [1]: Interlace/Progressive: Progressive
* [0]: External video settings enable: used. * [0]: External video settings enable: used.
*/ */
if (var->sync & FB_SYNC_HOR_HIGH_ACT) if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
sync |= 4; sync |= 4;
if (var->sync & FB_SYNC_VERT_HIGH_ACT) if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
sync |= 8; sync |= 8;
dev_dbg(hdmi->dev, "H: %u, %u, %u, %u; V: %u, %u, %u, %u; sync 0x%x\n", dev_dbg(hdmi->dev, "H: %u, %u, %u, %u; V: %u, %u, %u, %u; sync 0x%x\n",
htotal, hblank, hdelay, var->hsync_len, htotal, hblank, hdelay, mode->hsync_len,
vtotal, vblank, vdelay, var->vsync_len, sync); vtotal, vblank, vdelay, mode->vsync_len, sync);
hdmi_write(hdmi, sync | (voffset << 4), HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS); hdmi_write(hdmi, sync | (voffset << 4), HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS);
...@@ -335,8 +336,8 @@ static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi) ...@@ -335,8 +336,8 @@ static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi)
hdmi_write(hdmi, hdelay, HDMI_EXTERNAL_H_DELAY_7_0); hdmi_write(hdmi, hdelay, HDMI_EXTERNAL_H_DELAY_7_0);
hdmi_write(hdmi, hdelay >> 8, HDMI_EXTERNAL_H_DELAY_9_8); hdmi_write(hdmi, hdelay >> 8, HDMI_EXTERNAL_H_DELAY_9_8);
hdmi_write(hdmi, var->hsync_len, HDMI_EXTERNAL_H_DURATION_7_0); hdmi_write(hdmi, mode->hsync_len, HDMI_EXTERNAL_H_DURATION_7_0);
hdmi_write(hdmi, var->hsync_len >> 8, HDMI_EXTERNAL_H_DURATION_9_8); hdmi_write(hdmi, mode->hsync_len >> 8, HDMI_EXTERNAL_H_DURATION_9_8);
hdmi_write(hdmi, vtotal, HDMI_EXTERNAL_V_TOTAL_7_0); hdmi_write(hdmi, vtotal, HDMI_EXTERNAL_V_TOTAL_7_0);
hdmi_write(hdmi, vtotal >> 8, HDMI_EXTERNAL_V_TOTAL_9_8); hdmi_write(hdmi, vtotal >> 8, HDMI_EXTERNAL_V_TOTAL_9_8);
...@@ -345,7 +346,7 @@ static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi) ...@@ -345,7 +346,7 @@ static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi)
hdmi_write(hdmi, vdelay, HDMI_EXTERNAL_V_DELAY); hdmi_write(hdmi, vdelay, HDMI_EXTERNAL_V_DELAY);
hdmi_write(hdmi, var->vsync_len, HDMI_EXTERNAL_V_DURATION); hdmi_write(hdmi, mode->vsync_len, HDMI_EXTERNAL_V_DURATION);
/* Set bit 0 of HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS here for external mode */ /* Set bit 0 of HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS here for external mode */
if (!hdmi->preprogrammed_vic) if (!hdmi->preprogrammed_vic)
...@@ -472,7 +473,7 @@ static void sh_hdmi_audio_config(struct sh_hdmi *hdmi) ...@@ -472,7 +473,7 @@ static void sh_hdmi_audio_config(struct sh_hdmi *hdmi)
*/ */
static void sh_hdmi_phy_config(struct sh_hdmi *hdmi) static void sh_hdmi_phy_config(struct sh_hdmi *hdmi)
{ {
if (hdmi->var.pixclock < 10000) { if (hdmi->mode.pixclock < 10000) {
/* for 1080p8bit 148MHz */ /* for 1080p8bit 148MHz */
hdmi_write(hdmi, 0x1d, HDMI_SLIPHDMIT_PARAM_SETTINGS_1); hdmi_write(hdmi, 0x1d, HDMI_SLIPHDMIT_PARAM_SETTINGS_1);
hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_2); hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_2);
...@@ -483,7 +484,7 @@ static void sh_hdmi_phy_config(struct sh_hdmi *hdmi) ...@@ -483,7 +484,7 @@ static void sh_hdmi_phy_config(struct sh_hdmi *hdmi)
hdmi_write(hdmi, 0x0e, HDMI_SLIPHDMIT_PARAM_SETTINGS_8); hdmi_write(hdmi, 0x0e, HDMI_SLIPHDMIT_PARAM_SETTINGS_8);
hdmi_write(hdmi, 0x25, HDMI_SLIPHDMIT_PARAM_SETTINGS_9); hdmi_write(hdmi, 0x25, HDMI_SLIPHDMIT_PARAM_SETTINGS_9);
hdmi_write(hdmi, 0x04, HDMI_SLIPHDMIT_PARAM_SETTINGS_10); hdmi_write(hdmi, 0x04, HDMI_SLIPHDMIT_PARAM_SETTINGS_10);
} else if (hdmi->var.pixclock < 30000) { } else if (hdmi->mode.pixclock < 30000) {
/* 720p, 8bit, 74.25MHz. Might need to be adjusted for other formats */ /* 720p, 8bit, 74.25MHz. Might need to be adjusted for other formats */
/* /*
* [1:0] Speed_A * [1:0] Speed_A
...@@ -732,14 +733,12 @@ static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi, ...@@ -732,14 +733,12 @@ static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi,
static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate, static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate,
unsigned long *parent_rate) unsigned long *parent_rate)
{ {
struct fb_var_screeninfo tmpvar; struct sh_mobile_lcdc_chan *ch = hdmi->entity.lcdc;
struct fb_var_screeninfo *var = &tmpvar;
const struct fb_videomode *mode, *found = NULL; const struct fb_videomode *mode, *found = NULL;
struct fb_info *info = hdmi->info;
struct fb_modelist *modelist = NULL;
unsigned int f_width = 0, f_height = 0, f_refresh = 0; unsigned int f_width = 0, f_height = 0, f_refresh = 0;
unsigned long found_rate_error = ULONG_MAX; /* silly compiler... */ unsigned long found_rate_error = ULONG_MAX; /* silly compiler... */
bool scanning = false, preferred_bad = false; bool scanning = false, preferred_bad = false;
bool use_edid_mode = false;
u8 edid[128]; u8 edid[128];
char *forced; char *forced;
int i; int i;
...@@ -854,12 +853,9 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate, ...@@ -854,12 +853,9 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate,
} }
/* Check if supported: sufficient fb memory, supported clock-rate */ /* Check if supported: sufficient fb memory, supported clock-rate */
fb_videomode_to_var(var, mode); if (ch && ch->notify &&
ch->notify(ch, SH_MOBILE_LCDC_EVENT_DISPLAY_MODE, mode,
var->bits_per_pixel = info->var.bits_per_pixel; NULL)) {
if (info && info->fbops->fb_check_var &&
info->fbops->fb_check_var(var, info)) {
scanning = true; scanning = true;
preferred_bad = true; preferred_bad = true;
continue; continue;
...@@ -867,28 +863,19 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate, ...@@ -867,28 +863,19 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate,
found = mode; found = mode;
found_rate_error = rate_error; found_rate_error = rate_error;
use_edid_mode = true;
} }
hdmi->var.width = hdmi->monspec.max_x * 10;
hdmi->var.height = hdmi->monspec.max_y * 10;
/* /*
* TODO 1: if no ->info is present, postpone running the config until * TODO 1: if no default mode is present, postpone running the config
* after ->info first gets registered. * until after the LCDC channel is initialized.
* TODO 2: consider registering the HDMI platform device from the LCDC * TODO 2: consider registering the HDMI platform device from the LCDC
* driver, and passing ->info with HDMI platform data. * driver.
*/ */
if (info && !found) { if (!found && hdmi->entity.def_mode.xres != 0) {
modelist = info->modelist.next && found = &hdmi->entity.def_mode;
!list_empty(&info->modelist) ? found_rate_error = sh_hdmi_rate_error(hdmi, found, hdmi_rate,
list_entry(info->modelist.next, parent_rate);
struct fb_modelist, list) :
NULL;
if (modelist) {
found = &modelist->mode;
found_rate_error = sh_hdmi_rate_error(hdmi, found, hdmi_rate, parent_rate);
}
} }
/* No cookie today */ /* No cookie today */
...@@ -912,12 +899,13 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate, ...@@ -912,12 +899,13 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate,
else else
hdmi->preprogrammed_vic = 0; hdmi->preprogrammed_vic = 0;
dev_dbg(hdmi->dev, "Using %s %s mode %ux%u@%uHz (%luHz), clock error %luHz\n", dev_dbg(hdmi->dev, "Using %s %s mode %ux%u@%uHz (%luHz), "
modelist ? "default" : "EDID", hdmi->preprogrammed_vic ? "VIC" : "external", "clock error %luHz\n", use_edid_mode ? "EDID" : "default",
found->xres, found->yres, found->refresh, hdmi->preprogrammed_vic ? "VIC" : "external", found->xres,
PICOS2KHZ(found->pixclock) * 1000, found_rate_error); found->yres, found->refresh, PICOS2KHZ(found->pixclock) * 1000,
found_rate_error);
fb_videomode_to_var(&hdmi->var, found); hdmi->mode = *found;
sh_hdmi_external_video_param(hdmi); sh_hdmi_external_video_param(hdmi);
return 0; return 0;
...@@ -998,22 +986,12 @@ static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id) ...@@ -998,22 +986,12 @@ static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
/* locking: called with info->lock held, or before register_framebuffer() */ static int sh_hdmi_display_on(struct sh_mobile_lcdc_entity *entity)
static void sh_hdmi_display_on(void *arg, struct fb_info *info)
{ {
/* struct sh_hdmi *hdmi = entity_to_sh_hdmi(entity);
* info is guaranteed to be valid, when we are called, because our
* FB_EVENT_FB_UNBIND notify is also called with info->lock held
*/
struct sh_hdmi *hdmi = arg;
struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
struct sh_mobile_lcdc_chan *ch = info->par;
dev_dbg(hdmi->dev, "%s(%p): state %x\n", __func__, dev_dbg(hdmi->dev, "%s(%p): state %x\n", __func__, hdmi,
pdata->lcd_dev, info->state); hdmi->hp_state);
/* No need to lock */
hdmi->info = info;
/* /*
* hp_state can be set to * hp_state can be set to
...@@ -1021,56 +999,30 @@ static void sh_hdmi_display_on(void *arg, struct fb_info *info) ...@@ -1021,56 +999,30 @@ static void sh_hdmi_display_on(void *arg, struct fb_info *info)
* HDMI_HOTPLUG_CONNECTED: on monitor plug-in * HDMI_HOTPLUG_CONNECTED: on monitor plug-in
* HDMI_HOTPLUG_EDID_DONE: on EDID read completion * HDMI_HOTPLUG_EDID_DONE: on EDID read completion
*/ */
switch (hdmi->hp_state) { if (hdmi->hp_state == HDMI_HOTPLUG_EDID_DONE) {
case HDMI_HOTPLUG_EDID_DONE:
/* PS mode d->e. All functions are active */ /* PS mode d->e. All functions are active */
hdmi_write(hdmi, 0x80, HDMI_SYSTEM_CTRL); hdmi_write(hdmi, 0x80, HDMI_SYSTEM_CTRL);
dev_dbg(hdmi->dev, "HDMI running\n"); dev_dbg(hdmi->dev, "HDMI running\n");
break;
case HDMI_HOTPLUG_DISCONNECTED:
info->state = FBINFO_STATE_SUSPENDED;
default:
hdmi->var = ch->display_var;
} }
return hdmi->hp_state == HDMI_HOTPLUG_DISCONNECTED
? SH_MOBILE_LCDC_DISPLAY_DISCONNECTED
: SH_MOBILE_LCDC_DISPLAY_CONNECTED;
} }
/* locking: called with info->lock held */ static void sh_hdmi_display_off(struct sh_mobile_lcdc_entity *entity)
static void sh_hdmi_display_off(void *arg)
{ {
struct sh_hdmi *hdmi = arg; struct sh_hdmi *hdmi = entity_to_sh_hdmi(entity);
struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
dev_dbg(hdmi->dev, "%s(%p)\n", __func__, pdata->lcd_dev); dev_dbg(hdmi->dev, "%s(%p)\n", __func__, hdmi);
/* PS mode e->a */ /* PS mode e->a */
hdmi_write(hdmi, 0x10, HDMI_SYSTEM_CTRL); hdmi_write(hdmi, 0x10, HDMI_SYSTEM_CTRL);
} }
static bool sh_hdmi_must_reconfigure(struct sh_hdmi *hdmi) static const struct sh_mobile_lcdc_entity_ops sh_hdmi_ops = {
{ .display_on = sh_hdmi_display_on,
struct fb_info *info = hdmi->info; .display_off = sh_hdmi_display_off,
struct sh_mobile_lcdc_chan *ch = info->par; };
struct fb_var_screeninfo *new_var = &hdmi->var, *old_var = &ch->display_var;
struct fb_videomode mode1, mode2;
fb_var_to_videomode(&mode1, old_var);
fb_var_to_videomode(&mode2, new_var);
dev_dbg(info->dev, "Old %ux%u, new %ux%u\n",
mode1.xres, mode1.yres, mode2.xres, mode2.yres);
if (fb_mode_is_equal(&mode1, &mode2)) {
/* It can be a different monitor with an equal video-mode */
old_var->width = new_var->width;
old_var->height = new_var->height;
return false;
}
dev_dbg(info->dev, "Switching %u -> %u lines\n",
mode1.yres, mode2.yres);
*old_var = *new_var;
return true;
}
/** /**
* sh_hdmi_clk_configure() - set HDMI clock frequency and enable the clock * sh_hdmi_clk_configure() - set HDMI clock frequency and enable the clock
...@@ -1111,20 +1063,11 @@ static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long hdmi_rate, ...@@ -1111,20 +1063,11 @@ static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long hdmi_rate,
static void sh_hdmi_edid_work_fn(struct work_struct *work) static void sh_hdmi_edid_work_fn(struct work_struct *work)
{ {
struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work); struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work);
struct fb_info *info; struct sh_mobile_lcdc_chan *ch = hdmi->entity.lcdc;
struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
struct sh_mobile_lcdc_chan *ch;
int ret; int ret;
dev_dbg(hdmi->dev, "%s(%p): begin, hotplug status %d\n", __func__, dev_dbg(hdmi->dev, "%s(%p): begin, hotplug status %d\n", __func__, hdmi,
pdata->lcd_dev, hdmi->hp_state); hdmi->hp_state);
if (!pdata->lcd_dev)
return;
mutex_lock(&hdmi->mutex);
info = hdmi->info;
if (hdmi->hp_state == HDMI_HOTPLUG_CONNECTED) { if (hdmi->hp_state == HDMI_HOTPLUG_CONNECTED) {
unsigned long parent_rate = 0, hdmi_rate; unsigned long parent_rate = 0, hdmi_rate;
...@@ -1145,103 +1088,32 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work) ...@@ -1145,103 +1088,32 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
/* Switched to another (d) power-save mode */ /* Switched to another (d) power-save mode */
msleep(10); msleep(10);
if (!info) if (ch && ch->notify)
goto out; ch->notify(ch, SH_MOBILE_LCDC_EVENT_DISPLAY_CONNECT,
&hdmi->mode, &hdmi->monspec);
ch = info->par;
if (lock_fb_info(info)) {
console_lock();
/* HDMI plug in */
if (!sh_hdmi_must_reconfigure(hdmi) &&
info->state == FBINFO_STATE_RUNNING) {
/*
* First activation with the default monitor - just turn
* on, if we run a resume here, the logo disappears
*/
info->var.width = hdmi->var.width;
info->var.height = hdmi->var.height;
sh_hdmi_display_on(hdmi, info);
} else {
/* New monitor or have to wake up */
fb_set_suspend(info, 0);
}
console_unlock();
unlock_fb_info(info);
}
} else { } else {
ret = 0;
if (!info)
goto out;
hdmi->monspec.modedb_len = 0; hdmi->monspec.modedb_len = 0;
fb_destroy_modedb(hdmi->monspec.modedb); fb_destroy_modedb(hdmi->monspec.modedb);
hdmi->monspec.modedb = NULL; hdmi->monspec.modedb = NULL;
if (lock_fb_info(info)) { if (ch && ch->notify)
console_lock(); ch->notify(ch, SH_MOBILE_LCDC_EVENT_DISPLAY_DISCONNECT,
NULL, NULL);
/* HDMI disconnect */ ret = 0;
fb_set_suspend(info, 1);
console_unlock();
unlock_fb_info(info);
}
} }
out: out:
if (ret < 0 && ret != -EAGAIN) if (ret < 0 && ret != -EAGAIN)
hdmi->hp_state = HDMI_HOTPLUG_DISCONNECTED; hdmi->hp_state = HDMI_HOTPLUG_DISCONNECTED;
mutex_unlock(&hdmi->mutex);
dev_dbg(hdmi->dev, "%s(%p): end\n", __func__, pdata->lcd_dev); dev_dbg(hdmi->dev, "%s(%p): end\n", __func__, hdmi);
}
static int sh_hdmi_notify(struct notifier_block *nb,
unsigned long action, void *data)
{
struct fb_event *event = data;
struct fb_info *info = event->info;
struct sh_mobile_lcdc_chan *ch = info->par;
struct sh_mobile_lcdc_board_cfg *board_cfg = &ch->cfg.board_cfg;
struct sh_hdmi *hdmi = board_cfg->board_data;
if (!hdmi || nb != &hdmi->notifier || hdmi->info != info)
return NOTIFY_DONE;
switch(action) {
case FB_EVENT_FB_REGISTERED:
/* Unneeded, activation taken care by sh_hdmi_display_on() */
break;
case FB_EVENT_FB_UNREGISTERED:
/*
* We are called from unregister_framebuffer() with the
* info->lock held. This is bad for us, because we can race with
* the scheduled work, which has to call fb_set_suspend(), which
* takes info->lock internally, so, sh_hdmi_edid_work_fn()
* cannot take and hold info->lock for the whole function
* duration. Using an additional lock creates a classical AB-BA
* lock up. Therefore, we have to release the info->lock
* temporarily, synchronise with the work queue and re-acquire
* the info->lock.
*/
unlock_fb_info(info);
mutex_lock(&hdmi->mutex);
hdmi->info = NULL;
mutex_unlock(&hdmi->mutex);
lock_fb_info(info);
return NOTIFY_OK;
}
return NOTIFY_DONE;
} }
static int __init sh_hdmi_probe(struct platform_device *pdev) 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 = pdev->dev.platform_data;
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct sh_mobile_lcdc_board_cfg *board_cfg;
int irq = platform_get_irq(pdev, 0), ret; int irq = platform_get_irq(pdev, 0), ret;
struct sh_hdmi *hdmi; struct sh_hdmi *hdmi;
long rate; long rate;
...@@ -1255,9 +1127,9 @@ static int __init sh_hdmi_probe(struct platform_device *pdev) ...@@ -1255,9 +1127,9 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
mutex_init(&hdmi->mutex);
hdmi->dev = &pdev->dev; hdmi->dev = &pdev->dev;
hdmi->entity.owner = THIS_MODULE;
hdmi->entity.ops = &sh_hdmi_ops;
hdmi->hdmi_clk = clk_get(&pdev->dev, "ick"); hdmi->hdmi_clk = clk_get(&pdev->dev, "ick");
if (IS_ERR(hdmi->hdmi_clk)) { if (IS_ERR(hdmi->hdmi_clk)) {
...@@ -1297,14 +1169,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev) ...@@ -1297,14 +1169,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
goto emap; goto emap;
} }
platform_set_drvdata(pdev, hdmi); platform_set_drvdata(pdev, &hdmi->entity);
/* Set up LCDC callbacks */
board_cfg = &pdata->lcd_chan->board_cfg;
board_cfg->owner = THIS_MODULE;
board_cfg->board_data = hdmi;
board_cfg->display_on = sh_hdmi_display_on;
board_cfg->display_off = sh_hdmi_display_off;
INIT_DELAYED_WORK(&hdmi->edid_work, sh_hdmi_edid_work_fn); INIT_DELAYED_WORK(&hdmi->edid_work, sh_hdmi_edid_work_fn);
...@@ -1329,9 +1194,6 @@ static int __init sh_hdmi_probe(struct platform_device *pdev) ...@@ -1329,9 +1194,6 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
goto ecodec; goto ecodec;
} }
hdmi->notifier.notifier_call = sh_hdmi_notify;
fb_register_client(&hdmi->notifier);
return 0; return 0;
ecodec: ecodec:
...@@ -1347,7 +1209,6 @@ static int __init sh_hdmi_probe(struct platform_device *pdev) ...@@ -1347,7 +1209,6 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
erate: erate:
clk_put(hdmi->hdmi_clk); clk_put(hdmi->hdmi_clk);
egetclk: egetclk:
mutex_destroy(&hdmi->mutex);
kfree(hdmi); kfree(hdmi);
return ret; return ret;
...@@ -1355,21 +1216,12 @@ static int __init sh_hdmi_probe(struct platform_device *pdev) ...@@ -1355,21 +1216,12 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
static int __exit sh_hdmi_remove(struct platform_device *pdev) static int __exit sh_hdmi_remove(struct platform_device *pdev)
{ {
struct sh_mobile_hdmi_info *pdata = pdev->dev.platform_data; struct sh_hdmi *hdmi = entity_to_sh_hdmi(platform_get_drvdata(pdev));
struct sh_hdmi *hdmi = platform_get_drvdata(pdev);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct sh_mobile_lcdc_board_cfg *board_cfg = &pdata->lcd_chan->board_cfg;
int irq = platform_get_irq(pdev, 0); int irq = platform_get_irq(pdev, 0);
snd_soc_unregister_codec(&pdev->dev); snd_soc_unregister_codec(&pdev->dev);
fb_unregister_client(&hdmi->notifier);
board_cfg->display_on = NULL;
board_cfg->display_off = NULL;
board_cfg->board_data = NULL;
board_cfg->owner = NULL;
/* No new work will be scheduled, wait for running ISR */ /* No new work will be scheduled, wait for running ISR */
free_irq(irq, hdmi); free_irq(irq, hdmi);
/* Wait for already scheduled work */ /* Wait for already scheduled work */
...@@ -1380,7 +1232,6 @@ static int __exit sh_hdmi_remove(struct platform_device *pdev) ...@@ -1380,7 +1232,6 @@ static int __exit sh_hdmi_remove(struct platform_device *pdev)
clk_put(hdmi->hdmi_clk); clk_put(hdmi->hdmi_clk);
iounmap(hdmi->base); iounmap(hdmi->base);
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
mutex_destroy(&hdmi->mutex);
kfree(hdmi); kfree(hdmi);
return 0; return 0;
......
...@@ -8,26 +8,27 @@ ...@@ -8,26 +8,27 @@
* for more details. * for more details.
*/ */
#include <linux/kernel.h> #include <linux/atomic.h>
#include <linux/init.h> #include <linux/backlight.h>
#include <linux/delay.h>
#include <linux/mm.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/pm_runtime.h> #include <linux/console.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/videodev2.h>
#include <linux/vmalloc.h>
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/slab.h> #include <linux/kernel.h>
#include <linux/console.h> #include <linux/mm.h>
#include <linux/backlight.h>
#include <linux/gpio.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/videodev2.h>
#include <linux/vmalloc.h>
#include <video/sh_mobile_lcdc.h> #include <video/sh_mobile_lcdc.h>
#include <video/sh_mobile_meram.h> #include <video/sh_mobile_meram.h>
#include <linux/atomic.h>
#include "sh_mobile_lcdcfb.h" #include "sh_mobile_lcdcfb.h"
...@@ -37,6 +38,24 @@ ...@@ -37,6 +38,24 @@
#define MAX_XRES 1920 #define MAX_XRES 1920
#define MAX_YRES 1080 #define MAX_YRES 1080
struct sh_mobile_lcdc_priv {
void __iomem *base;
int irq;
atomic_t hw_usecnt;
struct device *dev;
struct clk *dot_clk;
unsigned long lddckr;
struct sh_mobile_lcdc_chan ch[2];
struct notifier_block notifier;
int started;
int forced_fourcc; /* 2 channel LCDC must share fourcc setting */
struct sh_mobile_meram_info *meram_dev;
};
/* -----------------------------------------------------------------------------
* Registers access
*/
static unsigned long lcdc_offs_mainlcd[NR_CH_REGS] = { static unsigned long lcdc_offs_mainlcd[NR_CH_REGS] = {
[LDDCKPAT1R] = 0x400, [LDDCKPAT1R] = 0x400,
[LDDCKPAT2R] = 0x404, [LDDCKPAT2R] = 0x404,
...@@ -75,38 +94,6 @@ static unsigned long lcdc_offs_sublcd[NR_CH_REGS] = { ...@@ -75,38 +94,6 @@ static unsigned long lcdc_offs_sublcd[NR_CH_REGS] = {
[LDPMR] = 0x63c, [LDPMR] = 0x63c,
}; };
static const struct fb_videomode default_720p = {
.name = "HDMI 720p",
.xres = 1280,
.yres = 720,
.left_margin = 220,
.right_margin = 110,
.hsync_len = 40,
.upper_margin = 20,
.lower_margin = 5,
.vsync_len = 5,
.pixclock = 13468,
.refresh = 60,
.sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
};
struct sh_mobile_lcdc_priv {
void __iomem *base;
int irq;
atomic_t hw_usecnt;
struct device *dev;
struct clk *dot_clk;
unsigned long lddckr;
struct sh_mobile_lcdc_chan ch[2];
struct notifier_block notifier;
int started;
int forced_fourcc; /* 2 channel LCDC must share fourcc setting */
struct sh_mobile_meram_info *meram_dev;
};
static bool banked(int reg_nr) static bool banked(int reg_nr)
{ {
switch (reg_nr) { switch (reg_nr) {
...@@ -127,6 +114,11 @@ static bool banked(int reg_nr) ...@@ -127,6 +114,11 @@ static bool banked(int reg_nr)
return false; return false;
} }
static int lcdc_chan_is_sublcd(struct sh_mobile_lcdc_chan *chan)
{
return chan->cfg->chan == LCDC_CHAN_SUBLCD;
}
static void lcdc_write_chan(struct sh_mobile_lcdc_chan *chan, static void lcdc_write_chan(struct sh_mobile_lcdc_chan *chan,
int reg_nr, unsigned long data) int reg_nr, unsigned long data)
{ {
...@@ -169,11 +161,72 @@ static void lcdc_wait_bit(struct sh_mobile_lcdc_priv *priv, ...@@ -169,11 +161,72 @@ static void lcdc_wait_bit(struct sh_mobile_lcdc_priv *priv,
cpu_relax(); cpu_relax();
} }
static int lcdc_chan_is_sublcd(struct sh_mobile_lcdc_chan *chan) /* -----------------------------------------------------------------------------
* Clock management
*/
static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv)
{
if (atomic_inc_and_test(&priv->hw_usecnt)) {
if (priv->dot_clk)
clk_enable(priv->dot_clk);
pm_runtime_get_sync(priv->dev);
if (priv->meram_dev && priv->meram_dev->pdev)
pm_runtime_get_sync(&priv->meram_dev->pdev->dev);
}
}
static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv)
{ {
return chan->cfg.chan == LCDC_CHAN_SUBLCD; if (atomic_sub_return(1, &priv->hw_usecnt) == -1) {
if (priv->meram_dev && priv->meram_dev->pdev)
pm_runtime_put_sync(&priv->meram_dev->pdev->dev);
pm_runtime_put(priv->dev);
if (priv->dot_clk)
clk_disable(priv->dot_clk);
}
}
static int sh_mobile_lcdc_setup_clocks(struct sh_mobile_lcdc_priv *priv,
int clock_source)
{
struct clk *clk;
char *str;
switch (clock_source) {
case LCDC_CLK_BUS:
str = "bus_clk";
priv->lddckr = LDDCKR_ICKSEL_BUS;
break;
case LCDC_CLK_PERIPHERAL:
str = "peripheral_clk";
priv->lddckr = LDDCKR_ICKSEL_MIPI;
break;
case LCDC_CLK_EXTERNAL:
str = NULL;
priv->lddckr = LDDCKR_ICKSEL_HDMI;
break;
default:
return -EINVAL;
}
if (str == NULL)
return 0;
clk = clk_get(priv->dev, str);
if (IS_ERR(clk)) {
dev_err(priv->dev, "cannot get dot clock %s\n", str);
return PTR_ERR(clk);
}
priv->dot_clk = clk;
return 0;
} }
/* -----------------------------------------------------------------------------
* Display, panel and deferred I/O
*/
static void lcdc_sys_write_index(void *handle, unsigned long data) static void lcdc_sys_write_index(void *handle, unsigned long data)
{ {
struct sh_mobile_lcdc_chan *ch = handle; struct sh_mobile_lcdc_chan *ch = handle;
...@@ -216,74 +269,11 @@ struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = { ...@@ -216,74 +269,11 @@ struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
lcdc_sys_read_data, lcdc_sys_read_data,
}; };
static int sh_mobile_format_fourcc(const struct fb_var_screeninfo *var)
{
if (var->grayscale > 1)
return var->grayscale;
switch (var->bits_per_pixel) {
case 16:
return V4L2_PIX_FMT_RGB565;
case 24:
return V4L2_PIX_FMT_BGR24;
case 32:
return V4L2_PIX_FMT_BGR32;
default:
return 0;
}
}
static int sh_mobile_format_is_fourcc(const struct fb_var_screeninfo *var)
{
return var->grayscale > 1;
}
static bool sh_mobile_format_is_yuv(const struct fb_var_screeninfo *var)
{
if (var->grayscale <= 1)
return false;
switch (var->grayscale) {
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV61:
case V4L2_PIX_FMT_NV24:
case V4L2_PIX_FMT_NV42:
return true;
default:
return false;
}
}
static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv)
{
if (atomic_inc_and_test(&priv->hw_usecnt)) {
if (priv->dot_clk)
clk_enable(priv->dot_clk);
pm_runtime_get_sync(priv->dev);
if (priv->meram_dev && priv->meram_dev->pdev)
pm_runtime_get_sync(&priv->meram_dev->pdev->dev);
}
}
static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv)
{
if (atomic_sub_return(1, &priv->hw_usecnt) == -1) {
if (priv->meram_dev && priv->meram_dev->pdev)
pm_runtime_put_sync(&priv->meram_dev->pdev->dev);
pm_runtime_put(priv->dev);
if (priv->dot_clk)
clk_disable(priv->dot_clk);
}
}
static int sh_mobile_lcdc_sginit(struct fb_info *info, static int sh_mobile_lcdc_sginit(struct fb_info *info,
struct list_head *pagelist) struct list_head *pagelist)
{ {
struct sh_mobile_lcdc_chan *ch = info->par; struct sh_mobile_lcdc_chan *ch = info->par;
unsigned int nr_pages_max = info->fix.smem_len >> PAGE_SHIFT; unsigned int nr_pages_max = ch->fb_size >> PAGE_SHIFT;
struct page *page; struct page *page;
int nr_pages = 0; int nr_pages = 0;
...@@ -299,7 +289,7 @@ static void sh_mobile_lcdc_deferred_io(struct fb_info *info, ...@@ -299,7 +289,7 @@ static void sh_mobile_lcdc_deferred_io(struct fb_info *info,
struct list_head *pagelist) struct list_head *pagelist)
{ {
struct sh_mobile_lcdc_chan *ch = info->par; struct sh_mobile_lcdc_chan *ch = info->par;
struct sh_mobile_lcdc_board_cfg *bcfg = &ch->cfg.board_cfg; const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg;
/* enable clocks before accessing hardware */ /* enable clocks before accessing hardware */
sh_mobile_lcdc_clk_on(ch->lcdc); sh_mobile_lcdc_clk_on(ch->lcdc);
...@@ -323,16 +313,15 @@ static void sh_mobile_lcdc_deferred_io(struct fb_info *info, ...@@ -323,16 +313,15 @@ static void sh_mobile_lcdc_deferred_io(struct fb_info *info,
unsigned int nr_pages = sh_mobile_lcdc_sginit(info, pagelist); unsigned int nr_pages = sh_mobile_lcdc_sginit(info, pagelist);
/* trigger panel update */ /* trigger panel update */
dma_map_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE); dma_map_sg(ch->lcdc->dev, ch->sglist, nr_pages, DMA_TO_DEVICE);
if (bcfg->start_transfer) if (panel->start_transfer)
bcfg->start_transfer(bcfg->board_data, ch, panel->start_transfer(ch, &sh_mobile_lcdc_sys_bus_ops);
&sh_mobile_lcdc_sys_bus_ops);
lcdc_write_chan(ch, LDSM2R, LDSM2R_OSTRG); lcdc_write_chan(ch, LDSM2R, LDSM2R_OSTRG);
dma_unmap_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE); dma_unmap_sg(ch->lcdc->dev, ch->sglist, nr_pages,
DMA_TO_DEVICE);
} else { } else {
if (bcfg->start_transfer) if (panel->start_transfer)
bcfg->start_transfer(bcfg->board_data, ch, panel->start_transfer(ch, &sh_mobile_lcdc_sys_bus_ops);
&sh_mobile_lcdc_sys_bus_ops);
lcdc_write_chan(ch, LDSM2R, LDSM2R_OSTRG); lcdc_write_chan(ch, LDSM2R, LDSM2R_OSTRG);
} }
} }
...@@ -345,6 +334,217 @@ static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info) ...@@ -345,6 +334,217 @@ static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info)
schedule_delayed_work(&info->deferred_work, fbdefio->delay); schedule_delayed_work(&info->deferred_work, fbdefio->delay);
} }
static void sh_mobile_lcdc_display_on(struct sh_mobile_lcdc_chan *ch)
{
const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg;
if (ch->tx_dev) {
int ret;
ret = ch->tx_dev->ops->display_on(ch->tx_dev);
if (ret < 0)
return;
if (ret == SH_MOBILE_LCDC_DISPLAY_DISCONNECTED)
ch->info->state = FBINFO_STATE_SUSPENDED;
}
/* HDMI must be enabled before LCDC configuration */
if (panel->display_on)
panel->display_on();
}
static void sh_mobile_lcdc_display_off(struct sh_mobile_lcdc_chan *ch)
{
const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg;
if (panel->display_off)
panel->display_off();
if (ch->tx_dev)
ch->tx_dev->ops->display_off(ch->tx_dev);
}
static bool
sh_mobile_lcdc_must_reconfigure(struct sh_mobile_lcdc_chan *ch,
const struct fb_videomode *new_mode)
{
dev_dbg(ch->info->dev, "Old %ux%u, new %ux%u\n",
ch->display.mode.xres, ch->display.mode.yres,
new_mode->xres, new_mode->yres);
/* It can be a different monitor with an equal video-mode */
if (fb_mode_is_equal(&ch->display.mode, new_mode))
return false;
dev_dbg(ch->info->dev, "Switching %u -> %u lines\n",
ch->display.mode.yres, new_mode->yres);
ch->display.mode = *new_mode;
return true;
}
static int sh_mobile_check_var(struct fb_var_screeninfo *var,
struct fb_info *info);
static int sh_mobile_lcdc_display_notify(struct sh_mobile_lcdc_chan *ch,
enum sh_mobile_lcdc_entity_event event,
const struct fb_videomode *mode,
const struct fb_monspecs *monspec)
{
struct fb_info *info = ch->info;
struct fb_var_screeninfo var;
int ret = 0;
switch (event) {
case SH_MOBILE_LCDC_EVENT_DISPLAY_CONNECT:
/* HDMI plug in */
if (lock_fb_info(info)) {
console_lock();
ch->display.width = monspec->max_x * 10;
ch->display.height = monspec->max_y * 10;
if (!sh_mobile_lcdc_must_reconfigure(ch, mode) &&
info->state == FBINFO_STATE_RUNNING) {
/* First activation with the default monitor.
* Just turn on, if we run a resume here, the
* logo disappears.
*/
info->var.width = monspec->max_x * 10;
info->var.height = monspec->max_y * 10;
sh_mobile_lcdc_display_on(ch);
} else {
/* New monitor or have to wake up */
fb_set_suspend(info, 0);
}
console_unlock();
unlock_fb_info(info);
}
break;
case SH_MOBILE_LCDC_EVENT_DISPLAY_DISCONNECT:
/* HDMI disconnect */
if (lock_fb_info(info)) {
console_lock();
fb_set_suspend(info, 1);
console_unlock();
unlock_fb_info(info);
}
break;
case SH_MOBILE_LCDC_EVENT_DISPLAY_MODE:
/* Validate a proposed new mode */
fb_videomode_to_var(&var, mode);
var.bits_per_pixel = info->var.bits_per_pixel;
var.grayscale = info->var.grayscale;
ret = sh_mobile_check_var(&var, info);
break;
}
return ret;
}
/* -----------------------------------------------------------------------------
* Format helpers
*/
struct sh_mobile_lcdc_format_info {
u32 fourcc;
unsigned int bpp;
bool yuv;
u32 lddfr;
};
static const struct sh_mobile_lcdc_format_info sh_mobile_format_infos[] = {
{
.fourcc = V4L2_PIX_FMT_RGB565,
.bpp = 16,
.yuv = false,
.lddfr = LDDFR_PKF_RGB16,
}, {
.fourcc = V4L2_PIX_FMT_BGR24,
.bpp = 24,
.yuv = false,
.lddfr = LDDFR_PKF_RGB24,
}, {
.fourcc = V4L2_PIX_FMT_BGR32,
.bpp = 32,
.yuv = false,
.lddfr = LDDFR_PKF_ARGB32,
}, {
.fourcc = V4L2_PIX_FMT_NV12,
.bpp = 12,
.yuv = true,
.lddfr = LDDFR_CC | LDDFR_YF_420,
}, {
.fourcc = V4L2_PIX_FMT_NV21,
.bpp = 12,
.yuv = true,
.lddfr = LDDFR_CC | LDDFR_YF_420,
}, {
.fourcc = V4L2_PIX_FMT_NV16,
.bpp = 16,
.yuv = true,
.lddfr = LDDFR_CC | LDDFR_YF_422,
}, {
.fourcc = V4L2_PIX_FMT_NV61,
.bpp = 16,
.yuv = true,
.lddfr = LDDFR_CC | LDDFR_YF_422,
}, {
.fourcc = V4L2_PIX_FMT_NV24,
.bpp = 24,
.yuv = true,
.lddfr = LDDFR_CC | LDDFR_YF_444,
}, {
.fourcc = V4L2_PIX_FMT_NV42,
.bpp = 24,
.yuv = true,
.lddfr = LDDFR_CC | LDDFR_YF_444,
},
};
static const struct sh_mobile_lcdc_format_info *
sh_mobile_format_info(u32 fourcc)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(sh_mobile_format_infos); ++i) {
if (sh_mobile_format_infos[i].fourcc == fourcc)
return &sh_mobile_format_infos[i];
}
return NULL;
}
static int sh_mobile_format_fourcc(const struct fb_var_screeninfo *var)
{
if (var->grayscale > 1)
return var->grayscale;
switch (var->bits_per_pixel) {
case 16:
return V4L2_PIX_FMT_RGB565;
case 24:
return V4L2_PIX_FMT_BGR24;
case 32:
return V4L2_PIX_FMT_BGR32;
default:
return 0;
}
}
static int sh_mobile_format_is_fourcc(const struct fb_var_screeninfo *var)
{
return var->grayscale > 1;
}
/* -----------------------------------------------------------------------------
* Start, stop and IRQ
*/
static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data) static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data)
{ {
struct sh_mobile_lcdc_priv *priv = data; struct sh_mobile_lcdc_priv *priv = data;
...@@ -385,6 +585,26 @@ static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data) ...@@ -385,6 +585,26 @@ static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int sh_mobile_wait_for_vsync(struct sh_mobile_lcdc_chan *ch)
{
unsigned long ldintr;
int ret;
/* Enable VSync End interrupt and be careful not to acknowledge any
* pending interrupt.
*/
ldintr = lcdc_read(ch->lcdc, _LDINTR);
ldintr |= LDINTR_VEE | LDINTR_STATUS_MASK;
lcdc_write(ch->lcdc, _LDINTR, ldintr);
ret = wait_for_completion_interruptible_timeout(&ch->vsync_completion,
msecs_to_jiffies(100));
if (!ret)
return -ETIMEDOUT;
return 0;
}
static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv *priv, static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv *priv,
int start) int start)
{ {
...@@ -416,53 +636,52 @@ static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv *priv, ...@@ -416,53 +636,52 @@ static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv *priv,
static void sh_mobile_lcdc_geometry(struct sh_mobile_lcdc_chan *ch) static void sh_mobile_lcdc_geometry(struct sh_mobile_lcdc_chan *ch)
{ {
struct fb_var_screeninfo *var = &ch->info->var, *display_var = &ch->display_var; const struct fb_var_screeninfo *var = &ch->info->var;
const struct fb_videomode *mode = &ch->display.mode;
unsigned long h_total, hsync_pos, display_h_total; unsigned long h_total, hsync_pos, display_h_total;
u32 tmp; u32 tmp;
tmp = ch->ldmt1r_value; tmp = ch->ldmt1r_value;
tmp |= (var->sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : LDMT1R_VPOL; tmp |= (var->sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : LDMT1R_VPOL;
tmp |= (var->sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : LDMT1R_HPOL; tmp |= (var->sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : LDMT1R_HPOL;
tmp |= (ch->cfg.flags & LCDC_FLAGS_DWPOL) ? LDMT1R_DWPOL : 0; tmp |= (ch->cfg->flags & LCDC_FLAGS_DWPOL) ? LDMT1R_DWPOL : 0;
tmp |= (ch->cfg.flags & LCDC_FLAGS_DIPOL) ? LDMT1R_DIPOL : 0; tmp |= (ch->cfg->flags & LCDC_FLAGS_DIPOL) ? LDMT1R_DIPOL : 0;
tmp |= (ch->cfg.flags & LCDC_FLAGS_DAPOL) ? LDMT1R_DAPOL : 0; tmp |= (ch->cfg->flags & LCDC_FLAGS_DAPOL) ? LDMT1R_DAPOL : 0;
tmp |= (ch->cfg.flags & LCDC_FLAGS_HSCNT) ? LDMT1R_HSCNT : 0; tmp |= (ch->cfg->flags & LCDC_FLAGS_HSCNT) ? LDMT1R_HSCNT : 0;
tmp |= (ch->cfg.flags & LCDC_FLAGS_DWCNT) ? LDMT1R_DWCNT : 0; tmp |= (ch->cfg->flags & LCDC_FLAGS_DWCNT) ? LDMT1R_DWCNT : 0;
lcdc_write_chan(ch, LDMT1R, tmp); lcdc_write_chan(ch, LDMT1R, tmp);
/* setup SYS bus */ /* setup SYS bus */
lcdc_write_chan(ch, LDMT2R, ch->cfg.sys_bus_cfg.ldmt2r); lcdc_write_chan(ch, LDMT2R, ch->cfg->sys_bus_cfg.ldmt2r);
lcdc_write_chan(ch, LDMT3R, ch->cfg.sys_bus_cfg.ldmt3r); lcdc_write_chan(ch, LDMT3R, ch->cfg->sys_bus_cfg.ldmt3r);
/* horizontal configuration */ /* horizontal configuration */
h_total = display_var->xres + display_var->hsync_len + h_total = mode->xres + mode->hsync_len + mode->left_margin
display_var->left_margin + display_var->right_margin; + mode->right_margin;
tmp = h_total / 8; /* HTCN */ tmp = h_total / 8; /* HTCN */
tmp |= (min(display_var->xres, var->xres) / 8) << 16; /* HDCN */ tmp |= (min(mode->xres, ch->xres) / 8) << 16; /* HDCN */
lcdc_write_chan(ch, LDHCNR, tmp); lcdc_write_chan(ch, LDHCNR, tmp);
hsync_pos = display_var->xres + display_var->right_margin; hsync_pos = mode->xres + mode->right_margin;
tmp = hsync_pos / 8; /* HSYNP */ tmp = hsync_pos / 8; /* HSYNP */
tmp |= (display_var->hsync_len / 8) << 16; /* HSYNW */ tmp |= (mode->hsync_len / 8) << 16; /* HSYNW */
lcdc_write_chan(ch, LDHSYNR, tmp); lcdc_write_chan(ch, LDHSYNR, tmp);
/* vertical configuration */ /* vertical configuration */
tmp = display_var->yres + display_var->vsync_len + tmp = mode->yres + mode->vsync_len + mode->upper_margin
display_var->upper_margin + display_var->lower_margin; /* VTLN */ + mode->lower_margin; /* VTLN */
tmp |= min(display_var->yres, var->yres) << 16; /* VDLN */ tmp |= min(mode->yres, ch->yres) << 16; /* VDLN */
lcdc_write_chan(ch, LDVLNR, tmp); lcdc_write_chan(ch, LDVLNR, tmp);
tmp = display_var->yres + display_var->lower_margin; /* VSYNP */ tmp = mode->yres + mode->lower_margin; /* VSYNP */
tmp |= display_var->vsync_len << 16; /* VSYNW */ tmp |= mode->vsync_len << 16; /* VSYNW */
lcdc_write_chan(ch, LDVSYNR, tmp); lcdc_write_chan(ch, LDVSYNR, tmp);
/* Adjust horizontal synchronisation for HDMI */ /* Adjust horizontal synchronisation for HDMI */
display_h_total = display_var->xres + display_var->hsync_len + display_h_total = mode->xres + mode->hsync_len + mode->left_margin
display_var->left_margin + display_var->right_margin; + mode->right_margin;
tmp = ((display_var->xres & 7) << 24) | tmp = ((mode->xres & 7) << 24) | ((display_h_total & 7) << 16)
((display_h_total & 7) << 16) | | ((mode->hsync_len & 7) << 8) | (hsync_pos & 7);
((display_var->hsync_len & 7) << 8) |
(hsync_pos & 7);
lcdc_write_chan(ch, LDHAJR, tmp); lcdc_write_chan(ch, LDHAJR, tmp);
} }
...@@ -498,7 +717,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -498,7 +717,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
/* Power supply */ /* Power supply */
lcdc_write_chan(ch, LDPMR, 0); lcdc_write_chan(ch, LDPMR, 0);
m = ch->cfg.clock_divider; m = ch->cfg->clock_divider;
if (!m) if (!m)
continue; continue;
...@@ -525,32 +744,10 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -525,32 +744,10 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
sh_mobile_lcdc_geometry(ch); sh_mobile_lcdc_geometry(ch);
switch (sh_mobile_format_fourcc(&ch->info->var)) { tmp = ch->format->lddfr;
case V4L2_PIX_FMT_RGB565:
tmp = LDDFR_PKF_RGB16;
break;
case V4L2_PIX_FMT_BGR24:
tmp = LDDFR_PKF_RGB24;
break;
case V4L2_PIX_FMT_BGR32:
tmp = LDDFR_PKF_ARGB32;
break;
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV21:
tmp = LDDFR_CC | LDDFR_YF_420;
break;
case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV61:
tmp = LDDFR_CC | LDDFR_YF_422;
break;
case V4L2_PIX_FMT_NV24:
case V4L2_PIX_FMT_NV42:
tmp = LDDFR_CC | LDDFR_YF_444;
break;
}
if (sh_mobile_format_is_yuv(&ch->info->var)) { if (ch->format->yuv) {
switch (ch->info->var.colorspace) { switch (ch->colorspace) {
case V4L2_COLORSPACE_REC709: case V4L2_COLORSPACE_REC709:
tmp |= LDDFR_CF1; tmp |= LDDFR_CF1;
break; break;
...@@ -563,7 +760,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -563,7 +760,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
lcdc_write_chan(ch, LDDFR, tmp); lcdc_write_chan(ch, LDDFR, tmp);
lcdc_write_chan(ch, LDMLSR, ch->pitch); lcdc_write_chan(ch, LDMLSR, ch->pitch);
lcdc_write_chan(ch, LDSA1R, ch->base_addr_y); lcdc_write_chan(ch, LDSA1R, ch->base_addr_y);
if (sh_mobile_format_is_yuv(&ch->info->var)) if (ch->format->yuv)
lcdc_write_chan(ch, LDSA2R, ch->base_addr_c); lcdc_write_chan(ch, LDSA2R, ch->base_addr_c);
/* When using deferred I/O mode, configure the LCDC for one-shot /* When using deferred I/O mode, configure the LCDC for one-shot
...@@ -571,7 +768,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -571,7 +768,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
* continuous read mode. * continuous read mode.
*/ */
if (ch->ldmt1r_value & LDMT1R_IFM && if (ch->ldmt1r_value & LDMT1R_IFM &&
ch->cfg.sys_bus_cfg.deferred_io_msec) { ch->cfg->sys_bus_cfg.deferred_io_msec) {
lcdc_write_chan(ch, LDSM1R, LDSM1R_OS); lcdc_write_chan(ch, LDSM1R, LDSM1R_OS);
lcdc_write(priv, _LDINTR, LDINTR_FE); lcdc_write(priv, _LDINTR, LDINTR_FE);
} else { } else {
...@@ -580,7 +777,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -580,7 +777,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
} }
/* Word and long word swap. */ /* Word and long word swap. */
switch (sh_mobile_format_fourcc(&priv->ch[0].info->var)) { switch (priv->ch[0].format->fourcc) {
case V4L2_PIX_FMT_RGB565: case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV61: case V4L2_PIX_FMT_NV61:
...@@ -609,7 +806,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -609,7 +806,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
{ {
struct sh_mobile_meram_info *mdev = priv->meram_dev; struct sh_mobile_meram_info *mdev = priv->meram_dev;
struct sh_mobile_lcdc_board_cfg *board_cfg;
struct sh_mobile_lcdc_chan *ch; struct sh_mobile_lcdc_chan *ch;
unsigned long tmp; unsigned long tmp;
int ret; int ret;
...@@ -626,15 +822,15 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -626,15 +822,15 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
lcdc_wait_bit(priv, _LDCNT2R, LDCNT2R_BR, 0); lcdc_wait_bit(priv, _LDCNT2R, LDCNT2R_BR, 0);
for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
ch = &priv->ch[k]; const struct sh_mobile_lcdc_panel_cfg *panel;
ch = &priv->ch[k];
if (!ch->enabled) if (!ch->enabled)
continue; continue;
board_cfg = &ch->cfg.board_cfg; panel = &ch->cfg->panel_cfg;
if (board_cfg->setup_sys) { if (panel->setup_sys) {
ret = board_cfg->setup_sys(board_cfg->board_data, ch, ret = panel->setup_sys(ch, &sh_mobile_lcdc_sys_bus_ops);
&sh_mobile_lcdc_sys_bus_ops);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -642,33 +838,30 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -642,33 +838,30 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
/* Compute frame buffer base address and pitch for each channel. */ /* Compute frame buffer base address and pitch for each channel. */
for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
struct sh_mobile_meram_cfg *cfg;
int pixelformat; int pixelformat;
void *meram;
ch = &priv->ch[k]; ch = &priv->ch[k];
if (!ch->enabled) if (!ch->enabled)
continue; continue;
ch->base_addr_y = ch->info->fix.smem_start; ch->base_addr_y = ch->dma_handle;
ch->base_addr_c = ch->base_addr_y ch->base_addr_c = ch->base_addr_y + ch->xres * ch->yres_virtual;
+ ch->info->var.xres
* ch->info->var.yres_virtual;
ch->pitch = ch->info->fix.line_length;
/* Enable MERAM if possible. */ /* Enable MERAM if possible. */
cfg = ch->cfg.meram_cfg; if (mdev == NULL || mdev->ops == NULL ||
if (mdev == NULL || mdev->ops == NULL || cfg == NULL) ch->cfg->meram_cfg == NULL)
continue; continue;
/* we need to de-init configured ICBs before we can /* we need to de-init configured ICBs before we can
* re-initialize them. * re-initialize them.
*/ */
if (ch->meram_enabled) { if (ch->meram) {
mdev->ops->meram_unregister(mdev, cfg); mdev->ops->meram_unregister(mdev, ch->meram);
ch->meram_enabled = 0; ch->meram = NULL;
} }
switch (sh_mobile_format_fourcc(&ch->info->var)) { switch (ch->format->fourcc) {
case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV16:
...@@ -687,13 +880,15 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -687,13 +880,15 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
break; break;
} }
ret = mdev->ops->meram_register(mdev, cfg, ch->pitch, meram = mdev->ops->meram_register(mdev, ch->cfg->meram_cfg,
ch->info->var.yres, pixelformat, ch->pitch, ch->yres, pixelformat,
ch->base_addr_y, ch->base_addr_c,
&ch->base_addr_y, &ch->base_addr_c,
&ch->pitch); &ch->pitch);
if (!ret) if (!IS_ERR(meram)) {
ch->meram_enabled = 1; mdev->ops->meram_update(mdev, meram,
ch->base_addr_y, ch->base_addr_c,
&ch->base_addr_y, &ch->base_addr_c);
ch->meram = meram;
}
} }
/* Start the LCDC. */ /* Start the LCDC. */
...@@ -707,7 +902,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -707,7 +902,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
if (!ch->enabled) if (!ch->enabled)
continue; continue;
tmp = ch->cfg.sys_bus_cfg.deferred_io_msec; tmp = ch->cfg->sys_bus_cfg.deferred_io_msec;
if (ch->ldmt1r_value & LDMT1R_IFM && tmp) { if (ch->ldmt1r_value & LDMT1R_IFM && tmp) {
ch->defio.deferred_io = sh_mobile_lcdc_deferred_io; ch->defio.deferred_io = sh_mobile_lcdc_deferred_io;
ch->defio.delay = msecs_to_jiffies(tmp); ch->defio.delay = msecs_to_jiffies(tmp);
...@@ -715,11 +910,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -715,11 +910,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
fb_deferred_io_init(ch->info); fb_deferred_io_init(ch->info);
} }
board_cfg = &ch->cfg.board_cfg; sh_mobile_lcdc_display_on(ch);
if (board_cfg->display_on && try_module_get(board_cfg->owner)) {
board_cfg->display_on(board_cfg->board_data, ch->info);
module_put(board_cfg->owner);
}
if (ch->bl) { if (ch->bl) {
ch->bl->props.power = FB_BLANK_UNBLANK; ch->bl->props.power = FB_BLANK_UNBLANK;
...@@ -733,7 +924,6 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -733,7 +924,6 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv) static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
{ {
struct sh_mobile_lcdc_chan *ch; struct sh_mobile_lcdc_chan *ch;
struct sh_mobile_lcdc_board_cfg *board_cfg;
int k; int k;
/* clean up deferred io and ask board code to disable panel */ /* clean up deferred io and ask board code to disable panel */
...@@ -760,20 +950,14 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv) ...@@ -760,20 +950,14 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
backlight_update_status(ch->bl); backlight_update_status(ch->bl);
} }
board_cfg = &ch->cfg.board_cfg; sh_mobile_lcdc_display_off(ch);
if (board_cfg->display_off && try_module_get(board_cfg->owner)) {
board_cfg->display_off(board_cfg->board_data);
module_put(board_cfg->owner);
}
/* disable the meram */ /* disable the meram */
if (ch->meram_enabled) { if (ch->meram) {
struct sh_mobile_meram_cfg *cfg;
struct sh_mobile_meram_info *mdev; struct sh_mobile_meram_info *mdev;
cfg = ch->cfg.meram_cfg;
mdev = priv->meram_dev; mdev = priv->meram_dev;
mdev->ops->meram_unregister(mdev, cfg); mdev->ops->meram_unregister(mdev, ch->meram);
ch->meram_enabled = 0; ch->meram = 0;
} }
} }
...@@ -790,86 +974,9 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv) ...@@ -790,86 +974,9 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
sh_mobile_lcdc_clk_off(priv); sh_mobile_lcdc_clk_off(priv);
} }
static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch) /* -----------------------------------------------------------------------------
{ * Frame buffer operations
int interface_type = ch->cfg.interface_type;
switch (interface_type) {
case RGB8:
case RGB9:
case RGB12A:
case RGB12B:
case RGB16:
case RGB18:
case RGB24:
case SYS8A:
case SYS8B:
case SYS8C:
case SYS8D:
case SYS9:
case SYS12:
case SYS16A:
case SYS16B:
case SYS16C:
case SYS18:
case SYS24:
break;
default:
return -EINVAL;
}
/* SUBLCD only supports SYS interface */
if (lcdc_chan_is_sublcd(ch)) {
if (!(interface_type & LDMT1R_IFM))
return -EINVAL;
interface_type &= ~LDMT1R_IFM;
}
ch->ldmt1r_value = interface_type;
return 0;
}
static int sh_mobile_lcdc_setup_clocks(struct platform_device *pdev,
int clock_source,
struct sh_mobile_lcdc_priv *priv)
{
char *str;
switch (clock_source) {
case LCDC_CLK_BUS:
str = "bus_clk";
priv->lddckr = LDDCKR_ICKSEL_BUS;
break;
case LCDC_CLK_PERIPHERAL:
str = "peripheral_clk";
priv->lddckr = LDDCKR_ICKSEL_MIPI;
break;
case LCDC_CLK_EXTERNAL:
str = NULL;
priv->lddckr = LDDCKR_ICKSEL_HDMI;
break;
default:
return -EINVAL;
}
if (str) {
priv->dot_clk = clk_get(&pdev->dev, str);
if (IS_ERR(priv->dot_clk)) {
dev_err(&pdev->dev, "cannot get dot clock %s\n", str);
return PTR_ERR(priv->dot_clk);
}
}
/* Runtime PM support involves two step for this driver:
* 1) Enable Runtime PM
* 2) Force Runtime PM Resume since hardware is accessed from probe()
*/ */
priv->dev = &pdev->dev;
pm_runtime_enable(priv->dev);
pm_runtime_resume(priv->dev);
return 0;
}
static int sh_mobile_lcdc_setcolreg(u_int regno, static int sh_mobile_lcdc_setcolreg(u_int regno,
u_int red, u_int green, u_int blue, u_int red, u_int green, u_int blue,
...@@ -936,14 +1043,12 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var, ...@@ -936,14 +1043,12 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
unsigned long new_pan_offset; unsigned long new_pan_offset;
unsigned long base_addr_y, base_addr_c; unsigned long base_addr_y, base_addr_c;
unsigned long c_offset; unsigned long c_offset;
bool yuv = sh_mobile_format_is_yuv(&info->var);
if (!yuv) if (!ch->format->yuv)
new_pan_offset = var->yoffset * info->fix.line_length new_pan_offset = var->yoffset * ch->pitch
+ var->xoffset * (info->var.bits_per_pixel / 8); + var->xoffset * (ch->format->bpp / 8);
else else
new_pan_offset = var->yoffset * info->fix.line_length new_pan_offset = var->yoffset * ch->pitch + var->xoffset;
+ var->xoffset;
if (new_pan_offset == ch->pan_offset) if (new_pan_offset == ch->pan_offset)
return 0; /* No change, do nothing */ return 0; /* No change, do nothing */
...@@ -952,39 +1057,33 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var, ...@@ -952,39 +1057,33 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
/* Set the source address for the next refresh */ /* Set the source address for the next refresh */
base_addr_y = ch->dma_handle + new_pan_offset; base_addr_y = ch->dma_handle + new_pan_offset;
if (yuv) { if (ch->format->yuv) {
/* Set y offset */ /* Set y offset */
c_offset = var->yoffset * info->fix.line_length c_offset = var->yoffset * ch->pitch
* (info->var.bits_per_pixel - 8) / 8; * (ch->format->bpp - 8) / 8;
base_addr_c = ch->dma_handle base_addr_c = ch->dma_handle + ch->xres * ch->yres_virtual
+ info->var.xres * info->var.yres_virtual
+ c_offset; + c_offset;
/* Set x offset */ /* Set x offset */
if (sh_mobile_format_fourcc(&info->var) == V4L2_PIX_FMT_NV24) if (ch->format->fourcc == V4L2_PIX_FMT_NV24)
base_addr_c += 2 * var->xoffset; base_addr_c += 2 * var->xoffset;
else else
base_addr_c += var->xoffset; base_addr_c += var->xoffset;
} }
if (ch->meram_enabled) { if (ch->meram) {
struct sh_mobile_meram_cfg *cfg;
struct sh_mobile_meram_info *mdev; struct sh_mobile_meram_info *mdev;
int ret;
cfg = ch->cfg.meram_cfg;
mdev = priv->meram_dev; mdev = priv->meram_dev;
ret = mdev->ops->meram_update(mdev, cfg, mdev->ops->meram_update(mdev, ch->meram,
base_addr_y, base_addr_c, base_addr_y, base_addr_c,
&base_addr_y, &base_addr_c); &base_addr_y, &base_addr_c);
if (ret)
return ret;
} }
ch->base_addr_y = base_addr_y; ch->base_addr_y = base_addr_y;
ch->base_addr_c = base_addr_c; ch->base_addr_c = base_addr_c;
lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y); lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y);
if (yuv) if (ch->format->yuv)
lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c); lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c);
if (lcdc_chan_is_sublcd(ch)) if (lcdc_chan_is_sublcd(ch))
...@@ -999,27 +1098,6 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var, ...@@ -999,27 +1098,6 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
return 0; return 0;
} }
static int sh_mobile_wait_for_vsync(struct fb_info *info)
{
struct sh_mobile_lcdc_chan *ch = info->par;
unsigned long ldintr;
int ret;
/* Enable VSync End interrupt and be careful not to acknowledge any
* pending interrupt.
*/
ldintr = lcdc_read(ch->lcdc, _LDINTR);
ldintr |= LDINTR_VEE | LDINTR_STATUS_MASK;
lcdc_write(ch->lcdc, _LDINTR, ldintr);
ret = wait_for_completion_interruptible_timeout(&ch->vsync_completion,
msecs_to_jiffies(100));
if (!ret)
return -ETIMEDOUT;
return 0;
}
static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd, static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
...@@ -1027,7 +1105,7 @@ static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd, ...@@ -1027,7 +1105,7 @@ static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd,
switch (cmd) { switch (cmd) {
case FBIO_WAITFORVSYNC: case FBIO_WAITFORVSYNC:
retval = sh_mobile_wait_for_vsync(info); retval = sh_mobile_wait_for_vsync(info->par);
break; break;
default: default:
...@@ -1040,7 +1118,8 @@ static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd, ...@@ -1040,7 +1118,8 @@ static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd,
static void sh_mobile_fb_reconfig(struct fb_info *info) static void sh_mobile_fb_reconfig(struct fb_info *info)
{ {
struct sh_mobile_lcdc_chan *ch = info->par; struct sh_mobile_lcdc_chan *ch = info->par;
struct fb_videomode mode1, mode2; struct fb_var_screeninfo var;
struct fb_videomode mode;
struct fb_event event; struct fb_event event;
int evnt = FB_EVENT_MODE_CHANGE_ALL; int evnt = FB_EVENT_MODE_CHANGE_ALL;
...@@ -1048,14 +1127,19 @@ static void sh_mobile_fb_reconfig(struct fb_info *info) ...@@ -1048,14 +1127,19 @@ static void sh_mobile_fb_reconfig(struct fb_info *info)
/* More framebuffer users are active */ /* More framebuffer users are active */
return; return;
fb_var_to_videomode(&mode1, &ch->display_var); fb_var_to_videomode(&mode, &info->var);
fb_var_to_videomode(&mode2, &info->var);
if (fb_mode_is_equal(&mode1, &mode2)) if (fb_mode_is_equal(&ch->display.mode, &mode))
return; return;
/* Display has been re-plugged, framebuffer is free now, reconfigure */ /* Display has been re-plugged, framebuffer is free now, reconfigure */
if (fb_set_var(info, &ch->display_var) < 0) var = info->var;
fb_videomode_to_var(&var, &ch->display.mode);
var.width = ch->display.width;
var.height = ch->display.height;
var.activate = FB_ACTIVATE_NOW;
if (fb_set_var(info, &var) < 0)
/* Couldn't reconfigure, hopefully, can continue as before */ /* Couldn't reconfigure, hopefully, can continue as before */
return; return;
...@@ -1065,7 +1149,7 @@ static void sh_mobile_fb_reconfig(struct fb_info *info) ...@@ -1065,7 +1149,7 @@ static void sh_mobile_fb_reconfig(struct fb_info *info)
* user event, we have to call the chain ourselves. * user event, we have to call the chain ourselves.
*/ */
event.info = info; event.info = info;
event.data = &mode1; event.data = &ch->display.mode;
fb_notifier_call_chain(evnt, &event); fb_notifier_call_chain(evnt, &event);
} }
...@@ -1124,8 +1208,8 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in ...@@ -1124,8 +1208,8 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in
* distance between two modes is defined as the size of the * distance between two modes is defined as the size of the
* non-overlapping parts of the two rectangles. * non-overlapping parts of the two rectangles.
*/ */
for (i = 0; i < ch->cfg.num_cfg; ++i) { for (i = 0; i < ch->cfg->num_modes; ++i) {
const struct fb_videomode *mode = &ch->cfg.lcd_cfg[i]; const struct fb_videomode *mode = &ch->cfg->lcd_modes[i];
unsigned int dist; unsigned int dist;
/* We can only round up. */ /* We can only round up. */
...@@ -1144,7 +1228,7 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in ...@@ -1144,7 +1228,7 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in
} }
/* If no available mode can be used, return an error. */ /* If no available mode can be used, return an error. */
if (ch->cfg.num_cfg != 0) { if (ch->cfg->num_modes != 0) {
if (best_dist == (unsigned int)-1) if (best_dist == (unsigned int)-1)
return -EINVAL; return -EINVAL;
...@@ -1156,37 +1240,22 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in ...@@ -1156,37 +1240,22 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in
* resolution. * resolution.
*/ */
if (var->xres_virtual < var->xres) if (var->xres_virtual < var->xres)
var->xres_virtual = var->xres; var->xres_virtual = var->xres;
if (var->yres_virtual < var->yres) if (var->yres_virtual < var->yres)
var->yres_virtual = var->yres; var->yres_virtual = var->yres;
if (sh_mobile_format_is_fourcc(var)) { if (sh_mobile_format_is_fourcc(var)) {
switch (var->grayscale) { const struct sh_mobile_lcdc_format_info *format;
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV21: format = sh_mobile_format_info(var->grayscale);
var->bits_per_pixel = 12; if (format == NULL)
break;
case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV61:
var->bits_per_pixel = 16;
break;
case V4L2_PIX_FMT_BGR24:
case V4L2_PIX_FMT_NV24:
case V4L2_PIX_FMT_NV42:
var->bits_per_pixel = 24;
break;
case V4L2_PIX_FMT_BGR32:
var->bits_per_pixel = 32;
break;
default:
return -EINVAL; return -EINVAL;
} var->bits_per_pixel = format->bpp;
/* Default to RGB and JPEG color-spaces for RGB and YUV formats /* Default to RGB and JPEG color-spaces for RGB and YUV formats
* respectively. * respectively.
*/ */
if (!sh_mobile_format_is_yuv(var)) if (!format->yuv)
var->colorspace = V4L2_COLORSPACE_SRGB; var->colorspace = V4L2_COLORSPACE_SRGB;
else if (var->colorspace != V4L2_COLORSPACE_REC709) else if (var->colorspace != V4L2_COLORSPACE_REC709)
var->colorspace = V4L2_COLORSPACE_JPEG; var->colorspace = V4L2_COLORSPACE_JPEG;
...@@ -1246,22 +1315,28 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in ...@@ -1246,22 +1315,28 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in
static int sh_mobile_set_par(struct fb_info *info) static int sh_mobile_set_par(struct fb_info *info)
{ {
struct sh_mobile_lcdc_chan *ch = info->par; struct sh_mobile_lcdc_chan *ch = info->par;
u32 line_length = info->fix.line_length;
int ret; int ret;
sh_mobile_lcdc_stop(ch->lcdc); sh_mobile_lcdc_stop(ch->lcdc);
if (sh_mobile_format_is_yuv(&info->var)) ch->format = sh_mobile_format_info(sh_mobile_format_fourcc(&info->var));
info->fix.line_length = info->var.xres; ch->colorspace = info->var.colorspace;
ch->xres = info->var.xres;
ch->xres_virtual = info->var.xres_virtual;
ch->yres = info->var.yres;
ch->yres_virtual = info->var.yres_virtual;
if (ch->format->yuv)
ch->pitch = info->var.xres;
else else
info->fix.line_length = info->var.xres ch->pitch = info->var.xres * ch->format->bpp / 8;
* info->var.bits_per_pixel / 8;
ret = sh_mobile_lcdc_start(ch->lcdc); ret = sh_mobile_lcdc_start(ch->lcdc);
if (ret < 0) { if (ret < 0)
dev_err(info->dev, "%s: unable to restart LCDC\n", __func__); dev_err(info->dev, "%s: unable to restart LCDC\n", __func__);
info->fix.line_length = line_length;
} info->fix.line_length = ch->pitch;
if (sh_mobile_format_is_fourcc(&info->var)) { if (sh_mobile_format_is_fourcc(&info->var)) {
info->fix.type = FB_TYPE_FOURCC; info->fix.type = FB_TYPE_FOURCC;
...@@ -1290,8 +1365,8 @@ static int sh_mobile_lcdc_blank(int blank, struct fb_info *info) ...@@ -1290,8 +1365,8 @@ static int sh_mobile_lcdc_blank(int blank, struct fb_info *info)
/* blank the screen? */ /* blank the screen? */
if (blank > FB_BLANK_UNBLANK && ch->blank_status == FB_BLANK_UNBLANK) { if (blank > FB_BLANK_UNBLANK && ch->blank_status == FB_BLANK_UNBLANK) {
struct fb_fillrect rect = { struct fb_fillrect rect = {
.width = info->var.xres, .width = ch->xres,
.height = info->var.yres, .height = ch->yres,
}; };
sh_mobile_lcdc_fillrect(info, &rect); sh_mobile_lcdc_fillrect(info, &rect);
} }
...@@ -1307,8 +1382,8 @@ static int sh_mobile_lcdc_blank(int blank, struct fb_info *info) ...@@ -1307,8 +1382,8 @@ static int sh_mobile_lcdc_blank(int blank, struct fb_info *info)
* mode will reenable the clocks and update the screen in time, * mode will reenable the clocks and update the screen in time,
* so it does not need this. */ * so it does not need this. */
if (!info->fbdefio) { if (!info->fbdefio) {
sh_mobile_wait_for_vsync(info); sh_mobile_wait_for_vsync(ch);
sh_mobile_wait_for_vsync(info); sh_mobile_wait_for_vsync(ch);
} }
sh_mobile_lcdc_clk_off(p); sh_mobile_lcdc_clk_off(p);
} }
...@@ -1334,25 +1409,161 @@ static struct fb_ops sh_mobile_lcdc_ops = { ...@@ -1334,25 +1409,161 @@ static struct fb_ops sh_mobile_lcdc_ops = {
.fb_set_par = sh_mobile_set_par, .fb_set_par = sh_mobile_set_par,
}; };
static void
sh_mobile_lcdc_channel_fb_unregister(struct sh_mobile_lcdc_chan *ch)
{
if (ch->info && ch->info->dev)
unregister_framebuffer(ch->info);
}
static int __devinit
sh_mobile_lcdc_channel_fb_register(struct sh_mobile_lcdc_chan *ch)
{
struct fb_info *info = ch->info;
int ret;
if (info->fbdefio) {
ch->sglist = vmalloc(sizeof(struct scatterlist) *
ch->fb_size >> PAGE_SHIFT);
if (!ch->sglist) {
dev_err(ch->lcdc->dev, "cannot allocate sglist\n");
return -ENOMEM;
}
}
info->bl_dev = ch->bl;
ret = register_framebuffer(info);
if (ret < 0)
return ret;
dev_info(ch->lcdc->dev, "registered %s/%s as %dx%d %dbpp.\n",
dev_name(ch->lcdc->dev), (ch->cfg->chan == LCDC_CHAN_MAINLCD) ?
"mainlcd" : "sublcd", info->var.xres, info->var.yres,
info->var.bits_per_pixel);
/* deferred io mode: disable clock to save power */
if (info->fbdefio || info->state == FBINFO_STATE_SUSPENDED)
sh_mobile_lcdc_clk_off(ch->lcdc);
return ret;
}
static void
sh_mobile_lcdc_channel_fb_cleanup(struct sh_mobile_lcdc_chan *ch)
{
struct fb_info *info = ch->info;
if (!info || !info->device)
return;
if (ch->sglist)
vfree(ch->sglist);
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
static int __devinit
sh_mobile_lcdc_channel_fb_init(struct sh_mobile_lcdc_chan *ch,
const struct fb_videomode *mode,
unsigned int num_modes)
{
struct sh_mobile_lcdc_priv *priv = ch->lcdc;
struct fb_var_screeninfo *var;
struct fb_info *info;
int ret;
/* Allocate and initialize the frame buffer device. Create the modes
* list and allocate the color map.
*/
info = framebuffer_alloc(0, priv->dev);
if (info == NULL) {
dev_err(priv->dev, "unable to allocate fb_info\n");
return -ENOMEM;
}
ch->info = info;
info->flags = FBINFO_FLAG_DEFAULT;
info->fbops = &sh_mobile_lcdc_ops;
info->device = priv->dev;
info->screen_base = ch->fb_mem;
info->pseudo_palette = &ch->pseudo_palette;
info->par = ch;
fb_videomode_to_modelist(mode, num_modes, &info->modelist);
ret = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0);
if (ret < 0) {
dev_err(priv->dev, "unable to allocate cmap\n");
return ret;
}
/* Initialize fixed screen information. Restrict pan to 2 lines steps
* for NV12 and NV21.
*/
info->fix = sh_mobile_lcdc_fix;
info->fix.smem_start = ch->dma_handle;
info->fix.smem_len = ch->fb_size;
info->fix.line_length = ch->pitch;
if (ch->format->yuv)
info->fix.visual = FB_VISUAL_FOURCC;
else
info->fix.visual = FB_VISUAL_TRUECOLOR;
if (ch->format->fourcc == V4L2_PIX_FMT_NV12 ||
ch->format->fourcc == V4L2_PIX_FMT_NV21)
info->fix.ypanstep = 2;
/* Initialize variable screen information using the first mode as
* default. The default Y virtual resolution is twice the panel size to
* allow for double-buffering.
*/
var = &info->var;
fb_videomode_to_var(var, mode);
var->width = ch->cfg->panel_cfg.width;
var->height = ch->cfg->panel_cfg.height;
var->yres_virtual = var->yres * 2;
var->activate = FB_ACTIVATE_NOW;
/* Use the legacy API by default for RGB formats, and the FOURCC API
* for YUV formats.
*/
if (!ch->format->yuv)
var->bits_per_pixel = ch->format->bpp;
else
var->grayscale = ch->format->fourcc;
ret = sh_mobile_check_var(var, info);
if (ret)
return ret;
return 0;
}
/* -----------------------------------------------------------------------------
* Backlight
*/
static int sh_mobile_lcdc_update_bl(struct backlight_device *bdev) static int sh_mobile_lcdc_update_bl(struct backlight_device *bdev)
{ {
struct sh_mobile_lcdc_chan *ch = bl_get_data(bdev); struct sh_mobile_lcdc_chan *ch = bl_get_data(bdev);
struct sh_mobile_lcdc_board_cfg *cfg = &ch->cfg.board_cfg;
int brightness = bdev->props.brightness; int brightness = bdev->props.brightness;
if (bdev->props.power != FB_BLANK_UNBLANK || if (bdev->props.power != FB_BLANK_UNBLANK ||
bdev->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) bdev->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
brightness = 0; brightness = 0;
return cfg->set_brightness(cfg->board_data, brightness); return ch->cfg->bl_info.set_brightness(brightness);
} }
static int sh_mobile_lcdc_get_brightness(struct backlight_device *bdev) static int sh_mobile_lcdc_get_brightness(struct backlight_device *bdev)
{ {
struct sh_mobile_lcdc_chan *ch = bl_get_data(bdev); struct sh_mobile_lcdc_chan *ch = bl_get_data(bdev);
struct sh_mobile_lcdc_board_cfg *cfg = &ch->cfg.board_cfg;
return cfg->get_brightness(cfg->board_data); return ch->cfg->bl_info.get_brightness();
} }
static int sh_mobile_lcdc_check_fb(struct backlight_device *bdev, static int sh_mobile_lcdc_check_fb(struct backlight_device *bdev,
...@@ -1373,7 +1584,7 @@ static struct backlight_device *sh_mobile_lcdc_bl_probe(struct device *parent, ...@@ -1373,7 +1584,7 @@ static struct backlight_device *sh_mobile_lcdc_bl_probe(struct device *parent,
{ {
struct backlight_device *bl; struct backlight_device *bl;
bl = backlight_device_register(ch->cfg.bl_info.name, parent, ch, bl = backlight_device_register(ch->cfg->bl_info.name, parent, ch,
&sh_mobile_lcdc_bl_ops, NULL); &sh_mobile_lcdc_bl_ops, NULL);
if (IS_ERR(bl)) { if (IS_ERR(bl)) {
dev_err(parent, "unable to register backlight device: %ld\n", dev_err(parent, "unable to register backlight device: %ld\n",
...@@ -1381,7 +1592,7 @@ static struct backlight_device *sh_mobile_lcdc_bl_probe(struct device *parent, ...@@ -1381,7 +1592,7 @@ static struct backlight_device *sh_mobile_lcdc_bl_probe(struct device *parent,
return NULL; return NULL;
} }
bl->props.max_brightness = ch->cfg.bl_info.max_brightness; bl->props.max_brightness = ch->cfg->bl_info.max_brightness;
bl->props.brightness = bl->props.max_brightness; bl->props.brightness = bl->props.max_brightness;
backlight_update_status(bl); backlight_update_status(bl);
...@@ -1393,6 +1604,10 @@ static void sh_mobile_lcdc_bl_remove(struct backlight_device *bdev) ...@@ -1393,6 +1604,10 @@ static void sh_mobile_lcdc_bl_remove(struct backlight_device *bdev)
backlight_device_unregister(bdev); backlight_device_unregister(bdev);
} }
/* -----------------------------------------------------------------------------
* Power management
*/
static int sh_mobile_lcdc_suspend(struct device *dev) static int sh_mobile_lcdc_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
...@@ -1436,6 +1651,10 @@ static const struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = { ...@@ -1436,6 +1651,10 @@ static const struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = {
.runtime_resume = sh_mobile_lcdc_runtime_resume, .runtime_resume = sh_mobile_lcdc_runtime_resume,
}; };
/* -----------------------------------------------------------------------------
* Framebuffer notifier
*/
/* locking: called with info->lock held */ /* locking: called with info->lock held */
static int sh_mobile_lcdc_notify(struct notifier_block *nb, static int sh_mobile_lcdc_notify(struct notifier_block *nb,
unsigned long action, void *data) unsigned long action, void *data)
...@@ -1443,7 +1662,6 @@ static int sh_mobile_lcdc_notify(struct notifier_block *nb, ...@@ -1443,7 +1662,6 @@ static int sh_mobile_lcdc_notify(struct notifier_block *nb,
struct fb_event *event = data; struct fb_event *event = data;
struct fb_info *info = event->info; struct fb_info *info = event->info;
struct sh_mobile_lcdc_chan *ch = info->par; struct sh_mobile_lcdc_chan *ch = info->par;
struct sh_mobile_lcdc_board_cfg *board_cfg = &ch->cfg.board_cfg;
if (&ch->lcdc->notifier != nb) if (&ch->lcdc->notifier != nb)
return NOTIFY_DONE; return NOTIFY_DONE;
...@@ -1453,10 +1671,7 @@ static int sh_mobile_lcdc_notify(struct notifier_block *nb, ...@@ -1453,10 +1671,7 @@ static int sh_mobile_lcdc_notify(struct notifier_block *nb,
switch(action) { switch(action) {
case FB_EVENT_SUSPEND: case FB_EVENT_SUSPEND:
if (board_cfg->display_off && try_module_get(board_cfg->owner)) { sh_mobile_lcdc_display_off(ch);
board_cfg->display_off(board_cfg->board_data);
module_put(board_cfg->owner);
}
sh_mobile_lcdc_stop(ch->lcdc); sh_mobile_lcdc_stop(ch->lcdc);
break; break;
case FB_EVENT_RESUME: case FB_EVENT_RESUME:
...@@ -1464,47 +1679,60 @@ static int sh_mobile_lcdc_notify(struct notifier_block *nb, ...@@ -1464,47 +1679,60 @@ static int sh_mobile_lcdc_notify(struct notifier_block *nb,
sh_mobile_fb_reconfig(info); sh_mobile_fb_reconfig(info);
mutex_unlock(&ch->open_lock); mutex_unlock(&ch->open_lock);
/* HDMI must be enabled before LCDC configuration */ sh_mobile_lcdc_display_on(ch);
if (board_cfg->display_on && try_module_get(board_cfg->owner)) {
board_cfg->display_on(board_cfg->board_data, info);
module_put(board_cfg->owner);
}
sh_mobile_lcdc_start(ch->lcdc); sh_mobile_lcdc_start(ch->lcdc);
} }
return NOTIFY_OK; return NOTIFY_OK;
} }
/* -----------------------------------------------------------------------------
* Probe/remove and driver init/exit
*/
static const struct fb_videomode default_720p __devinitconst = {
.name = "HDMI 720p",
.xres = 1280,
.yres = 720,
.left_margin = 220,
.right_margin = 110,
.hsync_len = 40,
.upper_margin = 20,
.lower_margin = 5,
.vsync_len = 5,
.pixclock = 13468,
.refresh = 60,
.sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
};
static int sh_mobile_lcdc_remove(struct platform_device *pdev) static int sh_mobile_lcdc_remove(struct platform_device *pdev)
{ {
struct sh_mobile_lcdc_priv *priv = platform_get_drvdata(pdev); struct sh_mobile_lcdc_priv *priv = platform_get_drvdata(pdev);
struct fb_info *info;
int i; int i;
fb_unregister_client(&priv->notifier); fb_unregister_client(&priv->notifier);
for (i = 0; i < ARRAY_SIZE(priv->ch); i++) for (i = 0; i < ARRAY_SIZE(priv->ch); i++)
if (priv->ch[i].info && priv->ch[i].info->dev) sh_mobile_lcdc_channel_fb_unregister(&priv->ch[i]);
unregister_framebuffer(priv->ch[i].info);
sh_mobile_lcdc_stop(priv); sh_mobile_lcdc_stop(priv);
for (i = 0; i < ARRAY_SIZE(priv->ch); i++) { for (i = 0; i < ARRAY_SIZE(priv->ch); i++) {
info = priv->ch[i].info; struct sh_mobile_lcdc_chan *ch = &priv->ch[i];
if (!info || !info->device) if (ch->tx_dev) {
continue; ch->tx_dev->lcdc = NULL;
module_put(ch->cfg->tx_dev->dev.driver->owner);
}
if (priv->ch[i].sglist) sh_mobile_lcdc_channel_fb_cleanup(ch);
vfree(priv->ch[i].sglist);
if (info->screen_base) if (ch->fb_mem)
dma_free_coherent(&pdev->dev, info->fix.smem_len, dma_free_coherent(&pdev->dev, ch->fb_size,
info->screen_base, ch->fb_mem, ch->dma_handle);
priv->ch[i].dma_handle);
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
} }
for (i = 0; i < ARRAY_SIZE(priv->ch); i++) { for (i = 0; i < ARRAY_SIZE(priv->ch); i++) {
...@@ -1512,11 +1740,10 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev) ...@@ -1512,11 +1740,10 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev)
sh_mobile_lcdc_bl_remove(priv->ch[i].bl); sh_mobile_lcdc_bl_remove(priv->ch[i].bl);
} }
if (priv->dot_clk) if (priv->dot_clk) {
pm_runtime_disable(&pdev->dev);
clk_put(priv->dot_clk); clk_put(priv->dot_clk);
}
if (priv->dev)
pm_runtime_disable(priv->dev);
if (priv->base) if (priv->base)
iounmap(priv->base); iounmap(priv->base);
...@@ -1527,49 +1754,82 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev) ...@@ -1527,49 +1754,82 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev)
return 0; return 0;
} }
static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch, static int __devinit sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch)
struct device *dev) {
int interface_type = ch->cfg->interface_type;
switch (interface_type) {
case RGB8:
case RGB9:
case RGB12A:
case RGB12B:
case RGB16:
case RGB18:
case RGB24:
case SYS8A:
case SYS8B:
case SYS8C:
case SYS8D:
case SYS9:
case SYS12:
case SYS16A:
case SYS16B:
case SYS16C:
case SYS18:
case SYS24:
break;
default:
return -EINVAL;
}
/* SUBLCD only supports SYS interface */
if (lcdc_chan_is_sublcd(ch)) {
if (!(interface_type & LDMT1R_IFM))
return -EINVAL;
interface_type &= ~LDMT1R_IFM;
}
ch->ldmt1r_value = interface_type;
return 0;
}
static int __devinit
sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_priv *priv,
struct sh_mobile_lcdc_chan *ch)
{ {
struct sh_mobile_lcdc_chan_cfg *cfg = &ch->cfg; const struct sh_mobile_lcdc_format_info *format;
const struct sh_mobile_lcdc_chan_cfg *cfg = ch->cfg;
const struct fb_videomode *max_mode; const struct fb_videomode *max_mode;
const struct fb_videomode *mode; const struct fb_videomode *mode;
struct fb_var_screeninfo *var; unsigned int num_modes;
struct fb_info *info;
unsigned int max_size; unsigned int max_size;
int num_cfg; unsigned int i;
void *buf;
int ret;
int i;
mutex_init(&ch->open_lock); mutex_init(&ch->open_lock);
ch->notify = sh_mobile_lcdc_display_notify;
/* Allocate the frame buffer device. */ /* Validate the format. */
ch->info = framebuffer_alloc(0, dev); format = sh_mobile_format_info(cfg->fourcc);
if (!ch->info) { if (format == NULL) {
dev_err(dev, "unable to allocate fb_info\n"); dev_err(priv->dev, "Invalid FOURCC %08x.\n", cfg->fourcc);
return -ENOMEM; return -EINVAL;
} }
info = ch->info;
info->fbops = &sh_mobile_lcdc_ops;
info->par = ch;
info->pseudo_palette = &ch->pseudo_palette;
info->flags = FBINFO_FLAG_DEFAULT;
/* Iterate through the modes to validate them and find the highest /* Iterate through the modes to validate them and find the highest
* resolution. * resolution.
*/ */
max_mode = NULL; max_mode = NULL;
max_size = 0; max_size = 0;
for (i = 0, mode = cfg->lcd_cfg; i < cfg->num_cfg; i++, mode++) { for (i = 0, mode = cfg->lcd_modes; i < cfg->num_modes; i++, mode++) {
unsigned int size = mode->yres * mode->xres; unsigned int size = mode->yres * mode->xres;
/* NV12/NV21 buffers must have even number of lines */ /* NV12/NV21 buffers must have even number of lines */
if ((cfg->fourcc == V4L2_PIX_FMT_NV12 || if ((cfg->fourcc == V4L2_PIX_FMT_NV12 ||
cfg->fourcc == V4L2_PIX_FMT_NV21) && (mode->yres & 0x1)) { cfg->fourcc == V4L2_PIX_FMT_NV21) && (mode->yres & 0x1)) {
dev_err(dev, "yres must be multiple of 2 for YCbCr420 " dev_err(priv->dev, "yres must be multiple of 2 for "
"mode.\n"); "YCbCr420 mode.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -1582,93 +1842,59 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch, ...@@ -1582,93 +1842,59 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
if (!max_size) if (!max_size)
max_size = MAX_XRES * MAX_YRES; max_size = MAX_XRES * MAX_YRES;
else else
dev_dbg(dev, "Found largest videomode %ux%u\n", dev_dbg(priv->dev, "Found largest videomode %ux%u\n",
max_mode->xres, max_mode->yres); max_mode->xres, max_mode->yres);
/* Create the mode list. */ if (cfg->lcd_modes == NULL) {
if (cfg->lcd_cfg == NULL) {
mode = &default_720p; mode = &default_720p;
num_cfg = 1; num_modes = 1;
} else { } else {
mode = cfg->lcd_cfg; mode = cfg->lcd_modes;
num_cfg = cfg->num_cfg; num_modes = cfg->num_modes;
} }
fb_videomode_to_modelist(mode, num_cfg, &info->modelist); /* Use the first mode as default. */
ch->format = format;
ch->xres = mode->xres;
ch->xres_virtual = mode->xres;
ch->yres = mode->yres;
ch->yres_virtual = mode->yres * 2;
/* Initialize variable screen information using the first mode as if (!format->yuv) {
* default. The default Y virtual resolution is twice the panel size to ch->colorspace = V4L2_COLORSPACE_SRGB;
* allow for double-buffering. ch->pitch = ch->xres * format->bpp / 8;
*/ } else {
var = &info->var; ch->colorspace = V4L2_COLORSPACE_REC709;
fb_videomode_to_var(var, mode); ch->pitch = ch->xres;
var->width = cfg->lcd_size_cfg.width;
var->height = cfg->lcd_size_cfg.height;
var->yres_virtual = var->yres * 2;
var->activate = FB_ACTIVATE_NOW;
switch (cfg->fourcc) {
case V4L2_PIX_FMT_RGB565:
var->bits_per_pixel = 16;
break;
case V4L2_PIX_FMT_BGR24:
var->bits_per_pixel = 24;
break;
case V4L2_PIX_FMT_BGR32:
var->bits_per_pixel = 32;
break;
default:
var->grayscale = cfg->fourcc;
break;
} }
/* Make sure the memory size check won't fail. smem_len is initialized ch->display.width = cfg->panel_cfg.width;
* later based on var. ch->display.height = cfg->panel_cfg.height;
*/ ch->display.mode = *mode;
info->fix.smem_len = UINT_MAX;
ret = sh_mobile_check_var(var, info);
if (ret)
return ret;
max_size = max_size * var->bits_per_pixel / 8 * 2;
/* Allocate frame buffer memory and color map. */ /* Allocate frame buffer memory. */
buf = dma_alloc_coherent(dev, max_size, &ch->dma_handle, GFP_KERNEL); ch->fb_size = max_size * format->bpp / 8 * 2;
if (!buf) { ch->fb_mem = dma_alloc_coherent(priv->dev, ch->fb_size, &ch->dma_handle,
dev_err(dev, "unable to allocate buffer\n"); GFP_KERNEL);
if (ch->fb_mem == NULL) {
dev_err(priv->dev, "unable to allocate buffer\n");
return -ENOMEM; return -ENOMEM;
} }
ret = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0); /* Initialize the transmitter device if present. */
if (ret < 0) { if (cfg->tx_dev) {
dev_err(dev, "unable to allocate cmap\n"); if (!cfg->tx_dev->dev.driver ||
dma_free_coherent(dev, max_size, buf, ch->dma_handle); !try_module_get(cfg->tx_dev->dev.driver->owner)) {
return ret; dev_warn(priv->dev,
"unable to get transmitter device\n");
return -EINVAL;
} }
ch->tx_dev = platform_get_drvdata(cfg->tx_dev);
/* Initialize fixed screen information. Restrict pan to 2 lines steps ch->tx_dev->lcdc = ch;
* for NV12 and NV21. ch->tx_dev->def_mode = *mode;
*/
info->fix = sh_mobile_lcdc_fix;
info->fix.smem_start = ch->dma_handle;
info->fix.smem_len = max_size;
if (cfg->fourcc == V4L2_PIX_FMT_NV12 ||
cfg->fourcc == V4L2_PIX_FMT_NV21)
info->fix.ypanstep = 2;
if (sh_mobile_format_is_yuv(var)) {
info->fix.line_length = var->xres;
info->fix.visual = FB_VISUAL_FOURCC;
} else {
info->fix.line_length = var->xres * var->bits_per_pixel / 8;
info->fix.visual = FB_VISUAL_TRUECOLOR;
} }
info->screen_base = buf; return sh_mobile_lcdc_channel_fb_init(ch, mode, num_modes);
info->device = dev;
ch->display_var = *var;
return 0;
} }
static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev) static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
...@@ -1698,6 +1924,8 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev) ...@@ -1698,6 +1924,8 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
priv->dev = &pdev->dev;
priv->meram_dev = pdata->meram_dev;
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
error = request_irq(i, sh_mobile_lcdc_irq, 0, error = request_irq(i, sh_mobile_lcdc_irq, 0,
...@@ -1714,7 +1942,7 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev) ...@@ -1714,7 +1942,7 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
struct sh_mobile_lcdc_chan *ch = priv->ch + num_channels; struct sh_mobile_lcdc_chan *ch = priv->ch + num_channels;
ch->lcdc = priv; ch->lcdc = priv;
memcpy(&ch->cfg, &pdata->ch[i], sizeof(pdata->ch[i])); ch->cfg = &pdata->ch[i];
error = sh_mobile_lcdc_check_interface(ch); error = sh_mobile_lcdc_check_interface(ch);
if (error) { if (error) {
...@@ -1726,7 +1954,7 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev) ...@@ -1726,7 +1954,7 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
ch->pan_offset = 0; ch->pan_offset = 0;
/* probe the backlight is there is one defined */ /* probe the backlight is there is one defined */
if (ch->cfg.bl_info.max_brightness) if (ch->cfg->bl_info.max_brightness)
ch->bl = sh_mobile_lcdc_bl_probe(&pdev->dev, ch); ch->bl = sh_mobile_lcdc_bl_probe(&pdev->dev, ch);
switch (pdata->ch[i].chan) { switch (pdata->ch[i].chan) {
...@@ -1757,18 +1985,19 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev) ...@@ -1757,18 +1985,19 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
if (!priv->base) if (!priv->base)
goto err1; goto err1;
error = sh_mobile_lcdc_setup_clocks(pdev, pdata->clock_source, priv); error = sh_mobile_lcdc_setup_clocks(priv, pdata->clock_source);
if (error) { if (error) {
dev_err(&pdev->dev, "unable to setup clocks\n"); dev_err(&pdev->dev, "unable to setup clocks\n");
goto err1; goto err1;
} }
priv->meram_dev = pdata->meram_dev; /* Enable runtime PM. */
pm_runtime_enable(&pdev->dev);
for (i = 0; i < num_channels; i++) { for (i = 0; i < num_channels; i++) {
struct sh_mobile_lcdc_chan *ch = priv->ch + i; struct sh_mobile_lcdc_chan *ch = priv->ch + i;
error = sh_mobile_lcdc_channel_init(ch, &pdev->dev); error = sh_mobile_lcdc_channel_init(priv, ch);
if (error) if (error)
goto err1; goto err1;
} }
...@@ -1781,31 +2010,10 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev) ...@@ -1781,31 +2010,10 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
for (i = 0; i < num_channels; i++) { for (i = 0; i < num_channels; i++) {
struct sh_mobile_lcdc_chan *ch = priv->ch + i; struct sh_mobile_lcdc_chan *ch = priv->ch + i;
struct fb_info *info = ch->info;
if (info->fbdefio) {
ch->sglist = vmalloc(sizeof(struct scatterlist) *
info->fix.smem_len >> PAGE_SHIFT);
if (!ch->sglist) {
dev_err(&pdev->dev, "cannot allocate sglist\n");
goto err1;
}
}
info->bl_dev = ch->bl;
error = register_framebuffer(info); error = sh_mobile_lcdc_channel_fb_register(ch);
if (error < 0) if (error)
goto err1; goto err1;
dev_info(info->dev, "registered %s/%s as %dx%d %dbpp.\n",
pdev->name, (ch->cfg.chan == LCDC_CHAN_MAINLCD) ?
"mainlcd" : "sublcd", info->var.xres, info->var.yres,
info->var.bits_per_pixel);
/* deferred io mode: disable clock to save power */
if (info->fbdefio || info->state == FBINFO_STATE_SUSPENDED)
sh_mobile_lcdc_clk_off(priv);
} }
/* Failure ignored */ /* Failure ignored */
......
...@@ -14,9 +14,35 @@ enum { LDDCKPAT1R, LDDCKPAT2R, LDMT1R, LDMT2R, LDMT3R, LDDFR, LDSM1R, ...@@ -14,9 +14,35 @@ enum { LDDCKPAT1R, LDDCKPAT2R, LDMT1R, LDMT2R, LDMT3R, LDDFR, LDSM1R,
#define PALETTE_NR 16 #define PALETTE_NR 16
struct sh_mobile_lcdc_priv;
struct fb_info;
struct backlight_device; struct backlight_device;
struct fb_info;
struct module;
struct sh_mobile_lcdc_chan;
struct sh_mobile_lcdc_entity;
struct sh_mobile_lcdc_format_info;
struct sh_mobile_lcdc_priv;
#define SH_MOBILE_LCDC_DISPLAY_DISCONNECTED 0
#define SH_MOBILE_LCDC_DISPLAY_CONNECTED 1
struct sh_mobile_lcdc_entity_ops {
/* Display */
int (*display_on)(struct sh_mobile_lcdc_entity *entity);
void (*display_off)(struct sh_mobile_lcdc_entity *entity);
};
enum sh_mobile_lcdc_entity_event {
SH_MOBILE_LCDC_EVENT_DISPLAY_CONNECT,
SH_MOBILE_LCDC_EVENT_DISPLAY_DISCONNECT,
SH_MOBILE_LCDC_EVENT_DISPLAY_MODE,
};
struct sh_mobile_lcdc_entity {
struct module *owner;
const struct sh_mobile_lcdc_entity_ops *ops;
struct sh_mobile_lcdc_chan *lcdc;
struct fb_videomode def_mode;
};
/* /*
* struct sh_mobile_lcdc_chan - LCDC display channel * struct sh_mobile_lcdc_chan - LCDC display channel
...@@ -27,29 +53,57 @@ struct backlight_device; ...@@ -27,29 +53,57 @@ struct backlight_device;
*/ */
struct sh_mobile_lcdc_chan { struct sh_mobile_lcdc_chan {
struct sh_mobile_lcdc_priv *lcdc; struct sh_mobile_lcdc_priv *lcdc;
struct sh_mobile_lcdc_entity *tx_dev;
const struct sh_mobile_lcdc_chan_cfg *cfg;
unsigned long *reg_offs; unsigned long *reg_offs;
unsigned long ldmt1r_value; unsigned long ldmt1r_value;
unsigned long enabled; /* ME and SE in LDCNT2R */ unsigned long enabled; /* ME and SE in LDCNT2R */
struct sh_mobile_lcdc_chan_cfg cfg; void *meram;
u32 pseudo_palette[PALETTE_NR];
struct fb_info *info; struct mutex open_lock; /* protects the use counter */
struct backlight_device *bl; int use_count;
void *fb_mem;
unsigned long fb_size;
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct fb_deferred_io defio;
struct scatterlist *sglist;
unsigned long frame_end;
unsigned long pan_offset; unsigned long pan_offset;
unsigned long frame_end;
wait_queue_head_t frame_end_wait; wait_queue_head_t frame_end_wait;
struct completion vsync_completion; struct completion vsync_completion;
struct fb_var_screeninfo display_var;
int use_count; const struct sh_mobile_lcdc_format_info *format;
int blank_status; u32 colorspace;
struct mutex open_lock; /* protects the use counter */ unsigned int xres;
int meram_enabled; unsigned int xres_virtual;
unsigned int yres;
unsigned int yres_virtual;
unsigned int pitch;
unsigned long base_addr_y; unsigned long base_addr_y;
unsigned long base_addr_c; unsigned long base_addr_c;
unsigned int pitch;
int (*notify)(struct sh_mobile_lcdc_chan *ch,
enum sh_mobile_lcdc_entity_event event,
const struct fb_videomode *mode,
const struct fb_monspecs *monspec);
/* Backlight */
struct backlight_device *bl;
/* FB */
struct fb_info *info;
u32 pseudo_palette[PALETTE_NR];
struct {
unsigned int width;
unsigned int height;
struct fb_videomode mode;
} display;
struct fb_deferred_io defio;
struct scatterlist *sglist;
int blank_status;
}; };
#endif #endif
...@@ -9,16 +9,22 @@ ...@@ -9,16 +9,22 @@
* for more details. * for more details.
*/ */
#include <linux/device.h>
#include <linux/err.h>
#include <linux/genalloc.h>
#include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/platform_device.h>
#include <video/sh_mobile_meram.h> #include <video/sh_mobile_meram.h>
/* meram registers */ /* -----------------------------------------------------------------------------
* MERAM registers
*/
#define MEVCR1 0x4 #define MEVCR1 0x4
#define MEVCR1_RST (1 << 31) #define MEVCR1_RST (1 << 31)
#define MEVCR1_WD (1 << 30) #define MEVCR1_WD (1 << 30)
...@@ -81,16 +87,14 @@ ...@@ -81,16 +87,14 @@
((yszm1) << MExxBSIZE_YSZM1_SHIFT) | \ ((yszm1) << MExxBSIZE_YSZM1_SHIFT) | \
((xszm1) << MExxBSIZE_XSZM1_SHIFT)) ((xszm1) << MExxBSIZE_XSZM1_SHIFT))
#define SH_MOBILE_MERAM_ICB_NUM 32 static const unsigned long common_regs[] = {
static unsigned long common_regs[] = {
MEVCR1, MEVCR1,
MEQSEL1, MEQSEL1,
MEQSEL2, MEQSEL2,
}; };
#define CMN_REGS_SIZE ARRAY_SIZE(common_regs) #define MERAM_REGS_SIZE ARRAY_SIZE(common_regs)
static unsigned long icb_regs[] = { static const unsigned long icb_regs[] = {
MExxCTL, MExxCTL,
MExxBSIZE, MExxBSIZE,
MExxMNCF, MExxMNCF,
...@@ -100,216 +104,269 @@ static unsigned long icb_regs[] = { ...@@ -100,216 +104,269 @@ static unsigned long icb_regs[] = {
}; };
#define ICB_REGS_SIZE ARRAY_SIZE(icb_regs) #define ICB_REGS_SIZE ARRAY_SIZE(icb_regs)
/*
* sh_mobile_meram_icb - MERAM ICB information
* @regs: Registers cache
* @index: ICB index
* @offset: MERAM block offset
* @size: MERAM block size in KiB
* @cache_unit: Bytes to cache per ICB
* @pixelformat: Video pixel format of the data stored in the ICB
* @current_reg: Which of Start Address Register A (0) or B (1) is in use
*/
struct sh_mobile_meram_icb {
unsigned long regs[ICB_REGS_SIZE];
unsigned int index;
unsigned long offset;
unsigned int size;
unsigned int cache_unit;
unsigned int pixelformat;
unsigned int current_reg;
};
#define MERAM_ICB_NUM 32
struct sh_mobile_meram_fb_plane {
struct sh_mobile_meram_icb *marker;
struct sh_mobile_meram_icb *cache;
};
struct sh_mobile_meram_fb_cache {
unsigned int nplanes;
struct sh_mobile_meram_fb_plane planes[2];
};
/*
* sh_mobile_meram_priv - MERAM device
* @base: Registers base address
* @meram: MERAM physical address
* @regs: Registers cache
* @lock: Protects used_icb and icbs
* @used_icb: Bitmask of used ICBs
* @icbs: ICBs
* @pool: Allocation pool to manage the MERAM
*/
struct sh_mobile_meram_priv { struct sh_mobile_meram_priv {
void __iomem *base; void __iomem *base;
unsigned long meram;
unsigned long regs[MERAM_REGS_SIZE];
struct mutex lock; struct mutex lock;
unsigned long used_icb; unsigned long used_icb;
int used_meram_cache_regions; struct sh_mobile_meram_icb icbs[MERAM_ICB_NUM];
unsigned long used_meram_cache[SH_MOBILE_MERAM_ICB_NUM];
unsigned long cmn_saved_regs[CMN_REGS_SIZE]; struct gen_pool *pool;
unsigned long icb_saved_regs[ICB_REGS_SIZE * SH_MOBILE_MERAM_ICB_NUM];
}; };
/* settings */ /* settings */
#define MERAM_GRANULARITY 1024
#define MERAM_SEC_LINE 15 #define MERAM_SEC_LINE 15
#define MERAM_LINE_WIDTH 2048 #define MERAM_LINE_WIDTH 2048
/* /* -----------------------------------------------------------------------------
* MERAM/ICB access functions * Registers access
*/ */
#define MERAM_ICB_OFFSET(base, idx, off) ((base) + (off) + (idx) * 0x20) #define MERAM_ICB_OFFSET(base, idx, off) ((base) + (off) + (idx) * 0x20)
static inline void meram_write_icb(void __iomem *base, int idx, int off, static inline void meram_write_icb(void __iomem *base, unsigned int idx,
unsigned long val) unsigned int off, unsigned long val)
{ {
iowrite32(val, MERAM_ICB_OFFSET(base, idx, off)); iowrite32(val, MERAM_ICB_OFFSET(base, idx, off));
} }
static inline unsigned long meram_read_icb(void __iomem *base, int idx, int off) static inline unsigned long meram_read_icb(void __iomem *base, unsigned int idx,
unsigned int off)
{ {
return ioread32(MERAM_ICB_OFFSET(base, idx, off)); return ioread32(MERAM_ICB_OFFSET(base, idx, off));
} }
static inline void meram_write_reg(void __iomem *base, int off, static inline void meram_write_reg(void __iomem *base, unsigned int off,
unsigned long val) unsigned long val)
{ {
iowrite32(val, base + off); iowrite32(val, base + off);
} }
static inline unsigned long meram_read_reg(void __iomem *base, int off) static inline unsigned long meram_read_reg(void __iomem *base, unsigned int off)
{ {
return ioread32(base + off); return ioread32(base + off);
} }
/* /* -----------------------------------------------------------------------------
* register ICB * Allocation
*/
#define MERAM_CACHE_START(p) ((p) >> 16)
#define MERAM_CACHE_END(p) ((p) & 0xffff)
#define MERAM_CACHE_SET(o, s) ((((o) & 0xffff) << 16) | \
(((o) + (s) - 1) & 0xffff))
/*
* check if there's no overlaps in MERAM allocation.
*/ */
static inline int meram_check_overlap(struct sh_mobile_meram_priv *priv, /* Allocate ICBs and MERAM for a plane. */
struct sh_mobile_meram_icb *new) static int __meram_alloc(struct sh_mobile_meram_priv *priv,
struct sh_mobile_meram_fb_plane *plane,
size_t size)
{ {
int i; unsigned long mem;
int used_start, used_end, meram_start, meram_end; unsigned long idx;
/* valid ICB? */ idx = find_first_zero_bit(&priv->used_icb, 28);
if (new->marker_icb & ~0x1f || new->cache_icb & ~0x1f) if (idx == 28)
return 1; return -ENOMEM;
plane->cache = &priv->icbs[idx];
if (test_bit(new->marker_icb, &priv->used_icb) || idx = find_next_zero_bit(&priv->used_icb, 32, 28);
test_bit(new->cache_icb, &priv->used_icb)) if (idx == 32)
return 1; return -ENOMEM;
plane->marker = &priv->icbs[idx];
for (i = 0; i < priv->used_meram_cache_regions; i++) { mem = gen_pool_alloc(priv->pool, size * 1024);
used_start = MERAM_CACHE_START(priv->used_meram_cache[i]); if (mem == 0)
used_end = MERAM_CACHE_END(priv->used_meram_cache[i]); return -ENOMEM;
meram_start = new->meram_offset;
meram_end = new->meram_offset + new->meram_size;
if ((meram_start >= used_start && meram_start < used_end) || __set_bit(plane->marker->index, &priv->used_icb);
(meram_end > used_start && meram_end < used_end)) __set_bit(plane->cache->index, &priv->used_icb);
return 1;
} plane->marker->offset = mem - priv->meram;
plane->marker->size = size;
return 0; return 0;
} }
/* /* Free ICBs and MERAM for a plane. */
* mark the specified ICB as used static void __meram_free(struct sh_mobile_meram_priv *priv,
*/ struct sh_mobile_meram_fb_plane *plane)
{
gen_pool_free(priv->pool, priv->meram + plane->marker->offset,
plane->marker->size * 1024);
static inline void meram_mark(struct sh_mobile_meram_priv *priv, __clear_bit(plane->marker->index, &priv->used_icb);
struct sh_mobile_meram_icb *new) __clear_bit(plane->cache->index, &priv->used_icb);
}
/* Is this a YCbCr(NV12, NV16 or NV24) colorspace? */
static int is_nvcolor(int cspace)
{ {
int n; if (cspace == SH_MOBILE_MERAM_PF_NV ||
cspace == SH_MOBILE_MERAM_PF_NV24)
return 1;
return 0;
}
if (new->marker_icb < 0 || new->cache_icb < 0) /* Allocate memory for the ICBs and mark them as used. */
return; static struct sh_mobile_meram_fb_cache *
meram_alloc(struct sh_mobile_meram_priv *priv,
const struct sh_mobile_meram_cfg *cfg,
int pixelformat)
{
struct sh_mobile_meram_fb_cache *cache;
unsigned int nplanes = is_nvcolor(pixelformat) ? 2 : 1;
int ret;
__set_bit(new->marker_icb, &priv->used_icb); if (cfg->icb[0].meram_size == 0)
__set_bit(new->cache_icb, &priv->used_icb); return ERR_PTR(-EINVAL);
n = priv->used_meram_cache_regions; if (nplanes == 2 && cfg->icb[1].meram_size == 0)
return ERR_PTR(-EINVAL);
priv->used_meram_cache[n] = MERAM_CACHE_SET(new->meram_offset, cache = kzalloc(sizeof(*cache), GFP_KERNEL);
new->meram_size); if (cache == NULL)
return ERR_PTR(-ENOMEM);
priv->used_meram_cache_regions++; cache->nplanes = nplanes;
}
/* ret = __meram_alloc(priv, &cache->planes[0], cfg->icb[0].meram_size);
* unmark the specified ICB as used if (ret < 0)
*/ goto error;
static inline void meram_unmark(struct sh_mobile_meram_priv *priv, cache->planes[0].marker->current_reg = 1;
struct sh_mobile_meram_icb *icb) cache->planes[0].marker->pixelformat = pixelformat;
{
int i; if (cache->nplanes == 1)
unsigned long pattern; return cache;
if (icb->marker_icb < 0 || icb->cache_icb < 0) ret = __meram_alloc(priv, &cache->planes[1], cfg->icb[1].meram_size);
return; if (ret < 0) {
__meram_free(priv, &cache->planes[0]);
__clear_bit(icb->marker_icb, &priv->used_icb); goto error;
__clear_bit(icb->cache_icb, &priv->used_icb);
pattern = MERAM_CACHE_SET(icb->meram_offset, icb->meram_size);
for (i = 0; i < priv->used_meram_cache_regions; i++) {
if (priv->used_meram_cache[i] == pattern) {
while (i < priv->used_meram_cache_regions - 1) {
priv->used_meram_cache[i] =
priv->used_meram_cache[i + 1] ;
i++;
}
priv->used_meram_cache[i] = 0;
priv->used_meram_cache_regions--;
break;
}
} }
return cache;
error:
kfree(cache);
return ERR_PTR(-ENOMEM);
} }
/* /* Unmark the specified ICB as used. */
* is this a YCbCr(NV12, NV16 or NV24) colorspace static void meram_free(struct sh_mobile_meram_priv *priv,
*/ struct sh_mobile_meram_fb_cache *cache)
static inline int is_nvcolor(int cspace)
{ {
if (cspace == SH_MOBILE_MERAM_PF_NV || __meram_free(priv, &cache->planes[0]);
cspace == SH_MOBILE_MERAM_PF_NV24) if (cache->nplanes == 2)
return 1; __meram_free(priv, &cache->planes[1]);
return 0;
kfree(cache);
} }
/* /* Set the next address to fetch. */
* set the next address to fetch static void meram_set_next_addr(struct sh_mobile_meram_priv *priv,
*/ struct sh_mobile_meram_fb_cache *cache,
static inline void meram_set_next_addr(struct sh_mobile_meram_priv *priv,
struct sh_mobile_meram_cfg *cfg,
unsigned long base_addr_y, unsigned long base_addr_y,
unsigned long base_addr_c) unsigned long base_addr_c)
{ {
struct sh_mobile_meram_icb *icb = cache->planes[0].marker;
unsigned long target; unsigned long target;
target = (cfg->current_reg) ? MExxSARA : MExxSARB; icb->current_reg ^= 1;
cfg->current_reg ^= 1; target = icb->current_reg ? MExxSARB : MExxSARA;
/* set the next address to fetch */ /* set the next address to fetch */
meram_write_icb(priv->base, cfg->icb[0].cache_icb, target, meram_write_icb(priv->base, cache->planes[0].cache->index, target,
base_addr_y); base_addr_y);
meram_write_icb(priv->base, cfg->icb[0].marker_icb, target, meram_write_icb(priv->base, cache->planes[0].marker->index, target,
base_addr_y + cfg->icb[0].cache_unit); base_addr_y + cache->planes[0].marker->cache_unit);
if (is_nvcolor(cfg->pixelformat)) { if (cache->nplanes == 2) {
meram_write_icb(priv->base, cfg->icb[1].cache_icb, target, meram_write_icb(priv->base, cache->planes[1].cache->index,
base_addr_c); target, base_addr_c);
meram_write_icb(priv->base, cfg->icb[1].marker_icb, target, meram_write_icb(priv->base, cache->planes[1].marker->index,
base_addr_c + cfg->icb[1].cache_unit); target, base_addr_c +
cache->planes[1].marker->cache_unit);
} }
} }
/* /* Get the next ICB address. */
* get the next ICB address static void
*/ meram_get_next_icb_addr(struct sh_mobile_meram_info *pdata,
static inline void meram_get_next_icb_addr(struct sh_mobile_meram_info *pdata, struct sh_mobile_meram_fb_cache *cache,
struct sh_mobile_meram_cfg *cfg, unsigned long *icb_addr_y, unsigned long *icb_addr_c)
unsigned long *icb_addr_y,
unsigned long *icb_addr_c)
{ {
struct sh_mobile_meram_icb *icb = cache->planes[0].marker;
unsigned long icb_offset; unsigned long icb_offset;
if (pdata->addr_mode == SH_MOBILE_MERAM_MODE0) if (pdata->addr_mode == SH_MOBILE_MERAM_MODE0)
icb_offset = 0x80000000 | (cfg->current_reg << 29); icb_offset = 0x80000000 | (icb->current_reg << 29);
else else
icb_offset = 0xc0000000 | (cfg->current_reg << 23); icb_offset = 0xc0000000 | (icb->current_reg << 23);
*icb_addr_y = icb_offset | (cfg->icb[0].marker_icb << 24); *icb_addr_y = icb_offset | (cache->planes[0].marker->index << 24);
if (is_nvcolor(cfg->pixelformat)) if (cache->nplanes == 2)
*icb_addr_c = icb_offset | (cfg->icb[1].marker_icb << 24); *icb_addr_c = icb_offset
| (cache->planes[1].marker->index << 24);
} }
#define MERAM_CALC_BYTECOUNT(x, y) \ #define MERAM_CALC_BYTECOUNT(x, y) \
(((x) * (y) + (MERAM_LINE_WIDTH - 1)) & ~(MERAM_LINE_WIDTH - 1)) (((x) * (y) + (MERAM_LINE_WIDTH - 1)) & ~(MERAM_LINE_WIDTH - 1))
/* /* Initialize MERAM. */
* initialize MERAM
*/
static int meram_init(struct sh_mobile_meram_priv *priv, static int meram_init(struct sh_mobile_meram_priv *priv,
struct sh_mobile_meram_icb *icb, struct sh_mobile_meram_fb_plane *plane,
int xres, int yres, int *out_pitch) unsigned int xres, unsigned int yres,
unsigned int *out_pitch)
{ {
struct sh_mobile_meram_icb *marker = plane->marker;
unsigned long total_byte_count = MERAM_CALC_BYTECOUNT(xres, yres); unsigned long total_byte_count = MERAM_CALC_BYTECOUNT(xres, yres);
unsigned long bnm; unsigned long bnm;
int lcdc_pitch, xpitch, line_cnt; unsigned int lcdc_pitch;
int save_lines; unsigned int xpitch;
unsigned int line_cnt;
unsigned int save_lines;
/* adjust pitch to 1024, 2048, 4096 or 8192 */ /* adjust pitch to 1024, 2048, 4096 or 8192 */
lcdc_pitch = (xres - 1) | 1023; lcdc_pitch = (xres - 1) | 1023;
...@@ -322,13 +379,13 @@ static int meram_init(struct sh_mobile_meram_priv *priv, ...@@ -322,13 +379,13 @@ static int meram_init(struct sh_mobile_meram_priv *priv,
lcdc_pitch = xpitch = MERAM_LINE_WIDTH; lcdc_pitch = xpitch = MERAM_LINE_WIDTH;
line_cnt = total_byte_count >> 11; line_cnt = total_byte_count >> 11;
*out_pitch = xres; *out_pitch = xres;
save_lines = (icb->meram_size / 16 / MERAM_SEC_LINE); save_lines = plane->marker->size / 16 / MERAM_SEC_LINE;
save_lines *= MERAM_SEC_LINE; save_lines *= MERAM_SEC_LINE;
} else { } else {
xpitch = xres; xpitch = xres;
line_cnt = yres; line_cnt = yres;
*out_pitch = lcdc_pitch; *out_pitch = lcdc_pitch;
save_lines = icb->meram_size / (lcdc_pitch >> 10) / 2; save_lines = plane->marker->size / (lcdc_pitch >> 10) / 2;
save_lines &= 0xff; save_lines &= 0xff;
} }
bnm = (save_lines - 1) << 16; bnm = (save_lines - 1) << 16;
...@@ -336,19 +393,20 @@ static int meram_init(struct sh_mobile_meram_priv *priv, ...@@ -336,19 +393,20 @@ static int meram_init(struct sh_mobile_meram_priv *priv,
/* TODO: we better to check if we have enough MERAM buffer size */ /* TODO: we better to check if we have enough MERAM buffer size */
/* set up ICB */ /* set up ICB */
meram_write_icb(priv->base, icb->cache_icb, MExxBSIZE, meram_write_icb(priv->base, plane->cache->index, MExxBSIZE,
MERAM_MExxBSIZE_VAL(0x0, line_cnt - 1, xpitch - 1)); MERAM_MExxBSIZE_VAL(0x0, line_cnt - 1, xpitch - 1));
meram_write_icb(priv->base, icb->marker_icb, MExxBSIZE, meram_write_icb(priv->base, plane->marker->index, MExxBSIZE,
MERAM_MExxBSIZE_VAL(0xf, line_cnt - 1, xpitch - 1)); MERAM_MExxBSIZE_VAL(0xf, line_cnt - 1, xpitch - 1));
meram_write_icb(priv->base, icb->cache_icb, MExxMNCF, bnm); meram_write_icb(priv->base, plane->cache->index, MExxMNCF, bnm);
meram_write_icb(priv->base, icb->marker_icb, MExxMNCF, bnm); meram_write_icb(priv->base, plane->marker->index, MExxMNCF, bnm);
meram_write_icb(priv->base, icb->cache_icb, MExxSBSIZE, xpitch); meram_write_icb(priv->base, plane->cache->index, MExxSBSIZE, xpitch);
meram_write_icb(priv->base, icb->marker_icb, MExxSBSIZE, xpitch); meram_write_icb(priv->base, plane->marker->index, MExxSBSIZE, xpitch);
/* save a cache unit size */ /* save a cache unit size */
icb->cache_unit = xres * save_lines; plane->cache->cache_unit = xres * save_lines;
plane->marker->cache_unit = xres * save_lines;
/* /*
* Set MERAM for framebuffer * Set MERAM for framebuffer
...@@ -356,13 +414,13 @@ static int meram_init(struct sh_mobile_meram_priv *priv, ...@@ -356,13 +414,13 @@ static int meram_init(struct sh_mobile_meram_priv *priv,
* we also chain the cache_icb and the marker_icb. * we also chain the cache_icb and the marker_icb.
* we also split the allocated MERAM buffer between two ICBs. * we also split the allocated MERAM buffer between two ICBs.
*/ */
meram_write_icb(priv->base, icb->cache_icb, MExxCTL, meram_write_icb(priv->base, plane->cache->index, MExxCTL,
MERAM_MExxCTL_VAL(icb->marker_icb, icb->meram_offset) | MERAM_MExxCTL_VAL(plane->marker->index, marker->offset)
MExxCTL_WD1 | MExxCTL_WD0 | MExxCTL_WS | MExxCTL_CM | | MExxCTL_WD1 | MExxCTL_WD0 | MExxCTL_WS | MExxCTL_CM |
MExxCTL_MD_FB); MExxCTL_MD_FB);
meram_write_icb(priv->base, icb->marker_icb, MExxCTL, meram_write_icb(priv->base, plane->marker->index, MExxCTL,
MERAM_MExxCTL_VAL(icb->cache_icb, icb->meram_offset + MERAM_MExxCTL_VAL(plane->cache->index, marker->offset +
icb->meram_size / 2) | plane->marker->size / 2) |
MExxCTL_WD1 | MExxCTL_WD0 | MExxCTL_WS | MExxCTL_CM | MExxCTL_WD1 | MExxCTL_WD0 | MExxCTL_WS | MExxCTL_CM |
MExxCTL_MD_FB); MExxCTL_MD_FB);
...@@ -370,239 +428,175 @@ static int meram_init(struct sh_mobile_meram_priv *priv, ...@@ -370,239 +428,175 @@ static int meram_init(struct sh_mobile_meram_priv *priv,
} }
static void meram_deinit(struct sh_mobile_meram_priv *priv, static void meram_deinit(struct sh_mobile_meram_priv *priv,
struct sh_mobile_meram_icb *icb) struct sh_mobile_meram_fb_plane *plane)
{ {
/* disable ICB */ /* disable ICB */
meram_write_icb(priv->base, icb->cache_icb, MExxCTL, meram_write_icb(priv->base, plane->cache->index, MExxCTL,
MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF); MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF);
meram_write_icb(priv->base, icb->marker_icb, MExxCTL, meram_write_icb(priv->base, plane->marker->index, MExxCTL,
MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF); MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF);
icb->cache_unit = 0;
plane->cache->cache_unit = 0;
plane->marker->cache_unit = 0;
} }
/* /* -----------------------------------------------------------------------------
* register the ICB * Registration/unregistration
*/ */
static int sh_mobile_meram_register(struct sh_mobile_meram_info *pdata, static void *sh_mobile_meram_register(struct sh_mobile_meram_info *pdata,
struct sh_mobile_meram_cfg *cfg, const struct sh_mobile_meram_cfg *cfg,
int xres, int yres, int pixelformat, unsigned int xres, unsigned int yres,
unsigned long base_addr_y, unsigned int pixelformat,
unsigned long base_addr_c, unsigned int *pitch)
unsigned long *icb_addr_y,
unsigned long *icb_addr_c,
int *pitch)
{ {
struct platform_device *pdev; struct sh_mobile_meram_fb_cache *cache;
struct sh_mobile_meram_priv *priv; struct sh_mobile_meram_priv *priv = pdata->priv;
int n, out_pitch; struct platform_device *pdev = pdata->pdev;
int error = 0; unsigned int out_pitch;
if (!pdata || !pdata->priv || !pdata->pdev || !cfg)
return -EINVAL;
if (pixelformat != SH_MOBILE_MERAM_PF_NV && if (pixelformat != SH_MOBILE_MERAM_PF_NV &&
pixelformat != SH_MOBILE_MERAM_PF_NV24 && pixelformat != SH_MOBILE_MERAM_PF_NV24 &&
pixelformat != SH_MOBILE_MERAM_PF_RGB) pixelformat != SH_MOBILE_MERAM_PF_RGB)
return -EINVAL; return ERR_PTR(-EINVAL);
priv = pdata->priv; dev_dbg(&pdev->dev, "registering %dx%d (%s)", xres, yres,
pdev = pdata->pdev; !pixelformat ? "yuv" : "rgb");
dev_dbg(&pdev->dev, "registering %dx%d (%s) (y=%08lx, c=%08lx)",
xres, yres, (!pixelformat) ? "yuv" : "rgb",
base_addr_y, base_addr_c);
/* we can't handle wider than 8192px */ /* we can't handle wider than 8192px */
if (xres > 8192) { if (xres > 8192) {
dev_err(&pdev->dev, "width exceeding the limit (> 8192)."); dev_err(&pdev->dev, "width exceeding the limit (> 8192).");
return -EINVAL; return ERR_PTR(-EINVAL);
}
/* do we have at least one ICB config? */
if (cfg->icb[0].marker_icb < 0 || cfg->icb[0].cache_icb < 0) {
dev_err(&pdev->dev, "at least one ICB is required.");
return -EINVAL;
} }
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
if (priv->used_meram_cache_regions + 2 > SH_MOBILE_MERAM_ICB_NUM) { /* We now register the ICBs and allocate the MERAM regions. */
dev_err(&pdev->dev, "no more ICB available."); cache = meram_alloc(priv, cfg, pixelformat);
error = -EINVAL; if (IS_ERR(cache)) {
goto err; dev_err(&pdev->dev, "MERAM allocation failed (%ld).",
} PTR_ERR(cache));
/* make sure that there's no overlaps */
if (meram_check_overlap(priv, &cfg->icb[0])) {
dev_err(&pdev->dev, "conflicting config detected.");
error = -EINVAL;
goto err;
}
n = 1;
/* do the same if we have the second ICB set */
if (cfg->icb[1].marker_icb >= 0 && cfg->icb[1].cache_icb >= 0) {
if (meram_check_overlap(priv, &cfg->icb[1])) {
dev_err(&pdev->dev, "conflicting config detected.");
error = -EINVAL;
goto err;
}
n = 2;
}
if (is_nvcolor(pixelformat) && n != 2) {
dev_err(&pdev->dev, "requires two ICB sets for planar Y/C.");
error = -EINVAL;
goto err; goto err;
} }
/* we now register the ICB */
cfg->pixelformat = pixelformat;
meram_mark(priv, &cfg->icb[0]);
if (is_nvcolor(pixelformat))
meram_mark(priv, &cfg->icb[1]);
/* initialize MERAM */ /* initialize MERAM */
meram_init(priv, &cfg->icb[0], xres, yres, &out_pitch); meram_init(priv, &cache->planes[0], xres, yres, &out_pitch);
*pitch = out_pitch; *pitch = out_pitch;
if (pixelformat == SH_MOBILE_MERAM_PF_NV) if (pixelformat == SH_MOBILE_MERAM_PF_NV)
meram_init(priv, &cfg->icb[1], xres, (yres + 1) / 2, meram_init(priv, &cache->planes[1], xres, (yres + 1) / 2,
&out_pitch); &out_pitch);
else if (pixelformat == SH_MOBILE_MERAM_PF_NV24) else if (pixelformat == SH_MOBILE_MERAM_PF_NV24)
meram_init(priv, &cfg->icb[1], 2 * xres, (yres + 1) / 2, meram_init(priv, &cache->planes[1], 2 * xres, (yres + 1) / 2,
&out_pitch); &out_pitch);
cfg->current_reg = 1;
meram_set_next_addr(priv, cfg, base_addr_y, base_addr_c);
meram_get_next_icb_addr(pdata, cfg, icb_addr_y, icb_addr_c);
dev_dbg(&pdev->dev, "registered - can access via y=%08lx, c=%08lx",
*icb_addr_y, *icb_addr_c);
err: err:
mutex_unlock(&priv->lock); mutex_unlock(&priv->lock);
return error; return cache;
} }
static int sh_mobile_meram_unregister(struct sh_mobile_meram_info *pdata, static void
struct sh_mobile_meram_cfg *cfg) sh_mobile_meram_unregister(struct sh_mobile_meram_info *pdata, void *data)
{ {
struct sh_mobile_meram_priv *priv; struct sh_mobile_meram_fb_cache *cache = data;
struct sh_mobile_meram_priv *priv = pdata->priv;
if (!pdata || !pdata->priv || !cfg)
return -EINVAL;
priv = pdata->priv;
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
/* deinit & unmark */ /* deinit & free */
if (is_nvcolor(cfg->pixelformat)) { meram_deinit(priv, &cache->planes[0]);
meram_deinit(priv, &cfg->icb[1]); if (cache->nplanes == 2)
meram_unmark(priv, &cfg->icb[1]); meram_deinit(priv, &cache->planes[1]);
}
meram_deinit(priv, &cfg->icb[0]);
meram_unmark(priv, &cfg->icb[0]);
mutex_unlock(&priv->lock); meram_free(priv, cache);
return 0; mutex_unlock(&priv->lock);
} }
static int sh_mobile_meram_update(struct sh_mobile_meram_info *pdata, static void
struct sh_mobile_meram_cfg *cfg, sh_mobile_meram_update(struct sh_mobile_meram_info *pdata, void *data,
unsigned long base_addr_y, unsigned long base_addr_y, unsigned long base_addr_c,
unsigned long base_addr_c, unsigned long *icb_addr_y, unsigned long *icb_addr_c)
unsigned long *icb_addr_y,
unsigned long *icb_addr_c)
{ {
struct sh_mobile_meram_priv *priv; struct sh_mobile_meram_fb_cache *cache = data;
struct sh_mobile_meram_priv *priv = pdata->priv;
if (!pdata || !pdata->priv || !cfg)
return -EINVAL;
priv = pdata->priv;
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
meram_set_next_addr(priv, cfg, base_addr_y, base_addr_c); meram_set_next_addr(priv, cache, base_addr_y, base_addr_c);
meram_get_next_icb_addr(pdata, cfg, icb_addr_y, icb_addr_c); meram_get_next_icb_addr(pdata, cache, icb_addr_y, icb_addr_c);
mutex_unlock(&priv->lock); mutex_unlock(&priv->lock);
return 0;
} }
static int sh_mobile_meram_runtime_suspend(struct device *dev) static struct sh_mobile_meram_ops sh_mobile_meram_ops = {
.module = THIS_MODULE,
.meram_register = sh_mobile_meram_register,
.meram_unregister = sh_mobile_meram_unregister,
.meram_update = sh_mobile_meram_update,
};
/* -----------------------------------------------------------------------------
* Power management
*/
static int sh_mobile_meram_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev); struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev);
int k, j; unsigned int i, j;
for (k = 0; k < CMN_REGS_SIZE; k++) for (i = 0; i < MERAM_REGS_SIZE; i++)
priv->cmn_saved_regs[k] = meram_read_reg(priv->base, priv->regs[i] = meram_read_reg(priv->base, common_regs[i]);
common_regs[k]);
for (j = 0; j < 32; j++) { for (i = 0; i < 32; i++) {
if (!test_bit(j, &priv->used_icb)) if (!test_bit(i, &priv->used_icb))
continue; continue;
for (k = 0; k < ICB_REGS_SIZE; k++) { for (j = 0; j < ICB_REGS_SIZE; j++) {
priv->icb_saved_regs[j * ICB_REGS_SIZE + k] = priv->icbs[i].regs[j] =
meram_read_icb(priv->base, j, icb_regs[k]); meram_read_icb(priv->base, i, icb_regs[j]);
/* Reset ICB on resume */ /* Reset ICB on resume */
if (icb_regs[k] == MExxCTL) if (icb_regs[j] == MExxCTL)
priv->icb_saved_regs[j * ICB_REGS_SIZE + k] |= priv->icbs[i].regs[j] |=
MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF; MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF;
} }
} }
return 0; return 0;
} }
static int sh_mobile_meram_runtime_resume(struct device *dev) static int sh_mobile_meram_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev); struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev);
int k, j; unsigned int i, j;
for (j = 0; j < 32; j++) { for (i = 0; i < 32; i++) {
if (!test_bit(j, &priv->used_icb)) if (!test_bit(i, &priv->used_icb))
continue; continue;
for (k = 0; k < ICB_REGS_SIZE; k++) { for (j = 0; j < ICB_REGS_SIZE; j++)
meram_write_icb(priv->base, j, icb_regs[k], meram_write_icb(priv->base, i, icb_regs[j],
priv->icb_saved_regs[j * ICB_REGS_SIZE + k]); priv->icbs[i].regs[j]);
}
} }
for (k = 0; k < CMN_REGS_SIZE; k++) for (i = 0; i < MERAM_REGS_SIZE; i++)
meram_write_reg(priv->base, common_regs[k], meram_write_reg(priv->base, common_regs[i], priv->regs[i]);
priv->cmn_saved_regs[k]);
return 0; return 0;
} }
static const struct dev_pm_ops sh_mobile_meram_dev_pm_ops = { static UNIVERSAL_DEV_PM_OPS(sh_mobile_meram_dev_pm_ops,
.runtime_suspend = sh_mobile_meram_runtime_suspend, sh_mobile_meram_suspend,
.runtime_resume = sh_mobile_meram_runtime_resume, sh_mobile_meram_resume, NULL);
};
static struct sh_mobile_meram_ops sh_mobile_meram_ops = {
.module = THIS_MODULE,
.meram_register = sh_mobile_meram_register,
.meram_unregister = sh_mobile_meram_unregister,
.meram_update = sh_mobile_meram_update,
};
/* /* -----------------------------------------------------------------------------
* initialize MERAM * Probe/remove and driver init/exit
*/ */
static int sh_mobile_meram_remove(struct platform_device *pdev);
static int __devinit sh_mobile_meram_probe(struct platform_device *pdev) static int __devinit sh_mobile_meram_probe(struct platform_device *pdev)
{ {
struct sh_mobile_meram_priv *priv; struct sh_mobile_meram_priv *priv;
struct sh_mobile_meram_info *pdata = pdev->dev.platform_data; struct sh_mobile_meram_info *pdata = pdev->dev.platform_data;
struct resource *res; struct resource *regs;
struct resource *meram;
unsigned int i;
int error; int error;
if (!pdata) { if (!pdata) {
...@@ -610,8 +604,9 @@ static int __devinit sh_mobile_meram_probe(struct platform_device *pdev) ...@@ -610,8 +604,9 @@ static int __devinit sh_mobile_meram_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { meram = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (regs == NULL || meram == NULL) {
dev_err(&pdev->dev, "cannot get platform resources\n"); dev_err(&pdev->dev, "cannot get platform resources\n");
return -ENOENT; return -ENOENT;
} }
...@@ -622,32 +617,74 @@ static int __devinit sh_mobile_meram_probe(struct platform_device *pdev) ...@@ -622,32 +617,74 @@ static int __devinit sh_mobile_meram_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
platform_set_drvdata(pdev, priv); /* Initialize private data. */
/* initialize private data */
mutex_init(&priv->lock); mutex_init(&priv->lock);
priv->base = ioremap_nocache(res->start, resource_size(res)); priv->used_icb = pdata->reserved_icbs;
for (i = 0; i < MERAM_ICB_NUM; ++i)
priv->icbs[i].index = i;
pdata->ops = &sh_mobile_meram_ops;
pdata->priv = priv;
pdata->pdev = pdev;
/* Request memory regions and remap the registers. */
if (!request_mem_region(regs->start, resource_size(regs), pdev->name)) {
dev_err(&pdev->dev, "MERAM registers region already claimed\n");
error = -EBUSY;
goto err_req_regs;
}
if (!request_mem_region(meram->start, resource_size(meram),
pdev->name)) {
dev_err(&pdev->dev, "MERAM memory region already claimed\n");
error = -EBUSY;
goto err_req_meram;
}
priv->base = ioremap_nocache(regs->start, resource_size(regs));
if (!priv->base) { if (!priv->base) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
error = -EFAULT; error = -EFAULT;
goto err; goto err_ioremap;
} }
pdata->ops = &sh_mobile_meram_ops;
pdata->priv = priv; priv->meram = meram->start;
pdata->pdev = pdev;
/* Create and initialize the MERAM memory pool. */
priv->pool = gen_pool_create(ilog2(MERAM_GRANULARITY), -1);
if (priv->pool == NULL) {
error = -ENOMEM;
goto err_genpool;
}
error = gen_pool_add(priv->pool, meram->start, resource_size(meram),
-1);
if (error < 0)
goto err_genpool;
/* initialize ICB addressing mode */ /* initialize ICB addressing mode */
if (pdata->addr_mode == SH_MOBILE_MERAM_MODE1) if (pdata->addr_mode == SH_MOBILE_MERAM_MODE1)
meram_write_reg(priv->base, MEVCR1, MEVCR1_AMD1); meram_write_reg(priv->base, MEVCR1, MEVCR1_AMD1);
platform_set_drvdata(pdev, priv);
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
dev_info(&pdev->dev, "sh_mobile_meram initialized."); dev_info(&pdev->dev, "sh_mobile_meram initialized.");
return 0; return 0;
err: err_genpool:
sh_mobile_meram_remove(pdev); if (priv->pool)
gen_pool_destroy(priv->pool);
iounmap(priv->base);
err_ioremap:
release_mem_region(meram->start, resource_size(meram));
err_req_meram:
release_mem_region(regs->start, resource_size(regs));
err_req_regs:
mutex_destroy(&priv->lock);
kfree(priv);
return error; return error;
} }
...@@ -656,11 +693,16 @@ static int __devinit sh_mobile_meram_probe(struct platform_device *pdev) ...@@ -656,11 +693,16 @@ static int __devinit sh_mobile_meram_probe(struct platform_device *pdev)
static int sh_mobile_meram_remove(struct platform_device *pdev) static int sh_mobile_meram_remove(struct platform_device *pdev)
{ {
struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev); struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev);
struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct resource *meram = platform_get_resource(pdev, IORESOURCE_MEM, 1);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
if (priv->base) gen_pool_destroy(priv->pool);
iounmap(priv->base); iounmap(priv->base);
release_mem_region(meram->start, resource_size(meram));
release_mem_region(regs->start, resource_size(regs));
mutex_destroy(&priv->lock); mutex_destroy(&priv->lock);
......
...@@ -31,8 +31,6 @@ struct clk; ...@@ -31,8 +31,6 @@ struct clk;
#define HDMI_SND_SRC_HBR (3 << 0) #define HDMI_SND_SRC_HBR (3 << 0)
struct sh_mobile_hdmi_info { struct sh_mobile_hdmi_info {
struct sh_mobile_lcdc_chan_cfg *lcd_chan;
struct device *lcd_dev;
unsigned int flags; unsigned int flags;
long (*clk_optimize_parent)(unsigned long target, unsigned long *best_freq, long (*clk_optimize_parent)(unsigned long target, unsigned long *best_freq,
unsigned long *parent_freq); unsigned long *parent_freq);
......
...@@ -147,29 +147,23 @@ struct sh_mobile_lcdc_sys_bus_ops { ...@@ -147,29 +147,23 @@ struct sh_mobile_lcdc_sys_bus_ops {
unsigned long (*read_data)(void *handle); unsigned long (*read_data)(void *handle);
}; };
struct module; struct sh_mobile_lcdc_panel_cfg {
struct sh_mobile_lcdc_board_cfg { unsigned long width; /* Panel width in mm */
struct module *owner; unsigned long height; /* Panel height in mm */
void *board_data; int (*setup_sys)(void *sys_ops_handle,
int (*setup_sys)(void *board_data, void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops); struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
void (*start_transfer)(void *board_data, void *sys_ops_handle, void (*start_transfer)(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops); struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
void (*display_on)(void *board_data, struct fb_info *info); void (*display_on)(void);
void (*display_off)(void *board_data); void (*display_off)(void);
int (*set_brightness)(void *board_data, int brightness);
int (*get_brightness)(void *board_data);
};
struct sh_mobile_lcdc_lcd_size_cfg { /* width and height of panel in mm */
unsigned long width;
unsigned long height;
}; };
/* backlight info */ /* backlight info */
struct sh_mobile_lcdc_bl_info { struct sh_mobile_lcdc_bl_info {
const char *name; const char *name;
int max_brightness; int max_brightness;
int (*set_brightness)(int brightness);
int (*get_brightness)(void);
}; };
struct sh_mobile_lcdc_chan_cfg { struct sh_mobile_lcdc_chan_cfg {
...@@ -179,13 +173,14 @@ struct sh_mobile_lcdc_chan_cfg { ...@@ -179,13 +173,14 @@ struct sh_mobile_lcdc_chan_cfg {
int interface_type; /* selects RGBn or SYSn I/F, see above */ int interface_type; /* selects RGBn or SYSn I/F, see above */
int clock_divider; int clock_divider;
unsigned long flags; /* LCDC_FLAGS_... */ unsigned long flags; /* LCDC_FLAGS_... */
const struct fb_videomode *lcd_cfg; const struct fb_videomode *lcd_modes;
int num_cfg; int num_modes;
struct sh_mobile_lcdc_lcd_size_cfg lcd_size_cfg; struct sh_mobile_lcdc_panel_cfg panel_cfg;
struct sh_mobile_lcdc_board_cfg board_cfg;
struct sh_mobile_lcdc_bl_info bl_info; struct sh_mobile_lcdc_bl_info bl_info;
struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */ struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
struct sh_mobile_meram_cfg *meram_cfg; const struct sh_mobile_meram_cfg *meram_cfg;
struct platform_device *tx_dev; /* HDMI/DSI transmitter device */
}; };
struct sh_mobile_lcdc_info { struct sh_mobile_lcdc_info {
......
...@@ -17,48 +17,43 @@ enum { ...@@ -17,48 +17,43 @@ enum {
struct sh_mobile_meram_priv; struct sh_mobile_meram_priv;
struct sh_mobile_meram_ops; struct sh_mobile_meram_ops;
/*
* struct sh_mobile_meram_info - MERAM platform data
* @reserved_icbs: Bitmask of reserved ICBs (for instance used through UIO)
*/
struct sh_mobile_meram_info { struct sh_mobile_meram_info {
int addr_mode; int addr_mode;
u32 reserved_icbs;
struct sh_mobile_meram_ops *ops; struct sh_mobile_meram_ops *ops;
struct sh_mobile_meram_priv *priv; struct sh_mobile_meram_priv *priv;
struct platform_device *pdev; struct platform_device *pdev;
}; };
/* icb config */ /* icb config */
struct sh_mobile_meram_icb { struct sh_mobile_meram_icb_cfg {
int marker_icb; /* ICB # for Marker ICB */ unsigned int meram_size; /* MERAM Buffer Size to use */
int cache_icb; /* ICB # for Cache ICB */
int meram_offset; /* MERAM Buffer Offset to use */
int meram_size; /* MERAM Buffer Size to use */
int cache_unit; /* bytes to cache per ICB */
}; };
struct sh_mobile_meram_cfg { struct sh_mobile_meram_cfg {
struct sh_mobile_meram_icb icb[2]; struct sh_mobile_meram_icb_cfg icb[2];
int pixelformat;
int current_reg;
}; };
struct module; struct module;
struct sh_mobile_meram_ops { struct sh_mobile_meram_ops {
struct module *module; struct module *module;
/* register usage of meram */ /* register usage of meram */
int (*meram_register)(struct sh_mobile_meram_info *meram_dev, void *(*meram_register)(struct sh_mobile_meram_info *meram_dev,
struct sh_mobile_meram_cfg *cfg, const struct sh_mobile_meram_cfg *cfg,
int xres, int yres, int pixelformat, unsigned int xres, unsigned int yres,
unsigned long base_addr_y, unsigned int pixelformat,
unsigned long base_addr_c, unsigned int *pitch);
unsigned long *icb_addr_y,
unsigned long *icb_addr_c, int *pitch);
/* unregister usage of meram */ /* unregister usage of meram */
int (*meram_unregister)(struct sh_mobile_meram_info *meram_dev, void (*meram_unregister)(struct sh_mobile_meram_info *meram_dev,
struct sh_mobile_meram_cfg *cfg); void *data);
/* update meram settings */ /* update meram settings */
int (*meram_update)(struct sh_mobile_meram_info *meram_dev, void (*meram_update)(struct sh_mobile_meram_info *meram_dev, void *data,
struct sh_mobile_meram_cfg *cfg,
unsigned long base_addr_y, unsigned long base_addr_y,
unsigned long base_addr_c, unsigned long base_addr_c,
unsigned long *icb_addr_y, unsigned long *icb_addr_y,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment