All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model
@ 2017-04-14 11:07 Jean-Jacques Hiblot
  2017-04-14 11:07 ` [U-Boot] [PATCH 01/11] arm: omap: sata: move enable sata clocks to enable_basic_clocks() Jean-Jacques Hiblot
                   ` (11 more replies)
  0 siblings, 12 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:07 UTC (permalink / raw)
  To: u-boot

This series adds support for SATA using the driver model on omap platforms.
It is based on the work of Mugunthan V N <mugunthanvnm@ti.com> in Feb 2016

The first 2 patches are preparatory work.
The 3rd patch adds a new framework to handle PHYs in a generic manner. The idea
is to move the phy initialization out of the board-specific code into a proper
driver. The link between the phy device and the controller device is done in
by device-tree as it's done in linux. The API to control a phy has been copied
from linux, excpet that the functions are prefixed by 'generic_phy_' instead of
just 'phy_' because phy_reset() is already used to handle the Ethernet phys.
The 5th patch adds a phy driver for the pipe3 sata phy found in the
omaps/am5x/dra7x SOCs.
The 6th patch allows the device under the node ocp2scp at 4a090000 to be probed.
The 7th patch implements a driver for the SATA controller found in the
omaps/am5x/dra7x SOCs.
The 8th patch is cosmetic and changes the interface of scsi_detect_dev()
The 9th patch moves the call to part_init() out of scsi_detect_dev(). This is
a preparatory work path #10.
The 10th patches fix a divide-by-0 error that happens in scsi_scan()
when DM is used and split scsi_scan() in 2 functions for clarity.
The last patch enables the DM sata by default for the dra7 platforms.

changes since v2:
* Added unit tests for generic PHY uclass.
* Changed the generic phy API to use a 'struct udevice*' to reference the phy
  device.
* Don't modify anymore the root Makefile.
* Updated the Kconfig with more details on the PHY framework.
* Use a Unique Lincense Identifier (SPDX)
* Use omap5-u-boot.dtsi to mark the ocp2scp bus as compatible with "simple-bus"
* Split scsi_scan() in 2 for clarity. The function was becoming too long.

changes since v1:
* changed the way the 'old' sata code is compiled out when DM_SCSI is enabled.
* added a new framework for PHY management.
* added a new driver for the PIPE3 phy and use it in the dwc_ahci driver.
* changed the interface of scsi_detect_dev() and moved the call part_init() out
  of it.
* modified the fix to scsi_scan() in order to call scsi_detect_dev() only once.
* the max_lun and max_id parameters are now taken from the device-tree.
* Updated the defconfig changes to include the PHY driver and its dependencies.

Jean-Jacques Hiblot (11):
  arm: omap: sata: move enable sata clocks to enable_basic_clocks()
  arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI
    is defined
  drivers: phy: add generic PHY framework
  dm: test: Add tests for the generic PHY uclass
  drivers: phy: add PIPE3 phy driver
  dra7: dtsi: mark ocp2scp bus compatible with "simple-bus"
  drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata
    device
  scsi: make the LUN a parameter of scsi_detect_dev()
  scsi: move the partition initialization out of the scsi detection
  dm: scsi: fix divide-by-0 error in scsi_scan()
  defconfig: dra7xx_evm: enable CONFIG_BLK and disk driver model for
    SCSI

 arch/arm/dts/omap5-u-boot.dtsi      |   4 +
 arch/arm/mach-omap2/Makefile        |   2 +
 arch/arm/mach-omap2/omap5/hw_data.c |  12 ++
 arch/arm/mach-omap2/sata.c          |  23 ---
 arch/sandbox/dts/test.dts           |   9 +
 common/scsi.c                       |  98 +++++-----
 configs/dra7xx_evm_defconfig        |  12 +-
 configs/dra7xx_hs_evm_defconfig     |  11 +-
 configs/sandbox_defconfig           |   2 +
 configs/sandbox_noblk_defconfig     |   2 +
 configs/sandbox_spl_defconfig       |   3 +
 drivers/Kconfig                     |   2 +
 drivers/Makefile                    |   1 +
 drivers/block/Kconfig               |  10 +
 drivers/block/Makefile              |   1 +
 drivers/block/dwc_ahci.c            | 100 ++++++++++
 drivers/phy/Kconfig                 |  59 ++++++
 drivers/phy/Makefile                |   4 +
 drivers/phy/phy-uclass.c            |  64 +++++++
 drivers/phy/sandbox-phy.c           |  78 ++++++++
 drivers/phy/ti-pipe3-phy.c          | 365 ++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h              |   1 +
 include/generic-phy.h               |  36 ++++
 test/dm/Makefile                    |   1 +
 test/dm/generic_phy.c               |  89 +++++++++
 25 files changed, 922 insertions(+), 67 deletions(-)
 create mode 100644 drivers/block/dwc_ahci.c
 create mode 100644 drivers/phy/Kconfig
 create mode 100644 drivers/phy/Makefile
 create mode 100644 drivers/phy/phy-uclass.c
 create mode 100644 drivers/phy/sandbox-phy.c
 create mode 100644 drivers/phy/ti-pipe3-phy.c
 create mode 100644 include/generic-phy.h
 create mode 100644 test/dm/generic_phy.c

-- 
1.9.1

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

* [U-Boot] [PATCH 01/11] arm: omap: sata: move enable sata clocks to enable_basic_clocks()
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
@ 2017-04-14 11:07 ` Jean-Jacques Hiblot
  2017-04-14 11:08 ` [U-Boot] [PATCH 02/11] arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI is defined Jean-Jacques Hiblot
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:07 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>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
 arch/arm/mach-omap2/omap5/hw_data.c | 12 ++++++++++++
 arch/arm/mach-omap2/sata.c          | 23 -----------------------
 2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/arch/arm/mach-omap2/omap5/hw_data.c b/arch/arm/mach-omap2/omap5/hw_data.c
index 5d956b5..a8a6b8a 100644
--- a/arch/arm/mach-omap2/omap5/hw_data.c
+++ b/arch/arm/mach-omap2/omap5/hw_data.c
@@ -361,6 +361,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
 	};
 
@@ -379,6 +382,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
 	};
 
@@ -411,6 +417,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);
diff --git a/arch/arm/mach-omap2/sata.c b/arch/arm/mach-omap2/sata.c
index 2c2d1bc..0c82689 100644
--- a/arch/arm/mach-omap2/sata.c
+++ b/arch/arm/mach-omap2/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 */
-- 
1.9.1

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

* [U-Boot] [PATCH 02/11] arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI is defined
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
  2017-04-14 11:07 ` [U-Boot] [PATCH 01/11] arm: omap: sata: move enable sata clocks to enable_basic_clocks() Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-14 11:08 ` [U-Boot] [PATCH 03/11] drivers: phy: add generic PHY framework Jean-Jacques Hiblot
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 UTC (permalink / raw)
  To: u-boot

When CONFIG_DM_SCSI is defined, the SATA initialization will be implemented
in the scsi-uclass driver.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
 arch/arm/mach-omap2/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index e814eb0..aa3986d 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -29,9 +29,11 @@ obj-y	+= abb.o
 endif
 
 ifneq ($(CONFIG_OMAP54XX),)
+ifeq ($(CONFIG_DM_SCSI),)
 obj-y	+= pipe3-phy.o
 obj-$(CONFIG_SCSI_AHCI_PLAT) += sata.o
 endif
+endif
 
 ifeq ($(CONFIG_SYS_DCACHE_OFF),)
 obj-y	+= omap-cache.o
-- 
1.9.1

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

* [U-Boot] [PATCH 03/11] drivers: phy: add generic PHY framework
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
  2017-04-14 11:07 ` [U-Boot] [PATCH 01/11] arm: omap: sata: move enable sata clocks to enable_basic_clocks() Jean-Jacques Hiblot
  2017-04-14 11:08 ` [U-Boot] [PATCH 02/11] arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI is defined Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-15 17:10   ` Simon Glass
  2017-04-14 11:08 ` [U-Boot] [PATCH 04/11] dm: test: Add tests for the generic PHY uclass Jean-Jacques Hiblot
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 UTC (permalink / raw)
  To: u-boot

The PHY framework provides a set of APIs to control a PHY. This API is
derived from the linux version of the generic PHY framework.
Currently the API supports init(), deinit(), power_on, power_off() and
reset(). The framework provides a way to get a reference to a phy from the
device-tree.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 drivers/Kconfig          |  2 ++
 drivers/Makefile         |  1 +
 drivers/phy/Kconfig      | 32 ++++++++++++++++++++++++
 drivers/phy/Makefile     |  2 ++
 drivers/phy/phy-uclass.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h   |  1 +
 include/generic-phy.h    | 36 +++++++++++++++++++++++++++
 7 files changed, 138 insertions(+)
 create mode 100644 drivers/phy/Kconfig
 create mode 100644 drivers/phy/Makefile
 create mode 100644 drivers/phy/phy-uclass.c
 create mode 100644 include/generic-phy.h

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 0e5d97d..a90ceca 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -88,6 +88,8 @@ source "drivers/video/Kconfig"
 
 source "drivers/watchdog/Kconfig"
 
+source "drivers/phy/Kconfig"
+
 config PHYS_TO_BUS
 	bool "Custom physical to bus address mapping"
 	help
diff --git a/drivers/Makefile b/drivers/Makefile
index 5d8baa5..0be0624 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_$(SPL_)CLK)	+= clk/
 obj-$(CONFIG_$(SPL_)LED)	+= led/
 obj-$(CONFIG_$(SPL_)PINCTRL)	+= pinctrl/
 obj-$(CONFIG_$(SPL_)RAM)	+= ram/
+obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy/
 
 ifdef CONFIG_SPL_BUILD
 
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
new file mode 100644
index 0000000..d66c9e3
--- /dev/null
+++ b/drivers/phy/Kconfig
@@ -0,0 +1,32 @@
+
+menu "PHY Subsystem"
+
+config GENERIC_PHY
+	bool "PHY Core"
+	depends on DM
+	help
+	  Generic PHY support.
+
+	  This framework is designed to provide a generic interface for PHY
+	  devices. PHYs are commonly used for high speed interfaces such as
+	  SATA or PCIe.
+	  The API provides functions to initialize/deinitialize the
+	  phy, power on/off the phy, and reset the phy. It's meant to be as
+	  compatible as possible with the equivalent framework found in the
+	  linux kernel.
+
+config SPL_GENERIC_PHY
+	bool "PHY Core in SPL"
+	depends on DM
+	help
+	  Generic PHY support in SPL.
+
+	  This framework is designed to provide a generic interface for PHY
+	  devices. PHYs are commonly used for high speed interfaces such as
+	  SATA or PCIe.
+	  The API provides functions to initialize/deinitialize the
+	  phy, power on/off the phy, and reset the phy. It's meant to be as
+	  compatible as possible with the equivalent framework found in the
+	  linux kernel.
+
+endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
new file mode 100644
index 0000000..b29a8b9
--- /dev/null
+++ b/drivers/phy/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o
+
diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
new file mode 100644
index 0000000..e15ed43
--- /dev/null
+++ b/drivers/phy/phy-uclass.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <generic-phy.h>
+
+struct udevice *dm_generic_phy_get(struct udevice *parent, const char *string)
+{
+	struct udevice *dev;
+
+	int rc = uclass_get_device_by_phandle(UCLASS_PHY, parent,
+					   string, &dev);
+	if (rc) {
+		debug("unable to find generic_phy device (err: %d)\n", rc);
+		return ERR_PTR(rc);
+	}
+
+	return dev;
+}
+
+int generic_phy_init(struct udevice *dev)
+{
+	struct generic_phy_ops const *ops = dev->driver->ops;
+
+	return (ops && ops->init) ? ops->init(dev) : 0;
+}
+
+int generic_phy_reset(struct udevice *dev)
+{
+	struct generic_phy_ops const *ops = dev->driver->ops;
+
+	return (ops && ops->reset) ? ops->reset(dev) : 0;
+}
+
+int generic_phy_exit(struct udevice *dev)
+{
+	struct generic_phy_ops const *ops = dev->driver->ops;
+
+	return (ops && ops->exit) ? ops->exit(dev) : 0;
+}
+
+int generic_phy_power_on(struct udevice *dev)
+{
+	struct generic_phy_ops const *ops = dev->driver->ops;
+
+	return (ops && ops->power_on) ? ops->power_on(dev) : 0;
+}
+
+int generic_phy_power_off(struct udevice *dev)
+{
+	struct generic_phy_ops const *ops = dev->driver->ops;
+
+	return (ops && ops->power_off) ? ops->power_off(dev) : 0;
+}
+
+UCLASS_DRIVER(generic_phy) = {
+	.id		= UCLASS_PHY,
+	.name		= "generic_phy",
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 8c92d0b..9d34a32 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -83,6 +83,7 @@ enum uclass_id {
 	UCLASS_VIDEO,		/* Video or LCD device */
 	UCLASS_VIDEO_BRIDGE,	/* Video bridge, e.g. DisplayPort to LVDS */
 	UCLASS_VIDEO_CONSOLE,	/* Text console driver for video device */
+	UCLASS_PHY,		/* generic PHY device */
 
 	UCLASS_COUNT,
 	UCLASS_INVALID = -1,
diff --git a/include/generic-phy.h b/include/generic-phy.h
new file mode 100644
index 0000000..24475f0
--- /dev/null
+++ b/include/generic-phy.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __GENERIC_PHY_H
+#define __GENERIC_PHY_H
+
+/*
+ * struct udevice_ops - set of function pointers for phy operations
+ * @init: operation to be performed for initializing phy (optionnal)
+ * @exit: operation to be performed while exiting (optionnal)
+ * @reset: reset the phy (optionnal).
+ * @power_on: powering on the phy (optionnal)
+ * @power_off: powering off the phy (optionnal)
+ */
+struct generic_phy_ops {
+	int	(*init)(struct udevice *phy);
+	int	(*exit)(struct udevice *phy);
+	int	(*reset)(struct udevice *phy);
+	int	(*power_on)(struct udevice *phy);
+	int	(*power_off)(struct udevice *phy);
+};
+
+
+int generic_phy_init(struct udevice *phy);
+int generic_phy_reset(struct udevice *phy);
+int generic_phy_exit(struct udevice *phy);
+int generic_phy_power_on(struct udevice *phy);
+int generic_phy_power_off(struct udevice *phy);
+
+struct udevice *dm_generic_phy_get(struct udevice *parent, const char *string);
+
+#endif /*__GENERIC_PHY_H */
-- 
1.9.1

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

* [U-Boot] [PATCH 04/11] dm: test: Add tests for the generic PHY uclass
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
                   ` (2 preceding siblings ...)
  2017-04-14 11:08 ` [U-Boot] [PATCH 03/11] drivers: phy: add generic PHY framework Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-15 17:10   ` Simon Glass
  2017-04-14 11:08 ` [U-Boot] [PATCH 05/11] drivers: phy: add PIPE3 phy driver Jean-Jacques Hiblot
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 UTC (permalink / raw)
  To: u-boot

Those tests check:
- the ability for a phy-user to get a phy device a reference in the
  device-tree
- the ability to perform operations on the phy (init,deinit,on,off)
- the behavior of the uclass when optional operations are not implemented

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 arch/sandbox/dts/test.dts       |  9 +++++
 configs/sandbox_defconfig       |  2 +
 configs/sandbox_noblk_defconfig |  2 +
 configs/sandbox_spl_defconfig   |  3 ++
 drivers/phy/Kconfig             |  9 +++++
 drivers/phy/Makefile            |  1 +
 drivers/phy/sandbox-phy.c       | 78 ++++++++++++++++++++++++++++++++++++
 test/dm/Makefile                |  1 +
 test/dm/generic_phy.c           | 89 +++++++++++++++++++++++++++++++++++++++++
 9 files changed, 194 insertions(+)
 create mode 100644 drivers/phy/sandbox-phy.c
 create mode 100644 test/dm/generic_phy.c

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index fff175d..918c899 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -59,6 +59,15 @@
 		ping-add = <3>;
 	};
 
+	gen_phy: gen_phy {
+		compatible = "sandbox,phy";
+	};
+
+	gen_phy_user: gen_phy_user {
+		compatible = "simple-bus";
+		phy = <&gen_phy>;
+	};
+
 	some-bus {
 		#address-cells = <1>;
 		#size-cells = <0>;
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 7f3f5ac..42116cf 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -164,6 +164,8 @@ CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_GENERIC_PHY=y
+CONFIG_PHY_SANDBOX=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_TPM=y
 CONFIG_LZ4=y
diff --git a/configs/sandbox_noblk_defconfig b/configs/sandbox_noblk_defconfig
index 3f8e70d..7a5cd4b 100644
--- a/configs/sandbox_noblk_defconfig
+++ b/configs/sandbox_noblk_defconfig
@@ -166,6 +166,8 @@ CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_GENERIC_PHY=y
+CONFIG_PHY_SANDBOX=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_TPM=y
 CONFIG_LZ4=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index ade6714..9b4cf39 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -170,6 +170,9 @@ CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_GENERIC_PHY=y
+CONFIG_SPL_GENERIC_PHY=y
+CONFIG_PHY_SANDBOX=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_TPM=y
 CONFIG_LZ4=y
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index d66c9e3..032b932 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -29,4 +29,13 @@ config SPL_GENERIC_PHY
 	  compatible as possible with the equivalent framework found in the
 	  linux kernel.
 
+config PHY_SANDBOX
+	bool "Sandbox PHY support"
+	depends on SANDBOX
+	depends on GENERIC_PHY
+	help
+	  This select a dummy sandbox PHY driver. It used only to implement
+	  unit tests for the generic phy framework
+
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index b29a8b9..0125844 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o
+obj-$(CONFIG_PHY_SANDBOX) += sandbox-phy.o
 
diff --git a/drivers/phy/sandbox-phy.c b/drivers/phy/sandbox-phy.c
new file mode 100644
index 0000000..1c60308
--- /dev/null
+++ b/drivers/phy/sandbox-phy.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <generic-phy.h>
+
+struct sandbox_phy_priv {
+	int initialized;
+	int on;
+};
+
+static int sandbox_phy_power_on(struct udevice *dev)
+{
+	struct sandbox_phy_priv *priv = dev_get_priv(dev);
+	if (!priv->initialized)
+		return -EIO;
+	priv->on = 1;
+	return 0;
+}
+
+static int sandbox_phy_power_off(struct udevice *dev)
+{
+	struct sandbox_phy_priv *priv = dev_get_priv(dev);
+	if (!priv->initialized)
+		return -EIO;
+	priv->on = 0;
+	return 0;
+}
+
+static int sandbox_phy_init(struct udevice *dev)
+{
+	struct sandbox_phy_priv *priv = dev_get_priv(dev);
+	priv->initialized = 1;
+	priv->on = 0;
+	return 0;
+}
+
+static int sandbox_phy_exit(struct udevice *dev)
+{
+	struct sandbox_phy_priv *priv = dev_get_priv(dev);
+	priv->initialized = 0;
+	priv->on = 0;
+	return 0;
+}
+
+static int sandbox_phy_probe(struct udevice *dev)
+{
+	struct sandbox_phy_priv *priv = dev_get_priv(dev);
+	priv->initialized = 0;
+	priv->on = 0;
+	return 0;
+}
+
+static struct generic_phy_ops sandbox_phy_ops = {
+	.power_on = sandbox_phy_power_on,
+	.power_off = sandbox_phy_power_off,
+	.init = sandbox_phy_init,
+	.exit = sandbox_phy_exit,
+};
+
+static const struct udevice_id sandbox_phy_ids[] = {
+	{ .compatible = "sandbox,phy" },
+	{ }
+};
+
+U_BOOT_DRIVER(phy_sandbox) = {
+	.name		= "phy_sandbox",
+	.id		= UCLASS_PHY,
+	.of_match	= sandbox_phy_ids,
+	.ops		= &sandbox_phy_ops,
+	.probe		= sandbox_phy_probe,
+	.priv_auto_alloc_size = sizeof(struct sandbox_phy_priv),
+};
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 1885e17..e2b7d43 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -41,4 +41,5 @@ obj-$(CONFIG_TIMER) += timer.o
 obj-$(CONFIG_DM_VIDEO) += video.o
 obj-$(CONFIG_ADC) += adc.o
 obj-$(CONFIG_SPMI) += spmi.o
+obj-$(CONFIG_GENERIC_PHY) += generic_phy.o
 endif
diff --git a/test/dm/generic_phy.c b/test/dm/generic_phy.c
new file mode 100644
index 0000000..08b862a
--- /dev/null
+++ b/test/dm/generic_phy.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <test/ut.h>
+#include <generic-phy.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Base test of the phy uclass */
+static int dm_test_phy_base(struct unit_test_state *uts)
+{
+	struct udevice *dev_method1;
+	struct udevice *dev_method2;
+	struct udevice *parent;
+
+
+	/* Get the device using the phy device*/
+	ut_assertok(uclass_get_device_by_name(UCLASS_SIMPLE_BUS,
+					      "gen_phy_user", &parent));
+	/* Get the phy device with std uclass function */
+	ut_assertok(uclass_get_device_by_name(UCLASS_PHY, "gen_phy",
+					      &dev_method1));
+
+	/*
+	 * Get the phy device from user device and compare with the one
+	 * obtained with the previous method.
+	 */
+	dev_method2 = dm_generic_phy_get(parent, "phy");
+	ut_assertnonnull(dev_method2);
+	ut_assertok_ptr(dev_method2);
+	ut_asserteq_ptr(dev_method1, dev_method2);
+
+	/* Try to get a non-existing phy */
+	ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PHY, 1, &dev_method2));
+	dev_method2 = dm_generic_phy_get(parent, "phy_not_existing");
+	ut_assert(IS_ERR_OR_NULL(dev_method2));
+
+	return 0;
+}
+DM_TEST(dm_test_phy_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test of the phy uclass using the sandbox phy driver operations */
+static int dm_test_phy_ops(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	struct udevice *parent;
+
+	ut_assertok(uclass_get_device_by_name(UCLASS_SIMPLE_BUS,
+					      "gen_phy_user", &parent));
+	dev = dm_generic_phy_get(parent, "phy");
+	ut_assertnonnull(dev);
+	ut_assertok_ptr(dev);
+
+	/* test normal operations */
+	ut_assertok(generic_phy_init(dev));
+	ut_assertok(generic_phy_power_on(dev));
+	ut_assertok(generic_phy_power_off(dev));
+
+	/*
+	 * test operations after exit().
+	 * The sandbox phy driver does not allow it.
+	 */
+	ut_assertok(generic_phy_exit(dev));
+	ut_assert(generic_phy_power_on(dev) != 0);
+	ut_assert(generic_phy_power_off(dev) != 0);
+
+	/*
+	 * test normal operations again (after re-init)
+	 */
+	ut_assertok(generic_phy_init(dev));
+	ut_assertok(generic_phy_power_on(dev));
+	ut_assertok(generic_phy_power_off(dev));
+
+	/*
+	 * test calling unimplemented feature.
+	 * The call is expected to succeed
+	 */
+	ut_assertok(generic_phy_reset(dev));
+
+	return 0;
+}
+DM_TEST(dm_test_phy_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
1.9.1

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

* [U-Boot] [PATCH 05/11] drivers: phy: add PIPE3 phy driver
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
                   ` (3 preceding siblings ...)
  2017-04-14 11:08 ` [U-Boot] [PATCH 04/11] dm: test: Add tests for the generic PHY uclass Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-14 11:08 ` [U-Boot] [PATCH 06/11] dra7: dtsi: mark ocp2scp bus compatible with "simple-bus" Jean-Jacques Hiblot
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 UTC (permalink / raw)
  To: u-boot

This phy is found on omap platforms with sata capabilities.
Except for the part related to the DM and the PHY framework, the code is
basically a copy paste from arch/arm/mach-omap2/pipe3-phy.c

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 drivers/phy/Kconfig        |  18 +++
 drivers/phy/Makefile       |   1 +
 drivers/phy/ti-pipe3-phy.c | 365 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 384 insertions(+)
 create mode 100644 drivers/phy/ti-pipe3-phy.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 032b932..b9a8093 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -38,4 +38,22 @@ config PHY_SANDBOX
 	  unit tests for the generic phy framework
 
 
+config PIPE3_PHY
+	bool "Support omap's PIPE3 PHY"
+	depends on GENERIC_PHY && ARCH_OMAP2
+	help
+	  Support for the omap PIPE3 phy for sata
+
+	  This PHY is found on omap devices supporting SATA such as dra7, am57x
+	  and omap5
+
+config SPL_PIPE3_PHY
+	bool "Support omap's PIPE3 PHY in SPL"
+	depends on SPL_GENERIC_PHY && ARCH_OMAP2
+	help
+	  Support for the omap PIPE3 phy for sata in SPL
+
+	  This PHY is found on omap devices supporting SATA such as dra7, am57x
+	  and omap5
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 0125844..701f7c8 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o
 obj-$(CONFIG_PHY_SANDBOX) += sandbox-phy.o
+obj-$(CONFIG_$(SPL_)PIPE3_PHY) += ti-pipe3-phy.o
 
diff --git a/drivers/phy/ti-pipe3-phy.c b/drivers/phy/ti-pipe3-phy.c
new file mode 100644
index 0000000..3964823
--- /dev/null
+++ b/drivers/phy/ti-pipe3-phy.c
@@ -0,0 +1,365 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/device.h>
+#include <generic-phy.h>
+#include <asm/io.h>
+#include <asm/arch/sys_proto.h>
+#include <syscon.h>
+#include <regmap.h>
+
+/* PLLCTRL Registers */
+#define PLL_STATUS              0x00000004
+#define PLL_GO                  0x00000008
+#define PLL_CONFIGURATION1      0x0000000C
+#define PLL_CONFIGURATION2      0x00000010
+#define PLL_CONFIGURATION3      0x00000014
+#define PLL_CONFIGURATION4      0x00000020
+
+#define PLL_REGM_MASK           0x001FFE00
+#define PLL_REGM_SHIFT          9
+#define PLL_REGM_F_MASK         0x0003FFFF
+#define PLL_REGM_F_SHIFT        0
+#define PLL_REGN_MASK           0x000001FE
+#define PLL_REGN_SHIFT          1
+#define PLL_SELFREQDCO_MASK     0x0000000E
+#define PLL_SELFREQDCO_SHIFT    1
+#define PLL_SD_MASK             0x0003FC00
+#define PLL_SD_SHIFT            10
+#define SET_PLL_GO              0x1
+#define PLL_TICOPWDN            BIT(16)
+#define PLL_LDOPWDN             BIT(15)
+#define PLL_LOCK                0x2
+#define PLL_IDLE                0x1
+
+/* Software rest for the SATA PLL (in CTRL_CORE_SMA_SW_0 register)*/
+#define SATA_PLL_SOFT_RESET (1<<18)
+
+/* PHY POWER CONTROL Register */
+#define OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK         0x003FC000
+#define OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT        0xE
+
+#define OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK        0xFFC00000
+#define OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT       0x16
+
+#define OMAP_CTRL_PIPE3_PHY_TX_RX_POWERON       0x3
+#define OMAP_CTRL_PIPE3_PHY_TX_RX_POWEROFF      0x0
+
+
+#define PLL_IDLE_TIME   100     /* in milliseconds */
+#define PLL_LOCK_TIME   100     /* in milliseconds */
+
+struct omap_pipe3 {
+	void __iomem		*pll_ctrl_base;
+	void __iomem		*power_reg;
+	void __iomem		*pll_reset_reg;
+	struct pipe3_dpll_map	*dpll_map;
+};
+
+
+struct pipe3_dpll_params {
+	u16     m;
+	u8      n;
+	u8      freq:3;
+	u8      sd;
+	u32     mf;
+};
+
+struct pipe3_dpll_map {
+	unsigned long rate;
+	struct pipe3_dpll_params params;
+};
+
+static inline u32 omap_pipe3_readl(void __iomem *addr, unsigned offset)
+{
+	return readl(addr + offset);
+}
+
+static inline void omap_pipe3_writel(void __iomem *addr, unsigned offset,
+		u32 data)
+{
+	writel(data, addr + offset);
+}
+
+static struct pipe3_dpll_params *omap_pipe3_get_dpll_params(struct omap_pipe3
+									*pipe3)
+{
+	u32 rate;
+	struct pipe3_dpll_map *dpll_map = pipe3->dpll_map;
+
+	rate = get_sys_clk_freq();
+
+	for (; dpll_map->rate; dpll_map++) {
+		if (rate == dpll_map->rate)
+			return &dpll_map->params;
+	}
+
+	printf("%s: No DPLL configuration for %u Hz SYS CLK\n",
+	       __func__, rate);
+	return NULL;
+}
+
+static int omap_pipe3_wait_lock(struct omap_pipe3 *pipe3)
+{
+	u32 val;
+	int timeout = PLL_LOCK_TIME;
+
+	do {
+		mdelay(1);
+		val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_STATUS);
+		if (val & PLL_LOCK)
+			break;
+	} while (--timeout);
+
+	if (!(val & PLL_LOCK)) {
+		printf("%s: DPLL failed to lock\n", __func__);
+		return -EBUSY;
+	}
+
+	return 0;
+}
+
+static int omap_pipe3_dpll_program(struct omap_pipe3 *pipe3)
+{
+	u32                     val;
+	struct pipe3_dpll_params *dpll_params;
+
+	dpll_params = omap_pipe3_get_dpll_params(pipe3);
+	if (!dpll_params) {
+		printf("%s: Invalid DPLL parameters\n", __func__);
+		return -EINVAL;
+	}
+
+	val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_CONFIGURATION1);
+	val &= ~PLL_REGN_MASK;
+	val |= dpll_params->n << PLL_REGN_SHIFT;
+	omap_pipe3_writel(pipe3->pll_ctrl_base, PLL_CONFIGURATION1, val);
+
+	val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_CONFIGURATION2);
+	val &= ~PLL_SELFREQDCO_MASK;
+	val |= dpll_params->freq << PLL_SELFREQDCO_SHIFT;
+	omap_pipe3_writel(pipe3->pll_ctrl_base, PLL_CONFIGURATION2, val);
+
+	val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_CONFIGURATION1);
+	val &= ~PLL_REGM_MASK;
+	val |= dpll_params->m << PLL_REGM_SHIFT;
+	omap_pipe3_writel(pipe3->pll_ctrl_base, PLL_CONFIGURATION1, val);
+
+	val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_CONFIGURATION4);
+	val &= ~PLL_REGM_F_MASK;
+	val |= dpll_params->mf << PLL_REGM_F_SHIFT;
+	omap_pipe3_writel(pipe3->pll_ctrl_base, PLL_CONFIGURATION4, val);
+
+	val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_CONFIGURATION3);
+	val &= ~PLL_SD_MASK;
+	val |= dpll_params->sd << PLL_SD_SHIFT;
+	omap_pipe3_writel(pipe3->pll_ctrl_base, PLL_CONFIGURATION3, val);
+
+	omap_pipe3_writel(pipe3->pll_ctrl_base, PLL_GO, SET_PLL_GO);
+
+	return omap_pipe3_wait_lock(pipe3);
+}
+
+static void omap_control_pipe3_power(struct omap_pipe3 *pipe3, int on)
+{
+	u32 val, rate;
+
+	val = readl(pipe3->power_reg);
+
+	rate = get_sys_clk_freq();
+	rate = rate/1000000;
+
+	if (on) {
+		val &= ~(OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK |
+				OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK);
+		val |= OMAP_CTRL_PIPE3_PHY_TX_RX_POWERON <<
+			OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
+		val |= rate <<
+			OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT;
+	} else {
+		val &= ~OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK;
+		val |= OMAP_CTRL_PIPE3_PHY_TX_RX_POWEROFF <<
+			OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
+	}
+
+	writel(val, pipe3->power_reg);
+}
+
+static int pipe3_power_on(struct udevice *dev)
+{
+	int ret;
+	u32 val;
+	struct omap_pipe3 *pipe3 = dev_get_priv(dev);
+
+	/* Program the DPLL only if not locked */
+	val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_STATUS);
+	if (!(val & PLL_LOCK)) {
+		ret = omap_pipe3_dpll_program(pipe3);
+		if (ret)
+			return ret;
+	} else {
+		/* else just bring it out of IDLE mode */
+		val = omap_pipe3_readl(pipe3->pll_ctrl_base,
+				       PLL_CONFIGURATION2);
+		if (val & PLL_IDLE) {
+			val &= ~PLL_IDLE;
+			omap_pipe3_writel(pipe3->pll_ctrl_base,
+					  PLL_CONFIGURATION2, val);
+			ret = omap_pipe3_wait_lock(pipe3);
+			if (ret)
+				return ret;
+		}
+	}
+
+	/* Power up the PHY */
+	omap_control_pipe3_power(pipe3, 1);
+
+	return 0;
+}
+
+static int pipe3_power_off(struct udevice *dev)
+{
+	u32 val;
+	int timeout = PLL_IDLE_TIME;
+	struct omap_pipe3 *pipe3 = dev_get_priv(dev);
+
+	/* Power down the PHY */
+	omap_control_pipe3_power(pipe3, 0);
+
+	/* Put DPLL in IDLE mode */
+	val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_CONFIGURATION2);
+	val |= PLL_IDLE;
+	omap_pipe3_writel(pipe3->pll_ctrl_base, PLL_CONFIGURATION2, val);
+
+	/* wait for LDO and Oscillator to power down */
+	do {
+		mdelay(1);
+		val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_STATUS);
+		if ((val & PLL_TICOPWDN) && (val & PLL_LDOPWDN))
+			break;
+	} while (--timeout);
+
+	if (!(val & PLL_TICOPWDN) || !(val & PLL_LDOPWDN)) {
+		printf("%s: Failed to power down DPLL: PLL_STATUS 0x%x\n",
+		       __func__, val);
+		return -EBUSY;
+	}
+
+	return 0;
+}
+
+static int pipe3_reset(struct udevice *dev)
+{
+	u32 val;
+	struct omap_pipe3 *pipe3 = dev_get_priv(dev);
+
+	val = readl(pipe3->pll_reset_reg);
+	writel(val | SATA_PLL_SOFT_RESET, pipe3->pll_reset_reg);
+	mdelay(1);
+	writel(val & ~SATA_PLL_SOFT_RESET, pipe3->pll_reset_reg);
+	return 0;
+}
+
+static void *get_reg(struct udevice *dev, const char *name)
+{
+	struct udevice *syscon;
+	struct regmap *regmap;
+	const fdt32_t *cell;
+	int len, err;
+	void *base;
+
+	err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
+					   name, &syscon);
+	if (err) {
+		error("unable to find syscon device for %s (%d)\n",
+		      name, err);
+		return NULL;
+	}
+
+	regmap = syscon_get_regmap(syscon);
+	if (IS_ERR(regmap)) {
+		error("unable to find regmap for %s (%ld)\n",
+		      name, PTR_ERR(regmap));
+		return NULL;
+	}
+
+	cell = fdt_getprop(gd->fdt_blob, dev->of_offset, name,
+			   &len);
+	if (len < 2*sizeof(fdt32_t)) {
+		error("offset not available for %s\n", name);
+		return NULL;
+	}
+
+	base = regmap_get_range(regmap, 0);
+	if (!base)
+		return NULL;
+
+	return fdtdec_get_number(cell + 1, 1) + base;
+}
+
+static int pipe3_phy_probe(struct udevice *dev)
+{
+	fdt_addr_t addr;
+	fdt_size_t sz;
+	struct omap_pipe3 *pipe3 = dev_get_priv(dev);
+
+	addr = dev_get_addr_size_index(dev, 2, &sz);
+	if (addr == FDT_ADDR_T_NONE) {
+		error("missing pll ctrl address\n");
+		return -EINVAL;
+	}
+
+	pipe3->pll_ctrl_base = map_physmem(addr, sz, MAP_NOCACHE);
+	if (!pipe3->pll_ctrl_base) {
+		error("unable to remap pll ctrl\n");
+		return -EINVAL;
+	}
+
+	pipe3->power_reg = get_reg(dev, "syscon-phy-power");
+	if (!pipe3->power_reg)
+		return -EINVAL;
+
+	pipe3->pll_reset_reg = get_reg(dev, "syscon-pllreset");
+	if (!pipe3->pll_reset_reg)
+		return -EINVAL;
+
+	pipe3->dpll_map = (struct pipe3_dpll_map *)dev_get_driver_data(dev);
+
+	return 0;
+}
+
+static struct pipe3_dpll_map dpll_map_sata[] = {
+	{12000000, {1000, 7, 4, 6, 0} },        /* 12 MHz */
+	{16800000, {714, 7, 4, 6, 0} },         /* 16.8 MHz */
+	{19200000, {625, 7, 4, 6, 0} },         /* 19.2 MHz */
+	{20000000, {600, 7, 4, 6, 0} },         /* 20 MHz */
+	{26000000, {461, 7, 4, 6, 0} },         /* 26 MHz */
+	{38400000, {312, 7, 4, 6, 0} },         /* 38.4 MHz */
+	{ },                                    /* Terminator */
+};
+
+static const struct udevice_id pipe3_phy_ids[] = {
+	{ .compatible = "ti,phy-pipe3-sata", .data = (ulong)&dpll_map_sata },
+	{ }
+};
+
+static struct generic_phy_ops pipe3_phy_ops = {
+	.power_on = pipe3_power_on,
+	.power_off = pipe3_power_off,
+	.reset = pipe3_reset
+};
+
+U_BOOT_DRIVER(pipe3_phy) = {
+	.name	= "pipe3_phy",
+	.id	= UCLASS_PHY,
+	.of_match = pipe3_phy_ids,
+	.ops = &pipe3_phy_ops,
+	.probe = pipe3_phy_probe,
+	.priv_auto_alloc_size = sizeof(struct omap_pipe3),
+};
-- 
1.9.1

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

* [U-Boot] [PATCH 06/11] dra7: dtsi: mark ocp2scp bus compatible with "simple-bus"
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
                   ` (4 preceding siblings ...)
  2017-04-14 11:08 ` [U-Boot] [PATCH 05/11] drivers: phy: add PIPE3 phy driver Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-14 20:06   ` Tom Rini
  2017-04-14 11:08 ` [U-Boot] [PATCH 07/11] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device Jean-Jacques Hiblot
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 UTC (permalink / raw)
  To: u-boot

This is needed to probe devices under that bus such as the SATA PHY.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 arch/arm/dts/omap5-u-boot.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/omap5-u-boot.dtsi b/arch/arm/dts/omap5-u-boot.dtsi
index 6305f57..9247314 100644
--- a/arch/arm/dts/omap5-u-boot.dtsi
+++ b/arch/arm/dts/omap5-u-boot.dtsi
@@ -10,6 +10,10 @@
 /{
 	ocp {
 		u-boot,dm-pre-reloc;
+
+		ocp2scp at 4a090000 {
+			compatible = "ti,omap-ocp2scp", "simple-bus";
+		};
 	};
 };
 
-- 
1.9.1

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

* [U-Boot] [PATCH 07/11] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
                   ` (5 preceding siblings ...)
  2017-04-14 11:08 ` [U-Boot] [PATCH 06/11] dra7: dtsi: mark ocp2scp bus compatible with "simple-bus" Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-14 11:08 ` [U-Boot] [PATCH 08/11] scsi: make the LUN a parameter of scsi_detect_dev() Jean-Jacques Hiblot
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 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>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 drivers/block/Kconfig    |  10 +++++
 drivers/block/Makefile   |   1 +
 drivers/block/dwc_ahci.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)
 create mode 100644 drivers/block/dwc_ahci.c

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 88e66e2..b3d35bd 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -48,4 +48,14 @@ config SATA_CEVA
 	  ZynqMP. Support up to 2 external devices. Complient with SATA 3.1 and
 	  AHCI 1.3 specifications with hot-plug detect feature.
 
+
+config DWC_AHCI
+	bool "Enable Synopsys DWC AHCI driver support"
+	select SCSI_AHCI
+	select GENERIC_PHY
+	depends on DM_SCSI
+	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 a72feec..cffe498 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -11,6 +11,7 @@ ifndef CONFIG_BLK
 obj-y += blk_legacy.o
 endif
 
+obj-$(CONFIG_DWC_AHCI) += dwc_ahci.o
 obj-$(CONFIG_AHCI) += ahci-uclass.o
 obj-$(CONFIG_DM_SCSI) += scsi-uclass.o
 obj-$(CONFIG_SCSI_AHCI) += ahci.o
diff --git a/drivers/block/dwc_ahci.c b/drivers/block/dwc_ahci.c
new file mode 100644
index 0000000..ca32841
--- /dev/null
+++ b/drivers/block/dwc_ahci.c
@@ -0,0 +1,100 @@
+/*
+ * 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 <scsi.h>
+#include <sata.h>
+#include <asm/arch/sata.h>
+#include <asm/io.h>
+#include <generic-phy.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+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);
+	struct scsi_platdata *plat = dev_get_platdata(dev);
+	fdt_addr_t addr;
+
+	plat->max_id = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, "max-id",
+				       CONFIG_SYS_SCSI_MAX_SCSI_ID);
+	plat->max_lun = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+					"max-lun", CONFIG_SYS_SCSI_MAX_LUN);
+
+	priv->base = map_physmem(dev_get_addr(dev), sizeof(void *),
+				 MAP_NOCACHE);
+
+	addr = dev_get_addr_index(dev, 1);
+	if (addr != FDT_ADDR_T_NONE) {
+		priv->wrapper_base = map_physmem(addr, sizeof(void *),
+						 MAP_NOCACHE);
+	} else {
+		priv->wrapper_base = NULL;
+	}
+
+	return 0;
+}
+
+static int dwc_ahci_probe(struct udevice *dev)
+{
+	struct dwc_ahci_priv *priv = dev_get_priv(dev);
+	int ret;
+	struct udevice *phy = dm_generic_phy_get(dev, "phys");
+
+	if (IS_ERR(phy)) {
+		error("can't get the phy from DT\n");
+		return PTR_ERR(phy);
+	}
+
+	ret = generic_phy_init(phy);
+	if (ret) {
+		error("unable to initialize the sata phy\n");
+		return ret;
+	}
+
+	ret = generic_phy_power_on(phy);
+	if (ret) {
+		error("unable to power on the sata phy\n");
+		return 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);
+	}
+
+	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_SCSI,
+	.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),
+	.platdata_auto_alloc_size = sizeof(struct scsi_platdata),
+	.flags = DM_FLAG_ALLOC_PRIV_DMA,
+};
-- 
1.9.1

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

* [U-Boot] [PATCH 08/11] scsi: make the LUN a parameter of scsi_detect_dev()
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
                   ` (6 preceding siblings ...)
  2017-04-14 11:08 ` [U-Boot] [PATCH 07/11] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-14 11:08 ` [U-Boot] [PATCH 09/11] scsi: move the partition initialization out of the scsi detection Jean-Jacques Hiblot
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 UTC (permalink / raw)
  To: u-boot

This is a cosmetic change. target and LUN have kind of the same role in
this function. One of them was passed as a parameter and the other was
embedded in a structure. For consistency, pass both of them as parameters.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 common/scsi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/common/scsi.c b/common/scsi.c
index fb5b407..d55ba89 100644
--- a/common/scsi.c
+++ b/common/scsi.c
@@ -473,14 +473,15 @@ static void scsi_init_dev_desc(struct blk_desc *dev_desc, int devnum)
  * scsi_detect_dev - Detect scsi device
  *
  * @target: target id
+ * @lun: target lun
  * @dev_desc: block device description
  *
  * The scsi_detect_dev detects and fills a dev_desc structure when the device is
- * detected. The LUN number is taken from the struct blk_desc *dev_desc.
+ * detected.
  *
  * Return: 0 on success, error value otherwise
  */
-static int scsi_detect_dev(int target, struct blk_desc *dev_desc)
+static int scsi_detect_dev(int target, int lun, struct blk_desc *dev_desc)
 {
 	unsigned char perq, modi;
 	lbaint_t capacity;
@@ -488,7 +489,7 @@ static int scsi_detect_dev(int target, struct blk_desc *dev_desc)
 	ccb *pccb = (ccb *)&tempccb;
 
 	pccb->target = target;
-	pccb->lun = dev_desc->lun;
+	pccb->lun = lun;
 	pccb->pdata = (unsigned char *)&tempbuff;
 	pccb->datalen = 512;
 	scsi_setup_inquiry(pccb);
@@ -599,8 +600,7 @@ int scsi_scan(int mode)
 				bdesc = dev_get_uclass_platdata(bdev);
 
 				scsi_init_dev_desc_priv(bdesc);
-				bdesc->lun = lun;
-				ret = scsi_detect_dev(i, bdesc);
+				ret = scsi_detect_dev(i, lun, bdesc);
 				if (ret) {
 					device_unbind(bdev);
 					continue;
@@ -630,8 +630,8 @@ int scsi_scan(int mode)
 	scsi_max_devs = 0;
 	for (i = 0; i < CONFIG_SYS_SCSI_MAX_SCSI_ID; i++) {
 		for (lun = 0; lun < CONFIG_SYS_SCSI_MAX_LUN; lun++) {
-			scsi_dev_desc[scsi_max_devs].lun = lun;
-			ret = scsi_detect_dev(i, &scsi_dev_desc[scsi_max_devs]);
+			ret = scsi_detect_dev(i, lun,
+					      &scsi_dev_desc[scsi_max_devs]);
 			if (ret)
 				continue;
 
-- 
1.9.1

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

* [U-Boot] [PATCH 09/11] scsi: move the partition initialization out of the scsi detection
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
                   ` (7 preceding siblings ...)
  2017-04-14 11:08 ` [U-Boot] [PATCH 08/11] scsi: make the LUN a parameter of scsi_detect_dev() Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-14 11:08 ` [U-Boot] [PATCH 10/11] dm: scsi: fix divide-by-0 error in scsi_scan() Jean-Jacques Hiblot
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 UTC (permalink / raw)
  To: u-boot

We might want to get information about the scsi device without initializing the partition.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 common/scsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/scsi.c b/common/scsi.c
index d55ba89..972ef338 100644
--- a/common/scsi.c
+++ b/common/scsi.c
@@ -540,7 +540,6 @@ static int scsi_detect_dev(int target, int lun, struct blk_desc *dev_desc)
 	dev_desc->blksz = blksz;
 	dev_desc->log2blksz = LOG2(dev_desc->blksz);
 	dev_desc->type = perq;
-	part_init(&dev_desc[0]);
 removable:
 	return 0;
 }
@@ -605,6 +604,7 @@ int scsi_scan(int mode)
 					device_unbind(bdev);
 					continue;
 				}
+				part_init(bdesc);
 
 				if (mode == 1) {
 					printf("  Device %d: ", 0);
@@ -634,6 +634,7 @@ int scsi_scan(int mode)
 					      &scsi_dev_desc[scsi_max_devs]);
 			if (ret)
 				continue;
+			part_init(&scsi_dev_desc[scsi_max_devs]);
 
 			if (mode == 1) {
 				printf("  Device %d: ", 0);
-- 
1.9.1

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

* [U-Boot] [PATCH 10/11] dm: scsi: fix divide-by-0 error in scsi_scan()
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
                   ` (8 preceding siblings ...)
  2017-04-14 11:08 ` [U-Boot] [PATCH 09/11] scsi: move the partition initialization out of the scsi detection Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-14 11:08 ` [U-Boot] [PATCH 11/11] defconfig: dra7xx_evm: enable CONFIG_BLK and disk driver model for SCSI Jean-Jacques Hiblot
  2017-04-14 11:13 ` [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
  11 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 UTC (permalink / raw)
  To: u-boot

With DM_SCSI enabled, blk_create_devicef() is called with blkz = 0, leading
to a divide-by-0 exception.
scsi_detect_dev() can be used to get the required parameters (block size
and number of blocks) from the drive before calling blk_create_devicef().

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 common/scsi.c | 85 ++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 49 insertions(+), 36 deletions(-)

diff --git a/common/scsi.c b/common/scsi.c
index 972ef338..c456f5a 100644
--- a/common/scsi.c
+++ b/common/scsi.c
@@ -549,6 +549,52 @@ removable:
  * to the user if mode = 1
  */
 #if defined(CONFIG_DM_SCSI)
+static int do_scsi_scan_one(struct udevice *dev, int id, int lun, int mode)
+{
+	int ret;
+	struct udevice *bdev;
+	struct blk_desc bd;
+	struct blk_desc *bdesc;
+	char str[10];
+
+	/*
+	 * detect the scsi driver to get information about its geometry (block
+	 * size, number of blocks) and other parameters (ids, type, ...)
+	 */
+	scsi_init_dev_desc_priv(&bd);
+	if (scsi_detect_dev(id, lun, &bd))
+		return -ENODEV;
+
+	/*
+	* Create only one block device and do detection
+	* to make sure that there won't be a lot of
+	* block devices created
+	*/
+	snprintf(str, sizeof(str), "id%dlun%d", id, lun);
+	ret = blk_create_devicef(dev, "scsi_blk", str, IF_TYPE_SCSI, -1,
+			bd.blksz, bd.blksz * bd.lba, &bdev);
+	if (ret) {
+		debug("Can't create device\n");
+		return ret;
+	}
+
+	bdesc = dev_get_uclass_platdata(bdev);
+	bdesc->target = id;
+	bdesc->lun = lun;
+	bdesc->removable = bd.removable;
+	bdesc->type = bd.type;
+	memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor));
+	memcpy(&bdesc->product, &bd.product, sizeof(bd.product));
+	memcpy(&bdesc->revision, &bd.revision,	sizeof(bd.revision));
+	part_init(bdesc);
+
+	if (mode == 1) {
+		printf("  Device %d: ", 0);
+		dev_print(bdesc);
+	}
+	return 0;
+}
+
 int scsi_scan(int mode)
 {
 	unsigned char i, lun;
@@ -576,42 +622,9 @@ int scsi_scan(int mode)
 		/* Get controller platdata */
 		plat = dev_get_platdata(dev);
 
-		for (i = 0; i < plat->max_id; i++) {
-			for (lun = 0; lun < plat->max_lun; lun++) {
-				struct udevice *bdev; /* block device */
-				/* block device description */
-				struct blk_desc *bdesc;
-				char str[10];
-
-				/*
-				 * Create only one block device and do detection
-				 * to make sure that there won't be a lot of
-				 * block devices created
-				 */
-				snprintf(str, sizeof(str), "id%dlun%d", i, lun);
-				ret = blk_create_devicef(dev, "scsi_blk",
-							  str, IF_TYPE_SCSI,
-							  -1, 0, 0, &bdev);
-				if (ret) {
-					debug("Can't create device\n");
-					return ret;
-				}
-				bdesc = dev_get_uclass_platdata(bdev);
-
-				scsi_init_dev_desc_priv(bdesc);
-				ret = scsi_detect_dev(i, lun, bdesc);
-				if (ret) {
-					device_unbind(bdev);
-					continue;
-				}
-				part_init(bdesc);
-
-				if (mode == 1) {
-					printf("  Device %d: ", 0);
-					dev_print(bdesc);
-				} /* if mode */
-			} /* next LUN */
-		}
+		for (i = 0; i < plat->max_id; i++)
+			for (lun = 0; lun < plat->max_lun; lun++)
+				do_scsi_scan_one(dev, i, lun, mode);
 	}
 
 	return 0;
-- 
1.9.1

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

* [U-Boot] [PATCH 11/11] defconfig: dra7xx_evm: enable CONFIG_BLK and disk driver model for SCSI
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
                   ` (9 preceding siblings ...)
  2017-04-14 11:08 ` [U-Boot] [PATCH 10/11] dm: scsi: fix divide-by-0 error in scsi_scan() Jean-Jacques Hiblot
@ 2017-04-14 11:08 ` Jean-Jacques Hiblot
  2017-04-14 11:13 ` [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
  11 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:08 UTC (permalink / raw)
  To: u-boot

Enable disk driver model for dra7xx_evm as dwc_ahci supports
driver model. As a consequence we must also enable CONFIG_BLK and
CONFIG_DM_USB.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
 configs/dra7xx_evm_defconfig    | 12 +++++++++++-
 configs/dra7xx_hs_evm_defconfig | 11 ++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index 42f87b3..8bc395f 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -59,7 +59,13 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm"
 CONFIG_DM=y
 CONFIG_SPL_DM=y
-# CONFIG_BLK is not set
+CONFIG_REGMAP=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
+CONFIG_BLK=y
+CONFIG_DM_SCSI=y
+CONFIG_DWC_AHCI=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_SF=y
@@ -89,6 +95,7 @@ CONFIG_TI_QSPI=y
 CONFIG_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
@@ -101,3 +108,6 @@ CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_G_DNL_MANUFACTURER="Texas Instruments"
 CONFIG_G_DNL_VENDOR_NUM=0x0451
 CONFIG_G_DNL_PRODUCT_NUM=0xd022
+CONFIG_SPL_GENERIC_PHY=y
+CONFIG_PIPE3_PHY=y
+CONFIG_SPL_PIPE3_PHY=y
diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
index 871604f..40ac3d5 100644
--- a/configs/dra7xx_hs_evm_defconfig
+++ b/configs/dra7xx_hs_evm_defconfig
@@ -64,7 +64,12 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm"
 CONFIG_DM=y
 CONFIG_SPL_DM=y
-# CONFIG_BLK is not set
+CONFIG_REGMAP=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
+CONFIG_DM_SCSI=y
+CONFIG_DWC_AHCI=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_SF=y
@@ -94,6 +99,7 @@ CONFIG_TI_QSPI=y
 CONFIG_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
@@ -106,3 +112,6 @@ CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_G_DNL_MANUFACTURER="Texas Instruments"
 CONFIG_G_DNL_VENDOR_NUM=0x0451
 CONFIG_G_DNL_PRODUCT_NUM=0xd022
+CONFIG_SPL_GENERIC_PHY=y
+CONFIG_PIPE3_PHY=y
+CONFIG_SPL_PIPE3_PHY=y
-- 
1.9.1

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

* [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model
  2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
                   ` (10 preceding siblings ...)
  2017-04-14 11:08 ` [U-Boot] [PATCH 11/11] defconfig: dra7xx_evm: enable CONFIG_BLK and disk driver model for SCSI Jean-Jacques Hiblot
@ 2017-04-14 11:13 ` Jean-Jacques Hiblot
  11 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-14 11:13 UTC (permalink / raw)
  To: u-boot

Hi all,

This is the VERSION 3 of the series. Sorry for the confusion, I messed 
up while preparing the patches.

Jean-Jacques



On 14/04/2017 13:07, Jean-Jacques Hiblot wrote:
> This series adds support for SATA using the driver model on omap platforms.
> It is based on the work of Mugunthan V N <mugunthanvnm@ti.com> in Feb 2016
>
> The first 2 patches are preparatory work.
> The 3rd patch adds a new framework to handle PHYs in a generic manner. The idea
> is to move the phy initialization out of the board-specific code into a proper
> driver. The link between the phy device and the controller device is done in
> by device-tree as it's done in linux. The API to control a phy has been copied
> from linux, excpet that the functions are prefixed by 'generic_phy_' instead of
> just 'phy_' because phy_reset() is already used to handle the Ethernet phys.
> The 5th patch adds a phy driver for the pipe3 sata phy found in the
> omaps/am5x/dra7x SOCs.
> The 6th patch allows the device under the node ocp2scp at 4a090000 to be probed.
> The 7th patch implements a driver for the SATA controller found in the
> omaps/am5x/dra7x SOCs.
> The 8th patch is cosmetic and changes the interface of scsi_detect_dev()
> The 9th patch moves the call to part_init() out of scsi_detect_dev(). This is
> a preparatory work path #10.
> The 10th patches fix a divide-by-0 error that happens in scsi_scan()
> when DM is used and split scsi_scan() in 2 functions for clarity.
> The last patch enables the DM sata by default for the dra7 platforms.
>
> changes since v2:
> * Added unit tests for generic PHY uclass.
> * Changed the generic phy API to use a 'struct udevice*' to reference the phy
>    device.
> * Don't modify anymore the root Makefile.
> * Updated the Kconfig with more details on the PHY framework.
> * Use a Unique Lincense Identifier (SPDX)
> * Use omap5-u-boot.dtsi to mark the ocp2scp bus as compatible with "simple-bus"
> * Split scsi_scan() in 2 for clarity. The function was becoming too long.
>
> changes since v1:
> * changed the way the 'old' sata code is compiled out when DM_SCSI is enabled.
> * added a new framework for PHY management.
> * added a new driver for the PIPE3 phy and use it in the dwc_ahci driver.
> * changed the interface of scsi_detect_dev() and moved the call part_init() out
>    of it.
> * modified the fix to scsi_scan() in order to call scsi_detect_dev() only once.
> * the max_lun and max_id parameters are now taken from the device-tree.
> * Updated the defconfig changes to include the PHY driver and its dependencies.
>
> Jean-Jacques Hiblot (11):
>    arm: omap: sata: move enable sata clocks to enable_basic_clocks()
>    arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI
>      is defined
>    drivers: phy: add generic PHY framework
>    dm: test: Add tests for the generic PHY uclass
>    drivers: phy: add PIPE3 phy driver
>    dra7: dtsi: mark ocp2scp bus compatible with "simple-bus"
>    drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata
>      device
>    scsi: make the LUN a parameter of scsi_detect_dev()
>    scsi: move the partition initialization out of the scsi detection
>    dm: scsi: fix divide-by-0 error in scsi_scan()
>    defconfig: dra7xx_evm: enable CONFIG_BLK and disk driver model for
>      SCSI
>
>   arch/arm/dts/omap5-u-boot.dtsi      |   4 +
>   arch/arm/mach-omap2/Makefile        |   2 +
>   arch/arm/mach-omap2/omap5/hw_data.c |  12 ++
>   arch/arm/mach-omap2/sata.c          |  23 ---
>   arch/sandbox/dts/test.dts           |   9 +
>   common/scsi.c                       |  98 +++++-----
>   configs/dra7xx_evm_defconfig        |  12 +-
>   configs/dra7xx_hs_evm_defconfig     |  11 +-
>   configs/sandbox_defconfig           |   2 +
>   configs/sandbox_noblk_defconfig     |   2 +
>   configs/sandbox_spl_defconfig       |   3 +
>   drivers/Kconfig                     |   2 +
>   drivers/Makefile                    |   1 +
>   drivers/block/Kconfig               |  10 +
>   drivers/block/Makefile              |   1 +
>   drivers/block/dwc_ahci.c            | 100 ++++++++++
>   drivers/phy/Kconfig                 |  59 ++++++
>   drivers/phy/Makefile                |   4 +
>   drivers/phy/phy-uclass.c            |  64 +++++++
>   drivers/phy/sandbox-phy.c           |  78 ++++++++
>   drivers/phy/ti-pipe3-phy.c          | 365 ++++++++++++++++++++++++++++++++++++
>   include/dm/uclass-id.h              |   1 +
>   include/generic-phy.h               |  36 ++++
>   test/dm/Makefile                    |   1 +
>   test/dm/generic_phy.c               |  89 +++++++++
>   25 files changed, 922 insertions(+), 67 deletions(-)
>   create mode 100644 drivers/block/dwc_ahci.c
>   create mode 100644 drivers/phy/Kconfig
>   create mode 100644 drivers/phy/Makefile
>   create mode 100644 drivers/phy/phy-uclass.c
>   create mode 100644 drivers/phy/sandbox-phy.c
>   create mode 100644 drivers/phy/ti-pipe3-phy.c
>   create mode 100644 include/generic-phy.h
>   create mode 100644 test/dm/generic_phy.c
>

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

* [U-Boot] [PATCH 06/11] dra7: dtsi: mark ocp2scp bus compatible with "simple-bus"
  2017-04-14 11:08 ` [U-Boot] [PATCH 06/11] dra7: dtsi: mark ocp2scp bus compatible with "simple-bus" Jean-Jacques Hiblot
@ 2017-04-14 20:06   ` Tom Rini
  0 siblings, 0 replies; 18+ messages in thread
From: Tom Rini @ 2017-04-14 20:06 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 14, 2017 at 01:08:04PM +0200, Jean-Jacques Hiblot wrote:

> This is needed to probe devices under that bus such as the SATA PHY.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@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: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170414/c053806e/attachment.sig>

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

* [U-Boot] [PATCH 04/11] dm: test: Add tests for the generic PHY uclass
  2017-04-14 11:08 ` [U-Boot] [PATCH 04/11] dm: test: Add tests for the generic PHY uclass Jean-Jacques Hiblot
@ 2017-04-15 17:10   ` Simon Glass
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-04-15 17:10 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On 14 April 2017 at 05:08, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> Those tests check:
> - the ability for a phy-user to get a phy device a reference in the
>   device-tree
> - the ability to perform operations on the phy (init,deinit,on,off)
> - the behavior of the uclass when optional operations are not implemented
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>  arch/sandbox/dts/test.dts       |  9 +++++
>  configs/sandbox_defconfig       |  2 +
>  configs/sandbox_noblk_defconfig |  2 +
>  configs/sandbox_spl_defconfig   |  3 ++
>  drivers/phy/Kconfig             |  9 +++++
>  drivers/phy/Makefile            |  1 +
>  drivers/phy/sandbox-phy.c       | 78 ++++++++++++++++++++++++++++++++++++
>  test/dm/Makefile                |  1 +
>  test/dm/generic_phy.c           | 89 +++++++++++++++++++++++++++++++++++++++++
>  9 files changed, 194 insertions(+)
>  create mode 100644 drivers/phy/sandbox-phy.c
>  create mode 100644 test/dm/generic_phy.c

This looks really good, just some nits.

>
> diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
> index fff175d..918c899 100644
> --- a/arch/sandbox/dts/test.dts
> +++ b/arch/sandbox/dts/test.dts
> @@ -59,6 +59,15 @@
>                 ping-add = <3>;
>         };
>
> +       gen_phy: gen_phy {
> +               compatible = "sandbox,phy";
> +       };
> +
> +       gen_phy_user: gen_phy_user {
> +               compatible = "simple-bus";
> +               phy = <&gen_phy>;
> +       };
> +
>         some-bus {
>                 #address-cells = <1>;
>                 #size-cells = <0>;
> diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
> index 7f3f5ac..42116cf 100644
> --- a/configs/sandbox_defconfig
> +++ b/configs/sandbox_defconfig
> @@ -164,6 +164,8 @@ CONFIG_CONSOLE_ROTATION=y
>  CONFIG_CONSOLE_TRUETYPE=y
>  CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
>  CONFIG_VIDEO_SANDBOX_SDL=y
> +CONFIG_GENERIC_PHY=y
> +CONFIG_PHY_SANDBOX=y
>  CONFIG_CMD_DHRYSTONE=y
>  CONFIG_TPM=y
>  CONFIG_LZ4=y
> diff --git a/configs/sandbox_noblk_defconfig b/configs/sandbox_noblk_defconfig
> index 3f8e70d..7a5cd4b 100644
> --- a/configs/sandbox_noblk_defconfig
> +++ b/configs/sandbox_noblk_defconfig
> @@ -166,6 +166,8 @@ CONFIG_CONSOLE_ROTATION=y
>  CONFIG_CONSOLE_TRUETYPE=y
>  CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
>  CONFIG_VIDEO_SANDBOX_SDL=y
> +CONFIG_GENERIC_PHY=y
> +CONFIG_PHY_SANDBOX=y
>  CONFIG_CMD_DHRYSTONE=y
>  CONFIG_TPM=y
>  CONFIG_LZ4=y
> diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
> index ade6714..9b4cf39 100644
> --- a/configs/sandbox_spl_defconfig
> +++ b/configs/sandbox_spl_defconfig
> @@ -170,6 +170,9 @@ CONFIG_CONSOLE_ROTATION=y
>  CONFIG_CONSOLE_TRUETYPE=y
>  CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
>  CONFIG_VIDEO_SANDBOX_SDL=y
> +CONFIG_GENERIC_PHY=y
> +CONFIG_SPL_GENERIC_PHY=y
> +CONFIG_PHY_SANDBOX=y
>  CONFIG_CMD_DHRYSTONE=y
>  CONFIG_TPM=y
>  CONFIG_LZ4=y
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index d66c9e3..032b932 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -29,4 +29,13 @@ config SPL_GENERIC_PHY
>           compatible as possible with the equivalent framework found in the
>           linux kernel.
>
> +config PHY_SANDBOX
> +       bool "Sandbox PHY support"
> +       depends on SANDBOX
> +       depends on GENERIC_PHY
> +       help
> +         This select a dummy sandbox PHY driver. It used only to implement
> +         unit tests for the generic phy framework
> +
> +
>  endmenu
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index b29a8b9..0125844 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -1,2 +1,3 @@
>  obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o
> +obj-$(CONFIG_PHY_SANDBOX) += sandbox-phy.o
>
> diff --git a/drivers/phy/sandbox-phy.c b/drivers/phy/sandbox-phy.c
> new file mode 100644
> index 0000000..1c60308
> --- /dev/null
> +++ b/drivers/phy/sandbox-phy.c
> @@ -0,0 +1,78 @@
> +/*
> + * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
> + * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <generic-phy.h>
> +
> +struct sandbox_phy_priv {
> +       int initialized;
> +       int on;

bool?

> +};
> +
> +static int sandbox_phy_power_on(struct udevice *dev)
> +{
> +       struct sandbox_phy_priv *priv = dev_get_priv(dev);

blank line between decls and rest of code
> +       if (!priv->initialized)
> +               return -EIO;
> +       priv->on = 1;

blank line before return
true/false better than 0/1 I think

> +       return 0;
> +}
> +
> +static int sandbox_phy_power_off(struct udevice *dev)
> +{
> +       struct sandbox_phy_priv *priv = dev_get_priv(dev);
> +       if (!priv->initialized)
> +               return -EIO;
> +       priv->on = 0;
> +       return 0;
> +}
> +
> +static int sandbox_phy_init(struct udevice *dev)
> +{
> +       struct sandbox_phy_priv *priv = dev_get_priv(dev);
> +       priv->initialized = 1;
> +       priv->on = 0;
> +       return 0;
> +}
> +
> +static int sandbox_phy_exit(struct udevice *dev)
> +{
> +       struct sandbox_phy_priv *priv = dev_get_priv(dev);
> +       priv->initialized = 0;
> +       priv->on = 0;
> +       return 0;
> +}
> +
> +static int sandbox_phy_probe(struct udevice *dev)
> +{
> +       struct sandbox_phy_priv *priv = dev_get_priv(dev);
> +       priv->initialized = 0;
> +       priv->on = 0;
> +       return 0;
> +}
> +
> +static struct generic_phy_ops sandbox_phy_ops = {
> +       .power_on = sandbox_phy_power_on,
> +       .power_off = sandbox_phy_power_off,
> +       .init = sandbox_phy_init,
> +       .exit = sandbox_phy_exit,
> +};
> +
> +static const struct udevice_id sandbox_phy_ids[] = {
> +       { .compatible = "sandbox,phy" },
> +       { }
> +};
> +
> +U_BOOT_DRIVER(phy_sandbox) = {
> +       .name           = "phy_sandbox",
> +       .id             = UCLASS_PHY,
> +       .of_match       = sandbox_phy_ids,
> +       .ops            = &sandbox_phy_ops,
> +       .probe          = sandbox_phy_probe,
> +       .priv_auto_alloc_size = sizeof(struct sandbox_phy_priv),
> +};
> diff --git a/test/dm/Makefile b/test/dm/Makefile
> index 1885e17..e2b7d43 100644
> --- a/test/dm/Makefile
> +++ b/test/dm/Makefile
> @@ -41,4 +41,5 @@ obj-$(CONFIG_TIMER) += timer.o
>  obj-$(CONFIG_DM_VIDEO) += video.o
>  obj-$(CONFIG_ADC) += adc.o
>  obj-$(CONFIG_SPMI) += spmi.o
> +obj-$(CONFIG_GENERIC_PHY) += generic_phy.o

check ordering

>  endif
> diff --git a/test/dm/generic_phy.c b/test/dm/generic_phy.c
> new file mode 100644
> index 0000000..08b862a
> --- /dev/null
> +++ b/test/dm/generic_phy.c
> @@ -0,0 +1,89 @@
> +/*
> + * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
> + * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <dm/test.h>
> +#include <test/ut.h>
> +#include <generic-phy.h>

This should go below dm.h

> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/* Base test of the phy uclass */
> +static int dm_test_phy_base(struct unit_test_state *uts)
> +{
> +       struct udevice *dev_method1;
> +       struct udevice *dev_method2;
> +       struct udevice *parent;
> +
> +

drop extra blank ilne

> +       /* Get the device using the phy device*/
> +       ut_assertok(uclass_get_device_by_name(UCLASS_SIMPLE_BUS,
> +                                             "gen_phy_user", &parent));
> +       /* Get the phy device with std uclass function */
> +       ut_assertok(uclass_get_device_by_name(UCLASS_PHY, "gen_phy",
> +                                             &dev_method1));
> +
> +       /*
> +        * Get the phy device from user device and compare with the one
> +        * obtained with the previous method.
> +        */
> +       dev_method2 = dm_generic_phy_get(parent, "phy");

This should be able to use ut_assertok() once the function returns an
error code.

> +       ut_assertnonnull(dev_method2);
> +       ut_assertok_ptr(dev_method2);
> +       ut_asserteq_ptr(dev_method1, dev_method2);
> +
> +       /* Try to get a non-existing phy */
> +       ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PHY, 1, &dev_method2));
> +       dev_method2 = dm_generic_phy_get(parent, "phy_not_existing");
> +       ut_assert(IS_ERR_OR_NULL(dev_method2));
> +
> +       return 0;
> +}
> +DM_TEST(dm_test_phy_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
> +
> +/* Test of the phy uclass using the sandbox phy driver operations */
> +static int dm_test_phy_ops(struct unit_test_state *uts)
> +{
> +       struct udevice *dev;
> +       struct udevice *parent;
> +
> +       ut_assertok(uclass_get_device_by_name(UCLASS_SIMPLE_BUS,
> +                                             "gen_phy_user", &parent));
> +       dev = dm_generic_phy_get(parent, "phy");
> +       ut_assertnonnull(dev);
> +       ut_assertok_ptr(dev);
> +
> +       /* test normal operations */
> +       ut_assertok(generic_phy_init(dev));
> +       ut_assertok(generic_phy_power_on(dev));
> +       ut_assertok(generic_phy_power_off(dev));
> +
> +       /*
> +        * test operations after exit().
> +        * The sandbox phy driver does not allow it.
> +        */
> +       ut_assertok(generic_phy_exit(dev));
> +       ut_assert(generic_phy_power_on(dev) != 0);
> +       ut_assert(generic_phy_power_off(dev) != 0);
> +
> +       /*
> +        * test normal operations again (after re-init)
> +        */
> +       ut_assertok(generic_phy_init(dev));
> +       ut_assertok(generic_phy_power_on(dev));
> +       ut_assertok(generic_phy_power_off(dev));
> +
> +       /*
> +        * test calling unimplemented feature.
> +        * The call is expected to succeed
> +        */
> +       ut_assertok(generic_phy_reset(dev));
> +
> +       return 0;
> +}
> +DM_TEST(dm_test_phy_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
> --
> 1.9.1
>

Great test, thanks.

Regards,
Simon

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

* [U-Boot] [PATCH 03/11] drivers: phy: add generic PHY framework
  2017-04-14 11:08 ` [U-Boot] [PATCH 03/11] drivers: phy: add generic PHY framework Jean-Jacques Hiblot
@ 2017-04-15 17:10   ` Simon Glass
  2017-04-18 13:32     ` Jean-Jacques Hiblot
  0 siblings, 1 reply; 18+ messages in thread
From: Simon Glass @ 2017-04-15 17:10 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On 14 April 2017 at 05:08, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> The PHY framework provides a set of APIs to control a PHY. This API is
> derived from the linux version of the generic PHY framework.
> Currently the API supports init(), deinit(), power_on, power_off() and
> reset(). The framework provides a way to get a reference to a phy from the
> device-tree.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>  drivers/Kconfig          |  2 ++
>  drivers/Makefile         |  1 +
>  drivers/phy/Kconfig      | 32 ++++++++++++++++++++++++
>  drivers/phy/Makefile     |  2 ++
>  drivers/phy/phy-uclass.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
>  include/dm/uclass-id.h   |  1 +
>  include/generic-phy.h    | 36 +++++++++++++++++++++++++++
>  7 files changed, 138 insertions(+)
>  create mode 100644 drivers/phy/Kconfig
>  create mode 100644 drivers/phy/Makefile
>  create mode 100644 drivers/phy/phy-uclass.c
>  create mode 100644 include/generic-phy.h

I mostly have minor things at this point. Note that I've applied the
patches from your series that I can, so please rebase on master.

Also can you please:
- check your version number (I think you might be up to v3 now)
- include a change log with each patch (patman might help you)
- rebase on u-boot-dm/master

I'm sorry if this comes across as a bit pedantic. But you are creating
a new uclass which I think will be quite important in U-Boot. I
suspect it will be used by USB, perhaps Ethernet and other systems, so
careful design and documentation is pretty important.

>
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index 0e5d97d..a90ceca 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -88,6 +88,8 @@ source "drivers/video/Kconfig"
>
>  source "drivers/watchdog/Kconfig"
>
> +source "drivers/phy/Kconfig"
> +
>  config PHYS_TO_BUS
>         bool "Custom physical to bus address mapping"
>         help
> diff --git a/drivers/Makefile b/drivers/Makefile
> index 5d8baa5..0be0624 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -7,6 +7,7 @@ obj-$(CONFIG_$(SPL_)CLK)        += clk/
>  obj-$(CONFIG_$(SPL_)LED)       += led/
>  obj-$(CONFIG_$(SPL_)PINCTRL)   += pinctrl/
>  obj-$(CONFIG_$(SPL_)RAM)       += ram/
> +obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy/

Please maintain the ordering here

>
>  ifdef CONFIG_SPL_BUILD
>
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> new file mode 100644
> index 0000000..d66c9e3
> --- /dev/null
> +++ b/drivers/phy/Kconfig
> @@ -0,0 +1,32 @@
> +
> +menu "PHY Subsystem"
> +
> +config GENERIC_PHY
> +       bool "PHY Core"
> +       depends on DM
> +       help
> +         Generic PHY support.
> +
> +         This framework is designed to provide a generic interface for PHY

PHY means?

> +         devices. PHYs are commonly used for high speed interfaces such as
> +         SATA or PCIe.

Please write out SATA and PCIe in full at least once. This is help so
we should not assume much.

> +         The API provides functions to initialize/deinitialize the
> +         phy, power on/off the phy, and reset the phy. It's meant to be as

Is it PHY or phy?

> +         compatible as possible with the equivalent framework found in the
> +         linux kernel.
> +
> +config SPL_GENERIC_PHY
> +       bool "PHY Core in SPL"
> +       depends on DM
> +       help
> +         Generic PHY support in SPL.
> +
> +         This framework is designed to provide a generic interface for PHY
> +         devices. PHYs are commonly used for high speed interfaces such as
> +         SATA or PCIe.
> +         The API provides functions to initialize/deinitialize the
> +         phy, power on/off the phy, and reset the phy. It's meant to be as
> +         compatible as possible with the equivalent framework found in the
> +         linux kernel.
> +
> +endmenu
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> new file mode 100644
> index 0000000..b29a8b9
> --- /dev/null
> +++ b/drivers/phy/Makefile
> @@ -0,0 +1,2 @@
> +obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o
> +
> diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
> new file mode 100644
> index 0000000..e15ed43
> --- /dev/null
> +++ b/drivers/phy/phy-uclass.c
> @@ -0,0 +1,64 @@
> +/*
> + * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
> + * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <generic-phy.h>
> +
> +struct udevice *dm_generic_phy_get(struct udevice *parent, const char *string)

Can you make this return an error code instead, and the device pointer
as a parameter? This is how it is generally down in DM. See
uclass_first_device() for example.

Also I think you should drop the dm_ in the name. That prefix is used
for core driver model functions, and DM versions of function that have
a non-DM analogue.

Also I think 'get' is too short. We normally use that for getting by
index. How about generic_phy_get_by_name() or, phy_get_by_name() if
you rename it?

> +{
> +       struct udevice *dev;
> +
> +       int rc = uclass_get_device_by_phandle(UCLASS_PHY, parent,
> +                                          string, &dev);
> +       if (rc) {
> +               debug("unable to find generic_phy device (err: %d)\n", rc);
> +               return ERR_PTR(rc);
> +       }
> +
> +       return dev;
> +}
> +
> +int generic_phy_init(struct udevice *dev)
> +{
> +       struct generic_phy_ops const *ops = dev->driver->ops;

Please use a header-file macro to access ops. See clk-uclass.c for an example.

> +
> +       return (ops && ops->init) ? ops->init(dev) : 0;

You don't need to check ops since it is invalid not to have one. So:

return ops->init ? ops->init(dev) : 0;

> +}
> +
> +int generic_phy_reset(struct udevice *dev)
> +{
> +       struct generic_phy_ops const *ops = dev->driver->ops;
> +
> +       return (ops && ops->reset) ? ops->reset(dev) : 0;
> +}
> +
> +int generic_phy_exit(struct udevice *dev)
> +{
> +       struct generic_phy_ops const *ops = dev->driver->ops;
> +
> +       return (ops && ops->exit) ? ops->exit(dev) : 0;
> +}
> +
> +int generic_phy_power_on(struct udevice *dev)
> +{
> +       struct generic_phy_ops const *ops = dev->driver->ops;
> +
> +       return (ops && ops->power_on) ? ops->power_on(dev) : 0;
> +}
> +
> +int generic_phy_power_off(struct udevice *dev)
> +{
> +       struct generic_phy_ops const *ops = dev->driver->ops;
> +
> +       return (ops && ops->power_off) ? ops->power_off(dev) : 0;
> +}
> +
> +UCLASS_DRIVER(generic_phy) = {
> +       .id             = UCLASS_PHY,

I would like the uclass name to match the header file and the uclass
name. So if you are calling this generic_phy, then the uclass should
be named this too. Same with the directory drivers/phy. If you want to
rename it all to 'phy' then that is fine too.

> +       .name           = "generic_phy",
> +};
> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
> index 8c92d0b..9d34a32 100644
> --- a/include/dm/uclass-id.h
> +++ b/include/dm/uclass-id.h
> @@ -83,6 +83,7 @@ enum uclass_id {
>         UCLASS_VIDEO,           /* Video or LCD device */
>         UCLASS_VIDEO_BRIDGE,    /* Video bridge, e.g. DisplayPort to LVDS */
>         UCLASS_VIDEO_CONSOLE,   /* Text console driver for video device */
> +       UCLASS_PHY,             /* generic PHY device */

Physical layer device? Can you make your comment a bit more useful?

>
>         UCLASS_COUNT,
>         UCLASS_INVALID = -1,
> diff --git a/include/generic-phy.h b/include/generic-phy.h
> new file mode 100644
> index 0000000..24475f0
> --- /dev/null
> +++ b/include/generic-phy.h
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
> + * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#ifndef __GENERIC_PHY_H
> +#define __GENERIC_PHY_H
> +
> +/*
> + * struct udevice_ops - set of function pointers for phy operations
> + * @init: operation to be performed for initializing phy (optionnal)

optional

Can you please put these comments in front of each function in struct
generic_phy_ops as is done with other uclasses? Your description
should explain what the operation does. For example, what happens for
init()? Since the phy has already been probed, what should you not do
in probe() but do in init()?

> + * @exit: operation to be performed while exiting (optionnal)

exiting what? Please add some more detail.

> + * @reset: reset the phy (optionnal).
> + * @power_on: powering on the phy (optionnal)
> + * @power_off: powering off the phy (optionnal)

Are these optional because the phy might be powered on during one of
the other operations? Otherwise it doesn't seem helpful to have the
thing not ever power on.

> + */
> +struct generic_phy_ops {
> +       int     (*init)(struct udevice *phy);
> +       int     (*exit)(struct udevice *phy);
> +       int     (*reset)(struct udevice *phy);
> +       int     (*power_on)(struct udevice *phy);
> +       int     (*power_off)(struct udevice *phy);
> +};
> +
> +
> +int generic_phy_init(struct udevice *phy);

Here you need to repeat your comments from above - see other uclasses
for an example.

> +int generic_phy_reset(struct udevice *phy);
> +int generic_phy_exit(struct udevice *phy);
> +int generic_phy_power_on(struct udevice *phy);
> +int generic_phy_power_off(struct udevice *phy);
> +
> +struct udevice *dm_generic_phy_get(struct udevice *parent, const char *string);

This function need a comment. Also instead of string can you think of
a descriptive name, e.g. phy_name?

> +
> +#endif /*__GENERIC_PHY_H */
> --
> 1.9.1
>

Regards,
Simon

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

* [U-Boot] [PATCH 03/11] drivers: phy: add generic PHY framework
  2017-04-15 17:10   ` Simon Glass
@ 2017-04-18 13:32     ` Jean-Jacques Hiblot
  2017-04-19  0:12       ` Simon Glass
  0 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-04-18 13:32 UTC (permalink / raw)
  To: u-boot



On 15/04/2017 19:10, Simon Glass wrote:
> Hi Jean-Jacques,
>
> On 14 April 2017 at 05:08, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>> The PHY framework provides a set of APIs to control a PHY. This API is
>> derived from the linux version of the generic PHY framework.
>> Currently the API supports init(), deinit(), power_on, power_off() and
>> reset(). The framework provides a way to get a reference to a phy from the
>> device-tree.
>>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>> ---
>>   drivers/Kconfig          |  2 ++
>>   drivers/Makefile         |  1 +
>>   drivers/phy/Kconfig      | 32 ++++++++++++++++++++++++
>>   drivers/phy/Makefile     |  2 ++
>>   drivers/phy/phy-uclass.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
>>   include/dm/uclass-id.h   |  1 +
>>   include/generic-phy.h    | 36 +++++++++++++++++++++++++++
>>   7 files changed, 138 insertions(+)
>>   create mode 100644 drivers/phy/Kconfig
>>   create mode 100644 drivers/phy/Makefile
>>   create mode 100644 drivers/phy/phy-uclass.c
>>   create mode 100644 include/generic-phy.h
> I mostly have minor things at this point. Note that I've applied the
> patches from your series that I can, so please rebase on master.
>
> Also can you please:
> - check your version number (I think you might be up to v3 now)
> - include a change log with each patch (patman might help you)
> - rebase on u-boot-dm/master
>
> I'm sorry if this comes across as a bit pedantic. But you are creating
> a new uclass which I think will be quite important in U-Boot. I
> suspect it will be used by USB, perhaps Ethernet and other systems, so
> careful design and documentation is pretty important.
>
>> diff --git a/drivers/Kconfig b/drivers/Kconfig
>> index 0e5d97d..a90ceca 100644
>> --- a/drivers/Kconfig
>> +++ b/drivers/Kconfig
>> @@ -88,6 +88,8 @@ source "drivers/video/Kconfig"
>>
>>   source "drivers/watchdog/Kconfig"
>>
>> +source "drivers/phy/Kconfig"
>> +
>>   config PHYS_TO_BUS
>>          bool "Custom physical to bus address mapping"
>>          help
>> diff --git a/drivers/Makefile b/drivers/Makefile
>> index 5d8baa5..0be0624 100644
>> --- a/drivers/Makefile
>> +++ b/drivers/Makefile
>> @@ -7,6 +7,7 @@ obj-$(CONFIG_$(SPL_)CLK)        += clk/
>>   obj-$(CONFIG_$(SPL_)LED)       += led/
>>   obj-$(CONFIG_$(SPL_)PINCTRL)   += pinctrl/
>>   obj-$(CONFIG_$(SPL_)RAM)       += ram/
>> +obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy/
> Please maintain the ordering here
>
>>   ifdef CONFIG_SPL_BUILD
>>
>> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
>> new file mode 100644
>> index 0000000..d66c9e3
>> --- /dev/null
>> +++ b/drivers/phy/Kconfig
>> @@ -0,0 +1,32 @@
>> +
>> +menu "PHY Subsystem"
>> +
>> +config GENERIC_PHY
>> +       bool "PHY Core"
>> +       depends on DM
>> +       help
>> +         Generic PHY support.
>> +
>> +         This framework is designed to provide a generic interface for PHY
> PHY means?
>
>> +         devices. PHYs are commonly used for high speed interfaces such as
>> +         SATA or PCIe.
> Please write out SATA and PCIe in full at least once. This is help so
> we should not assume much.
>
>> +         The API provides functions to initialize/deinitialize the
>> +         phy, power on/off the phy, and reset the phy. It's meant to be as
> Is it PHY or phy?
>
>> +         compatible as possible with the equivalent framework found in the
>> +         linux kernel.
>> +
>> +config SPL_GENERIC_PHY
>> +       bool "PHY Core in SPL"
>> +       depends on DM
>> +       help
>> +         Generic PHY support in SPL.
>> +
>> +         This framework is designed to provide a generic interface for PHY
>> +         devices. PHYs are commonly used for high speed interfaces such as
>> +         SATA or PCIe.
>> +         The API provides functions to initialize/deinitialize the
>> +         phy, power on/off the phy, and reset the phy. It's meant to be as
>> +         compatible as possible with the equivalent framework found in the
>> +         linux kernel.
>> +
>> +endmenu
>> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
>> new file mode 100644
>> index 0000000..b29a8b9
>> --- /dev/null
>> +++ b/drivers/phy/Makefile
>> @@ -0,0 +1,2 @@
>> +obj-$(CONFIG_$(SPL_)GENERIC_PHY) += phy-uclass.o
>> +
>> diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
>> new file mode 100644
>> index 0000000..e15ed43
>> --- /dev/null
>> +++ b/drivers/phy/phy-uclass.c
>> @@ -0,0 +1,64 @@
>> +/*
>> + * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
>> + * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
>> + *
>> + * SPDX-License-Identifier:    GPL-2.0+
>> + */
>> +
>> +#include <common.h>
>> +#include <dm.h>
>> +#include <generic-phy.h>
>> +
>> +struct udevice *dm_generic_phy_get(struct udevice *parent, const char *string)
> Can you make this return an error code instead, and the device pointer
> as a parameter? This is how it is generally down in DM. See
> uclass_first_device() for example.
>
> Also I think you should drop the dm_ in the name. That prefix is used
> for core driver model functions, and DM versions of function that have
> a non-DM analogue.
>
> Also I think 'get' is too short. We normally use that for getting by
> index. How about generic_phy_get_by_name() or, phy_get_by_name() if
> you rename it?
>
>> +{
>> +       struct udevice *dev;
>> +
>> +       int rc = uclass_get_device_by_phandle(UCLASS_PHY, parent,
>> +                                          string, &dev);
>> +       if (rc) {
>> +               debug("unable to find generic_phy device (err: %d)\n", rc);
>> +               return ERR_PTR(rc);
>> +       }
>> +
>> +       return dev;
>> +}
>> +
>> +int generic_phy_init(struct udevice *dev)
>> +{
>> +       struct generic_phy_ops const *ops = dev->driver->ops;
> Please use a header-file macro to access ops. See clk-uclass.c for an example.
>
>> +
>> +       return (ops && ops->init) ? ops->init(dev) : 0;
> You don't need to check ops since it is invalid not to have one. So:
>
> return ops->init ? ops->init(dev) : 0;
>
>> +}
>> +
>> +int generic_phy_reset(struct udevice *dev)
>> +{
>> +       struct generic_phy_ops const *ops = dev->driver->ops;
>> +
>> +       return (ops && ops->reset) ? ops->reset(dev) : 0;
>> +}
>> +
>> +int generic_phy_exit(struct udevice *dev)
>> +{
>> +       struct generic_phy_ops const *ops = dev->driver->ops;
>> +
>> +       return (ops && ops->exit) ? ops->exit(dev) : 0;
>> +}
>> +
>> +int generic_phy_power_on(struct udevice *dev)
>> +{
>> +       struct generic_phy_ops const *ops = dev->driver->ops;
>> +
>> +       return (ops && ops->power_on) ? ops->power_on(dev) : 0;
>> +}
>> +
>> +int generic_phy_power_off(struct udevice *dev)
>> +{
>> +       struct generic_phy_ops const *ops = dev->driver->ops;
>> +
>> +       return (ops && ops->power_off) ? ops->power_off(dev) : 0;
>> +}
>> +
>> +UCLASS_DRIVER(generic_phy) = {
>> +       .id             = UCLASS_PHY,
> I would like the uclass name to match the header file and the uclass
> name. So if you are calling this generic_phy, then the uclass should
> be named this too. Same with the directory drivers/phy. If you want to
> rename it all to 'phy' then that is fine too.
IMO 'phy' would be the best option.
Unfortunately there are already tons of functions starting with 'phy_' 
and they're used for the ethernet phy. So I would propose to use 'phy' 
everywhere except for the API where 'generic_phy_' can be used to prefix 
the functions.
What do you think ?
>> +       .name           = "generic_phy",
>> +};
>> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
>> index 8c92d0b..9d34a32 100644
>> --- a/include/dm/uclass-id.h
>> +++ b/include/dm/uclass-id.h
>> @@ -83,6 +83,7 @@ enum uclass_id {
>>          UCLASS_VIDEO,           /* Video or LCD device */
>>          UCLASS_VIDEO_BRIDGE,    /* Video bridge, e.g. DisplayPort to LVDS */
>>          UCLASS_VIDEO_CONSOLE,   /* Text console driver for video device */
>> +       UCLASS_PHY,             /* generic PHY device */
> Physical layer device? Can you make your comment a bit more useful?
>
>>          UCLASS_COUNT,
>>          UCLASS_INVALID = -1,
>> diff --git a/include/generic-phy.h b/include/generic-phy.h
>> new file mode 100644
>> index 0000000..24475f0
>> --- /dev/null
>> +++ b/include/generic-phy.h
>> @@ -0,0 +1,36 @@
>> +/*
>> + * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
>> + * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
>> + *
>> + * SPDX-License-Identifier:    GPL-2.0+
>> + */
>> +
>> +#ifndef __GENERIC_PHY_H
>> +#define __GENERIC_PHY_H
>> +
>> +/*
>> + * struct udevice_ops - set of function pointers for phy operations
>> + * @init: operation to be performed for initializing phy (optionnal)
> optional
>
> Can you please put these comments in front of each function in struct
> generic_phy_ops as is done with other uclasses? Your description
> should explain what the operation does. For example, what happens for
> init()? Since the phy has already been probed, what should you not do
> in probe() but do in init()?
I'll work on documenting this. Too bad that linux also lacks this 
documentation.
The core idea is that probe() does not do much hardware-wise, it sets up 
everyting (irqs, mapping, clocks) but the actual initialization of the 
hardware is done in init().

Jean-Jacques

>> + * @exit: operation to be performed while exiting (optionnal)
> exiting what? Please add some more detail.
>
>> + * @reset: reset the phy (optionnal).
>> + * @power_on: powering on the phy (optionnal)
>> + * @power_off: powering off the phy (optionnal)
> Are these optional because the phy might be powered on during one of
> the other operations? Otherwise it doesn't seem helpful to have the
> thing not ever power on.
>
>> + */
>> +struct generic_phy_ops {
>> +       int     (*init)(struct udevice *phy);
>> +       int     (*exit)(struct udevice *phy);
>> +       int     (*reset)(struct udevice *phy);
>> +       int     (*power_on)(struct udevice *phy);
>> +       int     (*power_off)(struct udevice *phy);
>> +};
>> +
>> +
>> +int generic_phy_init(struct udevice *phy);
> Here you need to repeat your comments from above - see other uclasses
> for an example.
>
>> +int generic_phy_reset(struct udevice *phy);
>> +int generic_phy_exit(struct udevice *phy);
>> +int generic_phy_power_on(struct udevice *phy);
>> +int generic_phy_power_off(struct udevice *phy);
>> +
>> +struct udevice *dm_generic_phy_get(struct udevice *parent, const char *string);
> This function need a comment. Also instead of string can you think of
> a descriptive name, e.g. phy_name?
>
>> +
>> +#endif /*__GENERIC_PHY_H */
>> --
>> 1.9.1
>>
> Regards,
> Simon
>

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

* [U-Boot] [PATCH 03/11] drivers: phy: add generic PHY framework
  2017-04-18 13:32     ` Jean-Jacques Hiblot
@ 2017-04-19  0:12       ` Simon Glass
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-04-19  0:12 UTC (permalink / raw)
  To: u-boot

Hi

,[..]

>>> +UCLASS_DRIVER(generic_phy) = {
>>> +       .id             = UCLASS_PHY,
>>
>> I would like the uclass name to match the header file and the uclass
>> name. So if you are calling this generic_phy, then the uclass should
>> be named this too. Same with the directory drivers/phy. If you want to
>> rename it all to 'phy' then that is fine too.
>
> IMO 'phy' would be the best option.
> Unfortunately there are already tons of functions starting with 'phy_' and
> they're used for the ethernet phy. So I would propose to use 'phy'
> everywhere except for the API where 'generic_phy_' can be used to prefix the
> functions.
> What do you think ?

Sounds good. That would be easy to clean up later once Ethernet Phy is done.

>
>>> +       .name           = "generic_phy",
>>> +};
>>> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
>>> index 8c92d0b..9d34a32 100644
>>> --- a/include/dm/uclass-id.h
>>> +++ b/include/dm/uclass-id.h
>>> @@ -83,6 +83,7 @@ enum uclass_id {
>>>          UCLASS_VIDEO,           /* Video or LCD device */
>>>          UCLASS_VIDEO_BRIDGE,    /* Video bridge, e.g. DisplayPort to
>>> LVDS */
>>>          UCLASS_VIDEO_CONSOLE,   /* Text console driver for video device
>>> */
>>> +       UCLASS_PHY,             /* generic PHY device */
>>
>> Physical layer device? Can you make your comment a bit more useful?
>>
>>>          UCLASS_COUNT,
>>>          UCLASS_INVALID = -1,
>>> diff --git a/include/generic-phy.h b/include/generic-phy.h
>>> new file mode 100644
>>> index 0000000..24475f0
>>> --- /dev/null
>>> +++ b/include/generic-phy.h
>>> @@ -0,0 +1,36 @@
>>> +/*
>>> + * Copyright (C) 2017 Texas Instruments Incorporated -
>>> http://www.ti.com/
>>> + * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
>>> + *
>>> + * SPDX-License-Identifier:    GPL-2.0+
>>> + */
>>> +
>>> +#ifndef __GENERIC_PHY_H
>>> +#define __GENERIC_PHY_H
>>> +
>>> +/*
>>> + * struct udevice_ops - set of function pointers for phy operations
>>> + * @init: operation to be performed for initializing phy (optionnal)
>>
>> optional
>>
>> Can you please put these comments in front of each function in struct
>> generic_phy_ops as is done with other uclasses? Your description
>> should explain what the operation does. For example, what happens for
>> init()? Since the phy has already been probed, what should you not do
>> in probe() but do in init()?
>
> I'll work on documenting this. Too bad that linux also lacks this
> documentation.
> The core idea is that probe() does not do much hardware-wise, it sets up
> everyting (irqs, mapping, clocks) but the actual initialization of the
> hardware is done in init().

OK sounds good.

Regards,
Simon

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

end of thread, other threads:[~2017-04-19  0:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-14 11:07 [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot
2017-04-14 11:07 ` [U-Boot] [PATCH 01/11] arm: omap: sata: move enable sata clocks to enable_basic_clocks() Jean-Jacques Hiblot
2017-04-14 11:08 ` [U-Boot] [PATCH 02/11] arm: omap: sata: compile out board-level sata code when CONFIG_DM_SCSI is defined Jean-Jacques Hiblot
2017-04-14 11:08 ` [U-Boot] [PATCH 03/11] drivers: phy: add generic PHY framework Jean-Jacques Hiblot
2017-04-15 17:10   ` Simon Glass
2017-04-18 13:32     ` Jean-Jacques Hiblot
2017-04-19  0:12       ` Simon Glass
2017-04-14 11:08 ` [U-Boot] [PATCH 04/11] dm: test: Add tests for the generic PHY uclass Jean-Jacques Hiblot
2017-04-15 17:10   ` Simon Glass
2017-04-14 11:08 ` [U-Boot] [PATCH 05/11] drivers: phy: add PIPE3 phy driver Jean-Jacques Hiblot
2017-04-14 11:08 ` [U-Boot] [PATCH 06/11] dra7: dtsi: mark ocp2scp bus compatible with "simple-bus" Jean-Jacques Hiblot
2017-04-14 20:06   ` Tom Rini
2017-04-14 11:08 ` [U-Boot] [PATCH 07/11] drivers: block: dwc_ahci: Implement a driver for Synopsys DWC sata device Jean-Jacques Hiblot
2017-04-14 11:08 ` [U-Boot] [PATCH 08/11] scsi: make the LUN a parameter of scsi_detect_dev() Jean-Jacques Hiblot
2017-04-14 11:08 ` [U-Boot] [PATCH 09/11] scsi: move the partition initialization out of the scsi detection Jean-Jacques Hiblot
2017-04-14 11:08 ` [U-Boot] [PATCH 10/11] dm: scsi: fix divide-by-0 error in scsi_scan() Jean-Jacques Hiblot
2017-04-14 11:08 ` [U-Boot] [PATCH 11/11] defconfig: dra7xx_evm: enable CONFIG_BLK and disk driver model for SCSI Jean-Jacques Hiblot
2017-04-14 11:13 ` [U-Boot] [PATCH 00/11] OMAP: Move SATA to use block driver model Jean-Jacques Hiblot

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.