linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC/PATCH 03/10] [ARM] tegra: Add clock support
Date: Thu, 18 Mar 2010 08:42:05 +0000	[thread overview]
Message-ID: <20100318084205.GB8267@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1268721688-27550-4-git-send-email-konkers@google.com>

On Mon, Mar 15, 2010 at 11:41:21PM -0700, konkers at google.com wrote:
> From: Colin Cross <ccross@android.com>
> 
> Signed-off-by: Colin Cross <ccross@android.com>
> Signed-off-by: Erik Gilling <konkers@android.com>
> ---
>  arch/arm/Kconfig                          |    1 +
>  arch/arm/mach-tegra/Makefile              |    2 +
>  arch/arm/mach-tegra/clock.c               |  191 +++++++
>  arch/arm/mach-tegra/clock.h               |  103 ++++
>  arch/arm/mach-tegra/common.c              |    1 +
>  arch/arm/mach-tegra/include/mach/clkdev.h |   32 ++
>  arch/arm/mach-tegra/tegra2_clocks.c       |  837 +++++++++++++++++++++++++++++
>  7 files changed, 1167 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-tegra/clock.c
>  create mode 100644 arch/arm/mach-tegra/clock.h
>  create mode 100644 arch/arm/mach-tegra/include/mach/clkdev.h
>  create mode 100644 arch/arm/mach-tegra/tegra2_clocks.c
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 1232104..a5be2d6 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -576,6 +576,7 @@ config ARCH_TEGRA
>          select GENERIC_CLOCKEVENTS
>          select GENERIC_GPIO
>          select HAVE_CLK
> +        select COMMON_CLKDEV

These should be indented using tabs, not spaces.

> +/**
> + * clk_preinit - initialize any fields in the struct clk before clk init
> + * @clk: struct clk * to initialize
> + *
> + * Initialize any struct clk fields needed before normal clk initialization
> + * can run.  No return value.
> + */
> +void clk_preinit(struct clk *c)
> +{
> +	c->lock = __SPIN_LOCK_UNLOCKED(c->lock);

	spin_lock_init(&c->lock);

> +int clk_set_parent(struct clk *c, struct clk *parent)
> +{
> +	unsigned long flags;
> +	int ret = 0;
> +	spin_lock_irqsave(&c->lock, flags);
> +	if (c->ops && c->ops->set_parent)
> +		ret = c->ops->set_parent(c, parent);
> +	else
> +		BUG();

Does this condition really justify crashing the kernel?  Why not just
return an error?

> +int clk_set_rate(struct clk *c, unsigned long rate)
> +{
> +	int ret = 0;
> +	unsigned long flags;
> +	spin_lock_irqsave(&c->lock, flags);
> +	if (c->ops && c->ops->set_rate)
> +		ret = c->ops->set_rate(c, rate);
> +	else
> +		BUG();

Ditto.

> +unsigned long clk_get_rate(struct clk *c)
> +{
> +	int ret = 0;
> +	unsigned long flags;
> +	spin_lock_irqsave(&c->lock, flags);
> +	if (c->ops && c->ops->get_rate)
> +		ret = c->ops->get_rate(c);
> +	else if (c->parent)
> +		ret = clk_get_rate(c->parent);
> +	else
> +		BUG();

Ditto.

> +/* PLL Functions */
> +static int tegra2_pll_clk_set_rate(struct clk *c, unsigned long rate)
> +{
> +	u32 val;
> +	unsigned long input_rate;
> +	const struct clk_pll_table *sel;
> +
> +	pr_debug("%s on clock %s\n", __func__, c->name);
> +	/* BUG_ON(c->refcnt != 0); */
> +
> +	input_rate = clk_get_rate(c->parent);
> +	for (sel = c->pll_table; sel->input_rate != 0; sel++) {
> +		if (sel->input_rate == input_rate && sel->output_rate == rate) {
> +			c->n = sel->n;
> +			c->m = sel->m;
> +			c->p = sel->p;
> +			c->cpcon = sel->cpcon;
> +			val = clk_readl(c->reg + PLL_BASE);
> +			if (c->flags & PLL_FIXED)
> +				val |= PLL_BASE_OVERRIDE;
> +			val &= ~(PLL_BASE_DIVP_MASK | PLL_BASE_DIVN_MASK |
> +				 PLL_BASE_DIVM_MASK);
> +			val |= (c->m << PLL_BASE_DIVM_SHIFT) |
> +				(c->n << PLL_BASE_DIVN_SHIFT);
> +			BUG_ON(c->p > 2);
> +			if (c->p == 2)
> +				val |= 1 << PLL_BASE_DIVP_SHIFT;
> +			clk_writel(val, c->reg + PLL_BASE);
> +			c->rate = rate;
> +
> +			if (c->flags & PLL_HAS_CPCON) {
> +				val = c->cpcon << PLL_MISC_CPCON_SHIFT;
> +				clk_writel(val, c->reg + PLL_MISC);
> +			}
> +			return 0;
> +		}
> +	}
> +	return 1;

What's this 'return 1' on error and 'return 0' on  success?  The clk API
uses standard Linux error codes, which are negative constants on error.
Please use a standard constant from the errno.h headers.

  parent reply	other threads:[~2010-03-18  8:42 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-09 16:38 [RFC/PATCH] ARM: add Tegra support Mike Rapoport
2010-03-14  6:51 ` Mike Rapoport
2010-03-15  6:54   ` Thierry Reding
2010-03-15 16:16     ` Thierry Reding
2010-03-15 17:41 ` Gary King
2010-03-15 18:09 ` Russell King - ARM Linux
2010-03-15 22:38 ` Erik Gilling
2010-03-16  6:41   ` [RFC/PATCH 00/10] Tegra2 support konkers at google.com
2010-03-16  6:41     ` [RFC/PATCH 01/10] [ARM] tegra: initial tegra support konkers at google.com
2010-03-16  6:41       ` [RFC/PATCH 02/10] [ARM] tegra: Add IRQ support konkers at google.com
2010-03-16  6:41         ` [RFC/PATCH 03/10] [ARM] tegra: Add clock support konkers at google.com
2010-03-16  6:41           ` [RFC/PATCH 04/10] [ARM] tegra: SMP support konkers at google.com
2010-03-16  6:41             ` [RFC/PATCH 05/10] [ARM] tegra: Add timer support konkers at google.com
2010-03-16  6:41               ` [RFC/PATCH 06/10] [ARM] tegra: add GPIO support konkers at google.com
2010-03-16  6:41                 ` [RFC/PATCH 07/10] [ARM] tegra: add pinmux support konkers at google.com
2010-03-16  6:41                   ` [RFC/PATCH 08/10] [ARM] tegra: Add framebuffer driver konkers at google.com
2010-03-16  6:41                     ` [RFC/PATCH 09/10] [ARM] tegra: harmony: Add harmony board file konkers at google.com
2010-03-16  6:41                       ` [RFC/PATCH 10/10] [ARM] tegra: Add harmony_defconfig konkers at google.com
2010-03-17  8:21                       ` [RFC/PATCH 09/10] [ARM] tegra: harmony: Add harmony board file Mike Rapoport
2010-03-18  2:27                         ` Erik Gilling
2010-03-18 20:41                           ` mike at compulab.co.il
2010-03-16  7:57                     ` [RFC/PATCH 08/10] [ARM] tegra: Add framebuffer driver Jaya Kumar
2010-03-17  0:31                       ` Colin Cross
2010-03-18  8:47                     ` Russell King - ARM Linux
2010-03-18 23:57                       ` Colin Cross
2010-03-17  8:15                 ` [RFC/PATCH 06/10] [ARM] tegra: add GPIO support Mike Rapoport
2010-03-18  2:19                   ` Erik Gilling
2010-03-18  8:42           ` Russell King - ARM Linux [this message]
2010-03-18 23:57             ` [RFC/PATCH 03/10] [ARM] tegra: Add clock support Colin Cross
2010-03-17  7:57       ` [RFC/PATCH 01/10] [ARM] tegra: initial tegra support Mike Rapoport
2010-03-18  8:32     ` [RFC/PATCH 00/10] Tegra2 support Russell King - ARM Linux
2010-03-18 16:40       ` Erik Gilling
2010-03-18 20:30       ` Erik Gilling
2010-03-18 21:03         ` Erik Gilling
2010-03-16  8:49   ` [RFC/PATCH] ARM: add Tegra support Mike Rapoport
2010-03-16 13:44     ` Brian Swetland
2010-03-16 14:11       ` Mike Rapoport

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=20100318084205.GB8267@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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).