add support for DWC UFS Controller
Subsystems (3)
v16 cover add support for DWC UFS Controller
As requested, I am sending v15 to be included in the SCSI patchwork. The patches were produced on top of the latest (2016-05-02) 4.7/scsi-queue branch. The patches were also validated by checkpatch.pl.
The work consisted of:
- Fixed typo in ufshcd-pltfrm.c
- Tweak ufshcd.c for UFS 2.0 support
- Implement ufshcd-dwc which contains all DWC HW specific code
- Unipro attributes were added and new registers were added to the driver
- Implement a tc-dwc-g210 containing G210 MPHY specific code
- Implement a tc-dwc-g210 glue platform driver
- Implement a tc-dwc-g210 glue pci driver
- Documentation update
Joao Pinto (9):
ufs: fixed typo in ufshcd-pltfrm
ufs: add UFS 2.0 to ufshcd-pltfrm bindings
ufs: add UFS 2.0 capabilities
ufs: add unipro attributes
ufs: add link status to ufshci
ufs: add support for DesignWare Controller
ufs: add support for Synopsys G210 Test Chip
ufs: add TC G210 platform driver
ufs: add TC G210 pci driver
.../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt | 26 ++ .../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 4 +- MAINTAINERS | 6 + drivers/scsi/ufs/Kconfig | 16 ++ drivers/scsi/ufs/Makefile | 2 + drivers/scsi/ufs/tc-dwc-g210-pci.c | 181 ++++++++++++ drivers/scsi/ufs/tc-dwc-g210-pltfrm.c | 113 ++++++++ drivers/scsi/ufs/tc-dwc-g210.c | 315 +++++++++++++++++++++ drivers/scsi/ufs/tc-dwc-g210.h | 19 ++ drivers/scsi/ufs/ufshcd-dwc.c | 150 ++++++++++ drivers/scsi/ufs/ufshcd-dwc.h | 26 ++ drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +- drivers/scsi/ufs/ufshcd.c | 89 +++--- drivers/scsi/ufs/ufshcd.h | 7 + drivers/scsi/ufs/ufshci-dwc.h | 36 +++ drivers/scsi/ufs/ufshci.h | 11 + drivers/scsi/ufs/unipro.h | 39 +++ 17 files changed, 998 insertions(+), 44 deletions(-) create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c create mode 100644 drivers/scsi/ufs/tc-dwc-g210.c create mode 100644 drivers/scsi/ufs/tc-dwc-g210.h create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h create mode 100644 drivers/scsi/ufs/ufshci-dwc.h
Signature · 1 line
1.8.1.5
PATCH v16 1/9 ufs: fixed typo in ufshcd-pltfrm
Fixed typo in ufshcd-pltfrm.
---
Changes v0->v16:
- Nothing changed (just to keep up with patch set version).
drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd-pltfrm.c +1 -1
@@ -372,6 +372,6 @@ EXPORT_SYMBOL_GPL(ufshcd_pltfrm_init);MODULE_AUTHOR ("Santosh Yaragnavi <[email protected]>" );MODULE_AUTHOR ("Vinayak Holikatti <[email protected]>" ); -MODULE_DESCRIPTION ("UFS host controller Pltform bus based glue driver" ); +MODULE_DESCRIPTION ("UFS host controller Platform bus based glue driver" );MODULE_LICENSE ("GPL" );MODULE_VERSION (UFSHCD_DRIVER_VERSION );
Signature · 1 line
1.8.1.5
PATCH v16 2/9 ufs: add UFS 2.0 to ufshcd-pltfrm bindings
In reply to Joao PintoAdd UFS 2.0 to the ufshcd-pltfrm devicetree binding.
---
Changes v12->v16:
- Nothing changed (just to keep up with patch set version). Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2 -2
@@ -4,8 +4,8 @@ UFSHC nodes are defined to describe on-chip UFS host controllers. Each UFS controller instance should have its own node. Required properties: -- compatible : must contain "jedec,ufs-1.1", may also list one or more - of the following: +- compatible : must contain "jedec,ufs-1.1" or "jedec,ufs-2.0", may + also list one or more of the following: "qcom,msm8994-ufshc" "qcom,msm8996-ufshc" "qcom,ufshc"
Signature · 1 line
1.8.1.5
PATCH v16 3/9 ufs: add UFS 2.0 capabilities
In reply to Joao PintoAdd UFS 2.0 support to the UFS core driver.
---
Changes v12->v16:
- Nothing changed (just to keep up with patch set version). Changes v11->v12 (Tomas Winkler):
- devicetree binding tweak was moved to a separated patch
- unipro tweaks were moved to a separated patch
- ufshcd_compose_upiu was decomposed in 2 functions
- UTP_CMD_TYPE_UFS_STORAGE is now 0x1 (previously was 0x11) Changes v8->v11:
- Nothing changed (just to keep up with patch set version). Changes v7->v8:
- Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings Changes v0->v7:
- Nothing changed (just to keep up with patch set version).
drivers/scsi/ufs/ufshcd.c | 89 +++++++++++++++++++++++++---------------------- drivers/scsi/ufs/ufshci.h | 5 +++ 2 files changed, 53 insertions(+), 41 deletions(-)
drivers/scsi/ufs/ufshcd.c +48 -41
@@ -1173,7 +1173,7 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs)* @cmd_dir: requests data direction */ static void ufshcd_prepare_req_desc_hdr (struct ufshcd_lrb *lrbp, -u32 *upiu_flags,enum dma_data_direction cmd_dir) +u32 *upiu_flags,enum dma_data_direction cmd_dir) {struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;u32 data_direction;
@@ -1299,47 +1299,55 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp) }/** -* ufshcd_compose_upiu - form UFS Protocol Information Unit(UPIU) +* ufshcd_comp_devman_upiu - UFS Protocol Information Unit(UPIU) +* for Device Management Purposes * @hba - per adapter instance * @lrb - pointer to local reference block */ -static int ufshcd_compose_upiu (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) +static int ufshcd_comp_devman_upiu (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) {u32 upiu_flags;int ret =0 ; -switch (lrbp->command_type) { -case UTP_CMD_TYPE_SCSI : -if (likely (lrbp->cmd)) { -ufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags, - lrbp->cmd->sc_data_direction); -ufshcd_prepare_utp_scsi_cmd_upiu (lrbp, upiu_flags); - }else { - ret = -EINVAL ; - } -break ; -case UTP_CMD_TYPE_DEV_MANAGE : -ufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags,DMA_NONE ); -if (hba->dev_cmd.type ==DEV_CMD_TYPE_QUERY ) -ufshcd_prepare_utp_query_req_upiu ( - hba, lrbp, upiu_flags); -else if (hba->dev_cmd.type ==DEV_CMD_TYPE_NOP ) -ufshcd_prepare_utp_nop_upiu (lrbp); -else - ret = -EINVAL ; -break ; -case UTP_CMD_TYPE_UFS : -/* For UFS native command implementation */ - ret = -ENOTSUPP ; -dev_err (hba->dev,"%s: UFS native command are not supported\n" , - __func__); -break ; -default : - ret = -ENOTSUPP ; -dev_err (hba->dev,"%s: unknown command type: 0x%x\n" , - __func__, lrbp->command_type); -break ; - }/* end of switch */ +if (hba->ufs_version ==UFSHCI_VERSION_20 ) + lrbp->command_type =UTP_CMD_TYPE_UFS_STORAGE ; +else + lrbp->command_type =UTP_CMD_TYPE_DEV_MANAGE ; + +ufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags,DMA_NONE ); +if (hba->dev_cmd.type ==DEV_CMD_TYPE_QUERY ) +ufshcd_prepare_utp_query_req_upiu (hba, lrbp, upiu_flags); +else if (hba->dev_cmd.type ==DEV_CMD_TYPE_NOP ) +ufshcd_prepare_utp_nop_upiu (lrbp); +else + ret = -EINVAL ; + +return ret; +} + +/** +* ufshcd_comp_scsi_upiu - UFS Protocol Information Unit(UPIU) +* for SCSI Purposes +* @hba - per adapter instance +* @lrb - pointer to local reference block +*/ +static int ufshcd_comp_scsi_upiu (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) +{ +u32 upiu_flags; +int ret =0 ; + +if (hba->ufs_version ==UFSHCI_VERSION_20 ) + lrbp->command_type =UTP_CMD_TYPE_UFS_STORAGE ; +else + lrbp->command_type =UTP_CMD_TYPE_SCSI ; + +if (likely (lrbp->cmd)) { +ufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags, + lrbp->cmd->sc_data_direction); +ufshcd_prepare_utp_scsi_cmd_upiu (lrbp, upiu_flags); + }else { + ret = -EINVAL ; + }return ret; }
@@ -1451,10 +1459,9 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) lrbp->task_tag = tag; lrbp->lun =ufshcd_scsi_to_upiu_lun (cmd->device->lun); lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed (hba) ? true : false; - lrbp->command_type =UTP_CMD_TYPE_SCSI ; -/* form UPIU before issuing the command */ -ufshcd_compose_upiu (hba, lrbp); +ufshcd_comp_scsi_upiu (hba, lrbp); + err =ufshcd_map_sg (lrbp);if (err) { lrbp->cmd =NULL ;
@@ -1479,11 +1486,10 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, lrbp->sense_buffer =NULL ; lrbp->task_tag = tag; lrbp->lun =0 ;/* device management cmd is not specific to any LUN */ - lrbp->command_type =UTP_CMD_TYPE_DEV_MANAGE ; lrbp->intr_cmd = true;/* No interrupt aggregation */ hba->dev_cmd.type = cmd_type; -return ufshcd_compose_upiu (hba, lrbp); +return ufshcd_comp_devman_upiu (hba, lrbp); } static int
@@ -3539,7 +3545,8 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,/* Do not touch lrbp after scsi done */ cmd->scsi_done (cmd);__ufshcd_release (hba); - }else if (lrbp->command_type ==UTP_CMD_TYPE_DEV_MANAGE ) { + }else if (lrbp->command_type ==UTP_CMD_TYPE_DEV_MANAGE || + lrbp->command_type ==UTP_CMD_TYPE_UFS_STORAGE ) {if (hba->dev_cmd.complete)complete (hba->dev_cmd.complete); }
drivers/scsi/ufs/ufshci.h +5 -0
@@ -279,6 +279,11 @@ enum { UTP_CMD_TYPE_DEV_MANAGE = 0x2, }; +/* To accommodate UFS2.0 required Command type */ +enum { +UTP_CMD_TYPE_UFS_STORAGE =0x1 , +}; +enum {UTP_SCSI_COMMAND =0x00000000 ,UTP_NATIVE_UFS_COMMAND =0x10000000 ,
Signature · 1 line
1.8.1.5
PATCH v16 4/9 ufs: add unipro attributes
In reply to Joao PintoAdd unipro attributes.
---
Changes v12->v16:
- Nothing changed (just to keep up with patch set version). Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12
drivers/scsi/ufs/unipro.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/scsi/ufs/unipro.h +39 -0
@@ -36,6 +36,10 @@#define TX_LCC_SEQUENCER 0x0032#define TX_MIN_ACTIVATETIME 0x0033#define TX_PWM_G6_G7_SYNC_LENGTH 0x0034 +#define TX_REFCLKFREQ 0x00EB +#define TX_CFGCLKFREQVAL 0x00EC +#define CFGEXTRATTR 0x00F0 +#define DITHERCTRL2 0x00F1/* * M-RX Configuration Attributes
@@ -51,10 +55,40 @@#define RX_TERMINATION_FORCE_ENABLE 0x0089#define RX_MIN_ACTIVATETIME_CAPABILITY 0x008F#define RX_HIBERN8TIME_CAPABILITY 0x0092 +#define RX_REFCLKFREQ 0x00EB +#define RX_CFGCLKFREQVAL 0x00EC +#define CFGWIDEINLN 0x00F0 +#define CFGRXCDR8 0x00BA +#define ENARXDIRECTCFG4 0x00F2 +#define CFGRXOVR8 0x00BD +#define RXDIRECTCTRL2 0x00C7 +#define ENARXDIRECTCFG3 0x00F3 +#define RXCALCTRL 0x00B4 +#define ENARXDIRECTCFG2 0x00F4 +#define CFGRXOVR4 0x00E9 +#define RXSQCTRL 0x00B5 +#define CFGRXOVR6 0x00BF#define is_mphy_tx_attr (attr) (attr < RX_MODE)#define RX_MIN_ACTIVATETIME_UNIT_US 100#define HIBERN8TIME_UNIT_US 100 + +/* +* Common Block Attributes +*/ +#define TX_GLOBALHIBERNATE UNIPRO_CB_OFFSET(0x002B) +#define REFCLKMODE UNIPRO_CB_OFFSET(0x00BF) +#define DIRECTCTRL19 UNIPRO_CB_OFFSET(0x00CD) +#define DIRECTCTRL10 UNIPRO_CB_OFFSET(0x00E6) +#define CDIRECTCTRL6 UNIPRO_CB_OFFSET(0x00EA) +#define RTOBSERVESELECT UNIPRO_CB_OFFSET(0x00F0) +#define CBDIVFACTOR UNIPRO_CB_OFFSET(0x00F1) +#define CBDCOCTRL5 UNIPRO_CB_OFFSET(0x00F3) +#define CBPRGPLL2 UNIPRO_CB_OFFSET(0x00F8) +#define CBPRGTUNING UNIPRO_CB_OFFSET(0x00FB) + +#define UNIPRO_CB_OFFSET (x) (0x8000 | x) +/* * PHY Adpater attributes */
@@ -119,6 +153,11 @@#define PA_TACTIVATE_TIME_UNIT_US 10#define PA_HIBERN8_TIME_UNIT_US 100 +/*Other attributes*/ +#define VS_MPHYCFGUPDT 0xD085 +#define VS_DEBUGOMC 0xD09E +#define VS_POWERSTATE 0xD083 +/* PHY Adapter Protocol Constants */ #define PA_MAXDATALANES 4
Signature · 1 line
1.8.1.5
PATCH v16 5/9 ufs: add link status to ufshci
In reply to Joao PintoAdd link status to ufshci.
---
Changes v12->v16:
- Nothing changed (just to keep up with patch set version). Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12
drivers/scsi/ufs/ufshci.h | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/ufs/ufshci.h +6 -0
@@ -220,6 +220,12 @@ enum {#define UIC_ARG_ATTR_TYPE (t) (((t) & 0xFF) << 16)#define UIC_GET_ATTR_ID (v) (((v) >> 16) & 0xFFFF) +/* Link Status*/ +enum link_status { +UFSHCD_LINK_IS_DOWN =1 , +UFSHCD_LINK_IS_UP =2 , +}; +/* UIC Commands */ enum uic_cmd_dme {UIC_CMD_DME_GET =0x01 ,
Signature · 1 line
1.8.1.5
PATCH v16 6/9 ufs: add support for DesignWare Controller
In reply to Joao PintoThis patch has the goal to add support for DesignWare UFS Controller specific operations.
---
Changes v15->v16 (Martin K. Petersen):
- DWC core does not longer have a Kconfig item (also affected Makefile) Kconfig options reduction was the justification for this change.
Changes v12->v15:
- Nothing changed (just to keep up with patch set version). Changes v11->v12 (Tomas Winkler):
- custom_phy_initialization is now phy_initialization
- ufshcd_is_intr_aggr_allowed() has now a DWC tweak
- link status was now moved to a separated patch
Changes v10->v11:
- Nothing changed (just to keep up with patch set version). Changes v9->v10 (Arnd Bergmann):
- Patch now only has DWC controller specific code
- Added custom_phy_initialization callback for PHY specific code Changes v8->v9 (Robert Herring):
- drop 0x in the node declaration
- most specific compatibility string declared first
Changes v7->v8 (Akinobu Mita):
- DME sets were simplified for easier reading
- CLK DIV default values definitions names were changed to match the register's name
- New line added to dev_err and dev_info statements
Changes v6->v7 (Arnd Bergmann):
- Changed DT node name (to ufs only) and the memory address (to 0xd000000)
- Removed CONFIG_PM from the PCI glue driver (pm.h already does this)
- No other changes are necessary in ufshcd.c because of the link up notify function usage (it is simpler now)
- Removed the PHY mentioning since the Test Chip is not a real PHY for real world usage, since it is a test chip for prototyping with a very specific usage
- Added again the Test Chip 20-bit option
Changes v5->v6:
- Patch bad format fixed
Changes v4->v5 (Akinobu Mita):
- All functions used only locally in ufshcd-dwc are now declared as static
- ufshcd_dwc_configuration() was removed in ufshcd-dwc and a notify function (ufshcd_dwc_link_startup_notify) was created to deal with the DWC specific init routines
- 20-bit RMMI option was removed from Kconfig. Now if MPHY TC is selected and 40-bit is not then it assumes a 20-bit config
Changes v3->v4 (Arnd Bergmann and Mark Rutland):
- SCSI_UFS_DWC_HOOKS is now silent and selected by the SCSI_UFS_DWC_PLAT or SCSI_UFS_DWC_PCI
- Compatibility string has the ufs core version for info purposes since the driver is capable of getting the controller version from its registers
- Created ufs-dwc-pci glue driver with specific DWC data
- MPHY configuration remains in the ufshcd-dwc since it is unipro attribute writting only not following the a linux phy framework logic
Changes v2->v3 (Julian Calaby):
- Implement a common DWC code to be used by the platform and pci glue drivers
- Synopsys ID & Class added to the existing pci driver and specific DWC was also added to the pci driver
Changes v1->v2 (Akinobu Mita):
- Implement a platform driver that uses the existing UFS core driver
- Add DWC specific code to the existing UFS core driver
MAINTAINERS | 6 ++ drivers/scsi/ufs/ufshcd-dwc.c | 150 ++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshcd-dwc.h | 26 ++++++++ drivers/scsi/ufs/ufshcd.h | 7 ++ drivers/scsi/ufs/ufshci-dwc.h | 36 ++++++++++ 5 files changed, 225 insertions(+) create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h create mode 100644 drivers/scsi/ufs/ufshci-dwc.h
MAINTAINERS +6 -0
@@ -11451,6 +11451,12 @@ S: Supported F: Documentation/scsi/ufs.txt F: drivers/scsi/ufs/ +UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS +M: Joao Pinto <[email protected]> +L: [email protected] +S: Supported +F: drivers/scsi/ufs/*dwc* + UNSORTED BLOCK IMAGES (UBI) M: Artem Bityutskiy <[email protected]> M: Richard Weinberger <[email protected]>
drivers/scsi/ufs/ufshcd-dwc.c new file +150 -0
150 lines not on this page · raw message
drivers/scsi/ufs/ufshcd-dwc.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* UFS Host driver for Synopsys Designware Core +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* Authors: Joao Pinto <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#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/scsi/ufs/ufshcd.h +7 -0
@@ -264,6 +264,7 @@ struct ufs_pwr_mode_info {* @suspend: called during host controller PM callback * @resume: called during host controller PM callback * @dbg_register_dump: used to dump controller debug information +* @phy_initialization: used to initialize phys */ struct ufs_hba_variant_ops {const char *name;
@@ -285,6 +286,7 @@ struct ufs_hba_variant_ops {int (*suspend)(struct ufs_hba *,enum ufs_pm_op );int (*resume)(struct ufs_hba *,enum ufs_pm_op );void (*dbg_register_dump)(struct ufs_hba *hba); +int (*phy_initialization)(struct ufs_hba *); };/* clock gating state */
@@ -567,11 +569,16 @@ static inline bool ufshcd_can_autobkops_during_suspend(struct ufs_hba *hba)static inline bool ufshcd_is_intr_aggr_allowed (struct ufs_hba *hba) { +/* DWC UFS Core has the Interrupt aggregation feature but is not detectable*/ +#ifndef CONFIG_SCSI_UFS_DWC if ((hba->caps &UFSHCD_CAP_INTR_AGGR ) && !(hba->quirks &UFSHCD_QUIRK_BROKEN_INTR_AGGR ))return true;else return false; +#else +return true; +#endif }#define ufshcd_writel (hba, val, reg) \
drivers/scsi/ufs/ufshci-dwc.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* UFS Host driver for Synopsys Designware Core +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* Authors: Joao Pinto <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#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 /* End of Header */
Signature · 1 line
1.8.1.5
PATCH v16 7/9 ufs: add support for Synopsys G210 Test Chip
In reply to Joao PintoThis patch adds support for Synopsys G210 Test Chip.
---
Changes v15->v16 (Martin K. Petersen):
- Test Chip G210 does not longer have a Kconfig item (also affected Makefile) Kconfig options reduction was the justification for this change.
Changes v10->v15:
- Nothing changed (just to keep up with patch set version). Changes v0->v10:
- This patch only appeared in v10
drivers/scsi/ufs/tc-dwc-g210.c | 315 +++++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/tc-dwc-g210.h | 19 +++ 2 files changed, 334 insertions(+) create mode 100644 drivers/scsi/ufs/tc-dwc-g210.c create mode 100644 drivers/scsi/ufs/tc-dwc-g210.h
drivers/scsi/ufs/tc-dwc-g210.c new file +315 -0
@@ -0,0 +1,315 @@ +/* +* Synopsys G210 Test Chip driver +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* Authors: Joao Pinto <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include "ufshcd.h" +#include "unipro.h" + +#include "ufshcd-dwc.h" +#include "ufshci-dwc.h" + +/** +* tc_dwc_g210_setup_40bit_rmmi() +* This function configures Synopsys TC specific atributes (40-bit RMMI) +* @hba: Pointer to drivers structure +* +* Returns 0 on success or non-zero value on failure +*/ +static int tc_dwc_g210_setup_40bit_rmmi (struct ufs_hba *hba) +{ +const struct ufshcd_dme_attr_val setup_attrs[] = { + {UIC_ARG_MIB (TX_GLOBALHIBERNATE ),0x00 ,DME_LOCAL }, + {UIC_ARG_MIB (REFCLKMODE ),0x01 ,DME_LOCAL }, + {UIC_ARG_MIB (CDIRECTCTRL6 ),0x80 ,DME_LOCAL }, + {UIC_ARG_MIB (CBDIVFACTOR ),0x08 ,DME_LOCAL }, + {UIC_ARG_MIB (CBDCOCTRL5 ),0x64 ,DME_LOCAL }, + {UIC_ARG_MIB (CBPRGTUNING ),0x09 ,DME_LOCAL }, + {UIC_ARG_MIB (RTOBSERVESELECT ),0x00 ,DME_LOCAL }, + {UIC_ARG_MIB_SEL (TX_REFCLKFREQ ,SELIND_LN0_TX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (TX_CFGCLKFREQVAL ,SELIND_LN0_TX ),0x19 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGEXTRATTR ,SELIND_LN0_TX ),0x14 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (DITHERCTRL2 ,SELIND_LN0_TX ),0xd6 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RX_REFCLKFREQ ,SELIND_LN0_RX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RX_CFGCLKFREQVAL ,SELIND_LN0_RX ),0x19 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGWIDEINLN ,SELIND_LN0_RX ),4 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXCDR8 ,SELIND_LN0_RX ),0x80 , +DME_LOCAL }, + {UIC_ARG_MIB (DIRECTCTRL10 ),0x04 ,DME_LOCAL }, + {UIC_ARG_MIB (DIRECTCTRL19 ),0x02 ,DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXCDR8 ,SELIND_LN0_RX ),0x80 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (ENARXDIRECTCFG4 ,SELIND_LN0_RX ),0x03 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR8 ,SELIND_LN0_RX ),0x16 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RXDIRECTCTRL2 ,SELIND_LN0_RX ),0x42 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (ENARXDIRECTCFG3 ,SELIND_LN0_RX ),0xa4 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RXCALCTRL ,SELIND_LN0_RX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (ENARXDIRECTCFG2 ,SELIND_LN0_RX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR4 ,SELIND_LN0_RX ),0x28 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RXSQCTRL ,SELIND_LN0_RX ),0x1E , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR6 ,SELIND_LN0_RX ),0x2f , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR6 ,SELIND_LN0_RX ),0x2f , +DME_LOCAL }, + {UIC_ARG_MIB (CBPRGPLL2 ),0x00 ,DME_LOCAL }, + }; + +return ufshcd_dwc_dme_set_attrs (hba, setup_attrs, +ARRAY_SIZE (setup_attrs)); +} + +/** +* tc_dwc_g210_setup_20bit_rmmi_lane0() +* This function configures Synopsys TC 20-bit RMMI Lane 0 +* @hba: Pointer to drivers structure +* +* Returns 0 on success or non-zero value on failure +*/ +static int tc_dwc_g210_setup_20bit_rmmi_lane0 (struct ufs_hba *hba) +{ +const struct ufshcd_dme_attr_val setup_attrs[] = { + {UIC_ARG_MIB_SEL (TX_REFCLKFREQ ,SELIND_LN0_TX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (TX_CFGCLKFREQVAL ,SELIND_LN0_TX ),0x19 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RX_CFGCLKFREQVAL ,SELIND_LN0_RX ),0x19 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGEXTRATTR ,SELIND_LN0_TX ),0x12 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (DITHERCTRL2 ,SELIND_LN0_TX ),0xd6 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RX_REFCLKFREQ ,SELIND_LN0_RX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGWIDEINLN ,SELIND_LN0_RX ),2 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXCDR8 ,SELIND_LN0_RX ),0x80 , +DME_LOCAL }, + {UIC_ARG_MIB (DIRECTCTRL10 ),0x04 ,DME_LOCAL }, + {UIC_ARG_MIB (DIRECTCTRL19 ),0x02 ,DME_LOCAL }, + {UIC_ARG_MIB_SEL (ENARXDIRECTCFG4 ,SELIND_LN0_RX ),0x03 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR8 ,SELIND_LN0_RX ),0x16 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RXDIRECTCTRL2 ,SELIND_LN0_RX ),0x42 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (ENARXDIRECTCFG3 ,SELIND_LN0_RX ),0xa4 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RXCALCTRL ,SELIND_LN0_RX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (ENARXDIRECTCFG2 ,SELIND_LN0_RX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR4 ,SELIND_LN0_RX ),0x28 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RXSQCTRL ,SELIND_LN0_RX ),0x1E , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR6 ,SELIND_LN0_RX ),0x2f , +DME_LOCAL }, + {UIC_ARG_MIB (CBPRGPLL2 ),0x00 ,DME_LOCAL }, + }; + +return ufshcd_dwc_dme_set_attrs (hba, setup_attrs, +ARRAY_SIZE (setup_attrs)); +} + +/** +* tc_dwc_g210_setup_20bit_rmmi_lane1() +* This function configures Synopsys TC 20-bit RMMI Lane 1 +* @hba: Pointer to drivers structure +* +* Returns 0 on success or non-zero value on failure +*/ +static int tc_dwc_g210_setup_20bit_rmmi_lane1 (struct ufs_hba *hba) +{ +int connected_rx_lanes =0 ; +int connected_tx_lanes =0 ; +int ret =0 ; + +const struct ufshcd_dme_attr_val setup_tx_attrs[] = { + {UIC_ARG_MIB_SEL (TX_REFCLKFREQ ,SELIND_LN1_TX ),0x0d , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (TX_CFGCLKFREQVAL ,SELIND_LN1_TX ),0x19 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGEXTRATTR ,SELIND_LN1_TX ),0x12 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (DITHERCTRL2 ,SELIND_LN0_TX ),0xd6 , +DME_LOCAL }, + }; + +const struct ufshcd_dme_attr_val setup_rx_attrs[] = { + {UIC_ARG_MIB_SEL (RX_REFCLKFREQ ,SELIND_LN1_RX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RX_CFGCLKFREQVAL ,SELIND_LN1_RX ),0x19 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGWIDEINLN ,SELIND_LN1_RX ),2 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXCDR8 ,SELIND_LN1_RX ),0x80 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (ENARXDIRECTCFG4 ,SELIND_LN1_RX ),0x03 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR8 ,SELIND_LN1_RX ),0x16 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RXDIRECTCTRL2 ,SELIND_LN1_RX ),0x42 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (ENARXDIRECTCFG3 ,SELIND_LN1_RX ),0xa4 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RXCALCTRL ,SELIND_LN1_RX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (ENARXDIRECTCFG2 ,SELIND_LN1_RX ),0x01 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR4 ,SELIND_LN1_RX ),0x28 , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (RXSQCTRL ,SELIND_LN1_RX ),0x1E , +DME_LOCAL }, + {UIC_ARG_MIB_SEL (CFGRXOVR6 ,SELIND_LN1_RX ),0x2f , +DME_LOCAL }, + }; + +/* Get the available lane count */ +ufshcd_dme_get (hba,UIC_ARG_MIB (PA_CONNECTEDRXDATALANES ), + &connected_rx_lanes); +ufshcd_dme_get (hba,UIC_ARG_MIB (PA_CONNECTEDTXDATALANES ), + &connected_tx_lanes); + +if (connected_tx_lanes ==2 ) { + + ret =ufshcd_dwc_dme_set_attrs (hba, setup_tx_attrs, +ARRAY_SIZE (setup_tx_attrs)); + +if (ret) + goto out; + } + +if (connected_rx_lanes ==2 ) { + ret =ufshcd_dwc_dme_set_attrs (hba, setup_rx_attrs, +ARRAY_SIZE (setup_rx_attrs)); + } + +out: +return ret; +} + +/** +* tc_dwc_g210_setup_20bit_rmmi() +* This function configures Synopsys TC specific atributes (20-bit RMMI) +* @hba: Pointer to drivers structure +* +* Returns 0 on success or non-zero value on failure +*/ +static int tc_dwc_g210_setup_20bit_rmmi (struct ufs_hba *hba) +{ +int ret =0 ; + +const struct ufshcd_dme_attr_val setup_attrs[] = { + {UIC_ARG_MIB (TX_GLOBALHIBERNATE ),0x00 ,DME_LOCAL }, + {UIC_ARG_MIB (REFCLKMODE ),0x01 ,DME_LOCAL }, + {UIC_ARG_MIB (CDIRECTCTRL6 ),0xc0 ,DME_LOCAL }, + {UIC_ARG_MIB (CBDIVFACTOR ),0x44 ,DME_LOCAL }, + {UIC_ARG_MIB (CBDCOCTRL5 ),0x64 ,DME_LOCAL }, + {UIC_ARG_MIB (CBPRGTUNING ),0x09 ,DME_LOCAL }, + {UIC_ARG_MIB (RTOBSERVESELECT ),0x00 ,DME_LOCAL }, + }; + + ret =ufshcd_dwc_dme_set_attrs (hba, setup_attrs, +ARRAY_SIZE (setup_attrs)); +if (ret) + goto out; + +/* Lane 0 configuration*/ + ret =tc_dwc_g210_setup_20bit_rmmi_lane0 (hba); +if (ret) + goto out; + +/* Lane 1 configuration*/ + ret =tc_dwc_g210_setup_20bit_rmmi_lane1 (hba); +if (ret) + goto out; + +out: +return ret; +} + +/** +* tc_dwc_g210_config_40_bit() +* This function configures Local (host) Synopsys 40-bit TC specific attributes +* +* @hba: Pointer to drivers structure +* +* Returns 0 on success non-zero value on failure +*/ +int tc_dwc_g210_config_40_bit (struct ufs_hba *hba) +{ +int ret =0 ; + +dev_info (hba->dev,"Configuring Test Chip 40-bit RMMI\n" ); + ret =tc_dwc_g210_setup_40bit_rmmi (hba); +if (ret) { +dev_err (hba->dev,"Configuration failed\n" ); + goto out; + } + +/* To write Shadow register bank to effective configuration block */ + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (VS_MPHYCFGUPDT ),0x01 ); +if (ret) + goto out; + +/* To configure Debug OMC */ + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (VS_DEBUGOMC ),0x01 ); + +out: +return ret; +} +EXPORT_SYMBOL (tc_dwc_g210_config_40_bit); + +/** +* tc_dwc_g210_config_20_bit() +* This function configures Local (host) Synopsys 20-bit TC specific attributes +* +* @hba: Pointer to drivers structure +* +* Returns 0 on success non-zero value on failure +*/ +int tc_dwc_g210_config_20_bit (struct ufs_hba *hba) +{ +int ret =0 ; + +dev_info (hba->dev,"Configuring Test Chip 20-bit RMMI\n" ); + ret =tc_dwc_g210_setup_20bit_rmmi (hba); +if (ret) { +dev_err (hba->dev,"Configuration failed\n" ); + goto out; + } + +/* To write Shadow register bank to effective configuration block */ + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (VS_MPHYCFGUPDT ),0x01 ); +if (ret) + goto out; + +/* To configure Debug OMC */ + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (VS_DEBUGOMC ),0x01 ); + +out: +return ret; +} +EXPORT_SYMBOL (tc_dwc_g210_config_20_bit);
drivers/scsi/ufs/tc-dwc-g210.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Synopsys G210 Test Chip driver +* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* Authors: Joao Pinto <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _TC_DWC_G210_H +#define _TC_DWC_G210_H + +int tc_dwc_g210_config_40_bit (struct ufs_hba *hba); +int tc_dwc_g210_config_20_bit (struct ufs_hba *hba); + +#endif /* End of Header */
Signature · 1 line
1.8.1.5
PATCH v16 8/9 add TC G210 platform driver
In reply to Joao PintoThis patch adds a glue platform driver for the Synopsys G210 Test Chip.
---
Changes v15->v16 (Martin K. Petersen):
- The glue driver Makefile entry calls the dwc and tc objects directly. Changes v13->v15:
- Nothing changed (just to keep up with patch set version). Changes v12->v13 (Rob Herring):
- Removed spaces from the compatibility string (pltfm driver and DT bindings)
- Removed underscores from the node descriptor
Changes v11->v12 (Tomas Winkler):
- custom_phy_initialization replaced by phy_initialization Changes v10->v11 (Arnd Bergmann):
- vops structs are now passed in .data
Changes v0->v10:
- This patch only appeared in v10
.../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt | 26 +++++ drivers/scsi/ufs/Kconfig | 8 ++ drivers/scsi/ufs/Makefile | 1 + drivers/scsi/ufs/tc-dwc-g210-pltfrm.c | 113 +++++++++++++++++++++ 4 files changed, 148 insertions(+) create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt new file +26 -0
@@ -0,0 +1,26 @@ +* Universal Flash Storage (UFS) DesignWare Host Controller + +DWC_UFS nodes are defined to describe on-chip UFS host controllers and MPHY. +Each UFS controller instance should have its own node. + +Required properties: +- compatible : compatible list must contain the PHY type & version: + "snps,g210-tc-6.00-20bit" + "snps,g210-tc-6.00-40bit" + complemented with the Controller IP version: + "snps,dwc-ufshcd-1.40a" + complemented with the JEDEC version: + "jedec,ufs-1.1" + "jedec,ufs-2.0" + +- reg : <registers mapping> +- interrupts : <interrupt mapping for UFS host controller IRQ> + +Example for a setup using a 1.40a DWC Controller with a 6.00 G210 40-bit TC: + dwc-ufs@d0000000 { + compatible = "snps,g210-tc-6.00-40bit", + "snps,dwc-ufshcd-1.40a", + "jedec,ufs-2.0"; + reg = < 0xd0000000 0x10000 >; + interrupts = < 24 >; + };
drivers/scsi/ufs/Kconfig +8 -0
@@ -72,6 +72,14 @@ config SCSI_UFSHCD_PLATFORM If unsure, say N. +config SCSI_UFS_DWC_TC_PLATFORM + tristate "DesignWare platform support using a G210 Test Chip" + depends on SCSI_UFSHCD_PLATFORM + ---help--- + Synopsys Test Chip is a PHY for prototyping purposes. + + If unsure, say N. + config SCSI_UFS_QCOM tristate "QCOM specific hooks to UFS controller platform driver" depends on SCSI_UFSHCD_PLATFORM && ARCH_QCOM
drivers/scsi/ufs/Makefile +1 -0
@@ -1,4 +1,5 @@ # UFSHCD makefile +obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
drivers/scsi/ufs/tc-dwc-g210-pltfrm.c new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
1.8.1.5
PATCH v16 9/9 ufs: add TC G210 pci driver
In reply to Joao PintoThis patch adds a glue pci driver for the Synopsys G210 Test Chip.
---
Changes v15->v16 (Martin K. Petersen):
- The glue driver Makefile entry calls the dwc and tc objects directly. Changes v13->v15:
- Nothing changed (just to keep up with patch set version). Changes v12->v13:
- Nothing changed (just to keep up with patch set version). Changes v10->v12 (Tomas Winkler):
- custom_phy_initialization replaced by phy_initialization Changes v10->v11 (Arnd Bergmann):
- tc_type is now initialized to TC_G210_INV
- probe function checks if the test chip version is specified Changes v0->v10:
- This patch only appeared in v10
drivers/scsi/ufs/Kconfig | 8 ++ drivers/scsi/ufs/Makefile | 1 + drivers/scsi/ufs/tc-dwc-g210-pci.c | 181 +++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+) create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c
drivers/scsi/ufs/Kconfig +8 -0
@@ -61,6 +61,14 @@ config SCSI_UFSHCD_PCI If unsure, say N. +config SCSI_UFS_DWC_TC_PCI + tristate "DesignWare pci support using a G210 Test Chip" + depends on SCSI_UFSHCD_PCI + ---help--- + Synopsys Test Chip is a PHY for prototyping purposes. + + If unsure, say N. + config SCSI_UFSHCD_PLATFORM tristate "Platform bus based UFS Controller support" depends on SCSI_UFSHCD
drivers/scsi/ufs/Makefile +1 -0
@@ -1,4 +1,5 @@ # UFSHCD makefile +obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210.o obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
drivers/scsi/ufs/tc-dwc-g210-pci.c new file +181 -0
181 lines not on this page · raw message
Signature · 1 line
1.8.1.5