Skip to contentSkip to conversation

i.MX PATA cleanup and i.MX51 support

PATCH New Sascha Hauer 3 participants 10 messages Apr 4, 2013 – Apr 11, 2013

Subsystems (7)
lore
Share & tools
lore

Sascha Hauer

author maintainer
#0 lore raw

PATCH 1/1 i.MX PATA cleanup and i.MX51 support

The following contains some cleanup and devicetree support for the i.MX PATA driver. Also i.MX51 PATA support is added.

The first four patches should go via the ata tree, the others through arm-soc, they do not depend on each other.

Sascha

----------------------------------------------------------------
Sascha Hauer (6):
ata: i.MX PATA: Use devm_clk_get
ata: i.MX PATA: cleanup error path
ata: i.MX PATA: use void __iomem * for regs
ata: i.MX PATA: add devicetree support
ARM: i.MX5: Add PATA and SRTC clocks
ARM: i.MX51: Add PATA support

 Documentation/devicetree/bindings/ata/imx-pata.txt | 17 +++++++++
 .../devicetree/bindings/clock/imx5-clock.txt       |  2 +
 arch/arm/boot/dts/imx51.dtsi                       | 44 ++++++++++++++++++++++
 arch/arm/mach-imx/clk-imx51-imx53.c                |  4 +-
 drivers/ata/pata_imx.c                             | 36 +++++++++++++-----
 5 files changed, 92 insertions(+), 11 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/imx-pata.txt
author maintainer
#1 lore raw

PATCH 1/6 ata: i.MX PATA: Use devm_clk_get

To make the error path a bit simpler.

---
 drivers/ata/pata_imx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/ata/pata_imx.c +2 -3
index 4084944..af893dd 100644
@@ -112,7 +112,7 @@ static int pata_imx_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
-	priv->clk = clk_get(&pdev->dev, NULL);
+	priv->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(priv->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
 		return PTR_ERR(priv->clk);
@@ -163,7 +163,7 @@ static int pata_imx_probe(struct platform_device *pdev)
 
 free_priv:
 	clk_disable_unprepare(priv->clk);
-	clk_put(priv->clk);
+
 	return -ENOMEM;
 }
 
@@ -177,7 +177,6 @@ static int pata_imx_remove(struct platform_device *pdev)
 	__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
 
 	clk_disable_unprepare(priv->clk);
-	clk_put(priv->clk);
 
 	return 0;
 }
Signature · 1 line
1.8.2.rc2
author maintainer
#2 lore raw

PATCH 2/6 ata: i.MX PATA: cleanup error path

In reply to Sascha Hauer

- rename free_priv label to 'err' since priv is allocated with devm_* and not freed here.
- add missing 'goto err' in case ata_host_activate fails
- add 'ret' variable to return correct error value instead of hardcoded -ENOMEM in error case.

---
 drivers/ata/pata_imx.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/ata/pata_imx.c +14 -6
index af893dd..f243496 100644
@@ -98,6 +98,7 @@ static int pata_imx_probe(struct platform_device *pdev)
 	struct pata_imx_priv *priv;
 	int irq = 0;
 	struct resource *io_res;
+	int ret;
 
 	io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (io_res == NULL)
@@ -121,8 +122,10 @@ static int pata_imx_probe(struct platform_device *pdev)
 	clk_prepare_enable(priv->clk);
 
 	host = ata_host_alloc(&pdev->dev, 1);
-	if (!host)
-		goto free_priv;
+	if (!host) {
+		ret = -ENOMEM;
+		goto err;
+	}
 
 	host->private_data = priv;
 	ap = host->ports[0];
@@ -135,7 +138,8 @@ static int pata_imx_probe(struct platform_device *pdev)
 		resource_size(io_res));
 	if (!priv->host_regs) {
 		dev_err(&pdev->dev, "failed to map IO/CTL base\n");
-		goto free_priv;
+		ret = -EBUSY;
+		goto err;
 	}
 
 	ap->ioaddr.cmd_addr = priv->host_regs + PATA_IMX_DRIVE_DATA;
@@ -158,13 +162,17 @@ static int pata_imx_probe(struct platform_device *pdev)
 			priv->host_regs + PATA_IMX_ATA_INT_EN);
 
 	/* activate */
-	return ata_host_activate(host, irq, ata_sff_interrupt, 0,
+	ret = ata_host_activate(host, irq, ata_sff_interrupt, 0,
 				&pata_imx_sht);
 
-free_priv:
+	if (ret)
+		goto err;
+
+	return 0;
+err:
 	clk_disable_unprepare(priv->clk);
 
-	return -ENOMEM;
+	return ret;
 }
 
 static int pata_imx_remove(struct platform_device *pdev)
Signature · 1 line
1.8.2.rc2
author maintainer
#3 lore raw

PATCH 3/6 ata: i.MX PATA: use void __iomem * for regs

In reply to Sascha Hauer

regs is returned from ioremap, so add a __iomem. Also, make it void * instead of u8 *.

---
 drivers/ata/pata_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/pata_imx.c +1 -1
index f243496..adbb01d 100644
@@ -37,7 +37,7 @@
 struct pata_imx_priv {
 	struct clk *clk;
 	/* timings/interrupt/control regs */
-	u8 *host_regs;
+	void __iomem *host_regs;
 	u32 ata_ctl;
 };
 
Signature · 1 line
1.8.2.rc2
author maintainer
#4 lore raw

PATCH 4/6 ata: i.MX PATA: add devicetree support

In reply to Sascha Hauer

Not much to do here, only the compatible entries have to be added.

---
 Documentation/devicetree/bindings/ata/imx-pata.txt | 17 +++++++++++++++++
 drivers/ata/pata_imx.c                             |  9 +++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ata/imx-pata.txt
Documentation/devicetree/bindings/ata/imx-pata.txt new file +17 -0
new file mode 100644
index 0000000..e38d734
@@ -0,0 +1,17 @@
+* Freescale i.MX PATA Controller
+
+Required properties:
+- compatible: "fsl,imx27-pata"
+- reg: Address range of the PATA Controller
+- interrupts: The interrupt of the PATA Controller
+- clocks: the clocks for the PATA Controller
+
+Example:
+
+	pata: pata at 83fe0000 {
+		compatible = "fsl,imx51-pata", "fsl,imx27-pata";
+		reg = <0x83fe0000 0x4000>;
+		interrupts = <70>;
+		clocks = <&clks 161>;
+		status = "disabled";
+	};
drivers/ata/pata_imx.c +9 -0
index adbb01d..aa3d166 100644
@@ -230,11 +230,20 @@ static const struct dev_pm_ops pata_imx_pm_ops = {
 };
 #endif
 
+static const struct of_device_id imx_pata_dt_ids[] = {
+	{
+		.compatible = "fsl,imx27-pata",
+	}, {
+		/* sentinel */
+	}
+};
+
 static struct platform_driver pata_imx_driver = {
 	.probe		= pata_imx_probe,
 	.remove		= pata_imx_remove,
 	.driver = {
 		.name		= DRV_NAME,
+		.of_match_table	= imx_pata_dt_ids,
 		.owner		= THIS_MODULE,
 #ifdef CONFIG_PM
 		.pm		= &pata_imx_pm_ops,
Signature · 1 line
1.8.2.rc2
#5 lore raw

PATCH 4/6 ata: i.MX PATA: add devicetree support

Quoted 8 lines · Sascha Hauer

Not much to do here, only the compatible entries have to be added.

---
  Documentation/devicetree/bindings/ata/imx-pata.txt | 17 +++++++++++++++++
  drivers/ata/pata_imx.c                             |  9 +++++++++
  2 files changed, 26 insertions(+)

create mode 100644 Documentation/devicetree/bindings/ata/imx-pata.txt

applied 1-4

author maintainer
#6 lore raw

PATCH 5/6 ARM: i.MX5: Add PATA and SRTC clocks

In reply to Sascha Hauer

This adds the clock gates and the binding documentation for PATA and SRTC.

---
 Documentation/devicetree/bindings/clock/imx5-clock.txt | 2 ++
 arch/arm/mach-imx/clk-imx51-imx53.c                    | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/imx5-clock.txt +2 -0
index 2a0c904..da5eb30 100644
@@ -172,6 +172,8 @@ clocks and IDs.
 	can1_serial_gate	157
 	can1_ipg_gate		158
 	owire_gate		159
+	srtc_gate		160
+	pata_gate		161
 
 Examples (for mx53):
 
arch/arm/mach-imx/clk-imx51-imx53.c +3 -1
index 0f39f8c..026a819 100644
@@ -83,7 +83,7 @@ enum imx5_clks {
 	ssi2_root_gate, ssi3_root_gate, ssi_ext1_gate, ssi_ext2_gate,
 	epit1_ipg_gate, epit1_hf_gate, epit2_ipg_gate, epit2_hf_gate,
 	can_sel, can1_serial_gate, can1_ipg_gate,
-	owire_gate,
+	owire_gate, srtc_gate, pata_gate,
 	clk_max
 };
 
@@ -235,6 +235,8 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
 	clk[epit2_ipg_gate] = imx_clk_gate2("epit2_ipg_gate", "ipg", MXC_CCM_CCGR2, 6);
 	clk[epit2_hf_gate] = imx_clk_gate2("epit2_hf_gate", "per_root", MXC_CCM_CCGR2, 8);
 	clk[owire_gate] = imx_clk_gate2("owire_gate", "per_root", MXC_CCM_CCGR2, 22);
+	clk[srtc_gate] = imx_clk_gate2("srtc_gate", "per_root", MXC_CCM_CCGR4, 28);
+	clk[pata_gate] = imx_clk_gate2("pata_gate", "ipg", MXC_CCM_CCGR4, 0);
 
 	for (i = 0; i < ARRAY_SIZE(clk); i++)
 		if (IS_ERR(clk[i]))
Signature · 1 line
1.8.2.rc2
#7 lore raw

PATCH 5/6 ARM: i.MX5: Add PATA and SRTC clocks

Quoted 4 lines · Sascha Hauer

This adds the clock gates and the binding documentation for PATA and SRTC.

Patch #5 and #6 applied, thanks.

author maintainer
#8 lore raw

PATCH 6/6 ARM: i.MX51: Add PATA support

In reply to Sascha Hauer

This adds the PATA device and the pinctrl group for to the i.MX51 dts.

---
 arch/arm/boot/dts/imx51.dtsi | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
arch/arm/boot/dts/imx51.dtsi +44 -0
index fcf035b..cc54f0d 100644
@@ -411,6 +411,42 @@
 					};
 				};
 
+				pata {
+					pinctrl_pata_1: patagrp-1 {
+						fsl,pins = <
+							MX51_PAD_NANDF_WE_B__PATA_DIOW		0x2004
+							MX51_PAD_NANDF_RE_B__PATA_DIOR		0x2004
+							MX51_PAD_NANDF_ALE__PATA_BUFFER_EN	0x2004
+							MX51_PAD_NANDF_CLE__PATA_RESET_B	0x2004
+							MX51_PAD_NANDF_WP_B__PATA_DMACK		0x2004
+							MX51_PAD_NANDF_RB0__PATA_DMARQ		0x2004
+							MX51_PAD_NANDF_RB1__PATA_IORDY		0x2004
+							MX51_PAD_GPIO_NAND__PATA_INTRQ		0x2004
+							MX51_PAD_NANDF_CS2__PATA_CS_0		0x2004
+							MX51_PAD_NANDF_CS3__PATA_CS_1		0x2004
+							MX51_PAD_NANDF_CS4__PATA_DA_0		0x2004
+							MX51_PAD_NANDF_CS5__PATA_DA_1		0x2004
+							MX51_PAD_NANDF_CS6__PATA_DA_2		0x2004
+							MX51_PAD_NANDF_D15__PATA_DATA15		0x2004
+							MX51_PAD_NANDF_D14__PATA_DATA14		0x2004
+							MX51_PAD_NANDF_D13__PATA_DATA13		0x2004
+							MX51_PAD_NANDF_D12__PATA_DATA12		0x2004
+							MX51_PAD_NANDF_D11__PATA_DATA11		0x2004
+							MX51_PAD_NANDF_D10__PATA_DATA10		0x2004
+							MX51_PAD_NANDF_D9__PATA_DATA9		0x2004
+							MX51_PAD_NANDF_D8__PATA_DATA8		0x2004
+							MX51_PAD_NANDF_D7__PATA_DATA7		0x2004
+							MX51_PAD_NANDF_D6__PATA_DATA6		0x2004
+							MX51_PAD_NANDF_D5__PATA_DATA5		0x2004
+							MX51_PAD_NANDF_D4__PATA_DATA4		0x2004
+							MX51_PAD_NANDF_D3__PATA_DATA3		0x2004
+							MX51_PAD_NANDF_D2__PATA_DATA2		0x2004
+							MX51_PAD_NANDF_D1__PATA_DATA1		0x2004
+							MX51_PAD_NANDF_D0__PATA_DATA0		0x2004
+						>;
+					};
+				};
+
 				uart1 {
 					pinctrl_uart1_1: uart1grp-1 {
 						fsl,pins = <
@@ -591,6 +627,14 @@
 				status = "disabled";
 			};
 
+			pata: pata@83fe0000 {
+				compatible = "fsl,imx51-pata", "fsl,imx27-pata";
+				reg = <0x83fe0000 0x4000>;
+				interrupts = <70>;
+				clocks = <&clks 161>;
+				status = "disabled";
+			};
+
 			ssi3: ssi at 83fe8000 {
 				compatible = "fsl,imx51-ssi", "fsl,imx21-ssi";
 				reg = <0x83fe8000 0x4000>;
Signature · 1 line
1.8.2.rc2
author maintainer
#9 lore raw

PATCH 1/1 i.MX PATA cleanup and i.MX51 support

In reply to Sascha Hauer

Hi Jeff,

Any comments to this series? Can you queue 1-4 for the next merge window?

Sascha

Quoted 30 lines · Sascha Hauer

The following contains some cleanup and devicetree support for the i.MX PATA driver. Also i.MX51 PATA support is added.

The first four patches should go via the ata tree, the others through arm-soc, they do not depend on each other.

Sascha

----------------------------------------------------------------
Sascha Hauer (6):
ata: i.MX PATA: Use devm_clk_get
ata: i.MX PATA: cleanup error path
ata: i.MX PATA: use void __iomem * for regs
ata: i.MX PATA: add devicetree support
ARM: i.MX5: Add PATA and SRTC clocks
ARM: i.MX51: Add PATA support

 Documentation/devicetree/bindings/ata/imx-pata.txt | 17 +++++++++
 .../devicetree/bindings/clock/imx5-clock.txt       |  2 +
 arch/arm/boot/dts/imx51.dtsi                       | 44 ++++++++++++++++++++++
 arch/arm/mach-imx/clk-imx51-imx53.c                |  4 +-
 drivers/ata/pata_imx.c                             | 36 +++++++++++++-----
 5 files changed, 92 insertions(+), 11 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/imx-pata.txt

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |