4 * Copyright (C) 2006, 2007 OpenWrt.org
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <asm/addrspace.h>
25 #include <linux/delay.h>
27 #define AR7_REGS_BASE 0x08610000
29 #define AR7_REGS_MAC0 (AR7_REGS_BASE + 0x0000)
30 #define AR7_REGS_EMIF (AR7_REGS_BASE + 0x0800)
31 #define AR7_REGS_GPIO (AR7_REGS_BASE + 0x0900)
32 #define AR7_REGS_POWER (AR7_REGS_BASE + 0x0a00)
33 #define AR7_REGS_WDT (AR7_REGS_BASE + 0x0b00)
34 #define AR7_REGS_UART0 (AR7_REGS_BASE + 0x0e00)
35 #define AR7_REGS_UART1 (AR7_REGS_BASE + 0x0f00)
36 #define AR7_REGS_RESET (AR7_REGS_BASE + 0x1600)
37 #define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800)
38 #define AR7_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1C00)
39 #define AR7_REGS_MDIO (AR7_REGS_BASE + 0x1E00)
40 #define AR7_REGS_IRQ (AR7_REGS_BASE + 0x2400)
41 #define AR7_REGS_MAC1 (AR7_REGS_BASE + 0x2800)
43 #define AR7_RESET_PEREPHERIAL 0x0
44 #define AR7_RESET_SOFTWARE 0x4
45 #define AR7_RESET_STATUS 0x8
47 #define AR7_RESET_BIT_MDIO 22
49 /* GPIO control registers */
50 #define AR7_GPIO_INPUT 0x0
51 #define AR7_GPIO_OUTPUT 0x4
52 #define AR7_GPIO_DIR 0x8
53 #define AR7_GPIO_ENABLE 0xC
55 #define AR7_GPIO_BIT_STATUS_LED 8
59 #define AR7_IRQ_UART0 15
60 #define AR7_IRQ_UART1 16
62 struct plat_cpmac_data
{
69 extern char *prom_getenv(char *envname
);
71 /* A bunch of small bit-toggling functions */
72 static inline u32
get_chip_id(void)
74 return *((u16
*)KSEG1ADDR(AR7_REGS_GPIO
+ 0x14));
77 static inline int ar7_cpu_freq(void)
79 u16 chip_id
= get_chip_id();
91 static inline int ar7_bus_freq(void)
93 u16 chip_id
= get_chip_id();
104 #define ar7_cpmac_freq ar7_bus_freq
106 static inline int ar7_has_high_cpmac(void)
108 u16 chip_id
= get_chip_id();
117 #define ar7_has_high_vlynq ar7_has_high_cpmac
119 static inline void ar7_device_enable(u32 bit
)
121 volatile u32
*reset_reg
= (u32
*)KSEG1ADDR(AR7_REGS_RESET
+ AR7_RESET_PEREPHERIAL
);
122 *reset_reg
|= (1 << bit
);
126 static inline void ar7_device_disable(u32 bit
)
128 volatile u32
*reset_reg
= (u32
*)KSEG1ADDR(AR7_REGS_RESET
+ AR7_RESET_PEREPHERIAL
);
129 *reset_reg
&= ~(1 << bit
);
133 static inline void ar7_device_reset(u32 bit
)
135 ar7_device_disable(bit
);
136 ar7_device_enable(bit
);
139 static inline void ar7_device_on(u32 bit
)
141 volatile u32
*power_reg
= (u32
*)KSEG1ADDR(AR7_REGS_POWER
);
142 *power_reg
|= (1 << bit
);
146 static inline void ar7_device_off(u32 bit
)
148 volatile u32
*power_reg
= (u32
*)KSEG1ADDR(AR7_REGS_POWER
);
149 *power_reg
&= ~(1 << bit
);
This page took 0.047523 seconds and 5 git commands to generate.