]> git.wh0rd.org - patches.git/blob - 0001-use-syscontrol-functions-where-possible.patch
more random patches. who knows.
[patches.git] / 0001-use-syscontrol-functions-where-possible.patch
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
5
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
8 ---
9 cpu/blackfin/initcode.c | 57 +++++++++++++++++++++++++++++-----------------
10 cpu/blackfin/reset.c | 8 +++++-
11 2 files changed, 42 insertions(+), 23 deletions(-)
12
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);
19 #endif
20
21 - serial_putc('L');
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.
25 + */
26 + if (BOOTROM_CAPS_SYSCONTROL) {
27 + serial_putc('S');
28
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);
36 + } else {
37 + serial_putc('L');
38
39 - serial_putc('A');
40 + bfin_write_PLL_LOCKCNT(CONFIG_PLL_LOCKCNT_VAL);
41
42 - /* Only reprogram when needed to avoid triggering unnecessary
43 - * PLL relock sequences.
44 - */
45 - if (bfin_read_VR_CTL() != CONFIG_VR_CTL_VAL) {
46 - serial_putc('!');
47 - bfin_write_VR_CTL(CONFIG_VR_CTL_VAL);
48 - asm("idle;");
49 - }
50 + serial_putc('A');
51
52 - serial_putc('C');
53 + /* Only reprogram when needed to avoid triggering unnecessary
54 + * PLL relock sequences.
55 + */
56 + if (bfin_read_VR_CTL() != CONFIG_VR_CTL_VAL) {
57 + serial_putc('!');
58 + bfin_write_VR_CTL(CONFIG_VR_CTL_VAL);
59 + asm("idle;");
60 + }
61
62 - bfin_write_PLL_DIV(CONFIG_PLL_DIV_VAL);
63 + serial_putc('C');
64
65 - serial_putc('K');
66 + bfin_write_PLL_DIV(CONFIG_PLL_DIV_VAL);
67
68 - /* Only reprogram when needed to avoid triggering unnecessary
69 - * PLL relock sequences.
70 - */
71 - if (bfin_read_PLL_CTL() != CONFIG_PLL_CTL_VAL) {
72 - serial_putc('!');
73 - bfin_write_PLL_CTL(CONFIG_PLL_CTL_VAL);
74 - asm("idle;");
75 + serial_putc('K');
76 +
77 + /* Only reprogram when needed to avoid triggering unnecessary
78 + * PLL relock sequences.
79 + */
80 + if (bfin_read_PLL_CTL() != CONFIG_PLL_CTL_VAL) {
81 + serial_putc('!');
82 + bfin_write_PLL_CTL(CONFIG_PLL_CTL_VAL);
83 + asm("idle;");
84 + }
85 }
86
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
92 @@ -8,6 +8,7 @@
93 #include <common.h>
94 #include <command.h>
95 #include <asm/blackfin.h>
96 +#include <asm/mach-common/bits/bootrom.h>
97 #include "cpu.h"
98
99 /* A system soft reset makes external memory unusable so force
100 @@ -19,7 +20,7 @@
101 * the core reset.
102 */
103 __attribute__ ((__l1_text__, __noreturn__))
104 -void bfin_reset(void)
105 +static void bfin_reset(void)
106 {
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)
110 if (board_reset)
111 board_reset();
112 while (1)
113 - asm("jump (%0);" : : "a" (bfin_reset));
114 + if (0 /*BOOTROM_CAPS_SYSCONTROL -- current silicon is broken*/)
115 + syscontrol(SYSCTRL_SOFTRESET, NULL, NULL);
116 + else
117 + asm("jump (%0);" : : "a" (bfin_reset));
118 }
119
120 __attribute__ ((__noreturn__))
121 --
122 1.5.5.3
123