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

Commit cefe5d68 authored by Ajay Agarwal's avatar Ajay Agarwal
Browse files

phy: msm: usb: Support for mode switch based on PHY ID IRQ



Add support where user can specify using dtsi attribute to switch
target modes(host or peripheral) solely depending on PHY ID IRQ.
If PHY ID state is low, then enable host mode. If PHY ID state is
high, then enable peripheral mode.

Change-Id: I8b04760965a13dfb993c08453394bf5194c9bede
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
parent 45757987
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -189,6 +189,8 @@ Optional properties :
	point to external connector device, which provide "USB-HOST" cable events.
	A single phandle may be specified if a single connector device provides
	both "USB" and "USB-HOST" events.
- qcom,phy-id-high-as-peripheral: If present, specifies device to switch to device mode
	if PHY ID state is high or host mode if PHY ID state is low.

Example HSUSB OTG controller device node :
	usb@f9690000 {
+18 −2
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ struct msm_otg_platform_data {
	bool enable_streaming;
	bool enable_axi_prefetch;
	bool vbus_low_as_hostmode;
	bool phy_id_high_as_peripheral;
};

#define SDP_CHECK_DELAY_MS 10000 /* in ms */
@@ -2325,10 +2326,17 @@ static void msm_otg_init_sm(struct msm_otg *motg)
				else
					clear_bit(ID, &motg->inputs);
			} else if (motg->phy_irq) {
				if (msm_otg_read_phy_id_state(motg))
				if (msm_otg_read_phy_id_state(motg)) {
					set_bit(ID, &motg->inputs);
				else
					if (pdata->phy_id_high_as_peripheral)
						set_bit(B_SESS_VLD,
								&motg->inputs);
				} else {
					clear_bit(ID, &motg->inputs);
					if (pdata->phy_id_high_as_peripheral)
						clear_bit(B_SESS_VLD,
								&motg->inputs);
				}
			}
		}
		break;
@@ -2637,6 +2645,8 @@ static void msm_id_status_w(struct work_struct *w)
			gpio_direction_input(motg->pdata->switch_sel_gpio);
		if (!test_and_set_bit(ID, &motg->inputs)) {
			pr_debug("ID set\n");
			if (motg->pdata->phy_id_high_as_peripheral)
				set_bit(B_SESS_VLD, &motg->inputs);
			msm_otg_dbg_log_event(&motg->phy, "ID SET",
					motg->inputs, motg->phy.otg->state);
			work = 1;
@@ -2646,6 +2656,8 @@ static void msm_id_status_w(struct work_struct *w)
			gpio_direction_output(motg->pdata->switch_sel_gpio, 1);
		if (test_and_clear_bit(ID, &motg->inputs)) {
			pr_debug("ID clear\n");
			if (motg->pdata->phy_id_high_as_peripheral)
				clear_bit(B_SESS_VLD, &motg->inputs);
			msm_otg_dbg_log_event(&motg->phy, "ID CLEAR",
					motg->inputs, motg->phy.otg->state);
			work = 1;
@@ -3424,6 +3436,10 @@ struct msm_otg_platform_data *msm_otg_dt_to_pdata(struct platform_device *pdev)

	pdata->vbus_low_as_hostmode = of_property_read_bool(node,
					"qcom,vbus-low-as-hostmode");

	pdata->phy_id_high_as_peripheral = of_property_read_bool(node,
					"qcom,phy-id-high-as-peripheral");

	return pdata;
}