Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5563740rwi; Sun, 23 Oct 2022 08:07:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5VPittmpPUEZ7r5Y1ETvj1UGHhRAR4qt1kHM1XfkRGP1ym3vc9b+o5BJfBfWZ3aVINTWcT X-Received: by 2002:a17:907:a4e:b0:77d:94d:8148 with SMTP id be14-20020a1709070a4e00b0077d094d8148mr22853798ejc.607.1666537649397; Sun, 23 Oct 2022 08:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666537649; cv=none; d=google.com; s=arc-20160816; b=Dyo+NkI9z2R0YxEHH6bTT7PZpbNSzWSF+o4eLUGzF5PPuK49vTfqF0ym2PPxUDUeWI HEU7tSYlvAtMXw7DRYEa1seY2VJC5ddabN0PaVDMOldKjSdbpHpNHpLRhzYGyOyx+0VC jZEKxFIaCS8LBEhkqtzCZ9uJVnpcgeN1GNcSL5VOlIZi0Kwc+pNxYRwDCF5cZ/Zafliy RYE5vbSemqcETB9GPUTNsBivhkkpzmTpV+OtMJzY+IXUi4DcM0NRkwBDdMWard2jTiR4 0Gx7b5q+wLcjWAwdz5KnZGugVaBKQ7JQIL5MSAwsTLfzAVQazFHZ0IXej+XxyGHr6pDV cD6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=aKHgjslC8BpjNm94J0N795D7jnNyFIy6w5eny7ti0dU=; b=wQO7ElihoXOdh/Li8OwuUKfFoZEpcmkv8KYYirvVUk0php48hC03g/W0+Nhabq4h3I 78iH3LmQ06oYQkbpHayWg5rMZre60QtZanLnIeKIgrRC6YFhyN4BOr7we24B2YFhoB/J 0w4yw35F8gF3vinvcTE6Pof18NQHhFhrpuwiMRCVZY7buOC5Tl6J5wYyu8Ta++xS9dX7 JhE/tfQLNmlbJcQQGsZdIsSNrKDFj86uOzInltGj/XJ1EyDtmwDx93d/zPyKYv+JboRm 4/2pynkPvftEimEIxH/pHThFC/+W7DD9aZqItkZ0/Lu0LJL8ufqvUwnIpPtFNdb5uEc1 a/bQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds14-20020a170907724e00b0078c3197bf86si24723372ejc.533.2022.10.23.08.07.01; Sun, 23 Oct 2022 08:07:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230071AbiJWPBo (ORCPT + 99 others); Sun, 23 Oct 2022 11:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbiJWPBn (ORCPT ); Sun, 23 Oct 2022 11:01:43 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9073D72284; Sun, 23 Oct 2022 08:01:41 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.94.2) (envelope-from ) id 1omcTp-0008Qd-Iw; Sun, 23 Oct 2022 17:01:37 +0200 Date: Sun, 23 Oct 2022 16:01:34 +0100 From: Daniel Golle To: Krzysztof Kozlowski Cc: Rob Herring , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Thierry Reding , linux-mediatek@lists.infradead.org, Krzysztof Kozlowski , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Matthias Brugger , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/2] dt-bindings: pwm: mediatek: Add compatible string for MT7986 Message-ID: References: <20221021222338.GA565200-robh@kernel.org> <5182e3c4-9e5e-2c36-408b-9029c65c8803@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 23, 2022 at 08:39:34AM -0400, Krzysztof Kozlowski wrote: > On 23/10/2022 08:24, Daniel Golle wrote: > > Hi Krzysztof, > > > > On Sat, Oct 22, 2022 at 12:35:25PM -0400, Krzysztof Kozlowski wrote: > >> On 21/10/2022 18:58, Daniel Golle wrote: > >>> On Fri, Oct 21, 2022 at 05:23:38PM -0500, Rob Herring wrote: > >>>> On Fri, Oct 21, 2022 at 04:25:18PM +0100, Daniel Golle wrote: > >>>>> Add new compatible string for MT7986 PWM. > >>>>> > >>>>> Signed-off-by: Daniel Golle > >>>>> --- > >>>>> Documentation/devicetree/bindings/pwm/pwm-mediatek.txt | 1 + > >>>>> 1 file changed, 1 insertion(+) > >>>>> > >>>>> diff --git a/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt b/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt > >>>>> index 554c96b6d0c3e0..6f4e60c9e18b81 100644 > >>>>> --- a/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt > >>>>> +++ b/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt > >>>>> @@ -8,6 +8,7 @@ Required properties: > >>>>> - "mediatek,mt7623-pwm": found on mt7623 SoC. > >>>>> - "mediatek,mt7628-pwm": found on mt7628 SoC. > >>>>> - "mediatek,mt7629-pwm": found on mt7629 SoC. > >>>>> + - "mediatek,mt7986-pwm": found on mt7986 SoC. > >>>> > >>>> This version of the PWM h/w is not compatible with any of the existing > >>>> chips? If it is, it should have a fallback compatible. > >>> > >>> No, it is unique because it comes with just 2 PWM channels. > >>> Otherwise the driver behaves just like for MT8183 (4 channels) or > >>> MT8365 (3 channels) which also got distinct compatible strings. > >> > >> Then something would be here compatible. E.g. If you bound MT8183 with > >> mt7986-pwm compatible, would you get working device with two channels? > > > > Yes, but I'd see another 2 channels which do not work, accessing them > > may even cause problems (I haven't tried that) as it means accessing > > an undocumented memory range of the SoC which we in general we > > shouldn't be messing around with. > > Why on MT8183 there would be undocumented memory? Where is undocumented > memory? So we were talking about using the MT8183 compatible for MT7986 SoC, as the PWM units are identical apart from the number of channels they offer: MT7986 got 2 PWM channels. The MMIO registers used for those two channels start at offsets 0x10 (pwm0) and 0x50 (pwm1) MT8183 got 4 PWM channels. The MMIO registers used for those four channels start of offsets 0x10 (pwm0), 0x50 (pwm1), 0x90 (pwm2) and 0xd0 (pwm3). Hence, when using the MT8183 compatible with MT7986, the driver will access offsets 0x90 and 0xd0 in case the users enables the (bogus) outputs pwm2 and pwm3. These offsets, however, are not mentioned in the datasheet, so it has to be considered that writing things to these undocumented offsets could cause unknown behavior. I hope it's more clear now what I mean. > > > > > Also note that this case is the same as MT8183 vs. MT8365, they got > > distinct compatible strings and also for those two the only difference > > is the number of channels. > > So why they are not made compatible? My guess is that it's for this very reason: To correctly communicate the capabilities (in this case: number of channels) to the driver and not have bogus pwmX show up in the OS which then causes undocumented MMIO register access in case anyone tries to actually use them. > > > > >> > >> If so, they are compatible. > > > > By that definition you should remove the additional compatible for > > MT8365 or rather, it should have been rejected for the same argument. > > > > I'm talking about > > commit fe00faee8060402a3d85aed95775e16838a6dad2 > > commit 394b517585da9fbb2eea2f2103ff47d37321e976 > > This is a pattern spreading in several Mediatek bindings and we already > commented on new patches. I don't know why people working on Mediatek do > not mark pieces compatible. Others will have to answer that for you. To me this looks a bit like a structural shortcoming of the PWM controller bindings: if there was a way to tell the driver "hey, this is like MT8183, but it got only two channels" that would solve it nicely. This could either be done using child-nodes for each PWM channel or by simply adding a 'nr-pwms' property. Cheers Daniel