Deleted Added
full compact
ti_gpio.c (273799) ti_gpio.c (274670)
1/*-
2 * Copyright (c) 2011
3 * Ben Gray <ben.r.gray@gmail.com>.
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:

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

35 *
36 * Beware the OMA datasheet(s) lists GPIO banks 1-6, whereas I've used 0-5 here
37 * in the code.
38 *
39 *
40 */
41
42#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2011
3 * Ben Gray <ben.r.gray@gmail.com>.
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:

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

35 *
36 * Beware the OMA datasheet(s) lists GPIO banks 1-6, whereas I've used 0-5 here
37 * in the code.
38 *
39 *
40 */
41
42#include <sys/cdefs.h>
43__FBSDID("$FreeBSD: head/sys/arm/ti/ti_gpio.c 273799 2014-10-28 18:33:59Z loos $");
43__FBSDID("$FreeBSD: head/sys/arm/ti/ti_gpio.c 274670 2014-11-18 17:22:08Z loos $");
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/bus.h>
48
49#include <sys/kernel.h>
50#include <sys/module.h>
51#include <sys/rman.h>

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

457static int
458ti_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
459{
460 struct ti_gpio_softc *sc = device_get_softc(dev);
461 uint32_t bank = (pin / PINS_PER_BANK);
462 uint32_t mask = (1UL << (pin % PINS_PER_BANK));
463 uint32_t reg_val;
464
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/bus.h>
48
49#include <sys/kernel.h>
50#include <sys/module.h>
51#include <sys/rman.h>

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

457static int
458ti_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
459{
460 struct ti_gpio_softc *sc = device_get_softc(dev);
461 uint32_t bank = (pin / PINS_PER_BANK);
462 uint32_t mask = (1UL << (pin % PINS_PER_BANK));
463 uint32_t reg_val;
464
465 /* Sanity check the flags supplied are valid, i.e. not input and output */
466 if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) == 0x0000)
467 return (EINVAL);
468 if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
469 (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
470 return (EINVAL);
471 if ((flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) ==
472 (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN))
473 return (EINVAL);
474
475 TI_GPIO_LOCK(sc);
476
477 /* Sanity check the pin number is valid */
478 if ((bank >= ti_max_gpio_banks()) || (sc->sc_mem_res[bank] == NULL)) {
479 TI_GPIO_UNLOCK(sc);
480 return (EINVAL);
481 }
482

--- 398 unchanged lines hidden ---
465 TI_GPIO_LOCK(sc);
466
467 /* Sanity check the pin number is valid */
468 if ((bank >= ti_max_gpio_banks()) || (sc->sc_mem_res[bank] == NULL)) {
469 TI_GPIO_UNLOCK(sc);
470 return (EINVAL);
471 }
472

--- 398 unchanged lines hidden ---