Reuse the DE3.3 planes and mixer infrastructure for Allwinner A733 DE3.5. Enable 40-bit DMA addresses and commit shadow blocks via RCQ.
Signed-off-by: Alastair D'Silva <[email protected]> --- drivers/gpu/drm/sun4i/sun4i_drv.c | 10 +- drivers/gpu/drm/sun4i/sun50i_planes.c | 98 +++++++++--- drivers/gpu/drm/sun4i/sun50i_planes.h | 5 + drivers/gpu/drm/sun4i/sun8i_csc.c | 3 +- drivers/gpu/drm/sun4i/sun8i_mixer.c | 200 +++++++++++++++++++----- drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 12 +- drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 6 + drivers/gpu/drm/sun4i/sun8i_vi_layer.h | 2 + drivers/gpu/drm/sun4i/sun8i_vi_scaler.c | 3 +- 9 files changed, 272 insertions(+), 67 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index 248be5ff4f36..c17208c91cd0 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -378,10 +378,13 @@ static int sun4i_drv_probe(struct platform_device *pdev) INIT_KFIFO(list.fifo); /* - * DE2 and DE3 cores actually supports 40-bit addresses, but - * driver does not. + * DE2 and DE3 cores actually support 40-bit addresses, but the + * driver uses 32-bit for them. DE3.5 requires 40-bit DMA. */ - dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); + if (of_device_is_compatible(np, "allwinner,sun60i-a733-display-engine")) + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40)); + else + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); dma_set_max_seg_size(&pdev->dev, UINT_MAX); for (i = 0;; i++) { @@ -442,6 +445,7 @@ static const struct of_device_id sun4i_drv_of_table[] = { { .compatible = "allwinner,sun20i-d1-display-engine" }, { .compatible = "allwinner,sun50i-a64-display-engine" }, { .compatible = "allwinner,sun50i-h6-display-engine" }, + { .compatible = "allwinner,sun60i-a733-display-engine" }, { } }; MODULE_DEVICE_TABLE(of, sun4i_drv_of_table); diff --git a/drivers/gpu/drm/sun4i/sun50i_planes.c b/drivers/gpu/drm/sun4i/sun50i_planes.c index 05607445cc38..a597fbbe54dc 100644 --- a/drivers/gpu/drm/sun4i/sun50i_planes.c +++ b/drivers/gpu/drm/sun4i/sun50i_planes.c @@ -4,6 +4,7 @@ #include <drm/drm_device.h> #include <linux/device.h> +#include <linux/dma-mapping.h> #include <linux/io.h> #include <linux/module.h> #include <linux/of.h> @@ -12,6 +13,7 @@ #include <linux/regmap.h> #include "sun50i_planes.h" +#include "sun60i_de35_rcq.h" #include "sun8i_ui_layer.h" #include "sun8i_vi_layer.h" @@ -37,11 +39,39 @@ static const struct sun50i_planes_quirks sun50i_h616_planes_quirks = { }, }; +static const struct sun50i_planes_quirks sun60i_a733_planes_quirks = { + .is_de35 = true, + .def_map = { + { + .map = {0, 6, 7, 1, 2, 8}, + .num_ch = 6, + }, + }, + .cfg = { + .de_type = SUN8I_MIXER_DE35, + .scaler_mask = 0, + .scanline_yuv = 4096, + }, +}; + +static const struct sun60i_de35_rcq_block_desc sun60i_a733_plane_blocks[] = { + { 0x001000, 0x100 }, { 0x001800, 0x80 }, /* vch0 */ + { 0x021000, 0x100 }, { 0x021800, 0x80 }, /* vch1 */ + { 0x041000, 0x100 }, { 0x041800, 0x80 }, /* vch2 */ + { 0x0c1000, 0x90 }, /* uch0 */ + { 0x0e1000, 0x90 }, /* uch1 */ + { 0x101000, 0x90 }, /* uch2 */ +}; + static const struct of_device_id sun50i_planes_of_table[] = { { .compatible = "allwinner,sun50i-h616-de33-planes", .data = &sun50i_h616_planes_quirks }, + { + .compatible = "allwinner,sun60i-a733-de35-planes", + .data = &sun60i_a733_planes_quirks + }, { } }; MODULE_DEVICE_TABLE(of, sun50i_planes_of_table); @@ -105,6 +135,13 @@ sun50i_planes_setup(struct device *dev, struct drm_device *drm, return drm_planes; } +struct sun60i_de35_rcq *sun50i_planes_get_rcq(struct device *dev) +{ + struct sun50i_planes *planes = dev_get_drvdata(dev); + + return planes ? planes->rcq : NULL; +} + static void sun50i_planes_init_mapping(struct sun50i_planes *planes) { const struct sun50i_planes_quirks *quirks = planes->quirks; @@ -161,39 +198,56 @@ static int sun50i_planes_probe(struct platform_device *pdev) if (!planes->quirks) return dev_err_probe(dev, -EINVAL, "Unable to get quirks\n"); - np = of_parse_phandle(dev->of_node, - "allwinner,plane-mapping", 0); - if (!np) - return dev_err_probe(dev, -EINVAL, "Missing mapping phandle\n"); - - clk_pdev = of_find_device_by_node(np); - of_node_put(np); - if (!clk_pdev) - return dev_err_probe(dev, -EPROBE_DEFER, "Unable to get mapping\n"); - - /* Regmap is registered by display clocks driver during its probe. */ - planes->mapping = dev_get_regmap(&clk_pdev->dev, NULL); - if (!planes->mapping) { - platform_device_put(clk_pdev); - return dev_err_probe(dev, -EPROBE_DEFER, "Unable to get regmap\n"); - } + if (!planes->quirks->is_de35) { + np = of_parse_phandle(dev->of_node, + "allwinner,plane-mapping", 0); + if (!np) + return dev_err_probe(dev, -EINVAL, "Missing mapping phandle\n"); + + clk_pdev = of_find_device_by_node(np); + of_node_put(np); + if (!clk_pdev) + return dev_err_probe(dev, -EPROBE_DEFER, "Unable to get mapping\n"); + + /* Regmap is registered by display clocks driver during its probe. */ + planes->mapping = dev_get_regmap(&clk_pdev->dev, NULL); + if (!planes->mapping) { + platform_device_put(clk_pdev); + return dev_err_probe(dev, -EPROBE_DEFER, "Unable to get regmap\n"); + } - if (!device_link_add(dev, &clk_pdev->dev, - DL_FLAG_AUTOREMOVE_CONSUMER)) { + if (!device_link_add(dev, &clk_pdev->dev, + DL_FLAG_AUTOREMOVE_CONSUMER)) { + platform_device_put(clk_pdev); + return dev_err_probe(dev, -EINVAL, "Failed to create link\n"); + } platform_device_put(clk_pdev); - return dev_err_probe(dev, -EINVAL, "Failed to create link\n"); } - platform_device_put(clk_pdev); regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(regs)) return PTR_ERR(regs); - planes->regs = devm_regmap_init_mmio(dev, regs, &sun50i_planes_regmap_config); + if (planes->quirks->is_de35) { + int ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40)); + + if (ret) + return ret; + + planes->regs = sun60i_de35_rcq_regmap_init(dev, regs, 0x100000, + sun60i_a733_plane_blocks, + ARRAY_SIZE(sun60i_a733_plane_blocks), + &sun50i_planes_regmap_config, + &planes->rcq); + } else { + planes->regs = devm_regmap_init_mmio(dev, regs, + &sun50i_planes_regmap_config); + } if (IS_ERR(planes->regs)) return PTR_ERR(planes->regs); - sun50i_planes_init_mapping(planes); + if (!planes->quirks->is_de35) + sun50i_planes_init_mapping(planes); dev_set_drvdata(dev, planes); diff --git a/drivers/gpu/drm/sun4i/sun50i_planes.h b/drivers/gpu/drm/sun4i/sun50i_planes.h index 9b4f77a6b94e..f3637222c3a1 100644 --- a/drivers/gpu/drm/sun4i/sun50i_planes.h +++ b/drivers/gpu/drm/sun4i/sun50i_planes.h @@ -23,20 +23,25 @@ struct default_map { unsigned int num_ch; }; +struct sun60i_de35_rcq; + struct sun50i_planes_quirks { struct default_map def_map[MAX_DISP]; struct sun8i_layer_cfg cfg; + bool is_de35; }; struct sun50i_planes { struct regmap *regs; struct regmap *mapping; const struct sun50i_planes_quirks *quirks; + struct sun60i_de35_rcq *rcq; }; struct drm_plane ** sun50i_planes_setup(struct device *dev, struct drm_device *drm, unsigned int mixer); +struct sun60i_de35_rcq *sun50i_planes_get_rcq(struct device *dev); extern struct platform_driver sun50i_planes_platform_driver; diff --git a/drivers/gpu/drm/sun4i/sun8i_csc.c b/drivers/gpu/drm/sun4i/sun8i_csc.c index 70fc9b017d17..76904871abbd 100644 --- a/drivers/gpu/drm/sun4i/sun8i_csc.c +++ b/drivers/gpu/drm/sun4i/sun8i_csc.c @@ -304,7 +304,8 @@ void sun8i_csc_config(struct sun8i_layer *layer, mode, state->color_encoding, state->color_range); return; - } else if (layer->cfg->de_type == SUN8I_MIXER_DE33) { + } else if (layer->cfg->de_type == SUN8I_MIXER_DE33 || + layer->cfg->de_type == SUN8I_MIXER_DE35) { sun8i_de33_ccsc_setup(layer->regs, layer->channel, mode, state->color_encoding, state->color_range); diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c index 4677180ec780..638064ea1a72 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -15,6 +15,7 @@ #include <linux/of_graph.h> #include <linux/of_platform.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> #include <linux/reset.h> #include <drm/drm_atomic.h> @@ -30,6 +31,7 @@ #include "sun8i_ui_layer.h" #include "sun8i_vi_layer.h" #include "sun50i_planes.h" +#include "sun60i_de35_rcq.h" #include "sunxi_engine.h" struct de2_fmt_info { @@ -307,9 +309,19 @@ static void sun8i_mixer_commit(struct sunxi_engine *engine, regmap_write(engine->regs, SUN8I_MIXER_BLEND_PIPE_CTL(bld_base), pipe_en | SUN8I_MIXER_BLEND_PIPE_CTL_FC_EN(0)); - if (mixer->cfg->de_type != SUN8I_MIXER_DE33) + if (mixer->cfg->de_type == SUN8I_MIXER_DE35) { + struct sun60i_de35_rcq *planes_rcq; + + planes_rcq = sun50i_planes_get_rcq(mixer->planes_dev); + sun60i_de35_rcq_commit(mixer->top_regs, + mixer->rcq, planes_rcq, + mixer->rcq_heads, + mixer->rcq_heads_dma, + mixer->rcq_max_heads); + } else if (mixer->cfg->de_type != SUN8I_MIXER_DE33) { regmap_write(engine->regs, SUN8I_MIXER_GLOBAL_DBUFF, SUN8I_MIXER_GLOBAL_DBUFF_ENABLE); + } } static struct drm_plane **sun8i_layers_init(struct drm_device *drm, @@ -403,7 +415,9 @@ static void sun8i_mixer_mode_set(struct sunxi_engine *engine, DRM_DEBUG_DRIVER("Updating global size W: %u H: %u\n", mode->hdisplay, mode->vdisplay); - if (mixer->cfg->de_type == SUN8I_MIXER_DE33) + if (mixer->cfg->de_type == SUN8I_MIXER_DE35) + regmap_write(mixer->top_regs, SUN60I_DE35_TOP_OUT_SIZE, size); + else if (mixer->cfg->de_type == SUN8I_MIXER_DE33) regmap_write(mixer->top_regs, SUN50I_MIXER_GLOBAL_SIZE, size); else regmap_write(mixer->engine.regs, SUN8I_MIXER_GLOBAL_SIZE, size); @@ -450,6 +464,19 @@ static const struct regmap_config sun8i_top_regmap_config = { .max_register = 0x3c, }; +static const struct regmap_config sun60i_de35_top_regmap_config = { + .name = "top", + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + .max_register = 0x1fc, +}; + +static const struct sun60i_de35_rcq_block_desc sun60i_de35_mixer_rcq_blocks[] = { + { .offset = 0x1000, .size = 0x60 }, + { .offset = 0x1080, .size = 0x80 }, +}; + static const struct regmap_config sun50i_mixer33_regmap_config = { .name = "display", .reg_bits = 32, @@ -484,17 +511,40 @@ static void sun8i_mixer_init(struct sun8i_mixer *mixer) struct regmap *top_regs; int plane_cnt, i; - if (mixer->cfg->de_type == SUN8I_MIXER_DE33) + if (mixer->cfg->de_type == SUN8I_MIXER_DE33 || + mixer->cfg->de_type == SUN8I_MIXER_DE35) top_regs = mixer->top_regs; else top_regs = mixer->engine.regs; - /* Enable the mixer */ - regmap_write(top_regs, SUN8I_MIXER_GLOBAL_CTL, - SUN8I_MIXER_GLOBAL_CTL_RT_EN); + if (mixer->cfg->de_type == SUN8I_MIXER_DE35) { + regmap_set_bits(top_regs, SUN60I_DE35_TOP_RESET, + BIT(0) | BIT(16)); + regmap_set_bits(top_regs, SUN60I_DE35_TOP_CLK, + BIT(0) | BIT(16)); + regmap_set_bits(top_regs, SUN60I_DE35_TOP_MBUS_CLK, + BIT(0) | BIT(4)); + /* Route mixer0 to TCON_TV0 (index 4); leave disp1-3 unrouted */ + regmap_write(top_regs, SUN60I_DE35_TOP_DE2TCON_MUX, 0x0000fff4); + /* Route all VCH/UCH channels to mixer0 */ + regmap_write(top_regs, SUN60I_DE35_TOP_VCH2CORE_MUX, 0); + regmap_write(top_regs, SUN60I_DE35_TOP_UCH2CORE_MUX, 0); + /* + * Map blender ports 0..5 to match sun60i_a733_planes_quirks + * def_map {0, 6, 7, 1, 2, 8}: vch0, uch0, uch1, vch1, vch2, uch2. + */ + regmap_write(top_regs, SUN60I_DE35_TOP_PORT2CHN_MUX, 0x00a21980); + regmap_write(top_regs, SUN60I_DE35_TOP_BUF_DEPTH, 0x3000); + regmap_write(top_regs, SUN60I_DE35_TOP_GLB_CTL, 0x1); + regmap_write(top_regs, SUN60I_DE35_TOP_AUTO_CLK, 0x1); + } else { + /* Enable the mixer */ + regmap_write(top_regs, SUN8I_MIXER_GLOBAL_CTL, + SUN8I_MIXER_GLOBAL_CTL_RT_EN); - if (mixer->cfg->de_type == SUN8I_MIXER_DE33) - regmap_write(top_regs, SUN50I_MIXER_GLOBAL_CLK, 1); + if (mixer->cfg->de_type == SUN8I_MIXER_DE33) + regmap_write(top_regs, SUN50I_MIXER_GLOBAL_CLK, 1); + } /* Set background color to black */ regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_BKCOLOR(base), @@ -533,25 +583,28 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, void __iomem *regs; int i, ret; - /* - * The mixer uses single 32-bit register to store memory - * addresses, so that it cannot deal with 64-bit memory - * addresses. - * Restrict the DMA mask so that the mixer won't be - * allocated some memory that is too high. - */ - ret = dma_set_mask(dev, DMA_BIT_MASK(32)); - if (ret) { - dev_err(dev, "Cannot do 32-bit DMA.\n"); - return ret; - } - mixer = devm_kzalloc_obj(dev, *mixer); if (!mixer) return -ENOMEM; dev_set_drvdata(dev, mixer); mixer->engine.node = dev->of_node; + mixer->cfg = of_device_get_match_data(dev); + if (!mixer->cfg) + return -EINVAL; + + /* + * DE2/DE3/DE33 mixers use 32-bit DMA addresses; DE3.5 supports 40-bit + * addresses via RCQ and layer top_haddr registers. + */ + ret = dma_set_mask_and_coherent(dev, + mixer->cfg->de_type == SUN8I_MIXER_DE35 ? + DMA_BIT_MASK(40) : DMA_BIT_MASK(32)); + if (ret) { + dev_err(dev, "Cannot set DMA mask.\n"); + return ret; + } + /* * This assume we have the same DMA constraints for all our the * devices in our pipeline (all the backends, but also the @@ -578,11 +631,8 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, */ mixer->engine.id = sun8i_mixer_of_get_id(dev->of_node); - mixer->cfg = of_device_get_match_data(dev); - if (!mixer->cfg) - return -EINVAL; - - if (mixer->cfg->de_type == SUN8I_MIXER_DE33) { + if (mixer->cfg->de_type == SUN8I_MIXER_DE33 || + mixer->cfg->de_type == SUN8I_MIXER_DE35) { /* * The original DE33 binding described planes as part of * the mixer, which can't work with more than one mixer. @@ -592,7 +642,7 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, if (of_property_match_string(dev->of_node, "reg-names", "layers") >= 0 || !of_property_present(dev->of_node, "allwinner,planes")) return dev_err_probe(dev, -EINVAL, - "Unsupported DE33 mixer binding, please update the device tree\n"); + "Unsupported DE33/DE35 mixer binding, please update the device tree\n"); mixer->engine.ops = &sun50i_engine_ops; } else { @@ -603,7 +653,14 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, if (IS_ERR(regs)) return PTR_ERR(regs); - if (mixer->cfg->de_type == SUN8I_MIXER_DE33) + if (mixer->cfg->de_type == SUN8I_MIXER_DE35) + mixer->engine.regs = + sun60i_de35_rcq_regmap_init(dev, regs, 0x280000, + sun60i_de35_mixer_rcq_blocks, + ARRAY_SIZE(sun60i_de35_mixer_rcq_blocks), + &sun50i_mixer33_regmap_config, + &mixer->rcq); + else if (mixer->cfg->de_type == SUN8I_MIXER_DE33) mixer->engine.regs = devm_regmap_init_mmio(dev, regs, &sun50i_mixer33_regmap_config); else @@ -614,36 +671,79 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, return PTR_ERR(mixer->engine.regs); } - if (mixer->cfg->de_type == SUN8I_MIXER_DE33) { + if (mixer->cfg->de_type == SUN8I_MIXER_DE33 || + mixer->cfg->de_type == SUN8I_MIXER_DE35) { + const struct regmap_config *top_cfg; + regs = devm_platform_ioremap_resource_byname(pdev, "top"); if (IS_ERR(regs)) return PTR_ERR(regs); - mixer->top_regs = devm_regmap_init_mmio(dev, regs, - &sun8i_top_regmap_config); + top_cfg = mixer->cfg->de_type == SUN8I_MIXER_DE35 ? + &sun60i_de35_top_regmap_config : + &sun8i_top_regmap_config; + mixer->top_regs = devm_regmap_init_mmio(dev, regs, top_cfg); if (IS_ERR(mixer->top_regs)) { dev_err(dev, "Couldn't create the top regmap\n"); return PTR_ERR(mixer->top_regs); } } - mixer->reset = devm_reset_control_get(dev, NULL); + if (mixer->cfg->de_type == SUN8I_MIXER_DE35) { + size_t heads_size; + + mixer->rcq_max_heads = 32; + heads_size = mixer->rcq_max_heads * sizeof(*mixer->rcq_heads); + mixer->rcq_heads = dmam_alloc_coherent(dev, heads_size, + &mixer->rcq_heads_dma, + GFP_KERNEL); + if (!mixer->rcq_heads) + return -ENOMEM; + } + + pm_runtime_enable(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret < 0) + goto err_pm_disable; + + mixer->reset = devm_reset_control_array_get_exclusive(dev); if (IS_ERR(mixer->reset)) { dev_err(dev, "Couldn't get our reset line\n"); - return PTR_ERR(mixer->reset); + ret = PTR_ERR(mixer->reset); + goto err_pm_put; } ret = reset_control_deassert(mixer->reset); if (ret) { dev_err(dev, "Couldn't deassert our reset line\n"); - return ret; + goto err_pm_put; + } + + mixer->ahb_clk = devm_clk_get_optional(dev, "ahb"); + if (IS_ERR(mixer->ahb_clk)) { + ret = PTR_ERR(mixer->ahb_clk); + goto err_assert_reset; } + ret = clk_prepare_enable(mixer->ahb_clk); + if (ret) + goto err_assert_reset; + + mixer->mbus_clk = devm_clk_get_optional(dev, "mbus"); + if (IS_ERR(mixer->mbus_clk)) { + ret = PTR_ERR(mixer->mbus_clk); + goto err_disable_ahb_clk; + } + + ret = clk_prepare_enable(mixer->mbus_clk); + if (ret) + goto err_disable_ahb_clk; + mixer->bus_clk = devm_clk_get(dev, "bus"); if (IS_ERR(mixer->bus_clk)) { dev_err(dev, "Couldn't get the mixer bus clock\n"); ret = PTR_ERR(mixer->bus_clk); - goto err_assert_reset; + goto err_disable_mbus_clk; } clk_prepare_enable(mixer->bus_clk); @@ -664,7 +764,8 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, clk_prepare_enable(mixer->mod_clk); - if (mixer->cfg->de_type == SUN8I_MIXER_DE33) { + if (mixer->cfg->de_type == SUN8I_MIXER_DE33 || + mixer->cfg->de_type == SUN8I_MIXER_DE35) { struct platform_device *planes_pdev; struct device_node *np; @@ -729,14 +830,23 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, return 0; err_put_device: - if (mixer->cfg->de_type == SUN8I_MIXER_DE33) + if (mixer->cfg->de_type == SUN8I_MIXER_DE33 || + mixer->cfg->de_type == SUN8I_MIXER_DE35) put_device(mixer->planes_dev); err_disable_mod_clk: clk_disable_unprepare(mixer->mod_clk); err_disable_bus_clk: clk_disable_unprepare(mixer->bus_clk); +err_disable_mbus_clk: + clk_disable_unprepare(mixer->mbus_clk); +err_disable_ahb_clk: + clk_disable_unprepare(mixer->ahb_clk); err_assert_reset: reset_control_assert(mixer->reset); +err_pm_put: + pm_runtime_put_sync(dev); +err_pm_disable: + pm_runtime_disable(dev); return ret; } @@ -747,12 +857,17 @@ static void sun8i_mixer_unbind(struct device *dev, struct device *master, list_del(&mixer->engine.list); - if (mixer->cfg->de_type == SUN8I_MIXER_DE33) + if (mixer->cfg->de_type == SUN8I_MIXER_DE33 || + mixer->cfg->de_type == SUN8I_MIXER_DE35) put_device(mixer->planes_dev); clk_disable_unprepare(mixer->mod_clk); clk_disable_unprepare(mixer->bus_clk); + clk_disable_unprepare(mixer->mbus_clk); + clk_disable_unprepare(mixer->ahb_clk); reset_control_assert(mixer->reset); + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); } static const struct component_ops sun8i_mixer_ops = { @@ -935,6 +1050,11 @@ static const struct sun8i_mixer_cfg sun50i_h616_mixer0_cfg = { .mod_rate = 600000000, }; +static const struct sun8i_mixer_cfg sun60i_a733_mixer0_cfg = { + .de_type = SUN8I_MIXER_DE35, + .mod_rate = 600000000, +}; + static const struct of_device_id sun8i_mixer_of_table[] = { { .compatible = "allwinner,sun8i-a83t-de2-mixer-0", @@ -984,6 +1104,10 @@ static const struct of_device_id sun8i_mixer_of_table[] = { .compatible = "allwinner,sun50i-h616-de33-mixer-0", .data = &sun50i_h616_mixer0_cfg, }, + { + .compatible = "allwinner,sun60i-a733-de35-mixer-0", + .data = &sun60i_a733_mixer0_cfg, + }, { } }; MODULE_DEVICE_TABLE(of, sun8i_mixer_of_table); diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c index f9c7f28f9fa2..a95e89b77f32 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c @@ -100,7 +100,8 @@ static void sun8i_ui_layer_update_coord(struct sun8i_layer *layer, hscale = state->src_w / state->crtc_w; vscale = state->src_h / state->crtc_h; - if (layer->cfg->de_type == SUN8I_MIXER_DE33) { + if (layer->cfg->de_type == SUN8I_MIXER_DE33 || + layer->cfg->de_type == SUN8I_MIXER_DE35) { sun8i_vi_scaler_setup(layer, src_w, src_h, dst_w, dst_h, hscale, vscale, hphase, vphase, state->fb->format); @@ -112,7 +113,8 @@ static void sun8i_ui_layer_update_coord(struct sun8i_layer *layer, } } else { DRM_DEBUG_DRIVER("HW scaling is not needed\n"); - if (layer->cfg->de_type == SUN8I_MIXER_DE33) + if (layer->cfg->de_type == SUN8I_MIXER_DE33 || + layer->cfg->de_type == SUN8I_MIXER_DE35) sun8i_vi_scaler_enable(layer, false); else sun8i_ui_scaler_enable(layer, false); @@ -143,6 +145,12 @@ static void sun8i_ui_layer_update_buffer(struct sun8i_layer *layer, regmap_write(layer->regs, SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR(ch_base, layer->overlay), lower_32_bits(dma_addr)); + if (layer->cfg->de_type == SUN8I_MIXER_DE35) + regmap_update_bits(layer->regs, + SUN8I_MIXER_CHAN_UI_TOP_HADDR(ch_base), + 0xff << (8 * layer->overlay), + (upper_32_bits(dma_addr) & 0xff) << + (8 * layer->overlay)); } static int sun8i_ui_layer_atomic_check(struct drm_plane *plane, diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c index 4d3fc03f9877..e1c22e0ffc92 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c @@ -222,6 +222,12 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_layer *layer, SUN8I_MIXER_CHAN_VI_LAYER_TOP_LADDR(ch_base, layer->overlay, i), lower_32_bits(dma_addr)); + if (layer->cfg->de_type == SUN8I_MIXER_DE35) + regmap_update_bits(layer->regs, + SUN8I_MIXER_CHAN_VI_TOP_HADDR(ch_base, i), + 0xff << (8 * layer->overlay), + (upper_32_bits(dma_addr) & 0xff) << + (8 * layer->overlay)); } } diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.h b/drivers/gpu/drm/sun4i/sun8i_vi_layer.h index 29cc5573691f..43f62c3ad6fd 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.h +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.h @@ -18,6 +18,8 @@ ((base) + 0x30 * (layer) + 0xc + 4 * (plane)) #define SUN8I_MIXER_CHAN_VI_LAYER_TOP_LADDR(base, layer, plane) \ ((base) + 0x30 * (layer) + 0x18 + 4 * (plane)) +#define SUN8I_MIXER_CHAN_VI_TOP_HADDR(base, plane) \ + ((base) + 0xd0 + 4 * (plane)) #define SUN8I_MIXER_CHAN_VI_OVL_SIZE(base) \ ((base) + 0xe8) #define SUN8I_MIXER_CHAN_VI_HDS_Y(base) \ diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_scaler.c b/drivers/gpu/drm/sun4i/sun8i_vi_scaler.c index a5cc99981006..428df62e1079 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_scaler.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_scaler.c @@ -835,7 +835,8 @@ static const u32 bicubic4coefftab32[480] = { static u32 sun8i_vi_scaler_base(struct sun8i_layer *layer) { - if (layer->cfg->de_type == SUN8I_MIXER_DE33) + if (layer->cfg->de_type == SUN8I_MIXER_DE33 || + layer->cfg->de_type == SUN8I_MIXER_DE35) return DE33_VI_SCALER_UNIT_BASE + DE33_CH_SIZE * layer->channel; else if (layer->cfg->de_type == SUN8I_MIXER_DE3) -- 2.53.0
