2 * SATA glue for Cavium Octeon III SOCs.
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
9 * Copyright (C) 2010-2015 Cavium Networks
13 #include <linux/module.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/platform_device.h>
16 #include <linux/of_platform.h>
18 #include <asm/octeon/octeon.h>
20 #define CVMX_SATA_UCTL_SHIM_CFG 0xE8
22 #define SATA_UCTL_ENDIAN_MODE_BIG 1
23 #define SATA_UCTL_ENDIAN_MODE_LITTLE 0
24 #define SATA_UCTL_ENDIAN_MODE_MASK 3
26 #define SATA_UCTL_DMA_ENDIAN_MODE_SHIFT 8
27 #define SATA_UCTL_CSR_ENDIAN_MODE_SHIFT 0
28 #define SATA_UCTL_DMA_READ_CMD_SHIFT 12
30 static int ahci_octeon_probe(struct platform_device
*pdev
)
32 struct device
*dev
= &pdev
->dev
;
33 struct device_node
*node
= dev
->of_node
;
38 base
= devm_platform_ioremap_resource(pdev
, 0);
42 cfg
= cvmx_readq_csr(base
+ CVMX_SATA_UCTL_SHIM_CFG
);
44 cfg
&= ~(SATA_UCTL_ENDIAN_MODE_MASK
<< SATA_UCTL_DMA_ENDIAN_MODE_SHIFT
);
45 cfg
&= ~(SATA_UCTL_ENDIAN_MODE_MASK
<< SATA_UCTL_CSR_ENDIAN_MODE_SHIFT
);
48 cfg
|= SATA_UCTL_ENDIAN_MODE_BIG
<< SATA_UCTL_DMA_ENDIAN_MODE_SHIFT
;
49 cfg
|= SATA_UCTL_ENDIAN_MODE_BIG
<< SATA_UCTL_CSR_ENDIAN_MODE_SHIFT
;
51 cfg
|= SATA_UCTL_ENDIAN_MODE_LITTLE
<< SATA_UCTL_DMA_ENDIAN_MODE_SHIFT
;
52 cfg
|= SATA_UCTL_ENDIAN_MODE_LITTLE
<< SATA_UCTL_CSR_ENDIAN_MODE_SHIFT
;
55 cfg
|= 1 << SATA_UCTL_DMA_READ_CMD_SHIFT
;
57 cvmx_writeq_csr(base
+ CVMX_SATA_UCTL_SHIM_CFG
, cfg
);
60 dev_err(dev
, "no device node, failed to add octeon sata\n");
64 ret
= of_platform_populate(node
, NULL
, NULL
, dev
);
66 dev_err(dev
, "failed to add ahci-platform core\n");
73 static const struct of_device_id octeon_ahci_match
[] = {
74 { .compatible
= "cavium,octeon-7130-sata-uctl", },
77 MODULE_DEVICE_TABLE(of
, octeon_ahci_match
);
79 static struct platform_driver ahci_octeon_driver
= {
80 .probe
= ahci_octeon_probe
,
82 .name
= "octeon-ahci",
83 .of_match_table
= octeon_ahci_match
,
87 module_platform_driver(ahci_octeon_driver
);
89 MODULE_LICENSE("GPL");
90 MODULE_AUTHOR("Cavium, Inc. <support@cavium.com>");
91 MODULE_DESCRIPTION("Cavium Inc. sata config.");