Lines Matching +full:- +full:- +full:disable +full:- +full:fdt
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2006-2007 Sylvain Munaut <tnt@246tNt.com>
7 * ( by Andrey Volkov <avolkov@varma-el.com> )
8 * Copyright (C) 2003-2004 MontaVista, Software, Inc.
27 #define DRIVER_NAME "bestcomm-core"
31 { .compatible = "fsl,mpc5200-sram", },
32 { .compatible = "mpc5200-sram", },
49 int i, tasknum = -1; in bcom_task_alloc()
57 spin_lock(&bcom_eng->lock); in bcom_task_alloc()
60 if (!bcom_eng->tdt[i].stop) { /* we use stop as a marker */ in bcom_task_alloc()
61 bcom_eng->tdt[i].stop = 0xfffffffful; /* dummy addr */ in bcom_task_alloc()
66 spin_unlock(&bcom_eng->lock); in bcom_task_alloc()
76 tsk->tasknum = tasknum; in bcom_task_alloc()
78 tsk->priv = (void*)tsk + sizeof(struct bcom_task); in bcom_task_alloc()
81 tsk->irq = irq_of_parse_and_map(bcom_eng->ofnode, tsk->tasknum); in bcom_task_alloc()
82 if (!tsk->irq) in bcom_task_alloc()
87 tsk->cookie = kmalloc_array(bd_count, sizeof(void *), in bcom_task_alloc()
89 if (!tsk->cookie) in bcom_task_alloc()
92 tsk->bd = bcom_sram_alloc(bd_count * bd_size, 4, &tsk->bd_pa); in bcom_task_alloc()
93 if (!tsk->bd) in bcom_task_alloc()
95 memset_io(tsk->bd, 0x00, bd_count * bd_size); in bcom_task_alloc()
97 tsk->num_bd = bd_count; in bcom_task_alloc()
98 tsk->bd_size = bd_size; in bcom_task_alloc()
105 if (tsk->irq) in bcom_task_alloc()
106 irq_dispose_mapping(tsk->irq); in bcom_task_alloc()
107 bcom_sram_free(tsk->bd); in bcom_task_alloc()
108 kfree(tsk->cookie); in bcom_task_alloc()
112 bcom_eng->tdt[tasknum].stop = 0; in bcom_task_alloc()
122 bcom_disable_task(tsk->tasknum); in bcom_task_free()
125 bcom_eng->tdt[tsk->tasknum].start = 0; in bcom_task_free()
126 bcom_eng->tdt[tsk->tasknum].stop = 0; in bcom_task_free()
129 irq_dispose_mapping(tsk->irq); in bcom_task_free()
130 bcom_sram_free(tsk->bd); in bcom_task_free()
131 kfree(tsk->cookie); in bcom_task_free()
145 if (hdr->magic != BCOM_TASK_MAGIC) { in bcom_load_image()
148 return -EINVAL; in bcom_load_image()
154 return -EINVAL; in bcom_load_image()
158 tdt = &bcom_eng->tdt[task]; in bcom_load_image()
160 if (tdt->start) { in bcom_load_image()
162 if (hdr->desc_size != bcom_task_num_descs(task)) { in bcom_load_image()
167 hdr->desc_size, in bcom_load_image()
169 return -EINVAL; in bcom_load_image()
174 desc = bcom_sram_alloc(hdr->desc_size * sizeof(u32), 4, &start_pa); in bcom_load_image()
176 return -ENOMEM; in bcom_load_image()
178 tdt->start = start_pa; in bcom_load_image()
179 tdt->stop = start_pa + ((hdr->desc_size-1) * sizeof(u32)); in bcom_load_image()
190 var_src = desc_src + hdr->desc_size; in bcom_load_image()
191 inc_src = var_src + hdr->var_size; in bcom_load_image()
193 memcpy_toio(desc, desc_src, hdr->desc_size * sizeof(u32)); in bcom_load_image()
194 memcpy_toio(var + hdr->first_var, var_src, hdr->var_size * sizeof(u32)); in bcom_load_image()
195 memcpy_toio(inc, inc_src, hdr->inc_size * sizeof(u32)); in bcom_load_image()
236 bcom_enable_task(tsk->tasknum); in bcom_enable()
243 bcom_disable_task(tsk->tasknum); in bcom_disable()
253 /* this will need to be updated if Freescale changes their task code FDT */
255 0xa0045670, /* FDT[48] - load_acc() */
256 0x80045670, /* FDT[49] - unload_acc() */
257 0x21800000, /* FDT[50] - and() */
258 0x21e00000, /* FDT[51] - or() */
259 0x21500000, /* FDT[52] - xor() */
260 0x21400000, /* FDT[53] - andn() */
261 0x21500000, /* FDT[54] - not() */
262 0x20400000, /* FDT[55] - add() */
263 0x20500000, /* FDT[56] - sub() */
264 0x20800000, /* FDT[57] - lsh() */
265 0x20a00000, /* FDT[58] - rsh() */
266 0xc0170000, /* FDT[59] - crc8() */
267 0xc0145670, /* FDT[60] - crc16() */
268 0xc0345670, /* FDT[61] - crc32() */
269 0xa0076540, /* FDT[62] - endian32() */
270 0xa0000760, /* FDT[63] - endian16() */
280 /* Allocate & clear SRAM zones for FDT, TDTs, contexts and vars/incs */ in bcom_engine_init()
286 bcom_eng->tdt = bcom_sram_alloc(tdt_size, sizeof(u32), &tdt_pa); in bcom_engine_init()
287 bcom_eng->ctx = bcom_sram_alloc(ctx_size, BCOM_CTX_ALIGN, &ctx_pa); in bcom_engine_init()
288 bcom_eng->var = bcom_sram_alloc(var_size, BCOM_VAR_ALIGN, &var_pa); in bcom_engine_init()
289 bcom_eng->fdt = bcom_sram_alloc(fdt_size, BCOM_FDT_ALIGN, &fdt_pa); in bcom_engine_init()
291 if (!bcom_eng->tdt || !bcom_eng->ctx || !bcom_eng->var || !bcom_eng->fdt) { in bcom_engine_init()
294 bcom_sram_free(bcom_eng->tdt); in bcom_engine_init()
295 bcom_sram_free(bcom_eng->ctx); in bcom_engine_init()
296 bcom_sram_free(bcom_eng->var); in bcom_engine_init()
297 bcom_sram_free(bcom_eng->fdt); in bcom_engine_init()
299 return -ENOMEM; in bcom_engine_init()
302 memset_io(bcom_eng->tdt, 0x00, tdt_size); in bcom_engine_init()
303 memset_io(bcom_eng->ctx, 0x00, ctx_size); in bcom_engine_init()
304 memset_io(bcom_eng->var, 0x00, var_size); in bcom_engine_init()
305 memset_io(bcom_eng->fdt, 0x00, fdt_size); in bcom_engine_init()
307 /* Copy the FDT for the EU#3 */ in bcom_engine_init()
308 memcpy_toio(&bcom_eng->fdt[48], fdt_ops, sizeof(fdt_ops)); in bcom_engine_init()
313 out_be16(&bcom_eng->regs->tcr[task], 0); in bcom_engine_init()
314 out_8(&bcom_eng->regs->ipr[task], 0); in bcom_engine_init()
316 bcom_eng->tdt[task].context = ctx_pa; in bcom_engine_init()
317 bcom_eng->tdt[task].var = var_pa; in bcom_engine_init()
318 bcom_eng->tdt[task].fdt = fdt_pa; in bcom_engine_init()
324 out_be32(&bcom_eng->regs->taskBar, tdt_pa); in bcom_engine_init()
327 out_8(&bcom_eng->regs->ipr[BCOM_INITIATOR_ALWAYS], BCOM_IPR_ALWAYS); in bcom_engine_init()
329 /* Disable COMM Bus Prefetch on the original 5200; it's broken */ in bcom_engine_init()
334 spin_lock_init(&bcom_eng->lock); in bcom_engine_init()
347 out_be16(&bcom_eng->regs->tcr[task], 0); in bcom_engine_cleanup()
348 out_8(&bcom_eng->regs->ipr[task], 0); in bcom_engine_cleanup()
351 out_be32(&bcom_eng->regs->taskBar, 0ul); in bcom_engine_cleanup()
354 bcom_sram_free(bcom_eng->tdt); in bcom_engine_cleanup()
355 bcom_sram_free(bcom_eng->ctx); in bcom_engine_cleanup()
356 bcom_sram_free(bcom_eng->var); in bcom_engine_cleanup()
357 bcom_sram_free(bcom_eng->fdt); in bcom_engine_cleanup()
376 of_node_get(op->dev.of_node); in mpc52xx_bcom_probe()
383 rv = -ENODEV; in mpc52xx_bcom_probe()
398 rv = -ENOMEM; in mpc52xx_bcom_probe()
403 bcom_eng->ofnode = op->dev.of_node; in mpc52xx_bcom_probe()
406 if (of_address_to_resource(op->dev.of_node, 0, &res_bcom)) { in mpc52xx_bcom_probe()
409 rv = -EINVAL; in mpc52xx_bcom_probe()
417 rv = -EBUSY; in mpc52xx_bcom_probe()
421 bcom_eng->regs_base = res_bcom.start; in mpc52xx_bcom_probe()
422 bcom_eng->regs = ioremap(res_bcom.start, sizeof(struct mpc52xx_sdma)); in mpc52xx_bcom_probe()
423 if (!bcom_eng->regs) { in mpc52xx_bcom_probe()
426 rv = -ENOMEM; in mpc52xx_bcom_probe()
437 (long)bcom_eng->regs_base); in mpc52xx_bcom_probe()
443 iounmap(bcom_eng->regs); in mpc52xx_bcom_probe()
450 of_node_put(op->dev.of_node); in mpc52xx_bcom_probe()
467 iounmap(bcom_eng->regs); in mpc52xx_bcom_remove()
468 release_mem_region(bcom_eng->regs_base, sizeof(struct mpc52xx_sdma)); in mpc52xx_bcom_remove()
471 of_node_put(bcom_eng->ofnode); in mpc52xx_bcom_remove()
481 { .compatible = "fsl,mpc5200-bestcomm", },
482 { .compatible = "mpc5200-bestcomm", },
523 MODULE_AUTHOR("Andrey Volkov <avolkov@varma-el.com>");