Skip to contentSkip to conversation

libata: pata_samsung_cf: Add Samsung PATA controller driver

PATCH Superseded Kukjin Kim 5 participants 12 messages Jun 14, 2010 – Jun 29, 2010

Subsystems (2)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Kukjin Kim

author
#0 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: 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 v3:

Addressed comments from

Sergei Shtylyov:
- Removed filename in header
- Used ata_timing_compute for obtaining timing parameters
- Removed valid PIO mode check
- Added softreset method and associated functions
- Used devm_request_mem_region function as had used devm_ioremap earlier
- Removed kree and release_mem_region calls because of managed kzalloc and request_mem_region fns being used
- Added return in clk_get function
- Added missing clk_put
- Corrected indentation issue

Ben Dooks:
- Added missing 'void __iomem' parameters
- Added check for trailing bytes in data_xfer function
- Removed assignment in data_xfer function
- Coding changes - e.g. in pata_s3c_enable, pata_s3c_dev_select, wait_for_host_ready
- Removed host checks in suspend/resume functions

 drivers/ata/Kconfig           |    9 +
 drivers/ata/Makefile          |    1 +
 drivers/ata/pata_samsung_cf.c |  735 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 745 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 +735 -0

735 lines not on this page · raw message

Signature · 1 line
1.6.6.1
author
#1 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

Quoted 5 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.

Quoted 4 lines

---

Hi,

Maybe missed? :-(

If no problems, please apply or kindly let me know how this should be handled.

Quoted 26 lines

Changes since v3:

Addressed comments from

Sergei Shtylyov:
- Removed filename in header
- Used ata_timing_compute for obtaining timing parameters
- Removed valid PIO mode check
- Added softreset method and associated functions
- Used devm_request_mem_region function as had used devm_ioremap earlier
- Removed kree and release_mem_region calls because of managed kzalloc and request_mem_region fns being used
- Added return in clk_get function
- Added missing clk_put
- Corrected indentation issue

Ben Dooks:
- Added missing 'void __iomem' parameters
- Added check for trailing bytes in data_xfer function
- Removed assignment in data_xfer function
- Coding changes - e.g. in pata_s3c_enable, pata_s3c_dev_select, wait_for_host_ready
- Removed host checks in suspend/resume functions

Quoted 7 lines
 drivers/ata/Kconfig           |    9 +
 drivers/ata/Makefile          |    1 +
 drivers/ata/pata_samsung_cf.c |  735
+++++++++++++++++++++++++++++++++++++++++
 3 files changed, 745 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/pata_samsung_cf.c

(snip)

Thanks.

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

#2 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

In reply to Kukjin Kim
Quoted 7 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.

Send it through the appropriate subsystem tree for this platform...

author
#3 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

Quoted 5 lines · Jeff Garzik
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 7 lines
Quoted 3 lines

Send it through the appropriate subsystem tree for this platform...

Hi,

You mean in my case, appropriate subsystem tree is ARM tree. But I think, as Ben commented, it's better drivers go to upstream via the driver's tree.
And of course, I read your comments about this like below... 'platform drivers do not build and/or work without additional platform glue...'

Hmm.
I'm not sure which way is better...

Russell,

How do you think?
May I send this to your patch tracking system?
Or...how should I handle this?

Thanks.

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

#4 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

Dne P? 25. ?ervna 2010 05:38:19 Kukjin Kim napsal(a):

Quoted 28 lines
Quoted 4 lines · Jeff Garzik
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 6 lines
Quoted 2 lines

Send it through the appropriate subsystem tree for this platform...

Hi,

You mean in my case, appropriate subsystem tree is ARM tree. But I think, as Ben commented, it's better drivers go to upstream via the driver's tree.
And of course, I read your comments about this like below... 'platform drivers do not build and/or work without additional platform glue...'

Quoted 2 lines

Hmm.
I'm not sure which way is better...

I pushed pata_pxa through Eric as well ... go for the linux-arm tree. Cheers

Quoted 19 lines

Russell,

How do you think?
May I send this to your patch tracking system?
Or...how should I handle this?

Thanks.

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

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#5 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

Quoted 1 line · Marek Vasut

Hello Marek,

Quoted 29 lines

Dne Pá 25. června 2010 05:38:19 Kukjin Kim napsal(a):

Quoted 28 lines
Quoted 4 lines · Jeff Garzik
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 6 lines
Quoted 2 lines

Send it through the appropriate subsystem tree for this platform...

Hi,

You mean in my case, appropriate subsystem tree is ARM tree. But I think, as Ben commented, it's better drivers go to upstream via the driver's tree.
And of course, I read your comments about this like below... 'platform drivers do not build and/or work without additional platform glue...'

Quoted 4 lines
Quoted 2 lines

Hmm.
I'm not sure which way is better...

I pushed pata_pxa through Eric as well ... go for the linux-arm tree.

Thanks for your help ;-)

But if possible, rmk patch tracking system is better to me. As Russell's comments, I will send to rmk with Ben's ack.

Thanks.

Quoted 8 lines

Cheers

Quoted 7 lines

Russell,

How do you think?
May I send this to your patch tracking system?
Or...how should I handle this?

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

#6 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

In reply to Kukjin Kim
Quoted 5 lines · Kukjin Kim

Russell,

How do you think?
May I send this to your patch tracking system?
Or...how should I handle this?

If Jeff is happy, then I'm happy. However, shouldn't it also have Ben's ack?

#7 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

Hello.

Quoted 6 lines · Russell King - ARM Linux
Quoted 3 lines

How do you think?
May I send this to your patch tracking system?
Or...how should I handle this?

If Jeff is happy, then I'm happy. However, shouldn't it also have Ben's ack?

I for one still have comments to be addressed, will post in a jiffy...

MBR, Sergei

author
#8 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

Quoted 5 lines · Sergei Shtylyov

Hello.

Russell King - ARM Linux wrote:

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

How do you think?
May I send this to your patch tracking system?
Or...how should I handle this?

If Jeff is happy, then I'm happy. However, shouldn't it also have Ben's ack?

I for one still have comments to be addressed, will post in a jiffy...

OK..will address comments from you as soon as possible.

Thanks.

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

author
#9 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

In reply to Russell King - ARM Linux
Quoted 10 lines · Russell King
Quoted 5 lines · Kukjin Kim

Russell,

How do you think?
May I send this to your patch tracking system?
Or...how should I handle this?

If Jeff is happy, then I'm happy. However, shouldn't it also have Ben's ack?

Sounds good :-)

Hmm..submitted has been addressed comments from Ben. So maybe can get the Ben's ack.

But will waiting for Ben's ack.

Thanks.

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

#10 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

In reply to Kukjin Kim

Hello.

Quoted 7 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.

[...]

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

[...]

drivers/ata/pata_samsung_cf.c line 80

Quoted 11 lines
drivers/ata/pata_samsung_cf.c new file +11 -0
+static unsigned long
+pata_s3c_setup_timing(struct s3c_ide_info *info, const struct ata_timing *ata)
+{
+	int t1;
+	int t2;
+	int t2i;
+	ulong piotime;
+
+	t1 = ata->setup;
+	t2 = ata->act8b;
+	t2i = ata->rec8b;

Could be initializers...

[...]

Quoted 20 lines
drivers/ata/pata_samsung_cf.c new file +20 -0
+/*
+ * pata_s3c_data_xfer - Transfer data by PIO
+ */
+unsigned int pata_s3c_data_xfer(struct ata_device *dev, unsigned char *buf,
+				unsigned int buflen, int rw)
+{
+	struct ata_port *ap = dev->link->ap;
+	struct s3c_ide_info *info = ap->host->private_data;
+	void __iomem *data_addr = ap->ioaddr.data_addr;
+	unsigned int words = buflen >> 1, i;
+	u16 *data_ptr = (u16 *)buf;
+
+	/* Requires wait same as in ata_inb/ata_outb */
+	if (rw == READ)
+		for (i = 0; i < words; i++, data_ptr++) {
+			wait_for_host_ready(info);
+			(void) readw(data_addr);
+			wait_for_host_ready(info);
+			*data_ptr = readw(info->ide_addr
+					+ S3C_ATA_PIO_RDATA);

drivers/ata/pata_samsung_cf.c line 274

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+		}
+	else
+		for (i = 0; i < words; i++, data_ptr++) {
+			wait_for_host_ready(info);
+			writew(*data_ptr, data_addr);
+		}
+
+	if (buflen & 0x01) {
+		dev_err(ap->dev, "unexpected trailing data\n");
+		return -EINVAL;

This method should return number of bytes consumed, never error...

Quoted 4 lines
drivers/ata/pata_samsung_cf.c new file +4 -0
+	}
+
+	return words << 1;
+}

[...]

drivers/ata/pata_samsung_cf.c line 303

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+/*
+ * pata_s3c_devchk - PATA device presence detection
+ */
+static unsigned int pata_s3c_devchk(struct ata_port *ap,
+				unsigned int device)
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+	u8 nsect, lbal;
+
+	ap->ops->sff_dev_select(ap, device);

Can call pata_s3c_dev_select() directly...

Quoted 16 lines
drivers/ata/pata_samsung_cf.c new file +16 -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 */
+	rc = ata_sff_wait_ready(link, deadline);

drivers/ata/pata_samsung_cf.c line 348

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+	if (rc)
+		return rc;
+
+	/* if device 1 was found in ata_devchk, wait for register
+	 * access briefly, then wait for BSY to clear.
+	 */
+	if (dev1) {
+		int i;
+
+		ap->ops->sff_dev_select(ap, 1);

Ditto.

Quoted 9 lines
drivers/ata/pata_samsung_cf.c new file +9 -0
+
+		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 */

drivers/ata/pata_samsung_cf.c line 367

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+		}
+
+		rc = ata_sff_wait_ready(link, deadline);
+		if (rc) {
+			if (rc != -ENODEV)
+				return rc;
+			ret = rc;
+		}
+	}
+

Should have copied the original commant here, cause I dount that this
drive selection trickery is indeed necessary...

drivers/ata/pata_samsung_cf.c line 372

Quoted 5 lines
drivers/ata/pata_samsung_cf.c new file +5 -0
+	ap->ops->sff_dev_select(ap, 0);
+	if (dev1)
+		ap->ops->sff_dev_select(ap, 1);
+	if (dev0)
+		ap->ops->sff_dev_select(ap, 0);

Ditto.

drivers/ata/pata_samsung_cf.c line 403

Quoted 8 lines
drivers/ata/pata_samsung_cf.c new file +8 -0
+/*
+ * pata_s3c_softreset - reset host port via ATA SRST
+ */
+static int pata_s3c_softreset(struct ata_link *link, unsigned int *classes,
+			 unsigned long deadline)
+{
+	struct ata_port *ap = link->ap;
+	unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;

I don't see where you set this flag, hence the check seems useless.

drivers/ata/pata_samsung_cf.c line 415

Quoted 12 lines
drivers/ata/pata_samsung_cf.c new file +12 -0
+	unsigned int devmask = 0;
+	int rc;
+	u8 err;
+
+	/* determine if device 0/1 are present */
+	if (pata_s3c_devchk(ap, 0))
+		devmask |= (1 << 0);
+	if (slave_possible && pata_s3c_devchk(ap, 1))
+		devmask |= (1 << 1);
+
+	/* select device 0 again */
+	ap->ops->sff_dev_select(ap, 0);

Can call pata_s3c_dev_select() directly...

drivers/ata/pata_samsung_cf.c line 420

Quoted 5 lines
drivers/ata/pata_samsung_cf.c new file +5 -0
+
+	/* issue bus reset */
+	rc = pata_s3c_bus_softreset(ap, devmask, deadline);
+	/* if link is occupied, -ENODEV too is an error */
+	if (rc && (rc != -ENODEV || sata_scr_valid(link))) {

sata_scr_valid() doesn't apply to your PATA driver, no need to call it.

Quoted 5 lines
drivers/ata/pata_samsung_cf.c new file +5 -0
+static void pata_s3c_hwinit(struct s3c_ide_info *info,
+				struct s3c_ide_platdata *pdata)
+{
+	switch (info->cpu_type) {
+	case TYPE_S3C64XX:

drivers/ata/pata_samsung_cf.c line 499

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+		/* Configure as big endian */
+		pata_s3c_cfg_mode(info->sfr_addr);
+		pata_s3c_set_endian(info->ide_addr, 1);
+		pata_s3c_enable(info->ide_addr, true);
+		msleep(100);
+
+		/* Remove IRQ Status */
+		writel(0x1f, info->ide_addr + S3C_ATA_IRQ);
+		writel(0x1b, info->ide_addr + S3C_ATA_IRQ_MSK);
+	break;

Mis-indented: one more tab needed.

drivers/ata/pata_samsung_cf.c line 502

Quoted 3 lines
drivers/ata/pata_samsung_cf.c new file +3 -0
+
+	case TYPE_S5PC100:
+		pata_s3c_cfg_mode(info->sfr_addr);

There should be a comment like /* FALLTHRU */ if *break* is omitted.

drivers/ata/pata_samsung_cf.c line 513

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+	case TYPE_S5PV210:
+		/* Configure as little endian */
+		pata_s3c_set_endian(info->ide_addr, 0);
+		pata_s3c_enable(info->ide_addr, true);
+		msleep(100);
+
+		/* Remove IRQ Status */
+		writel(0x3f, info->ide_addr + S3C_ATA_IRQ);
+		writel(0x3f, info->ide_addr + S3C_ATA_IRQ_MSK);
+	break;

Mis-indented.

Quoted 1 line

+static int __devinit pata_s3c_probe(struct platform_device *pdev)

Is this device really hot-pluggable? Shouldn't this be '__init' instead?

Quoted 11 lines
drivers/ata/pata_samsung_cf.c new file +11 -0
+{
+	struct s3c_ide_platdata *pdata = pdev->dev.platform_data;
+	struct device *dev = &pdev->dev;
+	struct s3c_ide_info *info;
+	struct resource *res;
+	struct ata_port *ap;
+	struct ata_host *host;
+	enum s3c_cpu_type cpu_type;
+	int ret;
+
+	cpu_type = platform_get_device_id(pdev)->driver_data;

drivers/ata/pata_samsung_cf.c line 541

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info) {
+		dev_err(dev, "failed to allocate memory for device data\n");
+		return -ENOMEM;
+	}
+
+	info->irq = platform_get_irq(pdev, 0);
+	if (info->irq < 0) {
+		dev_err(dev, "could not obtain irq number\n");

You driver permits working without IRQ -- why require an IRQ resource even
if there's no IRQ?

[...]

drivers/ata/pata_samsung_cf.c line 602

Quoted 1 line
drivers/ata/pata_samsung_cf.c new file +1 -0
+	if (!info->irq) {
    Should be (info->irq <= 0) instead, I think, with the above check removed.
Quoted 4 lines
drivers/ata/pata_samsung_cf.c new file +4 -0
+		ap->flags |= ATA_FLAG_PIO_POLLING;
+		ata_port_desc(ap, "no IRQ, using PIO polling\n");
+	}
+

[...]

drivers/ata/pata_samsung_cf.c line 707

Quoted 2 lines
drivers/ata/pata_samsung_cf.c new file +2 -0
+static struct platform_driver pata_s3c_driver = {
+	.probe		= pata_s3c_probe,

If this function will be '__init', this needs to be removed.

[...]

drivers/ata/pata_samsung_cf.c line 721

Quoted 3 lines
drivers/ata/pata_samsung_cf.c new file +3 -0
+static int __init pata_s3c_init(void)
+{
+	return platform_driver_register(&pata_s3c_driver);

I'd coinsider platform_driver_probe() -- this device doesn't seem to be
hot-pluggable...

MBR, Sergei

author
#11 lore raw

PATCH v4 1/1 libata: pata_samsung_cf: Add Samsung PATA controller driver

Quoted 3 lines · Sergei Shtylyov

Hello.

Hello :-)

Thanks for your review and comments.

Quoted 5 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 7 lines
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..aeb2825

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

[...]

drivers/ata/pata_samsung_cf.c

Quoted 2 lines
drivers/ata/pata_samsung_cf.c new file +2 -0
+static unsigned long
+pata_s3c_setup_timing(struct s3c_ide_info *info, const struct

ata_timing *ata)

Quoted 12 lines

drivers/ata/pata_samsung_cf.c line 80

Quoted 9 lines
drivers/ata/pata_samsung_cf.c new file +9 -0
+{
+	int t1;
+	int t2;
+	int t2i;
+	ulong piotime;
+
+	t1 = ata->setup;
+	t2 = ata->act8b;
+	t2i = ata->rec8b;

Could be initializers...

OK.

Quoted 6 lines

[...]

drivers/ata/pata_samsung_cf.c

Quoted 4 lines
drivers/ata/pata_samsung_cf.c new file +4 -0
+/*
+ * pata_s3c_data_xfer - Transfer data by PIO
+ */
+unsigned int pata_s3c_data_xfer(struct ata_device *dev, unsigned char

*buf,

Quoted 20 lines
Quoted 20 lines
drivers/ata/pata_samsung_cf.c new file +20 -0
+				unsigned int buflen, int rw)
+{
+	struct ata_port *ap = dev->link->ap;
+	struct s3c_ide_info *info = ap->host->private_data;
+	void __iomem *data_addr = ap->ioaddr.data_addr;
+	unsigned int words = buflen >> 1, i;
+	u16 *data_ptr = (u16 *)buf;
+
+	/* Requires wait same as in ata_inb/ata_outb */
+	if (rw == READ)
+		for (i = 0; i < words; i++, data_ptr++) {
+			wait_for_host_ready(info);
+			(void) readw(data_addr);
+			wait_for_host_ready(info);
+			*data_ptr = readw(info->ide_addr
+					+ S3C_ATA_PIO_RDATA);
+		}
+	else
+		for (i = 0; i < words; i++, data_ptr++) {
+			wait_for_host_ready(info);
Quoted 9 lines

drivers/ata/pata_samsung_cf.c line 274

Quoted 6 lines
drivers/ata/pata_samsung_cf.c new file +6 -0
+			writew(*data_ptr, data_addr);
+		}
+
+	if (buflen & 0x01) {
+		dev_err(ap->dev, "unexpected trailing data\n");
+		return -EINVAL;

This method should return number of bytes consumed, never error...

OK..will remove the invalid return.

Quoted 7 lines
Quoted 4 lines
drivers/ata/pata_samsung_cf.c new file +4 -0
+	}
+
+	return words << 1;
+}

[...]

Quoted 13 lines

drivers/ata/pata_samsung_cf.c line 303

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+/*
+ * pata_s3c_devchk - PATA device presence detection
+ */
+static unsigned int pata_s3c_devchk(struct ata_port *ap,
+				unsigned int device)
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+	u8 nsect, lbal;
+
+	ap->ops->sff_dev_select(ap, device);

Can call pata_s3c_dev_select() directly...

Will replace it throughout the file.

Quoted 2 lines
Quoted 2 lines

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

reset

Quoted 41 lines
Quoted 14 lines

+ */

drivers/ata/pata_samsung_cf.c new file +13 -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 */
+	rc = ata_sff_wait_ready(link, deadline);

drivers/ata/pata_samsung_cf.c line 348

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+	if (rc)
+		return rc;
+
+	/* if device 1 was found in ata_devchk, wait for register
+	 * access briefly, then wait for BSY to clear.
+	 */
+	if (dev1) {
+		int i;
+
+		ap->ops->sff_dev_select(ap, 1);

Ditto.

Quoted 14 lines
drivers/ata/pata_samsung_cf.c new file +14 -0
+
+		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) {
+			if (rc != -ENODEV)
Quoted 9 lines

drivers/ata/pata_samsung_cf.c line 367

Quoted 5 lines
drivers/ata/pata_samsung_cf.c new file +5 -0
+				return rc;
+			ret = rc;
+		}
+	}
+

Should have copied the original commant here, cause I dount that this
drive selection trickery is indeed necessary...

Will add comment.

Quoted 8 lines

drivers/ata/pata_samsung_cf.c line 372

Quoted 5 lines
drivers/ata/pata_samsung_cf.c new file +5 -0
+	ap->ops->sff_dev_select(ap, 0);
+	if (dev1)
+		ap->ops->sff_dev_select(ap, 1);
+	if (dev0)
+		ap->ops->sff_dev_select(ap, 0);

Ditto.

Quoted 4 lines

drivers/ata/pata_samsung_cf.c

Quoted 4 lines
drivers/ata/pata_samsung_cf.c new file +4 -0
+/*
+ * pata_s3c_softreset - reset host port via ATA SRST
+ */
+static int pata_s3c_softreset(struct ata_link *link, unsigned int

*classes,

Quoted 7 lines

drivers/ata/pata_samsung_cf.c line 403

Quoted 4 lines
drivers/ata/pata_samsung_cf.c new file +4 -0
+			 unsigned long deadline)
+{
+	struct ata_port *ap = link->ap;
+	unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;

I don't see where you set this flag, hence the check seems useless.

Will remove the checks associated with this flag.

Quoted 15 lines

drivers/ata/pata_samsung_cf.c line 415

Quoted 12 lines
drivers/ata/pata_samsung_cf.c new file +12 -0
+	unsigned int devmask = 0;
+	int rc;
+	u8 err;
+
+	/* determine if device 0/1 are present */
+	if (pata_s3c_devchk(ap, 0))
+		devmask |= (1 << 0);
+	if (slave_possible && pata_s3c_devchk(ap, 1))
+		devmask |= (1 << 1);
+
+	/* select device 0 again */
+	ap->ops->sff_dev_select(ap, 0);

Can call pata_s3c_dev_select() directly...

Quoted 7 lines

drivers/ata/pata_samsung_cf.c line 420

Quoted 5 lines
drivers/ata/pata_samsung_cf.c new file +5 -0
+
+	/* issue bus reset */
+	rc = pata_s3c_bus_softreset(ap, devmask, deadline);
+	/* if link is occupied, -ENODEV too is an error */
+	if (rc && (rc != -ENODEV || sata_scr_valid(link))) {

sata_scr_valid() doesn't apply to your PATA driver, no need to call

it.

Quoted 1 line

OK

Quoted 24 lines
Quoted 5 lines
drivers/ata/pata_samsung_cf.c new file +5 -0
+static void pata_s3c_hwinit(struct s3c_ide_info *info,
+				struct s3c_ide_platdata *pdata)
+{
+	switch (info->cpu_type) {
+	case TYPE_S3C64XX:

drivers/ata/pata_samsung_cf.c line 499

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+		/* Configure as big endian */
+		pata_s3c_cfg_mode(info->sfr_addr);
+		pata_s3c_set_endian(info->ide_addr, 1);
+		pata_s3c_enable(info->ide_addr, true);
+		msleep(100);
+
+		/* Remove IRQ Status */
+		writel(0x1f, info->ide_addr + S3C_ATA_IRQ);
+		writel(0x1b, info->ide_addr + S3C_ATA_IRQ_MSK);
+	break;

Mis-indented: one more tab needed.

drivers/ata/pata_samsung_cf.c line 502

Quoted 3 lines
drivers/ata/pata_samsung_cf.c new file +3 -0
+
+	case TYPE_S5PC100:
+		pata_s3c_cfg_mode(info->sfr_addr);

There should be a comment like /* FALLTHRU */ if *break* is omitted.

Quoted 13 lines

drivers/ata/pata_samsung_cf.c line 513

Quoted 10 lines
drivers/ata/pata_samsung_cf.c new file +10 -0
+	case TYPE_S5PV210:
+		/* Configure as little endian */
+		pata_s3c_set_endian(info->ide_addr, 0);
+		pata_s3c_enable(info->ide_addr, true);
+		msleep(100);
+
+		/* Remove IRQ Status */
+		writel(0x3f, info->ide_addr + S3C_ATA_IRQ);
+		writel(0x3f, info->ide_addr + S3C_ATA_IRQ_MSK);
+	break;

Mis-indented.

Will correct the indentation and add a fall through comment.

Quoted 3 lines
Quoted 1 line

+static int __devinit pata_s3c_probe(struct platform_device *pdev)

Is this device really hot-pluggable? Shouldn't this be '__init'

instead?

Quoted 1 line

No, it's not..will change to __init.

Quoted 15 lines
Quoted 15 lines
drivers/ata/pata_samsung_cf.c new file +15 -0
+{
+	struct s3c_ide_platdata *pdata = pdev->dev.platform_data;
+	struct device *dev = &pdev->dev;
+	struct s3c_ide_info *info;
+	struct resource *res;
+	struct ata_port *ap;
+	struct ata_host *host;
+	enum s3c_cpu_type cpu_type;
+	int ret;
+
+	cpu_type = platform_get_device_id(pdev)->driver_data;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info) {
+		dev_err(dev, "failed to allocate memory for device data\n");
Quoted 8 lines

drivers/ata/pata_samsung_cf.c line 541

Quoted 6 lines
drivers/ata/pata_samsung_cf.c new file +6 -0
+		return -ENOMEM;
+	}
+
+	info->irq = platform_get_irq(pdev, 0);
+	if (info->irq < 0) {
+		dev_err(dev, "could not obtain irq number\n");

You driver permits working without IRQ -- why require an IRQ resource

even

Quoted 2 lines

if there's no IRQ?

Will remove the check as driver can be used in polling mode.

Quoted 5 lines

[...]

drivers/ata/pata_samsung_cf.c line 602

Quoted 1 line
drivers/ata/pata_samsung_cf.c new file +1 -0
+	if (!info->irq) {
    Should be (info->irq <= 0) instead, I think, with the above check

removed.

Quoted 1 line

OK

Quoted 7 lines
Quoted 4 lines
drivers/ata/pata_samsung_cf.c new file +4 -0
+		ap->flags |= ATA_FLAG_PIO_POLLING;
+		ata_port_desc(ap, "no IRQ, using PIO polling\n");
+	}
+

[...]

Quoted 5 lines

drivers/ata/pata_samsung_cf.c line 707

Quoted 2 lines
drivers/ata/pata_samsung_cf.c new file +2 -0
+static struct platform_driver pata_s3c_driver = {
+	.probe		= pata_s3c_probe,

If this function will be '__init', this needs to be removed.

Will remove probe method and used platform_driver_probe().

Quoted 7 lines

[...]

drivers/ata/pata_samsung_cf.c line 721

Quoted 3 lines
drivers/ata/pata_samsung_cf.c new file +3 -0
+static int __init pata_s3c_init(void)
+{
+	return platform_driver_register(&pata_s3c_driver);

I'd coinsider platform_driver_probe() -- this device doesn't seem to

be

Quoted 2 lines

hot-pluggable...

Thanks. Will re-submit updated soon.

Thanks.

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