Deleted Added
full compact
ar71xx_gpio.c (228725) ar71xx_gpio.c (234515)
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 228725 2011-12-20 00:33:56Z adrian $");
34__FBSDID("$FreeBSD: head/sys/mips/atheros/ar71xx_gpio.c 234515 2012-04-20 22:44:00Z 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>

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

324}
325
326static int
327ar71xx_gpio_attach(device_t dev)
328{
329 struct ar71xx_gpio_softc *sc = device_get_softc(dev);
330 int error = 0;
331 int i, j, maxpin;
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>

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

324}
325
326static int
327ar71xx_gpio_attach(device_t dev)
328{
329 struct ar71xx_gpio_softc *sc = device_get_softc(dev);
330 int error = 0;
331 int i, j, maxpin;
332 int mask;
332 int mask, pinon;
333 int old = 0;
334
335 KASSERT((device_get_unit(dev) == 0),
336 ("ar71xx_gpio: Only one gpio module supported"));
337
338 mtx_init(&sc->gpio_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
339 MTX_DEF);
340

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

389 /* disable interrupts for all pins */
390 GPIO_WRITE(sc, AR71XX_GPIO_INT_MASK, 0);
391
392 /* Initialise all pins specified in the mask, up to the pin count */
393 (void) ar71xx_gpio_pin_max(dev, &maxpin);
394 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
395 "pinmask", &mask) != 0)
396 mask = 0;
333 int old = 0;
334
335 KASSERT((device_get_unit(dev) == 0),
336 ("ar71xx_gpio: Only one gpio module supported"));
337
338 mtx_init(&sc->gpio_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
339 MTX_DEF);
340

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

389 /* disable interrupts for all pins */
390 GPIO_WRITE(sc, AR71XX_GPIO_INT_MASK, 0);
391
392 /* Initialise all pins specified in the mask, up to the pin count */
393 (void) ar71xx_gpio_pin_max(dev, &maxpin);
394 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
395 "pinmask", &mask) != 0)
396 mask = 0;
397 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
398 "pinon", &pinon) != 0)
399 pinon = 0;
397 device_printf(dev, "gpio pinmask=0x%x\n", mask);
398 for (i = 0, j = 0; j < maxpin; j++) {
399 if ((mask & (1 << j)) == 0)
400 continue;
401 snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,
402 "pin %d", j);
403 sc->gpio_pins[i].gp_pin = j;
404 sc->gpio_pins[i].gp_caps = DEFAULT_CAPS;
405 sc->gpio_pins[i].gp_flags = 0;
406 ar71xx_gpio_pin_configure(sc, &sc->gpio_pins[i], DEFAULT_CAPS);
407 i++;
408 }
409 sc->gpio_npins = i;
400 device_printf(dev, "gpio pinmask=0x%x\n", mask);
401 for (i = 0, j = 0; j < maxpin; j++) {
402 if ((mask & (1 << j)) == 0)
403 continue;
404 snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,
405 "pin %d", j);
406 sc->gpio_pins[i].gp_pin = j;
407 sc->gpio_pins[i].gp_caps = DEFAULT_CAPS;
408 sc->gpio_pins[i].gp_flags = 0;
409 ar71xx_gpio_pin_configure(sc, &sc->gpio_pins[i], DEFAULT_CAPS);
410 i++;
411 }
412 sc->gpio_npins = i;
413 for (i = 0; i < sc->gpio_npins; i++) {
414 j = sc->gpio_pins[i].gp_pin;
415 if ((pinon & (1 << j)) != 0)
416 ar71xx_gpio_pin_set(dev, j, 1);
417 }
410 device_add_child(dev, "gpioc", device_get_unit(dev));
411 device_add_child(dev, "gpiobus", device_get_unit(dev));
412 return (bus_generic_attach(dev));
413}
414
415static int
416ar71xx_gpio_detach(device_t dev)
417{

--- 42 unchanged lines hidden ---
418 device_add_child(dev, "gpioc", device_get_unit(dev));
419 device_add_child(dev, "gpiobus", device_get_unit(dev));
420 return (bus_generic_attach(dev));
421}
422
423static int
424ar71xx_gpio_detach(device_t dev)
425{

--- 42 unchanged lines hidden ---