1313#include <linux/percpu.h>
1414#include <linux/param.h>
1515#include <linux/errno.h>
16+ #include <linux/clk.h>
1617
1718#include <asm/setup.h>
1819#include <asm/sysreg.h>
@@ -187,9 +188,20 @@ static int __init topology_init(void)
187188
188189subsys_initcall (topology_init );
189190
191+ struct chip_id_map {
192+ u16 mid ;
193+ u16 pn ;
194+ const char * name ;
195+ };
196+
197+ static const struct chip_id_map chip_names [] = {
198+ { .mid = 0x1f , .pn = 0x1e82 , .name = "AT32AP700x" },
199+ };
200+ #define NR_CHIP_NAMES ARRAY_SIZE(chip_names)
201+
190202static const char * cpu_names [] = {
191203 "Morgan" ,
192- "AP7000 " ,
204+ "AP7 " ,
193205};
194206#define NR_CPU_NAMES ARRAY_SIZE(cpu_names)
195207
@@ -206,12 +218,32 @@ static const char *mmu_types[] = {
206218 "MPU"
207219};
208220
221+ static const char * cpu_feature_flags [] = {
222+ "rmw" , "dsp" , "simd" , "ocd" , "perfctr" , "java" , "fpu" ,
223+ };
224+
225+ static const char * get_chip_name (struct avr32_cpuinfo * cpu )
226+ {
227+ unsigned int i ;
228+ unsigned int mid = avr32_get_manufacturer_id (cpu );
229+ unsigned int pn = avr32_get_product_number (cpu );
230+
231+ for (i = 0 ; i < NR_CHIP_NAMES ; i ++ ) {
232+ if (chip_names [i ].mid == mid && chip_names [i ].pn == pn )
233+ return chip_names [i ].name ;
234+ }
235+
236+ return "(unknown)" ;
237+ }
238+
209239void __init setup_processor (void )
210240{
211241 unsigned long config0 , config1 ;
212242 unsigned long features ;
213243 unsigned cpu_id , cpu_rev , arch_id , arch_rev , mmu_type ;
244+ unsigned device_id ;
214245 unsigned tmp ;
246+ unsigned i ;
215247
216248 config0 = sysreg_read (CONFIG0 );
217249 config1 = sysreg_read (CONFIG1 );
@@ -221,11 +253,14 @@ void __init setup_processor(void)
221253 arch_rev = SYSREG_BFEXT (AR , config0 );
222254 mmu_type = SYSREG_BFEXT (MMUT , config0 );
223255
256+ device_id = ocd_read (DID );
257+
224258 boot_cpu_data .arch_type = arch_id ;
225259 boot_cpu_data .cpu_type = cpu_id ;
226260 boot_cpu_data .arch_revision = arch_rev ;
227261 boot_cpu_data .cpu_revision = cpu_rev ;
228262 boot_cpu_data .tlb_config = mmu_type ;
263+ boot_cpu_data .device_id = device_id ;
229264
230265 tmp = SYSREG_BFEXT (ILSZ , config1 );
231266 if (tmp ) {
@@ -247,41 +282,34 @@ void __init setup_processor(void)
247282 return ;
248283 }
249284
250- printk ("CPU: %s [%02x] revision %d (%s revision %d)\n" ,
285+ printk ("CPU: %s chip revision %c\n" , get_chip_name (& boot_cpu_data ),
286+ avr32_get_chip_revision (& boot_cpu_data ) + 'A' );
287+ printk ("CPU: %s [%02x] core revision %d (%s arch revision %d)\n" ,
251288 cpu_names [cpu_id ], cpu_id , cpu_rev ,
252289 arch_names [arch_id ], arch_rev );
253290 printk ("CPU: MMU configuration: %s\n" , mmu_types [mmu_type ]);
254291
255292 printk ("CPU: features:" );
256293 features = 0 ;
257- if (config0 & SYSREG_BIT (CONFIG0_R )) {
294+ if (config0 & SYSREG_BIT (CONFIG0_R ))
258295 features |= AVR32_FEATURE_RMW ;
259- printk (" rmw" );
260- }
261- if (config0 & SYSREG_BIT (CONFIG0_D )) {
296+ if (config0 & SYSREG_BIT (CONFIG0_D ))
262297 features |= AVR32_FEATURE_DSP ;
263- printk (" dsp" );
264- }
265- if (config0 & SYSREG_BIT (CONFIG0_S )) {
298+ if (config0 & SYSREG_BIT (CONFIG0_S ))
266299 features |= AVR32_FEATURE_SIMD ;
267- printk (" simd" );
268- }
269- if (config0 & SYSREG_BIT (CONFIG0_O )) {
300+ if (config0 & SYSREG_BIT (CONFIG0_O ))
270301 features |= AVR32_FEATURE_OCD ;
271- printk (" ocd" );
272- }
273- if (config0 & SYSREG_BIT (CONFIG0_P )) {
302+ if (config0 & SYSREG_BIT (CONFIG0_P ))
274303 features |= AVR32_FEATURE_PCTR ;
275- printk (" perfctr" );
276- }
277- if (config0 & SYSREG_BIT (CONFIG0_J )) {
304+ if (config0 & SYSREG_BIT (CONFIG0_J ))
278305 features |= AVR32_FEATURE_JAVA ;
279- printk (" java" );
280- }
281- if (config0 & SYSREG_BIT (CONFIG0_F )) {
306+ if (config0 & SYSREG_BIT (CONFIG0_F ))
282307 features |= AVR32_FEATURE_FPU ;
283- printk (" fpu" );
284- }
308+
309+ for (i = 0 ; i < ARRAY_SIZE (cpu_feature_flags ); i ++ )
310+ if (features & (1 << i ))
311+ printk (" %s" , cpu_feature_flags [i ]);
312+
285313 printk ("\n" );
286314 boot_cpu_data .features = features ;
287315}
@@ -291,6 +319,8 @@ static int c_show(struct seq_file *m, void *v)
291319{
292320 unsigned int icache_size , dcache_size ;
293321 unsigned int cpu = smp_processor_id ();
322+ unsigned int freq ;
323+ unsigned int i ;
294324
295325 icache_size = boot_cpu_data .icache .ways *
296326 boot_cpu_data .icache .sets *
@@ -301,15 +331,21 @@ static int c_show(struct seq_file *m, void *v)
301331
302332 seq_printf (m , "processor\t: %d\n" , cpu );
303333
334+ seq_printf (m , "chip type\t: %s revision %c\n" ,
335+ get_chip_name (& boot_cpu_data ),
336+ avr32_get_chip_revision (& boot_cpu_data ) + 'A' );
304337 if (boot_cpu_data .arch_type < NR_ARCH_NAMES )
305- seq_printf (m , "cpu family \t: %s revision %d\n" ,
338+ seq_printf (m , "cpu arch \t: %s revision %d\n" ,
306339 arch_names [boot_cpu_data .arch_type ],
307340 boot_cpu_data .arch_revision );
308341 if (boot_cpu_data .cpu_type < NR_CPU_NAMES )
309- seq_printf (m , "cpu type \t: %s revision %d\n" ,
342+ seq_printf (m , "cpu core \t: %s revision %d\n" ,
310343 cpu_names [boot_cpu_data .cpu_type ],
311344 boot_cpu_data .cpu_revision );
312345
346+ freq = (clk_get_rate (boot_cpu_data .clk ) + 500 ) / 1000 ;
347+ seq_printf (m , "cpu MHz\t\t: %u.%03u\n" , freq / 1000 , freq % 1000 );
348+
313349 seq_printf (m , "i-cache\t\t: %dK (%u ways x %u sets x %u)\n" ,
314350 icache_size >> 10 ,
315351 boot_cpu_data .icache .ways ,
@@ -320,7 +356,13 @@ static int c_show(struct seq_file *m, void *v)
320356 boot_cpu_data .dcache .ways ,
321357 boot_cpu_data .dcache .sets ,
322358 boot_cpu_data .dcache .linesz );
323- seq_printf (m , "bogomips\t: %lu.%02lu\n" ,
359+
360+ seq_printf (m , "features\t:" );
361+ for (i = 0 ; i < ARRAY_SIZE (cpu_feature_flags ); i ++ )
362+ if (boot_cpu_data .features & (1 << i ))
363+ seq_printf (m , " %s" , cpu_feature_flags [i ]);
364+
365+ seq_printf (m , "\nbogomips\t: %lu.%02lu\n" ,
324366 boot_cpu_data .loops_per_jiffy / (500000 /HZ ),
325367 (boot_cpu_data .loops_per_jiffy / (5000 /HZ )) % 100 );
326368
0 commit comments