All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [RFC PATCH] TWL4030: make LEDs selectable in twl4030_led_init()
@ 2009-11-30 22:53 Grazvydas Ignotas
  2009-12-01 14:24 ` Tom
  0 siblings, 1 reply; 3+ messages in thread
From: Grazvydas Ignotas @ 2009-11-30 22:53 UTC (permalink / raw)
  To: u-boot

Not all boards have both LEDs hooked, so enabling both on
boards with single LED will just waste power.

Make it possible to choose LEDs by adding arguments to
twl4030_led_init().

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
---
 board/logicpd/zoom1/zoom1.c         |    2 +-
 board/logicpd/zoom2/zoom2.c         |    2 +-
 board/overo/overo.c                 |    2 +-
 board/pandora/pandora.c             |    2 +-
 board/ti/beagle/beagle.c            |    2 +-
 board/timll/devkit8000/devkit8000.c |    2 +-
 drivers/misc/twl4030_led.c          |   11 +++++++----
 include/twl4030.h                   |    2 +-
 8 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/board/logicpd/zoom1/zoom1.c b/board/logicpd/zoom1/zoom1.c
index f4d3754..093b1bf 100644
--- a/board/logicpd/zoom1/zoom1.c
+++ b/board/logicpd/zoom1/zoom1.c
@@ -62,7 +62,7 @@ int board_init(void)
 int misc_init_r(void)
 {
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(1, 1);
 	dieid_num_r();
 
 	/*
diff --git a/board/logicpd/zoom2/zoom2.c b/board/logicpd/zoom2/zoom2.c
index dadbeb6..c93aeec 100644
--- a/board/logicpd/zoom2/zoom2.c
+++ b/board/logicpd/zoom2/zoom2.c
@@ -148,7 +148,7 @@ int misc_init_r(void)
 {
 	zoom2_identify();
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(1, 1);
 	dieid_num_r();
 
 	/*
diff --git a/board/overo/overo.c b/board/overo/overo.c
index d42dc13..29600b0 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -67,7 +67,7 @@ int board_init(void)
 int misc_init_r(void)
 {
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(1, 1);
 
 #if defined(CONFIG_CMD_NET)
 	setup_net_chip();
diff --git a/board/pandora/pandora.c b/board/pandora/pandora.c
index 460ed12..c8007dc 100644
--- a/board/pandora/pandora.c
+++ b/board/pandora/pandora.c
@@ -66,7 +66,7 @@ int misc_init_r(void)
 	struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
 
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(0, 1);
 
 	/* Configure GPIOs to output */
 	writel(~(GPIO14 | GPIO15 | GPIO16 | GPIO23), &gpio1_base->oe);
diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index 32d501e..87c9b0f 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -107,7 +107,7 @@ int misc_init_r(void)
 	struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
 
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(1, 1);
 
 	/* Configure GPIOs to output */
 	writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
index db7d2e2..7eb7793 100644
--- a/board/timll/devkit8000/devkit8000.c
+++ b/board/timll/devkit8000/devkit8000.c
@@ -76,7 +76,7 @@ int misc_init_r(void)
 
 	twl4030_power_init();
 #ifdef CONFIG_TWL4030_LED
-	twl4030_led_init();
+	twl4030_led_init(1, 1);
 #endif
 
 #ifdef CONFIG_DRIVER_DM9000
diff --git a/drivers/misc/twl4030_led.c b/drivers/misc/twl4030_led.c
index bfdafef..9e945a4 100644
--- a/drivers/misc/twl4030_led.c
+++ b/drivers/misc/twl4030_led.c
@@ -39,12 +39,15 @@
 #define LEDAPWM			(0x1 << 4)
 #define LEDBPWM			(0x1 << 5)
 
-void twl4030_led_init(void)
+void twl4030_led_init(int leda_on, int ledb_on)
 {
-	unsigned char byte;
+	unsigned char byte = 0;
 
-	/* enable LED */
-	byte = LEDBPWM | LEDAPWM | LEDBON | LEDAON;
+	/* enable LEDs */
+	if (leda_on)
+		byte |= LEDAPWM | LEDAON;
+	if (ledb_on)
+		byte |= LEDBPWM | LEDBON;
 
 	twl4030_i2c_write_u8(TWL4030_CHIP_LED, byte,
 			     TWL4030_LED_LEDEN);
diff --git a/include/twl4030.h b/include/twl4030.h
index f260ecb..82b3682 100644
--- a/include/twl4030.h
+++ b/include/twl4030.h
@@ -396,6 +396,6 @@ void twl4030_power_mmc_init(void);
 /*
  * LED
  */
-void twl4030_led_init(void);
+void twl4030_led_init(int leda_on, int ledb_on);
 
 #endif /* TWL4030_H */
-- 
1.6.3.3

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

* [U-Boot] [RFC PATCH] TWL4030: make LEDs selectable in twl4030_led_init()
  2009-11-30 22:53 [U-Boot] [RFC PATCH] TWL4030: make LEDs selectable in twl4030_led_init() Grazvydas Ignotas
@ 2009-12-01 14:24 ` Tom
  2009-12-01 14:49   ` Grazvydas Ignotas
  0 siblings, 1 reply; 3+ messages in thread
From: Tom @ 2009-12-01 14:24 UTC (permalink / raw)
  To: u-boot

Grazvydas Ignotas wrote:
> Not all boards have both LEDs hooked, so enabling both on
> boards with single LED will just waste power.
>

This looks like a pandora specific change.
Please say something like, "For Pandora, only 1 led is required.. "

In some cases, the twl4030 led is the only led for the board.
In this case, it would be good if the twl4030 led was hooked into
the status led functionality.  There is already an interface to
turning led's on and off.

> Make it possible to choose LEDs by adding arguments to
> twl4030_led_init().
> 
> Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
> ---
>  board/logicpd/zoom1/zoom1.c         |    2 +-
>  board/logicpd/zoom2/zoom2.c         |    2 +-
>  board/overo/overo.c                 |    2 +-
>  board/pandora/pandora.c             |    2 +-
>  board/ti/beagle/beagle.c            |    2 +-
>  board/timll/devkit8000/devkit8000.c |    2 +-
>  drivers/misc/twl4030_led.c          |   11 +++++++----
>  include/twl4030.h                   |    2 +-
>  8 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/board/logicpd/zoom1/zoom1.c b/board/logicpd/zoom1/zoom1.c
> index f4d3754..093b1bf 100644
> --- a/board/logicpd/zoom1/zoom1.c
> +++ b/board/logicpd/zoom1/zoom1.c
> @@ -62,7 +62,7 @@ int board_init(void)
>  int misc_init_r(void)
>  {
>  	twl4030_power_init();
> -	twl4030_led_init();
> +	twl4030_led_init(1, 1);

I do not like passing in immediates.

>  	dieid_num_r();
>  
>  	/*
> diff --git a/board/logicpd/zoom2/zoom2.c b/board/logicpd/zoom2/zoom2.c
> index dadbeb6..c93aeec 100644
> --- a/board/logicpd/zoom2/zoom2.c
> +++ b/board/logicpd/zoom2/zoom2.c
> @@ -148,7 +148,7 @@ int misc_init_r(void)
>  {
>  	zoom2_identify();
>  	twl4030_power_init();
> -	twl4030_led_init();
> +	twl4030_led_init(1, 1);
>  	dieid_num_r();
>  
>  	/*
> diff --git a/board/overo/overo.c b/board/overo/overo.c
> index d42dc13..29600b0 100644
> --- a/board/overo/overo.c
> +++ b/board/overo/overo.c
> @@ -67,7 +67,7 @@ int board_init(void)
>  int misc_init_r(void)
>  {
>  	twl4030_power_init();
> -	twl4030_led_init();
> +	twl4030_led_init(1, 1);
>  
>  #if defined(CONFIG_CMD_NET)
>  	setup_net_chip();
> diff --git a/board/pandora/pandora.c b/board/pandora/pandora.c
> index 460ed12..c8007dc 100644
> --- a/board/pandora/pandora.c
> +++ b/board/pandora/pandora.c
> @@ -66,7 +66,7 @@ int misc_init_r(void)
>  	struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
>  
>  	twl4030_power_init();
> -	twl4030_led_init();
> +	twl4030_led_init(0, 1);
>  
>  	/* Configure GPIOs to output */
>  	writel(~(GPIO14 | GPIO15 | GPIO16 | GPIO23), &gpio1_base->oe);
> diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
> index 32d501e..87c9b0f 100644
> --- a/board/ti/beagle/beagle.c
> +++ b/board/ti/beagle/beagle.c
> @@ -107,7 +107,7 @@ int misc_init_r(void)
>  	struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
>  
>  	twl4030_power_init();
> -	twl4030_led_init();
> +	twl4030_led_init(1, 1);
>  
>  	/* Configure GPIOs to output */
>  	writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
> diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
> index db7d2e2..7eb7793 100644
> --- a/board/timll/devkit8000/devkit8000.c
> +++ b/board/timll/devkit8000/devkit8000.c
> @@ -76,7 +76,7 @@ int misc_init_r(void)
>  
>  	twl4030_power_init();
>  #ifdef CONFIG_TWL4030_LED
> -	twl4030_led_init();
> +	twl4030_led_init(1, 1);
>  #endif
>  
>  #ifdef CONFIG_DRIVER_DM9000
> diff --git a/drivers/misc/twl4030_led.c b/drivers/misc/twl4030_led.c
> index bfdafef..9e945a4 100644
> --- a/drivers/misc/twl4030_led.c
> +++ b/drivers/misc/twl4030_led.c
> @@ -39,12 +39,15 @@
>  #define LEDAPWM			(0x1 << 4)
>  #define LEDBPWM			(0x1 << 5)
>  
> -void twl4030_led_init(void)
> +void twl4030_led_init(int leda_on, int ledb_on)
>  {

This must change to passing in a #defin-ed parameters.
This can be something like

void twl4030_led_init(unsigned char ledon)

where ledon can be

at most (LEDAON | LEDBON)

Export LEDAON and LEDBON so the namespace is ok.
Something like TWL4030_LED_LEDEN_LEDAON etc should be added to
twl4030.h

> -	unsigned char byte;
> +	unsigned char byte = 0;
>  
> -	/* enable LED */
> -	byte = LEDBPWM | LEDAPWM | LEDBON | LEDAON;
> +	/* enable LEDs */
> +	if (leda_on)
> +		byte |= LEDAPWM | LEDAON;
> +	if (ledb_on)
> +		byte |= LEDBPWM | LEDBON;
>  
>  	twl4030_i2c_write_u8(TWL4030_CHIP_LED, byte,
>  			     TWL4030_LED_LEDEN);
> diff --git a/include/twl4030.h b/include/twl4030.h
> index f260ecb..82b3682 100644
> --- a/include/twl4030.h
> +++ b/include/twl4030.h
> @@ -396,6 +396,6 @@ void twl4030_power_mmc_init(void);
>  /*
>   * LED
>   */
> -void twl4030_led_init(void);
> +void twl4030_led_init(int leda_on, int ledb_on);
>  
>  #endif /* TWL4030_H */

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

* [U-Boot] [RFC PATCH] TWL4030: make LEDs selectable in twl4030_led_init()
  2009-12-01 14:24 ` Tom
@ 2009-12-01 14:49   ` Grazvydas Ignotas
  0 siblings, 0 replies; 3+ messages in thread
From: Grazvydas Ignotas @ 2009-12-01 14:49 UTC (permalink / raw)
  To: u-boot

On Tue, Dec 1, 2009 at 4:24 PM, Tom <Tom.Rix@windriver.com> wrote:
> Grazvydas Ignotas wrote:
>>
>> Not all boards have both LEDs hooked, so enabling both on
>> boards with single LED will just waste power.
>>
>
> This looks like a pandora specific change.
> Please say something like, "For Pandora, only 1 led is required.. "

ok

> In some cases, the twl4030 led is the only led for the board.
> In this case, it would be good if the twl4030 led was hooked into
> the status led functionality. ?There is already an interface to
> turning led's on and off.

Yes, but that code would have to be duplicated for all such boards (as
LEDs are board specific), and it would make more difficult to add
additional non-TWL4030 controlled LEDs later (for example pandora has
some but doesn't expose them to u-boot).

<snip>

>> --- a/drivers/misc/twl4030_led.c
>> +++ b/drivers/misc/twl4030_led.c
>> @@ -39,12 +39,15 @@
>> ?#define LEDAPWM ? ? ? ? ? ? ? ? ? ? ? ?(0x1 << 4)
>> ?#define LEDBPWM ? ? ? ? ? ? ? ? ? ? ? ?(0x1 << 5)
>> ?-void twl4030_led_init(void)
>> +void twl4030_led_init(int leda_on, int ledb_on)
>> ?{
>
> This must change to passing in a #defin-ed parameters.
> This can be something like
>
> void twl4030_led_init(unsigned char ledon)
>
> where ledon can be
>
> at most (LEDAON | LEDBON)
>
> Export LEDAON and LEDBON so the namespace is ok.
> Something like TWL4030_LED_LEDEN_LEDAON etc should be added to
> twl4030.h

ok, will do this then.

>
>> - ? ? ? unsigned char byte;
>> + ? ? ? unsigned char byte = 0;
>> ?- ? ? ? /* enable LED */
>> - ? ? ? byte = LEDBPWM | LEDAPWM | LEDBON | LEDAON;
>> + ? ? ? /* enable LEDs */
>> + ? ? ? if (leda_on)
>> + ? ? ? ? ? ? ? byte |= LEDAPWM | LEDAON;
>> + ? ? ? if (ledb_on)
>> + ? ? ? ? ? ? ? byte |= LEDBPWM | LEDBON;
>> ? ? ? ? ?twl4030_i2c_write_u8(TWL4030_CHIP_LED, byte,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? TWL4030_LED_LEDEN);
>> diff --git a/include/twl4030.h b/include/twl4030.h
>> index f260ecb..82b3682 100644
>> --- a/include/twl4030.h
>> +++ b/include/twl4030.h
>> @@ -396,6 +396,6 @@ void twl4030_power_mmc_init(void);
>> ?/*
>> ?* LED
>> ?*/
>> -void twl4030_led_init(void);
>> +void twl4030_led_init(int leda_on, int ledb_on);
>> ??#endif /* TWL4030_H */
>
>

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

end of thread, other threads:[~2009-12-01 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-30 22:53 [U-Boot] [RFC PATCH] TWL4030: make LEDs selectable in twl4030_led_init() Grazvydas Ignotas
2009-12-01 14:24 ` Tom
2009-12-01 14:49   ` Grazvydas Ignotas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.