Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1128619ybe; Mon, 2 Sep 2019 15:07:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZ7LhAHig+LBfAhSKA/tv+eTRQhFCzDbWsQWYJUOryE97PAg3qQ7CIe3vVsZdZAApWbofg X-Received: by 2002:a65:6815:: with SMTP id l21mr27442942pgt.146.1567462069679; Mon, 02 Sep 2019 15:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567462069; cv=none; d=google.com; s=arc-20160816; b=p9/2C3QFYAUEg3ajjy1TqYvsJO2qSnt5YtZ1QkgUSqCUMKtMGTiYaV9TM8vIEkOAb7 ecgOtpkIRPw8/LsROwWDlTXQ2WN+RcOPHw3gVl2SWgwVWHLZBNu/kLDQY+iB0JYljka2 9686DVpzOl2U68TmttiwyXjsOXO8pUwvFHSxsuZAmSaBMWnBhq15CSJx5ng4yhiq2XSH zhanb2I+lwxiKBkSA5+PbuPYkgsonJ/gO0O6RyGc8IvCrQI+GnVueh3OnCik8G6Csyy3 MWk0pDvfUszCx96JTK1dmyXh1BcAFTjUohjfiacMG74ILV4T3Cqw3Awob/oI7x64JL+J AJ7g== 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=qheEaqbo7JPkZrd6C0f084OuMiH7jmWGMxuDz2HD13Q=; b=y7OeXl2B8biI/0KeRVTU5F5NnS13UzYGHvvdG0ufZe5BF0+NfAhdP6vbCpN8I9lKra a6MjMZ7+YjFSazBMYj5t/Rs502WP876odyr6Z0aFeodQ/h6zeYMWozBrGNhTxWaNyeRv hmOSBacPj2ihSXCEetTu5NT0qf75FzG58bK1SP5pUSglfGLf5UXjhD8kU1EIOCDXoBZ3 Ux1hRjRaONSHDRPN3jNs4ClAVXdvN5BVLKlV+ev0zTT+lIc8KSUt28LQQ9chKEWL0hbY fxTNuAeDusIY9dqjQw0Bb7i4xiXxCxPgYj8twxcPBgdKXFSJpvMT+T1XU2FRTzYx1c0N v7kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kJNxvgSJ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u65si9043529pfu.160.2019.09.02.15.07.34; Mon, 02 Sep 2019 15:07:49 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kJNxvgSJ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727792AbfIBWF3 (ORCPT + 99 others); Mon, 2 Sep 2019 18:05:29 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44906 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727775AbfIBWF3 (ORCPT ); Mon, 2 Sep 2019 18:05:29 -0400 Received: by mail-pg1-f195.google.com with SMTP id i18so7981365pgl.11; Mon, 02 Sep 2019 15:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qheEaqbo7JPkZrd6C0f084OuMiH7jmWGMxuDz2HD13Q=; b=kJNxvgSJhbmsCH9tyXj23F4iPNyvuMKdcr8FWc6ZElFc18oDscBjGvhUJ3PDIDa9iU CWGMW8m0sfdiBv6oQKDmlHwGdaRrbDDsSk1fiYkdJiljmZ8bD7aeFxodRED39OPOciID kLhBZ/GpY30Oz0enJF9Tbps8pXSxb2zZa/a+7X25NXaJIwMhskAZpads3GF8jKVbCzfF UG8UVILu8KHtxM6J0I7uiUfloT06mcdkspYdZgQ0xGhU8fL+/BZx9oHrTNHxNAeR7vBX A5nGgwQHMq09NTH3jOsTZQ+wYO2v2VcMfL9uUY6cVdKftHC1eM0ubd/k8F27n+hIQ6NZ NMUg== 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=qheEaqbo7JPkZrd6C0f084OuMiH7jmWGMxuDz2HD13Q=; b=X37D1YaYWRl4XNzEi9PGkRIIwE92izMHJz/fcZ7ybEaegTPueofKx8nuNt81YV+KDu naCCjQ1N0jyySaNg5CMz6r2fzn70B0oL523fR1oNHGEKCseDTlTwrR5MDQDg1w+VJk6d +VY1NIU5NV+SMCf67/dKOtbqR82aL5UPjbK3Tsw07NwPi/LGLoyjCu9yV7KLccleOJI1 bIAlcqtkTGvQsu4tg/CoH7qbVXLtCRvHMcg9OgV7SwwjrdkQD5S2fvUqB+lJjrhBJ/tt sdio1vQmikcXMNRzBjhagCUOFdI2Q+FKOMV0n6b0gJWx26ZSSG0r20DgQauzDgy0dJRU C1DQ== X-Gm-Message-State: APjAAAVxm4w3Xd2pxQmY9avLINSRPkQnXffNRMOS1rw2TBOfVmXP0y+Z X9JPWKZf341gqbNJKh5AqpGjPr1NFXtve+Sa3zU= X-Received: by 2002:a17:90a:bf01:: with SMTP id c1mr15294811pjs.30.1567461928498; Mon, 02 Sep 2019 15:05:28 -0700 (PDT) MIME-Version: 1.0 References: <20190830022542.8571-1-benchuanggli@gmail.com> In-Reply-To: <20190830022542.8571-1-benchuanggli@gmail.com> From: Andy Shevchenko Date: Tue, 3 Sep 2019 01:05:16 +0300 Message-ID: Subject: Re: [PATCH V7 5/5] mmc: host: sdhci-pci: Add Genesys Logic GL975x support To: Ben Chuang Cc: Adrian Hunter , Ulf Hansson , linux-mmc , Linux Kernel Mailing List , johnsonm@danlj.org, ben.chuang@genesyslogic.com.tw 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 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