| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * arch/sh/kernel/cpu/sh3/probe.c | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * CPU Subtype Probing for SH-3. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 1999, 2000  Niibe Yutaka | 
					
						
							|  |  |  |  * Copyright (C) 2002  Paul Mundt | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is subject to the terms and conditions of the GNU General Public | 
					
						
							|  |  |  |  * License.  See the file "COPYING" in the main directory of this archive | 
					
						
							|  |  |  |  * for more details. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/init.h>
 | 
					
						
							|  |  |  | #include <asm/processor.h>
 | 
					
						
							|  |  |  | #include <asm/cache.h>
 | 
					
						
							|  |  |  | #include <asm/io.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-18 17:10:12 -04:00
										 |  |  | void cpu_probe(void) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	unsigned long addr0, addr1, data0, data1, data2, data3; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-30 17:06:36 +09:00
										 |  |  | 	jump_to_uncached(); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Check if the entry shadows or not. | 
					
						
							|  |  |  | 	 * When shadowed, it's 128-entry system. | 
					
						
							|  |  |  | 	 * Otherwise, it's 256-entry system. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	addr0 = CACHE_OC_ADDRESS_ARRAY + (3 << 12); | 
					
						
							|  |  |  | 	addr1 = CACHE_OC_ADDRESS_ARRAY + (1 << 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* First, write back & invalidate */ | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 	data0  = __raw_readl(addr0); | 
					
						
							|  |  |  | 	__raw_writel(data0&~(SH_CACHE_VALID|SH_CACHE_UPDATED), addr0); | 
					
						
							|  |  |  | 	data1  = __raw_readl(addr1); | 
					
						
							|  |  |  | 	__raw_writel(data1&~(SH_CACHE_VALID|SH_CACHE_UPDATED), addr1); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Next, check if there's shadow or not */ | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 	data0 = __raw_readl(addr0); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	data0 ^= SH_CACHE_VALID; | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 	__raw_writel(data0, addr0); | 
					
						
							|  |  |  | 	data1 = __raw_readl(addr1); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	data2 = data1 ^ SH_CACHE_VALID; | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 	__raw_writel(data2, addr1); | 
					
						
							|  |  |  | 	data3 = __raw_readl(addr0); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Lastly, invaliate them. */ | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 	__raw_writel(data0&~SH_CACHE_VALID, addr0); | 
					
						
							|  |  |  | 	__raw_writel(data2&~SH_CACHE_VALID, addr1); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-30 17:06:36 +09:00
										 |  |  | 	back_to_cached(); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 	boot_cpu_data.dcache.ways		= 4; | 
					
						
							|  |  |  | 	boot_cpu_data.dcache.entry_shift	= 4; | 
					
						
							|  |  |  | 	boot_cpu_data.dcache.linesz		= L1_CACHE_BYTES; | 
					
						
							|  |  |  | 	boot_cpu_data.dcache.flags		= 0; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * 7709A/7729 has 16K cache (256-entry), while 7702 has only | 
					
						
							|  |  |  | 	 * 2K(direct) 7702 is not supported (yet) | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	if (data0 == data1 && data2 == data3) {	/* Shadow */ | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 		boot_cpu_data.dcache.way_incr	= (1 << 11); | 
					
						
							|  |  |  | 		boot_cpu_data.dcache.entry_mask	= 0x7f0; | 
					
						
							|  |  |  | 		boot_cpu_data.dcache.sets	= 128; | 
					
						
							|  |  |  | 		boot_cpu_data.type = CPU_SH7708; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 		boot_cpu_data.flags |= CPU_HAS_MMU_PAGE_ASSOC; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	} else {				/* 7709A or 7729  */ | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 		boot_cpu_data.dcache.way_incr	= (1 << 12); | 
					
						
							|  |  |  | 		boot_cpu_data.dcache.entry_mask	= 0xff0; | 
					
						
							|  |  |  | 		boot_cpu_data.dcache.sets	= 256; | 
					
						
							|  |  |  | 		boot_cpu_data.type = CPU_SH7729; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-09-27 17:38:11 +09:00
										 |  |  | #if defined(CONFIG_CPU_SUBTYPE_SH7706)
 | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 		boot_cpu_data.type = CPU_SH7706; | 
					
						
							| 
									
										
										
										
											2006-09-27 17:38:11 +09:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | #if defined(CONFIG_CPU_SUBTYPE_SH7710)
 | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 		boot_cpu_data.type = CPU_SH7710; | 
					
						
							| 
									
										
										
										
											2006-09-27 17:38:11 +09:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2007-03-27 18:13:51 +09:00
										 |  |  | #if defined(CONFIG_CPU_SUBTYPE_SH7712)
 | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 		boot_cpu_data.type = CPU_SH7712; | 
					
						
							| 
									
										
										
										
											2007-03-27 18:13:51 +09:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2007-08-20 08:59:33 +09:00
										 |  |  | #if defined(CONFIG_CPU_SUBTYPE_SH7720)
 | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 		boot_cpu_data.type = CPU_SH7720; | 
					
						
							| 
									
										
										
										
											2007-08-20 08:59:33 +09:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2007-12-26 11:45:06 +09:00
										 |  |  | #if defined(CONFIG_CPU_SUBTYPE_SH7721)
 | 
					
						
							|  |  |  | 		boot_cpu_data.type = CPU_SH7721; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #if defined(CONFIG_CPU_SUBTYPE_SH7705)
 | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 		boot_cpu_data.type = CPU_SH7705; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if defined(CONFIG_SH7705_CACHE_32KB)
 | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 		boot_cpu_data.dcache.way_incr	= (1 << 13); | 
					
						
							|  |  |  | 		boot_cpu_data.dcache.entry_mask	= 0x1ff0; | 
					
						
							|  |  |  | 		boot_cpu_data.dcache.sets	= 512; | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 		__raw_writel(CCR_CACHE_32KB, CCR3_REG); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 		__raw_writel(CCR_CACHE_16KB, CCR3_REG); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * SH-3 doesn't have separate caches | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2007-09-27 18:18:39 +09:00
										 |  |  | 	boot_cpu_data.dcache.flags |= SH_CACHE_COMBINED; | 
					
						
							|  |  |  | 	boot_cpu_data.icache = boot_cpu_data.dcache; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-15 10:48:13 +09:00
										 |  |  | 	boot_cpu_data.family = CPU_FAMILY_SH3; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | } |