All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/6] driver model bring-up of sata device on dra72 and dra74 evm
@ 2016-01-18  8:47 Mugunthan V N
  2016-01-18  8:47 ` [U-Boot] [PATCH 1/6] arm: omap: sata: move enable sata clocks to enable_basic_clocks() Mugunthan V N
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Mugunthan V N @ 2016-01-18  8:47 UTC (permalink / raw)
  To: u-boot

This patch series enables sata driver to adopt driver model. This
has been tested on the following evms (logs [1]) by loading
kernel and dtb from sata hard-disk.
* dra72 evm
* dra74 evm

Also pushed a branch for testing [2]

[1] - http://pastebin.ubuntu.com/14565924/
[2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git dm-sata

Mugunthan V N (6):
  arm: omap: sata: move enable sata clocks to enable_basic_clocks()
  dm: implement a SATA uclass
  arm: omap-common: sata: prepare driver for DM conversion
  drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata
    device
  defconfig: dra74_evm: enable sata driver model
  defconfig: dra72_evm: enable sata driver model

 arch/arm/cpu/armv7/omap-common/sata.c | 38 ++++++-------------
 arch/arm/cpu/armv7/omap5/hw_data.c    | 12 ++++++
 configs/dra72_evm_defconfig           |  2 +
 configs/dra74_evm_defconfig           |  2 +
 drivers/block/Kconfig                 | 17 +++++++++
 drivers/block/Makefile                |  3 ++
 drivers/block/dwc_ahci.c              | 71 +++++++++++++++++++++++++++++++++++
 drivers/block/sata-uclass.c           | 69 ++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h                |  1 +
 include/sata.h                        |  2 +
 10 files changed, 190 insertions(+), 27 deletions(-)
 create mode 100644 drivers/block/dwc_ahci.c
 create mode 100644 drivers/block/sata-uclass.c

-- 
2.7.0.rc3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 1/6] arm: omap: sata: move enable sata clocks to enable_basic_clocks()
  2016-01-18  8:47 [U-Boot] [PATCH 0/6] driver model bring-up of sata device on dra72 and dra74 evm Mugunthan V N
@ 2016-01-18  8:47 ` Mugunthan V N
  2016-01-19 18:09   ` Tom Rini
  2016-01-18  8:47 ` [U-Boot] [PATCH 2/6] dm: implement a SATA uclass Mugunthan V N
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-01-18  8:47 UTC (permalink / raw)
  To: u-boot

All the clocks which has to be enabled has to be done in
enable_basic_clocks(), so moving enable sata clock to common
clocks enable function.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 arch/arm/cpu/armv7/omap-common/sata.c | 23 -----------------------
 arch/arm/cpu/armv7/omap5/hw_data.c    | 12 ++++++++++++
 2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/sata.c b/arch/arm/cpu/armv7/omap-common/sata.c
index 2c2d1bc..0c82689 100644
--- a/arch/arm/cpu/armv7/omap-common/sata.c
+++ b/arch/arm/cpu/armv7/omap-common/sata.c
@@ -37,29 +37,6 @@ int init_sata(int dev)
 	int ret;
 	u32 val;
 
-	u32 const clk_domains_sata[] = {
-		0
-	};
-
-	u32 const clk_modules_hw_auto_sata[] = {
-		(*prcm)->cm_l3init_ocp2scp3_clkctrl,
-		0
-	};
-
-	u32 const clk_modules_explicit_en_sata[] = {
-		(*prcm)->cm_l3init_sata_clkctrl,
-		0
-	};
-
-	do_enable_clocks(clk_domains_sata,
-			 clk_modules_hw_auto_sata,
-			 clk_modules_explicit_en_sata,
-			 0);
-
-	/* Enable optional functional clock for SATA */
-	setbits_le32((*prcm)->cm_l3init_sata_clkctrl,
-		     SATA_CLKCTRL_OPTFCLKEN_MASK);
-
 	sata_phy.power_reg = (void __iomem *)(*ctrl)->control_phy_power_sata;
 
 	/* Power up the PHY */
diff --git a/arch/arm/cpu/armv7/omap5/hw_data.c b/arch/arm/cpu/armv7/omap5/hw_data.c
index 7f8c0a4..2e554bd 100644
--- a/arch/arm/cpu/armv7/omap5/hw_data.c
+++ b/arch/arm/cpu/armv7/omap5/hw_data.c
@@ -460,6 +460,9 @@ void enable_basic_clocks(void)
 		(*prcm)->cm_l4per_gpio6_clkctrl,
 		(*prcm)->cm_l4per_gpio7_clkctrl,
 		(*prcm)->cm_l4per_gpio8_clkctrl,
+#ifdef CONFIG_SCSI_AHCI_PLAT
+		(*prcm)->cm_l3init_ocp2scp3_clkctrl,
+#endif
 		0
 	};
 
@@ -478,6 +481,9 @@ void enable_basic_clocks(void)
 #ifdef CONFIG_TI_QSPI
 		(*prcm)->cm_l4per_qspi_clkctrl,
 #endif
+#ifdef CONFIG_SCSI_AHCI_PLAT
+		(*prcm)->cm_l3init_sata_clkctrl,
+#endif
 		0
 	};
 
@@ -510,6 +516,12 @@ void enable_basic_clocks(void)
 	setbits_le32((*prcm)->cm_l4per_qspi_clkctrl, (1<<24));
 #endif
 
+#ifdef CONFIG_SCSI_AHCI_PLAT
+	/* Enable optional functional clock for SATA */
+	setbits_le32((*prcm)->cm_l3init_sata_clkctrl,
+		     SATA_CLKCTRL_OPTFCLKEN_MASK);
+#endif
+
 	/* Enable SCRM OPT clocks for PER and CORE dpll */
 	setbits_le32((*prcm)->cm_wkupaon_scrm_clkctrl,
 			OPTFCLKEN_SCRM_PER_MASK);
-- 
2.7.0.rc3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 2/6] dm: implement a SATA uclass
  2016-01-18  8:47 [U-Boot] [PATCH 0/6] driver model bring-up of sata device on dra72 and dra74 evm Mugunthan V N
  2016-01-18  8:47 ` [U-Boot] [PATCH 1/6] arm: omap: sata: move enable sata clocks to enable_basic_clocks() Mugunthan V N
@ 2016-01-18  8:47 ` Mugunthan V N
  2016-01-18  9:23   ` Bin Meng
  2016-01-18  8:47 ` [U-Boot] [PATCH 3/6] arm: omap-common: sata: prepare driver for DM conversion Mugunthan V N
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-01-18  8:47 UTC (permalink / raw)
  To: u-boot

Implement a SATA uclass that can represent a SATA controller.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 drivers/block/Kconfig       | 10 +++++++
 drivers/block/Makefile      |  2 ++
 drivers/block/sata-uclass.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h      |  1 +
 4 files changed, 82 insertions(+)
 create mode 100644 drivers/block/sata-uclass.c

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index e69de29..44d8a6b 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -0,0 +1,10 @@
+menu "SATA Device Support"
+
+config SATA
+	bool "Enable driver model for SATA drivers"
+	depends on DM
+	help
+	  Enable driver model for block devices like SCSI. It uses the
+	  same API as block, but now implemented by the uclass.
+
+endmenu
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index eb8bda9..c2dae17 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -5,6 +5,8 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+obj-$(CONFIG_SATA) += sata-uclass.o
+
 obj-$(CONFIG_SCSI_AHCI) += ahci.o
 obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
 obj-$(CONFIG_FSL_SATA) += fsl_sata.o
diff --git a/drivers/block/sata-uclass.c b/drivers/block/sata-uclass.c
new file mode 100644
index 0000000..62773b6
--- /dev/null
+++ b/drivers/block/sata-uclass.c
@@ -0,0 +1,69 @@
+/*
+ * SATA device U-Class driver
+ *
+ * (C) Copyright 2016
+ *     Texas Instruments Incorporated, <www.ti.com>
+ *
+ * Author: Mugunthan V N <mugunthanvnm@ti.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/uclass-internal.h>
+#include <dm/device-internal.h>
+#include <errno.h>
+#include <scsi.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * struct mmc_uclass_priv - Holds information about a device used by the uclass
+ */
+struct sata_uclass_priv {
+	struct block_dev_desc_t *block_dev;
+};
+
+int scsi_get_device(int index, struct udevice **devp)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_find_device(UCLASS_SATA, index, &dev);
+	if (ret || !dev) {
+		printf("%d device not found\n", index);
+		return ret;
+	}
+
+	ret = device_probe(dev);
+	if (ret) {
+		error("device probe error\n");
+		return ret;
+	}
+
+	*devp = dev;
+
+	return ret;
+}
+
+void scsi_init(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = scsi_get_device(0, &dev);
+	if (ret || !dev) {
+		error("scsi device not found\n");
+		return;
+	}
+
+	scsi_scan(1);
+}
+
+UCLASS_DRIVER(sata) = {
+	.id		= UCLASS_SATA,
+	.name		= "sata",
+	.flags		= DM_UC_FLAG_SEQ_ALIAS,
+	.per_device_auto_alloc_size = sizeof(struct sata_uclass_priv),
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 27fa0b6..80977ca 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -55,6 +55,7 @@ enum uclass_id {
 	UCLASS_RESET,		/* Reset device */
 	UCLASS_REMOTEPROC,	/* Remote Processor device */
 	UCLASS_RTC,		/* Real time clock device */
+	UCLASS_SATA,		/* SATA devices */
 	UCLASS_SERIAL,		/* Serial UART */
 	UCLASS_SPI,		/* SPI bus */
 	UCLASS_SPI_FLASH,	/* SPI flash */
-- 
2.7.0.rc3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 3/6] arm: omap-common: sata: prepare driver for DM conversion
  2016-01-18  8:47 [U-Boot] [PATCH 0/6] driver model bring-up of sata device on dra72 and dra74 evm Mugunthan V N
  2016-01-18  8:47 ` [U-Boot] [PATCH 1/6] arm: omap: sata: move enable sata clocks to enable_basic_clocks() Mugunthan V N
  2016-01-18  8:47 ` [U-Boot] [PATCH 2/6] dm: implement a SATA uclass Mugunthan V N
@ 2016-01-18  8:47 ` Mugunthan V N
  2016-01-19 18:10   ` Tom Rini
  2016-01-18  8:47 ` [U-Boot] [PATCH 4/6] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device Mugunthan V N
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-01-18  8:47 UTC (permalink / raw)
  To: u-boot

Prepare sata driver for DM conversion by abstracting sata phy
init to seperate function.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 arch/arm/cpu/armv7/omap-common/sata.c | 13 +++++++++----
 include/sata.h                        |  2 ++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/sata.c b/arch/arm/cpu/armv7/omap-common/sata.c
index 0c82689..5ebd799 100644
--- a/arch/arm/cpu/armv7/omap-common/sata.c
+++ b/arch/arm/cpu/armv7/omap-common/sata.c
@@ -32,15 +32,20 @@ struct omap_pipe3 sata_phy = {
 	.dpll_map = dpll_map_sata,
 };
 
+int enable_sata_phy(void)
+{
+	sata_phy.power_reg = (void __iomem *)(*ctrl)->control_phy_power_sata;
+
+	/* Power up the PHY */
+	return phy_pipe3_power_on(&sata_phy);
+}
+
 int init_sata(int dev)
 {
 	int ret;
 	u32 val;
 
-	sata_phy.power_reg = (void __iomem *)(*ctrl)->control_phy_power_sata;
-
-	/* Power up the PHY */
-	phy_pipe3_power_on(&sata_phy);
+	enable_sata_phy();
 
 	/* Enable SATA module, No Idle, No Standby */
 	val = TI_SATA_IDLE_NO | TI_SATA_STANDBY_NO;
diff --git a/include/sata.h b/include/sata.h
index fa61da8..c2b5360 100644
--- a/include/sata.h
+++ b/include/sata.h
@@ -16,4 +16,6 @@ int sata_port_status(int dev, int port);
 
 extern block_dev_desc_t sata_dev_desc[];
 
+int enable_sata_phy(void);
+
 #endif
-- 
2.7.0.rc3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 4/6] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device
  2016-01-18  8:47 [U-Boot] [PATCH 0/6] driver model bring-up of sata device on dra72 and dra74 evm Mugunthan V N
                   ` (2 preceding siblings ...)
  2016-01-18  8:47 ` [U-Boot] [PATCH 3/6] arm: omap-common: sata: prepare driver for DM conversion Mugunthan V N
@ 2016-01-18  8:47 ` Mugunthan V N
  2016-01-19 18:11   ` Tom Rini
  2016-01-18  8:47 ` [U-Boot] [PATCH 5/6] defconfig: dra74_evm: enable sata driver model Mugunthan V N
  2016-01-18  8:47 ` [U-Boot] [PATCH 6/6] defconfig: dra72_evm: " Mugunthan V N
  5 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-01-18  8:47 UTC (permalink / raw)
  To: u-boot

Implement a sata driver for Synopsys DWC sata device based on
U-boot driver model.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 arch/arm/cpu/armv7/omap-common/sata.c |  2 +
 drivers/block/Kconfig                 |  7 ++++
 drivers/block/Makefile                |  1 +
 drivers/block/dwc_ahci.c              | 71 +++++++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+)
 create mode 100644 drivers/block/dwc_ahci.c

diff --git a/arch/arm/cpu/armv7/omap-common/sata.c b/arch/arm/cpu/armv7/omap-common/sata.c
index 5ebd799..e47e01b 100644
--- a/arch/arm/cpu/armv7/omap-common/sata.c
+++ b/arch/arm/cpu/armv7/omap-common/sata.c
@@ -40,6 +40,7 @@ int enable_sata_phy(void)
 	return phy_pipe3_power_on(&sata_phy);
 }
 
+#ifndef CONFIG_SATA
 int init_sata(int dev)
 {
 	int ret;
@@ -73,3 +74,4 @@ void scsi_bus_reset(void)
 	ahci_reset((void __iomem *)DWC_AHSATA_BASE);
 	ahci_init((void __iomem *)DWC_AHSATA_BASE);
 }
+#endif
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 44d8a6b..6b94c3f 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -7,4 +7,11 @@ config SATA
 	  Enable driver model for block devices like SCSI. It uses the
 	  same API as block, but now implemented by the uclass.
 
+config DWC_AHCI
+	bool "Enable Synopsys DWC AHCI driver support"
+	depends on SATA
+	help
+	  Enable this driver to support Sata devices through
+	  Synopsys DWC AHCI module.
+
 endmenu
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index c2dae17..189d17f 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -6,6 +6,7 @@
 #
 
 obj-$(CONFIG_SATA) += sata-uclass.o
+obj-$(CONFIG_DWC_AHCI) += dwc_ahci.o
 
 obj-$(CONFIG_SCSI_AHCI) += ahci.o
 obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
diff --git a/drivers/block/dwc_ahci.c b/drivers/block/dwc_ahci.c
new file mode 100644
index 0000000..b6c3bba
--- /dev/null
+++ b/drivers/block/dwc_ahci.c
@@ -0,0 +1,71 @@
+/*
+ * DWC SATA platform driver
+ *
+ * (C) Copyright 2016
+ *     Texas Instruments Incorporated, <www.ti.com>
+ *
+ * Author: Mugunthan V N <mugunthanvnm@ti.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <ahci.h>
+#include <sata.h>
+#include <asm/arch/sata.h>
+#include <asm/io.h>
+
+struct dwc_ahci_priv {
+	void *base;
+	void *wrapper_base;
+};
+
+static int dwc_ahci_ofdata_to_platdata(struct udevice *dev)
+{
+	struct dwc_ahci_priv *priv = dev_get_priv(dev);
+	fdt_addr_t addr;
+
+	priv->base = (void *)dev_get_addr(dev);
+
+	addr = dev_get_addr_index(dev, 1);
+	priv->wrapper_base = (addr != FDT_ADDR_T_NONE) ? (void *)addr : NULL;
+
+	return 0;
+}
+
+static int dwc_ahci_probe(struct udevice *dev)
+{
+	struct dwc_ahci_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	if (priv->wrapper_base) {
+		u32 val = TI_SATA_IDLE_NO | TI_SATA_STANDBY_NO;
+
+		/* Enable SATA module, No Idle, No Standby */
+		writel(val, priv->wrapper_base + TI_SATA_SYSCONFIG);
+	}
+
+	ret = enable_sata_phy();
+	if (ret) {
+		error("Sata phy enable failed\n");
+		return ret;
+	}
+
+	return ahci_init(priv->base);
+}
+
+static const struct udevice_id dwc_ahci_ids[] = {
+	{ .compatible = "snps,dwc-ahci" },
+	{ }
+};
+
+U_BOOT_DRIVER(dwc_ahci) = {
+	.name	= "dwc_ahci",
+	.id	= UCLASS_SATA,
+	.of_match = dwc_ahci_ids,
+	.ofdata_to_platdata = dwc_ahci_ofdata_to_platdata,
+	.probe	= dwc_ahci_probe,
+	.priv_auto_alloc_size = sizeof(struct dwc_ahci_priv),
+	.flags = DM_FLAG_ALLOC_PRIV_DMA,
+};
-- 
2.7.0.rc3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 5/6] defconfig: dra74_evm: enable sata driver model
  2016-01-18  8:47 [U-Boot] [PATCH 0/6] driver model bring-up of sata device on dra72 and dra74 evm Mugunthan V N
                   ` (3 preceding siblings ...)
  2016-01-18  8:47 ` [U-Boot] [PATCH 4/6] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device Mugunthan V N
@ 2016-01-18  8:47 ` Mugunthan V N
  2016-01-19 18:11   ` Tom Rini
  2016-01-18  8:47 ` [U-Boot] [PATCH 6/6] defconfig: dra72_evm: " Mugunthan V N
  5 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-01-18  8:47 UTC (permalink / raw)
  To: u-boot

Enable sata driver model for dra74_evm as dwc_ahci supports
driver model

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 configs/dra74_evm_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/dra74_evm_defconfig b/configs/dra74_evm_defconfig
index 6e5a705..18bb950 100644
--- a/configs/dra74_evm_defconfig
+++ b/configs/dra74_evm_defconfig
@@ -21,3 +21,5 @@ CONFIG_SYS_NS16550=y
 CONFIG_TI_QSPI=y
 CONFIG_DM_SPI=y
 CONFIG_DM_SPI_FLASH=y
+CONFIG_SATA=y
+CONFIG_DWC_AHCI=y
-- 
2.7.0.rc3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 6/6] defconfig: dra72_evm: enable sata driver model
  2016-01-18  8:47 [U-Boot] [PATCH 0/6] driver model bring-up of sata device on dra72 and dra74 evm Mugunthan V N
                   ` (4 preceding siblings ...)
  2016-01-18  8:47 ` [U-Boot] [PATCH 5/6] defconfig: dra74_evm: enable sata driver model Mugunthan V N
@ 2016-01-18  8:47 ` Mugunthan V N
  2016-01-19 18:11   ` Tom Rini
  5 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-01-18  8:47 UTC (permalink / raw)
  To: u-boot

Enable sata driver model for dra72_evm as dwc_ahci supports
driver model

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 configs/dra72_evm_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/dra72_evm_defconfig b/configs/dra72_evm_defconfig
index b57ecca..b22438e 100644
--- a/configs/dra72_evm_defconfig
+++ b/configs/dra72_evm_defconfig
@@ -22,3 +22,5 @@ CONFIG_SYS_NS16550=y
 CONFIG_TI_QSPI=y
 CONFIG_DM_SPI=y
 CONFIG_DM_SPI_FLASH=y
+CONFIG_SATA=y
+CONFIG_DWC_AHCI=y
-- 
2.7.0.rc3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 2/6] dm: implement a SATA uclass
  2016-01-18  8:47 ` [U-Boot] [PATCH 2/6] dm: implement a SATA uclass Mugunthan V N
@ 2016-01-18  9:23   ` Bin Meng
  2016-01-19  5:09     ` Mugunthan V N
  0 siblings, 1 reply; 15+ messages in thread
From: Bin Meng @ 2016-01-18  9:23 UTC (permalink / raw)
  To: u-boot

+Simon

On Mon, Jan 18, 2016 at 4:47 PM, Mugunthan V N <mugunthanvnm@ti.com> wrote:
> Implement a SATA uclass that can represent a SATA controller.
>
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> ---
>  drivers/block/Kconfig       | 10 +++++++
>  drivers/block/Makefile      |  2 ++
>  drivers/block/sata-uclass.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
>  include/dm/uclass-id.h      |  1 +
>  4 files changed, 82 insertions(+)
>  create mode 100644 drivers/block/sata-uclass.c
>
> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> index e69de29..44d8a6b 100644
> --- a/drivers/block/Kconfig
> +++ b/drivers/block/Kconfig
> @@ -0,0 +1,10 @@
> +menu "SATA Device Support"
> +
> +config SATA
> +       bool "Enable driver model for SATA drivers"
> +       depends on DM
> +       help
> +         Enable driver model for block devices like SCSI. It uses the
> +         same API as block, but now implemented by the uclass.
> +
> +endmenu
> diff --git a/drivers/block/Makefile b/drivers/block/Makefile
> index eb8bda9..c2dae17 100644
> --- a/drivers/block/Makefile
> +++ b/drivers/block/Makefile
> @@ -5,6 +5,8 @@
>  # SPDX-License-Identifier:     GPL-2.0+
>  #
>
> +obj-$(CONFIG_SATA) += sata-uclass.o
> +
>  obj-$(CONFIG_SCSI_AHCI) += ahci.o
>  obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
>  obj-$(CONFIG_FSL_SATA) += fsl_sata.o
> diff --git a/drivers/block/sata-uclass.c b/drivers/block/sata-uclass.c
> new file mode 100644
> index 0000000..62773b6
> --- /dev/null
> +++ b/drivers/block/sata-uclass.c
> @@ -0,0 +1,69 @@
> +/*
> + * SATA device U-Class driver
> + *
> + * (C) Copyright 2016
> + *     Texas Instruments Incorporated, <www.ti.com>
> + *
> + * Author: Mugunthan V N <mugunthanvnm@ti.com>
> + *
> + * SPDX-License-Identifier:     GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <dm/uclass-internal.h>
> +#include <dm/device-internal.h>
> +#include <errno.h>
> +#include <scsi.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/*
> + * struct mmc_uclass_priv - Holds information about a device used by the uclass
> + */

Please use single-line comment when it fits just one line. Also it's not mmc.

> +struct sata_uclass_priv {
> +       struct block_dev_desc_t *block_dev;
> +};
> +
> +int scsi_get_device(int index, struct udevice **devp)
> +{
> +       struct udevice *dev;
> +       int ret;
> +
> +       ret = uclass_find_device(UCLASS_SATA, index, &dev);
> +       if (ret || !dev) {
> +               printf("%d device not found\n", index);
> +               return ret;
> +       }
> +
> +       ret = device_probe(dev);
> +       if (ret) {
> +               error("device probe error\n");
> +               return ret;
> +       }
> +
> +       *devp = dev;
> +
> +       return ret;
> +}
> +
> +void scsi_init(void)
> +{
> +       struct udevice *dev;
> +       int ret;
> +
> +       ret = scsi_get_device(0, &dev);
> +       if (ret || !dev) {
> +               error("scsi device not found\n");
> +               return;
> +       }
> +
> +       scsi_scan(1);
> +}
> +
> +UCLASS_DRIVER(sata) = {
> +       .id             = UCLASS_SATA,
> +       .name           = "sata",
> +       .flags          = DM_UC_FLAG_SEQ_ALIAS,
> +       .per_device_auto_alloc_size = sizeof(struct sata_uclass_priv),
> +};
> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
> index 27fa0b6..80977ca 100644
> --- a/include/dm/uclass-id.h
> +++ b/include/dm/uclass-id.h
> @@ -55,6 +55,7 @@ enum uclass_id {
>         UCLASS_RESET,           /* Reset device */
>         UCLASS_REMOTEPROC,      /* Remote Processor device */
>         UCLASS_RTC,             /* Real time clock device */
> +       UCLASS_SATA,            /* SATA devices */
>         UCLASS_SERIAL,          /* Serial UART */
>         UCLASS_SPI,             /* SPI bus */
>         UCLASS_SPI_FLASH,       /* SPI flash */
> --

I would like to see a full DM conversion of the SCSI codes. But this
patch looks to me it's just a place holder?

Regards,
Bin

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 2/6] dm: implement a SATA uclass
  2016-01-18  9:23   ` Bin Meng
@ 2016-01-19  5:09     ` Mugunthan V N
  2016-01-20  4:35       ` Simon Glass
  0 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-01-19  5:09 UTC (permalink / raw)
  To: u-boot

On Monday 18 January 2016 02:53 PM, Bin Meng wrote:
> +Simon
> 
> On Mon, Jan 18, 2016 at 4:47 PM, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>> Implement a SATA uclass that can represent a SATA controller.
>>
>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>> ---
>>  drivers/block/Kconfig       | 10 +++++++
>>  drivers/block/Makefile      |  2 ++
>>  drivers/block/sata-uclass.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
>>  include/dm/uclass-id.h      |  1 +
>>  4 files changed, 82 insertions(+)
>>  create mode 100644 drivers/block/sata-uclass.c
>>
>> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
>> index e69de29..44d8a6b 100644
>> --- a/drivers/block/Kconfig
>> +++ b/drivers/block/Kconfig
>> @@ -0,0 +1,10 @@
>> +menu "SATA Device Support"
>> +
>> +config SATA
>> +       bool "Enable driver model for SATA drivers"
>> +       depends on DM
>> +       help
>> +         Enable driver model for block devices like SCSI. It uses the
>> +         same API as block, but now implemented by the uclass.
>> +
>> +endmenu
>> diff --git a/drivers/block/Makefile b/drivers/block/Makefile
>> index eb8bda9..c2dae17 100644
>> --- a/drivers/block/Makefile
>> +++ b/drivers/block/Makefile
>> @@ -5,6 +5,8 @@
>>  # SPDX-License-Identifier:     GPL-2.0+
>>  #
>>
>> +obj-$(CONFIG_SATA) += sata-uclass.o
>> +
>>  obj-$(CONFIG_SCSI_AHCI) += ahci.o
>>  obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
>>  obj-$(CONFIG_FSL_SATA) += fsl_sata.o
>> diff --git a/drivers/block/sata-uclass.c b/drivers/block/sata-uclass.c
>> new file mode 100644
>> index 0000000..62773b6
>> --- /dev/null
>> +++ b/drivers/block/sata-uclass.c
>> @@ -0,0 +1,69 @@
>> +/*
>> + * SATA device U-Class driver
>> + *
>> + * (C) Copyright 2016
>> + *     Texas Instruments Incorporated, <www.ti.com>
>> + *
>> + * Author: Mugunthan V N <mugunthanvnm@ti.com>
>> + *
>> + * SPDX-License-Identifier:     GPL-2.0+
>> + */
>> +
>> +#include <common.h>
>> +#include <dm.h>
>> +#include <dm/uclass-internal.h>
>> +#include <dm/device-internal.h>
>> +#include <errno.h>
>> +#include <scsi.h>
>> +
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +/*
>> + * struct mmc_uclass_priv - Holds information about a device used by the uclass
>> + */
> 
> Please use single-line comment when it fits just one line. Also it's not mmc.

Will fix it in next version.

> 
>> +struct sata_uclass_priv {
>> +       struct block_dev_desc_t *block_dev;
>> +};
>> +
>> +int scsi_get_device(int index, struct udevice **devp)
>> +{
>> +       struct udevice *dev;
>> +       int ret;
>> +
>> +       ret = uclass_find_device(UCLASS_SATA, index, &dev);
>> +       if (ret || !dev) {
>> +               printf("%d device not found\n", index);
>> +               return ret;
>> +       }
>> +
>> +       ret = device_probe(dev);
>> +       if (ret) {
>> +               error("device probe error\n");
>> +               return ret;
>> +       }
>> +
>> +       *devp = dev;
>> +
>> +       return ret;
>> +}
>> +
>> +void scsi_init(void)
>> +{
>> +       struct udevice *dev;
>> +       int ret;
>> +
>> +       ret = scsi_get_device(0, &dev);
>> +       if (ret || !dev) {
>> +               error("scsi device not found\n");
>> +               return;
>> +       }
>> +
>> +       scsi_scan(1);
>> +}
>> +
>> +UCLASS_DRIVER(sata) = {
>> +       .id             = UCLASS_SATA,
>> +       .name           = "sata",
>> +       .flags          = DM_UC_FLAG_SEQ_ALIAS,
>> +       .per_device_auto_alloc_size = sizeof(struct sata_uclass_priv),
>> +};
>> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
>> index 27fa0b6..80977ca 100644
>> --- a/include/dm/uclass-id.h
>> +++ b/include/dm/uclass-id.h
>> @@ -55,6 +55,7 @@ enum uclass_id {
>>         UCLASS_RESET,           /* Reset device */
>>         UCLASS_REMOTEPROC,      /* Remote Processor device */
>>         UCLASS_RTC,             /* Real time clock device */
>> +       UCLASS_SATA,            /* SATA devices */
>>         UCLASS_SERIAL,          /* Serial UART */
>>         UCLASS_SPI,             /* SPI bus */
>>         UCLASS_SPI_FLASH,       /* SPI flash */
>> --
> 
> I would like to see a full DM conversion of the SCSI codes. But this
> patch looks to me it's just a place holder?

Ultimately that will be the final goal, now this is just a place holder
to move towards DM conversion.

Regards
Mugunthan V N

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 1/6] arm: omap: sata: move enable sata clocks to enable_basic_clocks()
  2016-01-18  8:47 ` [U-Boot] [PATCH 1/6] arm: omap: sata: move enable sata clocks to enable_basic_clocks() Mugunthan V N
@ 2016-01-19 18:09   ` Tom Rini
  0 siblings, 0 replies; 15+ messages in thread
From: Tom Rini @ 2016-01-19 18:09 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 18, 2016 at 02:17:38PM +0530, Mugunthan V N wrote:

> All the clocks which has to be enabled has to be done in
> enable_basic_clocks(), so moving enable sata clock to common
> clocks enable function.
> 
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160119/d70dc688/attachment.sig>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 3/6] arm: omap-common: sata: prepare driver for DM conversion
  2016-01-18  8:47 ` [U-Boot] [PATCH 3/6] arm: omap-common: sata: prepare driver for DM conversion Mugunthan V N
@ 2016-01-19 18:10   ` Tom Rini
  0 siblings, 0 replies; 15+ messages in thread
From: Tom Rini @ 2016-01-19 18:10 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 18, 2016 at 02:17:40PM +0530, Mugunthan V N wrote:

> Prepare sata driver for DM conversion by abstracting sata phy
> init to seperate function.
> 
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160119/669201a2/attachment.sig>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 4/6] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device
  2016-01-18  8:47 ` [U-Boot] [PATCH 4/6] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device Mugunthan V N
@ 2016-01-19 18:11   ` Tom Rini
  0 siblings, 0 replies; 15+ messages in thread
From: Tom Rini @ 2016-01-19 18:11 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 18, 2016 at 02:17:41PM +0530, Mugunthan V N wrote:

> Implement a sata driver for Synopsys DWC sata device based on
> U-boot driver model.
> 
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160119/50ea5135/attachment.sig>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 5/6] defconfig: dra74_evm: enable sata driver model
  2016-01-18  8:47 ` [U-Boot] [PATCH 5/6] defconfig: dra74_evm: enable sata driver model Mugunthan V N
@ 2016-01-19 18:11   ` Tom Rini
  0 siblings, 0 replies; 15+ messages in thread
From: Tom Rini @ 2016-01-19 18:11 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 18, 2016 at 02:17:42PM +0530, Mugunthan V N wrote:

> Enable sata driver model for dra74_evm as dwc_ahci supports
> driver model
> 
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160119/43d250aa/attachment.sig>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 6/6] defconfig: dra72_evm: enable sata driver model
  2016-01-18  8:47 ` [U-Boot] [PATCH 6/6] defconfig: dra72_evm: " Mugunthan V N
@ 2016-01-19 18:11   ` Tom Rini
  0 siblings, 0 replies; 15+ messages in thread
From: Tom Rini @ 2016-01-19 18:11 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 18, 2016 at 02:17:43PM +0530, Mugunthan V N wrote:

> Enable sata driver model for dra72_evm as dwc_ahci supports
> driver model
> 
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160119/8c768b56/attachment.sig>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 2/6] dm: implement a SATA uclass
  2016-01-19  5:09     ` Mugunthan V N
@ 2016-01-20  4:35       ` Simon Glass
  0 siblings, 0 replies; 15+ messages in thread
From: Simon Glass @ 2016-01-20  4:35 UTC (permalink / raw)
  To: u-boot

Hi,

On 18 January 2016 at 22:09, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>
> On Monday 18 January 2016 02:53 PM, Bin Meng wrote:
> > +Simon
> >
> > On Mon, Jan 18, 2016 at 4:47 PM, Mugunthan V N <mugunthanvnm@ti.com> wrote:
> >> Implement a SATA uclass that can represent a SATA controller.
> >>
> >> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> >> ---
> >>  drivers/block/Kconfig       | 10 +++++++
> >>  drivers/block/Makefile      |  2 ++
> >>  drivers/block/sata-uclass.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
> >>  include/dm/uclass-id.h      |  1 +
> >>  4 files changed, 82 insertions(+)
> >>  create mode 100644 drivers/block/sata-uclass.c
> >>
> >> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> >> index e69de29..44d8a6b 100644
> >> --- a/drivers/block/Kconfig
> >> +++ b/drivers/block/Kconfig
> >> @@ -0,0 +1,10 @@
> >> +menu "SATA Device Support"
> >> +
> >> +config SATA
> >> +       bool "Enable driver model for SATA drivers"
> >> +       depends on DM
> >> +       help
> >> +         Enable driver model for block devices like SCSI. It uses the
> >> +         same API as block, but now implemented by the uclass.
> >> +
> >> +endmenu
> >> diff --git a/drivers/block/Makefile b/drivers/block/Makefile
> >> index eb8bda9..c2dae17 100644
> >> --- a/drivers/block/Makefile
> >> +++ b/drivers/block/Makefile
> >> @@ -5,6 +5,8 @@
> >>  # SPDX-License-Identifier:     GPL-2.0+
> >>  #
> >>
> >> +obj-$(CONFIG_SATA) += sata-uclass.o
> >> +
> >>  obj-$(CONFIG_SCSI_AHCI) += ahci.o
> >>  obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
> >>  obj-$(CONFIG_FSL_SATA) += fsl_sata.o
> >> diff --git a/drivers/block/sata-uclass.c b/drivers/block/sata-uclass.c
> >> new file mode 100644
> >> index 0000000..62773b6
> >> --- /dev/null
> >> +++ b/drivers/block/sata-uclass.c
> >> @@ -0,0 +1,69 @@
> >> +/*
> >> + * SATA device U-Class driver
> >> + *
> >> + * (C) Copyright 2016
> >> + *     Texas Instruments Incorporated, <www.ti.com>
> >> + *
> >> + * Author: Mugunthan V N <mugunthanvnm@ti.com>
> >> + *
> >> + * SPDX-License-Identifier:     GPL-2.0+
> >> + */
> >> +
> >> +#include <common.h>
> >> +#include <dm.h>
> >> +#include <dm/uclass-internal.h>
> >> +#include <dm/device-internal.h>
> >> +#include <errno.h>
> >> +#include <scsi.h>
> >> +
> >> +DECLARE_GLOBAL_DATA_PTR;
> >> +
> >> +/*
> >> + * struct mmc_uclass_priv - Holds information about a device used by the uclass
> >> + */
> >
> > Please use single-line comment when it fits just one line. Also it's not mmc.
>
> Will fix it in next version.
>
> >
> >> +struct sata_uclass_priv {
> >> +       struct block_dev_desc_t *block_dev;
> >> +};
> >> +
> >> +int scsi_get_device(int index, struct udevice **devp)
> >> +{
> >> +       struct udevice *dev;
> >> +       int ret;
> >> +
> >> +       ret = uclass_find_device(UCLASS_SATA, index, &dev);
> >> +       if (ret || !dev) {
> >> +               printf("%d device not found\n", index);
> >> +               return ret;
> >> +       }
> >> +
> >> +       ret = device_probe(dev);
> >> +       if (ret) {
> >> +               error("device probe error\n");
> >> +               return ret;
> >> +       }
> >> +
> >> +       *devp = dev;
> >> +
> >> +       return ret;
> >> +}
> >> +
> >> +void scsi_init(void)
> >> +{
> >> +       struct udevice *dev;
> >> +       int ret;
> >> +
> >> +       ret = scsi_get_device(0, &dev);
> >> +       if (ret || !dev) {
> >> +               error("scsi device not found\n");
> >> +               return;
> >> +       }
> >> +
> >> +       scsi_scan(1);
> >> +}
> >> +
> >> +UCLASS_DRIVER(sata) = {
> >> +       .id             = UCLASS_SATA,
> >> +       .name           = "sata",
> >> +       .flags          = DM_UC_FLAG_SEQ_ALIAS,
> >> +       .per_device_auto_alloc_size = sizeof(struct sata_uclass_priv),
> >> +};
> >> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
> >> index 27fa0b6..80977ca 100644
> >> --- a/include/dm/uclass-id.h
> >> +++ b/include/dm/uclass-id.h
> >> @@ -55,6 +55,7 @@ enum uclass_id {
> >>         UCLASS_RESET,           /* Reset device */
> >>         UCLASS_REMOTEPROC,      /* Remote Processor device */
> >>         UCLASS_RTC,             /* Real time clock device */
> >> +       UCLASS_SATA,            /* SATA devices */
> >>         UCLASS_SERIAL,          /* Serial UART */
> >>         UCLASS_SPI,             /* SPI bus */
> >>         UCLASS_SPI_FLASH,       /* SPI flash */
> >> --
> >
> > I would like to see a full DM conversion of the SCSI codes. But this
> > patch looks to me it's just a place holder?
>
> Ultimately that will be the final goal, now this is just a place holder
> to move towards DM conversion.

I have a series which adds a disk uclass. It was using AHCI (=SATA)
but Bin pointed out that this might be too specific.

So perhaps you should use that?

http://patchwork.ozlabs.org/patch/569381/

Regards,
Simon

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-01-20  4:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18  8:47 [U-Boot] [PATCH 0/6] driver model bring-up of sata device on dra72 and dra74 evm Mugunthan V N
2016-01-18  8:47 ` [U-Boot] [PATCH 1/6] arm: omap: sata: move enable sata clocks to enable_basic_clocks() Mugunthan V N
2016-01-19 18:09   ` Tom Rini
2016-01-18  8:47 ` [U-Boot] [PATCH 2/6] dm: implement a SATA uclass Mugunthan V N
2016-01-18  9:23   ` Bin Meng
2016-01-19  5:09     ` Mugunthan V N
2016-01-20  4:35       ` Simon Glass
2016-01-18  8:47 ` [U-Boot] [PATCH 3/6] arm: omap-common: sata: prepare driver for DM conversion Mugunthan V N
2016-01-19 18:10   ` Tom Rini
2016-01-18  8:47 ` [U-Boot] [PATCH 4/6] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device Mugunthan V N
2016-01-19 18:11   ` Tom Rini
2016-01-18  8:47 ` [U-Boot] [PATCH 5/6] defconfig: dra74_evm: enable sata driver model Mugunthan V N
2016-01-19 18:11   ` Tom Rini
2016-01-18  8:47 ` [U-Boot] [PATCH 6/6] defconfig: dra72_evm: " Mugunthan V N
2016-01-19 18:11   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.