~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/ralink/mt7620.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/mips/ralink/mt7620.c (Version linux-6.12-rc7) and /arch/ppc/ralink/mt7620.c (Version linux-6.3.13)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  *                                                
  4  * Parts of this file are based on Ralink's 2.    
  5  *                                                
  6  * Copyright (C) 2008-2011 Gabor Juhos <juhosg    
  7  * Copyright (C) 2008 Imre Kaloz <kaloz@openwr    
  8  * Copyright (C) 2013 John Crispin <john@phroz    
  9  */                                               
 10                                                   
 11 #include <linux/kernel.h>                         
 12 #include <linux/init.h>                           
 13 #include <linux/bug.h>                            
 14 #include <linux/slab.h>                           
 15 #include <linux/sys_soc.h>                        
 16                                                   
 17 #include <asm/mipsregs.h>                         
 18 #include <asm/mach-ralink/ralink_regs.h>          
 19 #include <asm/mach-ralink/mt7620.h>               
 20                                                   
 21 #include "common.h"                               
 22                                                   
 23 /* analog */                                      
 24 #define PMU0_CFG                0x88              
 25 #define PMU_SW_SET              BIT(28)           
 26 #define A_DCDC_EN               BIT(24)           
 27 #define A_SSC_PERI              BIT(19)           
 28 #define A_SSC_GEN               BIT(18)           
 29 #define A_SSC_M                 0x3               
 30 #define A_SSC_S                 16                
 31 #define A_DLY_M                 0x7               
 32 #define A_DLY_S                 8                 
 33 #define A_VTUNE_M               0xff              
 34                                                   
 35 /* digital */                                     
 36 #define PMU1_CFG                0x8C              
 37 #define DIG_SW_SEL              BIT(25)           
 38                                                   
 39 /* EFUSE bits */                                  
 40 #define EFUSE_MT7688            0x100000          
 41                                                   
 42 /* DRAM type bit */                               
 43 #define DRAM_TYPE_MT7628_MASK   0x1               
 44                                                   
 45 /* does the board have sdram or ddram */          
 46 static int dram_type;                             
 47                                                   
 48 static struct ralink_soc_info *soc_info_ptr;      
 49                                                   
 50 static __init void                                
 51 mt7620_dram_init(struct ralink_soc_info *soc_i    
 52 {                                                 
 53         switch (dram_type) {                      
 54         case SYSCFG0_DRAM_TYPE_SDRAM:             
 55                 pr_info("Board has SDRAM\n");     
 56                 soc_info->mem_size_min = MT762    
 57                 soc_info->mem_size_max = MT762    
 58                 break;                            
 59                                                   
 60         case SYSCFG0_DRAM_TYPE_DDR1:              
 61                 pr_info("Board has DDR1\n");      
 62                 soc_info->mem_size_min = MT762    
 63                 soc_info->mem_size_max = MT762    
 64                 break;                            
 65                                                   
 66         case SYSCFG0_DRAM_TYPE_DDR2:              
 67                 pr_info("Board has DDR2\n");      
 68                 soc_info->mem_size_min = MT762    
 69                 soc_info->mem_size_max = MT762    
 70                 break;                            
 71         default:                                  
 72                 BUG();                            
 73         }                                         
 74 }                                                 
 75                                                   
 76 static __init void                                
 77 mt7628_dram_init(struct ralink_soc_info *soc_i    
 78 {                                                 
 79         switch (dram_type) {                      
 80         case SYSCFG0_DRAM_TYPE_DDR1_MT7628:       
 81                 pr_info("Board has DDR1\n");      
 82                 soc_info->mem_size_min = MT762    
 83                 soc_info->mem_size_max = MT762    
 84                 break;                            
 85                                                   
 86         case SYSCFG0_DRAM_TYPE_DDR2_MT7628:       
 87                 pr_info("Board has DDR2\n");      
 88                 soc_info->mem_size_min = MT762    
 89                 soc_info->mem_size_max = MT762    
 90                 break;                            
 91         default:                                  
 92                 BUG();                            
 93         }                                         
 94 }                                                 
 95                                                   
 96 static unsigned int __init mt7620_get_soc_name    
 97 {                                                 
 98         return __raw_readl(MT7620_SYSC_BASE +     
 99 }                                                 
100                                                   
101 static unsigned int __init mt7620_get_soc_name    
102 {                                                 
103         return __raw_readl(MT7620_SYSC_BASE +     
104 }                                                 
105                                                   
106 static bool __init mt7620_soc_valid(void)         
107 {                                                 
108         if (mt7620_get_soc_name0() == MT7620_C    
109             mt7620_get_soc_name1() == MT7620_C    
110                 return true;                      
111         else                                      
112                 return false;                     
113 }                                                 
114                                                   
115 static bool __init mt7628_soc_valid(void)         
116 {                                                 
117         if (mt7620_get_soc_name0() == MT7620_C    
118             mt7620_get_soc_name1() == MT7628_C    
119                 return true;                      
120         else                                      
121                 return false;                     
122 }                                                 
123                                                   
124 static unsigned int __init mt7620_get_rev(void    
125 {                                                 
126         return __raw_readl(MT7620_SYSC_BASE +     
127 }                                                 
128                                                   
129 static unsigned int __init mt7620_get_bga(void    
130 {                                                 
131         return (mt7620_get_rev() >> CHIP_REV_P    
132 }                                                 
133                                                   
134 static unsigned int __init mt7620_get_efuse(vo    
135 {                                                 
136         return __raw_readl(MT7620_SYSC_BASE +     
137 }                                                 
138                                                   
139 static unsigned int __init mt7620_get_soc_ver(    
140 {                                                 
141         return (mt7620_get_rev() >> CHIP_REV_V    
142 }                                                 
143                                                   
144 static unsigned int __init mt7620_get_soc_eco(    
145 {                                                 
146         return (mt7620_get_rev() & CHIP_REV_EC    
147 }                                                 
148                                                   
149 static const char __init *mt7620_get_soc_name(    
150 {                                                 
151         if (mt7620_soc_valid()) {                 
152                 u32 bga = mt7620_get_bga();       
153                                                   
154                 if (bga) {                        
155                         ralink_soc = MT762X_SO    
156                         soc_info->compatible =    
157                         return "MT7620A";         
158                 } else {                          
159                         ralink_soc = MT762X_SO    
160                         soc_info->compatible =    
161                         return "MT7620N";         
162                 }                                 
163         } else if (mt7628_soc_valid()) {          
164                 u32 efuse = mt7620_get_efuse()    
165                 unsigned char *name = NULL;       
166                                                   
167                 if (efuse & EFUSE_MT7688) {       
168                         ralink_soc = MT762X_SO    
169                         name = "MT7688";          
170                 } else {                          
171                         ralink_soc = MT762X_SO    
172                         name = "MT7628AN";        
173                 }                                 
174                 soc_info->compatible = "ralink    
175                 return name;                      
176         } else {                                  
177                 panic("mt762x: unknown SoC, n0    
178                       mt7620_get_soc_name0(),     
179         }                                         
180 }                                                 
181                                                   
182 static const char __init *mt7620_get_soc_id_na    
183 {                                                 
184         if (ralink_soc == MT762X_SOC_MT7620A)     
185                 return "mt7620a";                 
186         else if (ralink_soc == MT762X_SOC_MT76    
187                 return "mt7620n";                 
188         else if (ralink_soc == MT762X_SOC_MT76    
189                 return "mt7688";                  
190         else if (ralink_soc == MT762X_SOC_MT76    
191                 return "mt7628n";                 
192         else                                      
193                 return "invalid";                 
194 }                                                 
195                                                   
196 static int __init mt7620_soc_dev_init(void)       
197 {                                                 
198         struct soc_device *soc_dev;               
199         struct soc_device_attribute *soc_dev_a    
200                                                   
201         soc_dev_attr = kzalloc(sizeof(*soc_dev    
202         if (!soc_dev_attr)                        
203                 return -ENOMEM;                   
204                                                   
205         soc_dev_attr->family = "Ralink";          
206         soc_dev_attr->soc_id = mt7620_get_soc_    
207                                                   
208         soc_dev_attr->data = soc_info_ptr;        
209                                                   
210         soc_dev = soc_device_register(soc_dev_    
211         if (IS_ERR(soc_dev)) {                    
212                 kfree(soc_dev_attr);              
213                 return PTR_ERR(soc_dev);          
214         }                                         
215                                                   
216         return 0;                                 
217 }                                                 
218 device_initcall(mt7620_soc_dev_init);             
219                                                   
220 void __init prom_soc_init(struct ralink_soc_in    
221 {                                                 
222         const char *name = mt7620_get_soc_name    
223         u32 cfg0;                                 
224         u32 pmu0;                                 
225         u32 pmu1;                                 
226                                                   
227         snprintf(soc_info->sys_type, RAMIPS_SY    
228                 "MediaTek %s ver:%u eco:%u",      
229                 name, mt7620_get_soc_ver(), mt    
230                                                   
231         cfg0 = __raw_readl(MT7620_SYSC_BASE +     
232         if (is_mt76x8()) {                        
233                 dram_type = cfg0 & DRAM_TYPE_M    
234         } else {                                  
235                 dram_type = (cfg0 >> SYSCFG0_D    
236                             SYSCFG0_DRAM_TYPE_    
237                 if (dram_type == SYSCFG0_DRAM_    
238                         dram_type = SYSCFG0_DR    
239         }                                         
240                                                   
241         soc_info->mem_base = MT7620_DRAM_BASE;    
242         if (is_mt76x8())                          
243                 mt7628_dram_init(soc_info);       
244         else                                      
245                 mt7620_dram_init(soc_info);       
246                                                   
247         pmu0 = __raw_readl(MT7620_SYSC_BASE +     
248         pmu1 = __raw_readl(MT7620_SYSC_BASE +     
249                                                   
250         pr_info("Analog PMU set to %s control\    
251                 (pmu0 & PMU_SW_SET) ? ("sw") :    
252         pr_info("Digital PMU set to %s control    
253                 (pmu1 & DIG_SW_SEL) ? ("sw") :    
254                                                   
255         soc_info_ptr = soc_info;                  
256 }                                                 
257                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php