]> git.sur5r.net Git - u-boot/commitdiff
arm: mx6: cm_fx6: add sata support
authorNikita Kiryanov <nikita@compulab.co.il>
Wed, 20 Aug 2014 12:09:06 +0000 (15:09 +0300)
committerStefano Babic <sbabic@denx.de>
Tue, 9 Sep 2014 13:37:08 +0000 (15:37 +0200)
Add support for SATA.

Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@ti.com>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
board/compulab/cm_fx6/cm_fx6.c
board/compulab/cm_fx6/common.h
include/configs/cm_fx6.h

index 1664fe866e8d8b94cde7e556e103e0185fae642d..fdb8ebf9e75567c41965d4018b306f2266ffc5e8 100644 (file)
 #include <miiphy.h>
 #include <netdev.h>
 #include <fdt_support.h>
+#include <sata.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/iomux.h>
 #include <asm/imx-common/mxc_i2c.h>
+#include <asm/imx-common/sata.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include "common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_DWC_AHSATA
+static int cm_fx6_issd_gpios[] = {
+       /* The order of the GPIOs in the array is important! */
+       CM_FX6_SATA_PHY_SLP,
+       CM_FX6_SATA_NRSTDLY,
+       CM_FX6_SATA_PWREN,
+       CM_FX6_SATA_NSTANDBY1,
+       CM_FX6_SATA_NSTANDBY2,
+       CM_FX6_SATA_LDO_EN,
+};
+
+static void cm_fx6_sata_power(int on)
+{
+       int i;
+
+       if (!on) { /* tell the iSSD that the power will be removed */
+               gpio_direction_output(CM_FX6_SATA_PWLOSS_INT, 1);
+               mdelay(10);
+       }
+
+       for (i = 0; i < ARRAY_SIZE(cm_fx6_issd_gpios); i++) {
+               gpio_direction_output(cm_fx6_issd_gpios[i], on);
+               udelay(100);
+       }
+
+       if (!on) /* for compatibility lower the power loss interrupt */
+               gpio_direction_output(CM_FX6_SATA_PWLOSS_INT, 0);
+}
+
+static iomux_v3_cfg_t const sata_pads[] = {
+       /* SATA PWR */
+       IOMUX_PADS(PAD_ENET_TX_EN__GPIO1_IO28 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+       IOMUX_PADS(PAD_EIM_A22__GPIO2_IO16    | MUX_PAD_CTRL(NO_PAD_CTRL)),
+       IOMUX_PADS(PAD_EIM_D20__GPIO3_IO20    | MUX_PAD_CTRL(NO_PAD_CTRL)),
+       IOMUX_PADS(PAD_EIM_A25__GPIO5_IO02    | MUX_PAD_CTRL(NO_PAD_CTRL)),
+       /* SATA CTRL */
+       IOMUX_PADS(PAD_ENET_TXD0__GPIO1_IO30  | MUX_PAD_CTRL(NO_PAD_CTRL)),
+       IOMUX_PADS(PAD_EIM_D23__GPIO3_IO23    | MUX_PAD_CTRL(NO_PAD_CTRL)),
+       IOMUX_PADS(PAD_EIM_D29__GPIO3_IO29    | MUX_PAD_CTRL(NO_PAD_CTRL)),
+       IOMUX_PADS(PAD_EIM_A23__GPIO6_IO06    | MUX_PAD_CTRL(NO_PAD_CTRL)),
+       IOMUX_PADS(PAD_EIM_BCLK__GPIO6_IO31   | MUX_PAD_CTRL(NO_PAD_CTRL)),
+};
+
+static void cm_fx6_setup_issd(void)
+{
+       SETUP_IOMUX_PADS(sata_pads);
+       /* Make sure this gpio has logical 0 value */
+       gpio_direction_output(CM_FX6_SATA_PWLOSS_INT, 0);
+       udelay(100);
+
+       cm_fx6_sata_power(0);
+       mdelay(250);
+       cm_fx6_sata_power(1);
+}
+
+#define CM_FX6_SATA_INIT_RETRIES       10
+int sata_initialize(void)
+{
+       int err, i;
+
+       cm_fx6_setup_issd();
+       for (i = 0; i < CM_FX6_SATA_INIT_RETRIES; i++) {
+               err = setup_sata();
+               if (err) {
+                       printf("SATA setup failed: %d\n", err);
+                       return err;
+               }
+
+               udelay(100);
+
+               err = __sata_initialize();
+               if (!err)
+                       break;
+
+               /* There is no device on the SATA port */
+               if (sata_port_status(0, 0) == 0)
+                       break;
+
+               /* There's a device, but link not established. Retry */
+       }
+
+       return err;
+}
+#endif
+
 #ifdef CONFIG_SYS_I2C_MXC
 #define I2C_PAD_CTRL   (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
                        PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \
index f841c90c54943be6d04ec4f15e65f5b9c29a74ff..76097f80af364ed211063062de8150d50d31c8a8 100644 (file)
 #define CM_FX6_ENET_NRST       IMX_GPIO_NR(2, 8)
 #define CM_FX6_USB_HUB_RST     IMX_GPIO_NR(7, 8)
 #define SB_FX6_USB_OTG_PWR     IMX_GPIO_NR(3, 22)
+#define CM_FX6_ENET_NRST       IMX_GPIO_NR(2, 8)
+#define CM_FX6_USB_HUB_RST     IMX_GPIO_NR(7, 8)
+#define SB_FX6_USB_OTG_PWR     IMX_GPIO_NR(3, 22)
+#define CM_FX6_SATA_PWREN      IMX_GPIO_NR(1, 28)
+#define CM_FX6_SATA_VDDC_CTRL  IMX_GPIO_NR(1, 30)
+#define CM_FX6_SATA_LDO_EN     IMX_GPIO_NR(2, 16)
+#define CM_FX6_SATA_NSTANDBY1  IMX_GPIO_NR(3, 20)
+#define CM_FX6_SATA_PHY_SLP    IMX_GPIO_NR(3, 23)
+#define CM_FX6_SATA_STBY_REQ   IMX_GPIO_NR(3, 29)
+#define CM_FX6_SATA_NSTANDBY2  IMX_GPIO_NR(5, 2)
+#define CM_FX6_SATA_NRSTDLY    IMX_GPIO_NR(6, 6)
+#define CM_FX6_SATA_PWLOSS_INT IMX_GPIO_NR(6, 31)
+
 
 void cm_fx6_set_usdhc_iomux(void);
 void cm_fx6_set_ecspi_iomux(void);
index cccc989f9ce846a032483c34a7923242b762af27..10d02b4e18c9b843387dacec2c3eba1b332e7eb7 100644 (file)
        "mmcboot=echo Booting from mmc ...; " \
                "run mmcargs; " \
                "run doboot\0" \
+       "satadev=0\0" \
+       "sataroot=/dev/sda2 rw rootwait\0" \
+       "sataargs=setenv bootargs console=${console} " \
+               "root=${sataroot} " \
+               "${video}\0" \
+       "loadsatabootscript=load sata ${satadev} ${loadaddr} ${bootscr}\0" \
+       "satabootscript=echo Running bootscript from sata ...; " \
+               "source ${loadaddr}\0" \
+       "sataloadkernel=load sata ${satadev} ${loadaddr} ${kernel}\0" \
+       "sataloadfdt=load sata ${satadev} ${fdtaddr} ${fdtfile}\0" \
+       "sataboot=echo Booting from sata ...; "\
+               "run sataargs; " \
+               "run doboot\0" \
        "nandroot=/dev/mtdblock4 rw\0" \
        "nandrootfstype=ubifs\0" \
        "nandargs=setenv bootargs console=${console} " \
                                "fi;" \
                        "fi;" \
                "fi;" \
+               "if sata init; then " \
+                       "if run loadsatabootscript; then " \
+                               "run satabootscript;" \
+                       "else "\
+                               "if run sataloadkernel; then " \
+                                       "if ${loadfdt}; then " \
+                                               "run sataloadfdt; " \
+                                       "fi;" \
+                                       "run sataboot;" \
+                               "fi;" \
+                       "fi;" \
+               "fi;" \
                "run nandboot\0"
 
 #define CONFIG_BOOTCOMMAND \
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_I2C_EEPROM_BUS      2
 
+/* SATA */
+#define CONFIG_CMD_SATA
+#define CONFIG_SYS_SATA_MAX_DEVICE     1
+#define CONFIG_LIBATA
+#define CONFIG_LBA48
+#define CONFIG_DWC_AHSATA
+#define CONFIG_DWC_AHSATA_PORT_ID      0
+#define CONFIG_DWC_AHSATA_BASE_ADDR    SATA_ARB_BASE_ADDR
+
 /* GPIO */
 #define CONFIG_MXC_GPIO