2 * MikroTik RouterBOARD 750 support
4 * Copyright (C) 2010-2012 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/export.h>
12 #include <linux/platform_device.h>
14 #include <asm/mach-ath79/ar71xx_regs.h>
15 #include <asm/mach-ath79/ath79.h>
16 #include <asm/mach-ath79/mach-rb750.h>
20 #include "machtypes.h"
22 static struct rb750_led_data rb750_leds
[] = {
24 .name
= "rb750:green:act",
25 .mask
= RB750_LED_ACT
,
28 .name
= "rb750:green:port1",
29 .mask
= RB750_LED_PORT5
,
32 .name
= "rb750:green:port2",
33 .mask
= RB750_LED_PORT4
,
36 .name
= "rb750:green:port3",
37 .mask
= RB750_LED_PORT3
,
40 .name
= "rb750:green:port4",
41 .mask
= RB750_LED_PORT2
,
44 .name
= "rb750:green:port5",
45 .mask
= RB750_LED_PORT1
,
50 static struct rb750_led_platform_data rb750_leds_data
= {
51 .num_leds
= ARRAY_SIZE(rb750_leds
),
55 static struct platform_device rb750_leds_device
= {
58 .platform_data
= &rb750_leds_data
,
62 static struct platform_device rb750_nand_device
= {
67 int rb750_latch_change(u32 mask_clr
, u32 mask_set
)
69 static DEFINE_SPINLOCK(lock
);
70 static u32 latch_set
= RB750_LED_BITS
| RB750_LVC573_LE
;
77 spin_lock_irqsave(&lock
, flags
);
79 if ((mask_clr
& BIT(31)) != 0 &&
80 (latch_set
& RB750_LVC573_LE
) == 0) {
84 latch_set
= (latch_set
| mask_set
) & ~mask_clr
;
85 latch_clr
= (latch_clr
| mask_clr
) & ~mask_set
;
88 latch_oe
= __raw_readl(ath79_gpio_base
+ AR71XX_GPIO_REG_OE
);
90 if (likely(latch_set
& RB750_LVC573_LE
)) {
91 void __iomem
*base
= ath79_gpio_base
;
93 t
= __raw_readl(base
+ AR71XX_GPIO_REG_OE
);
94 t
|= mask_clr
| latch_oe
| mask_set
;
96 __raw_writel(t
, base
+ AR71XX_GPIO_REG_OE
);
97 __raw_writel(latch_clr
, base
+ AR71XX_GPIO_REG_CLEAR
);
98 __raw_writel(latch_set
, base
+ AR71XX_GPIO_REG_SET
);
99 } else if (mask_clr
& RB750_LVC573_LE
) {
100 void __iomem
*base
= ath79_gpio_base
;
102 latch_oe
= __raw_readl(base
+ AR71XX_GPIO_REG_OE
);
103 __raw_writel(RB750_LVC573_LE
, base
+ AR71XX_GPIO_REG_CLEAR
);
105 __raw_readl(base
+ AR71XX_GPIO_REG_CLEAR
);
111 spin_unlock_irqrestore(&lock
, flags
);
114 EXPORT_SYMBOL_GPL(rb750_latch_change
);
116 void rb750_nand_pins_enable(void)
118 ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE
,
119 AR724X_GPIO_FUNC_SPI_EN
);
121 EXPORT_SYMBOL_GPL(rb750_nand_pins_enable
);
123 void rb750_nand_pins_disable(void)
125 ath79_gpio_function_setup(AR724X_GPIO_FUNC_SPI_EN
,
126 AR724X_GPIO_FUNC_JTAG_DISABLE
);
128 EXPORT_SYMBOL_GPL(rb750_nand_pins_disable
);
130 static void __init
rb750_setup(void)
132 ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
133 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
134 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
135 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
136 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
138 ath79_init_mac(ath79_eth0_data
.mac_addr
, ath79_mac_base
, 0);
139 ath79_init_mac(ath79_eth1_data
.mac_addr
, ath79_mac_base
, 1);
141 ath79_register_mdio(0, 0x0);
144 ath79_register_eth(1);
147 ath79_register_eth(0);
149 platform_device_register(&rb750_leds_device
);
150 platform_device_register(&rb750_nand_device
);
153 MIPS_MACHINE(ATH79_MACH_RB_750
, "750i", "MikroTik RouterBOARD 750",