From ebf5d7cb55ae0d1ed2116cf25ae210a9c8ecc4e5 Mon Sep 17 00:00:00 2001
From: Gaurang Rathod <Gaurang.Rathod@infineon.com>
Date: Sun, 29 Jan 2023 23:52:24 -0600
Subject: [PATCH 199/296] brcmfmac: Chip id changes for 43022

Signed-off-by: Gaurang Rathod <Gaurang.Rathod@infineon.com>


---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c    | 4 ++++
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c  | 4 ++--
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c    | 7 ++++++-
 .../net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h  | 1 +
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index 931b743442af..d58cd5ae7b4f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -1714,6 +1714,7 @@ bool brcmf_chip_sr_capable(struct brcmf_chip *pub)
 	case BRCM_CC_4359_CHIP_ID:
 	case CY_CC_43752_CHIP_ID:
 	case CY_CC_43012_CHIP_ID:
+	case CY_CC_43022_CHIP_ID:
 		addr = CORE_CC_REG(pmu->base, retention_ctl);
 		reg = chip->ops->read32(chip->ctx, addr);
 		return (reg & (PMU_RCTL_MACPHY_DISABLE_MASK |
@@ -1747,6 +1748,7 @@ void brcmf_chip_reset_pmu_regs(struct brcmf_chip *pub)
 
 	switch (pub->chip) {
 	case CY_CC_43012_CHIP_ID:
+	case CY_CC_43022_CHIP_ID:
 		/* SW scratch */
 		addr = CORE_CC_REG(base, swscratch);
 		chip->ops->write32(chip->ctx, addr, 0);
@@ -1780,6 +1782,7 @@ void brcmf_chip_set_default_min_res_mask(struct brcmf_chip *pub)
 	base = brcmf_chip_get_pmu(pub)->base;
 	switch (pub->chip) {
 	case CY_CC_43012_CHIP_ID:
+	case CY_CC_43022_CHIP_ID:
 		addr = CORE_CC_REG(base, min_res_mask);
 		chip->ops->write32(chip->ctx, addr,
 			CY_43012_PMU_MIN_RES_MASK);
@@ -1852,6 +1855,7 @@ void brcmf_chip_reset_watchdog(struct brcmf_chip *pub)
 
 	switch (pub->chip) {
 	case CY_CC_43012_CHIP_ID:
+	case CY_CC_43022_CHIP_ID:
 		addr = CORE_CC_REG(base, min_res_mask);
 		chip->ops->write32(chip->ctx, addr,
 			CY_43012_PMU_MIN_RES_MASK);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index d475dbd56454..cfdeeee1ead4 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -598,8 +598,8 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 		goto done;
 	}
 
-	/* Enable event_msg_ext specific to 43012 chip */
-	if (bus->chip == CY_CC_43012_CHIP_ID) {
+	/* Enable event_msg_ext specific to 43012/43022 chip */
+	if (bus->chip == CY_CC_43012_CHIP_ID || bus->chip == CY_CC_43022_CHIP_ID) {
 		/* Program event_msg_ext to support event larger than 128 */
 		msglen = (roundup(BRCMF_E_LAST, NBBY) / NBBY) +
 				  EVENTMSGS_EXT_STRUCT_SIZE;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 7c067a332861..8e46ec1dffb6 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -668,6 +668,7 @@ CY_FW_DEF(4356, "cyfmac4356-sdio");
 CY_FW_DEF(4359, "cyfmac4359-sdio");
 CY_FW_DEF(4373, "cyfmac4373-sdio");
 CY_FW_DEF(43012, "cyfmac43012-sdio");
+CY_FW_DEF(43022, "cyfmac43022-sdio");
 BRCMF_FW_CLM_DEF(43752, "brcmfmac43752-sdio");
 CY_FW_DEF(89459, "cyfmac54591-sdio");
 CY_FW_TRXSE_DEF(55500, "cyfmac55500-sdio");
@@ -705,6 +706,7 @@ static const struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = {
 	BRCMF_FW_ENTRY(CY_CC_4373_CHIP_ID, 0xFFFFFFFF, 4373),
 	BRCMF_FW_ENTRY(CY_CC_43012_CHIP_ID, 0xFFFFFFFF, 43012),
 	BRCMF_FW_ENTRY(CY_CC_43439_CHIP_ID, 0xFFFFFFFF, 43439),
+	BRCMF_FW_ENTRY(CY_CC_43022_CHIP_ID, 0xFFFFFFFF, 43022),
 	BRCMF_FW_ENTRY(CY_CC_43752_CHIP_ID, 0xFFFFFFFF, 43752),
 	BRCMF_FW_ENTRY(CY_CC_89459_CHIP_ID, 0xFFFFFFFF, 89459),
 	BRCMF_FW_ENTRY(CY_CC_55572_CHIP_ID, 0xFFFFFFFF, 55572),
@@ -771,6 +773,7 @@ brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on)
 	 */
 	if (!on && ((bus->ci->chip == CY_CC_43012_CHIP_ID) ||
 		    (bus->ci->chip == CY_CC_55500_CHIP_ID) ||
+		    (bus->ci->chip == CY_CC_43022_CHIP_ID) ||
 		    (bus->ci->chip == CY_CC_55572_CHIP_ID)))
 		return err;
 
@@ -2667,7 +2670,8 @@ static int brcmf_sdio_tx_ctrlframe(struct brcmf_sdio *bus, u8 *frame, u16 len)
 
 static bool brcmf_chip_is_ulp(struct brcmf_chip *ci)
 {
-	if (ci->chip == CY_CC_43012_CHIP_ID)
+	if (ci->chip == CY_CC_43012_CHIP_ID ||
+	    ci->chip == CY_CC_43022_CHIP_ID)
 		return true;
 	else
 		return false;
@@ -3876,6 +3880,7 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus,
 static bool brcmf_sdio_aos_no_decode(struct brcmf_sdio *bus)
 {
 	if (bus->ci->chip == CY_CC_43012_CHIP_ID ||
+	    bus->ci->chip == CY_CC_43022_CHIP_ID ||
 	    bus->ci->chip == CY_CC_43752_CHIP_ID ||
 	    bus->ci->chip == CY_CC_4373_CHIP_ID ||
 	    bus->ci->chip == CY_CC_55500_CHIP_ID ||
diff --git a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
index 50cbc7c1137b..65264da8cf4e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
+++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
@@ -59,6 +59,7 @@
 #define CY_CC_43430_CHIP_ID		43430
 #define CY_CC_4373_CHIP_ID		0x4373
 #define CY_CC_43012_CHIP_ID		43012
+#define CY_CC_43022_CHIP_ID		43022
 #define CY_CC_43439_CHIP_ID		43439
 #define CY_CC_43752_CHIP_ID		43752
 #define CY_CC_54591_CHIP_ID		0x4355
-- 
2.25.1

