Debian Codegraph @

src/soc/amd/common/block/alink/alink.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <arch/io.h>
4 #include <stdint.h>
5 #include <console/console.h>
6 #include <amdblocks/alink.h>
7
8 void alink_ab_indx(u32 reg_space, u32 reg_addr, u32 mask, u32 val)
9 {
10 u32 tmp;
11
12 outl((reg_space & 0x7) << 29 | reg_addr, AB_INDX);
13 tmp = inl(AB_DATA);
14 /* rpr 4.2
15 * For certain revisions of the chip, the ABCFG registers,
16 * with an address of 0x100NN (where 'N' is any hexadecimal
17 * number), require an extra programming step.*/
18 outl(0, AB_INDX);
19
20 tmp &= ~mask;
21 tmp |= val;
22
23 // printk(BIOS_DEBUG, "about write %x, index=%x", tmp,
24 // (reg_space&0x3)<<29 | reg_addr);
25
26 /* probably we don't have to do it again. */
27 outl((reg_space & 0x7) << 29 | reg_addr, AB_INDX);
28 outl(tmp, AB_DATA);
29 outl(0, AB_INDX);
30 }
31
32 void alink_rc_indx(u32 reg_space, u32 reg_addr, u32 port, u32 mask, u32 val)
33 {
34 u32 tmp;
35
36 outl((reg_space & 0x7) << 29 | (port & 3) << 24 | reg_addr, AB_INDX);
37 tmp = inl(AB_DATA);
38 /* rpr 4.2
39 * For certain revisions of the chip, the ABCFG registers,
40 * with an address of 0x100NN (where 'N' is any hexadecimal
41 * number), require an extra programming step.*/
42 outl(0, AB_INDX);
43
44 tmp &= ~mask;
45 tmp |= val;
46
47 //printk(BIOS_DEBUG, "about write %x, index=%x", tmp,
48 // (reg_space&0x3)<<29 | (port&3) << 24 | reg_addr);
49
50 /* probably we don't have to do it again. */
51 outl((reg_space & 0x7) << 29 | (port & 3) << 24 | reg_addr, AB_INDX);
52 outl(tmp, AB_DATA);
53 outl(0, AB_INDX);
54 }
55
56 /*
57 * space = 0: AX_INDXC, AX_DATAC
58 * space = 1: AX_INDXP, AX_DATAP
59 */
60 void alink_ax_indx(u32 space /*c or p? */, u32 axindc, u32 mask, u32 val)
61 {
62 u32 tmp;
63
64 /* read axindc to tmp */
65 outl(space << 29 | space << 3 | 0x30, AB_INDX);
66 outl(axindc, AB_DATA);
67 outl(0, AB_INDX);
68 outl(space << 29 | space << 3 | 0x34, AB_INDX);
69 tmp = inl(AB_DATA);
70 outl(0, AB_INDX);
71
72 tmp &= ~mask;
73 tmp |= val;
74
75 /* write tmp */
76 outl(space << 29 | space << 3 | 0x30, AB_INDX);
77 outl(axindc, AB_DATA);
78 outl(0, AB_INDX);
79 outl(space << 29 | space << 3 | 0x34, AB_INDX);
80 outl(tmp, AB_DATA);
81 outl(0, AB_INDX);
82 }