Both structures describe features of a particular OMAP DSS version, there's no reason to keep them separate. Merge them together, allowing initialization of the features based on the DSS compatible string instead of the OMAP SoC version. Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> --- drivers/gpu/drm/omapdrm/dss/core.c | 2 - drivers/gpu/drm/omapdrm/dss/dss.c | 128 +---------------- drivers/gpu/drm/omapdrm/dss/dss.h | 6 + drivers/gpu/drm/omapdrm/dss/dss_features.c | 220 ++++++++++++++++++++--------- drivers/gpu/drm/omapdrm/dss/dss_features.h | 41 +++++- 5 files changed, 204 insertions(+), 193 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index 839bfb5a2e48..2a8bf441d38d 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -54,8 +54,6 @@ static int __init omap_dss_probe(struct platform_device *pdev) { core.pdev = pdev; - dss_features_init(omapdss_get_version()); - return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 34d5caa7d0b5..edfb1ecded76 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -77,16 +77,6 @@ struct dss_ops { enum dss_clk_source clk_src); }; -struct dss_features { - enum dss_device_type type; - u8 fck_div_max; - u8 dss_fck_multiplier; - const char *parent_clk_name; - const enum omap_display_type *ports; - int num_ports; - const struct dss_ops *ops; -}; - static struct { struct platform_device *pdev; void __iomem *base; @@ -108,7 +98,7 @@ static struct { bool ctx_valid; u32 ctx[DSS_SZ_REGS / sizeof(u32)]; - const struct dss_features *feat; + const struct omap_dss_features *feat; struct dss_pll *video1_pll; struct dss_pll *video2_pll; @@ -969,114 +959,25 @@ static inline void dss_uninitialize_debugfs(void) } #endif /* CONFIG_OMAP2_DSS_DEBUGFS */ -static const struct dss_ops dss_ops_omap2_omap3 = { +const struct dss_ops dss_ops_omap2_omap3 = { .dpi_select_source = &dss_dpi_select_source_omap2_omap3, }; -static const struct dss_ops dss_ops_omap4 = { +const struct dss_ops dss_ops_omap4 = { .dpi_select_source = &dss_dpi_select_source_omap4, .select_lcd_source = &dss_lcd_clk_mux_omap4, }; -static const struct dss_ops dss_ops_omap5 = { +const struct dss_ops dss_ops_omap5 = { .dpi_select_source = &dss_dpi_select_source_omap5, .select_lcd_source = &dss_lcd_clk_mux_omap5, }; -static const struct dss_ops dss_ops_dra7 = { +const struct dss_ops dss_ops_dra7 = { .dpi_select_source = &dss_dpi_select_source_dra7xx, .select_lcd_source = &dss_lcd_clk_mux_dra7, }; -static const enum omap_display_type omap2plus_ports[] = { - OMAP_DISPLAY_TYPE_DPI, -}; - -static const enum omap_display_type omap34xx_ports[] = { - OMAP_DISPLAY_TYPE_DPI, - OMAP_DISPLAY_TYPE_SDI, -}; - -static const enum omap_display_type dra7xx_ports[] = { - OMAP_DISPLAY_TYPE_DPI, - OMAP_DISPLAY_TYPE_DPI, - OMAP_DISPLAY_TYPE_DPI, -}; - -static const struct dss_features omap24xx_dss_feats = { - .type = DSS_TYPE_OMAP2, - /* - * fck div max is really 16, but the divider range has gaps. The range - * from 1 to 6 has no gaps, so let's use that as a max. - */ - .fck_div_max = 6, - .dss_fck_multiplier = 2, - .parent_clk_name = "core_ck", - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_omap2_omap3, -}; - -static const struct dss_features omap34xx_dss_feats = { - .type = DSS_TYPE_OMAP3, - .fck_div_max = 16, - .dss_fck_multiplier = 2, - .parent_clk_name = "dpll4_ck", - .ports = omap34xx_ports, - .num_ports = ARRAY_SIZE(omap34xx_ports), - .ops = &dss_ops_omap2_omap3, -}; - -static const struct dss_features omap3630_dss_feats = { - .type = DSS_TYPE_OMAP3, - .fck_div_max = 32, - .dss_fck_multiplier = 1, - .parent_clk_name = "dpll4_ck", - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_omap2_omap3, -}; - -static const struct dss_features omap44xx_dss_feats = { - .type = DSS_TYPE_OMAP4, - .fck_div_max = 32, - .dss_fck_multiplier = 1, - .parent_clk_name = "dpll_per_x2_ck", - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_dra7, -}; - -static const struct dss_features omap54xx_dss_feats = { - .type = DSS_TYPE_OMAP5, - .fck_div_max = 64, - .dss_fck_multiplier = 1, - .parent_clk_name = "dpll_per_x2_ck", - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_omap5, -}; - -static const struct dss_features am43xx_dss_feats = { - .type = DSS_TYPE_OMAP3, - .fck_div_max = 0, - .dss_fck_multiplier = 0, - .parent_clk_name = NULL, - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_omap2_omap3, -}; - -static const struct dss_features dra7xx_dss_feats = { - .type = DSS_TYPE_DRA7, - .fck_div_max = 64, - .dss_fck_multiplier = 1, - .parent_clk_name = "dpll_per_x2_ck", - .ports = dra7xx_ports, - .num_ports = ARRAY_SIZE(dra7xx_ports), - .ops = &dss_ops_dra7, -}; - static int dss_init_ports(struct platform_device *pdev) { struct device_node *parent = pdev->dev.of_node; @@ -1225,23 +1126,6 @@ static int dss_video_pll_probe(struct platform_device *pdev) } /* DSS HW IP initialisation */ -static const struct of_device_id dss_of_match[] = { - { .compatible = "ti,omap2-dss", .data = &omap24xx_dss_feats }, - { .compatible = "ti,omap3-dss", .data = &omap3630_dss_feats }, - { .compatible = "ti,omap4-dss", .data = &omap44xx_dss_feats }, - { .compatible = "ti,omap5-dss", .data = &omap54xx_dss_feats }, - { .compatible = "ti,dra7-dss", .data = &dra7xx_dss_feats }, - {}, -}; -MODULE_DEVICE_TABLE(of, dss_of_match); - -static const struct soc_device_attribute dss_soc_devices[] = { - { .machine = "OMAP3430/3530", .data = &omap34xx_dss_feats }, - { .machine = "AM35??", .data = &omap34xx_dss_feats }, - { .family = "AM43xx", .data = &am43xx_dss_feats }, - { /* sentinel */ } -}; - static int dss_bind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -1396,6 +1280,8 @@ static int dss_probe(struct platform_device *pdev) else dss.feat = of_match_device(dss_of_match, &pdev->dev)->data; + dss_features_init(dss.feat); + r = dss_initialize_debugfs(); if (r) return r; diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index eca7d731f5c8..e339874f6824 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -245,6 +245,12 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id) return false; } +struct dss_ops; +extern const struct dss_ops dss_ops_omap2_omap3; +extern const struct dss_ops dss_ops_omap4; +extern const struct dss_ops dss_ops_omap5; +extern const struct dss_ops dss_ops_dra7; + /* DSS */ #if defined(CONFIG_OMAP2_DSS_DEBUGFS) int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)); diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.c b/drivers/gpu/drm/omapdrm/dss/dss_features.c index ee5b93ce2763..f92df91a9d4c 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.c +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.c @@ -21,7 +21,9 @@ #include <linux/module.h> #include <linux/types.h> #include <linux/err.h> +#include <linux/mod_devicetable.h> #include <linux/slab.h> +#include <linux/sys_soc.h> #include "omapdss.h" #include "dss.h" @@ -36,27 +38,6 @@ struct dss_param_range { int min, max; }; -struct omap_dss_features { - const struct dss_reg_field *reg_fields; - const int num_reg_fields; - - const enum dss_feat_id *features; - const int num_features; - - const int num_mgrs; - const int num_ovls; - const enum omap_display_type *supported_displays; - const enum omap_dss_output_id *supported_outputs; - const enum omap_color_mode *supported_color_modes; - const enum omap_overlay_caps *overlay_caps; - const struct dss_param_range *dss_params; - - const enum omap_dss_rotation_type supported_rotation_types; - - const u32 buffer_size_unit; - const u32 burst_size_unit; -}; - /* This struct is assigned to one of the below during initialization */ static const struct omap_dss_features *omap_current_dss_features; @@ -587,8 +568,35 @@ static const enum dss_feat_id omap5_dss_feat_list[] = { FEAT_MFLAG, }; +static const enum omap_display_type omap2plus_ports[] = { + OMAP_DISPLAY_TYPE_DPI, +}; + +static const enum omap_display_type omap34xx_ports[] = { + OMAP_DISPLAY_TYPE_DPI, + OMAP_DISPLAY_TYPE_SDI, +}; + +static const enum omap_display_type dra7xx_ports[] = { + OMAP_DISPLAY_TYPE_DPI, + OMAP_DISPLAY_TYPE_DPI, + OMAP_DISPLAY_TYPE_DPI, +}; + /* OMAP2 DSS Features */ -static const struct omap_dss_features omap2_dss_features = { +static const struct omap_dss_features omap24xx_dss_features = { + .type = DSS_TYPE_OMAP2, + /* + * fck div max is really 16, but the divider range has gaps. The range + * from 1 to 6 has no gaps, so let's use that as a max. + */ + .fck_div_max = 6, + .dss_fck_multiplier = 2, + .parent_clk_name = "core_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = omap2_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields), @@ -609,6 +617,14 @@ static const struct omap_dss_features omap2_dss_features = { /* OMAP3 DSS Features */ static const struct omap_dss_features omap3430_dss_features = { + .type = DSS_TYPE_OMAP3, + .fck_div_max = 16, + .dss_fck_multiplier = 2, + .parent_clk_name = "dpll4_ck", + .ports = omap34xx_ports, + .num_ports = ARRAY_SIZE(omap34xx_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = omap3_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields), @@ -632,6 +648,14 @@ static const struct omap_dss_features omap3430_dss_features = { * vdds_dsi regulator. */ static const struct omap_dss_features am35xx_dss_features = { + .type = DSS_TYPE_OMAP3, + .fck_div_max = 16, + .dss_fck_multiplier = 2, + .parent_clk_name = "dpll4_ck", + .ports = omap34xx_ports, + .num_ports = ARRAY_SIZE(omap34xx_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = omap3_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields), @@ -651,6 +675,14 @@ static const struct omap_dss_features am35xx_dss_features = { }; static const struct omap_dss_features am43xx_dss_features = { + .type = DSS_TYPE_OMAP3, + .fck_div_max = 0, + .dss_fck_multiplier = 0, + .parent_clk_name = NULL, + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = am43xx_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(am43xx_dss_reg_fields), @@ -670,6 +702,14 @@ static const struct omap_dss_features am43xx_dss_features = { }; static const struct omap_dss_features omap3630_dss_features = { + .type = DSS_TYPE_OMAP3, + .fck_div_max = 32, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll4_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = omap3_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields), @@ -691,6 +731,14 @@ static const struct omap_dss_features omap3630_dss_features = { /* OMAP4 DSS Features */ /* For OMAP4430 ES 1.0 revision */ static const struct omap_dss_features omap4430_es1_0_dss_features = { + .type = DSS_TYPE_OMAP4, + .fck_div_max = 32, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_dra7, + .reg_fields = omap4_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields), @@ -711,6 +759,14 @@ static const struct omap_dss_features omap4430_es1_0_dss_features = { /* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */ static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = { + .type = DSS_TYPE_OMAP4, + .fck_div_max = 32, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_dra7, + .reg_fields = omap4_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields), @@ -730,7 +786,15 @@ static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = { }; /* For all the other OMAP4 versions */ -static const struct omap_dss_features omap4_dss_features = { +static const struct omap_dss_features omap44xx_dss_features = { + .type = DSS_TYPE_OMAP4, + .fck_div_max = 32, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_dra7, + .reg_fields = omap4_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields), @@ -750,7 +814,15 @@ static const struct omap_dss_features omap4_dss_features = { }; /* OMAP5 DSS Features */ -static const struct omap_dss_features omap5_dss_features = { +static const struct omap_dss_features omap54xx_dss_features = { + .type = DSS_TYPE_OMAP5, + .fck_div_max = 64, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap5, + .reg_fields = omap5_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap5_dss_reg_fields), @@ -769,7 +841,59 @@ static const struct omap_dss_features omap5_dss_features = { .burst_size_unit = 16, }; -/* Functions returning values related to a DSS feature */ +/* DRA7 DSS Features */ +static const struct omap_dss_features dra7xx_dss_features = { + .type = DSS_TYPE_DRA7, + .fck_div_max = 64, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = dra7xx_ports, + .num_ports = ARRAY_SIZE(dra7xx_ports), + .ops = &dss_ops_dra7, + + .reg_fields = omap5_dss_reg_fields, + .num_reg_fields = ARRAY_SIZE(omap5_dss_reg_fields), + + .features = omap5_dss_feat_list, + .num_features = ARRAY_SIZE(omap5_dss_feat_list), + + .num_mgrs = 4, + .num_ovls = 4, + .supported_displays = omap5_dss_supported_displays, + .supported_outputs = omap5_dss_supported_outputs, + .supported_color_modes = omap4_dss_supported_color_modes, + .overlay_caps = omap4_dss_overlay_caps, + .dss_params = omap5_dss_param_range, + .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER, + .buffer_size_unit = 16, + .burst_size_unit = 16, +}; + +const struct of_device_id dss_of_match[] = { + { .compatible = "ti,omap2-dss", .data = &omap24xx_dss_features }, + { .compatible = "ti,omap3-dss", .data = &omap3630_dss_features }, + { .compatible = "ti,omap4-dss", .data = &omap44xx_dss_features }, + { .compatible = "ti,omap5-dss", .data = &omap54xx_dss_features }, + { .compatible = "ti,dra7-dss", .data = &dra7xx_dss_features }, + {}, +}; +MODULE_DEVICE_TABLE(of, dss_of_match); + +const struct soc_device_attribute dss_soc_devices[] = { + { .machine = "OMAP3430/3530", .data = &omap3430_dss_features }, + { .machine = "OMAP4430", + .revision = "ES1.0", .data = &omap4430_es1_0_dss_features }, + { .machine = "OMAP4430", + .revision = "ES2.[012]", .data = &omap4430_es2_0_1_2_dss_features }, + { .machine = "AM35??", .data = &am35xx_dss_features }, + { .family = "AM43xx", .data = &am43xx_dss_features }, + { /* sentinel */ } +}; + +/* ----------------------------------------------------------------------------- + * Functions returning values related to a DSS feature + */ + int dss_feat_get_num_mgrs(void) { return omap_current_dss_features->num_mgrs; @@ -859,49 +983,7 @@ bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type) return omap_current_dss_features->supported_rotation_types & rot_type; } -void dss_features_init(enum omapdss_version version) +void dss_features_init(const struct omap_dss_features *features) { - switch (version) { - case OMAPDSS_VER_OMAP24xx: - omap_current_dss_features = &omap2_dss_features; - break; - - case OMAPDSS_VER_OMAP34xx_ES1: - case OMAPDSS_VER_OMAP34xx_ES3: - omap_current_dss_features = &omap3430_dss_features; - break; - - case OMAPDSS_VER_OMAP3630: - omap_current_dss_features = &omap3630_dss_features; - break; - - case OMAPDSS_VER_OMAP4430_ES1: - omap_current_dss_features = &omap4430_es1_0_dss_features; - break; - - case OMAPDSS_VER_OMAP4430_ES2: - omap_current_dss_features = &omap4430_es2_0_1_2_dss_features; - break; - - case OMAPDSS_VER_OMAP4: - omap_current_dss_features = &omap4_dss_features; - break; - - case OMAPDSS_VER_OMAP5: - case OMAPDSS_VER_DRA7xx: - omap_current_dss_features = &omap5_dss_features; - break; - - case OMAPDSS_VER_AM35xx: - omap_current_dss_features = &am35xx_dss_features; - break; - - case OMAPDSS_VER_AM43xx: - omap_current_dss_features = &am43xx_dss_features; - break; - - default: - DSSWARN("Unsupported OMAP version"); - break; - } + omap_current_dss_features = features; } diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.h b/drivers/gpu/drm/omapdrm/dss/dss_features.h index bb4b7f0e642b..dde8f32e677f 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.h +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.h @@ -20,6 +20,13 @@ #ifndef __OMAP2_DSS_FEATURES_H #define __OMAP2_DSS_FEATURES_H +#include <linux/mod_devicetable.h> +#include <linux/sys_soc.h> + +struct dss_ops; +struct dss_param_range; +struct dss_reg_field; + #define MAX_DSS_MANAGERS 4 #define MAX_DSS_OVERLAYS 4 #define MAX_DSS_LCD_MANAGERS 3 @@ -85,6 +92,35 @@ enum dss_range_param { FEAT_PARAM_LINEWIDTH, }; +struct omap_dss_features { + enum dss_device_type type; + u8 fck_div_max; + u8 dss_fck_multiplier; + const char *parent_clk_name; + const enum omap_display_type *ports; + int num_ports; + const struct dss_ops *ops; + + const struct dss_reg_field *reg_fields; + int num_reg_fields; + + const enum dss_feat_id *features; + int num_features; + + int num_mgrs; + int num_ovls; + const enum omap_display_type *supported_displays; + const enum omap_dss_output_id *supported_outputs; + const enum omap_color_mode *supported_color_modes; + const enum omap_overlay_caps *overlay_caps; + const struct dss_param_range *dss_params; + + enum omap_dss_rotation_type supported_rotation_types; + + u32 buffer_size_unit; + u32 burst_size_unit; +}; + /* DSS Feature Functions */ unsigned long dss_feat_get_param_min(enum dss_range_param param); unsigned long dss_feat_get_param_max(enum dss_range_param param); @@ -99,9 +135,12 @@ bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type); bool dss_has_feature(enum dss_feat_id id); void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end); -void dss_features_init(enum omapdss_version version); +void dss_features_init(const struct omap_dss_features *features); enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel); enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel); +extern const struct of_device_id dss_of_match[]; +extern const struct soc_device_attribute dss_soc_devices[]; + #endif -- Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel