summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/starfive/pinctrl-starfive.h
blob: 7d2828f653414d96e75c484cbe08b03f905c3d80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Pinctrl / GPIO driver for StarFive SoC
 *
 * Copyright (C) 2022-2023 StarFive Technology Co., Ltd.
 *   Author: Lee Kuan Lim <kuanlim.lee@starfivetech.com>
 *   Author: Jianlong Huang <jianlong.huang@starfivetech.com>
 */


#define STARFIVE_PINCTRL(a, b) { .number = a, .name = b }

extern const struct pinctrl_ops starfive_pinctrl_ops;

struct starfive_pinctrl_pin {
	unsigned int number;
	const char *name;
};

struct starfive_pinctrl_soc_info {
	/* pinctrl */
	int (*set_one_pinmux)(struct udevice *dev, unsigned int pin,
			unsigned int din, u32 dout, u32 doen, u32 func);
	int (*get_padcfg_base)(struct udevice *dev,
			unsigned int pin);

	/* gpio dout/doen/din/gpioinput register */
	unsigned int dout_reg_base;
	unsigned int dout_mask;
	unsigned int doen_reg_base;
	unsigned int doen_mask;
	unsigned int gpi_reg_base;
	unsigned int gpi_mask;
	unsigned int gpioin_reg_base;

	/* gpio */
	const char *gpio_bank_name;
	int ngpios;
	void (*gpio_init_hw)(struct udevice *dev);
};

/*
 * struct starfive_pinctrl_priv - private data for Starfive pinctrl driver
 *
 * @padctl_base: base address of the pinctrl device
 * @info: SoC specific data & function
 */
struct starfive_pinctrl_priv {
	void __iomem *base;
	struct starfive_pinctrl_soc_info *info;
};

void starfive_set_gpiomux(struct udevice *dev, unsigned int pin,
		unsigned int din, u32 dout, u32 doen);
int starfive_pinctrl_probe(struct udevice *dev,
		const struct starfive_pinctrl_soc_info *info);