Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH -mm][MIPS] GPIO LED driver for the WGT634U machine
@ 2007-08-15 11:25 Aurelien Jarno
  2007-08-15 15:39 ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: Aurelien Jarno @ 2007-08-15 11:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mips

The patch below adds GPIO support to the BCM947xx platform. It uses
the new gpio-led driver and a platform driver for the pin definitions.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

--- a/arch/mips/bcm947xx/Makefile
+++ b/arch/mips/bcm947xx/Makefile
@@ -3,4 +3,4 @@
 # under Linux.
 #

-obj-y := irq.o prom.o serial.o setup.o time.o
+obj-y := irq.o prom.o serial.o setup.o time.o wgt634u.o
--- a/arch/mips/bcm947xx/wgt634u.c
+++ b/arch/mips/bcm947xx/wgt634u.c
@@ -0,0 +1,64 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
+ */
+
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/leds.h>
+#include <linux/ssb/ssb.h>
+#include <asm/mach-bcm947xx/bcm947xx.h>
+
+/* GPIO definitions for the WGT634U */
+#define WGT634U_GPIO_LED	3
+#define WGT634U_GPIO_RESET	2
+#define WGT634U_GPIO_TP1	7
+#define WGT634U_GPIO_TP2	6
+#define WGT634U_GPIO_TP3	5
+#define WGT634U_GPIO_TP4	4
+#define WGT634U_GPIO_TP5	1
+
+static const struct gpio_led wgt634u_leds[] = {
+	{
+		.name = "power",
+		.gpio = WGT634U_GPIO_LED,
+		.active_low = 1,
+		.default_trigger = "heartbeat",
+	},
+};
+
+static const struct gpio_led_platform_data wgt634u_led_data = {
+	.num_leds =     ARRAY_SIZE(wgt634u_leds),
+	.leds =         (void *) wgt634u_leds,
+};
+
+static struct platform_device wgt634u_gpio_leds = {
+	.name =         "leds-gpio",
+	.id =           -1,
+	.dev = {
+		.platform_data = (void *) &wgt634u_led_data,
+	}
+};
+
+static int __init wgt634u_init(void)
+{
+	/* There is no easy way to detect that we are running on a WGT634U
+	 * machine. Use the MAC address as an heuristic. Netgear Inc. has
+	 * been allocated ranges 00:09:5b:xx:xx:xx and 00:0f:b5:xx:xx:xx.
+	 */
+
+	u8 *et0mac = ssb_bcm947xx.sprom.r1.et0mac;
+
+	if (et0mac[0] == 0x00 &&
+	    ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
+	     (et0mac[1] == 0x0f && et0mac[2] == 0xb5)))
+		return platform_device_register(&wgt634u_gpio_leds);
+	else
+		return -ENODEV;
+}
+
+module_init(wgt634u_init);
+

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

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

* Re: [PATCH -mm][MIPS] GPIO LED driver for the WGT634U machine
  2007-08-15 11:25 [PATCH -mm][MIPS] GPIO LED driver for the WGT634U machine Aurelien Jarno
@ 2007-08-15 15:39 ` Geert Uytterhoeven
  2007-08-15 16:00   ` Geert Uytterhoeven
  2007-08-15 18:41   ` Aurelien Jarno
  0 siblings, 2 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2007-08-15 15:39 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: Andrew Morton, linux-mips

On Wed, 15 Aug 2007, Aurelien Jarno wrote:
> --- a/arch/mips/bcm947xx/wgt634u.c
> +++ b/arch/mips/bcm947xx/wgt634u.c

> +static const struct gpio_led wgt634u_leds[] = {

> +static const struct gpio_led_platform_data wgt634u_led_data = {
> +	.num_leds =     ARRAY_SIZE(wgt634u_leds),
> +	.leds =         (void *) wgt634u_leds,
                        ^^^^^^^^

gpio_led_platform_data.leds is of type struct gpio_led *.
Should it be const, or should the const be dropped from wgt634u_leds?

> +static struct platform_device wgt634u_gpio_leds = {
> +	.name =         "leds-gpio",
> +	.id =           -1,
> +	.dev = {
> +		.platform_data = (void *) &wgt634u_led_data,
                                 ^^^^^^^^
device.platform_data is a void *, so you can drop the cast.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* Re: [PATCH -mm][MIPS] GPIO LED driver for the WGT634U machine
  2007-08-15 15:39 ` Geert Uytterhoeven
@ 2007-08-15 16:00   ` Geert Uytterhoeven
  2007-08-15 18:41   ` Aurelien Jarno
  1 sibling, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2007-08-15 16:00 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: Andrew Morton, linux-mips

On Wed, 15 Aug 2007, Geert Uytterhoeven wrote:
> On Wed, 15 Aug 2007, Aurelien Jarno wrote:
> > --- a/arch/mips/bcm947xx/wgt634u.c
> > +++ b/arch/mips/bcm947xx/wgt634u.c
> 
> > +static const struct gpio_led wgt634u_leds[] = {
> 
> > +static const struct gpio_led_platform_data wgt634u_led_data = {
> > +	.num_leds =     ARRAY_SIZE(wgt634u_leds),
> > +	.leds =         (void *) wgt634u_leds,
>                         ^^^^^^^^
> 
> gpio_led_platform_data.leds is of type struct gpio_led *.
> Should it be const, or should the const be dropped from wgt634u_leds?
> 
> > +static struct platform_device wgt634u_gpio_leds = {
> > +	.name =         "leds-gpio",
> > +	.id =           -1,
> > +	.dev = {
> > +		.platform_data = (void *) &wgt634u_led_data,
>                                  ^^^^^^^^
> device.platform_data is a void *, so you can drop the cast.

Hmm, wgt634u_led_data is const too. But casting away constness is
usually an indicator that something is wrong.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* Re: [PATCH -mm][MIPS] GPIO LED driver for the WGT634U machine
  2007-08-15 15:39 ` Geert Uytterhoeven
  2007-08-15 16:00   ` Geert Uytterhoeven
@ 2007-08-15 18:41   ` Aurelien Jarno
  1 sibling, 0 replies; 4+ messages in thread
From: Aurelien Jarno @ 2007-08-15 18:41 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Andrew Morton, linux-mips

On Wed, Aug 15, 2007 at 05:39:31PM +0200, Geert Uytterhoeven wrote:
> On Wed, 15 Aug 2007, Aurelien Jarno wrote:
> > --- a/arch/mips/bcm947xx/wgt634u.c
> > +++ b/arch/mips/bcm947xx/wgt634u.c
> 
> > +static const struct gpio_led wgt634u_leds[] = {
> 
> > +static const struct gpio_led_platform_data wgt634u_led_data = {
> > +	.num_leds =     ARRAY_SIZE(wgt634u_leds),
> > +	.leds =         (void *) wgt634u_leds,
>                         ^^^^^^^^
> 
> gpio_led_platform_data.leds is of type struct gpio_led *.
> Should it be const, or should the const be dropped from wgt634u_leds?
> 
> > +static struct platform_device wgt634u_gpio_leds = {
> > +	.name =         "leds-gpio",
> > +	.id =           -1,
> > +	.dev = {
> > +		.platform_data = (void *) &wgt634u_led_data,
>                                  ^^^^^^^^
> device.platform_data is a void *, so you can drop the cast.
> 

Thanks for your comments. It looks like I haven't choose the right
example file (arch/avr32/boards/atngw100/setup.c). Andrew, please find
an updated patch below.

Regards,
Aurelien



The patch below adds GPIO support to the BCM947xx platform. It uses
the new gpio-led driver and a platform driver for the pin definitions.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

--- a/arch/mips/bcm947xx/Makefile
+++ b/arch/mips/bcm947xx/Makefile
@@ -3,4 +3,4 @@
 # under Linux.
 #

-obj-y := irq.o prom.o serial.o setup.o time.o
+obj-y := irq.o prom.o serial.o setup.o time.o wgt634u.o
--- a/arch/mips/bcm947xx/wgt634u.c
+++ b/arch/mips/bcm947xx/wgt634u.c
@@ -0,0 +1,64 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
+ */
+
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/leds.h>
+#include <linux/ssb/ssb.h>
+#include <asm/mach-bcm947xx/bcm947xx.h>
+
+/* GPIO definitions for the WGT634U */
+#define WGT634U_GPIO_LED	3
+#define WGT634U_GPIO_RESET	2
+#define WGT634U_GPIO_TP1	7
+#define WGT634U_GPIO_TP2	6
+#define WGT634U_GPIO_TP3	5
+#define WGT634U_GPIO_TP4	4
+#define WGT634U_GPIO_TP5	1
+
+static struct gpio_led wgt634u_leds[] = {
+	{
+		.name = "power",
+		.gpio = WGT634U_GPIO_LED,
+		.active_low = 1,
+		.default_trigger = "heartbeat",
+	},
+};
+
+static struct gpio_led_platform_data wgt634u_led_data = {
+	.num_leds =     ARRAY_SIZE(wgt634u_leds),
+	.leds =         wgt634u_leds,
+};
+
+static struct platform_device wgt634u_gpio_leds = {
+	.name =         "leds-gpio",
+	.id =           -1,
+	.dev = {
+		.platform_data = &wgt634u_led_data,
+	}
+};
+
+static int __init wgt634u_init(void)
+{
+	/* There is no easy way to detect that we are running on a WGT634U
+	 * machine. Use the MAC address as an heuristic. Netgear Inc. has
+	 * been allocated ranges 00:09:5b:xx:xx:xx and 00:0f:b5:xx:xx:xx.
+	 */
+
+	u8 *et0mac = ssb_bcm947xx.sprom.r1.et0mac;
+
+	if (et0mac[0] == 0x00 &&
+	    ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
+	     (et0mac[1] == 0x0f && et0mac[2] == 0xb5)))
+		return platform_device_register(&wgt634u_gpio_leds);
+	else
+		return -ENODEV;
+}
+
+module_init(wgt634u_init);
+

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

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

end of thread, other threads:[~2007-08-15 18:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-15 11:25 [PATCH -mm][MIPS] GPIO LED driver for the WGT634U machine Aurelien Jarno
2007-08-15 15:39 ` Geert Uytterhoeven
2007-08-15 16:00   ` Geert Uytterhoeven
2007-08-15 18:41   ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox