Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1266920pxf; Fri, 19 Mar 2021 03:20:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlfmSxLaCU9PraT+Sd7fGR+sylgCErDpaUBP0IycjGN8EskGOCMPQZ5oX2H4WLl8NSgczi X-Received: by 2002:a17:906:4a05:: with SMTP id w5mr3387719eju.526.1616149215082; Fri, 19 Mar 2021 03:20:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1616149215; cv=pass; d=google.com; s=arc-20160816; b=gr2XTf+0qIxewv/qAtFcCxojXOhvf96tRwt5V5QHF1zroT4PTY+LztDDeDyfi3b3Yj pAldU8OEhAoeretYF78pwRIiJmUeqnwG6jP9NvaYQCZBDVh9A0IHSREVrgpTqp/Qow93 1TBDkWajN3ItRL281FEeeFOwGA0SGKtvzJPusJwY8gUIOjj0JkvE8et5tFgymlCNiDNQ 0g6tBeOg3Vh27JVP/rWPoJu91wXrNkm41c9dygwt4FY1fCJlCKjj1ALkDUw7Fy4EK+7M OiCa1oFm00643E486a5vIP1J+hKzSVoae2Hjkf+qO06sw09vZnHAonSvmYUkl+gcW44a MCVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kuCPuN4VdnfXo8onp4yP3064s5vYqLa1xQpgmgwj6Mo=; b=WAnuybD6PXlOl9XzqTg0bul3InB8sljqj60eeHOQb7OQNh4R0SoGgU87ToN03Ve58T I4JyjAr8RoZTxa7F26aPDRN8F3aZQTr71kbA9c7VjN8ts1E7PC6UJSKJfsOnNkTo+HpL Cmx+edS9fJef/nyKcOtQb4wPjlZo/fgkyprqjYs5sAdEfBZUw1c547bmM9H1LlN+tGD7 DaAQB7qaHmZtN0gPH5uQpOyfUmYVeX/5wpvRb19xHW5Hxn0YtxziZsMpVTQHb4m3DYfx v1cp6PyY9yFFEJ5Vpy86XzUXvj7jVP8RJSMlweAjy9reZDi/G+JJl0hfOzE5Szqxv4+o ibeg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=GByoDAkP; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si3544088edq.578.2021.03.19.03.19.52; Fri, 19 Mar 2021 03:20:15 -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=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=GByoDAkP; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbhCSKQ1 (ORCPT + 99 others); Fri, 19 Mar 2021 06:16:27 -0400 Received: from mail-eopbgr40059.outbound.protection.outlook.com ([40.107.4.59]:40287 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229720AbhCSKQX (ORCPT ); Fri, 19 Mar 2021 06:16:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lP3B2q9gaYAtIENYOp0u3/uBjIVXt3ZMEEbUGTwzMbbr082KE9oVfnSd/Ubjz5KPF5W44OY6Sdi47eMgmTpWRwo+lBHBAh6DDOGayjXN4fC7KOHdzS8et7jhOlAyhiLSWeAQAcYvWsqqaJexQvqzAw180K/nwblTQ23XW7X0dfKdyNp4+MNDQVkrarSvgIMr45LuY+CC5bXhKLseojacP5/xzr0DDc+oYvA9nsdkHxug9Vb/IaGGEfbcUHNNf11DPOj677PQwlpfojT6dzX8fws/7JzsdJafO3jLX9cHK3HTpwD/0f47NmY6nY/kIGNvDxMwexB8G0yNHyMr37GU2Q== 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=kuCPuN4VdnfXo8onp4yP3064s5vYqLa1xQpgmgwj6Mo=; b=nnSW2eHQaJOJw7WluPIVlugwqUovZY6vFUPX3LuOM1gk499mHR0I7WqPyK1xx6GnawN4xncROcru2iF8cIlQE5gNGfnUplFNleoyYF2jjCrswx7/Abw84tVMGExdntnf1seVR7x47vSd45RIjbr5zSFVWjT87ciRmG2boSkQfDrs3YaiYsF04iNFMoxHX6Z5tyaiBZVHr9EmR5Gvmlyo/eQfWpCBemaC4TgJ9xecV5BLf43GVd4x4rBGNaUMRiIF4k1dzQuAuS8vQxlGqqWbt0ex+UVSi5QO75znj4UdXO4b28xmYC8dYM8bLR5JX41ZCOSvyVWnxCWQ3LFM+/S42w== 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=kuCPuN4VdnfXo8onp4yP3064s5vYqLa1xQpgmgwj6Mo=; b=GByoDAkPwSppuiKd20yJhWJuaHbhOWqrJ23Eksi0GDSNguwItOaQu/PHoYl1RX2rSBQOaBlP67i4ZsBsxmHvmAtU+Dw2BKmO3ZR+Nm8/AK92WFmUVQwqbOF4n4ZkcAstbFmIozdiKdqWqrEZc1OwT16D0E4T5Z3iYtMPctEZDE0= 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 DB8PR04MB5803.eurprd04.prod.outlook.com (2603:10a6:10:a9::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Fri, 19 Mar 2021 10:16:18 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::d58c:d479:d094:43d0]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::d58c:d479:d094:43d0%9]) with mapi id 15.20.3933.032; Fri, 19 Mar 2021 10:16:18 +0000 From: "Peng Fan (OSS)" To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan Subject: [PATCH 2/2] remoteproc: imx_rproc: support remote cores booted before Linux Kernel Date: Fri, 19 Mar 2021 18:47:08 +0800 Message-Id: <20210319104708.7754-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210319104708.7754-1-peng.fan@oss.nxp.com> References: <20210319104708.7754-1-peng.fan@oss.nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: MAXPR0101CA0030.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:d::16) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by MAXPR0101CA0030.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18 via Frontend Transport; Fri, 19 Mar 2021 10:16:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a7231efc-144f-458b-ec24-08d8eac008d1 X-MS-TrafficTypeDiagnostic: DB8PR04MB5803: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1013; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z029hehTRuS5LOX9CeoDvQ8g2vBn0NZxL+e2MPveegxnR5ciT0rUiKZSb4rN9fo8TXsB9AzWrJvj8SqUdoE6TW0fp0Z/7QgAXfqDPjCDtT0eCIlb4Jspv8rQBC8Ey93ZIZX/JK83ZWJNTCb+Ir0uC6gJXYEqCEzm8qsZ9It4TqPxvzVdYJnM4x46eeXMW/23MO33m/jUbkhL57RQdl0hWTXcJtm/eYEPi/Un2vLxaCSGMSK7r6O9hD577hezSUIwWs1QL0OPYlDf5AeGMwMnzUD9x2GE2bXHyvn/LCFFr20hv9byZIarTD55PU0Pdx4EdVBRhvYEDLgG7V3dTGbmhZyYtJHNeNEpzfumnCdoJM4M4RK1+XVqT9afMNFOcAZvhGcXAquWL6EK6EmDsrPOLbt+Dpjm3yy0kltIbWi+nMIykgZYMtA/Wh1RVtvxxgIZst3vYDgOUrRHegL7lBlXyReaNG02qAgiRw34TRRzeQHt7RlTVBF422xKAYKK4GStmuEPSqgna2E38KFYMBkpZJ2MDGCbqHgs7AreOPdywybVqPt+nT3g61j3uJn15elAA7ECsTIZk8XSpsAS+/kQBOzGJl9oVeytt76kSTH1YQU4xD1RORQ8LftA9jNarNzJ0dzYRskCDK7wedTGz6CUT5KY8qtw9+zYAk6e50eaOBg= 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)(136003)(396003)(346002)(39860400002)(366004)(376002)(2616005)(8936002)(316002)(956004)(26005)(38100700001)(8676002)(6512007)(7416002)(66946007)(66556008)(5660300002)(52116002)(6666004)(6486002)(2906002)(6506007)(186003)(86362001)(66476007)(16526019)(83380400001)(478600001)(4326008)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?VDCLPtd34M9+oZ6QhKo3KzvKfkWrBGkY7vrUtgnZbAWZuScuxyMKuG2x0WbS?= =?us-ascii?Q?Di4p1k2aWhgATNRlcTscgfyljr7M0zmPKqmFP4TZR5iapxnjdqfIyfZHN1sN?= =?us-ascii?Q?ItPDoTO7ML/D9P6YvqSDR7028RoC6rOVPiV4W/eqAKuCC720eChuavky1+A9?= =?us-ascii?Q?CC2Vz973M46GyDW671BNcBxTSQl+eupVozBUBGT+9F6yzpIJ5cnMr13ZVxwM?= =?us-ascii?Q?UCdaayQEIshRQVXrVC/Rlo3hZo242KlXIOJAzVhSYVV7hl7Ro/Pf7LMIk4eP?= =?us-ascii?Q?acGwCUEb95oQ38hF/I7l3UwtGbmV0ASrPSxIsvGgY77KLXbsGlR0K7Waycle?= =?us-ascii?Q?RGUto7ribi0Bxr0NNsYDlVaiCa/bGp20mzUgest/PeT+2WZ2iYauxmGnh7ja?= =?us-ascii?Q?ntvjd3sH/ZP5oygNV2B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GSMV2TVy5?= =?us-ascii?Q?6dQhCfNc2MS7YljajoldZQ5K5yttWdS9LbMCbzYFQ6slMg=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7231efc-144f-458b-ec24-08d8eac008d1 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2021 10:16:17.9019 (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: TVvQDP6fWR65GyoiRuPnTMqRvXMlYuOvNzLaolBN4v24s9gUz/0E2N5zcqwckYLDjBORft3RXJfykcw7MmOITg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB5803 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Fan Support remote cores booted before Linux Kernel booting. Add rsc_table to hold the resource table published by remote cores Add attach hook Add imx_rproc_detect_mode to detect remote cores' working mode, and if remote cores are booted before booting Linux Kernel, parse the memory regions and initialize the table_ptr, table_sz, cached_table. Signed-off-by: Peng Fan --- drivers/remoteproc/imx_rproc.c | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 24275429a7cc..fdaaf7599cc8 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -74,6 +74,16 @@ struct imx_rproc_att { int flags; }; +enum imx_rproc_mode { + /* Linux load/kick remote core */ + IMX_RPROC_NORMAL, + /* + * remote core booted before kicking Linux, and remote core + * could be stopped & restarted by Linux + */ + IMX_RPROC_EARLY_BOOT, +}; + struct imx_rproc_dcfg { u32 src_reg; u32 src_mask; @@ -95,6 +105,8 @@ struct imx_rproc { struct mbox_chan *rx_ch; struct work_struct rproc_work; struct workqueue_struct *workqueue; + enum imx_rproc_mode mode; + void __iomem *rsc_table; }; static const struct imx_rproc_att imx_rproc_att_imx8mq[] = { @@ -229,6 +241,9 @@ static int imx_rproc_stop(struct rproc *rproc) if (ret) dev_err(dev, "Failed to stop M4!\n"); + if (priv->mode == IMX_RPROC_EARLY_BOOT) + priv->mode = IMX_RPROC_NORMAL; + return ret; } @@ -398,9 +413,15 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid) __func__, vqid, err); } +static int imx_rproc_attach(struct rproc *rproc) +{ + return 0; +} + static const struct rproc_ops imx_rproc_ops = { .start = imx_rproc_start, .stop = imx_rproc_stop, + .attach = imx_rproc_attach, .kick = imx_rproc_kick, .da_to_va = imx_rproc_da_to_va, .load = rproc_elf_load_segments, @@ -470,6 +491,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv, } priv->mem[b].sys_addr = res.start; priv->mem[b].size = resource_size(&res); + if (!strcmp(node->name, "rsc_table")) + priv->rsc_table = priv->mem[b].cpu_addr; b++; } @@ -536,6 +559,43 @@ static void imx_rproc_free_mbox(struct rproc *rproc) mbox_free_channel(priv->rx_ch); } +static int imx_rproc_detect_mode(struct imx_rproc *priv) +{ + const struct imx_rproc_dcfg *dcfg = priv->dcfg; + struct rproc *rproc = priv->rproc; + struct device *dev = priv->dev; + 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 (!(val & dcfg->src_stop)) + priv->mode = IMX_RPROC_EARLY_BOOT; + else + priv->mode = IMX_RPROC_NORMAL; + + if (priv->mode == IMX_RPROC_EARLY_BOOT) { + priv->rproc->state = RPROC_DETACHED; + + ret = imx_rproc_parse_memory_regions(priv->rproc); + if (ret) + return ret; + + if (!priv->rsc_table) + return 0; + + rproc->table_ptr = (struct resource_table *)priv->rsc_table; + rproc->table_sz = SZ_1K; + rproc->cached_table = NULL; + } + + return 0; +} + static int imx_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -590,6 +650,10 @@ static int imx_rproc_probe(struct platform_device *pdev) goto err_put_mbox; } + ret = imx_rproc_detect_mode(priv); + if (ret) + goto err_put_mbox; + priv->clk = devm_clk_get(dev, NULL); if (IS_ERR(priv->clk)) { dev_err(dev, "Failed to get clock\n"); -- 2.30.0