* [RFC PATCH 1/2] AHCI Add the AHCI SATA feature on MX53 platforms
@ 2011-03-10 8:59 Richard Zhu
2011-03-10 8:59 ` [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Richard Zhu
0 siblings, 1 reply; 8+ messages in thread
From: Richard Zhu @ 2011-03-10 8:59 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Richard Zhu <Hong-Xing.Zhu@freescale.com>
---
arch/arm/mach-mx5/clock-mx51-mx53.c | 11 +++++
arch/arm/mach-mx5/devices-imx53.h | 4 ++
arch/arm/plat-mxc/devices/Kconfig | 4 ++
arch/arm/plat-mxc/devices/Makefile | 1 +
arch/arm/plat-mxc/devices/platform-ahci-imx.c | 55 +++++++++++++++++++++++
arch/arm/plat-mxc/include/mach/ahci_sata.h | 51 +++++++++++++++++++++
arch/arm/plat-mxc/include/mach/devices-common.h | 10 ++++
7 files changed, 136 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/plat-mxc/devices/platform-ahci-imx.c
create mode 100644 arch/arm/plat-mxc/include/mach/ahci_sata.h
diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
index 652ace4..2b3d27c 100644
--- a/arch/arm/mach-mx5/clock-mx51-mx53.c
+++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
@@ -1380,6 +1380,14 @@ 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,
+};
+
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);
@@ -1468,6 +1476,9 @@ static struct clk_lookup mx53_lookups[] = {
_REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk)
_REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)
_REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk)
+ _REGISTER_CLOCK(NULL, "imx_sata_clk", sata_clk)
+ _REGISTER_CLOCK(NULL, "usb_phy1", usb_phy1_clk)
+ _REGISTER_CLOCK(NULL, "ahb_clk", ahb_clk)
};
static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices-imx53.h b/arch/arm/mach-mx5/devices-imx53.h
index 9251008..09ebb43 100644
--- a/arch/arm/mach-mx5/devices-imx53.h
+++ b/arch/arm/mach-mx5/devices-imx53.h
@@ -33,3 +33,7 @@ extern const struct imx_spi_imx_data imx53_ecspi_data[] __initconst;
extern const struct imx_imx2_wdt_data imx53_imx2_wdt_data[] __initconst;
#define imx53_add_imx2_wdt(id, pdata) \
imx_add_imx2_wdt(&imx53_imx2_wdt_data[id])
+
+extern const struct imx_ahci_imx_data imx53_ahci_imx_data[] __initconst;
+#define imx53_add_ahci_imx(id, pdata) \
+ imx_add_ahci_imx(&imx53_ahci_imx_data[id], pdata)
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index b9ab1d5..087595a 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -71,3 +71,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
config IMX_HAVE_PLATFORM_SPI_IMX
bool
+
+config IMX_HAVE_PLATFORM_SATA_AHCI
+ bool
+ default y if SOC_IMX53
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index 75cd2ec..e0b7fa3 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -22,3 +22,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RNGA) += platform-mxc_rnga.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_SATA_AHCI) += platform-ahci-imx.o
diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
new file mode 100644
index 0000000..a3ed6f7
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+#define imx_ahci_data_entry_single(soc) \
+ { \
+ .iobase = soc ## _SATA_BASE_ADDR, \
+ .irq = soc ## _INT_SATA, \
+ }
+
+#ifdef CONFIG_SOC_IMX53
+const struct imx_ahci_imx_data imx53_ahci_imx_data __initconst =
+ imx_ahci_data_entry_single(MX53);
+#endif
+
+struct platform_device *__init imx_add_ahci_imx(
+ const struct imx_ahci_imx_data *data,
+ const struct ahci_platform_data *pdata)
+{
+ struct resource res[] = {
+ {
+ .start = data->iobase,
+ .end = data->iobase + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = data->irq,
+ .end = data->irq,
+ .flags = IORESOURCE_IRQ,
+ },
+ };
+
+ return imx_add_platform_device_dmamask("ahci", 0 /* -1? */,
+ res, ARRAY_SIZE(res),
+ pdata, sizeof(*pdata), DMA_BIT_MASK(32));
+}
diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
new file mode 100644
index 0000000..25df23e
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __PLAT_MXC_AHCI_SATA_H__
+#define __PLAT_MXC_AHCI_SATA_H__
+
+enum {
+ HOST_CAP = 0x00,
+ HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
+ HOST_PORTS_IMPL = 0x0c,
+ HOST_TIMER1MS = 0xe0, /* Timer 1-ms */
+ /* Offest used to control the MPLL input clk */
+ PHY_CR_CLOCK_FREQ_OVRD = 0x12,
+ /* Port0 SATA Status */
+ PORT_SATA_SR = 0x128,
+ /* Port0 PHY Control */
+ PORT_PHY_CTL = 0x178,
+ /* PORT_PHY_CTL bits */
+ PORT_PHY_CTL_CAP_ADR_LOC = 0x10000,
+ PORT_PHY_CTL_CAP_DAT_LOC = 0x20000,
+ PORT_PHY_CTL_WRITE_LOC = 0x40000,
+ PORT_PHY_CTL_READ_LOC = 0x80000,
+ /* Port0 PHY Status */
+ PORT_PHY_SR = 0x17c,
+ /* PORT_PHY_SR */
+ PORT_PHY_STAT_DATA_LOC = 0,
+ PORT_PHY_STAT_ACK_LOC = 18,
+ /* SATA PHY Register */
+ SATA_PHY_CR_CLOCK_CRCMP_LT_LIMIT = 0x0001,
+ SATA_PHY_CR_CLOCK_DAC_CTL = 0x0008,
+ SATA_PHY_CR_CLOCK_RTUNE_CTL = 0x0009,
+ SATA_PHY_CR_CLOCK_ADC_OUT = 0x000A,
+ SATA_PHY_CR_CLOCK_MPLL_TST = 0x0017,
+};
+
+#endif /* __PLAT_MXC_AHCI_SATA_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 8658c9c..81baca6 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -264,3 +264,13 @@ struct imx_spi_imx_data {
struct platform_device *__init imx_add_spi_imx(
const struct imx_spi_imx_data *data,
const struct spi_imx_master *pdata);
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
+ int id;
+ 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);
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
2011-03-10 8:59 [RFC PATCH 1/2] AHCI Add the AHCI SATA feature on MX53 platforms Richard Zhu
@ 2011-03-10 8:59 ` Richard Zhu
0 siblings, 0 replies; 8+ messages in thread
From: Richard Zhu @ 2011-03-10 8:59 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Richard Zhu <Hong-Xing.Zhu@freescale.com>
---
arch/arm/mach-mx5/board-mx53_loco.c | 120 +++++++++++++++++++++++++++++++++++
1 files changed, 120 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c
index 0a18f8d..9a7bbea 100644
--- a/arch/arm/mach-mx5/board-mx53_loco.c
+++ b/arch/arm/mach-mx5/board-mx53_loco.c
@@ -23,11 +23,13 @@
#include <linux/fec.h>
#include <linux/delay.h>
#include <linux/gpio.h>
+#include <linux/ahci_platform.h>
#include <mach/common.h>
#include <mach/hardware.h>
#include <mach/imx-uart.h>
#include <mach/iomux-mx53.h>
+#include <mach/ahci_sata.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -203,6 +205,123 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
.bitrate = 100000,
};
+/* HW Initialization, if return 0, initialization is successful. */
+static int sata_init(struct device *dev, void __iomem *addr)
+{
+ void __iomem *mmio;
+ struct clk *clk;
+ int ret = 0;
+ u32 tmpdata;
+
+ clk = clk_get(dev, "imx_sata_clk");
+ ret = IS_ERR(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't get clock.\n");
+ return ret;
+ }
+ ret = clk_enable(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't enable clock.\n");
+ clk_put(clk);
+ return ret;
+ }
+
+ /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+ clk = clk_get(dev, "usb_phy1");
+ ret = IS_ERR(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
+ goto no_input_clk;
+ }
+ ret = clk_enable(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI Can't enable USB PHY1 clock.\n");
+ clk_put(clk);
+ goto no_input_clk;
+ }
+
+ /* Get the AHB clock rate, and configure the TIMER1MS reg later */
+ clk = clk_get(NULL, "ahb_clk");
+ ret = IS_ERR(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't get AHB clock.\n");
+ goto no_clk;
+ }
+
+ mmio = ioremap(MX53_SATA_BASE_ADDR, SZ_2K);
+ if (mmio == NULL) {
+ printk(KERN_ERR "Failed to map SATA REGS\n");
+ goto no_clk;
+ }
+
+ tmpdata = readl(mmio + HOST_CAP);
+ if (!(tmpdata & HOST_CAP_SSS)) {
+ tmpdata |= HOST_CAP_SSS;
+ writel(tmpdata, mmio + HOST_CAP);
+ }
+
+ if (!(readl(mmio + HOST_PORTS_IMPL) & 0x1))
+ writel((readl(mmio + HOST_PORTS_IMPL) | 0x1),
+ mmio + HOST_PORTS_IMPL);
+
+ tmpdata = clk_get_rate(clk) / 1000;
+ writel(tmpdata, mmio + HOST_TIMER1MS);
+
+ iounmap(mmio);
+
+ return ret;
+
+no_clk:
+ clk = clk_get(dev, "usb_phy1");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+
+no_input_clk:
+ clk = clk_get(dev, "imx_sata_clk");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get clock.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+
+ return ret;
+}
+
+static void sata_exit(struct device *dev)
+{
+ struct clk *clk;
+
+ clk = clk_get(dev, "usb_phy1");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+
+ clk = clk_get(dev, "imx_sata_clk");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get clock.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+}
+
+static struct ahci_platform_data sata_data = {
+ .init = sata_init,
+ .exit = sata_exit,
+};
+
static void __init mx53_loco_board_init(void)
{
mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
@@ -215,6 +334,7 @@ static void __init mx53_loco_board_init(void)
imx53_add_imx_i2c(1, &mx53_loco_i2c_data);
imx53_add_sdhci_esdhc_imx(0, NULL);
imx53_add_sdhci_esdhc_imx(2, NULL);
+ imx53_add_ahci_imx(0, &sata_data);
}
static void __init mx53_loco_timer_init(void)
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC PATCH 1/2] AHCI Add the AHCI SATA feature on MX53 platforms
@ 2011-03-14 9:55 Richard Zhu
2011-03-14 9:55 ` [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Richard Zhu
0 siblings, 1 reply; 8+ messages in thread
From: Richard Zhu @ 2011-03-14 9:55 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Richard Zhu <Hong-Xing.Zhu@freescale.com>
---
arch/arm/mach-mx5/clock-mx51-mx53.c | 11 +++++
arch/arm/mach-mx5/devices-imx53.h | 4 ++
arch/arm/plat-mxc/devices/Kconfig | 4 ++
arch/arm/plat-mxc/devices/Makefile | 1 +
arch/arm/plat-mxc/devices/platform-ahci-imx.c | 55 +++++++++++++++++++++++
arch/arm/plat-mxc/include/mach/ahci_sata.h | 51 +++++++++++++++++++++
arch/arm/plat-mxc/include/mach/devices-common.h | 10 ++++
7 files changed, 136 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/plat-mxc/devices/platform-ahci-imx.c
create mode 100644 arch/arm/plat-mxc/include/mach/ahci_sata.h
diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
index 652ace4..2b3d27c 100644
--- a/arch/arm/mach-mx5/clock-mx51-mx53.c
+++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
@@ -1380,6 +1380,14 @@ 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,
+};
+
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);
@@ -1468,6 +1476,9 @@ static struct clk_lookup mx53_lookups[] = {
_REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk)
_REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)
_REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk)
+ _REGISTER_CLOCK(NULL, "imx_sata_clk", sata_clk)
+ _REGISTER_CLOCK(NULL, "usb_phy1", usb_phy1_clk)
+ _REGISTER_CLOCK(NULL, "ahb_clk", ahb_clk)
};
static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices-imx53.h b/arch/arm/mach-mx5/devices-imx53.h
index 9251008..09ebb43 100644
--- a/arch/arm/mach-mx5/devices-imx53.h
+++ b/arch/arm/mach-mx5/devices-imx53.h
@@ -33,3 +33,7 @@ extern const struct imx_spi_imx_data imx53_ecspi_data[] __initconst;
extern const struct imx_imx2_wdt_data imx53_imx2_wdt_data[] __initconst;
#define imx53_add_imx2_wdt(id, pdata) \
imx_add_imx2_wdt(&imx53_imx2_wdt_data[id])
+
+extern const struct imx_ahci_imx_data imx53_ahci_imx_data[] __initconst;
+#define imx53_add_ahci_imx(id, pdata) \
+ imx_add_ahci_imx(&imx53_ahci_imx_data[id], pdata)
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index b9ab1d5..087595a 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -71,3 +71,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
config IMX_HAVE_PLATFORM_SPI_IMX
bool
+
+config IMX_HAVE_PLATFORM_SATA_AHCI
+ bool
+ default y if SOC_IMX53
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index 75cd2ec..e0b7fa3 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -22,3 +22,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RNGA) += platform-mxc_rnga.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_SATA_AHCI) += platform-ahci-imx.o
diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
new file mode 100644
index 0000000..a3ed6f7
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+#define imx_ahci_data_entry_single(soc) \
+ { \
+ .iobase = soc ## _SATA_BASE_ADDR, \
+ .irq = soc ## _INT_SATA, \
+ }
+
+#ifdef CONFIG_SOC_IMX53
+const struct imx_ahci_imx_data imx53_ahci_imx_data __initconst =
+ imx_ahci_data_entry_single(MX53);
+#endif
+
+struct platform_device *__init imx_add_ahci_imx(
+ const struct imx_ahci_imx_data *data,
+ const struct ahci_platform_data *pdata)
+{
+ struct resource res[] = {
+ {
+ .start = data->iobase,
+ .end = data->iobase + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = data->irq,
+ .end = data->irq,
+ .flags = IORESOURCE_IRQ,
+ },
+ };
+
+ return imx_add_platform_device_dmamask("ahci", 0 /* -1? */,
+ res, ARRAY_SIZE(res),
+ pdata, sizeof(*pdata), DMA_BIT_MASK(32));
+}
diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
new file mode 100644
index 0000000..25df23e
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __PLAT_MXC_AHCI_SATA_H__
+#define __PLAT_MXC_AHCI_SATA_H__
+
+enum {
+ HOST_CAP = 0x00,
+ HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
+ HOST_PORTS_IMPL = 0x0c,
+ HOST_TIMER1MS = 0xe0, /* Timer 1-ms */
+ /* Offest used to control the MPLL input clk */
+ PHY_CR_CLOCK_FREQ_OVRD = 0x12,
+ /* Port0 SATA Status */
+ PORT_SATA_SR = 0x128,
+ /* Port0 PHY Control */
+ PORT_PHY_CTL = 0x178,
+ /* PORT_PHY_CTL bits */
+ PORT_PHY_CTL_CAP_ADR_LOC = 0x10000,
+ PORT_PHY_CTL_CAP_DAT_LOC = 0x20000,
+ PORT_PHY_CTL_WRITE_LOC = 0x40000,
+ PORT_PHY_CTL_READ_LOC = 0x80000,
+ /* Port0 PHY Status */
+ PORT_PHY_SR = 0x17c,
+ /* PORT_PHY_SR */
+ PORT_PHY_STAT_DATA_LOC = 0,
+ PORT_PHY_STAT_ACK_LOC = 18,
+ /* SATA PHY Register */
+ SATA_PHY_CR_CLOCK_CRCMP_LT_LIMIT = 0x0001,
+ SATA_PHY_CR_CLOCK_DAC_CTL = 0x0008,
+ SATA_PHY_CR_CLOCK_RTUNE_CTL = 0x0009,
+ SATA_PHY_CR_CLOCK_ADC_OUT = 0x000A,
+ SATA_PHY_CR_CLOCK_MPLL_TST = 0x0017,
+};
+
+#endif /* __PLAT_MXC_AHCI_SATA_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 8658c9c..81baca6 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -264,3 +264,13 @@ struct imx_spi_imx_data {
struct platform_device *__init imx_add_spi_imx(
const struct imx_spi_imx_data *data,
const struct spi_imx_master *pdata);
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
+ int id;
+ 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);
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
2011-03-14 9:55 [RFC PATCH 1/2] AHCI Add the AHCI SATA feature on MX53 platforms Richard Zhu
@ 2011-03-14 9:55 ` Richard Zhu
2011-03-14 14:50 ` Jeff Garzik
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Richard Zhu @ 2011-03-14 9:55 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Richard Zhu <Hong-Xing.Zhu@freescale.com>
---
arch/arm/mach-mx5/board-mx53_loco.c | 120 +++++++++++++++++++++++++++++++++++
1 files changed, 120 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c
index 0a18f8d..9a7bbea 100644
--- a/arch/arm/mach-mx5/board-mx53_loco.c
+++ b/arch/arm/mach-mx5/board-mx53_loco.c
@@ -23,11 +23,13 @@
#include <linux/fec.h>
#include <linux/delay.h>
#include <linux/gpio.h>
+#include <linux/ahci_platform.h>
#include <mach/common.h>
#include <mach/hardware.h>
#include <mach/imx-uart.h>
#include <mach/iomux-mx53.h>
+#include <mach/ahci_sata.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -203,6 +205,123 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
.bitrate = 100000,
};
+/* HW Initialization, if return 0, initialization is successful. */
+static int sata_init(struct device *dev, void __iomem *addr)
+{
+ void __iomem *mmio;
+ struct clk *clk;
+ int ret = 0;
+ u32 tmpdata;
+
+ clk = clk_get(dev, "imx_sata_clk");
+ ret = IS_ERR(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't get clock.\n");
+ return ret;
+ }
+ ret = clk_enable(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't enable clock.\n");
+ clk_put(clk);
+ return ret;
+ }
+
+ /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+ clk = clk_get(dev, "usb_phy1");
+ ret = IS_ERR(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
+ goto no_input_clk;
+ }
+ ret = clk_enable(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI Can't enable USB PHY1 clock.\n");
+ clk_put(clk);
+ goto no_input_clk;
+ }
+
+ /* Get the AHB clock rate, and configure the TIMER1MS reg later */
+ clk = clk_get(NULL, "ahb_clk");
+ ret = IS_ERR(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't get AHB clock.\n");
+ goto no_clk;
+ }
+
+ mmio = ioremap(MX53_SATA_BASE_ADDR, SZ_2K);
+ if (mmio == NULL) {
+ printk(KERN_ERR "Failed to map SATA REGS\n");
+ goto no_clk;
+ }
+
+ tmpdata = readl(mmio + HOST_CAP);
+ if (!(tmpdata & HOST_CAP_SSS)) {
+ tmpdata |= HOST_CAP_SSS;
+ writel(tmpdata, mmio + HOST_CAP);
+ }
+
+ if (!(readl(mmio + HOST_PORTS_IMPL) & 0x1))
+ writel((readl(mmio + HOST_PORTS_IMPL) | 0x1),
+ mmio + HOST_PORTS_IMPL);
+
+ tmpdata = clk_get_rate(clk) / 1000;
+ writel(tmpdata, mmio + HOST_TIMER1MS);
+
+ iounmap(mmio);
+
+ return ret;
+
+no_clk:
+ clk = clk_get(dev, "usb_phy1");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+
+no_input_clk:
+ clk = clk_get(dev, "imx_sata_clk");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get clock.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+
+ return ret;
+}
+
+static void sata_exit(struct device *dev)
+{
+ struct clk *clk;
+
+ clk = clk_get(dev, "usb_phy1");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+
+ clk = clk_get(dev, "imx_sata_clk");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get clock.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+}
+
+static struct ahci_platform_data sata_data = {
+ .init = sata_init,
+ .exit = sata_exit,
+};
+
static void __init mx53_loco_board_init(void)
{
mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
@@ -215,6 +334,7 @@ static void __init mx53_loco_board_init(void)
imx53_add_imx_i2c(1, &mx53_loco_i2c_data);
imx53_add_sdhci_esdhc_imx(0, NULL);
imx53_add_sdhci_esdhc_imx(2, NULL);
+ imx53_add_ahci_imx(0, &sata_data);
}
static void __init mx53_loco_timer_init(void)
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
2011-03-14 9:55 ` [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Richard Zhu
@ 2011-03-14 14:50 ` Jeff Garzik
2011-03-15 9:02 ` Sascha Hauer
2011-03-15 9:32 ` Sascha Hauer
2 siblings, 0 replies; 8+ messages in thread
From: Jeff Garzik @ 2011-03-14 14:50 UTC (permalink / raw)
To: linux-arm-kernel
On 03/14/2011 05:55 AM, Richard Zhu wrote:
> Signed-off-by: Richard Zhu<Hong-Xing.Zhu@freescale.com>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
2011-03-14 9:55 ` [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Richard Zhu
2011-03-14 14:50 ` Jeff Garzik
@ 2011-03-15 9:02 ` Sascha Hauer
2011-03-16 9:49 ` Zhu Richard-R65037
2011-03-15 9:32 ` Sascha Hauer
2 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2011-03-15 9:02 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Mar 14, 2011 at 05:55:44PM +0800, Richard Zhu wrote:
> Signed-off-by: Richard Zhu <Hong-Xing.Zhu@freescale.com>
> ---
> arch/arm/mach-mx5/board-mx53_loco.c | 120 +++++++++++++++++++++++++++++++++++
> 1 files changed, 120 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c
> index 0a18f8d..9a7bbea 100644
> --- a/arch/arm/mach-mx5/board-mx53_loco.c
> +++ b/arch/arm/mach-mx5/board-mx53_loco.c
> @@ -23,11 +23,13 @@
> #include <linux/fec.h>
> #include <linux/delay.h>
> #include <linux/gpio.h>
> +#include <linux/ahci_platform.h>
>
> #include <mach/common.h>
> #include <mach/hardware.h>
> #include <mach/imx-uart.h>
> #include <mach/iomux-mx53.h>
> +#include <mach/ahci_sata.h>
>
> #include <asm/mach-types.h>
> #include <asm/mach/arch.h>
> @@ -203,6 +205,123 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
> .bitrate = 100000,
> };
>
> +/* HW Initialization, if return 0, initialization is successful. */
> +static int sata_init(struct device *dev, void __iomem *addr)
> +{
> + void __iomem *mmio;
> + struct clk *clk;
> + int ret = 0;
> + u32 tmpdata;
> +
> + clk = clk_get(dev, "imx_sata_clk");
> + ret = IS_ERR(clk);
> + if (ret) {
> + printk(KERN_ERR "IMX AHCI can't get clock.\n");
> + return ret;
> + }
IS_ERR returns 0 or 1 which is not a valid return value here.
> + ret = clk_enable(clk);
> + if (ret) {
> + printk(KERN_ERR "IMX AHCI can't enable clock.\n");
You have a struct device *, so you should use dev_err.
> + clk_put(clk);
> + return ret;
> + }
> +
> + /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
> + clk = clk_get(dev, "usb_phy1");
> + ret = IS_ERR(clk);
> + if (ret) {
> + printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
> + goto no_input_clk;
> + }
> + ret = clk_enable(clk);
> + if (ret) {
> + printk(KERN_ERR "IMX AHCI Can't enable USB PHY1 clock.\n");
> + clk_put(clk);
> + goto no_input_clk;
> + }
> +
> + /* Get the AHB clock rate, and configure the TIMER1MS reg later */
> + clk = clk_get(NULL, "ahb_clk");
> + ret = IS_ERR(clk);
> + if (ret) {
> + printk(KERN_ERR "IMX AHCI can't get AHB clock.\n");
> + goto no_clk;
> + }
> +
> + mmio = ioremap(MX53_SATA_BASE_ADDR, SZ_2K);
> + if (mmio == NULL) {
> + printk(KERN_ERR "Failed to map SATA REGS\n");
> + goto no_clk;
> + }
> +
> + tmpdata = readl(mmio + HOST_CAP);
> + if (!(tmpdata & HOST_CAP_SSS)) {
> + tmpdata |= HOST_CAP_SSS;
> + writel(tmpdata, mmio + HOST_CAP);
> + }
> +
> + if (!(readl(mmio + HOST_PORTS_IMPL) & 0x1))
> + writel((readl(mmio + HOST_PORTS_IMPL) | 0x1),
> + mmio + HOST_PORTS_IMPL);
> +
> + tmpdata = clk_get_rate(clk) / 1000;
> + writel(tmpdata, mmio + HOST_TIMER1MS);
> +
> + iounmap(mmio);
> +
> + return ret;
> +
> +no_clk:
> + clk = clk_get(dev, "usb_phy1");
While technically not strictly necessary at the moment you should
balance your clk_get / clk_put calls. Everything else is bad taste.
> + if (IS_ERR(clk)) {
> + clk = NULL;
> + printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
> + } else {
> + clk_disable(clk);
> + clk_put(clk);
> + }
> +
> +no_input_clk:
> + clk = clk_get(dev, "imx_sata_clk");
> + if (IS_ERR(clk)) {
> + clk = NULL;
> + printk(KERN_ERR "IMX AHCI can't get clock.\n");
> + } else {
> + clk_disable(clk);
> + clk_put(clk);
> + }
> +
> + return ret;
> +}
> +
> +static void sata_exit(struct device *dev)
> +{
> + struct clk *clk;
> +
> + clk = clk_get(dev, "usb_phy1");
> + if (IS_ERR(clk)) {
> + clk = NULL;
> + printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
> + } else {
> + clk_disable(clk);
> + clk_put(clk);
> + }
> +
> + clk = clk_get(dev, "imx_sata_clk");
> + if (IS_ERR(clk)) {
> + clk = NULL;
> + printk(KERN_ERR "IMX AHCI can't get clock.\n");
> + } else {
> + clk_disable(clk);
> + clk_put(clk);
> + }
> +}
> +
> +static struct ahci_platform_data sata_data = {
> + .init = sata_init,
> + .exit = sata_exit,
> +};
> +
> static void __init mx53_loco_board_init(void)
> {
> mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
> @@ -215,6 +334,7 @@ static void __init mx53_loco_board_init(void)
> imx53_add_imx_i2c(1, &mx53_loco_i2c_data);
> imx53_add_sdhci_esdhc_imx(0, NULL);
> imx53_add_sdhci_esdhc_imx(2, NULL);
> + imx53_add_ahci_imx(0, &sata_data);
> }
>
> static void __init mx53_loco_timer_init(void)
> --
> 1.7.1
>
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
2011-03-15 9:02 ` Sascha Hauer
@ 2011-03-16 9:49 ` Zhu Richard-R65037
0 siblings, 0 replies; 8+ messages in thread
From: Zhu Richard-R65037 @ 2011-03-16 9:49 UTC (permalink / raw)
To: linux-arm-kernel
Hi Sascha:
Best Regards
Richard Zhu
> -----Original Message-----
> From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
> Sent: Tuesday, March 15, 2011 5:03 PM
> To: Zhu Richard-R65037
> Cc: linux-arm-kernel at lists.infradead.org; jgarzik at pobox.com;
> kernel at pengutronix.de; linux-ide at vger.kernel.org;
> avorontsov at ru.mvista.com; eric at eukrea.com; eric.miao at linaro.org
> Subject: Re: [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
>
> On Mon, Mar 14, 2011 at 05:55:44PM +0800, Richard Zhu wrote:
> > Signed-off-by: Richard Zhu <Hong-Xing.Zhu@freescale.com>
> > ---
> > arch/arm/mach-mx5/board-mx53_loco.c | 120
> > +++++++++++++++++++++++++++++++++++
> > 1 files changed, 120 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/arm/mach-mx5/board-mx53_loco.c
> > b/arch/arm/mach-mx5/board-mx53_loco.c
> > index 0a18f8d..9a7bbea 100644
> > --- a/arch/arm/mach-mx5/board-mx53_loco.c
> > +++ b/arch/arm/mach-mx5/board-mx53_loco.c
> > @@ -23,11 +23,13 @@
> > #include <linux/fec.h>
> > #include <linux/delay.h>
> > #include <linux/gpio.h>
> > +#include <linux/ahci_platform.h>
> >
> > #include <mach/common.h>
> > #include <mach/hardware.h>
> > #include <mach/imx-uart.h>
> > #include <mach/iomux-mx53.h>
> > +#include <mach/ahci_sata.h>
> >
> > #include <asm/mach-types.h>
> > #include <asm/mach/arch.h>
> > @@ -203,6 +205,123 @@ static const struct imxi2c_platform_data
> mx53_loco_i2c_data __initconst = {
> > .bitrate = 100000,
> > };
> >
> > +/* HW Initialization, if return 0, initialization is successful. */
> > +static int sata_init(struct device *dev, void __iomem *addr) {
> > + void __iomem *mmio;
> > + struct clk *clk;
> > + int ret = 0;
> > + u32 tmpdata;
> > +
> > + clk = clk_get(dev, "imx_sata_clk");
> > + ret = IS_ERR(clk);
> > + if (ret) {
> > + printk(KERN_ERR "IMX AHCI can't get clock.\n");
> > + return ret;
> > + }
>
> IS_ERR returns 0 or 1 which is not a valid return value here.
Accepted.
>
> > + ret = clk_enable(clk);
> > + if (ret) {
> > + printk(KERN_ERR "IMX AHCI can't enable clock.\n");
>
> You have a struct device *, so you should use dev_err.
Accepted.
>
> > + clk_put(clk);
> > + return ret;
> > + }
> > +
> > + /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
> > + clk = clk_get(dev, "usb_phy1");
> > + ret = IS_ERR(clk);
> > + if (ret) {
> > + printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
> > + goto no_input_clk;
> > + }
> > + ret = clk_enable(clk);
> > + if (ret) {
> > + printk(KERN_ERR "IMX AHCI Can't enable USB PHY1 clock.\n");
> > + clk_put(clk);
> > + goto no_input_clk;
> > + }
> > +
> > + /* Get the AHB clock rate, and configure the TIMER1MS reg later */
> > + clk = clk_get(NULL, "ahb_clk");
> > + ret = IS_ERR(clk);
> > + if (ret) {
> > + printk(KERN_ERR "IMX AHCI can't get AHB clock.\n");
> > + goto no_clk;
> > + }
> > +
> > + mmio = ioremap(MX53_SATA_BASE_ADDR, SZ_2K);
> > + if (mmio == NULL) {
> > + printk(KERN_ERR "Failed to map SATA REGS\n");
> > + goto no_clk;
> > + }
> > +
> > + tmpdata = readl(mmio + HOST_CAP);
> > + if (!(tmpdata & HOST_CAP_SSS)) {
> > + tmpdata |= HOST_CAP_SSS;
> > + writel(tmpdata, mmio + HOST_CAP);
> > + }
> > +
> > + if (!(readl(mmio + HOST_PORTS_IMPL) & 0x1))
> > + writel((readl(mmio + HOST_PORTS_IMPL) | 0x1),
> > + mmio + HOST_PORTS_IMPL);
> > +
> > + tmpdata = clk_get_rate(clk) / 1000;
> > + writel(tmpdata, mmio + HOST_TIMER1MS);
> > +
> > + iounmap(mmio);
> > +
> > + return ret;
> > +
> > +no_clk:
> > + clk = clk_get(dev, "usb_phy1");
>
> While technically not strictly necessary at the moment you should balance
> your clk_get / clk_put calls. Everything else is bad taste.
>
Yeah, you are right.
How do you think about add two clk pointers member into ahci_host_priv struct to balance
clk_get/clk_put pair calls?
Or
Added one private pointer into ahci_host_priv to make a more flexible method for kinds of different platforms to
balance the hw resource(clk, power and so on) balance?
>
> > + if (IS_ERR(clk)) {
> > + clk = NULL;
> > + printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
> > + } else {
> > + clk_disable(clk);
> > + clk_put(clk);
> > + }
> > +
> > +no_input_clk:
> > + clk = clk_get(dev, "imx_sata_clk");
> > + if (IS_ERR(clk)) {
> > + clk = NULL;
> > + printk(KERN_ERR "IMX AHCI can't get clock.\n");
> > + } else {
> > + clk_disable(clk);
> > + clk_put(clk);
> > + }
> > +
> > + return ret;
> > +}
> > +
> > +static void sata_exit(struct device *dev) {
> > + struct clk *clk;
> > +
> > + clk = clk_get(dev, "usb_phy1");
> > + if (IS_ERR(clk)) {
> > + clk = NULL;
> > + printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
> > + } else {
> > + clk_disable(clk);
> > + clk_put(clk);
> > + }
> > +
> > + clk = clk_get(dev, "imx_sata_clk");
> > + if (IS_ERR(clk)) {
> > + clk = NULL;
> > + printk(KERN_ERR "IMX AHCI can't get clock.\n");
> > + } else {
> > + clk_disable(clk);
> > + clk_put(clk);
> > + }
> > +}
> > +
> > +static struct ahci_platform_data sata_data = {
> > + .init = sata_init,
> > + .exit = sata_exit,
> > +};
> > +
> > static void __init mx53_loco_board_init(void) {
> > mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
> > @@ -215,6 +334,7 @@ static void __init mx53_loco_board_init(void)
> > imx53_add_imx_i2c(1, &mx53_loco_i2c_data);
> > imx53_add_sdhci_esdhc_imx(0, NULL);
> > imx53_add_sdhci_esdhc_imx(2, NULL);
> > + imx53_add_ahci_imx(0, &sata_data);
> > }
> >
> > static void __init mx53_loco_timer_init(void)
> > --
> > 1.7.1
> >
> >
> >
>
> --
> Pengutronix e.K. |
> |
> Industrial Linux Solutions | http://www.pengutronix.de/
> |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0
> |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555
> |
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
2011-03-14 9:55 ` [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Richard Zhu
2011-03-14 14:50 ` Jeff Garzik
2011-03-15 9:02 ` Sascha Hauer
@ 2011-03-15 9:32 ` Sascha Hauer
2011-03-16 9:56 ` Zhu Richard-R65037
2 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2011-03-15 9:32 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Mar 14, 2011 at 05:55:44PM +0800, Richard Zhu wrote:
> Signed-off-by: Richard Zhu <Hong-Xing.Zhu@freescale.com>
> ---
> arch/arm/mach-mx5/board-mx53_loco.c | 120 +++++++++++++++++++++++++++++++++++
> 1 files changed, 120 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c
> index 0a18f8d..9a7bbea 100644
> --- a/arch/arm/mach-mx5/board-mx53_loco.c
> +++ b/arch/arm/mach-mx5/board-mx53_loco.c
> @@ -23,11 +23,13 @@
> #include <linux/fec.h>
> #include <linux/delay.h>
> #include <linux/gpio.h>
> +#include <linux/ahci_platform.h>
>
> #include <mach/common.h>
> #include <mach/hardware.h>
> #include <mach/imx-uart.h>
> #include <mach/iomux-mx53.h>
> +#include <mach/ahci_sata.h>
>
> #include <asm/mach-types.h>
> #include <asm/mach/arch.h>
> @@ -203,6 +205,123 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
> .bitrate = 100000,
> };
>
> +/* HW Initialization, if return 0, initialization is successful. */
> +static int sata_init(struct device *dev, void __iomem *addr)
Isn't this addr pointer exactly the address you remap again below?
> +{
> + void __iomem *mmio;
> + struct clk *clk;
> + int ret = 0;
> + u32 tmpdata;
> +
> + clk = clk_get(dev, "imx_sata_clk");
This one is associated with the device, so passing in dev here is ok,
but...
> + ret = IS_ERR(clk);
> + if (ret) {
> + printk(KERN_ERR "IMX AHCI can't get clock.\n");
> + return ret;
> + }
> + ret = clk_enable(clk);
> + if (ret) {
> + printk(KERN_ERR "IMX AHCI can't enable clock.\n");
> + clk_put(clk);
> + return ret;
> + }
> +
> + /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
> + clk = clk_get(dev, "usb_phy1");
... this clock is not associated with the device, it just happens to be
used for this purpose on LOCO. Or is this this really not LOCO specific
but i.MX53 specific? If this is LOCO specific you should pass NULL as
the device pointer. If this is i.MX53 specific we should discuss about
adding a imx53_init_sata as then all of this function is not LOCO
specific.
Have these patches undergone some Linaro internal review? These are
really not ready for the wider world.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
2011-03-15 9:32 ` Sascha Hauer
@ 2011-03-16 9:56 ` Zhu Richard-R65037
0 siblings, 0 replies; 8+ messages in thread
From: Zhu Richard-R65037 @ 2011-03-16 9:56 UTC (permalink / raw)
To: linux-arm-kernel
Hi Sascha:
Best Regards
Richard Zhu
> -----Original Message-----
> From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
> Sent: Tuesday, March 15, 2011 5:33 PM
> To: Zhu Richard-R65037
> Cc: linux-arm-kernel at lists.infradead.org; jgarzik at pobox.com;
> kernel at pengutronix.de; linux-ide at vger.kernel.org;
> avorontsov at ru.mvista.com; eric at eukrea.com; eric.miao at linaro.org
> Subject: Re: [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
>
> On Mon, Mar 14, 2011 at 05:55:44PM +0800, Richard Zhu wrote:
> > Signed-off-by: Richard Zhu <Hong-Xing.Zhu@freescale.com>
> > ---
> > arch/arm/mach-mx5/board-mx53_loco.c | 120
> > +++++++++++++++++++++++++++++++++++
> > 1 files changed, 120 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/arm/mach-mx5/board-mx53_loco.c
> > b/arch/arm/mach-mx5/board-mx53_loco.c
> > index 0a18f8d..9a7bbea 100644
> > --- a/arch/arm/mach-mx5/board-mx53_loco.c
> > +++ b/arch/arm/mach-mx5/board-mx53_loco.c
> > @@ -23,11 +23,13 @@
> > #include <linux/fec.h>
> > #include <linux/delay.h>
> > #include <linux/gpio.h>
> > +#include <linux/ahci_platform.h>
> >
> > #include <mach/common.h>
> > #include <mach/hardware.h>
> > #include <mach/imx-uart.h>
> > #include <mach/iomux-mx53.h>
> > +#include <mach/ahci_sata.h>
> >
> > #include <asm/mach-types.h>
> > #include <asm/mach/arch.h>
> > @@ -203,6 +205,123 @@ static const struct imxi2c_platform_data
> mx53_loco_i2c_data __initconst = {
> > .bitrate = 100000,
> > };
> >
> > +/* HW Initialization, if return 0, initialization is successful. */
> > +static int sata_init(struct device *dev, void __iomem *addr)
>
> Isn't this addr pointer exactly the address you remap again below?
Yes, it is.
Would re-use this parameter later.
>
> > +{
> > + void __iomem *mmio;
> > + struct clk *clk;
> > + int ret = 0;
> > + u32 tmpdata;
> > +
> > + clk = clk_get(dev, "imx_sata_clk");
>
> This one is associated with the device, so passing in dev here is ok,
> but...
>
> > + ret = IS_ERR(clk);
> > + if (ret) {
> > + printk(KERN_ERR "IMX AHCI can't get clock.\n");
> > + return ret;
> > + }
> > + ret = clk_enable(clk);
> > + if (ret) {
> > + printk(KERN_ERR "IMX AHCI can't enable clock.\n");
> > + clk_put(clk);
> > + return ret;
> > + }
> > +
> > + /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
> > + clk = clk_get(dev, "usb_phy1");
>
> ... this clock is not associated with the device, it just happens to be
> used for this purpose on LOCO. Or is this this really not LOCO specific
> but i.MX53 specific? If this is LOCO specific you should pass NULL as the
> device pointer. If this is i.MX53 specific we should discuss about adding
> a imx53_init_sata as then all of this function is not LOCO specific.
>
This is related to the HW design.
On MX53 SOC, the AHCI bus clk can be sourced from internal USB_PHY1 clk, or one external
crystal oscillator.
I would create external two functions later, one used for internal clk initialization, and
the other would be used when external crystal oscillator is used.
and move these codes into the internal clk initialization function.
How do you think about it?
>
> Have these patches undergone some Linaro internal review? These are
> really not ready for the wider world.
>
> Sascha
>
> --
> Pengutronix e.K. |
> |
> Industrial Linux Solutions | http://www.pengutronix.de/
> |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0
> |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555
> |
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-03-16 9:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-10 8:59 [RFC PATCH 1/2] AHCI Add the AHCI SATA feature on MX53 platforms Richard Zhu
2011-03-10 8:59 ` [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Richard Zhu
-- strict thread matches above, loose matches on Subject: below --
2011-03-14 9:55 [RFC PATCH 1/2] AHCI Add the AHCI SATA feature on MX53 platforms Richard Zhu
2011-03-14 9:55 ` [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Richard Zhu
2011-03-14 14:50 ` Jeff Garzik
2011-03-15 9:02 ` Sascha Hauer
2011-03-16 9:49 ` Zhu Richard-R65037
2011-03-15 9:32 ` Sascha Hauer
2011-03-16 9:56 ` Zhu Richard-R65037
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).