Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/gpu/drm/ast/ast_post.c
26493 views
1
/*
2
* Copyright 2012 Red Hat Inc.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the
6
* "Software"), to deal in the Software without restriction, including
7
* without limitation the rights to use, copy, modify, merge, publish,
8
* distribute, sub license, and/or sell copies of the Software, and to
9
* permit persons to whom the Software is furnished to do so, subject to
10
* the following conditions:
11
*
12
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
15
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
16
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
* USE OR OTHER DEALINGS IN THE SOFTWARE.
19
*
20
* The above copyright notice and this permission notice (including the
21
* next paragraph) shall be included in all copies or substantial portions
22
* of the Software.
23
*
24
*/
25
/*
26
* Authors: Dave Airlie <[email protected]>
27
*/
28
29
#include <linux/delay.h>
30
#include <linux/pci.h>
31
32
#include <drm/drm_print.h>
33
34
#include "ast_drv.h"
35
#include "ast_post.h"
36
37
u32 __ast_mindwm(void __iomem *regs, u32 r)
38
{
39
u32 data;
40
41
__ast_write32(regs, 0xf004, r & 0xffff0000);
42
__ast_write32(regs, 0xf000, 0x1);
43
44
do {
45
data = __ast_read32(regs, 0xf004) & 0xffff0000;
46
} while (data != (r & 0xffff0000));
47
48
return __ast_read32(regs, 0x10000 + (r & 0x0000ffff));
49
}
50
51
void __ast_moutdwm(void __iomem *regs, u32 r, u32 v)
52
{
53
u32 data;
54
55
__ast_write32(regs, 0xf004, r & 0xffff0000);
56
__ast_write32(regs, 0xf000, 0x1);
57
58
do {
59
data = __ast_read32(regs, 0xf004) & 0xffff0000;
60
} while (data != (r & 0xffff0000));
61
62
__ast_write32(regs, 0x10000 + (r & 0x0000ffff), v);
63
}
64
65
u32 ast_mindwm(struct ast_device *ast, u32 r)
66
{
67
return __ast_mindwm(ast->regs, r);
68
}
69
70
void ast_moutdwm(struct ast_device *ast, u32 r, u32 v)
71
{
72
__ast_moutdwm(ast->regs, r, v);
73
}
74
75
int ast_post_gpu(struct ast_device *ast)
76
{
77
int ret;
78
79
if (AST_GEN(ast) >= 7) {
80
ret = ast_2600_post(ast);
81
if (ret)
82
return ret;
83
} else if (AST_GEN(ast) >= 6) {
84
ret = ast_2500_post(ast);
85
if (ret)
86
return ret;
87
} else if (AST_GEN(ast) >= 4) {
88
ret = ast_2300_post(ast);
89
if (ret)
90
return ret;
91
} else if (AST_GEN(ast) >= 2) {
92
ret = ast_2100_post(ast);
93
if (ret)
94
return ret;
95
} else {
96
ret = ast_2000_post(ast);
97
if (ret)
98
return ret;
99
}
100
101
return 0;
102
}
103
104
#define TIMEOUT 5000000
105
106
bool mmc_test(struct ast_device *ast, u32 datagen, u8 test_ctl)
107
{
108
u32 data, timeout;
109
110
ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
111
ast_moutdwm(ast, 0x1e6e0070, (datagen << 3) | test_ctl);
112
timeout = 0;
113
do {
114
data = ast_mindwm(ast, 0x1e6e0070) & 0x3000;
115
if (data & 0x2000)
116
return false;
117
if (++timeout > TIMEOUT) {
118
ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
119
return false;
120
}
121
} while (!data);
122
ast_moutdwm(ast, 0x1e6e0070, 0x0);
123
return true;
124
}
125
126
bool mmc_test_burst(struct ast_device *ast, u32 datagen)
127
{
128
return mmc_test(ast, datagen, 0xc1);
129
}
130
131