From patchwork Fri Jun 16 14:54:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitkumar Karwar X-Patchwork-Id: 9791931 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74DBB6038E for ; Fri, 16 Jun 2017 14:57:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B18228614 for ; Fri, 16 Jun 2017 14:57:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FB7C28649; Fri, 16 Jun 2017 14:57:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D99DB28614 for ; Fri, 16 Jun 2017 14:57:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752727AbdFPO5u (ORCPT ); Fri, 16 Jun 2017 10:57:50 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36768 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752231AbdFPO5t (ORCPT ); Fri, 16 Jun 2017 10:57:49 -0400 Received: by mail-pf0-f196.google.com with SMTP id y7so6919661pfd.3 for ; Fri, 16 Jun 2017 07:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JnZ7hqka+owATKZu/VpdmP0kGfTj2k6a5pjTyld7UcA=; b=Dz2+xLwzHs2Vp6FYLlP6DfvTeOx+qZ6vGBpkuWb9NzY+ub9lHGrnm/FXS30C4oEPXd U4MLZMEegDsJbYNMSnFBctzCwptr5M092MNstzDsDh7JiOjlcWlwJZRITz6WnlQc4dNz je+5KPgDRL+DtbtP5lmHGm094gyBEDQ9xm+nACyltpvC8CYP2YDxxpSY6YaoRV2tRXwh BD4ARuyn/qFUPAbNCZ4DeAol/A/JQvYKGOiVxT9uPWVw8eRA/dTtg7rl/YJvFpwyy4Pd 6GFeDXnlrLv7KJ1iCyQVOENHXyDeaBcQ8aH4jnC37+jUFn6BbJWTFMaCz/FdbsU8R0oe 3/ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JnZ7hqka+owATKZu/VpdmP0kGfTj2k6a5pjTyld7UcA=; b=uUBV/coaTDtRTkuVqjFSS0P0cV2/UR819T/x9g+HkNoKo2/UhY7nmvGy0o86+JycAO thXQs6PXydD49WoVwgVSt8RvaRFbs4M9fise8K+gPt1KKmt+T1/tTO0UEViw4vvtQlXI VMV2gtXkeq14biacmbbz/uooulx9yWxEbeDfDAEDHAd6W5rvr+ka3FNWmJ2W1vKmp2PK lk1od5CjQQjT90+aLdNk7K8D/2wgCJeefuOty8Yh0vfSKjRI0VJim2i7DPaV3Ou2WiD3 qdVyG0hGuNw7XhruMZZ+s5No+gXUpIfjJGwhfTpPGAkafofSenxn/c5ZsYQ/G/KErHEz xILQ== X-Gm-Message-State: AKS2vOzlfcz9N8ttMQOizco6XwTDOpIRco2tHm4vYDmt9ZFOPw9zcMwi WP3hWmgAxny8V04V X-Received: by 10.101.76.201 with SMTP id n9mr11890359pgt.40.1497625068779; Fri, 16 Jun 2017 07:57:48 -0700 (PDT) Received: from cpu185.redpinesignals.com ([203.196.161.90]) by smtp.gmail.com with ESMTPSA id 66sm5799930pgh.59.2017.06.16.07.57.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jun 2017 07:57:48 -0700 (PDT) From: Amitkumar Karwar X-Google-Original-From: Amitkumar Karwar To: Kalle Valo Cc: linux-wireless@vger.kernel.org, Amitkumar Karwar , Karun Eagalapati , Amitkumar Karwar Subject: [v2 05/20] rsi: card reset for USB interface Date: Fri, 16 Jun 2017 20:24:26 +0530 Message-Id: <1497624881-2315-6-git-send-email-amit.karwar@redpinesignals.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497624881-2315-1-git-send-email-amit.karwar@redpinesignals.com> References: <1497624881-2315-1-git-send-email-amit.karwar@redpinesignals.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Karun Eagalapati We need to reset the chip in teardown path so that it can work next time when driver is loaded. This patch adds support for this reset configuration for USB. Signed-off-by: Karun Eagalapati Signed-off-by: Amitkumar Karwar --- drivers/net/wireless/rsi/rsi_91x_usb.c | 72 ++++++++++++++++++++++++++++++++++ drivers/net/wireless/rsi/rsi_usb.h | 1 + 2 files changed, 73 insertions(+) diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c index bcd7f45..1d7bb9d 100644 --- a/drivers/net/wireless/rsi/rsi_91x_usb.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb.c @@ -558,6 +558,77 @@ static int rsi_init_usb_interface(struct rsi_hw *adapter, return status; } +static int usb_ulp_read_write(struct rsi_hw *adapter, u16 addr, u32 data, + u16 len_in_bits) +{ + int ret; + + ret = rsi_usb_master_reg_write + (adapter, RSI_GSPI_DATA_REG1, + ((addr << 6) | ((data >> 16) & 0xffff)), 2); + if (ret < 0) + return ret; + + ret = rsi_usb_master_reg_write(adapter, RSI_GSPI_DATA_REG0, + (data & 0xffff), 2); + if (ret < 0) + return ret; + + /* Initializing GSPI for ULP read/writes */ + rsi_usb_master_reg_write(adapter, RSI_GSPI_CTRL_REG0, + RSI_GSPI_CTRL_REG0_VALUE, 2); + + ret = rsi_usb_master_reg_write(adapter, RSI_GSPI_CTRL_REG1, + ((len_in_bits - 1) | RSI_GSPI_TRIG), 2); + if (ret < 0) + return ret; + + msleep(20); + + return 0; +} + +static int rsi_reset_card(struct rsi_hw *adapter) +{ + int ret; + + rsi_dbg(INFO_ZONE, "Resetting Card...\n"); + rsi_usb_master_reg_write(adapter, RSI_TA_HOLD_REG, 0xE, 4); + + /* This msleep will ensure Thread-Arch processor to go to hold + * and any pending dma transfers to rf in device to finish. + */ + msleep(100); + + ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_TIMER_1, + RSI_ULP_WRITE_2, 32); + if (ret < 0) + goto fail; + ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_TIMER_2, + RSI_ULP_WRITE_0, 32); + if (ret < 0) + goto fail; + ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_DELAY_TIMER_1, + RSI_ULP_WRITE_50, 32); + if (ret < 0) + goto fail; + ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_DELAY_TIMER_2, + RSI_ULP_WRITE_0, 32); + if (ret < 0) + goto fail; + ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_TIMER_ENABLE, + RSI_ULP_TIMER_ENABLE, 32); + if (ret < 0) + goto fail; + + rsi_dbg(INFO_ZONE, "Reset card done\n"); + return ret; + +fail: + rsi_dbg(ERR_ZONE, "Reset card failed\n"); + return ret; +} + /** * rsi_probe() - This function is called by kernel when the driver provided * Vendor and device IDs are matched. All the initialization @@ -641,6 +712,7 @@ static void rsi_disconnect(struct usb_interface *pfunction) return; rsi_mac80211_detach(adapter); + rsi_reset_card(adapter); rsi_deinit_usb_interface(adapter); rsi_91x_deinit(adapter); diff --git a/drivers/net/wireless/rsi/rsi_usb.h b/drivers/net/wireless/rsi/rsi_usb.h index 59513ac..2c5c0e7 100644 --- a/drivers/net/wireless/rsi/rsi_usb.h +++ b/drivers/net/wireless/rsi/rsi_usb.h @@ -25,6 +25,7 @@ #define USB_INTERNAL_REG_1 0x25000 #define RSI_USB_READY_MAGIC_NUM 0xab #define FW_STATUS_REG 0x41050012 +#define RSI_TA_HOLD_REG 0x22000844 #define USB_VENDOR_REGISTER_READ 0x15 #define USB_VENDOR_REGISTER_WRITE 0x16