Lines Matching refs:mc
25 struct meson_dev *mc = (struct meson_dev *)data; in meson_irq_handler() local
30 if (mc->irqs[flow] == irq) { in meson_irq_handler()
31 p = readl(mc->base + ((0x04 + flow) << 2)); in meson_irq_handler()
33 writel_relaxed(0xF, mc->base + ((0x4 + flow) << 2)); in meson_irq_handler()
34 mc->chanlist[flow].status = 1; in meson_irq_handler()
35 complete(&mc->chanlist[flow].complete); in meson_irq_handler()
38 dev_err(mc->dev, "%s %d Got irq for flow %d but ctrl is empty\n", __func__, irq, flow); in meson_irq_handler()
42 dev_err(mc->dev, "%s %d from unknown irq\n", __func__, irq); in meson_irq_handler()
103 struct meson_dev *mc = seq->private; in meson_debugfs_show() local
107 seq_printf(seq, "Channel %d: nreq %lu\n", i, mc->chanlist[i].stat_req); in meson_debugfs_show()
124 static void meson_free_chanlist(struct meson_dev *mc, int i) in meson_free_chanlist() argument
127 crypto_engine_exit(mc->chanlist[i].engine); in meson_free_chanlist()
128 if (mc->chanlist[i].tl) in meson_free_chanlist()
129 dma_free_coherent(mc->dev, sizeof(struct meson_desc) * MAXDESC, in meson_free_chanlist()
130 mc->chanlist[i].tl, in meson_free_chanlist()
131 mc->chanlist[i].t_phy); in meson_free_chanlist()
139 static int meson_allocate_chanlist(struct meson_dev *mc) in meson_allocate_chanlist() argument
143 mc->chanlist = devm_kcalloc(mc->dev, MAXFLOW, in meson_allocate_chanlist()
145 if (!mc->chanlist) in meson_allocate_chanlist()
149 init_completion(&mc->chanlist[i].complete); in meson_allocate_chanlist()
151 mc->chanlist[i].engine = crypto_engine_alloc_init(mc->dev, true); in meson_allocate_chanlist()
152 if (!mc->chanlist[i].engine) { in meson_allocate_chanlist()
153 dev_err(mc->dev, "Cannot allocate engine\n"); in meson_allocate_chanlist()
158 err = crypto_engine_start(mc->chanlist[i].engine); in meson_allocate_chanlist()
160 dev_err(mc->dev, "Cannot start engine\n"); in meson_allocate_chanlist()
163 mc->chanlist[i].tl = dma_alloc_coherent(mc->dev, in meson_allocate_chanlist()
165 &mc->chanlist[i].t_phy, in meson_allocate_chanlist()
167 if (!mc->chanlist[i].tl) { in meson_allocate_chanlist()
174 meson_free_chanlist(mc, i); in meson_allocate_chanlist()
178 static int meson_register_algs(struct meson_dev *mc) in meson_register_algs() argument
183 mc_algs[i].mc = mc; in meson_register_algs()
188 dev_err(mc->dev, "Fail to register %s\n", in meson_register_algs()
190 mc_algs[i].mc = NULL; in meson_register_algs()
200 static void meson_unregister_algs(struct meson_dev *mc) in meson_unregister_algs() argument
205 if (!mc_algs[i].mc) in meson_unregister_algs()
217 struct meson_dev *mc; in meson_crypto_probe() local
220 mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL); in meson_crypto_probe()
221 if (!mc) in meson_crypto_probe()
224 mc->dev = &pdev->dev; in meson_crypto_probe()
225 platform_set_drvdata(pdev, mc); in meson_crypto_probe()
227 mc->base = devm_platform_ioremap_resource(pdev, 0); in meson_crypto_probe()
228 if (IS_ERR(mc->base)) { in meson_crypto_probe()
229 err = PTR_ERR(mc->base); in meson_crypto_probe()
233 mc->busclk = devm_clk_get(&pdev->dev, "blkmv"); in meson_crypto_probe()
234 if (IS_ERR(mc->busclk)) { in meson_crypto_probe()
235 err = PTR_ERR(mc->busclk); in meson_crypto_probe()
241 mc->irqs[i] = platform_get_irq(pdev, i); in meson_crypto_probe()
242 if (mc->irqs[i] < 0) in meson_crypto_probe()
243 return mc->irqs[i]; in meson_crypto_probe()
245 err = devm_request_irq(&pdev->dev, mc->irqs[i], meson_irq_handler, 0, in meson_crypto_probe()
246 "gxl-crypto", mc); in meson_crypto_probe()
248 dev_err(mc->dev, "Cannot request IRQ for flow %d\n", i); in meson_crypto_probe()
253 err = clk_prepare_enable(mc->busclk); in meson_crypto_probe()
259 err = meson_allocate_chanlist(mc); in meson_crypto_probe()
263 err = meson_register_algs(mc); in meson_crypto_probe()
268 mc->dbgfs_dir = debugfs_create_dir("gxl-crypto", NULL); in meson_crypto_probe()
269 debugfs_create_file("stats", 0444, mc->dbgfs_dir, mc, &meson_debugfs_fops); in meson_crypto_probe()
274 meson_unregister_algs(mc); in meson_crypto_probe()
276 meson_free_chanlist(mc, MAXFLOW - 1); in meson_crypto_probe()
277 clk_disable_unprepare(mc->busclk); in meson_crypto_probe()
283 struct meson_dev *mc = platform_get_drvdata(pdev); in meson_crypto_remove() local
286 debugfs_remove_recursive(mc->dbgfs_dir); in meson_crypto_remove()
289 meson_unregister_algs(mc); in meson_crypto_remove()
291 meson_free_chanlist(mc, MAXFLOW - 1); in meson_crypto_remove()
293 clk_disable_unprepare(mc->busclk); in meson_crypto_remove()