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>
17 #include "dev-ap91-eth.h"
19 static struct rb750_led_data rb750_leds
[] = {
21 .name
= "rb750:green:act",
22 .mask
= RB750_LED_ACT
,
25 .name
= "rb750:green:port1",
26 .mask
= RB750_LED_PORT5
,
29 .name
= "rb750:green:port2",
30 .mask
= RB750_LED_PORT4
,
33 .name
= "rb750:green:port3",
34 .mask
= RB750_LED_PORT3
,
37 .name
= "rb750:green:port4",
38 .mask
= RB750_LED_PORT2
,
41 .name
= "rb750:green:port5",
42 .mask
= RB750_LED_PORT1
,
47 static struct rb750_led_platform_data rb750_leds_data
= {
48 .num_leds
= ARRAY_SIZE(rb750_leds
),
52 static struct platform_device rb750_leds_device
= {
55 .platform_data
= &rb750_leds_data
,
59 static const char *rb750_port_names
[AP91_ETH_NUM_PORT_NAMES
] __initdata
= {
66 static struct platform_device rb750_nand_device
= {
71 int rb750_latch_change(u32 mask_clr
, u32 mask_set
)
73 static DEFINE_SPINLOCK(lock
);
74 static u32 latch_set
= RB750_LED_BITS
| RB750_LVC573_LE
;
81 spin_lock_irqsave(&lock
, flags
);
83 if ((mask_clr
& BIT(31)) != 0 &&
84 (latch_set
& RB750_LVC573_LE
) == 0) {
88 latch_set
= (latch_set
| mask_set
) & ~mask_clr
;
89 latch_clr
= (latch_clr
| mask_clr
) & ~mask_set
;
92 latch_oe
= __raw_readl(ar71xx_gpio_base
+ GPIO_REG_OE
);
94 if (likely(latch_set
& RB750_LVC573_LE
)) {
95 void __iomem
*base
= ar71xx_gpio_base
;
97 t
= __raw_readl(base
+ GPIO_REG_OE
);
98 t
|= mask_clr
| latch_oe
| mask_set
;
100 __raw_writel(t
, base
+ GPIO_REG_OE
);
101 __raw_writel(latch_clr
, base
+ GPIO_REG_CLEAR
);
102 __raw_writel(latch_set
, base
+ GPIO_REG_SET
);
103 } else if (mask_clr
& RB750_LVC573_LE
) {
104 void __iomem
*base
= ar71xx_gpio_base
;
106 latch_oe
= __raw_readl(base
+ GPIO_REG_OE
);
107 __raw_writel(RB750_LVC573_LE
, base
+ GPIO_REG_CLEAR
);
109 __raw_readl(base
+ GPIO_REG_CLEAR
);
115 spin_unlock_irqrestore(&lock
, flags
);
118 EXPORT_SYMBOL_GPL(rb750_latch_change
);
120 static void __init
rb750_setup(void)
122 ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
123 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
124 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
125 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
126 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
128 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, ar71xx_mac_base
, 0);
129 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, ar71xx_mac_base
, 1);
130 ap91_eth_init(rb750_port_names
);
132 platform_device_register(&rb750_leds_device
);
133 platform_device_register(&rb750_nand_device
);
136 MIPS_MACHINE(AR71XX_MACH_RB_750
, "750i", "MikroTik RouterBOARD 750",