Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp481666ybe; Wed, 4 Sep 2019 02:55:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwd2jpC4clRloO9mr8lLTQxt3EhN8Wlr2GyK3SsfSP+e1dMFzvk6/e/9uSsiMDogXYO8xqE X-Received: by 2002:a63:f401:: with SMTP id g1mr35683832pgi.314.1567590956669; Wed, 04 Sep 2019 02:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567590956; cv=none; d=google.com; s=arc-20160816; b=bUskLUPbCpsr2ECdmeva9S2xIMLTIgtz+9Hnb/0P2qq1rBaXuCbW3XjfqNP1alVOrM bv8hJA7fvuuLDNpOxSf6awC0r7DtTN5i+716QGyVdgvTyO+1Ct4jUpOBeOi/b5P54XUd pQfNnpxkohkltvFydFk+jr6VkorTOZMEzx57/F8mgZCjEupDtCJAhYDEz5y1YSJyYgAu YYdt2byrjK6HqomD9ju+6/4OzXVjgpipcfluiElurhvr4YTDROIk1fvVMIYsIJvLug+L 8sHndJCkVB+zQ92zwF7vTQlsBJYEAWItVXI0ekXdXinfVaPAicoW/2wElx/U7Sy+AjYL Lm4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=+PELp8mCFOpnb9jq5QF59BEE9SRRIAvun4gI/eErXn0=; b=rFWSBq4scJfDta4fGbIp/eS6IsaHZLj4XY1JbFLPLrhOk57nGs81keHk4EbkNCIjNm CVYPaZKoes2eHjnHo0r8cgQfjdCgTkITSLsABKxs/0ZmEv7bsTAxL/KJO/Pm+JYzCPKK 7eWqkgmPbDQEVuc0DM9d699LqIYTngPDFAgvYLG8g/rHj0kAKze5gJ11TwYcj8+/ngEm TI3r0yriVuSR0hnIQTs8MvojoyGrDxdCMXyYTYM9Cb3rbBz3pnasgQ6PSVvG6iVhxBeh E/P6RozScGpNVBbhFrOsnuLXrYzbLHEoMIQCreBNmMJwwItj+pkNFABayTyYfwVr9VLU UYUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si15807085pfr.263.2019.09.04.02.55.41; Wed, 04 Sep 2019 02:55:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729821AbfIDJyX (ORCPT + 99 others); Wed, 4 Sep 2019 05:54:23 -0400 Received: from mga17.intel.com ([192.55.52.151]:13365 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729045AbfIDJyX (ORCPT ); Wed, 4 Sep 2019 05:54:23 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 02:54:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,465,1559545200"; d="scan'208";a="198989002" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.66]) ([10.237.72.66]) by fmsmga001.fm.intel.com with ESMTP; 04 Sep 2019 02:54:20 -0700 Subject: Re: [PATCH V7 5/5] mmc: host: sdhci-pci: Add Genesys Logic GL975x support To: Ben Chuang , Andy Shevchenko Cc: Ulf Hansson , linux-mmc , Linux Kernel Mailing List , "Michael K. Johnson" , Ben Chuang References: <20190830022542.8571-1-benchuanggli@gmail.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Wed, 4 Sep 2019 12:53:12 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/09/19 3:58 AM, Ben Chuang wrote: > On Tue, Sep 3, 2019 at 6:05 AM Andy Shevchenko > wrote: >> >> On Fri, Aug 30, 2019 at 5:28 AM Ben Chuang wrote: >>> >>> From: Ben Chuang >>> >>> Add support for the GL9750 and GL9755 chipsets. >>> >>> Enable v4 mode and wait 5ms after set 1.8V signal enable for GL9750/ >>> GL9755. Fix the value of SDHCI_MAX_CURRENT register and use the vendor >>> tuning flow for GL9750. >>> >> >>> Signed-off-by: Ben Chuang >> >> Usually last one for latest developer / submitter goes on. >> >>> Co-developed-by: Michael K Johnson >>> Signed-off-by: Michael K Johnson >> >> >>> +#define GLI_MAX_TUNING_LOOP 40 >> >> >>> +static void gli_set_9750(struct sdhci_host *host) >>> +{ >>> + u32 driving_value = 0; >>> + u32 pll_value = 0; >>> + u32 sw_ctrl_value = 0; >>> + u32 misc_value = 0; >>> + u32 parameter_value = 0; >>> + u32 control_value = 0; >> >>> + >> >> Redundant blank line. >> >>> + u16 ctrl2 = 0; >> >> Do you need these all assignments above? >> >>> + driving_value = sdhci_readl(host, SDHCI_GLI_9750_DRIVING); >>> + pll_value = sdhci_readl(host, SDHCI_GLI_9750_PLL); >>> + sw_ctrl_value = sdhci_readl(host, SDHCI_GLI_9750_SW_CTRL); >>> + misc_value = sdhci_readl(host, SDHCI_GLI_9750_MISC); >>> + parameter_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_PARAMETERS); >>> + control_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_CONTROL); >> >> >> >>> + >>> + udelay(1); >> >> This misses the answer to question why. Why this is needed and why >> timeout is this long? >> >>> + >>> + gl9750_wt_off(host); >>> +} >> >>> +static int __sdhci_execute_tuning_9750(struct sdhci_host *host, u32 opcode) >>> +{ >>> + int i; >> >>> + int rx_inv = 0; >> >> Duplicate assignment. >> >>> + >>> + for (rx_inv = 0; rx_inv < 2; rx_inv++) { >> >>> + if (rx_inv & 0x1) >>> + gli_set_9750_rx_inv(host, true); >>> + else >>> + gli_set_9750_rx_inv(host, false); >> >> gli_set_...(host, !!rx_inv); >> >>> + >>> + sdhci_start_tuning(host); >>> + >>> + for (i = 0; i < GLI_MAX_TUNING_LOOP; i++) { >>> + u16 ctrl; >>> + >>> + sdhci_send_tuning(host, opcode); >>> + >>> + if (!host->tuning_done) { >> >>> + if (rx_inv == 1) { >> >> It's an invariant to the loop. So, you may do this check after outter loop. >> >>> + pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n", >>> + mmc_hostname(host->mmc)); >> >>> + sdhci_abort_tuning(host, opcode); >> >> It will also de-duplicates this call. >> >>> + return -ETIMEDOUT; >>> + } >>> + sdhci_abort_tuning(host, opcode); >>> + break; >>> + } >> >>> + } >>> + } >>> + >>> + pr_info("%s: Tuning failed, falling back to fixed sampling clock\n", >>> + mmc_hostname(host->mmc)); >>> + sdhci_reset_tuning(host); >>> + return -EAGAIN; >>> +} >> >>> +static void sdhci_gli_voltage_switch(struct sdhci_host *host) >>> +{ >> >> Any comment why? >> >>> + usleep_range(5000, 5500); >>> +} >> >>> +static u32 sdhci_gl9750_readl(struct sdhci_host *host, int reg) >>> +{ >>> + u32 value; >>> + >>> + value = readl(host->ioaddr + reg); >> >>> + if (unlikely(reg == SDHCI_MAX_CURRENT)) { >>> + if (!(value & 0xff)) >>> + value |= 0xc8; >>> + } >> >> if (a) { >> if (b) { >> ... >> } >> } >> >> is the same as >> >> if (a && b) { >> ... >> } >> >>> + return value; >>> +} >> >>> +#define PCI_DEVICE_ID_GLI_9755 0x9755 >>> +#define PCI_DEVICE_ID_GLI_9750 0x9750 >> >> -- >> With Best Regards, >> Andy Shevchenko > > Hi, Andy, > > Thank you for your comments to make the code better. > Waiting to see if Adrian has any other comments. Nope! :-) Please go ahead and address Andy's comments.