30
30
31
31
#include "amdgpu.h"
32
32
#include "amdgpu_isp.h"
33
-
34
- #include "ivsrcid/isp/irqsrcs_isp_4_1.h"
35
-
36
- #define mmDAGB0_WRCLI5_V4_1 0x6811C
37
- #define mmDAGB0_WRCLI9_V4_1 0x6812C
38
- #define mmDAGB0_WRCLI10_V4_1 0x68130
39
- #define mmDAGB0_WRCLI14_V4_1 0x68140
40
- #define mmDAGB0_WRCLI19_V4_1 0x68154
41
- #define mmDAGB0_WRCLI20_V4_1 0x68158
42
-
43
- static const unsigned int isp_int_srcid [MAX_ISP_INT_SRC ] = {
44
- ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 ,
45
- ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 ,
46
- ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 ,
47
- ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 ,
48
- ISP_4_1__SRCID__ISP_RINGBUFFER_WPT13 ,
49
- ISP_4_1__SRCID__ISP_RINGBUFFER_WPT14 ,
50
- ISP_4_1__SRCID__ISP_RINGBUFFER_WPT15 ,
51
- ISP_4_1__SRCID__ISP_RINGBUFFER_WPT16
52
- };
33
+ #include "isp_v4_1_0.h"
34
+ #include "isp_v4_1_1.h"
53
35
54
36
static int isp_sw_init (void * handle )
55
37
{
56
- struct amdgpu_device * adev = (struct amdgpu_device * )handle ;
57
-
58
- adev -> isp .parent = adev -> dev ;
59
-
60
- adev -> isp .cgs_device = amdgpu_cgs_create_device (adev );
61
- if (!adev -> isp .cgs_device )
62
- return - EINVAL ;
63
-
64
38
return 0 ;
65
39
}
66
40
67
41
static int isp_sw_fini (void * handle )
68
42
{
69
- struct amdgpu_device * adev = (struct amdgpu_device * )handle ;
70
-
71
- if (adev -> isp .cgs_device )
72
- amdgpu_cgs_destroy_device (adev -> isp .cgs_device );
73
-
74
43
return 0 ;
75
44
}
76
45
@@ -83,93 +52,18 @@ static int isp_sw_fini(void *handle)
83
52
static int isp_hw_init (void * handle )
84
53
{
85
54
struct amdgpu_device * adev = (struct amdgpu_device * )handle ;
55
+ struct amdgpu_isp * isp = & adev -> isp ;
56
+
86
57
const struct amdgpu_ip_block * ip_block =
87
58
amdgpu_device_ip_get_ip_block (adev , AMD_IP_BLOCK_TYPE_ISP );
88
- u64 isp_base ;
89
- int int_idx ;
90
- int r ;
91
59
92
60
if (!ip_block )
93
61
return - EINVAL ;
94
62
95
- if (adev -> rmmio_size == 0 || adev -> rmmio_size < 0x5289 )
96
- return - EINVAL ;
97
-
98
- isp_base = adev -> rmmio_base ;
99
-
100
- adev -> isp .isp_cell = kcalloc (1 , sizeof (struct mfd_cell ), GFP_KERNEL );
101
- if (!adev -> isp .isp_cell ) {
102
- r = - ENOMEM ;
103
- DRM_ERROR ("%s: isp mfd cell alloc failed\n" , __func__ );
104
- goto failure ;
105
- }
106
-
107
- adev -> isp .isp_res = kcalloc (9 , sizeof (struct resource ), GFP_KERNEL );
108
- if (!adev -> isp .isp_res ) {
109
- r = - ENOMEM ;
110
- DRM_ERROR ("%s: isp mfd res alloc failed\n" , __func__ );
111
- goto failure ;
112
- }
113
-
114
- adev -> isp .isp_pdata = kzalloc (sizeof (* adev -> isp .isp_pdata ), GFP_KERNEL );
115
- if (!adev -> isp .isp_pdata ) {
116
- r = - ENOMEM ;
117
- DRM_ERROR ("%s: isp platform data alloc failed\n" , __func__ );
118
- goto failure ;
119
- }
120
-
121
- /* initialize isp platform data */
122
- adev -> isp .isp_pdata -> adev = (void * )adev ;
123
- adev -> isp .isp_pdata -> asic_type = adev -> asic_type ;
124
- adev -> isp .isp_pdata -> base_rmmio_size = adev -> rmmio_size ;
125
-
126
- adev -> isp .isp_res [0 ].name = "isp_reg" ;
127
- adev -> isp .isp_res [0 ].flags = IORESOURCE_MEM ;
128
- adev -> isp .isp_res [0 ].start = isp_base ;
129
- adev -> isp .isp_res [0 ].end = isp_base + ISP_REGS_OFFSET_END ;
130
-
131
- for (int_idx = 0 ; int_idx < MAX_ISP_INT_SRC ; int_idx ++ ) {
132
- adev -> isp .isp_res [int_idx + 1 ].name = "isp_irq" ;
133
- adev -> isp .isp_res [int_idx + 1 ].flags = IORESOURCE_IRQ ;
134
- adev -> isp .isp_res [int_idx + 1 ].start =
135
- amdgpu_irq_create_mapping (adev , isp_int_srcid [int_idx ]);
136
- adev -> isp .isp_res [int_idx + 1 ].end =
137
- adev -> isp .isp_res [int_idx + 1 ].start ;
138
- }
139
-
140
- adev -> isp .isp_cell [0 ].name = "amd_isp_capture" ;
141
- adev -> isp .isp_cell [0 ].num_resources = 9 ;
142
- adev -> isp .isp_cell [0 ].resources = & adev -> isp .isp_res [0 ];
143
- adev -> isp .isp_cell [0 ].platform_data = adev -> isp .isp_pdata ;
144
- adev -> isp .isp_cell [0 ].pdata_size = sizeof (struct isp_platform_data );
63
+ if (isp -> funcs -> hw_init != NULL )
64
+ return isp -> funcs -> hw_init (isp );
145
65
146
- r = mfd_add_hotplug_devices (adev -> isp .parent , adev -> isp .isp_cell , 1 );
147
- if (r ) {
148
- DRM_ERROR ("%s: add mfd hotplug device failed\n" , __func__ );
149
- goto failure ;
150
- }
151
-
152
- /*
153
- * Temporary WA added to disable MMHUB TLSi until the GART initialization
154
- * is ready to support MMHUB TLSi and SAW for ISP HW to access GART memory
155
- * using the TLSi path
156
- */
157
- cgs_write_register (adev -> isp .cgs_device , mmDAGB0_WRCLI5_V4_1 >> 2 , 0xFE5FEAA8 );
158
- cgs_write_register (adev -> isp .cgs_device , mmDAGB0_WRCLI9_V4_1 >> 2 , 0xFE5FEAA8 );
159
- cgs_write_register (adev -> isp .cgs_device , mmDAGB0_WRCLI10_V4_1 >> 2 , 0xFE5FEAA8 );
160
- cgs_write_register (adev -> isp .cgs_device , mmDAGB0_WRCLI14_V4_1 >> 2 , 0xFE5FEAA8 );
161
- cgs_write_register (adev -> isp .cgs_device , mmDAGB0_WRCLI19_V4_1 >> 2 , 0xFE5FEAA8 );
162
- cgs_write_register (adev -> isp .cgs_device , mmDAGB0_WRCLI20_V4_1 >> 2 , 0xFE5FEAA8 );
163
-
164
- return 0 ;
165
-
166
- failure :
167
-
168
- kfree (adev -> isp .isp_pdata );
169
- kfree (adev -> isp .isp_res );
170
- kfree (adev -> isp .isp_cell );
171
-
172
- return r ;
66
+ return - ENODEV ;
173
67
}
174
68
175
69
/**
@@ -181,15 +75,12 @@ static int isp_hw_init(void *handle)
181
75
static int isp_hw_fini (void * handle )
182
76
{
183
77
struct amdgpu_device * adev = (struct amdgpu_device * )handle ;
78
+ struct amdgpu_isp * isp = & adev -> isp ;
184
79
185
- /* remove isp mfd device */
186
- mfd_remove_devices ( adev -> isp . parent );
80
+ if ( isp -> funcs -> hw_fini != NULL )
81
+ return isp -> funcs -> hw_fini ( isp );
187
82
188
- kfree (adev -> isp .isp_res );
189
- kfree (adev -> isp .isp_cell );
190
- kfree (adev -> isp .isp_pdata );
191
-
192
- return 0 ;
83
+ return - ENODEV ;
193
84
}
194
85
195
86
static int isp_suspend (void * handle )
@@ -235,17 +126,29 @@ static int isp_load_fw_by_psp(struct amdgpu_device *adev)
235
126
236
127
static int isp_early_init (void * handle )
237
128
{
238
- int ret = 0 ;
239
129
struct amdgpu_device * adev = (struct amdgpu_device * )handle ;
130
+ struct amdgpu_isp * isp = & adev -> isp ;
131
+
132
+ switch (amdgpu_ip_version (adev , ISP_HWIP , 0 )) {
133
+ case IP_VERSION (4 , 1 , 0 ):
134
+ isp_v4_1_0_set_isp_funcs (isp );
135
+ break ;
136
+ case IP_VERSION (4 , 1 , 1 ):
137
+ isp_v4_1_1_set_isp_funcs (isp );
138
+ break ;
139
+ default :
140
+ return - EINVAL ;
141
+ }
142
+
143
+ isp -> adev = adev ;
144
+ isp -> parent = adev -> dev ;
240
145
241
- ret = isp_load_fw_by_psp (adev );
242
- if (ret ) {
243
- DRM_WARN ("%s: isp fw load failed %d\n" , __func__ , ret );
244
- /* allow amdgpu init to proceed though isp fw load fails */
245
- ret = 0 ;
146
+ if (isp_load_fw_by_psp (adev )) {
147
+ DRM_WARN ("%s: isp fw load failed\n" , __func__ );
148
+ return 0 ;
246
149
}
247
150
248
- return ret ;
151
+ return 0 ;
249
152
}
250
153
251
154
static bool isp_is_idle (void * handle )
@@ -292,10 +195,18 @@ static const struct amd_ip_funcs isp_ip_funcs = {
292
195
.set_powergating_state = isp_set_powergating_state ,
293
196
};
294
197
295
- const struct amdgpu_ip_block_version isp_ip_block = {
198
+ const struct amdgpu_ip_block_version isp_v4_1_0_ip_block = {
296
199
.type = AMD_IP_BLOCK_TYPE_ISP ,
297
200
.major = 4 ,
298
201
.minor = 1 ,
299
202
.rev = 0 ,
300
203
.funcs = & isp_ip_funcs ,
301
204
};
205
+
206
+ const struct amdgpu_ip_block_version isp_v4_1_1_ip_block = {
207
+ .type = AMD_IP_BLOCK_TYPE_ISP ,
208
+ .major = 4 ,
209
+ .minor = 1 ,
210
+ .rev = 1 ,
211
+ .funcs = & isp_ip_funcs ,
212
+ };
0 commit comments