1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2016-2017 NVIDIA Corporation
5 * Author: Thierry Reding <treding@nvidia.com>
8 #include <linux/gpio/driver.h>
9 #include <linux/interrupt.h>
10 #include <linux/irq.h>
11 #include <linux/module.h>
12 #include <linux/of_device.h>
13 #include <linux/platform_device.h>
15 #include <dt-bindings/gpio/tegra186-gpio.h>
16 #include <dt-bindings/gpio/tegra194-gpio.h>
18 #define TEGRA186_GPIO_ENABLE_CONFIG 0x00
19 #define TEGRA186_GPIO_ENABLE_CONFIG_ENABLE BIT(0)
20 #define TEGRA186_GPIO_ENABLE_CONFIG_OUT BIT(1)
21 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_NONE (0x0 << 2)
22 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_LEVEL (0x1 << 2)
23 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE (0x2 << 2)
24 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_DOUBLE_EDGE (0x3 << 2)
25 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_MASK (0x3 << 2)
26 #define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL BIT(4)
27 #define TEGRA186_GPIO_ENABLE_CONFIG_INTERRUPT BIT(6)
29 #define TEGRA186_GPIO_DEBOUNCE_CONTROL 0x04
30 #define TEGRA186_GPIO_DEBOUNCE_CONTROL_THRESHOLD(x) ((x) & 0xff)
32 #define TEGRA186_GPIO_INPUT 0x08
33 #define TEGRA186_GPIO_INPUT_HIGH BIT(0)
35 #define TEGRA186_GPIO_OUTPUT_CONTROL 0x0c
36 #define TEGRA186_GPIO_OUTPUT_CONTROL_FLOATED BIT(0)
38 #define TEGRA186_GPIO_OUTPUT_VALUE 0x10
39 #define TEGRA186_GPIO_OUTPUT_VALUE_HIGH BIT(0)
41 #define TEGRA186_GPIO_INTERRUPT_CLEAR 0x14
43 #define TEGRA186_GPIO_INTERRUPT_STATUS(x) (0x100 + (x) * 4)
45 struct tegra_gpio_port
{
52 struct tegra_gpio_soc
{
53 const struct tegra_gpio_port
*ports
;
54 unsigned int num_ports
;
59 struct gpio_chip gpio
;
64 const struct tegra_gpio_soc
*soc
;
69 static const struct tegra_gpio_port
*
70 tegra186_gpio_get_port(struct tegra_gpio
*gpio
, unsigned int *pin
)
72 unsigned int start
= 0, i
;
74 for (i
= 0; i
< gpio
->soc
->num_ports
; i
++) {
75 const struct tegra_gpio_port
*port
= &gpio
->soc
->ports
[i
];
77 if (*pin
>= start
&& *pin
< start
+ port
->pins
) {
88 static void __iomem
*tegra186_gpio_get_base(struct tegra_gpio
*gpio
,
91 const struct tegra_gpio_port
*port
;
93 port
= tegra186_gpio_get_port(gpio
, &pin
);
97 return gpio
->base
+ port
->offset
+ pin
* 0x20;
100 static int tegra186_gpio_get_direction(struct gpio_chip
*chip
,
103 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
107 base
= tegra186_gpio_get_base(gpio
, offset
);
108 if (WARN_ON(base
== NULL
))
111 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
112 if (value
& TEGRA186_GPIO_ENABLE_CONFIG_OUT
)
118 static int tegra186_gpio_direction_input(struct gpio_chip
*chip
,
121 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
125 base
= tegra186_gpio_get_base(gpio
, offset
);
126 if (WARN_ON(base
== NULL
))
129 value
= readl(base
+ TEGRA186_GPIO_OUTPUT_CONTROL
);
130 value
|= TEGRA186_GPIO_OUTPUT_CONTROL_FLOATED
;
131 writel(value
, base
+ TEGRA186_GPIO_OUTPUT_CONTROL
);
133 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
134 value
|= TEGRA186_GPIO_ENABLE_CONFIG_ENABLE
;
135 value
&= ~TEGRA186_GPIO_ENABLE_CONFIG_OUT
;
136 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
141 static int tegra186_gpio_direction_output(struct gpio_chip
*chip
,
142 unsigned int offset
, int level
)
144 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
148 /* configure output level first */
149 chip
->set(chip
, offset
, level
);
151 base
= tegra186_gpio_get_base(gpio
, offset
);
152 if (WARN_ON(base
== NULL
))
155 /* set the direction */
156 value
= readl(base
+ TEGRA186_GPIO_OUTPUT_CONTROL
);
157 value
&= ~TEGRA186_GPIO_OUTPUT_CONTROL_FLOATED
;
158 writel(value
, base
+ TEGRA186_GPIO_OUTPUT_CONTROL
);
160 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
161 value
|= TEGRA186_GPIO_ENABLE_CONFIG_ENABLE
;
162 value
|= TEGRA186_GPIO_ENABLE_CONFIG_OUT
;
163 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
168 static int tegra186_gpio_get(struct gpio_chip
*chip
, unsigned int offset
)
170 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
174 base
= tegra186_gpio_get_base(gpio
, offset
);
175 if (WARN_ON(base
== NULL
))
178 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
179 if (value
& TEGRA186_GPIO_ENABLE_CONFIG_OUT
)
180 value
= readl(base
+ TEGRA186_GPIO_OUTPUT_VALUE
);
182 value
= readl(base
+ TEGRA186_GPIO_INPUT
);
184 return value
& BIT(0);
187 static void tegra186_gpio_set(struct gpio_chip
*chip
, unsigned int offset
,
190 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
194 base
= tegra186_gpio_get_base(gpio
, offset
);
195 if (WARN_ON(base
== NULL
))
198 value
= readl(base
+ TEGRA186_GPIO_OUTPUT_VALUE
);
200 value
&= ~TEGRA186_GPIO_OUTPUT_VALUE_HIGH
;
202 value
|= TEGRA186_GPIO_OUTPUT_VALUE_HIGH
;
204 writel(value
, base
+ TEGRA186_GPIO_OUTPUT_VALUE
);
207 static int tegra186_gpio_of_xlate(struct gpio_chip
*chip
,
208 const struct of_phandle_args
*spec
,
211 struct tegra_gpio
*gpio
= gpiochip_get_data(chip
);
212 unsigned int port
, pin
, i
, offset
= 0;
214 if (WARN_ON(chip
->of_gpio_n_cells
< 2))
217 if (WARN_ON(spec
->args_count
< chip
->of_gpio_n_cells
))
220 port
= spec
->args
[0] / 8;
221 pin
= spec
->args
[0] % 8;
223 if (port
>= gpio
->soc
->num_ports
) {
224 dev_err(chip
->parent
, "invalid port number: %u\n", port
);
228 for (i
= 0; i
< port
; i
++)
229 offset
+= gpio
->soc
->ports
[i
].pins
;
232 *flags
= spec
->args
[1];
237 static void tegra186_irq_ack(struct irq_data
*data
)
239 struct tegra_gpio
*gpio
= irq_data_get_irq_chip_data(data
);
242 base
= tegra186_gpio_get_base(gpio
, data
->hwirq
);
243 if (WARN_ON(base
== NULL
))
246 writel(1, base
+ TEGRA186_GPIO_INTERRUPT_CLEAR
);
249 static void tegra186_irq_mask(struct irq_data
*data
)
251 struct tegra_gpio
*gpio
= irq_data_get_irq_chip_data(data
);
255 base
= tegra186_gpio_get_base(gpio
, data
->hwirq
);
256 if (WARN_ON(base
== NULL
))
259 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
260 value
&= ~TEGRA186_GPIO_ENABLE_CONFIG_INTERRUPT
;
261 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
264 static void tegra186_irq_unmask(struct irq_data
*data
)
266 struct tegra_gpio
*gpio
= irq_data_get_irq_chip_data(data
);
270 base
= tegra186_gpio_get_base(gpio
, data
->hwirq
);
271 if (WARN_ON(base
== NULL
))
274 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
275 value
|= TEGRA186_GPIO_ENABLE_CONFIG_INTERRUPT
;
276 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
279 static int tegra186_irq_set_type(struct irq_data
*data
, unsigned int type
)
281 struct tegra_gpio
*gpio
= irq_data_get_irq_chip_data(data
);
285 base
= tegra186_gpio_get_base(gpio
, data
->hwirq
);
286 if (WARN_ON(base
== NULL
))
289 value
= readl(base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
290 value
&= ~TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_MASK
;
291 value
&= ~TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL
;
293 switch (type
& IRQ_TYPE_SENSE_MASK
) {
297 case IRQ_TYPE_EDGE_RISING
:
298 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE
;
299 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL
;
302 case IRQ_TYPE_EDGE_FALLING
:
303 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE
;
306 case IRQ_TYPE_EDGE_BOTH
:
307 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_DOUBLE_EDGE
;
310 case IRQ_TYPE_LEVEL_HIGH
:
311 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_LEVEL
;
312 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL
;
315 case IRQ_TYPE_LEVEL_LOW
:
316 value
|= TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_LEVEL
;
323 writel(value
, base
+ TEGRA186_GPIO_ENABLE_CONFIG
);
325 if ((type
& IRQ_TYPE_EDGE_BOTH
) == 0)
326 irq_set_handler_locked(data
, handle_level_irq
);
328 irq_set_handler_locked(data
, handle_edge_irq
);
333 static void tegra186_gpio_irq(struct irq_desc
*desc
)
335 struct tegra_gpio
*gpio
= irq_desc_get_handler_data(desc
);
336 struct irq_domain
*domain
= gpio
->gpio
.irq
.domain
;
337 struct irq_chip
*chip
= irq_desc_get_chip(desc
);
338 unsigned int parent
= irq_desc_get_irq(desc
);
339 unsigned int i
, offset
= 0;
341 chained_irq_enter(chip
, desc
);
343 for (i
= 0; i
< gpio
->soc
->num_ports
; i
++) {
344 const struct tegra_gpio_port
*port
= &gpio
->soc
->ports
[i
];
345 void __iomem
*base
= gpio
->base
+ port
->offset
;
346 unsigned int pin
, irq
;
349 /* skip ports that are not associated with this controller */
350 if (parent
!= gpio
->irq
[port
->irq
])
353 value
= readl(base
+ TEGRA186_GPIO_INTERRUPT_STATUS(1));
355 for_each_set_bit(pin
, &value
, port
->pins
) {
356 irq
= irq_find_mapping(domain
, offset
+ pin
);
357 if (WARN_ON(irq
== 0))
360 generic_handle_irq(irq
);
364 offset
+= port
->pins
;
367 chained_irq_exit(chip
, desc
);
370 static int tegra186_gpio_irq_domain_xlate(struct irq_domain
*domain
,
371 struct device_node
*np
,
372 const u32
*spec
, unsigned int size
,
373 unsigned long *hwirq
,
376 struct tegra_gpio
*gpio
= gpiochip_get_data(domain
->host_data
);
377 unsigned int port
, pin
, i
, offset
= 0;
385 if (port
>= gpio
->soc
->num_ports
) {
386 dev_err(gpio
->gpio
.parent
, "invalid port number: %u\n", port
);
390 for (i
= 0; i
< port
; i
++)
391 offset
+= gpio
->soc
->ports
[i
].pins
;
393 *type
= spec
[1] & IRQ_TYPE_SENSE_MASK
;
394 *hwirq
= offset
+ pin
;
399 static const struct irq_domain_ops tegra186_gpio_irq_domain_ops
= {
400 .map
= gpiochip_irq_map
,
401 .unmap
= gpiochip_irq_unmap
,
402 .xlate
= tegra186_gpio_irq_domain_xlate
,
405 static int tegra186_gpio_probe(struct platform_device
*pdev
)
407 unsigned int i
, j
, offset
;
408 struct gpio_irq_chip
*irq
;
409 struct tegra_gpio
*gpio
;
410 struct resource
*res
;
414 gpio
= devm_kzalloc(&pdev
->dev
, sizeof(*gpio
), GFP_KERNEL
);
418 gpio
->soc
= of_device_get_match_data(&pdev
->dev
);
420 res
= platform_get_resource_byname(pdev
, IORESOURCE_MEM
, "gpio");
421 gpio
->base
= devm_ioremap_resource(&pdev
->dev
, res
);
422 if (IS_ERR(gpio
->base
))
423 return PTR_ERR(gpio
->base
);
425 err
= platform_irq_count(pdev
);
431 gpio
->irq
= devm_kcalloc(&pdev
->dev
, gpio
->num_irq
, sizeof(*gpio
->irq
),
436 for (i
= 0; i
< gpio
->num_irq
; i
++) {
437 err
= platform_get_irq(pdev
, i
);
444 gpio
->gpio
.label
= gpio
->soc
->name
;
445 gpio
->gpio
.parent
= &pdev
->dev
;
447 gpio
->gpio
.get_direction
= tegra186_gpio_get_direction
;
448 gpio
->gpio
.direction_input
= tegra186_gpio_direction_input
;
449 gpio
->gpio
.direction_output
= tegra186_gpio_direction_output
;
450 gpio
->gpio
.get
= tegra186_gpio_get
,
451 gpio
->gpio
.set
= tegra186_gpio_set
;
453 gpio
->gpio
.base
= -1;
455 for (i
= 0; i
< gpio
->soc
->num_ports
; i
++)
456 gpio
->gpio
.ngpio
+= gpio
->soc
->ports
[i
].pins
;
458 names
= devm_kcalloc(gpio
->gpio
.parent
, gpio
->gpio
.ngpio
,
459 sizeof(*names
), GFP_KERNEL
);
463 for (i
= 0, offset
= 0; i
< gpio
->soc
->num_ports
; i
++) {
464 const struct tegra_gpio_port
*port
= &gpio
->soc
->ports
[i
];
467 for (j
= 0; j
< port
->pins
; j
++) {
468 name
= devm_kasprintf(gpio
->gpio
.parent
, GFP_KERNEL
,
469 "P%s.%02x", port
->name
, j
);
473 names
[offset
+ j
] = name
;
476 offset
+= port
->pins
;
479 gpio
->gpio
.names
= (const char * const *)names
;
481 gpio
->gpio
.of_node
= pdev
->dev
.of_node
;
482 gpio
->gpio
.of_gpio_n_cells
= 2;
483 gpio
->gpio
.of_xlate
= tegra186_gpio_of_xlate
;
485 gpio
->intc
.name
= pdev
->dev
.of_node
->name
;
486 gpio
->intc
.irq_ack
= tegra186_irq_ack
;
487 gpio
->intc
.irq_mask
= tegra186_irq_mask
;
488 gpio
->intc
.irq_unmask
= tegra186_irq_unmask
;
489 gpio
->intc
.irq_set_type
= tegra186_irq_set_type
;
491 irq
= &gpio
->gpio
.irq
;
492 irq
->chip
= &gpio
->intc
;
493 irq
->domain_ops
= &tegra186_gpio_irq_domain_ops
;
494 irq
->handler
= handle_simple_irq
;
495 irq
->default_type
= IRQ_TYPE_NONE
;
496 irq
->parent_handler
= tegra186_gpio_irq
;
497 irq
->parent_handler_data
= gpio
;
498 irq
->num_parents
= gpio
->num_irq
;
499 irq
->parents
= gpio
->irq
;
501 irq
->map
= devm_kcalloc(&pdev
->dev
, gpio
->gpio
.ngpio
,
502 sizeof(*irq
->map
), GFP_KERNEL
);
506 for (i
= 0, offset
= 0; i
< gpio
->soc
->num_ports
; i
++) {
507 const struct tegra_gpio_port
*port
= &gpio
->soc
->ports
[i
];
509 for (j
= 0; j
< port
->pins
; j
++)
510 irq
->map
[offset
+ j
] = irq
->parents
[port
->irq
];
512 offset
+= port
->pins
;
515 platform_set_drvdata(pdev
, gpio
);
517 err
= devm_gpiochip_add_data(&pdev
->dev
, &gpio
->gpio
, gpio
);
524 static int tegra186_gpio_remove(struct platform_device
*pdev
)
529 #define TEGRA186_MAIN_GPIO_PORT(port, base, count, controller) \
530 [TEGRA186_MAIN_GPIO_PORT_##port] = { \
537 static const struct tegra_gpio_port tegra186_main_ports
[] = {
538 TEGRA186_MAIN_GPIO_PORT( A
, 0x2000, 7, 2),
539 TEGRA186_MAIN_GPIO_PORT( B
, 0x3000, 7, 3),
540 TEGRA186_MAIN_GPIO_PORT( C
, 0x3200, 7, 3),
541 TEGRA186_MAIN_GPIO_PORT( D
, 0x3400, 6, 3),
542 TEGRA186_MAIN_GPIO_PORT( E
, 0x2200, 8, 2),
543 TEGRA186_MAIN_GPIO_PORT( F
, 0x2400, 6, 2),
544 TEGRA186_MAIN_GPIO_PORT( G
, 0x4200, 6, 4),
545 TEGRA186_MAIN_GPIO_PORT( H
, 0x1000, 7, 1),
546 TEGRA186_MAIN_GPIO_PORT( I
, 0x0800, 8, 0),
547 TEGRA186_MAIN_GPIO_PORT( J
, 0x5000, 8, 5),
548 TEGRA186_MAIN_GPIO_PORT( K
, 0x5200, 1, 5),
549 TEGRA186_MAIN_GPIO_PORT( L
, 0x1200, 8, 1),
550 TEGRA186_MAIN_GPIO_PORT( M
, 0x5600, 6, 5),
551 TEGRA186_MAIN_GPIO_PORT( N
, 0x0000, 7, 0),
552 TEGRA186_MAIN_GPIO_PORT( O
, 0x0200, 4, 0),
553 TEGRA186_MAIN_GPIO_PORT( P
, 0x4000, 7, 4),
554 TEGRA186_MAIN_GPIO_PORT( Q
, 0x0400, 6, 0),
555 TEGRA186_MAIN_GPIO_PORT( R
, 0x0a00, 6, 0),
556 TEGRA186_MAIN_GPIO_PORT( T
, 0x0600, 4, 0),
557 TEGRA186_MAIN_GPIO_PORT( X
, 0x1400, 8, 1),
558 TEGRA186_MAIN_GPIO_PORT( Y
, 0x1600, 7, 1),
559 TEGRA186_MAIN_GPIO_PORT(BB
, 0x2600, 2, 2),
560 TEGRA186_MAIN_GPIO_PORT(CC
, 0x5400, 4, 5),
563 static const struct tegra_gpio_soc tegra186_main_soc
= {
564 .num_ports
= ARRAY_SIZE(tegra186_main_ports
),
565 .ports
= tegra186_main_ports
,
566 .name
= "tegra186-gpio",
569 #define TEGRA186_AON_GPIO_PORT(port, base, count, controller) \
570 [TEGRA186_AON_GPIO_PORT_##port] = { \
577 static const struct tegra_gpio_port tegra186_aon_ports
[] = {
578 TEGRA186_AON_GPIO_PORT( S
, 0x0200, 5, 0),
579 TEGRA186_AON_GPIO_PORT( U
, 0x0400, 6, 0),
580 TEGRA186_AON_GPIO_PORT( V
, 0x0800, 8, 0),
581 TEGRA186_AON_GPIO_PORT( W
, 0x0a00, 8, 0),
582 TEGRA186_AON_GPIO_PORT( Z
, 0x0e00, 4, 0),
583 TEGRA186_AON_GPIO_PORT(AA
, 0x0c00, 8, 0),
584 TEGRA186_AON_GPIO_PORT(EE
, 0x0600, 3, 0),
585 TEGRA186_AON_GPIO_PORT(FF
, 0x0000, 5, 0),
588 static const struct tegra_gpio_soc tegra186_aon_soc
= {
589 .num_ports
= ARRAY_SIZE(tegra186_aon_ports
),
590 .ports
= tegra186_aon_ports
,
591 .name
= "tegra186-gpio-aon",
594 #define TEGRA194_MAIN_GPIO_PORT(port, base, count, controller) \
595 [TEGRA194_MAIN_GPIO_PORT_##port] = { \
602 static const struct tegra_gpio_port tegra194_main_ports
[] = {
603 TEGRA194_MAIN_GPIO_PORT( A
, 0x1400, 8, 1),
604 TEGRA194_MAIN_GPIO_PORT( B
, 0x4e00, 2, 4),
605 TEGRA194_MAIN_GPIO_PORT( C
, 0x4600, 8, 4),
606 TEGRA194_MAIN_GPIO_PORT( D
, 0x4800, 4, 4),
607 TEGRA194_MAIN_GPIO_PORT( E
, 0x4a00, 8, 4),
608 TEGRA194_MAIN_GPIO_PORT( F
, 0x4c00, 6, 4),
609 TEGRA194_MAIN_GPIO_PORT( G
, 0x4000, 8, 4),
610 TEGRA194_MAIN_GPIO_PORT( H
, 0x4200, 8, 4),
611 TEGRA194_MAIN_GPIO_PORT( I
, 0x4400, 5, 4),
612 TEGRA194_MAIN_GPIO_PORT( J
, 0x5200, 6, 5),
613 TEGRA194_MAIN_GPIO_PORT( K
, 0x3000, 8, 3),
614 TEGRA194_MAIN_GPIO_PORT( L
, 0x3200, 4, 3),
615 TEGRA194_MAIN_GPIO_PORT( M
, 0x2600, 8, 2),
616 TEGRA194_MAIN_GPIO_PORT( N
, 0x2800, 3, 2),
617 TEGRA194_MAIN_GPIO_PORT( O
, 0x5000, 6, 5),
618 TEGRA194_MAIN_GPIO_PORT( P
, 0x2a00, 8, 2),
619 TEGRA194_MAIN_GPIO_PORT( Q
, 0x2c00, 8, 2),
620 TEGRA194_MAIN_GPIO_PORT( R
, 0x2e00, 6, 2),
621 TEGRA194_MAIN_GPIO_PORT( S
, 0x3600, 8, 3),
622 TEGRA194_MAIN_GPIO_PORT( T
, 0x3800, 8, 3),
623 TEGRA194_MAIN_GPIO_PORT( U
, 0x3a00, 1, 3),
624 TEGRA194_MAIN_GPIO_PORT( V
, 0x1000, 8, 1),
625 TEGRA194_MAIN_GPIO_PORT( W
, 0x1200, 2, 1),
626 TEGRA194_MAIN_GPIO_PORT( X
, 0x2000, 8, 2),
627 TEGRA194_MAIN_GPIO_PORT( Y
, 0x2200, 8, 2),
628 TEGRA194_MAIN_GPIO_PORT( Z
, 0x2400, 8, 2),
629 TEGRA194_MAIN_GPIO_PORT(FF
, 0x3400, 2, 3),
630 TEGRA194_MAIN_GPIO_PORT(GG
, 0x0000, 2, 0)
633 static const struct tegra_gpio_soc tegra194_main_soc
= {
634 .num_ports
= ARRAY_SIZE(tegra194_main_ports
),
635 .ports
= tegra194_main_ports
,
636 .name
= "tegra194-gpio",
639 #define TEGRA194_AON_GPIO_PORT(port, base, count, controller) \
640 [TEGRA194_AON_GPIO_PORT_##port] = { \
647 static const struct tegra_gpio_port tegra194_aon_ports
[] = {
648 TEGRA194_AON_GPIO_PORT(AA
, 0x0600, 8, 0),
649 TEGRA194_AON_GPIO_PORT(BB
, 0x0800, 4, 0),
650 TEGRA194_AON_GPIO_PORT(CC
, 0x0200, 8, 0),
651 TEGRA194_AON_GPIO_PORT(DD
, 0x0400, 3, 0),
652 TEGRA194_AON_GPIO_PORT(EE
, 0x0000, 7, 0)
655 static const struct tegra_gpio_soc tegra194_aon_soc
= {
656 .num_ports
= ARRAY_SIZE(tegra194_aon_ports
),
657 .ports
= tegra194_aon_ports
,
658 .name
= "tegra194-gpio-aon",
661 static const struct of_device_id tegra186_gpio_of_match
[] = {
663 .compatible
= "nvidia,tegra186-gpio",
664 .data
= &tegra186_main_soc
666 .compatible
= "nvidia,tegra186-gpio-aon",
667 .data
= &tegra186_aon_soc
669 .compatible
= "nvidia,tegra194-gpio",
670 .data
= &tegra194_main_soc
672 .compatible
= "nvidia,tegra194-gpio-aon",
673 .data
= &tegra194_aon_soc
679 static struct platform_driver tegra186_gpio_driver
= {
681 .name
= "tegra186-gpio",
682 .of_match_table
= tegra186_gpio_of_match
,
684 .probe
= tegra186_gpio_probe
,
685 .remove
= tegra186_gpio_remove
,
687 module_platform_driver(tegra186_gpio_driver
);
689 MODULE_DESCRIPTION("NVIDIA Tegra186 GPIO controller driver");
690 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
691 MODULE_LICENSE("GPL v2");