2018-05-16 16:50:40 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 BayLibre, SAS.
|
|
|
|
* Author: Jerome Brunet <jbrunet@baylibre.com>
|
|
|
|
*/
|
2018-02-12 22:58:32 +08:00
|
|
|
|
|
|
|
#ifndef __CLK_REGMAP_H
|
|
|
|
#define __CLK_REGMAP_H
|
|
|
|
|
|
|
|
#include <linux/clk-provider.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct clk_regmap - regmap backed clock
|
|
|
|
*
|
|
|
|
* @hw: handle between common and hardware-specific interfaces
|
|
|
|
* @map: pointer to the regmap structure controlling the clock
|
|
|
|
* @data: data specific to the clock type
|
|
|
|
*
|
|
|
|
* Clock which is controlled by regmap backed registers. The actual type of
|
|
|
|
* of the clock is controlled by the clock_ops and data.
|
|
|
|
*/
|
|
|
|
struct clk_regmap {
|
|
|
|
struct clk_hw hw;
|
|
|
|
struct regmap *map;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define to_clk_regmap(_hw) container_of(_hw, struct clk_regmap, hw)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct clk_regmap_gate_data - regmap backed gate specific data
|
|
|
|
*
|
|
|
|
* @offset: offset of the register controlling gate
|
|
|
|
* @bit_idx: single bit controlling gate
|
|
|
|
* @flags: hardware-specific flags
|
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* Same as clk_gate except CLK_GATE_HIWORD_MASK which is ignored
|
|
|
|
*/
|
|
|
|
struct clk_regmap_gate_data {
|
|
|
|
unsigned int offset;
|
|
|
|
u8 bit_idx;
|
|
|
|
u8 flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct clk_regmap_gate_data *
|
|
|
|
clk_get_regmap_gate_data(struct clk_regmap *clk)
|
|
|
|
{
|
|
|
|
return (struct clk_regmap_gate_data *)clk->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern const struct clk_ops clk_regmap_gate_ops;
|
2018-11-23 05:40:15 +08:00
|
|
|
extern const struct clk_ops clk_regmap_gate_ro_ops;
|
2018-02-12 22:58:32 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct clk_regmap_div_data - regmap backed adjustable divider specific data
|
|
|
|
*
|
|
|
|
* @offset: offset of the register controlling the divider
|
|
|
|
* @shift: shift to the divider bit field
|
|
|
|
* @width: width of the divider bit field
|
|
|
|
* @table: array of value/divider pairs, last entry should have div = 0
|
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* Same as clk_divider except CLK_DIVIDER_HIWORD_MASK which is ignored
|
|
|
|
*/
|
|
|
|
struct clk_regmap_div_data {
|
|
|
|
unsigned int offset;
|
|
|
|
u8 shift;
|
|
|
|
u8 width;
|
|
|
|
u8 flags;
|
|
|
|
const struct clk_div_table *table;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct clk_regmap_div_data *
|
|
|
|
clk_get_regmap_div_data(struct clk_regmap *clk)
|
|
|
|
{
|
|
|
|
return (struct clk_regmap_div_data *)clk->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern const struct clk_ops clk_regmap_divider_ops;
|
|
|
|
extern const struct clk_ops clk_regmap_divider_ro_ops;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct clk_regmap_mux_data - regmap backed multiplexer clock specific data
|
|
|
|
*
|
|
|
|
* @hw: handle between common and hardware-specific interfaces
|
|
|
|
* @offset: offset of theregister controlling multiplexer
|
|
|
|
* @table: array of parent indexed register values
|
|
|
|
* @shift: shift to multiplexer bit field
|
|
|
|
* @mask: mask of mutliplexer bit field
|
|
|
|
* @flags: hardware-specific flags
|
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* Same as clk_divider except CLK_MUX_HIWORD_MASK which is ignored
|
|
|
|
*/
|
|
|
|
struct clk_regmap_mux_data {
|
|
|
|
unsigned int offset;
|
|
|
|
u32 *table;
|
|
|
|
u32 mask;
|
|
|
|
u8 shift;
|
|
|
|
u8 flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct clk_regmap_mux_data *
|
|
|
|
clk_get_regmap_mux_data(struct clk_regmap *clk)
|
|
|
|
{
|
|
|
|
return (struct clk_regmap_mux_data *)clk->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern const struct clk_ops clk_regmap_mux_ops;
|
|
|
|
extern const struct clk_ops clk_regmap_mux_ro_ops;
|
|
|
|
|
2019-07-26 00:42:36 +08:00
|
|
|
#define __MESON_PCLK(_name, _reg, _bit, _ops, _pname) \
|
clk: meson: rework and clean drivers dependencies
Initially, the meson clock directory only hosted 2 controllers drivers,
for meson8 and gxbb. At the time, both used the same set of clock drivers
so managing the dependencies was not a big concern.
Since this ancient time, entropy did its job, controllers with different
requirement and specific clock drivers have been added. Unfortunately, we
did not do a great job at managing the dependencies between the
controllers and the different clock drivers. Some drivers, such as
clk-phase or vid-pll-div, are compiled even if they are useless on the
target (meson8). As we are adding new controllers, we need to be able to
pick a driver w/o pulling the whole thing.
The patch aims to clean things up by:
* providing a dedicated CONFIG_ for each clock drivers
* allowing clock drivers to be compiled as a modules, if possible
* stating explicitly which drivers are required by each controller.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://lkml.kernel.org/r/20190201125841.26785-5-jbrunet@baylibre.com
2019-02-01 20:58:41 +08:00
|
|
|
struct clk_regmap _name = { \
|
|
|
|
.data = &(struct clk_regmap_gate_data){ \
|
|
|
|
.offset = (_reg), \
|
|
|
|
.bit_idx = (_bit), \
|
|
|
|
}, \
|
|
|
|
.hw.init = &(struct clk_init_data) { \
|
|
|
|
.name = #_name, \
|
2019-02-01 22:53:44 +08:00
|
|
|
.ops = _ops, \
|
2019-07-26 00:42:36 +08:00
|
|
|
.parent_hws = (const struct clk_hw *[]) { _pname }, \
|
clk: meson: rework and clean drivers dependencies
Initially, the meson clock directory only hosted 2 controllers drivers,
for meson8 and gxbb. At the time, both used the same set of clock drivers
so managing the dependencies was not a big concern.
Since this ancient time, entropy did its job, controllers with different
requirement and specific clock drivers have been added. Unfortunately, we
did not do a great job at managing the dependencies between the
controllers and the different clock drivers. Some drivers, such as
clk-phase or vid-pll-div, are compiled even if they are useless on the
target (meson8). As we are adding new controllers, we need to be able to
pick a driver w/o pulling the whole thing.
The patch aims to clean things up by:
* providing a dedicated CONFIG_ for each clock drivers
* allowing clock drivers to be compiled as a modules, if possible
* stating explicitly which drivers are required by each controller.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://lkml.kernel.org/r/20190201125841.26785-5-jbrunet@baylibre.com
2019-02-01 20:58:41 +08:00
|
|
|
.num_parents = 1, \
|
|
|
|
.flags = (CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED), \
|
|
|
|
}, \
|
|
|
|
}
|
|
|
|
|
2019-07-26 00:42:36 +08:00
|
|
|
#define MESON_PCLK(_name, _reg, _bit, _pname) \
|
|
|
|
__MESON_PCLK(_name, _reg, _bit, &clk_regmap_gate_ops, _pname)
|
2019-02-01 22:53:44 +08:00
|
|
|
|
2019-07-26 00:42:36 +08:00
|
|
|
#define MESON_PCLK_RO(_name, _reg, _bit, _pname) \
|
|
|
|
__MESON_PCLK(_name, _reg, _bit, &clk_regmap_gate_ro_ops, _pname)
|
2018-02-12 22:58:32 +08:00
|
|
|
#endif /* __CLK_REGMAP_H */
|