1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2022 Amarula Solutions(India)
4 * Author: Jagan Teki <jagan@amarulasolutions.com>
7 #ifndef __SAMSUNG_DSIM__
8 #define __SAMSUNG_DSIM__
10 #include <linux/gpio/consumer.h>
11 #include <linux/regulator/consumer.h>
13 #include <drm/drm_atomic_helper.h>
14 #include <drm/drm_of.h>
15 #include <drm/drm_mipi_dsi.h>
19 #define DSIM_STATE_ENABLED BIT(0)
20 #define DSIM_STATE_INITIALIZED BIT(1)
21 #define DSIM_STATE_CMD_LPM BIT(2)
22 #define DSIM_STATE_VIDOUT_AVAILABLE BIT(3)
24 enum samsung_dsim_type {
35 #define samsung_dsim_hw_is_exynos(hw) \
36 ((hw) >= DSIM_TYPE_EXYNOS3250 && (hw) <= DSIM_TYPE_EXYNOS5433)
38 struct samsung_dsim_transfer {
39 struct list_head list;
40 struct completion completed;
42 struct mipi_dsi_packet packet;
51 struct samsung_dsim_driver_data {
52 const unsigned int *reg_ofs;
53 unsigned int plltmr_reg;
54 unsigned int has_freqband:1;
55 unsigned int has_clklane_stop:1;
56 unsigned int has_broken_fifoctrl_emptyhdr:1;
57 unsigned int num_clks;
58 unsigned int min_freq;
59 unsigned int max_freq;
60 unsigned int wait_for_reset;
61 unsigned int num_bits_resol;
62 unsigned int pll_p_offset;
63 const unsigned int *reg_values;
64 unsigned int pll_fin_min;
65 unsigned int pll_fin_max;
70 struct samsung_dsim_host_ops {
71 int (*register_host)(struct samsung_dsim *dsim);
72 void (*unregister_host)(struct samsung_dsim *dsim);
73 int (*attach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device);
74 void (*detach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device);
75 irqreturn_t (*te_irq_handler)(struct samsung_dsim *dsim);
78 struct samsung_dsim_plat_data {
79 enum samsung_dsim_type hw_type;
80 const struct samsung_dsim_host_ops *host_ops;
84 struct mipi_dsi_host dsi_host;
85 struct drm_bridge bridge;
86 struct drm_bridge *out_bridge;
88 struct drm_display_mode mode;
90 void __iomem *reg_base;
94 struct regulator_bulk_data supplies[2];
96 struct gpio_desc *te_gpio;
107 bool swap_dn_dp_data;
109 struct drm_property *brightness;
110 struct completion completed;
112 spinlock_t transfer_lock; /* protects transfer_list */
113 struct list_head transfer_list;
115 const struct samsung_dsim_driver_data *driver_data;
116 const struct samsung_dsim_plat_data *plat_data;
121 extern int samsung_dsim_probe(struct platform_device *pdev);
122 extern void samsung_dsim_remove(struct platform_device *pdev);
123 extern const struct dev_pm_ops samsung_dsim_pm_ops;
125 #endif /* __SAMSUNG_DSIM__ */