Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp874382imu; Thu, 13 Dec 2018 06:01:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/VpG7LzS7Pz/xW8t6EtF0P8CeFJAeHKbCpGdAoTSbX0Kv8uri6LfuDqi38HHTS+lKDAZ5E/ X-Received: by 2002:a62:8dd9:: with SMTP id p86mr23866515pfk.143.1544709670531; Thu, 13 Dec 2018 06:01:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544709670; cv=none; d=google.com; s=arc-20160816; b=cgYcDDBsit5RRWDfbKMuj+cxP6GiZ85TYWoNJeislpU06oNRZLQ+o9hAmQ+YlbdBD1 U8ku4sOKCop6aLXm6qC8/dBQPOK+h14V0UNX9jaGA2mth3Bg0iPQ12AYGZnsGoRwWIcV 9YPym1dH/6eaD3dqPpHAbo///8pS1eZZwf4OOMfyy0U6QiPM4iEysErr7p6JUl+jAt9B WBgM9SOz9O9LMNFsktqg9CfbmYdWpfvO08+5FPSnQ8sy/cL6QPLnQZO++l8adRNqj+wv zQHDyFmpTwVWb7DCQn58l92KSIW2qcEH98VmFOF/DChQAZI5ZeHX+/onUw66Z4s9JwuT kgPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:cc:to:subject:from :date; bh=26MoHcxWFkAmikKZd//2oI7Jptf7WKxs2OlZ7GVv+Io=; b=0N1jClqHOnMw+IgEHsFvv9SKH9IPqnufWODA8bpbBAn94hb4MUnyDkF1He6a2mG80K /NSyyxjWUL41BqFQ5yDzdFzsYOTVEpGgc9kx7rpS1t1w5TG2eAM0fPKToTrFImWMrTHm KCt0a/QRag8TjoXPY25I0REnJ+7bVVpcmd454MfMrsYRiMxJgoRLsHTsDZmv1ekCHfxR kUwOgsDvuyf4y/6S2qwQ5aO87f8ebcAJl/4yjo+PRACHF01JTfokaSxqPGiLWr1xj2Ws HEidjurVyvF5Vy0RtinqODLVovUS2TyVkP1TUQTcO5uMHNWOfBWdw+gvQFzX1t2Np3aD Swsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=JBbFAERd; 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=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g33si1686883pgm.426.2018.12.13.06.00.52; Thu, 13 Dec 2018 06:01:10 -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=@crapouillou.net header.s=mail header.b=JBbFAERd; 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=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729588AbeLMN6m (ORCPT + 99 others); Thu, 13 Dec 2018 08:58:42 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:57384 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729516AbeLMN6m (ORCPT ); Thu, 13 Dec 2018 08:58:42 -0500 Date: Thu, 13 Dec 2018 14:58:31 +0100 From: Paul Cercueil Subject: Re: [PATCH v8 12/26] pwm: jz4740: Allow selection of PWM channels 0 and 1 To: Uwe =?iso-8859-1?q?Kleine-K=F6nig?= 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 Message-Id: <1544709511.18952.0@crapouillou.net> In-Reply-To: <20181213091822.r5ilpsllfhzaiqw4@pengutronix.de> References: <20181212220922.18759-1-paul@crapouillou.net> <20181212220922.18759-13-paul@crapouillou.net> <20181213091822.r5ilpsllfhzaiqw4@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1544709518; bh=26MoHcxWFkAmikKZd//2oI7Jptf7WKxs2OlZ7GVv+Io=; h=Date:From:Subject:To:Cc:Message-Id:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; b=JBbFAERd2CX+tEa7VVKLv26zALIkQ8qAjxxGiPYlZhXx/jnbcaM36KjqZhphUYdV/xmAz+JRgiIQph+EcRo6J8rRSWlUOzhYwDX4RTT7kt9M/o8qCe5+4oPx2bqMUKpgtYhB77ezxHcy8LJsa2wBl+5IXs1HCi0HE8Vt3ttVhsI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Le jeu. 13 d=E9c. 2018 =E0 10:18, Uwe Kleine-K=F6nig=20 a =E9crit : > 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,=20 >> and >> thus unavailable for PWM. >>=20 >> The driver will now only allow a PWM channel to be requested if=20 >> memory >> resources corresponding to the register area of the channel were >> supplied to the driver. This allows the TCU channels to be reserved=20 >> for >> system tasks from within the devicetree. >>=20 >> Signed-off-by: Paul Cercueil >=20 > While there is someone caring for this driver I'd like to complete (a > bit) my picture about the different capabilities and specialities of=20 > the > supported PWMs. So I have a few questions: >=20 > 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/ > 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=20 > 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=20 backlight. Somebody would have to check with a logic analyzer. > 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=20 "abrupt" shutdown (bit set). TCSR bit 9. I think that graceful shutdown will=20 complete the running period, then keep the level active. Abrupt shutdown will=20 keep the current level of the line. >> @@ -42,11 +68,7 @@ static int jz4740_pwm_request(struct pwm_chip=20 >> *chip, struct pwm_device *pwm) >> char clk_name[16]; >> int ret; >>=20 >> - /* >> - * Timers 0 and 1 are used for system tasks, so they are=20 >> unavailable >> - * for use as PWMs. >> - */ >> - if (pwm->hwpwm < 2) >> + if (!jz4740_pwm_can_use_chn(jz, pwm->hwpwm)) >> return -EBUSY; >=20 > Maybe EBUSY isn't the best choice here. If the needed register space=20 > 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? >> snprintf(clk_name, sizeof(clk_name), "timer%u", pwm->hwpwm); >> @@ -208,6 +230,12 @@ static int jz4740_pwm_probe(struct=20 >> platform_device *pdev) >> return -EINVAL; >> } >>=20 >> + jz4740->parent_res =3D platform_get_resource( >> + to_platform_device(dev->parent), >> + IORESOURCE_MEM, 0); >> + if (!jz4740->parent_res) >> + return -EINVAL; >> + >> jz4740->chip.dev =3D dev; >> jz4740->chip.ops =3D &jz4740_pwm_ops; >> jz4740->chip.npwm =3D NUM_PWM; >=20 > Thanks > Uwe >=20 > -- > Pengutronix e.K. | Uwe Kleine-K=F6nig =20 > | > Industrial Linux Solutions |=20 > http://www.pengutronix.de/ | =