2 * Pinctrl driver for Rockchip SoCs
4 * Copyright (c) 2013 MundoReader S.L.
5 * Author: Heiko Stuebner <heiko@sntech.de>
7 * With some ideas taken from pinctrl-samsung:
8 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
9 * http://www.samsung.com
10 * Copyright (c) 2012 Linaro Ltd
11 * http://www.linaro.org
14 * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as published
18 * by the Free Software Foundation.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
26 #include <linux/module.h>
27 #include <linux/platform_device.h>
29 #include <linux/bitops.h>
30 #include <linux/gpio.h>
31 #include <linux/of_address.h>
32 #include <linux/of_irq.h>
33 #include <linux/pinctrl/machine.h>
34 #include <linux/pinctrl/pinconf.h>
35 #include <linux/pinctrl/pinctrl.h>
36 #include <linux/pinctrl/pinmux.h>
37 #include <linux/pinctrl/pinconf-generic.h>
38 #include <linux/irqchip/chained_irq.h>
39 #include <linux/clk.h>
40 #include <dt-bindings/pinctrl/rockchip.h>
45 /* GPIO control registers */
46 #define GPIO_SWPORT_DR 0x00
47 #define GPIO_SWPORT_DDR 0x04
48 #define GPIO_INTEN 0x30
49 #define GPIO_INTMASK 0x34
50 #define GPIO_INTTYPE_LEVEL 0x38
51 #define GPIO_INT_POLARITY 0x3c
52 #define GPIO_INT_STATUS 0x40
53 #define GPIO_INT_RAWSTATUS 0x44
54 #define GPIO_DEBOUNCE 0x48
55 #define GPIO_PORTS_EOI 0x4c
56 #define GPIO_EXT_PORT 0x50
57 #define GPIO_LS_SYNC 0x60
59 enum rockchip_pinctrl_type
{
65 enum rockchip_pin_bank_type
{
71 * @reg_base: register base of the gpio bank
72 * @reg_pull: optional separate register for additional pull settings
73 * @clk: clock of the gpio bank
74 * @irq: interrupt of the gpio bank
75 * @pin_base: first pin number
76 * @nr_pins: number of pins in this bank
77 * @name: name of the bank
78 * @bank_num: number of the bank, to account for holes
79 * @valid: are all necessary informations present
80 * @of_node: dt node of this bank
81 * @drvdata: common pinctrl basedata
82 * @domain: irqdomain of the gpio bank
83 * @gpio_chip: gpiolib chip
85 * @slock: spinlock for the gpio bank
87 struct rockchip_pin_bank
{
88 void __iomem
*reg_base
;
89 void __iomem
*reg_pull
;
96 enum rockchip_pin_bank_type bank_type
;
98 struct device_node
*of_node
;
99 struct rockchip_pinctrl
*drvdata
;
100 struct irq_domain
*domain
;
101 struct gpio_chip gpio_chip
;
102 struct pinctrl_gpio_range grange
;
104 u32 toggle_edge_mode
;
107 #define PIN_BANK(id, pins, label) \
116 struct rockchip_pin_ctrl
{
117 struct rockchip_pin_bank
*pin_banks
;
121 enum rockchip_pinctrl_type type
;
123 void (*pull_calc_reg
)(struct rockchip_pin_bank
*bank
, int pin_num
,
124 void __iomem
**reg
, u8
*bit
);
127 struct rockchip_pin_config
{
129 unsigned long *configs
;
130 unsigned int nconfigs
;
134 * struct rockchip_pin_group: represent group of pins of a pinmux function.
135 * @name: name of the pin group, used to lookup the group.
136 * @pins: the pins included in this group.
137 * @npins: number of pins included in this group.
138 * @func: the mux function number to be programmed when selected.
139 * @configs: the config values to be set for each pin
140 * @nconfigs: number of configs for each pin
142 struct rockchip_pin_group
{
146 struct rockchip_pin_config
*data
;
150 * struct rockchip_pmx_func: represent a pin function.
151 * @name: name of the pin function, used to lookup the function.
152 * @groups: one or more names of pin groups that provide this function.
153 * @num_groups: number of groups included in @groups.
155 struct rockchip_pmx_func
{
161 struct rockchip_pinctrl
{
162 void __iomem
*reg_base
;
163 void __iomem
*reg_pull
;
165 struct rockchip_pin_ctrl
*ctrl
;
166 struct pinctrl_desc pctl
;
167 struct pinctrl_dev
*pctl_dev
;
168 struct rockchip_pin_group
*groups
;
169 unsigned int ngroups
;
170 struct rockchip_pmx_func
*functions
;
171 unsigned int nfunctions
;
174 static inline struct rockchip_pin_bank
*gc_to_pin_bank(struct gpio_chip
*gc
)
176 return container_of(gc
, struct rockchip_pin_bank
, gpio_chip
);
179 static const inline struct rockchip_pin_group
*pinctrl_name_to_group(
180 const struct rockchip_pinctrl
*info
,
185 for (i
= 0; i
< info
->ngroups
; i
++) {
186 if (!strcmp(info
->groups
[i
].name
, name
))
187 return &info
->groups
[i
];
194 * given a pin number that is local to a pin controller, find out the pin bank
195 * and the register base of the pin bank.
197 static struct rockchip_pin_bank
*pin_to_bank(struct rockchip_pinctrl
*info
,
200 struct rockchip_pin_bank
*b
= info
->ctrl
->pin_banks
;
202 while (pin
>= (b
->pin_base
+ b
->nr_pins
))
208 static struct rockchip_pin_bank
*bank_num_to_bank(
209 struct rockchip_pinctrl
*info
,
212 struct rockchip_pin_bank
*b
= info
->ctrl
->pin_banks
;
215 for (i
= 0; i
< info
->ctrl
->nr_banks
; i
++, b
++) {
216 if (b
->bank_num
== num
)
220 return ERR_PTR(-EINVAL
);
224 * Pinctrl_ops handling
227 static int rockchip_get_groups_count(struct pinctrl_dev
*pctldev
)
229 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
231 return info
->ngroups
;
234 static const char *rockchip_get_group_name(struct pinctrl_dev
*pctldev
,
237 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
239 return info
->groups
[selector
].name
;
242 static int rockchip_get_group_pins(struct pinctrl_dev
*pctldev
,
243 unsigned selector
, const unsigned **pins
,
246 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
248 if (selector
>= info
->ngroups
)
251 *pins
= info
->groups
[selector
].pins
;
252 *npins
= info
->groups
[selector
].npins
;
257 static int rockchip_dt_node_to_map(struct pinctrl_dev
*pctldev
,
258 struct device_node
*np
,
259 struct pinctrl_map
**map
, unsigned *num_maps
)
261 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
262 const struct rockchip_pin_group
*grp
;
263 struct pinctrl_map
*new_map
;
264 struct device_node
*parent
;
269 * first find the group of this node and check if we need to create
270 * config maps for pins
272 grp
= pinctrl_name_to_group(info
, np
->name
);
274 dev_err(info
->dev
, "unable to find group for node %s\n",
279 map_num
+= grp
->npins
;
280 new_map
= devm_kzalloc(pctldev
->dev
, sizeof(*new_map
) * map_num
,
289 parent
= of_get_parent(np
);
291 devm_kfree(pctldev
->dev
, new_map
);
294 new_map
[0].type
= PIN_MAP_TYPE_MUX_GROUP
;
295 new_map
[0].data
.mux
.function
= parent
->name
;
296 new_map
[0].data
.mux
.group
= np
->name
;
299 /* create config map */
301 for (i
= 0; i
< grp
->npins
; i
++) {
302 new_map
[i
].type
= PIN_MAP_TYPE_CONFIGS_PIN
;
303 new_map
[i
].data
.configs
.group_or_pin
=
304 pin_get_name(pctldev
, grp
->pins
[i
]);
305 new_map
[i
].data
.configs
.configs
= grp
->data
[i
].configs
;
306 new_map
[i
].data
.configs
.num_configs
= grp
->data
[i
].nconfigs
;
309 dev_dbg(pctldev
->dev
, "maps: function %s group %s num %d\n",
310 (*map
)->data
.mux
.function
, (*map
)->data
.mux
.group
, map_num
);
315 static void rockchip_dt_free_map(struct pinctrl_dev
*pctldev
,
316 struct pinctrl_map
*map
, unsigned num_maps
)
320 static const struct pinctrl_ops rockchip_pctrl_ops
= {
321 .get_groups_count
= rockchip_get_groups_count
,
322 .get_group_name
= rockchip_get_group_name
,
323 .get_group_pins
= rockchip_get_group_pins
,
324 .dt_node_to_map
= rockchip_dt_node_to_map
,
325 .dt_free_map
= rockchip_dt_free_map
,
333 * Set a new mux function for a pin.
335 * The register is divided into the upper and lower 16 bit. When changing
336 * a value, the previous register value is not read and changed. Instead
337 * it seems the changed bits are marked in the upper 16 bit, while the
338 * changed value gets set in the same offset in the lower 16 bit.
339 * All pin settings seem to be 2 bit wide in both the upper and lower
341 * @bank: pin bank to change
342 * @pin: pin to change
343 * @mux: new mux function to set
345 static int rockchip_set_mux(struct rockchip_pin_bank
*bank
, int pin
, int mux
)
347 struct rockchip_pinctrl
*info
= bank
->drvdata
;
348 void __iomem
*reg
= info
->reg_base
+ info
->ctrl
->mux_offset
;
354 * The first 16 pins of rk3188_bank0 are always gpios and do not have
355 * a mux register at all.
357 if (bank
->bank_type
== RK3188_BANK0
&& pin
< 16) {
358 if (mux
!= RK_FUNC_GPIO
) {
360 "pin %d only supports a gpio mux\n", pin
);
367 dev_dbg(info
->dev
, "setting mux of GPIO%d-%d to %d\n",
368 bank
->bank_num
, pin
, mux
);
370 /* get basic quadrupel of mux registers and the correct reg inside */
371 reg
+= bank
->bank_num
* 0x10;
372 reg
+= (pin
/ 8) * 4;
375 spin_lock_irqsave(&bank
->slock
, flags
);
377 data
= (3 << (bit
+ 16));
378 data
|= (mux
& 3) << bit
;
381 spin_unlock_irqrestore(&bank
->slock
, flags
);
386 #define RK2928_PULL_OFFSET 0x118
387 #define RK2928_PULL_PINS_PER_REG 16
388 #define RK2928_PULL_BANK_STRIDE 8
390 static void rk2928_calc_pull_reg_and_bit(struct rockchip_pin_bank
*bank
,
391 int pin_num
, void __iomem
**reg
, u8
*bit
)
393 struct rockchip_pinctrl
*info
= bank
->drvdata
;
395 *reg
= info
->reg_base
+ RK2928_PULL_OFFSET
;
396 *reg
+= bank
->bank_num
* RK2928_PULL_BANK_STRIDE
;
397 *reg
+= (pin_num
/ RK2928_PULL_PINS_PER_REG
) * 4;
399 *bit
= pin_num
% RK2928_PULL_PINS_PER_REG
;
402 #define RK3188_PULL_BITS_PER_PIN 2
403 #define RK3188_PULL_PINS_PER_REG 8
404 #define RK3188_PULL_BANK_STRIDE 16
406 static void rk3188_calc_pull_reg_and_bit(struct rockchip_pin_bank
*bank
,
407 int pin_num
, void __iomem
**reg
, u8
*bit
)
409 struct rockchip_pinctrl
*info
= bank
->drvdata
;
411 /* The first 12 pins of the first bank are located elsewhere */
412 if (bank
->bank_type
== RK3188_BANK0
&& pin_num
< 12) {
413 *reg
= bank
->reg_pull
+
414 ((pin_num
/ RK3188_PULL_PINS_PER_REG
) * 4);
415 *bit
= pin_num
% RK3188_PULL_PINS_PER_REG
;
416 *bit
*= RK3188_PULL_BITS_PER_PIN
;
418 *reg
= info
->reg_pull
- 4;
419 *reg
+= bank
->bank_num
* RK3188_PULL_BANK_STRIDE
;
420 *reg
+= ((pin_num
/ RK3188_PULL_PINS_PER_REG
) * 4);
423 * The bits in these registers have an inverse ordering
424 * with the lowest pin being in bits 15:14 and the highest
427 *bit
= 7 - (pin_num
% RK3188_PULL_PINS_PER_REG
);
428 *bit
*= RK3188_PULL_BITS_PER_PIN
;
432 static int rockchip_get_pull(struct rockchip_pin_bank
*bank
, int pin_num
)
434 struct rockchip_pinctrl
*info
= bank
->drvdata
;
435 struct rockchip_pin_ctrl
*ctrl
= info
->ctrl
;
440 /* rk3066b does support any pulls */
441 if (ctrl
->type
== RK3066B
)
442 return PIN_CONFIG_BIAS_DISABLE
;
444 ctrl
->pull_calc_reg(bank
, pin_num
, ®
, &bit
);
446 switch (ctrl
->type
) {
448 return !(readl_relaxed(reg
) & BIT(bit
))
449 ? PIN_CONFIG_BIAS_PULL_PIN_DEFAULT
450 : PIN_CONFIG_BIAS_DISABLE
;
452 data
= readl_relaxed(reg
) >> bit
;
453 data
&= (1 << RK3188_PULL_BITS_PER_PIN
) - 1;
457 return PIN_CONFIG_BIAS_DISABLE
;
459 return PIN_CONFIG_BIAS_PULL_UP
;
461 return PIN_CONFIG_BIAS_PULL_DOWN
;
463 return PIN_CONFIG_BIAS_BUS_HOLD
;
466 dev_err(info
->dev
, "unknown pull setting\n");
469 dev_err(info
->dev
, "unsupported pinctrl type\n");
474 static int rockchip_set_pull(struct rockchip_pin_bank
*bank
,
475 int pin_num
, int pull
)
477 struct rockchip_pinctrl
*info
= bank
->drvdata
;
478 struct rockchip_pin_ctrl
*ctrl
= info
->ctrl
;
484 dev_dbg(info
->dev
, "setting pull of GPIO%d-%d to %d\n",
485 bank
->bank_num
, pin_num
, pull
);
487 /* rk3066b does support any pulls */
488 if (ctrl
->type
== RK3066B
)
489 return pull
? -EINVAL
: 0;
491 ctrl
->pull_calc_reg(bank
, pin_num
, ®
, &bit
);
493 switch (ctrl
->type
) {
495 spin_lock_irqsave(&bank
->slock
, flags
);
497 data
= BIT(bit
+ 16);
498 if (pull
== PIN_CONFIG_BIAS_DISABLE
)
502 spin_unlock_irqrestore(&bank
->slock
, flags
);
505 spin_lock_irqsave(&bank
->slock
, flags
);
507 /* enable the write to the equivalent lower bits */
508 data
= ((1 << RK3188_PULL_BITS_PER_PIN
) - 1) << (bit
+ 16);
511 case PIN_CONFIG_BIAS_DISABLE
:
513 case PIN_CONFIG_BIAS_PULL_UP
:
516 case PIN_CONFIG_BIAS_PULL_DOWN
:
519 case PIN_CONFIG_BIAS_BUS_HOLD
:
523 spin_unlock_irqrestore(&bank
->slock
, flags
);
524 dev_err(info
->dev
, "unsupported pull setting %d\n",
531 spin_unlock_irqrestore(&bank
->slock
, flags
);
534 dev_err(info
->dev
, "unsupported pinctrl type\n");
542 * Pinmux_ops handling
545 static int rockchip_pmx_get_funcs_count(struct pinctrl_dev
*pctldev
)
547 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
549 return info
->nfunctions
;
552 static const char *rockchip_pmx_get_func_name(struct pinctrl_dev
*pctldev
,
555 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
557 return info
->functions
[selector
].name
;
560 static int rockchip_pmx_get_groups(struct pinctrl_dev
*pctldev
,
561 unsigned selector
, const char * const **groups
,
562 unsigned * const num_groups
)
564 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
566 *groups
= info
->functions
[selector
].groups
;
567 *num_groups
= info
->functions
[selector
].ngroups
;
572 static int rockchip_pmx_enable(struct pinctrl_dev
*pctldev
, unsigned selector
,
575 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
576 const unsigned int *pins
= info
->groups
[group
].pins
;
577 const struct rockchip_pin_config
*data
= info
->groups
[group
].data
;
578 struct rockchip_pin_bank
*bank
;
581 dev_dbg(info
->dev
, "enable function %s group %s\n",
582 info
->functions
[selector
].name
, info
->groups
[group
].name
);
585 * for each pin in the pin group selected, program the correspoding pin
586 * pin function number in the config register.
588 for (cnt
= 0; cnt
< info
->groups
[group
].npins
; cnt
++) {
589 bank
= pin_to_bank(info
, pins
[cnt
]);
590 ret
= rockchip_set_mux(bank
, pins
[cnt
] - bank
->pin_base
,
597 /* revert the already done pin settings */
598 for (cnt
--; cnt
>= 0; cnt
--)
599 rockchip_set_mux(bank
, pins
[cnt
] - bank
->pin_base
, 0);
607 static void rockchip_pmx_disable(struct pinctrl_dev
*pctldev
,
608 unsigned selector
, unsigned group
)
610 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
611 const unsigned int *pins
= info
->groups
[group
].pins
;
612 struct rockchip_pin_bank
*bank
;
615 dev_dbg(info
->dev
, "disable function %s group %s\n",
616 info
->functions
[selector
].name
, info
->groups
[group
].name
);
618 for (cnt
= 0; cnt
< info
->groups
[group
].npins
; cnt
++) {
619 bank
= pin_to_bank(info
, pins
[cnt
]);
620 rockchip_set_mux(bank
, pins
[cnt
] - bank
->pin_base
, 0);
625 * The calls to gpio_direction_output() and gpio_direction_input()
626 * leads to this function call (via the pinctrl_gpio_direction_{input|output}()
627 * function called from the gpiolib interface).
629 static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev
*pctldev
,
630 struct pinctrl_gpio_range
*range
,
631 unsigned offset
, bool input
)
633 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
634 struct rockchip_pin_bank
*bank
;
635 struct gpio_chip
*chip
;
640 bank
= gc_to_pin_bank(chip
);
641 pin
= offset
- chip
->base
;
643 dev_dbg(info
->dev
, "gpio_direction for pin %u as %s-%d to %s\n",
644 offset
, range
->name
, pin
, input
? "input" : "output");
646 ret
= rockchip_set_mux(bank
, pin
, RK_FUNC_GPIO
);
650 data
= readl_relaxed(bank
->reg_base
+ GPIO_SWPORT_DDR
);
651 /* set bit to 1 for output, 0 for input */
656 writel_relaxed(data
, bank
->reg_base
+ GPIO_SWPORT_DDR
);
661 static const struct pinmux_ops rockchip_pmx_ops
= {
662 .get_functions_count
= rockchip_pmx_get_funcs_count
,
663 .get_function_name
= rockchip_pmx_get_func_name
,
664 .get_function_groups
= rockchip_pmx_get_groups
,
665 .enable
= rockchip_pmx_enable
,
666 .disable
= rockchip_pmx_disable
,
667 .gpio_set_direction
= rockchip_pmx_gpio_set_direction
,
671 * Pinconf_ops handling
674 static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl
*ctrl
,
675 enum pin_config_param pull
)
677 switch (ctrl
->type
) {
679 return (pull
== PIN_CONFIG_BIAS_PULL_PIN_DEFAULT
||
680 pull
== PIN_CONFIG_BIAS_DISABLE
);
682 return pull
? false : true;
684 return (pull
!= PIN_CONFIG_BIAS_PULL_PIN_DEFAULT
);
690 /* set the pin config settings for a specified pin */
691 static int rockchip_pinconf_set(struct pinctrl_dev
*pctldev
, unsigned int pin
,
692 unsigned long *configs
, unsigned num_configs
)
694 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
695 struct rockchip_pin_bank
*bank
= pin_to_bank(info
, pin
);
696 enum pin_config_param param
;
701 for (i
= 0; i
< num_configs
; i
++) {
702 param
= pinconf_to_config_param(configs
[i
]);
703 arg
= pinconf_to_config_argument(configs
[i
]);
706 case PIN_CONFIG_BIAS_DISABLE
:
707 rc
= rockchip_set_pull(bank
, pin
- bank
->pin_base
,
712 case PIN_CONFIG_BIAS_PULL_UP
:
713 case PIN_CONFIG_BIAS_PULL_DOWN
:
714 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT
:
715 case PIN_CONFIG_BIAS_BUS_HOLD
:
716 if (!rockchip_pinconf_pull_valid(info
->ctrl
, param
))
722 rc
= rockchip_set_pull(bank
, pin
- bank
->pin_base
,
731 } /* for each config */
736 /* get the pin config settings for a specified pin */
737 static int rockchip_pinconf_get(struct pinctrl_dev
*pctldev
, unsigned int pin
,
738 unsigned long *config
)
740 struct rockchip_pinctrl
*info
= pinctrl_dev_get_drvdata(pctldev
);
741 struct rockchip_pin_bank
*bank
= pin_to_bank(info
, pin
);
742 enum pin_config_param param
= pinconf_to_config_param(*config
);
745 case PIN_CONFIG_BIAS_DISABLE
:
746 if (rockchip_get_pull(bank
, pin
- bank
->pin_base
) != param
)
751 case PIN_CONFIG_BIAS_PULL_UP
:
752 case PIN_CONFIG_BIAS_PULL_DOWN
:
753 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT
:
754 case PIN_CONFIG_BIAS_BUS_HOLD
:
755 if (!rockchip_pinconf_pull_valid(info
->ctrl
, param
))
758 if (rockchip_get_pull(bank
, pin
- bank
->pin_base
) != param
)
771 static const struct pinconf_ops rockchip_pinconf_ops
= {
772 .pin_config_get
= rockchip_pinconf_get
,
773 .pin_config_set
= rockchip_pinconf_set
,
776 static const struct of_device_id rockchip_bank_match
[] = {
777 { .compatible
= "rockchip,gpio-bank" },
778 { .compatible
= "rockchip,rk3188-gpio-bank0" },
782 static void rockchip_pinctrl_child_count(struct rockchip_pinctrl
*info
,
783 struct device_node
*np
)
785 struct device_node
*child
;
787 for_each_child_of_node(np
, child
) {
788 if (of_match_node(rockchip_bank_match
, child
))
792 info
->ngroups
+= of_get_child_count(child
);
796 static int rockchip_pinctrl_parse_groups(struct device_node
*np
,
797 struct rockchip_pin_group
*grp
,
798 struct rockchip_pinctrl
*info
,
801 struct rockchip_pin_bank
*bank
;
808 dev_dbg(info
->dev
, "group(%d): %s\n", index
, np
->name
);
810 /* Initialise group */
811 grp
->name
= np
->name
;
814 * the binding format is rockchip,pins = <bank pin mux CONFIG>,
815 * do sanity check and calculate pins number
817 list
= of_get_property(np
, "rockchip,pins", &size
);
818 /* we do not check return since it's safe node passed down */
819 size
/= sizeof(*list
);
820 if (!size
|| size
% 4) {
821 dev_err(info
->dev
, "wrong pins number or pins and configs should be by 4\n");
825 grp
->npins
= size
/ 4;
827 grp
->pins
= devm_kzalloc(info
->dev
, grp
->npins
* sizeof(unsigned int),
829 grp
->data
= devm_kzalloc(info
->dev
, grp
->npins
*
830 sizeof(struct rockchip_pin_config
),
832 if (!grp
->pins
|| !grp
->data
)
835 for (i
= 0, j
= 0; i
< size
; i
+= 4, j
++) {
836 const __be32
*phandle
;
837 struct device_node
*np_config
;
839 num
= be32_to_cpu(*list
++);
840 bank
= bank_num_to_bank(info
, num
);
842 return PTR_ERR(bank
);
844 grp
->pins
[j
] = bank
->pin_base
+ be32_to_cpu(*list
++);
845 grp
->data
[j
].func
= be32_to_cpu(*list
++);
851 np_config
= of_find_node_by_phandle(be32_to_cpup(phandle
));
852 ret
= pinconf_generic_parse_dt_config(np_config
,
853 &grp
->data
[j
].configs
, &grp
->data
[j
].nconfigs
);
861 static int rockchip_pinctrl_parse_functions(struct device_node
*np
,
862 struct rockchip_pinctrl
*info
,
865 struct device_node
*child
;
866 struct rockchip_pmx_func
*func
;
867 struct rockchip_pin_group
*grp
;
869 static u32 grp_index
;
872 dev_dbg(info
->dev
, "parse function(%d): %s\n", index
, np
->name
);
874 func
= &info
->functions
[index
];
876 /* Initialise function */
877 func
->name
= np
->name
;
878 func
->ngroups
= of_get_child_count(np
);
879 if (func
->ngroups
<= 0)
882 func
->groups
= devm_kzalloc(info
->dev
,
883 func
->ngroups
* sizeof(char *), GFP_KERNEL
);
887 for_each_child_of_node(np
, child
) {
888 func
->groups
[i
] = child
->name
;
889 grp
= &info
->groups
[grp_index
++];
890 ret
= rockchip_pinctrl_parse_groups(child
, grp
, info
, i
++);
898 static int rockchip_pinctrl_parse_dt(struct platform_device
*pdev
,
899 struct rockchip_pinctrl
*info
)
901 struct device
*dev
= &pdev
->dev
;
902 struct device_node
*np
= dev
->of_node
;
903 struct device_node
*child
;
907 rockchip_pinctrl_child_count(info
, np
);
909 dev_dbg(&pdev
->dev
, "nfunctions = %d\n", info
->nfunctions
);
910 dev_dbg(&pdev
->dev
, "ngroups = %d\n", info
->ngroups
);
912 info
->functions
= devm_kzalloc(dev
, info
->nfunctions
*
913 sizeof(struct rockchip_pmx_func
),
915 if (!info
->functions
) {
916 dev_err(dev
, "failed to allocate memory for function list\n");
920 info
->groups
= devm_kzalloc(dev
, info
->ngroups
*
921 sizeof(struct rockchip_pin_group
),
924 dev_err(dev
, "failed allocate memory for ping group list\n");
930 for_each_child_of_node(np
, child
) {
931 if (of_match_node(rockchip_bank_match
, child
))
934 ret
= rockchip_pinctrl_parse_functions(child
, info
, i
++);
936 dev_err(&pdev
->dev
, "failed to parse function\n");
944 static int rockchip_pinctrl_register(struct platform_device
*pdev
,
945 struct rockchip_pinctrl
*info
)
947 struct pinctrl_desc
*ctrldesc
= &info
->pctl
;
948 struct pinctrl_pin_desc
*pindesc
, *pdesc
;
949 struct rockchip_pin_bank
*pin_bank
;
953 ctrldesc
->name
= "rockchip-pinctrl";
954 ctrldesc
->owner
= THIS_MODULE
;
955 ctrldesc
->pctlops
= &rockchip_pctrl_ops
;
956 ctrldesc
->pmxops
= &rockchip_pmx_ops
;
957 ctrldesc
->confops
= &rockchip_pinconf_ops
;
959 pindesc
= devm_kzalloc(&pdev
->dev
, sizeof(*pindesc
) *
960 info
->ctrl
->nr_pins
, GFP_KERNEL
);
962 dev_err(&pdev
->dev
, "mem alloc for pin descriptors failed\n");
965 ctrldesc
->pins
= pindesc
;
966 ctrldesc
->npins
= info
->ctrl
->nr_pins
;
969 for (bank
= 0 , k
= 0; bank
< info
->ctrl
->nr_banks
; bank
++) {
970 pin_bank
= &info
->ctrl
->pin_banks
[bank
];
971 for (pin
= 0; pin
< pin_bank
->nr_pins
; pin
++, k
++) {
973 pdesc
->name
= kasprintf(GFP_KERNEL
, "%s-%d",
974 pin_bank
->name
, pin
);
979 info
->pctl_dev
= pinctrl_register(ctrldesc
, &pdev
->dev
, info
);
980 if (!info
->pctl_dev
) {
981 dev_err(&pdev
->dev
, "could not register pinctrl driver\n");
985 for (bank
= 0; bank
< info
->ctrl
->nr_banks
; ++bank
) {
986 pin_bank
= &info
->ctrl
->pin_banks
[bank
];
987 pin_bank
->grange
.name
= pin_bank
->name
;
988 pin_bank
->grange
.id
= bank
;
989 pin_bank
->grange
.pin_base
= pin_bank
->pin_base
;
990 pin_bank
->grange
.base
= pin_bank
->gpio_chip
.base
;
991 pin_bank
->grange
.npins
= pin_bank
->gpio_chip
.ngpio
;
992 pin_bank
->grange
.gc
= &pin_bank
->gpio_chip
;
993 pinctrl_add_gpio_range(info
->pctl_dev
, &pin_bank
->grange
);
996 ret
= rockchip_pinctrl_parse_dt(pdev
, info
);
998 pinctrl_unregister(info
->pctl_dev
);
1009 static int rockchip_gpio_request(struct gpio_chip
*chip
, unsigned offset
)
1011 return pinctrl_request_gpio(chip
->base
+ offset
);
1014 static void rockchip_gpio_free(struct gpio_chip
*chip
, unsigned offset
)
1016 pinctrl_free_gpio(chip
->base
+ offset
);
1019 static void rockchip_gpio_set(struct gpio_chip
*gc
, unsigned offset
, int value
)
1021 struct rockchip_pin_bank
*bank
= gc_to_pin_bank(gc
);
1022 void __iomem
*reg
= bank
->reg_base
+ GPIO_SWPORT_DR
;
1023 unsigned long flags
;
1026 spin_lock_irqsave(&bank
->slock
, flags
);
1029 data
&= ~BIT(offset
);
1031 data
|= BIT(offset
);
1034 spin_unlock_irqrestore(&bank
->slock
, flags
);
1038 * Returns the level of the pin for input direction and setting of the DR
1039 * register for output gpios.
1041 static int rockchip_gpio_get(struct gpio_chip
*gc
, unsigned offset
)
1043 struct rockchip_pin_bank
*bank
= gc_to_pin_bank(gc
);
1046 data
= readl(bank
->reg_base
+ GPIO_EXT_PORT
);
1053 * gpiolib gpio_direction_input callback function. The setting of the pin
1054 * mux function as 'gpio input' will be handled by the pinctrl susbsystem
1057 static int rockchip_gpio_direction_input(struct gpio_chip
*gc
, unsigned offset
)
1059 return pinctrl_gpio_direction_input(gc
->base
+ offset
);
1063 * gpiolib gpio_direction_output callback function. The setting of the pin
1064 * mux function as 'gpio output' will be handled by the pinctrl susbsystem
1067 static int rockchip_gpio_direction_output(struct gpio_chip
*gc
,
1068 unsigned offset
, int value
)
1070 rockchip_gpio_set(gc
, offset
, value
);
1071 return pinctrl_gpio_direction_output(gc
->base
+ offset
);
1075 * gpiolib gpio_to_irq callback function. Creates a mapping between a GPIO pin
1076 * and a virtual IRQ, if not already present.
1078 static int rockchip_gpio_to_irq(struct gpio_chip
*gc
, unsigned offset
)
1080 struct rockchip_pin_bank
*bank
= gc_to_pin_bank(gc
);
1086 virq
= irq_create_mapping(bank
->domain
, offset
);
1088 return (virq
) ? : -ENXIO
;
1091 static const struct gpio_chip rockchip_gpiolib_chip
= {
1092 .request
= rockchip_gpio_request
,
1093 .free
= rockchip_gpio_free
,
1094 .set
= rockchip_gpio_set
,
1095 .get
= rockchip_gpio_get
,
1096 .direction_input
= rockchip_gpio_direction_input
,
1097 .direction_output
= rockchip_gpio_direction_output
,
1098 .to_irq
= rockchip_gpio_to_irq
,
1099 .owner
= THIS_MODULE
,
1103 * Interrupt handling
1106 static void rockchip_irq_demux(unsigned int irq
, struct irq_desc
*desc
)
1108 struct irq_chip
*chip
= irq_get_chip(irq
);
1109 struct rockchip_pin_bank
*bank
= irq_get_handler_data(irq
);
1110 u32 polarity
= 0, data
= 0;
1112 bool edge_changed
= false;
1114 dev_dbg(bank
->drvdata
->dev
, "got irq for bank %s\n", bank
->name
);
1116 chained_irq_enter(chip
, desc
);
1118 pend
= readl_relaxed(bank
->reg_base
+ GPIO_INT_STATUS
);
1120 if (bank
->toggle_edge_mode
) {
1121 polarity
= readl_relaxed(bank
->reg_base
+
1123 data
= readl_relaxed(bank
->reg_base
+ GPIO_EXT_PORT
);
1131 virq
= irq_linear_revmap(bank
->domain
, irq
);
1134 dev_err(bank
->drvdata
->dev
, "unmapped irq %d\n", irq
);
1138 dev_dbg(bank
->drvdata
->dev
, "handling irq %d\n", irq
);
1141 * Triggering IRQ on both rising and falling edge
1142 * needs manual intervention.
1144 if (bank
->toggle_edge_mode
& BIT(irq
)) {
1145 if (data
& BIT(irq
))
1146 polarity
&= ~BIT(irq
);
1148 polarity
|= BIT(irq
);
1150 edge_changed
= true;
1153 generic_handle_irq(virq
);
1156 if (bank
->toggle_edge_mode
&& edge_changed
) {
1157 /* Interrupt params should only be set with ints disabled */
1158 data
= readl_relaxed(bank
->reg_base
+ GPIO_INTEN
);
1159 writel_relaxed(0, bank
->reg_base
+ GPIO_INTEN
);
1160 writel(polarity
, bank
->reg_base
+ GPIO_INT_POLARITY
);
1161 writel(data
, bank
->reg_base
+ GPIO_INTEN
);
1164 chained_irq_exit(chip
, desc
);
1167 static int rockchip_irq_set_type(struct irq_data
*d
, unsigned int type
)
1169 struct irq_chip_generic
*gc
= irq_data_get_irq_chip_data(d
);
1170 struct rockchip_pin_bank
*bank
= gc
->private;
1171 u32 mask
= BIT(d
->hwirq
);
1177 /* make sure the pin is configured as gpio input */
1178 ret
= rockchip_set_mux(bank
, d
->hwirq
, RK_FUNC_GPIO
);
1182 data
= readl_relaxed(bank
->reg_base
+ GPIO_SWPORT_DDR
);
1184 writel_relaxed(data
, bank
->reg_base
+ GPIO_SWPORT_DDR
);
1186 if (type
& IRQ_TYPE_EDGE_BOTH
)
1187 __irq_set_handler_locked(d
->irq
, handle_edge_irq
);
1189 __irq_set_handler_locked(d
->irq
, handle_level_irq
);
1193 level
= readl_relaxed(gc
->reg_base
+ GPIO_INTTYPE_LEVEL
);
1194 polarity
= readl_relaxed(gc
->reg_base
+ GPIO_INT_POLARITY
);
1197 case IRQ_TYPE_EDGE_BOTH
:
1198 bank
->toggle_edge_mode
|= mask
;
1202 * Determine gpio state. If 1 next interrupt should be falling
1205 data
= readl(bank
->reg_base
+ GPIO_EXT_PORT
);
1211 case IRQ_TYPE_EDGE_RISING
:
1212 bank
->toggle_edge_mode
&= ~mask
;
1216 case IRQ_TYPE_EDGE_FALLING
:
1217 bank
->toggle_edge_mode
&= ~mask
;
1221 case IRQ_TYPE_LEVEL_HIGH
:
1222 bank
->toggle_edge_mode
&= ~mask
;
1226 case IRQ_TYPE_LEVEL_LOW
:
1227 bank
->toggle_edge_mode
&= ~mask
;
1236 writel_relaxed(level
, gc
->reg_base
+ GPIO_INTTYPE_LEVEL
);
1237 writel_relaxed(polarity
, gc
->reg_base
+ GPIO_INT_POLARITY
);
1244 static int rockchip_interrupts_register(struct platform_device
*pdev
,
1245 struct rockchip_pinctrl
*info
)
1247 struct rockchip_pin_ctrl
*ctrl
= info
->ctrl
;
1248 struct rockchip_pin_bank
*bank
= ctrl
->pin_banks
;
1249 unsigned int clr
= IRQ_NOREQUEST
| IRQ_NOPROBE
| IRQ_NOAUTOEN
;
1250 struct irq_chip_generic
*gc
;
1254 for (i
= 0; i
< ctrl
->nr_banks
; ++i
, ++bank
) {
1256 dev_warn(&pdev
->dev
, "bank %s is not valid\n",
1261 bank
->domain
= irq_domain_add_linear(bank
->of_node
, 32,
1262 &irq_generic_chip_ops
, NULL
);
1263 if (!bank
->domain
) {
1264 dev_warn(&pdev
->dev
, "could not initialize irq domain for bank %s\n",
1269 ret
= irq_alloc_domain_generic_chips(bank
->domain
, 32, 1,
1270 "rockchip_gpio_irq", handle_level_irq
,
1271 clr
, 0, IRQ_GC_INIT_MASK_CACHE
);
1273 dev_err(&pdev
->dev
, "could not alloc generic chips for bank %s\n",
1275 irq_domain_remove(bank
->domain
);
1279 gc
= irq_get_domain_generic_chip(bank
->domain
, 0);
1280 gc
->reg_base
= bank
->reg_base
;
1282 gc
->chip_types
[0].regs
.mask
= GPIO_INTEN
;
1283 gc
->chip_types
[0].regs
.ack
= GPIO_PORTS_EOI
;
1284 gc
->chip_types
[0].chip
.irq_ack
= irq_gc_ack_set_bit
;
1285 gc
->chip_types
[0].chip
.irq_mask
= irq_gc_mask_clr_bit
;
1286 gc
->chip_types
[0].chip
.irq_unmask
= irq_gc_mask_set_bit
;
1287 gc
->chip_types
[0].chip
.irq_set_wake
= irq_gc_set_wake
;
1288 gc
->chip_types
[0].chip
.irq_set_type
= rockchip_irq_set_type
;
1290 irq_set_handler_data(bank
->irq
, bank
);
1291 irq_set_chained_handler(bank
->irq
, rockchip_irq_demux
);
1297 static int rockchip_gpiolib_register(struct platform_device
*pdev
,
1298 struct rockchip_pinctrl
*info
)
1300 struct rockchip_pin_ctrl
*ctrl
= info
->ctrl
;
1301 struct rockchip_pin_bank
*bank
= ctrl
->pin_banks
;
1302 struct gpio_chip
*gc
;
1306 for (i
= 0; i
< ctrl
->nr_banks
; ++i
, ++bank
) {
1308 dev_warn(&pdev
->dev
, "bank %s is not valid\n",
1313 bank
->gpio_chip
= rockchip_gpiolib_chip
;
1315 gc
= &bank
->gpio_chip
;
1316 gc
->base
= bank
->pin_base
;
1317 gc
->ngpio
= bank
->nr_pins
;
1318 gc
->dev
= &pdev
->dev
;
1319 gc
->of_node
= bank
->of_node
;
1320 gc
->label
= bank
->name
;
1322 ret
= gpiochip_add(gc
);
1324 dev_err(&pdev
->dev
, "failed to register gpio_chip %s, error code: %d\n",
1330 rockchip_interrupts_register(pdev
, info
);
1335 for (--i
, --bank
; i
>= 0; --i
, --bank
) {
1339 if (gpiochip_remove(&bank
->gpio_chip
))
1340 dev_err(&pdev
->dev
, "gpio chip %s remove failed\n",
1341 bank
->gpio_chip
.label
);
1346 static int rockchip_gpiolib_unregister(struct platform_device
*pdev
,
1347 struct rockchip_pinctrl
*info
)
1349 struct rockchip_pin_ctrl
*ctrl
= info
->ctrl
;
1350 struct rockchip_pin_bank
*bank
= ctrl
->pin_banks
;
1354 for (i
= 0; !ret
&& i
< ctrl
->nr_banks
; ++i
, ++bank
) {
1358 ret
= gpiochip_remove(&bank
->gpio_chip
);
1362 dev_err(&pdev
->dev
, "gpio chip remove failed\n");
1367 static int rockchip_get_bank_data(struct rockchip_pin_bank
*bank
,
1370 struct resource res
;
1372 if (of_address_to_resource(bank
->of_node
, 0, &res
)) {
1373 dev_err(dev
, "cannot find IO resource for bank\n");
1377 bank
->reg_base
= devm_ioremap_resource(dev
, &res
);
1378 if (IS_ERR(bank
->reg_base
))
1379 return PTR_ERR(bank
->reg_base
);
1382 * special case, where parts of the pull setting-registers are
1383 * part of the PMU register space
1385 if (of_device_is_compatible(bank
->of_node
,
1386 "rockchip,rk3188-gpio-bank0")) {
1387 bank
->bank_type
= RK3188_BANK0
;
1389 if (of_address_to_resource(bank
->of_node
, 1, &res
)) {
1390 dev_err(dev
, "cannot find IO resource for bank\n");
1394 bank
->reg_pull
= devm_ioremap_resource(dev
, &res
);
1395 if (IS_ERR(bank
->reg_pull
))
1396 return PTR_ERR(bank
->reg_pull
);
1398 bank
->bank_type
= COMMON_BANK
;
1401 bank
->irq
= irq_of_parse_and_map(bank
->of_node
, 0);
1403 bank
->clk
= of_clk_get(bank
->of_node
, 0);
1404 if (IS_ERR(bank
->clk
))
1405 return PTR_ERR(bank
->clk
);
1407 return clk_prepare_enable(bank
->clk
);
1410 static const struct of_device_id rockchip_pinctrl_dt_match
[];
1412 /* retrieve the soc specific data */
1413 static struct rockchip_pin_ctrl
*rockchip_pinctrl_get_soc_data(
1414 struct rockchip_pinctrl
*d
,
1415 struct platform_device
*pdev
)
1417 const struct of_device_id
*match
;
1418 struct device_node
*node
= pdev
->dev
.of_node
;
1419 struct device_node
*np
;
1420 struct rockchip_pin_ctrl
*ctrl
;
1421 struct rockchip_pin_bank
*bank
;
1424 match
= of_match_node(rockchip_pinctrl_dt_match
, node
);
1425 ctrl
= (struct rockchip_pin_ctrl
*)match
->data
;
1427 for_each_child_of_node(node
, np
) {
1428 if (!of_find_property(np
, "gpio-controller", NULL
))
1431 bank
= ctrl
->pin_banks
;
1432 for (i
= 0; i
< ctrl
->nr_banks
; ++i
, ++bank
) {
1433 if (!strcmp(bank
->name
, np
->name
)) {
1436 if (!rockchip_get_bank_data(bank
, &pdev
->dev
))
1444 bank
= ctrl
->pin_banks
;
1445 for (i
= 0; i
< ctrl
->nr_banks
; ++i
, ++bank
) {
1446 spin_lock_init(&bank
->slock
);
1448 bank
->pin_base
= ctrl
->nr_pins
;
1449 ctrl
->nr_pins
+= bank
->nr_pins
;
1455 static int rockchip_pinctrl_probe(struct platform_device
*pdev
)
1457 struct rockchip_pinctrl
*info
;
1458 struct device
*dev
= &pdev
->dev
;
1459 struct rockchip_pin_ctrl
*ctrl
;
1460 struct resource
*res
;
1463 if (!dev
->of_node
) {
1464 dev_err(dev
, "device tree node not found\n");
1468 info
= devm_kzalloc(dev
, sizeof(struct rockchip_pinctrl
), GFP_KERNEL
);
1472 ctrl
= rockchip_pinctrl_get_soc_data(info
, pdev
);
1474 dev_err(dev
, "driver data not available\n");
1480 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1481 info
->reg_base
= devm_ioremap_resource(&pdev
->dev
, res
);
1482 if (IS_ERR(info
->reg_base
))
1483 return PTR_ERR(info
->reg_base
);
1485 /* The RK3188 has its pull registers in a separate place */
1486 if (ctrl
->type
== RK3188
) {
1487 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 1);
1488 info
->reg_pull
= devm_ioremap_resource(&pdev
->dev
, res
);
1489 if (IS_ERR(info
->reg_pull
))
1490 return PTR_ERR(info
->reg_pull
);
1493 ret
= rockchip_gpiolib_register(pdev
, info
);
1497 ret
= rockchip_pinctrl_register(pdev
, info
);
1499 rockchip_gpiolib_unregister(pdev
, info
);
1503 platform_set_drvdata(pdev
, info
);
1508 static struct rockchip_pin_bank rk2928_pin_banks
[] = {
1509 PIN_BANK(0, 32, "gpio0"),
1510 PIN_BANK(1, 32, "gpio1"),
1511 PIN_BANK(2, 32, "gpio2"),
1512 PIN_BANK(3, 32, "gpio3"),
1515 static struct rockchip_pin_ctrl rk2928_pin_ctrl
= {
1516 .pin_banks
= rk2928_pin_banks
,
1517 .nr_banks
= ARRAY_SIZE(rk2928_pin_banks
),
1518 .label
= "RK2928-GPIO",
1521 .pull_calc_reg
= rk2928_calc_pull_reg_and_bit
,
1524 static struct rockchip_pin_bank rk3066a_pin_banks
[] = {
1525 PIN_BANK(0, 32, "gpio0"),
1526 PIN_BANK(1, 32, "gpio1"),
1527 PIN_BANK(2, 32, "gpio2"),
1528 PIN_BANK(3, 32, "gpio3"),
1529 PIN_BANK(4, 32, "gpio4"),
1530 PIN_BANK(6, 16, "gpio6"),
1533 static struct rockchip_pin_ctrl rk3066a_pin_ctrl
= {
1534 .pin_banks
= rk3066a_pin_banks
,
1535 .nr_banks
= ARRAY_SIZE(rk3066a_pin_banks
),
1536 .label
= "RK3066a-GPIO",
1539 .pull_calc_reg
= rk2928_calc_pull_reg_and_bit
,
1542 static struct rockchip_pin_bank rk3066b_pin_banks
[] = {
1543 PIN_BANK(0, 32, "gpio0"),
1544 PIN_BANK(1, 32, "gpio1"),
1545 PIN_BANK(2, 32, "gpio2"),
1546 PIN_BANK(3, 32, "gpio3"),
1549 static struct rockchip_pin_ctrl rk3066b_pin_ctrl
= {
1550 .pin_banks
= rk3066b_pin_banks
,
1551 .nr_banks
= ARRAY_SIZE(rk3066b_pin_banks
),
1552 .label
= "RK3066b-GPIO",
1557 static struct rockchip_pin_bank rk3188_pin_banks
[] = {
1558 PIN_BANK(0, 32, "gpio0"),
1559 PIN_BANK(1, 32, "gpio1"),
1560 PIN_BANK(2, 32, "gpio2"),
1561 PIN_BANK(3, 32, "gpio3"),
1564 static struct rockchip_pin_ctrl rk3188_pin_ctrl
= {
1565 .pin_banks
= rk3188_pin_banks
,
1566 .nr_banks
= ARRAY_SIZE(rk3188_pin_banks
),
1567 .label
= "RK3188-GPIO",
1570 .pull_calc_reg
= rk3188_calc_pull_reg_and_bit
,
1573 static const struct of_device_id rockchip_pinctrl_dt_match
[] = {
1574 { .compatible
= "rockchip,rk2928-pinctrl",
1575 .data
= (void *)&rk2928_pin_ctrl
},
1576 { .compatible
= "rockchip,rk3066a-pinctrl",
1577 .data
= (void *)&rk3066a_pin_ctrl
},
1578 { .compatible
= "rockchip,rk3066b-pinctrl",
1579 .data
= (void *)&rk3066b_pin_ctrl
},
1580 { .compatible
= "rockchip,rk3188-pinctrl",
1581 .data
= (void *)&rk3188_pin_ctrl
},
1584 MODULE_DEVICE_TABLE(of
, rockchip_pinctrl_dt_match
);
1586 static struct platform_driver rockchip_pinctrl_driver
= {
1587 .probe
= rockchip_pinctrl_probe
,
1589 .name
= "rockchip-pinctrl",
1590 .owner
= THIS_MODULE
,
1591 .of_match_table
= rockchip_pinctrl_dt_match
,
1595 static int __init
rockchip_pinctrl_drv_register(void)
1597 return platform_driver_register(&rockchip_pinctrl_driver
);
1599 postcore_initcall(rockchip_pinctrl_drv_register
);
1601 MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
1602 MODULE_DESCRIPTION("Rockchip pinctrl driver");
1603 MODULE_LICENSE("GPL v2");