Software APIs
dt_gpio.h File Reference

Device Tables (DT) for IP gpio and top earlgrey. More...

#include "dt_api.h"
#include <stdint.h>

Go to the source code of this file.

Macros

#define OPENTITAN_GPIO_HAS_IN_INTR_CTRL   1
 List of supported hardware features.
 
#define OPENTITAN_GPIO_HAS_IN_FILTER   1
 
#define OPENTITAN_GPIO_HAS_OUT_MASK   1
 

Typedefs

typedef enum dt_gpio dt_gpio_t
 List of instances.
 
typedef enum dt_gpio_reg_block dt_gpio_reg_block_t
 List of register blocks.
 
typedef enum dt_gpio_irq dt_gpio_irq_t
 List of IRQs.
 
typedef enum dt_gpio_alert dt_gpio_alert_t
 List of Alerts.
 
typedef enum dt_gpio_clock dt_gpio_clock_t
 List of clock ports.
 
typedef enum dt_gpio_reset dt_gpio_reset_t
 List of reset ports.
 
typedef enum dt_gpio_periph_io dt_gpio_periph_io_t
 List of peripheral I/O.
 

Enumerations

enum  dt_gpio {
  kDtGpio = 0 ,
  kDtGpioFirst = 0 ,
  kDtGpioCount = 1
}
 List of instances. More...
 
enum  dt_gpio_reg_block {
  kDtGpioRegBlockCore = 0 ,
  kDtGpioRegBlockCount = 1
}
 List of register blocks. More...
 
enum  dt_gpio_irq {
  kDtGpioIrqGpio0 = 0 ,
  kDtGpioIrqGpio1 = 1 ,
  kDtGpioIrqGpio2 = 2 ,
  kDtGpioIrqGpio3 = 3 ,
  kDtGpioIrqGpio4 = 4 ,
  kDtGpioIrqGpio5 = 5 ,
  kDtGpioIrqGpio6 = 6 ,
  kDtGpioIrqGpio7 = 7 ,
  kDtGpioIrqGpio8 = 8 ,
  kDtGpioIrqGpio9 = 9 ,
  kDtGpioIrqGpio10 = 10 ,
  kDtGpioIrqGpio11 = 11 ,
  kDtGpioIrqGpio12 = 12 ,
  kDtGpioIrqGpio13 = 13 ,
  kDtGpioIrqGpio14 = 14 ,
  kDtGpioIrqGpio15 = 15 ,
  kDtGpioIrqGpio16 = 16 ,
  kDtGpioIrqGpio17 = 17 ,
  kDtGpioIrqGpio18 = 18 ,
  kDtGpioIrqGpio19 = 19 ,
  kDtGpioIrqGpio20 = 20 ,
  kDtGpioIrqGpio21 = 21 ,
  kDtGpioIrqGpio22 = 22 ,
  kDtGpioIrqGpio23 = 23 ,
  kDtGpioIrqGpio24 = 24 ,
  kDtGpioIrqGpio25 = 25 ,
  kDtGpioIrqGpio26 = 26 ,
  kDtGpioIrqGpio27 = 27 ,
  kDtGpioIrqGpio28 = 28 ,
  kDtGpioIrqGpio29 = 29 ,
  kDtGpioIrqGpio30 = 30 ,
  kDtGpioIrqGpio31 = 31 ,
  kDtGpioIrqCount = 32
}
 List of IRQs. More...
 
enum  dt_gpio_alert {
  kDtGpioAlertFatalFault = 0 ,
  kDtGpioAlertCount = 1
}
 List of Alerts. More...
 
enum  dt_gpio_clock {
  kDtGpioClockClk = 0 ,
  kDtGpioClockCount = 1
}
 List of clock ports. More...
 
enum  dt_gpio_reset {
  kDtGpioResetRst = 0 ,
  kDtGpioResetCount = 1
}
 List of reset ports. More...
 
enum  dt_gpio_periph_io {
  kDtGpioPeriphIoGpio0 = 0 ,
  kDtGpioPeriphIoGpio1 = 1 ,
  kDtGpioPeriphIoGpio2 = 2 ,
  kDtGpioPeriphIoGpio3 = 3 ,
  kDtGpioPeriphIoGpio4 = 4 ,
  kDtGpioPeriphIoGpio5 = 5 ,
  kDtGpioPeriphIoGpio6 = 6 ,
  kDtGpioPeriphIoGpio7 = 7 ,
  kDtGpioPeriphIoGpio8 = 8 ,
  kDtGpioPeriphIoGpio9 = 9 ,
  kDtGpioPeriphIoGpio10 = 10 ,
  kDtGpioPeriphIoGpio11 = 11 ,
  kDtGpioPeriphIoGpio12 = 12 ,
  kDtGpioPeriphIoGpio13 = 13 ,
  kDtGpioPeriphIoGpio14 = 14 ,
  kDtGpioPeriphIoGpio15 = 15 ,
  kDtGpioPeriphIoGpio16 = 16 ,
  kDtGpioPeriphIoGpio17 = 17 ,
  kDtGpioPeriphIoGpio18 = 18 ,
  kDtGpioPeriphIoGpio19 = 19 ,
  kDtGpioPeriphIoGpio20 = 20 ,
  kDtGpioPeriphIoGpio21 = 21 ,
  kDtGpioPeriphIoGpio22 = 22 ,
  kDtGpioPeriphIoGpio23 = 23 ,
  kDtGpioPeriphIoGpio24 = 24 ,
  kDtGpioPeriphIoGpio25 = 25 ,
  kDtGpioPeriphIoGpio26 = 26 ,
  kDtGpioPeriphIoGpio27 = 27 ,
  kDtGpioPeriphIoGpio28 = 28 ,
  kDtGpioPeriphIoGpio29 = 29 ,
  kDtGpioPeriphIoGpio30 = 30 ,
  kDtGpioPeriphIoGpio31 = 31 ,
  kDtGpioPeriphIoCount = 32
}
 List of peripheral I/O. More...
 

Functions

dt_gpio_t dt_gpio_from_instance_id (dt_instance_id_t inst_id)
 Get the gpio instance from an instance ID.
 
dt_instance_id_t dt_gpio_instance_id (dt_gpio_t dt)
 Get the instance ID of an instance.
 
uint32_t dt_gpio_reg_block (dt_gpio_t dt, dt_gpio_reg_block_t reg_block)
 Get the register base address of an instance.
 
dt_plic_irq_id_t dt_gpio_irq_to_plic_id (dt_gpio_t dt, dt_gpio_irq_t irq)
 Get the PLIC ID of a gpio IRQ for a given instance.
 
dt_gpio_irq_t dt_gpio_irq_from_plic_id (dt_gpio_t dt, dt_plic_irq_id_t irq)
 Convert a global IRQ ID to a local gpio IRQ type.
 
dt_alert_id_t dt_gpio_alert_to_alert_id (dt_gpio_t dt, dt_gpio_alert_t alert)
 Get the alert ID of a gpio alert for a given instance.
 
dt_gpio_alert_t dt_gpio_alert_from_alert_id (dt_gpio_t dt, dt_alert_id_t alert)
 Convert a global alert ID to a local gpio alert type.
 
dt_periph_io_t dt_gpio_periph_io (dt_gpio_t dt, dt_gpio_periph_io_t sig)
 Get the peripheral I/O description of an instance.
 
dt_clock_t dt_gpio_clock (dt_gpio_t dt, dt_gpio_clock_t clk)
 Get the clock signal connected to a clock port of an instance.
 
dt_reset_t dt_gpio_reset (dt_gpio_t dt, dt_gpio_reset_t rst)
 Get the reset signal connected to a reset port of an instance.
 

Detailed Description

Device Tables (DT) for IP gpio and top earlgrey.

This file contains the type definitions and global functions of the gpio.

Definition in file dt_gpio.h.

Macro Definition Documentation

◆ OPENTITAN_GPIO_HAS_IN_FILTER

#define OPENTITAN_GPIO_HAS_IN_FILTER   1

Definition at line 158 of file dt_gpio.h.

◆ OPENTITAN_GPIO_HAS_IN_INTR_CTRL

#define OPENTITAN_GPIO_HAS_IN_INTR_CTRL   1

List of supported hardware features.

Definition at line 157 of file dt_gpio.h.

◆ OPENTITAN_GPIO_HAS_OUT_MASK

#define OPENTITAN_GPIO_HAS_OUT_MASK   1

Definition at line 159 of file dt_gpio.h.

Typedef Documentation

◆ dt_gpio_alert_t

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

◆ dt_gpio_clock_t

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

◆ dt_gpio_irq_t

typedef enum dt_gpio_irq dt_gpio_irq_t

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

◆ dt_gpio_periph_io_t

List of peripheral I/O.

Peripheral I/O are guaranteed to be numbered consecutively from 0.

◆ dt_gpio_reg_block_t

List of register blocks.

Register blocks are guaranteed to start at 0 and to be consecutively numbered.

◆ dt_gpio_reset_t

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumeration Type Documentation

◆ dt_gpio

enum dt_gpio

List of instances.

Enumerator
kDtGpio 

gpio

Definition at line 23 of file dt_gpio.h.

◆ dt_gpio_alert

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

Enumerator
kDtGpioAlertFatalFault 

This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.

Definition at line 88 of file dt_gpio.h.

◆ dt_gpio_clock

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtGpioClockClk 

Clock port clk_i.

Definition at line 98 of file dt_gpio.h.

◆ dt_gpio_irq

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

Enumerator
kDtGpioIrqGpio0 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio1 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio2 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio3 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio4 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio5 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio6 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio7 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio8 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio9 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio10 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio11 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio12 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio13 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio14 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio15 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio16 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio17 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio18 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio19 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio20 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio21 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio22 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio23 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio24 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio25 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio26 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio27 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio28 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio29 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio30 

raised if any of GPIO pin detects configured interrupt mode

kDtGpioIrqGpio31 

raised if any of GPIO pin detects configured interrupt mode

Definition at line 47 of file dt_gpio.h.

◆ dt_gpio_periph_io

List of peripheral I/O.

Peripheral I/O are guaranteed to be numbered consecutively from 0.

Definition at line 118 of file dt_gpio.h.

◆ dt_gpio_reg_block

List of register blocks.

Register blocks are guaranteed to start at 0 and to be consecutively numbered.

Definition at line 34 of file dt_gpio.h.

◆ dt_gpio_reset

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtGpioResetRst 

Reset port rst_ni.

Definition at line 108 of file dt_gpio.h.

Function Documentation

◆ dt_gpio_alert_from_alert_id()

dt_gpio_alert_t dt_gpio_alert_from_alert_id ( dt_gpio_t dt,
dt_alert_id_t alert )

Convert a global alert ID to a local gpio alert type.

Parameters
dtInstance of gpio.
alertA global alert ID that belongs to this instance.
Returns
The gpio alert, or kDtGpioAlertCount.

Note: This function assumes that the global alert ID belongs to the instance of gpio passed in parameter. In other words, it must be the case that dt_gpio_instance_id(dt) == dt_alert_id_to_instance_id(alert). Otherwise, this function will return kDtGpioAlertCount.

Definition at line 374 of file dt_gpio.c.

◆ dt_gpio_alert_to_alert_id()

dt_alert_id_t dt_gpio_alert_to_alert_id ( dt_gpio_t dt,
dt_gpio_alert_t alert )

Get the alert ID of a gpio alert for a given instance.

Note: This function only makes sense if the instance is connected to the Alert Handler. For any instances where the instance is not connected, the return value is unspecified.

Parameters
dtInstance of gpio.
alertA gpio alert.
Returns
The Alert Handler alert ID of the alert of this instance.

Definition at line 368 of file dt_gpio.c.

◆ dt_gpio_clock()

Get the clock signal connected to a clock port of an instance.

Parameters
dtInstance of gpio.
clkClock port.
Returns
Clock signal.

Definition at line 392 of file dt_gpio.c.

◆ dt_gpio_from_instance_id()

dt_gpio_t dt_gpio_from_instance_id ( dt_instance_id_t inst_id)

Get the gpio instance from an instance ID.

For example, dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3.

Parameters
inst_idInstance ID.
Returns
A gpio instance.

Note: This function only makes sense if the instance ID has device type gpio, otherwise the returned value is unspecified.

Definition at line 324 of file dt_gpio.c.

◆ dt_gpio_instance_id()

dt_instance_id_t dt_gpio_instance_id ( dt_gpio_t dt)

Get the instance ID of an instance.

Parameters
dtInstance of gpio.
Returns
The instance ID of that instance.

Definition at line 331 of file dt_gpio.c.

◆ dt_gpio_irq_from_plic_id()

dt_gpio_irq_t dt_gpio_irq_from_plic_id ( dt_gpio_t dt,
dt_plic_irq_id_t irq )

Convert a global IRQ ID to a local gpio IRQ type.

Parameters
dtInstance of gpio.
irqA PLIC ID that belongs to this instance.
Returns
The gpio IRQ, or kDtGpioIrqCount.

Note: This function assumes that the PLIC ID belongs to the instance of gpio passed in parameter. In other words, it must be the case that dt_gpio_instance_id(dt) == dt_plic_id_to_instance_id(irq). Otherwise, this function will return kDtGpioIrqCount.

Definition at line 353 of file dt_gpio.c.

◆ dt_gpio_irq_to_plic_id()

dt_plic_irq_id_t dt_gpio_irq_to_plic_id ( dt_gpio_t dt,
dt_gpio_irq_t irq )

Get the PLIC ID of a gpio IRQ for a given instance.

If the instance is not connected to the PLIC, this function will return kDtPlicIrqIdNone.

Parameters
dtInstance of gpio.
irqA gpio IRQ.
Returns
The PLIC ID of the IRQ of this instance.

Definition at line 343 of file dt_gpio.c.

◆ dt_gpio_periph_io()

Get the peripheral I/O description of an instance.

Parameters
dtInstance of gpio.
sigRequested peripheral I/O.
Returns
Description of the requested peripheral I/O for this instance.

Definition at line 385 of file dt_gpio.c.

◆ dt_gpio_reg_block()

uint32_t dt_gpio_reg_block ( dt_gpio_t dt,
dt_gpio_reg_block_t reg_block )

Get the register base address of an instance.

Parameters
dtInstance of gpio.
reg_blockThe register block requested.
Returns
The register base address of the requested block.

Definition at line 336 of file dt_gpio.c.

◆ dt_gpio_reset()

Get the reset signal connected to a reset port of an instance.

Parameters
dtInstance of gpio.
rstReset port.
Returns
Reset signal.

Definition at line 399 of file dt_gpio.c.