From: Hiroshi Doyu <hdoyu@nvidia.com>
To: "swarren@wwwdotorg.org" <swarren@wwwdotorg.org>,
Prashant Gaikwad <pgaikwad@nvidia.com>
Cc: "mturquette@linaro.org" <mturquette@linaro.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/9] clk: tegra: Add tegra specific clocks
Date: Wed, 16 Jan 2013 13:31:51 +0100 [thread overview]
Message-ID: <20130116.143151.1531468192773974887.hdoyu@nvidia.com> (raw)
In-Reply-To: <1357890387-23245-3-git-send-email-pgaikwad@nvidia.com>
Prashant Gaikwad <pgaikwad@nvidia.com> wrote @ Fri, 11 Jan 2013 08:46:20 +0100:
...
> +const struct clk_ops tegra_clk_periph_ops = {
> + .get_parent = clk_periph_get_parent,
> + .set_parent = clk_periph_set_parent,
> + .recalc_rate = clk_periph_recalc_rate,
> + .round_rate = clk_periph_round_rate,
> + .set_rate = clk_periph_set_rate,
> + .is_enabled = clk_periph_is_enabled,
> + .enable = clk_periph_enable,
> + .disable = clk_periph_disable,
> +};
> +
> +const struct clk_ops tegra_clk_periph_nodiv_ops = {
> + .get_parent = clk_periph_get_parent,
> + .set_parent = clk_periph_set_parent,
> + .is_enabled = clk_periph_is_enabled,
> + .enable = clk_periph_enable,
> + .disable = clk_periph_disable,
> +};
> +
> +struct clk *tegra_clk_periph(const char *name, const char **parent_names,
> + int num_parents, struct tegra_clk_periph *periph,
> + void __iomem *clk_base, u32 offset)
> +{
> + struct clk *clk;
> + struct clk_init_data init;
> +
> + init.name = name;
> + init.ops = &tegra_clk_periph_ops;
> + init.flags = 0;
> + init.parent_names = parent_names;
> + init.num_parents = num_parents;
> +
> + periph->hw.init = &init;
> + periph->magic = TEGRA_CLK_PERIPH_MAGIC;
> + periph->mux.reg = clk_base + offset;
> + periph->divider.reg = clk_base + offset;
> + periph->gate.clk_base = clk_base;
> +
> + clk = clk_register(NULL, &periph->hw);
> + if (IS_ERR(clk))
> + return clk;
> +
> + periph->mux.hw.clk = clk;
> + periph->divider.hw.clk = clk;
> + periph->gate.hw.clk = clk;
> +
> + return clk;
> +}
> +
> +struct clk *tegra_clk_periph_nodiv(const char *name, const char **parent_names,
> + int num_parents, struct tegra_clk_periph *periph,
> + void __iomem *clk_base, u32 offset)
> +{
> + struct clk *clk;
> + struct clk_init_data init;
> +
> + init.name = name;
> + init.ops = &tegra_clk_periph_nodiv_ops;
> + init.flags = CLK_SET_RATE_PARENT;
> + init.parent_names = parent_names;
> + init.num_parents = num_parents;
> +
> + periph->hw.init = &init;
> + periph->magic = TEGRA_CLK_PERIPH_MAGIC;
> + periph->mux.reg = clk_base + offset;
> + periph->gate.clk_base = clk_base;
> +
> + clk = clk_register(NULL, &periph->hw);
> + if (IS_ERR(clk))
> + return clk;
> +
> + periph->mux.hw.clk = clk;
> + periph->gate.hw.clk = clk;
> +
> + return clk;
> +}
The above two functions are almost duplicate, can we take the common part from them?
const struct clk_ops tegra_clk_periph_nodiv_ops = {
.get_parent = clk_periph_get_parent,
.set_parent = clk_periph_set_parent,
.is_enabled = clk_periph_is_enabled,
.enable = clk_periph_enable,
.disable = clk_periph_disable,
};
struct clk *__tegra_clk_periph(const char *name, const char **parent_names,
int num_parents, struct tegra_clk_periph *periph,
void __iomem *clk_base, u32 offset, int div)
{
struct clk *clk;
struct clk_init_data init;
init.name = name;
init.parent_names = parent_names;
init.num_parents = num_parents;
init.ops = div ? &tegra_clk_periph_ops : &tegra_clk_periph_nodiv_ops
init.flags = div ? 0 : CLK_SET_RATE_PARENT;
periph->hw.init = &init;
periph->magic = TEGRA_CLK_PERIPH_MAGIC;
periph->mux.reg = clk_base + offset;
periph->divider.reg = clk_base + offset;
periph->gate.clk_base = clk_base;
clk = clk_register(NULL, &periph->hw);
if (IS_ERR(clk))
return clk;
periph->mux.hw.clk = clk;
periph->divider.hw.clk = div ? NULL : clk;
periph->gate.hw.clk = clk;
return clk;
}
static inline struct clk *tegra_clk_periph(const char *name, const char **parent_names,
int num_parents, struct tegra_clk_periph *periph,
void __iomem *clk_base, u32 offset)
{
return __tegra_clk_periph(name, parent_names, num_parents, periph, clk_base, offset, 1);
}
static inline struct clk *tegra_clk_periph_nodiv(const char *name, const char **parent_names,
int num_parents, struct tegra_clk_periph *periph,
void __iomem *clk_base, u32 offset, )
{
return __tegra_clk_periph(name, parent_names, num_parents, periph, clk_base, offset, 0);
}
next prev parent reply other threads:[~2013-01-16 12:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-11 7:46 [PATCH v4 0/9] Migrate Tegra to common clock framework Prashant Gaikwad
2013-01-11 7:46 ` [PATCH v4 1/9] ARM: tegra: Add function to read chipid Prashant Gaikwad
2013-01-11 7:46 ` [PATCH v4 2/9] clk: tegra: Add tegra specific clocks Prashant Gaikwad
2013-01-11 11:48 ` Hiroshi Doyu
2013-01-11 21:35 ` Stephen Warren
2013-01-16 8:19 ` Hiroshi Doyu
2013-01-16 18:04 ` Stephen Warren
2013-01-14 7:28 ` Sivaram Nair
2013-01-16 12:31 ` Hiroshi Doyu [this message]
2013-01-16 18:44 ` Stephen Warren
2013-01-16 15:12 ` Hiroshi Doyu
2013-01-16 20:11 ` Stephen Warren
2013-01-17 5:03 ` Hiroshi Doyu
2013-01-17 16:35 ` Stephen Warren
2013-01-11 7:46 ` [PATCH v4 3/9] arm: tegra: Move tegra_cpu_car.h to linux/clk/tegra.h Prashant Gaikwad
2013-01-11 7:46 ` [PATCH v4 4/9] ARM: tegra: Define Tegra20 CAR binding Prashant Gaikwad
2013-01-11 7:46 ` [PATCH v4 5/9] ARM: Tegra: Define Tegra30 " Prashant Gaikwad
2013-01-16 11:28 ` Hiroshi Doyu
2013-01-16 17:30 ` Stephen Warren
2013-01-11 7:46 ` [PATCH v4 6/9] clk: tegra: add clock support for tegra20 Prashant Gaikwad
2013-01-11 20:54 ` Stephen Warren
2013-01-11 7:46 ` [PATCH v4 7/9] clk: tegra: add clock support for tegra30 Prashant Gaikwad
2013-01-11 12:17 ` Hiroshi Doyu
2013-01-11 21:40 ` Stephen Warren
2013-01-14 5:33 ` Hiroshi Doyu
2013-01-11 7:46 ` [PATCH v4 8/9] arm: tegra: Migrate to new clock code Prashant Gaikwad
2013-01-11 7:46 ` [PATCH v4 9/9] arm: tegra: Remove legacy " Prashant Gaikwad
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=20130116.143151.1531468192773974887.hdoyu@nvidia.com \
--to=hdoyu@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=pgaikwad@nvidia.com \
--cc=swarren@wwwdotorg.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
all inboxes | Powered by JetHome®