LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Lee Jones <lee.jones@linaro.org>
Cc: "Olof Johansson" <olof@lixom.net>,
"Arnd Bergmann" <arnd@arndb.de>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, "Rob Herring" <robh+dt@kernel.org>,
"Eddie Huang" <eddie.huang@mediatek.com>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"Samuel Ortiz" <sameo@linux.intel.com>,
"Yingjoe Chen (陳英洲)" <Yingjoe.Chen@mediatek.com>,
"Henry Chen" <henryc.chen@mediatek.com>,
"YH Chen (陳昱豪)" <yh.chen@mediatek.com>,
"Flora Fu" <flora.fu@mediatek.com>
Subject: Re: [PATCH 7/7] mfd: Add support for the MediaTek MT6397 PMIC
Date: Mon, 26 Jan 2015 11:52:22 +0100 [thread overview]
Message-ID: <20150126105222.GM12209@pengutronix.de> (raw)
In-Reply-To: <20150123161440.GA11745@x1>
On Fri, Jan 23, 2015 at 04:14:40PM +0000, Lee Jones wrote:
> On Fri, 23 Jan 2015, Sascha Hauer wrote:
>
> > From: Flora Fu <flora.fu@mediatek.com>
> >
> > This adds support for the MediaTek MT6397 PMIC. This is a
> > multifunction device with the following sub modules:
> >
> > - Regulator
> > - RTC
> > - Audio codec
> > - GPIO
> > - Clock
> >
> > It is interfaced to the host controller using SPI interface by a proprietary
> > hardware called PMIC wrapper or pwrap. MT6397 MFD is a child device of the
> > pwrap.
> >
> > Signed-off-by: Flora Fu, MediaTek
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > Cc: Samuel Ortiz <sameo@linux.intel.com>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > ---
> > Documentation/devicetree/bindings/mfd/mt6397.txt | 70 +++++
>
> This should be submitted seperately, as per:
>
> Documentation/devicetree/bindings/submitting-patches.txt
I didn't know this document yet, thanks for noting. I thought it is still
acceptable to combine patches adding both code and the binding docs.
>
> > drivers/mfd/Kconfig | 10 +
> > drivers/mfd/Makefile | 1 +
> > drivers/mfd/mt6397-core.c | 251 ++++++++++++++++
> > include/linux/mfd/mt6397/core.h | 76 +++++
> > include/linux/mfd/mt6397/registers.h | 362 +++++++++++++++++++++++
> > 6 files changed, 770 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/mfd/mt6397.txt
> > create mode 100644 drivers/mfd/mt6397-core.c
> > create mode 100644 include/linux/mfd/mt6397/core.h
> > create mode 100644 include/linux/mfd/mt6397/registers.h
> >
> > diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
> > new file mode 100644
> > index 0000000..25b40a6
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
> > @@ -0,0 +1,70 @@
> > +MediaTek MT6397 Multifunction Device Driver
> > +
> > +MT6397 is a multifunction device with the following sub modules:
> > +- Regulator
> > +- RTC
> > +- Audio codec
> > +- GPIO
> > +- Clock
> > +
> > +It is interfaced to host controller using SPI interface by a proprietary hardware
> > +called PMIC wrapper or pwrap. MT6397 MFD is a child device of pwrap.
> > +See the following for pwarp node definitions:
> > +Documentation/devicetree/bindings/soc/pwrap.txt
> > +
> > +This document describes the binding for mfd device and its sub module.
>
> Nit: s/mfd/MFD/
>
> > +Required properties:
> > +compatible: "mediatek,mt6397"
> > +
> > +Optional subnodes:
> > +
> > +- rtc:
> > + Required properties:
> > + - compatible: "mediatek,mt6397-rtc",
> > +- regulators
> > + Required properties:
> > + - compatible: "mediatek,mt6397-regulator",
> > + see Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
> > +- codec
> > + Required properties:
> > + - compatible: "mediatek,mt6397-codec",
> > +- clk
> > + Required properties:
> > + - compatible: "mediatek,mt6397-clk",
>
> Nit: Titles with or without ':', as long as it's consistent.
>
> Drop the comma at the end of each compatible line.
>
> > +Example:
> > + pwrap: pwrap@1000f000 {
> > + compatible = "mediatek,mt8135-pwrap";
> > +
> > + ...
> > +
> > + pmic {
> > + compatible = "mediatek,mt6397";
> > +
> > + codec: mt6397codec {
> > + compatible = "mediatek,mt6397-codec";
> > + };
> > +
> > + mt6397regulator: mt6397regulator {
>
> s/mt6397regulator/regulator/
Dropped the label completely since consumers will point to the
individual regulators, not this node.
> > diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
> > new file mode 100644
> > index 0000000..9710fca
> > --- /dev/null
> > +++ b/drivers/mfd/mt6397-core.c
> > @@ -0,0 +1,251 @@
> > +/*
> > + * Copyright (c) 2014 MediaTek Inc.
> > + * Author: Flora Fu, MediaTek
>
> Email address?
She does not work for MediaTek anymore. Her Email address is no longer
valid, so I removed it but kept her credits in the driver.
> > +{
> > + return irq >> 4;
> > +}
> > +
> > +static void mt6397_irq_lock(struct irq_data *data)
> > +{
> > + struct mt6397_chip *mt6397 = irq_get_chip_data(data->irq);
> > +
> > + mutex_lock(&mt6397->irqlock);
> > +}
> > +
> > +static void mt6397_irq_sync_unlock(struct irq_data *data)
> > +{
> > + int i;
> > + struct mt6397_chip *mt6397 = irq_get_chip_data(data->irq);
> > +
> > + regmap_write(mt6397->regmap, MT6397_INT_CON0, mt6397->irq_masks_cur[0]);
> > + regmap_write(mt6397->regmap, MT6397_INT_CON1, mt6397->irq_masks_cur[1]);
> > +
> > + mutex_unlock(&mt6397->irqlock);
> > +}
> > +
> > +static void mt6397_irq_mask(struct irq_data *data)
> > +{
> > + struct mt6397_chip *mt6397 = irq_get_chip_data(data->irq);
> > + int shift = mt6397_irq_shift(data->hwirq);
> > + int reg = mt6397_irq_reg(data->hwirq);
> > + int reg_ofs = MT6397_INT_CON0 + reg * 2;
> > +
> > + mt6397->irq_masks_cur[reg] &= ~(1 << shift);
>
> s/(1 << shift)/BIT(shift)/
Is it mentioned somewhere that these BIT macros shall be used? There are
quadrillions of examples for both styles in the kernel and personally I
think 1 << x is more readable.
> > + for (i = 0; i < MT6397_IRQ_GROUP_NR; i++) {
> > + ret = regmap_read(mt6397->regmap,
> > + MT6397_INT_STATUS0 + i * 2, &irq_reg[i]);
> > + if (ret > 0) {
>
> Can regmap_read() return <0?
Yes, but not > 0 ;). Fixed.
>
> > + dev_err(mt6397->dev,
> > + "failed to read interrupt status [0x%x]\n",
> > + MT6397_INT_STATUS0 + i * 2);
> > + return IRQ_NONE;
> > + }
> > + }
> > +
> > + for (i = 0; i < MT6397_IRQ_NR; i++) {
> > + int shift = mt6397_irq_shift(i);
> > + int reg = mt6397_irq_reg(i);
> > + int reg_ofs = MT6397_INT_STATUS0 + reg * 2;
> > +
> > + if (irq_reg[reg] & (1 << shift)) {
> > + cur_irq = irq_find_mapping(mt6397->irq_domain, i);
> > + if (cur_irq)
> > + handle_nested_irq(cur_irq);
> > +
> > + /* write 1 to status bit to clear the event. */
>
> There are very few comments in the driver and _this_ is where it was
> felt appropriate to do so? If you put "MT6397_INT_STATUS0 + reg * 2"
> directly into the call, the line will speak for itself.
I refactored the code a bit, like write status reg once after handling
all interrupts and not after each interrupt. I also removed this comment
since it only states the obvious.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2015-01-26 10:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-23 14:09 [PATCH v2] MediaTek PMIC support Sascha Hauer
2015-01-23 14:09 ` [PATCH 1/7] soc: Add MediaTek infracfg controller support Sascha Hauer
2015-01-23 14:09 ` [PATCH 2/7] soc: Add MediaTek pericfg " Sascha Hauer
2015-01-23 14:09 ` [PATCH 3/7] dt: bindings: Add MediaTek MT8135/MT8173 reset controller defines Sascha Hauer
2015-01-23 14:09 ` [PATCH 4/7] soc: mediatek: Add PMIC wrapper for MT8135 and MT6397 SoC Sascha Hauer
2015-01-23 14:10 ` [PATCH 5/7] ARM: dts: mt8135: Add pericfg, infracfg and pmic wrapper nodes Sascha Hauer
2015-01-23 14:10 ` [PATCH 6/7] ARM: dts: mt8135-evbp1: Add PMIC support Sascha Hauer
2015-01-23 14:10 ` [PATCH 7/7] mfd: Add support for the MediaTek MT6397 PMIC Sascha Hauer
2015-01-23 16:14 ` Lee Jones
2015-01-26 10:52 ` Sascha Hauer [this message]
2015-01-26 11:11 ` Lee Jones
2015-01-26 11:26 ` Sascha Hauer
2015-01-26 11:47 ` [PATCH v2] MediaTek PMIC support Sascha Hauer
2015-01-29 12:39 ` Matthias Brugger
2015-01-29 13:22 ` Matthias Brugger
2015-01-29 14:27 ` Sascha Hauer
2015-01-29 15:44 ` Matthias Brugger
2015-01-29 16:18 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150126105222.GM12209@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=Yingjoe.Chen@mediatek.com \
--cc=arnd@arndb.de \
--cc=eddie.huang@mediatek.com \
--cc=flora.fu@mediatek.com \
--cc=henryc.chen@mediatek.com \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=olof@lixom.net \
--cc=robh+dt@kernel.org \
--cc=sameo@linux.intel.com \
--cc=yh.chen@mediatek.com \
--subject='Re: [PATCH 7/7] mfd: Add support for the MediaTek MT6397 PMIC' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).