From owner-svn-src-head@freebsd.org Mon Aug 19 14:28:55 2019 Return-Path: Delivered-To: svn-src-head@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 27C77C8204; Mon, 19 Aug 2019 14:28:55 +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) server-signature RSA-PSS (4096 bits) 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 46BxBH0GbLz3PPx; Mon, 19 Aug 2019 14:28:55 +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 DA9791BF3A; Mon, 19 Aug 2019 14:28:54 +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 x7JESseq067072; Mon, 19 Aug 2019 14:28:54 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7JESsvn067071; Mon, 19 Aug 2019 14:28:54 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201908191428.x7JESsvn067071@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 19 Aug 2019 14:28:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351217 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 351217 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.29 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: Mon, 19 Aug 2019 14:28:55 -0000 Author: manu Date: Mon Aug 19 14:28:54 2019 New Revision: 351217 URL: https://svnweb.freebsd.org/changeset/base/351217 Log: arm64: a37x0_gpio: Use syscon instead of MMIO region The fdt node for this driver is a simple-mfd and syscon compatible one meaning that simplemfd will be the driver attached for it. The gpio driver is attached to the 'gpio' subnode so use syscon_get_handle_default to obtain the handle of the syscon from the parent device and use this to read/write to the memory region. MFC after: 1 week Modified: head/sys/arm/mv/a37x0_gpio.c Modified: head/sys/arm/mv/a37x0_gpio.c ============================================================================== --- head/sys/arm/mv/a37x0_gpio.c Mon Aug 19 14:20:26 2019 (r351216) +++ head/sys/arm/mv/a37x0_gpio.c Mon Aug 19 14:28:54 2019 (r351217) @@ -46,21 +46,14 @@ __FBSDID("$FreeBSD$"); #include #include "gpio_if.h" +#include "syscon_if.h" -static struct resource_spec a37x0_gpio_res_spec[] = { - { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* Pinctl / GPIO */ - { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* Interrupts control */ - { -1, 0, 0 } -}; - struct a37x0_gpio_softc { - bus_space_tag_t sc_bst; - bus_space_handle_t sc_bsh; device_t sc_busdev; int sc_type; uint32_t sc_max_pins; uint32_t sc_npins; - struct resource *sc_mem_res[nitems(a37x0_gpio_res_spec) - 1]; + struct syscon *syscon; }; /* Memory regions. */ @@ -72,9 +65,9 @@ struct a37x0_gpio_softc { #define A37X0_SB_GPIO 2 #define A37X0_GPIO_WRITE(_sc, _off, _val) \ - bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off), (_val)) + SYSCON_WRITE_4((_sc)->syscon, (_off), (_val)) #define A37X0_GPIO_READ(_sc, _off) \ - bus_space_read_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off)) + SYSCON_READ_4((_sc)->syscon, (_off)) #define A37X0_GPIO_BIT(_p) (1U << ((_p) % 32)) #define A37X0_GPIO_OUT_EN(_p) (0x0 + ((_p) / 32) * 4) @@ -280,6 +273,12 @@ a37x0_gpio_attach(device_t dev) sc = device_get_softc(dev); + err = syscon_get_handle_default(dev, &sc->syscon); + if (err != 0) { + device_printf(dev, "Cannot get syscon handle from parent\n"); + return (ENXIO); + } + /* Read and verify the "gpio-ranges" property. */ ncells = OF_getencprop_alloc(ofw_bus_get_node(dev), "gpio-ranges", (void **)&ranges); @@ -295,14 +294,6 @@ a37x0_gpio_attach(device_t dev) /* Check the number of pins in the DTS vs HW capabilities. */ if (sc->sc_npins > sc->sc_max_pins) return (ENXIO); - - err = bus_alloc_resources(dev, a37x0_gpio_res_spec, sc->sc_mem_res); - if (err != 0) { - device_printf(dev, "cannot allocate memory window\n"); - return (ENXIO); - } - sc->sc_bst = rman_get_bustag(sc->sc_mem_res[A37X0_GPIO]); - sc->sc_bsh = rman_get_bushandle(sc->sc_mem_res[A37X0_GPIO]); sc->sc_busdev = gpiobus_attach_bus(dev); if (sc->sc_busdev == NULL)