Hello hsin-hsiung wang,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/45398
to review the following change.
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface(PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
TEST=Boots correctly on MT8192EVB.
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,550 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/1
diff --git a/src/soc/mediatek/mt8192/Makefile.inc b/src/soc/mediatek/mt8192/Makefile.inc index 533eae2..0fc47c4 100755 --- a/src/soc/mediatek/mt8192/Makefile.inc +++ b/src/soc/mediatek/mt8192/Makefile.inc @@ -9,6 +9,7 @@ bootblock-y += ../common/timer.c bootblock-y += ../common/uart.c bootblock-y += ../common/wdt.c +bootblock-y += pmif.c pmif_clk.c pmif_spi.c pmif_spmi.c
verstage-y += flash_controller.c verstage-y += ../common/gpio.c gpio.c diff --git a/src/soc/mediatek/mt8192/bootblock.c b/src/soc/mediatek/mt8192/bootblock.c index 8dffe56..0852f0e 100644 --- a/src/soc/mediatek/mt8192/bootblock.c +++ b/src/soc/mediatek/mt8192/bootblock.c @@ -3,6 +3,7 @@ #include <bootblock_common.h> #include <soc/mmu_operations.h> #include <soc/pll.h> +#include <soc/pmif.h> #include <soc/wdt.h>
void bootblock_soc_init(void) @@ -10,4 +11,5 @@ mtk_mmu_init(); mtk_wdt_init(); mt_pll_init(); + mtk_pmif_init(); } diff --git a/src/soc/mediatek/mt8192/include/soc/addressmap.h b/src/soc/mediatek/mt8192/include/soc/addressmap.h index e0cd536..e9cb788 100644 --- a/src/soc/mediatek/mt8192/include/soc/addressmap.h +++ b/src/soc/mediatek/mt8192/include/soc/addressmap.h @@ -21,7 +21,11 @@ GPT_BASE = IO_PHYS + 0x00008000, EINT_BASE = IO_PHYS + 0x0000B000, APMIXED_BASE = IO_PHYS + 0x0000C000, - PWRAP_BASE = IO_PHYS + 0x0000D000, + MODEM_TEMP_SHARE_BASE = IO_PHYS + 0x00018000, + PMIF_SPI_BASE = IO_PHYS + 0x00026000, + PMIF_SPMI_BASE = IO_PHYS + 0x00027000, + PMICSPI_MST_BASE = IO_PHYS + 0x00028000, + SPMI_MST_BASE = IO_PHYS + 0x00029000, UART0_BASE = IO_PHYS + 0x01002000, SPI0_BASE = IO_PHYS + 0x0100A000, SPI1_BASE = IO_PHYS + 0x01010000, diff --git a/src/soc/mediatek/mt8192/include/soc/pll.h b/src/soc/mediatek/mt8192/include/soc/pll.h index 442aa30..c83436e 100644 --- a/src/soc/mediatek/mt8192/include/soc/pll.h +++ b/src/soc/mediatek/mt8192/include/soc/pll.h @@ -178,7 +178,11 @@ u32 mfgpll_con2; u32 mfgpll_con3; u32 ap_pllgp1_con2; - u32 reserved2[33]; + u32 reserved2[13]; + u32 ulposc1_con0; + u32 ulposc1_con1; + u32 ulposc1_con2; + u32 reserved3[17]; u32 ap_pllgp2_con0; /* 0x0300 */ u32 ap_pllgp2_con1; u32 univpll_con0; diff --git a/src/soc/mediatek/mt8192/include/soc/pmif.h b/src/soc/mediatek/mt8192/include/soc/pmif.h new file mode 100644 index 0000000..6106a3d --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/pmif.h @@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __MT8192_SOC_PMIF_H__ +#define __MT8192_SOC_PMIF_H__ + +#include <types.h> + +enum { + PMIF_CMD_REG_0, + PMIF_CMD_REG, + PMIF_CMD_EXT_REG, + PMIF_CMD_EXT_REG_LONG, +}; + +struct mtk_pmif_regs { + u32 init_done; + u32 reserved1[5]; + u32 inf_busy_sta; + u32 other_busy_sta_0; + u32 other_busy_sta_1; + u32 inf_en; + u32 other_inf_en; + u32 inf_cmd_per_0; + u32 inf_cmd_per_1; + u32 inf_cmd_per_2; + u32 inf_cmd_per_3; + u32 inf_max_bytecnt_per_0; + u32 inf_max_bytecnt_per_1; + u32 inf_max_bytecnt_per_2; + u32 inf_max_bytecnt_per_3; + u32 staupd_ctrl; + u32 reserved2[48]; + u32 int_gps_auxadc_cmd_addr; + u32 int_gps_auxadc_cmd; + u32 int_gps_auxadc_rdata_addr; + u32 reserved3[13]; + u32 arb_en; + u32 reserved4[34]; + u32 lat_cnter_en; + u32 lat_limit_loading; + u32 lat_limit_0; + u32 lat_limit_1; + u32 lat_limit_2; + u32 lat_limit_3; + u32 lat_limit_4; + u32 lat_limit_5; + u32 lat_limit_6; + u32 lat_limit_7; + u32 lat_limit_8; + u32 lat_limit_9; + u32 reserved5[99]; + u32 crc_ctrl; + u32 crc_sta; + u32 sig_mode; + u32 pmic_sig_addr; + u32 pmic_sig_val; + u32 reserved6[2]; + u32 cmdissue_en; + u32 reserved7[10]; + u32 timer_ctrl; + u32 timer_sta; + u32 sleep_protection_ctrl; + u32 reserved8[5]; + u32 spi_mode_ctrl; + u32 reserved9[2]; + u32 pmic_eint_sta_addr; + u32 reserved10[2]; + u32 irq_event_en_0; + u32 irq_flag_raw_0; + u32 irq_flag_0; + u32 irq_clr_0; + u32 reserved11[502]; + u32 swinf_0_acc; + u32 swinf_0_wdata_31_0; + u32 swinf_0_wdata_63_32; + u32 reserved12[2]; + u32 swinf_0_rdata_31_0; + u32 swinf_0_rdata_63_32; + u32 reserved13[2]; + u32 swinf_0_vld_clr; + u32 swinf_0_sta; + u32 reserved14[5]; + u32 swinf_1_acc; + u32 swinf_1_wdata_31_0; + u32 swinf_1_wdata_63_32; + u32 reserved15[2]; + u32 swinf_1_rdata_31_0; + u32 swinf_1_rdata_63_32; + u32 reserved16[2]; + u32 swinf_1_vld_clr; + u32 swinf_1_sta; + u32 reserved17[5]; + u32 swinf_2_acc; + u32 swinf_2_wdata_31_0; + u32 swinf_2_wdata_63_32; + u32 reserved18[2]; + u32 swinf_2_rdata_31_0; + u32 swinf_2_rdata_63_32; + u32 reserved19[2]; + u32 swinf_2_vld_clr; + u32 swinf_2_sta; + u32 reserved20[5]; + u32 swinf_3_acc; + u32 swinf_3_wdata_31_0; + u32 swinf_3_wdata_63_32; + u32 reserved21[2]; + u32 swinf_3_rdata_31_0; + u32 swinf_3_rdata_63_32; + u32 reserved22[2]; + u32 swinf_3_vld_clr; + u32 swinf_3_sta; + u32 reserved23[133]; +}; + +check_member(mtk_pmif_regs, inf_busy_sta, 0x18); +check_member(mtk_pmif_regs, int_gps_auxadc_cmd_addr, 0x110); +check_member(mtk_pmif_regs, arb_en, 0x0150); +check_member(mtk_pmif_regs, lat_cnter_en, 0x1DC); +check_member(mtk_pmif_regs, crc_ctrl, 0x398); +check_member(mtk_pmif_regs, cmdissue_en, 0x3B4); +check_member(mtk_pmif_regs, timer_ctrl, 0x3E0); +check_member(mtk_pmif_regs, spi_mode_ctrl, 0x400); +check_member(mtk_pmif_regs, pmic_eint_sta_addr, 0x40C); +check_member(mtk_pmif_regs, irq_event_en_0, 0x418); +check_member(mtk_pmif_regs, swinf_0_acc, 0xC00); + +struct pmif { + struct mtk_pmif_regs *mtk_pmif; + int swinf_ch_start; + int swinf_no; + int mstid; + int pmifid; + int (*read_cmd)(struct pmif *arb, unsigned int slvid, + unsigned int addr, unsigned int *rdata); + int (*write_cmd)(struct pmif *arb, unsigned int slvid, + unsigned int addr, unsigned int wdata); + int (*is_pmif_init_done)(struct pmif *arb); +}; + +enum { + PMIF_SPI, + PMIF_SPMI, +}; + +enum { + E_IO = 1, /* I/O error */ + E_BUSY, /* Device or resource busy */ + E_NODEV, /* No such device */ + E_INVAL, /* Invalid argument */ + E_OPNOTSUPP, /* Operation not supported on transport endpoint */ + E_TIMEOUT, /* Wait for idle time out */ + E_READ_TEST_FAIL, /* SPI read fail */ + E_SPI_INIT_RESET_SPI, /* reset SPI fail */ + E_SPI_INIT_SIDLY, /* SPI edge calibration fail */ +}; + +/* start external API */ +extern struct pmif *get_pmif_controller(int inf, int mstid); +extern int mtk_pmif_init(void); +#endif /*__MT8192_SOC_PMIF_H__*/ diff --git a/src/soc/mediatek/mt8192/include/soc/pmif_spi.h b/src/soc/mediatek/mt8192/include/soc/pmif_spi.h new file mode 100644 index 0000000..606dbbd --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/pmif_spi.h @@ -0,0 +1,132 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __SOC_MEDIATEK_MT8192_PMIC_WRAP_H__ +#define __SOC_MEDIATEK_MT8192_PMIC_WRAP_H__ + +#include <soc/addressmap.h> +#include <types.h> + +struct mt8192_pmicspi_mst_regs { + u32 reserved1[4]; + u32 other_busy_sta_0; + u32 wrap_en; + u32 reserved2[2]; + u32 man_en; + u32 man_acc; + u32 reserved3[3]; + u32 mux_sel; + u32 reserved4[3]; + u32 dio_en; + u32 rddmy; + u32 cslext_write; + u32 cslext_read; + u32 cshext_write; + u32 cshext_read; + u32 ext_ck_write; + u32 ext_ck_read; + u32 si_sampling_ctrl; +}; + +check_member(mt8192_pmicspi_mst_regs, other_busy_sta_0, 0x10); +check_member(mt8192_pmicspi_mst_regs, man_en, 0x20); +check_member(mt8192_pmicspi_mst_regs, mux_sel, 0x34); +check_member(mt8192_pmicspi_mst_regs, dio_en, 0x44); + +static struct mt8192_pmicspi_mst_regs * const mtk_pmicspi_mst = (void *)PMICSPI_MST_BASE; + +struct mtk_iocfg_tl_regs { + u32 drv_cfg0; + u32 drv_cfg0_set; + u32 drv_cfg0_clr; +}; +check_member(mtk_iocfg_tl_regs, drv_cfg0_set, 0x4); +check_member(mtk_iocfg_tl_regs, drv_cfg0_clr, 0x8); + +#define mtk_iocfg_tl ((struct mtk_iocfg_tl_regs *)IOCFG_TL_BASE) + +struct mtk_modem_temp_share_regs { + u32 ctrl; +}; + +#define mtk_modem_temp_share ((struct mtk_modem_temp_share_regs *)SPM_BASE) + +/* PMIC registers */ +enum { + PMIC_BASE = 0x0000, + PMIC_SMT_CON1 = PMIC_BASE + 0x0032, + PMIC_DRV_CON1 = PMIC_BASE + 0x003a, + PMIC_FILTER_CON0 = PMIC_BASE + 0x0042, + PMIC_GPIO_PULLEN0_CLR = PMIC_BASE + 0x0098, + PMIC_RG_SPI_CON0 = PMIC_BASE + 0x0408, + PMIC_DEW_DIO_EN = PMIC_BASE + 0x040c, + PMIC_DEW_READ_TEST = PMIC_BASE + 0x040e, + PMIC_DEW_WRITE_TEST = PMIC_BASE + 0x0410, + PMIC_DEW_CRC_EN = PMIC_BASE + 0x0414, + PMIC_DEW_CRC_VAL = PMIC_BASE + 0x0416, + PMIC_DEW_RDDMY_NO = PMIC_BASE + 0x0424, + PMIC_RG_SPI_CON2 = PMIC_BASE + 0x0426, + PMIC_SPISLV_KEY = PMIC_BASE + 0x044a, + PMIC_INT_STA = PMIC_BASE + 0x0452, + PMIC_AUXADC_ADC7 = PMIC_BASE + 0x1096, + PMIC_AUXADC_ADC10 = PMIC_BASE + 0x109c, + PMIC_AUXADC_RQST0 = PMIC_BASE + 0x1108, +}; + +#define PMIF_SPI_MD_SWINF_NO 0 +#define PMIF_SPI_AP_SECURE_SWINF_NO 1 +#define PMIF_SPI_AP_SWINF_NO 2 +#define PMIF_SPI_SWINF_0_CHAN_NO 8 +#define PMIF_SPI_MD_SWINF_CHAN_NO BIT(PMIF_SPI_SWINF_0_CHAN_NO + PMIF_SPI_MD_SWINF_NO) +#define PMIF_SPI_AP_SECURE_SWINF_CHAN_NO BIT(PMIF_SPI_SWINF_0_CHAN_NO + PMIF_SPI_AP_SECURE_SWINF_NO) +#define PMIF_SPI_AP_SWINF_CHAN_NO BIT(PMIF_SPI_SWINF_0_CHAN_NO + PMIF_SPI_AP_SWINF_NO) + +#define DEFAULT_SLVID 0 + +#define GET_PMICSPI_BUSY(x) ((x>>9) & 0x00000001) +#define GET_CMDISSUE_BUSY(x) ((x>>2) & 0x00000001) + +enum { + SPI_CLK = 0x1, + SPI_CSN = 0x1 << 1, + SPI_MOSI = 0x1 << 2, + SPI_MISO = 0x1 << 3, + SPI_FILTER = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, + SPI_SMT = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO), + SPI_PULL_DISABLE = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, +}; + +enum { + IO_4_MA = 0x8, +}; + +enum { + SPI_CLK_SHIFT = 0, + SPI_CSN_SHIFT = 4, + SPI_MOSI_SHIFT = 8, + SPI_MISO_SHIFT = 12, + SPI_DRIVING = (IO_4_MA << SPI_CLK_SHIFT | IO_4_MA << SPI_CSN_SHIFT | + IO_4_MA << SPI_MOSI_SHIFT | IO_4_MA << SPI_MISO_SHIFT), +}; + +enum { + OP_WR = 0x1, + OP_CSH = 0x0, + OP_CSL = 0x1, + OP_OUTS = 0x8, +}; + +enum { + DEFAULT_VALUE_READ_TEST = 0x5aa5, + WRITE_TEST_VALUE = 0xa55a +}; + +enum { + DUMMY_READ_CYCLES = 0X8, +}; + +enum { + E_CLK_EDGE = 1, + E_CLK_LAST_SETTING +}; +extern int pmif_spi_init(struct pmif *arb); +#endif /* __SOC_MEDIATEK_MT8192_PMIC_WRAP_H__ */ diff --git a/src/soc/mediatek/mt8192/include/soc/pmif_spmi.h b/src/soc/mediatek/mt8192/include/soc/pmif_spmi.h new file mode 100644 index 0000000..5f89ddc --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/pmif_spmi.h @@ -0,0 +1,143 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __PMIF_SPMI_H__ +#define __PMIF_SPMI_H__ + +#include <soc/addressmap.h> + +#define DEFAULT_VALUE_READ_TEST (0x5a) +#define DEFAULT_VALUE_WRITE_TEST (0xa5) + +#define GET_REC_CMD(x) (x & 0x00000003) +#define GET_REC_W(x) ((x>>2) & 0x00000001) +#define GET_REC_OP_ST_NACK(x) ((x>>3) & 0x00000001) +#define GET_REC_PMIF_NACK(x) ((x>>4) & 0x00000001) +#define GET_REC_PMIF_PARITY_ERR(x) ((x>>5) & 0x00000001) +#define GET_REC_PMIF_BYTE_ERR(x) ((x>>6) & 0x00000001) +#define GET_REC_PMIF_GRP_RD_ERR(x) ((x>>7) & 0x00000001) +#define GET_REC_SLVID(x) ((x>>8) & 0x0000000f) +#define GET_REC_BYTECNT(x) ((x>>12) & 0x0000000f) +#define GET_REC_ADDR(x) ((x>>16) & 0x0000ffff) + +/* + * GPIO number for IO driving config, + * These can be look up by platform/<mtxxxx>/src/drivers/inc/gpio_cfg.h + * must check by platform + */ +#define SPMI_SCL_GPIO 89 +#define SPMI_SDA_GPIO 90 +#define SPMI_SCL_DRV_SHIFT (3) +#define SPMI_SDA_DRV_SHIFT (6) + +#define SPMIMST_RST_SHIFT 4 +#define WDT_UNLOCK_SHIFT 24 + +#define WDT_UNLOCK_KEY 0x85 + +struct mtk_rgu_regs { + u32 reserved[36]; + u32 wdt_swsysrst2; +}; +check_member(mtk_rgu_regs, wdt_swsysrst2, 0x0090); + +struct mtk_iocfg_bm_regs { + u32 reserved[9]; + u32 drv_cfg2_set; + u32 drv_cfg2_clr; +}; +check_member(mtk_iocfg_bm_regs, drv_cfg2_set, 0x0024); +check_member(mtk_iocfg_bm_regs, drv_cfg2_clr, 0x0028); + +struct mtk_spm_regs { + u32 poweron_config_en; + u32 reserved[263]; + u32 ulposc_con; +}; +check_member(mtk_spm_regs, ulposc_con, 0x0420); + +struct mtk_spmi_mst_reg { + u32 op_st_ctrl; + u32 grp_id_en; + u32 op_st_sta; + u32 mst_sampl; + u32 mst_req_en; + u32 reserved1[11]; + u32 rec_ctrl; + u32 rec0; + u32 rec1; + u32 rec2; + u32 rec3; + u32 rec4; + u32 reserved2[41]; + u32 mst_dbg; +}; + +check_member(mtk_spmi_mst_reg, rec_ctrl, 0x40); +check_member(mtk_spmi_mst_reg, mst_dbg, 0xfc); + +#define mtk_rug ((struct mtk_rgu_regs *)RGU_BASE) +#define mtk_iocfg_bm ((struct mtk_iocfg_bm_regs *)IOCFG_BM_BASE) +#define mtk_spm ((struct mtk_spm_regs *)SPM_BASE) +#define mtk_spmi_mst ((struct mtk_spmi_mst_reg *)SPMI_MST_BASE) + +struct cali { + unsigned int dly; + unsigned int pol; +}; + +enum +{ + SPMI_CK_NO_DLY = 0, + SPMI_CK_DLY_1T +}; + +enum +{ + SPMI_CK_POL_NEG = 0, + SPMI_CK_POL_POS +}; + +enum +{ + SPMI_OP_ST_BUSY = 1, + SPMI_OP_ST_ACK = 0, + SPMI_OP_ST_NACK = 1 +}; + +enum +{ + SPMI_RCS_SR_BIT, + SPMI_RCS_A_BIT +}; + +enum +{ + SPMI_RCS_MST_W = 1, + SPMI_RCS_SLV_W = 3 +}; + +enum +{ + SPMI_RESET = 0, + SPMI_SLEEP, + SPMI_SHUTDOWN, + SPMI_WAKEUP +}; + +enum spmi_regs { + SPMI_OP_ST_CTRL, + SPMI_GRP_ID_EN, + SPMI_OP_ST_STA, + SPMI_MST_SAMPL, + SPMI_MST_REQ_EN, + SPMI_REC_CTRL, + SPMI_REC0, + SPMI_REC1, + SPMI_REC2, + SPMI_REC3, + SPMI_REC4, + SPMI_MST_DBG +}; + +extern int pmif_spmi_init(struct pmif *arb); +#endif /*__PMIF_SPMI_H__*/ diff --git a/src/soc/mediatek/mt8192/include/soc/pmif_sw.h b/src/soc/mediatek/mt8192/include/soc/pmif_sw.h new file mode 100644 index 0000000..1d250bf --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/pmif_sw.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __PMIF_SW_H__ +#define __PMIF_SW_H__ + +/* Read/write byte limitation, by project */ +/* hw bytecnt indicate when we set 0, it can send 1 byte; + * set 1, it can send 2 byte. + */ +#define PMIF_BYTECNT_MAX 1 + +/* macro for SWINF_FSM */ +#define SWINF_FSM_IDLE (0x00) +#define SWINF_FSM_REQ (0x02) +#define SWINF_FSM_WFDLE (0x04) +#define SWINF_FSM_WFVLDCLR (0x06) +#define SWINF_INIT_DONE (0x01) + +/* indicate which number SW channel start, by project */ +#define PMIF_SWINF_0_CHAN_NO 4 + +/* MD: 0, security domain: 1, AP: 2 */ +#define PMIF_AP_SWINF_NO 2 + +#define GET_SWINF_0_FSM(x) ((x >> 1) & 0x7) + +struct pmif_mpu { + unsigned int rgn_slvid; + unsigned short rgn_s_addr; + unsigned short rgn_e_addr; + unsigned int rgn_domain_per; +}; + +enum { + PMIF_READ_US = 1000, + PMIF_WAIT_IDLE_US = 1000, +}; +extern int pmif_clk_init(void); +#endif /*__PMIF_SW_H__*/ diff --git a/src/soc/mediatek/mt8192/include/soc/spmi.h b/src/soc/mediatek/mt8192/include/soc/spmi.h new file mode 100644 index 0000000..61e49b5 --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/spmi.h @@ -0,0 +1,78 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2020 MediaTek Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __SPMI_H__ +#define __SPMI_H__ + +/* enum marco for cmd/channel */ +enum spmi_master +{ + SPMI_MASTER_0, + SPMI_MASTER_1, + SPMI_MASTER_2, + SPMI_MASTER_3 +}; + +enum spmi_slave +{ + SPMI_SLAVE_0, + SPMI_SLAVE_1, + SPMI_SLAVE_2, + SPMI_SLAVE_3, + SPMI_SLAVE_4, + SPMI_SLAVE_5, + SPMI_SLAVE_6, + SPMI_SLAVE_7, + SPMI_SLAVE_8, + SPMI_SLAVE_9, + SPMI_SLAVE_10, + SPMI_SLAVE_11, + SPMI_SLAVE_12, + SPMI_SLAVE_13, + SPMI_SLAVE_14, + SPMI_SLAVE_15 +}; + +enum slv_type +{ + BUCK_CPU, + BUCK_GPU, + BUCK_MD, + BUCK_RF, + MAIN_PMIC, + BUCK_VPU, + SUB_PMIC, + SLV_TYPE_MAX +}; + +enum slv_type_id +{ + BUCK_RF_ID = 1, + BUCK_MD_ID = 3, + MAIN_PMIC_ID = 5, + BUCK_CPU_ID = 6, + BUCK_GPU_ID = 7, + BUCK_VPU_ID, + SUB_PMIC_ID = 10, + SLV_TYPE_ID_MAX +}; + +struct spmi_device { + int slvid; + int grpiden; + enum slv_type type; + enum slv_type_id type_id; +}; +#endif /*__SPMI_H__*/ diff --git a/src/soc/mediatek/mt8192/pmif.c b/src/soc/mediatek/mt8192/pmif.c new file mode 100644 index 0000000..ca42d37 --- /dev/null +++ b/src/soc/mediatek/mt8192/pmif.c @@ -0,0 +1,176 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <assert.h> +#include <console/console.h> +#include <device/mmio.h> +#include <soc/addressmap.h> +#include <soc/pmif.h> +#include <soc/pmif_spi.h> +#include <soc/pmif_spmi.h> +#include <soc/pmif_sw.h> +#include <soc/spmi.h> +#include <string.h> +#include <timer.h> + +static unsigned int pmif_check_idle(struct pmif *arb, unsigned int timeout_us) { + unsigned int reg_rdata; + struct stopwatch sw; + + stopwatch_init_usecs_expire(&sw, timeout_us); + do { + reg_rdata = read32(&arb->mtk_pmif->swinf_0_sta + 0x10 * arb->swinf_no); + if (stopwatch_expired(&sw)) { + printk(BIOS_ERR, "[%s] timeout\n", __func__); + return E_TIMEOUT; + } + } while (GET_SWINF_0_FSM(reg_rdata) != SWINF_FSM_IDLE); + + return 0; +} + +static inline unsigned int pmif_check_vldclr(struct pmif *arb, unsigned int timeout_us) { + unsigned int reg_rdata; + struct stopwatch sw; + + stopwatch_init_usecs_expire(&sw, timeout_us); + do { + reg_rdata = read32(&arb->mtk_pmif->swinf_0_sta + 0x10 * arb->swinf_no); + if (stopwatch_expired(&sw)) { + printk(BIOS_ERR, "[%s] timeout\n", __func__); + return E_TIMEOUT; + } + } while (GET_SWINF_0_FSM(reg_rdata) != SWINF_FSM_WFVLDCLR); + + return 0; +} + +static int pmif_send_cmd(struct pmif *arb, unsigned int write, + unsigned int opc, unsigned int slvid, unsigned int addr, + unsigned int *rdata, unsigned int wdata, unsigned int len) +{ + unsigned int ret = 0, data = 0; + unsigned int bc = len - 1; + + bc = 0; + /* Wait for Software Interface FSM state to be IDLE. */ + ret = pmif_check_idle(arb, PMIF_WAIT_IDLE_US); + if(ret) + return ret; + + /* Set the write data */ + if (write == 1) { + /* Set the write data. */ + write32(&arb->mtk_pmif->swinf_0_wdata_31_0 + 0x10 * arb->swinf_no, wdata); + } + + /* Send the command. */ + write32(&arb->mtk_pmif->swinf_0_acc + 0x10 * arb->swinf_no, + (opc << 30) | (write << 29) | (slvid << 24) | (bc << 16) | addr); + + if (write == 0) { + /* Wait for Software Interface FSM state to be WFVLDCLR, + * + * read the data and clear the valid flag. + */ + ret = pmif_check_vldclr(arb, PMIF_READ_US); + if(ret) + return ret; + + data = read32(&arb->mtk_pmif->swinf_0_rdata_31_0 + 0x10 * arb->swinf_no); + *rdata = data; + write32(&arb->mtk_pmif->swinf_0_vld_clr + 0x10 * arb->swinf_no, 0x1); + } + + return 0; +} + +static int pmif_spmi_read_cmd(struct pmif *arb,unsigned int slvid, + unsigned int addr, unsigned int *rdata) +{ + + return pmif_send_cmd(arb, 0, PMIF_CMD_EXT_REG_LONG, slvid, addr, rdata, 0, (PMIF_BYTECNT_MAX - 1)); +} + +static int pmif_spmi_write_cmd(struct pmif *arb, unsigned int slvid, + unsigned int addr, unsigned int wdata) +{ + return pmif_send_cmd(arb, 1, PMIF_CMD_EXT_REG_LONG, slvid, addr, NULL, wdata, (PMIF_BYTECNT_MAX - 1)); +} + +static int pmif_spi_read_cmd(struct pmif *arb, unsigned int slvid, + unsigned int addr, unsigned int *rdata) +{ + + return pmif_send_cmd(arb, 0, PMIF_CMD_REG_0, slvid, addr, rdata, 0, (PMIF_BYTECNT_MAX - 1)); +} + +static int pmif_spi_write_cmd(struct pmif *arb, unsigned int slvid, + unsigned int addr, unsigned int wdata) +{ + return pmif_send_cmd(arb, 1, PMIF_CMD_REG_0, slvid, addr, NULL, wdata, (PMIF_BYTECNT_MAX - 1)); +} + +static int is_pmif_init_done(struct pmif *arb) +{ + if ((read32(&arb->mtk_pmif->init_done) & 0x1)) + return 0; + + return -E_NODEV; +} + +static struct pmif pmif_spmi_arb[] = { + { + .mtk_pmif = (struct mtk_pmif_regs *)PMIF_SPMI_BASE, + .swinf_ch_start = PMIF_SWINF_0_CHAN_NO, + .swinf_no = PMIF_AP_SWINF_NO, + .mstid = SPMI_MASTER_0, + .pmifid = PMIF_SPMI, + .write_cmd = pmif_spmi_write_cmd, + .read_cmd = pmif_spmi_read_cmd, + .is_pmif_init_done = is_pmif_init_done, + }, +}; + +static struct pmif pmif_spi_arb[] = { + { + .mtk_pmif = (struct mtk_pmif_regs *)PMIF_SPI_BASE, + .swinf_no = PMIF_AP_SWINF_NO, + .pmifid = PMIF_SPI, + .write_cmd = pmif_spi_write_cmd, + .read_cmd = pmif_spi_read_cmd, + .is_pmif_init_done = is_pmif_init_done, + }, +}; + +struct pmif *get_pmif_controller(int inf, int mstid) +{ + if (inf == PMIF_SPMI) + return &pmif_spmi_arb[mstid]; + else if (inf == PMIF_SPI) + return &pmif_spi_arb[0]; + + return NULL; +} + +int mtk_pmif_init(void) +{ + int ret = 1; + + ret = pmif_clk_init(); + if (ret) + goto FAIL; + + ret = pmif_spmi_init(&pmif_spmi_arb[SPMI_MASTER_0]); + if (ret) + goto FAIL; + + ret = pmif_spi_init(&pmif_spi_arb[0]); + if (ret) + goto FAIL; + + return 0; + +FAIL: + /* assert(0); */ + return ret; +} diff --git a/src/soc/mediatek/mt8192/pmif_clk.c b/src/soc/mediatek/mt8192/pmif_clk.c new file mode 100644 index 0000000..96dfe0e --- /dev/null +++ b/src/soc/mediatek/mt8192/pmif_clk.c @@ -0,0 +1,234 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <delay.h> +#include <device/mmio.h> +#include <soc/infracfg.h> +#include <soc/pll.h> +#include <soc/pll_common.h> +#include <soc/pmif.h> +#include <soc/pmif_sw.h> +#include <soc/pmif_spmi.h> + +#define FREQ_260MHZ 260 +/* calibation miss rate, unit: 0.1% */ +#define CAL_MIS_RATE 40 +/* + * FREQ METER ID + * Ask clkmgr owner to find this information + * at clock table[fmeter]. + */ +#define FREQ_METER_ABIST_AD_OSC_CK 37 +#define CAL_MAX_VAL 0x7f + +static unsigned int mt_get_abist_freq(unsigned int ID) +{ + int output = 0, i = 0; + unsigned int temp, clk26cali_0, clk_dbg_cfg, clk_misc_cfg_0, clk26cali_1; + + clk_dbg_cfg = read32(&mtk_topckgen->clk_dbg_cfg); + /* sel abist_cksw and enable freq meter sel abist */ + write32(&mtk_topckgen->clk_dbg_cfg, (clk_dbg_cfg & 0xFFC0FFFC)|(ID << 16)); + + clk_misc_cfg_0 = read32(&mtk_topckgen->clk_misc_cfg_0); + /* select divider, div 4 */ + write32(&mtk_topckgen->clk_misc_cfg_0, (clk_misc_cfg_0 & 0x00FFFFFF) | (3 << 24)); + + clk26cali_0 = read32(&mtk_topckgen->clk26cali_0); + clk26cali_1 = read32(&mtk_topckgen->clk26cali_1); + write32(&mtk_topckgen->clk26cali_0, 0x1000); + write32(&mtk_topckgen->clk26cali_0, 0x1010); + + /* wait frequency meter finish */ + while (read32(&mtk_topckgen->clk26cali_0) & 0x10) + { + udelay(10); + i++; + if(i > 100) + break; + } + + temp = read32(&mtk_topckgen->clk26cali_1) & 0xFFFF; + output = ((temp * 26000) ) / 1024; /* Khz */ + + write32(&mtk_topckgen->clk_dbg_cfg, clk_dbg_cfg); + write32(&mtk_topckgen->clk_misc_cfg_0, clk_misc_cfg_0); + write32(&mtk_topckgen->clk26cali_0, clk26cali_0); + write32(&mtk_topckgen->clk26cali_1, clk26cali_1); + + return output * 4; +} + +static void pmif_ulposc_config(void) +{ + /* Config ULPOSC_CON0 */ + /* OSC_CP_EN = 0 */ + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x1 << 24)); + + /* OSC_DIV = 1110 */ + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x3f << 18)); + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) | (0xe << 18)); + + /* OSC_FBAND = 0010 */ + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0xf << 14)); + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) | (0x2 << 14)); + + /* OSC_IBAND = 1010010 */ + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f << 7)); + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) | (0x52 << 7)); + + /* OSC_CALI = 1000000 */ + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f)); + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) | 0x40); + + /* + **** Config ULPOSC_CON1 *** + */ + + /* OSC_DIV2_EN= 1b'0 */ + write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0x1 << 26)); + + /* OSC_MOD = 00 */ + write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0x3 << 24)); + + /* OSC_RSV2= 8b'00000000 */ + write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff << 16)); + + /* OSC_RSV1= 8b'00101001 */ + write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff << 8)); + write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) | (0x29 << 8)); + + /* OSC_32KCALI = 8b'00000000 */ + write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff)); + + /* + **** Config ULPOSC_CON2 *** + */ + + /* OSC_BIAS= 8b'01000010 */ + write32(&mtk_apmixed->ulposc1_con2, read32(&mtk_apmixed->ulposc1_con2) &~(0xff)); + write32(&mtk_apmixed->ulposc1_con2, read32(&mtk_apmixed->ulposc1_con2) | (0x40)); + +} + +static u32 pmif_get_ulposc_freq(u32 cali_val) +{ + u32 result = 0; + + /* set calibration value */ + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f)); + write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) | cali_val); + + udelay(50); + + result = mt_get_abist_freq(FREQ_METER_ABIST_AD_OSC_CK); + + return result / 1000; +} + +static int pmif_ulposc_cali(void) +{ + u32 current_val = 0, min = 0, max = CAL_MAX_VAL, middle; + u32 diff_by_min = 0, diff_by_max = 0xffff, cal_result; + int ret = 0; + + do { + middle = (min + max) / 2; + if (middle == min) + break; + + current_val = pmif_get_ulposc_freq(middle); + + if (current_val > FREQ_260MHZ) + max = middle; + else + min = middle; + } while (min <= max); + + current_val = pmif_get_ulposc_freq(min); + if (current_val > FREQ_260MHZ) + diff_by_min = current_val - FREQ_260MHZ; + else + diff_by_min = FREQ_260MHZ - current_val; + + current_val = pmif_get_ulposc_freq(max); + if (current_val > FREQ_260MHZ) + diff_by_max = current_val - FREQ_260MHZ; + else + diff_by_max = FREQ_260MHZ - current_val; + + if (diff_by_min < diff_by_max) { + cal_result = min; + current_val = pmif_get_ulposc_freq(min); + } else { + cal_result = max; + current_val = pmif_get_ulposc_freq(max); + } + + /* check if calibrated value is in the range of target value +- 15% */ + if (current_val < (FREQ_260MHZ * (1000 - CAL_MIS_RATE) / 1000) + || current_val > (FREQ_260MHZ * (1000 + CAL_MIS_RATE) / 1000)) { + printk(BIOS_ERR, "[%s]calibration fail: %dM\n", __func__, current_val); + ret = 1; + } + + return ret; +} + +static int pmif_init_ulposc(void) +{ + int ret = 1; + + /* calibrate ULPOSC1 */ + pmif_ulposc_config(); + + /* enable spm swinf */ + if ((read32(&mtk_spm->poweron_config_en) & 0x1) != 0x1) + write32(&mtk_spm->poweron_config_en, (0xb16 << 16) | 0x1); + + /* turn on ulposc */ + write32(&mtk_spm->ulposc_con, read32(&mtk_spm->ulposc_con) | 0x1); + udelay(100); + write32(&mtk_spm->ulposc_con, read32(&mtk_spm->ulposc_con) | 0x1 << 2); + + ret = pmif_ulposc_cali(); + return ret; +} + +int pmif_clk_init(void) +{ + int ret = 1; + + ret = pmif_init_ulposc(); + if(ret) + return -E_NODEV; + + /* turn off pmic_cg_tmr, cg_ap, cg_md, cg_conn clock */ + write32(&mt8192_infracfg->module_sw_cg_0_set, 0xf); + /* Use MTS: modem_temp_share_cg need to enable + * DRV_WriteReg32(MODULE_SW_CG_2_SET, 0x00000020); + * Use TIA: modem_temp_share_cg not need + */ + write32(&mtk_topckgen->clk_cfg_8_clr, (0x1 << 15) | (0x1 << 12) | (0x7 << 8)); + write32(&mtk_topckgen->clk_cfg_update1, 0x1 << 2); + + /* use ULPOSC1 clock */ + write32(&mt8192_infracfg->pmicw_clock_ctrl_clr, 0xf); + + /* toggle SPMI sw reset */ + write32(&mt8192_infracfg->infra_globalcon_rst2_set, 0x1 << 14); + write32(&mt8192_infracfg->infra_globalcon_rst2_clr, 0x1 << 14); + + /* toggle SPI sw reset */ + write32(&mt8192_infracfg->infra_globalcon_rst2_set, 0x1); + write32(&mt8192_infracfg->infra_globalcon_rst2_clr, 0x1); + + /* turn on pmic_cg_tmr, cg_ap, cg_md, cg_conn clock */ + write32(&mt8192_infracfg->module_sw_cg_0_clr, 0xf); + /* Use MTS: modem_temp_share_cg need to enable + * DRV_WriteReg32(MODULE_SW_CG_2_CLR, 0x00000020); + * Use TIA: modem_temp_share_cg not need + */ + + return 0; +} diff --git a/src/soc/mediatek/mt8192/pmif_spi.c b/src/soc/mediatek/mt8192/pmif_spi.c new file mode 100644 index 0000000..e1d77aa --- /dev/null +++ b/src/soc/mediatek/mt8192/pmif_spi.c @@ -0,0 +1,319 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <delay.h> +#include <device/mmio.h> +#include <soc/infracfg.h> +#include <soc/pll.h> +#include <soc/pmif.h> +#include <soc/pmif_spi.h> +#include <soc/pmif_sw.h> +#include <timer.h> + +/* PMIF, SPI_MODE_CTRL */ +DEFINE_BIT(SPI_MODE_CTRL_VLD_SRCLK_EN_CTRL, 5) +DEFINE_BIT(SPI_MODE_CTRL_PMIF_RDY, 9) +DEFINE_BIT(SPI_MODE_CTRL_SRCLK_EN, 10) +DEFINE_BIT(SPI_MODE_CTRL_SRVOL_EN, 11) + +/* PMIF, SLEEP_PROTECTION_CTRL */ +DEFINE_BITFIELD(SPM_SLEEP_REQ_SEL, 1, 0) +DEFINE_BITFIELD(SCP_SLEEP_REQ_SEL, 10, 9) + +/* PMIF, STAUPD_CTRL */ +DEFINE_BITFIELD(STAUPD_CTRL_PRD, 3, 0) +DEFINE_BIT(STAUPD_CTRL_PMIC0_SIG_STA, 4) +DEFINE_BIT(STAUPD_CTRL_PMIC0_EINT_STA, 6) + +/* SPIMST, Manual_Mode_Access */ +DEFINE_BIT(SPI_RW, 13) +DEFINE_BITFIELD(SPI_OP, 12, 8) + +static void pmif_spi_config(struct pmif *arb) +{ + /* Set srclk_en always valid regardless of ulposc_sel_for_scp */ + SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, SPI_MODE_CTRL_VLD_SRCLK_EN_CTRL, 0); + + + /* Set SPI mode controlled by srclk_en and srvol_en instead of pmif_rdy */ + SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, SPI_MODE_CTRL_SRCLK_EN, 1, SPI_MODE_CTRL_SRVOL_EN, 1); + SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, SPI_MODE_CTRL_PMIF_RDY, 0); + + SET32_BITFIELDS(&arb->mtk_pmif->sleep_protection_ctrl, SPM_SLEEP_REQ_SEL, 0); + SET32_BITFIELDS(&arb->mtk_pmif->sleep_protection_ctrl, SCP_SLEEP_REQ_SEL, 0); + + /* Enable SWINF for AP */ + write32(&arb->mtk_pmif->inf_en, PMIF_SPI_AP_SWINF_CHAN_NO); + + /* Enable arbitration for SWINF for AP */ + write32(&arb->mtk_pmif->arb_en, PMIF_SPI_AP_SWINF_CHAN_NO); + + /* Enable PMIF_SPI Command Issue */ + write32(&arb->mtk_pmif->cmdissue_en, 1); +} + +static signed int reset_spislv(void) +{ + unsigned int pmicspi_mst_dio_en_backup, rdata; + struct stopwatch sw; + + write32(&mtk_pmicspi_mst->wrap_en, 0); + write32(&mtk_pmicspi_mst->mux_sel, 1); + write32(&mtk_pmicspi_mst->man_en, 1); + pmicspi_mst_dio_en_backup = read32(&mtk_pmicspi_mst->dio_en); + write32(&mtk_pmicspi_mst->dio_en, 0); + + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, SPI_RW, OP_WR, SPI_OP, OP_CSL); + /* Reset counter */ + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, SPI_RW, OP_WR, SPI_OP, OP_OUTS); + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, SPI_RW, OP_WR, SPI_OP, OP_CSH); + /* + * In order to pull CSN signal to PMIC, + * PMIC will count it then reset spi slave + */ + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, SPI_RW, OP_WR, SPI_OP, OP_OUTS); + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, SPI_RW, OP_WR, SPI_OP, OP_OUTS); + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, SPI_RW, OP_WR, SPI_OP, OP_OUTS); + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, SPI_RW, OP_WR, SPI_OP, OP_OUTS); + + /* Wait for PMIC SPI Master to be idle */ + stopwatch_init_usecs_expire(&sw, PMIF_WAIT_IDLE_US); + do { + rdata = read32(&mtk_pmicspi_mst->other_busy_sta_0); + if (stopwatch_expired(&sw)) { + printk(BIOS_ERR, "[%s] timeout\n", __func__); + return E_TIMEOUT; + } + } while (GET_PMICSPI_BUSY(rdata) != 0x0); + + write32(&mtk_pmicspi_mst->man_en, 0); + write32(&mtk_pmicspi_mst->mux_sel, 0); + write32(&mtk_pmicspi_mst->wrap_en, 1); + write32(&mtk_pmicspi_mst->dio_en, pmicspi_mst_dio_en_backup); + + return 0; +} + +static void init_reg_clock(struct pmif *arb) +{ + unsigned int rdata; + + /* Set SoC SPI IO driving strength to 4 mA */ + write32(&mtk_iocfg_tl->drv_cfg0_clr, 0x7 << 21); + write32(&mtk_iocfg_tl->drv_cfg0_set, 0x1 << 21); + + /* Configure SPI protocol */ + write32(&mtk_pmicspi_mst->ext_ck_write, 1); + write32(&mtk_pmicspi_mst->ext_ck_read, 0); + write32(&mtk_pmicspi_mst->cshext_write, 0); + write32(&mtk_pmicspi_mst->cshext_read, 0); + write32(&mtk_pmicspi_mst->cslext_write, 0); + write32(&mtk_pmicspi_mst->cslext_read, 0x100); + + /* Set Read Dummy Cycle Number (Slave Clock is 18MHz) */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_DEW_RDDMY_NO, DUMMY_READ_CYCLES); + write32(&mtk_pmicspi_mst->rddmy, DUMMY_READ_CYCLES); + + /* Enable DIO mode */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_DEW_DIO_EN, 0x1); + + /* Wait for completion of sending the commands */ + do { + rdata = read32(&arb->mtk_pmif->inf_busy_sta); + } while ((rdata & PMIF_SPI_AP_SWINF_CHAN_NO) != 0x0); + + do { + rdata = read32(&arb->mtk_pmif->other_busy_sta_0); + } while (GET_CMDISSUE_BUSY(rdata) != 0x0); + + do { + rdata = read32(&mtk_pmicspi_mst->other_busy_sta_0); + } while (GET_PMICSPI_BUSY(rdata) != 0x0); + + write32(&mtk_pmicspi_mst->dio_en, 1); +} + +static void init_spislv(struct pmif *arb) +{ + /* Turn on SPI IO filter function */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_FILTER_CON0, SPI_FILTER); + /* Turn on SPI IO SMT function to improve noise immunity */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_SMT_CON1, SPI_SMT); + /* Turn off SPI IO pull function for power saving */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_GPIO_PULLEN0_CLR, SPI_PULL_DISABLE); + /* Enable SPI access in SODI-3.0 and Suspend modes */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_RG_SPI_CON0, 0x2); + /* Set SPI IO driving strength to 4 mA */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_DRV_CON1, SPI_DRIVING); +} + +static s32 init_sistrobe(struct pmif *arb) +{ + unsigned int rdata = 0; + int si_sample_ctrl; + int test_data[30] = { + 0x6996, 0x9669, 0x6996, 0x9669, 0x6996, 0x9669, 0x6996, + 0x9669, 0x6996, 0x9669, 0x5AA5, 0xA55A, 0x5AA5, 0xA55A, + 0x5AA5, 0xA55A, 0x5AA5, 0xA55A, 0x5AA5, 0xA55A, 0x1B27, + 0x1B27, 0x1B27, 0x1B27, 0x1B27, 0x1B27, 0x1B27, 0x1B27, + 0x1B27, 0x1B27}; + + for (si_sample_ctrl = 0; si_sample_ctrl < 16; si_sample_ctrl++) { + write32(&mtk_pmicspi_mst->si_sampling_ctrl, si_sample_ctrl << 5); + + arb->read_cmd(arb, DEFAULT_SLVID, PMIC_DEW_READ_TEST, &rdata); + if (rdata == DEFAULT_VALUE_READ_TEST) + break; + } + + if (si_sample_ctrl == 16) + return E_CLK_EDGE; + + if (si_sample_ctrl == 15) + return E_CLK_LAST_SETTING; + + /* + * Add the delay time of SPI data from PMIC to align the start boundary + * to current sampling clock edge. + */ + for (int si_dly = 0; si_dly < 10; si_dly++) { + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_RG_SPI_CON2, si_dly); + + int start_boundary_found = 0; + for (size_t i = 0; i < 30; i++) { + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_DEW_WRITE_TEST, test_data[i]); + arb->read_cmd(arb, DEFAULT_SLVID, PMIC_DEW_WRITE_TEST, &rdata); + if ((rdata & 0x7fff) != (test_data[i] & 0x7fff)) { + start_boundary_found = 1; + break; + } + } + if (start_boundary_found == 1) + break; + } + + /* + * Change the sampling clock edge to the next one which is the middle + * of SPI data window. + */ + write32(&mtk_pmicspi_mst->si_sampling_ctrl, ++si_sample_ctrl << 5); + + /* Read Test */ + arb->read_cmd(arb, DEFAULT_SLVID, PMIC_DEW_READ_TEST, &rdata); + if (rdata != DEFAULT_VALUE_READ_TEST) { + printk(BIOS_ERR, "[%s] rdata = %#x, exp = %#x\n", + __func__, rdata, DEFAULT_VALUE_READ_TEST); + return E_READ_TEST_FAIL; + } + + return 0; +} + +static void initstaupd(struct pmif *arb) +{ + unsigned int rdata; + + /* Unlock SPI Slave registers */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_SPISLV_KEY, 0xbade); + + /* Enable CRC of PMIC 0 */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_DEW_CRC_EN, 0x1); + + /* Wait for completion of sending the commands */ + do { + rdata = read32(&arb->mtk_pmif->inf_busy_sta); + } while ((rdata & PMIF_SPI_AP_SWINF_CHAN_NO) != 0x0); + + do { + rdata = read32(&arb->mtk_pmif->other_busy_sta_0); + } while (GET_CMDISSUE_BUSY(rdata) != 0x0); + + do { + rdata = read32(&mtk_pmicspi_mst->other_busy_sta_0); + } while (GET_PMICSPI_BUSY(rdata) != 0x0); + + /* Configure CRC of PMIC Interface */ + write32(&arb->mtk_pmif->crc_ctrl, 0x1); + write32(&arb->mtk_pmif->sig_mode, 0x0); + + /* Lock SPI Slave registers */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_SPISLV_KEY, 0x0); + + /* Setup PMIC Siganature */ + write32(&arb->mtk_pmif->pmic_sig_addr, PMIC_DEW_CRC_VAL); + + /* Setup PMIC EINT */ + write32(&arb->mtk_pmif->pmic_eint_sta_addr, PMIC_INT_STA); + + SET32_BITFIELDS(&arb->mtk_pmif->staupd_ctrl, STAUPD_CTRL_PRD, 5, + STAUPD_CTRL_PMIC0_SIG_STA, 1, STAUPD_CTRL_PMIC0_EINT_STA, 1); +} + +int pmif_spi_init(struct pmif *arb) +{ + int sub_return = 0; + + pmif_spi_config(arb); + + /* Reset spislv */ + sub_return = reset_spislv(); + if (sub_return != 0) + return E_SPI_INIT_RESET_SPI; + + /* Enable WRAP */ + write32(&mtk_pmicspi_mst->wrap_en, 0x1); + + /* SPI Waveform Configuration */ + init_reg_clock(arb); + + /* SPI Slave Configuration */ + init_spislv(arb); + + /* Input data calibration flow; */ + sub_return = init_sistrobe(arb); + if (sub_return != 0) { + printk(BIOS_ERR, "[%s] data calibration fail,ret=%d\n", + __func__, sub_return); + return E_SPI_INIT_SIDLY; + } + + /* Lock SPISLV Registers */ + arb->write_cmd(arb, DEFAULT_SLVID, PMIC_SPISLV_KEY, 0x0); + + /* + * Status update function initialization + * 1. Signature Checking using CRC (CRC 0 only) + * 2. EINT update + * 3. Read back Auxadc thermal data for GPS + */ + initstaupd(arb); + + /* Configure PMIF Timer */ + write32(&arb->mtk_pmif->timer_ctrl, 0x3); + + /* Enable interfaces and arbitration */ + write32(&arb->mtk_pmif->inf_en, 0x307f | + PMIF_SPI_MD_SWINF_CHAN_NO | + PMIF_SPI_AP_SECURE_SWINF_CHAN_NO | + PMIF_SPI_AP_SWINF_CHAN_NO); + + write32(&arb->mtk_pmif->arb_en, 0x707f | + PMIF_SPI_MD_SWINF_CHAN_NO | + PMIF_SPI_AP_SECURE_SWINF_CHAN_NO | + PMIF_SPI_AP_SWINF_CHAN_NO); + + /* Enable GPS AUXADC HW 0 and 1 */ + write32(&arb->mtk_pmif->arb_en, read32(&arb->mtk_pmif->arb_en) | (0x3 << 19)); + write32(&arb->mtk_pmif->other_inf_en, read32(&arb->mtk_pmif->other_inf_en) | (0x3 << 4)); + + /* Set INIT_DONE */ + write32(&arb->mtk_pmif->init_done, 0x1); + + /* Configure MD ADC Interface */ + udelay(100); + + /* write MODEM_TEMP_SHARE_CTRL start */ + write32(&mtk_modem_temp_share->ctrl, 0xf0); + + return 0; +} diff --git a/src/soc/mediatek/mt8192/pmif_spmi.c b/src/soc/mediatek/mt8192/pmif_spmi.c new file mode 100644 index 0000000..4a9af68 --- /dev/null +++ b/src/soc/mediatek/mt8192/pmif_spmi.c @@ -0,0 +1,256 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <soc/pmif.h> +#include <soc/spmi.h> +#include <soc/pmif_sw.h> +#include <soc/pmif_spmi.h> +#include <soc/addressmap.h> +#include <device/mmio.h> +#include <string.h> +#include <console/console.h> +#include <soc/pll.h> +#include <soc/pll_common.h> + +#define PMIF_CMD_PER_3 (0x1 << PMIF_CMD_EXT_REG_LONG) +#define PMIF_CMD_PER_1_3 \ + ((0x1 << PMIF_CMD_REG) | (0x1 << PMIF_CMD_EXT_REG_LONG)) +#define PMIF_CMD_PER_2_3 \ + ((0x1 << PMIF_CMD_EXT_REG) | (0x1 << PMIF_CMD_EXT_REG_LONG)) + +/* spmi master setting */ +struct spmi_device spmi_dev[] = { + { + .slvid = SPMI_SLAVE_6, + .grpiden = 0x800, + .type = BUCK_CPU, + .type_id = BUCK_CPU_ID, + }, { + .slvid = SPMI_SLAVE_7, + .grpiden = 0x800, + .type = BUCK_GPU, + .type_id = BUCK_GPU_ID, + }, +}; + +static int spmi_config_io(void) +{ + /* 0'b010 SPMI_SCL[5:3]; */ + write32(&mtk_iocfg_bm->drv_cfg2_set, 0x2 << SPMI_SCL_DRV_SHIFT); + write32(&mtk_iocfg_bm->drv_cfg2_clr, 0x5 << SPMI_SCL_DRV_SHIFT); + /* 0'b010 SPMI_SDA[6:8] */ + write32(&mtk_iocfg_bm->drv_cfg2_set, 0x2 << SPMI_SDA_DRV_SHIFT); + write32(&mtk_iocfg_bm->drv_cfg2_clr, 0x5 << SPMI_SDA_DRV_SHIFT); + + return 0; +} + +static int spmi_config_master(void) +{ + /* Software reset */ + write32(&mtk_rug->wdt_swsysrst2, + (WDT_UNLOCK_KEY << WDT_UNLOCK_SHIFT) | \ + (0x1 << SPMIMST_RST_SHIFT)); + + write32(&mtk_topckgen->clk_cfg_15_clr, (0x700) | (0x1 << 12) | (0x1 << 15)); + write32(&mtk_topckgen->clk_cfg_update2, (0x1 << 30)); + + /* Software reset */ + write32(&mtk_rug->wdt_swsysrst2, (WDT_UNLOCK_KEY << WDT_UNLOCK_SHIFT)); + + /* Enable SPMI */ + write32(&mtk_spmi_mst->mst_req_en, 1); + + return 0; +} + +static int spmi_read_check(struct pmif *pmif_arb, int slvid) +{ + unsigned int rdata = 0; + + + /* MT6315_PMIC_HWCID_H_ADDR/MT6315_HWCID_H 0x9 */ + pmif_arb->read_cmd(pmif_arb, slvid, 0x9, &rdata); + if (rdata != 0x15) { + printk(BIOS_ERR, "%s next, slvid:%d rdata = 0x%x.\n", + __func__, slvid, rdata); + return -E_IO; + } + + /*MT6315_PMIC_SWCID_H_ADDR/MT6315_SWCID_H 0xb*/ + pmif_arb->read_cmd(pmif_arb, slvid, 0xb, &rdata); + if (rdata != 0x15) { + printk(BIOS_ERR, "%s next, slvid:%d rdata = 0x%x.\n", + __func__, slvid, rdata); + return -E_IO; + } + + return 0; +} + +static int spmi_cali_rd_clock_polarity(struct pmif *pmif_arb, struct spmi_device *dev) +{ + unsigned int i = 0; + struct cali cali_data[] = { + {SPMI_CK_DLY_1T, SPMI_CK_POL_POS}, + {SPMI_CK_NO_DLY, SPMI_CK_POL_POS}, + {SPMI_CK_NO_DLY, SPMI_CK_POL_NEG} + }; + + /* Indicate sampling clock polarity, 1: Positive 0: Negative */ + for (i = 0;i < 3; i++) { + write32(&mtk_spmi_mst->mst_sampl, (cali_data[i].dly << 0x1) | cali_data[i].pol); + if (spmi_read_check(pmif_arb, dev->slvid) == 0) + break; + } + + if (i == 3) { + printk(BIOS_ERR, "FATAL ERROR"); + /* ASSERT(0); */ + } + + return 0; +} + +static int spmi_mst_init(struct pmif *pmif_arb) +{ + int i; + unsigned char spmi_device_cnt; + + if (pmif_arb == NULL) { + printk(BIOS_ERR, "arguments err\n"); + return -E_INVAL; + } + + /* config IOCFG */ + spmi_config_io(); + spmi_config_master(); + + spmi_device_cnt = sizeof(spmi_dev)/sizeof(spmi_dev[0]); + for (i = 0; i < spmi_device_cnt; i++) { + //spmi_dev[i].pmif_arb = pmif_spmi_arb_ctrl[pmif_arb->mstid]; + spmi_cali_rd_clock_polarity(pmif_arb, &spmi_dev[i]); + } + + return 0; +} + +static void pmif_spmi_force_normal_mode(int mstid) +{ + struct pmif *arb = get_pmif_controller(PMIF_SPMI, mstid); + unsigned int value; + + /* listen srclken_0 only for entering normal or sleep mode */ + value = read32(&arb->mtk_pmif->spi_mode_ctrl) & (~(0x1 << 7)); + write32(&arb->mtk_pmif->spi_mode_ctrl, value); + + /* enable srclken_en or srvol_en(VREQ) control */ + value |= ((0x1 << 12) | (0x1 << 13)); + /* disable srclken_rc control */ + value &= (~(0x1 << 11)); + write32(&arb->mtk_pmif->spi_mode_ctrl, value); + + /* enable spm/scp sleep request */ + value = read32(&arb->mtk_pmif->sleep_protection_ctrl); + value &= (~0x3); + value &= (~(0x3 << 9)); + write32(&arb->mtk_pmif->sleep_protection_ctrl, value); +} + +static void pmif_spmi_enable_swinf(int mstid, unsigned int chan_no, + unsigned int swinf_no) +{ + struct pmif *arb = get_pmif_controller(PMIF_SPMI, mstid); + + /* Enable swinf chan_no = 4, swinf_no = 2*/ + write32(&arb->mtk_pmif->inf_en, 0x1 << (chan_no + swinf_no)); + + /* Enable arbitration */ + write32(&arb->mtk_pmif->arb_en, 0x1 << (chan_no + swinf_no)); +} + +static void pmif_spmi_enable_cmdIssue(int mstid, bool en) +{ + struct pmif *arb = get_pmif_controller(PMIF_SPMI, mstid); + + /* Enable cmdIssue */ + write32(&arb->mtk_pmif->cmdissue_en, en); +} + +static void pmif_spmi_enable(int mstid) +{ + struct pmif *arb = get_pmif_controller(PMIF_SPMI, mstid); + unsigned int bytecnt_per = 0, hw_bytecnt = 0; + unsigned int cmd_per = 0; + + /* clear all cmd permission for per channel */ + write32(&arb->mtk_pmif->inf_cmd_per_0, 0); + write32(&arb->mtk_pmif->inf_cmd_per_1, 0); + write32(&arb->mtk_pmif->inf_cmd_per_2, 0); + write32(&arb->mtk_pmif->inf_cmd_per_3, 0); + + /* enable if we need cmd 0~3 permission for per channel */ + cmd_per = PMIF_CMD_PER_3 << 28 | PMIF_CMD_PER_3 << 24 | + PMIF_CMD_PER_3 << 20 | PMIF_CMD_PER_3 << 16 | + PMIF_CMD_PER_3 << 8 | PMIF_CMD_PER_3 << 4 | + PMIF_CMD_PER_1_3 << 0; + write32(&arb->mtk_pmif->inf_cmd_per_0, cmd_per); + cmd_per = PMIF_CMD_PER_3 << 4; + write32(&arb->mtk_pmif->inf_cmd_per_1, cmd_per); + + /* set bytecnt max limitation*/ + write32(&arb->mtk_pmif->inf_max_bytecnt_per_0, 0); + write32(&arb->mtk_pmif->inf_max_bytecnt_per_1, 0); + write32(&arb->mtk_pmif->inf_max_bytecnt_per_2, 0); + write32(&arb->mtk_pmif->inf_max_bytecnt_per_3, 0); + + /* hw bytecnt indicate when we set 0, it can send 1 byte; + * set 1, it can send 2 byte. + */ + hw_bytecnt = PMIF_BYTECNT_MAX -1; + if (hw_bytecnt > 0) { + bytecnt_per = hw_bytecnt << 28 | hw_bytecnt << 24 | + hw_bytecnt << 20 | hw_bytecnt << 16 | + hw_bytecnt << 12 | hw_bytecnt << 8 | + hw_bytecnt << 4 | hw_bytecnt << 0; + } + write32(&arb->mtk_pmif->inf_max_bytecnt_per_0, bytecnt_per); + write32(&arb->mtk_pmif->inf_max_bytecnt_per_1, bytecnt_per); + write32(&arb->mtk_pmif->inf_max_bytecnt_per_2, bytecnt_per); + write32(&arb->mtk_pmif->inf_max_bytecnt_per_3, bytecnt_per); + + /* Add latency limitation */ + write32(&arb->mtk_pmif->lat_cnter_en, 0x2F7); + write32(&arb->mtk_pmif->lat_limit_0, 0); + write32(&arb->mtk_pmif->lat_limit_1, 0x4); + write32(&arb->mtk_pmif->lat_limit_2, 0x8); + write32(&arb->mtk_pmif->lat_limit_4, 0x8); + write32(&arb->mtk_pmif->lat_limit_6, 0x3FF); + write32(&arb->mtk_pmif->lat_limit_9, 0x4); + write32(&arb->mtk_pmif->lat_limit_loading, 0x2F7); + + write32(&arb->mtk_pmif->inf_en, 0x2F7); + write32(&arb->mtk_pmif->arb_en, 0x2F7); + write32(&arb->mtk_pmif->timer_ctrl, 0x3); + write32(&arb->mtk_pmif->init_done, 1); +} + +int pmif_spmi_init(struct pmif *arb) +{ + int ret = 0; + + if (arb->is_pmif_init_done(arb) != 0) { + pmif_spmi_force_normal_mode(arb->mstid); + pmif_spmi_enable_swinf(arb->mstid, PMIF_SWINF_0_CHAN_NO, arb->swinf_no); + pmif_spmi_enable_cmdIssue(arb->mstid, true); + pmif_spmi_enable(arb->mstid); + ret = arb->is_pmif_init_done(arb); + if(ret) + return -E_NODEV; + } + + ret = spmi_mst_init(arb); + if(ret) + return -E_NODEV; + + return 0; +}
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 1:
(76 comments)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 80: #define PMIF_SPI_AP_SECURE_SWINF_CHAN_NO BIT(PMIF_SPI_SWINF_0_CHAN_NO + PMIF_SPI_AP_SECURE_SWINF_NO) line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 89: SPI_CLK = 0x1, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 89: SPI_CLK = 0x1, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 90: SPI_CSN = 0x1 << 1, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 90: SPI_CSN = 0x1 << 1, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 91: SPI_MOSI = 0x1 << 2, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 91: SPI_MOSI = 0x1 << 2, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 92: SPI_MISO = 0x1 << 3, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 92: SPI_MISO = 0x1 << 3, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 93: SPI_FILTER = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 93: SPI_FILTER = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 94: SPI_SMT = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO), code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 94: SPI_SMT = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO), please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 95: SPI_PULL_DISABLE = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 95: SPI_PULL_DISABLE = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 99: IO_4_MA = 0x8, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 99: IO_4_MA = 0x8, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 103: SPI_CLK_SHIFT = 0, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 103: SPI_CLK_SHIFT = 0, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 104: SPI_CSN_SHIFT = 4, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 104: SPI_CSN_SHIFT = 4, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 105: SPI_MOSI_SHIFT = 8, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 105: SPI_MOSI_SHIFT = 8, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 106: SPI_MISO_SHIFT = 12, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 106: SPI_MISO_SHIFT = 12, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 107: SPI_DRIVING = (IO_4_MA << SPI_CLK_SHIFT | IO_4_MA << SPI_CSN_SHIFT | code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 107: SPI_DRIVING = (IO_4_MA << SPI_CLK_SHIFT | IO_4_MA << SPI_CSN_SHIFT | please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 108: IO_4_MA << SPI_MOSI_SHIFT | IO_4_MA << SPI_MISO_SHIFT), code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 108: IO_4_MA << SPI_MOSI_SHIFT | IO_4_MA << SPI_MISO_SHIFT), please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 124: DUMMY_READ_CYCLES = 0X8, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 124: DUMMY_READ_CYCLES = 0X8, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 89: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 95: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 101: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 108: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 114: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 120: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 21: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 29: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 49: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 61: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 15: static unsigned int pmif_check_idle(struct pmif *arb, unsigned int timeout_us) { open brace '{' following function definitions go on the next line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 28: return 0; please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 31: static inline unsigned int pmif_check_vldclr(struct pmif *arb, unsigned int timeout_us) { open brace '{' following function definitions go on the next line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 44: return 0; please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 57: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 76: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 87: static int pmif_spmi_read_cmd(struct pmif *arb,unsigned int slvid, space required after that ',' (ctx:VxV)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 91: return pmif_send_cmd(arb, 0, PMIF_CMD_EXT_REG_LONG, slvid, addr, rdata, 0, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 97: return pmif_send_cmd(arb, 1, PMIF_CMD_EXT_REG_LONG, slvid, addr, NULL, wdata, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 104: return pmif_send_cmd(arb, 0, PMIF_CMD_REG_0, slvid, addr, rdata, 0, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 110: return pmif_send_cmd(arb, 1, PMIF_CMD_REG_0, slvid, addr, NULL, wdata, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 43: while (read32(&mtk_topckgen->clk26cali_0) & 0x10) that open brace { should be on the previous line
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 47: if(i > 100) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 52: output = ((temp * 26000) ) / 1024; /* Khz */ space prohibited before that close parenthesis ')'
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 66: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x1 << 24)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 69: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x3f << 18)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 73: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0xf << 14)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 77: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f << 7)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 81: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 89: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0x1 << 26)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 92: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0x3 << 24)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 95: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff << 16)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 98: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff << 8)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 102: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 109: write32(&mtk_apmixed->ulposc1_con2, read32(&mtk_apmixed->ulposc1_con2) &~(0xff)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 119: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 203: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 39: SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, SPI_MODE_CTRL_SRCLK_EN, 1, SPI_MODE_CTRL_SRVOL_EN, 1); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 307: write32(&arb->mtk_pmif->other_inf_en, read32(&arb->mtk_pmif->other_inf_en) | (0x3 << 4)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 51: (WDT_UNLOCK_KEY << WDT_UNLOCK_SHIFT) | \ Avoid unnecessary line continuations
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 100: for (i = 0;i < 3; i++) { space required after that ';' (ctx:VxV)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 128: spmi_device_cnt = sizeof(spmi_dev)/sizeof(spmi_dev[0]); Prefer ARRAY_SIZE(spmi_dev)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 209: hw_bytecnt = PMIF_BYTECNT_MAX -1; need consistent spacing around '-' (ctx:WxV)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 247: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 252: if(ret) space required before the open parenthesis '('
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 1:
(10 comments)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 89: SPI_CLK = 0x1,
code indent should use tabs where possible
please fix the tab below.
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 27: 89 replace 89 by the real GPIO name.
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 27: SPMI_SCL_GPIO enum
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 89: {
open brace '{' following enum go on the same line
enum {
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 115: ((read32(&arb->mtk_pmif->init_done) & 0x1)) if (read32() & 0x1)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 157: int ret = 1; : : ret = pmif_clk_init(); : if (ret) : goto FAIL; : : ret = pmif_spmi_init(&pmif_spmi_arb[SPMI_MASTER_0]); : if (ret) : goto FAIL; : : ret = pmif_spi_init(&pmif_spi_arb[0]); : if (ret) : goto FAIL; : : return 0; : : FAIL: : /* assert(0); */ : return ret; int ret;
ret = pmif_clk_init(); if (!ret) ret = pmif_spmi_init(&pmif_spmi_arb[SPMI_MASTER_0]); if (!ret) ret = pmif_spi_init(&pmif_spi_arb[0]);
return ret;
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 13: #define FREQ_260MHZ 260 : /* calibation miss rate, unit: 0.1% */ : #define CAL_MIS_RATE 40 : /* : * FREQ METER ID : * Ask clkmgr owner to find this information : * at clock table[fmeter]. : */ : #define FREQ_METER_ABIST_AD_OSC_CK 37 : #define CAL_MAX_VAL 0x7f use enum
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 24: ID id
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 31: )|( ) | (
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 66: write32 consider SET32_BITFIELD?
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 1:
Is PMIF going to be a popular (and shared) interface for future SOCs? Maybe we should move the some of these to common/?
Yidi Lin has uploaded a new patch set (#2) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface(PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
TEST=Boots correctly on MT8192EVB.
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,510 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/2
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 2:
(77 comments)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 87: SPI_CLK = 0x1, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 87: SPI_CLK = 0x1, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 88: SPI_CSN = 0x1 << 1, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 88: SPI_CSN = 0x1 << 1, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 89: SPI_MOSI = 0x1 << 2, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 89: SPI_MOSI = 0x1 << 2, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 90: SPI_MISO = 0x1 << 3, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 90: SPI_MISO = 0x1 << 3, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 91: SPI_FILTER = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 91: SPI_FILTER = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 92: SPI_SMT = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO), code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 92: SPI_SMT = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO), please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 93: SPI_PULL_DISABLE = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 93: SPI_PULL_DISABLE = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 97: IO_4_MA = 0x8, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 97: IO_4_MA = 0x8, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 101: SPI_CLK_SHIFT = 0, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 101: SPI_CLK_SHIFT = 0, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 102: SPI_CSN_SHIFT = 4, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 102: SPI_CSN_SHIFT = 4, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 103: SPI_MOSI_SHIFT = 8, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 103: SPI_MOSI_SHIFT = 8, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 104: SPI_MISO_SHIFT = 12, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 104: SPI_MISO_SHIFT = 12, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 105: SPI_DRIVING = (IO_4_MA << SPI_CLK_SHIFT | IO_4_MA << SPI_CSN_SHIFT | code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 105: SPI_DRIVING = (IO_4_MA << SPI_CLK_SHIFT | IO_4_MA << SPI_CSN_SHIFT | please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 106: IO_4_MA << SPI_MOSI_SHIFT | IO_4_MA << SPI_MISO_SHIFT), code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 106: IO_4_MA << SPI_MOSI_SHIFT | IO_4_MA << SPI_MISO_SHIFT), please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 122: DUMMY_READ_CYCLES = 0X8, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 122: DUMMY_READ_CYCLES = 0X8, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 89: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 95: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 101: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 108: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 114: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 120: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 21: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 29: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 49: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/inc... PS2, Line 61: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 15: static unsigned int pmif_check_idle(struct pmif *arb, unsigned int timeout_us) { open brace '{' following function definitions go on the next line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 28: return 0; please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 31: static inline unsigned int pmif_check_vldclr(struct pmif *arb, unsigned int timeout_us) { open brace '{' following function definitions go on the next line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 44: return 0; please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 57: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 76: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 87: static int pmif_spmi_read_cmd(struct pmif *arb,unsigned int slvid, space required after that ',' (ctx:VxV)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 91: return pmif_send_cmd(arb, 0, PMIF_CMD_EXT_REG_LONG, slvid, addr, rdata, 0, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 97: return pmif_send_cmd(arb, 1, PMIF_CMD_EXT_REG_LONG, slvid, addr, NULL, wdata, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 104: return pmif_send_cmd(arb, 0, PMIF_CMD_REG_0, slvid, addr, rdata, 0, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 110: return pmif_send_cmd(arb, 1, PMIF_CMD_REG_0, slvid, addr, NULL, wdata, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 28: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x1 << 24)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 31: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x3f << 18)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 35: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0xf << 14)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 39: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f << 7)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 43: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 51: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0x1 << 26)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 54: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0x3 << 24)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 57: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff << 16)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 60: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff << 8)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 64: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 71: write32(&mtk_apmixed->ulposc1_con2, read32(&mtk_apmixed->ulposc1_con2) &~(0xff)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 81: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 162: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 69: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_CSL); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 71: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 72: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_CSH); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 77: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 78: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 79: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 80: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 311: write32(&arb->mtk_pmif->other_inf_en, read32(&arb->mtk_pmif->other_inf_en) | (0x3 << 4)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 48: (WDT_UNLOCK_KEY << WDT_UNLOCK_SHIFT) | \ Avoid unnecessary line continuations
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 120: spmi_device_cnt = sizeof(spmi_dev)/sizeof(spmi_dev[0]); Prefer ARRAY_SIZE(spmi_dev)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 200: hw_bytecnt = PMIF_BYTECNT_MAX -1; need consistent spacing around '-' (ctx:WxV)
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 238: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/2/src/soc/mediatek/mt8192/pmi... PS2, Line 243: if(ret) space required before the open parenthesis '('
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 3:
(77 comments)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 87: SPI_CLK = 0x1, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 87: SPI_CLK = 0x1, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 88: SPI_CSN = 0x1 << 1, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 88: SPI_CSN = 0x1 << 1, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 89: SPI_MOSI = 0x1 << 2, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 89: SPI_MOSI = 0x1 << 2, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 90: SPI_MISO = 0x1 << 3, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 90: SPI_MISO = 0x1 << 3, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 91: SPI_FILTER = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 91: SPI_FILTER = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 92: SPI_SMT = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO), code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 92: SPI_SMT = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO), please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 93: SPI_PULL_DISABLE = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 93: SPI_PULL_DISABLE = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 97: IO_4_MA = 0x8, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 97: IO_4_MA = 0x8, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 101: SPI_CLK_SHIFT = 0, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 101: SPI_CLK_SHIFT = 0, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 102: SPI_CSN_SHIFT = 4, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 102: SPI_CSN_SHIFT = 4, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 103: SPI_MOSI_SHIFT = 8, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 103: SPI_MOSI_SHIFT = 8, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 104: SPI_MISO_SHIFT = 12, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 104: SPI_MISO_SHIFT = 12, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 105: SPI_DRIVING = (IO_4_MA << SPI_CLK_SHIFT | IO_4_MA << SPI_CSN_SHIFT | code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 105: SPI_DRIVING = (IO_4_MA << SPI_CLK_SHIFT | IO_4_MA << SPI_CSN_SHIFT | please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 106: IO_4_MA << SPI_MOSI_SHIFT | IO_4_MA << SPI_MISO_SHIFT), code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 106: IO_4_MA << SPI_MOSI_SHIFT | IO_4_MA << SPI_MISO_SHIFT), please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 122: DUMMY_READ_CYCLES = 0X8, code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 122: DUMMY_READ_CYCLES = 0X8, please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 89: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 95: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 101: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 108: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 114: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 120: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 21: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 29: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 49: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/inc... PS3, Line 61: { open brace '{' following enum go on the same line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 15: static unsigned int pmif_check_idle(struct pmif *arb, unsigned int timeout_us) { open brace '{' following function definitions go on the next line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 28: return 0; please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 31: static inline unsigned int pmif_check_vldclr(struct pmif *arb, unsigned int timeout_us) { open brace '{' following function definitions go on the next line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 44: return 0; please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 57: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 76: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 87: static int pmif_spmi_read_cmd(struct pmif *arb,unsigned int slvid, space required after that ',' (ctx:VxV)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 91: return pmif_send_cmd(arb, 0, PMIF_CMD_EXT_REG_LONG, slvid, addr, rdata, 0, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 97: return pmif_send_cmd(arb, 1, PMIF_CMD_EXT_REG_LONG, slvid, addr, NULL, wdata, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 104: return pmif_send_cmd(arb, 0, PMIF_CMD_REG_0, slvid, addr, rdata, 0, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 110: return pmif_send_cmd(arb, 1, PMIF_CMD_REG_0, slvid, addr, NULL, wdata, (PMIF_BYTECNT_MAX - 1)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 28: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x1 << 24)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 31: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x3f << 18)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 35: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0xf << 14)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 39: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f << 7)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 43: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 51: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0x1 << 26)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 54: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0x3 << 24)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 57: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff << 16)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 60: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff << 8)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 64: write32(&mtk_apmixed->ulposc1_con1, read32(&mtk_apmixed->ulposc1_con1) &~(0xff)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 71: write32(&mtk_apmixed->ulposc1_con2, read32(&mtk_apmixed->ulposc1_con2) &~(0xff)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 81: write32(&mtk_apmixed->ulposc1_con0, read32(&mtk_apmixed->ulposc1_con0) &~(0x7f)); need consistent spacing around '&' (ctx:WxO)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 162: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 69: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_CSL); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 71: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 72: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_CSH); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 77: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 78: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 79: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 80: SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, MAN_ACC_SPI_OP, OP_OUTS); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 311: write32(&arb->mtk_pmif->other_inf_en, read32(&arb->mtk_pmif->other_inf_en) | (0x3 << 4)); line over 96 characters
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 48: (WDT_UNLOCK_KEY << WDT_UNLOCK_SHIFT) | \ Avoid unnecessary line continuations
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 120: spmi_device_cnt = sizeof(spmi_dev)/sizeof(spmi_dev[0]); Prefer ARRAY_SIZE(spmi_dev)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 200: hw_bytecnt = PMIF_BYTECNT_MAX -1; need consistent spacing around '-' (ctx:WxV)
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 238: if(ret) space required before the open parenthesis '('
https://review.coreboot.org/c/coreboot/+/45398/3/src/soc/mediatek/mt8192/pmi... PS3, Line 243: if(ret) space required before the open parenthesis '('
Yidi Lin has uploaded a new patch set (#4) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface(PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
TEST=Boots correctly on MT8192EVB.
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,423 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/4
Yidi Lin has uploaded a new patch set (#5) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface(PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
TEST=Boots correctly on MT8192EVB.
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,432 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/5
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 7:
(1 comment)
https://review.coreboot.org/c/coreboot/+/45398/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/45398/7//COMMIT_MSG@9 PS7, Line 9: power management interface(PMIF) Please add a space before the (.
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 7:
(23 comments)
https://review.coreboot.org/c/coreboot/+/45398/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/45398/7//COMMIT_MSG@11 PS7, Line 11: Where is the interface documented? Please add a datasheet name and revision.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 99: Print out as a debug message, how long it took?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 171: }; In that pattern documented somewhere?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 217: __func__, rdata, DEFAULT_VALUE_READ_TEST); Please use more elaborate error messages.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 234: /* Wait for completion of sending the commands */ : do { : rdata = read32(&arb->mtk_pmif->inf_busy_sta); : } while ((rdata & PMIF_SPI_AP) != 0x0); : : do { : rdata = read32(&arb->mtk_pmif->other_busy_sta_0); : } while (GET_CMDISSUE_BUSY(rdata) != 0x0); : : do { : rdata = read32(&mtk_pmicspi_mst->other_busy_sta_0); : } while (GET_PMICSPI_BUSY(rdata) != 0x0); Could these be endless loops?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 254: Setup Set up
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 257: Setup Set up
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 268: int ret = 0; Use CB_SUCCESS and friends?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 287: if (ret != 0) { Use CB_SUCCESS and friends.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 288: printk(BIOS_ERR, "[%s] data calibration fail,ret=%d\n", Please elaborate and add a space after the comma.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 298: Checking checking
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 298: 1. Signature Checking using CRC (CRC 0 only) : * 2. EINT update : * 3. Read back Auxadc thermal data for GPS
- Check signature using CRC (CRC 0 only)
- Update EINT
- …
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 300: Auxadc AUXADC
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 302: initstaupd `init_staupd()` for consistency with `init_sistrobe()`.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 321: udelay(100); How is that done by a delay?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 52: }, { Should { be on the next line?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 102: u32 i = 0; The native type should be enough for a counting variable.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 131: printk(BIOS_ERR, "%s: Null argument", __func__); Error messages should be more elaborate and helpful.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 162: u32 swinf_no) Fits into one line.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 200: write32(&arb->mtk_pmif->inf_cmd_per_1, cmd_per); Why does a different value have to be programmed here?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 210: */ Please use one of the recommended coding styles [1].
[1]: https://doc.coreboot.org/coding_style.html#commenting
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 224: 0x2F7 Add enums or macros?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 251: return -E_NODEV; Add a debug message?
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 7:
(4 comments)
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif.h:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 130: int swinf_no; Can the number be signed?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 131: int mstid; Should an id be unsigned?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 55: PMIC_BASE = 0x0000, : PMIC_SMT_CON1 = PMIC_BASE + 0x0032, : PMIC_DRV_CON1 = PMIC_BASE + 0x003a, : PMIC_FILTER_CON0 = PMIC_BASE + 0x0042, : PMIC_GPIO_PULLEN0_CLR = PMIC_BASE + 0x0098, : PMIC_RG_SPI_CON0 = PMIC_BASE + 0x0408, : PMIC_DEW_DIO_EN = PMIC_BASE + 0x040c, : PMIC_DEW_READ_TEST = PMIC_BASE + 0x040e, : PMIC_DEW_WRITE_TEST = PMIC_BASE + 0x0410, : PMIC_DEW_CRC_EN = PMIC_BASE + 0x0414, : PMIC_DEW_CRC_VAL = PMIC_BASE + 0x0416, : PMIC_DEW_RDDMY_NO = PMIC_BASE + 0x0424, : PMIC_RG_SPI_CON2 = PMIC_BASE + 0x0426, : PMIC_SPISLV_KEY = PMIC_BASE + 0x044a, : PMIC_INT_STA = PMIC_BASE + 0x0452, : PMIC_AUXADC_ADC7 = PMIC_BASE + 0x1096, : PMIC_AUXADC_ADC10 = PMIC_BASE + 0x109c, : PMIC_AUXADC_RQST0 = PMIC_BASE + 0x1108, Please use either tabs or spaces for alignment.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 46: int slvid; Can an ID be signed?
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 7:
(4 comments)
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif.h:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 134: unsigned int Why not `uintptr_t`?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 134: rdata Why not just data?
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 134: unsigned int Please use void type.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 136: unsigned int addr, unsigned int wdata); Ditto.
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 11:
(8 comments)
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 89: SPI_CLK = 0x1,
please fix the tab below.
Done
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 27: SPMI_SCL_GPIO
enum
Done
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 27: 89
replace 89 by the real GPIO name.
Done
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 115: ((read32(&arb->mtk_pmif->init_done) & 0x1))
if (read32() & 0x1)
Please address this.
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 157: int ret = 1; : : ret = pmif_clk_init(); : if (ret) : goto FAIL; : : ret = pmif_spmi_init(&pmif_spmi_arb[SPMI_MASTER_0]); : if (ret) : goto FAIL; : : ret = pmif_spi_init(&pmif_spi_arb[0]); : if (ret) : goto FAIL; : : return 0; : : FAIL: : /* assert(0); */ : return ret;
int ret; […]
Please address this.
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 24: ID
id
Done
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 31: )|(
) | (
Done
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 66: write32
consider SET32_BITFIELD?
Done
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 14:
(16 comments)
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/Ma... File src/soc/mediatek/mt8192/Makefile.inc:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/Ma... PS14, Line 12: bootblock Do we really need to enable PMIF in bootblock? Can we do that in romstage?
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif_sw.h:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/in... PS14, Line 13: (0x00) : #define SWINF_FSM_REQ (0x02) : #define SWINF_FSM_WFDLE (0x04) : #define SWINF_FSM_WFVLDCLR (0x06) : #define SWINF_INIT_DONE (0x01) no need to add () if this is a single number
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/in... PS14, Line 25: x always quote x as (x) if you're going to apply operations on it.
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 22: &arb->mtk_pmif->swinf_0_sta + 0x10 * arb->swinf_no slightly concerned about this.
What if we package swinf structure in reg as something like
struct pmif_swinf { type sta; type something; .. }
... struct mtk_pmif { struct pmif_swinf[0x10]; }
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 34: unsigned int reg_rdata; : struct stopwatch sw; : : stopwatch_init_usecs_expire(&sw, timeout_us); : do { : reg_rdata = read32(&arb->mtk_pmif->swinf_0_sta + 0x10 * arb->swinf_no); : if (stopwatch_expired(&sw)) { : printk(BIOS_ERR, "[%s] timeout\n", __func__); : return E_TIMEOUT; : } : } while (GET_SWINF_0_FSM(reg_rdata) != SWINF_FSM_WFVLDCLR); this looks pretty redundant with pmif_check_idle. Can we merge them as a single function
static unsigned int pmif_check_swinf(struct pmif *arb, uint32 expected, ... ) { ... while (GET(...) != expected); }
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 119: ((read32(&arb->mtk_pmif->init_done) & 0x1)) remove one level of quotes.
if (read32() & 0x1)
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 167: (struct pmif *)&pmif_spmi_arb[SPMI_MASTER_0] get_pmif_controller(PMIF_SPMI, SPMI_MASTER_0);
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 171: (struct pmif *)&pmif_spi_arb[0] get_pmif_controller(PMIF_SPI);
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 91: 50 Please explain why 50 is needed, or add a reference to which chapter this defined in which datasheet.
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 146: PROJECT_CODE, 0xb16); align with the ( above.
e.g. SET32_BITFIELDS(... PROJECT_CODE, ...);
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 163: PMIC_CG_MD align with the ( above
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 166: 0 align with the ( above
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 174: PMIC_WRAP_SWRST align with the ( above
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 176: PMIC_WRAP_SWRST align with the ( above
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 180: PMIC_CG_MD align with the ( above
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 321: 100 add a reference for where we can find this 100 being defined.
Yidi Lin has uploaded a new patch set (#18) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface(PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
TEST=Boots correctly on MT8192EVB.
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,432 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/18
hsin-hsiung wang has uploaded a new patch set (#20) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface(PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,451 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/20
hsin-hsiung wang has uploaded a new patch set (#21) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface(PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,451 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/21
hsin-hsiung wang has uploaded a new patch set (#22) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface(PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,451 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/22
hsin-hsiung wang has uploaded a new patch set (#23) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface(PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,452 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/23
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 23:
(16 comments)
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif.h:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 134: unsigned int
Why not `uintptr_t`?
the address and value of pmic mt6359p is 32 bit, so I think u32 should be enough.
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/inc... PS1, Line 89: {
enum {
Done
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 115: ((read32(&arb->mtk_pmif->init_done) & 0x1))
Please address this.
Done
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 157: int ret = 1; : : ret = pmif_clk_init(); : if (ret) : goto FAIL; : : ret = pmif_spmi_init(&pmif_spmi_arb[SPMI_MASTER_0]); : if (ret) : goto FAIL; : : ret = pmif_spi_init(&pmif_spi_arb[0]); : if (ret) : goto FAIL; : : return 0; : : FAIL: : /* assert(0); */ : return ret;
Please address this.
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 22: &arb->mtk_pmif->swinf_0_sta + 0x10 * arb->swinf_no
slightly concerned about this. […]
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 34: unsigned int reg_rdata; : struct stopwatch sw; : : stopwatch_init_usecs_expire(&sw, timeout_us); : do { : reg_rdata = read32(&arb->mtk_pmif->swinf_0_sta + 0x10 * arb->swinf_no); : if (stopwatch_expired(&sw)) { : printk(BIOS_ERR, "[%s] timeout\n", __func__); : return E_TIMEOUT; : } : } while (GET_SWINF_0_FSM(reg_rdata) != SWINF_FSM_WFVLDCLR);
this looks pretty redundant with pmif_check_idle. Can we merge them as a single function […]
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 119: ((read32(&arb->mtk_pmif->init_done) & 0x1))
remove one level of quotes. […]
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 167: (struct pmif *)&pmif_spmi_arb[SPMI_MASTER_0]
get_pmif_controller(PMIF_SPMI, SPMI_MASTER_0);
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 171: (struct pmif *)&pmif_spi_arb[0]
get_pmif_controller(PMIF_SPI);
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 52: }, {
Should { be on the next line?
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 102: u32 i = 0;
The native type should be enough for a counting variable.
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 131: printk(BIOS_ERR, "%s: Null argument", __func__);
Error messages should be more elaborate and helpful.
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 162: u32 swinf_no)
Fits into one line.
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 210: */
Please use one of the recommended coding styles [1]. […]
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 224: 0x2F7
Add enums or macros?
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 251: return -E_NODEV;
Add a debug message?
Done
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 23:
(9 comments)
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 55: PMIC_BASE = 0x0000, : PMIC_SMT_CON1 = PMIC_BASE + 0x0032, : PMIC_DRV_CON1 = PMIC_BASE + 0x003a, : PMIC_FILTER_CON0 = PMIC_BASE + 0x0042, : PMIC_GPIO_PULLEN0_CLR = PMIC_BASE + 0x0098, : PMIC_RG_SPI_CON0 = PMIC_BASE + 0x0408, : PMIC_DEW_DIO_EN = PMIC_BASE + 0x040c, : PMIC_DEW_READ_TEST = PMIC_BASE + 0x040e, : PMIC_DEW_WRITE_TEST = PMIC_BASE + 0x0410, : PMIC_DEW_CRC_EN = PMIC_BASE + 0x0414, : PMIC_DEW_CRC_VAL = PMIC_BASE + 0x0416, : PMIC_DEW_RDDMY_NO = PMIC_BASE + 0x0424, : PMIC_RG_SPI_CON2 = PMIC_BASE + 0x0426, : PMIC_SPISLV_KEY = PMIC_BASE + 0x044a, : PMIC_INT_STA = PMIC_BASE + 0x0452, : PMIC_AUXADC_ADC7 = PMIC_BASE + 0x1096, : PMIC_AUXADC_ADC10 = PMIC_BASE + 0x109c, : PMIC_AUXADC_RQST0 = PMIC_BASE + 0x1108,
Please use either tabs or spaces for alignment.
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif_sw.h:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/in... PS14, Line 13: (0x00) : #define SWINF_FSM_REQ (0x02) : #define SWINF_FSM_WFDLE (0x04) : #define SWINF_FSM_WFVLDCLR (0x06) : #define SWINF_INIT_DONE (0x01)
no need to add () if this is a single number
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/in... PS14, Line 25: x
always quote x as (x) if you're going to apply operations on it.
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 146: PROJECT_CODE, 0xb16);
align with the ( above. […]
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 163: PMIC_CG_MD
align with the ( above
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 166: 0
align with the ( above
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 174: PMIC_WRAP_SWRST
align with the ( above
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 176: PMIC_WRAP_SWRST
align with the ( above
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 180: PMIC_CG_MD
align with the ( above
Done
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 23:
(5 comments)
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif.h:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 130: int swinf_no;
Can the number be signed?
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 131: int mstid;
Should an id be unsigned?
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 134: rdata
Why not just data?
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 134: unsigned int
Please use void type.
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 136: unsigned int addr, unsigned int wdata);
Ditto.
Done
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 23:
(10 comments)
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 234: /* Wait for completion of sending the commands */ : do { : rdata = read32(&arb->mtk_pmif->inf_busy_sta); : } while ((rdata & PMIF_SPI_AP) != 0x0); : : do { : rdata = read32(&arb->mtk_pmif->other_busy_sta_0); : } while (GET_CMDISSUE_BUSY(rdata) != 0x0); : : do { : rdata = read32(&mtk_pmicspi_mst->other_busy_sta_0); : } while (GET_PMICSPI_BUSY(rdata) != 0x0);
Could these be endless loops?
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 254: Setup
Set up
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 257: Setup
Set up
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 268: int ret = 0;
Use CB_SUCCESS and friends?
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 288: printk(BIOS_ERR, "[%s] data calibration fail,ret=%d\n",
Please elaborate and add a space after the comma.
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 298: Checking
checking
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 298: 1. Signature Checking using CRC (CRC 0 only) : * 2. EINT update : * 3. Read back Auxadc thermal data for GPS
- Check signature using CRC (CRC 0 only) […]
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 300: Auxadc
AUXADC
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 302: initstaupd
`init_staupd()` for consistency with `init_sistrobe()`.
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 321: udelay(100);
How is that done by a delay?
After checking, we don't use md, so there is no need for this.
hsin-hsiung wang has uploaded a new patch set (#24) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,453 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/24
hsin-hsiung wang has uploaded a new patch set (#25) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,453 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/25
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 25:
(6 comments)
https://review.coreboot.org/c/coreboot/+/45398/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/45398/7//COMMIT_MSG@9 PS7, Line 9: power management interface(PMIF)
Please add a space before the (.
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 46: int slvid;
Can an ID be signed?
Done
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/1/src/soc/mediatek/mt8192/pmi... PS1, Line 13: #define FREQ_260MHZ 260 : /* calibation miss rate, unit: 0.1% */ : #define CAL_MIS_RATE 40 : /* : * FREQ METER ID : * Ask clkmgr owner to find this information : * at clock table[fmeter]. : */ : #define FREQ_METER_ABIST_AD_OSC_CK 37 : #define CAL_MAX_VAL 0x7f
use enum
move to header file and use enum.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 217: __func__, rdata, DEFAULT_VALUE_READ_TEST);
Please use more elaborate error messages.
Done
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 287: if (ret != 0) {
Use CB_SUCCESS and friends.
Would you please give me a hint about CB_SUCCESS and friends? There seems to be no proper definition.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 200: write32(&arb->mtk_pmif->inf_cmd_per_1, cmd_per);
Why does a different value have to be programmed here?
inf_cmd_per_1 is for the permission of interface 8~15 and inf_cmd_per_0 is for the permission of interface 0~7.
Yidi Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 25:
(1 comment)
https://review.coreboot.org/c/coreboot/+/45398/25/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/25/src/soc/mediatek/mt8192/pm... PS25, Line 103: u32 int
hsin-hsiung wang has uploaded a new patch set (#26) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,453 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/26
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 26:
(1 comment)
https://review.coreboot.org/c/coreboot/+/45398/25/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/25/src/soc/mediatek/mt8192/pm... PS25, Line 103: u32
int
Done
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 26:
(5 comments)
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/Ma... File src/soc/mediatek/mt8192/Makefile.inc:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/Ma... PS14, Line 12: bootblock
Do we really need to enable PMIF in bootblock? Can we do that in romstage?
I think there are several modules, like rtc/clkbuf/srclken_rc, which depend on pmif module. It is OK for me to move pmif module in romstage if these modules can move, too.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/pmif.h:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/inc... PS7, Line 134: unsigned int
the address and value of pmic mt6359p is 32 bit, so I think u32 should be enough.
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 91: 50
Please explain why 50 is needed, or add a reference to which chapter this defined in which datasheet […]
We need the delay for stable clk, and it is described in ULPOSC_SW_Calibration.doc.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 171: };
In that pattern documented somewhere?
No. This part is to do the calibration to find out the correct timing of spi. The test pattern is to verify the bit 0~15 of the read-back data. 0x6996 = 2'b[0110100110010110] 0x9669 = 2'b[1001011001101001]
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 321: 100
add a reference for where we can find this 100 being defined.
After checking, the project don't use modem feature, so we remove it.
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 26:
(3 comments)
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 171: };
No. This part is to do the calibration to find out the correct timing of spi. […]
1. So they are all random numbers? 2. Why is the 0x1B27 pattern different?
https://review.coreboot.org/c/coreboot/+/45398/26/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/26/src/soc/mediatek/mt8192/pm... PS26, Line 176: int u32?
https://review.coreboot.org/c/coreboot/+/45398/26/src/soc/mediatek/mt8192/pm... PS26, Line 206: 30 ARRAY_SIZE(test_data)
hsin-hsiung wang has uploaded a new patch set (#27) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,453 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/27
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 27:
(2 comments)
https://review.coreboot.org/c/coreboot/+/45398/26/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/26/src/soc/mediatek/mt8192/pm... PS26, Line 176: int
u32?
Done
https://review.coreboot.org/c/coreboot/+/45398/26/src/soc/mediatek/mt8192/pm... PS26, Line 206: 30
ARRAY_SIZE(test_data)
Done
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 27:
There are still 5 comments unresolved - please fix them.
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 27:
(2 comments)
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_clk.c:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 91: 50
We need the delay for stable clk, and it is described in ULPOSC_SW_Calibration.doc.
Done
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/pm... PS14, Line 321: 100
After checking, the project don't use modem feature, so we remove it.
Done
Yidi Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 27:
(3 comments)
https://review.coreboot.org/c/coreboot/+/45398/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/45398/7//COMMIT_MSG@11 PS7, Line 11:
Where is the interface documented? Please add a datasheet name and revision.
Ack
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/Ma... File src/soc/mediatek/mt8192/Makefile.inc:
https://review.coreboot.org/c/coreboot/+/45398/14/src/soc/mediatek/mt8192/Ma... PS14, Line 12: bootblock
I think there are several modules, like rtc/clkbuf/srclken_rc, which depend on pmif module. […]
Ack. rtc_init is done in bootblock.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 200: write32(&arb->mtk_pmif->inf_cmd_per_1, cmd_per);
inf_cmd_per_1 is for the permission of interface 8~15 and inf_cmd_per_0 is for the permission of int […]
Ack
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 27:
(1 comment)
still two comments (one to add timeout duration, one to answer yupingso's questions).
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 287: if (ret != 0) {
Would you please give me a hint about CB_SUCCESS and friends? […]
Ack
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 28:
(2 comments)
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 99:
Print out as a debug message, how long it took?
According to the log, it spends 1 us. log: [reset_spislv] 1 get_us_since_boot 0x1 us [reset_spislv] 2 get_us_since_boot 0x2 us code: printk(BIOS_ERR, "[%s] 1 get_us_since_boot %#x us\n", __func__, get_us_since_boot()); /* Wait for PMIC SPI Master to be idle */ if (check_idle(&mtk_pmicspi_mst->other_busy_sta_0, SPIMST_STA)) { printk(BIOS_ERR, "[%s] spi master busy, timeout\n", __func__); return E_TIMEOUT; } printk(BIOS_ERR, "[%s] 2 get_us_since_boot %#x us\n", __func__, get_us_since_boot());
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 171: };
- So they are all random numbers? […]
After confirming with DE, they are random numbers in order to verify the read-back data.
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 28:
(29 comments)
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif.h:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 165: Use tabs and align all of these comments.
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 45: #define mtk_iocfg_tl ((struct mtk_iocfg_tl_regs *)IOCFG_TL_BASE) Why not use a global variable just like mtk_pmicspi_mst?
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 51: #define mtk_modem_temp_share ((struct mtk_modem_temp_share_regs *)SPM_BASE) Why not use a global variable just like mtk_pmicspi_mst?
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 75: ( No need for parentheses here.
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 107: ( No need for parentheses.
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 124: X Use lowercase "x"?
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif_spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 96: ( No need for parentheses.
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 15: unsigned int Use "long" to be consistent with the signature of stopwatch_init_usecs_expire().
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 15: unsigned int int
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 16: unsigned int u32
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 18: unsigned int u32
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 31: unsigned int If it's boolean, use "int". Otherwise, consider u32, u16 or u8. Same for other similar arguments.
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 46: { No need for these.
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 46: if (write == 1) if (write)
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 55: if (write == 0) if (!write)
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 74: *data = 0; Is this for timeout case in pmif_send_cmd()?
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 89: ( No need for these. Better to write
data >>= shift;
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 122: ( No need for these. Better to write
data >>= shift;
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 175: if (inf == PMIF_SPMI) Check "mstid < ARRAY_SIZE(pmif_spmi_arb)".
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 191: Remove this blank line.
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/7/src/soc/mediatek/mt8192/pmi... PS7, Line 171: };
After confirming with DE, they are random numbers in order to verify the read-back data.
Ack
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 59: u32 int
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 59: u32 void
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 74: s32 Can we use int?
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 172: s32 Can we use int?
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 176: const u32 test_data[30] = { Add a comment
/* Random data for testing */
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 206: size_t int
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 104: b What does this "b" mean?
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 108: } },
hsin-hsiung wang has uploaded a new patch set (#29) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,441 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/29
hsin-hsiung wang has uploaded a new patch set (#30) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,441 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/30
hsin-hsiung wang has uploaded a new patch set (#31) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,441 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/31
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 31:
(27 comments)
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif.h:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 165:
Use tabs and align all of these comments.
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 45: #define mtk_iocfg_tl ((struct mtk_iocfg_tl_regs *)IOCFG_TL_BASE)
Why not use a global variable just like mtk_pmicspi_mst?
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 51: #define mtk_modem_temp_share ((struct mtk_modem_temp_share_regs *)SPM_BASE)
Why not use a global variable just like mtk_pmicspi_mst?
remove it because our chip won't use modem feature.
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 75: (
No need for parentheses here.
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 124: X
Use lowercase "x"?
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif_spmi.h:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 96: (
No need for parentheses.
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 15: unsigned int
int
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 15: unsigned int
Use "long" to be consistent with the signature of stopwatch_init_usecs_expire().
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 16: unsigned int
u32
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 18: unsigned int
u32
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 31: unsigned int
If it's boolean, use "int". Otherwise, consider u32, u16 or u8. Same for other similar arguments.
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 46: if (write == 1)
if (write)
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 46: {
No need for these.
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 55: if (write == 0)
if (!write)
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 74: *data = 0;
Is this for timeout case in pmif_send_cmd()?
yes, it is.
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 89: (
No need for these. Better to write […]
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 122: (
No need for these. Better to write […]
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 175: if (inf == PMIF_SPMI)
Check "mstid < ARRAY_SIZE(pmif_spmi_arb)".
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 191:
Remove this blank line.
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spi.c:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 59: u32
void
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 59: u32
int
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 74: s32
Can we use int?
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 172: s32
Can we use int?
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 176: const u32 test_data[30] = {
Add a comment […]
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 206: size_t
int
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif_spmi.c:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 104: b
What does this "b" mean?
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 108: }
},
Done
Yidi Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 31:
(2 comments)
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/in... PS28, Line 107: (
No need for parentheses.
Done
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/28/src/soc/mediatek/mt8192/pm... PS28, Line 74: *data = 0;
yes, it is.
Ack
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 31:
(1 comment)
https://review.coreboot.org/c/coreboot/+/45398/31/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/31/src/soc/mediatek/mt8192/pm... PS31, Line 173: if (inf == PMIF_SPMI && mstid < ARRAY_SIZE(pmif_spmi_arb)) { braces {} are not necessary for any arm of this statement
hsin-hsiung wang has uploaded a new patch set (#32) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,441 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/32
hsin-hsiung wang has uploaded a new patch set (#34) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,442 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/34
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 34: Code-Review+1
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 34: Code-Review+2
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 34:
(8 comments)
Final few nits
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif.h:
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/in... PS34, Line 166: r R
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/in... PS34, Line 68: Use tabs to align.
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 15: int long
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 15: long int
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 33: data Use u32.
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 33: ret Use "int" type.
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 44: { Remove these.
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 178: controller controller: inf = %d, mstid = %d
hsin-hsiung wang has uploaded a new patch set (#35) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,440 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/35
hsin-hsiung wang has uploaded a new patch set (#36) to the change originally created by CK HU. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,440 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/45398/36
hsin-hsiung wang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 36: Code-Review+1
(8 comments)
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif.h:
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/in... PS34, Line 166: r
R
Done
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/pmif_spi.h:
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/in... PS34, Line 68:
Use tabs to align.
Done
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 15: int
long
Done
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 15: long
int
Done
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 33: ret
Use "int" type.
Done
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 33: data
Use u32.
Done
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 44: {
Remove these.
Done
https://review.coreboot.org/c/coreboot/+/45398/34/src/soc/mediatek/mt8192/pm... PS34, Line 178: controller
controller: inf = %d, mstid = %d
Done
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 36: Code-Review+2
Hung-Te Lin has submitted this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
soc/mediatek/mt8192: add pmif driver
MT8192 uses power management interface (PMIF) to access pmics by spmi and spi, so we add pmif driver to control pmics.
BUG=b:155253454 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I32fc28f72d9522133baa06f9d67c383f814d862c Reviewed-on: https://review.coreboot.org/c/coreboot/+/45398 Reviewed-by: Hung-Te Lin hungte@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/bootblock.c M src/soc/mediatek/mt8192/include/soc/addressmap.h M src/soc/mediatek/mt8192/include/soc/pll.h A src/soc/mediatek/mt8192/include/soc/pmif.h A src/soc/mediatek/mt8192/include/soc/pmif_spi.h A src/soc/mediatek/mt8192/include/soc/pmif_spmi.h A src/soc/mediatek/mt8192/include/soc/pmif_sw.h A src/soc/mediatek/mt8192/include/soc/spmi.h A src/soc/mediatek/mt8192/pmif.c A src/soc/mediatek/mt8192/pmif_clk.c A src/soc/mediatek/mt8192/pmif_spi.c A src/soc/mediatek/mt8192/pmif_spmi.c 13 files changed, 1,440 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Hung-Te Lin: Looks good to me, approved hsin-hsiung wang: Looks good to me, but someone else must approve
diff --git a/src/soc/mediatek/mt8192/Makefile.inc b/src/soc/mediatek/mt8192/Makefile.inc index 13b5b21..9c21b4da 100644 --- a/src/soc/mediatek/mt8192/Makefile.inc +++ b/src/soc/mediatek/mt8192/Makefile.inc @@ -9,6 +9,7 @@ bootblock-y += ../common/timer.c bootblock-y += ../common/uart.c bootblock-y += ../common/wdt.c +bootblock-y += pmif.c pmif_clk.c pmif_spi.c pmif_spmi.c
verstage-y += flash_controller.c verstage-y += ../common/gpio.c gpio.c diff --git a/src/soc/mediatek/mt8192/bootblock.c b/src/soc/mediatek/mt8192/bootblock.c index 8dffe56..0852f0e 100644 --- a/src/soc/mediatek/mt8192/bootblock.c +++ b/src/soc/mediatek/mt8192/bootblock.c @@ -3,6 +3,7 @@ #include <bootblock_common.h> #include <soc/mmu_operations.h> #include <soc/pll.h> +#include <soc/pmif.h> #include <soc/wdt.h>
void bootblock_soc_init(void) @@ -10,4 +11,5 @@ mtk_mmu_init(); mtk_wdt_init(); mt_pll_init(); + mtk_pmif_init(); } diff --git a/src/soc/mediatek/mt8192/include/soc/addressmap.h b/src/soc/mediatek/mt8192/include/soc/addressmap.h index e0cd536..69d3157 100644 --- a/src/soc/mediatek/mt8192/include/soc/addressmap.h +++ b/src/soc/mediatek/mt8192/include/soc/addressmap.h @@ -21,7 +21,10 @@ GPT_BASE = IO_PHYS + 0x00008000, EINT_BASE = IO_PHYS + 0x0000B000, APMIXED_BASE = IO_PHYS + 0x0000C000, - PWRAP_BASE = IO_PHYS + 0x0000D000, + PMIF_SPI_BASE = IO_PHYS + 0x00026000, + PMIF_SPMI_BASE = IO_PHYS + 0x00027000, + PMICSPI_MST_BASE = IO_PHYS + 0x00028000, + SPMI_MST_BASE = IO_PHYS + 0x00029000, UART0_BASE = IO_PHYS + 0x01002000, SPI0_BASE = IO_PHYS + 0x0100A000, SPI1_BASE = IO_PHYS + 0x01010000, diff --git a/src/soc/mediatek/mt8192/include/soc/pll.h b/src/soc/mediatek/mt8192/include/soc/pll.h index d5a9cf9..09c4c471 100644 --- a/src/soc/mediatek/mt8192/include/soc/pll.h +++ b/src/soc/mediatek/mt8192/include/soc/pll.h @@ -178,7 +178,11 @@ u32 mfgpll_con2; u32 mfgpll_con3; u32 ap_pllgp1_con2; - u32 reserved2[33]; + u32 reserved2[13]; + u32 ulposc1_con0; + u32 ulposc1_con1; + u32 ulposc1_con2; + u32 reserved3[17]; u32 ap_pllgp2_con0; /* 0x0300 */ u32 ap_pllgp2_con1; u32 univpll_con0; diff --git a/src/soc/mediatek/mt8192/include/soc/pmif.h b/src/soc/mediatek/mt8192/include/soc/pmif.h new file mode 100644 index 0000000..fe3def0 --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/pmif.h @@ -0,0 +1,172 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __MT8192_SOC_PMIF_H__ +#define __MT8192_SOC_PMIF_H__ + +#include <types.h> + +enum { + PMIF_CMD_REG_0, + PMIF_CMD_REG, + PMIF_CMD_EXT_REG, + PMIF_CMD_EXT_REG_LONG, +}; + +struct mtk_pmif_regs { + u32 init_done; + u32 reserved1[5]; + u32 inf_busy_sta; + u32 other_busy_sta_0; + u32 other_busy_sta_1; + u32 inf_en; + u32 other_inf_en; + u32 inf_cmd_per_0; + u32 inf_cmd_per_1; + u32 inf_cmd_per_2; + u32 inf_cmd_per_3; + u32 inf_max_bytecnt_per_0; + u32 inf_max_bytecnt_per_1; + u32 inf_max_bytecnt_per_2; + u32 inf_max_bytecnt_per_3; + u32 staupd_ctrl; + u32 reserved2[48]; + u32 int_gps_auxadc_cmd_addr; + u32 int_gps_auxadc_cmd; + u32 int_gps_auxadc_rdata_addr; + u32 reserved3[13]; + u32 arb_en; + u32 reserved4[34]; + u32 lat_cnter_en; + u32 lat_limit_loading; + u32 lat_limit_0; + u32 lat_limit_1; + u32 lat_limit_2; + u32 lat_limit_3; + u32 lat_limit_4; + u32 lat_limit_5; + u32 lat_limit_6; + u32 lat_limit_7; + u32 lat_limit_8; + u32 lat_limit_9; + u32 reserved5[99]; + u32 crc_ctrl; + u32 crc_sta; + u32 sig_mode; + u32 pmic_sig_addr; + u32 pmic_sig_val; + u32 reserved6[2]; + u32 cmdissue_en; + u32 reserved7[10]; + u32 timer_ctrl; + u32 timer_sta; + u32 sleep_protection_ctrl; + u32 reserved8[5]; + u32 spi_mode_ctrl; + u32 reserved9[2]; + u32 pmic_eint_sta_addr; + u32 reserved10[2]; + u32 irq_event_en_0; + u32 irq_flag_raw_0; + u32 irq_flag_0; + u32 irq_clr_0; + u32 reserved11[502]; + u32 swinf_0_acc; + u32 swinf_0_wdata_31_0; + u32 swinf_0_wdata_63_32; + u32 reserved12[2]; + u32 swinf_0_rdata_31_0; + u32 swinf_0_rdata_63_32; + u32 reserved13[2]; + u32 swinf_0_vld_clr; + u32 swinf_0_sta; + u32 reserved14[5]; + u32 swinf_1_acc; + u32 swinf_1_wdata_31_0; + u32 swinf_1_wdata_63_32; + u32 reserved15[2]; + u32 swinf_1_rdata_31_0; + u32 swinf_1_rdata_63_32; + u32 reserved16[2]; + u32 swinf_1_vld_clr; + u32 swinf_1_sta; + u32 reserved17[5]; + u32 swinf_2_acc; + u32 swinf_2_wdata_31_0; + u32 swinf_2_wdata_63_32; + u32 reserved18[2]; + u32 swinf_2_rdata_31_0; + u32 swinf_2_rdata_63_32; + u32 reserved19[2]; + u32 swinf_2_vld_clr; + u32 swinf_2_sta; + u32 reserved20[5]; + u32 swinf_3_acc; + u32 swinf_3_wdata_31_0; + u32 swinf_3_wdata_63_32; + u32 reserved21[2]; + u32 swinf_3_rdata_31_0; + u32 swinf_3_rdata_63_32; + u32 reserved22[2]; + u32 swinf_3_vld_clr; + u32 swinf_3_sta; + u32 reserved23[133]; +}; + +check_member(mtk_pmif_regs, inf_busy_sta, 0x18); +check_member(mtk_pmif_regs, int_gps_auxadc_cmd_addr, 0x110); +check_member(mtk_pmif_regs, arb_en, 0x0150); +check_member(mtk_pmif_regs, lat_cnter_en, 0x1DC); +check_member(mtk_pmif_regs, crc_ctrl, 0x398); +check_member(mtk_pmif_regs, cmdissue_en, 0x3B4); +check_member(mtk_pmif_regs, timer_ctrl, 0x3E0); +check_member(mtk_pmif_regs, spi_mode_ctrl, 0x400); +check_member(mtk_pmif_regs, pmic_eint_sta_addr, 0x40C); +check_member(mtk_pmif_regs, irq_event_en_0, 0x418); +check_member(mtk_pmif_regs, swinf_0_acc, 0xC00); + +#define PMIF_SPMI_AP_CHAN (PMIF_SPMI_BASE + 0xC80) +#define PMIF_SPI_AP_CHAN (PMIF_SPI_BASE + 0xC80) + +struct chan_regs { + u32 ch_send; + u32 wdata; + u32 reserved12[3]; + u32 rdata; + u32 reserved13[3]; + u32 ch_rdy; + u32 ch_sta; +}; + +struct pmif { + struct mtk_pmif_regs *mtk_pmif; + struct chan_regs *ch; + u32 swinf_no; + u32 mstid; + u32 pmifid; + void (*read)(struct pmif *arb, u32 slvid, u32 reg, u32 *data); + void (*write)(struct pmif *arb, u32 slvid, u32 reg, u32 data); + u32 (*read_field)(struct pmif *arb, u32 slvid, u32 reg, u32 mask, u32 shift); + void (*write_field)(struct pmif *arb, u32 slvid, u32 reg, u32 val, u32 mask, u32 shift); + int (*is_pmif_init_done)(struct pmif *arb); +}; + +enum { + PMIF_SPI, + PMIF_SPMI, +}; + +enum { + E_IO = 1, /* I/O error */ + E_BUSY, /* Device or resource busy */ + E_NODEV, /* No such device */ + E_INVAL, /* Invalid argument */ + E_OPNOTSUPP, /* Operation not supported on transport endpoint */ + E_TIMEOUT, /* Wait for idle time out */ + E_READ_TEST_FAIL, /* SPI read fail */ + E_SPI_INIT_RESET_SPI, /* Reset SPI fail */ + E_SPI_INIT_SIDLY, /* SPI edge calibration fail */ +}; + +extern struct pmif *get_pmif_controller(int inf, int mstid); +extern int mtk_pmif_init(void); +#endif /*__MT8192_SOC_PMIF_H__*/ diff --git a/src/soc/mediatek/mt8192/include/soc/pmif_spi.h b/src/soc/mediatek/mt8192/include/soc/pmif_spi.h new file mode 100644 index 0000000..426aa3b --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/pmif_spi.h @@ -0,0 +1,125 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __SOC_MEDIATEK_MT8192_PMIC_WRAP_H__ +#define __SOC_MEDIATEK_MT8192_PMIC_WRAP_H__ + +#include <soc/addressmap.h> +#include <types.h> + +struct mt8192_pmicspi_mst_regs { + u32 reserved1[4]; + u32 other_busy_sta_0; + u32 wrap_en; + u32 reserved2[2]; + u32 man_en; + u32 man_acc; + u32 reserved3[3]; + u32 mux_sel; + u32 reserved4[3]; + u32 dio_en; + u32 rddmy; + u32 cslext_write; + u32 cslext_read; + u32 cshext_write; + u32 cshext_read; + u32 ext_ck_write; + u32 ext_ck_read; + u32 si_sampling_ctrl; +}; + +check_member(mt8192_pmicspi_mst_regs, other_busy_sta_0, 0x10); +check_member(mt8192_pmicspi_mst_regs, man_en, 0x20); +check_member(mt8192_pmicspi_mst_regs, mux_sel, 0x34); +check_member(mt8192_pmicspi_mst_regs, dio_en, 0x44); + +static struct mt8192_pmicspi_mst_regs * const mtk_pmicspi_mst = (void *)PMICSPI_MST_BASE; + +struct mt8192_iocfg_lm_regs { + u32 reserved[4]; + u32 drv_cfg1; +}; +check_member(mt8192_iocfg_lm_regs, drv_cfg1, 0x10); + +static struct mt8192_iocfg_lm_regs * const mtk_iocfg_lm = (void *)IOCFG_LM_BASE; + +/* PMIC registers */ +enum { + PMIC_BASE = 0x0000, + PMIC_SMT_CON1 = PMIC_BASE + 0x0032, + PMIC_DRV_CON1 = PMIC_BASE + 0x003a, + PMIC_FILTER_CON0 = PMIC_BASE + 0x0042, + PMIC_GPIO_PULLEN0_CLR = PMIC_BASE + 0x0098, + PMIC_RG_SPI_CON0 = PMIC_BASE + 0x0408, + PMIC_DEW_DIO_EN = PMIC_BASE + 0x040c, + PMIC_DEW_READ_TEST = PMIC_BASE + 0x040e, + PMIC_DEW_WRITE_TEST = PMIC_BASE + 0x0410, + PMIC_DEW_CRC_EN = PMIC_BASE + 0x0414, + PMIC_DEW_CRC_VAL = PMIC_BASE + 0x0416, + PMIC_DEW_RDDMY_NO = PMIC_BASE + 0x0424, + PMIC_RG_SPI_CON2 = PMIC_BASE + 0x0426, + PMIC_SPISLV_KEY = PMIC_BASE + 0x044a, + PMIC_INT_STA = PMIC_BASE + 0x0452, + PMIC_AUXADC_ADC7 = PMIC_BASE + 0x1096, + PMIC_AUXADC_ADC10 = PMIC_BASE + 0x109c, + PMIC_AUXADC_RQST0 = PMIC_BASE + 0x1108, +}; + +#define PMIF_SPI_HW_INF 0x307F +#define PMIF_SPI_MD BIT(8) +#define PMIF_SPI_AP_SECURE BIT(9) +#define PMIF_SPI_AP BIT(10) +#define PMIF_SPI_STAUPD BIT(14) +#define PMIF_SPI_TSX_HW BIT(19) +#define PMIF_SPI_DCXO_HW BIT(20) + +#define DEFAULT_SLVID 0 + +#define PMIF_CMD_STA BIT(2) +#define SPIMST_STA BIT(9) + +enum { + SPI_CLK = 0x1, + SPI_CSN = 0x1 << 1, + SPI_MOSI = 0x1 << 2, + SPI_MISO = 0x1 << 3, + SPI_FILTER = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, + SPI_SMT = SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO, + SPI_PULL_DISABLE = (SPI_CLK | SPI_CSN | SPI_MOSI | SPI_MISO) << 4, +}; + +enum { + IO_4_MA = 0x1, + SLV_IO_4_MA = 0x8, +}; + +enum { + SPI_CLK_SHIFT = 0, + SPI_CSN_SHIFT = 4, + SPI_MOSI_SHIFT = 8, + SPI_MISO_SHIFT = 12, + SPI_DRIVING = SLV_IO_4_MA << SPI_CLK_SHIFT | SLV_IO_4_MA << SPI_CSN_SHIFT | + SLV_IO_4_MA << SPI_MOSI_SHIFT | SLV_IO_4_MA << SPI_MISO_SHIFT, +}; + +enum { + OP_WR = 0x1, + OP_CSH = 0x0, + OP_CSL = 0x1, + OP_OUTS = 0x8, +}; + +enum { + DEFAULT_VALUE_READ_TEST = 0x5aa5, + WRITE_TEST_VALUE = 0xa55a, +}; + +enum { + DUMMY_READ_CYCLES = 0x8, +}; + +enum { + E_CLK_EDGE = 1, + E_CLK_LAST_SETTING, +}; +extern int pmif_spi_init(struct pmif *arb); +#endif /* __SOC_MEDIATEK_MT8192_PMIC_WRAP_H__ */ diff --git a/src/soc/mediatek/mt8192/include/soc/pmif_spmi.h b/src/soc/mediatek/mt8192/include/soc/pmif_spmi.h new file mode 100644 index 0000000..d89a072 --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/pmif_spmi.h @@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __PMIF_SPMI_H__ +#define __PMIF_SPMI_H__ + +#include <soc/addressmap.h> + +#define DEFAULT_VALUE_READ_TEST (0x5a) +#define DEFAULT_VALUE_WRITE_TEST (0xa5) + +/* indicate which number SW channel start, by project */ +#define PMIF_SPMI_SW_CHAN BIT(6) +#define PMIF_SPMI_INF 0x2F7 + +struct mtk_rgu_regs { + u32 reserved[36]; + u32 wdt_swsysrst2; +}; +check_member(mtk_rgu_regs, wdt_swsysrst2, 0x90); + +struct mtk_iocfg_bm_regs { + u32 reserved[8]; + u32 drv_cfg2; +}; +check_member(mtk_iocfg_bm_regs, drv_cfg2, 0x20); + +struct mtk_spm_regs { + u32 poweron_config_en; + u32 reserved[263]; + u32 ulposc_con; +}; +check_member(mtk_spm_regs, ulposc_con, 0x420); + +struct mtk_spmi_mst_reg { + u32 op_st_ctrl; + u32 grp_id_en; + u32 op_st_sta; + u32 mst_sampl; + u32 mst_req_en; + u32 reserved1[11]; + u32 rec_ctrl; + u32 rec0; + u32 rec1; + u32 rec2; + u32 rec3; + u32 rec4; + u32 reserved2[41]; + u32 mst_dbg; +}; + +check_member(mtk_spmi_mst_reg, rec_ctrl, 0x40); +check_member(mtk_spmi_mst_reg, mst_dbg, 0xfc); + +#define mtk_rug ((struct mtk_rgu_regs *)RGU_BASE) +#define mtk_iocfg_bm ((struct mtk_iocfg_bm_regs *)IOCFG_BM_BASE) +#define mtk_spm ((struct mtk_spm_regs *)SPM_BASE) +#define mtk_spmi_mst ((struct mtk_spmi_mst_reg *)SPMI_MST_BASE) + +struct cali { + unsigned int dly; + unsigned int pol; +}; + +enum { + SPMI_CK_NO_DLY = 0, + SPMI_CK_DLY_1T, +}; + +enum { + SPMI_CK_POL_NEG = 0, + SPMI_CK_POL_POS, +}; + +enum spmi_regs { + SPMI_OP_ST_CTRL, + SPMI_GRP_ID_EN, + SPMI_OP_ST_STA, + SPMI_MST_SAMPL, + SPMI_MST_REQ_EN, + SPMI_REC_CTRL, + SPMI_REC0, + SPMI_REC1, + SPMI_REC2, + SPMI_REC3, + SPMI_REC4, + SPMI_MST_DBG +}; + +/* MT6315 registers */ +enum { + MT6315_BASE = 0x0, + MT6315_READ_TEST = MT6315_BASE + 0x9, + MT6315_READ_TEST_1 = MT6315_BASE + 0xb, +}; + +#define MT6315_DEFAULT_VALUE_READ 0x15 + +extern int pmif_spmi_init(struct pmif *arb); +#endif /*__PMIF_SPMI_H__*/ diff --git a/src/soc/mediatek/mt8192/include/soc/pmif_sw.h b/src/soc/mediatek/mt8192/include/soc/pmif_sw.h new file mode 100644 index 0000000..fb4cbc9 --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/pmif_sw.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __PMIF_SW_H__ +#define __PMIF_SW_H__ + +/* Read/write byte limitation, by project */ +/* hw bytecnt indicate when we set 0, it can send 1 byte; + * set 1, it can send 2 byte. + */ +#define PMIF_BYTECNT_MAX 1 + +/* macro for SWINF_FSM */ +#define SWINF_FSM_IDLE 0x00 +#define SWINF_FSM_REQ 0x02 +#define SWINF_FSM_WFDLE 0x04 +#define SWINF_FSM_WFVLDCLR 0x06 +#define SWINF_INIT_DONE 0x01 + +#define FREQ_METER_ABIST_AD_OSC_CK 37 +#define GET_SWINF_0_FSM(x) (((x) >> 1) & 0x7) + +struct pmif_mpu { + unsigned int rgn_slvid; + unsigned short rgn_s_addr; + unsigned short rgn_e_addr; + unsigned int rgn_domain_per; +}; + +enum { + PMIF_READ_US = 1000, + PMIF_WAIT_IDLE_US = 1000, +}; + +enum { + FREQ_260MHZ = 260, +}; + +/* calibation tolerance rate, unit: 0.1% */ +enum { + CAL_TOL_RATE = 40, + CAL_MAX_VAL = 0x7F, +}; + +extern int pmif_clk_init(void); +#endif /*__PMIF_SW_H__*/ diff --git a/src/soc/mediatek/mt8192/include/soc/spmi.h b/src/soc/mediatek/mt8192/include/soc/spmi.h new file mode 100644 index 0000000..0d44198 --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/spmi.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __SPMI_H__ +#define __SPMI_H__ + +enum spmi_master { + SPMI_MASTER_0, + SPMI_MASTER_1, + SPMI_MASTER_2, + SPMI_MASTER_3, +}; + +enum spmi_slave { + SPMI_SLAVE_0, + SPMI_SLAVE_1, + SPMI_SLAVE_2, + SPMI_SLAVE_3, + SPMI_SLAVE_4, + SPMI_SLAVE_5, + SPMI_SLAVE_6, + SPMI_SLAVE_7, + SPMI_SLAVE_8, + SPMI_SLAVE_9, + SPMI_SLAVE_10, + SPMI_SLAVE_11, + SPMI_SLAVE_12, + SPMI_SLAVE_13, + SPMI_SLAVE_14, + SPMI_SLAVE_15, + SPMI_SLAVE_MAX, +}; + +enum slv_type { + BUCK_CPU, + BUCK_GPU, + SLV_TYPE_MAX, +}; + +enum slv_type_id { + BUCK_CPU_ID, + BUCK_GPU_ID, + SLV_TYPE_ID_MAX, +}; + +struct spmi_device { + u32 slvid; + enum slv_type type; + enum slv_type_id type_id; +}; +#endif /*__SPMI_H__*/ diff --git a/src/soc/mediatek/mt8192/pmif.c b/src/soc/mediatek/mt8192/pmif.c new file mode 100644 index 0000000..f6b1525 --- /dev/null +++ b/src/soc/mediatek/mt8192/pmif.c @@ -0,0 +1,191 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <assert.h> +#include <console/console.h> +#include <device/mmio.h> +#include <soc/addressmap.h> +#include <soc/pmif.h> +#include <soc/pmif_spi.h> +#include <soc/pmif_spmi.h> +#include <soc/pmif_sw.h> +#include <soc/spmi.h> +#include <string.h> +#include <timer.h> + +static int pmif_check_swinf(struct pmif *arb, long timeout_us, u32 expected_status) +{ + u32 reg_rdata; + struct stopwatch sw; + + stopwatch_init_usecs_expire(&sw, timeout_us); + do { + reg_rdata = read32(&arb->ch->ch_sta); + if (stopwatch_expired(&sw)) + return E_TIMEOUT; + } while (GET_SWINF_0_FSM(reg_rdata) != expected_status); + + return 0; +} + +static void pmif_send_cmd(struct pmif *arb, int write, u32 opc, u32 slvid, + u32 addr, u32 *rdata, u32 wdata, u32 len) +{ + int ret; + u32 data, bc = len - 1; + + /* Wait for Software Interface FSM state to be IDLE. */ + ret = pmif_check_swinf(arb, PMIF_WAIT_IDLE_US, SWINF_FSM_IDLE); + if (ret) { + printk(BIOS_ERR, "[%s] idle timeout\n", __func__); + return; + } + + /* Set the write data */ + if (write) + write32(&arb->ch->wdata, wdata); + + /* Send the command. */ + write32(&arb->ch->ch_send, + (opc << 30) | (write << 29) | (slvid << 24) | (bc << 16) | addr); + + if (!write) { + /* + * Wait for Software Interface FSM state to be WFVLDCLR, + * read the data and clear the valid flag. + */ + ret = pmif_check_swinf(arb, PMIF_READ_US, SWINF_FSM_WFVLDCLR); + if (ret) { + printk(BIOS_ERR, "[%s] read timeout\n", __func__); + return; + } + + data = read32(&arb->ch->rdata); + *rdata = data; + write32(&arb->ch->ch_rdy, 0x1); + } +} + +static void pmif_spmi_read(struct pmif *arb, u32 slvid, u32 reg, u32 *data) +{ + *data = 0; + pmif_send_cmd(arb, 0, PMIF_CMD_EXT_REG_LONG, slvid, reg, data, 0, 1); +} + +static void pmif_spmi_write(struct pmif *arb, u32 slvid, u32 reg, u32 data) +{ + pmif_send_cmd(arb, 1, PMIF_CMD_EXT_REG_LONG, slvid, reg, NULL, data, 1); +} + +static u32 pmif_spmi_read_field(struct pmif *arb, u32 slvid, u32 reg, u32 mask, u32 shift) +{ + u32 data; + + pmif_spmi_read(arb, slvid, reg, &data); + data &= (mask << shift); + data >>= shift; + + return data; +} + +static void pmif_spmi_write_field(struct pmif *arb, u32 slvid, u32 reg, + u32 val, u32 mask, u32 shift) +{ + u32 old, new; + + pmif_spmi_read(arb, slvid, reg, &old); + new = old & ~(mask << shift); + new |= (val << shift); + pmif_spmi_write(arb, slvid, reg, new); +} + +static void pmif_spi_read(struct pmif *arb, u32 slvid, u32 reg, u32 *data) +{ + *data = 0; + pmif_send_cmd(arb, 0, PMIF_CMD_REG_0, slvid, reg, data, 0, 1); +} + +static void pmif_spi_write(struct pmif *arb, u32 slvid, u32 reg, u32 data) +{ + pmif_send_cmd(arb, 1, PMIF_CMD_REG_0, slvid, reg, NULL, data, 1); +} + +static u32 pmif_spi_read_field(struct pmif *arb, u32 slvid, u32 reg, u32 mask, u32 shift) +{ + u32 data; + + pmif_spi_read(arb, slvid, reg, &data); + data &= (mask << shift); + data >>= shift; + + return data; +} + +static void pmif_spi_write_field(struct pmif *arb, u32 slvid, u32 reg, + u32 val, u32 mask, u32 shift) +{ + u32 old, new; + + pmif_spi_read(arb, slvid, reg, &old); + new = old & ~(mask << shift); + new |= (val << shift); + pmif_spi_write(arb, slvid, reg, new); +} + +static int is_pmif_init_done(struct pmif *arb) +{ + if (read32(&arb->mtk_pmif->init_done) & 0x1) + return 0; + + return -E_NODEV; +} + +static const struct pmif pmif_spmi_arb[] = { + { + .mtk_pmif = (struct mtk_pmif_regs *)PMIF_SPMI_BASE, + .ch = (struct chan_regs *)PMIF_SPMI_AP_CHAN, + .mstid = SPMI_MASTER_0, + .pmifid = PMIF_SPMI, + .write = pmif_spmi_write, + .read = pmif_spmi_read, + .write_field = pmif_spmi_write_field, + .read_field = pmif_spmi_read_field, + .is_pmif_init_done = is_pmif_init_done, + }, +}; + +static const struct pmif pmif_spi_arb[] = { + { + .mtk_pmif = (struct mtk_pmif_regs *)PMIF_SPI_BASE, + .ch = (struct chan_regs *)PMIF_SPI_AP_CHAN, + .pmifid = PMIF_SPI, + .write = pmif_spi_write, + .read = pmif_spi_read, + .write_field = pmif_spi_write_field, + .read_field = pmif_spi_read_field, + .is_pmif_init_done = is_pmif_init_done, + }, +}; + +struct pmif *get_pmif_controller(int inf, int mstid) +{ + if (inf == PMIF_SPMI && mstid < ARRAY_SIZE(pmif_spmi_arb)) + return (struct pmif *)&pmif_spmi_arb[mstid]; + else if (inf == PMIF_SPI) + return (struct pmif *)&pmif_spi_arb[0]; + + die("[%s] Failed to get pmif controller: inf = %d, mstid = %d\n", __func__, inf, mstid); + return NULL; +} + +int mtk_pmif_init(void) +{ + int ret; + + ret = pmif_clk_init(); + if (!ret) + ret = pmif_spmi_init(get_pmif_controller(PMIF_SPMI, SPMI_MASTER_0)); + if (!ret) + ret = pmif_spi_init(get_pmif_controller(PMIF_SPI, 0)); + + return ret; +} diff --git a/src/soc/mediatek/mt8192/pmif_clk.c b/src/soc/mediatek/mt8192/pmif_clk.c new file mode 100644 index 0000000..4e68f3e --- /dev/null +++ b/src/soc/mediatek/mt8192/pmif_clk.c @@ -0,0 +1,172 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <commonlib/helpers.h> +#include <console/console.h> +#include <delay.h> +#include <device/mmio.h> +#include <soc/infracfg.h> +#include <soc/pll.h> +#include <soc/pll_common.h> +#include <soc/pmif.h> +#include <soc/pmif_sw.h> +#include <soc/pmif_spmi.h> + +/* APMIXED, ULPOSC1_CON0 */ +DEFINE_BITFIELD(OSC1_CALI, 6, 0) +DEFINE_BITFIELD(OSC1_IBAND, 13, 7) +DEFINE_BITFIELD(OSC1_FBAND, 17, 14) +DEFINE_BITFIELD(OSC1_DIV, 23, 18) +DEFINE_BIT(OSC1_CP_EN, 24) + +/* APMIXED, ULPOSC1_CON1 */ +DEFINE_BITFIELD(OSC1_32KCALI, 7, 0) +DEFINE_BITFIELD(OSC1_RSV1, 15, 8) +DEFINE_BITFIELD(OSC1_RSV2, 23, 16) +DEFINE_BITFIELD(OSC1_MOD, 25, 24) +DEFINE_BIT(OSC1_DIV2_EN, 26) + +/* APMIXED, ULPOSC1_CON2 */ +DEFINE_BITFIELD(OSC1_BIAS, 7, 0) + +/* SPM, POWERON_CONFIG_EN */ +DEFINE_BIT(BCLK_CG_EN, 0) +DEFINE_BITFIELD(PROJECT_CODE, 31, 16) + +/* SPM, ULPOSC_CON */ +DEFINE_BIT(ULPOSC_EN, 0) +DEFINE_BIT(ULPOSC_CG_EN, 2) + +/* INFRA, MODULE_SW_CG */ +DEFINE_BIT(PMIC_CG_TMR, 0) +DEFINE_BIT(PMIC_CG_AP, 1) +DEFINE_BIT(PMIC_CG_MD, 2) +DEFINE_BIT(PMIC_CG_CONN, 3) + +/* INFRA, INFRA_GLOBALCON_RST2 */ +DEFINE_BIT(PMIC_WRAP_SWRST, 0) +DEFINE_BIT(PMICSPMI_SWRST, 14) + +/* INFRA, PMICW_CLOCK_CTRL */ +DEFINE_BITFIELD(PMIC_SYSCK_26M_SEL, 3, 0) + +/* TOPCKGEN, CLK_CFG_8 */ +DEFINE_BITFIELD(CLK_PWRAP_ULPOSC_SET, 10, 8) +DEFINE_BIT(CLK_PWRAP_ULPOSC_INV, 12) +DEFINE_BIT(PDN_PWRAP_ULPOSC, 15) + +/* TOPCKGEN, CLK_CFG_UPDATE1 */ +DEFINE_BIT(CLK_CFG_UPDATE1, 2) + +static void pmif_ulposc_config(void) +{ + /* ULPOSC1_CON0 */ + SET32_BITFIELDS(&mtk_apmixed->ulposc1_con0, OSC1_CP_EN, 0, OSC1_DIV, 0xe, + OSC1_FBAND, 0x2, OSC1_IBAND, 0x52, OSC1_CALI, 0x40); + + /* ULPOSC1_CON1 */ + SET32_BITFIELDS(&mtk_apmixed->ulposc1_con1, OSC1_DIV2_EN, 0, OSC1_MOD, 0, + OSC1_RSV2, 0, OSC1_RSV1, 0x29, OSC1_32KCALI, 0); + + /* ULPOSC1_CON2 */ + SET32_BITFIELDS(&mtk_apmixed->ulposc1_con2, OSC1_BIAS, 0x40); +} + +static u32 pmif_get_ulposc_freq_mhz(u32 cali_val) +{ + u32 result = 0; + + /* set calibration value */ + SET32_BITFIELDS(&mtk_apmixed->ulposc1_con0, OSC1_CALI, cali_val); + udelay(50); + result = mt_fmeter_get_freq_khz(FMETER_ABIST, FREQ_METER_ABIST_AD_OSC_CK); + + return result / 1000; +} + +static int pmif_ulposc_cali(void) +{ + u32 current_val = 0, min = 0, max = CAL_MAX_VAL, middle; + int ret = 0, diff_by_min, diff_by_max, cal_result; + + do { + middle = (min + max) / 2; + if (middle == min) + break; + + current_val = pmif_get_ulposc_freq_mhz(middle); + if (current_val > FREQ_260MHZ) + max = middle; + else + min = middle; + } while (min <= max); + + diff_by_min = pmif_get_ulposc_freq_mhz(min) - FREQ_260MHZ; + diff_by_min = ABS(diff_by_min); + + diff_by_max = pmif_get_ulposc_freq_mhz(max) - FREQ_260MHZ; + diff_by_max = ABS(diff_by_max); + + if (diff_by_min < diff_by_max) { + cal_result = min; + current_val = pmif_get_ulposc_freq_mhz(min); + } else { + cal_result = max; + current_val = pmif_get_ulposc_freq_mhz(max); + } + + /* check if calibrated value is in the range of target value +- 15% */ + if (current_val < (FREQ_260MHZ * (1000 - CAL_TOL_RATE) / 1000) || + current_val > (FREQ_260MHZ * (1000 + CAL_TOL_RATE) / 1000)) { + printk(BIOS_ERR, "[%s] calibration fail: %dM\n", __func__, current_val); + ret = 1; + } + + return ret; +} + +static int pmif_init_ulposc(void) +{ + /* calibrate ULPOSC1 */ + pmif_ulposc_config(); + + /* enable spm swinf */ + if (!READ32_BITFIELD(&mtk_spm->poweron_config_en, BCLK_CG_EN)) + SET32_BITFIELDS(&mtk_spm->poweron_config_en, BCLK_CG_EN, 1, + PROJECT_CODE, 0xb16); + + /* turn on ulposc */ + SET32_BITFIELDS(&mtk_spm->ulposc_con, ULPOSC_EN, 1); + udelay(100); + SET32_BITFIELDS(&mtk_spm->ulposc_con, ULPOSC_CG_EN, 1); + + return pmif_ulposc_cali(); +} + +int pmif_clk_init(void) +{ + if (pmif_init_ulposc()) + return E_NODEV; + + /* turn off pmic_cg_tmr, cg_ap, cg_md, cg_conn clock */ + SET32_BITFIELDS(&mt8192_infracfg->module_sw_cg_0_set, PMIC_CG_TMR, 1, PMIC_CG_AP, 1, + PMIC_CG_MD, 1, PMIC_CG_CONN, 1); + + SET32_BITFIELDS(&mtk_topckgen->clk_cfg_8, PDN_PWRAP_ULPOSC, 0, CLK_PWRAP_ULPOSC_INV, + 0, CLK_PWRAP_ULPOSC_SET, 0); + SET32_BITFIELDS(&mtk_topckgen->clk_cfg_update1, CLK_CFG_UPDATE1, 1); + + /* use ULPOSC1 clock */ + SET32_BITFIELDS(&mt8192_infracfg->pmicw_clock_ctrl_clr, PMIC_SYSCK_26M_SEL, 0xf); + + /* toggle SPI/SPMI sw reset */ + SET32_BITFIELDS(&mt8192_infracfg->infra_globalcon_rst2_set, PMICSPMI_SWRST, 1, + PMIC_WRAP_SWRST, 1); + SET32_BITFIELDS(&mt8192_infracfg->infra_globalcon_rst2_clr, PMICSPMI_SWRST, 1, + PMIC_WRAP_SWRST, 1); + + /* turn on pmic_cg_tmr, cg_ap, cg_md, cg_conn clock */ + SET32_BITFIELDS(&mt8192_infracfg->module_sw_cg_0_clr, PMIC_CG_TMR, 1, PMIC_CG_AP, 1, + PMIC_CG_MD, 1, PMIC_CG_CONN, 1); + + return 0; +} diff --git a/src/soc/mediatek/mt8192/pmif_spi.c b/src/soc/mediatek/mt8192/pmif_spi.c new file mode 100644 index 0000000..7262004 --- /dev/null +++ b/src/soc/mediatek/mt8192/pmif_spi.c @@ -0,0 +1,332 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <delay.h> +#include <device/mmio.h> +#include <soc/infracfg.h> +#include <soc/pll.h> +#include <soc/pmif.h> +#include <soc/pmif_spi.h> +#include <soc/pmif_sw.h> +#include <timer.h> + +/* PMIF, SPI_MODE_CTRL */ +DEFINE_BIT(SPI_MODE_CTRL_VLD_SRCLK_EN_CTRL, 5) +DEFINE_BIT(SPI_MODE_CTRL_PMIF_RDY, 9) +DEFINE_BIT(SPI_MODE_CTRL_SRCLK_EN, 10) +DEFINE_BIT(SPI_MODE_CTRL_SRVOL_EN, 11) + +/* PMIF, SLEEP_PROTECTION_CTRL */ +DEFINE_BITFIELD(SPM_SLEEP_REQ_SEL, 1, 0) +DEFINE_BITFIELD(SCP_SLEEP_REQ_SEL, 10, 9) + +/* PMIF, OTHER_INF_EN */ +DEFINE_BITFIELD(INTGPSADCINF_EN, 5, 4) + +/* PMIF, STAUPD_CTRL */ +DEFINE_BITFIELD(STAUPD_CTRL_PRD, 3, 0) +DEFINE_BIT(STAUPD_CTRL_PMIC0_SIG_STA, 4) +DEFINE_BIT(STAUPD_CTRL_PMIC0_EINT_STA, 6) + +/* SPIMST, Manual_Mode_Access */ +DEFINE_BITFIELD(MAN_ACC_SPI_OP, 12, 8) +DEFINE_BIT(MAN_ACC_SPI_RW, 13) + +/* IOCFG_LM, PWRAP_SPI0_DRIVING */ +DEFINE_BITFIELD(PWRAP_SPI0_DRIVING, 2, 0) + +static void pmif_spi_config(struct pmif *arb) +{ + /* Set srclk_en always valid regardless of ulposc_sel_for_scp */ + SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, SPI_MODE_CTRL_VLD_SRCLK_EN_CTRL, 0); + + /* Set SPI mode controlled by srclk_en and srvol_en instead of pmif_rdy */ + SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, + SPI_MODE_CTRL_SRCLK_EN, 1, + SPI_MODE_CTRL_SRVOL_EN, 1, + SPI_MODE_CTRL_PMIF_RDY, 0); + + SET32_BITFIELDS(&arb->mtk_pmif->sleep_protection_ctrl, SPM_SLEEP_REQ_SEL, 0, + SCP_SLEEP_REQ_SEL, 0); + + /* Enable SWINF for AP */ + write32(&arb->mtk_pmif->inf_en, PMIF_SPI_AP); + + /* Enable arbitration for SWINF for AP */ + write32(&arb->mtk_pmif->arb_en, PMIF_SPI_AP); + + /* Enable PMIF_SPI Command Issue */ + write32(&arb->mtk_pmif->cmdissue_en, 1); +} + +static int check_idle(void *addr, u32 expected) +{ + u32 reg_rdata; + struct stopwatch sw; + + stopwatch_init_usecs_expire(&sw, PMIF_WAIT_IDLE_US); + do { + reg_rdata = read32(addr); + if (stopwatch_expired(&sw)) + return E_TIMEOUT; + } while ((reg_rdata & expected) != 0); + + return 0; +} + +static int reset_spislv(void) +{ + u32 pmicspi_mst_dio_en_backup; + + write32(&mtk_pmicspi_mst->wrap_en, 0); + write32(&mtk_pmicspi_mst->mux_sel, 1); + write32(&mtk_pmicspi_mst->man_en, 1); + pmicspi_mst_dio_en_backup = read32(&mtk_pmicspi_mst->dio_en); + write32(&mtk_pmicspi_mst->dio_en, 0); + + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, + MAN_ACC_SPI_OP, OP_CSL); + /* Reset counter */ + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, + MAN_ACC_SPI_OP, OP_OUTS); + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, + MAN_ACC_SPI_OP, OP_CSH); + /* + * In order to pull CSN signal to PMIC, + * PMIC will count it then reset spi slave + */ + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, + MAN_ACC_SPI_OP, OP_OUTS); + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, + MAN_ACC_SPI_OP, OP_OUTS); + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, + MAN_ACC_SPI_OP, OP_OUTS); + SET32_BITFIELDS(&mtk_pmicspi_mst->man_acc, MAN_ACC_SPI_RW, OP_WR, + MAN_ACC_SPI_OP, OP_OUTS); + + /* Wait for PMIC SPI Master to be idle */ + if (check_idle(&mtk_pmicspi_mst->other_busy_sta_0, SPIMST_STA)) { + printk(BIOS_ERR, "[%s] spi master busy, timeout\n", __func__); + return E_TIMEOUT; + } + + write32(&mtk_pmicspi_mst->man_en, 0); + write32(&mtk_pmicspi_mst->mux_sel, 0); + write32(&mtk_pmicspi_mst->wrap_en, 1); + write32(&mtk_pmicspi_mst->dio_en, pmicspi_mst_dio_en_backup); + + return 0; +} + +static void init_reg_clock(struct pmif *arb) +{ + /* Set SoC SPI IO driving strength to 4 mA */ + SET32_BITFIELDS(&mtk_iocfg_lm->drv_cfg1, PWRAP_SPI0_DRIVING, IO_4_MA); + + /* Configure SPI protocol */ + write32(&mtk_pmicspi_mst->ext_ck_write, 1); + write32(&mtk_pmicspi_mst->ext_ck_read, 0); + write32(&mtk_pmicspi_mst->cshext_write, 0); + write32(&mtk_pmicspi_mst->cshext_read, 0); + write32(&mtk_pmicspi_mst->cslext_write, 0); + write32(&mtk_pmicspi_mst->cslext_read, 0x100); + + /* Set Read Dummy Cycle Number (Slave Clock is 18MHz) */ + arb->write(arb, DEFAULT_SLVID, PMIC_DEW_RDDMY_NO, DUMMY_READ_CYCLES); + write32(&mtk_pmicspi_mst->rddmy, DUMMY_READ_CYCLES); + + /* Enable DIO mode */ + arb->write(arb, DEFAULT_SLVID, PMIC_DEW_DIO_EN, 0x1); + + /* Wait for completion of sending the commands */ + if (check_idle(&arb->mtk_pmif->inf_busy_sta, PMIF_SPI_AP)) { + printk(BIOS_ERR, "[%s] pmif channel busy, timeout\n", __func__); + return; + } + + if (check_idle(&arb->mtk_pmif->other_busy_sta_0, PMIF_CMD_STA)) { + printk(BIOS_ERR, "[%s] pmif cmd busy, timeout\n", __func__); + return; + } + + if (check_idle(&mtk_pmicspi_mst->other_busy_sta_0, SPIMST_STA)) { + printk(BIOS_ERR, "[%s] spi master busy, timeout\n", __func__); + return; + } + + write32(&mtk_pmicspi_mst->dio_en, 1); +} + +static void init_spislv(struct pmif *arb) +{ + /* Turn on SPI IO filter function */ + arb->write(arb, DEFAULT_SLVID, PMIC_FILTER_CON0, SPI_FILTER); + /* Turn on SPI IO SMT function to improve noise immunity */ + arb->write(arb, DEFAULT_SLVID, PMIC_SMT_CON1, SPI_SMT); + /* Turn off SPI IO pull function for power saving */ + arb->write(arb, DEFAULT_SLVID, PMIC_GPIO_PULLEN0_CLR, SPI_PULL_DISABLE); + /* Enable SPI access in SODI-3.0 and Suspend modes */ + arb->write(arb, DEFAULT_SLVID, PMIC_RG_SPI_CON0, 0x2); + /* Set SPI IO driving strength to 4 mA */ + arb->write(arb, DEFAULT_SLVID, PMIC_DRV_CON1, SPI_DRIVING); +} + +static int init_sistrobe(struct pmif *arb) +{ + u32 rdata = 0; + int si_sample_ctrl; + /* Random data for testing */ + const u32 test_data[30] = { + 0x6996, 0x9669, 0x6996, 0x9669, 0x6996, 0x9669, 0x6996, + 0x9669, 0x6996, 0x9669, 0x5AA5, 0xA55A, 0x5AA5, 0xA55A, + 0x5AA5, 0xA55A, 0x5AA5, 0xA55A, 0x5AA5, 0xA55A, 0x1B27, + 0x1B27, 0x1B27, 0x1B27, 0x1B27, 0x1B27, 0x1B27, 0x1B27, + 0x1B27, 0x1B27 + }; + + for (si_sample_ctrl = 0; si_sample_ctrl < 16; si_sample_ctrl++) { + write32(&mtk_pmicspi_mst->si_sampling_ctrl, si_sample_ctrl << 5); + + arb->read(arb, DEFAULT_SLVID, PMIC_DEW_READ_TEST, &rdata); + if (rdata == DEFAULT_VALUE_READ_TEST) + break; + } + + if (si_sample_ctrl == 16) + return E_CLK_EDGE; + + if (si_sample_ctrl == 15) + return E_CLK_LAST_SETTING; + + /* + * Add the delay time of SPI data from PMIC to align the start boundary + * to current sampling clock edge. + */ + for (int si_dly = 0; si_dly < 10; si_dly++) { + arb->write(arb, DEFAULT_SLVID, PMIC_RG_SPI_CON2, si_dly); + + int start_boundary_found = 0; + for (int i = 0; i < ARRAY_SIZE(test_data); i++) { + arb->write(arb, DEFAULT_SLVID, PMIC_DEW_WRITE_TEST, test_data[i]); + arb->read(arb, DEFAULT_SLVID, PMIC_DEW_WRITE_TEST, &rdata); + if ((rdata & 0x7fff) != (test_data[i] & 0x7fff)) { + start_boundary_found = 1; + break; + } + } + if (start_boundary_found == 1) + break; + } + + /* + * Change the sampling clock edge to the next one which is the middle + * of SPI data window. + */ + write32(&mtk_pmicspi_mst->si_sampling_ctrl, ++si_sample_ctrl << 5); + + /* Read Test */ + arb->read(arb, DEFAULT_SLVID, PMIC_DEW_READ_TEST, &rdata); + if (rdata != DEFAULT_VALUE_READ_TEST) { + printk(BIOS_ERR, "[%s] Failed for read test, data = %#x.\n", + __func__, rdata); + return E_READ_TEST_FAIL; + } + + return 0; +} + +static void init_staupd(struct pmif *arb) +{ + /* Unlock SPI Slave registers */ + arb->write(arb, DEFAULT_SLVID, PMIC_SPISLV_KEY, 0xbade); + + /* Enable CRC of PMIC 0 */ + arb->write(arb, DEFAULT_SLVID, PMIC_DEW_CRC_EN, 0x1); + + /* Wait for completion of sending the commands */ + if (check_idle(&arb->mtk_pmif->inf_busy_sta, PMIF_SPI_AP)) { + printk(BIOS_ERR, "[%s] pmif channel busy, timeout\n", __func__); + return; + } + + if (check_idle(&arb->mtk_pmif->other_busy_sta_0, PMIF_CMD_STA)) { + printk(BIOS_ERR, "[%s] pmif cmd busy, timeout\n", __func__); + return; + } + + if (check_idle(&mtk_pmicspi_mst->other_busy_sta_0, SPIMST_STA)) { + printk(BIOS_ERR, "[%s] spi master busy, timeout\n", __func__); + return; + } + + /* Configure CRC of PMIC Interface */ + write32(&arb->mtk_pmif->crc_ctrl, 0x1); + write32(&arb->mtk_pmif->sig_mode, 0x0); + + /* Lock SPI Slave registers */ + arb->write(arb, DEFAULT_SLVID, PMIC_SPISLV_KEY, 0x0); + + /* Set up PMIC Siganature */ + write32(&arb->mtk_pmif->pmic_sig_addr, PMIC_DEW_CRC_VAL); + + /* Set up PMIC EINT */ + write32(&arb->mtk_pmif->pmic_eint_sta_addr, PMIC_INT_STA); + + SET32_BITFIELDS(&arb->mtk_pmif->staupd_ctrl, + STAUPD_CTRL_PRD, 5, + STAUPD_CTRL_PMIC0_SIG_STA, 1, + STAUPD_CTRL_PMIC0_EINT_STA, 1); +} + +int pmif_spi_init(struct pmif *arb) +{ + pmif_spi_config(arb); + + /* Reset spislv */ + if (reset_spislv()) + return E_SPI_INIT_RESET_SPI; + + /* Enable WRAP */ + write32(&mtk_pmicspi_mst->wrap_en, 0x1); + + /* SPI Waveform Configuration */ + init_reg_clock(arb); + + /* SPI Slave Configuration */ + init_spislv(arb); + + /* Input data calibration flow; */ + if (init_sistrobe(arb)) { + printk(BIOS_ERR, "[%s] data calibration fail\n", __func__); + return E_SPI_INIT_SIDLY; + } + + /* Lock SPISLV Registers */ + arb->write(arb, DEFAULT_SLVID, PMIC_SPISLV_KEY, 0x0); + + /* + * Status update function initialization + * 1. Check signature using CRC (CRC 0 only) + * 2. Update EINT + * 3. Read back AUXADC thermal data for GPS + */ + init_staupd(arb); + + /* Configure PMIF Timer */ + write32(&arb->mtk_pmif->timer_ctrl, 0x3); + + /* Enable interfaces and arbitration */ + write32(&arb->mtk_pmif->inf_en, PMIF_SPI_HW_INF | PMIF_SPI_MD | + PMIF_SPI_AP_SECURE | PMIF_SPI_AP); + + write32(&arb->mtk_pmif->arb_en, PMIF_SPI_HW_INF | PMIF_SPI_MD | PMIF_SPI_AP_SECURE | + PMIF_SPI_AP | PMIF_SPI_STAUPD | PMIF_SPI_TSX_HW | PMIF_SPI_DCXO_HW); + + /* Enable GPS AUXADC HW 0 and 1 */ + SET32_BITFIELDS(&arb->mtk_pmif->other_inf_en, INTGPSADCINF_EN, 0x3); + + /* Set INIT_DONE */ + write32(&arb->mtk_pmif->init_done, 0x1); + + return 0; +} diff --git a/src/soc/mediatek/mt8192/pmif_spmi.c b/src/soc/mediatek/mt8192/pmif_spmi.c new file mode 100644 index 0000000..87b003b --- /dev/null +++ b/src/soc/mediatek/mt8192/pmif_spmi.c @@ -0,0 +1,242 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <device/mmio.h> +#include <soc/addressmap.h> +#include <soc/pll.h> +#include <soc/pll_common.h> +#include <soc/pmif.h> +#include <soc/pmif_spmi.h> +#include <soc/pmif_sw.h> +#include <soc/spmi.h> +#include <string.h> + +#define PMIF_CMD_PER_3 (0x1 << PMIF_CMD_EXT_REG_LONG) +#define PMIF_CMD_PER_1_3 ((0x1 << PMIF_CMD_REG) | (0x1 << PMIF_CMD_EXT_REG_LONG)) + +/* IOCFG_BM, DRV_CFG2 */ +DEFINE_BITFIELD(SPMI_SCL, 5, 3) +DEFINE_BITFIELD(SPMI_SDA, 8, 6) + +/* TOPRGU, WDT_SWSYSRST2 */ +DEFINE_BIT(SPMI_MST_RST, 4) +DEFINE_BITFIELD(UNLOCK_KEY, 31, 24) + +/* TOPCKGEN, CLK_CFG_15 */ +DEFINE_BITFIELD(CLK_SPMI_MST_SEL, 10, 8) +DEFINE_BIT(CLK_SPMI_MST_INT, 12) +DEFINE_BIT(PDN_SPMI_MST, 15) + +/* TOPCKGEN, CLK_CFG_UPDATE2 */ +DEFINE_BIT(SPMI_MST_CK_UPDATE, 30) + +/* SPMI_MST, SPMI_SAMPL_CTRL */ +DEFINE_BIT(SAMPL_CK_POL, 0) +DEFINE_BITFIELD(SAMPL_CK_DLY, 3, 1) + +/* PMIF, SPI_MODE_CTRL */ +DEFINE_BIT(SPI_MODE_CTRL, 7) +DEFINE_BIT(SRVOL_EN, 11) +DEFINE_BIT(SPI_MODE_EXT_CMD, 12) +DEFINE_BIT(SPI_EINT_MODE_GATING_EN, 13) + +/* PMIF, SLEEP_PROTECTION_CTRL */ +DEFINE_BITFIELD(SPM_SLEEP_REQ_SEL, 1, 0) +DEFINE_BITFIELD(SCP_SLEEP_REQ_SEL, 10, 9) + +static const struct spmi_device spmi_dev[] = { + { + .slvid = SPMI_SLAVE_6, + .type = BUCK_CPU, + .type_id = BUCK_CPU_ID, + }, + { + .slvid = SPMI_SLAVE_7, + .type = BUCK_GPU, + .type_id = BUCK_GPU_ID, + }, +}; + +static int spmi_config_master(void) +{ + /* Software reset */ + SET32_BITFIELDS(&mtk_rug->wdt_swsysrst2, SPMI_MST_RST, 1, UNLOCK_KEY, 0x85); + + SET32_BITFIELDS(&mtk_topckgen->clk_cfg_15, + CLK_SPMI_MST_SEL, 0x7, + CLK_SPMI_MST_INT, 1, + PDN_SPMI_MST, 1); + SET32_BITFIELDS(&mtk_topckgen->clk_cfg_update2, SPMI_MST_CK_UPDATE, 1); + + /* Software reset */ + SET32_BITFIELDS(&mtk_rug->wdt_swsysrst2, SPMI_MST_RST, 0, UNLOCK_KEY, 0x85); + + /* Enable SPMI */ + write32(&mtk_spmi_mst->mst_req_en, 1); + + return 0; +} + +static int spmi_read_check(struct pmif *pmif_arb, int slvid) +{ + u32 rdata = 0; + + pmif_arb->read(pmif_arb, slvid, MT6315_READ_TEST, &rdata); + if (rdata != MT6315_DEFAULT_VALUE_READ) { + printk(BIOS_ERR, "%s next, slvid:%d rdata = 0x%x.\n", + __func__, slvid, rdata); + return -E_NODEV; + } + + pmif_arb->read(pmif_arb, slvid, MT6315_READ_TEST_1, &rdata); + if (rdata != MT6315_DEFAULT_VALUE_READ) { + printk(BIOS_ERR, "%s next, slvid:%d rdata = 0x%x.\n", + __func__, slvid, rdata); + return -E_NODEV; + } + + return 0; +} + +static int spmi_cali_rd_clock_polarity(struct pmif *pmif_arb, const struct spmi_device *dev) +{ + int i; + bool success = false; + const struct cali cali_data[] = { + {SPMI_CK_DLY_1T, SPMI_CK_POL_POS}, + {SPMI_CK_NO_DLY, SPMI_CK_POL_POS}, + {SPMI_CK_NO_DLY, SPMI_CK_POL_NEG}, + }; + + /* Indicate sampling clock polarity, 1: Positive 0: Negative */ + for (i = 0; i < ARRAY_SIZE(cali_data); i++) { + SET32_BITFIELDS(&mtk_spmi_mst->mst_sampl, SAMPL_CK_DLY, cali_data[i].dly, + SAMPL_CK_POL, cali_data[i].pol); + if (spmi_read_check(pmif_arb, dev->slvid) == 0) { + success = true; + break; + } + } + + if (!success) + die("ERROR - calibration fail for spmi clk"); + + return 0; +} + +static int spmi_mst_init(struct pmif *pmif_arb) +{ + int i; + + if (!pmif_arb) { + printk(BIOS_ERR, "%s: null pointer for pmif dev.\n", __func__); + return -E_INVAL; + } + + /* config IOCFG */ + SET32_BITFIELDS(&mtk_iocfg_bm->drv_cfg2, SPMI_SCL, 0x2, SPMI_SDA, 0x2); + spmi_config_master(); + + for (i = 0; i < ARRAY_SIZE(spmi_dev); i++) + spmi_cali_rd_clock_polarity(pmif_arb, &spmi_dev[i]); + + return 0; +} + +static void pmif_spmi_force_normal_mode(int mstid) +{ + struct pmif *arb = get_pmif_controller(PMIF_SPMI, mstid); + + /* listen srclken_0 only for entering normal or sleep mode */ + SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, + SPI_MODE_CTRL, 0, + SRVOL_EN, 0, + SPI_MODE_EXT_CMD, 1, + SPI_EINT_MODE_GATING_EN, 1); + + /* enable spm/scp sleep request */ + SET32_BITFIELDS(&arb->mtk_pmif->sleep_protection_ctrl, SPM_SLEEP_REQ_SEL, 0, + SCP_SLEEP_REQ_SEL, 0); +} + +static void pmif_spmi_enable_swinf(int mstid) +{ + struct pmif *arb = get_pmif_controller(PMIF_SPMI, mstid); + + write32(&arb->mtk_pmif->inf_en, PMIF_SPMI_SW_CHAN); + write32(&arb->mtk_pmif->arb_en, PMIF_SPMI_SW_CHAN); +} + +static void pmif_spmi_enable_cmdIssue(int mstid, bool en) +{ + struct pmif *arb = get_pmif_controller(PMIF_SPMI, mstid); + + /* Enable cmdIssue */ + write32(&arb->mtk_pmif->cmdissue_en, en); +} + +static void pmif_spmi_enable(int mstid) +{ + struct pmif *arb = get_pmif_controller(PMIF_SPMI, mstid); + u32 cmd_per; + + /* clear all cmd permission for per channel */ + write32(&arb->mtk_pmif->inf_cmd_per_0, 0); + write32(&arb->mtk_pmif->inf_cmd_per_1, 0); + write32(&arb->mtk_pmif->inf_cmd_per_2, 0); + write32(&arb->mtk_pmif->inf_cmd_per_3, 0); + + /* enable if we need cmd 0~3 permission for per channel */ + cmd_per = PMIF_CMD_PER_3 << 28 | PMIF_CMD_PER_3 << 24 | + PMIF_CMD_PER_3 << 20 | PMIF_CMD_PER_3 << 16 | + PMIF_CMD_PER_3 << 8 | PMIF_CMD_PER_3 << 4 | + PMIF_CMD_PER_1_3 << 0; + write32(&arb->mtk_pmif->inf_cmd_per_0, cmd_per); + + cmd_per = PMIF_CMD_PER_3 << 4; + write32(&arb->mtk_pmif->inf_cmd_per_1, cmd_per); + + /* + * set bytecnt max limitation. + * hw bytecnt indicate when we set 0, it can send 1 byte; + * set 1, it can send 2 byte. + */ + write32(&arb->mtk_pmif->inf_max_bytecnt_per_0, 0); + write32(&arb->mtk_pmif->inf_max_bytecnt_per_1, 0); + write32(&arb->mtk_pmif->inf_max_bytecnt_per_2, 0); + write32(&arb->mtk_pmif->inf_max_bytecnt_per_3, 0); + + /* Add latency limitation */ + write32(&arb->mtk_pmif->lat_cnter_en, PMIF_SPMI_INF); + write32(&arb->mtk_pmif->lat_limit_0, 0); + write32(&arb->mtk_pmif->lat_limit_1, 0x4); + write32(&arb->mtk_pmif->lat_limit_2, 0x8); + write32(&arb->mtk_pmif->lat_limit_4, 0x8); + write32(&arb->mtk_pmif->lat_limit_6, 0x3FF); + write32(&arb->mtk_pmif->lat_limit_9, 0x4); + write32(&arb->mtk_pmif->lat_limit_loading, PMIF_SPMI_INF); + + write32(&arb->mtk_pmif->inf_en, PMIF_SPMI_INF); + write32(&arb->mtk_pmif->arb_en, PMIF_SPMI_INF); + write32(&arb->mtk_pmif->timer_ctrl, 0x3); + write32(&arb->mtk_pmif->init_done, 1); +} + +int pmif_spmi_init(struct pmif *arb) +{ + if (arb->is_pmif_init_done(arb) != 0) { + pmif_spmi_force_normal_mode(arb->mstid); + pmif_spmi_enable_swinf(arb->mstid); + pmif_spmi_enable_cmdIssue(arb->mstid, true); + pmif_spmi_enable(arb->mstid); + if (arb->is_pmif_init_done(arb)) + return -E_NODEV; + } + + if (spmi_mst_init(arb)) { + printk(BIOS_ERR, "[%s] failed to init spmi master\n", __func__); + return -E_NODEV; + } + + return 0; +}
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45398 )
Change subject: soc/mediatek/mt8192: add pmif driver ......................................................................
Patch Set 38:
(1 comment)
https://review.coreboot.org/c/coreboot/+/45398/38/src/soc/mediatek/mt8192/pm... File src/soc/mediatek/mt8192/pmif.c:
https://review.coreboot.org/c/coreboot/+/45398/38/src/soc/mediatek/mt8192/pm... PS38, Line 49: addr Is this expected to be less than (1 << 16)? If so, should we change the type to u16?