linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
To: Attila Kinali <attila-HB9FjVmMKa7tRgLqZ5aouw@public.gmane.org>
Cc: Fabio Estevam
	<fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Wolfgang Denk <wd-ynQEQJNshbs@public.gmane.org>,
	Detlev Zundel <dzu-ynQEQJNshbs@public.gmane.org>,
	Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
	Stefano Babic <sbabic-ynQEQJNshbs@public.gmane.org>,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Chris Ball <cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>,
	Dong Aisheng <b29396-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	Linux ARM kernel
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH 05/10] mmc: spi: Pull out the SSP clock configuration function
Date: Tue, 17 Jul 2012 23:48:34 +0200	[thread overview]
Message-ID: <201207172348.34919.marex@denx.de> (raw)
In-Reply-To: <20120717153901.5530a246a7a5fecfef03b373-HB9FjVmMKa7tRgLqZ5aouw@public.gmane.org>

Dear Attila Kinali,

> On Mon, 16 Jul 2012 14:09:52 +0200
> 
> Marek Vasut <marex-ynQEQJNshbs@public.gmane.org> wrote:
> > Pull out the MMC clock configuration function and make it
> > into SSP clock configuration function, so it can be used by
> > the SPI driver too.
> > 
> > diff --git a/drivers/clk/mxs/clk-ssp.c b/drivers/clk/mxs/clk-ssp.c
> > new file mode 100644
> > index 0000000..b3c1e16
> > --- /dev/null
> > +++ b/drivers/clk/mxs/clk-ssp.c
> > @@ -0,0 +1,61 @@
> > +/*
> > + * Copyright 2012 DENX Software Engineering, GmbH
> > + *
> > + * Pulled from code:
> > + * Portions copyright (C) 2003 Russell King, PXA MMCI Driver
> > + * Portions copyright (C) 2004-2005 Pierre Ossman, W83L51xD SD/MMC
> > driver + *
> > + * Copyright 2008 Embedded Alley Solutions, Inc.
> > + * Copyright 2009-2011 Freescale Semiconductor, Inc.
> > + *
> > + * The code contained herein is licensed under the GNU General Public
> > + * License. You may obtain a copy of the GNU General Public License
> > + * Version 2 or later at the following locations:
> > + *
> > + * http://www.opensource.org/licenses/gpl-license.html
> > + * http://www.gnu.org/copyleft/gpl.html
> > + */
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/init.h>
> > +#include <linux/clk.h>
> > +#include <linux/module.h>
> > +#include <linux/device.h>
> > +#include <linux/io.h>
> > +#include <linux/spi/mxs-spi.h>
> > +
> > +void mxs_ssp_set_clk_rate(struct mxs_ssp *ssp, unsigned int rate)
> > +{
> > +	unsigned int ssp_clk, ssp_sck;
> > +	u32 clock_divide, clock_rate;
> > +	u32 val;
> > +
> > +	ssp_clk = clk_get_rate(ssp->clk);
> > +
> > +	for (clock_divide = 2; clock_divide <= 254; clock_divide += 2) {
> > +		clock_rate = DIV_ROUND_UP(ssp_clk, rate * clock_divide);
> > +		clock_rate = (clock_rate > 0) ? clock_rate - 1 : 0;
> > +		if (clock_rate <= 255)
> > +			break;
> > +	}
> > +
> > +	if (clock_divide > 254) {
> > +		dev_err(ssp->dev,
> > +			"%s: cannot set clock to %d\n", __func__, rate);
> > +		return;
> > +	}
> > +
> > +	ssp_sck = ssp_clk / clock_divide / (1 + clock_rate);
> > +
> > +	val = readl(ssp->base + HW_SSP_TIMING(ssp));
> > +	val &= ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE);
> > +	val |= BF_SSP(clock_divide, TIMING_CLOCK_DIVIDE);
> > +	val |= BF_SSP(clock_rate, TIMING_CLOCK_RATE);
> > +	writel(val, ssp->base + HW_SSP_TIMING(ssp));
> > +
> > +	ssp->clk_rate = ssp_sck;
> > +
> > +	dev_dbg(ssp->dev,
> > +		"%s: clock_divide %d, clock_rate %d, ssp_clk %d, rate_actual %d,
> > rate_requested %d\n", +		__func__, clock_divide, clock_rate, 
ssp_clk,
> > ssp_sck, rate);
> > +}
> 
> There is a EXPORT_SYMBOL_GPL(mxs_ssp_set_clk_rate); missing here.

What for?

Best regards,
Marek Vasut

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

  parent reply	other threads:[~2012-07-17 21:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-16 12:09 [PATCH 00/10] MXS SPI driver Marek Vasut
     [not found] ` <1342440597-8395-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
2012-07-16 12:09   ` [PATCH 01/10] mmc: spi: Move SSP register definitions into separate file Marek Vasut
2012-07-16 12:09   ` [PATCH 02/10] mmc: spi: Rename IMX2[38]_MMC to IMX2[38]_SSP Marek Vasut
2012-07-16 12:09   ` [PATCH 03/10] mmc: spi: Add necessary bits into mxs-spi.h Marek Vasut
2012-07-16 12:09   ` [PATCH 04/10] mmc: spi: Pull out parts shared between MMC and SPI Marek Vasut
2012-07-16 12:09   ` [PATCH 05/10] mmc: spi: Pull out the SSP clock configuration function Marek Vasut
     [not found]     ` <1342440597-8395-6-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
2012-07-17 13:39       ` Attila Kinali
     [not found]         ` <20120717153901.5530a246a7a5fecfef03b373-HB9FjVmMKa7tRgLqZ5aouw@public.gmane.org>
2012-07-17 21:48           ` Marek Vasut [this message]
     [not found]             ` <201207172348.34919.marex-ynQEQJNshbs@public.gmane.org>
2012-07-18  6:07               ` Attila Kinali
     [not found]                 ` <20120718080755.cf7d4ac2e423278ce12843e6-HB9FjVmMKa7tRgLqZ5aouw@public.gmane.org>
2012-07-18  8:40                   ` Marek Vasut
2012-07-16 12:09   ` [PATCH 06/10] spi: Add SPI driver for mx233/mx28 Marek Vasut
2012-07-16 12:09   ` [PATCH 07/10] mmc: spi: Pull out common DMA parts from MXS MMC Marek Vasut
2012-07-16 12:09   ` [PATCH 08/10] spi: Add DMA support into SPI driver Marek Vasut
2012-07-16 12:09   ` [PATCH 09/10] spi: Add SSP/SPI device tree documentation Marek Vasut
2012-07-16 12:09   ` [PATCH 10/10] ARM: mx28: Add SPI pinmux into imx28.dtsi Marek Vasut
2012-07-17 15:31   ` [PATCH 00/10] MXS SPI driver Mark Brown
     [not found]     ` <20120717153110.GC3107-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-07-17 22:09       ` Marek Vasut
     [not found]         ` <201207180009.54189.marex-ynQEQJNshbs@public.gmane.org>
2012-07-18 11:10           ` Mark Brown
     [not found]             ` <20120718111049.GA9923-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-07-18 13:37               ` Marek Vasut
2012-08-03 15:26 [PATCH 00/10 V3] " Marek Vasut
     [not found] ` <1344007575-11448-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
2012-08-03 15:26   ` [PATCH 05/10] mmc: spi: Pull out the SSP clock configuration function Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201207172348.34919.marex@denx.de \
    --to=marex-ynqeqjnshbs@public.gmane.org \
    --cc=attila-HB9FjVmMKa7tRgLqZ5aouw@public.gmane.org \
    --cc=b29396-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org \
    --cc=dzu-ynQEQJNshbs@public.gmane.org \
    --cc=fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=sbabic-ynQEQJNshbs@public.gmane.org \
    --cc=shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=wd-ynQEQJNshbs@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).