Add AMD UFS platfrom driver support
v2 cover Add AMD UFS platfrom driver support
Enable UFS DWC controller driver support and add AMD UFS platform driver support.
NOTE: These changes are rebased on top of this series [PATCH 00/13] ufs: enhancements to support Qualcomm UFS controllers
Changes in v2:
- Removed the ufshcd_vops_phy_initialization function.
- Removed the ufshcd_set_link_active function.
Venkatesh Yadav Abbarapu (3):
ufs: add support for DesignWare Controller
ufs: ufs-amd-versal2: Add support for AMD UFS controller
configs: versal2: Add support for AMD UFS platform driver
configs/amd_versal2_virt_defconfig | 2 +- drivers/ufs/Kconfig | 8 + drivers/ufs/Makefile | 1 + drivers/ufs/ufs-amd-versal2.c | 501 +++++++++++++++++++++++++++++ drivers/ufs/ufshcd-dwc.c | 133 ++++++++ drivers/ufs/ufshcd-dwc.h | 69 ++++ drivers/ufs/ufshci-dwc.h | 32 ++ drivers/ufs/unipro.h | 1 + 8 files changed, 746 insertions(+), 1 deletion(-) create mode 100644 drivers/ufs/ufs-amd-versal2.c create mode 100644 drivers/ufs/ufshcd-dwc.c create mode 100644 drivers/ufs/ufshcd-dwc.h create mode 100644 drivers/ufs/ufshci-dwc.h
Signature · 1 line
2.17.1
PATCH v2 1/3 ufs: add support for DesignWare Controller
This patch has the goal to add support for DesignWare UFS Controller specific operations.
This is based on linux kernel commit:
"drivers/scsi/ufs/ufshcd-dwc.c: ufs: add support for DesignWare Controller" (sha1: 4b9ffb5a353bdee49f1f477ffe2b95ab3f9cbc0c) It is ported from linux kernel 6.11-rc1.
---
Changes in v2:
- Removed the ufshcd_vops_phy_initialization function.
- Removed the ufshcd_set_link_active function.
drivers/ufs/ufshcd-dwc.c | 133 +++++++++++++++++++++++++++++++++++++++ drivers/ufs/ufshcd-dwc.h | 23 +++++++ drivers/ufs/ufshci-dwc.h | 32 ++++++++++ 3 files changed, 188 insertions(+) create mode 100644 drivers/ufs/ufshcd-dwc.c create mode 100644 drivers/ufs/ufshcd-dwc.h create mode 100644 drivers/ufs/ufshci-dwc.h
drivers/ufs/ufshcd-dwc.c new file +133 -0
@@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* UFS Host driver for Synopsys Designware Core +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +*/ +#include <clk.h> +#include <dm.h> +#include <ufs.h> +#include <asm/io.h> +#include <dm/device_compat.h> +#include <linux/bitops.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/time.h> + +#include "ufs.h" +#include "ufshci-dwc.h" +#include "ufshcd-dwc.h" + +int ufshcd_dwc_dme_set_attrs (struct ufs_hba *hba, +const struct ufshcd_dme_attr_val *v,int n) +{ +int ret =0 ; +int attr_node =0 ; + +for (attr_node =0 ; attr_node < n; attr_node++) { + ret =ufshcd_dme_set_attr (hba, v[attr_node].attr_sel, +ATTR_SET_NOR , v[attr_node].mib_val, v[attr_node].peer); +if (ret) +return ret; + } + +return 0 ; +} + +/** +* ufshcd_dwc_program_clk_div() - program clock divider. +* @hba: Private Structure pointer +* @divider_val: clock divider value to be programmed +* +*/ +static void ufshcd_dwc_program_clk_div (struct ufs_hba *hba,u32 divider_val) +{ +ufshcd_writel (hba, divider_val,DWC_UFS_REG_HCLKDIV ); +} + +/** +* ufshcd_dwc_link_is_up() - check if link is up. +* @hba: private structure pointer +* +* Return: 0 on success, non-zero value on failure. +*/ +static int ufshcd_dwc_link_is_up (struct ufs_hba *hba) +{ +int dme_result =0 ; + +ufshcd_dme_get (hba,UIC_ARG_MIB (VS_POWERSTATE ), &dme_result); + +if (dme_result ==UFSHCD_LINK_IS_UP ) +return 0 ; + +return 1 ; +} + +/** +* ufshcd_dwc_connection_setup() - configure unipro attributes. +* @hba: pointer to drivers private data +* +* This function configures both the local side (host) and the peer side +* (device) unipro attributes to establish the connection to application/ +* cport. +* This function is not required if the hardware is properly configured to +* have this connection setup on reset. But invoking this function does no +* harm and should be fine even working with any ufs device. +* +* Return: 0 on success non-zero value on failure. +*/ +static int ufshcd_dwc_connection_setup (struct ufs_hba *hba) +{ +static const struct ufshcd_dme_attr_val setup_attrs[] = { + {UIC_ARG_MIB (T_CONNECTIONSTATE ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (N_DEVICEID ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (N_DEVICEID_VALID ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (T_PEERDEVICEID ),1 ,DME_LOCAL }, + {UIC_ARG_MIB (T_PEERCPORTID ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (T_TRAFFICCLASS ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (T_CPORTFLAGS ),0x6 ,DME_LOCAL }, + {UIC_ARG_MIB (T_CPORTMODE ),1 ,DME_LOCAL }, + {UIC_ARG_MIB (T_CONNECTIONSTATE ),1 ,DME_LOCAL }, + {UIC_ARG_MIB (T_CONNECTIONSTATE ),0 ,DME_PEER }, + {UIC_ARG_MIB (N_DEVICEID ),1 ,DME_PEER }, + {UIC_ARG_MIB (N_DEVICEID_VALID ),1 ,DME_PEER }, + {UIC_ARG_MIB (T_PEERDEVICEID ),1 ,DME_PEER }, + {UIC_ARG_MIB (T_PEERCPORTID ),0 ,DME_PEER }, + {UIC_ARG_MIB (T_TRAFFICCLASS ),0 ,DME_PEER }, + {UIC_ARG_MIB (T_CPORTFLAGS ),0x6 ,DME_PEER }, + {UIC_ARG_MIB (T_CPORTMODE ),1 ,DME_PEER }, + {UIC_ARG_MIB (T_CONNECTIONSTATE ),1 ,DME_PEER } + }; +return ufshcd_dwc_dme_set_attrs (hba, setup_attrs,ARRAY_SIZE (setup_attrs)); +} + +/** +* ufshcd_dwc_link_startup_notify() - program clock divider. +* @hba: private structure pointer +* @status: Callback notify status +* +* Return: 0 on success, non-zero value on failure. +*/ +int ufshcd_dwc_link_startup_notify (struct ufs_hba *hba, +enum ufs_notify_change_status status) +{ +int err =0 ; + +if (status ==PRE_CHANGE ) { +ufshcd_dwc_program_clk_div (hba,DWC_UFS_REG_HCLKDIV_DIV_125 ); + }else {/* POST_CHANGE */ + err =ufshcd_dwc_link_is_up (hba); +if (err) { +dev_err (hba->dev,"Link is not up\n" ); +return err; + } + + err =ufshcd_dwc_connection_setup (hba); +if (err) +dev_err (hba->dev,"Connection setup failed (%d)\n" , + err); + } + +return err; +}
drivers/ufs/ufshcd-dwc.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* UFS Host driver for Synopsys Designware Core +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* Authors: Joao Pinto <[email protected]> +*/ + +#ifndef _UFSHCD_DWC_H +#define _UFSHCD_DWC_H + +struct ufshcd_dme_attr_val { +u32 attr_sel; +u32 mib_val; +u8 peer; +}; + +int ufshcd_dwc_link_startup_notify (struct ufs_hba *hba, +enum ufs_notify_change_status status); +int ufshcd_dwc_dme_set_attrs (struct ufs_hba *hba, +const struct ufshcd_dme_attr_val *v,int n); +#endif /* End of Header */
drivers/ufs/ufshci-dwc.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* UFS Host driver for Synopsys Designware Core +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* Authors: Joao Pinto <[email protected]> +*/ + +#ifndef _UFSHCI_DWC_H +#define _UFSHCI_DWC_H + +/* DWC HC UFSHCI specific Registers */ +enum dwc_specific_registers { +DWC_UFS_REG_HCLKDIV =0xFC , +}; + +/* Clock Divider Values: Hex equivalent of frequency in MHz */ +enum clk_div_values { +DWC_UFS_REG_HCLKDIV_DIV_62_5 =0x3e , +DWC_UFS_REG_HCLKDIV_DIV_125 =0x7d , +DWC_UFS_REG_HCLKDIV_DIV_200 =0xc8 , +}; + +/* Selector Index */ +enum selector_index { +SELIND_LN0_TX =0x00 , +SELIND_LN1_TX =0x01 , +SELIND_LN0_RX =0x04 , +SELIND_LN1_RX =0x05 , +}; +#endif
Signature · 1 line
2.17.1
Re: [PATCH v2 1/3] ufs: add support for DesignWare Controller
Quoted 218 lines · Venkatesh Yadav Abbarapu
This patch has the goal to add support for DesignWare UFS Controller specific operations.
This is based on linux kernel commit:
"drivers/scsi/ufs/ufshcd-dwc.c: ufs: add support for DesignWare Controller" (sha1:4b9ffb5a353bdee49f1f477ffe2b95ab3f9cbc0c) It is ported from linux kernel 6.11-rc1.Signed-off-by Venkatesh Yadav Abbarapu <[email protected]>---
Changes in v2:
- Removed theufshcd_vops_phy_initializationfunction.
- Removed theufshcd_set_link_activefunction.drivers/ufs/ufshcd-dwc.c | 133 +++++++++++++++++++++++++++++++++++++++ drivers/ufs/ufshcd-dwc.h | 23 +++++++ drivers/ufs/ufshci-dwc.h | 32 ++++++++++ 3 files changed, 188 insertions(+)create mode 100644
drivers/ufs/ufshcd-dwc.c
create mode 100644drivers/ufs/ufshcd-dwc.h
create mode 100644drivers/ufs/ufshci-dwc.hdrivers/ufs/ufshcd-dwc.c new file +133
-0@@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* UFS Host driver for Synopsys Designware Core +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +*/ +#include <clk.h> +#include <dm.h> +#include <ufs.h> +#include <asm/io.h> +#include <dm/device_compat.h> +#include <linux/bitops.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/time.h> + +#include "ufs.h" +#include "ufshci-dwc.h" +#include "ufshcd-dwc.h" + +int ufshcd_dwc_dme_set_attrs (struct ufs_hba *hba, +const struct ufshcd_dme_attr_val *v,int n) +{ +int ret =0 ; +int attr_node =0 ; + +for (attr_node =0 ; attr_node < n; attr_node++) { + ret =ufshcd_dme_set_attr (hba, v[attr_node].attr_sel, +ATTR_SET_NOR , v[attr_node].mib_val, v[attr_node].peer); +if (ret) +return ret; + } + +return 0 ; +} + +/** +* ufshcd_dwc_program_clk_div() - program clock divider. +* @hba: Private Structure pointer +* @divider_val: clock divider value to be programmed +* +*/ +static void ufshcd_dwc_program_clk_div (struct ufs_hba *hba,u32 divider_val) +{ +ufshcd_writel (hba, divider_val,DWC_UFS_REG_HCLKDIV ); +} + +/** +* ufshcd_dwc_link_is_up() - check if link is up. +* @hba: private structure pointer +* +* Return: 0 on success, non-zero value on failure. +*/ +static int ufshcd_dwc_link_is_up (struct ufs_hba *hba) +{ +int dme_result =0 ; + +ufshcd_dme_get (hba,UIC_ARG_MIB (VS_POWERSTATE ), &dme_result); + +if (dme_result ==UFSHCD_LINK_IS_UP ) +return 0 ; + +return 1 ; +} + +/** +* ufshcd_dwc_connection_setup() - configure unipro attributes. +* @hba: pointer to drivers private data +* +* This function configures both the local side (host) and the peer side +* (device) unipro attributes to establish the connection to application/ +* cport. +* This function is not required if the hardware is properly configured to +* have this connection setup on reset. But invoking this function does no +* harm and should be fine even working with any ufs device. +* +* Return: 0 on success non-zero value on failure. +*/ +static int ufshcd_dwc_connection_setup (struct ufs_hba *hba) +{ +static const struct ufshcd_dme_attr_val setup_attrs[] = { + {UIC_ARG_MIB (T_CONNECTIONSTATE ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (N_DEVICEID ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (N_DEVICEID_VALID ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (T_PEERDEVICEID ),1 ,DME_LOCAL }, + {UIC_ARG_MIB (T_PEERCPORTID ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (T_TRAFFICCLASS ),0 ,DME_LOCAL }, + {UIC_ARG_MIB (T_CPORTFLAGS ),0x6 ,DME_LOCAL }, + {UIC_ARG_MIB (T_CPORTMODE ),1 ,DME_LOCAL }, + {UIC_ARG_MIB (T_CONNECTIONSTATE ),1 ,DME_LOCAL }, + {UIC_ARG_MIB (T_CONNECTIONSTATE ),0 ,DME_PEER }, + {UIC_ARG_MIB (N_DEVICEID ),1 ,DME_PEER }, + {UIC_ARG_MIB (N_DEVICEID_VALID ),1 ,DME_PEER }, + {UIC_ARG_MIB (T_PEERDEVICEID ),1 ,DME_PEER }, + {UIC_ARG_MIB (T_PEERCPORTID ),0 ,DME_PEER }, + {UIC_ARG_MIB (T_TRAFFICCLASS ),0 ,DME_PEER }, + {UIC_ARG_MIB (T_CPORTFLAGS ),0x6 ,DME_PEER }, + {UIC_ARG_MIB (T_CPORTMODE ),1 ,DME_PEER }, + {UIC_ARG_MIB (T_CONNECTIONSTATE ),1 ,DME_PEER } + }; +return ufshcd_dwc_dme_set_attrs (hba, setup_attrs,ARRAY_SIZE (setup_attrs)); +} + +/** +* ufshcd_dwc_link_startup_notify() - program clock divider. +* @hba: private structure pointer +* @status: Callback notify status +* +* Return: 0 on success, non-zero value on failure. +*/ +int ufshcd_dwc_link_startup_notify (struct ufs_hba *hba, +enum ufs_notify_change_status status) +{ +int err =0 ; + +if (status ==PRE_CHANGE ) { +ufshcd_dwc_program_clk_div (hba,DWC_UFS_REG_HCLKDIV_DIV_125 ); + }else {/* POST_CHANGE */ + err =ufshcd_dwc_link_is_up (hba); +if (err) { +dev_err (hba->dev,"Link is not up\n" ); +return err; + } + + err =ufshcd_dwc_connection_setup (hba); +if (err) +dev_err (hba->dev,"Connection setup failed (%d)\n" , + err); + } + +return err; +}drivers/ufs/ufshcd-dwc.h new file +23
-0@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* UFS Host driver for Synopsys Designware Core +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* Authors: Joao Pinto <[email protected]> +*/ + +#ifndef _UFSHCD_DWC_H +#define _UFSHCD_DWC_H + +struct ufshcd_dme_attr_val { +u32 attr_sel; +u32 mib_val; +u8 peer; +}; + +int ufshcd_dwc_link_startup_notify (struct ufs_hba *hba, +enum ufs_notify_change_status status); +int ufshcd_dwc_dme_set_attrs (struct ufs_hba *hba, +const struct ufshcd_dme_attr_val *v,int n); +#endif /* End of Header */ drivers/ufs/ufshci-dwc.h new file +22
-0@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* UFS Host driver for Synopsys Designware Core +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* Authors: Joao Pinto <[email protected]> +*/ + +#ifndef _UFSHCI_DWC_H +#define _UFSHCI_DWC_H + +/* DWC HC UFSHCI specific Registers */ +enum dwc_specific_registers { +DWC_UFS_REG_HCLKDIV =0xFC , +}; + +/* Clock Divider Values: Hex equivalent of frequency in MHz */ +enum clk_div_values { +DWC_UFS_REG_HCLKDIV_DIV_62_5 =0x3e , +DWC_UFS_REG_HCLKDIV_DIV_125 =0x7d , + DWC_UFS_REG_HCLKDIV_DIV_200 = 0xc8,
drivers/ufs/ufshci-dwc.h line 32
Quoted 10 lines
drivers/ufs/ufshci-dwc.h new file +10
-0+}; + +/* Selector Index */ +enum selector_index { +SELIND_LN0_TX =0x00 , +SELIND_LN1_TX =0x01 , +SELIND_LN0_RX =0x04 , +SELIND_LN1_RX =0x05 , +}; +#endif
PATCH v2 2/3 ufs: ufs-amd-versal2: Add support for AMD UFS controller
In reply to Venkatesh Yadav AbbarapuAdd UFS AMD platform support on top of the UFS DWC
and UFS platform driver. UFS AMD platform requires
some platform specific configurations like M-PHY/RMMI/UniPro and vendor specific registers programming before doing the LINKSTARTUP.
--- drivers/ufs/Kconfig | 8 + drivers/ufs/Makefile | 1 + drivers/ufs/ufs-amd-versal2.c | 501 ++++++++++++++++++++++++++++++++++ drivers/ufs/ufshcd-dwc.h | 46 ++++ drivers/ufs/unipro.h | 1 + 5 files changed, 557 insertions(+) create mode 100644 drivers/ufs/ufs-amd-versal2.c
drivers/ufs/Kconfig +8 -0
@@ -41,4 +41,12 @@ config UFS_RENESAS UFS host on Renesas needs some vendor specific configuration before accessing the hardware. +config UFS_AMD_VERSAL2 + bool "AMD Versal Gen 2 UFS controller platform driver" + depends on UFS && ZYNQMP_FIRMWARE + help + This selects the AMD specific additions to UFSHCD platform driver. + UFS host on AMD needs some vendor specific configuration before accessing + the hardware. + endmenu
drivers/ufs/Makefile +1 -0
@@ -8,3 +8,4 @@ obj-$(CONFIG_CADENCE_UFS) += cdns-platform.o obj-$(CONFIG_TI_J721E_UFS) += ti-j721e-ufs.o obj-$(CONFIG_UFS_PCI) += ufs-pci.o obj-$(CONFIG_UFS_RENESAS) += ufs-renesas.o +obj-$(CONFIG_UFS_AMD_VERSAL2) += ufs-amd-versal2.o ufshcd-dwc.o
drivers/ufs/ufs-amd-versal2.c new file +501 -0
501 lines not on this page · raw message
drivers/ufs/ufshcd-dwc.h +46 -0
52 lines not on this page · raw message
drivers/ufs/unipro.h +1 -0
@@ -148,6 +148,7 @@#define VS_MPHYCFGUPDT 0xD085#define VS_DEBUGOMC 0xD09E#define VS_POWERSTATE 0xD083 +#define VS_MPHYDISABLE 0xD0C1#define PA_GRANULARITY_MIN_VAL 1#define PA_GRANULARITY_MAX_VAL 6
Signature · 1 line
2.17.1
PATCH v2 3/3 configs: versal2: Add support for AMD UFS platform driver
In reply to Venkatesh Yadav AbbarapuEnable AMD UFS platform driver.
--- configs/amd_versal2_virt_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configs/amd_versal2_virt_defconfig +1 -1
@@ -145,7 +145,7 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x0300 CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_THOR=y CONFIG_UFS=y -CONFIG_CADENCE_UFS=y +CONFIG_UFS_AMD_VERSAL2=y CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y
Signature · 1 line
2.17.1
Re: [PATCH v2 3/3] configs: versal2: Add support for AMD UFS platform driver
Quoted 12 lines · Venkatesh Yadav Abbarapu
Enable AMD UFS platform driver.
Signed-off-by Venkatesh Yadav Abbarapu <[email protected]>--- configs/amd_versal2_virt_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)configs/amd_versal2_virt_defconfig +0
-0
configs/amd_versal2_virt_defconfig CONFIG_USB_GADGET_PRODUCT_NUM=0x0300 · line 151
Quoted 8 lines
configs/amd_versal2_virt_defconfig +1
-1@@ -145,7 +145,7 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x0300 CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_THOR=y CONFIG_UFS=y -CONFIG_CADENCE_UFS=y +CONFIG_UFS_AMD_VERSAL2=y CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y
Thanks,
Michal
Hi,
Quoted 11 lines · Venkatesh Yadav Abbarapu
Enable UFS DWC controller driver support and add AMD UFS platform driver support.
NOTE: These changes are rebased on top of this series [PATCH 00/13] ufs: enhancements to support Qualcomm UFS controllers
Changes in v2:
- Removed theufshcd_vops_phy_initializationfunction.
- Removed theufshcd_set_link_activefunction.[...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-ufs (u-boot-ufs-next)
[1/3] ufs: add support for DesignWare Controller
https://source.denx.de/u-boot/custodians/u-boot-ufs/-/commit/4b0ea24b42012b7c046ef253cc3eeee248da5358 [2/3] ufs: ufs-amd-versal2: Add support for AMD UFS controller https://source.denx.de/u-boot/custodians/u-boot-ufs/-/commit/b5ac5f03072027cf1abf2ce28667c4f7348ddb0e [3/3] configs: versal2: Add support for AMD UFS platform driver https://source.denx.de/u-boot/custodians/u-boot-ufs/-/commit/d3c32f2c76d690814c59ee98c67e6c5e92fca3e4
Signature · 1 line
Neil