[edk2,6/9] Ufs: add PhyInit

Message ID 1483685538-11058-7-git-send-email-haojian.zhuang@linaro.org
State New
Headers show

Commit Message

Haojian Zhuang Jan. 6, 2017, 6:52 a.m.
Add PhyInit() to support designware UFS controller.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c    | 2 ++
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 8 ++++++++
 MdeModulePkg/Include/Protocol/UfsHostController.h    | 7 +++++++
 3 files changed, 17 insertions(+)

-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Haojian Zhuang Jan. 6, 2017, 8:21 a.m. | #1
It's a bit hard to implement it in lower layer. Since PhyInit ()
should be executed
between UFS controller enabled and UicDmeLinkStartup command.

Best Regards
Haojian

On 6 January 2017 at 15:27, Tian, Feng <feng.tian@intel.com> wrote:
> Could this be done at lower layer rather than changing existing interface?

>

> Thanks

> Feng

>

> -----Original Message-----

> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Haojian Zhuang

> Sent: Friday, January 6, 2017 2:52 PM

> To: Tian, Feng <feng.tian@intel.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org; edk2-devel@lists.01.org

> Cc: Haojian Zhuang <haojian.zhuang@linaro.org>

> Subject: [edk2] [PATCH 6/9] Ufs: add PhyInit

>

> Add PhyInit() to support designware UFS controller.

>

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

> ---

>  MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c    | 2 ++

>  MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 8 ++++++++

>  MdeModulePkg/Include/Protocol/UfsHostController.h    | 7 +++++++

>  3 files changed, 17 insertions(+)

>

> diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c

> index 7c831e9..761dc8e 100644

> --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c

> +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c

> @@ -853,6 +853,8 @@ UfsPassThruDriverBindingStart (

>      goto Error;

>    }

>

> +  MicroSecondDelay (100000);

> +

>    //

>    // Get Ufs Device's Lun Info by reading Configuration Descriptor.

>    //

> diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c

> index 218e9f5..7c01d57 100644

> --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c

> +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c

> @@ -2089,6 +2089,7 @@ UfsControllerInit (

>    )

>  {

>    EFI_STATUS             Status;

> +  EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc;

>

>    Status = UfsEnableHostController (Private);

>    if (EFI_ERROR (Status)) {

> @@ -2096,6 +2097,13 @@ UfsControllerInit (

>      return Status;

>    }

>

> +  UfsHc  = Private->UfsHostController;

> +  Status = UfsHc->PhyInit (UfsHc);

> +  if (EFI_ERROR (Status)) {

> +    DEBUG ((EFI_D_ERROR, "UfsControllerInit: Phy Init Fails, Status = %r\n", Status));

> +    return Status;

> +  }

> +

>    Status = UfsDeviceDetection (Private);

>    if (EFI_ERROR (Status)) {

>      DEBUG ((EFI_D_ERROR, "UfsControllerInit: Device Detection Fails, Status = %r\n", Status)); diff --git a/MdeModulePkg/Include/Protocol/UfsHostController.h b/MdeModulePkg/Include/Protocol/UfsHostController.h

> index 909c981..1f3605f 100644

> --- a/MdeModulePkg/Include/Protocol/UfsHostController.h

> +++ b/MdeModulePkg/Include/Protocol/UfsHostController.h

> @@ -221,6 +221,12 @@ EFI_STATUS

>    IN OUT VOID                                      *Buffer

>    );

>

> +typedef

> +EFI_STATUS

> +(EFIAPI *EDKII_UFS_HC_PHY_INIT)(

> +  IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL        *This

> +  );

> +

>  ///

>  ///  UFS Host Controller Protocol structure.

>  ///

> @@ -233,6 +239,7 @@ struct _EDKII_UFS_HOST_CONTROLLER_PROTOCOL {

>    EDKII_UFS_HC_FLUSH                  Flush;

>    EDKII_UFS_HC_MMIO_READ_WRITE        Read;

>    EDKII_UFS_HC_MMIO_READ_WRITE        Write;

> +  EDKII_UFS_HC_PHY_INIT               PhyInit;

>  };

>

>  ///

> --

> 2.7.4

>

> _______________________________________________

> edk2-devel mailing list

> edk2-devel@lists.01.org

> https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Tian, Feng Jan. 6, 2017, 8:44 a.m. | #2
Yes, I am thinking moving UFS HC enable to lower layer, this way should be able to eliminate interface change...

Thanks
Feng

-----Original Message-----
From: Haojian Zhuang [mailto:haojian.zhuang@linaro.org] 

Sent: Friday, January 6, 2017 4:22 PM
To: Tian, Feng <feng.tian@intel.com>
Cc: leif.lindholm@linaro.org; ard.biesheuvel@linaro.org; edk2-devel@lists.01.org
Subject: Re: [edk2] [PATCH 6/9] Ufs: add PhyInit

It's a bit hard to implement it in lower layer. Since PhyInit () should be executed between UFS controller enabled and UicDmeLinkStartup command.

Best Regards
Haojian

On 6 January 2017 at 15:27, Tian, Feng <feng.tian@intel.com> wrote:
> Could this be done at lower layer rather than changing existing interface?

>

> Thanks

> Feng

>

> -----Original Message-----

> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of 

> Haojian Zhuang

> Sent: Friday, January 6, 2017 2:52 PM

> To: Tian, Feng <feng.tian@intel.com>; leif.lindholm@linaro.org; 

> ard.biesheuvel@linaro.org; edk2-devel@lists.01.org

> Cc: Haojian Zhuang <haojian.zhuang@linaro.org>

> Subject: [edk2] [PATCH 6/9] Ufs: add PhyInit

>

> Add PhyInit() to support designware UFS controller.

>

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

> ---

>  MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c    | 2 ++

>  MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 8 ++++++++

>  MdeModulePkg/Include/Protocol/UfsHostController.h    | 7 +++++++

>  3 files changed, 17 insertions(+)

>

> diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c 

> b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c

> index 7c831e9..761dc8e 100644

> --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c

> +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c

> @@ -853,6 +853,8 @@ UfsPassThruDriverBindingStart (

>      goto Error;

>    }

>

> +  MicroSecondDelay (100000);

> +

>    //

>    // Get Ufs Device's Lun Info by reading Configuration Descriptor.

>    //

> diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 

> b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c

> index 218e9f5..7c01d57 100644

> --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c

> +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c

> @@ -2089,6 +2089,7 @@ UfsControllerInit (

>    )

>  {

>    EFI_STATUS             Status;

> +  EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc;

>

>    Status = UfsEnableHostController (Private);

>    if (EFI_ERROR (Status)) {

> @@ -2096,6 +2097,13 @@ UfsControllerInit (

>      return Status;

>    }

>

> +  UfsHc  = Private->UfsHostController;  Status = UfsHc->PhyInit 

> + (UfsHc);  if (EFI_ERROR (Status)) {

> +    DEBUG ((EFI_D_ERROR, "UfsControllerInit: Phy Init Fails, Status = %r\n", Status));

> +    return Status;

> +  }

> +

>    Status = UfsDeviceDetection (Private);

>    if (EFI_ERROR (Status)) {

>      DEBUG ((EFI_D_ERROR, "UfsControllerInit: Device Detection Fails, 

> Status = %r\n", Status)); diff --git 

> a/MdeModulePkg/Include/Protocol/UfsHostController.h 

> b/MdeModulePkg/Include/Protocol/UfsHostController.h

> index 909c981..1f3605f 100644

> --- a/MdeModulePkg/Include/Protocol/UfsHostController.h

> +++ b/MdeModulePkg/Include/Protocol/UfsHostController.h

> @@ -221,6 +221,12 @@ EFI_STATUS

>    IN OUT VOID                                      *Buffer

>    );

>

> +typedef

> +EFI_STATUS

> +(EFIAPI *EDKII_UFS_HC_PHY_INIT)(

> +  IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL        *This

> +  );

> +

>  ///

>  ///  UFS Host Controller Protocol structure.

>  ///

> @@ -233,6 +239,7 @@ struct _EDKII_UFS_HOST_CONTROLLER_PROTOCOL {

>    EDKII_UFS_HC_FLUSH                  Flush;

>    EDKII_UFS_HC_MMIO_READ_WRITE        Read;

>    EDKII_UFS_HC_MMIO_READ_WRITE        Write;

> +  EDKII_UFS_HC_PHY_INIT               PhyInit;

>  };

>

>  ///

> --

> 2.7.4

>

> _______________________________________________

> edk2-devel mailing list

> edk2-devel@lists.01.org

> https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Patch hide | download patch | download mbox

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
index 7c831e9..761dc8e 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
@@ -853,6 +853,8 @@  UfsPassThruDriverBindingStart (
     goto Error;
   }
 
+  MicroSecondDelay (100000);
+
   //
   // Get Ufs Device's Lun Info by reading Configuration Descriptor.
   //
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index 218e9f5..7c01d57 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -2089,6 +2089,7 @@  UfsControllerInit (
   )
 {
   EFI_STATUS             Status;
+  EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc;
 
   Status = UfsEnableHostController (Private);
   if (EFI_ERROR (Status)) {
@@ -2096,6 +2097,13 @@  UfsControllerInit (
     return Status;
   }
 
+  UfsHc  = Private->UfsHostController;
+  Status = UfsHc->PhyInit (UfsHc);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((EFI_D_ERROR, "UfsControllerInit: Phy Init Fails, Status = %r\n", Status));
+    return Status;
+  }
+
   Status = UfsDeviceDetection (Private);
   if (EFI_ERROR (Status)) {
     DEBUG ((EFI_D_ERROR, "UfsControllerInit: Device Detection Fails, Status = %r\n", Status));
diff --git a/MdeModulePkg/Include/Protocol/UfsHostController.h b/MdeModulePkg/Include/Protocol/UfsHostController.h
index 909c981..1f3605f 100644
--- a/MdeModulePkg/Include/Protocol/UfsHostController.h
+++ b/MdeModulePkg/Include/Protocol/UfsHostController.h
@@ -221,6 +221,12 @@  EFI_STATUS
   IN OUT VOID                                      *Buffer
   );
 
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_UFS_HC_PHY_INIT)(
+  IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL        *This
+  );
+
 ///
 ///  UFS Host Controller Protocol structure.
 ///
@@ -233,6 +239,7 @@  struct _EDKII_UFS_HOST_CONTROLLER_PROTOCOL {
   EDKII_UFS_HC_FLUSH                  Flush;
   EDKII_UFS_HC_MMIO_READ_WRITE        Read;
   EDKII_UFS_HC_MMIO_READ_WRITE        Write;
+  EDKII_UFS_HC_PHY_INIT               PhyInit;
 };
 
 ///