14
14
* GNU General Public License for more details.
15
15
*/
16
16
17
- #include <linux/clk.h>
18
17
#include <linux/err.h>
19
18
#include <linux/gpio.h>
20
19
#include <linux/init.h>
@@ -37,10 +36,9 @@ struct gpio_rcar_priv {
37
36
struct platform_device * pdev ;
38
37
struct gpio_chip gpio_chip ;
39
38
struct irq_chip irq_chip ;
40
- struct clk * clk ;
41
39
unsigned int irq_parent ;
40
+ atomic_t wakeup_path ;
42
41
bool has_both_edge_trigger ;
43
- bool needs_clk ;
44
42
};
45
43
46
44
#define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */
@@ -186,13 +184,10 @@ static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on)
186
184
}
187
185
}
188
186
189
- if (!p -> clk )
190
- return 0 ;
191
-
192
187
if (on )
193
- clk_enable ( p -> clk );
188
+ atomic_inc ( & p -> wakeup_path );
194
189
else
195
- clk_disable ( p -> clk );
190
+ atomic_dec ( & p -> wakeup_path );
196
191
197
192
return 0 ;
198
193
}
@@ -330,17 +325,14 @@ static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset,
330
325
331
326
struct gpio_rcar_info {
332
327
bool has_both_edge_trigger ;
333
- bool needs_clk ;
334
328
};
335
329
336
330
static const struct gpio_rcar_info gpio_rcar_info_gen1 = {
337
331
.has_both_edge_trigger = false,
338
- .needs_clk = false,
339
332
};
340
333
341
334
static const struct gpio_rcar_info gpio_rcar_info_gen2 = {
342
335
.has_both_edge_trigger = true,
343
- .needs_clk = true,
344
336
};
345
337
346
338
static const struct of_device_id gpio_rcar_of_table [] = {
@@ -403,7 +395,6 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins)
403
395
ret = of_parse_phandle_with_fixed_args (np , "gpio-ranges" , 3 , 0 , & args );
404
396
* npins = ret == 0 ? args .args [2 ] : RCAR_MAX_GPIO_PER_BANK ;
405
397
p -> has_both_edge_trigger = info -> has_both_edge_trigger ;
406
- p -> needs_clk = info -> needs_clk ;
407
398
408
399
if (* npins == 0 || * npins > RCAR_MAX_GPIO_PER_BANK ) {
409
400
dev_warn (& p -> pdev -> dev ,
@@ -440,16 +431,6 @@ static int gpio_rcar_probe(struct platform_device *pdev)
440
431
441
432
platform_set_drvdata (pdev , p );
442
433
443
- p -> clk = devm_clk_get (dev , NULL );
444
- if (IS_ERR (p -> clk )) {
445
- if (p -> needs_clk ) {
446
- dev_err (dev , "unable to get clock\n" );
447
- ret = PTR_ERR (p -> clk );
448
- goto err0 ;
449
- }
450
- p -> clk = NULL ;
451
- }
452
-
453
434
pm_runtime_enable (dev );
454
435
455
436
irq = platform_get_resource (pdev , IORESOURCE_IRQ , 0 );
@@ -531,11 +512,24 @@ static int gpio_rcar_remove(struct platform_device *pdev)
531
512
return 0 ;
532
513
}
533
514
515
+ static int __maybe_unused gpio_rcar_suspend (struct device * dev )
516
+ {
517
+ struct gpio_rcar_priv * p = dev_get_drvdata (dev );
518
+
519
+ if (atomic_read (& p -> wakeup_path ))
520
+ device_set_wakeup_path (dev );
521
+
522
+ return 0 ;
523
+ }
524
+
525
+ static SIMPLE_DEV_PM_OPS (gpio_rcar_pm_ops , gpio_rcar_suspend , NULL) ;
526
+
534
527
static struct platform_driver gpio_rcar_device_driver = {
535
528
.probe = gpio_rcar_probe ,
536
529
.remove = gpio_rcar_remove ,
537
530
.driver = {
538
531
.name = "gpio_rcar" ,
532
+ .pm = & gpio_rcar_pm_ops ,
539
533
.of_match_table = of_match_ptr (gpio_rcar_of_table ),
540
534
}
541
535
};
0 commit comments