2 * Copyright (C) 2015-2016 Socionext Inc.
3 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5 * SPDX-License-Identifier: GPL-2.0+
8 #ifndef __PINCTRL_UNIPHIER_H__
9 #define __PINCTRL_UNIPHIER_H__
11 #include <linux/bitops.h>
12 #include <linux/bug.h>
13 #include <linux/kernel.h>
14 #include <linux/types.h>
16 #define UNIPHIER_PIN_ATTR_PACKED(iectrl) (iectrl)
18 static inline unsigned int uniphier_pin_get_iectrl(unsigned long data)
24 * struct uniphier_pinctrl_pin - pin data for UniPhier SoC
27 * @data: additional per-pin data
29 struct uniphier_pinctrl_pin {
35 * struct uniphier_pinctrl_group - pin group data for UniPhier SoC
37 * @name: pin group name
38 * @pins: array of pins that belong to the group
39 * @num_pins: number of pins in the group
40 * @muxvals: array of values to be set to pinmux registers
42 struct uniphier_pinctrl_group {
50 * struct uniphier_pinctrl_socdata - SoC data for UniPhier pin controller
52 * @pins: array of pin data
53 * @pins_count: number of pin data
54 * @groups: array of pin group data
55 * @groups_count: number of pin group data
56 * @functions: array of pinmux function names
57 * @functions_count: number of pinmux functions
58 * @mux_bits: bit width of each pinmux register
59 * @reg_stride: stride of pinmux register address
60 * @caps: SoC-specific capability flag
62 struct uniphier_pinctrl_socdata {
63 const struct uniphier_pinctrl_pin *pins;
65 const struct uniphier_pinctrl_group *groups;
67 const char * const *functions;
70 #define UNIPHIER_PINCTRL_CAPS_PUPD_SIMPLE BIT(3)
71 #define UNIPHIER_PINCTRL_CAPS_PERPIN_IECTRL BIT(2)
72 #define UNIPHIER_PINCTRL_CAPS_DBGMUX_SEPARATE BIT(1)
73 #define UNIPHIER_PINCTRL_CAPS_MUX_4BIT BIT(0)
76 #define UNIPHIER_PINCTRL_PIN(a, b) \
79 .data = UNIPHIER_PIN_ATTR_PACKED(b), \
82 #define __UNIPHIER_PINCTRL_GROUP(grp) \
86 .num_pins = ARRAY_SIZE(grp##_pins), \
87 .muxvals = grp##_muxvals + \
88 BUILD_BUG_ON_ZERO(ARRAY_SIZE(grp##_pins) != \
89 ARRAY_SIZE(grp##_muxvals)), \
92 #define __UNIPHIER_PINMUX_FUNCTION(func) #func
94 #ifdef CONFIG_SPL_BUILD
96 * a tricky way to drop unneeded *_pins and *_muxvals arrays from SPL,
97 * suppressing "defined but not used" warnings.
99 #define UNIPHIER_PINCTRL_GROUP(grp) \
100 { .num_pins = ARRAY_SIZE(grp##_pins) + ARRAY_SIZE(grp##_muxvals) }
101 #define UNIPHIER_PINMUX_FUNCTION(func) NULL
103 #define UNIPHIER_PINCTRL_GROUP(grp) __UNIPHIER_PINCTRL_GROUP(grp)
104 #define UNIPHIER_PINMUX_FUNCTION(func) __UNIPHIER_PINMUX_FUNCTION(func)
107 #define UNIPHIER_PINCTRL_GROUP_SPL(grp) __UNIPHIER_PINCTRL_GROUP(grp)
108 #define UNIPHIER_PINMUX_FUNCTION_SPL(func) __UNIPHIER_PINMUX_FUNCTION(func)
111 * struct uniphier_pinctrl_priv - private data for UniPhier pinctrl driver
113 * @base: base address of the pinctrl device
114 * @socdata: SoC specific data
116 struct uniphier_pinctrl_priv {
118 struct uniphier_pinctrl_socdata *socdata;
121 extern const struct pinctrl_ops uniphier_pinctrl_ops;
123 int uniphier_pinctrl_probe(struct udevice *dev,
124 struct uniphier_pinctrl_socdata *socdata);
126 #endif /* __PINCTRL_UNIPHIER_H__ */