Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp254134pxa; Tue, 4 Aug 2020 23:36:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7+4GCbLqGFEOZ/quxii839sbDVkn4i9vPMGfIpe5H0p7+h27eF6oiiMUWpm4HG+ov7wfX X-Received: by 2002:a17:906:a84f:: with SMTP id dx15mr1563677ejb.377.1596609390840; Tue, 04 Aug 2020 23:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596609390; cv=none; d=google.com; s=arc-20160816; b=WNJklZoqUL3NcQZKcUx6fnOgOKHcFcN675Uksd4NIY/vl5fr8QQt84T/oo7+JI6490 Z7cygLLpKGRBxWP3RlY9kHa0h3MNMi8svSL2hbT3BRFTRSU6mRUGhW57QSrPZJXVN16h T/YRSNBxmm/zMkRQyl3msVrw5Mj+6aSaY0znfiFDkPAlzR8VMWKEdG3+KsGkZjRcUy1s oFHnsreGH3bTAc1rreH24aDXz9AmXpz/+J4nkSxohMlxI2Ry4X3hEwgEAHqwHaaVhgdd m86o4KvgZWpoSauAUAKsEi9lP1k/2XoPYuG6N+TkeLU3lwsbpiTADYvma2LMtXsCfHkb OsXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=X4ywlhldW4kDh3ZXxXvvyOrk6REe2o9rXP8i4tyEpJw=; b=i2ccUeuM0gShzgoCkySLg/JEU3yTInUoQl5toc+oe/JEntyf37aVmB8yts7rvYMxpb 5XSOW6tWutJ2zTv/adwx0p6d2D2AiEQPOAmewxyF+Fxl5DwRfkdCxDp/YqbZSnXP6Voc yv68DXSarD964reXbiTtGhpI+XTcRf9rPl+T292pRJ0Yv2Ml+WZn+p5yEBsvAz/BwsLa xEBqKku4EiDvIc5iskY7TVZ19kgwP9xk3TdRaOzvAlDh4V7w2cC9Iy6N4uFDVfRTzMoW bwY1sorzMcw+TCZhNzTdiJVzbB4Pn9IsZHg+m/Enrmzok6Zr7o0kilNPyCq4v6qDPiTC 6c9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=matpPN0T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si705982edr.11.2020.08.04.23.36.07; Tue, 04 Aug 2020 23:36:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=matpPN0T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728226AbgHEGfO (ORCPT + 99 others); Wed, 5 Aug 2020 02:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728064AbgHEGfN (ORCPT ); Wed, 5 Aug 2020 02:35:13 -0400 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6C2BC061756 for ; Tue, 4 Aug 2020 23:35:13 -0700 (PDT) Received: by mail-ua1-x944.google.com with SMTP id p27so9301973uaa.12 for ; Tue, 04 Aug 2020 23:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X4ywlhldW4kDh3ZXxXvvyOrk6REe2o9rXP8i4tyEpJw=; b=matpPN0TvrSyWoHIgom7iF9rqu/oVnIrSLCgFiaUjeB4QnF3CuXrNVs1WaP9ZsbU7q kh1mpN/x8nla/KPuWLFlYe7sjlT7wS5h03142IlJ4Cz539vrWRTT9rEqiGaRfqMGXXsG HW7xmUrlFdn5z5ZLV8zQYJpeIbd3mh7Z6U9Nsi6EPHyhpyHnPw1Q6qSrtrZkPV5IuZiA faYkJGRUa0yHV+qvxuEU6demhT4BBfxbZF1Tv8jiDbr6SSHxyetXdBbGiMHVQlNcaWma +DOFoLmiiWgtzUfUWFZznjDRyelYyxEIh8H//LI443lVOd4ya9v8D+4N8luP1fl2YfWa gwpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X4ywlhldW4kDh3ZXxXvvyOrk6REe2o9rXP8i4tyEpJw=; b=P/KpHWsvyT7ggu4AEw6gXj08aapyk2imwD9kFrXGFK7Y785r3EcbkW9SlQ++dT/7B0 w/grNCNKtz9pi/25c9cafoppEDlIhdgkdllkkGyHt6bM8WwhqAEGb7C7kw5XfRfyoGNw LlREYJ4XgWMca1chSQHitIqAy08MNB9LD5//8I6NoKCpFUsf/KZFK5ceSftvsy0jKGTP utmejPaTdf8g3vqN3tUofgndRYu0MrirIS/oo7iroM+L9FMS0fuZ32Lz2VwpFvKx3+on UHrQ0i1mIuwDlKlpsCY5jGkfH/1cuE7zWT/zcyvhdIf+qpgcXDSpEFcC1XOkkbBReZZP 85vw== X-Gm-Message-State: AOAM531VZg0biKWLiCEnim5VeQeoya2BFqV9tHIEvAnudq7R2Oacwhct 7Nzgc/XIIzJUEsiONlTaJAO+dhhBfNc66HD0ulVotQ== X-Received: by 2002:ab0:3114:: with SMTP id e20mr1041212ual.104.1596609312762; Tue, 04 Aug 2020 23:35:12 -0700 (PDT) MIME-Version: 1.0 References: <20200721012700.8564-1-shirley.her@bayhubtech.com> In-Reply-To: <20200721012700.8564-1-shirley.her@bayhubtech.com> From: Ulf Hansson Date: Wed, 5 Aug 2020 08:34:35 +0200 Message-ID: Subject: Re: [PATCH V1 2/2] mmc: sdhci-pci-o2micro: Add HW tuning for SDR104 mode To: shirley her Cc: Adrian Hunter , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List , "Shaper Liu (WH)" , "Chevron Li (WH)" , "Xiaoguang Yu (WH)" , "Max Huang (SC)" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 Jul 2020 at 03:29, shirley her wrote: > > Add HW tuning support for SD host controller in SDR104 mode > > Signed-off-by: Shirley Her Applied for next (a while ago), thanks! Kind regards Uffe > --- > Change in V1: > 1. Add HW tuning for SDR104 mode instead of SW tuning > 2. Change clock base to 208Mhz in SDR104 mode > 3. Add CMD and DATA line reset after HW tuning command > --- > drivers/mmc/host/sdhci-pci-o2micro.c | 33 ++++++++++++++++++++++++---- > 1 file changed, 29 insertions(+), 4 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c > index ed3c605fcf0c..fa76748d8929 100644 > --- a/drivers/mmc/host/sdhci-pci-o2micro.c > +++ b/drivers/mmc/host/sdhci-pci-o2micro.c > @@ -196,7 +196,7 @@ static void __sdhci_o2_execute_tuning(struct sdhci_host *host, u32 opcode) > { > int i; > > - sdhci_send_tuning(host, MMC_SEND_TUNING_BLOCK_HS200); > + sdhci_send_tuning(host, opcode); > > for (i = 0; i < 150; i++) { > u16 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); > @@ -305,10 +305,12 @@ static int sdhci_o2_execute_tuning(struct mmc_host *mmc, u32 opcode) > * This handler only implements the eMMC tuning that is specific to > * this controller. Fall back to the standard method for other TIMING. > */ > - if (host->timing != MMC_TIMING_MMC_HS200) > + if ((host->timing != MMC_TIMING_MMC_HS200) && > + (host->timing != MMC_TIMING_UHS_SDR104)) > return sdhci_execute_tuning(mmc, opcode); > > - if (WARN_ON(opcode != MMC_SEND_TUNING_BLOCK_HS200)) > + if (WARN_ON((opcode != MMC_SEND_TUNING_BLOCK_HS200) && > + (opcode != MMC_SEND_TUNING_BLOCK))) > return -EINVAL; > /* > * Judge the tuning reason, whether caused by dll shift > @@ -342,6 +344,9 @@ static int sdhci_o2_execute_tuning(struct mmc_host *mmc, u32 opcode) > sdhci_set_bus_width(host, current_bus_width); > } > > + sdhci_reset(host, SDHCI_RESET_CMD); > + sdhci_reset(host, SDHCI_RESET_DATA); > + > host->flags &= ~SDHCI_HS400_TUNING; > return 0; > } > @@ -369,7 +374,6 @@ static void o2_pci_led_enable(struct sdhci_pci_chip *chip) > scratch_32 |= O2_SD_LED_ENABLE; > pci_write_config_dword(chip->pdev, > O2_SD_TEST_REG, scratch_32); > - > } > > static void sdhci_pci_o2_fujin2_pci_init(struct sdhci_pci_chip *chip) > @@ -497,6 +501,10 @@ static void sdhci_o2_enable_clk(struct sdhci_host *host, u16 clk) > static void sdhci_pci_o2_set_clock(struct sdhci_host *host, unsigned int clock) > { > u16 clk; > + u8 scratch; > + u32 scratch_32; > + struct sdhci_pci_slot *slot = sdhci_priv(host); > + struct sdhci_pci_chip *chip = slot->chip; > > host->mmc->actual_clock = 0; > > @@ -505,6 +513,23 @@ static void sdhci_pci_o2_set_clock(struct sdhci_host *host, unsigned int clock) > if (clock == 0) > return; > > + if ((host->timing == MMC_TIMING_UHS_SDR104) && (clock == 200000000)) { > + pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); > + > + scratch &= 0x7f; > + pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > + > + pci_read_config_dword(chip->pdev, O2_SD_PLL_SETTING, &scratch_32); > + > + if ((scratch_32 & 0xFFFF0000) != 0x2c280000) > + o2_pci_set_baseclk(chip, 0x2c280000); > + > + pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); > + > + scratch |= 0x80; > + pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > + } > + > clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock); > sdhci_o2_enable_clk(host, clk); > } > -- > 2.25.1 >