Skip to contentSkip to conversation

S3C: ide: Add Samsung S3C IDE controller driver

PATCH Superseded Thomas Abraham 2 participants 2 messages Oct 14, 2009

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 S3C: ide: Add Samsung S3C IDE controller driver

This patch adds Samsung S3C IDE controller driver. This driver supports PIO and UDMA modes of data transfer.

Note: This patch includes suggested changes by Jassi and Marc Zyngier. The UDMA support has also been added in this patch.

---
 arch/arm/plat-s3c/Makefile |    5 +-
 drivers/ide/Kconfig        |   22 ++-
 drivers/ide/ide-proc.c     |    1 +
 drivers/ide/s3c-ide.c      |  810 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/ide.h        |    2 +-
 5 files changed, 836 insertions(+), 4 deletions(-)
 create mode 100644 drivers/ide/s3c-ide.c
arch/arm/plat-s3c/Makefile +3 -2
index 3c09109..d34d411 100644
@@ -34,11 +34,12 @@ obj-$(CONFIG_HAVE_PWM)		+= pwm.o
 
 # devices
 
-obj-$(CONFIG_S3C_DEV_HSMMC)	+= dev-hsmmc.o
-obj-$(CONFIG_S3C_DEV_HSMMC1)	+= dev-hsmmc1.o
+#obj-$(CONFIG_S3C_DEV_HSMMC)	+= dev-hsmmc.o
+#obj-$(CONFIG_S3C_DEV_HSMMC1)	+= dev-hsmmc1.o
 obj-y				+= dev-i2c0.o
 obj-$(CONFIG_S3C_DEV_I2C1)	+= dev-i2c1.o
 obj-$(CONFIG_S3C_DEV_FB)	+= dev-fb.o
 obj-$(CONFIG_S3C_DEV_USB_HOST)	+= dev-usb.o
 obj-$(CONFIG_S3C_DEV_USB_HSOTG)	+= dev-usb-hsotg.o
 obj-$(CONFIG_S3C_DEV_NAND)	+= dev-nand.o
+obj-y				+= dev-onenand.o
drivers/ide/Kconfig +21 -1
index 9a5d0aa..f6a728f 100644
@@ -292,6 +292,26 @@ config BLK_DEV_IDEPNP
 	  would like the kernel to automatically detect and activate
 	  it, say Y here.
 
+config BLK_DEV_IDE_S3C
+        tristate "Samsung S3C IDE Controller"
+	depends on PLAT_S3C64XX
+        help
+          Say Y here if you want to support using CF controller on SMDK(Samsung)
+	  development board. It will be configured for true IDE mode.
+
+config BLK_DEV_IDE_S3C_PIO
+        bool "Use PIO Mode"
+        depends on (BLK_DEV_IDE_S3C && !BLK_DEV_IDE_S3C_UDMA)
+        select IDE_XFER_MODE
+        help
+          Say Y here if you want to support the DMA in PIO Mode.
+
+config BLK_DEV_IDE_S3C_UDMA
+        bool "Use UDMA Mode"
+        depends on BLK_DEV_IDE_S3C
+        help
+          Say Y here if you want to support the UDMA.
+
 config BLK_DEV_IDEDMA_SFF
 	bool
 
@@ -910,7 +930,7 @@ endif
 
 config BLK_DEV_IDEDMA
 	def_bool BLK_DEV_IDEDMA_SFF || \
-		 BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
+		 BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA || BLK_DEV_IDE_S3C_UDMA
 	select IDE_XFER_MODE
 
 endif # IDE
drivers/ide/ide-proc.c +1 -0
index 3242698..d18478f 100644
@@ -51,6 +51,7 @@ static int proc_ide_read_imodel
 	case ide_au1xxx:	name = "au1xxx";	break;
 	case ide_palm3710:      name = "palm3710";      break;
 	case ide_acorn:		name = "acorn";		break;
+	case ide_s3c: 		name = "s3c-ide";	break;
 	default:		name = "(unknown)";	break;
 	}
 	len = sprintf(page, "%s\n", name);
drivers/ide/s3c-ide.c new file +810 -0

810 lines not on this page · raw message

include/linux/ide.h +1 -1
index edc93a6..ff9eb0e 100644
@@ -164,7 +164,7 @@ enum {		ide_unknown,	ide_generic,	ide_pci,
 		ide_cmd640,	ide_dtc2278,	ide_ali14xx,
 		ide_qd65xx,	ide_umc8672,	ide_ht6560b,
 		ide_4drives,	ide_pmac,	ide_acorn,
-		ide_au1xxx,	ide_palm3710
+		ide_au1xxx,	ide_palm3710,	ide_s3c
 };
 
 typedef u8 hwif_chipset_t;
Signature · 1 line
1.5.3.4
#1 lore raw
Quoted 2 lines · Thomas Abraham
 drivers/ide/Kconfig        |   22 ++-
 drivers/ide/ide-proc.c     |    1 +

It'd be nice to include some mention of why this is using drivers/ide rather than libata (or to see the driver be a libata one).

arch/arm/plat-s3c/Makefile obj-$(CONFIG_HAVE_PWM) += pwm.o · line 38

Quoted 4 lines
arch/arm/plat-s3c/Makefile +2 -2
-obj-$(CONFIG_S3C_DEV_HSMMC)	+= dev-hsmmc.o
-obj-$(CONFIG_S3C_DEV_HSMMC1)	+= dev-hsmmc1.o
+#obj-$(CONFIG_S3C_DEV_HSMMC)	+= dev-hsmmc.o
+#obj-$(CONFIG_S3C_DEV_HSMMC1)	+= dev-hsmmc1.o

This is a bit surprising? If these should be removed they should probably just be removed rather than commented out.

drivers/ide/Kconfig config BLK_DEV_IDEPNP · line 301

Quoted 7 lines
drivers/ide/Kconfig +7 -0
+config BLK_DEV_IDE_S3C
+        tristate "Samsung S3C IDE Controller"
+	depends on PLAT_S3C64XX
+        help
+          Say Y here if you want to support using CF controller on SMDK(Samsung)
+	  development board. It will be configured for true IDE mode.
+

Is this really only for the SMDK development boards or can the driver also be used on other boards - if it's only for the SMDK boards the dependencies and probably Kconfig name should be updated. If the driver is usable on other boards then the description could use an update.

drivers/ide/Kconfig config BLK_DEV_IDEPNP

Quoted 13 lines
drivers/ide/Kconfig +12 -0
+config BLK_DEV_IDE_S3C_PIO
+        bool "Use PIO Mode"
+        depends on (BLK_DEV_IDE_S3C && !BLK_DEV_IDE_S3C_UDMA)
+        select IDE_XFER_MODE
+        help
+          Say Y here if you want to support the DMA in PIO Mode.
 
+config BLK_DEV_IDE_S3C_UDMA
+        bool "Use UDMA Mode"
+        depends on BLK_DEV_IDE_S3C
+        help
+          Say Y here if you want to support the UDMA.
+

Do these need to be selected at Kconfig time?

drivers/ide/s3c-ide.c line 95

Quoted 2 lines
drivers/ide/s3c-ide.c new file +2 -0
+/* IDE device instantiation */
+static struct s3c_ide_device s3c_ide_dev;

Any reason not to do this dynamically?

drivers/ide/s3c-ide.c line 98

Quoted 2 lines
drivers/ide/s3c-ide.c new file +2 -0
+#define ide_writel(dev, value, reg) writel(value, dev->regbase + (reg))
+#define ide_readl(dev, reg) readl(dev->regbase + (reg))

static inline functions are generally preferred - they give type safety and avoid nasty surprises with macros.

Quoted 7 lines
drivers/ide/s3c-ide.c new file +7 -0
+/*
+ * following are the ide_dma_ops functions implemented by the ide driver
+ */
+static int s3c_ide_dma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
+{
+	return 0;
+}

drivers/ide/s3c-ide.c line 439

Quoted 10 lines
drivers/ide/s3c-ide.c new file +9 -0
+
+static void s3c_ide_dma_host_set(ide_drive_t *drive, int on)
+{
+	return;
+}
 
+static int s3c_ide_dma_test_irq(ide_drive_t *drive)
+{
+	return 1;
+}

These all look suspicous, especially the latter one - I'd expect the functions to be omitted if they don't do anything.

drivers/ide/s3c-ide.c line 695

Quoted 6 lines
drivers/ide/s3c-ide.c new file +6 -0
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		dev_err(&pdev->dev, "could not obtain base address \
+					of controller\n");
+		return -ENODEV;
+	}

This split of the error message is going to include an awful lot of blank space in the middle of the message. In general it's best not to split strings like this to support grep - something like this would be better:

dev_err(&pdev->dev,

		        "could not obtain base address of controller\n");

or if you need to split things then use

     "part 1"
     "part 2"

drivers/ide/s3c-ide.c line 754

Quoted 11 lines
drivers/ide/s3c-ide.c new file +10 -0
+	host->irq_handler = s3c_irq_handler;
+	host->ports[0]->hwif_data = (void *)ide_dev;
+
+	ret = ide_host_register(host, &s3c_port_info, hws);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to register ide host\n");
+		goto dealloc_ide_host;
+	}
 
+	s3c_ide_dev.hwif = host->ports[0];
+	platform_set_drvdata(pdev, host);

I'd expect to see these come before the driver is registered to avoid something trying to use the driver before they are fully set up.

drivers/ide/s3c-ide.c line 755

Quoted 1 line
drivers/ide/s3c-ide.c new file +1 -0
+	printk(KERN_INFO "S3C IDE driver configured");

This should probably be removed.