Date: Fri, 9 Dec 2016 20:13:31 +0000 (UTC) From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r309757 - stable/11/sys/arm/allwinner Message-ID: <201612092013.uB9KDVTl044641@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: manu Date: Fri Dec 9 20:13:31 2016 New Revision: 309757 URL: https://svnweb.freebsd.org/changeset/base/309757 Log: MFC r305349 (jmcneill): Add support for reading root key on A83T/A64. Modified: stable/11/sys/arm/allwinner/aw_sid.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/allwinner/aw_sid.c ============================================================================== --- stable/11/sys/arm/allwinner/aw_sid.c Fri Dec 9 20:07:01 2016 (r309756) +++ stable/11/sys/arm/allwinner/aw_sid.c Fri Dec 9 20:13:31 2016 (r309757) @@ -52,6 +52,11 @@ __FBSDID("$FreeBSD$"); #define SID_THERMAL_CALIB0 (SID_SRAM + 0x34) #define SID_THERMAL_CALIB1 (SID_SRAM + 0x38) +#define A10_ROOT_KEY_OFF 0x0 +#define A83T_ROOT_KEY_OFF SID_SRAM + +#define ROOT_KEY_SIZE 4 + enum sid_type { A10_SID = 1, A20_SID, @@ -67,7 +72,8 @@ static struct ofw_compat_data compat_dat struct aw_sid_softc { struct resource *res; - int type; + int type; + bus_size_t root_key_off; }; static struct aw_sid_softc *aw_sid_sc; @@ -81,9 +87,6 @@ enum sid_keys { AW_SID_ROOT_KEY, }; -#define ROOT_KEY_OFF 0x0 -#define ROOT_KEY_SIZE 4 - #define RD4(sc, reg) bus_read_4((sc)->res, (reg)) #define WR4(sc, reg, val) bus_write_4((sc)->res, (reg), (val)) @@ -118,17 +121,20 @@ aw_sid_attach(device_t dev) sc->type = ofw_bus_search_compatible(dev, compat_data)->ocd_data; switch (sc->type) { - case A10_SID: - case A20_SID: - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "rootkey", - CTLTYPE_STRING | CTLFLAG_RD, - dev, AW_SID_ROOT_KEY, aw_sid_sysctl, "A", "Root Key"); + case A83T_SID: + sc->root_key_off = A83T_ROOT_KEY_OFF; break; default: + sc->root_key_off = A10_ROOT_KEY_OFF; break; } + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "rootkey", + CTLTYPE_STRING | CTLFLAG_RD, + dev, AW_SID_ROOT_KEY, aw_sid_sysctl, "A", "Root Key"); + return (0); } @@ -159,11 +165,9 @@ aw_sid_get_rootkey(u_char *out) sc = aw_sid_sc; if (sc == NULL) return (ENXIO); - if (sc->type != A10_SID && sc->type != A20_SID) - return (ENXIO); for (i = 0; i < ROOT_KEY_SIZE ; i++) { - tmp = RD4(aw_sid_sc, ROOT_KEY_OFF + (i * 4)); + tmp = RD4(aw_sid_sc, aw_sid_sc->root_key_off + (i * 4)); be32enc(&out[i * 4], tmp); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612092013.uB9KDVTl044641>