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

Commit fbabead9 authored by Kyle Yan's avatar Kyle Yan Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: dwc3: use bus->sysdev for DMA configuration" into msm-4.9

parents 24b295ae 42695fc0
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)
static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
		struct dwc3_event_buffer *evt)
{
	dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
	dma_free_coherent(dwc->sysdev, evt->length, evt->buf, evt->dma);
}

/**
@@ -345,7 +345,7 @@ static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc,

	evt->dwc	= dwc;
	evt->length	= length;
	evt->buf	= dma_alloc_coherent(dwc->dev, length,
	evt->buf	= dma_alloc_coherent(dwc->sysdev, length,
			&evt->dma, GFP_KERNEL);
	if (!evt->buf)
		return ERR_PTR(-ENOMEM);
@@ -474,11 +474,11 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
	if (!WARN_ON(dwc->scratchbuf))
		return 0;

	scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf,
	scratch_addr = dma_map_single(dwc->sysdev, dwc->scratchbuf,
			dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE,
			DMA_BIDIRECTIONAL);
	if (dma_mapping_error(dwc->dev, scratch_addr)) {
		dev_err(dwc->dev, "failed to map scratch buffer\n");
	if (dma_mapping_error(dwc->sysdev, scratch_addr)) {
		dev_err(dwc->sysdev, "failed to map scratch buffer\n");
		ret = -EFAULT;
		goto err0;
	}
@@ -502,7 +502,7 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
	return 0;

err1:
	dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
	dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch *
			DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);

err0:
@@ -521,7 +521,7 @@ static void dwc3_free_scratch_buffers(struct dwc3 *dwc)
	if (!WARN_ON(dwc->scratchbuf))
		return;

	dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
	dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch *
			DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
	kfree(dwc->scratchbuf);
}
@@ -1214,6 +1214,13 @@ static int dwc3_probe(struct platform_device *pdev)

	dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node);

	dwc->sysdev_is_parent = device_property_read_bool(dev,
				"linux,sysdev_is_parent");
	if (dwc->sysdev_is_parent)
		dwc->sysdev = dwc->dev->parent;
	else
		dwc->sysdev = dwc->dev;

	dwc->has_lpm_erratum = device_property_read_bool(dev,
				"snps,has-lpm-erratum");
	device_property_read_u8(dev, "snps,lpm-nyet-threshold",
@@ -1288,12 +1295,6 @@ static int dwc3_probe(struct platform_device *pdev)

	spin_lock_init(&dwc->lock);

	if (!dev->dma_mask) {
		dev->dma_mask = dev->parent->dma_mask;
		dev->dma_parms = dev->parent->dma_parms;
		dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);
	}

	pm_runtime_no_callbacks(dev);
	pm_runtime_set_active(dev);
	pm_runtime_enable(dev);
+3 −0
Original line number Diff line number Diff line
@@ -887,6 +887,7 @@ struct dwc3_scratchpad_array {
 * @ep0_bounced: true when we used bounce buffer
 * @ep0_expect_in: true when we expect a DATA IN transfer
 * @has_hibernation: true when dwc3 was configured with Hibernation
 * @sysdev_is_parent: true when dwc3 device has a parent driver
 * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that
 *			there's now way for software to detect this in runtime.
 * @is_utmi_l1_suspend: the core asserts output signal
@@ -956,6 +957,7 @@ struct dwc3 {
	spinlock_t		lock;

	struct device		*dev;
	struct device		*sysdev;

	struct platform_device	*xhci;
	struct resource		xhci_resources[DWC3_XHCI_RESOURCES_NUM];
@@ -1062,6 +1064,7 @@ struct dwc3 {
	unsigned		ep0_bounced:1;
	unsigned		ep0_expect_in:1;
	unsigned		has_hibernation:1;
	unsigned		sysdev_is_parent:1;
	unsigned		has_lpm_erratum:1;
	unsigned		is_utmi_l1_suspend:1;
	unsigned		is_fpga:1;
+4 −4
Original line number Diff line number Diff line
@@ -1011,8 +1011,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
		u32	transfer_size = 0;
		u32	maxpacket;

		ret = usb_gadget_map_request(&dwc->gadget, &req->request,
				dep->number);
		ret = usb_gadget_map_request_by_dev(dwc->sysdev,
				&req->request, dep->number);
		if (ret) {
			dwc3_trace(trace_dwc3_ep0, "failed to map request");
			return;
@@ -1040,8 +1040,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
				DWC3_TRBCTL_CONTROL_DATA, false);
		ret = dwc3_ep0_start_trans(dwc, dep->number);
	} else {
		ret = usb_gadget_map_request(&dwc->gadget, &req->request,
				dep->number);
		ret = usb_gadget_map_request_by_dev(dwc->sysdev,
				&req->request, dep->number);
		if (ret) {
			dwc3_trace(trace_dwc3_ep0, "failed to map request");
			return;
+19 −18
Original line number Diff line number Diff line
@@ -295,8 +295,8 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
	if (dwc->ep0_bounced && dep->number <= 1)
		dwc->ep0_bounced = false;

	usb_gadget_unmap_request(&dwc->gadget, &req->request,
			req->direction);
	usb_gadget_unmap_request_by_dev(dwc->sysdev,
			&req->request, req->direction);

	trace_dwc3_gadget_giveback(req);

@@ -476,7 +476,7 @@ static int dwc3_alloc_trb_pool(struct dwc3_ep *dep)
	if (dep->trb_pool)
		return 0;

	dep->trb_pool = dma_zalloc_coherent(dwc->dev,
	dep->trb_pool = dma_zalloc_coherent(dwc->sysdev,
			sizeof(struct dwc3_trb) * num_trbs,
			&dep->trb_pool_dma, GFP_KERNEL);
	if (!dep->trb_pool) {
@@ -508,7 +508,7 @@ static void dwc3_free_trb_pool(struct dwc3_ep *dep)
		dbg_event(dep->number, "Clr_TRB", 0);
		dev_dbg(dwc->dev, "Clr_TRB ring of %s\n", dep->name);

		dma_free_coherent(dwc->dev,
		dma_free_coherent(dwc->sysdev,
				sizeof(struct dwc3_trb) * DWC3_TRB_NUM,
				dep->trb_pool, dep->trb_pool_dma);
		dep->trb_pool = NULL;
@@ -1150,8 +1150,8 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param)
		 * here and stop, unmap, free and del each of the linked
		 * requests instead of what we do now.
		 */
		usb_gadget_unmap_request(&dwc->gadget, &req->request,
				req->direction);
		usb_gadget_unmap_request_by_dev(dwc->sysdev,
				&req->request, req->direction);
		list_del(&req->list);
		return ret;
	}
@@ -1233,7 +1233,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)

	trace_dwc3_ep_queue(req);

	ret = usb_gadget_map_request(&dwc->gadget, &req->request,
	ret = usb_gadget_map_request_by_dev(dwc->sysdev, &req->request,
					    dep->direction);
	if (ret)
		return ret;
@@ -3615,7 +3615,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)

	INIT_WORK(&dwc->wakeup_work, dwc3_gadget_wakeup_work);

	dwc->ctrl_req = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ctrl_req),
	dwc->ctrl_req = dma_alloc_coherent(dwc->sysdev, sizeof(*dwc->ctrl_req),
			&dwc->ctrl_req_addr, GFP_KERNEL);
	if (!dwc->ctrl_req) {
		dev_err(dwc->dev, "failed to allocate ctrl request\n");
@@ -3623,7 +3623,8 @@ int dwc3_gadget_init(struct dwc3 *dwc)
		goto err0;
	}

	dwc->ep0_trb = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ep0_trb) * 2,
	dwc->ep0_trb = dma_alloc_coherent(dwc->sysdev,
					  sizeof(*dwc->ep0_trb) * 2,
					  &dwc->ep0_trb_addr, GFP_KERNEL);
	if (!dwc->ep0_trb) {
		dev_err(dwc->dev, "failed to allocate ep0 trb\n");
@@ -3637,7 +3638,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)
		goto err2;
	}

	dwc->ep0_bounce = dma_alloc_coherent(dwc->dev,
	dwc->ep0_bounce = dma_alloc_coherent(dwc->sysdev,
			DWC3_EP0_BOUNCE_SIZE, &dwc->ep0_bounce_addr,
			GFP_KERNEL);
	if (!dwc->ep0_bounce) {
@@ -3716,18 +3717,18 @@ int dwc3_gadget_init(struct dwc3 *dwc)

err4:
	dwc3_gadget_free_endpoints(dwc);
	dma_free_coherent(dwc->dev, DWC3_EP0_BOUNCE_SIZE,
	dma_free_coherent(dwc->sysdev, DWC3_EP0_BOUNCE_SIZE,
			dwc->ep0_bounce, dwc->ep0_bounce_addr);

err3:
	kfree(dwc->setup_buf);

err2:
	dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb) * 2,
	dma_free_coherent(dwc->sysdev, sizeof(*dwc->ep0_trb) * 2,
			dwc->ep0_trb, dwc->ep0_trb_addr);

err1:
	dma_free_coherent(dwc->dev, sizeof(*dwc->ctrl_req),
	dma_free_coherent(dwc->sysdev, sizeof(*dwc->ctrl_req),
			dwc->ctrl_req, dwc->ctrl_req_addr);

err0:
@@ -3747,16 +3748,16 @@ void dwc3_gadget_exit(struct dwc3 *dwc)

	dwc3_gadget_free_endpoints(dwc);

	dma_free_coherent(dwc->dev, DWC3_EP0_BOUNCE_SIZE,
	dma_free_coherent(dwc->sysdev, DWC3_EP0_BOUNCE_SIZE,
			dwc->ep0_bounce, dwc->ep0_bounce_addr);

	kfree(dwc->setup_buf);
	kfree(dwc->zlp_buf);

	dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb) * 2,
	dma_free_coherent(dwc->sysdev, sizeof(*dwc->ep0_trb) * 2,
			dwc->ep0_trb, dwc->ep0_trb_addr);

	dma_free_coherent(dwc->dev, sizeof(*dwc->ctrl_req),
	dma_free_coherent(dwc->sysdev, sizeof(*dwc->ctrl_req),
			dwc->ctrl_req, dwc->ctrl_req_addr);
}

+4 −9
Original line number Diff line number Diff line
@@ -72,12 +72,7 @@ int dwc3_host_init(struct dwc3 *dwc)
		return -ENOMEM;
	}

	arch_setup_dma_ops(&xhci->dev, 0, 0, NULL, 0);
	dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask);

	xhci->dev.parent	= dwc->dev;
	xhci->dev.dma_mask	= dwc->dev->dma_mask;
	xhci->dev.dma_parms	= dwc->dev->dma_parms;

	dwc->xhci = xhci;

@@ -100,9 +95,9 @@ int dwc3_host_init(struct dwc3 *dwc)
	}

	phy_create_lookup(dwc->usb2_generic_phy, "usb2-phy",
			  dev_name(&xhci->dev));
			  dev_name(dwc->dev));
	phy_create_lookup(dwc->usb3_generic_phy, "usb3-phy",
			  dev_name(&xhci->dev));
			  dev_name(dwc->dev));

	/* Platform device gets added as part of state machine */

@@ -115,9 +110,9 @@ int dwc3_host_init(struct dwc3 *dwc)
void dwc3_host_exit(struct dwc3 *dwc)
{
	phy_remove_lookup(dwc->usb2_generic_phy, "usb2-phy",
			  dev_name(&dwc->xhci->dev));
			  dev_name(dwc->dev));
	phy_remove_lookup(dwc->usb3_generic_phy, "usb3-phy",
			  dev_name(&dwc->xhci->dev));
			  dev_name(dwc->dev));
	if (!dwc->is_drd)
		platform_device_unregister(dwc->xhci);
}