Skip to contentSkip to conversation

Add amdisp pinctrl MFD resource

PATCH In review Pratap Nirujogi 2 participants 4 messages Feb 20, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add amdisp pinctrl MFD resource

This patch series includes two patches:

patch-1: drm/amdgpu: Replace DRM_ERROR() with drm_err()
patch-2: drm/amdgpu: Add amdisp pinctrl MFD resource

About Patch-1: DRM_ERROR() is no longer preferred. Replace DRM_ERROR() usage with drm_err() in isp driver.

About Patch-2: Sensor module power is controlled using a GPIO. Instead of accessing the GPIO MMIO resource directly in isp driver, a new AMDISP PINCTRL device is added, which acts as an interface for the sensor driver to enable / disable the GPIO to start / stop sensor streaming.

The GPIO resources required for AMDISP PINCTRL device are passed using the MFD interface from amdgpu.

Benjamin Chan (1):
drm/amdgpu: Add amdisp pinctrl MFD resource

Pratap Nirujogi (1):
drm/amdgpu: Replace DRM_ERROR() with drm_err()

 drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h |  1 +
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c | 57 +++++++++++++++++--------
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h |  4 +-
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 54 ++++++++++++++++-------
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h |  5 +--
 5 files changed, 82 insertions(+), 39 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 drm/amdgpu: Replace DRM_ERROR() with drm_err()

DRM_ERROR() is no longer preferred. Replace DRM_ERROR() usage with drm_err() in isp driver.

---
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c | 15 ++++++++++-----
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 15 ++++++++++-----
 2 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c +10 -5
index 964c29ef25dc..2475564b2c08 100644
@@ -53,7 +53,8 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
 	isp->isp_cell = kcalloc(2, sizeof(struct mfd_cell), GFP_KERNEL);
 	if (!isp->isp_cell) {
 		r = -ENOMEM;
-		DRM_ERROR("%s: isp mfd cell alloc failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: isp mfd cell alloc failed\n", __func__);
 		goto failure;
 	}
 
@@ -62,14 +63,16 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
 			       GFP_KERNEL);
 	if (!isp->isp_res) {
 		r = -ENOMEM;
-		DRM_ERROR("%s: isp mfd res alloc failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: isp mfd res alloc failed\n", __func__);
 		goto failure;
 	}
 
 	isp->isp_pdata = kzalloc(sizeof(*isp->isp_pdata), GFP_KERNEL);
 	if (!isp->isp_pdata) {
 		r = -ENOMEM;
-		DRM_ERROR("%s: isp platform data alloc failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: isp platform data alloc failed\n", __func__);
 		goto failure;
 	}
 
@@ -114,7 +117,8 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
 				   GFP_KERNEL);
 	if (!isp->isp_i2c_res) {
 		r = -ENOMEM;
-		DRM_ERROR("%s: isp mfd res alloc failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: isp mfd res alloc failed\n", __func__);
 		goto failure;
 	}
 
@@ -131,7 +135,8 @@ static int isp_v4_1_0_hw_init(struct amdgpu_isp *isp)
 
 	r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 2);
 	if (r) {
-		DRM_ERROR("%s: add mfd hotplug device failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: add mfd hotplug device failed\n", __func__);
 		goto failure;
 	}
 
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c +10 -5
index b56f27295468..3ee5942bc24d 100644
@@ -53,7 +53,8 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
 	isp->isp_cell = kcalloc(2, sizeof(struct mfd_cell), GFP_KERNEL);
 	if (!isp->isp_cell) {
 		r = -ENOMEM;
-		DRM_ERROR("%s: isp mfd cell alloc failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: isp mfd cell alloc failed\n", __func__);
 		goto failure;
 	}
 
@@ -63,14 +64,16 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
 			       GFP_KERNEL);
 	if (!isp->isp_res) {
 		r = -ENOMEM;
-		DRM_ERROR("%s: isp mfd res alloc failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: isp mfd res alloc failed\n", __func__);
 		goto failure;
 	}
 
 	isp->isp_pdata = kzalloc(sizeof(*isp->isp_pdata), GFP_KERNEL);
 	if (!isp->isp_pdata) {
 		r = -ENOMEM;
-		DRM_ERROR("%s: isp platform data alloc failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: isp platform data alloc failed\n", __func__);
 		goto failure;
 	}
 
@@ -114,7 +117,8 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
 	isp->isp_i2c_res = kcalloc(1, sizeof(struct resource), GFP_KERNEL);
 	if (!isp->isp_i2c_res) {
 		r = -ENOMEM;
-		DRM_ERROR("%s: isp mfd res alloc failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: isp mfd res alloc failed\n", __func__);
 		goto failure;
 	}
 
@@ -131,7 +135,8 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
 
 	r = mfd_add_hotplug_devices(isp->parent, isp->isp_cell, 2);
 	if (r) {
-		DRM_ERROR("%s: add mfd hotplug device failed\n", __func__);
+		drm_err(&adev->ddev,
+			"%s: add mfd hotplug device failed\n", __func__);
 		goto failure;
 	}
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/2 drm/amdgpu: Add amdisp pinctrl MFD resource

In reply to Pratap Nirujogi

From: Benjamin Chan <[email protected]>

AMDISP GPIO control uses a dedicated pinctrl driver, and requires MFD hotadd GPIO resources.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h |  1 +
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c | 42 +++++++++++++++++--------
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h |  4 +--
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 39 ++++++++++++++++-------
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h |  5 ++-
 5 files changed, 62 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h +1 -0
index b03664c66dd6..4f3b7b5d9c1f 100644
@@ -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;
drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c +29 -13

84 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h +2 -2
index 7db24c0f1080..4d239198edd0 100644
@@ -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);
 
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c +28 -11
index 3ee5942bc24d..69dd92f6e86d 100644
@@ -50,7 +50,7 @@ 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,
@@ -58,7 +58,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)
 		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);
@@ -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 =
@@ -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;
@@ -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__);
@@ -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;
 }
@@ -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;
 }
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h +2 -3
index 40887ddeb08c..fe45d70d87f1 100644
@@ -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
@@ -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);
 
Signature · 1 line
2.43.0
Reviewed-by on the v1 series
#3 lore raw
In reply to Pratap Nirujogi
Quoted 23 lines · Pratap Nirujogi

This patch series includes two patches:

patch-1: drm/amdgpu: Replace DRM_ERROR() with drm_err()
patch-2: drm/amdgpu: Add amdisp pinctrl MFD resource

About Patch-1: DRM_ERROR() is no longer preferred. Replace DRM_ERROR() usage with drm_err() in isp driver.

About Patch-2: Sensor module power is controlled using a GPIO. Instead of accessing the GPIO MMIO resource directly in isp driver, a new AMDISP PINCTRL device is added, which acts as an interface for the sensor driver to enable / disable the GPIO to start / stop sensor streaming.

The GPIO resources required for AMDISP PINCTRL device are passed using the MFD interface from amdgpu.

Benjamin Chan (1):
drm/amdgpu: Add amdisp pinctrl MFD resource

Pratap Nirujogi (1):
drm/amdgpu: Replace DRM_ERROR() with drm_err()

Quoted 7 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h |  1 +
  drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c | 57 +++++++++++++++++--------
  drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.h |  4 +-
  drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 54 ++++++++++++++++-------
  drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.h |  5 +--
  5 files changed, 82 insertions(+), 39 deletions(-)