Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161522209
D32587.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D32587.diff
View Options
Index: sys/dev/gpio/qoriq_gpio.h
===================================================================
--- /dev/null
+++ sys/dev/gpio/qoriq_gpio.h
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2020 Alstom Group.
+ * Copyright (c) 2020 Semihalf.
+ * Copyright (c) 2015 Justin Hibbits
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#define MAXPIN (31)
+
+#define BIT(x) (1 << (x))
+
+#define VALID_PIN(u) ((u) >= 0 && (u) <= MAXPIN)
+#define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | \
+ GPIO_PIN_OPENDRAIN | GPIO_PIN_PUSHPULL)
+
+#define GPIO_LOCK(sc) mtx_lock_spin(&(sc)->sc_mtx)
+#define GPIO_UNLOCK(sc) mtx_unlock_spin(&(sc)->sc_mtx)
+#define GPIO_LOCK_INIT(sc) \
+ mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->dev), \
+ "gpio", MTX_SPIN)
+#define GPIO_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx);
+
+#define GPIO_GPDIR 0x0
+#define GPIO_GPODR 0x4
+#define GPIO_GPDAT 0x8
+#define GPIO_GPIER 0xc
+#define GPIO_GPIMR 0x10
+#define GPIO_GPICR 0x14
+#define GPIO_GPIBE 0x18
+
+struct qoriq_gpio_softc {
+ device_t dev;
+ device_t busdev;
+ struct mtx sc_mtx;
+ struct resource *sc_mem;
+ struct gpio_pin sc_pins[MAXPIN + 1];
+};
+
+device_attach_t qoriq_gpio_attach;
+device_detach_t qoriq_gpio_detach;
+
+DECLARE_CLASS(qoriq_gpio_driver);
Index: sys/dev/gpio/qoriq_gpio.c
===================================================================
--- sys/dev/gpio/qoriq_gpio.c
+++ sys/dev/gpio/qoriq_gpio.c
@@ -46,40 +46,12 @@
#include <machine/stdarg.h>
#include <dev/gpio/gpiobusvar.h>
+#include <dev/gpio/qoriq_gpio.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include "gpio_if.h"
-#define MAXPIN (31)
-
-#define VALID_PIN(u) ((u) >= 0 && (u) <= MAXPIN)
-#define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | \
- GPIO_PIN_OPENDRAIN | GPIO_PIN_PUSHPULL)
-
-#define GPIO_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
-#define GPIO_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
-#define GPIO_LOCK_INIT(sc) \
- mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->dev), \
- "gpio", MTX_DEF)
-#define GPIO_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx);
-
-#define GPIO_GPDIR 0x0
-#define GPIO_GPODR 0x4
-#define GPIO_GPDAT 0x8
-#define GPIO_GPIER 0xc
-#define GPIO_GPIMR 0x10
-#define GPIO_GPICR 0x14
-#define GPIO_GPIBE 0x18
-
-struct qoriq_gpio_softc {
- device_t dev;
- device_t busdev;
- struct mtx sc_mtx;
- struct resource *sc_mem; /* Memory resource */
- struct gpio_pin sc_pins[MAXPIN + 1];
-};
-
static device_t
qoriq_gpio_get_bus(device_t dev)
{
@@ -379,9 +351,7 @@
return (err);
}
-static int qoriq_gpio_detach(device_t dev);
-
-static int
+int
qoriq_gpio_attach(device_t dev)
{
struct qoriq_gpio_softc *sc = device_get_softc(dev);
@@ -422,7 +392,7 @@
return (0);
}
-static int
+int
qoriq_gpio_detach(device_t dev)
{
struct qoriq_gpio_softc *sc = device_get_softc(dev);
@@ -464,13 +434,11 @@
DEVMETHOD_END
};
-static driver_t qoriq_gpio_driver = {
- "gpio",
- qoriq_gpio_methods,
- sizeof(struct qoriq_gpio_softc),
-};
static devclass_t qoriq_gpio_devclass;
+DEFINE_CLASS_0(gpio, qoriq_gpio_driver, qoriq_gpio_methods,
+ sizeof(struct qoriq_gpio_softc));
+
EARLY_DRIVER_MODULE(qoriq_gpio, simplebus, qoriq_gpio_driver,
qoriq_gpio_devclass, NULL, NULL,
BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jul 5, 12:43 PM (1 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34710079
Default Alt Text
D32587.diff (4 KB)
Attached To
Mode
D32587: qoriq_gpio: Add support for driver inheritance
Attached
Detach File
Event Timeline
Log In to Comment