Attention is currently required from: Guangjie Song, Hung-Te Lin, Jarried Lin, Yu-Ping Wu.
Yidi Lin has posted comments on this change by Jarried Lin. ( https://review.coreboot.org/c/coreboot/+/84497?usp=email )
Change subject: soc/mediatek/mt8196: Add mtcmos init support ......................................................................
Patch Set 34:
(2 comments)
File src/soc/mediatek/mt8196/mtcmos.c:
https://review.coreboot.org/c/coreboot/+/84497/comment/f2d69c42_004158bf?usp... : PS34, Line 150: CB_TYPE_PRE_OFF_SRAM, : CB_TYPE_POST_ON_SRAM, we don't need them in our case.
https://review.coreboot.org/c/coreboot/+/84497/comment/5b19c94a_bac170b5?usp... : PS34, Line 368: int mtcmos_cb_register(struct mtcmos_cb *cb) : { : struct mtcmos_cb *item = NULL; : bool exist = false; : : if (!cb) { : printk(BIOS_ERR, "node is NULL\n"); : return -EINVAL; : } : : if (!cb->name) { : printk(BIOS_ERR, "callback name NULL\n"); : return -EINVAL; : } : : if (!cb->pre_off && !cb->pre_on && !cb->post_on && !cb->post_off) { : printk(BIOS_ERR, "callback api NULL\n"); : return -EINVAL; : } : : /* add node to link list */ : list_for_each(item, mtcmos_cb_head, node) { : if (!strcmp(item->name, cb->name)) { : exist = true; : break; : } : } : if (exist) { : printk(BIOS_ERR, "ERR: %s exist\n", cb->name); : return -EEXIST; : } : : list_insert_after(&cb->node, &mtcmos_cb_head); : return 0; : } : : static int mtcmos_callback(u32 id, enum mtcmos_cb_type type) : { : struct mtcmos_cb *cb; : int ret = 0; : : list_for_each(cb, mtcmos_cb_head, node) { : if (cb->id == id) { : switch (type) { : case CB_TYPE_PRE_ON: : if (cb->pre_on) : ret = cb->pre_on(); : break; : case CB_TYPE_POST_ON: : if (cb->post_on) : ret = cb->post_on(); : break; : case CB_TYPE_PRE_OFF: : if (cb->pre_off) : ret = cb->pre_off(); : break; : case CB_TYPE_POST_OFF: : if (cb->post_off) : ret = cb->post_off(); : break; : case CB_TYPE_POST_ON_SRAM: : if (cb->post_on_sram) : ret = cb->post_on_sram(); : break; : case CB_TYPE_PRE_OFF_SRAM: : if (cb->pre_off_sram) : ret = cb->pre_off_sram(); : break; : default: : printk(BIOS_ERR, "%s(%u, %d) invalid type\n", __func__, id, type); : return -EINVAL; : } : : if (ret) : break; : } : } : : if (ret) : printk(BIOS_ERR, "%s(%u, %d) failed(%d)\n", __func__, id, type, ret); : : return ret; : } : : static inline int mtcmos_pre_on_callback(u32 id) : { : return mtcmos_callback(id, CB_TYPE_PRE_ON); : } : : static inline int mtcmos_pre_off_callback(u32 id) : { : return mtcmos_callback(id, CB_TYPE_PRE_OFF); : } : : static inline int mtcmos_post_on_callback(u32 id) : { : return mtcmos_callback(id, CB_TYPE_POST_ON); : } : : static inline int mtcmos_post_off_callback(u32 id) : { : return mtcmos_callback(id, CB_TYPE_POST_OFF); : } : : static inline int mtcmos_pre_off_sram_callback(u32 id) : { : return mtcmos_callback(id, CB_TYPE_PRE_OFF_SRAM); : } : : static inline int mtcmos_post_on_sram_callback(u32 id) : { : return mtcmos_callback(id, CB_TYPE_POST_ON_SRAM); : } I don't think it is worth to add such complex logic to register the callback for only for `4` types of mtcmos? (1 in mtcmos.c and 3 in mmfra_pd.c)
These 4 types only need `PRE_ON`, `POST_ON`, `PRE_OFF` and `POST_OFF` settings. Can we just simplify them like this ? ``` mtcmos_disp_vcore_pre_on(); mtcmos_ctrl(MTCMOS_ID_DISP_VCORE, MTCMOS_POWER_ON); mtcmos_disp_vcore_post_on(); ```