From patchwork Thu Jul 11 21:08:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13731062 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012009.outbound.protection.outlook.com [52.101.66.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3CDF2836A for ; Thu, 11 Jul 2024 21:09:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.9 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720732176; cv=fail; b=TYuiqBIZTcQ0grh/42xxT1InJg6FY4PtG7iTu2zPx7NvZeV+4yIxPQD7jGR+/xPpUKyHltDMg/9dt2FgTa2kHuaAoRkrge9XApWlNMQgg8j8WH10Qjoi21Bcex5Bc/gb/6tImetQwZBkkOJHm49KeIpxSfjbq+ZQ8HryRTGmez8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720732176; c=relaxed/simple; bh=V4/JiROHKoMNNWNqxA5q5eMS/NJIj1fiSgLqTWOjo8Q=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Mjsk4Kh4v1oRY0l6peODswwsXOB/Q8+Iya5RHlKcgvyPkZUqFp8/ketrdfiGg441OW34InqJjRYz2zVKGlAAToCAqa67Fxlw3vWVgKlfZW7cIzkjjE0nvmdGH2AEOT/HTeuEY0j1AOjAH9Xq/B/n+FjC0f2P4YYUDxRP3kyiBGw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=Sme1C5gM; arc=fail smtp.client-ip=52.101.66.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Sme1C5gM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xVJavxpesJrK65FZXb8CkWYStoP4zVCwKnwnuaVqudF9tTIlIVANT9cgV4pXeKIgf1DsPh/m5omKFwH6f5LY/Hw53fX7DMjrw4TUMKo8FzNiEiHphlQm2vCGev3dfCR9hGQt+YPCOQWu20yOwo0wTUiLRWzdzn/wYCvDZKWjOgKu3CTOhRs9+003OYttNlMEmfXxJStafMU15XddICSkC19Lr+X1LJDPTzwFkQqeI8hEfFxwkm3DVeL5Dn4Ti1sRd4rKDlEduhbWkpoURxI6XjqKMer/aTnLMDrLjFA/sc1zgCDu8U5rGDGkIAPR0hKQx2D1cJ/fZvbsUBhePo+sHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m0Rf+LL0Y+RBJFlfxKtCUFtRbaOB6chigoL7jGW+ZHA=; b=qbrY8yxrYdRbZeRBaDuPkJINLgv54MWLE8bYocsWpms6V4gPrYiqTyk0cq5SSBqISs0y1nntL2NEL7UmB+SX2NBeVpan1eJ29LRDdcAerGbP3CNdLYeuYDBE8K6/3l4NxBGhVTXiEAXjLRcvt6swYLT+P8U/H0f+iyY1ScS8V/0M/BXrITLQGHRUD51sgu18aOtbIylLi5z3P6aaFzinyXwiD8F8d75TeNYEbtZdRMTQFUogsNpiDdnlSjwIBJmWyLrTHv8ctux0nLLTHahzLJlWSNVTzaQardsI2unObHeWHPCF9MieC1QodFY22ESyfvmtwgo1vjU0wACJsAdnyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m0Rf+LL0Y+RBJFlfxKtCUFtRbaOB6chigoL7jGW+ZHA=; b=Sme1C5gMxtnKhr4afQPD8HmJsMYYLJtzP62lIiH7053Zes6uu2D3CcbXXP6ZBznUmdGigzZjgKojSqJKPTO5c83ox/QFwstqRUbvV9np9F/MQSrnPHLs4XxdVC0m7ObjmxcfUv9wTNBOBhxeW0cdk6A/FfnyhRCehnD561vED0E= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DBBPR04MB7915.eurprd04.prod.outlook.com (2603:10a6:10:1ea::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22; Thu, 11 Jul 2024 21:09:30 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%2]) with mapi id 15.20.7741.033; Thu, 11 Jul 2024 21:09:30 +0000 From: Frank Li Date: Thu, 11 Jul 2024 17:08:57 -0400 Subject: [PATCH 2/3] pwm: imx27: Add 32k clock for pwm in i.MX8QXP MIPI subsystem Message-Id: <20240711-pwm-v1-2-4d5766f99b8b@nxp.com> References: <20240711-pwm-v1-0-4d5766f99b8b@nxp.com> In-Reply-To: <20240711-pwm-v1-0-4d5766f99b8b@nxp.com> To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Philipp Zabel Cc: linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Frank Li , Liu Ying X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1720732158; l=2498; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=T8sTYpfSEeBY2/knCkc7BNYVCAkGkq10MM1DGu+SsPQ=; b=laVB2GjlhPvVez/dCnHfiC5J2Pd70yiRPMxc+6YKUpfyC8+AuOQuegC1xFUA2oIZDMFgyEpGo M/Fx/nzRQg/DtvkeFX17voA+4+JvrNHYGOKavnjPAEMZGGWSglnUCJ8 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0234.namprd13.prod.outlook.com (2603:10b6:a03:2c1::29) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7915:EE_ X-MS-Office365-Filtering-Correlation-Id: d6248656-b608-4b00-cda4-08dca1edc111 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|366016|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?BnnV6k53znGJoiNM423NdXFK1g7Ydze?= =?utf-8?q?R12Wy0Sh4LKrnpoy3TM0UtT9d2nm1Ph81Rbaf/WBKEvC1gBNJvDNF9SqXGGMpPQ3X?= =?utf-8?q?yiBK7AE/1n4WQF0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xSaOES/0Zu67GcD8qnGHPAewpfbwHQ0CEm2dzg?= =?utf-8?q?/x8xabX2WFuJ96TPZa4yDQ6qIR1GAMWnrv28KiC6pNDFaFTJyzgjqeS4wSEaFezjm?= =?utf-8?q?y4YXlmvopV+suQTuBiqRtoDZ+Sji8L/B5oWPFwX/XqmoFbIfcgP++3AQA8JcA4SDO?= =?utf-8?q?hgiR13xje2T4nGH5O2CdDIpNn/jb2E+LMZbSCEpPsj8upc0kXuUEsChaVTYeB2WdO?= =?utf-8?q?vYB8VvBuTemCyS0/nnSY0swU5iNltpS9jt2qSf1m9Iv0pSfdXEJAtlgxHla5I7eIS?= =?utf-8?q?1z2HMvP+tdUkPAhPBV1eRRwEXQ7kqw9mn5AgesWLqXCC1Qx5Jl1q9FvA1/lHqsfBl?= =?utf-8?q?I1pbVpHRpI1dZCwQuCHGI30FJoHS4o7izg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(366016)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RXo78MiIXHvTphFlyVmF9moMzYuF?= =?utf-8?q?5sRPNDcBs8ZGDTdAsSB2m/6DH18mTcHBljET/C3OcoTGWT+nSMGcQyNJIyVW0U7jH?= =?utf-8?q?A4//AffX2PfcWSLOxzyHpn4z1Ns5pYzIl1vmM0AGem60N489r9pJc+285iKptzvXc?= =?utf-8?q?6Em5AbnMjMUbHBDWalvNE2x5oaE8FM6CJn6jwEtMpgwjRluJBnvfSroNHYJ8DV2DD?= =?utf-8?q?/f0bOwudGzjYhbGUiMoCwO/1tBnhJaO//DCDZv1kErBVm5EGMtLVMBCzfaIXdj9RF?= =?utf-8?q?2mS31BleSvL+959y5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0FzgpMsE0+dETAcHqrXnyKbOcnnJ0UXHqYvhZ0hBtj25tKblgV/mLgBjmb?= =?utf-8?q?YXU2ZJGZB6ApiTXCU9SsomueW5qf0ax5rn1utdPKHVr/0D+jthsw5JKdkx5H4kEFf?= =?utf-8?q?mDXk8IfRWdnV2vBFaMdoS2cRysX0MoKGyWzG65iY7aTRQKGx1I6bydpidFLEwmQri?= =?utf-8?q?neoGvNw5LaEF++6D1k1FcmUdHj8y4qq6XPy17XW+uB6CbJ4KosL7RMHVE1iH9lbHL?= =?utf-8?q?YRV545dUBFIdTG4lH9N4DILNFecPyUJns2pwmIiQqhtWjHFUh2cWNZxWveLXVuYj0?= =?utf-8?q?Z5oE/zZ4hO7RXGCZo9WXV6t2pPc7d2w7O+VUJjb72k8dWgNZn4DEmRHHbEbfNWHeU?= =?utf-8?q?BfyaeyRW8gPq?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6248656-b608-4b00-cda4-08dca1edc111 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 21:09:29.9523 (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: H9UB1DH+Gf1E2j91kgjYbn7bARr8SPzCTrIiqzGcC01EEahQ1BdrlVCaPf9mEPJ+56pDsApbP4w4Bj1Jyg05Ww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7915 From: Liu Ying PWM in i.MX8QXP MIPI subsystem needs the clock '32k'. Use it if the DTS provides that. Signed-off-by: Liu Ying Signed-off-by: Frank Li --- drivers/pwm/pwm-imx27.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c index 9e2bbf5b4a8ce..032bce7d1fdd3 100644 --- a/drivers/pwm/pwm-imx27.c +++ b/drivers/pwm/pwm-imx27.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -82,6 +83,7 @@ struct pwm_imx27_chip { struct clk *clk_ipg; struct clk *clk_per; + struct clk *clk_32k; void __iomem *mmio_base; /* @@ -101,23 +103,36 @@ static int pwm_imx27_clk_prepare_enable(struct pwm_imx27_chip *imx) { int ret; + if (imx->clk_32k) { + ret = clk_prepare_enable(imx->clk_32k); + if (ret) + goto err1; + } + ret = clk_prepare_enable(imx->clk_ipg); if (ret) - return ret; + goto err2; ret = clk_prepare_enable(imx->clk_per); - if (ret) { - clk_disable_unprepare(imx->clk_ipg); - return ret; - } + if (ret) + goto err3; return 0; +err3: + clk_disable_unprepare(imx->clk_ipg); +err2: + if (imx->clk_32k) + clk_disable_unprepare(imx->clk_32k); +err1: + return ret; } static void pwm_imx27_clk_disable_unprepare(struct pwm_imx27_chip *imx) { clk_disable_unprepare(imx->clk_per); clk_disable_unprepare(imx->clk_ipg); + if (imx->clk_32k) + clk_disable_unprepare(imx->clk_32k); } static int pwm_imx27_get_state(struct pwm_chip *chip, @@ -223,6 +238,7 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); unsigned long long c; unsigned long long clkrate; + int val; int ret; u32 cr; @@ -325,6 +341,13 @@ static int pwm_imx27_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_per), "failed to get peripheral clock\n"); + imx->clk_32k = devm_clk_get_optional(&pdev->dev, "32k"); + if (IS_ERR(imx->clk_32k)) { + dev_err(&pdev->dev, "getting 32k clock failed with %ld\n", + PTR_ERR(imx->clk_32k)); + return PTR_ERR(imx->clk_32k); + } + chip->ops = &pwm_imx27_ops; imx->mmio_base = devm_platform_ioremap_resource(pdev, 0);