2 * MikroTik RouterBOARD 750 support
4 * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/platform_device.h>
12 #include <asm/mach-ar71xx/ar71xx.h>
13 #include <asm/mach-ar71xx/mach-rb750.h>
16 #include "dev-ap91-eth.h"
18 static struct rb750_led_data rb750_leds
[] = {
20 .name
= "rb750:green:act",
21 .mask
= RB750_LED_ACT
,
24 .name
= "rb750:green:port1",
25 .mask
= RB750_LED_PORT5
,
28 .name
= "rb750:green:port2",
29 .mask
= RB750_LED_PORT4
,
32 .name
= "rb750:green:port3",
33 .mask
= RB750_LED_PORT3
,
36 .name
= "rb750:green:port4",
37 .mask
= RB750_LED_PORT2
,
40 .name
= "rb750:green:port5",
41 .mask
= RB750_LED_PORT1
,
46 static struct rb750_led_platform_data rb750_leds_data
= {
47 .num_leds
= ARRAY_SIZE(rb750_leds
),
51 static struct platform_device rb750_leds_device
= {
54 .platform_data
= &rb750_leds_data
,
58 static const char *rb750_port_names
[AP91_ETH_NUM_PORT_NAMES
] __initdata
= {
65 static struct platform_device rb750_nand_device
= {
70 int rb750_latch_change(u32 mask_clr
, u32 mask_set
)
72 static DEFINE_SPINLOCK(lock
);
73 static u32 latch_set
= RB750_LED_BITS
| RB750_LVC573_LE
;
80 spin_lock_irqsave(&lock
, flags
);
82 if ((mask_clr
& BIT(31)) != 0 &&
83 (latch_set
& RB750_LVC573_LE
) == 0) {
87 latch_set
= (latch_set
| mask_set
) & ~mask_clr
;
88 latch_clr
= (latch_clr
| mask_clr
) & ~mask_set
;
91 latch_oe
= __raw_readl(ar71xx_gpio_base
+ GPIO_REG_OE
);
93 if (likely(latch_set
& RB750_LVC573_LE
)) {
94 void __iomem
*base
= ar71xx_gpio_base
;
96 t
= __raw_readl(base
+ GPIO_REG_OE
);
97 t
|= mask_clr
| latch_oe
| mask_set
;
99 __raw_writel(t
, base
+ GPIO_REG_OE
);
100 __raw_writel(latch_clr
, base
+ GPIO_REG_CLEAR
);
101 __raw_writel(latch_set
, base
+ GPIO_REG_SET
);
102 } else if (mask_clr
& RB750_LVC573_LE
) {
103 void __iomem
*base
= ar71xx_gpio_base
;
105 latch_oe
= __raw_readl(base
+ GPIO_REG_OE
);
106 __raw_writel(RB750_LVC573_LE
, base
+ GPIO_REG_CLEAR
);
108 __raw_readl(base
+ GPIO_REG_CLEAR
);
114 spin_unlock_irqrestore(&lock
, flags
);
117 EXPORT_SYMBOL_GPL(rb750_latch_change
);
119 static void __init
rb750_setup(void)
121 ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
122 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
123 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
124 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
125 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
127 ap91_eth_init(NULL
, rb750_port_names
);
128 platform_device_register(&rb750_leds_device
);
129 platform_device_register(&rb750_nand_device
);
132 MIPS_MACHINE(AR71XX_MACH_RB_750
, "750i", "MikroTik RouterBOARD 750",