Deleted Added
full compact
lpc_gpio.c (273799) lpc_gpio.c (277996)
1/*-
2 * Copyright (c) 2011 Jakub Wojciech Klama <jceel@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

45 * [52..64] -> P2.0..P2.12 (port 2)
46 * [65..88] -> P1.0..P1.23 (port 1)
47 * [89..96] -> P0.0..P0.7 (port 0)
48 *
49 */
50
51
52#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2011 Jakub Wojciech Klama <jceel@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

45 * [52..64] -> P2.0..P2.12 (port 2)
46 * [65..88] -> P1.0..P1.23 (port 1)
47 * [89..96] -> P0.0..P0.7 (port 0)
48 *
49 */
50
51
52#include <sys/cdefs.h>
53__FBSDID("$FreeBSD: head/sys/arm/lpc/lpc_gpio.c 273799 2014-10-28 18:33:59Z loos $");
53__FBSDID("$FreeBSD: head/sys/arm/lpc/lpc_gpio.c 277996 2015-01-31 19:32:14Z loos $");
54
55#include <sys/param.h>
56#include <sys/systm.h>
57#include <sys/bio.h>
58#include <sys/bus.h>
59#include <sys/conf.h>
60#include <sys/endian.h>
61#include <sys/kernel.h>

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

74
75#include <machine/bus.h>
76#include <machine/cpu.h>
77#include <machine/cpufunc.h>
78#include <machine/resource.h>
79#include <machine/intr.h>
80#include <machine/fdt.h>
81
54
55#include <sys/param.h>
56#include <sys/systm.h>
57#include <sys/bio.h>
58#include <sys/bus.h>
59#include <sys/conf.h>
60#include <sys/endian.h>
61#include <sys/kernel.h>

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

74
75#include <machine/bus.h>
76#include <machine/cpu.h>
77#include <machine/cpufunc.h>
78#include <machine/resource.h>
79#include <machine/intr.h>
80#include <machine/fdt.h>
81
82#include <dev/gpio/gpiobusvar.h>
82#include <dev/ofw/ofw_bus.h>
83#include <dev/ofw/ofw_bus_subr.h>
84
85#include <arm/lpc/lpcreg.h>
86#include <arm/lpc/lpcvar.h>
87
88#include "gpio_if.h"
89
90struct lpc_gpio_softc
91{
92 device_t lg_dev;
83#include <dev/ofw/ofw_bus.h>
84#include <dev/ofw/ofw_bus_subr.h>
85
86#include <arm/lpc/lpcreg.h>
87#include <arm/lpc/lpcvar.h>
88
89#include "gpio_if.h"
90
91struct lpc_gpio_softc
92{
93 device_t lg_dev;
94 device_t lg_busdev;
93 struct resource * lg_res;
94 bus_space_tag_t lg_bst;
95 bus_space_handle_t lg_bsh;
96};
97
98struct lpc_gpio_pinmap
99{
100 int lp_start_idx;

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

130
131#define LPC_GPIO_PIN_BIT(_map, _idx) \
132 (_map->lp_start_bit + LPC_GPIO_PIN_IDX(_map, _idx))
133
134static int lpc_gpio_probe(device_t);
135static int lpc_gpio_attach(device_t);
136static int lpc_gpio_detach(device_t);
137
95 struct resource * lg_res;
96 bus_space_tag_t lg_bst;
97 bus_space_handle_t lg_bsh;
98};
99
100struct lpc_gpio_pinmap
101{
102 int lp_start_idx;

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

132
133#define LPC_GPIO_PIN_BIT(_map, _idx) \
134 (_map->lp_start_bit + LPC_GPIO_PIN_IDX(_map, _idx))
135
136static int lpc_gpio_probe(device_t);
137static int lpc_gpio_attach(device_t);
138static int lpc_gpio_detach(device_t);
139
140static device_t lpc_gpio_get_bus(device_t);
138static int lpc_gpio_pin_max(device_t, int *);
139static int lpc_gpio_pin_getcaps(device_t, uint32_t, uint32_t *);
140static int lpc_gpio_pin_getflags(device_t, uint32_t, uint32_t *);
141static int lpc_gpio_pin_setflags(device_t, uint32_t, uint32_t);
142static int lpc_gpio_pin_getname(device_t, uint32_t, char *);
143static int lpc_gpio_pin_get(device_t, uint32_t, uint32_t *);
144static int lpc_gpio_pin_set(device_t, uint32_t, uint32_t);
145static int lpc_gpio_pin_toggle(device_t, uint32_t);

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

187 return (ENXIO);
188 }
189
190 sc->lg_bst = rman_get_bustag(sc->lg_res);
191 sc->lg_bsh = rman_get_bushandle(sc->lg_res);
192
193 lpc_gpio_sc = sc;
194
141static int lpc_gpio_pin_max(device_t, int *);
142static int lpc_gpio_pin_getcaps(device_t, uint32_t, uint32_t *);
143static int lpc_gpio_pin_getflags(device_t, uint32_t, uint32_t *);
144static int lpc_gpio_pin_setflags(device_t, uint32_t, uint32_t);
145static int lpc_gpio_pin_getname(device_t, uint32_t, char *);
146static int lpc_gpio_pin_get(device_t, uint32_t, uint32_t *);
147static int lpc_gpio_pin_set(device_t, uint32_t, uint32_t);
148static int lpc_gpio_pin_toggle(device_t, uint32_t);

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

190 return (ENXIO);
191 }
192
193 sc->lg_bst = rman_get_bustag(sc->lg_res);
194 sc->lg_bsh = rman_get_bushandle(sc->lg_res);
195
196 lpc_gpio_sc = sc;
197
195 device_add_child(dev, "gpioc", -1);
196 device_add_child(dev, "gpiobus", -1);
198 sc->lg_busdev = gpiobus_attach_bus(dev);
199 if (sc->lg_busdev == NULL) {
200 bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->lg_res);
201 return (ENXIO);
202 }
197
203
198 return (bus_generic_attach(dev));
204 return (0);
199}
200
201static int
202lpc_gpio_detach(device_t dev)
203{
204 return (EBUSY);
205}
206
205}
206
207static int
208lpc_gpio_detach(device_t dev)
209{
210 return (EBUSY);
211}
212
213static device_t
214lpc_gpio_get_bus(device_t dev)
215{
216 struct lpc_gpio_softc *sc;
217
218 sc = device_get_softc(dev);
219
220 return (sc->lg_busdev);
221}
222
207static int
208lpc_gpio_pin_max(device_t dev, int *npins)
209{
210 *npins = LPC_GPIO_NPINS - 1;
211 return (0);
212}
213
214static int

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

522
523static device_method_t lpc_gpio_methods[] = {
524 /* Device interface */
525 DEVMETHOD(device_probe, lpc_gpio_probe),
526 DEVMETHOD(device_attach, lpc_gpio_attach),
527 DEVMETHOD(device_detach, lpc_gpio_detach),
528
529 /* GPIO interface */
223static int
224lpc_gpio_pin_max(device_t dev, int *npins)
225{
226 *npins = LPC_GPIO_NPINS - 1;
227 return (0);
228}
229
230static int

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

538
539static device_method_t lpc_gpio_methods[] = {
540 /* Device interface */
541 DEVMETHOD(device_probe, lpc_gpio_probe),
542 DEVMETHOD(device_attach, lpc_gpio_attach),
543 DEVMETHOD(device_detach, lpc_gpio_detach),
544
545 /* GPIO interface */
546 DEVMETHOD(gpio_get_bus, lpc_gpio_get_bus),
530 DEVMETHOD(gpio_pin_max, lpc_gpio_pin_max),
531 DEVMETHOD(gpio_pin_getcaps, lpc_gpio_pin_getcaps),
532 DEVMETHOD(gpio_pin_getflags, lpc_gpio_pin_getflags),
533 DEVMETHOD(gpio_pin_setflags, lpc_gpio_pin_setflags),
534 DEVMETHOD(gpio_pin_getname, lpc_gpio_pin_getname),
535 DEVMETHOD(gpio_pin_set, lpc_gpio_pin_set),
536 DEVMETHOD(gpio_pin_get, lpc_gpio_pin_get),
537 DEVMETHOD(gpio_pin_toggle, lpc_gpio_pin_toggle),

--- 19 unchanged lines hidden ---
547 DEVMETHOD(gpio_pin_max, lpc_gpio_pin_max),
548 DEVMETHOD(gpio_pin_getcaps, lpc_gpio_pin_getcaps),
549 DEVMETHOD(gpio_pin_getflags, lpc_gpio_pin_getflags),
550 DEVMETHOD(gpio_pin_setflags, lpc_gpio_pin_setflags),
551 DEVMETHOD(gpio_pin_getname, lpc_gpio_pin_getname),
552 DEVMETHOD(gpio_pin_set, lpc_gpio_pin_set),
553 DEVMETHOD(gpio_pin_get, lpc_gpio_pin_get),
554 DEVMETHOD(gpio_pin_toggle, lpc_gpio_pin_toggle),

--- 19 unchanged lines hidden ---