diff options
Diffstat (limited to 'drivers/irqchip/irq-gic-pm.c')
-rw-r--r-- | drivers/irqchip/irq-gic-pm.c | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/drivers/irqchip/irq-gic-pm.c b/drivers/irqchip/irq-gic-pm.c index ecafd295c31c..c4aac0977d8a 100644 --- a/drivers/irqchip/irq-gic-pm.c +++ b/drivers/irqchip/irq-gic-pm.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/of_irq.h> | 19 | #include <linux/of_irq.h> |
20 | #include <linux/irqchip/arm-gic.h> | 20 | #include <linux/irqchip/arm-gic.h> |
21 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/pm_clock.h> | ||
23 | #include <linux/pm_runtime.h> | 22 | #include <linux/pm_runtime.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
25 | 24 | ||
@@ -28,17 +27,27 @@ struct gic_clk_data { | |||
28 | const char *const *clocks; | 27 | const char *const *clocks; |
29 | }; | 28 | }; |
30 | 29 | ||
30 | struct gic_chip_pm { | ||
31 | struct gic_chip_data *chip_data; | ||
32 | const struct gic_clk_data *clk_data; | ||
33 | struct clk_bulk_data *clks; | ||
34 | }; | ||
35 | |||
31 | static int gic_runtime_resume(struct device *dev) | 36 | static int gic_runtime_resume(struct device *dev) |
32 | { | 37 | { |
33 | struct gic_chip_data *gic = dev_get_drvdata(dev); | 38 | struct gic_chip_pm *chip_pm = dev_get_drvdata(dev); |
39 | struct gic_chip_data *gic = chip_pm->chip_data; | ||
40 | const struct gic_clk_data *data = chip_pm->clk_data; | ||
34 | int ret; | 41 | int ret; |
35 | 42 | ||
36 | ret = pm_clk_resume(dev); | 43 | ret = clk_bulk_prepare_enable(data->num_clocks, chip_pm->clks); |
37 | if (ret) | 44 | if (ret) { |
45 | dev_err(dev, "clk_enable failed: %d\n", ret); | ||
38 | return ret; | 46 | return ret; |
47 | } | ||
39 | 48 | ||
40 | /* | 49 | /* |
41 | * On the very first resume, the pointer to the driver data | 50 | * On the very first resume, the pointer to chip_pm->chip_data |
42 | * will be NULL and this is intentional, because we do not | 51 | * will be NULL and this is intentional, because we do not |
43 | * want to restore the GIC on the very first resume. So if | 52 | * want to restore the GIC on the very first resume. So if |
44 | * the pointer is not valid just return. | 53 | * the pointer is not valid just return. |
@@ -54,35 +63,14 @@ static int gic_runtime_resume(struct device *dev) | |||
54 | 63 | ||
55 | static int gic_runtime_suspend(struct device *dev) | 64 | static int gic_runtime_suspend(struct device *dev) |
56 | { | 65 | { |
57 | struct gic_chip_data *gic = dev_get_drvdata(dev); | 66 | struct gic_chip_pm *chip_pm = dev_get_drvdata(dev); |
67 | struct gic_chip_data *gic = chip_pm->chip_data; | ||
68 | const struct gic_clk_data *data = chip_pm->clk_data; | ||
58 | 69 | ||
59 | gic_dist_save(gic); | 70 | gic_dist_save(gic); |
60 | gic_cpu_save(gic); | 71 | gic_cpu_save(gic); |
61 | 72 | ||
62 | return pm_clk_suspend(dev); | 73 | clk_bulk_disable_unprepare(data->num_clocks, chip_pm->clks); |
63 | } | ||
64 | |||
65 | static int gic_get_clocks(struct device *dev, const struct gic_clk_data *data) | ||
66 | { | ||
67 | unsigned int i; | ||
68 | int ret; | ||
69 | |||
70 | if (!dev || !data) | ||
71 | return -EINVAL; | ||
72 | |||
73 | ret = pm_clk_create(dev); | ||
74 | if (ret) | ||
75 | return ret; | ||
76 | |||
77 | for (i = 0; i < data->num_clocks; i++) { | ||
78 | ret = of_pm_clk_add_clk(dev, data->clocks[i]); | ||
79 | if (ret) { | ||
80 | dev_err(dev, "failed to add clock %s\n", | ||
81 | data->clocks[i]); | ||
82 | pm_clk_destroy(dev); | ||
83 | return ret; | ||
84 | } | ||
85 | } | ||
86 | 74 | ||
87 | return 0; | 75 | return 0; |
88 | } | 76 | } |
@@ -91,8 +79,8 @@ static int gic_probe(struct platform_device *pdev) | |||
91 | { | 79 | { |
92 | struct device *dev = &pdev->dev; | 80 | struct device *dev = &pdev->dev; |
93 | const struct gic_clk_data *data; | 81 | const struct gic_clk_data *data; |
94 | struct gic_chip_data *gic; | 82 | struct gic_chip_pm *chip_pm; |
95 | int ret, irq; | 83 | int ret, irq, i; |
96 | 84 | ||
97 | data = of_device_get_match_data(&pdev->dev); | 85 | data = of_device_get_match_data(&pdev->dev); |
98 | if (!data) { | 86 | if (!data) { |
@@ -100,28 +88,41 @@ static int gic_probe(struct platform_device *pdev) | |||
100 | return -ENODEV; | 88 | return -ENODEV; |
101 | } | 89 | } |
102 | 90 | ||
91 | chip_pm = devm_kzalloc(dev, sizeof(*chip_pm), GFP_KERNEL); | ||
92 | if (!chip_pm) | ||
93 | return -ENOMEM; | ||
94 | |||
103 | irq = irq_of_parse_and_map(dev->of_node, 0); | 95 | irq = irq_of_parse_and_map(dev->of_node, 0); |
104 | if (!irq) { | 96 | if (!irq) { |
105 | dev_err(dev, "no parent interrupt found!\n"); | 97 | dev_err(dev, "no parent interrupt found!\n"); |
106 | return -EINVAL; | 98 | return -EINVAL; |
107 | } | 99 | } |
108 | 100 | ||
109 | ret = gic_get_clocks(dev, data); | 101 | chip_pm->clks = devm_kcalloc(dev, data->num_clocks, |
102 | sizeof(*chip_pm->clks), GFP_KERNEL); | ||
103 | if (!chip_pm->clks) | ||
104 | return -ENOMEM; | ||
105 | |||
106 | for (i = 0; i < data->num_clocks; i++) | ||
107 | chip_pm->clks[i].id = data->clocks[i]; | ||
108 | |||
109 | ret = devm_clk_bulk_get(dev, data->num_clocks, chip_pm->clks); | ||
110 | if (ret) | 110 | if (ret) |
111 | goto irq_dispose; | 111 | goto irq_dispose; |
112 | 112 | ||
113 | chip_pm->clk_data = data; | ||
114 | dev_set_drvdata(dev, chip_pm); | ||
115 | |||
113 | pm_runtime_enable(dev); | 116 | pm_runtime_enable(dev); |
114 | 117 | ||
115 | ret = pm_runtime_get_sync(dev); | 118 | ret = pm_runtime_get_sync(dev); |
116 | if (ret < 0) | 119 | if (ret < 0) |
117 | goto rpm_disable; | 120 | goto rpm_disable; |
118 | 121 | ||
119 | ret = gic_of_init_child(dev, &gic, irq); | 122 | ret = gic_of_init_child(dev, &chip_pm->chip_data, irq); |
120 | if (ret) | 123 | if (ret) |
121 | goto rpm_put; | 124 | goto rpm_put; |
122 | 125 | ||
123 | platform_set_drvdata(pdev, gic); | ||
124 | |||
125 | pm_runtime_put(dev); | 126 | pm_runtime_put(dev); |
126 | 127 | ||
127 | dev_info(dev, "GIC IRQ controller registered\n"); | 128 | dev_info(dev, "GIC IRQ controller registered\n"); |
@@ -132,7 +133,6 @@ rpm_put: | |||
132 | pm_runtime_put_sync(dev); | 133 | pm_runtime_put_sync(dev); |
133 | rpm_disable: | 134 | rpm_disable: |
134 | pm_runtime_disable(dev); | 135 | pm_runtime_disable(dev); |
135 | pm_clk_destroy(dev); | ||
136 | irq_dispose: | 136 | irq_dispose: |
137 | irq_dispose_mapping(irq); | 137 | irq_dispose_mapping(irq); |
138 | 138 | ||
@@ -142,6 +142,8 @@ irq_dispose: | |||
142 | static const struct dev_pm_ops gic_pm_ops = { | 142 | static const struct dev_pm_ops gic_pm_ops = { |
143 | SET_RUNTIME_PM_OPS(gic_runtime_suspend, | 143 | SET_RUNTIME_PM_OPS(gic_runtime_suspend, |
144 | gic_runtime_resume, NULL) | 144 | gic_runtime_resume, NULL) |
145 | SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, | ||
146 | pm_runtime_force_resume) | ||
145 | }; | 147 | }; |
146 | 148 | ||
147 | static const char * const gic400_clocks[] = { | 149 | static const char * const gic400_clocks[] = { |