static int alt_fpga_bridge_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct altera_hps2fpga_data *priv; const struct of_device_id *of_id; u32 enable; int ret; of_id = of_match_device(altera_fpga_of_match, dev); priv = (struct altera_hps2fpga_data *)of_id->data; priv->bridge_reset = of_reset_control_get_by_index(dev->of_node, 0); if (IS_ERR(priv->bridge_reset)) { dev_err(dev, "Could not get %s reset control\n", priv->name); return PTR_ERR(priv->bridge_reset); } if (priv->remap_mask) { priv->l3reg = syscon_regmap_lookup_by_compatible("altr,l3regs"); if (IS_ERR(priv->l3reg)) { dev_err(dev, "regmap for altr,l3regs lookup failed\n"); return PTR_ERR(priv->l3reg); } } priv->clk = devm_clk_get(dev, NULL); if (IS_ERR(priv->clk)) { dev_err(dev, "no clock specified\n"); return PTR_ERR(priv->clk); } ret = clk_prepare_enable(priv->clk); if (ret) { dev_err(dev, "could not enable clock\n"); return -EBUSY; } spin_lock_init(&l3_remap_lock); if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) { if (enable > 1) { dev_warn(dev, "invalid bridge-enable %u > 1\n", enable); } else { dev_info(dev, "%s bridge\n", (enable ? "enabling" : "disabling")); ret = _alt_hps2fpga_enable_set(priv, enable); if (ret) { fpga_bridge_unregister(&pdev->dev); return ret; } } } return fpga_bridge_register(dev, priv->name, &altera_hps2fpga_br_ops, priv); }
static int alt_fpga_bridge_remove(struct platform_device *pdev) { struct fpga_bridge *bridge = platform_get_drvdata(pdev); struct altera_hps2fpga_data *priv = bridge->priv; fpga_bridge_unregister(&pdev->dev); clk_disable_unprepare(priv->clk); return 0; }
static int fme_br_remove(struct platform_device *pdev) { struct fpga_bridge *br = platform_get_drvdata(pdev); struct fme_br_priv *priv = br->priv; fpga_bridge_unregister(br); if (priv->port_pdev) put_device(&priv->port_pdev->dev); if (priv->port_ops) dfl_fpga_port_ops_put(priv->port_ops); return 0; }