• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/include/drm/bridge/analogix_dp.h b/include/drm/bridge/analogix_dp.h
2index b0dcc0733..291eb8787 100644
3--- a/include/drm/bridge/analogix_dp.h
4+++ b/include/drm/bridge/analogix_dp.h
5@@ -8,6 +8,7 @@
6 #define _ANALOGIX_DP_H_
7
8 #include <drm/drm_crtc.h>
9+#include <sound/hdmi-codec.h>
10
11 struct analogix_dp_device;
12
13@@ -25,21 +26,32 @@ static inline bool is_rockchip(enum analogix_dp_devtype type)
14 struct analogix_dp_plat_data {
15 	enum analogix_dp_devtype dev_type;
16 	struct drm_panel *panel;
17+	struct drm_bridge *bridge;
18 	struct drm_encoder *encoder;
19 	struct drm_connector *connector;
20 	bool skip_connector;
21+	bool ssc;
22+
23+	bool split_mode;
24+	struct analogix_dp_device *left;
25+	struct analogix_dp_device *right;
26
27 	int (*power_on_start)(struct analogix_dp_plat_data *);
28 	int (*power_on_end)(struct analogix_dp_plat_data *);
29 	int (*power_off)(struct analogix_dp_plat_data *);
30 	int (*attach)(struct analogix_dp_plat_data *, struct drm_bridge *,
31 		      struct drm_connector *);
32+	void (*detach)(struct analogix_dp_plat_data *, struct drm_bridge *);
33 	int (*get_modes)(struct analogix_dp_plat_data *,
34 			 struct drm_connector *);
35+	void (*convert_to_split_mode)(struct drm_display_mode *);
36+	void (*convert_to_origin_mode)(struct drm_display_mode *);
37 };
38
39 int analogix_dp_resume(struct analogix_dp_device *dp);
40 int analogix_dp_suspend(struct analogix_dp_device *dp);
41+int analogix_dp_runtime_resume(struct analogix_dp_device *dp);
42+int analogix_dp_runtime_suspend(struct analogix_dp_device *dp);
43
44 struct analogix_dp_device *
45 analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data);
46@@ -50,4 +62,13 @@ void analogix_dp_remove(struct analogix_dp_device *dp);
47 int analogix_dp_start_crc(struct drm_connector *connector);
48 int analogix_dp_stop_crc(struct drm_connector *connector);
49
50+int analogix_dp_audio_hw_params(struct analogix_dp_device *dp,
51+				struct hdmi_codec_daifmt *daifmt,
52+				struct hdmi_codec_params *params);
53+void analogix_dp_audio_shutdown(struct analogix_dp_device *dp);
54+int analogix_dp_audio_startup(struct analogix_dp_device *dp);
55+int analogix_dp_audio_get_eld(struct analogix_dp_device *dp,
56+			      u8 *buf, size_t len);
57+int analogix_dp_loader_protect(struct analogix_dp_device *dp);
58+
59 #endif /* _ANALOGIX_DP_H_ */
60diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h
61index ea34ca146..0b7f860d9 100644
62--- a/include/drm/bridge/dw_hdmi.h
63+++ b/include/drm/bridge/dw_hdmi.h
64@@ -6,12 +6,15 @@
65 #ifndef __DW_HDMI__
66 #define __DW_HDMI__
67
68+#include <drm/drm_property.h>
69 #include <sound/hdmi-codec.h>
70+#include <media/cec.h>
71
72 struct drm_display_info;
73 struct drm_display_mode;
74 struct drm_encoder;
75 struct dw_hdmi;
76+struct dw_hdmi_qp;
77 struct platform_device;
78
79 /**
80@@ -92,6 +95,13 @@ enum dw_hdmi_phy_type {
81 	DW_HDMI_PHY_VENDOR_PHY = 0xfe,
82 };
83
84+struct dw_hdmi_audio_tmds_n {
85+	unsigned long tmds;
86+	unsigned int n_32k;
87+	unsigned int n_44k1;
88+	unsigned int n_48k;
89+};
90+
91 struct dw_hdmi_mpll_config {
92 	unsigned long mpixelclock;
93 	struct {
94@@ -112,6 +122,15 @@ struct dw_hdmi_phy_config {
95 	u16 vlev_ctr;   /* voltage level control */
96 };
97
98+struct dw_hdmi_link_config {
99+	bool dsc_mode;
100+	bool frl_mode;
101+	int frl_lanes;
102+	int rate_per_lane;
103+	int hcactive;
104+	u8 pps_payload[128];
105+};
106+
107 struct dw_hdmi_phy_ops {
108 	int (*init)(struct dw_hdmi *hdmi, void *data,
109 		    const struct drm_display_info *display,
110@@ -123,12 +142,48 @@ struct dw_hdmi_phy_ops {
111 	void (*setup_hpd)(struct dw_hdmi *hdmi, void *data);
112 };
113
114+struct dw_hdmi_qp_phy_ops {
115+	int (*init)(struct dw_hdmi_qp *hdmi, void *data,
116+		    struct drm_display_mode *mode);
117+	void (*disable)(struct dw_hdmi_qp *hdmi, void *data);
118+	enum drm_connector_status (*read_hpd)(struct dw_hdmi_qp *hdmi,
119+					      void *data);
120+	void (*update_hpd)(struct dw_hdmi_qp *hdmi, void *data,
121+			   bool force, bool disabled, bool rxsense);
122+	void (*setup_hpd)(struct dw_hdmi_qp *hdmi, void *data);
123+	void (*set_mode)(struct dw_hdmi_qp *dw_hdmi, void *data,
124+			 u32 mode_mask, bool enable);
125+};
126+
127+struct dw_hdmi_property_ops {
128+	void (*attach_properties)(struct drm_connector *connector,
129+				  unsigned int color, int version,
130+				  void *data);
131+	void (*destroy_properties)(struct drm_connector *connector,
132+				   void *data);
133+	int (*set_property)(struct drm_connector *connector,
134+			    struct drm_connector_state *state,
135+			    struct drm_property *property,
136+			    u64 val,
137+			    void *data);
138+	int (*get_property)(struct drm_connector *connector,
139+			    const struct drm_connector_state *state,
140+			    struct drm_property *property,
141+			    u64 *val,
142+			    void *data);
143+};
144+
145 struct dw_hdmi_plat_data {
146 	struct regmap *regm;
147
148+	unsigned long input_bus_format;
149 	unsigned long input_bus_encoding;
150+	unsigned int max_tmdsclk;
151 	bool use_drm_infoframe;
152 	bool ycbcr_420_allowed;
153+	bool unsupported_yuv_input;
154+	bool unsupported_deep_color;
155+	bool is_hdmi_qp;
156
157 	/*
158 	 * Private data passed to all the .mode_valid() and .configure_phy()
159@@ -137,22 +192,55 @@ struct dw_hdmi_plat_data {
160 	void *priv_data;
161
162 	/* Platform-specific mode validation (optional). */
163-	enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
164+	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
165+					   void *data,
166 					   const struct drm_display_info *info,
167 					   const struct drm_display_mode *mode);
168
169 	/* Vendor PHY support */
170 	const struct dw_hdmi_phy_ops *phy_ops;
171+	const struct dw_hdmi_qp_phy_ops *qp_phy_ops;
172 	const char *phy_name;
173 	void *phy_data;
174 	unsigned int phy_force_vendor;
175+	const struct dw_hdmi_audio_tmds_n *tmds_n_table;
176+
177+	/* split mode */
178+	bool split_mode;
179+	bool first_screen;
180+	struct dw_hdmi_qp *left;
181+	struct dw_hdmi_qp *right;
182
183 	/* Synopsys PHY support */
184 	const struct dw_hdmi_mpll_config *mpll_cfg;
185+	const struct dw_hdmi_mpll_config *mpll_cfg_420;
186 	const struct dw_hdmi_curr_ctrl *cur_ctr;
187 	const struct dw_hdmi_phy_config *phy_config;
188 	int (*configure_phy)(struct dw_hdmi *hdmi, void *data,
189 			     unsigned long mpixelclock);
190+
191+	unsigned long (*get_input_bus_format)(void *data);
192+	unsigned long (*get_output_bus_format)(void *data);
193+	unsigned long (*get_enc_in_encoding)(void *data);
194+	unsigned long (*get_enc_out_encoding)(void *data);
195+	unsigned long (*get_quant_range)(void *data);
196+	struct drm_property *(*get_hdr_property)(void *data);
197+	struct drm_property_blob *(*get_hdr_blob)(void *data);
198+	bool (*get_color_changed)(void *data);
199+	int (*get_yuv422_format)(struct drm_connector *connector,
200+				 struct edid *edid);
201+	int (*get_edid_dsc_info)(void *data, struct edid *edid);
202+	int (*get_next_hdr_data)(void *data, struct edid *edid,
203+				 struct drm_connector *connector);
204+	struct dw_hdmi_link_config *(*get_link_cfg)(void *data);
205+	void (*set_grf_cfg)(void *data);
206+	void (*convert_to_split_mode)(struct drm_display_mode *mode);
207+	void (*convert_to_origin_mode)(struct drm_display_mode *mode);
208+	int (*dclk_set)(void *data, bool enable);
209+
210+	/* Vendor Property support */
211+	const struct dw_hdmi_property_ops *property_ops;
212+	struct drm_connector *connector;
213 };
214
215 struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
216@@ -161,8 +249,9 @@ void dw_hdmi_remove(struct dw_hdmi *hdmi);
217 void dw_hdmi_unbind(struct dw_hdmi *hdmi);
218 struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,
219 			     struct drm_encoder *encoder,
220-			     const struct dw_hdmi_plat_data *plat_data);
221+			     struct dw_hdmi_plat_data *plat_data);
222
223+void dw_hdmi_suspend(struct dw_hdmi *hdmi);
224 void dw_hdmi_resume(struct dw_hdmi *hdmi);
225
226 void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense);
227@@ -192,5 +281,31 @@ enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi,
228 void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data,
229 			    bool force, bool disabled, bool rxsense);
230 void dw_hdmi_phy_setup_hpd(struct dw_hdmi *hdmi, void *data);
231+void dw_hdmi_set_quant_range(struct dw_hdmi *hdmi);
232+void dw_hdmi_set_output_type(struct dw_hdmi *hdmi, u64 val);
233+bool dw_hdmi_get_output_whether_hdmi(struct dw_hdmi *hdmi);
234+int dw_hdmi_get_output_type_cap(struct dw_hdmi *hdmi);
235+void dw_hdmi_set_cec_adap(struct dw_hdmi *hdmi, struct cec_adapter *adap);
236+
237+void dw_hdmi_qp_unbind(struct dw_hdmi_qp *hdmi);
238+struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
239+				struct drm_encoder *encoder,
240+				struct dw_hdmi_plat_data *plat_data);
241+void dw_hdmi_qp_suspend(struct device *dev, struct dw_hdmi_qp *hdmi);
242+void dw_hdmi_qp_resume(struct device *dev, struct dw_hdmi_qp *hdmi);
243+void dw_hdmi_qp_cec_set_hpd(struct dw_hdmi_qp *hdmi, bool plug_in, bool change);
244+void dw_hdmi_qp_set_cec_adap(struct dw_hdmi_qp *hdmi, struct cec_adapter *adap);
245+int dw_hdmi_qp_set_earc(struct dw_hdmi_qp *hdmi);
246+void dw_hdmi_qp_set_sample_rate(struct dw_hdmi_qp *hdmi, unsigned int rate);
247+void dw_hdmi_qp_set_channel_count(struct dw_hdmi_qp *hdmi, unsigned int cnt);
248+void dw_hdmi_qp_set_channel_status(struct dw_hdmi_qp *hdmi, u8 *channel_status,
249+				   bool ref2stream);
250+void dw_hdmi_qp_set_channel_allocation(struct dw_hdmi_qp *hdmi, unsigned int ca);
251+void dw_hdmi_qp_set_audio_infoframe(struct dw_hdmi_qp *hdmi,
252+				    struct hdmi_codec_params *hparms);
253+void dw_hdmi_qp_audio_enable(struct dw_hdmi_qp *hdmi);
254+void dw_hdmi_qp_audio_disable(struct dw_hdmi_qp *hdmi);
255+int dw_hdmi_qp_set_plugged_cb(struct dw_hdmi_qp *hdmi, hdmi_codec_plugged_cb fn,
256+			      struct device *codec_dev);
257
258 #endif /* __IMX_HDMI_H__ */
259diff --git a/include/drm/bridge/dw_mipi_dsi.h b/include/drm/bridge/dw_mipi_dsi.h
260index bda8aa7c2..f89b0476a 100644
261--- a/include/drm/bridge/dw_mipi_dsi.h
262+++ b/include/drm/bridge/dw_mipi_dsi.h
263@@ -66,5 +66,6 @@ void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi);
264 int dw_mipi_dsi_bind(struct dw_mipi_dsi *dsi, struct drm_encoder *encoder);
265 void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi);
266 void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave);
267+struct drm_connector *dw_mipi_dsi_get_connector(struct dw_mipi_dsi *dsi);
268
269 #endif /* __DW_MIPI_DSI__ */
270diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
271index f99d3417f..6bf8b2b78 100644
272--- a/include/drm/drm_auth.h
273+++ b/include/drm/drm_auth.h
274@@ -107,7 +107,6 @@ struct drm_master {
275 };
276
277 struct drm_master *drm_master_get(struct drm_master *master);
278-struct drm_master *drm_file_get_master(struct drm_file *file_priv);
279 void drm_master_put(struct drm_master **master);
280 bool drm_is_current_master(struct drm_file *fpriv);
281
282diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
283index 928136556..f8cd5d8e5 100644
284--- a/include/drm/drm_connector.h
285+++ b/include/drm/drm_connector.h
286@@ -175,6 +175,48 @@ struct drm_scdc {
287 	struct drm_scrambling scrambling;
288 };
289
290+#ifdef CONFIG_NO_GKI
291+/**
292+ * struct drm_hdmi_dsc_cap - DSC capabilities of HDMI sink
293+ *
294+ * Describes the DSC support provided by HDMI 2.1 sink.
295+ * The information is fetched fom additional HFVSDB blocks defined
296+ * for HDMI 2.1.
297+ */
298+struct drm_hdmi_dsc_cap {
299+	/** @v_1p2: flag for dsc1.2 version support by sink */
300+	bool v_1p2;
301+
302+	/** @native_420: Does sink support DSC with 4:2:0 compression */
303+	bool native_420;
304+
305+	/**
306+	 * @all_bpp: Does sink support all bpp with 4:4:4: or 4:2:2
307+	 * compressed formats
308+	 */
309+	bool all_bpp;
310+
311+	/**
312+	 * @bpc_supported: compressed bpc supported by sink : 10, 12 or 16 bpc
313+	 */
314+	u8 bpc_supported;
315+
316+	/** @max_slices: maximum number of Horizontal slices supported by */
317+	u8 max_slices;
318+
319+	/** @clk_per_slice : max pixel clock in MHz supported per slice */
320+	int clk_per_slice;
321+
322+	/** @max_lanes : dsc max lanes supported for Fixed rate Link training */
323+	u8 max_lanes;
324+
325+	/** @max_frl_rate_per_lane : maximum frl rate with DSC per lane */
326+	u8 max_frl_rate_per_lane;
327+
328+	/** @total_chunk_kbytes: max size of chunks in KBs supported per line*/
329+	u8 total_chunk_kbytes;
330+};
331+#endif
332
333 /**
334  * struct drm_hdmi_info - runtime information about the connected HDMI sink
335@@ -207,6 +249,17 @@ struct drm_hdmi_info {
336
337 	/** @y420_dc_modes: bitmap of deep color support index */
338 	u8 y420_dc_modes;
339+
340+#ifdef CONFIG_NO_GKI
341+	/** @max_frl_rate_per_lane: support fixed rate link */
342+	u8 max_frl_rate_per_lane;
343+
344+	/** @max_lanes: supported by sink */
345+	u8 max_lanes;
346+
347+	/** @dsc_cap: DSC capabilities of the sink */
348+	struct drm_hdmi_dsc_cap dsc_cap;
349+#endif
350 };
351
352 /**
353@@ -1596,6 +1649,7 @@ drm_connector_is_unregistered(struct drm_connector *connector)
354 		DRM_CONNECTOR_UNREGISTERED;
355 }
356
357+void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode);
358 const char *drm_get_connector_type_name(unsigned int connector_type);
359 const char *drm_get_connector_status_name(enum drm_connector_status status);
360 const char *drm_get_subpixel_order_name(enum subpixel_order order);
361diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
362index 59b51a09c..3a3d9d887 100644
363--- a/include/drm/drm_crtc.h
364+++ b/include/drm/drm_crtc.h
365@@ -287,7 +287,16 @@ struct drm_crtc_state {
366 	 * NULL) is an array of &struct drm_color_lut.
367 	 */
368 	struct drm_property_blob *gamma_lut;
369-
370+#if defined(CONFIG_ROCKCHIP_DRM_CUBIC_LUT)
371+	/**
372+	 * @cubic_lut:
373+	 *
374+	 * Cubic Lookup table for converting pixel data. See
375+	 * drm_crtc_enable_color_mgmt(). The blob (if not NULL) is a 3D array
376+	 * of &struct drm_color_lut.
377+	 */
378+	struct drm_property_blob *cubic_lut;
379+#endif
380 	/**
381 	 * @target_vblank:
382 	 *
383diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
384index e57d0440f..e395d1fc1 100644
385--- a/include/drm/drm_drv.h
386+++ b/include/drm/drm_drv.h
387@@ -29,6 +29,7 @@
388
389 #include <linux/list.h>
390 #include <linux/irqreturn.h>
391+#include <linux/uuid.h>
392
393 #include <drm/drm_device.h>
394
395@@ -460,6 +461,15 @@ struct drm_driver {
396 	int (*gem_prime_mmap)(struct drm_gem_object *obj,
397 				struct vm_area_struct *vma);
398
399+	/**
400+	 * @gem_prime_get_uuid
401+	 *
402+	 * get_uuid hook for GEM drivers. Retrieves the virtio uuid of the
403+	 * given GEM buffer.
404+	 */
405+	int (*gem_prime_get_uuid)(struct drm_gem_object *obj,
406+				  uuid_t *uuid);
407+
408 	/**
409 	 * @dumb_create:
410 	 *
411diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
412index e97daf6ff..043491c74 100644
413--- a/include/drm/drm_edid.h
414+++ b/include/drm/drm_edid.h
415@@ -229,6 +229,38 @@ struct detailed_timing {
416 				    DRM_EDID_YCBCR420_DC_36 | \
417 				    DRM_EDID_YCBCR420_DC_30)
418
419+#ifdef CONFIG_NO_GKI
420+/* HDMI 2.1 additional fields */
421+#define DRM_EDID_MAX_FRL_RATE_MASK		0xf0
422+#define DRM_EDID_FAPA_START_LOCATION		(1 << 0)
423+#define DRM_EDID_ALLM				(1 << 1)
424+#define DRM_EDID_FVA				(1 << 2)
425+
426+/* Deep Color specific */
427+#define DRM_EDID_DC_30BIT_420			(1 << 0)
428+#define DRM_EDID_DC_36BIT_420			(1 << 1)
429+#define DRM_EDID_DC_48BIT_420			(1 << 2)
430+
431+/* VRR specific */
432+#define DRM_EDID_CNMVRR				(1 << 3)
433+#define DRM_EDID_CINEMA_VRR			(1 << 4)
434+#define DRM_EDID_MDELTA				(1 << 5)
435+#define DRM_EDID_VRR_MAX_UPPER_MASK		0xc0
436+#define DRM_EDID_VRR_MAX_LOWER_MASK		0xff
437+#define DRM_EDID_VRR_MIN_MASK			0x3f
438+
439+/* DSC specific */
440+#define DRM_EDID_DSC_10BPC			(1 << 0)
441+#define DRM_EDID_DSC_12BPC			(1 << 1)
442+#define DRM_EDID_DSC_16BPC			(1 << 2)
443+#define DRM_EDID_DSC_ALL_BPP			(1 << 3)
444+#define DRM_EDID_DSC_NATIVE_420			(1 << 6)
445+#define DRM_EDID_DSC_1P2			(1 << 7)
446+#define DRM_EDID_DSC_MAX_FRL_RATE_MASK		0xf0
447+#define DRM_EDID_DSC_MAX_SLICES			0xf
448+#define DRM_EDID_DSC_TOTAL_CHUNK_KBYTES		0x3f
449+#endif
450+
451 /* ELD Header Block */
452 #define DRM_ELD_HEADER_BLOCK_SIZE	4
453
454@@ -359,8 +391,6 @@ drm_load_edid_firmware(struct drm_connector *connector)
455 }
456 #endif
457
458-bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2);
459-
460 int
461 drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
462 					 const struct drm_connector *connector,
463@@ -483,35 +513,99 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
464 	int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
465 			      size_t len),
466 	void *data);
467-struct edid *drm_get_edid(struct drm_connector *connector,
468-			  struct i2c_adapter *adapter);
469 struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
470 				     struct i2c_adapter *adapter);
471-struct edid *drm_edid_duplicate(const struct edid *edid);
472-int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
473-int drm_add_override_edid_modes(struct drm_connector *connector);
474
475-u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
476 bool drm_detect_hdmi_monitor(struct edid *edid);
477-bool drm_detect_monitor_audio(struct edid *edid);
478 enum hdmi_quantization_range
479 drm_default_rgb_quant_range(const struct drm_display_mode *mode);
480-int drm_add_modes_noedid(struct drm_connector *connector,
481-			 int hdisplay, int vdisplay);
482 void drm_set_preferred_mode(struct drm_connector *connector,
483 			    int hpref, int vpref);
484
485 int drm_edid_header_is_valid(const u8 *raw_edid);
486 bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
487 			  bool *edid_corrupt);
488-bool drm_edid_is_valid(struct edid *edid);
489+struct drm_display_mode *
490+drm_display_mode_from_cea_vic(struct drm_device *dev,
491+			      u8 video_code);
492+
493+#ifdef CONFIG_DRM_EDID
494+struct edid *drm_get_edid(struct drm_connector *connector,
495+			  struct i2c_adapter *adapter);
496+struct edid *drm_edid_duplicate(const struct edid *edid);
497+int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
498+int drm_add_override_edid_modes(struct drm_connector *connector);
499+u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
500+int drm_add_modes_noedid(struct drm_connector *connector,
501+			 int hdisplay, int vdisplay);
502+bool drm_detect_monitor_audio(struct edid *edid);
503 void drm_edid_get_monitor_name(struct edid *edid, char *name,
504 			       int buflen);
505+bool drm_edid_is_valid(struct edid *edid);
506+bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2);
507 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
508 					   int hsize, int vsize, int fresh,
509 					   bool rb);
510-struct drm_display_mode *
511-drm_display_mode_from_cea_vic(struct drm_device *dev,
512-			      u8 video_code);
513+#else
514+static inline struct edid *drm_get_edid(struct drm_connector *connector,
515+					struct i2c_adapter *adapter)
516+{
517+	return NULL;
518+}
519+
520+static inline struct edid *drm_edid_duplicate(const struct edid *edid)
521+{
522+	return NULL;
523+}
524+
525+static inline int drm_add_edid_modes(struct drm_connector *connector,
526+				     struct edid *edid)
527+{
528+	return 0;
529+}
530+
531+static inline int drm_add_override_edid_modes(struct drm_connector *connector)
532+{
533+	return 0;
534+}
535+
536+static inline u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
537+{
538+	return 0;
539+}
540+
541+static inline int drm_add_modes_noedid(struct drm_connector *connector,
542+				       int hdisplay, int vdisplay)
543+{
544+	return 0;
545+}
546+
547+static inline bool drm_detect_monitor_audio(struct edid *edid)
548+{
549+	return false;
550+}
551+
552+static inline void drm_edid_get_monitor_name(struct edid *edid, char *name,
553+					     int buflen)
554+{
555+}
556+
557+static inline bool drm_edid_is_valid(struct edid *edid)
558+{
559+	return false;
560+}
561+
562+static inline bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2)
563+{
564+	return false;
565+}
566+
567+static inline struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
568+					   int hsize, int vsize, int fresh,
569+					   bool rb)
570+{
571+	return NULL;
572+}
573+#endif
574
575 #endif /* __DRM_EDID_H__ */
576diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
577index 42d04607d..b81b3bfb0 100644
578--- a/include/drm/drm_file.h
579+++ b/include/drm/drm_file.h
580@@ -226,27 +226,15 @@ struct drm_file {
581 	/**
582 	 * @master:
583 	 *
584-	 * Master this node is currently associated with. Protected by struct
585-	 * &drm_device.master_mutex, and serialized by @master_lookup_lock.
586-	 *
587-	 * Only relevant if drm_is_primary_client() returns true. Note that
588-	 * this only matches &drm_device.master if the master is the currently
589-	 * active one.
590-	 *
591-	 * When dereferencing this pointer, either hold struct
592-	 * &drm_device.master_mutex for the duration of the pointer's use, or
593-	 * use drm_file_get_master() if struct &drm_device.master_mutex is not
594-	 * currently held and there is no other need to hold it. This prevents
595-	 * @master from being freed during use.
596+	 * Master this node is currently associated with. Only relevant if
597+	 * drm_is_primary_client() returns true. Note that this only
598+	 * matches &drm_device.master if the master is the currently active one.
599 	 *
600 	 * See also @authentication and @is_master and the :ref:`section on
601 	 * primary nodes and authentication <drm_primary_node>`.
602 	 */
603 	struct drm_master *master;
604
605-	/** @master_lock: Serializes @master. */
606-	spinlock_t master_lookup_lock;
607-
608 	/** @pid: Process that opened this file. */
609 	struct pid *pid;
610
611@@ -411,6 +399,9 @@ void drm_event_cancel_free(struct drm_device *dev,
612 			   struct drm_pending_event *p);
613 void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
614 void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
615+void drm_send_event_timestamp_locked(struct drm_device *dev,
616+				     struct drm_pending_event *e,
617+				     ktime_t timestamp);
618
619 struct file *mock_drm_getfile(struct drm_minor *minor, unsigned int flags);
620
621diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
622index 360e6377e..952f475a6 100644
623--- a/include/drm/drm_mipi_dsi.h
624+++ b/include/drm/drm_mipi_dsi.h
625@@ -19,12 +19,18 @@ struct drm_dsc_picture_parameter_set;
626 #define MIPI_DSI_MSG_REQ_ACK	BIT(0)
627 /* use Low Power Mode to transmit message */
628 #define MIPI_DSI_MSG_USE_LPM	BIT(1)
629+/* read mipi_dsi_msg.ctrl and unicast to only that ctrls */
630+#define MIPI_DSI_MSG_UNICAST	BIT(2)
631+/* Stack all commands until lastcommand bit and trigger all in one go */
632+#define MIPI_DSI_MSG_LASTCOMMAND BIT(3)
633
634 /**
635  * struct mipi_dsi_msg - read/write DSI buffer
636  * @channel: virtual channel id
637  * @type: payload data type
638  * @flags: flags controlling this message transmission
639+ * @ctrl: ctrl index to transmit on
640+ * @wait_ms: duration in ms to wait after message transmission
641  * @tx_len: length of @tx_buf
642  * @tx_buf: data to be written
643  * @rx_len: length of @rx_buf
644@@ -34,6 +40,8 @@ struct mipi_dsi_msg {
645 	u8 channel;
646 	u8 type;
647 	u16 flags;
648+	u32 ctrl;
649+	u32 wait_ms;
650
651 	size_t tx_len;
652 	const void *tx_buf;
653@@ -132,6 +140,10 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node);
654 #define MIPI_DSI_CLOCK_NON_CONTINUOUS	BIT(10)
655 /* transmit data in low power */
656 #define MIPI_DSI_MODE_LPM		BIT(11)
657+/* disable BLLP area */
658+#define MIPI_DSI_MODE_VIDEO_BLLP	BIT(12)
659+/* disable EOF BLLP area */
660+#define MIPI_DSI_MODE_VIDEO_EOF_BLLP	BIT(13)
661
662 enum mipi_dsi_pixel_format {
663 	MIPI_DSI_FMT_RGB888,
664diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
665index a18f73eb3..76d114569 100644
666--- a/include/drm/drm_mode_config.h
667+++ b/include/drm/drm_mode_config.h
668@@ -794,6 +794,19 @@ struct drm_mode_config {
669 	 */
670 	struct drm_property *gamma_lut_size_property;
671
672+#if defined(CONFIG_ROCKCHIP_DRM_CUBIC_LUT)
673+	/**
674+	 * @cubic_lut_property: Optional CRTC property to set the 3D LUT used to
675+	 * convert color spaces.
676+	 */
677+	struct drm_property *cubic_lut_property;
678+	/**
679+	 * @cubic_lut_size_property: Optional CRTC property for the size of the
680+	 * 3D LUT as supported by the driver (read-only).
681+	 */
682+	struct drm_property *cubic_lut_size_property;
683+#endif
684+
685 	/**
686 	 * @suggested_x_property: Optional connector property with a hint for
687 	 * the position of the output on the host's screen.
688diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
689index c34a3e803..6292fa663 100644
690--- a/include/drm/drm_mode_object.h
691+++ b/include/drm/drm_mode_object.h
692@@ -60,7 +60,7 @@ struct drm_mode_object {
693 	void (*free_cb)(struct kref *kref);
694 };
695
696-#define DRM_OBJECT_MAX_PROPERTY 24
697+#define DRM_OBJECT_MAX_PROPERTY 64
698 /**
699  * struct drm_object_properties - property tracking for &drm_mode_object
700  */
701diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h
702index 0f69f9fbf..a9d0c6b08 100644
703--- a/include/drm/drm_prime.h
704+++ b/include/drm/drm_prime.h
705@@ -107,5 +107,6 @@ void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
706 int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
707 				     dma_addr_t *addrs, int max_pages);
708
709+int drm_gem_dmabuf_get_uuid(struct dma_buf *dma_buf, uuid_t *uuid);
710
711 #endif /* __DRM_PRIME_H__ */
712diff --git a/include/dt-bindings/clock/rk3399-cru.h b/include/dt-bindings/clock/rk3399-cru.h
713index 44e0a319f..b541bdce1 100644
714--- a/include/dt-bindings/clock/rk3399-cru.h
715+++ b/include/dt-bindings/clock/rk3399-cru.h
716@@ -7,6 +7,8 @@
717 #ifndef _DT_BINDINGS_CLK_ROCKCHIP_RK3399_H
718 #define _DT_BINDINGS_CLK_ROCKCHIP_RK3399_H
719
720+#define RK3399_TWO_PLL_FOR_VOP
721+
722 /* core clocks */
723 #define PLL_APLLL			1
724 #define PLL_APLLB			2
725@@ -19,6 +21,7 @@
726 #define ARMCLKB				9
727
728 /* sclk gates (special clocks) */
729+#define SCLK_I2SOUT_SRC			64
730 #define SCLK_I2C1			65
731 #define SCLK_I2C2			66
732 #define SCLK_I2C3			67
733@@ -122,9 +125,18 @@
734 #define SCLK_DPHY_RX0_CFG		165
735 #define SCLK_RMII_SRC			166
736 #define SCLK_PCIEPHY_REF100M		167
737-#define SCLK_DDRC			168
738-#define SCLK_TESTCLKOUT1		169
739-#define SCLK_TESTCLKOUT2		170
740+#define SCLK_USBPHY0_480M_SRC		168
741+#define SCLK_USBPHY1_480M_SRC		169
742+#define SCLK_DDRC			170
743+#define SCLK_TESTCLKOUT2		171
744+#define SCLK_UART0_SRC			172
745+#define SCLK_UART_SRC			173
746+#define SCLK_I2S0_DIV			174
747+#define SCLK_I2S1_DIV			175
748+#define SCLK_I2S2_DIV			176
749+#define SCLK_SPDIF_DIV			177
750+#define SCLK_TESTCLKOUT1		179
751+#define SCLK_CIF_OUT_SRC		178
752
753 #define DCLK_VOP0			180
754 #define DCLK_VOP1			181
755@@ -351,6 +363,7 @@
756 #define SCLK_I2C0_PMU			9
757 #define SCLK_I2C4_PMU			10
758 #define SCLK_I2C8_PMU			11
759+#define SCLK_UART4_SRC			12
760
761 #define PCLK_SRC_PMU			19
762 #define PCLK_PMU			20
763@@ -421,7 +434,7 @@
764 #define SRST_A_ADB400_GIC2COREB		40
765 #define SRST_A_ADB400_COREB2GIC		41
766 #define SRST_P_DBG_B			42
767-#define SRST_L2_B_T			43
768+#define SRST_L2_B_T			44
769 #define SRST_ADB_B_T			45
770 #define SRST_A_RKPERF_B			46
771 #define SRST_PVTM_CORE_B		47
772@@ -594,13 +607,13 @@
773 #define SRST_P_SPI0			214
774 #define SRST_P_SPI1			215
775 #define SRST_P_SPI2			216
776-#define SRST_P_SPI3			217
777-#define SRST_P_SPI4			218
778+#define SRST_P_SPI4			217
779+#define SRST_P_SPI5			218
780 #define SRST_SPI0			219
781 #define SRST_SPI1			220
782 #define SRST_SPI2			221
783-#define SRST_SPI3			222
784-#define SRST_SPI4			223
785+#define SRST_SPI4			222
786+#define SRST_SPI5			223
787
788 /* cru_softrst_con14 */
789 #define SRST_I2S0_8CH			224
790@@ -722,8 +735,8 @@
791 #define SRST_H_CM0S_NOC			3
792 #define SRST_DBG_CM0S			4
793 #define SRST_PO_CM0S			5
794-#define SRST_P_SPI6			6
795-#define SRST_SPI6			7
796+#define SRST_P_SPI3			6
797+#define SRST_SPI3			7
798 #define SRST_P_TIMER_0_1		8
799 #define SRST_P_TIMER_0			9
800 #define SRST_P_TIMER_1			10
801diff --git a/include/dt-bindings/soc/rockchip,boot-mode.h b/include/dt-bindings/soc/rockchip,boot-mode.h
802index 4b0914c09..1436e1d32 100644
803--- a/include/dt-bindings/soc/rockchip,boot-mode.h
804+++ b/include/dt-bindings/soc/rockchip,boot-mode.h
805@@ -10,7 +10,15 @@
806 #define BOOT_BL_DOWNLOAD	(REBOOT_FLAG + 1)
807 /* enter recovery */
808 #define BOOT_RECOVERY		(REBOOT_FLAG + 3)
809- /* enter fastboot mode */
810+/* reboot by panic */
811+#define BOOT_PANIC		(REBOOT_FLAG + 7)
812+/* reboot by watchdog */
813+#define BOOT_WATCHDOG		(REBOOT_FLAG + 8)
814+/* enter fastboot mode */
815 #define BOOT_FASTBOOT		(REBOOT_FLAG + 9)
816+/* enter charging mode */
817+#define BOOT_CHARGING		(REBOOT_FLAG + 11)
818+/* enter usb mass storage mode */
819+#define BOOT_UMS		(REBOOT_FLAG + 12)
820
821 #endif
822diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
823index d9b69bbde..ebfb4e7c1 100644
824--- a/include/linux/blk_types.h
825+++ b/include/linux/blk_types.h
826@@ -46,6 +46,7 @@ struct block_device {
827 	int			bd_fsfreeze_count;
828 	/* Mutex for freeze */
829 	struct mutex		bd_fsfreeze_mutex;
830+	struct super_block	*bd_fsfreeze_sb;
831 } __randomize_layout;
832
833 /*
834diff --git a/include/linux/bpf.h b/include/linux/bpf.h
835index a8b2625e5..469fa0f9f 100644
836--- a/include/linux/bpf.h
837+++ b/include/linux/bpf.h
838@@ -173,7 +173,7 @@ struct bpf_map {
839 	atomic64_t usercnt;
840 	struct work_struct work;
841 	struct mutex freeze_mutex;
842-	atomic64_t writecnt;
843+	u64 writecnt; /* writable mmap cnt; protected by freeze_mutex */
844 };
845
846 static inline bool map_value_has_spin_lock(const struct bpf_map *map)
847@@ -1333,7 +1333,6 @@ void bpf_map_charge_move(struct bpf_map_memory *dst,
848 void *bpf_map_area_alloc(u64 size, int numa_node);
849 void *bpf_map_area_mmapable_alloc(u64 size, int numa_node);
850 void bpf_map_area_free(void *base);
851-bool bpf_map_write_active(const struct bpf_map *map);
852 void bpf_map_init_from_attr(struct bpf_map *map, union bpf_attr *attr);
853 int  generic_map_lookup_batch(struct bpf_map *map,
854 			      const union bpf_attr *attr,
855diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
856index 9c88b7da3..14b808b02 100644
857--- a/include/linux/cgroup.h
858+++ b/include/linux/cgroup.h
859@@ -676,6 +676,8 @@ static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
860 	return &cgrp->psi;
861 }
862
863+bool cgroup_psi_enabled(void);
864+
865 static inline void cgroup_init_kthreadd(void)
866 {
867 	/*
868@@ -735,6 +737,11 @@ static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
869 	return NULL;
870 }
871
872+static inline bool cgroup_psi_enabled(void)
873+{
874+	return false;
875+}
876+
877 static inline bool task_under_cgroup_hierarchy(struct task_struct *task,
878 					       struct cgroup *ancestor)
879 {
880@@ -816,13 +823,33 @@ static inline void cgroup_account_cputime_field(struct task_struct *task,
881  */
882 #ifdef CONFIG_SOCK_CGROUP_DATA
883
884+#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)
885+extern spinlock_t cgroup_sk_update_lock;
886+#endif
887+
888+void cgroup_sk_alloc_disable(void);
889 void cgroup_sk_alloc(struct sock_cgroup_data *skcd);
890 void cgroup_sk_clone(struct sock_cgroup_data *skcd);
891 void cgroup_sk_free(struct sock_cgroup_data *skcd);
892
893 static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd)
894 {
895-	return skcd->cgroup;
896+#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)
897+	unsigned long v;
898+
899+	/*
900+	 * @skcd->val is 64bit but the following is safe on 32bit too as we
901+	 * just need the lower ulong to be written and read atomically.
902+	 */
903+	v = READ_ONCE(skcd->val);
904+
905+	if (v & 3)
906+		return &cgrp_dfl_root.cgrp;
907+
908+	return (struct cgroup *)(unsigned long)v ?: &cgrp_dfl_root.cgrp;
909+#else
910+	return (struct cgroup *)(unsigned long)skcd->val;
911+#endif
912 }
913
914 #else	/* CONFIG_CGROUP_DATA */
915diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
916index 03a5de5f9..d9897d0b1 100644
917--- a/include/linux/clk-provider.h
918+++ b/include/linux/clk-provider.h
919@@ -599,6 +599,7 @@ struct clk_divider {
920 	u8		shift;
921 	u8		width;
922 	u8		flags;
923+	unsigned long	max_prate;
924 	const struct clk_div_table	*table;
925 	spinlock_t	*lock;
926 };
927@@ -936,6 +937,8 @@ void clk_hw_unregister_fixed_factor(struct clk_hw *hw);
928  * CLK_FRAC_DIVIDER_BIG_ENDIAN - By default little endian register accesses are
929  *	used for the divider register.  Setting this flag makes the register
930  *	accesses big endian.
931+ * CLK_FRAC_DIVIDER_NO_LIMIT - not need to follow the 20 times limit on
932+ *	fractional divider
933  */
934 struct clk_fractional_divider {
935 	struct clk_hw	hw;
936@@ -947,6 +950,7 @@ struct clk_fractional_divider {
937 	u8		nwidth;
938 	u32		nmask;
939 	u8		flags;
940+	unsigned long	max_prate;
941 	void		(*approximation)(struct clk_hw *hw,
942 				unsigned long rate, unsigned long *parent_rate,
943 				unsigned long *m, unsigned long *n);
944@@ -957,6 +961,7 @@ struct clk_fractional_divider {
945
946 #define CLK_FRAC_DIVIDER_ZERO_BASED		BIT(0)
947 #define CLK_FRAC_DIVIDER_BIG_ENDIAN		BIT(1)
948+#define CLK_FRAC_DIVIDER_NO_LIMIT		BIT(2)
949
950 extern const struct clk_ops clk_fractional_divider_ops;
951 struct clk *clk_register_fractional_divider(struct device *dev,
952@@ -1017,6 +1022,9 @@ extern const struct clk_ops clk_multiplier_ops;
953  * @mux_hw:	handle between composite and hardware-specific mux clock
954  * @rate_hw:	handle between composite and hardware-specific rate clock
955  * @gate_hw:	handle between composite and hardware-specific gate clock
956+ * @brother_hw: a member of clk_composite who has the common parent clocks
957+ *              with another clk_composite, and it's also a handle between
958+ *              common and hardware-specific interfaces
959  * @mux_ops:	clock ops for mux
960  * @rate_ops:	clock ops for rate
961  * @gate_ops:	clock ops for gate
962@@ -1028,6 +1036,7 @@ struct clk_composite {
963 	struct clk_hw	*mux_hw;
964 	struct clk_hw	*rate_hw;
965 	struct clk_hw	*gate_hw;
966+	struct clk_hw	*brother_hw;
967
968 	const struct clk_ops	*mux_ops;
969 	const struct clk_ops	*rate_ops;
970diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
971index 04c20de66..047f449d3 100644
972--- a/include/linux/cpuset.h
973+++ b/include/linux/cpuset.h
974@@ -15,6 +15,7 @@
975 #include <linux/cpumask.h>
976 #include <linux/nodemask.h>
977 #include <linux/mm.h>
978+#include <linux/mmu_context.h>
979 #include <linux/jump_label.h>
980
981 #ifdef CONFIG_CPUSETS
982@@ -162,6 +163,8 @@ static inline void set_mems_allowed(nodemask_t nodemask)
983 	task_unlock(current);
984 }
985
986+extern void cpuset_hotplug_workfn(struct work_struct *work);
987+
988 #else /* !CONFIG_CPUSETS */
989
990 static inline bool cpusets_enabled(void) { return false; }
991@@ -184,7 +187,7 @@ static inline void cpuset_read_unlock(void) { }
992 static inline void cpuset_cpus_allowed(struct task_struct *p,
993 				       struct cpumask *mask)
994 {
995-	cpumask_copy(mask, cpu_possible_mask);
996+	cpumask_copy(mask, task_cpu_possible_mask(p));
997 }
998
999 static inline void cpuset_cpus_allowed_fallback(struct task_struct *p)
1000@@ -280,6 +283,8 @@ static inline bool read_mems_allowed_retry(unsigned int seq)
1001 	return false;
1002 }
1003
1004+static inline void cpuset_hotplug_workfn(struct work_struct *work) {}
1005+
1006 #endif /* !CONFIG_CPUSETS */
1007
1008 #endif /* _LINUX_CPUSET_H */
1009diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
1010index 0c5706abb..fc3c3f21f 100644
1011--- a/include/linux/dma-buf.h
1012+++ b/include/linux/dma-buf.h
1013@@ -209,6 +209,41 @@ struct dma_buf_ops {
1014 	 */
1015 	int (*begin_cpu_access)(struct dma_buf *, enum dma_data_direction);
1016
1017+	/**
1018+	 * @begin_cpu_access_partial:
1019+	 *
1020+	 * This is called from dma_buf_begin_cpu_access_partial() and allows the
1021+	 * exporter to ensure that the memory specified in the range is
1022+	 * available for cpu access - the exporter might need to allocate or
1023+	 * swap-in and pin the backing storage.
1024+	 * The exporter also needs to ensure that cpu access is
1025+	 * coherent for the access direction. The direction can be used by the
1026+	 * exporter to optimize the cache flushing, i.e. access with a different
1027+	 * direction (read instead of write) might return stale or even bogus
1028+	 * data (e.g. when the exporter needs to copy the data to temporary
1029+	 * storage).
1030+	 *
1031+	 * This callback is optional.
1032+	 *
1033+	 * FIXME: This is both called through the DMA_BUF_IOCTL_SYNC command
1034+	 * from userspace (where storage shouldn't be pinned to avoid handing
1035+	 * de-factor mlock rights to userspace) and for the kernel-internal
1036+	 * users of the various kmap interfaces, where the backing storage must
1037+	 * be pinned to guarantee that the atomic kmap calls can succeed. Since
1038+	 * there's no in-kernel users of the kmap interfaces yet this isn't a
1039+	 * real problem.
1040+	 *
1041+	 * Returns:
1042+	 *
1043+	 * 0 on success or a negative error code on failure. This can for
1044+	 * example fail when the backing storage can't be allocated. Can also
1045+	 * return -ERESTARTSYS or -EINTR when the call has been interrupted and
1046+	 * needs to be restarted.
1047+	 */
1048+	int (*begin_cpu_access_partial)(struct dma_buf *dmabuf,
1049+					enum dma_data_direction,
1050+					unsigned int offset, unsigned int len);
1051+
1052 	/**
1053 	 * @end_cpu_access:
1054 	 *
1055@@ -228,6 +263,28 @@ struct dma_buf_ops {
1056 	 */
1057 	int (*end_cpu_access)(struct dma_buf *, enum dma_data_direction);
1058
1059+	/**
1060+	 * @end_cpu_access_partial:
1061+	 *
1062+	 * This is called from dma_buf_end_cpu_access_partial() when the
1063+	 * importer is done accessing the CPU. The exporter can use to limit
1064+	 * cache flushing to only the range specefied and to unpin any
1065+	 * resources pinned in @begin_cpu_access_umapped.
1066+	 * The result of any dma_buf kmap calls after end_cpu_access_partial is
1067+	 * undefined.
1068+	 *
1069+	 * This callback is optional.
1070+	 *
1071+	 * Returns:
1072+	 *
1073+	 * 0 on success or a negative error code on failure. Can return
1074+	 * -ERESTARTSYS or -EINTR when the call has been interrupted and needs
1075+	 * to be restarted.
1076+	 */
1077+	int (*end_cpu_access_partial)(struct dma_buf *dmabuf,
1078+				      enum dma_data_direction,
1079+				      unsigned int offset, unsigned int len);
1080+
1081 	/**
1082 	 * @mmap:
1083 	 *
1084@@ -267,6 +324,35 @@ struct dma_buf_ops {
1085
1086 	void *(*vmap)(struct dma_buf *);
1087 	void (*vunmap)(struct dma_buf *, void *vaddr);
1088+
1089+	/**
1090+	 * @get_uuid
1091+	 *
1092+	 * This is called by dma_buf_get_uuid to get the UUID which identifies
1093+	 * the buffer to virtio devices.
1094+	 *
1095+	 * This callback is optional.
1096+	 *
1097+	 * Returns:
1098+	 *
1099+	 * 0 on success or a negative error code on failure. On success uuid
1100+	 * will be populated with the buffer's UUID.
1101+	 */
1102+	int (*get_uuid)(struct dma_buf *dmabuf, uuid_t *uuid);
1103+
1104+	/**
1105+	 * @get_flags:
1106+	 *
1107+	 * This is called by dma_buf_get_flags and is used to get the buffer's
1108+	 * flags.
1109+	 * This callback is optional.
1110+	 *
1111+	 * Returns:
1112+	 *
1113+	 * 0 on success or a negative error code on failure. On success flags
1114+	 * will be populated with the buffer's flags.
1115+	 */
1116+	int (*get_flags)(struct dma_buf *dmabuf, unsigned long *flags);
1117 };
1118
1119 /**
1120@@ -297,6 +383,9 @@ struct dma_buf_ops {
1121  * @sysfs_entry: for exposing information about this buffer in sysfs.
1122  * The attachment_uid member of @sysfs_entry is protected by dma_resv lock
1123  * and is incremented on each attach.
1124+ * @mmap_count: number of times buffer has been mmapped.
1125+ * @exp_vm_ops: the vm ops provided by the buffer exporter.
1126+ * @vm_ops: the overridden vm_ops used to track mmap_count of the buffer.
1127  *
1128  * This represents a shared buffer, created by calling dma_buf_export(). The
1129  * userspace representation is a normal file descriptor, which can be created by
1130@@ -341,7 +430,12 @@ struct dma_buf {
1131 	struct dma_buf_sysfs_entry {
1132 		struct kobject kobj;
1133 		struct dma_buf *dmabuf;
1134+		unsigned int attachment_uid;
1135+		struct kset *attach_stats_kset;
1136 	} *sysfs_entry;
1137+	int mmap_count;
1138+	const struct vm_operations_struct *exp_vm_ops;
1139+	struct vm_operations_struct vm_ops;
1140 #endif
1141 };
1142
1143@@ -392,6 +486,9 @@ struct dma_buf_attach_ops {
1144  * @importer_ops: importer operations for this attachment, if provided
1145  * dma_buf_map/unmap_attachment() must be called with the dma_resv lock held.
1146  * @importer_priv: importer specific attachment data.
1147+ * @dma_map_attrs: DMA attributes to be used when the exporter maps the buffer
1148+ * through dma_buf_map_attachment.
1149+ * @sysfs_entry: For exposing information about this attachment in sysfs.
1150  *
1151  * This structure holds the attachment information between the dma_buf buffer
1152  * and its user device(s). The list contains one attachment struct per device
1153@@ -412,6 +509,14 @@ struct dma_buf_attachment {
1154 	const struct dma_buf_attach_ops *importer_ops;
1155 	void *importer_priv;
1156 	void *priv;
1157+	unsigned long dma_map_attrs;
1158+#ifdef CONFIG_DMABUF_SYSFS_STATS
1159+	/* for sysfs stats */
1160+	struct dma_buf_attach_sysfs_entry {
1161+		struct kobject kobj;
1162+		unsigned int map_counter;
1163+	} *sysfs_entry;
1164+#endif
1165 };
1166
1167 /**
1168@@ -489,6 +594,9 @@ dma_buf_attachment_is_dynamic(struct dma_buf_attachment *attach)
1169 	return !!attach->importer_ops;
1170 }
1171
1172+int get_each_dmabuf(int (*callback)(const struct dma_buf *dmabuf,
1173+		    void *private), void *private);
1174+int is_dma_buf_file(struct file *file);
1175 struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
1176 					  struct device *dev);
1177 struct dma_buf_attachment *
1178@@ -513,13 +621,21 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct sg_table *,
1179 void dma_buf_move_notify(struct dma_buf *dma_buf);
1180 int dma_buf_begin_cpu_access(struct dma_buf *dma_buf,
1181 			     enum dma_data_direction dir);
1182+int dma_buf_begin_cpu_access_partial(struct dma_buf *dma_buf,
1183+				     enum dma_data_direction dir,
1184+				     unsigned int offset, unsigned int len);
1185 int dma_buf_end_cpu_access(struct dma_buf *dma_buf,
1186 			   enum dma_data_direction dir);
1187+int dma_buf_end_cpu_access_partial(struct dma_buf *dma_buf,
1188+				     enum dma_data_direction dir,
1189+				     unsigned int offset, unsigned int len);
1190
1191 int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *,
1192 		 unsigned long);
1193 void *dma_buf_vmap(struct dma_buf *);
1194 void dma_buf_vunmap(struct dma_buf *, void *vaddr);
1195+int dma_buf_get_flags(struct dma_buf *dmabuf, unsigned long *flags);
1196+int dma_buf_get_uuid(struct dma_buf *dmabuf, uuid_t *uuid);
1197
1198 #ifdef CONFIG_DMABUF_PROCESS_INFO
1199 /**
1200diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
1201index 09e23adb3..9f12efaaa 100644
1202--- a/include/linux/dma-fence.h
1203+++ b/include/linux/dma-fence.h
1204@@ -372,6 +372,9 @@ static inline void __dma_fence_might_wait(void) {}
1205
1206 int dma_fence_signal(struct dma_fence *fence);
1207 int dma_fence_signal_locked(struct dma_fence *fence);
1208+int dma_fence_signal_timestamp(struct dma_fence *fence, ktime_t timestamp);
1209+int dma_fence_signal_timestamp_locked(struct dma_fence *fence,
1210+				      ktime_t timestamp);
1211 signed long dma_fence_default_wait(struct dma_fence *fence,
1212 				   bool intr, signed long timeout);
1213 int dma_fence_add_callback(struct dma_fence *fence,
1214diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h
1215index 83b8cfb2d..e8f0e92c2 100644
1216--- a/include/linux/dma-heap.h
1217+++ b/include/linux/dma-heap.h
1218@@ -16,15 +16,17 @@ struct dma_heap;
1219
1220 /**
1221  * struct dma_heap_ops - ops to operate on a given heap
1222- * @allocate:		allocate dmabuf and return fd
1223+ * @allocate:		allocate dmabuf and return struct dma_buf ptr
1224+ * @get_pool_size:	if heap maintains memory pools, get pool size in bytes
1225  *
1226- * allocate returns dmabuf fd  on success, -errno on error.
1227+ * allocate returns dmabuf on success, ERR_PTR(-errno) on error.
1228  */
1229 struct dma_heap_ops {
1230-	int (*allocate)(struct dma_heap *heap,
1231+	struct dma_buf *(*allocate)(struct dma_heap *heap,
1232 			unsigned long len,
1233 			unsigned long fd_flags,
1234 			unsigned long heap_flags);
1235+	long (*get_pool_size)(struct dma_heap *heap);
1236 };
1237
1238 /**
1239@@ -50,6 +52,15 @@ struct dma_heap_export_info {
1240  */
1241 void *dma_heap_get_drvdata(struct dma_heap *heap);
1242
1243+/**
1244+ * dma_heap_get_dev() - get device struct for the heap
1245+ * @heap: DMA-Heap to retrieve device struct from
1246+ *
1247+ * Returns:
1248+ * The device struct for the heap.
1249+ */
1250+struct device *dma_heap_get_dev(struct dma_heap *heap);
1251+
1252 /**
1253  * dma_heap_get_name() - get heap name
1254  * @heap: DMA-Heap to retrieve private data for
1255@@ -65,4 +76,49 @@ const char *dma_heap_get_name(struct dma_heap *heap);
1256  */
1257 struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info);
1258
1259+/**
1260+ * dma_heap_put - drops a reference to a dmabuf heaps, potentially freeing it
1261+ * @heap:		heap pointer
1262+ */
1263+void dma_heap_put(struct dma_heap *heap);
1264+
1265+/**
1266+ * dma_heap_find - Returns the registered dma_heap with the specified name
1267+ * @name: Name of the heap to find
1268+ *
1269+ * NOTE: dma_heaps returned from this function MUST be released
1270+ * using dma_heap_put() when the user is done.
1271+ */
1272+struct dma_heap *dma_heap_find(const char *name);
1273+
1274+/**
1275+ * dma_heap_buffer_alloc - Allocate dma-buf from a dma_heap
1276+ * @heap:	dma_heap to allocate from
1277+ * @len:	size to allocate
1278+ * @fd_flags:	flags to set on returned dma-buf fd
1279+ * @heap_flags:	flags to pass to the dma heap
1280+ *
1281+ * This is for internal dma-buf allocations only.
1282+ */
1283+struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
1284+				      unsigned int fd_flags,
1285+				      unsigned int heap_flags);
1286+
1287+/** dma_heap_buffer_free - Free dma_buf allocated by dma_heap_buffer_alloc
1288+ * @dma_buf:	dma_buf to free
1289+ *
1290+ * This is really only a simple wrapper to dma_buf_put()
1291+ */
1292+void dma_heap_buffer_free(struct dma_buf *);
1293+
1294+/**
1295+ * dma_heap_bufferfd_alloc - Allocate dma-buf fd from a dma_heap
1296+ * @heap:	dma_heap to allocate from
1297+ * @len:	size to allocate
1298+ * @fd_flags:	flags to set on returned dma-buf fd
1299+ * @heap_flags:	flags to pass to the dma heap
1300+ */
1301+int dma_heap_bufferfd_alloc(struct dma_heap *heap, size_t len,
1302+			    unsigned int fd_flags,
1303+			    unsigned int heap_flags);
1304 #endif /* _DMA_HEAPS_H */
1305diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h
1306index 2112f21f7..f51561eda 100644
1307--- a/include/linux/dma-iommu.h
1308+++ b/include/linux/dma-iommu.h
1309@@ -37,6 +37,11 @@ void iommu_dma_compose_msi_msg(struct msi_desc *desc,
1310
1311 void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
1312
1313+int iommu_dma_reserve_iova(struct device *dev, dma_addr_t base,
1314+			   u64 size);
1315+
1316+int iommu_dma_enable_best_fit_algo(struct device *dev);
1317+
1318 #else /* CONFIG_IOMMU_DMA */
1319
1320 struct iommu_domain;
1321@@ -78,5 +83,16 @@ static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_he
1322 {
1323 }
1324
1325+static inline int iommu_dma_reserve_iova(struct device *dev, dma_addr_t base,
1326+					 u64 size)
1327+{
1328+	return -ENODEV;
1329+}
1330+
1331+static inline int iommu_dma_enable_best_fit_algo(struct device *dev)
1332+{
1333+	return -ENODEV;
1334+}
1335+
1336 #endif	/* CONFIG_IOMMU_DMA */
1337 #endif	/* __DMA_IOMMU_H */
1338diff --git a/include/linux/dma-map-ops.h b/include/linux/dma-map-ops.h
1339index a5f89fc4d..a3ff9280f 100644
1340--- a/include/linux/dma-map-ops.h
1341+++ b/include/linux/dma-map-ops.h
1342@@ -258,6 +258,14 @@ void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
1343 #define pgprot_dmacoherent(prot)	pgprot_noncached(prot)
1344 #endif
1345
1346+/*
1347+ * If there is no system cache pgprot, then fallback to dmacoherent
1348+ * pgprot, as the expectation is that the device is not coherent.
1349+ */
1350+#ifndef pgprot_syscached
1351+#define pgprot_syscached(prot)		pgprot_dmacoherent(prot)
1352+#endif
1353+
1354 pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs);
1355 #else
1356 static inline pgprot_t dma_pgprot(struct device *dev, pgprot_t prot,
1357diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
1358index a7d70cdee..7270f12e2 100644
1359--- a/include/linux/dma-mapping.h
1360+++ b/include/linux/dma-mapping.h
1361@@ -61,6 +61,23 @@
1362  */
1363 #define DMA_ATTR_PRIVILEGED		(1UL << 9)
1364
1365+/*
1366+ * DMA_ATTR_SYS_CACHE_ONLY: used to indicate that the buffer should be mapped
1367+ * with the correct memory attributes so that it can be cached in the system
1368+ * or last level cache. This is useful for buffers that are being mapped for
1369+ * devices that are non-coherent, but can use the system cache.
1370+ */
1371+#define DMA_ATTR_SYS_CACHE_ONLY		(1UL << 10)
1372+
1373+/*
1374+ * DMA_ATTR_SYS_CACHE_ONLY_NWA: used to indicate that the buffer should be
1375+ * mapped with the correct memory attributes so that it can be cached in the
1376+ * system or last level cache, with a no write allocate cache policy. This is
1377+ * useful for buffers that are being mapped for devices that are non-coherent,
1378+ * but can use the system cache.
1379+ */
1380+#define DMA_ATTR_SYS_CACHE_ONLY_NWA	(1UL << 11)
1381+
1382 /*
1383  * A dma_addr_t can hold any valid DMA or bus address for the platform.  It can
1384  * be given to a device to use as a DMA source or target.  It is specific to a
1385diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
1386index dd357a747..493a047ed 100644
1387--- a/include/linux/dmaengine.h
1388+++ b/include/linux/dmaengine.h
1389@@ -418,6 +418,9 @@ enum dma_slave_buswidth {
1390  * @slave_id: Slave requester id. Only valid for slave channels. The dma
1391  * slave peripheral will have unique id as dma requester which need to be
1392  * pass as slave config.
1393+ * @peripheral_config: peripheral configuration for programming peripheral
1394+ * for dmaengine transfer
1395+ * @peripheral_size: peripheral configuration buffer size
1396  *
1397  * This struct is passed in as configuration data to a DMA engine
1398  * in order to set up a certain channel for DMA transport at runtime.
1399@@ -443,6 +446,8 @@ struct dma_slave_config {
1400 	u32 dst_port_window_size;
1401 	bool device_fc;
1402 	unsigned int slave_id;
1403+	void *peripheral_config;
1404+	size_t peripheral_size;
1405 };
1406
1407 /**
1408diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
1409index 5f04a2b35..9ca1ea02f 100644
1410--- a/include/linux/energy_model.h
1411+++ b/include/linux/energy_model.h
1412@@ -29,6 +29,8 @@ struct em_perf_state {
1413  * em_perf_domain - Performance domain
1414  * @table:		List of performance states, in ascending order
1415  * @nr_perf_states:	Number of performance states
1416+ * @milliwatts:		Flag indicating the power values are in milli-Watts
1417+ *			or some other scale.
1418  * @cpus:		Cpumask covering the CPUs of the domain. It's here
1419  *			for performance reasons to avoid potential cache
1420  *			misses during energy calculations in the scheduler
1421@@ -43,6 +45,7 @@ struct em_perf_state {
1422 struct em_perf_domain {
1423 	struct em_perf_state *table;
1424 	int nr_perf_states;
1425+	int milliwatts;
1426 	unsigned long cpus[];
1427 };
1428
1429@@ -95,7 +98,8 @@ struct em_data_callback {
1430 struct em_perf_domain *em_cpu_get(int cpu);
1431 struct em_perf_domain *em_pd_get(struct device *dev);
1432 int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
1433-				struct em_data_callback *cb, cpumask_t *span);
1434+				struct em_data_callback *cb, cpumask_t *span,
1435+				bool milliwatts);
1436 void em_dev_unregister_perf_domain(struct device *dev);
1437
1438 /**
1439@@ -119,6 +123,9 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
1440 	struct em_perf_state *ps;
1441 	int i, cpu;
1442
1443+	if (!sum_util)
1444+		return 0;
1445+
1446 	/*
1447 	 * In order to predict the performance state, map the utilization of
1448 	 * the most utilized CPU of the performance domain to a requested
1449@@ -202,7 +209,8 @@ struct em_data_callback {};
1450
1451 static inline
1452 int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
1453-				struct em_data_callback *cb, cpumask_t *span)
1454+				struct em_data_callback *cb, cpumask_t *span,
1455+				bool milliwatts)
1456 {
1457 	return -EINVAL;
1458 }
1459diff --git a/include/linux/extcon.h b/include/linux/extcon.h
1460index 0c19010da..9c4ff7f7d 100644
1461--- a/include/linux/extcon.h
1462+++ b/include/linux/extcon.h
1463@@ -37,6 +37,7 @@
1464 /* USB external connector */
1465 #define EXTCON_USB		1
1466 #define EXTCON_USB_HOST		2
1467+#define EXTCON_USB_VBUS_EN	3
1468
1469 /*
1470  * Charging external connector
1471diff --git a/include/linux/freezer.h b/include/linux/freezer.h
1472index 27828145c..f753c307b 100644
1473--- a/include/linux/freezer.h
1474+++ b/include/linux/freezer.h
1475@@ -27,6 +27,11 @@ static inline bool frozen(struct task_struct *p)
1476 	return p->flags & PF_FROZEN;
1477 }
1478
1479+static inline bool frozen_or_skipped(struct task_struct *p)
1480+{
1481+	return p->flags & (PF_FROZEN | PF_FREEZER_SKIP);
1482+}
1483+
1484 extern bool freezing_slow_path(struct task_struct *p);
1485
1486 /*
1487@@ -270,6 +275,7 @@ static inline int freezable_schedule_hrtimeout_range(ktime_t *expires,
1488
1489 #else /* !CONFIG_FREEZER */
1490 static inline bool frozen(struct task_struct *p) { return false; }
1491+static inline bool frozen_or_skipped(struct task_struct *p) { return false; }
1492 static inline bool freezing(struct task_struct *p) { return false; }
1493 static inline void __thaw_task(struct task_struct *t) {}
1494
1495diff --git a/include/linux/iommu.h b/include/linux/iommu.h
1496index e90c267e7..f94cfde78 100644
1497--- a/include/linux/iommu.h
1498+++ b/include/linux/iommu.h
1499@@ -31,6 +31,26 @@
1500  * if the IOMMU page table format is equivalent.
1501  */
1502 #define IOMMU_PRIV	(1 << 5)
1503+/*
1504+ * Non-coherent masters can use this page protection flag to set cacheable
1505+ * memory attributes for only a transparent outer level of cache, also known as
1506+ * the last-level or system cache.
1507+ */
1508+#define IOMMU_SYS_CACHE_ONLY	(1 << 6)
1509+/*
1510+ * Non-coherent masters can use this page protection flag to set cacheable
1511+ * memory attributes with a no write allocation cache policy for only a
1512+ * transparent outer level of cache, also known as the last-level or system
1513+ * cache.
1514+ */
1515+#define IOMMU_SYS_CACHE_ONLY_NWA (1 << 7)
1516+
1517+#ifdef CONFIG_NO_GKI
1518+
1519+/* For shoting entire IOMMU tlb once */
1520+#define IOMMU_TLB_SHOT_ENTIRE	(1 << 8)
1521+
1522+#endif
1523
1524 struct iommu_ops;
1525 struct iommu_group;
1526@@ -190,7 +210,12 @@ struct iommu_iotlb_gather {
1527  * @attach_dev: attach device to an iommu domain
1528  * @detach_dev: detach device from an iommu domain
1529  * @map: map a physically contiguous memory region to an iommu domain
1530+ * @map_pages: map a physically contiguous set of pages of the same size to
1531+ *             an iommu domain.
1532+ * @map_sg: map a scatter-gather list of physically contiguous chunks to
1533+ *          an iommu domain.
1534  * @unmap: unmap a physically contiguous memory region from an iommu domain
1535+ * @unmap_pages: unmap a number of pages of the same size from an iommu domain
1536  * @flush_iotlb_all: Synchronously flush all hardware TLBs for this domain
1537  * @iotlb_sync_map: Sync mappings created recently using @map to the hardware
1538  * @iotlb_sync: Flush all queued ranges from the hardware TLBs and empty flush
1539@@ -241,10 +266,20 @@ struct iommu_ops {
1540 	void (*detach_dev)(struct iommu_domain *domain, struct device *dev);
1541 	int (*map)(struct iommu_domain *domain, unsigned long iova,
1542 		   phys_addr_t paddr, size_t size, int prot, gfp_t gfp);
1543+	int (*map_pages)(struct iommu_domain *domain, unsigned long iova,
1544+			 phys_addr_t paddr, size_t pgsize, size_t pgcount,
1545+			 int prot, gfp_t gfp, size_t *mapped);
1546+	int (*map_sg)(struct iommu_domain *domain, unsigned long iova,
1547+		      struct scatterlist *sg, unsigned int nents, int prot,
1548+		      gfp_t gfp, size_t *mapped);
1549 	size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
1550 		     size_t size, struct iommu_iotlb_gather *iotlb_gather);
1551+	size_t (*unmap_pages)(struct iommu_domain *domain, unsigned long iova,
1552+			      size_t pgsize, size_t pgcount,
1553+			      struct iommu_iotlb_gather *iotlb_gather);
1554 	void (*flush_iotlb_all)(struct iommu_domain *domain);
1555-	void (*iotlb_sync_map)(struct iommu_domain *domain);
1556+	void (*iotlb_sync_map)(struct iommu_domain *domain, unsigned long iova,
1557+			       size_t size);
1558 	void (*iotlb_sync)(struct iommu_domain *domain,
1559 			   struct iommu_iotlb_gather *iotlb_gather);
1560 	phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);
1561@@ -561,6 +596,8 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain,
1562 extern struct iommu_group *pci_device_group(struct device *dev);
1563 /* Generic device grouping function */
1564 extern struct iommu_group *generic_device_group(struct device *dev);
1565+extern void rk_iommu_mask_irq(struct device *dev);
1566+extern void rk_iommu_unmask_irq(struct device *dev);
1567 /* FSL-MC device grouping function */
1568 struct iommu_group *fsl_mc_device_group(struct device *dev);
1569
1570@@ -1069,6 +1106,14 @@ static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
1571 {
1572 	return NULL;
1573 }
1574+
1575+static inline void rk_iommu_mask_irq(struct device *dev)
1576+{
1577+}
1578+
1579+static inline void rk_iommu_unmask_irq(struct device *dev)
1580+{
1581+}
1582 #endif /* CONFIG_IOMMU_API */
1583
1584 /**
1585diff --git a/include/linux/iova.h b/include/linux/iova.h
1586index a0637abff..58713bb72 100644
1587--- a/include/linux/iova.h
1588+++ b/include/linux/iova.h
1589@@ -95,6 +95,7 @@ struct iova_domain {
1590 						   flush-queues */
1591 	atomic_t fq_timer_on;			/* 1 when timer is active, 0
1592 						   when not */
1593+	bool best_fit;
1594 };
1595
1596 static inline unsigned long iova_size(struct iova *iova)
1597diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h
1598index f6d092fdb..ffb0a8705 100644
1599--- a/include/linux/irqchip/arm-gic-v3.h
1600+++ b/include/linux/irqchip/arm-gic-v3.h
1601@@ -708,6 +708,8 @@ static inline bool gic_enable_sre(void)
1602 	return !!(val & ICC_SRE_EL1_SRE);
1603 }
1604
1605+void gic_resume(void);
1606+
1607 #endif
1608
1609 #endif
1610diff --git a/include/linux/irqchip/arm-gic-v4.h b/include/linux/irqchip/arm-gic-v4.h
1611index 6976b8331..943c3411c 100644
1612--- a/include/linux/irqchip/arm-gic-v4.h
1613+++ b/include/linux/irqchip/arm-gic-v4.h
1614@@ -39,6 +39,8 @@ struct its_vpe {
1615 	irq_hw_number_t		vpe_db_lpi;
1616 	/* VPE resident */
1617 	bool			resident;
1618+	/* VPT parse complete */
1619+	bool			ready;
1620 	union {
1621 		/* GICv4.0 implementations */
1622 		struct {
1623@@ -104,6 +106,7 @@ enum its_vcpu_info_cmd_type {
1624 	PROP_UPDATE_AND_INV_VLPI,
1625 	SCHEDULE_VPE,
1626 	DESCHEDULE_VPE,
1627+	COMMIT_VPE,
1628 	INVALL_VPE,
1629 	PROP_UPDATE_VSGI,
1630 };
1631@@ -129,6 +132,7 @@ int its_alloc_vcpu_irqs(struct its_vm *vm);
1632 void its_free_vcpu_irqs(struct its_vm *vm);
1633 int its_make_vpe_resident(struct its_vpe *vpe, bool g0en, bool g1en);
1634 int its_make_vpe_non_resident(struct its_vpe *vpe, bool db);
1635+int its_commit_vpe(struct its_vpe *vpe);
1636 int its_invall_vpe(struct its_vpe *vpe);
1637 int its_map_vlpi(int irq, struct its_vlpi_map *map);
1638 int its_get_vlpi(int irq, struct its_vlpi_map *map);
1639diff --git a/include/linux/memblock.h b/include/linux/memblock.h
1640index 3baea2ef3..2b770134c 100644
1641--- a/include/linux/memblock.h
1642+++ b/include/linux/memblock.h
1643@@ -25,6 +25,10 @@ extern unsigned long max_pfn;
1644  */
1645 extern unsigned long long max_possible_pfn;
1646
1647+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
1648+extern int defer_free_memblock(void *unused);
1649+#endif
1650+
1651 /**
1652  * enum memblock_flags - definition of memory region attributes
1653  * @MEMBLOCK_NONE: no special request
1654@@ -404,13 +408,13 @@ void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align,
1655 			     phys_addr_t min_addr, phys_addr_t max_addr,
1656 			     int nid);
1657
1658-static inline void * __init memblock_alloc(phys_addr_t size,  phys_addr_t align)
1659+static __always_inline void *memblock_alloc(phys_addr_t size, phys_addr_t align)
1660 {
1661 	return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT,
1662 				      MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE);
1663 }
1664
1665-static inline void * __init memblock_alloc_raw(phys_addr_t size,
1666+static inline void *memblock_alloc_raw(phys_addr_t size,
1667 					       phys_addr_t align)
1668 {
1669 	return memblock_alloc_try_nid_raw(size, align, MEMBLOCK_LOW_LIMIT,
1670@@ -418,7 +422,7 @@ static inline void * __init memblock_alloc_raw(phys_addr_t size,
1671 					  NUMA_NO_NODE);
1672 }
1673
1674-static inline void * __init memblock_alloc_from(phys_addr_t size,
1675+static inline void *memblock_alloc_from(phys_addr_t size,
1676 						phys_addr_t align,
1677 						phys_addr_t min_addr)
1678 {
1679@@ -426,33 +430,33 @@ static inline void * __init memblock_alloc_from(phys_addr_t size,
1680 				      MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE);
1681 }
1682
1683-static inline void * __init memblock_alloc_low(phys_addr_t size,
1684+static inline void *memblock_alloc_low(phys_addr_t size,
1685 					       phys_addr_t align)
1686 {
1687 	return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT,
1688 				      ARCH_LOW_ADDRESS_LIMIT, NUMA_NO_NODE);
1689 }
1690
1691-static inline void * __init memblock_alloc_node(phys_addr_t size,
1692+static inline void *memblock_alloc_node(phys_addr_t size,
1693 						phys_addr_t align, int nid)
1694 {
1695 	return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT,
1696 				      MEMBLOCK_ALLOC_ACCESSIBLE, nid);
1697 }
1698
1699-static inline void __init memblock_free_early(phys_addr_t base,
1700+static inline void memblock_free_early(phys_addr_t base,
1701 					      phys_addr_t size)
1702 {
1703 	memblock_free(base, size);
1704 }
1705
1706-static inline void __init memblock_free_early_nid(phys_addr_t base,
1707+static inline void memblock_free_early_nid(phys_addr_t base,
1708 						  phys_addr_t size, int nid)
1709 {
1710 	memblock_free(base, size);
1711 }
1712
1713-static inline void __init memblock_free_late(phys_addr_t base, phys_addr_t size)
1714+static inline void memblock_free_late(phys_addr_t base, phys_addr_t size)
1715 {
1716 	__memblock_free_late(base, size);
1717 }
1718@@ -460,7 +464,7 @@ static inline void __init memblock_free_late(phys_addr_t base, phys_addr_t size)
1719 /*
1720  * Set the allocation direction to bottom-up or top-down.
1721  */
1722-static inline void __init memblock_set_bottom_up(bool enable)
1723+static inline __init void memblock_set_bottom_up(bool enable)
1724 {
1725 	memblock.bottom_up = enable;
1726 }
1727@@ -470,7 +474,7 @@ static inline void __init memblock_set_bottom_up(bool enable)
1728  * if this is true, that said, memblock will allocate memory
1729  * in bottom-up direction.
1730  */
1731-static inline bool memblock_bottom_up(void)
1732+static inline __init bool memblock_bottom_up(void)
1733 {
1734 	return memblock.bottom_up;
1735 }
1736diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
1737index e07f6e61c..7cdc5dfa4 100644
1738--- a/include/linux/mfd/rk808.h
1739+++ b/include/linux/mfd/rk808.h
1740@@ -113,6 +113,235 @@ enum rk808_reg {
1741 #define RK808_INT_STS_MSK_REG2	0x4f
1742 #define RK808_IO_POL_REG	0x50
1743
1744+/* RK816 */
1745+enum rk816_reg {
1746+	RK816_ID_DCDC1,
1747+	RK816_ID_DCDC2,
1748+	RK816_ID_DCDC3,
1749+	RK816_ID_DCDC4,
1750+	RK816_ID_LDO1,
1751+	RK816_ID_LDO2,
1752+	RK816_ID_LDO3,
1753+	RK816_ID_LDO4,
1754+	RK816_ID_LDO5,
1755+	RK816_ID_LDO6,
1756+};
1757+
1758+/*VERSION REGISTER*/
1759+#define RK816_CHIP_NAME_REG			0x17
1760+#define RK816_CHIP_VER_REG			0x18
1761+#define RK816_OTP_VER_REG			0x19
1762+#define RK816_NUM_REGULATORS			10
1763+
1764+/*POWER ON/OFF REGISTER*/
1765+#define RK816_VB_MON_REG			0x21
1766+#define RK816_THERMAL_REG			0x22
1767+#define RK816_PWRON_LP_INT_TIME_REG		0x47
1768+#define RK816_PWRON_DB_REG			0x48
1769+#define RK816_DEV_CTRL_REG			0x4B
1770+#define RK816_ON_SOURCE_REG			0xAE
1771+#define RK816_OFF_SOURCE_REG			0xAF
1772+
1773+/*POWER CHANNELS ENABLE REGISTER*/
1774+#define RK816_DCDC_EN_REG1			0x23
1775+#define RK816_DCDC_EN_REG2			0x24
1776+#define RK816_SLP_DCDC_EN_REG			0x25
1777+#define RK816_SLP_LDO_EN_REG			0x26
1778+#define RK816_LDO_EN_REG1			0x27
1779+#define RK816_LDO_EN_REG2			0x28
1780+
1781+/*BUCK AND LDO CONFIG REGISTER*/
1782+#define RK816_BUCK1_CONFIG_REG			0x2E
1783+#define RK816_BUCK1_ON_VSEL_REG			0x2F
1784+#define RK816_BUCK1_SLP_VSEL_REG		0x30
1785+#define RK816_BUCK2_CONFIG_REG			0x32
1786+#define RK816_BUCK2_ON_VSEL_REG			0x33
1787+#define RK816_BUCK2_SLP_VSEL_REG		0x34
1788+#define RK816_BUCK3_CONFIG_REG			0x36
1789+#define RK816_BUCK4_CONFIG_REG			0x37
1790+#define RK816_BUCK4_ON_VSEL_REG			0x38
1791+#define RK816_BUCK4_SLP_VSEL_REG		0x39
1792+#define RK816_LDO1_ON_VSEL_REG			0x3B
1793+#define RK816_LDO1_SLP_VSEL_REG			0x3C
1794+#define RK816_LDO2_ON_VSEL_REG			0x3D
1795+#define RK816_LDO2_SLP_VSEL_REG			0x3E
1796+#define RK816_LDO3_ON_VSEL_REG			0x3F
1797+#define RK816_LDO3_SLP_VSEL_REG			0x40
1798+#define RK816_LDO4_ON_VSEL_REG			0x41
1799+#define RK816_LDO4_SLP_VSEL_REG			0x42
1800+#define RK816_LDO5_ON_VSEL_REG			0x43
1801+#define RK816_LDO5_SLP_VSEL_REG			0x44
1802+#define RK816_LDO6_ON_VSEL_REG			0x45
1803+#define RK816_LDO6_SLP_VSEL_REG			0x46
1804+#define RK816_GPIO_IO_POL_REG			0x50
1805+
1806+/*CHARGER BOOST AND OTG REGISTER*/
1807+#define RK816_OTG_BUCK_LDO_CONFIG_REG           0x2A
1808+#define RK816_CHRG_CONFIG_REG                   0x2B
1809+#define RK816_BOOST_ON_VESL_REG                 0x54
1810+#define RK816_BOOST_SLP_VSEL_REG                0x55
1811+#define RK816_CHRG_BOOST_CONFIG_REG             0x9A
1812+#define RK816_SUP_STS_REG                       0xA0
1813+#define RK816_USB_CTRL_REG                      0xA1
1814+#define RK816_CHRG_CTRL_REG1                    0xA3
1815+#define RK816_CHRG_CTRL_REG2                    0xA4
1816+#define RK816_CHRG_CTRL_REG3                    0xA5
1817+#define RK816_BAT_CTRL_REG                      0xA6
1818+#define RK816_BAT_HTS_TS_REG                    0xA8
1819+#define RK816_BAT_LTS_TS_REG                    0xA9
1820+
1821+#define RK816_TS_CTRL_REG			0xAC
1822+#define RK816_ADC_CTRL_REG			0xAD
1823+#define RK816_GGCON_REG				0xB0
1824+#define RK816_GGSTS_REG				0xB1
1825+#define RK816_ZERO_CUR_ADC_REGH			0xB2
1826+#define RK816_ZERO_CUR_ADC_REGL			0xB3
1827+#define RK816_GASCNT_CAL_REG3			0xB4
1828+#define RK816_GASCNT_CAL_REG2			0xB5
1829+#define RK816_GASCNT_CAL_REG1			0xB6
1830+#define RK816_GASCNT_CAL_REG0			0xB7
1831+#define RK816_GASCNT_REG3			0xB8
1832+#define RK816_GASCNT_REG2			0xB9
1833+#define RK816_GASCNT_REG1			0xBA
1834+#define RK816_GASCNT_REG0			0xBB
1835+#define RK816_BAT_CUR_AVG_REGH			0xBC
1836+#define RK816_BAT_CUR_AVG_REGL			0xBD
1837+#define RK816_TS_ADC_REGH			0xBE
1838+#define RK816_TS_ADC_REGL			0xBF
1839+#define RK816_USB_ADC_REGH			0xC0
1840+#define RK816_USB_ADC_REGL			0xC1
1841+#define RK816_BAT_OCV_REGH			0xC2
1842+#define RK816_BAT_OCV_REGL			0xC3
1843+#define RK816_BAT_VOL_REGH			0xC4
1844+#define RK816_BAT_VOL_REGL			0xC5
1845+#define RK816_RELAX_ENTRY_THRES_REGH		0xC6
1846+#define RK816_RELAX_ENTRY_THRES_REGL		0xC7
1847+#define RK816_RELAX_EXIT_THRES_REGH		0xC8
1848+#define RK816_RELAX_EXIT_THRES_REGL		0xC9
1849+#define RK816_RELAX_VOL1_REGH			0xCA
1850+#define RK816_RELAX_VOL1_REGL			0xCB
1851+#define RK816_RELAX_VOL2_REGH			0xCC
1852+#define RK816_RELAX_VOL2_REGL			0xCD
1853+#define RK816_RELAX_CUR1_REGH			0xCE
1854+#define RK816_RELAX_CUR1_REGL			0xCF
1855+#define RK816_RELAX_CUR2_REGH			0xD0
1856+#define RK816_RELAX_CUR2_REGL			0xD1
1857+#define RK816_CAL_OFFSET_REGH			0xD2
1858+#define RK816_CAL_OFFSET_REGL			0xD3
1859+#define RK816_NON_ACT_TIMER_CNT_REG		0xD4
1860+#define RK816_VCALIB0_REGH			0xD5
1861+#define RK816_VCALIB0_REGL			0xD6
1862+#define RK816_VCALIB1_REGH			0xD7
1863+#define RK816_VCALIB1_REGL			0xD8
1864+#define RK816_FCC_GASCNT_REG3			0xD9
1865+#define RK816_FCC_GASCNT_REG2			0xDA
1866+#define RK816_FCC_GASCNT_REG1			0xDB
1867+#define RK816_FCC_GASCNT_REG0			0xDC
1868+#define RK816_IOFFSET_REGH			0xDD
1869+#define RK816_IOFFSET_REGL			0xDE
1870+#define RK816_SLEEP_CON_SAMP_CUR_REG		0xDF
1871+
1872+/*DATA REGISTER*/
1873+#define RK816_SOC_REG				0xE0
1874+#define RK816_REMAIN_CAP_REG3			0xE1
1875+#define RK816_REMAIN_CAP_REG2			0xE2
1876+#define RK816_REMAIN_CAP_REG1			0xE3
1877+#define RK816_REMAIN_CAP_REG0			0xE4
1878+#define RK816_UPDATE_LEVE_REG			0xE5
1879+#define RK816_NEW_FCC_REG3			0xE6
1880+#define RK816_NEW_FCC_REG2			0xE7
1881+#define RK816_NEW_FCC_REG1			0xE8
1882+#define RK816_NEW_FCC_REG0			0xE9
1883+#define RK816_NON_ACT_TIMER_CNT_REG_SAVE	0xEA
1884+#define RK816_OCV_VOL_VALID_REG			0xEB
1885+#define RK816_REBOOT_CNT_REG			0xEC
1886+#define RK816_PCB_IOFFSET_REG			0xED
1887+#define RK816_MISC_MARK_REG			0xEE
1888+#define RK816_HALT_CNT_REG			0xEF
1889+#define RK816_CALC_REST_REGH			0xF0
1890+#define RK816_CALC_REST_REGL			0xF1
1891+#define DATA18_REG				0xF2
1892+
1893+/*INTERRUPT REGISTER*/
1894+#define RK816_INT_STS_REG1			0x49
1895+#define RK816_INT_STS_MSK_REG1			0x4A
1896+#define RK816_INT_STS_REG2			0x4C
1897+#define RK816_INT_STS_MSK_REG2			0x4D
1898+#define RK816_INT_STS_REG3			0x4E
1899+#define RK816_INT_STS_MSK_REG3			0x4F
1900+#define RK816_GPIO_IO_POL_REG			0x50
1901+
1902+#define RK816_DATA18_REG			0xF2
1903+
1904+/* IRQ Definitions */
1905+#define RK816_IRQ_PWRON_FALL			0
1906+#define RK816_IRQ_PWRON_RISE			1
1907+#define RK816_IRQ_VB_LOW			2
1908+#define RK816_IRQ_PWRON				3
1909+#define RK816_IRQ_PWRON_LP			4
1910+#define RK816_IRQ_HOTDIE			5
1911+#define RK816_IRQ_RTC_ALARM			6
1912+#define RK816_IRQ_RTC_PERIOD			7
1913+#define RK816_IRQ_USB_OV			8
1914+#define RK816_IRQ_PLUG_IN			9
1915+#define RK816_IRQ_PLUG_OUT			10
1916+#define RK816_IRQ_CHG_OK			11
1917+#define RK816_IRQ_CHG_TE			12
1918+#define RK816_IRQ_CHG_TS			13
1919+#define RK816_IRQ_CHG_CVTLIM			14
1920+#define RK816_IRQ_DISCHG_ILIM			15
1921+
1922+#define RK816_IRQ_PWRON_FALL_MSK		BIT(5)
1923+#define RK816_IRQ_PWRON_RISE_MSK		BIT(6)
1924+#define RK816_IRQ_VB_LOW_MSK			BIT(1)
1925+#define RK816_IRQ_PWRON_MSK			BIT(2)
1926+#define RK816_IRQ_PWRON_LP_MSK			BIT(3)
1927+#define RK816_IRQ_HOTDIE_MSK			BIT(4)
1928+#define RK816_IRQ_RTC_ALARM_MSK			BIT(5)
1929+#define RK816_IRQ_RTC_PERIOD_MSK		BIT(6)
1930+#define RK816_IRQ_USB_OV_MSK			BIT(7)
1931+#define RK816_IRQ_PLUG_IN_MSK			BIT(0)
1932+#define RK816_IRQ_PLUG_OUT_MSK			BIT(1)
1933+#define RK816_IRQ_CHG_OK_MSK			BIT(2)
1934+#define RK816_IRQ_CHG_TE_MSK			BIT(3)
1935+#define RK816_IRQ_CHG_TS_MSK			BIT(4)
1936+#define RK816_IRQ_CHG_CVTLIM_MSK		BIT(6)
1937+#define RK816_IRQ_DISCHG_ILIM_MSK		BIT(7)
1938+
1939+#define RK816_VBAT_LOW_2V8			0x00
1940+#define RK816_VBAT_LOW_2V9			0x01
1941+#define RK816_VBAT_LOW_3V0			0x02
1942+#define RK816_VBAT_LOW_3V1			0x03
1943+#define RK816_VBAT_LOW_3V2			0x04
1944+#define RK816_VBAT_LOW_3V3			0x05
1945+#define RK816_VBAT_LOW_3V4			0x06
1946+#define RK816_VBAT_LOW_3V5			0x07
1947+#define RK816_PWR_FALL_INT_STATUS		(0x1 << 5)
1948+#define RK816_PWR_RISE_INT_STATUS		(0x1 << 6)
1949+#define RK816_ALARM_INT_STATUS			(0x1 << 5)
1950+#define EN_VBAT_LOW_IRQ				(0x1 << 4)
1951+#define VBAT_LOW_ACT_MASK			(0x1 << 4)
1952+#define RTC_TIMER_ALARM_INT_MSK			(0x3 << 2)
1953+#define RTC_TIMER_ALARM_INT_DIS			(0x0 << 2)
1954+#define RTC_PERIOD_ALARM_INT_MSK		(0x3 << 5)
1955+#define RTC_PERIOD_ALARM_INT_ST			(0x3 << 5)
1956+#define RTC_PERIOD_ALARM_INT_DIS		(0x3 << 5)
1957+#define RTC_PERIOD_ALARM_INT_EN			(0x9f)
1958+#define REG_WRITE_MSK				0xff
1959+#define BUCK4_MAX_ILIMIT			0x2c
1960+#define BUCK_RATE_MSK				(0x3 << 3)
1961+#define BUCK_RATE_12_5MV_US			(0x2 << 3)
1962+#define ALL_INT_FLAGS_ST			0xff
1963+#define PLUGIN_OUT_INT_EN			0xfc
1964+#define RK816_PWRON_FALL_RISE_INT_EN		0x9f
1965+#define BUCK1_2_IMAX_MAX			(0x3 << 6)
1966+#define BUCK3_4_IMAX_MAX			(0x3 << 3)
1967+#define BOOST_DISABLE				((0x1 << 5) | (0x0 << 1))
1968+#define BUCK4_VRP_3PERCENT			0xc0
1969+#define RK816_BUCK_DVS_CONFIRM			(0x1 << 7)
1970+#define RK816_TYPE_ES2				0x05
1971+#define RK816_CHIP_VERSION_MASK			0x0f
1972+
1973 /* RK818 */
1974 #define RK818_DCDC1			0
1975 #define RK818_LDO1			4
1976@@ -138,6 +367,8 @@ enum rk818_reg {
1977 	RK818_ID_OTG_SWITCH,
1978 };
1979
1980+#define RK818_VB_MON_REG		0x21
1981+#define RK818_THERMAL_REG		0x22
1982 #define RK818_DCDC_EN_REG		0x23
1983 #define RK818_LDO_EN_REG		0x24
1984 #define RK818_SLEEP_SET_OFF_REG1	0x25
1985@@ -190,7 +421,84 @@ enum rk818_reg {
1986 #define RK818_BOOST_LDO9_SLP_VSEL_REG	0x55
1987 #define RK818_BOOST_CTRL_REG		0x56
1988 #define RK818_DCDC_ILMAX		0x90
1989+#define RK818_CHRG_COMP_REG		0x9a
1990+#define RK818_SUP_STS_REG		0xa0
1991 #define RK818_USB_CTRL_REG		0xa1
1992+#define RK818_CHRG_CTRL_REG1		0xa3
1993+#define RK818_CHRG_CTRL_REG2		0xa4
1994+#define RK818_CHRG_CTRL_REG3		0xa5
1995+#define RK818_BAT_CTRL_REG		0xa6
1996+#define RK818_BAT_HTS_TS1_REG		0xa8
1997+#define RK818_BAT_LTS_TS1_REG		0xa9
1998+#define RK818_BAT_HTS_TS2_REG		0xaa
1999+#define RK818_BAT_LTS_TS2_REG		0xab
2000+#define RK818_TS_CTRL_REG		0xac
2001+#define RK818_ADC_CTRL_REG		0xad
2002+#define RK818_ON_SOURCE_REG		0xae
2003+#define RK818_OFF_SOURCE_REG		0xaf
2004+#define RK818_GGCON_REG			0xb0
2005+#define RK818_GGSTS_REG			0xb1
2006+#define RK818_FRAME_SMP_INTERV_REG	0xb2
2007+#define RK818_AUTO_SLP_CUR_THR_REG	0xb3
2008+#define RK818_GASCNT_CAL_REG3		0xb4
2009+#define RK818_GASCNT_CAL_REG2		0xb5
2010+#define RK818_GASCNT_CAL_REG1		0xb6
2011+#define RK818_GASCNT_CAL_REG0		0xb7
2012+#define RK818_GASCNT3_REG		0xb8
2013+#define RK818_GASCNT2_REG		0xb9
2014+#define RK818_GASCNT1_REG		0xba
2015+#define RK818_GASCNT0_REG		0xbb
2016+#define RK818_BAT_CUR_AVG_REGH		0xbc
2017+#define RK818_BAT_CUR_AVG_REGL		0xbd
2018+#define RK818_TS1_ADC_REGH		0xbe
2019+#define RK818_TS1_ADC_REGL		0xbf
2020+#define RK818_TS2_ADC_REGH		0xc0
2021+#define RK818_TS2_ADC_REGL		0xc1
2022+#define RK818_BAT_OCV_REGH		0xc2
2023+#define RK818_BAT_OCV_REGL		0xc3
2024+#define RK818_BAT_VOL_REGH		0xc4
2025+#define RK818_BAT_VOL_REGL		0xc5
2026+#define RK818_RELAX_ENTRY_THRES_REGH	0xc6
2027+#define RK818_RELAX_ENTRY_THRES_REGL	0xc7
2028+#define RK818_RELAX_EXIT_THRES_REGH	0xc8
2029+#define RK818_RELAX_EXIT_THRES_REGL	0xc9
2030+#define RK818_RELAX_VOL1_REGH		0xca
2031+#define RK818_RELAX_VOL1_REGL		0xcb
2032+#define RK818_RELAX_VOL2_REGH		0xcc
2033+#define RK818_RELAX_VOL2_REGL		0xcd
2034+#define RK818_BAT_CUR_R_CALC_REGH	0xce
2035+#define RK818_BAT_CUR_R_CALC_REGL	0xcf
2036+#define RK818_BAT_VOL_R_CALC_REGH	0xd0
2037+#define RK818_BAT_VOL_R_CALC_REGL	0xd1
2038+#define RK818_CAL_OFFSET_REGH		0xd2
2039+#define RK818_CAL_OFFSET_REGL		0xd3
2040+#define RK818_NON_ACT_TIMER_CNT_REG	0xd4
2041+#define RK818_VCALIB0_REGH		0xd5
2042+#define RK818_VCALIB0_REGL		0xd6
2043+#define RK818_VCALIB1_REGH		0xd7
2044+#define RK818_VCALIB1_REGL		0xd8
2045+#define RK818_IOFFSET_REGH		0xdd
2046+#define RK818_IOFFSET_REGL		0xde
2047+#define RK818_SOC_REG			0xe0
2048+#define RK818_REMAIN_CAP_REG3		0xe1
2049+#define RK818_REMAIN_CAP_REG2		0xe2
2050+#define RK818_REMAIN_CAP_REG1		0xe3
2051+#define RK818_REMAIN_CAP_REG0		0xe4
2052+#define RK818_UPDAT_LEVE_REG		0xe5
2053+#define RK818_NEW_FCC_REG3		0xe6
2054+#define RK818_NEW_FCC_REG2		0xe7
2055+#define RK818_NEW_FCC_REG1		0xe8
2056+#define RK818_NEW_FCC_REG0		0xe9
2057+#define RK818_NON_ACT_TIMER_CNT_SAVE_REG	0xea
2058+#define RK818_OCV_VOL_VALID_REG		0xeb
2059+#define RK818_REBOOT_CNT_REG		0xec
2060+#define RK818_POFFSET_REG		0xed
2061+#define RK818_MISC_MARK_REG		0xee
2062+#define RK818_HALT_CNT_REG		0xef
2063+#define RK818_CALC_REST_REGH		0xf0
2064+#define RK818_CALC_REST_REGL		0xf1
2065+#define RK818_SAVE_DATA19		0xf2
2066+#define RK818_NUM_REGULATOR		17
2067
2068 #define RK818_H5V_EN			BIT(0)
2069 #define RK818_REF_RDY_CTRL		BIT(1)
2070@@ -255,14 +563,22 @@ enum rk805_reg {
2071 #define RK805_PWRON_FALL_RISE_INT_MSK	0x81
2072
2073 /* RK805 IRQ Definitions */
2074-#define RK805_IRQ_PWRON_RISE		0
2075 #define RK805_IRQ_VB_LOW		1
2076 #define RK805_IRQ_PWRON			2
2077 #define RK805_IRQ_PWRON_LP		3
2078 #define RK805_IRQ_HOTDIE		4
2079 #define RK805_IRQ_RTC_ALARM		5
2080 #define RK805_IRQ_RTC_PERIOD		6
2081-#define RK805_IRQ_PWRON_FALL		7
2082+
2083+/*
2084+ * When PMIC irq occurs, regmap-irq.c will traverse all PMIC child
2085+ * interrupts from low index 0 to high index, we give fall interrupt
2086+ * high priority to be called earlier than rise, so that it can be
2087+ * override by late rise event. This can helps to solve key release
2088+ * glitch which make a wrongly fall event immediately after rise.
2089+ */
2090+#define RK805_IRQ_PWRON_FALL		0
2091+#define RK805_IRQ_PWRON_RISE		7
2092
2093 #define RK805_IRQ_PWRON_RISE_MSK	BIT(0)
2094 #define RK805_IRQ_VB_LOW_MSK		BIT(1)
2095@@ -289,6 +605,16 @@ enum rk805_reg {
2096 #define RK805_INT_ALARM_EN		(1 << 3)
2097 #define RK805_INT_TIMER_EN		(1 << 2)
2098
2099+#define RK805_SLP_LDO_EN_OFFSET		-1
2100+#define RK805_SLP_DCDC_EN_OFFSET	2
2101+
2102+#define RK805_RAMP_RATE_OFFSET		3
2103+#define RK805_RAMP_RATE_MASK		(3 << RK805_RAMP_RATE_OFFSET)
2104+#define RK805_RAMP_RATE_3MV_PER_US	(0 << RK805_RAMP_RATE_OFFSET)
2105+#define RK805_RAMP_RATE_6MV_PER_US	(1 << RK805_RAMP_RATE_OFFSET)
2106+#define RK805_RAMP_RATE_12_5MV_PER_US	(2 << RK805_RAMP_RATE_OFFSET)
2107+#define RK805_RAMP_RATE_25MV_PER_US	(3 << RK805_RAMP_RATE_OFFSET)
2108+
2109 /* RK808 IRQ Definitions */
2110 #define RK808_IRQ_VOUT_LO	0
2111 #define RK808_IRQ_VB_LO		1
2112@@ -348,6 +674,107 @@ enum rk805_reg {
2113
2114 #define RK818_NUM_IRQ		16
2115
2116+/*RK818_DCDC_EN_REG*/
2117+#define BUCK1_EN_MASK		BIT(0)
2118+#define BUCK2_EN_MASK		BIT(1)
2119+#define BUCK3_EN_MASK		BIT(2)
2120+#define BUCK4_EN_MASK		BIT(3)
2121+#define BOOST_EN_MASK		BIT(4)
2122+#define LDO9_EN_MASK		BIT(5)
2123+#define SWITCH_EN_MASK		BIT(6)
2124+#define OTG_EN_MASK		BIT(7)
2125+
2126+#define BUCK1_EN_ENABLE		BIT(0)
2127+#define BUCK2_EN_ENABLE		BIT(1)
2128+#define BUCK3_EN_ENABLE		BIT(2)
2129+#define BUCK4_EN_ENABLE		BIT(3)
2130+#define BOOST_EN_ENABLE		BIT(4)
2131+#define LDO9_EN_ENABLE		BIT(5)
2132+#define SWITCH_EN_ENABLE	BIT(6)
2133+#define OTG_EN_ENABLE		BIT(7)
2134+
2135+#define BUCK1_SLP_SET_MASK	BIT(0)
2136+#define BUCK2_SLP_SET_MASK	BIT(1)
2137+#define BUCK3_SLP_SET_MASK	BIT(2)
2138+#define BUCK4_SLP_SET_MASK	BIT(3)
2139+#define BOOST_SLP_SET_MASK	BIT(4)
2140+#define LDO9_SLP_SET_MASK	BIT(5)
2141+#define SWITCH_SLP_SET_MASK	BIT(6)
2142+#define OTG_SLP_SET_MASK	BIT(7)
2143+
2144+#define BUCK1_SLP_SET_OFF	BIT(0)
2145+#define BUCK2_SLP_SET_OFF	BIT(1)
2146+#define BUCK3_SLP_SET_OFF	BIT(2)
2147+#define BUCK4_SLP_SET_OFF	BIT(3)
2148+#define BOOST_SLP_SET_OFF	BIT(4)
2149+#define LDO9_SLP_SET_OFF	BIT(5)
2150+#define SWITCH_SLP_SET_OFF	BIT(6)
2151+#define OTG_SLP_SET_OFF		BIT(7)
2152+#define OTG_BOOST_SLP_OFF	(BOOST_SLP_SET_OFF | OTG_SLP_SET_OFF)
2153+
2154+#define BUCK1_SLP_SET_ON	BIT(0)
2155+#define BUCK2_SLP_SET_ON	BIT(1)
2156+#define BUCK3_SLP_SET_ON	BIT(2)
2157+#define BUCK4_SLP_SET_ON	BIT(3)
2158+#define BOOST_SLP_SET_ON	BIT(4)
2159+#define LDO9_SLP_SET_ON		BIT(5)
2160+#define SWITCH_SLP_SET_ON	BIT(6)
2161+#define OTG_SLP_SET_ON		BIT(7)
2162+
2163+#define VOUT_LO_MASK		BIT(0)
2164+#define VB_LO_MASK		BIT(1)
2165+#define PWRON_MASK		BIT(2)
2166+#define PWRON_LP_MASK		BIT(3)
2167+#define HOTDIE_MASK		BIT(4)
2168+#define RTC_ALARM_MASK		BIT(5)
2169+#define RTC_PERIOD_MASK		BIT(6)
2170+#define USB_OV_MASK		BIT(7)
2171+
2172+#define VOUT_LO_DISABLE		BIT(0)
2173+#define VB_LO_DISABLE		BIT(1)
2174+#define PWRON_DISABLE		BIT(2)
2175+#define PWRON_LP_DISABLE	BIT(3)
2176+#define HOTDIE_DISABLE		BIT(4)
2177+#define RTC_ALARM_DISABLE	BIT(5)
2178+#define RTC_PERIOD_DISABLE	BIT(6)
2179+#define USB_OV_INT_DISABLE	BIT(7)
2180+
2181+#define VOUT_LO_ENABLE		(0 << 0)
2182+#define VB_LO_ENABLE		(0 << 1)
2183+#define PWRON_ENABLE		(0 << 2)
2184+#define PWRON_LP_ENABLE		(0 << 3)
2185+#define HOTDIE_ENABLE		(0 << 4)
2186+#define RTC_ALARM_ENABLE	(0 << 5)
2187+#define RTC_PERIOD_ENABLE	(0 << 6)
2188+#define USB_OV_INT_ENABLE	(0 << 7)
2189+
2190+#define PLUG_IN_MASK		BIT(0)
2191+#define PLUG_OUT_MASK		BIT(1)
2192+#define CHGOK_MASK		BIT(2)
2193+#define CHGTE_MASK		BIT(3)
2194+#define CHGTS1_MASK		BIT(4)
2195+#define TS2_MASK		BIT(5)
2196+#define CHG_CVTLIM_MASK		BIT(6)
2197+#define DISCHG_ILIM_MASK	BIT(7)
2198+
2199+#define PLUG_IN_DISABLE		BIT(0)
2200+#define PLUG_OUT_DISABLE	BIT(1)
2201+#define CHGOK_DISABLE		BIT(2)
2202+#define CHGTE_DISABLE		BIT(3)
2203+#define CHGTS1_DISABLE		BIT(4)
2204+#define TS2_DISABLE		BIT(5)
2205+#define CHG_CVTLIM_DISABLE	BIT(6)
2206+#define DISCHG_ILIM_DISABLE	BIT(7)
2207+
2208+#define PLUG_IN_ENABLE		BIT(0)
2209+#define PLUG_OUT_ENABLE		BIT(1)
2210+#define CHGOK_ENABLE		BIT(2)
2211+#define CHGTE_ENABLE		BIT(3)
2212+#define CHGTS1_ENABLE		BIT(4)
2213+#define TS2_ENABLE		BIT(5)
2214+#define CHG_CVTLIM_ENABLE	BIT(6)
2215+#define DISCHG_ILIM_ENABLE	BIT(7)
2216+
2217 #define RK808_VBAT_LOW_2V8	0x00
2218 #define RK808_VBAT_LOW_2V9	0x01
2219 #define RK808_VBAT_LOW_3V0	0x02
2220@@ -381,7 +808,10 @@ enum rk805_reg {
2221
2222 #define VOUT_LO_INT	BIT(0)
2223 #define CLK32KOUT2_EN	BIT(0)
2224+#define CLK32KOUT2_FUNC		(0 << 1)
2225+#define CLK32KOUT2_FUNC_MASK	BIT(1)
2226
2227+#define TEMP105C			0x08
2228 #define TEMP115C			0x0c
2229 #define TEMP_HOTDIE_MSK			0x0c
2230 #define SLP_SD_MSK			(0x3 << 2)
2231@@ -391,6 +821,7 @@ enum rk805_reg {
2232 #define PWM_MODE_MSK			BIT(7)
2233 #define FPWM_MODE			BIT(7)
2234 #define AUTO_PWM_MODE			0
2235+#define REGS_WMSK			0xf0
2236
2237 enum rk817_reg_id {
2238 	RK817_ID_DCDC1 = 0,
2239@@ -436,6 +867,10 @@ enum rk809_reg_id {
2240 #define RK817_RTC_INT_REG		0xf
2241 #define RK817_RTC_COMP_LSB_REG		0x10
2242 #define RK817_RTC_COMP_MSB_REG		0x11
2243+#define RK817_ADC_CONFIG0		0x50
2244+#define RK817_CURE_ADC_K0		0xb0
2245+#define RK817_POWER_EN_SAVE0            0x99
2246+#define RK817_POWER_EN_SAVE1            0xa4
2247
2248 #define RK817_POWER_EN_REG(i)		(0xb1 + (i))
2249 #define RK817_POWER_SLP_EN_REG(i)	(0xb5 + (i))
2250@@ -462,6 +897,9 @@ enum rk809_reg_id {
2251 #define RK817_LDO_ON_VSEL_REG(idx)	(0xcc + (idx) * 2)
2252 #define RK817_BOOST_OTG_CFG		(0xde)
2253
2254+#define RK817_CHRG_OUT			0xe4
2255+#define RK817_CHRG_IN			0xe5
2256+#define RK817_CHRG_STS			0xeb
2257 #define RK817_ID_MSB			0xed
2258 #define RK817_ID_LSB			0xee
2259
2260@@ -609,16 +1047,27 @@ enum {
2261 	RK805_ID = 0x8050,
2262 	RK808_ID = 0x0000,
2263 	RK809_ID = 0x8090,
2264+	RK816_ID = 0x8160,
2265 	RK817_ID = 0x8170,
2266 	RK818_ID = 0x8180,
2267 };
2268
2269+struct rk808_pin_info {
2270+	struct pinctrl *p;
2271+	struct pinctrl_state *reset;
2272+	struct pinctrl_state *power_off;
2273+	struct pinctrl_state *sleep;
2274+};
2275+
2276 struct rk808 {
2277 	struct i2c_client		*i2c;
2278 	struct regmap_irq_chip_data	*irq_data;
2279+	struct regmap_irq_chip_data	*battery_irq_data;
2280 	struct regmap			*regmap;
2281 	long				variant;
2282 	const struct regmap_config	*regmap_cfg;
2283 	const struct regmap_irq_chip	*regmap_irq_chip;
2284+	void				(*pm_pwroff_prep_fn)(void);
2285+	struct rk808_pin_info *pins;
2286 };
2287 #endif /* __LINUX_REGULATOR_RK808_H */
2288diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
2289index 40d7e98fc..819f6119d 100644
2290--- a/include/linux/mmc/host.h
2291+++ b/include/linux/mmc/host.h
2292@@ -141,6 +141,7 @@ struct mmc_host_ops {
2293
2294 	/* Check if the card is pulling dat[0:3] low */
2295 	int	(*card_busy)(struct mmc_host *host);
2296+	int     (*set_sdio_status)(struct mmc_host *host, int val);
2297
2298 	/* The tuning command opcode value is different for SD and eMMC cards */
2299 	int	(*execute_tuning)(struct mmc_host *host, u32 opcode);
2300@@ -483,6 +484,9 @@ void mmc_free_host(struct mmc_host *);
2301 int mmc_of_parse(struct mmc_host *host);
2302 int mmc_of_parse_voltage(struct device_node *np, u32 *mask);
2303
2304+extern struct mmc_host *primary_sdio_host;
2305+int mmc_host_rescan(struct mmc_host *host, int val, int is_cap_sdio_irq);
2306+
2307 static inline void *mmc_priv(struct mmc_host *host)
2308 {
2309 	return (void *)host->private;
2310diff --git a/include/linux/mmu_context.h b/include/linux/mmu_context.h
2311index 03dee12d2..bc4ac3c52 100644
2312--- a/include/linux/mmu_context.h
2313+++ b/include/linux/mmu_context.h
2314@@ -14,4 +14,12 @@
2315 static inline void leave_mm(int cpu) { }
2316 #endif
2317
2318+/*
2319+ * CPUs that are capable of running task @p. By default, we assume a sane,
2320+ * homogeneous system. Must contain at least one active CPU.
2321+ */
2322+#ifndef task_cpu_possible_mask
2323+# define task_cpu_possible_mask(p)	cpu_possible_mask
2324+#endif
2325+
2326 #endif
2327diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
2328index 81a55e974..aefa0b0bc 100644
2329--- a/include/linux/power_supply.h
2330+++ b/include/linux/power_supply.h
2331@@ -49,6 +49,12 @@ enum {
2332 	POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE,	/* dynamically adjusted speed */
2333 	POWER_SUPPLY_CHARGE_TYPE_CUSTOM,	/* use CHARGE_CONTROL_* props */
2334 	POWER_SUPPLY_CHARGE_TYPE_LONGLIFE,	/* slow speed, longer life */
2335+
2336+	/*
2337+	 * force to 50 to minimize the chances of userspace binary
2338+	 * incompatibility on newer upstream kernels
2339+	 */
2340+	POWER_SUPPLY_CHARGE_TYPE_TAPER = 50,	/* charging in CV phase */
2341 };
2342
2343 enum {
2344@@ -386,12 +392,22 @@ extern void power_supply_put(struct power_supply *psy);
2345 #ifdef CONFIG_OF
2346 extern struct power_supply *power_supply_get_by_phandle(struct device_node *np,
2347 							const char *property);
2348+extern int power_supply_get_by_phandle_array(struct device_node *np,
2349+					     const char *property,
2350+					     struct power_supply **psy,
2351+					     ssize_t size);
2352 extern struct power_supply *devm_power_supply_get_by_phandle(
2353 				    struct device *dev, const char *property);
2354 #else /* !CONFIG_OF */
2355 static inline struct power_supply *
2356 power_supply_get_by_phandle(struct device_node *np, const char *property)
2357 { return NULL; }
2358+static inline int
2359+power_supply_get_by_phandle_array(struct device_node *np,
2360+				  const char *property,
2361+				  struct power_supply **psy,
2362+				  int size)
2363+{ return 0; }
2364 static inline struct power_supply *
2365 devm_power_supply_get_by_phandle(struct device *dev, const char *property)
2366 { return NULL; }
2367@@ -426,9 +442,16 @@ static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
2368 extern int power_supply_get_property(struct power_supply *psy,
2369 			    enum power_supply_property psp,
2370 			    union power_supply_propval *val);
2371+#if IS_ENABLED(CONFIG_POWER_SUPPLY)
2372 extern int power_supply_set_property(struct power_supply *psy,
2373 			    enum power_supply_property psp,
2374 			    const union power_supply_propval *val);
2375+#else
2376+static inline int power_supply_set_property(struct power_supply *psy,
2377+			    enum power_supply_property psp,
2378+			    const union power_supply_propval *val)
2379+{ return 0; }
2380+#endif
2381 extern int power_supply_property_is_writeable(struct power_supply *psy,
2382 					enum power_supply_property psp);
2383 extern void power_supply_external_power_changed(struct power_supply *psy);
2384diff --git a/include/linux/psi_types.h b/include/linux/psi_types.h
2385index 17d74f62c..541b45881 100644
2386--- a/include/linux/psi_types.h
2387+++ b/include/linux/psi_types.h
2388@@ -154,6 +154,7 @@ struct psi_group {
2389 	struct timer_list poll_timer;
2390 	wait_queue_head_t poll_wait;
2391 	atomic_t poll_wakeup;
2392+	atomic_t poll_scheduled;
2393
2394 	/* Protects data used by the monitor */
2395 	struct mutex trigger_lock;
2396diff --git a/include/linux/pwm.h b/include/linux/pwm.h
2397index a13ff383f..6b2a7fb80 100644
2398--- a/include/linux/pwm.h
2399+++ b/include/linux/pwm.h
2400@@ -59,6 +59,9 @@ struct pwm_state {
2401 	u64 period;
2402 	u64 duty_cycle;
2403 	enum pwm_polarity polarity;
2404+#ifdef CONFIG_PWM_ROCKCHIP_ONESHOT
2405+	u64 oneshot_count;
2406+#endif /* CONFIG_PWM_ROCKCHIP_ONESHOT */
2407 	bool enabled;
2408 };
2409
2410diff --git a/include/linux/reboot.h b/include/linux/reboot.h
2411index 3734cd8f3..1c8d7856c 100644
2412--- a/include/linux/reboot.h
2413+++ b/include/linux/reboot.h
2414@@ -49,6 +49,26 @@ extern int register_restart_handler(struct notifier_block *);
2415 extern int unregister_restart_handler(struct notifier_block *);
2416 extern void do_kernel_restart(char *cmd);
2417
2418+#ifdef CONFIG_NO_GKI
2419+extern int register_pre_restart_handler(struct notifier_block *nb);
2420+extern int unregister_pre_restart_handler(struct notifier_block *nb);
2421+extern void do_kernel_pre_restart(char *cmd);
2422+#else
2423+static inline int register_pre_restart_handler(struct notifier_block *nb)
2424+{
2425+	return 0;
2426+}
2427+
2428+static inline int unregister_pre_restart_handler(struct notifier_block *nb)
2429+{
2430+	return 0;
2431+}
2432+
2433+static inline void do_kernel_pre_restart(char *cmd)
2434+{
2435+}
2436+#endif
2437+
2438 /*
2439  * Architecture-specific implementations of sys_reboot commands.
2440  */
2441diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
2442index 11cade737..d7c77ee37 100644
2443--- a/include/linux/regulator/driver.h
2444+++ b/include/linux/regulator/driver.h
2445@@ -223,6 +223,8 @@ enum regulator_type {
2446  * @name: Identifying name for the regulator.
2447  * @supply_name: Identifying the regulator supply
2448  * @of_match: Name used to identify regulator in DT.
2449+ * @of_match_full_name: A flag to indicate that the of_match string, if
2450+ *			present, should be matched against the node full_name.
2451  * @regulators_node: Name of node containing regulator definitions in DT.
2452  * @of_parse_cb: Optional callback called only if of_match is present.
2453  *               Will be called for each regulator parsed from DT, during
2454@@ -314,6 +316,7 @@ struct regulator_desc {
2455 	const char *name;
2456 	const char *supply_name;
2457 	const char *of_match;
2458+	bool of_match_full_name;
2459 	const char *regulators_node;
2460 	int (*of_parse_cb)(struct device_node *,
2461 			    const struct regulator_desc *,
2462diff --git a/include/linux/regulator/fan53555.h b/include/linux/regulator/fan53555.h
2463index ce8df2186..e8703b6fc 100644
2464--- a/include/linux/regulator/fan53555.h
2465+++ b/include/linux/regulator/fan53555.h
2466@@ -52,6 +52,8 @@ struct fan53555_platform_data {
2467 	unsigned int slew_rate;
2468 	/* Sleep VSEL ID */
2469 	unsigned int sleep_vsel_id;
2470+	int limit_volt;
2471+	struct gpio_desc *vsel_gpio;
2472 };
2473
2474 #endif /* __FAN53555_H__ */
2475diff --git a/include/linux/sched.h b/include/linux/sched.h
2476index 3dca22f2a..ef9d4a196 100644
2477--- a/include/linux/sched.h
2478+++ b/include/linux/sched.h
2479@@ -1356,7 +1356,7 @@ struct task_struct {
2480 	u64				timer_slack_ns;
2481 	u64				default_timer_slack_ns;
2482
2483-#ifdef CONFIG_KASAN
2484+#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
2485 	unsigned int			kasan_depth;
2486 #endif
2487
2488diff --git a/include/linux/sched/hotplug.h b/include/linux/sched/hotplug.h
2489index 9a62ffdd2..89fb9b027 100644
2490--- a/include/linux/sched/hotplug.h
2491+++ b/include/linux/sched/hotplug.h
2492@@ -8,7 +8,11 @@
2493
2494 extern int sched_cpu_starting(unsigned int cpu);
2495 extern int sched_cpu_activate(unsigned int cpu);
2496+extern int sched_cpus_activate(struct cpumask *cpus);
2497 extern int sched_cpu_deactivate(unsigned int cpu);
2498+extern int sched_cpus_deactivate_nosync(struct cpumask *cpus);
2499+extern int sched_cpu_drain_rq(unsigned int cpu);
2500+extern void sched_cpu_drain_rq_wait(unsigned int cpu);
2501
2502 #ifdef CONFIG_HOTPLUG_CPU
2503 extern int sched_cpu_dying(unsigned int cpu);
2504diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
2505index 22420b45b..cc9f393e2 100644
2506--- a/include/linux/sched/isolation.h
2507+++ b/include/linux/sched/isolation.h
2508@@ -28,25 +28,10 @@ extern void __init housekeeping_init(void);
2509
2510 #else
2511
2512-#ifdef CONFIG_CPU_ISOLATION_OPT
2513-static inline int housekeeping_any_cpu(enum hk_flags flags)
2514-{
2515-	cpumask_t available;
2516-	int cpu;
2517-
2518-	cpumask_andnot(&available, cpu_online_mask, cpu_isolated_mask);
2519-	cpu = cpumask_any(&available);
2520-	if (cpu >= nr_cpu_ids)
2521-		cpu = smp_processor_id();
2522-
2523-	return cpu;
2524-}
2525-#else
2526 static inline int housekeeping_any_cpu(enum hk_flags flags)
2527 {
2528 	return smp_processor_id();
2529 }
2530-#endif
2531
2532 static inline const struct cpumask *housekeeping_cpumask(enum hk_flags flags)
2533 {
2534@@ -69,11 +54,7 @@ static inline bool housekeeping_cpu(int cpu, enum hk_flags flags)
2535 	if (static_branch_unlikely(&housekeeping_overridden))
2536 		return housekeeping_test_cpu(cpu, flags);
2537 #endif
2538-#ifdef CONFIG_CPU_ISOLATION_OPT
2539-	return !cpu_isolated(cpu);
2540-#else
2541 	return true;
2542-#endif
2543 }
2544
2545 #endif /* _LINUX_SCHED_ISOLATION_H */
2546diff --git a/include/linux/sched/wake_q.h b/include/linux/sched/wake_q.h
2547index 26a2013ac..1e05e5669 100644
2548--- a/include/linux/sched/wake_q.h
2549+++ b/include/linux/sched/wake_q.h
2550@@ -38,6 +38,7 @@
2551 struct wake_q_head {
2552 	struct wake_q_node *first;
2553 	struct wake_q_node **lastp;
2554+	int count;
2555 };
2556
2557 #define WAKE_Q_TAIL ((struct wake_q_node *) 0x01)
2558@@ -49,6 +50,7 @@ static inline void wake_q_init(struct wake_q_head *head)
2559 {
2560 	head->first = WAKE_Q_TAIL;
2561 	head->lastp = &head->first;
2562+	head->count = 0;
2563 }
2564
2565 static inline bool wake_q_empty(struct wake_q_head *head)
2566diff --git a/include/linux/sched/xacct.h b/include/linux/sched/xacct.h
2567index c078f0a94..9544c9d9d 100644
2568--- a/include/linux/sched/xacct.h
2569+++ b/include/linux/sched/xacct.h
2570@@ -28,6 +28,11 @@ static inline void inc_syscw(struct task_struct *tsk)
2571 {
2572 	tsk->ioac.syscw++;
2573 }
2574+
2575+static inline void inc_syscfs(struct task_struct *tsk)
2576+{
2577+	tsk->ioac.syscfs++;
2578+}
2579 #else
2580 static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
2581 {
2582@@ -44,6 +49,10 @@ static inline void inc_syscr(struct task_struct *tsk)
2583 static inline void inc_syscw(struct task_struct *tsk)
2584 {
2585 }
2586+
2587+static inline void inc_syscfs(struct task_struct *tsk)
2588+{
2589+}
2590 #endif
2591
2592 #endif /* _LINUX_SCHED_XACCT_H */
2593diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
2594index b56e1dedc..ba4246721 100644
2595--- a/include/linux/stmmac.h
2596+++ b/include/linux/stmmac.h
2597@@ -183,6 +183,7 @@ struct plat_stmmacenet_data {
2598 	void (*serdes_powerdown)(struct net_device *ndev, void *priv);
2599 	int (*init)(struct platform_device *pdev, void *priv);
2600 	void (*exit)(struct platform_device *pdev, void *priv);
2601+	void (*get_eth_addr)(void *priv, unsigned char *addr);
2602 	struct mac_device_info *(*setup)(void *priv);
2603 	void *bsp_priv;
2604 	struct clk *stmmac_clk;
2605diff --git a/include/linux/thermal.h b/include/linux/thermal.h
2606index 176d9454e..aa4b4114b 100644
2607--- a/include/linux/thermal.h
2608+++ b/include/linux/thermal.h
2609@@ -399,6 +399,7 @@ void thermal_cdev_update(struct thermal_cooling_device *);
2610 void thermal_notify_framework(struct thermal_zone_device *, int);
2611 int thermal_zone_device_enable(struct thermal_zone_device *tz);
2612 int thermal_zone_device_disable(struct thermal_zone_device *tz);
2613+int thermal_zone_device_is_enabled(struct thermal_zone_device *tz);
2614 #else
2615 static inline struct thermal_zone_device *thermal_zone_device_register(
2616 	const char *type, int trips, int mask, void *devdata,
2617@@ -453,6 +454,10 @@ static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
2618
2619 static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
2620 { return -ENODEV; }
2621+
2622+static inline int
2623+thermal_zone_device_is_enabled(struct thermal_zone_device *tz)
2624+{ return -ENODEV; }
2625 #endif /* CONFIG_THERMAL */
2626
2627 #endif /* __THERMAL_H__ */
2628diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h
2629index ead8c9a47..899c84e7c 100644
2630--- a/include/linux/usb/audio-v2.h
2631+++ b/include/linux/usb/audio-v2.h
2632@@ -168,6 +168,20 @@ struct uac2_effect_unit_descriptor {
2633 	__u8 bmaControls[]; /* variable length */
2634 } __attribute__((packed));
2635
2636+#define UAC2_DT_FEATURE_UNIT_SIZE(ch)		(6 + ((ch) + 1) * 4)
2637+
2638+/* As above, but more useful for defining your own descriptors: */
2639+#define DECLARE_UAC2_FEATURE_UNIT_DESCRIPTOR(ch)		\
2640+struct uac2_feature_unit_descriptor_##ch {			\
2641+	__u8  bLength;						\
2642+	__u8  bDescriptorType;					\
2643+	__u8  bDescriptorSubtype;				\
2644+	__u8  bUnitID;						\
2645+	__u8  bSourceID;					\
2646+	__le32 bmaControls[ch + 1];				\
2647+	__u8  iFeature;						\
2648+} __attribute__((packed))
2649+
2650 /* 4.9.2 Class-Specific AS Interface Descriptor */
2651
2652 struct uac2_as_header_descriptor {
2653@@ -331,6 +345,9 @@ struct uac2_interrupt_data_msg {
2654 #define UAC2_FU_OVERFLOW		0x0f
2655 #define UAC2_FU_LATENCY			0x10
2656
2657+#define UAC2_CONTROL_BIT_RO(CS)		(0x01 << (((CS) - 1) << 1))
2658+#define UAC2_CONTROL_BIT_RW(CS)		(0x03 << (((CS) - 1) << 1))
2659+
2660 /* A.17.8.1 Parametric Equalizer Section Effect Unit Control Selectors */
2661 #define UAC2_PE_UNDEFINED		0x00
2662 #define UAC2_PE_ENABLE			0x01
2663diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
2664index 170acd500..646cb0a8d 100644
2665--- a/include/linux/usb/audio.h
2666+++ b/include/linux/usb/audio.h
2667@@ -31,6 +31,7 @@ struct usb_audio_control {
2668 	int data[5];
2669 	int (*set)(struct usb_audio_control *con, u8 cmd, int value);
2670 	int (*get)(struct usb_audio_control *con, u8 cmd);
2671+	void *context;
2672 };
2673
2674 struct usb_audio_control_selector {
2675diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
2676index a2d229ab6..4d352204e 100644
2677--- a/include/linux/usb/composite.h
2678+++ b/include/linux/usb/composite.h
2679@@ -525,6 +525,8 @@ extern struct usb_string *usb_gstrings_attach(struct usb_composite_dev *cdev,
2680 extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n);
2681
2682 extern void composite_disconnect(struct usb_gadget *gadget);
2683+extern void composite_reset(struct usb_gadget *gadget);
2684+
2685 extern int composite_setup(struct usb_gadget *gadget,
2686 		const struct usb_ctrlrequest *ctrl);
2687 extern void composite_suspend(struct usb_gadget *gadget);
2688@@ -590,6 +592,7 @@ struct usb_function_instance {
2689 	struct config_group group;
2690 	struct list_head cfs_list;
2691 	struct usb_function_driver *fd;
2692+	struct usb_function *f;
2693 	int (*set_inst_name)(struct usb_function_instance *inst,
2694 			      const char *name);
2695 	void (*free_func_inst)(struct usb_function_instance *inst);
2696diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
2697index e7351d64f..a15700a40 100644
2698--- a/include/linux/usb/gadget.h
2699+++ b/include/linux/usb/gadget.h
2700@@ -217,6 +217,7 @@ struct usb_ep_caps {
2701  *	enabled and remains valid until the endpoint is disabled.
2702  * @comp_desc: In case of SuperSpeed support, this is the endpoint companion
2703  *	descriptor that is used to configure the endpoint
2704+ * @transfer_type: Used to specify transfer type of EP.
2705  *
2706  * the bus controller driver lists all the general purpose endpoints in
2707  * gadget->ep_list.  the control endpoint (gadget->ep0) is not in that list,
2708@@ -240,6 +241,9 @@ struct usb_ep {
2709 	u8			address;
2710 	const struct usb_endpoint_descriptor	*desc;
2711 	const struct usb_ss_ep_comp_descriptor	*comp_desc;
2712+#if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI)
2713+	u8			transfer_type;
2714+#endif
2715 };
2716
2717 /*-------------------------------------------------------------------------*/
2718@@ -323,6 +327,8 @@ struct usb_gadget_ops {
2719 			struct usb_gadget_driver *);
2720 	int	(*udc_stop)(struct usb_gadget *);
2721 	void	(*udc_set_speed)(struct usb_gadget *, enum usb_device_speed);
2722+	void	(*udc_set_ssp_rate)(struct usb_gadget *gadget,
2723+			enum usb_ssp_rate rate);
2724 	struct usb_ep *(*match_ep)(struct usb_gadget *,
2725 			struct usb_endpoint_descriptor *,
2726 			struct usb_ss_ep_comp_descriptor *);
2727@@ -339,6 +345,10 @@ struct usb_gadget_ops {
2728  * @speed: Speed of current connection to USB host.
2729  * @max_speed: Maximal speed the UDC can handle.  UDC must support this
2730  *      and all slower speeds.
2731+ * @ssp_rate: Current connected SuperSpeed Plus signaling rate and lane count.
2732+ * @max_ssp_rate: Maximum SuperSpeed Plus signaling rate and lane count the UDC
2733+ *	can handle. The UDC must support this and all slower speeds and lower
2734+ *	number of lanes.
2735  * @state: the state we are now (attached, suspended, configured, etc)
2736  * @name: Identifies the controller hardware type.  Used in diagnostics
2737  *	and sometimes configuration.
2738@@ -406,6 +416,11 @@ struct usb_gadget {
2739 	struct list_head		ep_list;	/* of usb_ep */
2740 	enum usb_device_speed		speed;
2741 	enum usb_device_speed		max_speed;
2742+
2743+	/* USB SuperSpeed Plus only */
2744+	enum usb_ssp_rate		ssp_rate;
2745+	enum usb_ssp_rate		max_ssp_rate;
2746+
2747 	enum usb_device_state		state;
2748 	const char			*name;
2749 	struct device			dev;
2750diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h
2751index 433040ff8..96b7ff66f 100644
2752--- a/include/linux/usb/pd.h
2753+++ b/include/linux/usb/pd.h
2754@@ -225,6 +225,7 @@ enum pd_pdo_type {
2755 #define PDO_FIXED_EXTPOWER		BIT(27) /* Externally powered */
2756 #define PDO_FIXED_USB_COMM		BIT(26) /* USB communications capable */
2757 #define PDO_FIXED_DATA_SWAP		BIT(25) /* Data role swap supported */
2758+#define PDO_FIXED_UNCHUNK_EXT		BIT(24) /* Unchunked Extended Message supported (Source) */
2759 #define PDO_FIXED_FRS_CURR_MASK		(BIT(24) | BIT(23)) /* FR_Swap Current (Sink) */
2760 #define PDO_FIXED_FRS_CURR_SHIFT	23
2761 #define PDO_FIXED_VOLT_SHIFT		10	/* 50mV units */
2762@@ -466,6 +467,7 @@ static inline unsigned int rdo_max_power(u32 rdo)
2763 #define PD_T_DRP_SRC		30
2764 #define PD_T_PS_SOURCE_OFF	920
2765 #define PD_T_PS_SOURCE_ON	480
2766+#define PD_T_PS_SOURCE_ON_PRS	450	/* 390 - 480ms */
2767 #define PD_T_PS_HARD_RESET	30
2768 #define PD_T_SRC_RECOVER	760
2769 #define PD_T_SRC_RECOVER_MAX	1000
2770@@ -478,14 +480,19 @@ static inline unsigned int rdo_max_power(u32 rdo)
2771 #define PD_T_NEWSRC		250	/* Maximum of 275ms */
2772 #define PD_T_SWAP_SRC_START	20	/* Minimum of 20ms */
2773 #define PD_T_BIST_CONT_MODE	50	/* 30 - 60 ms */
2774+#define PD_T_SINK_TX		16	/* 16 - 20 ms */
2775+#define PD_T_CHUNK_NOT_SUPP	42	/* 40 - 50 ms */
2776
2777 #define PD_T_DRP_TRY		100	/* 75 - 150 ms */
2778 #define PD_T_DRP_TRYWAIT	600	/* 400 - 800 ms */
2779
2780 #define PD_T_CC_DEBOUNCE	200	/* 100 - 200 ms */
2781 #define PD_T_PD_DEBOUNCE	20	/* 10 - 20 ms */
2782+#define PD_T_TRY_CC_DEBOUNCE	15	/* 10 - 20 ms */
2783
2784 #define PD_N_CAPS_COUNT		(PD_T_NO_RESPONSE / PD_T_SEND_SOURCE_CAP)
2785 #define PD_N_HARD_RESET_COUNT	2
2786
2787+#define PD_P_SNK_STDBY_MW	2500	/* 2500 mW */
2788+
2789 #endif /* __LINUX_USB_PD_H */
2790diff --git a/include/linux/usb/pd_ext_sdb.h b/include/linux/usb/pd_ext_sdb.h
2791index 0eb83ce19..b517ebc8f 100644
2792--- a/include/linux/usb/pd_ext_sdb.h
2793+++ b/include/linux/usb/pd_ext_sdb.h
2794@@ -24,8 +24,4 @@ enum usb_pd_ext_sdb_fields {
2795 #define USB_PD_EXT_SDB_EVENT_OVP		BIT(3)
2796 #define USB_PD_EXT_SDB_EVENT_CF_CV_MODE		BIT(4)
2797
2798-#define USB_PD_EXT_SDB_PPS_EVENTS	(USB_PD_EXT_SDB_EVENT_OCP |	\
2799-					 USB_PD_EXT_SDB_EVENT_OTP |	\
2800-					 USB_PD_EXT_SDB_EVENT_OVP)
2801-
2802 #endif /* __LINUX_USB_PD_EXT_SDB_H */
2803diff --git a/include/linux/usb/pd_vdo.h b/include/linux/usb/pd_vdo.h
2804index 68bdc4e2f..7f5e330a6 100644
2805--- a/include/linux/usb/pd_vdo.h
2806+++ b/include/linux/usb/pd_vdo.h
2807@@ -21,22 +21,24 @@
2808  * ----------
2809  * <31:16>  :: SVID
2810  * <15>     :: VDM type ( 1b == structured, 0b == unstructured )
2811- * <14:13>  :: Structured VDM version (can only be 00 == 1.0 currently)
2812+ * <14:13>  :: Structured VDM version
2813  * <12:11>  :: reserved
2814  * <10:8>   :: object position (1-7 valid ... used for enter/exit mode only)
2815  * <7:6>    :: command type (SVDM only?)
2816  * <5>      :: reserved (SVDM), command type (UVDM)
2817  * <4:0>    :: command
2818  */
2819-#define VDO(vid, type, custom)				\
2820+#define VDO(vid, type, ver, custom)			\
2821 	(((vid) << 16) |				\
2822 	 ((type) << 15) |				\
2823+	 ((ver) << 13) |				\
2824 	 ((custom) & 0x7FFF))
2825
2826 #define VDO_SVDM_TYPE		(1 << 15)
2827 #define VDO_SVDM_VERS(x)	((x) << 13)
2828 #define VDO_OPOS(x)		((x) << 8)
2829 #define VDO_CMDT(x)		((x) << 6)
2830+#define VDO_SVDM_VERS_MASK	VDO_SVDM_VERS(0x3)
2831 #define VDO_OPOS_MASK		VDO_OPOS(0x7)
2832 #define VDO_CMDT_MASK		VDO_CMDT(0x3)
2833
2834@@ -74,6 +76,7 @@
2835
2836 #define PD_VDO_VID(vdo)		((vdo) >> 16)
2837 #define PD_VDO_SVDM(vdo)	(((vdo) >> 15) & 1)
2838+#define PD_VDO_SVDM_VER(vdo)	(((vdo) >> 13) & 0x3)
2839 #define PD_VDO_OPOS(vdo)	(((vdo) >> 8) & 0x7)
2840 #define PD_VDO_CMD(vdo)		((vdo) & 0x1f)
2841 #define PD_VDO_CMDT(vdo)	(((vdo) >> 6) & 0x3)
2842@@ -103,25 +106,50 @@
2843  * --------------------
2844  * <31>     :: data capable as a USB host
2845  * <30>     :: data capable as a USB device
2846- * <29:27>  :: product type
2847+ * <29:27>  :: product type (UFP / Cable / VPD)
2848  * <26>     :: modal operation supported (1b == yes)
2849- * <25:16>  :: Reserved, Shall be set to zero
2850+ * <25:23>  :: product type (DFP) (SVDM version 2.0+ only; set to zero in version 1.0)
2851+ * <22:21>  :: connector type (SVDM version 2.0+ only; set to zero in version 1.0)
2852+ * <20:16>  :: Reserved, Shall be set to zero
2853  * <15:0>   :: USB-IF assigned VID for this cable vendor
2854  */
2855+
2856+/* PD Rev2.0 definition */
2857 #define IDH_PTYPE_UNDEF		0
2858+
2859+/* SOP Product Type (UFP) */
2860+#define IDH_PTYPE_NOT_UFP	0
2861 #define IDH_PTYPE_HUB		1
2862 #define IDH_PTYPE_PERIPH	2
2863+#define IDH_PTYPE_PSD		3
2864+#define IDH_PTYPE_AMA		5
2865+
2866+/* SOP' Product Type (Cable Plug / VPD) */
2867+#define IDH_PTYPE_NOT_CABLE	0
2868 #define IDH_PTYPE_PCABLE	3
2869 #define IDH_PTYPE_ACABLE	4
2870-#define IDH_PTYPE_AMA		5
2871+#define IDH_PTYPE_VPD		6
2872
2873-#define VDO_IDH(usbh, usbd, ptype, is_modal, vid)		\
2874-	((usbh) << 31 | (usbd) << 30 | ((ptype) & 0x7) << 27	\
2875-	 | (is_modal) << 26 | ((vid) & 0xffff))
2876+/* SOP Product Type (DFP) */
2877+#define IDH_PTYPE_NOT_DFP	0
2878+#define IDH_PTYPE_DFP_HUB	1
2879+#define IDH_PTYPE_DFP_HOST	2
2880+#define IDH_PTYPE_DFP_PB	3
2881+
2882+/* ID Header Mask */
2883+#define IDH_DFP_MASK		GENMASK(25, 23)
2884+#define IDH_CONN_MASK		GENMASK(22, 21)
2885+
2886+#define VDO_IDH(usbh, usbd, ufp_cable, is_modal, dfp, conn, vid)		\
2887+	((usbh) << 31 | (usbd) << 30 | ((ufp_cable) & 0x7) << 27		\
2888+	 | (is_modal) << 26 | ((dfp) & 0x7) << 23 | ((conn) & 0x3) << 21	\
2889+	 | ((vid) & 0xffff))
2890
2891 #define PD_IDH_PTYPE(vdo)	(((vdo) >> 27) & 0x7)
2892 #define PD_IDH_VID(vdo)		((vdo) & 0xffff)
2893 #define PD_IDH_MODAL_SUPP(vdo)	((vdo) & (1 << 26))
2894+#define PD_IDH_DFP_PTYPE(vdo)	(((vdo) >> 23) & 0x7)
2895+#define PD_IDH_CONN_TYPE(vdo)	(((vdo) >> 21) & 0x3)
2896
2897 /*
2898  * Cert Stat VDO
2899@@ -129,6 +157,7 @@
2900  * <31:0>  : USB-IF assigned XID for this cable
2901  */
2902 #define PD_CSTAT_XID(vdo)	(vdo)
2903+#define VDO_CERT(xid)		((xid) & 0xffffffff)
2904
2905 /*
2906  * Product VDO
2907@@ -140,77 +169,270 @@
2908 #define PD_PRODUCT_PID(vdo)	(((vdo) >> 16) & 0xffff)
2909
2910 /*
2911- * UFP VDO1
2912+ * UFP VDO (PD Revision 3.0+ only)
2913  * --------
2914  * <31:29> :: UFP VDO version
2915  * <28>    :: Reserved
2916  * <27:24> :: Device capability
2917- * <23:6>  :: Reserved
2918+ * <23:22> :: Connector type (10b == receptacle, 11b == captive plug)
2919+ * <21:11> :: Reserved
2920+ * <10:8>  :: Vconn power (AMA only)
2921+ * <7>     :: Vconn required (AMA only, 0b == no, 1b == yes)
2922+ * <6>     :: Vbus required (AMA only, 0b == yes, 1b == no)
2923  * <5:3>   :: Alternate modes
2924  * <2:0>   :: USB highest speed
2925  */
2926-#define PD_VDO1_UFP_DEVCAP(vdo)	(((vdo) & GENMASK(27, 24)) >> 24)
2927+#define PD_VDO_UFP_DEVCAP(vdo)	(((vdo) & GENMASK(27, 24)) >> 24)
2928
2929+/* UFP VDO Version */
2930+#define UFP_VDO_VER1_2		2
2931+
2932+/* Device Capability */
2933 #define DEV_USB2_CAPABLE	BIT(0)
2934 #define DEV_USB2_BILLBOARD	BIT(1)
2935 #define DEV_USB3_CAPABLE	BIT(2)
2936 #define DEV_USB4_CAPABLE	BIT(3)
2937
2938+/* Connector Type */
2939+#define UFP_RECEPTACLE		2
2940+#define UFP_CAPTIVE		3
2941+
2942+/* Vconn Power (AMA only, set to AMA_VCONN_NOT_REQ if Vconn is not required) */
2943+#define AMA_VCONN_PWR_1W	0
2944+#define AMA_VCONN_PWR_1W5	1
2945+#define AMA_VCONN_PWR_2W	2
2946+#define AMA_VCONN_PWR_3W	3
2947+#define AMA_VCONN_PWR_4W	4
2948+#define AMA_VCONN_PWR_5W	5
2949+#define AMA_VCONN_PWR_6W	6
2950+
2951+/* Vconn Required (AMA only) */
2952+#define AMA_VCONN_NOT_REQ	0
2953+#define AMA_VCONN_REQ		1
2954+
2955+/* Vbus Required (AMA only) */
2956+#define AMA_VBUS_REQ		0
2957+#define AMA_VBUS_NOT_REQ	1
2958+
2959+/* Alternate Modes */
2960+#define UFP_ALTMODE_NOT_SUPP	0
2961+#define UFP_ALTMODE_TBT3	BIT(0)
2962+#define UFP_ALTMODE_RECFG	BIT(1)
2963+#define UFP_ALTMODE_NO_RECFG	BIT(2)
2964+
2965+/* USB Highest Speed */
2966+#define UFP_USB2_ONLY		0
2967+#define UFP_USB32_GEN1		1
2968+#define UFP_USB32_4_GEN2	2
2969+#define UFP_USB4_GEN3		3
2970+
2971+#define VDO_UFP(ver, cap, conn, vcpwr, vcr, vbr, alt, spd)			\
2972+	(((ver) & 0x7) << 29 | ((cap) & 0xf) << 24 | ((conn) & 0x3) << 22	\
2973+	 | ((vcpwr) & 0x7) << 8 | (vcr) << 7 | (vbr) << 6 | ((alt) & 0x7) << 3	\
2974+	 | ((spd) & 0x7))
2975+
2976 /*
2977- * DFP VDO
2978+ * DFP VDO (PD Revision 3.0+ only)
2979  * --------
2980  * <31:29> :: DFP VDO version
2981  * <28:27> :: Reserved
2982  * <26:24> :: Host capability
2983- * <23:5>  :: Reserved
2984+ * <23:22> :: Connector type (10b == receptacle, 11b == captive plug)
2985+ * <21:5>  :: Reserved
2986  * <4:0>   :: Port number
2987  */
2988 #define PD_VDO_DFP_HOSTCAP(vdo)	(((vdo) & GENMASK(26, 24)) >> 24)
2989
2990+#define DFP_VDO_VER1_1		1
2991 #define HOST_USB2_CAPABLE	BIT(0)
2992 #define HOST_USB3_CAPABLE	BIT(1)
2993 #define HOST_USB4_CAPABLE	BIT(2)
2994+#define DFP_RECEPTACLE		2
2995+#define DFP_CAPTIVE		3
2996+
2997+#define VDO_DFP(ver, cap, conn, pnum)						\
2998+	(((ver) & 0x7) << 29 | ((cap) & 0x7) << 24 | ((conn) & 0x3) << 22	\
2999+	 | ((pnum) & 0x1f))
3000
3001 /*
3002- * Cable VDO
3003+ * Cable VDO (for both Passive and Active Cable VDO in PD Rev2.0)
3004  * ---------
3005  * <31:28> :: Cable HW version
3006  * <27:24> :: Cable FW version
3007  * <23:20> :: Reserved, Shall be set to zero
3008- * <19:18> :: type-C to Type-A/B/C (00b == A, 01 == B, 10 == C)
3009- * <17>    :: Type-C to Plug/Receptacle (0b == plug, 1b == receptacle)
3010+ * <19:18> :: type-C to Type-A/B/C/Captive (00b == A, 01 == B, 10 == C, 11 == Captive)
3011+ * <17>    :: Reserved, Shall be set to zero
3012  * <16:13> :: cable latency (0001 == <10ns(~1m length))
3013  * <12:11> :: cable termination type (11b == both ends active VCONN req)
3014  * <10>    :: SSTX1 Directionality support (0b == fixed, 1b == cfgable)
3015  * <9>     :: SSTX2 Directionality support
3016  * <8>     :: SSRX1 Directionality support
3017  * <7>     :: SSRX2 Directionality support
3018- * <6:5>   :: Vbus current handling capability
3019+ * <6:5>   :: Vbus current handling capability (01b == 3A, 10b == 5A)
3020  * <4>     :: Vbus through cable (0b == no, 1b == yes)
3021  * <3>     :: SOP" controller present? (0b == no, 1b == yes)
3022  * <2:0>   :: USB SS Signaling support
3023+ *
3024+ * Passive Cable VDO (PD Rev3.0+)
3025+ * ---------
3026+ * <31:28> :: Cable HW version
3027+ * <27:24> :: Cable FW version
3028+ * <23:21> :: VDO version
3029+ * <20>    :: Reserved, Shall be set to zero
3030+ * <19:18> :: Type-C to Type-C/Captive (10b == C, 11b == Captive)
3031+ * <17>    :: Reserved, Shall be set to zero
3032+ * <16:13> :: cable latency (0001 == <10ns(~1m length))
3033+ * <12:11> :: cable termination type (10b == Vconn not req, 01b == Vconn req)
3034+ * <10:9>  :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V)
3035+ * <8:7>   :: Reserved, Shall be set to zero
3036+ * <6:5>   :: Vbus current handling capability (01b == 3A, 10b == 5A)
3037+ * <4:3>   :: Reserved, Shall be set to zero
3038+ * <2:0>   :: USB highest speed
3039+ *
3040+ * Active Cable VDO 1 (PD Rev3.0+)
3041+ * ---------
3042+ * <31:28> :: Cable HW version
3043+ * <27:24> :: Cable FW version
3044+ * <23:21> :: VDO version
3045+ * <20>    :: Reserved, Shall be set to zero
3046+ * <19:18> :: Connector type (10b == C, 11b == Captive)
3047+ * <17>    :: Reserved, Shall be set to zero
3048+ * <16:13> :: cable latency (0001 == <10ns(~1m length))
3049+ * <12:11> :: cable termination type (10b == one end active, 11b == both ends active VCONN req)
3050+ * <10:9>  :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V)
3051+ * <8>     :: SBU supported (0b == supported, 1b == not supported)
3052+ * <7>     :: SBU type (0b == passive, 1b == active)
3053+ * <6:5>   :: Vbus current handling capability (01b == 3A, 10b == 5A)
3054+ * <2:0>   :: USB highest speed
3055  */
3056+/* Cable VDO Version */
3057+#define CABLE_VDO_VER1_0	0
3058+#define CABLE_VDO_VER1_3	3
3059+
3060+/* Connector Type (_ATYPE and _BTYPE are for PD Rev2.0 only) */
3061 #define CABLE_ATYPE		0
3062 #define CABLE_BTYPE		1
3063 #define CABLE_CTYPE		2
3064-#define CABLE_PLUG		0
3065-#define CABLE_RECEPTACLE	1
3066-#define CABLE_CURR_1A5		0
3067+#define CABLE_CAPTIVE		3
3068+
3069+/* Cable Latency */
3070+#define CABLE_LATENCY_1M	1
3071+#define CABLE_LATENCY_2M	2
3072+#define CABLE_LATENCY_3M	3
3073+#define CABLE_LATENCY_4M	4
3074+#define CABLE_LATENCY_5M	5
3075+#define CABLE_LATENCY_6M	6
3076+#define CABLE_LATENCY_7M	7
3077+#define CABLE_LATENCY_7M_PLUS	8
3078+
3079+/* Cable Termination Type */
3080+#define PCABLE_VCONN_NOT_REQ	0
3081+#define PCABLE_VCONN_REQ	1
3082+#define ACABLE_ONE_END		2
3083+#define ACABLE_BOTH_END		3
3084+
3085+/* Maximum Vbus Voltage */
3086+#define CABLE_MAX_VBUS_20V	0
3087+#define CABLE_MAX_VBUS_30V	1
3088+#define CABLE_MAX_VBUS_40V	2
3089+#define CABLE_MAX_VBUS_50V	3
3090+
3091+/* Active Cable SBU Supported/Type */
3092+#define ACABLE_SBU_SUPP		0
3093+#define ACABLE_SBU_NOT_SUPP	1
3094+#define ACABLE_SBU_PASSIVE	0
3095+#define ACABLE_SBU_ACTIVE	1
3096+
3097+/* Vbus Current Handling Capability */
3098+#define CABLE_CURR_DEF		0
3099 #define CABLE_CURR_3A		1
3100 #define CABLE_CURR_5A		2
3101+
3102+/* USB SuperSpeed Signaling Support (PD Rev2.0) */
3103 #define CABLE_USBSS_U2_ONLY	0
3104 #define CABLE_USBSS_U31_GEN1	1
3105 #define CABLE_USBSS_U31_GEN2	2
3106-#define VDO_CABLE(hw, fw, cbl, gdr, lat, term, tx1d, tx2d, rx1d, rx2d, cur,\
3107-		  vps, sopp, usbss) \
3108-	(((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 | ((cbl) & 0x3) << 18	\
3109-	 | (gdr) << 17 | ((lat) & 0x7) << 13 | ((term) & 0x3) << 11	\
3110-	 | (tx1d) << 10 | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7	\
3111-	 | ((cur) & 0x3) << 5 | (vps) << 4 | (sopp) << 3		\
3112-	 | ((usbss) & 0x7))
3113+
3114+/* USB Highest Speed */
3115+#define CABLE_USB2_ONLY		0
3116+#define CABLE_USB32_GEN1	1
3117+#define CABLE_USB32_4_GEN2	2
3118+#define CABLE_USB4_GEN3		3
3119+
3120+#define VDO_CABLE(hw, fw, cbl, lat, term, tx1d, tx2d, rx1d, rx2d, cur, vps, sopp, usbss) \
3121+	(((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 | ((cbl) & 0x3) << 18		\
3122+	 | ((lat) & 0x7) << 13 | ((term) & 0x3) << 11 | (tx1d) << 10		\
3123+	 | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7 | ((cur) & 0x3) << 5		\
3124+	 | (vps) << 4 | (sopp) << 3 | ((usbss) & 0x7))
3125+#define VDO_PCABLE(hw, fw, ver, conn, lat, term, vbm, cur, spd)			\
3126+	(((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21		\
3127+	 | ((conn) & 0x3) << 18 | ((lat) & 0xf) << 13 | ((term) & 0x3) << 11	\
3128+	 | ((vbm) & 0x3) << 9 | ((cur) & 0x3) << 5 | ((spd) & 0x7))
3129+#define VDO_ACABLE1(hw, fw, ver, conn, lat, term, vbm, sbu, sbut, cur, vbt, sopp, spd) \
3130+	(((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21		\
3131+	 | ((conn) & 0x3) << 18	| ((lat) & 0xf) << 13 | ((term) & 0x3) << 11	\
3132+	 | ((vbm) & 0x3) << 9 | (sbu) << 8 | (sbut) << 7 | ((cur) & 0x3) << 5	\
3133+	 | (vbt) << 4 | (sopp) << 3 | ((spd) & 0x7))
3134+
3135+#define VDO_TYPEC_CABLE_TYPE(vdo)	(((vdo) >> 18) & 0x3)
3136+
3137+/*
3138+ * Active Cable VDO 2
3139+ * ---------
3140+ * <31:24> :: Maximum operating temperature
3141+ * <23:16> :: Shutdown temperature
3142+ * <15>    :: Reserved, Shall be set to zero
3143+ * <14:12> :: U3/CLd power
3144+ * <11>    :: U3 to U0 transition mode (0b == direct, 1b == through U3S)
3145+ * <10>    :: Physical connection (0b == copper, 1b == optical)
3146+ * <9>     :: Active element (0b == redriver, 1b == retimer)
3147+ * <8>     :: USB4 supported (0b == yes, 1b == no)
3148+ * <7:6>   :: USB2 hub hops consumed
3149+ * <5>     :: USB2 supported (0b == yes, 1b == no)
3150+ * <4>     :: USB3.2 supported (0b == yes, 1b == no)
3151+ * <3>     :: USB lanes supported (0b == one lane, 1b == two lanes)
3152+ * <2>     :: Optically isolated active cable (0b == no, 1b == yes)
3153+ * <1>     :: Reserved, Shall be set to zero
3154+ * <0>     :: USB gen (0b == gen1, 1b == gen2+)
3155+ */
3156+
3157+/* U3/CLd Power*/
3158+#define ACAB2_U3_CLD_10MW_PLUS	0
3159+#define ACAB2_U3_CLD_10MW	1
3160+#define ACAB2_U3_CLD_5MW	2
3161+#define ACAB2_U3_CLD_1MW	3
3162+#define ACAB2_U3_CLD_500UW	4
3163+#define ACAB2_U3_CLD_200UW	5
3164+#define ACAB2_U3_CLD_50UW	6
3165+
3166+/* Other Active Cable VDO 2 Fields */
3167+#define ACAB2_U3U0_DIRECT	0
3168+#define ACAB2_U3U0_U3S		1
3169+#define ACAB2_PHY_COPPER	0
3170+#define ACAB2_PHY_OPTICAL	1
3171+#define ACAB2_REDRIVER		0
3172+#define ACAB2_RETIMER		1
3173+#define ACAB2_USB4_SUPP		0
3174+#define ACAB2_USB4_NOT_SUPP	1
3175+#define ACAB2_USB2_SUPP		0
3176+#define ACAB2_USB2_NOT_SUPP	1
3177+#define ACAB2_USB32_SUPP	0
3178+#define ACAB2_USB32_NOT_SUPP	1
3179+#define ACAB2_LANES_ONE		0
3180+#define ACAB2_LANES_TWO		1
3181+#define ACAB2_OPT_ISO_NO	0
3182+#define ACAB2_OPT_ISO_YES	1
3183+#define ACAB2_GEN_1		0
3184+#define ACAB2_GEN_2_PLUS	1
3185+
3186+#define VDO_ACABLE2(mtemp, stemp, u3p, trans, phy, ele, u4, hops, u2, u32, lane, iso, gen)	\
3187+	(((mtemp) & 0xff) << 24 | ((stemp) & 0xff) << 16 | ((u3p) & 0x7) << 12	\
3188+	 | (trans) << 11 | (phy) << 10 | (ele) << 9 | (u4) << 8			\
3189+	 | ((hops) & 0x3) << 6 | (u2) << 5 | (u32) << 4 | (lane) << 3		\
3190+	 | (iso) << 2 | (gen))
3191
3192 /*
3193- * AMA VDO
3194+ * AMA VDO (PD Rev2.0)
3195  * ---------
3196  * <31:28> :: Cable HW version
3197  * <27:24> :: Cable FW version
3198@@ -233,18 +455,40 @@
3199 #define PD_VDO_AMA_VCONN_REQ(vdo)	(((vdo) >> 4) & 1)
3200 #define PD_VDO_AMA_VBUS_REQ(vdo)	(((vdo) >> 3) & 1)
3201
3202-#define AMA_VCONN_PWR_1W	0
3203-#define AMA_VCONN_PWR_1W5	1
3204-#define AMA_VCONN_PWR_2W	2
3205-#define AMA_VCONN_PWR_3W	3
3206-#define AMA_VCONN_PWR_4W	4
3207-#define AMA_VCONN_PWR_5W	5
3208-#define AMA_VCONN_PWR_6W	6
3209 #define AMA_USBSS_U2_ONLY	0
3210 #define AMA_USBSS_U31_GEN1	1
3211 #define AMA_USBSS_U31_GEN2	2
3212 #define AMA_USBSS_BBONLY	3
3213
3214+/*
3215+ * VPD VDO
3216+ * ---------
3217+ * <31:28> :: HW version
3218+ * <27:24> :: FW version
3219+ * <23:21> :: VDO version
3220+ * <20:17> :: Reserved, Shall be set to zero
3221+ * <16:15> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V)
3222+ * <14>    :: Charge through current support (0b == 3A, 1b == 5A)
3223+ * <13>    :: Reserved, Shall be set to zero
3224+ * <12:7>  :: Vbus impedance
3225+ * <6:1>   :: Ground impedance
3226+ * <0>     :: Charge through support (0b == no, 1b == yes)
3227+ */
3228+#define VPD_VDO_VER1_0		0
3229+#define VPD_MAX_VBUS_20V	0
3230+#define VPD_MAX_VBUS_30V	1
3231+#define VPD_MAX_VBUS_40V	2
3232+#define VPD_MAX_VBUS_50V	3
3233+#define VPDCT_CURR_3A		0
3234+#define VPDCT_CURR_5A		1
3235+#define VPDCT_NOT_SUPP		0
3236+#define VPDCT_SUPP		1
3237+
3238+#define VDO_VPD(hw, fw, ver, vbm, curr, vbi, gi, ct)			\
3239+	(((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21	\
3240+	 | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7	\
3241+	 | ((gi) & 0x3f) << 1 | (ct))
3242+
3243 /*
3244  * SVDM Discover SVIDs request -> response
3245  *
3246diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
3247index 5e4c497f5..6567f7445 100644
3248--- a/include/linux/usb/quirks.h
3249+++ b/include/linux/usb/quirks.h
3250@@ -72,4 +72,7 @@
3251 /* device has endpoints that should be ignored */
3252 #define USB_QUIRK_ENDPOINT_IGNORE		BIT(15)
3253
3254+/* device can't support auto suspend function */
3255+#define USB_QUIRK_AUTO_SUSPEND			BIT(16)
3256+
3257 #endif /* __LINUX_USB_QUIRKS_H */
3258diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
3259index 09762d26f..cb69546f8 100644
3260--- a/include/linux/usb/tcpm.h
3261+++ b/include/linux/usb/tcpm.h
3262@@ -19,6 +19,10 @@ enum typec_cc_status {
3263 	TYPEC_CC_RP_3_0,
3264 };
3265
3266+/* Collision Avoidance */
3267+#define SINK_TX_NG	TYPEC_CC_RP_1_5
3268+#define SINK_TX_OK	TYPEC_CC_RP_3_0
3269+
3270 enum typec_cc_polarity {
3271 	TYPEC_POLARITY_CC1,
3272 	TYPEC_POLARITY_CC2,
3273@@ -62,6 +66,8 @@ enum tcpm_transmit_type {
3274  *		For example, some tcpcs may include BC1.2 charger detection
3275  *		and use that in this case.
3276  * @set_cc:	Called to set value of CC pins
3277+ * @apply_rc:	Optional; Needed to move TCPCI based chipset to APPLY_RC state
3278+ *		as stated by the TCPCI specification.
3279  * @get_cc:	Called to read current CC pin values
3280  * @set_polarity:
3281  *		Called to set polarity
3282@@ -83,6 +89,39 @@ enum tcpm_transmit_type {
3283  *		Optional; Called to enable/disable PD 3.0 fast role swap.
3284  *		Enabling frs is accessory dependent as not all PD3.0
3285  *		accessories support fast role swap.
3286+ * @frs_sourcing_vbus:
3287+ *		Optional; Called to notify that vbus is now being sourced.
3288+ *		Low level drivers can perform chip specific operations, if any.
3289+ * @enable_auto_vbus_discharge:
3290+ *		Optional; TCPCI spec based TCPC implementations can optionally
3291+ *		support hardware to autonomously dischrge vbus upon disconnecting
3292+ *		as sink or source. TCPM signals TCPC to enable the mechanism upon
3293+ *		entering connected state and signals disabling upon disconnect.
3294+ * @set_auto_vbus_discharge_threshold:
3295+ *		Mandatory when enable_auto_vbus_discharge is implemented. TCPM
3296+ *		calls this function to allow lower levels drivers to program the
3297+ *		vbus threshold voltage below which the vbus discharge circuit
3298+ *		will be turned on. requested_vbus_voltage is set to 0 when vbus
3299+ *		is going to disappear knowingly i.e. during PR_SWAP and
3300+ *		HARD_RESET etc.
3301+ * @is_vbus_vsafe0v:
3302+ *		Optional; TCPCI spec based TCPC implementations are expected to
3303+ *		detect VSAFE0V voltage level at vbus. When detection of VSAFE0V
3304+ *		is supported by TCPC, set this callback for TCPM to query
3305+ *		whether vbus is at VSAFE0V when needed.
3306+ *		Returns true when vbus is at VSAFE0V, false otherwise.
3307+ * @set_partner_usb_comm_capable:
3308+ *              Optional; The USB Communications Capable bit indicates if port
3309+ *              partner is capable of communication over the USB data lines
3310+ *              (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit.
3311+ * @check_contaminant:
3312+ *		Optional; The callback is called when CC pins report open status
3313+ *		at the end of the toggling period. Chip level drivers are
3314+ *		expected to check for contaminant and re-enable toggling if
3315+ *		needed. When 0 is not returned, check_contaminant is expected to
3316+ *		restart toggling after checking the connector for contaminant.
3317+ *		This forces the TCPM state machine to tranistion to TOGGLING state
3318+ *		without calling start_toggling callback.
3319  */
3320 struct tcpc_dev {
3321 	struct fwnode_handle *fwnode;
3322@@ -91,6 +130,8 @@ struct tcpc_dev {
3323 	int (*get_vbus)(struct tcpc_dev *dev);
3324 	int (*get_current_limit)(struct tcpc_dev *dev);
3325 	int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc);
3326+	int (*apply_rc)(struct tcpc_dev *dev, enum typec_cc_status cc,
3327+			enum typec_cc_polarity polarity);
3328 	int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1,
3329 		      enum typec_cc_status *cc2);
3330 	int (*set_polarity)(struct tcpc_dev *dev,
3331@@ -106,9 +147,16 @@ struct tcpc_dev {
3332 			      enum typec_cc_status cc);
3333 	int (*try_role)(struct tcpc_dev *dev, int role);
3334 	int (*pd_transmit)(struct tcpc_dev *dev, enum tcpm_transmit_type type,
3335-			   const struct pd_message *msg);
3336+			   const struct pd_message *msg, unsigned int negotiated_rev);
3337 	int (*set_bist_data)(struct tcpc_dev *dev, bool on);
3338 	int (*enable_frs)(struct tcpc_dev *dev, bool enable);
3339+	void (*frs_sourcing_vbus)(struct tcpc_dev *dev);
3340+	int (*enable_auto_vbus_discharge)(struct tcpc_dev *dev, bool enable);
3341+	int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev, enum typec_pwr_opmode mode,
3342+						 bool pps_active, u32 requested_vbus_voltage);
3343+	int (*check_contaminant)(struct tcpc_dev *dev);
3344+	bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev);
3345+	void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable);
3346 };
3347
3348 struct tcpm_port;
3349@@ -116,6 +164,10 @@ struct tcpm_port;
3350 struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc);
3351 void tcpm_unregister_port(struct tcpm_port *port);
3352
3353+int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
3354+				  unsigned int nr_pdo,
3355+				  unsigned int operating_snk_mw);
3356+
3357 void tcpm_vbus_change(struct tcpm_port *port);
3358 void tcpm_cc_change(struct tcpm_port *port);
3359 void tcpm_sink_frs(struct tcpm_port *port);
3360@@ -126,5 +178,7 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
3361 			       enum tcpm_transmit_status status);
3362 void tcpm_pd_hard_reset(struct tcpm_port *port);
3363 void tcpm_tcpc_reset(struct tcpm_port *port);
3364+bool tcpm_is_debouncing(struct tcpm_port *tcpm);
3365+bool tcpm_is_toggling(struct tcpm_port *port);
3366
3367 #endif /* __LINUX_USB_TCPM_H */
3368diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
3369index 6be558045..91b4303ca 100644
3370--- a/include/linux/usb/typec.h
3371+++ b/include/linux/usb/typec.h
3372@@ -126,9 +126,12 @@ struct typec_altmode_desc {
3373 	enum typec_port_data	roles;
3374 };
3375
3376+void typec_partner_set_pd_revision(struct typec_partner *partner, u16 pd_revision);
3377+int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmodes);
3378 struct typec_altmode
3379 *typec_partner_register_altmode(struct typec_partner *partner,
3380 				const struct typec_altmode_desc *desc);
3381+int typec_plug_set_num_altmodes(struct typec_plug *plug, int num_altmodes);
3382 struct typec_altmode
3383 *typec_plug_register_altmode(struct typec_plug *plug,
3384 			     const struct typec_altmode_desc *desc);
3385@@ -162,6 +165,7 @@ struct typec_plug_desc {
3386  * @type: The plug type from USB PD Cable VDO
3387  * @active: Is the cable active or passive
3388  * @identity: Result of Discover Identity command
3389+ * @pd_revision: USB Power Delivery Specification revision if supported
3390  *
3391  * Represents USB Type-C Cable attached to USB Type-C port.
3392  */
3393@@ -169,6 +173,8 @@ struct typec_cable_desc {
3394 	enum typec_plug_type	type;
3395 	unsigned int		active:1;
3396 	struct usb_pd_identity	*identity;
3397+	u16			pd_revision; /* 0300H = "3.0" */
3398+
3399 };
3400
3401 /*
3402@@ -176,15 +182,22 @@ struct typec_cable_desc {
3403  * @usb_pd: USB Power Delivery support
3404  * @accessory: Audio, Debug or none.
3405  * @identity: Discover Identity command data
3406+ * @pd_revision: USB Power Delivery Specification Revision if supported
3407  *
3408  * Details about a partner that is attached to USB Type-C port. If @identity
3409  * member exists when partner is registered, a directory named "identity" is
3410  * created to sysfs for the partner device.
3411+ *
3412+ * @pd_revision is based on the setting of the "Specification Revision" field
3413+ * in the message header on the initial "Source Capabilities" message received
3414+ * from the partner, or a "Request" message received from the partner, depending
3415+ * on whether our port is a Sink or a Source.
3416  */
3417 struct typec_partner_desc {
3418 	unsigned int		usb_pd:1;
3419 	enum typec_accessory	accessory;
3420 	struct usb_pd_identity	*identity;
3421+	u16			pd_revision; /* 0300H = "3.0" */
3422 };
3423
3424 /**
3425@@ -204,12 +217,19 @@ struct typec_operations {
3426 			     enum typec_port_type type);
3427 };
3428
3429+enum usb_pd_svdm_ver {
3430+	SVDM_VER_1_0 = 0,
3431+	SVDM_VER_2_0 = 1,
3432+	SVDM_VER_MAX = SVDM_VER_2_0,
3433+};
3434+
3435 /*
3436  * struct typec_capability - USB Type-C Port Capabilities
3437  * @type: Supported power role of the port
3438  * @data: Supported data role of the port
3439  * @revision: USB Type-C Specification release. Binary coded decimal
3440  * @pd_revision: USB Power Delivery Specification revision if supported
3441+ * @svdm_version: USB PD Structured VDM version if supported
3442  * @prefer_role: Initial role preference (DRP ports).
3443  * @accessory: Supported Accessory Modes
3444  * @fwnode: Optional fwnode of the port
3445@@ -223,6 +243,7 @@ struct typec_capability {
3446 	enum typec_port_data	data;
3447 	u16			revision; /* 0120H = "1.2" */
3448 	u16			pd_revision; /* 0300H = "3.0" */
3449+	enum usb_pd_svdm_ver	svdm_version;
3450 	int			prefer_role;
3451 	enum typec_accessory	accessory[TYPEC_MAX_ACCESSORY];
3452 	unsigned int		orientation_aware:1;
3453@@ -273,4 +294,8 @@ int typec_find_orientation(const char *name);
3454 int typec_find_port_power_role(const char *name);
3455 int typec_find_power_role(const char *name);
3456 int typec_find_port_data_role(const char *name);
3457+
3458+void typec_partner_set_svdm_version(struct typec_partner *partner,
3459+				    enum usb_pd_svdm_ver svdm_version);
3460+int typec_get_negotiated_svdm_version(struct typec_port *port);
3461 #endif /* __LINUX_USB_TYPEC_H */
3462diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h
3463index 5e0a7b764..65933cbe9 100644
3464--- a/include/linux/usb/typec_altmode.h
3465+++ b/include/linux/usb/typec_altmode.h
3466@@ -132,6 +132,16 @@ typec_altmode_get_orientation(struct typec_altmode *altmode)
3467 	return typec_get_orientation(typec_altmode2port(altmode));
3468 }
3469
3470+/**
3471+ * typec_altmode_get_svdm_version - Get negotiated SVDM version
3472+ * @altmode: Handle to the alternate mode
3473+ */
3474+static inline int
3475+typec_altmode_get_svdm_version(struct typec_altmode *altmode)
3476+{
3477+	return typec_get_negotiated_svdm_version(typec_altmode2port(altmode));
3478+}
3479+
3480 /**
3481  * struct typec_altmode_driver - USB Type-C alternate mode device driver
3482  * @id_table: Null terminated array of SVIDs
3483diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
3484index 47c2d501d..63dd44b72 100644
3485--- a/include/linux/usb/typec_tbt.h
3486+++ b/include/linux/usb/typec_tbt.h
3487@@ -39,12 +39,16 @@ struct typec_thunderbolt_data {
3488 #define   TBT_CABLE_USB3_GEN1		1
3489 #define   TBT_CABLE_USB3_PASSIVE	2
3490 #define   TBT_CABLE_10_AND_20GBPS	3
3491-#define TBT_CABLE_ROUNDED		BIT(19)
3492+#define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) \
3493+					(((_vdo_) & GENMASK(20, 19)) >> 19)
3494+#define   TBT_GEN3_NON_ROUNDED                 0
3495+#define   TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED    1
3496 #define TBT_CABLE_OPTICAL		BIT(21)
3497 #define TBT_CABLE_RETIMER		BIT(22)
3498 #define TBT_CABLE_LINK_TRAINING		BIT(23)
3499
3500 #define TBT_SET_CABLE_SPEED(_s_)	(((_s_) & GENMASK(2, 0)) << 16)
3501+#define TBT_SET_CABLE_ROUNDED(_g_)	(((_g_) & GENMASK(1, 0)) << 19)
3502
3503 /* TBT3 Device Enter Mode VDO bits */
3504 #define TBT_ENTER_MODE_CABLE_SPEED(s)	TBT_SET_CABLE_SPEED(s)
3505diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
3506index 8110c29fa..2e4f7721f 100644
3507--- a/include/linux/usb/usbnet.h
3508+++ b/include/linux/usb/usbnet.h
3509@@ -83,8 +83,6 @@ struct usbnet {
3510 #		define EVENT_LINK_CHANGE	11
3511 #		define EVENT_SET_RX_MODE	12
3512 #		define EVENT_NO_IP_ALIGN	13
3513-	u32			rx_speed;	/* in bps - NOT Mbps */
3514-	u32			tx_speed;	/* in bps - NOT Mbps */
3515 };
3516
3517 static inline struct usb_driver *driver_of(struct usb_interface *intf)
3518diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
3519index 92cd9f038..03b43b0f7 100644
3520--- a/include/media/v4l2-async.h
3521+++ b/include/media/v4l2-async.h
3522@@ -266,6 +266,21 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
3523 int v4l2_async_subdev_notifier_register(struct v4l2_subdev *sd,
3524 					struct v4l2_async_notifier *notifier);
3525
3526+/**
3527+ * v4l2_async_notifier_clr_unready_dev - remove unready subdevice
3528+ *
3529+ * @notifier: pointer to &struct v4l2_async_notifier
3530+ */
3531+#if IS_ENABLED(CONFIG_NO_GKI)
3532+int v4l2_async_notifier_clr_unready_dev(struct v4l2_async_notifier *notifier);
3533+#else
3534+static inline int
3535+v4l2_async_notifier_clr_unready_dev(struct v4l2_async_notifier *notifier)
3536+{
3537+	return 0;
3538+}
3539+#endif
3540+
3541 /**
3542  * v4l2_async_notifier_unregister - unregisters a subdevice
3543  *	asynchronous notifier
3544diff --git a/include/soc/rockchip/rockchip_sip.h b/include/soc/rockchip/rockchip_sip.h
3545index c46a9ae2a..4afba01c6 100644
3546--- a/include/soc/rockchip/rockchip_sip.h
3547+++ b/include/soc/rockchip/rockchip_sip.h
3548@@ -15,6 +15,12 @@
3549 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_RATE	0x05
3550 #define ROCKCHIP_SIP_CONFIG_DRAM_CLR_IRQ	0x06
3551 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_PARAM	0x07
3552-#define ROCKCHIP_SIP_CONFIG_DRAM_SET_ODT_PD	0x08
3553+#define ROCKCHIP_SIP_CONFIG_DRAM_GET_VERSION	0x08
3554+#define ROCKCHIP_SIP_CONFIG_DRAM_POST_SET_RATE	0x09
3555+#define ROCKCHIP_SIP_CONFIG_DRAM_SET_MSCH_RL	0x0a
3556+#define ROCKCHIP_SIP_CONFIG_DRAM_DEBUG		0x0b
3557+#define ROCKCHIP_SIP_CONFIG_MCU_START		0x0c
3558+#define ROCKCHIP_SIP_CONFIG_DRAM_GET_FREQ_INFO	0x0e
3559+#define ROCKCHIP_SIP_CONFIG_DRAM_ADDRMAP_GET	0x10
3560
3561 #endif
3562diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
3563index b55970859..4fc733c8c 100644
3564--- a/include/sound/hdmi-codec.h
3565+++ b/include/sound/hdmi-codec.h
3566@@ -34,6 +34,11 @@ struct hdmi_codec_daifmt {
3567 	unsigned int frame_clk_inv:1;
3568 	unsigned int bit_clk_master:1;
3569 	unsigned int frame_clk_master:1;
3570+	/* bit_fmt could be standard PCM format or
3571+	 * IEC958 encoded format. ALSA IEC958 plugin will pass
3572+	 * IEC958_SUBFRAME format to the underneath driver.
3573+	 */
3574+	snd_pcm_format_t bit_fmt;
3575 };
3576
3577 /*
3578@@ -60,12 +65,22 @@ struct hdmi_codec_ops {
3579
3580 	/*
3581 	 * Configures HDMI-encoder for audio stream.
3582-	 * Mandatory
3583+	 * Having either prepare or hw_params is mandatory.
3584 	 */
3585 	int (*hw_params)(struct device *dev, void *data,
3586 			 struct hdmi_codec_daifmt *fmt,
3587 			 struct hdmi_codec_params *hparms);
3588
3589+	/*
3590+	 * Configures HDMI-encoder for audio stream. Can be called
3591+	 * multiple times for each setup.
3592+	 *
3593+	 * Having either prepare or hw_params is mandatory.
3594+	 */
3595+	int (*prepare)(struct device *dev, void *data,
3596+		       struct hdmi_codec_daifmt *fmt,
3597+		       struct hdmi_codec_params *hparms);
3598+
3599 	/*
3600 	 * Shuts down the audio stream.
3601 	 * Mandatory
3602diff --git a/include/trace/events/cpuhp.h b/include/trace/events/cpuhp.h
3603index ad16f7731..f302ab6db 100644
3604--- a/include/trace/events/cpuhp.h
3605+++ b/include/trace/events/cpuhp.h
3606@@ -89,6 +89,28 @@ TRACE_EVENT(cpuhp_exit,
3607 		  __entry->cpu, __entry->state, __entry->idx,  __entry->ret)
3608 );
3609
3610+TRACE_EVENT(cpuhp_pause,
3611+	TP_PROTO(struct cpumask *cpus, u64 start_time, unsigned char pause),
3612+
3613+	TP_ARGS(cpus, start_time, pause),
3614+
3615+	TP_STRUCT__entry(
3616+		__field( unsigned int,	cpus		)
3617+		__field( unsigned int,	active_cpus	)
3618+		__field( unsigned int,	time		)
3619+		__field( unsigned char,	pause		)
3620+	),
3621+
3622+	TP_fast_assign(
3623+		__entry->cpus	     = cpumask_bits(cpus)[0];
3624+		__entry->active_cpus = cpumask_bits(cpu_active_mask)[0];
3625+		__entry->time        = div64_u64(sched_clock() - start_time, 1000);
3626+		__entry->pause	     = pause;
3627+	),
3628+
3629+	TP_printk("req_cpus=0x%x act_cpus=0x%x time=%u us paused=%d",
3630+		  __entry->cpus, __entry->active_cpus, __entry->time, __entry->pause)
3631+);
3632 #endif
3633
3634 /* This part must be outside protection */
3635diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
3636index dd5fff2bb..6c6a23b4b 100644
3637--- a/include/trace/events/sched.h
3638+++ b/include/trace/events/sched.h
3639@@ -203,6 +203,7 @@ TRACE_EVENT(sched_migrate_task,
3640 		__field(	int,	prio			)
3641 		__field(	int,	orig_cpu		)
3642 		__field(	int,	dest_cpu		)
3643+		__field(	int,	running			)
3644 	),
3645
3646 	TP_fast_assign(
3647@@ -211,11 +212,13 @@ TRACE_EVENT(sched_migrate_task,
3648 		__entry->prio		= p->prio; /* XXX SCHED_DEADLINE */
3649 		__entry->orig_cpu	= task_cpu(p);
3650 		__entry->dest_cpu	= dest_cpu;
3651+		__entry->running	= (p->state == TASK_RUNNING);
3652 	),
3653
3654-	TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d",
3655+	TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d running=%d",
3656 		  __entry->comm, __entry->pid, __entry->prio,
3657-		  __entry->orig_cpu, __entry->dest_cpu)
3658+		  __entry->orig_cpu, __entry->dest_cpu,
3659+		  __entry->running)
3660 );
3661
3662 DECLARE_EVENT_CLASS(sched_process_template,
3663diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
3664index 5498d7a65..5b5db0381 100644
3665--- a/include/uapi/drm/drm_fourcc.h
3666+++ b/include/uapi/drm/drm_fourcc.h
3667@@ -242,6 +242,8 @@ extern "C" {
3668  * index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian
3669  */
3670 #define DRM_FORMAT_NV15		fourcc_code('N', 'V', '1', '5') /* 2x2 subsampled Cr:Cb plane */
3671+#define DRM_FORMAT_NV20		fourcc_code('N', 'V', '2', '0') /* 2x1 subsampled Cr:Cb plane */
3672+#define DRM_FORMAT_NV30		fourcc_code('N', 'V', '3', '0') /* non-subsampled Cr:Cb plane */
3673
3674 /*
3675  * 2 plane YCbCr MSB aligned
3676diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h
3677index 84fa53ffb..096f891d4 100644
3678--- a/include/uapi/linux/media-bus-format.h
3679+++ b/include/uapi/linux/media-bus-format.h
3680@@ -34,7 +34,7 @@
3681
3682 #define MEDIA_BUS_FMT_FIXED			0x0001
3683
3684-/* RGB - next is	0x101d */
3685+/* RGB - next is	0x1024 */
3686 #define MEDIA_BUS_FMT_RGB444_1X12		0x1016
3687 #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE	0x1001
3688 #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE	0x1002
3689@@ -63,6 +63,10 @@
3690 #define MEDIA_BUS_FMT_RGB101010_1X30		0x1018
3691 #define MEDIA_BUS_FMT_RGB121212_1X36		0x1019
3692 #define MEDIA_BUS_FMT_RGB161616_1X48		0x101a
3693+#define MEDIA_BUS_FMT_RGB888_DUMMY_4X8		0x101f
3694+#define MEDIA_BUS_FMT_BGR888_DUMMY_4X8		0x1020
3695+#define MEDIA_BUS_FMT_RGB101010_1X7X5_SPWG	0x1022
3696+#define MEDIA_BUS_FMT_RGB101010_1X7X5_JEIDA	0x1023
3697
3698 /* YUV (including grey) - next is	0x202e */
3699 #define MEDIA_BUS_FMT_Y8_1X8			0x2001
3700diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_reg.h
3701index f51bc8f36..7e3fe68af 100644
3702--- a/include/uapi/linux/serial_reg.h
3703+++ b/include/uapi/linux/serial_reg.h
3704@@ -30,6 +30,7 @@
3705  * Sleep mode for ST16650 and TI16750.  For the ST16650, EFR[4]=1
3706  */
3707 #define UART_IERX_SLEEP		0x10 /* Enable sleep mode */
3708+#define UART_IER_PTIME		0x80 /* Enable programmable transmit interrupt mode */
3709
3710 #define UART_IIR	2	/* In:  Interrupt ID Register */
3711 #define UART_IIR_NO_INT		0x01 /* No interrupts pending */
3712diff --git a/include/uapi/linux/usb/f_accessory.h b/include/uapi/linux/usb/f_accessory.h
3713new file mode 100644
3714index 000000000..0baeb7d0d
3715--- /dev/null
3716+++ b/include/uapi/linux/usb/f_accessory.h
3717@@ -0,0 +1,146 @@
3718+/*
3719+ * Gadget Function Driver for Android USB accessories
3720+ *
3721+ * Copyright (C) 2011 Google, Inc.
3722+ * Author: Mike Lockwood <lockwood@android.com>
3723+ *
3724+ * This software is licensed under the terms of the GNU General Public
3725+ * License version 2, as published by the Free Software Foundation, and
3726+ * may be copied, distributed, and modified under those terms.
3727+ *
3728+ * This program is distributed in the hope that it will be useful,
3729+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3730+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3731+ * GNU General Public License for more details.
3732+ *
3733+ */
3734+
3735+#ifndef _UAPI_LINUX_USB_F_ACCESSORY_H
3736+#define _UAPI_LINUX_USB_F_ACCESSORY_H
3737+
3738+/* Use Google Vendor ID when in accessory mode */
3739+#define USB_ACCESSORY_VENDOR_ID 0x18D1
3740+
3741+
3742+/* Product ID to use when in accessory mode */
3743+#define USB_ACCESSORY_PRODUCT_ID 0x2D00
3744+
3745+/* Product ID to use when in accessory mode and adb is enabled */
3746+#define USB_ACCESSORY_ADB_PRODUCT_ID 0x2D01
3747+
3748+/* Indexes for strings sent by the host via ACCESSORY_SEND_STRING */
3749+#define ACCESSORY_STRING_MANUFACTURER   0
3750+#define ACCESSORY_STRING_MODEL          1
3751+#define ACCESSORY_STRING_DESCRIPTION    2
3752+#define ACCESSORY_STRING_VERSION        3
3753+#define ACCESSORY_STRING_URI            4
3754+#define ACCESSORY_STRING_SERIAL         5
3755+
3756+/* Control request for retrieving device's protocol version
3757+ *
3758+ *	requestType:    USB_DIR_IN | USB_TYPE_VENDOR
3759+ *	request:        ACCESSORY_GET_PROTOCOL
3760+ *	value:          0
3761+ *	index:          0
3762+ *	data            version number (16 bits little endian)
3763+ *                     1 for original accessory support
3764+ *                     2 adds HID and device to host audio support
3765+ */
3766+#define ACCESSORY_GET_PROTOCOL  51
3767+
3768+/* Control request for host to send a string to the device
3769+ *
3770+ *	requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
3771+ *	request:        ACCESSORY_SEND_STRING
3772+ *	value:          0
3773+ *	index:          string ID
3774+ *	data            zero terminated UTF8 string
3775+ *
3776+ *  The device can later retrieve these strings via the
3777+ *  ACCESSORY_GET_STRING_* ioctls
3778+ */
3779+#define ACCESSORY_SEND_STRING   52
3780+
3781+/* Control request for starting device in accessory mode.
3782+ * The host sends this after setting all its strings to the device.
3783+ *
3784+ *	requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
3785+ *	request:        ACCESSORY_START
3786+ *	value:          0
3787+ *	index:          0
3788+ *	data            none
3789+ */
3790+#define ACCESSORY_START         53
3791+
3792+/* Control request for registering a HID device.
3793+ * Upon registering, a unique ID is sent by the accessory in the
3794+ * value parameter. This ID will be used for future commands for
3795+ * the device
3796+ *
3797+ *	requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
3798+ *	request:        ACCESSORY_REGISTER_HID_DEVICE
3799+ *	value:          Accessory assigned ID for the HID device
3800+ *	index:          total length of the HID report descriptor
3801+ *	data            none
3802+ */
3803+#define ACCESSORY_REGISTER_HID         54
3804+
3805+/* Control request for unregistering a HID device.
3806+ *
3807+ *	requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
3808+ *	request:        ACCESSORY_REGISTER_HID
3809+ *	value:          Accessory assigned ID for the HID device
3810+ *	index:          0
3811+ *	data            none
3812+ */
3813+#define ACCESSORY_UNREGISTER_HID         55
3814+
3815+/* Control request for sending the HID report descriptor.
3816+ * If the HID descriptor is longer than the endpoint zero max packet size,
3817+ * the descriptor will be sent in multiple ACCESSORY_SET_HID_REPORT_DESC
3818+ * commands. The data for the descriptor must be sent sequentially
3819+ * if multiple packets are needed.
3820+ *
3821+ *	requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
3822+ *	request:        ACCESSORY_SET_HID_REPORT_DESC
3823+ *	value:          Accessory assigned ID for the HID device
3824+ *	index:          offset of data in descriptor
3825+ *                      (needed when HID descriptor is too big for one packet)
3826+ *	data            the HID report descriptor
3827+ */
3828+#define ACCESSORY_SET_HID_REPORT_DESC         56
3829+
3830+/* Control request for sending HID events.
3831+ *
3832+ *	requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
3833+ *	request:        ACCESSORY_SEND_HID_EVENT
3834+ *	value:          Accessory assigned ID for the HID device
3835+ *	index:          0
3836+ *	data            the HID report for the event
3837+ */
3838+#define ACCESSORY_SEND_HID_EVENT         57
3839+
3840+/* Control request for setting the audio mode.
3841+ *
3842+ *	requestType:	USB_DIR_OUT | USB_TYPE_VENDOR
3843+ *	request:        ACCESSORY_SET_AUDIO_MODE
3844+ *	value:          0 - no audio
3845+ *                     1 - device to host, 44100 16-bit stereo PCM
3846+ *	index:          0
3847+ *	data            none
3848+ */
3849+#define ACCESSORY_SET_AUDIO_MODE         58
3850+
3851+/* ioctls for retrieving strings set by the host */
3852+#define ACCESSORY_GET_STRING_MANUFACTURER   _IOW('M', 1, char[256])
3853+#define ACCESSORY_GET_STRING_MODEL          _IOW('M', 2, char[256])
3854+#define ACCESSORY_GET_STRING_DESCRIPTION    _IOW('M', 3, char[256])
3855+#define ACCESSORY_GET_STRING_VERSION        _IOW('M', 4, char[256])
3856+#define ACCESSORY_GET_STRING_URI            _IOW('M', 5, char[256])
3857+#define ACCESSORY_GET_STRING_SERIAL         _IOW('M', 6, char[256])
3858+/* returns 1 if there is a start request pending */
3859+#define ACCESSORY_IS_START_REQUESTED        _IO('M', 7)
3860+/* returns audio mode (set via the ACCESSORY_SET_AUDIO_MODE control request) */
3861+#define ACCESSORY_GET_AUDIO_MODE            _IO('M', 8)
3862+
3863+#endif /* _UAPI_LINUX_USB_F_ACCESSORY_H */
3864diff --git a/include/uapi/linux/usb/g_uvc.h b/include/uapi/linux/usb/g_uvc.h
3865index 652f169a0..428926e35 100644
3866--- a/include/uapi/linux/usb/g_uvc.h
3867+++ b/include/uapi/linux/usb/g_uvc.h
3868@@ -19,7 +19,9 @@
3869 #define UVC_EVENT_STREAMOFF		(V4L2_EVENT_PRIVATE_START + 3)
3870 #define UVC_EVENT_SETUP			(V4L2_EVENT_PRIVATE_START + 4)
3871 #define UVC_EVENT_DATA			(V4L2_EVENT_PRIVATE_START + 5)
3872-#define UVC_EVENT_LAST			(V4L2_EVENT_PRIVATE_START + 5)
3873+#define UVC_EVENT_SUSPEND		(V4L2_EVENT_PRIVATE_START + 6)
3874+#define UVC_EVENT_RESUME		(V4L2_EVENT_PRIVATE_START + 7)
3875+#define UVC_EVENT_LAST			(V4L2_EVENT_PRIVATE_START + 7)
3876
3877 struct uvc_request_data {
3878 	__s32 length;
3879diff --git a/include/uapi/linux/usb/video.h b/include/uapi/linux/usb/video.h
3880index bfdae12cd..b82436fd9 100644
3881--- a/include/uapi/linux/usb/video.h
3882+++ b/include/uapi/linux/usb/video.h
3883@@ -567,5 +567,63 @@ struct UVC_FRAME_MJPEG(n) {				\
3884 	__le32 dwFrameInterval[n];			\
3885 } __attribute__ ((packed))
3886
3887+/* Frame Based Payload - 3.1.1. Frame Based Video Format Descriptor */
3888+struct uvc_format_framebased {
3889+	__u8  bLength;
3890+	__u8  bDescriptorType;
3891+	__u8  bDescriptorSubType;
3892+	__u8  bFormatIndex;
3893+	__u8  bNumFrameDescriptors;
3894+	__u8  guidFormat[16];
3895+	__u8  bBitsPerPixel;
3896+	__u8  bDefaultFrameIndex;
3897+	__u8  bAspectRatioX;
3898+	__u8  bAspectRatioY;
3899+	__u8  bmInterfaceFlags;
3900+	__u8  bCopyProtect;
3901+	__u8  bVariableSize;
3902+} __attribute__((__packed__));
3903+
3904+#define UVC_DT_FORMAT_FRAMEBASED_SIZE			28
3905+
3906+/* Frame Based Payload - 3.1.2. Frame Based Video Frame Descriptor */
3907+struct uvc_frame_framebased {
3908+	__u8  bLength;
3909+	__u8  bDescriptorType;
3910+	__u8  bDescriptorSubType;
3911+	__u8  bFrameIndex;
3912+	__u8  bmCapabilities;
3913+	__u16 wWidth;
3914+	__u16 wHeight;
3915+	__u32 dwMinBitRate;
3916+	__u32 dwMaxBitRate;
3917+	__u32 dwDefaultFrameInterval;
3918+	__u8  bFrameIntervalType;
3919+	__u32 dwBytesPerLine;
3920+	__u32 dwFrameInterval[];
3921+} __attribute__((__packed__));
3922+
3923+#define UVC_DT_FRAME_FRAMEBASED_SIZE(n)                        (26+4*(n))
3924+
3925+#define UVC_FRAME_FRAMEBASED(n) \
3926+	uvc_frame_framebased_##n
3927+
3928+#define DECLARE_UVC_FRAME_FRAMEBASED(n)		\
3929+struct UVC_FRAME_FRAMEBASED(n) {		\
3930+	__u8  bLength;				\
3931+	__u8  bDescriptorType;			\
3932+	__u8  bDescriptorSubType;		\
3933+	__u8  bFrameIndex;			\
3934+	__u8  bmCapabilities;			\
3935+	__u16 wWidth;				\
3936+	__u16 wHeight;				\
3937+	__u32 dwMinBitRate;			\
3938+	__u32 dwMaxBitRate;			\
3939+	__u32 dwDefaultFrameInterval;		\
3940+	__u8  bFrameIntervalType;		\
3941+	__u32 dwBytesPerLine;			\
3942+	__u32 dwFrameInterval[n];		\
3943+} __attribute__ ((packed))
3944+
3945 #endif /* __LINUX_USB_VIDEO_H */
3946
3947diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
3948index a184c4939..a3eb68372 100644
3949--- a/include/uapi/linux/v4l2-controls.h
3950+++ b/include/uapi/linux/v4l2-controls.h
3951@@ -188,6 +188,12 @@ enum v4l2_colorfx {
3952  */
3953 #define V4L2_CID_USER_MAX217X_BASE		(V4L2_CID_USER_BASE + 0x1090)
3954
3955+/*
3956+ * The base for the tc35874x driver controls.
3957+ * We reserve 16 controls for this driver.
3958+ */
3959+#define V4L2_CID_USER_TC35874X_BASE		(V4L2_CID_USER_BASE + 0x10a0)
3960+
3961 /* The base for the imx driver controls.
3962  * We reserve 16 controls for this driver. */
3963 #define V4L2_CID_USER_IMX_BASE			(V4L2_CID_USER_BASE + 0x10b0)
3964diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
3965index 534eaa4d3..eb01fb549 100644
3966--- a/include/uapi/linux/videodev2.h
3967+++ b/include/uapi/linux/videodev2.h
3968@@ -689,6 +689,7 @@ struct v4l2_pix_format {
3969 #define V4L2_PIX_FMT_JPEG     v4l2_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG     */
3970 #define V4L2_PIX_FMT_DV       v4l2_fourcc('d', 'v', 's', 'd') /* 1394          */
3971 #define V4L2_PIX_FMT_MPEG     v4l2_fourcc('M', 'P', 'E', 'G') /* MPEG-1/2/4 Multiplexed */
3972+#define V4L2_PIX_FMT_H265     v4l2_fourcc('H', '2', '6', '5') /* H265 with start codes */
3973 #define V4L2_PIX_FMT_H264     v4l2_fourcc('H', '2', '6', '4') /* H264 with start codes */
3974 #define V4L2_PIX_FMT_H264_NO_SC v4l2_fourcc('A', 'V', 'C', '1') /* H264 without start codes */
3975 #define V4L2_PIX_FMT_H264_MVC v4l2_fourcc('M', '2', '6', '4') /* H264 MVC */
3976