Hello Po Xu,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/46390
to review the following change.
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
soc/mediatek/mt8192: Add auxadc driver
Add MT8192 auxadc driver.
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- M src/soc/mediatek/mt8192/Makefile.inc A src/soc/mediatek/mt8192/auxadc.c M src/soc/mediatek/mt8192/include/soc/addressmap.h A src/soc/mediatek/mt8192/include/soc/auxadc.h A src/soc/mediatek/mt8192/include/soc/efuse.h 5 files changed, 116 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/1
diff --git a/src/soc/mediatek/mt8192/Makefile.inc b/src/soc/mediatek/mt8192/Makefile.inc index d417ae2..9bb9cfd 100644 --- a/src/soc/mediatek/mt8192/Makefile.inc +++ b/src/soc/mediatek/mt8192/Makefile.inc @@ -1,5 +1,6 @@ ifeq ($(CONFIG_SOC_MEDIATEK_MT8192),y)
+bootblock-y += auxadc.c bootblock-y += bootblock.c bootblock-y += flash_controller.c bootblock-y += ../common/gpio.c gpio.c @@ -13,12 +14,14 @@ bootblock-y += mt6315.c bootblock-y += mt6359p.c
+verstage-y += auxadc.c verstage-y += flash_controller.c verstage-y += ../common/gpio.c gpio.c verstage-$(CONFIG_SPI_FLASH) += ../common/spi.c spi.c verstage-y += ../common/timer.c verstage-y += ../common/uart.c
+romstage-y += auxadc.c romstage-y += ../common/cbmem.c romstage-y += emi.c romstage-y += flash_controller.c @@ -29,6 +32,7 @@ romstage-y += ../common/timer.c romstage-y += ../common/uart.c
+ramstage-y += auxadc.c ramstage-y += flash_controller.c ramstage-y += ../common/gpio.c gpio.c ramstage-y += emi.c diff --git a/src/soc/mediatek/mt8192/auxadc.c b/src/soc/mediatek/mt8192/auxadc.c new file mode 100755 index 0000000..3f9238b --- /dev/null +++ b/src/soc/mediatek/mt8192/auxadc.c @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <device/mmio.h> +#include <assert.h> +#include <delay.h> +#include <soc/addressmap.h> +#include <soc/auxadc.h> +#include <soc/efuse.h> +#include <soc/infracfg.h> +#include <timer.h> + +static struct mtk_auxadc_regs *const mtk_auxadc = (void *)AUXADC_BASE; + +#define ADC_GE_A_SHIFT 10 +#define ADC_GE_A_MASK (0x3ff << ADC_GE_A_SHIFT) +#define ADC_OE_A_SHIFT 0 +#define ADC_OE_A_MASK (0x3ff << ADC_OE_A_SHIFT) +#define ADC_CALI_EN_A_SHIFT 20 +#define ADC_CALI_EN_A_MASK (0x1 << ADC_CALI_EN_A_SHIFT) + +static int cali_oe; +static int cali_ge; +static int calibrated = 0; +static void mt_auxadc_update_cali(void) +{ + uint32_t cali_reg; + int cali_ge_a; + int cali_oe_a; + + cali_reg = read32(&mtk_efuse->adc_cali_reg); + + if ((cali_reg & ADC_CALI_EN_A_MASK) != 0) { + cali_oe_a = (cali_reg & ADC_OE_A_MASK) >> ADC_OE_A_SHIFT; + cali_ge_a = (cali_reg & ADC_GE_A_MASK) >> ADC_GE_A_SHIFT; + cali_ge = cali_ge_a - 512; + cali_oe = cali_oe_a - 512; + } +} +static uint32_t auxadc_get_rawdata(int channel) +{ + setbits32(&mt8192_infracfg->module_sw_cg_1_clr, 1 << 10); + assert(wait_ms(300, !(read32(&mtk_auxadc->con2) & 0x1))); + + clrbits32(&mtk_auxadc->con1, 1 << channel); + assert(wait_ms(300, !(read32(&mtk_auxadc->data[channel]) & (1 << 12)))); + + setbits32(&mtk_auxadc->con1, 1 << channel); + udelay(25); + assert(wait_ms(300, read32(&mtk_auxadc->data[channel]) & (1 << 12))); + + uint32_t value = read32(&mtk_auxadc->data[channel]) & 0x0FFF; + + setbits32(&mt8192_infracfg->module_sw_cg_1_set, 1 << 10); + + return value; +} + +int auxadc_get_voltage(unsigned int channel) +{ + uint32_t raw_value; + assert(channel < 16); + + if (!calibrated) { + mt_auxadc_update_cali(); + calibrated = 1; + } + + /* 1.5V in 4096 steps */ + raw_value = auxadc_get_rawdata(channel); + raw_value = raw_value - cali_oe; + return (int)((int64_t)raw_value * 1500000 / (4096 + cali_ge)); +} diff --git a/src/soc/mediatek/mt8192/include/soc/addressmap.h b/src/soc/mediatek/mt8192/include/soc/addressmap.h old mode 100644 new mode 100755 index e9cb788..9760c88 --- a/src/soc/mediatek/mt8192/include/soc/addressmap.h +++ b/src/soc/mediatek/mt8192/include/soc/addressmap.h @@ -26,6 +26,7 @@ PMIF_SPMI_BASE = IO_PHYS + 0x00027000, PMICSPI_MST_BASE = IO_PHYS + 0x00028000, SPMI_MST_BASE = IO_PHYS + 0x00029000, + AUXADC_BASE = IO_PHYS + 0x01001000, UART0_BASE = IO_PHYS + 0x01002000, SPI0_BASE = IO_PHYS + 0x0100A000, SPI1_BASE = IO_PHYS + 0x01010000, @@ -37,6 +38,7 @@ SPI7_BASE = IO_PHYS + 0x0101E000, SSUSB_IPPC_BASE = IO_PHYS + 0x01203e00, SFLASH_REG_BASE = IO_PHYS + 0x01234000, + EFUSEC_BASE = IO_PHYS + 0x01C10000, IOCFG_RM_BASE = IO_PHYS + 0x01C20000, IOCFG_BM_BASE = IO_PHYS + 0x01D10000, IOCFG_BL_BASE = IO_PHYS + 0x01D30000, diff --git a/src/soc/mediatek/mt8192/include/soc/auxadc.h b/src/soc/mediatek/mt8192/include/soc/auxadc.h new file mode 100755 index 0000000..18350d6 --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/auxadc.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _MTK_ADC_H +#define _MTK_ADC_H + +#include <stdint.h> + +typedef struct mtk_auxadc_regs { + uint32_t con0; + uint32_t con1; + uint32_t con1_set; + uint32_t con1_clr; + uint32_t con2; + uint32_t data[16]; + uint32_t reserved[16]; + uint32_t misc; +} mtk_auxadc_regs; + +/* Return voltage in uVolt */ +int auxadc_get_voltage(unsigned int channel); +#endif diff --git a/src/soc/mediatek/mt8192/include/soc/efuse.h b/src/soc/mediatek/mt8192/include/soc/efuse.h new file mode 100755 index 0000000..f0f3405 --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/efuse.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _MTK_EFUSE_H +#define _MTK_EFUSE_H + +#include <soc/addressmap.h> +#include <types.h> + +struct efuse_regs { + uint32_t rserved[109]; + uint32_t adc_cali_reg; +}; + +check_member(efuse_regs, adc_cali_reg, 0x1b4); +static struct efuse_regs *const mtk_efuse = (void *)EFUSEC_BASE; + +#endif
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 4:
File src/soc/mediatek/mt8192/auxadc.c has one or more executable bits set in the file permissions. File src/soc/mediatek/mt8192/include/soc/auxadc.h has one or more executable bits set in the file permissions. File src/soc/mediatek/mt8192/include/soc/efuse.h has one or more executable bits set in the file permissions.
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG@10 PS4, Line 10: What is AUXADC, and what is the name and revision of the datasheet?
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 4:
(4 comments)
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG@9 PS4, Line 9: Add MT8192 auxadc driver. Please describe the implementation. A possible delay of 3 * 300 ms should be explained.
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/aux... File src/soc/mediatek/mt8192/auxadc.c:
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/aux... PS4, Line 41: setbits32(&mt8192_infracfg->module_sw_cg_1_clr, 1 << 10); : assert(wait_ms(300, !(read32(&mtk_auxadc->con2) & 0x1))); : : clrbits32(&mtk_auxadc->con1, 1 << channel); : assert(wait_ms(300, !(read32(&mtk_auxadc->data[channel]) & (1 << 12)))); : : setbits32(&mtk_auxadc->con1, 1 << channel); : udelay(25); : assert(wait_ms(300, read32(&mtk_auxadc->data[channel]) & (1 << 12))); 300 ms time-out sound too much for coreboot. Please print warning messages if it took longer than 10 ms.
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/auxadc.h:
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/inc... PS4, Line 20: auxadc_get_voltage Please add the unit to the function name: `auxadc_get_voltage_uv()`.
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/inc... PS4, Line 20: int Voltage is non-negative: `unsigned int`?
Felix Singer has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 12:
(4 comments)
https://review.coreboot.org/c/coreboot/+/46390/12/src/soc/mediatek/mt8192/au... File src/soc/mediatek/mt8192/auxadc.c:
PS12: Remove execute bit
https://review.coreboot.org/c/coreboot/+/46390/12/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/addressmap.h:
PS12: Remove execute bit
https://review.coreboot.org/c/coreboot/+/46390/12/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/auxadc.h:
PS12: Remove execute bit
https://review.coreboot.org/c/coreboot/+/46390/12/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/efuse.h:
PS12: Remove execute bit
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 12:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG@10 PS4, Line 10:
What is AUXADC, and what is the name and revision of the datasheet?
AUXADC: auxiliary analogue-to-digital conversion The auxiliary ADC unit is used to identify the plugged peripheral and perform temperature/voltage measurement.
Reference datasheet: AUXADC.pdf
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/aux... File src/soc/mediatek/mt8192/auxadc.c:
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/aux... PS4, Line 41: setbits32(&mt8192_infracfg->module_sw_cg_1_clr, 1 << 10); : assert(wait_ms(300, !(read32(&mtk_auxadc->con2) & 0x1))); : : clrbits32(&mtk_auxadc->con1, 1 << channel); : assert(wait_ms(300, !(read32(&mtk_auxadc->data[channel]) & (1 << 12)))); : : setbits32(&mtk_auxadc->con1, 1 << channel); : udelay(25); : assert(wait_ms(300, read32(&mtk_auxadc->data[channel]) & (1 << 12)));
300 ms time-out sound too much for coreboot. […]
First of all, wait_ms() will only delay 300ms in the worst case. If there is a 300ms delay, it means that auxadc has a problem or is blocked. Normally, there is no need to delay, and you can check that the busy bit or ready bit meets the sampling conditions. (Occasionally there may be a delay of 1~2ms), so you don’t need to worry about it delaying 300ms.
About 300ms delay is the recommended time given by designer.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 12:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG@10 PS4, Line 10:
AUXADC: auxiliary analogue-to-digital conversion […]
Please merge your answer into the commit description.
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/aux... File src/soc/mediatek/mt8192/auxadc.c:
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/aux... PS4, Line 41: setbits32(&mt8192_infracfg->module_sw_cg_1_clr, 1 << 10); : assert(wait_ms(300, !(read32(&mtk_auxadc->con2) & 0x1))); : : clrbits32(&mtk_auxadc->con1, 1 << channel); : assert(wait_ms(300, !(read32(&mtk_auxadc->data[channel]) & (1 << 12)))); : : setbits32(&mtk_auxadc->con1, 1 << channel); : udelay(25); : assert(wait_ms(300, read32(&mtk_auxadc->data[channel]) & (1 << 12)));
First of all, wait_ms() will only delay 300ms in the worst case. […]
Is the 300ms documented somewhere in data sheet? If yes you can simply add a comment for it.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 13:
File src/soc/mediatek/mt8192/auxadc.c has one or more executable bits set in the file permissions. File src/soc/mediatek/mt8192/include/soc/addressmap.h has one or more executable bits set in the file permissions. File src/soc/mediatek/mt8192/include/soc/auxadc.h has one or more executable bits set in the file permissions. File src/soc/mediatek/mt8192/include/soc/efuse.h has one or more executable bits set in the file permissions.
JG Poxu has uploaded a new patch set (#15) to the change originally created by Yidi Lin. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
soc/mediatek/mt8192: Add auxadc driver
Add MT8192 auxadc driver.
[Description] 1. AUXADC: auxiliary analogue-to-digital conversion The auxiliary ADC unit is used to identify the plugged peripheral and perform temperature/voltage measurement.
2. AUXADC will check whether the busy bit or data ready bit is ok before preparing for samping, or before/after trigggering sampling, and then decide whether to jump out or continue samping. In the worst case, time to check a busy bit or data ready bit will be delayed 300ms (Under normal circumstances, there is almost no delay or occasionally a few ms delay can be checked ok). The entire sampling flow, there will be a total of 3 check busy bit or data ready bit procee.
3. Reference datasheet: AUXADC.pdf
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- M src/soc/mediatek/mt8192/Makefile.inc A src/soc/mediatek/mt8192/auxadc.c M src/soc/mediatek/mt8192/include/soc/addressmap.h A src/soc/mediatek/mt8192/include/soc/auxadc.h A src/soc/mediatek/mt8192/include/soc/efuse.h 5 files changed, 116 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/15
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 14:
(9 comments)
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG@9 PS4, Line 9: Add MT8192 auxadc driver.
Please describe the implementation. A possible delay of 3 * 300 ms should be explained.
Done
https://review.coreboot.org/c/coreboot/+/46390/4//COMMIT_MSG@10 PS4, Line 10:
Please merge your answer into the commit description.
Done
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/aux... File src/soc/mediatek/mt8192/auxadc.c:
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/aux... PS4, Line 41: setbits32(&mt8192_infracfg->module_sw_cg_1_clr, 1 << 10); : assert(wait_ms(300, !(read32(&mtk_auxadc->con2) & 0x1))); : : clrbits32(&mtk_auxadc->con1, 1 << channel); : assert(wait_ms(300, !(read32(&mtk_auxadc->data[channel]) & (1 << 12)))); : : setbits32(&mtk_auxadc->con1, 1 << channel); : udelay(25); : assert(wait_ms(300, read32(&mtk_auxadc->data[channel]) & (1 << 12)));
Is the 300ms documented somewhere in data sheet? If yes you can simply add a comment for it.
The auxadc datasheet will be updated in the next version. thanks.
https://review.coreboot.org/c/coreboot/+/46390/12/src/soc/mediatek/mt8192/au... File src/soc/mediatek/mt8192/auxadc.c:
PS12:
Remove execute bit
Done
https://review.coreboot.org/c/coreboot/+/46390/12/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/addressmap.h:
PS12:
Remove execute bit
Done
https://review.coreboot.org/c/coreboot/+/46390/12/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/auxadc.h:
PS12:
Remove execute bit
Done
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/auxadc.h:
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/inc... PS4, Line 20: int
Voltage is non-negative: `unsigned int`?
fixed it.
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/inc... PS4, Line 20: auxadc_get_voltage
Please add the unit to the function name: `auxadc_get_voltage_uv()`.
fixed it.
https://review.coreboot.org/c/coreboot/+/46390/12/src/soc/mediatek/mt8192/in... File src/soc/mediatek/mt8192/include/soc/efuse.h:
PS12:
Remove execute bit
Done
Yidi Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 15:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46390/15//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/15//COMMIT_MSG@24 PS15, Line 24: Reference datasheet: AUXADC.pdf Reference datasheet: RH-A-2020-0070, v1.0
https://review.coreboot.org/c/coreboot/+/46390/15/src/soc/mediatek/mt8192/au... File src/soc/mediatek/mt8192/auxadc.c:
https://review.coreboot.org/c/coreboot/+/46390/15/src/soc/mediatek/mt8192/au... PS15, Line 3: #include <device/mmio.h> in alphabet order
JG Poxu has uploaded a new patch set (#16) to the change originally created by Yidi Lin. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
soc/mediatek/mt8192: Add auxadc driver
Add MT8192 auxadc driver.
[Description] 1. AUXADC: auxiliary analogue-to-digital conversion The auxiliary ADC unit is used to identify the plugged peripheral and perform temperature/voltage measurement.
2. AUXADC will check whether the busy bit or data ready bit is ok before preparing for samping, or before/after trigggering sampling, and then decide whether to jump out or continue samping. In the worst case, time to check a busy bit or data ready bit will be delayed 300ms (Under normal circumstances, there is almost no delay or occasionally a few ms delay can be checked ok). The entire sampling flow, there will be a total of 3 check busy bit or data ready bit procee.
3. Reference datasheet: RH-A-2020-0070, v1.0
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- M src/soc/mediatek/mt8192/Makefile.inc A src/soc/mediatek/mt8192/auxadc.c M src/soc/mediatek/mt8192/include/soc/addressmap.h A src/soc/mediatek/mt8192/include/soc/auxadc.h A src/soc/mediatek/mt8192/include/soc/efuse.h 5 files changed, 116 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/16
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 16:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46390/15//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/15//COMMIT_MSG@24 PS15, Line 24: Reference datasheet: AUXADC.pdf
Reference datasheet: RH-A-2020-0070, v1. […]
Done
https://review.coreboot.org/c/coreboot/+/46390/15/src/soc/mediatek/mt8192/au... File src/soc/mediatek/mt8192/auxadc.c:
https://review.coreboot.org/c/coreboot/+/46390/15/src/soc/mediatek/mt8192/au... PS15, Line 3: #include <device/mmio.h>
in alphabet order
Done
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 16:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/inc... File src/soc/mediatek/mt8192/include/soc/auxadc.h:
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/inc... PS4, Line 20: int
fixed it.
Done
https://review.coreboot.org/c/coreboot/+/46390/4/src/soc/mediatek/mt8192/inc... PS4, Line 20: auxadc_get_voltage
fixed it.
Done
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 16: Code-Review+1
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 19:
(1 comment)
The implementation looks exactly the same as the one in 8183. Please move 8183 to common/ and share it for both 8183 and 8192 (you may need to move some registers to include/soc).
https://review.coreboot.org/c/coreboot/+/46390/19/src/soc/mediatek/mt8192/au... File src/soc/mediatek/mt8192/auxadc.c:
https://review.coreboot.org/c/coreboot/+/46390/19/src/soc/mediatek/mt8192/au... PS19, Line 38: } add one blank line after this.
JG Poxu has uploaded a new patch set (#20) to the change originally created by Yidi Lin. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
soc/mediatek/mt8192: Add auxadc driver
Add MT8192 auxadc driver.
[Description] 1. AUXADC: auxiliary analogue-to-digital conversion The auxiliary ADC unit is used to identify the plugged peripheral and perform temperature/voltage measurement.
2. AUXADC will check whether the busy bit or data ready bit is ok before preparing for samping, or before/after trigggering sampling, and then decide whether to jump out or continue samping. In the worst case, time to check a busy bit or data ready bit will be delayed 300ms (Under normal circumstances, there is almost no delay or occasionally a few ms delay can be checked ok). The entire sampling flow, there will be a total of 3 check busy bit or data ready bit procee.
3. Reference datasheet: RH-A-2020-0070, v1.0
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- M src/soc/mediatek/mt8192/Makefile.inc A src/soc/mediatek/mt8192/auxadc.c M src/soc/mediatek/mt8192/include/soc/addressmap.h A src/soc/mediatek/mt8192/include/soc/auxadc.h A src/soc/mediatek/mt8192/include/soc/efuse.h 5 files changed, 117 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/20
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 20: Code-Review+1
(1 comment)
https://review.coreboot.org/c/coreboot/+/46390/19/src/soc/mediatek/mt8192/au... File src/soc/mediatek/mt8192/auxadc.c:
https://review.coreboot.org/c/coreboot/+/46390/19/src/soc/mediatek/mt8192/au... PS19, Line 38: }
add one blank line after this.
Done
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Po Xu,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46390
to look at the new patch set (#21).
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
soc/mediatek/mt8192: Add auxadc driver
Add MT8192 auxadc driver.
[Description] 1. AUXADC: auxiliary analogue-to-digital conversion The auxiliary ADC unit is used to identify the plugged peripheral and perform temperature/voltage measurement.
2. AUXADC will check whether the busy bit or data ready bit is ok before preparing for samping, or before/after trigggering sampling, and then decide whether to jump out or continue samping. In the worst case, time to check a busy bit or data ready bit will be delayed 300ms (Under normal circumstances, there is almost no delay or occasionally a few ms delay can be checked ok). The entire sampling flow, there will be a total of 3 check busy bit or data ready bit procee.
3. Reference datasheet: RH-A-2020-0070, v1.0
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- M src/soc/mediatek/mt8192/Makefile.inc A src/soc/mediatek/mt8192/auxadc.c M src/soc/mediatek/mt8192/include/soc/addressmap.h A src/soc/mediatek/mt8192/include/soc/auxadc.h A src/soc/mediatek/mt8192/include/soc/efuse.h 5 files changed, 116 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/21
Yidi Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 21:
Patch Set 19:
(1 comment)
The implementation looks exactly the same as the one in 8183. Please move 8183 to common/ and share it for both 8183 and 8192 (you may need to move some registers to include/soc).
Po Xu will submit a new patchset for reusing 8183 auxadc driver.
JG Poxu has uploaded a new patch set (#24) to the change originally created by Yidi Lin. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
soc/mediatek/mt8192: Add auxadc driver
Add MT8192 auxadc driver.
[Description] 1. AUXADC: auxiliary analogue-to-digital conversion The auxiliary ADC unit is used to identify the plugged peripheral and perform temperature/voltage measurement.
2. AUXADC will check whether the busy bit or data ready bit is ok before preparing for samping, or before/after trigggering sampling, and then decide whether to jump out or continue samping. In the worst case, time to check a busy bit or data ready bit will be delayed 300ms (Under normal circumstances, there is almost no delay or occasionally a few ms delay can be checked ok). The entire sampling flow, there will be a total of 3 check busy bit or data ready bit procee.
3. Reference datasheet: RH-A-2020-0070, v1.0
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- R src/soc/mediatek/common/auxadc.c A src/soc/mediatek/common/include/soc/auxadc_common.h M src/soc/mediatek/mt8183/Makefile.inc M src/soc/mediatek/mt8183/include/soc/auxadc.h M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8192/include/soc/addressmap.h A src/soc/mediatek/mt8192/include/soc/auxadc.h A src/soc/mediatek/mt8192/include/soc/efuse.h 8 files changed, 68 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/24
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 24:
Thanks for making this change! There's just one nit - please split this into two changes:
1. src/mediatek: Move auxadc driver from MT8183 to common
2. src/mediatek/mt8192: Enable auxadc driver
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek/mt8192: Add auxadc driver ......................................................................
Patch Set 24:
also, I saw build failure:
src/mainboard/google/kukui/boardid.c:72:14: error: implicit declaration of function 'auxadc_get_voltage'; did you mean 'auxadc_get_voltage_uv'? [-Werror=implicit-function-declaration] int value = auxadc_get_voltage(channel); ^~~~~~~~~~~~~~~~~~ auxadc_get_voltage_uv
JG Poxu has uploaded a new patch set (#25) to the change originally created by Yidi Lin. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
soc/mediatek: Move auxadc driver from MT8183 to common
Move auxadc driver from MT8183 to common
[Description] 1. AUXADC: auxiliary analogue-to-digital conversion The auxiliary ADC unit is used to identify the plugged peripheral and perform temperature/voltage measurement.
2. AUXADC will check whether the busy bit or data ready bit is ok before preparing for samping, or before/after trigggering sampling, and then decide whether to jump out or continue samping. In the worst case, time to check a busy bit or data ready bit will be delayed 300ms (Under normal circumstances, there is almost no delay or occasionally a few ms delay can be checked ok). The entire sampling flow, there will be a total of 3 check busy bit or data ready bit procee.
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- R src/soc/mediatek/common/auxadc.c A src/soc/mediatek/common/include/soc/auxadc_common.h M src/soc/mediatek/mt8183/Makefile.inc M src/soc/mediatek/mt8183/include/soc/auxadc.h 4 files changed, 22 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/25
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 25: Code-Review+2
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 25: Code-Review+1
Patch Set 24:
also, I saw build failure:
src/mainboard/google/kukui/boardid.c:72:14: error: implicit declaration of function 'auxadc_get_voltage'; did you mean 'auxadc_get_voltage_uv'? [-Werror=implicit-function-declaration] int value = auxadc_get_voltage(channel); ^~~~~~~~~~~~~~~~~~ auxadc_get_voltage_uv
Because now the api name of auxadc has been changed a bit ( comment: Paul Menzel Oct 16 Please add the unit to the function name:`auxadc_get_voltage_uv()`.), The caller still uses the original api, so it will cause build fail. We will continue to fix this fail later
JG Poxu has uploaded a new patch set (#26) to the change originally created by Yidi Lin. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
soc/mediatek: Move auxadc driver from MT8183 to common
Move auxadc driver from MT8183 to common, update boardid.c file to avoid build fail.
[Description] 1. AUXADC: auxiliary analogue-to-digital conversion The auxiliary ADC unit is used to identify the plugged peripheral and perform temperature/voltage measurement.
2. AUXADC will check whether the busy bit or data ready bit is ok before preparing for samping, or before/after trigggering sampling, and then decide whether to jump out or continue samping. In the worst case, time to check a busy bit or data ready bit will be delayed 300ms (Under normal circumstances, there is almost no delay or occasionally a few ms delay can be checked ok). The entire sampling flow, there will be a total of 3 check busy bit or data ready bit procee.
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- M src/mainboard/google/kukui/boardid.c R src/soc/mediatek/common/auxadc.c A src/soc/mediatek/common/include/soc/auxadc_common.h M src/soc/mediatek/mt8183/Makefile.inc M src/soc/mediatek/mt8183/include/soc/auxadc.h 5 files changed, 24 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/26
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 26: Code-Review+1
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 26:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46390/26//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/26//COMMIT_MSG@9 PS26, Line 9: Move auxadc driver from MT8183 to common, : update boardid.c file to avoid build fail. : : [Description] : 1. AUXADC: auxiliary analogue-to-digital conversion : The auxiliary ADC unit is used to identify the plugged : peripheral and perform temperature/voltage measurement. : : 2. AUXADC will check whether the busy bit or data ready bit is ok : before preparing for samping, or before/after trigggering sampling, : and then decide whether to jump out or continue samping. : In the worst case, time to check a busy bit or data ready bit will be delayed 300ms : (Under normal circumstances, there is almost no delay or occasionally : a few ms delay can be checked ok). : The entire sampling flow, there will be a total of 3 check busy bit or data ready bit procee. The auxadc (auxiliary analogue-to-digital conversion) is a unit to identify the plugged peripherals or measure the temperature or voltages.
The MT8183 auxadc driver can be shared by multiple Mediatek SOCs so we should move it to the common folder.
Po Xu has uploaded a new patch set (#27) to the change originally created by Yidi Lin. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
soc/mediatek: Move auxadc driver from MT8183 to common
The auxadc (auxiliary analogue-to-digital conversion) is a unit to identify the plugged peripherals or measure the temperature or voltages.
The MT8183 auxadc driver can be shared by multiple Mediatek SOCs so we should move it to the common folder.
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- M src/mainboard/google/kukui/boardid.c R src/soc/mediatek/common/auxadc.c A src/soc/mediatek/common/include/soc/auxadc_common.h M src/soc/mediatek/mt8183/Makefile.inc M src/soc/mediatek/mt8183/include/soc/auxadc.h 5 files changed, 24 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/27
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 27:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46390/26//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/26//COMMIT_MSG@9 PS26, Line 9: Move auxadc driver from MT8183 to common, : update boardid.c file to avoid build fail. : : [Description] : 1. AUXADC: auxiliary analogue-to-digital conversion : The auxiliary ADC unit is used to identify the plugged : peripheral and perform temperature/voltage measurement. : : 2. AUXADC will check whether the busy bit or data ready bit is ok : before preparing for samping, or before/after trigggering sampling, : and then decide whether to jump out or continue samping. : In the worst case, time to check a busy bit or data ready bit will be delayed 300ms : (Under normal circumstances, there is almost no delay or occasionally : a few ms delay can be checked ok). : The entire sampling flow, there will be a total of 3 check busy bit or data ready bit procee.
The auxadc (auxiliary analogue-to-digital conversion) is a unit […]
Done
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 27: Code-Review+2
Hello Hung-Te Lin, build bot (Jenkins), Patrick Georgi, Martin Roth, Yu-Ping Wu, Po Xu,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46390
to look at the new patch set (#29).
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
soc/mediatek: Move auxadc driver from MT8183 to common
The auxadc (auxiliary analogue-to-digital conversion) is a unit to identify the plugged peripherals or measure the temperature or voltages.
The MT8183 auxadc driver can be shared by multiple Mediatek SOCs so we should move it to the common folder.
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- M src/mainboard/google/kukui/boardid.c R src/soc/mediatek/common/auxadc.c A src/soc/mediatek/common/include/soc/auxadc_common.h M src/soc/mediatek/mt8183/Makefile.inc M src/soc/mediatek/mt8183/include/soc/auxadc.h 5 files changed, 24 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/29
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 29:
(5 comments)
https://review.coreboot.org/c/coreboot/+/46390/29//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/29//COMMIT_MSG@13 PS29, Line 13: Mediatek MediaTek
https://review.coreboot.org/c/coreboot/+/46390/29//COMMIT_MSG@13 PS29, Line 13: SOCs SoCs
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/Ma... File src/soc/mediatek/mt8183/Makefile.inc:
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/Ma... PS29, Line 3: bootblock-y += ../common/auxadc.c Move it right after bootblock.c?
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/Ma... PS29, Line 47: ramstage-y += ../common/auxadc.c Move it after emi.c?
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/in... File src/soc/mediatek/mt8183/include/soc/auxadc.h:
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/in... PS29, Line 21: mt8183_infracfg_regs Is this the same as mt8192_infracfg_regs? If so, we can further merge them.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 29: -Code-Review
Po Xu has uploaded a new patch set (#30) to the change originally created by Yidi Lin. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
soc/mediatek: Move auxadc driver from MT8183 to common
The auxadc (auxiliary analogue-to-digital conversion) is a unit to identify the plugged peripherals or measure the temperature or voltages.
The MT8183 auxadc driver can be shared by multiple MediaTek SoCs so we should move it to the common folder.
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e --- M src/mainboard/google/kukui/boardid.c R src/soc/mediatek/common/auxadc.c A src/soc/mediatek/common/include/soc/auxadc_common.h M src/soc/mediatek/mt8183/Makefile.inc M src/soc/mediatek/mt8183/include/soc/auxadc.h 5 files changed, 24 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/46390/30
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 30:
(5 comments)
https://review.coreboot.org/c/coreboot/+/46390/29//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46390/29//COMMIT_MSG@13 PS29, Line 13: Mediatek
MediaTek
Done
https://review.coreboot.org/c/coreboot/+/46390/29//COMMIT_MSG@13 PS29, Line 13: SOCs
SoCs
Done
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/Ma... File src/soc/mediatek/mt8183/Makefile.inc:
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/Ma... PS29, Line 3: bootblock-y += ../common/auxadc.c
Move it right after bootblock. […]
Done
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/Ma... PS29, Line 47: ramstage-y += ../common/auxadc.c
Move it after emi. […]
Done
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/in... File src/soc/mediatek/mt8183/include/soc/auxadc.h:
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/in... PS29, Line 21: mt8183_infracfg_regs
Is this the same as mt8192_infracfg_regs? If so, we can further merge them.
yes, Since mt8192 has mt8192_infracfg_regs, So it needs to be written separately, and then I define a common variable to make the .c file common.
Po Xu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 30:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/in... File src/soc/mediatek/mt8183/include/soc/auxadc.h:
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/in... PS29, Line 21: mt8183_infracfg_regs
yes, […]
update:
no, Since mt8192 has mt8192_infracfg_regs, So it needs to be written separately, and then I define a common variable to make the .c file common.
Yidi Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 30:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/in... File src/soc/mediatek/mt8183/include/soc/auxadc.h:
https://review.coreboot.org/c/coreboot/+/46390/29/src/soc/mediatek/mt8183/in... PS29, Line 21: mt8183_infracfg_regs
yes, […]
@Yu-Ping, Although most of the register definitions looks similar, the register definition taking effect or not depend on the modules in each IC. Each IC should have its own infracfg definition.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
Patch Set 30: Code-Review+2
Hung-Te Lin has submitted this change. ( https://review.coreboot.org/c/coreboot/+/46390 )
Change subject: soc/mediatek: Move auxadc driver from MT8183 to common ......................................................................
soc/mediatek: Move auxadc driver from MT8183 to common
The auxadc (auxiliary analogue-to-digital conversion) is a unit to identify the plugged peripherals or measure the temperature or voltages.
The MT8183 auxadc driver can be shared by multiple MediaTek SoCs so we should move it to the common folder.
Signed-off-by: Po Xu jg_poxu@mediatek.com Change-Id: Id4553e99c3578fa40e28b19a6e010b52650ba41e Reviewed-on: https://review.coreboot.org/c/coreboot/+/46390 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/boardid.c R src/soc/mediatek/common/auxadc.c A src/soc/mediatek/common/include/soc/auxadc_common.h M src/soc/mediatek/mt8183/Makefile.inc M src/soc/mediatek/mt8183/include/soc/auxadc.h 5 files changed, 24 insertions(+), 15 deletions(-)
Approvals: build bot (Jenkins): Verified Hung-Te Lin: Looks good to me, approved
diff --git a/src/mainboard/google/kukui/boardid.c b/src/mainboard/google/kukui/boardid.c index 6c7547c..04ae7db 100644 --- a/src/mainboard/google/kukui/boardid.c +++ b/src/mainboard/google/kukui/boardid.c @@ -13,7 +13,7 @@ #include <device/i2c_simple.h> #include <drivers/camera/cros_camera.h> #include <ec/google/chromeec/ec.h> -#include <soc/auxadc.h> +#include <soc/auxadc_common.h> #include <soc/i2c.h> #include <soc/pmic_wrap_common.h> #include <string.h> @@ -69,7 +69,7 @@
static uint32_t get_adc_index(unsigned int channel) { - int value = auxadc_get_voltage(channel); + int value = auxadc_get_voltage_uv(channel);
assert(channel < ARRAY_SIZE(adc_voltages)); const int *voltages = adc_voltages[channel]; diff --git a/src/soc/mediatek/mt8183/auxadc.c b/src/soc/mediatek/common/auxadc.c similarity index 86% rename from src/soc/mediatek/mt8183/auxadc.c rename to src/soc/mediatek/common/auxadc.c index 19c9948..6dbf12b 100644 --- a/src/soc/mediatek/mt8183/auxadc.c +++ b/src/soc/mediatek/common/auxadc.c @@ -1,12 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0-only */
-#include <device/mmio.h> #include <assert.h> #include <delay.h> +#include <device/mmio.h> #include <soc/addressmap.h> #include <soc/auxadc.h> #include <soc/efuse.h> -#include <soc/infracfg.h> #include <timer.h>
static struct mtk_auxadc_regs *const mtk_auxadc = (void *)AUXADC_BASE; @@ -36,9 +35,10 @@ cali_oe = cali_oe_a - 512; } } + static uint32_t auxadc_get_rawdata(int channel) { - setbits32(&mt8183_infracfg->module_sw_cg_1_clr, 1 << 10); + setbits32(&mtk_infracfg->module_sw_cg_1_clr, 1 << 10); assert(wait_ms(300, !(read32(&mtk_auxadc->con2) & 0x1)));
clrbits32(&mtk_auxadc->con1, 1 << channel); @@ -50,12 +50,12 @@
uint32_t value = read32(&mtk_auxadc->data[channel]) & 0x0FFF;
- setbits32(&mt8183_infracfg->module_sw_cg_1_set, 1 << 10); + setbits32(&mtk_infracfg->module_sw_cg_1_set, 1 << 10);
return value; }
-int auxadc_get_voltage(unsigned int channel) +unsigned int auxadc_get_voltage_uv(unsigned int channel) { uint32_t raw_value; assert(channel < 16); @@ -67,7 +67,6 @@
/* 1.5V in 4096 steps */ raw_value = auxadc_get_rawdata(channel); - raw_value = raw_value - cali_oe; - return (int)((int64_t)raw_value * 1500000 / (4096 + cali_ge)); + return (unsigned int)((int64_t)raw_value * 1500000 / (4096 + cali_ge)); } diff --git a/src/soc/mediatek/common/include/soc/auxadc_common.h b/src/soc/mediatek/common/include/soc/auxadc_common.h new file mode 100644 index 0000000..de2408f --- /dev/null +++ b/src/soc/mediatek/common/include/soc/auxadc_common.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _MTK_ADC_COMMON_H +#define _MTK_ADC_COMMON_H + +/* Return voltage in uVolt */ +unsigned int auxadc_get_voltage_uv(unsigned int channel); +#endif diff --git a/src/soc/mediatek/mt8183/Makefile.inc b/src/soc/mediatek/mt8183/Makefile.inc index b0dd48f..43893c3 100644 --- a/src/soc/mediatek/mt8183/Makefile.inc +++ b/src/soc/mediatek/mt8183/Makefile.inc @@ -1,7 +1,7 @@ ifeq ($(CONFIG_SOC_MEDIATEK_MT8183),y)
-bootblock-y += auxadc.c bootblock-y += bootblock.c +bootblock-y += ../common/auxadc.c bootblock-y += ../common/gpio.c gpio.c bootblock-y += ../common/pll.c pll.c bootblock-$(CONFIG_SPI_FLASH) += ../common/spi.c spi.c @@ -15,7 +15,7 @@ decompressor-y += ../common/mmu_operations.c decompressor-y += ../common/timer.c
-verstage-y += auxadc.c +verstage-y += ../common/auxadc.c verstage-y += ../common/gpio.c gpio.c verstage-$(CONFIG_SPI_FLASH) += ../common/spi.c spi.c verstage-y += mt8183.c @@ -24,7 +24,7 @@ verstage-y += ../common/uart.c verstage-y += ../common/wdt.c
-romstage-y += auxadc.c +romstage-y += ../common/auxadc.c romstage-y += ../common/cbmem.c emi.c romstage-y += dramc_init_setting.c romstage-y += dramc_param.c @@ -44,8 +44,8 @@ romstage-y += ../common/uart.c romstage-y += ../common/wdt.c
-ramstage-y += auxadc.c ramstage-y += emi.c +ramstage-y += ../common/auxadc.c ramstage-y += ../common/ddp.c ddp.c ramstage-y += ../common/dsi.c dsi.c ramstage-y += ../common/gpio.c gpio.c diff --git a/src/soc/mediatek/mt8183/include/soc/auxadc.h b/src/soc/mediatek/mt8183/include/soc/auxadc.h index 18350d6..0e07de0 100644 --- a/src/soc/mediatek/mt8183/include/soc/auxadc.h +++ b/src/soc/mediatek/mt8183/include/soc/auxadc.h @@ -3,6 +3,8 @@ #ifndef _MTK_ADC_H #define _MTK_ADC_H
+#include <soc/auxadc_common.h> +#include <soc/infracfg.h> #include <stdint.h>
typedef struct mtk_auxadc_regs { @@ -16,6 +18,6 @@ uint32_t misc; } mtk_auxadc_regs;
-/* Return voltage in uVolt */ -int auxadc_get_voltage(unsigned int channel); +static struct mt8183_infracfg_regs *const mtk_infracfg = mt8183_infracfg; + #endif