Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4578994imm; Wed, 30 May 2018 08:08:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKE77E6jCT/ag1mHr+bTjS/jhtYIVJ+VBoOsvblZH7eUBHYVlujttC3AU5/68ylZy6q1H1N X-Received: by 2002:a63:42c6:: with SMTP id p189-v6mr2615712pga.48.1527692928169; Wed, 30 May 2018 08:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527692928; cv=none; d=google.com; s=arc-20160816; b=C/eUKdecEblbghUhDx8q11NhczRDURPQPZTxUuu9F66oNznYNNOE5xTjRsb0BOwrQz 71BOON5eRMFi48xEpIuWbjAIWqKEDkPSEwtoc1MTh0+u9eIfpXfCbr/TWzBu0Fo9TXSp NL+Ae7/Mg8lJzUW4/+crR6DWdPXGhlL9ZwNn1PwqpW5XORCdq61EMT0jv4D1QgKJJexY D86Gf4P20mRO/3Tv9xMRYRZ/0Ny6r5B7psdffDUmLJ/0/sxt5mgnzLN/0oMWk10d5rNS LoNpbo00wILX04g0Mq2lwlo4YQ1vMG5E82v5LyNrfeIkATUqmmWgeb3oLagBStM0XYvT jpPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=jbvEF1afrR/OJrZAwsZlF0ImA16IxZ7Ror6ucCSohFg=; b=PBvgNa+iHTJxqeegZGLeZcu3g/83X6GKxGD06nr6kpWAlTu4dT5veHC1x4wHd1aLs1 QvxNfw0IZiPff/UxO3tCTCTIO2wdhVpsF3nXrcdjQOAgGKLoNggzVPSPWFQHxrcVunDw YflHUNiNsuLldu1CO3KBMgQQNJIt2tK8jXRX8eWbOnLqHW6VBA0FyhB1DxG9TU2scQoq 2pOAdiUgLAPylHZw5CLyYjLfCNC4TA3hzLbeLBXVLWPakKDHGIhXrgFCqO7W2DeGXajC 197Q0z09E52kiiyNydSrMHVlqfff1pbY8ZQxBG762VBuYSbziuB9Ju1JoPKzIj5KkLD5 vBoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=YyYf5wGg; 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=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i64-v6si6574611pli.431.2018.05.30.08.08.33; Wed, 30 May 2018 08:08:48 -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=@synopsys.com header.s=mail header.b=YyYf5wGg; 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=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753671AbeE3PHb (ORCPT + 99 others); Wed, 30 May 2018 11:07:31 -0400 Received: from smtprelay.synopsys.com ([198.182.37.59]:32846 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753599AbeE3PH2 (ORCPT ); Wed, 30 May 2018 11:07:28 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id D0A391E05E0; Wed, 30 May 2018 17:07:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1527692847; bh=jbvEF1afrR/OJrZAwsZlF0ImA16IxZ7Ror6ucCSohFg=; h=From:To:CC:Subject:Date:From; b=YyYf5wGg5LaqadPFdE6PEGxiXkv6ZcCcmVq8WGkK+kaSdeQFHqpKUM0Bu962Zqe+q r0VOlPcziLhDAWzDGXWf9AZhQAAi3vhEDDN/FiDDu5s+SP4M799uhX3zkgygnoxCpO 3H6LC4yhy4pi342e1PHm76KzEMTq+EXeYw6qW/q6ypgabfzzcydOaVYt9pS5Wp7nGX /JCPfWPrrUYg0MScXOFoYLHP5UhtN2CVoBCXmVHRZfKcxjwoQ1vkzgMNrPcSTBs0Sc JmHrFfhqtJXeIM35qkq2VvmRlnelt4oG4k+cJt2FOJEyJvLsumBibbpCRCdRc4KlLm LWXZPK/brKm9g== Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id 38F75499A; Wed, 30 May 2018 08:07:26 -0700 (PDT) Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.104) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 30 May 2018 08:07:25 -0700 Received: from IN01WEMBXB.internal.synopsys.com ([169.254.4.157]) by IN01WEHTCA.internal.synopsys.com ([::1]) with mapi id 14.03.0361.001; Wed, 30 May 2018 20:37:23 +0530 From: Prabu Thangamuthu To: "ulf.hansson@linaro.org" , "adrian.hunter@intel.com" , "linux-kernel@vger.kernel.org" , "linux-mmc@vger.kernel.org" CC: Manjunath M Bettegowda , "prabu.t@synopsys.com" Subject: [PATCH v2 1/1] mmc: sdhci-pci-dwc-mshc: synopsys dwc mshc support Thread-Topic: [PATCH v2 1/1] mmc: sdhci-pci-dwc-mshc: synopsys dwc mshc support Thread-Index: AdP4J+f4+DeR4dadRlSsPnyMsPMRwA== Date: Wed, 30 May 2018 15:07:23 +0000 Message-ID: <705D14B1C7978B40A723277C067CEDE2010A9B769C@IN01WEMBXB.internal.synopsys.com> Accept-Language: en-US, en-IN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.12.239.235] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =0A= Synopsys has DWC MSHC controller on HPAS-DX platform connected using PCIe= =0A= interface with SD card slot and eMMC device slots. This patch is to=0A= enable SD cards connected on this platform. As Clock generation logic=0A= is implemented using MMCM module of HAPS-DX platform, we have separate=0A= functions to control the MMCM to generate required clocks with respect=0A= to speed mode.=0A= =0A= Signed-off-by: Prabu Thangamuthu =0A= ---=0A= V2 - Removed sdhci-pci-dwc-mshc.h and moved into sdhci-pci-dwc-mshc.c=0A= Fixed coding style issue.=0A= Removed sdhci_snps_set_power and new approach to support eMMC device=0A= voltages will be submitted after completeing validations.=0A= V1 - Initial Patch.=0A= =0A= MAINTAINERS | 7 +++=0A= drivers/mmc/host/Makefile | 3 +-=0A= drivers/mmc/host/sdhci-pci-core.c | 1 +=0A= drivers/mmc/host/sdhci-pci-dwc-mshc.c | 88 ++++++++++++++++++++++++++++++++= +++=0A= drivers/mmc/host/sdhci-pci.h | 3 ++=0A= 5 files changed, 101 insertions(+), 1 deletion(-)=0A= create mode 100644 drivers/mmc/host/sdhci-pci-dwc-mshc.c=0A= =0A= diff --git a/MAINTAINERS b/MAINTAINERS=0A= index 4863175..aba98b6 100644=0A= --- a/MAINTAINERS=0A= +++ b/MAINTAINERS=0A= @@ -12684,6 +12684,13 @@ S: Maintained=0A= F: drivers/mmc/host/sdhci*=0A= F: include/linux/mmc/sdhci*=0A= =0A= +SYNOPSYS SDHCI COMPLIANT DWC MSHC DRIVER=0A= +M: Prabu Thangamuthu =0A= +M: Manjunath M B =0A= +L: linux-mmc@vger.kernel.org=0A= +S: Maintained=0A= +F: drivers/mmc/host/sdhci-pci-dwc-mshc.c=0A= +=0A= SECURE DIGITAL HOST CONTROLLER INTERFACE (SDHCI) SAMSUNG DRIVER=0A= M: Ben Dooks =0A= M: Jaehoon Chung =0A= diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile=0A= index 85dc132..20490f3 100644=0A= --- a/drivers/mmc/host/Makefile=0A= +++ b/drivers/mmc/host/Makefile=0A= @@ -11,7 +11,8 @@ obj-$(CONFIG_MMC_MXC) +=3D mxcmmc.o=0A= obj-$(CONFIG_MMC_MXS) +=3D mxs-mmc.o=0A= obj-$(CONFIG_MMC_SDHCI) +=3D sdhci.o=0A= obj-$(CONFIG_MMC_SDHCI_PCI) +=3D sdhci-pci.o=0A= -sdhci-pci-y +=3D sdhci-pci-core.o sdhci-pci-o2micro.o sdhci-pci-arasan.o= =0A= +sdhci-pci-y +=3D sdhci-pci-core.o sdhci-pci-o2micro.o sdhci-pci-arasan.o \= =0A= + sdhci-pci-dwc-mshc.o=0A= obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) +=3D sdhci-pci-data.o=0A= obj-$(CONFIG_MMC_SDHCI_ACPI) +=3D sdhci-acpi.o=0A= obj-$(CONFIG_MMC_SDHCI_PXAV3) +=3D sdhci-pxav3.o=0A= diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci= -core.c=0A= index 77dd352..ca1d4f7 100644=0A= --- a/drivers/mmc/host/sdhci-pci-core.c=0A= +++ b/drivers/mmc/host/sdhci-pci-core.c=0A= @@ -1511,6 +1511,7 @@ static int amd_probe(struct sdhci_pci_chip *chip)=0A= SDHCI_PCI_DEVICE(O2, SEABIRD0, o2),=0A= SDHCI_PCI_DEVICE(O2, SEABIRD1, o2),=0A= SDHCI_PCI_DEVICE(ARASAN, PHY_EMMC, arasan),=0A= + SDHCI_PCI_DEVICE(SYNOPSYS, DWC_MSHC, snps),=0A= SDHCI_PCI_DEVICE_CLASS(AMD, SYSTEM_SDHCI, PCI_CLASS_MASK, amd),=0A= /* Generic SD host controller */=0A= {PCI_DEVICE_CLASS(SYSTEM_SDHCI, PCI_CLASS_MASK)},=0A= diff --git a/drivers/mmc/host/sdhci-pci-dwc-mshc.c b/drivers/mmc/host/sdhci= -pci-dwc-mshc.c=0A= new file mode 100644=0A= index 0000000..0706055=0A= --- /dev/null=0A= +++ b/drivers/mmc/host/sdhci-pci-dwc-mshc.c=0A= @@ -0,0 +1,88 @@=0A= +// SPDX-License-Identifier: GPL-2.0=0A= +/*=0A= + * SDHCI driver for Synopsys DWC_MSHC controller=0A= + *=0A= + * Copyright (C) 2018 Synopsys, Inc. (www.synopsys.com)=0A= + *=0A= + * Authors:=0A= + * Prabu Thangamuthu =0A= + * Manjunath M B =0A= + *=0A= + * This program is free software; you can redistribute it and/or modify=0A= + * it under the terms of the GNU General Public License version 2 as=0A= + * published by the Free Software Foundation.=0A= + */=0A= +=0A= +#include "sdhci.h"=0A= +#include "sdhci-pci.h"=0A= +=0A= +#define SDHCI_VENDOR_PTR_R 0xE8=0A= +=0A= +/* Synopsys vendor specific registers */=0A= +#define SDHC_GPIO_OUT 0x34=0A= +#define SDHC_AT_CTRL_R 0x40=0A= +#define SDHC_SW_TUNE_EN 0x00000010=0A= +=0A= +/* MMCM DRP */=0A= +#define SDHC_MMCM_DIV_REG 0x1020=0A= +#define DIV_REG_100_MHZ 0x1145=0A= +#define DIV_REG_200_MHZ 0x1083=0A= +#define SDHC_MMCM_CLKFBOUT 0x1024=0A= +#define CLKFBOUT_100_MHZ 0x0000=0A= +#define CLKFBOUT_200_MHZ 0x0080=0A= +#define SDHC_CCLK_MMCM_RST 0x00000001=0A= +=0A= +static void sdhci_snps_set_clock(struct sdhci_host *host, unsigned int clo= ck)=0A= +{=0A= + u16 clk;=0A= + u32 reg, vendor_ptr;=0A= +=0A= + vendor_ptr =3D sdhci_readw(host, SDHCI_VENDOR_PTR_R);=0A= +=0A= + /* Disable software managed rx tuning */=0A= + reg =3D sdhci_readl(host, (SDHC_AT_CTRL_R + vendor_ptr));=0A= + reg &=3D ~SDHC_SW_TUNE_EN;=0A= + sdhci_writel(host, reg, (SDHC_AT_CTRL_R + vendor_ptr));=0A= +=0A= + if (clock <=3D 52000000) {=0A= + sdhci_set_clock(host, clock);=0A= + } else {=0A= + /* Assert reset to MMCM */=0A= + reg =3D sdhci_readl(host, (SDHC_GPIO_OUT + vendor_ptr));=0A= + reg |=3D SDHC_CCLK_MMCM_RST;=0A= + sdhci_writel(host, reg, (SDHC_GPIO_OUT + vendor_ptr));=0A= +=0A= + /* Configure MMCM */=0A= + if (clock =3D=3D 100000000) {=0A= + sdhci_writel(host, DIV_REG_100_MHZ, SDHC_MMCM_DIV_REG);=0A= + sdhci_writel(host, CLKFBOUT_100_MHZ,=0A= + SDHC_MMCM_CLKFBOUT);=0A= + } else {=0A= + sdhci_writel(host, DIV_REG_200_MHZ, SDHC_MMCM_DIV_REG);=0A= + sdhci_writel(host, CLKFBOUT_200_MHZ,=0A= + SDHC_MMCM_CLKFBOUT);=0A= + }=0A= +=0A= + /* De-assert reset to MMCM */=0A= + reg =3D sdhci_readl(host, (SDHC_GPIO_OUT + vendor_ptr));=0A= + reg &=3D ~SDHC_CCLK_MMCM_RST;=0A= + sdhci_writel(host, reg, (SDHC_GPIO_OUT + vendor_ptr));=0A= +=0A= + /* Enable clock */=0A= + clk =3D SDHCI_PROG_CLOCK_MODE | SDHCI_CLOCK_INT_EN |=0A= + SDHCI_CLOCK_CARD_EN;=0A= + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);=0A= + }=0A= +}=0A= +=0A= +static const struct sdhci_ops sdhci_snps_ops =3D {=0A= + .set_clock =3D sdhci_snps_set_clock,=0A= + .enable_dma =3D sdhci_pci_enable_dma,=0A= + .set_bus_width =3D sdhci_set_bus_width,=0A= + .reset =3D sdhci_reset,=0A= + .set_uhs_signaling =3D sdhci_set_uhs_signaling,=0A= +};=0A= +=0A= +const struct sdhci_pci_fixes sdhci_snps =3D {=0A= + .ops =3D &sdhci_snps_ops,=0A= +};=0A= diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h=0A= index db9cb54..60131b8 100644=0A= --- a/drivers/mmc/host/sdhci-pci.h=0A= +++ b/drivers/mmc/host/sdhci-pci.h=0A= @@ -59,6 +59,8 @@=0A= #define PCI_VENDOR_ID_ARASAN 0x16e6=0A= #define PCI_DEVICE_ID_ARASAN_PHY_EMMC 0x0670=0A= =0A= +#define PCI_DEVICE_ID_SYNOPSYS_DWC_MSHC 0xc202=0A= +=0A= /*=0A= * PCI device class and mask=0A= */=0A= @@ -182,5 +184,6 @@ static inline void *sdhci_pci_priv(struct sdhci_pci_slo= t *slot)=0A= #endif=0A= =0A= extern const struct sdhci_pci_fixes sdhci_arasan;=0A= +extern const struct sdhci_pci_fixes sdhci_snps;=0A= =0A= #endif /* __SDHCI_PCI_H */=0A= -- =0A= 1.9.1=0A= =0A= =0A=