Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp802989ybg; Sun, 26 Jul 2020 23:05:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2zTnrq+Kwr+D0jRdINHz8Bk6tBtzLu7cljvEkO8qcCRCu7Dyq+TNl2X1ICFxY5uHFF488 X-Received: by 2002:aa7:c31a:: with SMTP id l26mr19090848edq.61.1595829950349; Sun, 26 Jul 2020 23:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595829950; cv=none; d=google.com; s=arc-20160816; b=BILa74e8EKP0+Z2vbC8v1KraKKMdsMXhhXvXIT8iuBtvJthkt2PJOYBMSezreOg5TM CChYXSdDAuXChOQDq1rifaXfENNpkt712sx8klNsa2bOyn2s/uBMkImHwflyfHLhiRky LUEXDITsr/h94Xs+I4+ajDdhP/xzCor6c9feGR20BYFtHY3x17AEzHl2KH42FIJA1lGz N8I3Z5eCAXihX1EsJi70tvBRhcVq/5AWP8YcfAQqNzTSFEUf7wMldv4I9qh+XXTvXefe MgXtTi68+3fG19zU1veT8siBlfUuy3MXs2ZIrh7T8mE9GTwohxC053fTVnw/skIeHtof iUWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=GTntlQe3pTZpepsssL0PG+znjtrfFH3iGoCa26gpyrs=; b=pTauJhkVjY7p2i39RNKDW9mF4ENxeWCI/3eg2pdKjjILzzawWipQscWRMaScStB8dC cJ37WsO/fMZFj/kk+4aW9PJrillPPYcq0H5afogyzE4tW+MwjwQt7/FRn0NvAFGRsnAH h9awQ+9ChS2pTFMqUuyD5C3JKNhpDGVPaD0tvICj+aQV3gXrUZWYVIWQwGuMfhvifAvV lSEiSaAAF8rSrfJkD9uWHrqYCgJyHPNVpYBfnlBiFo34MYlEaopiUvhht0UrqeY1m/wA Vn7S5mH2dxpkZ/8hXW8/lmbJONdcyPFpPViSi1UrfR7s5kSCSk1qxiRwPpluCZaopVa6 R/SA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr21si7668393ejc.254.2020.07.26.23.05.28; Sun, 26 Jul 2020 23:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726387AbgG0GFB (ORCPT + 99 others); Mon, 27 Jul 2020 02:05:01 -0400 Received: from mga11.intel.com ([192.55.52.93]:20400 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726006AbgG0GFA (ORCPT ); Mon, 27 Jul 2020 02:05:00 -0400 IronPort-SDR: 5GO/oIOCsY7AOev2+zWpeuCKfW4Jb+j76bUD8vSAbeFA4ghWcJBZPd3xYF9ImZ1cIVuluEHPDg ZW11fW8GJXfg== X-IronPort-AV: E=McAfee;i="6000,8403,9694"; a="148842551" X-IronPort-AV: E=Sophos;i="5.75,401,1589266800"; d="scan'208";a="148842551" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2020 23:05:00 -0700 IronPort-SDR: ATP/V/OSOyilyayPRGX5a8AuuiTtLDt0SpZbXi9pG7yOYszbkEr/9NsdNqmQ1zO3owdu8oEOOQ iRSsGgFLxFOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,401,1589266800"; d="scan'208";a="273166720" Received: from linux.intel.com ([10.54.29.200]) by fmsmga008.fm.intel.com with ESMTP; 26 Jul 2020 23:05:00 -0700 Received: from [10.249.75.97] (rtanwar-MOBL.gar.corp.intel.com [10.249.75.97]) by linux.intel.com (Postfix) with ESMTP id 3F769580297; Sun, 26 Jul 2020 23:04:57 -0700 (PDT) Subject: Re: [PATCH v5 2/2] Add PWM fan controller driver for LGM SoC To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= Cc: linux-pwm@vger.kernel.org, thierry.reding@gmail.com, p.zabel@pengutronix.de, robh+dt@kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, andriy.shevchenko@intel.com, songjun.Wu@intel.com, cheol.yong.kim@intel.com, qi-ming.wu@intel.com, rahul.tanwar.linux@gmail.com References: <0f47648107ec23f72868ca37f29ea43e15c08e08.1595489518.git.rahul.tanwar@linux.intel.com> <20200723161553.ey47oijnwitf4hvu@pengutronix.de> From: "Tanwar, Rahul" Message-ID: Date: Mon, 27 Jul 2020 14:04:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200723161553.ey47oijnwitf4hvu@pengutronix.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Uwe, On 24/7/2020 12:15 am, Uwe Kleine-K?nig wrote: > Hello, > > On Thu, Jul 23, 2020 at 03:44:18PM +0800, Rahul Tanwar wrote: >> +static int lgm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, >> + const struct pwm_state *state) >> +{ >> + struct lgm_pwm_chip *pc = to_lgm_pwm_chip(chip); >> + u32 duty_cycle, val; >> + int ret; >> + >> + if (!state->enabled) { >> + ret = lgm_pwm_enable(chip, 0); >> + return ret; >> + } >> + >> + /* >> + * HW only supports NORMAL polarity >> + * HW supports fixed period which can not be changed/configured by user >> + */ >> + if (state->polarity != PWM_POLARITY_NORMAL || >> + state->period != pc->period) >> + return -EINVAL; > At least for state->polarity you have to check before state->enabled, as > the expectation on > > .enabled = false > .polarity = PWM_POLARITY_INVERSED > > is that the output becomes constant high. Also as confirmed at the end > of v4, state->period < pc->period was the right check to do. For below case: .enabled = false .polarity = PWM_POLARITY_INVERSED Since our HW does not support inversed polarity, the output for above case is expected to be constant low. And if we disable PWM before checking for polarity, the output becomes constant low. The code just does that. Sorry, i could not understand what is wrong with the code. It looks correct to me. Given the fact that we support fixed period, if we allow state->period < pc->period case then the duty cycle will be evaluated as higher than the requested one because the state->period is lesser than the actual fixed period supported by the HW. Can you please elaborate on why you think we should allow state->period < pc->period case? Thanks, Regards, Rahul