2018-05-16 11:50:40 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 BayLibre, SAS.
|
|
|
|
* Author: Jerome Brunet <jbrunet@baylibre.com>
|
|
|
|
*/
|
2018-02-12 17:58:32 +03: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 00:40:15 +03:00
|
|
|
extern const struct clk_ops clk_regmap_gate_ro_ops;
|
2018-02-12 17:58:32 +03: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-02-01 17:53:44 +03:00
|
|
|
#define __MESON_GATE(_name, _reg, _bit, _ops) \
|
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 15:58:41 +03: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 17:53:44 +03:00
|
|
|
.ops = _ops, \
|
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 15:58:41 +03:00
|
|
|
.parent_names = (const char *[]){ "clk81" }, \
|
|
|
|
.num_parents = 1, \
|
|
|
|
.flags = (CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED), \
|
|
|
|
}, \
|
|
|
|
}
|
|
|
|
|
2019-02-01 17:53:44 +03:00
|
|
|
#define MESON_GATE(_name, _reg, _bit) \
|
|
|
|
__MESON_GATE(_name, _reg, _bit, &clk_regmap_gate_ops)
|
|
|
|
|
|
|
|
#define MESON_GATE_RO(_name, _reg, _bit) \
|
|
|
|
__MESON_GATE(_name, _reg, _bit, &clk_regmap_gate_ro_ops)
|
2018-02-12 17:58:32 +03:00
|
|
|
#endif /* __CLK_REGMAP_H */
|