diff mbox series

[U-Boot,08/10] ata: dwc_ahsata: Add ahci driver model support

Message ID 20190301121101.14163-9-smoch@web.de
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show
Series tbs2910 fixes and driver model conversion | expand

Commit Message

Sören Moch March 1, 2019, 12:10 p.m. UTC
Disable this support for cm_fx6 to avoid breakage.

Signed-off-by: Soeren Moch <smoch@web.de>
---
It would be easy to add weak board_ahci_enable/disable functions which
can be overwritten (e.g. in the cm_fx6 board file) to handle power enable/
disable on driver probe/remove. But I have no idea why this board needs these
repeated probe/remove calls for the same sata device. In my tests on a
tbs2910 board a sata harddisk is always recognized by a 'sata init' command,
also without this probe loop.
If this can be ironed out, we can remove the DWC_AHSATA_AHCI config option.

Cc: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Marcel Ziswiler <marcel@ziswiler.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
---
 configs/cm_fx6_defconfig |  1 +
 drivers/ata/Kconfig      |  8 ++++++++
 drivers/ata/dwc_ahsata.c | 24 ++++++++++++++++++++++++
 3 files changed, 33 insertions(+)

--
2.17.1

Comments

Sören Moch March 7, 2019, 8:33 a.m. UTC | #1
On 01.03.19 13:10, Soeren Moch wrote:
> Disable this support for cm_fx6 to avoid breakage.
>
> Signed-off-by: Soeren Moch <smoch@web.de>
> ---
> It would be easy to add weak board_ahci_enable/disable functions which
> can be overwritten (e.g. in the cm_fx6 board file) to handle power enable/
> disable on driver probe/remove. But I have no idea why this board needs these
> repeated probe/remove calls for the same sata device. In my tests on a
> tbs2910 board a sata harddisk is always recognized by a 'sata init' command,
> also without this probe loop.
> If this can be ironed out, we can remove the DWC_AHSATA_AHCI config option.
>
> Cc: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: Marcel Ziswiler <marcel@ziswiler.com>
> Cc: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: u-boot@lists.denx.de
> ---

After rebasing this patch series from v2019.04-rc2 to -rc3, I get this:

Matrix U-Boot> sata init

AHCI 0001.0300 32 slots 1 ports 3 Gbps 0x1 impl SATA mode

flags: ncq stag pm led clo only pmp pio slum part

Can not start port 0

data abort

pc : [<8ffab37c>]          lr : [<8ffab595>]

reloc pc : [<1781837c>]    lr : [<17818595>]

sp : 87f909c8  ip : 87f90cd4     fp : 00000004

r10: 6c41202e  r9 : 87f90ea0     r8 : 00000000

r7 : 87f90a80  r6 : 00000200     r5 : 00000000  r4 : 87f90a80

r3 : 00000070  r2 : 87f90cc0     r1 : 87f90cc0  r0 : 00000000

Flags: nzcv  IRQs off  FIQs off  Mode SVC_32

Code: fb03231c f8d3030b 9001a00c 9e0c4611 (3038f8da)

Resetting CPU ...


Any idea what got broken here?

Thanks,
Soeren
Sören Moch March 8, 2019, 8:19 p.m. UTC | #2
On 07.03.19 09:33, Soeren Moch wrote:
> On 01.03.19 13:10, Soeren Moch wrote:
>> Disable this support for cm_fx6 to avoid breakage.
>>
>> Signed-off-by: Soeren Moch <smoch@web.de>
>> ---
>> It would be easy to add weak board_ahci_enable/disable functions which
>> can be overwritten (e.g. in the cm_fx6 board file) to handle power enable/
>> disable on driver probe/remove. But I have no idea why this board needs these
>> repeated probe/remove calls for the same sata device. In my tests on a
>> tbs2910 board a sata harddisk is always recognized by a 'sata init' command,
>> also without this probe loop.
>> If this can be ironed out, we can remove the DWC_AHSATA_AHCI config option.
>>
>> Cc: Nikita Kiryanov <nikita@compulab.co.il>
>> Cc: Stefano Babic <sbabic@denx.de>
>> Cc: Fabio Estevam <festevam@gmail.com>
>> Cc: Marcel Ziswiler <marcel@ziswiler.com>
>> Cc: Stefan Roese <sr@denx.de>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: u-boot@lists.denx.de
>> ---
> After rebasing this patch series from v2019.04-rc2 to -rc3, I get this:
>
> Matrix U-Boot> sata init
>
> AHCI 0001.0300 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
>
> flags: ncq stag pm led clo only pmp pio slum part
>
> Can not start port 0
>
> data abort
>
> pc : [<8ffab37c>]          lr : [<8ffab595>]
>
> reloc pc : [<1781837c>]    lr : [<17818595>]
>
> sp : 87f909c8  ip : 87f90cd4     fp : 00000004
>
> r10: 6c41202e  r9 : 87f90ea0     r8 : 00000000
>
> r7 : 87f90a80  r6 : 00000200     r5 : 00000000  r4 : 87f90a80
>
> r3 : 00000070  r2 : 87f90cc0     r1 : 87f90cc0  r0 : 00000000
>
> Flags: nzcv  IRQs off  FIQs off  Mode SVC_32
>
> Code: fb03231c f8d3030b 9001a00c 9e0c4611 (3038f8da)
>
> Resetting CPU ...
>
>
> Any idea what got broken here?
This was caused by a bad power supply.
So this patch series still works fine on top of v2019.04-rc3.

Sorry for the noise,
Soeren
diff mbox series

Patch

diff --git a/configs/cm_fx6_defconfig b/configs/cm_fx6_defconfig
index c8d1e83111..1623357132 100644
--- a/configs/cm_fx6_defconfig
+++ b/configs/cm_fx6_defconfig
@@ -51,6 +51,7 @@  CONFIG_DEFAULT_DEVICE_TREE="imx6q-cm-fx6"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DWC_AHSATA=y
+# CONFIG_DWC_AHSATA_AHCI is not set
 CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MMC=y
 CONFIG_FSL_ESDHC=y
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 49a056e941..d7818c2d68 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -66,6 +66,14 @@  config DWC_AHSATA
 	  Enable this driver to support the DWC AHSATA SATA controller found
 	  in i.MX5 and i.MX6 SoCs.

+config DWC_AHSATA_AHCI
+	bool "Enable DWC AHSATA AHCI driver support"
+	depends on DWC_AHSATA
+	depends on AHCI
+	default y
+	help
+	  Enable this option unless you need your private ahci implementation
+
 config FSL_SATA
 	bool "Enable Freescale SATA controller driver support"
 	select LIBATA
diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 6fe5641dd9..afced8e7e3 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -16,6 +16,7 @@ 
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/mach-imx/sata.h>
 #include <linux/bitops.h>
 #include <linux/ctype.h>
 #include <linux/errno.h>
@@ -1020,6 +1021,9 @@  int dwc_ahsata_probe(struct udevice *dev)
 	struct ahci_uc_priv *uc_priv = dev_get_uclass_priv(dev);
 	int ret;

+#if defined(CONFIG_MX6)
+	setup_sata();
+#endif
 	uc_priv->host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
 			ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | ATA_FLAG_NO_ATAPI;
 	uc_priv->mmio_base = (void __iomem *)dev_read_addr(dev);
@@ -1067,4 +1071,24 @@  U_BOOT_DRIVER(dwc_ahsata_blk) = {
 	.ops		= &dwc_ahsata_blk_ops,
 };

+#if CONFIG_IS_ENABLED(DWC_AHSATA_AHCI)
+struct ahci_ops dwc_ahsata_ahci_ops = {
+	.port_status = dwc_ahsata_port_status,
+	.reset       = dwc_ahsata_bus_reset,
+	.scan        = dwc_ahsata_scan,
+};
+
+static const struct udevice_id dwc_ahsata_ahci_ids[] = {
+	{ .compatible = "fsl,imx6q-ahci" },
+	{ }
+};
+
+U_BOOT_DRIVER(dwc_ahsata_ahci) = {
+	.name     = "dwc_ahsata_ahci",
+	.id       = UCLASS_AHCI,
+	.of_match = dwc_ahsata_ahci_ids,
+	.ops      = &dwc_ahsata_ahci_ops,
+	.probe    = dwc_ahsata_probe,
+};
+#endif
 #endif