linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO
@ 2011-12-11 20:11 Janusz Krzysztofik
  2011-12-11 20:11 ` [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore Janusz Krzysztofik
                   ` (12 more replies)
  0 siblings, 13 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:11 UTC (permalink / raw)
  To: Tony Lindgren, Grant Likely, Dmitry Torokhov, Richard Purdie,
	David Woodhouse, Tomi Valkeinen, Jarkko Nikula
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	linux-input, linux-mtd, linux-fbdev, alsa-devel, Liam Girdwood,
	Mark Brown

The Amstrad Delta board has two extra output ports used for driving
input lines of different on-board devices. Those ports are now
controlled with custom functions, provided by the board arch code and
used by several device drivers.

The idea behind the series is to replace those custom I/O functions
with gpiolib API. This way, existing drivers can be made less platform
dependent, and some of them perhaps even superseded with generic GPIO
based drivers after the board platform device descriptions are
converted. Moreover, should a new driver for the on-board Smart Card
controller ever be created, it could be designed as a generic GPIO
based driver, not a custom one.

Janusz Krzysztofik (10):
  GPIO: gpio-generic: Move initialization up to postcore
  ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
  ARM: OMAP1: ams-delta: supersede custom led device by leds-gpio
  LED: drop leds-ams-delta driver
  MTD: NAND: ams-delta: use GPIO instead of custom I/O
  ARM: OMAP1: ams-delta: Use GPIO API in modem setup
  ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API
  omapfb: lcd_ams_delta: Drive control lines over GPIO
  input: serio: ams-delta: toggle keyboard power over GPIO
  ARM: OMAP1: ams-delta: drop custom I/O functions

 arch/arm/mach-omap1/Kconfig                       |    2 +
 arch/arm/mach-omap1/board-ams-delta.c             |  220 +++++++++++++++++----
 arch/arm/plat-omap/include/plat/board-ams-delta.h |   50 ++---
 drivers/gpio/gpio-generic.c                       |    2 +-
 drivers/input/serio/ams_delta_serio.c             |   45 +++--
 drivers/leds/Kconfig                              |    7 -
 drivers/leds/Makefile                             |    1 -
 drivers/leds/leds-ams-delta.c                     |  137 -------------
 drivers/mtd/nand/ams-delta.c                      |   74 +++++--
 drivers/video/omap/lcd_ams_delta.c                |   27 ++-
 sound/soc/omap/ams-delta.c                        |   21 ++-
 11 files changed, 309 insertions(+), 277 deletions(-)
 delete mode 100644 drivers/leds/leds-ams-delta.c

-- 
1.7.3.4


^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
@ 2011-12-11 20:11 ` Janusz Krzysztofik
  2011-12-12 18:04   ` Tony Lindgren
  2011-12-14 11:13   ` Janusz Krzysztofik
  2011-12-11 20:12 ` [PATCH 02/10] ARM: OMAP1: ams-delta: Convert latches to basic_mmio_gpio Janusz Krzysztofik
                   ` (11 subsequent siblings)
  12 siblings, 2 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:11 UTC (permalink / raw)
  To: Tony Lindgren, Grant Likely
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik

This will allow boards with custom memory mapped GPIO ports to set up
and use those port pins while initializing devices from arch init.

Created against linux-3.2-rc5.

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 drivers/gpio/gpio-generic.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index 4e24436..a6eaf38 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -528,7 +528,7 @@ static int __init bgpio_platform_init(void)
 {
 	return platform_driver_register(&bgpio_driver);
 }
-module_init(bgpio_platform_init);
+postcore_initcall(bgpio_platform_init);
 
 static void __exit bgpio_platform_exit(void)
 {
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 02/10] ARM: OMAP1: ams-delta: Convert latches to basic_mmio_gpio
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
  2011-12-11 20:11 ` [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore Janusz Krzysztofik
@ 2011-12-11 20:12 ` Janusz Krzysztofik
  2011-12-11 20:12 ` [PATCH 03/10] ARM: OMAP1: ams-delta: Supersede custom led device by leds-gpio Janusz Krzysztofik
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:12 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Grant Likely

Once done, ams-delta specific device drivers currently calling custom
ams_delta_latch[12]_write() functions can call generic gpio_set_value()
instead, which will make them less platform dependent. Even more, some
custom ams-delta only drivers perhaps can be dropped from the tree after
converting selected ams-delta platform devices to follow generic GPIO
based device models.

Created against linux-3.2-rc5.
Requires patch 1/10 "GPIO: gpio-generic: Move initialization up to
postcore" to work correctly.

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 arch/arm/mach-omap1/Kconfig                       |    1 +
 arch/arm/mach-omap1/board-ams-delta.c             |  235 ++++++++++++++++++---
 arch/arm/plat-omap/include/plat/board-ams-delta.h |   43 +++-
 3 files changed, 241 insertions(+), 38 deletions(-)

diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index 73f287d..1b5f283 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -154,6 +154,7 @@ config MACH_NOKIA770
 config MACH_AMS_DELTA
 	bool "Amstrad E3 (Delta)"
 	depends on ARCH_OMAP1 && ARCH_OMAP15XX
+	select GPIO_GENERIC_PLATFORM
 	select FIQ
 	help
 	  Support for the Amstrad E3 (codename Delta) videophone. Say Y here
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index b0f15d2..d88419e 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -11,6 +11,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/basic_mmio_gpio.h>
 #include <linux/gpio.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -40,9 +41,6 @@
 
 #include <mach/ams-delta-fiq.h>
 
-static u8 ams_delta_latch1_reg;
-static u16 ams_delta_latch2_reg;
-
 static const unsigned int ams_delta_keymap[] = {
 	KEY(0, 0, KEY_F1),		/* Advert    */
 
@@ -121,39 +119,32 @@ static const unsigned int ams_delta_keymap[] = {
 	KEY(7, 3, KEY_LEFTCTRL),	/* Vol down  */
 };
 
-void ams_delta_latch1_write(u8 mask, u8 value)
-{
-	ams_delta_latch1_reg &= ~mask;
-	ams_delta_latch1_reg |= value;
-	*(volatile __u8 *) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg;
-}
-
-void ams_delta_latch2_write(u16 mask, u16 value)
-{
-	ams_delta_latch2_reg &= ~mask;
-	ams_delta_latch2_reg |= value;
-	*(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg;
-}
+#define _LATCH1_PHYS	0x01000000
+#define _LATCH1_VIRT	0xEA000000
+#define _MODEM_PHYS	0x04000000
+#define _MODEM_VIRT	0xEB000000
+#define _LATCH2_PHYS	0x08000000
+#define _LATCH2_VIRT	0xEC000000
 
 static struct map_desc ams_delta_io_desc[] __initdata = {
 	/* AMS_DELTA_LATCH1 */
 	{
-		.virtual	= AMS_DELTA_LATCH1_VIRT,
-		.pfn		= __phys_to_pfn(AMS_DELTA_LATCH1_PHYS),
+		.virtual	= _LATCH1_VIRT,
+		.pfn		= __phys_to_pfn(_LATCH1_PHYS),
 		.length		= 0x01000000,
 		.type		= MT_DEVICE
 	},
 	/* AMS_DELTA_LATCH2 */
 	{
-		.virtual	= AMS_DELTA_LATCH2_VIRT,
-		.pfn		= __phys_to_pfn(AMS_DELTA_LATCH2_PHYS),
+		.virtual	= _LATCH2_VIRT,
+		.pfn		= __phys_to_pfn(_LATCH2_PHYS),
 		.length		= 0x01000000,
 		.type		= MT_DEVICE
 	},
 	/* AMS_DELTA_MODEM */
 	{
-		.virtual	= AMS_DELTA_MODEM_VIRT,
-		.pfn		= __phys_to_pfn(AMS_DELTA_MODEM_PHYS),
+		.virtual	= _MODEM_VIRT,
+		.pfn		= __phys_to_pfn(_MODEM_PHYS),
 		.length		= 0x01000000,
 		.type		= MT_DEVICE
 	}
@@ -173,6 +164,195 @@ static struct omap_board_config_kernel ams_delta_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&ams_delta_lcd_config },
 };
 
+static struct resource _latch1_resources[] __initconst = {
+	[0] = {
+		.name	= "dat",
+		.start	= _LATCH1_PHYS,
+		.end	= _LATCH1_PHYS + ((AMS_DELTA_LATCH1_NGPIO - 1) / 8),
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct bgpio_pdata _latch1_pdata __initconst = {
+	.base	= AMS_DELTA_LATCH1_GPIO_BASE,
+	.ngpio	= AMS_DELTA_LATCH1_NGPIO,
+};
+
+static struct platform_device _latch1_device = {
+	.name		= "basic-mmio-gpio",
+	.id		= 0,
+	.resource	= _latch1_resources,
+	.num_resources	= ARRAY_SIZE(_latch1_resources),
+	.dev		= {
+		.platform_data	= &_latch1_pdata,
+	},
+};
+
+static struct resource _latch2_resources[] __initconst = {
+	[0] = {
+		.name	= "dat",
+		.start	= _LATCH2_PHYS,
+		.end	= _LATCH2_PHYS + ((AMS_DELTA_LATCH2_NGPIO - 1) / 8),
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct bgpio_pdata _latch2_pdata __initconst = {
+	.base	= AMS_DELTA_LATCH2_GPIO_BASE,
+	.ngpio	= AMS_DELTA_LATCH2_NGPIO,
+};
+
+static struct platform_device _latch2_device = {
+	.name		= "basic-mmio-gpio",
+	.id		= 1,
+	.resource	= _latch2_resources,
+	.num_resources	= ARRAY_SIZE(_latch2_resources),
+	.dev		= {
+		.platform_data	= &_latch2_pdata,
+	},
+};
+
+static struct platform_device *_latch_devices[] __initconst = {
+	&_latch1_device,
+	&_latch2_device,
+};
+
+static struct gpio _latch_gpios[] __initconst = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_CAMERA,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_camera",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_ADVERT,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_advert",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_EMAIL,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_email",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_HANDSFREE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_handsfree",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICEMAIL,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_voicemail",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_voice",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 6,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "dockit1",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 7,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "dockit2",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_vblen",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_ndisp",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nce",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nre",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nwp",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nwe",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_ale",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_cle",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "keybrd_pwr",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "keybrd_dataout",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "scard_rstin",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "scard_cmdvcc",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "modem_nreset",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_CODEC,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "modem_codec",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 14,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "hookflash1",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 15,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "hookflash2",
+	},
+};
+
+void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
+{
+	int bit;
+	u16 bitpos;
+
+	for (bit = 0; bit < ngpio; bit++) {
+		bitpos = 1 << bit;
+		if (mask & bitpos)
+			gpio_set_value(base + bit, (value & bitpos) != 0);
+	}
+}
+EXPORT_SYMBOL(ams_delta_latch_write);
+
 static struct resource ams_delta_nand_resources[] = {
 	[0] = {
 		.start	= OMAP1_MPUIO_BASE,
@@ -307,8 +487,8 @@ static void __init ams_delta_init(void)
 	omap_serial_init();
 	omap_register_i2c_bus(1, 100, NULL, 0);
 
-	/* Clear latch2 (NAND, LCD, modem enable) */
-	ams_delta_latch2_write(~0, 0);
+	platform_add_devices(_latch_devices, ARRAY_SIZE(_latch_devices));
+	BUG_ON(gpio_request_array(_latch_gpios, ARRAY_SIZE(_latch_gpios)));
 
 	omap1_usb_init(&ams_delta_usb_config);
 	omap1_set_camera_info(&ams_delta_camera_platform_data);
@@ -325,8 +505,8 @@ static void __init ams_delta_init(void)
 
 static struct plat_serial8250_port ams_delta_modem_ports[] = {
 	{
-		.membase	= IOMEM(AMS_DELTA_MODEM_VIRT),
-		.mapbase	= AMS_DELTA_MODEM_PHYS,
+		.membase	= IOMEM(_MODEM_VIRT),
+		.mapbase	= _MODEM_PHYS,
 		.irq		= -EINVAL, /* changed later */
 		.flags		= UPF_BOOT_AUTOCONF,
 		.irqflags	= IRQF_TRIGGER_RISING,
@@ -387,6 +567,3 @@ MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
 	.init_machine	= ams_delta_init,
 	.timer		= &omap1_timer,
 MACHINE_END
-
-EXPORT_SYMBOL(ams_delta_latch1_write);
-EXPORT_SYMBOL(ams_delta_latch2_write);
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 51b102d..1b8e759 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,13 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMS_DELTA_LATCH1_PHYS		0x01000000
-#define AMS_DELTA_LATCH1_VIRT		0xEA000000
-#define AMS_DELTA_MODEM_PHYS		0x04000000
-#define AMS_DELTA_MODEM_VIRT		0xEB000000
-#define AMS_DELTA_LATCH2_PHYS		0x08000000
-#define AMS_DELTA_LATCH2_VIRT		0xEC000000
-
 #define AMS_DELTA_LATCH1_LED_CAMERA	0x01
 #define AMS_DELTA_LATCH1_LED_ADVERT	0x02
 #define AMS_DELTA_LATCH1_LED_EMAIL	0x04
@@ -66,10 +59,42 @@
 #define AMS_DELTA_GPIO_PIN_CONFIG	11
 #define AMS_DELTA_GPIO_PIN_NAND_RB	12
 
+#define AMS_DELTA_GPIO_PIN_LED_CAMERA		232
+#define AMS_DELTA_GPIO_PIN_LED_ADVERT		233
+#define AMS_DELTA_GPIO_PIN_LED_EMAIL		234
+#define AMS_DELTA_GPIO_PIN_LED_HANDSFREE	235
+#define AMS_DELTA_GPIO_PIN_LED_VOICEMAIL	236
+#define AMS_DELTA_GPIO_PIN_LED_VOICE		237
+
+#define AMS_DELTA_GPIO_PIN_LCD_VBLEN		240
+#define AMS_DELTA_GPIO_PIN_LCD_NDISP		241
+#define AMS_DELTA_GPIO_PIN_NAND_NCE		242
+#define AMS_DELTA_GPIO_PIN_NAND_NRE		243
+#define AMS_DELTA_GPIO_PIN_NAND_NWP		244
+#define AMS_DELTA_GPIO_PIN_NAND_NWE		245
+#define AMS_DELTA_GPIO_PIN_NAND_ALE		246
+#define AMS_DELTA_GPIO_PIN_NAND_CLE		247
+#define AMS_DELTA_GPIO_PIN_KEYBRD_PWR		248
+#define AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT	249
+#define AMS_DELTA_GPIO_PIN_SCARD_RSTIN		250
+#define AMS_DELTA_GPIO_PIN_SCARD_CMDVCC		251
+#define AMS_DELTA_GPIO_PIN_MODEM_NRESET		252
+#define AMS_DELTA_GPIO_PIN_MODEM_CODEC		253
+
+#define AMS_DELTA_LATCH1_GPIO_BASE	AMS_DELTA_GPIO_PIN_LED_CAMERA
+#define AMS_DELTA_LATCH1_NGPIO		8
+#define AMS_DELTA_LATCH2_GPIO_BASE	AMS_DELTA_GPIO_PIN_LCD_VBLEN
+#define AMS_DELTA_LATCH2_NGPIO		16
+
 #ifndef __ASSEMBLY__
-void ams_delta_latch1_write(u8 mask, u8 value);
-void ams_delta_latch2_write(u16 mask, u16 value);
+void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value);
 #endif
+#define ams_delta_latch1_write(mask, value) \
+	ams_delta_latch_write(AMS_DELTA_LATCH1_GPIO_BASE, \
+			AMS_DELTA_LATCH1_NGPIO, (mask), (value))
+#define ams_delta_latch2_write(mask, value) \
+	ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \
+			AMS_DELTA_LATCH2_NGPIO, (mask), (value))
 
 #endif /* CONFIG_MACH_AMS_DELTA */
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 03/10] ARM: OMAP1: ams-delta: Supersede custom led device by leds-gpio
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
  2011-12-11 20:11 ` [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore Janusz Krzysztofik
  2011-12-11 20:12 ` [PATCH 02/10] ARM: OMAP1: ams-delta: Convert latches to basic_mmio_gpio Janusz Krzysztofik
@ 2011-12-11 20:12 ` Janusz Krzysztofik
  2011-12-11 20:12 ` [PATCH 04/10] LED: Drop leds-ams-delta driver Janusz Krzysztofik
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:12 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Richard Purdie

Now that the Amstrad Delta on-board latches have been converted to GPIO
devices, use the generic driver to control on-board LEDs which hang off
those latches.

Depends on patch 2/10 "ARM: OMAP1: Convert Amstrad E3 latches to
basic_mmio_gpio".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 arch/arm/mach-omap1/Kconfig                       |    1 +
 arch/arm/mach-omap1/board-ams-delta.c             |   87 +++++++++++---------
 arch/arm/plat-omap/include/plat/board-ams-delta.h |   19 -----
 3 files changed, 49 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index 1b5f283..f362f83 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -155,6 +155,7 @@ config MACH_AMS_DELTA
 	bool "Amstrad E3 (Delta)"
 	depends on ARCH_OMAP1 && ARCH_OMAP15XX
 	select GPIO_GENERIC_PLATFORM
+	select LEDS_GPIO_REGISTER
 	select FIQ
 	help
 	  Support for the Amstrad E3 (codename Delta) videophone. Say Y here
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index d88419e..bdf7399 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -164,18 +164,21 @@ static struct omap_board_config_kernel ams_delta_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&ams_delta_lcd_config },
 };
 
+#define _LATCH1_GPIO_BASE	232
+#define _LATCH1_NGPIO		8
+
 static struct resource _latch1_resources[] __initconst = {
 	[0] = {
 		.name	= "dat",
 		.start	= _LATCH1_PHYS,
-		.end	= _LATCH1_PHYS + ((AMS_DELTA_LATCH1_NGPIO - 1) / 8),
+		.end	= _LATCH1_PHYS + ((_LATCH1_NGPIO - 1) / 8),
 		.flags	= IORESOURCE_MEM,
 	},
 };
 
 static struct bgpio_pdata _latch1_pdata __initconst = {
-	.base	= AMS_DELTA_LATCH1_GPIO_BASE,
-	.ngpio	= AMS_DELTA_LATCH1_NGPIO,
+	.base	= _LATCH1_GPIO_BASE,
+	.ngpio	= _LATCH1_NGPIO,
 };
 
 static struct platform_device _latch1_device = {
@@ -219,42 +222,12 @@ static struct platform_device *_latch_devices[] __initconst = {
 
 static struct gpio _latch_gpios[] __initconst = {
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_CAMERA,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_camera",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_ADVERT,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_advert",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_EMAIL,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_email",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_HANDSFREE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_handsfree",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICEMAIL,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_voicemail",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_voice",
-	},
-	{
-		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 6,
+		.gpio	= _LATCH1_GPIO_BASE + 6,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "dockit1",
 	},
 	{
-		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 7,
+		.gpio	= _LATCH1_GPIO_BASE + 7,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "dockit2",
 	},
@@ -404,9 +377,45 @@ static struct platform_device ams_delta_lcd_device = {
 	.id	= -1,
 };
 
-static struct platform_device ams_delta_led_device = {
-	.name	= "ams-delta-led",
-	.id	= -1
+static struct gpio_led _gpio_leds[] __initconst = {
+	{
+		.name		 = "camera",
+		.gpio		 = _LATCH1_GPIO_BASE + 0,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+#ifdef CONFIG_LEDS_TRIGGERS
+		.default_trigger = "ams_delta_camera",
+#endif
+	},
+	{
+		.name		 = "advert",
+		.gpio		 = _LATCH1_GPIO_BASE + 1,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+	{
+		.name		 = "email",
+		.gpio		 = _LATCH1_GPIO_BASE + 2,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+	{
+		.name		 = "handsfree",
+		.gpio		 = _LATCH1_GPIO_BASE + 3,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+	{
+		.name		 = "voicemail",
+		.gpio		 = _LATCH1_GPIO_BASE + 4,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+	{
+		.name		 = "voice",
+		.gpio		 = _LATCH1_GPIO_BASE + 5,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+};
+
+static struct gpio_led_platform_data _leds_pdata __initconst = {
+	.leds		= _gpio_leds,
+	.num_leds	= ARRAY_SIZE(_gpio_leds),
 };
 
 static struct i2c_board_info ams_delta_camera_board_info[] = {
@@ -458,7 +467,6 @@ static struct platform_device *ams_delta_devices[] __initdata = {
 	&ams_delta_nand_device,
 	&ams_delta_kp_device,
 	&ams_delta_lcd_device,
-	&ams_delta_led_device,
 	&ams_delta_camera_device,
 };
 
@@ -496,6 +504,7 @@ static void __init ams_delta_init(void)
 	led_trigger_register_simple("ams_delta_camera",
 			&ams_delta_camera_led_trigger);
 #endif
+	gpio_led_register_device(-1, &_leds_pdata);
 	platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
 
 	ams_delta_init_fiq();
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 1b8e759..c096e14 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,13 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMS_DELTA_LATCH1_LED_CAMERA	0x01
-#define AMS_DELTA_LATCH1_LED_ADVERT	0x02
-#define AMS_DELTA_LATCH1_LED_EMAIL	0x04
-#define AMS_DELTA_LATCH1_LED_HANDSFREE	0x08
-#define AMS_DELTA_LATCH1_LED_VOICEMAIL	0x10
-#define AMS_DELTA_LATCH1_LED_VOICE	0x20
-
 #define AMS_DELTA_LATCH2_LCD_VBLEN	0x0001
 #define AMS_DELTA_LATCH2_LCD_NDISP	0x0002
 #define AMS_DELTA_LATCH2_NAND_NCE	0x0004
@@ -59,13 +52,6 @@
 #define AMS_DELTA_GPIO_PIN_CONFIG	11
 #define AMS_DELTA_GPIO_PIN_NAND_RB	12
 
-#define AMS_DELTA_GPIO_PIN_LED_CAMERA		232
-#define AMS_DELTA_GPIO_PIN_LED_ADVERT		233
-#define AMS_DELTA_GPIO_PIN_LED_EMAIL		234
-#define AMS_DELTA_GPIO_PIN_LED_HANDSFREE	235
-#define AMS_DELTA_GPIO_PIN_LED_VOICEMAIL	236
-#define AMS_DELTA_GPIO_PIN_LED_VOICE		237
-
 #define AMS_DELTA_GPIO_PIN_LCD_VBLEN		240
 #define AMS_DELTA_GPIO_PIN_LCD_NDISP		241
 #define AMS_DELTA_GPIO_PIN_NAND_NCE		242
@@ -81,17 +67,12 @@
 #define AMS_DELTA_GPIO_PIN_MODEM_NRESET		252
 #define AMS_DELTA_GPIO_PIN_MODEM_CODEC		253
 
-#define AMS_DELTA_LATCH1_GPIO_BASE	AMS_DELTA_GPIO_PIN_LED_CAMERA
-#define AMS_DELTA_LATCH1_NGPIO		8
 #define AMS_DELTA_LATCH2_GPIO_BASE	AMS_DELTA_GPIO_PIN_LCD_VBLEN
 #define AMS_DELTA_LATCH2_NGPIO		16
 
 #ifndef __ASSEMBLY__
 void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value);
 #endif
-#define ams_delta_latch1_write(mask, value) \
-	ams_delta_latch_write(AMS_DELTA_LATCH1_GPIO_BASE, \
-			AMS_DELTA_LATCH1_NGPIO, (mask), (value))
 #define ams_delta_latch2_write(mask, value) \
 	ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \
 			AMS_DELTA_LATCH2_NGPIO, (mask), (value))
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 04/10] LED: Drop leds-ams-delta driver
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
                   ` (2 preceding siblings ...)
  2011-12-11 20:12 ` [PATCH 03/10] ARM: OMAP1: ams-delta: Supersede custom led device by leds-gpio Janusz Krzysztofik
@ 2011-12-11 20:12 ` Janusz Krzysztofik
  2011-12-11 20:12 ` [PATCH 05/10] MTD: NAND: ams-delta: Use GPIO instead of custom I/O Janusz Krzysztofik
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:12 UTC (permalink / raw)
  To: Tony Lindgren, Richard Purdie
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik

This is no longer needed after the Amstrad Delta on-board LED devices
have been converted to leds-gpio compatible.

Created against linux-3.2-rc5.
Requires patch 3/10 "ARM: OMAP1: ams-delta: Supersede custom led device
by leds-gpio" for those LEDs to still work.

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 drivers/leds/Kconfig          |    7 --
 drivers/leds/Makefile         |    1 -
 drivers/leds/leds-ams-delta.c |  137 -----------------------------------------
 3 files changed, 0 insertions(+), 145 deletions(-)
 delete mode 100644 drivers/leds/leds-ams-delta.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index ff203a4..3523746 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -74,13 +74,6 @@ config LEDS_S3C24XX
 	  This option enables support for LEDs connected to GPIO lines
 	  on Samsung S3C24XX series CPUs, such as the S3C2410 and S3C2440.
 
-config LEDS_AMS_DELTA
-	tristate "LED Support for the Amstrad Delta (E3)"
-	depends on LEDS_CLASS
-	depends on MACH_AMS_DELTA
-	help
-	  This option enables support for the LEDs on Amstrad Delta (E3).
-
 config LEDS_NET48XX
 	tristate "LED Support for Soekris net48xx series Error LED"
 	depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index e4f6bf5..f2b75b2 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -12,7 +12,6 @@ obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
 obj-$(CONFIG_LEDS_LM3530)		+= leds-lm3530.o
 obj-$(CONFIG_LEDS_MIKROTIK_RB532)	+= leds-rb532.o
 obj-$(CONFIG_LEDS_S3C24XX)		+= leds-s3c24xx.o
-obj-$(CONFIG_LEDS_AMS_DELTA)		+= leds-ams-delta.o
 obj-$(CONFIG_LEDS_NET48XX)		+= leds-net48xx.o
 obj-$(CONFIG_LEDS_NET5501)		+= leds-net5501.o
 obj-$(CONFIG_LEDS_WRAP)			+= leds-wrap.o
diff --git a/drivers/leds/leds-ams-delta.c b/drivers/leds/leds-ams-delta.c
deleted file mode 100644
index 8c00937..0000000
--- a/drivers/leds/leds-ams-delta.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * LEDs driver for Amstrad Delta (E3)
- *
- * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
- *
- * 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.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/leds.h>
-#include <plat/board-ams-delta.h>
-
-/*
- * Our context
- */
-struct ams_delta_led {
-	struct led_classdev	cdev;
-	u8			bitmask;
-};
-
-static void ams_delta_led_set(struct led_classdev *led_cdev,
-		enum led_brightness value)
-{
-	struct ams_delta_led *led_dev =
-		container_of(led_cdev, struct ams_delta_led, cdev);
-
-	if (value)
-		ams_delta_latch1_write(led_dev->bitmask, led_dev->bitmask);
-	else
-		ams_delta_latch1_write(led_dev->bitmask, 0);
-}
-
-static struct ams_delta_led ams_delta_leds[] = {
-	{
-		.cdev		= {
-			.name		= "ams-delta::camera",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_CAMERA,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::advert",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_ADVERT,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::email",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_EMAIL,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::handsfree",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_HANDSFREE,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::voicemail",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_VOICEMAIL,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::voice",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_VOICE,
-	},
-};
-
-static int ams_delta_led_probe(struct platform_device *pdev)
-{
-	int i, ret;
-
-	for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++) {
-		ams_delta_leds[i].cdev.flags |= LED_CORE_SUSPENDRESUME;
-		ret = led_classdev_register(&pdev->dev,
-				&ams_delta_leds[i].cdev);
-		if (ret < 0)
-			goto fail;
-	}
-
-	return 0;
-fail:
-	while (--i >= 0)
-		led_classdev_unregister(&ams_delta_leds[i].cdev);
-	return ret;	
-}
-
-static int ams_delta_led_remove(struct platform_device *pdev)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
-		led_classdev_unregister(&ams_delta_leds[i].cdev);
-
-	return 0;
-}
-
-static struct platform_driver ams_delta_led_driver = {
-	.probe		= ams_delta_led_probe,
-	.remove		= ams_delta_led_remove,
-	.driver		= {
-		.name = "ams-delta-led",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init ams_delta_led_init(void)
-{
-	return platform_driver_register(&ams_delta_led_driver);
-}
-
-static void __exit ams_delta_led_exit(void)
-{
-	platform_driver_unregister(&ams_delta_led_driver);
-}
-
-module_init(ams_delta_led_init);
-module_exit(ams_delta_led_exit);
-
-MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
-MODULE_DESCRIPTION("Amstrad Delta LED driver");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:ams-delta-led");
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 05/10] MTD: NAND: ams-delta: Use GPIO instead of custom I/O
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
                   ` (3 preceding siblings ...)
  2011-12-11 20:12 ` [PATCH 04/10] LED: Drop leds-ams-delta driver Janusz Krzysztofik
@ 2011-12-11 20:12 ` Janusz Krzysztofik
  2011-12-11 20:12 ` [PATCH 06/10] ARM: OMAP1: ams-delta: Use GPIO API in modem setup Janusz Krzysztofik
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:12 UTC (permalink / raw)
  To: Tony Lindgren, David Woodhouse
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	linux-mtd

Don't use Amstrad Delta custom I/O functions for controlling the device,
use GPIO API instead.

While being at it, add missing gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB).

Depends on patch 2/10 "ARM: OMAP1: Convert Amstrad E3 latches to
basic_mmio_gpio".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
Hi,
I considered dropping the Amstrad Delta NAND driver and moving to either
gpio-nand or gen_nand, but finally decided to keep it for now.

The problem with the gpio-nand is that it seems to match a different
hardware interface model. Having no knowledge about the original
hardware that driver was designed in mind, I'd rather not try to
modify it, and creating another GPIO based NAND driver also seems not
a really good idea.

If I decided to use gen_nand instead, I would have to move virtually all
of the old driver callback functions somewhere under arch, either to the
board file or to a new one, and still use some hacks unless either
nand_base.c or plat_nand.c is modified.

I'm willing to take one of those two approaches in a follow up series if
I get a positive feedback.

Thanks,
Janusz


 arch/arm/mach-omap1/board-ams-delta.c             |   30 --------
 arch/arm/plat-omap/include/plat/board-ams-delta.h |    6 --
 drivers/mtd/nand/ams-delta.c                      |   74 ++++++++++++++------
 3 files changed, 52 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index bdf7399..7670374 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -242,36 +242,6 @@ static struct gpio _latch_gpios[] __initconst = {
 		.label	= "lcd_ndisp",
 	},
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_nce",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_nre",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_nwp",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_nwe",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_ale",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_cle",
-	},
-	{
 		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "keybrd_pwr",
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index c096e14..b586078 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -30,12 +30,6 @@
 
 #define AMS_DELTA_LATCH2_LCD_VBLEN	0x0001
 #define AMS_DELTA_LATCH2_LCD_NDISP	0x0002
-#define AMS_DELTA_LATCH2_NAND_NCE	0x0004
-#define AMS_DELTA_LATCH2_NAND_NRE	0x0008
-#define AMS_DELTA_LATCH2_NAND_NWP	0x0010
-#define AMS_DELTA_LATCH2_NAND_NWE	0x0020
-#define AMS_DELTA_LATCH2_NAND_ALE	0x0040
-#define AMS_DELTA_LATCH2_NAND_CLE	0x0080
 #define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
 #define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
 #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index 9e6b498..5769bd2 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -26,7 +26,7 @@
 #include <asm/io.h>
 #include <mach/hardware.h>
 #include <asm/sizes.h>
-#include <asm/gpio.h>
+#include <linux/gpio.h>
 #include <plat/board-ams-delta.h>
 
 /*
@@ -34,8 +34,6 @@
  */
 static struct mtd_info *ams_delta_mtd = NULL;
 
-#define NAND_MASK (AMS_DELTA_LATCH2_NAND_NRE | AMS_DELTA_LATCH2_NAND_NWE | AMS_DELTA_LATCH2_NAND_CLE | AMS_DELTA_LATCH2_NAND_ALE | AMS_DELTA_LATCH2_NAND_NCE | AMS_DELTA_LATCH2_NAND_NWP)
-
 /*
  * Define partitions for flash devices
  */
@@ -68,10 +66,9 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
 
 	writew(0, io_base + OMAP_MPUIO_IO_CNTL);
 	writew(byte, this->IO_ADDR_W);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 0);
 	ndelay(40);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE,
-			       AMS_DELTA_LATCH2_NAND_NWE);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 1);
 }
 
 static u_char ams_delta_read_byte(struct mtd_info *mtd)
@@ -80,12 +77,11 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd)
 	struct nand_chip *this = mtd->priv;
 	void __iomem *io_base = this->priv;
 
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0);
 	ndelay(40);
 	writew(~0, io_base + OMAP_MPUIO_IO_CNTL);
 	res = readw(this->IO_ADDR_R);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE,
-			       AMS_DELTA_LATCH2_NAND_NRE);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 1);
 
 	return res;
 }
@@ -132,15 +128,12 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd,
 {
 
 	if (ctrl & NAND_CTRL_CHANGE) {
-		unsigned long bits;
-
-		bits = (~ctrl & NAND_NCE) ? AMS_DELTA_LATCH2_NAND_NCE : 0;
-		bits |= (ctrl & NAND_CLE) ? AMS_DELTA_LATCH2_NAND_CLE : 0;
-		bits |= (ctrl & NAND_ALE) ? AMS_DELTA_LATCH2_NAND_ALE : 0;
-
-		ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_CLE |
-				AMS_DELTA_LATCH2_NAND_ALE |
-				AMS_DELTA_LATCH2_NAND_NCE, bits);
+		gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NCE,
+				(ctrl & NAND_NCE) == 0);
+		gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_CLE,
+				(ctrl & NAND_CLE) != 0);
+		gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_ALE,
+				(ctrl & NAND_ALE) != 0);
 	}
 
 	if (cmd != NAND_CMD_NONE)
@@ -152,6 +145,39 @@ static int ams_delta_nand_ready(struct mtd_info *mtd)
 	return gpio_get_value(AMS_DELTA_GPIO_PIN_NAND_RB);
 }
 
+static struct gpio _mandatory_gpio[] __initconst_or_module = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "nand_nce",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "nand_nre",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "nand_nwp",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "nand_nwe",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_ale",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_cle",
+	},
+};
+
 /*
  * Main initialization routine
  */
@@ -223,10 +249,9 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
 	platform_set_drvdata(pdev, io_base);
 
 	/* Set chip enabled, but  */
-	ams_delta_latch2_write(NAND_MASK, AMS_DELTA_LATCH2_NAND_NRE |
-					  AMS_DELTA_LATCH2_NAND_NWE |
-					  AMS_DELTA_LATCH2_NAND_NCE |
-					  AMS_DELTA_LATCH2_NAND_NWP);
+	err = gpio_request_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
+	if (err)
+		goto out_gpio;
 
 	/* Scan to find existence of the device */
 	if (nand_scan(ams_delta_mtd, 1)) {
@@ -241,7 +266,10 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
 	goto out;
 
  out_mtd:
+	gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
+out_gpio:
 	platform_set_drvdata(pdev, NULL);
+	gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
 	iounmap(io_base);
 out_release_io:
 	release_mem_region(res->start, resource_size(res));
@@ -262,6 +290,8 @@ static int __devexit ams_delta_cleanup(struct platform_device *pdev)
 	/* Release resources, unregister device */
 	nand_release(ams_delta_mtd);
 
+	gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
+	gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
 	iounmap(io_base);
 	release_mem_region(res->start, resource_size(res));
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 06/10] ARM: OMAP1: ams-delta: Use GPIO API in modem setup
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
                   ` (4 preceding siblings ...)
  2011-12-11 20:12 ` [PATCH 05/10] MTD: NAND: ams-delta: Use GPIO instead of custom I/O Janusz Krzysztofik
@ 2011-12-11 20:12 ` Janusz Krzysztofik
  2011-12-11 20:12 ` [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API Janusz Krzysztofik
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:12 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	alsa-devel, Jarkko Nikula, Liam Girdwood, Mark Brown

Don't use Amstrad Delta custom I/O functions for setting up modem
related pins, use GPIO API instead. However, keep old pin definitions
used by ams_delta_latch2_write() for now, as those are still used by the
Amstrad Delta ASoC driver.

While being at it, extend the device platform data with a power
management hook which toggles one of those new GPIO pins.

Depends on patch 2/10 "ARM: OMAP1: Convert Amstrad E3 latches to
basic_mmio_gpio".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 arch/arm/mach-omap1/board-ams-delta.c |   44 ++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 7670374..5705481 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -262,16 +262,6 @@ static struct gpio _latch_gpios[] __initconst = {
 		.label	= "scard_cmdvcc",
 	},
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "modem_nreset",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_CODEC,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "modem_codec",
-	},
-	{
 		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 14,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "hookflash1",
@@ -482,6 +472,12 @@ static void __init ams_delta_init(void)
 	omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
 }
 
+static void _modem_pm(struct uart_port *port, unsigned int state, unsigned old)
+{
+	if (state != old)
+		gpio_set_value(AMS_DELTA_GPIO_PIN_MODEM_NRESET, state == 0);
+}
+
 static struct plat_serial8250_port ams_delta_modem_ports[] = {
 	{
 		.membase	= IOMEM(_MODEM_VIRT),
@@ -492,6 +488,7 @@ static struct plat_serial8250_port ams_delta_modem_ports[] = {
 		.iotype		= UPIO_MEM,
 		.regshift	= 1,
 		.uartclk	= BASE_BAUD * 16,
+		.pm		= _modem_pm,
 	},
 	{ },
 };
@@ -504,6 +501,24 @@ static struct platform_device ams_delta_modem_device = {
 	},
 };
 
+static struct gpio _modem_gpios[] __initconst = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_IRQ,
+		.flags	= GPIOF_DIR_IN,
+		.label	= "modem_irq",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "modem_nreset",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_CODEC,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "modem_codec",
+	},
+};
+
 static int __init ams_delta_modem_init(void)
 {
 	int err;
@@ -515,16 +530,11 @@ static int __init ams_delta_modem_init(void)
 	ams_delta_modem_ports[0].irq =
 			gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
 
-	err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem");
+	err = gpio_request_array(_modem_gpios, ARRAY_SIZE(_modem_gpios));
 	if (err) {
-		pr_err("Couldn't request gpio pin for modem\n");
+		pr_err("Couldn't request gpio pins for modem\n");
 		return err;
 	}
-	gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
-
-	ams_delta_latch2_write(
-		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
-		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
 
 	return platform_device_register(&ams_delta_modem_device);
 }
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
                   ` (5 preceding siblings ...)
  2011-12-11 20:12 ` [PATCH 06/10] ARM: OMAP1: ams-delta: Use GPIO API in modem setup Janusz Krzysztofik
@ 2011-12-11 20:12 ` Janusz Krzysztofik
  2011-12-12  4:29   ` Mark Brown
  2011-12-21 18:33   ` Liam Girdwood
  2011-12-11 20:12 ` [PATCH 08/10] omapfb: lcd_ams_delta: Drive control lines over GPIO Janusz Krzysztofik
                   ` (5 subsequent siblings)
  12 siblings, 2 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:12 UTC (permalink / raw)
  To: Tony Lindgren, Jarkko Nikula
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	alsa-devel, Liam Girdwood, Mark Brown

Don't use Amstrad Delta custom I/O functions any longer, replace them
with GPIO. Old pin definitions, no longer used by the modem bits either,
can be dropped.

Depends on patch 2/10 "ARM: OMAP1: Convert Amstrad E3 latches to
basic_mmio_gpio".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 --
 sound/soc/omap/ams-delta.c                        |   21 ++++++++++++---------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index b586078..73fdab9 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -34,8 +34,6 @@
 #define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
 #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
 #define AMD_DELTA_LATCH2_SCARD_CMDVCC	0x0800
-#define AMS_DELTA_LATCH2_MODEM_NRESET	0x1000
-#define AMS_DELTA_LATCH2_MODEM_CODEC	0x2000
 
 #define AMS_DELTA_GPIO_PIN_KEYBRD_DATA	0
 #define AMS_DELTA_GPIO_PIN_KEYBRD_CLK	1
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index ccb8a6a..389c488 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -268,7 +268,7 @@ static void cx81801_timeout(unsigned long data)
 	/* Reconnect the codec DAI back from the modem to the CPU DAI
 	 * only if digital mute still off */
 	if (!muted)
-		ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0);
+		gpio_set_value(AMS_DELTA_GPIO_PIN_MODEM_CODEC, 0);
 }
 
 /*
@@ -378,8 +378,7 @@ static void cx81801_receive(struct tty_struct *tty,
 		/* Apply config pulse by connecting the codec to the modem
 		 * if not already done */
 		if (apply)
-			ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
-						AMS_DELTA_LATCH2_MODEM_CODEC);
+			gpio_set_value(AMS_DELTA_GPIO_PIN_MODEM_CODEC, 1);
 		break;
 	}
 }
@@ -438,13 +437,11 @@ static int ams_delta_set_bias_level(struct snd_soc_card *card,
 	case SND_SOC_BIAS_PREPARE:
 	case SND_SOC_BIAS_STANDBY:
 		if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
-			ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_NRESET,
-						AMS_DELTA_LATCH2_MODEM_NRESET);
+			gpio_set_value(AMS_DELTA_GPIO_PIN_MODEM_NRESET, 1);
 		break;
 	case SND_SOC_BIAS_OFF:
 		if (codec->dapm.bias_level != SND_SOC_BIAS_OFF)
-			ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_NRESET,
-						0);
+			gpio_set_value(AMS_DELTA_GPIO_PIN_MODEM_NRESET, 0);
 	}
 	codec->dapm.bias_level = level;
 
@@ -468,8 +465,7 @@ static int ams_delta_digital_mute(struct snd_soc_dai *dai, int mute)
 	spin_unlock_bh(&ams_delta_lock);
 
 	if (apply)
-		ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
-				mute ? AMS_DELTA_LATCH2_MODEM_CODEC : 0);
+		gpio_set_value(AMS_DELTA_GPIO_PIN_MODEM_CODEC, mute);
 	return 0;
 }
 
@@ -503,6 +499,13 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
 	int ret;
 	/* Codec is ready, now add/activate board specific controls */
 
+	/*
+	 * *_MODEM_CODEC and *_MODEM_NRESET GPIO pins manipulated above are
+	 * assumed to be already requested from the board initialisation code,
+	 * which should be done while setting up the modem device which those
+	 * pins are used for control of in the first place.
+	 */
+
 	/* Store a pointer to the codec structure for tty ldisc use */
 	cx20442_codec = codec;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 08/10] omapfb: lcd_ams_delta: Drive control lines over GPIO
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
                   ` (6 preceding siblings ...)
  2011-12-11 20:12 ` [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API Janusz Krzysztofik
@ 2011-12-11 20:12 ` Janusz Krzysztofik
  2011-12-12 11:24   ` Tomi Valkeinen
  2011-12-11 20:12 ` [PATCH 09/10] input: serio: ams-delta: Toggle keyboard power " Janusz Krzysztofik
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:12 UTC (permalink / raw)
  To: Tony Lindgren, Tomi Valkeinen
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	linux-fbdev

Don't use Amstrad Delta custom I/O functions any longer, use GPIO API
instead.

Depends on patch 5/10 "MTD: NAND: ams-delta: Use GPIO instead of custom
I/O".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 arch/arm/mach-omap1/board-ams-delta.c             |   10 -------
 arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 -
 drivers/video/omap/lcd_ams_delta.c                |   27 +++++++++++++++-----
 3 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 5705481..b7422e3 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -232,16 +232,6 @@ static struct gpio _latch_gpios[] __initconst = {
 		.label	= "dockit2",
 	},
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "lcd_vblen",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "lcd_ndisp",
-	},
-	{
 		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "keybrd_pwr",
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 73fdab9..1d0706e 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,8 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMS_DELTA_LATCH2_LCD_VBLEN	0x0001
-#define AMS_DELTA_LATCH2_LCD_NDISP	0x0002
 #define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
 #define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
 #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
diff --git a/drivers/video/omap/lcd_ams_delta.c b/drivers/video/omap/lcd_ams_delta.c
index 6978ae4..73b211b 100644
--- a/drivers/video/omap/lcd_ams_delta.c
+++ b/drivers/video/omap/lcd_ams_delta.c
@@ -25,6 +25,7 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 #include <linux/lcd.h>
+#include <linux/gpio.h>
 
 #include <plat/board-ams-delta.h>
 #include <mach/hardware.h>
@@ -98,29 +99,41 @@ static struct lcd_ops ams_delta_lcd_ops = {
 
 /* omapfb panel section */
 
+static struct gpio _gpios[] __initconst_or_module = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_vblen",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_ndisp",
+	},
+};
+
 static int ams_delta_panel_init(struct lcd_panel *panel,
 		struct omapfb_device *fbdev)
 {
-	return 0;
+	return gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
 }
 
 static void ams_delta_panel_cleanup(struct lcd_panel *panel)
 {
+	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
 }
 
 static int ams_delta_panel_enable(struct lcd_panel *panel)
 {
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_NDISP,
-			AMS_DELTA_LATCH2_LCD_NDISP);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN,
-			AMS_DELTA_LATCH2_LCD_VBLEN);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1);
 	return 0;
 }
 
 static void ams_delta_panel_disable(struct lcd_panel *panel)
 {
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN, 0);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_NDISP, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0);
 }
 
 static unsigned long ams_delta_panel_get_caps(struct lcd_panel *panel)
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 09/10] input: serio: ams-delta: Toggle keyboard power over GPIO
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
                   ` (7 preceding siblings ...)
  2011-12-11 20:12 ` [PATCH 08/10] omapfb: lcd_ams_delta: Drive control lines over GPIO Janusz Krzysztofik
@ 2011-12-11 20:12 ` Janusz Krzysztofik
  2011-12-12  8:18   ` Dmitry Torokhov
  2011-12-11 20:12 ` [PATCH 10/10] ARM: OMAP1: ams-delta: Drop custom I/O functions Janusz Krzysztofik
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:12 UTC (permalink / raw)
  To: Tony Lindgren, Dmitry Torokhov
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	linux-input

Don't use Amstrad Delta custom I/O functions once GPIO interface is
available for the underlying hardware.

Depends on patch 8/10 "omapfb: lcd_ams_delta: Drive control lines over
GPIO".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 arch/arm/mach-omap1/board-ams-delta.c             |    5 --
 arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 -
 drivers/input/serio/ams_delta_serio.c             |   45 +++++++++++---------
 3 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index b7422e3..587118c 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -232,11 +232,6 @@ static struct gpio _latch_gpios[] __initconst = {
 		.label	= "dockit2",
 	},
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "keybrd_pwr",
-	},
-	{
 		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "keybrd_dataout",
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 1d0706e..004c827 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,8 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
-#define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
 #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
 #define AMD_DELTA_LATCH2_SCARD_CMDVCC	0x0800
 
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index d4d08bd..1499c7d 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -92,8 +92,7 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
 static int ams_delta_serio_open(struct serio *serio)
 {
 	/* enable keyboard */
-	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR,
-			AMD_DELTA_LATCH2_KEYBRD_PWR);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1);
 
 	return 0;
 }
@@ -101,9 +100,26 @@ static int ams_delta_serio_open(struct serio *serio)
 static void ams_delta_serio_close(struct serio *serio)
 {
 	/* disable keyboard */
-	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0);
 }
 
+static struct gpio _gpios[] __initconst_or_module = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
+		.flags	= GPIOF_DIR_IN,
+		.label	= "serio-data",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
+		.flags	= GPIOF_DIR_IN,
+		.label	= "serio-clock",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "serio-power",
+	},
+};
 static int __init ams_delta_serio_init(void)
 {
 	int err;
@@ -123,19 +139,11 @@ static int __init ams_delta_serio_init(void)
 	strlcpy(ams_delta_serio->phys, "GPIO/serio0",
 			sizeof(ams_delta_serio->phys));
 
-	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_DATA, "serio-data");
+	err = gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
 	if (err) {
-		pr_err("ams_delta_serio: Couldn't request gpio pin for data\n");
+		pr_err("ams_delta_serio: Couldn't request gpio pins\n");
 		goto serio;
 	}
-	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
-
-	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_CLK, "serio-clock");
-	if (err) {
-		pr_err("ams_delta_serio: couldn't request gpio pin for clock\n");
-		goto gpio_data;
-	}
-	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
 
 	err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
 			ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING,
@@ -143,7 +151,7 @@ static int __init ams_delta_serio_init(void)
 	if (err < 0) {
 		pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n",
 				gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK));
-		goto gpio_clk;
+		goto gpio;
 	}
 	/*
 	 * Since GPIO register handling for keyboard clock pin is performed
@@ -157,10 +165,8 @@ static int __init ams_delta_serio_init(void)
 	dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name);
 
 	return 0;
-gpio_clk:
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
-gpio_data:
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
+gpio:
+	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
 serio:
 	kfree(ams_delta_serio);
 	return err;
@@ -171,7 +177,6 @@ static void __exit ams_delta_serio_exit(void)
 {
 	serio_unregister_port(ams_delta_serio);
 	free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
+	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
 }
 module_exit(ams_delta_serio_exit);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 10/10] ARM: OMAP1: ams-delta: Drop custom I/O functions
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
                   ` (8 preceding siblings ...)
  2011-12-11 20:12 ` [PATCH 09/10] input: serio: ams-delta: Toggle keyboard power " Janusz Krzysztofik
@ 2011-12-11 20:12 ` Janusz Krzysztofik
  2011-12-12  5:00 ` [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Jonathan McDowell
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-11 20:12 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik

Those are no longer required after all drivers which used them have been
converted to the GPIO interface.

Depends on patch 9/10 "input: serio: ams-delta: Toggle keyboard power
over GPIO".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
 arch/arm/mach-omap1/board-ams-delta.c             |   17 +++--------------
 arch/arm/plat-omap/include/plat/board-ams-delta.h |   10 ----------
 2 files changed, 3 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 587118c..bed43b4 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -258,19 +258,6 @@ static struct gpio _latch_gpios[] __initconst = {
 	},
 };
 
-void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
-{
-	int bit;
-	u16 bitpos;
-
-	for (bit = 0; bit < ngpio; bit++) {
-		bitpos = 1 << bit;
-		if (mask & bitpos)
-			gpio_set_value(base + bit, (value & bitpos) != 0);
-	}
-}
-EXPORT_SYMBOL(ams_delta_latch_write);
-
 static struct resource ams_delta_nand_resources[] = {
 	[0] = {
 		.start	= OMAP1_MPUIO_BASE,
@@ -441,7 +428,9 @@ static void __init ams_delta_init(void)
 	omap_register_i2c_bus(1, 100, NULL, 0);
 
 	platform_add_devices(_latch_devices, ARRAY_SIZE(_latch_devices));
-	BUG_ON(gpio_request_array(_latch_gpios, ARRAY_SIZE(_latch_gpios)));
+	/* Initialize pins not used by any drivers */
+	gpio_request_array(_latch_gpios, ARRAY_SIZE(_latch_gpios));
+	gpio_free_array(_latch_gpios, ARRAY_SIZE(_latch_gpios));
 
 	omap1_usb_init(&ams_delta_usb_config);
 	omap1_set_camera_info(&ams_delta_camera_platform_data);
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 004c827..b09b69d 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,9 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
-#define AMD_DELTA_LATCH2_SCARD_CMDVCC	0x0800
-
 #define AMS_DELTA_GPIO_PIN_KEYBRD_DATA	0
 #define AMS_DELTA_GPIO_PIN_KEYBRD_CLK	1
 #define AMS_DELTA_GPIO_PIN_MODEM_IRQ	2
@@ -58,13 +55,6 @@
 #define AMS_DELTA_LATCH2_GPIO_BASE	AMS_DELTA_GPIO_PIN_LCD_VBLEN
 #define AMS_DELTA_LATCH2_NGPIO		16
 
-#ifndef __ASSEMBLY__
-void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value);
-#endif
-#define ams_delta_latch2_write(mask, value) \
-	ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \
-			AMS_DELTA_LATCH2_NGPIO, (mask), (value))
-
 #endif /* CONFIG_MACH_AMS_DELTA */
 
 #endif /* __ASM_ARCH_OMAP_AMS_DELTA_H */
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* Re: [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API
  2011-12-11 20:12 ` [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API Janusz Krzysztofik
@ 2011-12-12  4:29   ` Mark Brown
  2011-12-21 18:33   ` Liam Girdwood
  1 sibling, 0 replies; 63+ messages in thread
From: Mark Brown @ 2011-12-12  4:29 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, Jarkko Nikula, linux-omap, linux-arm-kernel,
	linux-kernel, alsa-devel, Liam Girdwood

On Sun, Dec 11, 2011 at 09:12:05PM +0100, Janusz Krzysztofik wrote:
> Don't use Amstrad Delta custom I/O functions any longer, replace them
> with GPIO. Old pin definitions, no longer used by the modem bits either,
> can be dropped.

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
                   ` (9 preceding siblings ...)
  2011-12-11 20:12 ` [PATCH 10/10] ARM: OMAP1: ams-delta: Drop custom I/O functions Janusz Krzysztofik
@ 2011-12-12  5:00 ` Jonathan McDowell
  2011-12-19 23:08 ` [PATCH v2 0/7] " Janusz Krzysztofik
       [not found] ` <83e934adfc691b347534edb7788a67ab2e6bd7e1.1324331816.git.jkrzyszt@tis.icnet.pl>
  12 siblings, 0 replies; 63+ messages in thread
From: Jonathan McDowell @ 2011-12-12  5:00 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, Grant Likely, Dmitry Torokhov, Richard Purdie,
	David Woodhouse, Tomi Valkeinen, Jarkko Nikula, linux-fbdev,
	alsa-devel, Mark Brown, linux-kernel, linux-mtd, linux-input,
	linux-omap, Liam Girdwood, linux-arm-kernel

On Sun, Dec 11, 2011 at 09:11:58PM +0100, Janusz Krzysztofik wrote:
> The Amstrad Delta board has two extra output ports used for driving
> input lines of different on-board devices. Those ports are now
> controlled with custom functions, provided by the board arch code and
> used by several device drivers.
> 
> The idea behind the series is to replace those custom I/O functions
> with gpiolib API. This way, existing drivers can be made less platform
> dependent, and some of them perhaps even superseded with generic GPIO
> based drivers after the board platform device descriptions are
> converted. Moreover, should a new driver for the on-board Smart Card
> controller ever be created, it could be designed as a generic GPIO
> based driver, not a custom one.

Nice work; moving ams-delta over to gpiolib has been on my todo list for
a while (albeit quite low down).

J.

-- 
I just Fedexed my soul to hell. I'm *real* clever.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 09/10] input: serio: ams-delta: Toggle keyboard power over GPIO
  2011-12-11 20:12 ` [PATCH 09/10] input: serio: ams-delta: Toggle keyboard power " Janusz Krzysztofik
@ 2011-12-12  8:18   ` Dmitry Torokhov
  0 siblings, 0 replies; 63+ messages in thread
From: Dmitry Torokhov @ 2011-12-12  8:18 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, linux-omap, linux-arm-kernel, linux-kernel, linux-input

On Sun, Dec 11, 2011 at 09:12:07PM +0100, Janusz Krzysztofik wrote:
> Don't use Amstrad Delta custom I/O functions once GPIO interface is
> available for the underlying hardware.
> 
> Depends on patch 8/10 "omapfb: lcd_ams_delta: Drive control lines over
> GPIO".
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>

Acked-by: Dmitry Torokhov <dtor@mail.ru>

> ---
>  arch/arm/mach-omap1/board-ams-delta.c             |    5 --
>  arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 -
>  drivers/input/serio/ams_delta_serio.c             |   45 +++++++++++---------
>  3 files changed, 25 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
> index b7422e3..587118c 100644
> --- a/arch/arm/mach-omap1/board-ams-delta.c
> +++ b/arch/arm/mach-omap1/board-ams-delta.c
> @@ -232,11 +232,6 @@ static struct gpio _latch_gpios[] __initconst = {
>  		.label	= "dockit2",
>  	},
>  	{
> -		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
> -		.flags	= GPIOF_OUT_INIT_LOW,
> -		.label	= "keybrd_pwr",
> -	},
> -	{
>  		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
>  		.flags	= GPIOF_OUT_INIT_LOW,
>  		.label	= "keybrd_dataout",
> diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
> index 1d0706e..004c827 100644
> --- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
> +++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
> @@ -28,8 +28,6 @@
>  
>  #if defined (CONFIG_MACH_AMS_DELTA)
>  
> -#define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
> -#define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
>  #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
>  #define AMD_DELTA_LATCH2_SCARD_CMDVCC	0x0800
>  
> diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
> index d4d08bd..1499c7d 100644
> --- a/drivers/input/serio/ams_delta_serio.c
> +++ b/drivers/input/serio/ams_delta_serio.c
> @@ -92,8 +92,7 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
>  static int ams_delta_serio_open(struct serio *serio)
>  {
>  	/* enable keyboard */
> -	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR,
> -			AMD_DELTA_LATCH2_KEYBRD_PWR);
> +	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1);
>  
>  	return 0;
>  }
> @@ -101,9 +100,26 @@ static int ams_delta_serio_open(struct serio *serio)
>  static void ams_delta_serio_close(struct serio *serio)
>  {
>  	/* disable keyboard */
> -	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 0);
> +	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0);
>  }
>  
> +static struct gpio _gpios[] __initconst_or_module = {
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
> +		.flags	= GPIOF_DIR_IN,
> +		.label	= "serio-data",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
> +		.flags	= GPIOF_DIR_IN,
> +		.label	= "serio-clock",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "serio-power",
> +	},
> +};
>  static int __init ams_delta_serio_init(void)
>  {
>  	int err;
> @@ -123,19 +139,11 @@ static int __init ams_delta_serio_init(void)
>  	strlcpy(ams_delta_serio->phys, "GPIO/serio0",
>  			sizeof(ams_delta_serio->phys));
>  
> -	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_DATA, "serio-data");
> +	err = gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
>  	if (err) {
> -		pr_err("ams_delta_serio: Couldn't request gpio pin for data\n");
> +		pr_err("ams_delta_serio: Couldn't request gpio pins\n");
>  		goto serio;
>  	}
> -	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> -
> -	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_CLK, "serio-clock");
> -	if (err) {
> -		pr_err("ams_delta_serio: couldn't request gpio pin for clock\n");
> -		goto gpio_data;
> -	}
> -	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
>  
>  	err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
>  			ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING,
> @@ -143,7 +151,7 @@ static int __init ams_delta_serio_init(void)
>  	if (err < 0) {
>  		pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n",
>  				gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK));
> -		goto gpio_clk;
> +		goto gpio;
>  	}
>  	/*
>  	 * Since GPIO register handling for keyboard clock pin is performed
> @@ -157,10 +165,8 @@ static int __init ams_delta_serio_init(void)
>  	dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name);
>  
>  	return 0;
> -gpio_clk:
> -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
> -gpio_data:
> -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> +gpio:
> +	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
>  serio:
>  	kfree(ams_delta_serio);
>  	return err;
> @@ -171,7 +177,6 @@ static void __exit ams_delta_serio_exit(void)
>  {
>  	serio_unregister_port(ams_delta_serio);
>  	free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
> -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
> -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> +	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
>  }
>  module_exit(ams_delta_serio_exit);
> -- 
> 1.7.3.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Dmitry

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/10] omapfb: lcd_ams_delta: Drive control lines over GPIO
  2011-12-11 20:12 ` [PATCH 08/10] omapfb: lcd_ams_delta: Drive control lines over GPIO Janusz Krzysztofik
@ 2011-12-12 11:24   ` Tomi Valkeinen
  0 siblings, 0 replies; 63+ messages in thread
From: Tomi Valkeinen @ 2011-12-12 11:24 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, linux-omap, linux-arm-kernel, linux-kernel, linux-fbdev

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

On Sun, 2011-12-11 at 21:12 +0100, Janusz Krzysztofik wrote:
> Don't use Amstrad Delta custom I/O functions any longer, use GPIO API
> instead.
> 
> Depends on patch 5/10 "MTD: NAND: ams-delta: Use GPIO instead of custom
> I/O".
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> ---
>  arch/arm/mach-omap1/board-ams-delta.c             |   10 -------
>  arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 -
>  drivers/video/omap/lcd_ams_delta.c                |   27 +++++++++++++++-----
>  3 files changed, 20 insertions(+), 19 deletions(-)

Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-11 20:11 ` [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore Janusz Krzysztofik
@ 2011-12-12 18:04   ` Tony Lindgren
  2011-12-12 23:05     ` Janusz Krzysztofik
  2011-12-14 11:13   ` Janusz Krzysztofik
  1 sibling, 1 reply; 63+ messages in thread
From: Tony Lindgren @ 2011-12-12 18:04 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Grant Likely, linux-omap, linux-arm-kernel, linux-kernel

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111211 11:41]:
> This will allow boards with custom memory mapped GPIO ports to set up
> and use those port pins while initializing devices from arch init.

Care to explain a bit more why you need to initialize those devices
early on?

Usually moving things earlier and earlier is an endless loop 
adding more and more nasty dependencies..

I'd rather see things getting initialized later as regular
device drivers so we have decent kernel error messages when
something goes wrong without having to enable debug_ll.

Regards,

Tony


> Created against linux-3.2-rc5.
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> ---
>  drivers/gpio/gpio-generic.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
> index 4e24436..a6eaf38 100644
> --- a/drivers/gpio/gpio-generic.c
> +++ b/drivers/gpio/gpio-generic.c
> @@ -528,7 +528,7 @@ static int __init bgpio_platform_init(void)
>  {
>  	return platform_driver_register(&bgpio_driver);
>  }
> -module_init(bgpio_platform_init);
> +postcore_initcall(bgpio_platform_init);
>  
>  static void __exit bgpio_platform_exit(void)
>  {
> -- 
> 1.7.3.4
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-12 18:04   ` Tony Lindgren
@ 2011-12-12 23:05     ` Janusz Krzysztofik
  2011-12-12 23:15       ` Tony Lindgren
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-12 23:05 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Grant Likely, linux-omap, linux-arm-kernel, linux-kernel,
	Greg Kroah-Hartman, linux-serial

(adding Greg Kroah-Hartman and linux-serial@vger.kernel.org to Cc:)

On Monday 12 of December 2011 at 19:04:56, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111211 11:41]:
> > This will allow boards with custom memory mapped GPIO ports to set up
> > and use those port pins while initializing devices from arch init.
> 
> Care to explain a bit more why you need to initialize those devices
> early on?

Let me try.

>From patch 2/10 "ARM: OMAP1: ams-delta: Convert latches to 
basic_mmio_gpio":

> @@ -307,8 +487,8 @@ static void __init ams_delta_init(void)
>  	omap_serial_init();
>  	omap_register_i2c_bus(1, 100, NULL, 0);
>  
> -	/* Clear latch2 (NAND, LCD, modem enable) */
> -	ams_delta_latch2_write(~0, 0);
> +	platform_add_devices(_latch_devices, ARRAY_SIZE(_latch_devices));
> +	BUG_ON(gpio_request_array(_latch_gpios, ARRAY_SIZE(_latch_gpios)));
>  
>  	omap1_usb_init(&ams_delta_usb_config);
>  	omap1_set_camera_info(&ams_delta_camera_platform_data);

Here I'm accessing the latches from ams_delta_init() (.init_machine 
hook) with gpio_request_array() in order to:
a) clear their contents,
b) avoid accessing them, from ams_delta_latch_write(), never requested.

I could imagine clearing their contents with something like

	*(volatile __u8 *) AMS_DELTA_LATCH2_VIRT = 0;
	*(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = 0;

instead, i.e., the way the old code used to, than accessing those GPIO 
pins not requested, until they are finally requested by drivers updated 
to use gpiolib with successive patche. Would this be acceptable?

However,
>From patch 6/10 "ARM: OMAP1: ams-delta: Use GPIO API in modem setup":

> @@ -482,6 +472,12 @@ static void __init ams_delta_init(void)
>  	omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
>  }
>  
> +static void _modem_pm(struct uart_port *port, unsigned int state, unsigned old)
> +{
> +	if (state != old)
> +		gpio_set_value(AMS_DELTA_GPIO_PIN_MODEM_NRESET, state == 0);
> +}
> +
>  static struct plat_serial8250_port ams_delta_modem_ports[] = {
>  	{
>  		.membase	= IOMEM(_MODEM_VIRT),
> @@ -492,6 +488,7 @@ static struct plat_serial8250_port ams_delta_modem_ports[] = {
>  		.iotype		= UPIO_MEM,
>  		.regshift	= 1,
>  		.uartclk	= BASE_BAUD * 16,
> +		.pm		= _modem_pm,
>  	},
>  	{ },
>  };
> @@ -504,6 +501,24 @@ static struct platform_device ams_delta_modem_device = {
>  	},
>  };
>  
> +static struct gpio _modem_gpios[] __initconst = {
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_IRQ,
> +		.flags	= GPIOF_DIR_IN,
> +		.label	= "modem_irq",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
> +		.flags	= GPIOF_OUT_INIT_HIGH,
> +		.label	= "modem_nreset",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_CODEC,
> +		.flags	= GPIOF_OUT_INIT_HIGH,
> +		.label	= "modem_codec",
> +	},
> +};
> +
>  static int __init ams_delta_modem_init(void)
>  {
>  	int err;
> @@ -515,16 +530,11 @@ static int __init ams_delta_modem_init(void)
>  	ams_delta_modem_ports[0].irq =
>  			gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
>  
> -	err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem");
> +	err = gpio_request_array(_modem_gpios, ARRAY_SIZE(_modem_gpios));
>  	if (err) {
> -		pr_err("Couldn't request gpio pin for modem\n");
> +		pr_err("Couldn't request gpio pins for modem\n");
>  		return err;
>  	}
> -	gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> -
> -	ams_delta_latch2_write(
> -		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
> -		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
>  
>  	return platform_device_register(&ams_delta_modem_device);
>  }

Before the change, only one GPIO pin, that IRQ, driven with omap_gpio 
driver which is registered from postcore, was gpio_request()ed. Now, two 
more, gpio-generic driven pins, are also requested _and_ initialized in 
order to make the modem accessible. The ams_delta_modem_init() is 
installed with arch_initcall().

I could imagine initializing those modem pins the old way I've suggested 
above, but I can see no good solution to delegate calling of that 
gpio_request*() to the 8250 driver. For me, the only hook passed to the 
driver with platform_data that can be suitable is the .pm hook. However, 
when I tried to remove powering up the modem (rising up 
AMS_DELTA_GPIO_PIN_MODEM_NRESET) from the arch init and do this only 
from that .pm hook, the device was not detected, so I wonder if and when 
that hook is called, and if it is before probe, then perhaps powering 
up the modem chip from there is too late for the device to get up before 
being examined. But then, maybe if we initialize the pin the old way 
from arch init, it would be enough for the device to be detected, while 
consecutive open() response times may not be so critical. Perhaps Greg 
or another serial guru can shed some more light on this.

But this way or another, we are talking about dirty hacks here IMHO.

Thanks,
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-12 23:05     ` Janusz Krzysztofik
@ 2011-12-12 23:15       ` Tony Lindgren
  2011-12-12 23:44         ` Janusz Krzysztofik
  0 siblings, 1 reply; 63+ messages in thread
From: Tony Lindgren @ 2011-12-12 23:15 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Grant Likely, linux-omap, linux-arm-kernel, linux-kernel,
	Greg Kroah-Hartman, linux-serial

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111212 14:36]:
> (adding Greg Kroah-Hartman and linux-serial@vger.kernel.org to Cc:)
> 
> On Monday 12 of December 2011 at 19:04:56, Tony Lindgren wrote:
> > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111211 11:41]:
> > > This will allow boards with custom memory mapped GPIO ports to set up
> > > and use those port pins while initializing devices from arch init.
> > 
> > Care to explain a bit more why you need to initialize those devices
> > early on?
> 
> Let me try.
> 
> From patch 2/10 "ARM: OMAP1: ams-delta: Convert latches to 
> basic_mmio_gpio":
> 
> > @@ -307,8 +487,8 @@ static void __init ams_delta_init(void)
> >  	omap_serial_init();
> >  	omap_register_i2c_bus(1, 100, NULL, 0);
> >  
> > -	/* Clear latch2 (NAND, LCD, modem enable) */
> > -	ams_delta_latch2_write(~0, 0);
> > +	platform_add_devices(_latch_devices, ARRAY_SIZE(_latch_devices));
> > +	BUG_ON(gpio_request_array(_latch_gpios, ARRAY_SIZE(_latch_gpios)));
> >  
> >  	omap1_usb_init(&ams_delta_usb_config);
> >  	omap1_set_camera_info(&ams_delta_camera_platform_data);
> 
> Here I'm accessing the latches from ams_delta_init() (.init_machine 
> hook) with gpio_request_array() in order to:
> a) clear their contents,
> b) avoid accessing them, from ams_delta_latch_write(), never requested.
> 
> I could imagine clearing their contents with something like
> 
> 	*(volatile __u8 *) AMS_DELTA_LATCH2_VIRT = 0;
> 	*(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = 0;
> 
> instead, i.e., the way the old code used to, than accessing those GPIO 
> pins not requested, until they are finally requested by drivers updated 
> to use gpiolib with successive patche. Would this be acceptable?

Thanks for explaining, it's best to use gpio calls instead :)

How about just add some __initcall into your board-*.c file to
do the required setups a bit later? Just make sure you exit
early if (!machine_is...) fails.

> However,
> From patch 6/10 "ARM: OMAP1: ams-delta: Use GPIO API in modem setup":
> 
> > @@ -482,6 +472,12 @@ static void __init ams_delta_init(void)
> >  	omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
> >  }
> >  
> > +static void _modem_pm(struct uart_port *port, unsigned int state, unsigned old)
> > +{
> > +	if (state != old)
> > +		gpio_set_value(AMS_DELTA_GPIO_PIN_MODEM_NRESET, state == 0);
> > +}
> > +
> >  static struct plat_serial8250_port ams_delta_modem_ports[] = {
> >  	{
> >  		.membase	= IOMEM(_MODEM_VIRT),
> > @@ -492,6 +488,7 @@ static struct plat_serial8250_port ams_delta_modem_ports[] = {
> >  		.iotype		= UPIO_MEM,
> >  		.regshift	= 1,
> >  		.uartclk	= BASE_BAUD * 16,
> > +		.pm		= _modem_pm,
> >  	},
> >  	{ },
> >  };
> > @@ -504,6 +501,24 @@ static struct platform_device ams_delta_modem_device = {
> >  	},
> >  };
> >  
> > +static struct gpio _modem_gpios[] __initconst = {
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_IRQ,
> > +		.flags	= GPIOF_DIR_IN,
> > +		.label	= "modem_irq",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
> > +		.flags	= GPIOF_OUT_INIT_HIGH,
> > +		.label	= "modem_nreset",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_CODEC,
> > +		.flags	= GPIOF_OUT_INIT_HIGH,
> > +		.label	= "modem_codec",
> > +	},
> > +};
> > +
> >  static int __init ams_delta_modem_init(void)
> >  {
> >  	int err;
> > @@ -515,16 +530,11 @@ static int __init ams_delta_modem_init(void)
> >  	ams_delta_modem_ports[0].irq =
> >  			gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> >  
> > -	err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem");
> > +	err = gpio_request_array(_modem_gpios, ARRAY_SIZE(_modem_gpios));
> >  	if (err) {
> > -		pr_err("Couldn't request gpio pin for modem\n");
> > +		pr_err("Couldn't request gpio pins for modem\n");
> >  		return err;
> >  	}
> > -	gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> > -
> > -	ams_delta_latch2_write(
> > -		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
> > -		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
> >  
> >  	return platform_device_register(&ams_delta_modem_device);
> >  }
> 
> Before the change, only one GPIO pin, that IRQ, driven with omap_gpio 
> driver which is registered from postcore, was gpio_request()ed. Now, two 
> more, gpio-generic driven pins, are also requested _and_ initialized in 
> order to make the modem accessible. The ams_delta_modem_init() is 
> installed with arch_initcall().
> 
> I could imagine initializing those modem pins the old way I've suggested 
> above, but I can see no good solution to delegate calling of that 
> gpio_request*() to the 8250 driver. For me, the only hook passed to the 
> driver with platform_data that can be suitable is the .pm hook. However, 
> when I tried to remove powering up the modem (rising up 
> AMS_DELTA_GPIO_PIN_MODEM_NRESET) from the arch init and do this only 
> from that .pm hook, the device was not detected, so I wonder if and when 
> that hook is called, and if it is before probe, then perhaps powering 
> up the modem chip from there is too late for the device to get up before 
> being examined. But then, maybe if we initialize the pin the old way 
> from arch init, it would be enough for the device to be detected, while 
> consecutive open() response times may not be so critical. Perhaps Greg 
> or another serial guru can shed some more light on this.
> 
> But this way or another, we are talking about dirty hacks here IMHO.

Might be worth checking if some board specific __initcall helps here
too?

Regards,

Tony

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-12 23:15       ` Tony Lindgren
@ 2011-12-12 23:44         ` Janusz Krzysztofik
  2011-12-12 23:55           ` Tony Lindgren
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-12 23:44 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Grant Likely, linux-omap, linux-arm-kernel, linux-kernel,
	Greg Kroah-Hartman, linux-serial

On Tuesday 13 of December 2011 at 00:15:20, Tony Lindgren wrote:
> 
> Might be worth checking if some board specific __initcall helps here
> too?

If I only knew how I could insert a board specific __initcall between 
two points from where the generic-gpio first, then the 8250 driver, are 
called.

Any hints?

Thanks,
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-12 23:44         ` Janusz Krzysztofik
@ 2011-12-12 23:55           ` Tony Lindgren
  2011-12-13  0:15             ` Janusz Krzysztofik
  2011-12-14 13:10             ` Janusz Krzysztofik
  0 siblings, 2 replies; 63+ messages in thread
From: Tony Lindgren @ 2011-12-12 23:55 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Grant Likely, linux-omap, linux-arm-kernel, linux-kernel,
	Greg Kroah-Hartman, linux-serial

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111212 15:13]:
> On Tuesday 13 of December 2011 at 00:15:20, Tony Lindgren wrote:
> > 
> > Might be worth checking if some board specific __initcall helps here
> > too?
> 
> If I only knew how I could insert a board specific __initcall between 
> two points from where the generic-gpio first, then the 8250 driver, are 
> called.
> 
> Any hints?

Hmm, can't you do all that in the order you want in
ams_delta_modem_init()?  Or make that into a late_initcall so
you have generic-gpio available?

It seems that the pieces of code you're talking about don't need
to be initialized early, just needs to be done in the right
order to get things working.

Regards,

Tony

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-12 23:55           ` Tony Lindgren
@ 2011-12-13  0:15             ` Janusz Krzysztofik
  2011-12-14 13:10             ` Janusz Krzysztofik
  1 sibling, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-13  0:15 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Grant Likely, linux-omap, linux-arm-kernel, linux-kernel,
	Greg Kroah-Hartman, linux-serial

On Tuesday 13 of December 2011 at 00:55:44, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111212 15:13]:
> > On Tuesday 13 of December 2011 at 00:15:20, Tony Lindgren wrote:
> > > 
> > > Might be worth checking if some board specific __initcall helps here
> > > too?
> > 
> > If I only knew how I could insert a board specific __initcall between 
> > two points from where the generic-gpio first, then the 8250 driver, are 
> > called.
> > 
> > Any hints?
> 
> Hmm, can't you do all that in the order you want in
> ams_delta_modem_init()?  Or make that into a late_initcall so
> you have generic-gpio available?
> 
> It seems that the pieces of code you're talking about don't need
> to be initialized early, just needs to be done in the right
> order to get things working.

I think I've got it, thanks!
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-11 20:11 ` [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore Janusz Krzysztofik
  2011-12-12 18:04   ` Tony Lindgren
@ 2011-12-14 11:13   ` Janusz Krzysztofik
  1 sibling, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-14 11:13 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Grant Likely, linux-omap, linux-arm-kernel, linux-kernel

On Sunday 11 of December 2011 at 21:11:59, Janusz Krzysztofik wrote:
> This will allow boards with custom memory mapped GPIO ports to set up
> and use those port pins while initializing devices from arch init.

Please ignore this patch, I'm going to submit a replacement, based on an 
alternative approach suggested by Tony.

Thanks,
Janusz

> Created against linux-3.2-rc5.
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> ---
>  drivers/gpio/gpio-generic.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
> index 4e24436..a6eaf38 100644
> --- a/drivers/gpio/gpio-generic.c
> +++ b/drivers/gpio/gpio-generic.c
> @@ -528,7 +528,7 @@ static int __init bgpio_platform_init(void)
>  {
>  	return platform_driver_register(&bgpio_driver);
>  }
> -module_init(bgpio_platform_init);
> +postcore_initcall(bgpio_platform_init);
>  
>  static void __exit bgpio_platform_exit(void)
>  {
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-12 23:55           ` Tony Lindgren
  2011-12-13  0:15             ` Janusz Krzysztofik
@ 2011-12-14 13:10             ` Janusz Krzysztofik
  2011-12-14 18:21               ` Tony Lindgren
  1 sibling, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-14 13:10 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Grant Likely, linux-omap, linux-arm-kernel, linux-kernel,
	Greg Kroah-Hartman, linux-serial

On Tuesday 13 of December 2011 at 00:55:44, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111212 15:13]:
> > On Tuesday 13 of December 2011 at 00:15:20, Tony Lindgren wrote:
> > > 
> > > Might be worth checking if some board specific __initcall helps here
> > > too?
> > 
> > If I only knew how I could insert a board specific __initcall between 
> > two points from where the generic-gpio first, then the 8250 driver, are 
> > called.
> > 
> > Any hints?
> 
> Hmm, can't you do all that in the order you want in
> ams_delta_modem_init()?  Or make that into a late_initcall so
> you have generic-gpio available?
> 
> It seems that the pieces of code you're talking about don't need
> to be initialized early, just needs to be done in the right
> order to get things working.

Hi,
I'm almost done with moving registration of all latch dependent devices 
down to a late_initcall hook, however while working on this, I've found 
still another arrangement, yet better in my opinion:
1) generic-gpio driver registration moved from device_initcall up to 
   subsys_initcall,
2) latch dependent device registration left at arch_initcall, as it is 
   now,
3) a temporary hack, removed with the last patch in the series, that 
   requests GPIO pins on behalf of device drivers before those are 
   updated, placed between subsys_initcall and device_initcall, i.e., at 
   fs_initcall or rootfs_initcall; both look ugly, but this is only for 
   a while, in order to keep things working while in the transition,
4) the modem init hook, once updated with extra GPIO setup that must be 
   done on behalf of the 8250 driver, which is not prepared for 
   accepting any extra init hooks passed with the device platform data, 
   moved down to late_initcall, as suggested,
5) once all drivers are updated, the hack is removed, and an 
   initialization of unused pins added to that late_initcall modem hook, 
   perhaps renamed in order to not suggest it is still modem only 
   related.

What do you think?

Thanks,
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-14 13:10             ` Janusz Krzysztofik
@ 2011-12-14 18:21               ` Tony Lindgren
  2011-12-14 20:07                 ` Janusz Krzysztofik
  0 siblings, 1 reply; 63+ messages in thread
From: Tony Lindgren @ 2011-12-14 18:21 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Grant Likely, linux-omap, linux-arm-kernel, linux-kernel,
	Greg Kroah-Hartman, linux-serial

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111214 04:40]:
> On Tuesday 13 of December 2011 at 00:55:44, Tony Lindgren wrote:
> > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111212 15:13]:
> > > On Tuesday 13 of December 2011 at 00:15:20, Tony Lindgren wrote:
> > > > 
> > > > Might be worth checking if some board specific __initcall helps here
> > > > too?
> > > 
> > > If I only knew how I could insert a board specific __initcall between 
> > > two points from where the generic-gpio first, then the 8250 driver, are 
> > > called.
> > > 
> > > Any hints?
> > 
> > Hmm, can't you do all that in the order you want in
> > ams_delta_modem_init()?  Or make that into a late_initcall so
> > you have generic-gpio available?
> > 
> > It seems that the pieces of code you're talking about don't need
> > to be initialized early, just needs to be done in the right
> > order to get things working.
> 
> Hi,
> I'm almost done with moving registration of all latch dependent devices 
> down to a late_initcall hook, however while working on this, I've found 
> still another arrangement, yet better in my opinion:
> 1) generic-gpio driver registration moved from device_initcall up to 
>    subsys_initcall,
> 2) latch dependent device registration left at arch_initcall, as it is 
>    now,
> 3) a temporary hack, removed with the last patch in the series, that 
>    requests GPIO pins on behalf of device drivers before those are 
>    updated, placed between subsys_initcall and device_initcall, i.e., at 
>    fs_initcall or rootfs_initcall; both look ugly, but this is only for 
>    a while, in order to keep things working while in the transition,
> 4) the modem init hook, once updated with extra GPIO setup that must be 
>    done on behalf of the 8250 driver, which is not prepared for 
>    accepting any extra init hooks passed with the device platform data, 
>    moved down to late_initcall, as suggested,
> 5) once all drivers are updated, the hack is removed, and an 
>    initialization of unused pins added to that late_initcall modem hook, 
>    perhaps renamed in order to not suggest it is still modem only 
>    related.
> 
> What do you think?

Sounds better for sure than what we currently have :)

Tony

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-14 18:21               ` Tony Lindgren
@ 2011-12-14 20:07                 ` Janusz Krzysztofik
  2011-12-14 22:10                   ` Tony Lindgren
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-14 20:07 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Mark Brown, Liam Girdwood, Grant Likely, linux-omap,
	linux-arm-kernel, linux-kernel, Greg Kroah-Hartman, linux-serial

(adding Mark Brown and Liam Girdwood - regulator experts - to Cc:)

On Wednesday 14 of December 2011 at 19:21:49, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111214 04:40]:
> > On Tuesday 13 of December 2011 at 00:55:44, Tony Lindgren wrote:
> > > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111212 15:13]:
> > > > On Tuesday 13 of December 2011 at 00:15:20, Tony Lindgren wrote:
> > > > > 
> > > > > Might be worth checking if some board specific __initcall helps here
> > > > > too?
> > > > 
> > > > If I only knew how I could insert a board specific __initcall between 
> > > > two points from where the generic-gpio first, then the 8250 driver, are 
> > > > called.
> > > > 
> > > > Any hints?
> > > 
> > > Hmm, can't you do all that in the order you want in
> > > ams_delta_modem_init()?  Or make that into a late_initcall so
> > > you have generic-gpio available?
> > > 
> > > It seems that the pieces of code you're talking about don't need
> > > to be initialized early, just needs to be done in the right
> > > order to get things working.
> > 
> > Hi,
> > I'm almost done with moving registration of all latch dependent devices 
> > down to a late_initcall hook, however while working on this, I've found 
> > still another arrangement, yet better in my opinion:
> > 1) generic-gpio driver registration moved from device_initcall up to 
> >    subsys_initcall,
> > 2) latch dependent device registration left at arch_initcall, as it is 
> >    now,
> > 3) a temporary hack, removed with the last patch in the series, that 
> >    requests GPIO pins on behalf of device drivers before those are 
> >    updated, placed between subsys_initcall and device_initcall, i.e., at 
> >    fs_initcall or rootfs_initcall; both look ugly, but this is only for 
> >    a while, in order to keep things working while in the transition,
> > 4) the modem init hook, once updated with extra GPIO setup that must be 
> >    done on behalf of the 8250 driver, which is not prepared for 
> >    accepting any extra init hooks passed with the device platform data, 
> >    moved down to late_initcall, as suggested,
> > 5) once all drivers are updated, the hack is removed, and an 
> >    initialization of unused pins added to that late_initcall modem hook, 
> >    perhaps renamed in order to not suggest it is still modem only 
> >    related.
> > 
> > What do you think?
> 
> Sounds better for sure than what we currently have :)

Hmm, better doesn't necessarily mean good enough...

I forgot about the sound device, which shares its latch based GPIO pins 
with the modem, so should be registered after the modem.

To make things still more complicated, one of those GPIO pins provides 
power to both devices, so a still better solution I'd like to introduce 
would be a GPIO controlled regulator device which feeds both the modem 
and the sound card with power.

I've had a look at both generic regulator drivers, fixed.c and gpio-
regulator.c, both controlling devices over GPIO pins, and found those 
drivers registered at subsys_initcall level, calling gpio_request*() at 
probe time. Then again, we would need that base_mmio_gpio driver already 
registered before subsys_initcall.

Any suggestions?

Thanks,
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore
  2011-12-14 20:07                 ` Janusz Krzysztofik
@ 2011-12-14 22:10                   ` Tony Lindgren
  0 siblings, 0 replies; 63+ messages in thread
From: Tony Lindgren @ 2011-12-14 22:10 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Mark Brown, Liam Girdwood, Grant Likely, linux-omap,
	linux-arm-kernel, linux-kernel, Greg Kroah-Hartman, linux-serial

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111214 11:36]:
> (adding Mark Brown and Liam Girdwood - regulator experts - to Cc:)
> 
> On Wednesday 14 of December 2011 at 19:21:49, Tony Lindgren wrote:
> > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111214 04:40]:
> > > On Tuesday 13 of December 2011 at 00:55:44, Tony Lindgren wrote:
> > > > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111212 15:13]:
> > > > > On Tuesday 13 of December 2011 at 00:15:20, Tony Lindgren wrote:
> > > > > > 
> > > > > > Might be worth checking if some board specific __initcall helps here
> > > > > > too?
> > > > > 
> > > > > If I only knew how I could insert a board specific __initcall between 
> > > > > two points from where the generic-gpio first, then the 8250 driver, are 
> > > > > called.
> > > > > 
> > > > > Any hints?
> > > > 
> > > > Hmm, can't you do all that in the order you want in
> > > > ams_delta_modem_init()?  Or make that into a late_initcall so
> > > > you have generic-gpio available?
> > > > 
> > > > It seems that the pieces of code you're talking about don't need
> > > > to be initialized early, just needs to be done in the right
> > > > order to get things working.
> > > 
> > > Hi,
> > > I'm almost done with moving registration of all latch dependent devices 
> > > down to a late_initcall hook, however while working on this, I've found 
> > > still another arrangement, yet better in my opinion:
> > > 1) generic-gpio driver registration moved from device_initcall up to 
> > >    subsys_initcall,
> > > 2) latch dependent device registration left at arch_initcall, as it is 
> > >    now,
> > > 3) a temporary hack, removed with the last patch in the series, that 
> > >    requests GPIO pins on behalf of device drivers before those are 
> > >    updated, placed between subsys_initcall and device_initcall, i.e., at 
> > >    fs_initcall or rootfs_initcall; both look ugly, but this is only for 
> > >    a while, in order to keep things working while in the transition,
> > > 4) the modem init hook, once updated with extra GPIO setup that must be 
> > >    done on behalf of the 8250 driver, which is not prepared for 
> > >    accepting any extra init hooks passed with the device platform data, 
> > >    moved down to late_initcall, as suggested,
> > > 5) once all drivers are updated, the hack is removed, and an 
> > >    initialization of unused pins added to that late_initcall modem hook, 
> > >    perhaps renamed in order to not suggest it is still modem only 
> > >    related.
> > > 
> > > What do you think?
> > 
> > Sounds better for sure than what we currently have :)
> 
> Hmm, better doesn't necessarily mean good enough...
> 
> I forgot about the sound device, which shares its latch based GPIO pins 
> with the modem, so should be registered after the modem.
> 
> To make things still more complicated, one of those GPIO pins provides 
> power to both devices, so a still better solution I'd like to introduce 
> would be a GPIO controlled regulator device which feeds both the modem 
> and the sound card with power.
> 
> I've had a look at both generic regulator drivers, fixed.c and gpio-
> regulator.c, both controlling devices over GPIO pins, and found those 
> drivers registered at subsys_initcall level, calling gpio_request*() at 
> probe time. Then again, we would need that base_mmio_gpio driver already 
> registered before subsys_initcall.
> 
> Any suggestions?

Sounds like yet another case for the deferred probe patches posted
few weeks ago?

Regards,

Tony

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH v2 0/7] ARM: OMAP1: ams-delta: replace custom I/O with GPIO
  2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
                   ` (10 preceding siblings ...)
  2011-12-12  5:00 ` [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Jonathan McDowell
@ 2011-12-19 23:08 ` Janusz Krzysztofik
  2011-12-19 23:08   ` [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio Janusz Krzysztofik
                     ` (5 more replies)
       [not found] ` <83e934adfc691b347534edb7788a67ab2e6bd7e1.1324331816.git.jkrzyszt@tis.icnet.pl>
  12 siblings, 6 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-19 23:08 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Grant Likely, Dmitry Torokhov, Richard Purdie, David Woodhouse,
	Tomi Valkeinen, Jarkko Nikula, Liam Girdwood, Mark Brown,
	linux-input, linux-mtd, linux-fbdev, alsa-devel

The Amstrad Delta board has two extra output ports used for driving
input lines of different on-board devices. Those ports are now
controlled with custom functions, provided by the board arch code and
used by several device drivers.

The idea behind the series is to replace those custom I/O functions
with gpiolib API. This way, existing drivers can be made less platform
dependent, and some of them perhaps even superseded with generic GPIO
based drivers after the board platform device descriptions are
converted. Moreover, should a new driver for the on-board Smart Card
controller ever be created, it could be designed as a generic GPIO
based driver, not a custom one.

Changes against initial version:
* the initial patch, which tried to move the gpio-generic driver
  initialization up to the postcore_initcall level, replaced with an
  alternative solution, moving the on-board devices initialization down
  to late_initcall; thanks to Tony Lindgren who suggested this solution,
* dropped patches introducing changes to the modem and ASoC device
  handling; those will be addressed in a separate patch series,
* final cleanups also dropped until those remaining devices are updated,
* the serio driver now takes care of one more GPIO pin which, even if
  not used, belongs to the device interface and affects its functioning,
* misc code and changelog cosmetic cleanups,
* rebased on top of 3.2-rc6.


Thanks to those who reviewed the initial submission and responded with
their comments or Acks.

Janusz


Janusz Krzysztofik (7):
  ARM: OMAP1: ams-delta: register latch dependent devices later
  ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
  ARM: OMAP1: ams-delta: supersede custom led device by leds-gpio
  LED: drop leds-ams-delta driver
  MTD: NAND: ams-delta: use GPIO instead of custom I/O
  omapfb: lcd_ams_delta: drive control lines over GPIO
  input: serio: ams-delta: toggle keyboard power over GPIO

 arch/arm/mach-omap1/Kconfig                       |    2 +
 arch/arm/mach-omap1/board-ams-delta.c             |  226 +++++++++++++++++----
 arch/arm/plat-omap/include/plat/board-ams-delta.h |   48 ++---
 drivers/input/serio/ams_delta_serio.c             |   51 +++--
 drivers/leds/Kconfig                              |    7 -
 drivers/leds/Makefile                             |    1 -
 drivers/leds/leds-ams-delta.c                     |  137 -------------
 drivers/mtd/nand/ams-delta.c                      |   74 +++++--
 drivers/video/omap/lcd_ams_delta.c                |   27 ++-
 sound/soc/omap/ams-delta.c                        |    4 +
 10 files changed, 318 insertions(+), 259 deletions(-)
 delete mode 100644 drivers/leds/leds-ams-delta.c

-- 
1.7.3.4


^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
  2011-12-19 23:08 ` [PATCH v2 0/7] " Janusz Krzysztofik
@ 2011-12-19 23:08   ` Janusz Krzysztofik
  2011-12-20  0:06     ` Tony Lindgren
  2011-12-19 23:08   ` [PATCH v2 3/7] ARM: OMAP1: ams-delta: supersede custom led device by leds-gpio Janusz Krzysztofik
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-19 23:08 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Grant Likely

Once ready, ams-delta specific device drivers currently calling custom
ams_delta_latch[12]_write() functions can be updated to call generic
gpio_set_value() instead, which will make them less platform dependent.
Even more, some custom ams-delta only drivers can perhaps be dropped
from the tree after converting selected ams-delta platform devices to
follow generic GPIO based device models.

Depends on patch 1/7, "ARM: OMAP1: ams-delta: register latch dependent
devices later".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
Changes against initial version:
* refreshed on top of patch 1/7, which is the old 1/10 replacement,
* no need to BUG_ON() if GPIO request fails inside late_init(), can
  return with error from there insted,
* dropped leading underscores from local symbols, variable and function
  names (no namespace conflicts expected).


 arch/arm/mach-omap1/Kconfig                       |    1 +
 arch/arm/mach-omap1/board-ams-delta.c             |  237 ++++++++++++++++++---
 arch/arm/plat-omap/include/plat/board-ams-delta.h |   43 +++-
 3 files changed, 242 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index 73f287d..d2606b1 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -155,6 +155,7 @@ config MACH_AMS_DELTA
 	bool "Amstrad E3 (Delta)"
 	depends on ARCH_OMAP1 && ARCH_OMAP15XX
 	select FIQ
+	select GPIO_GENERIC_PLATFORM
 	help
 	  Support for the Amstrad E3 (codename Delta) videophone. Say Y here
 	  if you have such a device.
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 50987c9..cff2711 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -11,6 +11,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/basic_mmio_gpio.h>
 #include <linux/gpio.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -40,9 +41,6 @@
 
 #include <mach/ams-delta-fiq.h>
 
-static u8 ams_delta_latch1_reg;
-static u16 ams_delta_latch2_reg;
-
 static const unsigned int ams_delta_keymap[] = {
 	KEY(0, 0, KEY_F1),		/* Advert    */
 
@@ -121,39 +119,32 @@ static const unsigned int ams_delta_keymap[] = {
 	KEY(7, 3, KEY_LEFTCTRL),	/* Vol down  */
 };
 
-void ams_delta_latch1_write(u8 mask, u8 value)
-{
-	ams_delta_latch1_reg &= ~mask;
-	ams_delta_latch1_reg |= value;
-	*(volatile __u8 *) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg;
-}
-
-void ams_delta_latch2_write(u16 mask, u16 value)
-{
-	ams_delta_latch2_reg &= ~mask;
-	ams_delta_latch2_reg |= value;
-	*(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg;
-}
+#define LATCH1_PHYS	0x01000000
+#define LATCH1_VIRT	0xEA000000
+#define MODEM_PHYS	0x04000000
+#define MODEM_VIRT	0xEB000000
+#define LATCH2_PHYS	0x08000000
+#define LATCH2_VIRT	0xEC000000
 
 static struct map_desc ams_delta_io_desc[] __initdata = {
 	/* AMS_DELTA_LATCH1 */
 	{
-		.virtual	= AMS_DELTA_LATCH1_VIRT,
-		.pfn		= __phys_to_pfn(AMS_DELTA_LATCH1_PHYS),
+		.virtual	= LATCH1_VIRT,
+		.pfn		= __phys_to_pfn(LATCH1_PHYS),
 		.length		= 0x01000000,
 		.type		= MT_DEVICE
 	},
 	/* AMS_DELTA_LATCH2 */
 	{
-		.virtual	= AMS_DELTA_LATCH2_VIRT,
-		.pfn		= __phys_to_pfn(AMS_DELTA_LATCH2_PHYS),
+		.virtual	= LATCH2_VIRT,
+		.pfn		= __phys_to_pfn(LATCH2_PHYS),
 		.length		= 0x01000000,
 		.type		= MT_DEVICE
 	},
 	/* AMS_DELTA_MODEM */
 	{
-		.virtual	= AMS_DELTA_MODEM_VIRT,
-		.pfn		= __phys_to_pfn(AMS_DELTA_MODEM_PHYS),
+		.virtual	= MODEM_VIRT,
+		.pfn		= __phys_to_pfn(MODEM_PHYS),
 		.length		= 0x01000000,
 		.type		= MT_DEVICE
 	}
@@ -173,6 +164,190 @@ static struct omap_board_config_kernel ams_delta_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&ams_delta_lcd_config },
 };
 
+static struct resource latch1_resources[] __initconst = {
+	[0] = {
+		.name	= "dat",
+		.start	= LATCH1_PHYS,
+		.end	= LATCH1_PHYS + (AMS_DELTA_LATCH1_NGPIO - 1) / 8,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct bgpio_pdata latch1_pdata __initconst = {
+	.base	= AMS_DELTA_LATCH1_GPIO_BASE,
+	.ngpio	= AMS_DELTA_LATCH1_NGPIO,
+};
+
+static struct platform_device latch1_gpio_device = {
+	.name		= "basic-mmio-gpio",
+	.id		= 0,
+	.resource	= latch1_resources,
+	.num_resources	= ARRAY_SIZE(latch1_resources),
+	.dev		= {
+		.platform_data	= &latch1_pdata,
+	},
+};
+
+static struct resource latch2_resources[] __initconst = {
+	[0] = {
+		.name	= "dat",
+		.start	= LATCH2_PHYS,
+		.end	= LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct bgpio_pdata latch2_pdata __initconst = {
+	.base	= AMS_DELTA_LATCH2_GPIO_BASE,
+	.ngpio	= AMS_DELTA_LATCH2_NGPIO,
+};
+
+static struct platform_device latch2_gpio_device = {
+	.name		= "basic-mmio-gpio",
+	.id		= 1,
+	.resource	= latch2_resources,
+	.num_resources	= ARRAY_SIZE(latch2_resources),
+	.dev		= {
+		.platform_data	= &latch2_pdata,
+	},
+};
+
+static struct gpio latch_gpios[] __initconst = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_CAMERA,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_camera",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_ADVERT,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_advert",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_EMAIL,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_email",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_HANDSFREE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_handsfree",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICEMAIL,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_voicemail",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_voice",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 6,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "dockit1",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 7,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "dockit2",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_vblen",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_ndisp",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nce",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nre",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nwp",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nwe",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_ale",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_cle",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "keybrd_pwr",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "keybrd_dataout",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "scard_rstin",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "scard_cmdvcc",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "modem_nreset",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_CODEC,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "modem_codec",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 14,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "hookflash1",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 15,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "hookflash2",
+	},
+};
+
+void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
+{
+	int bit = 0;
+	u16 bitpos = 1 << bit;
+
+	for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
+		if (!(mask & bitpos))
+			continue;
+		gpio_set_value(base + bit, (value & bitpos) != 0);
+	}
+}
+EXPORT_SYMBOL(ams_delta_latch_write);
+
 static struct resource ams_delta_nand_resources[] = {
 	[0] = {
 		.start	= OMAP1_MPUIO_BASE,
@@ -275,11 +450,13 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
 };
 
 static struct platform_device *ams_delta_devices[] __initdata = {
+	&latch1_gpio_device,
+	&latch2_gpio_device,
 	&ams_delta_kp_device,
 	&ams_delta_camera_device,
 };
 
-static struct platform_device *late_devices[] __initdata = {
+static struct platform_device *late_devices[] __initconst = {
 	&ams_delta_nand_device,
 	&ams_delta_lcd_device,
 	&ams_delta_led_device,
@@ -325,8 +502,8 @@ static void __init ams_delta_init(void)
 
 static struct plat_serial8250_port ams_delta_modem_ports[] = {
 	{
-		.membase	= IOMEM(AMS_DELTA_MODEM_VIRT),
-		.mapbase	= AMS_DELTA_MODEM_PHYS,
+		.membase	= IOMEM(MODEM_VIRT),
+		.mapbase	= MODEM_PHYS,
 		.irq		= -EINVAL, /* changed later */
 		.flags		= UPF_BOOT_AUTOCONF,
 		.irqflags	= IRQF_TRIGGER_RISING,
@@ -352,8 +529,11 @@ static int __init late_init(void)
 	if (!machine_is_ams_delta())
 		return -ENODEV;
 
-	/* Clear latch2 (NAND, LCD, modem enable) */
-	ams_delta_latch2_write(~0, 0);
+	err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios));
+	if (err) {
+		pr_err("Couldn't take over latch1/latch2 GPIO pins\n");
+		return err;
+	}
 
 	platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
 
@@ -399,6 +579,3 @@ MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
 	.init_machine	= ams_delta_init,
 	.timer		= &omap1_timer,
 MACHINE_END
-
-EXPORT_SYMBOL(ams_delta_latch1_write);
-EXPORT_SYMBOL(ams_delta_latch2_write);
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 51b102d..68ffe32 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,13 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMS_DELTA_LATCH1_PHYS		0x01000000
-#define AMS_DELTA_LATCH1_VIRT		0xEA000000
-#define AMS_DELTA_MODEM_PHYS		0x04000000
-#define AMS_DELTA_MODEM_VIRT		0xEB000000
-#define AMS_DELTA_LATCH2_PHYS		0x08000000
-#define AMS_DELTA_LATCH2_VIRT		0xEC000000
-
 #define AMS_DELTA_LATCH1_LED_CAMERA	0x01
 #define AMS_DELTA_LATCH1_LED_ADVERT	0x02
 #define AMS_DELTA_LATCH1_LED_EMAIL	0x04
@@ -66,9 +59,41 @@
 #define AMS_DELTA_GPIO_PIN_CONFIG	11
 #define AMS_DELTA_GPIO_PIN_NAND_RB	12
 
+#define AMS_DELTA_GPIO_PIN_LED_CAMERA		232
+#define AMS_DELTA_GPIO_PIN_LED_ADVERT		233
+#define AMS_DELTA_GPIO_PIN_LED_EMAIL		234
+#define AMS_DELTA_GPIO_PIN_LED_HANDSFREE	235
+#define AMS_DELTA_GPIO_PIN_LED_VOICEMAIL	236
+#define AMS_DELTA_GPIO_PIN_LED_VOICE		237
+
+#define AMS_DELTA_GPIO_PIN_LCD_VBLEN		240
+#define AMS_DELTA_GPIO_PIN_LCD_NDISP		241
+#define AMS_DELTA_GPIO_PIN_NAND_NCE		242
+#define AMS_DELTA_GPIO_PIN_NAND_NRE		243
+#define AMS_DELTA_GPIO_PIN_NAND_NWP		244
+#define AMS_DELTA_GPIO_PIN_NAND_NWE		245
+#define AMS_DELTA_GPIO_PIN_NAND_ALE		246
+#define AMS_DELTA_GPIO_PIN_NAND_CLE		247
+#define AMS_DELTA_GPIO_PIN_KEYBRD_PWR		248
+#define AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT	249
+#define AMS_DELTA_GPIO_PIN_SCARD_RSTIN		250
+#define AMS_DELTA_GPIO_PIN_SCARD_CMDVCC		251
+#define AMS_DELTA_GPIO_PIN_MODEM_NRESET		252
+#define AMS_DELTA_GPIO_PIN_MODEM_CODEC		253
+
+#define AMS_DELTA_LATCH1_GPIO_BASE	AMS_DELTA_GPIO_PIN_LED_CAMERA
+#define AMS_DELTA_LATCH1_NGPIO		8
+#define AMS_DELTA_LATCH2_GPIO_BASE	AMS_DELTA_GPIO_PIN_LCD_VBLEN
+#define AMS_DELTA_LATCH2_NGPIO		16
+
 #ifndef __ASSEMBLY__
-void ams_delta_latch1_write(u8 mask, u8 value);
-void ams_delta_latch2_write(u16 mask, u16 value);
+void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value);
+#define ams_delta_latch1_write(mask, value) \
+	ams_delta_latch_write(AMS_DELTA_LATCH1_GPIO_BASE, \
+			AMS_DELTA_LATCH1_NGPIO, (mask), (value))
+#define ams_delta_latch2_write(mask, value) \
+	ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \
+			AMS_DELTA_LATCH2_NGPIO, (mask), (value))
 #endif
 
 #endif /* CONFIG_MACH_AMS_DELTA */
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH v2 3/7] ARM: OMAP1: ams-delta: supersede custom led device by leds-gpio
  2011-12-19 23:08 ` [PATCH v2 0/7] " Janusz Krzysztofik
  2011-12-19 23:08   ` [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio Janusz Krzysztofik
@ 2011-12-19 23:08   ` Janusz Krzysztofik
  2011-12-19 23:08   ` [PATCH v2 4/7] LED: drop leds-ams-delta driver Janusz Krzysztofik
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-19 23:08 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Richard Purdie

Now that the Amstrad Delta on-board latches have been converted to GPIO
devices, use the generic driver to control on-board LEDs which hang off
those latches.

Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
basic_mmio_gpio"

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
Changes against initial version:
* no functional changes,
* refreshed on top of v2 of patch 2/7,
* dropped leading underscores from local symbols, variable and function
  names (no namespace conflicts expected).


 arch/arm/mach-omap1/Kconfig                       |    1 +
 arch/arm/mach-omap1/board-ams-delta.c             |   87 +++++++++++---------
 arch/arm/plat-omap/include/plat/board-ams-delta.h |   19 -----
 3 files changed, 49 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index d2606b1..ed7e864 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -156,6 +156,7 @@ config MACH_AMS_DELTA
 	depends on ARCH_OMAP1 && ARCH_OMAP15XX
 	select FIQ
 	select GPIO_GENERIC_PLATFORM
+	select LEDS_GPIO_REGISTER
 	help
 	  Support for the Amstrad E3 (codename Delta) videophone. Say Y here
 	  if you have such a device.
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index cff2711..034d009 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -164,18 +164,21 @@ static struct omap_board_config_kernel ams_delta_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&ams_delta_lcd_config },
 };
 
+#define LATCH1_GPIO_BASE	232
+#define LATCH1_NGPIO		8
+
 static struct resource latch1_resources[] __initconst = {
 	[0] = {
 		.name	= "dat",
 		.start	= LATCH1_PHYS,
-		.end	= LATCH1_PHYS + (AMS_DELTA_LATCH1_NGPIO - 1) / 8,
+		.end	= LATCH1_PHYS + (LATCH1_NGPIO - 1) / 8,
 		.flags	= IORESOURCE_MEM,
 	},
 };
 
 static struct bgpio_pdata latch1_pdata __initconst = {
-	.base	= AMS_DELTA_LATCH1_GPIO_BASE,
-	.ngpio	= AMS_DELTA_LATCH1_NGPIO,
+	.base	= LATCH1_GPIO_BASE,
+	.ngpio	= LATCH1_NGPIO,
 };
 
 static struct platform_device latch1_gpio_device = {
@@ -214,42 +217,12 @@ static struct platform_device latch2_gpio_device = {
 
 static struct gpio latch_gpios[] __initconst = {
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_CAMERA,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_camera",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_ADVERT,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_advert",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_EMAIL,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_email",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_HANDSFREE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_handsfree",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICEMAIL,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_voicemail",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "led_voice",
-	},
-	{
-		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 6,
+		.gpio	= LATCH1_GPIO_BASE + 6,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "dockit1",
 	},
 	{
-		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 7,
+		.gpio	= LATCH1_GPIO_BASE + 7,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "dockit2",
 	},
@@ -399,9 +372,45 @@ static struct platform_device ams_delta_lcd_device = {
 	.id	= -1,
 };
 
-static struct platform_device ams_delta_led_device = {
-	.name	= "ams-delta-led",
-	.id	= -1
+static struct gpio_led gpio_leds[] __initconst = {
+	{
+		.name		 = "camera",
+		.gpio		 = LATCH1_GPIO_BASE + 0,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+#ifdef CONFIG_LEDS_TRIGGERS
+		.default_trigger = "ams_delta_camera",
+#endif
+	},
+	{
+		.name		 = "advert",
+		.gpio		 = LATCH1_GPIO_BASE + 1,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+	{
+		.name		 = "email",
+		.gpio		 = LATCH1_GPIO_BASE + 2,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+	{
+		.name		 = "handsfree",
+		.gpio		 = LATCH1_GPIO_BASE + 3,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+	{
+		.name		 = "voicemail",
+		.gpio		 = LATCH1_GPIO_BASE + 4,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+	{
+		.name		 = "voice",
+		.gpio		 = LATCH1_GPIO_BASE + 5,
+		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
+	},
+};
+
+static struct gpio_led_platform_data leds_pdata __initconst = {
+	.leds		= gpio_leds,
+	.num_leds	= ARRAY_SIZE(gpio_leds),
 };
 
 static struct i2c_board_info ams_delta_camera_board_info[] = {
@@ -459,7 +468,6 @@ static struct platform_device *ams_delta_devices[] __initdata = {
 static struct platform_device *late_devices[] __initconst = {
 	&ams_delta_nand_device,
 	&ams_delta_lcd_device,
-	&ams_delta_led_device,
 };
 
 static void __init ams_delta_init(void)
@@ -493,6 +501,7 @@ static void __init ams_delta_init(void)
 	led_trigger_register_simple("ams_delta_camera",
 			&ams_delta_camera_led_trigger);
 #endif
+	gpio_led_register_device(-1, &leds_pdata);
 	platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
 
 	ams_delta_init_fiq();
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 68ffe32..a0f86ca 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,13 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMS_DELTA_LATCH1_LED_CAMERA	0x01
-#define AMS_DELTA_LATCH1_LED_ADVERT	0x02
-#define AMS_DELTA_LATCH1_LED_EMAIL	0x04
-#define AMS_DELTA_LATCH1_LED_HANDSFREE	0x08
-#define AMS_DELTA_LATCH1_LED_VOICEMAIL	0x10
-#define AMS_DELTA_LATCH1_LED_VOICE	0x20
-
 #define AMS_DELTA_LATCH2_LCD_VBLEN	0x0001
 #define AMS_DELTA_LATCH2_LCD_NDISP	0x0002
 #define AMS_DELTA_LATCH2_NAND_NCE	0x0004
@@ -59,13 +52,6 @@
 #define AMS_DELTA_GPIO_PIN_CONFIG	11
 #define AMS_DELTA_GPIO_PIN_NAND_RB	12
 
-#define AMS_DELTA_GPIO_PIN_LED_CAMERA		232
-#define AMS_DELTA_GPIO_PIN_LED_ADVERT		233
-#define AMS_DELTA_GPIO_PIN_LED_EMAIL		234
-#define AMS_DELTA_GPIO_PIN_LED_HANDSFREE	235
-#define AMS_DELTA_GPIO_PIN_LED_VOICEMAIL	236
-#define AMS_DELTA_GPIO_PIN_LED_VOICE		237
-
 #define AMS_DELTA_GPIO_PIN_LCD_VBLEN		240
 #define AMS_DELTA_GPIO_PIN_LCD_NDISP		241
 #define AMS_DELTA_GPIO_PIN_NAND_NCE		242
@@ -81,16 +67,11 @@
 #define AMS_DELTA_GPIO_PIN_MODEM_NRESET		252
 #define AMS_DELTA_GPIO_PIN_MODEM_CODEC		253
 
-#define AMS_DELTA_LATCH1_GPIO_BASE	AMS_DELTA_GPIO_PIN_LED_CAMERA
-#define AMS_DELTA_LATCH1_NGPIO		8
 #define AMS_DELTA_LATCH2_GPIO_BASE	AMS_DELTA_GPIO_PIN_LCD_VBLEN
 #define AMS_DELTA_LATCH2_NGPIO		16
 
 #ifndef __ASSEMBLY__
 void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value);
-#define ams_delta_latch1_write(mask, value) \
-	ams_delta_latch_write(AMS_DELTA_LATCH1_GPIO_BASE, \
-			AMS_DELTA_LATCH1_NGPIO, (mask), (value))
 #define ams_delta_latch2_write(mask, value) \
 	ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \
 			AMS_DELTA_LATCH2_NGPIO, (mask), (value))
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH v2 4/7] LED: drop leds-ams-delta driver
  2011-12-19 23:08 ` [PATCH v2 0/7] " Janusz Krzysztofik
  2011-12-19 23:08   ` [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio Janusz Krzysztofik
  2011-12-19 23:08   ` [PATCH v2 3/7] ARM: OMAP1: ams-delta: supersede custom led device by leds-gpio Janusz Krzysztofik
@ 2011-12-19 23:08   ` Janusz Krzysztofik
  2011-12-19 23:08   ` [PATCH v2 5/7] MTD: NAND: ams-delta: use GPIO instead of custom I/O Janusz Krzysztofik
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-19 23:08 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Richard Purdie

This driver is no longer needed after the Amstrad Delta on-board LED
devices have been converted to leds-gpio compatible.

Created against linux-3.2-rc6.
Requires patch 3/7 "ARM: OMAP1: ams-delta: supersede custom led device
by leds-gpio" for those LEDs to still work.

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Cc: Richard Purdie <rpurdie@rpsys.net>
---
Changes against initial version:
* no functional changes,
* rebased on top of linux-3.2-rc6, just in case.


 drivers/leds/Kconfig          |    7 --
 drivers/leds/Makefile         |    1 -
 drivers/leds/leds-ams-delta.c |  137 -----------------------------------------
 3 files changed, 0 insertions(+), 145 deletions(-)
 delete mode 100644 drivers/leds/leds-ams-delta.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index ff203a4..3523746 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -74,13 +74,6 @@ config LEDS_S3C24XX
 	  This option enables support for LEDs connected to GPIO lines
 	  on Samsung S3C24XX series CPUs, such as the S3C2410 and S3C2440.
 
-config LEDS_AMS_DELTA
-	tristate "LED Support for the Amstrad Delta (E3)"
-	depends on LEDS_CLASS
-	depends on MACH_AMS_DELTA
-	help
-	  This option enables support for the LEDs on Amstrad Delta (E3).
-
 config LEDS_NET48XX
 	tristate "LED Support for Soekris net48xx series Error LED"
 	depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index e4f6bf5..f2b75b2 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -12,7 +12,6 @@ obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
 obj-$(CONFIG_LEDS_LM3530)		+= leds-lm3530.o
 obj-$(CONFIG_LEDS_MIKROTIK_RB532)	+= leds-rb532.o
 obj-$(CONFIG_LEDS_S3C24XX)		+= leds-s3c24xx.o
-obj-$(CONFIG_LEDS_AMS_DELTA)		+= leds-ams-delta.o
 obj-$(CONFIG_LEDS_NET48XX)		+= leds-net48xx.o
 obj-$(CONFIG_LEDS_NET5501)		+= leds-net5501.o
 obj-$(CONFIG_LEDS_WRAP)			+= leds-wrap.o
diff --git a/drivers/leds/leds-ams-delta.c b/drivers/leds/leds-ams-delta.c
deleted file mode 100644
index 8c00937..0000000
--- a/drivers/leds/leds-ams-delta.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * LEDs driver for Amstrad Delta (E3)
- *
- * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
- *
- * 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.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/leds.h>
-#include <plat/board-ams-delta.h>
-
-/*
- * Our context
- */
-struct ams_delta_led {
-	struct led_classdev	cdev;
-	u8			bitmask;
-};
-
-static void ams_delta_led_set(struct led_classdev *led_cdev,
-		enum led_brightness value)
-{
-	struct ams_delta_led *led_dev =
-		container_of(led_cdev, struct ams_delta_led, cdev);
-
-	if (value)
-		ams_delta_latch1_write(led_dev->bitmask, led_dev->bitmask);
-	else
-		ams_delta_latch1_write(led_dev->bitmask, 0);
-}
-
-static struct ams_delta_led ams_delta_leds[] = {
-	{
-		.cdev		= {
-			.name		= "ams-delta::camera",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_CAMERA,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::advert",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_ADVERT,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::email",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_EMAIL,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::handsfree",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_HANDSFREE,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::voicemail",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_VOICEMAIL,
-	},
-	{
-		.cdev		= {
-			.name		= "ams-delta::voice",
-			.brightness_set = ams_delta_led_set,
-		},
-		.bitmask	= AMS_DELTA_LATCH1_LED_VOICE,
-	},
-};
-
-static int ams_delta_led_probe(struct platform_device *pdev)
-{
-	int i, ret;
-
-	for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++) {
-		ams_delta_leds[i].cdev.flags |= LED_CORE_SUSPENDRESUME;
-		ret = led_classdev_register(&pdev->dev,
-				&ams_delta_leds[i].cdev);
-		if (ret < 0)
-			goto fail;
-	}
-
-	return 0;
-fail:
-	while (--i >= 0)
-		led_classdev_unregister(&ams_delta_leds[i].cdev);
-	return ret;	
-}
-
-static int ams_delta_led_remove(struct platform_device *pdev)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
-		led_classdev_unregister(&ams_delta_leds[i].cdev);
-
-	return 0;
-}
-
-static struct platform_driver ams_delta_led_driver = {
-	.probe		= ams_delta_led_probe,
-	.remove		= ams_delta_led_remove,
-	.driver		= {
-		.name = "ams-delta-led",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init ams_delta_led_init(void)
-{
-	return platform_driver_register(&ams_delta_led_driver);
-}
-
-static void __exit ams_delta_led_exit(void)
-{
-	platform_driver_unregister(&ams_delta_led_driver);
-}
-
-module_init(ams_delta_led_init);
-module_exit(ams_delta_led_exit);
-
-MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
-MODULE_DESCRIPTION("Amstrad Delta LED driver");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:ams-delta-led");
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH v2 5/7] MTD: NAND: ams-delta: use GPIO instead of custom I/O
  2011-12-19 23:08 ` [PATCH v2 0/7] " Janusz Krzysztofik
                     ` (2 preceding siblings ...)
  2011-12-19 23:08   ` [PATCH v2 4/7] LED: drop leds-ams-delta driver Janusz Krzysztofik
@ 2011-12-19 23:08   ` Janusz Krzysztofik
  2011-12-21 19:12     ` Tony Lindgren
  2011-12-21 20:56     ` Artem Bityutskiy
  2011-12-19 23:08   ` [PATCH v2 6/7] omapfb: lcd_ams_delta: drive control lines over GPIO Janusz Krzysztofik
  2011-12-19 23:08   ` [PATCH v2 7/7] input: serio: ams-delta: toggle keyboard power " Janusz Krzysztofik
  5 siblings, 2 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-19 23:08 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	linux-mtd, David Woodhouse

Don't use Amstrad Delta custom I/O functions for controlling the device,
use GPIO API instead.

While being at it, add missing gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB).

Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
basic_mmio_gpio"

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Tony Lindgren <tony@atomide.com>
---
Changes against initial version:
* no functional changes,
* rebased on top of v2 of patch 2/7, just in case.

Comments copied from initial submission:

Hi,
I considered dropping the Amstrad Delta NAND driver and moving to either
gpio-nand or gen_nand, but finally decided to keep it for now.

The problem with the gpio-nand is that it seems to match a different
hardware interface model. Having no knowledge about the original
hardware that driver was designed in mind, I'd rather not try to
modify it, and creating another GPIO based NAND driver also seems not
a really good idea.

If I decided to use gen_nand instead, I would have to move virtually all
of the old driver callback functions somewhere under arch, either to the
board file or to a new one, and still use some hacks unless either
nand_base.c or plat_nand.c is modified.

I'm willing to take one of those two approaches in a follow up series if
I get a positive feedback.

Thanks,
Janusz


 arch/arm/mach-omap1/board-ams-delta.c             |   30 --------
 arch/arm/plat-omap/include/plat/board-ams-delta.h |    6 --
 drivers/mtd/nand/ams-delta.c                      |   74 ++++++++++++++------
 3 files changed, 52 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 034d009..cc6f962 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -237,36 +237,6 @@ static struct gpio latch_gpios[] __initconst = {
 		.label	= "lcd_ndisp",
 	},
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_nce",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_nre",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_nwp",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_nwe",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_ale",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "nand_cle",
-	},
-	{
 		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "keybrd_pwr",
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index a0f86ca..3e57833 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -30,12 +30,6 @@
 
 #define AMS_DELTA_LATCH2_LCD_VBLEN	0x0001
 #define AMS_DELTA_LATCH2_LCD_NDISP	0x0002
-#define AMS_DELTA_LATCH2_NAND_NCE	0x0004
-#define AMS_DELTA_LATCH2_NAND_NRE	0x0008
-#define AMS_DELTA_LATCH2_NAND_NWP	0x0010
-#define AMS_DELTA_LATCH2_NAND_NWE	0x0020
-#define AMS_DELTA_LATCH2_NAND_ALE	0x0040
-#define AMS_DELTA_LATCH2_NAND_CLE	0x0080
 #define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
 #define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
 #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index 9e6b498..5769bd2 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -26,7 +26,7 @@
 #include <asm/io.h>
 #include <mach/hardware.h>
 #include <asm/sizes.h>
-#include <asm/gpio.h>
+#include <linux/gpio.h>
 #include <plat/board-ams-delta.h>
 
 /*
@@ -34,8 +34,6 @@
  */
 static struct mtd_info *ams_delta_mtd = NULL;
 
-#define NAND_MASK (AMS_DELTA_LATCH2_NAND_NRE | AMS_DELTA_LATCH2_NAND_NWE | AMS_DELTA_LATCH2_NAND_CLE | AMS_DELTA_LATCH2_NAND_ALE | AMS_DELTA_LATCH2_NAND_NCE | AMS_DELTA_LATCH2_NAND_NWP)
-
 /*
  * Define partitions for flash devices
  */
@@ -68,10 +66,9 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
 
 	writew(0, io_base + OMAP_MPUIO_IO_CNTL);
 	writew(byte, this->IO_ADDR_W);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 0);
 	ndelay(40);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE,
-			       AMS_DELTA_LATCH2_NAND_NWE);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 1);
 }
 
 static u_char ams_delta_read_byte(struct mtd_info *mtd)
@@ -80,12 +77,11 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd)
 	struct nand_chip *this = mtd->priv;
 	void __iomem *io_base = this->priv;
 
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0);
 	ndelay(40);
 	writew(~0, io_base + OMAP_MPUIO_IO_CNTL);
 	res = readw(this->IO_ADDR_R);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE,
-			       AMS_DELTA_LATCH2_NAND_NRE);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 1);
 
 	return res;
 }
@@ -132,15 +128,12 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd,
 {
 
 	if (ctrl & NAND_CTRL_CHANGE) {
-		unsigned long bits;
-
-		bits = (~ctrl & NAND_NCE) ? AMS_DELTA_LATCH2_NAND_NCE : 0;
-		bits |= (ctrl & NAND_CLE) ? AMS_DELTA_LATCH2_NAND_CLE : 0;
-		bits |= (ctrl & NAND_ALE) ? AMS_DELTA_LATCH2_NAND_ALE : 0;
-
-		ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_CLE |
-				AMS_DELTA_LATCH2_NAND_ALE |
-				AMS_DELTA_LATCH2_NAND_NCE, bits);
+		gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NCE,
+				(ctrl & NAND_NCE) == 0);
+		gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_CLE,
+				(ctrl & NAND_CLE) != 0);
+		gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_ALE,
+				(ctrl & NAND_ALE) != 0);
 	}
 
 	if (cmd != NAND_CMD_NONE)
@@ -152,6 +145,39 @@ static int ams_delta_nand_ready(struct mtd_info *mtd)
 	return gpio_get_value(AMS_DELTA_GPIO_PIN_NAND_RB);
 }
 
+static struct gpio _mandatory_gpio[] __initconst_or_module = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "nand_nce",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "nand_nre",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "nand_nwp",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
+		.flags	= GPIOF_OUT_INIT_HIGH,
+		.label	= "nand_nwe",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_ale",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_cle",
+	},
+};
+
 /*
  * Main initialization routine
  */
@@ -223,10 +249,9 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
 	platform_set_drvdata(pdev, io_base);
 
 	/* Set chip enabled, but  */
-	ams_delta_latch2_write(NAND_MASK, AMS_DELTA_LATCH2_NAND_NRE |
-					  AMS_DELTA_LATCH2_NAND_NWE |
-					  AMS_DELTA_LATCH2_NAND_NCE |
-					  AMS_DELTA_LATCH2_NAND_NWP);
+	err = gpio_request_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
+	if (err)
+		goto out_gpio;
 
 	/* Scan to find existence of the device */
 	if (nand_scan(ams_delta_mtd, 1)) {
@@ -241,7 +266,10 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
 	goto out;
 
  out_mtd:
+	gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
+out_gpio:
 	platform_set_drvdata(pdev, NULL);
+	gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
 	iounmap(io_base);
 out_release_io:
 	release_mem_region(res->start, resource_size(res));
@@ -262,6 +290,8 @@ static int __devexit ams_delta_cleanup(struct platform_device *pdev)
 	/* Release resources, unregister device */
 	nand_release(ams_delta_mtd);
 
+	gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
+	gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
 	iounmap(io_base);
 	release_mem_region(res->start, resource_size(res));
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH v2 6/7] omapfb: lcd_ams_delta: drive control lines over GPIO
  2011-12-19 23:08 ` [PATCH v2 0/7] " Janusz Krzysztofik
                     ` (3 preceding siblings ...)
  2011-12-19 23:08   ` [PATCH v2 5/7] MTD: NAND: ams-delta: use GPIO instead of custom I/O Janusz Krzysztofik
@ 2011-12-19 23:08   ` Janusz Krzysztofik
  2011-12-19 23:08   ` [PATCH v2 7/7] input: serio: ams-delta: toggle keyboard power " Janusz Krzysztofik
  5 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-19 23:08 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	linux-fbdev

Don't use Amstrad Delta custom I/O functions any longer, use GPIO API
instead.

Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
basic_mmio_gpio".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
---
Changes against initial version:
* was 8/10,
* no functional changes,
* rebased on top of v2 of patch 2/7, just in case.


 arch/arm/mach-omap1/board-ams-delta.c             |   10 -------
 arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 -
 drivers/video/omap/lcd_ams_delta.c                |   27 +++++++++++++++-----
 3 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index cc6f962..3aba8f9 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -227,16 +227,6 @@ static struct gpio latch_gpios[] __initconst = {
 		.label	= "dockit2",
 	},
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "lcd_vblen",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "lcd_ndisp",
-	},
-	{
 		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "keybrd_pwr",
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 3e57833..e9ad673 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,8 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMS_DELTA_LATCH2_LCD_VBLEN	0x0001
-#define AMS_DELTA_LATCH2_LCD_NDISP	0x0002
 #define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
 #define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
 #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
diff --git a/drivers/video/omap/lcd_ams_delta.c b/drivers/video/omap/lcd_ams_delta.c
index 6978ae4..73b211b 100644
--- a/drivers/video/omap/lcd_ams_delta.c
+++ b/drivers/video/omap/lcd_ams_delta.c
@@ -25,6 +25,7 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 #include <linux/lcd.h>
+#include <linux/gpio.h>
 
 #include <plat/board-ams-delta.h>
 #include <mach/hardware.h>
@@ -98,29 +99,41 @@ static struct lcd_ops ams_delta_lcd_ops = {
 
 /* omapfb panel section */
 
+static struct gpio _gpios[] __initconst_or_module = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_vblen",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_ndisp",
+	},
+};
+
 static int ams_delta_panel_init(struct lcd_panel *panel,
 		struct omapfb_device *fbdev)
 {
-	return 0;
+	return gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
 }
 
 static void ams_delta_panel_cleanup(struct lcd_panel *panel)
 {
+	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
 }
 
 static int ams_delta_panel_enable(struct lcd_panel *panel)
 {
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_NDISP,
-			AMS_DELTA_LATCH2_LCD_NDISP);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN,
-			AMS_DELTA_LATCH2_LCD_VBLEN);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1);
 	return 0;
 }
 
 static void ams_delta_panel_disable(struct lcd_panel *panel)
 {
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN, 0);
-	ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_NDISP, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0);
 }
 
 static unsigned long ams_delta_panel_get_caps(struct lcd_panel *panel)
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH v2 7/7] input: serio: ams-delta: toggle keyboard power over GPIO
  2011-12-19 23:08 ` [PATCH v2 0/7] " Janusz Krzysztofik
                     ` (4 preceding siblings ...)
  2011-12-19 23:08   ` [PATCH v2 6/7] omapfb: lcd_ams_delta: drive control lines over GPIO Janusz Krzysztofik
@ 2011-12-19 23:08   ` Janusz Krzysztofik
  2011-12-20 22:10     ` [PATCH] " Janusz Krzysztofik
  5 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-19 23:08 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Dmitry Torokhov, linux-input

Don't use Amstrad Delta custom I/O functions once GPIO interface is
available for the underlying hardware.

While requesting and initializing GPIO pins used, also take care of one
extra pin KEYBRD_DATAOUT which, even if not used by the driver, belongs
to the device and affects its functioning.

Once done, move the driver initialization back to the device_initcall
level, reverting the temporary chane introduced with patch 1/7 "ARM:
OMAP1: ams-delta: register latch dependent devices from late_initcall".
That change is no longer required once the driver takes care of
registering used GPIO pins, and it's better to initialize the device
before others using the latch2 based GPIO pins, otherwise a garbage is
reported on boot, perhaps due to random data already captured by the FIQ
handler while the keyboard related latch bits are written with random
values during initialization of those other latch2 dependent devices.

Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
basic_mmio_gpio"

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
Changes against initial version:
* was 9/10,
* rebased on top of v2 of patch 2/7, just in case,
* moved AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT pin handling from the board
  code to the driver,
* reverted a temporary change to the driver initcall level, introduced
  by the new solution provided with patch 1/7.


 arch/arm/mach-omap1/board-ams-delta.c             |   10 ----
 arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 -
 drivers/input/serio/ams_delta_serio.c             |   55 ++++++++++++---------
 3 files changed, 31 insertions(+), 36 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 3aba8f9..673cf21 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -227,16 +227,6 @@ static struct gpio latch_gpios[] __initconst = {
 		.label	= "dockit2",
 	},
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "keybrd_pwr",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "keybrd_dataout",
-	},
-	{
 		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "scard_rstin",
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index e9ad673..027e79e 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,8 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
-#define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
 #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
 #define AMD_DELTA_LATCH2_SCARD_CMDVCC	0x0800
 #define AMS_DELTA_LATCH2_MODEM_NRESET	0x1000
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index 56ffd7c..ef1ec40 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -92,8 +92,7 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
 static int ams_delta_serio_open(struct serio *serio)
 {
 	/* enable keyboard */
-	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR,
-			AMD_DELTA_LATCH2_KEYBRD_PWR);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1);
 
 	return 0;
 }
@@ -101,9 +100,32 @@ static int ams_delta_serio_open(struct serio *serio)
 static void ams_delta_serio_close(struct serio *serio)
 {
 	/* disable keyboard */
-	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0);
 }
 
+static struct gpio _gpios[] __initconst_or_module = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
+		.flags	= GPIOF_DIR_IN,
+		.label	= "serio-data",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
+		.flags	= GPIOF_DIR_IN,
+		.label	= "serio-clock",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "serio-power",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "serio-dataout",
+	},
+};
+
 static int __init ams_delta_serio_init(void)
 {
 	int err;
@@ -123,19 +145,11 @@ static int __init ams_delta_serio_init(void)
 	strlcpy(ams_delta_serio->phys, "GPIO/serio0",
 			sizeof(ams_delta_serio->phys));
 
-	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_DATA, "serio-data");
+	err = gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
 	if (err) {
-		pr_err("ams_delta_serio: Couldn't request gpio pin for data\n");
+		pr_err("ams_delta_serio: Couldn't request gpio pins\n");
 		goto serio;
 	}
-	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
-
-	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_CLK, "serio-clock");
-	if (err) {
-		pr_err("ams_delta_serio: couldn't request gpio pin for clock\n");
-		goto gpio_data;
-	}
-	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
 
 	err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
 			ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING,
@@ -143,7 +157,7 @@ static int __init ams_delta_serio_init(void)
 	if (err < 0) {
 		pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n",
 				gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK));
-		goto gpio_clk;
+		goto gpio;
 	}
 	/*
 	 * Since GPIO register handling for keyboard clock pin is performed
@@ -157,25 +171,18 @@ static int __init ams_delta_serio_init(void)
 	dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name);
 
 	return 0;
-gpio_clk:
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
-gpio_data:
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
+gpio:
+	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
 serio:
 	kfree(ams_delta_serio);
 	return err;
 }
-#ifndef MODULE
-late_initcall(ams_delta_serio_init);
-#else
 module_init(ams_delta_serio_init);
 
 static void __exit ams_delta_serio_exit(void)
 {
 	serio_unregister_port(ams_delta_serio);
 	free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
+	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
 }
 module_exit(ams_delta_serio_exit);
-#endif
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later
       [not found] ` <83e934adfc691b347534edb7788a67ab2e6bd7e1.1324331816.git.jkrzyszt@tis.icnet.pl>
@ 2011-12-19 23:28   ` Janusz Krzysztofik
  2011-12-20 18:06     ` Tony Lindgren
                       ` (2 more replies)
  0 siblings, 3 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-19 23:28 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Dmitry Torokhov, Jarkko Nikula, Liam Girdwood, Mark Brown,
	linux-input

Resending because of a typo in the Cc: list, sorry.

8<--------------------------

In preparation to converting Amstrad Delta on-board latches to
basic_mmio_gpio devices, registration of platform devices which depend
on latches and will require initialization of their GPIO pins first,
should be moved out of .machine_init down to late_initcall level, as the
gpio-generic driver is not available until device_initcall time.  The
latch reset operation, which will be replaced with GPIO initialization,
must also be moved to late_initcall for the same reason.

Since there was already another, separate arch_initcall function for
setting up one of those latch dependent devices, the on-board modem
device, reuse that function, i.e., rename it to a name that matches the
new purpose, extend with other device setup relocated from
.machine_init, and move down to the late_initcall level.

While being at it, add missing gpio_free() in case the modem platform
device registration fails.

In addition, defer registration of the Amstrad Delta ASoC and serio
devices, done from their device driver files, until late_initcall time,
as those drivers will depend on their GPIO pins already requested from
the board late_init() function until updated to register their GPIO pins
themselves.

Thanks to Tony Lindgren <tony@atomide.com> who suggested this approach
instead of shifting up the gpio-generic driver initialization.

Created and tested against linux-3.2-rc6.

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
This patch was not present in the initial submission, it replaces the
old patch 1/10, providing an alternative solution not touching the
gpio-generic driver.

Thanks,
Janusz


 arch/arm/mach-omap1/board-ams-delta.c |   28 ++++++++++++++++++++--------
 drivers/input/serio/ams_delta_serio.c |    4 ++++
 sound/soc/omap/ams-delta.c            |    4 ++++
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index b0f15d2..50987c9 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -275,11 +275,14 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
 };
 
 static struct platform_device *ams_delta_devices[] __initdata = {
-	&ams_delta_nand_device,
 	&ams_delta_kp_device,
+	&ams_delta_camera_device,
+};
+
+static struct platform_device *late_devices[] __initdata = {
+	&ams_delta_nand_device,
 	&ams_delta_lcd_device,
 	&ams_delta_led_device,
-	&ams_delta_camera_device,
 };
 
 static void __init ams_delta_init(void)
@@ -307,9 +310,6 @@ static void __init ams_delta_init(void)
 	omap_serial_init();
 	omap_register_i2c_bus(1, 100, NULL, 0);
 
-	/* Clear latch2 (NAND, LCD, modem enable) */
-	ams_delta_latch2_write(~0, 0);
-
 	omap1_usb_init(&ams_delta_usb_config);
 	omap1_set_camera_info(&ams_delta_camera_platform_data);
 #ifdef CONFIG_LEDS_TRIGGERS
@@ -345,13 +345,18 @@ static struct platform_device ams_delta_modem_device = {
 	},
 };
 
-static int __init ams_delta_modem_init(void)
+static int __init late_init(void)
 {
 	int err;
 
 	if (!machine_is_ams_delta())
 		return -ENODEV;
 
+	/* Clear latch2 (NAND, LCD, modem enable) */
+	ams_delta_latch2_write(~0, 0);
+
+	platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
+
 	omap_cfg_reg(M14_1510_GPIO2);
 	ams_delta_modem_ports[0].irq =
 			gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
@@ -367,9 +372,16 @@ static int __init ams_delta_modem_init(void)
 		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
 		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
 
-	return platform_device_register(&ams_delta_modem_device);
+	err = platform_device_register(&ams_delta_modem_device);
+	if (err)
+		goto gpio_free;
+	return 0;
+
+gpio_free:
+	gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
+	return err;
 }
-arch_initcall(ams_delta_modem_init);
+late_initcall(late_init);
 
 static void __init ams_delta_map_io(void)
 {
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index d4d08bd..56ffd7c 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -165,6 +165,9 @@ serio:
 	kfree(ams_delta_serio);
 	return err;
 }
+#ifndef MODULE
+late_initcall(ams_delta_serio_init);
+#else
 module_init(ams_delta_serio_init);
 
 static void __exit ams_delta_serio_exit(void)
@@ -175,3 +178,4 @@ static void __exit ams_delta_serio_exit(void)
 	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
 }
 module_exit(ams_delta_serio_exit);
+#endif
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index ccb8a6a..1764a3b 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -636,6 +636,9 @@ err:
 	platform_device_put(ams_delta_audio_platform_device);
 	return ret;
 }
+#ifndef MODULE
+late_initcall(ams_delta_module_init);
+#else
 module_init(ams_delta_module_init);
 
 static void __exit ams_delta_module_exit(void)
@@ -657,6 +660,7 @@ static void __exit ams_delta_module_exit(void)
 	platform_device_unregister(ams_delta_audio_platform_device);
 }
 module_exit(ams_delta_module_exit);
+#endif
 
 MODULE_AUTHOR("Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>");
 MODULE_DESCRIPTION("ALSA SoC driver for Amstrad E3 (Delta) videophone");
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
  2011-12-19 23:08   ` [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio Janusz Krzysztofik
@ 2011-12-20  0:06     ` Tony Lindgren
  2011-12-20  0:59       ` Janusz Krzysztofik
  0 siblings, 1 reply; 63+ messages in thread
From: Tony Lindgren @ 2011-12-20  0:06 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Grant Likely

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 14:41]:
> Once ready, ams-delta specific device drivers currently calling custom
> ams_delta_latch[12]_write() functions can be updated to call generic
> gpio_set_value() instead, which will make them less platform dependent.
> Even more, some custom ams-delta only drivers can perhaps be dropped
> from the tree after converting selected ams-delta platform devices to
> follow generic GPIO based device models.
> 
> Depends on patch 1/7, "ARM: OMAP1: ams-delta: register latch dependent
> devices later".

Hmm looking at this maybe you can move the all the latch stuff into
a device driver?

Then you can have the other drivers register with it and let the
module dependencies take care of the init order?

You should only register the platform_device entries in your board-*.c
file, I don't think you actually need to do anything there to power
up things in the board-*.c file execept for the 8250.c driver?

> +static struct gpio latch_gpios[] __initconst = {
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_LED_CAMERA,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "led_camera",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_LED_ADVERT,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "led_advert",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_LED_EMAIL,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "led_email",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_LED_HANDSFREE,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "led_handsfree",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICEMAIL,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "led_voicemail",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICE,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "led_voice",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 6,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "dockit1",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 7,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "dockit2",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "lcd_vblen",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "lcd_ndisp",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "nand_nce",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "nand_nre",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "nand_nwp",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "nand_nwe",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "nand_ale",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "nand_cle",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "keybrd_pwr",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "keybrd_dataout",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "scard_rstin",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "scard_cmdvcc",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "modem_nreset",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_CODEC,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "modem_codec",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 14,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "hookflash1",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 15,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "hookflash2",
> +	},
> +};
> +
> +void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
> +{
> +	int bit = 0;
> +	u16 bitpos = 1 << bit;
> +
> +	for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
> +		if (!(mask & bitpos))
> +			continue;
> +		gpio_set_value(base + bit, (value & bitpos) != 0);
> +	}
> +}
> +EXPORT_SYMBOL(ams_delta_latch_write);

This part especially looks like it really should be just a regular
device driver under drivers/ somewhere. That might simplify things
quite a bit for you..

Regards,

Tony

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
  2011-12-20  0:06     ` Tony Lindgren
@ 2011-12-20  0:59       ` Janusz Krzysztofik
  2011-12-20  1:04         ` Tony Lindgren
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-20  0:59 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel, linux-kernel, Grant Likely

On Tuesday 20 of December 2011 at 01:06:00, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 14:41]:
> > Once ready, ams-delta specific device drivers currently calling custom
> > ams_delta_latch[12]_write() functions can be updated to call generic
> > gpio_set_value() instead, which will make them less platform dependent.
> > Even more, some custom ams-delta only drivers can perhaps be dropped
> > from the tree after converting selected ams-delta platform devices to
> > follow generic GPIO based device models.
> > 
> > Depends on patch 1/7, "ARM: OMAP1: ams-delta: register latch dependent
> > devices later".
> 
> Hmm looking at this maybe you can move the all the latch stuff into
> a device driver?

The latch stuff is just platform data for the existing gpio-generic aka 
basic_mmio_gpio driver. I'm not sure if creating a new custom driver by 
just squashing an existig driver code with a board specific platform 
data is a good idea.

> Then you can have the other drivers register with it and let the
> module dependencies take care of the init order?

It it was more complicated than providing just platform data, not even a 
single custom callback, to an existing gpio-generic driver, creating a 
custom driver might help indeed. However, I think I have all issues with 
initialization order already sorted out without inventing a new driver.

> You should only register the platform_device entries in your board-*.c
> file, I don't think you actually need to do anything there to power
> up things in the board-*.c file execept for the 8250.c driver?

Exactly, but not in a single patch. With this patch, I keep the old API 
for all drivers to still work, that's why I have to handle GPIO pins on 
behalf of them until updated. Those are updated step by step throghout 
the following patches of the series.

> > +static struct gpio latch_gpios[] __initconst = {
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_LED_CAMERA,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "led_camera",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_LED_ADVERT,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "led_advert",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_LED_EMAIL,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "led_email",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_LED_HANDSFREE,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "led_handsfree",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICEMAIL,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "led_voicemail",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICE,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "led_voice",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 6,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "dockit1",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 7,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "dockit2",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "lcd_vblen",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "lcd_ndisp",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "nand_nce",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "nand_nre",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "nand_nwp",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "nand_nwe",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "nand_ale",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "nand_cle",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "keybrd_pwr",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "keybrd_dataout",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "scard_rstin",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "scard_cmdvcc",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "modem_nreset",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_CODEC,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "modem_codec",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 14,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "hookflash1",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 15,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "hookflash2",
> > +	},
> > +};
> > +
> > +void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
> > +{
> > +	int bit = 0;
> > +	u16 bitpos = 1 << bit;
> > +
> > +	for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
> > +		if (!(mask & bitpos))
> > +			continue;
> > +		gpio_set_value(base + bit, (value & bitpos) != 0);
> > +	}
> > +}
> > +EXPORT_SYMBOL(ams_delta_latch_write);
> 
> This part especially looks like it really should be just a regular
> device driver under drivers/ somewhere. 

I really don't understand what kind of a driver you might mean here.

The latch_gpios[] table is initially filled with all latch1 and latch2 
GPIO pins in order to register and initialize them from the board file 
until they are handled by respective existing device drivers (leds, 
nand, lcd, serio, serial8250, asoc) instead of those drivers accessing 
the latches with those old ams_delta_latch[12]_write() functions. That 
table will get almost empty after the transision process is completed, 
holding only pins not used by any drivers / connected to unsued devices, 
in order to initialize them from the board file for power saving 
purposes. A separate driver for the purpose of initializing a few GPIO 
pins seems an overkill.

The new ams_delta_latch_write() function is a unified replacement for 
those removed ams_delta_latch[12]_write(), and serves as a temporary 
wrapper over gpio_set_value(), providing the old API for those not yet 
updated device drivers, and will be removed after all drivers are 
converted.

Perhaps I was not clear enough with my intention of a smooth step by 
step transition to the GPIO API without breaking any signle driver with 
any single patch.

> That might simplify things quite a bit for you..

Will be simplified, step by step, while moving GPIO handling from the 
board file to all those existing device drivers.

I hope this clarifies things enough.

Thanks,
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
  2011-12-20  0:59       ` Janusz Krzysztofik
@ 2011-12-20  1:04         ` Tony Lindgren
  2011-12-20  1:18           ` Janusz Krzysztofik
  2011-12-20  2:24           ` [PATCH v2 2/7 v2] " Janusz Krzysztofik
  0 siblings, 2 replies; 63+ messages in thread
From: Tony Lindgren @ 2011-12-20  1:04 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Grant Likely

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 16:28]:
> On Tuesday 20 of December 2011 at 01:06:00, Tony Lindgren wrote:
> > 
> > This part especially looks like it really should be just a regular
> > device driver under drivers/ somewhere. 
> 
> I really don't understand what kind of a driver you might mean here.
> 
> The latch_gpios[] table is initially filled with all latch1 and latch2 
> GPIO pins in order to register and initialize them from the board file 
> until they are handled by respective existing device drivers (leds, 
> nand, lcd, serio, serial8250, asoc) instead of those drivers accessing 
> the latches with those old ams_delta_latch[12]_write() functions. That 
> table will get almost empty after the transision process is completed, 
> holding only pins not used by any drivers / connected to unsued devices, 
> in order to initialize them from the board file for power saving 
> purposes. A separate driver for the purpose of initializing a few GPIO 
> pins seems an overkill.

OK maybe update the comments a bit to describe how that table will
mostly disappear? It's not obvious from glancing over this patch
series :)
 
> The new ams_delta_latch_write() function is a unified replacement for 
> those removed ams_delta_latch[12]_write(), and serves as a temporary 
> wrapper over gpio_set_value(), providing the old API for those not yet 
> updated device drivers, and will be removed after all drivers are 
> converted.
> 
> Perhaps I was not clear enough with my intention of a smooth step by 
> step transition to the GPIO API without breaking any signle driver with 
> any single patch.
> 
> > That might simplify things quite a bit for you..
> 
> Will be simplified, step by step, while moving GPIO handling from the 
> board file to all those existing device drivers.
> 
> I hope this clarifies things enough.

Yes thanks :)

Tony

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
  2011-12-20  1:04         ` Tony Lindgren
@ 2011-12-20  1:18           ` Janusz Krzysztofik
  2011-12-20  2:13             ` Tony Lindgren
  2011-12-20  2:24           ` [PATCH v2 2/7 v2] " Janusz Krzysztofik
  1 sibling, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-20  1:18 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel, linux-kernel, Grant Likely

On Tuesday 20 of December 2011 at 02:04:46, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 16:28]:
> > On Tuesday 20 of December 2011 at 01:06:00, Tony Lindgren wrote:
> > > 
> > > This part especially looks like it really should be just a regular
> > > device driver under drivers/ somewhere. 
> > 
> > I really don't understand what kind of a driver you might mean here.
> > 
> > The latch_gpios[] table is initially filled with all latch1 and latch2 
> > GPIO pins in order to register and initialize them from the board file 
> > until they are handled by respective existing device drivers (leds, 
> > nand, lcd, serio, serial8250, asoc) instead of those drivers accessing 
> > the latches with those old ams_delta_latch[12]_write() functions. That 
> > table will get almost empty after the transision process is completed, 
> > holding only pins not used by any drivers / connected to unsued devices, 
> > in order to initialize them from the board file for power saving 
> > purposes. A separate driver for the purpose of initializing a few GPIO 
> > pins seems an overkill.
> 
> OK maybe update the comments a bit to describe how that table will
> mostly disappear? It's not obvious from glancing over this patch
> series :)

To be sure, do you mean in-line comments? Or the changelog message?

Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
  2011-12-20  1:18           ` Janusz Krzysztofik
@ 2011-12-20  2:13             ` Tony Lindgren
  0 siblings, 0 replies; 63+ messages in thread
From: Tony Lindgren @ 2011-12-20  2:13 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: linux-omap, linux-arm-kernel, linux-kernel, Grant Likely

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 16:46]:
> On Tuesday 20 of December 2011 at 02:04:46, Tony Lindgren wrote:
> > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 16:28]:
> > > On Tuesday 20 of December 2011 at 01:06:00, Tony Lindgren wrote:
> > > > 
> > > > This part especially looks like it really should be just a regular
> > > > device driver under drivers/ somewhere. 
> > > 
> > > I really don't understand what kind of a driver you might mean here.
> > > 
> > > The latch_gpios[] table is initially filled with all latch1 and latch2 
> > > GPIO pins in order to register and initialize them from the board file 
> > > until they are handled by respective existing device drivers (leds, 
> > > nand, lcd, serio, serial8250, asoc) instead of those drivers accessing 
> > > the latches with those old ams_delta_latch[12]_write() functions. That 
> > > table will get almost empty after the transision process is completed, 
> > > holding only pins not used by any drivers / connected to unsued devices, 
> > > in order to initialize them from the board file for power saving 
> > > purposes. A separate driver for the purpose of initializing a few GPIO 
> > > pins seems an overkill.
> > 
> > OK maybe update the comments a bit to describe how that table will
> > mostly disappear? It's not obvious from glancing over this patch
> > series :)
> 
> To be sure, do you mean in-line comments? Or the changelog message?

Just the changelog.

Tony

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH v2 2/7 v2] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
  2011-12-20  1:04         ` Tony Lindgren
  2011-12-20  1:18           ` Janusz Krzysztofik
@ 2011-12-20  2:24           ` Janusz Krzysztofik
  1 sibling, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-20  2:24 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel, linux-kernel, Grant Likely

Resubmitting with the changelog extended.

8<-------------------------

Once ready, ams-delta specific device drivers currently calling custom
ams_delta_latch[12]_write() functions can be updated to call generic
gpio_set_value() instead, which will make them less platform dependent.
Even more, some custom ams-delta only drivers can perhaps be dropped
from the tree after converting selected ams-delta platform devices to
follow generic GPIO based device models.

The latch_gpios[] table is initially filled with all latch1 and latch2 
GPIO pins in order to register and initialize them from the board file 
until those are handled by respective existing device drivers (leds, 
nand, lcd, serio, asoc, serial). That table will get almost empty after 
the transision process is completed, holding only pins not used by any 
drivers / connected to unused devices, in order to initialize them from 
the board file for power saving purposes.

The new ams_delta_latch_write() function is a unified replacement for 
those removed ams_delta_latch[12]_write(), and serves as a temporary 
wrapper over gpio_set_value(), providing the old API for those not yet 
updated device drivers, and will be removed after all custom drivers are 
converted or replaced.

Depends on patch 1/7, "ARM: OMAP1: ams-delta: register latch dependent
devices later".

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
Changes against initial version:
* refreshed on top of patch 1/7, which is the old 1/10 replacement,
* no need to BUG_ON() if GPIO request fails inside late_init(), can
  return with error from there instead,
* dropped leading underscores from local symbols, variable and function
  names (no namespace conflicts expected).


 arch/arm/mach-omap1/Kconfig                       |    1 +
 arch/arm/mach-omap1/board-ams-delta.c             |  237 ++++++++++++++++++---
 arch/arm/plat-omap/include/plat/board-ams-delta.h |   43 +++-
 3 files changed, 242 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index 73f287d..d2606b1 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -155,6 +155,7 @@ config MACH_AMS_DELTA
 	bool "Amstrad E3 (Delta)"
 	depends on ARCH_OMAP1 && ARCH_OMAP15XX
 	select FIQ
+	select GPIO_GENERIC_PLATFORM
 	help
 	  Support for the Amstrad E3 (codename Delta) videophone. Say Y here
 	  if you have such a device.
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 50987c9..cff2711 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -11,6 +11,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/basic_mmio_gpio.h>
 #include <linux/gpio.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -40,9 +41,6 @@
 
 #include <mach/ams-delta-fiq.h>
 
-static u8 ams_delta_latch1_reg;
-static u16 ams_delta_latch2_reg;
-
 static const unsigned int ams_delta_keymap[] = {
 	KEY(0, 0, KEY_F1),		/* Advert    */
 
@@ -121,39 +119,32 @@ static const unsigned int ams_delta_keymap[] = {
 	KEY(7, 3, KEY_LEFTCTRL),	/* Vol down  */
 };
 
-void ams_delta_latch1_write(u8 mask, u8 value)
-{
-	ams_delta_latch1_reg &= ~mask;
-	ams_delta_latch1_reg |= value;
-	*(volatile __u8 *) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg;
-}
-
-void ams_delta_latch2_write(u16 mask, u16 value)
-{
-	ams_delta_latch2_reg &= ~mask;
-	ams_delta_latch2_reg |= value;
-	*(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg;
-}
+#define LATCH1_PHYS	0x01000000
+#define LATCH1_VIRT	0xEA000000
+#define MODEM_PHYS	0x04000000
+#define MODEM_VIRT	0xEB000000
+#define LATCH2_PHYS	0x08000000
+#define LATCH2_VIRT	0xEC000000
 
 static struct map_desc ams_delta_io_desc[] __initdata = {
 	/* AMS_DELTA_LATCH1 */
 	{
-		.virtual	= AMS_DELTA_LATCH1_VIRT,
-		.pfn		= __phys_to_pfn(AMS_DELTA_LATCH1_PHYS),
+		.virtual	= LATCH1_VIRT,
+		.pfn		= __phys_to_pfn(LATCH1_PHYS),
 		.length		= 0x01000000,
 		.type		= MT_DEVICE
 	},
 	/* AMS_DELTA_LATCH2 */
 	{
-		.virtual	= AMS_DELTA_LATCH2_VIRT,
-		.pfn		= __phys_to_pfn(AMS_DELTA_LATCH2_PHYS),
+		.virtual	= LATCH2_VIRT,
+		.pfn		= __phys_to_pfn(LATCH2_PHYS),
 		.length		= 0x01000000,
 		.type		= MT_DEVICE
 	},
 	/* AMS_DELTA_MODEM */
 	{
-		.virtual	= AMS_DELTA_MODEM_VIRT,
-		.pfn		= __phys_to_pfn(AMS_DELTA_MODEM_PHYS),
+		.virtual	= MODEM_VIRT,
+		.pfn		= __phys_to_pfn(MODEM_PHYS),
 		.length		= 0x01000000,
 		.type		= MT_DEVICE
 	}
@@ -173,6 +164,190 @@ static struct omap_board_config_kernel ams_delta_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&ams_delta_lcd_config },
 };
 
+static struct resource latch1_resources[] __initconst = {
+	[0] = {
+		.name	= "dat",
+		.start	= LATCH1_PHYS,
+		.end	= LATCH1_PHYS + (AMS_DELTA_LATCH1_NGPIO - 1) / 8,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct bgpio_pdata latch1_pdata __initconst = {
+	.base	= AMS_DELTA_LATCH1_GPIO_BASE,
+	.ngpio	= AMS_DELTA_LATCH1_NGPIO,
+};
+
+static struct platform_device latch1_gpio_device = {
+	.name		= "basic-mmio-gpio",
+	.id		= 0,
+	.resource	= latch1_resources,
+	.num_resources	= ARRAY_SIZE(latch1_resources),
+	.dev		= {
+		.platform_data	= &latch1_pdata,
+	},
+};
+
+static struct resource latch2_resources[] __initconst = {
+	[0] = {
+		.name	= "dat",
+		.start	= LATCH2_PHYS,
+		.end	= LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct bgpio_pdata latch2_pdata __initconst = {
+	.base	= AMS_DELTA_LATCH2_GPIO_BASE,
+	.ngpio	= AMS_DELTA_LATCH2_NGPIO,
+};
+
+static struct platform_device latch2_gpio_device = {
+	.name		= "basic-mmio-gpio",
+	.id		= 1,
+	.resource	= latch2_resources,
+	.num_resources	= ARRAY_SIZE(latch2_resources),
+	.dev		= {
+		.platform_data	= &latch2_pdata,
+	},
+};
+
+static struct gpio latch_gpios[] __initconst = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_CAMERA,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_camera",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_ADVERT,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_advert",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_EMAIL,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_email",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_HANDSFREE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_handsfree",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICEMAIL,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_voicemail",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LED_VOICE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "led_voice",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 6,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "dockit1",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH1_GPIO_BASE + 7,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "dockit2",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_vblen",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "lcd_ndisp",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nce",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nre",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nwp",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_nwe",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_ale",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "nand_cle",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "keybrd_pwr",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "keybrd_dataout",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "scard_rstin",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "scard_cmdvcc",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "modem_nreset",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_MODEM_CODEC,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "modem_codec",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 14,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "hookflash1",
+	},
+	{
+		.gpio	= AMS_DELTA_LATCH2_GPIO_BASE + 15,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "hookflash2",
+	},
+};
+
+void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
+{
+	int bit = 0;
+	u16 bitpos = 1 << bit;
+
+	for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
+		if (!(mask & bitpos))
+			continue;
+		gpio_set_value(base + bit, (value & bitpos) != 0);
+	}
+}
+EXPORT_SYMBOL(ams_delta_latch_write);
+
 static struct resource ams_delta_nand_resources[] = {
 	[0] = {
 		.start	= OMAP1_MPUIO_BASE,
@@ -275,11 +450,13 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
 };
 
 static struct platform_device *ams_delta_devices[] __initdata = {
+	&latch1_gpio_device,
+	&latch2_gpio_device,
 	&ams_delta_kp_device,
 	&ams_delta_camera_device,
 };
 
-static struct platform_device *late_devices[] __initdata = {
+static struct platform_device *late_devices[] __initconst = {
 	&ams_delta_nand_device,
 	&ams_delta_lcd_device,
 	&ams_delta_led_device,
@@ -325,8 +502,8 @@ static void __init ams_delta_init(void)
 
 static struct plat_serial8250_port ams_delta_modem_ports[] = {
 	{
-		.membase	= IOMEM(AMS_DELTA_MODEM_VIRT),
-		.mapbase	= AMS_DELTA_MODEM_PHYS,
+		.membase	= IOMEM(MODEM_VIRT),
+		.mapbase	= MODEM_PHYS,
 		.irq		= -EINVAL, /* changed later */
 		.flags		= UPF_BOOT_AUTOCONF,
 		.irqflags	= IRQF_TRIGGER_RISING,
@@ -352,8 +529,11 @@ static int __init late_init(void)
 	if (!machine_is_ams_delta())
 		return -ENODEV;
 
-	/* Clear latch2 (NAND, LCD, modem enable) */
-	ams_delta_latch2_write(~0, 0);
+	err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios));
+	if (err) {
+		pr_err("Couldn't take over latch1/latch2 GPIO pins\n");
+		return err;
+	}
 
 	platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
 
@@ -399,6 +579,3 @@ MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
 	.init_machine	= ams_delta_init,
 	.timer		= &omap1_timer,
 MACHINE_END
-
-EXPORT_SYMBOL(ams_delta_latch1_write);
-EXPORT_SYMBOL(ams_delta_latch2_write);
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 51b102d..68ffe32 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,13 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMS_DELTA_LATCH1_PHYS		0x01000000
-#define AMS_DELTA_LATCH1_VIRT		0xEA000000
-#define AMS_DELTA_MODEM_PHYS		0x04000000
-#define AMS_DELTA_MODEM_VIRT		0xEB000000
-#define AMS_DELTA_LATCH2_PHYS		0x08000000
-#define AMS_DELTA_LATCH2_VIRT		0xEC000000
-
 #define AMS_DELTA_LATCH1_LED_CAMERA	0x01
 #define AMS_DELTA_LATCH1_LED_ADVERT	0x02
 #define AMS_DELTA_LATCH1_LED_EMAIL	0x04
@@ -66,9 +59,41 @@
 #define AMS_DELTA_GPIO_PIN_CONFIG	11
 #define AMS_DELTA_GPIO_PIN_NAND_RB	12
 
+#define AMS_DELTA_GPIO_PIN_LED_CAMERA		232
+#define AMS_DELTA_GPIO_PIN_LED_ADVERT		233
+#define AMS_DELTA_GPIO_PIN_LED_EMAIL		234
+#define AMS_DELTA_GPIO_PIN_LED_HANDSFREE	235
+#define AMS_DELTA_GPIO_PIN_LED_VOICEMAIL	236
+#define AMS_DELTA_GPIO_PIN_LED_VOICE		237
+
+#define AMS_DELTA_GPIO_PIN_LCD_VBLEN		240
+#define AMS_DELTA_GPIO_PIN_LCD_NDISP		241
+#define AMS_DELTA_GPIO_PIN_NAND_NCE		242
+#define AMS_DELTA_GPIO_PIN_NAND_NRE		243
+#define AMS_DELTA_GPIO_PIN_NAND_NWP		244
+#define AMS_DELTA_GPIO_PIN_NAND_NWE		245
+#define AMS_DELTA_GPIO_PIN_NAND_ALE		246
+#define AMS_DELTA_GPIO_PIN_NAND_CLE		247
+#define AMS_DELTA_GPIO_PIN_KEYBRD_PWR		248
+#define AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT	249
+#define AMS_DELTA_GPIO_PIN_SCARD_RSTIN		250
+#define AMS_DELTA_GPIO_PIN_SCARD_CMDVCC		251
+#define AMS_DELTA_GPIO_PIN_MODEM_NRESET		252
+#define AMS_DELTA_GPIO_PIN_MODEM_CODEC		253
+
+#define AMS_DELTA_LATCH1_GPIO_BASE	AMS_DELTA_GPIO_PIN_LED_CAMERA
+#define AMS_DELTA_LATCH1_NGPIO		8
+#define AMS_DELTA_LATCH2_GPIO_BASE	AMS_DELTA_GPIO_PIN_LCD_VBLEN
+#define AMS_DELTA_LATCH2_NGPIO		16
+
 #ifndef __ASSEMBLY__
-void ams_delta_latch1_write(u8 mask, u8 value);
-void ams_delta_latch2_write(u16 mask, u16 value);
+void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value);
+#define ams_delta_latch1_write(mask, value) \
+	ams_delta_latch_write(AMS_DELTA_LATCH1_GPIO_BASE, \
+			AMS_DELTA_LATCH1_NGPIO, (mask), (value))
+#define ams_delta_latch2_write(mask, value) \
+	ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \
+			AMS_DELTA_LATCH2_NGPIO, (mask), (value))
 #endif
 
 #endif /* CONFIG_MACH_AMS_DELTA */
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-19 23:28   ` [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later Janusz Krzysztofik
@ 2011-12-20 18:06     ` Tony Lindgren
  2011-12-20 20:34       ` Janusz Krzysztofik
  2011-12-20 20:40     ` Russell King - ARM Linux
  2011-12-20 21:54     ` [PATCH v2 1/7 v2] " Janusz Krzysztofik
  2 siblings, 1 reply; 63+ messages in thread
From: Tony Lindgren @ 2011-12-20 18:06 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Dmitry Torokhov, Jarkko Nikula, Liam Girdwood, Mark Brown,
	linux-input

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 14:57]:
> Resending because of a typo in the Cc: list, sorry.
> 
> 8<--------------------------
> 
> In preparation to converting Amstrad Delta on-board latches to
> basic_mmio_gpio devices, registration of platform devices which depend
> on latches and will require initialization of their GPIO pins first,
> should be moved out of .machine_init down to late_initcall level, as the
> gpio-generic driver is not available until device_initcall time.  The
> latch reset operation, which will be replaced with GPIO initialization,
> must also be moved to late_initcall for the same reason.
> 
> Since there was already another, separate arch_initcall function for
> setting up one of those latch dependent devices, the on-board modem
> device, reuse that function, i.e., rename it to a name that matches the
> new purpose, extend with other device setup relocated from
> .machine_init, and move down to the late_initcall level.
> 
> While being at it, add missing gpio_free() in case the modem platform
> device registration fails.
> 
> In addition, defer registration of the Amstrad Delta ASoC and serio
> devices, done from their device driver files, until late_initcall time,
> as those drivers will depend on their GPIO pins already requested from
> the board late_init() function until updated to register their GPIO pins
> themselves.
> 
> Thanks to Tony Lindgren <tony@atomide.com> who suggested this approach
> instead of shifting up the gpio-generic driver initialization.
...
 
> --- a/drivers/input/serio/ams_delta_serio.c
> +++ b/drivers/input/serio/ams_delta_serio.c
> @@ -165,6 +165,9 @@ serio:
>  	kfree(ams_delta_serio);
>  	return err;
>  }
> +#ifndef MODULE
> +late_initcall(ams_delta_serio_init);
> +#else
>  module_init(ams_delta_serio_init);
>  
>  static void __exit ams_delta_serio_exit(void)
> @@ -175,3 +178,4 @@ static void __exit ams_delta_serio_exit(void)
>  	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
>  }
>  module_exit(ams_delta_serio_exit);
> +#endif
> diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
> index ccb8a6a..1764a3b 100644
> --- a/sound/soc/omap/ams-delta.c
> +++ b/sound/soc/omap/ams-delta.c
> @@ -636,6 +636,9 @@ err:
>  	platform_device_put(ams_delta_audio_platform_device);
>  	return ret;
>  }
> +#ifndef MODULE
> +late_initcall(ams_delta_module_init);
> +#else
>  module_init(ams_delta_module_init);
>  
>  static void __exit ams_delta_module_exit(void)
> @@ -657,6 +660,7 @@ static void __exit ams_delta_module_exit(void)
>  	platform_device_unregister(ams_delta_audio_platform_device);
>  }
>  module_exit(ams_delta_module_exit);
> +#endif
>  
>  MODULE_AUTHOR("Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>");
>  MODULE_DESCRIPTION("ALSA SoC driver for Amstrad E3 (Delta) videophone");

This looks a bit odd.. I think these drivers should be converted to
a proper platform_driver so you can get rid of the machine_is_ams_delta
check in the init. Then you can rely on the probe to match the
device. To deal with the init order issues, you can pass a set_power
function pointer in platform_data that the driver can use. Or
set up a fixed regulator for it.

Regards,

Tony

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-20 18:06     ` Tony Lindgren
@ 2011-12-20 20:34       ` Janusz Krzysztofik
  2011-12-20 20:57         ` Tony Lindgren
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-20 20:34 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: alsa-devel, Mark Brown, Dmitry Torokhov, linux-kernel,
	linux-arm-kernel, linux-input, linux-omap, Liam Girdwood,
	Jarkko Nikula

On Tuesday 20 of December 2011 at 19:06:11, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 14:57]:
> > Resending because of a typo in the Cc: list, sorry.
> > 
> > 8<--------------------------
> > 
> > In preparation to converting Amstrad Delta on-board latches to
> > basic_mmio_gpio devices, registration of platform devices which depend
> > on latches and will require initialization of their GPIO pins first,
> > should be moved out of .machine_init down to late_initcall level, as the
> > gpio-generic driver is not available until device_initcall time.  The
> > latch reset operation, which will be replaced with GPIO initialization,
> > must also be moved to late_initcall for the same reason.
> > 
> > Since there was already another, separate arch_initcall function for
> > setting up one of those latch dependent devices, the on-board modem
> > device, reuse that function, i.e., rename it to a name that matches the
> > new purpose, extend with other device setup relocated from
> > .machine_init, and move down to the late_initcall level.
> > 
> > While being at it, add missing gpio_free() in case the modem platform
> > device registration fails.
> > 
> > In addition, defer registration of the Amstrad Delta ASoC and serio
> > devices, done from their device driver files, until late_initcall time,
> > as those drivers will depend on their GPIO pins already requested from
> > the board late_init() function until updated to register their GPIO pins
> > themselves.
> > 
> > Thanks to Tony Lindgren <tony@atomide.com> who suggested this approach
> > instead of shifting up the gpio-generic driver initialization.
> ...
>  
> > --- a/drivers/input/serio/ams_delta_serio.c
> > +++ b/drivers/input/serio/ams_delta_serio.c
> > @@ -165,6 +165,9 @@ serio:
> >  	kfree(ams_delta_serio);
> >  	return err;
> >  }
> > +#ifndef MODULE
> > +late_initcall(ams_delta_serio_init);
> > +#else
> >  module_init(ams_delta_serio_init);
> >  
> >  static void __exit ams_delta_serio_exit(void)
> > @@ -175,3 +178,4 @@ static void __exit ams_delta_serio_exit(void)
> >  	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> >  }
> >  module_exit(ams_delta_serio_exit);
> > +#endif
> > diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
> > index ccb8a6a..1764a3b 100644
> > --- a/sound/soc/omap/ams-delta.c
> > +++ b/sound/soc/omap/ams-delta.c
> > @@ -636,6 +636,9 @@ err:
> >  	platform_device_put(ams_delta_audio_platform_device);
> >  	return ret;
> >  }
> > +#ifndef MODULE
> > +late_initcall(ams_delta_module_init);
> > +#else
> >  module_init(ams_delta_module_init);
> >  
> >  static void __exit ams_delta_module_exit(void)
> > @@ -657,6 +660,7 @@ static void __exit ams_delta_module_exit(void)
> >  	platform_device_unregister(ams_delta_audio_platform_device);
> >  }
> >  module_exit(ams_delta_module_exit);
> > +#endif
> >  
> >  MODULE_AUTHOR("Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>");
> >  MODULE_DESCRIPTION("ALSA SoC driver for Amstrad E3 (Delta) videophone");
> 
> This looks a bit odd.. I think these drivers should be converted to
> a proper platform_driver so you can get rid of the machine_is_ams_delta
> check in the init. Then you can rely on the probe to match the
> device.

Mostly true, but first of all, I don't pretend to solve all problems 
with all Amstrad Delta specific drivers in this patch series. I'm 
concentrating on converting latches to GPIO pins, and updating those 
drivers to access those pins with gpiolib API instead of accessing the 
latches with the board specific API. Nothing more.

Now, regarding the serio driver, you are absolutely right, the device 
registration could be better moved out of the driver file to the board 
file. I'll probably do this some time in the future, once I'm ready with 
the latches related stuff, i.e. the ams_delta_latch_write() is finally 
removed from the board file as no longer used by any driver, and find 
some spare time again. For now, I'm moving that serio device/driver 
initialization to late_initcall with patch 2/7, and back to 
device_initcall once converted to gpiolib (patch 7/7). Is this 
acceptable? If not, let's drop those forward and back moves, and the 
driver will get broken with 2/7, but get repaired with 7/7, OK?

Regarding the sound card: the sound/soc/omap/ams-delta.c file is not a 
device driver per se, but rather a piece of code which sets up a 
platform device representing the sound card, i.e., provides platform 
device description and platform data, including device specific 
callbacks, to be used by the generic 'soc-audio' driver. There is no 
single platform_driver_register() called from that file, only 
platform_device_register() or alike. That code seems to belong logically 
to the board setup, but was always maintained, among 12 others, and for 
reasons not known to me with my relatively short experience as a kernel 
developer, inside the sound/soc/omap/ subtree, not under arch/arm/mach-
omap1/. Like all those 12 others, including sdp4430 which is quite 
recent I guess, it makes use of the machine_is_* function as if it was a 
part of a board files set. Then, the only way I can see to defer the 
device initialization until late_initcall time, with the soc-audio 
driver already loaded at the device_initcall level, is to move with that 
sound card platform device setup code, found in sound/soc/omap/ams-
delta.c, to the late_initcall. Am I missing something?

> To deal with the init order issues, you can pass a set_power
> function pointer in platform_data that the driver can use. Or
> set up a fixed regulator for it.

I'm already working on the follow up patch series mentioned in the cover 
letter, and yes, I'm using the fixed regulator. Be patient, please, as 
my resources are somehow limited.

Thanks,
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-19 23:28   ` [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later Janusz Krzysztofik
  2011-12-20 18:06     ` Tony Lindgren
@ 2011-12-20 20:40     ` Russell King - ARM Linux
  2011-12-20 20:51       ` [alsa-devel] " Janusz Krzysztofik
  2011-12-20 21:54     ` [PATCH v2 1/7 v2] " Janusz Krzysztofik
  2 siblings, 1 reply; 63+ messages in thread
From: Russell King - ARM Linux @ 2011-12-20 20:40 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, alsa-devel, Mark Brown, Dmitry Torokhov,
	linux-kernel, linux-arm-kernel, linux-input, linux-omap,
	Liam Girdwood, Jarkko Nikula

On Tue, Dec 20, 2011 at 12:28:32AM +0100, Janusz Krzysztofik wrote:
> diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
> index d4d08bd..56ffd7c 100644
> --- a/drivers/input/serio/ams_delta_serio.c
> +++ b/drivers/input/serio/ams_delta_serio.c
> @@ -165,6 +165,9 @@ serio:
>  	kfree(ams_delta_serio);
>  	return err;
>  }
> +#ifndef MODULE
> +late_initcall(ams_delta_serio_init);
> +#else
>  module_init(ams_delta_serio_init);
>  
>  static void __exit ams_delta_serio_exit(void)
> @@ -175,3 +178,4 @@ static void __exit ams_delta_serio_exit(void)
>  	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
>  }
>  module_exit(ams_delta_serio_exit);
> +#endif

It's worth noting:

#ifndef MODULE
#define late_initcall(fn)               __define_initcall("7",fn,7)
#else /* MODULE */
#define late_initcall(fn)               module_init(fn)

So really, all these ifndefs aren't required.  Just change the module_init()
to late_initcall().

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [alsa-devel] [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-20 20:40     ` Russell King - ARM Linux
@ 2011-12-20 20:51       ` Janusz Krzysztofik
  0 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-20 20:51 UTC (permalink / raw)
  To: alsa-devel
  Cc: Russell King - ARM Linux, Dmitry Torokhov, Tony Lindgren,
	Mark Brown, linux-kernel, Jarkko Nikula, linux-input, linux-omap,
	Liam Girdwood, linux-arm-kernel

On Tuesday 20 of December 2011 at 21:40:46, Russell King - ARM Linux wrote:
> On Tue, Dec 20, 2011 at 12:28:32AM +0100, Janusz Krzysztofik wrote:
> > diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
> > index d4d08bd..56ffd7c 100644
> > --- a/drivers/input/serio/ams_delta_serio.c
> > +++ b/drivers/input/serio/ams_delta_serio.c
> > @@ -165,6 +165,9 @@ serio:
> >  	kfree(ams_delta_serio);
> >  	return err;
> >  }
> > +#ifndef MODULE
> > +late_initcall(ams_delta_serio_init);
> > +#else
> >  module_init(ams_delta_serio_init);
> >  
> >  static void __exit ams_delta_serio_exit(void)
> > @@ -175,3 +178,4 @@ static void __exit ams_delta_serio_exit(void)
> >  	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> >  }
> >  module_exit(ams_delta_serio_exit);
> > +#endif
> 
> It's worth noting:
> 
> #ifndef MODULE
> #define late_initcall(fn)               __define_initcall("7",fn,7)
> #else /* MODULE */
> #define late_initcall(fn)               module_init(fn)
> 
> So really, all these ifndefs aren't required.  Just change the module_init()
> to late_initcall().

Thanks, I'll follow your pattern. My reason for using those ifdefery was 
a comment still found in include/linux/init.h:

#else /* MODULE */

/* Don't use these in modules, but some people do... */
#define early_initcall(fn)              module_init(fn)
#define core_initcall(fn)               module_init(fn)
...
#define late_initcall(fn)               module_init(fn)

Thanks,
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-20 20:34       ` Janusz Krzysztofik
@ 2011-12-20 20:57         ` Tony Lindgren
  0 siblings, 0 replies; 63+ messages in thread
From: Tony Lindgren @ 2011-12-20 20:57 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: alsa-devel, Mark Brown, Dmitry Torokhov, linux-kernel,
	linux-arm-kernel, linux-input, linux-omap, Liam Girdwood,
	Jarkko Nikula

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111220 12:03]:
> On Tuesday 20 of December 2011 at 19:06:11, Tony Lindgren wrote:
> 
> > To deal with the init order issues, you can pass a set_power
> > function pointer in platform_data that the driver can use. Or
> > set up a fixed regulator for it.
> 
> I'm already working on the follow up patch series mentioned in the cover 
> letter, and yes, I'm using the fixed regulator. Be patient, please, as 
> my resources are somehow limited.

Yes, I understand. For this patch I'm fine with the late_initcall
changes Russell suggested, then the rest can be done in separate
patches later on.

Regards,

Tony

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH v2 1/7 v2] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-19 23:28   ` [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later Janusz Krzysztofik
  2011-12-20 18:06     ` Tony Lindgren
  2011-12-20 20:40     ` Russell King - ARM Linux
@ 2011-12-20 21:54     ` Janusz Krzysztofik
  2011-12-21 19:08       ` Tony Lindgren
  2 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-20 21:54 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Dmitry Torokhov, Jarkko Nikula, Liam Girdwood, Mark Brown,
	Russell King - ARM Linux, linux-omap, linux-arm-kernel,
	linux-kernel, alsa-devel, linux-input, Janusz Krzysztofik

In preparation to converting Amstrad Delta on-board latches to
basic_mmio_gpio devices, registration of platform devices which depend
on latches and will require initialization of their GPIO pins first,
should be moved out of .machine_init down to late_initcall level, as the
gpio-generic driver is not available until device_initcall time.  The
latch reset operation, which will be replaced with GPIO initialization,
must also be moved to late_initcall for the same reason.

Since there was already another, separate arch_initcall function for
setting up one of those latch dependent devices, the on-board modem
device, reuse that function, i.e., rename it to a name that matches the
new purpose, extend with other device setup relocated from
.machine_init, and move down to the late_initcall level.

While being at it, add missing gpio_free() in case the modem platform
device registration fails.

Thanks to Tony Lindgren <tony@atomide.com> who suggested this approach
instead of shifting up the gpio-generic driver initialization.

In addition, defer registration of the Amstrad Delta ASoC and serio
devices, done from their device driver files, until late_initcall time,
as those drivers will depend on their GPIO pins already requested from
the board late_init() function until updated to register their GPIO pins
themselves.

Created and tested against linux-3.2-rc6.

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
Changes since the initial version of this patch:
* use late_initcall() unconditionally in modules, requested by Russell
  King (thanks!); an updated patch 7/7 will follow,
* in the changelog message, move credits to Tony up a bit, since the
  person responsible for other changes (he might not necessarily like)
  is me, not him ;).

Comments copied from this patch initial submission:
This patch was not present in the initial submission, it replaces the
old patch 1/10, providing an alternative solution not touching the
gpio-generic driver.

 arch/arm/mach-omap1/board-ams-delta.c |   28 ++++++++++++++++++++--------
 drivers/input/serio/ams_delta_serio.c |    2 +-
 sound/soc/omap/ams-delta.c            |    2 +-
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index b0f15d2..50987c9 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -275,11 +275,14 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
 };
 
 static struct platform_device *ams_delta_devices[] __initdata = {
-	&ams_delta_nand_device,
 	&ams_delta_kp_device,
+	&ams_delta_camera_device,
+};
+
+static struct platform_device *late_devices[] __initdata = {
+	&ams_delta_nand_device,
 	&ams_delta_lcd_device,
 	&ams_delta_led_device,
-	&ams_delta_camera_device,
 };
 
 static void __init ams_delta_init(void)
@@ -307,9 +310,6 @@ static void __init ams_delta_init(void)
 	omap_serial_init();
 	omap_register_i2c_bus(1, 100, NULL, 0);
 
-	/* Clear latch2 (NAND, LCD, modem enable) */
-	ams_delta_latch2_write(~0, 0);
-
 	omap1_usb_init(&ams_delta_usb_config);
 	omap1_set_camera_info(&ams_delta_camera_platform_data);
 #ifdef CONFIG_LEDS_TRIGGERS
@@ -345,13 +345,18 @@ static struct platform_device ams_delta_modem_device = {
 	},
 };
 
-static int __init ams_delta_modem_init(void)
+static int __init late_init(void)
 {
 	int err;
 
 	if (!machine_is_ams_delta())
 		return -ENODEV;
 
+	/* Clear latch2 (NAND, LCD, modem enable) */
+	ams_delta_latch2_write(~0, 0);
+
+	platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
+
 	omap_cfg_reg(M14_1510_GPIO2);
 	ams_delta_modem_ports[0].irq =
 			gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
@@ -367,9 +372,16 @@ static int __init ams_delta_modem_init(void)
 		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
 		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
 
-	return platform_device_register(&ams_delta_modem_device);
+	err = platform_device_register(&ams_delta_modem_device);
+	if (err)
+		goto gpio_free;
+	return 0;
+
+gpio_free:
+	gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
+	return err;
 }
-arch_initcall(ams_delta_modem_init);
+late_initcall(late_init);
 
 static void __init ams_delta_map_io(void)
 {
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index d4d08bd..835d37a 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -165,7 +165,7 @@ serio:
 	kfree(ams_delta_serio);
 	return err;
 }
-module_init(ams_delta_serio_init);
+late_initcall(ams_delta_serio_init);
 
 static void __exit ams_delta_serio_exit(void)
 {
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index ccb8a6a..be81bc7 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -636,7 +636,7 @@ err:
 	platform_device_put(ams_delta_audio_platform_device);
 	return ret;
 }
-module_init(ams_delta_module_init);
+late_initcall(ams_delta_module_init);
 
 static void __exit ams_delta_module_exit(void)
 {
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH] input: serio: ams-delta: toggle keyboard power over GPIO
  2011-12-19 23:08   ` [PATCH v2 7/7] input: serio: ams-delta: toggle keyboard power " Janusz Krzysztofik
@ 2011-12-20 22:10     ` Janusz Krzysztofik
  2011-12-21 19:09       ` Tony Lindgren
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-20 22:10 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Dmitry Torokhov, Russell King - ARM Linux, linux-omap,
	linux-arm-kernel, linux-kernel, linux-input, Janusz Krzysztofik

Don't use Amstrad Delta custom I/O functions once GPIO interface is
available for the underlying hardware.

While requesting and initializing GPIO pins used, also take care of one
extra pin KEYBRD_DATAOUT which, even if not used by the driver, belongs
to the device and affects its functioning.

Once done, move the driver initialization back to the device_initcall
level, reverting the temporary chane introduced with patch 1/7 "ARM:
OMAP1: ams-delta: register latch dependent devices later".  That change
is no longer required once the driver takes care of registering used
GPIO pins, and it's better to initialize the device before others using
the latch2 based GPIO pins, otherwise a garbage is reported on boot,
perhaps due to random data already captured by the FIQ handler while the
keyboard related latch bits are written with random values during
initialization of those other latch2 dependent devices.

Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
basic_mmio_gpio"

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
Hi,
I'm submitting only this one refreshed on top of updated 1/7. All others
(2/7-6/7) don't require any refresh, can be rebased smoothly.

Thanks,
Janusz


Changes against version 2:
* refreshed on top of updated patch 1/7 v2,
* changelog: corrected patch 1/7 summary (was inaccurate).

Changes against initial version:
* was 9/10,
* rebased on top of v2 of patch 2/7, just in case,
* moved AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT pin handling from the board
  code to the driver,
* reverted a temporary change to the driver initcall level, introduced
  by the new solution provided with patch 1/7.


 arch/arm/mach-omap1/board-ams-delta.c             |   10 ----
 arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 -
 drivers/input/serio/ams_delta_serio.c             |   53 ++++++++++++--------
:x 3 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 3aba8f9..673cf21 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -227,16 +227,6 @@ static struct gpio latch_gpios[] __initconst = {
 		.label	= "dockit2",
 	},
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "keybrd_pwr",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "keybrd_dataout",
-	},
-	{
 		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "scard_rstin",
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index e9ad673..027e79e 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,8 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
-#define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
 #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
 #define AMD_DELTA_LATCH2_SCARD_CMDVCC	0x0800
 #define AMS_DELTA_LATCH2_MODEM_NRESET	0x1000
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index 835d37a..ef1ec40 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -92,8 +92,7 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
 static int ams_delta_serio_open(struct serio *serio)
 {
 	/* enable keyboard */
-	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR,
-			AMD_DELTA_LATCH2_KEYBRD_PWR);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1);
 
 	return 0;
 }
@@ -101,9 +100,32 @@ static int ams_delta_serio_open(struct serio *serio)
 static void ams_delta_serio_close(struct serio *serio)
 {
 	/* disable keyboard */
-	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0);
 }
 
+static struct gpio _gpios[] __initconst_or_module = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
+		.flags	= GPIOF_DIR_IN,
+		.label	= "serio-data",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
+		.flags	= GPIOF_DIR_IN,
+		.label	= "serio-clock",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "serio-power",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "serio-dataout",
+	},
+};
+
 static int __init ams_delta_serio_init(void)
 {
 	int err;
@@ -123,19 +145,11 @@ static int __init ams_delta_serio_init(void)
 	strlcpy(ams_delta_serio->phys, "GPIO/serio0",
 			sizeof(ams_delta_serio->phys));
 
-	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_DATA, "serio-data");
+	err = gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
 	if (err) {
-		pr_err("ams_delta_serio: Couldn't request gpio pin for data\n");
+		pr_err("ams_delta_serio: Couldn't request gpio pins\n");
 		goto serio;
 	}
-	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
-
-	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_CLK, "serio-clock");
-	if (err) {
-		pr_err("ams_delta_serio: couldn't request gpio pin for clock\n");
-		goto gpio_data;
-	}
-	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
 
 	err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
 			ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING,
@@ -143,7 +157,7 @@ static int __init ams_delta_serio_init(void)
 	if (err < 0) {
 		pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n",
 				gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK));
-		goto gpio_clk;
+		goto gpio;
 	}
 	/*
 	 * Since GPIO register handling for keyboard clock pin is performed
@@ -157,21 +171,18 @@ static int __init ams_delta_serio_init(void)
 	dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name);
 
 	return 0;
-gpio_clk:
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
-gpio_data:
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
+gpio:
+	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
 serio:
 	kfree(ams_delta_serio);
 	return err;
 }
-late_initcall(ams_delta_serio_init);
+module_init(ams_delta_serio_init);
 
 static void __exit ams_delta_serio_exit(void)
 {
 	serio_unregister_port(ams_delta_serio);
 	free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
+	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
 }
 module_exit(ams_delta_serio_exit);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* Re: [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API
  2011-12-11 20:12 ` [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API Janusz Krzysztofik
  2011-12-12  4:29   ` Mark Brown
@ 2011-12-21 18:33   ` Liam Girdwood
  2011-12-21 22:14     ` Janusz Krzysztofik
  1 sibling, 1 reply; 63+ messages in thread
From: Liam Girdwood @ 2011-12-21 18:33 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, Jarkko Nikula, linux-omap, linux-arm-kernel,
	linux-kernel, alsa-devel, Mark Brown

On Sun, 2011-12-11 at 21:12 +0100, Janusz Krzysztofik wrote:
> Don't use Amstrad Delta custom I/O functions any longer, replace them
> with GPIO. Old pin definitions, no longer used by the modem bits either,
> can be dropped.
> 
> Depends on patch 2/10 "ARM: OMAP1: Convert Amstrad E3 latches to
> basic_mmio_gpio".
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>

Applied.

Thanks

Liam


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7 v2] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-20 21:54     ` [PATCH v2 1/7 v2] " Janusz Krzysztofik
@ 2011-12-21 19:08       ` Tony Lindgren
  2011-12-21 19:51         ` Janusz Krzysztofik
  0 siblings, 1 reply; 63+ messages in thread
From: Tony Lindgren @ 2011-12-21 19:08 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Dmitry Torokhov, Jarkko Nikula, Liam Girdwood, Mark Brown,
	Russell King - ARM Linux, linux-omap, linux-arm-kernel,
	linux-kernel, alsa-devel, linux-input

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111220 13:23]:
> In preparation to converting Amstrad Delta on-board latches to
> basic_mmio_gpio devices, registration of platform devices which depend
> on latches and will require initialization of their GPIO pins first,
> should be moved out of .machine_init down to late_initcall level, as the
> gpio-generic driver is not available until device_initcall time.  The
> latch reset operation, which will be replaced with GPIO initialization,
> must also be moved to late_initcall for the same reason.
> 
> Since there was already another, separate arch_initcall function for
> setting up one of those latch dependent devices, the on-board modem
> device, reuse that function, i.e., rename it to a name that matches the
> new purpose, extend with other device setup relocated from
> .machine_init, and move down to the late_initcall level.
> 
> While being at it, add missing gpio_free() in case the modem platform
> device registration fails.
> 
> Thanks to Tony Lindgren <tony@atomide.com> who suggested this approach
> instead of shifting up the gpio-generic driver initialization.
> 
> In addition, defer registration of the Amstrad Delta ASoC and serio
> devices, done from their device driver files, until late_initcall time,
> as those drivers will depend on their GPIO pins already requested from
> the board late_init() function until updated to register their GPIO pins
> themselves.
> 
> Created and tested against linux-3.2-rc6.
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>

Planning to apply this series. Dmitry, care to ack the drivers/input/serio/
related change?

Regards,

Tony

> ---
> Changes since the initial version of this patch:
> * use late_initcall() unconditionally in modules, requested by Russell
>   King (thanks!); an updated patch 7/7 will follow,
> * in the changelog message, move credits to Tony up a bit, since the
>   person responsible for other changes (he might not necessarily like)
>   is me, not him ;).
> 
> Comments copied from this patch initial submission:
> This patch was not present in the initial submission, it replaces the
> old patch 1/10, providing an alternative solution not touching the
> gpio-generic driver.
> 
>  arch/arm/mach-omap1/board-ams-delta.c |   28 ++++++++++++++++++++--------
>  drivers/input/serio/ams_delta_serio.c |    2 +-
>  sound/soc/omap/ams-delta.c            |    2 +-
>  3 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
> index b0f15d2..50987c9 100644
> --- a/arch/arm/mach-omap1/board-ams-delta.c
> +++ b/arch/arm/mach-omap1/board-ams-delta.c
> @@ -275,11 +275,14 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
>  };
>  
>  static struct platform_device *ams_delta_devices[] __initdata = {
> -	&ams_delta_nand_device,
>  	&ams_delta_kp_device,
> +	&ams_delta_camera_device,
> +};
> +
> +static struct platform_device *late_devices[] __initdata = {
> +	&ams_delta_nand_device,
>  	&ams_delta_lcd_device,
>  	&ams_delta_led_device,
> -	&ams_delta_camera_device,
>  };
>  
>  static void __init ams_delta_init(void)
> @@ -307,9 +310,6 @@ static void __init ams_delta_init(void)
>  	omap_serial_init();
>  	omap_register_i2c_bus(1, 100, NULL, 0);
>  
> -	/* Clear latch2 (NAND, LCD, modem enable) */
> -	ams_delta_latch2_write(~0, 0);
> -
>  	omap1_usb_init(&ams_delta_usb_config);
>  	omap1_set_camera_info(&ams_delta_camera_platform_data);
>  #ifdef CONFIG_LEDS_TRIGGERS
> @@ -345,13 +345,18 @@ static struct platform_device ams_delta_modem_device = {
>  	},
>  };
>  
> -static int __init ams_delta_modem_init(void)
> +static int __init late_init(void)
>  {
>  	int err;
>  
>  	if (!machine_is_ams_delta())
>  		return -ENODEV;
>  
> +	/* Clear latch2 (NAND, LCD, modem enable) */
> +	ams_delta_latch2_write(~0, 0);
> +
> +	platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
> +
>  	omap_cfg_reg(M14_1510_GPIO2);
>  	ams_delta_modem_ports[0].irq =
>  			gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> @@ -367,9 +372,16 @@ static int __init ams_delta_modem_init(void)
>  		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
>  		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
>  
> -	return platform_device_register(&ams_delta_modem_device);
> +	err = platform_device_register(&ams_delta_modem_device);
> +	if (err)
> +		goto gpio_free;
> +	return 0;
> +
> +gpio_free:
> +	gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> +	return err;
>  }
> -arch_initcall(ams_delta_modem_init);
> +late_initcall(late_init);
>  
>  static void __init ams_delta_map_io(void)
>  {
> diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
> index d4d08bd..835d37a 100644
> --- a/drivers/input/serio/ams_delta_serio.c
> +++ b/drivers/input/serio/ams_delta_serio.c
> @@ -165,7 +165,7 @@ serio:
>  	kfree(ams_delta_serio);
>  	return err;
>  }
> -module_init(ams_delta_serio_init);
> +late_initcall(ams_delta_serio_init);
>  
>  static void __exit ams_delta_serio_exit(void)
>  {
> diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
> index ccb8a6a..be81bc7 100644
> --- a/sound/soc/omap/ams-delta.c
> +++ b/sound/soc/omap/ams-delta.c
> @@ -636,7 +636,7 @@ err:
>  	platform_device_put(ams_delta_audio_platform_device);
>  	return ret;
>  }
> -module_init(ams_delta_module_init);
> +late_initcall(ams_delta_module_init);
>  
>  static void __exit ams_delta_module_exit(void)
>  {
> -- 
> 1.7.3.4
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH] input: serio: ams-delta: toggle keyboard power over GPIO
  2011-12-20 22:10     ` [PATCH] " Janusz Krzysztofik
@ 2011-12-21 19:09       ` Tony Lindgren
  2011-12-21 19:55         ` Janusz Krzysztofik
  0 siblings, 1 reply; 63+ messages in thread
From: Tony Lindgren @ 2011-12-21 19:09 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Dmitry Torokhov, Russell King - ARM Linux, linux-omap,
	linux-arm-kernel, linux-kernel, linux-input

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111220 13:39]:
> Don't use Amstrad Delta custom I/O functions once GPIO interface is
> available for the underlying hardware.
> 
> While requesting and initializing GPIO pins used, also take care of one
> extra pin KEYBRD_DATAOUT which, even if not used by the driver, belongs
> to the device and affects its functioning.
> 
> Once done, move the driver initialization back to the device_initcall
> level, reverting the temporary chane introduced with patch 1/7 "ARM:
> OMAP1: ams-delta: register latch dependent devices later".  That change
> is no longer required once the driver takes care of registering used
> GPIO pins, and it's better to initialize the device before others using
> the latch2 based GPIO pins, otherwise a garbage is reported on boot,
> perhaps due to random data already captured by the FIQ handler while the
> keyboard related latch bits are written with random values during
> initialization of those other latch2 dependent devices.
> 
> Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
> basic_mmio_gpio"
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>

I'm assuming Dmitry's ack for an earlier version of this patch also
covers this one when applying.

Regards,

Tony

> ---
> Hi,
> I'm submitting only this one refreshed on top of updated 1/7. All others
> (2/7-6/7) don't require any refresh, can be rebased smoothly.
> 
> Thanks,
> Janusz
> 
> 
> Changes against version 2:
> * refreshed on top of updated patch 1/7 v2,
> * changelog: corrected patch 1/7 summary (was inaccurate).
> 
> Changes against initial version:
> * was 9/10,
> * rebased on top of v2 of patch 2/7, just in case,
> * moved AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT pin handling from the board
>   code to the driver,
> * reverted a temporary change to the driver initcall level, introduced
>   by the new solution provided with patch 1/7.
> 
> 
>  arch/arm/mach-omap1/board-ams-delta.c             |   10 ----
>  arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 -
>  drivers/input/serio/ams_delta_serio.c             |   53 ++++++++++++--------
> :x 3 files changed, 32 insertions(+), 33 deletions(-)
> 
> diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
> index 3aba8f9..673cf21 100644
> --- a/arch/arm/mach-omap1/board-ams-delta.c
> +++ b/arch/arm/mach-omap1/board-ams-delta.c
> @@ -227,16 +227,6 @@ static struct gpio latch_gpios[] __initconst = {
>  		.label	= "dockit2",
>  	},
>  	{
> -		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
> -		.flags	= GPIOF_OUT_INIT_LOW,
> -		.label	= "keybrd_pwr",
> -	},
> -	{
> -		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
> -		.flags	= GPIOF_OUT_INIT_LOW,
> -		.label	= "keybrd_dataout",
> -	},
> -	{
>  		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
>  		.flags	= GPIOF_OUT_INIT_LOW,
>  		.label	= "scard_rstin",
> diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
> index e9ad673..027e79e 100644
> --- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
> +++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
> @@ -28,8 +28,6 @@
>  
>  #if defined (CONFIG_MACH_AMS_DELTA)
>  
> -#define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
> -#define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
>  #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
>  #define AMD_DELTA_LATCH2_SCARD_CMDVCC	0x0800
>  #define AMS_DELTA_LATCH2_MODEM_NRESET	0x1000
> diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
> index 835d37a..ef1ec40 100644
> --- a/drivers/input/serio/ams_delta_serio.c
> +++ b/drivers/input/serio/ams_delta_serio.c
> @@ -92,8 +92,7 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
>  static int ams_delta_serio_open(struct serio *serio)
>  {
>  	/* enable keyboard */
> -	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR,
> -			AMD_DELTA_LATCH2_KEYBRD_PWR);
> +	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1);
>  
>  	return 0;
>  }
> @@ -101,9 +100,32 @@ static int ams_delta_serio_open(struct serio *serio)
>  static void ams_delta_serio_close(struct serio *serio)
>  {
>  	/* disable keyboard */
> -	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 0);
> +	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0);
>  }
>  
> +static struct gpio _gpios[] __initconst_or_module = {
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
> +		.flags	= GPIOF_DIR_IN,
> +		.label	= "serio-data",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
> +		.flags	= GPIOF_DIR_IN,
> +		.label	= "serio-clock",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "serio-power",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "serio-dataout",
> +	},
> +};
> +
>  static int __init ams_delta_serio_init(void)
>  {
>  	int err;
> @@ -123,19 +145,11 @@ static int __init ams_delta_serio_init(void)
>  	strlcpy(ams_delta_serio->phys, "GPIO/serio0",
>  			sizeof(ams_delta_serio->phys));
>  
> -	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_DATA, "serio-data");
> +	err = gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
>  	if (err) {
> -		pr_err("ams_delta_serio: Couldn't request gpio pin for data\n");
> +		pr_err("ams_delta_serio: Couldn't request gpio pins\n");
>  		goto serio;
>  	}
> -	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> -
> -	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_CLK, "serio-clock");
> -	if (err) {
> -		pr_err("ams_delta_serio: couldn't request gpio pin for clock\n");
> -		goto gpio_data;
> -	}
> -	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
>  
>  	err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
>  			ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING,
> @@ -143,7 +157,7 @@ static int __init ams_delta_serio_init(void)
>  	if (err < 0) {
>  		pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n",
>  				gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK));
> -		goto gpio_clk;
> +		goto gpio;
>  	}
>  	/*
>  	 * Since GPIO register handling for keyboard clock pin is performed
> @@ -157,21 +171,18 @@ static int __init ams_delta_serio_init(void)
>  	dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name);
>  
>  	return 0;
> -gpio_clk:
> -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
> -gpio_data:
> -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> +gpio:
> +	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
>  serio:
>  	kfree(ams_delta_serio);
>  	return err;
>  }
> -late_initcall(ams_delta_serio_init);
> +module_init(ams_delta_serio_init);
>  
>  static void __exit ams_delta_serio_exit(void)
>  {
>  	serio_unregister_port(ams_delta_serio);
>  	free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
> -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
> -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> +	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
>  }
>  module_exit(ams_delta_serio_exit);
> -- 
> 1.7.3.4
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 5/7] MTD: NAND: ams-delta: use GPIO instead of custom I/O
  2011-12-19 23:08   ` [PATCH v2 5/7] MTD: NAND: ams-delta: use GPIO instead of custom I/O Janusz Krzysztofik
@ 2011-12-21 19:12     ` Tony Lindgren
  2011-12-21 19:45       ` Janusz Krzysztofik
  2011-12-21 20:56     ` Artem Bityutskiy
  1 sibling, 1 reply; 63+ messages in thread
From: Tony Lindgren @ 2011-12-21 19:12 UTC (permalink / raw)
  To: Janusz Krzysztofik, Artem Bityutskiy
  Cc: linux-omap, linux-arm-kernel, linux-kernel, linux-mtd, David Woodhouse

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 14:41]:
> Don't use Amstrad Delta custom I/O functions for controlling the device,
> use GPIO API instead.
> 
> While being at it, add missing gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB).
> 
> Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
> basic_mmio_gpio"
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Tony Lindgren <tony@atomide.com>

Artem, care to ack this one?

Regards,

Tony


> ---
> Changes against initial version:
> * no functional changes,
> * rebased on top of v2 of patch 2/7, just in case.
> 
> Comments copied from initial submission:
> 
> Hi,
> I considered dropping the Amstrad Delta NAND driver and moving to either
> gpio-nand or gen_nand, but finally decided to keep it for now.
> 
> The problem with the gpio-nand is that it seems to match a different
> hardware interface model. Having no knowledge about the original
> hardware that driver was designed in mind, I'd rather not try to
> modify it, and creating another GPIO based NAND driver also seems not
> a really good idea.
> 
> If I decided to use gen_nand instead, I would have to move virtually all
> of the old driver callback functions somewhere under arch, either to the
> board file or to a new one, and still use some hacks unless either
> nand_base.c or plat_nand.c is modified.
> 
> I'm willing to take one of those two approaches in a follow up series if
> I get a positive feedback.
> 
> Thanks,
> Janusz
> 
> 
>  arch/arm/mach-omap1/board-ams-delta.c             |   30 --------
>  arch/arm/plat-omap/include/plat/board-ams-delta.h |    6 --
>  drivers/mtd/nand/ams-delta.c                      |   74 ++++++++++++++------
>  3 files changed, 52 insertions(+), 58 deletions(-)
> 
> diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
> index 034d009..cc6f962 100644
> --- a/arch/arm/mach-omap1/board-ams-delta.c
> +++ b/arch/arm/mach-omap1/board-ams-delta.c
> @@ -237,36 +237,6 @@ static struct gpio latch_gpios[] __initconst = {
>  		.label	= "lcd_ndisp",
>  	},
>  	{
> -		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
> -		.flags	= GPIOF_OUT_INIT_LOW,
> -		.label	= "nand_nce",
> -	},
> -	{
> -		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
> -		.flags	= GPIOF_OUT_INIT_LOW,
> -		.label	= "nand_nre",
> -	},
> -	{
> -		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
> -		.flags	= GPIOF_OUT_INIT_LOW,
> -		.label	= "nand_nwp",
> -	},
> -	{
> -		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
> -		.flags	= GPIOF_OUT_INIT_LOW,
> -		.label	= "nand_nwe",
> -	},
> -	{
> -		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
> -		.flags	= GPIOF_OUT_INIT_LOW,
> -		.label	= "nand_ale",
> -	},
> -	{
> -		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
> -		.flags	= GPIOF_OUT_INIT_LOW,
> -		.label	= "nand_cle",
> -	},
> -	{
>  		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
>  		.flags	= GPIOF_OUT_INIT_LOW,
>  		.label	= "keybrd_pwr",
> diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
> index a0f86ca..3e57833 100644
> --- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
> +++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
> @@ -30,12 +30,6 @@
>  
>  #define AMS_DELTA_LATCH2_LCD_VBLEN	0x0001
>  #define AMS_DELTA_LATCH2_LCD_NDISP	0x0002
> -#define AMS_DELTA_LATCH2_NAND_NCE	0x0004
> -#define AMS_DELTA_LATCH2_NAND_NRE	0x0008
> -#define AMS_DELTA_LATCH2_NAND_NWP	0x0010
> -#define AMS_DELTA_LATCH2_NAND_NWE	0x0020
> -#define AMS_DELTA_LATCH2_NAND_ALE	0x0040
> -#define AMS_DELTA_LATCH2_NAND_CLE	0x0080
>  #define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
>  #define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
>  #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
> diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
> index 9e6b498..5769bd2 100644
> --- a/drivers/mtd/nand/ams-delta.c
> +++ b/drivers/mtd/nand/ams-delta.c
> @@ -26,7 +26,7 @@
>  #include <asm/io.h>
>  #include <mach/hardware.h>
>  #include <asm/sizes.h>
> -#include <asm/gpio.h>
> +#include <linux/gpio.h>
>  #include <plat/board-ams-delta.h>
>  
>  /*
> @@ -34,8 +34,6 @@
>   */
>  static struct mtd_info *ams_delta_mtd = NULL;
>  
> -#define NAND_MASK (AMS_DELTA_LATCH2_NAND_NRE | AMS_DELTA_LATCH2_NAND_NWE | AMS_DELTA_LATCH2_NAND_CLE | AMS_DELTA_LATCH2_NAND_ALE | AMS_DELTA_LATCH2_NAND_NCE | AMS_DELTA_LATCH2_NAND_NWP)
> -
>  /*
>   * Define partitions for flash devices
>   */
> @@ -68,10 +66,9 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
>  
>  	writew(0, io_base + OMAP_MPUIO_IO_CNTL);
>  	writew(byte, this->IO_ADDR_W);
> -	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE, 0);
> +	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 0);
>  	ndelay(40);
> -	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE,
> -			       AMS_DELTA_LATCH2_NAND_NWE);
> +	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 1);
>  }
>  
>  static u_char ams_delta_read_byte(struct mtd_info *mtd)
> @@ -80,12 +77,11 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd)
>  	struct nand_chip *this = mtd->priv;
>  	void __iomem *io_base = this->priv;
>  
> -	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE, 0);
> +	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0);
>  	ndelay(40);
>  	writew(~0, io_base + OMAP_MPUIO_IO_CNTL);
>  	res = readw(this->IO_ADDR_R);
> -	ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE,
> -			       AMS_DELTA_LATCH2_NAND_NRE);
> +	gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 1);
>  
>  	return res;
>  }
> @@ -132,15 +128,12 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd,
>  {
>  
>  	if (ctrl & NAND_CTRL_CHANGE) {
> -		unsigned long bits;
> -
> -		bits = (~ctrl & NAND_NCE) ? AMS_DELTA_LATCH2_NAND_NCE : 0;
> -		bits |= (ctrl & NAND_CLE) ? AMS_DELTA_LATCH2_NAND_CLE : 0;
> -		bits |= (ctrl & NAND_ALE) ? AMS_DELTA_LATCH2_NAND_ALE : 0;
> -
> -		ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_CLE |
> -				AMS_DELTA_LATCH2_NAND_ALE |
> -				AMS_DELTA_LATCH2_NAND_NCE, bits);
> +		gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NCE,
> +				(ctrl & NAND_NCE) == 0);
> +		gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_CLE,
> +				(ctrl & NAND_CLE) != 0);
> +		gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_ALE,
> +				(ctrl & NAND_ALE) != 0);
>  	}
>  
>  	if (cmd != NAND_CMD_NONE)
> @@ -152,6 +145,39 @@ static int ams_delta_nand_ready(struct mtd_info *mtd)
>  	return gpio_get_value(AMS_DELTA_GPIO_PIN_NAND_RB);
>  }
>  
> +static struct gpio _mandatory_gpio[] __initconst_or_module = {
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NCE,
> +		.flags	= GPIOF_OUT_INIT_HIGH,
> +		.label	= "nand_nce",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NRE,
> +		.flags	= GPIOF_OUT_INIT_HIGH,
> +		.label	= "nand_nre",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWP,
> +		.flags	= GPIOF_OUT_INIT_HIGH,
> +		.label	= "nand_nwp",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_NWE,
> +		.flags	= GPIOF_OUT_INIT_HIGH,
> +		.label	= "nand_nwe",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_ALE,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "nand_ale",
> +	},
> +	{
> +		.gpio	= AMS_DELTA_GPIO_PIN_NAND_CLE,
> +		.flags	= GPIOF_OUT_INIT_LOW,
> +		.label	= "nand_cle",
> +	},
> +};
> +
>  /*
>   * Main initialization routine
>   */
> @@ -223,10 +249,9 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, io_base);
>  
>  	/* Set chip enabled, but  */
> -	ams_delta_latch2_write(NAND_MASK, AMS_DELTA_LATCH2_NAND_NRE |
> -					  AMS_DELTA_LATCH2_NAND_NWE |
> -					  AMS_DELTA_LATCH2_NAND_NCE |
> -					  AMS_DELTA_LATCH2_NAND_NWP);
> +	err = gpio_request_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
> +	if (err)
> +		goto out_gpio;
>  
>  	/* Scan to find existence of the device */
>  	if (nand_scan(ams_delta_mtd, 1)) {
> @@ -241,7 +266,10 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
>  	goto out;
>  
>   out_mtd:
> +	gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
> +out_gpio:
>  	platform_set_drvdata(pdev, NULL);
> +	gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
>  	iounmap(io_base);
>  out_release_io:
>  	release_mem_region(res->start, resource_size(res));
> @@ -262,6 +290,8 @@ static int __devexit ams_delta_cleanup(struct platform_device *pdev)
>  	/* Release resources, unregister device */
>  	nand_release(ams_delta_mtd);
>  
> +	gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
> +	gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
>  	iounmap(io_base);
>  	release_mem_region(res->start, resource_size(res));
>  
> -- 
> 1.7.3.4
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 5/7] MTD: NAND: ams-delta: use GPIO instead of custom I/O
  2011-12-21 19:12     ` Tony Lindgren
@ 2011-12-21 19:45       ` Janusz Krzysztofik
  0 siblings, 0 replies; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-21 19:45 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Artem Bityutskiy, linux-omap, linux-arm-kernel, linux-kernel,
	linux-mtd, David Woodhouse

On Wednesday 21 of December 2011 at 20:12:12, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111219 14:41]:
> > Don't use Amstrad Delta custom I/O functions for controlling the device,
> > use GPIO API instead.
> > 
> > While being at it, add missing gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB).
> > 
> > Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
> > basic_mmio_gpio"
> > 
> > Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> > Cc: David Woodhouse <dwmw2@infradead.org>
> > Cc: Tony Lindgren <tony@atomide.com>
> 
> Artem, care to ack this one?


BTW, following the get_maintainer.pl script suggestions, I tried to 
include Artem in the Cc: list, but that script provided me with an 
invalid Artem's email address at nokia.com, and I gave up once my email 
gateway refused to accept that message. Now I've verified that several 
half or more year old commits signed by Artem were the sources of that 
apparently outdated information. Looks like the get_maintainer.pl script 
needs improvement, or should be used with care by people who don't 
follow all email address changes ;).

Thanks,
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7 v2] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-21 19:08       ` Tony Lindgren
@ 2011-12-21 19:51         ` Janusz Krzysztofik
  2011-12-21 20:07           ` Tony Lindgren
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-21 19:51 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Dmitry Torokhov, Jarkko Nikula, Liam Girdwood, Mark Brown,
	Russell King - ARM Linux, linux-omap, linux-arm-kernel,
	linux-kernel, alsa-devel, linux-input

On Wednesday 21 of December 2011 at 20:08:15, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111220 13:23]:
> > In preparation to converting Amstrad Delta on-board latches to
> > basic_mmio_gpio devices, registration of platform devices which depend
> > on latches and will require initialization of their GPIO pins first,
> > should be moved out of .machine_init down to late_initcall level, as the
> > gpio-generic driver is not available until device_initcall time.  The
> > latch reset operation, which will be replaced with GPIO initialization,
> > must also be moved to late_initcall for the same reason.
> > 
> > Since there was already another, separate arch_initcall function for
> > setting up one of those latch dependent devices, the on-board modem
> > device, reuse that function, i.e., rename it to a name that matches the
> > new purpose, extend with other device setup relocated from
> > .machine_init, and move down to the late_initcall level.
> > 
> > While being at it, add missing gpio_free() in case the modem platform
> > device registration fails.
> > 
> > Thanks to Tony Lindgren <tony@atomide.com> who suggested this approach
> > instead of shifting up the gpio-generic driver initialization.
> > 
> > In addition, defer registration of the Amstrad Delta ASoC and serio
> > devices, done from their device driver files, until late_initcall time,
> > as those drivers will depend on their GPIO pins already requested from
> > the board late_init() function until updated to register their GPIO pins
> > themselves.
> > 
> > Created and tested against linux-3.2-rc6.
> > 
> > Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> 
> Planning to apply this series. Dmitry, care to ack the drivers/input/serio/
> related change?

Don't we need Jarkko's or Mark's or Liam's ack as well for the change to 
the sound/soc/omap/ams-delta.c file?

Thanks,
Janusz

> Regards,
> 
> Tony
> 
> > ---
> > Changes since the initial version of this patch:
> > * use late_initcall() unconditionally in modules, requested by Russell
> >   King (thanks!); an updated patch 7/7 will follow,
> > * in the changelog message, move credits to Tony up a bit, since the
> >   person responsible for other changes (he might not necessarily like)
> >   is me, not him ;).
> > 
> > Comments copied from this patch initial submission:
> > This patch was not present in the initial submission, it replaces the
> > old patch 1/10, providing an alternative solution not touching the
> > gpio-generic driver.
> > 
> >  arch/arm/mach-omap1/board-ams-delta.c |   28 ++++++++++++++++++++--------
> >  drivers/input/serio/ams_delta_serio.c |    2 +-
> >  sound/soc/omap/ams-delta.c            |    2 +-
> >  3 files changed, 22 insertions(+), 10 deletions(-)
> > 
> > diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
> > index b0f15d2..50987c9 100644
> > --- a/arch/arm/mach-omap1/board-ams-delta.c
> > +++ b/arch/arm/mach-omap1/board-ams-delta.c
> > @@ -275,11 +275,14 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
> >  };
> >  
> >  static struct platform_device *ams_delta_devices[] __initdata = {
> > -	&ams_delta_nand_device,
> >  	&ams_delta_kp_device,
> > +	&ams_delta_camera_device,
> > +};
> > +
> > +static struct platform_device *late_devices[] __initdata = {
> > +	&ams_delta_nand_device,
> >  	&ams_delta_lcd_device,
> >  	&ams_delta_led_device,
> > -	&ams_delta_camera_device,
> >  };
> >  
> >  static void __init ams_delta_init(void)
> > @@ -307,9 +310,6 @@ static void __init ams_delta_init(void)
> >  	omap_serial_init();
> >  	omap_register_i2c_bus(1, 100, NULL, 0);
> >  
> > -	/* Clear latch2 (NAND, LCD, modem enable) */
> > -	ams_delta_latch2_write(~0, 0);
> > -
> >  	omap1_usb_init(&ams_delta_usb_config);
> >  	omap1_set_camera_info(&ams_delta_camera_platform_data);
> >  #ifdef CONFIG_LEDS_TRIGGERS
> > @@ -345,13 +345,18 @@ static struct platform_device ams_delta_modem_device = {
> >  	},
> >  };
> >  
> > -static int __init ams_delta_modem_init(void)
> > +static int __init late_init(void)
> >  {
> >  	int err;
> >  
> >  	if (!machine_is_ams_delta())
> >  		return -ENODEV;
> >  
> > +	/* Clear latch2 (NAND, LCD, modem enable) */
> > +	ams_delta_latch2_write(~0, 0);
> > +
> > +	platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
> > +
> >  	omap_cfg_reg(M14_1510_GPIO2);
> >  	ams_delta_modem_ports[0].irq =
> >  			gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> > @@ -367,9 +372,16 @@ static int __init ams_delta_modem_init(void)
> >  		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
> >  		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
> >  
> > -	return platform_device_register(&ams_delta_modem_device);
> > +	err = platform_device_register(&ams_delta_modem_device);
> > +	if (err)
> > +		goto gpio_free;
> > +	return 0;
> > +
> > +gpio_free:
> > +	gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> > +	return err;
> >  }
> > -arch_initcall(ams_delta_modem_init);
> > +late_initcall(late_init);
> >  
> >  static void __init ams_delta_map_io(void)
> >  {
> > diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
> > index d4d08bd..835d37a 100644
> > --- a/drivers/input/serio/ams_delta_serio.c
> > +++ b/drivers/input/serio/ams_delta_serio.c
> > @@ -165,7 +165,7 @@ serio:
> >  	kfree(ams_delta_serio);
> >  	return err;
> >  }
> > -module_init(ams_delta_serio_init);
> > +late_initcall(ams_delta_serio_init);
> >  
> >  static void __exit ams_delta_serio_exit(void)
> >  {
> > diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
> > index ccb8a6a..be81bc7 100644
> > --- a/sound/soc/omap/ams-delta.c
> > +++ b/sound/soc/omap/ams-delta.c
> > @@ -636,7 +636,7 @@ err:
> >  	platform_device_put(ams_delta_audio_platform_device);
> >  	return ret;
> >  }
> > -module_init(ams_delta_module_init);
> > +late_initcall(ams_delta_module_init);
> >  
> >  static void __exit ams_delta_module_exit(void)
> >  {
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH] input: serio: ams-delta: toggle keyboard power over GPIO
  2011-12-21 19:09       ` Tony Lindgren
@ 2011-12-21 19:55         ` Janusz Krzysztofik
  2011-12-22 17:45           ` Dmitry Torokhov
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-21 19:55 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Dmitry Torokhov, Russell King - ARM Linux, linux-omap,
	linux-arm-kernel, linux-kernel, linux-input

On Wednesday 21 of December 2011 at 20:09:45, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111220 13:39]:
> > Don't use Amstrad Delta custom I/O functions once GPIO interface is
> > available for the underlying hardware.
> > 
> > While requesting and initializing GPIO pins used, also take care of one
> > extra pin KEYBRD_DATAOUT which, even if not used by the driver, belongs
> > to the device and affects its functioning.
> > 
> > Once done, move the driver initialization back to the device_initcall
> > level, reverting the temporary chane introduced with patch 1/7 "ARM:
> > OMAP1: ams-delta: register latch dependent devices later".  That change
> > is no longer required once the driver takes care of registering used
> > GPIO pins, and it's better to initialize the device before others using
> > the latch2 based GPIO pins, otherwise a garbage is reported on boot,
> > perhaps due to random data already captured by the FIQ handler while the
> > keyboard related latch bits are written with random values during
> > initialization of those other latch2 dependent devices.
> > 
> > Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
> > basic_mmio_gpio"
> > 
> > Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> 
> I'm assuming Dmitry's ack for an earlier version of this patch also
> covers this one when applying.

Hi Dmitry,
Can we assume your ack still valid for this version?

Thanks,
Janusz

> Regards,
> 
> Tony
> 
> > ---
> > Hi,
> > I'm submitting only this one refreshed on top of updated 1/7. All others
> > (2/7-6/7) don't require any refresh, can be rebased smoothly.
> > 
> > Thanks,
> > Janusz
> > 
> > 
> > Changes against version 2:
> > * refreshed on top of updated patch 1/7 v2,
> > * changelog: corrected patch 1/7 summary (was inaccurate).
> > 
> > Changes against initial version:
> > * was 9/10,
> > * rebased on top of v2 of patch 2/7, just in case,
> > * moved AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT pin handling from the board
> >   code to the driver,
> > * reverted a temporary change to the driver initcall level, introduced
> >   by the new solution provided with patch 1/7.
> > 
> > 
> >  arch/arm/mach-omap1/board-ams-delta.c             |   10 ----
> >  arch/arm/plat-omap/include/plat/board-ams-delta.h |    2 -
> >  drivers/input/serio/ams_delta_serio.c             |   53 ++++++++++++--------
> > :x 3 files changed, 32 insertions(+), 33 deletions(-)
> > 
> > diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
> > index 3aba8f9..673cf21 100644
> > --- a/arch/arm/mach-omap1/board-ams-delta.c
> > +++ b/arch/arm/mach-omap1/board-ams-delta.c
> > @@ -227,16 +227,6 @@ static struct gpio latch_gpios[] __initconst = {
> >  		.label	= "dockit2",
> >  	},
> >  	{
> > -		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
> > -		.flags	= GPIOF_OUT_INIT_LOW,
> > -		.label	= "keybrd_pwr",
> > -	},
> > -	{
> > -		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
> > -		.flags	= GPIOF_OUT_INIT_LOW,
> > -		.label	= "keybrd_dataout",
> > -	},
> > -	{
> >  		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
> >  		.flags	= GPIOF_OUT_INIT_LOW,
> >  		.label	= "scard_rstin",
> > diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
> > index e9ad673..027e79e 100644
> > --- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
> > +++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
> > @@ -28,8 +28,6 @@
> >  
> >  #if defined (CONFIG_MACH_AMS_DELTA)
> >  
> > -#define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
> > -#define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
> >  #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
> >  #define AMD_DELTA_LATCH2_SCARD_CMDVCC	0x0800
> >  #define AMS_DELTA_LATCH2_MODEM_NRESET	0x1000
> > diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
> > index 835d37a..ef1ec40 100644
> > --- a/drivers/input/serio/ams_delta_serio.c
> > +++ b/drivers/input/serio/ams_delta_serio.c
> > @@ -92,8 +92,7 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
> >  static int ams_delta_serio_open(struct serio *serio)
> >  {
> >  	/* enable keyboard */
> > -	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR,
> > -			AMD_DELTA_LATCH2_KEYBRD_PWR);
> > +	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1);
> >  
> >  	return 0;
> >  }
> > @@ -101,9 +100,32 @@ static int ams_delta_serio_open(struct serio *serio)
> >  static void ams_delta_serio_close(struct serio *serio)
> >  {
> >  	/* disable keyboard */
> > -	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 0);
> > +	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0);
> >  }
> >  
> > +static struct gpio _gpios[] __initconst_or_module = {
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
> > +		.flags	= GPIOF_DIR_IN,
> > +		.label	= "serio-data",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
> > +		.flags	= GPIOF_DIR_IN,
> > +		.label	= "serio-clock",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "serio-power",
> > +	},
> > +	{
> > +		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
> > +		.flags	= GPIOF_OUT_INIT_LOW,
> > +		.label	= "serio-dataout",
> > +	},
> > +};
> > +
> >  static int __init ams_delta_serio_init(void)
> >  {
> >  	int err;
> > @@ -123,19 +145,11 @@ static int __init ams_delta_serio_init(void)
> >  	strlcpy(ams_delta_serio->phys, "GPIO/serio0",
> >  			sizeof(ams_delta_serio->phys));
> >  
> > -	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_DATA, "serio-data");
> > +	err = gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
> >  	if (err) {
> > -		pr_err("ams_delta_serio: Couldn't request gpio pin for data\n");
> > +		pr_err("ams_delta_serio: Couldn't request gpio pins\n");
> >  		goto serio;
> >  	}
> > -	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> > -
> > -	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_CLK, "serio-clock");
> > -	if (err) {
> > -		pr_err("ams_delta_serio: couldn't request gpio pin for clock\n");
> > -		goto gpio_data;
> > -	}
> > -	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
> >  
> >  	err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
> >  			ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING,
> > @@ -143,7 +157,7 @@ static int __init ams_delta_serio_init(void)
> >  	if (err < 0) {
> >  		pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n",
> >  				gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK));
> > -		goto gpio_clk;
> > +		goto gpio;
> >  	}
> >  	/*
> >  	 * Since GPIO register handling for keyboard clock pin is performed
> > @@ -157,21 +171,18 @@ static int __init ams_delta_serio_init(void)
> >  	dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name);
> >  
> >  	return 0;
> > -gpio_clk:
> > -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
> > -gpio_data:
> > -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> > +gpio:
> > +	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
> >  serio:
> >  	kfree(ams_delta_serio);
> >  	return err;
> >  }
> > -late_initcall(ams_delta_serio_init);
> > +module_init(ams_delta_serio_init);
> >  
> >  static void __exit ams_delta_serio_exit(void)
> >  {
> >  	serio_unregister_port(ams_delta_serio);
> >  	free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
> > -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
> > -	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
> > +	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
> >  }
> >  module_exit(ams_delta_serio_exit);
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7 v2] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-21 19:51         ` Janusz Krzysztofik
@ 2011-12-21 20:07           ` Tony Lindgren
  2011-12-22 10:39             ` Janusz Krzysztofik
  0 siblings, 1 reply; 63+ messages in thread
From: Tony Lindgren @ 2011-12-21 20:07 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Dmitry Torokhov, Jarkko Nikula, Liam Girdwood, Mark Brown,
	Russell King - ARM Linux, linux-omap, linux-arm-kernel,
	linux-kernel, alsa-devel, linux-input

* Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111221 11:20]:
> On Wednesday 21 of December 2011 at 20:08:15, Tony Lindgren wrote:
> > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111220 13:23]:
> > > In preparation to converting Amstrad Delta on-board latches to
> > > basic_mmio_gpio devices, registration of platform devices which depend
> > > on latches and will require initialization of their GPIO pins first,
> > > should be moved out of .machine_init down to late_initcall level, as the
> > > gpio-generic driver is not available until device_initcall time.  The
> > > latch reset operation, which will be replaced with GPIO initialization,
> > > must also be moved to late_initcall for the same reason.
> > > 
> > > Since there was already another, separate arch_initcall function for
> > > setting up one of those latch dependent devices, the on-board modem
> > > device, reuse that function, i.e., rename it to a name that matches the
> > > new purpose, extend with other device setup relocated from
> > > .machine_init, and move down to the late_initcall level.
> > > 
> > > While being at it, add missing gpio_free() in case the modem platform
> > > device registration fails.
> > > 
> > > Thanks to Tony Lindgren <tony@atomide.com> who suggested this approach
> > > instead of shifting up the gpio-generic driver initialization.
> > > 
> > > In addition, defer registration of the Amstrad Delta ASoC and serio
> > > devices, done from their device driver files, until late_initcall time,
> > > as those drivers will depend on their GPIO pins already requested from
> > > the board late_init() function until updated to register their GPIO pins
> > > themselves.
> > > 
> > > Created and tested against linux-3.2-rc6.
> > > 
> > > Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> > 
> > Planning to apply this series. Dmitry, care to ack the drivers/input/serio/
> > related change?
> 
> Don't we need Jarkko's or Mark's or Liam's ack as well for the change to 
> the sound/soc/omap/ams-delta.c file?

Yes, you're right.

Tony

> > > Changes since the initial version of this patch:
> > > * use late_initcall() unconditionally in modules, requested by Russell
> > >   King (thanks!); an updated patch 7/7 will follow,
> > > * in the changelog message, move credits to Tony up a bit, since the
> > >   person responsible for other changes (he might not necessarily like)
> > >   is me, not him ;).
> > > 
> > > Comments copied from this patch initial submission:
> > > This patch was not present in the initial submission, it replaces the
> > > old patch 1/10, providing an alternative solution not touching the
> > > gpio-generic driver.
> > > 
> > >  arch/arm/mach-omap1/board-ams-delta.c |   28 ++++++++++++++++++++--------
> > >  drivers/input/serio/ams_delta_serio.c |    2 +-
> > >  sound/soc/omap/ams-delta.c            |    2 +-
> > >  3 files changed, 22 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
> > > index b0f15d2..50987c9 100644
> > > --- a/arch/arm/mach-omap1/board-ams-delta.c
> > > +++ b/arch/arm/mach-omap1/board-ams-delta.c
> > > @@ -275,11 +275,14 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
> > >  };
> > >  
> > >  static struct platform_device *ams_delta_devices[] __initdata = {
> > > -	&ams_delta_nand_device,
> > >  	&ams_delta_kp_device,
> > > +	&ams_delta_camera_device,
> > > +};
> > > +
> > > +static struct platform_device *late_devices[] __initdata = {
> > > +	&ams_delta_nand_device,
> > >  	&ams_delta_lcd_device,
> > >  	&ams_delta_led_device,
> > > -	&ams_delta_camera_device,
> > >  };
> > >  
> > >  static void __init ams_delta_init(void)
> > > @@ -307,9 +310,6 @@ static void __init ams_delta_init(void)
> > >  	omap_serial_init();
> > >  	omap_register_i2c_bus(1, 100, NULL, 0);
> > >  
> > > -	/* Clear latch2 (NAND, LCD, modem enable) */
> > > -	ams_delta_latch2_write(~0, 0);
> > > -
> > >  	omap1_usb_init(&ams_delta_usb_config);
> > >  	omap1_set_camera_info(&ams_delta_camera_platform_data);
> > >  #ifdef CONFIG_LEDS_TRIGGERS
> > > @@ -345,13 +345,18 @@ static struct platform_device ams_delta_modem_device = {
> > >  	},
> > >  };
> > >  
> > > -static int __init ams_delta_modem_init(void)
> > > +static int __init late_init(void)
> > >  {
> > >  	int err;
> > >  
> > >  	if (!machine_is_ams_delta())
> > >  		return -ENODEV;
> > >  
> > > +	/* Clear latch2 (NAND, LCD, modem enable) */
> > > +	ams_delta_latch2_write(~0, 0);
> > > +
> > > +	platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
> > > +
> > >  	omap_cfg_reg(M14_1510_GPIO2);
> > >  	ams_delta_modem_ports[0].irq =
> > >  			gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> > > @@ -367,9 +372,16 @@ static int __init ams_delta_modem_init(void)
> > >  		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
> > >  		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
> > >  
> > > -	return platform_device_register(&ams_delta_modem_device);
> > > +	err = platform_device_register(&ams_delta_modem_device);
> > > +	if (err)
> > > +		goto gpio_free;
> > > +	return 0;
> > > +
> > > +gpio_free:
> > > +	gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> > > +	return err;
> > >  }
> > > -arch_initcall(ams_delta_modem_init);
> > > +late_initcall(late_init);
> > >  
> > >  static void __init ams_delta_map_io(void)
> > >  {
> > > diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
> > > index d4d08bd..835d37a 100644
> > > --- a/drivers/input/serio/ams_delta_serio.c
> > > +++ b/drivers/input/serio/ams_delta_serio.c
> > > @@ -165,7 +165,7 @@ serio:
> > >  	kfree(ams_delta_serio);
> > >  	return err;
> > >  }
> > > -module_init(ams_delta_serio_init);
> > > +late_initcall(ams_delta_serio_init);
> > >  
> > >  static void __exit ams_delta_serio_exit(void)
> > >  {
> > > diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
> > > index ccb8a6a..be81bc7 100644
> > > --- a/sound/soc/omap/ams-delta.c
> > > +++ b/sound/soc/omap/ams-delta.c
> > > @@ -636,7 +636,7 @@ err:
> > >  	platform_device_put(ams_delta_audio_platform_device);
> > >  	return ret;
> > >  }
> > > -module_init(ams_delta_module_init);
> > > +late_initcall(ams_delta_module_init);
> > >  
> > >  static void __exit ams_delta_module_exit(void)
> > >  {
> > 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 5/7] MTD: NAND: ams-delta: use GPIO instead of custom I/O
  2011-12-19 23:08   ` [PATCH v2 5/7] MTD: NAND: ams-delta: use GPIO instead of custom I/O Janusz Krzysztofik
  2011-12-21 19:12     ` Tony Lindgren
@ 2011-12-21 20:56     ` Artem Bityutskiy
  1 sibling, 0 replies; 63+ messages in thread
From: Artem Bityutskiy @ 2011-12-21 20:56 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, linux-omap, linux-arm-kernel, linux-kernel,
	linux-mtd, David Woodhouse

On Tue, 2011-12-20 at 00:08 +0100, Janusz Krzysztofik wrote:
> Don't use Amstrad Delta custom I/O functions for controlling the device,
> use GPIO API instead.
> 
> While being at it, add missing gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB).
> 
> Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
> basic_mmio_gpio"
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Tony Lindgren <tony@atomide.com>

Looks good, thanks!

Reviewed-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API
  2011-12-21 18:33   ` Liam Girdwood
@ 2011-12-21 22:14     ` Janusz Krzysztofik
  2011-12-22  9:25       ` Girdwood, Liam
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-21 22:14 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: Tony Lindgren, Jarkko Nikula, linux-omap, linux-arm-kernel,
	linux-kernel, alsa-devel, Mark Brown

On Wednesday 21 of December 2011 at 19:33:44, Liam Girdwood wrote:
> On Sun, 2011-12-11 at 21:12 +0100, Janusz Krzysztofik wrote:
> > Don't use Amstrad Delta custom I/O functions any longer, replace them
> > with GPIO. Old pin definitions, no longer used by the modem bits either,
> > can be dropped.
> > 
> > Depends on patch 2/10 "ARM: OMAP1: Convert Amstrad E3 latches to
> > basic_mmio_gpio".
> > 
> > Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> 
> Applied.

Hi,
I'm sorry, but I've probably missed to infrom you explicitly, i.e. other 
than in a cover letter to v2 of this series, that this particular patch 
has been dropped from the series. I've already started working on an 
alternative solution, which I intend to submit as a separate set. It 
will be free of potentail problems with two devices, a modem and the 
sound card, accessing the same GPIO pins concurrently. For the 
MODEM_NRESET pin I've already set up a virtual regulator on top of it, 
and for the MODEM_CODEC pin I'll probably choose a virtual clock (pinmux 
would match the hardware more closely here, but it looks too complicated 
to me). Moreover, I've already started to move all those GPIO pin 
related functions, i.e. bias control, digital mute and line discipline 
interaction, from the board file to the codec driver, where all those 
seem to belong.

Having this patch applied will conflict with the regultor and the clock 
solutions, taking control over those two GPIO pins. Please revert this 
patch, or reset it if still possible.

Thanks,
Janusz

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API
  2011-12-21 22:14     ` Janusz Krzysztofik
@ 2011-12-22  9:25       ` Girdwood, Liam
  0 siblings, 0 replies; 63+ messages in thread
From: Girdwood, Liam @ 2011-12-22  9:25 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, Jarkko Nikula, linux-omap, linux-arm-kernel,
	linux-kernel, alsa-devel, Mark Brown

On 21 December 2011 22:14, Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> wrote:
> On Wednesday 21 of December 2011 at 19:33:44, Liam Girdwood wrote:
>> On Sun, 2011-12-11 at 21:12 +0100, Janusz Krzysztofik wrote:
>> > Don't use Amstrad Delta custom I/O functions any longer, replace them
>> > with GPIO. Old pin definitions, no longer used by the modem bits either,
>> > can be dropped.
>> >
>> > Depends on patch 2/10 "ARM: OMAP1: Convert Amstrad E3 latches to
>> > basic_mmio_gpio".
>> >
>> > Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
>>
>> Applied.
>
> Hi,
> I'm sorry, but I've probably missed to infrom you explicitly, i.e. other
> than in a cover letter to v2 of this series, that this particular patch
> has been dropped from the series. I've already started working on an
> alternative solution, which I intend to submit as a separate set. It
> will be free of potentail problems with two devices, a modem and the
> sound card, accessing the same GPIO pins concurrently. For the
> MODEM_NRESET pin I've already set up a virtual regulator on top of it,
> and for the MODEM_CODEC pin I'll probably choose a virtual clock (pinmux
> would match the hardware more closely here, but it looks too complicated
> to me). Moreover, I've already started to move all those GPIO pin
> related functions, i.e. bias control, digital mute and line discipline
> interaction, from the board file to the codec driver, where all those
> seem to belong.
>
> Having this patch applied will conflict with the regultor and the clock
> solutions, taking control over those two GPIO pins. Please revert this
> patch, or reset it if still possible.
>
> Thanks,
> Janusz

Will do, I never pushed last night as it was late. So I'll only will
have to make a local change.

Thanks

Liam

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7 v2] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-21 20:07           ` Tony Lindgren
@ 2011-12-22 10:39             ` Janusz Krzysztofik
  2011-12-22 11:08               ` Jarkko Nikula
  0 siblings, 1 reply; 63+ messages in thread
From: Janusz Krzysztofik @ 2011-12-22 10:39 UTC (permalink / raw)
  To: Jarkko Nikula, Liam Girdwood, Mark Brown
  Cc: Tony Lindgren, Dmitry Torokhov, Russell King - ARM Linux,
	linux-omap, linux-arm-kernel, linux-kernel, alsa-devel,
	linux-input

On Wednesday 21 of December 2011 at 21:07:29, Tony Lindgren wrote:
> * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111221 11:20]:
> > On Wednesday 21 of December 2011 at 20:08:15, Tony Lindgren wrote:
> > > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111220 13:23]:
> > > > In preparation to converting Amstrad Delta on-board latches to
> > > > basic_mmio_gpio devices, registration of platform devices which depend
> > > > on latches and will require initialization of their GPIO pins first,
> > > > should be moved out of .machine_init down to late_initcall level, as the
> > > > gpio-generic driver is not available until device_initcall time.  The
> > > > latch reset operation, which will be replaced with GPIO initialization,
> > > > must also be moved to late_initcall for the same reason.
> > > > 
> > > > Since there was already another, separate arch_initcall function for
> > > > setting up one of those latch dependent devices, the on-board modem
> > > > device, reuse that function, i.e., rename it to a name that matches the
> > > > new purpose, extend with other device setup relocated from
> > > > .machine_init, and move down to the late_initcall level.
> > > > 
> > > > While being at it, add missing gpio_free() in case the modem platform
> > > > device registration fails.
> > > > 
> > > > Thanks to Tony Lindgren <tony@atomide.com> who suggested this approach
> > > > instead of shifting up the gpio-generic driver initialization.
> > > > 
> > > > In addition, defer registration of the Amstrad Delta ASoC and serio
> > > > devices, done from their device driver files, until late_initcall time,
> > > > as those drivers will depend on their GPIO pins already requested from
> > > > the board late_init() function until updated to register their GPIO pins
> > > > themselves.
> > > > 
> > > > Created and tested against linux-3.2-rc6.
> > > > 
> > > > Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> > > 
> > > Planning to apply this series. Dmitry, care to ack the drivers/input/serio/
> > > related change?
> > 
> > Don't we need Jarkko's or Mark's or Liam's ack as well for the change to 
> > the sound/soc/omap/ams-delta.c file?
> 
> Yes, you're right.

Jarkko, Mark or Liam, care to ack this change, moving the Amstrad Delta 
sound card registration to late_initcall?

Thanks,
Janusz

> > > > Changes since the initial version of this patch:
> > > > * use late_initcall() unconditionally in modules, requested by Russell
> > > >   King (thanks!); an updated patch 7/7 will follow,
> > > > * in the changelog message, move credits to Tony up a bit, since the
> > > >   person responsible for other changes (he might not necessarily like)
> > > >   is me, not him ;).
> > > > 
> > > > Comments copied from this patch initial submission:
> > > > This patch was not present in the initial submission, it replaces the
> > > > old patch 1/10, providing an alternative solution not touching the
> > > > gpio-generic driver.
> > > > 
> > > >  arch/arm/mach-omap1/board-ams-delta.c |   28 ++++++++++++++++++++--------
> > > >  drivers/input/serio/ams_delta_serio.c |    2 +-
> > > >  sound/soc/omap/ams-delta.c            |    2 +-
> > > >  3 files changed, 22 insertions(+), 10 deletions(-)
> > > > 
> > > > diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
> > > > index b0f15d2..50987c9 100644
> > > > --- a/arch/arm/mach-omap1/board-ams-delta.c
> > > > +++ b/arch/arm/mach-omap1/board-ams-delta.c
> > > > @@ -275,11 +275,14 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
> > > >  };
> > > >  
> > > >  static struct platform_device *ams_delta_devices[] __initdata = {
> > > > -	&ams_delta_nand_device,
> > > >  	&ams_delta_kp_device,
> > > > +	&ams_delta_camera_device,
> > > > +};
> > > > +
> > > > +static struct platform_device *late_devices[] __initdata = {
> > > > +	&ams_delta_nand_device,
> > > >  	&ams_delta_lcd_device,
> > > >  	&ams_delta_led_device,
> > > > -	&ams_delta_camera_device,
> > > >  };
> > > >  
> > > >  static void __init ams_delta_init(void)
> > > > @@ -307,9 +310,6 @@ static void __init ams_delta_init(void)
> > > >  	omap_serial_init();
> > > >  	omap_register_i2c_bus(1, 100, NULL, 0);
> > > >  
> > > > -	/* Clear latch2 (NAND, LCD, modem enable) */
> > > > -	ams_delta_latch2_write(~0, 0);
> > > > -
> > > >  	omap1_usb_init(&ams_delta_usb_config);
> > > >  	omap1_set_camera_info(&ams_delta_camera_platform_data);
> > > >  #ifdef CONFIG_LEDS_TRIGGERS
> > > > @@ -345,13 +345,18 @@ static struct platform_device ams_delta_modem_device = {
> > > >  	},
> > > >  };
> > > >  
> > > > -static int __init ams_delta_modem_init(void)
> > > > +static int __init late_init(void)
> > > >  {
> > > >  	int err;
> > > >  
> > > >  	if (!machine_is_ams_delta())
> > > >  		return -ENODEV;
> > > >  
> > > > +	/* Clear latch2 (NAND, LCD, modem enable) */
> > > > +	ams_delta_latch2_write(~0, 0);
> > > > +
> > > > +	platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
> > > > +
> > > >  	omap_cfg_reg(M14_1510_GPIO2);
> > > >  	ams_delta_modem_ports[0].irq =
> > > >  			gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> > > > @@ -367,9 +372,16 @@ static int __init ams_delta_modem_init(void)
> > > >  		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC,
> > > >  		AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC);
> > > >  
> > > > -	return platform_device_register(&ams_delta_modem_device);
> > > > +	err = platform_device_register(&ams_delta_modem_device);
> > > > +	if (err)
> > > > +		goto gpio_free;
> > > > +	return 0;
> > > > +
> > > > +gpio_free:
> > > > +	gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
> > > > +	return err;
> > > >  }
> > > > -arch_initcall(ams_delta_modem_init);
> > > > +late_initcall(late_init);
> > > >  
> > > >  static void __init ams_delta_map_io(void)
> > > >  {
> > > > diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
> > > > index d4d08bd..835d37a 100644
> > > > --- a/drivers/input/serio/ams_delta_serio.c
> > > > +++ b/drivers/input/serio/ams_delta_serio.c
> > > > @@ -165,7 +165,7 @@ serio:
> > > >  	kfree(ams_delta_serio);
> > > >  	return err;
> > > >  }
> > > > -module_init(ams_delta_serio_init);
> > > > +late_initcall(ams_delta_serio_init);
> > > >  
> > > >  static void __exit ams_delta_serio_exit(void)
> > > >  {
> > > > diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
> > > > index ccb8a6a..be81bc7 100644
> > > > --- a/sound/soc/omap/ams-delta.c
> > > > +++ b/sound/soc/omap/ams-delta.c
> > > > @@ -636,7 +636,7 @@ err:
> > > >  	platform_device_put(ams_delta_audio_platform_device);
> > > >  	return ret;
> > > >  }
> > > > -module_init(ams_delta_module_init);
> > > > +late_initcall(ams_delta_module_init);
> > > >  
> > > >  static void __exit ams_delta_module_exit(void)
> > > >  {
> > > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7 v2] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-22 10:39             ` Janusz Krzysztofik
@ 2011-12-22 11:08               ` Jarkko Nikula
  2011-12-22 11:10                 ` Mark Brown
  0 siblings, 1 reply; 63+ messages in thread
From: Jarkko Nikula @ 2011-12-22 11:08 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Liam Girdwood, Mark Brown, Tony Lindgren, Dmitry Torokhov,
	Russell King - ARM Linux, linux-omap, linux-arm-kernel,
	linux-kernel, alsa-devel, linux-input

On 12/22/2011 12:39 PM, Janusz Krzysztofik wrote:

>>> Don't we need Jarkko's or Mark's or Liam's ack as well for the change to
>>> the sound/soc/omap/ams-delta.c file?
>>
>> Yes, you're right.
>
> Jarkko, Mark or Liam, care to ack this change, moving the Amstrad Delta
> sound card registration to late_initcall?
>
Unfortunately I haven't had time to look at the series but I'm fine with 
sound/soc/omap/ams-delta.c change.

-- 
Jarkko

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH v2 1/7 v2] ARM: OMAP1: ams-delta: register latch dependent devices later
  2011-12-22 11:08               ` Jarkko Nikula
@ 2011-12-22 11:10                 ` Mark Brown
  0 siblings, 0 replies; 63+ messages in thread
From: Mark Brown @ 2011-12-22 11:10 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: Janusz Krzysztofik, Liam Girdwood, Tony Lindgren,
	Dmitry Torokhov, Russell King - ARM Linux, linux-omap,
	linux-arm-kernel, linux-kernel, alsa-devel, linux-input

On Thu, Dec 22, 2011 at 01:08:12PM +0200, Jarkko Nikula wrote:
> On 12/22/2011 12:39 PM, Janusz Krzysztofik wrote:

Guys *please* delete irrelevant context from mails.  I wasn't reading
any of the rest of it since nothing about the subject line says anything
about anything relevant and there was no content anywhere near the start
of the actual mails.  I only saw this because Jarkko did trim the
context.

> >Jarkko, Mark or Liam, care to ack this change, moving the Amstrad Delta
> >sound card registration to late_initcall?

> Unfortunately I haven't had time to look at the series but I'm fine
> with sound/soc/omap/ams-delta.c change.

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH] input: serio: ams-delta: toggle keyboard power over GPIO
  2011-12-21 19:55         ` Janusz Krzysztofik
@ 2011-12-22 17:45           ` Dmitry Torokhov
  2011-12-22 18:06             ` Tony Lindgren
  0 siblings, 1 reply; 63+ messages in thread
From: Dmitry Torokhov @ 2011-12-22 17:45 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Tony Lindgren, Russell King - ARM Linux, linux-omap,
	linux-arm-kernel, linux-kernel, linux-input

On Wed, Dec 21, 2011 at 08:55:09PM +0100, Janusz Krzysztofik wrote:
> On Wednesday 21 of December 2011 at 20:09:45, Tony Lindgren wrote:
> > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111220 13:39]:
> > > Don't use Amstrad Delta custom I/O functions once GPIO interface is
> > > available for the underlying hardware.
> > > 
> > > While requesting and initializing GPIO pins used, also take care of one
> > > extra pin KEYBRD_DATAOUT which, even if not used by the driver, belongs
> > > to the device and affects its functioning.
> > > 
> > > Once done, move the driver initialization back to the device_initcall
> > > level, reverting the temporary chane introduced with patch 1/7 "ARM:
> > > OMAP1: ams-delta: register latch dependent devices later".  That change
> > > is no longer required once the driver takes care of registering used
> > > GPIO pins, and it's better to initialize the device before others using
> > > the latch2 based GPIO pins, otherwise a garbage is reported on boot,
> > > perhaps due to random data already captured by the FIQ handler while the
> > > keyboard related latch bits are written with random values during
> > > initialization of those other latch2 dependent devices.
> > > 
> > > Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
> > > basic_mmio_gpio"
> > > 
> > > Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> > 
> > I'm assuming Dmitry's ack for an earlier version of this patch also
> > covers this one when applying.
> 
> Hi Dmitry,
> Can we assume your ack still valid for this version?
> 

Yes, please merge with your other changes.

BTW, if you could rename :static struct gpio _gpios" to "ams_delta_gpios"
that would be even better.

Thanks!

-- 
Dmitry

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH] input: serio: ams-delta: toggle keyboard power over GPIO
  2011-12-22 17:45           ` Dmitry Torokhov
@ 2011-12-22 18:06             ` Tony Lindgren
  0 siblings, 0 replies; 63+ messages in thread
From: Tony Lindgren @ 2011-12-22 18:06 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Janusz Krzysztofik, Russell King - ARM Linux, linux-omap,
	linux-arm-kernel, linux-kernel, linux-input

* Dmitry Torokhov <dmitry.torokhov@gmail.com> [111222 09:13]:
> On Wed, Dec 21, 2011 at 08:55:09PM +0100, Janusz Krzysztofik wrote:
> > On Wednesday 21 of December 2011 at 20:09:45, Tony Lindgren wrote:
> > > * Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> [111220 13:39]:
> > > > Don't use Amstrad Delta custom I/O functions once GPIO interface is
> > > > available for the underlying hardware.
> > > > 
> > > > While requesting and initializing GPIO pins used, also take care of one
> > > > extra pin KEYBRD_DATAOUT which, even if not used by the driver, belongs
> > > > to the device and affects its functioning.
> > > > 
> > > > Once done, move the driver initialization back to the device_initcall
> > > > level, reverting the temporary chane introduced with patch 1/7 "ARM:
> > > > OMAP1: ams-delta: register latch dependent devices later".  That change
> > > > is no longer required once the driver takes care of registering used
> > > > GPIO pins, and it's better to initialize the device before others using
> > > > the latch2 based GPIO pins, otherwise a garbage is reported on boot,
> > > > perhaps due to random data already captured by the FIQ handler while the
> > > > keyboard related latch bits are written with random values during
> > > > initialization of those other latch2 dependent devices.
> > > > 
> > > > Depends on patch 2/7 "ARM: OMAP1: ams-delta: convert latches to
> > > > basic_mmio_gpio"
> > > > 
> > > > Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> > > 
> > > I'm assuming Dmitry's ack for an earlier version of this patch also
> > > covers this one when applying.
> > 
> > Hi Dmitry,
> > Can we assume your ack still valid for this version?
> > 
> 
> Yes, please merge with your other changes.

OK thanks.
 
> BTW, if you could rename :static struct gpio _gpios" to "ams_delta_gpios"
> that would be even better.

Done, pushing into omap1-part2 branch with the updated patch below.

Regards,

Tony


From: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Date: Tue, 20 Dec 2011 23:10:34 +0100
Subject: [PATCH] input: serio: ams-delta: toggle keyboard power over GPIO

Don't use Amstrad Delta custom I/O functions once GPIO interface is
available for the underlying hardware.

While requesting and initializing GPIO pins used, also take care of one
extra pin KEYBRD_DATAOUT which, even if not used by the driver, belongs
to the device and affects its functioning.

Once done, move the driver initialization back to the device_initcall
level, reverting the temporary chane introduced with patch 1/7 "ARM:
OMAP1: ams-delta: register latch dependent devices later".  That change
is no longer required once the driver takes care of registering used
GPIO pins, and it's better to initialize the device before others using
the latch2 based GPIO pins, otherwise a garbage is reported on boot,
perhaps due to random data already captured by the FIQ handler while the
keyboard related latch bits are written with random values during
initialization of those other latch2 dependent devices.

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
[tony@atomide.com: renamed _gpios to ams_delta_gpios]
Signed-off-by: Tony Lindgren <tony@atomide.com>

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 3aba8f9..673cf21 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -227,16 +227,6 @@ static struct gpio latch_gpios[] __initconst = {
 		.label	= "dockit2",
 	},
 	{
-		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "keybrd_pwr",
-	},
-	{
-		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
-		.flags	= GPIOF_OUT_INIT_LOW,
-		.label	= "keybrd_dataout",
-	},
-	{
 		.gpio	= AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
 		.flags	= GPIOF_OUT_INIT_LOW,
 		.label	= "scard_rstin",
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index e9ad673..027e79e 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,8 +28,6 @@
 
 #if defined (CONFIG_MACH_AMS_DELTA)
 
-#define AMD_DELTA_LATCH2_KEYBRD_PWR	0x0100
-#define AMD_DELTA_LATCH2_KEYBRD_DATA	0x0200
 #define AMD_DELTA_LATCH2_SCARD_RSTIN	0x0400
 #define AMD_DELTA_LATCH2_SCARD_CMDVCC	0x0800
 #define AMS_DELTA_LATCH2_MODEM_NRESET	0x1000
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index 835d37a..0571e2e 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -92,8 +92,7 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
 static int ams_delta_serio_open(struct serio *serio)
 {
 	/* enable keyboard */
-	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR,
-			AMD_DELTA_LATCH2_KEYBRD_PWR);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1);
 
 	return 0;
 }
@@ -101,9 +100,32 @@ static int ams_delta_serio_open(struct serio *serio)
 static void ams_delta_serio_close(struct serio *serio)
 {
 	/* disable keyboard */
-	ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 0);
+	gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0);
 }
 
+static struct gpio ams_delta_gpios[] __initconst_or_module = {
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
+		.flags	= GPIOF_DIR_IN,
+		.label	= "serio-data",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
+		.flags	= GPIOF_DIR_IN,
+		.label	= "serio-clock",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "serio-power",
+	},
+	{
+		.gpio	= AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
+		.flags	= GPIOF_OUT_INIT_LOW,
+		.label	= "serio-dataout",
+	},
+};
+
 static int __init ams_delta_serio_init(void)
 {
 	int err;
@@ -123,19 +145,12 @@ static int __init ams_delta_serio_init(void)
 	strlcpy(ams_delta_serio->phys, "GPIO/serio0",
 			sizeof(ams_delta_serio->phys));
 
-	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_DATA, "serio-data");
+	err = gpio_request_array(ams_delta_gpios,
+				ARRAY_SIZE(ams_delta_gpios));
 	if (err) {
-		pr_err("ams_delta_serio: Couldn't request gpio pin for data\n");
+		pr_err("ams_delta_serio: Couldn't request gpio pins\n");
 		goto serio;
 	}
-	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
-
-	err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_CLK, "serio-clock");
-	if (err) {
-		pr_err("ams_delta_serio: couldn't request gpio pin for clock\n");
-		goto gpio_data;
-	}
-	gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
 
 	err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
 			ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING,
@@ -143,7 +158,7 @@ static int __init ams_delta_serio_init(void)
 	if (err < 0) {
 		pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n",
 				gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK));
-		goto gpio_clk;
+		goto gpio;
 	}
 	/*
 	 * Since GPIO register handling for keyboard clock pin is performed
@@ -157,21 +172,20 @@ static int __init ams_delta_serio_init(void)
 	dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name);
 
 	return 0;
-gpio_clk:
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
-gpio_data:
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
+gpio:
+	gpio_free_array(ams_delta_gpios,
+			ARRAY_SIZE(ams_delta_gpios));
 serio:
 	kfree(ams_delta_serio);
 	return err;
 }
-late_initcall(ams_delta_serio_init);
+module_init(ams_delta_serio_init);
 
 static void __exit ams_delta_serio_exit(void)
 {
 	serio_unregister_port(ams_delta_serio);
 	free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
-	gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
+	gpio_free_array(ams_delta_gpios,
+			ARRAY_SIZE(ams_delta_gpios));
 }
 module_exit(ams_delta_serio_exit);

^ permalink raw reply related	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2011-12-22 18:06 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-11 20:11 [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Janusz Krzysztofik
2011-12-11 20:11 ` [PATCH 01/10] GPIO: gpio-generic: Move initialization up to postcore Janusz Krzysztofik
2011-12-12 18:04   ` Tony Lindgren
2011-12-12 23:05     ` Janusz Krzysztofik
2011-12-12 23:15       ` Tony Lindgren
2011-12-12 23:44         ` Janusz Krzysztofik
2011-12-12 23:55           ` Tony Lindgren
2011-12-13  0:15             ` Janusz Krzysztofik
2011-12-14 13:10             ` Janusz Krzysztofik
2011-12-14 18:21               ` Tony Lindgren
2011-12-14 20:07                 ` Janusz Krzysztofik
2011-12-14 22:10                   ` Tony Lindgren
2011-12-14 11:13   ` Janusz Krzysztofik
2011-12-11 20:12 ` [PATCH 02/10] ARM: OMAP1: ams-delta: Convert latches to basic_mmio_gpio Janusz Krzysztofik
2011-12-11 20:12 ` [PATCH 03/10] ARM: OMAP1: ams-delta: Supersede custom led device by leds-gpio Janusz Krzysztofik
2011-12-11 20:12 ` [PATCH 04/10] LED: Drop leds-ams-delta driver Janusz Krzysztofik
2011-12-11 20:12 ` [PATCH 05/10] MTD: NAND: ams-delta: Use GPIO instead of custom I/O Janusz Krzysztofik
2011-12-11 20:12 ` [PATCH 06/10] ARM: OMAP1: ams-delta: Use GPIO API in modem setup Janusz Krzysztofik
2011-12-11 20:12 ` [PATCH 07/10] ASoC: OMAP: ams-delta: Drive modem/codec pins over GPIO API Janusz Krzysztofik
2011-12-12  4:29   ` Mark Brown
2011-12-21 18:33   ` Liam Girdwood
2011-12-21 22:14     ` Janusz Krzysztofik
2011-12-22  9:25       ` Girdwood, Liam
2011-12-11 20:12 ` [PATCH 08/10] omapfb: lcd_ams_delta: Drive control lines over GPIO Janusz Krzysztofik
2011-12-12 11:24   ` Tomi Valkeinen
2011-12-11 20:12 ` [PATCH 09/10] input: serio: ams-delta: Toggle keyboard power " Janusz Krzysztofik
2011-12-12  8:18   ` Dmitry Torokhov
2011-12-11 20:12 ` [PATCH 10/10] ARM: OMAP1: ams-delta: Drop custom I/O functions Janusz Krzysztofik
2011-12-12  5:00 ` [PATCH 00/10] ARM: OMAP1: ams-delta: replace custom I/O with GPIO Jonathan McDowell
2011-12-19 23:08 ` [PATCH v2 0/7] " Janusz Krzysztofik
2011-12-19 23:08   ` [PATCH v2 2/7] ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio Janusz Krzysztofik
2011-12-20  0:06     ` Tony Lindgren
2011-12-20  0:59       ` Janusz Krzysztofik
2011-12-20  1:04         ` Tony Lindgren
2011-12-20  1:18           ` Janusz Krzysztofik
2011-12-20  2:13             ` Tony Lindgren
2011-12-20  2:24           ` [PATCH v2 2/7 v2] " Janusz Krzysztofik
2011-12-19 23:08   ` [PATCH v2 3/7] ARM: OMAP1: ams-delta: supersede custom led device by leds-gpio Janusz Krzysztofik
2011-12-19 23:08   ` [PATCH v2 4/7] LED: drop leds-ams-delta driver Janusz Krzysztofik
2011-12-19 23:08   ` [PATCH v2 5/7] MTD: NAND: ams-delta: use GPIO instead of custom I/O Janusz Krzysztofik
2011-12-21 19:12     ` Tony Lindgren
2011-12-21 19:45       ` Janusz Krzysztofik
2011-12-21 20:56     ` Artem Bityutskiy
2011-12-19 23:08   ` [PATCH v2 6/7] omapfb: lcd_ams_delta: drive control lines over GPIO Janusz Krzysztofik
2011-12-19 23:08   ` [PATCH v2 7/7] input: serio: ams-delta: toggle keyboard power " Janusz Krzysztofik
2011-12-20 22:10     ` [PATCH] " Janusz Krzysztofik
2011-12-21 19:09       ` Tony Lindgren
2011-12-21 19:55         ` Janusz Krzysztofik
2011-12-22 17:45           ` Dmitry Torokhov
2011-12-22 18:06             ` Tony Lindgren
     [not found] ` <83e934adfc691b347534edb7788a67ab2e6bd7e1.1324331816.git.jkrzyszt@tis.icnet.pl>
2011-12-19 23:28   ` [PATCH v2 1/7][RESEND] ARM: OMAP1: ams-delta: register latch dependent devices later Janusz Krzysztofik
2011-12-20 18:06     ` Tony Lindgren
2011-12-20 20:34       ` Janusz Krzysztofik
2011-12-20 20:57         ` Tony Lindgren
2011-12-20 20:40     ` Russell King - ARM Linux
2011-12-20 20:51       ` [alsa-devel] " Janusz Krzysztofik
2011-12-20 21:54     ` [PATCH v2 1/7 v2] " Janusz Krzysztofik
2011-12-21 19:08       ` Tony Lindgren
2011-12-21 19:51         ` Janusz Krzysztofik
2011-12-21 20:07           ` Tony Lindgren
2011-12-22 10:39             ` Janusz Krzysztofik
2011-12-22 11:08               ` Jarkko Nikula
2011-12-22 11:10                 ` Mark Brown

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).