[U-Boot] [PATCH 27/29] dm: ahci: Add a driver for SCSI on AHCI

Simon Glass sjg at chromium.org
Wed Jun 14 10:59:18 UTC 2017


Hi Bin,

On 12 June 2017 at 21:14, Bin Meng <bmeng.cn at gmail.com> wrote:
> Hi Simon,
>
> On Tue, Jun 6, 2017 at 3:15 AM, Simon Glass <sjg at chromium.org> wrote:
>> Some AHCI drivers use SCSI under the hood. Rather than making the AHCI
>> driver be in the SCSI uclass it makes sense to have the AHCI device create
>> a SCSI device as a child. That way we can handle any AHCI-specific
>> operations rather than trying to pretend tha the device is just SCSI.
>>
>> To handle this we need to provide a way for AHCI drivers to bind a SCSI
>> device as its child, and probe it. Add functions for this.
>>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>>
>>  drivers/ata/ahci.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  include/ahci.h     | 22 ++++++++++++++++++++++
>>  2 files changed, 74 insertions(+)
>>
>> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
>> index 3528a1f3da..c67a144f02 100644
>> --- a/drivers/ata/ahci.c
>> +++ b/drivers/ata/ahci.c
>> @@ -23,6 +23,8 @@
>>  #include <libata.h>
>>  #include <linux/ctype.h>
>>  #include <ahci.h>
>> +#include <dm/device-internal.h>
>> +#include <dm/lists.h>
>>
>>  static int ata_io_flush(struct ahci_uc_priv *uc_priv, u8 port);
>>
>> @@ -1142,10 +1144,60 @@ static int ahci_scsi_bus_reset(struct udevice *dev)
>>  }
>>
>>  #ifdef CONFIG_DM_SCSI
>> +int ahci_bind_scsi(struct udevice *ahci_dev, struct udevice **devp)
>> +{
>> +       struct udevice *dev;
>> +       int ret;
>> +
>> +       ret = device_bind_driver(ahci_dev, "ahci_scsi", "ahci_scsi", &dev);
>> +       if (ret)
>> +               return ret;
>> +       *devp = dev;
>> +
>> +       return 0;
>> +}
>> +
>> +int ahci_probe_scsi(struct udevice *ahci_dev)
>> +{
>> +       struct ahci_uc_priv *uc_priv;
>> +       struct scsi_platdata *uc_plat;
>> +       struct udevice *dev;
>> +       int ret;
>> +
>> +       device_find_first_child(ahci_dev, &dev);
>> +       if (!dev)
>> +               return -ENODEV;
>> +       uc_plat = dev_get_uclass_platdata(dev);
>> +       uc_plat->base = (ulong)dm_pci_map_bar(ahci_dev, PCI_BASE_ADDRESS_5,
>> +                                             PCI_REGION_MEM);
>
> This assumes AHCI controller is on PCI bus. How about other AHCI
> controllers integrated directly into the SoC?

I have not done this yet - it would have to be a follow-up series.
This one focuses mostly on SCSI. The ahci.c driver seems to me to be
only supporting using an AHCI controller via SCSI. I added a comment
to the drop to make that clear once I figured it out.

Also sata.h will need converting and the AHCI uclass will need to have
operations, etc.

Regards,
Simon


More information about the U-Boot mailing list