2019-05-29 14:17:58 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-08-13 21:45:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DSI_PHY_H__
|
|
|
|
#define __DSI_PHY_H__
|
|
|
|
|
2021-03-31 10:57:24 +00:00
|
|
|
#include <linux/clk-provider.h>
|
2021-03-31 10:57:29 +00:00
|
|
|
#include <linux/delay.h>
|
2015-08-13 21:45:52 +00:00
|
|
|
#include <linux/regulator/consumer.h>
|
|
|
|
|
|
|
|
#include "dsi.h"
|
|
|
|
|
|
|
|
#define dsi_phy_read(offset) msm_readl((offset))
|
|
|
|
#define dsi_phy_write(offset, data) msm_writel((data), (offset))
|
2021-03-31 10:57:30 +00:00
|
|
|
#define dsi_phy_write_udelay(offset, data, delay_us) { msm_writel((data), (offset)); udelay(delay_us); }
|
|
|
|
#define dsi_phy_write_ndelay(offset, data, delay_ns) { msm_writel((data), (offset)); ndelay(delay_ns); }
|
2015-08-13 21:45:52 +00:00
|
|
|
|
|
|
|
struct msm_dsi_phy_ops {
|
2021-03-31 10:57:17 +00:00
|
|
|
int (*pll_init)(struct msm_dsi_phy *phy);
|
2021-03-31 10:57:35 +00:00
|
|
|
int (*enable)(struct msm_dsi_phy *phy,
|
2017-01-07 08:54:38 +00:00
|
|
|
struct msm_dsi_phy_clk_request *clk_req);
|
2015-08-13 21:45:52 +00:00
|
|
|
void (*disable)(struct msm_dsi_phy *phy);
|
2021-03-31 10:57:28 +00:00
|
|
|
void (*save_pll_state)(struct msm_dsi_phy *phy);
|
|
|
|
int (*restore_pll_state)(struct msm_dsi_phy *phy);
|
2021-08-05 17:08:17 +00:00
|
|
|
bool (*set_continuous_clock)(struct msm_dsi_phy *phy, bool enable);
|
2021-03-31 10:57:17 +00:00
|
|
|
};
|
|
|
|
|
2015-08-13 21:45:52 +00:00
|
|
|
struct msm_dsi_phy_cfg {
|
|
|
|
struct dsi_reg_config reg_cfg;
|
|
|
|
struct msm_dsi_phy_ops ops;
|
|
|
|
|
2021-03-31 10:57:19 +00:00
|
|
|
unsigned long min_pll_rate;
|
|
|
|
unsigned long max_pll_rate;
|
|
|
|
|
2016-06-23 09:56:04 +00:00
|
|
|
const resource_size_t io_start[DSI_MAX];
|
|
|
|
const int num_dsi_phy;
|
2019-05-30 16:00:49 +00:00
|
|
|
const int quirks;
|
2021-03-31 10:57:14 +00:00
|
|
|
bool has_phy_regulator;
|
|
|
|
bool has_phy_lane;
|
2015-08-13 21:45:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs;
|
2019-10-31 10:43:59 +00:00
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_famb_cfgs;
|
2015-08-13 21:45:52 +00:00
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_28nm_lp_cfgs;
|
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs;
|
2015-10-14 06:30:34 +00:00
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_28nm_8960_cfgs;
|
2017-01-03 14:15:43 +00:00
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_14nm_cfgs;
|
2020-07-26 11:12:01 +00:00
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_14nm_660_cfgs;
|
2018-01-17 06:05:25 +00:00
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_10nm_cfgs;
|
2019-05-30 16:00:39 +00:00
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_10nm_8998_cfgs;
|
2020-09-11 15:09:39 +00:00
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_7nm_cfgs;
|
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_7nm_8150_cfgs;
|
2021-06-22 12:42:27 +00:00
|
|
|
extern const struct msm_dsi_phy_cfg dsi_phy_7nm_7280_cfgs;
|
2015-08-13 21:45:52 +00:00
|
|
|
|
|
|
|
struct msm_dsi_dphy_timing {
|
|
|
|
u32 clk_zero;
|
|
|
|
u32 clk_trail;
|
|
|
|
u32 clk_prepare;
|
|
|
|
u32 hs_exit;
|
|
|
|
u32 hs_zero;
|
|
|
|
u32 hs_prepare;
|
|
|
|
u32 hs_trail;
|
|
|
|
u32 hs_rqst;
|
|
|
|
u32 ta_go;
|
|
|
|
u32 ta_sure;
|
|
|
|
u32 ta_get;
|
2016-09-15 09:04:49 +00:00
|
|
|
|
|
|
|
struct msm_dsi_phy_shared_timings shared_timings;
|
2017-01-03 14:01:16 +00:00
|
|
|
|
|
|
|
/* For PHY v2 only */
|
|
|
|
u32 hs_rqst_ckln;
|
|
|
|
u32 hs_prep_dly;
|
|
|
|
u32 hs_prep_dly_ckln;
|
|
|
|
u8 hs_halfbyte_en;
|
|
|
|
u8 hs_halfbyte_en_ckln;
|
2015-08-13 21:45:52 +00:00
|
|
|
};
|
|
|
|
|
2021-03-31 10:57:21 +00:00
|
|
|
#define DSI_BYTE_PLL_CLK 0
|
|
|
|
#define DSI_PIXEL_PLL_CLK 1
|
|
|
|
#define NUM_PROVIDED_CLKS 2
|
|
|
|
|
2015-08-13 21:45:52 +00:00
|
|
|
struct msm_dsi_phy {
|
|
|
|
struct platform_device *pdev;
|
|
|
|
void __iomem *base;
|
2021-03-31 10:57:31 +00:00
|
|
|
void __iomem *pll_base;
|
2015-08-13 21:45:52 +00:00
|
|
|
void __iomem *reg_base;
|
2017-01-03 14:15:43 +00:00
|
|
|
void __iomem *lane_base;
|
2021-04-27 00:18:28 +00:00
|
|
|
phys_addr_t base_size;
|
|
|
|
phys_addr_t pll_size;
|
|
|
|
phys_addr_t reg_size;
|
|
|
|
phys_addr_t lane_size;
|
2015-08-13 21:45:52 +00:00
|
|
|
int id;
|
|
|
|
|
|
|
|
struct clk *ahb_clk;
|
|
|
|
struct regulator_bulk_data supplies[DSI_DEV_REGULATOR_MAX];
|
|
|
|
|
|
|
|
struct msm_dsi_dphy_timing timing;
|
|
|
|
const struct msm_dsi_phy_cfg *cfg;
|
|
|
|
|
2016-09-15 09:14:22 +00:00
|
|
|
enum msm_dsi_phy_usecase usecase;
|
2015-08-13 21:45:52 +00:00
|
|
|
bool regulator_ldo_mode;
|
2021-06-17 14:43:35 +00:00
|
|
|
bool cphy_mode;
|
2015-08-13 21:45:52 +00:00
|
|
|
|
2021-03-31 10:57:29 +00:00
|
|
|
struct clk_hw *vco_hw;
|
|
|
|
bool pll_on;
|
2021-03-31 10:57:21 +00:00
|
|
|
|
|
|
|
struct clk_hw_onecell_data *provided_clocks;
|
2021-03-31 10:57:28 +00:00
|
|
|
|
|
|
|
bool state_saved;
|
2015-08-13 21:45:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PHY internal functions
|
|
|
|
*/
|
|
|
|
int msm_dsi_dphy_timing_calc(struct msm_dsi_dphy_timing *timing,
|
2017-01-03 14:01:16 +00:00
|
|
|
struct msm_dsi_phy_clk_request *clk_req);
|
|
|
|
int msm_dsi_dphy_timing_calc_v2(struct msm_dsi_dphy_timing *timing,
|
|
|
|
struct msm_dsi_phy_clk_request *clk_req);
|
2018-04-17 20:50:19 +00:00
|
|
|
int msm_dsi_dphy_timing_calc_v3(struct msm_dsi_dphy_timing *timing,
|
|
|
|
struct msm_dsi_phy_clk_request *clk_req);
|
2020-09-11 15:09:39 +00:00
|
|
|
int msm_dsi_dphy_timing_calc_v4(struct msm_dsi_dphy_timing *timing,
|
|
|
|
struct msm_dsi_phy_clk_request *clk_req);
|
2021-06-17 14:43:35 +00:00
|
|
|
int msm_dsi_cphy_timing_calc_v4(struct msm_dsi_dphy_timing *timing,
|
|
|
|
struct msm_dsi_phy_clk_request *clk_req);
|
2015-08-13 21:45:52 +00:00
|
|
|
|
|
|
|
#endif /* __DSI_PHY_H__ */
|