Skip to contentSkip to conversation

libata: pata_samsung: Add Samsung PATA controller driver

PATCH Superseded Kukjin Kim 2 participants 3 messages Jul 12, 2010 – Jul 13, 2010

Subsystems (2)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Kukjin Kim

author
#0 lore raw

PATCH v6 1/1 libata: pata_samsung: Add Samsung PATA controller driver

From: Abhilash Kesavan <[email protected]>

Adds support for the Samsung PATA controller. This driver is based on the Libata subsystem and references the earlier patches sent for IDE subsystem.

---
Changes since v5:
Following addresses recent comments from Sergei.
- Replace overlooked iowrite8 calls with ata_outb().
- Directly use PM state variable in suspend function.

 drivers/ata/Kconfig           |    9 +
 drivers/ata/Makefile          |    1 +
 drivers/ata/pata_samsung_cf.c |  727 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 737 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/pata_samsung_cf.c
drivers/ata/Kconfig +9 -0
index aa85a98..1b5facf 100644
@@ -796,6 +796,15 @@ config PATA_RZ1000
 
 	  If unsure, say N.
 
+config PATA_SAMSUNG_CF
+	tristate "Samsung SoC PATA support"
+	depends on SAMSUNG_DEV_IDE
+	help
+	  This option enables basic support for Samsung's S3C/S5P board
+	  PATA controllers via the new ATA layer
+
+	  If unsure, say N.
+
 config PATA_WINBOND_VLB
 	tristate "Winbond W83759A VLB PATA support (Experimental)"
 	depends on ISA && EXPERIMENTAL
drivers/ata/Makefile +1 -0
index 7ef89d7..9576776 100644
@@ -87,6 +87,7 @@ obj-$(CONFIG_PATA_OF_PLATFORM)	+= pata_of_platform.o
 obj-$(CONFIG_PATA_QDI)		+= pata_qdi.o
 obj-$(CONFIG_PATA_RB532)	+= pata_rb532_cf.o
 obj-$(CONFIG_PATA_RZ1000)	+= pata_rz1000.o
+obj-$(CONFIG_PATA_SAMSUNG_CF)	+= pata_samsung_cf.o
 obj-$(CONFIG_PATA_WINBOND_VLB)	+= pata_winbond.o
 
 # Should be last but two libata driver
drivers/ata/pata_samsung_cf.c new file +727 -0

727 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#1 lore raw

PATCH v6 1/1 libata: pata_samsung: Add Samsung PATA controller driver

Hello.

Quoted 8 lines · Kukjin Kim

From: Abhilash Kesavan <[email protected]>

Adds support for the Samsung PATA controller. This driver is based on the Libata subsystem and references the earlier patches sent for IDE subsystem.

There's probably still a place for improvement... sorry that I dind't
notice before. Other than that:

[...]

Quoted 6 lines
drivers/ata/pata_samsung_cf.c new file +0 -0
new file mode 100644
index 0000000..5718220
@@ -0,0 +1,727 @@

[...]

Quoted 15 lines
drivers/ata/pata_samsung_cf.c new file +15 -0
+/*
+ * pata_s3c_wait_after_reset - wait for devices to become ready after reset
+ */
+static int pata_s3c_wait_after_reset(struct ata_link *link,
+		unsigned int devmask, unsigned long deadline)
+{
+	struct ata_port *ap = link->ap;
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+	unsigned int dev0 = devmask & (1 << 0);
+	unsigned int dev1 = devmask & (1 << 1);
+	int rc, ret = 0;
+
+	msleep(ATA_WAIT_AFTER_RESET);
+
+	/* always check readiness of the master device */

drivers/ata/pata_samsung_cf.c line 341

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+	rc = ata_sff_wait_ready(link, deadline);
+	/* -ENODEV means the odd clown forgot the D7 pulldown resistor
+	 * and TF status is 0xff, bail out on it too.
+	 */
+	if (rc)
+		return rc;
+
+	/* if device 1 was found in ata_devchk, wait for register
+	 * access briefly, then wait for BSY to clear.
+	 */

You don't call pata_s3c_devchk() for device 1, so in principle you can
drop the following block:

Quoted 21 lines
drivers/ata/pata_samsung_cf.c new file +21 -0
+	if (dev1) {
+		int i;
+
+		pata_s3c_dev_select(ap, 1);
+
+		/* Wait for register access.  Some ATAPI devices fail
+		 * to set nsect/lbal after reset, so don't waste too
+		 * much time on it.  We're gonna wait for !BSY anyway.
+		 */
+		for (i = 0; i < 2; i++) {
+			u8 nsect, lbal;
+
+			nsect = ata_inb(ap->host, ioaddr->nsect_addr);
+			lbal = ata_inb(ap->host, ioaddr->lbal_addr);
+			if ((nsect == 1) && (lbal == 1))
+				break;
+			msleep(50);	/* give drive a breather */
+		}
+
+		rc = ata_sff_wait_ready(link, deadline);
+		if (rc) {

drivers/ata/pata_samsung_cf.c line 372

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+			if (rc != -ENODEV)
+				return rc;
+			ret = rc;
+		}
+	}
+
+	/* is all this really necessary? */
+	pata_s3c_dev_select(ap, 0);
+	if (dev1)
+		pata_s3c_dev_select(ap, 1);
    This too...
Quoted 6 lines
drivers/ata/pata_samsung_cf.c new file +6 -0
+	if (dev0)
+		pata_s3c_dev_select(ap, 0);
+
+	return ret;
+}
+

[...]

drivers/ata/pata_samsung_cf.c line 668

Quoted 8 lines
drivers/ata/pata_samsung_cf.c new file +8 -0
+static int pata_s3c_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct ata_host *host = platform_get_drvdata(pdev);
+	struct s3c_ide_platdata *pdata = pdev->dev.platform_data;
+	struct s3c_ide_info *info;
+
+	info = host->private_data;

Could be initializer...

MBR, Sergei

author
#2 lore raw

PATCH v6 1/1 libata: pata_samsung: Add Samsung PATA controller driver

Quoted 2 lines · Sergei Shtylyov

Hello.

Hi ;-)

Quoted 6 lines
Quoted 3 lines · Kukjin Kim

From: Abhilash Kesavan <[email protected]>

Adds support for the Samsung PATA controller. This driver is based on

the

Quoted 1 line
Quoted 1 line

Libata subsystem and references the earlier patches sent for IDE

subsystem.

Quoted 8 lines
Quoted 4 lines

There's probably still a place for improvement... sorry that I dind't
notice before. Other than that:

Ok..will address comments from you and re-submit.

Quoted 2 lines

Will be added above your ack in updated patch.
If any problem, please let me know.

Quoted 3 lines

[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/ata/pata_samsung_cf.c

Quoted 8 lines
Quoted 5 lines

new file mode 100644
index 0000000..5718220

drivers/ata/pata_samsung_cf.c new file +0 -0
@@ -0,0 +1,727 @@

[...]

Quoted 2 lines

+/*
+ * pata_s3c_wait_after_reset - wait for devices to become ready after

reset

Quoted 79 lines
Quoted 13 lines

+ */

drivers/ata/pata_samsung_cf.c new file +12 -0
+static int pata_s3c_wait_after_reset(struct ata_link *link,
+		unsigned int devmask, unsigned long deadline)
+{
+	struct ata_port *ap = link->ap;
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+	unsigned int dev0 = devmask & (1 << 0);
+	unsigned int dev1 = devmask & (1 << 1);
+	int rc, ret = 0;
+
+	msleep(ATA_WAIT_AFTER_RESET);
+
+	/* always check readiness of the master device */

drivers/ata/pata_samsung_cf.c line 341

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+	rc = ata_sff_wait_ready(link, deadline);
+	/* -ENODEV means the odd clown forgot the D7 pulldown resistor
+	 * and TF status is 0xff, bail out on it too.
+	 */
+	if (rc)
+		return rc;
+
+	/* if device 1 was found in ata_devchk, wait for register
+	 * access briefly, then wait for BSY to clear.
+	 */

You don't call pata_s3c_devchk() for device 1, so in principle you can
drop the following block:

Quoted 21 lines
drivers/ata/pata_samsung_cf.c new file +21 -0
+	if (dev1) {
+		int i;
+
+		pata_s3c_dev_select(ap, 1);
+
+		/* Wait for register access.  Some ATAPI devices fail
+		 * to set nsect/lbal after reset, so don't waste too
+		 * much time on it.  We're gonna wait for !BSY anyway.
+		 */
+		for (i = 0; i < 2; i++) {
+			u8 nsect, lbal;
+
+			nsect = ata_inb(ap->host, ioaddr->nsect_addr);
+			lbal = ata_inb(ap->host, ioaddr->lbal_addr);
+			if ((nsect == 1) && (lbal == 1))
+				break;
+			msleep(50);	/* give drive a breather */
+		}
+
+		rc = ata_sff_wait_ready(link, deadline);
+		if (rc) {

drivers/ata/pata_samsung_cf.c line 372

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+			if (rc != -ENODEV)
+				return rc;
+			ret = rc;
+		}
+	}
+
+	/* is all this really necessary? */
+	pata_s3c_dev_select(ap, 0);
+	if (dev1)
+		pata_s3c_dev_select(ap, 1);
    This too...
Quoted 6 lines
drivers/ata/pata_samsung_cf.c new file +6 -0
+	if (dev0)
+		pata_s3c_dev_select(ap, 0);
+
+	return ret;
+}
+

[...]

drivers/ata/pata_samsung_cf.c line 668

Quoted 8 lines
drivers/ata/pata_samsung_cf.c new file +8 -0
+static int pata_s3c_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct ata_host *host = platform_get_drvdata(pdev);
+	struct s3c_ide_platdata *pdata = pdev->dev.platform_data;
+	struct s3c_ide_info *info;
+
+	info = host->private_data;

Could be initializer...

Quoted 1 line

MBR, Sergei

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.