1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
/*++
linux/arch/arm/mach-wmt/board.c
Copyright (c) 2012 WonderMedia Technologies, Inc.
This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation,
either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
WonderMedia Technologies, Inc.
10F, 529, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C.
--*/
#define fail -1
#include <mach/hardware.h>
#include <mach/irqs.h>
#include <linux/sysctl.h>
extern unsigned int wmt_i2c0_speed_mode;
extern unsigned int wmt_i2c1_speed_mode;
#if 0
static int PM_USB_PostSuspend(void)
{
return 0;
}
static int PM_USB_PreResume(void)
{
unsigned int tmp32;
unsigned char tmp8;
/* EHCI PCI configuration seting */
/* set bus master */
*(volatile unsigned char*) 0xd8007804 = 0x17;
tmp8 = *(volatile unsigned char*) 0xd8007804;
if (tmp8 != 0x17) {
printk("PM_USB_init : 0xd8007104 = %02x\n", tmp8);
return fail;
}
/* set interrupt line */
*(volatile unsigned char*) 0xd800783c = 0x2b;
tmp8 = *(volatile unsigned char*) 0xd800783c;
if (tmp8 != 0x2b) {
printk("PM_USB_init : 0xd800713c = %02x\n", tmp8);
return fail;
}
/* enable AHB master cut data to 16/8/4 DW align */
tmp32 = *(volatile unsigned char*) 0xd800784c;
tmp32 &= 0xfffdffff;
*(volatile unsigned char*) 0xd800784c = tmp32;
tmp32 = *(volatile unsigned char*) 0xd800784c;
if ((tmp32&0x00020000) != 0x00000000)
printk("[EHCI] Programming EHCI PCI Configuration Offset Address : 4ch fail! \n");
/* UHCI PCI configuration setting */
/* set bus master */
*(volatile unsigned char*) 0xd8007a04 = 0x07;
tmp8 = *(volatile unsigned char*) 0xd8007a04;
if (tmp8 != 0x07) {
printk("PM_USB_init : 0xd8007304 = %02x\n", tmp8);
return fail;
}
/* set interrupt line */
*(volatile unsigned char*) 0xd8007a3c = 0x2b;
tmp8 = *(volatile unsigned char*) 0xd8007a3c;
if (tmp8 != 0x2b) {
printk("PM_USB_init : 0xd800733c = %02x\n", tmp8);
return fail;
}
return 0;
}
#endif
#if 0
static char MACVeeRom[32] = {0xFF};
static void PM_MAC_PreResume(void)
{
int i = 0;
*((volatile unsigned char*)0xd8004104) = 0x4;
/* restore VEE */
for (i = 0; i < 8; i++)
*(volatile unsigned long *)(0xd800415C + i*4) = *((int *)MACVeeRom + i);
/* reload VEE */
*(volatile unsigned char*)0xd800417C |= 0x01;
/* reload */
*(volatile unsigned char*)0xd8004074 |= 0xa0;
/* check reload VEE complete */
while ((*(volatile unsigned char*)0xd800417C & 0x02) != 0x02);
return;
}
static void PM_MAC_PostSuspend(void)
{
int i = 0;
/*save VEE*/
for (i = 0; i < 32; i++)
MACVeeRom[i] = *((volatile unsigned char*)0xd800415C + i);
return;
}
#endif
inline unsigned int wmt_read_oscr(void);
static u32 cyc_mark = 0;
#define PRIVATE_TIMER_CTRL (MPCORE_PRIVATE_MEM + 0x600)
#define PRIVATE_TIMER_INTSTAT (MPCORE_PRIVATE_MEM + 0x60C)
#define GIC_PEN_CLR (0xFE019280)
static void wmt_timer_postsuspend(void)
{
cyc_mark = wmt_read_oscr();
if (REG32_VAL(PRIVATE_TIMER_INTSTAT)) {
REG32_VAL(PRIVATE_TIMER_INTSTAT) = 0x1;
REG32_VAL(GIC_PEN_CLR) = 0x20000000;
}
}
static void wmt_timer_preresume(void)
{
// set saved counter value
OSCR_VAL = cyc_mark;
}
int PM_device_PreResume(void)
{
int result;
/* PM_MAC_PreResume(); */
wmt_timer_preresume();
/*
result = PM_USB_PreResume();
if (!result)
goto FAIL;
*/
return 0;
/* FAIL: */
return result;
}
int PM_device_PostSuspend(void)
{
/* PM_MAC_PostSuspend(); */
wmt_timer_postsuspend();
return 0;
}
|