Skip to content

Commit 05bafe9

Browse files
Pratap Nirujogialexdeucher
authored andcommitted
drm/amd/amdgpu: Add ISP4.1.0 and ISP4.1.1 modules
Add independent IP centric modules for ISP4.1.0 and ISP4.1.1 hw blocks. Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Pratap Nirujogi <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 0253d71 commit 05bafe9

File tree

8 files changed

+427
-133
lines changed

8 files changed

+427
-133
lines changed

drivers/gpu/drm/amd/amdgpu/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ endif
325325

326326
# add isp block
327327
ifneq ($(CONFIG_DRM_AMD_ISP),)
328-
amdgpu-y += amdgpu_isp.o
328+
amdgpu-y += \
329+
amdgpu_isp.o \
330+
isp_v4_1_0.o \
331+
isp_v4_1_1.o
329332
endif
330333

331334
obj-$(CONFIG_DRM_AMDGPU)+= amdgpu.o

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2391,8 +2391,10 @@ static int amdgpu_discovery_set_isp_ip_blocks(struct amdgpu_device *adev)
23912391
#if defined(CONFIG_DRM_AMD_ISP)
23922392
switch (amdgpu_ip_version(adev, ISP_HWIP, 0)) {
23932393
case IP_VERSION(4, 1, 0):
2394+
amdgpu_device_ip_block_add(adev, &isp_v4_1_0_ip_block);
2395+
break;
23942396
case IP_VERSION(4, 1, 1):
2395-
amdgpu_device_ip_block_add(adev, &isp_ip_block);
2397+
amdgpu_device_ip_block_add(adev, &isp_v4_1_1_ip_block);
23962398
break;
23972399
default:
23982400
break;

drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c

Lines changed: 39 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -30,47 +30,16 @@
3030

3131
#include "amdgpu.h"
3232
#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"
5335

5436
static int isp_sw_init(void *handle)
5537
{
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-
6438
return 0;
6539
}
6640

6741
static int isp_sw_fini(void *handle)
6842
{
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-
7443
return 0;
7544
}
7645

@@ -83,93 +52,18 @@ static int isp_sw_fini(void *handle)
8352
static int isp_hw_init(void *handle)
8453
{
8554
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
55+
struct amdgpu_isp *isp = &adev->isp;
56+
8657
const struct amdgpu_ip_block *ip_block =
8758
amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_ISP);
88-
u64 isp_base;
89-
int int_idx;
90-
int r;
9159

9260
if (!ip_block)
9361
return -EINVAL;
9462

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);
14565

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;
17367
}
17468

17569
/**
@@ -181,15 +75,12 @@ static int isp_hw_init(void *handle)
18175
static int isp_hw_fini(void *handle)
18276
{
18377
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
78+
struct amdgpu_isp *isp = &adev->isp;
18479

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);
18782

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;
19384
}
19485

19586
static int isp_suspend(void *handle)
@@ -235,17 +126,29 @@ static int isp_load_fw_by_psp(struct amdgpu_device *adev)
235126

236127
static int isp_early_init(void *handle)
237128
{
238-
int ret = 0;
239129
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;
240145

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;
246149
}
247150

248-
return ret;
151+
return 0;
249152
}
250153

251154
static bool isp_is_idle(void *handle)
@@ -292,10 +195,18 @@ static const struct amd_ip_funcs isp_ip_funcs = {
292195
.set_powergating_state = isp_set_powergating_state,
293196
};
294197

295-
const struct amdgpu_ip_block_version isp_ip_block = {
198+
const struct amdgpu_ip_block_version isp_v4_1_0_ip_block = {
296199
.type = AMD_IP_BLOCK_TYPE_ISP,
297200
.major = 4,
298201
.minor = 1,
299202
.rev = 0,
300203
.funcs = &isp_ip_funcs,
301204
};
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+
};

drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,31 @@
3030

3131
#define ISP_REGS_OFFSET_END 0x629A4
3232

33-
#define MAX_ISP_INT_SRC 8
33+
struct amdgpu_isp;
3434

3535
struct isp_platform_data {
3636
void *adev;
3737
u32 asic_type;
3838
resource_size_t base_rmmio_size;
3939
};
4040

41+
struct isp_funcs {
42+
int (*hw_init)(struct amdgpu_isp *isp);
43+
int (*hw_fini)(struct amdgpu_isp *isp);
44+
};
45+
4146
struct amdgpu_isp {
4247
struct device *parent;
43-
struct cgs_device *cgs_device;
48+
struct amdgpu_device *adev;
49+
const struct isp_funcs *funcs;
4450
struct mfd_cell *isp_cell;
4551
struct resource *isp_res;
4652
struct isp_platform_data *isp_pdata;
4753
unsigned int harvest_config;
4854
const struct firmware *fw;
4955
};
5056

51-
extern const struct amdgpu_ip_block_version isp_ip_block;
57+
extern const struct amdgpu_ip_block_version isp_v4_1_0_ip_block;
58+
extern const struct amdgpu_ip_block_version isp_v4_1_1_ip_block;
5259

5360
#endif /* __AMDGPU_ISP_H__ */

0 commit comments

Comments
 (0)