phy: qcom: Add driver for QCOM IPQ806x SATA PHY
PATCH 1/2 phy: qcom: Add driver for QCOM IPQ806x SATA PHY
Add a PHY driver for uses with AHCI based SATA controller driver on the IPQ806x family of SoCs.
--- drivers/phy/Kconfig | 6 ++ drivers/phy/Makefile | 1 + drivers/phy/phy-qcom-ipq806x-sata.c | 204 ++++++++++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 drivers/phy/phy-qcom-ipq806x-sata.c
drivers/phy/Kconfig +6 -0
@@ -178,4 +178,10 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY. +config PHY_QCOM_IPQ806X_SATA + tristate "Qualcomm IPQ806x SATA SerDes/PHY driver" + depends on ARCH_QCOM + depends on OF + select GENERIC_PHY + endmenu
drivers/phy/Makefile +1 -0
@@ -20,3 +20,4 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o +obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o
drivers/phy/phy-qcom-ipq806x-sata.c new file +204 -0
204 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
PATCH 2/2 phy: qcom: Add device tree bindings information
Add binding spec for Qualcomm SoC PHYs, starting with the SATA PHY on the IPQ806x family of SoCs.
--- Documentation/devicetree/bindings/phy/qcom-phy.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom-phy.txt
Documentation/devicetree/bindings/phy/qcom-phy.txt new file +23 -0
@@ -0,0 +1,23 @@ +Qualcomm IPQ806x SATA PHY Controller +------------------------------------ + +SATA PHY nodes are defined to describe on-chip SATA Physical layer controllers. +Each SATA PHY controller should have its own node. + +Required properties: +- compatible: compatible list, contains "qcom,ipq806x-sata-phy" +- reg: offset and length of the SATA PHY register set; +- #phy-cells: must be zero +- clocks: must be exactly one entry +- clock-names: must be "cfg" + +Example: + sata_phy: sata-phy at 1b400000 { + compatible = "qcom,ipq806x-sata-phy"; + reg = <0x1b400000 0x200>; + + clocks = <&gcc SATA_PHY_CFG_CLK>; + clock-names = "cfg"; + + #phy-cells = <0>; + };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
drivers/phy/phy-qcom-ipq806x-sata.c line 27
Quoted 3 lines · Kumar Gala
drivers/phy/phy-qcom-ipq806x-sata.c new file +3
-0+ +struct qcom_ipq806x_sata_phy { +struct device *dev;
Is this used?
Quoted 2 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +2
-0+void __iomem *mmio; +struct clk *cfg_clk;
[...]
drivers/phy/phy-qcom-ipq806x-sata.c line 70
Quoted 5 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +5
-0+ +static int qcom_ipq806x_sata_phy_init (struct phy *generic_phy) +{ +struct qcom_ipq806x_sata_phy *phy =phy_get_drvdata (generic_phy); +u32 reg =0 ;
unnecessary initialization
drivers/phy/phy-qcom-ipq806x-sata.c line 121
Quoted 5 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +5
-0+ +static int qcom_ipq806x_sata_phy_exit (struct phy *generic_phy) +{ +struct qcom_ipq806x_sata_phy *phy =phy_get_drvdata (generic_phy); +u32 reg =0 ;
unnecessary initialization
Quoted 10 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +9
-0+static int qcom_ipq806x_sata_phy_probe (struct platform_device *pdev) +{ +struct qcom_ipq806x_sata_phy *phy; +struct device *dev = &pdev->dev; +struct resource *res; +struct phy_provider *phy_provider; +struct phy *generic_phy; +int ret; +
drivers/phy/phy-qcom-ipq806x-sata.c line 155
Quoted 10 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +10
-0+ phy =devm_kzalloc (dev,sizeof (*phy),GFP_KERNEL ); +if (!phy) { +dev_err (dev,"%s: failed to allocate phy\n" , __func__); +return -ENOMEM ; + } + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + phy->mmio =devm_ioremap_resource (dev, res); +if (IS_ERR (phy->mmio)) { +dev_err (dev,"%s: phy mmio get resource failed\n" , __func__);
Unnecessary error message.
Quoted 14 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +14
-0+return PTR_ERR (phy->mmio); + } + + phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (phy_provider)) { +dev_err (dev,"%s: failed to register phy\n" , __func__); +return PTR_ERR (phy_provider); + } + + generic_phy =devm_phy_create (dev, &qcom_ipq806x_sata_phy_ops,NULL ); +if (IS_ERR (generic_phy)) { +dev_err (dev,"%s: failed to create phy\n" , __func__); +return PTR_ERR (generic_phy); + }
drivers/phy/phy-qcom-ipq806x-sata.c line 179
Quoted 10 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +10
-0+ + phy->cfg_clk =devm_clk_get (dev,"cfg" ); +if (IS_ERR (phy->cfg_clk)) { +dev_err (dev,"Failed to get sata cfg clock\n" ); +return PTR_ERR (phy->cfg_clk); + } + + ret =clk_prepare_enable (phy->cfg_clk); +if (ret) +return ret;
Shouldn't there be a remove that disables this clock?
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Hi,
Quoted 16 lines · Kumar Gala
Add a PHY driver for uses with AHCI based SATA controller driver on the IPQ806x family of SoCs.
Signed-off-by Kumar Gala <[email protected]>--- drivers/phy/Kconfig | 6 ++ drivers/phy/Makefile | 1 + drivers/phy/phy-qcom-ipq806x-sata.c | 204 ++++++++++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 drivers/phy/phy-qcom-ipq806x-sata.cdrivers/phy/Kconfig +0
-0
drivers/phy/Kconfig config PHY_XGENE · line 184
Quoted 7 lines
drivers/phy/Kconfig +4
-0@@ -178,4 +178,10 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY. +config PHY_QCOM_IPQ806X_SATA + tristate "Qualcomm IPQ806x SATA SerDes/PHY driver" + depends on ARCH_QCOM + depends on OF
depends on HAS_IOMEM?
Quoted 35 lines
drivers/phy/Kconfig +2
-0+ select GENERIC_PHY + endmenudrivers/phy/Makefile +1
-0@@ -20,3 +20,4 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o +obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.odrivers/phy/phy-qcom-ipq806x-sata.c new file +17
-0@@ -0,0 +1,204 @@ +/* +* Copyright (c) 2014, The Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 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/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h>
drivers/phy/phy-qcom-ipq806x-sata.c line 27
Quoted 10 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +10
-0+#include <linux/of_address.h> +#include <linux/time.h> +#include <linux/delay.h> +#include <linux/clk.h> +#include <linux/slab.h> +#include <linux/platform_device.h> +#include <linux/phy/phy.h> + +struct qcom_ipq806x_sata_phy { +struct device *dev;
dev is not used anywhere. remove it.
Quoted 36 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +36
-0+void __iomem *mmio; +struct clk *cfg_clk; +}; + +#define __set (v, a, b) (((v) << (b)) & GENMASK(a, b)) + +#define SATA_PHY_P0_PARAM0 0x200 +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN3 (x) __set(x, 17, 12) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN3_MASK GENMASK(17, 12) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN2 (x) __set(x, 11, 6) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN2_MASK GENMASK(11, 6) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN1 (x) __set(x, 5, 0) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN1_MASK GENMASK(5, 0) + +#define SATA_PHY_P0_PARAM1 0x204 +#define SATA_PHY_P0_PARAM1_RESERVED_BITS31_21 (x) __set(x, 31, 21) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN3 (x) __set(x, 20, 14) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN3_MASK GENMASK(20, 14) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN2 (x) __set(x, 13, 7) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN2_MASK GENMASK(13, 7) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN1 (x) __set(x, 6, 0) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN1_MASK GENMASK(6, 0) + +#define SATA_PHY_P0_PARAM2 0x208 +#define SATA_PHY_P0_PARAM2_RX_EQ (x) __set(x, 20, 18) +#define SATA_PHY_P0_PARAM2_RX_EQ_MASK GENMASK(20, 18) + +#define SATA_PHY_P0_PARAM3 0x20C +#define SATA_PHY_SSC_EN 0x8 +#define SATA_PHY_P0_PARAM4 0x210 +#define SATA_PHY_REF_SSP_EN 0x2 +#define SATA_PHY_RESET 0x1 + +static inline void qcom_ipq806x_sata_delay_us (unsigned int delay) +{ +/* sleep for max. 50us more to combine processor wakeups */
drivers/phy/phy-qcom-ipq806x-sata.c line 73
Quoted 10 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +10
-0+usleep_range (delay, delay +50 ); +} + +static int qcom_ipq806x_sata_phy_init (struct phy *generic_phy) +{ +struct qcom_ipq806x_sata_phy *phy =phy_get_drvdata (generic_phy); +u32 reg =0 ; + +/* Setting SSC_EN to 1 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM3 );
Why readl_relaxed?
Quoted 80 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +80
-0+ reg = reg |SATA_PHY_SSC_EN ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM3 ); + + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM0 ) & + ~(SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN3_MASK | +SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN2_MASK | +SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN1_MASK ); + reg |=SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN3 (0xf ); +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM0 ); + + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM1 ) & + ~(SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN3_MASK | +SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN2_MASK | +SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN1_MASK ); + reg |=SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN3 (0x55 ) | +SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN2 (0x55 ) | +SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN1 (0x55 ); +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM1 ); + + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM2 ) & + ~SATA_PHY_P0_PARAM2_RX_EQ_MASK ; + reg |=SATA_PHY_P0_PARAM2_RX_EQ (0x3 ); +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM2 ); + +/* Setting PHY_RESET to 1 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM4 ); + reg = reg |SATA_PHY_RESET ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM4 ); + +/* Setting REF_SSP_EN to 1 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM4 ); + reg = reg |SATA_PHY_REF_SSP_EN |SATA_PHY_RESET ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM4 ); +mb (); +qcom_ipq806x_sata_delay_us (20 ); + +/* Clearing PHY_RESET to 0 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM4 ); + reg = reg & ~SATA_PHY_RESET ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM4 ); + +return 0 ; +} + +static int qcom_ipq806x_sata_phy_exit (struct phy *generic_phy) +{ +struct qcom_ipq806x_sata_phy *phy =phy_get_drvdata (generic_phy); +u32 reg =0 ; + +/* Setting PHY_RESET to 1 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM4 ); + reg = reg |SATA_PHY_RESET ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM4 ); + +return 0 ; +} + +static struct phy_ops qcom_ipq806x_sata_phy_ops = { + .init = qcom_ipq806x_sata_phy_init, + .exit = qcom_ipq806x_sata_phy_exit, + .owner =THIS_MODULE , +}; + +static int qcom_ipq806x_sata_phy_probe (struct platform_device *pdev) +{ +struct qcom_ipq806x_sata_phy *phy; +struct device *dev = &pdev->dev; +struct resource *res; +struct phy_provider *phy_provider; +struct phy *generic_phy; +int ret; + + phy =devm_kzalloc (dev,sizeof (*phy),GFP_KERNEL ); +if (!phy) { +dev_err (dev,"%s: failed to allocate phy\n" , __func__); +return -ENOMEM ; + } + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + phy->mmio =devm_ioremap_resource (dev, res);
drivers/phy/phy-qcom-ipq806x-sata.c line 163
Quoted 10 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +10
-0+if (IS_ERR (phy->mmio)) { +dev_err (dev,"%s: phy mmio get resource failed\n" , __func__); +return PTR_ERR (phy->mmio); + } + + phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (phy_provider)) { +dev_err (dev,"%s: failed to register phy\n" , __func__); +return PTR_ERR (phy_provider); + }
phy_provider_register should be the last step. Move it after phy_set_drvdata().
Thanks
Kishon
Quoted 22 lines · Kishon Vijay Abraham I
Hi,
Quoted 19 lines · Kumar Gala
Add a PHY driver for uses with AHCI based SATA controller driver on the IPQ806x family of SoCs.
Signed-off-by Kumar Gala <[email protected]>---
drivers/phy/Kconfig | 6 ++ drivers/phy/Makefile | 1 + drivers/phy/phy-qcom-ipq806x-sata.c | 204 ++++++++++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+)create mode 100644
drivers/phy/phy-qcom-ipq806x-sata.cdrivers/phy/Kconfig +0
-0@@ -178,4 +178,10 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY.
Quoted 5 lines
drivers/phy/Kconfig config PHY_XGENE · line 184
Quoted 4 lines
drivers/phy/Kconfig +4
-0+config PHY_QCOM_IPQ806X_SATA + tristate "Qualcomm IPQ806x SATA SerDes/PHY driver" + depends on ARCH_QCOM + depends on OFdepends on
HAS_IOMEM?
will add
Quoted 39 lines
Quoted 39 lines
drivers/phy/Kconfig +2
-0+ select GENERIC_PHY +endmenu
drivers/phy/Makefile +0
-0@@ -20,3 +20,4 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.ophy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o
obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o
obj-$(CONFIG_PHY_XGENE) += phy-xgene.odrivers/phy/Makefile +1
-0+obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.odrivers/phy/phy-qcom-ipq806x-sata.c new file +21
-0@@ -0,0 +1,204 @@ +/* +* Copyright (c) 2014, The Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 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/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/time.h> +#include <linux/delay.h> +#include <linux/clk.h>
Quoted 8 lines
drivers/phy/phy-qcom-ipq806x-sata.c line 27
Quoted 6 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +6
-0+#include <linux/slab.h> +#include <linux/platform_device.h> +#include <linux/phy/phy.h> + +struct qcom_ipq806x_sata_phy { +struct device *dev;dev is not used anywhere. remove it.
already done in v2
Quoted 40 lines
Quoted 40 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +40
-0+void __iomem *mmio; +struct clk *cfg_clk; +}; + +#define __set (v, a, b) (((v) << (b)) & GENMASK(a, b)) + +#define SATA_PHY_P0_PARAM0 0x200 +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN3 (x) __set(x, 17, 12) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN3_MASK GENMASK(17, 12) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN2 (x) __set(x, 11, 6) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN2_MASK GENMASK(11, 6) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN1 (x) __set(x, 5, 0) +#define SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN1_MASK GENMASK(5, 0) + +#define SATA_PHY_P0_PARAM1 0x204 +#define SATA_PHY_P0_PARAM1_RESERVED_BITS31_21 (x) __set(x, 31, 21) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN3 (x) __set(x, 20, 14) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN3_MASK GENMASK(20, 14) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN2 (x) __set(x, 13, 7) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN2_MASK GENMASK(13, 7) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN1 (x) __set(x, 6, 0) +#define SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN1_MASK GENMASK(6, 0) + +#define SATA_PHY_P0_PARAM2 0x208 +#define SATA_PHY_P0_PARAM2_RX_EQ (x) __set(x, 20, 18) +#define SATA_PHY_P0_PARAM2_RX_EQ_MASK GENMASK(20, 18) + +#define SATA_PHY_P0_PARAM3 0x20C +#define SATA_PHY_SSC_EN 0x8 +#define SATA_PHY_P0_PARAM4 0x210 +#define SATA_PHY_REF_SSP_EN 0x2 +#define SATA_PHY_RESET 0x1 + +static inline void qcom_ipq806x_sata_delay_us (unsigned int delay) +{ +/* sleep for max. 50us more to combine processor wakeups */ +usleep_range (delay, delay +50 ); +} + +static int qcom_ipq806x_sata_phy_init (struct phy *generic_phy)
Quoted 8 lines
drivers/phy/phy-qcom-ipq806x-sata.c line 73
Quoted 6 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +6
-0+{ +struct qcom_ipq806x_sata_phy *phy =phy_get_drvdata (generic_phy); +u32 reg =0 ; + +/* Setting SSC_EN to 1 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM3 );Why
readl_relaxed?
because there is no need for readl?s memory barriers here.
Quoted 84 lines
Quoted 84 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +84
-0+ reg = reg |SATA_PHY_SSC_EN ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM3 ); + + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM0 ) & + ~(SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN3_MASK | +SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN2_MASK | +SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN1_MASK ); + reg |=SATA_PHY_P0_PARAM0_P0_TX_PREEMPH_GEN3 (0xf ); +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM0 ); + + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM1 ) & + ~(SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN3_MASK | +SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN2_MASK | +SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN1_MASK ); + reg |=SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN3 (0x55 ) | +SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN2 (0x55 ) | +SATA_PHY_P0_PARAM1_P0_TX_AMPLITUDE_GEN1 (0x55 ); +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM1 ); + + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM2 ) & + ~SATA_PHY_P0_PARAM2_RX_EQ_MASK ; + reg |=SATA_PHY_P0_PARAM2_RX_EQ (0x3 ); +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM2 ); + +/* Setting PHY_RESET to 1 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM4 ); + reg = reg |SATA_PHY_RESET ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM4 ); + +/* Setting REF_SSP_EN to 1 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM4 ); + reg = reg |SATA_PHY_REF_SSP_EN |SATA_PHY_RESET ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM4 ); +mb (); +qcom_ipq806x_sata_delay_us (20 ); + +/* Clearing PHY_RESET to 0 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM4 ); + reg = reg & ~SATA_PHY_RESET ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM4 ); + +return 0 ; +} + +static int qcom_ipq806x_sata_phy_exit (struct phy *generic_phy) +{ +struct qcom_ipq806x_sata_phy *phy =phy_get_drvdata (generic_phy); +u32 reg =0 ; + +/* Setting PHY_RESET to 1 */ + reg =readl_relaxed (phy->mmio +SATA_PHY_P0_PARAM4 ); + reg = reg |SATA_PHY_RESET ; +writel_relaxed (reg, phy->mmio +SATA_PHY_P0_PARAM4 ); + +return 0 ; +} + +static struct phy_ops qcom_ipq806x_sata_phy_ops = { + .init = qcom_ipq806x_sata_phy_init, + .exit = qcom_ipq806x_sata_phy_exit, + .owner =THIS_MODULE , +}; + +static int qcom_ipq806x_sata_phy_probe (struct platform_device *pdev) +{ +struct qcom_ipq806x_sata_phy *phy; +struct device *dev = &pdev->dev; +struct resource *res; +struct phy_provider *phy_provider; +struct phy *generic_phy; +int ret; + + phy =devm_kzalloc (dev,sizeof (*phy),GFP_KERNEL ); +if (!phy) { +dev_err (dev,"%s: failed to allocate phy\n" , __func__); +return -ENOMEM ; + } + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + phy->mmio =devm_ioremap_resource (dev, res); +if (IS_ERR (phy->mmio)) { +dev_err (dev,"%s: phy mmio get resource failed\n" , __func__); +return PTR_ERR (phy->mmio); + }
Quoted 8 lines
drivers/phy/phy-qcom-ipq806x-sata.c line 163
Quoted 6 lines
drivers/phy/phy-qcom-ipq806x-sata.c new file +6
-0+ + phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (phy_provider)) { +dev_err (dev,"%s: failed to register phy\n" , __func__); +return PTR_ERR (phy_provider); + }
phy_provider_registershould be the last step. Move it afterphy_set_drvdata().
will fix
Quoted 7 lines
Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation