From owner-svn-src-head@freebsd.org Sun Jan 7 04:59:29 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A6F0E68822; Sun, 7 Jan 2018 04:59:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CFCF76668; Sun, 7 Jan 2018 04:59:29 +0000 (UTC) (envelope-from kevans@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 9568A1CA61; Sun, 7 Jan 2018 04:59:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w074xSb5052268; Sun, 7 Jan 2018 04:59:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w074xSaZ052266; Sun, 7 Jan 2018 04:59:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201801070459.w074xSaZ052266@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 7 Jan 2018 04:59:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327670 - in head: share/man/man4 sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head: share/man/man4 sys/arm/allwinner X-SVN-Commit-Revision: 327670 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 04:59:29 -0000 Author: kevans Date: Sun Jan 7 04:59:28 2018 New Revision: 327670 URL: https://svnweb.freebsd.org/changeset/base/327670 Log: aw_sid(4): Add support for Allwinner H3 The sid controller on the H3 is generally identical in location, size, and efuse offset to the a64 and the a83t. The main difference is that the H3 has a silicon bug that sometimes causes the rootkey (at least) to be garbled unless first read by the prctl registers. This device is currently not in our DTS and, as of now, is not yet present in mainline Linux DTS. Tested on: OrangePi One Modified: head/share/man/man4/aw_sid.4 head/sys/arm/allwinner/aw_sid.c Modified: head/share/man/man4/aw_sid.4 ============================================================================== --- head/share/man/man4/aw_sid.4 Sun Jan 7 03:31:55 2018 (r327669) +++ head/share/man/man4/aw_sid.4 Sun Jan 7 04:59:28 2018 (r327670) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 2, 2018 +.Dd January 6, 2018 .Dt AW_SID 4 .Os .Sh NAME @@ -52,6 +52,8 @@ allwinner,sun7i-a20-sid allwinner,sun50i-a64-sid .It allwinner,sun8i-a83t-sid +.It +allwinner,sun8i-h3-sid .El .Sh SYSCTL VARIABLES The following read-only variables are available via Modified: head/sys/arm/allwinner/aw_sid.c ============================================================================== --- head/sys/arm/allwinner/aw_sid.c Sun Jan 7 03:31:55 2018 (r327669) +++ head/sys/arm/allwinner/aw_sid.c Sun Jan 7 04:59:28 2018 (r327670) @@ -67,36 +67,51 @@ __FBSDID("$FreeBSD$"); #define ROOT_KEY_SIZE 4 struct aw_sid_conf { + bus_size_t efuse_size; bus_size_t rootkey_offset; bool has_prctl; bool has_thermal; + bool requires_prctl_read; }; static const struct aw_sid_conf a10_conf = { + .efuse_size = 0x10, .rootkey_offset = 0, }; static const struct aw_sid_conf a20_conf = { + .efuse_size = 0x10, .rootkey_offset = 0, }; static const struct aw_sid_conf a64_conf = { + .efuse_size = 0x100, .rootkey_offset = SID_SRAM, .has_prctl = true, .has_thermal = true, }; static const struct aw_sid_conf a83t_conf = { + .efuse_size = 0x100, .rootkey_offset = SID_SRAM, .has_prctl = true, .has_thermal = true, }; +static const struct aw_sid_conf h3_conf = { + .efuse_size = 0x100, + .rootkey_offset = SID_SRAM, + .has_prctl = true, + .has_thermal = true, + .requires_prctl_read = true, +}; + static struct ofw_compat_data compat_data[] = { { "allwinner,sun4i-a10-sid", (uintptr_t)&a10_conf}, { "allwinner,sun7i-a20-sid", (uintptr_t)&a20_conf}, { "allwinner,sun50i-a64-sid", (uintptr_t)&a64_conf}, { "allwinner,sun8i-a83t-sid", (uintptr_t)&a83t_conf}, + { "allwinner,sun8i-h3-sid", (uintptr_t)&h3_conf}, { NULL, 0 } }; @@ -168,6 +183,8 @@ static int aw_sid_attach(device_t dev) { struct aw_sid_softc *sc; + bus_size_t i; + uint32_t val; sc = device_get_softc(dev); @@ -179,6 +196,19 @@ aw_sid_attach(device_t dev) mtx_init(&sc->prctl_mtx, device_get_nameunit(dev), NULL, MTX_DEF); sc->sid_conf = (struct aw_sid_conf *)ofw_bus_search_compatible(dev, compat_data)->ocd_data; aw_sid_sc = sc; + + /* + * This set of reads is solely for working around a silicon bug on some + * SoC that require a prctl read in order for direct register access to + * return a non-garbled value. Hence, the values we read are simply + * ignored. + */ + if (sc->sid_conf->requires_prctl_read) + for (i = 0; i < sc->sid_conf->efuse_size; i += 4) + if (aw_sid_prctl_read(dev, i, &val) != 0) { + device_printf(dev, "failed prctl read\n"); + return (ENXIO); + } SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),