Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4081245ybx; Mon, 4 Nov 2019 07:33:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzbgXKlnj/G60CxvgHNTB1riWMDdPZ1ufAMItx5GeKwuIBJ3Lj57Q0VAbtRe2zXUGCqgAZR X-Received: by 2002:a05:6402:1292:: with SMTP id w18mr30429991edv.151.1572881635644; Mon, 04 Nov 2019 07:33:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572881635; cv=none; d=google.com; s=arc-20160816; b=Fo6NP8AvvDTdhnbfiAmBpsu1qpzpYmlnvkDaIwr1v6dsNujGw9rEHKcYj02N69BjXJ JZFx4+09CSkxYekdSahavLLc02o53ZJpTuueYFvP8/rF24Oi1qK/5+iT34rJ/6zSjumy CgGhCM01jbAkOiHToEnArVDfeQlHBD8e4p6uw4It4IZyAZoxXhUH1QwsE9WYHhpnqecV DZWnsTMjRl7DhVs4ou8DTHICINYcy6Smt46nvZpu9QUVJJm/hrisK5hKDsUBlkpP+YAD MbnitTbsI+Ep0NBbpI8OsSeRCoghFX3oVwBhi4N2jtpTrRoGlZERdxVMr/23wS2+Is9F kpYQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=UCa5z4wM9ujAZVKxuB1XurT7/b8EmjpHqxtKJ4ezjzc=; b=VeE5nOXxe213PKOZ9ej512TqKjXf0dt56rvMRtqKKP18EGTZ3WeV08WHu89EGqy3vD towSUh5/RDU7u9RTUnI/Sht5RmNiQJbCuVbEGCsgCRJ5lHtZyxZHsOxxToG+XS7c7ykX Mlie6Teok+reqSSGO/oQlOJWbUpeajRTpHhBNU8ehKam72NQx4LxAf0wpCObYniNXTp0 aaPNMy/TEaGSt1Lb+KYmSJNewsKO7Qdldjiy4Un8VOzQ8IH1ZiuFWFCDPjuZmsH2KTWN v4m+oCw4P97mDhnjoBc5PTZnAyioh8U3gg/AERUshhjCDyXkAKdKeg+NZSoYS/O0wULA UgxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=S6CB0Alw; 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 b15si10859198ejv.167.2019.11.04.07.33.32; Mon, 04 Nov 2019 07:33:55 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=S6CB0Alw; 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 S1729084AbfKDPch (ORCPT + 99 others); Mon, 4 Nov 2019 10:32:37 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:42015 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727998AbfKDPcg (ORCPT ); Mon, 4 Nov 2019 10:32:36 -0500 Received: by mail-ot1-f68.google.com with SMTP id b16so14712856otk.9 for ; Mon, 04 Nov 2019 07:32:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=UCa5z4wM9ujAZVKxuB1XurT7/b8EmjpHqxtKJ4ezjzc=; b=S6CB0AlwooUoRSw6ziiydGxesCarlK3ax1IvdUt042v+6e7vu0MQQuEccP2x9Vmclg lZcw0d/CojZZSHzppk4d1uYymb7/ChgJPHYHyD5WBHfqu79a6C5A5gRjtt1FQMx3+NCi lQmgg4xvQ4rmhxpCyli3Or/D9vilHfamW1yXIE6G2p0O5SAb1aP4hHjp6+VyCuFeteaa xykIUmKfU+b0UEhM4RRfki5flpCaA4OtNWbAgiNOEc+tBrSjefz4IgJzquklqdt23tsT 7syHbrRvCyIsNb7l1POjVBDt9ivyzvCe+AYr7qgcJ/DauV4KvteEm+5E5tmlQxArEreO vblA== 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:content-transfer-encoding; bh=UCa5z4wM9ujAZVKxuB1XurT7/b8EmjpHqxtKJ4ezjzc=; b=E/bSNEuE1xlosk2tjzFrIW9Tpd0nlxsvwYWpUMpQ5eTNtiYvi5K2wTKKzBGhYt6nA8 cCnw/DNW23nWQZjM+Lsg1Bi+lq/wLrn47bSk3C/60JoAV7tmPOHOUkv//wdwVbDuwbyr JNM2RS3UqWEv53ibwGTkEFPx5hpzwAs6T97DkTDsVAfajFejQEx8IbceQVsRNIN80sIh 06WZ55tuh2V77Y5ZVbi5aojT6AynXKdTNv8hFQeen/F7b8QS5PJJwLI08aCUpwsfvscV 5MsVdjeEnD0eGMt4yX/gD5dOKN+ZMtrl8QRzW0hbkgPdK6Uvwqaazu38qVVy5ApQaDwF qP9w== X-Gm-Message-State: APjAAAXCdDS1qAloZQIOt20klqg2eO4zVZK8SLysRmrchmTuk8Hp6Gqh aXHe1ilvW1dhRPgUyS4GAW8RFxjPz+bGPoVkmE+3Pw== X-Received: by 2002:a05:6830:22ef:: with SMTP id t15mr3195246otc.256.1572881555374; Mon, 04 Nov 2019 07:32:35 -0800 (PST) MIME-Version: 1.0 References: <20191014124803.13661-1-miquel.raynal@bootlin.com> <20191015163055.0d8f44e5@xps13> <20191104161103.64995b8a@xps13> In-Reply-To: <20191104161103.64995b8a@xps13> From: Bartosz Golaszewski Date: Mon, 4 Nov 2019 16:32:23 +0100 Message-ID: Subject: Re: [PATCH] gpio: pca953x: Add Maxim MAX7313 PWM support To: Miquel Raynal Cc: Andy Shevchenko , Linus Walleij , Thierry Reding , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , "open list:GPIO SUBSYSTEM" , linux-pwm@vger.kernel.org, Linux Kernel Mailing List , Thomas Petazzoni Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pon., 4 lis 2019 o 16:11 Miquel Raynal napisa= =C5=82(a): > > 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 basi= c > > > > > 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 PCA8= 685 > > > > 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 bi= t > > > 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 wor= k > > > for the time I can spend on it. > > > > > > drivers/pwm/pwm-max7313.c: > > > > probe(platform_device) > > { > > struct regmap =3D 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: > ... +=3D 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. > I'm not sure if this has been discussed, but is it possible to create an MFD driver for this chip and conditionally plug in the GPIO part from pca953x? I don't like the idea of having PWM functionality in a GPIO driver either. Bart > > Thanks, > Miqu=C3=A8l