Skip to contentSkip to conversation

ata: Add iMX pata support

PATCH Superseded Arnaud Patard (Rtp) 2 participants 2 messages Jul 22, 2011

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: Add iMX pata support

Add basic support for pata on iMX. It has been tested only on imx51. SDMA support will probably be added later so this version supports only PIO.

v2:
- enable only when needed IORDY
- use dev_get_drvdata

drivers/ata/Kconfig +9 -0
Index: linux-2.6-submit/drivers/ata/Kconfig
===================================================================
@@ -467,6 +467,15 @@ config PATA_ICSIDE
 	  interface card.  This is not required for ICS partition support.
 	  If you are unsure, say N to this.
 
+config PATA_IMX
+	tristate "PATA support for Freescale iMX (Experimental)"
+	depends on ARCH_MX5 && EXPERIMENTAL
+	help
+	  This option enables support for the PATA host available on Freescale
+          iMX SoCs.
+
+	  If unsure, say N.
+
 config PATA_IT8213
 	tristate "IT8213 PATA support (Experimental)"
 	depends on PCI && EXPERIMENTAL
drivers/ata/Makefile +1 -0
Index: linux-2.6-submit/drivers/ata/Makefile
===================================================================
@@ -48,6 +48,7 @@ obj-$(CONFIG_PATA_HPT37X)	+= pata_hpt37x
 obj-$(CONFIG_PATA_HPT3X2N)	+= pata_hpt3x2n.o
 obj-$(CONFIG_PATA_HPT3X3)	+= pata_hpt3x3.o
 obj-$(CONFIG_PATA_ICSIDE)	+= pata_icside.o
+obj-$(CONFIG_PATA_IMX)		+= pata_imx.o
 obj-$(CONFIG_PATA_IT8213)	+= pata_it8213.o
 obj-$(CONFIG_PATA_IT821X)	+= pata_it821x.o
 obj-$(CONFIG_PATA_JMICRON)	+= pata_jmicron.o
drivers/ata/pata_imx.c new file +260 -0

260 lines not on this page · raw message

#1 lore raw

Hello.

Quoted 7 lines · Arnaud Patard (Rtp)

Add basic support for pata on iMX. It has been tested only on imx51. SDMA support will probably be added later so this version supports only PIO.

v2:
- enable only when needed IORDY
- use dev_get_drvdata

Shouldn't this be under --- tearline?

Quoted 1 line

[...]

Quoted 5 lines

Index: linux-2.6-submit/drivers/ata/pata_imx.c
===================================================================

drivers/ata/pata_imx.c new file +0 -0
@@ -0,0 +1,260 @@

[...]

Quoted 7 lines
drivers/ata/pata_imx.c new file +7 -0
+static int __devinit pata_imx_probe(struct platform_device *pdev)
+{
+	struct ata_host *host;
+	struct ata_port *ap;
+	struct pata_imx_priv *priv;
+	int irq = 0;
+	struct resource *io_res;

drivers/ata/pata_imx.c line 109

Quoted 10 lines
drivers/ata/pata_imx.c new file +10 -0
+	struct resource *irq_res;
+
+	io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (io_res == NULL)
+		return -EINVAL;
+
+	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (irq_res == NULL)
+		return -EINVAL;
+	irq = irq_res->start;

Using platfrom_get_irq() would have been somewhat simpler -- you don't
need 'irq_res' at all...

drivers/ata/pata_imx.c line 168

Quoted 3 lines
drivers/ata/pata_imx.c new file +3 -0
+free_priv:
+	if (priv->clk)
+		clk_disable(priv->clk);

Need to call clk_put() also...

Quoted 5 lines
drivers/ata/pata_imx.c new file +5 -0
+	kfree(priv);
+	return -ENOMEM;
+}
+
+static int __devexit pata_imx_remove(struct platform_device *pdev)

drivers/ata/pata_imx.c line 183

Quoted 10 lines
drivers/ata/pata_imx.c new file +10 -0
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	struct pata_imx_priv *priv = host->private_data;
+
+	ata_host_detach(host);
+
+	__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
+
+	if (priv->clk)
+		clk_disable(priv->clk);

Same here...

Quoted 18 lines
drivers/ata/pata_imx.c new file +18 -0
+#ifdef CONFIG_PM
+static int pata_imx_suspend(struct device *dev)
+{
+	struct ata_host *host = dev_get_drvdata(dev);
+	struct pata_imx_priv *priv = host->private_data;
+	int ret;
+
+	ret = ata_host_suspend(host, PMSG_SUSPEND);
+	if (!ret)
+		__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
+
+	if (priv->clk)
+		clk_disable(priv->clk);
+
+	return ret;
+}
+
+static int pata_imx_resume(struct device *dev)

drivers/ata/pata_imx.c line 217

Quoted 10 lines
drivers/ata/pata_imx.c new file +10 -0
+{
+	struct ata_host *host = dev_get_drvdata(dev);
+	struct pata_imx_priv *priv = host->private_data;
+
+	if (priv->clk)
+		clk_enable(priv->clk);
+
+	__raw_writel(PATA_IMX_ATA_CTRL_FIFO_RST_B |
+			PATA_IMX_ATA_CTRL_ATA_RST_B,
+			priv->host_regs + PATA_IMX_ATA_CONTROL);

This will disable IORDY.

WBR, Sergei