blob: 6e5a6cbafd83c949110db03300e291c4f2119604 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roese05b17652016-05-17 15:00:30 +02002/*
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
Stefan Roese05b17652016-05-17 15:00:30 +02004 */
5
Stefan Roese05b17652016-05-17 15:00:30 +02006#include <ahci.h>
7#include <dm.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Stefan Roese05b17652016-05-17 15:00:30 +02009
Stefan Roese05b17652016-05-17 15:00:30 +020010/*
11 * Dummy implementation that can be overwritten by a board
12 * specific function
13 */
14__weak int board_ahci_enable(void)
15{
16 return 0;
17}
18
Patrick Rudolph33169ec2024-10-23 15:20:00 +020019static int generic_ahci_bind(struct udevice *dev)
Ken Mac3f0ca12018-05-25 15:49:26 +080020{
21 struct udevice *scsi_dev;
22 int ret;
23
24 ret = ahci_bind_scsi(dev, &scsi_dev);
25 if (ret) {
26 debug("%s: Failed to bind (err=%d\n)", __func__, ret);
27 return ret;
28 }
29
30 return 0;
31}
32
Patrick Rudolph33169ec2024-10-23 15:20:00 +020033static int generic_ahci_probe(struct udevice *dev)
Stefan Roese05b17652016-05-17 15:00:30 +020034{
35 /*
36 * Board specific SATA / AHCI enable code, e.g. enable the
37 * AHCI power or deassert reset
38 */
39 board_ahci_enable();
40
Stefan Roesec62067b2021-04-07 09:12:34 +020041 ahci_probe_scsi(dev, (ulong)dev_remap_addr(dev));
Stefan Roese05b17652016-05-17 15:00:30 +020042
43 return 0;
44}
45
Patrick Rudolph33169ec2024-10-23 15:20:00 +020046static const struct udevice_id generic_ahci_ids[] = {
Baruch Siach74765de2019-03-24 13:27:44 +020047 { .compatible = "marvell,armada-380-ahci" },
Stefan Roese05b17652016-05-17 15:00:30 +020048 { .compatible = "marvell,armada-3700-ahci" },
Stefan Roesecb410332016-05-25 08:13:45 +020049 { .compatible = "marvell,armada-8k-ahci" },
Stefan Roesec62067b2021-04-07 09:12:34 +020050 { .compatible = "cavium,octeon-7130-ahci" },
Patrick Rudolph33169ec2024-10-23 15:20:00 +020051 { .compatible = "generic-ahci" },
Stefan Roese05b17652016-05-17 15:00:30 +020052 { }
53};
54
Patrick Rudolph33169ec2024-10-23 15:20:00 +020055U_BOOT_DRIVER(ahci_generic_drv) = {
56 .name = "ahci_generic",
Stefan Roese05b17652016-05-17 15:00:30 +020057 .id = UCLASS_AHCI,
Patrick Rudolph33169ec2024-10-23 15:20:00 +020058 .of_match = generic_ahci_ids,
59 .bind = generic_ahci_bind,
60 .probe = generic_ahci_probe,
Stefan Roese05b17652016-05-17 15:00:30 +020061};