[U-Boot] [PATCH 2/6] dm: implement a SATA uclass

Mugunthan V N mugunthanvnm at ti.com
Tue Jan 19 06:09:13 CET 2016


On Monday 18 January 2016 02:53 PM, Bin Meng wrote:
> +Simon
> 
> On Mon, Jan 18, 2016 at 4:47 PM, Mugunthan V N <mugunthanvnm at ti.com> wrote:
>> Implement a SATA uclass that can represent a SATA controller.
>>
>> Signed-off-by: Mugunthan V N <mugunthanvnm at ti.com>
>> ---
>>  drivers/block/Kconfig       | 10 +++++++
>>  drivers/block/Makefile      |  2 ++
>>  drivers/block/sata-uclass.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
>>  include/dm/uclass-id.h      |  1 +
>>  4 files changed, 82 insertions(+)
>>  create mode 100644 drivers/block/sata-uclass.c
>>
>> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
>> index e69de29..44d8a6b 100644
>> --- a/drivers/block/Kconfig
>> +++ b/drivers/block/Kconfig
>> @@ -0,0 +1,10 @@
>> +menu "SATA Device Support"
>> +
>> +config SATA
>> +       bool "Enable driver model for SATA drivers"
>> +       depends on DM
>> +       help
>> +         Enable driver model for block devices like SCSI. It uses the
>> +         same API as block, but now implemented by the uclass.
>> +
>> +endmenu
>> diff --git a/drivers/block/Makefile b/drivers/block/Makefile
>> index eb8bda9..c2dae17 100644
>> --- a/drivers/block/Makefile
>> +++ b/drivers/block/Makefile
>> @@ -5,6 +5,8 @@
>>  # SPDX-License-Identifier:     GPL-2.0+
>>  #
>>
>> +obj-$(CONFIG_SATA) += sata-uclass.o
>> +
>>  obj-$(CONFIG_SCSI_AHCI) += ahci.o
>>  obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
>>  obj-$(CONFIG_FSL_SATA) += fsl_sata.o
>> diff --git a/drivers/block/sata-uclass.c b/drivers/block/sata-uclass.c
>> new file mode 100644
>> index 0000000..62773b6
>> --- /dev/null
>> +++ b/drivers/block/sata-uclass.c
>> @@ -0,0 +1,69 @@
>> +/*
>> + * SATA device U-Class driver
>> + *
>> + * (C) Copyright 2016
>> + *     Texas Instruments Incorporated, <www.ti.com>
>> + *
>> + * Author: Mugunthan V N <mugunthanvnm at ti.com>
>> + *
>> + * SPDX-License-Identifier:     GPL-2.0+
>> + */
>> +
>> +#include <common.h>
>> +#include <dm.h>
>> +#include <dm/uclass-internal.h>
>> +#include <dm/device-internal.h>
>> +#include <errno.h>
>> +#include <scsi.h>
>> +
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +/*
>> + * struct mmc_uclass_priv - Holds information about a device used by the uclass
>> + */
> 
> Please use single-line comment when it fits just one line. Also it's not mmc.

Will fix it in next version.

> 
>> +struct sata_uclass_priv {
>> +       struct block_dev_desc_t *block_dev;
>> +};
>> +
>> +int scsi_get_device(int index, struct udevice **devp)
>> +{
>> +       struct udevice *dev;
>> +       int ret;
>> +
>> +       ret = uclass_find_device(UCLASS_SATA, index, &dev);
>> +       if (ret || !dev) {
>> +               printf("%d device not found\n", index);
>> +               return ret;
>> +       }
>> +
>> +       ret = device_probe(dev);
>> +       if (ret) {
>> +               error("device probe error\n");
>> +               return ret;
>> +       }
>> +
>> +       *devp = dev;
>> +
>> +       return ret;
>> +}
>> +
>> +void scsi_init(void)
>> +{
>> +       struct udevice *dev;
>> +       int ret;
>> +
>> +       ret = scsi_get_device(0, &dev);
>> +       if (ret || !dev) {
>> +               error("scsi device not found\n");
>> +               return;
>> +       }
>> +
>> +       scsi_scan(1);
>> +}
>> +
>> +UCLASS_DRIVER(sata) = {
>> +       .id             = UCLASS_SATA,
>> +       .name           = "sata",
>> +       .flags          = DM_UC_FLAG_SEQ_ALIAS,
>> +       .per_device_auto_alloc_size = sizeof(struct sata_uclass_priv),
>> +};
>> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
>> index 27fa0b6..80977ca 100644
>> --- a/include/dm/uclass-id.h
>> +++ b/include/dm/uclass-id.h
>> @@ -55,6 +55,7 @@ enum uclass_id {
>>         UCLASS_RESET,           /* Reset device */
>>         UCLASS_REMOTEPROC,      /* Remote Processor device */
>>         UCLASS_RTC,             /* Real time clock device */
>> +       UCLASS_SATA,            /* SATA devices */
>>         UCLASS_SERIAL,          /* Serial UART */
>>         UCLASS_SPI,             /* SPI bus */
>>         UCLASS_SPI_FLASH,       /* SPI flash */
>> --
> 
> I would like to see a full DM conversion of the SCSI codes. But this
> patch looks to me it's just a place holder?

Ultimately that will be the final goal, now this is just a place holder
to move towards DM conversion.

Regards
Mugunthan V N


More information about the U-Boot mailing list