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

Commit 2aa89ab3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ARM: dts: msm: add sink capabilities to PMI8998 PD PHY"

parents 674a9404 aacc57aa
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@ Optional properties:
- qcom,vconn-uses-external-source: Indicates whether VCONN supply is sourced
			from an external regulator. If omitted, then it is
			assumed it is connected to VBUS.
- qcom,default-sink-caps: List of 32-bit values representing the nominal sink
			capabilities in voltage (millivolts) and current
			(milliamps) pairs.

Example:
	qcom,qpnp-pdphy@1700 {
@@ -64,4 +67,8 @@ Example:
				  "msg-tx-failed",
				  "msg-tx-discarded",
				  "msg-rx-discarded";

		qcom,default-sink-caps = <5000 3000>, /* 5V @ 3A */
					 <9000 3000>, /* 9V @ 3A */
					 <12000 2250>; /* 12V @ 2.25A */
	};
+4 −0
Original line number Diff line number Diff line
@@ -290,6 +290,10 @@
					  "msg-tx-failed",
					  "msg-tx-discarded",
					  "msg-rx-discarded";

			qcom,default-sink-caps = <5000 3000>, /* 5V @ 3A */
						 <9000 3000>, /* 9V @ 3A */
						 <12000 2250>; /* 12V @ 2.25A */
		};

		bcl@4200 {
+50 −5
Original line number Diff line number Diff line
@@ -243,6 +243,10 @@ static void *usbpd_ipc_log;
#define MAX_VDM_RESPONSE_TIME	60 /* 2 * tVDMSenderResponse_max(30ms) */
#define MAX_VDM_BUSY_TIME	100 /* 2 * tVDMBusy (50ms) */

#define PD_SNK_PDO_FIXED(prs, hc, uc, usb_comm, drs, volt, curr) \
	(((prs) << 29) | ((hc) << 28) | ((uc) << 27) | ((usb_comm) << 26) | \
	 ((drs) << 25) | ((volt) << 10) | (curr))

/* VDM header is the first 32-bit object following the 16-bit PD header */
#define VDM_HDR_SVID(hdr)	((hdr) >> 16)
#define VDM_IS_SVDM(hdr)	((hdr) & 0x8000)
@@ -273,7 +277,7 @@ static int min_sink_current = 900;
module_param(min_sink_current, int, S_IRUSR | S_IWUSR);

static const u32 default_src_caps[] = { 0x36019096 };	/* VSafe5V @ 1.5A */
static const u32 default_snk_caps[] = { 0x2601905A };	/* 5V @ 900mA */
static const u32 default_snk_caps[] = { 0x2601912C };	/* VSafe5V @ 3A */

struct vdm_tx {
	u32			data[7];
@@ -318,6 +322,9 @@ struct usbpd {
	bool			peer_pr_swap;
	bool			peer_dr_swap;

	u32			sink_caps[7];
	int			num_sink_caps;

	struct power_supply	*usb_psy;
	struct notifier_block	psy_nb;

@@ -1718,8 +1725,8 @@ static void usbpd_sm(struct work_struct *w)
			}
		} else if (IS_CTRL(rx_msg, MSG_GET_SINK_CAP)) {
			ret = pd_send_msg(pd, MSG_SINK_CAPABILITIES,
					default_snk_caps,
					ARRAY_SIZE(default_snk_caps), SOP_MSG);
					pd->sink_caps, pd->num_sink_caps,
					SOP_MSG);
			if (ret) {
				usbpd_err(&pd->dev, "Error sending Sink Caps\n");
				usbpd_set_state(pd, PE_SRC_SEND_SOFT_RESET);
@@ -1996,8 +2003,8 @@ static void usbpd_sm(struct work_struct *w)
			usbpd_set_state(pd, PE_SNK_EVALUATE_CAPABILITY);
		} else if (IS_CTRL(rx_msg, MSG_GET_SINK_CAP)) {
			ret = pd_send_msg(pd, MSG_SINK_CAPABILITIES,
					default_snk_caps,
					ARRAY_SIZE(default_snk_caps), SOP_MSG);
					pd->sink_caps, pd->num_sink_caps,
					SOP_MSG);
			if (ret) {
				usbpd_err(&pd->dev, "Error sending Sink Caps\n");
				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
@@ -3157,6 +3164,44 @@ struct usbpd *usbpd_create(struct device *parent)
	pd->vconn_is_external = device_property_present(parent,
					"qcom,vconn-uses-external-source");

	pd->num_sink_caps = device_property_read_u32_array(parent,
			"qcom,default-sink-caps", NULL, 0);
	if (pd->num_sink_caps) {
		int i;
		u32 sink_caps[14];

		if (pd->num_sink_caps % 2 || pd->num_sink_caps > 14) {
			ret = -EINVAL;
			usbpd_err(&pd->dev, "default-sink-caps must be be specified as voltage/current, max 7 pairs\n");
			goto put_psy;
		}

		ret = device_property_read_u32_array(parent,
				"qcom,default-sink-caps", sink_caps,
				pd->num_sink_caps);
		if (ret) {
			usbpd_err(&pd->dev, "Error reading default-sink-caps\n");
			goto put_psy;
		}

		pd->num_sink_caps /= 2;

		for (i = 0; i < pd->num_sink_caps; i++) {
			int v = sink_caps[i * 2] / 50;
			int c = sink_caps[i * 2 + 1] / 10;

			pd->sink_caps[i] =
				PD_SNK_PDO_FIXED(0, 0, 0, 0, 0, v, c);
		}

		/* First PDO includes additional capabilities */
		pd->sink_caps[0] |= PD_SNK_PDO_FIXED(1, 0, 0, 1, 1, 0, 0);
	} else {
		memcpy(pd->sink_caps, default_snk_caps,
				sizeof(default_snk_caps));
		pd->num_sink_caps = ARRAY_SIZE(default_snk_caps);
	}

	/*
	 * Register the Android dual-role class (/sys/class/dual_role_usb/).
	 * The first instance should be named "otg_default" as that's what