Skip to content

Commit

Permalink
hal: renesas: ra: Initial support for mipi-dsi
Browse files Browse the repository at this point in the history
First commit to support r_mipi_dsi

Signed-off-by: Danh Doan <[email protected]>
  • Loading branch information
Danh Doan authored and thenguyenyf committed Nov 27, 2024
1 parent 1ce7f10 commit a3065f8
Show file tree
Hide file tree
Showing 7 changed files with 2,016 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/ra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_SDHI
fsp/src/r_sdhi/r_sdhi.c)
zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_DISPLAY
fsp/src/r_glcdc/r_glcdc.c)
zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_MIPI_DSI
fsp/src/r_mipi_dsi/r_mipi_dsi.c
fsp/src/r_mipi_phy/r_mipi_phy.c)

if(CONFIG_USE_RA_FSP_SCE)
zephyr_include_directories(
Expand Down
541 changes: 541 additions & 0 deletions drivers/ra/fsp/inc/api/r_mipi_dsi_api.h

Large diffs are not rendered by default.

106 changes: 106 additions & 0 deletions drivers/ra/fsp/inc/instances/r_mipi_dsi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef R_MIPI_DSI_H
#define R_MIPI_DSI_H

/***********************************************************************************************************************
* Includes
**********************************************************************************************************************/

#include "bsp_api.h"
#include "r_mipi_dsi_cfg.h"
#include "r_mipi_dsi_api.h"

/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
FSP_HEADER

/*******************************************************************************************************************//**
* @addtogroup MIPI_DSI
* @{
**********************************************************************************************************************/

/***********************************************************************************************************************
* Macro definitions
**********************************************************************************************************************/

/***********************************************************************************************************************
* Typedef definitions
**********************************************************************************************************************/

/** MIPI DSI interrupt configuration */
typedef struct st_mipi_dsi_irq_cfg
{
uint8_t ipl; ///< Interrupt priority
IRQn_Type irq; ///< Interrupt vector number
} mipi_dsi_irq_cfg_t;

/** Extended configuration structure for MIPI DSI. */
typedef struct st_mipi_dsi_extended_cfg
{
/* Interrupt configuration */
mipi_dsi_irq_cfg_t dsi_seq0; ///< Sequence 0 interrupt
mipi_dsi_irq_cfg_t dsi_seq1; ///< Sequence 1 interrupt
mipi_dsi_irq_cfg_t dsi_ferr; ///< DSI Fatal Error interrupt
mipi_dsi_irq_cfg_t dsi_ppi; ///< D-PHY PPI interrupt
mipi_dsi_irq_cfg_t dsi_rcv; ///< Receive interrupt
mipi_dsi_irq_cfg_t dsi_vin1; ///< Video Input Operation interrupt

uint32_t dsi_rxie; ///< Receive interrupt enable configuration
uint32_t dsi_ferrie; ///< Fatal error interrupt enable configuration
uint32_t dsi_plie; ///< Physical lane interrupt enable configuration
uint32_t dsi_vmie; ///< Video mode interrupt enable configuration
uint32_t dsi_sqch0ie; ///< Sequence Channel 0 interrupt enable configuration
uint32_t dsi_sqch1ie; ///< Sequence Channel 1 interrupt enable configuration
} mipi_dsi_extended_cfg_t;

/** MIPI DSI instance control block. */
typedef struct st_mipi_dsi_instance_ctrl
{
uint32_t open; ///< Interface is open
bool data_ulps_active; ///< Data lane ULPS status
bool clock_ulps_active; ///< Data lane ULPS status
mipi_dsi_lane_t ulps_status; ///< Ultra-low Power State active status
mipi_dsi_cfg_t const * p_cfg; ///< Pointer to configuration structure used to open the interface
void (* p_callback)(mipi_dsi_callback_args_t *); ///< Pointer to callback that is called when an adc_event_t occurs.
void const * p_context; ///< Pointer to context to be passed into callback function
mipi_dsi_callback_args_t * p_callback_memory; ///< Pointer to non-secure memory that can be used to pass arguments to a callback in non-secure memory.
} mipi_dsi_instance_ctrl_t;

/**********************************************************************************************************************
* Exported global variables
**********************************************************************************************************************/

/** @cond INC_HEADER_DEFS_SEC */
/** Filled in Interface API structure for this Instance. */
extern const mipi_dsi_api_t g_mipi_dsi;

/** @endcond */

/***********************************************************************************************************************
* Exported global functions (to be accessed by other files)
**********************************************************************************************************************/

/***********************************************************************************************************************
* Public APIs
**********************************************************************************************************************/
fsp_err_t R_MIPI_DSI_Open(mipi_dsi_ctrl_t * const p_api_ctrl, mipi_dsi_cfg_t const * const p_cfg);
fsp_err_t R_MIPI_DSI_Close(mipi_dsi_ctrl_t * const p_api_ctrl);
fsp_err_t R_MIPI_DSI_Start(mipi_dsi_ctrl_t * const p_api_ctrl);
fsp_err_t R_MIPI_DSI_UlpsEnter(mipi_dsi_ctrl_t * const p_api_ctrl, mipi_dsi_lane_t lane);
fsp_err_t R_MIPI_DSI_UlpsExit(mipi_dsi_ctrl_t * const p_api_ctrl, mipi_dsi_lane_t lane);
fsp_err_t R_MIPI_DSI_Stop(mipi_dsi_ctrl_t * const p_api_ctrl);
fsp_err_t R_MIPI_DSI_Command(mipi_dsi_ctrl_t * const p_api_ctrl, mipi_dsi_cmd_t * p_cmd);
fsp_err_t R_MIPI_DSI_StatusGet(mipi_dsi_ctrl_t * const p_api_ctrl, mipi_dsi_status_t * p_status);

/*******************************************************************************************************************//**
* @} (end defgroup MIPI_DSI)
**********************************************************************************************************************/

/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
FSP_FOOTER

#endif // R_MIPI_DSI_H
141 changes: 141 additions & 0 deletions drivers/ra/fsp/inc/instances/r_mipi_phy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef R_MIPI_PHY_H
#define R_MIPI_PHY_H

/***********************************************************************************************************************
* Includes
**********************************************************************************************************************/

#include "bsp_api.h"

/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
FSP_HEADER

/*******************************************************************************************************************//**
* @addtogroup MIPI_PHY
* @{
**********************************************************************************************************************/

/***********************************************************************************************************************
* Macro definitions
**********************************************************************************************************************/

/***********************************************************************************************************************
* Typedef definitions
**********************************************************************************************************************/

/* MIPI_PHY PLL speed configuration */
typedef union
{
__PACKED_STRUCT
{
uint8_t div; ///< PHY PLL divisor
uint8_t mul_frac; ///< PHY PLL fractional multiplier (0, 1/3, 2/3, or 1/2)
uint16_t mul_int; ///< PHY PLL integer multiplier (1-based)
};
uint32_t raw;
} mipi_phy_pll_cfg_t;

/** MIPI PHY D-PHY power mode transition timing */
typedef struct st_mipi_phy_timing
{
uint32_t t_init : 19; ///< Minimum duration of the TINIT state (Units: PCLKA cycles)
uint32_t : 13; // Padding
uint8_t t_clk_prep; ///< Duration of the clock lane LP-00 state (immediately before entry to the HS-0 state)
uint8_t t_hs_prep; ///< Duration of the data lane LP-00 state (immediately before entry to the HS-0 state)
union
{
__PACKED_STRUCT
{
uint8_t t_clk_zero; ///< TCLKZERO setting. See Figure 57.1 in User Manual (R01UH0995EJ0060) for more information
uint8_t t_clk_pre; ///< TCLKPRE setting. See Figure 57.1 in User Manual (R01UH0995EJ0060) for more information
uint8_t t_clk_post; ///< TCLKPOST setting. See Figure 57.1 in User Manual (R01UH0995EJ0060) for more information
uint8_t t_clk_trail; ///< TCLKTRAIL setting. See Figure 57.1 in User Manual (R01UH0995EJ0060) for more information
} dphytim4_b;
uint32_t dphytim4; ///< Clock lane pre and post data timing settings
};
union
{
__PACKED_STRUCT
{
uint8_t t_hs_zero; ///< THSZERO setting. See Figure 57.1 in User Maual (R01UH0995EJ0060) for more information
uint8_t t_hs_trail; ///< THSTRAIL setting. See Figure 57.1 in User Maual (R01UH0995EJ0060) for more information
uint8_t t_hs_exit; ///< THSEXIT setting. See Figure 57.1 in User Maual (R01UH0995EJ0060) for more information
uint8_t : 8;
} dphytim5_b;
uint32_t dphytim5; ///< High-Speed data lane timing settings
};
uint8_t t_lp_exit; ///< Low-power transition time to High-Speed mode
} mipi_phy_timing_t;

/** MIPI_PHY configuration structure. */
typedef struct st_mipi_phy_cfg
{
mipi_phy_pll_cfg_t pll_settings; ///< PHY PLL configuration (DPHYPLFCR)
uint8_t lp_divisor : 5; ///< PHY PLL LP speed divisor setting (DPHYESCCR)
mipi_phy_timing_t const * p_timing; ///< Pointer to D-PHY HS/LP transition timing values
} mipi_phy_cfg_t;

/** MIPI_PHY instance control block. */
typedef struct st_mipi_phy_ctrl
{
uint32_t open;
mipi_phy_cfg_t const * p_cfg;
} mipi_phy_ctrl_t;

/** Private Interface definition for MIPI PHY peripheral */
typedef struct st_mipi_phy_api
{
/** Open MIPI PHY device.
* @param[in,out] p_ctrl Pointer to MIPI PHY interface control block.
* @param[in] p_cfg Pointer to MIPI PHY configuration structure.
*/
fsp_err_t (* open)(mipi_phy_ctrl_t * const p_ctrl, mipi_phy_cfg_t const * const p_cfg);

/** Close MIPI PHY device.
* @param[in] p_ctrl Pointer to MIPI PHY interface control block.
*/
fsp_err_t (* close)(mipi_phy_ctrl_t * const p_ctrl);
} mipi_phy_api_t;

/** This structure encompasses everything that is needed to use an instance of this interface. */
typedef struct st_mipi_phy_instance
{
mipi_phy_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance
mipi_phy_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance
mipi_phy_api_t const * p_api; ///< Pointer to the API structure for this instance
} mipi_phy_instance_t;

/**********************************************************************************************************************
* Exported global variables
**********************************************************************************************************************/

/** @cond INC_HEADER_DEFS_SEC */
/** Filled in Interface API structure for this Instance. */
extern const mipi_phy_api_t g_mipi_phy;

/** @endcond */

/***********************************************************************************************************************
* Exported global functions (to be accessed by other files)
**********************************************************************************************************************/

/***********************************************************************************************************************
* Instance Functions (Note: This is not a public API and should not be called directly)
**********************************************************************************************************************/
fsp_err_t r_mipi_phy_open(mipi_phy_ctrl_t * const p_api_ctrl, mipi_phy_cfg_t const * const p_cfg);
fsp_err_t r_mipi_phy_close(mipi_phy_ctrl_t * const p_api_ctrl);

/*******************************************************************************************************************//**
* @} (end defgroup MIPI_PHY)
**********************************************************************************************************************/

/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
FSP_FOOTER

#endif // R_MIPI_PHY_H
Loading

0 comments on commit a3065f8

Please sign in to comment.