aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFinn Thain <fthain@telegraphics.com.au>2018-01-27 18:51:40 -0500
committerGeert Uytterhoeven <geert@linux-m68k.org>2018-03-19 05:22:59 -0400
commita64138ec15f4361c456563167bae12ed95a68d6b (patch)
treeabb1bc384ff0859af962044415ec0b0c8079c5df
parenta1eb1cdf4e55e1ecdb4a474070450d8a648686bf (diff)
macintosh/via-pmu68k: Initialize PMU driver with setup_arch and arch_initcall
The PMU watchdog will power down the system if the kernel is slow to start up, e.g. due to unpacking a large initrd. The powerpc version of this driver (via-pmu.c) has a solution for the same problem. It uses this call sequence: setup_arch find_via_pmu init_pmu ... arch_initcall via_pmu_start Bring via-pmu68k.c into line with via-pmu.c to fix this issue. Cc: Geert Uytterhoeven <geert@linux-m68k.org> Tested-by: Stan Johnson <userm57@yahoo.com> Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
-rw-r--r--arch/m68k/mac/config.c4
-rw-r--r--drivers/macintosh/via-pmu68k.c89
2 files changed, 65 insertions, 28 deletions
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 7890a8425710..36086cceb537 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -26,6 +26,7 @@
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/adb.h> 27#include <linux/adb.h>
28#include <linux/cuda.h> 28#include <linux/cuda.h>
29#include <linux/pmu.h>
29#include <linux/rtc.h> 30#include <linux/rtc.h>
30 31
31#include <asm/setup.h> 32#include <asm/setup.h>
@@ -890,6 +891,9 @@ static void __init mac_identify(void)
890#ifdef CONFIG_ADB_CUDA 891#ifdef CONFIG_ADB_CUDA
891 find_via_cuda(); 892 find_via_cuda();
892#endif 893#endif
894#ifdef CONFIG_ADB_PMU68K
895 find_via_pmu();
896#endif
893} 897}
894 898
895static void __init mac_report_hardware(void) 899static void __init mac_report_hardware(void)
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c
index 25465fb91ec9..7d9c4baf8c11 100644
--- a/drivers/macintosh/via-pmu68k.c
+++ b/drivers/macintosh/via-pmu68k.c
@@ -109,6 +109,7 @@ static int pmu_autopoll(int devs);
109void pmu_poll(void); 109void pmu_poll(void);
110static int pmu_reset_bus(void); 110static int pmu_reset_bus(void);
111 111
112static int init_pmu(void);
112static void pmu_start(void); 113static void pmu_start(void);
113static void send_byte(int x); 114static void send_byte(int x);
114static void recv_byte(void); 115static void recv_byte(void);
@@ -171,23 +172,76 @@ static s8 pmu_data_len[256][2] = {
171/*f8*/ {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 172/*f8*/ {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
172}; 173};
173 174
174int pmu_probe(void) 175int __init find_via_pmu(void)
175{ 176{
176 if (macintosh_config->adb_type == MAC_ADB_PB1) { 177 switch (macintosh_config->adb_type) {
178 case MAC_ADB_PB1:
177 pmu_kind = PMU_68K_V1; 179 pmu_kind = PMU_68K_V1;
178 } else if (macintosh_config->adb_type == MAC_ADB_PB2) { 180 break;
181 case MAC_ADB_PB2:
179 pmu_kind = PMU_68K_V2; 182 pmu_kind = PMU_68K_V2;
180 } else { 183 break;
184 default:
185 pmu_kind = PMU_UNKNOWN;
181 return -ENODEV; 186 return -ENODEV;
182 } 187 }
183 188
184 pmu_state = idle; 189 pmu_state = idle;
185 190
191 if (!init_pmu())
192 goto fail_init;
193
194 pr_info("adb: PMU 68K driver v0.5 for Unified ADB\n");
195
196 return 1;
197
198fail_init:
199 pmu_kind = PMU_UNKNOWN;
186 return 0; 200 return 0;
187} 201}
188 202
189static int 203static int pmu_probe(void)
190pmu_init(void) 204{
205 if (pmu_kind == PMU_UNKNOWN)
206 return -ENODEV;
207 return 0;
208}
209
210static int pmu_init(void)
211{
212 if (pmu_kind == PMU_UNKNOWN)
213 return -ENODEV;
214 return 0;
215}
216
217static int __init via_pmu_start(void)
218{
219 if (pmu_kind == PMU_UNKNOWN)
220 return -ENODEV;
221
222 if (request_irq(IRQ_MAC_ADB_SR, pmu_interrupt, 0, "PMU_SR",
223 pmu_interrupt)) {
224 pr_err("%s: can't get SR irq\n", __func__);
225 return -ENODEV;
226 }
227 if (request_irq(IRQ_MAC_ADB_CL, pmu_interrupt, 0, "PMU_CL",
228 pmu_interrupt)) {
229 pr_err("%s: can't get CL irq\n", __func__);
230 free_irq(IRQ_MAC_ADB_SR, pmu_interrupt);
231 return -ENODEV;
232 }
233
234 pmu_fully_inited = 1;
235
236 /* Enable backlight */
237 pmu_enable_backlight(1);
238
239 return 0;
240}
241
242arch_initcall(via_pmu_start);
243
244static int __init init_pmu(void)
191{ 245{
192 int timeout; 246 int timeout;
193 volatile struct adb_request req; 247 volatile struct adb_request req;
@@ -238,28 +292,7 @@ pmu_init(void)
238 bright_req_2.complete = 1; 292 bright_req_2.complete = 1;
239 bright_req_3.complete = 1; 293 bright_req_3.complete = 1;
240 294
241 if (request_irq(IRQ_MAC_ADB_SR, pmu_interrupt, 0, "pmu-shift", 295 return 1;
242 pmu_interrupt)) {
243 printk(KERN_ERR "pmu_init: can't get irq %d\n",
244 IRQ_MAC_ADB_SR);
245 return -EAGAIN;
246 }
247 if (request_irq(IRQ_MAC_ADB_CL, pmu_interrupt, 0, "pmu-clock",
248 pmu_interrupt)) {
249 printk(KERN_ERR "pmu_init: can't get irq %d\n",
250 IRQ_MAC_ADB_CL);
251 free_irq(IRQ_MAC_ADB_SR, pmu_interrupt);
252 return -EAGAIN;
253 }
254
255 pmu_fully_inited = 1;
256
257 /* Enable backlight */
258 pmu_enable_backlight(1);
259
260 printk("adb: PMU 68K driver v0.5 for Unified ADB.\n");
261
262 return 0;
263} 296}
264 297
265int 298int