add CNS3xxx AHCI support
v3 cover add CNS3xxx AHCI support
From: Mac Lin <[email protected]>
v3:
- Make the SoC-specific changes into ahci_platform.c directly.
- Some cosmetic code changes
v2: http://www.spinics.net/lists/linux-ide/msg39766.html
- Switch ahci_platform to module device table matching to add SoC specific support
v1: http://www.spinics.net/lists/arm-kernel/msg106236.html
- Add CNS3xxx SoC specific AHCI support
This patchset is based on linux-2.6.37
Mac Lin (2):
ahci_platform: switch to module device table matching
ahci_platform: add support for CNS3xxx SoC devices
arch/arm/mach-cns3xxx/devices.c | 2 +- drivers/ata/Kconfig | 11 ++++++++ drivers/ata/ahci_platform.c | 52 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 2 deletions(-)
PATCH v3 1/2 ahci_platform: switch to module device table matching
From: Mac Lin <[email protected]>
Switch the driver to use module device table matching mechanism to add SoC-specific parts to the generic driver.
--- drivers/ata/ahci_platform.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
drivers/ata/ahci_platform.c +12 -1
@@ -19,6 +19,7 @@#include <linux/interrupt.h> #include <linux/device.h> #include <linux/platform_device.h> +#include <linux/mod_devicetable.h> #include <linux/libata.h> #include <linux/ahci_platform.h> #include "ahci.h"
@@ -29,6 +30,7 @@ static struct scsi_host_template ahci_platform_sht = {static int __init ahci_probe (struct platform_device *pdev) { +const struct platform_device_id *platid =platform_get_device_id (pdev);struct device *dev = &pdev->dev;struct ahci_platform_data *pdata = dev->platform_data;struct ata_port_info pi = {
@@ -46,6 +48,9 @@ static int __init ahci_probe(struct platform_device *pdev)int i;int rc; +if (!pdata && platid && platid->driver_data) + pdata = (void *)platid->driver_data; + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem) {dev_err (dev,"no mmio space\n" );
@@ -171,12 +176,19 @@ static int __devexit ahci_remove(struct platform_device *pdev)return 0 ; } +static const struct platform_device_id ahci_pltfm_ids[] = { + {"ahci" , }, + { }, +}; +MODULE_DEVICE_TABLE (platform, ahci_pltfm_ids); +static struct platform_driver ahci_driver = { .remove =__devexit_p (ahci_remove), .driver = { .name ="ahci" , .owner =THIS_MODULE , }, + .id_table = ahci_pltfm_ids, };static int __init ahci_init (void )
@@ -194,4 +206,3 @@ module_exit(ahci_exit);MODULE_DESCRIPTION ("AHCI SATA platform driver" );MODULE_AUTHOR ("Anton Vorontsov <[email protected]>" );MODULE_LICENSE ("GPL" ); -MODULE_ALIAS ("platform:ahci" );
Signature · 1 line
1.7.3
PATCH v3 2/2 ahci_platform: add support for CNS3xxx SoC devices
In reply to mkl0301 at gmail.comFrom: Mac Lin <[email protected]>
CNS3xxx override the softreset function of ahci_platform ahci_softreset by cns3xxx_ahci_softreset, which would retry ahci_do_softreset again with pmp=0 if pmp=15 failed, for the controller has problem receiving D2H Reg FIS of the different PMP setting of the previous sent H2D Reg FIS.
Following describe the isssue with original ahci_platform driver on linux-2.6.37-rc3, arm/cns3xxx.
If CONFIG_SATA_PMP is enabled, while not using multiplier and connect the disks directly to the board, the disk cannot be found due to software reset always failed.
ahci ahci.0: forcing PORTS_IMPL to 0x3
ahci ahci.0: AHCI 0001.0100 32 slots 2 ports 3 Gbps 0x3 impl platform mode ahci ahci.0: flags: ncq sntf pm led clo only pmp pio slum part ccc scsi0 : ahci_platform
scsi1 : ahci_platform
ata1: SATA max UDMA/133 irq_stat 0x00400040, connection status changed irq 65
ata2: SATA max UDMA/133 mmio [mem 0x83000000-0x83ffffff] port 0x180 irq 65
ata2: SATA link down (SStatus 0 SControl 300)
ata1: link is slow to respond, please be patient (ready=0)
ata1: softreset failed (device not ready)
ata1: link is slow to respond, please be patient (ready=0)
ata1: softreset failed (device not ready)
ata1: link is slow to respond, please be patient (ready=0)
ata1: softreset failed (device not ready)
ata1: limiting SATA link speed to 1.5 Gbps
ata1: SATA link down (SStatus 1 SControl 310)
While using multiplier with CONFIG_SATA_PMP enabled, or using disks directly without CONFIG_SATA_PMP have no issue. It seems the device is sending D2H Reg FIS, but controller is not reflecting it on any known means.
--- arch/arm/mach-cns3xxx/devices.c | 2 +- drivers/ata/Kconfig | 11 +++++++++++ drivers/ata/ahci_platform.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletions(-)
arch/arm/mach-cns3xxx/devices.c +1 -1
@@ -40,7 +40,7 @@ static struct resource cns3xxx_ahci_resource[] = {static u64 cns3xxx_ahci_dmamask =DMA_BIT_MASK (32 );static struct platform_device cns3xxx_ahci_pdev = { - .name ="ahci" , + .name ="ahci-cns3xxx" , .id =0 , .resource = cns3xxx_ahci_resource, .num_resources =ARRAY_SIZE (cns3xxx_ahci_resource),
drivers/ata/Kconfig +11 -0
@@ -75,6 +75,17 @@ config SATA_AHCI_PLATFORM If unsure, say N. +config SATA_AHCI_CNS3XXX + bool "AHCI Support on the Cavium Networks CNS3xxx SOC" + depends on ARCH_CNS3XXX + depends on SATA_AHCI_PLATFORM + help + This option enables AHCI platform driver to support CNS3xxx + System-on-Chip devices. This is only needed when using CNS3xxx AHCI + controller. + + If unsure, say N. + config SATA_FSL tristate "Freescale 3.0Gbps SATA support" depends on FSL_SOC
drivers/ata/ahci_platform.c +39 -0
@@ -176,8 +176,47 @@ static int __devexit ahci_remove(struct platform_device *pdev)return 0 ; } +#ifdef CONFIG_SATA_AHCI_CNS3XXX +/* +* TODO: move cns3xxx_ahci_init to here after cns3xxx_pwr*() calls are +* thread-safe +*/ + +static int cns3xxx_ahci_softreset (struct ata_link *link,unsigned int *class, +unsigned long deadline) +{ +int pmp =sata_srst_pmp (link); +int ret; + + ret =ahci_do_softreset (link, class, pmp, deadline, ahci_check_ready); +if (pmp && ret) +return ahci_do_softreset (link, class,0 , deadline, + ahci_check_ready); +return ret; +} + +static struct ata_port_operations cns3xxx_ahci_ops = { + .inherits = &ahci_ops, + .softreset = cns3xxx_ahci_softreset, +}; + +static const struct ata_port_info cns3xxx_ata_port_info = { + .flags =AHCI_FLAG_COMMON , + .pio_mask =ATA_PIO4 , + .udma_mask =ATA_UDMA6 , + .port_ops = &cns3xxx_ahci_ops, +}; + +struct ahci_platform_data cns3xxx_ahci_platform_data = { + .ata_port_info = &cns3xxx_ata_port_info, +}; +#endif +static const struct platform_device_id ahci_pltfm_ids[] = { {"ahci" , }, +#ifdef CONFIG_SATA_AHCI_CNS3XXX + {"ahci-cns3xxx" , (kernel_ulong_t)&cns3xxx_ahci_platform_data}, +#endif { }, };MODULE_DEVICE_TABLE (platform, ahci_pltfm_ids);
Signature · 1 line
1.7.3
PATCH v3 2/2 ahci_platform: add support for CNS3xxx SoC devices
Hi Jeff,
2011/1/7 <[email protected]>:
Quoted 130 lines
From: Mac Lin <[email protected]>
CNS3xxx override the softreset function of
ahci_platformahci_softresetbycns3xxx_ahci_softreset, which would retryahci_do_softresetagain with pmp=0 if pmp=15 failed, for the controller has problem receiving D2H Reg FIS of the different PMP setting of the previous sent H2D Reg FIS.Following describe the isssue with original
ahci_platformdriver on linux-2.6.37-rc3, arm/cns3xxx.If
CONFIG_SATA_PMPis enabled, while not using multiplier and connect the disks directly to the board, the disk cannot be found due to software reset always failed.? ?ahci ahci.0: forcing
PORTS_IMPLto0x3
? ?ahci ahci.0: AHCI 0001.0100 32 slots 2 ports 3 Gbps0x3impl platform mode ? ?ahci ahci.0: flags: ncq sntf pm led clo only pmp pio slum part ccc ? ?scsi0 :ahci_platform
? ?scsi1 :ahci_platform
? ?ata1: SATA max UDMA/133irq_stat0x00400040, connection status changed irq 65 ? ?ata2: SATA max UDMA/133 mmio [mem 0x83000000-0x83ffffff] port0x180irq 65 ? ?ata2: SATA link down (SStatus 0 SControl 300)
? ?ata1: link is slow to respond, please be patient (ready=0)
? ?ata1: softreset failed (device not ready)
? ?ata1: link is slow to respond, please be patient (ready=0)
? ?ata1: softreset failed (device not ready)
? ?ata1: link is slow to respond, please be patient (ready=0)
? ?ata1: softreset failed (device not ready)
? ?ata1: limiting SATA link speed to 1.5 Gbps
? ?ata1: SATA link down (SStatus 1 SControl 310)While using multiplier with
CONFIG_SATA_PMPenabled, or using disks directly withoutCONFIG_SATA_PMPhave no issue. It seems the device is sending D2H Reg FIS, but controller is not reflecting it on any known means.Signed-off-by Mac Lin <[email protected]>---
?arch/arm/mach-cns3xxx/devices.c | ? ?2 +- ?drivers/ata/Kconfig ? ? ? ? ? ? | ? 11 +++++++++++ ?drivers/ata/ahci_platform.c ? ? | ? 39 +++++++++++++++++++++++++++++++++++++++?3 files changed, 51 insertions(+), 1 deletions(-)
arch/arm/mach-cns3xxx/devices.c +1
-1@@ -40,7 +40,7 @@ static struct resource cns3xxx_ahci_resource[] = { ?static u64 cns3xxx_ahci_dmamask = DMA_BIT_MASK(32); ?static struct platform_device cns3xxx_ahci_pdev = { - ? ? ? .name ? ? ? ? ? = "ahci", + ? ? ? .name ? ? ? ? ? = "ahci-cns3xxx", ? ? ? ?.id ? ? ? ? ? ? = 0, ? ? ? ?.resource ? ? ? = cns3xxx_ahci_resource, ? ? ? ?.num_resources ?= ARRAY_SIZE(cns3xxx_ahci_resource),drivers/ata/Kconfig +0
-0@@ -75,6 +75,17 @@ config SATA_AHCI_PLATFORM? ? ? ? ?If unsure, say N.
drivers/ata/Kconfig +11
-0+config SATA_AHCI_CNS3XXX + ? ? ? bool "AHCI Support on the Cavium Networks CNS3xxx SOC" + ? ? ? depends on ARCH_CNS3XXX + ? ? ? depends on SATA_AHCI_PLATFORM + ? ? ? help + ? ? ? ? This option enables AHCI platform driver to support CNS3xxx + ? ? ? ? System-on-Chip devices. This is only needed when using CNS3xxx AHCI + ? ? ? ? controller. + + ? ? ? ? If unsure, say N. +?config
SATA_FSL
? ? ? ?tristate "Freescale 3.0Gbps SATA support"
? ? ? ?depends onFSL_SOCdrivers/ata/ahci_platform.c +39
-1@@ -176,8 +176,47 @@ static int __devexit ahci_remove(struct platform_device *pdev) ? ? ? ?return 0; ?} +#ifdef CONFIG_SATA_AHCI_CNS3XXX +/* +* TODO: move cns3xxx_ahci_init to here after cns3xxx_pwr*() calls are +* thread-safe +*/ + +static int cns3xxx_ahci_softreset (struct ata_link *link,unsigned int *class, + ? ? ? ? ? ? ? ? ? ? ? ? unsigned long deadline) +{ + ? ? ? int pmp = sata_srst_pmp(link); + ? ? ? int ret; + + ? ? ? ret = ahci_do_softreset(link, class, pmp, deadline, ahci_check_ready); + ? ? ? if (pmp && ret) + ? ? ? ? ? ? ? return ahci_do_softreset(link, class, 0, deadline, + ? ? ? ? ? ? ? ? ? ? ? ahci_check_ready); + ? ? ? return ret; +} + +static struct ata_port_operations cns3xxx_ahci_ops = { + ? ? ? .inherits ? ? ? ? ? ? ? = &ahci_ops, + ? ? ? .softreset ? ? ? ? ? ? ?= cns3xxx_ahci_softreset, +}; + +static const struct ata_port_info cns3xxx_ata_port_info = { + ? ? ? .flags ? ? ? ? ?= AHCI_FLAG_COMMON, + ? ? ? .pio_mask ? ? ? = ATA_PIO4, + ? ? ? .udma_mask ? ? ?= ATA_UDMA6, + ? ? ? .port_ops ? ? ? = &cns3xxx_ahci_ops, +}; + +struct ahci_platform_data cns3xxx_ahci_platform_data = { + ? ? ? .ata_port_info ?= &cns3xxx_ata_port_info, +}; +#endif + ?static const struct platform_device_id ahci_pltfm_ids[] = { ? ? ? ?{ "ahci", }, +#ifdef CONFIG_SATA_AHCI_CNS3XXX + ? ? ? { "ahci-cns3xxx", (kernel_ulong_t)&cns3xxx_ahci_platform_data}, +#endif ? ? ? ?{ }, ?}; ?MODULE_DEVICE_TABLE(platform, ahci_pltfm_ids); --
Quoted 3 lines
1.7.3
The code is less readable with macro here and there. It would be more complicated if more SoC-specific code added.
I really prefer the original way.
Best Regards,
Mac Lin
PATCH v3 2/2 ahci_platform: add support for CNS3xxx SoC devices
Quoted 10 lines · Lin Mac
Hi Jeff,
2011/1/7 <[email protected]>:
Quoted 7 lines
From: Mac Lin <[email protected]>
CNS3xxx override the softreset function of
ahci_platformahci_softresetbycns3xxx_ahci_softreset, which would retryahci_do_softresetagain with pmp=0 if pmp=15 failed, for the controller has problem receiving D2H Reg FIS of the different PMP setting of the previous sent H2D Reg FIS.
Quoted 8 lines
Quoted 5 lines
Following describe the isssue with original
ahci_platformdriver on linux-2.6.37-rc3, arm/cns3xxx.If
CONFIG_SATA_PMPis enabled, while not using multiplier and connect the disks directly to the board, the disk cannot be found due to software reset alwayscomplicated if more SoC-specific code added.
I really prefer the original way.
Is there a reference to the original?
Signature · 3 lines
Ben Dooks, ben at fluff.org, http://www.fluff.org/ben/ Large Hadron Colada: A large Pina Colada that makes the universe disappear.
PATCH v3 2/2 ahci_platform: add support for CNS3xxx SoC devices
2011/1/7 Ben Dooks <[email protected]>:
Quoted 14 lines · Lin Mac
Quoted 13 lines
Hi Jeff,
2011/1/7 ?<[email protected]>:
Quoted 10 lines
From: Mac Lin <[email protected]>
CNS3xxx override the softreset function of
ahci_platformahci_softresetbycns3xxx_ahci_softreset, which would retryahci_do_softresetagain with pmp=0 if pmp=15 failed, for the controller has problem receiving D2H Reg FIS of the different PMP setting of the previous sent H2D Reg FIS.Following describe the isssue with original
ahci_platformdriver on linux-2.6.37-rc3, arm/cns3xxx.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
If
CONFIG_SATA_PMPis enabled, while not using multiplier and connect the disks directly to the board, the disk cannot be found due to software reset alwayscomplicated if more SoC-specific code added.
I really prefer the original way.Is there a reference to the original?
v2: http://www.spinics.net/lists/linux-ide/msg39766.html
Best Regards,
Mac Lin