Deleted Added
full compact
ar71xx_gpio.c (250165) ar71xx_gpio.c (253510)
1/*-
2 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
3 * Copyright (c) 2009, Luiz Otavio O Souza.
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:

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

26 * SUCH DAMAGE.
27 */
28
29/*
30 * GPIO driver for AR71xx
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
3 * Copyright (c) 2009, Luiz Otavio O Souza.
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:

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

26 * SUCH DAMAGE.
27 */
28
29/*
30 * GPIO driver for AR71xx
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/mips/atheros/ar71xx_gpio.c 250165 2013-05-02 00:40:45Z adrian $");
34__FBSDID("$FreeBSD: head/sys/mips/atheros/ar71xx_gpio.c 253510 2013-07-21 03:55:18Z adrian $");
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/bus.h>
39
40#include <sys/kernel.h>
41#include <sys/module.h>
42#include <sys/rman.h>
43#include <sys/lock.h>
44#include <sys/mutex.h>
45#include <sys/gpio.h>
46
47#include <machine/bus.h>
48#include <machine/resource.h>
49#include <mips/atheros/ar71xxreg.h>
50#include <mips/atheros/ar71xx_setup.h>
51#include <mips/atheros/ar71xx_gpiovar.h>
52#include <mips/atheros/ar933xreg.h>
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/bus.h>
39
40#include <sys/kernel.h>
41#include <sys/module.h>
42#include <sys/rman.h>
43#include <sys/lock.h>
44#include <sys/mutex.h>
45#include <sys/gpio.h>
46
47#include <machine/bus.h>
48#include <machine/resource.h>
49#include <mips/atheros/ar71xxreg.h>
50#include <mips/atheros/ar71xx_setup.h>
51#include <mips/atheros/ar71xx_gpiovar.h>
52#include <mips/atheros/ar933xreg.h>
53#include <mips/atheros/ar934xreg.h>
53
54#include "gpio_if.h"
55
56#define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)
57
58/*
59 * Helpers
60 */

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

85static int ar71xx_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags);
86static int ar71xx_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value);
87static int ar71xx_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val);
88static int ar71xx_gpio_pin_toggle(device_t dev, uint32_t pin);
89
90static void
91ar71xx_gpio_function_enable(struct ar71xx_gpio_softc *sc, uint32_t mask)
92{
54
55#include "gpio_if.h"
56
57#define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)
58
59/*
60 * Helpers
61 */

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

86static int ar71xx_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags);
87static int ar71xx_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value);
88static int ar71xx_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val);
89static int ar71xx_gpio_pin_toggle(device_t dev, uint32_t pin);
90
91static void
92ar71xx_gpio_function_enable(struct ar71xx_gpio_softc *sc, uint32_t mask)
93{
93 GPIO_SET_BITS(sc, AR71XX_GPIO_FUNCTION, mask);
94 if (ar71xx_soc == AR71XX_SOC_AR9341 ||
95 ar71xx_soc == AR71XX_SOC_AR9342 ||
96 ar71xx_soc == AR71XX_SOC_AR9344)
97 GPIO_SET_BITS(sc, AR934X_GPIO_REG_FUNC, mask);
98 else
99 GPIO_SET_BITS(sc, AR71XX_GPIO_FUNCTION, mask);
94}
95
96static void
97ar71xx_gpio_function_disable(struct ar71xx_gpio_softc *sc, uint32_t mask)
98{
100}
101
102static void
103ar71xx_gpio_function_disable(struct ar71xx_gpio_softc *sc, uint32_t mask)
104{
99 GPIO_CLEAR_BITS(sc, AR71XX_GPIO_FUNCTION, mask);
105 if (ar71xx_soc == AR71XX_SOC_AR9341 ||
106 ar71xx_soc == AR71XX_SOC_AR9342 ||
107 ar71xx_soc == AR71XX_SOC_AR9344)
108 GPIO_CLEAR_BITS(sc, AR934X_GPIO_REG_FUNC, mask);
109 else
110 GPIO_CLEAR_BITS(sc, AR71XX_GPIO_FUNCTION, mask);
100}
101
102static void
103ar71xx_gpio_pin_configure(struct ar71xx_gpio_softc *sc, struct gpio_pin *pin,
104 unsigned int flags)
105{
106 uint32_t mask;
107

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

136 case AR71XX_SOC_AR7241:
137 case AR71XX_SOC_AR7242:
138 *maxpin = AR724X_GPIO_PINS - 1;
139 break;
140 case AR71XX_SOC_AR9330:
141 case AR71XX_SOC_AR9331:
142 *maxpin = AR933X_GPIO_COUNT - 1;
143 break;
111}
112
113static void
114ar71xx_gpio_pin_configure(struct ar71xx_gpio_softc *sc, struct gpio_pin *pin,
115 unsigned int flags)
116{
117 uint32_t mask;
118

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

147 case AR71XX_SOC_AR7241:
148 case AR71XX_SOC_AR7242:
149 *maxpin = AR724X_GPIO_PINS - 1;
150 break;
151 case AR71XX_SOC_AR9330:
152 case AR71XX_SOC_AR9331:
153 *maxpin = AR933X_GPIO_COUNT - 1;
154 break;
155 case AR71XX_SOC_AR9341:
156 case AR71XX_SOC_AR9342:
157 case AR71XX_SOC_AR9344:
158 *maxpin = AR934X_GPIO_COUNT - 1;
144 default:
145 *maxpin = AR71XX_GPIO_PINS - 1;
146 }
147 return (0);
148}
149
150static int
151ar71xx_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps)

--- 320 unchanged lines hidden ---
159 default:
160 *maxpin = AR71XX_GPIO_PINS - 1;
161 }
162 return (0);
163}
164
165static int
166ar71xx_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps)

--- 320 unchanged lines hidden ---