From patchwork Fri Aug 21 09:27:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alim Akhtar X-Patchwork-Id: 7050761 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C2167C05AC for ; Fri, 21 Aug 2015 09:38:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8B35205F4 for ; Fri, 21 Aug 2015 09:38:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC2EC202FE for ; Fri, 21 Aug 2015 09:38:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753797AbbHUJiI (ORCPT ); Fri, 21 Aug 2015 05:38:08 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:34078 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753788AbbHUJiG (ORCPT ); Fri, 21 Aug 2015 05:38:06 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NTF032ATERF2930@mailout1.samsung.com>; Fri, 21 Aug 2015 18:38:03 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.122]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id E8.C3.20564.B71F6D55; Fri, 21 Aug 2015 18:38:03 +0900 (KST) X-AuditID: cbfee690-f796f6d000005054-2f-55d6f17b28b5 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 5A.FA.07062.B71F6D55; Fri, 21 Aug 2015 18:38:03 +0900 (KST) Received: from exypnos.sisodomain.com ([107.108.73.28]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NTF008WKEOTM680@mmp1.samsung.com>; Fri, 21 Aug 2015 18:38:03 +0900 (KST) From: Alim Akhtar To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vinholikatti@gmail.com, JBottomley@odin.com, Seungwon Jeon Subject: [PATCH 05/10] scsi: ufs: add quirk to enable host controller without hce Date: Fri, 21 Aug 2015 14:57:56 +0530 Message-id: <1440149281-26336-6-git-send-email-alim.akhtar@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1440149281-26336-1-git-send-email-alim.akhtar@samsung.com> References: <1440149281-26336-1-git-send-email-alim.akhtar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRmVeSWpSXmKPExsWyRsSkSrf647VQg49zxC3+r7/NYnF51xw2 i+7rO9gsPty/yGyxY2GVA6vHzll32T0O//jB7NG3ZRWjx+dNcgEsUVw2Kak5mWWpRfp2CVwZ L/oOMxa8ka34+OQKcwNjp0QXIyeHhICJRP+HA0wQtpjEhXvr2boYuTiEBFYwShz718IMU/R5 5UmoxFJGibUzjjNBOD8ZJd786mMDqWIT0Ja4O30L2CgRARuJ8zcfgNnMAuES1zbMZgexhQWC JT7/XcYIYrMIqEo0tNwG6+UVcJe4tfo7C8Q2RYnuZxPA4pwCHhJ3m+aBxYWAai5fPsYKslhC 4D+bxNeuDqhBAhLfJh8CKuIASshKbDoAdbWkxMEVN1gmMAovYGRYxSiaWpBcUJyUXmSiV5yY W1yal66XnJ+7iREYyKf/PZuwg/HeAetDjAIcjEo8vDMjr4UKsSaWFVfmHmI0BdowkVlKNDkf GC95JfGGxmZGFqYmpsZG5pZmSuK8r6V+BgsJpCeWpGanphakFsUXleakFh9iZOLglGpgjF3x a5sTc5FG3P487dnH3Jb8NTXUOzZtk2Vk8I9LJ1XXiNnMrZzWsjpnS4Ht2UsRSx99FZJP53eN FnNu5Ot0OvdcefOls78d9uVWbv7T87HG0O4d86Yv/mtFNi6av7Er0mqagcWWxIkLv0Zzey5a e1GvfPp3k+VBM+88fLjnlut0zfiyG7KxKUosxRmJhlrMRcWJAORtlbZfAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsVy+t9jAd3qj9dCDa4f5bT4v/42i8XlXXPY LLqv72Cz+HD/IrPFjoVVDqweO2fdZfc4/OMHs0ffllWMHp83yQWwRDUw2mSkJqakFimk5iXn p2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYA7VVSKEvMKQUKBSQWFyvp22Ga EBripmsB0xih6xsSBNdjZIAGEtYwZrzoO8xY8Ea24uOTK8wNjJ0SXYycHBICJhKfV55kg7DF JC7cWw9kc3EICSxllFg74zgThPOTUeLNrz6wKjYBbYm707cwgdgiAjYS528+ALOZBcIlrm2Y zQ5iCwsES3z+u4wRxGYRUJVoaLkN1ssr4C5xa/V3FohtihLdzyaAxTkFPCTuNs0DiwsB1Vy+ fIx1AiPvAkaGVYwSqQXJBcVJ6blGeanlesWJucWleel6yfm5mxjB0fJMegfj4V3uhxgFOBiV eHhnRF4LFWJNLCuuzD3EKMHBrCTCa/0CKMSbklhZlVqUH19UmpNafIjRFOiwicxSosn5wEjO K4k3NDYxNzU2tTSxMDGzVBLn1TfZFCokkJ5YkpqdmlqQWgTTx8TBKdXAOOfOMqnVYgc0vT6f mGi8u83oTPakV328RfNuvFt66WLSWoHnEuLy6/8W80rU3PK021WvnFxrrnNrZaKMxTmDD0JM Bh37jZRD9HeKvZi/q5enVFej7V2fQkX1ItFPC84/4pDb8c5iQvgWw7UO351FK83+vF/5MOjZ vxvVHGJzzMK4ssu6ZdWYlFiKMxINtZiLihMBMpDsU6wCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Seungwon Jeon Some host controller doesn't support host controller enable via HCE. Signed-off-by: Seungwon Jeon Signed-off-by: Alim Akhtar --- drivers/scsi/ufs/ufshcd.c | 76 +++++++++++++++++++++++++++++++++++++++++++-- drivers/scsi/ufs/ufshcd.h | 5 +++ 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 35380aa..bb143ac 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2106,6 +2106,52 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba) "dme-link-startup: error code %d\n", ret); return ret; } +/** + * ufshcd_dme_reset - UIC command for DME_RESET + * @hba: per adapter instance + * + * DME_RESET command is issued in order to reset UniPro stack. + * This function now deal with cold reset. + * + * Returns 0 on success, non-zero value on failure + */ +static int ufshcd_dme_reset(struct ufs_hba *hba) +{ + struct uic_command uic_cmd = {0}; + int ret; + + uic_cmd.command = UIC_CMD_DME_RESET; + + ret = ufshcd_send_uic_cmd(hba, &uic_cmd); + if (ret) + dev_err(hba->dev, + "dme-reset: error code %d\n", ret); + + return ret; +} + +/** + * ufshcd_dme_enable - UIC command for DME_ENABLE + * @hba: per adapter instance + * + * DME_ENABLE command is issued in order to enable UniPro stack. + * + * Returns 0 on success, non-zero value on failure + */ +static int ufshcd_dme_enable(struct ufs_hba *hba) +{ + struct uic_command uic_cmd = {0}; + int ret; + + uic_cmd.command = UIC_CMD_DME_ENABLE; + + ret = ufshcd_send_uic_cmd(hba, &uic_cmd); + if (ret) + dev_err(hba->dev, + "dme-reset: error code %d\n", ret); + + return ret; +} static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba) { @@ -2642,7 +2688,7 @@ out: } /** - * ufshcd_hba_enable - initialize the controller + * ufshcd_hba_execute_hce - initialize the controller * @hba: per adapter instance * * The controller resets itself and controller firmware initialization @@ -2651,7 +2697,7 @@ out: * * Returns 0 on success, non-zero value on failure */ -static int ufshcd_hba_enable(struct ufs_hba *hba) +static int ufshcd_hba_execute_hce(struct ufs_hba *hba) { int retry; @@ -2717,6 +2763,32 @@ static int ufshcd_hba_enable(struct ufs_hba *hba) return 0; } +static int ufshcd_hba_enable(struct ufs_hba *hba) +{ + int ret; + + if (hba->quirks & UFSHCI_QUIRK_BROKEN_HCE) { + ufshcd_set_link_off(hba); + if (hba->vops && hba->vops->hce_enable_notify) + hba->vops->hce_enable_notify(hba, PRE_CHANGE); + + /* enable UIC related interrupts */ + ufshcd_enable_intr(hba, UFSHCD_UIC_MASK); + ret = ufshcd_dme_reset(hba); + if (!ret) { + ret = ufshcd_dme_enable(hba); + if (!ret && hba->vops && hba->vops->hce_enable_notify) + hba->vops->hce_enable_notify(hba, POST_CHANGE); + if (ret) + dev_err(hba->dev, + "Host controller enable failed with non-hce\n"); + } + } else { + ret = ufshcd_hba_execute_hce(hba); + } + + return ret; +} static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer) { int tx_lanes, i, err = 0; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 7986a54..f4ad3df 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -477,6 +477,11 @@ struct ufs_hba { */ #define UFSHCI_QUIRK_BROKEN_RESET_INTR_AGGR UFS_BIT(8) + /* + * This quirks needs to be enabled if host controller cannot be + * enabled via HCE register. + */ + #define UFSHCI_QUIRK_BROKEN_HCE UFS_BIT(9) unsigned int quirks; /* Deviations from standard UFSHCI spec. */ wait_queue_head_t tm_wq;