Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2619565imm; Fri, 24 Aug 2018 02:22:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZddv9yU07Q3ZSlMmlRJAC+l49mtUnijJ52hZXIw8xz0/8WjC+vZL6lLAH8ZR2x1Jv2d9Ow X-Received: by 2002:a63:c114:: with SMTP id w20-v6mr873932pgf.234.1535102579319; Fri, 24 Aug 2018 02:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535102579; cv=none; d=google.com; s=arc-20160816; b=fETI5KGWh0UTSaiZN0U6E8/ketQDucCxhVVrF0WH3Btuew4Sdc1nzVweJEjD7ovhrg 0rr4LBM1xiqSRPIDzFL+EGgpGIDQuERjXewoZyNsco565GGzCQAwGhO81kFyjD8VvBdI UOr2PKLCWrd42ZBy0sOCTB0IGt+Eda+/tuFcKNqAFhLSVm1OairN5aRiEO9d6bWuqMDK JD9WqSLfCULcSUz/ZprnZkZ2CgjmsJXDeRoYAAVE7PUYVvCpSfvcjbEtOdy5Z9+gcz+6 OaCvWBzqWAuzjLWOajw1M1rmc5ysVzoUm9bN9y96x1lfYfIIUlOhAg/7AOTtQsYDLu4n 3yQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=vGFW0eksYTgAicHNEinOVTwkCq1QSfxHTkyhgrrD8X0=; b=skIJU2zTUMbzZR+sYsUdJcfscEY5K49nxEbbInEuSvDl9XegiM0VjitxmjJN+EUhiK sMtjHJrQtbRI4gS2bfzuk84C7LehRBDag0lGCMs/ml9pEGWwQ+BvsP0Zrt2pxOZugzLB iV7XV20UX14FbzKdcDOlYsE50zkO++G4ioZ3a43p3YK6jIbwQlJ2V8nDx93Z45RwhkSw C0ocBRAafe7k3nYdjpJn9iM9x6siXMV7F0gKzAgDj0th3MQS7ds5wRZLtsRM/mElnd46 tqWQ+w1kz2AJllP79rMmhjQYwK6U8p7B3ngY8BrO2vsJMsgHLusj2S/WC+kzoRJWvs8C JVoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cxqy8bF4; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7-v6si6731141pfj.284.2018.08.24.02.22.43; Fri, 24 Aug 2018 02:22:59 -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=@linaro.org header.s=google header.b=cxqy8bF4; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727714AbeHXMyp (ORCPT + 99 others); Fri, 24 Aug 2018 08:54:45 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46109 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726915AbeHXMyp (ORCPT ); Fri, 24 Aug 2018 08:54:45 -0400 Received: by mail-pf1-f193.google.com with SMTP id u24-v6so4252393pfn.13 for ; Fri, 24 Aug 2018 02:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vGFW0eksYTgAicHNEinOVTwkCq1QSfxHTkyhgrrD8X0=; b=cxqy8bF4frF/YyPA7ZMy11XROdwuJUAytF1f546o4eP/E87a262731O8XyfvKfwWOU bV86wioiIhKP8hF1CTAfgDrUjHXdsFAUw5aeRCJBKJwjZPJn/zVBSAJxFsvbnzdtJIHq 5NgTJ77HP4yI5DukUy8XHZZeJoTP03agdCXnY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vGFW0eksYTgAicHNEinOVTwkCq1QSfxHTkyhgrrD8X0=; b=EMQqJDTS4jHcymCfg1LC5buQJoQHTuKPdAxc9dsx/gd/NQTc8+0vLf6g9X3E/VGygJ IrtkQQFWKvPYQYsxQZyWWk0f0aLCURFIQsp4u1gT5Z5k4TBg7UIVAUj9W3Z/YhdmsOVo W+QTHb/H9W0s1xGpJLuwnDd2+t0/6IzvOImjl2kFWs7SZqOliyLv25toM1ak/UrAPLyR 0owA8+jTquG2eJe6p3y3FU0UDinJO/wcM6+SSClAXtZK9I441fwUX8rmGNZeuY2mBekJ cHyKzmHExmlNO5uFxbWoAMv60BX1LG4dpUuD/a5Bf7RIDQqfJjWTlyIZ8HhGeUypME2v TAiA== X-Gm-Message-State: APzg51DMCnLvw/VBujw5HHoMg+yQtRTLQ8HumcTWkyEydt1nBz8OwMmO 9KSUMXlgcU/Je+iA/hPtk6mTyg== X-Received: by 2002:a63:d946:: with SMTP id e6-v6mr910039pgj.24.1535102458765; Fri, 24 Aug 2018 02:20:58 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id g6-v6sm9520314pfb.11.2018.08.24.02.20.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Aug 2018 02:20:57 -0700 (PDT) From: Chunyan Zhang To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Orson Zhai , Baolin Wang , Billows Wu , Jason Wu , Chunyan Zhang , Chunyan Zhang Subject: [PATCH V6 2/9] mmc: sdhci: Add sd host v4 mode Date: Fri, 24 Aug 2018 17:20:21 +0800 Message-Id: <1535102428-20332-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535102428-20332-1-git-send-email-zhang.chunyan@linaro.org> References: <1535102428-20332-1-git-send-email-zhang.chunyan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For SD host controller version 4.00 or later ones, there're two modes of implementation - Version 3.00 compatible mode or Version 4 mode. This patch introduced an interface to enable v4 mode. Signed-off-by: Chunyan Zhang --- drivers/mmc/host/sdhci.c | 29 +++++++++++++++++++++++++++++ drivers/mmc/host/sdhci.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index f70135c..a50842c 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -123,6 +123,29 @@ EXPORT_SYMBOL_GPL(sdhci_dumpregs); * * \*****************************************************************************/ +static void sdhci_do_enable_v4_mode(struct sdhci_host *host) +{ + u16 ctrl2; + + ctrl2 = sdhci_readb(host, SDHCI_HOST_CONTROL2); + if (ctrl2 & SDHCI_CTRL_V4_MODE) + return; + + ctrl2 |= SDHCI_CTRL_V4_MODE; + sdhci_writeb(host, ctrl2, SDHCI_HOST_CONTROL); +} + +/* + * This can be called before sdhci_add_host() by Vendor's host controller + * driver to enable v4 mode if supported. + */ +void sdhci_enable_v4_mode(struct sdhci_host *host) +{ + host->v4_mode = true; + sdhci_do_enable_v4_mode(host); +} +EXPORT_SYMBOL_GPL(sdhci_enable_v4_mode); + static inline bool sdhci_data_line_cmd(struct mmc_command *cmd) { return cmd->data || cmd->flags & MMC_RSP_BUSY; @@ -252,6 +275,9 @@ static void sdhci_init(struct sdhci_host *host, int soft) else sdhci_do_reset(host, SDHCI_RESET_ALL); + if (host->v4_mode) + sdhci_do_enable_v4_mode(host); + sdhci_set_default_irqs(host); host->cqe_on = false; @@ -3371,6 +3397,9 @@ void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps, u32 *caps1) sdhci_do_reset(host, SDHCI_RESET_ALL); + if (host->v4_mode) + sdhci_do_enable_v4_mode(host); + of_property_read_u64(mmc_dev(host->mmc)->of_node, "sdhci-caps-mask", &dt_caps_mask); of_property_read_u64(mmc_dev(host->mmc)->of_node, diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 7ae95f8..131d869 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -184,6 +184,7 @@ #define SDHCI_CTRL_DRV_TYPE_D 0x0030 #define SDHCI_CTRL_EXEC_TUNING 0x0040 #define SDHCI_CTRL_TUNED_CLK 0x0080 +#define SDHCI_CTRL_V4_MODE 0x1000 #define SDHCI_CTRL_PRESET_VAL_ENABLE 0x8000 #define SDHCI_CAPABILITIES 0x40 @@ -504,6 +505,7 @@ struct sdhci_host { bool preset_enabled; /* Preset is enabled */ bool pending_reset; /* Cmd/data reset is pending */ bool irq_wake_enabled; /* IRQ wakeup is enabled */ + bool v4_mode; /* Host Version 4 Enable */ struct mmc_request *mrqs_done[SDHCI_MAX_MRQS]; /* Requests done */ struct mmc_command *cmd; /* Current command */ @@ -751,5 +753,6 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error, int *data_error); void sdhci_dumpregs(struct sdhci_host *host); +void sdhci_enable_v4_mode(struct sdhci_host *host); #endif /* __SDHCI_HW_H */ -- 2.7.4