intern.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * CAAM/SEC 4.x driver backend
  4. * Private/internal definitions between modules
  5. *
  6. * Copyright 2008-2011 Freescale Semiconductor, Inc.
  7. *
  8. */
  9. #ifndef INTERN_H
  10. #define INTERN_H
  11. /* Currently comes from Kconfig param as a ^2 (driver-required) */
  12. #define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE)
  13. /* Kconfig params for interrupt coalescing if selected (else zero) */
  14. #ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_INTC
  15. #define JOBR_INTC JRCFG_ICEN
  16. #define JOBR_INTC_TIME_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_TIME_THLD
  17. #define JOBR_INTC_COUNT_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_COUNT_THLD
  18. #else
  19. #define JOBR_INTC 0
  20. #define JOBR_INTC_TIME_THLD 0
  21. #define JOBR_INTC_COUNT_THLD 0
  22. #endif
  23. /*
  24. * Storage for tracking each in-process entry moving across a ring
  25. * Each entry on an output ring needs one of these
  26. */
  27. struct caam_jrentry_info {
  28. void (*callbk)(struct device *dev, u32 *desc, u32 status, void *arg);
  29. void *cbkarg; /* Argument per ring entry */
  30. u32 *desc_addr_virt; /* Stored virt addr for postprocessing */
  31. dma_addr_t desc_addr_dma; /* Stored bus addr for done matching */
  32. u32 desc_size; /* Stored size for postprocessing, header derived */
  33. };
  34. /* Private sub-storage for a single JobR */
  35. struct caam_drv_private_jr {
  36. struct list_head list_node; /* Job Ring device list */
  37. struct device *dev;
  38. int ridx;
  39. struct caam_job_ring __iomem *rregs; /* JobR's register space */
  40. struct tasklet_struct irqtask;
  41. int irq; /* One per queue */
  42. /* Number of scatterlist crypt transforms active on the JobR */
  43. atomic_t tfm_count ____cacheline_aligned;
  44. /* Job ring info */
  45. int ringsize; /* Size of rings (assume input = output) */
  46. struct caam_jrentry_info *entinfo; /* Alloc'ed 1 per ring entry */
  47. spinlock_t inplock ____cacheline_aligned; /* Input ring index lock */
  48. int inp_ring_write_index; /* Input index "tail" */
  49. int head; /* entinfo (s/w ring) head index */
  50. dma_addr_t *inpring; /* Base of input ring, alloc DMA-safe */
  51. spinlock_t outlock ____cacheline_aligned; /* Output ring index lock */
  52. int out_ring_read_index; /* Output index "tail" */
  53. int tail; /* entinfo (s/w ring) tail index */
  54. struct jr_outentry *outring; /* Base of output ring, DMA-safe */
  55. };
  56. /*
  57. * Driver-private storage for a single CAAM block instance
  58. */
  59. struct caam_drv_private {
  60. #ifdef CONFIG_CAAM_QI
  61. struct device *qidev;
  62. #endif
  63. /* Physical-presence section */
  64. struct caam_ctrl __iomem *ctrl; /* controller region */
  65. struct caam_deco __iomem *deco; /* DECO/CCB views */
  66. struct caam_assurance __iomem *assure;
  67. struct caam_queue_if __iomem *qi; /* QI control region */
  68. struct caam_job_ring __iomem *jr[4]; /* JobR's register space */
  69. /*
  70. * Detected geometry block. Filled in from device tree if powerpc,
  71. * or from register-based version detection code
  72. */
  73. u8 total_jobrs; /* Total Job Rings in device */
  74. u8 qi_present; /* Nonzero if QI present in device */
  75. u8 mc_en; /* Nonzero if MC f/w is active */
  76. int secvio_irq; /* Security violation interrupt number */
  77. int virt_en; /* Virtualization enabled in CAAM */
  78. int era; /* CAAM Era (internal HW revision) */
  79. #define RNG4_MAX_HANDLES 2
  80. /* RNG4 block */
  81. u32 rng4_sh_init; /* This bitmap shows which of the State
  82. Handles of the RNG4 block are initialized
  83. by this driver */
  84. struct clk *caam_ipg;
  85. struct clk *caam_mem;
  86. struct clk *caam_aclk;
  87. struct clk *caam_emi_slow;
  88. /*
  89. * debugfs entries for developer view into driver/device
  90. * variables at runtime.
  91. */
  92. #ifdef CONFIG_DEBUG_FS
  93. struct dentry *dfs_root;
  94. struct dentry *ctl; /* controller dir */
  95. struct debugfs_blob_wrapper ctl_kek_wrap, ctl_tkek_wrap, ctl_tdsk_wrap;
  96. struct dentry *ctl_kek, *ctl_tkek, *ctl_tdsk;
  97. #endif
  98. };
  99. void caam_jr_algapi_init(struct device *dev);
  100. void caam_jr_algapi_remove(struct device *dev);
  101. #ifdef CONFIG_DEBUG_FS
  102. static int caam_debugfs_u64_get(void *data, u64 *val)
  103. {
  104. *val = caam64_to_cpu(*(u64 *)data);
  105. return 0;
  106. }
  107. static int caam_debugfs_u32_get(void *data, u64 *val)
  108. {
  109. *val = caam32_to_cpu(*(u32 *)data);
  110. return 0;
  111. }
  112. DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u32_ro, caam_debugfs_u32_get, NULL, "%llu\n");
  113. DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u64_ro, caam_debugfs_u64_get, NULL, "%llu\n");
  114. #endif
  115. #endif /* INTERN_H */