Skip to contentSkip to conversation

omap: rx51: Platform support for lp5523 led chip

PATCH Superseded Ameya Palande 5 participants 14 messages Mar 31, 2011 – May 31, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 omap: rx51: Platform support for lp5523 led chip

---
 arch/arm/mach-omap2/board-rx51-peripherals.c |   81 ++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-rx51-peripherals.c +81 -0
index bbcb677..488916d 100644
@@ -38,6 +38,7 @@
 #include <sound/tpa6130a2-plat.h>
 #include <media/radio-si4713.h>
 #include <media/si4713.h>
+#include <linux/leds-lp5523.h>
 
 #include <../drivers/staging/iio/light/tsl2563.h>
 
@@ -51,6 +52,7 @@
 #define RX51_WL1251_IRQ_GPIO		42
 #define RX51_FMTX_RESET_GPIO		163
 #define RX51_FMTX_IRQ			53
+#define RX51_LP5523_CHIP_EN_GPIO	41
 
 /* list all spi devices here */
 enum {
@@ -67,6 +69,79 @@ static struct tsl2563_platform_data rx51_tsl2563_platform_data = {
 };
 #endif
 
+#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
+static struct lp5523_led_config rx51_lp5523_led_config[] = {
+	{
+		.chan_nr	= 0,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 1,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 2,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 3,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 4,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 5,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 6,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 7,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 8,
+		.led_current	= 50,
+	}
+};
+
+static int rx51_lp5523_setup(void)
+{
+	int err;
+
+	err = gpio_request(RX51_LP5523_CHIP_EN_GPIO, "lp5523_enable");
+	if (err < 0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	err = gpio_direction_output(RX51_LP5523_CHIP_EN_GPIO, 1);
+	if (err < 0) {
+		pr_err("Failed to change direction for %d GPIO\n",
+				RX51_LP5523_CHIP_EN_GPIO);
+	}
+	return err;
+}
+
+static void rx51_lp5523_release(void)
+{
+	gpio_free(RX51_LP5523_CHIP_EN_GPIO);
+}
+
+static void rx51_lp5523_enable(bool state)
+{
+	if (state)
+		gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, 1);
+	else
+		gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, 0);
+}
+
+static struct lp5523_platform_data rx51_lp5523_platform_data = {
+	.led_config		= rx51_lp5523_led_config,
+	.num_channels		= ARRAY_SIZE(rx51_lp5523_led_config),
+	.clock_mode		= LP5523_CLOCK_AUTO,
+	.setup_resources	= rx51_lp5523_setup,
+	.release_resources 	= rx51_lp5523_release,
+	.enable			= rx51_lp5523_enable,
+};
+#endif
+
 static struct omap2_mcspi_device_config wl1251_mcspi_config = {
 	.turbo_mode	= 0,
 	.single_channel	= 1,
@@ -816,6 +891,12 @@ static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
 		.platform_data = &rx51_tsl2563_platform_data,
 	},
 #endif
+#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
+	{
+		I2C_BOARD_INFO("lp5523", 0x32),
+		.platform_data  = &rx51_lp5523_platform_data,
+	},
+#endif
 	{
 		I2C_BOARD_INFO("tpa6130a2", 0x60),
 		.platform_data = &rx51_tpa6130a2_data,
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 omap: rx51: Platform support for lp5523 led chip

Hi,

Quoted 5 lines · Ameya Palande
arch/arm/mach-omap2/board-rx51-peripherals.c +5 -0
+static int rx51_lp5523_setup(void)
+{
+	int err;
+
+	err = gpio_request(RX51_LP5523_CHIP_EN_GPIO, "lp5523_enable");

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 118

Quoted 10 lines
arch/arm/mach-omap2/board-rx51-peripherals.c +10 -0
+	if (err < 0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	err = gpio_direction_output(RX51_LP5523_CHIP_EN_GPIO, 1);
+	if (err < 0) {
+		pr_err("Failed to change direction for %d GPIO\n",
+				RX51_LP5523_CHIP_EN_GPIO);
+	}

you can combine these two into

gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,

		"lp5523_enable");
Quoted 4 lines
arch/arm/mach-omap2/board-rx51-peripherals.c +4 -0
+	return err;
+}
+
+static void rx51_lp5523_release(void)

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 132

Quoted 10 lines
arch/arm/mach-omap2/board-rx51-peripherals.c +10 -0
+{
+	gpio_free(RX51_LP5523_CHIP_EN_GPIO);
+}
+
+static void rx51_lp5523_enable(bool state)
+{
+	if (state)
+		gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, 1);
+	else
+		gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, 0);

how about:

gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, !!state); ??

you drop a useless branch.

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 135

Quoted 3 lines
arch/arm/mach-omap2/board-rx51-peripherals.c +3 -0
+}
+
+static struct lp5523_platform_data rx51_lp5523_platform_data = {

should this be const ??

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 140

Quoted 5 lines
arch/arm/mach-omap2/board-rx51-peripherals.c +5 -0
+	.led_config		= rx51_lp5523_led_config,
+	.num_channels		= ARRAY_SIZE(rx51_lp5523_led_config),
+	.clock_mode		= LP5523_CLOCK_AUTO,
+	.setup_resources	= rx51_lp5523_setup,
+	.release_resources 	= rx51_lp5523_release,

^ trailing whitespace

Signature · 1 line
balbi
#2 lore raw

PATCH 1/1 omap: rx51: Platform support for lp5523 led chip

In reply to Ameya Palande

Hi,

Quoted 4 lines · Ameya Palande
arch/arm/mach-omap2/board-rx51-peripherals.c +4 -0
+static int rx51_lp5523_setup(void)
+{
+	int err;
+

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 117

Quoted 10 lines
arch/arm/mach-omap2/board-rx51-peripherals.c +10 -0
+	err = gpio_request(RX51_LP5523_CHIP_EN_GPIO, "lp5523_enable");
+	if (err < 0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	err = gpio_direction_output(RX51_LP5523_CHIP_EN_GPIO, 1);
+	if (err < 0) {
+		pr_err("Failed to change direction for %d GPIO\n",
+				RX51_LP5523_CHIP_EN_GPIO);

The error branch is missing gpio_free(). You can fix that by replacing these with just a single gpio_request_one() call.

Quoted 52 lines
arch/arm/mach-omap2/board-rx51-peripherals.c +27 -0
+	}
+	return err;
+}
+
+static void rx51_lp5523_release(void)
+{
+	gpio_free(RX51_LP5523_CHIP_EN_GPIO);
+}
+
+static void rx51_lp5523_enable(bool state)
+{
+	if (state)
+		gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, 1);
+	else
+		gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, 0);
+}
+
+static struct lp5523_platform_data rx51_lp5523_platform_data = {
+	.led_config		= rx51_lp5523_led_config,
+	.num_channels		= ARRAY_SIZE(rx51_lp5523_led_config),
+	.clock_mode		= LP5523_CLOCK_AUTO,
+	.setup_resources	= rx51_lp5523_setup,
+	.release_resources 	= rx51_lp5523_release,
+	.enable			= rx51_lp5523_enable,
+};
+#endif
+
static struct omap2_mcspi_device_config wl1251_mcspi_config = {
	.turbo_mode	= 0,
	.single_channel	= 1,
arch/arm/mach-omap2/board-rx51-peripherals.c +6 -0
@@ -816,6 +891,12 @@ static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
 		.platform_data = &rx51_tsl2563_platform_data,
 	},
 #endif
+#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
+	{
+		I2C_BOARD_INFO("lp5523", 0x32),
+		.platform_data  = &rx51_lp5523_platform_data,
+	},
+#endif
 	{
 		I2C_BOARD_INFO("tpa6130a2", 0x60),
 		.platform_data = &rx51_tpa6130a2_data,
Signature · 7 lines
1.7.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#3 lore raw

PATCH v2 1/1 omap: rx51: Platform support for lp5523 led chip

---
 arch/arm/mach-omap2/board-rx51-peripherals.c |   74 ++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-rx51-peripherals.c +74 -0
index bbcb677..ed289d1 100644
@@ -38,6 +38,7 @@
 #include <sound/tpa6130a2-plat.h>
 #include <media/radio-si4713.h>
 #include <media/si4713.h>
+#include <linux/leds-lp5523.h>
 
 #include <../drivers/staging/iio/light/tsl2563.h>
 
@@ -51,6 +52,7 @@
 #define RX51_WL1251_IRQ_GPIO		42
 #define RX51_FMTX_RESET_GPIO		163
 #define RX51_FMTX_IRQ			53
+#define RX51_LP5523_CHIP_EN_GPIO	41
 
 /* list all spi devices here */
 enum {
@@ -67,6 +69,72 @@ static struct tsl2563_platform_data rx51_tsl2563_platform_data = {
 };
 #endif
 
+#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
+static struct lp5523_led_config rx51_lp5523_led_config[] = {
+	{
+		.chan_nr	= 0,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 1,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 2,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 3,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 4,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 5,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 6,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 7,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 8,
+		.led_current	= 50,
+	}
+};
+
+static int rx51_lp5523_setup(void)
+{
+	int err;
+
+	err = gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
+			"lp5523_enable");
+	if (err < 0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	return err;
+}
+
+static void rx51_lp5523_release(void)
+{
+	gpio_free(RX51_LP5523_CHIP_EN_GPIO);
+}
+
+static void rx51_lp5523_enable(bool state)
+{
+	gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, !!state);
+}
+
+static struct lp5523_platform_data rx51_lp5523_platform_data = {
+	.led_config		= rx51_lp5523_led_config,
+	.num_channels		= ARRAY_SIZE(rx51_lp5523_led_config),
+	.clock_mode		= LP5523_CLOCK_AUTO,
+	.setup_resources	= rx51_lp5523_setup,
+	.release_resources	= rx51_lp5523_release,
+	.enable			= rx51_lp5523_enable,
+};
+#endif
+
 static struct omap2_mcspi_device_config wl1251_mcspi_config = {
 	.turbo_mode	= 0,
 	.single_channel	= 1,
@@ -816,6 +884,12 @@ static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
 		.platform_data = &rx51_tsl2563_platform_data,
 	},
 #endif
+#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
+	{
+		I2C_BOARD_INFO("lp5523", 0x32),
+		.platform_data  = &rx51_lp5523_platform_data,
+	},
+#endif
 	{
 		I2C_BOARD_INFO("tpa6130a2", 0x60),
 		.platform_data = &rx51_tpa6130a2_data,
Signature · 1 line
1.7.1
#4 lore raw

PATCH v2 1/1 omap: rx51: Platform support for lp5523 led chip

Quoted 6 lines · On Thu, 31 Mar 2011 16:38:12 +0300 Ameya Palande <[email protected]>…
---
 arch/arm/mach-omap2/board-rx51-peripherals.c |   74 ++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)

Nice keyboard and rgb led blinking:

while true; do ls /sys/class/leds/lp5523\:channel?/brightness |xargs -I {} bash -c 'echo $((RANDOM % 255)) > {}'; done

#5 lore raw

PATCH v2 1/1 omap: rx51: Platform support for lp5523 led chip

In reply to Ameya Palande

Hi,

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 115

Quoted 12 lines · Ameya Palande
arch/arm/mach-omap2/board-rx51-peripherals.c +12 -0
+static int rx51_lp5523_setup(void)
+{
+	int err;
+
+	err = gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
+			"lp5523_enable");
+	if (err < 0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	return err;

isn't enough to return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT, "lp5523_enable"); ??

Signature · 1 line
balbi
#6 lore raw

PATCH v2 1/1 omap: rx51: Platform support for lp5523 led chip

Hi Felipe,

Quoted 18 lines · ext Felipe Balbi

Hi,

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 115

Quoted 12 lines · Ameya Palande
arch/arm/mach-omap2/board-rx51-peripherals.c +12 -0
+static int rx51_lp5523_setup(void)
+{
+	int err;
+
+	err = gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
+			"lp5523_enable");
+	if (err<  0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	return err;

isn't enough to return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT, "lp5523_enable"); ??

But then we won't know the failure reason for lp5523_probe() I would prefer printing an error!

Cheers,
Ameya.

#7 lore raw

PATCH v2 1/1 omap: rx51: Platform support for lp5523 led chip

Quoted 22 lines · Ameya Palande

Hi Felipe,

Quoted 18 lines · ext Felipe Balbi

Hi,

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 115

Quoted 12 lines · Ameya Palande
arch/arm/mach-omap2/board-rx51-peripherals.c +12 -0
+static int rx51_lp5523_setup(void)
+{
+	int err;
+
+	err = gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
+			"lp5523_enable");
+	if (err<  0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	return err;

isn't enough to return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT, "lp5523_enable"); ??

Quoted 2 lines

But then we won't know the failure reason for lp5523_probe() I would prefer printing an error!

see that both gpio_request() and gpio_direction_output() have debugging prints for error cases ;-)

Signature · 1 line
balbi
#8 lore raw

PATCH v2 1/1 omap: rx51: Platform support for lp5523 led chip

Hi Felipe,

Quoted 23 lines · ext Felipe Balbi
Quoted 22 lines · Ameya Palande

Hi Felipe,

Quoted 18 lines · ext Felipe Balbi

Hi,

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 115

Quoted 12 lines · Ameya Palande
arch/arm/mach-omap2/board-rx51-peripherals.c +12 -0
+static int rx51_lp5523_setup(void)
+{
+	int err;
+
+	err = gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
+			"lp5523_enable");
+	if (err<   0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	return err;

isn't enough to return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT, "lp5523_enable"); ??

Quoted 5 lines
Quoted 2 lines

But then we won't know the failure reason for lp5523_probe() I would prefer printing an error!

see that both gpio_request() and gpio_direction_output() have debugging prints for error cases ;-)

Agreed :) Thanks for the review!
Will send v3.

Cheers,
Ameya.

#9 lore raw

PATCH v3 1/1 omap: rx51: Platform support for lp5523 led chip

In reply to Felipe Balbi
---
 arch/arm/mach-omap2/board-rx51-peripherals.c |   66 ++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-rx51-peripherals.c +66 -0
index bbcb677..d8ec895 100644
@@ -38,6 +38,7 @@
 #include <sound/tpa6130a2-plat.h>
 #include <media/radio-si4713.h>
 #include <media/si4713.h>
+#include <linux/leds-lp5523.h>
 
 #include <../drivers/staging/iio/light/tsl2563.h>
 
@@ -51,6 +52,7 @@
 #define RX51_WL1251_IRQ_GPIO		42
 #define RX51_FMTX_RESET_GPIO		163
 #define RX51_FMTX_IRQ			53
+#define RX51_LP5523_CHIP_EN_GPIO	41
 
 /* list all spi devices here */
 enum {
@@ -67,6 +69,64 @@ static struct tsl2563_platform_data rx51_tsl2563_platform_data = {
 };
 #endif
 
+#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
+static struct lp5523_led_config rx51_lp5523_led_config[] = {
+	{
+		.chan_nr	= 0,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 1,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 2,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 3,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 4,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 5,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 6,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 7,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 8,
+		.led_current	= 50,
+	}
+};
+
+static int rx51_lp5523_setup(void)
+{
+	return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
+			"lp5523_enable");
+}
+
+static void rx51_lp5523_release(void)
+{
+	gpio_free(RX51_LP5523_CHIP_EN_GPIO);
+}
+
+static void rx51_lp5523_enable(bool state)
+{
+	gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, !!state);
+}
+
+static struct lp5523_platform_data rx51_lp5523_platform_data = {
+	.led_config		= rx51_lp5523_led_config,
+	.num_channels		= ARRAY_SIZE(rx51_lp5523_led_config),
+	.clock_mode		= LP5523_CLOCK_AUTO,
+	.setup_resources	= rx51_lp5523_setup,
+	.release_resources	= rx51_lp5523_release,
+	.enable			= rx51_lp5523_enable,
+};
+#endif
+
 static struct omap2_mcspi_device_config wl1251_mcspi_config = {
 	.turbo_mode	= 0,
 	.single_channel	= 1,
@@ -816,6 +876,12 @@ static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
 		.platform_data = &rx51_tsl2563_platform_data,
 	},
 #endif
+#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
+	{
+		I2C_BOARD_INFO("lp5523", 0x32),
+		.platform_data  = &rx51_lp5523_platform_data,
+	},
+#endif
 	{
 		I2C_BOARD_INFO("tpa6130a2", 0x60),
 		.platform_data = &rx51_tpa6130a2_data,
Signature · 1 line
1.7.1
#10 lore raw

PATCH v3 1/1 omap: rx51: Platform support for lp5523 led chip

Quoted 2 lines · Ameya Palande
Quoted 105 lines
---
 arch/arm/mach-omap2/board-rx51-peripherals.c |   66 ++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-rx51-peripherals.c +66 -0
index bbcb677..d8ec895 100644
@@ -38,6 +38,7 @@
 #include <sound/tpa6130a2-plat.h>
 #include <media/radio-si4713.h>
 #include <media/si4713.h>
+#include <linux/leds-lp5523.h>
 
 #include <../drivers/staging/iio/light/tsl2563.h>
 
@@ -51,6 +52,7 @@
 #define RX51_WL1251_IRQ_GPIO		42
 #define RX51_FMTX_RESET_GPIO		163
 #define RX51_FMTX_IRQ			53
+#define RX51_LP5523_CHIP_EN_GPIO	41
 
 /* list all spi devices here */
 enum {
@@ -67,6 +69,64 @@ static struct tsl2563_platform_data rx51_tsl2563_platform_data = {
 };
 #endif
 
+#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
+static struct lp5523_led_config rx51_lp5523_led_config[] = {
+	{
+		.chan_nr	= 0,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 1,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 2,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 3,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 4,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 5,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 6,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 7,
+		.led_current	= 50,
+	}, {
+		.chan_nr	= 8,
+		.led_current	= 50,
+	}
+};
+
+static int rx51_lp5523_setup(void)
+{
+	return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
+			"lp5523_enable");
+}
+
+static void rx51_lp5523_release(void)
+{
+	gpio_free(RX51_LP5523_CHIP_EN_GPIO);
+}
+
+static void rx51_lp5523_enable(bool state)
+{
+	gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, !!state);
+}
+
+static struct lp5523_platform_data rx51_lp5523_platform_data = {
+	.led_config		= rx51_lp5523_led_config,
+	.num_channels		= ARRAY_SIZE(rx51_lp5523_led_config),
+	.clock_mode		= LP5523_CLOCK_AUTO,
+	.setup_resources	= rx51_lp5523_setup,
+	.release_resources	= rx51_lp5523_release,
+	.enable			= rx51_lp5523_enable,
+};
+#endif
+
 static struct omap2_mcspi_device_config wl1251_mcspi_config = {
 	.turbo_mode	= 0,
 	.single_channel	= 1,
@@ -816,6 +876,12 @@ static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
 		.platform_data = &rx51_tsl2563_platform_data,
 	},
 #endif
+#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
+	{
+		I2C_BOARD_INFO("lp5523", 0x32),
+		.platform_data  = &rx51_lp5523_platform_data,
+	},
+#endif
 	{
 		I2C_BOARD_INFO("tpa6130a2", 0x60),
 		.platform_data = &rx51_tpa6130a2_data,
Signature · 1 line
1.7.1
Signature · 1 line
balbi
maintainer
#11 lore raw

PATCH v3 1/1 omap: rx51: Platform support for lp5523 led chip

In reply to Ameya Palande

* Ameya Palande <[email protected]> [110401 03:13]:

Applying this into devel-board for a future merge window after we can add new code with "Platform support for lp5523 led chip" as the patch description.

Regards,

Tony

#12 lore raw

PATCH v2 1/1 omap: rx51: Platform support for lp5523 led chip

In reply to Felipe Balbi

Hi Felipe,

Quoted 23 lines · ext Felipe Balbi
Quoted 22 lines · Ameya Palande

Hi Felipe,

Quoted 18 lines · ext Felipe Balbi

Hi,

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 115

Quoted 12 lines · Ameya Palande
arch/arm/mach-omap2/board-rx51-peripherals.c +12 -0
+static int rx51_lp5523_setup(void)
+{
+	int err;
+
+	err = gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
+			"lp5523_enable");
+	if (err<   0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	return err;

isn't enough to return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT, "lp5523_enable"); ??

Quoted 5 lines
Quoted 2 lines

But then we won't know the failure reason for lp5523_probe() I would prefer printing an error!

see that both gpio_request() and gpio_direction_output() have debugging prints for error cases ;-)

Any comments about the version 3 of this patch?

Cheers,
Ameya.

#13 lore raw

PATCH v2 1/1 omap: rx51: Platform support for lp5523 led chip

Quoted 26 lines · Ameya Palande

Hi Felipe,

Quoted 23 lines · ext Felipe Balbi
Quoted 22 lines · Ameya Palande

Hi Felipe,

Quoted 18 lines · ext Felipe Balbi

Hi,

arch/arm/mach-omap2/board-rx51-peripherals.c static struct tsl2563_platform_data rx51_tsl2563_platform_data = { · line 115

Quoted 12 lines · Ameya Palande
arch/arm/mach-omap2/board-rx51-peripherals.c +12 -0
+static int rx51_lp5523_setup(void)
+{
+	int err;
+
+	err = gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
+			"lp5523_enable");
+	if (err<   0) {
+		pr_err("Unable to get lp5523_enable GPIO\n");
+		return err;
+	}
+
+	return err;

isn't enough to return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT, "lp5523_enable"); ??

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

But then we won't know the failure reason for lp5523_probe() I would prefer printing an error!

see that both gpio_request() and gpio_direction_output() have debugging prints for error cases ;-)

Any comments about the version 3 of this patch?

looks good to me. Replied with my Reviewed-by tag.

Signature · 1 line
balbi