From owner-svn-src-all@FreeBSD.ORG Sun May 4 04:01:28 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0D2B4715; Sun, 4 May 2014 04:01:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 EBAEC1892; Sun, 4 May 2014 04:01:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4441RJI052686; Sun, 4 May 2014 04:01:27 GMT (envelope-from loos@svn.freebsd.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4441Ql3052377; Sun, 4 May 2014 04:01:26 GMT (envelope-from loos@svn.freebsd.org) Message-Id: <201405040401.s4441Ql3052377@svn.freebsd.org> From: Luiz Otavio O Souza Date: Sun, 4 May 2014 04:01:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265310 - in head/sys/dev: gpio ofw 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.17 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: Sun, 04 May 2014 04:01:28 -0000 Author: loos Date: Sun May 4 04:01:26 2014 New Revision: 265310 URL: http://svnweb.freebsd.org/changeset/base/265310 Log: Move gpiobus routines to dev/gpio. Avoid polluting ofw_bus with bus specific parts. Requested by: nwhitehorn Modified: head/sys/dev/gpio/gpio_if.m head/sys/dev/gpio/gpiobus.c head/sys/dev/gpio/gpiobusvar.h head/sys/dev/gpio/ofw_gpiobus.c head/sys/dev/ofw/ofw_bus.h head/sys/dev/ofw/ofw_bus_if.m Modified: head/sys/dev/gpio/gpio_if.m ============================================================================== --- head/sys/dev/gpio/gpio_if.m Sun May 4 03:37:39 2014 (r265309) +++ head/sys/dev/gpio/gpio_if.m Sun May 4 04:01:26 2014 (r265310) @@ -31,6 +31,32 @@ INTERFACE gpio; +CODE { + static gpio_map_gpios_t gpio_default_map_gpios; + + int + gpio_default_map_gpios(device_t bus, phandle_t dev, + phandle_t gparent, int gcells, pcell_t *gpios, uint32_t *pin, + uint32_t *flags) + { + /* Propagate up the bus hierarchy until someone handles it. */ + if (device_get_parent(bus) != NULL) + return (GPIO_MAP_GPIOS(device_get_parent(bus), dev, + gparent, gcells, gpios, pin, flags)); + + /* If that fails, then assume the FreeBSD defaults. */ + *pin = gpios[0]; + if (gcells == 2 || gcells == 3) + *flags = gpios[gcells - 1]; + + return (0); + } +}; + +HEADER { + #include +}; + # # Get total number of pins # @@ -100,3 +126,16 @@ METHOD int pin_setflags { uint32_t pin_num; uint32_t flags; }; + +# +# Allow the GPIO controller to map the gpio-specifier on its own. +# +METHOD int map_gpios { + device_t bus; + phandle_t dev; + phandle_t gparent; + int gcells; + pcell_t *gpios; + uint32_t *pin; + uint32_t *flags; +} DEFAULT gpio_default_map_gpios; Modified: head/sys/dev/gpio/gpiobus.c ============================================================================== --- head/sys/dev/gpio/gpiobus.c Sun May 4 03:37:39 2014 (r265309) +++ head/sys/dev/gpio/gpiobus.c Sun May 4 04:01:26 2014 (r265310) @@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$"); #include -#include "gpio_if.h" #include "gpiobus_if.h" static int gpiobus_parse_pins(struct gpiobus_softc *, device_t, int); Modified: head/sys/dev/gpio/gpiobusvar.h ============================================================================== --- head/sys/dev/gpio/gpiobusvar.h Sun May 4 03:37:39 2014 (r265309) +++ head/sys/dev/gpio/gpiobusvar.h Sun May 4 04:01:26 2014 (r265310) @@ -39,6 +39,8 @@ #include #endif +#include "gpio_if.h" + #define GPIOBUS_IVAR(d) (struct gpiobus_ivar *) device_get_ivars(d) #define GPIOBUS_SOFTC(d) (struct gpiobus_softc *) device_get_softc(d) #define GPIOBUS_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) @@ -72,6 +74,13 @@ struct ofw_gpiobus_devinfo { struct ofw_bus_devinfo opd_obdinfo; }; +static __inline int +gpio_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells, + pcell_t *gpios, uint32_t *pin, uint32_t *flags) +{ + return (GPIO_MAP_GPIOS(bus, dev, gparent, gcells, gpios, pin, flags)); +} + device_t ofw_gpiobus_add_fdt_child(device_t, phandle_t); #endif void gpiobus_print_pins(struct gpiobus_ivar *); Modified: head/sys/dev/gpio/ofw_gpiobus.c ============================================================================== --- head/sys/dev/gpio/ofw_gpiobus.c Sun May 4 03:37:39 2014 (r265309) +++ head/sys/dev/gpio/ofw_gpiobus.c Sun May 4 04:01:26 2014 (r265310) @@ -39,8 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "gpio_if.h" - static int ofw_gpiobus_parse_gpios(struct gpiobus_softc *, struct gpiobus_ivar *, phandle_t); static struct ofw_gpiobus_devinfo *ofw_gpiobus_setup_devinfo(device_t, @@ -180,7 +178,7 @@ ofw_gpiobus_parse_gpios(struct gpiobus_s } /* Get the GPIO pin number and flags. */ - if (ofw_bus_map_gpios(sc->sc_dev, child, gpio, cells, + if (gpio_map_gpios(sc->sc_dev, child, gpio, cells, &gpios[i + 1], &dinfo->pins[j], &dinfo->flags[j]) != 0) { ofw_gpiobus_free_ivars(dinfo); free(gpios, M_DEVBUF); Modified: head/sys/dev/ofw/ofw_bus.h ============================================================================== --- head/sys/dev/ofw/ofw_bus.h Sun May 4 03:37:39 2014 (r265309) +++ head/sys/dev/ofw/ofw_bus.h Sun May 4 04:01:26 2014 (r265310) @@ -76,12 +76,4 @@ ofw_bus_map_intr(device_t dev, phandle_t return (OFW_BUS_MAP_INTR(dev, dev, iparent, icells, intr)); } -static __inline int -ofw_bus_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells, - pcell_t *gpios, uint32_t *pin, uint32_t *flags) -{ - return (OFW_BUS_MAP_GPIOS(bus, dev, gparent, gcells, gpios, pin, - flags)); -} - #endif /* !_DEV_OFW_OFW_BUS_H_ */ Modified: head/sys/dev/ofw/ofw_bus_if.m ============================================================================== --- head/sys/dev/ofw/ofw_bus_if.m Sun May 4 03:37:39 2014 (r265309) +++ head/sys/dev/ofw/ofw_bus_if.m Sun May 4 04:01:26 2014 (r265310) @@ -58,7 +58,6 @@ CODE { static ofw_bus_get_node_t ofw_bus_default_get_node; static ofw_bus_get_type_t ofw_bus_default_get_type; static ofw_bus_map_intr_t ofw_bus_default_map_intr; - static ofw_bus_map_gpios_t ofw_bus_default_map_gpios; static const struct ofw_bus_devinfo * ofw_bus_default_get_devinfo(device_t bus, device_t dev) @@ -114,24 +113,6 @@ CODE { /* If that fails, then assume a one-domain system */ return (interrupt[0]); } - - int - ofw_bus_default_map_gpios(device_t bus, phandle_t dev, - phandle_t gparent, int gcells, pcell_t *gpios, uint32_t *pin, - uint32_t *flags) - { - /* Propagate up the bus hierarchy until someone handles it. */ - if (device_get_parent(bus) != NULL) - return OFW_BUS_MAP_GPIOS(device_get_parent(bus), dev, - gparent, gcells, gpios, pin, flags); - - /* If that fails, then assume the FreeBSD defaults. */ - *pin = gpios[0]; - if (gcells == 2 || gcells == 3) - *flags = gpios[gcells - 1]; - - return (0); - } }; # Get the ofw_bus_devinfo struct for the device dev on the bus. Used for bus @@ -188,14 +169,3 @@ METHOD int map_intr { int icells; pcell_t *interrupt; } DEFAULT ofw_bus_default_map_intr; - -# Map the GPIO controller specific gpio-specifier to GPIO pin and flags. -METHOD int map_gpios { - device_t bus; - phandle_t dev; - phandle_t gparent; - int gcells; - pcell_t *gpios; - uint32_t *pin; - uint32_t *flags; -} DEFAULT ofw_bus_default_map_gpios;