All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
To: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: linux-tegra@vger.kernel.org,
	Javier Martinez Canillas <javier.martinez@collabora.co.uk>,
	mikko.perttunen@kapsi.fi, acourbot@nvidia.com,
	Mikko Perttunen <mperttunen@nvidia.com>,
	Peter De Schrijver <pdeschrijver@nvidia.com>,
	Prashant Gaikwad <pgaikwad@nvidia.com>,
	Mike Turquette <mturquette@linaro.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Alexandre Courbot <gnurou@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 12/14] clk: tegra: Add EMC clock driver
Date: Wed, 19 Nov 2014 16:29:53 +0100	[thread overview]
Message-ID: <20141119152941.GA26442@avionic-0071.adnet.avionic-design.de> (raw)
In-Reply-To: <1416312860-4446-13-git-send-email-tomeu.vizoso@collabora.com>

On Tue, Nov 18, 2014 at 01:13:14PM +0100, Tomeu Vizoso wrote:
> From: Mikko Perttunen <mperttunen@nvidia.com>
> 
> The driver is currently only tested on Tegra124 Jetson TK1, but should
> work with other Tegra124 boards, provided that correct EMC tables are
> provided through the device tree. Older chip models have differing
> timing change sequences, so they are not currently supported.
> 
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> 
> ---
> 
> v5:	* Get a pointer to the EMC driver at runtime, to be used when
> 	  calling the EMC API.
> 	* Misc. style fixes
> 	* Fix logic for rounding down to a high rate
> 
> v4:	* Adapt to changes in the OF bindings
> 	* Improve error handling
> 	* Fix comment style
> 	* Make static a few more functions
> 
> v3:	* Add some locking to protect the registers that are shared with the MC
> 	  clock
> 
> v2:	* Make sure that the clock is properly registered
> 	* Bail out early from attempts to set the same rate
> ---
> diff --git a/drivers/clk/tegra/clk-emc.c b/drivers/clk/tegra/clk-emc.c
> new file mode 100644
> index 0000000..399d945
> --- /dev/null
> +++ b/drivers/clk/tegra/clk-emc.c
> @@ -0,0 +1,532 @@
> +/*
> + * Rounds up unless no higher rate exists, in which case down. This way is
> + * safer since things have EMC rate floors. Also don't touch parent_rate
> + * since we don't want the CCF to play with our parent clocks.
> + */
> +static long emc_round_rate(struct clk_hw *hw, unsigned long rate,
> +		    unsigned long *parent_rate)
> +{
> +	struct tegra_clk_emc *tegra;
> +	u8 ram_code = tegra_read_ram_code();
> +	struct emc_timing *timing;
> +	int i;
> +
> +	tegra = container_of(hw, struct tegra_clk_emc, hw);
> +
> +	for (i = 0; i < tegra->num_timings; i++) {
> +		timing = tegra->timings + i;
> +		if (timing->ram_code != ram_code)
> +			continue;
> +
> +		if (timing->rate >= rate)
> +			return timing->rate;
> +	}
> +
> +	for (i = tegra->num_timings - 1; i >= 0; i--) {
> +		timing = tegra->timings + i;
> +		if (timing->ram_code != ram_code)
> +			continue;
> +
> +		return timing->rate;
> +	}

While this is technically not wrong, it could be simplified to something
like

        struct emc_timing *timing = NULL;

        for (i = 0; i < tegra->num_timings; i++) {
                if (tegra->timings[i].ram_code != ram_code)
                        continue;
                timing = tegra->timings + i;
                if (timing->rate >= rate)
                        return timing->rate;
        }
        if (timing)
                return timing->rate;

> +
> +	return __clk_get_rate(hw->clk);
> +}

  parent reply	other threads:[~2014-11-19 15:29 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18 12:13 [PATCH v5 00/14] Tegra124 EMC (external memory controller) support Tomeu Vizoso
2014-11-18 12:13 ` Tomeu Vizoso
2014-11-18 12:13 ` Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 01/14] clk: tegra124: Remove old emc clock Tomeu Vizoso
2014-11-18 21:23   ` Mike Turquette
2014-11-18 21:23     ` Mike Turquette
2014-11-18 12:13 ` [PATCH v5 02/14] of: Document long-ram-code property in nvidia,tegra20-apbmisc Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 03/14] soc/tegra: Add ram code reader helper Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 04/14] of: document new emc-timings subnode in nvidia,tegra124-car Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 05/14] of: Document timings subnode of nvidia,tegra-mc Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 06/14] of: Add Tegra124 EMC bindings Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 07/14] of: document external-memory-controller property in tegra124-car Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 08/14] ARM: tegra: Add EMC to Tegra124 device tree Tomeu Vizoso
2014-11-18 12:13   ` Tomeu Vizoso
2014-11-18 12:13   ` Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 09/14] ARM: tegra: Add EMC timings to Jetson TK1 " Tomeu Vizoso
2014-11-18 12:13   ` Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 10/14] memory: tegra: Add API needed by the EMC driver Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 11/14] memory: tegra: Add EMC (external memory controller) driver Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 12/14] clk: tegra: Add EMC clock driver Tomeu Vizoso
2014-11-18 21:33   ` Mike Turquette
2014-11-18 21:33     ` Mike Turquette
2014-11-19 15:29   ` Nikolaus Schulz [this message]
     [not found]   ` <1416312860-4446-13-git-send-email-tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2015-01-02 16:27     ` Peter De Schrijver
2015-01-02 16:27       ` Peter De Schrijver
2015-01-05 13:59       ` Thierry Reding
     [not found]         ` <20150105135912.GB12010-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-03-12  9:30           ` Tomeu Vizoso
2015-03-12  9:30             ` Tomeu Vizoso
2014-11-18 12:13 ` [PATCH v5 13/14] memory: tegra: Add debugfs entry for getting and setting the EMC rate Tomeu Vizoso
     [not found] ` <1416312860-4446-1-git-send-email-tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2014-11-18 12:13   ` [PATCH v5 14/14] clk: tegra: Set the EMC clock as the parent of the MC clock Tomeu Vizoso
2014-11-18 12:13     ` Tomeu Vizoso
     [not found]     ` <1416312860-4446-15-git-send-email-tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2014-11-18 21:35       ` Mike Turquette
2014-11-18 21:35         ` Mike Turquette

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=20141119152941.GA26442@avionic-0071.adnet.avionic-design.de \
    --to=nikolaus.schulz@avionic-design.de \
    --cc=acourbot@nvidia.com \
    --cc=gnurou@gmail.com \
    --cc=javier.martinez@collabora.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mikko.perttunen@kapsi.fi \
    --cc=mperttunen@nvidia.com \
    --cc=mturquette@linaro.org \
    --cc=pdeschrijver@nvidia.com \
    --cc=pgaikwad@nvidia.com \
    --cc=swarren@wwwdotorg.org \
    --cc=thierry.reding@gmail.com \
    --cc=tomeu.vizoso@collabora.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.