Skip to contentSkip to conversation

imx53 ahci driver v8

PATCH Superseded Richard Zhu 3 participants 9 messages Sep 22, 2011

Subsystems (5)

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v8 cover imx53 ahci driver v8

*** BLURB HERE ***
This is the seventh iteration of the imx53 ahci patch. Changes between v5 and v7 are described in the following description.

ChangeLog v5->v6:
- Move the most ahci initialization codes from the board related files to the common ahci_sata file.

- Add the imx53 ahci's own ata_port_info definition in ahci_platform driver, since the 'ahci_pmp_retry_srst_ops' is required when imx53 ahci is present.

ChangeLog v6->v7:
- Define the default imx53 ahci platform data, reduce the modificatons on the board related files.

- Handle the sata_pwr_en pin obviously on smd board.

ChangeLog V7->V8
- Accept Sascha's suggestions.
* Rename sata_init/sata_exit to imx_sata_init/imx_sata_exit.
* move the init/exit as static functions to platform-ahci-imx.c file. Make a wrapper on these functions, and avoid to pass the function hooks by platform data.

Richard Zhu (5):
AHCI Add the AHCI SATA feature on the MX53 platforms ahci_plt Add the board_ids and pi refer to different features MX53 Enable the AHCI SATA on MX53 ARD board
MX53 Enable the AHCI SATA on MX53 LOCO board
MX53 Enable the AHCI SATA on MX53 SMD board

 arch/arm/mach-mx5/board-mx53_ard.c              |    1 +
 arch/arm/mach-mx5/board-mx53_loco.c             |    1 +
 arch/arm/mach-mx5/board-mx53_smd.c              |   16 +++
 arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 +++
 arch/arm/mach-mx5/devices-imx53.h               |    2 +
 arch/arm/plat-mxc/devices/Kconfig               |    4 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-ahci-imx.c   |  156 +++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
 drivers/ata/ahci_platform.c                     |   44 ++++++-
 10 files changed, 248 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/plat-mxc/devices/platform-ahci-imx.c
#1 lore raw

PATCH v8 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms

---
 arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 +++
 arch/arm/mach-mx5/devices-imx53.h               |    2 +
 arch/arm/plat-mxc/devices/Kconfig               |    4 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-ahci-imx.c   |  156 +++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
 6 files changed, 192 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-mxc/devices/platform-ahci-imx.c
arch/arm/mach-mx5/clock-mx51-mx53.c +19 -0
index 7f20308..e1fadaf 100644
@@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
 	.secondary = &esdhc4_ipg_clk,
 };
 
+static struct clk sata_clk = {
+	.parent = &ipg_clk,
+	.enable = _clk_max_enable,
+	.enable_reg = MXC_CCM_CCGR4,
+	.enable_shift = MXC_CCM_CCGRx_CG1_OFFSET,
+	.disable = _clk_max_disable,
+};
+
+static struct clk ahci_phy_clk = {
+	.parent = &usb_phy1_clk,
+};
+
+static struct clk ahci_dma_clk = {
+	.parent = &ahb_clk,
+};
+
 DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk);
 DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk);
 DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk);
@@ -1503,6 +1519,9 @@ static struct clk_lookup mx53_lookups[] = {
 	_REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
 	_REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
 	_REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
 };
 
 static void clk_tree_init(void)
arch/arm/mach-mx5/devices-imx53.h +2 -0
index c27fe8b..1ab399e 100644
@@ -40,3 +40,5 @@ extern const struct imx_imx_ssi_data imx53_imx_ssi_data[];
 extern const struct imx_imx_keypad_data imx53_imx_keypad_data;
 #define imx53_add_imx_keypad(pdata)	\
 	imx_add_imx_keypad(&imx53_imx_keypad_data, pdata)
+
+extern struct platform_device *__init imx53_add_ahci_imx(void);
arch/arm/plat-mxc/devices/Kconfig +4 -0
index bd294ad..f63887b 100644
@@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 
 config IMX_HAVE_PLATFORM_SPI_IMX
 	bool
+
+config IMX_HAVE_PLATFORM_AHCI
+	bool
+	default y if ARCH_MX53
arch/arm/plat-mxc/devices/Makefile +1 -0
index b41bf97..e858ad9 100644
@@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_W1) += platform-mxc_w1.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX) += platform-sdhci-esdhc-imx.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) +=  platform-spi_imx.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_AHCI) +=  platform-ahci-imx.o
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +156 -0

156 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/devices-common.h +10 -0
index 524538a..f04e063 100644
@@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
 struct platform_device *imx_add_imx_dma(void);
 struct platform_device *imx_add_imx_sdma(char *name,
 	resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
+	const char *devid;
+	resource_size_t iobase;
+	resource_size_t irq;
+};
+struct platform_device *__init imx_add_ahci_imx(
+		const struct imx_ahci_imx_data *data,
+		const struct ahci_platform_data *pdata);
Signature · 1 line
1.7.1
#2 lore raw

PATCH v8 2/5 ahci_plt Add the board_ids and pi refer to different features

In reply to Richard Zhu

On imx53 AHCI, soft reset fails with IPMS set when PMP is enabled but SATA HDD/ODD is connected to SATA port, do soft reset again to port 0.
So the 'ahci_pmp_retry_srst_ops' is required when imx53 ahci is present.

---
 drivers/ata/ahci_platform.c |   44 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 38 insertions(+), 6 deletions(-)
drivers/ata/ahci_platform.c +38 -6
index 6fef1fa..c03277d 100644
@@ -23,6 +23,41 @@
 #include <linux/ahci_platform.h>
 #include "ahci.h"
 
+enum ahci_type {
+	AHCI,		/* standard platform ahci */
+	IMX53_AHCI,	/* ahci on i.mx53 */
+};
+
+static struct platform_device_id ahci_devtype[] = {
+	{
+		.name = "ahci",
+		.driver_data = AHCI,
+	}, {
+		.name = "imx53-ahci",
+		.driver_data = IMX53_AHCI,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, ahci_devtype);
+
+
+static const struct ata_port_info ahci_port_info[] = {
+	/* by features */
+	[AHCI] = {
+		.flags		= AHCI_FLAG_COMMON,
+		.pio_mask	= ATA_PIO4,
+		.udma_mask	= ATA_UDMA6,
+		.port_ops	= &ahci_ops,
+	},
+	[IMX53_AHCI] = {
+		.flags		= AHCI_FLAG_COMMON,
+		.pio_mask	= ATA_PIO4,
+		.udma_mask	= ATA_UDMA6,
+		.port_ops	= &ahci_pmp_retry_srst_ops,
+	},
+};
+
 static struct scsi_host_template ahci_platform_sht = {
 	AHCI_SHT("ahci_platform"),
 };
@@ -31,12 +66,8 @@ static int __init ahci_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct ahci_platform_data *pdata = dev->platform_data;
-	struct ata_port_info pi = {
-		.flags		= AHCI_FLAG_COMMON,
-		.pio_mask	= ATA_PIO4,
-		.udma_mask	= ATA_UDMA6,
-		.port_ops	= &ahci_ops,
-	};
+	const struct platform_device_id *id = platform_get_device_id(pdev);
+	struct ata_port_info pi = ahci_port_info[id->driver_data];
 	const struct ata_port_info *ppi[] = { &pi, NULL };
 	struct ahci_host_priv *hpriv;
 	struct ata_host *host;
@@ -177,6 +208,7 @@ static struct platform_driver ahci_driver = {
 		.name = "ahci",
 		.owner = THIS_MODULE,
 	},
+	.id_table	= ahci_devtype,
 };
 
 static int __init ahci_init(void)
Signature · 1 line
1.7.1
#3 lore raw

PATCH v8 3/5 MX53 Enable the AHCI SATA on MX53 ARD board

In reply to Richard Zhu
---
 arch/arm/mach-mx5/board-mx53_ard.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_ard.c +1 -0
index 76a67c4..ef2039e 100644
@@ -234,6 +234,7 @@ static void __init mx53_ard_board_init(void)
 	imx53_add_imx_i2c(1, &mx53_ard_i2c2_data);
 	imx53_add_imx_i2c(2, &mx53_ard_i2c3_data);
 	imx_add_gpio_keys(&ard_button_data);
+	imx53_add_ahci_imx();
 }
 
 static void __init mx53_ard_timer_init(void)
Signature · 1 line
1.7.1
#4 lore raw

PATCH v8 4/5 MX53 Enable the AHCI SATA on MX53 LOCO board

In reply to Richard Zhu
---
 arch/arm/mach-mx5/board-mx53_loco.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_loco.c +1 -0
index 4e1d51d..940aac9 100644
@@ -273,6 +273,7 @@ static void __init mx53_loco_board_init(void)
 	imx53_add_sdhci_esdhc_imx(2, &mx53_loco_sd3_data);
 	imx_add_gpio_keys(&loco_button_data);
 	gpio_led_register_device(-1, &mx53loco_leds_data);
+	imx53_add_ahci_imx();
 }
 
 static void __init mx53_loco_timer_init(void)
Signature · 1 line
1.7.1
#5 lore raw

PATCH v8 5/5 MX53 Enable the AHCI SATA on MX53 SMD board

In reply to Richard Zhu
---
 arch/arm/mach-mx5/board-mx53_smd.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_smd.c +16 -0
index bc02894..9d06fbe 100644
@@ -35,6 +35,7 @@
 #include "devices-imx53.h"
 
 #define SMD_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
+#define MX53_SMD_SATA_PWR_EN    IMX_GPIO_NR(3, 3)
 
 static iomux_v3_cfg_t mx53_smd_pads[] = {
 	MX53_PAD_CSI0_DAT10__UART1_TXD_MUX,
@@ -111,6 +112,19 @@ static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+static inline void mx53_smd_ahci_pwr_on(void)
+{
+	int ret;
+
+	/* Enable SATA PWR */
+	ret = gpio_request(MX53_SMD_SATA_PWR_EN, "ahci-sata-pwr");
+	if (ret) {
+		printk(KERN_ERR "failed to get SATA_PWR_EN: %d\n", ret);
+		return;
+	}
+	gpio_direction_output(MX53_SMD_SATA_PWR_EN, 1);
+}
+
 static void __init mx53_smd_board_init(void)
 {
 	imx53_soc_init();
@@ -125,6 +139,8 @@ static void __init mx53_smd_board_init(void)
 	imx53_add_sdhci_esdhc_imx(0, NULL);
 	imx53_add_sdhci_esdhc_imx(1, NULL);
 	imx53_add_sdhci_esdhc_imx(2, NULL);
+	mx53_smd_ahci_pwr_on();
+	imx53_add_ahci_imx();
 }
 
 static void __init mx53_smd_timer_init(void)
Signature · 1 line
1.7.1
reviewer
#6 lore raw

PATCH v8 5/5 MX53 Enable the AHCI SATA on MX53 SMD board

Quoted 18 lines · Richard Zhu

---
?arch/arm/mach-mx5/board-mx53_smd.c | ? 16 ++++++++++++++++ ?1 files changed, 16 insertions(+), 0 deletions(-)

arch/arm/mach-mx5/board-mx53_smd.c +0 -0
index bc02894..9d06fbe 100644
@@ -35,6 +35,7 @@

?#include "devices-imx53.h"

?#define SMD_FEC_PHY_RST ? ? ? ? ? ? ? ?IMX_GPIO_NR(7, 6) +#define MX53_SMD_SATA_PWR_EN ? ?IMX_GPIO_NR(3, 3)

?static iomux_v3_cfg_t mx53_smd_pads[] = {
? ? ? ?MX53_PAD_CSI0_DAT10__UART1_TXD_MUX,

arch/arm/mach-mx5/board-mx53_smd.c static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = { · line 120

Quoted 9 lines
arch/arm/mach-mx5/board-mx53_smd.c +6 -0
@@ -111,6 +112,19 @@ static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = {
 ? ? ? ?.bitrate = 100000,
 ?};
 
+static inline void mx53_smd_ahci_pwr_on(void)
+{
+ ? ? ? int ret;
+
+ ? ? ? /* Enable SATA PWR */
+ ? ? ? ret = gpio_request(MX53_SMD_SATA_PWR_EN, "ahci-sata-pwr");

Please use gpio_request_one.

arch/arm/mach-mx5/board-mx53_smd.c static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = { · line 122

Quoted 2 lines
arch/arm/mach-mx5/board-mx53_smd.c +2 -0
+ ? ? ? if (ret) {
+ ? ? ? ? ? ? ? printk(KERN_ERR "failed to get SATA_PWR_EN: %d\n", ret);

You can use pr_err instead.

Regards,

Fabio Estevam

#7 lore raw

PATCH v8 5/5 MX53 Enable the AHCI SATA on MX53 SMD board

In reply to Richard Zhu

Hello.

Quoted 9 lines · Richard Zhu
---
  arch/arm/mach-mx5/board-mx53_smd.c |   16 ++++++++++++++++
  1 files changed, 16 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_smd.c +0 -0
index bc02894..9d06fbe 100644

[...]

Quoted 5 lines
arch/arm/mach-mx5/board-mx53_smd.c +1 -0
@@ -111,6 +112,19 @@ static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = {
  	.bitrate = 100000,
  };
 
+static inline void mx53_smd_ahci_pwr_on(void)

arch/arm/mach-mx5/board-mx53_smd.c static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = { · line 125

Quoted 10 lines
arch/arm/mach-mx5/board-mx53_smd.c +10 -0
+{
+	int ret;
+
+	/* Enable SATA PWR */
+	ret = gpio_request(MX53_SMD_SATA_PWR_EN, "ahci-sata-pwr");
+	if (ret) {
+		printk(KERN_ERR "failed to get SATA_PWR_EN: %d\n", ret);
+		return;
+	}
+	gpio_direction_output(MX53_SMD_SATA_PWR_EN, 1);

You can use gpio_request_one() instead of gpio_request()/gpio_direction_*().

WBR, Sergei

#8 lore raw

PATCH v8 5/5 MX53 Enable the AHCI SATA on MX53 SMD board

Hi Fabio&Sergei:
Thanks for your comments.
Accepted. Would be changed later.

Best Regard
Richard Zhu

Quoted 37 lines · Sergei Shtylyov

Hello.

Quoted 10 lines · Richard Zhu
---
  arch/arm/mach-mx5/board-mx53_smd.c |   16 ++++++++++++++++
  1 files changed, 16 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_smd.c +0 -0
index bc02894..9d06fbe 100644

[...]

Quoted 6 lines
arch/arm/mach-mx5/board-mx53_smd.c +1 -0
@@ -111,6 +112,19 @@ static const struct imxi2c_platform_data
 mx53_smd_i2c_data __initconst = {
  	.bitrate = 100000,
  };
 
+static inline void mx53_smd_ahci_pwr_on(void)

arch/arm/mach-mx5/board-mx53_smd.c static const struct imxi2c_platform_data · line 126

Quoted 10 lines
arch/arm/mach-mx5/board-mx53_smd.c +10 -0
+{
+	int ret;
+
+	/* Enable SATA PWR */
+	ret = gpio_request(MX53_SMD_SATA_PWR_EN, "ahci-sata-pwr");
+	if (ret) {
+		printk(KERN_ERR "failed to get SATA_PWR_EN: %d\n", ret);
+		return;
+	}
+	gpio_direction_output(MX53_SMD_SATA_PWR_EN, 1);

You can use gpio_request_one() instead of
gpio_request()/gpio_direction_*().

WBR, Sergei