new locomo driver

Started by Dmitry Eremin-Solenikov on Oct 28, 2014 · 17 messages from 5 authors · Last reply Oct 31, 2014

Series

9 patches, 19 files

+1,580 −356

Subsystems (10)

Show 7 more

Maintainers (16)

Show 12 more
STALE4398d

open the first message on its own page

  1. [PATCH 02/15] GPIO: port LoCoMo gpio support from old driver
    Related patches
  2. [PATCH 03/15] leds: port locomo leds driver to new locomo core
    Related patches
  3. [PATCH 05/15] video: backlight: add new locomo backlight driver
    Related patches
  4. [PATCH 07/15] video: backlight: drop old locomo bl/lcd driver
    Related patches
  5. [PATCH 06/15] video: lcd: add LoCoMo LCD driver
    Related patches
  6. [PATCH 09/15] ARM: sa1100: don't preallocate IRQ space for locomo
    Related patches
  7. [PATCH 10/15] ARM: pxa: poodle: use new LoCoMo driver
    Related patches
  8. [PATCH 11/15] sound: soc: poodle: make use of new locomo GPIO interface
    Related patches
Message details and related content
Sharp Zaurus SL-5500 and SL-5600 use special companion Gate Array. Current
drivers present in Linux kernel has some problems:

 * It uses custom bus instead of platform bus/mfd core.
 * Device drivers are not well layered/separated.
 * It uses custom gpio accessors instead of using GPIOLIB.

With this patchset I tried to modernise and restructure the LoCoMo driver.
Also I added an experimental SPI driver that will be used by mmc-spi on
Sharp SL-5500 collie devices.

----------------------------------------------------------------
Dmitry Eremin-Solenikov (15):
      mfd: add new driver for Sharp LoCoMo
      GPIO: port LoCoMo gpio support from old driver
      leds: port locomo leds driver to new locomo core
      input: convert LoCoMo keyboard driver to use new locomo core
      video: backlight: add new locomo backlight driver
      video: lcd: add LoCoMo LCD driver
      video: backlight: drop old locomo bl/lcd driver
      ARM: sa1100: make collie use new locomo drivers
      ARM: sa1100: don't preallocate IRQ space for locomo
      ARM: pxa: poodle: use new LoCoMo driver
      sound: soc: poodle: make use of new locomo GPIO interface
      ARM: pxa: poodle: don't preallocate IRQ space for locomo
      ARM: drop old LoCoMo driver
      gpio: locomo: implement per-pin irq handling
      spi: add locomo SPI driver

 arch/arm/common/Kconfig                            |   3 -
 arch/arm/common/Makefile                           |   1 -
 arch/arm/common/locomo.c                           | 914 ---------------------
 arch/arm/mach-pxa/Kconfig                          |   1 -
 arch/arm/mach-pxa/include/mach/poodle.h            |  16 +-
 arch/arm/mach-pxa/poodle.c                         |  23 +-
 arch/arm/mach-sa1100/Kconfig                       |   1 -
 arch/arm/mach-sa1100/collie.c                      | 112 +--
 arch/arm/mach-sa1100/include/mach/collie.h         |  25 +-
 arch/arm/mach-sa1100/include/mach/irqs.h           |  19 +-
 drivers/gpio/Kconfig                               |   7 +

28 more lines

[PATCH 02/15] GPIO: port LoCoMo gpio support from old driver

Message details and related content
Add gpiolib driver for gpio pins placed on the LoCoMo GA.

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
---
 drivers/gpio/Kconfig       |   7 ++
 drivers/gpio/Makefile      |   1 +
 drivers/gpio/gpio-locomo.c | 228 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 236 insertions(+)
 create mode 100644 drivers/gpio/gpio-locomo.c
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 0959ca9..11c03d4 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -457,6 +457,13 @@ config GPIO_TB10X
 	select GENERIC_IRQ_CHIP
 	select OF_GPIO
 
+config GPIO_LOCOMO
+	bool "Sharp LoCoMo GPIO support"
+	depends on MFD_LOCOMO
+	help
+	  Select this to support GPIO pins on Sharp LoCoMo Grid Array found
+	  in Sharp Zaurus collie and poodle models.
+
 comment "I2C GPIO expanders:"
 
 config GPIO_ARIZONA
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index e5d346c..ed73f63 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_GPIO_JANZ_TTL)	+= gpio-janz-ttl.o
 obj-$(CONFIG_GPIO_KEMPLD)	+= gpio-kempld.o
 obj-$(CONFIG_ARCH_KS8695)	+= gpio-ks8695.o
 obj-$(CONFIG_GPIO_INTEL_MID)	+= gpio-intel-mid.o
+obj-$(CONFIG_GPIO_LOCOMO)	+= gpio-locomo.o
 obj-$(CONFIG_GPIO_LP3943)	+= gpio-lp3943.o
 obj-$(CONFIG_ARCH_LPC32XX)	+= gpio-lpc32xx.o
 obj-$(CONFIG_GPIO_LYNXPOINT)	+= gpio-lynxpoint.o
diff --git a/drivers/gpio/gpio-locomo.c b/drivers/gpio/gpio-locomo.c
new file mode 100644
index 0000000..3b54b07
--- /dev/null
+++ b/drivers/gpio/gpio-locomo.c
@@ -0,0 +1,228 @@
+/*
+ * Sharp LoCoMo support for GPIO
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This file contains all generic LoCoMo support.
+ *
+ * All initialization functions provided here are intended to be called
+ * from machine specific code with proper arguments when required.
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/gpio.h>
+#include <linux/io.h>
+#include <linux/spinlock.h>
+#include <linux/mfd/locomo.h>
+
+struct locomo_gpio {
+	void __iomem *regs;
+
+	spinlock_t lock;
+	struct gpio_chip gpio;
+
+	u16 rising_edge;
+	u16 falling_edge;
+
+	u16 save_gpo;
+	u16 save_gpe;
+};
+
+static int locomo_gpio_get(struct gpio_chip *chip,
+		unsigned offset)
+{
+	struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio);
+
+	return readw(lg->regs + LOCOMO_GPL) & (1 << offset);
+}
+
+static void __locomo_gpio_set(struct gpio_chip *chip,
+		unsigned offset, int value)
+{
+	struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio);
+	u16  r;
+
+	r = readw(lg->regs + LOCOMO_GPO);
+	if (value)
+		r |= 1 << offset;
+	else
+		r &= ~(1 << offset);
+	writew(r, lg->regs + LOCOMO_GPO);
+}
+
+static void locomo_gpio_set(struct gpio_chip *chip,
+		unsigned offset, int value)
+{
+	struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio);
+	unsigned long flags;
+
+	spin_lock_irqsave(&lg->lock, flags);
+
+	__locomo_gpio_set(chip, offset, value);
+
+	spin_unlock_irqrestore(&lg->lock, flags);
+}
+
+static int locomo_gpio_direction_input(struct gpio_chip *chip,
+			unsigned offset)
+{
+	struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio);
+	unsigned long flags;
+	u16 r;
+
+	spin_lock_irqsave(&lg->lock, flags);
+
+	r = readw(lg->regs + LOCOMO_GPD);
+	r |= (1 << offset);
+	writew(r, lg->regs + LOCOMO_GPD);
+
+	r = readw(lg->regs + LOCOMO_GPE);
+	r |= (1 << offset);
+	writew(r, lg->regs + LOCOMO_GPE);
+
+	spin_unlock_irqrestore(&lg->lock, flags);
+
+	return 0;
+}
+
+static int locomo_gpio_direction_output(struct gpio_chip *chip,
+			unsigned offset, int value)
+{
+	struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio);
+	unsigned long flags;
+	u16 r;
+
+	spin_lock_irqsave(&lg->lock, flags);
+
+	__locomo_gpio_set(chip, offset, value);
+
+	r = readw(lg->regs + LOCOMO_GPD);
+	r &= ~(1 << offset);
+	writew(r, lg->regs + LOCOMO_GPD);
+
+	r = readw(lg->regs + LOCOMO_GPE);
+	r &= ~(1 << offset);
+	writew(r, lg->regs + LOCOMO_GPE);
+
+	spin_unlock_irqrestore(&lg->lock, flags);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int locomo_gpio_suspend(struct device *dev)
+{
+	struct locomo_gpio *lg = dev_get_drvdata(dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&lg->lock, flags);
+
+	lg->save_gpo = readw(lg->regs + LOCOMO_GPO);
+	writew(0x00, lg->regs + LOCOMO_GPO);
+
+	lg->save_gpo = readw(lg->regs + LOCOMO_GPE);
+	writew(0x00, lg->regs + LOCOMO_GPE);
+
+	spin_unlock_irqrestore(&lg->lock, flags);
+	return 0;
+}
+
+static int locomo_gpio_resume(struct device *dev)
+{
+	struct locomo_gpio *lg = dev_get_drvdata(dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&lg->lock, flags);
+
+	writew(lg->save_gpo, lg->regs + LOCOMO_GPO);
+
+	writew(lg->save_gpe, lg->regs + LOCOMO_GPE);
+
+	spin_unlock_irqrestore(&lg->lock, flags);
+	return 0;
+}
+static SIMPLE_DEV_PM_OPS(locomo_gpio_pm,
+		locomo_gpio_suspend, locomo_gpio_resume);
+#define LOCOMO_GPIO_PM	(&locomo_gpio_pm)
+#else
+#define LOCOMO_GPIO_PM	NULL
+#endif
+
+static int locomo_gpio_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+	struct locomo_gpio *lg;
+	int ret;
+	struct locomo_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	lg = devm_kzalloc(&pdev->dev, sizeof(struct locomo_gpio),
+			GFP_KERNEL);
+	if (!lg)
+		return -ENOMEM;
+
+	lg->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(lg->regs))
+		return PTR_ERR(lg->regs);
+
+	spin_lock_init(&lg->lock);
+
+	platform_set_drvdata(pdev, lg);
+
+	writew(0, lg->regs + LOCOMO_GPO);
+	writew(0, lg->regs + LOCOMO_GPE);
+	writew(0, lg->regs + LOCOMO_GPD);
+	writew(0, lg->regs + LOCOMO_GIE);
+
+	lg->gpio.base = pdata ? pdata->gpio_base : -1;
+	lg->gpio.label = "locomo-gpio";
+	lg->gpio.ngpio = 16;
+	lg->gpio.set = locomo_gpio_set;
+	lg->gpio.get = locomo_gpio_get;
+	lg->gpio.direction_input = locomo_gpio_direction_input;
+	lg->gpio.direction_output = locomo_gpio_direction_output;
+
+	ret = gpiochip_add(&lg->gpio);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int locomo_gpio_remove(struct platform_device *pdev)
+{
+	struct locomo_gpio *lg = platform_get_drvdata(pdev);
+	int ret;
+
+	ret = gpiochip_remove(&lg->gpio);
+	if (ret) {
+		dev_err(&pdev->dev, "Can't remove gpio chip: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static struct platform_driver locomo_gpio_driver = {
+	.probe		= locomo_gpio_probe,
+	.remove		= locomo_gpio_remove,
+	.driver		= {
+		.name	= "locomo-gpio",
+		.owner	= THIS_MODULE,
+		.pm	= LOCOMO_GPIO_PM,
+	},
+};
+module_platform_driver(locomo_gpio_driver);
+
+MODULE_DESCRIPTION("Sharp LoCoMo GPIO driver");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>");
+MODULE_ALIAS("platform:locomo-gpio");
-- 
2.1.1

[PATCH 03/15] leds: port locomo leds driver to new locomo core

Message details and related content
Adapt locomo leds driver to new locomo core setup.

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
---
 drivers/leds/Kconfig       |   1 -
 drivers/leds/leds-locomo.c | 104 +++++++++++++++++++++++++++------------------
 2 files changed, 62 insertions(+), 43 deletions(-)
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index a210338..22ebf1c 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -69,7 +69,6 @@ config LEDS_LM3642
 config LEDS_LOCOMO
 	tristate "LED Support for Locomo device"
 	depends on LEDS_CLASS
-	depends on SHARP_LOCOMO
 	help
 	  This option enables support for the LEDs on Sharp Locomo.
 	  Zaurus models SL-5500 and SL-5600.
diff --git a/drivers/leds/leds-locomo.c b/drivers/leds/leds-locomo.c
index 80ba048..acb288f 100644
--- a/drivers/leds/leds-locomo.c
+++ b/drivers/leds/leds-locomo.c
@@ -11,87 +11,107 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/leds.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/mfd/locomo.h>
 
-#include <mach/hardware.h>
-#include <asm/hardware/locomo.h>
+struct locomo_led {
+	struct led_classdev led;
+	void __iomem *reg;
+};
 
 static void locomoled_brightness_set(struct led_classdev *led_cdev,
-				enum led_brightness value, int offset)
+				enum led_brightness value)
 {
-	struct locomo_dev *locomo_dev = LOCOMO_DEV(led_cdev->dev->parent);
+	struct locomo_led *led = container_of(led_cdev, struct locomo_led, led);
 	unsigned long flags;
 
 	local_irq_save(flags);
 	if (value)
-		locomo_writel(LOCOMO_LPT_TOFH, locomo_dev->mapbase + offset);
+		writew(LOCOMO_LPT_TOFH, led->reg);
 	else
-		locomo_writel(LOCOMO_LPT_TOFL, locomo_dev->mapbase + offset);
+		writew(LOCOMO_LPT_TOFL, led->reg);
 	local_irq_restore(flags);
 }
 
-static void locomoled_brightness_set0(struct led_classdev *led_cdev,
-				enum led_brightness value)
+static int locomo_led_register(
+		struct locomo_led *led,
+		struct device *dev,
+		const char *name,
+		const char *trigger,
+		void __iomem *reg)
 {
-	locomoled_brightness_set(led_cdev, value, LOCOMO_LPT0);
+	led->led.name = name;
+	led->led.default_trigger = trigger;
+	led->led.brightness_set = locomoled_brightness_set;
+	led->reg = reg;
+
+	return led_classdev_register(dev, &led->led);
 }
 
-static void locomoled_brightness_set1(struct led_classdev *led_cdev,
-				enum led_brightness value)
+static int locomoled_probe(struct platform_device *pdev)
 {
-	locomoled_brightness_set(led_cdev, value, LOCOMO_LPT1);
-}
+	int ret;
+	struct resource *mem;
+	void __iomem *regs;
+	struct locomo_led *leds;
 
-static struct led_classdev locomo_led0 = {
-	.name			= "locomo:amber:charge",
-	.default_trigger	= "main-battery-charging",
-	.brightness_set		= locomoled_brightness_set0,
-};
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!mem)
+		return -EINVAL;
 
-static struct led_classdev locomo_led1 = {
-	.name			= "locomo:green:mail",
-	.default_trigger	= "nand-disk",
-	.brightness_set		= locomoled_brightness_set1,
-};
+	regs = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
 
-static int locomoled_probe(struct locomo_dev *ldev)
-{
-	int ret;
+	leds = devm_kzalloc(&pdev->dev, 2 * sizeof(*leds), GFP_KERNEL);
+	if (!leds)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, leds);
 
-	ret = led_classdev_register(&ldev->dev, &locomo_led0);
+	ret = locomo_led_register(leds,
+			&pdev->dev,
+			"locomo:amber:charge",
+			"main-battery-charging",
+			regs + LOCOMO_LPT0);
 	if (ret < 0)
 		return ret;
 
-	ret = led_classdev_register(&ldev->dev, &locomo_led1);
+	ret = locomo_led_register(leds + 1,
+			&pdev->dev,
+			"locomo:green:mail",
+			"nand-disk",
+			regs + LOCOMO_LPT1);
 	if (ret < 0)
-		led_classdev_unregister(&locomo_led0);
+		led_classdev_unregister(&leds[0].led);
 
 	return ret;
 }
 
-static int locomoled_remove(struct locomo_dev *dev)
+static int locomoled_remove(struct platform_device *pdev)
 {
-	led_classdev_unregister(&locomo_led0);
-	led_classdev_unregister(&locomo_led1);
+	struct locomo_led *leds = platform_get_drvdata(pdev);
+
+	led_classdev_unregister(&leds[0].led);
+	led_classdev_unregister(&leds[1].led);
+
 	return 0;
 }
 
-static struct locomo_driver locomoled_driver = {
-	.drv = {
-		.name = "locomoled"
+static struct platform_driver locomoled_driver = {
+	.driver = {
+		.name = "locomo-led"
 	},
-	.devid	= LOCOMO_DEVID_LED,
 	.probe	= locomoled_probe,
 	.remove	= locomoled_remove,
 };
 
-static int __init locomoled_init(void)
-{
-	return locomo_driver_register(&locomoled_driver);
-}
-module_init(locomoled_init);
+module_platform_driver(locomoled_driver);
 
 MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>");
 MODULE_DESCRIPTION("Locomo LED driver");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:locomo-led");
-- 
2.1.1

[PATCH 05/15] video: backlight: add new locomo backlight driver

Message details and related content
Add new simple backlight driver - it cares only about PWM/frontlight
part of LoCoMo, it does not touch TFT settings and does not export TFT
power control.

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
---
 drivers/video/backlight/Kconfig     |   6 +-
 drivers/video/backlight/Makefile    |   2 +-
 drivers/video/backlight/locomo_bl.c | 171 ++++++++++++++++++++++++++++++++++++
 3 files changed, 175 insertions(+), 4 deletions(-)
 create mode 100644 drivers/video/backlight/locomo_bl.c
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 8d03924..03b77b33 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -218,12 +218,12 @@ config BACKLIGHT_LM3533
 	  levels.
 
 config BACKLIGHT_LOCOMO
-	tristate "Sharp LOCOMO LCD/Backlight Driver"
-	depends on SHARP_LOCOMO
+	tristate "Sharp LOCOMO Backlight 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/backlight driver.
+	  enable the backlight driver.
 
 config BACKLIGHT_OMAP1
 	tristate "OMAP1 PWL-based LCD Backlight"
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index fcd50b73..2a61b7e 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -39,7 +39,7 @@ obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO)	+= ipaq_micro_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3533)		+= lm3533_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3630A)		+= lm3630a_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3639)		+= lm3639_bl.o
-obj-$(CONFIG_BACKLIGHT_LOCOMO)		+= locomolcd.o
+obj-$(CONFIG_BACKLIGHT_LOCOMO)		+= locomo_bl.o
 obj-$(CONFIG_BACKLIGHT_LP855X)		+= lp855x_bl.o
 obj-$(CONFIG_BACKLIGHT_LP8788)		+= lp8788_bl.o
 obj-$(CONFIG_BACKLIGHT_LV5207LP)	+= lv5207lp.o
diff --git a/drivers/video/backlight/locomo_bl.c b/drivers/video/backlight/locomo_bl.c
new file mode 100644
index 0000000..cec1b51
--- /dev/null
+++ b/drivers/video/backlight/locomo_bl.c
@@ -0,0 +1,171 @@
+/*
+ * 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.
+ */
+
+#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/mfd/locomo.h>
+
+struct locomo_bl {
+	void __iomem *regs;
+	int current_intensity;
+	int gpio_fl_vr;
+};
+
+static const struct {
+	u16 duty, bpwf;
+	bool vr;
+} locomo_bl_pwm[] = {
+	{ 0, 161, false },
+	{ 117, 161, false },
+	{ 163, 148, false },
+	{ 194, 161, false },
+	{ 194, 161, true },
+};
+
+static int locomo_bl_set_intensity(struct backlight_device *bd)
+{
+	int intensity = bd->props.brightness;
+	struct locomo_bl *bl = dev_get_drvdata(&bd->dev);
+
+	if (bd->props.power != FB_BLANK_UNBLANK)
+		intensity = 0;
+	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+		intensity = 0;
+	if (bd->props.state & BL_CORE_SUSPENDED)
+		intensity = 0;
+
+	gpio_set_value(bl->gpio_fl_vr, locomo_bl_pwm[intensity].vr);
+
+	writew(locomo_bl_pwm[intensity].bpwf, bl->regs + LOCOMO_ALS);
+	udelay(100);
+	writew(locomo_bl_pwm[intensity].duty, bl->regs + LOCOMO_ALD);
+	udelay(100);
+	writew(locomo_bl_pwm[intensity].bpwf | LOCOMO_ALC_EN,
+			bl->regs + LOCOMO_ALS);
+
+	bl->current_intensity = intensity;
+	if (bd->props.state & BL_CORE_SUSPENDED)
+		writew(0x00, bl->regs + LOCOMO_ALS);
+
+	return 0;
+}
+
+static int locomo_bl_get_intensity(struct backlight_device *bd)
+{
+	struct locomo_bl *bl = dev_get_drvdata(&bd->dev);
+
+	return bl->current_intensity;
+}
+
+static const struct backlight_ops locomo_bl_ops = {
+	.options	= BL_CORE_SUSPENDRESUME,
+	.get_brightness = locomo_bl_get_intensity,
+	.update_status  = locomo_bl_set_intensity,
+};
+
+static int locomo_bl_probe(struct platform_device *dev)
+{
+	struct backlight_properties props;
+	struct resource *res;
+	struct locomo_bl_platform_data *pdata;
+	struct locomo_bl *bl;
+	struct backlight_device *locomo_bl_device;
+	int rc;
+
+	bl = devm_kmalloc(&dev->dev, sizeof(struct locomo_bl), GFP_KERNEL);
+	if (!bl)
+		return -ENOMEM;
+
+	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
+	bl->regs = devm_ioremap_resource(&dev->dev, res);
+	if (!bl->regs)
+		return -EINVAL;
+
+	pdata = dev_get_platdata(&dev->dev);
+	if (!pdata)
+		return -EINVAL;
+
+	bl->gpio_fl_vr = pdata->gpio_fl_vr;
+	rc = devm_gpio_request_one(&dev->dev, bl->gpio_fl_vr,
+			GPIOF_OUT_INIT_LOW, "FL VR");
+	if (rc)
+		return rc;
+
+	writew(0, bl->regs + LOCOMO_ALS);
+	writew(0, bl->regs + LOCOMO_ALD);
+
+	memset(&props, 0, sizeof(struct backlight_properties));
+	props.type = BACKLIGHT_RAW;
+	props.max_brightness = ARRAY_SIZE(locomo_bl_pwm) - 1;
+	props.brightness = props.max_brightness / 2;
+	locomo_bl_device = backlight_device_register("locomo-bl",
+						&dev->dev, bl,
+						&locomo_bl_ops, &props);
+
+	if (IS_ERR(locomo_bl_device))
+		return PTR_ERR(locomo_bl_device);
+
+	platform_set_drvdata(dev, locomo_bl_device);
+
+	/* Set up frontlight so that screen is readable */
+	backlight_update_status(locomo_bl_device);
+
+	return 0;
+}
+
+static int locomo_bl_remove(struct platform_device *dev)
+{
+	struct backlight_device *locomo_bl_device = platform_get_drvdata(dev);
+
+	locomo_bl_device->props.brightness = 0;
+	locomo_bl_device->props.power = 0;
+	locomo_bl_set_intensity(locomo_bl_device);
+
+	backlight_device_unregister(locomo_bl_device);
+
+	return 0;
+}
+
+static void locomo_bl_shutdown(struct platform_device *dev)
+{
+	struct backlight_device *locomo_bl_device = platform_get_drvdata(dev);
+
+	locomo_bl_device->props.brightness = 0;
+	locomo_bl_device->props.power = 0;
+	locomo_bl_set_intensity(locomo_bl_device);
+}
+
+static struct platform_driver locomo_bl_driver = {
+	.driver = {
+		.name	= "locomo-backlight",
+		.owner	= THIS_MODULE,
+	},
+	.probe	= locomo_bl_probe,
+	.remove	= locomo_bl_remove,
+	/* Turn off bl on power off/reboot */
+	.shutdown = locomo_bl_shutdown,
+};
+
+module_platform_driver(locomo_bl_driver);
+
+MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>, Pavel Machek <pavel@ucw.cz>");
+MODULE_DESCRIPTION("Collie Backlight driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:locomo-backlight");
-- 
2.1.1

[PATCH 07/15] video: backlight: drop old locomo bl/lcd driver

Message details and related content
Old locomolcd driver is now completely obsolete by new locomo_bl and
locomo_lcd drivers, so let's drop it.

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
---
 drivers/video/backlight/locomolcd.c | 255 ------------------------------------
 1 file changed, 255 deletions(-)
 delete mode 100644 drivers/video/backlight/locomolcd.c
diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
deleted file mode 100644
index 6c3ec42..0000000
--- a/drivers/video/backlight/locomolcd.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * 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/delay.h>
-#include <linux/device.h>
-#include <linux/interrupt.h>
-#include <linux/fb.h>
-#include <linux/backlight.h>
-
-#include <asm/hardware/locomo.h>
-#include <asm/irq.h>
-#include <asm/mach/sharpsl_param.h>
-#include <asm/mach-types.h>
-
-#include "../../../arch/arm/mach-sa1100/generic.h"
-
-static struct backlight_device *locomolcd_bl_device;
-static struct locomo_dev *locomolcd_dev;
-static unsigned long locomolcd_flags;
-#define LOCOMOLCD_SUSPENDED     0x01
-
-static void locomolcd_on(int comadj)
-{
-	locomo_gpio_set_dir(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_VSHA_ON, 0);
-	locomo_gpio_write(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_VSHA_ON, 1);
-	mdelay(2);
-
-	locomo_gpio_set_dir(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_VSHD_ON, 0);
-	locomo_gpio_write(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_VSHD_ON, 1);
-	mdelay(2);
-
-	locomo_m62332_senddata(locomolcd_dev, comadj, 0);
-	mdelay(5);
-
-	locomo_gpio_set_dir(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_VEE_ON, 0);
-	locomo_gpio_write(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_VEE_ON, 1);
-	mdelay(10);
-
-	/* TFTCRST | CPSOUT=0 | CPSEN */
-	locomo_writel(0x01, locomolcd_dev->mapbase + LOCOMO_TC);
-
-	/* Set CPSD */
-	locomo_writel(6, locomolcd_dev->mapbase + LOCOMO_CPSD);
-
-	/* TFTCRST | CPSOUT=0 | CPSEN */
-	locomo_writel((0x04 | 0x01), locomolcd_dev->mapbase + LOCOMO_TC);
-	mdelay(10);
-
-	locomo_gpio_set_dir(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_MOD, 0);
-	locomo_gpio_write(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_MOD, 1);
-}
-
-static void locomolcd_off(int comadj)
-{
-	/* TFTCRST=1 | CPSOUT=1 | CPSEN = 0 */
-	locomo_writel(0x06, locomolcd_dev->mapbase + LOCOMO_TC);
-	mdelay(1);
-
-	locomo_gpio_write(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_VSHA_ON, 0);
-	mdelay(110);
-
-	locomo_gpio_write(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_VEE_ON, 0);
-	mdelay(700);
-
-	/* TFTCRST=0 | CPSOUT=0 | CPSEN = 0 */
-	locomo_writel(0, locomolcd_dev->mapbase + LOCOMO_TC);
-	locomo_gpio_write(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_MOD, 0);
-	locomo_gpio_write(locomolcd_dev->dev.parent, LOCOMO_GPIO_LCD_VSHD_ON, 0);
-}
-
-void locomolcd_power(int on)
-{
-	int comadj = sharpsl_param.comadj;
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	if (!locomolcd_dev) {
-		local_irq_restore(flags);
-		return;
-	}
-
-	/* read comadj */
-	if (comadj = -1 && machine_is_collie())
-		comadj = 128;
-	if (comadj = -1 && machine_is_poodle())
-		comadj = 118;
-
-	if (on)
-		locomolcd_on(comadj);
-	else
-		locomolcd_off(comadj);
-
-	local_irq_restore(flags);
-}
-EXPORT_SYMBOL(locomolcd_power);
-
-static int current_intensity;
-
-static int locomolcd_set_intensity(struct backlight_device *bd)
-{
-	int intensity = bd->props.brightness;
-
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (locomolcd_flags & LOCOMOLCD_SUSPENDED)
-		intensity = 0;
-
-	switch (intensity) {
-	/*
-	 * AC and non-AC are handled differently,
-	 * but produce same results in sharp code?
-	 */
-	case 0:
-		locomo_frontlight_set(locomolcd_dev, 0, 0, 161);
-		break;
-	case 1:
-		locomo_frontlight_set(locomolcd_dev, 117, 0, 161);
-		break;
-	case 2:
-		locomo_frontlight_set(locomolcd_dev, 163, 0, 148);
-		break;
-	case 3:
-		locomo_frontlight_set(locomolcd_dev, 194, 0, 161);
-		break;
-	case 4:
-		locomo_frontlight_set(locomolcd_dev, 194, 1, 161);
-		break;
-	default:
-		return -ENODEV;
-	}
-	current_intensity = intensity;
-	return 0;
-}
-
-static int locomolcd_get_intensity(struct backlight_device *bd)
-{
-	return current_intensity;
-}
-
-static const struct backlight_ops locomobl_data = {
-	.get_brightness = locomolcd_get_intensity,
-	.update_status  = locomolcd_set_intensity,
-};
-
-#ifdef CONFIG_PM_SLEEP
-static int locomolcd_suspend(struct device *dev)
-{
-	locomolcd_flags |= LOCOMOLCD_SUSPENDED;
-	locomolcd_set_intensity(locomolcd_bl_device);
-	return 0;
-}
-
-static int locomolcd_resume(struct device *dev)
-{
-	locomolcd_flags &= ~LOCOMOLCD_SUSPENDED;
-	locomolcd_set_intensity(locomolcd_bl_device);
-	return 0;
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(locomolcd_pm_ops, locomolcd_suspend, locomolcd_resume);
-
-static int locomolcd_probe(struct locomo_dev *ldev)
-{
-	struct backlight_properties props;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	locomolcd_dev = ldev;
-
-	locomo_gpio_set_dir(ldev->dev.parent, LOCOMO_GPIO_FL_VR, 0);
-
-	/*
-	 * the poodle_lcd_power function is called for the first time
-	 * from fs_initcall, which is before locomo is activated.
-	 * We need to recall poodle_lcd_power here
-	 */
-	if (machine_is_poodle())
-		locomolcd_power(1);
-
-	local_irq_restore(flags);
-
-	memset(&props, 0, sizeof(struct backlight_properties));
-	props.type = BACKLIGHT_RAW;
-	props.max_brightness = 4;
-	locomolcd_bl_device = backlight_device_register("locomo-bl",
-							&ldev->dev, NULL,
-							&locomobl_data, &props);
-
-	if (IS_ERR(locomolcd_bl_device))
-		return PTR_ERR(locomolcd_bl_device);
-
-	/* Set up frontlight so that screen is readable */
-	locomolcd_bl_device->props.brightness = 2;
-	locomolcd_set_intensity(locomolcd_bl_device);
-
-	return 0;
-}
-
-static int locomolcd_remove(struct locomo_dev *dev)
-{
-	unsigned long flags;
-
-	locomolcd_bl_device->props.brightness = 0;
-	locomolcd_bl_device->props.power = 0;
-	locomolcd_set_intensity(locomolcd_bl_device);
-
-	backlight_device_unregister(locomolcd_bl_device);
-	local_irq_save(flags);
-	locomolcd_dev = NULL;
-	local_irq_restore(flags);
-	return 0;
-}
-
-static struct locomo_driver poodle_lcd_driver = {
-	.drv = {
-		.name	= "locomo-backlight",
-		.pm	= &locomolcd_pm_ops,
-	},
-	.devid	= LOCOMO_DEVID_BACKLIGHT,
-	.probe	= locomolcd_probe,
-	.remove	= locomolcd_remove,
-};
-
-static int __init locomolcd_init(void)
-{
-	return locomo_driver_register(&poodle_lcd_driver);
-}
-
-static void __exit locomolcd_exit(void)
-{
-	locomo_driver_unregister(&poodle_lcd_driver);
-}
-
-module_init(locomolcd_init);
-module_exit(locomolcd_exit);
-
-MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>, Pavel Machek <pavel@ucw.cz>");
-MODULE_DESCRIPTION("Collie LCD driver");
-MODULE_LICENSE("GPL");
-- 
2.1.1

[PATCH 06/15] video: lcd: add LoCoMo LCD driver

Message details and related content
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 <redacted>
---
 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
 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>
+
+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);
+
+	/* 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);
+
+	/* 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;
+
+	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,
+			&locomo_lcd_ops);
+
+	return 0;
+}
+
+static int locomolcd_remove(struct platform_device *dev)
+{
+	unsigned long flags;
+
+	lcd_device_unregister(lcd_dev);
+
+	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>");
+MODULE_DESCRIPTION("Collie LCD driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:locomo-lcd");
-- 
2.1.1

[PATCH 09/15] ARM: sa1100: don't preallocate IRQ space for locomo

Message details and related content
As new locomo driver properly supports SPARSE_IRQ, stop playing with
NR_IRQS on sa1100 (locomo was the last chip requiring NR_IRQ tricks).

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
---
 arch/arm/mach-sa1100/include/mach/irqs.h | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/arch/arm/mach-sa1100/include/mach/irqs.h b/arch/arm/mach-sa1100/include/mach/irqs.h
index 3790298..99e7202 100644
--- a/arch/arm/mach-sa1100/include/mach/irqs.h
+++ b/arch/arm/mach-sa1100/include/mach/irqs.h
@@ -68,22 +68,7 @@
 #define IRQ_BOARD_START		49
 #define IRQ_BOARD_END		65
 
-/*
- * Figure out the MAX IRQ number.
- *
- * Neponset, SA1111 and UCB1x00 are sparse IRQ aware, so can dynamically
- * allocate their IRQs above NR_IRQS.
- *
- * LoCoMo has 4 additional IRQs, but is not sparse IRQ aware, and so has
- * to be included in the NR_IRQS calculation.
- */
-#ifdef CONFIG_SHARP_LOCOMO
-#define NR_IRQS_LOCOMO		4
-#else
-#define NR_IRQS_LOCOMO		0
-#endif
-
 #ifndef NR_IRQS
-#define NR_IRQS (IRQ_BOARD_START + NR_IRQS_LOCOMO)
+#define NR_IRQS IRQ_BOARD_START
 #endif
-#define SA1100_NR_IRQS (IRQ_BOARD_START + NR_IRQS_LOCOMO)
+#define SA1100_NR_IRQS IRQ_BOARD_START
-- 
2.1.1

[PATCH 10/15] ARM: pxa: poodle: use new LoCoMo driver

Message details and related content
Convert poodle to use new mfd-based LoCoMo driver.

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
---
 arch/arm/mach-pxa/Kconfig               |  1 -
 arch/arm/mach-pxa/include/mach/poodle.h | 14 +++++++++-----
 arch/arm/mach-pxa/poodle.c              | 19 +++++++++++++++----
 3 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index e6690a4..1da3e8f 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -473,7 +473,6 @@ config MACH_POODLE
 	bool "Enable Sharp SL-5600 (Poodle) Support"
 	depends on PXA_SHARPSL
 	select PXA25x
-	select SHARP_LOCOMO
 
 config MACH_CORGI
 	bool "Enable Sharp SL-C700 (Corgi) Support"
diff --git a/arch/arm/mach-pxa/include/mach/poodle.h b/arch/arm/mach-pxa/include/mach/poodle.h
index b56b193..e8eb51e 100644
--- a/arch/arm/mach-pxa/include/mach/poodle.h
+++ b/arch/arm/mach-pxa/include/mach/poodle.h
@@ -81,11 +81,15 @@
 #define POODLE_GPIO_L_LCLK	(POODLE_SCOOP_GPIO_BASE + 10)
 #define POODLE_GPIO_HS_OUT	(POODLE_SCOOP_GPIO_BASE + 11)
 
-#define POODLE_LOCOMO_GPIO_AMP_ON      LOCOMO_GPIO(8)
-#define POODLE_LOCOMO_GPIO_MUTE_L      LOCOMO_GPIO(10)
-#define POODLE_LOCOMO_GPIO_MUTE_R      LOCOMO_GPIO(11)
-#define POODLE_LOCOMO_GPIO_232VCC_ON   LOCOMO_GPIO(12)
-#define POODLE_LOCOMO_GPIO_JK_B        LOCOMO_GPIO(13)
+#define POODLE_LOCOMO_GPIO_BASE	(PXA_NR_BUILTIN_GPIO + 12)
+#define POODLE_GPIO_LCD_VSHA_ON	(POODLE_LOCOMO_GPIO_BASE + 4)
+#define POODLE_GPIO_LCD_VSHD_ON	(POODLE_LOCOMO_GPIO_BASE + 5)
+#define POODLE_GPIO_LCD_VEE_ON	(POODLE_LOCOMO_GPIO_BASE + 6)
+#define POODLE_GPIO_LCD_MOD	(POODLE_LOCOMO_GPIO_BASE + 7)
+#define POODLE_GPIO_AMP_ON	(POODLE_LOCOMO_GPIO_BASE + 8)
+#define POODLE_GPIO_FL_VR	(POODLE_LOCOMO_GPIO_BASE + 9)
+#define POODLE_GPIO_MUTE_L	(POODLE_LOCOMO_GPIO_BASE + 10)
+#define POODLE_GPIO_MUTE_R	(POODLE_LOCOMO_GPIO_BASE + 11)
 
 #define POODLE_NR_IRQS		(IRQ_BOARD_START + 4)	/* 4 for LoCoMo */
 
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 1319916..3041d83 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -30,6 +30,7 @@
 #include <linux/spi/pxa2xx_spi.h>
 #include <linux/mtd/sharpsl.h>
 #include <linux/memblock.h>
+#include <linux/mfd/locomo.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -48,7 +49,6 @@
 #include <linux/platform_data/video-pxafb.h>
 
 #include <asm/hardware/scoop.h>
-#include <asm/hardware/locomo.h>
 #include <asm/mach/sharpsl_param.h>
 
 #include "generic.h"
@@ -178,7 +178,17 @@ static struct resource locomo_resources[] = {
 };
 
 static struct locomo_platform_data locomo_info = {
-	.irq_base	= IRQ_BOARD_START,
+	.gpio_data = {
+		.gpio_base = POODLE_LOCOMO_GPIO_BASE,
+	},
+	.bl_data = {
+		.comadj	          = 118,
+		.gpio_lcd_vsha_on = POODLE_GPIO_LCD_VSHA_ON,
+		.gpio_lcd_vshd_on = POODLE_GPIO_LCD_VSHD_ON,
+		.gpio_lcd_vee_on  = POODLE_GPIO_LCD_VEE_ON,
+		.gpio_lcd_mod     = POODLE_GPIO_LCD_MOD,
+		.gpio_fl_vr       = POODLE_GPIO_FL_VR,
+	},
 };
 
 struct platform_device poodle_locomo_device = {
@@ -191,8 +201,6 @@ struct platform_device poodle_locomo_device = {
 	},
 };
 
-EXPORT_SYMBOL(poodle_locomo_device);
-
 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
 static struct pxa2xx_spi_master poodle_spi_info = {
 	.num_chipselect	= 1,
@@ -444,6 +452,9 @@ static void __init poodle_init(void)
 
 	platform_scoop_config = &poodle_pcmcia_config;
 
+	if (sharpsl_param.comadj != -1)
+		locomo_info.bl_data.comadj = sharpsl_param.comadj;
+
 	ret = platform_add_devices(devices, ARRAY_SIZE(devices));
 	if (ret)
 		pr_warning("poodle: Unable to register LoCoMo device\n");
-- 
2.1.1

[PATCH 11/15] sound: soc: poodle: make use of new locomo GPIO interface

Message details and related content
Since LoCoMo driver has been converted to provide proper gpiolib
interface, make poodle ASoC platform driver use gpiolib API.

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
---
 sound/soc/pxa/poodle.c | 51 ++++++++++++++++++++++++--------------------------
 1 file changed, 24 insertions(+), 27 deletions(-)
diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c
index 21f3400..a593bff 100644
--- a/sound/soc/pxa/poodle.c
+++ b/sound/soc/pxa/poodle.c
@@ -20,12 +20,12 @@
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/gpio.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/soc.h>
 
 #include <asm/mach-types.h>
-#include <asm/hardware/locomo.h>
 #include <mach/poodle.h>
 #include <mach/audio.h>
 
@@ -48,16 +48,12 @@ static void poodle_ext_control(struct snd_soc_dapm_context *dapm)
 	/* set up jack connection */
 	if (poodle_jack_func = POODLE_HP) {
 		/* set = unmute headphone */
-		locomo_gpio_write(&poodle_locomo_device.dev,
-			POODLE_LOCOMO_GPIO_MUTE_L, 1);
-		locomo_gpio_write(&poodle_locomo_device.dev,
-			POODLE_LOCOMO_GPIO_MUTE_R, 1);
+		gpio_set_value(POODLE_GPIO_MUTE_L, 1);
+		gpio_set_value(POODLE_GPIO_MUTE_R, 1);
 		snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
 	} else {
-		locomo_gpio_write(&poodle_locomo_device.dev,
-			POODLE_LOCOMO_GPIO_MUTE_L, 0);
-		locomo_gpio_write(&poodle_locomo_device.dev,
-			POODLE_LOCOMO_GPIO_MUTE_R, 0);
+		gpio_set_value(POODLE_GPIO_MUTE_L, 0);
+		gpio_set_value(POODLE_GPIO_MUTE_R, 0);
 		snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
 	}
 
@@ -85,10 +81,8 @@ static int poodle_startup(struct snd_pcm_substream *substream)
 static void poodle_shutdown(struct snd_pcm_substream *substream)
 {
 	/* set = unmute headphone */
-	locomo_gpio_write(&poodle_locomo_device.dev,
-		POODLE_LOCOMO_GPIO_MUTE_L, 1);
-	locomo_gpio_write(&poodle_locomo_device.dev,
-		POODLE_LOCOMO_GPIO_MUTE_R, 1);
+	gpio_set_value(POODLE_GPIO_MUTE_L, 1);
+	gpio_set_value(POODLE_GPIO_MUTE_R, 1);
 }
 
 static int poodle_hw_params(struct snd_pcm_substream *substream,
@@ -178,12 +172,7 @@ static int poodle_set_spk(struct snd_kcontrol *kcontrol,
 static int poodle_amp_event(struct snd_soc_dapm_widget *w,
 	struct snd_kcontrol *k, int event)
 {
-	if (SND_SOC_DAPM_EVENT_ON(event))
-		locomo_gpio_write(&poodle_locomo_device.dev,
-			POODLE_LOCOMO_GPIO_AMP_ON, 0);
-	else
-		locomo_gpio_write(&poodle_locomo_device.dev,
-			POODLE_LOCOMO_GPIO_AMP_ON, 1);
+	gpio_set_value(POODLE_GPIO_AMP_ON, !(SND_SOC_DAPM_EVENT_ON(event)));
 
 	return 0;
 }
@@ -263,25 +252,32 @@ static struct snd_soc_card poodle = {
 	.num_dapm_routes = ARRAY_SIZE(poodle_audio_map),
 };
 
+struct gpio poodle_gpios[] = {
+	{ POODLE_GPIO_AMP_ON, GPIOF_OUT_INIT_HIGH, "Amplifier" },
+	{ POODLE_GPIO_MUTE_L, GPIOF_OUT_INIT_LOW, "Mute left" },
+	{ POODLE_GPIO_MUTE_R, GPIOF_OUT_INIT_LOW, "Mute right" },
+};
+
 static int poodle_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = &poodle;
 	int ret;
 
-	locomo_gpio_set_dir(&poodle_locomo_device.dev,
-		POODLE_LOCOMO_GPIO_AMP_ON, 0);
-	/* should we mute HP at startup - burning power ?*/
-	locomo_gpio_set_dir(&poodle_locomo_device.dev,
-		POODLE_LOCOMO_GPIO_MUTE_L, 0);
-	locomo_gpio_set_dir(&poodle_locomo_device.dev,
-		POODLE_LOCOMO_GPIO_MUTE_R, 0);
+	ret = gpio_request_array(poodle_gpios, ARRAY_SIZE(poodle_gpios));
+	if (ret) {
+		dev_err(&pdev->dev, "gpio_request_array() failed: %d\n",
+				ret);
+		return ret;
+	}
 
 	card->dev = &pdev->dev;
 
 	ret = snd_soc_register_card(card);
-	if (ret)
+	if (ret) {
 		dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
 			ret);
+		gpio_free_array(poodle_gpios, ARRAY_SIZE(poodle_gpios));
+	}
 	return ret;
 }
 
@@ -290,6 +286,7 @@ static int poodle_remove(struct platform_device *pdev)
 	struct snd_soc_card *card = platform_get_drvdata(pdev);
 
 	snd_soc_unregister_card(card);
+	gpio_free_array(poodle_gpios, ARRAY_SIZE(poodle_gpios));
 	return 0;
 }
 
-- 
2.1.1
Message details and related content
On Tue, Oct 28, 2014 at 03:01:53AM +0300, Dmitry Eremin-Solenikov wrote:
Sharp Zaurus SL-5500 and SL-5600 use special companion Gate Array. Current
drivers present in Linux kernel has some problems:

 * It uses custom bus instead of platform bus/mfd core.
I believe Greg wouldn't see that as a positive point.

Don't think that the platform bus _should_ always be used.  It shouldn't
(Greg has said he'd like to see the platform bus to be totally killed off.)
Instead, custom buses properly suited to the class of device in question
is much preferred, especially if it aids in...
 * Device drivers are not well layered/separated.
... better layering or separation of drivers.

So, thinking that converting from a custom bus to a platform bus
definitely is /not/ a positive step forward.

(Why mfd was ever allowed to re-use the platform bus stuff is a separate
question not relevent to these patches.)

-- 
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.

Re: [PATCH 05/15] video: backlight: add new locomo backlight driver

Message details and related content
On Tuesday, October 28, 2014 9:02 AM, Dmitry Eremin-Solenikov wrote:
quoted hunk
Add new simple backlight driver - it cares only about PWM/frontlight
part of LoCoMo, it does not touch TFT settings and does not export TFT
power control.

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
---
 drivers/video/backlight/Kconfig     |   6 +-
 drivers/video/backlight/Makefile    |   2 +-
 drivers/video/backlight/locomo_bl.c | 171 ++++++++++++++++++++++++++++++++++++
 3 files changed, 175 insertions(+), 4 deletions(-)
 create mode 100644 drivers/video/backlight/locomo_bl.c
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 8d03924..03b77b33 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -218,12 +218,12 @@ config BACKLIGHT_LM3533
 	  levels.

 config BACKLIGHT_LOCOMO
-	tristate "Sharp LOCOMO LCD/Backlight Driver"
-	depends on SHARP_LOCOMO
+	tristate "Sharp LOCOMO Backlight 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/backlight driver.
+	  enable the backlight driver.

 config BACKLIGHT_OMAP1
 	tristate "OMAP1 PWL-based LCD Backlight"
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index fcd50b73..2a61b7e 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -39,7 +39,7 @@ obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO)	+= ipaq_micro_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3533)		+= lm3533_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3630A)		+= lm3630a_bl.o

33 more quoted lines

Please, re-order these headers alphabetically.
It enhances the readability.
quoted hunk
+
+struct locomo_bl {
+	void __iomem *regs;
+	int current_intensity;
+	int gpio_fl_vr;
+};
+
+static const struct {
+	u16 duty, bpwf;
+	bool vr;
+} locomo_bl_pwm[] = {
+	{ 0, 161, false },
+	{ 117, 161, false },
+	{ 163, 148, false },
+	{ 194, 161, false },
+	{ 194, 161, true },
+};
+
+static int locomo_bl_set_intensity(struct backlight_device *bd)
+{
+	int intensity = bd->props.brightness;
+	struct locomo_bl *bl = dev_get_drvdata(&bd->dev);
+
+	if (bd->props.power != FB_BLANK_UNBLANK)
+		intensity = 0;
+	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+		intensity = 0;
+	if (bd->props.state & BL_CORE_SUSPENDED)
+		intensity = 0;
+
+	gpio_set_value(bl->gpio_fl_vr, locomo_bl_pwm[intensity].vr);
+
+	writew(locomo_bl_pwm[intensity].bpwf, bl->regs + LOCOMO_ALS);
+	udelay(100);
+	writew(locomo_bl_pwm[intensity].duty, bl->regs + LOCOMO_ALD);
+	udelay(100);
How about changing udelay() to usleep_range()?
+	writew(locomo_bl_pwm[intensity].bpwf | LOCOMO_ALC_EN,
+			bl->regs + LOCOMO_ALS);
quoted hunk
+
+	bl->current_intensity = intensity;
+	if (bd->props.state & BL_CORE_SUSPENDED)
+		writew(0x00, bl->regs + LOCOMO_ALS);
+
+	return 0;
+}
+
+static int locomo_bl_get_intensity(struct backlight_device *bd)
+{
+	struct locomo_bl *bl = dev_get_drvdata(&bd->dev);
+
+	return bl->current_intensity;
+}
+
+static const struct backlight_ops locomo_bl_ops = {
+	.options	= BL_CORE_SUSPENDRESUME,
+	.get_brightness = locomo_bl_get_intensity,
+	.update_status  = locomo_bl_set_intensity,
+};
+
+static int locomo_bl_probe(struct platform_device *dev)
+{
+	struct backlight_properties props;
+	struct resource *res;
+	struct locomo_bl_platform_data *pdata;
+	struct locomo_bl *bl;
+	struct backlight_device *locomo_bl_device;
+	int rc;
+
+	bl = devm_kmalloc(&dev->dev, sizeof(struct locomo_bl), GFP_KERNEL);
+	if (!bl)
+		return -ENOMEM;
+
+	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
There is no need to check this, because devm_ioremap_resource()
will check this.
quoted hunk
+	bl->regs = devm_ioremap_resource(&dev->dev, res);
+	if (!bl->regs)
+		return -EINVAL;
The correct usage is as follows.

	if (IS_ERR(base))
		return PTR_ERR(base);

Please change it as below.

	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
	bl->regs = devm_ioremap_resource(&dev->dev, res);
	if (IS_ERR(bl->regs))
		 return PTR_ERR(bl->regs);
quoted hunk
+
+	pdata = dev_get_platdata(&dev->dev);
+	if (!pdata)
+		return -EINVAL;
+
+	bl->gpio_fl_vr = pdata->gpio_fl_vr;
+	rc = devm_gpio_request_one(&dev->dev, bl->gpio_fl_vr,
+			GPIOF_OUT_INIT_LOW, "FL VR");
+	if (rc)
+		return rc;
+
+	writew(0, bl->regs + LOCOMO_ALS);
+	writew(0, bl->regs + LOCOMO_ALD);
+
+	memset(&props, 0, sizeof(struct backlight_properties));
+	props.type = BACKLIGHT_RAW;
+	props.max_brightness = ARRAY_SIZE(locomo_bl_pwm) - 1;
+	props.brightness = props.max_brightness / 2;
+	locomo_bl_device = backlight_device_register("locomo-bl",
Please use devm_backlight_device_register().
+						&dev->dev, bl,
+						&locomo_bl_ops, &props);
quoted hunk
+
+	if (IS_ERR(locomo_bl_device))
+		return PTR_ERR(locomo_bl_device);
+
+	platform_set_drvdata(dev, locomo_bl_device);
+
+	/* Set up frontlight so that screen is readable */
+	backlight_update_status(locomo_bl_device);
+
+	return 0;
+}
+
+static int locomo_bl_remove(struct platform_device *dev)
+{
+	struct backlight_device *locomo_bl_device = platform_get_drvdata(dev);
+
+	locomo_bl_device->props.brightness = 0;
+	locomo_bl_device->props.power = 0;
+	locomo_bl_set_intensity(locomo_bl_device);
+
+	backlight_device_unregister(locomo_bl_device);
If devm_backlight_device_register() is used in probe(),
there is no need to call backlight_device_unregister() in remove().
quoted hunk
+
+	return 0;
+}
+
+static void locomo_bl_shutdown(struct platform_device *dev)
+{
+	struct backlight_device *locomo_bl_device = platform_get_drvdata(dev);
+
+	locomo_bl_device->props.brightness = 0;
+	locomo_bl_device->props.power = 0;
+	locomo_bl_set_intensity(locomo_bl_device);
+}
+
+static struct platform_driver locomo_bl_driver = {
+	.driver = {
+		.name	= "locomo-backlight",
+		.owner	= THIS_MODULE,
+	},
+	.probe	= locomo_bl_probe,
+	.remove	= locomo_bl_remove,
+	/* Turn off bl on power off/reboot */
+	.shutdown = locomo_bl_shutdown,
+};
+
+module_platform_driver(locomo_bl_driver);
+
+MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>, Pavel Machek <pavel@ucw.cz>");
This might make checkpatch warning.
Please split these authors to lines as below.

MODULE_AUTHOR("John Lenz [off-list ref]");
MODULE_AUTHOR("Pavel Machek [off-list ref]");
+MODULE_DESCRIPTION("Collie Backlight 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-backlight");
--
2.1.1
Message details and related content
On Tue, Oct 28, 2014 at 12:13:39AM +0000, Russell King - ARM Linux wrote:
On Tue, Oct 28, 2014 at 03:01:53AM +0300, Dmitry Eremin-Solenikov wrote:
quoted
Sharp Zaurus SL-5500 and SL-5600 use special companion Gate Array. Current
drivers present in Linux kernel has some problems:
quoted
 * It uses custom bus instead of platform bus/mfd core.
I believe Greg wouldn't see that as a positive point.
Don't think that the platform bus _should_ always be used.  It shouldn't
(Greg has said he'd like to see the platform bus to be totally killed off.)
Instead, custom buses properly suited to the class of device in question
is much preferred, especially if it aids in...
quoted
 * Device drivers are not well layered/separated.
... better layering or separation of drivers.
So, thinking that converting from a custom bus to a platform bus
definitely is /not/ a positive step forward.
(Why mfd was ever allowed to re-use the platform bus stuff is a separate
question not relevent to these patches.)
The reason we ended up reusing the platform bus so much was that
originally people were doing custom buses but people started complaining
that the code was (or should be) a cut'n'paste of the platform bus and
that this duplication was both not pretty and a bit tedious for anyone
doing anything that involved deploying good practice over a lot of
buses.  Early MFDs were actually MMIO devices so the platform bus was a
good fit, then people (including me when I upstreamed the wm97xx drivers
and apparently whoever worked on these devices) started adding custom
buses and then people complianed that we should reuse both the bus type
and the MFD infrastructure so here we are.

Probably a way of sharing the platform code but giving the bus another
name and bus_type would allow for better separation here.

Re: [PATCH 06/15] video: lcd: add LoCoMo LCD driver

Message details and related content
On Tuesday, October 28, 2014 9:02 AM, Dmitry Eremin-Solenikov wrote:
quoted hunk
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 <redacted>
---
 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.
quoted hunk
 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.
quoted hunk
+
+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()?
quoted hunk
+
+	/* 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()?
quoted hunk
+
+	/* 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;
+}
+

29 more quoted lines

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);
quoted hunk
+
+	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().
quoted hunk
+			&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().
quoted hunk
+
+	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 [off-list ref]");
MODULE_AUTHOR("Pavel Machek [off-list ref]");
+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

Re: [PATCH 06/15] video: lcd: add LoCoMo LCD driver

Message details and related content
On 10/28/2014 03:30 AM, Jingoo Han wrote:
On Tuesday, October 28, 2014 9:02 AM, Dmitry Eremin-Solenikov wrote:
quoted
LoCoMo has some special handling for TFT screens attached to Collie and
Poodle. Implement that as a separate driver.
Thanks for the review, changes for both LCD and Backlight will be 
implemented in V2.


-- 
With best wishes
Dmitry

Re: [PATCH 02/15] GPIO: port LoCoMo gpio support from old driver

Message details and related content
On Tue, Oct 28, 2014 at 1:01 AM, Dmitry Eremin-Solenikov
[off-list ref] wrote:
Add gpiolib driver for gpio pins placed on the LoCoMo GA.

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
(...)
quoted hunk
+static int locomo_gpio_get(struct gpio_chip *chip,
+               unsigned offset)
+{
+       struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio);
+
+       return readw(lg->regs + LOCOMO_GPL) & (1 << offset);
Do this:

#include <linux/bitops.h>

return !!(readw(lg->regs + LOCOMO_GPL) & BIT(offset));

So you clamp the returned value to a bool.
quoted hunk
+static void __locomo_gpio_set(struct gpio_chip *chip,
+               unsigned offset, int value)
+{
+       struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio);
+       u16  r;
+
+       r = readw(lg->regs + LOCOMO_GPO);
+       if (value)
+               r |= 1 << offset;
r |= BIT(offset);
+       else
+               r &= ~(1 << offset);
r &= BIT(offset);

(etc, everywhere this pattern occurs).
quoted hunk
+static void locomo_gpio_set(struct gpio_chip *chip,
+               unsigned offset, int value)
+{
+       struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio);
+       unsigned long flags;
+
+       spin_lock_irqsave(&lg->lock, flags);
+
+       __locomo_gpio_set(chip, offset, value);
+
+       spin_unlock_irqrestore(&lg->lock, flags);
If you actually always have to be getting and releasing a spin lock around
the register writes, contemplate using regmap-mmio because that
is part of what it does.

But is this locking really necessary?
quoted hunk
+static int locomo_gpio_remove(struct platform_device *pdev)
+{
+       struct locomo_gpio *lg = platform_get_drvdata(pdev);
+       int ret;
+
+       ret = gpiochip_remove(&lg->gpio);
+       if (ret) {
+               dev_err(&pdev->dev, "Can't remove gpio chip: %d\n", ret);
+               return ret;
+       }
The return value from gpiochip_remove() has been removed in v3.18-rc1
so this will not compile.

Yours,
Linus Walleij

Re: [PATCH 09/15] ARM: sa1100: don't preallocate IRQ space for locomo

Message details and related content
On Tue, Oct 28, 2014 at 1:02 AM, Dmitry Eremin-Solenikov
[off-list ref] wrote:
As new locomo driver properly supports SPARSE_IRQ, stop playing with
NR_IRQS on sa1100 (locomo was the last chip requiring NR_IRQ tricks).

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
That's right! By moving to irqdomain things get even better :)

Yours,
Linus Walleij

Re: [PATCH 09/15] ARM: sa1100: don't preallocate IRQ space for locomo

Message details and related content
2014-10-31 10:50 GMT+03:00 Linus Walleij [off-list ref]:
On Tue, Oct 28, 2014 at 1:02 AM, Dmitry Eremin-Solenikov
[off-list ref] wrote:
quoted
As new locomo driver properly supports SPARSE_IRQ, stop playing with
NR_IRQS on sa1100 (locomo was the last chip requiring NR_IRQ tricks).

Signed-off-by: Dmitry Eremin-Solenikov <redacted>
That's right! By moving to irqdomain things get even better :)
That is a separate topic in my repo. I'll push that after finishing with LoCoMo.


-- 
With best wishes
Dmitry
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help