linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jingoo Han <jg1.han@samsung.com>
To: 'Dmitry Eremin-Solenikov' <dbaryshkov@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
	linux-input@vger.kernel.org, linux-leds@vger.kernel.org,
	linux-spi@vger.kernel.org, linux-fbdev@vger.kernel.org,
	alsa-devel@alsa-project.org,
	'Andrea Adami' <andrea.adami@gmail.com>,
	'Russell King' <linux@arm.linux.org.uk>,
	'Daniel Mack' <daniel@zonque.org>,
	'Haojian Zhuang' <haojian.zhuang@gmail.com>,
	'Robert Jarzmik' <robert.jarzmik@free.fr>,
	'Linus Walleij' <linus.walleij@linaro.org>,
	'Alexandre Courbot' <gnurou@gmail.com>,
	'Dmitry Torokhov' <dmitry.torokhov@gmail.com>,
	'Bryan Wu' <cooloney@gmail.com>,
	'Richard Purdie' <rpurdie@rpsys.net>,
	'Samuel Ortiz' <sameo@linux.intel.com>,
	'Lee Jones' <lee.jones@linaro.org>,
	'Mark Brown' <broonie@kernel.org>,
	'Liam Girdwood' <lgirdwood@gmail.com>,
	'Jingoo Han' <jg1.han@samsung.com>
Subject: Re: [PATCH 06/15] video: lcd: add LoCoMo LCD driver
Date: Tue, 28 Oct 2014 09:30:50 +0900	[thread overview]
Message-ID: <000101cff246$6d229850$4767c8f0$%han@samsung.com> (raw)
In-Reply-To: <1414454528-24240-7-git-send-email-dbaryshkov@gmail.com>

On Tuesday, October 28, 2014 9:02 AM, Dmitry Eremin-Solenikov wrote:
> 
> LoCoMo has some special handling for TFT screens attached to Collie and
> Poodle. Implement that as a separate driver.
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  drivers/video/backlight/Kconfig      |   8 ++
>  drivers/video/backlight/Makefile     |   1 +
>  drivers/video/backlight/locomo_lcd.c | 224 +++++++++++++++++++++++++++++++++++
>  3 files changed, 233 insertions(+)
>  create mode 100644 drivers/video/backlight/locomo_lcd.c
> 
> diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
> index 03b77b33..bc5c671 100644
> --- a/drivers/video/backlight/Kconfig
> +++ b/drivers/video/backlight/Kconfig
> @@ -48,6 +48,14 @@ config LCD_LMS283GF05
>  	  SPI driver for Samsung LMS283GF05. This provides basic support
>  	  for powering the LCD up/down through a sysfs interface.
> 
> +config LCD_LOCOMO
> +	tristate "Sharp LOCOMO LCD Driver"
> +	depends on MFD_LOCOMO
> +	default y
> +	help
> +	  If you have a Sharp Zaurus SL-5500 (Collie) or SL-5600 (Poodle) say y to
> +	  enable the LCD driver.
> +
>  config LCD_LTV350QV
>  	tristate "Samsung LTV350QV LCD Panel"
>  	depends on SPI_MASTER
> diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
> index 2a61b7e..b2580e7 100644
> --- a/drivers/video/backlight/Makefile
> +++ b/drivers/video/backlight/Makefile
> @@ -9,6 +9,7 @@ obj-$(CONFIG_LCD_ILI922X)		+= ili922x.o
>  obj-$(CONFIG_LCD_ILI9320)		+= ili9320.o
>  obj-$(CONFIG_LCD_L4F00242T03)		+= l4f00242t03.o
>  obj-$(CONFIG_LCD_LD9040)		+= ld9040.o
> +obj-$(CONFIG_LCD_LOCOMO)		+= locomo_lcd.o

Please insert this alphabetically for the readability.

>  obj-$(CONFIG_LCD_LMS283GF05)		+= lms283gf05.o
>  obj-$(CONFIG_LCD_LMS501KF03)		+= lms501kf03.o
>  obj-$(CONFIG_LCD_LTV350QV)		+= ltv350qv.o
> diff --git a/drivers/video/backlight/locomo_lcd.c b/drivers/video/backlight/locomo_lcd.c
> new file mode 100644
> index 0000000..245efb8
> --- /dev/null
> +++ b/drivers/video/backlight/locomo_lcd.c
> @@ -0,0 +1,224 @@
> +/*
> + * Backlight control code for Sharp Zaurus SL-5500
> + *
> + * Copyright 2005 John Lenz <lenz@cs.wisc.edu>
> + * Maintainer: Pavel Machek <pavel@ucw.cz> (unless John wants to :-)
> + * GPL v2
> + *
> + * This driver assumes single CPU. That's okay, because collie is
> + * slightly old hardware, and no one is going to retrofit second CPU to
> + * old PDA.
> + */
> +
> +/* LCD power functions */
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/platform_device.h>
> +#include <linux/fb.h>
> +#include <linux/backlight.h>
> +#include <linux/err.h>
> +#include <linux/gpio.h>
> +#include <linux/delay.h>
> +#include <linux/lcd.h>
> +#include <linux/mfd/locomo.h>

Please, re-order these headers alphabetically.
It enhances the readability.

> +
> +static struct platform_device *locomolcd_dev;
> +static struct locomo_lcd_platform_data lcd_data;
> +static bool locomolcd_is_on;
> +static bool locomolcd_is_suspended;
> +static void __iomem *locomolcd_regs;
> +static struct lcd_device *lcd_dev;
> +
> +static struct gpio locomo_gpios[] = {
> +	{ 0, GPIOF_OUT_INIT_LOW, "LCD VSHA on" },
> +	{ 0, GPIOF_OUT_INIT_LOW, "LCD VSHD on" },
> +	{ 0, GPIOF_OUT_INIT_LOW, "LCD Vee on" },
> +	{ 0, GPIOF_OUT_INIT_LOW, "LCD MOD" },
> +};
> +
> +static void locomolcd_on(void)
> +{
> +	gpio_set_value(lcd_data.gpio_lcd_vsha_on, 1);
> +	mdelay(2);
> +
> +	gpio_set_value(lcd_data.gpio_lcd_vshd_on, 1);
> +	mdelay(2);
> +
> +	locomo_m62332_senddata(locomolcd_dev->dev.parent, lcd_data.comadj, 0);
> +	mdelay(5);
> +
> +	gpio_set_value(lcd_data.gpio_lcd_vee_on, 1);
> +	mdelay(10);

How about changing mdelay() to usleep_range()?

> +
> +	/* TFTCRST | CPSOUT=0 | CPSEN */
> +	writew(0x01, locomolcd_regs + LOCOMO_TC);
> +
> +	/* Set CPSD */
> +	writew(6, locomolcd_regs + LOCOMO_CPSD);
> +
> +	/* TFTCRST | CPSOUT=0 | CPSEN */
> +	writew((0x04 | 0x01), locomolcd_regs + LOCOMO_TC);
> +	mdelay(10);
> +
> +	gpio_set_value(lcd_data.gpio_lcd_mod, 1);
> +}
> +
> +static void locomolcd_off(void)
> +{
> +	/* TFTCRST=1 | CPSOUT=1 | CPSEN = 0 */
> +	writew(0x06, locomolcd_regs + LOCOMO_TC);
> +	mdelay(1);
> +
> +	gpio_set_value(lcd_data.gpio_lcd_vsha_on, 0);
> +	mdelay(110);
> +
> +	gpio_set_value(lcd_data.gpio_lcd_vee_on, 0);
> +	mdelay(700);
> +
> +	locomo_m62332_senddata(locomolcd_dev->dev.parent, 0, 0);
> +	mdelay(5);

How about changing mdelay() to usleep_range() or msleep()?

> +
> +	/* TFTCRST=0 | CPSOUT=0 | CPSEN = 0 */
> +	writew(0, locomolcd_regs + LOCOMO_TC);
> +	gpio_set_value(lcd_data.gpio_lcd_mod, 0);
> +	gpio_set_value(lcd_data.gpio_lcd_vshd_on, 0);
> +}
> +
> +int locomo_lcd_set_power(struct lcd_device *lcd, int power)
> +{
> +	dev_dbg(&lcd->dev, "LCD power %d (is %d)\n", power, locomolcd_is_on);
> +	if (power == 0 && !locomolcd_is_on) {
> +		locomolcd_is_on = 1;
> +		locomolcd_on();
> +	}
> +	if (power != 0 && locomolcd_is_on) {
> +		locomolcd_is_on = 0;
> +		locomolcd_off();
> +	}
> +	return 0;
> +}
> +
> +static int locomo_lcd_get_power(struct lcd_device *lcd)
> +{
> +	return !locomolcd_is_on;
> +}
> +
> +static struct lcd_ops locomo_lcd_ops = {
> +	.set_power = locomo_lcd_set_power,
> +	.get_power = locomo_lcd_get_power,
> +};
> +
> +#ifdef CONFIG_PM_SLEEP
> +static int locomolcd_suspend(struct device *dev)
> +{
> +	locomolcd_is_suspended = true;
> +	locomolcd_off();
> +
> +	return 0;
> +}
> +
> +static int locomolcd_resume(struct device *dev)
> +{
> +	locomolcd_is_suspended = false;
> +
> +	if (locomolcd_is_on)
> +		locomolcd_on();
> +
> +	return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(locomolcd_pm, locomolcd_suspend, locomolcd_resume);
> +#define LOCOMOLCD_PM	(&locomolcd_pm)
> +#else
> +#define LOCOMOLCD_PM	NULL
> +#endif
> +
> +static int locomolcd_probe(struct platform_device *dev)
> +{
> +	unsigned long flags;
> +	struct resource *res;
> +	struct locomo_lcd_platform_data *pdata;
> +	int rc;
> +
> +	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
> +	if (!res)
> +		return -EINVAL;
> +	locomolcd_regs = devm_ioremap_resource(&dev->dev, res);
> +	if (!locomolcd_regs)
> +		return -EINVAL;

Please change it as below.

	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
	locomolcd_regs = devm_ioremap_resource(&dev->dev, res);
	if (IS_ERR(locomolcd_regs))
		 return PTR_ERR(locomolcd_regs);
> +
> +	pdata = dev_get_platdata(&dev->dev);
> +	if (!pdata)
> +		return -EINVAL;
> +
> +	lcd_data = *pdata;
> +
> +	locomo_gpios[0].gpio = lcd_data.gpio_lcd_vsha_on;
> +	locomo_gpios[1].gpio = lcd_data.gpio_lcd_vshd_on;
> +	locomo_gpios[2].gpio = lcd_data.gpio_lcd_vee_on;
> +	locomo_gpios[3].gpio = lcd_data.gpio_lcd_mod;
> +	dev_info(&dev->dev, "GPIOs: %d %d %d %d\n",
> +			locomo_gpios[0].gpio,
> +			locomo_gpios[1].gpio,
> +			locomo_gpios[2].gpio,
> +			locomo_gpios[3].gpio);
> +
> +	rc = gpio_request_array(locomo_gpios, ARRAY_SIZE(locomo_gpios));
> +	if (rc)
> +		return rc;
> +
> +	local_irq_save(flags);
> +	locomolcd_dev = dev;
> +
> +	locomolcd_is_on = 1;
> +	if (locomolcd_is_on)
> +		locomolcd_on();
> +
> +	local_irq_restore(flags);
> +
> +	lcd_dev = lcd_device_register("locomo", &dev->dev, NULL,

Please use devm_lcd_device_register().

> +			&locomo_lcd_ops);
> +
> +	return 0;
> +}
> +
> +static int locomolcd_remove(struct platform_device *dev)
> +{
> +	unsigned long flags;
> +
> +	lcd_device_unregister(lcd_dev);

If devm_lcd_device_register() is used in probe(),
there is no need to call lcd_device_unregister() in remove().

> +
> +	local_irq_save(flags);
> +
> +	locomolcd_off();
> +	locomolcd_dev = NULL;
> +
> +	local_irq_restore(flags);
> +
> +	gpio_free_array(locomo_gpios, ARRAY_SIZE(locomo_gpios));
> +
> +	return 0;
> +}
> +
> +static void locomolcd_shutdown(struct platform_device *dev)
> +{
> +	locomolcd_off();
> +}
> +
> +static struct platform_driver locomolcd_driver = {
> +	.driver = {
> +		.name	= "locomo-lcd",
> +		.owner	= THIS_MODULE,
> +		.pm	= LOCOMOLCD_PM,
> +	},
> +	.probe	= locomolcd_probe,
> +	.remove	= locomolcd_remove,
> +	.shutdown = locomolcd_shutdown,
> +};
> +
> +module_platform_driver(locomolcd_driver);
> +
> +MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>, Pavel Machek <pavel@ucw.cz>");


Please split these authors to lines as below.

MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>");
MODULE_AUTHOR("Pavel Machek <pavel@ucw.cz>");

> +MODULE_DESCRIPTION("Collie LCD driver");

What does mean 'Collie'? 'Locomo' looks better.

> +MODULE_LICENSE("GPL");

How about using "GPL v2"?

Thank you.

Best regards,
Jingoo Han

> +MODULE_ALIAS("platform:locomo-lcd");
> --
> 2.1.1

  reply	other threads:[~2014-10-28  0:30 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28  0:01 [PATCH 00/15] new locomo driver Dmitry Eremin-Solenikov
2014-10-28  0:01 ` [PATCH 01/15] mfd: add new driver for Sharp LoCoMo Dmitry Eremin-Solenikov
     [not found]   ` <1414454528-24240-2-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-31  7:42     ` Linus Walleij
2014-10-31  9:54       ` Dmitry Eremin-Solenikov
     [not found]         ` <CALT56yNX8v4mZn=o1ZoVLHPmg6wq0dgFNowpqNuFtU=eCc+d8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-03 13:41           ` Linus Walleij
2014-11-05 20:02             ` Dmitry Eremin-Solenikov
2014-11-05 20:24               ` Mark Brown
2014-11-14 12:47                 ` Dmitry Eremin-Solenikov
2014-11-14 15:10                   ` Mark Brown
2014-11-14 15:30                     ` Dmitry Eremin-Solenikov
2014-11-05 20:32               ` Lars-Peter Clausen
2014-11-05 20:42                 ` Lars-Peter Clausen
2014-10-28  0:01 ` [PATCH 02/15] GPIO: port LoCoMo gpio support from old driver Dmitry Eremin-Solenikov
2014-10-31  7:48   ` Linus Walleij
     [not found]     ` <CACRpkdY7tRadod2vQfEytmw-ubaMAvr_=XTczD5bUMkqie0xkg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-31  9:39       ` Dmitry Eremin-Solenikov
     [not found]         ` <CALT56yOgMUA7o2dzfHph=S2zkDV4zERzMh4ishpPwpAx7Cqj6Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-03 13:43           ` Linus Walleij
     [not found]             ` <CACRpkdb7v3LmOhbhQ9TPk1_bnLnpwizawW6RQvhQRLSjRewAaQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-05 21:33               ` Dmitry Eremin-Solenikov
2014-11-06  6:03                 ` Mark Brown
2014-11-11 13:16                   ` Dmitry Eremin-Solenikov
     [not found]                     ` <CALT56yPr42FV66USngocw=eWPt81d5R2MJxmzBnv02HOMmXAkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-11 13:23                       ` Mark Brown
2014-11-14 10:11                       ` Linus Walleij
2014-11-14 12:48                         ` Dmitry Eremin-Solenikov
2014-10-28  0:01 ` [PATCH 03/15] leds: port locomo leds driver to new locomo core Dmitry Eremin-Solenikov
     [not found] ` <1414454528-24240-1-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-28  0:01   ` [PATCH 04/15] input: convert LoCoMo keyboard driver to use " Dmitry Eremin-Solenikov
2014-10-28  0:09     ` Dmitry Torokhov
2014-10-28  0:02   ` [PATCH 08/15] ARM: sa1100: make collie use new locomo drivers Dmitry Eremin-Solenikov
2014-10-28  0:02   ` [PATCH 12/15] ARM: pxa: poodle: don't preallocate IRQ space for locomo Dmitry Eremin-Solenikov
2014-10-28 19:13     ` Robert Jarzmik
2014-10-28  0:02   ` [PATCH 13/15] ARM: drop old LoCoMo driver Dmitry Eremin-Solenikov
2014-10-28  0:02   ` [PATCH 14/15] gpio: locomo: implement per-pin irq handling Dmitry Eremin-Solenikov
2014-10-31  8:00     ` Linus Walleij
2014-10-31  9:35       ` Dmitry Eremin-Solenikov
2014-10-28  0:02   ` [PATCH 15/15] spi: add locomo SPI driver Dmitry Eremin-Solenikov
     [not found]     ` <1414454528-24240-16-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-28 11:03       ` Mark Brown
2014-10-28  0:01 ` [PATCH 05/15] video: backlight: add new locomo backlight driver Dmitry Eremin-Solenikov
2014-10-28  0:24   ` Jingoo Han
2014-10-28  0:01 ` [PATCH 06/15] video: lcd: add LoCoMo LCD driver Dmitry Eremin-Solenikov
2014-10-28  0:30   ` Jingoo Han [this message]
2014-10-28 16:47     ` Dmitry Eremin-Solenikov
2014-10-28  0:02 ` [PATCH 07/15] video: backlight: drop old locomo bl/lcd driver Dmitry Eremin-Solenikov
2014-10-28  0:02 ` [PATCH 09/15] ARM: sa1100: don't preallocate IRQ space for locomo Dmitry Eremin-Solenikov
2014-10-31  7:50   ` Linus Walleij
2014-10-31  9:33     ` Dmitry Eremin-Solenikov
2014-10-28  0:02 ` [PATCH 10/15] ARM: pxa: poodle: use new LoCoMo driver Dmitry Eremin-Solenikov
2014-10-28  0:02 ` [PATCH 11/15] sound: soc: poodle: make use of new locomo GPIO interface Dmitry Eremin-Solenikov
     [not found]   ` <1414454528-24240-12-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-28 14:58     ` Mark Brown
     [not found]       ` <20141028145850.GU18557-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-10-28 16:45         ` Dmitry Eremin-Solenikov
2014-10-29  3:03       ` Alexandre Courbot
     [not found]         ` <CAAVeFuKgARoMFzf+663iP6cULs93d4WSQS8ESjUb9VcxguWurA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-31  9:52           ` Linus Walleij
2014-10-31  9:58             ` Dmitry Eremin-Solenikov
2014-11-01  5:42               ` Alexandre Courbot
2014-10-28  0:13 ` [PATCH 00/15] new locomo driver Russell King - ARM Linux
     [not found]   ` <20141028001338.GZ27405-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-10-28  0:28     ` Dmitry Eremin-Solenikov
2014-10-28  0:29   ` Mark Brown

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='000101cff246$6d229850$4767c8f0$%han@samsung.com' \
    --to=jg1.han@samsung.com \
    --cc=alsa-devel@alsa-project.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=haojian.zhuang@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=robert.jarzmik@free.fr \
    --cc=rpurdie@rpsys.net \
    --cc=sameo@linux.intel.com \
    /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).