Skip to content

Commit dce1b82

Browse files
benjamin-kp-chanalexdeucher
authored andcommitted
drm/amdgpu: Add amdisp pinctrl MFD resource
AMDISP GPIO control uses a dedicated pinctrl driver, and requires MFD hotadd GPIO resources. Co-developed-by: Pratap Nirujogi <[email protected]> Signed-off-by: Benjamin Chan <[email protected]> Signed-off-by: Pratap Nirujogi <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 4343f81 commit dce1b82

File tree

5 files changed

+62
-29
lines changed

5 files changed

+62
-29
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct amdgpu_isp {
5050
struct mfd_cell *isp_cell;
5151
struct resource *isp_res;
5252
struct resource *isp_i2c_res;
53+
struct resource *isp_gpio_res;
5354
struct isp_platform_data *isp_pdata;
5455
unsigned int harvest_config;
5556
const struct firmware *fw;

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

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
5050

5151
isp_base = adev->rmmio_base;
5252

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

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

94-
isp->isp_res[2].name = "isp_gpio_sensor0_reg";
95-
isp->isp_res[2].flags = IORESOURCE_MEM;
96-
isp->isp_res[2].start = isp_base + ISP410_GPIO_SENSOR0_OFFSET;
97-
isp->isp_res[2].end = isp_base + ISP410_GPIO_SENSOR0_OFFSET +
98-
ISP410_GPIO_SENSOR0_SIZE;
99-
100-
for (idx = MAX_ISP410_MEM_RES + MAX_ISP410_SENSOR_RES, int_idx = 0;
101-
idx < num_res; idx++, int_idx++) {
94+
for (idx = MAX_ISP410_MEM_RES, int_idx = 0; idx < num_res; idx++, int_idx++) {
10295
isp->isp_res[idx].name = "isp_4_1_0_irq";
10396
isp->isp_res[idx].flags = IORESOURCE_IRQ;
10497
isp->isp_res[idx].start =
@@ -113,8 +106,8 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
113106
isp->isp_cell[0].platform_data = isp->isp_pdata;
114107
isp->isp_cell[0].pdata_size = sizeof(struct isp_platform_data);
115108

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

136-
r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 2);
129+
/* initialize isp gpiochip platform data */
130+
isp->isp_gpio_res = kcalloc(1, sizeof(struct resource), GFP_KERNEL);
131+
if (!isp->isp_gpio_res) {
132+
r = -ENOMEM;
133+
drm_err(&adev->ddev,
134+
"%s: isp gpio res alloc failed\n", __func__);
135+
goto failure;
136+
}
137+
138+
isp->isp_gpio_res[0].name = "isp_gpio_reg";
139+
isp->isp_gpio_res[0].flags = IORESOURCE_MEM;
140+
isp->isp_gpio_res[0].start = isp_base + ISP410_GPIO_SENSOR_OFFSET;
141+
isp->isp_gpio_res[0].end = isp_base + ISP410_GPIO_SENSOR_OFFSET +
142+
ISP410_GPIO_SENSOR_SIZE;
143+
144+
isp->isp_cell[2].name = "amdisp-pinctrl";
145+
isp->isp_cell[2].num_resources = 1;
146+
isp->isp_cell[2].resources = &isp->isp_gpio_res[0];
147+
isp->isp_cell[2].platform_data = isp->isp_pdata;
148+
isp->isp_cell[2].pdata_size = sizeof(struct isp_platform_data);
149+
150+
r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 3);
137151
if (r) {
138152
drm_err(&adev->ddev,
139153
"%s: add mfd hotplug device failed\n", __func__);
@@ -148,6 +162,7 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
148162
kfree(isp->isp_res);
149163
kfree(isp->isp_cell);
150164
kfree(isp->isp_i2c_res);
165+
kfree(isp->isp_gpio_res);
151166

152167
return r;
153168
}
@@ -160,6 +175,7 @@ static int isp_v4_1_0_hw_fini(struct amdgpu_isp *isp)
160175
kfree(isp->isp_cell);
161176
kfree(isp->isp_pdata);
162177
kfree(isp->isp_i2c_res);
178+
kfree(isp->isp_gpio_res);
163179

164180
return 0;
165181
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
#define ISP410_I2C0_OFFSET 0x66400
4343
#define ISP410_I2C0_SIZE 0x100
4444

45-
#define ISP410_GPIO_SENSOR0_OFFSET 0x6613C
46-
#define ISP410_GPIO_SENSOR0_SIZE 0x4
45+
#define ISP410_GPIO_SENSOR_OFFSET 0x6613C
46+
#define ISP410_GPIO_SENSOR_SIZE 0x54
4747

4848
void isp_v4_1_0_set_isp_funcs(struct amdgpu_isp *isp);
4949

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

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
5050

5151
isp_base = adev->rmmio_base;
5252

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

61-
num_res = MAX_ISP411_MEM_RES + MAX_ISP411_SENSOR_RES + MAX_ISP411_INT_SRC;
61+
num_res = MAX_ISP411_MEM_RES + MAX_ISP411_INT_SRC;
6262

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

95-
isp->isp_res[2].name = "isp_4_1_1_sensor0_reg";
96-
isp->isp_res[2].flags = IORESOURCE_MEM;
97-
isp->isp_res[2].start = isp_base + ISP411_GPIO_SENSOR0_OFFSET;
98-
isp->isp_res[2].end = isp_base + ISP411_GPIO_SENSOR0_OFFSET +
99-
ISP411_GPIO_SENSOR0_SIZE;
100-
101-
for (idx = MAX_ISP411_MEM_RES + MAX_ISP411_SENSOR_RES, int_idx = 0;
102-
idx < num_res; idx++, int_idx++) {
95+
for (idx = MAX_ISP411_MEM_RES, int_idx = 0; idx < num_res; idx++, int_idx++) {
10396
isp->isp_res[idx].name = "isp_4_1_1_irq";
10497
isp->isp_res[idx].flags = IORESOURCE_IRQ;
10598
isp->isp_res[idx].start =
@@ -114,6 +107,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
114107
isp->isp_cell[0].platform_data = isp->isp_pdata;
115108
isp->isp_cell[0].pdata_size = sizeof(struct isp_platform_data);
116109

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

136-
r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 2);
130+
/* initialize isp gpiochip platform data */
131+
isp->isp_gpio_res = kcalloc(1, sizeof(struct resource), GFP_KERNEL);
132+
if (!isp->isp_gpio_res) {
133+
r = -ENOMEM;
134+
drm_err(&adev->ddev,
135+
"%s: isp gpio res alloc failed\n", __func__);
136+
goto failure;
137+
}
138+
139+
isp->isp_gpio_res[0].name = "isp_gpio_reg";
140+
isp->isp_gpio_res[0].flags = IORESOURCE_MEM;
141+
isp->isp_gpio_res[0].start = isp_base + ISP411_GPIO_SENSOR_OFFSET;
142+
isp->isp_gpio_res[0].end = isp_base + ISP411_GPIO_SENSOR_OFFSET +
143+
ISP411_GPIO_SENSOR_SIZE;
144+
145+
isp->isp_cell[2].name = "amdisp-pinctrl";
146+
isp->isp_cell[2].num_resources = 1;
147+
isp->isp_cell[2].resources = &isp->isp_gpio_res[0];
148+
isp->isp_cell[2].platform_data = isp->isp_pdata;
149+
isp->isp_cell[2].pdata_size = sizeof(struct isp_platform_data);
150+
151+
r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 3);
137152
if (r) {
138153
drm_err(&adev->ddev,
139154
"%s: add mfd hotplug device failed\n", __func__);
@@ -148,6 +163,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
148163
kfree(isp->isp_res);
149164
kfree(isp->isp_cell);
150165
kfree(isp->isp_i2c_res);
166+
kfree(isp->isp_gpio_res);
151167

152168
return r;
153169
}
@@ -160,6 +176,7 @@ static int isp_v4_1_1_hw_fini(struct amdgpu_isp *isp)
160176
kfree(isp->isp_cell);
161177
kfree(isp->isp_pdata);
162178
kfree(isp->isp_i2c_res);
179+
kfree(isp->isp_gpio_res);
163180

164181
return 0;
165182
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "ivsrcid/isp/irqsrcs_isp_4_1.h"
3434

3535
#define MAX_ISP411_MEM_RES 2
36-
#define MAX_ISP411_SENSOR_RES 1
3736
#define MAX_ISP411_INT_SRC 8
3837

3938
#define ISP411_PHY0_OFFSET 0x66700
@@ -42,8 +41,8 @@
4241
#define ISP411_I2C0_OFFSET 0x66400
4342
#define ISP411_I2C0_SIZE 0x100
4443

45-
#define ISP411_GPIO_SENSOR0_OFFSET 0x6613C
46-
#define ISP411_GPIO_SENSOR0_SIZE 0x4
44+
#define ISP411_GPIO_SENSOR_OFFSET 0x6613C
45+
#define ISP411_GPIO_SENSOR_SIZE 0x54
4746

4847
void isp_v4_1_1_set_isp_funcs(struct amdgpu_isp *isp);
4948

0 commit comments

Comments
 (0)