Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1984896ybg; Fri, 5 Jun 2020 02:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbwyukDA6wBd+dZ3fbX2Jo1B2vpoTVTdv3VmUAqZVQsYQI/VlXng8vmLcad4A5oeiEOnGE X-Received: by 2002:a17:906:cd06:: with SMTP id oz6mr8313028ejb.434.1591349729812; Fri, 05 Jun 2020 02:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591349729; cv=none; d=google.com; s=arc-20160816; b=ensiS5+iEeB2tQHnE90WbBOxe6w7Q1l9c6xdcKKE+yxTflmcOHRgrwmeN97vwQV+T2 QGTxB2ZfzZaq+LH0AGIsI0Qon0nOrRRAVUD2bCnZC7Mr0tKSOa+mNI41/tzt9sBs3Ctg xSefwvLa/XUjI28KCd/DDF/5GTqkUaOvCXCSUjxw530k/oWmuaKboKjJAojlv7fi8u6e hBzip1pBJgHUpxJiEJ+ya5gBmW6ylc2bX1NNnTzoUqjIZ4InKfWw1zDv+BQi/uGpOvlH zPbnYEhes5un076wAlUHkMq7TMpbipHtRszc34kSyby6v2if8P1zK8lBOSSv4/oD3GVd 3a5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IXcPHC51fCcVubrTICi/8ebQ3LHbBGFqVc4ZlvkcGy8=; b=jnc5EPBIUNFPaAkQANm/4h5ydf1GkDvjOu+gOSGZbDsO4VfX4q6Bl3T/otxoexVa+X aRfptNIVr6vmfI0YX5oInOiBYwjTKaC9kVQCekOhPJiF9kgUL06luBOSKvDXafsCDYgM ixSjOJjDVD8oqL+xNy9D8EDbknkq0pXf2ilqyDATSEfX0C9wPM3opzHekWKR7riaZdoP P/dnZtvRUXiWvPajEvDvNc83Id4o0h/7oEQzpsFO0njsDlKz7Y0fXN5cc0QoftvjRgPd hY725q1+z6Vje3rFgMG5sMPJcVe5SGCrew5W1FPEh6avf/g69f2mmrvFaU8E1z02/1Lx LWDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YY5yU3cQ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f17si3242539ejh.246.2020.06.05.02.35.05; Fri, 05 Jun 2020 02:35:29 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YY5yU3cQ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726270AbgFEJdP (ORCPT + 99 others); Fri, 5 Jun 2020 05:33:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgFEJdO (ORCPT ); Fri, 5 Jun 2020 05:33:14 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19645C08C5C2; Fri, 5 Jun 2020 02:33:14 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id b5so4647711pfp.9; Fri, 05 Jun 2020 02:33:14 -0700 (PDT) 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; bh=IXcPHC51fCcVubrTICi/8ebQ3LHbBGFqVc4ZlvkcGy8=; b=YY5yU3cQ7x2nYhcyU6Irjiwac0T1X3r4FA1BzcjEXvTmKD8XF7ewfdDBsQMHyN6KxU cFdoRSQTl6THjHaN6iKdCqC0BT18oxYCTH1YobDoSbpGlkOC//8qTUR/rPRRlZVdI64f OsHkkqSlteKDL1f350r6Fe5Pb++laI5jkOJrF1Unn+FgfPyT5Gjit60bsEK9pPRGQ5DE DWn0f7KJp4ITvNVp9DaJtvu9QE8n38UOX22FxiXTySRqmj0VfkLbLpPs32+gcJm8HHyK TYxEPno36gqsfr6zFF1meSgq4MVTmwMPfHKo8WGVimW9hJWAdQTht0tModHLZnQB7XHA UroA== 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; bh=IXcPHC51fCcVubrTICi/8ebQ3LHbBGFqVc4ZlvkcGy8=; b=Go1XidAWBIijkRcRnR6QBYrpGiP5DvAfeukzAucLYVunsHVzXk8CFUBwTfX/QqTJQo J1Mc0b1lFdfYotrE0yI57A2KpiUsfjFgEAv2nTx1Og38iT/TKUhgYeTsIf8WAXHjOD0q QcwEs538z5T+16HL5JTFT9IJFSWzCcMOrt/fzoCgENUnQ40GI3cJa0PE56Irxlh8/g+p fEPxqfZwGsXZUXGR2rkTDARgr8Mi0g8Pp7iA59FVB5KjG5Swuj41cln+IvoHH4dt3Edy KxumhRInQnTo2a+jsWJD+7N7dp/tE/ukyr/KxCuXyGuv75jbxzJb21Og91RIVj1/Essr lu4A== X-Gm-Message-State: AOAM530l7+2paPoE7M5nyy6Iq/BXN+6TSTtjDdHLwjpPX1bZcY+rmrOt kmASl5aIzyfgGYx4+xysO5LxLK9SjClUkywiJBc= X-Received: by 2002:a63:305:: with SMTP id 5mr8367725pgd.74.1591349593472; Fri, 05 Jun 2020 02:33:13 -0700 (PDT) MIME-Version: 1.0 References: <20200604211039.12689-1-michael@walle.cc> <20200604211039.12689-6-michael@walle.cc> <20200605084915.GE3714@dell> In-Reply-To: <20200605084915.GE3714@dell> From: Andy Shevchenko Date: Fri, 5 Jun 2020 12:33:01 +0300 Message-ID: Subject: Re: [PATCH v4 05/11] pwm: add support for sl28cpld PWM controller To: Lee Jones Cc: Michael Walle , "open list:GPIO SUBSYSTEM" , devicetree , Linux Kernel Mailing List , linux-hwmon@vger.kernel.org, linux-pwm@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-arm Mailing List , Linus Walleij , Bartosz Golaszewski , Rob Herring , Jean Delvare , Guenter Roeck , Thierry Reding , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Wim Van Sebroeck , Shawn Guo , Li Yang , Thomas Gleixner , Jason Cooper , Marc Zyngier , Mark Brown , Greg Kroah-Hartman , Andy Shevchenko Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 5, 2020 at 11:51 AM Lee Jones wrote: > On Thu, 04 Jun 2020, Michael Walle wrote: ... > > + cycle = state->duty_cycle * config->max_duty_cycle; > > + do_div(cycle, state->period); > > Forgive my ignorance (I'm new here!), but what are these 2 lines > doing? Here we are multiplying the current duty_cycle with the > maximum value, then dividing by the period. > > So in the case of PWM_MODE_1KHZ with a 50% duty cycle, you'd have: > > (500000 * 0x20[16]) / 1000000 = [0x10]16 > > Thus, the above gives as a proportional representation of the maximum > valid value for placement into the cycle control register(s), right? > > Either way (whether I'm correct or not), I think it would be nice to > mention this in a comment. Maybe even clarify with a simple example. IIRC PWM has a helper for that (to calc period based on PWM state and new duty cycle %). -- With Best Regards, Andy Shevchenko