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

Commit f292fa9f authored by Mayank Rana's avatar Mayank Rana
Browse files

USB: android: Add support to get usb-core-id using devicetree



Android gadget driver is binded with UDC using usb-core-id value.
This change adds support to pass usb-core-id value through devicetree.
This is useful where multiple USB cores are used in device mode
concurrently and it is required to bind each gadget driver with each
core specific UDC.

Change-Id: Iba22bfbccb4f2a87a9ea513e074694004523933e
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 43a3965c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ Optional properties :
  a new LUN as CD-ROM.
- qcom,android-usb-uicc-nluns : Number of mass storage LUNs (8 bits) required
  for the UICC card.
- qcom,usb-core-id: Index to refer USB hardware core to bind android gadget driver
  with UDC if multiple USB peripheral controllers are present. If unspecified,
  core is set to zero by default.
Example Android USB device node :
	android_usb@fc42b0c8 {
		compatible = "qcom,android-usb";
@@ -30,4 +33,5 @@ Example Android USB device node :
		qcom,android-usb-swfi-latency = <1>;
		qcom,streaming-func = "rndis","mtp";
		qcom,android-usb-uicc-nluns = /bits/ 8 <1>;
		qcom,usb-core-id = <1>;
	};
+13 −4
Original line number Diff line number Diff line
@@ -3444,6 +3444,7 @@ static int android_create_device(struct android_dev *dev, u8 usb_core_id)
	 */
	snprintf(device_node_name, ANDROID_DEVICE_NODE_NAME_LENGTH,
		 "android%d", usb_core_id);
	pr_debug("%s(): creating android%d device\n", __func__, usb_core_id);
	dev->dev = device_create(android_class, NULL,
					MKDEV(0, 0), NULL, device_node_name);
	if (IS_ERR(dev->dev))
@@ -3560,6 +3561,7 @@ static int android_probe(struct platform_device *pdev)
	struct android_dev *android_dev;
	struct resource *res;
	int ret = 0, i, len = 0;
	u32 usb_core_id = 0;

	if (pdev->dev.of_node) {
		dev_dbg(&pdev->dev, "device tree enabled\n");
@@ -3572,6 +3574,11 @@ static int android_probe(struct platform_device *pdev)
		of_property_read_u32(pdev->dev.of_node,
				"qcom,android-usb-swfi-latency",
				&pdata->swfi_latency);
		ret = of_property_read_u32(pdev->dev.of_node,
					"qcom,usb-core-id",
					&usb_core_id);
		if (!ret)
			pdata->usb_core_id = usb_core_id;

		len = of_property_count_strings(pdev->dev.of_node,
				"qcom,streaming-func");
@@ -3652,15 +3659,17 @@ static int android_probe(struct platform_device *pdev)
	}

	if (pdata)
		ret = android_create_device(android_dev, pdata->usb_core_id);
	else
		ret = android_create_device(android_dev, 0);

		android_usb_driver.gadget_driver.usb_core_id =
						pdata->usb_core_id;
	ret = android_create_device(android_dev,
			android_usb_driver.gadget_driver.usb_core_id);
	if (ret) {
		pr_err("%s(): android_create_device failed\n", __func__);
		goto err_dev;
	}

	pr_debug("%s(): registering android_usb_driver with core id:%d\n",
		__func__, android_usb_driver.gadget_driver.usb_core_id);
	ret = usb_composite_probe(&android_usb_driver);
	if (ret) {
		/* Perhaps UDC hasn't probed yet, try again later */