107f120bcSAlex Elder // SPDX-License-Identifier: GPL-2.0 207f120bcSAlex Elder 307f120bcSAlex Elder /* Copyright (C) 2022 Linaro Ltd. */ 407f120bcSAlex Elder 507f120bcSAlex Elder #include <linux/types.h> 607f120bcSAlex Elder 707f120bcSAlex Elder #include "../ipa.h" 807f120bcSAlex Elder #include "../ipa_reg.h" 907f120bcSAlex Elder 1012c7ea7dSAlex Elder static const u32 ipa_reg_comp_cfg_fmask[] = { 1112c7ea7dSAlex Elder [COMP_CFG_ENABLE] = BIT(0), 1212c7ea7dSAlex Elder [GSI_SNOC_BYPASS_DIS] = BIT(1), 1312c7ea7dSAlex Elder [GEN_QMB_0_SNOC_BYPASS_DIS] = BIT(2), 1412c7ea7dSAlex Elder [GEN_QMB_1_SNOC_BYPASS_DIS] = BIT(3), 1512c7ea7dSAlex Elder [IPA_DCMP_FAST_CLK_EN] = BIT(4), 1612c7ea7dSAlex Elder /* Bits 5-31 reserved */ 1712c7ea7dSAlex Elder }; 1812c7ea7dSAlex Elder 1912c7ea7dSAlex Elder IPA_REG_FIELDS(COMP_CFG, comp_cfg, 0x0000003c); 2007f120bcSAlex Elder 21479deb32SAlex Elder static const u32 ipa_reg_clkon_cfg_fmask[] = { 22479deb32SAlex Elder [CLKON_RX] = BIT(0), 23479deb32SAlex Elder [CLKON_PROC] = BIT(1), 24479deb32SAlex Elder [TX_WRAPPER] = BIT(2), 25479deb32SAlex Elder [CLKON_MISC] = BIT(3), 26479deb32SAlex Elder [RAM_ARB] = BIT(4), 27479deb32SAlex Elder [FTCH_HPS] = BIT(5), 28479deb32SAlex Elder [FTCH_DPS] = BIT(6), 29479deb32SAlex Elder [CLKON_HPS] = BIT(7), 30479deb32SAlex Elder [CLKON_DPS] = BIT(8), 31479deb32SAlex Elder [RX_HPS_CMDQS] = BIT(9), 32479deb32SAlex Elder [HPS_DPS_CMDQS] = BIT(10), 33479deb32SAlex Elder [DPS_TX_CMDQS] = BIT(11), 34479deb32SAlex Elder [RSRC_MNGR] = BIT(12), 35479deb32SAlex Elder [CTX_HANDLER] = BIT(13), 36479deb32SAlex Elder [ACK_MNGR] = BIT(14), 37479deb32SAlex Elder [D_DCPH] = BIT(15), 38479deb32SAlex Elder [H_DCPH] = BIT(16), 39479deb32SAlex Elder /* Bits 17-31 reserved */ 40479deb32SAlex Elder }; 4107f120bcSAlex Elder 42479deb32SAlex Elder IPA_REG_FIELDS(CLKON_CFG, clkon_cfg, 0x00000044); 43479deb32SAlex Elder 44479deb32SAlex Elder static const u32 ipa_reg_route_fmask[] = { 45479deb32SAlex Elder [ROUTE_DIS] = BIT(0), 46479deb32SAlex Elder [ROUTE_DEF_PIPE] = GENMASK(5, 1), 47479deb32SAlex Elder [ROUTE_DEF_HDR_TABLE] = BIT(6), 48479deb32SAlex Elder [ROUTE_DEF_HDR_OFST] = GENMASK(16, 7), 49479deb32SAlex Elder [ROUTE_FRAG_DEF_PIPE] = GENMASK(21, 17), 50479deb32SAlex Elder /* Bits 22-23 reserved */ 51479deb32SAlex Elder [ROUTE_DEF_RETAIN_HDR] = BIT(24), 52479deb32SAlex Elder /* Bits 25-31 reserved */ 53479deb32SAlex Elder }; 54479deb32SAlex Elder 55479deb32SAlex Elder IPA_REG_FIELDS(ROUTE, route, 0x00000048); 5607f120bcSAlex Elder 57*62b9c009SAlex Elder static const u32 ipa_reg_shared_mem_size_fmask[] = { 58*62b9c009SAlex Elder [MEM_SIZE] = GENMASK(15, 0), 59*62b9c009SAlex Elder [MEM_BADDR] = GENMASK(31, 16), 60*62b9c009SAlex Elder }; 6107f120bcSAlex Elder 62*62b9c009SAlex Elder IPA_REG_FIELDS(SHARED_MEM_SIZE, shared_mem_size, 0x00000054); 6307f120bcSAlex Elder 64*62b9c009SAlex Elder static const u32 ipa_reg_qsb_max_writes_fmask[] = { 65*62b9c009SAlex Elder [GEN_QMB_0_MAX_WRITES] = GENMASK(3, 0), 66*62b9c009SAlex Elder [GEN_QMB_1_MAX_WRITES] = GENMASK(7, 4), 67*62b9c009SAlex Elder /* Bits 8-31 reserved */ 68*62b9c009SAlex Elder }; 6907f120bcSAlex Elder 70*62b9c009SAlex Elder IPA_REG_FIELDS(QSB_MAX_WRITES, qsb_max_writes, 0x00000074); 7107f120bcSAlex Elder 72*62b9c009SAlex Elder static const u32 ipa_reg_qsb_max_reads_fmask[] = { 73*62b9c009SAlex Elder [GEN_QMB_0_MAX_READS] = GENMASK(3, 0), 74*62b9c009SAlex Elder [GEN_QMB_1_MAX_READS] = GENMASK(7, 4), 75*62b9c009SAlex Elder }; 76*62b9c009SAlex Elder 77*62b9c009SAlex Elder IPA_REG_FIELDS(QSB_MAX_READS, qsb_max_reads, 0x00000078); 78*62b9c009SAlex Elder 79*62b9c009SAlex Elder static const u32 ipa_reg_filt_rout_hash_en_fmask[] = { 80*62b9c009SAlex Elder [IPV6_ROUTER_HASH] = BIT(0), 81*62b9c009SAlex Elder /* Bits 1-3 reserved */ 82*62b9c009SAlex Elder [IPV6_FILTER_HASH] = BIT(4), 83*62b9c009SAlex Elder /* Bits 5-7 reserved */ 84*62b9c009SAlex Elder [IPV4_ROUTER_HASH] = BIT(8), 85*62b9c009SAlex Elder /* Bits 9-11 reserved */ 86*62b9c009SAlex Elder [IPV4_FILTER_HASH] = BIT(12), 87*62b9c009SAlex Elder /* Bits 13-31 reserved */ 88*62b9c009SAlex Elder }; 89*62b9c009SAlex Elder 90*62b9c009SAlex Elder IPA_REG_FIELDS(FILT_ROUT_HASH_EN, filt_rout_hash_en, 0x000008c); 91*62b9c009SAlex Elder 92*62b9c009SAlex Elder static const u32 ipa_reg_filt_rout_hash_flush_fmask[] = { 93*62b9c009SAlex Elder [IPV6_ROUTER_HASH] = BIT(0), 94*62b9c009SAlex Elder /* Bits 1-3 reserved */ 95*62b9c009SAlex Elder [IPV6_FILTER_HASH] = BIT(4), 96*62b9c009SAlex Elder /* Bits 5-7 reserved */ 97*62b9c009SAlex Elder [IPV4_ROUTER_HASH] = BIT(8), 98*62b9c009SAlex Elder /* Bits 9-11 reserved */ 99*62b9c009SAlex Elder [IPV4_FILTER_HASH] = BIT(12), 100*62b9c009SAlex Elder /* Bits 13-31 reserved */ 101*62b9c009SAlex Elder }; 102*62b9c009SAlex Elder 103*62b9c009SAlex Elder IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x0000090); 10407f120bcSAlex Elder 10507f120bcSAlex Elder /* Valid bits defined by ipa->available */ 10607f120bcSAlex Elder IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c); 10707f120bcSAlex Elder 10807f120bcSAlex Elder IPA_REG(IPA_BCR, ipa_bcr, 0x000001d0); 10907f120bcSAlex Elder 11007f120bcSAlex Elder /* Offset must be a multiple of 8 */ 11107f120bcSAlex Elder IPA_REG(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); 11207f120bcSAlex Elder 11307f120bcSAlex Elder /* Valid bits defined by ipa->available */ 11407f120bcSAlex Elder IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); 11507f120bcSAlex Elder 11607f120bcSAlex Elder IPA_REG(COUNTER_CFG, counter_cfg, 0x000001f0); 11707f120bcSAlex Elder 11807f120bcSAlex Elder IPA_REG_STRIDE(SRC_RSRC_GRP_01_RSRC_TYPE, src_rsrc_grp_01_rsrc_type, 11907f120bcSAlex Elder 0x00000400, 0x0020); 12007f120bcSAlex Elder 12107f120bcSAlex Elder IPA_REG_STRIDE(SRC_RSRC_GRP_23_RSRC_TYPE, src_rsrc_grp_23_rsrc_type, 12207f120bcSAlex Elder 0x00000404, 0x0020); 12307f120bcSAlex Elder 12407f120bcSAlex Elder IPA_REG_STRIDE(SRC_RSRC_GRP_45_RSRC_TYPE, src_rsrc_grp_45_rsrc_type, 12507f120bcSAlex Elder 0x00000408, 0x0020); 12607f120bcSAlex Elder 12707f120bcSAlex Elder IPA_REG_STRIDE(SRC_RSRC_GRP_67_RSRC_TYPE, src_rsrc_grp_67_rsrc_type, 12807f120bcSAlex Elder 0x0000040c, 0x0020); 12907f120bcSAlex Elder 13007f120bcSAlex Elder IPA_REG_STRIDE(DST_RSRC_GRP_01_RSRC_TYPE, dst_rsrc_grp_01_rsrc_type, 13107f120bcSAlex Elder 0x00000500, 0x0020); 13207f120bcSAlex Elder 13307f120bcSAlex Elder IPA_REG_STRIDE(DST_RSRC_GRP_23_RSRC_TYPE, dst_rsrc_grp_23_rsrc_type, 13407f120bcSAlex Elder 0x00000504, 0x0020); 13507f120bcSAlex Elder 13607f120bcSAlex Elder IPA_REG_STRIDE(DST_RSRC_GRP_45_RSRC_TYPE, dst_rsrc_grp_45_rsrc_type, 13707f120bcSAlex Elder 0x00000508, 0x0020); 13807f120bcSAlex Elder 13907f120bcSAlex Elder IPA_REG_STRIDE(DST_RSRC_GRP_67_RSRC_TYPE, dst_rsrc_grp_67_rsrc_type, 14007f120bcSAlex Elder 0x0000050c, 0x0020); 14107f120bcSAlex Elder 14207f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_CTRL, endp_init_ctrl, 0x00000800, 0x0070); 14307f120bcSAlex Elder 14407f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_CFG, endp_init_cfg, 0x00000808, 0x0070); 14507f120bcSAlex Elder 14607f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_NAT, endp_init_nat, 0x0000080c, 0x0070); 14707f120bcSAlex Elder 14807f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_HDR, endp_init_hdr, 0x00000810, 0x0070); 14907f120bcSAlex Elder 15007f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_HDR_EXT, endp_init_hdr_ext, 0x00000814, 0x0070); 15107f120bcSAlex Elder 15207f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_HDR_METADATA_MASK, endp_init_hdr_metadata_mask, 15307f120bcSAlex Elder 0x00000818, 0x0070); 15407f120bcSAlex Elder 15507f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_MODE, endp_init_mode, 0x00000820, 0x0070); 15607f120bcSAlex Elder 15707f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_AGGR, endp_init_aggr, 0x00000824, 0x0070); 15807f120bcSAlex Elder 15907f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_HOL_BLOCK_EN, endp_init_hol_block_en, 16007f120bcSAlex Elder 0x0000082c, 0x0070); 16107f120bcSAlex Elder 16207f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_HOL_BLOCK_TIMER, endp_init_hol_block_timer, 16307f120bcSAlex Elder 0x00000830, 0x0070); 16407f120bcSAlex Elder 16507f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_DEAGGR, endp_init_deaggr, 0x00000834, 0x0070); 16607f120bcSAlex Elder 16707f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_RSRC_GRP, endp_init_rsrc_grp, 0x00000838, 0x0070); 16807f120bcSAlex Elder 16907f120bcSAlex Elder IPA_REG_STRIDE(ENDP_INIT_SEQ, endp_init_seq, 0x0000083c, 0x0070); 17007f120bcSAlex Elder 17107f120bcSAlex Elder IPA_REG_STRIDE(ENDP_STATUS, endp_status, 0x00000840, 0x0070); 17207f120bcSAlex Elder 17307f120bcSAlex Elder IPA_REG_STRIDE(ENDP_FILTER_ROUTER_HSH_CFG, endp_filter_router_hsh_cfg, 17407f120bcSAlex Elder 0x0000085c, 0x0070); 17507f120bcSAlex Elder 17607f120bcSAlex Elder /* Valid bits defined by enum ipa_irq_id; only used for GSI_EE_AP */ 17707f120bcSAlex Elder IPA_REG(IPA_IRQ_STTS, ipa_irq_stts, 0x00003008 + 0x1000 * GSI_EE_AP); 17807f120bcSAlex Elder 17907f120bcSAlex Elder /* Valid bits defined by enum ipa_irq_id; only used for GSI_EE_AP */ 18007f120bcSAlex Elder IPA_REG(IPA_IRQ_EN, ipa_irq_en, 0x0000300c + 0x1000 * GSI_EE_AP); 18107f120bcSAlex Elder 18207f120bcSAlex Elder /* Valid bits defined by enum ipa_irq_id; only used for GSI_EE_AP */ 18307f120bcSAlex Elder IPA_REG(IPA_IRQ_CLR, ipa_irq_clr, 0x00003010 + 0x1000 * GSI_EE_AP); 18407f120bcSAlex Elder 18507f120bcSAlex Elder IPA_REG(IPA_IRQ_UC, ipa_irq_uc, 0x0000301c + 0x1000 * GSI_EE_AP); 18607f120bcSAlex Elder 18707f120bcSAlex Elder /* Valid bits defined by ipa->available */ 18807f120bcSAlex Elder IPA_REG(IRQ_SUSPEND_INFO, irq_suspend_info, 0x00003030 + 0x1000 * GSI_EE_AP); 18907f120bcSAlex Elder 19007f120bcSAlex Elder /* Valid bits defined by ipa->available */ 19107f120bcSAlex Elder IPA_REG(IRQ_SUSPEND_EN, irq_suspend_en, 0x00003034 + 0x1000 * GSI_EE_AP); 19207f120bcSAlex Elder 19307f120bcSAlex Elder /* Valid bits defined by ipa->available */ 19407f120bcSAlex Elder IPA_REG(IRQ_SUSPEND_CLR, irq_suspend_clr, 0x00003038 + 0x1000 * GSI_EE_AP); 19507f120bcSAlex Elder 19607f120bcSAlex Elder static const struct ipa_reg *ipa_reg_array[] = { 19707f120bcSAlex Elder [COMP_CFG] = &ipa_reg_comp_cfg, 19807f120bcSAlex Elder [CLKON_CFG] = &ipa_reg_clkon_cfg, 19907f120bcSAlex Elder [ROUTE] = &ipa_reg_route, 20007f120bcSAlex Elder [SHARED_MEM_SIZE] = &ipa_reg_shared_mem_size, 20107f120bcSAlex Elder [QSB_MAX_WRITES] = &ipa_reg_qsb_max_writes, 20207f120bcSAlex Elder [QSB_MAX_READS] = &ipa_reg_qsb_max_reads, 20307f120bcSAlex Elder [FILT_ROUT_HASH_EN] = &ipa_reg_filt_rout_hash_en, 20407f120bcSAlex Elder [FILT_ROUT_HASH_FLUSH] = &ipa_reg_filt_rout_hash_flush, 20507f120bcSAlex Elder [STATE_AGGR_ACTIVE] = &ipa_reg_state_aggr_active, 20607f120bcSAlex Elder [IPA_BCR] = &ipa_reg_ipa_bcr, 20707f120bcSAlex Elder [LOCAL_PKT_PROC_CNTXT] = &ipa_reg_local_pkt_proc_cntxt, 20807f120bcSAlex Elder [AGGR_FORCE_CLOSE] = &ipa_reg_aggr_force_close, 20907f120bcSAlex Elder [COUNTER_CFG] = &ipa_reg_counter_cfg, 21007f120bcSAlex Elder [SRC_RSRC_GRP_01_RSRC_TYPE] = &ipa_reg_src_rsrc_grp_01_rsrc_type, 21107f120bcSAlex Elder [SRC_RSRC_GRP_23_RSRC_TYPE] = &ipa_reg_src_rsrc_grp_23_rsrc_type, 21207f120bcSAlex Elder [SRC_RSRC_GRP_45_RSRC_TYPE] = &ipa_reg_src_rsrc_grp_45_rsrc_type, 21307f120bcSAlex Elder [SRC_RSRC_GRP_67_RSRC_TYPE] = &ipa_reg_src_rsrc_grp_67_rsrc_type, 21407f120bcSAlex Elder [DST_RSRC_GRP_01_RSRC_TYPE] = &ipa_reg_dst_rsrc_grp_01_rsrc_type, 21507f120bcSAlex Elder [DST_RSRC_GRP_23_RSRC_TYPE] = &ipa_reg_dst_rsrc_grp_23_rsrc_type, 21607f120bcSAlex Elder [DST_RSRC_GRP_45_RSRC_TYPE] = &ipa_reg_dst_rsrc_grp_45_rsrc_type, 21707f120bcSAlex Elder [DST_RSRC_GRP_67_RSRC_TYPE] = &ipa_reg_dst_rsrc_grp_67_rsrc_type, 21807f120bcSAlex Elder [ENDP_INIT_CTRL] = &ipa_reg_endp_init_ctrl, 21907f120bcSAlex Elder [ENDP_INIT_CFG] = &ipa_reg_endp_init_cfg, 22007f120bcSAlex Elder [ENDP_INIT_NAT] = &ipa_reg_endp_init_nat, 22107f120bcSAlex Elder [ENDP_INIT_HDR] = &ipa_reg_endp_init_hdr, 22207f120bcSAlex Elder [ENDP_INIT_HDR_EXT] = &ipa_reg_endp_init_hdr_ext, 22307f120bcSAlex Elder [ENDP_INIT_HDR_METADATA_MASK] = &ipa_reg_endp_init_hdr_metadata_mask, 22407f120bcSAlex Elder [ENDP_INIT_MODE] = &ipa_reg_endp_init_mode, 22507f120bcSAlex Elder [ENDP_INIT_AGGR] = &ipa_reg_endp_init_aggr, 22607f120bcSAlex Elder [ENDP_INIT_HOL_BLOCK_EN] = &ipa_reg_endp_init_hol_block_en, 22707f120bcSAlex Elder [ENDP_INIT_HOL_BLOCK_TIMER] = &ipa_reg_endp_init_hol_block_timer, 22807f120bcSAlex Elder [ENDP_INIT_DEAGGR] = &ipa_reg_endp_init_deaggr, 22907f120bcSAlex Elder [ENDP_INIT_RSRC_GRP] = &ipa_reg_endp_init_rsrc_grp, 23007f120bcSAlex Elder [ENDP_INIT_SEQ] = &ipa_reg_endp_init_seq, 23107f120bcSAlex Elder [ENDP_STATUS] = &ipa_reg_endp_status, 23207f120bcSAlex Elder [ENDP_FILTER_ROUTER_HSH_CFG] = &ipa_reg_endp_filter_router_hsh_cfg, 23307f120bcSAlex Elder [IPA_IRQ_STTS] = &ipa_reg_ipa_irq_stts, 23407f120bcSAlex Elder [IPA_IRQ_EN] = &ipa_reg_ipa_irq_en, 23507f120bcSAlex Elder [IPA_IRQ_CLR] = &ipa_reg_ipa_irq_clr, 23607f120bcSAlex Elder [IPA_IRQ_UC] = &ipa_reg_ipa_irq_uc, 23707f120bcSAlex Elder [IRQ_SUSPEND_INFO] = &ipa_reg_irq_suspend_info, 23807f120bcSAlex Elder [IRQ_SUSPEND_EN] = &ipa_reg_irq_suspend_en, 23907f120bcSAlex Elder [IRQ_SUSPEND_CLR] = &ipa_reg_irq_suspend_clr, 24007f120bcSAlex Elder }; 24107f120bcSAlex Elder 24207f120bcSAlex Elder const struct ipa_regs ipa_regs_v3_1 = { 24307f120bcSAlex Elder .reg_count = ARRAY_SIZE(ipa_reg_array), 24407f120bcSAlex Elder .reg = ipa_reg_array, 24507f120bcSAlex Elder }; 246