Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2353759ybk; Mon, 11 May 2020 19:35:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbwLI3ez/cw+x5tX2EjnCh+LetPlWeYVyz2DvgfvoAVcBsTpRixIQ/au9LdgTRSYRyb2lF X-Received: by 2002:a17:906:dbcf:: with SMTP id yc15mr5180718ejb.176.1589250940441; Mon, 11 May 2020 19:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589250940; cv=none; d=google.com; s=arc-20160816; b=WllV17ccMFcJI6EG45Ub//5HfgP1rwTUxZVBm33omzFkKP3ACm8dfu2eYqxqHs/8aX RC0lVMKE/GXl4k7e4xlx2wDUI7n5zjuxLoBpNur66e4cq0C8dw9teXRSlDUQzpJIEqwr i33tnieIho6sLwZpn06HQmiNYGruNmHIRcFCq066+r9uSfDtX2PNP5+2/8jaxWf6s2uu SsnLadsBIXzEJJmeQgXYmMIS2LsxcKjI48kT1apKca15bMLz+q8vCJpAu0Ax183z0iTk aSvjvwzojM9ulGJZnB3gYVuVms8Lkzs5HQZv46xapK7q0LeT0jL/Xq7lpuXEkaqNyjOX BtGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=V94ZBtElrYKPuW5itFPhUi9hnQTxAz3rOMgMz//e1VI=; b=FAkTMgD7fpZWNMOT0hVoPEmyOeFxighkSncuX/QWeEfh5R4u25LaHWvEXUkQZ7/r6L wboTkXegawK9TCBIKkCcY33+lK/DmDCmo0vLaAas+ExNCoA0l60BhSS5YxBRlRsYAsPP yiyYu4/YWZKW0SyJqtSx1oGMIwqcZ7f5laCqFOj2eHRXVAVA7Ut1FNfxuRYMhqk/mDxK y2G37KBby3k41nPR1J+MH4T4DM1fix32V3MmFS+oQnivKuDY1L9FM3g1pmdyPgrSlj5I KQ2RzVYs9OS94qqKrlq3rIDWi+scT2UcrKS4iWcFZcrP9WJpOTlrSZwIujdY8+mcaWRP W8iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=tOAEgjT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z8si755797ejf.525.2020.05.11.19.35.18; Mon, 11 May 2020 19:35:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=tOAEgjT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728622AbgELCdm (ORCPT + 99 others); Mon, 11 May 2020 22:33:42 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:35323 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728606AbgELCdl (ORCPT ); Mon, 11 May 2020 22:33:41 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1589250820; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=V94ZBtElrYKPuW5itFPhUi9hnQTxAz3rOMgMz//e1VI=; b=tOAEgjT74784gLRXizgbGEv1gg00e0aqQ21w0GJvp0vybSCaoSPRFgPPOBBPNQM1KWt1IYzM PUkdQielBKxHbHTKgoMP9kEgRt/5zNSNblYtgbPr9ir+kir21UB1SU9r7bGbLSGRCkDRXy78 1FLqIQm6jblN+PBbwdk7G3vKU4w= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5eba0af8.7fa80de176f8-smtp-out-n02; Tue, 12 May 2020 02:33:28 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A2276C433CB; Tue, 12 May 2020 02:33:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from bbhatt-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bbhatt) by smtp.codeaurora.org (Postfix) with ESMTPSA id 72FA6C433CB; Tue, 12 May 2020 02:33:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 72FA6C433CB Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=bbhatt@codeaurora.org From: Bhaumik Bhatt To: manivannan.sadhasivam@linaro.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, hemantk@codeaurora.org, jhugo@codeaurora.org, Bhaumik Bhatt Subject: [PATCH v1 5/6] bus: mhi: core: Read and save device hardware information from BHI Date: Mon, 11 May 2020 19:33:15 -0700 Message-Id: <1589250796-32020-6-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1589250796-32020-1-git-send-email-bbhatt@codeaurora.org> References: <1589250796-32020-1-git-send-email-bbhatt@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Device hardware specific information such as serial number and the OEM PK hash can be read using BHI and saved on host to identify the endpoint. Signed-off-by: Bhaumik Bhatt Reviewed-by: Jeffrey Hugo --- drivers/bus/mhi/core/boot.c | 17 ++++++++++++++++- include/linux/mhi.h | 6 ++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c index 0b38014..24422f5 100644 --- a/drivers/bus/mhi/core/boot.c +++ b/drivers/bus/mhi/core/boot.c @@ -392,13 +392,28 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl) void *buf; dma_addr_t dma_addr; size_t size; - int ret; + int i, ret; if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { dev_err(dev, "Device MHI is not in valid state\n"); return; } + /* save hardware info from BHI */ + ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_SERIALNU, + &mhi_cntrl->serial_number); + if (ret) + dev_err(dev, "Could not capture serial number via BHI\n"); + + for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++) { + ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_OEMPKHASH(i), + &mhi_cntrl->oem_pk_hash[i]); + if (ret) { + dev_err(dev, "Could not capture OEM PK HASH via BHI\n"); + break; + } + } + /* If device is in pass through, do reset to ready state transition */ if (mhi_cntrl->ee == MHI_EE_PTHRU) goto fw_load_ee_pthru; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 026a624..42e4d1e 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -19,6 +19,8 @@ #define MHI_VOTE_BUS BIT(0) /* do not disable the mhi bus */ #define MHI_VOTE_DEVICE BIT(1) /* prevent mhi device from entering lpm */ +#define MHI_MAX_OEM_PK_HASH_SEGMENTS 16 + struct mhi_chan; struct mhi_event; struct mhi_ctxt; @@ -318,6 +320,8 @@ struct mhi_controller_config { * @device_number: MHI controller device number * @major_version: MHI controller major revision number * @minor_version: MHI controller minor revision number + * @serial_number: MHI controller serial number obtained from BHI + * @oem_pk_hash: MHI controller OEM PK Hash obtained from BHI * @mhi_event: MHI event ring configurations table * @mhi_cmd: MHI command ring configurations table * @mhi_ctxt: MHI device context, shared memory between host and device @@ -397,6 +401,8 @@ struct mhi_controller { u32 device_number; u32 major_version; u32 minor_version; + u32 serial_number; + u32 oem_pk_hash[MHI_MAX_OEM_PK_HASH_SEGMENTS]; struct mhi_event *mhi_event; struct mhi_cmd *mhi_cmd; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project