Lines Matching +full:clk +full:- +full:mgr

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2015-2016 Altera Corporation
7 #include <linux/clk.h>
10 #include <linux/fpga/fpga-mgr.h>
65 * struct a10_fpga_priv - private data for fpga manager
68 * @clk: clock
73 struct clk *clk; member
123 regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_02_OFST, in socfpga_a10_fpga_set_cfg_width()
133 regmap_write(priv->regmap, A10_FPGAMGR_DCLKSTAT_OFST, in socfpga_a10_fpga_generate_dclks()
137 regmap_write(priv->regmap, A10_FPGAMGR_DCLKCNT_OFST, count); in socfpga_a10_fpga_generate_dclks()
140 regmap_read_poll_timeout(priv->regmap, A10_FPGAMGR_DCLKSTAT_OFST, val, in socfpga_a10_fpga_generate_dclks()
144 regmap_write(priv->regmap, A10_FPGAMGR_DCLKSTAT_OFST, in socfpga_a10_fpga_generate_dclks()
154 return -EINVAL; in socfpga_a10_fpga_encrypted()
163 return -EINVAL; in socfpga_a10_fpga_compressed()
203 static int socfpga_a10_fpga_set_cdratio(struct fpga_manager *mgr, in socfpga_a10_fpga_set_cdratio() argument
207 struct a10_fpga_priv *priv = mgr->priv; in socfpga_a10_fpga_set_cdratio()
213 return -EINVAL; in socfpga_a10_fpga_set_cdratio()
217 return -EINVAL; in socfpga_a10_fpga_set_cdratio()
221 regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_02_OFST, in socfpga_a10_fpga_set_cdratio()
232 regmap_read(priv->regmap, A10_FPGAMGR_IMGCFG_STAT_OFST, &val); in socfpga_a10_fpga_read_stat()
245 return -EINVAL; in socfpga_a10_fpga_wait_for_pr_ready()
251 return -ETIMEDOUT; in socfpga_a10_fpga_wait_for_pr_ready()
262 return -EINVAL; in socfpga_a10_fpga_wait_for_pr_done()
268 return -ETIMEDOUT; in socfpga_a10_fpga_wait_for_pr_done()
272 static int socfpga_a10_fpga_write_init(struct fpga_manager *mgr, in socfpga_a10_fpga_write_init() argument
276 struct a10_fpga_priv *priv = mgr->priv; in socfpga_a10_fpga_write_init()
281 if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) in socfpga_a10_fpga_write_init()
284 return -EINVAL; in socfpga_a10_fpga_write_init()
291 dev_dbg(&mgr->dev, "Fail: invalid msel=%d\n", msel); in socfpga_a10_fpga_write_init()
292 return -EINVAL; in socfpga_a10_fpga_write_init()
300 return -EINVAL; in socfpga_a10_fpga_write_init()
306 ret = socfpga_a10_fpga_set_cdratio(mgr, cfg_width, buf, count); in socfpga_a10_fpga_write_init()
314 regmap_write(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_01_OFST, in socfpga_a10_fpga_write_init()
318 regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_02_OFST, in socfpga_a10_fpga_write_init()
326 regmap_write(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_00_OFST, in socfpga_a10_fpga_write_init()
333 regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_01_OFST, in socfpga_a10_fpga_write_init()
340 regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_01_OFST, in socfpga_a10_fpga_write_init()
354 static int socfpga_a10_fpga_write(struct fpga_manager *mgr, const char *buf, in socfpga_a10_fpga_write() argument
357 struct a10_fpga_priv *priv = mgr->priv; in socfpga_a10_fpga_write()
362 return -EINVAL; in socfpga_a10_fpga_write()
364 /* Write out the complete 32-bit chunks */ in socfpga_a10_fpga_write()
366 writel(buffer_32[i++], priv->fpga_data_addr); in socfpga_a10_fpga_write()
367 count -= sizeof(u32); in socfpga_a10_fpga_write()
370 /* Write out remaining non 32-bit chunks */ in socfpga_a10_fpga_write()
373 writel(buffer_32[i++] & 0x00ffffff, priv->fpga_data_addr); in socfpga_a10_fpga_write()
376 writel(buffer_32[i++] & 0x0000ffff, priv->fpga_data_addr); in socfpga_a10_fpga_write()
379 writel(buffer_32[i++] & 0x000000ff, priv->fpga_data_addr); in socfpga_a10_fpga_write()
385 return -EFAULT; in socfpga_a10_fpga_write()
391 static int socfpga_a10_fpga_write_complete(struct fpga_manager *mgr, in socfpga_a10_fpga_write_complete() argument
394 struct a10_fpga_priv *priv = mgr->priv; in socfpga_a10_fpga_write_complete()
402 regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_01_OFST, in socfpga_a10_fpga_write_complete()
409 regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_02_OFST, in socfpga_a10_fpga_write_complete()
413 regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_01_OFST, in socfpga_a10_fpga_write_complete()
418 regmap_update_bits(priv->regmap, A10_FPGAMGR_IMGCFG_CTL_01_OFST, in socfpga_a10_fpga_write_complete()
432 dev_dbg(&mgr->dev, in socfpga_a10_fpga_write_complete()
434 return -ETIMEDOUT; in socfpga_a10_fpga_write_complete()
440 static enum fpga_mgr_states socfpga_a10_fpga_state(struct fpga_manager *mgr) in socfpga_a10_fpga_state() argument
442 struct a10_fpga_priv *priv = mgr->priv; in socfpga_a10_fpga_state()
470 struct device *dev = &pdev->dev; in socfpga_a10_fpga_probe()
473 struct fpga_manager *mgr; in socfpga_a10_fpga_probe() local
478 return -ENOMEM; in socfpga_a10_fpga_probe()
486 priv->fpga_data_addr = devm_platform_ioremap_resource(pdev, 1); in socfpga_a10_fpga_probe()
487 if (IS_ERR(priv->fpga_data_addr)) in socfpga_a10_fpga_probe()
488 return PTR_ERR(priv->fpga_data_addr); in socfpga_a10_fpga_probe()
491 priv->regmap = devm_regmap_init_mmio(dev, reg_base, in socfpga_a10_fpga_probe()
493 if (IS_ERR(priv->regmap)) in socfpga_a10_fpga_probe()
494 return -ENODEV; in socfpga_a10_fpga_probe()
496 priv->clk = devm_clk_get(dev, NULL); in socfpga_a10_fpga_probe()
497 if (IS_ERR(priv->clk)) { in socfpga_a10_fpga_probe()
499 return PTR_ERR(priv->clk); in socfpga_a10_fpga_probe()
502 ret = clk_prepare_enable(priv->clk); in socfpga_a10_fpga_probe()
505 return -EBUSY; in socfpga_a10_fpga_probe()
508 mgr = fpga_mgr_register(dev, "SoCFPGA Arria10 FPGA Manager", in socfpga_a10_fpga_probe()
510 if (IS_ERR(mgr)) { in socfpga_a10_fpga_probe()
511 clk_disable_unprepare(priv->clk); in socfpga_a10_fpga_probe()
512 return PTR_ERR(mgr); in socfpga_a10_fpga_probe()
515 platform_set_drvdata(pdev, mgr); in socfpga_a10_fpga_probe()
522 struct fpga_manager *mgr = platform_get_drvdata(pdev); in socfpga_a10_fpga_remove() local
523 struct a10_fpga_priv *priv = mgr->priv; in socfpga_a10_fpga_remove()
525 fpga_mgr_unregister(mgr); in socfpga_a10_fpga_remove()
526 clk_disable_unprepare(priv->clk); in socfpga_a10_fpga_remove()
530 { .compatible = "altr,socfpga-a10-fpga-mgr", },