From patchwork Mon Jan 30 15:03:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dwivedi, Avaneesh Kumar (avani)" X-Patchwork-Id: 9545557 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 2079160417 for ; Mon, 30 Jan 2017 15:03:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1637427F7F for ; Mon, 30 Jan 2017 15:03:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B26B281A7; Mon, 30 Jan 2017 15:03:43 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 9C18727F7F for ; Mon, 30 Jan 2017 15:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932308AbdA3PDh (ORCPT ); Mon, 30 Jan 2017 10:03:37 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:58596 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932080AbdA3PDY (ORCPT ); Mon, 30 Jan 2017 10:03:24 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A723C607F2; Mon, 30 Jan 2017 15:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1485788602; bh=ATTFNKw/rcQ8tEHCrUXzo3T3W+9ErNLB7jzUco95854=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFDzwLSIY6rztWZTKUjs58imkv4be0GIPX3lqhwvBCGhkHR0vH/8KfzzsppjeW2F1 FW5Ha3K3PR1mqbS0uostYLoW2jLfFvqRvinKStflEAYS0fCcnyYcK/LBbArQOngeN7 bw11URECU3/fOChu2C/IQx64SgKLz6+8frMtHPvQ= Received: from akdwived-linux.qualcomm.com (unknown [202.46.23.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: akdwived@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E5CBC607A2; Mon, 30 Jan 2017 15:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1485788602; bh=ATTFNKw/rcQ8tEHCrUXzo3T3W+9ErNLB7jzUco95854=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFDzwLSIY6rztWZTKUjs58imkv4be0GIPX3lqhwvBCGhkHR0vH/8KfzzsppjeW2F1 FW5Ha3K3PR1mqbS0uostYLoW2jLfFvqRvinKStflEAYS0fCcnyYcK/LBbArQOngeN7 bw11URECU3/fOChu2C/IQx64SgKLz6+8frMtHPvQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E5CBC607A2 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=akdwived@codeaurora.org From: Avaneesh Kumar Dwivedi To: bjorn.andersson@linaro.org Cc: sboyd@codeaurora.org, agross@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, Avaneesh Kumar Dwivedi Subject: [PATCH v3 1/4] remoteproc: qcom: Compatible string based resource initialization. Date: Mon, 30 Jan 2017 20:33:06 +0530 Message-Id: <1485788589-21968-2-git-send-email-akdwived@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485788589-21968-1-git-send-email-akdwived@codeaurora.org> References: <1485788589-21968-1-git-send-email-akdwived@codeaurora.org> Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch initialize certain driver related data based on compatible string. This enable driver to handle more than one similar device in by differentiating in probe their private data. Signed-off-by: Avaneesh Kumar Dwivedi --- drivers/remoteproc/qcom_adsp_pil.c | 47 ++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 43a4ed2..f674301 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -32,9 +32,12 @@ #include "qcom_mdt_loader.h" #include "remoteproc_internal.h" -#define ADSP_CRASH_REASON_SMEM 423 -#define ADSP_FIRMWARE_NAME "adsp.mdt" -#define ADSP_PAS_ID 1 +struct adsp_data { + int crash_reason_smem; + const char *firmware_name; + int pas_id; +}; + struct qcom_adsp { struct device *dev; @@ -53,6 +56,9 @@ struct qcom_adsp { struct regulator *cx_supply; + int pas_id; + int crash_reason_smem; + struct completion start_done; struct completion stop_done; @@ -70,7 +76,7 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) bool relocate; int ret; - ret = qcom_scm_pas_init_image(ADSP_PAS_ID, fw->data, fw->size); + ret = qcom_scm_pas_init_image(adsp->pas_id, fw->data, fw->size); if (ret) { dev_err(&rproc->dev, "invalid firmware metadata\n"); return ret; @@ -85,7 +91,8 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) if (relocate) { adsp->mem_reloc = fw_addr; - ret = qcom_scm_pas_mem_setup(ADSP_PAS_ID, adsp->mem_phys, fw_size); + ret = qcom_scm_pas_mem_setup(adsp->pas_id, + adsp->mem_phys, fw_size); if (ret) { dev_err(&rproc->dev, "unable to setup memory for image\n"); return ret; @@ -113,7 +120,7 @@ static int adsp_start(struct rproc *rproc) if (ret) goto disable_clocks; - ret = qcom_scm_pas_auth_and_reset(ADSP_PAS_ID); + ret = qcom_scm_pas_auth_and_reset(adsp->pas_id); if (ret) { dev_err(adsp->dev, "failed to authenticate image and release reset\n"); @@ -124,7 +131,7 @@ static int adsp_start(struct rproc *rproc) msecs_to_jiffies(5000)); if (!ret) { dev_err(adsp->dev, "start timed out\n"); - qcom_scm_pas_shutdown(ADSP_PAS_ID); + qcom_scm_pas_shutdown(adsp->pas_id); ret = -ETIMEDOUT; goto disable_regulators; } @@ -157,7 +164,7 @@ static int adsp_stop(struct rproc *rproc) BIT(adsp->stop_bit), 0); - ret = qcom_scm_pas_shutdown(ADSP_PAS_ID); + ret = qcom_scm_pas_shutdown(adsp->pas_id); if (ret) dev_err(adsp->dev, "failed to shutdown: %d\n", ret); @@ -197,7 +204,7 @@ static irqreturn_t adsp_fatal_interrupt(int irq, void *dev) size_t len; char *msg; - msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, ADSP_CRASH_REASON_SMEM, &len); + msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, adsp->crash_reason_smem, &len); if (!IS_ERR(msg) && len > 0 && msg[0]) dev_err(adsp->dev, "fatal error received: %s\n", msg); @@ -311,20 +318,25 @@ static int adsp_alloc_memory_region(struct qcom_adsp *adsp) static int adsp_probe(struct platform_device *pdev) { + const struct adsp_data *desc; struct qcom_adsp *adsp; struct rproc *rproc; int ret; + desc = of_device_get_match_data(&pdev->dev); + if (!desc) + return -EINVAL; + if (!qcom_scm_is_available()) return -EPROBE_DEFER; - if (!qcom_scm_pas_supported(ADSP_PAS_ID)) { - dev_err(&pdev->dev, "PAS is not available for ADSP\n"); + if (!qcom_scm_pas_supported(desc->pas_id)) { + dev_err(&pdev->dev, "PAS is not available for subsystem\n"); return -ENXIO; } rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops, - ADSP_FIRMWARE_NAME, sizeof(*adsp)); + desc->firmware_name, sizeof(*adsp)); if (!rproc) { dev_err(&pdev->dev, "unable to allocate remoteproc\n"); return -ENOMEM; @@ -344,6 +356,8 @@ static int adsp_probe(struct platform_device *pdev) if (ret) goto free_rproc; + adsp->pas_id = desc->pas_id; + adsp->crash_reason_smem = desc->crash_reason_smem; ret = adsp_init_clock(adsp); if (ret) goto free_rproc; @@ -407,9 +421,14 @@ static int adsp_remove(struct platform_device *pdev) return 0; } +static const struct adsp_data adsp_resource_init = { + .crash_reason_smem = 423, + .firmware_name = "adsp.mdt", + .pas_id = 1, +}; static const struct of_device_id adsp_of_match[] = { - { .compatible = "qcom,msm8974-adsp-pil" }, - { .compatible = "qcom,msm8996-adsp-pil" }, + { .compatible = "qcom,msm8974-adsp-pil", .data = &adsp_resource_init}, + { .compatible = "qcom,msm8996-adsp-pil", .data = &adsp_resource_init}, { }, }; MODULE_DEVICE_TABLE(of, adsp_of_match);