18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef _DP_HPD_H_
78c2ecf20Sopenharmony_ci#define _DP_HPD_H_
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci//#include <linux/usb/usbpd.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci#include <linux/device.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cienum plug_orientation {
158c2ecf20Sopenharmony_ci	ORIENTATION_NONE,
168c2ecf20Sopenharmony_ci	ORIENTATION_CC1,
178c2ecf20Sopenharmony_ci	ORIENTATION_CC2,
188c2ecf20Sopenharmony_ci};
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/**
218c2ecf20Sopenharmony_ci * struct dp_usbpd - DisplayPort status
228c2ecf20Sopenharmony_ci *
238c2ecf20Sopenharmony_ci * @orientation: plug orientation configuration
248c2ecf20Sopenharmony_ci * @low_pow_st: low power state
258c2ecf20Sopenharmony_ci * @adaptor_dp_en: adaptor functionality enabled
268c2ecf20Sopenharmony_ci * @multi_func: multi-function preferred
278c2ecf20Sopenharmony_ci * @usb_config_req: request to switch to usb
288c2ecf20Sopenharmony_ci * @exit_dp_mode: request exit from displayport mode
298c2ecf20Sopenharmony_ci * @hpd_high: Hot Plug Detect signal is high.
308c2ecf20Sopenharmony_ci * @hpd_irq: Change in the status since last message
318c2ecf20Sopenharmony_ci * @alt_mode_cfg_done: bool to specify alt mode status
328c2ecf20Sopenharmony_ci * @debug_en: bool to specify debug mode
338c2ecf20Sopenharmony_ci * @connect: simulate disconnect or connect for debug mode
348c2ecf20Sopenharmony_ci */
358c2ecf20Sopenharmony_cistruct dp_usbpd {
368c2ecf20Sopenharmony_ci	enum plug_orientation orientation;
378c2ecf20Sopenharmony_ci	bool low_pow_st;
388c2ecf20Sopenharmony_ci	bool adaptor_dp_en;
398c2ecf20Sopenharmony_ci	bool multi_func;
408c2ecf20Sopenharmony_ci	bool usb_config_req;
418c2ecf20Sopenharmony_ci	bool exit_dp_mode;
428c2ecf20Sopenharmony_ci	bool hpd_high;
438c2ecf20Sopenharmony_ci	bool hpd_irq;
448c2ecf20Sopenharmony_ci	bool alt_mode_cfg_done;
458c2ecf20Sopenharmony_ci	bool debug_en;
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	int (*connect)(struct dp_usbpd *dp_usbpd, bool hpd);
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/**
518c2ecf20Sopenharmony_ci * struct dp_usbpd_cb - callback functions provided by the client
528c2ecf20Sopenharmony_ci *
538c2ecf20Sopenharmony_ci * @configure: called by usbpd module when PD communication has
548c2ecf20Sopenharmony_ci * been completed and the usb peripheral has been configured on
558c2ecf20Sopenharmony_ci * dp mode.
568c2ecf20Sopenharmony_ci * @disconnect: notify the cable disconnect issued by usb.
578c2ecf20Sopenharmony_ci * @attention: notify any attention message issued by usb.
588c2ecf20Sopenharmony_ci */
598c2ecf20Sopenharmony_cistruct dp_usbpd_cb {
608c2ecf20Sopenharmony_ci	int (*configure)(struct device *dev);
618c2ecf20Sopenharmony_ci	int (*disconnect)(struct device *dev);
628c2ecf20Sopenharmony_ci	int (*attention)(struct device *dev);
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/**
668c2ecf20Sopenharmony_ci * dp_hpd_get() - setup hpd module
678c2ecf20Sopenharmony_ci *
688c2ecf20Sopenharmony_ci * @dev: device instance of the caller
698c2ecf20Sopenharmony_ci * @cb: struct containing callback function pointers.
708c2ecf20Sopenharmony_ci *
718c2ecf20Sopenharmony_ci * This function allows the client to initialize the usbpd
728c2ecf20Sopenharmony_ci * module. The module will communicate with HPD module.
738c2ecf20Sopenharmony_ci */
748c2ecf20Sopenharmony_cistruct dp_usbpd *dp_hpd_get(struct device *dev, struct dp_usbpd_cb *cb);
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ciint dp_hpd_register(struct dp_usbpd *dp_usbpd);
778c2ecf20Sopenharmony_civoid dp_hpd_unregister(struct dp_usbpd *dp_usbpd);
788c2ecf20Sopenharmony_ciint dp_hpd_connect(struct dp_usbpd *dp_usbpd, bool hpd);
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#endif /* _DP_HPD_H_ */
81