linux_dsm_epyc7002/include/trace/events/clk.h
Jerome Brunet 9fba738a53 clk: add duty cycle support
Add the possibility to apply and query the clock signal duty cycle ratio.

This is useful when the duty cycle of the clock signal depends on some
other parameters controlled by the clock framework.

For example, the duty cycle of a divider may depends on the raw divider
setting (ratio = N / div) , which is controlled by the CCF. In such case,
going through the pwm framework to control the duty cycle ratio of this
clock would be a burden.

A clock provider is not required to implement the operation to set and get
the duty cycle. If it does not implement .get_duty_cycle(), the ratio is
assumed to be 50%.

This change also adds a new flag, CLK_DUTY_CYCLE_PARENT. This flag should
be used to indicate that a clock, such as gates and muxes, may inherit
the duty cycle ratio of its parent clock. If a clock does not provide a
get_duty_cycle() callback and has CLK_DUTY_CYCLE_PARENT, then the call
will be directly forwarded to its parent clock, if any. For
set_duty_cycle(), the clock should also have CLK_SET_RATE_PARENT for the
call to be forwarded

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20180619144141.8506-1-jbrunet@baylibre.com
2018-06-19 10:06:29 -07:00

235 lines
4.5 KiB
C

/*
* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that 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.
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM clk
#if !defined(_TRACE_CLK_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_CLK_H
#include <linux/tracepoint.h>
struct clk_core;
DECLARE_EVENT_CLASS(clk,
TP_PROTO(struct clk_core *core),
TP_ARGS(core),
TP_STRUCT__entry(
__string( name, core->name )
),
TP_fast_assign(
__assign_str(name, core->name);
),
TP_printk("%s", __get_str(name))
);
DEFINE_EVENT(clk, clk_enable,
TP_PROTO(struct clk_core *core),
TP_ARGS(core)
);
DEFINE_EVENT(clk, clk_enable_complete,
TP_PROTO(struct clk_core *core),
TP_ARGS(core)
);
DEFINE_EVENT(clk, clk_disable,
TP_PROTO(struct clk_core *core),
TP_ARGS(core)
);
DEFINE_EVENT(clk, clk_disable_complete,
TP_PROTO(struct clk_core *core),
TP_ARGS(core)
);
DEFINE_EVENT(clk, clk_prepare,
TP_PROTO(struct clk_core *core),
TP_ARGS(core)
);
DEFINE_EVENT(clk, clk_prepare_complete,
TP_PROTO(struct clk_core *core),
TP_ARGS(core)
);
DEFINE_EVENT(clk, clk_unprepare,
TP_PROTO(struct clk_core *core),
TP_ARGS(core)
);
DEFINE_EVENT(clk, clk_unprepare_complete,
TP_PROTO(struct clk_core *core),
TP_ARGS(core)
);
DECLARE_EVENT_CLASS(clk_rate,
TP_PROTO(struct clk_core *core, unsigned long rate),
TP_ARGS(core, rate),
TP_STRUCT__entry(
__string( name, core->name )
__field(unsigned long, rate )
),
TP_fast_assign(
__assign_str(name, core->name);
__entry->rate = rate;
),
TP_printk("%s %lu", __get_str(name), (unsigned long)__entry->rate)
);
DEFINE_EVENT(clk_rate, clk_set_rate,
TP_PROTO(struct clk_core *core, unsigned long rate),
TP_ARGS(core, rate)
);
DEFINE_EVENT(clk_rate, clk_set_rate_complete,
TP_PROTO(struct clk_core *core, unsigned long rate),
TP_ARGS(core, rate)
);
DECLARE_EVENT_CLASS(clk_parent,
TP_PROTO(struct clk_core *core, struct clk_core *parent),
TP_ARGS(core, parent),
TP_STRUCT__entry(
__string( name, core->name )
__string( pname, parent ? parent->name : "none" )
),
TP_fast_assign(
__assign_str(name, core->name);
__assign_str(pname, parent ? parent->name : "none");
),
TP_printk("%s %s", __get_str(name), __get_str(pname))
);
DEFINE_EVENT(clk_parent, clk_set_parent,
TP_PROTO(struct clk_core *core, struct clk_core *parent),
TP_ARGS(core, parent)
);
DEFINE_EVENT(clk_parent, clk_set_parent_complete,
TP_PROTO(struct clk_core *core, struct clk_core *parent),
TP_ARGS(core, parent)
);
DECLARE_EVENT_CLASS(clk_phase,
TP_PROTO(struct clk_core *core, int phase),
TP_ARGS(core, phase),
TP_STRUCT__entry(
__string( name, core->name )
__field( int, phase )
),
TP_fast_assign(
__assign_str(name, core->name);
__entry->phase = phase;
),
TP_printk("%s %d", __get_str(name), (int)__entry->phase)
);
DEFINE_EVENT(clk_phase, clk_set_phase,
TP_PROTO(struct clk_core *core, int phase),
TP_ARGS(core, phase)
);
DEFINE_EVENT(clk_phase, clk_set_phase_complete,
TP_PROTO(struct clk_core *core, int phase),
TP_ARGS(core, phase)
);
DECLARE_EVENT_CLASS(clk_duty_cycle,
TP_PROTO(struct clk_core *core, struct clk_duty *duty),
TP_ARGS(core, duty),
TP_STRUCT__entry(
__string( name, core->name )
__field( unsigned int, num )
__field( unsigned int, den )
),
TP_fast_assign(
__assign_str(name, core->name);
__entry->num = duty->num;
__entry->den = duty->den;
),
TP_printk("%s %u/%u", __get_str(name), (unsigned int)__entry->num,
(unsigned int)__entry->den)
);
DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle,
TP_PROTO(struct clk_core *core, struct clk_duty *duty),
TP_ARGS(core, duty)
);
DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle_complete,
TP_PROTO(struct clk_core *core, struct clk_duty *duty),
TP_ARGS(core, duty)
);
#endif /* _TRACE_CLK_H */
/* This part must be outside protection */
#include <trace/define_trace.h>