From patchwork Fri May 12 10:45:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Shih X-Patchwork-Id: 93129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5005546vqo; Fri, 12 May 2023 03:58:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BDatUi9u/3VU2T4Et0a5XhvGW+m8maCflwqmXUqCAzc36OwS6ZbEZSFgJ7Lasc8TNV8IT X-Received: by 2002:a17:902:c946:b0:1a5:22a:165c with SMTP id i6-20020a170902c94600b001a5022a165cmr30791088pla.0.1683889086444; Fri, 12 May 2023 03:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683889086; cv=none; d=google.com; s=arc-20160816; b=Kk16Kz+zKSx7XqdoKJADHQVKDPQX5qDnmgTOs/a0+2ap+xgH3a/hPjR8mBm1dwGueh WpyW2PQDHHpF5h+nVAbVNOmMNYCfPwdLupFeSp2eIB88Xmso+Hz0mHT44FMIPdf8ksvp VKzPL3YRxxgF377zUZkJCGtGnii1mzQjeKClsQA8ArUqRMJRHPPyfQ1BVQ6uMloGXZWm 9Ro822DT7ghuudOliB20aNSRYHmRAO46p/uOU9tcY4QBJNZCWsQW4QCFY3Phu1RZp3kF A9wNZP5KfP+pxu5G49VE+vBa/yH8h23byNOUXtUrsabh8vzdClgSKz9aA57vb/rDY13+ pMNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1SxJIzq87qXobHcRTYWJbit5Nqj1d0fM2PeE32DSP2o=; b=S2FT3JQr54V0Dg53s7x3Xq1bRwkXSP+w6R9hA0Qujhq3uwsKdR1O1K0jwxB6LyWoP0 u/c0TNlCdQibiS27zmiViacdCy5E+0QH7McJOWyyq//uf5nMx048jh76BQ1Plgg1plDt NXjyk8BcyP6fSFEcOl8jTjkvBFYSQ/uXi+LdpGJsu6eUZJe4zpLMPF47tEYYrymQ2ilq gvMggfEH/RkQZGGUp3vS+UcJ0GHj02/cQqT9l7q5zMl7mALqI7KN9Hm1wVW9IPVeRuV9 QsWZVLuhpCGRvUiet/W7EhaMx2xYS9McEvIXW4gHhlzbOrlR0pcGUog8h+LldQ2dMGjp MqwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="INylud/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l13-20020a170903120d00b001a654cdcce0si9431458plh.103.2023.05.12.03.57.49; Fri, 12 May 2023 03:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="INylud/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S240883AbjELKrf (ORCPT + 99 others); Fri, 12 May 2023 06:47:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240886AbjELKr3 (ORCPT ); Fri, 12 May 2023 06:47:29 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0FC71328F; Fri, 12 May 2023 03:47:09 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6439b410679so6454842b3a.0; Fri, 12 May 2023 03:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683888429; x=1686480429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1SxJIzq87qXobHcRTYWJbit5Nqj1d0fM2PeE32DSP2o=; b=INylud/BwUoM3kM5fNBMkglS5/fFPux/505IKyajC/h4rmZOPjGkS6ctbzwsuPglnI OG/5kj8Joc56PXESHK2iwjdTpOEMhqDA5EAnTzlUVuqdtEXXvTxQQ7pF6Ny4XKQy5rKD AsIgdGGOzzS15qhRGtDZFRGVg55Ne7TCJpCwxbLZBTGvPQTV3HvxULkIBYrOZjBM2aZp 2+kelVH9ybj0/+KwjyoMQUsm1aKTfjcoQqNxjeNATdJ9FZ6htdwLrFWEHr0G0S676ke9 z8Z2oKT9xvLKrIFp7ua+v5+8SrMUFENgwCWXyLXdsEgUtj0LmB2PYj1Y0LjpzIordtBQ VpJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683888429; x=1686480429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1SxJIzq87qXobHcRTYWJbit5Nqj1d0fM2PeE32DSP2o=; b=HaRkZeM5artj3QufdekTlxhocGznKPWircu2DVidFJ9qgBJpbFyeRySt39VGgA7tEg fwBuA/m6+JtSf0O3eCyQ4knH3oyIt/vZm/eB9pcoeh+S5Uh96ZGEmumqNw00Oa04CXsV gFUfDHEFqSwZ72YAMy3QFQdmoq9h1TbEiDDttXYGdCKgvT1nxVRYvE6TF6dqpeBxa5Xe jIp5H/sWjtHhtGyO5JrWLnilTJdbxKSkirGktSm7DZ8Wx01fo+gh+ssP+L2Ql1IWZdQ2 dY19ZO/qAjGJz9Pmvsv3kKHooISlVQhzenbSrUAaRKVa8A1ATeyrCIw4PsrsFIimnZvy 2ckA== X-Gm-Message-State: AC+VfDw7RSA7Tv/a/32nwJYBLrKwuUilU8Mht0/eo93FVLADgOQTJL3t SHZMgkYTBZJq9iX6GwGqiMg= X-Received: by 2002:a05:6a00:1a06:b0:63b:8423:9e31 with SMTP id g6-20020a056a001a0600b0063b84239e31mr29843428pfv.11.1683888429093; Fri, 12 May 2023 03:47:09 -0700 (PDT) Received: from localhost.localdomain (2001-b400-e2ae-0f1d-f6c2-46f4-c62f-3944.emome-ip6.hinet.net. [2001:b400:e2ae:f1d:f6c2:46f4:c62f:3944]) by smtp.gmail.com with ESMTPSA id g17-20020aa78751000000b0064358d032a4sm7019268pfo.145.2023.05.12.03.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 03:47:08 -0700 (PDT) From: Victor Shih X-Google-Original-From: Victor Shih To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, benchuanggli@gmail.com, HL.Liu@genesyslogic.com.tw, Greg.tu@genesyslogic.com.tw, takahiro.akashi@linaro.org, dlunev@chromium.org, Victor Shih , Ben Chuang Subject: [PATCH V1 1/3] mmc: sdhci-pci-gli: Add Genesys Logic GL9767 support Date: Fri, 12 May 2023 18:45:57 +0800 Message-Id: <20230512104559.11218-2-victor.shih@genesyslogic.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512104559.11218-1-victor.shih@genesyslogic.com.tw> References: <20230512104559.11218-1-victor.shih@genesyslogic.com.tw> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765685682337973759?= X-GMAIL-MSGID: =?utf-8?q?1765685682337973759?= Add support for the GL9767 chipset. GL9767 supports SD3 mode likes UHS-I SDR50, SDR104. Enable MSI interrupt for GL9767. Some platform do not support PCI INTx and devices can not work without interrupt. Signed-off-by: Ben Chuang Signed-off-by: Victor Shih --- drivers/mmc/host/sdhci-pci-core.c | 1 + drivers/mmc/host/sdhci-pci-gli.c | 132 ++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci-pci.h | 2 + 3 files changed, 135 insertions(+) diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c index 01975d145200..1c2572c0f012 100644 --- a/drivers/mmc/host/sdhci-pci-core.c +++ b/drivers/mmc/host/sdhci-pci-core.c @@ -1903,6 +1903,7 @@ static const struct pci_device_id pci_ids[] = { SDHCI_PCI_DEVICE(GLI, 9750, gl9750), SDHCI_PCI_DEVICE(GLI, 9755, gl9755), SDHCI_PCI_DEVICE(GLI, 9763E, gl9763e), + SDHCI_PCI_DEVICE(GLI, 9767, gl9767), SDHCI_PCI_DEVICE_CLASS(AMD, SYSTEM_SDHCI, PCI_CLASS_MASK, amd), /* Generic SD host controller */ {PCI_DEVICE_CLASS(SYSTEM_SDHCI, PCI_CLASS_MASK)}, diff --git a/drivers/mmc/host/sdhci-pci-gli.c b/drivers/mmc/host/sdhci-pci-gli.c index 633a8ee8f8c5..300512740cb0 100644 --- a/drivers/mmc/host/sdhci-pci-gli.c +++ b/drivers/mmc/host/sdhci-pci-gli.c @@ -149,6 +149,32 @@ #define PCI_GLI_9755_PM_CTRL 0xFC #define PCI_GLI_9755_PM_STATE GENMASK(1, 0) +#define SDHCI_GLI_9767_GM_BURST_SIZE 0x510 +#define SDHCI_GLI_9767_GM_BURST_SIZE_AXI_ALWAYS_SET BIT(8) + +#define PCIE_GLI_9767_VHS 0x884 +#define GLI_9767_VHS_REV GENMASK(19, 16) +#define GLI_9767_VHS_REV_R 0x0 +#define GLI_9767_VHS_REV_M 0x1 +#define GLI_9767_VHS_REV_W 0x2 + +#define PCIE_GLI_9767_PWR_MACRO_CTL 0x8D0 +#define PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE GENMASK(3, 0) +#define PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE GENMASK(15, 12) +#define PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE_VALUE 0x7 +#define PCIE_GLI_9767_PWR_MACRO_CTL_RCLK_AMPLITUDE_CTL GENMASK(29, 28) +#define PCIE_GLI_9767_PWR_MACRO_CTL_RCLK_AMPLITUDE_CTL_VALUE 0x3 + +#define PCIE_GLI_9767_SCR 0x8E0 +#define PCIE_GLI_9767_SCR_AUTO_AXI_W_BURST BIT(6) +#define PCIE_GLI_9767_SCR_AUTO_AXI_R_BURST BIT(7) +#define PCIE_GLI_9767_SCR_AXI_REQ BIT(9) +#define PCIE_GLI_9767_SCR_CARD_DET_PWR_SAVING_EN BIT(10) +#define PCIE_GLI_9767_SCR_SYSTEM_CLK_SELECT_MODE0 BIT(16) +#define PCIE_GLI_9767_SCR_SYSTEM_CLK_SELECT_MODE1 BIT(17) +#define PCIE_GLI_9767_SCR_CORE_PWR_D3_OFF BIT(21) +#define PCIE_GLI_9767_SCR_CFG_RST_DATA_LINK_DOWN BIT(30) + #define GLI_MAX_TUNING_LOOP 40 /* Genesys Logic chipset */ @@ -693,6 +719,61 @@ static void gl9755_hw_setting(struct sdhci_pci_slot *slot) gl9755_wt_off(pdev); } +static void gli_set_9767(struct sdhci_host *host) +{ + u32 value; + + value = sdhci_readl(host, SDHCI_GLI_9767_GM_BURST_SIZE); + value &= ~SDHCI_GLI_9767_GM_BURST_SIZE_AXI_ALWAYS_SET; + sdhci_writel(host, value, SDHCI_GLI_9767_GM_BURST_SIZE); +} + +static void gl9767_hw_setting(struct sdhci_pci_slot *slot) +{ + struct pci_dev *pdev = slot->chip->pdev; + u32 value; + + pci_read_config_dword(pdev, PCIE_GLI_9767_VHS, &value); + value &= ~GLI_9767_VHS_REV; + value |= FIELD_PREP(GLI_9767_VHS_REV, GLI_9767_VHS_REV_W); + pci_write_config_dword(pdev, PCIE_GLI_9767_VHS, value); + + pci_read_config_dword(pdev, PCIE_GLI_9767_PWR_MACRO_CTL, &value); + value &= ~(PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE | + PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE | + PCIE_GLI_9767_PWR_MACRO_CTL_RCLK_AMPLITUDE_CTL); + + value |= PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE | + FIELD_PREP(PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE, + PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE_VALUE) | + FIELD_PREP(PCIE_GLI_9767_PWR_MACRO_CTL_RCLK_AMPLITUDE_CTL, + PCIE_GLI_9767_PWR_MACRO_CTL_RCLK_AMPLITUDE_CTL_VALUE); + pci_write_config_dword(pdev, PCIE_GLI_9767_PWR_MACRO_CTL, value); + + pci_read_config_dword(pdev, PCIE_GLI_9767_SCR, &value); + value &= ~(PCIE_GLI_9767_SCR_SYSTEM_CLK_SELECT_MODE0 | + PCIE_GLI_9767_SCR_SYSTEM_CLK_SELECT_MODE1 | + PCIE_GLI_9767_SCR_CFG_RST_DATA_LINK_DOWN); + + value |= PCIE_GLI_9767_SCR_AUTO_AXI_W_BURST | + PCIE_GLI_9767_SCR_AUTO_AXI_R_BURST | + PCIE_GLI_9767_SCR_AXI_REQ | + PCIE_GLI_9767_SCR_CARD_DET_PWR_SAVING_EN | + PCIE_GLI_9767_SCR_CORE_PWR_D3_OFF; + pci_write_config_dword(pdev, PCIE_GLI_9767_SCR, value); + + pci_read_config_dword(pdev, PCIE_GLI_9767_VHS, &value); + value &= ~GLI_9767_VHS_REV; + value |= FIELD_PREP(GLI_9767_VHS_REV, GLI_9767_VHS_REV_R); + pci_write_config_dword(pdev, PCIE_GLI_9767_VHS, value); +} + +static void sdhci_gl9767_reset(struct sdhci_host *host, u8 mask) +{ + sdhci_reset(host, mask); + gli_set_9767(host); +} + static int gli_probe_slot_gl9750(struct sdhci_pci_slot *slot) { struct sdhci_host *host = slot->host; @@ -717,6 +798,19 @@ static int gli_probe_slot_gl9755(struct sdhci_pci_slot *slot) return 0; } +static int gli_probe_slot_gl9767(struct sdhci_pci_slot *slot) +{ + struct sdhci_host *host = slot->host; + + gli_set_9767(host); + gl9767_hw_setting(slot); + gli_pcie_enable_msi(slot); + slot->host->mmc->caps2 |= MMC_CAP2_NO_SDIO; + sdhci_enable_v4_mode(host); + + return 0; +} + static void sdhci_gli_voltage_switch(struct sdhci_host *host) { /* @@ -740,6 +834,25 @@ static void sdhci_gli_voltage_switch(struct sdhci_host *host) usleep_range(100000, 110000); } +static void sdhci_gl9767_voltage_switch(struct sdhci_host *host) +{ + /* + * According to Section 3.6.1 signal voltage switch procedure in + * SD Host Controller Simplified Spec. 4.20, steps 6~8 are as + * follows: + * (6) Set 1.8V Signal Enable in the Host Control 2 register. + * (7) Wait 5ms. 1.8V voltage regulator shall be stable within this + * period. + * (8) If 1.8V Signal Enable is cleared by Host Controller, go to + * step (12). + * + * Wait 5ms after set 1.8V signal enable in Host Control 2 register + * to ensure 1.8V signal enable bit is set by GL9767. + * + */ + usleep_range(5000, 5500); +} + static void sdhci_gl9750_reset(struct sdhci_host *host, u8 mask) { sdhci_reset(host, mask); @@ -1150,3 +1263,22 @@ const struct sdhci_pci_fixes sdhci_gl9763e = { #endif .add_host = gl9763e_add_host, }; + +static const struct sdhci_ops sdhci_gl9767_ops = { + .set_clock = sdhci_set_clock, + .enable_dma = sdhci_pci_enable_dma, + .set_bus_width = sdhci_set_bus_width, + .reset = sdhci_gl9767_reset, + .set_uhs_signaling = sdhci_set_uhs_signaling, + .voltage_switch = sdhci_gl9767_voltage_switch, +}; + +const struct sdhci_pci_fixes sdhci_gl9767 = { + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, + .quirks2 = SDHCI_QUIRK2_BROKEN_DDR50, + .probe_slot = gli_probe_slot_gl9767, + .ops = &sdhci_gl9767_ops, +#ifdef CONFIG_PM_SLEEP + .resume = sdhci_pci_gli_resume, +#endif +}; diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h index 3661a224fb04..9c8863956381 100644 --- a/drivers/mmc/host/sdhci-pci.h +++ b/drivers/mmc/host/sdhci-pci.h @@ -76,6 +76,7 @@ #define PCI_DEVICE_ID_GLI_9755 0x9755 #define PCI_DEVICE_ID_GLI_9750 0x9750 #define PCI_DEVICE_ID_GLI_9763E 0xe763 +#define PCI_DEVICE_ID_GLI_9767 0x9767 /* * PCI device class and mask @@ -195,5 +196,6 @@ extern const struct sdhci_pci_fixes sdhci_o2; extern const struct sdhci_pci_fixes sdhci_gl9750; extern const struct sdhci_pci_fixes sdhci_gl9755; extern const struct sdhci_pci_fixes sdhci_gl9763e; +extern const struct sdhci_pci_fixes sdhci_gl9767; #endif /* __SDHCI_PCI_H */ From patchwork Fri May 12 10:45:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Shih X-Patchwork-Id: 93133 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5016015vqo; Fri, 12 May 2023 04:13:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CEGIHYn92DvunufybadR2DzVdS8LFV5wpfLQjrPkO67eqGV9IMqVe2kSP0asNE+bgVVKj X-Received: by 2002:a17:902:db01:b0:1a6:b971:fae9 with SMTP id m1-20020a170902db0100b001a6b971fae9mr29806154plx.8.1683890023920; Fri, 12 May 2023 04:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683890023; cv=none; d=google.com; s=arc-20160816; b=f3Ld+GeIWMhK3N5lyq9dIHXg5eHH34ANxVenB/bThy6hSfmt8F1jcoW/3Qa2DctP0G r2nC+LCZKN8b+iq+74JzEaEPFfbt7Ab3EFOIAxYY6UMAjdU15xyTAt3ej3qGLMXyzYVs p6vhU3TGwK4JKC9xjMMgXZk8bfcYHV4diu74C3gz5lRxo/0W/doxPRX56GUuE3v+kgf1 cHwnmHD6MQXF7FruoOSwjXC0tihnYX/Gs4d7K/xy+5GRjdZrOuFPa+B4wcEttVo1B/bR blXhTatdPdtBAmDo5MD9QhKckrmbkUy5zMmkt5FSysg3TA5R5MWPN1mjrTvCVoCfakeN D5NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mTEC64ER82u3IhlaeRlkyP6syxElg6OBv01XXMZkg48=; b=lkX3UDX/s3xtjq2d+fTFNf2fwXSJk+3xI4Um7lyEzIQ49B1Yyk0KgKFxECKOoAMjsJ 5HrYYFHyofdhbGP68TQJv60bGuCHfNQPgWwcrb2asdiPMrzWHxGEk6te5I3lmhBE3P57 uZfQcxK6q0vImW860zY5sEH1jjnbgH4hWmlCfphD7FHfL/IjHMrN5Ii04RmwCwpoMXIs bimzylKQWE+iDd4+YrPlbmxiNlLCWJhF2B1xQpArrwJsaBhCNXXqmhSgg2is1xu/m7HV +WqbLe3n2AKXQh12BUSbq4GhJEj7rIQmrO8nXTtB4+eMrOyn8KGOppydB3RchnIgsYFz AkhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=fhXJHf+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a170902f68900b0019cd3a6016esi10043959plg.210.2023.05.12.04.13.28; Fri, 12 May 2023 04:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=fhXJHf+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S240828AbjELKri (ORCPT + 99 others); Fri, 12 May 2023 06:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240890AbjELKra (ORCPT ); Fri, 12 May 2023 06:47:30 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52C721329F; Fri, 12 May 2023 03:47:12 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-64a9335a8e7so4682752b3a.0; Fri, 12 May 2023 03:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683888432; x=1686480432; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mTEC64ER82u3IhlaeRlkyP6syxElg6OBv01XXMZkg48=; b=fhXJHf+wTETW1VS5IEXYkCxPs6Lsaqdt8THu8UT1xhP1eXkt0Mu6Z2i7D8a42Gj5sq ozUsWtcX+sQI0wwOHWudOPta0lMABsYzQ+vsg82L5oRHhlL+7Bi+hwCIFEeSR/Wp5OXA CmKHGDDABmJiqMDz9bvF9NLg/cC4IQ4vH+xscBRQ0IJyvRZ/hK6kKUm7Ewj4gkOLdUO1 hVTDwtCivMLvMQxi8dxynwqLWz57kfmwDA6M5ZTA3Me6TzGom/2QyhbAW9Wcr3xDigCJ m6bjrZt6bIEyAObzoX6eWHitG9YEcPw1XrHCr9LyUHvU63JUX4pD+8QsokDPhzdOBolo fX8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683888432; x=1686480432; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mTEC64ER82u3IhlaeRlkyP6syxElg6OBv01XXMZkg48=; b=T/5zE6twmrEPdOeshi//tfK/svUNobyci6edRExUnykUZka7THJcGbcp/Zm6WCdVAT zx9DjfcELMmU8cRIT0hqUU32c9O6FNIi4sbFG3cBnaDOync8sIz+wPg52psNjXLRoFN0 CsUzx1idlmYtupfams/bGZGMgdvpUDq3V9yYqCTjc2G8z6cg4soNAhb+vLWGNW0Cakih GQneScE4IyHKRNTKytptSy18hCpkfmbMIlJ5ZyLmZsHUjBualvVRtyjFDkTStyS4K60r XF/PVHu6A08DHS6qeLe2J2zi3u2P2SiujcbaG3q1WviYJZXwbe5JtNkBoKOovPsQV5v1 Qt2g== X-Gm-Message-State: AC+VfDz/U3FySwCM8Sdy97KV3GwW0Hf1C/0hKWnSzb22TOroQpwju5VF siDL5tU+ANfYCmg580J0sBQ= X-Received: by 2002:a05:6a20:8e05:b0:101:281c:494 with SMTP id y5-20020a056a208e0500b00101281c0494mr14977740pzj.27.1683888431804; Fri, 12 May 2023 03:47:11 -0700 (PDT) Received: from localhost.localdomain (2001-b400-e2ae-0f1d-f6c2-46f4-c62f-3944.emome-ip6.hinet.net. [2001:b400:e2ae:f1d:f6c2:46f4:c62f:3944]) by smtp.gmail.com with ESMTPSA id g17-20020aa78751000000b0064358d032a4sm7019268pfo.145.2023.05.12.03.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 03:47:11 -0700 (PDT) From: Victor Shih X-Google-Original-From: Victor Shih To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, benchuanggli@gmail.com, HL.Liu@genesyslogic.com.tw, Greg.tu@genesyslogic.com.tw, takahiro.akashi@linaro.org, dlunev@chromium.org, Victor Shih , Ben Chuang Subject: [PATCH V1 2/3] mmc: sdhci: Export sdhci_check_ro function symbol Date: Fri, 12 May 2023 18:45:58 +0800 Message-Id: <20230512104559.11218-3-victor.shih@genesyslogic.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512104559.11218-1-victor.shih@genesyslogic.com.tw> References: <20230512104559.11218-1-victor.shih@genesyslogic.com.tw> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765686665567005402?= X-GMAIL-MSGID: =?utf-8?q?1765686665567005402?= Export sdhci_check_ro() function symbols which are used by other SD Host controller drivers modules. Signed-off-by: Ben Chuang Signed-off-by: Victor Shih --- drivers/mmc/host/sdhci.c | 3 ++- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 3241916141d7..0c9b2006e24a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2513,7 +2513,7 @@ int sdhci_get_cd_nogpio(struct mmc_host *mmc) } EXPORT_SYMBOL_GPL(sdhci_get_cd_nogpio); -static int sdhci_check_ro(struct sdhci_host *host) +int sdhci_check_ro(struct sdhci_host *host) { unsigned long flags; int is_readonly; @@ -2536,6 +2536,7 @@ static int sdhci_check_ro(struct sdhci_host *host) return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ? !is_readonly : is_readonly; } +EXPORT_SYMBOL_GPL(sdhci_check_ro); #define SAMPLE_COUNT 5 diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index f4f2085c274c..54e9e13108e3 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -780,6 +780,7 @@ void sdhci_set_power_and_bus_voltage(struct sdhci_host *host, void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode, unsigned short vdd); int sdhci_get_cd_nogpio(struct mmc_host *mmc); +int sdhci_check_ro(struct sdhci_host *host); void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq); int sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq); void sdhci_set_bus_width(struct sdhci_host *host, int width); From patchwork Fri May 12 10:45:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Shih X-Patchwork-Id: 93134 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5016779vqo; Fri, 12 May 2023 04:14:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4vYSVPAYN1iTUxJAXt3lS8/AsutPm3EoMRGBs08j3KEjZ4zh+mRw1L5R/n4mXww9HdfTVQ X-Received: by 2002:a05:6a20:2588:b0:103:377e:439e with SMTP id k8-20020a056a20258800b00103377e439emr11754236pzd.60.1683890097163; Fri, 12 May 2023 04:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683890097; cv=none; d=google.com; s=arc-20160816; b=0GGq/aNzMfK8lSD8jIoUWnGNFnqIx6ROdKEZUkw5k99Drm38IUbxy2ILMxzQLyq3bv PaWgBSajp1aG+89qFSI6HyOGIEeXdqbvkCO8Nzb9B+bjJGFDs0czUkAM4qjpkgFONrI9 t2yN91HCIMflici+Y1AqK5zsnkkpYqZi0HzMJjQi5ZNWZeUBNsQni92h2DqDYKhKI+7p xe1AUT0laU96NZM65HAIGvE4hXX5l7aji5AJwcjHWGSEqiZ0G3cZzkqSZ2eyIyWGpuD8 R37x7R+BJhJlWfq6XsSqY2rfJCnK2FVDJrLCtDZW83jXNEtyPAb0mZNeh7HE1ti06trc uAMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d5wxPW18b4R0sRXPhoTakncl9njdflZ8y6zNcQOexJI=; b=Zy3+pD03Gm32JD56beVasLCDm1mHRJXq/Z6Z32YdHHgvU5Jotlko0/GUQWbZNPlmAC O/kOkiK8CG/HhjmhTj4wtVHbwvwWe0HnVvOWJgvjUbndY4w28iUKSUaPQK4E6ZNyswxW 8HoPGtWTyufLXhHHjFtZBtJT9OwW2iGjmgg1/ML51wYivbiKpAMzWuok8vsvjpVn/jp4 j2/xo7woLUBz+Twbzb2KSGok5C68Npkrr9P8L20yaIiy7qdFXQvCKq+SbztoyI8jko8d OYGUbIi1tSnUN04Sn40UJiy7HhMyYxzWv9wYqZ2E/yJ650GCHjLMMX/nrWnzXW4NCU4R rCVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Z7k82tc2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020aa796ac000000b0064375752593si9908548pfk.254.2023.05.12.04.14.40; Fri, 12 May 2023 04:14:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Z7k82tc2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S240897AbjELKrl (ORCPT + 99 others); Fri, 12 May 2023 06:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240892AbjELKra (ORCPT ); Fri, 12 May 2023 06:47:30 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D28AFE; Fri, 12 May 2023 03:47:15 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-52c6504974dso8897018a12.2; Fri, 12 May 2023 03:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683888434; x=1686480434; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d5wxPW18b4R0sRXPhoTakncl9njdflZ8y6zNcQOexJI=; b=Z7k82tc2HoQiz2Y+96UNv7Gma09OEv5PLhls+jCo9aEUte0iTPhxbotyN+DXIUBMue Y6Aev3n2O7roahg7/7l73/5kAWs5HqOLRfDnXCQcd7hCaP1ywIO+R8fIXO+0TrTErBB7 cgY2uOyQHwr5gCNCgtO79cU66o4+cAnMw8Zc7SGcgJRfqzazi21jdsuwyHftM3cHezg7 d922Bl3ZWM9n9sDK9X4SPUAeUm8urFCKzff6fyyoo7wDTnIUFt7NQ8rQrLIp+GprtJe7 k39EjFxVHPcGAm3EhGaX0ZFDS/WvgHRJm/SfVxoe6bQKDCHeu5t/4S39Ns9cKrSjQ7vh rRMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683888434; x=1686480434; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d5wxPW18b4R0sRXPhoTakncl9njdflZ8y6zNcQOexJI=; b=ctAEBSOr93dyjbqKW6P+oYIGX59kvTyLFsZiUzTsB/xVnZWtUw7TK7Jqjpvm+0RWXD I+nXu6Kuxu/ACH5cI1OMhP9sOndTWs50hy7NdLSkJ+ZNvbMR+lK5070xojbpMpkjIulN VJjhQRXKO3zi9y2t47rmRLDrnYjWbfTkl9r661h+icC7r8vMwvcF136QT74LPv54aVzw pVoc/nCpEPj9m9RJkrUkz/sy4hpXjJ1T+cwLRbwpspS/VuSSgRs0KH5okIgBWiUyJuKH Kqq0DGPh3trFwoE/w4ltAPA48fSxbNzg8YY0GN21vJHoz5J4faLI7iCOPjJWsyofDmgj f3UA== X-Gm-Message-State: AC+VfDxjZ7sTp5z9EtfMAnf6/Se6tNtU0OFlhfnQmGmFFdqjY6RvoOEV Ryb2gI1fEBJAgHWWU3Zuc20= X-Received: by 2002:a05:6a21:7881:b0:103:8590:bb50 with SMTP id bf1-20020a056a21788100b001038590bb50mr10019257pzc.44.1683888434485; Fri, 12 May 2023 03:47:14 -0700 (PDT) Received: from localhost.localdomain (2001-b400-e2ae-0f1d-f6c2-46f4-c62f-3944.emome-ip6.hinet.net. [2001:b400:e2ae:f1d:f6c2:46f4:c62f:3944]) by smtp.gmail.com with ESMTPSA id g17-20020aa78751000000b0064358d032a4sm7019268pfo.145.2023.05.12.03.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 03:47:14 -0700 (PDT) From: Victor Shih X-Google-Original-From: Victor Shih To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, benchuanggli@gmail.com, HL.Liu@genesyslogic.com.tw, Greg.tu@genesyslogic.com.tw, takahiro.akashi@linaro.org, dlunev@chromium.org, Victor Shih , Ben Chuang Subject: [PATCH V1 3/3] mmc: sdhci-pci-gli: Add support SD Express card for GL9767 Date: Fri, 12 May 2023 18:45:59 +0800 Message-Id: <20230512104559.11218-4-victor.shih@genesyslogic.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512104559.11218-1-victor.shih@genesyslogic.com.tw> References: <20230512104559.11218-1-victor.shih@genesyslogic.com.tw> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765686742330845777?= X-GMAIL-MSGID: =?utf-8?q?1765686742330845777?= Add support SD Express card for GL9767. The workflow of the SD Express card in GL9767 is as below. 1. GL9767 operates in SD mode and set MMC_CAP2_SD_EXP flag. 2. If card is inserted, Host send CMD8 to ask the capabilities of the card. 3. If the card has PCIe capability and write protect is not enable, then init_sd_express() will be invoked. 4. GL9767 switch from SD mode to PCIe/NVMe mode and mmc driver handover control to NVMe driver. 5. If card is removed, GL9767 will return to SD mode. Signed-off-by: Ben Chuang Signed-off-by: Victor Shih --- drivers/mmc/host/sdhci-pci-gli.c | 115 +++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/drivers/mmc/host/sdhci-pci-gli.c b/drivers/mmc/host/sdhci-pci-gli.c index 300512740cb0..a0f9c24439be 100644 --- a/drivers/mmc/host/sdhci-pci-gli.c +++ b/drivers/mmc/host/sdhci-pci-gli.c @@ -158,6 +158,13 @@ #define GLI_9767_VHS_REV_M 0x1 #define GLI_9767_VHS_REV_W 0x2 +#define PCIE_GLI_9767_CFG 0x8A0 +#define PCIE_GLI_9767_CFG_LOW_PWR_OFF BIT(12) + +#define PCIE_GLI_9767_COMBO_MUX_CTL 0x8C8 +#define PCIE_GLI_9767_COMBO_MUX_CTL_RST_EN BIT(6) +#define PCIE_GLI_9767_COMBO_MUX_CTL_WAIT_PERST_EN BIT(10) + #define PCIE_GLI_9767_PWR_MACRO_CTL 0x8D0 #define PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE GENMASK(3, 0) #define PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE GENMASK(15, 12) @@ -175,6 +182,27 @@ #define PCIE_GLI_9767_SCR_CORE_PWR_D3_OFF BIT(21) #define PCIE_GLI_9767_SCR_CFG_RST_DATA_LINK_DOWN BIT(30) +#define PCIE_GLI_9767_SDHC_CAP 0x91C +#define PCIE_GLI_9767_SDHC_CAP_SDEI_RESULT BIT(5) + +#define PCIE_GLI_9767_SD_EXPRESS_CTL 0x940 +#define PCIE_GLI_9767_SD_EXPRESS_CTL_SDEI_EXE BIT(0) +#define PCIE_GLI_9767_SD_EXPRESS_CTL_SD_EXPRESS_MODE BIT(1) + +#define PCIE_GLI_9767_SD_DATA_MULTI_CTL 0x944 +#define PCIE_GLI_9767_SD_DATA_MULTI_CTL_DISCONNECT_TIME GENMASK(23, 16) +#define PCIE_GLI_9767_SD_DATA_MULTI_CTL_DISCONNECT_TIME_VALUE 0x64 + +#define PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2 0x950 +#define PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2_SDEI_COMPLETE BIT(0) +#define PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2_SDEI_GEN_TIMER GENMASK(1, 0) + +#define PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_EN_REG2 0x954 +#define PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_EN_REG2_SDEI_COMPLETE_STATUS_EN GENMASK(1, 0) + +#define PCIE_GLI_9767_NORMAL_ERR_INT_SIGNAL_EN_REG2 0x958 +#define PCIE_GLI_9767_NORMAL_ERR_INT_SIGNAL_EN_REG2_SDEI_COMPLETE_SIGNAL_EN GENMASK(1, 0) + #define GLI_MAX_TUNING_LOOP 40 /* Genesys Logic chipset */ @@ -774,6 +802,91 @@ static void sdhci_gl9767_reset(struct sdhci_host *host, u8 mask) gli_set_9767(host); } +static int gl9767_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios) +{ + struct sdhci_host *host = mmc_priv(mmc); + struct sdhci_pci_slot *slot = sdhci_priv(host); + struct pci_dev *pdev; + u32 value; + int i; + + pdev = slot->chip->pdev; + + if (sdhci_check_ro(host)) { + mmc->ios.timing &= ~(MMC_TIMING_SD_EXP | MMC_TIMING_SD_EXP_1_2V); + return 0; + } + + pci_read_config_dword(pdev, PCIE_GLI_9767_VHS, &value); + value &= ~GLI_9767_VHS_REV; + value |= FIELD_PREP(GLI_9767_VHS_REV, GLI_9767_VHS_REV_W); + pci_write_config_dword(pdev, PCIE_GLI_9767_VHS, value); + + pci_read_config_dword(pdev, PCIE_GLI_9767_COMBO_MUX_CTL, &value); + value &= ~(PCIE_GLI_9767_COMBO_MUX_CTL_RST_EN | PCIE_GLI_9767_COMBO_MUX_CTL_WAIT_PERST_EN); + pci_write_config_dword(pdev, PCIE_GLI_9767_COMBO_MUX_CTL, value); + + pci_read_config_dword(pdev, PCIE_GLI_9767_SD_DATA_MULTI_CTL, &value); + value &= ~PCIE_GLI_9767_SD_DATA_MULTI_CTL_DISCONNECT_TIME; + value |= FIELD_PREP(PCIE_GLI_9767_SD_DATA_MULTI_CTL_DISCONNECT_TIME, + PCIE_GLI_9767_SD_DATA_MULTI_CTL_DISCONNECT_TIME_VALUE); + pci_write_config_dword(pdev, PCIE_GLI_9767_SD_DATA_MULTI_CTL, value); + + pci_read_config_dword(pdev, PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2, &value); + value |= PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2_SDEI_GEN_TIMER; + pci_write_config_dword(pdev, PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2, value); + + pci_read_config_dword(pdev, PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_EN_REG2, &value); + value |= PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_EN_REG2_SDEI_COMPLETE_STATUS_EN; + pci_write_config_dword(pdev, PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_EN_REG2, value); + + pci_read_config_dword(pdev, PCIE_GLI_9767_NORMAL_ERR_INT_SIGNAL_EN_REG2, &value); + value |= PCIE_GLI_9767_NORMAL_ERR_INT_SIGNAL_EN_REG2_SDEI_COMPLETE_SIGNAL_EN; + pci_write_config_dword(pdev, PCIE_GLI_9767_NORMAL_ERR_INT_SIGNAL_EN_REG2, value); + + pci_read_config_dword(pdev, PCIE_GLI_9767_CFG, &value); + value |= PCIE_GLI_9767_CFG_LOW_PWR_OFF; + pci_write_config_dword(pdev, PCIE_GLI_9767_CFG, value); + + value = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + value &= ~(SDHCI_CLOCK_CARD_EN | SDHCI_CLOCK_PLL_EN); + sdhci_writew(host, value, SDHCI_CLOCK_CONTROL); + + value = sdhci_readb(host, SDHCI_POWER_CONTROL); + value |= ((SDHCI_POWER_180 | SDHCI_POWER_ON) << 4); + sdhci_writeb(host, value, SDHCI_POWER_CONTROL); + + pci_read_config_dword(pdev, PCIE_GLI_9767_SD_EXPRESS_CTL, &value); + value |= PCIE_GLI_9767_SD_EXPRESS_CTL_SDEI_EXE; + pci_write_config_dword(pdev, PCIE_GLI_9767_SD_EXPRESS_CTL, value); + + for (i = 0; i < 10; i++) { + mdelay(10); + pci_read_config_dword(pdev, PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2, &value); + if (value & PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2_SDEI_COMPLETE) { + pci_write_config_dword(pdev, PCIE_GLI_9767_NORMAL_ERR_INT_STATUS_REG2, + value); + break; + } + } + + pci_read_config_dword(pdev, PCIE_GLI_9767_SDHC_CAP, &value); + if ((value & PCIE_GLI_9767_SDHC_CAP_SDEI_RESULT) == PCIE_GLI_9767_SDHC_CAP_SDEI_RESULT) { + pci_read_config_dword(pdev, PCIE_GLI_9767_SD_EXPRESS_CTL, &value); + value |= PCIE_GLI_9767_SD_EXPRESS_CTL_SD_EXPRESS_MODE; + pci_write_config_dword(pdev, PCIE_GLI_9767_SD_EXPRESS_CTL, value); + } else { + mmc->ios.timing &= ~(MMC_TIMING_SD_EXP | MMC_TIMING_SD_EXP_1_2V); + } + + pci_read_config_dword(pdev, PCIE_GLI_9767_VHS, &value); + value &= ~GLI_9767_VHS_REV; + value |= FIELD_PREP(GLI_9767_VHS_REV, GLI_9767_VHS_REV_R); + pci_write_config_dword(pdev, PCIE_GLI_9767_VHS, value); + + return 0; +} + static int gli_probe_slot_gl9750(struct sdhci_pci_slot *slot) { struct sdhci_host *host = slot->host; @@ -806,6 +919,8 @@ static int gli_probe_slot_gl9767(struct sdhci_pci_slot *slot) gl9767_hw_setting(slot); gli_pcie_enable_msi(slot); slot->host->mmc->caps2 |= MMC_CAP2_NO_SDIO; + host->mmc->caps2 |= MMC_CAP2_SD_EXP; + host->mmc_host_ops.init_sd_express = gl9767_init_sd_express; sdhci_enable_v4_mode(host); return 0;