1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only)
2 /* Copyright(c) 2020 Intel Corporation */
3 #include "adf_accel_devices.h"
4 #include "adf_gen4_hw_data.h"
6 static u64
build_csr_ring_base_addr(dma_addr_t addr
, u32 size
)
8 return BUILD_RING_BASE_ADDR(addr
, size
);
11 static u32
read_csr_ring_head(void __iomem
*csr_base_addr
, u32 bank
, u32 ring
)
13 return READ_CSR_RING_HEAD(csr_base_addr
, bank
, ring
);
16 static void write_csr_ring_head(void __iomem
*csr_base_addr
, u32 bank
, u32 ring
,
19 WRITE_CSR_RING_HEAD(csr_base_addr
, bank
, ring
, value
);
22 static u32
read_csr_ring_tail(void __iomem
*csr_base_addr
, u32 bank
, u32 ring
)
24 return READ_CSR_RING_TAIL(csr_base_addr
, bank
, ring
);
27 static void write_csr_ring_tail(void __iomem
*csr_base_addr
, u32 bank
, u32 ring
,
30 WRITE_CSR_RING_TAIL(csr_base_addr
, bank
, ring
, value
);
33 static u32
read_csr_e_stat(void __iomem
*csr_base_addr
, u32 bank
)
35 return READ_CSR_E_STAT(csr_base_addr
, bank
);
38 static void write_csr_ring_config(void __iomem
*csr_base_addr
, u32 bank
, u32 ring
,
41 WRITE_CSR_RING_CONFIG(csr_base_addr
, bank
, ring
, value
);
44 static void write_csr_ring_base(void __iomem
*csr_base_addr
, u32 bank
, u32 ring
,
47 WRITE_CSR_RING_BASE(csr_base_addr
, bank
, ring
, addr
);
50 static void write_csr_int_flag(void __iomem
*csr_base_addr
, u32 bank
,
53 WRITE_CSR_INT_FLAG(csr_base_addr
, bank
, value
);
56 static void write_csr_int_srcsel(void __iomem
*csr_base_addr
, u32 bank
)
58 WRITE_CSR_INT_SRCSEL(csr_base_addr
, bank
);
61 static void write_csr_int_col_en(void __iomem
*csr_base_addr
, u32 bank
, u32 value
)
63 WRITE_CSR_INT_COL_EN(csr_base_addr
, bank
, value
);
66 static void write_csr_int_col_ctl(void __iomem
*csr_base_addr
, u32 bank
,
69 WRITE_CSR_INT_COL_CTL(csr_base_addr
, bank
, value
);
72 static void write_csr_int_flag_and_col(void __iomem
*csr_base_addr
, u32 bank
,
75 WRITE_CSR_INT_FLAG_AND_COL(csr_base_addr
, bank
, value
);
78 static void write_csr_ring_srv_arb_en(void __iomem
*csr_base_addr
, u32 bank
,
81 WRITE_CSR_RING_SRV_ARB_EN(csr_base_addr
, bank
, value
);
84 void adf_gen4_init_hw_csr_ops(struct adf_hw_csr_ops
*csr_ops
)
86 csr_ops
->build_csr_ring_base_addr
= build_csr_ring_base_addr
;
87 csr_ops
->read_csr_ring_head
= read_csr_ring_head
;
88 csr_ops
->write_csr_ring_head
= write_csr_ring_head
;
89 csr_ops
->read_csr_ring_tail
= read_csr_ring_tail
;
90 csr_ops
->write_csr_ring_tail
= write_csr_ring_tail
;
91 csr_ops
->read_csr_e_stat
= read_csr_e_stat
;
92 csr_ops
->write_csr_ring_config
= write_csr_ring_config
;
93 csr_ops
->write_csr_ring_base
= write_csr_ring_base
;
94 csr_ops
->write_csr_int_flag
= write_csr_int_flag
;
95 csr_ops
->write_csr_int_srcsel
= write_csr_int_srcsel
;
96 csr_ops
->write_csr_int_col_en
= write_csr_int_col_en
;
97 csr_ops
->write_csr_int_col_ctl
= write_csr_int_col_ctl
;
98 csr_ops
->write_csr_int_flag_and_col
= write_csr_int_flag_and_col
;
99 csr_ops
->write_csr_ring_srv_arb_en
= write_csr_ring_srv_arb_en
;
101 EXPORT_SYMBOL_GPL(adf_gen4_init_hw_csr_ops
);