Commit 461395c4 authored by Tomi Valkeinen's avatar Tomi Valkeinen

OMAPDSS: handle output-driver reg/unreg more dynamically

Initialize and uninitialize the output drivers by using arrays of
pointers to the init/uninit functions. This simplifies the code
slightly.
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 852f0838
...@@ -515,10 +515,54 @@ static int omap_dss_bus_register(void) ...@@ -515,10 +515,54 @@ static int omap_dss_bus_register(void)
} }
/* INIT */ /* INIT */
static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
#ifdef CONFIG_OMAP2_DSS_DPI
dpi_init_platform_driver,
#endif
#ifdef CONFIG_OMAP2_DSS_SDI
sdi_init_platform_driver,
#endif
#ifdef CONFIG_OMAP2_DSS_RFBI
rfbi_init_platform_driver,
#endif
#ifdef CONFIG_OMAP2_DSS_VENC
venc_init_platform_driver,
#endif
#ifdef CONFIG_OMAP2_DSS_DSI
dsi_init_platform_driver,
#endif
#ifdef CONFIG_OMAP4_DSS_HDMI
hdmi_init_platform_driver,
#endif
};
static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = {
#ifdef CONFIG_OMAP2_DSS_DPI
dpi_uninit_platform_driver,
#endif
#ifdef CONFIG_OMAP2_DSS_SDI
sdi_uninit_platform_driver,
#endif
#ifdef CONFIG_OMAP2_DSS_RFBI
rfbi_uninit_platform_driver,
#endif
#ifdef CONFIG_OMAP2_DSS_VENC
venc_uninit_platform_driver,
#endif
#ifdef CONFIG_OMAP2_DSS_DSI
dsi_uninit_platform_driver,
#endif
#ifdef CONFIG_OMAP4_DSS_HDMI
hdmi_uninit_platform_driver,
#endif
};
static bool dss_output_drv_loaded[ARRAY_SIZE(dss_output_drv_reg_funcs)];
static int __init omap_dss_register_drivers(void) static int __init omap_dss_register_drivers(void)
{ {
int r; int r;
int i;
r = platform_driver_probe(&omap_dss_driver, omap_dss_probe); r = platform_driver_probe(&omap_dss_driver, omap_dss_probe);
if (r) if (r)
...@@ -536,56 +580,18 @@ static int __init omap_dss_register_drivers(void) ...@@ -536,56 +580,18 @@ static int __init omap_dss_register_drivers(void)
goto err_dispc; goto err_dispc;
} }
r = dpi_init_platform_driver(); /*
if (r) { * It's ok if the output-driver register fails. It happens, for example,
DSSERR("Failed to initialize dpi platform driver\n"); * when there is no output-device (e.g. SDI for OMAP4).
goto err_dpi; */
} for (i = 0; i < ARRAY_SIZE(dss_output_drv_reg_funcs); ++i) {
r = dss_output_drv_reg_funcs[i]();
r = sdi_init_platform_driver(); if (r == 0)
if (r) { dss_output_drv_loaded[i] = true;
DSSERR("Failed to initialize sdi platform driver\n");
goto err_sdi;
}
r = rfbi_init_platform_driver();
if (r) {
DSSERR("Failed to initialize rfbi platform driver\n");
goto err_rfbi;
}
r = venc_init_platform_driver();
if (r) {
DSSERR("Failed to initialize venc platform driver\n");
goto err_venc;
}
r = dsi_init_platform_driver();
if (r) {
DSSERR("Failed to initialize DSI platform driver\n");
goto err_dsi;
}
r = hdmi_init_platform_driver();
if (r) {
DSSERR("Failed to initialize hdmi\n");
goto err_hdmi;
} }
return 0; return 0;
err_hdmi:
dsi_uninit_platform_driver();
err_dsi:
venc_uninit_platform_driver();
err_venc:
rfbi_uninit_platform_driver();
err_rfbi:
sdi_uninit_platform_driver();
err_sdi:
dpi_uninit_platform_driver();
err_dpi:
dispc_uninit_platform_driver();
err_dispc: err_dispc:
dss_uninit_platform_driver(); dss_uninit_platform_driver();
err_dss: err_dss:
...@@ -596,12 +602,13 @@ static int __init omap_dss_register_drivers(void) ...@@ -596,12 +602,13 @@ static int __init omap_dss_register_drivers(void)
static void __exit omap_dss_unregister_drivers(void) static void __exit omap_dss_unregister_drivers(void)
{ {
hdmi_uninit_platform_driver(); int i;
dsi_uninit_platform_driver();
venc_uninit_platform_driver(); for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i) {
rfbi_uninit_platform_driver(); if (dss_output_drv_loaded[i])
sdi_uninit_platform_driver(); dss_output_drv_unreg_funcs[i]();
dpi_uninit_platform_driver(); }
dispc_uninit_platform_driver(); dispc_uninit_platform_driver();
dss_uninit_platform_driver(); dss_uninit_platform_driver();
......
...@@ -268,14 +268,9 @@ int dss_calc_clock_div(bool is_tft, unsigned long req_pck, ...@@ -268,14 +268,9 @@ int dss_calc_clock_div(bool is_tft, unsigned long req_pck,
struct dispc_clock_info *dispc_cinfo); struct dispc_clock_info *dispc_cinfo);
/* SDI */ /* SDI */
#ifdef CONFIG_OMAP2_DSS_SDI
int sdi_init_platform_driver(void); int sdi_init_platform_driver(void);
void sdi_uninit_platform_driver(void); void sdi_uninit_platform_driver(void);
int sdi_init_display(struct omap_dss_device *display); int sdi_init_display(struct omap_dss_device *display);
#else
static inline int sdi_init_platform_driver(void) { return 0; }
static inline void sdi_uninit_platform_driver(void) { }
#endif
/* DSI */ /* DSI */
#ifdef CONFIG_OMAP2_DSS_DSI #ifdef CONFIG_OMAP2_DSS_DSI
...@@ -312,13 +307,6 @@ void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev); ...@@ -312,13 +307,6 @@ void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev);
void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev); void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev);
struct platform_device *dsi_get_dsidev_from_id(int module); struct platform_device *dsi_get_dsidev_from_id(int module);
#else #else
static inline int dsi_init_platform_driver(void)
{
return 0;
}
static inline void dsi_uninit_platform_driver(void)
{
}
static inline int dsi_runtime_get(struct platform_device *dsidev) static inline int dsi_runtime_get(struct platform_device *dsidev)
{ {
return 0; return 0;
...@@ -375,14 +363,9 @@ static inline struct platform_device *dsi_get_dsidev_from_id(int module) ...@@ -375,14 +363,9 @@ static inline struct platform_device *dsi_get_dsidev_from_id(int module)
#endif #endif
/* DPI */ /* DPI */
#ifdef CONFIG_OMAP2_DSS_DPI
int dpi_init_platform_driver(void); int dpi_init_platform_driver(void);
void dpi_uninit_platform_driver(void); void dpi_uninit_platform_driver(void);
int dpi_init_display(struct omap_dss_device *dssdev); int dpi_init_display(struct omap_dss_device *dssdev);
#else
static inline int dpi_init_platform_driver(void) { return 0; }
static inline void dpi_uninit_platform_driver(void) { }
#endif
/* DISPC */ /* DISPC */
int dispc_init_platform_driver(void); int dispc_init_platform_driver(void);
...@@ -459,13 +442,6 @@ void venc_dump_regs(struct seq_file *s); ...@@ -459,13 +442,6 @@ void venc_dump_regs(struct seq_file *s);
int venc_init_display(struct omap_dss_device *display); int venc_init_display(struct omap_dss_device *display);
unsigned long venc_get_pixel_clock(void); unsigned long venc_get_pixel_clock(void);
#else #else
static inline int venc_init_platform_driver(void)
{
return 0;
}
static inline void venc_uninit_platform_driver(void)
{
}
static inline unsigned long venc_get_pixel_clock(void) static inline unsigned long venc_get_pixel_clock(void)
{ {
WARN("%s: VENC not compiled in, returning pclk as 0\n", __func__); WARN("%s: VENC not compiled in, returning pclk as 0\n", __func__);
...@@ -485,13 +461,6 @@ static inline int hdmi_init_display(struct omap_dss_device *dssdev) ...@@ -485,13 +461,6 @@ static inline int hdmi_init_display(struct omap_dss_device *dssdev)
{ {
return 0; return 0;
} }
static inline int hdmi_init_platform_driver(void)
{
return 0;
}
static inline void hdmi_uninit_platform_driver(void)
{
}
static inline unsigned long hdmi_get_pixel_clock(void) static inline unsigned long hdmi_get_pixel_clock(void)
{ {
WARN("%s: HDMI not compiled in, returning pclk as 0\n", __func__); WARN("%s: HDMI not compiled in, returning pclk as 0\n", __func__);
...@@ -509,20 +478,10 @@ int hdmi_panel_init(void); ...@@ -509,20 +478,10 @@ int hdmi_panel_init(void);
void hdmi_panel_exit(void); void hdmi_panel_exit(void);
/* RFBI */ /* RFBI */
#ifdef CONFIG_OMAP2_DSS_RFBI
int rfbi_init_platform_driver(void); int rfbi_init_platform_driver(void);
void rfbi_uninit_platform_driver(void); void rfbi_uninit_platform_driver(void);
void rfbi_dump_regs(struct seq_file *s); void rfbi_dump_regs(struct seq_file *s);
int rfbi_init_display(struct omap_dss_device *display); int rfbi_init_display(struct omap_dss_device *display);
#else
static inline int rfbi_init_platform_driver(void)
{
return 0;
}
static inline void rfbi_uninit_platform_driver(void)
{
}
#endif
#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
......
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