summaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc2/params.c
diff options
context:
space:
mode:
authorJohn Youn <John.Youn@synopsys.com>2017-01-23 23:55:35 +0100
committerFelipe Balbi <felipe.balbi@linux.intel.com>2017-01-24 15:19:05 +0100
commitf9f93cbb3c11e56d500fd77beb8eac6ded534d6c (patch)
tree3af92b1ab5f50983945f4a20f6f9327272a3e383 /drivers/usb/dwc2/params.c
parentusb: dwc2: Set core parameters to default values (diff)
downloadlinux-f9f93cbb3c11e56d500fd77beb8eac6ded534d6c.tar.xz
linux-f9f93cbb3c11e56d500fd77beb8eac6ded534d6c.zip
usb: dwc2: Get device properties
After setting the default core parameter values, read in the device properties and modify core parameter values if needed. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/dwc2/params.c')
-rw-r--r--drivers/usb/dwc2/params.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 6729f14d25de..4416eae09647 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -343,6 +343,40 @@ static void dwc2_set_default_params(struct dwc2_hsotg *hsotg)
}
}
+/**
+ * dwc2_get_device_properties() - Read in device properties.
+ *
+ * Read in the device properties and adjust core parameters if needed.
+ */
+static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg)
+{
+ struct dwc2_core_params *p = &hsotg->params;
+ int num;
+
+ if ((hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) ||
+ (hsotg->dr_mode == USB_DR_MODE_OTG)) {
+ device_property_read_u32(hsotg->dev, "g-rx-fifo-size",
+ &p->g_rx_fifo_size);
+
+ device_property_read_u32(hsotg->dev, "g-np-tx-fifo-size",
+ &p->g_np_tx_fifo_size);
+
+ num = device_property_read_u32_array(hsotg->dev,
+ "g-tx-fifo-size",
+ NULL, 0);
+
+ if (num > 0) {
+ num = min(num, 15);
+ memset(p->g_tx_fifo_size, 0,
+ sizeof(p->g_tx_fifo_size));
+ device_property_read_u32_array(hsotg->dev,
+ "g-tx-fifo-size",
+ &p->g_tx_fifo_size[1],
+ num);
+ }
+ }
+}
+
/*
* Gets host hardware parameters. Forces host mode if not currently in
* host mode. Should be called immediately after a core soft reset in
@@ -555,6 +589,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
int dwc2_init_params(struct dwc2_hsotg *hsotg)
{
dwc2_set_default_params(hsotg);
+ dwc2_get_device_properties(hsotg);
return 0;
}