2019-01-16 19:10:56 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2018, Linaro Ltd.
|
|
|
|
* Author: Georgi Djakov <georgi.djakov@linaro.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_INTERCONNECT_PROVIDER_H
|
|
|
|
#define __LINUX_INTERCONNECT_PROVIDER_H
|
|
|
|
|
|
|
|
#include <linux/interconnect.h>
|
|
|
|
|
|
|
|
#define icc_units_to_bps(bw) ((bw) * 1000ULL)
|
|
|
|
|
|
|
|
struct icc_node;
|
2019-01-16 19:10:58 +03:00
|
|
|
struct of_phandle_args;
|
|
|
|
|
2020-09-03 16:31:28 +03:00
|
|
|
/**
|
|
|
|
* struct icc_node_data - icc node data
|
|
|
|
*
|
|
|
|
* @node: icc node
|
|
|
|
* @tag: tag
|
|
|
|
*/
|
|
|
|
struct icc_node_data {
|
|
|
|
struct icc_node *node;
|
|
|
|
u32 tag;
|
|
|
|
};
|
|
|
|
|
2019-01-16 19:10:58 +03:00
|
|
|
/**
|
|
|
|
* struct icc_onecell_data - driver data for onecell interconnect providers
|
|
|
|
*
|
|
|
|
* @num_nodes: number of nodes in this device
|
|
|
|
* @nodes: array of pointers to the nodes in this device
|
|
|
|
*/
|
|
|
|
struct icc_onecell_data {
|
|
|
|
unsigned int num_nodes;
|
|
|
|
struct icc_node *nodes[];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct icc_node *of_icc_xlate_onecell(struct of_phandle_args *spec,
|
|
|
|
void *data);
|
2019-01-16 19:10:56 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct icc_provider - interconnect provider (controller) entity that might
|
|
|
|
* provide multiple interconnect controls
|
|
|
|
*
|
|
|
|
* @provider_list: list of the registered interconnect providers
|
|
|
|
* @nodes: internal list of the interconnect provider nodes
|
|
|
|
* @set: pointer to device specific set operation function
|
|
|
|
* @aggregate: pointer to device specific aggregate operation function
|
2019-08-09 15:13:24 +03:00
|
|
|
* @pre_aggregate: pointer to device specific function that is called
|
|
|
|
* before the aggregation begins (optional)
|
2020-08-25 20:01:50 +03:00
|
|
|
* @get_bw: pointer to device specific function to get current bandwidth
|
2019-01-16 19:10:58 +03:00
|
|
|
* @xlate: provider-specific callback for mapping nodes from phandle arguments
|
2020-09-03 16:31:28 +03:00
|
|
|
* @xlate_extended: vendor-specific callback for mapping node data from phandle arguments
|
2019-01-16 19:10:56 +03:00
|
|
|
* @dev: the device this interconnect provider belongs to
|
|
|
|
* @users: count of active users
|
2020-05-21 15:28:41 +03:00
|
|
|
* @inter_set: whether inter-provider pairs will be configured with @set
|
2019-01-16 19:10:56 +03:00
|
|
|
* @data: pointer to private data
|
|
|
|
*/
|
|
|
|
struct icc_provider {
|
|
|
|
struct list_head provider_list;
|
|
|
|
struct list_head nodes;
|
|
|
|
int (*set)(struct icc_node *src, struct icc_node *dst);
|
2019-08-09 15:13:23 +03:00
|
|
|
int (*aggregate)(struct icc_node *node, u32 tag, u32 avg_bw,
|
|
|
|
u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
|
2019-08-09 15:13:24 +03:00
|
|
|
void (*pre_aggregate)(struct icc_node *node);
|
2020-08-25 20:01:50 +03:00
|
|
|
int (*get_bw)(struct icc_node *node, u32 *avg, u32 *peak);
|
2019-01-16 19:10:58 +03:00
|
|
|
struct icc_node* (*xlate)(struct of_phandle_args *spec, void *data);
|
2020-09-03 16:31:28 +03:00
|
|
|
struct icc_node_data* (*xlate_extended)(struct of_phandle_args *spec, void *data);
|
2019-01-16 19:10:56 +03:00
|
|
|
struct device *dev;
|
|
|
|
int users;
|
2020-05-21 15:28:41 +03:00
|
|
|
bool inter_set;
|
2019-01-16 19:10:56 +03:00
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct icc_node - entity that is part of the interconnect topology
|
|
|
|
*
|
|
|
|
* @id: platform specific node id
|
|
|
|
* @name: node name used in debugfs
|
|
|
|
* @links: a list of targets pointing to where we can go next when traversing
|
|
|
|
* @num_links: number of links to other interconnect nodes
|
|
|
|
* @provider: points to the interconnect provider of this node
|
|
|
|
* @node_list: the list entry in the parent provider's "nodes" list
|
|
|
|
* @search_list: list used when walking the nodes graph
|
|
|
|
* @reverse: pointer to previous node when walking the nodes graph
|
|
|
|
* @is_traversed: flag that is used when walking the nodes graph
|
|
|
|
* @req_list: a list of QoS constraint requests associated with this node
|
|
|
|
* @avg_bw: aggregated value of average bandwidth requests from all consumers
|
|
|
|
* @peak_bw: aggregated value of peak bandwidth requests from all consumers
|
2020-08-25 20:01:51 +03:00
|
|
|
* @init_avg: average bandwidth value that is read from the hardware during init
|
|
|
|
* @init_peak: peak bandwidth value that is read from the hardware during init
|
2019-01-16 19:10:56 +03:00
|
|
|
* @data: pointer to private data
|
|
|
|
*/
|
|
|
|
struct icc_node {
|
|
|
|
int id;
|
|
|
|
const char *name;
|
|
|
|
struct icc_node **links;
|
|
|
|
size_t num_links;
|
|
|
|
|
|
|
|
struct icc_provider *provider;
|
|
|
|
struct list_head node_list;
|
|
|
|
struct list_head search_list;
|
|
|
|
struct icc_node *reverse;
|
|
|
|
u8 is_traversed:1;
|
|
|
|
struct hlist_head req_list;
|
|
|
|
u32 avg_bw;
|
|
|
|
u32 peak_bw;
|
2020-08-25 20:01:51 +03:00
|
|
|
u32 init_avg;
|
|
|
|
u32 init_peak;
|
2019-01-16 19:10:56 +03:00
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#if IS_ENABLED(CONFIG_INTERCONNECT)
|
|
|
|
|
2019-11-28 16:48:38 +03:00
|
|
|
int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
|
|
|
|
u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
|
2019-01-16 19:10:56 +03:00
|
|
|
struct icc_node *icc_node_create(int id);
|
|
|
|
void icc_node_destroy(int id);
|
|
|
|
int icc_link_create(struct icc_node *node, const int dst_id);
|
|
|
|
void icc_node_add(struct icc_node *node, struct icc_provider *provider);
|
|
|
|
void icc_node_del(struct icc_node *node);
|
2019-12-02 19:21:32 +03:00
|
|
|
int icc_nodes_remove(struct icc_provider *provider);
|
2023-03-06 10:56:31 +03:00
|
|
|
void icc_provider_init(struct icc_provider *provider);
|
|
|
|
int icc_provider_register(struct icc_provider *provider);
|
|
|
|
void icc_provider_deregister(struct icc_provider *provider);
|
2020-09-03 16:31:28 +03:00
|
|
|
struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec);
|
2020-08-25 20:01:51 +03:00
|
|
|
void icc_sync_state(struct device *dev);
|
2019-01-16 19:10:56 +03:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2019-11-28 16:48:38 +03:00
|
|
|
static inline int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
|
|
|
|
u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
2019-01-16 19:10:56 +03:00
|
|
|
static inline struct icc_node *icc_node_create(int id)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOTSUPP);
|
|
|
|
}
|
|
|
|
|
2020-06-16 16:43:23 +03:00
|
|
|
static inline void icc_node_destroy(int id)
|
2019-01-16 19:10:56 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int icc_link_create(struct icc_node *node, const int dst_id)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
2020-06-16 16:43:23 +03:00
|
|
|
static inline void icc_node_add(struct icc_node *node, struct icc_provider *provider)
|
2019-01-16 19:10:56 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-06-16 16:43:23 +03:00
|
|
|
static inline void icc_node_del(struct icc_node *node)
|
2019-01-16 19:10:56 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-12-02 19:21:32 +03:00
|
|
|
static inline int icc_nodes_remove(struct icc_provider *provider)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
2023-03-06 10:56:31 +03:00
|
|
|
static inline void icc_provider_init(struct icc_provider *provider) { }
|
|
|
|
|
|
|
|
static inline int icc_provider_register(struct icc_provider *provider)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void icc_provider_deregister(struct icc_provider *provider) { }
|
|
|
|
|
2020-09-03 16:31:28 +03:00
|
|
|
static inline struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec)
|
2020-05-21 15:28:39 +03:00
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOTSUPP);
|
|
|
|
}
|
|
|
|
|
2019-01-16 19:10:56 +03:00
|
|
|
#endif /* CONFIG_INTERCONNECT */
|
|
|
|
|
|
|
|
#endif /* __LINUX_INTERCONNECT_PROVIDER_H */
|