From: "Chanho Park" <chanho61.park@samsung.com>
To: "'Alim Akhtar'" <alim.akhtar@samsung.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
<linux-phy@lists.infradead.org>
Cc: <devicetree@vger.kernel.org>, <robh+dt@kernel.org>,
<krzysztof.kozlowski+dt@linaro.org>, <vkoul@kernel.org>,
<avri.altman@wdc.com>, <bvanassche@acm.org>,
<martin.petersen@oracle.com>, <pankaj.dubey@samsung.com>,
<linux-fsd@tesla.com>,
"'Bharat Uppal'" <bharat.uppal@samsung.com>
Subject: RE: [PATCH 5/6] ufs: host: ufs-exynos: add support for fsd ufs hci
Date: Tue, 31 May 2022 16:37:11 +0900 [thread overview]
Message-ID: <001101d874c1$3d850eb0$b88f2c10$@samsung.com> (raw)
In-Reply-To: <20220531012220.80563-6-alim.akhtar@samsung.com>
Hi,
> -----Original Message-----
> From: Alim Akhtar <alim.akhtar@samsung.com>
> Sent: Tuesday, May 31, 2022 10:22 AM
> To: linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
> linux-scsi@vger.kernel.org; linux-phy@lists.infradead.org
> Cc: devicetree@vger.kernel.org; robh+dt@kernel.org;
> krzysztof.kozlowski+dt@linaro.org; vkoul@kernel.org; avri.altman@wdc.com;
> bvanassche@acm.org; martin.petersen@oracle.com; chanho61.park@samsung.com;
> pankaj.dubey@samsung.com; Alim Akhtar <alim.akhtar@samsung.com>; linux-
> fsd@tesla.com; Bharat Uppal <bharat.uppal@samsung.com>
> Subject: [PATCH 5/6] ufs: host: ufs-exynos: add support for fsd ufs hci
>
> Adds support of UFS HCI which is found in Tesla FSD SoC. FSD also have an
> addition bit for MPHY APB clock which was not there (was reserved) for
> previous exynos SoC.
>
> Cc: linux-fsd@tesla.com
> Signed-off-by: Bharat Uppal <bharat.uppal@samsung.com>
> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
> ---
> drivers/ufs/host/ufs-exynos.c | 143 +++++++++++++++++++++++++++++++++-
> 1 file changed, 142 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index a81d8cbd542f..b3efdc4caca2 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -52,11 +52,12 @@
> #define HCI_ERR_EN_DME_LAYER 0x88
> #define HCI_CLKSTOP_CTRL 0xB0
> #define REFCLKOUT_STOP BIT(4)
> +#define MPHY_APBCLK_STOP BIT(3)
> #define REFCLK_STOP BIT(2)
> #define UNIPRO_MCLK_STOP BIT(1)
> #define UNIPRO_PCLK_STOP BIT(0)
> #define CLK_STOP_MASK (REFCLKOUT_STOP | REFCLK_STOP |\
> - UNIPRO_MCLK_STOP |\
> + UNIPRO_MCLK_STOP | MPHY_APBCLK_STOP|\
Please make this change into a separate patch of this series.
> UNIPRO_PCLK_STOP)
> #define HCI_MISC 0xB4
> #define REFCLK_CTRL_EN BIT(7)
> @@ -386,6 +387,104 @@ static int exynos7_ufs_post_pwr_change(struct
> exynos_ufs *ufs,
> return 0;
> }
>
> +static inline int fsd_ufs_pre_link(struct exynos_ufs *ufs) {
> + int i;
> + struct ufs_hba *hba = ufs->hba;
> +
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x9514), 1000000000L / ufs-
> >mclk_rate);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x201), 0x12);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x200), 0x40);
> +
> + for_each_ufs_tx_lane(ufs, i) {
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0xAA, i), 1000000000L /
> ufs->mclk_rate);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x8F, i), 0x3F);
> + }
> +
> + for_each_ufs_rx_lane(ufs, i) {
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x12, i), 1000000000L /
> ufs->mclk_rate);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x5C, i), 0x38);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x0F, i), 0x0);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x65, i), 0x1);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x69, i), 0x1);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x21, i), 0x0);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x22, i), 0x0);
> + }
> +
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x200), 0x0);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x9536), 0x4E20);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x9564), 0x2e820183);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x155E), 0x0);
Use PA_LOCAL_TX_LCC_ENABLE instead of 0x155E. I think you can find more values from unipro.h.
Please try to use as much as possible :)
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x3000), 0x0);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x3001), 0x1);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x4021), 0x1);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x4020), 0x1);
They can be set from exynos_ufs_establish_connt.
> +
> + return 0;
> +}
> +
> +static inline int fsd_ufs_post_link(struct exynos_ufs *ufs) {
> + int i;
> + struct ufs_hba *hba = ufs->hba;
> + u32 hw_cap_min_tactivate;
> + u32 peer_rx_min_actv_time_cap;
> + u32 max_rx_hibern8_time_cap;
> +
> + ufshcd_dme_get(hba, UIC_ARG_MIB_SEL(0x8F, 4),
> + &hw_cap_min_tactivate); /* HW Capability of
> MIN_TACTIVATE */
> + ufshcd_dme_get(hba, UIC_ARG_MIB(0x15A8),
> + &peer_rx_min_actv_time_cap); /* PA_TActivate */
> + ufshcd_dme_get(hba, UIC_ARG_MIB(0x15A7),
> + &max_rx_hibern8_time_cap); /* PA_Hibern8Time */
> +
> + if (peer_rx_min_actv_time_cap >= hw_cap_min_tactivate)
> + ufshcd_dme_peer_set(hba, UIC_ARG_MIB(0x15A8),
> + peer_rx_min_actv_time_cap + 1);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x15A7), max_rx_hibern8_time_cap +
> 1);
> +
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x9529), 0x01);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x15A4), 0xFA);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x9529), 0x00);
> +
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x200), 0x40);
> +
> + for_each_ufs_rx_lane(ufs, i) {
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x35, i), 0x05);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x73, i), 0x01);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x41, i), 0x02);
> + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x42, i), 0xAC);
> + }
> +
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x200), 0x0);
> +
> + return 0;
> +}
> +
> +static inline int fsd_ufs_pre_pwr_change(struct exynos_ufs *ufs,
> + struct ufs_pa_layer_attr *pwr)
> +{
> + struct ufs_hba *hba = ufs->hba;
> +
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x1569), 0x1);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x1584), 0x1);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x2041), 8064);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x2042), 28224);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x2043), 20160);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x15B0), 12000);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x15B1), 32000);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x15B2), 16000);
> +
> + unipro_writel(ufs, 8064, 0x7888);
> + unipro_writel(ufs, 28224, 0x788C);
> + unipro_writel(ufs, 20160, 0x7890);
> + unipro_writel(ufs, 12000, 0x78B8);
> + unipro_writel(ufs, 32000, 0x78BC);
> + unipro_writel(ufs, 16000, 0x78C0);
> +
> + return 0;
> +}
> +
> /*
> * exynos_ufs_auto_ctrl_hcc - HCI core clock control by h/w
> * Control should be disabled in the below cases @@ -1595,6 +1694,46 @@
> static struct exynos_ufs_drv_data exynos_ufs_drvs = {
> .post_pwr_change = exynos7_ufs_post_pwr_change,
> };
>
> +static struct exynos_ufs_uic_attr fsd_uic_attr = {
> + .tx_trailingclks = 0x10,
> + .tx_dif_p_nsec = 3000000, /* unit: ns */
> + .tx_dif_n_nsec = 1000000, /* unit: ns */
> + .tx_high_z_cnt_nsec = 20000, /* unit: ns */
> + .tx_base_unit_nsec = 100000, /* unit: ns */
> + .tx_gran_unit_nsec = 4000, /* unit: ns */
> + .tx_sleep_cnt = 1000, /* unit: ns */
> + .tx_min_activatetime = 0xa,
> + .rx_filler_enable = 0x2,
> + .rx_dif_p_nsec = 1000000, /* unit: ns */
> + .rx_hibern8_wait_nsec = 4000000, /* unit: ns */
> + .rx_base_unit_nsec = 100000, /* unit: ns */
> + .rx_gran_unit_nsec = 4000, /* unit: ns */
> + .rx_sleep_cnt = 1280, /* unit: ns */
> + .rx_stall_cnt = 320, /* unit: ns */
> + .rx_hs_g1_sync_len_cap = SYNC_LEN_COARSE(0xf),
> + .rx_hs_g2_sync_len_cap = SYNC_LEN_COARSE(0xf),
> + .rx_hs_g3_sync_len_cap = SYNC_LEN_COARSE(0xf),
> + .rx_hs_g1_prep_sync_len_cap = PREP_LEN(0xf),
> + .rx_hs_g2_prep_sync_len_cap = PREP_LEN(0xf),
> + .rx_hs_g3_prep_sync_len_cap = PREP_LEN(0xf),
> + .pa_dbg_option_suite = 0x2E820183,
> +};
> +
> +struct exynos_ufs_drv_data fsd_ufs_drvs = {
> + .uic_attr = &fsd_uic_attr,
> + .quirks = UFSHCD_QUIRK_PRDT_BYTE_GRAN |
> + UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR |
> + UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |
> + UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR,
> + .opts = EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL |
> + EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL |
> + EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
> + EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX,
> + .pre_link = fsd_ufs_pre_link,
> + .post_link = fsd_ufs_post_link,
> + .pre_pwr_change = fsd_ufs_pre_pwr_change,
> +};
> +
> static const struct of_device_id exynos_ufs_of_match[] = {
> { .compatible = "samsung,exynos7-ufs",
> .data = &exynos_ufs_drvs },
> @@ -1602,6 +1741,8 @@ static const struct of_device_id
> exynos_ufs_of_match[] = {
> .data = &exynosauto_ufs_drvs },
> { .compatible = "samsung,exynosautov9-ufs-vh",
> .data = &exynosauto_ufs_vh_drvs },
> + { .compatible = "tesla,fsd-ufs",
> + .data = &fsd_ufs_drvs },
> {},
> };
>
> --
> 2.25.1
next prev parent reply other threads:[~2022-05-31 7:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220531012331epcas5p23a835b3635e187ef04d4f28f0933f7c1@epcas5p2.samsung.com>
2022-05-31 1:22 ` [PATCH 0/6] Add support for UFS controller found in FSD SoC Alim Akhtar
[not found] ` <CGME20220531012336epcas5p2fcafe14c90ad3e3a0901fccd62d15437@epcas5p2.samsung.com>
2022-05-31 1:22 ` [PATCH 1/6] dt-bindings: phy: Add FSD UFS PHY bindings Alim Akhtar
2022-05-31 3:44 ` Bart Van Assche
2022-06-03 1:20 ` Alim Akhtar
2022-05-31 9:17 ` Krzysztof Kozlowski
2022-06-03 1:30 ` Alim Akhtar
[not found] ` <CGME20220531012341epcas5p19b15b4916b210687ab6b46d6da0b2273@epcas5p1.samsung.com>
2022-05-31 1:22 ` [PATCH 2/6] phy: samsung-ufs: move cdr offset to drvdata Alim Akhtar
2022-05-31 9:56 ` Krzysztof Kozlowski
2022-06-03 1:31 ` Alim Akhtar
2022-05-31 10:09 ` Krzysztof Kozlowski
[not found] ` <CGME20220531012347epcas5p48262cae18c75bb6ed029f7cd920800b4@epcas5p4.samsung.com>
2022-05-31 1:22 ` [PATCH 3/6] phy: samsung-ufs: add support for FSD ufs phy driver Alim Akhtar
2022-05-31 3:47 ` Bart Van Assche
2022-06-03 1:21 ` Alim Akhtar
[not found] ` <CGME20220531012351epcas5p389e28e28a48f9bb14a52fc81c417296d@epcas5p3.samsung.com>
2022-05-31 1:22 ` [PATCH 4/6] dt-bindings: ufs: exynos-ufs: add fsd compatible Alim Akhtar
2022-05-31 9:58 ` Krzysztof Kozlowski
[not found] ` <CGME20220531012356epcas5p3cd6638d4d3eccb28a28d064c9f585a4f@epcas5p3.samsung.com>
2022-05-31 1:22 ` [PATCH 5/6] ufs: host: ufs-exynos: add support for fsd ufs hci Alim Akhtar
2022-05-31 7:37 ` Chanho Park [this message]
2022-06-03 1:42 ` Alim Akhtar
2022-05-31 10:01 ` Krzysztof Kozlowski
[not found] ` <CGME20220531012400epcas5p1c30b75a928097bd19855dcd0d929ff10@epcas5p1.samsung.com>
2022-05-31 1:22 ` [PATCH 6/6] arm64: dts: fsd: add ufs device node Alim Akhtar
2022-05-31 10:09 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='001101d874c1$3d850eb0$b88f2c10$@samsung.com' \
--to=chanho61.park@samsung.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=bharat.uppal@samsung.com \
--cc=bvanassche@acm.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fsd@tesla.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=pankaj.dubey@samsung.com \
--cc=robh+dt@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).