From patchwork Fri Apr 23 18:29:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 427135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, PDS_BAD_THREAD_QP_64, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92EECC43460 for ; Fri, 23 Apr 2021 18:29:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 674E8613CB for ; Fri, 23 Apr 2021 18:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243728AbhDWSa1 (ORCPT ); Fri, 23 Apr 2021 14:30:27 -0400 Received: from esa.microchip.iphmx.com ([68.232.154.123]:44326 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbhDWSaX (ORCPT ); Fri, 23 Apr 2021 14:30:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1619202586; x=1650738586; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=QFicB3L4qgvsaTe1LnysfuYZ2JLhR9ebVCygbVi5giU=; b=sJYbg50K6doQzJTNK1ZtCXDtGPkLTQZNO6R9yIYUyyxGC49UoixLEGDn /fMr5GMtlx78jf56sQ+IK8WGuOj/YVE2I7bDtNImDf3MMDwC2cmhEl2q9 2bSwIezN45j91b6LpV7/GW0IVzG8kBsSPQwCYloyhMrX3Tn4rXoV21Dwe 877SDj//4JBAxgEDb8giojLVIeEykr3o9QRgqalkbI7RcO9oZSZH+VB/M pfl8XzKI4TsTk8HcCJMYC2Y/kTk3YTuyKafEf0p46DBhycMO3nOF+gqaF A7Qc3Ko5Sr+M+X1D9n/cDPLwYlf2pv1Izff+g64LegWB3u0e+2GcWyoNv g==; IronPort-SDR: zDsOARGEu+fv8gCimRShngcaLaSKNqLbhNxs5x3VzleXpyxj2ekGEkbtOSWwyp0sxh/yIoUOP2 ZXli/slLC8K0i1mPH8bnxDNCyJ/kV2YnV43yCh6XVW+QMjrC4EvxbMf1Aq0pBnmZCmEJVhYmdm 61B1lHkFE+vV4Hk8VQAqsD7gzgX5G8hxc2238JlJ+KBcD3GLBd4qer/OjHdI4FVVnVKWh0q95V Yemi8pZzF4l0J2QpMPtZLv78pJHP44G8QtQfbMM4NItqqz250hFKc2VL9rKpAOPRYo+2eCydNG XyE= X-IronPort-AV: E=Sophos;i="5.82,246,1613458800"; d="scan'208";a="111995816" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Apr 2021 11:29:46 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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.2176.2; Fri, 23 Apr 2021 11:29:46 -0700 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2 via Frontend Transport; Fri, 23 Apr 2021 11:29:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fXdT3/UzCcumcVKesK8wCpTCrMSIraDirL+P+ghwupYmCn0IMjTGwI1Vg/hCkw/XQ0cqx3BDWbZGPl3DOiJ/S0OUcF/0KVCaqeLmxysubdj0OaelMS7mEPjS3l4ivZYfC9AOhXccBa7FaF4Dmx3tOxyWMm9zaTDdnT9v9yazUYhH0qEdPbP0QHkeMPwxevi79k+ufmr89LhZTuIp2Kq/tKZM8ZOCKjOnDv1XbKf/ObA0OG0mYOvAJIkRr0zYePR9zm0xVYOwlxdSmuLICov+qRgT7kyJIb/noh98CEcYImCV62Px9gsTMRJSwvG7mir21cd52XO7UYmbr8+yIAm0IQ== 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=/uyh7oGn1inencRrX435KeD1+FY6No+0ZwBBbhuDg5A=; b=E20YBp5Jt7FvXN8RNdY6D++EUBrt89WyQyMzDQ262ehdRMkrhWOVm4rqMq8tIWI6ZmqcE3iVs8V5GUqNM7DJEvMMlaITO/0diJyUgR8EhHcCvxWdCheSpxWhbfzq5AMcLoLm9odUUc9F3na4Tyg/xt+ftrXRjGQVrT995mfTisMF0Q3IYg3/XNgFnEIhO/LIJ7OERYNOHROzlanK6KlpYuXu9LRd12j6Hg+p5KgA9gLhbVUUmCqdhlO/j+iHJ2gefV7EU8/xvTH8dQM17Fc79frW0vgf4OT2oi7w3VIwQ+5wybzdulzm5uG2j0PUL+s7i0duqMM1AfnSG/ViwVujFQ== 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=/uyh7oGn1inencRrX435KeD1+FY6No+0ZwBBbhuDg5A=; b=Cruej5jy3yRmTfQnilbBdOZKTjEFlA0B3ThOdZ0MMdjEs5k6S6rNNVOPsG7PWtBTfsd09xmG7OGL0CCwIH7km5LOA2g59XNLt5yq7YMOYuysvCuB/zgoLPaak6W4MYTcNqxB/tGBXVOVBjTUDGeabW+s9ysp2ZXuphrwFAYSC5w= Received: from SJ0PR11MB4943.namprd11.prod.outlook.com (2603:10b6:a03:2ad::17) by BYAPR11MB3318.namprd11.prod.outlook.com (2603:10b6:a03:7d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Fri, 23 Apr 2021 18:29:45 +0000 Received: from SJ0PR11MB4943.namprd11.prod.outlook.com ([fe80::5da7:92e6:d6c9:64b3]) by SJ0PR11MB4943.namprd11.prod.outlook.com ([fe80::5da7:92e6:d6c9:64b3%7]) with mapi id 15.20.4065.024; Fri, 23 Apr 2021 18:29:45 +0000 From: To: CC: , Subject: [PATCH 05/12] wilc1000: add reset/terminate/repeat command support for SPI bus Thread-Topic: [PATCH 05/12] wilc1000: add reset/terminate/repeat command support for SPI bus Thread-Index: AQHXOG6ijAl2K25sXEivkuk3dLQvdA== Date: Fri, 23 Apr 2021 18:29:45 +0000 Message-ID: <20210423182925.5865-6-ajay.kathat@microchip.com> References: <20210423182925.5865-1-ajay.kathat@microchip.com> In-Reply-To: <20210423182925.5865-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 authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=microchip.com; x-originating-ip: [106.51.107.119] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d6fb5033-a88c-4711-cf53-08d90685c4d2 x-ms-traffictypediagnostic: BYAPR11MB3318: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:147; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jjw/oe1XqbO0DclA0RVNJPUiBHvfc2mFwm8WjZSGhSa8t4cb1G3GWzb5C5I9GvDW6jc3ZTcNvcSw58BNnSPdrJ26nTpXyZ2HXTOC1JMhkCkny5UkH/YjJh5nDQo1q4atBn3/gmMVS3GHwug9etsxWrHS1ZgdfLMCofwAvY4jZULFGoU2/YEazcPiaL8a+kXtvVTI4MhdKQIkZvl8FwBmypaLGaon5Se0u5v6fAAPxSDHvEu6m0PcFDWCafXw62fxYiRX5jQprI3Wg1HFeFhwB731OnanRbxb53pjn7HTon292kQtTfvVju4q16FWY6uXuQzpMZKGD+GuN90t4wbICFt7dzYhNlWpO7XAo3mg9EkPwi724z3FE0Kffdxwp+r52kffVdid2AqhJsuqMrkV3aVgkdZ1q1N2zbUFI2VWVFT64ZfEpczVamAtm3GTgiHQFw2WRsOJF52ztSC/6Nn7aN89b2BZLaHjxuKu+RjwmGzNYAvHFbsvYOvL83v6qACyFp95tZS0AqdCbTKsmlSTxSsWi1gNp+MXXp/+n7xVn1AADLYrJQruz8ysuifQESR1BUY9w0k052E0xWPD8b+ETUC7MiY/xWid58fBCBEyUuI= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB4943.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(376002)(136003)(39860400002)(346002)(366004)(8676002)(478600001)(55236004)(5660300002)(54906003)(6506007)(71200400001)(1076003)(4326008)(2616005)(6486002)(86362001)(316002)(107886003)(6916009)(66476007)(66446008)(186003)(66946007)(36756003)(122000001)(26005)(66556008)(91956017)(38100700002)(8936002)(64756008)(76116006)(6512007)(2906002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?ezJ8EAO5j9V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8859-1?q?agaKIvlMpQ08j01C/9YbYf7JB0UaIyde+xOY8dqp/a/bK9l26C/?= =?iso-8859-1?q?B5Fl3Ydhztj0sT+iS/BSPlkSu9zfeg5MRJBR6HIs3F7nfqXrfCE?= =?iso-8859-1?q?XHkxK2UzqREuintTa8r9s3YSjVtx6ftLcJ/Uk81YRCCcIhhVMUg?= =?iso-8859-1?q?ct2yGCwz5r3/90XhmKHO6dbeL+VtgQhCzHdfrsQDceq3sBRcHoh?= =?iso-8859-1?q?XUJXy00iEZc8GWBnnFPSDssSCYDCCfzQ8eU4UdSuW3KHVRoAcLq?= =?iso-8859-1?q?TwsDkykKjAYNgmzeHZ+9IshE+MiXf68+Qh++y3nJWjFYlJnk/8u?= =?iso-8859-1?q?xtQkI72VK+m4yjtsv8S7gV8IdfbefuxWeeGkMrZom4Lrft+/BZe?= =?iso-8859-1?q?br0k3F7Dv/NKUkGtp4lAEnq6ujkaq4GM6HuSgpMhUlLm0autRjO?= =?iso-8859-1?q?y3OJEyGNb+j+u1Ph6N89llgLuMZRN3m/hmdWuorGMmV9B5A010D?= =?iso-8859-1?q?RRqOB6PmFT7y7YBi8Ivei7BCmfEX7iuVfpsuF6C0U4fXuQp5bgZ?= =?iso-8859-1?q?lAWWCQOJn9YdIvxqnQ=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4943.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6fb5033-a88c-4711-cf53-08d90685c4d2 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Apr 2021 18:29:45.1256 (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: wx86T2FUF3nkcwb5s8E+gtNkaJz0POsvGH4spTivy5q+++BJRq5pndszSg32/qQN6Cn1D1IVU2vVOO6WlmDkDtkhZzv0B2OOUDip8DGW0ZM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3318 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Added API to send reset/terminate/repeat SPI commands to FW. Signed-off-by: Ajay Singh --- drivers/net/wireless/microchip/wilc1000/spi.c | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c index 1472e9843896..607c8b642865 100644 --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c @@ -143,6 +143,12 @@ struct wilc_spi_rsp_data { u8 data[]; } __packed; +struct wilc_spi_special_cmd_rsp { + u8 skip_byte; + u8 rsp_cmd_type; + u8 status; +} __packed; + static int wilc_bus_probe(struct spi_device *spi) { int ret; @@ -705,6 +711,61 @@ static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz) return 0; } +static int wilc_spi_special_cmd(struct wilc *wilc, u8 cmd) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = wilc->bus_data; + u8 wb[32], rb[32]; + int cmd_len, resp_len = 0; + struct wilc_spi_cmd *c; + struct wilc_spi_special_cmd_rsp *r; + + if (cmd != CMD_TERMINATE && cmd != CMD_REPEAT && cmd != CMD_RESET) + return -EINVAL; + + memset(wb, 0x0, sizeof(wb)); + memset(rb, 0x0, sizeof(rb)); + c = (struct wilc_spi_cmd *)wb; + c->cmd_type = cmd; + + if (cmd == CMD_RESET) + memset(c->u.simple_cmd.addr, 0xFF, 3); + + cmd_len = offsetof(struct wilc_spi_cmd, u.simple_cmd.crc); + resp_len = sizeof(*r); + + if (spi_priv->crc7_enabled) { + c->u.simple_cmd.crc[0] = wilc_get_crc7(wb, cmd_len); + cmd_len += 1; + } + if (cmd_len + resp_len > ARRAY_SIZE(wb)) { + dev_err(&spi->dev, "spi buffer size too small (%d) (%d) (%zu)\n", + cmd_len, resp_len, ARRAY_SIZE(wb)); + return -EINVAL; + } + + if (wilc_spi_tx_rx(wilc, wb, rb, cmd_len + resp_len)) { + dev_err(&spi->dev, "Failed cmd write, bus error...\n"); + return -EINVAL; + } + + r = (struct wilc_spi_special_cmd_rsp *)&rb[cmd_len]; + if (r->rsp_cmd_type != cmd) { + if (!spi_priv->probing_crc) + dev_err(&spi->dev, + "Failed cmd response, cmd (%02x), resp (%02x)\n", + cmd, r->rsp_cmd_type); + return -EINVAL; + } + + if (r->status != WILC_SPI_COMMAND_STAT_SUCCESS) { + dev_err(&spi->dev, "Failed cmd state response state (%02x)\n", + r->status); + return -EINVAL; + } + return 0; +} + static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data) { struct spi_device *spi = to_spi_device(wilc->dev);