mb/google/nissa/var/rull: Configure Acoustic noise mitigation
[coreboot2.git] / src / soc / amd / common / block / alink / alink.c
blob47869982770a123ee594e8f7db9d8f28081a69e7
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <arch/io.h>
4 #include <stdint.h>
5 #include <console/console.h>
6 #include <amdblocks/alink.h>
8 void alink_ab_indx(u32 reg_space, u32 reg_addr, u32 mask, u32 val)
10 u32 tmp;
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);
20 tmp &= ~mask;
21 tmp |= val;
23 // printk(BIOS_DEBUG, "about write %x, index=%x", tmp,
24 // (reg_space&0x3)<<29 | reg_addr);
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);
32 void alink_rc_indx(u32 reg_space, u32 reg_addr, u32 port, u32 mask, u32 val)
34 u32 tmp;
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);
44 tmp &= ~mask;
45 tmp |= val;
47 //printk(BIOS_DEBUG, "about write %x, index=%x", tmp,
48 // (reg_space&0x3)<<29 | (port&3) << 24 | reg_addr);
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);
57 * space = 0: AX_INDXC, AX_DATAC
58 * space = 1: AX_INDXP, AX_DATAP
60 void alink_ax_indx(u32 space /*c or p? */, u32 axindc, u32 mask, u32 val)
62 u32 tmp;
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);
72 tmp &= ~mask;
73 tmp |= val;
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);