Lines Matching +full:static +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2013-2016 Altera Corporation, All Rights Reserved.
8 * fpga: altera-hps2fpga: fix HPS2FPGA bridge visibility to L3 masters
9 * Signed-off-by: Anatolij Gustschin <agust@denx.de>
19 * reprogramming the FPGA and re-enabled after the FPGA has been programmed.
23 #include <linux/fpga/fpga-bridge.h>
49 static int alt_hps2fpga_enable_show(struct fpga_bridge *bridge) in alt_hps2fpga_enable_show()
51 struct altera_hps2fpga_data *priv = bridge->priv; in alt_hps2fpga_enable_show()
53 return reset_control_status(priv->bridge_reset); in alt_hps2fpga_enable_show()
57 static unsigned int l3_remap_shadow;
58 static DEFINE_SPINLOCK(l3_remap_lock);
60 static int _alt_hps2fpga_enable_set(struct altera_hps2fpga_data *priv, in _alt_hps2fpga_enable_set()
61 bool enable) in _alt_hps2fpga_enable_set() argument
67 if (enable) in _alt_hps2fpga_enable_set()
68 ret = reset_control_deassert(priv->bridge_reset); in _alt_hps2fpga_enable_set()
70 ret = reset_control_assert(priv->bridge_reset); in _alt_hps2fpga_enable_set()
75 if (priv->remap_mask) { in _alt_hps2fpga_enable_set()
79 if (enable) in _alt_hps2fpga_enable_set()
80 l3_remap_shadow |= priv->remap_mask; in _alt_hps2fpga_enable_set()
82 l3_remap_shadow &= ~priv->remap_mask; in _alt_hps2fpga_enable_set()
84 ret = regmap_write(priv->l3reg, ALT_L3_REMAP_OFST, in _alt_hps2fpga_enable_set()
92 static int alt_hps2fpga_enable_set(struct fpga_bridge *bridge, bool enable) in alt_hps2fpga_enable_set() argument
94 return _alt_hps2fpga_enable_set(bridge->priv, enable); in alt_hps2fpga_enable_set()
97 static const struct fpga_bridge_ops altera_hps2fpga_br_ops = {
102 static struct altera_hps2fpga_data hps2fpga_data = {
107 static struct altera_hps2fpga_data lwhps2fpga_data = {
112 static struct altera_hps2fpga_data fpga2hps_data = {
116 static const struct of_device_id altera_fpga_of_match[] = {
117 { .compatible = "altr,socfpga-hps2fpga-bridge",
119 { .compatible = "altr,socfpga-lwhps2fpga-bridge",
121 { .compatible = "altr,socfpga-fpga2hps-bridge",
126 static int alt_fpga_bridge_probe(struct platform_device *pdev) in alt_fpga_bridge_probe()
128 struct device *dev = &pdev->dev; in alt_fpga_bridge_probe()
132 u32 enable; in alt_fpga_bridge_probe() local
138 return -ENODEV; in alt_fpga_bridge_probe()
141 priv = (struct altera_hps2fpga_data *)of_id->data; in alt_fpga_bridge_probe()
143 priv->bridge_reset = of_reset_control_get_exclusive_by_index(dev->of_node, in alt_fpga_bridge_probe()
145 if (IS_ERR(priv->bridge_reset)) { in alt_fpga_bridge_probe()
146 dev_err(dev, "Could not get %s reset control\n", priv->name); in alt_fpga_bridge_probe()
147 return PTR_ERR(priv->bridge_reset); in alt_fpga_bridge_probe()
150 if (priv->remap_mask) { in alt_fpga_bridge_probe()
151 priv->l3reg = syscon_regmap_lookup_by_compatible("altr,l3regs"); in alt_fpga_bridge_probe()
152 if (IS_ERR(priv->l3reg)) { in alt_fpga_bridge_probe()
154 return PTR_ERR(priv->l3reg); in alt_fpga_bridge_probe()
158 priv->clk = devm_clk_get(dev, NULL); in alt_fpga_bridge_probe()
159 if (IS_ERR(priv->clk)) { in alt_fpga_bridge_probe()
161 return PTR_ERR(priv->clk); in alt_fpga_bridge_probe()
164 ret = clk_prepare_enable(priv->clk); in alt_fpga_bridge_probe()
166 dev_err(dev, "could not enable clock\n"); in alt_fpga_bridge_probe()
167 return -EBUSY; in alt_fpga_bridge_probe()
170 if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) { in alt_fpga_bridge_probe()
171 if (enable > 1) { in alt_fpga_bridge_probe()
172 dev_warn(dev, "invalid bridge-enable %u > 1\n", enable); in alt_fpga_bridge_probe()
175 (enable ? "enabling" : "disabling")); in alt_fpga_bridge_probe()
177 ret = _alt_hps2fpga_enable_set(priv, enable); in alt_fpga_bridge_probe()
183 br = devm_fpga_bridge_create(dev, priv->name, in alt_fpga_bridge_probe()
186 ret = -ENOMEM; in alt_fpga_bridge_probe()
199 clk_disable_unprepare(priv->clk); in alt_fpga_bridge_probe()
204 static int alt_fpga_bridge_remove(struct platform_device *pdev) in alt_fpga_bridge_remove()
207 struct altera_hps2fpga_data *priv = bridge->priv; in alt_fpga_bridge_remove()
211 clk_disable_unprepare(priv->clk); in alt_fpga_bridge_remove()
218 static struct platform_driver alt_fpga_bridge_driver = {