1 /* SPDX-License-Identifier: MIT */
3 * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
29 #include "isp_v4_1_1.h"
31 static const unsigned int isp_4_1_1_int_srcid[MAX_ISP411_INT_SRC] = {
32 ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9,
33 ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10,
34 ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11,
35 ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12,
36 ISP_4_1__SRCID__ISP_RINGBUFFER_WPT13,
37 ISP_4_1__SRCID__ISP_RINGBUFFER_WPT14,
38 ISP_4_1__SRCID__ISP_RINGBUFFER_WPT15,
39 ISP_4_1__SRCID__ISP_RINGBUFFER_WPT16
42 static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
44 struct amdgpu_device *adev = isp->adev;
49 if (adev->rmmio_size == 0 || adev->rmmio_size < 0x5289)
52 isp_base = adev->rmmio_base;
54 isp->isp_cell = kcalloc(1, sizeof(struct mfd_cell), GFP_KERNEL);
57 DRM_ERROR("%s: isp mfd cell alloc failed\n", __func__);
61 isp->isp_res = kcalloc(MAX_ISP411_INT_SRC + 1, sizeof(struct resource),
65 DRM_ERROR("%s: isp mfd res alloc failed\n", __func__);
69 isp->isp_pdata = kzalloc(sizeof(*isp->isp_pdata), GFP_KERNEL);
70 if (!isp->isp_pdata) {
72 DRM_ERROR("%s: isp platform data alloc failed\n", __func__);
76 /* initialize isp platform data */
77 isp->isp_pdata->adev = (void *)adev;
78 isp->isp_pdata->asic_type = adev->asic_type;
79 isp->isp_pdata->base_rmmio_size = adev->rmmio_size;
81 isp->isp_res[0].name = "isp_4_1_1_reg";
82 isp->isp_res[0].flags = IORESOURCE_MEM;
83 isp->isp_res[0].start = isp_base;
84 isp->isp_res[0].end = isp_base + ISP_REGS_OFFSET_END;
86 for (int_idx = 0; int_idx < MAX_ISP411_INT_SRC; int_idx++) {
87 isp->isp_res[int_idx + 1].name = "isp_4_1_1_irq";
88 isp->isp_res[int_idx + 1].flags = IORESOURCE_IRQ;
89 isp->isp_res[int_idx + 1].start =
90 amdgpu_irq_create_mapping(adev, isp_4_1_1_int_srcid[int_idx]);
91 isp->isp_res[int_idx + 1].end =
92 isp->isp_res[int_idx + 1].start;
95 isp->isp_cell[0].name = "amd_isp_capture";
96 isp->isp_cell[0].num_resources = MAX_ISP411_INT_SRC + 1;
97 isp->isp_cell[0].resources = &isp->isp_res[0];
98 isp->isp_cell[0].platform_data = isp->isp_pdata;
99 isp->isp_cell[0].pdata_size = sizeof(struct isp_platform_data);
101 r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 1);
103 DRM_ERROR("%s: add mfd hotplug device failed\n", __func__);
111 kfree(isp->isp_pdata);
113 kfree(isp->isp_cell);
118 static int isp_v4_1_1_hw_fini(struct amdgpu_isp *isp)
120 mfd_remove_devices(isp->parent);
123 kfree(isp->isp_cell);
124 kfree(isp->isp_pdata);
129 static const struct isp_funcs isp_v4_1_1_funcs = {
130 .hw_init = isp_v4_1_1_hw_init,
131 .hw_fini = isp_v4_1_1_hw_fini,
134 void isp_v4_1_1_set_isp_funcs(struct amdgpu_isp *isp)
136 isp->funcs = &isp_v4_1_1_funcs;