2019-05-27 08:55:21 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2011-12-07 13:45:25 -03:00
|
|
|
/*
|
2020-05-27 23:59:40 +02:00
|
|
|
* drivers/media/i2c/ccs-pll.h
|
2011-12-07 13:45:25 -03:00
|
|
|
*
|
2020-05-27 23:59:40 +02:00
|
|
|
* Generic MIPI CCS/SMIA/SMIA++ PLL calculator
|
2011-12-07 13:45:25 -03:00
|
|
|
*
|
2020-05-27 23:59:40 +02:00
|
|
|
* Copyright (C) 2020 Intel Corporation
|
2011-12-07 13:45:25 -03:00
|
|
|
* Copyright (C) 2012 Nokia Corporation
|
2020-06-24 23:57:46 +02:00
|
|
|
* Contact: Sakari Ailus <sakari.ailus@linux.intel.com>
|
2011-12-07 13:45:25 -03:00
|
|
|
*/
|
|
|
|
|
2020-05-27 23:59:40 +02:00
|
|
|
#ifndef CCS_PLL_H
|
|
|
|
#define CCS_PLL_H
|
2011-12-07 13:45:25 -03:00
|
|
|
|
2012-10-20 10:35:25 -03:00
|
|
|
/* CSI-2 or CCP-2 */
|
2020-06-18 13:23:26 +02:00
|
|
|
#define CCS_PLL_BUS_TYPE_CSI2 0x00
|
2012-10-20 10:35:25 -03:00
|
|
|
|
|
|
|
/* op pix clock is for all lanes in total normally */
|
2020-05-27 23:59:40 +02:00
|
|
|
#define CCS_PLL_FLAG_OP_PIX_CLOCK_PER_LANE (1 << 0)
|
|
|
|
#define CCS_PLL_FLAG_NO_OP_CLOCKS (1 << 1)
|
2012-10-20 10:35:25 -03:00
|
|
|
|
2020-06-05 22:46:54 +02:00
|
|
|
struct ccs_pll_branch_fr {
|
|
|
|
uint16_t pre_pll_clk_div;
|
|
|
|
uint16_t pll_multiplier;
|
|
|
|
uint32_t pll_ip_clk_freq_hz;
|
|
|
|
uint32_t pll_op_clk_freq_hz;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ccs_pll_branch_bk {
|
2014-09-16 09:07:11 -03:00
|
|
|
uint16_t sys_clk_div;
|
|
|
|
uint16_t pix_clk_div;
|
|
|
|
uint32_t sys_clk_freq_hz;
|
|
|
|
uint32_t pix_clk_freq_hz;
|
|
|
|
};
|
|
|
|
|
2020-05-27 23:59:40 +02:00
|
|
|
struct ccs_pll {
|
2012-10-20 10:35:25 -03:00
|
|
|
/* input values */
|
|
|
|
uint8_t bus_type;
|
2020-06-18 13:23:26 +02:00
|
|
|
struct {
|
|
|
|
uint8_t lanes;
|
|
|
|
} csi2;
|
2014-04-08 18:14:42 -03:00
|
|
|
unsigned long flags;
|
2011-12-07 13:45:25 -03:00
|
|
|
uint8_t binning_horizontal;
|
|
|
|
uint8_t binning_vertical;
|
|
|
|
uint8_t scale_m;
|
|
|
|
uint8_t scale_n;
|
|
|
|
uint8_t bits_per_pixel;
|
|
|
|
uint32_t link_freq;
|
2014-09-16 09:04:35 -03:00
|
|
|
uint32_t ext_clk_freq_hz;
|
2011-12-07 13:45:25 -03:00
|
|
|
|
2012-10-20 10:35:25 -03:00
|
|
|
/* output values */
|
2020-06-05 22:46:54 +02:00
|
|
|
struct ccs_pll_branch_fr vt_fr;
|
|
|
|
struct ccs_pll_branch_bk vt_bk;
|
|
|
|
struct ccs_pll_branch_bk op_bk;
|
2011-12-07 13:45:25 -03:00
|
|
|
|
|
|
|
uint32_t pixel_rate_csi;
|
2014-04-01 19:18:09 -03:00
|
|
|
uint32_t pixel_rate_pixel_array;
|
2011-12-07 13:45:25 -03:00
|
|
|
};
|
|
|
|
|
2020-06-05 22:46:54 +02:00
|
|
|
struct ccs_pll_branch_limits_fr {
|
|
|
|
uint16_t min_pre_pll_clk_div;
|
|
|
|
uint16_t max_pre_pll_clk_div;
|
|
|
|
uint32_t min_pll_ip_clk_freq_hz;
|
|
|
|
uint32_t max_pll_ip_clk_freq_hz;
|
|
|
|
uint16_t min_pll_multiplier;
|
|
|
|
uint16_t max_pll_multiplier;
|
|
|
|
uint32_t min_pll_op_clk_freq_hz;
|
|
|
|
uint32_t max_pll_op_clk_freq_hz;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ccs_pll_branch_limits_bk {
|
2012-10-22 11:40:56 -03:00
|
|
|
uint16_t min_sys_clk_div;
|
|
|
|
uint16_t max_sys_clk_div;
|
|
|
|
uint32_t min_sys_clk_freq_hz;
|
|
|
|
uint32_t max_sys_clk_freq_hz;
|
|
|
|
uint16_t min_pix_clk_div;
|
|
|
|
uint16_t max_pix_clk_div;
|
|
|
|
uint32_t min_pix_clk_freq_hz;
|
|
|
|
uint32_t max_pix_clk_freq_hz;
|
|
|
|
};
|
|
|
|
|
2020-05-27 23:59:40 +02:00
|
|
|
struct ccs_pll_limits {
|
2011-12-07 13:45:25 -03:00
|
|
|
/* Strict PLL limits */
|
|
|
|
uint32_t min_ext_clk_freq_hz;
|
|
|
|
uint32_t max_ext_clk_freq_hz;
|
|
|
|
|
2020-06-05 22:46:54 +02:00
|
|
|
struct ccs_pll_branch_limits_fr vt_fr;
|
|
|
|
struct ccs_pll_branch_limits_bk vt_bk;
|
|
|
|
struct ccs_pll_branch_limits_bk op_bk;
|
2011-12-07 13:45:25 -03:00
|
|
|
|
|
|
|
/* Other relevant limits */
|
|
|
|
uint32_t min_line_length_pck_bin;
|
|
|
|
uint32_t min_line_length_pck;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct device;
|
|
|
|
|
2020-05-27 23:59:40 +02:00
|
|
|
int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *limits,
|
|
|
|
struct ccs_pll *pll);
|
2011-12-07 13:45:25 -03:00
|
|
|
|
2020-05-27 23:59:40 +02:00
|
|
|
#endif /* CCS_PLL_H */
|