From patchwork Mon Sep 28 04:09:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802805 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8B72E618 for ; Mon, 28 Sep 2020 04:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7259623998 for ; Mon, 28 Sep 2020 04:11:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GWmJumpQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbgI1ELJ (ORCPT ); Mon, 28 Sep 2020 00:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726615AbgI1ELH (ORCPT ); Mon, 28 Sep 2020 00:11:07 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8650C0613CF for ; Sun, 27 Sep 2020 21:11:07 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a9so2822991pjg.1 for ; Sun, 27 Sep 2020 21:11:07 -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:in-reply-to:references; bh=Y1HDeSf7eMJfSl6ZK/D9lqct6zJN8sO0bd/DmJuThzk=; b=GWmJumpQNYDpkW+si2fcpKk90e7hbuTjKyNSdHcpiMp7cEBlXKXGhvmL/JJrTTBPR4 8lQckHiKQ3Io3UHTz9Gp3aeigNONs/l+P7+3pXxwYSbWNFAvoepYa7ZnSytuZKo9e7AU vz+l2KOOBr2hy0NE2PjXRaT1BydvQZGyo/klKGx0oL/ch6h6igLP7TtZg+XnnnFL/lkm 8ILMpZ7/3d6uKABUgk48/M5b4iGkEuPIKiq4r7gCxcJgGfrFyIL52QUKksYqt5Fp7u6I rnhbxcxXgxwq+tZwQqyrGjjwCu+a/DY3Iy0IVoetyWtn97nOddAZWHlEAHKZMezpBWnU KdsA== 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=Y1HDeSf7eMJfSl6ZK/D9lqct6zJN8sO0bd/DmJuThzk=; b=BOPpWURKdx7F8CvrYcU4ZZaqWrCyAs/m7+FD8aXJjrQt+cBY+25NuxB9wcRdhz3tW4 jDHhjD4BHQ/yrhiJpDiGConxi8UUrXaAkDkg7iXn8LEYp6WkcGWrPw3HM8I7Q4d9rOXN aeD+5Y+ibo2CKm0BL1VL9wbIdKs17A9brAXrSObDDuBAHaTUpXiNjQWkTpJmw8QBzXTV 3tS6YNMbRglZLuSuoIy+KEpWgFDcBiiAZDyjjkrZSd3/RsrLM27vRaeVxAYIiFTOZzsb ASexdqFlcYgRGADgwQ22MEORVlZ5D9M6LSgQXHxqtMIx+9LphA3FujaGpiujpsgBd5zm YEHw== X-Gm-Message-State: AOAM533d0VUlYoPSlvGzkDbbRfzRAyY7ui2leLj7BX6xaONA5syI7VN5 /w7Y23V8hQFXMyWo0yW69Zca X-Google-Smtp-Source: ABdhPJx3Uzp+u6iVp2aTZdDvgZro+BN+JLXttA1Njr02Hi37JBxDdySbXYKvdzb0x1fOkjcTRLC0RQ== X-Received: by 2002:a17:90a:c705:: with SMTP id o5mr7853978pjt.68.1601266266730; Sun, 27 Sep 2020 21:11:06 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:06 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 09/21] bus: mhi: core: Read and save device hardware information from BHI Date: Mon, 28 Sep 2020 09:39:39 +0530 Message-Id: <20200928040951.18207-10-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt 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 Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- 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 0b38014d040e..24422f5c3d80 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 c56b4447a4e9..0c97f4bc5fae 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -16,6 +16,8 @@ #include #include +#define MHI_MAX_OEM_PK_HASH_SEGMENTS 16 + struct mhi_chan; struct mhi_event; struct mhi_ctxt; @@ -316,6 +318,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 @@ -394,6 +398,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;