blob: 3056bda7a94d7398194328d77ba8237382c01250 [file] [log] [blame]
Andrew F. Davisa513b2a2018-05-04 19:06:09 +00001/*
2 * Texas Instruments System Control Interface API
3 * Based on Linux and U-Boot implementation
4 *
5 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9
10#ifndef __TI_SCI_H
11#define __TI_SCI_H
12
Andrew F. Davis4f2a0552018-05-04 19:06:10 +000013#include <stdint.h>
14#include <stdbool.h>
15
16/**
17 * Device control operations
18 *
19 * - ti_sci_device_set_state - Set device state helper
20 * @flags: flags to setup for the device
21 * @state: State to move the device to
22 * - ti_sci_device_get_state - Get device state helper
23 * @clcnt: Pointer to Context Loss Count
24 * @resets: pointer to resets
25 * @p_state: pointer to p_state
26 * @c_state: pointer to c_state
27 * - ti_sci_device_get - command to request for device managed by TISCI
28 * - ti_sci_device_idle - Command to idle a device managed by TISCI
29 * - ti_sci_device_put - command to release a device managed by TISCI
30 * - ti_sci_device_is_valid - Is the device valid
31 * - ti_sci_device_get_clcnt - Get context loss counter
32 * @count: Pointer to Context Loss counter to populate
33 * - ti_sci_device_is_idle - Check if the device is requested to be idle
34 * @r_state: true if requested to be idle
35 * - ti_sci_device_is_stop - Check if the device is requested to be stopped
36 * @r_state: true if requested to be stopped
37 * @curr_state: true if currently stopped.
38 * - ti_sci_device_is_on - Check if the device is requested to be ON
39 * @r_state: true if requested to be ON
40 * @curr_state: true if currently ON and active
41 * - ti_sci_device_is_trans - Check if the device is currently transitioning
42 * @curr_state: true if currently transitioning.
43 * - ti_sci_device_set_resets - Command to set resets for
44 * device managed by TISCI
45 * @reset_state: Device specific reset bit field
46 * - ti_sci_device_get_resets - Get reset state for device managed by TISCI
47 * @reset_state: Pointer to reset state to populate
48 *
49 * NOTE: for all these functions, the following are generic in nature:
50 * @id: Device Identifier
51 * Returns 0 for successful request, else returns corresponding error message.
52 *
53 * Request for the device - NOTE: the client MUST maintain integrity of
54 * usage count by balancing get_device with put_device. No refcounting is
55 * managed by driver for that purpose.
56 */
57int ti_sci_device_set_state(uint32_t id, uint32_t flags, uint8_t state);
58int ti_sci_device_get_state(uint32_t id, uint32_t *clcnt, uint32_t *resets,
59 uint8_t *p_state, uint8_t *c_state);
60int ti_sci_device_get(uint32_t id);
61int ti_sci_device_idle(uint32_t id);
62int ti_sci_device_put(uint32_t id);
63int ti_sci_device_is_valid(uint32_t id);
64int ti_sci_device_get_clcnt(uint32_t id, uint32_t *count);
65int ti_sci_device_is_idle(uint32_t id, bool *r_state);
66int ti_sci_device_is_stop(uint32_t id, bool *r_state, bool *curr_state);
67int ti_sci_device_is_on(uint32_t id, bool *r_state, bool *curr_state);
68int ti_sci_device_is_trans(uint32_t id, bool *curr_state);
69int ti_sci_device_set_resets(uint32_t id, uint32_t reset_state);
70int ti_sci_device_get_resets(uint32_t id, uint32_t *reset_state);
71
Andrew F. Davisa513b2a2018-05-04 19:06:09 +000072/**
73 * ti_sci_init() - Basic initialization
74 *
75 * Return: 0 if all goes good, else appropriate error message.
76 */
77int ti_sci_init(void);
78
79#endif /* __TI_SCI_H */