Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36835579rwd; Tue, 11 Jul 2023 06:22:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlGXw+JWsiGSyAiH4hik4J6D4VxDDOP5UyyHO/wdYBofmft0ujjbKYfoW7ovjf1mWpZPCFph X-Received: by 2002:a17:90b:1d89:b0:263:50c2:e06b with SMTP id pf9-20020a17090b1d8900b0026350c2e06bmr11607928pjb.6.1689081774873; Tue, 11 Jul 2023 06:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689081774; cv=none; d=google.com; s=arc-20160816; b=clEbvR6JfayMQj5Dbn8HKeuyapJckTh4U1mdvv86AuIeJw9lPCbYGVDL/3TtaGcjS/ 2nn3WBqHpqU3m74yKiZV62VmyYhB/YPrjINo3Q+3TrQSAHi5g7HjYMR5Bg0jMVNfiUrP 47mlqB+kEaTrCidDojda+eSyNhXvlkN8nsVJaj9d3Fn9ilpqYHNzBM3BWpZc3vmGb3ZX 4SfbMcP6d0dpBTz4Q0UZlrz5PPb9bXY+9pg03NKwzd7bk9h5CminIEtRh5EG7OTkhiu9 s4V3vcr53gHQNnr4PqPN4oxKRx3RNU64vjuFcu5ZmBDXXrib/GrOVTf0rxc2NvTtUysu IzUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mzGPc3eaP7RI7nv++MCFW+ZV7pSmS8SPo25wJPiLyKk=; fh=FjmaPumrF5qbtpfaEdjzrrxoqL4BPFtr4kF1EzIWJWc=; b=IE7Q1MPONDD/8W5Gkz5sxUHwXEQ/DCwuY0VJZjkQjHx0zKGPK23Q1NgUQtKYkpPUTf 7m159ys9Q72KP6P09But0qcg2oIg2VS79KGWoNm15aIHrVtMrUvdCtthklfyFlLcLumN OIS7BllzQvtj9sjzGWuPfAKMYaqSwks2f8NmmOm+pvAiL2gNqC+1ThNujQt/8F4oMead GNalqkfQ+f8BK5pZAeyXqNKIu88ARZ3ZowDoyEI+ATyI1IAwZNtWhEv2JKu+WvcvvWxE mqLqVIcwvVbZYc2MdDD6Z+pTKPJxXp4pbEkQa/HQUXccQrIfDeuh+ppweeO2O6zr38ky 2M1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=C5RZhaPm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ch9-20020a17090af40900b0025e404ffb21si1568309pjb.18.2023.07.11.06.22.41; Tue, 11 Jul 2023 06:22:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=C5RZhaPm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232936AbjGKM7v (ORCPT + 99 others); Tue, 11 Jul 2023 08:59:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232300AbjGKM7i (ORCPT ); Tue, 11 Jul 2023 08:59:38 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5508D1716; Tue, 11 Jul 2023 05:59:05 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1b8b2b60731so25065785ad.2; Tue, 11 Jul 2023 05:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689080340; x=1691672340; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mzGPc3eaP7RI7nv++MCFW+ZV7pSmS8SPo25wJPiLyKk=; b=C5RZhaPm5WxP7MWWAmZd5ocJxCI5fxYTtk67GZ+hzITSsajMYvH6Oe43tuHF4ROQwZ KowIYeOtAf9AH6iKG76osIwI7XLsUmyO0Knm8Vu7iEEbgnt+k53WP/0Rvj6dP/hIRJqG j3mmU1awgsnkyUyTYhiwUvIHuP68MJb1alrsK+RQ/VlZB25tpCjlywy1nCixu3JCo+k/ 0SIdXLQOkjrdUEnOL3vwR7C64jn5uHa4YWePciDCzSRKarM6ea1FN289IX3KYGYa8osy RUSRrbHKyeF/VcrwquSWjKvyoIqwN0g48x+TEJjuZIj2gidrr4w829LWNAuou8okxaK+ VJHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689080340; x=1691672340; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mzGPc3eaP7RI7nv++MCFW+ZV7pSmS8SPo25wJPiLyKk=; b=IiVeNV6G6Vhg28Q40hxbXrRZEUTIttO78Jz8u+Y5oTu2EQ5QTEnoJNQmlr8Kk8/oZF G718t6nk1wm+O6NdONLngs+wOJhrNA5A/y228rtpOvHlvhq/l1xxiKKow0F1Q37/j13K lsJ+T56jbrTMSdd2rHFMynmakjchapXP0X0fqmqrc1XkrTd7GQF1U/7bnNqF7heSma6w XwqLAsGnNTfAleWdh67ztVWZMFJwmUPGP13E7ylVQYIICEIccruoyIpEv+JXf9iZI/cp 1kHl6KTYUim7btfwQyPh+hig9rVhzzA1yh2Gb62QztIhzue5s5Xo4sAuK3egvol5x/5X +xtw== X-Gm-Message-State: ABy/qLYD+bnWO8+71EoYgEk0/Br1w2D/dOOQa6E+JRbrkifoytgaXxjZ 72bLZvBt2jRV1peZtm5pb1o= X-Received: by 2002:a17:902:d486:b0:1b2:1b22:196 with SMTP id c6-20020a170902d48600b001b21b220196mr17158736plg.48.1689080340280; Tue, 11 Jul 2023 05:59:00 -0700 (PDT) Received: from localhost.localdomain ([113.103.7.132]) by smtp.gmail.com with ESMTPSA id az10-20020a170902a58a00b001b04c2023e3sm1836998plb.218.2023.07.11.05.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 05:58:59 -0700 (PDT) From: Guiting Shen To: claudiu.beznea@microchip.com Cc: thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Guiting Shen Subject: [PATCH v2] pwm: atmel: Enable clk when pwm already enabled in bootloader Date: Tue, 11 Jul 2023 20:58:50 +0800 Message-Id: <20230711125850.12626-1-aarongt.shen@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver would never call clk_enable() if the PWM channel was already enabled in bootloader which lead to dump the warning message "the PWM clock already disabled" when turning off the PWM channel. Add atmel_pwm_enable_clk_if_on() in probe function to enable clock if the PWM channel was already enabled in bootloader. Signed-off-by: Guiting Shen --- drivers/pwm/pwm-atmel.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index cdbc23649032..ced4ad3c68b2 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -464,6 +464,31 @@ static const struct of_device_id atmel_pwm_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, atmel_pwm_dt_ids); +static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm) +{ + unsigned int i; + int err; + u32 sr; + + sr = atmel_pwm_readl(atmel_pwm, PWM_SR); + if (!sr) + return 0; + + for (i = 0; i < atmel_pwm->chip.npwm; i++) { + if (!(sr & (1 << i))) + continue; + + err = clk_enable(atmel_pwm->clk); + if (err) { + dev_err(atmel_pwm->chip.dev, + "failed to enable clock: %pe\n", ERR_PTR(err)); + return err; + } + } + + return 0; +} + static int atmel_pwm_probe(struct platform_device *pdev) { struct atmel_pwm_chip *atmel_pwm; @@ -496,6 +521,10 @@ static int atmel_pwm_probe(struct platform_device *pdev) atmel_pwm->chip.ops = &atmel_pwm_ops; atmel_pwm->chip.npwm = 4; + ret = atmel_pwm_enable_clk_if_on(atmel_pwm); + if (ret < 0) + goto unprepare_clk; + ret = pwmchip_add(&atmel_pwm->chip); if (ret < 0) { dev_err(&pdev->dev, "failed to add PWM chip %d\n", ret); -- 2.25.1