1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2022 Amarula Solutions(India)
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_bridge.h>
15 #include <drm/drm_mipi_dsi.h>
16 #include <drm/drm_of.h>
18 struct platform_device;
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)
26 enum samsung_dsim_type {
37 #define samsung_dsim_hw_is_exynos(hw) \
38 ((hw) >= DSIM_TYPE_EXYNOS3250 && (hw) <= DSIM_TYPE_EXYNOS5433)
40 struct samsung_dsim_transfer {
41 struct list_head list;
42 struct completion completed;
44 struct mipi_dsi_packet packet;
53 struct samsung_dsim_driver_data {
54 const unsigned int *reg_ofs;
55 unsigned int plltmr_reg;
56 unsigned int has_freqband:1;
57 unsigned int has_clklane_stop:1;
58 unsigned int has_broken_fifoctrl_emptyhdr:1;
59 unsigned int num_clks;
60 unsigned int min_freq;
61 unsigned int max_freq;
62 unsigned int wait_for_reset;
63 unsigned int num_bits_resol;
64 unsigned int pll_p_offset;
65 const unsigned int *reg_values;
66 unsigned int pll_fin_min;
67 unsigned int pll_fin_max;
72 struct samsung_dsim_host_ops {
73 int (*register_host)(struct samsung_dsim *dsim);
74 void (*unregister_host)(struct samsung_dsim *dsim);
75 int (*attach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device);
76 void (*detach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device);
77 irqreturn_t (*te_irq_handler)(struct samsung_dsim *dsim);
80 struct samsung_dsim_plat_data {
81 enum samsung_dsim_type hw_type;
82 const struct samsung_dsim_host_ops *host_ops;
86 struct mipi_dsi_host dsi_host;
87 struct drm_bridge bridge;
88 struct drm_bridge *out_bridge;
90 struct drm_display_mode mode;
92 void __iomem *reg_base;
96 struct regulator_bulk_data supplies[2];
98 struct gpio_desc *te_gpio;
109 bool swap_dn_dp_data;
111 struct drm_property *brightness;
112 struct completion completed;
114 spinlock_t transfer_lock; /* protects transfer_list */
115 struct list_head transfer_list;
117 const struct samsung_dsim_driver_data *driver_data;
118 const struct samsung_dsim_plat_data *plat_data;
123 extern int samsung_dsim_probe(struct platform_device *pdev);
124 extern void samsung_dsim_remove(struct platform_device *pdev);
125 extern const struct dev_pm_ops samsung_dsim_pm_ops;
127 #endif /* __SAMSUNG_DSIM__ */