/* * Define a pin group referring to a subset of an array of pins.
*/ #define SH_PFC_PIN_GROUP_SUBSET(_name, data, first, n) { \
.name = #_name, \
.pins = data##_pins + first, \
.mux = data##_mux + first, \
.nr_pins = n + \
BUILD_BUG_ON_ZERO(first + n > ARRAY_SIZE(data##_pins)) + \
BUILD_BUG_ON_ZERO(first + n > ARRAY_SIZE(data##_mux)), \
}
/* * Define a pin group for the data pins of a resizable bus. * An optional 'suffix' argument is accepted, to be used when the same group * can appear on a different set of pins.
*/ #define BUS_DATA_PIN_GROUP(base, n, ...) \
SH_PFC_PIN_GROUP_SUBSET(base##n##__VA_ARGS__, base##__VA_ARGS__, 0, n)
/* * Describe a config register consisting of several fields of the same width * - name: Register name (unused, for documentation purposes only) * - r: Physical register address * - r_width: Width of the register (in bits) * - f_width: Width of the fixed-width register fields (in bits) * - ids: For each register field (from left to right, i.e. MSB to LSB), * 2^f_width enum IDs must be specified, one for each possible * combination of the register field bit values, all wrapped using * the GROUP() macro.
*/ #define PINMUX_CFG_REG(name, r, r_width, f_width, ids) \
.reg = r, .reg_width = r_width, \
.field_width = f_width + BUILD_BUG_ON_ZERO(r_width % f_width) + \
BUILD_BUG_ON_ZERO(sizeof((const u16 []) { ids }) / sizeof(u16) != \
(r_width / f_width) << f_width), \
.enum_ids = (const u16 [(r_width / f_width) << f_width]) { ids }
/* * Describe a config register consisting of several fields of different widths * - name: Register name (unused, for documentation purposes only) * - r: Physical register address * - r_width: Width of the register (in bits) * - f_widths: List of widths of the register fields (in bits), from left * to right (i.e. MSB to LSB), wrapped using the GROUP() macro. * Reserved fields are indicated by negating the field width. * - ids: For each non-reserved register field (from left to right, i.e. MSB * to LSB), 2^f_widths[i] enum IDs must be specified, one for each * possible combination of the register field bit values, all wrapped * using the GROUP() macro.
*/ #define PINMUX_CFG_REG_VAR(name, r, r_width, f_widths, ids) \
.reg = r, .reg_width = r_width, \
.var_field_width = (const s8 []) { f_widths, 0 }, \
SET_NR_ENUM_IDS(sizeof((const u16 []) { ids }) / sizeof(u16)) \
.enum_ids = (const u16 []) { ids }
struct pinmux_bias_reg { /* At least one of puen/pud must exist */
u32 puen; /* Pull-enable or pull-up control register */
u32 pud; /* Pull-up/down or pull-down control register */ const u16 pins[32];
};
/* * Describe a data register * - name: Register name (unused, for documentation purposes only) * - r: Physical register address * - r_width: Width of the register (in bits) * - ids: For each register bit (from left to right, i.e. MSB to LSB), one * enum ID must be specified, all wrapped using the GROUP() macro.
*/ #define PINMUX_DATA_REG(name, r, r_width, ids) \
.reg = r, .reg_width = r_width + \
BUILD_BUG_ON_ZERO(sizeof((const u16 []) { ids }) / sizeof(u16) != \
r_width), \
.enum_ids = (const u16 [r_width]) { ids }
struct pinmux_irq { constshort *gpios;
};
/* * Describe the mapping from GPIOs to a single IRQ * - ids...: List of GPIOs that are mapped to the same IRQ
*/ #define PINMUX_IRQ(ids...) { \
.gpios = (constshort []) { ids, -1 } \
}
/* ----------------------------------------------------------------------------- * Helper macros to create pin and port lists
*/
/* * sh_pfc_soc_info pinmux_data array macros
*/
/* * Describe generic pinmux data * - data_or_mark: *_DATA or *_MARK enum ID * - ids...: List of enum IDs to associate with data_or_mark
*/ #define PINMUX_DATA(data_or_mark, ids...) data_or_mark, ids, 0
/* * Describe a pinmux configuration without GPIO function that needs * configuration in a Peripheral Function Select Register (IPSR) * - ipsr: IPSR field (unused, for documentation purposes only) * - fn: Function name, referring to a field in the IPSR
*/ #define PINMUX_IPSR_NOGP(ipsr, fn) \
PINMUX_DATA(fn##_MARK, FN_##fn)
/* * Describe a pinmux configuration with GPIO function that needs configuration * in both a Peripheral Function Select Register (IPSR) and in a * GPIO/Peripheral Function Select Register (GPSR) * - ipsr: IPSR field * - fn: Function name, also referring to the IPSR field
*/ #define PINMUX_IPSR_GPSR(ipsr, fn) \
PINMUX_DATA(fn##_MARK, FN_##fn, FN_##ipsr)
/* * Describe a pinmux configuration without GPIO function that needs * configuration in a Peripheral Function Select Register (IPSR), and where the * pinmux function has a representation in a Module Select Register (MOD_SEL). * - ipsr: IPSR field (unused, for documentation purposes only) * - fn: Function name, also referring to the IPSR field * - msel: Module selector
*/ #define PINMUX_IPSR_NOGM(ipsr, fn, msel) \
PINMUX_DATA(fn##_MARK, FN_##fn, FN_##msel)
/* * Describe a pinmux configuration with GPIO function where the pinmux function * has no representation in a Peripheral Function Select Register (IPSR), but * instead solely depends on a group selection. * - gpsr: GPSR field * - fn: Function name, also referring to the GPSR field * - gsel: Group selector
*/ #define PINMUX_IPSR_NOFN(gpsr, fn, gsel) \
PINMUX_DATA(fn##_MARK, FN_##gpsr, FN_##gsel)
/* * Describe a pinmux configuration with GPIO function that needs configuration * in both a Peripheral Function Select Register (IPSR) and a GPIO/Peripheral * Function Select Register (GPSR), and where the pinmux function has a * representation in a Module Select Register (MOD_SEL). * - ipsr: IPSR field * - fn: Function name, also referring to the IPSR field * - msel: Module selector
*/ #define PINMUX_IPSR_MSEL(ipsr, fn, msel) \
PINMUX_DATA(fn##_MARK, FN_##msel, FN_##fn, FN_##ipsr)
/* * Describe a pinmux configuration similar to PINMUX_IPSR_MSEL, but with * an additional select register that controls physical multiplexing * with another pin. * - ipsr: IPSR field * - fn: Function name, also referring to the IPSR field * - psel: Physical multiplexing selector * - msel: Module selector
*/ #define PINMUX_IPSR_PHYS_MSEL(ipsr, fn, psel, msel) \
PINMUX_DATA(fn##_MARK, FN_##psel, FN_##msel, FN_##fn, FN_##ipsr)
/* * Describe a pinmux configuration in which a pin is physically multiplexed * with other pins. * - ipsr: IPSR field * - fn: Function name * - psel: Physical multiplexing selector
*/ #define PINMUX_IPSR_PHYS(ipsr, fn, psel) \
PINMUX_DATA(fn##_MARK, FN_##psel, FN_##ipsr)
/* * Describe a pinmux configuration for a single-function pin with GPIO * capability. * - fn: Function name
*/ #define PINMUX_SINGLE(fn) \
PINMUX_DATA(fn##_MARK, FN_##fn)
/* PINMUX_DATA_GP_ALL - Expand to a list of name_DATA, name_FN marks */ #define _GP_DATA(bank, pin, name, sfx, cfg) PINMUX_DATA(name##_DATA, name##_FN) #define PINMUX_DATA_GP_ALL() CPU_ALL_GP(_GP_DATA, unused)
/* * GP_ASSIGN_LAST() - Expand to an enum definition for the last GP pin * * The largest GP pin index is obtained by taking the size of a union, * containing one array per GP pin, sized by the corresponding pin index. * As the fields in the CPU_ALL_GP() macro definition are separated by commas, * while the members of a union must be terminated by semicolons, the commas * are absorbed by wrapping them inside dummy attributes.
*/ #define _GP_ENTRY(bank, pin, name, sfx, cfg) \
deprecated)); char name[(bank * 32) + pin] __attribute__((deprecated #define GP_ASSIGN_LAST() \
GP_LAST = sizeof(union { \ char dummy[0] __attribute__((deprecated, \
CPU_ALL_GP(_GP_ENTRY, unused), \
deprecated)); \
})
/* PORT_ALL(suffix) - Expand to a list of PORT_#_suffix */ #define _PORT_ALL(pn, pfx, sfx) pfx##_##sfx #define PORT_ALL(str) CPU_ALL_PORT(_PORT_ALL, PORT, str)
/* PINMUX_DATA_ALL - Expand to a list of PORT_name_DATA, PORT_name_FN0, * PORT_name_OUT, PORT_name_IN marks
*/ #define _PORT_DATA(pn, pfx, sfx) \
PINMUX_DATA(PORT##pfx##_DATA, PORT##pfx##_FN0, \
PORT##pfx##_OUT, PORT##pfx##_IN) #define PINMUX_DATA_ALL() CPU_ALL_PORT(_PORT_DATA, , unused)
/* * PORT_ASSIGN_LAST() - Expand to an enum definition for the last PORT pin * * The largest PORT pin index is obtained by taking the size of a union, * containing one array per PORT pin, sized by the corresponding pin index. * As the fields in the CPU_ALL_PORT() macro definition are separated by * commas, while the members of a union must be terminated by semicolons, the * commas are absorbed by wrapping them inside dummy attributes.
*/ #define _PORT_ENTRY(pn, pfx, sfx) \
deprecated)); char pfx[pn] __attribute__((deprecated #define PORT_ASSIGN_LAST() \
PORT_LAST = sizeof(union { \ char dummy[0] __attribute__((deprecated, \
CPU_ALL_PORT(_PORT_ENTRY, PORT, unused), \
deprecated)); \
})
/* GPIO_FN(name) - Expand to a sh_pfc_pin entry for a function GPIO */ #define PINMUX_GPIO_FN(gpio, base, data_or_mark) \
[gpio - (base)] = { \
.name = __stringify(gpio), \
.enum_id = data_or_mark, \
} #define GPIO_FN(str) \
PINMUX_GPIO_FN(GPIO_FN_##str, PINMUX_FN_BASE, str##_MARK)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.