2019-05-27 14:55:01 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2016-08-30 15:54:24 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 IBM Corp.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PINCTRL_ASPEED
|
|
|
|
#define PINCTRL_ASPEED
|
|
|
|
|
|
|
|
#include <linux/pinctrl/pinctrl.h>
|
|
|
|
#include <linux/pinctrl/pinmux.h>
|
|
|
|
#include <linux/pinctrl/pinconf.h>
|
|
|
|
#include <linux/pinctrl/pinconf-generic.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
|
2019-07-09 19:41:53 +08:00
|
|
|
#include "pinmux-aspeed.h"
|
2016-08-30 15:54:24 +08:00
|
|
|
|
2017-04-07 20:57:11 +08:00
|
|
|
/**
|
|
|
|
* @param The pinconf parameter type
|
|
|
|
* @pins The pin range this config struct covers, [low, high]
|
|
|
|
* @reg The register housing the configuration bits
|
|
|
|
* @mask The mask to select the bits of interest in @reg
|
|
|
|
*/
|
|
|
|
struct aspeed_pin_config {
|
|
|
|
enum pin_config_param param;
|
|
|
|
unsigned int pins[2];
|
|
|
|
unsigned int reg;
|
|
|
|
u8 bit;
|
|
|
|
u8 value;
|
|
|
|
};
|
|
|
|
|
2016-08-30 15:54:24 +08:00
|
|
|
#define ASPEED_PINCTRL_PIN(name_) \
|
|
|
|
[name_] = { \
|
|
|
|
.number = name_, \
|
|
|
|
.name = #name_, \
|
|
|
|
.drv_data = (void *) &(PIN_SYM(name_)) \
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:14:29 +08:00
|
|
|
#define ASPEED_SB_PINCONF(param_, pin0_, pin1_, reg_, bit_) { \
|
|
|
|
.param = param_, \
|
|
|
|
.pins = {pin0_, pin1_}, \
|
|
|
|
.reg = reg_, \
|
|
|
|
.bit = bit_ \
|
|
|
|
}
|
|
|
|
|
2019-06-28 10:38:37 +08:00
|
|
|
struct aspeed_pinctrl_data {
|
|
|
|
struct regmap *scu;
|
|
|
|
|
|
|
|
const struct pinctrl_pin_desc *pins;
|
2016-08-30 15:54:24 +08:00
|
|
|
const unsigned int npins;
|
|
|
|
|
2019-06-28 10:38:37 +08:00
|
|
|
const struct aspeed_pin_config *configs;
|
|
|
|
const unsigned int nconfigs;
|
2016-08-30 15:54:24 +08:00
|
|
|
|
2019-06-28 10:38:37 +08:00
|
|
|
struct aspeed_pinmux_data pinmux;
|
2016-08-30 15:54:24 +08:00
|
|
|
};
|
|
|
|
|
2019-06-28 10:38:37 +08:00
|
|
|
/* Aspeed pinctrl helpers */
|
2016-08-30 15:54:24 +08:00
|
|
|
int aspeed_pinctrl_get_groups_count(struct pinctrl_dev *pctldev);
|
|
|
|
const char *aspeed_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned int group);
|
|
|
|
int aspeed_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned int group, const unsigned int **pins,
|
|
|
|
unsigned int *npins);
|
|
|
|
void aspeed_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev,
|
|
|
|
struct seq_file *s, unsigned int offset);
|
|
|
|
int aspeed_pinmux_get_fn_count(struct pinctrl_dev *pctldev);
|
|
|
|
const char *aspeed_pinmux_get_fn_name(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned int function);
|
|
|
|
int aspeed_pinmux_get_fn_groups(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned int function, const char * const **groups,
|
|
|
|
unsigned int * const num_groups);
|
|
|
|
int aspeed_pinmux_set_mux(struct pinctrl_dev *pctldev, unsigned int function,
|
|
|
|
unsigned int group);
|
|
|
|
int aspeed_gpio_request_enable(struct pinctrl_dev *pctldev,
|
|
|
|
struct pinctrl_gpio_range *range,
|
|
|
|
unsigned int offset);
|
|
|
|
int aspeed_pinctrl_probe(struct platform_device *pdev,
|
|
|
|
struct pinctrl_desc *pdesc,
|
|
|
|
struct aspeed_pinctrl_data *pdata);
|
2017-04-07 20:57:11 +08:00
|
|
|
int aspeed_pin_config_get(struct pinctrl_dev *pctldev, unsigned int offset,
|
|
|
|
unsigned long *config);
|
|
|
|
int aspeed_pin_config_set(struct pinctrl_dev *pctldev, unsigned int offset,
|
|
|
|
unsigned long *configs, unsigned int num_configs);
|
|
|
|
int aspeed_pin_config_group_get(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned int selector,
|
|
|
|
unsigned long *config);
|
|
|
|
int aspeed_pin_config_group_set(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned int selector,
|
|
|
|
unsigned long *configs,
|
|
|
|
unsigned int num_configs);
|
2016-08-30 15:54:24 +08:00
|
|
|
|
|
|
|
#endif /* PINCTRL_ASPEED */
|