2 * Copyright (c) 2010 Adrian Chadd
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef __AR5315_CPUDEF_H__
30 #define __AR5315_CPUDEF_H__
32 struct ar5315_cpu_def {
33 void (* detect_mem_size) (void);
34 void (* detect_sys_frequency) (void);
35 void (* ar5315_chip_device_reset) (void);
36 void (* ar5315_chip_device_start) (void);
37 int (* ar5315_chip_device_stopped) (uint32_t);
38 void (* ar5315_chip_set_pll_ge) (int, int);
39 void (* ar5315_chip_set_mii_speed) (uint32_t, uint32_t);
40 void (* ar5315_chip_ddr_flush_ge) (int);
41 uint32_t (* ar5315_chip_get_eth_pll) (unsigned int, int);
42 void (* ar5315_chip_soc_init) (void);
45 * Allow to change MII bus mode:
46 * AR5315_ARGE_MII_MODE_MII
47 * AR5315_ARGE_MII_MODE_RMII
48 * AR5315_ARGE_MII_MODE_GMII
49 * AR5315_ARGE_MII_MODE_RGMII
50 * mii_mode(unit, mode);
52 #define AR5315_ARGE_MII_MODE_MII 0x0100
53 #define AR5315_ARGE_MII_MODE_RMII 0x0101
54 #define AR5315_ARGE_MII_MODE_GMII 0x1000
55 #define AR5315_ARGE_MII_MODE_RGMII 0x1001
56 void (* ar5315_chip_set_mii_mode) (int, int, int);
59 extern struct ar5315_cpu_def * ar5315_cpu_ops;
61 static inline void ar531x_detect_mem_size(void)
63 ar5315_cpu_ops->detect_mem_size();
66 static inline void ar531x_detect_sys_frequency(void)
68 ar5315_cpu_ops->detect_sys_frequency();
71 static inline void ar531x_device_reset(void)
73 ar5315_cpu_ops->ar5315_chip_device_reset();
76 static inline void ar531x_device_start(void)
78 ar5315_cpu_ops->ar5315_chip_device_start();
81 static inline int ar531x_device_stopped(uint32_t mask)
83 return ar5315_cpu_ops->ar5315_chip_device_stopped(mask);
86 static inline void ar531x_device_set_pll_ge(int unit, int speed)
88 ar5315_cpu_ops->ar5315_chip_set_pll_ge(unit, speed);
91 static inline void ar531x_device_set_mii_speed(int unit, int speed)
93 ar5315_cpu_ops->ar5315_chip_set_mii_speed(unit, speed);
96 static inline void ar531x_device_flush_ddr_ge(int unit)
98 ar5315_cpu_ops->ar5315_chip_ddr_flush_ge(unit);
101 static inline void ar531x_device_soc_init(void)
103 ar5315_cpu_ops->ar5315_chip_soc_init();
106 static inline void ar531x_device_set_mii_mode(int unit, int mode, int speed)
108 ar5315_cpu_ops->ar5315_chip_set_mii_mode(unit, mode, speed);
111 /* XXX shouldn't be here! */
112 extern uint32_t u_ar531x_cpu_freq;
113 extern uint32_t u_ar531x_ahb_freq;
114 extern uint32_t u_ar531x_ddr_freq;
116 extern uint32_t u_ar531x_uart_addr;
118 extern uint32_t u_ar531x_gpio_di;
119 extern uint32_t u_ar531x_gpio_do;
120 extern uint32_t u_ar531x_gpio_cr;
121 extern uint32_t u_ar531x_gpio_pins;
123 extern uint32_t u_ar531x_wdog_ctl;
124 extern uint32_t u_ar531x_wdog_timer;
126 static inline uint32_t ar531x_cpu_freq(void) { return u_ar531x_cpu_freq; }
127 static inline uint32_t ar531x_ahb_freq(void) { return u_ar531x_ahb_freq; }
128 static inline uint32_t ar531x_ddr_freq(void) { return u_ar531x_ddr_freq; }
130 static inline uint32_t ar531x_uart_addr(void) { return u_ar531x_uart_addr; }
132 static inline uint32_t ar531x_gpio_di(void) { return u_ar531x_gpio_di; }
133 static inline uint32_t ar531x_gpio_cr(void) { return u_ar531x_gpio_cr; }
134 static inline uint32_t ar531x_gpio_do(void) { return u_ar531x_gpio_do; }
135 static inline uint32_t ar531x_gpio_pins(void) { return u_ar531x_gpio_pins; }
137 static inline uint32_t ar531x_wdog_ctl(void) { return u_ar531x_wdog_ctl; }
138 static inline uint32_t ar531x_wdog_timer(void) { return u_ar531x_wdog_timer; }