ata: Add APM X-Gene SoC AHCI SATA host controller support
Subsystems (3)
v13 cover ata: Add APM X-Gene SoC AHCI SATA host controller support
This patch adds support for the APM X-Gene SoC AHCI SATA host controller. In order for the host controller to work, the corresponding PHY driver musts also be available.
v13:
* Add fully-winged style comment for function xgene_ahci_read_id and xgene_ahci_do_hardrest
* Minor comments update for function xgene_ahci_read_id, xgene_ahci_do_hardrest, and xgene_ahci_hardreset
* NOTE: There is no functional code change.
v12:
* Remove function xgene_ahci_get_channel and use the ata_port field port_no
* Update comment for function xgene_ahci_read_id to function comment style '/**'
* Update comment for multiple lines to fully-winged style
v11:
* Drop the export functions requirement with libachi
* Change CONFIG_SATA_XGENE to CONFIG_AHCI_XGENE
* Rename file sata_xgene.c to ahci_xgene.c
* Convert to use Hans De Geode version 5 ahci_platform code re-factor changes to reduce code duplication. For extra context, use plat_data to store our context. The probe function follows the ahci_sunxi implementation. A number of code fragments update to reflect this change.
* Update comment for function xgene_ahci_read_id
* Minor code move around in function xgene_ahci_do_hardreset and use ATA_BUSY instead 0x80
* Fix hardreset to use start_engine function pointer as required due to newer kernel rebased
* Fix the set DMA mask for 32-bit as well
v10:
* Update binding documentation
v9:
* Remove ACPI/EFI include files
* Remove the IO flush support, interrupt routine, and DTS resources
* Remove function xgene_rd, xgene_wr, and xgene_wr_flush
* Remove PMP support (function xgene_ahci_qc_issue, xgene_ahci_qc_prep, xgene_ahci_qc_fill_rtf, xgene_ahci_softreset, and xgene_ahci_do_softreset)
* Rename function xgene_ahci_enable_phy to xgene_ahci_force_phy_rdy
* Clean up hardreset functions
* Require v7 of the PHY driver
v8:
* Remove _ADDR from defines
* Remove define MSTAWAUX_COHERENT_BYPASS_SET and STARAUX_COHERENT_BYPASS_SET and use direct coding
* Remove the un-necessary check for DTS boot with built in ACPI table
* Switch to use dma_set_mask_and_coherent for setting DMA mask
* Remove ACPI table matching code
* Update clock-names for sata01clk, sata23clk, and sata45clk
v7:
* Update the clock code by toggle the clock
* Update the DTS clock mask values due to the clock spilt between host and v5 of the PHY drivers
v6:
* Update binding documentation
* Change select PHY_XGENE_SATA to PHY_XGENE
* Add ULL to constants
* Change indentation and comments
* Clean up the probe functions a bit more
* Remove xgene_ahci_remove function
* Add the flush register to DTS
* Remove the interrupt-parent from DTS
v5:
* Sync up to v3 of the PHY driver
* Remove MSLIM wrapper functions
* Change the memory shutdown loop to use usleep_range
* Use devm_ioremap_resource instead devm_ioremap
* Remove suspend/resume functions as not needed
v4:
* Remove the ID property in DT
* Remove the temporary PHY direct function call and use PHY function
* Change printk to pr_debug
* Move the IOB flush addresses into the DT
* Remove the parameters retrieval function as no longer needed
* Remove the header file as no longer needed
* Require v2 patch of the SATA PHY driver. Require slightly modification in the Kconfig as it is moved to folder driver/phy and use Kconfig PHY_XGENE_SATA instead SATA_XGENE_PHY.
v3:
* Move out the SATA PHY to another driver
* Remove the clock-cells entry from DTS
* Remove debug wrapper
* Remove delay functions wrapper
* Clean up resource and IRQ query
* Remove query clock name
* Switch to use dma_set_mask/dma_coherent_mask
* Remove un-necessary devm_kfree
* Update GPL license header to v2
* Spilt up function xgene_ahci_hardreset
* Spilt up function xgene_ahci_probe
* Remove all reference of CONFIG_ARCH_MSLIM
* Clean up chip revision code
v2:
* Clean up file sata_xgene.c with Lindent and etc
* Clean up file sata_xgene_serdes.c with Lindent and etc
* Add description to each patch
v1:
* inital version
---
Loc Ho (3):
Documentation: Add documentation for APM X-Gene SoC SATA host
controller DTS binding
ata: Add APM X-Gene SoC AHCI SATA host controller driver
arm64: Add APM X-Gene SoC AHCI SATA host controller DTS entries
.../devicetree/bindings/ata/apm-xgene.txt | 70 +++ arch/arm64/boot/dts/apm-storm.dtsi | 75 +++ drivers/ata/Kconfig | 8 + drivers/ata/Makefile | 1 + drivers/ata/ahci_xgene.c | 581 ++++++++++++++++++++ 5 files changed, 735 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/ata/apm-xgene.txt create mode 100644 drivers/ata/ahci_xgene.c
PATCH v13 1/3 Documentation: Add documentation for APM X-Gene SoC SATA host controller DTS binding
--- .../devicetree/bindings/ata/apm-xgene.txt | 70 ++++++++++++++++++++ 1 files changed, 70 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/ata/apm-xgene.txt
Documentation/devicetree/bindings/ata/apm-xgene.txt new file +70 -0
@@ -0,0 +1,70 @@ +* APM X-Gene 6.0 Gb/s SATA host controller nodes + +SATA host controller nodes are defined to describe on-chip Serial ATA +controllers. Each SATA controller (pair of ports) have its own node. + +Required properties: +- compatible : Shall contain: + * "apm,xgene-ahci-sgmii" if mux'ed with SGMII + * "apm,xgene-ahci-pcie" if mux'ed with PCIe +- reg : First memory resource shall be the AHCI memory + resource. + Second memory resource shall be the host controller + memory resource. +- interrupts : Interrupt-specifier for SATA host controller IRQ. +- clocks : Reference to the clock entry. +- phys : A list of phandles + phy-specifiers, one for each + entry in phy-names. +- phy-names : Should contain: + * "sata-6g" for the SATA 6.0Gbps PHY + +Optional properties: +- status : Shall be "ok" if enabled or "disabled" if disabled. + Default is "ok". +- interrupt-parent : Interrupt controller. + +Example: + sataclk: sataclk { + compatible = "fixed-clock"; + #clock-cells = <1>; + clock-frequency = <100000000>; + clock-output-names = "sataclk"; + }; + + phy2: phy at 1f22a000 { + compatible = "apm,xgene-phy"; + reg = <0x0 0x1f22a000 0x0 0x100>, + <0x0 0x1f22c000 0x0 0x100>; + #phy-cells = <1>; + }; + + phy3: phy at 1f23a000 { + compatible = "apm,xgene-phy"; + reg = <0x0 0x1f23a000 0x0 0x100>, + <0x0 0x1f23c000 0x0 0x100>; + #phy-cells = <1>; + }; + + sata2: sata at 1a400000 { + compatible = "apm,xgene-ahci-sgmii"; + reg = <0x0 0x1a400000 0x0 0x1000>, + <0x0 0x1f220000 0x0 0x10000>; + interrupt-parent = <&gic>; + interrupts = <0x0 0x87 0x4>; + status = "ok"; + clocks = <&sataclk 0>; + phys = <&phy2 0>; + phy-names = "sata-6g"; + }; + + sata3: sata at 1a800000 { + compatible = "apm,xgene-ahci-pcie"; + reg = <0x0 0x1a800000 0x0 0x1000>, + <0x0 0x1f230000 0x0 0x10000>; + interrupt-parent = <&gic>; + interrupts = <0x0 0x88 0x4>; + status = "ok"; + clocks = <&sataclk 0>; + phys = <&phy3 0>; + phy-names = "sata-6g"; + };
Signature · 1 line
1.5.5
PATCH v13 2/3 ata: Add APM X-Gene SoC AHCI SATA host controller driver
This patch adds support for the APM X-Gene SoC AHCI SATA host controller driver. It requires the corresponding APM X-Gene SoC PHY driver.
--- drivers/ata/Kconfig | 8 + drivers/ata/Makefile | 1 + drivers/ata/ahci_xgene.c | 581 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 590 insertions(+), 0 deletions(-) create mode 100644 drivers/ata/ahci_xgene.c
drivers/ata/Kconfig +8 -0
@@ -115,6 +115,14 @@ config AHCI_SUNXI If unsure, say N. +config AHCI_XGENE + tristate "APM X-Gene 6.0Gbps AHCI SATA host controller support" + depends on ARM64 || COMPILE_TEST + select SATA_AHCI_PLATFORM + select PHY_XGENE + help + This option enables support for APM X-Gene SoC SATA host controller. + config SATA_FSL tristate "Freescale 3.0Gbps SATA support" depends on FSL_SOC
drivers/ata/Makefile +1 -0
@@ -12,6 +12,7 @@ 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_AHCI_SUNXI) += ahci_sunxi.o +obj-$(CONFIG_AHCI_XGENE) += ahci_xgene.o # SFF w/ custom DMA obj-$(CONFIG_PDC_ADMA) += pdc_adma.o
drivers/ata/ahci_xgene.c new file +581 -0
581 lines not on this page · raw message
Signature · 1 line
1.5.5
PATCH v13 3/3 arm64: Add APM X-Gene SoC AHCI SATA host controller DTS entries
--- arch/arm64/boot/dts/apm-storm.dtsi | 75 ++++++++++++++++++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-)
arch/arm64/boot/dts/apm-storm.dtsi +75 -0
@@ -221,6 +221,48 @@ enable-offset = <0x0>; enable-mask = <0x06>; }; + + sata01clk: sata01clk at 1f21c000 { + compatible = "apm,xgene-device-clock"; + #clock-cells = <1>; + clocks = <&socplldiv2 0>; + clock-names = "socplldiv2"; + reg = <0x0 0x1f21c000 0x0 0x1000>; + reg-names = "csr-reg"; + clock-output-names = "sata01clk"; + csr-offset = <0x4>; + csr-mask = <0x05>; + enable-offset = <0x0>; + enable-mask = <0x39>; + }; + + sata23clk: sata23clk at 1f22c000 { + compatible = "apm,xgene-device-clock"; + #clock-cells = <1>; + clocks = <&socplldiv2 0>; + clock-names = "socplldiv2"; + reg = <0x0 0x1f22c000 0x0 0x1000>; + reg-names = "csr-reg"; + clock-output-names = "sata23clk"; + csr-offset = <0x4>; + csr-mask = <0x05>; + enable-offset = <0x0>; + enable-mask = <0x39>; + }; + + sata45clk: sata45clk at 1f23c000 { + compatible = "apm,xgene-device-clock"; + #clock-cells = <1>; + clocks = <&socplldiv2 0>; + clock-names = "socplldiv2"; + reg = <0x0 0x1f23c000 0x0 0x1000>; + reg-names = "csr-reg"; + clock-output-names = "sata45clk"; + csr-offset = <0x4>; + csr-mask = <0x05>; + enable-offset = <0x0>; + enable-mask = <0x39>; + }; }; serial0: serial at 1c020000 {
@@ -262,5 +304,38 @@ apm,tx-boost-gain = <31 31 31 31 31 31>; apm,tx-eye-tuning = <2 10 10 2 10 10>; }; + + sata1: sata at 1a000000 { + compatible = "apm,xgene-ahci-sgmii"; + reg = <0x0 0x1a000000 0x0 0x1000>, + <0x0 0x1f210000 0x0 0x10000>; + interrupts = <0x0 0x86 0x4>; + status = "disabled"; + clocks = <&sata01clk 0>; + phys = <&phy1 0>; + phy-names = "sata-6g"; + }; + + sata2: sata at 1a400000 { + compatible = "apm,xgene-ahci-sgmii"; + reg = <0x0 0x1a400000 0x0 0x1000>, + <0x0 0x1f220000 0x0 0x10000>; + interrupts = <0x0 0x87 0x4>; + status = "ok"; + clocks = <&sata23clk 0>; + phys = <&phy2 0>; + phy-names = "sata-6g"; + }; + + sata3: sata at 1a800000 { + compatible = "apm,xgene-ahci-pcie"; + reg = <0x0 0x1a800000 0x0 0x1000>, + <0x0 0x1f230000 0x0 0x10000>; + interrupts = <0x0 0x88 0x4>; + status = "ok"; + clocks = <&sata45clk 0>; + phys = <&phy3 0>; + phy-names = "sata-6g"; + }; }; };
Signature · 1 line
1.5.5
PATCH v13 3/3 arm64: Add APM X-Gene SoC AHCI SATA host controller DTS entries
Quoted 3 lines · Loc Ho
Signed-off-by Loc Ho <[email protected]>Signed-off-by Tuan Phan <[email protected]>Signed-off-by Suman Tripathi <[email protected]>
This doesn't apply cleanly to libata/for-3.15. How should this be routed?
Thanks.
Signature · 1 line
tejun
A message that is not in the archive (sent off-list or not yet received): CAPw-ZT=CNdGn_iPp+jJbymvgBTNpXe1nCLeNwPWBdD3AAnHE6A@mail.gmail.com
PATCH v13 3/3 arm64: Add APM X-Gene SoC AHCI SATA host controller DTS entries
Hi,
Quoted 7 lines · Loc Ho
Hi Tejun,
On Sun, Feb 23, 2014 at 10:54:25PM -0700, Loc Ho wrote:
> Signed-off-by: Loc Ho <lho at apm.com <mailto:[email protected]>>
> Signed-off-by: Tuan Phan <tphan at apm.com <mailto:[email protected]>> > Signed-off-by: Suman Tripathi <stripathi at apm.com <mailto:[email protected]>>
Quoted 8 lines
This doesn't apply cleanly to libata/for-3.15. How should this be routed?
You need to apply the corresponding PHY driver as well. Are you taken the corresponding PHY driver into your libata tree? If not, we will need to route to Kishon generic PHY framework tree. I include Kishon Vijay Abraham to this email thread.
I prefer dt entry go via dt maintainer. However I can add my Acked-by for the dt patches if you can copy me in those patches.
Quoted 5 lines
Kishon,
Do I need to re-send my SATA PHY driver to you as I had being posting them to the scsi/arm mailing list?
Yes please.
Thanks
Kishon
PATCH v13 3/3 arm64: Add APM X-Gene SoC AHCI SATA host controller DTS entries
Hi Kishon/Tejun,
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Signed-off-by Loc Ho <lho at apm.com <mailto:[email protected]>>Signed-off-by Tuan Phan <tphan at apm.com <mailto:[email protected]>>Signed-off-by Suman Tripathi <stripathi at apm.com <mailto:[email protected]>>This doesn't apply cleanly to libata/for-3.15. How should this be routed?
Quoted 7 lines
Quoted 4 lines
You need to apply the corresponding PHY driver as well. Are you taken the corresponding PHY driver into your libata tree? If not, we will need to route to Kishon generic PHY framework tree. I include Kishon Vijay Abraham to this email thread.
I prefer dt entry go via dt maintainer. However I can add my Acked-by for the dt patches if you can copy me in those patches.
The dt email is cc'ed in the patch. Do I need to do anything more here?
Quoted 6 lines
Quoted 4 lines
Kishon,
Do I need to re-send my SATA PHY driver to you as I had being posting them to the scsi/arm mailing list?
Yes please.
Okay... I will re-post the PHY to you and linux-kernel at vger.kernel.org.
-Loc
PATCH v13 2/3 ata: Add APM X-Gene SoC AHCI SATA host controller driver
In reply to Loc HoHello, Loc.
Almost there. Just one more thing.
On Sun, Feb 23, 2014 at 10:54:24PM -0700, Loc Ho wrote:
....
Quoted 19 lines
drivers/ata/ahci_xgene.c new file +19
-0+static int xgene_ahci_init_memram (struct xgene_ahci_context *ctx) +{ +void __iomem *diagcsr = ctx->csr_base +SATA_DIAG_OFFSET ; +int try; +u32 val; + + val =readl (diagcsr +CFG_MEM_RAM_SHUTDOWN ); +if (val ==0 ) { +dev_dbg (ctx->dev,"memory already released from shutdown\n" ); +return 0 ; + } +dev_dbg (ctx->dev,"Release memory from shutdown\n" ); +/* SATA controller memory in shutdown. Remove from shutdown. */ +writel (0x0 , diagcsr +CFG_MEM_RAM_SHUTDOWN ); +readl (diagcsr +CFG_MEM_RAM_SHUTDOWN );/* Force a barrier */ + +/* Check for at least ~1ms */ + try =1000 ; + do {
drivers/ata/ahci_xgene.c line 128
Quoted 10 lines
drivers/ata/ahci_xgene.c new file +10
-0+ val =readl (diagcsr +BLOCK_MEM_RDY ); +if (val !=0xFFFFFFFF ) +usleep_range (1 ,100 ); + }while (val !=0xFFFFFFFF && try-- >0 ); +if (try <=0 ) { +dev_err (ctx->dev,"failed to release memory from shutdown\n" ); +return -ENODEV ; + } +return 0 ; +}
Hmm... ISTR raising this issue before but the above is way more elaborate than necessary. This isn't in any sense a hot path and 1ms is short enough to handle it simply. If the only thing being addressed here is that the init may take upto 1ms, you might as well just do
writel(0x0, diagcsr + CFG_MEM_RAM_SHUTDOWN);
readl(diagcsr + CFG_MEM_RAM_SHUTDOWN); /* Force a barrier */
msleep(1); /* reset may take upto 1ms */
if (readl(diagcsr + BLOCK_MEM_RDY) != 0xFFFFFFFF) {
dev_err(...);
return -ENODEV;
}
return 0;Thanks.
Signature · 1 line
tejun
A message that is not in the archive (sent off-list or not yet received): CAPw-ZT=VHj+fO-7+G6Zdx+T+osJhXaR9AYHbx_TbWFWHBiDKYg@mail.gmail.com
PATCH v13 2/3 ata: Add APM X-Gene SoC AHCI SATA host controller driver
Hey,
Quoted 6 lines · Loc Ho
The completion of the RAM removal from shutdown is quite fast. As per spec, the max time is 1ms but from the run-time code, it only take one (1us) or two (2us) read for this to completed. An 1 ms hard delay is more than 100 time slower. The code isn't that complex. If you strongly advise that I should remove the while loop and use 1 ms, then okay. Otherwise, I would prefer to keep the original code.
The code is rather silly because as it's written the delay may be upto 100ms. If it's sitting in the hot path, using things like usleep_range() makes sense. In probe / shutdown paths, it's just an unnecessary distraction. If the timeout is as short as 1ms, it doesn't really matter whether the hardware can do it faster or not. It's just irrelevant. Please just write simple code.
Thanks.
Signature · 1 line
tejun