From patchwork Fri Feb 14 11:52:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 11382143 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 401F913A4 for ; Fri, 14 Feb 2020 11:52:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02AC1222C2 for ; Fri, 14 Feb 2020 11:52:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="EHRx8tuC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728264AbgBNLwS (ORCPT ); Fri, 14 Feb 2020 06:52:18 -0500 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:44336 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727805AbgBNLwS (ORCPT ); Fri, 14 Feb 2020 06:52:18 -0500 Received-SPF: Pass (esa4.microchip.iphmx.com: domain of Ajay.Kathat@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="Ajay.Kathat@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com -exists:%{i}.spf.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa4.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa4.microchip.iphmx.com; spf=Pass smtp.mailfrom=Ajay.Kathat@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: TBF+hzJdIOLvmtFgrepvVYmXswrQrdmRiTugeK6tdMgH8lIfdo+olP25Zd7ym4ebeP0m5rGjnO YgiFvSfRQYAhqahuBcQvd7bcFJGGYlsxnAXDZyskyWbmfNLVemNtEU6rvF15XSTvvxD5srAzJE J4vrc0228o2DLsWtQOeNocKAuyC+Dr/foG3lVa8mgHbHaHH+xHzeJ6pAnm0sGMvGMuRSlTaSEU RqlNpCG30tM6Tgr7ZV9OxdHuq4waaB9HxGtPdhwvMkHJGllUBjzyT2Hkz+iaKM0YdY9tZfe7su H9s= X-IronPort-AV: E=Sophos;i="5.70,440,1574146800"; d="scan'208";a="64197884" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2020 04:52:17 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 14 Feb 2020 04:52:19 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 14 Feb 2020 04:52:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MrlfWRVHdecF4KOE5YddKOgrpXWnVVYlhRDZZ/k9goeA53rcLxOK+xBVuftjqqxADb5p2FjBAUsCZU2S1x5hv2Y/QrThOImgfEnc55pkLdIAL2iRRE+bvZnKCI9PmM7tsrcSe1Gl0wTuA/1yqp16rbqNuLRnkT1Y7UykwoKUcWiJs/atzF8v+NxJPy42LgaNdQG3ecbfxl4V16z3e3xPNRkhzw+v2tVKCi8DdPKLF94/9lc2ay/aOSVIYdZDdClIVWQkExacQn71StPak2zi+k0imengfMG1JaaYRn6Z6C8YkVrh5xiCC/RlRoEF5m8kb5FLhC+zXgFND6SDfn845Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q4T5Y6SGXu1kugvEHjbw/UIMbc7W1MnLPH2atAaWFfo=; b=feFF3RQSOthyK9MwfA8qMaq+uGMQMnvGXY10pPIaGmDtIUDFWv57rGLslhe5qAL0KQRDSdOLUP/aR383mIC2U+6hhV47293eCQJ5+L7Od2MO/8S+KktDCTMW7WcA6LVtE1WZ86NJmz7K16ikhVLw7tdPN6q9I1RuxIcrmkOr7vl9Ug6cZu8PgDZvQXkfJgZKVsUE+Fuefo5TL/5WsiVCoACVWiYT3HASakHOjWB4dyv+RsmizIgB9farj5rTpRAuSoibLz/JiD5+hulCLWvRji0ffwbuPl6DOj0iHRPt1TmJeMVLBOP0E0Bky4yCF7JmxBJ4fDLzqDcRlJunX4a/Fw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q4T5Y6SGXu1kugvEHjbw/UIMbc7W1MnLPH2atAaWFfo=; b=EHRx8tuCvmes2sTCUlfC1HhhOCXQDab1yqz7H7X4Oq1bpFI/z6cYA0NLb6EuTEsfjsnZuglSjPutOzalHXNU6/RzcJoxrvspJVUzMKQS8qLrt6Uf08o69z/zbP+RBs+xDwmHLKWLHHDI40HZA5z8V/DFQ1f/uZ/uNf0+bQ/u9ro= Received: from BN6PR11MB3985.namprd11.prod.outlook.com (10.255.129.78) by BN6PR11MB1652.namprd11.prod.outlook.com (10.172.24.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.25; Fri, 14 Feb 2020 11:52:15 +0000 Received: from BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4]) by BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4%3]) with mapi id 15.20.2729.027; Fri, 14 Feb 2020 11:52:15 +0000 From: To: CC: , , , , Subject: [PATCH 1/8] staging: wilc1000: make use of FIELD_GET/_PREP macro Thread-Topic: [PATCH 1/8] staging: wilc1000: make use of FIELD_GET/_PREP macro Thread-Index: AQHV4y0zpLk4/0zZ5UOS9u/6UMd/gg== Date: Fri, 14 Feb 2020 11:52:15 +0000 Message-ID: <20200214172250.13026-2-ajay.kathat@microchip.com> References: <20200214172250.13026-1-ajay.kathat@microchip.com> In-Reply-To: <20200214172250.13026-1-ajay.kathat@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-originating-ip: [121.244.27.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a3db65d6-e1c1-4526-84db-08d7b14455df x-ms-traffictypediagnostic: BN6PR11MB1652: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:335; x-forefront-prvs: 03137AC81E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39850400004)(136003)(189003)(199004)(6506007)(2906002)(26005)(6512007)(2616005)(107886003)(6486002)(5660300002)(186003)(316002)(54906003)(4326008)(81156014)(81166006)(86362001)(64756008)(66476007)(66446008)(66556008)(8936002)(8676002)(76116006)(91956017)(66946007)(478600001)(36756003)(6916009)(71200400001)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR11MB1652;H:BN6PR11MB3985.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 30/jYRV4YLrTF+C60Jd4A9uboPzIEiKo9uUMuaYM96U3MoLS0oUA008bXDKMKeXvycqnl6R01n+wwZmEyDWKYi9iyOQPQ2yIA0kmUIM45JFqF+HbjIW0dRhJluN29cVfZPQ64spvJzctYRlYtocXqr9wdHzolI32FCGf1mTHn6RFDvwyInwV9N6A8Drlj4jaV/cPlw+ddltU52ps6L1FNV6rS0VQoFDAQtB6KEF9JA1u2vnfQZ8WtpcmmPun1DOuh4aYRVRZGBXbb5g8A56FIzBcsn3oX1kjproTJHlCL5Ok3TsZ93pEENSp2UKZJ7d7IOGoYX+OIujhIPyGWn+HVYSsgoYbH+/p2evCRbR4rwQJRozOd7+J+0jFiQJXID/AByiDo5lSdcELI1UaCZlxzdBsixR7rcke94BL9S4espVodZ/dppJ2MSQiU1tYNrul x-ms-exchange-antispam-messagedata: hy1ZeMDE2b6aNSa9F5A06jdZwVtouTo2TW8kjjQNmjFDVaWyXu1p69i9D5O7yPD6prJK7B3qMKfEY4k/dF7rsnFjYGKUm1pTtMXkzKUHzAnoW3rqTir2vvuyPIQY2Wp/8R4j8V+Ayjzoj2o6k3bQgQ== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: a3db65d6-e1c1-4526-84db-08d7b14455df X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2020 11:52:15.0959 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: wk+07f2cBmFn/XaDD2uTzP7P59xsl2HnshCp39Y0u+KciudxAbjOA4TNyEnFceRs4jATGH1ryWG1KBn7g9ixNNPz2cOpTufBh6djexIaUAk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1652 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Simplified the code by making use of FIELD_GET/_PREP bitfield macro. Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/cfg80211.c | 2 +- drivers/staging/wilc1000/mon.c | 2 +- drivers/staging/wilc1000/netdev.h | 2 -- drivers/staging/wilc1000/spi.c | 2 +- drivers/staging/wilc1000/wlan.c | 32 +++++++++++++++-------------- drivers/staging/wilc1000/wlan.h | 20 +++++++++++++++++- 6 files changed, 39 insertions(+), 21 deletions(-) diff --git a/drivers/staging/wilc1000/cfg80211.c b/drivers/staging/wilc1000/cfg80211.c index d9c7bed2e6fb..995b1f306807 100644 --- a/drivers/staging/wilc1000/cfg80211.c +++ b/drivers/staging/wilc1000/cfg80211.c @@ -988,7 +988,7 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) s32 freq; header = get_unaligned_le32(buff - HOST_HDR_OFFSET); - pkt_offset = GET_PKT_OFFSET(header); + pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header); if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { bool ack = false; diff --git a/drivers/staging/wilc1000/mon.c b/drivers/staging/wilc1000/mon.c index 48ac33f06f63..60331417bd98 100644 --- a/drivers/staging/wilc1000/mon.c +++ b/drivers/staging/wilc1000/mon.c @@ -40,7 +40,7 @@ void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size) * The packet offset field contain info about what type of management * the frame we are dealing with and ack status */ - pkt_offset = GET_PKT_OFFSET(header); + pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header); if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { /* hostapd callback mgmt frame */ diff --git a/drivers/staging/wilc1000/netdev.h b/drivers/staging/wilc1000/netdev.h index c475e78e3a69..e3689e2a4abb 100644 --- a/drivers/staging/wilc1000/netdev.h +++ b/drivers/staging/wilc1000/netdev.h @@ -29,8 +29,6 @@ #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 #define DEFAULT_LINK_SPEED 72 -#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) - struct wilc_wfi_stats { unsigned long rx_packets; unsigned long tx_packets; diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c index 9a9f3624e158..300c5c832572 100644 --- a/drivers/staging/wilc1000/spi.c +++ b/drivers/staging/wilc1000/spi.c @@ -898,7 +898,7 @@ static int wilc_spi_read_size(struct wilc *wilc, u32 *size) int ret; ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, size); - *size = *size & IRQ_DMA_WD_CNT_MASK; + *size = FIELD_GET(IRQ_DMA_WD_CNT_MASK, *size); return ret; } diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c index 601e4d1345d2..9dfabd1af4e7 100644 --- a/drivers/staging/wilc1000/wlan.c +++ b/drivers/staging/wilc1000/wlan.c @@ -568,8 +568,8 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) ret = func->hif_read_reg(wilc, WILC_HOST_VMM_CTL, ®); if (ret) break; - if ((reg >> 2) & 0x1) { - entries = ((reg >> 3) & 0x3f); + if (FIELD_GET(WILC_VMM_ENTRY_AVAILABLE, reg)) { + entries = FIELD_GET(WILC_VMM_ENTRY_COUNT, reg); break; } release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); @@ -610,6 +610,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) do { u32 header, buffer_offset; char *bssid; + u8 mgmt_ptk = 0; tqe = wilc_wlan_txq_remove_from_head(dev); if (!tqe) @@ -620,15 +621,16 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) break; le32_to_cpus(&vmm_table[i]); - vmm_sz = (vmm_table[i] & 0x3ff); + vmm_sz = FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]); vmm_sz *= 4; - header = (tqe->type << 31) | - (tqe->buffer_size << 15) | - vmm_sz; + if (tqe->type == WILC_MGMT_PKT) - header |= BIT(30); - else - header &= ~BIT(30); + mgmt_ptk = 1; + + header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tqe->type) | + FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, mgmt_ptk) | + FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->buffer_size) | + FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz)); cpu_to_le32s(&header); memcpy(&txb[offset], &header, 4); @@ -686,10 +688,10 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size) buff_ptr = buffer + offset; header = get_unaligned_le32(buff_ptr); - is_cfg_packet = (header >> 31) & 0x1; - pkt_offset = (header >> 22) & 0x1ff; - tp_len = (header >> 11) & 0x7ff; - pkt_len = header & 0x7ff; + is_cfg_packet = FIELD_GET(WILC_PKT_HDR_CONFIG_FIELD, header); + pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header); + tp_len = FIELD_GET(WILC_PKT_HDR_TOTAL_LEN_FIELD, header); + pkt_len = FIELD_GET(WILC_PKT_HDR_LEN_FIELD, header); if (pkt_len == 0 || tp_len == 0) break; @@ -758,11 +760,11 @@ static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status) int ret = 0; struct rxq_entry_t *rqe; - size = (int_status & 0x7fff) << 2; + size = FIELD_GET(WILC_INTERRUPT_DATA_SIZE, int_status) << 2; while (!size && retries < 10) { wilc->hif_func->hif_read_size(wilc, &size); - size = (size & 0x7fff) << 2; + size = FIELD_GET(WILC_INTERRUPT_DATA_SIZE, size) << 2; retries++; } diff --git a/drivers/staging/wilc1000/wlan.h b/drivers/staging/wilc1000/wlan.h index 8c4634262adb..d3e822c374eb 100644 --- a/drivers/staging/wilc1000/wlan.h +++ b/drivers/staging/wilc1000/wlan.h @@ -8,6 +8,7 @@ #define WILC_WLAN_H #include +#include /******************************************** * @@ -135,6 +136,23 @@ #define MODALIAS "WILC_SPI" #define GPIO_NUM 0x44 + +#define WILC_PKT_HDR_CONFIG_FIELD BIT(31) +#define WILC_PKT_HDR_OFFSET_FIELD GENMASK(30, 22) +#define WILC_PKT_HDR_TOTAL_LEN_FIELD GENMASK(21, 11) +#define WILC_PKT_HDR_LEN_FIELD GENMASK(10, 0) + +#define WILC_INTERRUPT_DATA_SIZE GENMASK(14, 0) + +#define WILC_VMM_BUFFER_SIZE GENMASK(9, 0) + +#define WILC_VMM_HDR_TYPE BIT(31) +#define WILC_VMM_HDR_MGMT_FIELD BIT(30) +#define WILC_VMM_HDR_PKT_SIZE GENMASK(29, 15) +#define WILC_VMM_HDR_BUFF_SIZE GENMASK(14, 0) + +#define WILC_VMM_ENTRY_COUNT GENMASK(8, 3) +#define WILC_VMM_ENTRY_AVAILABLE BIT(2) /*******************************************/ /* E0 and later Interrupt flags. */ /*******************************************/ @@ -150,7 +168,7 @@ /* 21: INT5 flag */ /*******************************************/ #define IRG_FLAGS_OFFSET 16 -#define IRQ_DMA_WD_CNT_MASK ((1ul << IRG_FLAGS_OFFSET) - 1) +#define IRQ_DMA_WD_CNT_MASK GENMASK(IRG_FLAGS_OFFSET - 1, 0) #define INT_0 BIT(IRG_FLAGS_OFFSET) #define INT_1 BIT(IRG_FLAGS_OFFSET + 1) #define INT_2 BIT(IRG_FLAGS_OFFSET + 2) From patchwork Fri Feb 14 11:52:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 11382147 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 593291580 for ; Fri, 14 Feb 2020 11:52:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CFC72187F for ; Fri, 14 Feb 2020 11:52:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="s8yrRqQ3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728658AbgBNLwY (ORCPT ); Fri, 14 Feb 2020 06:52:24 -0500 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:38153 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbgBNLwY (ORCPT ); Fri, 14 Feb 2020 06:52:24 -0500 Received-SPF: Pass (esa6.microchip.iphmx.com: domain of Ajay.Kathat@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="Ajay.Kathat@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com -exists:%{i}.spf.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa6.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa6.microchip.iphmx.com; spf=Pass smtp.mailfrom=Ajay.Kathat@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: VejlnREsMaibfsPd9byep8m8rUuHUZKHajWpCY0PNatqhcgNqfgsjhQLlBlG4u8F+HC0UbtmD5 s056LuLGH0DVOAfDSDLFbB9REThOhi0DUR03RxWq6KaOIw73BtEYdCGo5igvAb4lMXc/DsvmAs DCmlxB8SdNSnRRtR8Y6W5n3d/GHlbuCsv3YzgbUGLBvDx78vuqm3CDCm9sv+qZv3GJLcHUPM5+ lfeFfGJCUmtt+ENxqvDW1Xis+6yPbuLqL0h4ZHlJiJpI3zTgbIW5VO9B/rrS4cyGcixhpfYVNu Ln8= X-IronPort-AV: E=Sophos;i="5.70,440,1574146800"; d="scan'208";a="2407498" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2020 04:52:22 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 14 Feb 2020 04:52:17 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 14 Feb 2020 04:52:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g/62RKRkxSJxThalYSTQ0PkHYenEoB6XfG6lcBj1nrGd0qo51oE3jSmFfda1W/s3020rlrKBxe6sq2hIppRSSr2tAQSx4IOSc7cOX31cx8Ny2orysT8UuvcRb+v9n2IxtVjXXYitEkmp/mdcmEG5btx1ehTKJFCZReirQOFODtARzqcv9mKxPRlYpH1BR+ksuLVCWdoel9csjeylX17F/PbdjsQfquUEZJIWap+qZaSlt010aThuxOGrNjt10+MLLwSyxC0ZyvnPkS5/kVJ6WhrsC7qeaY3qLmU42ZakleK51p83csp6nxJEDm+3nk/XoRsAS9LLKb5/oo5FgBV1/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hZB9xt5EMqgliNQU4hwMcuTiop27heqZSAUa5xhfOPQ=; b=TIUoyKF1SYll3TAg0Uu2sOuA/l38HfeBs/IpPC1cX87ysF5GgajPRZz5f56pPKdqWPJF9LvezRdCa2CbloObtJtH7v7JV6RJ7AyJA3nrDaP6Ej1OpjFz1Fx+AKXbLg/96V0FpjB5NvZJi6lvhacLWpnKJE5+2qnTl6UC/+IVDEzt1yw6ng+F0WRHymLv/JVyJgGeWCGzJTH4fCC+TRfAy8p9XVMvkAC4F2nZCWG6Yt/NGr//mAHO08LeiZ7DOCiDYdn/9g8gOjydvnMUart0a/ZSutplwkuCnQ2jYazBgb1juPgbp+0zsVpZJvnTgfGcBpi7wK8NcAPbCb0+6TVq8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hZB9xt5EMqgliNQU4hwMcuTiop27heqZSAUa5xhfOPQ=; b=s8yrRqQ3SkN+tBzv91+UhKLm6h+Ko3EnE702aofC9PreemCOX11gGmMy8Ns3LLhwnxzY7fjO9t3zUJche+KSB4STdMcUkvaUPGTnHKJiVf2zYWazKQEy1HyqFrrFxud9FBmwsFcP7M3Etzmbg3LASa1T5ZuqpobtJG2e3lmEXKM= Received: from BN6PR11MB3985.namprd11.prod.outlook.com (10.255.129.78) by BN6PR11MB1652.namprd11.prod.outlook.com (10.172.24.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.25; Fri, 14 Feb 2020 11:52:16 +0000 Received: from BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4]) by BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4%3]) with mapi id 15.20.2729.027; Fri, 14 Feb 2020 11:52:16 +0000 From: To: CC: , , , , Subject: [PATCH 2/8] staging: wilc1000: remove use of MAX_NUN_INT_THRPT_ENH2 macro Thread-Topic: [PATCH 2/8] staging: wilc1000: remove use of MAX_NUN_INT_THRPT_ENH2 macro Thread-Index: AQHV4y00V2/iVypneE+qm9kUF2X10g== Date: Fri, 14 Feb 2020 11:52:16 +0000 Message-ID: <20200214172250.13026-3-ajay.kathat@microchip.com> References: <20200214172250.13026-1-ajay.kathat@microchip.com> In-Reply-To: <20200214172250.13026-1-ajay.kathat@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-originating-ip: [121.244.27.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b3487434-8847-45cc-e634-08d7b14456b0 x-ms-traffictypediagnostic: BN6PR11MB1652: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2043; x-forefront-prvs: 03137AC81E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39850400004)(136003)(189003)(199004)(6506007)(2906002)(26005)(6512007)(2616005)(107886003)(6486002)(5660300002)(186003)(316002)(54906003)(4326008)(81156014)(81166006)(86362001)(64756008)(66476007)(66446008)(66556008)(8936002)(8676002)(76116006)(91956017)(66946007)(478600001)(36756003)(6916009)(71200400001)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR11MB1652;H:BN6PR11MB3985.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lHIMfoATzo5zQRGe+U+puhQwET2ow8HouKEPpt6xA4mN/yjj0bLKuobISJxwJWeo6Bi85UNmsx66zsFPyKkL1+bRAdgORbIQQ0fVODdBTewnHq+tCSD6yvBieMRcRz0UkS9uDxY2OZs8Se2be+pRxgHdR65pmbv02TQBv0niE8xVkXwpDXTlTeQL1BRWjv7Nb88BOiZwNWcmhsaiPw8d1kvaV/bgejrVjaPDMZv+36wd681/eqhY0Bg/k+0hgrUY5TtGiv7XEiQfIkDsijwn9qT4WZv67LCgnOEG0zxnEeOOYLY5sCEW7ztIZjKCD6UT/Hw9GsgC4HVjJvEENRu+Kn+11R8123I3fKUVUSK5oyDoIjSBtz5wmDDvUewrX2+w2fGP0iqUYHq9F4m2IBQE1oDViCUntMYLaAkxiQJ12qruHGSzOqBgAbQX8VBRKFPj x-ms-exchange-antispam-messagedata: x8DNRfJJAbUmf7f2K7dLyxhDHSF4wW4jIxNXG9OVr8Vh68SUMD0/fvi6MoxGAJnj0gaGWyKi1ePI/CD6Ka4t2EwEg95SeI1CRQNSKpCYfA3e7/jCRA1i2lbYwkT1qIyBs5qfCVqOollALQpvfe6HQg== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: b3487434-8847-45cc-e634-08d7b14456b0 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2020 11:52:16.4022 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: qTtMRU/X8rP/WZv1GwqSGY5Y0cL5fTVJe+W8qCDL+4u8MRJNYsG1Wby4SvQiOcSEp2VbnsJMSBoJR8R8YGarooeqwBaIaRtepwCyw79SV8E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1652 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Make use of MAX_NUM_INT existing macro to handle the maximum supported interrupts count and removed MAX_NUN_INT_THRPT_ENH2 macro. Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/sdio.c | 20 +++----------------- drivers/staging/wilc1000/wlan.h | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c index ca99335687c4..77ef84f9cc37 100644 --- a/drivers/staging/wilc1000/sdio.c +++ b/drivers/staging/wilc1000/sdio.c @@ -27,8 +27,6 @@ struct wilc_sdio { bool irq_gpio; u32 block_size; int nint; -/* Max num interrupts allowed in registers 0xf7, 0xf8 */ -#define MAX_NUN_INT_THRPT_ENH2 (5) int has_thrpt_enh3; }; @@ -818,8 +816,6 @@ static int wilc_sdio_read_int(struct wilc *wilc, u32 *int_status) tmp |= INT_3; if (cmd.data & BIT(5)) tmp |= INT_4; - if (cmd.data & BIT(6)) - tmp |= INT_5; for (i = sdio_priv->nint; i < MAX_NUM_INT; i++) { if ((tmp >> (IRG_FLAGS_OFFSET + i)) & 0x1) { dev_err(&func->dev, @@ -854,16 +850,11 @@ static int wilc_sdio_clear_int_ext(struct wilc *wilc, u32 val) int vmm_ctl; if (sdio_priv->has_thrpt_enh3) { - u32 reg; + u32 reg = 0; - if (sdio_priv->irq_gpio) { - u32 flags; + if (sdio_priv->irq_gpio) + reg = val & (BIT(MAX_NUM_INT) - 1); - flags = val & (BIT(MAX_NUN_INT_THRPT_ENH2) - 1); - reg = flags; - } else { - reg = 0; - } /* select VMM table 0 */ if (val & SEL_VMM_TBL0) reg |= BIT(5); @@ -975,11 +966,6 @@ static int wilc_sdio_sync_ext(struct wilc *wilc, int nint) dev_err(&func->dev, "Too many interrupts (%d)...\n", nint); return -EINVAL; } - if (nint > MAX_NUN_INT_THRPT_ENH2) { - dev_err(&func->dev, - "Cannot support more than 5 interrupts when has_thrpt_enh2=1.\n"); - return -EINVAL; - } sdio_priv->nint = nint; diff --git a/drivers/staging/wilc1000/wlan.h b/drivers/staging/wilc1000/wlan.h index d3e822c374eb..876b02e93a81 100644 --- a/drivers/staging/wilc1000/wlan.h +++ b/drivers/staging/wilc1000/wlan.h @@ -175,7 +175,7 @@ #define INT_3 BIT(IRG_FLAGS_OFFSET + 3) #define INT_4 BIT(IRG_FLAGS_OFFSET + 4) #define INT_5 BIT(IRG_FLAGS_OFFSET + 5) -#define MAX_NUM_INT 6 +#define MAX_NUM_INT 5 /*******************************************/ /* E0 and later Interrupt flags. */ From patchwork Fri Feb 14 11:52:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 11382149 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E258B159A for ; Fri, 14 Feb 2020 11:52:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B85CE222C2 for ; Fri, 14 Feb 2020 11:52:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="DdwzWt3L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728850AbgBNLwZ (ORCPT ); Fri, 14 Feb 2020 06:52:25 -0500 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:38153 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgBNLwY (ORCPT ); Fri, 14 Feb 2020 06:52:24 -0500 Received-SPF: Pass (esa6.microchip.iphmx.com: domain of Ajay.Kathat@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="Ajay.Kathat@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com -exists:%{i}.spf.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa6.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa6.microchip.iphmx.com; spf=Pass smtp.mailfrom=Ajay.Kathat@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: ZbV8FXUZeRDEaCvu95JUGdjVxVxSvpCVKc649iZrijDtylZ7QVQp07mhJVWQNJmLRzhLFYE0dp ykdsZSBxEBJv4PO1YYM5xcXAkr0O/NzFpYh5gTEKAPwSGL06aI6qaVYTCWvBvS8EYzTySrlmV2 OkZEg76rLbBl0fK/rjNxdIGHkPxJ+50yLhg2WEsesSnF7cHC/ApDcCAWXntZsK5QYztz+tympx qZiFgPc0VO2GHAjjyxh0w1qqJbBRtNlKMoiHncfzfu8VQcJcqnhLSVuZVnRu7pAkwEc9gnimNl Rlw= X-IronPort-AV: E=Sophos;i="5.70,440,1574146800"; d="scan'208";a="2407500" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2020 04:52:22 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 14 Feb 2020 04:52:19 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 14 Feb 2020 04:52:21 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hcY4eIPkkK9LCm9Eb4m0H+Glam1Nc5sK0yS4euGMf9I0DBdo7hDyJ8I7YTvSf9EWVuBEkth8wFNTsmcGR1Ii9Fky6o0wG1wWmKbebd8WpxyPG9q3b4IfQNugbJy11J0dCf6F+BwdOGFxbzB7Yd1ShY6ECdV5UWsDsY+7bM5SvgthSeqwyx6xmE+tpnvBvYEM7e18tkwP+gFCPaXuwdAWGP+68+B+FHPIVsT1LXUcjCDsbhkn37plXworjlFDGU4RduVqKdC+geiFYOLmDsjr9QIaZytvwe4rJO7X66Ct1Hc97rFpP98UjqjWa0TTL0GksN97XTfO0EMmLB/qv4T0+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CgdvCm7s1YxFpluNUcAJ3TlrsooRFRN/fsQYrqSvzzI=; b=FvEShimJfuguISxIg2RQjWBPC9/HAglO5qSTvxpPy7g6R60lGwGP2o95iUL2+9v5V3L0H3kFe0eL6ZgBmX0Wq/BBXoPkoWvgC/KdehAOR5r2F17GRc5FLTrscmYmSebCzlCxu1kA07v5aZiCBKR/HR2dHDjDjow54Aipo8n8d4rqB7d8hWfq3ikB/aYRb8TQT3pgGYxjbxCiLMEaCOF5O5WQ9Wc00/NOyNKALOPuUyoiD8ShCwn++KiA3mOZpOnwRMTHJStbdZNmORBzA8WJDY4yzjDjZcph6QAQkYnW574SfZpZPFQajP/JXXKM292mQfLaG5EVJNh1EIj/K0N6GQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CgdvCm7s1YxFpluNUcAJ3TlrsooRFRN/fsQYrqSvzzI=; b=DdwzWt3L2WTht18SQW+wffthyUjL+gv+J2fA2QCiBNy80w3r4oKQjCHNbrCChMWHvVscWfXC+WMcDD3EkobPC8/YMGaZfwFT1WcWr1DLdiLxn2OkGYlaAuNpm7E/3AMPxE+uO34/u8co6WqeQs+VB6+OAS252ZFmoFBLjDdJ/Mo= Received: from BN6PR11MB3985.namprd11.prod.outlook.com (10.255.129.78) by BN6PR11MB1652.namprd11.prod.outlook.com (10.172.24.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.25; Fri, 14 Feb 2020 11:52:17 +0000 Received: from BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4]) by BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4%3]) with mapi id 15.20.2729.027; Fri, 14 Feb 2020 11:52:17 +0000 From: To: CC: , , , , Subject: [PATCH 3/8] staging: wilc1000: refactor interrupt handling for sdio Thread-Topic: [PATCH 3/8] staging: wilc1000: refactor interrupt handling for sdio Thread-Index: AQHV4y00e/jvJc9bxUmb1pIn/96kzg== Date: Fri, 14 Feb 2020 11:52:17 +0000 Message-ID: <20200214172250.13026-4-ajay.kathat@microchip.com> References: <20200214172250.13026-1-ajay.kathat@microchip.com> In-Reply-To: <20200214172250.13026-1-ajay.kathat@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-originating-ip: [121.244.27.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 218715a2-dece-49ba-4e13-08d7b1445765 x-ms-traffictypediagnostic: BN6PR11MB1652: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1013; x-forefront-prvs: 03137AC81E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39850400004)(136003)(189003)(199004)(6506007)(2906002)(26005)(6512007)(2616005)(107886003)(6486002)(5660300002)(186003)(316002)(54906003)(4326008)(81156014)(81166006)(86362001)(64756008)(66476007)(66446008)(66556008)(8936002)(8676002)(76116006)(91956017)(66946007)(478600001)(36756003)(6916009)(71200400001)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR11MB1652;H:BN6PR11MB3985.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0IIBvEcpN1/Fbj+u93YzwuE5rehrhunqu8TFc2wdTnDhWYJPDAF7DEhjcVdE9YMPkcoFPXnEdnMEWlUV3AoF5DmLQ3vFahZvRwa9Kha1vj+g6uMbz4WwEX81aj5CHI5j9Fpw4VUGmS5PJKQxKtF6Y8w9iIqVu747PbgaQgBjwyHDqzSfdeWIIGp5/Tyh7gMeMyPp3ZbRPAfbdC33dAQ4MRKm0qQZhZusWMqLGxtgnizKYla+PVPfJmpAN24oobVEx9Q/cC7byhtivQG11sfIXNaDghM1b2DRFTQveEUpBA06PSxIqBBqN6SeUOMr4OxBDbhTNZn/GJWaRRynh9bHEiD2G9+hDU+UL3Xsoi0qR77f6Svvll+quY/wEZIM5Sp72HH6j5ZcaLSwTKUKitB/mW+uBXE1La09mU/chgsqc2iRF30dwoJat6xmRyCAXKzj x-ms-exchange-antispam-messagedata: GugRH9WFMoQWkwFhFjZT0u6u2iJlq/LhEKzFLAiQLsyhw3nn9P1hna5wq2rdhhovF19G50gvk/5TODcmvDiw4J7dglUOJefDXQbDssLeFNqH3yQCSILNsLJgALRtaPTmEoHGs5EWxJ3O3flCxDaG7A== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 218715a2-dece-49ba-4e13-08d7b1445765 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2020 11:52:17.6095 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3pvnl0Uh4F8cF+0XFscggtMy3xqjd5ScMv+AN1gvR8luZwEomfJ52y9yBPPNitT0zL93KEsi6N5bxtPMY+uoYDwUOBZsTL76Ge9r9W1g4jA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1652 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Make use of FIELD_PREP/FIELD_GET macro to refactor the interrupt handling for SDIO. Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/sdio.c | 98 ++++++++++++--------------------- drivers/staging/wilc1000/spi.c | 4 -- drivers/staging/wilc1000/wlan.h | 3 + 3 files changed, 39 insertions(+), 66 deletions(-) diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c index 77ef84f9cc37..66706efc5711 100644 --- a/drivers/staging/wilc1000/sdio.c +++ b/drivers/staging/wilc1000/sdio.c @@ -26,7 +26,6 @@ static const struct sdio_device_id wilc_sdio_ids[] = { struct wilc_sdio { bool irq_gpio; u32 block_size; - int nint; int has_thrpt_enh3; }; @@ -790,6 +789,7 @@ static int wilc_sdio_read_int(struct wilc *wilc, u32 *int_status) struct sdio_func *func = dev_to_sdio_func(wilc->dev); struct wilc_sdio *sdio_priv = wilc->bus_data; u32 tmp; + u8 irq_flags; struct sdio_cmd52 cmd; wilc_sdio_read_size(wilc, &tmp); @@ -798,44 +798,22 @@ static int wilc_sdio_read_int(struct wilc *wilc, u32 *int_status) * Read IRQ flags **/ if (!sdio_priv->irq_gpio) { - int i; - - cmd.read_write = 0; cmd.function = 1; cmd.address = 0x04; - cmd.data = 0; - wilc_sdio_cmd52(wilc, &cmd); - - if (cmd.data & BIT(0)) - tmp |= INT_0; - if (cmd.data & BIT(2)) - tmp |= INT_1; - if (cmd.data & BIT(3)) - tmp |= INT_2; - if (cmd.data & BIT(4)) - tmp |= INT_3; - if (cmd.data & BIT(5)) - tmp |= INT_4; - for (i = sdio_priv->nint; i < MAX_NUM_INT; i++) { - if ((tmp >> (IRG_FLAGS_OFFSET + i)) & 0x1) { - dev_err(&func->dev, - "Unexpected interrupt (1) : tmp=%x, data=%x\n", - tmp, cmd.data); - break; - } - } } else { - u32 irq_flags; - - cmd.read_write = 0; cmd.function = 0; - cmd.raw = 0; cmd.address = 0xf7; - cmd.data = 0; - wilc_sdio_cmd52(wilc, &cmd); - irq_flags = cmd.data & 0x1f; - tmp |= ((irq_flags >> 0) << IRG_FLAGS_OFFSET); } + cmd.raw = 0; + cmd.read_write = 0; + cmd.data = 0; + wilc_sdio_cmd52(wilc, &cmd); + irq_flags = cmd.data; + tmp |= FIELD_PREP(IRG_FLAGS_MASK, cmd.data); + + if (FIELD_GET(UNHANDLED_IRQ_MASK, irq_flags)) + dev_err(&func->dev, "Unexpected interrupt (1) int=%lx\n", + FIELD_GET(UNHANDLED_IRQ_MASK, irq_flags)); *int_status = tmp; @@ -890,38 +868,36 @@ static int wilc_sdio_clear_int_ext(struct wilc *wilc, u32 val) * Must clear each interrupt individually. */ u32 flags; + int i; flags = val & (BIT(MAX_NUM_INT) - 1); - if (flags) { - int i; - - for (i = 0; i < sdio_priv->nint; i++) { - if (flags & 1) { - struct sdio_cmd52 cmd; - - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0xf8; - cmd.data = BIT(i); - - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd52, set 0xf8 data (%d) ...\n", - __LINE__); - return ret; - } + for (i = 0; i < NUM_INT_EXT && flags; i++) { + if (flags & BIT(i)) { + struct sdio_cmd52 cmd; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf8; + cmd.data = BIT(i); + + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd52, set 0xf8 data (%d) ...\n", + __LINE__); + return ret; } - flags >>= 1; + flags &= ~BIT(i); } + } - for (i = sdio_priv->nint; i < MAX_NUM_INT; i++) { - if (flags & 1) - dev_err(&func->dev, - "Unexpected interrupt cleared %d...\n", - i); - flags >>= 1; + for (i = NUM_INT_EXT; i < MAX_NUM_INT && flags; i++) { + if (flags & BIT(i)) { + dev_err(&func->dev, + "Unexpected interrupt cleared %d...\n", + i); + flags &= ~BIT(i); } } } @@ -967,8 +943,6 @@ static int wilc_sdio_sync_ext(struct wilc *wilc, int nint) return -EINVAL; } - sdio_priv->nint = nint; - /** * Disable power sequencer **/ diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c index 300c5c832572..37be627e72ce 100644 --- a/drivers/staging/wilc1000/spi.c +++ b/drivers/staging/wilc1000/spi.c @@ -12,7 +12,6 @@ struct wilc_spi { int crc_off; - int nint; }; static const struct wilc_hif_func wilc_hif_spi; @@ -916,7 +915,6 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val) static int wilc_spi_sync_ext(struct wilc *wilc, int nint) { struct spi_device *spi = to_spi_device(wilc->dev); - struct wilc_spi *spi_priv = wilc->bus_data; u32 reg; int ret, i; @@ -925,8 +923,6 @@ static int wilc_spi_sync_ext(struct wilc *wilc, int nint) return -EINVAL; } - spi_priv->nint = nint; - /* * interrupt pin mux select */ diff --git a/drivers/staging/wilc1000/wlan.h b/drivers/staging/wilc1000/wlan.h index 876b02e93a81..27f08b375345 100644 --- a/drivers/staging/wilc1000/wlan.h +++ b/drivers/staging/wilc1000/wlan.h @@ -176,6 +176,8 @@ #define INT_4 BIT(IRG_FLAGS_OFFSET + 4) #define INT_5 BIT(IRG_FLAGS_OFFSET + 5) #define MAX_NUM_INT 5 +#define IRG_FLAGS_MASK GENMASK(IRG_FLAGS_OFFSET + MAX_NUM_INT, \ + IRG_FLAGS_OFFSET) /*******************************************/ /* E0 and later Interrupt flags. */ @@ -203,6 +205,7 @@ #define DATA_INT_EXT INT_0 #define ALL_INT_EXT DATA_INT_EXT #define NUM_INT_EXT 1 +#define UNHANDLED_IRQ_MASK GENMASK(MAX_NUM_INT - 1, NUM_INT_EXT) #define DATA_INT_CLR CLR_INT0 From patchwork Fri Feb 14 11:52:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 11382151 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8932F13A4 for ; Fri, 14 Feb 2020 11:52:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DC09222C2 for ; Fri, 14 Feb 2020 11:52:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="P+p9nHQd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728902AbgBNLwZ (ORCPT ); Fri, 14 Feb 2020 06:52:25 -0500 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:42590 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728689AbgBNLwY (ORCPT ); Fri, 14 Feb 2020 06:52:24 -0500 Received-SPF: Pass (esa2.microchip.iphmx.com: domain of Ajay.Kathat@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="Ajay.Kathat@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com -exists:%{i}.spf.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa2.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa2.microchip.iphmx.com; spf=Pass smtp.mailfrom=Ajay.Kathat@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: 3L+dZ3C5tl2s9MBSYm3YU8Nj+bUbyzzWQ11HsEGZdp6N9x0uWltgMfmjG/0lmxPlIz2WYy/oEY eXB7ZQA8DleC36v7NV2kygMpqQTn8w5jsC1EaAoCnOyC8YrzFqKTC/VkSMkeAm8uMnS/qKlsFy EDa5l8EuX/8B7295aM9lZGldrQFQAgQc2O1rD/9+9N1XbGcAlM7WSftGwWVE2oqdX7Dm8NYo7C KeREkv3fmuSppEX6MJ7E2JDdWA3EGaf0SRBVdi1/s0n5k9kLYOXUU1uFE8lOxywCwTCE2Hpznz 4OQ= X-IronPort-AV: E=Sophos;i="5.70,440,1574146800"; d="scan'208";a="65913231" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2020 04:52:22 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 14 Feb 2020 04:52:17 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 14 Feb 2020 04:52:17 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ic8rgLe7FULVYkZswnqSILoakekcgY9I9IPXDyHlRJLx6PsfLRjkRaP+Ba5LLoX8fULugwYaHb9sHZI+RNt+YzFhB77uKmLzx82ltJ8z8vJKpHqrg2h+lza0gqVIDHhAhw3IVeFFFORBPxmtIhmdDAd4023/cD7f3JYk2rPkTCIpxSUUcvPfNqkjs+Zg9NeeRrJ41O6dVX+2p3kqBvxBLuk+pgCn4dkDZDdiBpjf7KNF1MS28NX2frG+zuKIgGcu84xUSmshHApIMtGroBHFFWSGH5iheMeDhriQC0ynwEHw+x9EML/P5Q+U7htt6mgo80Lo6uxgmGNeaDWLKhGnsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PtVr42Go0BYLzbFSjwNuCLwJedypOsoN7S1WRLUJvaY=; b=PCWrjlm8PzNofAtHzciZ7WQGL077u2Ep95QXfza8XP6YTAz3SfyhW5gOBd17qABbJRe+xrYkyfrIwU6TSMUAnEjLZLMp2Dc0/hHQ8f6D8DkaCKqUFd0DMN1qp4buxrjGf0FZ+6M8QOsAPS5yHKbGQyxGVW6AqqAjYuRCl998V51IRmQRWUi7DaXMuvHUenY5vFwQTSpS1h+DpAScMQitZO5fk7iYZ2XxvrMVH4SRKOfb9sQukgJliMHgrKzgOnpYvHWL63qpffvFTRSulqCul9or0xFh+szmsL+FT0cdx+V+cl0wAavTQ/vpQDTXiqEVmhLFV99KVSyLUjWJcrvCkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PtVr42Go0BYLzbFSjwNuCLwJedypOsoN7S1WRLUJvaY=; b=P+p9nHQdjf6apN86w/DR0di5ANmV8i/s/cztmL3FhgL4g+RZDeLZQK7H+TPPB9PWLHQN8Qm6ZyCgfvLG0KoSLX9qi4deeAi8YvQtP4DO85k75OdWDBQYyr2BT00HVb5xWKQTLW7MXFnKtv1b4EbefhMjcwtayQcxfrk25w5nvng= Received: from BN6PR11MB3985.namprd11.prod.outlook.com (10.255.129.78) by BN6PR11MB1652.namprd11.prod.outlook.com (10.172.24.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.25; Fri, 14 Feb 2020 11:52:19 +0000 Received: from BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4]) by BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4%3]) with mapi id 15.20.2729.027; Fri, 14 Feb 2020 11:52:19 +0000 From: To: CC: , , , , Subject: [PATCH 4/8] staging: wilc1000: make use of ALIGN macro Thread-Topic: [PATCH 4/8] staging: wilc1000: make use of ALIGN macro Thread-Index: AQHV4y01fyqHwhyg7Ee2FuDOZILgyA== Date: Fri, 14 Feb 2020 11:52:18 +0000 Message-ID: <20200214172250.13026-5-ajay.kathat@microchip.com> References: <20200214172250.13026-1-ajay.kathat@microchip.com> In-Reply-To: <20200214172250.13026-1-ajay.kathat@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-originating-ip: [121.244.27.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 31369809-175a-45bc-2f8d-08d7b1445818 x-ms-traffictypediagnostic: BN6PR11MB1652: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1186; x-forefront-prvs: 03137AC81E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39850400004)(136003)(189003)(199004)(6506007)(2906002)(26005)(6512007)(2616005)(107886003)(6486002)(5660300002)(186003)(316002)(54906003)(4326008)(81156014)(81166006)(86362001)(64756008)(66476007)(66446008)(66556008)(8936002)(8676002)(76116006)(91956017)(66946007)(478600001)(36756003)(6916009)(71200400001)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR11MB1652;H:BN6PR11MB3985.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2lQ9l//zY2k9uI5Bhj1wyFU/t5z/fSBQr3MsNTA8EuIPoNz8T68L+7oFSye9BoYOcewFxLaXnLqjZsDqJQVkcPCBLxIfrwSCk3l7SARpSIlEoT3kP1S4HCPpwTIknONEKcUcwNjS1+wRC2rDVk3frhY8g/aso7b5lS3pnctNF6mrxhlOCmBnbfbRl5RP7xqm9qAlR8S66mYffrqEahMsQtIdbrzlZd+agDRliBEO1YuJp0u6POmwb+ZwUKF2OYCmOu7jxDsv17VqolbrVz/lCdES622KBvmrL/1IkX9EtK/fUZyFwYCxjXPIpFLIeomtEsqQCXv7YSq191NhbAn1oQskNdk4w9LYPd1mHwk/LRaZy5GTDDcnKb3cO02b9tLvfcHwbhcLd7KTba13B27m7LypqgGkW4K0wlSQJHaUZhGq2gkmYrrWm44S6LgKQQa6 x-ms-exchange-antispam-messagedata: 2rEK5mOJpwXol8fCpKOy0sOcGsZWFKN8nPemKZVofUD7tKpzE1mIXMtJa18V52lp9nqPdTleL0ELWZty/4lqtwCdDNJ2Am4to8AC9kPzhpKcs7XyrS77WbCDODEMIYIhDoVvC+NP3PefL8P1/uVQ5Q== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 31369809-175a-45bc-2f8d-08d7b1445818 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2020 11:52:18.8148 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SF1LmBZuBoOivnTZAbsW+XXhU8GuQFF44TXV0o1EUzjazh048I0UMIxLIgTd2dJnKhKsPTSeWkKVpu2r/L90qGNb5iytUPIbuQU1K4/pJGk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1652 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Make use of 'ALIGN' macro to align the size data value. Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/sdio.c | 34 ++------------------------------- drivers/staging/wilc1000/wlan.c | 4 +--- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c index 66706efc5711..212affc4b9c1 100644 --- a/drivers/staging/wilc1000/sdio.c +++ b/drivers/staging/wilc1000/sdio.c @@ -415,28 +415,12 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) cmd.read_write = 1; if (addr > 0) { - /** - * has to be word aligned... - **/ - if (size & 0x3) { - size += 4; - size &= ~0x3; - } - /** * func 0 access **/ cmd.function = 0; cmd.address = 0x10f; } else { - /** - * has to be word aligned... - **/ - if (size & 0x3) { - size += 4; - size &= ~0x3; - } - /** * func 1 access **/ @@ -444,6 +428,7 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) cmd.address = 0; } + size = ALIGN(size, 4); nblk = size / block_size; nleft = size % block_size; @@ -551,28 +536,12 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) cmd.read_write = 0; if (addr > 0) { - /** - * has to be word aligned... - **/ - if (size & 0x3) { - size += 4; - size &= ~0x3; - } - /** * func 0 access **/ cmd.function = 0; cmd.address = 0x10f; } else { - /** - * has to be word aligned... - **/ - if (size & 0x3) { - size += 4; - size &= ~0x3; - } - /** * func 1 access **/ @@ -580,6 +549,7 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) cmd.address = 0; } + size = ALIGN(size, 4); nblk = size / block_size; nleft = size % block_size; diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c index 9dfabd1af4e7..db4ef175ccee 100644 --- a/drivers/staging/wilc1000/wlan.c +++ b/drivers/staging/wilc1000/wlan.c @@ -508,9 +508,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) vmm_sz = HOST_HDR_OFFSET; vmm_sz += tqe->buffer_size; - - if (vmm_sz & 0x3) - vmm_sz = (vmm_sz + 4) & ~0x3; + vmm_sz = ALIGN(vmm_sz, 4); if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) break; From patchwork Fri Feb 14 11:52:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 11382157 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E246713A4 for ; Fri, 14 Feb 2020 11:52:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7B6022314 for ; Fri, 14 Feb 2020 11:52:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="ZqMZ+YDL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729032AbgBNLw1 (ORCPT ); Fri, 14 Feb 2020 06:52:27 -0500 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:12309 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728595AbgBNLwZ (ORCPT ); Fri, 14 Feb 2020 06:52:25 -0500 Received-SPF: Pass (esa3.microchip.iphmx.com: domain of Ajay.Kathat@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="Ajay.Kathat@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com -exists:%{i}.spf.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa3.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa3.microchip.iphmx.com; spf=Pass smtp.mailfrom=Ajay.Kathat@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: 9mQBf00YgoWVBEC/SVAy1cTTA8uP1EJm1mwssT2HaC10Iibu8ns/Z+br5+1JfBplIpTrDpXPpL J+N329TI03+nLiBztdNVVaBK+r5jdYTjOqq0GjK8ePr/sHn0nBnts+AoMThocIQvf2QRPm7D4p ciMjkqb5efKGlrdZCWR8nXajgOHz+G5RlUJ6Cv8kd7qTutf3RG7wOTrqudblKgmScrLXGQntW4 BbDavhR3xbe5aYIqd1fA6G29N1IwnDye2L6LCQX8RFWx7Utkp0rC+w2xsg25oBmopvUy9y55OG 9ug= X-IronPort-AV: E=Sophos;i="5.70,440,1574146800"; d="scan'208";a="66696566" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2020 04:52:22 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 14 Feb 2020 04:52:21 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 14 Feb 2020 04:52:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bujOsUU1sJVn4tpNl6DdGNC8J3YBJbr2ec6oP5U8kofRMBQ14eLikPdKnAEzU0W7vKUqB6EFbXB9bLK2XwAf4PyOUD731RmA7jnGVSuu0GpaJ1Y2GjABmNhnVser2Ht5/3bnudVRfR2q2Y1H8ydhcqFOw4UFjmdKKxC2kaKA7aR3ax2DNXVjXlCCqySn7YmcRzTsTipnqttcEngPaJtK5F0T1sizJ3h5NY2ydxJyOqBPeWX+JN+PaX521UjuQrAfK8I0NU2KYTuOcfzxQrp6tvoe5Z8FOQIerBY+Uh17NuApSzkqkQo0ADyyWZ5f7n+kUCwW67+01w+x6HvNWX41YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gTsTwpXVCcc/XEMlj+i3yx9evQXL+2DOj8hdRoHOWX4=; b=mwoDfktbzBAQaRLa7oQdFfXJwc3PqmE5eIBr3EPs/r6FP7NtUUJGl5VSSFZws9KsdzoHzuWJisi0/xLTraL3yGyGUJsYQ7AA2Feqi6nXdSgctV9g3MEe2QRdjnAinhv69iQQC+M6eIINjujKOpquaCLG5dlAyRHpei/COSEQK2tX7h5hTZ9lRURDZJ5ICWqvGMOoomSPyaztSjUrFGxYa0Hn6mhcxe7h/kguMnpxpa0PwXqpmI53a5RdYxyuLI4382iF3kaK60wd0GML86nO2fXPknXIQ0qAa6JFKTCERm+SuVSWOPvbLtVB35FLNoWTiXKsA5/8m+UGXw3oRvTlKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gTsTwpXVCcc/XEMlj+i3yx9evQXL+2DOj8hdRoHOWX4=; b=ZqMZ+YDLU1a2COZU7tGm7OX3zfI8+kASOkWPSfD42rESsLqxkUz31Tvh1Pp9or0opIJBLMLoAEqL1Foxe5KDfUdtSxaC4bPSjfCizKKQnNyyDNV+Xq5WVTCvc1WtuGxH8lg3jAIcdVZjRF1/6h+1fFr2RLcpB+UXMmqRkyXXizY= Received: from BN6PR11MB3985.namprd11.prod.outlook.com (10.255.129.78) by BN6PR11MB1652.namprd11.prod.outlook.com (10.172.24.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.25; Fri, 14 Feb 2020 11:52:20 +0000 Received: from BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4]) by BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4%3]) with mapi id 15.20.2729.027; Fri, 14 Feb 2020 11:52:20 +0000 From: To: CC: , , , , Subject: [PATCH 5/8] staging: wilc1000: use commmon function to set SDIO block size Thread-Topic: [PATCH 5/8] staging: wilc1000: use commmon function to set SDIO block size Thread-Index: AQHV4y023xTLXituAkSbMSiOMiI3jA== Date: Fri, 14 Feb 2020 11:52:20 +0000 Message-ID: <20200214172250.13026-6-ajay.kathat@microchip.com> References: <20200214172250.13026-1-ajay.kathat@microchip.com> In-Reply-To: <20200214172250.13026-1-ajay.kathat@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-originating-ip: [121.244.27.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fdc85ade-116c-4853-2a01-08d7b14458da x-ms-traffictypediagnostic: BN6PR11MB1652: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:65; x-forefront-prvs: 03137AC81E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39850400004)(136003)(189003)(199004)(6506007)(2906002)(26005)(6512007)(2616005)(107886003)(6486002)(5660300002)(186003)(316002)(54906003)(4326008)(81156014)(81166006)(86362001)(64756008)(66476007)(66446008)(66556008)(8936002)(8676002)(76116006)(91956017)(66946007)(478600001)(36756003)(6916009)(71200400001)(1076003)(49343001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR11MB1652;H:BN6PR11MB3985.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: L2s0vk1PF+w0IcT9kTGP9yAd7prl7xRE7Mhxwmx4kks0E/QFi05X2rzLQCtSoKXRDyN9M1OoUMOr+FR7Fl93gmseeqTn3t73qu26w5VtwVbJnATUCE/Ht3dsCNxSgUyxkonIxuMoNCUtkLVAAfYumR9l1OrL1uBRHkINd/jmkmnO1V/4t3B4TTJ0HsXiqYtZMaCPn+AyJ5ifqRAeI+S+3HzQw8hC9WUA6HABUrcTKVn0f4udoPVClou+MyG//cTqrHZhKx91BWNoaz9XkSreaJTDtWIp4cKzqjiT7KXciUvhwbD8mqUolAc0wQLGaG9hESllQiaX5tCt28lANU7lsP0GYl1Rk9SL97Ab47uxbKfPO2dmiAnyiZ9dnVOUtZPFN164s/GyPNNJgayF4GZR+nT59mhEjxLL9OIb2Fzpkr7XSFm3U/3p4O6fhBWNI3vErs8PSnG0eitdf0X9ATgYbdRaX4RVUSEHEWlouTT7nPcEsf2Zwz7AW/Y+cGyEphpQ x-ms-exchange-antispam-messagedata: 9sDqqrvGeBKUeyu1ldUldDEj8QMS6qo0JmJsOHSE7xFSUjF2k0mOkVWeN2Ey6QQRI2rcqy0Hb6uPoDryZU7Vw3AFkNkNyPReGt78cpEYU6J1o9v+HdcCD4VHNy72rldZeF8HNKwFrfhG0mv98251lg== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: fdc85ade-116c-4853-2a01-08d7b14458da X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2020 11:52:20.0241 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fIVZwi8cdpm+ykHslP+/sjWW+o127SPe0pdMht9Ncr3yEh7AtdqLSrMbNhWZT/FwisfYSSZbTj1fQp5tyXa9YykDoyK8xKefdODP5O+YxVk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1652 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Use common function wilc_sdio_set_block_size() to set the block size for SDIO. Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/sdio.c | 51 +++++++-------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c index 212affc4b9c1..57c0e8415bc9 100644 --- a/drivers/staging/wilc1000/sdio.c +++ b/drivers/staging/wilc1000/sdio.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "netdev.h" #include "cfg80211.h" @@ -292,7 +293,8 @@ static int wilc_sdio_set_func0_csa_address(struct wilc *wilc, u32 adr) return 0; } -static int wilc_sdio_set_func0_block_size(struct wilc *wilc, u32 block_size) +static int wilc_sdio_set_block_size(struct wilc *wilc, u8 func_num, + u32 block_size) { struct sdio_func *func = dev_to_sdio_func(wilc->dev); struct sdio_cmd52 cmd; @@ -301,52 +303,21 @@ static int wilc_sdio_set_func0_block_size(struct wilc *wilc, u32 block_size) cmd.read_write = 1; cmd.function = 0; cmd.raw = 0; - cmd.address = 0x10; + cmd.address = SDIO_FBR_BASE(func_num) + SDIO_CCCR_BLKSIZE; cmd.data = (u8)block_size; ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x10 data...\n"); + dev_err(&func->dev, "Failed cmd52, set %04x data...\n", + cmd.address); return ret; } - cmd.address = 0x11; + cmd.address = SDIO_FBR_BASE(func_num) + SDIO_CCCR_BLKSIZE + 1; cmd.data = (u8)(block_size >> 8); ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x11 data...\n"); - return ret; - } - - return 0; -} - -/******************************************** - * - * Function 1 - * - ********************************************/ - -static int wilc_sdio_set_func1_block_size(struct wilc *wilc, u32 block_size) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct sdio_cmd52 cmd; - int ret; - - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0x110; - cmd.data = (u8)block_size; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x110 data...\n"); - return ret; - } - cmd.address = 0x111; - cmd.data = (u8)(block_size >> 8); - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x111 data...\n"); + dev_err(&func->dev, "Failed cmd52, set %04x data...\n", + cmd.address); return ret; } @@ -638,7 +609,7 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume) /** * function 0 block size **/ - ret = wilc_sdio_set_func0_block_size(wilc, WILC_SDIO_BLOCK_SIZE); + ret = wilc_sdio_set_block_size(wilc, 0, WILC_SDIO_BLOCK_SIZE); if (ret) { dev_err(&func->dev, "Fail cmd 52, set func 0 block size...\n"); return ret; @@ -688,7 +659,7 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume) /** * func 1 is ready, set func 1 block size **/ - ret = wilc_sdio_set_func1_block_size(wilc, WILC_SDIO_BLOCK_SIZE); + ret = wilc_sdio_set_block_size(wilc, 1, WILC_SDIO_BLOCK_SIZE); if (ret) { dev_err(&func->dev, "Fail set func 1 block size...\n"); return ret; From patchwork Fri Feb 14 11:52:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 11382153 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A6ED159A for ; Fri, 14 Feb 2020 11:52:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06F28222C2 for ; Fri, 14 Feb 2020 11:52:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="N+5QNq9o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728755AbgBNLwZ (ORCPT ); Fri, 14 Feb 2020 06:52:25 -0500 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:42590 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727805AbgBNLwY (ORCPT ); Fri, 14 Feb 2020 06:52:24 -0500 Received-SPF: Pass (esa2.microchip.iphmx.com: domain of Ajay.Kathat@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="Ajay.Kathat@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com -exists:%{i}.spf.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa2.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa2.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa2.microchip.iphmx.com; spf=Pass smtp.mailfrom=Ajay.Kathat@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: U1niBVXvcirbDTDbeaw6FgfuS4a/elwOVrZULOWJqEwBDzgYy9O51R5PlRm92u5Vs+5kuQO/xD YwavTG4C+BIQAvDzmGOyQG94a7j1mGjGd36qwKCVInXOFdxhB70ZtueDveeKm7WGQs2lTGDpWo ExFs1I2hLIoc2F2T4FqdJ1UWyb/ex5JuVvxOOrOBEsDRjlQuTcek+ZQRtklzsNHobbALvbk2SG eGc2LrIKy8VHkMOpruKwAcX5OEdEsNmR3f7EoAtxk3sjw4plNvM8hhXgDcgjgWOp8gZ04ax2Am E7g= X-IronPort-AV: E=Sophos;i="5.70,440,1574146800"; d="scan'208";a="65913233" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2020 04:52:22 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 14 Feb 2020 04:52:20 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 14 Feb 2020 04:52:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PSiO4K09MAaf5d/+wvizFSMGtLNqU/9z/i6ca5fiATPQpkCXuaOneBUDSSmaJEzURwEEpx+zeXFPYuPmDSKWPuc97Xh3gCYHGG+WbjVYp98Of6e++llY4eXAGEnSyJBwwy8zF3KX9xrfsoyzWPwJBjG9vnIVrIK2Ny5BPDIU/9WgjpbWdmdwpOpfPhyytT0Vitz3P9OHIFj3sUvGypp4C1p1iQAHSWUg/d1clxtLryG7ZsNXpiz23fpBqOrz/urhBzj8w+ZcSo5H3LVrleHCIzPO8plgnmsekVHwFFCT83NAlWmFHd4akXE9LLbr9e62+TcIinz7Cu8e1SXYIo5G0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tq2VE6ZJqGMa/iPJFiRJMdGoKkneYzdKaghASYsDyGM=; b=U61ZjdC0rk+BUpPjfdJk2C4fo+Zhr0bTdkdJi3O65NTCG0JAxvS3SPMiLbuFinYWuTmrca5QrM7lvXg/ELsb1syIas8QrbnLHetZdtylCS+c4ZypG7/VfM3XodVBvezOg5hMAAt2RPgZU2V8NZk9cPTLwROs7LIt/t/bT5ROZDh+gaoBOwZ9kwCbK/dQ+kVQWEouPz3KzInCdIwQIi4kY2dVDPww8TBjRlxlENITNJjIwpn1tFdj2sqDoUVF3gA3I4I7S/fiGd720LNhD5020pIDTpzR2Rkh2+4rDkyMhoSc3uN3zEJ+QtUVR63sw3cAdmuuXYrRwZt8mUJVdnkhcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tq2VE6ZJqGMa/iPJFiRJMdGoKkneYzdKaghASYsDyGM=; b=N+5QNq9oGdwrTldzQPdirTawcL6B/5ltyjCK4XVKm2PoyPeFZbfPZd+9qn0EevDbsf0RmoNVUJTZrLZKD4aSkpUFaWcRMerKXq3BbZlbxR3Yn9Nei3gf/WWNjmakV24q3jLVvfWAuVNNlhPadoGjMDtrCRqRGRUrIZ4LPIQTVfo= Received: from BN6PR11MB3985.namprd11.prod.outlook.com (10.255.129.78) by BN6PR11MB1652.namprd11.prod.outlook.com (10.172.24.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.25; Fri, 14 Feb 2020 11:52:21 +0000 Received: from BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4]) by BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4%3]) with mapi id 15.20.2729.027; Fri, 14 Feb 2020 11:52:21 +0000 From: To: CC: , , , , Subject: [PATCH 6/8] staging: wilc1000: define macros for different register address for SDIO Thread-Topic: [PATCH 6/8] staging: wilc1000: define macros for different register address for SDIO Thread-Index: AQHV4y02d5Z3dnBw90ulNuON4rAHrg== Date: Fri, 14 Feb 2020 11:52:21 +0000 Message-ID: <20200214172250.13026-7-ajay.kathat@microchip.com> References: <20200214172250.13026-1-ajay.kathat@microchip.com> In-Reply-To: <20200214172250.13026-1-ajay.kathat@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-originating-ip: [121.244.27.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 89abfd1d-fa6a-4bbf-dff0-08d7b144598e x-ms-traffictypediagnostic: BN6PR11MB1652: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:71; x-forefront-prvs: 03137AC81E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39850400004)(136003)(189003)(199004)(6506007)(2906002)(26005)(6512007)(2616005)(107886003)(6486002)(5660300002)(186003)(316002)(54906003)(4326008)(81156014)(81166006)(86362001)(64756008)(66476007)(66446008)(66556008)(8936002)(8676002)(76116006)(91956017)(66946007)(478600001)(36756003)(6916009)(71200400001)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR11MB1652;H:BN6PR11MB3985.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: c2KyryzoS2JvaOn4e6o8UQzE7I6SwC9oDDB59yZ97aX03KuwidTfYmI41zquhPZnImO8JGEzbP7tYkHwezYVffC+ocS9pbKhYV5NRGM+jXy1f4LhaBUqFHkQiJPt1XgI544u3QfjPhMOcxM0ZmWmV5J2pfTsrC0IKPj110VwR96RhzmvhcSgL4dSDuxhfrCeTWEUCQL1Pov+HgE1niHxnMzLFdFRhW7TU/V2KcyEAPOwG/ULYiGXRyp4/khK/wRS9uZWa6Oy8UCpsSrKFk0+BijFu4EBKs5rhhxFvg34p/v3AsTD3VE66+y2kAYEY/JwFFiTJV7gM0EqcXthUAOrZ8/VCslWqYctOLfSZA6RdqpVMYhah6fFd47O1SRGsbdw6qq+SncQG0Wy9lUc8Ee4neSCfy2Zg72zTi5ASBEPqsP7g/j4DlU+wKuT3vf2Sv3W x-ms-exchange-antispam-messagedata: ftfisfXMSCfcfTiIuD9y4YPLKpeQve3KQn6SVrkJkYzOFRf/ZsRtZLz2/Y/iFGbZTwgkZR1vW726/obSPMpLraiGxUAs2kqgPo2JuNU+7x1hd3d5Er2AbeBthoNznA7V9IGCtJIJVS15Y7+TWsPxLA== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 89abfd1d-fa6a-4bbf-dff0-08d7b144598e X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2020 11:52:21.2873 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: PE/889O7cE1FAilRcg7IqfIFNVqZhjG5lUbd5ifTF8DGqCm5MtQVj8DInXPMpHoc1XFRj7v+0sRt+qvX2mOg16gkNx3FSsIrmQcURSX1gMY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1652 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Instead of using hardcoded value for SDIO register address added the macro for them. Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/sdio.c | 77 +++++++++++++++++---------------- drivers/staging/wilc1000/wlan.h | 36 +++++++++++++++ 2 files changed, 76 insertions(+), 37 deletions(-) diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c index 57c0e8415bc9..0670c5956aef 100644 --- a/drivers/staging/wilc1000/sdio.c +++ b/drivers/staging/wilc1000/sdio.c @@ -183,8 +183,8 @@ static int wilc_sdio_reset(struct wilc *wilc) cmd.read_write = 1; cmd.function = 0; cmd.raw = 0; - cmd.address = 0x6; - cmd.data = 0x8; + cmd.address = SDIO_CCCR_ABORT; + cmd.data = WILC_SDIO_CCCR_ABORT_RESET; ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { dev_err(&func->dev, "Fail cmd 52, reset cmd ...\n"); @@ -266,27 +266,30 @@ static int wilc_sdio_set_func0_csa_address(struct wilc *wilc, u32 adr) cmd.read_write = 1; cmd.function = 0; cmd.raw = 0; - cmd.address = 0x10c; + cmd.address = WILC_SDIO_FBR_CSA_REG; cmd.data = (u8)adr; ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x10c data...\n"); + dev_err(&func->dev, "Failed cmd52, set %04x data...\n", + cmd.address); return ret; } - cmd.address = 0x10d; + cmd.address = WILC_SDIO_FBR_CSA_REG + 1; cmd.data = (u8)(adr >> 8); ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x10d data...\n"); + dev_err(&func->dev, "Failed cmd52, set %04x data...\n", + cmd.address); return ret; } - cmd.address = 0x10e; + cmd.address = WILC_SDIO_FBR_CSA_REG + 2; cmd.data = (u8)(adr >> 16); ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x10e data...\n"); + dev_err(&func->dev, "Failed cmd52, set %04x data...\n", + cmd.address); return ret; } @@ -337,7 +340,7 @@ static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, u32 data) cpu_to_le32s(&data); - if (addr >= 0xf0 && addr <= 0xff) { + if (addr >= 0xf0 && addr <= 0xff) { /* only vendor specific registers */ struct sdio_cmd52 cmd; cmd.read_write = 1; @@ -361,7 +364,7 @@ static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, u32 data) cmd.read_write = 1; cmd.function = 0; - cmd.address = 0x10f; + cmd.address = WILC_SDIO_FBR_DATA_REG; cmd.block_mode = 0; cmd.increment = 1; cmd.count = 4; @@ -390,13 +393,13 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) * func 0 access **/ cmd.function = 0; - cmd.address = 0x10f; + cmd.address = WILC_SDIO_FBR_DATA_REG; } else { /** * func 1 access **/ cmd.function = 1; - cmd.address = 0; + cmd.address = WILC_SDIO_F1_DATA_REG; } size = ALIGN(size, 4); @@ -455,7 +458,7 @@ static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data) struct wilc_sdio *sdio_priv = wilc->bus_data; int ret; - if (addr >= 0xf0 && addr <= 0xff) { + if (addr >= 0xf0 && addr <= 0xff) { /* only vendor specific registers */ struct sdio_cmd52 cmd; cmd.read_write = 0; @@ -478,7 +481,7 @@ static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data) cmd.read_write = 0; cmd.function = 0; - cmd.address = 0x10f; + cmd.address = WILC_SDIO_FBR_DATA_REG; cmd.block_mode = 0; cmd.increment = 1; cmd.count = 4; @@ -511,13 +514,13 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) * func 0 access **/ cmd.function = 0; - cmd.address = 0x10f; + cmd.address = WILC_SDIO_FBR_DATA_REG; } else { /** * func 1 access **/ cmd.function = 1; - cmd.address = 0; + cmd.address = WILC_SDIO_F1_DATA_REG; } size = ALIGN(size, 4); @@ -598,8 +601,8 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume) cmd.read_write = 1; cmd.function = 0; cmd.raw = 1; - cmd.address = 0x100; - cmd.data = 0x80; + cmd.address = SDIO_FBR_BASE(func->num); + cmd.data = SDIO_FBR_ENABLE_CSA; ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { dev_err(&func->dev, "Fail cmd 52, enable csa...\n"); @@ -622,8 +625,8 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume) cmd.read_write = 1; cmd.function = 0; cmd.raw = 1; - cmd.address = 0x2; - cmd.data = 0x2; + cmd.address = SDIO_CCCR_IOEx; + cmd.data = WILC_SDIO_CCCR_IO_EN_FUNC1; ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { dev_err(&func->dev, @@ -637,7 +640,7 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume) cmd.read_write = 0; cmd.function = 0; cmd.raw = 0; - cmd.address = 0x3; + cmd.address = SDIO_CCCR_IORx; loop = 3; do { cmd.data = 0; @@ -647,7 +650,7 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume) "Fail cmd 52, get IOR register...\n"); return ret; } - if (cmd.data == 0x2) + if (cmd.data == WILC_SDIO_CCCR_IO_EN_FUNC1) break; } while (loop--); @@ -671,8 +674,8 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume) cmd.read_write = 1; cmd.function = 0; cmd.raw = 1; - cmd.address = 0x4; - cmd.data = 0x3; + cmd.address = SDIO_CCCR_IENx; + cmd.data = WILC_SDIO_CCCR_IEN_MASTER | WILC_SDIO_CCCR_IEN_FUNC1; ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { dev_err(&func->dev, "Fail cmd 52, set IEN register...\n"); @@ -711,12 +714,12 @@ static int wilc_sdio_read_size(struct wilc *wilc, u32 *size) cmd.read_write = 0; cmd.function = 0; cmd.raw = 0; - cmd.address = 0xf2; + cmd.address = WILC_SDIO_INTERRUPT_DATA_SZ_REG; cmd.data = 0; wilc_sdio_cmd52(wilc, &cmd); tmp = cmd.data; - cmd.address = 0xf3; + cmd.address = WILC_SDIO_INTERRUPT_DATA_SZ_REG + 1; cmd.data = 0; wilc_sdio_cmd52(wilc, &cmd); tmp |= (cmd.data << 8); @@ -740,10 +743,10 @@ static int wilc_sdio_read_int(struct wilc *wilc, u32 *int_status) **/ if (!sdio_priv->irq_gpio) { cmd.function = 1; - cmd.address = 0x04; + cmd.address = WILC_SDIO_EXT_IRQ_FLAG_REG; } else { cmd.function = 0; - cmd.address = 0xf7; + cmd.address = WILC_SDIO_IRQ_FLAG_REG; } cmd.raw = 0; cmd.read_write = 0; @@ -789,14 +792,14 @@ static int wilc_sdio_clear_int_ext(struct wilc *wilc, u32 val) cmd.read_write = 1; cmd.function = 0; cmd.raw = 0; - cmd.address = 0xf8; + cmd.address = WILC_SDIO_IRQ_CLEAR_FLAG_REG; cmd.data = reg; ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { dev_err(&func->dev, - "Failed cmd52, set 0xf8 data (%d) ...\n", - __LINE__); + "Failed cmd52, set (%02x) data (%d) ...\n", + cmd.address, __LINE__); return ret; } } @@ -819,14 +822,14 @@ static int wilc_sdio_clear_int_ext(struct wilc *wilc, u32 val) cmd.read_write = 1; cmd.function = 0; cmd.raw = 0; - cmd.address = 0xf8; + cmd.address = WILC_SDIO_IRQ_CLEAR_FLAG_REG; cmd.data = BIT(i); ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { dev_err(&func->dev, - "Failed cmd52, set 0xf8 data (%d) ...\n", - __LINE__); + "Failed cmd52, set (%02x) data (%d) ...\n", + cmd.address, __LINE__); return ret; } flags &= ~BIT(i); @@ -860,13 +863,13 @@ static int wilc_sdio_clear_int_ext(struct wilc *wilc, u32 val) cmd.read_write = 1; cmd.function = 0; cmd.raw = 0; - cmd.address = 0xf6; + cmd.address = WILC_SDIO_VMM_TBL_CTRL_REG; cmd.data = vmm_ctl; ret = wilc_sdio_cmd52(wilc, &cmd); if (ret) { dev_err(&func->dev, - "Failed cmd52, set 0xf6 data (%d) ...\n", - __LINE__); + "Failed cmd52, set (%02x) data (%d) ...\n", + cmd.address, __LINE__); return ret; } } diff --git a/drivers/staging/wilc1000/wlan.h b/drivers/staging/wilc1000/wlan.h index 27f08b375345..ceec4801f18f 100644 --- a/drivers/staging/wilc1000/wlan.h +++ b/drivers/staging/wilc1000/wlan.h @@ -93,6 +93,42 @@ #define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - \ WILC_SPI_REG_BASE) +/* Functions IO enables bits */ +#define WILC_SDIO_CCCR_IO_EN_FUNC1 BIT(1) + +/* Function/Interrupt enables bits */ +#define WILC_SDIO_CCCR_IEN_MASTER BIT(0) +#define WILC_SDIO_CCCR_IEN_FUNC1 BIT(1) + +/* Abort CCCR register bits */ +#define WILC_SDIO_CCCR_ABORT_RESET BIT(3) + +/* Vendor specific CCCR registers */ +#define WILC_SDIO_WAKEUP_REG 0xf0 +#define WILC_SDIO_WAKEUP_BIT BIT(0) + +#define WILC_SDIO_CLK_STATUS_REG 0xf1 +#define WILC_SDIO_CLK_STATUS_BIT BIT(0) + +#define WILC_SDIO_INTERRUPT_DATA_SZ_REG 0xf2 /* Read size (2 bytes) */ + +#define WILC_SDIO_VMM_TBL_CTRL_REG 0xf6 +#define WILC_SDIO_IRQ_FLAG_REG 0xf7 +#define WILC_SDIO_IRQ_CLEAR_FLAG_REG 0xf8 + +#define WILC_SDIO_HOST_TO_FW_REG 0xfa +#define WILC_SDIO_HOST_TO_FW_BIT BIT(0) + +#define WILC_SDIO_FW_TO_HOST_REG 0xfc +#define WILC_SDIO_FW_TO_HOST_BIT BIT(0) + +/* Function 1 specific FBR register */ +#define WILC_SDIO_FBR_CSA_REG 0x10C /* CSA pointer (3 bytes) */ +#define WILC_SDIO_FBR_DATA_REG 0x10F + +#define WILC_SDIO_F1_DATA_REG 0x0 +#define WILC_SDIO_EXT_IRQ_FLAG_REG 0x4 + #define WILC_AHB_DATA_MEM_BASE 0x30000 #define WILC_AHB_SHARE_MEM_BASE 0xd0000 From patchwork Fri Feb 14 11:52:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 11382155 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECC3913A4 for ; Fri, 14 Feb 2020 11:52:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C28BF22314 for ; Fri, 14 Feb 2020 11:52:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="LBwZesNU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729007AbgBNLw1 (ORCPT ); Fri, 14 Feb 2020 06:52:27 -0500 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:38153 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbgBNLwZ (ORCPT ); Fri, 14 Feb 2020 06:52:25 -0500 Received-SPF: Pass (esa6.microchip.iphmx.com: domain of Ajay.Kathat@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="Ajay.Kathat@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com -exists:%{i}.spf.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa6.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa6.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa6.microchip.iphmx.com; spf=Pass smtp.mailfrom=Ajay.Kathat@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: kFrWksIESHNHWy58kc+J788uewWR83V4KIoHxkGZw77O0gTwbnthhBZJz3uCZrmeUEI9QN9Kai sRR+Rq6etqiShyJdqq/77QpQoS14LWlnPSqLWk/WGzkMvGtJkQb/XcxPjS7mdR28Tr2CVSZgMh e3Op2AMl3kwkNkE+6YXm8dbS3UkrhBZSKKIjTo2yDtQl913eaX0kSy0UcFVoLonhIEzcvZpMN2 9hbAGT/U9X3vudHHKwziMcWaPCOPFA+L2Tqtf5AeK6zUIt6GB3b5HSeeJ7QXG0BPHjjvpGvR8c 7lI= X-IronPort-AV: E=Sophos;i="5.70,440,1574146800"; d="scan'208";a="2407530" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2020 04:52:24 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 14 Feb 2020 04:52:24 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 14 Feb 2020 04:52:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kpKxN1a+xj00F1i5Yh4xFsHtlYloc8nlXZGGM1MX261HfsxBXJbXTUGnx6aIlTPDKHs/eHCsE1ZWw8Z3d7sDNq9n6zsKKyvCIAWzbJUvyv9gaBdpR01KHG6FDn/OfThyASGuNusiKlReqd62eittTatwg5apU0l7w3eMnq38QIORbmOO/tJ2zZbtfuMcG9sTsnL5UedrCv+hw4IsDuRaLYT71DdGbliy567X5FWMAcl8PKKWol1EqZHouNnBgQ0dOd1Ag4c8akaD+hH1T/D1+8fB3LFe1+yTEjz2dm+O3JcLRvdsc9aiQoiQgbEkqugHW1jxBepXm/+SW3YOWA4/NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JWlBmo6jxY/3TKM5si9sreXGoVrjbUsBaxMKlnx0ZF4=; b=kiXVMnoUdvJjfJW5Lor6zX5tLO7+T1vgFLMDxLFqS8YoMnY9vPsiuYcTP2/RBkq4iI3lQghshfVvwQRUN3hDmhC9AfP397f0RzcjE9YYR28t0n08+APAwTIgePzxFnVqKpLvnisaUq33uzS5RKIK+xeI5zt9jaH8P42QrbCL3GSqgF0AIIDawLbyJcDOuQ59DJOzmVwAYyT8RTg8aHiXnwr9IW/rFWJQ+TG9+BzjswUdSrRpUUxoE4XdxExKOgHOerT8Bffzs716extPpBjqPmwdJpUjV+mShIsXEyUOpd7r44hAdTrU1SzPCZdi8epd8FUzW9VWMQccGmYiXaqL4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JWlBmo6jxY/3TKM5si9sreXGoVrjbUsBaxMKlnx0ZF4=; b=LBwZesNUBOA0/dI9ISXfAZD+bsK+y56WRCDrkP9iyDONs6149+9fzFOjg2Vn8Z2V3y93U63p3nb9giYgazUtg1yxNWmG8OXVEB1rPHmTRkzCR7qDIMGFuqbKnw3H3F6gjiZFfburdwMd+l0MABlUuRcdoThiPcDpjfzxRQypCfQ= Received: from BN6PR11MB3985.namprd11.prod.outlook.com (10.255.129.78) by BN6PR11MB1652.namprd11.prod.outlook.com (10.172.24.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.25; Fri, 14 Feb 2020 11:52:22 +0000 Received: from BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4]) by BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4%3]) with mapi id 15.20.2729.027; Fri, 14 Feb 2020 11:52:22 +0000 From: To: CC: , , , , Subject: [PATCH 7/8] staging: wilc1000: use short name for hif local variable in chip_wakeup() Thread-Topic: [PATCH 7/8] staging: wilc1000: use short name for hif local variable in chip_wakeup() Thread-Index: AQHV4y03I2fF2LfS3US2FIJ4hO+iQQ== Date: Fri, 14 Feb 2020 11:52:22 +0000 Message-ID: <20200214172250.13026-8-ajay.kathat@microchip.com> References: <20200214172250.13026-1-ajay.kathat@microchip.com> In-Reply-To: <20200214172250.13026-1-ajay.kathat@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-originating-ip: [121.244.27.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1d2c1f2d-c696-40be-87d1-08d7b1445a52 x-ms-traffictypediagnostic: BN6PR11MB1652: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3968; x-forefront-prvs: 03137AC81E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39850400004)(136003)(189003)(199004)(6506007)(2906002)(26005)(6512007)(2616005)(107886003)(6486002)(5660300002)(186003)(316002)(54906003)(4326008)(81156014)(81166006)(86362001)(64756008)(66476007)(66446008)(66556008)(8936002)(8676002)(76116006)(91956017)(66946007)(478600001)(36756003)(6916009)(71200400001)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR11MB1652;H:BN6PR11MB3985.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jux6EI+BodbxUo338Wdw3xJh5RgdVd36XMHb9l0ipGbbrBRoBwUL4hhDlsWWmvOV4cG8nUpPiWmW3aTft9p54p/mK8DoPmf/emoiYGidGcZrB38jcr7e6Z45F9oqhUv5sY6E3MAD6G4eylvOztklRouQNnFys1wzuLBUg6PMdVvPOns1BwmwxR80sRgunpHOqZqTMj/todPmW5qRhirp5xyIR0H1QrOkJO0JBwptkoScklaSL7YPEMtvWkVs/9eOKgXPN5KFuqh1fF/hL8aYoPM+MAM03C2LfvQZjfal4e7SIgqHRxIlb0oqKRyDVvXv0wXiDQ2dughdpqlIPyZ6qfWspiBfhlLiLBK1AgKsx4UnYmL8vDihfrg0nU4BcL4dMcUQVomldOf6z9dR9sKkAtCOM6DCfmWZOdxTegEaYtUVd/W8QP4FVtLhNhBhfH0N x-ms-exchange-antispam-messagedata: slNiZihQq8sO0kl6m++Jo5OSL46hVv2+mYnR24f45e08DApYMVWGhAr/grCMj5DWjaAwTS5js5P8Q5CO6PFM2Zcm6tTKX3JiH9Pqj737g67L56PbJDkbfz3Gh9JSo7phJVmjTXhfPp7hWVhUkCgYgQ== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 1d2c1f2d-c696-40be-87d1-08d7b1445a52 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2020 11:52:22.5486 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: JMy3YtgD+jJeIHOwwYsFOpeStfJ7bjByLIjxKS0ebRlaRviBrn/c7ovTutNCiKXbpKdMa+2+CHjZOb7XjRz0A1Xpp6ECu91a5ZHz54Tqs44= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1652 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Make use of a shorter name for 'hif' variable to avoid possible 80 character checkpatch warning while the replacing hardcoded value with macros in chip_wakeup(). Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/wlan.c | 35 +++++++++++++++------------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c index db4ef175ccee..31f424efe01d 100644 --- a/drivers/staging/wilc1000/wlan.c +++ b/drivers/staging/wilc1000/wlan.c @@ -403,37 +403,34 @@ EXPORT_SYMBOL_GPL(chip_allow_sleep); void chip_wakeup(struct wilc *wilc) { u32 reg, clk_status_reg; + const struct wilc_hif_func *h = wilc->hif_func; - if ((wilc->io_type & 0x1) == WILC_HIF_SPI) { + if (wilc->io_type == WILC_HIF_SPI) { do { - wilc->hif_func->hif_read_reg(wilc, 1, ®); - wilc->hif_func->hif_write_reg(wilc, 1, reg | BIT(1)); - wilc->hif_func->hif_write_reg(wilc, 1, reg & ~BIT(1)); + h->hif_read_reg(wilc, 1, ®); + h->hif_write_reg(wilc, 1, reg | BIT(1)); + h->hif_write_reg(wilc, 1, reg & ~BIT(1)); do { usleep_range(2000, 2500); wilc_get_chipid(wilc, true); } while (wilc_get_chipid(wilc, true) == 0); } while (wilc_get_chipid(wilc, true) == 0); - } else if ((wilc->io_type & 0x1) == WILC_HIF_SDIO) { - wilc->hif_func->hif_write_reg(wilc, 0xfa, 1); + } else if (wilc->io_type == WILC_HIF_SDIO) { + h->hif_write_reg(wilc, 0xfa, 1); usleep_range(200, 400); - wilc->hif_func->hif_read_reg(wilc, 0xf0, ®); + h->hif_read_reg(wilc, 0xf0, ®); do { - wilc->hif_func->hif_write_reg(wilc, 0xf0, - reg | BIT(0)); - wilc->hif_func->hif_read_reg(wilc, 0xf1, - &clk_status_reg); + h->hif_write_reg(wilc, 0xf0, reg | BIT(0)); + h->hif_read_reg(wilc, 0xf1, &clk_status_reg); while ((clk_status_reg & 0x1) == 0) { usleep_range(2000, 2500); - wilc->hif_func->hif_read_reg(wilc, 0xf1, - &clk_status_reg); + h->hif_read_reg(wilc, 0xf1, &clk_status_reg); } if ((clk_status_reg & 0x1) == 0) { - wilc->hif_func->hif_write_reg(wilc, 0xf0, - reg & (~BIT(0))); + h->hif_write_reg(wilc, 0xf0, reg & (~BIT(0))); } } while ((clk_status_reg & 0x1) == 0); } @@ -442,13 +439,13 @@ void chip_wakeup(struct wilc *wilc) if (wilc_get_chipid(wilc, false) < 0x1002b0) { u32 val32; - wilc->hif_func->hif_read_reg(wilc, 0x1e1c, &val32); + h->hif_read_reg(wilc, 0x1e1c, &val32); val32 |= BIT(6); - wilc->hif_func->hif_write_reg(wilc, 0x1e1c, val32); + h->hif_write_reg(wilc, 0x1e1c, val32); - wilc->hif_func->hif_read_reg(wilc, 0x1e9c, &val32); + h->hif_read_reg(wilc, 0x1e9c, &val32); val32 |= BIT(6); - wilc->hif_func->hif_write_reg(wilc, 0x1e9c, val32); + h->hif_write_reg(wilc, 0x1e9c, val32); } } wilc->chip_ps_state = WILC_CHIP_WAKEDUP; From patchwork Fri Feb 14 11:52:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 11382159 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F06413A4 for ; Fri, 14 Feb 2020 11:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D2C9222C2 for ; Fri, 14 Feb 2020 11:52:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="dYPMNMpI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729048AbgBNLw3 (ORCPT ); Fri, 14 Feb 2020 06:52:29 -0500 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:12309 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728689AbgBNLw2 (ORCPT ); Fri, 14 Feb 2020 06:52:28 -0500 Received-SPF: Pass (esa3.microchip.iphmx.com: domain of Ajay.Kathat@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="Ajay.Kathat@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com -exists:%{i}.spf.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa3.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Ajay.Kathat@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa3.microchip.iphmx.com; spf=Pass smtp.mailfrom=Ajay.Kathat@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: vsaN7KGY1facWw1FoX7fomqTyhz7YJwfWgAe0zlt980TQRErwbO78MMEJ5NUVRbJ2UWz0aXUdU 0aAQzPrPD3WTKk2XKOtnbCts+fYWO6Kir3hLgXepoJZhdXOPsXE5HwQPTobXppffq9zb2CSr6B nWNxuXAVGZFmtFlcDe9zDPvmG2w/O2wLZXZ07FIwllg6IOBdDS7+hTBPS3klXBH84AjI1Lh2mv 7+c4prgYSKPYLzikzO5g3NaNFadr+SyHmwZiGKsU9muUWiAWJJ5fFa4X64wvv76AW+9sUFfepP bdQ= X-IronPort-AV: E=Sophos;i="5.70,440,1574146800"; d="scan'208";a="66696577" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2020 04:52:26 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 14 Feb 2020 04:52:26 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 14 Feb 2020 04:52:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MArrHNcqXYYxlg4uzrDI8FpBKEJZ3TGDujokQSINkbg02WEo5osHchx8yurCu+pRQYTeS1XJvP80tuB5GZLoxcylNELYgO5rkbuzglKP+KzU+jlMR65wIbmsqs28ZJmGszfQ6ma2HKPcDe5txZyljqRMpWmZ/vWYqMGJjotI/2aNndlhcYsdTlz0nKiq5Pz2xpRwsFgbMZBHVwJ1cBWHbuwtYqtbAzaOcXmUu0iQwUImstkYLhojsNHl/vuED+v0KY1/He3/GW0uO62nQ17p72hGguyAGvr6/NtW8O90qSbCEV7rURFmZVuNbVsoaXVWsQLbO3o4AKxBRgSeeWlQDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6mvY4+lBkx/9nXSxxyOI1oL+fY87mSQbDZTIc62+9rw=; b=cdlE2WPUULmwszCa3eA/2pLuNZJnqZe6ck7kQhWb+8ZIXPhiL1+pxVJBICj+BgQqLBb5kV0sH1oN6sPOx+sHjw6e8TrywQ+10U81sJa+gUsAjlpK6/ygUmpE/FakltU/y2CBm2kGZcVPCntEBwJjpIwlkM+V3kut7BeQgOlCzMyWC+YbgX+mjWkDX8/aq82Iv0Fb1QtcLNqUqkEOfKyF4sSbHs+CvhLbxhXFJZso5LECXXAvzU8wOg+Ol4oCRlJ4Hi7OcXRkpxMNZ93yx6pAQQ+28UxR+FvK86cXDR/ebVop3e4XLBgrg/g3avgp+TVhoAS4IPwWKgMPAUH8ri/hBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6mvY4+lBkx/9nXSxxyOI1oL+fY87mSQbDZTIc62+9rw=; b=dYPMNMpIRdZWGfZ0pWsC/HNtfbYOy05fp37h0oGs4bGNyCIsuI1xt1tDM5Ii+tA35Ns+xiZGwMoKkTrwA8T0p2am4Tf/QmYKDzMChJd+IMwbDyDp0Ui1k9M+hItSSp+AM2XSfqjSqNUopZydDhK9/OFEd1yMLRTI++Cp1u1istc= Received: from BN6PR11MB3985.namprd11.prod.outlook.com (10.255.129.78) by BN6PR11MB1652.namprd11.prod.outlook.com (10.172.24.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.25; Fri, 14 Feb 2020 11:52:24 +0000 Received: from BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4]) by BN6PR11MB3985.namprd11.prod.outlook.com ([fe80::ec62:e7fd:f17c:dfd4%3]) with mapi id 15.20.2729.027; Fri, 14 Feb 2020 11:52:24 +0000 From: To: CC: , , , , Subject: [PATCH 8/8] staging: wilc1000: define macros to replace magic number values Thread-Topic: [PATCH 8/8] staging: wilc1000: define macros to replace magic number values Thread-Index: AQHV4y04Pa/fqdvkgUei+QBjm2Y+9g== Date: Fri, 14 Feb 2020 11:52:23 +0000 Message-ID: <20200214172250.13026-9-ajay.kathat@microchip.com> References: <20200214172250.13026-1-ajay.kathat@microchip.com> In-Reply-To: <20200214172250.13026-1-ajay.kathat@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-originating-ip: [121.244.27.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9307f65c-5d65-46a8-e9ee-08d7b1445b1a x-ms-traffictypediagnostic: BN6PR11MB1652: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:159; x-forefront-prvs: 03137AC81E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(366004)(39850400004)(136003)(189003)(199004)(6506007)(2906002)(26005)(6512007)(2616005)(107886003)(6486002)(5660300002)(186003)(316002)(54906003)(4326008)(81156014)(81166006)(86362001)(64756008)(66476007)(66446008)(66556008)(8936002)(8676002)(30864003)(76116006)(91956017)(66946007)(478600001)(36756003)(6916009)(71200400001)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR11MB1652;H:BN6PR11MB3985.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 04ddSOsTH5CIFyTWtj4rcwb7G7B4V4Vv7cQGsyPk6S6Sv/oStNXi9UXQ6CuJunO+OCI+jW/spN+Kgdgtma9noUKlR899Qh1GW8yQeGEczmSoU4lr25+eE/3kkoFVzjPtXlnCESDS4TvMZ8uuxnLC615fy70u9iii9n9LrOMvex2eZd9jRV7jPuDYZ4jSwibxuEg7jfX/zT/26GltEDZtJi7tm2TTvC/etaXFMVz5YtNBHFU2yazpByTvTUCYcXAZPbF9lGQgH7jsAa597tN9jw2S9b+lT+v5PNd89KQFjontBFTFnwq5Lz3v++PII1ql2JS1FNT6HUpcCkYXvIWqoQFctLDAxQ9mGls/ONF1d6WSXfDr7vgUidZKjR4F8Q+KnlZCtQ527s8AsTlOz8wBo49qd6Mq12VGKn+cvH50D6EwtN97rqawvDwGp6sIMu7Q x-ms-exchange-antispam-messagedata: nNM8luQRht4akNKLmGa5Qrs8LqpbSsQEe4IF+2U0KF5XkZHVSbD8QQ7VlWiyjwyuF6q9u3kQBdqBCZmgm1HDh1z2vRjvk5/bvY+yuZFrfD577jibmusXRFQ+eGxDbHmbTp1TJLI1t1T7HzG4qq+teg== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 9307f65c-5d65-46a8-e9ee-08d7b1445b1a X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2020 11:52:23.8448 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8BrYKU6bvmEBmdAhynopJ1EH7jYjRQOTpcpcelEHZvEvc+xCRvA5T/19uMo+KOephaDzFTWCYbWTI2R04AiUjrkPfvinhypejbsh9TnUDdk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1652 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Define macros for global as well as SPI/SDIO specific register to avoid use of magic numbers. Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/sdio.c | 7 ++- drivers/staging/wilc1000/spi.c | 17 ++++--- drivers/staging/wilc1000/wlan.c | 83 +++++++++++++++++++-------------- drivers/staging/wilc1000/wlan.h | 35 ++++++++++++++ 4 files changed, 99 insertions(+), 43 deletions(-) diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c index 0670c5956aef..2301e90c21ca 100644 --- a/drivers/staging/wilc1000/sdio.c +++ b/drivers/staging/wilc1000/sdio.c @@ -686,13 +686,16 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume) * make sure can read back chip id correctly **/ if (!resume) { - ret = wilc_sdio_read_reg(wilc, 0x1000, &chipid); + int rev; + + ret = wilc_sdio_read_reg(wilc, WILC_CHIPID, &chipid); if (ret) { dev_err(&func->dev, "Fail cmd read chip id...\n"); return ret; } dev_err(&func->dev, "chipid (%08x)\n", chipid); - if ((chipid & 0xfff) > 0x2a0) + rev = FIELD_GET(WILC_CHIP_REV_FIELD, chipid); + if (rev > FIELD_GET(WILC_CHIP_REV_FIELD, WILC_1000_BASE_ID_2A)) sdio_priv->has_thrpt_enh3 = 1; else sdio_priv->has_thrpt_enh3 = 0; diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c index 37be627e72ce..44f7d48851b5 100644 --- a/drivers/staging/wilc1000/spi.c +++ b/drivers/staging/wilc1000/spi.c @@ -683,7 +683,7 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data) u8 cmd = CMD_SINGLE_READ; u8 clockless = 0; - if (addr < 0x30) { + if (addr < WILC_SPI_CLOCKLESS_ADDR_LIMIT) { /* Clockless register */ cmd = CMD_INTERNAL_READ; clockless = 1; @@ -760,7 +760,7 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data) u8 cmd = CMD_SINGLE_WRITE; u8 clockless = 0; - if (addr < 0x30) { + if (addr < WILC_SPI_CLOCKLESS_ADDR_LIMIT) { /* Clockless register */ cmd = CMD_INTERNAL_WRITE; clockless = 1; @@ -829,7 +829,7 @@ static int wilc_spi_init(struct wilc *wilc, bool resume) int ret; if (isinit) { - ret = wilc_spi_read_reg(wilc, 0x1000, &chipid); + ret = wilc_spi_read_reg(wilc, WILC_CHIPID, &chipid); if (ret) dev_err(&spi->dev, "Fail cmd read chip id...\n"); @@ -881,7 +881,7 @@ static int wilc_spi_init(struct wilc *wilc, bool resume) /* * make sure can read back chip id correctly */ - ret = wilc_spi_read_reg(wilc, 0x1000, &chipid); + ret = wilc_spi_read_reg(wilc, WILC_CHIPID, &chipid); if (ret) { dev_err(&spi->dev, "Fail cmd read chip id...\n"); return ret; @@ -896,7 +896,8 @@ static int wilc_spi_read_size(struct wilc *wilc, u32 *size) { int ret; - ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, size); + ret = spi_internal_read(wilc, + WILC_SPI_INT_STATUS - WILC_SPI_REG_BASE, size); *size = FIELD_GET(IRQ_DMA_WD_CNT_MASK, *size); return ret; @@ -904,12 +905,14 @@ static int wilc_spi_read_size(struct wilc *wilc, u32 *size) static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) { - return spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, int_status); + return spi_internal_read(wilc, WILC_SPI_INT_STATUS - WILC_SPI_REG_BASE, + int_status); } static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val) { - return spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE, val); + return spi_internal_write(wilc, WILC_SPI_INT_CLEAR - WILC_SPI_REG_BASE, + val); } static int wilc_spi_sync_ext(struct wilc *wilc, int nint) diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c index 31f424efe01d..f633c6b9f0a9 100644 --- a/drivers/staging/wilc1000/wlan.c +++ b/drivers/staging/wilc1000/wlan.c @@ -11,7 +11,7 @@ static inline bool is_wilc1000(u32 id) { - return (id & 0xfffff000) == 0x100000; + return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID; } static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire) @@ -393,10 +393,11 @@ void chip_allow_sleep(struct wilc *wilc) { u32 reg = 0; - wilc->hif_func->hif_read_reg(wilc, 0xf0, ®); + wilc->hif_func->hif_read_reg(wilc, WILC_SDIO_WAKEUP_REG, ®); - wilc->hif_func->hif_write_reg(wilc, 0xf0, reg & ~BIT(0)); - wilc->hif_func->hif_write_reg(wilc, 0xfa, 0); + wilc->hif_func->hif_write_reg(wilc, WILC_SDIO_WAKEUP_REG, + reg & ~WILC_SDIO_WAKEUP_BIT); + wilc->hif_func->hif_write_reg(wilc, WILC_SDIO_HOST_TO_FW_REG, 0); } EXPORT_SYMBOL_GPL(chip_allow_sleep); @@ -407,9 +408,11 @@ void chip_wakeup(struct wilc *wilc) if (wilc->io_type == WILC_HIF_SPI) { do { - h->hif_read_reg(wilc, 1, ®); - h->hif_write_reg(wilc, 1, reg | BIT(1)); - h->hif_write_reg(wilc, 1, reg & ~BIT(1)); + h->hif_read_reg(wilc, WILC_SPI_WAKEUP_REG, ®); + h->hif_write_reg(wilc, WILC_SPI_WAKEUP_REG, + reg | WILC_SPI_WAKEUP_BIT); + h->hif_write_reg(wilc, WILC_SPI_WAKEUP_REG, + reg & ~WILC_SPI_WAKEUP_BIT); do { usleep_range(2000, 2500); @@ -417,35 +420,40 @@ void chip_wakeup(struct wilc *wilc) } while (wilc_get_chipid(wilc, true) == 0); } while (wilc_get_chipid(wilc, true) == 0); } else if (wilc->io_type == WILC_HIF_SDIO) { - h->hif_write_reg(wilc, 0xfa, 1); + h->hif_write_reg(wilc, WILC_SDIO_HOST_TO_FW_REG, + WILC_SDIO_HOST_TO_FW_BIT); usleep_range(200, 400); - h->hif_read_reg(wilc, 0xf0, ®); + h->hif_read_reg(wilc, WILC_SDIO_WAKEUP_REG, ®); do { - h->hif_write_reg(wilc, 0xf0, reg | BIT(0)); - h->hif_read_reg(wilc, 0xf1, &clk_status_reg); + h->hif_write_reg(wilc, WILC_SDIO_WAKEUP_REG, + reg | WILC_SDIO_WAKEUP_BIT); + h->hif_read_reg(wilc, WILC_SDIO_CLK_STATUS_REG, + &clk_status_reg); - while ((clk_status_reg & 0x1) == 0) { + while (!(clk_status_reg & WILC_SDIO_CLK_STATUS_BIT)) { usleep_range(2000, 2500); - h->hif_read_reg(wilc, 0xf1, &clk_status_reg); + h->hif_read_reg(wilc, WILC_SDIO_CLK_STATUS_REG, + &clk_status_reg); } - if ((clk_status_reg & 0x1) == 0) { - h->hif_write_reg(wilc, 0xf0, reg & (~BIT(0))); + if (!(clk_status_reg & WILC_SDIO_CLK_STATUS_BIT)) { + h->hif_write_reg(wilc, WILC_SDIO_WAKEUP_REG, + reg & ~WILC_SDIO_WAKEUP_BIT); } - } while ((clk_status_reg & 0x1) == 0); + } while (!(clk_status_reg & WILC_SDIO_CLK_STATUS_BIT)); } if (wilc->chip_ps_state == WILC_CHIP_SLEEPING_MANUAL) { - if (wilc_get_chipid(wilc, false) < 0x1002b0) { + if (wilc_get_chipid(wilc, false) < WILC_1000_BASE_ID_2B) { u32 val32; - h->hif_read_reg(wilc, 0x1e1c, &val32); + h->hif_read_reg(wilc, WILC_REG_4_TO_1_RX, &val32); val32 |= BIT(6); - h->hif_write_reg(wilc, 0x1e1c, val32); + h->hif_write_reg(wilc, WILC_REG_4_TO_1_RX, val32); - h->hif_read_reg(wilc, 0x1e9c, &val32); + h->hif_read_reg(wilc, WILC_REG_4_TO_1_TX_BANK0, &val32); val32 |= BIT(6); - h->hif_write_reg(wilc, 0x1e9c, val32); + h->hif_write_reg(wilc, WILC_REG_4_TO_1_TX_BANK0, val32); } } wilc->chip_ps_state = WILC_CHIP_WAKEDUP; @@ -455,7 +463,7 @@ EXPORT_SYMBOL_GPL(chip_wakeup); void host_wakeup_notify(struct wilc *wilc) { acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - wilc->hif_func->hif_write_reg(wilc, 0x10b0, 1); + wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_2, 1); release_bus(wilc, WILC_BUS_RELEASE_ONLY); } EXPORT_SYMBOL_GPL(host_wakeup_notify); @@ -463,7 +471,7 @@ EXPORT_SYMBOL_GPL(host_wakeup_notify); void host_sleep_notify(struct wilc *wilc) { acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - wilc->hif_func->hif_write_reg(wilc, 0x10ac, 1); + wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_1, 1); release_bus(wilc, WILC_BUS_RELEASE_ONLY); } EXPORT_SYMBOL_GPL(host_sleep_notify); @@ -884,7 +892,7 @@ int wilc_wlan_start(struct wilc *wilc) wilc->hif_func->hif_sync_ext(wilc, NUM_INT_EXT); - ret = wilc->hif_func->hif_read_reg(wilc, 0x1000, &chipid); + ret = wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &chipid); if (ret) { release_bus(wilc, WILC_BUS_RELEASE_ONLY); return ret; @@ -1125,18 +1133,24 @@ static int init_chip(struct net_device *dev) chipid = wilc_get_chipid(wilc, true); if ((chipid & 0xfff) != 0xa0) { - ret = wilc->hif_func->hif_read_reg(wilc, 0x1118, ®); + ret = wilc->hif_func->hif_read_reg(wilc, + WILC_CORTUS_RESET_MUX_SEL, + ®); if (ret) { netdev_err(dev, "fail read reg 0x1118\n"); goto release; } reg |= BIT(0); - ret = wilc->hif_func->hif_write_reg(wilc, 0x1118, reg); + ret = wilc->hif_func->hif_write_reg(wilc, + WILC_CORTUS_RESET_MUX_SEL, + reg); if (ret) { netdev_err(dev, "fail write reg 0x1118\n"); goto release; } - ret = wilc->hif_func->hif_write_reg(wilc, 0xc0000, 0x71); + ret = wilc->hif_func->hif_write_reg(wilc, + WILC_CORTUS_BOOT_REGISTER, + WILC_CORTUS_BOOT_FROM_IRAM); if (ret) { netdev_err(dev, "fail write reg 0xc0000\n"); goto release; @@ -1156,20 +1170,21 @@ u32 wilc_get_chipid(struct wilc *wilc, bool update) u32 rfrevid = 0; if (chipid == 0 || update) { - wilc->hif_func->hif_read_reg(wilc, 0x1000, &tempchipid); - wilc->hif_func->hif_read_reg(wilc, 0x13f4, &rfrevid); + wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &tempchipid); + wilc->hif_func->hif_read_reg(wilc, WILC_RF_REVISION_ID, + &rfrevid); if (!is_wilc1000(tempchipid)) { chipid = 0; return chipid; } - if (tempchipid == 0x1002a0) { + if (tempchipid == WILC_1000_BASE_ID_2A) { /* 0x1002A0 */ if (rfrevid != 0x1) - tempchipid = 0x1002a1; - } else if (tempchipid == 0x1002b0) { + tempchipid = WILC_1000_BASE_ID_2A_REV1; + } else if (tempchipid == WILC_1000_BASE_ID_2B) { /* 0x1002B0 */ if (rfrevid == 0x4) - tempchipid = 0x1002b1; + tempchipid = WILC_1000_BASE_ID_2B_REV1; else if (rfrevid != 0x3) - tempchipid = 0x1002b2; + tempchipid = WILC_1000_BASE_ID_2B_REV2; } chipid = tempchipid; diff --git a/drivers/staging/wilc1000/wlan.h b/drivers/staging/wilc1000/wlan.h index ceec4801f18f..5999c5490ea5 100644 --- a/drivers/staging/wilc1000/wlan.h +++ b/drivers/staging/wilc1000/wlan.h @@ -66,6 +66,8 @@ #define WILC_INTR_CLEAR (WILC_INTR_REG_BASE + 0x30) #define WILC_INTR_STATUS (WILC_INTR_REG_BASE + 0x40) +#define WILC_RF_REVISION_ID 0x13f4 + #define WILC_VMM_TBL_SIZE 64 #define WILC_VMM_TX_TBL_BASE 0x150400 #define WILC_VMM_RX_TBL_BASE 0x150500 @@ -89,10 +91,17 @@ #define WILC_SPI_TX_MODE (WILC_SPI_REG_BASE + 0x20) #define WILC_SPI_PROTOCOL_CONFIG (WILC_SPI_REG_BASE + 0x24) #define WILC_SPI_INTR_CTL (WILC_SPI_REG_BASE + 0x2c) +#define WILC_SPI_INT_STATUS (WILC_SPI_REG_BASE + 0x40) +#define WILC_SPI_INT_CLEAR (WILC_SPI_REG_BASE + 0x44) + +#define WILC_SPI_WAKEUP_REG 0x1 +#define WILC_SPI_WAKEUP_BIT BIT(1) #define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - \ WILC_SPI_REG_BASE) +#define WILC_SPI_CLOCKLESS_ADDR_LIMIT 0x30 + /* Functions IO enables bits */ #define WILC_SDIO_CCCR_IO_EN_FUNC1 BIT(1) @@ -149,6 +158,32 @@ #define WILC_HAVE_DISABLE_WILC_UART BIT(7) #define WILC_HAVE_USE_IRQ_AS_HOST_WAKE BIT(8) +#define WILC_CORTUS_INTERRUPT_BASE 0x10A8 +#define WILC_CORTUS_INTERRUPT_1 (WILC_CORTUS_INTERRUPT_BASE + 0x4) +#define WILC_CORTUS_INTERRUPT_2 (WILC_CORTUS_INTERRUPT_BASE + 0x8) + +/* tx control register 1 to 4 for RX */ +#define WILC_REG_4_TO_1_RX 0x1e1c + +/* tx control register 1 to 4 for TX Bank_0 */ +#define WILC_REG_4_TO_1_TX_BANK0 0x1e9c + +#define WILC_CORTUS_RESET_MUX_SEL 0x1118 +#define WILC_CORTUS_BOOT_REGISTER 0xc0000 + +#define WILC_CORTUS_BOOT_FROM_IRAM 0x71 + +#define WILC_1000_BASE_ID 0x100000 + +#define WILC_1000_BASE_ID_2A 0x1002A0 +#define WILC_1000_BASE_ID_2A_REV1 (WILC_1000_BASE_ID_2A + 1) + +#define WILC_1000_BASE_ID_2B 0x1002B0 +#define WILC_1000_BASE_ID_2B_REV1 (WILC_1000_BASE_ID_2B + 1) +#define WILC_1000_BASE_ID_2B_REV2 (WILC_1000_BASE_ID_2B + 2) + +#define WILC_CHIP_REV_FIELD GENMASK(11, 0) + /******************************************** * * Wlan Defines