Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Wills Wang | 833a1a8 | 2016-03-16 16:59:52 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Atheros AR71XX/AR724X/AR913X common definitions |
| 4 | * |
Rosy Song | bd905c3 | 2019-03-16 09:24:44 +0800 | [diff] [blame] | 5 | * Copyright (C) 2018-2019 Rosy Song <rosysong@rosinson.com> |
Wills Wang | 833a1a8 | 2016-03-16 16:59:52 +0800 | [diff] [blame] | 6 | * Copyright (C) 2015-2016 Wills Wang <wills.wang@live.com> |
| 7 | * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> |
| 8 | * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> |
Wills Wang | 833a1a8 | 2016-03-16 16:59:52 +0800 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef __ASM_MACH_ATH79_H |
| 12 | #define __ASM_MACH_ATH79_H |
| 13 | |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
Wills Wang | 833a1a8 | 2016-03-16 16:59:52 +0800 | [diff] [blame] | 15 | #include <linux/types.h> |
| 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
| 19 | enum ath79_soc_type { |
| 20 | ATH79_SOC_UNKNOWN, |
| 21 | ATH79_SOC_AR7130, |
| 22 | ATH79_SOC_AR7141, |
| 23 | ATH79_SOC_AR7161, |
| 24 | ATH79_SOC_AR7240, |
| 25 | ATH79_SOC_AR7241, |
| 26 | ATH79_SOC_AR7242, |
| 27 | ATH79_SOC_AR9130, |
| 28 | ATH79_SOC_AR9132, |
| 29 | ATH79_SOC_AR9330, |
| 30 | ATH79_SOC_AR9331, |
| 31 | ATH79_SOC_AR9341, |
| 32 | ATH79_SOC_AR9342, |
| 33 | ATH79_SOC_AR9344, |
| 34 | ATH79_SOC_QCA9533, |
| 35 | ATH79_SOC_QCA9556, |
| 36 | ATH79_SOC_QCA9558, |
| 37 | ATH79_SOC_TP9343, |
| 38 | ATH79_SOC_QCA9561, |
| 39 | }; |
| 40 | |
| 41 | static inline int soc_is_ar71xx(void) |
| 42 | { |
| 43 | return gd->arch.soc == ATH79_SOC_AR7130 || |
| 44 | gd->arch.soc == ATH79_SOC_AR7141 || |
| 45 | gd->arch.soc == ATH79_SOC_AR7161; |
| 46 | } |
| 47 | |
| 48 | static inline int soc_is_ar724x(void) |
| 49 | { |
| 50 | return gd->arch.soc == ATH79_SOC_AR7240 || |
| 51 | gd->arch.soc == ATH79_SOC_AR7241 || |
| 52 | gd->arch.soc == ATH79_SOC_AR7242; |
| 53 | } |
| 54 | |
| 55 | static inline int soc_is_ar7240(void) |
| 56 | { |
| 57 | return gd->arch.soc == ATH79_SOC_AR7240; |
| 58 | } |
| 59 | |
| 60 | static inline int soc_is_ar7241(void) |
| 61 | { |
| 62 | return gd->arch.soc == ATH79_SOC_AR7241; |
| 63 | } |
| 64 | |
| 65 | static inline int soc_is_ar7242(void) |
| 66 | { |
| 67 | return gd->arch.soc == ATH79_SOC_AR7242; |
| 68 | } |
| 69 | |
| 70 | static inline int soc_is_ar913x(void) |
| 71 | { |
| 72 | return gd->arch.soc == ATH79_SOC_AR9130 || |
| 73 | gd->arch.soc == ATH79_SOC_AR9132; |
| 74 | } |
| 75 | |
| 76 | static inline int soc_is_ar933x(void) |
| 77 | { |
| 78 | return gd->arch.soc == ATH79_SOC_AR9330 || |
| 79 | gd->arch.soc == ATH79_SOC_AR9331; |
| 80 | } |
| 81 | |
| 82 | static inline int soc_is_ar9341(void) |
| 83 | { |
| 84 | return gd->arch.soc == ATH79_SOC_AR9341; |
| 85 | } |
| 86 | |
| 87 | static inline int soc_is_ar9342(void) |
| 88 | { |
| 89 | return gd->arch.soc == ATH79_SOC_AR9342; |
| 90 | } |
| 91 | |
| 92 | static inline int soc_is_ar9344(void) |
| 93 | { |
| 94 | return gd->arch.soc == ATH79_SOC_AR9344; |
| 95 | } |
| 96 | |
| 97 | static inline int soc_is_ar934x(void) |
| 98 | { |
| 99 | return soc_is_ar9341() || |
| 100 | soc_is_ar9342() || |
| 101 | soc_is_ar9344(); |
| 102 | } |
| 103 | |
| 104 | static inline int soc_is_qca9533(void) |
| 105 | { |
| 106 | return gd->arch.soc == ATH79_SOC_QCA9533; |
| 107 | } |
| 108 | |
| 109 | static inline int soc_is_qca953x(void) |
| 110 | { |
| 111 | return soc_is_qca9533(); |
| 112 | } |
| 113 | |
| 114 | static inline int soc_is_qca9556(void) |
| 115 | { |
| 116 | return gd->arch.soc == ATH79_SOC_QCA9556; |
| 117 | } |
| 118 | |
| 119 | static inline int soc_is_qca9558(void) |
| 120 | { |
| 121 | return gd->arch.soc == ATH79_SOC_QCA9558; |
| 122 | } |
| 123 | |
| 124 | static inline int soc_is_qca955x(void) |
| 125 | { |
| 126 | return soc_is_qca9556() || soc_is_qca9558(); |
| 127 | } |
| 128 | |
| 129 | static inline int soc_is_tp9343(void) |
| 130 | { |
| 131 | return gd->arch.soc == ATH79_SOC_TP9343; |
| 132 | } |
| 133 | |
| 134 | static inline int soc_is_qca9561(void) |
| 135 | { |
| 136 | return gd->arch.soc == ATH79_SOC_QCA9561; |
| 137 | } |
| 138 | |
| 139 | static inline int soc_is_qca956x(void) |
| 140 | { |
| 141 | return soc_is_tp9343() || soc_is_qca9561(); |
| 142 | } |
| 143 | |
Wills Wang | ddc0552 | 2016-05-30 22:54:50 +0800 | [diff] [blame] | 144 | u32 ath79_get_bootstrap(void); |
Marek Vasut | c06cdad | 2016-05-06 20:10:39 +0200 | [diff] [blame] | 145 | int ath79_eth_reset(void); |
Marek Vasut | dff26d8 | 2016-05-06 20:10:37 +0200 | [diff] [blame] | 146 | int ath79_usb_reset(void); |
| 147 | |
Marek Vasut | 6a713ea | 2016-05-06 20:10:40 +0200 | [diff] [blame] | 148 | void ar934x_pll_init(const u16 cpu_mhz, const u16 ddr_mhz, const u16 ahb_mhz); |
| 149 | void ar934x_ddr_init(const u16 cpu_mhz, const u16 ddr_mhz, const u16 ahb_mhz); |
| 150 | |
Rosy Song | bd905c3 | 2019-03-16 09:24:44 +0800 | [diff] [blame] | 151 | void qca956x_pll_init(void); |
| 152 | void qca956x_ddr_init(void); |
Wills Wang | 833a1a8 | 2016-03-16 16:59:52 +0800 | [diff] [blame] | 153 | #endif /* __ASM_MACH_ATH79_H */ |