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>
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 struct platform_device rb750_nand_device
= {
63 int rb750_latch_change(u32 mask_clr
, u32 mask_set
)
65 static DEFINE_SPINLOCK(lock
);
66 static u32 latch_set
= RB750_LED_BITS
| RB750_LVC573_LE
;
73 spin_lock_irqsave(&lock
, flags
);
75 if ((mask_clr
& BIT(31)) != 0 &&
76 (latch_set
& RB750_LVC573_LE
) == 0) {
80 latch_set
= (latch_set
| mask_set
) & ~mask_clr
;
81 latch_clr
= (latch_clr
| mask_clr
) & ~mask_set
;
84 latch_oe
= __raw_readl(ar71xx_gpio_base
+ GPIO_REG_OE
);
86 if (likely(latch_set
& RB750_LVC573_LE
)) {
87 void __iomem
*base
= ar71xx_gpio_base
;
89 t
= __raw_readl(base
+ GPIO_REG_OE
);
90 t
|= mask_clr
| latch_oe
| mask_set
;
92 __raw_writel(t
, base
+ GPIO_REG_OE
);
93 __raw_writel(latch_clr
, base
+ GPIO_REG_CLEAR
);
94 __raw_writel(latch_set
, base
+ GPIO_REG_SET
);
95 } else if (mask_clr
& RB750_LVC573_LE
) {
96 void __iomem
*base
= ar71xx_gpio_base
;
98 latch_oe
= __raw_readl(base
+ GPIO_REG_OE
);
99 __raw_writel(RB750_LVC573_LE
, base
+ GPIO_REG_CLEAR
);
101 __raw_readl(base
+ GPIO_REG_CLEAR
);
107 spin_unlock_irqrestore(&lock
, flags
);
110 EXPORT_SYMBOL_GPL(rb750_latch_change
);
112 static void __init
rb750_setup(void)
114 ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
115 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
116 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
117 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
118 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
120 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, ar71xx_mac_base
, 0);
121 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, ar71xx_mac_base
, 1);
124 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
125 ar71xx_eth0_data
.speed
= SPEED_100
;
126 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
129 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
130 ar71xx_eth1_data
.speed
= SPEED_1000
;
131 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
132 ar71xx_eth1_data
.has_ar7240_switch
= 1;
134 ar71xx_add_device_mdio(0x0);
135 ar71xx_add_device_eth(1);
136 ar71xx_add_device_eth(0);
138 platform_device_register(&rb750_leds_device
);
139 platform_device_register(&rb750_nand_device
);
142 MIPS_MACHINE(AR71XX_MACH_RB_750
, "750i", "MikroTik RouterBOARD 750",