From patchwork Tue Feb 21 16:15:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Stromdahl X-Patchwork-Id: 9585041 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 B26BE6042F for ; Tue, 21 Feb 2017 16:17:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FD40200F5 for ; Tue, 21 Feb 2017 16:17:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93CBE27BFF; Tue, 21 Feb 2017 16:17:01 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 14EB4200F5 for ; Tue, 21 Feb 2017 16:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=m4llKm+LyPMDxwxrnxfTCtcgRpZNxFJoKc89N8dmsbU=; b=jRsEgg6N2TRaZCK0rDmhmhKizg Sy7DOcxi0Vd3HE/o6wkjhVfIuIWgFmunVLRTGH2izsHqoO8+vQHUliXJGDJniTnzFOXjc7jiDfvIE 2sKYExCLuVFbuIlC/BL+GkLUxPJW4lp55t9vVuksECducA4Og1k7KToPteC71WrsQS3qoMdOelSuF 31bKnFyZJ5urr4kIa1nTW/WI4Ui523XM8xP6IZCHkOnhLzUCHHWp70u6RoP0g4wckHRYIOssayy+J iVVZZcgkaSHhmi2gr0S06T2i2q9lw81cJovTckpAQ+6z1HwCmfLITueIf8+RahqgJ0RB5+Icqslj4 jRcCMvCg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cgD7X-00073U-67; Tue, 21 Feb 2017 16:16:55 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cgD7E-0006hn-AY for ath10k@lists.infradead.org; Tue, 21 Feb 2017 16:16:40 +0000 Received: by mail-lf0-x243.google.com with SMTP id 90so4026759lfr.3 for ; Tue, 21 Feb 2017 08:16:21 -0800 (PST) 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=mOhv3aENRhgXf049Mozmrn1yZt1BamaqVxLhqlE6Kd4=; b=HBLDym+ERCUW7i1oF2O5WJY0bJy7cPzr1Gg2X6iCf/ojvKEfjDcDzqfXOfcLflZbHw yiAc8Ba8V99AwTi6c+5N00oxgg3mkcVTcZIU0mkfSQ/t2TVF80CEs7KzDnr6hK/XQioR 9gM96JjA8Wi81vLWnjvS72ot7OBGPT3TvhXFAFwavIUM4KBMU39I68653AVxNW8HpABH uN2WxM5zkVpp8OSgLanz+jDVm6bZgf8/zdciZprF/+1cyqkWTrg5OWc7jEwBEH993QYA CH/LGvUOp6zNyvkFtjFn+6Qi93AIbKR0hzkIDLI3iJvl7IDRHy+EA5bNqYkA0FPgmU6b X34Q== 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=mOhv3aENRhgXf049Mozmrn1yZt1BamaqVxLhqlE6Kd4=; b=eJ+EgV9qhjpEZ0M6JUVMbPuNr6WbK5/N0OyQWBcvbZlrYsqC8Znb/BK3mqLob5c2PM 5CCTbdAZ6QeMdq4lIFgpMdpq+bWhCqTmOPIMIloV0N588ahkpjIPSnxnVX5hrDGc3qbu ltHyVzZ0Av4+WByYYZLz2MVRu4+BVIRE8izQaIa7DoodByDOLTMnNIuueGXW/0A42f9v o/T+bRMv5HPWn34l0YEsjjjaecPuqFnz+d6OH7j68WTCKpQOgpXxrEo6rmovdRQHz5R7 K6l1v99jbov3aXL1cfR9JGr34bna7cEYXudI+wvI8wzoNVomcpVvo5uW2IjcpIh+xymW 5G+g== X-Gm-Message-State: AMke39lvjLbXDh3Gxrzokde7qM7PB03lP/l+r+LKSyUoiwEvvjPcrZJzQev8th9yP5wR8w== X-Received: by 10.46.7.66 with SMTP id i2mr6937858ljd.79.1487693779914; Tue, 21 Feb 2017 08:16:19 -0800 (PST) Received: from erik-mate-1604.lan (90-227-62-61-no75.tbcn.telia.com. [90.227.62.61]) by smtp.gmail.com with ESMTPSA id t29sm6336069ljd.39.2017.02.21.08.16.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 08:16:19 -0800 (PST) From: Erik Stromdahl To: kvalo@qca.qualcomm.com, linux-wireless@vger.kernel.org, ath10k@lists.infradead.org Subject: [RFC v4 08/21] ath10k: sdio get target info Date: Tue, 21 Feb 2017 17:15:28 +0100 Message-Id: <1487693741-10042-9-git-send-email-erik.stromdahl@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487693741-10042-1-git-send-email-erik.stromdahl@gmail.com> References: <1487693741-10042-1-git-send-email-erik.stromdahl@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170221_081636_656382_298C22C0 X-CRM114-Status: GOOD ( 13.08 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Erik Stromdahl MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Special BMI get target info function for SDIO. Signed-off-by: Erik Stromdahl --- drivers/net/wireless/ath/ath10k/bmi.c | 70 ++++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/bmi.h | 2 + drivers/net/wireless/ath/ath10k/core.c | 5 ++- 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/bmi.c b/drivers/net/wireless/ath/ath10k/bmi.c index abeee20..54aaa1c0 100644 --- a/drivers/net/wireless/ath/ath10k/bmi.c +++ b/drivers/net/wireless/ath/ath10k/bmi.c @@ -97,6 +97,76 @@ int ath10k_bmi_get_target_info(struct ath10k *ar, return 0; } +#define TARGET_VERSION_SENTINAL 0xffffffffu + +int ath10k_bmi_get_target_info_sdio(struct ath10k *ar, + struct bmi_target_info *target_info) +{ + struct bmi_cmd cmd; + union bmi_resp resp; + u32 cmdlen = sizeof(cmd.id) + sizeof(cmd.get_target_info); + u32 resplen, tmp, ver_len; + int ret; + + ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi get target info SDIO\n"); + + if (ar->bmi.done_sent) { + ath10k_warn(ar, "BMI Get Target Info Command disallowed\n"); + return -EBUSY; + } + + cmd.id = __cpu_to_le32(BMI_GET_TARGET_INFO); + + /* Step 1: Read 4 bytes of the target info and check if it is + * the special sentinal version word or the first word in the + * version response. + */ + resplen = sizeof(u32); + ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, &tmp, &resplen); + if (ret) { + ath10k_warn(ar, "unable to read from device\n"); + return ret; + } + + /* Some SDIO boards have a special sentinal byte before the real + * version response. + */ + if (tmp == TARGET_VERSION_SENTINAL) { + /* Step 1b: Read the version length */ + resplen = sizeof(u32); + ret = ath10k_hif_exchange_bmi_msg(ar, NULL, 0, &tmp, + &resplen); + if (ret) { + ath10k_warn(ar, "unable to read from device\n"); + return ret; + } + } + + ver_len = __le32_to_cpu(tmp); + + /* Step 2: Check the target info length */ + if (ver_len != sizeof(resp.get_target_info)) { + ath10k_warn(ar, "Unexpected target info len: %u. Expected: %zu\n", + ver_len, sizeof(resp.get_target_info)); + return -EINVAL; + } + + /* Step 3: Read the rest of the version response */ + resplen = sizeof(resp.get_target_info) - sizeof(u32); + ret = ath10k_hif_exchange_bmi_msg(ar, NULL, 0, + &resp.get_target_info.version, + &resplen); + if (ret) { + ath10k_warn(ar, "unable to read from device\n"); + return ret; + } + + target_info->version = __le32_to_cpu(resp.get_target_info.version); + target_info->type = __le32_to_cpu(resp.get_target_info.type); + + return 0; +} + int ath10k_bmi_read_memory(struct ath10k *ar, u32 address, void *buffer, u32 length) { diff --git a/drivers/net/wireless/ath/ath10k/bmi.h b/drivers/net/wireless/ath/ath10k/bmi.h index a65f262..2043d00 100644 --- a/drivers/net/wireless/ath/ath10k/bmi.h +++ b/drivers/net/wireless/ath/ath10k/bmi.h @@ -197,6 +197,8 @@ void ath10k_bmi_start(struct ath10k *ar); int ath10k_bmi_done(struct ath10k *ar); int ath10k_bmi_get_target_info(struct ath10k *ar, struct bmi_target_info *target_info); +int ath10k_bmi_get_target_info_sdio(struct ath10k *ar, + struct bmi_target_info *target_info); int ath10k_bmi_read_memory(struct ath10k *ar, u32 address, void *buffer, u32 length); int ath10k_bmi_write_memory(struct ath10k *ar, u32 address, diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index eae502e..a0b331d 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -2186,7 +2186,10 @@ static int ath10k_core_probe_fw(struct ath10k *ar) } memset(&target_info, 0, sizeof(target_info)); - ret = ath10k_bmi_get_target_info(ar, &target_info); + if (ar->hif.bus == ATH10K_BUS_SDIO) + ret = ath10k_bmi_get_target_info_sdio(ar, &target_info); + else + ret = ath10k_bmi_get_target_info(ar, &target_info); if (ret) { ath10k_err(ar, "could not get target info (%d)\n", ret); goto err_power_down;