Skip to contentSkip to conversation

couple questions on driver model for gpio, and gpio in sandbox

U-Boot Robert P. J. Day 1 participant 1 message Sep 23, 2016

lore
Share & tools
lore
#0 lore raw

currently crawling through the gpio code in u-boot so, question one,
i see in include/asm-generic/gpio.h, the explicitly listed as "deprecated" old API routines:

int gpio_request(unsigned gpio, const char *label) int gpio_free(unsigned gpio)
int gpio_direction_input(unsigned gpio)
int gpio_direction_output(unsigned gpio, int value) int gpio_get_value(unsigned gpio)
int gpio_set_value(unsigned gpio, int value)

is that it? are those the entirety of the old-style gpio API that are now deprecated? as in, all else in that header file is relevant for the newer driver model?

also, i note in that same file enum and flags for the states of a
gpio:

/* State of a GPIO, as reported by get_function() */ enum gpio_func_t {
GPIOF_INPUT = 0,
GPIOF_OUTPUT,
GPIOF_UNUSED, /* Not claimed */
GPIOF_UNKNOWN, /* Not known */
GPIOF_FUNC, /* Not used as a GPIO */

GPIOF_COUNT,
};

struct udevice;

  struct gpio_desc {
        struct udevice *dev;    /* Device, NULL for invalid GPIO */
        unsigned long flags;
  #define GPIOD_REQUESTED         (1 << 0)        /* Requested/claimed */
  #define GPIOD_IS_OUT            (1 << 1)        /* GPIO is an output */
  #define GPIOD_IS_IN             (1 << 2)        /* GPIO is an input */
  #define GPIOD_ACTIVE_LOW        (1 << 3)        /* value has active low */
  #define GPIOD_IS_OUT_ACTIVE     (1 << 4)        /* set output active   */

uint offset; /* GPIO offset within the device */
/*
* We could consider adding the GPIO label in here. Possibly we could
* use this structure for internal GPIO information.
*/
};

however, i note this in drivers/gpio/sandbox.c:

  /* Flags for each GPIO */
  #define GPIOF_OUTPUT    (1 << 0)        /* Currently set as an output */
  #define GPIOF_HIGH      (1 << 1)        /* Currently set high */
  #define GPIOF_ODR       (1 << 2)        /* Currently set to open drain mode */

this looks like sandbox is (re)defining some GPIO-related flags ... is there some reason it doesn't just use the flag definitions from the earlier header file? or is that a silly question?

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================