Received: by 10.192.165.148 with SMTP id m20csp3090405imm; Sun, 29 Apr 2018 13:52:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoWce6pU+f9dL/qUXn9kbcpcasHYLESscsreXve3hedajsH1ckIL3ryn/1fK0YW2C4nXIyh X-Received: by 10.98.211.82 with SMTP id q79mr9833484pfg.45.1525035159056; Sun, 29 Apr 2018 13:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525035159; cv=none; d=google.com; s=arc-20160816; b=kx75ekxTiVTbOZQS+jnSihIqIZ+OjF7Mxqr2sN02U1totv7iISt6c4YWDeUc2oTlSA SE3ZCdbn+rt7+V5ZxoHJw49IXcoARBI2vGTeI2TOOq88iRPsj4SpFmkjAuYATiycWIg5 uw4X66TowJizxNvNUpWlwMi238v1xQLBQY2gbJMQMrgan4C8KZ7lQK5TMuapCHHlb2dg llR88KyKerNIw0YOnN8xedF3s2kpdXdBnGY1x/1q+/X6HJctPsTAof6ckcmebsO8QuCV 2jMabgUp7cUj828RAJnbVbAomNwL0JHCCBJX3NLeAubl3EXsxn5AWpj5Ok3xrUTxOE/B RW4w== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=PfnZqIS2EgW+ZRHYcee0QIi9YVRmfV7TbvbIQLZaDVc=; b=UvXYfrLG4aW5P5HCXJGzIcwqmGPt8GZUByHtniKdXcpnmNODHE0Y96J2MzpWbPNqRR p7VqdLFMFOpnoMWf66VM5IK+cYpQo6xMBJxl0mpriHAUv0ydxihx+gIq8mxionj0Ij+z jdRvRFIdoA0gCZ58muDCGdcDxLqepA7oeXCbjfcwL9mw6OVi216FblbvYjGh0q3qzVd0 E9qcIk0QrCca9MUq7uVWzZlHinQCrtGssPa00Ak/O0DWFxQxb6BMxSZBrqDYSoMWJHRx 8WLHI6836dHdSL92Yr8Etgwj459F+soIhkxPMCGsRFf6UDRYf/q4pNQldKc1DYQdA5Iw a7oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=l3WQ+MxA; 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 a63si6270513pfc.131.2018.04.29.13.51.50; Sun, 29 Apr 2018 13:52:39 -0700 (PDT) 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=@sifive.com header.s=google header.b=l3WQ+MxA; 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 S1754253AbeD2Uvi (ORCPT + 99 others); Sun, 29 Apr 2018 16:51:38 -0400 Received: from mail-yb0-f177.google.com ([209.85.213.177]:33526 "EHLO mail-yb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754138AbeD2Uvg (ORCPT ); Sun, 29 Apr 2018 16:51:36 -0400 Received: by mail-yb0-f177.google.com with SMTP id y5-v6so2443755ybg.0 for ; Sun, 29 Apr 2018 13:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=PfnZqIS2EgW+ZRHYcee0QIi9YVRmfV7TbvbIQLZaDVc=; b=l3WQ+MxApqa9IyJ792RluJXvpcUvy1f1TPWZc3sC9qpAFJXxL8l2l7GxKXerwFOnCo 2amk0DMw+STajpx9566LjlM7R0pCj+SN+kgFKO7I7q7Zx5lNNg6pwcgKymG/bsA2iUD+ TbP4PvwkVRGv+XQAEo08KH9a5swDsBiMdN8pW/BC1Rqjkyi5H6+s5tlljQ6tfp9eR0tZ FfZaHOBJT1jjJ0QWv8kpw0VXhMQY1Cf0CSxl+8kG1I6RRamNKLzlRQuRTMO086zOX5+a 4xcWgWnWFlDnNL3H1gHK/NLJ3Vy9zP4dJ516OZZqsb8eLYOfVRvHGgZBampmU9lZ3QQz sdjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=PfnZqIS2EgW+ZRHYcee0QIi9YVRmfV7TbvbIQLZaDVc=; b=hthdqmIL0p86MepmcB07s8KNqQArr+H9Xwt7xPTarcFgfzO/Qq1aAygyii5yaQHlSI gmRuagJg1/rynyMCqwDHBHeVUdE4wnxBkM7bhoKXtAQfMn0wKYtRFTXRGHH1xw2+wQMw tbjugQgZV3PDLgx4cMQtsiRXBJpNC3o6/inBPgWO6vQd6dN4NDhopBIQ5cMMf8whMmnt 1twmvB6hGCelYeRn7Y/o5m3gPCASeXjn7RU24C5w0rLFySIIETwcvaP1O55ITEM9EmHz W6+i9jRXtTKzN3JXhv1W4TKXHTIHDz+tj/Edwm9sCRbLBQ5wzSFo8ZtchVfoQWgl4eRC V/EQ== X-Gm-Message-State: ALQs6tBKZgmx+UsHjLRrcPE7wxOKQcnuOjees8eOP7SroWtNdTwyNjmI RXGhu8waRgb5/JgSr05vJA7QqwXVtdjf0hc+IPSGzA== X-Received: by 2002:a25:5806:: with SMTP id m6-v6mr5479258ybb.312.1525035094992; Sun, 29 Apr 2018 13:51:34 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:3dc7:0:0:0:0:0 with HTTP; Sun, 29 Apr 2018 13:51:34 -0700 (PDT) In-Reply-To: <20180429055417.GA10221@mithrandir> References: <1524869998-2805-1-git-send-email-wesley@sifive.com> <1524869998-2805-2-git-send-email-wesley@sifive.com> <20180429055417.GA10221@mithrandir> From: Wesley Terpstra Date: Sun, 29 Apr 2018 13:51:34 -0700 Message-ID: Subject: Re: [PATCH 1/3] dt-bindings: added new pwm-sifive driver documentation To: Thierry Reding Cc: Rob Herring , Mark Rutland , =?UTF-8?Q?Andreas_F=C3=A4rber?= , =?UTF-8?Q?Noralf_Tr=C3=B8nnes?= , David Lechner , Alexandre Belloni , SZ Lin , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 Sat, Apr 28, 2018 at 10:54 PM, Thierry Reding wrote: > On Fri, Apr 27, 2018 at 03:59:56PM -0700, Wesley W. Terpstra wrote: >> +Unlike most other PWM controllers, the SiFive PWM controller currently only >> +supports one period for all channels in the PWM. This is set globally in DTS. >> +The period also has significant restrictions on the values it can achieve, >> +which the driver rounds to the nearest achievable frequency. > > How about you encode this in the driver rather than DT? We have several > drivers with similar restrictions and they usually allow the first PWM > channel to choose an arbitrary period and return an error if subsequent > channels request a period that can't be supported. > > I think something similar could work with that second restriction. Why > not return an error if the exact period can't be set? Or perhaps allow > some percentage of deviation. Interesting. There are two ways to use this PWM. In one mode you use all channels of the PWM as outputs. This is the mode the driver supports because the HiFive Unleashed board uses all channels connected to LEDs. In this case, the PWM period must always be a power-of-two reduction from the core bus clock frequency. The core bus clock frequency can vary. Therefore, even if the caller's frequency can be achieved at the time of the method call, it may not remain achievable. You might say this is a ridiculous PWM design, and I'd agree with you, but sadly this is what is found in these chips. So effectively, the only thing we can guarantee is that the period is within a multiple of sqrt(2) from the requested period, except even that is not true due to saturation restrictions that could push the period even further from what you ask. In the other mode (where you sacrifice one of the output channels), you have finer control of the period, but it still affects all channels. This mode might be a better fit for your proposed API, except that the driver would still be subject to saturation restrictions on the period. And those restrictions will change as the core bus frequency is changed, which means that again, even if your target period can be achieved (common to all channels) at invocation, it might not be achievable later. IMO the only real control this PWM can offer reliably is the duty cycle, which is why I've written it how I have. If you see a better solution to the above problems, I am open to suggestions. >> +Required properties: >> +- compatible: should be "sifive,pwm0" > > Why not simply "sifive,pwm"? If this is supposed to be some sort of > version number, then it is more customary to use the name of the first > SoC that integrates the IP. There are some exceptions, like for example > when the IP is third-party and is integrated in a number of different > SoCs. In such cases the IP is often properly versioned. But that doesn't > seem to be the case here. It is indeed a version number. The first SoC which integrated this IP cannot run linux. We've put a version number like this into all of our IP blocks. Isn't an increasing number, which clearly indicates increased functionality, better than a reference to a sequence of SoCs whose relationships are not all that clear?