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

Commit 59337761 authored by Jack Pham's avatar Jack Pham
Browse files

misc: liquid_dock: Make dock_enable GPIO optional



The MSM8994 LiQUID docking station does not have a
pin for a dock_enable GPIO, as the USB and Ethernet
ports are always powered via the DC source. Make
this GPIO optional.

As the power to the hub and Ethernet ports may now
be always-on, also make sure to assert the reset lines
prior to adding the USB host controller. This way the
deassertion of the resets will happen after the USB
stack is fully initialized to kick off enumeration.

Change-Id: I864ebcfa94d58e741e7378db0c24fdc6220dc18f
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent f25bc4cd
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -11,10 +11,12 @@ Required properties:
	       also supported but deprecated.
	       also supported but deprecated.
 - qcom,dock-detect-gpio: phandle to a GPIO node corresponding to the input
 - qcom,dock-detect-gpio: phandle to a GPIO node corresponding to the input
                         signal indicating when the dock is connected
                         signal indicating when the dock is connected
 - qcom,dock-enable-gpio: phandle to a GPIO node corresponding to the output
                         signal that turns on/off power to the ports
 - qcom,dock-hub-reset-gpio: phandle to a GPIO node corresponding to the output
 - qcom,dock-hub-reset-gpio: phandle to a GPIO node corresponding to the output
                            signal that resets the USB ports
                            signal that resets the USB ports
 - qcom,dock-eth-reset-gpio: phandle to a GPIO node corresponding to the output
 - qcom,dock-eth-reset-gpio: phandle to a GPIO node corresponding to the output
                            signal that resets the Ethernet ports
                            signal that resets the Ethernet ports
 - qcom,usb-host: phandle to the USB host controller connected to the dock port
 - qcom,usb-host: phandle to the USB host controller connected to the dock port

Optional properties:
 - qcom,dock-enable-gpio: phandle to a GPIO node corresponding to the output
                         signal that turns on/off power to the ports
+16 −12
Original line number Original line Diff line number Diff line
@@ -76,18 +76,22 @@ static void dock_detected_work(struct work_struct *w)
	struct liquid_dock *dock = container_of(w, struct liquid_dock,
	struct liquid_dock *dock = container_of(w, struct liquid_dock,
						 dock_work);
						 dock_work);
	docked = gpio_get_value(dock->dock_detect);
	docked = gpio_get_value(dock->dock_detect);

	if (dock->dock_enable)
		gpio_direction_output(dock->dock_enable, 0);
		gpio_direction_output(dock->dock_enable, 0);


	if (docked) {
	if (docked) {
		/* assert RESETs before turning on power */
		gpio_direction_output(dock->dock_hub_reset, 1);
		gpio_direction_output(dock->dock_eth_reset, 1);

		if (device_attach(&dock->usb3_pdev->dev) != 1) {
		if (device_attach(&dock->usb3_pdev->dev) != 1) {
			dev_err(dock->dev, "Could not add USB driver 0x%p\n",
			dev_err(dock->dev, "Could not add USB driver 0x%p\n",
				dock->usb3_pdev);
				dock->usb3_pdev);
			return;
			return;
		}
		}


		/* assert RESETs before turning on power */
		if (dock->dock_enable)
		gpio_direction_output(dock->dock_hub_reset, 1);
		gpio_direction_output(dock->dock_eth_reset, 1);
			gpio_direction_output(dock->dock_enable, 1);
			gpio_direction_output(dock->dock_enable, 1);


		msleep(20); /* short delay before de-asserting RESETs */
		msleep(20); /* short delay before de-asserting RESETs */
@@ -170,14 +174,14 @@ static int liquid_dock_probe(struct platform_device *pdev)
		return ret;
		return ret;


	dock->dock_enable = of_get_named_gpio(node, "qcom,dock-enable-gpio", 0);
	dock->dock_enable = of_get_named_gpio(node, "qcom,dock-enable-gpio", 0);
	if (dock->dock_enable < 0) {
	if (dock->dock_enable < 0) { /* optional */
		dev_err(dock->dev, "unable to get dock-enable-gpio\n");
		dock->dock_enable = 0;
		return dock->dock_enable;
	} else {
	}
		ret = devm_gpio_request(dock->dev, dock->dock_enable,

					"dock_enable");
	ret = devm_gpio_request(dock->dev, dock->dock_enable, "dock_enable");
		if (ret)
		if (ret)
			return ret;
			return ret;
	}


	usb3_node = of_parse_phandle(node, "qcom,usb-host", 0);
	usb3_node = of_parse_phandle(node, "qcom,usb-host", 0);
	if (!usb3_node) {
	if (!usb3_node) {