From owner-svn-src-stable-12@freebsd.org Fri Jun 19 18:53:33 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 152433367B4; Fri, 19 Jun 2020 18:53:33 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49pScr6tchz4fVb; Fri, 19 Jun 2020 18:53:32 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CC5BC1F770; Fri, 19 Jun 2020 18:53:32 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05JIrWK2081200; Fri, 19 Jun 2020 18:53:32 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05JIrWxe081199; Fri, 19 Jun 2020 18:53:32 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202006191853.05JIrWxe081199@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 19 Jun 2020 18:53:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r362410 - stable/12/sys/arm64/rockchip X-SVN-Group: stable-12 X-SVN-Commit-Author: manu X-SVN-Commit-Paths: stable/12/sys/arm64/rockchip X-SVN-Commit-Revision: 362410 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jun 2020 18:53:33 -0000 Author: manu Date: Fri Jun 19 18:53:32 2020 New Revision: 362410 URL: https://svnweb.freebsd.org/changeset/base/362410 Log: MFC r360228: 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 Modified: stable/12/sys/arm64/rockchip/rk_tsadc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/rockchip/rk_tsadc.c ============================================================================== --- stable/12/sys/arm64/rockchip/rk_tsadc.c Fri Jun 19 18:43:13 2020 (r362409) +++ stable/12/sys/arm64/rockchip/rk_tsadc.c Fri Jun 19 18:53:32 2020 (r362410) @@ -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 */