blob: d85b906b88e9797f38b042e9063a282ff6a2ad92 [file] [log] [blame]
Varun Wadekarb3741032017-09-25 13:27:45 -07001/*
Varun Wadekard11345a2018-05-25 14:34:53 -07002 * Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
Varun Wadekarb3741032017-09-25 13:27:45 -07003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Varun Wadekard11345a2018-05-25 14:34:53 -07007#ifndef BPMP_INTF_H
8#define BPMP_INTF_H
Varun Wadekarb3741032017-09-25 13:27:45 -07009
10/**
11 * Flags used in IPC req
12 */
13#define FLAG_DO_ACK (U(1) << 0)
Varun Wadekard11345a2018-05-25 14:34:53 -070014#define FLAG_RING_DOORBELL (U(1) << 1)
Varun Wadekarb3741032017-09-25 13:27:45 -070015
16/* Bit 1 is designated for CCPlex in secure world */
steven kao05ee5822018-01-02 19:07:00 -080017#define HSP_MASTER_CCPLEX_BIT (U(1) << 1)
Varun Wadekarb3741032017-09-25 13:27:45 -070018/* Bit 19 is designated for BPMP in non-secure world */
19#define HSP_MASTER_BPMP_BIT (U(1) << 19)
20/* Timeout to receive response from BPMP is 1 sec */
21#define TIMEOUT_RESPONSE_FROM_BPMP_US U(1000000) /* in microseconds */
22
23/**
24 * IVC protocol defines and command/response frame
25 */
26
27/**
28 * IVC specific defines
29 */
30#define IVC_CMD_SZ_BYTES U(128)
31#define IVC_DATA_SZ_BYTES U(120)
32
33/**
34 * Holds frame data for an IPC request
35 */
36struct frame_data {
37 /* Identification as to what kind of data is being transmitted */
38 uint32_t mrq;
39
40 /* Flags for slave as to how to respond back */
41 uint32_t flags;
42
43 /* Actual data being sent */
44 uint8_t data[IVC_DATA_SZ_BYTES];
45};
46
47/**
48 * Commands send to the BPMP firmware
49 */
50
51/**
steven kao05ee5822018-01-02 19:07:00 -080052 * MRQ command codes
Varun Wadekarb3741032017-09-25 13:27:45 -070053 */
54#define MRQ_RESET U(20)
steven kao05ee5822018-01-02 19:07:00 -080055#define MRQ_CLK U(22)
Varun Wadekarb3741032017-09-25 13:27:45 -070056
57/**
58 * Reset sub-commands
59 */
60#define CMD_RESET_ASSERT U(1)
61#define CMD_RESET_DEASSERT U(2)
62#define CMD_RESET_MODULE U(3)
63
64/**
65 * Used by the sender of an #MRQ_RESET message to request BPMP to
66 * assert or deassert a given reset line.
67 */
68struct __attribute__((packed)) mrq_reset_request {
69 /* reset action to perform (mrq_reset_commands) */
70 uint32_t cmd;
71 /* id of the reset to affected */
72 uint32_t reset_id;
73};
74
steven kao05ee5822018-01-02 19:07:00 -080075/**
76 * MRQ_CLK sub-commands
77 *
78 */
79enum {
Varun Wadekard11345a2018-05-25 14:34:53 -070080 CMD_CLK_GET_RATE = U(1),
81 CMD_CLK_SET_RATE = U(2),
82 CMD_CLK_ROUND_RATE = U(3),
83 CMD_CLK_GET_PARENT = U(4),
84 CMD_CLK_SET_PARENT = U(5),
85 CMD_CLK_IS_ENABLED = U(6),
86 CMD_CLK_ENABLE = U(7),
87 CMD_CLK_DISABLE = U(8),
88 CMD_CLK_GET_ALL_INFO = U(14),
89 CMD_CLK_GET_MAX_CLK_ID = U(15),
steven kao05ee5822018-01-02 19:07:00 -080090 CMD_CLK_MAX,
91};
92
93/**
94 * Used by the sender of an #MRQ_CLK message to control clocks. The
95 * clk_request is split into several sub-commands. Some sub-commands
96 * require no additional data. Others have a sub-command specific
97 * payload
98 *
99 * |sub-command |payload |
100 * |----------------------------|-----------------------|
101 * |CMD_CLK_GET_RATE |- |
102 * |CMD_CLK_SET_RATE |clk_set_rate |
103 * |CMD_CLK_ROUND_RATE |clk_round_rate |
104 * |CMD_CLK_GET_PARENT |- |
105 * |CMD_CLK_SET_PARENT |clk_set_parent |
106 * |CMD_CLK_IS_ENABLED |- |
107 * |CMD_CLK_ENABLE |- |
108 * |CMD_CLK_DISABLE |- |
109 * |CMD_CLK_GET_ALL_INFO |- |
110 * |CMD_CLK_GET_MAX_CLK_ID |- |
111 *
112 */
113struct mrq_clk_request {
114 /**
115 * sub-command and clock id concatenated to 32-bit word.
116 * - bits[31..24] is the sub-cmd.
117 * - bits[23..0] is the clock id
118 */
119 uint32_t cmd_and_id;
120};
121
122/**
123 * Macro to prepare the MRQ_CLK sub-command
124 */
125#define make_mrq_clk_cmd(cmd, id) (((cmd) << 24) | (id & 0xFFFFFF))
126
Varun Wadekard11345a2018-05-25 14:34:53 -0700127#endif /* BPMP_INTF_H */