From: Lee Jones <lee.jones@linaro.org>
To: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>,
Daniel Mack <daniel@zonque.org>,
Robert Jarzmik <robert.jarzmik@free.fr>,
Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>,
Wolfram Sang <wsa@the-dreams.de>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
Samuel Ortiz <sameo@linux.intel.com>,
Mark Brown <broonie@kernel.org>, Jingoo Han <jg1.han@samsung.com>,
Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Andrea Adami <andrea.adami@gmail.com>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
linux-i2c@vger.kernel.org,
linux-input <linux-input@vger.kernel.org>,
linux-leds <linux-leds@vger.kernel.org>,
linux-spi <linux-spi@vger.kern>
Subject: Re: [PATCH v2 01/17] mfd: add new driver for Sharp LoCoMo
Date: Wed, 13 May 2015 10:41:32 +0100 [thread overview]
Message-ID: <20150513094132.GE3394@x1> (raw)
In-Reply-To: <CALT56yP6FPhGRZFJZkyjjpqGJ6bofg+a1BTC9KcVAgpmt2htoA@mail.gmail.com>
On Tue, 12 May 2015, Dmitry Eremin-Solenikov wrote:
> 2015-04-28 21:45 GMT+03:00 Lee Jones <lee.jones@linaro.org>:
> > On Tue, 28 Apr 2015, Dmitry Eremin-Solenikov wrote:
> >
> >> LoCoMo is a GA used on Sharp Zaurus SL-5x00. Current driver does has
> >> several design issues (special bus instead of platform bus, doesn't use
> >> mfd-core, etc).
> >>
> >> Implement 'core' parts of locomo support as an mfd driver.
> >>
> >> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> >> ---
>
> Thanks for the review. I agree (and have implemented) with most of
> your comments.
> However I have few questions. See below.
>
> >
> >> +/* the following is the overall data for the locomo chip */
> >> +struct locomo {
> >> + struct device *dev;
> >> + unsigned int irq;
> >> + spinlock_t lock;
> >> + struct irq_domain *domain;
> >> + struct regmap *regmap;
> >> +};
> >> +
> >> +static struct resource locomo_kbd_resources[] = {
> >> + DEFINE_RES_IRQ(IRQ_LOCOMO_KEY),
> >> +};
> >> +
> >> +static struct resource locomo_gpio_resources[] = {
> >> + DEFINE_RES_IRQ(IRQ_LOCOMO_GPIO),
> >> +};
> >> +
> >> +/* Filled in locomo_probe() function. */
> >> +static struct locomo_gpio_platform_data locomo_gpio_pdata;
> >
> > I'd prefer you didn't use globals for this.
>
> Just for platform data, or for all the structures?
Just for this. The remainder are standard.
> >> +static struct resource locomo_lt_resources[] = {
> >> + DEFINE_RES_IRQ(IRQ_LOCOMO_LT),
> >> +};
> >> +
> >> +static struct resource locomo_spi_resources[] = {
> >> + DEFINE_RES_IRQ(IRQ_LOCOMO_SPI),
> >> +};
> >> +
> >> +/* Filled in locomo_probe() function. */
> >> +static struct locomo_lcd_platform_data locomo_lcd_pdata;
> >> +
> >> +static struct mfd_cell locomo_cells[] = {
> >> + {
> >> + .name = "locomo-kbd",
> >> + .resources = locomo_kbd_resources,
> >> + .num_resources = ARRAY_SIZE(locomo_kbd_resources),
> >> + },
> >> + {
> >> + .name = "locomo-gpio",
> >> + .resources = locomo_gpio_resources,
> >> + .num_resources = ARRAY_SIZE(locomo_gpio_resources),
> >> + .platform_data = &locomo_gpio_pdata,
> >> + .pdata_size = sizeof(locomo_gpio_pdata),
> >> + },
> >> + {
> >> + .name = "locomo-lt", /* Long time timer */
> >> + .resources = locomo_lt_resources,
> >> + .num_resources = ARRAY_SIZE(locomo_lt_resources),
> >> + },
> >> + {
> >> + .name = "locomo-spi",
> >> + .resources = locomo_spi_resources,
> >> + .num_resources = ARRAY_SIZE(locomo_spi_resources),
> >> + },
> >> + {
> >> + .name = "locomo-led",
> >> + },
> >> + {
> >> + .name = "locomo-backlight",
> >> + },
> >
> > Please make these:
> >
> >> + { .name = "locomo-led" },
> >> + { .name = "locomo-backlight" },
> >
> > ... and put them at the bottom.
>
> They will be populated by of_compatible lines, so it makes little sense
> to me. What about adding of compatibility lines to this patch?
Also fine.
Although if you assure me you will do it, you can add them separately.
> >> + while (1) {
> >> + regmap_read(lchip->regmap, LOCOMO_ICR, &req);
> >> + req &= 0x0f00;
> >
> > What is this magic number? Please #define it.
>
> Adding comments to this function instead.
Also acceptable.
> >> + if (!req)
> >> + break;
> >> +
> >> + irq = ffs(req) - 9;
> >
> > Minus another random number? Either define it or enter a comment.
> >
> >> +#ifdef CONFIG_PM_SLEEP
> >> +static int locomo_suspend(struct device *dev)
> >> +{
> >> + struct locomo *lchip = dev_get_drvdata(dev);
> >> +
> >> + /* AUDIO */
> >
> > WHY ARE YOU SHOUTING? Ironic eh? ;)
> >
> >> + regmap_write(lchip->regmap, LOCOMO_PAIF, 0x00);
> >> +
> >> + /*
> >> + * Original code disabled the clock depending on leds settings
> >> + * However we disable leds before suspend, thus it's safe
> >> + * to just assume this setting.
> >> + */
> >> + /* CLK32 off */
> >> + regmap_write(lchip->regmap, LOCOMO_C32K, 0x00);
> >> +
> >> + /* 22MHz/24MHz clock off */
> >> + regmap_write(lchip->regmap, LOCOMO_ACC, 0x00);
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static int locomo_resume(struct device *dev)
> >> +{
> >> + struct locomo *lchip = dev_get_drvdata(dev);
> >
> > Do audio and clk sort themselves out?
>
> PAIF and ACC registers are used only by audio parts of the device. However
> there is no current Linux driver for those parts. The registers are cleared
> in case the firmware has set something in them, but in future it will
> be the task
> of the audio driver to properly clear and restore them.
>
> >> + regmap_write(lchip->regmap, LOCOMO_C32K, 0x00);
> >> +
> >> + return 0;
> >> +}
> >> +
>
> [skipped]
> >> +
> >> + if (pdata) {
> >> + locomo_gpio_pdata.gpio_base = pdata->gpio_base;
> >> + locomo_lcd_pdata.comadj = pdata->comadj;
> >> + } else {
> >> + locomo_gpio_pdata.gpio_base = -1;
> >> + locomo_lcd_pdata.comadj = 128;
> >> + }
> >
> > struct locomo_gpio_platform_data locomo_gpio_pdata;
> >
> > locomo_gpio_pdata = devm_kzalloc(<blah>);
> >
> > locomo_cells[GPIO].platform_data = locomo_gpio_pdata;
>
> I do not quite agree with you at this place. The passed platform_data
> will be kmemdup()'ed inside platform core. So the whole struct will be
> duplicated twice inside kmallocate'd memory. Ideally I'd like to drop
> the whole platform_data busyness, but that requires switching to DTS
> first.
Sounds reasonable.
> >> diff --git a/include/linux/mfd/locomo.h b/include/linux/mfd/locomo.h
> >> new file mode 100644
> >> index 0000000..6729767
> >> --- /dev/null
> >> +++ b/include/linux/mfd/locomo.h
>
> >> +/* MCS decoder for boot selecting */
> >> +#define LOCOMO_MCSX0 0x10
> >> +#define LOCOMO_MCSX1 0x14
> >> +#define LOCOMO_MCSX2 0x18
> >> +#define LOCOMO_MCSX3 0x1c
> >
> > These are pretty cryptic. Any way of making them easier to identify.
>
> No way. The names are based on old Sharp code. The drivers do not use
> them, but I'd like to still keep the registers for the reference purposes.
So they are not used at all? Then why do you want to keep them?
> >> +struct locomo_gpio_platform_data {
> >> + unsigned int gpio_base;
> >> +};
> >
> > A struct for a single int seems overkill.
> >
> >> +struct locomo_lcd_platform_data {
> >> + u8 comadj;
> >> +};
> >> +
> >> +struct locomo_platform_data {
> >> + unsigned int gpio_base;
> >> + u8 comadj;
> >> +};
> >
> > Why do you need to pass gpio_base twice?
>
> First: machine file -> core driver
> Second: core driver -> gpio driver
>
> The other way to do the same would be:
>
> struct locomo_gpio_platform_data {
> unsigned int gpio_base;
> };
>
> struct locomo_lcd_platform_data {
> u8 comadj;
> };
>
> struct locomo_platform_data {
> struct locomo_gpio_platform_data gpio_pdata;
> struct locomo_lcd_platform_data lcd_pdata;
> };
>
> And to assign pointers to the passed data in the mfd_cells
> during locomo_probe. Does that look better to you?
Bingo.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-05-13 9:41 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-27 23:55 [PATCH v2 00/17] new locomo driver set Dmitry Eremin-Solenikov
2015-04-27 23:55 ` [PATCH v2 01/17] mfd: add new driver for Sharp LoCoMo Dmitry Eremin-Solenikov
[not found] ` <1430178954-11138-2-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-28 18:45 ` Lee Jones
2015-05-12 20:39 ` Dmitry Eremin-Solenikov
2015-05-13 9:41 ` Lee Jones [this message]
2015-04-27 23:55 ` [PATCH v2 02/17] leds: port locomo leds driver to new locomo core Dmitry Eremin-Solenikov
2015-05-06 15:05 ` Jacek Anaszewski
2015-05-12 15:35 ` Dmitry Eremin-Solenikov
[not found] ` <CALT56yNJWapNw1XLrzfbUDUz1LF_BB9DfF94H6GhbnBUEP80_w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-13 10:31 ` Jacek Anaszewski
[not found] ` <555327EA.5060402-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-05-13 14:14 ` Dmitry Eremin-Solenikov
2015-05-13 14:53 ` Jacek Anaszewski
[not found] ` <5553654F.4010608-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-05-13 16:42 ` Dmitry Torokhov
2015-05-14 6:35 ` Jacek Anaszewski
[not found] ` <1430178954-11138-1-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-27 23:55 ` [PATCH v2 03/17] input: convert LoCoMo keyboard driver to use " Dmitry Eremin-Solenikov
2015-05-12 20:21 ` Dmitry Torokhov
2015-05-12 21:01 ` Dmitry Eremin-Solenikov
2015-05-12 21:13 ` Dmitry Torokhov
2015-04-27 23:55 ` [PATCH v2 04/17] input: locomokbd: provide an Alt-SysRQ combination Dmitry Eremin-Solenikov
2015-05-12 20:12 ` Dmitry Torokhov
2015-05-12 20:40 ` Dmitry Eremin-Solenikov
2015-04-27 23:55 ` [PATCH v2 06/17] video: lcd: add LoCoMo LCD driver Dmitry Eremin-Solenikov
2015-04-27 23:55 ` [PATCH v2 10/17] i2c: add locomo i2c driver Dmitry Eremin-Solenikov
2015-05-12 19:24 ` Wolfram Sang
2015-05-12 19:27 ` Dmitry Eremin-Solenikov
2015-05-12 19:28 ` Wolfram Sang
2015-04-27 23:55 ` [PATCH v2 05/17] video: backlight: add new locomo backlight driver Dmitry Eremin-Solenikov
2015-04-27 23:55 ` [PATCH v2 07/17] gpio: port LoCoMo gpio support from old driver Dmitry Eremin-Solenikov
2015-05-06 14:12 ` Linus Walleij
2015-04-27 23:55 ` [PATCH v2 08/17] gpio: locomo: implement per-pin irq handling Dmitry Eremin-Solenikov
2015-05-06 14:15 ` Linus Walleij
2015-05-06 16:42 ` Dmitry Eremin-Solenikov
2015-05-12 11:15 ` Linus Walleij
2015-04-27 23:55 ` [PATCH v2 09/17] spi: add locomo SPI driver Dmitry Eremin-Solenikov
2015-04-29 11:27 ` Mark Brown
2015-04-27 23:55 ` [PATCH v2 11/17] ARM: sa1100: make collie use new locomo drivers Dmitry Eremin-Solenikov
2015-04-27 23:55 ` [PATCH v2 12/17] ARM: sa1100: don't preallocate IRQ space for locomo Dmitry Eremin-Solenikov
2015-04-27 23:55 ` [PATCH v2 13/17] ASoC: pxa: poodle: make use of new locomo GPIO interface Dmitry Eremin-Solenikov
2015-05-06 14:19 ` Linus Walleij
2015-04-27 23:55 ` [PATCH v2 14/17] ARM: pxa: poodle: use new LoCoMo driver Dmitry Eremin-Solenikov
[not found] ` <1430178954-11138-15-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-28 19:35 ` Robert Jarzmik
2015-05-06 14:20 ` Linus Walleij
2015-04-27 23:55 ` [PATCH v2 15/17] ARM: pxa: poodle: don't preallocate IRQ space for locomo Dmitry Eremin-Solenikov
2015-04-28 19:36 ` Robert Jarzmik
2015-04-27 23:55 ` [PATCH v2 16/17] video: backlight: drop old locomo bl/lcd driver Dmitry Eremin-Solenikov
2015-04-27 23:55 ` [PATCH v2 17/17] ARM: drop old LoCoMo driver Dmitry Eremin-Solenikov
[not found] ` <1430178954-11138-18-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-06 14:22 ` Linus Walleij
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=20150513094132.GE3394@x1 \
--to=lee.jones@linaro.org \
--cc=andrea.adami@gmail.com \
--cc=broonie@kernel.org \
--cc=cooloney@gmail.com \
--cc=daniel@zonque.org \
--cc=dbaryshkov@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gnurou@gmail.com \
--cc=jg1.han@samsung.com \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-spi@vger.kern \
--cc=linux@arm.linux.org.uk \
--cc=plagnioj@jcrosoft.com \
--cc=robert.jarzmik@free.fr \
--cc=rpurdie@rpsys.net \
--cc=sameo@linux.intel.com \
--cc=tomi.valkeinen@ti.com \
--cc=wsa@the-dreams.de \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).