Skip to contentSkip to conversation

Add Compact Flash driver for Samsung SoCs

PATCH New Kukjin Kim 7 participants 24 messages May 27, 2010 – Jun 3, 2010

Subsystems (4)
lore
Share & tools
lore

Kukjin Kim

author
#0 lore raw

PATCH 1/1 Add Compact Flash driver for Samsung SoCs

This patches add PATA driver for Samsung SoCs. And this enables support for Compact Flash interfacing with Samsung SoCs.

[PATCH 1/4] ARM: S3C64XX: Add support for Compact Flash driver on SMDK6410 [PATCH 2/4] ARM: S5PV210: Add support for Compact Flash driver on SMDKV210/SMDKC110 [PATCH 3/4] ARM: S5PC100: Add support for Compact Flash driver on SMDKC100 [PATCH 4/4] pata_samsung: Add Samsung PATA controller driver

author
#1 lore raw

PATCH 1/4 ARM: S3C64XX: Add support for Compact Flash driver on SMDK6410

From: Abhilash Kesavan <[email protected]>

Following is added for the CF-ATA driver:
- Platform data strucure definition and instantiation
- Platform device definition and enabling code
- Platform-specific gpio setup code
- CF controller register definitions

---
 arch/arm/mach-s3c64xx/Kconfig                   |    7 +++
 arch/arm/mach-s3c64xx/Makefile                  |    1 +
 arch/arm/mach-s3c64xx/clock.c                   |    6 +++
 arch/arm/mach-s3c64xx/include/mach/map.h        |    5 ++-
 arch/arm/mach-s3c64xx/include/mach/regs-clock.h |    5 ++
 arch/arm/mach-s3c64xx/mach-smdk6410.c           |    9 ++++
 arch/arm/mach-s3c64xx/s3c6410.c                 |    1 +
 arch/arm/mach-s3c64xx/setup-ide.c               |   55 ++++++++++++++++++++++
 arch/arm/plat-samsung/Kconfig                   |    5 ++
 arch/arm/plat-samsung/Makefile                  |    1 +
 arch/arm/plat-samsung/dev-ide.c                 |   52 +++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/ata.h        |   38 +++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h       |    1 +
 arch/arm/plat-samsung/include/plat/regs-ata.h   |   56 +++++++++++++++++++++++
 14 files changed, 241 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-s3c64xx/setup-ide.c
 create mode 100644 arch/arm/plat-samsung/dev-ide.c
 create mode 100644 arch/arm/plat-samsung/include/plat/ata.h
 create mode 100644 arch/arm/plat-samsung/include/plat/regs-ata.h
arch/arm/mach-s3c64xx/Kconfig +7 -0
index f5a5972..c00401e 100644
@@ -67,6 +67,11 @@ config S3C64XX_SETUP_SDHCI_GPIO
 	help
 	  Common setup code for S3C64XX SDHCI GPIO configurations
 
+config S3C64XX_SETUP_IDE
+	bool
+	help
+	  Common setup code for S3C64XX IDE.
+
 # S36400 Macchine support
 
 config MACH_SMDK6400
@@ -101,9 +106,11 @@ config MACH_SMDK6410
 	select S3C_DEV_USB_HSOTG
 	select S3C_DEV_WDT
 	select HAVE_S3C2410_WATCHDOG
+	select S3C_DEV_IDE
 	select S3C64XX_SETUP_SDHCI
 	select S3C64XX_SETUP_I2C1
 	select S3C64XX_SETUP_FB_24BPP
+	select S3C64XX_SETUP_IDE
 	help
 	  Machine support for the Samsung SMDK6410
 
arch/arm/mach-s3c64xx/Makefile +1 -0
index 9d10069..0d52c35 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_S3C64XX_SETUP_I2C1) += setup-i2c1.o
 obj-$(CONFIG_S3C64XX_SETUP_SDHCI) += setup-sdhci.o
 obj-$(CONFIG_S3C64XX_SETUP_FB_24BPP) += setup-fb-24bpp.o
 obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
+obj-$(CONFIG_S3C64XX_SETUP_IDE) += setup-ide.o
 
 # PM
 
arch/arm/mach-s3c64xx/clock.c +6 -0
index 7a4138b..9dac5c4 100644
@@ -304,6 +304,12 @@ static struct clk init_clocks[] = {
 		.id		= -1,
 		.parent		= &clk_p,
 		.ctrlbit	= S3C_CLKCON_PCLK_AC97,
+	}, {
+		.name		= "cfcon",
+		.id		= -1,
+		.parent		= &clk_h,
+		.enable		= s3c64xx_hclk_ctrl,
+		.ctrlbit	= S3C_CLKCON_HCLK_IHOST,
 	}
 };
 
arch/arm/mach-s3c64xx/include/mach/map.h +4 -1
index e1eab3c..4b1ac79 100644
@@ -86,6 +86,9 @@
 #define S3C64XX_SZ_GPIO		SZ_4K
 
 #define S3C64XX_PA_SDRAM	(0x50000000)
+
+#define S3C64XX_PA_CFCON	(0x70300000)
+
 #define S3C64XX_PA_VIC0		(0x71200000)
 #define S3C64XX_PA_VIC1		(0x71300000)
 
@@ -118,7 +121,7 @@
 #define S3C_VA_USB_HSPHY	S3C64XX_VA_USB_HSPHY
 #define S3C_PA_RTC		S3C64XX_PA_RTC
 #define S3C_PA_WDT		S3C64XX_PA_WATCHDOG
-
+#define SAMSUNG_PA_CFCON	S3C64XX_PA_CFCON
 #define SAMSUNG_PA_ADC		S3C64XX_PA_ADC
 
 #endif /* __ASM_ARCH_6400_MAP_H */
arch/arm/mach-s3c64xx/include/mach/regs-clock.h +5 -0
index 0114eb0..05332b9 100644
@@ -34,6 +34,7 @@
 #define S3C_SCLK_GATE		S3C_CLKREG(0x38)
 #define S3C_MEM0_GATE		S3C_CLKREG(0x3C)
 #define S3C6410_CLK_SRC2	S3C_CLKREG(0x10C)
+#define S3C_MEM_SYS_CFG		S3C_CLKREG(0x120)
 
 /* CLKDIV0 */
 #define S3C6400_CLKDIV0_PCLK_MASK	(0xf << 12)
@@ -154,4 +155,8 @@
 #define S3C6400_CLKSRC_EPLL_MOUT_SHIFT	(2)
 #define S3C6400_CLKSRC_MFC		(1 << 4)
 
+/* MEM_SYS_CFG */
+#define MEM_SYS_CFG_INDEP_CF		0x4000
+#define MEM_SYS_CFG_EBI_FIX_PRI_CFCON	0x30
+
 #endif /* _PLAT_REGS_CLOCK_H */
arch/arm/mach-s3c64xx/mach-smdk6410.c +9 -0
index d9a0355..cc1bb0f 100644
@@ -56,6 +56,7 @@
 #include <mach/regs-gpio.h>
 #include <mach/regs-sys.h>
 #include <mach/regs-srom.h>
+#include <plat/ata.h>
 #include <plat/iic.h>
 #include <plat/fb.h>
 #include <plat/gpio-cfg.h>
@@ -242,6 +243,11 @@ static struct platform_device smdk6410_b_pwr_5v = {
 };
 #endif
 
+static struct s3c_ide_platdata smdk6410_ide_pdata __initdata = {
+	.setup_gpio	= s3c_ide_setup_gpio,
+	.cfg_mode	= s3c_ide_cfg_mode,
+};
+
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
@@ -267,6 +273,7 @@ static struct platform_device *smdk6410_devices[] __initdata = {
 	&s3c_device_adc,
 	&s3c_device_ts,
 	&s3c_device_wdt,
+	&s3c_device_cfcon,
 };
 
 #ifdef CONFIG_REGULATOR
@@ -665,6 +672,8 @@ static void __init smdk6410_machine_init(void)
 	i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
 	i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
 
+	s3c_ide_set_platdata(&smdk6410_ide_pdata);
+
 	platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices));
 }
 
arch/arm/mach-s3c64xx/s3c6410.c +1 -0
index 014401c..1d1dce4 100644
@@ -58,6 +58,7 @@ void __init s3c6410_map_io(void)
 	s3c_device_nand.name = "s3c6400-nand";
 	s3c_onenand_setname("s3c6410-onenand");
 	s3c64xx_onenand1_setname("s3c6410-onenand");
+	s3c_device_cfcon.name = "s3c6400-pata";
 }
 
 void __init s3c6410_init_clocks(int xtal)
arch/arm/mach-s3c64xx/setup-ide.c new file +55 -0

55 lines not on this page · raw message

arch/arm/plat-samsung/Kconfig +5 -0
index 2753fb3..6ec97fe 100644
@@ -175,6 +175,11 @@ config S3C_DEV_I2C2
 	help
 	  Compile in platform device definitions for I2C channel 2
 
+config S3C_DEV_IDE
+	bool
+	help
+	  Compile in platform device definitions for IDE
+
 config S3C_DEV_FB
 	bool
 	help
arch/arm/plat-samsung/Makefile +1 -0
index b1d82cc..252fc76 100644
@@ -48,6 +48,7 @@ obj-$(CONFIG_S3C_DEV_RTC)	+= dev-rtc.o
 
 obj-$(CONFIG_SAMSUNG_DEV_ADC)	+= dev-adc.o
 obj-$(CONFIG_SAMSUNG_DEV_TS)	+= dev-ts.o
+obj-$(CONFIG_S3C_DEV_IDE)	+= dev-ide.o
 
 # DMA support
 
arch/arm/plat-samsung/dev-ide.c new file +52 -0

52 lines not on this page · raw message

arch/arm/plat-samsung/include/plat/ata.h new file +38 -0
new file mode 100644
index 0000000..aea11dc
@@ -0,0 +1,38 @@
+/* arch/arm/plat-samsung/include/plat/ata.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * S3C - CF Controller platform_device info
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_PLAT_ATA_H
+#define __ASM_PLAT_ATA_H __FILE__
+
+/**
+ * struct s3c_ide_platdata - S3C IDE driver platform data.
+ * @setup_gpio: Setup the external GPIO pins to the right state for data
+ * transfer in true-ide mode.
+ * @cfg_mode: Platform specific setup for configuring the CF controller
+ * in true-ide mode.
+ */
+struct s3c_ide_platdata {
+	void (*setup_gpio)(void);
+	void (*cfg_mode)(void __iomem *sfrbase);
+};
+
+/*
+ * s3c_ide_set_platdata() - Setup the platform specifc data for IDE driver.
+ * @pdata: Platform data for IDE driver.
+ */
+extern void s3c_ide_set_platdata(struct s3c_ide_platdata *pdata);
+
+/* architecture-specific IDE configuration */
+extern void s3c_ide_setup_gpio(void);
+extern void s3c_ide_cfg_mode(void __iomem *sfrbase);
+
+#endif /*__ASM_PLAT_ATA_H */
arch/arm/plat-samsung/include/plat/devs.h +1 -0
index e6144e4..e3fcddb 100644
@@ -75,6 +75,7 @@ extern struct platform_device s5pc110_device_onenand;
 
 extern struct platform_device s3c_device_usbgadget;
 extern struct platform_device s3c_device_usb_hsotg;
+extern struct platform_device s3c_device_cfcon;
 
 extern struct platform_device s5pv210_device_ac97;
 extern struct platform_device s5pv210_device_pcm0;
arch/arm/plat-samsung/include/plat/regs-ata.h new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#2 lore raw

PATCH 1/4 ARM: S3C64XX: Add support for Compact Flash driver on SMDK6410

Quoted 11 lines · Kukjin Kim

From: Abhilash Kesavan <[email protected]>

Following is added for the CF-ATA driver:
- Platform data strucure definition and instantiation
- Platform device definition and enabling code
- Platform-specific gpio setup code
- CF controller register definitions

Quoted 15 lines
---
 arch/arm/mach-s3c64xx/Kconfig                   |    7 +++
 arch/arm/mach-s3c64xx/Makefile                  |    1 +
 arch/arm/mach-s3c64xx/clock.c                   |    6 +++
 arch/arm/mach-s3c64xx/include/mach/map.h        |    5 ++-
 arch/arm/mach-s3c64xx/include/mach/regs-clock.h |    5 ++
 arch/arm/mach-s3c64xx/mach-smdk6410.c           |    9 ++++
 arch/arm/mach-s3c64xx/s3c6410.c                 |    1 +
 arch/arm/mach-s3c64xx/setup-ide.c               |   55 ++++++++++++++++++++++
 arch/arm/plat-samsung/Kconfig                   |    5 ++
 arch/arm/plat-samsung/Makefile                  |    1 +
 arch/arm/plat-samsung/dev-ide.c                 |   52 +++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/ata.h        |   38 +++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h       |    1 +
 arch/arm/plat-samsung/include/plat/regs-ata.h   |   56 +++++++++++++++++++++++

it would have been useful to keep the plat-samsung changes seperate.

Quoted 120 lines
 14 files changed, 241 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-s3c64xx/setup-ide.c
 create mode 100644 arch/arm/plat-samsung/dev-ide.c
 create mode 100644 arch/arm/plat-samsung/include/plat/ata.h
 create mode 100644 arch/arm/plat-samsung/include/plat/regs-ata.h
arch/arm/mach-s3c64xx/Kconfig +7 -0
index f5a5972..c00401e 100644
@@ -67,6 +67,11 @@ config S3C64XX_SETUP_SDHCI_GPIO
 	help
 	  Common setup code for S3C64XX SDHCI GPIO configurations
 
+config S3C64XX_SETUP_IDE
+	bool
+	help
+	  Common setup code for S3C64XX IDE.
+
 # S36400 Macchine support
 
 config MACH_SMDK6400
@@ -101,9 +106,11 @@ config MACH_SMDK6410
 	select S3C_DEV_USB_HSOTG
 	select S3C_DEV_WDT
 	select HAVE_S3C2410_WATCHDOG
+	select S3C_DEV_IDE
 	select S3C64XX_SETUP_SDHCI
 	select S3C64XX_SETUP_I2C1
 	select S3C64XX_SETUP_FB_24BPP
+	select S3C64XX_SETUP_IDE
 	help
 	  Machine support for the Samsung SMDK6410
 
arch/arm/mach-s3c64xx/Makefile +1 -0
index 9d10069..0d52c35 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_S3C64XX_SETUP_I2C1) += setup-i2c1.o
 obj-$(CONFIG_S3C64XX_SETUP_SDHCI) += setup-sdhci.o
 obj-$(CONFIG_S3C64XX_SETUP_FB_24BPP) += setup-fb-24bpp.o
 obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
+obj-$(CONFIG_S3C64XX_SETUP_IDE) += setup-ide.o
 
 # PM
 
arch/arm/mach-s3c64xx/clock.c +6 -0
index 7a4138b..9dac5c4 100644
@@ -304,6 +304,12 @@ static struct clk init_clocks[] = {
 		.id		= -1,
 		.parent		= &clk_p,
 		.ctrlbit	= S3C_CLKCON_PCLK_AC97,
+	}, {
+		.name		= "cfcon",
+		.id		= -1,
+		.parent		= &clk_h,
+		.enable		= s3c64xx_hclk_ctrl,
+		.ctrlbit	= S3C_CLKCON_HCLK_IHOST,
 	}
 };
 
arch/arm/mach-s3c64xx/include/mach/map.h +4 -1
index e1eab3c..4b1ac79 100644
@@ -86,6 +86,9 @@
 #define S3C64XX_SZ_GPIO		SZ_4K
 
 #define S3C64XX_PA_SDRAM	(0x50000000)
+
+#define S3C64XX_PA_CFCON	(0x70300000)
+
 #define S3C64XX_PA_VIC0		(0x71200000)
 #define S3C64XX_PA_VIC1		(0x71300000)
 
@@ -118,7 +121,7 @@
 #define S3C_VA_USB_HSPHY	S3C64XX_VA_USB_HSPHY
 #define S3C_PA_RTC		S3C64XX_PA_RTC
 #define S3C_PA_WDT		S3C64XX_PA_WATCHDOG
-
+#define SAMSUNG_PA_CFCON	S3C64XX_PA_CFCON
 #define SAMSUNG_PA_ADC		S3C64XX_PA_ADC
 
 #endif /* __ASM_ARCH_6400_MAP_H */
arch/arm/mach-s3c64xx/include/mach/regs-clock.h +5 -0
index 0114eb0..05332b9 100644
@@ -34,6 +34,7 @@
 #define S3C_SCLK_GATE		S3C_CLKREG(0x38)
 #define S3C_MEM0_GATE		S3C_CLKREG(0x3C)
 #define S3C6410_CLK_SRC2	S3C_CLKREG(0x10C)
+#define S3C_MEM_SYS_CFG		S3C_CLKREG(0x120)
 
 /* CLKDIV0 */
 #define S3C6400_CLKDIV0_PCLK_MASK	(0xf << 12)
@@ -154,4 +155,8 @@
 #define S3C6400_CLKSRC_EPLL_MOUT_SHIFT	(2)
 #define S3C6400_CLKSRC_MFC		(1 << 4)
 
+/* MEM_SYS_CFG */
+#define MEM_SYS_CFG_INDEP_CF		0x4000
+#define MEM_SYS_CFG_EBI_FIX_PRI_CFCON	0x30
+
 #endif /* _PLAT_REGS_CLOCK_H */
arch/arm/mach-s3c64xx/mach-smdk6410.c +1 -0
index d9a0355..cc1bb0f 100644
@@ -56,6 +56,7 @@
 #include <mach/regs-gpio.h>
 #include <mach/regs-sys.h>
 #include <mach/regs-srom.h>
+#include <plat/ata.h>
 #include <plat/iic.h>
 #include <plat/fb.h>
 #include <plat/gpio-cfg.h>

arch/arm/mach-s3c64xx/mach-smdk6410.c static struct platform_device smdk6410_b_pwr_5v = { · line 248

Quoted 6 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +3 -0
@@ -242,6 +243,11 @@ static struct platform_device smdk6410_b_pwr_5v = {
 };
 #endif
 
+static struct s3c_ide_platdata smdk6410_ide_pdata __initdata = {
+	.setup_gpio	= s3c_ide_setup_gpio,
+	.cfg_mode	= s3c_ide_cfg_mode,

These should have been called s3c64xx_ide...

I'll have a think about what we should be doing with this, it might be wroth passing this via the archdata and leaving the platform data for the board. If these configs are generally going to be per SoC then i'd prefer to see this in the archdata and once per SoC.

Quoted 27 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +5 -0
+};
+
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
@@ -267,6 +273,7 @@ static struct platform_device *smdk6410_devices[] __initdata = {
 	&s3c_device_adc,
 	&s3c_device_ts,
 	&s3c_device_wdt,
+	&s3c_device_cfcon,
 };
 
 #ifdef CONFIG_REGULATOR
@@ -665,6 +672,8 @@ static void __init smdk6410_machine_init(void)
 	i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
 	i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
 
+	s3c_ide_set_platdata(&smdk6410_ide_pdata);
+
 	platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices));
 }
 
arch/arm/mach-s3c64xx/s3c6410.c +0 -0
index 014401c..1d1dce4 100644

arch/arm/mach-s3c64xx/s3c6410.c void __init s3c6410_map_io(void) · line 62

Quoted 5 lines
arch/arm/mach-s3c64xx/s3c6410.c +1 -0
@@ -58,6 +58,7 @@ void __init s3c6410_map_io(void)
 	s3c_device_nand.name = "s3c6400-nand";
 	s3c_onenand_setname("s3c6410-onenand");
 	s3c64xx_onenand1_setname("s3c6410-onenand");
+	s3c_device_cfcon.name = "s3c6400-pata";
 }

let's get this sorted out and use one method. see Kyungmin Park's prev. comments on the subject.

Quoted 44 lines
arch/arm/mach-s3c64xx/s3c6410.c +0 -0
 void __init s3c6410_init_clocks(int xtal)
arch/arm/mach-s3c64xx/setup-ide.c new file +37 -0
new file mode 100644
index 0000000..0bf4e5e
@@ -0,0 +1,55 @@
+/* linux/arch/arm/mach-s3c64xx/setup-ide.c
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com/
+ *
+ * S3C64XX setup information for IDE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/io.h>
+
+#include <mach/map.h>
+#include <mach/gpio.h>
+#include <mach/regs-clock.h>
+#include <plat/gpio-cfg.h>
+#include <plat/regs-ata.h>
+
+void s3c_ide_setup_gpio(void)
+{
+	u32 reg;
+	u32 gpio = 0;
+
+	reg = __raw_readl(S3C_MEM_SYS_CFG) & (~0x3f);
+
+	/* Independent CF interface, CF chip select configuration */
+	__raw_writel(reg | MEM_SYS_CFG_INDEP_CF |
+		MEM_SYS_CFG_EBI_FIX_PRI_CFCON, S3C_MEM_SYS_CFG);
+
+	s3c_gpio_cfgpin(S3C64XX_GPB(4), S3C_GPIO_SFN(4));
+
+	/* Set XhiDATA[15:0] pins as CF Data[15:0] */
+	for (gpio = S3C64XX_GPK(0); gpio <= S3C64XX_GPK(15); gpio++)

arch/arm/mach-s3c64xx/setup-ide.c line 47

Quoted 10 lines
arch/arm/mach-s3c64xx/setup-ide.c new file +10 -0
+		s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(5));
+
+	/* Set XhiADDR[2:0] pins as CF ADDR[2:0] */
+	for (gpio = S3C64XX_GPL(0); gpio <= S3C64XX_GPL(2); gpio++)
+		s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(6));
+
+	/* Set Xhi ctrl pins as CF ctrl pins(IORDY, IOWR, IORD, CE[0:1]) */
+	s3c_gpio_cfgpin(S3C64XX_GPM(5), S3C_GPIO_SFN(1));
+	for (gpio = S3C64XX_GPM(0); gpio <= S3C64XX_GPM(4); gpio++)
+		s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(6));

i'll update this to the cfgrange when merging the cfgrange code.

arch/arm/mach-s3c64xx/setup-ide.c line 55

Quoted 8 lines
arch/arm/mach-s3c64xx/setup-ide.c new file +8 -0
+}
+
+void s3c_ide_cfg_mode(void __iomem *sfrbase)
+{
+	/* Select true-ide as the internal operating mode*/
+	writel(readl(sfrbase + S3C_CFATA_MUX) | S3C_CFATA_MUX_TRUEIDE,
+						sfrbase + S3C_CFATA_MUX);
+}

maybe we just put this in the driver and select on type.

Quoted 43 lines
arch/arm/plat-samsung/Kconfig +5 -0
index 2753fb3..6ec97fe 100644
@@ -175,6 +175,11 @@ config S3C_DEV_I2C2
 	help
 	  Compile in platform device definitions for I2C channel 2
 
+config S3C_DEV_IDE
+	bool
+	help
+	  Compile in platform device definitions for IDE
+
 config S3C_DEV_FB
 	bool
 	help
arch/arm/plat-samsung/Makefile +1 -0
index b1d82cc..252fc76 100644
@@ -48,6 +48,7 @@ obj-$(CONFIG_S3C_DEV_RTC)	+= dev-rtc.o
 
 obj-$(CONFIG_SAMSUNG_DEV_ADC)	+= dev-adc.o
 obj-$(CONFIG_SAMSUNG_DEV_TS)	+= dev-ts.o
+obj-$(CONFIG_S3C_DEV_IDE)	+= dev-ide.o
 
 # DMA support
 
arch/arm/plat-samsung/dev-ide.c new file +9 -0
new file mode 100644
index 0000000..c6b3292
@@ -0,0 +1,52 @@
+/* linux/arch/arm/plat-samsung/dev-ide.c
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * S3C CF-ATA device definition.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as

arch/arm/plat-samsung/dev-ide.c line 19

Quoted 10 lines
arch/arm/plat-samsung/dev-ide.c new file +10 -0
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <mach/map.h>
+#include <plat/ata.h>

do we need linux/io.h in here?

soem spacing inebtwee nthe include groups would be nice too,.

arch/arm/plat-samsung/dev-ide.c line 25

Quoted 5 lines
arch/arm/plat-samsung/dev-ide.c new file +5 -0
+static struct resource s3c_cfcon_resource[] = {
+	[0] = {
+		.start	= SAMSUNG_PA_CFCON,
+		.end	= SAMSUNG_PA_CFCON + SZ_1M - 1,
+		.flags	= IORESOURCE_MEM,

do we really need to map SZ_1M?

arch/arm/plat-samsung/dev-ide.c line 35

Quoted 10 lines
arch/arm/plat-samsung/dev-ide.c new file +10 -0
+	},
+	[1] = {
+		.start	= IRQ_CFCON,
+		.end	= IRQ_CFCON,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device s3c_device_cfcon = {
+	.name		= "s3c-pata",

if the name is going to change, let's simply not bother setting one here.

arch/arm/plat-samsung/dev-ide.c line 45

Quoted 10 lines
arch/arm/plat-samsung/dev-ide.c new file +9 -0
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(s3c_cfcon_resource),
+	.resource	= s3c_cfcon_resource,
+};
 
+void s3c_ide_set_platdata(struct s3c_ide_platdata *pdata)
+{
+	struct s3c_ide_platdata *pd;
+
+	pd = (struct s3c_ide_platdata *)kmemdup(pdata,

^^^^^ not needed.

Quoted 128 lines
arch/arm/plat-samsung/dev-ide.c new file +7 -0
+		sizeof(struct s3c_ide_platdata), GFP_KERNEL);
+	if (!pd) {
+		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
+		return;
+	}
+	s3c_device_cfcon.dev.platform_data = pd;
+}
arch/arm/plat-samsung/include/plat/ata.h new file +38 -0
new file mode 100644
index 0000000..aea11dc
@@ -0,0 +1,38 @@
+/* arch/arm/plat-samsung/include/plat/ata.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * S3C - CF Controller platform_device info
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_PLAT_ATA_H
+#define __ASM_PLAT_ATA_H __FILE__
+
+/**
+ * struct s3c_ide_platdata - S3C IDE driver platform data.
+ * @setup_gpio: Setup the external GPIO pins to the right state for data
+ * transfer in true-ide mode.
+ * @cfg_mode: Platform specific setup for configuring the CF controller
+ * in true-ide mode.
+ */
+struct s3c_ide_platdata {
+	void (*setup_gpio)(void);
+	void (*cfg_mode)(void __iomem *sfrbase);
+};
+
+/*
+ * s3c_ide_set_platdata() - Setup the platform specifc data for IDE driver.
+ * @pdata: Platform data for IDE driver.
+ */
+extern void s3c_ide_set_platdata(struct s3c_ide_platdata *pdata);
+
+/* architecture-specific IDE configuration */
+extern void s3c_ide_setup_gpio(void);
+extern void s3c_ide_cfg_mode(void __iomem *sfrbase);
+
+#endif /*__ASM_PLAT_ATA_H */
arch/arm/plat-samsung/include/plat/devs.h +1 -0
index e6144e4..e3fcddb 100644
@@ -75,6 +75,7 @@ extern struct platform_device s5pc110_device_onenand;
 
 extern struct platform_device s3c_device_usbgadget;
 extern struct platform_device s3c_device_usb_hsotg;
+extern struct platform_device s3c_device_cfcon;
 
 extern struct platform_device s5pv210_device_ac97;
 extern struct platform_device s5pv210_device_pcm0;
arch/arm/plat-samsung/include/plat/regs-ata.h new file +56 -0
new file mode 100644
index 0000000..f73b267
@@ -0,0 +1,56 @@
+/* arch/arm/plat-samsung/include/plat/regs-ata.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * S3C CF-ATA register definitions
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_PLAT_REGS_ATA_H
+#define __ASM_PLAT_REGS_ATA_H __FILE__
+
+#define S3C_CFATA_REG(x)	(x)
+
+#define S3C_CFATA_MUX		S3C_CFATA_REG(0x0)
+
+#define S3C_ATA_CTRL		S3C_CFATA_REG(0x0)
+#define S3C_ATA_STATUS		S3C_CFATA_REG(0x4)
+#define S3C_ATA_CMD		S3C_CFATA_REG(0x8)
+#define S3C_ATA_SWRST		S3C_CFATA_REG(0xc)
+#define S3C_ATA_IRQ		S3C_CFATA_REG(0x10)
+#define S3C_ATA_IRQ_MSK		S3C_CFATA_REG(0x14)
+#define S3C_ATA_CFG		S3C_CFATA_REG(0x18)
+
+#define S3C_ATA_MDMA_TIME	S3C_CFATA_REG(0x28)
+#define S3C_ATA_PIO_TIME	S3C_CFATA_REG(0x2c)
+#define S3C_ATA_UDMA_TIME	S3C_CFATA_REG(0x30)
+#define S3C_ATA_XFR_NUM		S3C_CFATA_REG(0x34)
+#define S3C_ATA_XFR_CNT		S3C_CFATA_REG(0x38)
+#define S3C_ATA_TBUF_START	S3C_CFATA_REG(0x3c)
+#define S3C_ATA_TBUF_SIZE	S3C_CFATA_REG(0x40)
+#define S3C_ATA_SBUF_START	S3C_CFATA_REG(0x44)
+#define S3C_ATA_SBUF_SIZE	S3C_CFATA_REG(0x48)
+#define S3C_ATA_CADR_TBUF	S3C_CFATA_REG(0x4c)
+#define S3C_ATA_CADR_SBUF	S3C_CFATA_REG(0x50)
+#define S3C_ATA_PIO_DTR		S3C_CFATA_REG(0x54)
+#define S3C_ATA_PIO_FED		S3C_CFATA_REG(0x58)
+#define S3C_ATA_PIO_SCR		S3C_CFATA_REG(0x5c)
+#define S3C_ATA_PIO_LLR		S3C_CFATA_REG(0x60)
+#define S3C_ATA_PIO_LMR		S3C_CFATA_REG(0x64)
+#define S3C_ATA_PIO_LHR		S3C_CFATA_REG(0x68)
+#define S3C_ATA_PIO_DVR		S3C_CFATA_REG(0x6c)
+#define S3C_ATA_PIO_CSD		S3C_CFATA_REG(0x70)
+#define S3C_ATA_PIO_DAD		S3C_CFATA_REG(0x74)
+#define S3C_ATA_PIO_READY	S3C_CFATA_REG(0x78)
+#define S3C_ATA_PIO_RDATA	S3C_CFATA_REG(0x7c)
+
+#define S3C_CFATA_MUX_TRUEIDE	0x01
+
+#define S3C_ATA_CFG_SWAP	0x40
+#define S3C_ATA_CFG_IORDYEN	0x02
+
+#endif /* __ASM_PLAT_REGS_ATA_H */
Signature · 1 line
1.6.2.5
Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#3 lore raw

PATCH 1/4 ARM: S3C64XX: Add support for Compact Flash driver on SMDK6410

Hello,

Quoted 200 lines · Ben Dooks
Quoted 11 lines · Kukjin Kim

From: Abhilash Kesavan <[email protected]>

Following is added for the CF-ATA driver:
- Platform data strucure definition and instantiation
- Platform device definition and enabling code
- Platform-specific gpio setup code
- CF controller register definitions

Quoted 9 lines
---
 arch/arm/mach-s3c64xx/Kconfig                   |    7 +++
 arch/arm/mach-s3c64xx/Makefile                  |    1 +
 arch/arm/mach-s3c64xx/clock.c                   |    6 +++
 arch/arm/mach-s3c64xx/include/mach/map.h        |    5 ++-
 arch/arm/mach-s3c64xx/include/mach/regs-clock.h |    5 ++
 arch/arm/mach-s3c64xx/mach-smdk6410.c           |    9 ++++
 arch/arm/mach-s3c64xx/s3c6410.c                 |    1 +
 arch/arm/mach-s3c64xx/setup-ide.c               |   55

++++++++++++++++++++++

Quoted 3 lines
 arch/arm/plat-samsung/Kconfig                   |    5 ++
 arch/arm/plat-samsung/Makefile                  |    1 +
 arch/arm/plat-samsung/dev-ide.c                 |   52

+++++++++++++++++++++

Quoted 3 lines
 arch/arm/plat-samsung/include/plat/ata.h        |   38 +++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h       |    1 +
 arch/arm/plat-samsung/include/plat/regs-ata.h   |   56

+++++++++++++++++++++++

it would have been useful to keep the plat-samsung changes seperate.

arch/arm/mach-

Quoted 7 lines
 14 files changed, 241 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-s3c64xx/setup-ide.c
 create mode 100644 arch/arm/plat-samsung/dev-ide.c
 create mode 100644 arch/arm/plat-samsung/include/plat/ata.h
 create mode 100644 arch/arm/plat-samsung/include/plat/regs-ata.h
arch/arm/mach- renamed from arch/arm/mach-s3c64xx/Kconfig +0 -0

s3c64xx/Kconfig

arch/arm/mach-

Quoted 28 lines

index f5a5972..c00401e 100644

arch/arm/mach-s3c64xx/Kconfig +7 -0
@@ -67,6 +67,11 @@ config S3C64XX_SETUP_SDHCI_GPIO
 	help
 	  Common setup code for S3C64XX SDHCI GPIO configurations
 
+config S3C64XX_SETUP_IDE
+	bool
+	help
+	  Common setup code for S3C64XX IDE.
+
 # S36400 Macchine support
 
 config MACH_SMDK6400
@@ -101,9 +106,11 @@ config MACH_SMDK6410
 	select S3C_DEV_USB_HSOTG
 	select S3C_DEV_WDT
 	select HAVE_S3C2410_WATCHDOG
+	select S3C_DEV_IDE
 	select S3C64XX_SETUP_SDHCI
 	select S3C64XX_SETUP_I2C1
 	select S3C64XX_SETUP_FB_24BPP
+	select S3C64XX_SETUP_IDE
 	help
 	  Machine support for the Samsung SMDK6410
 
arch/arm/mach- renamed from arch/arm/mach-s3c64xx/Makefile +0 -0

s3c64xx/Makefile

arch/arm/mach-

Quoted 12 lines

index 9d10069..0d52c35 100644

arch/arm/mach-s3c64xx/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_S3C64XX_SETUP_I2C1) += setup-i2c1.o
 obj-$(CONFIG_S3C64XX_SETUP_SDHCI) += setup-sdhci.o
 obj-$(CONFIG_S3C64XX_SETUP_FB_24BPP) += setup-fb-24bpp.o
 obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
+obj-$(CONFIG_S3C64XX_SETUP_IDE) += setup-ide.o
 
 # PM
 
arch/arm/mach- renamed from arch/arm/mach-s3c64xx/clock.c +0 -0

s3c64xx/clock.c

arch/arm/mach-

Quoted 17 lines

index 7a4138b..9dac5c4 100644

arch/arm/mach-s3c64xx/clock.c +6 -0
@@ -304,6 +304,12 @@ static struct clk init_clocks[] = {
 		.id		= -1,
 		.parent		= &clk_p,
 		.ctrlbit	= S3C_CLKCON_PCLK_AC97,
+	}, {
+		.name		= "cfcon",
+		.id		= -1,
+		.parent		= &clk_h,
+		.enable		= s3c64xx_hclk_ctrl,
+		.ctrlbit	= S3C_CLKCON_HCLK_IHOST,
 	}
 };
 
arch/arm/mach- renamed from arch/arm/mach-s3c64xx/include/mach/map.h +0 -0

s3c64xx/include/mach/map.h

Review

Quoted 23 lines

index e1eab3c..4b1ac79 100644

arch/arm/mach-s3c64xx/include/mach/map.h +4 -1
@@ -86,6 +86,9 @@
 #define S3C64XX_SZ_GPIO		SZ_4K
 
 #define S3C64XX_PA_SDRAM	(0x50000000)
+
+#define S3C64XX_PA_CFCON	(0x70300000)
+
 #define S3C64XX_PA_VIC0		(0x71200000)
 #define S3C64XX_PA_VIC1		(0x71300000)
 
@@ -118,7 +121,7 @@
 #define S3C_VA_USB_HSPHY	S3C64XX_VA_USB_HSPHY
 #define S3C_PA_RTC		S3C64XX_PA_RTC
 #define S3C_PA_WDT		S3C64XX_PA_WATCHDOG
-
+#define SAMSUNG_PA_CFCON	S3C64XX_PA_CFCON
 #define SAMSUNG_PA_ADC		S3C64XX_PA_ADC
 
 #endif /* __ASM_ARCH_6400_MAP_H */
(quoted diff) +0 -0

b/arch/arm/mach-s3c64xx/include/mach/regs-clock.h

arch/arm/mach-

Quoted 21 lines

index 0114eb0..05332b9 100644

arch/arm/mach-s3c64xx/include/mach/regs-clock.h +5 -0
@@ -34,6 +34,7 @@
 #define S3C_SCLK_GATE		S3C_CLKREG(0x38)
 #define S3C_MEM0_GATE		S3C_CLKREG(0x3C)
 #define S3C6410_CLK_SRC2	S3C_CLKREG(0x10C)
+#define S3C_MEM_SYS_CFG		S3C_CLKREG(0x120)
 
 /* CLKDIV0 */
 #define S3C6400_CLKDIV0_PCLK_MASK	(0xf << 12)
@@ -154,4 +155,8 @@
 #define S3C6400_CLKSRC_EPLL_MOUT_SHIFT	(2)
 #define S3C6400_CLKSRC_MFC		(1 << 4)
 
+/* MEM_SYS_CFG */
+#define MEM_SYS_CFG_INDEP_CF		0x4000
+#define MEM_SYS_CFG_EBI_FIX_PRI_CFCON	0x30
+
 #endif /* _PLAT_REGS_CLOCK_H */
arch/arm/mach- renamed from arch/arm/mach-s3c64xx/mach-smdk6410.c +0 -0

s3c64xx/mach-smdk6410.c

Quoted 12 lines

index d9a0355..cc1bb0f 100644

arch/arm/mach-s3c64xx/mach-smdk6410.c +1 -0
@@ -56,6 +56,7 @@
 #include <mach/regs-gpio.h>
 #include <mach/regs-sys.h>
 #include <mach/regs-srom.h>
+#include <plat/ata.h>
 #include <plat/iic.h>
 #include <plat/fb.h>
 #include <plat/gpio-cfg.h>

arch/arm/mach-s3c64xx/mach-smdk6410.c static struct platform_device smdk6410_b_pwr_5v = { · line 248

Quoted 6 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +3 -0
@@ -242,6 +243,11 @@ static struct platform_device smdk6410_b_pwr_5v = {
 };
 #endif
 
+static struct s3c_ide_platdata smdk6410_ide_pdata __initdata = {
+	.setup_gpio	= s3c_ide_setup_gpio,
+	.cfg_mode	= s3c_ide_cfg_mode,

These should have been called s3c64xx_ide...

I'll have a think about what we should be doing with this, it might be wroth passing this via the archdata and leaving the platform data for the board. If these configs are generally going to be per SoC then i'd prefer to see this in the archdata and once per SoC.

arch/arm/mach-s3c64xx/mach-smdk6410.c static struct platform_device *smdk6410_devices[]

Quoted 6 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +2 -0
+};
+
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
@@ -267,6 +273,7 @@ static struct platform_device *smdk6410_devices[]

__initdata = {

arch/arm/mach-

Quoted 17 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +3 -0
 	&s3c_device_adc,
 	&s3c_device_ts,
 	&s3c_device_wdt,
+	&s3c_device_cfcon,
 };
 
 #ifdef CONFIG_REGULATOR
@@ -665,6 +672,8 @@ static void __init smdk6410_machine_init(void)
 	i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
 	i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
 
+	s3c_ide_set_platdata(&smdk6410_ide_pdata);
+
 	platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices));
 }
 
arch/arm/mach- renamed from arch/arm/mach-s3c64xx/s3c6410.c +0 -0

s3c64xx/s3c6410.c

Quoted 12 lines

arch/arm/mach-s3c64xx/s3c6410.c void __init s3c6410_map_io(void) · line 62

Quoted 9 lines

index 014401c..1d1dce4 100644

arch/arm/mach-s3c64xx/s3c6410.c +1 -0
@@ -58,6 +58,7 @@ void __init s3c6410_map_io(void)
 	s3c_device_nand.name = "s3c6400-nand";
 	s3c_onenand_setname("s3c6410-onenand");
 	s3c64xx_onenand1_setname("s3c6410-onenand");
+	s3c_device_cfcon.name = "s3c6400-pata";
 }

let's get this sorted out and use one method. see Kyungmin Park's prev. comments on the subject.

There are boards that doesn't have cf/ide connector at all. It would be good to have s3c-dev not compiled in for some custom kernels. It would be better to hide the driver name change behind a function/macro like it is done for the one-nand driver.

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center

author
#4 lore raw

PATCH 1/4 ARM: S3C64XX: Add support for Compact Flash driver on SMDK6410

In reply to Ben Dooks
Quoted 26 lines · Ben Dooks
Quoted 11 lines · Kukjin Kim

From: Abhilash Kesavan <[email protected]>

Following is added for the CF-ATA driver:
- Platform data strucure definition and instantiation
- Platform device definition and enabling code
- Platform-specific gpio setup code
- CF controller register definitions

Quoted 9 lines
---
 arch/arm/mach-s3c64xx/Kconfig                   |    7 +++
 arch/arm/mach-s3c64xx/Makefile                  |    1 +
 arch/arm/mach-s3c64xx/clock.c                   |    6 +++
 arch/arm/mach-s3c64xx/include/mach/map.h        |    5 ++-
 arch/arm/mach-s3c64xx/include/mach/regs-clock.h |    5 ++
 arch/arm/mach-s3c64xx/mach-smdk6410.c           |    9 ++++
 arch/arm/mach-s3c64xx/s3c6410.c                 |    1 +
 arch/arm/mach-s3c64xx/setup-ide.c               |   55

++++++++++++++++++++++

Quoted 3 lines
 arch/arm/plat-samsung/Kconfig                   |    5 ++
 arch/arm/plat-samsung/Makefile                  |    1 +
 arch/arm/plat-samsung/dev-ide.c                 |   52
Quoted 9 lines

+++++++++++++++++++++

Quoted 3 lines
 arch/arm/plat-samsung/include/plat/ata.h        |   38 +++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h       |    1 +
 arch/arm/plat-samsung/include/plat/regs-ata.h   |   56

+++++++++++++++++++++++

it would have been useful to keep the plat-samsung changes seperate.

Ok..will separate the plat-samsung and machine code into different patches.

Quoted 7 lines

Review

Quoted 7 lines
 14 files changed, 241 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-s3c64xx/setup-ide.c
 create mode 100644 arch/arm/plat-samsung/dev-ide.c
 create mode 100644 arch/arm/plat-samsung/include/plat/ata.h
 create mode 100644 arch/arm/plat-samsung/include/plat/regs-ata.h
(quoted diff) +0 -0

b/arch/arm/mach-s3c64xx/Kconfig

Quoted 27 lines
Quoted 27 lines

index f5a5972..c00401e 100644

arch/arm/mach-s3c64xx/Kconfig +7 -0
@@ -67,6 +67,11 @@ config S3C64XX_SETUP_SDHCI_GPIO
 	help
 	  Common setup code for S3C64XX SDHCI GPIO configurations
 
+config S3C64XX_SETUP_IDE
+	bool
+	help
+	  Common setup code for S3C64XX IDE.
+
 # S36400 Macchine support
 
 config MACH_SMDK6400
@@ -101,9 +106,11 @@ config MACH_SMDK6410
 	select S3C_DEV_USB_HSOTG
 	select S3C_DEV_WDT
 	select HAVE_S3C2410_WATCHDOG
+	select S3C_DEV_IDE
 	select S3C64XX_SETUP_SDHCI
 	select S3C64XX_SETUP_I2C1
 	select S3C64XX_SETUP_FB_24BPP
+	select S3C64XX_SETUP_IDE
 	help
 	  Machine support for the Samsung SMDK6410
 
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/mach-s3c64xx/Makefile

Quoted 9 lines
Quoted 9 lines

index 9d10069..0d52c35 100644

arch/arm/mach-s3c64xx/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_S3C64XX_SETUP_I2C1) += setup-i2c1.o
 obj-$(CONFIG_S3C64XX_SETUP_SDHCI) += setup-sdhci.o
 obj-$(CONFIG_S3C64XX_SETUP_FB_24BPP) += setup-fb-24bpp.o
 obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
+obj-$(CONFIG_S3C64XX_SETUP_IDE) += setup-ide.o
 
Quoted 3 lines

Review

Quoted 3 lines
arch/arm/mach-s3c64xx/Makefile +0 -0
 # PM
 
(quoted diff) +0 -0

b/arch/arm/mach-s3c64xx/clock.c

Quoted 39 lines

arch/arm/mach-

Quoted 17 lines

index 7a4138b..9dac5c4 100644

arch/arm/mach-s3c64xx/clock.c +6 -0
@@ -304,6 +304,12 @@ static struct clk init_clocks[] = {
 		.id		= -1,
 		.parent		= &clk_p,
 		.ctrlbit	= S3C_CLKCON_PCLK_AC97,
+	}, {
+		.name		= "cfcon",
+		.id		= -1,
+		.parent		= &clk_h,
+		.enable		= s3c64xx_hclk_ctrl,
+		.ctrlbit	= S3C_CLKCON_HCLK_IHOST,
 	}
 };
 
arch/arm/mach- renamed from arch/arm/mach-s3c64xx/include/mach/map.h +0 -0

s3c64xx/include/mach/map.h

Quoted 21 lines

index e1eab3c..4b1ac79 100644

arch/arm/mach-s3c64xx/include/mach/map.h +4 -1
@@ -86,6 +86,9 @@
 #define S3C64XX_SZ_GPIO		SZ_4K
 
 #define S3C64XX_PA_SDRAM	(0x50000000)
+
+#define S3C64XX_PA_CFCON	(0x70300000)
+
 #define S3C64XX_PA_VIC0		(0x71200000)
 #define S3C64XX_PA_VIC1		(0x71300000)
 
@@ -118,7 +121,7 @@
 #define S3C_VA_USB_HSPHY	S3C64XX_VA_USB_HSPHY
 #define S3C_PA_RTC		S3C64XX_PA_RTC
 #define S3C_PA_WDT		S3C64XX_PA_WATCHDOG
-
+#define SAMSUNG_PA_CFCON	S3C64XX_PA_CFCON
 #define SAMSUNG_PA_ADC		S3C64XX_PA_ADC
 
Quoted 2 lines

Review

Quoted 2 lines
arch/arm/mach-s3c64xx/include/mach/map.h +0 -0
 #endif /* __ASM_ARCH_6400_MAP_H */
(quoted diff) +0 -0

b/arch/arm/mach-

Quoted 45 lines

s3c64xx/include/mach/regs-clock.h

arch/arm/mach-

Quoted 21 lines

index 0114eb0..05332b9 100644

arch/arm/mach-s3c64xx/include/mach/regs-clock.h +5 -0
@@ -34,6 +34,7 @@
 #define S3C_SCLK_GATE		S3C_CLKREG(0x38)
 #define S3C_MEM0_GATE		S3C_CLKREG(0x3C)
 #define S3C6410_CLK_SRC2	S3C_CLKREG(0x10C)
+#define S3C_MEM_SYS_CFG		S3C_CLKREG(0x120)
 
 /* CLKDIV0 */
 #define S3C6400_CLKDIV0_PCLK_MASK	(0xf << 12)
@@ -154,4 +155,8 @@
 #define S3C6400_CLKSRC_EPLL_MOUT_SHIFT	(2)
 #define S3C6400_CLKSRC_MFC		(1 << 4)
 
+/* MEM_SYS_CFG */
+#define MEM_SYS_CFG_INDEP_CF		0x4000
+#define MEM_SYS_CFG_EBI_FIX_PRI_CFCON	0x30
+
 #endif /* _PLAT_REGS_CLOCK_H */
arch/arm/mach- renamed from arch/arm/mach-s3c64xx/mach-smdk6410.c +0 -0

s3c64xx/mach-smdk6410.c

Quoted 12 lines

index d9a0355..cc1bb0f 100644

arch/arm/mach-s3c64xx/mach-smdk6410.c +1 -0
@@ -56,6 +56,7 @@
 #include <mach/regs-gpio.h>
 #include <mach/regs-sys.h>
 #include <mach/regs-srom.h>
+#include <plat/ata.h>
 #include <plat/iic.h>
 #include <plat/fb.h>
 #include <plat/gpio-cfg.h>

arch/arm/mach-s3c64xx/mach-smdk6410.c static struct platform_device smdk6410_b_pwr_5v = { · line 248

Quoted 6 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +3 -0
@@ -242,6 +243,11 @@ static struct platform_device smdk6410_b_pwr_5v = {
 };
 #endif
 
+static struct s3c_ide_platdata smdk6410_ide_pdata __initdata = {
+	.setup_gpio	= s3c_ide_setup_gpio,
+	.cfg_mode	= s3c_ide_cfg_mode,

These should have been called s3c64xx_ide...

Quoted 5 lines

I'll have a think about what we should be doing with this, it might be wroth passing this via the archdata and leaving the platform data for the board. If these configs are generally going to be per SoC then i'd prefer to see this in the archdata and once per SoC.

Will change it to per SoC.

Quoted 18 lines

arch/arm/mach-s3c64xx/mach-smdk6410.c static struct platform_device *smdk6410_devices[]

Quoted 6 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +2 -0
+};
+
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
@@ -267,6 +273,7 @@ static struct platform_device *smdk6410_devices[]

__initdata = {

Quoted 11 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +1 -0
 	&s3c_device_adc,
 	&s3c_device_ts,
 	&s3c_device_wdt,
+	&s3c_device_cfcon,
 };
 
 #ifdef CONFIG_REGULATOR
@@ -665,6 +672,8 @@ static void __init smdk6410_machine_init(void)
 	i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
 	i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
 
Quoted 7 lines

arch/arm/mach-s3c64xx/mach-smdk6410.c static void __init smdk6410_machine_init(void)

Quoted 3 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +2 -0
+	s3c_ide_set_platdata(&smdk6410_ide_pdata);
+
 	platform_add_devices(smdk6410_devices,

ARRAY_SIZE(smdk6410_devices));

Review

Quoted 3 lines
arch/arm/mach-s3c64xx/mach-smdk6410.c +0 -0
 }
 
(quoted diff) +0 -0

b/arch/arm/mach-s3c64xx/s3c6410.c

Quoted 4 lines
Quoted 4 lines

index 014401c..1d1dce4 100644

arch/arm/mach-s3c64xx/s3c6410.c +0 -0
@@ -58,6 +58,7 @@ void __init s3c6410_map_io(void)
Quoted 9 lines

arch/arm/mach-s3c64xx/s3c6410.c void __init s3c6410_map_io(void) · line 62

Quoted 5 lines
arch/arm/mach-s3c64xx/s3c6410.c +1 -0
 	s3c_device_nand.name = "s3c6400-nand";
 	s3c_onenand_setname("s3c6410-onenand");
 	s3c64xx_onenand1_setname("s3c6410-onenand");
+	s3c_device_cfcon.name = "s3c6400-pata";
 }

let's get this sorted out and use one method. see Kyungmin Park's prev. comments on the subject.

Will create a new file ata-core.h on the lines of iic-core.h/onenand-core.h

Quoted 2 lines

Review

Quoted 2 lines
arch/arm/mach-s3c64xx/s3c6410.c +0 -0
 void __init s3c6410_init_clocks(int xtal)
(quoted diff) +0 -0

b/arch/arm/mach-s3c64xx/setup-

Quoted 47 lines

ide.c

Quoted 46 lines

new file mode 100644
index 0000000..0bf4e5e

arch/arm/mach-s3c64xx/setup-ide.c new file +41 -0
@@ -0,0 +1,55 @@
+/* linux/arch/arm/mach-s3c64xx/setup-ide.c
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com/
+ *
+ * S3C64XX setup information for IDE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/io.h>
+
+#include <mach/map.h>
+#include <mach/gpio.h>
+#include <mach/regs-clock.h>
+#include <plat/gpio-cfg.h>
+#include <plat/regs-ata.h>
+
+void s3c_ide_setup_gpio(void)
+{
+	u32 reg;
+	u32 gpio = 0;
+
+	reg = __raw_readl(S3C_MEM_SYS_CFG) & (~0x3f);
+
+	/* Independent CF interface, CF chip select configuration */
+	__raw_writel(reg | MEM_SYS_CFG_INDEP_CF |
+		MEM_SYS_CFG_EBI_FIX_PRI_CFCON, S3C_MEM_SYS_CFG);
+
+	s3c_gpio_cfgpin(S3C64XX_GPB(4), S3C_GPIO_SFN(4));
+
+	/* Set XhiDATA[15:0] pins as CF Data[15:0] */
+	for (gpio = S3C64XX_GPK(0); gpio <= S3C64XX_GPK(15); gpio++)
+		s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(5));
+
+	/* Set XhiADDR[2:0] pins as CF ADDR[2:0] */
+	for (gpio = S3C64XX_GPL(0); gpio <= S3C64XX_GPL(2); gpio++)
Quoted 9 lines

arch/arm/mach-s3c64xx/setup-ide.c line 47

Quoted 6 lines
arch/arm/mach-s3c64xx/setup-ide.c new file +6 -0
+		s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(6));
+
+	/* Set Xhi ctrl pins as CF ctrl pins(IORDY, IOWR, IORD, CE[0:1]) */
+	s3c_gpio_cfgpin(S3C64XX_GPM(5), S3C_GPIO_SFN(1));
+	for (gpio = S3C64XX_GPM(0); gpio <= S3C64XX_GPM(4); gpio++)
+		s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(6));

i'll update this to the cfgrange when merging the cfgrange code.

OK

Quoted 11 lines

arch/arm/mach-s3c64xx/setup-ide.c line 55

Quoted 8 lines
arch/arm/mach-s3c64xx/setup-ide.c new file +8 -0
+}
+
+void s3c_ide_cfg_mode(void __iomem *sfrbase)
+{
+	/* Select true-ide as the internal operating mode*/
+	writel(readl(sfrbase + S3C_CFATA_MUX) | S3C_CFATA_MUX_TRUEIDE,
+						sfrbase + S3C_CFATA_MUX);
+}

maybe we just put this in the driver and select on type.

Will move it to the driver file.

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/plat-samsung/Kconfig

Quoted 7 lines
Quoted 7 lines

index 2753fb3..6ec97fe 100644

arch/arm/plat-samsung/Kconfig +0 -0
@@ -175,6 +175,11 @@ config S3C_DEV_I2C2
 	help
 	  Compile in platform device definitions for I2C channel 2
 
Quoted 9 lines

Review

Quoted 9 lines
arch/arm/plat-samsung/Kconfig +5 -0
+config S3C_DEV_IDE
+	bool
+	help
+	  Compile in platform device definitions for IDE
+
 config S3C_DEV_FB
 	bool
 	help
(quoted diff) +0 -0

b/arch/arm/plat-samsung/Makefile

Quoted 5 lines
Quoted 5 lines

index b1d82cc..252fc76 100644

arch/arm/plat-samsung/Makefile +0 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_S3C_DEV_RTC)	+= dev-rtc.o
 
Quoted 7 lines

Review

Quoted 7 lines
arch/arm/plat-samsung/Makefile +1 -0
 obj-$(CONFIG_SAMSUNG_DEV_ADC)	+= dev-adc.o
 obj-$(CONFIG_SAMSUNG_DEV_TS)	+= dev-ts.o
+obj-$(CONFIG_S3C_DEV_IDE)	+= dev-ide.o
 
 # DMA support
 
(quoted diff) +0 -0

b/arch/arm/plat-samsung/dev-ide.c

Quoted 18 lines
Quoted 18 lines

new file mode 100644
index 0000000..c6b3292

arch/arm/plat-samsung/dev-ide.c new file +13 -0
@@ -0,0 +1,52 @@
+/* linux/arch/arm/plat-samsung/dev-ide.c
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * S3C CF-ATA device definition.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
Quoted 9 lines

arch/arm/plat-samsung/dev-ide.c line 19

Quoted 6 lines
arch/arm/plat-samsung/dev-ide.c new file +6 -0
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <mach/map.h>
+#include <plat/ata.h>

do we need linux/io.h in here?

No..will remove it.

Quoted 2 lines

soem spacing inebtwee nthe include groups would be nice too,.

OK

Quoted 7 lines

arch/arm/plat-samsung/dev-ide.c line 25

Quoted 5 lines
arch/arm/plat-samsung/dev-ide.c new file +5 -0
+static struct resource s3c_cfcon_resource[] = {
+	[0] = {
+		.start	= SAMSUNG_PA_CFCON,
+		.end	= SAMSUNG_PA_CFCON + SZ_1M - 1,
+		.flags	= IORESOURCE_MEM,

do we really need to map SZ_1M?

Will change it to SZ_16K.

Quoted 5 lines
Quoted 5 lines
arch/arm/plat-samsung/dev-ide.c new file +5 -0
+	},
+	[1] = {
+		.start	= IRQ_CFCON,
+		.end	= IRQ_CFCON,
+		.flags	= IORESOURCE_IRQ,
Quoted 9 lines

arch/arm/plat-samsung/dev-ide.c line 35

Quoted 5 lines
arch/arm/plat-samsung/dev-ide.c new file +5 -0
+	},
+};
+
+struct platform_device s3c_device_cfcon = {
+	.name		= "s3c-pata",

if the name is going to change, let's simply not bother setting one here.

Will remove the name.

Quoted 11 lines

arch/arm/plat-samsung/dev-ide.c line 45

Quoted 10 lines
arch/arm/plat-samsung/dev-ide.c new file +9 -0
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(s3c_cfcon_resource),
+	.resource	= s3c_cfcon_resource,
+};
 
+void s3c_ide_set_platdata(struct s3c_ide_platdata *pdata)
+{
+	struct s3c_ide_platdata *pd;
+
+	pd = (struct s3c_ide_platdata *)kmemdup(pdata,

^^^^^ not needed.

Will remove it.

Quoted 36 lines

arch/arm/plat-samsung/dev-ide.c

Quoted 3 lines
arch/arm/plat-samsung/dev-ide.c new file +3 -0
+		sizeof(struct s3c_ide_platdata), GFP_KERNEL);
+	if (!pd) {
+		printk(KERN_ERR "%s: no memory for platform data\n",

__func__);

arch/arm/plat-

Quoted 5 lines
arch/arm/plat-samsung/dev-ide.c new file +4 -0
+		return;
+	}
+	s3c_device_cfcon.dev.platform_data = pd;
+}
arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/ata.h +0 -0

samsung/include/plat/ata.h

Quoted 26 lines

new file mode 100644
index 0000000..aea11dc

arch/arm/plat-samsung/include/plat/ata.h new file +21 -0
@@ -0,0 +1,38 @@
+/* arch/arm/plat-samsung/include/plat/ata.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * S3C - CF Controller platform_device info
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_PLAT_ATA_H
+#define __ASM_PLAT_ATA_H __FILE__
+
+/**
+ * struct s3c_ide_platdata - S3C IDE driver platform data.
+ * @setup_gpio: Setup the external GPIO pins to the right state for data
+ * transfer in true-ide mode.
+ * @cfg_mode: Platform specific setup for configuring the CF controller
+ * in true-ide mode.
Quoted 8 lines

arch/arm/plat-samsung/include/plat/ata.h

Quoted 8 lines
arch/arm/plat-samsung/include/plat/ata.h new file +8 -0
+ */
+struct s3c_ide_platdata {
+	void (*setup_gpio)(void);
+	void (*cfg_mode)(void __iomem *sfrbase);
+};
+
+/*
+ * s3c_ide_set_platdata() - Setup the platform specifc data for IDE

driver.

Quoted 16 lines

arch/arm/plat-

Quoted 10 lines
arch/arm/plat-samsung/include/plat/ata.h new file +9 -0
+ * @pdata: Platform data for IDE driver.
+ */
+extern void s3c_ide_set_platdata(struct s3c_ide_platdata *pdata);
+
+/* architecture-specific IDE configuration */
+extern void s3c_ide_setup_gpio(void);
+extern void s3c_ide_cfg_mode(void __iomem *sfrbase);
+
+#endif /*__ASM_PLAT_ATA_H */
arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/devs.h +0 -0

samsung/include/plat/devs.h

Quoted 5 lines

index e6144e4..e3fcddb 100644

arch/arm/plat-samsung/include/plat/devs.h +0 -0
@@ -75,6 +75,7 @@ extern struct platform_device s5pc110_device_onenand;
 
Quoted 7 lines

Review

Quoted 7 lines
arch/arm/plat-samsung/include/plat/devs.h +1 -0
 extern struct platform_device s3c_device_usbgadget;
 extern struct platform_device s3c_device_usb_hsotg;
+extern struct platform_device s3c_device_cfcon;
 
 extern struct platform_device s5pv210_device_ac97;
 extern struct platform_device s5pv210_device_pcm0;
(quoted diff) +0 -0

b/arch/arm/plat-

Quoted 57 lines

samsung/include/plat/regs-ata.h

Quoted 56 lines

new file mode 100644
index 0000000..f73b267

arch/arm/plat-samsung/include/plat/regs-ata.h new file +51 -0
@@ -0,0 +1,56 @@
+/* arch/arm/plat-samsung/include/plat/regs-ata.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * S3C CF-ATA register definitions
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_PLAT_REGS_ATA_H
+#define __ASM_PLAT_REGS_ATA_H __FILE__
+
+#define S3C_CFATA_REG(x)	(x)
+
+#define S3C_CFATA_MUX		S3C_CFATA_REG(0x0)
+
+#define S3C_ATA_CTRL		S3C_CFATA_REG(0x0)
+#define S3C_ATA_STATUS		S3C_CFATA_REG(0x4)
+#define S3C_ATA_CMD		S3C_CFATA_REG(0x8)
+#define S3C_ATA_SWRST		S3C_CFATA_REG(0xc)
+#define S3C_ATA_IRQ		S3C_CFATA_REG(0x10)
+#define S3C_ATA_IRQ_MSK		S3C_CFATA_REG(0x14)
+#define S3C_ATA_CFG		S3C_CFATA_REG(0x18)
+
+#define S3C_ATA_MDMA_TIME	S3C_CFATA_REG(0x28)
+#define S3C_ATA_PIO_TIME	S3C_CFATA_REG(0x2c)
+#define S3C_ATA_UDMA_TIME	S3C_CFATA_REG(0x30)
+#define S3C_ATA_XFR_NUM		S3C_CFATA_REG(0x34)
+#define S3C_ATA_XFR_CNT		S3C_CFATA_REG(0x38)
+#define S3C_ATA_TBUF_START	S3C_CFATA_REG(0x3c)
+#define S3C_ATA_TBUF_SIZE	S3C_CFATA_REG(0x40)
+#define S3C_ATA_SBUF_START	S3C_CFATA_REG(0x44)
+#define S3C_ATA_SBUF_SIZE	S3C_CFATA_REG(0x48)
+#define S3C_ATA_CADR_TBUF	S3C_CFATA_REG(0x4c)
+#define S3C_ATA_CADR_SBUF	S3C_CFATA_REG(0x50)
+#define S3C_ATA_PIO_DTR		S3C_CFATA_REG(0x54)
+#define S3C_ATA_PIO_FED		S3C_CFATA_REG(0x58)
+#define S3C_ATA_PIO_SCR		S3C_CFATA_REG(0x5c)
+#define S3C_ATA_PIO_LLR		S3C_CFATA_REG(0x60)
+#define S3C_ATA_PIO_LMR		S3C_CFATA_REG(0x64)
+#define S3C_ATA_PIO_LHR		S3C_CFATA_REG(0x68)
+#define S3C_ATA_PIO_DVR		S3C_CFATA_REG(0x6c)
+#define S3C_ATA_PIO_CSD		S3C_CFATA_REG(0x70)
+#define S3C_ATA_PIO_DAD		S3C_CFATA_REG(0x74)
+#define S3C_ATA_PIO_READY	S3C_CFATA_REG(0x78)
+#define S3C_ATA_PIO_RDATA	S3C_CFATA_REG(0x7c)
+
+#define S3C_CFATA_MUX_TRUEIDE	0x01
Quoted 8 lines
Quoted 8 lines
arch/arm/plat-samsung/include/plat/regs-ata.h new file +5 -1
+
+#define S3C_ATA_CFG_SWAP	0x40
+#define S3C_ATA_CFG_IORDYEN	0x02
+
+#endif /* __ASM_PLAT_REGS_ATA_H */
--

1.6.2.5

Thanks.

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

#5 lore raw

PATCH 1/4 ARM: S3C64XX: Add support for Compact Flash driver on SMDK6410

In reply to Kukjin Kim

arch/arm/mach-s3c64xx/setup-ide.c line 18

Quoted 2 lines · Kukjin Kim
arch/arm/mach-s3c64xx/setup-ide.c new file +2 -0
+#include <mach/map.h>
+#include <mach/gpio.h>

shouldn't this be linux/gpio.h ?

author
#6 lore raw

PATCH 1/4 ARM: S3C64XX: Add support for Compact Flash driver on SMDK6410

Quoted 6 lines · Russell King - ARM Linux

arch/arm/mach-s3c64xx/setup-ide.c line 18

Quoted 2 lines · Kukjin Kim
arch/arm/mach-s3c64xx/setup-ide.c new file +2 -0
+#include <mach/map.h>
+#include <mach/gpio.h>

shouldn't this be linux/gpio.h ?

Will change it.

Thanks.

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

author
#7 lore raw

PATCH 2/4 ARM: S5PV210: Add support for Compact Flash driver on SMDKV210/SMDKC110

In reply to Kukjin Kim

From: Abhilash Kesavan <[email protected]>

Following is added for the CF-ATA driver:
- Platform data strucure instantiation
- Platform device definition and enabling code
- Platform-specific gpio setup code
- Fixed IRQ naming to match across 64xx and v210

---
 arch/arm/mach-s5pv210/Kconfig             |    9 +++++
 arch/arm/mach-s5pv210/Makefile            |    1 +
 arch/arm/mach-s5pv210/cpu.c               |    1 +
 arch/arm/mach-s5pv210/include/mach/irqs.h |    2 +-
 arch/arm/mach-s5pv210/include/mach/map.h  |    4 ++-
 arch/arm/mach-s5pv210/mach-smdkc110.c     |    8 ++++
 arch/arm/mach-s5pv210/mach-smdkv210.c     |    7 ++++
 arch/arm/mach-s5pv210/setup-ide.c         |   51 +++++++++++++++++++++++++++++
 8 files changed, 81 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-s5pv210/setup-ide.c
arch/arm/mach-s5pv210/Kconfig +9 -0
index 0761eac..29b900e 100644
@@ -43,6 +43,11 @@ config S5PV210_SETUP_SDHCI_GPIO
 	help
 	  Common setup code for SDHCI gpio.
 
+config S5PV210_SETUP_IDE
+	bool
+	help
+	  Common setup code for S5PV210 IDE GPIO configurations
+
 # machine support
 
 config MACH_AQUILA
@@ -75,6 +80,8 @@ config MACH_SMDKV210
 	select SAMSUNG_DEV_TS
 	select S3C_DEV_WDT
 	select HAVE_S3C2410_WATCHDOG
+	select S3C_DEV_IDE
+	select S5PV210_SETUP_IDE
 	help
 	  Machine support for Samsung SMDKV210
 
@@ -84,6 +91,8 @@ config MACH_SMDKC110
 	select ARCH_SPARSEMEM_ENABLE
 	select S3C_DEV_WDT
 	select HAVE_S3C2410_WATCHDOG
+	select S3C_DEV_IDE
+	select S5PV210_SETUP_IDE
 	help
 	  Machine support for Samsung SMDKC110
 	  S5PC110(MCP) is one of package option of S5PV210
arch/arm/mach-s5pv210/Makefile +1 -0
index 30be9a6..af55785 100644
@@ -31,5 +31,6 @@ obj-$(CONFIG_S5PC110_DEV_ONENAND) += dev-onenand.o
 obj-$(CONFIG_S5PV210_SETUP_FB_24BPP)	+= setup-fb-24bpp.o
 obj-$(CONFIG_S5PV210_SETUP_I2C1) 	+= setup-i2c1.o
 obj-$(CONFIG_S5PV210_SETUP_I2C2) 	+= setup-i2c2.o
+obj-$(CONFIG_S5PV210_SETUP_IDE)		+= setup-ide.o
 obj-$(CONFIG_S5PV210_SETUP_SDHCI)       += setup-sdhci.o
 obj-$(CONFIG_S5PV210_SETUP_SDHCI_GPIO)	+= setup-sdhci-gpio.o
arch/arm/mach-s5pv210/cpu.c +1 -0
index 411a4a9..fac2f0d 100644
@@ -79,6 +79,7 @@ void __init s5pv210_map_io(void)
 #ifdef CONFIG_S3C_DEV_ADC
 	s3c_device_adc.name	= "s3c64xx-adc";
 #endif
+	s3c_device_cfcon.name = "s5pv210-pata";
 
 	iotable_init(s5pv210_iodesc, ARRAY_SIZE(s5pv210_iodesc));
 
arch/arm/mach-s5pv210/include/mach/irqs.h +1 -1
index 9689537..e1d3c45 100644
@@ -45,7 +45,7 @@
 #define IRQ_IEMIEC		S5P_IRQ_VIC1(6)
 #define IRQ_ONENAND		S5P_IRQ_VIC1(7)
 #define IRQ_NFC			S5P_IRQ_VIC1(8)
-#define IRQ_CFC			S5P_IRQ_VIC1(9)
+#define IRQ_CFCON		S5P_IRQ_VIC1(9)
 #define IRQ_UART0		S5P_IRQ_VIC1(10)
 #define IRQ_UART1		S5P_IRQ_VIC1(11)
 #define IRQ_UART2		S5P_IRQ_VIC1(12)
arch/arm/mach-s5pv210/include/mach/map.h +3 -1
index 34eb168..48b8c02 100644
@@ -54,6 +54,8 @@
 
 #define S5PV210_PA_SROMC	(0xE8000000)
 
+#define S5PV210_PA_CFCON	(0xE8200000)
+
 #define S5PV210_PA_MDMA		0xFA200000
 #define S5PV210_PA_PDMA0	0xE0900000
 #define S5PV210_PA_PDMA1	0xE0A00000
@@ -102,7 +104,7 @@
 #define S3C_PA_IIC2		S5PV210_PA_IIC2
 #define S3C_PA_FB		S5PV210_PA_FB
 #define S3C_PA_WDT		S5PV210_PA_WATCHDOG
-
+#define SAMSUNG_PA_CFCON	S5PV210_PA_CFCON
 #define SAMSUNG_PA_ADC		S5PV210_PA_ADC
 
 #endif /* __ASM_ARCH_MAP_H */
arch/arm/mach-s5pv210/mach-smdkc110.c +8 -0
index 4c8903c..7fce0a2 100644
@@ -25,6 +25,7 @@
 #include <plat/s5pv210.h>
 #include <plat/devs.h>
 #include <plat/cpu.h>
+#include <plat/ata.h>
 
 /* Following are default values for UCON, ULCON and UFCON UART registers */
 #define S5PV210_UCON_DEFAULT	(S3C2410_UCON_TXILEVEL |	\
@@ -71,10 +72,15 @@ static struct s3c2410_uartcfg smdkv210_uartcfgs[] __initdata = {
 	},
 };
 
+static struct s3c_ide_platdata smdkv210_ide_pdata __initdata = {
+	.setup_gpio	= s3c_ide_setup_gpio,
+};
+
 static struct platform_device *smdkc110_devices[] __initdata = {
 	&s5pv210_device_iis0,
 	&s5pv210_device_ac97,
 	&s3c_device_wdt,
+	&s3c_device_cfcon,
 };
 
 static void __init smdkc110_map_io(void)
@@ -86,6 +92,8 @@ static void __init smdkc110_map_io(void)
 
 static void __init smdkc110_machine_init(void)
 {
+	s3c_ide_set_platdata(&smdkv210_ide_pdata);
+
 	platform_add_devices(smdkc110_devices, ARRAY_SIZE(smdkc110_devices));
 }
 
arch/arm/mach-s5pv210/mach-smdkv210.c +7 -0
index 0d46279..ac42e7c 100644
@@ -27,6 +27,7 @@
 #include <plat/cpu.h>
 #include <plat/adc.h>
 #include <plat/ts.h>
+#include <plat/ata.h>
 
 /* Following are default values for UCON, ULCON and UFCON UART registers */
 #define S5PV210_UCON_DEFAULT	(S3C2410_UCON_TXILEVEL |	\
@@ -73,12 +74,17 @@ static struct s3c2410_uartcfg smdkv210_uartcfgs[] __initdata = {
 	},
 };
 
+static struct s3c_ide_platdata smdkv210_ide_pdata __initdata = {
+	.setup_gpio	= s3c_ide_setup_gpio,
+};
+
 static struct platform_device *smdkv210_devices[] __initdata = {
 	&s5pv210_device_iis0,
 	&s5pv210_device_ac97,
 	&s3c_device_adc,
 	&s3c_device_ts,
 	&s3c_device_wdt,
+	&s3c_device_cfcon,
 };
 
 static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
@@ -97,6 +103,7 @@ static void __init smdkv210_map_io(void)
 static void __init smdkv210_machine_init(void)
 {
 	s3c24xx_ts_set_platdata(&s3c_ts_platform);
+	s3c_ide_set_platdata(&smdkv210_ide_pdata);
 	platform_add_devices(smdkv210_devices, ARRAY_SIZE(smdkv210_devices));
 }
 
arch/arm/mach-s5pv210/setup-ide.c new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#8 lore raw

PATCH 2/4 ARM: S5PV210: Add support for Compact Flash driver on SMDKV210/SMDKC110

Quoted 1 line · Kukjin Kim

+#include <mach/gpio.h>

linux/gpio.h ?

author
#9 lore raw

PATCH 3/4 ARM: S5PC100: Add support for Compact Flash driver on SMDKC100

In reply to Kukjin Kim

From: Abhilash Kesavan <[email protected]>

Following is added for the CF-ATA driver:
- Platform data strucure instantiatio
- Platform device definition and enabling code
- Platform-specific gpio setup code

---
 arch/arm/mach-s5pc100/Kconfig                   |    7 ++
 arch/arm/mach-s5pc100/Makefile                  |    1 +
 arch/arm/mach-s5pc100/cpu.c                     |    1 +
 arch/arm/mach-s5pc100/include/mach/irqs.h       |    2 +-
 arch/arm/mach-s5pc100/include/mach/map.h        |    4 +
 arch/arm/mach-s5pc100/include/mach/regs-clock.h |    3 +
 arch/arm/mach-s5pc100/mach-smdkc100.c           |    8 ++
 arch/arm/mach-s5pc100/setup-ide.c               |   79 +++++++++++++++++++++++
 8 files changed, 104 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-s5pc100/setup-ide.c
arch/arm/mach-s5pc100/Kconfig +7 -0
index b2a11df..d030c95 100644
@@ -36,17 +36,24 @@ config S5PC100_SETUP_SDHCI_GPIO
 	help
 	  Common setup code for SDHCI gpio.
 
+config S5PC100_SETUP_IDE
+	bool
+	help
+	  Common setup code for S5PC100 IDE GPIO configurations
+
 config MACH_SMDKC100
 	bool "SMDKC100"
 	select CPU_S5PC100
 	select S3C_DEV_FB
 	select S3C_DEV_I2C1
+	select S3C_DEV_IDE
 	select S3C_DEV_HSMMC
 	select S3C_DEV_HSMMC1
 	select S3C_DEV_HSMMC2
 	select S5PC100_SETUP_FB_24BPP
 	select S5PC100_SETUP_I2C1
 	select S5PC100_SETUP_SDHCI
+	select S5PC100_SETUP_IDE
 	help
 	  Machine support for the Samsung SMDKC100
 
arch/arm/mach-s5pc100/Makefile +1 -0
index 543f3de..f192d1a 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_S5PC100_SETUP_FB_24BPP)	+= setup-fb-24bpp.o
 obj-$(CONFIG_S5PC100_SETUP_I2C1)	+= setup-i2c1.o
 obj-$(CONFIG_S5PC100_SETUP_SDHCI)	+= setup-sdhci.o
 obj-$(CONFIG_S5PC100_SETUP_SDHCI_GPIO)	+= setup-sdhci-gpio.o
+obj-$(CONFIG_S5PC100_SETUP_IDE)		+= setup-ide.o
 
 # device support
 obj-y				+= dev-audio.o
arch/arm/mach-s5pc100/cpu.c +1 -0
index 7b5bdbc..7df6db0 100644
@@ -92,6 +92,7 @@ void __init s5pc100_map_io(void)
 	s3c_i2c1_setname("s3c2440-i2c");
 
 	s3c_onenand_setname("s5pc100-onenand");
+	s3c_device_cfcon.name = "s5pc100-pata";
 }
 
 void __init s5pc100_init_clocks(int xtal)
arch/arm/mach-s5pc100/include/mach/irqs.h +1 -1
index 28aa551..bfcc0b9 100644
@@ -38,7 +38,7 @@
 #define IRQ_IEMIEC		S5P_IRQ_VIC1(6)
 #define IRQ_ONENAND		S5P_IRQ_VIC1(7)
 #define IRQ_NFC			S5P_IRQ_VIC1(8)
-#define IRQ_CFC			S5P_IRQ_VIC1(9)
+#define IRQ_CFCON		S5P_IRQ_VIC1(9)
 #define IRQ_UART0		S5P_IRQ_VIC1(10)
 #define IRQ_UART1		S5P_IRQ_VIC1(11)
 #define IRQ_UART2		S5P_IRQ_VIC1(12)
arch/arm/mach-s5pc100/include/mach/map.h +4 -0
index cadae43..c5f944a 100644
@@ -61,6 +61,9 @@
 
 #define S5PC100_PA_ONENAND	(0xE7100000)
 
+/* CF Controller */
+#define S5PC100_PA_CFCON	(0xE7800000)
+
 /* DMA */
 #define S5PC100_PA_MDMA		(0xE8100000)
 #define S5PC100_PA_PDMA0	(0xE9000000)
@@ -134,5 +137,6 @@
 #define S3C_PA_ONENAND		S5PC100_PA_ONENAND
 #define S3C_PA_ONENAND_BUF	S5PC100_PA_ONENAND_BUF
 #define S3C_SZ_ONENAND_BUF	S5PC100_SZ_ONENAND_BUF
+#define SAMSUNG_PA_CFCON	S5PC100_PA_CFCON
 
 #endif /* __ASM_ARCH_C100_MAP_H */
arch/arm/mach-s5pc100/include/mach/regs-clock.h +3 -0
index 5d27d28..bc92da2 100644
@@ -71,7 +71,10 @@
 #define S5P_CLKDIV1_PCLKD1_SHIFT	(16)
 
 #define S5PC100_SWRESET		S5PC100_REG_OTHERS(0x000)
+#define S5PC100_MEM_SYS_CFG	S5PC100_REG_OTHERS(0x200)
 
 #define S5PC100_SWRESET_RESETVAL	0xc100
 
+#define MEM_SYS_CFG_EBI_FIX_PRI_CFCON	0x30
+
 #endif /* __ASM_ARCH_REGS_CLOCK_H */
arch/arm/mach-s5pc100/mach-smdkc100.c +8 -0
index af22f82..e69ddf9 100644
@@ -42,6 +42,7 @@
 #include <plat/s5pc100.h>
 #include <plat/fb.h>
 #include <plat/iic.h>
+#include <plat/ata.h>
 
 /* Following are default values for UCON, ULCON and UFCON UART registers */
 #define S5PC100_UCON_DEFAULT	(S3C2410_UCON_TXILEVEL |	\
@@ -149,6 +150,11 @@ static struct s3c_fb_platdata smdkc100_lcd_pdata __initdata = {
 	.setup_gpio	= s5pc100_fb_gpio_setup_24bpp,
 };
 
+static struct s3c_ide_platdata smdkc100_ide_pdata __initdata = {
+	.setup_gpio	= s3c_ide_setup_gpio,
+	.cfg_mode	= s3c_ide_cfg_mode,
+};
+
 static struct platform_device *smdkc100_devices[] __initdata = {
 	&s3c_device_i2c0,
 	&s3c_device_i2c1,
@@ -159,6 +165,7 @@ static struct platform_device *smdkc100_devices[] __initdata = {
 	&smdkc100_lcd_powerdev,
 	&s5pc100_device_iis0,
 	&s5pc100_device_ac97,
+	&s3c_device_cfcon,
 };
 
 static void __init smdkc100_map_io(void)
@@ -177,6 +184,7 @@ static void __init smdkc100_machine_init(void)
 	i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
 
 	s3c_fb_set_platdata(&smdkc100_lcd_pdata);
+	s3c_ide_set_platdata(&smdkc100_ide_pdata);
 
 	/* LCD init */
 	gpio_request(S5PC100_GPD(0), "GPD");
arch/arm/mach-s5pc100/setup-ide.c new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#10 lore raw

PATCH 3/4 ARM: S5PC100: Add support for Compact Flash driver on SMDKC100

arch/arm/mach-s5pc100/setup-ide.c line 17

Quoted 5 lines · Kukjin Kim
arch/arm/mach-s5pc100/setup-ide.c new file +5 -0
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/io.h>
+
+#include <mach/gpio.h>

linux/gpio.h ?

author
#11 lore raw

PATCH 3/4 ARM: S5PC100: Add support for Compact Flash driver on SMDKC100

Quoted 9 lines · Russell King - ARM Linux

arch/arm/mach-s5pc100/setup-ide.c line 17

Quoted 5 lines · Kukjin Kim
arch/arm/mach-s5pc100/setup-ide.c new file +5 -0
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/io.h>
+
+#include <mach/gpio.h>

linux/gpio.h ?

Will change it :-)

Thanks.

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

author
#12 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

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

---
 drivers/ata/Kconfig        |    9 +
 drivers/ata/Makefile       |    1 +
 drivers/ata/pata_samsung.c |  591 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 601 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/pata_samsung.c
drivers/ata/Kconfig +9 -0
index e68541f..ce40f66 100644
@@ -640,6 +640,15 @@ config PATA_RZ1000
 
 	  If unsure, say N.
 
+config PATA_SAMSUNG
+	tristate "Samsung SoC PATA support"
+	depends on S3C_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_SC1200
 	tristate "SC1200 PATA support"
 	depends on PCI
drivers/ata/Makefile +1 -0
index d0a93c4..0b6d29a 100644
@@ -62,6 +62,7 @@ obj-$(CONFIG_PATA_RADISYS)	+= pata_radisys.o
 obj-$(CONFIG_PATA_RB532)	+= pata_rb532_cf.o
 obj-$(CONFIG_PATA_RDC)		+= pata_rdc.o
 obj-$(CONFIG_PATA_RZ1000)	+= pata_rz1000.o
+obj-$(CONFIG_PATA_SAMSUNG)	+= pata_samsung.o
 obj-$(CONFIG_PATA_SC1200)	+= pata_sc1200.o
 obj-$(CONFIG_PATA_SERVERWORKS)	+= pata_serverworks.o
 obj-$(CONFIG_PATA_SIL680)	+= pata_sil680.o
drivers/ata/pata_samsung.c new file +591 -0

591 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#13 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

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

---
 drivers/ata/Kconfig        |    9 +
 drivers/ata/Makefile       |    1 +
 drivers/ata/pata_samsung.c |  591 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 601 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/pata_samsung.c
drivers/ata/Kconfig +9 -0
index e68541f..ce40f66 100644
@@ -640,6 +640,15 @@ config PATA_RZ1000
 
 	  If unsure, say N.
 
+config PATA_SAMSUNG
+	tristate "Samsung SoC PATA support"
+	depends on S3C_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_SC1200
 	tristate "SC1200 PATA support"
 	depends on PCI
drivers/ata/Makefile +0 -0
index d0a93c4..0b6d29a 100644

drivers/ata/Makefile obj-$(CONFIG_PATA_RADISYS) += pata_radisys.o · line 65

Quoted 4 lines
drivers/ata/Makefile +1 -0
@@ -62,6 +62,7 @@ obj-$(CONFIG_PATA_RADISYS)	+= pata_radisys.o
 obj-$(CONFIG_PATA_RB532)	+= pata_rb532_cf.o
 obj-$(CONFIG_PATA_RDC)		+= pata_rdc.o
 obj-$(CONFIG_PATA_RZ1000)	+= pata_rz1000.o
+obj-$(CONFIG_PATA_SAMSUNG)	+= pata_samsung.o

do you want to call it pata_samsung_soc.o instead, in case samsung make otehr types of pata controller?

Quoted 9 lines
drivers/ata/Makefile +0 -0
 obj-$(CONFIG_PATA_SC1200)	+= pata_sc1200.o
 obj-$(CONFIG_PATA_SERVERWORKS)	+= pata_serverworks.o
 obj-$(CONFIG_PATA_SIL680)	+= pata_sil680.o
drivers/ata/pata_samsung.c new file +0 -0
new file mode 100644
index 0000000..14381e4

drivers/ata/pata_samsung.c line 6

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
@@ -0,0 +1,591 @@
+/* linux/drivers/ata/pata_samsung.c
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * PATA driver for Samsung SoC's.

SoCs.

Quoted 74 lines
drivers/ata/pata_samsung.c new file +74 -0
+ * Supports CF Interface in True IDE mode. Currently only PIO mode has been
+ * implemented; UDMA support has to be added.
+ *
+ * Based on:
+ *	PATA driver for AT91SAM9260 Static Memory Controller
+ *	PATA driver for Toshiba SCC controller
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/libata.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <plat/ata.h>
+#include <plat/regs-ata.h>
+
+#define DRV_NAME "pata_samsung"
+#define DRV_VERSION "0.1"
+
+enum s3c_cpu_type {
+	TYPE_S3C6400,
+	TYPE_S5PC100,
+	TYPE_S5PV210,
+};
+
+/*
+ * struct s3c_ide_info - S3C PATA instance.
+ * @clk: The clock resource for this controller.
+ * @ide_addr: The area mapped for the hardware registers.
+ * @sfr_addr: The area mapped for the special function registers.
+ * @irq: The IRQ number we are using.
+ * @cpu_type: The exact type of this controller.
+ * @fifo_status_reg: The ATA_FIFO_STATUS register offset.
+ */
+struct s3c_ide_info {
+	struct clk *clk;
+	void __iomem *ide_addr;
+	void __iomem *sfr_addr;
+	unsigned int irq;
+	enum s3c_cpu_type cpu_type;
+	unsigned int fifo_status_reg;
+};
+
+static unsigned long piotime[5];
+
+static void pata_s3c_set_endian(void *s3c_ide_regbase, u8 mode)
+{
+	u32 reg = readl(s3c_ide_regbase + S3C_ATA_CFG);
+	reg = mode ? (reg & ~S3C_ATA_CFG_SWAP) : (reg | S3C_ATA_CFG_SWAP);
+	writel(reg, s3c_ide_regbase + S3C_ATA_CFG);
+}
+
+static void pata_s3c_tune_chipset(struct s3c_ide_info *info, u8 ide_mode)
+{
+	ulong ata_cfg = readl(info->ide_addr + S3C_ATA_CFG);
+
+	/* IORDY is enabled for modes > PIO2 */
+	if (XFER_PIO_0 <= ide_mode && ide_mode <= XFER_PIO_4) {
+
+		switch (ide_mode) {
+		case XFER_PIO_0:
+		case XFER_PIO_1:
+		case XFER_PIO_2:
+			ata_cfg &= (~S3C_ATA_CFG_IORDYEN);
+			break;
+		case XFER_PIO_3:
+		case XFER_PIO_4:

drivers/ata/pata_samsung.c line 90

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+			ata_cfg |= S3C_ATA_CFG_IORDYEN;
+			break;
+		}
+
+		writel(ata_cfg, info->ide_addr + S3C_ATA_CFG);
+		writel(piotime[ide_mode - XFER_PIO_0],
+			info->ide_addr + S3C_ATA_PIO_TIME);
+	} else {
+		/* Default to PIO0 */
+		ata_cfg &= (~S3C_ATA_CFG_IORDYEN);

technically no need to ().

Quoted 31 lines
drivers/ata/pata_samsung.c new file +31 -0
+		writel(ata_cfg, info->ide_addr + S3C_ATA_CFG);
+		writel(piotime[0], info->ide_addr + S3C_ATA_PIO_TIME);
+	}
+}
+
+static void
+pata_s3c_set_piomode(struct ata_port *ap, struct ata_device *adev)
+{
+	struct s3c_ide_info *info = ap->host->private_data;
+
+	/* Configure IORDY based on PIO mode and also set the timing value */
+	pata_s3c_tune_chipset(info, adev->pio_mode);
+}
+
+/*
+ * Waits until the IDE controller is able to perform next read/write
+ * operation to the disk. Needed for 64XX series boards only.
+ */
+static int wait_for_host_ready(struct s3c_ide_info *info)
+{
+	ulong timeout;
+
+	/* wait for maximum of 20 msec */
+	timeout = jiffies + msecs_to_jiffies(20);
+	while (time_before(jiffies, timeout)) {
+		if ((readl(info->ide_addr + info->fifo_status_reg) >> 28) == 0)
+			return 0;
+	}
+	return -EBUSY;
+}
+

drivers/ata/pata_samsung.c line 131

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+/*
+ * Writes to one of the task file registers.
+ */
+static void ata_outb(struct ata_host *host, u8 addr, void __iomem *reg)
+{
+	struct s3c_ide_info *info = host->private_data;
+
+	wait_for_host_ready(info);
+	__raw_writeb(addr, reg);
+}

probably want writeb() here. you've used the non __raw versions elsewhere.

Quoted 103 lines
drivers/ata/pata_samsung.c new file +103 -0
+/*
+ * Reads from one of the task file registers.
+ */
+static u8 ata_inb(struct ata_host *host, void __iomem *reg)
+{
+	struct s3c_ide_info *info = host->private_data;
+	u8 temp;
+
+	wait_for_host_ready(info);
+	temp = __raw_readb(reg);
+	wait_for_host_ready(info);
+	temp = __raw_readb(info->ide_addr + S3C_ATA_PIO_RDATA);
+	return temp;
+}
+
+/*
+ * pata_s3c_tf_load - send taskfile registers to host controller
+ */
+static void pata_s3c_tf_load(struct ata_port *ap,
+				const struct ata_taskfile *tf)
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+	unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
+
+	if (tf->ctl != ap->last_ctl) {
+		if (ioaddr->ctl_addr)
+			ata_outb(ap->host, tf->ctl, ioaddr->ctl_addr);
+		ap->last_ctl = tf->ctl;
+		ata_wait_idle(ap);
+	}
+
+	if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
+		WARN_ON_ONCE(!ioaddr->ctl_addr);
+		ata_outb(ap->host, tf->hob_feature, ioaddr->feature_addr);
+		ata_outb(ap->host, tf->hob_nsect, ioaddr->nsect_addr);
+		ata_outb(ap->host, tf->hob_lbal, ioaddr->lbal_addr);
+		ata_outb(ap->host, tf->hob_lbam, ioaddr->lbam_addr);
+		ata_outb(ap->host, tf->hob_lbah, ioaddr->lbah_addr);
+	}
+
+	if (is_addr) {
+		ata_outb(ap->host, tf->feature, ioaddr->feature_addr);
+		ata_outb(ap->host, tf->nsect, ioaddr->nsect_addr);
+		ata_outb(ap->host, tf->lbal, ioaddr->lbal_addr);
+		ata_outb(ap->host, tf->lbam, ioaddr->lbam_addr);
+		ata_outb(ap->host, tf->lbah, ioaddr->lbah_addr);
+	}
+
+	if (tf->flags & ATA_TFLAG_DEVICE)
+		ata_outb(ap->host, tf->device, ioaddr->device_addr);
+
+	ata_wait_idle(ap);
+}
+
+/*
+ * pata_s3c_tf_read - input device's ATA taskfile shadow registers
+ */
+static void pata_s3c_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+
+	tf->command = ata_sff_check_status(ap);
+	tf->feature = ata_inb(ap->host, ioaddr->error_addr);
+	tf->nsect = ata_inb(ap->host, ioaddr->nsect_addr);
+	tf->lbal = ata_inb(ap->host, ioaddr->lbal_addr);
+	tf->lbam = ata_inb(ap->host, ioaddr->lbam_addr);
+	tf->lbah = ata_inb(ap->host, ioaddr->lbah_addr);
+	tf->device = ata_inb(ap->host, ioaddr->device_addr);
+
+	if (tf->flags & ATA_TFLAG_LBA48) {
+		if (likely(ioaddr->ctl_addr)) {
+			iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr);
+			tf->hob_feature = ata_inb(ap->host, ioaddr->error_addr);
+			tf->hob_nsect = ata_inb(ap->host, ioaddr->nsect_addr);
+			tf->hob_lbal = ata_inb(ap->host, ioaddr->lbal_addr);
+			tf->hob_lbam = ata_inb(ap->host, ioaddr->lbam_addr);
+			tf->hob_lbah = ata_inb(ap->host, ioaddr->lbah_addr);
+			iowrite8(tf->ctl, ioaddr->ctl_addr);
+			ap->last_ctl = tf->ctl;
+		} else
+			WARN_ON_ONCE(1);
+	}
+}
+
+/*
+ * pata_s3c_exec_command - issue ATA command to host controller
+ */
+static void pata_s3c_exec_command(struct ata_port *ap,
+				const struct ata_taskfile *tf)
+{
+	ata_outb(ap->host, tf->command, ap->ioaddr.command_addr);
+	ata_sff_pause(ap);
+}
+
+/*
+ * pata_s3c_check_status - Read device status register
+ */
+static u8 pata_s3c_check_status(struct ata_port *ap)
+{
+	return ata_inb(ap->host, ap->ioaddr.status_addr);
+}
+
+/*

drivers/ata/pata_samsung.c line 245

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -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 *temp_addr = (u16 *)buf;

hmm, how about calling it data_ptr instead of temp_addr?

drivers/ata/pata_samsung.c

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+	if (rw == READ) {
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			*temp_addr = __raw_readw(data_addr);
+			wait_for_host_ready(info);
+			*temp_addr = __raw_readw(info->ide_addr
+					+ S3C_ATA_PIO_RDATA)

think you want readw() here, please ensure consitency.

this also look a bit weird, you are writing to *temp_addr twice, could you simply dicscard the first read?

note, you say s3c64xx only needs wait_for_host_ready() but you always call it?

Quoted 26 lines
drivers/ata/pata_samsung.c new file +26 -0
+		}
+	} else {
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			writel(*temp_addr, data_addr);
+		}
+	}
+
+	return words << 1;
+}
+
+static struct scsi_host_template pata_s3c_sht = {
+	ATA_PIO_SHT(DRV_NAME),
+};
+
+static struct ata_port_operations pata_s3c_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.sff_check_status	= pata_s3c_check_status,
+	.sff_tf_load		= pata_s3c_tf_load,
+	.sff_tf_read		= pata_s3c_tf_read,
+	.sff_data_xfer		= pata_s3c_data_xfer,
+	.sff_exec_command	= pata_s3c_exec_command,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};
+

drivers/ata/pata_samsung.c line 289

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+static struct ata_port_operations pata_s5p_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};
+
+static void pata_s3c_enable(void *s3c_ide_regbase, u8 state)
+{
+	u32 temp = readl(s3c_ide_regbase + S3C_ATA_CTRL);
+	temp = state ? temp | 1 : temp & ~1;

you might want ()around the temp |1 and temp & ~1

Quoted 14 lines
drivers/ata/pata_samsung.c new file +14 -0
+	writel(temp, s3c_ide_regbase + S3C_ATA_CTRL);
+}
+
+static irqreturn_t pata_s3c_irq(int irq, void *dev_instance)
+{
+	struct ata_host *host = dev_instance;
+	struct s3c_ide_info *info = host->private_data;
+	u32 reg;
+
+	reg = readl(info->ide_addr + S3C_ATA_IRQ);
+	writel(reg, info->ide_addr + S3C_ATA_IRQ);
+
+	return ata_sff_interrupt(irq, dev_instance);
+}

drivers/ata/pata_samsung.c line 313

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+
+static void pata_s3c_setup_timing(struct s3c_ide_info *info)
+{
+	uint t1, t2, teoc, i;
+
+	uint pio_t1[5] = { 70, 50, 30, 30, 25 };
+	uint pio_t2[5] = { 290, 290, 290, 80, 70 };
+	uint pio_teoc[5] = { 240, 43, 10, 70, 25 };
+
+	ulong cycle_time = (uint) (1000000000 / clk_get_rate(info->clk));

ulong and uinit? surely pick one. you might want to keep UL and cajhnge 1000000000 to 1000000000UL

Quoted 64 lines
drivers/ata/pata_samsung.c new file +64 -0
+	for (i = 0; i < 5; i++) {
+		t1 = (pio_t1[i] / cycle_time) & 0x0f;
+		t2 = (pio_t2[i] / cycle_time) & 0xff;
+		teoc = (pio_teoc[i] / cycle_time) & 0xff;
+		piotime[i] = (teoc << 12) | (t2 << 4) | t1;
+	}
+}
+
+static void pata_s3c_hwinit(struct s3c_ide_info *info,
+				struct s3c_ide_platdata *pdata)
+{
+	/* Select true-ide as the internal operating mode*/
+	if (pdata && (pdata->cfg_mode))
+		pdata->cfg_mode(info->sfr_addr);
+
+	switch (info->cpu_type) {
+	case TYPE_S3C6400:
+		/* Configure as big endian and enable the i/f*/
+		pata_s3c_set_endian(info->ide_addr, 1);
+		pata_s3c_enable(info->ide_addr, 1);
+		mdelay(100);
+
+		/* Remove IRQ Status */
+		writel(0x1f, info->ide_addr + S3C_ATA_IRQ);
+		writel(0x1b, info->ide_addr + S3C_ATA_IRQ_MSK);
+	break;
+
+	case TYPE_S5PV210:
+	case TYPE_S5PC100:
+		/* Configure as little endian and enable the i/f */
+		pata_s3c_set_endian(info->ide_addr, 0);
+		pata_s3c_enable(info->ide_addr, 1);
+		mdelay(100);
+
+		/* Remove IRQ Status */
+		writel(0x3f, info->ide_addr + S3C_ATA_IRQ);
+		writel(0x3f, info->ide_addr + S3C_ATA_IRQ_MSK);
+	break;
+
+	default:
+		BUG();
+	}
+}
+
+static int __devinit pata_s3c_probe(struct platform_device *pdev)
+{
+	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");
+		return -ENOMEM;
+	}
+
+	info->irq = platform_get_irq(pdev, 0);

drivers/ata/pata_samsung.c line 388

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+	if (info->irq < 0) {
+		dev_err(dev, "could not obtain irq number\n");
+		ret = -ENODEV;
+		goto release_device_mem;
+	}
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		dev_err(dev, "failed to get mem resource\n");
+		ret = -ENODEV;

if i remeber correctly, you don't want to be returning -ENODEV as it will be ignored by the uper layers.

drivers/ata/pata_samsung.c line 393

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+		goto release_device_mem;
+	}
+
+	info->ide_addr = devm_ioremap(dev,
+				res->start, res->end - res->start + 1);

resource_size() is your friend here.

drivers/ata/pata_samsung.c line 400

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+	if (!info->ide_addr) {
+		dev_err(dev, "failed to map IO base address\n");
+		ret = -ENOMEM;
+		goto release_mem;
+	}
+
+	info->clk = clk_get(&pdev->dev, "cfcon");

need to do something about using explicit names here, should be clk_get(, NULL)

Quoted 60 lines
drivers/ata/pata_samsung.c new file +60 -0
+	if (IS_ERR(info->clk)) {
+		dev_err(dev, "failed to get access to cf controller clock\n");
+		ret = PTR_ERR(info->clk);
+		info->clk = NULL;
+		goto unmap;
+	}
+
+	if (clk_enable(info->clk)) {
+		dev_err(dev, "failed to enable clock source.\n");
+		goto clkerr;
+	}
+
+	/* init ata host */
+	host = ata_host_alloc(dev, 1);
+	if (!host) {
+		dev_err(dev, "failed to allocate ide host\n");
+		ret = -ENOMEM;
+		goto stop_clk;
+	}
+
+	ap = host->ports[0];
+	ap->flags |= ATA_FLAG_MMIO;
+	ap->pio_mask = ATA_PIO4;
+
+	if (cpu_type == TYPE_S3C6400) {
+		ap->ops = &pata_s3c_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;
+		info->fifo_status_reg = 0x94;
+	} else if (cpu_type == TYPE_S5PC100) {
+		ap->ops = &pata_s5p_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;
+		info->fifo_status_reg = 0x84;
+	} else {
+		ap->ops = &pata_s5p_port_ops;
+		info->fifo_status_reg = 0x84;
+	}
+
+	info->cpu_type = cpu_type;
+
+	if (!(info->irq)) {
+		ap->flags |= ATA_FLAG_PIO_POLLING;
+		ata_port_desc(ap, "no IRQ, using PIO polling\n");
+	}
+
+	ap->ioaddr.cmd_addr =  info->ide_addr + S3C_ATA_CMD;
+	ap->ioaddr.data_addr = info->ide_addr + S3C_ATA_PIO_DTR;
+	ap->ioaddr.error_addr = info->ide_addr + S3C_ATA_PIO_FED;
+	ap->ioaddr.feature_addr = info->ide_addr + S3C_ATA_PIO_FED;
+	ap->ioaddr.nsect_addr = info->ide_addr + S3C_ATA_PIO_SCR;
+	ap->ioaddr.lbal_addr = info->ide_addr + S3C_ATA_PIO_LLR;
+	ap->ioaddr.lbam_addr = info->ide_addr + S3C_ATA_PIO_LMR;
+	ap->ioaddr.lbah_addr = info->ide_addr + S3C_ATA_PIO_LHR;
+	ap->ioaddr.device_addr = info->ide_addr + S3C_ATA_PIO_DVR;
+	ap->ioaddr.status_addr = info->ide_addr + S3C_ATA_PIO_CSD;
+	ap->ioaddr.command_addr = info->ide_addr + S3C_ATA_PIO_CSD;
+	ap->ioaddr.altstatus_addr = info->ide_addr + S3C_ATA_PIO_DAD;
+	ap->ioaddr.ctl_addr = info->ide_addr + S3C_ATA_PIO_DAD;
+

drivers/ata/pata_samsung.c line 470

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+
+	ata_port_desc(ap, "mmio cmd 0x%llx ",
+			(unsigned long long)res->start);
+
+	host->private_data = info;
+
+	/* Calculates timing parameters for PIO mode */
+	pata_s3c_setup_timing(info);
+
+	if (pdata && (pdata->setup_gpio))

no need for () around the pdata->setup_gpio

drivers/ata/pata_samsung.c line 478

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+		pdata->setup_gpio();
+
+	/* Set endianness and enable the interface */
+	pata_s3c_hwinit(info, pdata);
+
+	return ata_host_activate(host, info->irq ? info->irq : 0,
+			info->irq ? pata_s3c_irq : NULL,
+			IRQF_DISABLED, &pata_s3c_sht);

do you really need to run with IRQs disabled?

Quoted 83 lines
drivers/ata/pata_samsung.c new file +83 -0
+	dev_set_drvdata(&pdev->dev, host);
+
+stop_clk:
+	clk_disable(info->clk);
+clkerr:
+	clk_put(info->clk);
+unmap:
+	devm_iounmap(dev, info->ide_addr);
+release_mem:
+	release_mem_region(res->start, res->end - res->start + 1);
+release_device_mem:
+	kfree(info);
+return ret;
+}
+
+static int __devexit pata_s3c_remove(struct platform_device *pdev)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	struct s3c_ide_info *info;
+	struct resource *res;
+
+	if (!host)
+		return 0;
+	info = host->private_data;
+
+	ata_host_detach(host);
+
+	devm_iounmap(&pdev->dev, info->ide_addr);
+	clk_disable(info->clk);
+	clk_put(info->clk);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	release_mem_region(res->start, res->end - res->start + 1);
+	kfree(info);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int pata_s3c_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	if (host)
+		return ata_host_suspend(host, state);
+	else
+		return 0;
+}
+
+static int pata_s3c_resume(struct platform_device *pdev)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	struct s3c_ide_platdata *pdata = pdev->dev.platform_data;
+	struct s3c_ide_info *info;
+
+	info = host->private_data;
+
+	if (host) {
+		pata_s3c_hwinit(info, pdata);
+		ata_host_resume(host);
+	}
+
+	return 0;
+}
+#endif
+
+/* driver device registration */
+static struct platform_device_id pata_s3c_driver_ids[] = {
+	{
+		.name		= "s3c6400-pata",
+		.driver_data	= TYPE_S3C6400,
+	}, {
+		.name		= "s5pc100-pata",
+		.driver_data	= TYPE_S5PC100,
+	}, {
+		.name		= "s5pv210-pata",
+		.driver_data	= TYPE_S5PV210,
+	},
+	{ }
+};
+
+MODULE_DEVICE_TABLE(platform, pata_s3c_driver_ids);
+
+static struct platform_driver pata_s3c_driver = {
+	.probe		= pata_s3c_probe,

drivers/ata/pata_samsung.c line 572

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+	.remove		= __devexit_p(pata_s3c_remove),
+	.id_table	= pata_s3c_driver_ids,
+	.driver		= {
+		.name		= DRV_NAME,
+		.owner		= THIS_MODULE,
+	},
+#ifdef CONFIG_PM
+	.suspend	= pata_s3c_suspend,
+	.resume		= pata_s3c_resume,
+#endif

please look at using the new pm_ops.

Quoted 21 lines
drivers/ata/pata_samsung.c new file +19 -0
+};
+
+static int __init pata_s3c_init(void)
+{
+	return platform_driver_register(&pata_s3c_driver);
+}
+
+static void __exit pata_s3c_exit(void)
+{
+	platform_driver_unregister(&pata_s3c_driver);
+}
+
+module_init(pata_s3c_init);
+module_exit(pata_s3c_exit);
+
+MODULE_AUTHOR("Abhilash Kesavan, <[email protected]>");
+MODULE_DESCRIPTION("low-level driver for Samsung PATA controller");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRV_VERSION);
Signature · 1 line
1.6.2.5

not bad, needs some cleanup.

Signature · 4 lines
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
author
#14 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

Quoted 6 lines · Ben Dooks
Quoted 4 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 34 lines
Quoted 7 lines
---
 drivers/ata/Kconfig        |    9 +
 drivers/ata/Makefile       |    1 +
 drivers/ata/pata_samsung.c |  591

++++++++++++++++++++++++++++++++++++++++++++

Quoted 26 lines
 3 files changed, 601 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/pata_samsung.c
drivers/ata/Kconfig +9 -0
index e68541f..ce40f66 100644
@@ -640,6 +640,15 @@ config PATA_RZ1000
 
 	  If unsure, say N.
 
+config PATA_SAMSUNG
+	tristate "Samsung SoC PATA support"
+	depends on S3C_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_SC1200
 	tristate "SC1200 PATA support"
 	depends on PCI
drivers/ata/Makefile +0 -1
index d0a93c4..0b6d29a 100644
--- a/drivers/ata/Makefile
Quoted 8 lines

drivers/ata/Makefile obj-$(CONFIG_PATA_RADISYS) += pata_radisys.o · line 65

Quoted 6 lines

+++ b/drivers/ata/Makefile

drivers/ata/Makefile +1 -0
@@ -62,6 +62,7 @@ obj-$(CONFIG_PATA_RADISYS)	+= pata_radisys.o
 obj-$(CONFIG_PATA_RB532)	+= pata_rb532_cf.o
 obj-$(CONFIG_PATA_RDC)		+= pata_rdc.o
 obj-$(CONFIG_PATA_RZ1000)	+= pata_rz1000.o
+obj-$(CONFIG_PATA_SAMSUNG)	+= pata_samsung.o

do you want to call it pata_samsung_soc.o instead, in case samsung make otehr types of pata controller?

Will change the name to pata_samsung_cf.

Quoted 8 lines
Quoted 8 lines
drivers/ata/Makefile +0 -0
 obj-$(CONFIG_PATA_SC1200)	+= pata_sc1200.o
 obj-$(CONFIG_PATA_SERVERWORKS)	+= pata_serverworks.o
 obj-$(CONFIG_PATA_SIL680)	+= pata_sil680.o
drivers/ata/pata_samsung.c new file +0 -0
new file mode 100644
index 0000000..14381e4
Quoted 8 lines

drivers/ata/pata_samsung.c line 6

Quoted 7 lines
drivers/ata/pata_samsung.c new file +6 -0
@@ -0,0 +1,591 @@
+/* linux/drivers/ata/pata_samsung.c
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * PATA driver for Samsung SoC's.

SoCs.

OK

Quoted 1 line

drivers/ata/pata_samsung.c line 7

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+ * Supports CF Interface in True IDE mode. Currently only PIO mode has

been

Quoted 7 lines

drivers/ata/pata_samsung.c

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+ * implemented; UDMA support has to be added.
+ *
+ * Based on:
+ *	PATA driver for AT91SAM9260 Static Memory Controller
+ *	PATA driver for Toshiba SCC controller
+ *
+ * This program is free software; you can redistribute it and/or modify

it

Quoted 49 lines
Quoted 38 lines
drivers/ata/pata_samsung.c new file +38 -0
+ * under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/libata.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <plat/ata.h>
+#include <plat/regs-ata.h>
+
+#define DRV_NAME "pata_samsung"
+#define DRV_VERSION "0.1"
+
+enum s3c_cpu_type {
+	TYPE_S3C6400,
+	TYPE_S5PC100,
+	TYPE_S5PV210,
+};
+
+/*
+ * struct s3c_ide_info - S3C PATA instance.
+ * @clk: The clock resource for this controller.
+ * @ide_addr: The area mapped for the hardware registers.
+ * @sfr_addr: The area mapped for the special function registers.
+ * @irq: The IRQ number we are using.
+ * @cpu_type: The exact type of this controller.
+ * @fifo_status_reg: The ATA_FIFO_STATUS register offset.
+ */
+struct s3c_ide_info {
+	struct clk *clk;
+	void __iomem *ide_addr;
+	void __iomem *sfr_addr;
+	unsigned int irq;

drivers/ata/pata_samsung.c

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+	enum s3c_cpu_type cpu_type;
+	unsigned int fifo_status_reg;
+};
+
+static unsigned long piotime[5];
+
+static void pata_s3c_set_endian(void *s3c_ide_regbase, u8 mode)
+{
+	u32 reg = readl(s3c_ide_regbase + S3C_ATA_CFG);
+	reg = mode ? (reg & ~S3C_ATA_CFG_SWAP) : (reg |

S3C_ATA_CFG_SWAP);

Quoted 4 lines

drivers/ata/pata_samsung.c

Quoted 4 lines
drivers/ata/pata_samsung.c new file +4 -0
+	writel(reg, s3c_ide_regbase + S3C_ATA_CFG);
+}
+
+static void pata_s3c_tune_chipset(struct s3c_ide_info *info, u8

ide_mode)

Quoted 17 lines
Quoted 17 lines
drivers/ata/pata_samsung.c new file +17 -0
+{
+	ulong ata_cfg = readl(info->ide_addr + S3C_ATA_CFG);
+
+	/* IORDY is enabled for modes > PIO2 */
+	if (XFER_PIO_0 <= ide_mode && ide_mode <= XFER_PIO_4) {
+
+		switch (ide_mode) {
+		case XFER_PIO_0:
+		case XFER_PIO_1:
+		case XFER_PIO_2:
+			ata_cfg &= (~S3C_ATA_CFG_IORDYEN);
+			break;
+		case XFER_PIO_3:
+		case XFER_PIO_4:
+			ata_cfg |= S3C_ATA_CFG_IORDYEN;
+			break;
+		}
Quoted 8 lines

drivers/ata/pata_samsung.c line 90

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+
+		writel(ata_cfg, info->ide_addr + S3C_ATA_CFG);
+		writel(piotime[ide_mode - XFER_PIO_0],
+			info->ide_addr + S3C_ATA_PIO_TIME);
+	} else {
+		/* Default to PIO0 */
+		ata_cfg &= (~S3C_ATA_CFG_IORDYEN);

technically no need to ().

OK

Quoted 18 lines
Quoted 18 lines
drivers/ata/pata_samsung.c new file +18 -0
+		writel(ata_cfg, info->ide_addr + S3C_ATA_CFG);
+		writel(piotime[0], info->ide_addr + S3C_ATA_PIO_TIME);
+	}
+}
+
+static void
+pata_s3c_set_piomode(struct ata_port *ap, struct ata_device *adev)
+{
+	struct s3c_ide_info *info = ap->host->private_data;
+
+	/* Configure IORDY based on PIO mode and also set the timing value */
+	pata_s3c_tune_chipset(info, adev->pio_mode);
+}
+
+/*
+ * Waits until the IDE controller is able to perform next read/write
+ * operation to the disk. Needed for 64XX series boards only.
+ */
Quoted 8 lines

drivers/ata/pata_samsung.c

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+static int wait_for_host_ready(struct s3c_ide_info *info)
+{
+	ulong timeout;
+
+	/* wait for maximum of 20 msec */
+	timeout = jiffies + msecs_to_jiffies(20);
+	while (time_before(jiffies, timeout)) {
+		if ((readl(info->ide_addr + info->fifo_status_reg) >> 28) ==

0)

Quoted 9 lines
Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+			return 0;
+	}
+	return -EBUSY;
+}
+
+/*
+ * Writes to one of the task file registers.
+ */
+static void ata_outb(struct ata_host *host, u8 addr, void __iomem *reg)
Quoted 9 lines

drivers/ata/pata_samsung.c line 131

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+{
+	struct s3c_ide_info *info = host->private_data;
+
+	wait_for_host_ready(info);
+	__raw_writeb(addr, reg);
+}

probably want writeb() here. you've used the non __raw versions elsewhere.

OK

Quoted 50 lines
Quoted 50 lines
drivers/ata/pata_samsung.c new file +50 -0
+/*
+ * Reads from one of the task file registers.
+ */
+static u8 ata_inb(struct ata_host *host, void __iomem *reg)
+{
+	struct s3c_ide_info *info = host->private_data;
+	u8 temp;
+
+	wait_for_host_ready(info);
+	temp = __raw_readb(reg);
+	wait_for_host_ready(info);
+	temp = __raw_readb(info->ide_addr + S3C_ATA_PIO_RDATA);
+	return temp;
+}
+
+/*
+ * pata_s3c_tf_load - send taskfile registers to host controller
+ */
+static void pata_s3c_tf_load(struct ata_port *ap,
+				const struct ata_taskfile *tf)
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+	unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
+
+	if (tf->ctl != ap->last_ctl) {
+		if (ioaddr->ctl_addr)
+			ata_outb(ap->host, tf->ctl, ioaddr->ctl_addr);
+		ap->last_ctl = tf->ctl;
+		ata_wait_idle(ap);
+	}
+
+	if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
+		WARN_ON_ONCE(!ioaddr->ctl_addr);
+		ata_outb(ap->host, tf->hob_feature, ioaddr->feature_addr);
+		ata_outb(ap->host, tf->hob_nsect, ioaddr->nsect_addr);
+		ata_outb(ap->host, tf->hob_lbal, ioaddr->lbal_addr);
+		ata_outb(ap->host, tf->hob_lbam, ioaddr->lbam_addr);
+		ata_outb(ap->host, tf->hob_lbah, ioaddr->lbah_addr);
+	}
+
+	if (is_addr) {
+		ata_outb(ap->host, tf->feature, ioaddr->feature_addr);
+		ata_outb(ap->host, tf->nsect, ioaddr->nsect_addr);
+		ata_outb(ap->host, tf->lbal, ioaddr->lbal_addr);
+		ata_outb(ap->host, tf->lbam, ioaddr->lbam_addr);
+		ata_outb(ap->host, tf->lbah, ioaddr->lbah_addr);
+	}
+
+	if (tf->flags & ATA_TFLAG_DEVICE)
+		ata_outb(ap->host, tf->device, ioaddr->device_addr);
Quoted 8 lines

drivers/ata/pata_samsung.c

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+
+	ata_wait_idle(ap);
+}
+
+/*
+ * pata_s3c_tf_read - input device's ATA taskfile shadow registers
+ */
+static void pata_s3c_tf_read(struct ata_port *ap, struct ata_taskfile

*tf)

Quoted 7 lines
Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+
+	tf->command = ata_sff_check_status(ap);
+	tf->feature = ata_inb(ap->host, ioaddr->error_addr);
+	tf->nsect = ata_inb(ap->host, ioaddr->nsect_addr);
+	tf->lbal = ata_inb(ap->host, ioaddr->lbal_addr);
Quoted 8 lines

drivers/ata/pata_samsung.c

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+	tf->lbam = ata_inb(ap->host, ioaddr->lbam_addr);
+	tf->lbah = ata_inb(ap->host, ioaddr->lbah_addr);
+	tf->device = ata_inb(ap->host, ioaddr->device_addr);
+
+	if (tf->flags & ATA_TFLAG_LBA48) {
+		if (likely(ioaddr->ctl_addr)) {
+			iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr);
+			tf->hob_feature = ata_inb(ap->host,

ioaddr->error_addr);

Quoted 1 line

drivers/ata/pata_samsung.c line 205

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+			tf->hob_nsect = ata_inb(ap->host,

ioaddr->nsect_addr);

Quoted 24 lines
Quoted 24 lines
drivers/ata/pata_samsung.c new file +24 -0
+			tf->hob_lbal = ata_inb(ap->host, ioaddr->lbal_addr);
+			tf->hob_lbam = ata_inb(ap->host, ioaddr->lbam_addr);
+			tf->hob_lbah = ata_inb(ap->host, ioaddr->lbah_addr);
+			iowrite8(tf->ctl, ioaddr->ctl_addr);
+			ap->last_ctl = tf->ctl;
+		} else
+			WARN_ON_ONCE(1);
+	}
+}
+
+/*
+ * pata_s3c_exec_command - issue ATA command to host controller
+ */
+static void pata_s3c_exec_command(struct ata_port *ap,
+				const struct ata_taskfile *tf)
+{
+	ata_outb(ap->host, tf->command, ap->ioaddr.command_addr);
+	ata_sff_pause(ap);
+}
+
+/*
+ * pata_s3c_check_status - Read device status register
+ */
+static u8 pata_s3c_check_status(struct ata_port *ap)
Quoted 8 lines

drivers/ata/pata_samsung.c

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+{
+	return ata_inb(ap->host, ap->ioaddr.status_addr);
+}
+
+/*
+ * pata_s3c_data_xfer - Transfer data by PIO
+ */
+unsigned int pata_s3c_data_xfer(struct ata_device *dev, unsigned char

*buf,

Quoted 10 lines

drivers/ata/pata_samsung.c line 245

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -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 *temp_addr = (u16 *)buf;

hmm, how about calling it data_ptr instead of temp_addr?

OK

Quoted 10 lines

drivers/ata/pata_samsung.c

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+	if (rw == READ) {
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			*temp_addr = __raw_readw(data_addr);
+			wait_for_host_ready(info);
+			*temp_addr = __raw_readw(info->ide_addr
+					+ S3C_ATA_PIO_RDATA)

think you want readw() here, please ensure consitency.

Quoted 6 lines

this also look a bit weird, you are writing to *temp_addr twice, could you simply dicscard the first read?

note, you say s3c64xx only needs wait_for_host_ready() but you always call it?

wait_for_host_ready is called via pata_s3c_port_ops which is only for 64xx.

Quoted 29 lines
Quoted 29 lines
drivers/ata/pata_samsung.c new file +29 -0
+		}
+	} else {
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			writel(*temp_addr, data_addr);
+		}
+	}
+
+	return words << 1;
+}
+
+static struct scsi_host_template pata_s3c_sht = {
+	ATA_PIO_SHT(DRV_NAME),
+};
+
+static struct ata_port_operations pata_s3c_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.sff_check_status	= pata_s3c_check_status,
+	.sff_tf_load		= pata_s3c_tf_load,
+	.sff_tf_read		= pata_s3c_tf_read,
+	.sff_data_xfer		= pata_s3c_data_xfer,
+	.sff_exec_command	= pata_s3c_exec_command,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};
+
+static struct ata_port_operations pata_s5p_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.qc_prep		= ata_noop_qc_prep,
Quoted 8 lines

drivers/ata/pata_samsung.c line 289

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+	.set_piomode		= pata_s3c_set_piomode,
+};
+
+static void pata_s3c_enable(void *s3c_ide_regbase, u8 state)
+{
+	u32 temp = readl(s3c_ide_regbase + S3C_ATA_CTRL);
+	temp = state ? temp | 1 : temp & ~1;

you might want ()around the temp |1 and temp & ~1

OK

Quoted 19 lines
Quoted 19 lines
drivers/ata/pata_samsung.c new file +19 -0
+	writel(temp, s3c_ide_regbase + S3C_ATA_CTRL);
+}
+
+static irqreturn_t pata_s3c_irq(int irq, void *dev_instance)
+{
+	struct ata_host *host = dev_instance;
+	struct s3c_ide_info *info = host->private_data;
+	u32 reg;
+
+	reg = readl(info->ide_addr + S3C_ATA_IRQ);
+	writel(reg, info->ide_addr + S3C_ATA_IRQ);
+
+	return ata_sff_interrupt(irq, dev_instance);
+}
+
+static void pata_s3c_setup_timing(struct s3c_ide_info *info)
+{
+	uint t1, t2, teoc, i;
+
Quoted 9 lines

drivers/ata/pata_samsung.c line 313

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+	uint pio_t1[5] = { 70, 50, 30, 30, 25 };
+	uint pio_t2[5] = { 290, 290, 290, 80, 70 };
+	uint pio_teoc[5] = { 240, 43, 10, 70, 25 };
+
+	ulong cycle_time = (uint) (1000000000 / clk_get_rate(info->clk));

ulong and uinit? surely pick one. you might want to keep UL and cajhnge 1000000000 to 1000000000UL

OK

Quoted 69 lines
Quoted 69 lines
drivers/ata/pata_samsung.c new file +69 -0
+	for (i = 0; i < 5; i++) {
+		t1 = (pio_t1[i] / cycle_time) & 0x0f;
+		t2 = (pio_t2[i] / cycle_time) & 0xff;
+		teoc = (pio_teoc[i] / cycle_time) & 0xff;
+		piotime[i] = (teoc << 12) | (t2 << 4) | t1;
+	}
+}
+
+static void pata_s3c_hwinit(struct s3c_ide_info *info,
+				struct s3c_ide_platdata *pdata)
+{
+	/* Select true-ide as the internal operating mode*/
+	if (pdata && (pdata->cfg_mode))
+		pdata->cfg_mode(info->sfr_addr);
+
+	switch (info->cpu_type) {
+	case TYPE_S3C6400:
+		/* Configure as big endian and enable the i/f*/
+		pata_s3c_set_endian(info->ide_addr, 1);
+		pata_s3c_enable(info->ide_addr, 1);
+		mdelay(100);
+
+		/* Remove IRQ Status */
+		writel(0x1f, info->ide_addr + S3C_ATA_IRQ);
+		writel(0x1b, info->ide_addr + S3C_ATA_IRQ_MSK);
+	break;
+
+	case TYPE_S5PV210:
+	case TYPE_S5PC100:
+		/* Configure as little endian and enable the i/f */
+		pata_s3c_set_endian(info->ide_addr, 0);
+		pata_s3c_enable(info->ide_addr, 1);
+		mdelay(100);
+
+		/* Remove IRQ Status */
+		writel(0x3f, info->ide_addr + S3C_ATA_IRQ);
+		writel(0x3f, info->ide_addr + S3C_ATA_IRQ_MSK);
+	break;
+
+	default:
+		BUG();
+	}
+}
+
+static int __devinit pata_s3c_probe(struct platform_device *pdev)
+{
+	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");
+		return -ENOMEM;
+	}
+
+	info->irq = platform_get_irq(pdev, 0);
+	if (info->irq < 0) {
+		dev_err(dev, "could not obtain irq number\n");
+		ret = -ENODEV;
+		goto release_device_mem;
+	}
Quoted 9 lines

drivers/ata/pata_samsung.c line 388

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		dev_err(dev, "failed to get mem resource\n");
+		ret = -ENODEV;

if i remeber correctly, you don't want to be returning -ENODEV as it will be ignored by the uper layers.

Will replace with EINVAL.

Quoted 8 lines

drivers/ata/pata_samsung.c line 393

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+		goto release_device_mem;
+	}
+
+	info->ide_addr = devm_ioremap(dev,
+				res->start, res->end - res->start + 1);

resource_size() is your friend here.

OK

Quoted 9 lines

drivers/ata/pata_samsung.c line 400

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+	if (!info->ide_addr) {
+		dev_err(dev, "failed to map IO base address\n");
+		ret = -ENOMEM;
+		goto release_mem;
+	}
+
+	info->clk = clk_get(&pdev->dev, "cfcon");

need to do something about using explicit names here, should be clk_get(,

NULL)

Quoted 1 line

OK

Quoted 2 lines

drivers/ata/pata_samsung.c line 399

Quoted 2 lines
drivers/ata/pata_samsung.c new file +2 -0
+	if (IS_ERR(info->clk)) {
+		dev_err(dev, "failed to get access to cf controller

clock\n");

Quoted 61 lines
Quoted 61 lines
drivers/ata/pata_samsung.c new file +61 -0
+		ret = PTR_ERR(info->clk);
+		info->clk = NULL;
+		goto unmap;
+	}
+
+	if (clk_enable(info->clk)) {
+		dev_err(dev, "failed to enable clock source.\n");
+		goto clkerr;
+	}
+
+	/* init ata host */
+	host = ata_host_alloc(dev, 1);
+	if (!host) {
+		dev_err(dev, "failed to allocate ide host\n");
+		ret = -ENOMEM;
+		goto stop_clk;
+	}
+
+	ap = host->ports[0];
+	ap->flags |= ATA_FLAG_MMIO;
+	ap->pio_mask = ATA_PIO4;
+
+	if (cpu_type == TYPE_S3C6400) {
+		ap->ops = &pata_s3c_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;
+		info->fifo_status_reg = 0x94;
+	} else if (cpu_type == TYPE_S5PC100) {
+		ap->ops = &pata_s5p_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;
+		info->fifo_status_reg = 0x84;
+	} else {
+		ap->ops = &pata_s5p_port_ops;
+		info->fifo_status_reg = 0x84;
+	}
+
+	info->cpu_type = cpu_type;
+
+	if (!(info->irq)) {
+		ap->flags |= ATA_FLAG_PIO_POLLING;
+		ata_port_desc(ap, "no IRQ, using PIO polling\n");
+	}
+
+	ap->ioaddr.cmd_addr =  info->ide_addr + S3C_ATA_CMD;
+	ap->ioaddr.data_addr = info->ide_addr + S3C_ATA_PIO_DTR;
+	ap->ioaddr.error_addr = info->ide_addr + S3C_ATA_PIO_FED;
+	ap->ioaddr.feature_addr = info->ide_addr + S3C_ATA_PIO_FED;
+	ap->ioaddr.nsect_addr = info->ide_addr + S3C_ATA_PIO_SCR;
+	ap->ioaddr.lbal_addr = info->ide_addr + S3C_ATA_PIO_LLR;
+	ap->ioaddr.lbam_addr = info->ide_addr + S3C_ATA_PIO_LMR;
+	ap->ioaddr.lbah_addr = info->ide_addr + S3C_ATA_PIO_LHR;
+	ap->ioaddr.device_addr = info->ide_addr + S3C_ATA_PIO_DVR;
+	ap->ioaddr.status_addr = info->ide_addr + S3C_ATA_PIO_CSD;
+	ap->ioaddr.command_addr = info->ide_addr + S3C_ATA_PIO_CSD;
+	ap->ioaddr.altstatus_addr = info->ide_addr + S3C_ATA_PIO_DAD;
+	ap->ioaddr.ctl_addr = info->ide_addr + S3C_ATA_PIO_DAD;
+
+
+	ata_port_desc(ap, "mmio cmd 0x%llx ",
+			(unsigned long long)res->start);
Quoted 8 lines

drivers/ata/pata_samsung.c line 470

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+
+	host->private_data = info;
+
+	/* Calculates timing parameters for PIO mode */
+	pata_s3c_setup_timing(info);
+
+	if (pdata && (pdata->setup_gpio))

no need for () around the pdata->setup_gpio

OK

Quoted 11 lines

drivers/ata/pata_samsung.c line 478

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+		pdata->setup_gpio();
+
+	/* Set endianness and enable the interface */
+	pata_s3c_hwinit(info, pdata);
+
+	return ata_host_activate(host, info->irq ? info->irq : 0,
+			info->irq ? pata_s3c_irq : NULL,
+			IRQF_DISABLED, &pata_s3c_sht);

do you really need to run with IRQs disabled?

No.. will correct it

Quoted 31 lines
Quoted 31 lines
drivers/ata/pata_samsung.c new file +31 -0
+	dev_set_drvdata(&pdev->dev, host);
+
+stop_clk:
+	clk_disable(info->clk);
+clkerr:
+	clk_put(info->clk);
+unmap:
+	devm_iounmap(dev, info->ide_addr);
+release_mem:
+	release_mem_region(res->start, res->end - res->start + 1);
+release_device_mem:
+	kfree(info);
+return ret;
+}
+
+static int __devexit pata_s3c_remove(struct platform_device *pdev)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	struct s3c_ide_info *info;
+	struct resource *res;
+
+	if (!host)
+		return 0;
+	info = host->private_data;
+
+	ata_host_detach(host);
+
+	devm_iounmap(&pdev->dev, info->ide_addr);
+	clk_disable(info->clk);
+	clk_put(info->clk);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Quoted 8 lines

drivers/ata/pata_samsung.c

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+	release_mem_region(res->start, res->end - res->start + 1);
+	kfree(info);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int pata_s3c_suspend(struct platform_device *pdev, pm_message_t

state)

Quoted 47 lines
Quoted 47 lines
drivers/ata/pata_samsung.c new file +47 -0
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	if (host)
+		return ata_host_suspend(host, state);
+	else
+		return 0;
+}
+
+static int pata_s3c_resume(struct platform_device *pdev)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	struct s3c_ide_platdata *pdata = pdev->dev.platform_data;
+	struct s3c_ide_info *info;
+
+	info = host->private_data;
+
+	if (host) {
+		pata_s3c_hwinit(info, pdata);
+		ata_host_resume(host);
+	}
+
+	return 0;
+}
+#endif
+
+/* driver device registration */
+static struct platform_device_id pata_s3c_driver_ids[] = {
+	{
+		.name		= "s3c6400-pata",
+		.driver_data	= TYPE_S3C6400,
+	}, {
+		.name		= "s5pc100-pata",
+		.driver_data	= TYPE_S5PC100,
+	}, {
+		.name		= "s5pv210-pata",
+		.driver_data	= TYPE_S5PV210,
+	},
+	{ }
+};
+
+MODULE_DEVICE_TABLE(platform, pata_s3c_driver_ids);
+
+static struct platform_driver pata_s3c_driver = {
+	.probe		= pata_s3c_probe,
+	.remove		= __devexit_p(pata_s3c_remove),
+	.id_table	= pata_s3c_driver_ids,
+	.driver		= {
Quoted 9 lines

drivers/ata/pata_samsung.c line 572

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+		.name		= DRV_NAME,
+		.owner		= THIS_MODULE,
+	},
+#ifdef CONFIG_PM
+	.suspend	= pata_s3c_suspend,
+	.resume		= pata_s3c_resume,
+#endif

please look at using the new pm_ops.

Will use dev_pm_ops.

Quoted 15 lines
Quoted 15 lines
drivers/ata/pata_samsung.c new file +15 -0
+};
+
+static int __init pata_s3c_init(void)
+{
+	return platform_driver_register(&pata_s3c_driver);
+}
+
+static void __exit pata_s3c_exit(void)
+{
+	platform_driver_unregister(&pata_s3c_driver);
+}
+
+module_init(pata_s3c_init);
+module_exit(pata_s3c_exit);
+
Quoted 9 lines
Quoted 6 lines
drivers/ata/pata_samsung.c new file +4 -1
+MODULE_AUTHOR("Abhilash Kesavan, <[email protected]>");
+MODULE_DESCRIPTION("low-level driver for Samsung PATA controller");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRV_VERSION);
--

1.6.2.5

not bad, needs some cleanup.

Thanks.

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

#15 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

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

---

?drivers/ata/Kconfig ? ? ? ?| ? ?9 +
?drivers/ata/Makefile ? ? ? | ? ?1 +
?drivers/ata/pata_samsung.c | ?591

Fasten your seat belts before reading further....

Rather than generic 'samsung', I would suggest the driver named after the SoC, that is supported first(chronologically) in mainline kernel. All newer SoCs should be simply taken to contain the controller of that SoC. Otherwise, the same naming problem comes back to haunt us should Samsung decides to use a different IP in future SoCs. What would we call that driver? pata_samsung_v2.c ?

my two sparks
Jassi

#16 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

Quoted 13 lines · Jassi Brar
Quoted 11 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.

---

?drivers/ata/Kconfig ? ? ? ?| ? ?9 +
?drivers/ata/Makefile ? ? ? | ? ?1 +
?drivers/ata/pata_samsung.c | ?591
Quoted 8 lines

Fasten your seat belts before reading further....

Rather than generic 'samsung', I would suggest the driver named after the SoC, that is supported first(chronologically) in mainline kernel. All newer SoCs should be simply taken to contain the controller of that SoC. Otherwise, the same naming problem comes back to haunt us should Samsung decides to use a different IP in future SoCs. What would we call that driver? pata_samsung_v2.c ?

I'm not so bothered, but it could be pata_samsung_cfcon or anything, a new block could be called pata_samsung_v2 or fred for all I really care about this.

Quoted 2 lines

my two sparks
Jassi

Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#17 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

Quoted 23 lines · Ben Dooks
Quoted 13 lines · Jassi Brar
Quoted 11 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.

---

?drivers/ata/Kconfig ? ? ? ?| ? ?9 +
?drivers/ata/Makefile ? ? ? | ? ?1 +
?drivers/ata/pata_samsung.c | ?591
Quoted 8 lines

Fasten your seat belts before reading further....

Rather than generic 'samsung', I would suggest the driver named after the SoC, that is supported first(chronologically) in mainline kernel. All newer SoCs should be simply taken to contain the controller of that SoC. Otherwise, the same naming problem comes back to haunt us should Samsung decides to use a different IP in future SoCs. What would we call that driver? pata_samsung_v2.c ?

Quoted 2 lines

I'm not so bothered, but it could be pata_samsung_cfcon or anything, a new block could be called pata_samsung_v2 or fred

well, then pata_samsung.c is better for we know chances of this IP change in future SoCs are quite slim.
And even if it does change we shall call it pata_samsung_really_final_this_time.c ;)

#18 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

In reply to Kukjin Kim

Hello.

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

drivers/ata/pata_samsung.c new file +0 -0
new file mode 100644
index 0000000..14381e4
@@ -0,0 +1,591 @@

[...]

drivers/ata/pata_samsung.c line 77

Quoted 12 lines
drivers/ata/pata_samsung.c new file +12 -0
+static void pata_s3c_tune_chipset(struct s3c_ide_info *info, u8 ide_mode)
+{
+	ulong ata_cfg = readl(info->ide_addr + S3C_ATA_CFG);
+
+	/* IORDY is enabled for modes > PIO2 */
+	if (XFER_PIO_0 <= ide_mode && ide_mode <= XFER_PIO_4) {
+
+		switch (ide_mode) {
+		case XFER_PIO_0:
+		case XFER_PIO_1:
+		case XFER_PIO_2:
+			ata_cfg &= (~S3C_ATA_CFG_IORDYEN);

Useless parens.

drivers/ata/pata_samsung.c line 81

Quoted 4 lines
drivers/ata/pata_samsung.c new file +4 -0
+			break;
+		case XFER_PIO_3:
+		case XFER_PIO_4:
+			ata_cfg |= S3C_ATA_CFG_IORDYEN;

IORDY should be controlled by ata_id_pio_need_iordy(), not by mode
number. PIO2 also can have IODRY enabled.

drivers/ata/pata_samsung.c line 92

Quoted 11 lines
drivers/ata/pata_samsung.c new file +11 -0
+			break;
+		}
+
+		writel(ata_cfg, info->ide_addr + S3C_ATA_CFG);
+		writel(piotime[ide_mode - XFER_PIO_0],
+			info->ide_addr + S3C_ATA_PIO_TIME);
+	} else {
+		/* Default to PIO0 */
+		ata_cfg &= (~S3C_ATA_CFG_IORDYEN);
+		writel(ata_cfg, info->ide_addr + S3C_ATA_CFG);
+		writel(piotime[0], info->ide_addr + S3C_ATA_PIO_TIME);

If you don't support DMA modes or modes higher than PIO4 (PIO5 and
PIO6 would have been good for CF though), just do nothing.

drivers/ata/pata_samsung.c line 102

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+	}
+}
+
+static void
+pata_s3c_set_piomode(struct ata_port *ap, struct ata_device *adev)
+{
+	struct s3c_ide_info *info = ap->host->private_data;
+
+	/* Configure IORDY based on PIO mode and also set the timing value */
+	pata_s3c_tune_chipset(info, adev->pio_mode);

Don't see why you need a separate function for that. Maybe in
preparation to UDMA support?

drivers/ata/pata_samsung.c line 130

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+/*
+ * Writes to one of the task file registers.
+ */
+static void ata_outb(struct ata_host *host, u8 addr, void __iomem *reg)
+{
+	struct s3c_ide_info *info = host->private_data;
+
+	wait_for_host_ready(info);
+	__raw_writeb(addr, reg);

You should use write?() or __raw_write?() consistently...

drivers/ata/pata_samsung.c line 158

Quoted 11 lines
drivers/ata/pata_samsung.c new file +11 -0
+/*
+ * pata_s3c_tf_load - send taskfile registers to host controller
+ */
+static void pata_s3c_tf_load(struct ata_port *ap,
+				const struct ata_taskfile *tf)
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+	unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
+
+	if (tf->ctl != ap->last_ctl) {
+		if (ioaddr->ctl_addr)
    This register does exist and you assign ioaddr->ctl_addr in 

pata_s3c_probe(), hence the check is pointless.

drivers/ata/pata_samsung.c line 165

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+			ata_outb(ap->host, tf->ctl, ioaddr->ctl_addr);
+		ap->last_ctl = tf->ctl;
+		ata_wait_idle(ap);
+	}
+
+	if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
+		WARN_ON_ONCE(!ioaddr->ctl_addr);

You don't need this either.

drivers/ata/pata_samsung.c line 194

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+/*
+ * pata_s3c_tf_read - input device's ATA taskfile shadow registers
+ */
+static void pata_s3c_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+
+	tf->command = ata_sff_check_status(ap);

But you have overriden this method, so ata_sff_check_status()
shouldn't work!

drivers/ata/pata_samsung.c line 203

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+	tf->feature = ata_inb(ap->host, ioaddr->error_addr);
+	tf->nsect = ata_inb(ap->host, ioaddr->nsect_addr);
+	tf->lbal = ata_inb(ap->host, ioaddr->lbal_addr);
+	tf->lbam = ata_inb(ap->host, ioaddr->lbam_addr);
+	tf->lbah = ata_inb(ap->host, ioaddr->lbah_addr);
+	tf->device = ata_inb(ap->host, ioaddr->device_addr);
+
+	if (tf->flags & ATA_TFLAG_LBA48) {
+		if (likely(ioaddr->ctl_addr)) {

Not just likely, it's always true. Emilinate the check please.

drivers/ata/pata_samsung.c line 213

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+			iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr);
+			tf->hob_feature = ata_inb(ap->host, ioaddr->error_addr);
+			tf->hob_nsect = ata_inb(ap->host, ioaddr->nsect_addr);
+			tf->hob_lbal = ata_inb(ap->host, ioaddr->lbal_addr);
+			tf->hob_lbam = ata_inb(ap->host, ioaddr->lbam_addr);
+			tf->hob_lbah = ata_inb(ap->host, ioaddr->lbah_addr);
+			iowrite8(tf->ctl, ioaddr->ctl_addr);
+			ap->last_ctl = tf->ctl;
+		} else
+			WARN_ON_ONCE(1);

Not needed.

drivers/ata/pata_samsung.c line 247

Quoted 13 lines
drivers/ata/pata_samsung.c new file +13 -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 *temp_addr = (u16 *)buf;
+
+	if (rw == READ) {

{} not needed.

drivers/ata/pata_samsung.c line 255

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			*temp_addr = __raw_readw(data_addr);
+			wait_for_host_ready(info);
+			*temp_addr = __raw_readw(info->ide_addr
+					+ S3C_ATA_PIO_RDATA);
+		}
+	} else {

{} not needed.

drivers/ata/pata_samsung.c line 260

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			writel(*temp_addr, data_addr);
+		}
+	}

Well, if this is pere CF case, 'buflen' can't be odd, but otherwise
you should handle that case...

drivers/ata/pata_samsung.c line 271

Quoted 11 lines
drivers/ata/pata_samsung.c new file +11 -0
+
+	return words << 1;
+}
+
+static struct scsi_host_template pata_s3c_sht = {
+	ATA_PIO_SHT(DRV_NAME),
+};
+
+static struct ata_port_operations pata_s3c_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.sff_check_status	= pata_s3c_check_status,

Since simple iowrite8() isn't enough in your case, you also need to
override sff_dev_select(), sff_check_altstatus(), and sff_set_devctl() methods...

Quoted 13 lines
drivers/ata/pata_samsung.c new file +13 -0
+	.sff_tf_load		= pata_s3c_tf_load,
+	.sff_tf_read		= pata_s3c_tf_read,
+	.sff_data_xfer		= pata_s3c_data_xfer,
+	.sff_exec_command	= pata_s3c_exec_command,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};
+
+static struct ata_port_operations pata_s5p_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};

[...]

drivers/ata/pata_samsung.c line 309

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+static void pata_s3c_setup_timing(struct s3c_ide_info *info)
+{
+	uint t1, t2, teoc, i;
+
+	uint pio_t1[5] = { 70, 50, 30, 30, 25 };

Could use ata_timing_find_mode() here to get the mode timings,
intead of duplicating them from libata-ocre.c...

drivers/ata/pata_samsung.c line 310

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+	uint pio_t2[5] = { 290, 290, 290, 80, 70 };

Note that those active times are for command cycles, not for data ones.

drivers/ata/pata_samsung.c line 311

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+	uint pio_teoc[5] = { 240, 43, 10, 70, 25 };

What timing is this? :-O

drivers/ata/pata_samsung.c line 317

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+
+	ulong cycle_time = (uint) (1000000000 / clk_get_rate(info->clk));
+
+	for (i = 0; i < 5; i++) {
+		t1 = (pio_t1[i] / cycle_time) & 0x0f;
+		t2 = (pio_t2[i] / cycle_time) & 0xff;

Could use ata_timing_compute() here.

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+		teoc = (pio_teoc[i] / cycle_time) & 0xff;
+		piotime[i] = (teoc << 12) | (t2 << 4) | t1;
+	}
+}
+

drivers/ata/pata_samsung.c line 332

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+static void pata_s3c_hwinit(struct s3c_ide_info *info,
+				struct s3c_ide_platdata *pdata)
+{
+	/* Select true-ide as the internal operating mode*/
+	if (pdata && (pdata->cfg_mode))
+		pdata->cfg_mode(info->sfr_addr);
+
+	switch (info->cpu_type) {
+	case TYPE_S3C6400:
+		/* Configure as big endian and enable the i/f*/

Put space before */, please.

Quoted 40 lines
drivers/ata/pata_samsung.c new file +40 -0
+static int __devinit pata_s3c_probe(struct platform_device *pdev)
+{
+	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");
+		return -ENOMEM;
+	}
+
+	info->irq = platform_get_irq(pdev, 0);
+	if (info->irq < 0) {
+		dev_err(dev, "could not obtain irq number\n");
+		ret = -ENODEV;
+		goto release_device_mem;
+	}
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		dev_err(dev, "failed to get mem resource\n");
+		ret = -ENODEV;
+		goto release_device_mem;
+	}
+
+	info->ide_addr = devm_ioremap(dev,
+				res->start, res->end - res->start + 1);
+	if (!info->ide_addr) {
+		dev_err(dev, "failed to map IO base address\n");
+		ret = -ENOMEM;
+		goto release_mem;
+	}

drivers/ata/pata_samsung.c line 408

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+
+	info->clk = clk_get(&pdev->dev, "cfcon");
+	if (IS_ERR(info->clk)) {
+		dev_err(dev, "failed to get access to cf controller clock\n");
+		ret = PTR_ERR(info->clk);
+		info->clk = NULL;
+		goto unmap;
+	}
+
+	if (clk_enable(info->clk)) {

Can it really fail?

Quoted 15 lines
drivers/ata/pata_samsung.c new file +15 -0
+		dev_err(dev, "failed to enable clock source.\n");
+		goto clkerr;
+	}
+
+	/* init ata host */
+	host = ata_host_alloc(dev, 1);
+	if (!host) {
+		dev_err(dev, "failed to allocate ide host\n");
+		ret = -ENOMEM;
+		goto stop_clk;
+	}
+
+	ap = host->ports[0];
+	ap->flags |= ATA_FLAG_MMIO;
+	ap->pio_mask = ATA_PIO4;

drivers/ata/pata_samsung.c line 433

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+
+	if (cpu_type == TYPE_S3C6400) {
+		ap->ops = &pata_s3c_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;
+		info->fifo_status_reg = 0x94;
+	} else if (cpu_type == TYPE_S5PC100) {
+		ap->ops = &pata_s5p_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;

Does make sense to assign those before *if*.

drivers/ata/pata_samsung.c line 436

Quoted 3 lines
drivers/ata/pata_samsung.c new file +3 -0
+		info->fifo_status_reg = 0x84;
+	} else {
+		ap->ops = &pata_s5p_port_ops;
    You don't assign 'info->ide_addr' here but you'll need it in 

pata_s3c_tune_chipset() which will be called thru pata_s5p_port_ops!

drivers/ata/pata_samsung.c line 442

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+		info->fifo_status_reg = 0x84;
+	}
+
+	info->cpu_type = cpu_type;
+
+	if (!(info->irq)) {
    Parens not needed around 'info->irq'.
Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+		ap->flags |= ATA_FLAG_PIO_POLLING;
+		ata_port_desc(ap, "no IRQ, using PIO polling\n");
+	}
+
+	ap->ioaddr.cmd_addr =  info->ide_addr + S3C_ATA_CMD;
+	ap->ioaddr.data_addr = info->ide_addr + S3C_ATA_PIO_DTR;
+	ap->ioaddr.error_addr = info->ide_addr + S3C_ATA_PIO_FED;
+	ap->ioaddr.feature_addr = info->ide_addr + S3C_ATA_PIO_FED;
+	ap->ioaddr.nsect_addr = info->ide_addr + S3C_ATA_PIO_SCR;

drivers/ata/pata_samsung.c line 461

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+	ap->ioaddr.lbal_addr = info->ide_addr + S3C_ATA_PIO_LLR;
+	ap->ioaddr.lbam_addr = info->ide_addr + S3C_ATA_PIO_LMR;
+	ap->ioaddr.lbah_addr = info->ide_addr + S3C_ATA_PIO_LHR;
+	ap->ioaddr.device_addr = info->ide_addr + S3C_ATA_PIO_DVR;
+	ap->ioaddr.status_addr = info->ide_addr + S3C_ATA_PIO_CSD;
+	ap->ioaddr.command_addr = info->ide_addr + S3C_ATA_PIO_CSD;
+	ap->ioaddr.altstatus_addr = info->ide_addr + S3C_ATA_PIO_DAD;
+	ap->ioaddr.ctl_addr = info->ide_addr + S3C_ATA_PIO_DAD;
+
+

Extra newline?

drivers/ata/pata_samsung.c line 468

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+	ata_port_desc(ap, "mmio cmd 0x%llx ",
+			(unsigned long long)res->start);
+
+	host->private_data = info;
+
+	/* Calculates timing parameters for PIO mode */
+	pata_s3c_setup_timing(info);

You could do it right in pata_s3c_tune_chipset() -- no need to
precalculate the timings.

drivers/ata/pata_samsung.c line 470

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+	if (pdata && (pdata->setup_gpio))
    Prens not needed around 'pdata->setup_gpio'.

drivers/ata/pata_samsung.c line 476

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+		pdata->setup_gpio();
+
+	/* Set endianness and enable the interface */
+	pata_s3c_hwinit(info, pdata);
+
+	return ata_host_activate(host, info->irq ? info->irq : 0,
    This ?: doesn't make sense, just pass 'info->irq'.

drivers/ata/pata_samsung.c line 480

Quoted 4 lines
drivers/ata/pata_samsung.c new file +4 -0
+			info->irq ? pata_s3c_irq : NULL,
+			IRQF_DISABLED, &pata_s3c_sht);
+
+	dev_set_drvdata(&pdev->dev, host);

Could use platform_set_drvdata(pdev, host)...

drivers/ata/pata_samsung.c line 487

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+
+stop_clk:
+	clk_disable(info->clk);
+clkerr:
+	clk_put(info->clk);
+unmap:
+	devm_iounmap(dev, info->ide_addr);

devm_ioremap() should "look after itself", so no explicait call
should be needed, if I don't mistake...

drivers/ata/pata_samsung.c

Quoted 2 lines
drivers/ata/pata_samsung.c new file +2 -0
+release_mem:
+	release_mem_region(res->start, res->end - res->start + 1);

But you didn't call request_mem_region()!

drivers/ata/pata_samsung.c line 497

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+release_device_mem:
+	kfree(info);
+return ret;
+}
+
+static int __devexit pata_s3c_remove(struct platform_device *pdev)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);

Could use platform_get_drvdata(pdev)...

Quoted 4 lines
drivers/ata/pata_samsung.c new file +4 -0
+	struct s3c_ide_info *info;
+	struct resource *res;
+
+	if (!host)

drivers/ata/pata_samsung.c line 511

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+		return 0;
+	info = host->private_data;
+
+	ata_host_detach(host);
+
+	devm_iounmap(&pdev->dev, info->ide_addr);
+	clk_disable(info->clk);
+	clk_put(info->clk);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	release_mem_region(res->start, res->end - res->start + 1);

Use resource_size(). Also, you don't call request_mem_region().

drivers/ata/pata_samsung.c line 520

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+	kfree(info);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int pata_s3c_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);

Could use platform_get_drvdata(pdev)...

drivers/ata/pata_samsung.c line 529

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+	if (host)
+		return ata_host_suspend(host, state);
+	else
+		return 0;
+}
+
+static int pata_s3c_resume(struct platform_device *pdev)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);

Could use platform_get_drvdata(pdev)...

MBR, Sergei

author
#19 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

Quoted 3 lines · Sergei Shtylyov

Hello.

Hi :-)

Quoted 6 lines
Quoted 4 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
Quoted 3 lines
Quoted 8 lines
Quoted 6 lines
drivers/ata/pata_samsung.c new file +0 -0
new file mode 100644
index 0000000..14381e4
@@ -0,0 +1,591 @@

[...]

Quoted 1 line

+static void pata_s3c_tune_chipset(struct s3c_ide_info *info, u8

ide_mode)

Quoted 5 lines
Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+{
+	ulong ata_cfg = readl(info->ide_addr + S3C_ATA_CFG);
+
+	/* IORDY is enabled for modes > PIO2 */
+	if (XFER_PIO_0 <= ide_mode && ide_mode <= XFER_PIO_4) {
Quoted 9 lines

drivers/ata/pata_samsung.c line 77

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+
+		switch (ide_mode) {
+		case XFER_PIO_0:
+		case XFER_PIO_1:
+		case XFER_PIO_2:
+			ata_cfg &= (~S3C_ATA_CFG_IORDYEN);

Useless parens.

OK

Quoted 8 lines

drivers/ata/pata_samsung.c line 81

Quoted 4 lines
drivers/ata/pata_samsung.c new file +4 -0
+			break;
+		case XFER_PIO_3:
+		case XFER_PIO_4:
+			ata_cfg |= S3C_ATA_CFG_IORDYEN;

IORDY should be controlled by ata_id_pio_need_iordy(), not by mode
number. PIO2 also can have IODRY enabled.

Will use ata_id_pio_need_iordy().

Quoted 6 lines
Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+			break;
+		}
+
+		writel(ata_cfg, info->ide_addr + S3C_ATA_CFG);
+		writel(piotime[ide_mode - XFER_PIO_0],
+			info->ide_addr + S3C_ATA_PIO_TIME);
Quoted 9 lines

drivers/ata/pata_samsung.c line 92

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+	} else {
+		/* Default to PIO0 */
+		ata_cfg &= (~S3C_ATA_CFG_IORDYEN);
+		writel(ata_cfg, info->ide_addr + S3C_ATA_CFG);
+		writel(piotime[0], info->ide_addr + S3C_ATA_PIO_TIME);

If you don't support DMA modes or modes higher than PIO4 (PIO5 and
PIO6 would have been good for CF though), just do nothing.

OK

Quoted 5 lines
Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+	}
+}
+
+static void
+pata_s3c_set_piomode(struct ata_port *ap, struct ata_device *adev)
Quoted 9 lines

drivers/ata/pata_samsung.c line 102

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+{
+	struct s3c_ide_info *info = ap->host->private_data;
+
+	/* Configure IORDY based on PIO mode and also set the timing value */
+	pata_s3c_tune_chipset(info, adev->pio_mode);

Don't see why you need a separate function for that. Maybe in
preparation to UDMA support?

That was it..but will remove pata_s3c_set_piomode() and call pata_s3c_tune_chipset() directly.

Quoted 12 lines

drivers/ata/pata_samsung.c line 130

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+/*
+ * Writes to one of the task file registers.
+ */
+static void ata_outb(struct ata_host *host, u8 addr, void __iomem *reg)
+{
+	struct s3c_ide_info *info = host->private_data;
+
+	wait_for_host_ready(info);
+	__raw_writeb(addr, reg);

You should use write?() or __raw_write?() consistently...

OK

Quoted 13 lines

drivers/ata/pata_samsung.c line 158

Quoted 11 lines
drivers/ata/pata_samsung.c new file +11 -0
+/*
+ * pata_s3c_tf_load - send taskfile registers to host controller
+ */
+static void pata_s3c_tf_load(struct ata_port *ap,
+				const struct ata_taskfile *tf)
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+	unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
+
+	if (tf->ctl != ap->last_ctl) {
+		if (ioaddr->ctl_addr)
    This register does exist and you assign ioaddr->ctl_addr in
Quoted 2 lines

pata_s3c_probe(), hence the check is pointless.

Will remove the check.

Quoted 10 lines

drivers/ata/pata_samsung.c line 165

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+			ata_outb(ap->host, tf->ctl, ioaddr->ctl_addr);
+		ap->last_ctl = tf->ctl;
+		ata_wait_idle(ap);
+	}
+
+	if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
+		WARN_ON_ONCE(!ioaddr->ctl_addr);

You don't need this either.

OK

Quoted 4 lines

drivers/ata/pata_samsung.c

Quoted 4 lines
drivers/ata/pata_samsung.c new file +4 -0
+/*
+ * pata_s3c_tf_read - input device's ATA taskfile shadow registers
+ */
+static void pata_s3c_tf_read(struct ata_port *ap, struct ata_taskfile

*tf)

Quoted 8 lines

drivers/ata/pata_samsung.c line 194

Quoted 4 lines
drivers/ata/pata_samsung.c new file +4 -0
+{
+	struct ata_ioports *ioaddr = &ap->ioaddr;
+
+	tf->command = ata_sff_check_status(ap);

But you have overriden this method, so ata_sff_check_status()
shouldn't work!

OK

Quoted 12 lines

drivers/ata/pata_samsung.c line 203

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+	tf->feature = ata_inb(ap->host, ioaddr->error_addr);
+	tf->nsect = ata_inb(ap->host, ioaddr->nsect_addr);
+	tf->lbal = ata_inb(ap->host, ioaddr->lbal_addr);
+	tf->lbam = ata_inb(ap->host, ioaddr->lbam_addr);
+	tf->lbah = ata_inb(ap->host, ioaddr->lbah_addr);
+	tf->device = ata_inb(ap->host, ioaddr->device_addr);
+
+	if (tf->flags & ATA_TFLAG_LBA48) {
+		if (likely(ioaddr->ctl_addr)) {

Not just likely, it's always true. Emilinate the check please.

OK

Quoted 2 lines

drivers/ata/pata_samsung.c

Quoted 2 lines
drivers/ata/pata_samsung.c new file +2 -0
+			iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr);
+			tf->hob_feature = ata_inb(ap->host,

ioaddr->error_addr);

Quoted 1 line

drivers/ata/pata_samsung.c

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+			tf->hob_nsect = ata_inb(ap->host,

ioaddr->nsect_addr);

Quoted 10 lines

drivers/ata/pata_samsung.c line 213

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+			tf->hob_lbal = ata_inb(ap->host, ioaddr->lbal_addr);
+			tf->hob_lbam = ata_inb(ap->host, ioaddr->lbam_addr);
+			tf->hob_lbah = ata_inb(ap->host, ioaddr->lbah_addr);
+			iowrite8(tf->ctl, ioaddr->ctl_addr);
+			ap->last_ctl = tf->ctl;
+		} else
+			WARN_ON_ONCE(1);

Not needed.

OK

Quoted 4 lines

drivers/ata/pata_samsung.c

Quoted 4 lines
drivers/ata/pata_samsung.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 12 lines

drivers/ata/pata_samsung.c line 247

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -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 *temp_addr = (u16 *)buf;
+
+	if (rw == READ) {

{} not needed.

OK

Quoted 11 lines

drivers/ata/pata_samsung.c line 255

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			*temp_addr = __raw_readw(data_addr);
+			wait_for_host_ready(info);
+			*temp_addr = __raw_readw(info->ide_addr
+					+ S3C_ATA_PIO_RDATA);
+		}
+	} else {

{} not needed.

OK

Quoted 9 lines

drivers/ata/pata_samsung.c line 260

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			writel(*temp_addr, data_addr);
+		}
+	}

Well, if this is pere CF case, 'buflen' can't be odd, but otherwise
you should handle that case...

OK

Quoted 7 lines
Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+
+	return words << 1;
+}
+
+static struct scsi_host_template pata_s3c_sht = {
+	ATA_PIO_SHT(DRV_NAME),
+};
Quoted 9 lines

drivers/ata/pata_samsung.c line 271

Quoted 4 lines
drivers/ata/pata_samsung.c new file +4 -0
+
+static struct ata_port_operations pata_s3c_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.sff_check_status	= pata_s3c_check_status,

Since simple iowrite8() isn't enough in your case, you also need to
override sff_dev_select(), sff_check_altstatus(), and sff_set_devctl() methods...

Will add these overrides.

Quoted 25 lines
Quoted 13 lines
drivers/ata/pata_samsung.c new file +13 -0
+	.sff_tf_load		= pata_s3c_tf_load,
+	.sff_tf_read		= pata_s3c_tf_read,
+	.sff_data_xfer		= pata_s3c_data_xfer,
+	.sff_exec_command	= pata_s3c_exec_command,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};
+
+static struct ata_port_operations pata_s5p_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};

[...]

drivers/ata/pata_samsung.c line 309

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+static void pata_s3c_setup_timing(struct s3c_ide_info *info)
+{
+	uint t1, t2, teoc, i;
+
+	uint pio_t1[5] = { 70, 50, 30, 30, 25 };

Could use ata_timing_find_mode() here to get the mode timings,
intead of duplicating them from libata-ocre.c...

Quoted 4 lines

drivers/ata/pata_samsung.c line 310

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+	uint pio_t2[5] = { 290, 290, 290, 80, 70 };

Note that those active times are for command cycles, not for data ones.

OK

Quoted 4 lines

drivers/ata/pata_samsung.c line 311

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+	uint pio_teoc[5] = { 240, 43, 10, 70, 25 };

What timing is this? :-O

Should have been t2i rec.

Quoted 9 lines

drivers/ata/pata_samsung.c line 317

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+
+	ulong cycle_time = (uint) (1000000000 / clk_get_rate(info->clk));
+
+	for (i = 0; i < 5; i++) {
+		t1 = (pio_t1[i] / cycle_time) & 0x0f;
+		t2 = (pio_t2[i] / cycle_time) & 0xff;

Could use ata_timing_compute() here.

Will re-use the timing parameters and ata_timing_compute(), ata_timing_find_mode() from libata-core.c

Quoted 9 lines
Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+		teoc = (pio_teoc[i] / cycle_time) & 0xff;
+		piotime[i] = (teoc << 12) | (t2 << 4) | t1;
+	}
+}
+
+static void pata_s3c_hwinit(struct s3c_ide_info *info,
+				struct s3c_ide_platdata *pdata)
+{
+	/* Select true-ide as the internal operating mode*/
Quoted 9 lines

drivers/ata/pata_samsung.c line 332

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+	if (pdata && (pdata->cfg_mode))
+		pdata->cfg_mode(info->sfr_addr);
+
+	switch (info->cpu_type) {
+	case TYPE_S3C6400:
+		/* Configure as big endian and enable the i/f*/

Put space before */, please.

OK

Quoted 36 lines
Quoted 36 lines
drivers/ata/pata_samsung.c new file +36 -0
+static int __devinit pata_s3c_probe(struct platform_device *pdev)
+{
+	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");
+		return -ENOMEM;
+	}
+
+	info->irq = platform_get_irq(pdev, 0);
+	if (info->irq < 0) {
+		dev_err(dev, "could not obtain irq number\n");
+		ret = -ENODEV;
+		goto release_device_mem;
+	}
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		dev_err(dev, "failed to get mem resource\n");
+		ret = -ENODEV;
+		goto release_device_mem;
+	}
+
+	info->ide_addr = devm_ioremap(dev,
+				res->start, res->end - res->start + 1);
+	if (!info->ide_addr) {
Quoted 8 lines

drivers/ata/pata_samsung.c

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+		dev_err(dev, "failed to map IO base address\n");
+		ret = -ENOMEM;
+		goto release_mem;
+	}
+
+	info->clk = clk_get(&pdev->dev, "cfcon");
+	if (IS_ERR(info->clk)) {
+		dev_err(dev, "failed to get access to cf controller

clock\n");

Quoted 9 lines

drivers/ata/pata_samsung.c line 408

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+		ret = PTR_ERR(info->clk);
+		info->clk = NULL;
+		goto unmap;
+	}
+
+	if (clk_enable(info->clk)) {

Can it really fail?

Will remove it.

Quoted 19 lines
Quoted 19 lines
drivers/ata/pata_samsung.c new file +19 -0
+		dev_err(dev, "failed to enable clock source.\n");
+		goto clkerr;
+	}
+
+	/* init ata host */
+	host = ata_host_alloc(dev, 1);
+	if (!host) {
+		dev_err(dev, "failed to allocate ide host\n");
+		ret = -ENOMEM;
+		goto stop_clk;
+	}
+
+	ap = host->ports[0];
+	ap->flags |= ATA_FLAG_MMIO;
+	ap->pio_mask = ATA_PIO4;
+
+	if (cpu_type == TYPE_S3C6400) {
+		ap->ops = &pata_s3c_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
Quoted 9 lines

drivers/ata/pata_samsung.c line 433

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+		info->ide_addr = info->ide_addr + 0x1900;
+		info->fifo_status_reg = 0x94;
+	} else if (cpu_type == TYPE_S5PC100) {
+		ap->ops = &pata_s5p_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;

Does make sense to assign those before *if*.

Offsets not required for S5PV210/S5PC110.

Quoted 7 lines

drivers/ata/pata_samsung.c line 436

Quoted 3 lines
drivers/ata/pata_samsung.c new file +3 -0
+		info->fifo_status_reg = 0x84;
+	} else {
+		ap->ops = &pata_s5p_port_ops;
    You don't assign 'info->ide_addr' here but you'll need it in

pata_s3c_tune_chipset() which will be called thru pata_s5p_port_ops!

The address received at ioremap() is enough for S5PV210/S5PC110..no offset needed.

Quoted 9 lines

drivers/ata/pata_samsung.c line 442

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+		info->fifo_status_reg = 0x84;
+	}
+
+	info->cpu_type = cpu_type;
+
+	if (!(info->irq)) {
    Parens not needed around 'info->irq'.

OK

Quoted 13 lines
Quoted 13 lines
drivers/ata/pata_samsung.c new file +13 -0
+		ap->flags |= ATA_FLAG_PIO_POLLING;
+		ata_port_desc(ap, "no IRQ, using PIO polling\n");
+	}
+
+	ap->ioaddr.cmd_addr =  info->ide_addr + S3C_ATA_CMD;
+	ap->ioaddr.data_addr = info->ide_addr + S3C_ATA_PIO_DTR;
+	ap->ioaddr.error_addr = info->ide_addr + S3C_ATA_PIO_FED;
+	ap->ioaddr.feature_addr = info->ide_addr + S3C_ATA_PIO_FED;
+	ap->ioaddr.nsect_addr = info->ide_addr + S3C_ATA_PIO_SCR;
+	ap->ioaddr.lbal_addr = info->ide_addr + S3C_ATA_PIO_LLR;
+	ap->ioaddr.lbam_addr = info->ide_addr + S3C_ATA_PIO_LMR;
+	ap->ioaddr.lbah_addr = info->ide_addr + S3C_ATA_PIO_LHR;
+	ap->ioaddr.device_addr = info->ide_addr + S3C_ATA_PIO_DVR;
Quoted 9 lines

drivers/ata/pata_samsung.c line 461

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+	ap->ioaddr.status_addr = info->ide_addr + S3C_ATA_PIO_CSD;
+	ap->ioaddr.command_addr = info->ide_addr + S3C_ATA_PIO_CSD;
+	ap->ioaddr.altstatus_addr = info->ide_addr + S3C_ATA_PIO_DAD;
+	ap->ioaddr.ctl_addr = info->ide_addr + S3C_ATA_PIO_DAD;
+
+

Extra newline?

Yes..will remove it.

Quoted 11 lines

drivers/ata/pata_samsung.c line 468

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+	ata_port_desc(ap, "mmio cmd 0x%llx ",
+			(unsigned long long)res->start);
+
+	host->private_data = info;
+
+	/* Calculates timing parameters for PIO mode */
+	pata_s3c_setup_timing(info);

You could do it right in pata_s3c_tune_chipset() -- no need to
precalculate the timings.

Will move it.

Quoted 4 lines

drivers/ata/pata_samsung.c line 470

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+	if (pdata && (pdata->setup_gpio))
    Prens not needed around 'pdata->setup_gpio'.

OK

Quoted 9 lines

drivers/ata/pata_samsung.c line 476

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+		pdata->setup_gpio();
+
+	/* Set endianness and enable the interface */
+	pata_s3c_hwinit(info, pdata);
+
+	return ata_host_activate(host, info->irq ? info->irq : 0,
    This ?: doesn't make sense, just pass 'info->irq'.

OK

Quoted 7 lines

drivers/ata/pata_samsung.c line 480

Quoted 4 lines
drivers/ata/pata_samsung.c new file +4 -0
+			info->irq ? pata_s3c_irq : NULL,
+			IRQF_DISABLED, &pata_s3c_sht);
+
+	dev_set_drvdata(&pdev->dev, host);

Could use platform_set_drvdata(pdev, host)...

OK

Quoted 11 lines

drivers/ata/pata_samsung.c line 487

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+
+stop_clk:
+	clk_disable(info->clk);
+clkerr:
+	clk_put(info->clk);
+unmap:
+	devm_iounmap(dev, info->ide_addr);

devm_ioremap() should "look after itself", so no explicait call
should be needed, if I don't mistake...

OK

Quoted 5 lines

drivers/ata/pata_samsung.c

Quoted 2 lines
drivers/ata/pata_samsung.c new file +2 -0
+release_mem:
+	release_mem_region(res->start, res->end - res->start + 1);

But you didn't call request_mem_region()!

I didn't..will remove.

Quoted 11 lines

drivers/ata/pata_samsung.c line 497

Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+release_device_mem:
+	kfree(info);
+return ret;
+}
+
+static int __devexit pata_s3c_remove(struct platform_device *pdev)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);

Could use platform_get_drvdata(pdev)...

OK

Quoted 8 lines
Quoted 8 lines
drivers/ata/pata_samsung.c new file +8 -0
+	struct s3c_ide_info *info;
+	struct resource *res;
+
+	if (!host)
+		return 0;
+	info = host->private_data;
+
+	ata_host_detach(host);
Quoted 9 lines

drivers/ata/pata_samsung.c line 511

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+
+	devm_iounmap(&pdev->dev, info->ide_addr);
+	clk_disable(info->clk);
+	clk_put(info->clk);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	release_mem_region(res->start, res->end - res->start + 1);

Use resource_size(). Also, you don't call request_mem_region().

OK

Quoted 7 lines

drivers/ata/pata_samsung.c

Quoted 7 lines
drivers/ata/pata_samsung.c new file +7 -0
+	kfree(info);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int pata_s3c_suspend(struct platform_device *pdev, pm_message_t

state)

Quoted 5 lines

drivers/ata/pata_samsung.c

Quoted 2 lines
drivers/ata/pata_samsung.c new file +2 -0
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);

Could use platform_get_drvdata(pdev)...

OK

Quoted 12 lines

drivers/ata/pata_samsung.c line 529

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+	if (host)
+		return ata_host_suspend(host, state);
+	else
+		return 0;
+}
+
+static int pata_s3c_resume(struct platform_device *pdev)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);

Could use platform_get_drvdata(pdev)...

OK

Thanks.

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

#20 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

Hello.

Quoted 3 lines · Kukjin Kim
Quoted 3 lines
Quoted 3 lines

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.

Where I those I wonder? :-)
It's a pity they didn't get accepted.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

[...]

Quoted 7 lines
Quoted 7 lines

drivers/ata/pata_samsung.c line 260

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			writel(*temp_addr, data_addr);
+		}
+	}

Well, if this is pere CF case, 'buflen' can't be odd, but otherwise

I meant to type "pure". :-)

Quoted 7 lines
Quoted 5 lines

you should handle that case...

drivers/ata/pata_samsung.c line 311

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+	uint pio_teoc[5] = { 240, 43, 10, 70, 25 };

What timing is this? :-O

Should have been t2i rec.

If it's t2i timing, it is incorrect for the first 3 PIO modes.

Quoted 12 lines
Quoted 11 lines

drivers/ata/pata_samsung.c line 433

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+	if (cpu_type == TYPE_S3C6400) {
+		ap->ops = &pata_s3c_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;
+		info->fifo_status_reg = 0x94;
+	} else if (cpu_type == TYPE_S5PC100) {
+		ap->ops = &pata_s5p_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;

Does make sense to assign those before *if*.

Quoted 1 line

Offsets not required for S5PV210/S5PC110.

pata_s3c_tune_chipset() certainly requires them.

Quoted 9 lines
Quoted 6 lines

drivers/ata/pata_samsung.c line 436

Quoted 3 lines
drivers/ata/pata_samsung.c new file +3 -0
+		info->fifo_status_reg = 0x84;
+	} else {
+		ap->ops = &pata_s5p_port_ops;
    You don't assign 'info->ide_addr' here but you'll need it in

pata_s3c_tune_chipset() which will be called thru pata_s5p_port_ops!

The address received at ioremap() is enough for S5PV210/S5PC110..no offset needed.

I only have to restate that pata_s3c_tune_chipset() does use
'info->ide_addr'. Maybe you shouldn't install this method for S5PV210/S5PC110? Or do you mean thgat offset of 0 will work?

Quoted 6 lines
Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+release_mem:
+	release_mem_region(res->start, res->end - res->start + 1);

But you didn't call request_mem_region()!

I didn't..will remove.

But you should call request_mem_region() in one or another form...

MBR, Sergei

author
#21 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

Quoted 2 lines · Sergei Shtylyov

Hello.

Hi ;-)

Quoted 4 lines
Quoted 2 lines · Kukjin Kim
Quoted 2 lines
Quoted 2 lines

From: Abhilash Kesavan <[email protected]>
Adds support for the Samsung PATA controller. This driver is based on

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Libata subsystem and references the earlier patches sent for IDE

subsystem.

Quoted 4 lines

Where I those I wonder? :-)
It's a pity they didn't get accepted.

Was told that that only new libata based drivers would be accepted.

Quoted 13 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

[...]

Quoted 7 lines
Quoted 7 lines

drivers/ata/pata_samsung.c line 260

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+		for (i = 0; i < words; i++, temp_addr++) {
+			wait_for_host_ready(info);
+			writel(*temp_addr, data_addr);
+		}
+	}

Well, if this is pere CF case, 'buflen' can't be odd, but otherwise

Quoted 2 lines

I meant to type "pure". :-)

considering CF in true-ide mode..should I still add the check?

Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

you should handle that case...

drivers/ata/pata_samsung.c line 311

Quoted 1 line
drivers/ata/pata_samsung.c new file +1 -0
+	uint pio_teoc[5] = { 240, 43, 10, 70, 25 };

What timing is this? :-O

Should have been t2i rec.

If it's t2i timing, it is incorrect for the first 3 PIO modes.

Should have been (240, 93, 40, 70, 25)

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

drivers/ata/pata_samsung.c line 433

Quoted 9 lines
drivers/ata/pata_samsung.c new file +9 -0
+	if (cpu_type == TYPE_S3C6400) {
+		ap->ops = &pata_s3c_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;
+		info->fifo_status_reg = 0x94;
+	} else if (cpu_type == TYPE_S5PC100) {
+		ap->ops = &pata_s5p_port_ops;
+		info->sfr_addr = info->ide_addr + 0x1800;
+		info->ide_addr = info->ide_addr + 0x1900;

Does make sense to assign those before *if*.

Quoted 4 lines
Quoted 1 line

Offsets not required for S5PV210/S5PC110.

pata_s3c_tune_chipset() certainly requires them.

yes..but for V210/C110 just the ioremapped info->ide_addr with 0 offset is enough.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

drivers/ata/pata_samsung.c line 436

Quoted 3 lines
drivers/ata/pata_samsung.c new file +3 -0
+		info->fifo_status_reg = 0x84;
+	} else {
+		ap->ops = &pata_s5p_port_ops;
    You don't assign 'info->ide_addr' here but you'll need it in

pata_s3c_tune_chipset() which will be called thru pata_s5p_port_ops!

The address received at ioremap() is enough for S5PV210/S5PC110..no

offset

Quoted 4 lines
Quoted 1 line

needed.

I only have to restate that pata_s3c_tune_chipset() does use
'info->ide_addr'. Maybe you shouldn't install this method for

S5PV210/S5PC110?

Quoted 2 lines

Or do you mean thgat offset of 0 will work?

V210/C110 requires 0 offset as compared to 6410 and C100 which require 0x1800.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+release_mem:
+	release_mem_region(res->start, res->end - res->start + 1);

But you didn't call request_mem_region()!

I didn't..will remove.

But you should call request_mem_region() in one or another form...

OK..will request mem_region() before ioremap()..and then the release_mem's should be fine.

Thanks.

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

#22 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

In reply to Kukjin Kim

Hello,

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

Just one small thing.

Quoted 6 lines
drivers/ata/pata_samsung.c new file +6 -0
+static struct ata_port_operations pata_s3c_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.sff_check_status	= pata_s3c_check_status,
+	.sff_tf_load		= pata_s3c_tf_load,
+	.sff_tf_read		= pata_s3c_tf_read,
+	.sff_data_xfer		= pata_s3c_data_xfer,

drivers/ata/pata_samsung.c line 284

Quoted 10 lines
drivers/ata/pata_samsung.c new file +10 -0
+	.sff_exec_command	= pata_s3c_exec_command,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};
+
+static struct ata_port_operations pata_s5p_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};

You don't need to override .qc_prep to ata_noop_qc_prep() and can you please base the patch against the current libata-dev#upstream?

Thanks.

Signature · 1 line
tejun
author
#23 lore raw

PATCH 4/4 pata_samsung: Add Samsung PATA controller driver

Quoted 8 lines · Tejun Heo

Hello,

Quoted 4 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 14 lines

Just one small thing.

Quoted 11 lines
drivers/ata/pata_samsung.c new file +11 -0
+static struct ata_port_operations pata_s3c_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.sff_check_status	= pata_s3c_check_status,
+	.sff_tf_load		= pata_s3c_tf_load,
+	.sff_tf_read		= pata_s3c_tf_read,
+	.sff_data_xfer		= pata_s3c_data_xfer,
+	.sff_exec_command	= pata_s3c_exec_command,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};
+
Quoted 9 lines

drivers/ata/pata_samsung.c line 284

Quoted 5 lines
drivers/ata/pata_samsung.c new file +5 -0
+static struct ata_port_operations pata_s5p_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.qc_prep		= ata_noop_qc_prep,
+	.set_piomode		= pata_s3c_set_piomode,
+};

You don't need to override .qc_prep to ata_noop_qc_prep() and can you please base the patch against the current libata-dev#upstream?

Will remove the override and rebase the new patches against upstream branch.

Thanks.

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