From owner-svn-src-all@freebsd.org Thu Aug 25 10:24:15 2016 Return-Path: Delivered-To: svn-src-all@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 7EBC3BC566C; Thu, 25 Aug 2016 10:24:15 +0000 (UTC) (envelope-from jmcneill@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 mx1.freebsd.org (Postfix) with ESMTPS id 59FC11238; Thu, 25 Aug 2016 10:24:15 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7PAOEck014711; Thu, 25 Aug 2016 10:24:14 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7PAOEMa014710; Thu, 25 Aug 2016 10:24:14 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201608251024.u7PAOEMa014710@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Thu, 25 Aug 2016 10:24:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r304795 - head/sys/arm/allwinner/clk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Aug 2016 10:24:15 -0000 Author: jmcneill Date: Thu Aug 25 10:24:14 2016 New Revision: 304795 URL: https://svnweb.freebsd.org/changeset/base/304795 Log: Add support for Allwinner multi-parent bus gates. Reviewed by: andrew, manu Modified: head/sys/arm/allwinner/clk/aw_gate.c Modified: head/sys/arm/allwinner/clk/aw_gate.c ============================================================================== --- head/sys/arm/allwinner/clk/aw_gate.c Thu Aug 25 10:20:27 2016 (r304794) +++ head/sys/arm/allwinner/clk/aw_gate.c Thu Aug 25 10:24:14 2016 (r304795) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -89,11 +90,14 @@ static struct ofw_compat_data compat_dat (uintptr_t)"Allwinner APB0 Clock Gates" }, { "allwinner,sun8i-h3-bus-gates-clk", - (uintptr_t)"Allwinner Bus Clock Gates"}, + (uintptr_t)"Allwinner Bus Clock Gates" }, { "allwinner,sun9i-a80-apbs-gates-clk", (uintptr_t)"Allwinner APBS Clock Gates" }, + { "allwinner,sunxi-multi-bus-gates-clk", + (uintptr_t)"Allwinner Multi Bus Clock Gates" }, + { NULL, 0 } }; @@ -119,6 +123,43 @@ aw_gate_create(device_t dev, bus_addr_t } static int +aw_gate_add(device_t dev, struct clkdom *clkdom, phandle_t node, + bus_addr_t paddr) +{ + const char **names; + uint32_t *indices; + clk_t clk_parent; + int index, nout, error; + + indices = NULL; + + nout = clk_parse_ofw_out_names(dev, node, &names, &indices); + if (nout == 0) { + device_printf(dev, "no clock outputs found\n"); + return (ENOENT); + } + if (indices == NULL) { + device_printf(dev, "no clock-indices property\n"); + return (ENXIO); + } + + error = clk_get_by_ofw_index(dev, node, 0, &clk_parent); + if (error != 0) { + device_printf(dev, "cannot parse clock parent\n"); + return (ENXIO); + } + + for (index = 0; index < nout; index++) { + error = aw_gate_create(dev, paddr, clkdom, + clk_get_name(clk_parent), names[index], indices[index]); + if (error) + return (error); + } + + return (0); +} + +static int aw_gate_probe(device_t dev) { const char *d; @@ -138,16 +179,11 @@ static int aw_gate_attach(device_t dev) { struct clkdom *clkdom; - const char **names; - int index, nout, error; - uint32_t *indices; - clk_t clk_parent; bus_addr_t paddr; bus_size_t psize; - phandle_t node; + phandle_t node, child; node = ofw_bus_get_node(dev); - indices = NULL; if (ofw_reg_to_paddr(node, 0, &paddr, &psize, NULL) != 0) { device_printf(dev, "cannot parse 'reg' property\n"); @@ -156,44 +192,21 @@ aw_gate_attach(device_t dev) clkdom = clkdom_create(dev); - nout = clk_parse_ofw_out_names(dev, node, &names, &indices); - if (nout == 0) { - device_printf(dev, "no clock outputs found\n"); - error = ENOENT; - goto fail; - } - if (indices == NULL) { - device_printf(dev, "no clock-indices property\n"); - error = ENXIO; - goto fail; - } - - error = clk_get_by_ofw_index(dev, 0, 0, &clk_parent); - if (error != 0) { - device_printf(dev, "cannot parse clock parent\n"); - return (ENXIO); - } - - for (index = 0; index < nout; index++) { - error = aw_gate_create(dev, paddr, clkdom, - clk_get_name(clk_parent), names[index], indices[index]); - if (error) - goto fail; - } + if (ofw_bus_is_compatible(dev, "allwinner,sunxi-multi-bus-gates-clk")) { + for (child = OF_child(node); child > 0; child = OF_peer(child)) + aw_gate_add(dev, clkdom, child, paddr); + } else + aw_gate_add(dev, clkdom, node, paddr); if (clkdom_finit(clkdom) != 0) { device_printf(dev, "cannot finalize clkdom initialization\n"); - error = ENXIO; - goto fail; + return (ENXIO); } if (bootverbose) clkdom_dump(clkdom); return (0); - -fail: - return (error); } static device_method_t aw_gate_methods[] = {