1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
5 #include <soc/mt6315.h>
7 #include <soc/pmif_spmi.h>
9 static struct pmif
*pmif_arb
= NULL
;
11 static void mt6315_read(u32 slvid
, u32 reg
, u32
*data
)
13 pmif_arb
->read(pmif_arb
, slvid
, reg
, data
);
16 static void mt6315_write(u32 slvid
, u32 reg
, u32 data
)
18 pmif_arb
->write(pmif_arb
, slvid
, reg
, data
);
21 void mt6315_write_field(u32 slvid
, u32 reg
, u32 val
, u32 mask
, u32 shift
)
23 pmif_arb
->write_field(pmif_arb
, slvid
, reg
, val
, mask
, shift
);
26 static void mt6315_wdt_enable(u32 slvid
)
28 mt6315_write(slvid
, 0x3A9, 0x63);
29 mt6315_write(slvid
, 0x3A8, 0x15);
30 mt6315_write(slvid
, 0x127, 0x2);
31 mt6315_write(slvid
, 0x127, 0x1);
32 mt6315_write(slvid
, 0x127, 0x8);
34 mt6315_write(slvid
, 0x128, 0x8);
35 mt6315_write(slvid
, 0x3A8, 0);
36 mt6315_write(slvid
, 0x3A9, 0);
39 void mt6315_buck_set_voltage(u32 slvid
, u32 buck_id
, u32 buck_uv
)
41 unsigned int vol_reg
, vol_val
;
44 die("ERROR: pmif_arb not initialized");
48 vol_reg
= MT6315_BUCK_TOP_ELR0
;
51 vol_reg
= MT6315_BUCK_TOP_ELR3
;
54 die("ERROR: Unknown buck_id %u", buck_id
);
58 vol_val
= buck_uv
/ 6250;
59 mt6315_write(slvid
, vol_reg
, vol_val
);
62 u32
mt6315_buck_get_voltage(u32 slvid
, u32 buck_id
)
67 die("ERROR: pmif_arb not initialized");
71 vol_reg
= MT6315_BUCK_VBUCK1_DBG0
;
74 vol_reg
= MT6315_BUCK_VBUCK1_DBG3
;
77 die("ERROR: Unknown buck_id %u", buck_id
);
81 mt6315_read(slvid
, vol_reg
, &vol
);
85 static void init_pmif_arb(void)
88 pmif_arb
= get_pmif_controller(PMIF_SPMI
, 0);
90 die("ERROR: No spmi device");
93 if (pmif_arb
->is_pmif_init_done(pmif_arb
))
94 die("ERROR - Failed to initialize pmif spmi");
97 void mt6315_init(void)
103 for (i
= 0; i
< spmi_dev_cnt
; i
++)
104 mt6315_wdt_enable(spmi_dev
[i
].slvid
);
106 mt6315_init_setting();