1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2 * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
8 /** struct ionic_intr - interrupt control register set.
9 * @coal_init: coalesce timer initial value.
10 * @mask: interrupt mask value.
11 * @credits: interrupt credit count and return.
12 * @mask_assert: interrupt mask value on assert.
13 * @coal: coalesce timer time remaining.
24 /** enum ionic_intr_mask_vals - valid values for mask and mask_assert.
25 * @IONIC_INTR_MASK_CLEAR: unmask interrupt.
26 * @IONIC_INTR_MASK_SET: mask interrupt.
28 enum ionic_intr_mask_vals {
29 IONIC_INTR_MASK_CLEAR = 0,
30 IONIC_INTR_MASK_SET = 1,
33 /** enum ionic_intr_credits_bits - bitwise composition of credits values.
34 * @IONIC_INTR_CRED_COUNT: bit mask of credit count, no shift needed.
35 * @IONIC_INTR_CRED_COUNT_SIGNED: bit mask of credit count, including sign bit.
36 * @IONIC_INTR_CRED_UNMASK: unmask the interrupt.
37 * @IONIC_INTR_CRED_RESET_COALESCE: reset the coalesce timer.
38 * @IONIC_INTR_CRED_REARM: unmask the and reset the timer.
40 enum ionic_intr_credits_bits {
41 IONIC_INTR_CRED_COUNT = 0x7fffu,
42 IONIC_INTR_CRED_COUNT_SIGNED = 0xffffu,
43 IONIC_INTR_CRED_UNMASK = 0x10000u,
44 IONIC_INTR_CRED_RESET_COALESCE = 0x20000u,
45 IONIC_INTR_CRED_REARM = (IONIC_INTR_CRED_UNMASK |
46 IONIC_INTR_CRED_RESET_COALESCE),
50 ionic_intr_coal_init(struct ionic_intr __iomem *intr_ctrl,
51 int intr_idx, uint32_t coal)
53 iowrite32(coal, &intr_ctrl[intr_idx].coal_init);
57 ionic_intr_mask(struct ionic_intr __iomem *intr_ctrl,
58 int intr_idx, uint32_t mask)
60 iowrite32(mask, &intr_ctrl[intr_idx].mask);
64 ionic_intr_credits(struct ionic_intr __iomem *intr_ctrl,
65 int intr_idx, uint32_t cred, uint32_t flags)
67 if (cred > IONIC_INTR_CRED_COUNT) {
68 IONIC_WARN_ON(cred > IONIC_INTR_CRED_COUNT);
69 cred = ioread32(&intr_ctrl[intr_idx].credits);
70 cred &= IONIC_INTR_CRED_COUNT_SIGNED;
73 iowrite32(cred | flags, &intr_ctrl[intr_idx].credits);
77 ionic_intr_clean(struct ionic_intr __iomem *intr_ctrl,
82 cred = ioread32(&intr_ctrl[intr_idx].credits);
83 cred &= IONIC_INTR_CRED_COUNT_SIGNED;
84 cred |= IONIC_INTR_CRED_RESET_COALESCE;
85 iowrite32(cred, &intr_ctrl[intr_idx].credits);
89 ionic_intr_mask_assert(struct ionic_intr __iomem *intr_ctrl,
90 int intr_idx, uint32_t mask)
92 iowrite32(mask, &intr_ctrl[intr_idx].mask_assert);
95 /** enum ionic_dbell_bits - bitwise composition of dbell values.
97 * @IONIC_DBELL_QID_MASK: unshifted mask of valid queue id bits.
98 * @IONIC_DBELL_QID_SHIFT: queue id shift amount in dbell value.
99 * @IONIC_DBELL_QID: macro to build QID component of dbell value.
101 * @IONIC_DBELL_RING_MASK: unshifted mask of valid ring bits.
102 * @IONIC_DBELL_RING_SHIFT: ring shift amount in dbell value.
103 * @IONIC_DBELL_RING: macro to build ring component of dbell value.
105 * @IONIC_DBELL_RING_0: ring zero dbell component value.
106 * @IONIC_DBELL_RING_1: ring one dbell component value.
107 * @IONIC_DBELL_RING_2: ring two dbell component value.
108 * @IONIC_DBELL_RING_3: ring three dbell component value.
110 * @IONIC_DBELL_INDEX_MASK: bit mask of valid index bits, no shift needed.
112 enum ionic_dbell_bits {
113 IONIC_DBELL_QID_MASK = 0xffffff,
114 IONIC_DBELL_QID_SHIFT = 24,
116 #define IONIC_DBELL_QID(n) \
117 (((u64)(n) & IONIC_DBELL_QID_MASK) << IONIC_DBELL_QID_SHIFT)
119 IONIC_DBELL_RING_MASK = 0x7,
120 IONIC_DBELL_RING_SHIFT = 16,
122 #define IONIC_DBELL_RING(n) \
123 (((u64)(n) & IONIC_DBELL_RING_MASK) << IONIC_DBELL_RING_SHIFT)
125 IONIC_DBELL_RING_0 = 0,
126 IONIC_DBELL_RING_1 = IONIC_DBELL_RING(1),
127 IONIC_DBELL_RING_2 = IONIC_DBELL_RING(2),
128 IONIC_DBELL_RING_3 = IONIC_DBELL_RING(3),
130 IONIC_DBELL_INDEX_MASK = 0xffff,
133 #endif /* _IONIC_REGS_H_ */