Software APIs
dt_pwm.h
Go to the documentation of this file.
1
// Copyright lowRISC contributors (OpenTitan project).
2
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3
// SPDX-License-Identifier: Apache-2.0
4
//
5
// Device table API auto-generated by `dtgen`
6
7
#ifndef OPENTITAN_DT_PWM_H_
8
#define OPENTITAN_DT_PWM_H_
9
10
/**
11
* @file
12
* @brief Device Tables (DT) for IP pwm and top earlgrey.
13
*
14
* This file contains the type definitions and global functions of the pwm.
15
*/
16
17
#include "
dt_api.h
"
18
#include <stdint.h>
19
20
/**
21
* List of instances.
22
*/
23
typedef
enum
dt_pwm
{
24
kDtPwmAon
= 0,
/**< pwm_aon */
25
kDtPwmFirst = 0,
/**< \internal First instance */
26
kDtPwmCount = 1,
/**< \internal Number of instances */
27
}
dt_pwm_t
;
28
29
/**
30
* List of register blocks.
31
*
32
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
33
*/
34
typedef
enum
dt_pwm_reg_block
{
35
kDtPwmRegBlockCore = 0,
/**< */
36
kDtPwmRegBlockCount = 1,
/**< \internal Number of register blocks */
37
}
dt_pwm_reg_block_t
;
38
39
/** Primary register block (associated with the "primary" set of registers that control the IP). */
40
static
const
dt_pwm_reg_block_t
kDtPwmRegBlockPrimary = kDtPwmRegBlockCore;
41
42
/**
43
* List of Alerts.
44
*
45
* Alerts are guaranteed to be numbered consecutively from 0.
46
*/
47
typedef
enum
dt_pwm_alert
{
48
kDtPwmAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
49
kDtPwmAlertCount = 1,
/**< \internal Number of Alerts */
50
}
dt_pwm_alert_t
;
51
52
/**
53
* List of clock ports.
54
*
55
* Clock ports are guaranteed to be numbered consecutively from 0.
56
*/
57
typedef
enum
dt_pwm_clock
{
58
kDtPwmClockClk
= 0,
/**< Clock port clk_i */
59
kDtPwmClockCore
= 1,
/**< Clock port clk_core_i */
60
kDtPwmClockCount = 2,
/**< \internal Number of clock ports */
61
}
dt_pwm_clock_t
;
62
63
/**
64
* List of reset ports.
65
*
66
* Reset ports are guaranteed to be numbered consecutively from 0.
67
*/
68
typedef
enum
dt_pwm_reset
{
69
kDtPwmResetRst
= 0,
/**< Reset port rst_ni */
70
kDtPwmResetCore
= 1,
/**< Reset port rst_core_ni */
71
kDtPwmResetCount = 2,
/**< \internal Number of reset ports */
72
}
dt_pwm_reset_t
;
73
74
/**
75
* List of peripheral I/O.
76
*
77
* Peripheral I/O are guaranteed to be numbered consecutively from 0.
78
*/
79
typedef
enum
dt_pwm_periph_io
{
80
kDtPwmPeriphIoPwm0 = 0,
/**< */
81
kDtPwmPeriphIoPwm1 = 1,
/**< */
82
kDtPwmPeriphIoPwm2 = 2,
/**< */
83
kDtPwmPeriphIoPwm3 = 3,
/**< */
84
kDtPwmPeriphIoPwm4 = 4,
/**< */
85
kDtPwmPeriphIoPwm5 = 5,
/**< */
86
kDtPwmPeriphIoCount = 6,
/**< \internal Number of peripheral I/O */
87
}
dt_pwm_periph_io_t
;
88
89
/**
90
* List of supported hardware features.
91
*/
92
#define OPENTITAN_PWM_HAS_DUTYCYCLE 1
93
#define OPENTITAN_PWM_HAS_BLINK 1
94
#define OPENTITAN_PWM_HAS_HEARTBEAT 1
95
#define OPENTITAN_PWM_HAS_POLARITY 1
96
#define OPENTITAN_PWM_HAS_CLOCKDIVIDER 1
97
#define OPENTITAN_PWM_HAS_PHASEDELAY 1
98
99
100
101
/**
102
* Get the pwm instance from an instance ID
103
*
104
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
105
*
106
* @param inst_id Instance ID.
107
* @return A pwm instance.
108
*
109
* **Note:** This function only makes sense if the instance ID has device type pwm,
110
* otherwise the returned value is unspecified.
111
*/
112
dt_pwm_t
dt_pwm_from_instance_id
(
dt_instance_id_t
inst_id);
113
114
/**
115
* Get the instance ID of an instance.
116
*
117
* @param dt Instance of pwm.
118
* @return The instance ID of that instance.
119
*/
120
dt_instance_id_t
dt_pwm_instance_id
(
dt_pwm_t
dt);
121
122
/**
123
* Get the register base address of an instance.
124
*
125
* @param dt Instance of pwm.
126
* @param reg_block The register block requested.
127
* @return The register base address of the requested block.
128
*/
129
uint32_t
dt_pwm_reg_block
(
130
dt_pwm_t
dt,
131
dt_pwm_reg_block_t
reg_block);
132
133
/**
134
* Get the primary register base address of an instance.
135
*
136
* This is just a convenience function, equivalent to
137
* `dt_pwm_reg_block(dt, kDtPwmRegBlockCore)`
138
*
139
* @param dt Instance of pwm.
140
* @return The register base address of the primary register block.
141
*/
142
static
inline
uint32_t dt_pwm_primary_reg_block(
143
dt_pwm_t
dt) {
144
return
dt_pwm_reg_block
(dt, kDtPwmRegBlockCore);
145
}
146
147
148
/**
149
* Get the alert ID of a pwm alert for a given instance.
150
*
151
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
152
* instances where the instance is not connected, the return value is unspecified.
153
*
154
* @param dt Instance of pwm.
155
* @param alert A pwm alert.
156
* @return The Alert Handler alert ID of the alert of this instance.
157
*/
158
dt_alert_id_t
dt_pwm_alert_to_alert_id
(
159
dt_pwm_t
dt,
160
dt_pwm_alert_t
alert);
161
162
/**
163
* Convert a global alert ID to a local pwm alert type.
164
*
165
* @param dt Instance of pwm.
166
* @param alert A global alert ID that belongs to this instance.
167
* @return The pwm alert, or `kDtPwmAlertCount`.
168
*
169
* **Note:** This function assumes that the global alert ID belongs to the
170
* instance of pwm passed in parameter. In other words, it must be the case
171
* that `dt_pwm_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
172
* this function will return `kDtPwmAlertCount`.
173
*/
174
dt_pwm_alert_t
dt_pwm_alert_from_alert_id
(
175
dt_pwm_t
dt,
176
dt_alert_id_t
alert);
177
178
179
/**
180
* Get the peripheral I/O description of an instance.
181
*
182
* @param dt Instance of pwm.
183
* @param sig Requested peripheral I/O.
184
* @return Description of the requested peripheral I/O for this instance.
185
*/
186
dt_periph_io_t
dt_pwm_periph_io
(
187
dt_pwm_t
dt,
188
dt_pwm_periph_io_t
sig);
189
190
/**
191
* Get the clock signal connected to a clock port of an instance.
192
*
193
* @param dt Instance of pwm.
194
* @param clk Clock port.
195
* @return Clock signal.
196
*/
197
dt_clock_t
dt_pwm_clock
(
198
dt_pwm_t
dt,
199
dt_pwm_clock_t
clk);
200
201
/**
202
* Get the reset signal connected to a reset port of an instance.
203
*
204
* @param dt Instance of pwm.
205
* @param rst Reset port.
206
* @return Reset signal.
207
*/
208
dt_reset_t
dt_pwm_reset
(
209
dt_pwm_t
dt,
210
dt_pwm_reset_t
rst);
211
212
213
214
#endif
// OPENTITAN_DT_PWM_H_
(earlgrey)
hw
top
dt
dt_pwm.h
Return to
OpenTitan Documentation