This source file includes following definitions.
- ldphys
- clk_init
- clk_slow
- tsu_clockstop
- swift_clockstop
- clock_stop_probe
1
2
3
4
5
6 #include <linux/string.h>
7
8 #include <asm/asi.h>
9 #include <asm/oplib.h>
10 #include <asm/io.h>
11
12 #define MACIO_SCSI_CSR_ADDR 0x78400000
13 #define MACIO_EN_DMA 0x00000200
14 #define CLOCK_INIT_DONE 1
15
16 static int clk_state;
17 static volatile unsigned char *clk_ctrl;
18 void (*cpu_pwr_save)(void);
19
20 static inline unsigned int ldphys(unsigned int addr)
21 {
22 unsigned long data;
23
24 __asm__ __volatile__("\n\tlda [%1] %2, %0\n\t" :
25 "=r" (data) :
26 "r" (addr), "i" (ASI_M_BYPASS));
27 return data;
28 }
29
30 static void clk_init(void)
31 {
32 __asm__ __volatile__("mov 0x6c, %%g1\n\t"
33 "mov 0x4c, %%g2\n\t"
34 "mov 0xdf, %%g3\n\t"
35 "stb %%g1, [%0+3]\n\t"
36 "stb %%g2, [%0+3]\n\t"
37 "stb %%g3, [%0+3]\n\t" : :
38 "r" (clk_ctrl) :
39 "g1", "g2", "g3");
40 }
41
42 static void clk_slow(void)
43 {
44 __asm__ __volatile__("mov 0xcc, %%g2\n\t"
45 "mov 0x4c, %%g3\n\t"
46 "mov 0xcf, %%g4\n\t"
47 "mov 0xdf, %%g5\n\t"
48 "stb %%g2, [%0+3]\n\t"
49 "stb %%g3, [%0+3]\n\t"
50 "stb %%g4, [%0+3]\n\t"
51 "stb %%g5, [%0+3]\n\t" : :
52 "r" (clk_ctrl) :
53 "g2", "g3", "g4", "g5");
54 }
55
56 static void tsu_clockstop(void)
57 {
58 unsigned int mcsr;
59 unsigned long flags;
60
61 if (!clk_ctrl)
62 return;
63 if (!(clk_state & CLOCK_INIT_DONE)) {
64 save_flags(flags); cli();
65 clk_init();
66 clk_state |= CLOCK_INIT_DONE;
67 restore_flags(flags);
68 return;
69 }
70 if (!(clk_ctrl[2] & 1))
71 return;
72
73 save_flags(flags); cli();
74
75
76 mcsr = ldphys(MACIO_SCSI_CSR_ADDR);
77 if ((mcsr&MACIO_EN_DMA) != 0) {
78 restore_flags(flags);
79 return;
80 }
81
82
83
84 clk_slow();
85 restore_flags(flags);
86 }
87
88 static void swift_clockstop(void)
89 {
90 if (!clk_ctrl)
91 return;
92 clk_ctrl[0] = 0;
93 }
94
95 void clock_stop_probe(void)
96 {
97 unsigned int node, clk_nd;
98 char name[20];
99
100 prom_getstring(prom_root_node, "name", name, sizeof(name));
101 if (strncmp(name, "Tadpole", 7))
102 return;
103 node = prom_getchild(prom_root_node);
104 node = prom_searchsiblings(node, "obio");
105 node = prom_getchild(node);
106 clk_nd = prom_searchsiblings(node, "clk-ctrl");
107 if (!clk_nd)
108 return;
109 printk("Clock Stopping h/w detected... ");
110 clk_ctrl = (char *) prom_getint(clk_nd, "address");
111 clk_state = 0;
112 if (name[10] == '\0') {
113 cpu_pwr_save = tsu_clockstop;
114 printk("enabled (S3)\n");
115 } else if ((name[10] == 'X') || (name[10] == 'G')) {
116 cpu_pwr_save = swift_clockstop;
117 printk("enabled (%s)\n",name+7);
118 } else
119 printk("disabled %s\n",name+7);
120 }