diff options
Diffstat (limited to 'drivers/ata/disk_ata_drive.c')
-rw-r--r-- | drivers/ata/disk_ata_drive.c | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c index 11f7151e51..a49acc1641 100644 --- a/drivers/ata/disk_ata_drive.c +++ b/drivers/ata/disk_ata_drive.c @@ -1,18 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2011 Juergen Beisert, Pengutronix * * Inspired from various soures like http://wiki.osdev.org/ATA_PIO_Mode, * u-boot and the linux kernel - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #include <common.h> @@ -26,7 +17,7 @@ #include <disks.h> #include <dma.h> -static uint64_t ata_id_n_sectors(uint16_t *id) +static blkcnt_t ata_id_n_sectors(uint16_t *id) { if (ata_id_has_lba(id)) { if (ata_id_has_lba48(id)) @@ -75,7 +66,7 @@ static void __maybe_unused ata_dump_id(uint16_t *id) unsigned char serial[ATA_ID_SERNO_LEN + 1]; unsigned char firmware[ATA_ID_FW_REV_LEN + 1]; unsigned char product[ATA_ID_PROD_LEN + 1]; - uint64_t n_sectors; + sector_t n_sectors; /* Serial number */ ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial)); @@ -89,9 +80,9 @@ static void __maybe_unused ata_dump_id(uint16_t *id) ata_id_c_string(id, product, ATA_ID_PROD, sizeof(product)); printf("Product model number: %s\n\r", product); - /* Total sectors of device */ + /* Total sectors of device */ n_sectors = ata_id_n_sectors(id); - printf("Capablity: %lld sectors\n\r", n_sectors); + printf("Capacity: %lld sectors\n\r", n_sectors); printf ("id[49]: capabilities = 0x%04x\n" "id[53]: field valid = 0x%04x\n" @@ -104,12 +95,14 @@ static void __maybe_unused ata_dump_id(uint16_t *id) id[ATA_ID_PIO_MODES], id[ATA_ID_QUEUE_DEPTH]); - printf ("id[76]: sata capablity = 0x%04x\n" + printf ("id[76]: sata capabilities 1 = 0x%04x\n" + "id[77]: sata capabilities 2 = 0x%04x\n" "id[78]: sata features supported = 0x%04x\n" - "id[79]: sata features enable = 0x%04x\n", - id[76], /* FIXME */ - id[78], /* FIXME */ - id[79]); /* FIXME */ + "id[79]: sata features enabled = 0x%04x\n", + id[ATA_ID_SATA_CAPAB_1], + id[ATA_ID_SATA_CAPAB_2], + id[ATA_ID_SATA_FEAT_SUPP], + id[ATA_ID_SATA_FEAT_ENABLE]); printf ("id[80]: major version = 0x%04x\n" "id[81]: minor version = 0x%04x\n" @@ -117,12 +110,13 @@ static void __maybe_unused ata_dump_id(uint16_t *id) "id[83]: command set supported 2 = 0x%04x\n" "id[84]: command set extension = 0x%04x\n", id[ATA_ID_MAJOR_VER], - id[81], /* FIXME */ + id[ATA_ID_MINOR_VER], id[ATA_ID_COMMAND_SET_1], id[ATA_ID_COMMAND_SET_2], id[ATA_ID_CFSSE]); - printf ("id[85]: command set enable 1 = 0x%04x\n" - "id[86]: command set enable 2 = 0x%04x\n" + + printf ("id[85]: command set enabled 1 = 0x%04x\n" + "id[86]: command set enabled 2 = 0x%04x\n" "id[87]: command set default = 0x%04x\n" "id[88]: udma = 0x%04x\n" "id[93]: hardware reset result = 0x%04x\n", @@ -165,8 +159,8 @@ static void ata_fix_endianess(uint16_t *buf, unsigned wds) * @note Due to 'block' is of type 'int' only small disks can be handled! * @todo Optimize the read loop */ -static int ata_read(struct block_device *blk, void *buffer, int block, - int num_blocks) +static int ata_read(struct block_device *blk, void *buffer, sector_t block, + blkcnt_t num_blocks) { struct ata_port *port = container_of(blk, struct ata_port, blk); @@ -187,7 +181,7 @@ static int ata_read(struct block_device *blk, void *buffer, int block, * @todo Optimize the write loop */ static int __maybe_unused ata_write(struct block_device *blk, - const void *buffer, int block, int num_blocks) + const void *buffer, sector_t block, blkcnt_t num_blocks) { struct ata_port *port = container_of(blk, struct ata_port, blk); @@ -205,7 +199,7 @@ static int ata_port_init(struct ata_port *port) { int rc; struct ata_port_operations *ops = port->ops; - struct device_d *dev = &port->class_dev; + struct device *dev = &port->class_dev; if (ops->init) { rc = ops->init(port); @@ -251,6 +245,7 @@ static int ata_port_init(struct ata_port *port) port->blk.num_blocks = ata_id_n_sectors(port->id); port->blk.blockbits = SECTOR_SHIFT; + port->blk.type = port->ahci ? BLK_TYPE_AHCI : BLK_TYPE_IDE; rc = blockdevice_register(&port->blk); if (rc != 0) { @@ -260,11 +255,6 @@ static int ata_port_init(struct ata_port *port) dev_info(dev, "registered /dev/%s\n", port->blk.cdev.name); - /* create partitions on demand */ - rc = parse_partition_table(&port->blk); - if (rc != 0) - dev_warn(dev, "No partition table found\n"); - return 0; on_error: @@ -299,14 +289,14 @@ static int ata_set_probe(struct param_d *param, void *priv) return ata_port_detect(port); } -static int ata_detect(struct device_d *dev) +static int ata_detect(struct device *dev) { struct ata_port *port = container_of(dev, struct ata_port, class_dev); return ata_port_detect(port); } -static void ata_info(struct device_d *dev) +static void ata_info(struct device *dev) { struct ata_port *port = container_of(dev, struct ata_port, class_dev); |