static int sti_hqvdp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *vtg_np; struct sti_hqvdp *hqvdp; struct resource *res; DRM_DEBUG_DRIVER("\n"); hqvdp = devm_kzalloc(dev, sizeof(*hqvdp), GFP_KERNEL); if (!hqvdp) { DRM_ERROR("Failed to allocate HQVDP context\n"); return -ENOMEM; } hqvdp->dev = dev; /* Get Memory resources */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { DRM_ERROR("Get memory resource failed\n"); return -ENXIO; } hqvdp->regs = devm_ioremap(dev, res->start, resource_size(res)); if (hqvdp->regs == NULL) { DRM_ERROR("Register mapping failed\n"); return -ENXIO; } /* Get clock resources */ hqvdp->clk = devm_clk_get(dev, "hqvdp"); hqvdp->clk_pix_main = devm_clk_get(dev, "pix_main"); if (IS_ERR(hqvdp->clk) || IS_ERR(hqvdp->clk_pix_main)) { DRM_ERROR("Cannot get clocks\n"); return -ENXIO; } /* Get reset resources */ hqvdp->reset = devm_reset_control_get(dev, "hqvdp"); if (!IS_ERR(hqvdp->reset)) reset_control_deassert(hqvdp->reset); vtg_np = of_parse_phandle(pdev->dev.of_node, "st,vtg", 0); if (vtg_np) hqvdp->vtg = of_vtg_find(vtg_np); of_node_put(vtg_np); platform_set_drvdata(pdev, hqvdp); return component_add(&pdev->dev, &sti_hqvdp_ops); }
static int sti_compositor_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct device_node *vtg_np; struct sti_compositor *compo; struct resource *res; compo = devm_kzalloc(dev, sizeof(*compo), GFP_KERNEL); if (!compo) { DRM_ERROR("Failed to allocate compositor context\n"); return -ENOMEM; } compo->dev = dev; compo->vtg_vblank_nb.notifier_call = sti_crtc_vblank_cb; /* populate data structure depending on compatibility */ BUG_ON(!of_match_node(compositor_of_match, np)->data); memcpy(&compo->data, of_match_node(compositor_of_match, np)->data, sizeof(struct sti_compositor_data)); /* Get Memory ressources */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { DRM_ERROR("Get memory resource failed\n"); return -ENXIO; } compo->regs = devm_ioremap(dev, res->start, resource_size(res)); if (compo->regs == NULL) { DRM_ERROR("Register mapping failed\n"); return -ENXIO; } /* Get clock resources */ compo->clk_compo_main = devm_clk_get(dev, "compo_main"); if (IS_ERR(compo->clk_compo_main)) { DRM_ERROR("Cannot get compo_main clock\n"); return PTR_ERR(compo->clk_compo_main); } compo->clk_compo_aux = devm_clk_get(dev, "compo_aux"); if (IS_ERR(compo->clk_compo_aux)) { DRM_ERROR("Cannot get compo_aux clock\n"); return PTR_ERR(compo->clk_compo_aux); } compo->clk_pix_main = devm_clk_get(dev, "pix_main"); if (IS_ERR(compo->clk_pix_main)) { DRM_ERROR("Cannot get pix_main clock\n"); return PTR_ERR(compo->clk_pix_main); } compo->clk_pix_aux = devm_clk_get(dev, "pix_aux"); if (IS_ERR(compo->clk_pix_aux)) { DRM_ERROR("Cannot get pix_aux clock\n"); return PTR_ERR(compo->clk_pix_aux); } /* Get reset resources */ compo->rst_main = devm_reset_control_get(dev, "compo-main"); /* Take compo main out of reset */ if (!IS_ERR(compo->rst_main)) reset_control_deassert(compo->rst_main); compo->rst_aux = devm_reset_control_get(dev, "compo-aux"); /* Take compo aux out of reset */ if (!IS_ERR(compo->rst_aux)) reset_control_deassert(compo->rst_aux); vtg_np = of_parse_phandle(pdev->dev.of_node, "st,vtg", 0); if (vtg_np) compo->vtg_main = of_vtg_find(vtg_np); vtg_np = of_parse_phandle(pdev->dev.of_node, "st,vtg", 1); if (vtg_np) compo->vtg_aux = of_vtg_find(vtg_np); platform_set_drvdata(pdev, compo); return component_add(&pdev->dev, &sti_compositor_ops); }