ata: Add APM X-Gene SoC AHCI SATA host controller support
Subsystems (3)
v11 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.
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 | 554 ++++++++++++++++++++ 5 files changed, 708 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/ata/apm-xgene.txt create mode 100644 drivers/ata/ahci_xgene.c
PATCH v11 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 v11 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 | 554 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 563 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 +554 -0
554 lines not on this page · raw message
Signature · 1 line
1.5.5
PATCH v11 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 v11 2/3 ata: Add APM X-Gene SoC AHCI SATA host controller driver
In reply to Loc HoHello, Loc.
On Mon, Feb 17, 2014 at 12:17:12AM -0700, Loc Ho wrote:
...
drivers/ata/ahci_xgene.c line 107
Quoted 8 lines
drivers/ata/ahci_xgene.c new file +8
-0+static int xgene_ahci_get_channel (struct ata_host *host,struct ata_port *port) +{ +int i; +for (i =0 ; i < host->n_ports; i++) +if (host->ports[i] == port) +return i; +return -1 ; +}
Didn't I ask you why you weren't using ap->port_no?
Quoted 7 lines
+/*
+ * Custom Query ID command
+ *
+ * Due to HW errata, we must stop and re-start the port state machine after
+ * read ID command. Also disable support for DEVSLP as hardware don't support
+ * it.
+ */
Please use /** function comment style.
drivers/ata/ahci_xgene.c line 156
Quoted 11 lines
drivers/ata/ahci_xgene.c new file +11
-0+static unsigned int xgene_ahci_read_id (struct ata_device *dev, +struct ata_taskfile *tf,u16 *id) +{ +u32 err_mask; +void __iomem *port_mmio =ahci_port_base (dev->link->ap); + + err_mask =ata_do_dev_read_id (dev, tf, id); +if (err_mask) +return err_mask; + +/* Mask reserved area. Bit78 spec of Link Power Management
Another review point which hasn't been addressed. Please use fully-winged comments for multiline comments.
Quoted 23 lines
drivers/ata/ahci_xgene.c new file +23
-0+* bit15-8: reserved +* bit7: NCQ autosence +* bit6: Software settings preservation supported +* bit5: reserved +* bit4: In-order sata delivery supported +* bit3: DIPM requests supported +* bit2: DMA Setup FIS Auto-Activate optimization supported +* bit1: DMA Setup FIX non-Zero buffer offsets supported +* bit0: Reserved +* +* Clear reserved bit (DEVSLP bit) as we don't support DEVSLP +*/ + id[78 ] &=0x00FF ; + +/* Restart the port if required due to HW errata */ +if (!readl (port_mmio +PORT_CMD_ISSUE )) { +writel (PORT_CMD_FIS_RX , port_mmio +PORT_CMD ); +readl (port_mmio +PORT_CMD );/* Force a barrier */ +writel (PORT_CMD_FIS_RX |PORT_CMD_START , port_mmio +PORT_CMD ); +readl (port_mmio +PORT_CMD );/* Force a barrier */ + } +return 0 ; +}
...
Quoted 3 lines
drivers/ata/ahci_xgene.c new file +3
-0+static int xgene_ahci_do_hardreset (struct ata_link *link, +unsigned long deadline,bool *online) +{
...
Quoted 12 lines
drivers/ata/ahci_xgene.c new file +12
-0+hardreset_retry: +/* clear D2H reception area to properly wait for D2H FIS */ +ata_tf_init (link->device, &tf); + tf.command =ATA_BUSY ; +ata_tf_to_fis (&tf,0 ,0 , d2h_fis); + rc =sata_link_hardreset (link, timing, deadline, online, + ahci_check_ready); + +if (*online) { +int chan =xgene_ahci_get_channel (ap->host, ap); + +/* Check to ensure that the disk comes up in matching speed */
drivers/ata/ahci_xgene.c line 281
Quoted 10 lines
drivers/ata/ahci_xgene.c new file +10
-0+if (first_time) { +u32 gen_speed; + + first_time =0 ; +sata_scr_read (link,SCR_STATUS , &gen_speed); + gen_speed = (gen_speed >>4 ) &0xf ; +if (gen_speed ==1 || gen_speed ==2 ) { +/* For Gen2/1 and first time, let's check again +* with Gen2/1 PHY to ensure actual Gen2/1 disk. +*/
Another review point not addressed.
Thanks.
Signature · 1 line
tejun