Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ee58aff authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drm/msm/dp: support probe defer for the usbpd driver"

parents e954c53b 35e1b941
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ struct dp_display_private {
	atomic_t aborted;

	struct platform_device *pdev;
	struct usbpd *pd;
	struct device_node *aux_switch_node;
	struct dentry *root;
	struct completion notification_comp;
@@ -1388,7 +1389,7 @@ static int dp_init_sub_modules(struct dp_display_private *dp)
	cb->disconnect = dp_display_usbpd_disconnect_cb;
	cb->attention  = dp_display_usbpd_attention_cb;

	dp->hpd = dp_hpd_get(dev, dp->parser, &dp->catalog->hpd, cb);
	dp->hpd = dp_hpd_get(dev, dp->parser, &dp->catalog->hpd, dp->pd, cb);
	if (IS_ERR(dp->hpd)) {
		rc = PTR_ERR(dp->hpd);
		pr_err("failed to initialize hpd, rc = %d\n", rc);
@@ -2155,6 +2156,28 @@ static int dp_display_create_workqueue(struct dp_display_private *dp)
	return 0;
}

static int dp_display_usbpd_get(struct dp_display_private *dp)
{
	int rc = 0;
	char const *phandle = "qcom,dp-usbpd-detection";

	dp->pd = devm_usbpd_get_by_phandle(&dp->pdev->dev, phandle);
	if (IS_ERR(dp->pd)) {
		rc = PTR_ERR(dp->pd);

		/*
		 * If the pd handle is not present(if return is -ENXIO) then the
		 * platform might be using a direct hpd connection from sink.
		 * So, return success in this case.
		 */
		if (rc == -ENXIO)
			return 0;

		pr_err("usbpd phandle failed (%ld)\n", PTR_ERR(dp->pd));
	}
	return rc;
}

static int dp_display_fsa4480_callback(struct notifier_block *self,
		unsigned long event, void *data)
{
@@ -2610,6 +2633,10 @@ static int dp_display_probe(struct platform_device *pdev)
	memset(&dp->mst, 0, sizeof(dp->mst));
	atomic_set(&dp->aborted, 0);

	rc = dp_display_usbpd_get(dp);
	if (rc)
		goto error;

	rc = dp_display_init_aux_switch(dp);
	if (rc) {
		rc = -EPROBE_DEFER;
+4 −3
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ static void dp_hpd_isr(struct dp_hpd *dp_hpd)
}

struct dp_hpd *dp_hpd_get(struct device *dev, struct dp_parser *parser,
		struct dp_catalog_hpd *catalog, struct dp_hpd_cb *cb)
		struct dp_catalog_hpd *catalog, struct usbpd *pd,
		struct dp_hpd_cb *cb)
{
	struct dp_hpd *dp_hpd;

@@ -67,7 +68,7 @@ struct dp_hpd *dp_hpd_get(struct device *dev, struct dp_parser *parser,
		}
		dp_hpd->type = DP_HPD_GPIO;
	} else {
		dp_hpd = dp_usbpd_get(dev, cb);
		dp_hpd = dp_usbpd_init(dev, pd, cb);
		if (IS_ERR(dp_hpd)) {
			pr_err("failed to get usbpd\n");
			goto out;
@@ -93,7 +94,7 @@ void dp_hpd_put(struct dp_hpd *dp_hpd)

	switch (dp_hpd->type) {
	case DP_HPD_USBPD:
		dp_usbpd_put(dp_hpd);
		dp_usbpd_deinit(dp_hpd);
		break;
	case DP_HPD_GPIO:
		dp_gpio_hpd_put(dp_hpd);
+5 −2
Original line number Diff line number Diff line
@@ -87,14 +87,17 @@ struct dp_hpd {
 * dp_hpd_get() - configure and get the DisplayPlot HPD module data
 *
 * @dev: device instance of the caller
 * @parser: DP parser
 * @parser: pointer to DP parser module
 * @catalog: pointer to DP catalog module
 * @pd: handle for the ubspd driver data
 * @cb: callback function for HPD response
 * return: pointer to allocated hpd module data
 *
 * This function sets up the hpd module
 */
struct dp_hpd *dp_hpd_get(struct device *dev, struct dp_parser *parser,
		struct dp_catalog_hpd *catalog, struct dp_hpd_cb *cb);
		struct dp_catalog_hpd *catalog, struct usbpd *pd,
		struct dp_hpd_cb *cb);

/**
 * dp_hpd_put()
+5 −13
Original line number Diff line number Diff line
@@ -523,11 +523,10 @@ static void dp_usbpd_wakeup_phy(struct dp_hpd *dp_hpd, bool wakeup)
	usbpd_vdm_in_suspend(usbpd->pd, wakeup);
}

struct dp_hpd *dp_usbpd_get(struct device *dev, struct dp_hpd_cb *cb)
struct dp_hpd *dp_usbpd_init(struct device *dev, struct usbpd *pd,
		struct dp_hpd_cb *cb)
{
	int rc = 0;
	const char *pd_phandle = "qcom,dp-usbpd-detection";
	struct usbpd *pd = NULL;
	struct dp_usbpd_private *usbpd;
	struct dp_usbpd *dp_usbpd;
	struct usbpd_svid_handler svid_handler = {
@@ -538,19 +537,12 @@ struct dp_hpd *dp_usbpd_get(struct device *dev, struct dp_hpd_cb *cb)
		.disconnect	= &dp_usbpd_disconnect_cb,
	};

	if (!cb) {
		pr_err("invalid cb data\n");
	if (IS_ERR(pd) || !cb) {
		pr_err("invalid data\n");
		rc = -EINVAL;
		goto error;
	}

	pd = devm_usbpd_get_by_phandle(dev, pd_phandle);
	if (IS_ERR(pd)) {
		pr_err("usbpd phandle failed (%ld)\n", PTR_ERR(pd));
		rc = PTR_ERR(pd);
		goto error;
	}

	usbpd = devm_kzalloc(dev, sizeof(*usbpd), GFP_KERNEL);
	if (!usbpd) {
		rc = -ENOMEM;
@@ -573,7 +565,7 @@ struct dp_hpd *dp_usbpd_get(struct device *dev, struct dp_hpd_cb *cb)
	return ERR_PTR(rc);
}

void dp_usbpd_put(struct dp_hpd *dp_hpd)
void dp_usbpd_deinit(struct dp_hpd *dp_hpd)
{
	struct dp_usbpd *dp_usbpd;
	struct dp_usbpd_private *usbpd;
+13 −4
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -57,9 +57,10 @@ struct dp_usbpd {
};

/**
 * dp_usbpd_get() - setup usbpd module
 * dp_usbpd_init() - initialize the usbpd module
 *
 * @dev: device instance of the caller
 * @pd: handle for the usbpd driver data
 * @cb: struct containing callback function pointers.
 *
 * This function allows the client to initialize the usbpd
@@ -68,7 +69,15 @@ struct dp_usbpd {
 * sink/usb device. This module will notify the client using
 * the callback functions about the connection and status.
 */
struct dp_hpd *dp_usbpd_get(struct device *dev, struct dp_hpd_cb *cb);
struct dp_hpd *dp_usbpd_init(struct device *dev, struct usbpd *pd,
		struct dp_hpd_cb *cb);

void dp_usbpd_put(struct dp_hpd *pd);
/**
 * dp_usbpd_deinit() - deinitialize the usbpd module
 *
 * @pd: pointer to the dp_hpd base module
 *
 * This function will cleanup the usbpd module
 */
void dp_usbpd_deinit(struct dp_hpd *pd);
#endif /* _DP_USBPD_H_ */