From owner-svn-src-all@freebsd.org Thu Jan 16 21:19:27 2020 Return-Path: Delivered-To: svn-src-all@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 E52051F64DD; Thu, 16 Jan 2020 21:19:27 +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 47zHBl5ltTz4c9s; Thu, 16 Jan 2020 21:19:27 +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 A6D1E25CE4; Thu, 16 Jan 2020 21:19:27 +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 00GLJRG7039364; Thu, 16 Jan 2020 21:19:27 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00GLJR56039362; Thu, 16 Jan 2020 21:19:27 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202001162119.00GLJR56039362@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Thu, 16 Jan 2020 21:19:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356806 - in head: share/man/man9 sys/dev/fdt X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: in head: share/man/man9 sys/dev/fdt X-SVN-Commit-Revision: 356806 X-SVN-Commit-Repository: base 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.29 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, 16 Jan 2020 21:19:28 -0000 Author: manu Date: Thu Jan 16 21:19:27 2020 New Revision: 356806 URL: https://svnweb.freebsd.org/changeset/base/356806 Log: fdt_pinctrl: Add new methods for gpios Most of the gpio controller cannot configure or get the configuration of the pin muxing as it's usually handled in the pinctrl driver. But they can know what is the pinmuxing driver either because they are child of it or via the gpio-range property. Add some new methods to fdt_pinctrl that a pin controller can implement. Some methods are : fdt_pinctrl_is_gpio: Use to know if the pin in the gpio mode fdt_pinctrl_set_flags: Set the flags of the pin (pullup/pulldown etc ...) fdt_pinctrl_get_flags: Get the flags of the pin (pullup/pulldown etc ...) The defaults method returns EOPNOTSUPP. Reviewed by: ian, bcr (manpages) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D23093 Modified: head/share/man/man9/fdt_pinctrl.9 head/sys/dev/fdt/fdt_pinctrl_if.m Modified: head/share/man/man9/fdt_pinctrl.9 ============================================================================== --- head/share/man/man9/fdt_pinctrl.9 Thu Jan 16 20:57:29 2020 (r356805) +++ head/share/man/man9/fdt_pinctrl.9 Thu Jan 16 21:19:27 2020 (r356806) @@ -125,6 +125,36 @@ foo_configure_pins(device_t dev, phandle_t cfgxref) } static int +foo_is_gpio(device_t dev, device_t gpiodev, bool *is_gpio) +{ + return (foo_is_pin_func_gpio(is_gpio)); +} + +static int +foo_set_flags(device_t dev, device_t gpiodev, uint32_t pin, uint32_t flags) +{ + int rv; + + rv = foo_is_pin_func_gpio(is_gpio); + if (rv != 0) + return (rv); + foo_set_flags(pin, flags); + return (0); +} + +static int +foo_get_flags(device_t dev, device_t gpiodev, uint32_t pin, uint32_t *flags) +{ + int rv; + + rv = foo_is_pin_func_gpio(is_gpio); + if (rv != 0) + return (rv); + foo_get_flags(pin, flags); + return (0); +} + +static int foo_attach(device_t dev) { ... @@ -144,6 +174,9 @@ static device_method_t foo_methods[] = { /* fdt_pinctrl interface */ DEVMETHOD(fdt_pinctrl_configure, foo_configure_pins), + DEVMETHOD(fdt_pinctrl_is_gpio, foo_is_gpio), + DEVMETHOD(fdt_pinctrl_set_flags, foo_set_flags), + DEVMETHOD(fdt_pinctrl_get_flags, foo_get_flags), /* Terminate method list */ DEVMETHOD_END Modified: head/sys/dev/fdt/fdt_pinctrl_if.m ============================================================================== --- head/sys/dev/fdt/fdt_pinctrl_if.m Thu Jan 16 20:57:29 2020 (r356805) +++ head/sys/dev/fdt/fdt_pinctrl_if.m Thu Jan 16 21:19:27 2020 (r356806) @@ -36,6 +36,31 @@ INTERFACE fdt_pinctrl; +CODE { + static int + fdt_pinctrl_default_is_gpio(device_t pinctrl, device_t gpio, bool *is_gpio) + { + + return (EOPNOTSUPP); + } + + static int + fdt_pinctrl_default_set_flags(device_t pinctrl, device_t gpio, uint32_t pin, + uint32_t flags) + { + + return (EOPNOTSUPP); + } + + static int + fdt_pinctrl_default_get_flags(device_t pinctrl, device_t gpio, uint32_t pin, + uint32_t *flags) + { + + return (EOPNOTSUPP); + } +}; + # Needed for timestamping device probe/attach calls HEADER { #include @@ -57,3 +82,36 @@ METHOD int configure { phandle_t cfgxref; }; + +# +# Test if the pin is in gpio mode +# Called from a gpio device +# +METHOD int is_gpio { + device_t pinctrl; + device_t gpio; + uint32_t pin; + bool *is_gpio; +} DEFAULT fdt_pinctrl_default_is_gpio; + +# +# Set the flags of a pin +# Called from a gpio device +# +METHOD int set_flags { + device_t pinctrl; + device_t gpio; + uint32_t pin; + uint32_t flags; +} DEFAULT fdt_pinctrl_default_set_flags; + +# +# Get the flags of a pin +# Called from a gpio device +# +METHOD int get_flags { + device_t pinctrl; + device_t gpio; + uint32_t pin; + uint32_t *flags; +} DEFAULT fdt_pinctrl_default_get_flags;