Received: by 10.223.185.116 with SMTP id b49csp8433831wrg; Fri, 2 Mar 2018 01:30:45 -0800 (PST) X-Google-Smtp-Source: AG47ELvFqxWcIAcWnRpCi+r/t0YMJoO/g+GGz2mR7uU+6g485T04zeWCppq3yf0ApWipHTMOEh8B X-Received: by 2002:a17:902:f44:: with SMTP id 62-v6mr4623284ply.27.1519983045705; Fri, 02 Mar 2018 01:30:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519983045; cv=none; d=google.com; s=arc-20160816; b=oSk4rt7ZGgiR5TwxecQCXEfn28p9Fh1vpwxvnllFGsG9v3xeeBG2STDaSpbJ0j9re6 p8lJgObLV/us0BQsp5U+8rI5s5hqp500d2XXOMGCzi9K6MBQ27I934V1BjKvOOgre0ji Y6UeNAF19FtzyPciVDqMUt8hECudpuiq3sSB/zSmqvYQP01irn5wzAaD/cCD26VW0TbL oWNp9Uyf3eu0Y1OpfWEjB5ZR/H4A7Hl7YcJmmSass0a3rnpgRlrUuTE5lUmZ/2nbNJ/l 4wAZ0Dul13YZyK1dadyKPS9eyujnSgSBtg3w2dsWU+vqjHbnHNLY2TM6MV2f+Ne0JBT8 q2lA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=clJyX9rVORgqy78sU2aD84fAsXGAPxT+K39odoHwGCo=; b=Hrpl8r2gpEmglv0sK7mecvXHBJz4xG4z+PDFnM1FeT/QUrNfEYnucRmWmOczuHiV+8 1LFQqtYneh3Xiy82Olk926NaCMds13xdtlHAedQ3a8pvN6NsfjZzw0+QXvX9eniAxOw8 PuwFZm0iQnbyO2YduLEd7B4qRdlpwQsvUcfwUyebBJW0OqkgDP4W+J9+WF23SNYfhN1V 9tXs1ucg8K04LJWD1U6ONqOUxSDelyl+S7bIZt3uGtjtcqfFZSuLDE7QtHi1gFeGCuWV A9y4MYgpg/81pKaN4wQLAPqetE15sO7Siz1/cPE5GjbL//2KKdVCifB3UG7ST36rEaP7 DV9Q== 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 z15-v6si4707433pll.405.2018.03.02.01.30.31; Fri, 02 Mar 2018 01:30:45 -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 S1425750AbeCBJ2u (ORCPT + 99 others); Fri, 2 Mar 2018 04:28:50 -0500 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:59064 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1425206AbeCBJ2V (ORCPT ); Fri, 2 Mar 2018 04:28:21 -0500 X-IronPort-AV: E=Sophos;i="5.47,411,1515481200"; d="scan'208";a="11692114" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Mar 2018 02:28:19 -0700 Received: from [10.145.6.76] (10.10.76.4) by chn-sv-exch06.mchp-main.com (10.10.76.107) with Microsoft SMTP Server id 14.3.352.0; Fri, 2 Mar 2018 02:28:19 -0700 Subject: Re: [PATCH v3 05/10] pwm: add PWM mode to pwm_config() To: Jani Nikula , Thierry Reding CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <1519300881-8136-1-git-send-email-claudiu.beznea@microchip.com> <1519300881-8136-6-git-send-email-claudiu.beznea@microchip.com> <20180228194429.GD22932@mithrandir> <87r2p4hod7.fsf@intel.com> From: Claudiu Beznea Message-ID: <585cc4ae-3674-c119-295b-e59f4242e619@microchip.com> Date: Fri, 2 Mar 2018 11:28:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <87r2p4hod7.fsf@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28.02.2018 22:04, Jani Nikula wrote: > On Wed, 28 Feb 2018, Thierry Reding wrote: >> Anyone that needs something other than normal mode should use the new >> atomic PWM API. > > At the risk of revealing my true ignorance, what is the new atomic PWM > API? Where? Examples of how one would convert old code over to the new > API? As far as I know, the old PWM core code uses config(), set_polarity(), enable(), disable() methods of driver, registered as pwm_ops: struct pwm_ops { int (*request)(struct pwm_chip *chip, struct pwm_device *pwm); void (*free)(struct pwm_chip *chip, struct pwm_device *pwm); int (*config)(struct pwm_chip *chip, struct pwm_device *pwm, int duty_ns, int period_ns); int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm, enum pwm_polarity polarity); int (*capture)(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_capture *result, unsigned long timeout); int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm); void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm); int (*apply)(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state); void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state); #ifdef CONFIG_DEBUG_FS void (*dbg_show)(struct pwm_chip *chip, struct seq_file *s); #endif struct module *owner; }; to do settings on hardware. In order to so settings on a PWM the users should have been follow the below steps: ->config() ->set_polarity() ->enable() Moreover, if the PWM was previously enabled it should have been first disable and then to follow the above steps in order to apply a new settings on hardware. The driver should have been provide, at probe, all the above function: ->config(), ->set_polarity(), ->disable(), ->enable(), function that were used by PWM core. Now, having atomic PWM, the driver should provide one function to PWM core, which is ->apply() function. Every PWM has a state associated, which keeps the period, duty cycle, polarity and enable/disable status. The driver's ->apply() function takes as argument the state that should be applied and it takes care of applying this new state directly without asking user to call ->disable(), then ->config()/->set_polarity(), then ->enable() to apply new hardware settings. The PWM consumer could set a new state for PWM it uses, using pwm_apply_state(pwm, new_state); Regarding the models to switch on atomic PWM, on the controller side you can check for drivers that registers apply function at probe time. Regarding the PWM users, you can look for pwm_apply_state() (drivers/hwmon/pwm-fan.c or drivers/input/misc/pwm-beeper.c are some examples). Thierry, please correct me if I'm wrong. Thank you, Claudiu Beznea > > BR, > Jani. >