From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753003AbcDZJGg (ORCPT ); Tue, 26 Apr 2016 05:06:36 -0400 Received: from eusmtp01.atmel.com ([212.144.249.242]:8506 "EHLO eusmtp01.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752262AbcDZJGd (ORCPT ); Tue, 26 Apr 2016 05:06:33 -0400 Date: Tue, 26 Apr 2016 11:05:22 +0200 From: Ludovic Desroches To: Prabu Thangamuthu , "Ulf Hansson (ulf.hansson@linaro.org)" , Adrian Hunter , Bjorn Helgaas , Andrew Morton , "David S. Miller" , Greg Kroah-Hartman , Kalle Valo , Mauro Carvalho Chehab , Guenter Roeck , Jiri Slaby , Chaotian Jing , Andrei Pistirica , Ben Hutchings , Joshua Henderson , Manjunath M Bettegowda , "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3] mmc: sdhci-pci: add Support of Synopsys DWC_MSHC IP Message-ID: <20160426090522.GB8756@odux.rfo.atmel.com> Mail-Followup-To: Prabu Thangamuthu , "Ulf Hansson (ulf.hansson@linaro.org)" , Adrian Hunter , Bjorn Helgaas , Andrew Morton , "David S. Miller" , Greg Kroah-Hartman , Kalle Valo , Mauro Carvalho Chehab , Guenter Roeck , Jiri Slaby , Chaotian Jing , Andrei Pistirica , Ben Hutchings , Joshua Henderson , Manjunath M Bettegowda , "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <705D14B1C7978B40A723277C067CEDE2010A4B12F8@IN01WEMBXB.internal.synopsys.com> <20160426085845.GA8756@odux.rfo.atmel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20160426085845.GA8756@odux.rfo.atmel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 26, 2016 at 10:58:45AM +0200, Ludovic Desroches wrote: > On Wed, Apr 20, 2016 at 12:22:59PM +0000, Prabu Thangamuthu wrote: > > Patch for Standard SD Host Controller Interface compliant Synopsys > > sdhci-dwc controller driver. This code supports PCI based interface. > > > > Signed-off-by: Prabu Thangamuthu > > --- > > Change log v3: > > -Removed unused code. > > -Updated review comments. > > > > Change log v2: > > -Removed Synopsys specific PCI device ID's from pci_ids.h. > > -Updated the PCI device ID's in sdhci-pci-core.c. > > > > MAINTAINERS | 7 + > > drivers/mmc/host/Makefile | 3 +- > > drivers/mmc/host/sdhci-pci-core.c | 14 ++ > > drivers/mmc/host/sdhci-pci-dwc.c | 260 ++++++++++++++++++++++++++++++++++++++ > > drivers/mmc/host/sdhci-pci-dwc.h | 55 ++++++++ > > 5 files changed, 338 insertions(+), 1 deletion(-) > > create mode 100644 drivers/mmc/host/sdhci-pci-dwc.c > > create mode 100644 drivers/mmc/host/sdhci-pci-dwc.h > > [snip] > > +static int snps_init_clock(struct sdhci_host *host) > > +{ > > + int div = 0; > > + int mul = 0; > > + int div_val = 0; > > + int mul_val = 0; > > + int mul_div_val = 0; > > + int reg = 0; > > + u32 mask = 0; > > + > > Some variables don't need initialization here or you can directly assign > the right value: int div = 2, mul = 2, etc. div and mul are even useless, they are const. You can directly declare mul_val = 1, div_val = 1. Regards Ludovic > > > + /* Configure the BCLK DRP to get 100 MHZ Clock */ > > + > > + /* > > + * To get 100MHz from 100MHz input freq, > > + * mul=2 and div=2 > > + * Formula: output_clock = (input clock * mul) / div > > + */ > > + mul = 2; > > + div = 2; > > + mul_val = mul - 1; > > + div_val = div - 1; > > + /* > > + * Program the DCM DRP > > + * Step 1: Assert DCM Reset > > + * Step 2: Program the mul and div values in DRP > > + * Step 3: Read from DRP base 0x00 to restore DCM output as per > > + * www.xilinx.com/support/documentation/user_guides/ug191.pdf > > + * Step 4: De-Assert reset to DCM > > + */ > > + mask = SDHC_BCLK_DCM_RST; > > + snps_reset_dcm(host, mask, 1); > > + > > + mul_div_val = (mul_val << 8) | div_val; > > + sdhci_writew(host, mul_div_val, BCLK_DCM_MUL_DIV_DRP); > > + > > + reg = sdhci_readl(host, BCLK_DCM_DRP_BASE_51); > > + > > + snps_reset_dcm(host, mask, 0); > > + > > + /* > > + * By Default Clocks to Controller are OFF. > > + * Before stack applies reset; we need to turn on the clock > > + */ > > + sdhci_writew(host, SDHCI_CLOCK_INT_EN, SDHCI_CLOCK_CONTROL); > > + > > + return 0; > > + > > +}