diff mbox

[U-Boot,06/18] sata: dwc_ahsata: implement sata_port_status

Message ID 1407051288-17324-7-git-send-email-nikita@compulab.co.il
State Changes Requested
Delegated to: Stefano Babic
Headers show

Commit Message

Nikita Kiryanov Aug. 3, 2014, 7:34 a.m. UTC
Define the new common function sata_port_status() which can be
used to query the sata driver for the state of ports, and implement it
for dwc_ahsata.

Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@ti.com>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
---
 drivers/block/dwc_ahsata.c | 17 +++++++++++++++++
 include/sata.h             |  1 +
 2 files changed, 18 insertions(+)

Comments

Marek Vasut Aug. 3, 2014, 1:49 p.m. UTC | #1
On Sunday, August 03, 2014 at 09:34:36 AM, Nikita Kiryanov wrote:
> Define the new common function sata_port_status() which can be
> used to query the sata driver for the state of ports, and implement it
> for dwc_ahsata.
> 
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Tom Rini <trini@ti.com>
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> ---
>  drivers/block/dwc_ahsata.c | 17 +++++++++++++++++
>  include/sata.h             |  1 +
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/block/dwc_ahsata.c b/drivers/block/dwc_ahsata.c
> index 15d65d7..e122ed9 100644
> --- a/drivers/block/dwc_ahsata.c
> +++ b/drivers/block/dwc_ahsata.c
> @@ -864,6 +864,23 @@ u32 ata_low_level_rw_lba28(int dev, u32 blknr,
> lbaint_t blkcnt, return blkcnt;
>  }
> 
> +int sata_port_status(int dev, int port)
> +{
> +	struct sata_port_regs *port_mmio;
> +	struct ahci_probe_ent *probe_ent = NULL;
> +
> +	if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1))
> +		return -1;

Please lets use values from errno.h here , let's set a good example and just do 
that please.
[...]
Best regards,
Marek Vasut
Nikita Kiryanov Aug. 4, 2014, 12:49 p.m. UTC | #2
On 03/08/14 16:49, Marek Vasut wrote:
> On Sunday, August 03, 2014 at 09:34:36 AM, Nikita Kiryanov wrote:
>> Define the new common function sata_port_status() which can be
>> used to query the sata driver for the state of ports, and implement it
>> for dwc_ahsata.
>>
>> Cc: Stefano Babic <sbabic@denx.de>
>> Cc: Tom Rini <trini@ti.com>
>> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
>> ---
>>   drivers/block/dwc_ahsata.c | 17 +++++++++++++++++
>>   include/sata.h             |  1 +
>>   2 files changed, 18 insertions(+)
>>
>> diff --git a/drivers/block/dwc_ahsata.c b/drivers/block/dwc_ahsata.c
>> index 15d65d7..e122ed9 100644
>> --- a/drivers/block/dwc_ahsata.c
>> +++ b/drivers/block/dwc_ahsata.c
>> @@ -864,6 +864,23 @@ u32 ata_low_level_rw_lba28(int dev, u32 blknr,
>> lbaint_t blkcnt, return blkcnt;
>>   }
>>
>> +int sata_port_status(int dev, int port)
>> +{
>> +	struct sata_port_regs *port_mmio;
>> +	struct ahci_probe_ent *probe_ent = NULL;
>> +
>> +	if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1))
>> +		return -1;
>
> Please lets use values from errno.h here , let's set a good example and just do
> that please.

Will do...

> [...]
> Best regards,
> Marek Vasut
>
Marek Vasut Aug. 4, 2014, 1:10 p.m. UTC | #3
On Monday, August 04, 2014 at 02:49:45 PM, Nikita Kiryanov wrote:
> On 03/08/14 16:49, Marek Vasut wrote:
> > On Sunday, August 03, 2014 at 09:34:36 AM, Nikita Kiryanov wrote:
> >> Define the new common function sata_port_status() which can be
> >> used to query the sata driver for the state of ports, and implement it
> >> for dwc_ahsata.
> >> 
> >> Cc: Stefano Babic <sbabic@denx.de>
> >> Cc: Tom Rini <trini@ti.com>
> >> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> >> ---
> >> 
> >>   drivers/block/dwc_ahsata.c | 17 +++++++++++++++++
> >>   include/sata.h             |  1 +
> >>   2 files changed, 18 insertions(+)
> >> 
> >> diff --git a/drivers/block/dwc_ahsata.c b/drivers/block/dwc_ahsata.c
> >> index 15d65d7..e122ed9 100644
> >> --- a/drivers/block/dwc_ahsata.c
> >> +++ b/drivers/block/dwc_ahsata.c
> >> @@ -864,6 +864,23 @@ u32 ata_low_level_rw_lba28(int dev, u32 blknr,
> >> lbaint_t blkcnt, return blkcnt;
> >> 
> >>   }
> >> 
> >> +int sata_port_status(int dev, int port)
> >> +{
> >> +	struct sata_port_regs *port_mmio;
> >> +	struct ahci_probe_ent *probe_ent = NULL;
> >> +
> >> +	if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1))
> >> +		return -1;
> > 
> > Please lets use values from errno.h here , let's set a good example and
> > just do that please.
> 
> Will do...

Thanks!

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/drivers/block/dwc_ahsata.c b/drivers/block/dwc_ahsata.c
index 15d65d7..e122ed9 100644
--- a/drivers/block/dwc_ahsata.c
+++ b/drivers/block/dwc_ahsata.c
@@ -864,6 +864,23 @@  u32 ata_low_level_rw_lba28(int dev, u32 blknr, lbaint_t blkcnt,
 	return blkcnt;
 }
 
+int sata_port_status(int dev, int port)
+{
+	struct sata_port_regs *port_mmio;
+	struct ahci_probe_ent *probe_ent = NULL;
+
+	if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1))
+		return -1;
+
+	if (sata_dev_desc[dev].priv == NULL)
+		return -1;
+
+	probe_ent = (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+	port_mmio = (struct sata_port_regs *)probe_ent->port[port].port_mmio;
+
+	return readl(&(port_mmio->ssts)) && SATA_PORT_SSTS_DET_MASK;
+}
+
 /*
  * SATA interface between low level driver and command layer
  */
diff --git a/include/sata.h b/include/sata.h
index c95dc56..38f4b4a 100644
--- a/include/sata.h
+++ b/include/sata.h
@@ -9,6 +9,7 @@  ulong sata_write(int dev, ulong blknr, lbaint_t blkcnt, const void *buffer);
 
 int sata_initialize(void);
 int __sata_initialize(void);
+int sata_port_status(int dev, int port);
 
 extern block_dev_desc_t sata_dev_desc[];