1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <common.h>
21#include <asm/cpm_8260.h>
22
23DECLARE_GLOBAL_DATA_PTR;
24
25void
26m8260_cpm_reset(void)
27{
28 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
29 volatile ulong count;
30
31
32
33 gd->arch.dp_alloc_base = CPM_DATAONLY_BASE;
34 gd->arch.dp_alloc_top = gd->arch.dp_alloc_base + CPM_DATAONLY_SIZE;
35
36
37
38
39 immr->im_cpm.cp_cpcr = CPM_CR_RST;
40 count = 0;
41 do {
42 __asm__ __volatile__ ("eieio");
43 } while ((immr->im_cpm.cp_cpcr & CPM_CR_FLG) && ++count < 1000000);
44
45#ifdef CONFIG_HARD_I2C
46 immr->im_dprambase16[PROFF_I2C_BASE / sizeof(u16)] = 0;
47#endif
48}
49
50
51
52
53
54uint
55m8260_cpm_dpalloc(uint size, uint align)
56{
57 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
58 uint retloc;
59 uint align_mask, off;
60 uint savebase;
61
62 align_mask = align - 1;
63 savebase = gd->arch.dp_alloc_base;
64
65 off = gd->arch.dp_alloc_base & align_mask;
66 if (off != 0)
67 gd->arch.dp_alloc_base += (align - off);
68
69 if ((off = size & align_mask) != 0)
70 size += align - off;
71
72 if ((gd->arch.dp_alloc_base + size) >= gd->arch.dp_alloc_top) {
73 gd->arch.dp_alloc_base = savebase;
74 panic("m8260_cpm_dpalloc: ran out of dual port ram!");
75 }
76
77 retloc = gd->arch.dp_alloc_base;
78 gd->arch.dp_alloc_base += size;
79
80 memset((void *)&immr->im_dprambase[retloc], 0, size);
81
82 return(retloc);
83}
84
85
86
87
88uint
89m8260_cpm_hostalloc(uint size, uint align)
90{
91
92 return (m8260_cpm_dpalloc(size, align));
93}
94
95
96
97
98
99
100
101
102
103
104
105#define BRG_INT_CLK gd->arch.brg_clk
106#define BRG_UART_CLK (BRG_INT_CLK / 16)
107
108
109
110
111void
112m8260_cpm_setbrg(uint brg, uint rate)
113{
114 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
115 volatile uint *bp;
116 uint cd = BRG_UART_CLK / rate;
117
118 if ((BRG_UART_CLK % rate) < (rate / 2))
119 cd--;
120 if (brg < 4) {
121 bp = (uint *)&immr->im_brgc1;
122 }
123 else {
124 bp = (uint *)&immr->im_brgc5;
125 brg -= 4;
126 }
127 bp += brg;
128 *bp = (cd << 1) | CPM_BRG_EN;
129}
130
131
132
133
134void
135m8260_cpm_fastbrg(uint brg, uint rate, int div16)
136{
137 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
138 volatile uint *bp;
139
140
141
142 if (brg < 4) {
143 bp = (uint *)&immr->im_brgc1;
144 }
145 else {
146 bp = (uint *)&immr->im_brgc5;
147 brg -= 4;
148 }
149 bp += brg;
150 *bp = (((((BRG_INT_CLK+rate-1)/rate)-1)&0xfff)<<1)|CPM_BRG_EN;
151 if (div16)
152 *bp |= CPM_BRG_DIV16;
153}
154
155
156
157
158
159void
160m8260_cpm_extcbrg(uint brg, uint rate, uint extclk, int pinsel)
161{
162 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
163 volatile uint *bp;
164
165 if (brg < 4) {
166 bp = (uint *)&immr->im_brgc1;
167 }
168 else {
169 bp = (uint *)&immr->im_brgc5;
170 brg -= 4;
171 }
172 bp += brg;
173 *bp = ((((((extclk/16)+rate-1)/rate)-1)&0xfff)<<1)|CPM_BRG_EN;
174 if (pinsel == 0)
175 *bp |= CPM_BRG_EXTC_CLK3_9;
176 else
177 *bp |= CPM_BRG_EXTC_CLK5_15;
178}
179