Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1074459imm; Tue, 5 Jun 2018 08:44:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJp7GiNMAiUcm1mPTiZskiTq4JZ4Qu3XjqRWhmxTKtt04acGQCb2hB3xH4n4WOBvCCW4QNX X-Received: by 2002:a17:902:8a94:: with SMTP id p20-v6mr26934025plo.258.1528213445179; Tue, 05 Jun 2018 08:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528213445; cv=none; d=google.com; s=arc-20160816; b=Be8MrxAyPvZDxZUZEH9sBLYXab5HYMah/1JELPXYuxDL5Jt48v4olJLblZ7uMEiHHx ln1R0ZbR/+vUNmoU03j8PK4buhqjcD6JTVJyHNviGYaT0ET448VR7xQKInJu1iqmzVMi yKfFmyiVyknbbkkLITBh49Il1SGh1FLGUEvSU1HMClsbWQN4E/QS+hMftGSWYeIevnSb BwusJC02ouO0evqyN/w4KXQNgpS66KVHygzVoxzbcvniEAK/GTqsYy4e04cx2gHDcPAW S0xiwSPuT96kIvyz6h7mtdZQjjNiTm0XMGSv/0GJ73pmRjjVuk97dnXdy70LEUaLVrF/ hbDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Z6OvfSLQYylOij3tn7Hl7MVYOhc/6ihAw9b/tAAhWog=; b=Ktyh82t1DQGK3aikDfH8HyDF6FmRmRcwb+0W5qvcgvyxpgl8MX0JaXeO6M7DnmOdDk HW1hFtOr6KQz1gXFFuU2iXJn+vBn/hgJ/5iibMy/6BtygEi8+UF8OF49k1wT7XcaSsf3 BQj51ib5JT1vXLVLQskdobREnbNR7xXnCjRfL+h0KhyC6xEclEEn+hfQfHpLrdo0y/qE MQCu+/cG7qgLie5aBIRCR7Zsb7O2EnwP8CyDK52vDTEfoX8hvC4bIRTqixzrocdYpn92 +NTZygww5NOtIiR+eN9G3oIEYQ1Tojr/Wt6nTksffCPL6K458+BF2eDQk+SGTNStp1Df 1m4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=cmslA3aF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si49038034pld.296.2018.06.05.08.43.50; Tue, 05 Jun 2018 08:44:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=cmslA3aF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752294AbeFEPm2 (ORCPT + 99 others); Tue, 5 Jun 2018 11:42:28 -0400 Received: from mail-he1eur01on0075.outbound.protection.outlook.com ([104.47.0.75]:46715 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751952AbeFEPm0 (ORCPT ); Tue, 5 Jun 2018 11:42:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z6OvfSLQYylOij3tn7Hl7MVYOhc/6ihAw9b/tAAhWog=; b=cmslA3aFuMdCSt95BaW54MDLAK2wB8wwN41RLlJcVRcB9zoc8mm1RnalyZDGe7ef/jxqBAVyBRbffBJ5z74/h6KysHaPoC4F9rhdkiz2BUiAgXC9nd6LHvv0M1jV/zbKFAieP6pijqIMoNPORdjsMOfdARrDu+ZCsWbKLAe0+wU= Received: from HE1PR04MB3289.eurprd04.prod.outlook.com (10.170.255.157) by HE1PR04MB2969.eurprd04.prod.outlook.com (10.170.255.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.15; Tue, 5 Jun 2018 15:42:21 +0000 Received: from HE1PR04MB3289.eurprd04.prod.outlook.com ([fe80::2c2b:a7a3:cca9:8147]) by HE1PR04MB3289.eurprd04.prod.outlook.com ([fe80::2c2b:a7a3:cca9:8147%3]) with mapi id 15.20.0820.015; Tue, 5 Jun 2018 15:42:21 +0000 From: Shenwei Wang To: "thierry.reding@gmail.com" CC: "linux-pwm@vger.kernel.org" , dl-linux-imx , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 1/1] pwm: fsl-ftm: Support the new version of FTM block on i.MX8x Thread-Topic: [PATCH 1/1] pwm: fsl-ftm: Support the new version of FTM block on i.MX8x Thread-Index: AQHT84pNMjdFhAI/vUSobBw7N99yZ6RIh/dggAlYL0A= Date: Tue, 5 Jun 2018 15:42:21 +0000 Message-ID: References: <20180524180848.61844-1-shenwei.wang@nxp.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shenwei.wang@nxp.com; x-originating-ip: [64.157.242.222] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;HE1PR04MB2969;7:lGvi5GU76CvjB0P7x3SsSvlU2iBnP5xwPq9DBnRz8ba6aaBP3mHcmxnFAmlqeE4b+als5dgtqlJx1VgmGybR76ZuuepEVqgf43RE3OZtz44x3J+W+Csqdm/kGfh/lszD+vuwBaVG9A1JnNINZkbqBx0bUuVvRP/KquICNZWK+uizlHKqvc79uYM+fKzY2r6au1ea/tVIdYKOHQ19lBYWFjX8dttE40Q9V3fzeeDwVZVJh+jbI+8BU2p+O8hUkNFk x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:HE1PR04MB2969; x-ms-traffictypediagnostic: HE1PR04MB2969: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197)(85827821059158); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231254)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:HE1PR04MB2969;BCL:0;PCL:0;RULEID:;SRVR:HE1PR04MB2969; x-forefront-prvs: 0694C54398 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(39860400002)(396003)(376002)(346002)(39380400002)(13464003)(199004)(189003)(59450400001)(3846002)(478600001)(97736004)(6506007)(53546011)(99286004)(476003)(186003)(6116002)(39060400002)(44832011)(81166006)(106356001)(81156014)(486006)(105586002)(3280700002)(2900100001)(102836004)(8936002)(6916009)(5250100002)(53936002)(26005)(7696005)(2501003)(1361003)(4326008)(6246003)(446003)(76176011)(2351001)(11346002)(3660700001)(33656002)(14454004)(5660300001)(9686003)(2906002)(5640700003)(316002)(74316002)(66066001)(54906003)(229853002)(6436002)(305945005)(25786009)(8676002)(55016002)(7736002)(86362001)(68736007);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR04MB2969;H:HE1PR04MB3289.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: FRFqL7D5SdG4W6MX4Mq3ym0VJ1PCvPj9YigVmv0jWtJnbkPmtFYLteFkbPo8PTzeF5SaXwsoJRc7Pm/c3vJgwDAwy+Qqs7LOUx+kr6bK1c8DZrmevNW45LV34XuV0czipEet2309BUEilQKU9CXblglxlNqvvHUMxcgO+QVhCFr02HdlHOD0p2o+02EzgY5v spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: bf6ce4d6-d5ac-4e62-26a4-08d5cafaed7a X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf6ce4d6-d5ac-4e62-26a4-08d5cafaed7a X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jun 2018 15:42:21.6695 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB2969 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Thierry, Can you please share your comments on the patch? Thanks, Shenwei -----Original Message----- From: Shenwei Wang=20 Sent: Wednesday, May 30, 2018 12:00 PM To: thierry.reding@gmail.com Cc: linux-pwm@vger.kernel.org; dl-linux-imx ; linux-kern= el@vger.kernel.org Subject: RE: [PATCH 1/1] pwm: fsl-ftm: Support the new version of FTM block= on i.MX8x Ping. Shenwei -----Original Message----- From: Shenwei Wang=20 Sent: Thursday, May 24, 2018 1:09 PM To: thierry.reding@gmail.com Cc: linux-pwm@vger.kernel.org; dl-linux-imx ; linux-kern= el@vger.kernel.org; Shenwei Wang Subject: [PATCH 1/1] pwm: fsl-ftm: Support the new version of FTM block on = i.MX8x On the new i.MX8x SoC family, the following changes were made on the FTM block: 1. Need to enable the IPG clock before accessing any FTM registers. Because= the IPG clock is not an option for FTM counter clock source, it can't be u= sed as the ftm_sys clock. 2. An additional PWM enable bit was added for each PWM channel in register = FTM_SC[16:23]. It supports 8 channels. Bit16 is for channel 0, and bit23 fo= r channel 7. As the IP version information can not be obtained in any of the FTM registe= rs, a property of "fsl,has-pwmen-bits" is added in the ftm pwm device node.= If it has the property, the driver set the PWM enable bit when a PWM chann= el is requested. Signed-off-by: Shenwei Wang --- drivers/pwm/pwm-fsl-ftm.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/pwm-fsl-ftm.c b/drivers/pwm/pwm-fsl-ftm.c index 55= 7b4ea..0426458f 100644 --- a/drivers/pwm/pwm-fsl-ftm.c +++ b/drivers/pwm/pwm-fsl-ftm.c @@ -86,7 +86,9 @@ struct fsl_pwm_chip { struct regmap *regmap; =20 int period_ns; + bool has_pwmen; =20 + struct clk *ipg_clk; struct clk *clk[FSL_PWM_CLK_MAX]; }; =20 @@ -97,16 +99,31 @@ static inline struct fsl_pwm_chip *to_fsl_chip(struct p= wm_chip *chip) =20 static int fsl_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) = { + int ret; struct fsl_pwm_chip *fpc =3D to_fsl_chip(chip); =20 - return clk_prepare_enable(fpc->clk[FSL_PWM_CLK_SYS]); + ret =3D clk_prepare_enable(fpc->ipg_clk); + + if ((!ret) && (fpc->has_pwmen)) { + mutex_lock(&fpc->lock); + regmap_update_bits(fpc->regmap, FTM_SC, + BIT(pwm->hwpwm + 16), BIT(pwm->hwpwm + 16)); + mutex_unlock(&fpc->lock); + } + + return ret; } =20 static void fsl_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) { struct fsl_pwm_chip *fpc =3D to_fsl_chip(chip); =20 - clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_SYS]); + if (fpc->has_pwmen) { + mutex_lock(&fpc->lock); + regmap_update_bits(fpc->regmap, FTM_SC, BIT(pwm->hwpwm + 16), 0); + mutex_unlock(&fpc->lock); + } + clk_disable_unprepare(fpc->ipg_clk); } =20 static int fsl_pwm_calculate_default_ps(struct fsl_pwm_chip *fpc, @@ -363,= 7 +380,7 @@ static int fsl_pwm_init(struct fsl_pwm_chip *fpc) { int ret; =20 - ret =3D clk_prepare_enable(fpc->clk[FSL_PWM_CLK_SYS]); + ret =3D clk_prepare_enable(fpc->ipg_clk); if (ret) return ret; =20 @@ -371,7 +388,7 @@ static int fsl_pwm_init(struct fsl_pwm_chip *fpc) regmap_write(fpc->regmap, FTM_OUTINIT, 0x00); regmap_write(fpc->regmap, FTM_OUTMASK, 0xFF); =20 - clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_SYS]); + clk_disable_unprepare(fpc->ipg_clk); =20 return 0; } @@ -428,6 +445,10 @@ static int fsl_pwm_probe(struct platform_device *pdev) return PTR_ERR(fpc->clk[FSL_PWM_CLK_SYS]); } =20 + fpc->ipg_clk =3D devm_clk_get(&pdev->dev, "ipg"); + if (IS_ERR(fpc->ipg_clk)) + fpc->ipg_clk =3D fpc->clk[FSL_PWM_CLK_SYS]; + fpc->clk[FSL_PWM_CLK_FIX] =3D devm_clk_get(fpc->chip.dev, "ftm_fix"); if (IS_ERR(fpc->clk[FSL_PWM_CLK_FIX])) return PTR_ERR(fpc->clk[FSL_PWM_CLK_FIX]); @@ -446,6 +467,8 @@ static int fsl_pwm_probe(struct platform_device *pdev) fpc->chip.of_pwm_n_cells =3D 3; fpc->chip.base =3D -1; fpc->chip.npwm =3D 8; + fpc->has_pwmen =3D of_property_read_bool(pdev->dev.of_node, + "fsl,ftm-has-pwmen-bits"); =20 ret =3D pwmchip_add(&fpc->chip); if (ret < 0) { @@ -480,7 +503,7 @@ static int fsl_pwm_suspend(struct device *dev) if (!test_bit(PWMF_REQUESTED, &pwm->flags)) continue; =20 - clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_SYS]); + clk_disable_unprepare(fpc->ipg_clk); =20 if (!pwm_is_enabled(pwm)) continue; @@ -503,7 +526,7 @@ static int fsl_pwm_resume(struct device *dev) if (!test_bit(PWMF_REQUESTED, &pwm->flags)) continue; =20 - clk_prepare_enable(fpc->clk[FSL_PWM_CLK_SYS]); + clk_prepare_enable(fpc->ipg_clk); =20 if (!pwm_is_enabled(pwm)) continue; -- 2.9.2