Lines Matching +full:ast2500 +full:- +full:scu

1 // SPDX-License-Identifier: GPL-2.0+
5 #include <linux/dma-mapping.h>
37 * The AST2500 supports a total of 3 output paths:
56 * The driver was written with the 'AST2500 Software Programming Guide' v17,
61 u32 dac_reg; /* DAC register in SCU */
63 u32 vga_scratch_reg; /* VGA scratch register in SCU */
93 { .compatible = "aspeed,ast2400-gfx", .data = &ast2400_config },
94 { .compatible = "aspeed,ast2500-gfx", .data = &ast2500_config },
95 { .compatible = "aspeed,ast2600-gfx", .data = &ast2600_config },
114 drm->mode_config.min_width = 0; in aspeed_gfx_setup_mode_config()
115 drm->mode_config.min_height = 0; in aspeed_gfx_setup_mode_config()
116 drm->mode_config.max_width = 800; in aspeed_gfx_setup_mode_config()
117 drm->mode_config.max_height = 600; in aspeed_gfx_setup_mode_config()
118 drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs; in aspeed_gfx_setup_mode_config()
129 reg = readl(priv->base + CRT_CTRL1); in aspeed_gfx_irq_handler()
132 drm_crtc_handle_vblank(&priv->pipe.crtc); in aspeed_gfx_irq_handler()
133 writel(reg, priv->base + priv->int_clr_reg); in aspeed_gfx_irq_handler()
142 struct platform_device *pdev = to_platform_device(drm->dev); in aspeed_gfx_load()
144 struct device_node *np = pdev->dev.of_node; in aspeed_gfx_load()
150 priv->base = devm_ioremap_resource(drm->dev, res); in aspeed_gfx_load()
151 if (IS_ERR(priv->base)) in aspeed_gfx_load()
152 return PTR_ERR(priv->base); in aspeed_gfx_load()
154 config = device_get_match_data(&pdev->dev); in aspeed_gfx_load()
156 return -EINVAL; in aspeed_gfx_load()
158 priv->dac_reg = config->dac_reg; in aspeed_gfx_load()
159 priv->int_clr_reg = config->int_clear_reg; in aspeed_gfx_load()
160 priv->vga_scratch_reg = config->vga_scratch_reg; in aspeed_gfx_load()
161 priv->throd_val = config->throd_val; in aspeed_gfx_load()
162 priv->scan_line_max = config->scan_line_max; in aspeed_gfx_load()
164 priv->scu = syscon_regmap_lookup_by_phandle(np, "syscon"); in aspeed_gfx_load()
165 if (IS_ERR(priv->scu)) { in aspeed_gfx_load()
166 priv->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2500-scu"); in aspeed_gfx_load()
167 if (IS_ERR(priv->scu)) { in aspeed_gfx_load()
168 dev_err(&pdev->dev, "failed to find SCU regmap\n"); in aspeed_gfx_load()
169 return PTR_ERR(priv->scu); in aspeed_gfx_load()
173 ret = of_reserved_mem_device_init(drm->dev); in aspeed_gfx_load()
175 dev_err(&pdev->dev, in aspeed_gfx_load()
180 ret = dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)); in aspeed_gfx_load()
182 dev_err(&pdev->dev, "failed to set DMA mask: %d\n", ret); in aspeed_gfx_load()
186 priv->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); in aspeed_gfx_load()
187 if (IS_ERR(priv->rst)) { in aspeed_gfx_load()
188 dev_err(&pdev->dev, in aspeed_gfx_load()
190 return PTR_ERR(priv->rst); in aspeed_gfx_load()
192 reset_control_deassert(priv->rst); in aspeed_gfx_load()
194 priv->clk = devm_clk_get(drm->dev, NULL); in aspeed_gfx_load()
195 if (IS_ERR(priv->clk)) { in aspeed_gfx_load()
196 dev_err(&pdev->dev, in aspeed_gfx_load()
198 return PTR_ERR(priv->clk); in aspeed_gfx_load()
200 clk_prepare_enable(priv->clk); in aspeed_gfx_load()
203 writel(0, priv->base + CRT_CTRL1); in aspeed_gfx_load()
204 writel(0, priv->base + CRT_CTRL2); in aspeed_gfx_load()
212 dev_err(drm->dev, "Failed to initialise vblank\n"); in aspeed_gfx_load()
218 dev_err(drm->dev, "Failed to create outputs\n"); in aspeed_gfx_load()
224 dev_err(drm->dev, "Cannot setup simple display pipe\n"); in aspeed_gfx_load()
228 ret = devm_request_irq(drm->dev, platform_get_irq(pdev, 0), in aspeed_gfx_load()
231 dev_err(drm->dev, "Failed to install IRQ handler\n"); in aspeed_gfx_load()
251 .name = "aspeed-gfx-drm",
270 return -EINVAL; in dac_mux_store()
272 rc = regmap_update_bits(priv->scu, priv->dac_reg, 0x30000, val << 16); in dac_mux_store()
285 rc = regmap_read(priv->scu, priv->dac_reg, &reg); in dac_mux_show()
300 rc = regmap_read(priv->scu, priv->vga_scratch_reg, &reg); in vga_pw_show()
323 priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver, in aspeed_gfx_probe()
328 ret = aspeed_gfx_load(&priv->drm); in aspeed_gfx_probe()
334 ret = sysfs_create_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group); in aspeed_gfx_probe()
338 ret = drm_dev_register(&priv->drm, 0); in aspeed_gfx_probe()
342 drm_fbdev_dma_setup(&priv->drm, 32); in aspeed_gfx_probe()
346 sysfs_remove_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group); in aspeed_gfx_probe()
347 aspeed_gfx_unload(&priv->drm); in aspeed_gfx_probe()
356 sysfs_remove_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group); in aspeed_gfx_remove()