* [PATCH] Soekris net5501 board support code
@ 2008-12-26 1:26 Alessandro Zummo
2008-12-27 0:41 ` Andrew Morton
0 siblings, 1 reply; 7+ messages in thread
From: Alessandro Zummo @ 2008-12-26 1:26 UTC (permalink / raw)
To: lkml; +Cc: rpurdie
This patch detects the net5501 board and instantiates the
correct platform devices (GPIO and leds).
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
---
arch/x86/Kconfig | 9 +++
arch/x86/kernel/Makefile | 1
arch/x86/kernel/soekris.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 138 insertions(+)
--- linux-tuxrouter-2.6.28-isdn.orig/arch/x86/Kconfig 2008-12-25 16:55:23.000000000 +0100
+++ linux-tuxrouter-2.6.28-isdn/arch/x86/Kconfig 2008-12-25 16:55:24.000000000 +0100
@@ -1850,6 +1850,15 @@ config OLPC
Add support for detecting the unique features of the OLPC
XO hardware.
+config SOEKRIS
+ bool "Soekris net5501 support"
+ depends on MGEODE_LX
+ default n
+ help
+ Add support for the Soekris net5501 board. You might also want
+ to enable support for the AMD CS553X GPIOs (CONFIG_GPIO_CS553X)
+ and leds.
+
endif # X86_32
config K8_NB
--- linux-tuxrouter-2.6.28-isdn.orig/arch/x86/kernel/Makefile 2008-12-25 16:55:23.000000000 +0100
+++ linux-tuxrouter-2.6.28-isdn/arch/x86/kernel/Makefile 2008-12-25 16:55:24.000000000 +0100
@@ -99,6 +99,7 @@ obj-$(CONFIG_SCx200) += scx200.o
scx200-y += scx200_32.o
obj-$(CONFIG_OLPC) += olpc.o
+obj-$(CONFIG_SOEKRIS) += soekris.o
microcode-y := microcode_core.o
microcode-$(CONFIG_MICROCODE_INTEL) += microcode_intel.o
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-tuxrouter-2.6.28-isdn/arch/x86/kernel/soekris.c 2008-12-25 16:55:45.000000000 +0100
@@ -0,0 +1,128 @@
+/*
+ * Soekris board support code
+ *
+ * Copyright (c) 2008 Tower Technologies
+ * Written by Alessandro Zummo <a.zummo@towertech.it>
+ *
+ * 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/kernel.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/string.h>
+#include <linux/leds.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+
+#include <asm/geode.h>
+
+#if defined(CONFIG_GPIO_CS553X) || defined(CONFIG_GPIO_CS553X_MODULE)
+#ifdef CONFIG_LEDS_CLASS
+static struct gpio_led net5501_leds[] = {
+ { .name = "error", .gpio = -1 }, /* filled later */
+};
+
+static struct gpio_led_platform_data net5501_leds_data = {
+ .num_leds = ARRAY_SIZE(net5501_leds),
+ .leds = net5501_leds,
+};
+
+static struct platform_device net5501_leds_dev = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev.platform_data = &net5501_leds_data,
+};
+#endif /* CONFIG_LEDS_CLASS */
+
+static int cs553x_gpio_setup(struct platform_device *pdev, unsigned base,
+ unsigned ngpio, void *context)
+{
+#ifdef CONFIG_LEDS_CLASS
+ net5501_leds[0].gpio = base + 6; /* "error" led */
+ return platform_device_register(&net5501_leds_dev);
+#else
+ return 0;
+#endif
+}
+
+static int cs553x_gpio_teardown(struct platform_device *pdev, unsigned base,
+ unsigned ngpio, void *context)
+{
+#ifdef CONFIG_LEDS_CLASS
+ platform_device_unregister(&net5501_leds_dev);
+#endif
+ return 0;
+}
+
+struct cs553x_gpio_platform_data net5501_gpio_data = {
+ .gpio_base = -1,
+ .io_base = 0, /* filled later */
+ .setup = cs553x_gpio_setup,
+ .teardown = cs553x_gpio_teardown,
+};
+
+static struct platform_device net5501_gpio = {
+ .name = "cs553x-gpio",
+ .id = -1,
+ .dev.platform_data = &net5501_gpio_data,
+};
+#endif /* CONFIG_GPIO_CS553X */
+
+static void __init init_net5501(void)
+{
+#if defined(CONFIG_GPIO_CS553X) || defined(CONFIG_GPIO_CS553X_MODULE)
+ net5501_gpio_data.io_base = geode_gpio_base();
+ platform_device_register(&net5501_gpio);
+#endif
+}
+
+struct soekris_board {
+ u16 offset;
+ char *sig;
+ u8 len;
+ void (*init)(void);
+};
+
+static struct soekris_board __initdata boards[] = {
+ { 0xb7b, "net5501", 7, init_net5501 }, /* net5501 v1.33/1.33c */
+ { 0xb1f, "net5501", 7, init_net5501 }, /* net5501 v1.32i */
+};
+
+static int __init soekris_init(void)
+{
+ int i;
+ unsigned char *rombase, *bios;
+
+ if (!is_geode() || geode_has_vsa2())
+ return 0;
+
+ rombase = ioremap(0xffff0000, 0xffff);
+ if (!rombase)
+ return 0;
+
+ bios = rombase + 0x20; /* null terminated */
+
+ if (strncmp(bios, "comBIOS", 7))
+ goto unmap;
+
+ for (i = 0; i < ARRAY_SIZE(boards); i++) {
+ unsigned char *model = rombase + boards[i].offset;
+
+ if (strncmp(model, boards[i].sig, boards[i].len) == 0) {
+ printk(KERN_INFO "Soekris %s: %s\n", model, bios);
+
+ if (boards[i].init)
+ boards[i].init();
+ break;
+ }
+ }
+
+unmap:
+ iounmap(rombase);
+ return 0;
+}
+
+arch_initcall(soekris_init);
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Soekris net5501 board support code
2008-12-26 1:26 [PATCH] Soekris net5501 board support code Alessandro Zummo
@ 2008-12-27 0:41 ` Andrew Morton
2008-12-27 0:55 ` H. Peter Anvin
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2008-12-27 0:41 UTC (permalink / raw)
To: Alessandro Zummo
Cc: lkml, rpurdie, Ingo Molnar, Thomas Gleixner, H. Peter Anvin
On Fri, 26 Dec 2008 02:26:02 +0100 Alessandro Zummo <alessandro.zummo@towertech.it> wrote:
> This patch detects the net5501 board and instantiates the
> correct platform devices (GPIO and leds).
>
> Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
>
> ---
> arch/x86/Kconfig | 9 +++
> arch/x86/kernel/Makefile | 1
> arch/x86/kernel/soekris.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++
You might want to tell the x86 maintainers about this :)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Soekris net5501 board support code
2008-12-27 0:41 ` Andrew Morton
@ 2008-12-27 0:55 ` H. Peter Anvin
2008-12-27 1:41 ` Alessandro Zummo
0 siblings, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2008-12-27 0:55 UTC (permalink / raw)
To: Andrew Morton
Cc: Alessandro Zummo, lkml, rpurdie, Ingo Molnar, Thomas Gleixner
Andrew Morton wrote:
> On Fri, 26 Dec 2008 02:26:02 +0100 Alessandro Zummo <alessandro.zummo@towertech.it> wrote:
>
>> This patch detects the net5501 board and instantiates the
>> correct platform devices (GPIO and leds).
>>
>> Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
>>
>> ---
>> arch/x86/Kconfig | 9 +++
>> arch/x86/kernel/Makefile | 1
>> arch/x86/kernel/soekris.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++
>
> You might want to tell the x86 maintainers about this :)
The current consensus (to the extent that one exists) seems to be that
platform device drivers belong in drivers[/platform]/x86, instead of in
arch/x86. drivers/platform doesn't exist in the current -linus tree,
but Len Brown has patches to do it which should be pushed upstream in
this merge window. In the meantime, use the old name drivers/misc (a
misnomer today, but won't be for much longer.)
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Soekris net5501 board support code
2008-12-27 0:55 ` H. Peter Anvin
@ 2008-12-27 1:41 ` Alessandro Zummo
0 siblings, 0 replies; 7+ messages in thread
From: Alessandro Zummo @ 2008-12-27 1:41 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Andrew Morton, lkml, rpurdie, Ingo Molnar, Thomas Gleixner
On Fri, 26 Dec 2008 16:55:06 -0800
"H. Peter Anvin" <hpa@zytor.com> wrote:
> >> arch/x86/Kconfig | 9 +++
> >> arch/x86/kernel/Makefile | 1
> >> arch/x86/kernel/soekris.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++
> >
> > You might want to tell the x86 maintainers about this :)
>
> The current consensus (to the extent that one exists) seems to be that
> platform device drivers belong in drivers[/platform]/x86, instead of in
> arch/x86. drivers/platform doesn't exist in the current -linus tree,
> but Len Brown has patches to do it which should be pushed upstream in
> this merge window. In the meantime, use the old name drivers/misc (a
> misnomer today, but won't be for much longer.)
Hi Peter,
I'm awaiting feedback from the geode mailing list to see if they
want to move to the GPIO class and thus instantiate the GPIO
devices in geode_32.c.
The remaining pieces (LEDS) could then be moved to drivers/platform, even if
it's not a real driver.
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Soekris net5501 board support code
@ 2009-02-05 15:13 Alessandro Zummo
2009-02-06 23:21 ` Andrew Morton
0 siblings, 1 reply; 7+ messages in thread
From: Alessandro Zummo @ 2009-02-05 15:13 UTC (permalink / raw)
To: lkml; +Cc: rpurdie, Ingo Molnar, Thomas Gleixner, H. Peter Anvin
Board support code for the Soekris net5501.
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
---
drivers/platform/x86/Kconfig | 14 ++++++
drivers/platform/x86/Makefile | 1
drivers/platform/x86/soekris.c | 92 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 107 insertions(+)
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.28/drivers/platform/x86/soekris.c 2009-02-03 22:45:16.000000000 +0100
@@ -0,0 +1,92 @@
+/*
+ * Soekris board support code
+ *
+ * Copyright (C) 2008-2009 Tower Technologies
+ * Written by Alessandro Zummo <a.zummo@towertech.it>
+ *
+ * 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/kernel.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/string.h>
+#include <linux/leds.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+
+#include <asm/geode.h>
+
+static struct gpio_led net5501_leds[] = {
+ {
+ .name = "error",
+ .gpio = 6,
+ .default_trigger = "default-on",
+ },
+};
+
+static struct gpio_led_platform_data net5501_leds_data = {
+ .num_leds = ARRAY_SIZE(net5501_leds),
+ .leds = net5501_leds,
+};
+
+static struct platform_device net5501_leds_dev = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev.platform_data = &net5501_leds_data,
+};
+
+static void __init init_net5501(void)
+{
+ platform_device_register(&net5501_leds_dev);
+}
+
+struct soekris_board {
+ u16 offset;
+ char *sig;
+ u8 len;
+ void (*init)(void);
+};
+
+static struct soekris_board __initdata boards[] = {
+ { 0xb7b, "net5501", 7, init_net5501 }, /* net5501 v1.33/1.33c */
+ { 0xb1f, "net5501", 7, init_net5501 }, /* net5501 v1.32i */
+};
+
+static int __init soekris_init(void)
+{
+ int i;
+ unsigned char *rombase, *bios;
+
+ if (!is_geode() || geode_has_vsa2())
+ return 0;
+
+ rombase = ioremap(0xffff0000, 0xffff);
+ if (!rombase)
+ return 0;
+
+ bios = rombase + 0x20; /* null terminated */
+
+ if (strncmp(bios, "comBIOS", 7))
+ goto unmap;
+
+ for (i = 0; i < ARRAY_SIZE(boards); i++) {
+ unsigned char *model = rombase + boards[i].offset;
+
+ if (strncmp(model, boards[i].sig, boards[i].len) == 0) {
+ printk(KERN_INFO "Soekris %s: %s\n", model, bios);
+
+ if (boards[i].init)
+ boards[i].init();
+ break;
+ }
+ }
+
+unmap:
+ iounmap(rombase);
+ return 0;
+}
+
+arch_initcall(soekris_init);
--- linux-2.6.28.orig/drivers/platform/x86/Kconfig 2009-02-03 19:30:25.000000000 +0100
+++ linux-2.6.28/drivers/platform/x86/Kconfig 2009-02-03 22:39:28.000000000 +0100
@@ -395,4 +395,18 @@ config ACPI_TOSHIBA
If you have a legacy free Toshiba laptop (such as the Libretto L1
series), say Y.
+
+config SOEKRIS
+ bool "Soekris net5501 support"
+ depends on MGEODE_LX
+ select GPIOLIB
+ select GEODE_GPIO
+ select LEDS_CLASS
+ select LEDS_GPIO
+ select LEDS_TRIGGER_DEFAULT_ON
+ default n
+ help
+ Add support for the Soekris net5501 board (detection, error led
+ and GPIO).
+
endif # X86_PLATFORM_DEVICES
--- linux-2.6.28.orig/drivers/platform/x86/Makefile 2009-02-03 19:30:25.000000000 +0100
+++ linux-2.6.28/drivers/platform/x86/Makefile 2009-02-03 20:26:33.000000000 +0100
@@ -18,3 +18,4 @@ obj-$(CONFIG_INTEL_MENLOW) += intel_menl
obj-$(CONFIG_ACPI_WMI) += wmi.o
obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o
obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o
+obj-$(CONFIG_SOEKRIS) += soekris.o
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Soekris net5501 board support code
2009-02-05 15:13 Alessandro Zummo
@ 2009-02-06 23:21 ` Andrew Morton
2009-02-06 23:35 ` Alessandro Zummo
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2009-02-06 23:21 UTC (permalink / raw)
To: Alessandro Zummo; +Cc: linux-kernel, rpurdie, mingo, tglx, hpa
On Thu, 5 Feb 2009 16:13:19 +0100
Alessandro Zummo <alessandro.zummo@towertech.it> wrote:
> +static int __init soekris_init(void)
> +{
> + int i;
> + unsigned char *rombase, *bios;
> +
> + if (!is_geode() || geode_has_vsa2())
> + return 0;
> +
> + rombase = ioremap(0xffff0000, 0xffff);
> + if (!rombase)
> + return 0;
Is it appropriate to silently "succeed" if the ioremap() failed?
> + bios = rombase + 0x20; /* null terminated */
> +
> + if (strncmp(bios, "comBIOS", 7))
> + goto unmap;
> +
> + for (i = 0; i < ARRAY_SIZE(boards); i++) {
> + unsigned char *model = rombase + boards[i].offset;
> +
> + if (strncmp(model, boards[i].sig, boards[i].len) == 0) {
> + printk(KERN_INFO "Soekris %s: %s\n", model, bios);
> +
> + if (boards[i].init)
> + boards[i].init();
> + break;
> + }
> + }
> +
> +unmap:
> + iounmap(rombase);
> + return 0;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Soekris net5501 board support code
2009-02-06 23:21 ` Andrew Morton
@ 2009-02-06 23:35 ` Alessandro Zummo
0 siblings, 0 replies; 7+ messages in thread
From: Alessandro Zummo @ 2009-02-06 23:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, rpurdie, mingo, tglx, hpa
On Fri, 6 Feb 2009 15:21:21 -0800
Andrew Morton <akpm@linux-foundation.org> wrote:
> > + rombase = ioremap(0xffff0000, 0xffff);
> > + if (!rombase)
> > + return 0;
>
> Is it appropriate to silently "succeed" if the ioremap() failed?
maybe not.. I'll add a printk. ty.
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-02-06 23:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-26 1:26 [PATCH] Soekris net5501 board support code Alessandro Zummo
2008-12-27 0:41 ` Andrew Morton
2008-12-27 0:55 ` H. Peter Anvin
2008-12-27 1:41 ` Alessandro Zummo
-- strict thread matches above, loose matches on Subject: below --
2009-02-05 15:13 Alessandro Zummo
2009-02-06 23:21 ` Andrew Morton
2009-02-06 23:35 ` Alessandro Zummo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox