1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2000-2005, DENX Software Engineering
5 * Copyright (C) Procsys. All rights reserved.
8 * Copyright (C) 2008 Freescale Semiconductor, Inc.
20 struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
23 int sata_reset(struct udevice *dev)
25 struct ahci_ops *ops = ahci_get_ops(dev);
30 return ops->reset(dev);
33 int sata_dm_port_status(struct udevice *dev, int port)
35 struct ahci_ops *ops = ahci_get_ops(dev);
37 if (!ops->port_status)
40 return ops->port_status(dev, port);
43 int sata_scan(struct udevice *dev)
45 struct ahci_ops *ops = ahci_get_ops(dev);
50 return ops->scan(dev);
54 #ifdef CONFIG_PARTITIONS
55 struct blk_desc *sata_get_dev(int dev)
57 return (dev < CONFIG_SYS_SATA_MAX_DEVICE) ? &sata_dev_desc[dev] : NULL;
62 static unsigned long sata_bread(struct udevice *dev, lbaint_t start,
63 lbaint_t blkcnt, void *dst)
68 static unsigned long sata_bwrite(struct udevice *dev, lbaint_t start,
69 lbaint_t blkcnt, const void *buffer)
75 int __sata_initialize(void)
80 for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
81 memset(&sata_dev_desc[i], 0, sizeof(struct blk_desc));
82 sata_dev_desc[i].if_type = IF_TYPE_SATA;
83 sata_dev_desc[i].devnum = i;
84 sata_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
85 sata_dev_desc[i].type = DEV_TYPE_HARDDISK;
86 sata_dev_desc[i].lba = 0;
87 sata_dev_desc[i].blksz = 512;
88 sata_dev_desc[i].log2blksz = LOG2(sata_dev_desc[i].blksz);
92 if (!rc && sata_dev_desc[i].lba > 0 &&
93 sata_dev_desc[i].blksz > 0) {
94 part_init(&sata_dev_desc[i]);
102 int sata_initialize(void) __attribute__((weak, alias("__sata_initialize")));
104 __weak int __sata_stop(void)
108 for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++)
109 err |= reset_sata(i);
112 printf("Could not reset some SATA devices\n");
116 int sata_stop(void) __attribute__((weak, alias("__sata_stop")));
119 static const struct blk_ops sata_blk_ops = {
121 .write = sata_bwrite,
124 U_BOOT_DRIVER(sata_blk) = {
127 .ops = &sata_blk_ops,