Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / pinctrl / vt8500 / pinctrl-wmt.h
blob6233115c9b194150358e05f3532579e6ecc9358f
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Pinctrl driver for the Wondermedia SoC's
5 * Copyright (c) 2013 Tony Prisk <linux@prisktech.co.nz>
6 */
8 #include <linux/gpio/driver.h>
10 /* VT8500 has no enable register in the extgpio bank. */
11 #define NO_REG 0xFFFF
13 #define WMT_PINCTRL_BANK(__en, __dir, __dout, __din, __pen, __pcfg) \
14 { \
15 .reg_en = __en, \
16 .reg_dir = __dir, \
17 .reg_data_out = __dout, \
18 .reg_data_in = __din, \
19 .reg_pull_en = __pen, \
20 .reg_pull_cfg = __pcfg, \
23 /* Encode/decode the bank/bit pairs into a pin value */
24 #define WMT_PIN(__bank, __offset) ((__bank << 5) | __offset)
25 #define WMT_BANK_FROM_PIN(__pin) (__pin >> 5)
26 #define WMT_BIT_FROM_PIN(__pin) (__pin & 0x1f)
28 #define WMT_GROUP(__name, __data) \
29 { \
30 .name = __name, \
31 .pins = __data, \
32 .npins = ARRAY_SIZE(__data), \
35 struct wmt_pinctrl_bank_registers {
36 u32 reg_en;
37 u32 reg_dir;
38 u32 reg_data_out;
39 u32 reg_data_in;
41 u32 reg_pull_en;
42 u32 reg_pull_cfg;
45 struct wmt_pinctrl_group {
46 const char *name;
47 const unsigned int *pins;
48 const unsigned npins;
51 struct wmt_pinctrl_data {
52 struct device *dev;
53 struct pinctrl_dev *pctl_dev;
55 /* must be initialized before calling wmt_pinctrl_probe */
56 void __iomem *base;
57 const struct wmt_pinctrl_bank_registers *banks;
58 const struct pinctrl_pin_desc *pins;
59 const char * const *groups;
61 u32 nbanks;
62 u32 npins;
63 u32 ngroups;
65 struct gpio_chip gpio_chip;
66 struct pinctrl_gpio_range gpio_range;
69 int wmt_pinctrl_probe(struct platform_device *pdev,
70 struct wmt_pinctrl_data *data);