From fb0d25511130225c4c0ec7d71779c4a737f9ffd3 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Thu, 23 Apr 2020 19:16:20 +0000 Subject: [PATCH] arm64: rockchip: Fix TSADC on RK3328 The TSADC familiy is a little bit more complex than V2 and V3. Early revision do not use syscon and do not use qsel (RK3288). Next revision still do not use syscon but uses qsel (RK3328). Final revision use both. Submitted by: peterj MFC after: 1 month --- sys/arm64/rockchip/rk_tsadc.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sys/arm64/rockchip/rk_tsadc.c b/sys/arm64/rockchip/rk_tsadc.c index 3aa2f381eb9e..7adb121d3b4a 100644 --- a/sys/arm64/rockchip/rk_tsadc.c +++ b/sys/arm64/rockchip/rk_tsadc.c @@ -98,24 +98,19 @@ struct tsensor { int channel; }; -enum tsadc_type { - RK_TSADC_V2, - RK_TSADC_V3 -}; - struct rk_calib_entry { uint32_t raw; int temp; }; struct tsadc_calib_info { - bool decrement_mode; struct rk_calib_entry *table; int nentries; }; struct tsadc_conf { - enum tsadc_type type; + int use_syscon; + int q_sel_ntc; int shutdown_temp; int shutdown_mode; int shutdown_pol; @@ -188,7 +183,8 @@ struct tsensor rk3288_tsensors[] = { }; struct tsadc_conf rk3288_tsadc_conf = { - .type = RK_TSADC_V2, + .use_syscon = 0, + .q_sel_ntc = 0, .shutdown_temp = 95000, .shutdown_mode = 1, /* GPIO */ .shutdown_pol = 0, /* Low */ @@ -241,7 +237,8 @@ static struct tsensor rk3328_tsensors[] = { }; static struct tsadc_conf rk3328_tsadc_conf = { - .type = RK_TSADC_V3, + .use_syscon = 0, + .q_sel_ntc = 1, .shutdown_temp = 95000, .shutdown_mode = 0, /* CRU */ .shutdown_pol = 0, /* Low */ @@ -296,7 +293,8 @@ static struct tsensor rk3399_tsensors[] = { }; static struct tsadc_conf rk3399_tsadc_conf = { - .type = RK_TSADC_V3, + .use_syscon = 1, + .q_sel_ntc = 1, .shutdown_temp = 95000, .shutdown_mode = 1, /* GPIO */ .shutdown_pol = 0, /* Low */ @@ -444,11 +442,11 @@ tsadc_init(struct tsadc_softc *sc) val |= TSADC_AUTO_CON_POL_HI; else val &= ~TSADC_AUTO_CON_POL_HI; - if (sc->conf->type == RK_TSADC_V3) + if (sc->conf->q_sel_ntc) val |= TSADC_AUTO_Q_SEL; WR4(sc, TSADC_AUTO_CON, val); - if (sc->conf->type == RK_TSADC_V2) { + if (!sc->conf->use_syscon) { /* V2 init */ WR4(sc, TSADC_AUTO_PERIOD, 250); /* 250 ms */ WR4(sc, TSADC_AUTO_PERIOD_HT, 50); /* 50 ms */