From patchwork Fri Apr 22 09:03:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrejs Cainikovs X-Patchwork-Id: 565215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4399C433FE for ; Fri, 22 Apr 2022 09:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1445836AbiDVJGj (ORCPT ); Fri, 22 Apr 2022 05:06:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359739AbiDVJGi (ORCPT ); Fri, 22 Apr 2022 05:06:38 -0400 Received: from CHE01-GV0-obe.outbound.protection.outlook.com (mail-gv0che01on2128.outbound.protection.outlook.com [40.107.23.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E27D853712; Fri, 22 Apr 2022 02:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R7tVaNWmi/LSMDSHYdRr6oQRRJGfaojbWmVUXsHHIPCnojleMsRnU7ZUnkvy1pnmDiwCAirZxj82qL8g7ffw77b6EpjS2nyMxRFn/gOp/BkcRq+xOR9/DA/d1drKgZn8CeXVw37TfaBUYW7AIU5u8nvwuXb8v+xIFL0B7RJlwStcWBFkjFFsczyGDxszHyAagZmqEvNP/6Mo/WG23DU9w3+A6nqceoJIHwfFInlPSd4Ut35G6NGnIfFSd7Nk88Rf0Y+ypbJSruq4wJ/u+CzOGmi83k7XqYOBmc6IokHuNX6YR+4LNdgt+AmFVCXQH79odyUlso65AQu1uiRIfTXixw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GoZjLK97WI4aQlNkrx10mSm0M1CPn3sGa6ohjZnI1yk=; b=KuiLfrTddDRX15TCcXScsRMv8mwtuJduS5Bnx8cR3e2n0/9Pk3/egXe2h5qZLLH6ZatHJRLWhKfu8ZJ8PVZIEnC7fwzL0Q1aYCKRQPjsJpHIMclGvG2t4k/0gPJJqrw7kzB0v3dAuscgc6bvyUhkGEsstOkNiusFNWIDvh/9ZS0iK42c6hwOuQG+UhKBlfJCWpYVsViCWFlij+AL8vw+zRFm0IbhwMBZyb1ann8mkR/nse4uUColDyxDHj/YwitPnyXN8Ca/JkQRvQ5OmKs3ffm1rK63P8n3ONGlQ84suGozvPBvw3cW9hur//ytx0HrPm/10ZkNYtgXuIXtG3wrNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=toradex.com; dmarc=pass action=none header.from=toradex.com; dkim=pass header.d=toradex.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toradex.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GoZjLK97WI4aQlNkrx10mSm0M1CPn3sGa6ohjZnI1yk=; b=TfE2ZgRYqeAFihQbUbs8/efB7mjgXITxz9Ugr33yenez4vKPVXRXYJk2Dr5yncdom2AfCknOn6MhURK5FKcwOxjihIImMI6/zmuk/NobA+XZyEkoncBRfFcyZI6Kws+1tchd4mcmOgpeORXsAXhRuLHfVCSOq39b/9IzxhvVI2A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=toradex.com; Received: from GVAP278MB0929.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:57::6) by ZR0P278MB0393.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:34::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Fri, 22 Apr 2022 09:03:41 +0000 Received: from GVAP278MB0929.CHEP278.PROD.OUTLOOK.COM ([fe80::d03a:14ba:bd9a:e165]) by GVAP278MB0929.CHEP278.PROD.OUTLOOK.COM ([fe80::d03a:14ba:bd9a:e165%7]) with mapi id 15.20.5186.015; Fri, 22 Apr 2022 09:03:41 +0000 From: Andrejs Cainikovs To: linux-wireless@vger.kernel.org, Amitkumar Karwar , Ganapathi Bhat , Sharvari Harisangam , Xinming Hu Cc: Andrejs Cainikovs , Kalle Valo , "David S . Miller" , Jakub Kicinski , Brian Norris , =?utf-8?q?Jonas_Dre=C3=9Fler?= , =?utf-8?q?Alvin_=C5=A0ipra?= =?utf-8?q?ga?= , Francesco Dolcini , netdev@vger.kernel.org Subject: [PATCH v2 1/2] mwifiex: Select firmware based on strapping Date: Fri, 22 Apr 2022 11:03:12 +0200 Message-Id: <20220422090313.125857-2-andrejs.cainikovs@toradex.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220422090313.125857-1-andrejs.cainikovs@toradex.com> References: <20220422090313.125857-1-andrejs.cainikovs@toradex.com> X-ClientProxiedBy: ZR0P278CA0151.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::12) To GVAP278MB0929.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:57::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd730d8f-22cd-46ad-6b47-08da243eff3c X-MS-TrafficTypeDiagnostic: ZR0P278MB0393:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: giSG7MwrSEDJJKI9w5gd7x0LHXmJx3Ir3+xW8m2IoBR1S0wyO16x+SEuiW0SRfTOWrvDFz9KL+Gv8YAKOtH4DW37p/ZQQKUdYgvXk40sNemW/GlfAX1AixH5nGO2latG3+Mz7To8xNuHLPSY1FiTx7yqYowIsa6zr9RvT1eYJQZWlW3iIftsORBCKEnzoAYLJn+eWK+OpHYkQsEHmLn6dCobZGoEnIIyQqEhPUg4SVyXIM6BweZsTmkC0oAMBu1WaAmzNUVVtJrzFWUdEQayB7cH2E+FE71UlqUjhYDU6ZnZW0fSjM8zTBvlPo716bQYXPTWep8vlxjzDedGhdpuw3V01scY/RefaRhdZ28oc0L4ncIYkEN7j6aV+5EgUU2VgVKc+dFjlu9ZO/vW/KRrWMkEU31toojcfcCpQX83AaDrPShgRfYWGiar1mzQLu5D4u85P5fmfz9Pc/YRCCU+W2OwBHFP/MnfJ8dzY/MgQ3V5vpEikf9PNJzFl4pl8qKpz4Ifj3ha0VOepjp6qLNMtgsBLw5scWo7TDwKeMLFDC911SEeoEiASldfeh8wUdkBn1G4i8to8RwoLGzlmdLU25Av0qmFZ4E9z0RquVBlliHh1W200coS4/2HoL6ScrNiZmIpJPCHwVSUa+8tcB7KU5a23RsHLBV1DWCJitsZffP3jl8RIhvpl+xZ9+D28apF/Y3aMnGXeftMCVq66RH5OmNSRnclLbtajlEfzMh1uwtl5adBCeJ5reUZigp2yp7mPuoX9iLC7a/la4jI2OsmCp65lT1sO7NautWUH9Db28Q= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GVAP278MB0929.CHEP278.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(396003)(39850400004)(136003)(346002)(376002)(6506007)(2616005)(6512007)(86362001)(316002)(6666004)(44832011)(2906002)(5660300002)(7416002)(54906003)(26005)(1076003)(8936002)(110136005)(38100700002)(186003)(52116002)(508600001)(38350700002)(966005)(6486002)(36756003)(8676002)(4326008)(66574015)(66476007)(66556008)(66946007)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?r0yFhhGRElm2j6Z7obwgyF7D/0ZW?= =?utf-8?q?fNsD8dxf4aVhUIaVfR5qDkwOLsu/g20pLi/+SjDe98s3pfVLQjwxldTjG4JS+6g7K?= =?utf-8?q?o+Rw4/CL5L/Yax2uLLl0QAC44rH8PktyreeuAcUtrL37Tf5L7UBRO/k2Il6IzZJu+?= =?utf-8?q?RSCcwCHhDqJY2MbQYMPEWVHNbzU7riP61mKWRIzgt6d84A8hwYiwy0JNzC6yxyMt0?= =?utf-8?q?YvDKXdirDA/t5VXUU/3/6tBq2Zgv77mqW6YFMwkVFjAbdLblSy1hVuflEp8R9bpdH?= =?utf-8?q?p/0j5hrfNQtCNSfy2/neZew8t+uypJ6CztK1hLjSC71o4ogWq/Ai43U3SCVW5KoHH?= =?utf-8?q?iORQIObB17V7HXu/0lvCFUczy1jzFDksOoRT52xS0G1Y27XYoToHngREaaI6HS+Ls?= =?utf-8?q?QW3mbZPyH0vsDZQRnkLLNbI4znIkuOcrZftRrHa9TnPNq//M6F2wF3FVjJE/GRaFL?= =?utf-8?q?nl+nApwdA+cnSfVG82GbB1xbD9Q7s6DEoqdN5vsTrBvEXNeHp4LUGA2ape8UCEJtb?= =?utf-8?q?7Rv96i5xA/l6SHD/ox5KhqELDjDto6p/qYRCvSunla4bQdmcWEJsUsee9DCt+HohP?= =?utf-8?q?DFpJdtEkCSpMZ984q7uA8ct/K0Q62f6Lh5fpN62UuNIUAFQ7ngrEelVmo21qdKmJ+?= =?utf-8?q?L9pLHYZL57MhMbtcKDrs25bqesspepDIW9vzI+sJJUHYotc4OH2SPS+aldkR3/F/w?= =?utf-8?q?SGYUxviEpz94LeTqHPwM7H4c1vp2jOj+QKonMycIoUqZQU1BrKPFGXl16nO2zJnFh?= =?utf-8?q?mWNSj/0tI7fAIl6RTTHWnMkv7/CBeEFKdFYscCrjAa1pG6+suwNHipmNzvomHWmAb?= =?utf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atorOrg: toradex.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd730d8f-22cd-46ad-6b47-08da243eff3c X-MS-Exchange-CrossTenant-AuthSource: GVAP278MB0929.CHEP278.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2022 09:03:41.5849 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d9995866-0d9b-4251-8315-093f062abab4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vBhLL0MvdRlR03H8CtFFQJP3burn+xRsI6x2T1ckNyt9r9k5eJnVMD79PNBx0qoXiPZcO9pbwtxAAY8J19LknSxkXLWlS/CWnd77S0u6O6s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZR0P278MB0393 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Some WiFi/Bluetooth modules might have different host connection options, allowing to either use SDIO for both WiFi and Bluetooth, or SDIO for WiFi and UART for Bluetooth. It is possible to detect whether a module has SDIO-SDIO or SDIO-UART connection by reading its host strap register. This change introduces a way to automatically select appropriate firmware depending of the connection method, and removes a need of symlinking or overwriting the original firmware file with a required one. Host strap register used in this commit comes from the NXP driver [1] hosted at Code Aurora. [1] https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/net/wireless/nxp/mxm_wifiex/wlan_src/mlinux/moal_sdio_mmc.c?h=rel_imx_5.4.70_2.3.2&id=688b67b2c7220b01521ffe560da7eee33042c7bd#n1274 Signed-off-by: Andrejs Cainikovs Reviewed-by: Alvin Šipraga --- drivers/net/wireless/marvell/mwifiex/sdio.c | 21 ++++++++++++++++++++- drivers/net/wireless/marvell/mwifiex/sdio.h | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index 4f3238d2a171..d26efd56be08 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c @@ -182,6 +182,9 @@ static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8997 = { .host_int_rsr_reg = 0x4, .host_int_status_reg = 0x0C, .host_int_mask_reg = 0x08, + .host_strap_reg = 0xF4, + .host_strap_mask = 0x01, + .host_strap_value = 0x00, .status_reg_0 = 0xE8, .status_reg_1 = 0xE9, .sdio_int_mask = 0xff, @@ -283,6 +286,9 @@ static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8987 = { .host_int_rsr_reg = 0x4, .host_int_status_reg = 0x0C, .host_int_mask_reg = 0x08, + .host_strap_reg = 0xF4, + .host_strap_mask = 0x01, + .host_strap_value = 0x00, .status_reg_0 = 0xE8, .status_reg_1 = 0xE9, .sdio_int_mask = 0xff, @@ -536,6 +542,7 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) struct mwifiex_sdio_device *data = (void *)id->driver_data; card->firmware = data->firmware; + card->firmware_sdiouart = data->firmware_sdiouart; card->reg = data->reg; card->max_ports = data->max_ports; card->mp_agg_pkt_limit = data->mp_agg_pkt_limit; @@ -2439,6 +2446,7 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) int ret; struct sdio_mmc_card *card = adapter->card; struct sdio_func *func = card->func; + const char *firmware = card->firmware; /* save adapter pointer in card */ card->adapter = adapter; @@ -2455,7 +2463,18 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) return ret; } - strcpy(adapter->fw_name, card->firmware); + /* Select correct firmware (sdsd or sdiouart) firmware based on the strapping + * option + */ + if (card->firmware_sdiouart) { + u8 val; + + mwifiex_read_reg(adapter, card->reg->host_strap_reg, &val); + if ((val & card->reg->host_strap_mask) == card->reg->host_strap_value) + firmware = card->firmware_sdiouart; + } + strcpy(adapter->fw_name, firmware); + if (card->fw_dump_enh) { adapter->mem_type_mapping_tbl = generic_mem_type_map; adapter->num_mem_types = 1; diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.h b/drivers/net/wireless/marvell/mwifiex/sdio.h index 5648512c9300..ad2c28cbb630 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.h +++ b/drivers/net/wireless/marvell/mwifiex/sdio.h @@ -196,6 +196,9 @@ struct mwifiex_sdio_card_reg { u8 host_int_rsr_reg; u8 host_int_status_reg; u8 host_int_mask_reg; + u8 host_strap_reg; + u8 host_strap_mask; + u8 host_strap_value; u8 status_reg_0; u8 status_reg_1; u8 sdio_int_mask; @@ -241,6 +244,7 @@ struct sdio_mmc_card { struct completion fw_done; const char *firmware; + const char *firmware_sdiouart; const struct mwifiex_sdio_card_reg *reg; u8 max_ports; u8 mp_agg_pkt_limit; @@ -274,6 +278,7 @@ struct sdio_mmc_card { struct mwifiex_sdio_device { const char *firmware; + const char *firmware_sdiouart; const struct mwifiex_sdio_card_reg *reg; u8 max_ports; u8 mp_agg_pkt_limit;