#include <linux/device.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/of.h>
#include <linux/scmi_protocol.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h>
#include "pinctrl-utils.h"
#include "core.h"
#include "pinconf.h"
#define DRV_NAME …
#define SCMI_NUM_CONFIGS …
static const struct scmi_pinctrl_proto_ops *pinctrl_ops;
struct scmi_pinctrl { … };
static int pinctrl_scmi_get_groups_count(struct pinctrl_dev *pctldev)
{ … }
static const char *pinctrl_scmi_get_group_name(struct pinctrl_dev *pctldev,
unsigned int selector)
{ … }
static int pinctrl_scmi_get_group_pins(struct pinctrl_dev *pctldev,
unsigned int selector,
const unsigned int **pins,
unsigned int *num_pins)
{ … }
static const struct pinctrl_ops pinctrl_scmi_pinctrl_ops = …;
static int pinctrl_scmi_get_functions_count(struct pinctrl_dev *pctldev)
{ … }
static const char *pinctrl_scmi_get_function_name(struct pinctrl_dev *pctldev,
unsigned int selector)
{ … }
static int pinctrl_scmi_get_function_groups(struct pinctrl_dev *pctldev,
unsigned int selector,
const char * const **p_groups,
unsigned int * const p_num_groups)
{ … }
static int pinctrl_scmi_func_set_mux(struct pinctrl_dev *pctldev,
unsigned int selector, unsigned int group)
{ … }
static int pinctrl_scmi_request(struct pinctrl_dev *pctldev,
unsigned int offset)
{ … }
static int pinctrl_scmi_free(struct pinctrl_dev *pctldev, unsigned int offset)
{ … }
static const struct pinmux_ops pinctrl_scmi_pinmux_ops = …;
static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
enum scmi_pinctrl_conf_type *type)
{ … }
static int pinctrl_scmi_pinconf_get(struct pinctrl_dev *pctldev,
unsigned int pin, unsigned long *config)
{ … }
static int
pinctrl_scmi_alloc_configs(struct pinctrl_dev *pctldev, u32 num_configs,
u32 **p_config_value,
enum scmi_pinctrl_conf_type **p_config_type)
{ … }
static void
pinctrl_scmi_free_configs(struct pinctrl_dev *pctldev, u32 num_configs,
u32 **p_config_value,
enum scmi_pinctrl_conf_type **p_config_type)
{ … }
static int pinctrl_scmi_pinconf_set(struct pinctrl_dev *pctldev,
unsigned int pin,
unsigned long *configs,
unsigned int num_configs)
{ … }
static int pinctrl_scmi_pinconf_group_set(struct pinctrl_dev *pctldev,
unsigned int group,
unsigned long *configs,
unsigned int num_configs)
{
int i, ret;
struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
enum scmi_pinctrl_conf_type config_type[SCMI_NUM_CONFIGS];
u32 config_value[SCMI_NUM_CONFIGS];
enum scmi_pinctrl_conf_type *p_config_type = config_type;
u32 *p_config_value = config_value;
enum pin_config_param param;
if (!configs || !num_configs)
return -EINVAL;
ret = pinctrl_scmi_alloc_configs(pctldev, num_configs, &p_config_type,
&p_config_value);
if (ret)
return ret;
for (i = 0; i < num_configs; i++) {
param = pinconf_to_config_param(configs[i]);
ret = pinctrl_scmi_map_pinconf_type(param, &p_config_type[i]);
if (ret) {
dev_err(pmx->dev, "Error map pinconf_type %d\n", ret);
goto free_config;
}
p_config_value[i] = pinconf_to_config_argument(configs[i]);
}
ret = pinctrl_ops->settings_conf(pmx->ph, group, GROUP_TYPE,
num_configs, p_config_type,
p_config_value);
if (ret)
dev_err(pmx->dev, "Error parsing config %d", ret);
free_config:
pinctrl_scmi_free_configs(pctldev, num_configs, &p_config_type,
&p_config_value);
return ret;
};
static int pinctrl_scmi_pinconf_group_get(struct pinctrl_dev *pctldev,
unsigned int group,
unsigned long *config)
{ … }
static const struct pinconf_ops pinctrl_scmi_pinconf_ops = …;
static int pinctrl_scmi_get_pins(struct scmi_pinctrl *pmx,
struct pinctrl_desc *desc)
{ … }
static const char * const scmi_pinctrl_blocklist[] = …;
static int scmi_pinctrl_probe(struct scmi_device *sdev)
{ … }
static const struct scmi_device_id scmi_id_table[] = …;
MODULE_DEVICE_TABLE(scmi, scmi_id_table);
static struct scmi_driver scmi_pinctrl_driver = …;
module_scmi_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;