Pavona Software APIs
api.c
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
8/**
9 * @file
10 * @brief Device Tables (DT) API for top scafi_deprecated
11 */
12
13#include "hw/top/dt/api.h"
15#include <stdint.h>
16
17
18enum {
19 kTopScafiDeprecatedPlicIrqIdCount = kTopScafiDeprecatedPlicIrqIdLast + 1,
20};
21
22static const dt_instance_id_t instance_from_irq[kTopScafiDeprecatedPlicIrqIdCount] = {
111};
112
114 if (irq <= kTopScafiDeprecatedPlicIrqIdLast) {
115 return instance_from_irq[irq];
116 }
118}
119
141};
142
144 if ((int)dev < kDtInstanceIdCount) {
145 return device_type[dev];
146 }
148}
149
150/**
151 * Pad description.
152 *
153 * A `dt_pad_t` represents a chip's physical pad.
154 */
155typedef struct dt_pad_desc {
156 dt_pad_type_t type; /**< Pad type */
157 /**
158 * For `kDtPadTypeMio` pads: MIO out number. This is the index of the MIO_OUTSEL register
159 * that controls this pad (or the output part of this pad).
160 *
161 * For `kDtPadTypeDio`: DIO pad number. This is the index of the various DIO_PAD_* registers
162 * that control this pad.
163 */
164 uint16_t mio_out_or_direct_pad;
165 /**
166 * For `kDtPadTypeMio` pads: MIO pad number. This is the value to put in the MIO_PERIPH_INSEL
167 * registers to connect a peripheral to this pad.
168 */
169 uint16_t insel;
171
172
173
174// Pad descriptions.
175static const dt_pad_desc_t dt_pad[kDtPadCount] = {
177 .type = kDtPadTypeMio,
178 .mio_out_or_direct_pad = 0,
180 },
182 .type = kDtPadTypeMio,
183 .mio_out_or_direct_pad = 0,
185 },
186 [kDtPadIoa0] = {
187 .type = kDtPadTypeMio,
188 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoa0,
190 },
191 [kDtPadIoa1] = {
192 .type = kDtPadTypeMio,
193 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoa1,
195 },
196 [kDtPadIoa2] = {
197 .type = kDtPadTypeMio,
198 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoa2,
200 },
201 [kDtPadIoa3] = {
202 .type = kDtPadTypeMio,
203 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoa3,
205 },
206 [kDtPadIoa4] = {
207 .type = kDtPadTypeMio,
208 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoa4,
210 },
211 [kDtPadIoa5] = {
212 .type = kDtPadTypeMio,
213 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoa5,
215 },
216 [kDtPadIoa6] = {
217 .type = kDtPadTypeMio,
218 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoa6,
220 },
221 [kDtPadIoa7] = {
222 .type = kDtPadTypeMio,
223 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoa7,
225 },
226 [kDtPadIoa8] = {
227 .type = kDtPadTypeMio,
228 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoa8,
230 },
231 [kDtPadIob0] = {
232 .type = kDtPadTypeMio,
233 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob0,
235 },
236 [kDtPadIob1] = {
237 .type = kDtPadTypeMio,
238 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob1,
240 },
241 [kDtPadIob2] = {
242 .type = kDtPadTypeMio,
243 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob2,
245 },
246 [kDtPadIob3] = {
247 .type = kDtPadTypeMio,
248 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob3,
250 },
251 [kDtPadIob4] = {
252 .type = kDtPadTypeMio,
253 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob4,
255 },
256 [kDtPadIob5] = {
257 .type = kDtPadTypeMio,
258 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob5,
260 },
261 [kDtPadIob6] = {
262 .type = kDtPadTypeMio,
263 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob6,
265 },
266 [kDtPadIob7] = {
267 .type = kDtPadTypeMio,
268 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob7,
270 },
271 [kDtPadIob8] = {
272 .type = kDtPadTypeMio,
273 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob8,
275 },
276 [kDtPadIob9] = {
277 .type = kDtPadTypeMio,
278 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob9,
280 },
281 [kDtPadIob10] = {
282 .type = kDtPadTypeMio,
283 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob10,
285 },
286 [kDtPadIob11] = {
287 .type = kDtPadTypeMio,
288 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob11,
290 },
291 [kDtPadIob12] = {
292 .type = kDtPadTypeMio,
293 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIob12,
295 },
296 [kDtPadIoc0] = {
297 .type = kDtPadTypeMio,
298 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc0,
300 },
301 [kDtPadIoc1] = {
302 .type = kDtPadTypeMio,
303 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc1,
305 },
306 [kDtPadIoc2] = {
307 .type = kDtPadTypeMio,
308 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc2,
310 },
311 [kDtPadIoc3] = {
312 .type = kDtPadTypeMio,
313 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc3,
315 },
316 [kDtPadIoc4] = {
317 .type = kDtPadTypeMio,
318 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc4,
320 },
321 [kDtPadIoc5] = {
322 .type = kDtPadTypeMio,
323 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc5,
325 },
326 [kDtPadIoc6] = {
327 .type = kDtPadTypeMio,
328 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc6,
330 },
331 [kDtPadIoc7] = {
332 .type = kDtPadTypeMio,
333 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc7,
335 },
336 [kDtPadIoc8] = {
337 .type = kDtPadTypeMio,
338 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc8,
340 },
341 [kDtPadIoc9] = {
342 .type = kDtPadTypeMio,
343 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc9,
345 },
346 [kDtPadIoc10] = {
347 .type = kDtPadTypeMio,
348 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc10,
350 },
351 [kDtPadIoc11] = {
352 .type = kDtPadTypeMio,
353 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc11,
355 },
356 [kDtPadIoc12] = {
357 .type = kDtPadTypeMio,
358 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIoc12,
360 },
361 [kDtPadIor0] = {
362 .type = kDtPadTypeMio,
363 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor0,
365 },
366 [kDtPadIor1] = {
367 .type = kDtPadTypeMio,
368 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor1,
370 },
371 [kDtPadIor2] = {
372 .type = kDtPadTypeMio,
373 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor2,
375 },
376 [kDtPadIor3] = {
377 .type = kDtPadTypeMio,
378 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor3,
380 },
381 [kDtPadIor4] = {
382 .type = kDtPadTypeMio,
383 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor4,
385 },
386 [kDtPadIor5] = {
387 .type = kDtPadTypeMio,
388 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor5,
390 },
391 [kDtPadIor6] = {
392 .type = kDtPadTypeMio,
393 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor6,
395 },
396 [kDtPadIor7] = {
397 .type = kDtPadTypeMio,
398 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor7,
400 },
401 [kDtPadIor10] = {
402 .type = kDtPadTypeMio,
403 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor10,
405 },
406 [kDtPadIor11] = {
407 .type = kDtPadTypeMio,
408 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor11,
410 },
411 [kDtPadIor12] = {
412 .type = kDtPadTypeMio,
413 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor12,
415 },
416 [kDtPadIor13] = {
417 .type = kDtPadTypeMio,
418 .mio_out_or_direct_pad = kTopScafiDeprecatedPinmuxMioOutIor13,
420 },
422 .type = kDtPadTypeDio,
423 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiHost0Sd0,
424 .insel = 0,
425 },
427 .type = kDtPadTypeDio,
428 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiHost0Sd1,
429 .insel = 0,
430 },
432 .type = kDtPadTypeDio,
433 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiHost0Sd2,
434 .insel = 0,
435 },
437 .type = kDtPadTypeDio,
438 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiHost0Sd3,
439 .insel = 0,
440 },
442 .type = kDtPadTypeDio,
443 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiDeviceSd0,
444 .insel = 0,
445 },
447 .type = kDtPadTypeDio,
448 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiDeviceSd1,
449 .insel = 0,
450 },
452 .type = kDtPadTypeDio,
453 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiDeviceSd2,
454 .insel = 0,
455 },
457 .type = kDtPadTypeDio,
458 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiDeviceSd3,
459 .insel = 0,
460 },
461 [kDtPadUsbdevUsbDp] = {
462 .type = kDtPadTypeDio,
463 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsUsbdevUsbDp,
464 .insel = 0,
465 },
466 [kDtPadUsbdevUsbDn] = {
467 .type = kDtPadTypeDio,
468 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsUsbdevUsbDn,
469 .insel = 0,
470 },
472 .type = kDtPadTypeDio,
473 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiDeviceSck,
474 .insel = 0,
475 },
477 .type = kDtPadTypeDio,
478 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiDeviceCsb,
479 .insel = 0,
480 },
482 .type = kDtPadTypeDio,
483 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiHost0Sck,
484 .insel = 0,
485 },
487 .type = kDtPadTypeDio,
488 .mio_out_or_direct_pad = kTopScafiDeprecatedDirectPadsSpiHost0Csb,
489 .insel = 0,
490 },
491};
492
493
494
495#define TRY_GET_PAD(pad, default) ({ if ((pad) < (dt_pad_t)0 || (int)(pad) >= kDtPadCount) return (default); &dt_pad[pad]; })
496
498 return TRY_GET_PAD(pad, kDtPadTypeUnspecified)->type;
499}
500
501dt_pinmux_mio_out_t dt_pad_mio_out(dt_pad_t pad) {
502 return (dt_pinmux_mio_out_t)TRY_GET_PAD(pad, 0)->mio_out_or_direct_pad;
503}
504
505dt_pinmux_muxed_pad_t dt_pad_mio_pad_index(dt_pad_t pad) {
506 // Same index as MIO_OUT.
507 return (dt_pinmux_muxed_pad_t)dt_pad_mio_out(pad);
508}
509
510dt_pinmux_insel_t dt_pad_mio_insel(dt_pad_t pad) {
511 return (dt_pinmux_insel_t)TRY_GET_PAD(pad, 0)->insel;
512}
513
514dt_pinmux_direct_pad_t dt_pad_dio_pad_index(dt_pad_t pad) {
515 return (dt_pinmux_direct_pad_t)TRY_GET_PAD(pad, 0)->mio_out_or_direct_pad;
516}
517
518/* Pin that is constantly tied to high-Z (input only) */
519const dt_periph_io_t kDtPeriphIoConstantHighZ = {
520 .__internal = {
521 .type = kDtPeriphIoTypeMio,
522 .periph_input_or_direct_pad = 0,
523 .outsel_or_dt_pad = kDtPinmuxOutselConstantHighZ,
524 }
525};
526
527/* Pin that is constantly tied to zero (input/output) */
528const dt_periph_io_t kDtPeriphIoConstantZero = {
529 .__internal = {
530 .type = kDtPeriphIoTypeMio,
531 .periph_input_or_direct_pad = 0,
532 .outsel_or_dt_pad = kDtPinmuxOutselConstantZero,
533 }
534};
535
536/* Pin that is constantly tied to one (input/output) */
537const dt_periph_io_t kDtPeriphIoConstantOne = {
538 .__internal = {
539 .type = kDtPeriphIoTypeMio,
540 .periph_input_or_direct_pad = 0,
541 .outsel_or_dt_pad = kDtPinmuxOutselConstantOne,
542 }
543};