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

Commit 06e7114f authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Felipe Balbi
Browse files

usb: common: of_usb_get_dr_mode to usb_get_dr_mode



By using the unified device property interface, the function
can be made available for all platforms and not just the
ones using DT.

Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 66647273
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -611,7 +611,7 @@ static int ci_get_platdata(struct device *dev,
		platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);

	if (!platdata->dr_mode)
		platdata->dr_mode = of_usb_get_dr_mode(dev->of_node);
		platdata->dr_mode = usb_get_dr_mode(dev);

	if (platdata->dr_mode == USB_DR_MODE_UNKNOWN)
		platdata->dr_mode = USB_DR_MODE_OTG;
+4 −11
Original line number Diff line number Diff line
@@ -99,7 +99,6 @@ const char *usb_state_string(enum usb_device_state state)
}
EXPORT_SYMBOL_GPL(usb_state_string);

#ifdef CONFIG_OF
static const char *const usb_dr_modes[] = {
	[USB_DR_MODE_UNKNOWN]		= "",
	[USB_DR_MODE_HOST]		= "host",
@@ -107,19 +106,12 @@ static const char *const usb_dr_modes[] = {
	[USB_DR_MODE_OTG]		= "otg",
};

/**
 * of_usb_get_dr_mode - Get dual role mode for given device_node
 * @np:	Pointer to the given device_node
 *
 * The function gets phy interface string from property 'dr_mode',
 * and returns the correspondig enum usb_dr_mode
 */
enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
enum usb_dr_mode usb_get_dr_mode(struct device *dev)
{
	const char *dr_mode;
	int err, i;

	err = of_property_read_string(np, "dr_mode", &dr_mode);
	err = device_property_read_string(dev, "dr_mode", &dr_mode);
	if (err < 0)
		return USB_DR_MODE_UNKNOWN;

@@ -129,8 +121,9 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)

	return USB_DR_MODE_UNKNOWN;
}
EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
EXPORT_SYMBOL_GPL(usb_get_dr_mode);

#ifdef CONFIG_OF
/**
 * of_usb_host_tpl_support - to get if Targeted Peripheral List is supported
 * for given targeted hosts (non-PC hosts)
+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
	dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
		(unsigned long)res->start, hsotg->regs);

	hsotg->dr_mode = of_usb_get_dr_mode(dev->dev.of_node);
	hsotg->dr_mode = usb_get_dr_mode(&dev->dev);

	/*
	 * Attempt to find a generic PHY, then look for an old style
+1 −1
Original line number Diff line number Diff line
@@ -871,6 +871,7 @@ static int dwc3_probe(struct platform_device *pdev)
	hird_threshold = 12;

	dwc->maximum_speed = usb_get_maximum_speed(dev);
	dwc->dr_mode = usb_get_dr_mode(dev);

	if (node) {
		dwc->has_lpm_erratum = of_property_read_bool(node,
@@ -886,7 +887,6 @@ static int dwc3_probe(struct platform_device *pdev)

		dwc->needs_fifo_resize = of_property_read_bool(node,
				"tx-fifo-resize");
		dwc->dr_mode = of_usb_get_dr_mode(node);

		dwc->disable_scramble_quirk = of_property_read_bool(node,
				"snps,disable_scramble_quirk");
+1 −1
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ static int st_dwc3_probe(struct platform_device *pdev)
		goto undo_softreset;
	}

	dwc3_data->dr_mode = of_usb_get_dr_mode(child_pdev->dev.of_node);
	dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);

	/*
	 * Configure the USB port as device or host according to the static
Loading