linux/drivers/gpu/drm/stm/lvds.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2023, STMicroelectronics - All Rights Reserved
 * Author(s): Raphaël GALLAIS-POU <[email protected]> for STMicroelectronics.
 */

#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_device.h>
#include <drm/drm_of.h>
#include <drm/drm_panel.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>

#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/media-bus-format.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/reset.h>

/* LVDS Host registers */
#define LVDS_CR
#define LVDS_DMLCR0
#define LVDS_DMMCR0
#define LVDS_DMLCR1
#define LVDS_DMMCR1
#define LVDS_DMLCR2
#define LVDS_DMMCR2
#define LVDS_DMLCR3
#define LVDS_DMMCR3
#define LVDS_DMLCR4
#define LVDS_DMMCR4
#define LVDS_CDL1CR
#define LVDS_CDL2CR

#define CDL1CR_DEFAULT
#define CDL2CR_DEFAULT

#define LVDS_DMLCR(bit)
#define LVDS_DMMCR(bit)

/* LVDS Wrapper registers */
#define LVDS_WCLKCR

#define LVDS_HWCFGR
#define LVDS_VERR
#define LVDS_IPIDR
#define LVDS_SIDR

/* Bitfield description */
#define CR_LVDSEN
#define CR_HSPOL
#define CR_VSPOL
#define CR_DEPOL
#define CR_CI
#define CR_LKMOD
#define CR_LKPHA
#define CR_LK1POL
#define CR_LK2POL

#define DMMCR_MAP0
#define DMMCR_MAP1
#define DMMCR_MAP2
#define DMMCR_MAP3
#define DMLCR_MAP4
#define DMLCR_MAP5
#define DMLCR_MAP6

#define CDLCR_DISTR0
#define CDLCR_DISTR1
#define CDLCR_DISTR2
#define CDLCR_DISTR3
#define CDLCR_DISTR4

#define PHY_GCR_BIT_CLK_OUT
#define PHY_GCR_LS_CLK_OUT
#define PHY_GCR_DP_CLK_OUT
#define PHY_GCR_RSTZ
#define PHY_GCR_DIV_RSTN
#define PHY_SCR_TX_EN
/* Current mode driver enable */
#define PHY_CMCR_CM_EN_DL
#define PHY_CMCR_CM_EN_DL4
/* Bias enable */
#define PHY_BCR1_EN_BIAS_DL
#define PHY_BCR2_BIAS_EN
/* Voltage mode driver enable */
#define PHY_BCR3_VM_EN_DL
#define PHY_DCR_POWER_OK
#define PHY_CFGCR_EN_DIG_DL
#define PHY_PLLCR1_PLL_EN
#define PHY_PLLCR1_EN_SD
#define PHY_PLLCR1_EN_TWG
#define PHY_PLLCR1_DIV_EN
#define PHY_PLLCR2_NDIV
#define PHY_PLLCR2_BDIV
#define PHY_PLLSR_PLL_LOCK
#define PHY_PLLSDCR1_MDIV
#define PHY_PLLTESTCR_TDIV
#define PHY_PLLTESTCR_CLK_EN
#define PHY_PLLTESTCR_EN

#define WCLKCR_SECND_CLKPIX_SEL
#define WCLKCR_SRCSEL

/* Sleep & timeout for pll lock/unlock */
#define SLEEP_US
#define TIMEOUT_US

/*
 * The link phase defines whether an ODD pixel is carried over together with
 * the next EVEN pixel or together with the previous EVEN pixel.
 *
 * LVDS_DUAL_LINK_EVEN_ODD_PIXELS (LKPHA = 0)
 *
 * ,--------.  ,--------.  ,--------.  ,--------.  ,---------.
 * | ODD  LK \/ PIXEL  3 \/ PIXEL  1 \/ PIXEL' 1 \/ PIXEL' 3 |
 * | EVEN LK /\ PIXEL  2 /\ PIXEL' 0 /\ PIXEL' 2 /\ PIXEL' 4 |
 * `--------'  `--------'  `--------'  `--------'  `---------'
 *
 * LVDS_DUAL_LINK_ODD_EVEN_PIXELS (LKPHA = 1)
 *
 * ,--------.  ,--------.  ,--------.  ,--------.  ,---------.
 * | ODD  LK \/ PIXEL  3 \/ PIXEL  1 \/ PIXEL' 1 \/ PIXEL' 3 |
 * | EVEN LK /\ PIXEL  4 /\ PIXEL  2 /\ PIXEL' 0 /\ PIXEL' 2 |
 * `--------'  `--------'  `--------'  `--------'  `---------'
 *
 */
enum lvds_link_type {};

enum lvds_pixel {};

struct phy_reg_offsets {};

struct lvds_phy_info {};

static struct lvds_phy_info lvds_phy_16ff_primary =;

static struct lvds_phy_info lvds_phy_16ff_secondary =;

struct stm_lvds {};

#define bridge_to_stm_lvds(b)

#define connector_to_stm_lvds(c)

#define lvds_is_dual_link(lvds)

static inline void lvds_write(struct stm_lvds *lvds, u32 reg, u32 val)
{}

static inline u32 lvds_read(struct stm_lvds *lvds, u32 reg)
{}

static inline void lvds_set(struct stm_lvds *lvds, u32 reg, u32 mask)
{}

static inline void lvds_clear(struct stm_lvds *lvds, u32 reg, u32 mask)
{}

/*
 * Expected JEIDA-RGB888 data to be sent in LSB format
 *	    bit6 ............................bit0
 * CHAN0   {ONE, ONE, ZERO, ZERO, ZERO, ONE, ONE}
 * CHAN1   {G2,  R7,  R6,   R5,   R4,   R3,  R2}
 * CHAN2   {B3,  B2,  G7,   G6,   G5,   G4,  G3}
 * CHAN3   {DE,  VS,  HS,   B7,   B6,   B5,  B4}
 * CHAN4   {CE,  B1,  B0,   G1,   G0,   R1,  R0}
 */
static enum lvds_pixel lvds_bitmap_jeida_rgb888[5][7] =;

/*
 * Expected VESA-RGB888 data to be sent in LSB format
 *	    bit6 ............................bit0
 * CHAN0   {ONE, ONE, ZERO, ZERO, ZERO, ONE, ONE}
 * CHAN1   {G0,  R5,  R4,   R3,   R2,   R1,  R0}
 * CHAN2   {B1,  B0,  G5,   G4,   G3,   G2,  G1}
 * CHAN3   {DE,  VS,  HS,   B5,   B4,   B3,  B2}
 * CHAN4   {CE,  B7,  B6,   G7,   G6,   R7,  R6}
 */
static enum lvds_pixel lvds_bitmap_vesa_rgb888[5][7] =;

/*
 * Clocks and PHY related functions
 */
static int lvds_pll_enable(struct stm_lvds *lvds, struct lvds_phy_info *phy)
{}

static int pll_get_clkout_khz(int clkin_khz, int bdiv, int mdiv, int ndiv)
{}

#define TDIV
#define NDIV_MIN
#define NDIV_MAX
#define BDIV_MIN
#define BDIV_MAX
#define MDIV_MIN
#define MDIV_MAX

static int lvds_pll_get_params(struct stm_lvds *lvds,
			       unsigned int clkin_khz, unsigned int clkout_khz,
			       unsigned int *bdiv, unsigned int *mdiv, unsigned int *ndiv)
{}

static void lvds_pll_config(struct stm_lvds *lvds, struct lvds_phy_info *phy)
{}

static int lvds_pixel_clk_enable(struct clk_hw *hw)
{}

static void lvds_pixel_clk_disable(struct clk_hw *hw)
{}

static unsigned long lvds_pixel_clk_recalc_rate(struct clk_hw *hw,
						unsigned long parent_rate)
{}

static long lvds_pixel_clk_round_rate(struct clk_hw *hw, unsigned long rate,
				      unsigned long *parent_rate)
{}

static const struct clk_ops lvds_pixel_clk_ops =;

static const struct clk_init_data clk_data =;

static void lvds_pixel_clk_unregister(void *data)
{}

static int lvds_pixel_clk_register(struct stm_lvds *lvds)
{}

/*
 * Host configuration related
 */
static void lvds_config_data_mapping(struct stm_lvds *lvds)
{}

static void lvds_config_mode(struct stm_lvds *lvds)
{}

static int lvds_connector_get_modes(struct drm_connector *connector)
{}

static int lvds_connector_atomic_check(struct drm_connector *connector,
				       struct drm_atomic_state *state)
{}

static const struct drm_connector_helper_funcs lvds_conn_helper_funcs =;

static const struct drm_connector_funcs lvds_conn_funcs =;

static int lvds_attach(struct drm_bridge *bridge,
		       enum drm_bridge_attach_flags flags)
{}

static void lvds_atomic_enable(struct drm_bridge *bridge,
			       struct drm_bridge_state *old_bridge_state)
{}

static void lvds_atomic_disable(struct drm_bridge *bridge,
				struct drm_bridge_state *old_bridge_state)
{}

static const struct drm_bridge_funcs lvds_bridge_funcs =;

static int lvds_probe(struct platform_device *pdev)
{}

static void lvds_remove(struct platform_device *pdev)
{}

static const struct of_device_id lvds_dt_ids[] =;

MODULE_DEVICE_TABLE(of, lvds_dt_ids);

static struct platform_driver lvds_platform_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();