[U-Boot] [PATCH 6/8] ARM: imx: dh-imx6: Convert SATA support to DM
Stefan Roese
sr at denx.de
Sun May 12 10:04:47 UTC 2019
On 12.05.19 02:57, Marek Vasut wrote:
> Enable DM SATA support on DHCOM iMX6 PDK2.
> Convert board code to match the DM support.
>
> Signed-off-by: Marek Vasut <marex at denx.de>
> Cc: Fabio Estevam <fabio.estevam at nxp.com>
> Cc: Ludwig Zenz <lzenz at dh-electronics.com>
> Cc: Stefano Babic <sbabic at denx.de>
> ---
> board/dhelectronics/dh_imx6/dh_imx6.c | 55 +++++++++++++++++++++++++--
> configs/dh_imx6_defconfig | 2 +
> include/configs/dh_imx6.h | 5 ---
> 3 files changed, 53 insertions(+), 9 deletions(-)
>
> diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c
> index 193bb0eade..2381df84b4 100644
> --- a/board/dhelectronics/dh_imx6/dh_imx6.c
> +++ b/board/dhelectronics/dh_imx6/dh_imx6.c
> @@ -20,6 +20,8 @@
> #include <asm/mach-imx/iomux-v3.h>
> #include <asm/mach-imx/mxc_i2c.h>
> #include <asm/mach-imx/sata.h>
> +#include <ahci.h>
> +#include <dwc_ahsata.h>
> #include <environment.h>
> #include <errno.h>
> #include <fsl_esdhc.h>
> @@ -302,10 +304,6 @@ int board_init(void)
> }
> #endif
>
> -#ifdef CONFIG_SATA
> - setup_sata();
> -#endif
> -
> setup_dhcom_mac_from_fuse();
>
> return 0;
> @@ -384,3 +382,52 @@ int checkboard(void)
> puts("Board: DHCOM i.MX6\n");
> return 0;
> }
> +
> +#if CONFIG_IS_ENABLED(AHCI)
> +static int sata_imx_probe(struct udevice *dev)
> +{
> + int i, err;
> +
> + for (i = 0; i < 10; i++) {
> + err = setup_sata();
> + if (err) {
> + printf("SATA setup failed: %d\n", err);
> + return err;
> + }
> +
> + udelay(100);
> +
> + err = dwc_ahsata_probe(dev);
> + if (!err)
> + break;
> +
> + /* There is no device on the SATA port */
> + if (sata_dm_port_status(0, 0) == 0)
> + break;
> +
> + /* There's a device, but link not established. Retry */
> + device_remove(dev, DM_REMOVE_NORMAL);
> + }
> +
> + return 0;
> +}
> +
> +struct ahci_ops sata_imx_ops = {
> + .port_status = dwc_ahsata_port_status,
> + .reset = dwc_ahsata_bus_reset,
> + .scan = dwc_ahsata_scan,
> +};
> +
> +static const struct udevice_id sata_imx_ids[] = {
> + { .compatible = "fsl,imx6q-ahci" },
> + { }
> +};
> +
> +U_BOOT_DRIVER(sata_imx) = {
> + .name = "dwc_ahci",
> + .id = UCLASS_AHCI,
> + .of_match = sata_imx_ids,
> + .ops = &sata_imx_ops,
> + .probe = sata_imx_probe,
> +};
> +#endif /* AHCI */
Is this code dh_imx6 specific in any way? If not, then it would be
better placed in drivers/ata, so that other i.MX6 boards might use
it as well. Or am I missing something?
Thanks,
Stefan
More information about the U-Boot
mailing list