1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2016 Stefan Roese <sr@denx.de>
4  */
5 
6 #include <common.h>
7 #include <ahci.h>
8 #include <dm.h>
9 #include <log.h>
10 
11 /*
12  * Dummy implementation that can be overwritten by a board
13  * specific function
14  */
board_ahci_enable(void)15 __weak int board_ahci_enable(void)
16 {
17 	return 0;
18 }
19 
mvebu_ahci_bind(struct udevice * dev)20 static int mvebu_ahci_bind(struct udevice *dev)
21 {
22 	struct udevice *scsi_dev;
23 	int ret;
24 
25 	ret = ahci_bind_scsi(dev, &scsi_dev);
26 	if (ret) {
27 		debug("%s: Failed to bind (err=%d\n)", __func__, ret);
28 		return ret;
29 	}
30 
31 	return 0;
32 }
33 
mvebu_ahci_probe(struct udevice * dev)34 static int mvebu_ahci_probe(struct udevice *dev)
35 {
36 	/*
37 	 * Board specific SATA / AHCI enable code, e.g. enable the
38 	 * AHCI power or deassert reset
39 	 */
40 	board_ahci_enable();
41 
42 	ahci_probe_scsi(dev, dev_read_addr(dev));
43 
44 	return 0;
45 }
46 
47 static const struct udevice_id mvebu_ahci_ids[] = {
48 	{ .compatible = "marvell,armada-380-ahci" },
49 	{ .compatible = "marvell,armada-3700-ahci" },
50 	{ .compatible = "marvell,armada-8k-ahci" },
51 	{ }
52 };
53 
54 U_BOOT_DRIVER(ahci_mvebu_drv) = {
55 	.name		= "ahci_mvebu",
56 	.id		= UCLASS_AHCI,
57 	.of_match	= mvebu_ahci_ids,
58 	.bind		= mvebu_ahci_bind,
59 	.probe		= mvebu_ahci_probe,
60 };
61