Re: [U-Boot] [PATCH 2/6] dm: implement a SATA uclass
Hi, On 18 January 2016 at 22:09, Mugunthan V N wrote: > > On Monday 18 January 2016 02:53 PM, Bin Meng wrote: > > +Simon > > > > On Mon, Jan 18, 2016 at 4:47 PM, Mugunthan V N wrote: > >> Implement a SATA uclass that can represent a SATA controller. > >> > >> Signed-off-by: Mugunthan V N > >> --- > >> 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 000..62773b6 > >> --- /dev/null > >> +++ b/drivers/block/sata-uclass.c > >> @@ -0,0 +1,69 @@ > >> +/* > >> + * SATA device U-Class driver > >> + * > >> + * (C) Copyright 2016 > >> + * Texas Instruments Incorporated, > >> + * > >> + * Author: Mugunthan V N > >> + * > >> + * SPDX-License-Identifier: GPL-2.0+ > >> + */ > >> + > >> +#include > >> +#include > >> +#include > >> +#include > >> +#include > >> +#include > >> + > >> +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. I have a series which adds a disk uclass. It was using AHCI (=SATA) but Bin pointed out that this might be too specific. So perhaps you should use that? http://patchwork.ozlabs.org/patch/569381/ Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/6] dm: implement a SATA uclass
On Monday 18 January 2016 02:53 PM, Bin Meng wrote: > +Simon > > On Mon, Jan 18, 2016 at 4:47 PM, Mugunthan V N wrote: >> Implement a SATA uclass that can represent a SATA controller. >> >> Signed-off-by: Mugunthan V N >> --- >> 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 000..62773b6 >> --- /dev/null >> +++ b/drivers/block/sata-uclass.c >> @@ -0,0 +1,69 @@ >> +/* >> + * SATA device U-Class driver >> + * >> + * (C) Copyright 2016 >> + * Texas Instruments Incorporated, >> + * >> + * Author: Mugunthan V N >> + * >> + * SPDX-License-Identifier: GPL-2.0+ >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +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 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/6] dm: implement a SATA uclass
+Simon On Mon, Jan 18, 2016 at 4:47 PM, Mugunthan V N wrote: > Implement a SATA uclass that can represent a SATA controller. > > Signed-off-by: Mugunthan V N > --- > 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 000..62773b6 > --- /dev/null > +++ b/drivers/block/sata-uclass.c > @@ -0,0 +1,69 @@ > +/* > + * SATA device U-Class driver > + * > + * (C) Copyright 2016 > + * Texas Instruments Incorporated, > + * > + * Author: Mugunthan V N > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +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. > +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? Regards, Bin ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/6] dm: implement a SATA uclass
Implement a SATA uclass that can represent a SATA controller. Signed-off-by: Mugunthan V N --- 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 000..62773b6 --- /dev/null +++ b/drivers/block/sata-uclass.c @@ -0,0 +1,69 @@ +/* + * SATA device U-Class driver + * + * (C) Copyright 2016 + * Texas Instruments Incorporated, + * + * Author: Mugunthan V N + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/* + * struct mmc_uclass_priv - Holds information about a device used by the uclass + */ +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 */ -- 2.7.0.rc3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot