Skip to contentSkip to conversation

Add SATA support for TI OMAP5 and DRA7 SoCs

RFC PATCH In review Roger Quadros 6 participants 42 messages Sep 19, 2013 – Feb 7, 2014

Subsystems (11)
lore
Share & tools
lore
#0 lore raw

cover Add SATA support for TI OMAP5 and DRA7 SoCs

Hi,

This series adds SATA controller support for the Texas Instruments OMAP5 and DRA7 platforms.

As the SATA controller is compatible with AHCI, we use the ahci_platform driver and just provide the glue logic.

The AHCI controller is enclosed within a TI specific Wrapper that controls the controller power mode. Patch 9 adds a driver for this wrapper.

The controller is linked to a SATA (PIPE3) PHY, which needs to be clocked and powered up before it can be used. We do that with the help of the generic PHY framework [2] in Patch 8.

Patches 1 to 7 adapt the the PHY driver to the Generic PHY framework.

Patches 9 to 15 provide platform adaptation code for OMAP5 and DRA7.

Patches are based on v3.12-rc1 with the following patches on top
[1] - omap control usb multiple instance support

      http://article.gmane.org/gmane.linux.ports.arm.kernel/267587
      git://github.com/rogerq/linux.git usb-control-module

[2] - Generic PHY framework
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing

[3] - Clock DT support

      git://gitorious.org/~kristo/omap-pm/omap-pm-work.git mainline-3.11-rc3-omap-dt-clks-v5

[4] - PHY framework mis cleanup

      https://lkml.org/lkml/2013/9/2/313

NOTE: [2], [3] and [4] will cause merge conflicts and need to be resolved manually. A merged tree is available for reference/testing at

git://github.com/rogerq/linux.git ti-3.12-sata

Tested on omap5-uevm and dra7-evm with Gen2 SATA hard drive.

Known issues:
- Gen3 SATA SSD does not work due to some issue with PHY speed negotiation.

cheers,
-roger

---
Balaji T K (3):
ata: ahci_platform: Manage SATA PHY
arm: dts: omap5: add sata node
arm: dts: dra7: add sata node

Benoit Cousson (1):
arm: omap5: hwmod: add missing ocp2scp hwmod data

Keshava Munegowda (1):
ARM: omap5: hwmod: Add ocp2scp3 and sata hwmods

Kishon Vijay Abraham I (2):
phy: rename struct omap_control_usb to struct omap_control_phy
phy: omap-pipe3: use generic clock names

Nikhil Devshatwar (1):
ARM: DRA7: hwmod: Add ocp2scp3 and sata hwmods

Roger Quadros (7):
phy: omap-control: Update DT binding information
ARM: dts: omap5: Add clocks to usb3_phy node
phy: omap-pipe3: Add SATA DPLL support
phy: omap-pipe3: update compatibility string and DT binding
ARM: dts: omap5: Update usb3phy node
ata: ti_sata: Add Texas Instruments SATA Wrapper driver
ARM: dts: omap5: add ocp2scp1 address resource

 .../devicetree/bindings/ata/ahci-platform.txt      |    2 +-
 Documentation/devicetree/bindings/ata/ti-sata.txt  |   31 ++
 Documentation/devicetree/bindings/phy/omap-phy.txt |   26 ++-
 Documentation/devicetree/bindings/usb/omap-usb.txt |   23 --
 arch/arm/boot/dts/dra7.dtsi                        |   49 ++++
 arch/arm/boot/dts/omap5.dtsi                       |   56 ++++-
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c         |  117 ++++++++
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c          |   40 +++-
 drivers/ata/Kconfig                                |    8 +
 drivers/ata/Makefile                               |    1 +
 drivers/ata/ahci.h                                 |    2 +
 drivers/ata/ahci_platform.c                        |   31 ++-
 drivers/ata/sata_ti.c                              |  160 +++++++++++
 drivers/phy/Kconfig                                |   14 +-
 drivers/phy/Makefile                               |    1 +
 drivers/phy/phy-omap-control.c                     |  300 ++++++++++++++++++++
 drivers/phy/phy-omap-pipe3.c                       |  157 ++++++-----
 drivers/phy/phy-omap-usb2.c                        |    9 +-
 drivers/usb/musb/omap2430.c                        |    2 +-
 drivers/usb/phy/Kconfig                            |   10 -
 drivers/usb/phy/Makefile                           |    1 -
 drivers/usb/phy/phy-omap-control.c                 |  300 --------------------
 include/linux/phy/omap_control_phy.h               |   83 ++++++
 include/linux/phy/omap_pipe3.h                     |    6 +
 include/linux/usb/omap_control_usb.h               |   83 ------
 25 files changed, 1013 insertions(+), 499 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/ti-sata.txt
 create mode 100644 drivers/ata/sata_ti.c
 create mode 100644 drivers/phy/phy-omap-control.c
 delete mode 100644 drivers/usb/phy/phy-omap-control.c
 create mode 100644 include/linux/phy/omap_control_phy.h
 delete mode 100644 include/linux/usb/omap_control_usb.h
Signature · 1 line
1.7.4.1
#1 lore raw

RFC PATCH 1/15 phy: rename struct omap_control_usb to struct omap_control_phy

From: Kishon Vijay Abraham I <[email protected]>

Rename struct omap_control_usb to struct omap_control_phy since it can be used to control PHY of USB, SATA and PCIE. Also move the driver and include files under *phy* and made the corresponding changes in the users of phy-omap-control.

---
 drivers/phy/Kconfig                  |   14 ++-
 drivers/phy/Makefile                 |    1 +
 drivers/phy/phy-omap-control.c       |  300 ++++++++++++++++++++++++++++++++++
 drivers/phy/phy-omap-pipe3.c         |    8 +-
 drivers/phy/phy-omap-usb2.c          |    9 +-
 drivers/usb/musb/omap2430.c          |    2 +-
 drivers/usb/phy/Kconfig              |   10 -
 drivers/usb/phy/Makefile             |    1 -
 drivers/usb/phy/phy-omap-control.c   |  300 ----------------------------------
 include/linux/phy/omap_control_phy.h |   83 ++++++++++
 include/linux/usb/omap_control_usb.h |   83 ----------
 11 files changed, 406 insertions(+), 405 deletions(-)
 create mode 100644 drivers/phy/phy-omap-control.c
 delete mode 100644 drivers/usb/phy/phy-omap-control.c
 create mode 100644 include/linux/phy/omap_control_phy.h
 delete mode 100644 include/linux/usb/omap_control_usb.h
drivers/phy/Kconfig +12 -2
index 5c2e7a0..7155f56 100644
@@ -15,12 +15,22 @@ config GENERIC_PHY
 	  phy users can obtain reference to the PHY. All the users of this
 	  framework should select this config.
 
+config OMAP_CONTROL_PHY
+	tristate "OMAP CONTROL PHY Driver"
+	help
+	  Enable this to add support for the PHY part present in the control
+	  module. This driver has API to power on the USB2 PHY and to write to
+	  the mailbox. The mailbox is present only in omap4 and the register to
+	  power on the USB2 PHY is present in OMAP4 and OMAP5. OMAP5 has an
+	  additional register to power on USB3 PHY/SATA PHY/PCIE PHY
+	  (PIPE3 PHY).
+
 config OMAP_USB2
 	tristate "OMAP USB2 PHY Driver"
 	depends on ARCH_OMAP2PLUS
 	select GENERIC_PHY
 	select USB_PHY
-	select OMAP_CONTROL_USB
+	select OMAP_CONTROL_PHY
 	help
 	  Enable this to support the transceiver that is part of SOC. This
 	  driver takes care of all the PHY functionality apart from comparator.
@@ -30,7 +40,7 @@ config OMAP_USB2
 config OMAP_PIPE3
 	tristate "OMAP PIPE3 PHY Driver"
 	select GENERIC_PHY
-	select OMAP_CONTROL_USB
+	select OMAP_CONTROL_PHY
 	help
 	  Enable this to support the PIPE3 PHY that is part of SOC. This
 	  driver takes care of all the PHY functionality apart from comparator.
drivers/phy/Makefile +1 -0
index 48bf9f2..f0127f6 100644
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)	+= phy-core.o
+obj-$(CONFIG_OMAP_CONTROL_PHY)	+= phy-omap-control.o
 obj-$(CONFIG_OMAP_USB2)		+= phy-omap-usb2.o
 obj-$(CONFIG_OMAP_PIPE3)	+= phy-omap-pipe3.o
 obj-$(CONFIG_TWL4030_USB)	+= phy-twl4030-usb.o
drivers/phy/phy-omap-control.c new file +300 -0

300 lines not on this page · raw message

drivers/phy/phy-omap-pipe3.c +4 -4
index ee9a901..63de0f8 100644
@@ -26,7 +26,7 @@
 #include <linux/err.h>
 #include <linux/pm_runtime.h>
 #include <linux/delay.h>
-#include <linux/usb/omap_control_usb.h>
+#include <linux/phy/omap_control_phy.h>
 #include <linux/of_platform.h>
 
 #define	PLL_STATUS		0x00000004
@@ -101,7 +101,7 @@ static int omap_pipe3_power_off(struct phy *x)
 		udelay(1);
 	} while (--timeout);
 
-	omap_control_usb_phy_power(phy->control_dev, 0);
+	omap_control_phy_power(phy->control_dev, 0);
 
 	return 0;
 }
@@ -194,7 +194,7 @@ static int omap_pipe3_init(struct phy *x)
 	if (ret)
 		return ret;
 
-	omap_control_usb_phy_power(phy->control_dev, 1);
+	omap_control_phy_power(phy->control_dev, 1);
 
 	return 0;
 }
@@ -270,7 +270,7 @@ static int omap_pipe3_probe(struct platform_device *pdev)
 
 	phy->control_dev = &control_pdev->dev;
 
-	omap_control_usb_phy_power(phy->control_dev, 0);
+	omap_control_phy_power(phy->control_dev, 0);
 
 	platform_set_drvdata(pdev, phy);
 	pm_runtime_enable(phy->dev);
drivers/phy/phy-omap-usb2.c +5 -4
index 332178d..9c231b8 100644
@@ -27,7 +27,8 @@
 #include <linux/err.h>
 #include <linux/pm_runtime.h>
 #include <linux/delay.h>
-#include <linux/usb/omap_control_usb.h>
+#include <linux/phy/omap_control_phy.h>
+#include <linux/phy/phy.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 
@@ -102,7 +103,7 @@ static int omap_usb_power_off(struct phy *x)
 {
 	struct omap_usb *phy = phy_get_drvdata(x);
 
-	omap_control_usb_phy_power(phy->control_dev, 0);
+	omap_control_phy_power(phy->control_dev, 0);
 
 	return 0;
 }
@@ -111,7 +112,7 @@ static int omap_usb_power_on(struct phy *x)
 {
 	struct omap_usb *phy = phy_get_drvdata(x);
 
-	omap_control_usb_phy_power(phy->control_dev, 1);
+	omap_control_phy_power(phy->control_dev, 1);
 
 	return 0;
 }
@@ -172,7 +173,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
 	phy->control_dev = &control_pdev->dev;
 
-	omap_control_usb_phy_power(phy->control_dev, 0);
+	omap_control_phy_power(phy->control_dev, 0);
 
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
drivers/usb/musb/omap2430.c +1 -1
index 9eab645..4f5ef0b 100644
@@ -37,7 +37,7 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/usb/musb-omap.h>
-#include <linux/usb/omap_control_usb.h>
+#include <linux/phy/omap_control_phy.h>
 #include <linux/of_platform.h>
 
 #include "musb_core.h"
drivers/usb/phy/Kconfig +0 -10
index 0210e03..f517d49 100644
@@ -56,16 +56,6 @@ config NOP_USB_XCEIV
 	  built-in with usb ip or which are autonomous and doesn't require any
 	  phy programming such as ISP1x04 etc.
 
-config OMAP_CONTROL_USB
-	tristate "OMAP CONTROL USB Driver"
-	depends on ARCH_OMAP2PLUS || COMPILE_TEST
-	help
-	  Enable this to add support for the USB part present in the control
-	  module. This driver has API to power on the USB2 PHY and to write to
-	  the mailbox. The mailbox is present only in omap4 and the register to
-	  power on the USB2 PHY is present in OMAP4 and OMAP5. OMAP5 has an
-	  additional register to power on USB3 PHY.
-
 config AM335X_CONTROL_USB
 	tristate
 
drivers/usb/phy/Makefile +0 -1
index fa80661..b356953 100644
@@ -12,7 +12,6 @@ obj-$(CONFIG_FSL_USB2_OTG)		+= phy-fsl-usb2.o
 obj-$(CONFIG_ISP1301_OMAP)		+= phy-isp1301-omap.o
 obj-$(CONFIG_MV_U3D_PHY)		+= phy-mv-u3d-usb.o
 obj-$(CONFIG_NOP_USB_XCEIV)		+= phy-generic.o
-obj-$(CONFIG_OMAP_CONTROL_USB)		+= phy-omap-control.o
 obj-$(CONFIG_AM335X_CONTROL_USB)	+= phy-am335x-control.o
 obj-$(CONFIG_AM335X_PHY_USB)		+= phy-am335x.o
 obj-$(CONFIG_SAMSUNG_USBPHY)		+= phy-samsung-usb.o
drivers/usb/phy/phy-omap-control.c deleted +0 -300

300 lines not on this page · raw message

include/linux/phy/omap_control_phy.h new file +83 -0

83 lines not on this page · raw message

include/linux/usb/omap_control_usb.h deleted +0 -83

83 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

Re: [RFC PATCH 01/15] phy: rename struct omap_control_usb to struct omap_control_phy

Quoted 18 lines · Roger Quadros

From: Kishon Vijay Abraham I <[email protected]>

Rename struct omap_control_usb to struct omap_control_phy since it can be used to control PHY of USB, SATA and PCIE. Also move the driver and include files under *phy* and made the corresponding changes in the users of phy-omap-control.

---
 drivers/phy/Kconfig                  |   14 ++-
 drivers/phy/Makefile                 |    1 +
 drivers/phy/phy-omap-control.c       |  300 ++++++++++++++++++++++++++++++++++
 drivers/phy/phy-omap-pipe3.c         |    8 +-
 drivers/phy/phy-omap-usb2.c          |    9 +-
 drivers/usb/musb/omap2430.c          |    2 +-
 drivers/usb/phy/Kconfig              |   10 -
 drivers/usb/phy/Makefile             |    1 -
Quoted 8 lines
 drivers/usb/phy/phy-omap-control.c   |  300 ----------------------------------
 include/linux/phy/omap_control_phy.h |   83 ++++++++++
 include/linux/usb/omap_control_usb.h |   83 ----------
 11 files changed, 406 insertions(+), 405 deletions(-)
 create mode 100644 drivers/phy/phy-omap-control.c
 delete mode 100644 drivers/usb/phy/phy-omap-control.c
 create mode 100644 include/linux/phy/omap_control_phy.h
 delete mode 100644 include/linux/usb/omap_control_usb.h

In case you do another version of this set, please use "git format-patch -M", which will detect renames and hence make the review much easier.

Daniel

#3 lore raw

RFC PATCH 2/15 phy: omap-control: Update DT binding information

In reply to Roger Quadros

Update compatibility string and DT binding document.

---
 Documentation/devicetree/bindings/phy/omap-phy.txt |   23 ++++++++++++++++++++
 Documentation/devicetree/bindings/usb/omap-usb.txt |   23 --------------------
 2 files changed, 23 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/phy/omap-phy.txt +23 -0
index 2c485ee..cf45b01 100644
@@ -1,5 +1,28 @@
 OMAP PHY: DT DOCUMENTATION FOR PHYs in OMAP PLATFORM
 
+OMAP CONTROL PHY
+
+Required properties:
+ - compatible: Should be one of
+ "ti,control-phy-otghs" - if it has otghs_control mailbox register as on OMAP4.
+ "ti,control-phy-usb2" - if it has Power down bit in control_dev_conf register
+			e.g. USB2_PHY on OMAP5.
+ "ti,control-phy-pipe3" - if it has DPLL and individual Rx & Tx power control
+			e.g. USB3 PHY and SATA PHY on OMAP5.
+ "ti,control-phy-dra7usb2" - if it has power down register like USB2 PHY on
+			DRA7 platform.
+ - reg : Address and length of the register set for the device. It contains
+   the address of "otghs_control" for control-phy-otghs or "power" register
+   for other types.
+ - reg-names: should be "otghs_control" control-phy-otghs and "power" for
+   other types.
+
+omap_control_otghs: omap-control-phy at 4a002300 {
+	compatible = "ti,control-phy-otghs";
+	reg = <0x4a00233c 0x4>;
+	reg-names = "otghs_control";
+};
+
 OMAP USB2 PHY
 
 Required properties:
Documentation/devicetree/bindings/usb/omap-usb.txt +0 -23
index b2bf7b3..4aa8eab 100644
@@ -79,26 +79,3 @@ omap_dwc3 {
 	clock-names = "usb_otg_ss_refclk960m";
 	ranges;
 };
-
-OMAP CONTROL USB
-
-Required properties:
- - compatible: Should be one of
- "ti,control-phy-otghs" - if it has otghs_control mailbox register as on OMAP4.
- "ti,control-phy-usb2" - if it has Power down bit in control_dev_conf register
-			e.g. USB2_PHY on OMAP5.
- "ti,control-phy-pipe3" - if it has DPLL and individual Rx & Tx power control
-			e.g. USB3 PHY and SATA PHY on OMAP5.
- "ti,control-phy-dra7usb2" - if it has power down register like USB2 PHY on
-			DRA7 platform.
- - reg : Address and length of the register set for the device. It contains
-   the address of "otghs_control" for control-phy-otghs or "power" register
-   for other types.
- - reg-names: should be "otghs_control" control-phy-otghs and "power" for
-   other types.
-
-omap_control_usb: omap-control-usb at 4a002300 {
-	compatible = "ti,control-phy-otghs";
-	reg = <0x4a00233c 0x4>;
-	reg-names = "otghs_control";
-};
Signature · 1 line
1.7.4.1
#4 lore raw

RFC PATCH 3/15 ARM: dts: omap5: Add clocks to usb3_phy node

In reply to Roger Quadros

The pipe3-phy driver expects certain named clocks. Provide the necessary clocks.

---
 arch/arm/boot/dts/omap5.dtsi |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap5.dtsi +2 -0
index 576b06a..97f361a 100644
@@ -677,6 +677,8 @@
 				      <0x4a084c00 0x40>;
 				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
 				ctrl-module = <&omap_control_usb3phy>;
+				clocks = <&usb_phy_cm_clk32k>, <&sys_clkin>;
+				clock-names = "wkupclk", "sysclk";
 				#phy-cells = <0>;
 			};
 		};
Signature · 1 line
1.7.4.1
#5 lore raw

RFC PATCH 4/15 phy: omap-pipe3: use generic clock names

In reply to Roger Quadros

From: Kishon Vijay Abraham I <[email protected]>

As this driver is no longer USB specific use generic clock names.

[Roger Q]
- Fix PLL_SD_SHIFT from 9 to 10
- As optclk and wkupclk may not be always required, don't bail out if they aren't available.

---
 drivers/phy/phy-omap-pipe3.c |   71 +++++++++++++++++++++++-------------------
 1 files changed, 39 insertions(+), 32 deletions(-)
drivers/phy/phy-omap-pipe3.c +39 -32
index 63de0f8..807ab8a 100644
@@ -37,15 +37,15 @@
 #define	PLL_CONFIGURATION4	0x00000020
 
 #define	PLL_REGM_MASK		0x001FFE00
-#define	PLL_REGM_SHIFT		0x9
+#define	PLL_REGM_SHIFT		9
 #define	PLL_REGM_F_MASK		0x0003FFFF
-#define	PLL_REGM_F_SHIFT	0x0
+#define	PLL_REGM_F_SHIFT	0
 #define	PLL_REGN_MASK		0x000001FE
-#define	PLL_REGN_SHIFT		0x1
+#define	PLL_REGN_SHIFT		1
 #define	PLL_SELFREQDCO_MASK	0x0000000E
-#define	PLL_SELFREQDCO_SHIFT	0x1
+#define	PLL_SELFREQDCO_SHIFT	1
 #define	PLL_SD_MASK		0x0003FC00
-#define	PLL_SD_SHIFT		0x9
+#define	PLL_SD_SHIFT		10
 #define	SET_PLL_GO		0x1
 #define	PLL_TICOPWDN		0x10000
 #define	PLL_LOCK		0x2
@@ -232,23 +232,21 @@ static int omap_pipe3_probe(struct platform_device *pdev)
 
 	phy->dev		= &pdev->dev;
 
-	phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
-	if (IS_ERR(phy->wkupclk)) {
-		dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n");
-		return PTR_ERR(phy->wkupclk);
-	}
-	clk_prepare(phy->wkupclk);
+	phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");
+	if (IS_ERR(phy->wkupclk))
+		dev_dbg(&pdev->dev, "unable to get wkupclk\n");
+	else
+		clk_prepare(phy->wkupclk);
 
-	phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m");
-	if (IS_ERR(phy->optclk)) {
-		dev_err(&pdev->dev, "unable to get usb_otg_ss_refclk960m\n");
-		return PTR_ERR(phy->optclk);
-	}
-	clk_prepare(phy->optclk);
+	phy->optclk = devm_clk_get(phy->dev, "optclk");
+	if (IS_ERR(phy->optclk))
+		dev_dbg(&pdev->dev, "unable to get optclk\n");
+	else
+		clk_prepare(phy->optclk);
 
-	phy->sys_clk = devm_clk_get(phy->dev, "sys_clkin");
+	phy->sys_clk = devm_clk_get(phy->dev, "sysclk");
 	if (IS_ERR(phy->sys_clk)) {
-		pr_err("%s: unable to get sys_clkin\n", __func__);
+		dev_err(&pdev->dev, "unable to get sysclk\n");
 		return -EINVAL;
 	}
 
@@ -290,8 +288,10 @@ static int omap_pipe3_remove(struct platform_device *pdev)
 {
 	struct omap_pipe3 *phy = platform_get_drvdata(pdev);
 
-	clk_unprepare(phy->wkupclk);
-	clk_unprepare(phy->optclk);
+	if (!IS_ERR(phy->wkupclk))
+		clk_unprepare(phy->wkupclk);
+	if (!IS_ERR(phy->optclk))
+		clk_unprepare(phy->optclk);
 	if (!pm_runtime_suspended(&pdev->dev))
 		pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
@@ -305,8 +305,10 @@ static int omap_pipe3_runtime_suspend(struct device *dev)
 {
 	struct omap_pipe3	*phy = dev_get_drvdata(dev);
 
-	clk_disable(phy->wkupclk);
-	clk_disable(phy->optclk);
+	if (!IS_ERR(phy->wkupclk))
+		clk_disable(phy->wkupclk);
+	if (!IS_ERR(phy->optclk))
+		clk_disable(phy->optclk);
 
 	return 0;
 }
@@ -316,22 +318,27 @@ static int omap_pipe3_runtime_resume(struct device *dev)
 	u32 ret = 0;
 	struct omap_pipe3	*phy = dev_get_drvdata(dev);
 
-	ret = clk_enable(phy->optclk);
-	if (ret) {
-		dev_err(phy->dev, "Failed to enable optclk %d\n", ret);
-		goto err1;
+	if (!IS_ERR(phy->optclk)) {
+		ret = clk_enable(phy->optclk);
+		if (ret) {
+			dev_err(phy->dev, "Failed to enable optclk %d\n", ret);
+			goto err1;
+		}
 	}
 
-	ret = clk_enable(phy->wkupclk);
-	if (ret) {
-		dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret);
-		goto err2;
+	if (!IS_ERR(phy->wkupclk)) {
+		ret = clk_enable(phy->wkupclk);
+		if (ret) {
+			dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret);
+			goto err2;
+		}
 	}
 
 	return 0;
 
 err2:
-	clk_disable(phy->optclk);
+	if (!IS_ERR(phy->optclk))
+		clk_disable(phy->optclk);
 
 err1:
 	return ret;
Signature · 1 line
1.7.4.1
#6 lore raw

RFC PATCH 5/15 phy: omap-pipe3: Add SATA DPLL support

In reply to Roger Quadros

USB and SATA DPLLs need different settings. Provide the SATA DPLL settings and use the proper DPLL settings based on device tree compatible_id.

---
 drivers/phy/phy-omap-pipe3.c   |   82 ++++++++++++++++++++++++++--------------
 include/linux/phy/omap_pipe3.h |    6 +++
 2 files changed, 60 insertions(+), 28 deletions(-)
drivers/phy/phy-omap-pipe3.c +54 -28
index 807ab8a..19d1664 100644
@@ -58,29 +58,41 @@
  */
 # define PLL_IDLE_TIME  100;
 
-struct pipe3_dpll_map {
-	unsigned long rate;
-	struct pipe3_dpll_params params;
-};
-
-static struct pipe3_dpll_map dpll_map[] = {
+static struct pipe3_dpll_map dpll_map_usb[] = {
 	{12000000, {1250, 5, 4, 20, 0} },	/* 12 MHz */
 	{16800000, {3125, 20, 4, 20, 0} },	/* 16.8 MHz */
 	{19200000, {1172, 8, 4, 20, 65537} },	/* 19.2 MHz */
 	{20000000, {1000, 7, 4, 10, 0} },	/* 20 MHz */
 	{26000000, {1250, 12, 4, 20, 0} },	/* 26 MHz */
 	{38400000, {3125, 47, 4, 20, 92843} },	/* 38.4 MHz */
+	{ },					/* Terminator */
+};
+
+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 struct pipe3_dpll_params *omap_pipe3_get_dpll_params(unsigned long rate)
+static struct pipe3_dpll_params *omap_pipe3_get_dpll_params(struct omap_pipe3
+									*pipe3)
 {
-	int i;
+	unsigned long rate;
+	struct pipe3_dpll_map *dpll_map = pipe3->dpll_map;
 
-	for (i = 0; i < ARRAY_SIZE(dpll_map); i++) {
-		if (rate == dpll_map[i].rate)
-			return &dpll_map[i].params;
+	rate = clk_get_rate(pipe3->sys_clk);
+
+	for (; dpll_map->rate; dpll_map++) {
+		if (rate == dpll_map->rate)
+			return &dpll_map->params;
 	}
 
+	dev_err(pipe3->dev,
+		  "No DPLL configuration for %lu Hz SYS CLK\n", rate);
 	return 0;
 }
 
@@ -148,10 +160,8 @@ static int omap_pipe3_dpll_lock(struct omap_pipe3 *phy)
 	struct pipe3_dpll_params *dpll_params;
 
 	rate = clk_get_rate(phy->sys_clk);
-	dpll_params = omap_pipe3_get_dpll_params(rate);
+	dpll_params = omap_pipe3_get_dpll_params(phy);
 	if (!dpll_params) {
-		dev_err(phy->dev,
-			  "No DPLL configuration for %lu Hz SYS CLK\n", rate);
 		return -EINVAL;
 	}
 
@@ -206,6 +216,25 @@ static struct phy_ops ops = {
 	.owner		= THIS_MODULE,
 };
 
+#ifdef CONFIG_OF
+static const struct of_device_id omap_pipe3_id_table[] = {
+	{
+		.compatible = "ti,omap-pipe3",
+		.data = dpll_map_usb,
+	},
+	{
+		.compatible = "ti,omap-sata",
+		.data = dpll_map_sata,
+	},
+	{
+		.compatible = "ti,omap-usb3",
+		.data = dpll_map_usb,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, omap_pipe3_id_table);
+#endif
+
 static int omap_pipe3_probe(struct platform_device *pdev)
 {
 	struct omap_pipe3 *phy;
@@ -215,9 +244,7 @@ static int omap_pipe3_probe(struct platform_device *pdev)
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *control_node;
 	struct platform_device *control_pdev;
-
-	if (!node)
-		return -EINVAL;
+	const struct of_device_id *match;
 
 	phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy) {
@@ -225,6 +252,16 @@ static int omap_pipe3_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	match = of_match_device(of_match_ptr(omap_pipe3_id_table), &pdev->dev);
+	if (!match)
+		return -EINVAL;
+
+	phy->dpll_map = (struct pipe3_dpll_map *)match->data;
+	if (!phy->dpll_map) {
+		dev_err(&pdev->dev, "no dpll data\n");
+		return -EINVAL;
+	}
+
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pll_ctrl");
 	phy->pll_ctrl_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(phy->pll_ctrl_base))
@@ -354,17 +391,6 @@ static const struct dev_pm_ops omap_pipe3_pm_ops = {
 #define DEV_PM_OPS     NULL
 #endif
 
-#ifdef CONFIG_OF
-static const struct of_device_id omap_pipe3_id_table[] = {
-	{ .compatible = "ti,omap-pipe3" },
-	{ .compatible = "ti,omap-sata" },
-	{ .compatible = "ti,omap-pcie" },
-	{ .compatible = "ti,omap-usb3" },
-	{}
-};
-MODULE_DEVICE_TABLE(of, omap_pipe3_id_table);
-#endif
-
 static struct platform_driver omap_pipe3_driver = {
 	.probe		= omap_pipe3_probe,
 	.remove		= omap_pipe3_remove,
include/linux/phy/omap_pipe3.h +6 -0
index 7329056..86825ca 100644
@@ -29,6 +29,11 @@ struct pipe3_dpll_params {
 	u32	mf;
 };
 
+struct pipe3_dpll_map {
+	unsigned long rate;
+	struct pipe3_dpll_params params;
+};
+
 struct omap_pipe3 {
 	void __iomem		*pll_ctrl_base;
 	struct device		*dev;
@@ -36,6 +41,7 @@ struct omap_pipe3 {
 	struct clk		*wkupclk;
 	struct clk		*sys_clk;
 	struct clk		*optclk;
+	struct pipe3_dpll_map	*dpll_map;
 };
 
 static inline u32 omap_pipe3_readl(void __iomem *addr, unsigned offset)
Signature · 1 line
1.7.4.1
#7 lore raw

RFC PATCH 6/15 phy: omap-pipe3: update compatibility string and DT binding

In reply to Roger Quadros

Improve compatibility string format to "ti,phy-pipe3-<type>" where <type> can be "usb3" or "sata". Remove "pcie" type as it is not yet supported due to missing DPLL data.

---
 Documentation/devicetree/bindings/phy/omap-phy.txt |    3 +--
 drivers/phy/phy-omap-pipe3.c                       |    8 ++------
 2 files changed, 3 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/phy/omap-phy.txt +1 -2
index cf45b01..8e09ad3 100644
@@ -47,8 +47,7 @@ usb2phy at 4a0ad080 {
 OMAP PIPE3 PHY
 
 Required properties:
- - compatible: Should be "ti,omap-usb3", "ti,omap-pipe3", "ti,omap-sata"
-   or "ti,omap-pcie"
+ - compatible: Should be "ti,phy-pipe3-usb3" or "ti,phy-pipe3-sata"
  - reg : Address and length of the register set for the device.
  - reg-names: The names of the register addresses corresponding to the registers
    filled in "reg".
drivers/phy/phy-omap-pipe3.c +2 -6
index 19d1664..67eeaeb 100644
@@ -219,17 +219,13 @@ static struct phy_ops ops = {
 #ifdef CONFIG_OF
 static const struct of_device_id omap_pipe3_id_table[] = {
 	{
-		.compatible = "ti,omap-pipe3",
+		.compatible = "ti,phy-pipe3-usb3",
 		.data = dpll_map_usb,
 	},
 	{
-		.compatible = "ti,omap-sata",
+		.compatible = "ti,phy-pipe3-sata",
 		.data = dpll_map_sata,
 	},
-	{
-		.compatible = "ti,omap-usb3",
-		.data = dpll_map_usb,
-	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, omap_pipe3_id_table);
Signature · 1 line
1.7.4.1
#8 lore raw

RFC PATCH 7/15 ARM: dts: omap5: Update usb3phy node

In reply to Roger Quadros

Update compatible property for usb3phy node.

---
 arch/arm/boot/dts/omap5.dtsi |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/boot/dts/omap5.dtsi +1 -1
index 97f361a..06aa665 100644
@@ -671,7 +671,7 @@
 			};
 
 			usb3_phy: usb3phy at 4a084400 {
-				compatible = "ti,omap-usb3";
+				compatible = "ti,phy-pipe3-usb3";
 				reg = <0x4a084400 0x80>,
 				      <0x4a084800 0x64>,
 				      <0x4a084c00 0x40>;
Signature · 1 line
1.7.4.1
#9 lore raw

RFC PATCH 8/15 ata: ahci_platform: Manage SATA PHY

In reply to Roger Quadros

From: Balaji T K <[email protected]>

Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the PHY framework.

[Roger Q] Cleaned up.

---
 .../devicetree/bindings/ata/ahci-platform.txt      |    2 +-
 drivers/ata/Kconfig                                |    1 +
 drivers/ata/ahci.h                                 |    2 +
 drivers/ata/ahci_platform.c                        |   31 +++++++++++++++++++-
 4 files changed, 34 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/ata/ahci-platform.txt +1 -1
index 89de156..c6c549a 100644
@@ -4,7 +4,7 @@ SATA nodes are defined to describe on-chip Serial ATA controllers.
 Each SATA controller should have its own node.
 
 Required properties:
-- compatible        : compatible list, contains "snps,spear-ahci"
+- compatible        : compatible list, contains "snps,spear-ahci" or "snps,dwc-ahci"
 - interrupts        : <interrupt mapping for SATA IRQ>
 - reg               : <registers mapping>
 
drivers/ata/Kconfig +1 -0
index 4e73772..a53ef27 100644
@@ -91,6 +91,7 @@ config SATA_AHCI
 
 config SATA_AHCI_PLATFORM
 	tristate "Platform AHCI SATA support"
+	select GENERIC_PHY
 	help
 	  This option enables support for Platform AHCI Serial ATA
 	  controllers.
drivers/ata/ahci.h +2 -0
index 1145637..94484cb 100644
@@ -37,6 +37,7 @@
 
 #include <linux/clk.h>
 #include <linux/libata.h>
+#include <linux/phy/phy.h>
 
 /* Enclosure Management Control */
 #define EM_CTRL_MSG_TYPE              0x000f0000
@@ -322,6 +323,7 @@ struct ahci_host_priv {
 	u32			em_buf_sz;	/* EM buffer size in byte */
 	u32			em_msg_type;	/* EM message type */
 	struct clk		*clk;		/* Only for platforms supporting clk */
+	struct phy		*phy;		/* If platforms use phy */
 	void			*plat_data;	/* Other platform data */
 };
 
drivers/ata/ahci_platform.c +30 -1
index 2daaee0..f812ffa 100644
@@ -23,6 +23,7 @@
 #include <linux/platform_device.h>
 #include <linux/libata.h>
 #include <linux/ahci_platform.h>
+#include <linux/phy/phy.h>
 #include "ahci.h"
 
 static void ahci_host_stop(struct ata_host *host);
@@ -141,16 +142,32 @@ static int ahci_probe(struct platform_device *pdev)
 		}
 	}
 
+	hpriv->phy = devm_phy_get(dev, "sata-phy");
+	if (IS_ERR(hpriv->phy)) {
+		dev_err(dev, "can't get phy\n");
+		/* return only if -EPROBE_DEFER */
+		if (PTR_ERR(hpriv->phy) == -EPROBE_DEFER) {
+			rc = -EPROBE_DEFER;
+			goto disable_unprepare_clk;
+		}
+	}
+
 	/*
 	 * Some platforms might need to prepare for mmio region access,
 	 * which could be done in the following init call. So, the mmio
 	 * region shouldn't be accessed before init (if provided) has
 	 * returned successfully.
 	 */
+
+	if (!(IS_ERR(hpriv->phy))) {
+		phy_init(hpriv->phy);
+		phy_power_on(hpriv->phy);
+	}
+
 	if (pdata && pdata->init) {
 		rc = pdata->init(dev, hpriv->mmio);
 		if (rc)
-			goto disable_unprepare_clk;
+			goto disable_phy;
 	}
 
 	ahci_save_initial_config(dev, hpriv,
@@ -220,6 +237,12 @@ static int ahci_probe(struct platform_device *pdev)
 pdata_exit:
 	if (pdata && pdata->exit)
 		pdata->exit(dev);
+disable_phy:
+	if (!IS_ERR(hpriv->phy)) {
+		phy_power_off(hpriv->phy);
+		phy_exit(hpriv->phy);
+	}
+
 disable_unprepare_clk:
 	if (!IS_ERR(hpriv->clk))
 		clk_disable_unprepare(hpriv->clk);
@@ -238,6 +261,11 @@ static void ahci_host_stop(struct ata_host *host)
 	if (pdata && pdata->exit)
 		pdata->exit(dev);
 
+	if (!IS_ERR(hpriv->phy)) {
+		phy_power_off(hpriv->phy);
+		phy_exit(hpriv->phy);
+	}
+
 	if (!IS_ERR(hpriv->clk)) {
 		clk_disable_unprepare(hpriv->clk);
 		clk_put(hpriv->clk);
@@ -328,6 +356,7 @@ static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume);
 static const struct of_device_id ahci_of_match[] = {
 	{ .compatible = "snps,spear-ahci", },
 	{ .compatible = "snps,exynos5440-ahci", },
+	{ .compatible = "snps,dwc-ahci", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, ahci_of_match);
Signature · 1 line
1.7.4.1
#10 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Quoted 7 lines · Roger Quadros

From: Balaji T K <[email protected]>

Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the PHY framework.

Quoted 5 lines

[Roger Q] Cleaned up.

Looks okay to me although I don't know whether everyone using ahci_platform would be happy with requiring phy. Sergei, does this look good to you?

Thanks.

Signature · 1 line
tejun
#11 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Hello.

Quoted 9 lines · Tejun Heo
Quoted 8 lines

From: Balaji T K <[email protected]>

Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the PHY framework.

[Roger Q] Cleaned up.

Quoted 7 lines
Quoted 3 lines

Looks okay to me although I don't know whether everyone using ahci_platform would be happy with requiring phy. Sergei, does this look good to you?

Not sure why you asked -- I'm not using this driver, neither I'm the
author of it (former MV's Anton Vorontsov is IIRC). I've commented on the patch anyway though...

Quoted 1 line

Thanks.

WBR, Sergei

#12 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Hello,

Quoted 1 line · Sergei Shtylyov

Not sure why you asked -- I'm not using this driver, neither I'm

Well, you have better grip of what's going on in the embedded world than me. I'm mostly curious whether adding dependency on PHY is okay.

Thanks.

Signature · 1 line
tejun
#13 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Hi Tejun,

Quoted 8 lines · Tejun Heo

Hello,

Quoted 1 line · Sergei Shtylyov

Not sure why you asked -- I'm not using this driver, neither I'm

Well, you have better grip of what's going on in the embedded world than me. I'm mostly curious whether adding dependency on PHY is okay.

There is no hard dependency on presence of PHY. The driver will continue as usual if devm_phy_get() fails.
I hope selecting GENERIC_PHY in Kconfig is not an issue.

cheers,
-roger

#14 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Hello.

Quoted 8 lines · Roger Quadros
Quoted 4 lines
Quoted 1 line

Not sure why you asked -- I'm not using this driver, neither I'm

Well, you have better grip of what's going on in the embedded world than me. I'm mostly curious whether adding dependency on PHY is okay.

There is no hard dependency on presence of PHY. The driver will continue as usual if devm_phy_get() fails.
I hope selecting GENERIC_PHY in Kconfig is not an issue.

Selecting in the AHCI_PLATFORM section? It seems I have overlooked it. No,
I don't think it's a good idea. The generic PHY functions seem to be stubbed when GENERIC_PHY=n.

Quoted 2 lines

cheers,
-roger

WBR, Sergei

#15 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Quoted 6 lines · Sergei Shtylyov

Hello.

Quoted 1 line · Roger Quadros
Quoted 1 line
Quoted 1 line

Not sure why you asked -- I'm not using this driver, neither I'm

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Well, you have better grip of what's going on in the embedded world than me. I'm mostly curious whether adding dependency on PHY is okay.

There is no hard dependency on presence of PHY. The driver will continue as usual if devm_phy_get() fails.
I hope selecting GENERIC_PHY in Kconfig is not an issue.

Selecting in the AHCI_PLATFORM section? It seems I have overlooked it. No, I don't think it's a good idea. The generic PHY functions seem to be stubbed when GENERIC_PHY=n.

OK I will remove the select then.

cheers,
-roger

#16 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Hi,

Quoted 10 lines · Roger Quadros
Quoted 9 lines · Sergei Shtylyov

Hello.

Quoted 4 lines · Roger Quadros
Quoted 4 lines
Quoted 1 line

Not sure why you asked -- I'm not using this driver, neither I'm

Well, you have better grip of what's going on in the embedded world than me. I'm mostly curious whether adding dependency on PHY is okay.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

There is no hard dependency on presence of PHY. The driver will continue as usual if devm_phy_get() fails.
I hope selecting GENERIC_PHY in Kconfig is not an issue.

Selecting in the AHCI_PLATFORM section? It seems I have overlooked it. No, I don't think it's a good idea. The generic PHY functions seem to be stubbed when GENERIC_PHY=n.

OK I will remove the select then.

If I remove the select then build fails like so if we set CONFIG_GENERIC_PHY to 'm' and CONFIG_SATA_AHCI_PLATFORM to 'y'

drivers/built-in.o: In function `ahci_platform_enable_resources':
(.text+0x162647): undefined reference to phy_init' drivers/built-in.o: In function ahci_platform_enable_resources':
(.text+0x16267c): undefined reference to phy_power_on' drivers/built-in.o: In function ahci_platform_enable_resources':
(.text+0x162694): undefined reference to phy_exit' drivers/built-in.o: In function ahci_platform_disable_resources':
(.text+0x1626af): undefined reference to phy_power_off' drivers/built-in.o: In function ahci_platform_disable_resources':
(.text+0x1626b7): undefined reference to phy_exit' drivers/built-in.o: In function ahci_platform_get_resources':
(.text+0x162768): undefined reference to `devm_phy_get'
make: *** [vmlinux] Error 1

This means we need to make CONFIG_SATA_AHCI_PLATFORM depend on CONFIG_GENERIC_PHY or select it.

OR

Generic PHY layer must be fixed so that the API's are always built in.

What is the better option? I believe making the PHY API's always built in is the better option.

cheers,
-roger

#17 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Quoted 10 lines · On Friday 07 February 2014 12:33:38 Roger Quadros wrote:

This means we need to make CONFIG_SATA_AHCI_PLATFORM depend on CONFIG_GENERIC_PHY or select it.

OR

Generic PHY layer must be fixed so that the API's are always built in.

What is the better option? I believe making the PHY API's always built in is the better option.

CONFIG_SATA_AHCI_PLATFORM should do

	"depends on CONFIG_GENERIC_PHY || !CONFIG_GENERIC_PHY"

which is the Kconfig way of saying that if CONFIG_GENERIC_PHY is a module, CONFIG_SATA_AHCI_PLATFORM needs to be a module as well.

Arnd

#18 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · On Friday 07 February 2014 12:33:38 Roger Quadros wrote:

This means we need to make CONFIG_SATA_AHCI_PLATFORM depend on CONFIG_GENERIC_PHY or select it.

OR

Generic PHY layer must be fixed so that the API's are always built in.

What is the better option? I believe making the PHY API's always built in is the better option.

Quoted 7 lines

CONFIG_SATA_AHCI_PLATFORM should do

	"depends on CONFIG_GENERIC_PHY || !CONFIG_GENERIC_PHY"

which is the Kconfig way of saying that if CONFIG_GENERIC_PHY is a module, CONFIG_SATA_AHCI_PLATFORM needs to be a module as well.

Ah, that's neat. Thanks :).

cheers,
-roger

#19 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

In reply to Tejun Heo

Hello.

Quoted 4 lines · Tejun Heo
Quoted 1 line

Not sure why you asked -- I'm not using this driver, neither I'm

Well, you have better grip of what's going on in the embedded world than me. I'm mostly curious whether adding dependency on PHY is okay.

This driver already supports optional clock, the optional PHY support
seems analogous.

Quoted 1 line

Thanks.

WBR, Sergei

#20 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Hi,

Quoted 11 lines · Sergei Shtylyov

Hello.

Quoted 4 lines · Tejun Heo
Quoted 1 line

Not sure why you asked -- I'm not using this driver, neither I'm

Well, you have better grip of what's going on in the embedded world than me. I'm mostly curious whether adding dependency on PHY is okay.

This driver already supports optional clock, the optional PHY support
seems analogous.

Right, this reminds me that PHY support should probably also be added to ahci_suspend() and ahci_resume().

Also please note the generic PHY framework is not yet merged in Linus' tree so this patch should probably be merged only after the generic PHY framework is in.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

#21 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

In reply to Roger Quadros

Hello.

Quoted 12 lines · Roger Quadros

From: Balaji T K <[email protected]>

Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the PHY framework.

[Roger Q] Cleaned up.

[...]

drivers/ata/ahci.h line 40

Quoted 9 lines
drivers/ata/ahci.h +1 -0
index 1145637..94484cb 100644
@@ -37,6 +37,7 @@
 
  #include <linux/clk.h>
  #include <linux/libata.h>
+#include <linux/phy/phy.h>

struct phy;

should suffice.

Quoted 13 lines
drivers/ata/ahci.h +1 -0
@@ -322,6 +323,7 @@ struct ahci_host_priv {
  	u32			em_buf_sz;	/* EM buffer size in byte */
  	u32			em_msg_type;	/* EM message type */
  	struct clk		*clk;		/* Only for platforms supporting clk */
+	struct phy		*phy;		/* If platforms use phy */
  	void			*plat_data;	/* Other platform data */
  };
 
drivers/ata/ahci_platform.c +0 -0
index 2daaee0..f812ffa 100644

drivers/ata/ahci_platform.c line 26

Quoted 4 lines
drivers/ata/ahci_platform.c +1 -0
@@ -23,6 +23,7 @@
  #include <linux/platform_device.h>
  #include <linux/libata.h>
  #include <linux/ahci_platform.h>
+#include <linux/phy/phy.h>

Why include it from both ahci.h and here?

drivers/ata/ahci_platform.c static int ahci_probe(struct platform_device *pdev) · line 147

Quoted 10 lines
drivers/ata/ahci_platform.c +3 -0
  #include "ahci.h"
 
  static void ahci_host_stop(struct ata_host *host);
@@ -141,16 +142,32 @@ static int ahci_probe(struct platform_device *pdev)
  		}
  	}
 
+	hpriv->phy = devm_phy_get(dev, "sata-phy");
+	if (IS_ERR(hpriv->phy)) {
+		dev_err(dev, "can't get phy\n");

Don't think it's a good idea to complain about missing PHY when the driver
doesn't even use it.

Quoted 5 lines
drivers/ata/ahci_platform.c +5 -0
+		/* return only if -EPROBE_DEFER */
+		if (PTR_ERR(hpriv->phy) == -EPROBE_DEFER) {
+			rc = -EPROBE_DEFER;
+			goto disable_unprepare_clk;
+		}

drivers/ata/ahci_platform.c static int ahci_probe(struct platform_device *pdev) · line 162

Quoted 10 lines
drivers/ata/ahci_platform.c +4 -0
+	}
+
  	/*
  	 * Some platforms might need to prepare for mmio region access,
  	 * which could be done in the following init call. So, the mmio
  	 * region shouldn't be accessed before init (if provided) has
  	 * returned successfully.
  	 */
+
+	if (!(IS_ERR(hpriv->phy))) {

() not needed around IS_ERR() invocation.

drivers/ata/ahci_platform.c static int ahci_probe(struct platform_device *pdev) · line 166

Quoted 4 lines
drivers/ata/ahci_platform.c +4 -0
+		phy_init(hpriv->phy);
+		phy_power_on(hpriv->phy);
+	}
+

I think this is misplaced, i.e. it should precede the comment.

Quoted 8 lines
drivers/ata/ahci_platform.c +1 -1
  	if (pdata && pdata->init) {
  		rc = pdata->init(dev, hpriv->mmio);
  		if (rc)
-			goto disable_unprepare_clk;
+			goto disable_phy;
  	}
 
  	ahci_save_initial_config(dev, hpriv,

[...]

drivers/ata/ahci_platform.c static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume); · line 359

Quoted 5 lines
drivers/ata/ahci_platform.c +1 -0
@@ -328,6 +356,7 @@ static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume);
  static const struct of_device_id ahci_of_match[] = {
  	{ .compatible = "snps,spear-ahci", },
  	{ .compatible = "snps,exynos5440-ahci", },
+	{ .compatible = "snps,dwc-ahci", },

Looks like the binding documentation is incomplete -- it doesn't list
"snps,exynos5440-ahci"...

WBR, Sergei

#22 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Hello,

Quoted 9 lines · Sergei Shtylyov

drivers/ata/ahci.h line 40

Quoted 5 lines
drivers/ata/ahci.h +1 -0
@@ -37,6 +37,7 @@
 
 #include <linux/clk.h>
 #include <linux/libata.h>
+#include <linux/phy/phy.h>

struct phy;

should suffice.

Unless it's actually likely to cause inclusion loop, I think it's better to include the header than adding explicit declarations.

Thanks.

Signature · 1 line
tejun
#23 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Hello.

Quoted 6 lines · Tejun Heo
Quoted 5 lines
Quoted 5 lines
drivers/ata/ahci.h +1 -0
@@ -37,6 +37,7 @@
 
  #include <linux/clk.h>
  #include <linux/libata.h>
+#include <linux/phy/phy.h>
Quoted 6 lines
Quoted 3 lines

struct phy;

should suffice.

Unless it's actually likely to cause inclusion loop, I think it's better to include the header than adding explicit declarations.

Apparently, tastes differ here. E.g. Greg KH would have also told Roger to
use forward declaration in such case. :-)

Quoted 1 line

Thanks.

WBR, Sergei

#24 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

Quoted 5 lines · Sergei Shtylyov
Quoted 2 lines

Unless it's actually likely to cause inclusion loop, I think it's better to include the header than adding explicit declarations.

Apparently, tastes differ here. E.g. Greg KH would have also told
Roger to use forward declaration in such case. :-)

Yes, it's a matter of taste, but, of course mine is better than Greg's. :P

Signature · 1 line
tejun
#25 lore raw

Re: [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY

In reply to Sergei Shtylyov

Hi,

Quoted 40 lines · Sergei Shtylyov

Hello.

Quoted 12 lines · Roger Quadros

From: Balaji T K <[email protected]>

Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the PHY framework.

[Roger Q] Cleaned up.

[...]

drivers/ata/ahci.h line 40

Quoted 9 lines
drivers/ata/ahci.h +1 -0
index 1145637..94484cb 100644
@@ -37,6 +37,7 @@
 
  #include <linux/clk.h>
  #include <linux/libata.h>
+#include <linux/phy/phy.h>

struct phy;

should suffice.

Quoted 8 lines
drivers/ata/ahci.h +1 -0
@@ -322,6 +323,7 @@ struct ahci_host_priv {
      u32            em_buf_sz;    /* EM buffer size in byte */
      u32            em_msg_type;    /* EM message type */
      struct clk        *clk;        /* Only for platforms supporting clk */
+    struct phy        *phy;        /* If platforms use phy */
      void            *plat_data;    /* Other platform data */
  };
 
Quoted 12 lines

drivers/ata/ahci_platform.c line 26

Quoted 9 lines
drivers/ata/ahci_platform.c +1 -0
index 2daaee0..f812ffa 100644
@@ -23,6 +23,7 @@
  #include <linux/platform_device.h>
  #include <linux/libata.h>
  #include <linux/ahci_platform.h>
+#include <linux/phy/phy.h>

Why include it from both ahci.h and here?

OK. will move it to just .c file.

Quoted 7 lines
Quoted 7 lines
drivers/ata/ahci_platform.c +0 -0
  #include "ahci.h"
 
  static void ahci_host_stop(struct ata_host *host);
@@ -141,16 +142,32 @@ static int ahci_probe(struct platform_device *pdev)
          }
      }
 
Quoted 5 lines

drivers/ata/ahci_platform.c static int ahci_probe(struct platform_device *pdev) · line 147

Quoted 3 lines
drivers/ata/ahci_platform.c +3 -0
+    hpriv->phy = devm_phy_get(dev, "sata-phy");
+    if (IS_ERR(hpriv->phy)) {
+        dev_err(dev, "can't get phy\n");

Don't think it's a good idea to complain about missing PHY when the driver doesn't even use it.

OK. will change it to dev_dbg() instead.

Quoted 10 lines
Quoted 10 lines
drivers/ata/ahci_platform.c +7 -0
+        /* return only if -EPROBE_DEFER */
+        if (PTR_ERR(hpriv->phy) == -EPROBE_DEFER) {
+            rc = -EPROBE_DEFER;
+            goto disable_unprepare_clk;
+        }
+    }
+
      /*
       * Some platforms might need to prepare for mmio region access,
Quoted 8 lines

drivers/ata/ahci_platform.c static int ahci_probe(struct platform_device *pdev) · line 162

Quoted 6 lines
drivers/ata/ahci_platform.c +2 -0
       * which could be done in the following init call. So, the mmio
       * region shouldn't be accessed before init (if provided) has
       * returned successfully.
       */
+
+    if (!(IS_ERR(hpriv->phy))) {

() not needed around IS_ERR() invocation.

OK.

Quoted 8 lines

drivers/ata/ahci_platform.c static int ahci_probe(struct platform_device *pdev) · line 166

Quoted 5 lines
drivers/ata/ahci_platform.c +4 -0
+        phy_init(hpriv->phy);
+        phy_power_on(hpriv->phy);
+    }
+

I think this is misplaced, i.e. it should precede the comment.

OK.

Quoted 8 lines

drivers/ata/ahci_platform.c static int ahci_probe(struct platform_device *pdev) · line 173

Quoted 8 lines
drivers/ata/ahci_platform.c +1 -1
      if (pdata && pdata->init) {
          rc = pdata->init(dev, hpriv->mmio);
          if (rc)
-            goto disable_unprepare_clk;
+            goto disable_phy;
      }
 
      ahci_save_initial_config(dev, hpriv,
Quoted 8 lines

[...]

drivers/ata/ahci_platform.c static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume); · line 359

Quoted 5 lines
drivers/ata/ahci_platform.c +1 -0
@@ -328,6 +356,7 @@ static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume);
  static const struct of_device_id ahci_of_match[] = {
      { .compatible = "snps,spear-ahci", },
      { .compatible = "snps,exynos5440-ahci", },
+    { .compatible = "snps,dwc-ahci", },

Looks like the binding documentation is incomplete -- it doesn't list "snps,exynos5440-ahci"...

OK, I'll update it. Thanks for review.

cheers,
-roger

#26 lore raw

RFC PATCH 9/15 ata: ti_sata: Add Texas Instruments SATA Wrapper driver

In reply to Roger Quadros

Texas Instruments SoCs like OMAP5 and DRA7 contain a SATA wrapper around the AHCI SATA core. This driver will manage that.

---
 Documentation/devicetree/bindings/ata/ti-sata.txt |   31 ++++
 drivers/ata/Kconfig                               |    7 +
 drivers/ata/Makefile                              |    1 +
 drivers/ata/sata_ti.c                             |  160 +++++++++++++++++++++
 4 files changed, 199 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/ti-sata.txt
 create mode 100644 drivers/ata/sata_ti.c
Documentation/devicetree/bindings/ata/ti-sata.txt new file +31 -0
new file mode 100644
index 0000000..bf0ea3b
@@ -0,0 +1,31 @@
+* Texas Instruments SATA Controller Wrapper
+
+Required properties:
+- compatible	: "ti,sata"
+- ti,hwmods	: "sata"
+- reg		: Register mapping
+- #address-cells: <1>
+- #size-cells	: <1>
+- ranges	: allows valid translation between child's address space and parent's
+		  address space.
+- Must contain at least one child node for the SATA controller core
+
+Example:
+
+	sata: sata at 4a141100 {
+		compatible = "ti,sata";
+		ti,hwmods = "sata";
+		reg = <0x4a141100 0x7>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+		dwc-ahci at 4a140000 {
+			compatible = "snps,dwc-ahci";
+			reg = <0x4a140000 0x1100>;
+			interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>;
+			phys = <&sata_phy>;
+			phy-names = "sata-phy";
+			clocks = <&sata_ref_clk>;
+			clock-names = "optclk";
+		};
+	};
drivers/ata/Kconfig +7 -0
index a53ef27..a3de4d2 100644
@@ -138,6 +138,13 @@ config SATA_SIL24
 
 	  If unsure, say N.
 
+config SATA_TI
+	tristate "Texas Instruments SATA Wrapper driver"
+	depends on ARCH_OMAP
+	help
+	  This options enables SATA Wrapper driver for Texas Instruments SoCs.
+	  It is found on OMAP5 and DRA7.
+
 config ATA_SFF
 	bool "ATA SFF support (for legacy IDE and PATA)"
 	default y
drivers/ata/Makefile +1 -0
index 46518c6..673ba5e 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_SATA_SIL24)	+= sata_sil24.o
 obj-$(CONFIG_SATA_DWC)		+= sata_dwc_460ex.o
 obj-$(CONFIG_SATA_HIGHBANK)	+= sata_highbank.o libahci.o
 obj-$(CONFIG_AHCI_IMX)		+= ahci_imx.o
+obj-$(CONFIG_SATA_TI)		+= sata_ti.o
 
 # SFF w/ custom DMA
 obj-$(CONFIG_PDC_ADMA)		+= pdc_adma.o
drivers/ata/sata_ti.c new file +160 -0

160 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#27 lore raw

Re: [RFC PATCH 09/15] ata: ti_sata: Add Texas Instruments SATA Wrapper driver

Hi,

Quoted 87 lines · Roger Quadros

Texas Instruments SoCs like OMAP5 and DRA7 contain a SATA wrapper around the AHCI SATA core. This driver will manage that.

---
 Documentation/devicetree/bindings/ata/ti-sata.txt |   31 ++++
 drivers/ata/Kconfig                               |    7 +
 drivers/ata/Makefile                              |    1 +
 drivers/ata/sata_ti.c                             |  160 +++++++++++++++++++++
 4 files changed, 199 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/ti-sata.txt
 create mode 100644 drivers/ata/sata_ti.c
Documentation/devicetree/bindings/ata/ti-sata.txt new file +31 -0
new file mode 100644
index 0000000..bf0ea3b
@@ -0,0 +1,31 @@
+* Texas Instruments SATA Controller Wrapper
+
+Required properties:
+- compatible	: "ti,sata"
+- ti,hwmods	: "sata"
+- reg		: Register mapping
+- #address-cells: <1>
+- #size-cells	: <1>
+- ranges	: allows valid translation between child's address space and parent's
+		  address space.
+- Must contain at least one child node for the SATA controller core
+
+Example:
+
+	sata: sata at 4a141100 {
+		compatible = "ti,sata";
+		ti,hwmods = "sata";
+		reg = <0x4a141100 0x7>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+		dwc-ahci at 4a140000 {
+			compatible = "snps,dwc-ahci";
+			reg = <0x4a140000 0x1100>;
+			interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>;
+			phys = <&sata_phy>;
+			phy-names = "sata-phy";
+			clocks = <&sata_ref_clk>;
+			clock-names = "optclk";
+		};
+	};
drivers/ata/Kconfig +7 -0
index a53ef27..a3de4d2 100644
@@ -138,6 +138,13 @@ config SATA_SIL24
 
 	  If unsure, say N.
 
+config SATA_TI
+	tristate "Texas Instruments SATA Wrapper driver"
+	depends on ARCH_OMAP
+	help
+	  This options enables SATA Wrapper driver for Texas Instruments SoCs.
+	  It is found on OMAP5 and DRA7.
+
 config ATA_SFF
 	bool "ATA SFF support (for legacy IDE and PATA)"
 	default y
drivers/ata/Makefile +1 -0
index 46518c6..673ba5e 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_SATA_SIL24)	+= sata_sil24.o
 obj-$(CONFIG_SATA_DWC)		+= sata_dwc_460ex.o
 obj-$(CONFIG_SATA_HIGHBANK)	+= sata_highbank.o libahci.o
 obj-$(CONFIG_AHCI_IMX)		+= ahci_imx.o
+obj-$(CONFIG_SATA_TI)		+= sata_ti.o
 
 # SFF w/ custom DMA
 obj-$(CONFIG_PDC_ADMA)		+= pdc_adma.o
drivers/ata/sata_ti.c new file +0 -0
new file mode 100644
index 0000000..0b9093d

drivers/ata/sata_ti.c line 2

Quoted 2 lines
drivers/ata/sata_ti.c new file +2 -0
@@ -0,0 +1,160 @@
+/**
+ * sata-ti.c - Texas Instruments Specific SATA Glue layer

s/sata-ti/sata_ti/

Quoted 22 lines
drivers/ata/sata_ti.c new file +22 -0
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Authors: Roger Quadros <[email protected]>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/platform_device.h>
+#include <linux/ioport.h>
+#include <linux/io.h>
+#include <linux/pm_runtime.h>

drivers/ata/sata_ti.c line 34

Quoted 10 lines
drivers/ata/sata_ti.c new file +10 -0
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+/*
+ * All these registers belong to OMAP's Wrapper around the
+ * DesignWare SATA Core.
+ */
+
+#define SATA_SYSCONFIG				0x0000
+#define SATA_CDRLOCK				0x0004

These defines are not used anywhere.

Quoted 27 lines
drivers/ata/sata_ti.c new file +27 -0
+struct ti_sata {
+	struct device *dev;
+	void __iomem *base;
+};
+
+static int ti_sata_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device *dev = &pdev->dev;
+	struct ti_sata *sata;
+	struct resource *res;
+	void __iomem *base;
+	int ret;
+
+	if (!np) {
+		dev_err(dev, "device node not found\n");
+		return -EINVAL;
+	}
+
+	sata = devm_kzalloc(dev, sizeof(*sata), GFP_KERNEL);
+	if (!sata)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, sata);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {

drivers/ata/sata_ti.c line 72

Quoted 10 lines
drivers/ata/sata_ti.c new file +10 -0
+		dev_err(dev, "missing memory base resource\n");
+		return -EINVAL;
+	}
+
+	base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	sata->dev = dev;
+	sata->base = base;

sata structure is just setup and it is not used later anywhere.

drivers/ata/sata_ti.c line 82

Quoted 9 lines
drivers/ata/sata_ti.c new file +9 -0
+	pm_runtime_enable(dev);
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0) {
+		dev_err(dev, "pm_runtime_get_sync failed with err %d\n",
+									ret);
+		goto runtime_disable;
+	}
+
+	ret = of_platform_populate(np, NULL, NULL, dev);

Shouldn't this driver depend on CONFIG_OF?

Quoted 39 lines
drivers/ata/sata_ti.c new file +39 -0
+	if (ret) {
+		dev_err(&pdev->dev, "failed to create TI SATA children\n");
+		goto runtime_put;
+	}
+
+	return 0;
+
+runtime_put:
+	pm_runtime_put_sync(dev);
+
+runtime_disable:
+	pm_runtime_disable(dev);
+
+	return ret;
+}
+
+static int ti_sata_remove_child(struct device *dev, void *c)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+
+	platform_device_unregister(pdev);
+
+	return 0;
+}
+
+static int ti_sata_remove(struct platform_device *pdev)
+{
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
+	device_for_each_child(&pdev->dev, NULL, ti_sata_remove_child);
+
+	return 0;
+}
+
+static const struct of_device_id of_ti_sata_match[] = {
+	{
+		.compatible =	"ti,sata"
+	},
+	{ },

drivers/ata/sata_ti.c line 131

Quoted 10 lines
drivers/ata/sata_ti.c new file +10 -0
+};
+MODULE_DEVICE_TABLE(of, of_ti_sata_match);
+
+#ifdef CONFIG_PM
+
+static int ti_sata_resume(struct device *dev)
+{
+	pm_runtime_disable(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);

This doesn't look like a correct ->resume method:
* it shouldn't touch runtime PM at all
* for each ->resume method there should be a corresponding ->suspend method

Moreover this whole wrapper driver seems strange, why not just add a proper runtime PM support to ahci_platform driver instead?

Quoted 19 lines
drivers/ata/sata_ti.c new file +19 -0
+
+	return 0;
+}
+
+static const struct dev_pm_ops ti_sata_dev_pm_ops = {
+	.resume = ti_sata_resume,
+};
+
+#define DEV_PM_OPS	(&ti_sata_dev_pm_ops)
+#else
+#define DEV_PM_OPS	NULL
+#endif /* CONFIG_PM */
+
+static struct platform_driver ti_sata_driver = {
+	.probe		= ti_sata_probe,
+	.remove		= ti_sata_remove,
+	.driver		= {
+		.name	= "ti-sata",
+		.of_match_table	= of_ti_sata_match,

drivers/ata/sata_ti.c line 160

Quoted 10 lines
drivers/ata/sata_ti.c new file +10 -0
+		.pm	= DEV_PM_OPS,
+	},
+};
+
+module_platform_driver(ti_sata_driver);
+
+MODULE_ALIAS("platform:ti-sata");
+MODULE_AUTHOR("Roger Quadros <[email protected]>");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("TI SATA Glue Layer");

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

#28 lore raw

Re: [RFC PATCH 09/15] ata: ti_sata: Add Texas Instruments SATA Wrapper driver

On Wednesday, September 25, 2013 02:37:19 PM Bartlomiej Zolnierkiewicz wrote:

[...]

Quoted 12 lines

drivers/ata/sata_ti.c line 131

Quoted 7 lines
drivers/ata/sata_ti.c new file +7 -0
+#ifdef CONFIG_PM
+
+static int ti_sata_resume(struct device *dev)
+{
+	pm_runtime_disable(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);

This doesn't look like a correct ->resume method:
* it shouldn't touch runtime PM at all
* for each ->resume method there should be a corresponding ->suspend method

Quoted 2 lines

Moreover this whole wrapper driver seems strange, why not just add a proper runtime PM support to ahci_platform driver instead?

Hmm, even this shouldn't be needed as this wrapper driver doesn't have ->runtime_suspend and ->runtime resume methods.

What exactly is the purpose of the existence of this wrapper driver?

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

#29 lore raw

Re: [RFC PATCH 09/15] ata: ti_sata: Add Texas Instruments SATA Wrapper driver

Hi,

Quoted 16 lines · Bartlomiej Zolnierkiewicz

On Wednesday, September 25, 2013 02:37:19 PM Bartlomiej Zolnierkiewicz wrote:

[...]

Quoted 12 lines

drivers/ata/sata_ti.c line 131

Quoted 7 lines
drivers/ata/sata_ti.c new file +7 -0
+#ifdef CONFIG_PM
+
+static int ti_sata_resume(struct device *dev)
+{
+	pm_runtime_disable(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);

This doesn't look like a correct ->resume method:
* it shouldn't touch runtime PM at all
* for each ->resume method there should be a corresponding ->suspend method

Quoted 7 lines
Quoted 2 lines

Moreover this whole wrapper driver seems strange, why not just add a proper runtime PM support to ahci_platform driver instead?

Hmm, even this shouldn't be needed as this wrapper driver doesn't have ->runtime_suspend and ->runtime resume methods.

What exactly is the purpose of the existence of this wrapper driver?

This is the weirdness of OMAP hwmod framework :).

The OMAP hwmod framework tries to manage the module clocks by itself and needs a runtime_resume to enable the relevant clocks.

hwmod framework will be deprecated in the near future and this is the place where we need to handle the resources.

But since we are not yet there, I can get rid of this wrapper driver for now and add the necessary pm_runtime calls in the ahci_platform driver.

cheers,
-roger

#30 lore raw

RFC PATCH 10/15 ARM: omap5: hwmod: Add ocp2scp3 and sata hwmods

In reply to Roger Quadros

From: Keshava Munegowda <[email protected]>

Create hwmods for ocp2scp3 and sata modules.

[Roger Q] Clean up.

---
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c |   72 ++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_54xx_data.c +72 -0
index 3dae6b9..2b698b8 100644
@@ -1545,6 +1545,76 @@ static struct omap_hwmod omap54xx_wd_timer2_hwmod = {
 	},
 };
 
+/*
+ * 'ocp2scp' class
+ * bridge to transform ocp interface protocol to scp (serial control port)
+ * protocol
+ */
+/* ocp2scp3 */
+static struct omap_hwmod omap54xx_ocp2scp3_hwmod;
+/* l4_cfg -> ocp2scp3 */
+static struct omap_hwmod_ocp_if omap54xx_l4_cfg__ocp2scp3 = {
+	.master		= &omap54xx_l4_cfg_hwmod,
+	.slave		= &omap54xx_ocp2scp3_hwmod,
+	.clk		= "l4_root_clk_div",
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
+static struct omap_hwmod omap54xx_ocp2scp3_hwmod = {
+	.name		= "ocp2scp3",
+	.class		= &omap54xx_ocp2scp_hwmod_class,
+	.clkdm_name	= "l3init_clkdm",
+	.prcm = {
+		.omap4 = {
+			.clkctrl_offs = OMAP54XX_CM_L3INIT_OCP2SCP3_CLKCTRL_OFFSET,
+			.context_offs = OMAP54XX_RM_L3INIT_OCP2SCP3_CONTEXT_OFFSET,
+			.modulemode   = MODULEMODE_HWCTRL,
+		},
+	},
+};
+
+/*
+ * 'sata' class
+ * sata:  serial ata interface  gen2 compliant   ( 1 rx/ 1 tx)
+ */
+
+static struct omap_hwmod_class_sysconfig omap54xx_sata_sysc = {
+	.sysc_offs	= 0x0000,
+	.sysc_flags	= (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+			   SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
+			   MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
+	.sysc_fields	= &omap_hwmod_sysc_type2,
+};
+
+static struct omap_hwmod_class omap54xx_sata_hwmod_class = {
+	.name	= "sata",
+	.sysc	= &omap54xx_sata_sysc,
+};
+
+/* sata */
+static struct omap_hwmod omap54xx_sata_hwmod = {
+	.name		= "sata",
+	.class		= &omap54xx_sata_hwmod_class,
+	.clkdm_name	= "l3init_clkdm",
+	.flags		= HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
+	.main_clk	= "func_48m_fclk",
+	.prcm = {
+		.omap4 = {
+			.clkctrl_offs = OMAP54XX_CM_L3INIT_SATA_CLKCTRL_OFFSET,
+			.context_offs = OMAP54XX_RM_L3INIT_SATA_CONTEXT_OFFSET,
+			.modulemode   = MODULEMODE_SWCTRL,
+		},
+	},
+};
+
+/* l4_cfg -> sata */
+static struct omap_hwmod_ocp_if omap54xx_l4_cfg__sata = {
+	.master		= &omap54xx_l4_cfg_hwmod,
+	.slave		= &omap54xx_sata_hwmod,
+	.clk		= "l3_iclk_div",
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
 
 /*
  * Interfaces
@@ -2192,6 +2262,8 @@ static struct omap_hwmod_ocp_if *omap54xx_hwmod_ocp_ifs[] __initdata = {
 	&omap54xx_l4_per__uart6,
 	&omap54xx_l4_cfg__usb_otg_ss,
 	&omap54xx_l4_wkup__wd_timer2,
+	&omap54xx_l4_cfg__ocp2scp3,
+	&omap54xx_l4_cfg__sata,
 	NULL,
 };
 
Signature · 1 line
1.7.4.1
#31 lore raw

RFC PATCH 11/15 arm: omap5: hwmod: add missing ocp2scp hwmod data

In reply to Roger Quadros

From: Benoit Cousson <[email protected]>

without that hwmod data, USB3 will not in OMAP5 boards.

---
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c |   45 ++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_54xx_data.c +45 -0
index 2b698b8..e7d4fcb 100644
@@ -1146,6 +1146,42 @@ static struct omap_hwmod omap54xx_mpu_hwmod = {
 };
 
 /*
+ * 'ocp2scp' class
+ * bridge to transform ocp interface protocol to scp (serial control port)
+ * protocol
+ */
+
+static struct omap_hwmod_class_sysconfig omap54xx_ocp2scp_sysc = {
+	.rev_offs	= 0x0000,
+	.sysc_offs	= 0x0010,
+	.syss_offs	= 0x0014,
+	.sysc_flags	= (SYSC_HAS_AUTOIDLE | SYSC_HAS_SIDLEMODE |
+			SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
+	.sysc_fields	= &omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class omap54xx_ocp2scp_hwmod_class = {
+	.name	= "ocp2scp",
+	.sysc	= &omap54xx_ocp2scp_sysc,
+};
+
+/* ocp2scp1 */
+static struct omap_hwmod omap54xx_ocp2scp1_hwmod = {
+	.name		= "ocp2scp1",
+	.class		= &omap54xx_ocp2scp_hwmod_class,
+	.clkdm_name	= "l3init_clkdm",
+	.main_clk	= "l4_root_clk_div",
+	.prcm = {
+		.omap4 = {
+			.clkctrl_offs = OMAP54XX_CM_L3INIT_OCP2SCP1_CLKCTRL_OFFSET,
+			.context_offs = OMAP54XX_RM_L3INIT_OCP2SCP1_CONTEXT_OFFSET,
+			.modulemode   = MODULEMODE_HWCTRL,
+		},
+	},
+};
+
+/*
  * 'timer' class
  * general purpose timer module with accurate 1ms tick
  * This class contains several variants: ['timer_1ms', 'timer']
@@ -2040,6 +2076,14 @@ static struct omap_hwmod_ocp_if omap54xx_l4_cfg__mpu = {
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/* l4_cfg -> ocp2scp1 */
+static struct omap_hwmod_ocp_if omap54xx_l4_cfg__ocp2scp1 = {
+	.master		= &omap54xx_l4_cfg_hwmod,
+	.slave		= &omap54xx_ocp2scp1_hwmod,
+	.clk		= "l4_root_clk_div",
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
 /* l4_wkup -> timer1 */
 static struct omap_hwmod_ocp_if omap54xx_l4_wkup__timer1 = {
 	.master		= &omap54xx_l4_wkup_hwmod,
@@ -2243,6 +2287,7 @@ static struct omap_hwmod_ocp_if *omap54xx_hwmod_ocp_ifs[] __initdata = {
 	&omap54xx_l4_per__mmc4,
 	&omap54xx_l4_per__mmc5,
 	&omap54xx_l4_cfg__mpu,
+	&omap54xx_l4_cfg__ocp2scp1,
 	&omap54xx_l4_wkup__timer1,
 	&omap54xx_l4_per__timer2,
 	&omap54xx_l4_per__timer3,
Signature · 1 line
1.7.4.1
#32 lore raw

RFC PATCH 12/15 ARM: dts: omap5: add ocp2scp1 address resource

In reply to Roger Quadros

Add OCP2SCP1 module address space.

---
 arch/arm/boot/dts/omap5.dtsi |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap5.dtsi +1 -0
index 06aa665..8a88a94 100644
@@ -663,6 +663,7 @@
 			#size-cells = <1>;
 			ranges;
 			ti,hwmods = "ocp2scp1";
+			reg = <0x4a080000 0x1f>;
 			usb2_phy: usb2phy at 4a084000 {
 				compatible = "ti,omap-usb2";
 				reg = <0x4a084000 0x7c>;
Signature · 1 line
1.7.4.1
#33 lore raw

Re: [RFC PATCH 12/15] ARM: dts: omap5: add ocp2scp1 address resource

Quoted 13 lines · Roger Quadros

Add OCP2SCP1 module address space.

---
  arch/arm/boot/dts/omap5.dtsi |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap5.dtsi +0 -0
index 06aa665..8a88a94 100644

arch/arm/boot/dts/omap5.dtsi line 666

Quoted 4 lines
arch/arm/boot/dts/omap5.dtsi +1 -0
@@ -663,6 +663,7 @@
  			#size-cells = <1>;
  			ranges;
  			ti,hwmods = "ocp2scp1";
+			reg = <0x4a080000 0x1f>;
    Are you sure length is not 0x20?

WBR, Sergei

#34 lore raw

Re: [RFC PATCH 12/15] ARM: dts: omap5: add ocp2scp1 address resource

Hi,

Quoted 10 lines · Sergei Shtylyov
Quoted 7 lines · Roger Quadros

Add OCP2SCP1 module address space.

---
  arch/arm/boot/dts/omap5.dtsi |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
Quoted 11 lines

arch/arm/boot/dts/omap5.dtsi line 666

Quoted 9 lines
arch/arm/boot/dts/omap5.dtsi +1 -0
index 06aa665..8a88a94 100644
@@ -663,6 +663,7 @@
              #size-cells = <1>;
              ranges;
              ti,hwmods = "ocp2scp1";
+            reg = <0x4a080000 0x1f>;

Are you sure length is not 0x20?

Actually there are just 4 of 32-bit registers with the last one starting at 0x18, so I think length should be 0x1c.

I copied 0x1f from omap4.dtsi. Looks like that is wrong as well. But it is harmless as nobody else is using that address.

I'll fix this to 0x1c in next rev.

cheers,
-roger

#35 lore raw

RFC PATCH 13/15 arm: dts: omap5: add sata node

In reply to Roger Quadros

From: Balaji T K <[email protected]>

Add support for sata.

[Roger Q] Clean up.

---
 arch/arm/boot/dts/omap5.dtsi |   51 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)
arch/arm/boot/dts/omap5.dtsi +50 -1
index 8a88a94..a79ccb7 100644
@@ -434,6 +434,53 @@
 			dma-names = "tx", "rx";
 		};
 
+		omap_control_sata: control-phy at 4a002374 {
+			compatible = "ti,control-phy-pipe3";
+			reg = <0x4a002374 0x4>;
+			reg-names = "power";
+			clocks = <&sys_clkin>;
+			clock-names = "sysclk";
+		};
+
+		ocp2scp3: ocp2scp3 at 4a090000 {
+			compatible = "ti,omap-ocp2scp";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			ti,hwmods = "ocp2scp3";
+			reg = <0x4a090000 0x1f>; /* ocp2scp3 */
+			reg-names = "ocp2scp3";
+			sata_phy: sataphy at 4A096000 {
+				compatible = "ti,phy-pipe3-sata";
+				reg = <0x4A096000 0x80>, /* phy_rx */
+				      <0x4A096400 0x64>, /* phy_tx */
+				      <0x4A096800 0x40>; /* pll_ctrl */
+				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
+				ctrl-module = <&omap_control_sata>;
+				clocks = <&sys_clkin>;
+				clock-names = "sysclk";
+				#phy-cells = <0>;
+			};
+		};
+
+		sata: sata at 4a141100 {
+			compatible = "ti,sata";
+			ti,hwmods = "sata";
+			reg = <0x4a141100 0x7>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			dwc-ahci at 4a140000 {
+				  compatible = "snps,dwc-ahci";
+				  reg = <0x4a140000 0x1100>;
+				  interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>;
+				  phys = <&sata_phy>;
+				  phy-names = "sata-phy";
+				  clocks = <&sata_ref_clk>;
+				  clock-names = "optclk";
+			};
+		};
+
 		keypad: keypad at 4ae1c000 {
 			compatible = "ti,omap4-keypad";
 			reg = <0x4ae1c000 0x400>;
@@ -636,6 +683,8 @@
 			compatible = "ti,control-phy-pipe3";
 			reg = <0x4a002370 0x4>;
 			reg-names = "power";
+			clocks = <&sys_clkin>;
+			clock-names = "sysclk";
 		};
 
 		omap_dwc3 at 4a020000 {
@@ -657,7 +706,7 @@
 			};
 		};
 
-		ocp2scp {
+		ocp2scp1: ocp2scp1 at 4a080000 {
 			compatible = "ti,omap-ocp2scp";
 			#address-cells = <1>;
 			#size-cells = <1>;
Signature · 1 line
1.7.4.1
#36 lore raw

RFC PATCH 14/15 ARM: DRA7: hwmod: Add ocp2scp3 and sata hwmods

In reply to Roger Quadros

From: Nikhil Devshatwar <[email protected]>

Add hwmods for ocp2scp3 and sata modules.

[Roger Q] Clean up.

---
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c |   40 +++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/omap_hwmod_7xx_data.c +35 -5
index f647998b..4d7d70f 100644
@@ -1215,6 +1215,40 @@ static struct omap_hwmod dra7xx_ocp2scp1_hwmod = {
 	},
 };
 
+/* ocp2scp3 */
+static struct omap_hwmod dra7xx_ocp2scp3_hwmod;
+static struct omap_hwmod_addr_space dra7xx_ocp2scp3_addrs[] = {
+	{
+		.name		= "ocp2scp3",
+		.pa_start	= 0x4a090000,
+		.pa_end		= 0x4a09001f,
+		.flags		= ADDR_TYPE_RT
+	},
+	{ }
+};
+
+/* l4_cfg -> ocp2scp3 */
+static struct omap_hwmod_ocp_if dra7xx_l4_cfg__ocp2scp3 = {
+	.master		= &dra7xx_l4_cfg_hwmod,
+	.slave		= &dra7xx_ocp2scp3_hwmod,
+	.clk		= "l4_root_clk_div",
+	.addr		= dra7xx_ocp2scp3_addrs,
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
+static struct omap_hwmod dra7xx_ocp2scp3_hwmod = {
+	.name		= "ocp2scp3",
+	.class		= &dra7xx_ocp2scp_hwmod_class,
+	.clkdm_name	= "l3init_clkdm",
+	.prcm = {
+		.omap4 = {
+			.clkctrl_offs = DRA7XX_CM_L3INIT_OCP2SCP3_CLKCTRL_OFFSET,
+			.context_offs = DRA7XX_RM_L3INIT_OCP2SCP3_CONTEXT_OFFSET,
+			.modulemode   = MODULEMODE_HWCTRL,
+		},
+	},
+};
+
 /*
  * 'qspi' class
  *
@@ -1268,9 +1302,6 @@ static struct omap_hwmod_class dra7xx_sata_hwmod_class = {
 };
 
 /* sata */
-static struct omap_hwmod_opt_clk sata_opt_clks[] = {
-	{ .role = "ref_clk", .clk = "sata_ref_clk" },
-};
 
 static struct omap_hwmod dra7xx_sata_hwmod = {
 	.name		= "sata",
@@ -1285,8 +1316,6 @@ static struct omap_hwmod dra7xx_sata_hwmod = {
 			.modulemode   = MODULEMODE_SWCTRL,
 		},
 	},
-	.opt_clks	= sata_opt_clks,
-	.opt_clks_cnt	= ARRAY_SIZE(sata_opt_clks),
 };
 
 /*
@@ -2683,6 +2712,7 @@ static struct omap_hwmod_ocp_if *dra7xx_hwmod_ocp_ifs[] __initdata = {
 	&dra7xx_l4_per1__mmc4,
 	&dra7xx_l4_cfg__mpu,
 	&dra7xx_l4_cfg__ocp2scp1,
+	&dra7xx_l4_cfg__ocp2scp3,
 	&dra7xx_l3_main_1__qspi,
 	&dra7xx_l4_cfg__sata,
 	&dra7xx_l4_cfg__smartreflex_core,
Signature · 1 line
1.7.4.1
#37 lore raw

RFC PATCH 15/15 arm: dts: dra7: add sata node

In reply to Roger Quadros

From: Balaji T K <[email protected]>

Add support for sata controller.

[Roger Q] Clean up.

---
 arch/arm/boot/dts/dra7.dtsi |   49 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
arch/arm/boot/dts/dra7.dtsi +49 -0
index ce9a0f0..545545d 100644
@@ -426,6 +426,55 @@
 			dma-names = "tx", "rx";
 		};
 
+		omap_control_sata: control-phy at 4a002374 {
+			compatible = "ti,control-phy-pipe3";
+			reg = <0x4a002374 0x4>;
+			reg-names = "power";
+			clocks = <&sys_clkin1>;
+			clock-names = "sysclk";
+		};
+
+		ocp2scp3: ocp2scp3 at 4a090000 {
+			compatible = "ti,omap-ocp2scp";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			ti,hwmods = "ocp2scp3";
+			reg = <0x4a090000 0x1f>; /* ocp2scp3 */
+			reg-names = "ocp2scp3";
+			sata_phy: sataphy at 4A096000 {
+				compatible = "ti,phy-pipe3-sata";
+				reg = <0x4A096000 0x80>, /* phy_rx */
+				      <0x4A096400 0x64>, /* phy_tx */
+				      <0x4A096800 0x40>; /* pll_ctrl */
+				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
+				ctrl-module = <&omap_control_sata>;
+				clocks = <&sata_ref_clk>,
+					 <&sys_clkin1>;
+				clock-names = "optclk", "sysclk";
+				#phy-cells = <0>;
+			};
+		};
+
+		sata: sata at 4a141100 {
+			compatible = "ti,sata";
+			ti,hwmods = "sata";
+			reg = <0x4a141100 0x7>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			dwc-ahci at 4a140000 {
+				  compatible = "snps,dwc-ahci";
+				  reg = <0x4a140000 0x1100>;
+				  interrupts = <0 54 0x4>;
+				  phys = <&sata_phy>;
+				  phy-names = "sata-phy";
+				  clocks = <&sata_ref_clk>;
+				  clock-names = "optclk";
+			};
+		};
+
+
 		mcspi1: spi at 48098000 {
 			compatible = "ti,omap4-mcspi";
 			reg = <0x48098000 0x200>;
Signature · 1 line
1.7.4.1
#38 lore raw

Re: [RFC PATCH 15/15] arm: dts: dra7: add sata node

Hello.

Quoted 28 lines · Roger Quadros

From: Balaji T K <[email protected]>

Add support for sata controller.

[Roger Q] Clean up.

---
  arch/arm/boot/dts/dra7.dtsi |   49 +++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 49 insertions(+), 0 deletions(-)
arch/arm/boot/dts/dra7.dtsi +7 -0
index ce9a0f0..545545d 100644
@@ -426,6 +426,55 @@
  			dma-names = "tx", "rx";
  		};
 
+		omap_control_sata: control-phy at 4a002374 {
+			compatible = "ti,control-phy-pipe3";
+			reg = <0x4a002374 0x4>;
+			reg-names = "power";
+			clocks = <&sys_clkin1>;
+			clock-names = "sysclk";
+		};

arch/arm/boot/dts/dra7.dtsi line 445

Quoted 10 lines
arch/arm/boot/dts/dra7.dtsi +10 -0
+
+		ocp2scp3: ocp2scp3 at 4a090000 {
+			compatible = "ti,omap-ocp2scp";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			ti,hwmods = "ocp2scp3";
+			reg = <0x4a090000 0x1f>; /* ocp2scp3 */
+			reg-names = "ocp2scp3";
+			sata_phy: sataphy at 4A096000 {

It's better to name the PHY nodes uniformly after already standard
"ethernet-phy" and your "control-phy".

Quoted 11 lines
arch/arm/boot/dts/dra7.dtsi +11 -0
+				compatible = "ti,phy-pipe3-sata";
+				reg = <0x4A096000 0x80>, /* phy_rx */
+				      <0x4A096400 0x64>, /* phy_tx */
+				      <0x4A096800 0x40>; /* pll_ctrl */
+				reg-names = "phy_rx", "phy_tx", "pll_ctrl";
+				ctrl-module = <&omap_control_sata>;
+				clocks = <&sata_ref_clk>,
+					 <&sys_clkin1>;
+				clock-names = "optclk", "sysclk";
+				#phy-cells = <0>;
+			};

arch/arm/boot/dts/dra7.dtsi line 466

Quoted 10 lines
arch/arm/boot/dts/dra7.dtsi +10 -0
+		};
+
+		sata: sata at 4a141100 {
+			compatible = "ti,sata";
+			ti,hwmods = "sata";
+			reg = <0x4a141100 0x7>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			dwc-ahci at 4a140000 {

Hm, ePAPR spec. [1] says that "the name of a node should be somewhat
generic, reflecting the function of the device and not its precise programming model", so it looks like the name should be "sata" as well. I'm a bit at a loss here, not sure why you had to use the nested device nodes.

arch/arm/boot/dts/dra7.dtsi line 470

Quoted 4 lines
arch/arm/boot/dts/dra7.dtsi +4 -0
+				  compatible = "snps,dwc-ahci";
+				  reg = <0x4a140000 0x1100>;
+				  interrupts = <0 54 0x4>;
+				  phys = <&sata_phy>;

Hm, it's the third PHY related generic property I'm encountering. First,
there was "phy-handle", then "phy", now "phys"... Seems like a bit too much. :-)

arch/arm/boot/dts/dra7.dtsi line 475

Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
+				  phy-names = "sata-phy";
+				  clocks = <&sata_ref_clk>;
+				  clock-names = "optclk";
+			};
+		};

[1] http://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf

#39 lore raw

Re: [RFC PATCH 15/15] arm: dts: dra7: add sata node

Hi,

Quoted 36 lines · Sergei Shtylyov

Hello.

Quoted 32 lines · Roger Quadros

From: Balaji T K <[email protected]>

Add support for sata controller.

[Roger Q] Clean up.

---
  arch/arm/boot/dts/dra7.dtsi |   49 +++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 49 insertions(+), 0 deletions(-)
arch/arm/boot/dts/dra7.dtsi +11 -0
index ce9a0f0..545545d 100644
@@ -426,6 +426,55 @@
              dma-names = "tx", "rx";
          };
 
+        omap_control_sata: control-phy at 4a002374 {
+            compatible = "ti,control-phy-pipe3";
+            reg = <0x4a002374 0x4>;
+            reg-names = "power";
+            clocks = <&sys_clkin1>;
+            clock-names = "sysclk";
+        };
+
+        ocp2scp3: ocp2scp3 at 4a090000 {
+            compatible = "ti,omap-ocp2scp";
+            #address-cells = <1>;
Quoted 8 lines

arch/arm/boot/dts/dra7.dtsi line 445

Quoted 6 lines
arch/arm/boot/dts/dra7.dtsi +6 -0
+            #size-cells = <1>;
+            ranges;
+            ti,hwmods = "ocp2scp3";
+            reg = <0x4a090000 0x1f>; /* ocp2scp3 */
+            reg-names = "ocp2scp3";
+            sata_phy: sataphy at 4A096000 {

It's better to name the PHY nodes uniformly after already standard "ethernet-phy" and your "control-phy".

OK. will fix it to sata-phy.

Quoted 23 lines
Quoted 12 lines
arch/arm/boot/dts/dra7.dtsi +11 -0
+                compatible = "ti,phy-pipe3-sata";
+                reg = <0x4A096000 0x80>, /* phy_rx */
+                      <0x4A096400 0x64>, /* phy_tx */
+                      <0x4A096800 0x40>; /* pll_ctrl */
+                reg-names = "phy_rx", "phy_tx", "pll_ctrl";
+                ctrl-module = <&omap_control_sata>;
+                clocks = <&sata_ref_clk>,
+                     <&sys_clkin1>;
+                clock-names = "optclk", "sysclk";
+                #phy-cells = <0>;
+            };

arch/arm/boot/dts/dra7.dtsi line 466

Quoted 10 lines
arch/arm/boot/dts/dra7.dtsi +10 -0
+        };
+
+        sata: sata at 4a141100 {
+            compatible = "ti,sata";
+            ti,hwmods = "sata";
+            reg = <0x4a141100 0x7>;
+            #address-cells = <1>;
+            #size-cells = <1>;
+            ranges;
+            dwc-ahci at 4a140000 {
Quoted 2 lines

Hm, ePAPR spec. [1] says that "the name of a node should be somewhat generic, reflecting the function of the device and not its precise programming model", so it looks like the name should be "sata" as well. I'm a bit at a loss here, not sure why you had to use the nested device nodes.

ok. will fix it to sata.
I've nested it because the wrapper registers are not part of the AHCI sata controller. They are TI specific registers for power management.
Similar setup is on the USB controller. Please see omap_dwc3 node.

But if you have better idea, please let me know.

Quoted 6 lines

arch/arm/boot/dts/dra7.dtsi line 470

Quoted 4 lines
arch/arm/boot/dts/dra7.dtsi +4 -0
+                  compatible = "snps,dwc-ahci";
+                  reg = <0x4a140000 0x1100>;
+                  interrupts = <0 54 0x4>;
+                  phys = <&sata_phy>;

Hm, it's the third PHY related generic property I'm encountering. First, there was "phy-handle", then "phy", now "phys"... Seems like a bit too much. :-)

I'm afraid but this is how the designers have made it.

1) control-phy-pipe3 is that part of the PHY which sits in control module space and is different from the sata-phy space and hence needs a different node. If it were to me, I would just put this resource in sata-phy node, but there was a discussion about this earlier to do it otherwise [1].

2) sata-phy (sataphy) is the actual SATA PHY device.

3) phys is just a reference to the sata_phy and is used via the generic PHY framework. It is upto the sata driver to power up/down the phy.

Quoted 9 lines

arch/arm/boot/dts/dra7.dtsi line 475

Quoted 6 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
+                  phy-names = "sata-phy";
+                  clocks = <&sata_ref_clk>;
+                  clock-names = "optclk";
+            };
+        };

[1] http://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf

cheers,
-roger

[1] - https://lkml.org/lkml/2012/9/10/399

#40 lore raw

Re: [RFC PATCH 15/15] arm: dts: dra7: add sata node

Quoted 18 lines · Roger Quadros
Quoted 18 lines
Quoted 18 lines

From: Balaji T K <[email protected]>

Add support for sata controller.

[Roger Q] Clean up.

---
   arch/arm/boot/dts/dra7.dtsi |   49 +++++++++++++++++++++++++++++++++++++++++++
   1 files changed, 49 insertions(+), 0 deletions(-)
arch/arm/boot/dts/dra7.dtsi +0 -0
index ce9a0f0..545545d 100644
@@ -426,6 +426,55 @@

[...]

Quoted 4 lines
Quoted 4 lines

arch/arm/boot/dts/dra7.dtsi line 462

Quoted 4 lines
arch/arm/boot/dts/dra7.dtsi +4 -0
+        sata: sata at 4a141100 {
+            compatible = "ti,sata";
+            ti,hwmods = "sata";
+            reg = <0x4a141100 0x7>;
    Not 0x8 BTW?
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
arch/arm/boot/dts/dra7.dtsi +4 -0
+            #address-cells = <1>;
+            #size-cells = <1>;
+            ranges;
+            dwc-ahci at 4a140000 {
Quoted 8 lines
Quoted 1 line

Hm, ePAPR spec. [1] says that "the name of a node should be somewhat generic, reflecting the function of the device and not its precise programming model", so it looks like the name should be "sata" as well. I'm a bit at a loss here, not sure why you had to use the nested device nodes.

ok. will fix it to sata.
I've nested it because the wrapper registers are not part of the AHCI sata controller. They are TI specific registers for power management.
Similar setup is on the USB controller. Please see omap_dwc3 node.

But if you have better idea, please let me know.

Don't know, it seems to me that you're over-complicating it by using the
nested nodes. You could just have AHCI regs as a first tuple of the "regs" prop, and PM regs as a second tuple.

Quoted 9 lines
Quoted 6 lines

arch/arm/boot/dts/dra7.dtsi line 470

Quoted 4 lines
arch/arm/boot/dts/dra7.dtsi +4 -0
+                  compatible = "snps,dwc-ahci";
+                  reg = <0x4a140000 0x1100>;
+                  interrupts = <0 54 0x4>;
+                  phys = <&sata_phy>;

Hm, it's the third PHY related generic property I'm encountering. First, there was "phy-handle", then "phy", now "phys"... Seems like a bit too much. :-)

I'm afraid but this is how the designers have made it.

Quoted 8 lines

1) control-phy-pipe3 is that part of the PHY which sits in control module space and is different from the sata-phy space and hence needs a different node. If it were to me, I would just put this resource in sata-phy node, but there was a discussion about this earlier to do it otherwise [1].

2) sata-phy (sataphy) is the actual SATA PHY device.

3) phys is just a reference to the sata_phy and is used via the generic PHY framework. It is upto the sata driver to power up/down the phy.

I understand that it's a reference but why have 3 variants of such phandle
containing prop? Is it really possible for a device to have multiple PHYs? Well, remembering our customer's USB, it's indeed possible, however, there 2 PHYs out of 3 are not software controllable...

Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
+                  phy-names = "sata-phy";
+                  clocks = <&sata_ref_clk>;
+                  clock-names = "optclk";
+            };
+        };
Quoted 6 lines
Quoted 1 line

[1] http://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf

cheers,
-roger

[1] - https://lkml.org/lkml/2012/9/10/399

WBR, Sergei

#41 lore raw

Re: [RFC PATCH 15/15] arm: dts: dra7: add sata node

Quoted 22 lines · Sergei Shtylyov
Quoted 18 lines · Roger Quadros
Quoted 18 lines
Quoted 18 lines

From: Balaji T K <[email protected]>

Add support for sata controller.

[Roger Q] Clean up.

---
   arch/arm/boot/dts/dra7.dtsi |   49 +++++++++++++++++++++++++++++++++++++++++++
   1 files changed, 49 insertions(+), 0 deletions(-)
arch/arm/boot/dts/dra7.dtsi +0 -0
index ce9a0f0..545545d 100644
@@ -426,6 +426,55 @@

[...]

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

arch/arm/boot/dts/dra7.dtsi line 462

Quoted 4 lines
arch/arm/boot/dts/dra7.dtsi +4 -0
+        sata: sata at 4a141100 {
+            compatible = "ti,sata";
+            ti,hwmods = "sata";
+            reg = <0x4a141100 0x7>;
   Not 0x8 BTW?

You are right. Two 32 bit registers are used.
However, in the instance summary, the reference manual says 256 bytes. So I think we should use 0x100.

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

arch/arm/boot/dts/dra7.dtsi line 466

Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +4 -0
+            #address-cells = <1>;
+            #size-cells = <1>;
+            ranges;
+            dwc-ahci at 4a140000 {

Hm, ePAPR spec. [1] says that "the name of a node should be somewhat generic, reflecting the function of the device and not its precise programming model", so it looks like the name should be "sata" as well. I'm a bit at a loss here, not sure why you had to use the nested device nodes.

Quoted 9 lines
Quoted 6 lines

ok. will fix it to sata.
I've nested it because the wrapper registers are not part of the AHCI sata controller. They are TI specific registers for power management.
Similar setup is on the USB controller. Please see omap_dwc3 node.

But if you have better idea, please let me know.

Don't know, it seems to me that you're over-complicating it by using the nested nodes. You could just have AHCI regs as a first tuple of the "regs" prop, and PM regs as a second tuple.

Yes that is possible, and in fact it was that way in Balaji's original code. However in that case, won't TI specific handling be need to be done in the ahci_platform driver?

As of now, that is limited to using pm_runtime to enable/disable the hardware module so it is generic enough. However in the future it would mean reading/writing to the TI wrapper register. If this can be done in ahci_platform driver then I don't see any issue and can combine the 2 nodes.

Quoted 13 lines
Quoted 12 lines
Quoted 6 lines

arch/arm/boot/dts/dra7.dtsi line 470

Quoted 4 lines
arch/arm/boot/dts/dra7.dtsi +4 -0
+                  compatible = "snps,dwc-ahci";
+                  reg = <0x4a140000 0x1100>;
+                  interrupts = <0 54 0x4>;
+                  phys = <&sata_phy>;

Hm, it's the third PHY related generic property I'm encountering. First, there was "phy-handle", then "phy", now "phys"... Seems like a bit too much. :-)

I'm afraid but this is how the designers have made it.

1) control-phy-pipe3 is that part of the PHY which sits in control module space and is different from the sata-phy space and hence needs a different node. If it were to me, I would just put this resource in sata-phy node, but there was a discussion about this earlier to do it otherwise [1].

Quoted 7 lines
Quoted 4 lines

2) sata-phy (sataphy) is the actual SATA PHY device.

3) phys is just a reference to the sata_phy and is used via the generic PHY framework. It is upto the sata driver to power up/down the phy.

I understand that it's a reference but why have 3 variants of such phandle containing prop? Is it really possible for a device to have multiple PHYs? Well, remembering our customer's USB, it's indeed possible, however, there 2 PHYs out of 3 are not software controllable...

If I understand right, are you asking that we don't need "phy-names" property if there can be only one PHY? I too think it is redundant. Maybe the PHY framework should be modified to allow users to use phy_get() whithout any phy name string. In such case it should return the first PHY.
Kishon, any thoughts?

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

arch/arm/boot/dts/dra7.dtsi line 475

Quoted 5 lines
arch/arm/boot/dts/dra7.dtsi +5 -0
+                  phy-names = "sata-phy";
+                  clocks = <&sata_ref_clk>;
+                  clock-names = "optclk";
+            };
+        };

[1] http://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf

cheers,
-roger