2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2016-08-16 09:49:49 +00:00
|
|
|
/*
|
|
|
|
* (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;
|
2018-10-05 07:35:26 +00:00
|
|
|
const void *data;
|
2016-08-16 09:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
2017-07-09 22:30:04 +00:00
|
|
|
struct meson_bank *banks;
|
2016-08-16 09:49:49 +00:00
|
|
|
unsigned int pin_base;
|
|
|
|
unsigned int num_pins;
|
|
|
|
unsigned int num_groups;
|
|
|
|
unsigned int num_funcs;
|
2017-07-09 22:30:04 +00:00
|
|
|
unsigned int num_banks;
|
2018-10-05 07:35:26 +00:00
|
|
|
const struct driver *gpio_driver;
|
|
|
|
void *pmx_data;
|
2016-08-16 09:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct meson_pinctrl {
|
|
|
|
struct meson_pinctrl_data *data;
|
|
|
|
void __iomem *reg_mux;
|
2017-07-09 22:30:04 +00:00
|
|
|
void __iomem *reg_gpio;
|
2019-01-04 14:44:34 +00:00
|
|
|
void __iomem *reg_pull;
|
|
|
|
void __iomem *reg_pullen;
|
2017-07-09 22:30:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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];
|
2016-08-16 09:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define PIN(x, b) (b + x)
|
|
|
|
|
|
|
|
#define FUNCTION(fn) \
|
|
|
|
{ \
|
|
|
|
.name = #fn, \
|
|
|
|
.groups = fn ## _groups, \
|
|
|
|
.num_groups = ARRAY_SIZE(fn ## _groups), \
|
|
|
|
}
|
|
|
|
|
2017-07-09 22:30:04 +00:00
|
|
|
#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 }, \
|
|
|
|
}, \
|
|
|
|
}
|
|
|
|
|
2016-08-16 09:49:49 +00:00
|
|
|
#define MESON_PIN(x, b) PINCTRL_PIN(PIN(x, b), #x)
|
|
|
|
|
|
|
|
extern const struct pinctrl_ops meson_pinctrl_ops;
|
|
|
|
|
2018-10-05 07:35:26 +00:00
|
|
|
int meson_pinctrl_get_groups_count(struct udevice *dev);
|
|
|
|
const char *meson_pinctrl_get_group_name(struct udevice *dev,
|
|
|
|
unsigned int selector);
|
|
|
|
int meson_pinmux_get_functions_count(struct udevice *dev);
|
|
|
|
const char *meson_pinmux_get_function_name(struct udevice *dev,
|
|
|
|
unsigned int selector);
|
2016-08-16 09:49:49 +00:00
|
|
|
int meson_pinctrl_probe(struct udevice *dev);
|
|
|
|
|
2018-10-05 07:35:26 +00:00
|
|
|
int meson_gpio_get(struct udevice *dev, unsigned int offset);
|
|
|
|
int meson_gpio_set(struct udevice *dev, unsigned int offset, int value);
|
|
|
|
int meson_gpio_get_direction(struct udevice *dev, unsigned int offset);
|
|
|
|
int meson_gpio_direction_input(struct udevice *dev, unsigned int offset);
|
|
|
|
int meson_gpio_direction_output(struct udevice *dev, unsigned int offset,
|
|
|
|
int value);
|
|
|
|
int meson_gpio_probe(struct udevice *dev);
|
|
|
|
|
2019-01-04 14:44:34 +00:00
|
|
|
int meson_pinconf_set(struct udevice *dev, unsigned int pin,
|
|
|
|
unsigned int param, unsigned int arg);
|
|
|
|
int meson_pinconf_group_set(struct udevice *dev,
|
|
|
|
unsigned int group_selector,
|
|
|
|
unsigned int param, unsigned int arg);
|
|
|
|
|
2016-08-16 09:49:49 +00:00
|
|
|
#endif /* __PINCTRL_MESON_H__ */
|