Lines Matching +full:core +full:- +full:clk

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * SLIM core rproc driver
10 #include <linux/clk.h>
20 /* SLIM core registers */
59 int clk, err; in slim_clk_get() local
61 for (clk = 0; clk < ST_SLIM_MAX_CLK; clk++) { in slim_clk_get()
62 slim_rproc->clks[clk] = of_clk_get(dev->of_node, clk); in slim_clk_get()
63 if (IS_ERR(slim_rproc->clks[clk])) { in slim_clk_get()
64 err = PTR_ERR(slim_rproc->clks[clk]); in slim_clk_get()
65 if (err == -EPROBE_DEFER) in slim_clk_get()
67 slim_rproc->clks[clk] = NULL; in slim_clk_get()
75 while (--clk >= 0) in slim_clk_get()
76 clk_put(slim_rproc->clks[clk]); in slim_clk_get()
83 int clk; in slim_clk_disable() local
85 for (clk = 0; clk < ST_SLIM_MAX_CLK && slim_rproc->clks[clk]; clk++) in slim_clk_disable()
86 clk_disable_unprepare(slim_rproc->clks[clk]); in slim_clk_disable()
91 int clk, ret; in slim_clk_enable() local
93 for (clk = 0; clk < ST_SLIM_MAX_CLK && slim_rproc->clks[clk]; clk++) { in slim_clk_enable()
94 ret = clk_prepare_enable(slim_rproc->clks[clk]); in slim_clk_enable()
102 while (--clk >= 0) in slim_clk_enable()
103 clk_disable_unprepare(slim_rproc->clks[clk]); in slim_clk_enable()
113 struct device *dev = &rproc->dev; in slim_rproc_start()
114 struct st_slim_rproc *slim_rproc = rproc->priv; in slim_rproc_start()
120 writel(val, slim_rproc->slimcore + SLIM_CLK_GATE_OFST); in slim_rproc_start()
122 /* disable SLIM core STBus sync */ in slim_rproc_start()
123 writel(SLIM_STBUS_SYNC_DIS, slim_rproc->peri + SLIM_STBUS_SYNC_OFST); in slim_rproc_start()
127 slim_rproc->slimcore + SLIM_CLK_GATE_OFST); in slim_rproc_start()
130 writel(~0U, slim_rproc->peri + SLIM_INT_CLR_OFST); in slim_rproc_start()
131 writel(~0U, slim_rproc->peri + SLIM_CMD_CLR_OFST); in slim_rproc_start()
134 writel(~0U, slim_rproc->peri + SLIM_INT_MASK_OFST); in slim_rproc_start()
135 writel(~0U, slim_rproc->peri + SLIM_CMD_MASK_OFST); in slim_rproc_start()
138 writel(SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST); in slim_rproc_start()
140 hw_id = readl_relaxed(slim_rproc->slimcore + SLIM_ID_OFST); in slim_rproc_start()
141 hw_ver = readl_relaxed(slim_rproc->slimcore + SLIM_VER_OFST); in slim_rproc_start()
143 fw_rev = readl(slim_rproc->mem[ST_SLIM_DMEM].cpu_addr + in slim_rproc_start()
155 struct st_slim_rproc *slim_rproc = rproc->priv; in slim_rproc_stop()
159 writel(0UL, slim_rproc->peri + SLIM_INT_MASK_OFST); in slim_rproc_stop()
160 writel(0UL, slim_rproc->peri + SLIM_CMD_MASK_OFST); in slim_rproc_stop()
163 writel(SLIM_CLK_GATE_DIS, slim_rproc->slimcore + SLIM_CLK_GATE_OFST); in slim_rproc_stop()
165 writel(!SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST); in slim_rproc_stop()
167 val = readl(slim_rproc->slimcore + SLIM_EN_OFST); in slim_rproc_stop()
169 dev_warn(&rproc->dev, "Failed to disable SLIM"); in slim_rproc_stop()
171 dev_dbg(&rproc->dev, "slim stopped\n"); in slim_rproc_stop()
178 struct st_slim_rproc *slim_rproc = rproc->priv; in slim_rproc_da_to_va()
183 if (da != slim_rproc->mem[i].bus_addr) in slim_rproc_da_to_va()
186 if (len <= slim_rproc->mem[i].size) { in slim_rproc_da_to_va()
188 va = (__force void *)slim_rproc->mem[i].cpu_addr; in slim_rproc_da_to_va()
193 dev_dbg(&rproc->dev, "da = 0x%llx len = 0x%zx va = 0x%pK\n", in slim_rproc_da_to_va()
209 * st_slim_rproc_alloc() - allocate and initialise slim rproc
214 * device drivers whose IP is based around the SLIM core. It
215 * obtains and enables any clocks required by the SLIM core and also
224 struct device *dev = &pdev->dev; in st_slim_rproc_alloc()
226 struct device_node *np = dev->of_node; in st_slim_rproc_alloc()
232 return ERR_PTR(-EINVAL); in st_slim_rproc_alloc()
234 if (!of_device_is_compatible(np, "st,slim-rproc")) in st_slim_rproc_alloc()
235 return ERR_PTR(-EINVAL); in st_slim_rproc_alloc()
237 rproc = rproc_alloc(dev, np->name, &slim_rproc_ops, in st_slim_rproc_alloc()
240 return ERR_PTR(-ENOMEM); in st_slim_rproc_alloc()
242 rproc->has_iommu = false; in st_slim_rproc_alloc()
244 slim_rproc = rproc->priv; in st_slim_rproc_alloc()
245 slim_rproc->rproc = rproc; in st_slim_rproc_alloc()
252 slim_rproc->mem[i].cpu_addr = devm_ioremap_resource(dev, res); in st_slim_rproc_alloc()
253 if (IS_ERR(slim_rproc->mem[i].cpu_addr)) { in st_slim_rproc_alloc()
254 dev_err(&pdev->dev, "devm_ioremap_resource failed\n"); in st_slim_rproc_alloc()
255 err = PTR_ERR(slim_rproc->mem[i].cpu_addr); in st_slim_rproc_alloc()
258 slim_rproc->mem[i].bus_addr = res->start; in st_slim_rproc_alloc()
259 slim_rproc->mem[i].size = resource_size(res); in st_slim_rproc_alloc()
262 slim_rproc->slimcore = devm_platform_ioremap_resource_byname(pdev, "slimcore"); in st_slim_rproc_alloc()
263 if (IS_ERR(slim_rproc->slimcore)) { in st_slim_rproc_alloc()
264 dev_err(&pdev->dev, "failed to ioremap slimcore IO\n"); in st_slim_rproc_alloc()
265 err = PTR_ERR(slim_rproc->slimcore); in st_slim_rproc_alloc()
269 slim_rproc->peri = devm_platform_ioremap_resource_byname(pdev, "peripherals"); in st_slim_rproc_alloc()
270 if (IS_ERR(slim_rproc->peri)) { in st_slim_rproc_alloc()
271 dev_err(&pdev->dev, "failed to ioremap peripherals IO\n"); in st_slim_rproc_alloc()
272 err = PTR_ERR(slim_rproc->peri); in st_slim_rproc_alloc()
298 for (i = 0; i < ST_SLIM_MAX_CLK && slim_rproc->clks[i]; i++) in st_slim_rproc_alloc()
299 clk_put(slim_rproc->clks[i]); in st_slim_rproc_alloc()
307 * st_slim_rproc_put() - put slim rproc resources
315 int clk; in st_slim_rproc_put() local
322 for (clk = 0; clk < ST_SLIM_MAX_CLK && slim_rproc->clks[clk]; clk++) in st_slim_rproc_put()
323 clk_put(slim_rproc->clks[clk]); in st_slim_rproc_put()
325 rproc_del(slim_rproc->rproc); in st_slim_rproc_put()
326 rproc_free(slim_rproc->rproc); in st_slim_rproc_put()
331 MODULE_DESCRIPTION("STMicroelectronics SLIM core rproc driver");