// SPDX-License-Identifier: GPL-2.0+ /* * CAAM/SEC 4.x transport/backend driver * JobR backend functionality * * Copyright 2008-2012 Freescale Semiconductor, Inc. * Copyright 2019, 2023 NXP */ #include <linux/of_irq.h> #include <linux/of_address.h> #include <linux/platform_device.h> #include "compat.h" #include "ctrl.h" #include "regs.h" #include "jr.h" #include "desc.h" #include "intern.h" struct jr_driver_data { … } ____cacheline_aligned; static struct jr_driver_data driver_data; static DEFINE_MUTEX(algs_lock); static unsigned int active_devs; static void register_algs(struct caam_drv_private_jr *jrpriv, struct device *dev) { … } static void unregister_algs(void) { … } static void caam_jr_crypto_engine_exit(void *data) { … } /* * Put the CAAM in quiesce, ie stop * * Must be called with itr disabled */ static int caam_jr_stop_processing(struct device *dev, u32 jrcr_bits) { … } /* * Flush the job ring, so the jobs running will be stopped, jobs queued will be * invalidated and the CAAM will no longer fetch fron input ring. * * Must be called with itr disabled */ static int caam_jr_flush(struct device *dev) { … } /* The resume can be used after a park or a flush if CAAM has not been reset */ static int caam_jr_restart_processing(struct device *dev) { … } static int caam_reset_hw_jr(struct device *dev) { … } /* * Shutdown JobR independent of platform property code */ static int caam_jr_shutdown(struct device *dev) { … } static void caam_jr_remove(struct platform_device *pdev) { … } /* Main per-ring interrupt handler */ static irqreturn_t caam_jr_interrupt(int irq, void *st_dev) { … } /* Deferred service handler, run as interrupt-fired tasklet */ static void caam_jr_dequeue(unsigned long devarg) { … } /** * caam_jr_alloc() - Alloc a job ring for someone to use as needed. * * returns : pointer to the newly allocated physical * JobR dev can be written to if successful. **/ struct device *caam_jr_alloc(void) { … } EXPORT_SYMBOL(…); /** * caam_jr_free() - Free the Job Ring * @rdev: points to the dev that identifies the Job ring to * be released. **/ void caam_jr_free(struct device *rdev) { … } EXPORT_SYMBOL(…); /** * caam_jr_enqueue() - Enqueue a job descriptor head. Returns -EINPROGRESS * if OK, -ENOSPC if the queue is full, -EIO if it cannot map the caller's * descriptor. * @dev: struct device of the job ring to be used * @desc: points to a job descriptor that execute our request. All * descriptors (and all referenced data) must be in a DMAable * region, and all data references must be physical addresses * accessible to CAAM (i.e. within a PAMU window granted * to it). * @cbk: pointer to a callback function to be invoked upon completion * of this request. This has the form: * callback(struct device *dev, u32 *desc, u32 stat, void *arg) * where: * dev: contains the job ring device that processed this * response. * desc: descriptor that initiated the request, same as * "desc" being argued to caam_jr_enqueue(). * status: untranslated status received from CAAM. See the * reference manual for a detailed description of * error meaning, or see the JRSTA definitions in the * register header file * areq: optional pointer to an argument passed with the * original request * @areq: optional pointer to a user argument for use at callback * time. **/ int caam_jr_enqueue(struct device *dev, u32 *desc, void (*cbk)(struct device *dev, u32 *desc, u32 status, void *areq), void *areq) { … } EXPORT_SYMBOL(…); static void caam_jr_init_hw(struct device *dev, dma_addr_t inpbusaddr, dma_addr_t outbusaddr) { … } static void caam_jr_reset_index(struct caam_drv_private_jr *jrp) { … } /* * Init JobR independent of platform property detection */ static int caam_jr_init(struct device *dev) { … } static void caam_jr_irq_dispose_mapping(void *data) { … } /* * Probe routine for each detected JobR subsystem. */ static int caam_jr_probe(struct platform_device *pdev) { … } static void caam_jr_get_hw_state(struct device *dev) { … } static int caam_jr_suspend(struct device *dev) { … } static int caam_jr_resume(struct device *dev) { … } static DEFINE_SIMPLE_DEV_PM_OPS(caam_jr_pm_ops, caam_jr_suspend, caam_jr_resume); static const struct of_device_id caam_jr_match[] = …; MODULE_DEVICE_TABLE(of, caam_jr_match); static struct platform_driver caam_jr_driver = …; static int __init jr_driver_init(void) { … } static void __exit jr_driver_exit(void) { … } module_init(…) …; module_exit(jr_driver_exit); MODULE_LICENSE(…) …; MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …;