/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright (C) 2023-2024, Advanced Micro Devices, Inc.3*/45#ifndef _AIE2_SOLVER_H6#define _AIE2_SOLVER_H78#define XRS_MAX_COL 128910/*11* Structure used to describe a partition. A partition is column based12* allocation unit described by its start column and number of columns.13*/14struct aie_part {15u32 start_col;16u32 ncols;17};1819/*20* The QoS capabilities of a given AIE partition.21*/22struct aie_qos_cap {23u32 opc; /* operations per cycle */24u32 dma_bw; /* DMA bandwidth */25};2627/*28* QoS requirement of a resource allocation.29*/30struct aie_qos {31u32 gops; /* Giga operations */32u32 fps; /* Frames per second */33u32 dma_bw; /* DMA bandwidth */34u32 latency; /* Frame response latency */35u32 exec_time; /* Frame execution time */36u32 priority; /* Request priority */37};3839/*40* Structure used to describe a relocatable CDO (Configuration Data Object).41*/42struct cdo_parts {43u32 *start_cols; /* Start column array */44u32 cols_len; /* Length of start column array */45u32 ncols; /* # of column */46struct aie_qos_cap qos_cap; /* CDO QoS capabilities */47};4849/*50* Structure used to describe a request to allocate.51*/52struct alloc_requests {53u64 rid;54struct cdo_parts cdo;55struct aie_qos rqos; /* Requested QoS */56};5758/*59* Load callback argument60*/61struct xrs_action_load {62u32 rid;63struct aie_part part;64};6566/*67* Define the power level available68*69* POWER_LEVEL_MIN:70* Lowest power level. Usually set when all actions are unloaded.71*72* POWER_LEVEL_n73* Power levels 0 - n, is a step increase in system frequencies74*/75enum power_level {76POWER_LEVEL_MIN = 0x0,77POWER_LEVEL_0 = 0x1,78POWER_LEVEL_1 = 0x2,79POWER_LEVEL_2 = 0x3,80POWER_LEVEL_3 = 0x4,81POWER_LEVEL_4 = 0x5,82POWER_LEVEL_5 = 0x6,83POWER_LEVEL_6 = 0x7,84POWER_LEVEL_7 = 0x8,85POWER_LEVEL_NUM,86};8788/*89* Structure used to describe the frequency table.90* Resource solver chooses the frequency from the table91* to meet the QOS requirements.92*/93struct clk_list_info {94u32 num_levels; /* available power levels */95u32 cu_clk_list[POWER_LEVEL_NUM]; /* available aie clock frequencies in Mhz*/96};9798struct xrs_action_ops {99int (*load)(void *cb_arg, struct xrs_action_load *action);100int (*unload)(void *cb_arg);101int (*set_dft_dpm_level)(struct drm_device *ddev, u32 level);102};103104/*105* Structure used to describe information for solver during initialization.106*/107struct init_config {108u32 total_col;109u32 sys_eff_factor; /* system efficiency factor */110u32 latency_adj; /* latency adjustment in ms */111struct clk_list_info clk_list; /* List of frequencies available in system */112struct drm_device *ddev;113struct xrs_action_ops *actions;114};115116/*117* xrsm_init() - Register resource solver. Resource solver client needs118* to call this function to register itself.119*120* @cfg: The system metrics for resource solver to use121*122* Return: A resource solver handle123*124* Note: We should only create one handle per AIE array to be managed.125*/126void *xrsm_init(struct init_config *cfg);127128/*129* xrs_allocate_resource() - Request to allocate resources for a given context130* and a partition metadata. (See struct part_meta)131*132* @hdl: Resource solver handle obtained from xrs_init()133* @req: Input to the Resource solver including request id134* and partition metadata.135* @cb_arg: callback argument pointer136*137* Return: 0 when successful.138* Or standard error number when failing139*140* Note:141* There is no lock mechanism inside resource solver. So it is142* the caller's responsibility to lock down XCLBINs and grab143* necessary lock.144*/145int xrs_allocate_resource(void *hdl, struct alloc_requests *req, void *cb_arg);146147/*148* xrs_release_resource() - Request to free resources for a given context.149*150* @hdl: Resource solver handle obtained from xrs_init()151* @rid: The Request ID to identify the requesting context152*/153int xrs_release_resource(void *hdl, u64 rid);154#endif /* _AIE2_SOLVER_H */155156157