add support for DWC UFS Controller
Subsystems (3)
v7 cover add support for DWC UFS Controller
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 ufs-dwc glue platform driver
- Implement a ufs-dwc-pci glue pci driver
Joao Pinto (3):
fixed typo in ufshcd-pltfrm
added UFS 2.0 capabilities
add support for DWC UFS Host Controller
Documentation/devicetree/bindings/ufs/ufs-dwc.txt | 17 + MAINTAINERS | 6 + drivers/scsi/ufs/Kconfig | 51 ++ drivers/scsi/ufs/Makefile | 3 + drivers/scsi/ufs/ufs-dwc-pci.c | 172 +++++ drivers/scsi/ufs/ufs-dwc.c | 102 +++ drivers/scsi/ufs/ufshcd-dwc.c | 739 ++++++++++++++++++++++ drivers/scsi/ufs/ufshcd-dwc.h | 18 + drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +- drivers/scsi/ufs/ufshcd.c | 29 +- drivers/scsi/ufs/ufshci-dwc.h | 42 ++ drivers/scsi/ufs/ufshci.h | 1 + drivers/scsi/ufs/unipro.h | 39 ++ 13 files changed, 1216 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/ufs/ufs-dwc.txt create mode 100644 drivers/scsi/ufs/ufs-dwc-pci.c create mode 100644 drivers/scsi/ufs/ufs-dwc.c 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 v7 1/3 fixed typo in ufshcd-pltfrm
Fixed typo in ufshcd-pltfrm.
---
Changes v0->v7:
- 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
@@ -353,6 +353,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 v7 2/3 added UFS 2.0 capabilities
In reply to Joao PintoAdding UFS 2.0 support to the UFS core driver.
---
Changes v0->v7:
- Nothing changed (just to keep up with patch set version).
drivers/scsi/ufs/ufshcd.c | 29 +++++++++++++++++++++++++---- drivers/scsi/ufs/ufshci.h | 1 + 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/scsi/ufs/ufshcd.c +25 -4
@@ -1223,6 +1223,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) ret = -EINVAL ; }break ; +case UTP_CMD_TYPE_UFS_STORAGE :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 )
@@ -1287,6 +1288,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)struct ufshcd_lrb *lrbp;struct ufs_hba *hba;unsigned long flags; +u32 upiu_flags;int tag;int err =0 ;
@@ -1343,10 +1345,23 @@ 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 ; + +if (hba->ufs_version ==UFSHCI_VERSION_20 ) + lrbp->command_type =UTP_CMD_TYPE_UFS_STORAGE ; +else + lrbp->command_type =UTP_CMD_TYPE_SCSI ;/* form UPIU before issuing the command */ -ufshcd_compose_upiu (hba, lrbp); +if (hba->ufs_version ==UFSHCI_VERSION_20 ) { +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 + err = -EINVAL ; + }else +ufshcd_compose_upiu (hba, lrbp); + err =ufshcd_map_sg (lrbp);if (err) { lrbp->cmd =NULL ;
@@ -1371,7 +1386,12 @@ 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 ; + +if (hba->ufs_version ==UFSHCI_VERSION_20 ) + lrbp->command_type =UTP_CMD_TYPE_UFS_STORAGE ; +else + lrbp->command_type =UTP_CMD_TYPE_DEV_MANAGE ; + lrbp->intr_cmd = true;/* No interrupt aggregation */ hba->dev_cmd.type = cmd_type;
@@ -3187,7 +3207,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 +1 -0
@@ -273,6 +273,7 @@ enum {UTP_CMD_TYPE_SCSI =0x0 ,UTP_CMD_TYPE_UFS =0x1 ,UTP_CMD_TYPE_DEV_MANAGE =0x2 , + UTP_CMD_TYPE_UFS_STORAGE = 0x11, }; enum {
Signature · 1 line
1.8.1.5
PATCH v7 3/3 add support for DWC UFS Host Controller
In reply to Joao PintoThis patch has the goal to add support for DesignWare UFS Controller specific operations and to add specific platform and pci drivers.
---
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
Documentation/devicetree/bindings/ufs/ufs-dwc.txt | 17 + MAINTAINERS | 6 + drivers/scsi/ufs/Kconfig | 51 ++ drivers/scsi/ufs/Makefile | 3 + drivers/scsi/ufs/ufs-dwc-pci.c | 172 +++++ drivers/scsi/ufs/ufs-dwc.c | 102 +++ drivers/scsi/ufs/ufshcd-dwc.c | 739 ++++++++++++++++++++++ drivers/scsi/ufs/ufshcd-dwc.h | 18 + drivers/scsi/ufs/ufshci-dwc.h | 42 ++ drivers/scsi/ufs/unipro.h | 39 ++ 10 files changed, 1189 insertions(+) create mode 100644 Documentation/devicetree/bindings/ufs/ufs-dwc.txt create mode 100644 drivers/scsi/ufs/ufs-dwc-pci.c create mode 100644 drivers/scsi/ufs/ufs-dwc.c 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
Documentation/devicetree/bindings/ufs/ufs-dwc.txt new file +17 -0
@@ -0,0 +1,17 @@ +* Universal Flash Storage (UFS) DesignWare Host Controller + +DWC_UFSHC nodes are defined to describe on-chip UFS host controllers. +Each UFS controller instance should have its own node. + +Required properties: +- compatible : compatible string ("snps,ufshcd-1.0", "snps,ufshcd-1.1" + or "snps,ufshcd-2.0") +- reg : <registers mapping> +- interrupts : <interrupt mapping for UFS host controller IRQ> + +Example: + ufs@0xd0000000 { + compatible = "snps,ufshcd-2.0"; + reg = < 0xd0000000 0x10000 >; + interrupts = < 24 >; + };
MAINTAINERS +6 -0
@@ -11006,6 +11006,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/Kconfig +51 -0
54 lines not on this page · raw message
drivers/scsi/ufs/Makefile +3 -0
@@ -1,4 +1,7 @@ # UFSHCD makefile +obj-$(CONFIG_SCSI_UFS_DWC_HOOKS) += ufshcd-dwc.o +obj-$(CONFIG_SCSI_UFS_DWC_PLAT) += ufs-dwc.o +obj-$(CONFIG_SCSI_UFS_DWC_PCI) += ufs-dwc-pci.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/ufs-dwc-pci.c new file +172 -0
172 lines not on this page · raw message
drivers/scsi/ufs/ufs-dwc.c new file +102 -0
102 lines not on this page · raw message
drivers/scsi/ufs/ufshcd-dwc.c new file +739 -0
739 lines not on this page · raw message
drivers/scsi/ufs/ufshcd-dwc.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* 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 + +int ufshcd_dwc_link_startup_notify (struct ufs_hba *hba, +enum ufs_notify_change_status status); +#endif /* End of Header */
drivers/scsi/ufs/ufshci-dwc.h new file +42 -0
42 lines not on this page · raw message
drivers/scsi/ufs/unipro.h +39 -0
@@ -35,6 +35,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
@@ -48,8 +52,38 @@#define RX_ENTER_HIBERN8 0x00A7#define RX_BYPASS_8B10B_ENABLE 0x00A8#define RX_TERMINATION_FORCE_ENABLE 0x0089 +#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) + +/* +* 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 */
@@ -110,6 +144,11 @@#define PA_STALLNOCONFIGTIME 0x15A3#define PA_SAVECONFIGTIME 0x15A4 +/*Other attributes*/ +#define VS_MPHYCFGUPDT 0xD085 +#define VS_DEBUGOMC 0xD09E +#define VS_POWERSTATE 0xD083 +/* PA power modes */ enum {FAST_MODE =1 ,
Signature · 1 line
1.8.1.5
Rob Herring
maintainerRe: [PATCH v7 3/3] add support for DWC UFS Host Controller
Quoted 65 lines · Joao Pinto
This patch has the goal to add support for DesignWare UFS Controller specific operations and to add specific platform and pci drivers.
---
Changesv6->v7(Arnd Bergmann):
- Changed DT node name (to ufs only) and the memory address (to0xd000000)
- RemovedCONFIG_PMfrom the PCI glue driver (pm.halready does this)
- No other changes are necessary inufshcd.cbecause 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
Changesv5->v6:
- Patch bad format fixed
Changesv4->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 fromKconfig. Now if MPHY TC is selected and 40-bit is not then it assumes a 20-bit config
Changesv3->v4(Arnd Bergmann and Mark Rutland):
-SCSI_UFS_DWC_HOOKSis now silent and selected by theSCSI_UFS_DWC_PLATorSCSI_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
Changesv2->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
Changesv1->v2(Akinobu Mita):
- Implement a platform driver that uses the existing UFS core driver
- Add DWC specific code to the existing UFS core driverDocumentation/devicetree/bindings/ufs/ufs-dwc.txt | 17 + MAINTAINERS | 6 + drivers/scsi/ufs/Kconfig | 51 ++ drivers/scsi/ufs/Makefile | 3 + drivers/scsi/ufs/ufs-dwc-pci.c | 172 +++++ drivers/scsi/ufs/ufs-dwc.c | 102 +++ drivers/scsi/ufs/ufshcd-dwc.c | 739 ++++++++++++++++++++++ drivers/scsi/ufs/ufshcd-dwc.h | 18 + drivers/scsi/ufs/ufshci-dwc.h | 42 ++ drivers/scsi/ufs/unipro.h | 39 ++ 10 files changed, 1189 insertions(+) create mode 100644 Documentation/devicetree/bindings/ufs/ufs-dwc.txt create mode 100644 drivers/scsi/ufs/ufs-dwc-pci.c create mode 100644 drivers/scsi/ufs/ufs-dwc.c 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.hDocumentation/devicetree/bindings/ufs/ufs-dwc.txt new file +0
-0
Documentation/devicetree/bindings/ufs/ufs-dwc.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/ufs/ufs-dwc.txt new file +8
-0@@ -0,0 +1,17 @@ +* Universal Flash Storage (UFS) DesignWare Host Controller + +DWC_UFSHC nodes are defined to describe on-chip UFS host controllers. +Each UFS controller instance should have its own node. + +Required properties: +- compatible : compatible string ("snps,ufshcd-1.0", "snps,ufshcd-1.1" + or "snps,ufshcd-2.0")
History has taught us this needs to have a vendor specific compatible string as well. Don't necessarily have to define it now, but just state a vendor string is needed too.
Documentation/devicetree/bindings/ufs/ufs-dwc.txt line 17
Quoted 9 lines
Documentation/devicetree/bindings/ufs/ufs-dwc.txt new file +9
-0+- reg : <registers mapping> +- interrupts : <interrupt mapping for UFS host controller IRQ> + +Example: + ufs@0xd0000000 { + compatible = "snps,ufshcd-2.0"; + reg = < 0xd0000000 0x10000 >; + interrupts = < 24 >; + };
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 3/3] add support for DWC UFS Host Controller
Hi Rob,
Quoted 8 lines · Rob Herring
Documentation/devicetree/bindings/ufs/ufs-dwc.txt line 8
Quoted 3 lines · Joao Pinto
Documentation/devicetree/bindings/ufs/ufs-dwc.txt new file +3
-0+Required properties: +- compatible : compatible string ("snps,ufshcd-1.0", "snps,ufshcd-1.1" + or "snps,ufshcd-2.0")History has taught us this needs to have a vendor specific compatible string as well. Don't necessarily have to define it now, but just state a vendor string is needed too.
The compatibility string already as the "snps" which is the acronym for Synopsys which is the HW Controller vendor. Isn't this enough?
Quoted 10 lines
Documentation/devicetree/bindings/ufs/ufs-dwc.txt line 17
Quoted 10 lines
+- reg : <registers mapping> +- interrupts : <interrupt mapping for UFS host controller IRQ>Documentation/devicetree/bindings/ufs/ufs-dwc.txt new file +7
-0+ +Example: + ufs@0xd0000000 { + compatible = "snps,ufshcd-2.0"; + reg = < 0xd0000000 0x10000 >; + interrupts = < 24 >; + };
Thanks,
Joao
Rob Herring
maintainerRe: [PATCH v7 3/3] add support for DWC UFS Host Controller
Quoted 8 lines · Joao Pinto
Hi Rob,
Quoted 5 lines · Rob Herring
Quoted 3 lines · Joao Pinto
Documentation/devicetree/bindings/ufs/ufs-dwc.txt new file +3
-0+Required properties: +- compatible : compatible string ("snps,ufshcd-1.0", "snps,ufshcd-1.1" + or "snps,ufshcd-2.0")
Quoted 6 lines
Quoted 3 lines
History has taught us this needs to have a vendor specific compatible string as well. Don't necessarily have to define it now, but just state a vendor string is needed too.
The compatibility string already as the "snps" which is the acronym for Synopsys which is the HW Controller vendor. Isn't this enough?
Go look drivers for any licensed IP: DW PCIe, DW GMAC, USB EHCI controllers (pretty much all licensed IP), etc. They all have variations either from versions of the IP, configuration of the IP, "enhancements" by the licensee, integration quirks, or all of the above.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 3/3] add support for DWC UFS Host Controller
In reply to Joao PintoHi Joao,
2016-02-11 21:13 GMT+09:00 Joao Pinto <Joao.Pinto-HKixBCOQz3hWk0Htik3J/[email protected]>:
Quoted 72 lines
drivers/scsi/ufs/ufshcd-dwc.c new file +72
-0+static int ufshcd_dwc_connection_setup (struct ufs_hba *hba) +{ +int ret =0 ; + +/* Local side Configuration */ + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_CONNECTIONSTATE ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (N_DEVICEID ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (N_DEVICEID_VALID ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_PEERDEVICEID ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_PEERCPORTID ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_TRAFFICCLASS ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_CPORTFLAGS ),0x6 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_CPORTMODE ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_CONNECTIONSTATE ),1 ); +if (ret) + goto out; + + +/* Peer side Configuration */ + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_CONNECTIONSTATE ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (N_DEVICEID ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (N_DEVICEID_VALID ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_PEERDEVICEID ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_PEERCPORTID ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_TRAFFICCLASS ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_CPORTFLAGS ),0x6 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_CPORTMODE ),1 );
drivers/scsi/ufs/ufshcd-dwc.c line 147
Quoted 10 lines
drivers/scsi/ufs/ufshcd-dwc.c new file +10
-0+if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_CONNECTIONSTATE ),1 ); +if (ret) + goto out; + +out: +return ret; +}
This looks a bit redundant. The most part of the functions in this file is doing ufshcd_dme_set() or ufshcd_dme_peer_set(), so should we introduce ufshcd_dme_set_attrs() like below? It will also increase readability.
struct ufshcd_dme_attr_val {
u32 attr_sel;
u32 mib_val;
u8 peer;
};int ufshcd_dme_set_attrs(struct ufs_hba *hba,
const struct ufshcd_dme_attr_val *v, int n)
{
for (i = 0; i < n; i++) {
int ret = ufshcd_dme_set_attr(hba, v[i].attr_sel, ...);
if (ret)
return ret;
}
return 0;
}static int ufshcd_dwc_connection_setup(struct ufs_hba *hba)
{
const struct ufshcd_dme_attr setup_attrs[] = {
{ UIC_ARG_MIB(T_CONNECTIONSTATE), 0, DME_LOCAL },
{ UIC_ARG_MIB(T_DEVICEID), 0, DME_LOCAL },
...
};
return ufshcd_dme_set_attrs(hba, setup_attrs, ARRAY_SIZE(setup_attrs));
}drivers/scsi/ufs/ufshcd-dwc.c line 676
Quoted 9 lines
drivers/scsi/ufs/ufshcd-dwc.c new file +9
-0+static int ufshcd_dwc_setup_tc (struct ufs_hba *hba) +{ +int ret =0 ; + +#ifdef CONFIG_SCSI_UFS_DWC_40BIT_RMMI +dev_info (hba->dev,"Configuring Test Chip 40-bit RMMI" ); + ret =ufshcd_dwc_setup_40bit_rmmi (hba); +if (ret) { +dev_err (hba->dev,"Configuration failed" );
Please add \n in the end of message.
(and there are same issues in this file)
drivers/scsi/ufs/ufshci-dwc.h line 32
Quoted 7 lines
drivers/scsi/ufs/ufshci-dwc.h new file +7
-0+ +/* Clock Divider Values: Hex equivalent of frequency in MHz */ +enum clk_div_values { +UFSHCD_CLK_DIV_62_5 =0x3e , +UFSHCD_CLK_DIV_125 =0x7d , +UFSHCD_CLK_DIV_200 =0xc8 , +};
This is used as register value for DWC_UFS_REG_HCLKDIV. So should they have similar prefix (DWC_UFS_REG_HCLKDIV_*)?
Quoted 1 line
drivers/scsi/ufs/unipro.h +0
-0
...
drivers/scsi/ufs/unipro.h line 150
Quoted 4 lines
drivers/scsi/ufs/unipro.h +4
-0+/*Other attributes*/ +#define VS_MPHYCFGUPDT 0xD085 +#define VS_DEBUGOMC 0xD09E +#define VS_POWERSTATE 0xD083
Are these vendor specific attributes? If so, please move them to ufshci-dwc.h.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 3/3] add support for DWC UFS Host Controller
Hi Akinobu,
Quoted 82 lines · Akinobu Mita
Hi Joao,
2016-02-11 21:13 GMT+09:00 Joao Pinto <Joao.Pinto-HKixBCOQz3hWk0Htik3J/[email protected]>:
Quoted 79 lines
drivers/scsi/ufs/ufshcd-dwc.c new file +79
-0+static int ufshcd_dwc_connection_setup (struct ufs_hba *hba) +{ +int ret =0 ; + +/* Local side Configuration */ + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_CONNECTIONSTATE ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (N_DEVICEID ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (N_DEVICEID_VALID ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_PEERDEVICEID ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_PEERCPORTID ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_TRAFFICCLASS ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_CPORTFLAGS ),0x6 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_CPORTMODE ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_set (hba,UIC_ARG_MIB (T_CONNECTIONSTATE ),1 ); +if (ret) + goto out; + + +/* Peer side Configuration */ + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_CONNECTIONSTATE ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (N_DEVICEID ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (N_DEVICEID_VALID ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_PEERDEVICEID ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_PEERCPORTID ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_TRAFFICCLASS ),0 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_CPORTFLAGS ),0x6 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_CPORTMODE ),1 ); +if (ret) + goto out; + + ret =ufshcd_dme_peer_set (hba,UIC_ARG_MIB (T_CONNECTIONSTATE ),1 ); +if (ret) + goto out; +
Quoted 8 lines
drivers/scsi/ufs/ufshcd-dwc.c line 147
Quoted 3 lines
drivers/scsi/ufs/ufshcd-dwc.c new file +3
-0+out: +return ret; +}This looks a bit redundant. The most part of the functions in this file is doing
ufshcd_dme_set()orufshcd_dme_peer_set(), so should we introduceufshcd_dme_set_attrs()like below? It will also increase readability.
We can do that, it would make the function body lighter and more easy to read I agree with you!
Quoted 43 lines
struct ufshcd_dme_attr_val { u32 attr_sel; u32 mib_val; u8 peer; };int ufshcd_dme_set_attrs(struct
ufs_hba*hba,
const structufshcd_dme_attr_val*v, int n){ for (i = 0; i < n; i++) { int ret = ufshcd_dme_set_attr(hba, v[i].attr_sel, ...); if (ret) return ret; } return 0; }static int
ufshcd_dwc_connection_setup(struct ufs_hba *hba){ const struct ufshcd_dme_attr setup_attrs[] = { { UIC_ARG_MIB(T_CONNECTIONSTATE), 0, DME_LOCAL }, { UIC_ARG_MIB(T_DEVICEID), 0, DME_LOCAL }, ... }; return ufshcd_dme_set_attrs(hba, setup_attrs, ARRAY_SIZE(setup_attrs)); }drivers/scsi/ufs/ufshcd-dwc.c line 676
Quoted 9 lines
drivers/scsi/ufs/ufshcd-dwc.c new file +9
-0+static int ufshcd_dwc_setup_tc (struct ufs_hba *hba) +{ +int ret =0 ; + +#ifdef CONFIG_SCSI_UFS_DWC_40BIT_RMMI +dev_info (hba->dev,"Configuring Test Chip 40-bit RMMI" ); + ret =ufshcd_dwc_setup_40bit_rmmi (hba); +if (ret) { +dev_err (hba->dev,"Configuration failed" );Please add \n in the end of message.
(and there are same issues in this file)
Quoted 10 lines
drivers/scsi/ufs/ufshci-dwc.h line 32
Quoted 7 lines
drivers/scsi/ufs/ufshci-dwc.h new file +7
-0+ +/* Clock Divider Values: Hex equivalent of frequency in MHz */ +enum clk_div_values { +UFSHCD_CLK_DIV_62_5 =0x3e , +UFSHCD_CLK_DIV_125 =0x7d , +UFSHCD_CLK_DIV_200 =0xc8 , +};This is used as register value for
DWC_UFS_REG_HCLKDIV. So should they have similar prefix (DWC_UFS_REG_HCLKDIV_*)?
I agree with you, they should have since they are DWC specific.
Quoted 5 lines
Quoted 2 lines
drivers/scsi/ufs/unipro.h +0
-0...
Quoted 7 lines
drivers/scsi/ufs/unipro.h line 150
Quoted 4 lines
drivers/scsi/ufs/unipro.h +4
-0+/*Other attributes*/ +#define VS_MPHYCFGUPDT 0xD085 +#define VS_DEBUGOMC 0xD09E +#define VS_POWERSTATE 0xD083Are these vendor specific attributes? If so, please move them to
ufshci-dwc.h.
These are not DWC specific, that's why I added them to the common unipro.h
Quoted 1 line
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html