Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1293899imu; Thu, 13 Dec 2018 12:34:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/VUYnd1EXUI66YSpy4gGFvczNcJGsst9Dn2QYNDEZmoBYsYj4I7gStdCNUrKIY1u6FctLjs X-Received: by 2002:a17:902:30a3:: with SMTP id v32mr306015plb.26.1544733251971; Thu, 13 Dec 2018 12:34:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544733251; cv=none; d=google.com; s=arc-20160816; b=vMsM71/2/bYdoLgdTEYpyLJIy3HKuqft1RgmGy5jFpoo7dSazAnuY5Lvjh3DlO9dB0 3e9nR4iLDhw0qkt23+sa6iZrIrlTHtaSTymokev8vd11sLXidvhYVCUBfDyEQ9bWCvry e3+iDELk+RRp4M4a5BXXipZ8aJlw1wmkbeFRHXd5rbICShlViqFXMtSvY3zufoMgokTj Yw4Lk8ZTeSEdZJjc5t3vxut8wufUf+EtP7IL5t1Ve2Snlh35FUTxOYpE2JY/rUzlGE/u TXI2jrWoUtvD7bE1w2cPcD514X3IssGJ7lHT76TmvC7gWYj3wNmDwpvZgD1IrrMVoP71 4gdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=lzblr0/WkGUIBRTiwNtnpUbyrTo2lFL6/wQqf0DsmPk=; b=ED929Jy1fPxqXvBg7LaJisPLh+m5+Rw6NDNpXPd+jTItWi8J+LW64xLEy597tJ4SF9 bGLmGkE4xmgpW3By7Y/DiEpk6G5eFr1GIQEuJX1zcj1LgnNhKpgeZOmBKqXe+0K+kXJk pAHzHtnMORb7DegegaAz5SEKnC+5SweHyAtJWSvJHQXRwy2QNkMJC/CDgHD5OQVbB1lP 5k6ks8LV5umkQggqNlKjA5MFlYeeog+ru0NNUqXI0jke8Mb9oFJ0LR61yOX/GSUqleOo YYzDytWUblfli3MErvWT17EkaM7eOlFOWUEqWRHI+qQ6336dQSnSkj3arWykNCE3Cpia BMHA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si2128326pgv.123.2018.12.13.12.33.56; Thu, 13 Dec 2018 12:34:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727809AbeLMUc7 (ORCPT + 99 others); Thu, 13 Dec 2018 15:32:59 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:58281 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726401AbeLMUc6 (ORCPT ); Thu, 13 Dec 2018 15:32:58 -0500 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gXXf4-0002sW-Mz; Thu, 13 Dec 2018 21:32:46 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1gXXf1-0000z0-Sz; Thu, 13 Dec 2018 21:32:43 +0100 Date: Thu, 13 Dec 2018 21:32:43 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Paul Cercueil Cc: Thierry Reding , Rob Herring , Mark Rutland , Daniel Lezcano , Thomas Gleixner , Ralf Baechle , Paul Burton , James Hogan , Jonathan Corbet , Mathieu Malaterre , Ezequiel Garcia , PrasannaKumar Muralidharan , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-mips@vger.kernel.org, linux-doc@vger.kernel.org, linux-clk@vger.kernel.org, od@zcrc.me Subject: Re: [PATCH v8 12/26] pwm: jz4740: Allow selection of PWM channels 0 and 1 Message-ID: <20181213203243.ucjwqtkyp6aboxp4@pengutronix.de> References: <20181212220922.18759-1-paul@crapouillou.net> <20181212220922.18759-13-paul@crapouillou.net> <20181213091822.r5ilpsllfhzaiqw4@pengutronix.de> <1544709511.18952.0@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1544709511.18952.0@crapouillou.net> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 13, 2018 at 02:58:31PM +0100, Paul Cercueil wrote: > Hi, > > Le jeu. 13 d?c. 2018 ? 10:18, Uwe Kleine-K?nig > a ?crit : > > On Wed, Dec 12, 2018 at 11:09:07PM +0100, Paul Cercueil wrote: > > > The TCU channels 0 and 1 were previously reserved for system tasks, > > > and > > > thus unavailable for PWM. > > > > > > The driver will now only allow a PWM channel to be requested if > > > memory > > > resources corresponding to the register area of the channel were > > > supplied to the driver. This allows the TCU channels to be reserved > > > for > > > system tasks from within the devicetree. > > > > > > Signed-off-by: Paul Cercueil > > > > While there is someone caring for this driver I'd like to complete (a > > bit) my picture about the different capabilities and specialities of the > > supported PWMs. So I have a few questions: > > > > Is there a publicly available reference manual for this device? (If > > yes, adding a link to the driver would be great.) > > I have them here: https://zcrc.me/~paul/jz_docs/ Is this link good enough to add it to the driver? From a quick view I'd say this is another pwm implementation that gets active on pwm_disable(). Can you confirm this? > > jz4740_pwm_config looks as if the currently running period isn't > > completed before the new config is in effect. Is that correct? If yes, > > can this be fixed? A similar question for set_polarity: Does setting the > > JZ_TIMER_CTRL_PWM_ACTIVE_LOW bit in the control register take effect > > immediately or is this shadowed until the next period starts? > > I don't really know. We only use this driver for a rumble motor and > backlight. > Somebody would have to check with a logic analyzer. depending on the possible timings you might also be able to test this e.g. by setting: duty_cycle=1ms, period=5s and then duty_cycle=5s, period=5s . If the implementation is right your display should be dark for nearly 5 seconds. (And the second call to pwm_apply should also block until the display is on.) > > How does the device's output behave after the PWM is disabled? > > Does it complete the currently running period? How does the output > > behave then? (active/inactive/high/low/high-z?) > > There's a bit to toggle between "graceful" shutdown (bit clear) and "abrupt" > shutdown (bit set). TCSR bit 9. I think that graceful shutdown will complete > the running period, then keep the level active. Abrupt shutdown will keep > the > current level of the line. Can you confirm the things you think above? I'd like to have them eventually documented in the driver. > > > @@ -42,11 +68,7 @@ static int jz4740_pwm_request(struct pwm_chip > > > *chip, struct pwm_device *pwm) > > > char clk_name[16]; > > > int ret; > > > > > > - /* > > > - * Timers 0 and 1 are used for system tasks, so they are > > > unavailable > > > - * for use as PWMs. > > > - */ > > > - if (pwm->hwpwm < 2) > > > + if (!jz4740_pwm_can_use_chn(jz, pwm->hwpwm)) > > > return -EBUSY; > > > > Maybe EBUSY isn't the best choice here. If the needed register space for > > the requested pwm is not included in the memory resources provided to > > the device I'd prefer ENXIO or ENODEV. > > The idea was that if we don't get the register space we need, that means > the channel is used for something else, hence the EBUSY. Should I switch > it to ENXIO? I understand your reasoning, but I think it's misleading. If I get -EBUSY from a PWM driver I'd start searching for another user of said resource. With ENXIO or ENODEV it's more obvious that the driver isn't responsible for the resource that was requested. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |