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_PINCTRL_PINMUX_BASE 0x1000
17 #define UNIPHIER_PINCTRL_LOAD_PINMUX 0x1700
18 #define UNIPHIER_PINCTRL_IECTRL 0x1d00
20 #define UNIPHIER_PIN_ATTR_PACKED(iectrl) (iectrl)
22 static inline unsigned int uniphier_pin_get_iectrl(unsigned long data)
28 * struct uniphier_pinctrl_pin - pin data for UniPhier SoC
31 * @data: additional per-pin data
33 struct uniphier_pinctrl_pin {
39 * struct uniphier_pinctrl_group - pin group data for UniPhier SoC
41 * @name: pin group name
42 * @pins: array of pins that belong to the group
43 * @num_pins: number of pins in the group
44 * @muxvals: array of values to be set to pinmux registers
46 struct uniphier_pinctrl_group {
54 * struct uniphier_pinctrl_socdata - SoC data for UniPhier pin controller
56 * @pins: array of pin data
57 * @pins_count: number of pin data
58 * @groups: array of pin group data
59 * @groups_count: number of pin group data
60 * @functions: array of pinmux function names
61 * @functions_count: number of pinmux functions
62 * @mux_bits: bit width of each pinmux register
63 * @reg_stride: stride of pinmux register address
64 * @caps: SoC-specific capability flag
66 struct uniphier_pinctrl_socdata {
67 const struct uniphier_pinctrl_pin *pins;
69 const struct uniphier_pinctrl_group *groups;
71 const char * const *functions;
74 #define UNIPHIER_PINCTRL_CAPS_PERPIN_IECTRL BIT(1)
75 #define UNIPHIER_PINCTRL_CAPS_DBGMUX_SEPARATE BIT(0)
78 #define UNIPHIER_PINCTRL_PIN(a, b) \
81 .data = UNIPHIER_PIN_ATTR_PACKED(b), \
84 #define __UNIPHIER_PINCTRL_GROUP(grp) \
88 .num_pins = ARRAY_SIZE(grp##_pins), \
89 .muxvals = grp##_muxvals + \
90 BUILD_BUG_ON_ZERO(ARRAY_SIZE(grp##_pins) != \
91 ARRAY_SIZE(grp##_muxvals)), \
94 #define __UNIPHIER_PINMUX_FUNCTION(func) #func
96 #ifdef CONFIG_SPL_BUILD
97 #define UNIPHIER_PINCTRL_GROUP(grp) { .name = NULL }
98 #define UNIPHIER_PINMUX_FUNCTION(func) NULL
100 #define UNIPHIER_PINCTRL_GROUP(grp) __UNIPHIER_PINCTRL_GROUP(grp)
101 #define UNIPHIER_PINMUX_FUNCTION(func) __UNIPHIER_PINMUX_FUNCTION(func)
104 #define UNIPHIER_PINCTRL_GROUP_SPL(grp) __UNIPHIER_PINCTRL_GROUP(grp)
105 #define UNIPHIER_PINMUX_FUNCTION_SPL(func) __UNIPHIER_PINMUX_FUNCTION(func)
108 * struct uniphier_pinctrl_priv - private data for UniPhier pinctrl driver
110 * @base: base address of the pinctrl device
111 * @socdata: SoC specific data
113 struct uniphier_pinctrl_priv {
115 struct uniphier_pinctrl_socdata *socdata;
118 extern const struct pinctrl_ops uniphier_pinctrl_ops;
120 int uniphier_pinctrl_probe(struct udevice *dev,
121 struct uniphier_pinctrl_socdata *socdata);
123 #endif /* __PINCTRL_UNIPHIER_H__ */