blob: 8be1826d4055a19cf84d8c3171c1fec759f20a25 [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
Ken Ma6ac85382018-05-25 15:49:26 +080042 ahci_probe_scsi(dev, (ulong)devfdt_get_addr_ptr(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 Roesef61aefc2016-05-17 15:00:30 +020051 { }
52};
53
54U_BOOT_DRIVER(ahci_mvebu_drv) = {
55 .name = "ahci_mvebu",
56 .id = UCLASS_AHCI,
57 .of_match = mvebu_ahci_ids,
Ken Ma6ac85382018-05-25 15:49:26 +080058 .bind = mvebu_ahci_bind,
Stefan Roesef61aefc2016-05-17 15:00:30 +020059 .probe = mvebu_ahci_probe,
60};