From patchwork Thu Apr 15 13:27:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 12205495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87209C43460 for ; Thu, 15 Apr 2021 13:46:16 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE5E261008 for ; Thu, 15 Apr 2021 13:46:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE5E261008 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MVqegmeO2cM+Ed8I++ibiKrN3L8ql9qZp+ZTCoXkAE4=; b=g4MCausxkVftyFlL04NFVDnPR Q4yJ/Ii9tHp+38j7H79Fz6PloVRO/q7ZkPO3UNawCC3cp5cTNcT/0eET7IhwVN87A4roZTjyqLeA1 G+YUSW/z6gdUZS6eThmKgLCymh0pnj1ROitz/RRuShUq/e9H942kQ1UelERGlYtpGk0fB1Ha3HlKG 5gWQZpkndsOczjb3QoPyDXMSt7ul64sINimEnSSDwjEoxr7eFuuuW1hCWPfb9BX+TZSPuLVi4uQBr rSN2GrIofIlT12w58T5kn+ZtOWpoMAsxyhTbOfDN0wGHijPhJGcUv0jOPzV3WJGdMDd6cWvnc597A 9POp59GCA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lX2Hp-00GIiG-4x; Thu, 15 Apr 2021 13:44:01 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lX2H4-00GIUj-SU for linux-arm-kernel@desiato.infradead.org; Thu, 15 Apr 2021 13:43:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0Irswd7lUzB1pM9KD5IwiTaCbYnT1kuWoR+EHA/da7s=; b=Jb+LHzCSFhwiPMpCGmNUnFd5/W ytMtBqwDNOXkMIbxq4E9hQ/FFjQ+wOSnRsAWUBEwt+vBgYQDX2I1KBB1IEM23THCNyR7BITKJta5a 3aHlTrSKYx2YLd7MavrYM6eGqcBdgcfVxkaTR7XANpHfBIDkTnnyMHRtohWwIAukMpMy7zp/z65O+ CWpFvRP2KxTX0H9HFmt/kfxvxOsm90MoaQMoluPJ9rYbXjh63/jc9iInR29EaWv5QUpZq9q0ngKeJ mZbcDmS1pHxlXzgxLTj9MP2JJ9Do9y5SxpHNpOPCTycERsSCQmfLbC6triEFszcCp3kcKuD/EKl6I 27Edw1mw==; Received: from mail-vi1eur05on2068.outbound.protection.outlook.com ([40.107.21.68] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lX2H2-008cEf-8o for linux-arm-kernel@lists.infradead.org; Thu, 15 Apr 2021 13:43:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fksAX73Q8d/chpKyAq7Ey8VZgLW8pGWlU6VeYZit4VmzFRzlhjBPm/4YSp9hLArdLyA0Sq8lOLPQAIYQnuvBPupl1I/3f3OYqKgvy+pf8JmofhiymP+0P2x+bHVgWvRnrNLRm8Txx9Le/Ets5PI66esyoEI6mcinYluqZf1JWygrGeub5u3FkNgotGw2tmFdXBryQGSgOMpGD9R8WAlQ/FFgEtme2c9ehsWsY1hNypYViF54TjCPHwvAyOnhlvcHjoH80mptqDjqYYsWX3bAUyMQoWxVASuM0FiW/mCumvmoUZY3DCnJul9mBQSFpZxA0zszx6asozrfeS2dW8pcxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0Irswd7lUzB1pM9KD5IwiTaCbYnT1kuWoR+EHA/da7s=; b=AFwNdvoT25RqwgnIjC2/Xs+QbefxgSVzwjqd63cXmuAB8VwOP7tQZgTd1RiIA3NZyyKqzKU++dYuoF0bPEvOf+HyQ8oUMXr/tfJWwM28+56R/WrLn/QxI+lrMxNkj7jjoUOvhFt0ywblm7Q2IiWgoIWn8qmfABXjuC4/vnByRmS1tg2Da329RJEzyGJJTLxQGlSu9J8eNgPGKO0T1+YRO9Q7qyE28YMFrfmZAJFHBwgqi1NYH43y/bYYUW6w2zaw27Mfy3piE3c7YtA9F3iMwSJJwKPX/XDworoOIkOWHbhZ9mq61XTY9ECv7APicrqPeAgb44tZ2SmQk2g/RZ927g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0Irswd7lUzB1pM9KD5IwiTaCbYnT1kuWoR+EHA/da7s=; b=TwadtdIcFywuuRXXwsTKkv5MxX2iVe4JiBTk88NGycs6YwUdZ4M2tPcqkUWZRXVnkzJ5ZqhHBeKZfPtCsWQhDdvKdHWQLBlKmChN1kB+Mw8Cn2p6Du1prGSA04RcmvCD/G1KxDko02NRe5qQAFvpjC6WclvFq0LanBrXSTYCeh4= Authentication-Results: wizery.com; dkim=none (message not signed) header.d=none;wizery.com; dmarc=none action=none header.from=oss.nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB5241.eurprd04.prod.outlook.com (2603:10a6:10:1d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16; Thu, 15 Apr 2021 13:43:08 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c57a:6964:f72c:21cf]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c57a:6964:f72c:21cf%11]) with mapi id 15.20.3999.037; Thu, 15 Apr 2021 13:43:08 +0000 From: peng.fan@oss.nxp.com To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de, robh+dt@kernel.org, devicetree@vger.kernel.org Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan Subject: [PATCH V4 5/8] remoteproc: imx_rproc: initial support for mutilple start/stop method Date: Thu, 15 Apr 2021 21:27:38 +0800 Message-Id: <1618493261-32606-6-git-send-email-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618493261-32606-1-git-send-email-peng.fan@oss.nxp.com> References: <1618493261-32606-1-git-send-email-peng.fan@oss.nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK2PR02CA0132.apcprd02.prod.outlook.com (2603:1096:202:16::16) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by HK2PR02CA0132.apcprd02.prod.outlook.com (2603:1096:202:16::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4042.16 via Frontend Transport; Thu, 15 Apr 2021 13:43:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1b5b5b53-7d28-4658-0814-08d900146757 X-MS-TrafficTypeDiagnostic: DB7PR04MB5241: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:341; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gg6BcXCxmFThwXJdj7uufLfchYHm6rglahHY+vcEnaGpfu72f5F6PU8OGwiXq4fQY3tAypOxkIWl6ARW11hd0lexYBZ7E/HfbN80PoSUKl28vYNwT82lY7Y6SHfUQjRcC+qzoDY2L90t16/eh+fIwA6LpqT6JnQ0NKNcm/C/uQRo3m3tCBMFgp0YCKpwhYZn3VDbVU3nRgO/sFO0QrNx9ny84pjErZcACJepNSkU5RT6JakltD3TqQrDYzn+2Tjd2WjLLSx/fGZpzpBczKkkgc0coW/x3BcxuYECvHcPHbfXIWJDHOSk4djVCIVOEvLcjZa7IaS04yP+0K23e9YTCm00hePo+f08kuYvwM5nyzsbPyXfyZMaPVsH3fuhVEANHV+OVytyoQi+yfk6ejAayNa61O0Cc0LEKpBd5Zp9Y14sNWqEsF2GBXW1E09jmmEmW1+zOK5FnuhA+GLEaHRoOD1aCpPRCy42xRZQJF3x2dM7AdtItuRM4Ofp77INE+i/FxVn2Xq/83kUTyfQNTeR32fRZW03tLgoglNYVHqlT/wJKWaC0D3BJU7JIdJ5b4T5mKWGqspx5mN91x/V2IEsW4KHfXpx8vLaLG+/zayO/wdHV2gMYR7e0XSkxIb48pDPBGW22h23blHGdAtK64tvdwIH7+ODn+HNb/6+1ESqvbT4lS1Rln6deXFRzL5yeK04 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0402MB2760.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(39860400002)(366004)(136003)(376002)(396003)(6666004)(6506007)(26005)(956004)(186003)(8676002)(16526019)(6512007)(7416002)(2616005)(4326008)(38100700002)(38350700002)(316002)(69590400012)(86362001)(478600001)(5660300002)(8936002)(52116002)(66946007)(2906002)(66476007)(9686003)(83380400001)(66556008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EBohXX3DstWIcqqHK4O8WyDSPXPR705xFuqkS6EsigEdQztadhUF69syf8yUzGZKO6W5u165/AUh0vjlc1YiPfo0CoARqazbyXD2Y68BW5sSGIn4EI2FtAqePaWczJe2cZoCpcBUtiMTH6agoJlNzx9AA5nxb6d0wQ8mqIZuiz/izBYPucpljLKkBpFvuOii6IKZqaaMjwE8oHuHgs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3yivKWk/eYHxT1F4Soxad0ztZ7dQkcrbbPs2wkmhhhLBQ X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b5b5b53-7d28-4658-0814-08d900146757 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2021 13:43:08.4168 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: p9a7RefcUq/pMox3u483bTnTZN+XLgDfw1/mEbp0sFHbRkcILUcKebPCVpFw8204S/B5T1GFc/elpMayAI6vhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5241 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210415_064312_339479_3D01D19C X-CRM114-Status: GOOD ( 17.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan Add three methods IMX_RPROC_NONE(no need start/stop), IMX_RPROC_MMIO (start/stop through mmio) and IMX_RPROC_SMC(start/stop through ARM SMCCC). The current SoCs supported are all using IMX_RPROC_MMIO, add a restrict in imx_rproc_detect_mode that only SoCs using IMX_RPROC_MMIO needs syscon regmap to access registers. Signed-off-by: Peng Fan --- drivers/remoteproc/imx_rproc.c | 51 +++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 06dac92..2b633fd 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -74,6 +74,15 @@ struct imx_rproc_att { int flags; }; +/* Remote core start/stop method */ +enum imx_rproc_method { + IMX_RPROC_NONE, + /* Through syscon regmap */ + IMX_RPROC_MMIO, + /* Through ARM SMCCC */ + IMX_RPROC_SMC, +}; + struct imx_rproc_dcfg { u32 src_reg; u32 src_mask; @@ -81,6 +90,7 @@ struct imx_rproc_dcfg { u32 src_stop; const struct imx_rproc_att *att; size_t att_size; + enum imx_rproc_method method; }; struct imx_rproc { @@ -183,6 +193,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = { .src_stop = IMX7D_M4_STOP, .att = imx_rproc_att_imx8mq, .att_size = ARRAY_SIZE(imx_rproc_att_imx8mq), + .method = IMX_RPROC_MMIO, }; static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = { @@ -192,6 +203,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = { .src_stop = IMX7D_M4_STOP, .att = imx_rproc_att_imx7d, .att_size = ARRAY_SIZE(imx_rproc_att_imx7d), + .method = IMX_RPROC_MMIO, }; static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = { @@ -201,6 +213,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = { .src_stop = IMX6SX_M4_STOP, .att = imx_rproc_att_imx6sx, .att_size = ARRAY_SIZE(imx_rproc_att_imx6sx), + .method = IMX_RPROC_MMIO, }; static int imx_rproc_start(struct rproc *rproc) @@ -560,19 +573,35 @@ static void imx_rproc_free_mbox(struct rproc *rproc) static int imx_rproc_detect_mode(struct imx_rproc *priv) { + struct regmap_config config = { .name = "imx-rproc" }; const struct imx_rproc_dcfg *dcfg = priv->dcfg; struct device *dev = priv->dev; + struct regmap *regmap; int ret; u32 val; - ret = regmap_read(priv->regmap, dcfg->src_reg, &val); - if (ret) { - dev_err(dev, "Failed to read src\n"); - return ret; + if (dcfg->method != IMX_RPROC_MMIO) + return 0; + + regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon"); + if (IS_ERR(regmap)) { + dev_err(dev, "failed to find syscon\n"); + return PTR_ERR(regmap); } - if (!(val & dcfg->src_stop)) - priv->rproc->state = RPROC_DETACHED; + priv->regmap = regmap; + regmap_attach_dev(dev, regmap, &config); + + if (regmap) { + ret = regmap_read(regmap, dcfg->src_reg, &val); + if (ret) { + dev_err(dev, "Failed to read src\n"); + return ret; + } + + if (!(val & dcfg->src_stop)) + priv->rproc->state = RPROC_DETACHED; + } return 0; } @@ -583,18 +612,9 @@ static int imx_rproc_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; struct imx_rproc *priv; struct rproc *rproc; - struct regmap_config config = { .name = "imx-rproc" }; const struct imx_rproc_dcfg *dcfg; - struct regmap *regmap; int ret; - regmap = syscon_regmap_lookup_by_phandle(np, "syscon"); - if (IS_ERR(regmap)) { - dev_err(dev, "failed to find syscon\n"); - return PTR_ERR(regmap); - } - regmap_attach_dev(dev, regmap, &config); - /* set some other name then imx */ rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops, NULL, sizeof(*priv)); @@ -609,7 +629,6 @@ static int imx_rproc_probe(struct platform_device *pdev) priv = rproc->priv; priv->rproc = rproc; - priv->regmap = regmap; priv->dcfg = dcfg; priv->dev = dev;