| 1 |
/* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 |
/* |
| 3 |
* Copyright (C) 2022 Amarula Solutions(India) |
| 4 |
* Author: Jagan Teki <[email protected]> |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef __SAMSUNG_DSIM__ |
| 8 |
#define __SAMSUNG_DSIM__ |
| 9 |
|
| 10 |
#include <linux/gpio/consumer.h> |
| 11 |
#include <linux/regulator/consumer.h> |
| 12 |
|
| 13 |
#include <drm/drm_atomic_helper.h> |
| 14 |
#include <drm/drm_bridge.h> |
| 15 |
#include <drm/drm_mipi_dsi.h> |
| 16 |
#include <drm/drm_of.h> |
| 17 |
|
| 18 |
struct platform_device; |
| 19 |
struct samsung_dsim; |
| 20 |
|
| 21 |
#define DSIM_STATE_ENABLED BIT(0) |
| 22 |
#define DSIM_STATE_INITIALIZED BIT(1) |
| 23 |
#define DSIM_STATE_CMD_LPM BIT(2) |
| 24 |
#define DSIM_STATE_VIDOUT_AVAILABLE BIT(3) |
| 25 |
|
| 26 |
enum samsung_dsim_type { |
| 27 |
DSIM_TYPE_EXYNOS3250, |
| 28 |
DSIM_TYPE_EXYNOS4210, |
| 29 |
DSIM_TYPE_EXYNOS5410, |
| 30 |
DSIM_TYPE_EXYNOS5422, |
| 31 |
DSIM_TYPE_EXYNOS5433, |
| 32 |
DSIM_TYPE_EXYNOS7870, |
| 33 |
DSIM_TYPE_IMX8MM, |
| 34 |
DSIM_TYPE_IMX8MP, |
| 35 |
DSIM_TYPE_COUNT, |
| 36 |
}; |
| 37 |
|
| 38 |
#define samsung_dsim_hw_is_exynos(hw) \ |
| 39 |
((hw) >= DSIM_TYPE_EXYNOS3250 && (hw) <= DSIM_TYPE_EXYNOS5433) |
| 40 |
|
| 41 |
struct samsung_dsim_transfer { |
| 42 |
struct list_head list; |
| 43 |
struct completion completed; |
| 44 |
int result; |
| 45 |
struct mipi_dsi_packet packet; |
| 46 |
u16 flags; |
| 47 |
u16 tx_done; |
| 48 |
|
| 49 |
u8 *rx_payload; |
| 50 |
u16 rx_len; |
| 51 |
u16 rx_done; |
| 52 |
}; |
| 53 |
|
| 54 |
struct samsung_dsim_driver_data { |
| 55 |
const unsigned int *reg_ofs; |
| 56 |
unsigned int plltmr_reg; |
| 57 |
unsigned int has_legacy_status_reg:1; |
| 58 |
unsigned int has_freqband:1; |
| 59 |
unsigned int has_clklane_stop:1; |
| 60 |
unsigned int has_broken_fifoctrl_emptyhdr:1; |
| 61 |
unsigned int has_sfrctrl:1; |
| 62 |
struct clk_bulk_data *clk_data; |
| 63 |
unsigned int num_clks; |
| 64 |
unsigned int min_freq; |
| 65 |
unsigned int max_freq; |
| 66 |
unsigned int wait_for_hdr_fifo; |
| 67 |
unsigned int wait_for_reset; |
| 68 |
unsigned int num_bits_resol; |
| 69 |
unsigned int video_mode_bit; |
| 70 |
unsigned int pll_stable_bit; |
| 71 |
unsigned int esc_clken_bit; |
| 72 |
unsigned int byte_clken_bit; |
| 73 |
unsigned int tx_req_hsclk_bit; |
| 74 |
unsigned int lane_esc_clk_bit; |
| 75 |
unsigned int lane_esc_data_offset; |
| 76 |
unsigned int pll_p_offset; |
| 77 |
unsigned int pll_m_offset; |
| 78 |
unsigned int pll_s_offset; |
| 79 |
unsigned int main_vsa_offset; |
| 80 |
const unsigned int *reg_values; |
| 81 |
unsigned int pll_fin_min; |
| 82 |
unsigned int pll_fin_max; |
| 83 |
u16 m_min; |
| 84 |
u16 m_max; |
| 85 |
}; |
| 86 |
|
| 87 |
struct samsung_dsim_host_ops { |
| 88 |
int (*register_host)(struct samsung_dsim *dsim); |
| 89 |
void (*unregister_host)(struct samsung_dsim *dsim); |
| 90 |
int (*attach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device); |
| 91 |
void (*detach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device); |
| 92 |
irqreturn_t (*te_irq_handler)(struct samsung_dsim *dsim); |
| 93 |
}; |
| 94 |
|
| 95 |
struct samsung_dsim_plat_data { |
| 96 |
enum samsung_dsim_type hw_type; |
| 97 |
const struct samsung_dsim_host_ops *host_ops; |
| 98 |
}; |
| 99 |
|
| 100 |
struct samsung_dsim { |
| 101 |
struct mipi_dsi_host dsi_host; |
| 102 |
struct drm_bridge bridge; |
| 103 |
struct device *dev; |
| 104 |
struct drm_display_mode mode; |
| 105 |
|
| 106 |
void __iomem *reg_base; |
| 107 |
struct phy *phy; |
| 108 |
struct clk *pll_clk; |
| 109 |
struct regulator_bulk_data supplies[2]; |
| 110 |
int irq; |
| 111 |
struct gpio_desc *te_gpio; |
| 112 |
|
| 113 |
u32 pll_clk_rate; |
| 114 |
u32 burst_clk_rate; |
| 115 |
u32 hs_clock; |
| 116 |
u32 esc_clk_rate; |
| 117 |
u32 lanes; |
| 118 |
u32 mode_flags; |
| 119 |
u32 format; |
| 120 |
|
| 121 |
bool swap_dn_dp_clk; |
| 122 |
bool swap_dn_dp_data; |
| 123 |
int state; |
| 124 |
struct drm_property *brightness; |
| 125 |
struct completion completed; |
| 126 |
|
| 127 |
spinlock_t transfer_lock; /* protects transfer_list */ |
| 128 |
struct list_head transfer_list; |
| 129 |
|
| 130 |
const struct samsung_dsim_driver_data *driver_data; |
| 131 |
const struct samsung_dsim_plat_data *plat_data; |
| 132 |
|
| 133 |
void *priv; |
| 134 |
}; |
| 135 |
|
| 136 |
extern int samsung_dsim_probe(struct platform_device *pdev); |
| 137 |
extern void samsung_dsim_remove(struct platform_device *pdev); |
| 138 |
extern const struct dev_pm_ops samsung_dsim_pm_ops; |
| 139 |
|
| 140 |
#endif /* __SAMSUNG_DSIM__ */ |