diff mbox

[v2] ARM: kirkwood: Add support for Buffalo LS-XHL

Message ID 1307655488-12811-2-git-send-email-michael@walle.cc (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Walle June 9, 2011, 9:38 p.m. UTC
Add support for the Buffalo Linkstation XHL. This NAS box is based on a
Marvell Kirkwood chip at 1.2 GHz and features 256 MB RAM, 512kb SPI boot
flash, gigabit ethernet and one SATA port.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 arch/arm/configs/kirkwood_defconfig  |    1 +
 arch/arm/mach-kirkwood/Kconfig       |    6 +
 arch/arm/mach-kirkwood/Makefile      |    1 +
 arch/arm/mach-kirkwood/lsxhl-setup.c |  313 ++++++++++++++++++++++++++++++++++
 arch/arm/tools/mach-types            |    1 +
 5 files changed, 322 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-kirkwood/lsxhl-setup.c

Comments

Simon Guinot June 10, 2011, 1:45 p.m. UTC | #1
Hi Michael,

On Thu, Jun 09, 2011 at 11:38:08PM +0200, Michael Walle wrote:
> Add support for the Buffalo Linkstation XHL. This NAS box is based on a
> Marvell Kirkwood chip at 1.2 GHz and features 256 MB RAM, 512kb SPI boot
> flash, gigabit ethernet and one SATA port.
> 
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
>  arch/arm/configs/kirkwood_defconfig  |    1 +
>  arch/arm/mach-kirkwood/Kconfig       |    6 +
>  arch/arm/mach-kirkwood/Makefile      |    1 +
>  arch/arm/mach-kirkwood/lsxhl-setup.c |  313 ++++++++++++++++++++++++++++++++++
>  arch/arm/tools/mach-types            |    1 +
>  5 files changed, 322 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-kirkwood/lsxhl-setup.c
> 

... snip ...

> diff --git a/arch/arm/mach-kirkwood/lsxhl-setup.c b/arch/arm/mach-kirkwood/lsxhl-setup.c
> new file mode 100644
> index 0000000..783d257
> --- /dev/null
> +++ b/arch/arm/mach-kirkwood/lsxhl-setup.c
> @@ -0,0 +1,313 @@
> +/*
> + * arch/arm/mach-kirkwood/lsxhl-setup.c
> + *
> + * Buffalo LS-XHL Series Setup
> + *
> + * This file is licensed under the terms of the GNU General Public
> + * License version 2.  This program is licensed "as is" without any
> + * warranty of any kind, whether express or implied.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/platform_device.h>
> +#include <linux/mtd/physmap.h>
> +#include <linux/ata_platform.h>
> +#include <linux/spi/flash.h>
> +#include <linux/spi/spi.h>
> +#include <linux/mv643xx_eth.h>
> +#include <linux/gpio.h>
> +#include <linux/gpio_keys.h>
> +#include <linux/gpio-fan.h>
> +#include <linux/input.h>
> +#include <linux/leds.h>
> +#include <asm/mach-types.h>
> +#include <asm/mach/arch.h>
> +#include <mach/kirkwood.h>
> +#include <plat/mvsdio.h>

I think this include is unneeded.

... snip ...

> diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
> index 3b3776d..8acc587 100644
> --- a/arch/arm/tools/mach-types
> +++ b/arch/arm/tools/mach-types
> @@ -448,6 +448,7 @@ mityomapl138		MACH_MITYOMAPL138	MITYOMAPL138		2650
>  guruplug		MACH_GURUPLUG		GURUPLUG		2659
>  spear310		MACH_SPEAR310		SPEAR310		2660
>  spear320		MACH_SPEAR320		SPEAR320		2661
> +lsxhl			MACH_LSXHL		LSXHL			2663
>  aquila			MACH_AQUILA		AQUILA			2676
>  sheeva_esata		MACH_ESATA_SHEEVAPLUG	ESATA_SHEEVAPLUG	2678
>  msm7x30_surf		MACH_MSM7X30_SURF	MSM7X30_SURF		2679

You should probably ask the ARM maintainer to restore this machine
number entry.

BTW, I don't know if Nicolas will mainline this old fashioned board
setup. He is waiting for a DT alternative for Kirkwood.

Regards,

Simon
Nicolas Pitre June 11, 2011, 2:52 a.m. UTC | #2
On Fri, 10 Jun 2011, Simon Guinot wrote:

> BTW, I don't know if Nicolas will mainline this old fashioned board
> setup. He is waiting for a DT alternative for Kirkwood.

That's exact.  Right now there is a de facto moratorium with the 
addition of old style board support to the mainline kernel.

We need some generic Kirkwood infrastructure based on device tree to be 
created instead.  And then the addition of support for a new board would 
only require a new DTB to be passed to the kernel.


Nicolas
Bjørn Forsman June 30, 2011, 8:58 p.m. UTC | #3
Hi Michael,

On 9 June 2011 23:38, Michael Walle <michael@walle.cc> wrote:
> Add support for the Buffalo Linkstation XHL. This NAS box is based on a
> Marvell Kirkwood chip at 1.2 GHz and features 256 MB RAM, 512kb SPI boot
> flash, gigabit ethernet and one SATA port.
>
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
>  arch/arm/configs/kirkwood_defconfig  |    1 +
>  arch/arm/mach-kirkwood/Kconfig       |    6 +
>  arch/arm/mach-kirkwood/Makefile      |    1 +
>  arch/arm/mach-kirkwood/lsxhl-setup.c |  313 ++++++++++++++++++++++++++++++++++
>  arch/arm/tools/mach-types            |    1 +
>  5 files changed, 322 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-kirkwood/lsxhl-setup.c

First, thanks a lot for posting this, I've been wanting mainline
support for this device for a long time :-)

I tried this patch on my LS-XHL and found two issues:

1) When setting the fan speed to 0, the system produces a lot of GPIO
fan alarm IRQs and then the kernel reports that it's disabling the
GPIO fan alarm IRQ altogether:

$ echo 0 | sudo tee /sys/bus/platform/devices/gpio-fan/fan1_target
Message from syslogd@localhost at Jun 30 22:44:28 ...
 kernel:Disabling IRQ #104
$ dmesg
[...]
irq 104: nobody cared (try booting with the "irqpoll" option)
[<c0031210>] (unwind_backtrace+0x0/0xf0) from [<c0072d44>]
(__report_bad_irq.clone.6+0x24/0xec)
[<c0072d44>] (__report_bad_irq.clone.6+0x24/0xec) from [<c0073040>]
(note_interrupt+0x1d4/0x234)
[<c0073040>] (note_interrupt+0x1d4/0x234) from [<c00717d4>]
(handle_irq_event_percpu+0xa8/0x1ac)
[<c00717d4>] (handle_irq_event_percpu+0xa8/0x1ac) from [<c007192c>]
(handle_irq_event+0x54/0x84)
[<c007192c>] (handle_irq_event+0x54/0x84) from [<c0073bac>]
(handle_edge_irq+0xa4/0x1a0)
[<c0073bac>] (handle_edge_irq+0xa4/0x1a0) from [<c0071144>]
(generic_handle_irq+0x30/0x44)
[<c0071144>] (generic_handle_irq+0x30/0x44) from [<c00361d4>]
(orion_gpio_irq_handler+0xa4/0xb4)
[<c00361d4>] (orion_gpio_irq_handler+0xa4/0xb4) from [<c0071144>]
(generic_handle_irq+0x30/0x44)
[<c0071144>] (generic_handle_irq+0x30/0x44) from [<c002c030>]
(asm_do_IRQ+0x30/0x84)
[<c002c030>] (asm_do_IRQ+0x30/0x84) from [<c0391348>] (__irq_svc+0x48/0xa8)
Exception stack(0xc2181f18 to 0xc2181f60)
1f00:                                                       c2181f60 fed20204
1f20: 00000000 20000013 00000202 c05609c4 c2180000 00000001 c05609c4 c04bdbd8
1f40: c05609a0 0000000a 006881e0 c2181f60 c0043580 c0043070 20000013 ffffffff
[<c0391348>] (__irq_svc+0x48/0xa8) from [<c0043070>] (__do_softirq+0x4c/0x124)
[<c0043070>] (__do_softirq+0x4c/0x124) from [<c0043580>] (irq_exit+0x90/0x98)
[<c0043580>] (irq_exit+0x90/0x98) from [<c002c034>] (asm_do_IRQ+0x34/0x84)
[<c002c034>] (asm_do_IRQ+0x34/0x84) from [<c039154c>] (__irq_usr+0x4c/0xa0)
Exception stack(0xc2181fb0 to 0xc2181ff8)
1fa0:                                     00000001 bef0ead0 0000003f 00000001
1fc0: 0009c9cd 0000006f 00000004 bef0eaf8 0009c9c8 00000036 00000001 00000002
1fe0: 00000005 bef0eaf8 00077bd0 00077be4 00000010 ffffffff
handlers:
[<c0280ed8>] fan_alarm_irq_handler
Disabling IRQ #104

$ cat /proc/interrupts
           CPU0
  1:      14919  orion_irq  orion_tick
  5:          2  orion_irq  mv_xor.0
  6:          2  orion_irq  mv_xor.1
  7:          2  orion_irq  mv_xor.2
  8:          2  orion_irq  mv_xor.3
 15:       2714  orion_irq  eth1
 19:          0  orion_irq  ehci_hcd:usb1
 21:       4560  orion_irq  sata_mv
 22:          0  orion_irq  mv_crypto
 33:        279  orion_irq
 46:         36  orion_irq  mv643xx_eth
 47:          0  orion_irq  mv643xx_eth
 53:          0  orion_irq  rtc-mv
104:     100000         -  GPIO fan alarm
105:          0         -  Function Button
106:          0         -  Power-auto Switch
107:          0         -  Power-on Switch
Err:          0


2) Pressing the FUNC button or moving the power switch seems to hang
the device; my SSH connection freezes and the only way back is a
reboot. One time I managed to capture this output before the box froze
(I only moved the power switch this time):

$ evtest  /dev/input/event0
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
  Event type 0 (Sync)
  Event type 5 (?)
    Event code 0 (?)
    Event code 1 (?)
Testing ... (interrupt to exit)
Event: time 1309463461.949923, type 5 (?), code 1 (?), value 1
Event: time 1309463461.949926, -------------- Report Sync ------------
Event: time 1309463462.070543, type 5 (?), code 1 (?), value 0
Event: time 1309463462.070545, -------------- Report Sync ------------
Event: time 1309463462.070658, type 5 (?), code 0 (?), value 1
Event: time 1309463462.070660, -------------- Report Sync ------------

And at the same time, in another terminal:

$ cat /proc/interrupts
           CPU0
  1:      15567  orion_irq  orion_tick
  5:          2  orion_irq  mv_xor.0
  6:          2  orion_irq  mv_xor.1
  7:          2  orion_irq  mv_xor.2
  8:          2  orion_irq  mv_xor.3
 15:       1965  orion_irq  eth1
 19:          0  orion_irq  ehci_hcd:usb1
 21:       4675  orion_irq  sata_mv
 22:          0  orion_irq  mv_crypto
 33:        268  orion_irq
 46:         36  orion_irq  mv643xx_eth
 47:          0  orion_irq  mv643xx_eth
 53:          0  orion_irq  rtc-mv
104:          0         -  GPIO fan alarm
105:          0         -  Function Button
106:        775         -  Power-auto Switch
107:   10154532         -  Power-on Switch
Err:          0

So, the power switch also seem to suffer from some interrupt overload;
10154532 IRQs for Power-auto Switch is not right...right?

Have you seen this behaviour?

I can do more testing if someone can point me in the right direction.
(I don't have serial port access to the box, so it's a bit of a
crippled development environment. But it will have to do.)

Best regards,
Bjørn Forsman
Simon Guinot June 30, 2011, 9:49 p.m. UTC | #4
Hi Bjørn,

On Thu, Jun 30, 2011 at 10:58:15PM +0200, Bjørn Forsman wrote:
> Hi Michael,
> 
> On 9 June 2011 23:38, Michael Walle <michael@walle.cc> wrote:
> > Add support for the Buffalo Linkstation XHL. This NAS box is based on a
> > Marvell Kirkwood chip at 1.2 GHz and features 256 MB RAM, 512kb SPI boot
> > flash, gigabit ethernet and one SATA port.
> >
> > Signed-off-by: Michael Walle <michael@walle.cc>
> > ---
> >  arch/arm/configs/kirkwood_defconfig  |    1 +
> >  arch/arm/mach-kirkwood/Kconfig       |    6 +
> >  arch/arm/mach-kirkwood/Makefile      |    1 +
> >  arch/arm/mach-kirkwood/lsxhl-setup.c |  313 ++++++++++++++++++++++++++++++++++
> >  arch/arm/tools/mach-types            |    1 +
> >  5 files changed, 322 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/arm/mach-kirkwood/lsxhl-setup.c
> 
> First, thanks a lot for posting this, I've been wanting mainline
> support for this device for a long time :-)
> 
> I tried this patch on my LS-XHL and found two issues:
> 
> 1) When setting the fan speed to 0, the system produces a lot of GPIO
> fan alarm IRQs and then the kernel reports that it's disabling the
> GPIO fan alarm IRQ altogether:
> 
> $ echo 0 | sudo tee /sys/bus/platform/devices/gpio-fan/fan1_target
> Message from syslogd@localhost at Jun 30 22:44:28 ...
>  kernel:Disabling IRQ #104
> $ dmesg
> [...]
> irq 104: nobody cared (try booting with the "irqpoll" option)
> [<c0031210>] (unwind_backtrace+0x0/0xf0) from [<c0072d44>]
> (__report_bad_irq.clone.6+0x24/0xec)
> [<c0072d44>] (__report_bad_irq.clone.6+0x24/0xec) from [<c0073040>]
> (note_interrupt+0x1d4/0x234)
> [<c0073040>] (note_interrupt+0x1d4/0x234) from [<c00717d4>]
> (handle_irq_event_percpu+0xa8/0x1ac)
> [<c00717d4>] (handle_irq_event_percpu+0xa8/0x1ac) from [<c007192c>]
> (handle_irq_event+0x54/0x84)
> [<c007192c>] (handle_irq_event+0x54/0x84) from [<c0073bac>]
> (handle_edge_irq+0xa4/0x1a0)
> [<c0073bac>] (handle_edge_irq+0xa4/0x1a0) from [<c0071144>]
> (generic_handle_irq+0x30/0x44)
> [<c0071144>] (generic_handle_irq+0x30/0x44) from [<c00361d4>]
> (orion_gpio_irq_handler+0xa4/0xb4)
> [<c00361d4>] (orion_gpio_irq_handler+0xa4/0xb4) from [<c0071144>]
> (generic_handle_irq+0x30/0x44)
> [<c0071144>] (generic_handle_irq+0x30/0x44) from [<c002c030>]
> (asm_do_IRQ+0x30/0x84)
> [<c002c030>] (asm_do_IRQ+0x30/0x84) from [<c0391348>] (__irq_svc+0x48/0xa8)
> Exception stack(0xc2181f18 to 0xc2181f60)
> 1f00:                                                       c2181f60 fed20204
> 1f20: 00000000 20000013 00000202 c05609c4 c2180000 00000001 c05609c4 c04bdbd8
> 1f40: c05609a0 0000000a 006881e0 c2181f60 c0043580 c0043070 20000013 ffffffff
> [<c0391348>] (__irq_svc+0x48/0xa8) from [<c0043070>] (__do_softirq+0x4c/0x124)
> [<c0043070>] (__do_softirq+0x4c/0x124) from [<c0043580>] (irq_exit+0x90/0x98)
> [<c0043580>] (irq_exit+0x90/0x98) from [<c002c034>] (asm_do_IRQ+0x34/0x84)
> [<c002c034>] (asm_do_IRQ+0x34/0x84) from [<c039154c>] (__irq_usr+0x4c/0xa0)
> Exception stack(0xc2181fb0 to 0xc2181ff8)
> 1fa0:                                     00000001 bef0ead0 0000003f 00000001
> 1fc0: 0009c9cd 0000006f 00000004 bef0eaf8 0009c9c8 00000036 00000001 00000002
> 1fe0: 00000005 bef0eaf8 00077bd0 00077be4 00000010 ffffffff
> handlers:
> [<c0280ed8>] fan_alarm_irq_handler
> Disabling IRQ #104
> 
> $ cat /proc/interrupts
>            CPU0
>   1:      14919  orion_irq  orion_tick
>   5:          2  orion_irq  mv_xor.0
>   6:          2  orion_irq  mv_xor.1
>   7:          2  orion_irq  mv_xor.2
>   8:          2  orion_irq  mv_xor.3
>  15:       2714  orion_irq  eth1
>  19:          0  orion_irq  ehci_hcd:usb1
>  21:       4560  orion_irq  sata_mv
>  22:          0  orion_irq  mv_crypto
>  33:        279  orion_irq
>  46:         36  orion_irq  mv643xx_eth
>  47:          0  orion_irq  mv643xx_eth
>  53:          0  orion_irq  rtc-mv
> 104:     100000         -  GPIO fan alarm
> 105:          0         -  Function Button
> 106:          0         -  Power-auto Switch
> 107:          0         -  Power-on Switch
> Err:          0
> 
> 
> 2) Pressing the FUNC button or moving the power switch seems to hang
> the device; my SSH connection freezes and the only way back is a
> reboot. One time I managed to capture this output before the box froze
> (I only moved the power switch this time):
> 
> $ evtest  /dev/input/event0
> Input driver version is 1.0.1
> Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
> Input device name: "gpio-keys"
> Supported events:
>   Event type 0 (Sync)
>   Event type 5 (?)
>     Event code 0 (?)
>     Event code 1 (?)
> Testing ... (interrupt to exit)
> Event: time 1309463461.949923, type 5 (?), code 1 (?), value 1
> Event: time 1309463461.949926, -------------- Report Sync ------------
> Event: time 1309463462.070543, type 5 (?), code 1 (?), value 0
> Event: time 1309463462.070545, -------------- Report Sync ------------
> Event: time 1309463462.070658, type 5 (?), code 0 (?), value 1
> Event: time 1309463462.070660, -------------- Report Sync ------------
> 
> And at the same time, in another terminal:
> 
> $ cat /proc/interrupts
>            CPU0
>   1:      15567  orion_irq  orion_tick
>   5:          2  orion_irq  mv_xor.0
>   6:          2  orion_irq  mv_xor.1
>   7:          2  orion_irq  mv_xor.2
>   8:          2  orion_irq  mv_xor.3
>  15:       1965  orion_irq  eth1
>  19:          0  orion_irq  ehci_hcd:usb1
>  21:       4675  orion_irq  sata_mv
>  22:          0  orion_irq  mv_crypto
>  33:        268  orion_irq
>  46:         36  orion_irq  mv643xx_eth
>  47:          0  orion_irq  mv643xx_eth
>  53:          0  orion_irq  rtc-mv
> 104:          0         -  GPIO fan alarm
> 105:          0         -  Function Button
> 106:        775         -  Power-auto Switch
> 107:   10154532         -  Power-on Switch
> Err:          0
> 
> So, the power switch also seem to suffer from some interrupt overload;
> 10154532 IRQs for Power-auto Switch is not right...right?
> 
> Have you seen this behaviour?
> 
> I can do more testing if someone can point me in the right direction.
> (I don't have serial port access to the box, so it's a bit of a
> crippled development environment. But it will have to do.)

It is probably related to a edge GPIO interrupts bug:
http://lists.arm.linux.org.uk/lurker/message/20110629.200122.012d23be.en.html

Regards,

Simon
Michael Walle July 4, 2011, 8:50 p.m. UTC | #5
Am Donnerstag 30 Juni 2011, 22:58:15 schrieb Bjørn Forsman:
> Hi Michael,
[..]
> So, the power switch also seem to suffer from some interrupt overload;
> 10154532 IRQs for Power-auto Switch is not right...right?
> 
> Have you seen this behaviour?
Nope, the interrupt behaves normally for me. But i'm running this patch with 
kernel 2.6.32 and tested it briefly with 2.6.39.

Could you verify, if you are triggering the bug Simon posted above?
Bjørn Forsman July 5, 2011, 9:42 p.m. UTC | #6
2011/7/4 Michael Walle <michael@walle.cc>:
> Am Donnerstag 30 Juni 2011, 22:58:15 schrieb Bjørn Forsman:
>> Hi Michael,
> [..]
>> So, the power switch also seem to suffer from some interrupt overload;
>> 10154532 IRQs for Power-auto Switch is not right...right?
>>
>> Have you seen this behaviour?
> Nope, the interrupt behaves normally for me. But i'm running this patch with
> kernel 2.6.32 and tested it briefly with 2.6.39.
>
> Could you verify, if you are triggering the bug Simon posted above?

Yes, it must be the same bug. I reverted
e59347a1d15c0b1d9fdc510520f8fa78d7d19a5b (arm: orion: Use generic irq
chip) on top of "3.0-rc5 + this LS-XHL patch" and the IRQ issues are
gone.

$ cat /proc/interrupts   # after toggling the buttons and setting fan
speed to 0 a few times
...
104:          4  orion_gpio_irq  GPIO fan alarm
105:          4  orion_gpio_irq  Function Button
106:          6  orion_gpio_irq  Power-auto Switch
107:          4  orion_gpio_irq  Power-on Switch

No system hang/reboot/lockups :-)

Compare that with /proc/interrupts from the bugged version; it lists
"-" instead of "orion_gpio_irq" as IRQ handler:

104:     100000         -  GPIO fan alarm
105:          0         -  Function Button
106:          0         -  Power-auto Switch
107:          0         -  Power-on Switch

Best regards,
Bjørn Forsman
diff mbox

Patch

diff --git a/arch/arm/configs/kirkwood_defconfig b/arch/arm/configs/kirkwood_defconfig
index aeb3af5..9f77811 100644
--- a/arch/arm/configs/kirkwood_defconfig
+++ b/arch/arm/configs/kirkwood_defconfig
@@ -28,6 +28,7 @@  CONFIG_MACH_D2NET_V2=y
 CONFIG_MACH_NET2BIG_V2=y
 CONFIG_MACH_NET5BIG_V2=y
 CONFIG_MACH_T5325=y
+CONFIG_MACH_LSXHL=y
 # CONFIG_CPU_FEROCEON_OLD_ID is not set
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 7fc603b..307cc99 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -130,6 +130,12 @@  config MACH_T5325
 	  Say 'Y' here if you want your kernel to support the
 	  HP t5325 Thin Client.
 
+config MACH_LSXHL
+	bool "Buffalo LS-XHL Series"
+	help
+	  Say 'Y' here if you want your kernel to support the
+	  Buffalo LS-XHL Series.
+
 endmenu
 
 endif
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
index 5dcaa81..221980b 100644
--- a/arch/arm/mach-kirkwood/Makefile
+++ b/arch/arm/mach-kirkwood/Makefile
@@ -18,5 +18,6 @@  obj-$(CONFIG_MACH_D2NET_V2)		+= d2net_v2-setup.o lacie_v2-common.o
 obj-$(CONFIG_MACH_NET2BIG_V2)		+= netxbig_v2-setup.o lacie_v2-common.o
 obj-$(CONFIG_MACH_NET5BIG_V2)		+= netxbig_v2-setup.o lacie_v2-common.o
 obj-$(CONFIG_MACH_T5325)		+= t5325-setup.o
+obj-$(CONFIG_MACH_LSXHL)		+= lsxhl-setup.o
 
 obj-$(CONFIG_CPU_IDLE)			+= cpuidle.o
diff --git a/arch/arm/mach-kirkwood/lsxhl-setup.c b/arch/arm/mach-kirkwood/lsxhl-setup.c
new file mode 100644
index 0000000..783d257
--- /dev/null
+++ b/arch/arm/mach-kirkwood/lsxhl-setup.c
@@ -0,0 +1,313 @@ 
+/*
+ * arch/arm/mach-kirkwood/lsxhl-setup.c
+ *
+ * Buffalo LS-XHL Series Setup
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/physmap.h>
+#include <linux/ata_platform.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>
+#include <linux/mv643xx_eth.h>
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
+#include <linux/gpio-fan.h>
+#include <linux/input.h>
+#include <linux/leds.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <mach/kirkwood.h>
+#include <plat/mvsdio.h>
+#include "common.h"
+#include "mpp.h"
+
+/*****************************************************************************
+ * 512KB SPI Flash on BOOT Device
+ ****************************************************************************/
+static struct mtd_partition lsxhl_partitions[] = {
+	{
+		.name		= "u-boot",
+		.size		= 0x70000,
+		.offset		= 0x00000,
+		.mask_flags	= MTD_WRITEABLE,
+	},
+	{
+		.name		= "u-boot env",
+		.size		= 0x10000,
+		.offset		= 0x70000,
+	}
+};
+
+static struct flash_platform_data lsxhl_spi_slave_data = {
+	.type		= "m25p40",
+	.parts		= lsxhl_partitions,
+	.nr_parts	= ARRAY_SIZE(lsxhl_partitions),
+};
+
+static struct spi_board_info __initdata lsxhl_spi_slave_info[] = {
+	{
+		.modalias	= "m25p80",
+		.platform_data	= &lsxhl_spi_slave_data,
+		.irq		= -1,
+		.max_speed_hz	= 20000000,
+		.bus_num	= 0,
+		.chip_select	= 0,
+	}
+};
+
+/*****************************************************************************
+ * Ethernet
+ ****************************************************************************/
+static struct mv643xx_eth_platform_data lsxhl_ge00_data = {
+	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
+};
+
+static struct mv643xx_eth_platform_data lsxhl_ge01_data = {
+	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
+};
+
+/*****************************************************************************
+ * SATA
+ ****************************************************************************/
+static struct mv_sata_platform_data lsxhl_sata_data = {
+	.n_ports	= 1,
+};
+
+/*****************************************************************************
+ * LEDs attached to GPIO
+ ****************************************************************************/
+#define LSXHL_GPIO_LED_ALARM		37
+#define LSXHL_GPIO_LED_INFO		38
+#define LSXHL_GPIO_LED_PWR		39
+#define LSXHL_GPIO_LED_FUNC_BLUE	36
+#define LSXHL_GPIO_LED_FUNC_RED		48
+
+static struct gpio_led lsxhl_led_pins[] = {
+	{
+		.name			= "alarm:red",
+		.gpio			= LSXHL_GPIO_LED_ALARM,
+		.active_low		= 1,
+	},
+	{
+		.name			= "info:amber",
+		.gpio			= LSXHL_GPIO_LED_INFO,
+		.active_low		= 1,
+	},
+	{
+		.name			= "power:blue",
+		.default_trigger	= "default-on",
+		.gpio			= LSXHL_GPIO_LED_PWR,
+		.active_low		= 1,
+	},
+	{
+		.name			= "func:blue:bottom",
+		.gpio			= LSXHL_GPIO_LED_FUNC_BLUE,
+		.active_low		= 1,
+	},
+	{
+		.name			= "func:red:bottom",
+		.gpio			= LSXHL_GPIO_LED_FUNC_RED,
+		.active_low		= 1,
+	},
+};
+
+static struct gpio_led_platform_data lsxhl_led_data = {
+	.leds		= lsxhl_led_pins,
+	.num_leds	= ARRAY_SIZE(lsxhl_led_pins),
+};
+
+static struct platform_device lsxhl_leds = {
+	.name	= "leds-gpio",
+	.id	= -1,
+	.dev	= {
+		.platform_data	= &lsxhl_led_data,
+	}
+};
+
+/*****************************************************************************
+ * General Setup
+ ****************************************************************************/
+#define LSXHL_GPIO_HDD_POWER 10
+#define LSXHL_GPIO_USB_POWER 11
+
+/*****************************************************************************
+ * GPIO Attached Keys
+ ****************************************************************************/
+#define LSXHL_GPIO_KEY_FUNC		41
+#define LSXHL_GPIO_KEY_AUTOPOWER	42
+#define LSXHL_GPIO_KEY_POWER		43
+#define LSXHL_SW_POWER		0x00
+#define LSXHL_SW_AUTOPOWER	0x01
+#define LSXHL_SW_FUNC		0x02
+
+static struct gpio_keys_button lsxhl_buttons[] = {
+	{
+		.type = EV_SW,
+		.code = LSXHL_SW_POWER,
+		.gpio = LSXHL_GPIO_KEY_POWER,
+		.desc = "Power-on Switch",
+		.active_low = 1,
+	}, {
+		.type = EV_SW,
+		.code = LSXHL_SW_AUTOPOWER,
+		.gpio = LSXHL_GPIO_KEY_AUTOPOWER,
+		.desc = "Power-auto Switch",
+		.active_low = 1,
+	}, {
+		.type = EV_SW,
+		.code = LSXHL_SW_POWER,
+		.gpio = LSXHL_GPIO_KEY_FUNC,
+		.desc = "Function Button",
+		.active_low = 1,
+	},
+};
+
+static struct gpio_keys_platform_data lsxhl_button_data = {
+	.buttons = lsxhl_buttons,
+	.nbuttons = ARRAY_SIZE(lsxhl_buttons),
+};
+
+static struct platform_device lsxhl_button_device = {
+	.name = "gpio-keys",
+	.id = -1,
+	.num_resources = 0,
+	.dev = {
+		.platform_data = &lsxhl_button_data,
+	},
+};
+
+/*****************************************************************************
+ * GPIO Fan
+ ****************************************************************************/
+#define LSXHL_GPIO_FAN_HIGH	18
+#define LSXHL_GPIO_FAN_LOW	19
+#define LSXHL_GPIO_FAN_LOCK	40
+
+static struct gpio_fan_alarm lsxhl_alarm = {
+	.gpio = LSXHL_GPIO_FAN_LOCK,
+};
+
+static struct gpio_fan_speed lsxhl_speeds[] = {
+	{
+		.rpm = 0,
+		.ctrl_val = 3,
+	}, {
+		.rpm = 1500,
+		.ctrl_val = 1,
+	}, {
+		.rpm = 3250,
+		.ctrl_val = 2,
+	}, {
+		.rpm = 5000,
+		.ctrl_val = 0,
+	}
+};
+
+static int lsxhl_gpio_list[] = {
+	LSXHL_GPIO_FAN_HIGH, LSXHL_GPIO_FAN_LOW,
+};
+
+static struct gpio_fan_platform_data lsxhl_fan_data = {
+	.num_ctrl = ARRAY_SIZE(lsxhl_gpio_list),
+	.ctrl = lsxhl_gpio_list,
+	.alarm = &lsxhl_alarm,
+	.num_speed = ARRAY_SIZE(lsxhl_speeds),
+	.speed = lsxhl_speeds,
+};
+
+static struct platform_device lsxhl_fan_device = {
+	.name = "gpio-fan",
+	.id = -1,
+	.num_resources = 0,
+	.dev = {
+		.platform_data = &lsxhl_fan_data,
+	},
+};
+
+/*****************************************************************************
+ * GPIO Data
+ ****************************************************************************/
+
+static unsigned int lsxhl_mpp_config[] __initdata = {
+	MPP10_GPO,	/* HDD Power Enable */
+	MPP11_GPIO,	/* USB Vbus Enable */
+	MPP18_GPO,	/* FAN High Enable# */
+	MPP19_GPO,	/* FAN Low Enable# */
+	MPP36_GPIO,	/* Function Blue LED */
+	MPP37_GPIO,	/* Alarm LED */
+	MPP38_GPIO,	/* Info LED */
+	MPP39_GPIO,	/* Power LED */
+	MPP40_GPIO,	/* Fan Lock */
+	MPP41_GPIO,	/* Function Button */
+	MPP42_GPIO,	/* Power Switch */
+	MPP43_GPIO,	/* Power Auto Switch */
+	MPP48_GPIO,	/* Function Red LED */
+	0
+};
+
+/*****************************************************************************
+ * LS-XHL specific power off method: reboot
+ ****************************************************************************/
+/*
+ * On the LS-XHL, the shutdown process is following:
+ * - Userland monitors key events until the power switch goes to off position
+ * - The board reboots
+ * - U-boot starts and goes into an idle mode waiting for the user
+ *   to move the switch to ON position
+ *
+ */
+
+static void lsxhl_power_off(void)
+{
+	arm_machine_restart('h', NULL);
+}
+
+static void __init lsxhl_init(void)
+{
+	/*
+	 * Basic setup. Needs to be called early.
+	 */
+	kirkwood_init();
+	kirkwood_mpp_conf(lsxhl_mpp_config);
+
+	/*
+	 * Configure peripherals.
+	 */
+	kirkwood_uart0_init();
+	kirkwood_ehci_init();
+	kirkwood_ge00_init(&lsxhl_ge00_data);
+	kirkwood_ge01_init(&lsxhl_ge01_data);
+	kirkwood_sata_init(&lsxhl_sata_data);
+	kirkwood_spi_init();
+
+	platform_device_register(&lsxhl_leds);
+	platform_device_register(&lsxhl_button_device);
+	platform_device_register(&lsxhl_fan_device);
+
+	spi_register_board_info(lsxhl_spi_slave_info,
+				ARRAY_SIZE(lsxhl_spi_slave_info));
+
+	/* usb power on */
+	gpio_set_value(LSXHL_GPIO_USB_POWER, 1);
+
+	/* register power-off method */
+	pm_power_off = lsxhl_power_off;
+
+	pr_info("%s: finished\n", __func__);
+}
+
+MACHINE_START(LSXHL, "Buffalo LS-XHL Series")
+	.boot_params	= 0x00000100,
+	.init_machine	= lsxhl_init,
+	.map_io		= kirkwood_map_io,
+	.init_early	= kirkwood_init_early,
+	.init_irq	= kirkwood_init_irq,
+	.timer		= &kirkwood_timer,
+MACHINE_END
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
index 3b3776d..8acc587 100644
--- a/arch/arm/tools/mach-types
+++ b/arch/arm/tools/mach-types
@@ -448,6 +448,7 @@  mityomapl138		MACH_MITYOMAPL138	MITYOMAPL138		2650
 guruplug		MACH_GURUPLUG		GURUPLUG		2659
 spear310		MACH_SPEAR310		SPEAR310		2660
 spear320		MACH_SPEAR320		SPEAR320		2661
+lsxhl			MACH_LSXHL		LSXHL			2663
 aquila			MACH_AQUILA		AQUILA			2676
 sheeva_esata		MACH_ESATA_SHEEVAPLUG	ESATA_SHEEVAPLUG	2678
 msm7x30_surf		MACH_MSM7X30_SURF	MSM7X30_SURF		2679