Re: [PATCH V7 1/2] PHY: Exynos: Add Exynos5250 SATA PHY driver

2014-01-28 Thread Kishon Vijay Abraham I
Hi,

On Monday 27 January 2014 07:49 PM, Yuvaraj Kumar C D wrote:
> This patch adds the SATA PHY driver for Exynos5250.Exynos5250 SATA
> PHY comprises of CMU and TRSV blocks which are of I2C register Map.
> So this patch also adds a i2c client driver, which is used configure
> the CMU and TRSV block of exynos5250 SATA PHY.
> 
> This patch incorporates the generic PHY framework to deal with SATA
> PHY.
> 
> This patch depends on the below patches
>   [1].drivers: phy: add generic PHY framework
>   by Kishon Vijay Abraham I

It no longer should be mentioned here as it is already in mainline. Moreover
these information shouldn't be in commit log. Just move it below '---'.
>   [2].ata: ahci_platform: Manage SATA PHY
>   by Roger Quadros 
> 
> Signed-off-by: Yuvaraj Kumar C D 
> Signed-off-by: Girish K S 
> Signed-off-by: Vasanth Ananthan 
> ---
> Changes from V6:
>   1.Removed phy-exynos5250-sata-i2c.c,as it is not required
> after moving to of_find_i2c_device_by_node().
>   2.Changed struct __iomem *pmureg tp struct regmap *pmureg.
>   3.Changed the wait_for_reg_status() to return 0 or -EFAULT.
> 
> Changes from V5:
>   1.Rebased on latest generic PHY framework for-next tree.
>   2.Minor nits such as indentations.
> 
> Changes from V4:
>   1.Made Exynos5250 SATA PHY driver by default selects
>   CONFIG_I2C and CONFIG_I2C_S3C2410, as SATA PHY driver
>   depends on I2C.
>   2.struct i2c_driver sataphy_i2c_driver made static which
>   was earlier global type.
>   3.Renamed the files to phy-exynos5250-sata.c and 
>   phy-exynos5250-sata-i2c.c and CONFIG_EXYNOS5250_SATA_PHY
>   to CONFIG_PHY_EXYNOS5250_SATA. 
> 
> Changes from V3:
>   1.Moved devm_phy_create before to devm_phy_provider_register.
> 
> Changes from V2:
>   1.Removed of_match_table
>   2.Moved to syscon interface for PMU handling.
> 
> Changes from V1:
>   1.Adapted to latest version of Generic PHY framework
>   2.Removed exynos_sata_i2c_remove function.
>  
>  drivers/phy/Kconfig   |   13 ++
>  drivers/phy/Makefile  |1 +
>  drivers/phy/phy-exynos5250-sata.c |  244 
> +
>  3 files changed, 258 insertions(+)
>  create mode 100644 drivers/phy/phy-exynos5250-sata.c
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index d0611b8..df79150 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -57,4 +57,17 @@ config PHY_EXYNOS_DP_VIDEO
>   help
> Support for Display Port PHY found on Samsung EXYNOS SoCs.
>  
> +config PHY_EXYNOS5250_SATA
> + tristate "Exynos5250 Sata SerDes/PHY driver"
> + depends on SOC_EXYNOS5250
> + select GENERIC_PHY
> + select I2C
> + select I2C_S3C2410

depends on HAS_IOMEM and depends on OF.
> + select MFD_SYSCON
> + help
> +   Enable this to support SATA SerDes/Phy found on Samsung's
> +   Exynos5250 based SoCs.This SerDes/Phy supports SATA 1.5 Gb/s,
> +   SATA 3.0 Gb/s, SATA 6.0 Gb/s speeds. It supports one SATA host
> +   port to accept one SATA device.
> +
>  endmenu
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index 4e4adc9..5d93dc9 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -8,3 +8,4 @@ obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)   += 
> phy-exynos-mipi-video.o
>  obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o
>  obj-$(CONFIG_OMAP_USB2)  += phy-omap-usb2.o
>  obj-$(CONFIG_TWL4030_USB)+= phy-twl4030-usb.o
> +obj-$(CONFIG_PHY_EXYNOS5250_SATA)+= phy-exynos5250-sata.o
> diff --git a/drivers/phy/phy-exynos5250-sata.c 
> b/drivers/phy/phy-exynos5250-sata.c
> new file mode 100644
> index 000..b35168d
> --- /dev/null
> +++ b/drivers/phy/phy-exynos5250-sata.c
> @@ -0,0 +1,244 @@
> +/*
> + * Samsung SATA SerDes(PHY) driver
> + *
> + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
> + * Authors: Girish K S 
> + * Yuvaraj Kumar C D 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define EXYNOS5_SATA_RESET   0x4
> +#define RESET_CMN_RST_N  (1 << 1)

use BIT macro here and below.
> +#define LINK_RESET   0xf
> +#define EXYNOS5_SATA_MODE0   0x10
> +#define EXYNOS5_SATAPHY_PMU_ENABLE   (1 << 0)
> +#define SATA_SPD_GEN3(2 << 0)
> +#define EXYNOS5_SATA_CTRL0   0x14
> +#define CTRL0_P0_PHY_CALIBRATED_SEL  (1 << 9)
> +#define CTRL0_P0_PHY_CALIBRATED  (1 << 8)
> +#define EXYNOS5_SATA_PHSATA_CTRLM0xe0
> +#define PHCTRLM_REF_RATE (1 << 1)
> +#define 

Re: [PATCH V7 1/2] PHY: Exynos: Add Exynos5250 SATA PHY driver

2014-01-28 Thread Kishon Vijay Abraham I
Hi,

On Monday 27 January 2014 07:49 PM, Yuvaraj Kumar C D wrote:
 This patch adds the SATA PHY driver for Exynos5250.Exynos5250 SATA
 PHY comprises of CMU and TRSV blocks which are of I2C register Map.
 So this patch also adds a i2c client driver, which is used configure
 the CMU and TRSV block of exynos5250 SATA PHY.
 
 This patch incorporates the generic PHY framework to deal with SATA
 PHY.
 
 This patch depends on the below patches
   [1].drivers: phy: add generic PHY framework
   by Kishon Vijay Abraham Ikis...@ti.com

It no longer should be mentioned here as it is already in mainline. Moreover
these information shouldn't be in commit log. Just move it below '---'.
   [2].ata: ahci_platform: Manage SATA PHY
   by Roger Quadros rog...@ti.com
 
 Signed-off-by: Yuvaraj Kumar C D yuvaraj...@samsung.com
 Signed-off-by: Girish K S ks.g...@samsung.com
 Signed-off-by: Vasanth Ananthan vasant...@samsung.com
 ---
 Changes from V6:
   1.Removed phy-exynos5250-sata-i2c.c,as it is not required
 after moving to of_find_i2c_device_by_node().
   2.Changed struct __iomem *pmureg tp struct regmap *pmureg.
   3.Changed the wait_for_reg_status() to return 0 or -EFAULT.
 
 Changes from V5:
   1.Rebased on latest generic PHY framework for-next tree.
   2.Minor nits such as indentations.
 
 Changes from V4:
   1.Made Exynos5250 SATA PHY driver by default selects
   CONFIG_I2C and CONFIG_I2C_S3C2410, as SATA PHY driver
   depends on I2C.
   2.struct i2c_driver sataphy_i2c_driver made static which
   was earlier global type.
   3.Renamed the files to phy-exynos5250-sata.c and 
   phy-exynos5250-sata-i2c.c and CONFIG_EXYNOS5250_SATA_PHY
   to CONFIG_PHY_EXYNOS5250_SATA. 
 
 Changes from V3:
   1.Moved devm_phy_create before to devm_phy_provider_register.
 
 Changes from V2:
   1.Removed of_match_table
   2.Moved to syscon interface for PMU handling.
 
 Changes from V1:
   1.Adapted to latest version of Generic PHY framework
   2.Removed exynos_sata_i2c_remove function.
  
  drivers/phy/Kconfig   |   13 ++
  drivers/phy/Makefile  |1 +
  drivers/phy/phy-exynos5250-sata.c |  244 
 +
  3 files changed, 258 insertions(+)
  create mode 100644 drivers/phy/phy-exynos5250-sata.c
 
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index d0611b8..df79150 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -57,4 +57,17 @@ config PHY_EXYNOS_DP_VIDEO
   help
 Support for Display Port PHY found on Samsung EXYNOS SoCs.
  
 +config PHY_EXYNOS5250_SATA
 + tristate Exynos5250 Sata SerDes/PHY driver
 + depends on SOC_EXYNOS5250
 + select GENERIC_PHY
 + select I2C
 + select I2C_S3C2410

depends on HAS_IOMEM and depends on OF.
 + select MFD_SYSCON
 + help
 +   Enable this to support SATA SerDes/Phy found on Samsung's
 +   Exynos5250 based SoCs.This SerDes/Phy supports SATA 1.5 Gb/s,
 +   SATA 3.0 Gb/s, SATA 6.0 Gb/s speeds. It supports one SATA host
 +   port to accept one SATA device.
 +
  endmenu
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index 4e4adc9..5d93dc9 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -8,3 +8,4 @@ obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)   += 
 phy-exynos-mipi-video.o
  obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o
  obj-$(CONFIG_OMAP_USB2)  += phy-omap-usb2.o
  obj-$(CONFIG_TWL4030_USB)+= phy-twl4030-usb.o
 +obj-$(CONFIG_PHY_EXYNOS5250_SATA)+= phy-exynos5250-sata.o
 diff --git a/drivers/phy/phy-exynos5250-sata.c 
 b/drivers/phy/phy-exynos5250-sata.c
 new file mode 100644
 index 000..b35168d
 --- /dev/null
 +++ b/drivers/phy/phy-exynos5250-sata.c
 @@ -0,0 +1,244 @@
 +/*
 + * Samsung SATA SerDes(PHY) driver
 + *
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + * Authors: Girish K S ks.g...@samsung.com
 + * Yuvaraj Kumar C D yuvaraj...@samsung.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/clk.h
 +#include linux/delay.h
 +#include linux/io.h
 +#include linux/i2c.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/of_address.h
 +#include linux/phy/phy.h
 +#include linux/platform_device.h
 +#include linux/regmap.h
 +#include linux/spinlock.h
 +#include linux/mfd/syscon.h
 +
 +#define EXYNOS5_SATA_RESET   0x4
 +#define RESET_CMN_RST_N  (1  1)

use BIT macro here and below.
 +#define LINK_RESET   0xf
 +#define EXYNOS5_SATA_MODE0   0x10
 +#define EXYNOS5_SATAPHY_PMU_ENABLE   (1  0)
 +#define SATA_SPD_GEN3(2  0)
 +#define EXYNOS5_SATA_CTRL0   0x14
 +#define 

[PATCH V7 1/2] PHY: Exynos: Add Exynos5250 SATA PHY driver

2014-01-27 Thread Yuvaraj Kumar C D
This patch adds the SATA PHY driver for Exynos5250.Exynos5250 SATA
PHY comprises of CMU and TRSV blocks which are of I2C register Map.
So this patch also adds a i2c client driver, which is used configure
the CMU and TRSV block of exynos5250 SATA PHY.

This patch incorporates the generic PHY framework to deal with SATA
PHY.

This patch depends on the below patches
[1].drivers: phy: add generic PHY framework
by Kishon Vijay Abraham I
[2].ata: ahci_platform: Manage SATA PHY
by Roger Quadros 

Signed-off-by: Yuvaraj Kumar C D 
Signed-off-by: Girish K S 
Signed-off-by: Vasanth Ananthan 
---
Changes from V6:
1.Removed phy-exynos5250-sata-i2c.c,as it is not required
  after moving to of_find_i2c_device_by_node().
2.Changed struct __iomem *pmureg tp struct regmap *pmureg.
3.Changed the wait_for_reg_status() to return 0 or -EFAULT.

Changes from V5:
1.Rebased on latest generic PHY framework for-next tree.
2.Minor nits such as indentations.

Changes from V4:
1.Made Exynos5250 SATA PHY driver by default selects
CONFIG_I2C and CONFIG_I2C_S3C2410, as SATA PHY driver
depends on I2C.
2.struct i2c_driver sataphy_i2c_driver made static which
was earlier global type.
3.Renamed the files to phy-exynos5250-sata.c and 
phy-exynos5250-sata-i2c.c and CONFIG_EXYNOS5250_SATA_PHY
to CONFIG_PHY_EXYNOS5250_SATA. 

Changes from V3:
1.Moved devm_phy_create before to devm_phy_provider_register.

Changes from V2:
1.Removed of_match_table
2.Moved to syscon interface for PMU handling.

Changes from V1:
1.Adapted to latest version of Generic PHY framework
2.Removed exynos_sata_i2c_remove function.
 
 drivers/phy/Kconfig   |   13 ++
 drivers/phy/Makefile  |1 +
 drivers/phy/phy-exynos5250-sata.c |  244 +
 3 files changed, 258 insertions(+)
 create mode 100644 drivers/phy/phy-exynos5250-sata.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index d0611b8..df79150 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -57,4 +57,17 @@ config PHY_EXYNOS_DP_VIDEO
help
  Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
+config PHY_EXYNOS5250_SATA
+   tristate "Exynos5250 Sata SerDes/PHY driver"
+   depends on SOC_EXYNOS5250
+   select GENERIC_PHY
+   select I2C
+   select I2C_S3C2410
+   select MFD_SYSCON
+   help
+ Enable this to support SATA SerDes/Phy found on Samsung's
+ Exynos5250 based SoCs.This SerDes/Phy supports SATA 1.5 Gb/s,
+ SATA 3.0 Gb/s, SATA 6.0 Gb/s speeds. It supports one SATA host
+ port to accept one SATA device.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 4e4adc9..5d93dc9 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += 
phy-exynos-mipi-video.o
 obj-$(CONFIG_PHY_MVEBU_SATA)   += phy-mvebu-sata.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
 obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
+obj-$(CONFIG_PHY_EXYNOS5250_SATA)  += phy-exynos5250-sata.o
diff --git a/drivers/phy/phy-exynos5250-sata.c 
b/drivers/phy/phy-exynos5250-sata.c
new file mode 100644
index 000..b35168d
--- /dev/null
+++ b/drivers/phy/phy-exynos5250-sata.c
@@ -0,0 +1,244 @@
+/*
+ * Samsung SATA SerDes(PHY) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Authors: Girish K S 
+ * Yuvaraj Kumar C D 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define EXYNOS5_SATA_RESET 0x4
+#define RESET_CMN_RST_N(1 << 1)
+#define LINK_RESET 0xf
+#define EXYNOS5_SATA_MODE0 0x10
+#define EXYNOS5_SATAPHY_PMU_ENABLE (1 << 0)
+#define SATA_SPD_GEN3  (2 << 0)
+#define EXYNOS5_SATA_CTRL0 0x14
+#define CTRL0_P0_PHY_CALIBRATED_SEL(1 << 9)
+#define CTRL0_P0_PHY_CALIBRATED(1 << 8)
+#define EXYNOS5_SATA_PHSATA_CTRLM  0xe0
+#define PHCTRLM_REF_RATE   (1 << 1)
+#define PHCTRLM_HIGH_SPEED (1 << 0)
+#define EXYNOS5_SATA_PHSATA_STATM  0xf0
+#define PHSTATM_PLL_LOCKED (1 << 0)
+#define EXYNOS_SATA_PHY_EN (1 << 0)
+#define SATAPHY_CONTROL_OFFSET 0x0724
+
+#define PHY_PLL_TIMEOUT (usecs_to_jiffies(1000))
+
+struct exynos_sata_phy {
+   struct phy *phy;
+   struct clk *phyclk;
+   void __iomem *regs;
+   struct regmap *pmureg;
+   struct i2c_client *client;
+};
+

[PATCH V7 1/2] PHY: Exynos: Add Exynos5250 SATA PHY driver

2014-01-27 Thread Yuvaraj Kumar C D
This patch adds the SATA PHY driver for Exynos5250.Exynos5250 SATA
PHY comprises of CMU and TRSV blocks which are of I2C register Map.
So this patch also adds a i2c client driver, which is used configure
the CMU and TRSV block of exynos5250 SATA PHY.

This patch incorporates the generic PHY framework to deal with SATA
PHY.

This patch depends on the below patches
[1].drivers: phy: add generic PHY framework
by Kishon Vijay Abraham Ikis...@ti.com
[2].ata: ahci_platform: Manage SATA PHY
by Roger Quadros rog...@ti.com

Signed-off-by: Yuvaraj Kumar C D yuvaraj...@samsung.com
Signed-off-by: Girish K S ks.g...@samsung.com
Signed-off-by: Vasanth Ananthan vasant...@samsung.com
---
Changes from V6:
1.Removed phy-exynos5250-sata-i2c.c,as it is not required
  after moving to of_find_i2c_device_by_node().
2.Changed struct __iomem *pmureg tp struct regmap *pmureg.
3.Changed the wait_for_reg_status() to return 0 or -EFAULT.

Changes from V5:
1.Rebased on latest generic PHY framework for-next tree.
2.Minor nits such as indentations.

Changes from V4:
1.Made Exynos5250 SATA PHY driver by default selects
CONFIG_I2C and CONFIG_I2C_S3C2410, as SATA PHY driver
depends on I2C.
2.struct i2c_driver sataphy_i2c_driver made static which
was earlier global type.
3.Renamed the files to phy-exynos5250-sata.c and 
phy-exynos5250-sata-i2c.c and CONFIG_EXYNOS5250_SATA_PHY
to CONFIG_PHY_EXYNOS5250_SATA. 

Changes from V3:
1.Moved devm_phy_create before to devm_phy_provider_register.

Changes from V2:
1.Removed of_match_table
2.Moved to syscon interface for PMU handling.

Changes from V1:
1.Adapted to latest version of Generic PHY framework
2.Removed exynos_sata_i2c_remove function.
 
 drivers/phy/Kconfig   |   13 ++
 drivers/phy/Makefile  |1 +
 drivers/phy/phy-exynos5250-sata.c |  244 +
 3 files changed, 258 insertions(+)
 create mode 100644 drivers/phy/phy-exynos5250-sata.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index d0611b8..df79150 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -57,4 +57,17 @@ config PHY_EXYNOS_DP_VIDEO
help
  Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
+config PHY_EXYNOS5250_SATA
+   tristate Exynos5250 Sata SerDes/PHY driver
+   depends on SOC_EXYNOS5250
+   select GENERIC_PHY
+   select I2C
+   select I2C_S3C2410
+   select MFD_SYSCON
+   help
+ Enable this to support SATA SerDes/Phy found on Samsung's
+ Exynos5250 based SoCs.This SerDes/Phy supports SATA 1.5 Gb/s,
+ SATA 3.0 Gb/s, SATA 6.0 Gb/s speeds. It supports one SATA host
+ port to accept one SATA device.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 4e4adc9..5d93dc9 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += 
phy-exynos-mipi-video.o
 obj-$(CONFIG_PHY_MVEBU_SATA)   += phy-mvebu-sata.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
 obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
+obj-$(CONFIG_PHY_EXYNOS5250_SATA)  += phy-exynos5250-sata.o
diff --git a/drivers/phy/phy-exynos5250-sata.c 
b/drivers/phy/phy-exynos5250-sata.c
new file mode 100644
index 000..b35168d
--- /dev/null
+++ b/drivers/phy/phy-exynos5250-sata.c
@@ -0,0 +1,244 @@
+/*
+ * Samsung SATA SerDes(PHY) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Authors: Girish K S ks.g...@samsung.com
+ * Yuvaraj Kumar C D yuvaraj...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/io.h
+#include linux/i2c.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/regmap.h
+#include linux/spinlock.h
+#include linux/mfd/syscon.h
+
+#define EXYNOS5_SATA_RESET 0x4
+#define RESET_CMN_RST_N(1  1)
+#define LINK_RESET 0xf
+#define EXYNOS5_SATA_MODE0 0x10
+#define EXYNOS5_SATAPHY_PMU_ENABLE (1  0)
+#define SATA_SPD_GEN3  (2  0)
+#define EXYNOS5_SATA_CTRL0 0x14
+#define CTRL0_P0_PHY_CALIBRATED_SEL(1  9)
+#define CTRL0_P0_PHY_CALIBRATED(1  8)
+#define EXYNOS5_SATA_PHSATA_CTRLM  0xe0
+#define PHCTRLM_REF_RATE   (1  1)
+#define PHCTRLM_HIGH_SPEED (1  0)
+#define EXYNOS5_SATA_PHSATA_STATM  0xf0
+#define PHSTATM_PLL_LOCKED (1  0)
+#define EXYNOS_SATA_PHY_EN