Skip to content

Commit 3e9d9df

Browse files
Pratap Nirujogialexdeucher
authored andcommitted
drm/amd/amdgpu: Add GPIO resources required for amdisp
ISP is a child device to GFX, and its device specific information is not available in ACPI. Adding the 2 GPIO resources required for ISP_v4_1_1 in amdgpu_isp driver. - GPIO 0 to allow sensor driver to enable and disable sensor module. - GPIO 85 to allow ISP driver to enable and disable ISP RGB streaming mode. Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent e485502 commit 3e9d9df

4 files changed

Lines changed: 67 additions & 2 deletions

File tree

drivers/gpu/drm/amd/amdgpu/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ config DRM_AMDGPU_USERPTR
7777

7878
config DRM_AMD_ISP
7979
bool "Enable AMD Image Signal Processor IP support"
80-
depends on DRM_AMDGPU
80+
depends on DRM_AMDGPU && ACPI
8181
select MFD_CORE
8282
select PM_GENERIC_DOMAINS if PM
8383
help

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,10 @@ static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { retu
17131713
static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false; }
17141714
#endif
17151715

1716+
#if defined(CONFIG_DRM_AMD_ISP)
1717+
int amdgpu_acpi_get_isp4_dev_hid(u8 (*hid)[ACPI_ID_LEN]);
1718+
#endif
1719+
17161720
void amdgpu_register_gpu_instance(struct amdgpu_device *adev);
17171721
void amdgpu_unregister_gpu_instance(struct amdgpu_device *adev);
17181722

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,5 +1532,35 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev)
15321532
return true;
15331533
#endif /* CONFIG_AMD_PMC */
15341534
}
1535-
15361535
#endif /* CONFIG_SUSPEND */
1536+
1537+
#if IS_ENABLED(CONFIG_DRM_AMD_ISP)
1538+
static const struct acpi_device_id isp_sensor_ids[] = {
1539+
{ "OMNI5C10" },
1540+
{ }
1541+
};
1542+
1543+
static int isp_match_acpi_device_ids(struct device *dev, const void *data)
1544+
{
1545+
return acpi_match_device(data, dev) ? 1 : 0;
1546+
}
1547+
1548+
int amdgpu_acpi_get_isp4_dev_hid(u8 (*hid)[ACPI_ID_LEN])
1549+
{
1550+
struct device *pdev __free(put_device) = NULL;
1551+
struct acpi_device *acpi_pdev;
1552+
1553+
pdev = bus_find_device(&platform_bus_type, NULL, isp_sensor_ids,
1554+
isp_match_acpi_device_ids);
1555+
if (!pdev)
1556+
return -EINVAL;
1557+
1558+
acpi_pdev = ACPI_COMPANION(pdev);
1559+
if (!acpi_pdev)
1560+
return -ENODEV;
1561+
1562+
strscpy(*hid, acpi_device_hid(acpi_pdev));
1563+
1564+
return 0;
1565+
}
1566+
#endif /* CONFIG_DRM_AMD_ISP */

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*
2626
*/
2727

28+
#include <linux/gpio/machine.h>
2829
#include "amdgpu.h"
2930
#include "isp_v4_1_1.h"
3031

@@ -39,15 +40,45 @@ static const unsigned int isp_4_1_1_int_srcid[MAX_ISP411_INT_SRC] = {
3940
ISP_4_1__SRCID__ISP_RINGBUFFER_WPT16
4041
};
4142

43+
static struct gpiod_lookup_table isp_gpio_table = {
44+
.dev_id = "amd_isp_capture",
45+
.table = {
46+
GPIO_LOOKUP("AMDI0030:00", 85, "enable_isp", GPIO_ACTIVE_HIGH),
47+
{ }
48+
},
49+
};
50+
51+
static struct gpiod_lookup_table isp_sensor_gpio_table = {
52+
.dev_id = "i2c-ov05c10",
53+
.table = {
54+
GPIO_LOOKUP("amdisp-pinctrl", 0, "enable", GPIO_ACTIVE_HIGH),
55+
{ }
56+
},
57+
};
58+
4259
static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
4360
{
4461
struct amdgpu_device *adev = isp->adev;
4562
int idx, int_idx, num_res, r;
63+
u8 isp_dev_hid[ACPI_ID_LEN];
4664
u64 isp_base;
4765

4866
if (adev->rmmio_size == 0 || adev->rmmio_size < 0x5289)
4967
return -EINVAL;
5068

69+
r = amdgpu_acpi_get_isp4_dev_hid(&isp_dev_hid);
70+
if (r) {
71+
drm_dbg(&adev->ddev, "Invalid isp platform detected (%d)", r);
72+
/* allow GPU init to progress */
73+
return 0;
74+
}
75+
76+
/* add GPIO resources required for OMNI5C10 sensor */
77+
if (!strcmp("OMNI5C10", isp_dev_hid)) {
78+
gpiod_add_lookup_table(&isp_gpio_table);
79+
gpiod_add_lookup_table(&isp_sensor_gpio_table);
80+
}
81+
5182
isp_base = adev->rmmio_base;
5283

5384
isp->isp_cell = kcalloc(3, sizeof(struct mfd_cell), GFP_KERNEL);

0 commit comments

Comments
 (0)