linux/drivers/gpu/drm/loongson/lsdc_pixpll.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2023 Loongson Technology Corporation Limited
 */

#include <linux/delay.h>

#include <drm/drm_managed.h>

#include "lsdc_drv.h"

/*
 * The structure of the pixel PLL registers is evolved with times,
 * it can be different across different chip also.
 */

/* size is u64, note that all loongson's cpu is little endian.
 * This structure is same for ls7a2000, ls7a1000 and ls2k2000.
 */
struct lsdc_pixpll_reg {};

lsdc_pixpll_reg_bitmap;

struct clk_to_pixpll_parms_lookup_t {};

static const struct clk_to_pixpll_parms_lookup_t pixpll_parms_table[] =;

static void lsdc_pixel_pll_free(struct drm_device *ddev, void *data)
{}

/*
 * ioremap the device dependent PLL registers
 *
 * @this: point to the object where this function is called from
 */
static int lsdc_pixel_pll_setup(struct lsdc_pixpll * const this)
{}

/*
 * Find a set of pll parameters from a static local table which avoid
 * computing the pll parameter eachtime a modeset is triggered.
 *
 * @this: point to the object where this function is called from
 * @clock: the desired output pixel clock, the unit is kHz
 * @pout: point to where the parameters to store if found
 *
 * Return 0 if success, return -1 if not found.
 */
static int lsdc_pixpll_find(struct lsdc_pixpll * const this,
			    unsigned int clock,
			    struct lsdc_pixpll_parms *pout)
{}

/*
 * Find a set of pll parameters which have minimal difference with the
 * desired pixel clock frequency. It does that by computing all of the
 * possible combination. Compute the diff and find the combination with
 * minimal diff.
 *
 * clock_out = refclk / div_ref * loopc / div_out
 *
 * refclk is determined by the oscillator mounted on motherboard(100MHz
 * in almost all board)
 *
 * @this: point to the object from where this function is called
 * @clock: the desired output pixel clock, the unit is kHz
 * @pout: point to the out struct of lsdc_pixpll_parms
 *
 * Return 0 if a set of parameter is found, otherwise return the error
 * between clock_kHz we wanted and the most closest candidate with it.
 */
static int lsdc_pixel_pll_compute(struct lsdc_pixpll * const this,
				  unsigned int clock,
				  struct lsdc_pixpll_parms *pout)
{}

/* Pixel pll hardware related ops, per display pipe */

static void __pixpll_rreg(struct lsdc_pixpll *this,
			  union lsdc_pixpll_reg_bitmap *dst)
{}

static void __pixpll_wreg(struct lsdc_pixpll *this,
			  union lsdc_pixpll_reg_bitmap *src)
{}

static void __pixpll_ops_powerup(struct lsdc_pixpll * const this)
{}

static void __pixpll_ops_powerdown(struct lsdc_pixpll * const this)
{}

static void __pixpll_ops_on(struct lsdc_pixpll * const this)
{}

static void __pixpll_ops_off(struct lsdc_pixpll * const this)
{}

static void __pixpll_ops_bypass(struct lsdc_pixpll * const this)
{}

static void __pixpll_ops_unbypass(struct lsdc_pixpll * const this)
{}

static void __pixpll_ops_untoggle_param(struct lsdc_pixpll * const this)
{}

static void __pixpll_ops_set_param(struct lsdc_pixpll * const this,
				   struct lsdc_pixpll_parms const *p)
{}

static void __pixpll_ops_toggle_param(struct lsdc_pixpll * const this)
{}

static void __pixpll_ops_wait_locked(struct lsdc_pixpll * const this)
{}

/*
 * Update the PLL parameters to the PLL hardware
 *
 * @this: point to the object from which this function is called
 * @pin: point to the struct of lsdc_pixpll_parms passed in
 *
 * return 0 if successful.
 */
static int lsdc_pixpll_update(struct lsdc_pixpll * const this,
			      struct lsdc_pixpll_parms const *pin)
{}

static unsigned int lsdc_pixpll_get_freq(struct lsdc_pixpll * const this)
{}

static void lsdc_pixpll_print(struct lsdc_pixpll * const this,
			      struct drm_printer *p)
{}

/*
 * LS7A1000, LS7A2000 and ls2k2000's pixel pll setting register is same,
 * we take this as default, create a new instance if a different model is
 * introduced.
 */
static const struct lsdc_pixpll_funcs __pixpll_default_funcs =;

/* pixel pll initialization */

int lsdc_pixpll_init(struct lsdc_pixpll * const this,
		     struct drm_device *ddev,
		     unsigned int index)
{}