Skip to contentSkip to conversation

Generic PHY driver for the Exynos SoC MIPI CSI-2/DSI DPHYs

PATCH Superseded Sylwester Nawrocki 7 participants 17 messages Jun 26, 2013 – Jul 1, 2013

Subsystems (7)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Generic PHY driver for the Exynos SoC MIPI CSI-2/DSI DPHYs

This patch series adds a simple driver for the Samsung S5P/Exynos SoC series MIPI CSI-2 receiver (MIPI CSIS) and MIPI DSI transmitter (MIPI DSIM) DPHYs, using the generic PHY framework [1]. Previously the MIPI CSIS and MIPI DSIM used a platform callback to control the PHY power enable and reset bits. The platform callback can now be dropped and those drivers don't need any calls back to the platform code, which makes migration to the device tree complete for MIPI CSIS.

Changes since v2:
- adapted to the generic PHY API v9: use phy_set/get_drvdata(),
- fixed of_xlate callback to return ERR_PTR() instead of NULL,
- namespace cleanup, put "GPL v2" as MODULE_LICENSE, removed pr_debug,
- removed phy id check in __set_phy_state().

Patches 2...3/5 are unchanged, description of patch 5/5 has been updated.

Changes since v1:
- enabled build as module and with CONFIG_OF disabled,
- added phy_id enum,
- of_address_to_resource() replaced with platform_get_resource(),
- adapted to changes in the PHY API v7, v8 - added phy labels,
- added MODULE_DEVICE_TABLE() entry,
- the driver file renamed to phy-exynos-mipi-video.c,
- changed DT compatible string to "samsung,s5pv210-mipi-video-phy",
- corrected the compatible property's description.
- patch 3/5 "video: exynos_dsi: Use generic PHY driver" replaced with a patch modifying the MIPI DSIM driver which is currently in mainline.

This series depends on the generic PHY framework [1]. It can be browsed at:
http://git.linuxtv.org/snawrocki/samsung.git/exynos-mipi-phy
This branch is based on the 'for-next' branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung.git
and the patch series:
http://www.spinics.net/lists/arm-kernel/msg254667.html

[1] https://lkml.org/lkml/2013/6/26/259

Sylwester Nawrocki (5):
phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs
ARM: dts: Add MIPI PHY node to exynos4.dtsi
video: exynos_mipi_dsim: Use the generic PHY driver
exynos4-is: Use the generic MIPI CSIS PHY driver
ARM: Samsung: Remove the MIPI PHY setup code

 .../phy/samsung,s5pv210-mipi-video-phy.txt         |   14 ++
 arch/arm/boot/dts/exynos4.dtsi                     |   10 ++
 arch/arm/mach-exynos/include/mach/regs-pmu.h       |    5 -
 arch/arm/mach-s5pv210/include/mach/regs-clock.h    |    4 -
 arch/arm/plat-samsung/Kconfig                      |    5 -
 arch/arm/plat-samsung/Makefile                     |    1 -
 arch/arm/plat-samsung/setup-mipiphy.c              |   60 -------
 drivers/media/platform/exynos4-is/mipi-csis.c      |   16 +-
 drivers/phy/Kconfig                                |    9 ++
 drivers/phy/Makefile                               |    3 +-
 drivers/phy/phy-exynos-mipi-video.c                |  170 ++++++++++++++++++++
 drivers/video/exynos/exynos_mipi_dsi.c             |   18 +--
 include/linux/platform_data/mipi-csis.h            |   11 +-
 include/video/exynos_mipi_dsim.h                   |    6 +-
 14 files changed, 233 insertions(+), 99 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/samsung,s5pv210-mipi-video-phy.txt
 delete mode 100644 arch/arm/plat-samsung/setup-mipiphy.c
 create mode 100644 drivers/phy/phy-exynos-mipi-video.c

--
1.7.9.5

#1 lore raw

PATCH v3 1/5 phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs.

---
Changes since v2:
- adapted to the generic PHY API v9: use phy_set/get_drvdata(),
- fixed of_xlate callback to return ERR_PTR() instead of NULL,
- namespace cleanup, put "GPL v2" as MODULE_LICENSE, removed pr_debug,
- removed phy id check in __set_phy_state().

---
 .../phy/samsung,s5pv210-mipi-video-phy.txt         |   14 ++
 drivers/phy/Kconfig                                |    9 ++
 drivers/phy/Makefile                               |    3 +-
 drivers/phy/phy-exynos-mipi-video.c                |  170 ++++++++++++++++++++
 4 files changed, 195 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/samsung,s5pv210-mipi-video-phy.txt
 create mode 100644 drivers/phy/phy-exynos-mipi-video.c
Documentation/devicetree/bindings/phy/samsung,s5pv210-mipi-video-phy.txt new file +14 -0
new file mode 100644
index 0000000..5ff208c
@@ -0,0 +1,14 @@
+Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY
+-------------------------------------------------
+
+Required properties:
+- compatible : should be "samsung,s5pv210-mipi-video-phy";
+- reg : offset and length of the MIPI DPHY register set;
+- #phy-cells : from the generic phy bindings, must be 1;
+
+For "samsung,s5pv210-mipi-video-phy" compatible PHYs the second cell in
+the PHY specifier identifies the PHY and its meaning is as follows:
+  0 - MIPI CSIS 0,
+  1 - MIPI DSIM 0,
+  2 - MIPI CSIS 1,
+  3 - MIPI DSIM 1.
drivers/phy/Kconfig +9 -0
index 5f85909..6f446d0 100644
@@ -11,3 +11,12 @@ menuconfig GENERIC_PHY
 	  devices present in the kernel. This layer will have the generic
 	  API by which phy drivers can create PHY using the phy framework and
 	  phy users can obtain reference to the PHY.
+
+if GENERIC_PHY
+
+config PHY_EXYNOS_MIPI_VIDEO
+	tristate "S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver"
+	help
+	  Support for MIPI CSI-2 and MIPI DSI DPHY found on Samsung
+	  S5P and EXYNOS SoCs.
+endif
drivers/phy/Makefile +2 -1
index 9e9560f..71d8841 100644
@@ -2,4 +2,5 @@
 # Makefile for the phy drivers.
 #
 
-obj-$(CONFIG_GENERIC_PHY)	+= phy-core.o
+obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
+obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)	+= phy-exynos-mipi-video.o
drivers/phy/phy-exynos-mipi-video.c new file +170 -0

170 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 1/5 phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

Quoted 5 lines · Sylwester Nawrocki

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs.

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130627/216fee7e/attachment.sig>
#3 lore raw

PATCH v3 1/5 phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

Quoted 8 lines · Felipe Balbi
Quoted 5 lines · Sylwester Nawrocki

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs.

Thank you for your review and ack!

Just for the record, I have tested this driver as a loadable module on Exynos4412 TRATS2 board and it all worked fine for both the camera and display side.

--
Regards,
Sylwester

#4 lore raw

PATCH v3 1/5 phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

Quoted 8 lines · Sylwester Nawrocki
Quoted 7 lines · Felipe Balbi
Quoted 5 lines · Sylwester Nawrocki

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs.

Quoted 7 lines
Quoted 1 line

Thank you for your review and ack!

Just for the record, I have tested this driver as a loadable module on Exynos4412 TRATS2 board and it all worked fine for both the camera and display side.

Awesome dude :-) very cool, let's hope more users convert to Kishon's generic phy layer :-)

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130627/a1037fd2/attachment.sig>
#5 lore raw

PATCH v3 1/5 phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

In reply to Sylwester Nawrocki
Quoted 12 lines · Sylwester Nawrocki

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs.

---
Changes since v2:
- adapted to the generic PHY API v9: use phy_set/get_drvdata(),
- fixed of_xlate callback to return ERR_PTR() instead of NULL,
- namespace cleanup, put "GPL v2" as MODULE_LICENSE, removed pr_debug,
- removed phy id check in __set_phy_state().
---

[...]

drivers/phy/phy-exynos-mipi-video.c line 60

Quoted 7 lines
drivers/phy/phy-exynos-mipi-video.c new file +7 -0
+
+	if (IS_EXYNOS_MIPI_DSIM_PHY_ID(id))
+		reset = EXYNOS_MIPI_PHY_MRESETN;
+	else
+		reset = EXYNOS_MIPI_PHY_SRESETN;
+
+	spin_lock_irqsave(&state->slock, flags);

Sorry for one stupid question here, why do you use spin_lock_irqsave() rather than spin_lock(),
I don't see the irq handler will use this spinlock anywhere in this c file.

Regards,
Hui.

Quoted 18 lines
drivers/phy/phy-exynos-mipi-video.c new file +17 -0
+	reg = readl(addr);
+	if (on)
+		reg |= reset;
+	else
+		reg &= ~reset;
+	writel(reg, addr);
+
+	/* Clear ENABLE bit only if MRESETN, SRESETN bits are not set. */
+	if (on)
+		reg |= EXYNOS_MIPI_PHY_ENABLE;
+	else if (!(reg & EXYNOS_MIPI_PHY_RESET_MASK))
+		reg &= ~EXYNOS_MIPI_PHY_ENABLE;
+
+	writel(reg, addr);
+	spin_unlock_irqrestore(&state->slock, flags);
+	return 0;
+}
#6 lore raw

PATCH v3 1/5 phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

Quoted 14 lines · Hui Wang
Quoted 12 lines · Sylwester Nawrocki

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs.

---
Changes since v2:
- adapted to the generic PHY API v9: use phy_set/get_drvdata(),
- fixed of_xlate callback to return ERR_PTR() instead of NULL,
- namespace cleanup, put "GPL v2" as MODULE_LICENSE, removed pr_debug,
- removed phy id check in __set_phy_state().
---

[...]

Quoted 11 lines

drivers/phy/phy-exynos-mipi-video.c line 60

Quoted 7 lines
drivers/phy/phy-exynos-mipi-video.c new file +7 -0
+
+	if (IS_EXYNOS_MIPI_DSIM_PHY_ID(id))
+		reset = EXYNOS_MIPI_PHY_MRESETN;
+	else
+		reset = EXYNOS_MIPI_PHY_SRESETN;
+
+	spin_lock_irqsave(&state->slock, flags);

Sorry for one stupid question here, why do you use spin_lock_irqsave() rather than spin_lock(),
I don't see the irq handler will use this spinlock anywhere in this c file.

Yes, there is no chance the PHY users could call the phy ops from within an interrupt context. Especially now when there is a per phy object mutex used in the PHY operation helpers. So I'll replace it with plain spin_lock/unlock. Thank you for the review.

Regards,
Sylwester

#7 lore raw

PATCH v3 1/5 phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

Hi,

Quoted 27 lines · Sylwester Nawrocki
Quoted 14 lines · Hui Wang
Quoted 12 lines · Sylwester Nawrocki

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs.

---
Changes since v2:
- adapted to the generic PHY API v9: use phy_set/get_drvdata(),
- fixed of_xlate callback to return ERR_PTR() instead of NULL,
- namespace cleanup, put "GPL v2" as MODULE_LICENSE, removed pr_debug,
- removed phy id check in __set_phy_state().
---

[...]

Quoted 11 lines

drivers/phy/phy-exynos-mipi-video.c line 60

Quoted 7 lines
drivers/phy/phy-exynos-mipi-video.c new file +7 -0
+
+	if (IS_EXYNOS_MIPI_DSIM_PHY_ID(id))
+		reset = EXYNOS_MIPI_PHY_MRESETN;
+	else
+		reset = EXYNOS_MIPI_PHY_SRESETN;
+
+	spin_lock_irqsave(&state->slock, flags);

Sorry for one stupid question here, why do you use spin_lock_irqsave() rather than spin_lock(),
I don't see the irq handler will use this spinlock anywhere in this c file.

Quoted 4 lines

Yes, there is no chance the PHY users could call the phy ops from within an interrupt context. Especially now when there is a per phy object mutex used in the PHY operation helpers. So I'll replace it with plain spin_lock/unlock. Thank you for the review.

Now that PHY ops is already protected, do you really need a spin_lock here?

Thanks
Kishon

#8 lore raw

PATCH v3 1/5 phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

Hi,

Quoted 29 lines · Kishon Vijay Abraham I
Quoted 28 lines · Sylwester Nawrocki
Quoted 26 lines · Hui Wang
Quoted 12 lines · Sylwester Nawrocki

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs.

---
Changes since v2:
- adapted to the generic PHY API v9: use phy_set/get_drvdata(),
- fixed of_xlate callback to return ERR_PTR() instead of NULL,
- namespace cleanup, put "GPL v2" as MODULE_LICENSE, removed pr_debug,
- removed phy id check in __set_phy_state().
---

[...]

drivers/phy/phy-exynos-mipi-video.c line 60

Quoted 7 lines
drivers/phy/phy-exynos-mipi-video.c new file +7 -0
+
+ if (IS_EXYNOS_MIPI_DSIM_PHY_ID(id))
+ reset = EXYNOS_MIPI_PHY_MRESETN;
+ else
+ reset = EXYNOS_MIPI_PHY_SRESETN;
+
+ spin_lock_irqsave(&state->slock, flags);

Sorry for one stupid question here, why do you use spin_lock_irqsave() rather than spin_lock(),
I don't see the irq handler will use this spinlock anywhere in this c file.

Quoted 6 lines
Quoted 4 lines

Yes, there is no chance the PHY users could call the phy ops from within an interrupt context. Especially now when there is a per phy object mutex used in the PHY operation helpers. So I'll replace it with plain spin_lock/unlock. Thank you for the review.

Now that PHY ops is already protected, do you really need a spin_lock here?

It is still needed, to synchronize access to the control register from two separate PHY objects. The mutex is per PHY object, while the spinlock is per PHY provider.

Thanks,
Sylwester

#9 lore raw

PATCH v3 1/5 phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs

Hi,

Quoted 37 lines · Sylwester Nawrocki

Hi,

Quoted 34 lines · Kishon Vijay Abraham I
Quoted 32 lines · Sylwester Nawrocki
Quoted 14 lines · Hui Wang
Quoted 12 lines · Sylwester Nawrocki

Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs.

---
Changes since v2:
- adapted to the generic PHY API v9: use phy_set/get_drvdata(),
- fixed of_xlate callback to return ERR_PTR() instead of NULL,
- namespace cleanup, put "GPL v2" as MODULE_LICENSE, removed pr_debug,
- removed phy id check in __set_phy_state().
---

[...]

Quoted 12 lines

drivers/phy/phy-exynos-mipi-video.c line 60

Quoted 7 lines
drivers/phy/phy-exynos-mipi-video.c new file +7 -0
+
+ if (IS_EXYNOS_MIPI_DSIM_PHY_ID(id))
+ reset = EXYNOS_MIPI_PHY_MRESETN;
+ else
+ reset = EXYNOS_MIPI_PHY_SRESETN;
+
+ spin_lock_irqsave(&state->slock, flags);

Sorry for one stupid question here, why do you use spin_lock_irqsave() rather than spin_lock(),
I don't see the irq handler will use this spinlock anywhere in this c file.

Yes, there is no chance the PHY users could call the phy ops from within an interrupt context. Especially now when there is a per phy object mutex used in the PHY operation helpers. So I'll replace it with plain spin_lock/unlock. Thank you for the review.

Quoted 5 lines
Quoted 1 line

Now that PHY ops is already protected, do you really need a spin_lock here?

It is still needed, to synchronize access to the control register from two separate PHY objects. The mutex is per PHY object, while the spinlock is per PHY provider.

Ok. Makes sense.

Thanks
Kishon

#10 lore raw

PATCH v3 2/5 ARM: dts: Add MIPI PHY node to exynos4.dtsi

In reply to Sylwester Nawrocki

Add PHY provider node for the MIPI CSIS and MIPI DSIM PHYs.

---
 arch/arm/boot/dts/exynos4.dtsi |   10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/exynos4.dtsi +10 -0
index 4d61120..9542088 100644
@@ -98,6 +98,12 @@
 		reg = <0x10010000 0x400>;
 	};
 
+	mipi_phy: video-phy at 10020710 {
+		compatible = "samsung,s5pv210-mipi-video-phy";
+		reg = <0x10020710 8>;
+		#phy-cells = <1>;
+	};
+
 	camera {
 		compatible = "samsung,fimc", "simple-bus";
 		status = "disabled";
@@ -147,6 +153,8 @@
 			interrupts = <0 78 0>;
 			bus-width = <4>;
 			samsung,power-domain = <&pd_cam>;
+			phys = <&mipi_phy 0>;
+			phy-names = "csis";
 			status = "disabled";
 		};
 
@@ -156,6 +164,8 @@
 			interrupts = <0 80 0>;
 			bus-width = <2>;
 			samsung,power-domain = <&pd_cam>;
+			phys = <&mipi_phy 2>;
+			phy-names = "csis";
 			status = "disabled";
 		};
 	};
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH v3 2/5 ARM: dts: Add MIPI PHY node to exynos4.dtsi

Quoted 4 lines · Sylwester Nawrocki

Add PHY provider node for the MIPI CSIS and MIPI DSIM PHYs.

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130627/5dab068f/attachment.sig>
#12 lore raw

PATCH v3 3/5 video: exynos_mipi_dsim: Use the generic PHY driver

In reply to Sylwester Nawrocki

Use the generic PHY API instead of the platform callback to control the MIPI DSIM DPHY. The 'phy_label' field is added to the platform data structure to allow PHY lookup on non-dt platforms.

---
 drivers/video/exynos/exynos_mipi_dsi.c |   18 +++++++++---------
 include/video/exynos_mipi_dsim.h       |    6 ++++--
 2 files changed, 13 insertions(+), 11 deletions(-)
drivers/video/exynos/exynos_mipi_dsi.c +9 -9
index 32e5406..1f96004 100644
@@ -156,8 +156,7 @@ static int exynos_mipi_dsi_blank_mode(struct mipi_dsim_device *dsim, int power)
 		exynos_mipi_regulator_enable(dsim);
 
 		/* enable MIPI-DSI PHY. */
-		if (dsim->pd->phy_enable)
-			dsim->pd->phy_enable(pdev, true);
+		phy_power_on(dsim->phy);
 
 		clk_enable(dsim->clock);
 
@@ -373,6 +372,10 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	dsim->phy = devm_phy_get(&pdev->dev, dsim_pd->phy_label);
+	if (IS_ERR(dsim->phy))
+		return PTR_ERR(dsim->phy);
+
 	dsim->clock = devm_clk_get(&pdev->dev, "dsim0");
 	if (IS_ERR(dsim->clock)) {
 		dev_err(&pdev->dev, "failed to get dsim clock source\n");
@@ -439,8 +442,7 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
 	exynos_mipi_regulator_enable(dsim);
 
 	/* enable MIPI-DSI PHY. */
-	if (dsim->pd->phy_enable)
-		dsim->pd->phy_enable(pdev, true);
+	phy_power_on(dsim->phy);
 
 	exynos_mipi_update_cfg(dsim);
 
@@ -504,9 +506,8 @@ static int exynos_mipi_dsi_suspend(struct device *dev)
 	if (client_drv && client_drv->suspend)
 		client_drv->suspend(client_dev);
 
-	/* enable MIPI-DSI PHY. */
-	if (dsim->pd->phy_enable)
-		dsim->pd->phy_enable(pdev, false);
+	/* disable MIPI-DSI PHY. */
+	phy_power_off(dsim->phy);
 
 	clk_disable(dsim->clock);
 
@@ -536,8 +537,7 @@ static int exynos_mipi_dsi_resume(struct device *dev)
 	exynos_mipi_regulator_enable(dsim);
 
 	/* enable MIPI-DSI PHY. */
-	if (dsim->pd->phy_enable)
-		dsim->pd->phy_enable(pdev, true);
+	phy_power_on(dsim->phy);
 
 	clk_enable(dsim->clock);
 
include/video/exynos_mipi_dsim.h +4 -2
index 89dc88a..fd69beb 100644
@@ -216,6 +216,7 @@ struct mipi_dsim_config {
  *	automatically.
  * @e_clk_src: select byte clock source.
  * @pd: pointer to MIPI-DSI driver platform data.
+ * @phy: pointer to the generic PHY
  */
 struct mipi_dsim_device {
 	struct device			*dev;
@@ -236,6 +237,7 @@ struct mipi_dsim_device {
 	bool				suspended;
 
 	struct mipi_dsim_platform_data	*pd;
+	struct phy			*phy;
 };
 
 /*
@@ -248,7 +250,7 @@ struct mipi_dsim_device {
  * @enabled: indicate whether mipi controller got enabled or not.
  * @lcd_panel_info: pointer for lcd panel specific structure.
  *	this structure specifies width, height, timing and polarity and so on.
- * @phy_enable: pointer to a callback controlling D-PHY enable/reset
+ * @phy_label: the generic PHY label
  */
 struct mipi_dsim_platform_data {
 	char				lcd_panel_name[PANEL_NAME_SIZE];
@@ -257,7 +259,7 @@ struct mipi_dsim_platform_data {
 	unsigned int			enabled;
 	void				*lcd_panel_info;
 
-	int (*phy_enable)(struct platform_device *pdev, bool on);
+	const char 			*phy_label;
 };
 
 /*
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH v3 3/5 video: exynos_mipi_dsim: Use the generic PHY driver

Quoted 99 lines · Sylwester Nawrocki

Use the generic PHY API instead of the platform callback to control the MIPI DSIM DPHY. The 'phy_label' field is added to the platform data structure to allow PHY lookup on non-dt platforms.

---
  drivers/video/exynos/exynos_mipi_dsi.c |   18 +++++++++---------
  include/video/exynos_mipi_dsim.h       |    6 ++++--
  2 files changed, 13 insertions(+), 11 deletions(-)
drivers/video/exynos/exynos_mipi_dsi.c +9 -9
index 32e5406..1f96004 100644
@@ -156,8 +156,7 @@ static int exynos_mipi_dsi_blank_mode(struct mipi_dsim_device *dsim, int power)
  		exynos_mipi_regulator_enable(dsim);
 
  		/* enable MIPI-DSI PHY. */
-		if (dsim->pd->phy_enable)
-			dsim->pd->phy_enable(pdev, true);
+		phy_power_on(dsim->phy);
 
  		clk_enable(dsim->clock);
 
@@ -373,6 +372,10 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
  		return ret;
  	}
 
+	dsim->phy = devm_phy_get(&pdev->dev, dsim_pd->phy_label);
+	if (IS_ERR(dsim->phy))
+		return PTR_ERR(dsim->phy);
+
  	dsim->clock = devm_clk_get(&pdev->dev, "dsim0");
  	if (IS_ERR(dsim->clock)) {
  		dev_err(&pdev->dev, "failed to get dsim clock source\n");
@@ -439,8 +442,7 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
  	exynos_mipi_regulator_enable(dsim);
 
  	/* enable MIPI-DSI PHY. */
-	if (dsim->pd->phy_enable)
-		dsim->pd->phy_enable(pdev, true);
+	phy_power_on(dsim->phy);
 
  	exynos_mipi_update_cfg(dsim);
 
@@ -504,9 +506,8 @@ static int exynos_mipi_dsi_suspend(struct device *dev)
  	if (client_drv && client_drv->suspend)
  		client_drv->suspend(client_dev);
 
-	/* enable MIPI-DSI PHY. */
-	if (dsim->pd->phy_enable)
-		dsim->pd->phy_enable(pdev, false);
+	/* disable MIPI-DSI PHY. */
+	phy_power_off(dsim->phy);
 
  	clk_disable(dsim->clock);
 
@@ -536,8 +537,7 @@ static int exynos_mipi_dsi_resume(struct device *dev)
  	exynos_mipi_regulator_enable(dsim);
 
  	/* enable MIPI-DSI PHY. */
-	if (dsim->pd->phy_enable)
-		dsim->pd->phy_enable(pdev, true);
+	phy_power_on(dsim->phy);
 
  	clk_enable(dsim->clock);
 
include/video/exynos_mipi_dsim.h +3 -1
index 89dc88a..fd69beb 100644
@@ -216,6 +216,7 @@ struct mipi_dsim_config {
   *	automatically.
   * @e_clk_src: select byte clock source.
   * @pd: pointer to MIPI-DSI driver platform data.
+ * @phy: pointer to the generic PHY
   */
  struct mipi_dsim_device {
  	struct device			*dev;
@@ -236,6 +237,7 @@ struct mipi_dsim_device {
  	bool				suspended;
 
  	struct mipi_dsim_platform_data	*pd;
+	struct phy			*phy;
  };
 
  /*
@@ -248,7 +250,7 @@ struct mipi_dsim_device {
   * @enabled: indicate whether mipi controller got enabled or not.
   * @lcd_panel_info: pointer for lcd panel specific structure.
   *	this structure specifies width, height, timing and polarity and so on.
- * @phy_enable: pointer to a callback controlling D-PHY enable/reset
+ * @phy_label: the generic PHY label
   */
  struct mipi_dsim_platform_data {
  	char				lcd_panel_name[PANEL_NAME_SIZE];

include/video/exynos_mipi_dsim.h struct mipi_dsim_platform_data { · line 265

Quoted 8 lines
include/video/exynos_mipi_dsim.h +1 -1
@@ -257,7 +259,7 @@ struct mipi_dsim_platform_data {
  	unsigned int			enabled;
  	void				*lcd_panel_info;
 
-	int (*phy_enable)(struct platform_device *pdev, bool on);
+	const char 			*phy_label;
  };
 
  /*

I confirmed that this patch operates well. It looks good to me.

Thank you,
Donghwa Lee

#14 lore raw

PATCH v3 4/5 exynos4-is: Use the generic MIPI CSIS PHY driver

In reply to Sylwester Nawrocki

Use the generic PHY API instead of the platform callback to control the MIPI CSIS DPHY. The 'phy_label' field is added to the platform data structure to allow PHY lookup on non-dt platforms

---
 drivers/media/platform/exynos4-is/mipi-csis.c |   16 +++++++++++++---
 include/linux/platform_data/mipi-csis.h       |   11 ++---------
 2 files changed, 15 insertions(+), 12 deletions(-)
drivers/media/platform/exynos4-is/mipi-csis.c +13 -3
index a2eda9d..8436254 100644
@@ -20,6 +20,7 @@
 #include <linux/memory.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/phy/phy.h>
 #include <linux/platform_data/mipi-csis.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -167,6 +168,7 @@ struct csis_pktbuf {
  * @sd: v4l2_subdev associated with CSIS device instance
  * @index: the hardware instance index
  * @pdev: CSIS platform device
+ * @phy: pointer to the CSIS generic PHY
  * @regs: mmaped I/O registers memory
  * @supplies: CSIS regulator supplies
  * @clock: CSIS clocks
@@ -189,6 +191,8 @@ struct csis_state {
 	struct v4l2_subdev sd;
 	u8 index;
 	struct platform_device *pdev;
+	struct phy *phy;
+	const char *phy_label;
 	void __iomem *regs;
 	struct regulator_bulk_data supplies[CSIS_NUM_SUPPLIES];
 	struct clk *clock[NUM_CSIS_CLOCKS];
@@ -726,6 +730,7 @@ static int s5pcsis_get_platform_data(struct platform_device *pdev,
 	state->index = max(0, pdev->id);
 	state->max_num_lanes = state->index ? CSIS1_MAX_LANES :
 					      CSIS0_MAX_LANES;
+	state->phy_label = pdata->phy_label;
 	return 0;
 }
 
@@ -763,8 +768,9 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 					"samsung,csis-wclk");
 
 	state->num_lanes = endpoint.bus.mipi_csi2.num_data_lanes;
-
 	of_node_put(node);
+
+	state->phy_label = "csis";
 	return 0;
 }
 #else
@@ -800,6 +806,10 @@ static int s5pcsis_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
+	state->phy = devm_phy_get(dev, state->phy_label);
+	if (IS_ERR(state->phy))
+		return PTR_ERR(state->phy);
+
 	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	state->regs = devm_ioremap_resource(dev, mem_res);
 	if (IS_ERR(state->regs))
@@ -893,7 +903,7 @@ static int s5pcsis_pm_suspend(struct device *dev, bool runtime)
 	mutex_lock(&state->lock);
 	if (state->flags & ST_POWERED) {
 		s5pcsis_stop_stream(state);
-		ret = s5p_csis_phy_enable(state->index, false);
+		ret = phy_power_off(state->phy);
 		if (ret)
 			goto unlock;
 		ret = regulator_bulk_disable(CSIS_NUM_SUPPLIES,
@@ -929,7 +939,7 @@ static int s5pcsis_pm_resume(struct device *dev, bool runtime)
 					    state->supplies);
 		if (ret)
 			goto unlock;
-		ret = s5p_csis_phy_enable(state->index, true);
+		ret = phy_power_on(state->phy);
 		if (!ret) {
 			state->flags |= ST_POWERED;
 		} else {
include/linux/platform_data/mipi-csis.h +2 -9
index bf34e17..9214317 100644
@@ -17,21 +17,14 @@
  * @wclk_source: CSI wrapper clock selection: 0 - bus clock, 1 - ext. SCLK_CAM
  * @lanes:       number of data lanes used
  * @hs_settle:   HS-RX settle time
+ * @phy_label:	 the generic PHY label
  */
 struct s5p_platform_mipi_csis {
 	unsigned long clk_rate;
 	u8 wclk_source;
 	u8 lanes;
 	u8 hs_settle;
+	const char *phy_label;
 };
 
-/**
- * s5p_csis_phy_enable - global MIPI-CSI receiver D-PHY control
- * @id:     MIPI-CSIS harware instance index (0...1)
- * @on:     true to enable D-PHY and deassert its reset
- *          false to disable D-PHY
- * @return: 0 on success, or negative error code on failure
- */
-int s5p_csis_phy_enable(int id, bool on);
-
 #endif /* __PLAT_SAMSUNG_MIPI_CSIS_H_ */
Signature · 1 line
1.7.9.5
#15 lore raw

PATCH v3 5/5 ARM: Samsung: Remove the MIPI PHY setup code

In reply to Sylwester Nawrocki

Generic PHY drivers are used to handle the MIPI CSIS and MIPI DSIM DPHYs so we can remove now unused code at arch/arm/plat-samsung. In case there is any board file for S5PV210 platforms using MIPI CSIS/DSIM (not any upstream currently) it should use the generic PHY API to bind the PHYs to respective PHY consumer drivers and a platform device for the PHY provider should be defined.

---
 arch/arm/mach-exynos/include/mach/regs-pmu.h    |    5 --
 arch/arm/mach-s5pv210/include/mach/regs-clock.h |    4 --
 arch/arm/plat-samsung/Kconfig                   |    5 --
 arch/arm/plat-samsung/Makefile                  |    1 -
 arch/arm/plat-samsung/setup-mipiphy.c           |   60 -----------------------
 5 files changed, 75 deletions(-)
 delete mode 100644 arch/arm/plat-samsung/setup-mipiphy.c
arch/arm/mach-exynos/include/mach/regs-pmu.h +0 -5
index 57344b7..2cdb63e 100644
@@ -44,11 +44,6 @@
 #define S5P_DAC_PHY_CONTROL			S5P_PMUREG(0x070C)
 #define S5P_DAC_PHY_ENABLE			(1 << 0)
 
-#define S5P_MIPI_DPHY_CONTROL(n)		S5P_PMUREG(0x0710 + (n) * 4)
-#define S5P_MIPI_DPHY_ENABLE			(1 << 0)
-#define S5P_MIPI_DPHY_SRESETN			(1 << 1)
-#define S5P_MIPI_DPHY_MRESETN			(1 << 2)
-
 #define S5P_INFORM0				S5P_PMUREG(0x0800)
 #define S5P_INFORM1				S5P_PMUREG(0x0804)
 #define S5P_INFORM2				S5P_PMUREG(0x0808)
arch/arm/mach-s5pv210/include/mach/regs-clock.h +0 -4
index 032de66..e345584 100644
@@ -147,10 +147,6 @@
 #define S5P_HDMI_PHY_CONTROL	S5P_CLKREG(0xE804)
 #define S5P_USB_PHY_CONTROL	S5P_CLKREG(0xE80C)
 #define S5P_DAC_PHY_CONTROL	S5P_CLKREG(0xE810)
-#define S5P_MIPI_DPHY_CONTROL(x) S5P_CLKREG(0xE814)
-#define S5P_MIPI_DPHY_ENABLE	(1 << 0)
-#define S5P_MIPI_DPHY_SRESETN	(1 << 1)
-#define S5P_MIPI_DPHY_MRESETN	(1 << 2)
 
 #define S5P_INFORM0		S5P_CLKREG(0xF000)
 #define S5P_INFORM1		S5P_CLKREG(0xF004)
arch/arm/plat-samsung/Kconfig +0 -5
index b21d9d5..60f6337 100644
@@ -388,11 +388,6 @@ config S3C24XX_PWM
 	  Support for exporting the PWM timer blocks via the pwm device
 	  system
 
-config S5P_SETUP_MIPIPHY
-	bool
-	help
-	  Compile in common setup code for MIPI-CSIS and MIPI-DSIM devices
-
 config S3C_SETUP_CAMIF
 	bool
 	help
arch/arm/plat-samsung/Makefile +0 -1
index 5d7f839..0db786e 100644
@@ -38,7 +38,6 @@ obj-$(CONFIG_S5P_DEV_UART)	+= s5p-dev-uart.o
 obj-$(CONFIG_SAMSUNG_DEV_BACKLIGHT)	+= dev-backlight.o
 
 obj-$(CONFIG_S3C_SETUP_CAMIF)	+= setup-camif.o
-obj-$(CONFIG_S5P_SETUP_MIPIPHY)	+= setup-mipiphy.o
 
 # DMA support
 
arch/arm/plat-samsung/setup-mipiphy.c deleted +0 -60

60 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#16 lore raw

PATCH v3 5/5 ARM: Samsung: Remove the MIPI PHY setup code

Quoted 11 lines · Sylwester Nawrocki

Generic PHY drivers are used to handle the MIPI CSIS and MIPI DSIM DPHYs so we can remove now unused code at arch/arm/plat-samsung. In case there is any board file for S5PV210 platforms using MIPI CSIS/DSIM (not any upstream currently) it should use the generic PHY API to bind the PHYs to respective PHY consumer drivers and a platform device for the PHY provider should be defined.

Quoted 6 lines
---
 arch/arm/mach-exynos/include/mach/regs-pmu.h    |    5 --
 arch/arm/mach-s5pv210/include/mach/regs-clock.h |    4 --
 arch/arm/plat-samsung/Kconfig                   |    5 --
 arch/arm/plat-samsung/Makefile                  |    1 -
 arch/arm/plat-samsung/setup-mipiphy.c           |   60

---------------------

Quoted 4 lines

--

 5 files changed, 75 deletions(-)
 delete mode 100644 arch/arm/plat-samsung/setup-mipiphy.c

Looks good, please feel free to add my ack on this,

Thanks,
- Kukjin