Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp336602imu; Thu, 8 Nov 2018 02:48:08 -0800 (PST) X-Google-Smtp-Source: AJdET5eVv8+i5ilVba51iT2Q/F8E8cZqOLzyRiCSJzTgYtU9S9DA//FKkHDNcj9Q5RAvm2t0a3cm X-Received: by 2002:a17:902:1123:: with SMTP id d32-v6mr373694pla.62.1541674088534; Thu, 08 Nov 2018 02:48:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541674088; cv=none; d=google.com; s=arc-20160816; b=ryHP15PcIE8tToKSm6WGEDyBteY2UvG8WND8WFaZJksQdlJUJkl2+G6j0g0fgfuxqD Mi/mG/DAVnZxk1emEEHCYfEv51DXoEHTt4shDZxyqDo0G5iWOqHWMFuxq1IRvt3R+5B6 5SRzTCZn7nbtvcRg+aSz0FVta5vyIF5yDiGdyhW7UJy2/OLxOvwVz+/dyn21iEpUgdxA wbThQJyTC01/0yslf+qy8y3F3ZLm/IXwuDwNO/HhDkoTm/rUgZ1wnWZfOSLwUaz3tQ7h sxkH+krmgDlN57bU0k/IugTFUCTpe8r0Twu54wWPnFWek3IIhIXcZU4K0zEw/Sq8S9n4 VXiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PzVp2vehovBKgbVNnHHKfUEFWz4EG4q13FH78e+GO6o=; b=Zgjld/4FpzZwrXnRHyXg1/QfGHLU+eSWUQbZilGV4z0ce/nCdKRwzd7z6Js6Z34fW9 gUP9Jw1rzJReF5mLWF4S2B/DVo0dKt3LrrWMPazGaw9DetQU3ysfVSC3X0LpvluLCfxL rYGIixiYySuaEMran53mReHpryU95hs+CMfMWe6qPcOFM9gMiTdJrZBc8fMB1YOWUU/R CeZzHskfYMWzCx023KpXiSg/D8Z8e8/KMTZOVU7N1OVixEb1HIIvNF2jQCvQTMO+4SyT 2m4WgvJJvowvJiVyr+0OGtnP0hH/CR58syN36rQ2d/ziF0au5GykHATVoxCUox2/ouWZ bVDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=euL+hg3r; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g137-v6si4308114pfb.34.2018.11.08.02.47.52; Thu, 08 Nov 2018 02:48:08 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=euL+hg3r; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726944AbeKHUWX (ORCPT + 99 others); Thu, 8 Nov 2018 15:22:23 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:47017 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbeKHUWW (ORCPT ); Thu, 8 Nov 2018 15:22:22 -0500 Received: by mail-yw1-f67.google.com with SMTP id v5-v6so3354419ywa.13; Thu, 08 Nov 2018 02:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=PzVp2vehovBKgbVNnHHKfUEFWz4EG4q13FH78e+GO6o=; b=euL+hg3riR0hcLsDR+TA0Nw19YLiLP37xHRb4ugzqC+OY64XYGWIdGttm+BiwP+EXM lxqcGPb147nieelu0mfR23DX1LAWPvZxh2GIaXphnx4S+7u6N/DSA2F1ymrDAZIMHZ9m Ec0F+foMCZqP6htaf+FjGQFG4RM/1eyRYSvT1ctppmnq8ic7GqhbK35WHIrRm9wNiSs4 tln1JInogVIwqmxfV0eKtroMPVypnMfUb+2HTgYXjhJsA3LuRe0huYXvwTuD9DrXHBIK GpTpNk3twT27nkF+UQJXq1ygiOlyABoZ1oX3ZztTwYkOGoUa8qKmYF8c+hwVHy9NPCMC ly/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=PzVp2vehovBKgbVNnHHKfUEFWz4EG4q13FH78e+GO6o=; b=gcu2BLlT8XrlDWGYIWd2i+DTOfSqBODkxGyoyULdt9+l2ovzobi/WLtgwLQEZacF0u cA0SD9DLMndnylCHvXJ96U0fYe/AefYh1ZecGIvAt8GX4L9qguXGp0k7UrN8hJ56SrKI VXKg/82/jEBUOYTZ8s1sN2/g3WTntl5n5QMFLpYTwpo7qbQlHAW3icwqub6fJLzKCfPx u/cbu788Rjq73Hi9emaJR3IE/+Q8knl8GyjZLuC/66BH4sJbOCtsTQeCRSicZeNCuyks /gbKW2VC5WXxq9jxfB+dWLMe5yJwyS3e/2GtbB4PMopWALyNjoKYFZWdwhOQr4ShPvbh nKVg== X-Gm-Message-State: AGRZ1gL/hlBA+ElW9E0nKE2rqucvk008Eoiwm4SNyJelPuGRUAbjacAm E40wRckWxjndXsfgZ/QzSNrH+Nkn6tdLN9NuCQk= X-Received: by 2002:a81:5044:: with SMTP id e65-v6mr3663155ywb.392.1541674049220; Thu, 08 Nov 2018 02:47:29 -0800 (PST) MIME-Version: 1.0 References: <20181107093613.26734-1-peron.clem@gmail.com> <20181107093613.26734-2-peron.clem@gmail.com> <20181107162908.tejzekhc35pbknut@pengutronix.de> In-Reply-To: <20181107162908.tejzekhc35pbknut@pengutronix.de> From: =?UTF-8?B?Q2zDqW1lbnQgUMOpcm9u?= Date: Thu, 8 Nov 2018 11:47:17 +0100 Message-ID: Subject: Re: [PATCH 2/2] pwm: bcm-kona: apply pwm settings on enable To: u.kleine-koenig@pengutronix.de Cc: Thierry Reding , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Suji Velupillai Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Uwe, On Wed, 7 Nov 2018 at 17:29, Uwe Kleine-K=C3=B6nig wrote: > > Hello, > > On Wed, Nov 07, 2018 at 10:36:13AM +0100, Cl=C3=A9ment P=C3=A9ron wrote: > > From: Suji Velupillai > > > > When pwm_bl framework calls enable, a call to pwm_is_enabled(pwm) still > > return false, this prevents the backlight being turn on at boot time. > > > > Signed-off-by: Suji Velupillai > > Signed-off-by: Cl=C3=A9ment P=C3=A9ron > > --- > > drivers/pwm/pwm-bcm-kona.c | 16 +++++++++++----- > > 1 file changed, 11 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/pwm/pwm-bcm-kona.c b/drivers/pwm/pwm-bcm-kona.c > > index 09a95aeb3a70..d991d53c4b38 100644 > > --- a/drivers/pwm/pwm-bcm-kona.c > > +++ b/drivers/pwm/pwm-bcm-kona.c > > @@ -108,8 +108,8 @@ static void kona_pwmc_apply_settings(struct kona_pw= mc *kp, unsigned int chan) > > ndelay(400); > > } > > > > -static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *= pwm, > > - int duty_ns, int period_ns) > > +static int __pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm= , > > + int duty_ns, int period_ns, bool pwmc_enabled) > > { > > struct kona_pwmc *kp =3D to_kona_pwmc(chip); > > u64 val, div, rate; > > @@ -155,7 +155,7 @@ static int kona_pwmc_config(struct pwm_chip *chip, = struct pwm_device *pwm, > > * always calculated above to ensure the new values are > > * validated immediately instead of on enable. > > */ > > - if (pwm_is_enabled(pwm)) { > > + if (pwm_is_enabled(pwm) || pwmc_enabled) { > > Having pwm-API-calls in hw-drivers is ugly. Apart from not giving the > intended return code this function should IMHO be reserved to pwm > consumers. The underlaying problem is that pwm-bl does: > > pwm_config(pwm, duty_cycle, period); > pwm_enable(pwm); > > and expects that the duty_cycle and period is used then. Doesn't > everything works just fine if the if-block is always executed? Tested and works fine for me. But I only have a Cygnus proc. Maybe there is some issue with Kona as explained by the comment (even if I don't understand it well). * Don't apply settings if disabled. The period and duty cycle are * always calculated above to ensure the new values are * validated immediately instead of on enable. Regards, Clement > > The better fix here would be to convert the driver to the atomic API > (i.e. implement .apply instead of .config, .set_polarity, .enable and > .disable). > > Alternatively in .enable ensure that the hardware is programmed with the > parameters from pwm->state. (But converting to the atomic API is the > better approach.) > > Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-K=C3=B6nig = | > Industrial Linux Solutions | http://www.pengutronix.de/ = |