From patchwork Mon Sep 4 10:43:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 111539 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1349345qge; Mon, 4 Sep 2017 03:43:11 -0700 (PDT) X-Received: by 10.99.43.145 with SMTP id r139mr11200200pgr.155.1504521791873; Mon, 04 Sep 2017 03:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504521791; cv=none; d=google.com; s=arc-20160816; b=L7e8lJXfWcZMpObO2Yo5APj8m3Erb5DlcUSOmIhDtIxIMgFSd7NviLn4NZSIYAO3Br /6kdMCDxyYkriUqybHZ2tLw+2FlwFFxMU9tU1OO8Y+qwq0mZjHYtndfcj0BxDjh6Tnmj s+9QFRN7ln3rlZUx7GFMF4CWcWxjs7GklKQAiIs83DbPVFbHbCwLfXjiunH79hE7PKHJ 3X0UJ8mBE6Lqx7RBVf3Xe+IzhUB9k+SgpPmEu+eINUb4g+LED8INrTQGP6N+GrMuOZVd zsXRNM2zfP/g/dOAvq9scH6e/mmmcrGxJU6AO8/hMDPp3VxSkCMHint0kvYzA7YR8O8T hYxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=EAPFZOS3awwXlTjkccZ7mUORdrYeQLekBjpFV4EZ3qo=; b=KeHOy9Yo3v5p9zsEzDrb64AxL3RDsEDqQ4+0WqlvglHA1WcATE3XHwZ28i7xMoZ7lx 2MnKJgL+A4r6BEcb8tmj7lIpinl+SKVNIQyvV80NRAZNvCNOHRd3Ag2MCE2JHYRazFEq bOBi0rlAB5GogRy4qOF9o8bQZOQI5YwRy4PIlS24ePa6cW6YDdAbxEEUxDdgt8PrILBY kcTMERGStj8rCCs+i6gs4iouUwqeQSxa1BKnJF/rdvRxusP1IEXRwIPKJ2D04lx7frMR vRBVpFe46HRP3OuND+dtcOG6SSgBGKD3O6RjoqoyiD/UNjso+ugN+hxlTkd5kCbcL187 TfcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TORZJz+y; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l2si4775009pfj.245.2017.09.04.03.43.11; Mon, 04 Sep 2017 03:43:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TORZJz+y; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753485AbdIDKnK (ORCPT + 9 others); Mon, 4 Sep 2017 06:43:10 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:38313 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753483AbdIDKnJ (ORCPT ); Mon, 4 Sep 2017 06:43:09 -0400 Received: by mail-wm0-f42.google.com with SMTP id 187so910892wmn.1 for ; Mon, 04 Sep 2017 03:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=rE2og6fuMU3DhQHSDHkAtCXddJMg4hh4oJTTVlfGc+w=; b=TORZJz+yKK+mtDdivm34knSjLJUZisjYiiU62SEVfiHRFkmE1+aXNEzhCtbVos872b VMUPjMzmPDD+2cBPppP2+A1rH2DmKFpshW1dTcwBNumpc1TaMtnkKXAoc/xvgERg0D6C 1JmsD487KTizyi2uiB/4f/uVIhOzk7NBwAwuk= 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; bh=rE2og6fuMU3DhQHSDHkAtCXddJMg4hh4oJTTVlfGc+w=; b=TuhHlvIQRCcWEon7w1JXz8EDlcAfLGmenyzGQsnd6rgMgVdv8Tln7h7VDfUsJI/bLt V7DYI2FGX7x9LDumEfbeMlAzAMxUTl0wpv91s/EOOAjRAab4HEkviWq8yZu6vWqWbF3+ T2iXVdz7eanzSYJ7hGvmJOCvlV6+iS0K8Z37QM++IuugGdmnccfaWMaC2WsTD8SfW7Ja rNYLSMF0S6VSzgZW/v6BED8s7jfdPNHYeC9RPq/zt8dVeYXVbY3FFqSInD8zYtrNScCw lSTbjjGmAuEftNKFEvKwU96TzWH2LTOHuGrdsinjbpxqCWuTcIOBH/FWub2AgJ1gTtqw twxA== X-Gm-Message-State: AHPjjUhyyFywYJoz2h17Ji/+A0JlpziYcMV1bI6bEt1US7A5a2SvrlSd n5lIizkE6O82q9tJ X-Google-Smtp-Source: ADKCNb5ln5ljZMua6sT8fkRjDiudkfHQHoWEgOVVE9KFrXNA2w446cGqLGVx8ZDTov4nNWER/Oekcw== X-Received: by 10.28.74.89 with SMTP id x86mr2614wma.57.1504521788172; Mon, 04 Sep 2017 03:43:08 -0700 (PDT) Received: from localhost.localdomain ([80.12.59.80]) by smtp.gmail.com with ESMTPSA id p87sm205297wmf.22.2017.09.04.03.43.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Sep 2017 03:43:07 -0700 (PDT) From: Loic Poulain To: marcel@holtmann.org Cc: linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, robh@kernel.org, Loic Poulain Subject: [PATCH v3] Bluetooth: btqcomsmd: BD address setup Date: Mon, 4 Sep 2017 12:43:04 +0200 Message-Id: <1504521784-9766-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Bluetooth BD address can be retrieved in the same way as for wcnss-wlan MAC address. This patch mainly stores the local-mac-address property and sets the BD address during hci device setup. If there is no such property, mark the device as unconfigured. Signed-off-by: Loic Poulain --- drivers/bluetooth/btqcomsmd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) v2: Set device as unconfigured if default address detected Add warning if BD addr retrieved from DT v3: if no addr retrieved from DT, unconditionally set the invalid BD addr flag. swap and set bdaddr in the platform probe -- 2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c index ef730c173d4b..37406a6aa1b5 100644 --- a/drivers/bluetooth/btqcomsmd.c +++ b/drivers/bluetooth/btqcomsmd.c @@ -15,6 +15,8 @@ #include #include #include +#include + #include #include @@ -26,6 +28,7 @@ struct btqcomsmd { struct hci_dev *hdev; + bdaddr_t bdaddr; struct rpmsg_endpoint *acl_channel; struct rpmsg_endpoint *cmd_channel; }; @@ -100,8 +103,35 @@ static int btqcomsmd_close(struct hci_dev *hdev) return 0; } +static int btqcomsmd_setup(struct hci_dev *hdev) +{ + struct btqcomsmd *btq = hci_get_drvdata(hdev); + struct sk_buff *skb; + + skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) + return PTR_ERR(skb); + kfree_skb(skb); + + /* Device does not have persistent storage for BD address. + * Mark the device with invalid BD addr flag if no address + * retrieved from DT. + */ + if (!bacmp(&btq->bdaddr, BDADDR_ANY)) { + bt_dev_err(hdev, "No BD address configured"); + set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks); + return 0; + } + + bt_dev_info(hdev, "BD address %pMR retrieved from device-tree", + &btq->bdaddr); + + return qca_set_bdaddr_rome(hdev, &btq->bdaddr); +} + static int btqcomsmd_probe(struct platform_device *pdev) { + const bdaddr_t *local_addr; struct btqcomsmd *btq; struct hci_dev *hdev; void *wcnss; @@ -123,6 +153,17 @@ static int btqcomsmd_probe(struct platform_device *pdev) if (IS_ERR(btq->cmd_channel)) return PTR_ERR(btq->cmd_channel); + /* Having a unique BD address is critical. + * Usually, the local-mac-address property is injected by + * the bootloader which has access to the provisioned data. + */ + local_addr = of_get_property(pdev->dev.of_node, "local-mac-address", + &ret); + if (local_addr && ret == sizeof(bdaddr_t)) { + /* local-mac-address stored with most significant byte first */ + baswap(&btq->bdaddr, local_addr); + } + hdev = hci_alloc_dev(); if (!hdev) return -ENOMEM; @@ -135,6 +176,7 @@ static int btqcomsmd_probe(struct platform_device *pdev) hdev->open = btqcomsmd_open; hdev->close = btqcomsmd_close; hdev->send = btqcomsmd_send; + hdev->setup = btqcomsmd_setup; hdev->set_bdaddr = qca_set_bdaddr_rome; ret = hci_register_dev(hdev);