2 * Copyright (C) 2014-2015 Broadcom Corporation
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * This file contains the Broadcom Cygnus GPIO driver that supports 3
14 * GPIO controllers on Cygnus including the ASIU GPIO controller, the
15 * chipCommonG GPIO controller, and the always-on GPIO controller. Basic
16 * PINCONF such as bias pull up/down, and drive strength are also supported
19 * Pins from the ASIU GPIO can be individually muxed to GPIO function,
20 * through the interaction with the Cygnus IOMUX controller
23 #include <linux/kernel.h>
24 #include <linux/slab.h>
25 #include <linux/interrupt.h>
27 #include <linux/gpio.h>
28 #include <linux/ioport.h>
29 #include <linux/of_device.h>
30 #include <linux/of_irq.h>
31 #include <linux/pinctrl/pinctrl.h>
32 #include <linux/pinctrl/pinconf.h>
33 #include <linux/pinctrl/pinconf-generic.h>
35 #include "../pinctrl-utils.h"
37 #define CYGNUS_GPIO_DATA_IN_OFFSET 0x00
38 #define CYGNUS_GPIO_DATA_OUT_OFFSET 0x04
39 #define CYGNUS_GPIO_OUT_EN_OFFSET 0x08
40 #define CYGNUS_GPIO_INT_TYPE_OFFSET 0x0c
41 #define CYGNUS_GPIO_INT_DE_OFFSET 0x10
42 #define CYGNUS_GPIO_INT_EDGE_OFFSET 0x14
43 #define CYGNUS_GPIO_INT_MSK_OFFSET 0x18
44 #define CYGNUS_GPIO_INT_STAT_OFFSET 0x1c
45 #define CYGNUS_GPIO_INT_MSTAT_OFFSET 0x20
46 #define CYGNUS_GPIO_INT_CLR_OFFSET 0x24
47 #define CYGNUS_GPIO_PAD_RES_OFFSET 0x34
48 #define CYGNUS_GPIO_RES_EN_OFFSET 0x38
50 /* drive strength control for ASIU GPIO */
51 #define CYGNUS_GPIO_ASIU_DRV0_CTRL_OFFSET 0x58
53 /* drive strength control for CCM/CRMU (AON) GPIO */
54 #define CYGNUS_GPIO_DRV0_CTRL_OFFSET 0x00
56 #define GPIO_BANK_SIZE 0x200
57 #define NGPIOS_PER_BANK 32
58 #define GPIO_BANK(pin) ((pin) / NGPIOS_PER_BANK)
60 #define CYGNUS_GPIO_REG(pin, reg) (GPIO_BANK(pin) * GPIO_BANK_SIZE + (reg))
61 #define CYGNUS_GPIO_SHIFT(pin) ((pin) % NGPIOS_PER_BANK)
63 #define GPIO_DRV_STRENGTH_BIT_SHIFT 20
64 #define GPIO_DRV_STRENGTH_BITS 3
65 #define GPIO_DRV_STRENGTH_BIT_MASK ((1 << GPIO_DRV_STRENGTH_BITS) - 1)
70 * @dev: pointer to device
71 * @base: I/O register base for Cygnus GPIO controller
72 * @io_ctrl: I/O register base for certain type of Cygnus GPIO controller that
73 * has the PINCONF support implemented outside of the GPIO block
74 * @lock: lock to protect access to I/O registers
76 * @num_banks: number of GPIO banks, each bank supports up to 32 GPIOs
77 * @pinmux_is_supported: flag to indicate this GPIO controller contains pins
78 * that can be individually muxed to GPIO
79 * @pctl: pointer to pinctrl_dev
80 * @pctldesc: pinctrl descriptor
86 void __iomem
*io_ctrl
;
93 bool pinmux_is_supported
;
95 struct pinctrl_dev
*pctl
;
96 struct pinctrl_desc pctldesc
;
99 static inline struct cygnus_gpio
*to_cygnus_gpio(struct gpio_chip
*gc
)
101 return container_of(gc
, struct cygnus_gpio
, gc
);
105 * Mapping from PINCONF pins to GPIO pins is 1-to-1
107 static inline unsigned cygnus_pin_to_gpio(unsigned pin
)
113 * cygnus_set_bit - set or clear one bit (corresponding to the GPIO pin) in a
114 * Cygnus GPIO register
116 * @cygnus_gpio: Cygnus GPIO device
117 * @reg: register offset
121 static inline void cygnus_set_bit(struct cygnus_gpio
*chip
, unsigned int reg
,
122 unsigned gpio
, bool set
)
124 unsigned int offset
= CYGNUS_GPIO_REG(gpio
, reg
);
125 unsigned int shift
= CYGNUS_GPIO_SHIFT(gpio
);
128 val
= readl(chip
->base
+ offset
);
133 writel(val
, chip
->base
+ offset
);
136 static inline bool cygnus_get_bit(struct cygnus_gpio
*chip
, unsigned int reg
,
139 unsigned int offset
= CYGNUS_GPIO_REG(gpio
, reg
);
140 unsigned int shift
= CYGNUS_GPIO_SHIFT(gpio
);
142 return !!(readl(chip
->base
+ offset
) & BIT(shift
));
145 static void cygnus_gpio_irq_handler(struct irq_desc
*desc
)
147 struct gpio_chip
*gc
= irq_desc_get_handler_data(desc
);
148 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
149 struct irq_chip
*irq_chip
= irq_desc_get_chip(desc
);
152 chained_irq_enter(irq_chip
, desc
);
154 /* go through the entire GPIO banks and handle all interrupts */
155 for (i
= 0; i
< chip
->num_banks
; i
++) {
156 unsigned long val
= readl(chip
->base
+ (i
* GPIO_BANK_SIZE
) +
157 CYGNUS_GPIO_INT_MSTAT_OFFSET
);
159 for_each_set_bit(bit
, &val
, NGPIOS_PER_BANK
) {
160 unsigned pin
= NGPIOS_PER_BANK
* i
+ bit
;
161 int child_irq
= irq_find_mapping(gc
->irqdomain
, pin
);
164 * Clear the interrupt before invoking the
165 * handler, so we do not leave any window
167 writel(BIT(bit
), chip
->base
+ (i
* GPIO_BANK_SIZE
) +
168 CYGNUS_GPIO_INT_CLR_OFFSET
);
170 generic_handle_irq(child_irq
);
174 chained_irq_exit(irq_chip
, desc
);
178 static void cygnus_gpio_irq_ack(struct irq_data
*d
)
180 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
181 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
182 unsigned gpio
= d
->hwirq
;
183 unsigned int offset
= CYGNUS_GPIO_REG(gpio
,
184 CYGNUS_GPIO_INT_CLR_OFFSET
);
185 unsigned int shift
= CYGNUS_GPIO_SHIFT(gpio
);
186 u32 val
= BIT(shift
);
188 writel(val
, chip
->base
+ offset
);
192 * cygnus_gpio_irq_set_mask - mask/unmask a GPIO interrupt
195 * @unmask: mask/unmask GPIO interrupt
197 static void cygnus_gpio_irq_set_mask(struct irq_data
*d
, bool unmask
)
199 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
200 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
201 unsigned gpio
= d
->hwirq
;
203 cygnus_set_bit(chip
, CYGNUS_GPIO_INT_MSK_OFFSET
, gpio
, unmask
);
206 static void cygnus_gpio_irq_mask(struct irq_data
*d
)
208 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
209 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
212 spin_lock_irqsave(&chip
->lock
, flags
);
213 cygnus_gpio_irq_set_mask(d
, false);
214 spin_unlock_irqrestore(&chip
->lock
, flags
);
217 static void cygnus_gpio_irq_unmask(struct irq_data
*d
)
219 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
220 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
223 spin_lock_irqsave(&chip
->lock
, flags
);
224 cygnus_gpio_irq_set_mask(d
, true);
225 spin_unlock_irqrestore(&chip
->lock
, flags
);
228 static int cygnus_gpio_irq_set_type(struct irq_data
*d
, unsigned int type
)
230 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
231 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
232 unsigned gpio
= d
->hwirq
;
233 bool level_triggered
= false;
234 bool dual_edge
= false;
235 bool rising_or_high
= false;
238 switch (type
& IRQ_TYPE_SENSE_MASK
) {
239 case IRQ_TYPE_EDGE_RISING
:
240 rising_or_high
= true;
243 case IRQ_TYPE_EDGE_FALLING
:
246 case IRQ_TYPE_EDGE_BOTH
:
250 case IRQ_TYPE_LEVEL_HIGH
:
251 level_triggered
= true;
252 rising_or_high
= true;
255 case IRQ_TYPE_LEVEL_LOW
:
256 level_triggered
= true;
260 dev_err(chip
->dev
, "invalid GPIO IRQ type 0x%x\n",
265 spin_lock_irqsave(&chip
->lock
, flags
);
266 cygnus_set_bit(chip
, CYGNUS_GPIO_INT_TYPE_OFFSET
, gpio
,
268 cygnus_set_bit(chip
, CYGNUS_GPIO_INT_DE_OFFSET
, gpio
, dual_edge
);
269 cygnus_set_bit(chip
, CYGNUS_GPIO_INT_EDGE_OFFSET
, gpio
,
271 spin_unlock_irqrestore(&chip
->lock
, flags
);
274 "gpio:%u level_triggered:%d dual_edge:%d rising_or_high:%d\n",
275 gpio
, level_triggered
, dual_edge
, rising_or_high
);
280 static struct irq_chip cygnus_gpio_irq_chip
= {
281 .name
= "bcm-cygnus-gpio",
282 .irq_ack
= cygnus_gpio_irq_ack
,
283 .irq_mask
= cygnus_gpio_irq_mask
,
284 .irq_unmask
= cygnus_gpio_irq_unmask
,
285 .irq_set_type
= cygnus_gpio_irq_set_type
,
289 * Request the Cygnus IOMUX pinmux controller to mux individual pins to GPIO
291 static int cygnus_gpio_request(struct gpio_chip
*gc
, unsigned offset
)
293 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
294 unsigned gpio
= gc
->base
+ offset
;
296 /* not all Cygnus GPIO pins can be muxed individually */
297 if (!chip
->pinmux_is_supported
)
300 return pinctrl_request_gpio(gpio
);
303 static void cygnus_gpio_free(struct gpio_chip
*gc
, unsigned offset
)
305 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
306 unsigned gpio
= gc
->base
+ offset
;
308 if (!chip
->pinmux_is_supported
)
311 pinctrl_free_gpio(gpio
);
314 static int cygnus_gpio_direction_input(struct gpio_chip
*gc
, unsigned gpio
)
316 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
319 spin_lock_irqsave(&chip
->lock
, flags
);
320 cygnus_set_bit(chip
, CYGNUS_GPIO_OUT_EN_OFFSET
, gpio
, false);
321 spin_unlock_irqrestore(&chip
->lock
, flags
);
323 dev_dbg(chip
->dev
, "gpio:%u set input\n", gpio
);
328 static int cygnus_gpio_direction_output(struct gpio_chip
*gc
, unsigned gpio
,
331 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
334 spin_lock_irqsave(&chip
->lock
, flags
);
335 cygnus_set_bit(chip
, CYGNUS_GPIO_OUT_EN_OFFSET
, gpio
, true);
336 cygnus_set_bit(chip
, CYGNUS_GPIO_DATA_OUT_OFFSET
, gpio
, !!(val
));
337 spin_unlock_irqrestore(&chip
->lock
, flags
);
339 dev_dbg(chip
->dev
, "gpio:%u set output, value:%d\n", gpio
, val
);
344 static void cygnus_gpio_set(struct gpio_chip
*gc
, unsigned gpio
, int val
)
346 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
349 spin_lock_irqsave(&chip
->lock
, flags
);
350 cygnus_set_bit(chip
, CYGNUS_GPIO_DATA_OUT_OFFSET
, gpio
, !!(val
));
351 spin_unlock_irqrestore(&chip
->lock
, flags
);
353 dev_dbg(chip
->dev
, "gpio:%u set, value:%d\n", gpio
, val
);
356 static int cygnus_gpio_get(struct gpio_chip
*gc
, unsigned gpio
)
358 struct cygnus_gpio
*chip
= to_cygnus_gpio(gc
);
359 unsigned int offset
= CYGNUS_GPIO_REG(gpio
,
360 CYGNUS_GPIO_DATA_IN_OFFSET
);
361 unsigned int shift
= CYGNUS_GPIO_SHIFT(gpio
);
363 return !!(readl(chip
->base
+ offset
) & BIT(shift
));
366 static int cygnus_get_groups_count(struct pinctrl_dev
*pctldev
)
372 * Only one group: "gpio_grp", since this local pinctrl device only performs
373 * GPIO specific PINCONF configurations
375 static const char *cygnus_get_group_name(struct pinctrl_dev
*pctldev
,
381 static const struct pinctrl_ops cygnus_pctrl_ops
= {
382 .get_groups_count
= cygnus_get_groups_count
,
383 .get_group_name
= cygnus_get_group_name
,
384 .dt_node_to_map
= pinconf_generic_dt_node_to_map_pin
,
385 .dt_free_map
= pinctrl_utils_dt_free_map
,
388 static int cygnus_gpio_set_pull(struct cygnus_gpio
*chip
, unsigned gpio
,
389 bool disable
, bool pull_up
)
393 spin_lock_irqsave(&chip
->lock
, flags
);
396 cygnus_set_bit(chip
, CYGNUS_GPIO_RES_EN_OFFSET
, gpio
, false);
398 cygnus_set_bit(chip
, CYGNUS_GPIO_PAD_RES_OFFSET
, gpio
,
400 cygnus_set_bit(chip
, CYGNUS_GPIO_RES_EN_OFFSET
, gpio
, true);
403 spin_unlock_irqrestore(&chip
->lock
, flags
);
405 dev_dbg(chip
->dev
, "gpio:%u set pullup:%d\n", gpio
, pull_up
);
410 static void cygnus_gpio_get_pull(struct cygnus_gpio
*chip
, unsigned gpio
,
411 bool *disable
, bool *pull_up
)
415 spin_lock_irqsave(&chip
->lock
, flags
);
416 *disable
= !cygnus_get_bit(chip
, CYGNUS_GPIO_RES_EN_OFFSET
, gpio
);
417 *pull_up
= cygnus_get_bit(chip
, CYGNUS_GPIO_PAD_RES_OFFSET
, gpio
);
418 spin_unlock_irqrestore(&chip
->lock
, flags
);
421 static int cygnus_gpio_set_strength(struct cygnus_gpio
*chip
, unsigned gpio
,
425 unsigned int i
, offset
, shift
;
429 /* make sure drive strength is supported */
430 if (strength
< 2 || strength
> 16 || (strength
% 2))
434 base
= chip
->io_ctrl
;
435 offset
= CYGNUS_GPIO_DRV0_CTRL_OFFSET
;
438 offset
= CYGNUS_GPIO_REG(gpio
,
439 CYGNUS_GPIO_ASIU_DRV0_CTRL_OFFSET
);
442 shift
= CYGNUS_GPIO_SHIFT(gpio
);
444 dev_dbg(chip
->dev
, "gpio:%u set drive strength:%d mA\n", gpio
,
447 spin_lock_irqsave(&chip
->lock
, flags
);
448 strength
= (strength
/ 2) - 1;
449 for (i
= 0; i
< GPIO_DRV_STRENGTH_BITS
; i
++) {
450 val
= readl(base
+ offset
);
452 val
|= ((strength
>> i
) & 0x1) << shift
;
453 writel(val
, base
+ offset
);
456 spin_unlock_irqrestore(&chip
->lock
, flags
);
461 static int cygnus_gpio_get_strength(struct cygnus_gpio
*chip
, unsigned gpio
,
465 unsigned int i
, offset
, shift
;
470 base
= chip
->io_ctrl
;
471 offset
= CYGNUS_GPIO_DRV0_CTRL_OFFSET
;
474 offset
= CYGNUS_GPIO_REG(gpio
,
475 CYGNUS_GPIO_ASIU_DRV0_CTRL_OFFSET
);
478 shift
= CYGNUS_GPIO_SHIFT(gpio
);
480 spin_lock_irqsave(&chip
->lock
, flags
);
482 for (i
= 0; i
< GPIO_DRV_STRENGTH_BITS
; i
++) {
483 val
= readl(base
+ offset
) & BIT(shift
);
485 *strength
+= (val
<< i
);
490 *strength
= (*strength
+ 1) * 2;
491 spin_unlock_irqrestore(&chip
->lock
, flags
);
496 static int cygnus_pin_config_get(struct pinctrl_dev
*pctldev
, unsigned pin
,
497 unsigned long *config
)
499 struct cygnus_gpio
*chip
= pinctrl_dev_get_drvdata(pctldev
);
500 enum pin_config_param param
= pinconf_to_config_param(*config
);
501 unsigned gpio
= cygnus_pin_to_gpio(pin
);
503 bool disable
, pull_up
;
507 case PIN_CONFIG_BIAS_DISABLE
:
508 cygnus_gpio_get_pull(chip
, gpio
, &disable
, &pull_up
);
514 case PIN_CONFIG_BIAS_PULL_UP
:
515 cygnus_gpio_get_pull(chip
, gpio
, &disable
, &pull_up
);
516 if (!disable
&& pull_up
)
521 case PIN_CONFIG_BIAS_PULL_DOWN
:
522 cygnus_gpio_get_pull(chip
, gpio
, &disable
, &pull_up
);
523 if (!disable
&& !pull_up
)
528 case PIN_CONFIG_DRIVE_STRENGTH
:
529 ret
= cygnus_gpio_get_strength(chip
, gpio
, &arg
);
533 *config
= pinconf_to_config_packed(param
, arg
);
544 static int cygnus_pin_config_set(struct pinctrl_dev
*pctldev
, unsigned pin
,
545 unsigned long *configs
, unsigned num_configs
)
547 struct cygnus_gpio
*chip
= pinctrl_dev_get_drvdata(pctldev
);
548 enum pin_config_param param
;
550 unsigned i
, gpio
= cygnus_pin_to_gpio(pin
);
553 for (i
= 0; i
< num_configs
; i
++) {
554 param
= pinconf_to_config_param(configs
[i
]);
555 arg
= pinconf_to_config_argument(configs
[i
]);
558 case PIN_CONFIG_BIAS_DISABLE
:
559 ret
= cygnus_gpio_set_pull(chip
, gpio
, true, false);
564 case PIN_CONFIG_BIAS_PULL_UP
:
565 ret
= cygnus_gpio_set_pull(chip
, gpio
, false, true);
570 case PIN_CONFIG_BIAS_PULL_DOWN
:
571 ret
= cygnus_gpio_set_pull(chip
, gpio
, false, false);
576 case PIN_CONFIG_DRIVE_STRENGTH
:
577 ret
= cygnus_gpio_set_strength(chip
, gpio
, arg
);
583 dev_err(chip
->dev
, "invalid configuration\n");
586 } /* for each config */
592 static const struct pinconf_ops cygnus_pconf_ops
= {
594 .pin_config_get
= cygnus_pin_config_get
,
595 .pin_config_set
= cygnus_pin_config_set
,
599 * Cygnus GPIO controller supports some PINCONF related configurations such as
600 * pull up, pull down, and drive strength, when the pin is configured to GPIO
602 * Here a local pinctrl device is created with simple 1-to-1 pin mapping to the
605 static int cygnus_gpio_register_pinconf(struct cygnus_gpio
*chip
)
607 struct pinctrl_desc
*pctldesc
= &chip
->pctldesc
;
608 struct pinctrl_pin_desc
*pins
;
609 struct gpio_chip
*gc
= &chip
->gc
;
612 pins
= devm_kcalloc(chip
->dev
, gc
->ngpio
, sizeof(*pins
), GFP_KERNEL
);
616 for (i
= 0; i
< gc
->ngpio
; i
++) {
618 pins
[i
].name
= devm_kasprintf(chip
->dev
, GFP_KERNEL
,
624 pctldesc
->name
= dev_name(chip
->dev
);
625 pctldesc
->pctlops
= &cygnus_pctrl_ops
;
626 pctldesc
->pins
= pins
;
627 pctldesc
->npins
= gc
->ngpio
;
628 pctldesc
->confops
= &cygnus_pconf_ops
;
630 chip
->pctl
= pinctrl_register(pctldesc
, chip
->dev
, chip
);
631 if (IS_ERR(chip
->pctl
)) {
632 dev_err(chip
->dev
, "unable to register pinctrl device\n");
633 return PTR_ERR(chip
->pctl
);
639 static void cygnus_gpio_unregister_pinconf(struct cygnus_gpio
*chip
)
642 pinctrl_unregister(chip
->pctl
);
645 struct cygnus_gpio_data
{
649 static const struct cygnus_gpio_data cygnus_cmm_gpio_data
= {
653 static const struct cygnus_gpio_data cygnus_asiu_gpio_data
= {
657 static const struct cygnus_gpio_data cygnus_crmu_gpio_data
= {
661 static const struct of_device_id cygnus_gpio_of_match
[] = {
663 .compatible
= "brcm,cygnus-ccm-gpio",
664 .data
= &cygnus_cmm_gpio_data
,
667 .compatible
= "brcm,cygnus-asiu-gpio",
668 .data
= &cygnus_asiu_gpio_data
,
671 .compatible
= "brcm,cygnus-crmu-gpio",
672 .data
= &cygnus_crmu_gpio_data
,
676 static int cygnus_gpio_probe(struct platform_device
*pdev
)
678 struct device
*dev
= &pdev
->dev
;
679 struct resource
*res
;
680 struct cygnus_gpio
*chip
;
681 struct gpio_chip
*gc
;
684 const struct of_device_id
*match
;
685 const struct cygnus_gpio_data
*gpio_data
;
687 match
= of_match_device(cygnus_gpio_of_match
, dev
);
690 gpio_data
= match
->data
;
691 ngpios
= gpio_data
->num_gpios
;
693 chip
= devm_kzalloc(dev
, sizeof(*chip
), GFP_KERNEL
);
698 platform_set_drvdata(pdev
, chip
);
700 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
701 chip
->base
= devm_ioremap_resource(dev
, res
);
702 if (IS_ERR(chip
->base
)) {
703 dev_err(dev
, "unable to map I/O memory\n");
704 return PTR_ERR(chip
->base
);
707 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 1);
709 chip
->io_ctrl
= devm_ioremap_resource(dev
, res
);
710 if (IS_ERR(chip
->io_ctrl
)) {
711 dev_err(dev
, "unable to map I/O memory\n");
712 return PTR_ERR(chip
->io_ctrl
);
716 spin_lock_init(&chip
->lock
);
721 chip
->num_banks
= (ngpios
+ NGPIOS_PER_BANK
- 1) / NGPIOS_PER_BANK
;
722 gc
->label
= dev_name(dev
);
724 gc
->of_node
= dev
->of_node
;
725 gc
->request
= cygnus_gpio_request
;
726 gc
->free
= cygnus_gpio_free
;
727 gc
->direction_input
= cygnus_gpio_direction_input
;
728 gc
->direction_output
= cygnus_gpio_direction_output
;
729 gc
->set
= cygnus_gpio_set
;
730 gc
->get
= cygnus_gpio_get
;
732 chip
->pinmux_is_supported
= of_property_read_bool(dev
->of_node
,
735 ret
= gpiochip_add(gc
);
737 dev_err(dev
, "unable to add GPIO chip\n");
741 ret
= cygnus_gpio_register_pinconf(chip
);
743 dev_err(dev
, "unable to register pinconf\n");
744 goto err_rm_gpiochip
;
747 /* optional GPIO interrupt support */
748 irq
= platform_get_irq(pdev
, 0);
750 ret
= gpiochip_irqchip_add(gc
, &cygnus_gpio_irq_chip
, 0,
751 handle_simple_irq
, IRQ_TYPE_NONE
);
753 dev_err(dev
, "no GPIO irqchip\n");
754 goto err_unregister_pinconf
;
757 gpiochip_set_chained_irqchip(gc
, &cygnus_gpio_irq_chip
, irq
,
758 cygnus_gpio_irq_handler
);
763 err_unregister_pinconf
:
764 cygnus_gpio_unregister_pinconf(chip
);
772 static struct platform_driver cygnus_gpio_driver
= {
774 .name
= "cygnus-gpio",
775 .of_match_table
= cygnus_gpio_of_match
,
777 .probe
= cygnus_gpio_probe
,
780 static int __init
cygnus_gpio_init(void)
782 return platform_driver_probe(&cygnus_gpio_driver
, cygnus_gpio_probe
);
784 arch_initcall_sync(cygnus_gpio_init
);