clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/clk-provider.h>
|
2013-03-29 03:31:27 +07:00
|
|
|
#include <linux/export.h>
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
|
|
|
#include "clk.h"
|
|
|
|
|
|
|
|
static u8 clk_periph_get_parent(struct clk_hw *hw)
|
|
|
|
{
|
|
|
|
struct tegra_clk_periph *periph = to_clk_periph(hw);
|
|
|
|
const struct clk_ops *mux_ops = periph->mux_ops;
|
|
|
|
struct clk_hw *mux_hw = &periph->mux.hw;
|
|
|
|
|
2015-02-12 20:58:30 +07:00
|
|
|
__clk_hw_set_clk(mux_hw, hw);
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
|
|
|
|
return mux_ops->get_parent(mux_hw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clk_periph_set_parent(struct clk_hw *hw, u8 index)
|
|
|
|
{
|
|
|
|
struct tegra_clk_periph *periph = to_clk_periph(hw);
|
|
|
|
const struct clk_ops *mux_ops = periph->mux_ops;
|
|
|
|
struct clk_hw *mux_hw = &periph->mux.hw;
|
|
|
|
|
2015-02-12 20:58:30 +07:00
|
|
|
__clk_hw_set_clk(mux_hw, hw);
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
|
|
|
|
return mux_ops->set_parent(mux_hw, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long clk_periph_recalc_rate(struct clk_hw *hw,
|
|
|
|
unsigned long parent_rate)
|
|
|
|
{
|
|
|
|
struct tegra_clk_periph *periph = to_clk_periph(hw);
|
|
|
|
const struct clk_ops *div_ops = periph->div_ops;
|
|
|
|
struct clk_hw *div_hw = &periph->divider.hw;
|
|
|
|
|
2015-02-12 20:58:30 +07:00
|
|
|
__clk_hw_set_clk(div_hw, hw);
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
|
|
|
|
return div_ops->recalc_rate(div_hw, parent_rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static long clk_periph_round_rate(struct clk_hw *hw, unsigned long rate,
|
|
|
|
unsigned long *prate)
|
|
|
|
{
|
|
|
|
struct tegra_clk_periph *periph = to_clk_periph(hw);
|
|
|
|
const struct clk_ops *div_ops = periph->div_ops;
|
|
|
|
struct clk_hw *div_hw = &periph->divider.hw;
|
|
|
|
|
2015-02-12 20:58:30 +07:00
|
|
|
__clk_hw_set_clk(div_hw, hw);
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
|
|
|
|
return div_ops->round_rate(div_hw, rate, prate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clk_periph_set_rate(struct clk_hw *hw, unsigned long rate,
|
|
|
|
unsigned long parent_rate)
|
|
|
|
{
|
|
|
|
struct tegra_clk_periph *periph = to_clk_periph(hw);
|
|
|
|
const struct clk_ops *div_ops = periph->div_ops;
|
|
|
|
struct clk_hw *div_hw = &periph->divider.hw;
|
|
|
|
|
2015-02-12 20:58:30 +07:00
|
|
|
__clk_hw_set_clk(div_hw, hw);
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
|
|
|
|
return div_ops->set_rate(div_hw, rate, parent_rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clk_periph_is_enabled(struct clk_hw *hw)
|
|
|
|
{
|
|
|
|
struct tegra_clk_periph *periph = to_clk_periph(hw);
|
|
|
|
const struct clk_ops *gate_ops = periph->gate_ops;
|
|
|
|
struct clk_hw *gate_hw = &periph->gate.hw;
|
|
|
|
|
2015-02-12 20:58:30 +07:00
|
|
|
__clk_hw_set_clk(gate_hw, hw);
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
|
|
|
|
return gate_ops->is_enabled(gate_hw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clk_periph_enable(struct clk_hw *hw)
|
|
|
|
{
|
|
|
|
struct tegra_clk_periph *periph = to_clk_periph(hw);
|
|
|
|
const struct clk_ops *gate_ops = periph->gate_ops;
|
|
|
|
struct clk_hw *gate_hw = &periph->gate.hw;
|
|
|
|
|
2015-02-12 20:58:30 +07:00
|
|
|
__clk_hw_set_clk(gate_hw, hw);
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
|
|
|
|
return gate_ops->enable(gate_hw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clk_periph_disable(struct clk_hw *hw)
|
|
|
|
{
|
|
|
|
struct tegra_clk_periph *periph = to_clk_periph(hw);
|
|
|
|
const struct clk_ops *gate_ops = periph->gate_ops;
|
|
|
|
struct clk_hw *gate_hw = &periph->gate.hw;
|
|
|
|
|
|
|
|
gate_ops->disable(gate_hw);
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2013-10-08 18:17:42 +07:00
|
|
|
static const struct clk_ops tegra_clk_periph_nodiv_ops = {
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
.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,
|
|
|
|
};
|
|
|
|
|
2014-01-15 12:43:25 +07:00
|
|
|
static const struct clk_ops tegra_clk_periph_no_gate_ops = {
|
2013-11-18 22:11:38 +07:00
|
|
|
.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,
|
|
|
|
};
|
|
|
|
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
static struct clk *_tegra_clk_register_periph(const char *name,
|
2017-02-28 21:37:19 +07:00
|
|
|
const char * const *parent_names, int num_parents,
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
struct tegra_clk_periph *periph,
|
2013-09-02 22:43:56 +07:00
|
|
|
void __iomem *clk_base, u32 offset,
|
2013-04-03 21:40:42 +07:00
|
|
|
unsigned long flags)
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
{
|
|
|
|
struct clk *clk;
|
|
|
|
struct clk_init_data init;
|
2015-04-20 19:38:39 +07:00
|
|
|
const struct tegra_clk_periph_regs *bank;
|
2013-09-02 22:43:56 +07:00
|
|
|
bool div = !(periph->gate.flags & TEGRA_PERIPH_NO_DIV);
|
|
|
|
|
2013-11-18 22:11:38 +07:00
|
|
|
if (periph->gate.flags & TEGRA_PERIPH_NO_DIV) {
|
|
|
|
flags |= CLK_SET_RATE_PARENT;
|
|
|
|
init.ops = &tegra_clk_periph_nodiv_ops;
|
|
|
|
} else if (periph->gate.flags & TEGRA_PERIPH_NO_GATE)
|
|
|
|
init.ops = &tegra_clk_periph_no_gate_ops;
|
|
|
|
else
|
|
|
|
init.ops = &tegra_clk_periph_ops;
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
|
|
|
|
init.name = name;
|
2013-04-03 21:40:42 +07:00
|
|
|
init.flags = flags;
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
init.parent_names = parent_names;
|
|
|
|
init.num_parents = num_parents;
|
|
|
|
|
2013-08-22 22:44:06 +07:00
|
|
|
bank = get_reg_bank(periph->gate.clk_num);
|
|
|
|
if (!bank)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
/* Data in .init is copied by clk_register(), so stack variable OK */
|
|
|
|
periph->hw.init = &init;
|
|
|
|
periph->magic = TEGRA_CLK_PERIPH_MAGIC;
|
|
|
|
periph->mux.reg = clk_base + offset;
|
|
|
|
periph->divider.reg = div ? (clk_base + offset) : NULL;
|
|
|
|
periph->gate.clk_base = clk_base;
|
2013-08-22 22:44:06 +07:00
|
|
|
periph->gate.regs = bank;
|
2013-09-02 19:22:02 +07:00
|
|
|
periph->gate.enable_refcnt = periph_clk_enb_refcnt;
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
|
|
|
|
clk = clk_register(NULL, &periph->hw);
|
|
|
|
if (IS_ERR(clk))
|
|
|
|
return clk;
|
|
|
|
|
|
|
|
periph->mux.hw.clk = clk;
|
|
|
|
periph->divider.hw.clk = div ? clk : NULL;
|
|
|
|
periph->gate.hw.clk = clk;
|
|
|
|
|
|
|
|
return clk;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct clk *tegra_clk_register_periph(const char *name,
|
2017-02-28 21:37:19 +07:00
|
|
|
const char * const *parent_names, int num_parents,
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
struct tegra_clk_periph *periph, void __iomem *clk_base,
|
2013-04-03 21:40:42 +07:00
|
|
|
u32 offset, unsigned long flags)
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
{
|
|
|
|
return _tegra_clk_register_periph(name, parent_names, num_parents,
|
2013-09-02 22:43:56 +07:00
|
|
|
periph, clk_base, offset, flags);
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
struct clk *tegra_clk_register_periph_nodiv(const char *name,
|
2017-03-20 23:14:14 +07:00
|
|
|
const char * const *parent_names, int num_parents,
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
struct tegra_clk_periph *periph, void __iomem *clk_base,
|
|
|
|
u32 offset)
|
|
|
|
{
|
2013-09-02 22:43:56 +07:00
|
|
|
periph->gate.flags |= TEGRA_PERIPH_NO_DIV;
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
return _tegra_clk_register_periph(name, parent_names, num_parents,
|
2013-09-02 22:43:56 +07:00
|
|
|
periph, clk_base, offset, CLK_SET_RATE_PARENT);
|
clk: tegra: add Tegra specific clocks
Add Tegra specific clocks, pll, pll_out, peripheral, frac_divider, super.
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
[swarren: alloc sizeof(*foo) not sizeof(struct foo), add comments re:
storing pointers to stack variables, make a timeout loop more idiomatic,
use _clk_pll_disable() not clk_disable_pll() from _program_pll() to
avoid redundant lock operations, unified tegra_clk_periph() and
tegra_clk_periph_nodiv(), unified tegra_clk_pll{,e}, rename all clock
registration functions so they don't have the same name as the clock
structs, return -EINVAL from clk_plle_enable when matching table rate
not found, pass ops to _tegra_clk_register_pll rather than a bool.]
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 14:46:20 +07:00
|
|
|
}
|
2017-08-30 17:11:53 +07:00
|
|
|
|
|
|
|
struct clk *tegra_clk_register_periph_data(void __iomem *clk_base,
|
|
|
|
struct tegra_periph_init_data *init)
|
|
|
|
{
|
|
|
|
return _tegra_clk_register_periph(init->name, init->p.parent_names,
|
|
|
|
init->num_parents, &init->periph,
|
|
|
|
clk_base, init->offset, init->flags);
|
|
|
|
}
|