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

Commit f5730bc7 authored by Pavankumar Kondeti's avatar Pavankumar Kondeti Committed by Sujeet Kumar
Browse files

USB: android: Add support for USB UICC mass storage



USB UICC cards can support multiple partitions which can be
exposed to the host via USB mass storage function. The number
of partitions of UICC card may vary for each target. Hence
create a device tree property to accept the required luns.

CRs-Fixed: 639635
Change-Id: I5bf5e9acd9fed72adffe469b602ab2d431ccfa3e
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent 53f84163
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -232,10 +232,13 @@ Optional properties :
  turnaround timeout is observed on enabling streaming. Hence it is required
  to see these errors and number of erros on enabling this at USB level to make
  final decision to enable this feature or not.
- qcom,android-usb-uicc-nluns : Number of mass storage LUNs (8 bits) required
  for the UICC card.
Example Android USB device node :
	android_usb@fc42b0c8 {
		compatible = "qcom,android-usb";
		reg = <0xfc42b0c8 0xc8>;
		qcom,android-usb-swfi-latency = <1>;
		qcom,streaming-func = "rndis","mtp";
		qcom,android-usb-uicc-nluns = /bits/ 8 <1>;
	};
+22 −3
Original line number Diff line number Diff line
@@ -2185,14 +2185,17 @@ struct mass_storage_function_config {
	struct fsg_common *common;
};

#define MAX_LUN_NAME 8
static int mass_storage_function_init(struct android_usb_function *f,
					struct usb_composite_dev *cdev)
{
	struct android_dev *dev = cdev_to_android_dev(cdev);
	struct mass_storage_function_config *config;
	struct fsg_common *common;
	int err;
	int i;
	const char *name[2];
	int i, n;
	char name[FSG_MAX_LUNS][MAX_LUN_NAME];
	u8 uicc_nluns = dev->pdata ? dev->pdata->uicc_nluns : 0;

	config = kzalloc(sizeof(struct mass_storage_function_config),
							GFP_KERNEL);
@@ -2202,9 +2205,21 @@ static int mass_storage_function_init(struct android_usb_function *f,
	}

	config->fsg.nluns = 1;
	name[0] = "lun";
	snprintf(name[0], MAX_LUN_NAME, "lun");
	config->fsg.luns[0].removable = 1;

	if (uicc_nluns > FSG_MAX_LUNS - config->fsg.nluns) {
		uicc_nluns = FSG_MAX_LUNS - config->fsg.nluns;
		pr_debug("limiting uicc luns to %d\n", uicc_nluns);
	}

	for (i = 0; i < uicc_nluns; i++) {
		n = config->fsg.nluns;
		snprintf(name[n], MAX_LUN_NAME, "uicc%d", i);
		config->fsg.luns[n].removable = 1;
		config->fsg.nluns++;
	}

	common = fsg_common_init(NULL, cdev, &config->fsg);
	if (IS_ERR(common)) {
		kfree(config);
@@ -3516,6 +3531,10 @@ static int android_probe(struct platform_device *pdev)
		}

		pdata->streaming_func_count = len;

		ret = of_property_read_u8(pdev->dev.of_node,
				"qcom,android-usb-uicc-nluns",
				&pdata->uicc_nluns);
	} else {
		pdata = pdev->dev.platform_data;
	}
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ struct android_usb_platform_data {
	u8 usb_core_id;
	char streaming_func[MAX_STREAMING_FUNCS][FUNC_NAME_LEN];
	int  streaming_func_count;
	u8 uicc_nluns;
};

#ifndef CONFIG_TARGET_CORE