Skip to contentSkip to conversation

Adding SATA PHY framework and PHY controller driver

PATCH New Vasanth Ananthan 1 participant 3 messages Feb 5, 2013

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

v2 cover Adding SATA PHY framework and PHY controller driver

Changes since v1:

1. Moved regs-sata.h to driver/ata/ and renamed to sata_exynos_phy.h

2. Added support for getting the sata phy PMU control register base address through device tree.

Vasanth Ananthan (2):
driver: ata: SATA PHY framework
driver: ata: add new Exynos5250 SATA PHY controller driver

 drivers/ata/Kconfig           |   20 +++
 drivers/ata/Makefile          |    2 +
 drivers/ata/sata_exynos_phy.c |  297 +++++++++++++++++++++++++++++++++++++++++
 drivers/ata/sata_exynos_phy.h |   31 +++++
 drivers/ata/sata_phy.c        |  146 ++++++++++++++++++++
 drivers/ata/sata_phy.h        |   29 ++++
 6 files changed, 525 insertions(+)
 create mode 100644 drivers/ata/sata_exynos_phy.c
 create mode 100644 drivers/ata/sata_exynos_phy.h
 create mode 100644 drivers/ata/sata_phy.c
 create mode 100644 drivers/ata/sata_phy.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/2 driver: ata: SATA PHY framework

This patch adds SATA PHY framework APIs. The framework acts as an interface between the SATA controller and the PHY controller. The SATA PHY controller driver registers the PHY with the framework through the sata_add_phy call, passing its device_node. The SATA controller requests for an appropriate PHY controller by passing the device_node of the PHY, the SATA controller node is mapped to in the device tree, to sata_get_phy call. After getting the PHY, SATA controllers initializes corresponding PHY controller through sata_init_phy call.

---
 drivers/ata/Kconfig    |   10 ++++
 drivers/ata/Makefile   |    1 +
 drivers/ata/sata_phy.c |  146 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/sata_phy.h |   29 ++++++++++
 4 files changed, 186 insertions(+)
 create mode 100644 drivers/ata/sata_phy.c
 create mode 100644 drivers/ata/sata_phy.h
drivers/ata/Kconfig +10 -0
index 996d16c..2ad1080 100644
@@ -96,6 +96,16 @@ config SATA_AHCI_PLATFORM
 
 	  If unsure, say N.
 
+config SATA_PHY
+	bool "SATA PHY Framework"
+	default n
+	help
+	  This option enables the SATA PHY framework APIs. The framework acts
+	  as an interface between the SATA controller and the PHY controller.
+	  The PHY controller registers itself with the framework through the APIs
+	  provided and the SATA controller finds and requests for an appropriate
+	  PHY controller. This can be used by platforms with device tree support.
+
 config SATA_FSL
 	tristate "Freescale 3.0Gbps SATA support"
 	depends on FSL_SOC
drivers/ata/Makefile +1 -0
index 85e3de4..3d2d128 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_SATA_INIC162X)	+= sata_inic162x.o
 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_SATA_PHY)		+= sata_phy.o
 
 # SFF w/ custom DMA
 obj-$(CONFIG_PDC_ADMA)		+= pdc_adma.o
drivers/ata/sata_phy.c new file +146 -0

146 lines not on this page · raw message

drivers/ata/sata_phy.h new file +29 -0
new file mode 100644
index 0000000..03ae2f9
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
+ *              http://www.samsung.com
+ *
+ * SATA utility framework definitions.
+ *
+ * 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.
+*/
+
+#define IN_USE		1
+#define NOT_IN_USE	0
+
+struct sata_phy {
+	int (*init) (struct sata_phy *);
+	int (*shutdown) (struct sata_phy *);
+	struct device *dev;
+	void *priv_data;
+	struct list_head head;
+	unsigned char status;
+};
+
+struct sata_phy *sata_get_phy(struct device_node *);
+int sata_add_phy(struct sata_phy *);
+void sata_remove_phy(struct sata_phy *);
+void sata_put_phy(struct sata_phy *);
+int sata_init_phy(struct sata_phy *);
+void sata_shutdown_phy(struct sata_phy *);
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 2/2 driver: ata: add new Exynos5250 SATA PHY controller driver

In reply to Vasanth Ananthan

Adding platform driver and I2C client driver for SATA PHY controller for Samsung Exynos5250.

The PHY controller in Exynos5250 has both the APB interface and I2C client interface, hence it requires both a platform driver and an I2C client driver. The PHY controller's primary charecteristics are handled through the APB interface, facilitated by the platform driver and the 40 bit interface should be enabled through the I2C interface, facilitated by the I2C client driver.

Further, this PHY controller driver uses PHY framework introduced by this patchset. The driver registers its initialization/shutdown call back to the framework and corresponding port this PHY controller is assciated with gets this PHY and initializes it.

---
 drivers/ata/Kconfig           |   10 ++
 drivers/ata/Makefile          |    1 +
 drivers/ata/sata_exynos_phy.c |  297 +++++++++++++++++++++++++++++++++++++++++
 drivers/ata/sata_exynos_phy.h |   31 +++++
 4 files changed, 339 insertions(+)
 create mode 100644 drivers/ata/sata_exynos_phy.c
 create mode 100644 drivers/ata/sata_exynos_phy.h
drivers/ata/Kconfig +10 -0
index 2ad1080..b7f2e29 100644
@@ -106,6 +106,16 @@ config SATA_PHY
 	  provided and the SATA controller finds and requests for an appropriate
 	  PHY controller. This can be used by platforms with device tree support.
 
+config SATA_EXYNOS_PHY
+	bool "Exynos5250 SATA PHY support"
+	default n
+	select I2C
+	select HAVE_S3C2410_I2C
+	select I2C_S3C2410
+	select SATA_PHY
+	help
+	  This options enables the support for sata phy in exynos5250.
+
 config SATA_FSL
 	tristate "Freescale 3.0Gbps SATA support"
 	depends on FSL_SOC
drivers/ata/Makefile +1 -0
index 3d2d128..bed6977 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_SATA_PHY)		+= sata_phy.o
+obj-$(CONFIG_SATA_EXYNOS_PHY)	+= sata_exynos_phy.o
 
 # SFF w/ custom DMA
 obj-$(CONFIG_PDC_ADMA)		+= pdc_adma.o
drivers/ata/sata_exynos_phy.c new file +297 -0

297 lines not on this page · raw message

drivers/ata/sata_exynos_phy.h new file +31 -0
new file mode 100644
index 0000000..2eea737
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
+ *              http://www.samsung.com
+ *
+ * EXYNOS - SATA PHY controller definition
+ *
+ * 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.
+*/
+
+#define EXYNOS5_SATA_RESET		0x4
+#define RESET_CMN_RST_N			(1 << 1)
+#define LINK_RESET			0xF0000
+
+#define EXYNOS5_SATA_MODE0		0x10
+
+#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 SATA_PHY_CON_RESET              0xF003F
+
+#define SATA_PHY_PMU_EN			0x1
Signature · 1 line
1.7.9.5