X-Git-Url: http://git.ozo.com/?a=blobdiff_plain;f=target%2Flinux%2Far71xx%2Ffiles%2Farch%2Fmips%2Far71xx%2Fmach-rb750.c;h=1698db9146426ac7535e5df4d970dc14af4622f8;hb=7ee68b0bf39237ac6fa0f3137be865c4048e2e64;hp=dd481d9eb92773b3c5e5173ad6c29fdeaf9e77c3;hpb=8221ebb0200c30f1896ae82a03c29d5a0916c685;p=openwrt-10.03%2F.git diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb750.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb750.c index dd481d9eb..1698db914 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb750.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb750.c @@ -8,14 +8,113 @@ * by the Free Software Foundation. */ +#include #include +#include #include "machtype.h" #include "dev-ap91-eth.h" +static struct rb750_led_data rb750_leds[] = { + { + .name = "rb750:green:act", + .mask = RB750_LED_ACT, + .active_low = 1, + }, { + .name = "rb750:green:port1", + .mask = RB750_LED_PORT5, + .active_low = 1, + }, { + .name = "rb750:green:port2", + .mask = RB750_LED_PORT4, + .active_low = 1, + }, { + .name = "rb750:green:port3", + .mask = RB750_LED_PORT3, + .active_low = 1, + }, { + .name = "rb750:green:port4", + .mask = RB750_LED_PORT2, + .active_low = 1, + }, { + .name = "rb750:green:port5", + .mask = RB750_LED_PORT1, + .active_low = 1, + } +}; + +static struct rb750_led_platform_data rb750_leds_data = { + .num_leds = ARRAY_SIZE(rb750_leds), + .leds = rb750_leds, +}; + +static struct platform_device rb750_leds_device = { + .name = "leds-rb750", + .id = -1, + .dev = { + .platform_data = &rb750_leds_data, + } +}; + +int rb750_latch_change(u32 mask_clr, u32 mask_set) +{ + static DEFINE_SPINLOCK(lock); + static u32 latch_set = RB750_LED_BITS | RB750_LVC573_LE; + static u32 latch_oe; + static u32 latch_clr; + unsigned long flags; + u32 t; + int ret = 0; + + spin_lock_irqsave(&lock, flags); + + if ((mask_clr & BIT(31)) != 0 && + (latch_set & RB750_LVC573_LE) == 0) { + goto unlock; + } + + latch_set = (latch_set | mask_set) & ~mask_clr; + latch_clr = (latch_clr | mask_clr) & ~mask_set; + + if (latch_oe == 0) + latch_oe = __raw_readl(ar71xx_gpio_base + GPIO_REG_OE); + + if (likely(latch_set & RB750_LVC573_LE)) { + void __iomem *base = ar71xx_gpio_base; + + t = __raw_readl(base + GPIO_REG_OE); + t |= mask_clr | latch_oe | mask_set; + + __raw_writel(t, base + GPIO_REG_OE); + __raw_writel(latch_clr, base + GPIO_REG_CLEAR); + __raw_writel(latch_set, base + GPIO_REG_SET); + } else if (mask_clr & RB750_LVC573_LE) { + void __iomem *base = ar71xx_gpio_base; + + latch_oe = __raw_readl(base + GPIO_REG_OE); + __raw_writel(RB750_LVC573_LE, base + GPIO_REG_CLEAR); + /* flush write */ + __raw_readl(base + GPIO_REG_CLEAR); + } + + ret = 1; + + unlock: + spin_unlock_irqrestore(&lock, flags); + return ret; +} +EXPORT_SYMBOL_GPL(rb750_latch_change); + static void __init rb750_setup(void) { + ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN | + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN | + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN | + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN | + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN); + ap91_eth_init(NULL); + platform_device_register(&rb750_leds_device); } MIPS_MACHINE(AR71XX_MACH_RB_750, "750i", "MikroTik RouterBOARD 750",