Skip to content

Commit

Permalink
drm/amdgpu: Add amdisp pinctrl MFD resource
Browse files Browse the repository at this point in the history
AMDISP GPIO control uses a dedicated pinctrl driver,
and requires MFD hotadd GPIO resources.

Co-developed-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
Signed-off-by: Benjamin Chan <benjamin.chan@amd.com>
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>
  • Loading branch information
Benjamin Chan authored and Alex Deucher committed Feb 27, 2025
1 parent 4343f81 commit dce1b82
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 29 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct amdgpu_isp {
struct mfd_cell *isp_cell;
struct resource *isp_res;
struct resource *isp_i2c_res;
struct resource *isp_gpio_res;
struct isp_platform_data *isp_pdata;
unsigned int harvest_config;
const struct firmware *fw;
Expand Down
42 changes: 29 additions & 13 deletions drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)

isp_base = adev->rmmio_base;

isp->isp_cell = kcalloc(2, sizeof(struct mfd_cell), GFP_KERNEL);
isp->isp_cell = kcalloc(3, sizeof(struct mfd_cell), GFP_KERNEL);
if (!isp->isp_cell) {
r = -ENOMEM;
drm_err(&adev->ddev,
"%s: isp mfd cell alloc failed\n", __func__);
goto failure;
}

num_res = MAX_ISP410_MEM_RES + MAX_ISP410_SENSOR_RES + MAX_ISP410_INT_SRC;
num_res = MAX_ISP410_MEM_RES + MAX_ISP410_INT_SRC;
isp->isp_res = kcalloc(num_res, sizeof(struct resource),
GFP_KERNEL);
if (!isp->isp_res) {
Expand Down Expand Up @@ -91,14 +91,7 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
isp->isp_res[1].start = isp_base + ISP410_PHY0_OFFSET;
isp->isp_res[1].end = isp_base + ISP410_PHY0_OFFSET + ISP410_PHY0_SIZE;

isp->isp_res[2].name = "isp_gpio_sensor0_reg";
isp->isp_res[2].flags = IORESOURCE_MEM;
isp->isp_res[2].start = isp_base + ISP410_GPIO_SENSOR0_OFFSET;
isp->isp_res[2].end = isp_base + ISP410_GPIO_SENSOR0_OFFSET +
ISP410_GPIO_SENSOR0_SIZE;

for (idx = MAX_ISP410_MEM_RES + MAX_ISP410_SENSOR_RES, int_idx = 0;
idx < num_res; idx++, int_idx++) {
for (idx = MAX_ISP410_MEM_RES, int_idx = 0; idx < num_res; idx++, int_idx++) {
isp->isp_res[idx].name = "isp_4_1_0_irq";
isp->isp_res[idx].flags = IORESOURCE_IRQ;
isp->isp_res[idx].start =
Expand All @@ -113,8 +106,8 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
isp->isp_cell[0].platform_data = isp->isp_pdata;
isp->isp_cell[0].pdata_size = sizeof(struct isp_platform_data);

isp->isp_i2c_res = kcalloc(1, sizeof(struct resource),
GFP_KERNEL);
/* initialize isp i2c platform data */
isp->isp_i2c_res = kcalloc(1, sizeof(struct resource), GFP_KERNEL);
if (!isp->isp_i2c_res) {
r = -ENOMEM;
drm_err(&adev->ddev,
Expand All @@ -133,7 +126,28 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
isp->isp_cell[1].platform_data = isp->isp_pdata;
isp->isp_cell[1].pdata_size = sizeof(struct isp_platform_data);

r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 2);
/* initialize isp gpiochip platform data */
isp->isp_gpio_res = kcalloc(1, sizeof(struct resource), GFP_KERNEL);
if (!isp->isp_gpio_res) {
r = -ENOMEM;
drm_err(&adev->ddev,
"%s: isp gpio res alloc failed\n", __func__);
goto failure;
}

isp->isp_gpio_res[0].name = "isp_gpio_reg";
isp->isp_gpio_res[0].flags = IORESOURCE_MEM;
isp->isp_gpio_res[0].start = isp_base + ISP410_GPIO_SENSOR_OFFSET;
isp->isp_gpio_res[0].end = isp_base + ISP410_GPIO_SENSOR_OFFSET +
ISP410_GPIO_SENSOR_SIZE;

isp->isp_cell[2].name = "amdisp-pinctrl";
isp->isp_cell[2].num_resources = 1;
isp->isp_cell[2].resources = &isp->isp_gpio_res[0];
isp->isp_cell[2].platform_data = isp->isp_pdata;
isp->isp_cell[2].pdata_size = sizeof(struct isp_platform_data);

r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 3);
if (r) {
drm_err(&adev->ddev,
"%s: add mfd hotplug device failed\n", __func__);
Expand All @@ -148,6 +162,7 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
kfree(isp->isp_res);
kfree(isp->isp_cell);
kfree(isp->isp_i2c_res);
kfree(isp->isp_gpio_res);

return r;
}
Expand All @@ -160,6 +175,7 @@ static int isp_v4_1_0_hw_fini(struct amdgpu_isp *isp)
kfree(isp->isp_cell);
kfree(isp->isp_pdata);
kfree(isp->isp_i2c_res);
kfree(isp->isp_gpio_res);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#define ISP410_I2C0_OFFSET 0x66400
#define ISP410_I2C0_SIZE 0x100

#define ISP410_GPIO_SENSOR0_OFFSET 0x6613C
#define ISP410_GPIO_SENSOR0_SIZE 0x4
#define ISP410_GPIO_SENSOR_OFFSET 0x6613C
#define ISP410_GPIO_SENSOR_SIZE 0x54

void isp_v4_1_0_set_isp_funcs(struct amdgpu_isp *isp);

Expand Down
39 changes: 28 additions & 11 deletions drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)

isp_base = adev->rmmio_base;

isp->isp_cell = kcalloc(2, sizeof(struct mfd_cell), GFP_KERNEL);
isp->isp_cell = kcalloc(3, sizeof(struct mfd_cell), GFP_KERNEL);
if (!isp->isp_cell) {
r = -ENOMEM;
drm_err(&adev->ddev,
"%s: isp mfd cell alloc failed\n", __func__);
goto failure;
}

num_res = MAX_ISP411_MEM_RES + MAX_ISP411_SENSOR_RES + MAX_ISP411_INT_SRC;
num_res = MAX_ISP411_MEM_RES + MAX_ISP411_INT_SRC;

isp->isp_res = kcalloc(num_res, sizeof(struct resource),
GFP_KERNEL);
Expand Down Expand Up @@ -92,14 +92,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
isp->isp_res[1].start = isp_base + ISP411_PHY0_OFFSET;
isp->isp_res[1].end = isp_base + ISP411_PHY0_OFFSET + ISP411_PHY0_SIZE;

isp->isp_res[2].name = "isp_4_1_1_sensor0_reg";
isp->isp_res[2].flags = IORESOURCE_MEM;
isp->isp_res[2].start = isp_base + ISP411_GPIO_SENSOR0_OFFSET;
isp->isp_res[2].end = isp_base + ISP411_GPIO_SENSOR0_OFFSET +
ISP411_GPIO_SENSOR0_SIZE;

for (idx = MAX_ISP411_MEM_RES + MAX_ISP411_SENSOR_RES, int_idx = 0;
idx < num_res; idx++, int_idx++) {
for (idx = MAX_ISP411_MEM_RES, int_idx = 0; idx < num_res; idx++, int_idx++) {
isp->isp_res[idx].name = "isp_4_1_1_irq";
isp->isp_res[idx].flags = IORESOURCE_IRQ;
isp->isp_res[idx].start =
Expand All @@ -114,6 +107,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
isp->isp_cell[0].platform_data = isp->isp_pdata;
isp->isp_cell[0].pdata_size = sizeof(struct isp_platform_data);

/* initialize isp i2c platform data */
isp->isp_i2c_res = kcalloc(1, sizeof(struct resource), GFP_KERNEL);
if (!isp->isp_i2c_res) {
r = -ENOMEM;
Expand All @@ -133,7 +127,28 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
isp->isp_cell[1].platform_data = isp->isp_pdata;
isp->isp_cell[1].pdata_size = sizeof(struct isp_platform_data);

r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 2);
/* initialize isp gpiochip platform data */
isp->isp_gpio_res = kcalloc(1, sizeof(struct resource), GFP_KERNEL);
if (!isp->isp_gpio_res) {
r = -ENOMEM;
drm_err(&adev->ddev,
"%s: isp gpio res alloc failed\n", __func__);
goto failure;
}

isp->isp_gpio_res[0].name = "isp_gpio_reg";
isp->isp_gpio_res[0].flags = IORESOURCE_MEM;
isp->isp_gpio_res[0].start = isp_base + ISP411_GPIO_SENSOR_OFFSET;
isp->isp_gpio_res[0].end = isp_base + ISP411_GPIO_SENSOR_OFFSET +
ISP411_GPIO_SENSOR_SIZE;

isp->isp_cell[2].name = "amdisp-pinctrl";
isp->isp_cell[2].num_resources = 1;
isp->isp_cell[2].resources = &isp->isp_gpio_res[0];
isp->isp_cell[2].platform_data = isp->isp_pdata;
isp->isp_cell[2].pdata_size = sizeof(struct isp_platform_data);

r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 3);
if (r) {
drm_err(&adev->ddev,
"%s: add mfd hotplug device failed\n", __func__);
Expand All @@ -148,6 +163,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
kfree(isp->isp_res);
kfree(isp->isp_cell);
kfree(isp->isp_i2c_res);
kfree(isp->isp_gpio_res);

return r;
}
Expand All @@ -160,6 +176,7 @@ static int isp_v4_1_1_hw_fini(struct amdgpu_isp *isp)
kfree(isp->isp_cell);
kfree(isp->isp_pdata);
kfree(isp->isp_i2c_res);
kfree(isp->isp_gpio_res);

return 0;
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "ivsrcid/isp/irqsrcs_isp_4_1.h"

#define MAX_ISP411_MEM_RES 2
#define MAX_ISP411_SENSOR_RES 1
#define MAX_ISP411_INT_SRC 8

#define ISP411_PHY0_OFFSET 0x66700
Expand All @@ -42,8 +41,8 @@
#define ISP411_I2C0_OFFSET 0x66400
#define ISP411_I2C0_SIZE 0x100

#define ISP411_GPIO_SENSOR0_OFFSET 0x6613C
#define ISP411_GPIO_SENSOR0_SIZE 0x4
#define ISP411_GPIO_SENSOR_OFFSET 0x6613C
#define ISP411_GPIO_SENSOR_SIZE 0x54

void isp_v4_1_1_set_isp_funcs(struct amdgpu_isp *isp);

Expand Down

0 comments on commit dce1b82

Please sign in to comment.