blob: 6bdebf28cd59de02ffd7d72d56d1d6d5bd28d1a6 [file] [log] [blame]
Masahiro Yamada5dc626f2015-09-11 20:17:32 +09001/*
2 * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#ifndef __PINCTRL_UNIPHIER_H__
8#define __PINCTRL_UNIPHIER_H__
9
Masahiro Yamada84b8bf62016-01-24 23:27:48 +090010#include <linux/bug.h>
Masahiro Yamada5dc626f2015-09-11 20:17:32 +090011#include <linux/kernel.h>
12#include <linux/types.h>
13
14#define UNIPHIER_PINCTRL_PINMUX_BASE 0x0
15#define UNIPHIER_PINCTRL_LOAD_PINMUX 0x700
16#define UNIPHIER_PINCTRL_IECTRL 0xd00
17
18#define UNIPHIER_PIN_ATTR_PACKED(iectrl) (iectrl)
19
20static inline unsigned int uniphier_pin_get_iectrl(unsigned long data)
21{
22 return data;
23}
24
25/**
26 * struct uniphier_pinctrl_pin - pin data for UniPhier SoC
27 *
28 * @number: pin number
29 * @data: additional per-pin data
30 */
31struct uniphier_pinctrl_pin {
32 unsigned number;
33 unsigned long data;
34};
35
36/**
37 * struct uniphier_pinctrl_group - pin group data for UniPhier SoC
38 *
39 * @name: pin group name
40 * @pins: array of pins that belong to the group
41 * @num_pins: number of pins in the group
42 * @muxvals: array of values to be set to pinmux registers
43 */
44struct uniphier_pinctrl_group {
45 const char *name;
46 const unsigned *pins;
47 unsigned num_pins;
48 const unsigned *muxvals;
49};
50
51/**
52 * struct uniphier_pinctrl_socdata - SoC data for UniPhier pin controller
53 *
54 * @pins: array of pin data
55 * @pins_count: number of pin data
56 * @groups: array of pin group data
57 * @groups_count: number of pin group data
58 * @functions: array of pinmux function names
59 * @functions_count: number of pinmux functions
60 * @mux_bits: bit width of each pinmux register
61 * @reg_stride: stride of pinmux register address
62 * @load_pinctrl: if true, LOAD_PINMUX register must be set to one for new
63 * values in pinmux registers to become really effective
64 */
65struct uniphier_pinctrl_socdata {
66 const struct uniphier_pinctrl_pin *pins;
67 int pins_count;
68 const struct uniphier_pinctrl_group *groups;
69 int groups_count;
70 const char * const *functions;
71 int functions_count;
72 unsigned mux_bits;
73 unsigned reg_stride;
74 bool load_pinctrl;
75};
76
77#define UNIPHIER_PINCTRL_PIN(a, b) \
78{ \
79 .number = a, \
80 .data = UNIPHIER_PIN_ATTR_PACKED(b), \
81}
82
83#define UNIPHIER_PINCTRL_GROUP(grp) \
84 { \
85 .name = #grp, \
86 .pins = grp##_pins, \
87 .num_pins = ARRAY_SIZE(grp##_pins), \
88 .muxvals = grp##_muxvals + \
89 BUILD_BUG_ON_ZERO(ARRAY_SIZE(grp##_pins) != \
90 ARRAY_SIZE(grp##_muxvals)), \
91 }
92
93/**
94 * struct uniphier_pinctrl_priv - private data for UniPhier pinctrl driver
95 *
96 * @base: base address of the pinctrl device
97 * @socdata: SoC specific data
98 */
99struct uniphier_pinctrl_priv {
100 void __iomem *base;
101 struct uniphier_pinctrl_socdata *socdata;
102};
103
104extern const struct pinctrl_ops uniphier_pinctrl_ops;
105
106int uniphier_pinctrl_probe(struct udevice *dev,
107 struct uniphier_pinctrl_socdata *socdata);
108
109int uniphier_pinctrl_remove(struct udevice *dev);
110
111#endif /* __PINCTRL_UNIPHIER_H__ */