From patchwork Mon Jan 30 17:26:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9546333 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 3B0F960453 for ; Tue, 31 Jan 2017 01:26:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E1482818B for ; Tue, 31 Jan 2017 01:26:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21479281D2; Tue, 31 Jan 2017 01:26:00 +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=-4.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,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 A6EE42818B for ; Tue, 31 Jan 2017 01:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754680AbdAaBZh (ORCPT ); Mon, 30 Jan 2017 20:25:37 -0500 Received: from mail-it0-f45.google.com ([209.85.214.45]:35168 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752700AbdAaBZW (ORCPT ); Mon, 30 Jan 2017 20:25:22 -0500 Received: by mail-it0-f45.google.com with SMTP id 203so207305201ith.0 for ; Mon, 30 Jan 2017 17:25:17 -0800 (PST) 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=wv5uBNJ+QtydGlW/E0vxNWrGXjyru5jbmtZCOKbrjT4=; b=abJf4ypZFZF3zD/Wgp+H53/PpkrzUsFb7f2CiYvgL+Fdzuxyo697cvSS0QcUs1AACW lF/q9U16UyGRVmw3FNGJSFt9AAfkpECISp/uduOVCXQmTTcPmLWVngj9LNAhTgQGVYZ9 iWP7jF6g9+RvQglTzKbMOL2nt8nH2pjQApppg= 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=wv5uBNJ+QtydGlW/E0vxNWrGXjyru5jbmtZCOKbrjT4=; b=Xft16kTu4E160kC8GajaXxmpELm4Od68gFLKm4TTWUrSv+d3ehDTZCXdRUxn0ZXXQy KUrgTz9JaijEq4rdhGk3kRCMseaEF21o67DnysiNPQ98Q650dgR8HrVxviDPsoaWS8hD D2pm7byQjssGjprHiInCZRd9wMXP0tLiYanwEjDDUfs7YtvnkVz1Bp2djTo6YbWDBLia qnBCA/jzzbD5fkijyccHZCj3/RW8g4x+wD74iQYOmOVsDM0outYOvK2t4dkR3AZlUaFF SkyfA8PKO9dpTsu1U1NfuQnb8QVLD92X4rUY66xdaRExYslOBYR9B3WFO/ZeSU30zVhr ykKA== X-Gm-Message-State: AIkVDXKDhcLg6hpsbTPUKddW3jYI9j+DC6Xj/dn80T7eYzglEaVfSv+9klz1IyuRA0Xt0nGQ X-Received: by 10.99.147.18 with SMTP id b18mr8166636pge.22.1485825916720; Mon, 30 Jan 2017 17:25:16 -0800 (PST) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id q64sm19436198pga.0.2017.01.30.17.25.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2017 17:25:15 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/3] remoteproc: qcom: wcnss: Make SMD handling common Date: Mon, 30 Jan 2017 09:26:22 -0800 Message-Id: <20170130172623.4894-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170130172623.4894-1-bjorn.andersson@linaro.org> References: <20170130172623.4894-1-bjorn.andersson@linaro.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 Move the SMD edge handling to the Qualcomm common file to make it reusable for other Qualcomm remoteproc drivers. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_common.c | 50 ++++++++++++++++++++++++++++++++++++++++ drivers/remoteproc/qcom_common.h | 15 ++++++++++-- drivers/remoteproc/qcom_wcnss.c | 28 ++++------------------ 3 files changed, 67 insertions(+), 26 deletions(-) diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index bd400336e209..bb90481215c6 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -19,10 +19,13 @@ #include #include #include +#include #include "remoteproc_internal.h" #include "qcom_common.h" +#define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev) + /** * qcom_mdt_find_rsc_table() - provide dummy resource table for remoteproc * @rproc: remoteproc handle @@ -42,5 +45,52 @@ struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, } EXPORT_SYMBOL_GPL(qcom_mdt_find_rsc_table); +static int smd_subdev_probe(struct rproc_subdev *subdev) +{ + struct qcom_rproc_subdev *smd = to_smd_subdev(subdev); + + smd->edge = qcom_smd_register_edge(smd->dev, smd->node); + + return IS_ERR(smd->edge) ? PTR_ERR(smd->edge) : 0; +} + +static void smd_subdev_remove(struct rproc_subdev *subdev) +{ + struct qcom_rproc_subdev *smd = to_smd_subdev(subdev); + + qcom_smd_unregister_edge(smd->edge); + smd->edge = NULL; +} + +/** + * qcom_add_smd_subdev() - try to add a SMD subdevice to rproc + * @rproc: rproc handle to parent the subdevice + * @smd: reference to a Qualcomm subdev context + */ +void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd) +{ + struct device *dev = &rproc->dev; + + smd->node = of_get_child_by_name(dev->parent->of_node, "smd-edge"); + if (!smd->node) + return; + + smd->dev = dev; + rproc_add_subdev(rproc, &smd->subdev, smd_subdev_probe, smd_subdev_remove); +} +EXPORT_SYMBOL_GPL(qcom_add_smd_subdev); + +/** + * qcom_remove_smd_subdev() - remove the smd subdevice from rproc + * @rproc: rproc handle + * @smd: the SMD subdevice to remove + */ +void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd) +{ + rproc_remove_subdev(rproc, &smd->subdev); + of_node_put(smd->node); +} +EXPORT_SYMBOL_GPL(qcom_remove_smd_subdev); + MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/remoteproc/qcom_common.h b/drivers/remoteproc/qcom_common.h index caecf27c4ffa..db5c826d5cd4 100644 --- a/drivers/remoteproc/qcom_common.h +++ b/drivers/remoteproc/qcom_common.h @@ -1,11 +1,22 @@ #ifndef __RPROC_QCOM_COMMON_H__ #define __RPROC_QCOM_COMMON_H__ -struct resource_table; -struct rproc; +#include +#include "remoteproc_internal.h" + +struct qcom_rproc_subdev { + struct rproc_subdev subdev; + + struct device *dev; + struct device_node *node; + struct qcom_smd_edge *edge; +}; struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, const struct firmware *fw, int *tablesz); +void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); +void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); + #endif diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index f158f8243b04..42ef6f3ebb2e 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -97,9 +97,7 @@ struct qcom_wcnss { void *mem_region; size_t mem_size; - struct device_node *smd_node; - struct qcom_smd_edge *smd_edge; - struct rproc_subdev smd_subdev; + struct qcom_rproc_subdev smd_subdev; }; static const struct wcnss_data riva_data = { @@ -401,23 +399,6 @@ static irqreturn_t wcnss_stop_ack_interrupt(int irq, void *dev) return IRQ_HANDLED; } -static int wcnss_smd_probe(struct rproc_subdev *subdev) -{ - struct qcom_wcnss *wcnss = container_of(subdev, struct qcom_wcnss, smd_subdev); - - wcnss->smd_edge = qcom_smd_register_edge(wcnss->dev, wcnss->smd_node); - - return IS_ERR(wcnss->smd_edge) ? PTR_ERR(wcnss->smd_edge) : 0; -} - -static void wcnss_smd_remove(struct rproc_subdev *subdev) -{ - struct qcom_wcnss *wcnss = container_of(subdev, struct qcom_wcnss, smd_subdev); - - qcom_smd_unregister_edge(wcnss->smd_edge); - wcnss->smd_edge = NULL; -} - static int wcnss_init_regulators(struct qcom_wcnss *wcnss, const struct wcnss_vreg_info *info, int num_vregs) @@ -600,9 +581,7 @@ static int wcnss_probe(struct platform_device *pdev) } } - wcnss->smd_node = of_get_child_by_name(pdev->dev.of_node, "smd-edge"); - if (wcnss->smd_node) - rproc_add_subdev(rproc, &wcnss->smd_subdev, wcnss_smd_probe, wcnss_smd_remove); + qcom_add_smd_subdev(rproc, &wcnss->smd_subdev); ret = rproc_add(rproc); if (ret) @@ -622,9 +601,10 @@ static int wcnss_remove(struct platform_device *pdev) of_platform_depopulate(&pdev->dev); - of_node_put(wcnss->smd_node); qcom_smem_state_put(wcnss->state); rproc_del(wcnss->rproc); + + qcom_remove_smd_subdev(wcnss->rproc, &wcnss->smd_subdev); rproc_free(wcnss->rproc); return 0;