Skip to content

Commit 7ac7a0e

Browse files
Chenhongrenjhedberg
authored andcommitted
soc: ite: it8xxx2: increase sspi_clk and fix clock divisor setting
This commit raises the sspi clock from 24MHz to 48MHz and corrects the clock divisor setting for it82xx2 chips. Signed-off-by: Ren Chen <[email protected]>
1 parent 4f413d8 commit 7ac7a0e

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

soc/ite/ec/it8xxx2/chip_chipregs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ enum chip_pll_mode {
12561256
#define IT8XXX2_ECPM_SCDCR2 ECREG(IT8XXX2_ECPM_BASE + 0x0e)
12571257
#define IT8XXX2_ECPM_SCDCR3 ECREG(IT8XXX2_ECPM_BASE + 0x0f)
12581258
#define IT8XXX2_ECPM_SCDCR4 ECREG(IT8XXX2_ECPM_BASE + 0x10)
1259+
#define IT8XXX2_ECPM_SCDCR8 ECREG(IT8XXX2_ECPM_BASE + 0x18)
12591260
#define IT8XXX2_ECPM_PFACC0R ECREG(IT8XXX2_ECPM_BASE + 0x20)
12601261
#define IT8XXX2_ECPM_PFACC1R ECREG(IT8XXX2_ECPM_BASE + 0x21)
12611262
#define IT8XXX2_ECPM_PFACC2R ECREG(IT8XXX2_ECPM_BASE + 0x40)

soc/ite/ec/it8xxx2/soc.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ COND_CODE_1(DT_NODE_EXISTS(DT_INST(1, ite_it8xxx2_usbpd)), (2), (1))
4949
#define SSPI_CLOCK_GATING BIT(1)
5050
#define AUTO_SSPI_CLOCK_GATING BIT(4)
5151

52+
#define CLK_DIV_HIGH_FIELDS(n) FIELD_PREP(GENMASK(7, 4), n)
53+
#define CLK_DIV_LOW_FIELDS(n) FIELD_PREP(GENMASK(3, 0), n)
54+
5255
uint32_t chip_get_pll_freq(void)
5356
{
5457
uint32_t pllfreq;
@@ -127,7 +130,7 @@ static const struct pll_config_t pll_configuration[PLL_FREQ_CNT] = {
127130
* USB div = 0 (PLL / 1 = 48 mhz)
128131
* UART div = 1 (PLL / 2 = 24 mhz)
129132
* SMB div = 1 (PLL / 2 = 24 mhz)
130-
* SSPI div = 1 (PLL / 2 = 24 mhz)
133+
* SSPI div = 0 (PLL / 1 = 48 mhz)
131134
* EC div = 6 (FND / 6 = 8 mhz)
132135
* JTAG div = 1 (PLL / 2 = 24 mhz)
133136
* PWM div = 0 (PLL / 1 = 48 mhz)
@@ -139,7 +142,7 @@ static const struct pll_config_t pll_configuration[PLL_FREQ_CNT] = {
139142
.div_usb = 0,
140143
.div_uart = 1,
141144
.div_smb = 1,
142-
.div_sspi = 1,
145+
.div_sspi = 0,
143146
#ifdef CONFIG_SOC_IT8XXX2_EC_BUS_24MHZ
144147
.div_ec = 1,
145148
#else
@@ -155,7 +158,7 @@ static const struct pll_config_t pll_configuration[PLL_FREQ_CNT] = {
155158
* USB div = 1 (PLL / 2 = 48 mhz)
156159
* UART div = 3 (PLL / 4 = 24 mhz)
157160
* SMB div = 3 (PLL / 4 = 24 mhz)
158-
* SSPI div = 3 (PLL / 4 = 24 mhz)
161+
* SSPI div = 1 (PLL / 2 = 48 mhz)
159162
* EC div = 6 (FND / 6 = 8 mhz)
160163
* JTAG div = 3 (PLL / 4 = 24 mhz)
161164
* PWM div = 1 (PLL / 2 = 48 mhz)
@@ -167,7 +170,7 @@ static const struct pll_config_t pll_configuration[PLL_FREQ_CNT] = {
167170
.div_usb = 1,
168171
.div_uart = 3,
169172
.div_smb = 3,
170-
.div_sspi = 3,
173+
.div_sspi = 1,
171174
#ifdef CONFIG_SOC_IT8XXX2_EC_BUS_24MHZ
172175
.div_ec = 1,
173176
#else
@@ -206,8 +209,20 @@ void __soc_ram_code chip_run_pll_sequence(const struct pll_config_t *pll)
206209
chip_pll_ctrl(CHIP_PLL_DOZE);
207210
/* USB and UART */
208211
IT8XXX2_ECPM_SCDCR1 = (pll->div_usb << 4) | pll->div_uart;
209-
/* SSPI and SMB */
210-
IT8XXX2_ECPM_SCDCR2 = (pll->div_sspi << 4) | pll->div_smb;
212+
213+
#ifdef CONFIG_SOC_IT8XXX2_REG_SET_V1
214+
/* SMB and SSPI */
215+
IT8XXX2_ECPM_SCDCR2 = CLK_DIV_HIGH_FIELDS(pll->div_sspi) | CLK_DIV_LOW_FIELDS(pll->div_smb);
216+
#elif CONFIG_SOC_IT8XXX2_REG_SET_V2
217+
/* SMB */
218+
IT8XXX2_ECPM_SCDCR2 = CLK_DIV_LOW_FIELDS(pll->div_smb);
219+
/* SSPI */
220+
IT8XXX2_ECPM_SCDCR8 =
221+
CLK_DIV_HIGH_FIELDS(pll->div_sspi) | CLK_DIV_LOW_FIELDS(pll->div_sspi);
222+
#else
223+
BUILD_ASSERT(false, "unknown sspi and smb clock divisor setting for register set version");
224+
#endif /* CONFIG_SOC_IT8XXX2_REG_SET_V1 */
225+
211226
/* USBPD and PWM */
212227
IT8XXX2_ECPM_SCDCR4 = (pll->div_usbpd << 4) | pll->div_pwm;
213228
}

0 commit comments

Comments
 (0)