diff mbox

[U-Boot,2/2] mx6cuboxi: Add support for sata

Message ID 20170515172446.1014-3-pbrobinson@gmail.com
State Changes Requested
Delegated to: Stefano Babic
Headers show

Commit Message

Peter Robinson May 15, 2017, 5:24 p.m. UTC
The Cubox-i and Hummingboard series of devices have an option of
SATA on board, and depending on how the fuses are blown even the
option to boot SPL from SATA. So enable support for it so it can
be used to boot the OS from if people desire.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c |  7 +++++++
 configs/mx6cuboxi_defconfig          | 23 ++++++++++++-----------
 include/configs/mx6cuboxi.h          | 11 +++++++++++
 3 files changed, 30 insertions(+), 11 deletions(-)

Comments

Jonathan Gray May 16, 2017, 5:50 a.m. UTC | #1
On Mon, May 15, 2017 at 06:24:46PM +0100, Peter Robinson wrote:
> The Cubox-i and Hummingboard series of devices have an option of
> SATA on board, and depending on how the fuses are blown even the
> option to boot SPL from SATA. So enable support for it so it can
> be used to boot the OS from if people desire.
> 
> Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  board/solidrun/mx6cuboxi/mx6cuboxi.c |  7 +++++++
>  configs/mx6cuboxi_defconfig          | 23 ++++++++++++-----------
>  include/configs/mx6cuboxi.h          | 11 +++++++++++
>  3 files changed, 30 insertions(+), 11 deletions(-)
> 
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index 285588d80a..59a78dfa6a 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> @@ -22,6 +22,7 @@
>  #include <linux/errno.h>
>  #include <asm/gpio.h>
>  #include <asm/imx-common/iomux-v3.h>
> +#include <asm/imx-common/sata.h>
>  #include <asm/imx-common/video.h>
>  #include <mmc.h>
>  #include <fsl_esdhc.h>
> @@ -314,6 +315,12 @@ int board_early_init_f(void)
>  	ret = setup_display();
>  #endif
>  
> +#ifdef CONFIG_CMD_SATA
> +	/* Only mx6q/mx6q has SATA */
> +	if (is_mx6dq())
> +		setup_sata();

Comment was intended to be mx6d/mx6q?

Though the test here may not be needed as setup_sata() returns early if
not available.  And mx6cuboxi.c wouldn't need to be updated here if a
i.MX 6DualPlus or i.MX 6QuadPlus board from SolidRun shows up at some
point in the future.

u-boot/arch/arm/imx-common/sata.c

int setup_sata(void)
{
	struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
	int ret;

	if (!is_mx6dq() && !is_mx6dqp())
		return 1;

> +#endif
> +
>  #ifdef CONFIG_USB_EHCI_MX6
>  	setup_usb();
>  #endif
> diff --git a/configs/mx6cuboxi_defconfig b/configs/mx6cuboxi_defconfig
> index c34beb74e2..ca5f5189f6 100644
> --- a/configs/mx6cuboxi_defconfig
> +++ b/configs/mx6cuboxi_defconfig
> @@ -1,30 +1,31 @@
>  CONFIG_ARM=y
>  CONFIG_ARCH_MX6=y
> +CONFIG_TARGET_MX6CUBOXI=y
> +CONFIG_SPL=y
> +CONFIG_SPL_EXT_SUPPORT=y
>  CONFIG_SPL_GPIO_SUPPORT=y
> +CONFIG_SPL_I2C_SUPPORT=y
>  CONFIG_SPL_LIBCOMMON_SUPPORT=y
> +CONFIG_SPL_LIBDISK_SUPPORT=y
>  CONFIG_SPL_LIBGENERIC_SUPPORT=y
> -CONFIG_TARGET_MX6CUBOXI=y
>  CONFIG_SPL_MMC_SUPPORT=y
> +# CONFIG_SPL_PARTITION_UUIDS is not set
>  CONFIG_SPL_SERIAL_SUPPORT=y
> -CONFIG_SPL_LIBDISK_SUPPORT=y
>  CONFIG_SPL_WATCHDOG_SUPPORT=y
> -# CONFIG_CMD_BMODE is not set
>  CONFIG_VIDEO=y
>  CONFIG_DISTRO_DEFAULTS=y
>  CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/imx-common/spl_sd.cfg,MX6QDL"
>  # CONFIG_SYS_STDIO_DEREGISTER is not set
>  CONFIG_BOARD_EARLY_INIT_F=y
> -CONFIG_SPL=y
> -CONFIG_SPL_EXT_SUPPORT=y
> -CONFIG_SPL_I2C_SUPPORT=y
> -# CONFIG_CMD_IMLS is not set
> +# CONFIG_CMD_BMODE is not set
> +CONFIG_CMD_CACHE=y
> +CONFIG_CMD_EXT4_WRITE=y
>  # CONFIG_CMD_FLASH is not set
> +CONFIG_CMD_GPIO=y
> +# CONFIG_CMD_IMLS is not set
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_SATA=y
>  CONFIG_CMD_USB=y
> -CONFIG_CMD_GPIO=y
> -CONFIG_CMD_CACHE=y
> -CONFIG_CMD_EXT4_WRITE=y
> -# CONFIG_SPL_PARTITION_UUIDS is not set
>  CONFIG_DM=y
>  CONFIG_DM_THERMAL=y
>  CONFIG_USB=y
> diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
> index 84fdf656cd..be071769fc 100644
> --- a/include/configs/mx6cuboxi.h
> +++ b/include/configs/mx6cuboxi.h
> @@ -21,6 +21,16 @@
>  /* MMC Configs */
>  #define CONFIG_SYS_FSL_ESDHC_ADDR	USDHC2_BASE_ADDR
>  
> +/* SATA Configuration */
> +#ifdef CONFIG_CMD_SATA
> +#define CONFIG_DWC_AHSATA
> +#define CONFIG_SYS_SATA_MAX_DEVICE      1
> +#define CONFIG_DWC_AHSATA_PORT_ID       0
> +#define CONFIG_DWC_AHSATA_BASE_ADDR     SATA_ARB_BASE_ADDR
> +#define CONFIG_LBA48
> +#define CONFIG_LIBATA
> +#endif
> +
>  /* Ethernet Configuration */
>  #define CONFIG_FEC_MXC
>  #define CONFIG_MII
> @@ -119,6 +129,7 @@
>  
>  #define BOOT_TARGET_DEVICES(func) \
>  	func(MMC, mmc, 0) \
> +	func(SATA, sata, 0) \
>  	func(USB, usb, 0) \
>  	func(PXE, pxe, na) \
>  	func(DHCP, dhcp, na)
> -- 
> 2.13.0
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Fabio Estevam June 1, 2017, 4:24 p.m. UTC | #2
On Mon, May 15, 2017 at 2:24 PM, Peter Robinson <pbrobinson@gmail.com> wrote:
> The Cubox-i and Hummingboard series of devices have an option of
> SATA on board, and depending on how the fuses are blown even the
> option to boot SPL from SATA. So enable support for it so it can
> be used to boot the OS from if people desire.
>
> Signed-off-by: Peter Robinson <pbrobinson@gmail.com>

Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Fabio Estevam June 1, 2017, 4:27 p.m. UTC | #3
On Tue, May 16, 2017 at 2:50 AM, Jonathan Gray <jsg@jsg.id.au> wrote:

> Comment was intended to be mx6d/mx6q?
>
> Though the test here may not be needed as setup_sata() returns early if
> not available.  And mx6cuboxi.c wouldn't need to be updated here if a
> i.MX 6DualPlus or i.MX 6QuadPlus board from SolidRun shows up at some
> point in the future.
>
> u-boot/arch/arm/imx-common/sata.c
>
> int setup_sata(void)
> {
>         struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
>         int ret;
>
>         if (!is_mx6dq() && !is_mx6dqp())
>                 return 1;

Good points!

Peter, please send a v2 taking into account Jonathan's comments. Thanks
Fabio Estevam June 29, 2017, 2:36 p.m. UTC | #4
[Adding the list on Cc]

On Thu, Jun 29, 2017 at 11:33 AM, Peter Robinson <pbrobinson@gmail.com> wrote:

> So I can just drop that check?

Yes, doing like this would be enough:

+#ifdef CONFIG_CMD_SATA
+               setup_sata();
+#endif
diff mbox

Patch

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 285588d80a..59a78dfa6a 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -22,6 +22,7 @@ 
 #include <linux/errno.h>
 #include <asm/gpio.h>
 #include <asm/imx-common/iomux-v3.h>
+#include <asm/imx-common/sata.h>
 #include <asm/imx-common/video.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
@@ -314,6 +315,12 @@  int board_early_init_f(void)
 	ret = setup_display();
 #endif
 
+#ifdef CONFIG_CMD_SATA
+	/* Only mx6q/mx6q has SATA */
+	if (is_mx6dq())
+		setup_sata();
+#endif
+
 #ifdef CONFIG_USB_EHCI_MX6
 	setup_usb();
 #endif
diff --git a/configs/mx6cuboxi_defconfig b/configs/mx6cuboxi_defconfig
index c34beb74e2..ca5f5189f6 100644
--- a/configs/mx6cuboxi_defconfig
+++ b/configs/mx6cuboxi_defconfig
@@ -1,30 +1,31 @@ 
 CONFIG_ARM=y
 CONFIG_ARCH_MX6=y
+CONFIG_TARGET_MX6CUBOXI=y
+CONFIG_SPL=y
+CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_TARGET_MX6CUBOXI=y
 CONFIG_SPL_MMC_SUPPORT=y
+# CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_SPL_SERIAL_SUPPORT=y
-CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_SPL_WATCHDOG_SUPPORT=y
-# CONFIG_CMD_BMODE is not set
 CONFIG_VIDEO=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/imx-common/spl_sd.cfg,MX6QDL"
 # CONFIG_SYS_STDIO_DEREGISTER is not set
 CONFIG_BOARD_EARLY_INIT_F=y
-CONFIG_SPL=y
-CONFIG_SPL_EXT_SUPPORT=y
-CONFIG_SPL_I2C_SUPPORT=y
-# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_BMODE is not set
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT4_WRITE=y
 # CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_IMLS is not set
 CONFIG_CMD_MMC=y
+CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
-CONFIG_CMD_GPIO=y
-CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT4_WRITE=y
-# CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_DM=y
 CONFIG_DM_THERMAL=y
 CONFIG_USB=y
diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
index 84fdf656cd..be071769fc 100644
--- a/include/configs/mx6cuboxi.h
+++ b/include/configs/mx6cuboxi.h
@@ -21,6 +21,16 @@ 
 /* MMC Configs */
 #define CONFIG_SYS_FSL_ESDHC_ADDR	USDHC2_BASE_ADDR
 
+/* SATA Configuration */
+#ifdef CONFIG_CMD_SATA
+#define CONFIG_DWC_AHSATA
+#define CONFIG_SYS_SATA_MAX_DEVICE      1
+#define CONFIG_DWC_AHSATA_PORT_ID       0
+#define CONFIG_DWC_AHSATA_BASE_ADDR     SATA_ARB_BASE_ADDR
+#define CONFIG_LBA48
+#define CONFIG_LIBATA
+#endif
+
 /* Ethernet Configuration */
 #define CONFIG_FEC_MXC
 #define CONFIG_MII
@@ -119,6 +129,7 @@ 
 
 #define BOOT_TARGET_DEVICES(func) \
 	func(MMC, mmc, 0) \
+	func(SATA, sata, 0) \
 	func(USB, usb, 0) \
 	func(PXE, pxe, na) \
 	func(DHCP, dhcp, na)