blob: f05150d61ddf4ff5d4c70c53995aeb0caa072cb1 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roesef61aefc2016-05-17 15:00:30 +02002/*
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
Stefan Roesef61aefc2016-05-17 15:00:30 +02004 */
5
6#include <common.h>
7#include <ahci.h>
8#include <dm.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -06009#include <log.h>
Stefan Roesef61aefc2016-05-17 15:00:30 +020010
Stefan Roesef61aefc2016-05-17 15:00:30 +020011/*
12 * Dummy implementation that can be overwritten by a board
13 * specific function
14 */
15__weak int board_ahci_enable(void)
16{
17 return 0;
18}
19
Ken Ma6ac85382018-05-25 15:49:26 +080020static 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
Stefan Roesef61aefc2016-05-17 15:00:30 +020034static 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
Stefan Roese1eefd492021-04-07 09:12:34 +020042 ahci_probe_scsi(dev, (ulong)dev_remap_addr(dev));
Stefan Roesef61aefc2016-05-17 15:00:30 +020043
44 return 0;
45}
46
47static const struct udevice_id mvebu_ahci_ids[] = {
Baruch Siach5903b912019-03-24 13:27:44 +020048 { .compatible = "marvell,armada-380-ahci" },
Stefan Roesef61aefc2016-05-17 15:00:30 +020049 { .compatible = "marvell,armada-3700-ahci" },
Stefan Roese21b29fc2016-05-25 08:13:45 +020050 { .compatible = "marvell,armada-8k-ahci" },
Stefan Roese1eefd492021-04-07 09:12:34 +020051 { .compatible = "cavium,octeon-7130-ahci" },
Stefan Roesef61aefc2016-05-17 15:00:30 +020052 { }
53};
54
55U_BOOT_DRIVER(ahci_mvebu_drv) = {
56 .name = "ahci_mvebu",
57 .id = UCLASS_AHCI,
58 .of_match = mvebu_ahci_ids,
Ken Ma6ac85382018-05-25 15:49:26 +080059 .bind = mvebu_ahci_bind,
Stefan Roesef61aefc2016-05-17 15:00:30 +020060 .probe = mvebu_ahci_probe,
61};