Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2830810ybg; Thu, 24 Oct 2019 16:11:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHfQIeww6rPnMbDEYuIszZ422wAmjxn25LIR1bzNNbydpGG1hzzGQOJE8xpUMmdKzlKoG7 X-Received: by 2002:a50:eb95:: with SMTP id y21mr701591edr.155.1571958705580; Thu, 24 Oct 2019 16:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571958705; cv=none; d=google.com; s=arc-20160816; b=wiieZHh/LA5g1uZU3uIcNA6vV8OVttwBn4Bn2YruKhxPtWe/XVh1MWQQJv/O83/4b2 gGa57Rkz8v4FQ9jNyg0qxwIIWzOQfR9jG8sJMWZAV3XoQ4Wm4cHw+1K6XlHfrLXoSzid muToVGeDXBhIm2OpgixO2WJqrENfYhwrLEYtj+XXrYqbt5pnviSwaNcIvgqibcQ2lIJV wqDv5zQt6sD6u+Uq89tjl8bIm06qzIPi6g2N0LATtQGotChNoo/zhhzMCC2qUzSMBJQA nN1SL8rv5tAJX26ipevwR/NV/wx0lKS6+APH75RFyH0X1rybN8B9B5Fx1AwK3Q5uQncc TEJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=G4vdb56f6clb5k1zxUC/hpMvO/EV60ACJWqtpC79nFU=; b=WOdLrqSNPI33UPNzwi9VWb1IdZfJsiU/BG1vvNHQ0NMzpEpt+UKlQjduWPxQnwWDg6 pZWFDmVXADBfDcaE2CHoQuDdvfdQoTQIIpD0LO3m4dj/lHCf4gn6HFLJ+YU+9zJCePZ6 /cBaLkcjIh9gxDp0EtCDLeyBrbMDO6f1X8dLKOrBAGkJ2KQpAqFa4RhJPSiZU2J0vit5 3qlIimYYJuSQa/TLHZkhHBNwW0PSI1k3jqTHBRzISXyFWtzJDz+VCgnem797Dr/s5MuM f2nfFzVFpkXAWAiD4mDcA9DyWnQDeuieMBG4q5g1lM1J/MxxU9icf1s1mgHiMwHx71mi rPPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MWFTxBFo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si20690edd.189.2019.10.24.16.11.21; Thu, 24 Oct 2019 16:11:45 -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=@linaro.org header.s=google header.b=MWFTxBFo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438215AbfJXI3d (ORCPT + 99 others); Thu, 24 Oct 2019 04:29:33 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39382 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727024AbfJXI3c (ORCPT ); Thu, 24 Oct 2019 04:29:32 -0400 Received: by mail-wm1-f68.google.com with SMTP id r141so1639947wme.4 for ; Thu, 24 Oct 2019 01:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=G4vdb56f6clb5k1zxUC/hpMvO/EV60ACJWqtpC79nFU=; b=MWFTxBFoF/A1/WoBHVj4CbXYa/Pfi+Fu/HBTS1OD78S8XdVhAfAv2FPoim6z/HL0fJ bAsjZ+nQU7xuGOSLAMS2cU1WpogE6lpqKrhD0fwpRUWBooxdm7oatdnbiFT1vKMQRuXI YUesDSYrlrXY7rtIkZZGFVWVQMmXWOoDkYjmG/FlPyxrTaFiOsrgcX/deoqQpQrz8WC9 eb7bHMF072EjgrW7DtfWSSoYwWX/Okev8BmdNZBQGxbi/4F2jWxN2L1lgUa8PMMJyWd2 9WdYf7WE46xuvVtBI4kSOqH1p5U/DpO+hajtJZ1AcsTM2xKtX35hm8MaY5eHyUBhdkRQ 8xLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=G4vdb56f6clb5k1zxUC/hpMvO/EV60ACJWqtpC79nFU=; b=q5tD4r1THMXCZSo6HQfUZP0UnCOaUzbJkuqgxkk1RH3UWjZDEIO/1YZIGiOsS+gZQ0 xL5Mkt9K1Ais7cM8M9EoeC7fVtvL+V8QNozhGsfeKD1Dpnpzq+MUmpk8qe8FVN4Jh5kn gUcy3PA57J49A7dmzzb0CuRrRfy42UCjubjowDrJoIQr5aniQqjx9ec/VgJLtVhYroaZ Eot5nh82rXq1IwxOb0RnNkvU15rW33jEicfnZAz6FFUOtLugTEZmTq+6NcvrGYHLoWEl jNkGConEt1MAeXgwu3yIQrRXNyPsdc5ddQgO5tJKAbd6v2ao6lnjkasDX84Tm9qZuylV JQUg== X-Gm-Message-State: APjAAAW/iYTCxY+qM44Z6j4OpEGWh9+svEdKeyGOQVsSNIJkqArzH6XR iAW/UjnC3U/n3BAssZi8MCvt7w== X-Received: by 2002:a7b:c049:: with SMTP id u9mr3667702wmc.12.1571905770490; Thu, 24 Oct 2019 01:29:30 -0700 (PDT) Received: from dell ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id j63sm2931576wmj.46.2019.10.24.01.29.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 01:29:29 -0700 (PDT) Date: Thu, 24 Oct 2019 09:29:28 +0100 From: Lee Jones To: Gene Chen Cc: matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, gene_chen@richtek.com, Wilma.Wu@mediatek.com, shufan_lee@richtek.com, cy_huang@richtek.com Subject: Re: [PATCH v4] mfd: mt6360: add pmic mt6360 driver Message-ID: <20191024082928.GL15843@dell> References: <1571749359-15752-1-git-send-email-gene.chen.richtek@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1571749359-15752-1-git-send-email-gene.chen.richtek@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 22 Oct 2019, Gene Chen wrote: > From: Gene Chen > > Add mfd driver for mt6360 pmic chip include > Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck > > Signed-off-by: Gene Chen --- > drivers/mfd/Kconfig | 12 + > drivers/mfd/Makefile | 1 + > drivers/mfd/mt6360-core.c | 457 +++++++++++++++++++++++++++++++++++++ > include/linux/mfd/mt6360-private.h | 279 ++++++++++++++++++++++ > include/linux/mfd/mt6360.h | 32 +++ > 5 files changed, 781 insertions(+) > create mode 100644 drivers/mfd/mt6360-core.c > create mode 100644 include/linux/mfd/mt6360-private.h > create mode 100644 include/linux/mfd/mt6360.h > > changelogs between v1 & v2 > - include missing header file > > changelogs between v2 & v3 > - add changelogs > > changelogs between v3 & v4 > - fix Kconfig description > - replace mt6360_pmu_info with mt6360_pmu_data > - replace probe with probe_new > - remove unnecessary irq_chip variable > - remove annotation > - replace MT6360_MFD_CELL with OF_MFD_CELL [...] > +/* IRQ definitions */ > +struct mt6360_pmu_irq_desc { > + const char *name; > + irq_handler_t irq_handler; > +}; > + > +#define MT6360_DT_VALPROP(name, type) \ > + {#name, offsetof(type, name)} > + > +struct mt6360_val_prop { > + const char *name; > + size_t offset; > +}; > + > +static inline void mt6360_dt_parser_helper(struct device_node *np, void *data, > + const struct mt6360_val_prop *props, > + int prop_cnt) > +{ > + int i; > + > + for (i = 0; i < prop_cnt; i++) { > + if (unlikely(!props[i].name)) > + continue; > + of_property_read_u32(np, props[i].name, data + props[i].offset); > + } > +} > + > +#define MT6360_PDATA_VALPROP(name, type, reg, shift, mask, func, base) \ > + {offsetof(type, name), reg, shift, mask, func, base} > + > +struct mt6360_pdata_prop { > + size_t offset; > + u8 reg; > + u8 shift; > + u8 mask; > + u32 (*transform)(u32 val); > + u8 base; > +}; > + > +static inline int mt6360_pdata_apply_helper(void *context, void *pdata, > + const struct mt6360_pdata_prop *prop, > + int prop_cnt) > +{ > + int i, ret; > + u32 val; > + > + for (i = 0; i < prop_cnt; i++) { > + val = *(u32 *)(pdata + prop[i].offset); > + if (prop[i].transform) > + val = prop[i].transform(val); > + val += prop[i].base; > + ret = regmap_update_bits(context, > + prop[i].reg, prop[i].mask, val << prop[i].shift); > + if (ret < 0) > + return ret; > + } > + return 0; > +} Where are these helpers used? Are they generic? Why are they helpful to you, but not helpful to anyone else? -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog