Lines Matching +full:ast2600 +full:- +full:scu
1 // SPDX-License-Identifier: GPL-2.0+
5 #include <linux/dma-mapping.h>
62 u32 dac_reg; /* DAC register in SCU */
64 u32 vga_scratch_reg; /* VGA scratch register in SCU */
94 { .compatible = "aspeed,ast2400-gfx", .data = &ast2400_config },
95 { .compatible = "aspeed,ast2500-gfx", .data = &ast2500_config },
96 { .compatible = "aspeed,ast2600-gfx", .data = &ast2600_config },
115 drm->mode_config.min_width = 0; in aspeed_gfx_setup_mode_config()
116 drm->mode_config.min_height = 0; in aspeed_gfx_setup_mode_config()
117 drm->mode_config.max_width = 800; in aspeed_gfx_setup_mode_config()
118 drm->mode_config.max_height = 600; in aspeed_gfx_setup_mode_config()
119 drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs; in aspeed_gfx_setup_mode_config()
130 reg = readl(priv->base + CRT_CTRL1); in aspeed_gfx_irq_handler()
133 drm_crtc_handle_vblank(&priv->pipe.crtc); in aspeed_gfx_irq_handler()
134 writel(reg, priv->base + priv->int_clr_reg); in aspeed_gfx_irq_handler()
143 struct platform_device *pdev = to_platform_device(drm->dev); in aspeed_gfx_load()
145 struct device_node *np = pdev->dev.of_node; in aspeed_gfx_load()
152 priv->base = devm_ioremap_resource(drm->dev, res); in aspeed_gfx_load()
153 if (IS_ERR(priv->base)) in aspeed_gfx_load()
154 return PTR_ERR(priv->base); in aspeed_gfx_load()
156 match = of_match_device(aspeed_gfx_match, &pdev->dev); in aspeed_gfx_load()
158 return -EINVAL; in aspeed_gfx_load()
159 config = match->data; in aspeed_gfx_load()
161 priv->dac_reg = config->dac_reg; in aspeed_gfx_load()
162 priv->int_clr_reg = config->int_clear_reg; in aspeed_gfx_load()
163 priv->vga_scratch_reg = config->vga_scratch_reg; in aspeed_gfx_load()
164 priv->throd_val = config->throd_val; in aspeed_gfx_load()
165 priv->scan_line_max = config->scan_line_max; in aspeed_gfx_load()
167 priv->scu = syscon_regmap_lookup_by_phandle(np, "syscon"); in aspeed_gfx_load()
168 if (IS_ERR(priv->scu)) { in aspeed_gfx_load()
169 priv->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2500-scu"); in aspeed_gfx_load()
170 if (IS_ERR(priv->scu)) { in aspeed_gfx_load()
171 dev_err(&pdev->dev, "failed to find SCU regmap\n"); in aspeed_gfx_load()
172 return PTR_ERR(priv->scu); in aspeed_gfx_load()
176 ret = of_reserved_mem_device_init(drm->dev); in aspeed_gfx_load()
178 dev_err(&pdev->dev, in aspeed_gfx_load()
183 ret = dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)); in aspeed_gfx_load()
185 dev_err(&pdev->dev, "failed to set DMA mask: %d\n", ret); in aspeed_gfx_load()
189 priv->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); in aspeed_gfx_load()
190 if (IS_ERR(priv->rst)) { in aspeed_gfx_load()
191 dev_err(&pdev->dev, in aspeed_gfx_load()
193 return PTR_ERR(priv->rst); in aspeed_gfx_load()
195 reset_control_deassert(priv->rst); in aspeed_gfx_load()
197 priv->clk = devm_clk_get(drm->dev, NULL); in aspeed_gfx_load()
198 if (IS_ERR(priv->clk)) { in aspeed_gfx_load()
199 dev_err(&pdev->dev, in aspeed_gfx_load()
201 return PTR_ERR(priv->clk); in aspeed_gfx_load()
203 clk_prepare_enable(priv->clk); in aspeed_gfx_load()
206 writel(0, priv->base + CRT_CTRL1); in aspeed_gfx_load()
207 writel(0, priv->base + CRT_CTRL2); in aspeed_gfx_load()
215 dev_err(drm->dev, "Failed to initialise vblank\n"); in aspeed_gfx_load()
221 dev_err(drm->dev, "Failed to create outputs\n"); in aspeed_gfx_load()
227 dev_err(drm->dev, "Cannot setup simple display pipe\n"); in aspeed_gfx_load()
231 ret = devm_request_irq(drm->dev, platform_get_irq(pdev, 0), in aspeed_gfx_load()
234 dev_err(drm->dev, "Failed to install IRQ handler\n"); in aspeed_gfx_load()
254 .name = "aspeed-gfx-drm",
273 return -EINVAL; in dac_mux_store()
275 rc = regmap_update_bits(priv->scu, priv->dac_reg, 0x30000, val << 16); in dac_mux_store()
288 rc = regmap_read(priv->scu, priv->dac_reg, ®); in dac_mux_show()
303 rc = regmap_read(priv->scu, priv->vga_scratch_reg, ®); in vga_pw_show()
326 priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver, in aspeed_gfx_probe()
331 ret = aspeed_gfx_load(&priv->drm); in aspeed_gfx_probe()
337 ret = sysfs_create_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group); in aspeed_gfx_probe()
341 ret = drm_dev_register(&priv->drm, 0); in aspeed_gfx_probe()
345 drm_fbdev_generic_setup(&priv->drm, 32); in aspeed_gfx_probe()
349 sysfs_remove_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group); in aspeed_gfx_probe()
350 aspeed_gfx_unload(&priv->drm); in aspeed_gfx_probe()
359 sysfs_remove_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group); in aspeed_gfx_remove()