Deleted Added
full compact
omap4_gpio.c (273262) omap4_gpio.c (283276)
1/*-
2 * Copyright (c) 2011 Ben Gray <ben.r.gray@gmail.com>.
3 * Copyright (c) 2014 Andrew Turner <andrew@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 13 unchanged lines hidden (view full) ---

22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2011 Ben Gray <ben.r.gray@gmail.com>.
3 * Copyright (c) 2014 Andrew Turner <andrew@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 13 unchanged lines hidden (view full) ---

22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/arm/ti/omap4/omap4_gpio.c 273262 2014-10-18 17:51:34Z andrew $");
30__FBSDID("$FreeBSD: head/sys/arm/ti/omap4/omap4_gpio.c 283276 2015-05-22 03:16:18Z gonzo $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/bus.h>
37#include <sys/gpio.h>
38
39#include <machine/bus.h>
40
41#include <dev/fdt/fdt_common.h>
42#include <dev/ofw/ofw_bus.h>
43#include <dev/ofw/ofw_bus_subr.h>
44
45#include <arm/ti/ti_cpuid.h>
46#include <arm/ti/ti_gpio.h>
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/bus.h>
37#include <sys/gpio.h>
38
39#include <machine/bus.h>
40
41#include <dev/fdt/fdt_common.h>
42#include <dev/ofw/ofw_bus.h>
43#include <dev/ofw/ofw_bus_subr.h>
44
45#include <arm/ti/ti_cpuid.h>
46#include <arm/ti/ti_gpio.h>
47#include <arm/ti/ti_scm.h>
47#include <arm/ti/ti_pinmux.h>
48
49#include <arm/ti/omap4/omap4_scm_padconf.h>
50
51#include "ti_gpio_if.h"
52
53static struct ofw_compat_data compat_data[] = {
54 {"ti,omap4-gpio", 1},
55 {"ti,gpio", 1},

--- 16 unchanged lines hidden (view full) ---

72
73 return (0);
74}
75
76static int
77omap4_gpio_set_flags(device_t dev, uint32_t gpio, uint32_t flags)
78{
79 unsigned int state = 0;
48
49#include <arm/ti/omap4/omap4_scm_padconf.h>
50
51#include "ti_gpio_if.h"
52
53static struct ofw_compat_data compat_data[] = {
54 {"ti,omap4-gpio", 1},
55 {"ti,gpio", 1},

--- 16 unchanged lines hidden (view full) ---

72
73 return (0);
74}
75
76static int
77omap4_gpio_set_flags(device_t dev, uint32_t gpio, uint32_t flags)
78{
79 unsigned int state = 0;
80 struct ti_gpio_softc *sc;
81
82 sc = device_get_softc(dev);
80 /* First the SCM driver needs to be told to put the pad into GPIO mode */
81 if (flags & GPIO_PIN_OUTPUT)
82 state = PADCONF_PIN_OUTPUT;
83 else if (flags & GPIO_PIN_INPUT) {
84 if (flags & GPIO_PIN_PULLUP)
85 state = PADCONF_PIN_INPUT_PULLUP;
86 else if (flags & GPIO_PIN_PULLDOWN)
87 state = PADCONF_PIN_INPUT_PULLDOWN;
88 else
89 state = PADCONF_PIN_INPUT;
90 }
83 /* First the SCM driver needs to be told to put the pad into GPIO mode */
84 if (flags & GPIO_PIN_OUTPUT)
85 state = PADCONF_PIN_OUTPUT;
86 else if (flags & GPIO_PIN_INPUT) {
87 if (flags & GPIO_PIN_PULLUP)
88 state = PADCONF_PIN_INPUT_PULLUP;
89 else if (flags & GPIO_PIN_PULLDOWN)
90 state = PADCONF_PIN_INPUT_PULLDOWN;
91 else
92 state = PADCONF_PIN_INPUT;
93 }
91 return ti_scm_padconf_set_gpiomode(gpio, state);
94 return ti_pinmux_padconf_set_gpiomode((sc->sc_bank-1)*32 + gpio, state);
92}
93
94static int
95omap4_gpio_get_flags(device_t dev, uint32_t gpio, uint32_t *flags)
96{
97 unsigned int state;
95}
96
97static int
98omap4_gpio_get_flags(device_t dev, uint32_t gpio, uint32_t *flags)
99{
100 unsigned int state;
101 struct ti_gpio_softc *sc;
98
102
103 sc = device_get_softc(dev);
104
99 /* Get the current pin state */
105 /* Get the current pin state */
100 if (ti_scm_padconf_get_gpiomode(gpio, &state) != 0) {
106 if (ti_pinmux_padconf_get_gpiomode((sc->sc_bank-1)*32 + gpio, &state) != 0) {
101 *flags = 0;
102 return (EINVAL);
103 } else {
104 switch (state) {
105 case PADCONF_PIN_OUTPUT:
106 *flags = GPIO_PIN_OUTPUT;
107 break;
108 case PADCONF_PIN_INPUT:

--- 35 unchanged lines hidden ---
107 *flags = 0;
108 return (EINVAL);
109 } else {
110 switch (state) {
111 case PADCONF_PIN_OUTPUT:
112 *flags = GPIO_PIN_OUTPUT;
113 break;
114 case PADCONF_PIN_INPUT:

--- 35 unchanged lines hidden ---