#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/of.h>
#include <linux/of_graph.h>
#include <linux/mfd/syscon.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_bridge_connector.h>
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_simple_kms_helper.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
#include "kmb_dsi.h"
#include "kmb_regs.h"
static struct mipi_dsi_host *dsi_host;
static struct mipi_dsi_device *dsi_device;
static struct drm_bridge *adv_bridge;
#define IMG_HEIGHT_LINES …
#define IMG_WIDTH_PX …
#define MIPI_TX_ACTIVE_LANES …
static struct mipi_tx_frame_section_cfg mipi_tx_frame0_sect_cfg = …;
static struct mipi_tx_frame_cfg mipitx_frame0_cfg = …;
static const struct mipi_tx_dsi_cfg mipitx_dsi_cfg = …;
static struct mipi_ctrl_cfg mipi_tx_init_cfg = …;
struct mipi_hs_freq_range_cfg { … };
struct vco_params { … };
static const struct vco_params vco_table[] = …;
static const struct mipi_hs_freq_range_cfg
mipi_hs_freq_range[MIPI_DPHY_DEFAULT_BIT_RATES] = …;
static void kmb_dsi_clk_disable(struct kmb_dsi *kmb_dsi)
{ … }
void kmb_dsi_host_unregister(struct kmb_dsi *kmb_dsi)
{ … }
static ssize_t kmb_dsi_host_transfer(struct mipi_dsi_host *host,
const struct mipi_dsi_msg *msg)
{ … }
static int kmb_dsi_host_attach(struct mipi_dsi_host *host,
struct mipi_dsi_device *dev)
{ … }
static int kmb_dsi_host_detach(struct mipi_dsi_host *host,
struct mipi_dsi_device *dev)
{ … }
static const struct mipi_dsi_host_ops kmb_dsi_host_ops = …;
int kmb_dsi_host_bridge_init(struct device *dev)
{ … }
static u32 mipi_get_datatype_params(u32 data_type, u32 data_mode,
struct mipi_data_type_params *params)
{ … }
static u32 compute_wc(u32 width_px, u8 size_constr_p, u8 size_constr_b)
{ … }
static u32 compute_unpacked_bytes(u32 wc, u8 bits_per_pclk)
{ … }
static u32 mipi_tx_fg_section_cfg_regs(struct kmb_dsi *kmb_dsi,
u8 frame_id, u8 section,
u32 height_lines, u32 unpacked_bytes,
struct mipi_tx_frame_sect_phcfg *ph_cfg)
{ … }
static u32 mipi_tx_fg_section_cfg(struct kmb_dsi *kmb_dsi,
u8 frame_id, u8 section,
struct mipi_tx_frame_section_cfg *frame_scfg,
u32 *bits_per_pclk, u32 *wc)
{ … }
#define CLK_DIFF_LOW …
#define CLK_DIFF_HI …
#define SYSCLK_500 …
static void mipi_tx_fg_cfg_regs(struct kmb_dsi *kmb_dsi, u8 frame_gen,
struct mipi_tx_frame_timing_cfg *fg_cfg)
{ … }
static void mipi_tx_fg_cfg(struct kmb_dsi *kmb_dsi, u8 frame_gen,
u8 active_lanes, u32 bpp, u32 wc,
u32 lane_rate_mbps, struct mipi_tx_frame_cfg *fg_cfg)
{ … }
static void mipi_tx_multichannel_fifo_cfg(struct kmb_dsi *kmb_dsi,
u8 active_lanes, u8 vchannel_id)
{ … }
static void mipi_tx_ctrl_cfg(struct kmb_dsi *kmb_dsi, u8 fg_id,
struct mipi_ctrl_cfg *ctrl_cfg)
{ … }
static u32 mipi_tx_init_cntrl(struct kmb_dsi *kmb_dsi,
struct mipi_ctrl_cfg *ctrl_cfg)
{ … }
static void test_mode_send(struct kmb_dsi *kmb_dsi, u32 dphy_no,
u32 test_code, u32 test_data)
{ … }
static inline void
set_test_mode_src_osc_freq_target_low_bits(struct kmb_dsi *kmb_dsi,
u32 dphy_no,
u32 freq)
{ … }
static inline void
set_test_mode_src_osc_freq_target_hi_bits(struct kmb_dsi *kmb_dsi,
u32 dphy_no,
u32 freq)
{ … }
static void mipi_tx_get_vco_params(struct vco_params *vco)
{ … }
static void mipi_tx_pll_setup(struct kmb_dsi *kmb_dsi, u32 dphy_no,
u32 ref_clk_mhz, u32 target_freq_mhz)
{ … }
static void set_slewrate_gt_1500(struct kmb_dsi *kmb_dsi, u32 dphy_no)
{ … }
static void set_slewrate_gt_1000(struct kmb_dsi *kmb_dsi, u32 dphy_no)
{ … }
static void set_slewrate_lt_1000(struct kmb_dsi *kmb_dsi, u32 dphy_no)
{ … }
static void setup_pll(struct kmb_dsi *kmb_dsi, u32 dphy_no,
struct mipi_ctrl_cfg *cfg)
{ … }
static void set_lane_data_rate(struct kmb_dsi *kmb_dsi, u32 dphy_no,
struct mipi_ctrl_cfg *cfg)
{ … }
static void dphy_init_sequence(struct kmb_dsi *kmb_dsi,
struct mipi_ctrl_cfg *cfg, u32 dphy_no,
int active_lanes, enum dphy_mode mode)
{ … }
static void dphy_wait_fsm(struct kmb_dsi *kmb_dsi, u32 dphy_no,
enum dphy_tx_fsm fsm_state)
{ … }
static void wait_init_done(struct kmb_dsi *kmb_dsi, u32 dphy_no,
u32 active_lanes)
{ … }
static void wait_pll_lock(struct kmb_dsi *kmb_dsi, u32 dphy_no)
{ … }
static u32 mipi_tx_init_dphy(struct kmb_dsi *kmb_dsi,
struct mipi_ctrl_cfg *cfg)
{ … }
static void connect_lcd_to_mipi(struct kmb_dsi *kmb_dsi,
struct drm_atomic_state *old_state)
{ … }
int kmb_dsi_mode_set(struct kmb_dsi *kmb_dsi, struct drm_display_mode *mode,
int sys_clk_mhz, struct drm_atomic_state *old_state)
{ … }
struct kmb_dsi *kmb_dsi_init(struct platform_device *pdev)
{ … }
int kmb_dsi_encoder_init(struct drm_device *dev, struct kmb_dsi *kmb_dsi)
{ … }
int kmb_dsi_map_mmio(struct kmb_dsi *kmb_dsi)
{ … }
static int kmb_dsi_clk_enable(struct kmb_dsi *kmb_dsi)
{ … }
int kmb_dsi_clk_init(struct kmb_dsi *kmb_dsi)
{ … }