From patchwork Tue Nov 8 08:00:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 9416827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20CDE6022E for ; Tue, 8 Nov 2016 08:00:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 125E528AF7 for ; Tue, 8 Nov 2016 08:00:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0735A28B44; Tue, 8 Nov 2016 08:00:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48D5328AF7 for ; Tue, 8 Nov 2016 08:00:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752798AbcKHIAm convert rfc822-to-8bit (ORCPT ); Tue, 8 Nov 2016 03:00:42 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:57288 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752315AbcKHIAm (ORCPT ); Tue, 8 Nov 2016 03:00:42 -0500 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGB01D86CX07980@mailout3.samsung.com> for linux-scsi@vger.kernel.org; Tue, 08 Nov 2016 17:00:40 +0900 (KST) X-AuditID: cbfee61a-f79916d0000062de-cc-58218628454b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id D5.C5.25310.82681285; Tue, 8 Nov 2016 17:00:40 +0900 (KST) Received: from DOKWMADKIM02 ([12.36.166.218]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGB0023KCX4P680@mmp1.samsung.com>; Tue, 08 Nov 2016 17:00:40 +0900 (KST) From: Kiwoong Kim To: "James E.J. Bottomley" , linux-scsi@vger.kernel.org, "Martin K. Petersen" , vinholikatti@gmail.com Cc: =?UTF-8?B?7LaU7ZeM6rSR?= Subject: [PATCH v1] ufs: add a variety of definitions decribed in UFS spec Date: Tue, 08 Nov 2016 17:00:40 +0900 Message-id: <002501d23996$327bfdb0$9773f910$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8BIT X-Mailer: Microsoft Outlook 15.0 Thread-index: AdI5litiqeuVuDeTRbKWGISXeqlqJQ== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRmVeSWpSXmKPExsVy+t9jAV2NNsUIg28b+C1mX2hitFg1Mc+i +/oONovlx/8xWexYWOXA6rFz1l12jweHNrN4fHx6i8Wjb8sqRo/Pm+QCWKPcbDJSE1NSixRS 85LzUzLz0m2VQkPcdC2UFPISc1NtlSJ0fUOClBTKEnNKgTwjAzTg4BzgHqykb5fglnFn/hyW gplqFT0/3jM3MHYrdDFyckgImEhc2zGJCcIWk7hwbz1bFyMXh5DAUkaJpSdmMEM47xklzsxY xgpSxSagKfH05lQmkISIwHxGiUU7drKAJJgFDCU23J/MCGILC3hJbN5wGMxmEVCVuP3jCNgK XgFLiT97G9kgbEGJH5PvQfWqS0yat4gZwtaWePLuAivESQoSuz8dBbNFBPQkXq3awghRIyKx 78U7xgmMArOQjJqFZNQsJKNmIWlZwMiyilEitSC5oDgpPdcwL7Vcrzgxt7g0L10vOT93EyM4 zp5J7WA8uMv9EKMAB6MSD2+HjGKEEGtiWXFl7iFGCQ5mJRFe7mqgEG9KYmVValF+fFFpTmrx IUZToGcnMkuJJucDU0BeSbyhibmJubGBhbmlpYmRkjhv4+xn4UIC6YklqdmpqQWpRTB9TByc Ug2MgvJ2XKZ83bLzt2g96nX3Lwk41PI98ufjC3/Xzl93W3Pu7w+FHRGCjyc+EQo5fPlS9Y70 uLs+XCeOugR0eB93fPispuK3V77arpxZ3HmpUZILPHSe+hkVzRC4tNBiv5f5zPLzDzLVDew3 O9xZlavX0WrPaLXniphTx/O9wUy35jzwmJeX+ZVdiaU4I9FQi7moOBEAl5Lus8kCAAA= X-MTR: 20000000000000000@CPGS Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These things are defined to be used by some UFS Host controllers. Signed-off-by: Kiwoong Kim --- drivers/scsi/ufs/mphy.h | 38 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshci.h | 14 +++++++++++--- drivers/scsi/ufs/unipro.h | 24 ++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 drivers/scsi/ufs/mphy.h diff --git a/drivers/scsi/ufs/mphy.h b/drivers/scsi/ufs/mphy.h new file mode 100644 index 0000000..c431f49 --- /dev/null +++ b/drivers/scsi/ufs/mphy.h @@ -0,0 +1,38 @@ +/* + * drivers/scsi/ufs/mphy.h + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef _MPHY_H_ +#define _MPHY_H_ + +#define TX_HIBERN8TIME_CAP 0x0f +#define TX_MIN_ACTIVATE_TIME 0x33 + +#define RX_HS_G1_SYNC_LEN_CAP 0x8b +#define RX_HS_G1_PREP_LEN_CAP 0x8c +#define RX_HS_G2_SYNC_LEN_CAP 0x94 +#define RX_HS_G3_SYNC_LEN_CAP 0x95 +#define RX_HS_G2_PREP_LEN_CAP 0x96 +#define RX_HS_G3_PREP_LEN_CAP 0x97 + #define SYNC_RANGE_FINE (0 << 6) + #define SYNC_RANGE_COARSE (1 << 6) + #define SYNC_LEN(x) ((x) & 0x3f) + #define PREP_LEN(x) ((x) & 0xf) +#define RX_ADV_GRANULARITY_CAP 0x98 + #define RX_ADV_GRAN_STEP(x) ((((x) & 0x3) << 1) | 0x1) +#define TX_ADV_GRANULARITY_CAP 0x10 + #define TX_ADV_GRAN_STEP(x) ((((x) & 0x3) << 1) | 0x1) +#define RX_MIN_ACTIVATETIME_CAP 0x8f +#define RX_HIBERN8TIME_CAP 0x92 +#define RX_ADV_HIBERN8TIME_CAP 0x99 +#define RX_ADV_MIN_ACTIVATETIME_CAP 0x9a + +#endif /* _MPHY_H_ */ + diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h index 9599741..26dc340 100644 --- a/drivers/scsi/ufs/ufshci.h +++ b/drivers/scsi/ufs/ufshci.h @@ -170,17 +170,25 @@ enum { /* UECDL - Host UIC Error Code Data Link Layer 3Ch */ #define UIC_DATA_LINK_LAYER_ERROR UFS_BIT(31) #define UIC_DATA_LINK_LAYER_ERROR_CODE_MASK 0x7FFF -#define UIC_DATA_LINK_LAYER_ERROR_PA_INIT 0x2000 -#define UIC_DATA_LINK_LAYER_ERROR_NAC_RECEIVED 0x0001 -#define UIC_DATA_LINK_LAYER_ERROR_TCx_REPLAY_TIMEOUT 0x0002 +#define UIC_DATA_LINK_LAYER_ERROR_NAC_RECEIVED UFS_BIT(0) +#define UIC_DATA_LINK_LAYER_ERROR_TCx_REPLAY_TIMEOUT UFS_BIT(1) +#define UIC_DATA_LINK_LAYER_ERROR_RX_BUF_OF UFS_BIT(5) +#define UIC_DATA_LINK_LAYER_ERROR_PA_INIT UFS_BIT(13) /* UECN - Host UIC Error Code Network Layer 40h */ #define UIC_NETWORK_LAYER_ERROR UFS_BIT(31) #define UIC_NETWORK_LAYER_ERROR_CODE_MASK 0x7 +#define UIC_NETWORK_UNSUPPORTED_HEADER_TYPE BIT(0) +#define UIC_NETWORK_BAD_DEVICEID_ENC BIT(1) +#define UIC_NETWORK_LHDR_TRAP_PACKET_DROPPING BIT(2) /* UECT - Host UIC Error Code Transport Layer 44h */ #define UIC_TRANSPORT_LAYER_ERROR UFS_BIT(31) #define UIC_TRANSPORT_LAYER_ERROR_CODE_MASK 0x7F +#define UIC_TRANSPORT_UNSUPPORTED_HEADER_TYPE BIT(0) +#define UIC_TRANSPORT_UNKNOWN_CPORTID BIT(1) +#define UIC_TRANSPORT_NO_CONNECTION_RX BIT(2) +#define UIC_TRANSPORT_BAD_TC BIT(4) /* UECDME - Host UIC Error Code DME 48h */ #define UIC_DME_ERROR UFS_BIT(31) diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h index eff8b56..e47e2c2 100644 --- a/drivers/scsi/ufs/unipro.h +++ b/drivers/scsi/ufs/unipro.h @@ -127,6 +127,7 @@ #define PA_PACPREQEOBTIMEOUT 0x1591 #define PA_HIBERN8TIME 0x15A7 #define PA_LOCALVERINFO 0x15A9 +#define PA_GRANULARITY 0x15AA #define PA_TACTIVATE 0x15A8 #define PA_PACPFRAMECOUNT 0x15C0 #define PA_PACPERRORCOUNT 0x15C1 @@ -170,6 +171,9 @@ enum { UNCHANGED = 7, }; +#define IS_PWR_MODE_HS(m) (((m) == FAST_MODE) || ((m) == FASTAUTO_MODE)) +#define IS_PWR_MODE_PWM(m) (((m) == SLOW_MODE) || ((m) == SLOWAUTO_MODE)) + /* PA TX/RX Frequency Series */ enum { PA_HS_MODE_A = 1, @@ -231,6 +235,11 @@ enum ufs_unipro_ver { #define DL_PEERTC1PRESENT 0x2066 #define DL_PEERTC1RXINITCREVAL 0x2067 +/* Default value of L2 Timer */ +#define FC0PROTTIMEOUTVAL 8191 +#define TC0REPLAYTIMEOUTVAL 65535 +#define AFC0REQTIMEOUTVAL 32767 + /* * Network Layer Attributes */ @@ -259,6 +268,21 @@ enum ufs_unipro_ver { #define T_TC0TXMAXSDUSIZE 0x4060 #define T_TC1TXMAXSDUSIZE 0x4061 +/* CPort setting */ +#define E2EFC_ON (1 << 0) +#define E2EFC_OFF (0 << 0) +#define CSD_N_ON (0 << 1) +#define CSD_N_OFF (1 << 1) +#define CSV_N_ON (0 << 2) +#define CSV_N_OFF (1 << 2) +#define CPORT_DEF_FLAGS (CSV_N_OFF | CSD_N_OFF | E2EFC_OFF) + +/* CPort connection state */ +enum { + CPORT_IDLE = 0, + CPORT_CONNECTED, +}; + #ifdef FALSE #undef FALSE #endif