Re: [PATCH 2/2] Initial support for the Ubiquiti Networks XM board.

From: Renà Bolldorf
Date: Thu Nov 17 2011 - 05:31:47 EST


Did not reply to all.....

2011/11/16 Renà Bolldorf <xsecute@xxxxxxxxxxxxxx>:
> On Wed, Nov 16, 2011 at 9:02 PM, Gabor Juhos <juhosg@xxxxxxxxxxx> wrote:
>> Hi Rene,
>>
>>> Signed-off-by: Rene Bolldorf <xsecute@xxxxxxxxxxxxxx>
>>> ---
>>> Âarch/mips/ath79/Kconfig    Â|  12 ++++
>>> Âarch/mips/ath79/Makefile    |  Â1 +
>>> Âarch/mips/ath79/Platform    |  Â7 ++-
>>> Âarch/mips/ath79/mach-ubnt-xm.c | Â110 ++++++++++++++++++++++++++++++++++++++++
>>> Âarch/mips/ath79/machtypes.h  Â|  Â1 +
>>> Â5 files changed, 128 insertions(+), 3 deletions(-)
>>> Âcreate mode 100644 arch/mips/ath79/mach-ubnt-xm.c
>>>
>>> diff --git a/arch/mips/ath79/Kconfig b/arch/mips/ath79/Kconfig
>>> index 4770741..fa74e73 100644
>>> --- a/arch/mips/ath79/Kconfig
>>> +++ b/arch/mips/ath79/Kconfig
>>> @@ -23,6 +23,16 @@ config ATH79_MACH_PB44
>>> Â Â Â Â Say 'Y' here if you want your kernel to support the
>>> Â Â Â Â Atheros PB44 reference board.
>>>
>>> +config ATH79_MACH_UBNT_XM
>>> + Â Â bool "Ubiquiti Networks XM board"
>>> + Â Â select SOC_AR724X
>>> + Â Â select ATH79_DEV_GPIO_BUTTONS
>>> + Â Â select ATH79_DEV_LEDS_GPIO
>>> + Â Â select ATH79_DEV_SPI
>>> + Â Â help
>>> + Â Â Â Say 'Y' here if you want your kernel to support the
>>> + Â Â Â Ubiquiti Networks XM board.
>>> +
>>> Âendmenu
>>>
>>> Âconfig SOC_AR71XX
>>> @@ -33,6 +43,8 @@ config SOC_AR71XX
>>> Âconfig SOC_AR724X
>>> Â Â Â select USB_ARCH_HAS_EHCI
>>> Â Â Â select USB_ARCH_HAS_OHCI
>>> + Â Â select HW_HAS_PCI
>>> + Â Â select PCI
>>
>> Please don't select the whole PCI subsystem. Even if the hardware has PCI
>> support, not everyone wants to build a kernel with PCI support.
>>
>>> Â Â Â def_bool n
>>>
>>> Âconfig SOC_AR913X
>>> diff --git a/arch/mips/ath79/Makefile b/arch/mips/ath79/Makefile
>>> index c33d465..ac9f375 100644
>>> --- a/arch/mips/ath79/Makefile
>>> +++ b/arch/mips/ath79/Makefile
>>> @@ -26,3 +26,4 @@ obj-$(CONFIG_ATH79_DEV_SPI) Â Â Â Â += dev-spi.o
>>> Â#
>>> Âobj-$(CONFIG_ATH79_MACH_AP81) Â Â Â Â Â Â Â Â+= mach-ap81.o
>>> Âobj-$(CONFIG_ATH79_MACH_PB44) Â Â Â Â Â Â Â Â+= mach-pb44.o
>>> +obj-$(CONFIG_ATH79_MACH_UBNT_XM) Â Â += mach-ubnt-xm.o
>>> diff --git a/arch/mips/ath79/Platform b/arch/mips/ath79/Platform
>>> index 2bd6636..aca7ab1 100644
>>> --- a/arch/mips/ath79/Platform
>>> +++ b/arch/mips/ath79/Platform
>>> @@ -2,6 +2,7 @@
>>> Â# Atheros AR71xx/AR724x/AR913x
>>> Â#
>>>
>>> -platform-$(CONFIG_ATH79) Â Â += ath79/
>>> -cflags-$(CONFIG_ATH79) Â Â Â Â Â Â Â += -I$(srctree)/arch/mips/include/asm/mach-ath79
>>> -load-$(CONFIG_ATH79) Â Â Â Â = 0xffffffff80060000
>>> +platform-$(CONFIG_ATH79) Â Â Â Â Â Â += ath79/
>>> +cflags-$(CONFIG_ATH79) Â Â Â Â Â Â Â Â Â Â Â += -I$(srctree)/arch/mips/include/asm/mach-ath79
>>> +load-$(CONFIG_ATH79) Â Â Â Â Â Â Â Â = 0xffffffff80060000
>>> +load-$(CONFIG_ATH79_MACH_UBNT_XM) Â Â= 0xffffffff80002000
>>
>> Please don't add another load address here.The ath79 platform code has been
>> designed in a way which allows a single kernel image to run on all
>> AR71xx/AR724x/AR913X/AR933x based boards, and the 0x80060000 load address has
>> been chosen due to compatibility reasons. It allows to boot the kernel on older
>> boards which are using RedBoot as the bootloader. The U-Boot on the
>> AR724x/AR933x based boards can load the kernel to 0x8006000.
>>
>>> diff --git a/arch/mips/ath79/mach-ubnt-xm.c b/arch/mips/ath79/mach-ubnt-xm.c
>>> new file mode 100644
>>> index 0000000..150a0a0
>>> --- /dev/null
>>> +++ b/arch/mips/ath79/mach-ubnt-xm.c
>>> @@ -0,0 +1,110 @@
>>> +/*
>>> + * ÂUbiquiti Networks XM board support
>>> + *
>>> + * ÂCopyright (C) 2011 Renà Bolldorf <xsecute@xxxxxxxxxxxxxx>
>>> + *
>>> + * ÂDerived from: mach-pb44.c
>>> + *
>>> + * Â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/init.h>
>>> +#include <linux/pci.h>
>>> +#include <linux/ath9k_platform.h>
>>> +
>>> +#include "machtypes.h"
>>> +#include "dev-gpio-buttons.h"
>>> +#include "dev-leds-gpio.h"
>>> +#include "dev-spi.h"
>>> +
>>> +#define UBNT_XM_GPIO_LED_L1 Â Â Â Â Â0
>>> +#define UBNT_XM_GPIO_LED_L2 Â Â Â Â Â1
>>> +#define UBNT_XM_GPIO_LED_L3 Â Â Â Â Â11
>>> +#define UBNT_XM_GPIO_LED_L4 Â Â Â Â Â7
>>> +
>>> +#define UBNT_XM_GPIO_BTN_RESET Â Â Â Â Â Â Â 12
>>> +
>>> +#define UBNT_XM_KEYS_POLL_INTERVAL Â 20
>>> +#define UBNT_XM_KEYS_DEBOUNCE_INTERVAL Â Â Â (3 * UBNT_XM_KEYS_POLL_INTERVAL)
>>> +
>>> +#define UBNT_XM_PCI_IRQ Â Â Â Â Â Â Â Â Â Â Â48
>>> +#define UBNT_XM_EEPROM_ADDR Â Â Â Â Â(u8 *) KSEG1ADDR(0x1fff1000)
>>> +
>>> +static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
>>> + Â Â {
>>> +       .name      = "signal:poor",
>>> +       .gpio      = UBNT_XM_GPIO_LED_L1,
>>> +       .active_low   = 0,
>>> + Â Â }, {
>>> +       .name      = "signal:bad",
>>> +       .gpio      = UBNT_XM_GPIO_LED_L2,
>>> +       .active_low   = 0,
>>> + Â Â }, {
>>> +       .name      = "signal:good",
>>> +       .gpio      = UBNT_XM_GPIO_LED_L3,
>>> +       .active_low   = 0,
>>> + Â Â }, {
>>> +       .name      = "signal:excellent",
>>> +       .gpio      = UBNT_XM_GPIO_LED_L4,
>>> +       .active_low   = 0,
>>> + Â Â },
>>
>> The LED names should follow the Linux LED Device Naming convention.
>> See Documentation/leds/leds-class.txt.
>>
>>> +};
>>> +
>>> +static struct gpio_keys_button ubnt_xm_gpio_keys[] __initdata = {
>>> + Â Â {
>>> +       .desc      = "reset",
>>> +       .type      = EV_KEY,
>>> +       .code      = KEY_RESTART,
>>> + Â Â Â Â Â Â .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
>>> +       .gpio      = UBNT_XM_GPIO_BTN_RESET,
>>> +       .active_low   = 1,
>>> + Â Â }
>>> +};
>>> +
>>> +static struct spi_board_info ubnt_xm_spi_info[] = {
>>> + Â Â {
>>> +       .bus_num    Â= 0,
>>> +       .chip_select  Â= 0,
>>> +       .max_speed_hz  = 25000000,
>>> +       .modalias    = "mx25l6405d",
>>> + Â Â }
>>> +};
>>> +
>>> +static struct ath79_spi_platform_data ubnt_xm_spi_data = {
>>> +   .bus_num        Â= 0,
>>> +   .num_chipselect     = 1,
>>> +};
>>> +
>>> +static struct ath9k_platform_data ubnt_xm_eeprom_data;
>>> +
>>> +int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
>>> +{
>>> + Â Â return UBNT_XM_PCI_IRQ;
>>> +}
>>> +
>>> +int pcibios_plat_dev_init(struct pci_dev *dev)
>>> +{
>>> + Â Â dev->dev.platform_data = &ubnt_xm_eeprom_data;
>>> +
>>> + Â Â return 0;
>>> +}
>>
>> The 'pci_bios_map_irq' and 'pcibios_plat_dev_init' functions are global, so you
>> can have only one instance of them within the kernel. Adding these functions
>> into a machine specific file would prevent to build a kernel which supports
>> multiple different boards.
>>
>>> +
>>> +static void __init ubnt_xm_init(void)
>>> +{
>>> + Â Â ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
>>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âubnt_xm_leds_gpio);
>>
>> The Ubiquiti xM family has several different models. Registering all of the assigned
>> GPIO lines varies between the different boards.
>>
> I know that the GPIO lines from NanoBridge, Picostation and Rocket
> with board revision v1 are the same.
> I note this in the kconf help text.
>
> I improve the code and send a V2.
>
> Thank you for the hints.
>>> +
>>> + Â Â ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
>>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ARRAY_SIZE(ubnt_xm_gpio_keys),
>>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ubnt_xm_gpio_keys);
>>> +
>>> + Â Â ath79_register_spi(&ubnt_xm_spi_data, ubnt_xm_spi_info,
>>> + Â Â Â Â Â Â Â Â Â Â Â ÂARRAY_SIZE(ubnt_xm_spi_info));
>>> +
>>> + Â Â memcpy(ubnt_xm_eeprom_data.eeprom_data, UBNT_XM_EEPROM_ADDR,
>>> + Â Â Â Â Â Âsizeof(ubnt_xm_eeprom_data.eeprom_data));
>>> +}
>>> +
>>> +MIPS_MACHINE(ATH79_MACH_UBNT_XM, "UBNT-XM", "Ubiquiti Networks XM board", ubnt_xm_init);
>>> diff --git a/arch/mips/ath79/machtypes.h b/arch/mips/ath79/machtypes.h
>>> index 3940fe4..1bb0747 100644
>>> --- a/arch/mips/ath79/machtypes.h
>>> +++ b/arch/mips/ath79/machtypes.h
>>> @@ -18,6 +18,7 @@ enum ath79_mach_type {
>>> Â Â Â ATH79_MACH_GENERIC = 0,
>>> Â Â Â ATH79_MACH_AP81, Â Â Â Â Â Â Â Â/* Atheros AP81 reference board */
>>> Â Â Â ATH79_MACH_PB44, Â Â Â Â Â Â Â Â/* Atheros PB44 reference board */
>>> + Â Â ATH79_MACH_UBNT_XM, Â Â Â Â Â Â /* Ubiquiti Networks XM board */
>>> Â};
>>>
>>> Â#endif /* _ATH79_MACHTYPE_H */
>>
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/