1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Pinctrl driver for the Wondermedia SoC's
5 * Copyright (c) 2013 Tony Prisk <linux@prisktech.co.nz>
8 #include <linux/gpio/driver.h>
10 /* VT8500 has no enable register in the extgpio bank. */
13 #define WMT_PINCTRL_BANK(__en, __dir, __dout, __din, __pen, __pcfg) \
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) \
32 .npins = ARRAY_SIZE(__data), \
35 struct wmt_pinctrl_bank_registers
{
45 struct wmt_pinctrl_group
{
47 const unsigned int *pins
;
51 struct wmt_pinctrl_data
{
53 struct pinctrl_dev
*pctl_dev
;
55 /* must be initialized before calling wmt_pinctrl_probe */
57 const struct wmt_pinctrl_bank_registers
*banks
;
58 const struct pinctrl_pin_desc
*pins
;
59 const char * const *groups
;
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
);