mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-26 04:53:42 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
136 lines
2.8 KiB
C
136 lines
2.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* (C) Copyright 2016 - Beniamino Galvani <b.galvani@gmail.com>
|
|
*/
|
|
|
|
#ifndef __PINCTRL_MESON_H__
|
|
#define __PINCTRL_MESON_H__
|
|
|
|
#include <linux/types.h>
|
|
|
|
struct meson_pmx_group {
|
|
const char *name;
|
|
const unsigned int *pins;
|
|
unsigned int num_pins;
|
|
bool is_gpio;
|
|
unsigned int reg;
|
|
unsigned int bit;
|
|
};
|
|
|
|
struct meson_pmx_func {
|
|
const char *name;
|
|
const char * const *groups;
|
|
unsigned int num_groups;
|
|
};
|
|
|
|
struct meson_pinctrl_data {
|
|
const char *name;
|
|
struct meson_pmx_group *groups;
|
|
struct meson_pmx_func *funcs;
|
|
struct meson_bank *banks;
|
|
unsigned int pin_base;
|
|
unsigned int num_pins;
|
|
unsigned int num_groups;
|
|
unsigned int num_funcs;
|
|
unsigned int num_banks;
|
|
};
|
|
|
|
struct meson_pinctrl {
|
|
struct meson_pinctrl_data *data;
|
|
void __iomem *reg_mux;
|
|
void __iomem *reg_gpio;
|
|
};
|
|
|
|
/**
|
|
* struct meson_reg_desc - a register descriptor
|
|
*
|
|
* @reg: register offset in the regmap
|
|
* @bit: bit index in register
|
|
*
|
|
* The structure describes the information needed to control pull,
|
|
* pull-enable, direction, etc. for a single pin
|
|
*/
|
|
struct meson_reg_desc {
|
|
unsigned int reg;
|
|
unsigned int bit;
|
|
};
|
|
|
|
/**
|
|
* enum meson_reg_type - type of registers encoded in @meson_reg_desc
|
|
*/
|
|
enum meson_reg_type {
|
|
REG_PULLEN,
|
|
REG_PULL,
|
|
REG_DIR,
|
|
REG_OUT,
|
|
REG_IN,
|
|
NUM_REG,
|
|
};
|
|
|
|
/**
|
|
* struct meson bank
|
|
*
|
|
* @name: bank name
|
|
* @first: first pin of the bank
|
|
* @last: last pin of the bank
|
|
* @regs: array of register descriptors
|
|
*
|
|
* A bank represents a set of pins controlled by a contiguous set of
|
|
* bits in the domain registers. The structure specifies which bits in
|
|
* the regmap control the different functionalities. Each member of
|
|
* the @regs array refers to the first pin of the bank.
|
|
*/
|
|
struct meson_bank {
|
|
const char *name;
|
|
unsigned int first;
|
|
unsigned int last;
|
|
struct meson_reg_desc regs[NUM_REG];
|
|
};
|
|
|
|
#define PIN(x, b) (b + x)
|
|
|
|
#define GROUP(grp, r, b) \
|
|
{ \
|
|
.name = #grp, \
|
|
.pins = grp ## _pins, \
|
|
.num_pins = ARRAY_SIZE(grp ## _pins), \
|
|
.reg = r, \
|
|
.bit = b, \
|
|
}
|
|
|
|
#define GPIO_GROUP(gpio, b) \
|
|
{ \
|
|
.name = #gpio, \
|
|
.pins = (const unsigned int[]){ PIN(gpio, b) }, \
|
|
.num_pins = 1, \
|
|
.is_gpio = true, \
|
|
}
|
|
|
|
#define FUNCTION(fn) \
|
|
{ \
|
|
.name = #fn, \
|
|
.groups = fn ## _groups, \
|
|
.num_groups = ARRAY_SIZE(fn ## _groups), \
|
|
}
|
|
|
|
#define BANK(n, f, l, per, peb, pr, pb, dr, db, or, ob, ir, ib) \
|
|
{ \
|
|
.name = n, \
|
|
.first = f, \
|
|
.last = l, \
|
|
.regs = { \
|
|
[REG_PULLEN] = { per, peb }, \
|
|
[REG_PULL] = { pr, pb }, \
|
|
[REG_DIR] = { dr, db }, \
|
|
[REG_OUT] = { or, ob }, \
|
|
[REG_IN] = { ir, ib }, \
|
|
}, \
|
|
}
|
|
|
|
#define MESON_PIN(x, b) PINCTRL_PIN(PIN(x, b), #x)
|
|
|
|
extern const struct pinctrl_ops meson_pinctrl_ops;
|
|
|
|
int meson_pinctrl_probe(struct udevice *dev);
|
|
|
|
#endif /* __PINCTRL_MESON_H__ */
|