u-boot/include/clk/sunxi.h
Andre Przywara d6cb09d89d clk: sunxi: add and use dummy gate clocks
Some devices enumerate various clocks in their DT, and many drivers
just blanketly try to enable all of them. This creates problems
since we only model a few gate clocks, and the clock driver outputs
a warning when a clock is not described:
=========
sunxi_set_gate: (CLK#3) unhandled
=========

Some clocks don't have an enable bit, or are already enabled in a
different way, so we might want to just ignore them.

Add a CCU_CLK_F_DUMMY_GATE flag that indicates that case, and define
a GATE_DUMMY macro that can be used in the clock description array.
Define a few clocks, used by some pinctrl devices, that way to suppress
the runtime warnings.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
2022-05-24 01:16:15 +01:00

104 lines
1.8 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2018 Amarula Solutions.
* Author: Jagan Teki <jagan@amarulasolutions.com>
*/
#ifndef _CLK_SUNXI_H
#define _CLK_SUNXI_H
#include <linux/bitops.h>
/**
* enum ccu_flags - ccu clock/reset flags
*
* @CCU_CLK_F_IS_VALID: is given clock gate is valid?
* @CCU_RST_F_IS_VALID: is given reset control is valid?
*/
enum ccu_flags {
CCU_CLK_F_IS_VALID = BIT(0),
CCU_RST_F_IS_VALID = BIT(1),
CCU_CLK_F_DUMMY_GATE = BIT(2),
};
/**
* struct ccu_clk_gate - ccu clock gate
* @off: gate offset
* @bit: gate bit
* @flags: ccu clock gate flags
*/
struct ccu_clk_gate {
u16 off;
u32 bit;
enum ccu_flags flags;
};
#define GATE(_off, _bit) { \
.off = _off, \
.bit = _bit, \
.flags = CCU_CLK_F_IS_VALID, \
}
#define GATE_DUMMY { \
.flags = CCU_CLK_F_DUMMY_GATE, \
}
/**
* struct ccu_reset - ccu reset
* @off: reset offset
* @bit: reset bit
* @flags: ccu reset control flags
*/
struct ccu_reset {
u16 off;
u32 bit;
enum ccu_flags flags;
};
#define RESET(_off, _bit) { \
.off = _off, \
.bit = _bit, \
.flags = CCU_RST_F_IS_VALID, \
}
/**
* struct ccu_desc - clock control unit descriptor
*
* @gates: clock gates
* @resets: reset unit
*/
struct ccu_desc {
const struct ccu_clk_gate *gates;
const struct ccu_reset *resets;
};
/**
* struct ccu_priv - sunxi clock control unit
*
* @base: base address
* @desc: ccu descriptor
*/
struct ccu_priv {
void *base;
const struct ccu_desc *desc;
};
/**
* sunxi_clk_probe - common sunxi clock probe
* @dev: clock device
*/
int sunxi_clk_probe(struct udevice *dev);
extern struct clk_ops sunxi_clk_ops;
/**
* sunxi_reset_bind() - reset binding
*
* @dev: reset device
* @count: reset count
* Return: 0 success, or error value
*/
int sunxi_reset_bind(struct udevice *dev, ulong count);
#endif /* _CLK_SUNXI_H */