xref: /OK3568_Linux_fs/u-boot/arch/arm/mach-mvebu/sata.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (C) 2016 Stefan Roese <sr@denx.de>
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <ahci.h>
9 #include <dm.h>
10 
11 DECLARE_GLOBAL_DATA_PTR;
12 
13 /*
14  * Dummy implementation that can be overwritten by a board
15  * specific function
16  */
board_ahci_enable(void)17 __weak int board_ahci_enable(void)
18 {
19 	return 0;
20 }
21 
22 #ifdef CONFIG_ARMADA_8K
23 /* CP110 has different AHCI port addresses */
ahci_port_base(void __iomem * base,u32 port)24 void __iomem *ahci_port_base(void __iomem *base, u32 port)
25 {
26 	return base + 0x10000 + (port * 0x10000);
27 }
28 #endif
29 
mvebu_ahci_probe(struct udevice * dev)30 static int mvebu_ahci_probe(struct udevice *dev)
31 {
32 	/*
33 	 * Board specific SATA / AHCI enable code, e.g. enable the
34 	 * AHCI power or deassert reset
35 	 */
36 	board_ahci_enable();
37 
38 	ahci_init(devfdt_get_addr_ptr(dev));
39 
40 	return 0;
41 }
42 
43 static const struct udevice_id mvebu_ahci_ids[] = {
44 	{ .compatible = "marvell,armada-3700-ahci" },
45 	{ .compatible = "marvell,armada-8k-ahci" },
46 	{ }
47 };
48 
49 U_BOOT_DRIVER(ahci_mvebu_drv) = {
50 	.name		= "ahci_mvebu",
51 	.id		= UCLASS_AHCI,
52 	.of_match	= mvebu_ahci_ids,
53 	.probe		= mvebu_ahci_probe,
54 };
55