Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4058820ybx; Mon, 4 Nov 2019 07:12:37 -0800 (PST) X-Google-Smtp-Source: APXvYqz5XE7H3qsZ270yaMPzxJKEOgxJ3Yq6IJawQbfbqMgCJWP2a6GMqKIF68AZGGYpvvrDV2We X-Received: by 2002:a17:906:7fcb:: with SMTP id r11mr6598422ejs.85.1572880357455; Mon, 04 Nov 2019 07:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572880357; cv=none; d=google.com; s=arc-20160816; b=rk06o7DHQDiSx8IdEix5foIMHsxVwIP5UKAyFBa1mRB6vAFSi4iTOglwVraeM6SqPY LWbjYRLcw/1qvYXhQzo2J4YylvX8aTsT9TZ/WjD0xQQz7HMwVUj6QnhbFl1NsoNC2eWK 4MR+MEr7MFwA1ndz+AlN5T7PP1dVHY4tsdkdMMCKEtdMT84lrqRaA8swG5N1CAaQrMyt us+KIMychQBmFGn9FqRxpsme6Zt7TFCLZrqecUohmOCbT69MGkLDU0Cc2ongkkMB88LR ymW3zUGojm84RVekW99vdwPu+Jyv3D8HyAA3Bo0EcMyupPWnMKtE+OVF/1qeaYc7GUpe Wh6w== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=MePWhTpjabcwAnNWYXGCJMV1NtK4UUw0KlMiSXFo/Aw=; b=VSwDq1LQf93X8+/M4ZXdHjZozfXQGVS8fnTEzaFQ2wnOuj8/3hWI9TpdhTbJa42TMJ OnzjZKgNvy4FY/8RG+t3pDX7U+ujn64+7O5tpIp+lgQgJkrkmOYc/yY8kQNCvMZx9MWy a9eMWrgM1R34Xvf2ZL7M9iXOW+4f3I8z1NSfJpmjNyugtHIlsLRQH8AKYMtDrv1b2Slx 32Fo+NXf3/ChpwQP2PWjzyK2tHzCTFdV9yvBMMisH2rksmCL0z/nR02hxgH0Qab6ArWn l5ZjGa1W65rhhxNteYqxTAYI0SSHLtYJ1RMrW3ARDZ2/SFbcii9lR795i1ezxm2oIDoO fAFQ== 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 11si8279377edv.422.2019.11.04.07.12.14; Mon, 04 Nov 2019 07:12:37 -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 S1729242AbfKDPLH convert rfc822-to-8bit (ORCPT + 99 others); Mon, 4 Nov 2019 10:11:07 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:56735 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727998AbfKDPLG (ORCPT ); Mon, 4 Nov 2019 10:11:06 -0500 X-Originating-IP: 86.250.200.211 Received: from xps13 (lfbn-1-17395-211.w86-250.abo.wanadoo.fr [86.250.200.211]) (Authenticated sender: miquel.raynal@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 63294240015; Mon, 4 Nov 2019 15:11:04 +0000 (UTC) Date: Mon, 4 Nov 2019 16:11:03 +0100 From: Miquel Raynal To: Andy Shevchenko Cc: Linus Walleij , Bartosz Golaszewski , Thierry Reding , Uwe =?UTF-8?B?S2xlaW5lLUvDtm5pZw==?= , "open list:GPIO SUBSYSTEM" , linux-pwm@vger.kernel.org, Linux Kernel Mailing List , Thomas Petazzoni Subject: Re: [PATCH] gpio: pca953x: Add Maxim MAX7313 PWM support Message-ID: <20191104161103.64995b8a@xps13> In-Reply-To: References: <20191014124803.13661-1-miquel.raynal@bootlin.com> <20191015163055.0d8f44e5@xps13> Organization: Bootlin X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Linus, Andy Shevchenko wrote on Tue, 15 Oct 2019 17:55:33 +0300: > On Tue, Oct 15, 2019 at 5:30 PM Miquel Raynal wrote: > > > > Hi Andy, > > > > Thanks for the feedback. > > > > Andy Shevchenko wrote on Mon, 14 Oct 2019 > > 20:59:01 +0300: > > > > > On Mon, Oct 14, 2019 at 4:09 PM Miquel Raynal wrote: > > > > > > > > The MAX7313 chip is fully compatible with the PCA9535 on its basic > > > > functions but can also manage the intensity on each of its ports with > > > > PWM. Each output is independent and may be tuned with 16 values (4 > > > > bits per output). The period is always 32kHz, only the duty-cycle may > > > > be changed. One can use any output as GPIO or PWM. > > > > > > Can we rather not contaminate driver with this? > > > > > > Just register a separate PWM driver and export its functionality to > > > GPIO, or other way around (in the latter case we actually have PCA8685 > > > which provides a GPIO fgunctionality). > > > > > > > I understand your concern but I am not sure to understand which > > solution you have in mind. In the former case, could you explain a bit > > more what you are thinking about? Would linking the PWM support with > > the GPIO driver (code would be located in another .c file) work for > > you? Or maybe you would prefer an MFD on top of the GPIO driver? > > > > As for the later case, I am not willing to re-implement GPIO support in > > an alternate driver for an already supported chip, it is too much work > > for the time I can spend on it. > > > drivers/pwm/pwm-max7313.c: > > probe(platform_device) > { > struct regmap = pdata; > ... > } > > --- 8< --- 8< --- > drivers/gpio/gpio-pca953x.c: > > probe() > { > struct regmap rm; > ... > if (dev_has_pwm) > pca953x_register_pwm_driver(rm); > ... > } > > In the above regmap may be replaced with some (shared) container. > > Or other way around. PWM registers GPIO (which actually I prefer since > we have PCA9685 case where PWM provides GPIO functionality, though via > different means) > Can I have your input on this proposal? On one hand I agree that the GPIO driver is already quite big due to its genericity and the amount of controllers it supports, on the other hand: 1/ Registering a PWM driver from the GPIO core seems strange. Maybe registering a platform device could do the trick but I am not convinced it is worth the trouble. 2/ Putting the PWM logic in the drivers/pwm/ directory is not very convenient as the object file will have to be embedded within the GPIO one; this line in drivers/gpio/Makefile would be horrible: ... += gpio-pca953x.o ../pwm/pwm-max7313.o (not even sure it works) 3/ In any cases, the regmap's ->readable_reg(), ->writable_reg() callbacks shall be tweaked to turn the PWM registers accessible, so we would still have PWM related code in the PCA953x GPIO driver. In the end, I wonder if keeping everything in one file is not better? Eventually I can create a separate file and fill it with just the PWM helpers/hooks. Please advise on the better solution for you, I'll wait your feedback before addressing Thierry Reding's other review and resubmit. Thanks, Miquèl