pinctrl: add more pinconf/pinctrl definitions
These pinconf/pinctrl definitions will be used by the next patches. The definitions was taken from public headers of linux-7.0. It's used by several linux pinctrl drivers, so it might be helpful for U-Boot as well. Pinconf definitions are placed near the corresponding U-Boot definitions in file include/dm/pinctrl.h. Pin/group/function definitions stored within the same path as in linux (include/linux/pinctrl/pinctrl.h). Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu> Reviewed-by: David Lechner <dlechner@baylibre.com>
This commit is contained in:
committed by
Tom Rini
parent
d26cb20e6b
commit
7518f6fbc4
@@ -481,6 +481,34 @@ enum pin_config_param {
|
||||
PIN_CONFIG_MAX = 255, /* 0xFF */
|
||||
};
|
||||
|
||||
/*
|
||||
* Helpful configuration macro to be used in tables etc.
|
||||
*/
|
||||
#define PIN_CONF_PACKED(p, a) ((a << 8) | ((unsigned long) p & 0xffUL))
|
||||
|
||||
/*
|
||||
* The following inlines stuffs a configuration parameter and data value
|
||||
* into and out of an unsigned long argument, as used by the generic pin config
|
||||
* system. We put the parameter in the lower 8 bits and the argument in the
|
||||
* upper 24 bits.
|
||||
*/
|
||||
|
||||
static inline enum pin_config_param pinconf_to_config_param(unsigned long config)
|
||||
{
|
||||
return (enum pin_config_param) (config & 0xffUL);
|
||||
}
|
||||
|
||||
static inline u32 pinconf_to_config_argument(unsigned long config)
|
||||
{
|
||||
return (u32) ((config >> 8) & 0xffffffUL);
|
||||
}
|
||||
|
||||
static inline unsigned long pinconf_to_config_packed(enum pin_config_param param,
|
||||
u32 argument)
|
||||
{
|
||||
return PIN_CONF_PACKED(param, argument);
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(PINCTRL_GENERIC)
|
||||
/**
|
||||
* pinctrl_generic_set_state() - Generic set_state operation
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
|
||||
#ifndef __LINUX_PINCTRL_PINCTRL_H
|
||||
#define __LINUX_PINCTRL_PINCTRL_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/**
|
||||
* struct pingroup - provides information on pingroup
|
||||
* @name: a name for pingroup
|
||||
* @pins: an array of pins in the pingroup
|
||||
* @npins: number of pins in the pingroup
|
||||
*/
|
||||
struct pingroup {
|
||||
const char *name;
|
||||
const unsigned int *pins;
|
||||
size_t npins;
|
||||
};
|
||||
|
||||
/* Convenience macro to define a single named or anonymous pingroup */
|
||||
#define PINCTRL_PINGROUP(_name, _pins, _npins) \
|
||||
(struct pingroup) { \
|
||||
.name = _name, \
|
||||
.pins = _pins, \
|
||||
.npins = _npins, \
|
||||
}
|
||||
|
||||
/**
|
||||
* struct pinctrl_pin_desc - boards/machines provide information on their
|
||||
* pins, pads or other muxable units in this struct
|
||||
* @number: unique pin number from the global pin number space
|
||||
* @name: a name for this pin
|
||||
* @drv_data: driver-defined per-pin data. pinctrl core does not touch this
|
||||
*/
|
||||
struct pinctrl_pin_desc {
|
||||
unsigned int number;
|
||||
const char *name;
|
||||
void *drv_data;
|
||||
};
|
||||
|
||||
/* Convenience macro to define a single named or anonymous pin descriptor */
|
||||
#define PINCTRL_PIN(_number, _name) \
|
||||
(struct pinctrl_pin_desc) { \
|
||||
.number = _number, \
|
||||
.name = _name, \
|
||||
}
|
||||
|
||||
#define PINCTRL_PIN_ANON(_number) \
|
||||
(struct pinctrl_pin_desc) { \
|
||||
.number = _number, \
|
||||
}
|
||||
|
||||
/**
|
||||
* struct pinfunction - Description about a function
|
||||
* @name: Name of the function
|
||||
* @groups: An array of groups for this function
|
||||
* @ngroups: Number of groups in @groups
|
||||
* @flags: Additional pin function flags
|
||||
*/
|
||||
struct pinfunction {
|
||||
const char *name;
|
||||
const char * const *groups;
|
||||
size_t ngroups;
|
||||
};
|
||||
|
||||
/* Convenience macro to define a single named pinfunction */
|
||||
#define PINCTRL_PINFUNCTION(_name, _groups, _ngroups) \
|
||||
(struct pinfunction) { \
|
||||
.name = (_name), \
|
||||
.groups = (_groups), \
|
||||
.ngroups = (_ngroups), \
|
||||
}
|
||||
|
||||
#endif /* __LINUX_PINCTRL_PINCTRL_H */
|
||||
Reference in New Issue
Block a user