2 * Copyright (c) 2016-2017 NVIDIA Corporation
4 * Author: Thierry Reding <treding@nvidia.com>
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
11 #include <linux/gpio/driver.h>
12 #include <linux/interrupt.h>
13 #include <linux/irq.h>
14 #include <linux/module.h>
15 #include <linux/of_device.h>
16 #include <linux/platform_device.h>
18 #include <dt-bindings/gpio/tegra186-gpio.h>
19 #include <dt-bindings/gpio/tegra194-gpio.h>
21 #define TEGRA186_GPIO_ENABLE_CONFIG 0x00
22 #define TEGRA186_GPIO_ENABLE_CONFIG_ENABLE BIT(0)
23 #define TEGRA186_GPIO_ENABLE_CONFIG_OUT BIT(1)
24 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_NONE (0x0 << 2)
25 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_LEVEL (0x1 << 2)
26 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE (0x2 << 2)
27 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_DOUBLE_EDGE (0x3 << 2)
28 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_MASK (0x3 << 2)
29 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL BIT(4)
30 #define TEGRA186_GPIO_ENABLE_CONFIG_INTERRUPT BIT(6)
32 #define TEGRA186_GPIO_DEBOUNCE_CONTROL 0x04
33 #define TEGRA186_GPIO_DEBOUNCE_CONTROL_THRESHOLD(x) ((x) & 0xff)
35 #define TEGRA186_GPIO_INPUT 0x08
36 #define TEGRA186_GPIO_INPUT_HIGH BIT(0)
38 #define TEGRA186_GPIO_OUTPUT_CONTROL 0x0c
39 #define TEGRA186_GPIO_OUTPUT_CONTROL_FLOATED BIT(0)
41 #define TEGRA186_GPIO_OUTPUT_VALUE 0x10
42 #define TEGRA186_GPIO_OUTPUT_VALUE_HIGH BIT(0)
44 #define TEGRA186_GPIO_INTERRUPT_CLEAR 0x14
46 #define TEGRA186_GPIO_INTERRUPT_STATUS(x) (0x100 + (x) * 4)
48 struct tegra_gpio_port
{
55 struct tegra_gpio_soc
{
56 const struct tegra_gpio_port
*ports
;
57 unsigned int num_ports
;
62 struct gpio_chip gpio
;
67 const struct tegra_gpio_soc
*soc
;
72 static const struct tegra_gpio_port
*
73 tegra186_gpio_get_port(struct tegra_gpio
*gpio
, unsigned int *pin
)
75 unsigned int start
= 0, i
;
77 for (i
= 0; i
< gpio
->soc
->num_ports
; i
++) {
78 const struct tegra_gpio_port
*port
= &gpio
->soc
->ports
[i
];
80 if (*pin
>= start
&& *pin
< start
+ port
->pins
) {
91 static void __iomem
*tegra186_gpio_get_base(struct tegra_gpio
*gpio
,
94 const struct tegra_gpio_port
*port
;
96 port
= tegra186_gpio_get_port(gpio
, &pin
);
100 return gpio
->base
+ port
->offset
+ pin
* 0x20;
103 static int tegra186_gpio_get_direction(struct gpio_chip
*chip
,
106 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
110 base
= tegra186_gpio_get_base(gpio
, offset
);
111 if (WARN_ON(base
== NULL
))
114 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
115 if (value
& TEGRA186_GPIO_ENABLE_CONFIG_OUT
)
121 static int tegra186_gpio_direction_input(struct gpio_chip
*chip
,
124 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
128 base
= tegra186_gpio_get_base(gpio
, offset
);
129 if (WARN_ON(base
== NULL
))
132 value
= readl(base
+ TEGRA186_GPIO_OUTPUT_CONTROL
);
133 value
|= TEGRA186_GPIO_OUTPUT_CONTROL_FLOATED
;
134 writel(value
, base
+ TEGRA186_GPIO_OUTPUT_CONTROL
);
136 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
137 value
|= TEGRA186_GPIO_ENABLE_CONFIG_ENABLE
;
138 value
&= ~TEGRA186_GPIO_ENABLE_CONFIG_OUT
;
139 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
144 static int tegra186_gpio_direction_output(struct gpio_chip
*chip
,
145 unsigned int offset
, int level
)
147 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
151 /* configure output level first */
152 chip
->set(chip
, offset
, level
);
154 base
= tegra186_gpio_get_base(gpio
, offset
);
155 if (WARN_ON(base
== NULL
))
158 /* set the direction */
159 value
= readl(base
+ TEGRA186_GPIO_OUTPUT_CONTROL
);
160 value
&= ~TEGRA186_GPIO_OUTPUT_CONTROL_FLOATED
;
161 writel(value
, base
+ TEGRA186_GPIO_OUTPUT_CONTROL
);
163 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
164 value
|= TEGRA186_GPIO_ENABLE_CONFIG_ENABLE
;
165 value
|= TEGRA186_GPIO_ENABLE_CONFIG_OUT
;
166 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
171 static int tegra186_gpio_get(struct gpio_chip
*chip
, unsigned int offset
)
173 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
177 base
= tegra186_gpio_get_base(gpio
, offset
);
178 if (WARN_ON(base
== NULL
))
181 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
182 if (value
& TEGRA186_GPIO_ENABLE_CONFIG_OUT
)
183 value
= readl(base
+ TEGRA186_GPIO_OUTPUT_VALUE
);
185 value
= readl(base
+ TEGRA186_GPIO_INPUT
);
187 return value
& BIT(0);
190 static void tegra186_gpio_set(struct gpio_chip
*chip
, unsigned int offset
,
193 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
197 base
= tegra186_gpio_get_base(gpio
, offset
);
198 if (WARN_ON(base
== NULL
))
201 value
= readl(base
+ TEGRA186_GPIO_OUTPUT_VALUE
);
203 value
&= ~TEGRA186_GPIO_OUTPUT_VALUE_HIGH
;
205 value
|= TEGRA186_GPIO_OUTPUT_VALUE_HIGH
;
207 writel(value
, base
+ TEGRA186_GPIO_OUTPUT_VALUE
);
210 static int tegra186_gpio_of_xlate(struct gpio_chip
*chip
,
211 const struct of_phandle_args
*spec
,
214 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
215 unsigned int port
, pin
, i
, offset
= 0;
217 if (WARN_ON(chip
->of_gpio_n_cells
< 2))
220 if (WARN_ON(spec
->args_count
< chip
->of_gpio_n_cells
))
223 port
= spec
->args
[0] / 8;
224 pin
= spec
->args
[0] % 8;
226 if (port
>= gpio
->soc
->num_ports
) {
227 dev_err(chip
->parent
, "invalid port number: %u\n", port
);
231 for (i
= 0; i
< port
; i
++)
232 offset
+= gpio
->soc
->ports
[i
].pins
;
235 *flags
= spec
->args
[1];
240 static void tegra186_irq_ack(struct irq_data
*data
)
242 struct tegra_gpio
*gpio
= irq_data_get_irq_chip_data(data
);
245 base
= tegra186_gpio_get_base(gpio
, data
->hwirq
);
246 if (WARN_ON(base
== NULL
))
249 writel(1, base
+ TEGRA186_GPIO_INTERRUPT_CLEAR
);
252 static void tegra186_irq_mask(struct irq_data
*data
)
254 struct tegra_gpio
*gpio
= irq_data_get_irq_chip_data(data
);
258 base
= tegra186_gpio_get_base(gpio
, data
->hwirq
);
259 if (WARN_ON(base
== NULL
))
262 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
263 value
&= ~TEGRA186_GPIO_ENABLE_CONFIG_INTERRUPT
;
264 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
267 static void tegra186_irq_unmask(struct irq_data
*data
)
269 struct tegra_gpio
*gpio
= irq_data_get_irq_chip_data(data
);
273 base
= tegra186_gpio_get_base(gpio
, data
->hwirq
);
274 if (WARN_ON(base
== NULL
))
277 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
278 value
|= TEGRA186_GPIO_ENABLE_CONFIG_INTERRUPT
;
279 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
282 static int tegra186_irq_set_type(struct irq_data
*data
, unsigned int flow
)
284 struct tegra_gpio
*gpio
= irq_data_get_irq_chip_data(data
);
288 base
= tegra186_gpio_get_base(gpio
, data
->hwirq
);
289 if (WARN_ON(base
== NULL
))
292 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
293 value
&= ~TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_MASK
;
294 value
&= ~TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL
;
296 switch (flow
& IRQ_TYPE_SENSE_MASK
) {
300 case IRQ_TYPE_EDGE_RISING
:
301 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE
;
302 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL
;
305 case IRQ_TYPE_EDGE_FALLING
:
306 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE
;
309 case IRQ_TYPE_EDGE_BOTH
:
310 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_DOUBLE_EDGE
;
313 case IRQ_TYPE_LEVEL_HIGH
:
314 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_LEVEL
;
315 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL
;
318 case IRQ_TYPE_LEVEL_LOW
:
319 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_LEVEL
;
326 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
328 if ((flow
& IRQ_TYPE_EDGE_BOTH
) == 0)
329 irq_set_handler_locked(data
, handle_level_irq
);
331 irq_set_handler_locked(data
, handle_edge_irq
);
336 static void tegra186_gpio_irq(struct irq_desc
*desc
)
338 struct tegra_gpio
*gpio
= irq_desc_get_handler_data(desc
);
339 struct irq_domain
*domain
= gpio
->gpio
.irq
.domain
;
340 struct irq_chip
*chip
= irq_desc_get_chip(desc
);
341 unsigned int parent
= irq_desc_get_irq(desc
);
342 unsigned int i
, offset
= 0;
344 chained_irq_enter(chip
, desc
);
346 for (i
= 0; i
< gpio
->soc
->num_ports
; i
++) {
347 const struct tegra_gpio_port
*port
= &gpio
->soc
->ports
[i
];
348 void __iomem
*base
= gpio
->base
+ port
->offset
;
349 unsigned int pin
, irq
;
352 /* skip ports that are not associated with this controller */
353 if (parent
!= gpio
->irq
[port
->irq
])
356 value
= readl(base
+ TEGRA186_GPIO_INTERRUPT_STATUS(1));
358 for_each_set_bit(pin
, &value
, port
->pins
) {
359 irq
= irq_find_mapping(domain
, offset
+ pin
);
360 if (WARN_ON(irq
== 0))
363 generic_handle_irq(irq
);
367 offset
+= port
->pins
;
370 chained_irq_exit(chip
, desc
);
373 static int tegra186_gpio_irq_domain_xlate(struct irq_domain
*domain
,
374 struct device_node
*np
,
375 const u32
*spec
, unsigned int size
,
376 unsigned long *hwirq
,
379 struct tegra_gpio
*gpio
= gpiochip_get_data(domain
->host_data
);
380 unsigned int port
, pin
, i
, offset
= 0;
388 if (port
>= gpio
->soc
->num_ports
) {
389 dev_err(gpio
->gpio
.parent
, "invalid port number: %u\n", port
);
393 for (i
= 0; i
< port
; i
++)
394 offset
+= gpio
->soc
->ports
[i
].pins
;
396 *type
= spec
[1] & IRQ_TYPE_SENSE_MASK
;
397 *hwirq
= offset
+ pin
;
402 static const struct irq_domain_ops tegra186_gpio_irq_domain_ops
= {
403 .map
= gpiochip_irq_map
,
404 .unmap
= gpiochip_irq_unmap
,
405 .xlate
= tegra186_gpio_irq_domain_xlate
,
408 static int tegra186_gpio_probe(struct platform_device
*pdev
)
410 unsigned int i
, j
, offset
;
411 struct gpio_irq_chip
*irq
;
412 struct tegra_gpio
*gpio
;
413 struct resource
*res
;
417 gpio
= devm_kzalloc(&pdev
->dev
, sizeof(*gpio
), GFP_KERNEL
);
421 gpio
->soc
= of_device_get_match_data(&pdev
->dev
);
423 res
= platform_get_resource_byname(pdev
, IORESOURCE_MEM
, "gpio");
424 gpio
->base
= devm_ioremap_resource(&pdev
->dev
, res
);
425 if (IS_ERR(gpio
->base
))
426 return PTR_ERR(gpio
->base
);
428 err
= platform_irq_count(pdev
);
434 gpio
->irq
= devm_kcalloc(&pdev
->dev
, gpio
->num_irq
, sizeof(*gpio
->irq
),
439 for (i
= 0; i
< gpio
->num_irq
; i
++) {
440 err
= platform_get_irq(pdev
, i
);
447 gpio
->gpio
.label
= gpio
->soc
->name
;
448 gpio
->gpio
.parent
= &pdev
->dev
;
450 gpio
->gpio
.get_direction
= tegra186_gpio_get_direction
;
451 gpio
->gpio
.direction_input
= tegra186_gpio_direction_input
;
452 gpio
->gpio
.direction_output
= tegra186_gpio_direction_output
;
453 gpio
->gpio
.get
= tegra186_gpio_get
,
454 gpio
->gpio
.set
= tegra186_gpio_set
;
456 gpio
->gpio
.base
= -1;
458 for (i
= 0; i
< gpio
->soc
->num_ports
; i
++)
459 gpio
->gpio
.ngpio
+= gpio
->soc
->ports
[i
].pins
;
461 names
= devm_kcalloc(gpio
->gpio
.parent
, gpio
->gpio
.ngpio
,
462 sizeof(*names
), GFP_KERNEL
);
466 for (i
= 0, offset
= 0; i
< gpio
->soc
->num_ports
; i
++) {
467 const struct tegra_gpio_port
*port
= &gpio
->soc
->ports
[i
];
470 for (j
= 0; j
< port
->pins
; j
++) {
471 name
= devm_kasprintf(gpio
->gpio
.parent
, GFP_KERNEL
,
472 "P%s.%02x", port
->name
, j
);
476 names
[offset
+ j
] = name
;
479 offset
+= port
->pins
;
482 gpio
->gpio
.names
= (const char * const *)names
;
484 gpio
->gpio
.of_node
= pdev
->dev
.of_node
;
485 gpio
->gpio
.of_gpio_n_cells
= 2;
486 gpio
->gpio
.of_xlate
= tegra186_gpio_of_xlate
;
488 gpio
->intc
.name
= pdev
->dev
.of_node
->name
;
489 gpio
->intc
.irq_ack
= tegra186_irq_ack
;
490 gpio
->intc
.irq_mask
= tegra186_irq_mask
;
491 gpio
->intc
.irq_unmask
= tegra186_irq_unmask
;
492 gpio
->intc
.irq_set_type
= tegra186_irq_set_type
;
494 irq
= &gpio
->gpio
.irq
;
495 irq
->chip
= &gpio
->intc
;
496 irq
->domain_ops
= &tegra186_gpio_irq_domain_ops
;
497 irq
->handler
= handle_simple_irq
;
498 irq
->default_type
= IRQ_TYPE_NONE
;
499 irq
->parent_handler
= tegra186_gpio_irq
;
500 irq
->parent_handler_data
= gpio
;
501 irq
->num_parents
= gpio
->num_irq
;
502 irq
->parents
= gpio
->irq
;
504 irq
->map
= devm_kcalloc(&pdev
->dev
, gpio
->gpio
.ngpio
,
505 sizeof(*irq
->map
), GFP_KERNEL
);
509 for (i
= 0, offset
= 0; i
< gpio
->soc
->num_ports
; i
++) {
510 const struct tegra_gpio_port
*port
= &gpio
->soc
->ports
[i
];
512 for (j
= 0; j
< port
->pins
; j
++)
513 irq
->map
[offset
+ j
] = irq
->parents
[port
->irq
];
515 offset
+= port
->pins
;
518 platform_set_drvdata(pdev
, gpio
);
520 err
= devm_gpiochip_add_data(&pdev
->dev
, &gpio
->gpio
, gpio
);
527 static int tegra186_gpio_remove(struct platform_device
*pdev
)
532 #define TEGRA_MAIN_GPIO_PORT(port, base, count, controller) \
533 [TEGRA_MAIN_GPIO_PORT_##port] = { \
540 static const struct tegra_gpio_port tegra186_main_ports
[] = {
541 TEGRA_MAIN_GPIO_PORT( A
, 0x2000, 7, 2),
542 TEGRA_MAIN_GPIO_PORT( B
, 0x3000, 7, 3),
543 TEGRA_MAIN_GPIO_PORT( C
, 0x3200, 7, 3),
544 TEGRA_MAIN_GPIO_PORT( D
, 0x3400, 6, 3),
545 TEGRA_MAIN_GPIO_PORT( E
, 0x2200, 8, 2),
546 TEGRA_MAIN_GPIO_PORT( F
, 0x2400, 6, 2),
547 TEGRA_MAIN_GPIO_PORT( G
, 0x4200, 6, 4),
548 TEGRA_MAIN_GPIO_PORT( H
, 0x1000, 7, 1),
549 TEGRA_MAIN_GPIO_PORT( I
, 0x0800, 8, 0),
550 TEGRA_MAIN_GPIO_PORT( J
, 0x5000, 8, 5),
551 TEGRA_MAIN_GPIO_PORT( K
, 0x5200, 1, 5),
552 TEGRA_MAIN_GPIO_PORT( L
, 0x1200, 8, 1),
553 TEGRA_MAIN_GPIO_PORT( M
, 0x5600, 6, 5),
554 TEGRA_MAIN_GPIO_PORT( N
, 0x0000, 7, 0),
555 TEGRA_MAIN_GPIO_PORT( O
, 0x0200, 4, 0),
556 TEGRA_MAIN_GPIO_PORT( P
, 0x4000, 7, 4),
557 TEGRA_MAIN_GPIO_PORT( Q
, 0x0400, 6, 0),
558 TEGRA_MAIN_GPIO_PORT( R
, 0x0a00, 6, 0),
559 TEGRA_MAIN_GPIO_PORT( T
, 0x0600, 4, 0),
560 TEGRA_MAIN_GPIO_PORT( X
, 0x1400, 8, 1),
561 TEGRA_MAIN_GPIO_PORT( Y
, 0x1600, 7, 1),
562 TEGRA_MAIN_GPIO_PORT(BB
, 0x2600, 2, 2),
563 TEGRA_MAIN_GPIO_PORT(CC
, 0x5400, 4, 5),
566 static const struct tegra_gpio_soc tegra186_main_soc
= {
567 .num_ports
= ARRAY_SIZE(tegra186_main_ports
),
568 .ports
= tegra186_main_ports
,
569 .name
= "tegra186-gpio",
572 #define TEGRA_AON_GPIO_PORT(port, base, count, controller) \
573 [TEGRA_AON_GPIO_PORT_##port] = { \
580 static const struct tegra_gpio_port tegra186_aon_ports
[] = {
581 TEGRA_AON_GPIO_PORT( S
, 0x0200, 5, 0),
582 TEGRA_AON_GPIO_PORT( U
, 0x0400, 6, 0),
583 TEGRA_AON_GPIO_PORT( V
, 0x0800, 8, 0),
584 TEGRA_AON_GPIO_PORT( W
, 0x0a00, 8, 0),
585 TEGRA_AON_GPIO_PORT( Z
, 0x0e00, 4, 0),
586 TEGRA_AON_GPIO_PORT(AA
, 0x0c00, 8, 0),
587 TEGRA_AON_GPIO_PORT(EE
, 0x0600, 3, 0),
588 TEGRA_AON_GPIO_PORT(FF
, 0x0000, 5, 0),
591 static const struct tegra_gpio_soc tegra186_aon_soc
= {
592 .num_ports
= ARRAY_SIZE(tegra186_aon_ports
),
593 .ports
= tegra186_aon_ports
,
594 .name
= "tegra186-gpio-aon",
597 #define TEGRA194_MAIN_GPIO_PORT(port, base, count, controller) \
598 [TEGRA194_MAIN_GPIO_PORT_##port] = { \
605 static const struct tegra_gpio_port tegra194_main_ports
[] = {
606 TEGRA194_MAIN_GPIO_PORT( A
, 0x1400, 8, 1),
607 TEGRA194_MAIN_GPIO_PORT( B
, 0x4e00, 2, 4),
608 TEGRA194_MAIN_GPIO_PORT( C
, 0x4600, 8, 4),
609 TEGRA194_MAIN_GPIO_PORT( D
, 0x4800, 4, 4),
610 TEGRA194_MAIN_GPIO_PORT( E
, 0x4a00, 8, 4),
611 TEGRA194_MAIN_GPIO_PORT( F
, 0x4c00, 6, 4),
612 TEGRA194_MAIN_GPIO_PORT( G
, 0x4000, 8, 4),
613 TEGRA194_MAIN_GPIO_PORT( H
, 0x4200, 8, 4),
614 TEGRA194_MAIN_GPIO_PORT( I
, 0x4400, 5, 4),
615 TEGRA194_MAIN_GPIO_PORT( J
, 0x5200, 6, 5),
616 TEGRA194_MAIN_GPIO_PORT( K
, 0x3000, 8, 3),
617 TEGRA194_MAIN_GPIO_PORT( L
, 0x3200, 4, 3),
618 TEGRA194_MAIN_GPIO_PORT( M
, 0x2600, 8, 2),
619 TEGRA194_MAIN_GPIO_PORT( N
, 0x2800, 3, 2),
620 TEGRA194_MAIN_GPIO_PORT( O
, 0x5000, 6, 5),
621 TEGRA194_MAIN_GPIO_PORT( P
, 0x2a00, 8, 2),
622 TEGRA194_MAIN_GPIO_PORT( Q
, 0x2c00, 8, 2),
623 TEGRA194_MAIN_GPIO_PORT( R
, 0x2e00, 6, 2),
624 TEGRA194_MAIN_GPIO_PORT( S
, 0x3600, 8, 3),
625 TEGRA194_MAIN_GPIO_PORT( T
, 0x3800, 8, 3),
626 TEGRA194_MAIN_GPIO_PORT( U
, 0x3a00, 1, 3),
627 TEGRA194_MAIN_GPIO_PORT( V
, 0x1000, 8, 1),
628 TEGRA194_MAIN_GPIO_PORT( W
, 0x1200, 2, 1),
629 TEGRA194_MAIN_GPIO_PORT( X
, 0x2000, 8, 2),
630 TEGRA194_MAIN_GPIO_PORT( Y
, 0x2200, 8, 2),
631 TEGRA194_MAIN_GPIO_PORT( Z
, 0x2400, 8, 2),
632 TEGRA194_MAIN_GPIO_PORT(FF
, 0x3400, 2, 3),
633 TEGRA194_MAIN_GPIO_PORT(GG
, 0x0000, 2, 0)
636 static const struct tegra_gpio_soc tegra194_main_soc
= {
637 .num_ports
= ARRAY_SIZE(tegra194_main_ports
),
638 .ports
= tegra194_main_ports
,
639 .name
= "tegra194-gpio",
642 #define TEGRA194_AON_GPIO_PORT(port, base, count, controller) \
643 [TEGRA194_AON_GPIO_PORT_##port] = { \
650 static const struct tegra_gpio_port tegra194_aon_ports
[] = {
651 TEGRA194_AON_GPIO_PORT(AA
, 0x0600, 8, 0),
652 TEGRA194_AON_GPIO_PORT(BB
, 0x0800, 4, 0),
653 TEGRA194_AON_GPIO_PORT(CC
, 0x0200, 8, 0),
654 TEGRA194_AON_GPIO_PORT(DD
, 0x0400, 3, 0),
655 TEGRA194_AON_GPIO_PORT(EE
, 0x0000, 7, 0)
658 static const struct tegra_gpio_soc tegra194_aon_soc
= {
659 .num_ports
= ARRAY_SIZE(tegra194_aon_ports
),
660 .ports
= tegra194_aon_ports
,
661 .name
= "tegra194-gpio-aon",
664 static const struct of_device_id tegra186_gpio_of_match
[] = {
666 .compatible
= "nvidia,tegra186-gpio",
667 .data
= &tegra186_main_soc
669 .compatible
= "nvidia,tegra186-gpio-aon",
670 .data
= &tegra186_aon_soc
672 .compatible
= "nvidia,tegra194-gpio",
673 .data
= &tegra194_main_soc
675 .compatible
= "nvidia,tegra194-gpio-aon",
676 .data
= &tegra194_aon_soc
682 static struct platform_driver tegra186_gpio_driver
= {
684 .name
= "tegra186-gpio",
685 .of_match_table
= tegra186_gpio_of_match
,
687 .probe
= tegra186_gpio_probe
,
688 .remove
= tegra186_gpio_remove
,
690 module_platform_driver(tegra186_gpio_driver
);
692 MODULE_DESCRIPTION("NVIDIA Tegra186 GPIO controller driver");
693 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
694 MODULE_LICENSE("GPL v2");