1 From f2501ad7f47f0b912b53e3e2094e9bfe12f2a491 Mon Sep 17 00:00:00 2001
2 From: Mike Frysinger <vapier.adi@gmail.com>
3 Date: Fri, 4 Jan 2008 17:05:28 -0500
4 Subject: [PATCH] use syscontrol functions where possible
6 this works on my bf548-ezkit 0.1 and should use the bootrom func to
7 program the memory which means the otp fps will be taken into account
9 cpu/blackfin/initcode.c | 57 +++++++++++++++++++++++++++++-----------------
10 cpu/blackfin/reset.c | 8 +++++-
11 2 files changed, 42 insertions(+), 23 deletions(-)
13 diff --git a/cpu/blackfin/initcode.c b/cpu/blackfin/initcode.c
14 index 360caa8..1e39043 100644
15 --- a/cpu/blackfin/initcode.c
16 +++ b/cpu/blackfin/initcode.c
17 @@ -299,34 +299,49 @@ void initcode(ADI_BOOT_DATA *bootstruct)
18 bfin_write_SIC_IWR(1);
22 + /* With newer bootroms, we use the helper function to set up
23 + * the memory controller. Older bootroms lacks such helpers
24 + * so we do it ourselves.
26 + if (BOOTROM_CAPS_SYSCONTROL) {
29 - bfin_write_PLL_LOCKCNT(CONFIG_PLL_LOCKCNT_VAL);
30 + ADI_SYSCTRL_VALUES memory_settings;
31 + memory_settings.uwVrCtl = CONFIG_VR_CTL_VAL;
32 + memory_settings.uwPllCtl = CONFIG_PLL_CTL_VAL;
33 + memory_settings.uwPllDiv = CONFIG_PLL_DIV_VAL;
34 + memory_settings.uwPllLockCnt = CONFIG_PLL_LOCKCNT_VAL;
35 + syscontrol(SYSCTRL_WRITE | SYSCTRL_PLLCTL | SYSCTRL_PLLDIV | SYSCTRL_VRCTL | SYSCTRL_INTVOLTAGE, &memory_settings, NULL);
40 + bfin_write_PLL_LOCKCNT(CONFIG_PLL_LOCKCNT_VAL);
42 - /* Only reprogram when needed to avoid triggering unnecessary
43 - * PLL relock sequences.
45 - if (bfin_read_VR_CTL() != CONFIG_VR_CTL_VAL) {
47 - bfin_write_VR_CTL(CONFIG_VR_CTL_VAL);
53 + /* Only reprogram when needed to avoid triggering unnecessary
54 + * PLL relock sequences.
56 + if (bfin_read_VR_CTL() != CONFIG_VR_CTL_VAL) {
58 + bfin_write_VR_CTL(CONFIG_VR_CTL_VAL);
62 - bfin_write_PLL_DIV(CONFIG_PLL_DIV_VAL);
66 + bfin_write_PLL_DIV(CONFIG_PLL_DIV_VAL);
68 - /* Only reprogram when needed to avoid triggering unnecessary
69 - * PLL relock sequences.
71 - if (bfin_read_PLL_CTL() != CONFIG_PLL_CTL_VAL) {
73 - bfin_write_PLL_CTL(CONFIG_PLL_CTL_VAL);
77 + /* Only reprogram when needed to avoid triggering unnecessary
78 + * PLL relock sequences.
80 + if (bfin_read_PLL_CTL() != CONFIG_PLL_CTL_VAL) {
82 + bfin_write_PLL_CTL(CONFIG_PLL_CTL_VAL);
87 /* Since we've changed the SCLK above, we may need to update
88 diff --git a/cpu/blackfin/reset.c b/cpu/blackfin/reset.c
89 index b796740..be08d80 100644
90 --- a/cpu/blackfin/reset.c
91 +++ b/cpu/blackfin/reset.c
95 #include <asm/blackfin.h>
96 +#include <asm/mach-common/bits/bootrom.h>
99 /* A system soft reset makes external memory unusable so force
103 __attribute__ ((__l1_text__, __noreturn__))
104 -void bfin_reset(void)
105 +static void bfin_reset(void)
107 /* Wait for completion of "system" events such as cache line
108 * line fills so that we avoid infinite stalls later on as
109 @@ -75,7 +76,10 @@ static inline void bfin_reset_trampoline(void)
113 - asm("jump (%0);" : : "a" (bfin_reset));
114 + if (0 /*BOOTROM_CAPS_SYSCONTROL -- current silicon is broken*/)
115 + syscontrol(SYSCTRL_SOFTRESET, NULL, NULL);
117 + asm("jump (%0);" : : "a" (bfin_reset));
120 __attribute__ ((__noreturn__))