Skip to contentSkip to conversation

ata: Add APM X-Gene SoC 6.0Gbps SATA PHY support

PATCH Superseded Loc Ho 6 participants 22 messages Nov 19, 2013 – Nov 22, 2013

Subsystems (4)

v2 of 18 Superseded Latest is v18 →

lore
Share & tools
lore

Loc Ho

author
#0 lore raw

v2 cover ata: Add APM X-Gene SoC 6.0Gbps SATA PHY support

ata: Add APM X-Gene SoC 6.0Gbps SATA PHY support

This patch adds support for APM X-Gene SoC 6.0Gbps SATA PHY. This is the physical layer interface for the corresponding SATA host controller. This driver uses the new PHY generic framework posted by Kishon Vijay Abrahm. In addition, the new PHY generic framework is patched to provide an function to set the speed of the PHY.

v2
* Remove port knowledge from functions
* Make all functions static
* Remove ID completely
* Make resource requirement based on compatible type
* Rename override PHY parameters with more descriptive name
* Add override PHY parameter for per controller, per port, and per speed
* Patch the generic PHY frame to expose set_speed operation

v1
* Initial version

---
Loc Ho (4):
PHY: Add function set_speed to generic PHY framework
Documentation: Add APM X-Gene SoC 6.0Gbps SATA PHY driver binding
documentation
ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver
arm64: Add APM X-Gene SoC 6.0Gbps SATA PHY DTS entries

 .../devicetree/bindings/ata/apm-xgene-phy.txt      |   61 +
 arch/arm64/boot/dts/apm-storm.dtsi                 |   28 +
 drivers/ata/Kconfig                                |    6 +
 drivers/ata/Makefile                               |    1 +
 drivers/ata/sata_xgene_phy.c                       | 2067 ++++++++++++++++++++
 include/linux/phy/phy.h                            |   22 +
 6 files changed, 2185 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/apm-xgene-phy.txt
 create mode 100644 drivers/ata/sata_xgene_phy.c
author
#1 lore raw

PATCH v2 1/4 PHY: Add function set_speed to generic PHY framework

PHY: Add function set_speed to generic PHY framework

This patch adds function set_speed to the generic PHY framework operation structure. This function can be called to instruct the PHY underlying layer at specified lane to configure for specified speed in hertz.

---
 include/linux/phy/phy.h |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
include/linux/phy/phy.h +22 -0
index 9351a16..df9b1d1 100644
@@ -32,6 +32,7 @@ struct phy;
  * @exit: operation to be performed while exiting
  * @power_on: powering on the phy
  * @power_off: powering off the phy
+ * @set_speed: set operation speed in hz
  * @owner: the module owner containing the ops
  */
 struct phy_ops {
@@ -39,6 +40,7 @@ struct phy_ops {
 	int	(*exit)(struct phy *phy);
 	int	(*power_on)(struct phy *phy);
 	int	(*power_off)(struct phy *phy);
+	int	(*set_speed)(struct phy *phy, int lane, u64 speed);
 	struct module *owner;
 };
 
@@ -341,4 +343,24 @@ out:
 	return ret;
 }
 
+static inline int phy_set_speed(struct phy *phy, int lane, u64 speed)
+{
+	int ret = -ENOTSUPP;
+
+	mutex_lock(&phy->mutex);
+	if (phy->ops->set_speed) {
+		ret =  phy->ops->set_speed(phy, lane, speed);
+		if (ret < 0) {
+			dev_err(&phy->dev, "phy set speed failed --> %d\n",
+				ret);
+			goto out;
+		}
+	}
+
+out:
+	mutex_unlock(&phy->mutex);
+
+	return ret;
+}
+
 #endif /* __DRIVERS_PHY_H */
Signature · 1 line
1.5.5
author
#2 lore raw

PATCH v2 2/4 Documentation: Add APM X-Gene SoC 6.0Gbps SATA PHY driver binding documentation

Documentation: Add APM X-Gene SoC 6.0Gbps SATA PHY driver binding documentation

Document the DTS binding for the X-Gene SoC SATA PHY driver.

---
 .../devicetree/bindings/ata/apm-xgene-phy.txt      |   61 ++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/apm-xgene-phy.txt
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +61 -0
new file mode 100644
index 0000000..bbae164
@@ -0,0 +1,61 @@
+* APM X-Gene 6.0 Gb/s SATA PHY nodes
+
+SATA PHY nodes are defined to describe on-chip Serial ATA PHY. Each SATA PHY
+(pair of PHY) has its own node.
+
+Required properties:
+- compatible		: Shall be "apm,xgene-ahci-phy" or
+			  "apm,xgene-ahci-phy2". The "apm,xgene-ahci-phy"
+			  describes an port shared with SGMII Ethernet port.
+			  The "apm,xgene-ahci-phy2" describes an port not
+			  shared with SGMII and the PLL located at another
+			  memory resource region.
+- reg			: First PHY memory resource
+			  Second separate PHY PLL clock memory resource if
+			  type "apm,xgene-ahci-phy2"
+- #phy-cells		: Shall be 0
+
+Optional properties:
+- status		: Shall be "ok" if enabled or "na" if disabled. Default
+			  is "ok".
+- txeyetuning		: Manual control to fine tune the capture of the serial
+			  bit lines from the automatic calibrated position.
+			  Two set of 3-tuple setting for Gen1, Gen2, and Gen3.
+			  Range from 0 to 0x7f. Default is 0xa.
+- txeyedirection	: Eye tuning manual control direction. 0 means sample
+			  data earlier than the nominal sampling point. 1 means
+			  sample data later than the nominal sampling point.
+			  Two set of 3-tuple setting for Gen1, Gen2, and Gen3.
+			  Default is 0x0.
+- txboostgain		: Frequency boost and DC gain control. Two set of
+			  3-tuple setting for Gen1, Gen2, and Gen3. Range is
+			  between 0 to 0x1f. Default is 0x3.
+- txspeed		: Tx operating speed. Two set of 3-tuple for
+			  Gen1 (0x1), Gen2 (0x3), and Gen3 (0x7). Default is
+			  0x7.
+
+NOTE: PHY override parameters are board specific setting.
+
+Example:
+		sataphy0: sataphy at 1f210000 {
+			compatible = "apm,xgene-ahci-phy";
+			reg = <0x0 0x1f210000 0x0 0x10000>;
+			#phy-cells = <0>;
+			status = "na";
+		};
+
+		sataphy1: sataphy at 1f220000 {
+			compatible = "apm,xgene-ahci-phy";
+			reg = <0x0 0x1f220000 0x0 0x10000>;
+			#phy-cells = <0>;
+			status = "ok";
+		};
+
+		sataphy2: sataphy at 1f230000 {
+			compatible = "apm,xgene-ahci-phy2";
+			reg = <0x0 0x1f230000 0x0 0x10000
+			       0x0 0x1f2d0000 0x0 0x10000 >;
+			#phy-cells = <0>;
+			status = "ok";
+		};
+
Signature · 1 line
1.5.5
author
#3 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

This patch adds support for APM X-Gene SoC 6.0Gbps SATA PHY. This is the physical layer interface for the corresponding SATA host controller. This driver uses the new PHY generic framework posted by Kishon Vijay Abrahm.

---
 drivers/ata/Kconfig          |    6 +
 drivers/ata/Makefile         |    1 +
 drivers/ata/sata_xgene_phy.c | 2067 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 2074 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/sata_xgene_phy.c
drivers/ata/Kconfig +6 -0
index 4e73772..54fa724 100644
@@ -106,6 +106,12 @@ config AHCI_IMX
 
 	  If unsure, say N.
 
+config SATA_XGENE_PHY
+	tristate "APM X-Gene 6.0Gbps SATA PHY support"
+	depends on ARM64 || COMPILE_TEST
+	help
+	  This option enables support for APM X-Gene SoC SATA PHY.
+
 config SATA_FSL
 	tristate "Freescale 3.0Gbps SATA support"
 	depends on FSL_SOC
drivers/ata/Makefile +1 -0
index 46518c6..be53890 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_XGENE_PHY)	+= sata_xgene_phy.o
 
 # SFF w/ custom DMA
 obj-$(CONFIG_PDC_ADMA)		+= pdc_adma.o
drivers/ata/sata_xgene_phy.c new file +2067 -0

2,067 lines not on this page · raw message

Signature · 1 line
1.5.5
author
#4 lore raw

PATCH v2 4/4 arm64: Add APM X-Gene SoC 6.0Gbps SATA PHY DTS entries

arm64: Add APM X-Gene SoC 6.0Gbps SATA PHY DTS entries

This patch adds the DTS entries for the APM X-Gene SoC 6.0Gbps SATA PHY driver. The PHY for controller 0 and 1 are enabled by default.

---
 arch/arm64/boot/dts/apm-storm.dtsi |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
arch/arm64/boot/dts/apm-storm.dtsi +28 -0
index 359d7b6..1d1c8bc 100644
@@ -193,5 +193,33 @@
 			reg = <0x0 0x17000014 0x0 0x100>;
 			mask = <0x1>;
 		};
+
+		sataphy0: sataphy at 1f210000 {
+			compatible = "apm,xgene-ahci-phy";
+			reg = <0x0 0x1f210000 0x0 0x10000>;
+			#phy-cells = <0>;
+			status = "na";
+			txbooster = <0x2 0x2 0x2 0x2 0x2 0x2>;
+			txskew = <0xa 0xa 0xa 0xa 0xa 0xa>;
+		};
+
+		sataphy1: sataphy at 1f220000 {
+			compatible = "apm,xgene-ahci-phy";
+			reg = <0x0 0x1f220000 0x0 0x10000>;
+			#phy-cells = <0>;
+			status = "ok";
+			txbooster = <0x2 0x2 0x2 0x2 0x2 0x2>;
+			txskew = <0xa 0xa 0xa 0x5 0x5 0x5>;
+		};
+
+		sataphy2: sataphy at 1f230000 {
+			compatible = "apm,xgene-ahci-phy2";
+			reg = <0x0 0x1f230000 0x0 0x10000
+			       0x0 0x1f2d0000 0x0 0x10000>;
+			#phy-cells = <0>;
+			status = "ok";
+			txbooster = <0x3 0x3 0x3 0x3 0x3 0x3>;
+			txskew = <0xa 0xa 0xa 0xc 0xc 0xc>;
+		};
 	};
 };
Signature · 1 line
1.5.5
author
#5 lore raw

PATCH v2 4/4 arm64: Add APM X-Gene SoC 6.0Gbps SATA PHY DTS entries

Hi,

arch/arm64/boot/dts/apm-storm.dtsi line 203

Quoted 2 lines
arch/arm64/boot/dts/apm-storm.dtsi +2 -0
+                       txbooster = <0x2 0x2 0x2 0x2 0x2 0x2>;
+                       txskew = <0xa 0xa 0xa 0xa 0xa 0xa>;

[Loc Ho]
These isn't correct. They should be txboostgain and txeyetuning. I will fix these in the next version.

-Loc

#6 lore raw

PATCH v2 4/4 arm64: Add APM X-Gene SoC 6.0Gbps SATA PHY DTS entries

In reply to Loc Ho
Quoted 17 lines · Loc Ho

arm64: Add APM X-Gene SoC 6.0Gbps SATA PHY DTS entries

This patch adds the DTS entries for the APM X-Gene SoC 6.0Gbps SATA PHY driver. The PHY for controller 0 and 1 are enabled by default.

---
 arch/arm64/boot/dts/apm-storm.dtsi |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
arch/arm64/boot/dts/apm-storm.dtsi +0 -0
index 359d7b6..1d1c8bc 100644

arch/arm64/boot/dts/apm-storm.dtsi line 201

Quoted 9 lines
arch/arm64/boot/dts/apm-storm.dtsi +6 -0
@@ -193,5 +193,33 @@
 			reg = <0x0 0x17000014 0x0 0x100>;
 			mask = <0x1>;
 		};
+
+		sataphy0: sataphy at 1f210000 {
+			compatible = "apm,xgene-ahci-phy";
+			reg = <0x0 0x1f210000 0x0 0x10000>;
+			#phy-cells = <0>;
+			status = "na";

s/"na"/"disabled"/g

arch/arm64/boot/dts/apm-storm.dtsi line 212

Quoted 11 lines
arch/arm64/boot/dts/apm-storm.dtsi +11 -0
+			txbooster = <0x2 0x2 0x2 0x2 0x2 0x2>;
+			txskew = <0xa 0xa 0xa 0xa 0xa 0xa>;
+		};
+
+		sataphy1: sataphy at 1f220000 {
+			compatible = "apm,xgene-ahci-phy";
+			reg = <0x0 0x1f220000 0x0 0x10000>;
+			#phy-cells = <0>;
+			status = "ok";
+			txbooster = <0x2 0x2 0x2 0x2 0x2 0x2>;
+			txskew = <0xa 0xa 0xa 0x5 0x5 0x5>;

I don't recall seeing txskew in the binding document or code, but I see you've noticed too.

arch/arm64/boot/dts/apm-storm.dtsi line 218

Quoted 6 lines
arch/arm64/boot/dts/apm-storm.dtsi +6 -0
+		};
+
+		sataphy2: sataphy at 1f230000 {
+			compatible = "apm,xgene-ahci-phy2";
+			reg = <0x0 0x1f230000 0x0 0x10000
+			       0x0 0x1f2d0000 0x0 0x10000>;

Nit: please bracket entries individually:

reg = <0x0 0x1f230000 0x0 0x10000>,

      <0x0 0x1f2d0000 0x0 0x10000>;

Thanks,
Mark.

#7 lore raw

PATCH v2 4/4 arm64: Add APM X-Gene SoC 6.0Gbps SATA PHY DTS entries

In reply to Loc Ho

Hello.

Quoted 17 lines · Loc Ho

arm64: Add APM X-Gene SoC 6.0Gbps SATA PHY DTS entries

This patch adds the DTS entries for the APM X-Gene SoC 6.0Gbps SATA PHY driver. The PHY for controller 0 and 1 are enabled by default.

---
  arch/arm64/boot/dts/apm-storm.dtsi |   28 ++++++++++++++++++++++++++++
  1 files changed, 28 insertions(+), 0 deletions(-)
arch/arm64/boot/dts/apm-storm.dtsi +0 -0
index 359d7b6..1d1c8bc 100644

arch/arm64/boot/dts/apm-storm.dtsi line 197

Quoted 5 lines
arch/arm64/boot/dts/apm-storm.dtsi +2 -0
@@ -193,5 +193,33 @@
  			reg = <0x0 0x17000014 0x0 0x100>;
  			mask = <0x1>;
  		};
+
+		sataphy0: sataphy at 1f210000 {

The nodes should better be named like "sata-phy at 1f210000" to better comply
with the "ethernet-phy" name we see in the ePAPR spec.

WBR, Sergei

#8 lore raw

PATCH v2 4/4 arm64: Add APM X-Gene SoC 6.0Gbps SATA PHY DTS entries

Quoted 11 lines · Sergei Shtylyov

arch/arm64/boot/dts/apm-storm.dtsi line 197

Quoted 8 lines
arch/arm64/boot/dts/apm-storm.dtsi +2 -0
@@ -193,5 +193,33 @@
                      reg = <0x0 0x17000014 0x0 0x100>;
                      mask = <0x1>;
              };
+
+             sataphy0: sataphy at 1f210000 {

The nodes should better be named like "sata-phy at 1f210000" to better comply
with the "ethernet-phy" name we see in the ePAPR spec.

Well, since the phy can be used for other devices, I'd rather name it just "phy", or possibly "serdes". The fact that it happens to be used for sata here should not influence the naming when both the phy driver and the hardware are completely generic.

Arnd

#9 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

In reply to Loc Ho

drivers/ata/sata_xgene_phy.c line 2014

Quoted 4 lines · Loc Ho
drivers/ata/sata_xgene_phy.c new file +4 -0
+
+       sprintf(name, "xgene-ahci-phy-%08X", (u32) ctx->csr_phys);
+       ctx->phy = devm_phy_create(ctx->dev, (u32) ctx->csr_phys,
+                                  &xgene_phy_ops, name);

The devm_phy_create() API has changed, so suggest you make your patch against -next tree.

Thanks,
--
Ming Lei

Signature · 1 line
Ming Lei
author
#10 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

Hi,

I will move to the official GIT for 3.12.00 instead rc7. It is the same as Linux-next GIT.

-Loc

Quoted 15 lines · Ming Lei

drivers/ata/sata_xgene_phy.c line 2014

Quoted 4 lines · Loc Ho
drivers/ata/sata_xgene_phy.c new file +4 -0
+
+       sprintf(name, "xgene-ahci-phy-%08X", (u32) ctx->csr_phys);
+       ctx->phy = devm_phy_create(ctx->dev, (u32) ctx->csr_phys,
+                                  &xgene_phy_ops, name);

The devm_phy_create() API has changed, so suggest you make your patch against -next tree.

Thanks,
--
Ming Lei

--
Ming Lei

#11 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

In reply to Loc Ho

Hi,

Quoted 8 lines · Loc Ho

This patch adds support for APM X-Gene SoC 6.0Gbps SATA PHY. This is the physical layer interface for the corresponding SATA host controller. This driver uses the new PHY generic framework posted by Kishon Vijay Abrahm.

---

As a general note, this patch is very difficult to review.

There are a large number of macros for accessing bits of registers, vast swathes of register reads and writes which all look very similar, and while I suspect could be factored out further into more descriptive helpers I don't know enough about the hardware to even figure out if any of it is correct as it stands.

Many of the comments provide little to no information, and comments next to variables seem to be just the variable name with additional spaces.

There are a few inconsistencies in style which are simply jarring (e.g. randomly jumping between lower case and upper case in prints, using different loop structures when repeatedly performing an action for calibration), and preferably would be more uniform.

[...]

drivers/ata/sata_xgene_phy.c line 567

Quoted 6 lines
drivers/ata/sata_xgene_phy.c new file +6 -0
+struct xgene_ahci_phy_ctx {
+       struct device *dev;
+       struct phy *phy;
+       u64 csr_phys;           /* Physical address of PHY CSR base addr */
+       void *csr_base;         /* PHY CSR base addr */
+       void *pcie_base;        /* PHY CSR base addr with PCIE clock macro */

Should these not have an __iomem annotation? Elsewhere too...

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+
+       /* Override Serdes parameters */
+       u32 speed[MAX_CHANNEL]; /* Index for override parameter per channel */
+       u32 txspeed[3];         /* Tx speed */
+       u32 txboostgain[MAX_CHANNEL*3]; /* Tx freq boost and gain control */
+       u32 txeyetuning[MAX_CHANNEL*3]; /* Tx eye tuning */
+       u32 txeyedirection[MAX_CHANNEL*3]; /* Tx eye tuning direction */
+};
+
+/* Manual calibration is required for chip that is earlier than A3.

drivers/ata/sata_xgene_phy.c line 587

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+   To enable, pass boot argument sata_xgene_phy.manual=1 */
+static int enable_manual_cal;
+MODULE_PARM_DESC(manual, "Enable manual calibration (1=enable 0=disable)");
+module_param_named(manual, enable_manual_cal, int, 0444);
+
+static void phy_rd(void *addr, u32 *val)
+{
+       *val = readl(addr);
+#if defined(XGENE_DBG1_CSR)
+       pr_debug("SATAPHY CSR RD: 0x%p value: 0x%08x\n", addr, *val);

Can you not use dev_dbg here as you do elsehere?

Either that or make your own debug print function, with the ifdefs hidden in its definition.

[...]

drivers/ata/sata_xgene_phy.c line 605

Quoted 7 lines
drivers/ata/sata_xgene_phy.c new file +7 -0
+static void phy_wr_flush(void *addr, u32 val)
+{
+       writel(val, addr);
+#if defined(XGENE_DBG1_CSR)
+       pr_debug("SATAPHY CSR WR: 0x%p value: 0x%08x\n", addr, val);
+#endif
+       val = readl(addr);      /* Force an barrier */

Nit: s/an barrier/a barrier/g

Quoted 6 lines
drivers/ata/sata_xgene_phy.c new file +6 -0
+}
+
+static void serdes_wr(void *csr_base, u32 indirect_cmd_reg,
+                     u32 indirect_data_reg, u32 addr, u32 data)
+{
+       u32 val;

drivers/ata/sata_xgene_phy.c line 621

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+       u32 cmd;
+
+       cmd = CFG_IND_WR_CMD_MASK | CFG_IND_CMD_DONE_MASK;
+       cmd = (addr << 4) | cmd;
+       phy_wr(csr_base + indirect_data_reg, data);
+       phy_rd(csr_base + indirect_data_reg, &val); /* Force a barrier */
+       phy_wr(csr_base + indirect_cmd_reg, cmd);
+       phy_rd(csr_base + indirect_cmd_reg, &val); /* Force a barrier */
+       /* Add an barrier - very important please don't remove */
+       mb();

Why? Either justify this or remove it.

[...]

drivers/ata/sata_xgene_phy.c line 642

Quoted 12 lines
drivers/ata/sata_xgene_phy.c new file +12 -0
+static void serdes_rd(void *csr_base, u32 indirect_cmd_reg,
+                     u32 indirect_data_reg, u32 addr, u32 *data)
+{
+       u32 val;
+       u32 cmd;
+
+       cmd = CFG_IND_RD_CMD_MASK | CFG_IND_CMD_DONE_MASK;
+       cmd = (addr << 4) | cmd;
+       phy_wr(csr_base + indirect_cmd_reg, cmd);
+       phy_rd(csr_base + indirect_cmd_reg, &val); /* Force a barrier */
+       /* Add an barrier - very important please don't remove */
+       mb();

Why? Please justify why I shouldn't just remove it.

Review

Quoted 2 lines
(quoted diff) +2 -0
+       /* Ignore one read */
+       phy_rd(csr_base + indirect_cmd_reg, &val);

Why?

[...]

Quoted 31 lines
drivers/ata/sata_xgene_phy.c new file +31 -0
+static int xgene_phy_cal_rdy_check(void *csr_serdes,
+                                  void (*serdes_rd) (void *, u32, u32 *),
+                                  void (*serdes_wr) (void *, u32, u32),
+                                  void (*serdes_toggle1to0) (void *, u32, u32))
+{
+       int loopcount;
+       u32 val;
+
+       if (!enable_manual_cal)
+               goto skip_manual_cal;
+
+       /* TERM CALIBRATION CH0 */
+       serdes_rd(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG17_ADDR, &val);
+       val = CMU_REG17_PVT_CODE_R2A_SET(val, 0x12);
+       val = CMU_REG17_RESERVED_7_SET(val, 0x0);
+       serdes_wr(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG17_ADDR, val);
+       serdes_toggle1to0(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG17_ADDR,
+                       CMU_REG17_PVT_TERM_MAN_ENA_MASK);
+       /* DOWN CALIBRATION CH0 */
+       serdes_rd(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG17_ADDR, &val);
+       val = CMU_REG17_PVT_CODE_R2A_SET(val, 0x26);
+       val = CMU_REG17_RESERVED_7_SET(val, 0x0);
+       serdes_wr(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG17_ADDR, val);
+       serdes_toggle1to0(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG16_ADDR,
+                       CMU_REG16_PVT_DN_MAN_ENA_MASK);
+       /* UP CALIBRATION CH0 */
+       serdes_rd(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG17_ADDR, &val);
+       val = CMU_REG17_PVT_CODE_R2A_SET(val, 0x28);
+       val = CMU_REG17_RESERVED_7_SET(val, 0x0);
+       serdes_wr(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG17_ADDR, val);
+       serdes_toggle1to0(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG16_ADDR,

drivers/ata/sata_xgene_phy.c line 783

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+                       CMU_REG16_PVT_UP_MAN_ENA_MASK);
+
+skip_manual_cal:
+       /* Check PLL calibration for 10ms */
+       loopcount = 50;
+       do {
+               serdes_rd(csr_serdes, KC_CLKMACRO_CMU_REGS_CMU_REG7_ADDR, &val);
+               if (CMU_REG7_PLL_CALIB_DONE_RD(val))
+                       return 0;
+               udelay(200); /* No need to poll faster than 200 us */

Why? Does the hardware take that long to respond? If so, mention that.

drivers/ata/sata_xgene_phy.c line 786

Quoted 3 lines
drivers/ata/sata_xgene_phy.c new file +3 -0
+       } while (!CMU_REG7_PLL_CALIB_DONE_RD(val) && --loopcount > 0);
+
+       return -1;

The return value never seems to be used by callers. If this fails, how bad is it to continue as if this had succeeded?

[...]

Quoted 11 lines
drivers/ata/sata_xgene_phy.c new file +11 -0
+/* SATA port macro configuration */
+static int xgene_phy_sata_macro_cfg(struct xgene_ahci_phy_ctx *ctx)
+{
+       void *csr_serdes = ctx->csr_base + SATA_SERDES_OFFSET;
+       int calib_loop_count = 0;
+       u32 val;
+
+       phy_rd(csr_serdes + SATA_ENET_CLK_MACRO_REG_ADDR, &val);
+       val = I_RESET_B_SET(val, 0x0);
+       val = I_PLL_FBDIV_SET(val, 0x27);
+       val = I_CUSTOMEROV_SET(val, 0x0);

drivers/ata/sata_xgene_phy.c line 955

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+       phy_wr(csr_serdes + SATA_ENET_CLK_MACRO_REG_ADDR, val);
+
+       xgene_phy_macro_cfg(csr_serdes, sds_rd, sds_wr, 1 /* 100MHz ref */);
+
+       phy_rd(csr_serdes + SATA_ENET_CLK_MACRO_REG_ADDR, &val);
+       val = I_RESET_B_SET(val, 0x1);
+       val = I_CUSTOMEROV_SET(val, 0x0);
+       phy_wr(csr_serdes + SATA_ENET_CLK_MACRO_REG_ADDR, val);
+
+       mb();

Please comment all barriers with a description of why they are necessary.

drivers/ata/sata_xgene_phy.c line 961

Quoted 6 lines
drivers/ata/sata_xgene_phy.c new file +6 -0
+
+       while (++calib_loop_count <= 5) {
+               if (xgene_phy_macro_cal_rdy_chk(ctx) == 0)
+                       break;
+               xgene_phy_macro_pdwn_force_vco(ctx);
+       }

Why 5 times? Does the hardware take some time to respond? I didn't spot any explicitly delays in the callees.

drivers/ata/sata_xgene_phy.c line 967

Quoted 6 lines
drivers/ata/sata_xgene_phy.c new file +6 -0
+       if (calib_loop_count > 5) {
+               dev_err(ctx->dev, "Clock macro PLL not ready...\n");
+               return -1;
+       }
+       phy_rd(csr_serdes + SATA_ENET_CLK_MACRO_REG_ADDR, &val);
+       dev_dbg(ctx->dev, "Clock macro PLL %sLOOKED...\n",

Perhaps "locked"?

drivers/ata/sata_xgene_phy.c line 970

Quoted 3 lines
drivers/ata/sata_xgene_phy.c new file +3 -0
+               O_PLL_LOCK_RD(val) ? "" : "UN");
+       dev_dbg(ctx->dev, "Clock macro PLL %sREADY...\n",
+               O_PLL_READY_RD(val) ? "" : "NOT");

Why is part of this in UPPERCASE?

[...]

drivers/ata/sata_xgene_phy.c line 1002

Quoted 2 lines
drivers/ata/sata_xgene_phy.c new file +2 -0
+       xgene_phy_macro_cfg(pcie_base, sds_pcie_rd, sds_pcie_wr,
+                           0 /* 50Mhz clock */);

The fact that you have a comment on each call to xgene_phy_macro_cfg shows that the prototype can be improved. Take a flags parameter instead of the ref_100MHz parameter, and have some defines like PHY_CLK_50MHZ and PHY_CLK_100MHZ. That will make things much clearer.

drivers/ata/sata_xgene_phy.c line 1011

Quoted 9 lines
drivers/ata/sata_xgene_phy.c new file +9 -0
+
+       phy_rd(pcie_base + SM_PCIE_X8_SDS_CSR_REGS_PCIE_CLK_MACRO_REG_ADDR,
+              &val);
+       val = PCIE_CLK_MACRO_REG_I_RESET_B_SET(val, 0x1);
+       val = PCIE_CLK_MACRO_REG_I_CUSTOMEROV_SET(val, 0x0);
+       phy_wr(pcie_base + SM_PCIE_X8_SDS_CSR_REGS_PCIE_CLK_MACRO_REG_ADDR,
+              val);
+
+       mb();

Why?

drivers/ata/sata_xgene_phy.c line 1019

Quoted 8 lines
drivers/ata/sata_xgene_phy.c new file +8 -0
+
+       /* Check for 5 times */
+       calib_loop_count = 5;
+       do {
+               if (xgene_phy_pcie_macro_cal_rdy_chk(ctx) == 0)
+                       break;
+               xgene_phy_pcie_macro_pdwn_force_vco(ctx);
+       } while (--calib_loop_count > 0);

Why 5 times?

drivers/ata/sata_xgene_phy.c line 1029

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+       if (calib_loop_count <= 0) {
+               dev_err(ctx->dev, "Clock macro PLL failed\n");
+               return -1;
+       }
+       phy_rd(pcie_base + SM_PCIE_X8_SDS_CSR_REGS_PCIE_CLK_MACRO_REG_ADDR,
+              &val);
+       dev_dbg(ctx->dev, "Clock macro PLL %sLOOKED...\n",
+                PCIE_CLK_MACRO_REG_O_PLL_LOCK_RD(val) ? "" : "UN");
+       dev_dbg(ctx->dev, "Clock macro PLL %sREADY...\n",
+                PCIE_CLK_MACRO_REG_O_PLL_READY_RD(val) ? "" : "NOT ");

Again, why does the sentence suddenly switch to UPPERCASE?

[...]

Quoted 43 lines
drivers/ata/sata_xgene_phy.c new file +43 -0
+static void xgene_phy_force_lat_summer_cal(struct xgene_ahci_phy_ctx *ctx,
+                                          int channel)
+{
+       void *csr_base = ctx->csr_base + SATA_SERDES_OFFSET;
+       u32 os = channel * 0x200;
+       int i;
+       struct {
+               u32 reg;
+               u32 val;
+       } serdes_reg[] = {
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG38_ADDR, 0x0},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG39_ADDR, 0xff00},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG40_ADDR, 0xffff},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG41_ADDR, 0xffff},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG42_ADDR, 0xffff},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG43_ADDR, 0xffff},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG44_ADDR, 0xffff},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG45_ADDR, 0xffff},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG46_ADDR, 0xffff},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG47_ADDR, 0xfffc},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG48_ADDR, 0x0},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG49_ADDR, 0x0},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG50_ADDR, 0x0},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG51_ADDR, 0x0},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG52_ADDR, 0x0},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG53_ADDR, 0x0},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG54_ADDR, 0x0},
+               {KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG55_ADDR, 0x0},
+               {0, 0x0},
+       };
+
+       /* SUMMER CALIBRATION CH0/CH1 */
+       /* SUMMER calib toggle CHX */
+       sds_toggle1to0(csr_base,
+                      KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG127_ADDR + os,
+                      CH0_RXTX_REG127_FORCE_SUM_CAL_START_MASK);
+       /* latch calib toggle CHX */
+       sds_toggle1to0(csr_base,
+                      KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG127_ADDR + os,
+                      CH0_RXTX_REG127_FORCE_LAT_CAL_START_MASK);
+       /* CHX */
+       sds_wr(csr_base, KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG28_ADDR + os, 0x7);
+       sds_wr(csr_base, KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG31_ADDR + os,

drivers/ata/sata_xgene_phy.c line 1138

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+              0x7e00);
+
+       sds_clrbits(csr_base, KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG4_ADDR + os,
+                   CH0_RXTX_REG4_TX_LOOPBACK_BUF_EN_MASK);
+       sds_clrbits(csr_base, KC_SERDES_X2_RXTX_REGS_CH0_RXTX_REG7_ADDR + os,
+                   CH0_RXTX_REG7_LOOP_BACK_ENA_CTLE_MASK);
+
+       /* RXTX_REG38-55 */
+       for (i = 0; serdes_reg[i].reg != 0; i++)
+               sds_wr(csr_base, serdes_reg[i].reg + os, serdes_reg[i].val);

As the size is well known in advance, why not use ARRAY_SIZE rather than having a terminating element:

for (i = 0; i < ARRAY_SIZE(serdes_reg); i++)

	sds_wr(...);

[...]

drivers/ata/sata_xgene_phy.c line 1159

Quoted 4 lines
drivers/ata/sata_xgene_phy.c new file +4 -0
+static void xgene_phy_gen_avg_val(struct xgene_ahci_phy_ctx *ctx, int channel)
+{
+       void *csr_serdes_base = ctx->csr_base + SATA_SERDES_OFFSET;
+       int avg_loop = 10;

What is value meant to mean? How was it derived?

Quoted 1 line

+ int MAX_LOOP = 10;

Why UPPERCASE?

That violates the principle of least surprise, I'd expect a name in uppercase to be a #defined value.

[...]

Quoted 1 line

+ dev_dbg(ctx->dev, "Interation Value: %d\n", avg_loop);

s/Interation/Iteration/g

Even then, why not just say something like "took %d loops to ${DO THING}"?

[...]

drivers/ata/sata_xgene_phy.c line 1662

Quoted 8 lines
drivers/ata/sata_xgene_phy.c new file +8 -0
+skip_manual_cal:
+       /* Check for 10 ms */
+       loopcount = 50;
+       do {
+               sds_rd(csr_serdes, KC_SERDES_CMU_REGS_CMU_REG7_ADDR, &val);
+               if (CMU_REG7_PLL_CALIB_DONE_RD(val))
+                       break;
+               udelay(200);    /* No need to poll more than 200 us */

Please comment _why_ there's no need.

Quoted 7 lines
drivers/ata/sata_xgene_phy.c new file +7 -0
+       } while (--loopcount > 0);
+
+       sds_rd(csr_serdes, KC_SERDES_CMU_REGS_CMU_REG7_ADDR, &val);
+       if (CMU_REG7_PLL_CALIB_DONE_RD(val) == 1)
+               dev_dbg(ctx->dev, "PLL calibration done\n");
+       if (CMU_REG7_VCO_CAL_FAIL_RD(val) == 0x0) {
+               dev_dbg(ctx->dev, "PLL calibration successful\n");

drivers/ata/sata_xgene_phy.c line 1679

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+       } else {
+               /* Assert SDS reset and recall calib function */
+               dev_err(ctx->dev,
+                       "PLL calibration failed due to VCO failure\n");
+               return -1;
+       }
+
+       dev_dbg(ctx->dev, "Checking TX ready\n");
+       sds_rd(csr_serdes, KC_SERDES_CMU_REGS_CMU_REG15_ADDR, &val);
+       dev_dbg(ctx->dev, "PHY TX is %sready\n", val & 0x300 ? "" : "NOT ");

Now we have MIXED case; why?

[...]

drivers/ata/sata_xgene_phy.c line 1823

Quoted 6 lines
drivers/ata/sata_xgene_phy.c new file +6 -0
+       phy_rd(csr_serdes_base + SATA_ENET_SDS_PCS_CTL0_ADDR, &val);
+       val = REGSPEC_CFG_I_RX_WORDMODE0_SET(val, 0x3);
+       val = REGSPEC_CFG_I_TX_WORDMODE0_SET(val, 0x3);
+       phy_wr(csr_serdes_base + SATA_ENET_SDS_PCS_CTL0_ADDR, val);
+
+       mb();

Why?

drivers/ata/sata_xgene_phy.c line 1835

Quoted 12 lines
drivers/ata/sata_xgene_phy.c new file +12 -0
+
+       calib_loop_count = 10;
+       do {
+               rc = xgene_phy_cal_rdy_chk(ctx);
+               if (rc == 0)
+                       break;
+               xgene_phy_pdwn_force_vco(ctx);
+       } while (++calib_loop_count > 0);
+       if (calib_loop_count <= 0) {
+               dev_err(ctx->dev, "PLL calibration failed\n");
+               return -ENODEV;
+       }

This loop and check are broken. Because calib_loop_count is signed, overflow is undefined behaviour. As calib_loop_count initialised to 10, and then only incremented, the only was it could become less than zero is upon overflow.

Perhaps this should be calib_loop_count--, and then a test for calib_loop_count > 0.

drivers/ata/sata_xgene_phy.c line 1870

Quoted 6 lines
drivers/ata/sata_xgene_phy.c new file +6 -0
+static int xgene_ahci_phy_hw_init(struct phy *phy)
+{
+       struct xgene_ahci_phy_ctx *ctx = phy_get_drvdata(phy);
+       int rc;
+
+       rc = xgene_phy_init(ctx, SATA_CLK_EXT_DIFF, 0 /* SSC */);

It would be far nicer to make the call tell you everything you need to know about the arguments, rather than adding comments inside the call.

drivers/ata/sata_xgene_phy.c line 1910

Quoted 9 lines
drivers/ata/sata_xgene_phy.c new file +9 -0
+static int xgene_ahci_phy_power_on(struct phy *phy)
+{
+       return 0;
+}
+
+static int xgene_ahci_phy_power_off(struct phy *phy)
+{
+       return 0;
+}

I'm not entirely familiar with the PHY framework, but it seems odd to have these if they do nothing. Are there no regulators / resets / gpios to poke, registers to reset to sane values?

drivers/ata/sata_xgene_phy.c line 1934

Quoted 7 lines
drivers/ata/sata_xgene_phy.c new file +7 -0
+static void xgene_ahci_phy_get_param(struct platform_device *pdev,
+       const char *name, u32 *buffer, int count, u32 default_val)
+{
+       int rc;
+       int i;
+       rc = of_property_read_u32_array(pdev->dev.of_node, name, buffer,
+                                       count);

Why not return here if !rc? Then you don't need to indent the next statement.

Quoted 6 lines
drivers/ata/sata_xgene_phy.c new file +6 -0
+       if (rc) {
+               for (i = 0; i < count; i++)
+                       buffer[i] = default_val;
+       }
+}
+

drivers/ata/sata_xgene_phy.c line 1950

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+static int xgene_ahci_phy_probe(struct platform_device *pdev)
+{
+       struct phy_provider *phy_provider;
+       struct xgene_ahci_phy_ctx *ctx;
+       struct resource *res;
+       char name[80];
+       int rc = 0;
+
+       if (!of_device_is_available(pdev->dev.of_node))
+               return -ENODEV;

I was under the impression the standard bus types already checked the device was available, and would not allocate a device for those which were not. From a glance at drivers/of/platform.c, it seems this line is unnecessary.

drivers/ata/sata_xgene_phy.c line 1998

Quoted 9 lines
drivers/ata/sata_xgene_phy.c new file +9 -0
+       /* Load override paramaters */
+       xgene_ahci_phy_get_param(pdev, "txeyetuning", ctx->txeyetuning, 6,
+                                DEFAULT_TXEYETUNING);
+       xgene_ahci_phy_get_param(pdev, "txeyedirection", ctx->txeyedirection,
+                                6, DEFAULT_TXEYEDIRECTION);
+       xgene_ahci_phy_get_param(pdev, "txboostgain", ctx->txboostgain, 6,
+                                DEFAULT_TXBOOST_GAIN);
+       xgene_ahci_phy_get_param(pdev, "txspeed", ctx->txspeed, 3,
+                                DEFAULT_SPD_SEL);

Further to my comments on the binding, these should probably also be prefixed with "apm,".

Quoted 4 lines
drivers/ata/sata_xgene_phy.c new file +4 -0
+       ctx->speed[0] = 2;      /* Default to Gen3 for channel 0 */
+       ctx->speed[1] = 2;      /* Default to Gen3 for channel 1 */
+
+       ctx->dev = &pdev->dev;

drivers/ata/sata_xgene_phy.c line 2012

Quoted 10 lines
drivers/ata/sata_xgene_phy.c new file +10 -0
+       platform_set_drvdata(pdev, ctx);
+
+       phy_provider = devm_of_phy_provider_register(ctx->dev,
+                                                    xgene_ahci_phy_xlate);
+       if (IS_ERR(phy_provider)) {
+               rc = PTR_ERR(phy_provider);
+               goto error;
+       }
+
+       sprintf(name, "xgene-ahci-phy-%08X", (u32) ctx->csr_phys);

Why cap this to 32 bits if this going to appear on a 64-bit system?

drivers/ata/sata_xgene_phy.c line 2014

Quoted 2 lines
drivers/ata/sata_xgene_phy.c new file +2 -0
+       ctx->phy = devm_phy_create(ctx->dev, (u32) ctx->csr_phys,
+                                  &xgene_phy_ops, name);

Likewise, this looks odd.

Thanks,
Mark.

#12 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

Quoted 11 lines · On Wednesday 20 November 2013 11:37:05 Mark Rutland wrote:

drivers/ata/sata_xgene_phy.c line 587

Quoted 5 lines
drivers/ata/sata_xgene_phy.c new file +5 -0
+static void phy_rd(void *addr, u32 *val)
+{
+       *val = readl(addr);
+#if defined(XGENE_DBG1_CSR)
+       pr_debug("SATAPHY CSR RD: 0x%p value: 0x%08x\n", addr, *val);

Can you not use dev_dbg here as you do elsehere?

Either that or make your own debug print function, with the ifdefs hidden in its definition.

pr_debug() is already conditional on #ifdef DEBUG, the extra #if can just get removed here.

Arnd

#13 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

In reply to Loc Ho

Hey, guys.

Quoted 3 lines · Loc Ho

This patch adds support for APM X-Gene SoC 6.0Gbps SATA PHY. This is the physical layer interface for the corresponding SATA host controller. This driver uses the new PHY generic framework posted by Kishon Vijay Abrahm.

Hmm... this is related to ahci but isn't even a libata driver and is the first such driver proposed. Are we sure drivers/ata is the best home for this? Shouldn't we create a separate directory somewhere? It's confusing, at least to me, to have non-libata driver under drivers/ata.

Thanks.

Signature · 1 line
tejun
#14 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

Quoted 10 lines · Tejun Heo
Quoted 3 lines · Loc Ho

This patch adds support for APM X-Gene SoC 6.0Gbps SATA PHY. This is the physical layer interface for the corresponding SATA host controller. This driver uses the new PHY generic framework posted by Kishon Vijay Abrahm.

Hmm... this is related to ahci but isn't even a libata driver and is the first such driver proposed. Are we sure drivers/ata is the best home for this? Shouldn't we create a separate directory somewhere? It's confusing, at least to me, to have non-libata driver under drivers/ata.

It needs to be in drivers/phy, which is currently being prepared for the next merge window and which contains the generic interface used in this driver.

Arnd

#15 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

Hello, Arnd.

Quoted 3 lines · Arnd Bergmann

It needs to be in drivers/phy, which is currently being prepared for the next merge window and which contains the generic interface used in this driver.

Ah, cool, so I don't need to worry about this one, right?

Thanks a lot. :)

Signature · 1 line
tejun
#16 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

Quoted 6 lines · Tejun Heo
Quoted 3 lines · Arnd Bergmann

It needs to be in drivers/phy, which is currently being prepared for the next merge window and which contains the generic interface used in this driver.

Ah, cool, so I don't need to worry about this one, right?

Right, we just need to make sure the patches are staged the right way when they go through different subsystem maintainers. There should not be any build-time dependencies, so I think it won't be an issue.

Arnd

author
#17 lore raw

PATCH v2 3/4 ata: add APM X-Gene SoC 6.0Gbps SATA PHY driver

In reply to Arnd Bergmann

Hi,

Quoted 12 lines · Tejun Heo
Quoted 10 lines · Loc Ho
Quoted 3 lines

This patch adds support for APM X-Gene SoC 6.0Gbps SATA PHY. This is the physical layer interface for the corresponding SATA host controller. This driver uses the new PHY generic framework posted by Kishon Vijay Abrahm.

Hmm... this is related to ahci but isn't even a libata driver and is the first such driver proposed. Are we sure drivers/ata is the best home for this? Shouldn't we create a separate directory somewhere? It's confusing, at least to me, to have non-libata driver under drivers/ata.

Quoted 3 lines

It needs to be in drivers/phy, which is currently being prepared for the next merge window and which contains the generic interface used in this driver.

[Loc Ho]
I will move it to drivers/phy. The PHY framework did make it to the final release of 3.12.00.

-Loc

#18 lore raw

PATCH v2 2/4 Documentation: Add APM X-Gene SoC 6.0Gbps SATA PHY driver binding documentation

In reply to Loc Ho
Quoted 20 lines · Loc Ho

Documentation: Add APM X-Gene SoC 6.0Gbps SATA PHY driver binding documentation

Document the DTS binding for the X-Gene SoC SATA PHY driver.

---
 .../devicetree/bindings/ata/apm-xgene-phy.txt      |   61 ++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/apm-xgene-phy.txt
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +2 -0
new file mode 100644
index 0000000..bbae164
@@ -0,0 +1,61 @@
+* APM X-Gene 6.0 Gb/s SATA PHY nodes
+

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 12

Quoted 10 lines
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +10 -0
+SATA PHY nodes are defined to describe on-chip Serial ATA PHY. Each SATA PHY
+(pair of PHY) has its own node.
+
+Required properties:
+- compatible		: Shall be "apm,xgene-ahci-phy" or
+			  "apm,xgene-ahci-phy2". The "apm,xgene-ahci-phy"
+			  describes an port shared with SGMII Ethernet port.
+			  The "apm,xgene-ahci-phy2" describes an port not
+			  shared with SGMII and the PLL located at another
+			  memory resource region.

Is there not a better name available than "apm,xgene-ahci-phy2"?

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 15

Quoted 3 lines
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +3 -0
+- reg			: First PHY memory resource
+			  Second separate PHY PLL clock memory resource if
+			  type "apm,xgene-ahci-phy2"

Is ths PLL actually part of the PHY, or does it just feed the PHY?

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 20

Quoted 5 lines
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +5 -0
+- #phy-cells		: Shall be 0
+
+Optional properties:
+- status		: Shall be "ok" if enabled or "na" if disabled. Default
+			  is "ok".

Do not use "na", use the standard "disabled".

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 24

Quoted 4 lines
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +4 -0
+- txeyetuning		: Manual control to fine tune the capture of the serial
+			  bit lines from the automatic calibrated position.
+			  Two set of 3-tuple setting for Gen1, Gen2, and Gen3.
+			  Range from 0 to 0x7f. Default is 0xa.

If you have a property for which the name consists of multiple words, split the words with '-'.

What does this actually mean?

What units are these values in?

What effect do those values have?

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 29

Quoted 5 lines
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +5 -0
+- txeyedirection	: Eye tuning manual control direction. 0 means sample
+			  data earlier than the nominal sampling point. 1 means
+			  sample data later than the nominal sampling point.
+			  Two set of 3-tuple setting for Gen1, Gen2, and Gen3.
+			  Default is 0x0.

Likewise, use '-'.

s/than/then/ ?

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 32

Quoted 3 lines
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +3 -0
+- txboostgain		: Frequency boost and DC gain control. Two set of
+			  3-tuple setting for Gen1, Gen2, and Gen3. Range is
+			  between 0 to 0x1f. Default is 0x3.

Use '-'.

What units are these values in?

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 35

Quoted 3 lines
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +3 -0
+- txspeed		: Tx operating speed. Two set of 3-tuple for
+			  Gen1 (0x1), Gen2 (0x3), and Gen3 (0x7). Default is
+			  0x7.

Units?

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 44

Quoted 9 lines
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +9 -0
+
+NOTE: PHY override parameters are board specific setting.
+
+Example:
+		sataphy0: sataphy at 1f210000 {
+			compatible = "apm,xgene-ahci-phy";
+			reg = <0x0 0x1f210000 0x0 0x10000>;
+			#phy-cells = <0>;
+			status = "na";

Please eradicate all instances of "na".

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 57

Quoted 13 lines
Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +13 -0
+		};
+
+		sataphy1: sataphy at 1f220000 {
+			compatible = "apm,xgene-ahci-phy";
+			reg = <0x0 0x1f220000 0x0 0x10000>;
+			#phy-cells = <0>;
+			status = "ok";
+		};
+
+		sataphy2: sataphy at 1f230000 {
+			compatible = "apm,xgene-ahci-phy2";
+			reg = <0x0 0x1f230000 0x0 0x10000
+			       0x0 0x1f2d0000 0x0 0x10000 >;

Nit: bracket list entries individually, and don't apply random spacing:

reg = <0x0 0x1f230000 0x0 0x10000>,

      <0x0 0x1f2d0000 0x0 0x10000>;

Thanks,
Mark.

author
#19 lore raw

PATCH v2 2/4 Documentation: Add APM X-Gene SoC 6.0Gbps SATA PHY driver binding documentation

Hi,

Quoted 8 lines

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 12

Quoted 6 lines

+- compatible : Shall be "apm,xgene-ahci-phy" or

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +5 -0
+                       "apm,xgene-ahci-phy2". The "apm,xgene-ahci-phy"
+                       describes an port shared with SGMII Ethernet port.
+                       The "apm,xgene-ahci-phy2" describes an port not
+                       shared with SGMII and the PLL located at another
+                       memory resource region.

Is there not a better name available than "apm,xgene-ahci-phy2"?

[Loc Ho]
I will name it apm,xgene-ahci-phyx.

Quoted 5 lines

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 15

Quoted 3 lines

+- reg : First PHY memory resource

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +2 -0
+                       Second separate PHY PLL clock memory resource if
+                       type "apm,xgene-ahci-phy2"

Is ths PLL actually part of the PHY, or does it just feed the PHY?

[Loc Ho]
This is always the PLL clock macro in each IP. For the 3rd controller, we require an extra clock macro and can NOT use the original clock macro as it is not mux'ed with the SGMII port.

Quoted 6 lines

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 24

Quoted 5 lines

+- txeyetuning : Manual control to fine tune the capture of the serial

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +3 -0
+                       bit lines from the automatic calibrated position.
+                       Two set of 3-tuple setting for Gen1, Gen2, and Gen3.
+                       Range from 0 to 0x7f. Default is 0xa.
Quoted 8 lines

If you have a property for which the name consists of multiple words, split the words with '-'.

What does this actually mean?

What units are these values in?

What effect do those values have?

[Loc Ho]
Will provide in next version.

Quoted 10 lines

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 29

Quoted 6 lines

+- txeyedirection : Eye tuning manual control direction. 0 means sample

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +4 -0
+                       data earlier than the nominal sampling point. 1 means
+                       sample data later than the nominal sampling point.
+                       Two set of 3-tuple setting for Gen1, Gen2, and Gen3.
+                       Default is 0x0.

Likewise, use '-'.

s/than/then/ ?

[Loc Ho]
I believe that than is appropriate here a we are doing an comparison.

-Loc

#20 lore raw

PATCH v2 2/4 Documentation: Add APM X-Gene SoC 6.0Gbps SATA PHY driver binding documentation

Quoted 17 lines · Loc Ho

Hi,

Quoted 8 lines

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 12

Quoted 6 lines

+- compatible : Shall be "apm,xgene-ahci-phy" or

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +5 -0
+                       "apm,xgene-ahci-phy2". The "apm,xgene-ahci-phy"
+                       describes an port shared with SGMII Ethernet port.
+                       The "apm,xgene-ahci-phy2" describes an port not
+                       shared with SGMII and the PLL located at another
+                       memory resource region.

Is there not a better name available than "apm,xgene-ahci-phy2"?

[Loc Ho]
I will name it apm,xgene-ahci-phyx.

Quoted 4 lines
Quoted 3 lines

+- reg : First PHY memory resource

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +2 -0
+                       Second separate PHY PLL clock memory resource if
+                       type "apm,xgene-ahci-phy2"
Quoted 5 lines
Quoted 1 line

Is ths PLL actually part of the PHY, or does it just feed the PHY?

[Loc Ho]
This is always the PLL clock macro in each IP. For the 3rd controller, we require an extra clock macro and can NOT use the original clock macro as it is not mux'ed with the SGMII port.

Ok. Is the reference clock into the PLL always on, or might we need to describe it?

Quoted 10 lines
Quoted 10 lines

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt line 24

Quoted 6 lines

+- txeyetuning : Manual control to fine tune the capture of the serial

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +3 -0
+                       bit lines from the automatic calibrated position.
+                       Two set of 3-tuple setting for Gen1, Gen2, and Gen3.
+                       Range from 0 to 0x7f. Default is 0xa.

If you have a property for which the name consists of multiple words, split the words with '-'.

Quoted 7 lines
Quoted 5 lines

What does this actually mean?

What units are these values in?

What effect do those values have?

[Loc Ho]
Will provide in next version.

Cheers.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

+- txeyedirection : Eye tuning manual control direction. 0 means sample

Documentation/devicetree/bindings/ata/apm-xgene-phy.txt new file +4 -0
+                       data earlier than the nominal sampling point. 1 means
+                       sample data later than the nominal sampling point.
+                       Two set of 3-tuple setting for Gen1, Gen2, and Gen3.
+                       Default is 0x0.
Quoted 5 lines
Quoted 3 lines

Likewise, use '-'.

s/than/then/ ?

[Loc Ho]
I believe that than is appropriate here a we are doing an comparison.

Apologies, you are corerct; I completely misread this.

Thanks,
Mark.

#21 lore raw

PATCH v2 1/4 PHY: Add function set_speed to generic PHY framework

In reply to Loc Ho

Hello.

Quoted 1 line · Loc Ho

PHY: Add function set_speed to generic PHY framework

There's no need to duplicate the subject in the changelog verbatim.

Quoted 6 lines

This patch adds function set_speed to the generic PHY framework operation structure. This function can be called to instruct the PHY underlying layer at specified lane to configure for specified speed in hertz.

WBR, Sergei