@@ -1858,4 +1858,172 @@ void rpmi_service_group_perf_destroy(struct rpmi_service_group *group);
18581858
18591859/** @} */
18601860
1861+ /*************************************************************************************/
1862+
1863+ /**
1864+ * \defgroup LIBRPMI_VOLTSRVGRP_INTERFACE RPMI Voltage Service Group Library Interface
1865+ * @brief Global functions and data structures implemented by the RPMI library
1866+ * for RPMI Voltage service group.
1867+ * @{
1868+ */
1869+
1870+ /** Supported voltage domain states */
1871+ enum rpmi_voltage_state {
1872+ RPMI_VOLT_STATE_INVALID = -1 ,
1873+ RPMI_VOLT_STATE_DISABLED = 0 ,
1874+ RPMI_VOLT_STATE_ENABLED = 1 ,
1875+ RPMI_VOLT_STATE_ALWAYS_ON = 2 ,
1876+ RPMI_VOLT_STATE_MAX_IDX ,
1877+ };
1878+
1879+ /** Voltage type based on voltage format */
1880+ enum rpmi_voltage_type {
1881+ RPMI_VOLT_TYPE_INVALID = -1 ,
1882+ RPMI_VOLT_TYPE_DISCRETE = 0 ,
1883+ RPMI_VOLT_TYPE_LINEAR = 2 ,
1884+ RPMI_VOLT_TYPE_MAX_IDX ,
1885+ };
1886+
1887+ /** voltage domain capabilities */
1888+ enum rpmi_voltage_capability {
1889+ RPMI_VOLT_CAPABILITY_INVALID = -1 ,
1890+ RPMI_VOLT_CAPABILITY_ENABLED_DISABLED = 0 ,
1891+ RPMI_VOLT_CAPABILITY_ALWAYS_ON = 1 ,
1892+ RPMI_VOLT_CAPABILITY_MAX_IDX ,
1893+ };
1894+
1895+ /** voltage domain config */
1896+ enum rpmi_voltage_config {
1897+ RPMI_VOLT_CONFIG_NOT_SUPPORTED = 0 ,
1898+ RPMI_VOLT_CONFIG_ENABLED = 1 ,
1899+ RPMI_VOLT_CONFIG_DISABLED = 2 ,
1900+ RPMI_VOLT_CONFIG_MAX_IDX ,
1901+ };
1902+
1903+ struct rpmi_voltage_discrete_range {
1904+ rpmi_uint32_t * uvolt ;
1905+ };
1906+
1907+ struct rpmi_voltage_linear_range {
1908+ rpmi_uint32_t uvolt_min ;
1909+ rpmi_uint32_t uvolt_max ;
1910+ rpmi_uint32_t uvolt_step ;
1911+ };
1912+
1913+ /**
1914+ * Voltage Data and Tree details
1915+ *
1916+ * This structure represents the static
1917+ * voltage domain data which platform has to maintain
1918+ * and pass to create the voltage service group.
1919+ */
1920+ struct rpmi_voltage_data {
1921+ /* voltage domain name */
1922+ const char * name ;
1923+ /* voltage format */
1924+ rpmi_uint32_t voltage_type ;
1925+ /** regulator control */
1926+ rpmi_uint32_t control ;
1927+ /* regulator config */
1928+ rpmi_uint32_t config ;
1929+ /** number of supported voltage levels */
1930+ rpmi_uint32_t num_levels ;
1931+ /** transition latency */
1932+ rpmi_uint32_t trans_latency ;
1933+ /** discrete voltage range */
1934+ struct rpmi_voltage_discrete_range * discrete_range ;
1935+ /** linear voltage range */
1936+ struct rpmi_voltage_linear_range * linear_range ;
1937+ /** discrete voltage levels */
1938+ rpmi_int32_t * discrete_levels ;
1939+ /** linear voltage levels */
1940+ rpmi_int32_t * linear_levels ;
1941+ /** voltage level */
1942+ rpmi_int32_t level_uv ;
1943+ };
1944+
1945+ /** Voltage Domain Attributes */
1946+ struct rpmi_voltage_attrs {
1947+ /** voltage service return status */
1948+ rpmi_int32_t status ;
1949+ /* regulator capability */
1950+ rpmi_uint32_t capability ;
1951+ /* regulator config */
1952+ rpmi_uint32_t config ;
1953+ /** number of supported levels */
1954+ rpmi_uint32_t num_levels ;
1955+ /* transition latency */
1956+ rpmi_uint32_t trans_latency ;
1957+ /** array of supported levels */
1958+ rpmi_int32_t * level_array ;
1959+ /* voltage domain name */
1960+ const char * name ;
1961+ };
1962+
1963+ /** Platform specific voltage operations(synchronous) */
1964+ struct rpmi_voltage_platform_ops {
1965+ /**
1966+ * set config of voltage regulator
1967+ **/
1968+ enum rpmi_error (* set_config )(void * priv ,
1969+ rpmi_uint32_t volt_id ,
1970+ rpmi_uint32_t config );
1971+
1972+ /**
1973+ * get config of voltage regulator
1974+ **/
1975+ enum rpmi_error (* get_config )(void * priv ,
1976+ rpmi_uint32_t volt_id ,
1977+ rpmi_uint32_t * config );
1978+
1979+ /**
1980+ * set level of voltage regulator
1981+ **/
1982+ enum rpmi_error (* set_level )(void * priv ,
1983+ rpmi_uint32_t volt_id ,
1984+ rpmi_int32_t * volt_level );
1985+
1986+ /**
1987+ * get level of voltage regulator
1988+ **/
1989+ enum rpmi_error (* get_level )(void * priv ,
1990+ rpmi_uint32_t volt_id ,
1991+ rpmi_int32_t * volt_level );
1992+
1993+ /**
1994+ * Get perf supported levels
1995+ **/
1996+ enum rpmi_error (* get_supp_levels )(void * priv ,
1997+ rpmi_uint32_t volt_id ,
1998+ rpmi_uint32_t max ,
1999+ rpmi_uint32_t volt_index ,
2000+ rpmi_uint32_t * returned_levels ,
2001+ rpmi_int32_t * level_array );
2002+ };
2003+
2004+ /**
2005+ * @brief Create a device voltage service group instance
2006+ *
2007+ * @param[in] voltage_count number of voltage domains
2008+ * @param[in] voltage_tree_data pointer to voltage domain data
2009+ * @param[in] ops pointer to platform specific voltage operations
2010+ * @param[in] ops_priv pointer to private data of platform operations
2011+ * @return rpmi_service_group * pointer to RPMI service group instance upon
2012+ * success and NULL upon failure
2013+ */
2014+ struct rpmi_service_group *
2015+ rpmi_service_group_voltage_create (rpmi_uint32_t voltage_count ,
2016+ const struct rpmi_voltage_data * voltage_tree_data ,
2017+ const struct rpmi_voltage_platform_ops * ops ,
2018+ void * ops_priv );
2019+
2020+ /**
2021+ * @brief Destroy(free) a voltage service group instance
2022+ *
2023+ * @param[in] group pointer to RPMI service group instance
2024+ */
2025+ void rpmi_service_group_voltage_destroy (struct rpmi_service_group * group );
2026+
2027+ /** @} */
2028+
18612029#endif /* __LIBRPMI_H__ */
0 commit comments