aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel/setup.c
diff options
context:
space:
mode:
authorBob Liu <lliubbo@gmail.com>2012-05-16 05:37:24 -0400
committerBob Liu <lliubbo@gmail.com>2012-05-21 02:54:12 -0400
commitb5affb0147cee0ea05d909396f8e389092729236 (patch)
tree483471450269ac65f7748b5408c7f77520421d55 /arch/blackfin/kernel/setup.c
parent22a826288522863fb748851824ce634eda4f1b07 (diff)
blackfin: add bf60x to current framework
This patch added bf60x to current blackfin kernel framework. Signed-off-by: Bob Liu <lliubbo@gmail.com>
Diffstat (limited to 'arch/blackfin/kernel/setup.c')
-rw-r--r--arch/blackfin/kernel/setup.c159
1 files changed, 141 insertions, 18 deletions
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index 2ad747e909fb..c113cfa459a7 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -25,6 +25,7 @@
25#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
26#include <asm/blackfin.h> 26#include <asm/blackfin.h>
27#include <asm/cplbinit.h> 27#include <asm/cplbinit.h>
28#include <asm/clocks.h>
28#include <asm/div64.h> 29#include <asm/div64.h>
29#include <asm/cpu.h> 30#include <asm/cpu.h>
30#include <asm/fixed_code.h> 31#include <asm/fixed_code.h>
@@ -550,7 +551,6 @@ static __init void memory_setup(void)
550{ 551{
551#ifdef CONFIG_MTD_UCLINUX 552#ifdef CONFIG_MTD_UCLINUX
552 unsigned long mtd_phys = 0; 553 unsigned long mtd_phys = 0;
553 unsigned long n;
554#endif 554#endif
555 unsigned long max_mem; 555 unsigned long max_mem;
556 556
@@ -594,9 +594,9 @@ static __init void memory_setup(void)
594 mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8))); 594 mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));
595 595
596# if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS) 596# if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS)
597 n = ext2_image_size((void *)(mtd_phys + 0x400)); 597 if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC)
598 if (n) 598 mtd_size =
599 mtd_size = PAGE_ALIGN(n * 1024); 599 PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10);
600# endif 600# endif
601 601
602# if defined(CONFIG_CRAMFS) 602# if defined(CONFIG_CRAMFS)
@@ -612,7 +612,8 @@ static __init void memory_setup(void)
612 612
613 /* ROM_FS is XIP, so if we found it, we need to limit memory */ 613 /* ROM_FS is XIP, so if we found it, we need to limit memory */
614 if (memory_end > max_mem) { 614 if (memory_end > max_mem) {
615 pr_info("Limiting kernel memory to %liMB due to anomaly 05000263\n", max_mem >> 20); 615 pr_info("Limiting kernel memory to %liMB due to anomaly 05000263\n",
616 (max_mem - CONFIG_PHY_RAM_BASE_ADDRESS) >> 20);
616 memory_end = max_mem; 617 memory_end = max_mem;
617 } 618 }
618 } 619 }
@@ -642,7 +643,8 @@ static __init void memory_setup(void)
642 * doesn't exist, or we don't need to - then dont. 643 * doesn't exist, or we don't need to - then dont.
643 */ 644 */
644 if (memory_end > max_mem) { 645 if (memory_end > max_mem) {
645 pr_info("Limiting kernel memory to %liMB due to anomaly 05000263\n", max_mem >> 20); 646 pr_info("Limiting kernel memory to %liMB due to anomaly 05000263\n",
647 (max_mem - CONFIG_PHY_RAM_BASE_ADDRESS) >> 20);
646 memory_end = max_mem; 648 memory_end = max_mem;
647 } 649 }
648 650
@@ -661,8 +663,8 @@ static __init void memory_setup(void)
661 init_mm.end_data = (unsigned long)_edata; 663 init_mm.end_data = (unsigned long)_edata;
662 init_mm.brk = (unsigned long)0; 664 init_mm.brk = (unsigned long)0;
663 665
664 printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20); 666 printk(KERN_INFO "Board Memory: %ldMB\n", (physical_mem_end - CONFIG_PHY_RAM_BASE_ADDRESS) >> 20);
665 printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20); 667 printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", (_ramend - CONFIG_PHY_RAM_BASE_ADDRESS) >> 20);
666 668
667 printk(KERN_INFO "Memory map:\n" 669 printk(KERN_INFO "Memory map:\n"
668 " fixedcode = 0x%p-0x%p\n" 670 " fixedcode = 0x%p-0x%p\n"
@@ -705,7 +707,7 @@ void __init find_min_max_pfn(void)
705 int i; 707 int i;
706 708
707 max_pfn = 0; 709 max_pfn = 0;
708 min_low_pfn = memory_end; 710 min_low_pfn = PFN_DOWN(memory_end);
709 711
710 for (i = 0; i < bfin_memmap.nr_map; i++) { 712 for (i = 0; i < bfin_memmap.nr_map; i++) {
711 unsigned long start, end; 713 unsigned long start, end;
@@ -748,8 +750,7 @@ static __init void setup_bootmem_allocator(void)
748 /* pfn of the first usable page frame after kernel image*/ 750 /* pfn of the first usable page frame after kernel image*/
749 if (min_low_pfn < memory_start >> PAGE_SHIFT) 751 if (min_low_pfn < memory_start >> PAGE_SHIFT)
750 min_low_pfn = memory_start >> PAGE_SHIFT; 752 min_low_pfn = memory_start >> PAGE_SHIFT;
751 753 start_pfn = CONFIG_PHY_RAM_BASE_ADDRESS >> PAGE_SHIFT;
752 start_pfn = PAGE_OFFSET >> PAGE_SHIFT;
753 end_pfn = memory_end >> PAGE_SHIFT; 754 end_pfn = memory_end >> PAGE_SHIFT;
754 755
755 /* 756 /*
@@ -794,8 +795,8 @@ static __init void setup_bootmem_allocator(void)
794 } 795 }
795 796
796 /* reserve memory before memory_start, including bootmap */ 797 /* reserve memory before memory_start, including bootmap */
797 reserve_bootmem(PAGE_OFFSET, 798 reserve_bootmem(CONFIG_PHY_RAM_BASE_ADDRESS,
798 memory_start + bootmap_size + PAGE_SIZE - 1 - PAGE_OFFSET, 799 memory_start + bootmap_size + PAGE_SIZE - 1 - CONFIG_PHY_RAM_BASE_ADDRESS,
799 BOOTMEM_DEFAULT); 800 BOOTMEM_DEFAULT);
800} 801}
801 802
@@ -844,13 +845,40 @@ static inline int __init get_mem_size(void)
844 break; 845 break;
845 } 846 }
846 switch (ddrctl & 0x30000) { 847 switch (ddrctl & 0x30000) {
847 case DEVWD_4: ret *= 2; 848 case DEVWD_4:
848 case DEVWD_8: ret *= 2; 849 ret *= 2;
849 case DEVWD_16: break; 850 case DEVWD_8:
851 ret *= 2;
852 case DEVWD_16:
853 break;
850 } 854 }
851 if ((ddrctl & 0xc000) == 0x4000) 855 if ((ddrctl & 0xc000) == 0x4000)
852 ret *= 2; 856 ret *= 2;
853 return ret; 857 return ret;
858#elif defined(CONFIG_BF60x)
859 u32 ddrctl = bfin_read_DDR0_CFG();
860 int ret;
861 switch (ddrctl & 0xf00) {
862 case DEVSZ_64:
863 ret = 64 / 8;
864 break;
865 case DEVSZ_128:
866 ret = 128 / 8;
867 break;
868 case DEVSZ_256:
869 ret = 256 / 8;
870 break;
871 case DEVSZ_512:
872 ret = 512 / 8;
873 break;
874 case DEVSZ_1G:
875 ret = 1024 / 8;
876 break;
877 case DEVSZ_2G:
878 ret = 2048 / 8;
879 break;
880 }
881 return ret;
854#endif 882#endif
855 BUG(); 883 BUG();
856} 884}
@@ -864,12 +892,14 @@ void __init setup_arch(char **cmdline_p)
864{ 892{
865 u32 mmr; 893 u32 mmr;
866 unsigned long sclk, cclk; 894 unsigned long sclk, cclk;
895 struct clk *clk;
867 896
868 native_machine_early_platform_add_devices(); 897 native_machine_early_platform_add_devices();
869 898
870 enable_shadow_console(); 899 enable_shadow_console();
871 900
872 /* Check to make sure we are running on the right processor */ 901 /* Check to make sure we are running on the right processor */
902 mmr = bfin_cpuid();
873 if (unlikely(CPUID != bfin_cpuid())) 903 if (unlikely(CPUID != bfin_cpuid()))
874 printk(KERN_ERR "ERROR: Not running on ADSP-%s: unknown CPUID 0x%04x Rev 0.%d\n", 904 printk(KERN_ERR "ERROR: Not running on ADSP-%s: unknown CPUID 0x%04x Rev 0.%d\n",
875 CPU, bfin_cpuid(), bfin_revid()); 905 CPU, bfin_cpuid(), bfin_revid());
@@ -890,6 +920,10 @@ void __init setup_arch(char **cmdline_p)
890 920
891 memset(&bfin_memmap, 0, sizeof(bfin_memmap)); 921 memset(&bfin_memmap, 0, sizeof(bfin_memmap));
892 922
923#ifdef CONFIG_BF60x
924 /* Should init clock device before parse command early */
925 clk_init();
926#endif
893 /* If the user does not specify things on the command line, use 927 /* If the user does not specify things on the command line, use
894 * what the bootloader set things up as 928 * what the bootloader set things up as
895 */ 929 */
@@ -904,6 +938,7 @@ void __init setup_arch(char **cmdline_p)
904 938
905 memory_setup(); 939 memory_setup();
906 940
941#ifndef CONFIG_BF60x
907 /* Initialize Async memory banks */ 942 /* Initialize Async memory banks */
908 bfin_write_EBIU_AMBCTL0(AMBCTL0VAL); 943 bfin_write_EBIU_AMBCTL0(AMBCTL0VAL);
909 bfin_write_EBIU_AMBCTL1(AMBCTL1VAL); 944 bfin_write_EBIU_AMBCTL1(AMBCTL1VAL);
@@ -913,6 +948,7 @@ void __init setup_arch(char **cmdline_p)
913 bfin_write_EBIU_MODE(CONFIG_EBIU_MODEVAL); 948 bfin_write_EBIU_MODE(CONFIG_EBIU_MODEVAL);
914 bfin_write_EBIU_FCTL(CONFIG_EBIU_FCTLVAL); 949 bfin_write_EBIU_FCTL(CONFIG_EBIU_FCTLVAL);
915#endif 950#endif
951#endif
916#ifdef CONFIG_BFIN_HYSTERESIS_CONTROL 952#ifdef CONFIG_BFIN_HYSTERESIS_CONTROL
917 bfin_write_PORTF_HYSTERESIS(HYST_PORTF_0_15); 953 bfin_write_PORTF_HYSTERESIS(HYST_PORTF_0_15);
918 bfin_write_PORTG_HYSTERESIS(HYST_PORTG_0_15); 954 bfin_write_PORTG_HYSTERESIS(HYST_PORTG_0_15);
@@ -921,8 +957,24 @@ void __init setup_arch(char **cmdline_p)
921 ~HYST_NONEGPIO_MASK) | HYST_NONEGPIO); 957 ~HYST_NONEGPIO_MASK) | HYST_NONEGPIO);
922#endif 958#endif
923 959
960#ifdef CONFIG_BF60x
961 clk = clk_get(NULL, "CCLK");
962 if (!IS_ERR(clk)) {
963 cclk = clk_get_rate(clk);
964 clk_put(clk);
965 } else
966 cclk = 0;
967
968 clk = clk_get(NULL, "SCLK0");
969 if (!IS_ERR(clk)) {
970 sclk = clk_get_rate(clk);
971 clk_put(clk);
972 } else
973 sclk = 0;
974#else
924 cclk = get_cclk(); 975 cclk = get_cclk();
925 sclk = get_sclk(); 976 sclk = get_sclk();
977#endif
926 978
927 if ((ANOMALY_05000273 || ANOMALY_05000274) && (cclk >> 1) < sclk) 979 if ((ANOMALY_05000273 || ANOMALY_05000274) && (cclk >> 1) < sclk)
928 panic("ANOMALY 05000273 or 05000274: CCLK must be >= 2*SCLK"); 980 panic("ANOMALY 05000273 or 05000274: CCLK must be >= 2*SCLK");
@@ -938,7 +990,7 @@ void __init setup_arch(char **cmdline_p)
938 printk(KERN_INFO "Hardware Trace %s and %sabled\n", 990 printk(KERN_INFO "Hardware Trace %s and %sabled\n",
939 (mmr & 0x1) ? "active" : "off", 991 (mmr & 0x1) ? "active" : "off",
940 (mmr & 0x2) ? "en" : "dis"); 992 (mmr & 0x2) ? "en" : "dis");
941 993#ifndef CONFIG_BF60x
942 mmr = bfin_read_SYSCR(); 994 mmr = bfin_read_SYSCR();
943 printk(KERN_INFO "Boot Mode: %i\n", mmr & 0xF); 995 printk(KERN_INFO "Boot Mode: %i\n", mmr & 0xF);
944 996
@@ -980,7 +1032,7 @@ void __init setup_arch(char **cmdline_p)
980 printk(KERN_INFO "Recovering from Watchdog event\n"); 1032 printk(KERN_INFO "Recovering from Watchdog event\n");
981 else if (_bfin_swrst & RESET_SOFTWARE) 1033 else if (_bfin_swrst & RESET_SOFTWARE)
982 printk(KERN_NOTICE "Reset caused by Software reset\n"); 1034 printk(KERN_NOTICE "Reset caused by Software reset\n");
983 1035#endif
984 printk(KERN_INFO "Blackfin support (C) 2004-2010 Analog Devices, Inc.\n"); 1036 printk(KERN_INFO "Blackfin support (C) 2004-2010 Analog Devices, Inc.\n");
985 if (bfin_compiled_revid() == 0xffff) 1037 if (bfin_compiled_revid() == 0xffff)
986 printk(KERN_INFO "Compiled for ADSP-%s Rev any, running on 0.%d\n", CPU, bfin_revid()); 1038 printk(KERN_INFO "Compiled for ADSP-%s Rev any, running on 0.%d\n", CPU, bfin_revid());
@@ -1060,10 +1112,12 @@ subsys_initcall(topology_init);
1060 1112
1061/* Get the input clock frequency */ 1113/* Get the input clock frequency */
1062static u_long cached_clkin_hz = CONFIG_CLKIN_HZ; 1114static u_long cached_clkin_hz = CONFIG_CLKIN_HZ;
1115#ifndef CONFIG_BF60x
1063static u_long get_clkin_hz(void) 1116static u_long get_clkin_hz(void)
1064{ 1117{
1065 return cached_clkin_hz; 1118 return cached_clkin_hz;
1066} 1119}
1120#endif
1067static int __init early_init_clkin_hz(char *buf) 1121static int __init early_init_clkin_hz(char *buf)
1068{ 1122{
1069 cached_clkin_hz = simple_strtoul(buf, NULL, 0); 1123 cached_clkin_hz = simple_strtoul(buf, NULL, 0);
@@ -1075,6 +1129,7 @@ static int __init early_init_clkin_hz(char *buf)
1075} 1129}
1076early_param("clkin_hz=", early_init_clkin_hz); 1130early_param("clkin_hz=", early_init_clkin_hz);
1077 1131
1132#ifndef CONFIG_BF60x
1078/* Get the voltage input multiplier */ 1133/* Get the voltage input multiplier */
1079static u_long get_vco(void) 1134static u_long get_vco(void)
1080{ 1135{
@@ -1097,10 +1152,23 @@ static u_long get_vco(void)
1097 cached_vco *= msel; 1152 cached_vco *= msel;
1098 return cached_vco; 1153 return cached_vco;
1099} 1154}
1155#endif
1100 1156
1101/* Get the Core clock */ 1157/* Get the Core clock */
1102u_long get_cclk(void) 1158u_long get_cclk(void)
1103{ 1159{
1160#ifdef CONFIG_BF60x
1161 struct clk *cclk;
1162 u_long cclk_rate;
1163
1164 cclk = clk_get(NULL, "CCLK");
1165 if (IS_ERR(cclk))
1166 return 0;
1167
1168 cclk_rate = clk_get_rate(cclk);
1169 clk_put(cclk);
1170 return cclk_rate;
1171#else
1104 static u_long cached_cclk_pll_div, cached_cclk; 1172 static u_long cached_cclk_pll_div, cached_cclk;
1105 u_long csel, ssel; 1173 u_long csel, ssel;
1106 1174
@@ -1120,12 +1188,66 @@ u_long get_cclk(void)
1120 else 1188 else
1121 cached_cclk = get_vco() >> csel; 1189 cached_cclk = get_vco() >> csel;
1122 return cached_cclk; 1190 return cached_cclk;
1191#endif
1123} 1192}
1124EXPORT_SYMBOL(get_cclk); 1193EXPORT_SYMBOL(get_cclk);
1125 1194
1195#ifdef CONFIG_BF60x
1196/* Get the bf60x clock of SCLK0 domain */
1197u_long get_sclk0(void)
1198{
1199 struct clk *sclk0;
1200 u_long sclk0_rate;
1201
1202 sclk0 = clk_get(NULL, "SCLK0");
1203 if (IS_ERR(sclk0))
1204 return 0;
1205
1206 sclk0_rate = clk_get_rate(sclk0);
1207 clk_put(sclk0);
1208 return sclk0_rate;
1209}
1210EXPORT_SYMBOL(get_sclk0);
1211
1212/* Get the bf60x clock of SCLK1 domain */
1213u_long get_sclk1(void)
1214{
1215 struct clk *sclk1;
1216 u_long sclk1_rate;
1217
1218 sclk1 = clk_get(NULL, "SCLK1");
1219 if (IS_ERR(sclk1))
1220 return 0;
1221
1222 sclk1_rate = clk_get_rate(sclk1);
1223 clk_put(sclk1);
1224 return sclk1_rate;
1225}
1226EXPORT_SYMBOL(get_sclk1);
1227
1228/* Get the bf60x DRAM clock */
1229u_long get_dclk(void)
1230{
1231 struct clk *dclk;
1232 u_long dclk_rate;
1233
1234 dclk = clk_get(NULL, "DCLK");
1235 if (IS_ERR(dclk))
1236 return 0;
1237
1238 dclk_rate = clk_get_rate(dclk);
1239 clk_put(dclk);
1240 return dclk_rate;
1241}
1242EXPORT_SYMBOL(get_dclk);
1243#endif
1244
1126/* Get the System clock */ 1245/* Get the System clock */
1127u_long get_sclk(void) 1246u_long get_sclk(void)
1128{ 1247{
1248#ifdef CONFIG_BF60x
1249 return get_sclk0();
1250#else
1129 static u_long cached_sclk; 1251 static u_long cached_sclk;
1130 u_long ssel; 1252 u_long ssel;
1131 1253
@@ -1146,6 +1268,7 @@ u_long get_sclk(void)
1146 1268
1147 cached_sclk = get_vco() / ssel; 1269 cached_sclk = get_vco() / ssel;
1148 return cached_sclk; 1270 return cached_sclk;
1271#endif
1149} 1272}
1150EXPORT_SYMBOL(get_sclk); 1273EXPORT_SYMBOL(get_sclk);
1151 1274