From a94c7e6abd8f81d3a4c76aa30c274bf975aac34a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lothar=20Wa=C3=9Fmann?= Date: Thu, 24 Oct 2013 10:23:18 +0200 Subject: [PATCH] ahci_platform: enable DT probing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Lothar Waßmann --- drivers/ata/ahci_platform.c | 102 ++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index d3d12be88f96..135461dc33ef 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "ahci.h" static void ahci_host_stop(struct ata_host *host); @@ -33,22 +34,6 @@ enum ahci_type { STRICT_AHCI, /* delayed DMA engine start */ }; -static struct platform_device_id ahci_devtype[] = { - { - .name = "ahci", - .driver_data = AHCI, - }, { - .name = "imx53-ahci", - .driver_data = IMX53_AHCI, - }, { - .name = "strict-ahci", - .driver_data = STRICT_AHCI, - }, { - /* sentinel */ - } -}; -MODULE_DEVICE_TABLE(platform, ahci_devtype); - struct ata_port_operations ahci_platform_ops = { .inherits = &ahci_ops, .host_stop = ahci_host_stop, @@ -60,28 +45,52 @@ static struct ata_port_operations ahci_platform_retry_srst_ops = { .host_stop = ahci_host_stop, }; -static const struct ata_port_info ahci_port_info[] = { - /* by features */ - [AHCI] = { - .flags = AHCI_FLAG_COMMON, - .pio_mask = ATA_PIO4, - .udma_mask = ATA_UDMA6, - .port_ops = &ahci_platform_ops, +static const struct ata_port_info ahci_port_info = { + .flags = AHCI_FLAG_COMMON, + .pio_mask = ATA_PIO4, + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_platform_ops, +}; + +static const struct ata_port_info imx53_ahci_port_info = { + .flags = AHCI_FLAG_COMMON, + .pio_mask = ATA_PIO4, + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_platform_retry_srst_ops, +}; + +static const struct ata_port_info strict_ahci_port_info = { + AHCI_HFLAGS (AHCI_HFLAG_DELAY_ENGINE), + .flags = AHCI_FLAG_COMMON, + .pio_mask = ATA_PIO4, + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_platform_ops, +}; + +static struct platform_device_id ahci_devtype[] = { + { + .name = "ahci", + .driver_data = (kernel_ulong_t)&ahci_port_info, }, - [IMX53_AHCI] = { - .flags = AHCI_FLAG_COMMON, - .pio_mask = ATA_PIO4, - .udma_mask = ATA_UDMA6, - .port_ops = &ahci_platform_retry_srst_ops, + { + .name = "imx53-ahci", + .driver_data = (kernel_ulong_t)&imx53_ahci_port_info, }, - [STRICT_AHCI] = { - AHCI_HFLAGS (AHCI_HFLAG_DELAY_ENGINE), - .flags = AHCI_FLAG_COMMON, - .pio_mask = ATA_PIO4, - .udma_mask = ATA_UDMA6, - .port_ops = &ahci_platform_ops, + { + .name = "strict-ahci", + .driver_data = (kernel_ulong_t)&strict_ahci_port_info, }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(platform, ahci_devtype); + +static const struct of_device_id ahci_of_match[] = { + { .compatible = "snps,spear-ahci", }, + { .compatible = "snps,exynos5440-ahci", }, + { .compatible = "fsl,imx53-ahci", .data = &imx53_ahci_port_info, }, + { /* sentinel */ } }; +MODULE_DEVICE_TABLE(of, ahci_of_match); static struct scsi_host_template ahci_platform_sht = { AHCI_SHT("ahci_platform"), @@ -91,9 +100,9 @@ static int ahci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct ahci_platform_data *pdata = dev_get_platdata(dev); - const struct platform_device_id *id = platform_get_device_id(pdev); - struct ata_port_info pi = ahci_port_info[id ? id->driver_data : 0]; - const struct ata_port_info *ppi[] = { &pi, NULL }; + const struct of_device_id *of_id; + struct ata_port_info pi; + const struct ata_port_info *ppi[] = { &pi, NULL, }; struct ahci_host_priv *hpriv; struct ata_host *host; struct resource *mem; @@ -101,6 +110,18 @@ static int ahci_probe(struct platform_device *pdev) int n_ports; int i; int rc; + const struct ata_port_info *p; + + of_id = of_match_device(ahci_of_match, &pdev->dev); + if (of_id) { + p = of_id->data; + } else { + const struct platform_device_id *id; + + id = platform_get_device_id(pdev); + p = (struct ata_port_info *)id->driver_data; + } + pi = *p; mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { @@ -326,13 +347,6 @@ disable_unprepare_clk: static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume); -static const struct of_device_id ahci_of_match[] = { - { .compatible = "snps,spear-ahci", }, - { .compatible = "snps,exynos5440-ahci", }, - {}, -}; -MODULE_DEVICE_TABLE(of, ahci_of_match); - static struct platform_driver ahci_driver = { .probe = ahci_probe, .remove = ata_platform_remove_one, -- 2.39.2