blob: 266157ae179a0a1ac08b56fac1d0a48724fb52cd [file] [log] [blame]
Greg Kroah-Hartman5fd54ac2017-11-03 11:28:30 +01001// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
John Youn323230e2016-11-03 17:55:50 -07002/*
3 * Copyright (C) 2004-2016 Synopsys, Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions, and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The names of the above-listed copyright holders may not be used
15 * to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation; either version 2 of the License, or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#include <linux/kernel.h>
37#include <linux/module.h>
38#include <linux/of_device.h>
39
40#include "core.h"
41
John Youn7de1deb2017-01-23 14:57:04 -080042static void dwc2_set_bcm_params(struct dwc2_hsotg *hsotg)
43{
44 struct dwc2_core_params *p = &hsotg->params;
John Youn323230e2016-11-03 17:55:50 -070045
John Youn7de1deb2017-01-23 14:57:04 -080046 p->host_rx_fifo_size = 774;
John Youn7de1deb2017-01-23 14:57:04 -080047 p->max_transfer_size = 65535;
48 p->max_packet_count = 511;
John Youn7de1deb2017-01-23 14:57:04 -080049 p->ahbcfg = 0x10;
John Youn7de1deb2017-01-23 14:57:04 -080050}
John Youn323230e2016-11-03 17:55:50 -070051
John Youn7de1deb2017-01-23 14:57:04 -080052static void dwc2_set_his_params(struct dwc2_hsotg *hsotg)
53{
54 struct dwc2_core_params *p = &hsotg->params;
John Youn323230e2016-11-03 17:55:50 -070055
John Youn7de1deb2017-01-23 14:57:04 -080056 p->otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE;
57 p->speed = DWC2_SPEED_PARAM_HIGH;
58 p->host_rx_fifo_size = 512;
59 p->host_nperio_tx_fifo_size = 512;
60 p->host_perio_tx_fifo_size = 512;
61 p->max_transfer_size = 65535;
62 p->max_packet_count = 511;
63 p->host_channels = 16;
64 p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI;
65 p->phy_utmi_width = 8;
66 p->i2c_enable = false;
John Youn7de1deb2017-01-23 14:57:04 -080067 p->reload_ctl = false;
68 p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 <<
69 GAHBCFG_HBSTLEN_SHIFT;
Chen Yuca8b0332017-01-23 15:00:18 -080070 p->change_speed_quirk = true;
John Stultzd98c6242018-05-18 17:49:03 -070071 p->power_down = false;
John Youn7de1deb2017-01-23 14:57:04 -080072}
John Youn323230e2016-11-03 17:55:50 -070073
Marek Szyprowski35a60542018-11-20 16:38:15 +010074static void dwc2_set_s3c6400_params(struct dwc2_hsotg *hsotg)
75{
76 struct dwc2_core_params *p = &hsotg->params;
77
78 p->power_down = 0;
79}
80
John Youn7de1deb2017-01-23 14:57:04 -080081static void dwc2_set_rk_params(struct dwc2_hsotg *hsotg)
82{
83 struct dwc2_core_params *p = &hsotg->params;
84
85 p->otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE;
86 p->host_rx_fifo_size = 525;
87 p->host_nperio_tx_fifo_size = 128;
88 p->host_perio_tx_fifo_size = 256;
89 p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 <<
90 GAHBCFG_HBSTLEN_SHIFT;
SolidHalc2167652018-10-02 20:58:16 -050091 p->power_down = 0;
John Youn7de1deb2017-01-23 14:57:04 -080092}
93
94static void dwc2_set_ltq_params(struct dwc2_hsotg *hsotg)
95{
96 struct dwc2_core_params *p = &hsotg->params;
97
98 p->otg_cap = 2;
99 p->host_rx_fifo_size = 288;
100 p->host_nperio_tx_fifo_size = 128;
101 p->host_perio_tx_fifo_size = 96;
102 p->max_transfer_size = 65535;
103 p->max_packet_count = 511;
104 p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 <<
105 GAHBCFG_HBSTLEN_SHIFT;
106}
107
108static void dwc2_set_amlogic_params(struct dwc2_hsotg *hsotg)
109{
110 struct dwc2_core_params *p = &hsotg->params;
111
112 p->otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE;
113 p->speed = DWC2_SPEED_PARAM_HIGH;
114 p->host_rx_fifo_size = 512;
115 p->host_nperio_tx_fifo_size = 500;
116 p->host_perio_tx_fifo_size = 500;
117 p->host_channels = 16;
118 p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI;
119 p->ahbcfg = GAHBCFG_HBSTLEN_INCR8 <<
120 GAHBCFG_HBSTLEN_SHIFT;
John Youn7de1deb2017-01-23 14:57:04 -0800121}
122
123static void dwc2_set_amcc_params(struct dwc2_hsotg *hsotg)
124{
125 struct dwc2_core_params *p = &hsotg->params;
126
127 p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 << GAHBCFG_HBSTLEN_SHIFT;
128}
John Youn323230e2016-11-03 17:55:50 -0700129
Bruno Herrerae35b1352017-01-31 23:25:43 -0200130static void dwc2_set_stm32f4x9_fsotg_params(struct dwc2_hsotg *hsotg)
131{
132 struct dwc2_core_params *p = &hsotg->params;
133
134 p->otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE;
135 p->speed = DWC2_SPEED_PARAM_FULL;
136 p->host_rx_fifo_size = 128;
137 p->host_nperio_tx_fifo_size = 96;
138 p->host_perio_tx_fifo_size = 96;
139 p->max_packet_count = 256;
140 p->phy_type = DWC2_PHY_TYPE_PARAM_FS;
141 p->i2c_enable = false;
Bruno Herrerae35b1352017-01-31 23:25:43 -0200142 p->activate_stm_fs_transceiver = true;
143}
144
Amelie Delaunay1a149e32018-03-01 11:05:35 +0100145static void dwc2_set_stm32f7_hsotg_params(struct dwc2_hsotg *hsotg)
Amelie Delaunayd8fae8b2017-08-17 11:33:01 +0200146{
147 struct dwc2_core_params *p = &hsotg->params;
148
149 p->host_rx_fifo_size = 622;
150 p->host_nperio_tx_fifo_size = 128;
151 p->host_perio_tx_fifo_size = 256;
152}
153
John Youn323230e2016-11-03 17:55:50 -0700154const struct of_device_id dwc2_of_match_table[] = {
John Youn7de1deb2017-01-23 14:57:04 -0800155 { .compatible = "brcm,bcm2835-usb", .data = dwc2_set_bcm_params },
156 { .compatible = "hisilicon,hi6220-usb", .data = dwc2_set_his_params },
157 { .compatible = "rockchip,rk3066-usb", .data = dwc2_set_rk_params },
158 { .compatible = "lantiq,arx100-usb", .data = dwc2_set_ltq_params },
159 { .compatible = "lantiq,xrx200-usb", .data = dwc2_set_ltq_params },
160 { .compatible = "snps,dwc2" },
Marek Szyprowski35a60542018-11-20 16:38:15 +0100161 { .compatible = "samsung,s3c6400-hsotg",
162 .data = dwc2_set_s3c6400_params },
Martin Blumenstingl55b644f2017-05-06 19:37:45 +0200163 { .compatible = "amlogic,meson8-usb",
164 .data = dwc2_set_amlogic_params },
John Youn7de1deb2017-01-23 14:57:04 -0800165 { .compatible = "amlogic,meson8b-usb",
166 .data = dwc2_set_amlogic_params },
167 { .compatible = "amlogic,meson-gxbb-usb",
168 .data = dwc2_set_amlogic_params },
169 { .compatible = "amcc,dwc-otg", .data = dwc2_set_amcc_params },
Bruno Herrerae35b1352017-01-31 23:25:43 -0200170 { .compatible = "st,stm32f4x9-fsotg",
171 .data = dwc2_set_stm32f4x9_fsotg_params },
172 { .compatible = "st,stm32f4x9-hsotg" },
Amelie Delaunay1a149e32018-03-01 11:05:35 +0100173 { .compatible = "st,stm32f7-hsotg",
174 .data = dwc2_set_stm32f7_hsotg_params },
John Youn323230e2016-11-03 17:55:50 -0700175 {},
176};
177MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
178
John Youn245977c2017-01-23 14:55:14 -0800179static void dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg)
John Youn05ee7992016-11-03 17:56:05 -0700180{
John Youn245977c2017-01-23 14:55:14 -0800181 u8 val;
John Youn05ee7992016-11-03 17:56:05 -0700182
John Youn245977c2017-01-23 14:55:14 -0800183 switch (hsotg->hw_params.op_mode) {
184 case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE:
185 val = DWC2_CAP_PARAM_HNP_SRP_CAPABLE;
John Youn05ee7992016-11-03 17:56:05 -0700186 break;
John Youn245977c2017-01-23 14:55:14 -0800187 case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE:
188 case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE:
189 case GHWCFG2_OP_MODE_SRP_CAPABLE_HOST:
190 val = DWC2_CAP_PARAM_SRP_ONLY_CAPABLE;
John Youn05ee7992016-11-03 17:56:05 -0700191 break;
192 default:
John Youn245977c2017-01-23 14:55:14 -0800193 val = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE;
John Youn05ee7992016-11-03 17:56:05 -0700194 break;
John Youn323230e2016-11-03 17:55:50 -0700195 }
196
John Younbea8e862016-11-03 17:55:53 -0700197 hsotg->params.otg_cap = val;
John Youn323230e2016-11-03 17:55:50 -0700198}
199
John Youn245977c2017-01-23 14:55:14 -0800200static void dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg)
John Youn323230e2016-11-03 17:55:50 -0700201{
John Youn245977c2017-01-23 14:55:14 -0800202 int val;
203 u32 hs_phy_type = hsotg->hw_params.hs_phy_type;
John Youn323230e2016-11-03 17:55:50 -0700204
John Youn245977c2017-01-23 14:55:14 -0800205 val = DWC2_PHY_TYPE_PARAM_FS;
206 if (hs_phy_type != GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED) {
207 if (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI ||
208 hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI_ULPI)
209 val = DWC2_PHY_TYPE_PARAM_UTMI;
210 else
211 val = DWC2_PHY_TYPE_PARAM_ULPI;
John Youn323230e2016-11-03 17:55:50 -0700212 }
213
John Youn245977c2017-01-23 14:55:14 -0800214 if (dwc2_is_fs_iot(hsotg))
215 hsotg->params.phy_type = DWC2_PHY_TYPE_PARAM_FS;
John Youn323230e2016-11-03 17:55:50 -0700216
John Younbea8e862016-11-03 17:55:53 -0700217 hsotg->params.phy_type = val;
John Youn323230e2016-11-03 17:55:50 -0700218}
219
John Youn245977c2017-01-23 14:55:14 -0800220static void dwc2_set_param_speed(struct dwc2_hsotg *hsotg)
John Youn323230e2016-11-03 17:55:50 -0700221{
John Youn245977c2017-01-23 14:55:14 -0800222 int val;
John Youn323230e2016-11-03 17:55:50 -0700223
John Youn245977c2017-01-23 14:55:14 -0800224 val = hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS ?
225 DWC2_SPEED_PARAM_FULL : DWC2_SPEED_PARAM_HIGH;
John Youn323230e2016-11-03 17:55:50 -0700226
John Youn245977c2017-01-23 14:55:14 -0800227 if (dwc2_is_fs_iot(hsotg))
228 val = DWC2_SPEED_PARAM_FULL;
John Youn323230e2016-11-03 17:55:50 -0700229
John Youn245977c2017-01-23 14:55:14 -0800230 if (dwc2_is_hs_iot(hsotg))
231 val = DWC2_SPEED_PARAM_HIGH;
John Youn323230e2016-11-03 17:55:50 -0700232
John Younbea8e862016-11-03 17:55:53 -0700233 hsotg->params.speed = val;
John Youn323230e2016-11-03 17:55:50 -0700234}
235
John Youn245977c2017-01-23 14:55:14 -0800236static void dwc2_set_param_phy_utmi_width(struct dwc2_hsotg *hsotg)
John Youn323230e2016-11-03 17:55:50 -0700237{
John Youn245977c2017-01-23 14:55:14 -0800238 int val;
John Youn323230e2016-11-03 17:55:50 -0700239
John Youn245977c2017-01-23 14:55:14 -0800240 val = (hsotg->hw_params.utmi_phy_data_width ==
241 GHWCFG4_UTMI_PHY_DATA_WIDTH_8) ? 8 : 16;
John Youn323230e2016-11-03 17:55:50 -0700242
John Younbea8e862016-11-03 17:55:53 -0700243 hsotg->params.phy_utmi_width = val;
John Youn323230e2016-11-03 17:55:50 -0700244}
245
John Youn05ee7992016-11-03 17:56:05 -0700246static void dwc2_set_param_tx_fifo_sizes(struct dwc2_hsotg *hsotg)
247{
John Youn05ee7992016-11-03 17:56:05 -0700248 struct dwc2_core_params *p = &hsotg->params;
Sevak Arakelyanc138ecf2017-01-23 15:01:23 -0800249 int depth_average;
250 int fifo_count;
251 int i;
252
253 fifo_count = dwc2_hsotg_tx_fifo_count(hsotg);
John Youn05ee7992016-11-03 17:56:05 -0700254
255 memset(p->g_tx_fifo_size, 0, sizeof(p->g_tx_fifo_size));
Sevak Arakelyanc138ecf2017-01-23 15:01:23 -0800256 depth_average = dwc2_hsotg_tx_fifo_average_depth(hsotg);
257 for (i = 1; i <= fifo_count; i++)
258 p->g_tx_fifo_size[i] = depth_average;
John Youn9962b622016-11-09 19:27:40 -0800259}
260
John Youn03ea6d62018-02-16 14:12:28 +0400261static void dwc2_set_param_power_down(struct dwc2_hsotg *hsotg)
262{
263 int val;
264
265 if (hsotg->hw_params.hibernation)
266 val = 2;
267 else if (hsotg->hw_params.power_optimized)
268 val = 1;
269 else
270 val = 0;
271
272 hsotg->params.power_down = val;
273}
274
John Youn05ee7992016-11-03 17:56:05 -0700275/**
John Youn245977c2017-01-23 14:55:14 -0800276 * dwc2_set_default_params() - Set all core parameters to their
277 * auto-detected default values.
Grigor Tovmasyan6fb914d2018-05-16 12:04:24 +0400278 *
279 * @hsotg: Programming view of the DWC_otg controller
280 *
John Youn323230e2016-11-03 17:55:50 -0700281 */
John Youn245977c2017-01-23 14:55:14 -0800282static void dwc2_set_default_params(struct dwc2_hsotg *hsotg)
John Youn323230e2016-11-03 17:55:50 -0700283{
John Youn05ee7992016-11-03 17:56:05 -0700284 struct dwc2_hw_params *hw = &hsotg->hw_params;
285 struct dwc2_core_params *p = &hsotg->params;
John Youn6b66ce52016-11-03 17:56:12 -0700286 bool dma_capable = !(hw->arch == GHWCFG2_SLAVE_ONLY_ARCH);
John Youn323230e2016-11-03 17:55:50 -0700287
John Youn245977c2017-01-23 14:55:14 -0800288 dwc2_set_param_otg_cap(hsotg);
289 dwc2_set_param_phy_type(hsotg);
290 dwc2_set_param_speed(hsotg);
291 dwc2_set_param_phy_utmi_width(hsotg);
John Youn03ea6d62018-02-16 14:12:28 +0400292 dwc2_set_param_power_down(hsotg);
John Youn245977c2017-01-23 14:55:14 -0800293 p->phy_ulpi_ddr = false;
294 p->phy_ulpi_ext_vbus = false;
295
296 p->enable_dynamic_fifo = hw->enable_dynamic_fifo;
297 p->en_multiple_tx_fifo = hw->en_multiple_tx_fifo;
298 p->i2c_enable = hw->i2c_enable;
Razmik Karapetyan66e77a22018-01-24 17:40:29 +0400299 p->acg_enable = hw->acg_enable;
John Youn245977c2017-01-23 14:55:14 -0800300 p->ulpi_fs_ls = false;
301 p->ts_dline = false;
302 p->reload_ctl = (hw->snpsid >= DWC2_CORE_REV_2_92a);
303 p->uframe_sched = true;
304 p->external_id_pin_ctl = false;
Sevak Arakelyan6f80b6d2018-01-24 17:41:48 +0400305 p->lpm = true;
306 p->lpm_clock_gating = true;
307 p->besl = true;
308 p->hird_threshold_en = true;
309 p->hird_threshold = 4;
Grigor Tovmasyanb43ebc92018-05-05 12:17:58 +0400310 p->ipg_isoc_en = false;
Grigor Tovmasyanca531bc2018-08-29 20:59:34 +0400311 p->service_interval = false;
John Youn245977c2017-01-23 14:55:14 -0800312 p->max_packet_count = hw->max_packet_count;
313 p->max_transfer_size = hw->max_transfer_size;
Razmik Karapetyan1b52d2f2018-01-19 14:40:23 +0400314 p->ahbcfg = GAHBCFG_HBSTLEN_INCR << GAHBCFG_HBSTLEN_SHIFT;
Grigor Tovmasyanf3a61e42018-08-29 21:01:31 +0400315 p->ref_clk_per = 33333;
316 p->sof_cnt_wkup_alert = 100;
John Youn245977c2017-01-23 14:55:14 -0800317
John Youn6b66ce52016-11-03 17:56:12 -0700318 if ((hsotg->dr_mode == USB_DR_MODE_HOST) ||
319 (hsotg->dr_mode == USB_DR_MODE_OTG)) {
John Youn245977c2017-01-23 14:55:14 -0800320 p->host_dma = dma_capable;
321 p->dma_desc_enable = false;
322 p->dma_desc_fs_enable = false;
323 p->host_support_fs_ls_low_power = false;
324 p->host_ls_low_power_phy_clk = false;
325 p->host_channels = hw->host_channels;
326 p->host_rx_fifo_size = hw->rx_fifo_size;
327 p->host_nperio_tx_fifo_size = hw->host_nperio_tx_fifo_size;
328 p->host_perio_tx_fifo_size = hw->host_perio_tx_fifo_size;
John Youn6b66ce52016-11-03 17:56:12 -0700329 }
330
John Youn05ee7992016-11-03 17:56:05 -0700331 if ((hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) ||
332 (hsotg->dr_mode == USB_DR_MODE_OTG)) {
John Youn245977c2017-01-23 14:55:14 -0800333 p->g_dma = dma_capable;
334 p->g_dma_desc = hw->dma_desc_enable;
John Youn05ee7992016-11-03 17:56:05 -0700335
336 /*
337 * The values for g_rx_fifo_size (2048) and
338 * g_np_tx_fifo_size (1024) come from the legacy s3c
339 * gadget driver. These defaults have been hard-coded
340 * for some time so many platforms depend on these
341 * values. Leave them as defaults for now and only
342 * auto-detect if the hardware does not support the
343 * default.
344 */
John Youn245977c2017-01-23 14:55:14 -0800345 p->g_rx_fifo_size = 2048;
346 p->g_np_tx_fifo_size = 1024;
John Youn05ee7992016-11-03 17:56:05 -0700347 dwc2_set_param_tx_fifo_sizes(hsotg);
348 }
John Youn323230e2016-11-03 17:55:50 -0700349}
350
John Younf9f93cb2017-01-23 14:55:35 -0800351/**
352 * dwc2_get_device_properties() - Read in device properties.
353 *
Grigor Tovmasyan6fb914d2018-05-16 12:04:24 +0400354 * @hsotg: Programming view of the DWC_otg controller
355 *
John Younf9f93cb2017-01-23 14:55:35 -0800356 * Read in the device properties and adjust core parameters if needed.
357 */
358static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg)
359{
360 struct dwc2_core_params *p = &hsotg->params;
361 int num;
362
363 if ((hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) ||
364 (hsotg->dr_mode == USB_DR_MODE_OTG)) {
365 device_property_read_u32(hsotg->dev, "g-rx-fifo-size",
366 &p->g_rx_fifo_size);
367
368 device_property_read_u32(hsotg->dev, "g-np-tx-fifo-size",
369 &p->g_np_tx_fifo_size);
370
371 num = device_property_read_u32_array(hsotg->dev,
372 "g-tx-fifo-size",
373 NULL, 0);
374
375 if (num > 0) {
376 num = min(num, 15);
377 memset(p->g_tx_fifo_size, 0,
378 sizeof(p->g_tx_fifo_size));
379 device_property_read_u32_array(hsotg->dev,
380 "g-tx-fifo-size",
381 &p->g_tx_fifo_size[1],
382 num);
383 }
384 }
Dinh Nguyenb11633c2017-10-16 08:57:18 -0500385
386 if (of_find_property(hsotg->dev->of_node, "disable-over-current", NULL))
387 p->oc_disable = true;
John Younf9f93cb2017-01-23 14:55:35 -0800388}
389
John Yound936e662017-01-23 14:56:43 -0800390static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg)
391{
392 int valid = 1;
393
394 switch (hsotg->params.otg_cap) {
395 case DWC2_CAP_PARAM_HNP_SRP_CAPABLE:
396 if (hsotg->hw_params.op_mode != GHWCFG2_OP_MODE_HNP_SRP_CAPABLE)
397 valid = 0;
398 break;
399 case DWC2_CAP_PARAM_SRP_ONLY_CAPABLE:
400 switch (hsotg->hw_params.op_mode) {
401 case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE:
402 case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE:
403 case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE:
404 case GHWCFG2_OP_MODE_SRP_CAPABLE_HOST:
405 break;
406 default:
407 valid = 0;
408 break;
409 }
410 break;
411 case DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE:
412 /* always valid */
413 break;
414 default:
415 valid = 0;
416 break;
417 }
418
419 if (!valid)
420 dwc2_set_param_otg_cap(hsotg);
421}
422
423static void dwc2_check_param_phy_type(struct dwc2_hsotg *hsotg)
424{
425 int valid = 0;
426 u32 hs_phy_type;
427 u32 fs_phy_type;
428
429 hs_phy_type = hsotg->hw_params.hs_phy_type;
430 fs_phy_type = hsotg->hw_params.fs_phy_type;
431
432 switch (hsotg->params.phy_type) {
433 case DWC2_PHY_TYPE_PARAM_FS:
434 if (fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED)
435 valid = 1;
436 break;
437 case DWC2_PHY_TYPE_PARAM_UTMI:
438 if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI) ||
439 (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI_ULPI))
440 valid = 1;
441 break;
442 case DWC2_PHY_TYPE_PARAM_ULPI:
443 if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI) ||
444 (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI_ULPI))
445 valid = 1;
446 break;
447 default:
448 break;
449 }
450
451 if (!valid)
452 dwc2_set_param_phy_type(hsotg);
453}
454
455static void dwc2_check_param_speed(struct dwc2_hsotg *hsotg)
456{
457 int valid = 1;
458 int phy_type = hsotg->params.phy_type;
459 int speed = hsotg->params.speed;
460
461 switch (speed) {
462 case DWC2_SPEED_PARAM_HIGH:
463 if ((hsotg->params.speed == DWC2_SPEED_PARAM_HIGH) &&
464 (phy_type == DWC2_PHY_TYPE_PARAM_FS))
465 valid = 0;
466 break;
467 case DWC2_SPEED_PARAM_FULL:
468 case DWC2_SPEED_PARAM_LOW:
469 break;
470 default:
471 valid = 0;
472 break;
473 }
474
475 if (!valid)
476 dwc2_set_param_speed(hsotg);
477}
478
479static void dwc2_check_param_phy_utmi_width(struct dwc2_hsotg *hsotg)
480{
481 int valid = 0;
482 int param = hsotg->params.phy_utmi_width;
483 int width = hsotg->hw_params.utmi_phy_data_width;
484
485 switch (width) {
486 case GHWCFG4_UTMI_PHY_DATA_WIDTH_8:
487 valid = (param == 8);
488 break;
489 case GHWCFG4_UTMI_PHY_DATA_WIDTH_16:
490 valid = (param == 16);
491 break;
492 case GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16:
493 valid = (param == 8 || param == 16);
494 break;
495 }
496
497 if (!valid)
498 dwc2_set_param_phy_utmi_width(hsotg);
499}
500
Vardan Mikayelyan631a2312018-02-16 14:07:05 +0400501static void dwc2_check_param_power_down(struct dwc2_hsotg *hsotg)
502{
503 int param = hsotg->params.power_down;
504
505 switch (param) {
506 case DWC2_POWER_DOWN_PARAM_NONE:
507 break;
508 case DWC2_POWER_DOWN_PARAM_PARTIAL:
509 if (hsotg->hw_params.power_optimized)
510 break;
511 dev_dbg(hsotg->dev,
512 "Partial power down isn't supported by HW\n");
513 param = DWC2_POWER_DOWN_PARAM_NONE;
514 break;
515 case DWC2_POWER_DOWN_PARAM_HIBERNATION:
516 if (hsotg->hw_params.hibernation)
517 break;
518 dev_dbg(hsotg->dev,
519 "Hibernation isn't supported by HW\n");
520 param = DWC2_POWER_DOWN_PARAM_NONE;
521 break;
522 default:
523 dev_err(hsotg->dev,
524 "%s: Invalid parameter power_down=%d\n",
525 __func__, param);
526 param = DWC2_POWER_DOWN_PARAM_NONE;
527 break;
528 }
529
530 hsotg->params.power_down = param;
531}
532
Sevak Arakelyan3c6aea72017-01-23 15:01:45 -0800533static void dwc2_check_param_tx_fifo_sizes(struct dwc2_hsotg *hsotg)
534{
535 int fifo_count;
536 int fifo;
537 int min;
538 u32 total = 0;
539 u32 dptxfszn;
540
541 fifo_count = dwc2_hsotg_tx_fifo_count(hsotg);
542 min = hsotg->hw_params.en_multiple_tx_fifo ? 16 : 4;
543
544 for (fifo = 1; fifo <= fifo_count; fifo++)
545 total += hsotg->params.g_tx_fifo_size[fifo];
546
547 if (total > dwc2_hsotg_tx_fifo_total_depth(hsotg) || !total) {
548 dev_warn(hsotg->dev, "%s: Invalid parameter g-tx-fifo-size, setting to default average\n",
549 __func__);
550 dwc2_set_param_tx_fifo_sizes(hsotg);
551 }
552
553 for (fifo = 1; fifo <= fifo_count; fifo++) {
Minas Harutyunyan92730832017-11-30 12:16:37 +0400554 dptxfszn = hsotg->hw_params.g_tx_fifo_size[fifo];
Sevak Arakelyan3c6aea72017-01-23 15:01:45 -0800555
556 if (hsotg->params.g_tx_fifo_size[fifo] < min ||
557 hsotg->params.g_tx_fifo_size[fifo] > dptxfszn) {
558 dev_warn(hsotg->dev, "%s: Invalid parameter g_tx_fifo_size[%d]=%d\n",
559 __func__, fifo,
560 hsotg->params.g_tx_fifo_size[fifo]);
561 hsotg->params.g_tx_fifo_size[fifo] = dptxfszn;
562 }
563 }
564}
565
John Yound936e662017-01-23 14:56:43 -0800566#define CHECK_RANGE(_param, _min, _max, _def) do { \
Grigor Tovmasyan47265c02018-04-03 15:22:25 +0400567 if ((int)(hsotg->params._param) < (_min) || \
John Yound936e662017-01-23 14:56:43 -0800568 (hsotg->params._param) > (_max)) { \
569 dev_warn(hsotg->dev, "%s: Invalid parameter %s=%d\n", \
570 __func__, #_param, hsotg->params._param); \
571 hsotg->params._param = (_def); \
572 } \
573 } while (0)
574
575#define CHECK_BOOL(_param, _check) do { \
576 if (hsotg->params._param && !(_check)) { \
577 dev_warn(hsotg->dev, "%s: Invalid parameter %s=%d\n", \
578 __func__, #_param, hsotg->params._param); \
579 hsotg->params._param = false; \
580 } \
581 } while (0)
582
583static void dwc2_check_params(struct dwc2_hsotg *hsotg)
584{
585 struct dwc2_hw_params *hw = &hsotg->hw_params;
586 struct dwc2_core_params *p = &hsotg->params;
587 bool dma_capable = !(hw->arch == GHWCFG2_SLAVE_ONLY_ARCH);
588
589 dwc2_check_param_otg_cap(hsotg);
590 dwc2_check_param_phy_type(hsotg);
591 dwc2_check_param_speed(hsotg);
592 dwc2_check_param_phy_utmi_width(hsotg);
Vardan Mikayelyan631a2312018-02-16 14:07:05 +0400593 dwc2_check_param_power_down(hsotg);
John Yound936e662017-01-23 14:56:43 -0800594 CHECK_BOOL(enable_dynamic_fifo, hw->enable_dynamic_fifo);
595 CHECK_BOOL(en_multiple_tx_fifo, hw->en_multiple_tx_fifo);
596 CHECK_BOOL(i2c_enable, hw->i2c_enable);
Grigor Tovmasyanb43ebc92018-05-05 12:17:58 +0400597 CHECK_BOOL(ipg_isoc_en, hw->ipg_isoc_en);
Razmik Karapetyan66e77a22018-01-24 17:40:29 +0400598 CHECK_BOOL(acg_enable, hw->acg_enable);
John Yound936e662017-01-23 14:56:43 -0800599 CHECK_BOOL(reload_ctl, (hsotg->hw_params.snpsid > DWC2_CORE_REV_2_92a));
Sevak Arakelyan6f80b6d2018-01-24 17:41:48 +0400600 CHECK_BOOL(lpm, (hsotg->hw_params.snpsid >= DWC2_CORE_REV_2_80a));
601 CHECK_BOOL(lpm, hw->lpm_mode);
602 CHECK_BOOL(lpm_clock_gating, hsotg->params.lpm);
603 CHECK_BOOL(besl, hsotg->params.lpm);
604 CHECK_BOOL(besl, (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a));
605 CHECK_BOOL(hird_threshold_en, hsotg->params.lpm);
606 CHECK_RANGE(hird_threshold, 0, hsotg->params.besl ? 12 : 7, 0);
Grigor Tovmasyanca531bc2018-08-29 20:59:34 +0400607 CHECK_BOOL(service_interval, hw->service_interval_mode);
John Yound936e662017-01-23 14:56:43 -0800608 CHECK_RANGE(max_packet_count,
609 15, hw->max_packet_count,
610 hw->max_packet_count);
611 CHECK_RANGE(max_transfer_size,
612 2047, hw->max_transfer_size,
613 hw->max_transfer_size);
614
615 if ((hsotg->dr_mode == USB_DR_MODE_HOST) ||
616 (hsotg->dr_mode == USB_DR_MODE_OTG)) {
617 CHECK_BOOL(host_dma, dma_capable);
618 CHECK_BOOL(dma_desc_enable, p->host_dma);
619 CHECK_BOOL(dma_desc_fs_enable, p->dma_desc_enable);
620 CHECK_BOOL(host_ls_low_power_phy_clk,
621 p->phy_type == DWC2_PHY_TYPE_PARAM_FS);
622 CHECK_RANGE(host_channels,
623 1, hw->host_channels,
624 hw->host_channels);
625 CHECK_RANGE(host_rx_fifo_size,
626 16, hw->rx_fifo_size,
627 hw->rx_fifo_size);
628 CHECK_RANGE(host_nperio_tx_fifo_size,
629 16, hw->host_nperio_tx_fifo_size,
630 hw->host_nperio_tx_fifo_size);
631 CHECK_RANGE(host_perio_tx_fifo_size,
632 16, hw->host_perio_tx_fifo_size,
633 hw->host_perio_tx_fifo_size);
634 }
635
636 if ((hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) ||
637 (hsotg->dr_mode == USB_DR_MODE_OTG)) {
638 CHECK_BOOL(g_dma, dma_capable);
639 CHECK_BOOL(g_dma_desc, (p->g_dma && hw->dma_desc_enable));
640 CHECK_RANGE(g_rx_fifo_size,
641 16, hw->rx_fifo_size,
642 hw->rx_fifo_size);
643 CHECK_RANGE(g_np_tx_fifo_size,
644 16, hw->dev_nperio_tx_fifo_size,
645 hw->dev_nperio_tx_fifo_size);
Sevak Arakelyan3c6aea72017-01-23 15:01:45 -0800646 dwc2_check_param_tx_fifo_sizes(hsotg);
John Yound936e662017-01-23 14:56:43 -0800647 }
648}
649
John Youn323230e2016-11-03 17:55:50 -0700650/*
651 * Gets host hardware parameters. Forces host mode if not currently in
652 * host mode. Should be called immediately after a core soft reset in
653 * order to get the reset values.
654 */
655static void dwc2_get_host_hwparams(struct dwc2_hsotg *hsotg)
656{
657 struct dwc2_hw_params *hw = &hsotg->hw_params;
658 u32 gnptxfsiz;
659 u32 hptxfsiz;
John Youn323230e2016-11-03 17:55:50 -0700660
661 if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
662 return;
663
Vardan Mikayelyan13b1f8e2018-02-16 12:56:03 +0400664 dwc2_force_mode(hsotg, true);
John Youn323230e2016-11-03 17:55:50 -0700665
Gevorg Sahakyanf25c42b2018-07-26 18:00:13 +0400666 gnptxfsiz = dwc2_readl(hsotg, GNPTXFSIZ);
667 hptxfsiz = dwc2_readl(hsotg, HPTXFSIZ);
John Youn323230e2016-11-03 17:55:50 -0700668
John Youn323230e2016-11-03 17:55:50 -0700669 hw->host_nperio_tx_fifo_size = (gnptxfsiz & FIFOSIZE_DEPTH_MASK) >>
670 FIFOSIZE_DEPTH_SHIFT;
671 hw->host_perio_tx_fifo_size = (hptxfsiz & FIFOSIZE_DEPTH_MASK) >>
672 FIFOSIZE_DEPTH_SHIFT;
673}
674
675/*
676 * Gets device hardware parameters. Forces device mode if not
677 * currently in device mode. Should be called immediately after a core
678 * soft reset in order to get the reset values.
679 */
680static void dwc2_get_dev_hwparams(struct dwc2_hsotg *hsotg)
681{
682 struct dwc2_hw_params *hw = &hsotg->hw_params;
John Youn323230e2016-11-03 17:55:50 -0700683 u32 gnptxfsiz;
Minas Harutyunyan92730832017-11-30 12:16:37 +0400684 int fifo, fifo_count;
John Youn323230e2016-11-03 17:55:50 -0700685
686 if (hsotg->dr_mode == USB_DR_MODE_HOST)
687 return;
688
Vardan Mikayelyan13b1f8e2018-02-16 12:56:03 +0400689 dwc2_force_mode(hsotg, false);
John Youn323230e2016-11-03 17:55:50 -0700690
Gevorg Sahakyanf25c42b2018-07-26 18:00:13 +0400691 gnptxfsiz = dwc2_readl(hsotg, GNPTXFSIZ);
John Youn323230e2016-11-03 17:55:50 -0700692
Minas Harutyunyan92730832017-11-30 12:16:37 +0400693 fifo_count = dwc2_hsotg_tx_fifo_count(hsotg);
694
695 for (fifo = 1; fifo <= fifo_count; fifo++) {
696 hw->g_tx_fifo_size[fifo] =
Gevorg Sahakyanf25c42b2018-07-26 18:00:13 +0400697 (dwc2_readl(hsotg, DPTXFSIZN(fifo)) &
Minas Harutyunyan92730832017-11-30 12:16:37 +0400698 FIFOSIZE_DEPTH_MASK) >> FIFOSIZE_DEPTH_SHIFT;
699 }
700
John Youn323230e2016-11-03 17:55:50 -0700701 hw->dev_nperio_tx_fifo_size = (gnptxfsiz & FIFOSIZE_DEPTH_MASK) >>
702 FIFOSIZE_DEPTH_SHIFT;
703}
704
705/**
706 * During device initialization, read various hardware configuration
707 * registers and interpret the contents.
Grigor Tovmasyan6fb914d2018-05-16 12:04:24 +0400708 *
709 * @hsotg: Programming view of the DWC_otg controller
710 *
John Youn323230e2016-11-03 17:55:50 -0700711 */
712int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
713{
714 struct dwc2_hw_params *hw = &hsotg->hw_params;
715 unsigned int width;
716 u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4;
717 u32 grxfsiz;
718
719 /*
720 * Attempt to ensure this device is really a DWC_otg Controller.
721 * Read and verify the GSNPSID register contents. The value should be
Gevorg Sahakyand14ccab2018-01-16 16:21:46 +0400722 * 0x45f4xxxx, 0x5531xxxx or 0x5532xxxx
John Youn323230e2016-11-03 17:55:50 -0700723 */
Gevorg Sahakyand14ccab2018-01-16 16:21:46 +0400724
Gevorg Sahakyanf25c42b2018-07-26 18:00:13 +0400725 hw->snpsid = dwc2_readl(hsotg, GSNPSID);
Gevorg Sahakyand14ccab2018-01-16 16:21:46 +0400726 if ((hw->snpsid & GSNPSID_ID_MASK) != DWC2_OTG_ID &&
727 (hw->snpsid & GSNPSID_ID_MASK) != DWC2_FS_IOT_ID &&
728 (hw->snpsid & GSNPSID_ID_MASK) != DWC2_HS_IOT_ID) {
John Youn323230e2016-11-03 17:55:50 -0700729 dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n",
730 hw->snpsid);
731 return -ENODEV;
732 }
733
734 dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x (snpsid=%x)\n",
735 hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf,
736 hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid);
737
Gevorg Sahakyanf25c42b2018-07-26 18:00:13 +0400738 hwcfg1 = dwc2_readl(hsotg, GHWCFG1);
739 hwcfg2 = dwc2_readl(hsotg, GHWCFG2);
740 hwcfg3 = dwc2_readl(hsotg, GHWCFG3);
741 hwcfg4 = dwc2_readl(hsotg, GHWCFG4);
742 grxfsiz = dwc2_readl(hsotg, GRXFSIZ);
John Youn323230e2016-11-03 17:55:50 -0700743
John Youn323230e2016-11-03 17:55:50 -0700744 /* hwcfg1 */
745 hw->dev_ep_dirs = hwcfg1;
746
747 /* hwcfg2 */
748 hw->op_mode = (hwcfg2 & GHWCFG2_OP_MODE_MASK) >>
749 GHWCFG2_OP_MODE_SHIFT;
750 hw->arch = (hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >>
751 GHWCFG2_ARCHITECTURE_SHIFT;
752 hw->enable_dynamic_fifo = !!(hwcfg2 & GHWCFG2_DYNAMIC_FIFO);
753 hw->host_channels = 1 + ((hwcfg2 & GHWCFG2_NUM_HOST_CHAN_MASK) >>
754 GHWCFG2_NUM_HOST_CHAN_SHIFT);
755 hw->hs_phy_type = (hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >>
756 GHWCFG2_HS_PHY_TYPE_SHIFT;
757 hw->fs_phy_type = (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >>
758 GHWCFG2_FS_PHY_TYPE_SHIFT;
759 hw->num_dev_ep = (hwcfg2 & GHWCFG2_NUM_DEV_EP_MASK) >>
760 GHWCFG2_NUM_DEV_EP_SHIFT;
761 hw->nperio_tx_q_depth =
762 (hwcfg2 & GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK) >>
763 GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT << 1;
764 hw->host_perio_tx_q_depth =
765 (hwcfg2 & GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK) >>
766 GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT << 1;
767 hw->dev_token_q_depth =
768 (hwcfg2 & GHWCFG2_DEV_TOKEN_Q_DEPTH_MASK) >>
769 GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT;
770
771 /* hwcfg3 */
772 width = (hwcfg3 & GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK) >>
773 GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT;
774 hw->max_transfer_size = (1 << (width + 11)) - 1;
775 width = (hwcfg3 & GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK) >>
776 GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT;
777 hw->max_packet_count = (1 << (width + 4)) - 1;
778 hw->i2c_enable = !!(hwcfg3 & GHWCFG3_I2C);
779 hw->total_fifo_size = (hwcfg3 & GHWCFG3_DFIFO_DEPTH_MASK) >>
780 GHWCFG3_DFIFO_DEPTH_SHIFT;
Sevak Arakelyan6f80b6d2018-01-24 17:41:48 +0400781 hw->lpm_mode = !!(hwcfg3 & GHWCFG3_OTG_LPM_EN);
John Youn323230e2016-11-03 17:55:50 -0700782
783 /* hwcfg4 */
784 hw->en_multiple_tx_fifo = !!(hwcfg4 & GHWCFG4_DED_FIFO_EN);
785 hw->num_dev_perio_in_ep = (hwcfg4 & GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK) >>
786 GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT;
Minas Harutyunyan92730832017-11-30 12:16:37 +0400787 hw->num_dev_in_eps = (hwcfg4 & GHWCFG4_NUM_IN_EPS_MASK) >>
788 GHWCFG4_NUM_IN_EPS_SHIFT;
John Youn323230e2016-11-03 17:55:50 -0700789 hw->dma_desc_enable = !!(hwcfg4 & GHWCFG4_DESC_DMA);
790 hw->power_optimized = !!(hwcfg4 & GHWCFG4_POWER_OPTIMIZ);
Vardan Mikayelyan631a2312018-02-16 14:07:05 +0400791 hw->hibernation = !!(hwcfg4 & GHWCFG4_HIBER);
John Youn323230e2016-11-03 17:55:50 -0700792 hw->utmi_phy_data_width = (hwcfg4 & GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK) >>
793 GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT;
Razmik Karapetyan66e77a22018-01-24 17:40:29 +0400794 hw->acg_enable = !!(hwcfg4 & GHWCFG4_ACG_SUPPORTED);
Grigor Tovmasyanb43ebc92018-05-05 12:17:58 +0400795 hw->ipg_isoc_en = !!(hwcfg4 & GHWCFG4_IPG_ISOC_SUPPORTED);
Grigor Tovmasyanca531bc2018-08-29 20:59:34 +0400796 hw->service_interval_mode = !!(hwcfg4 &
797 GHWCFG4_SERVICE_INTERVAL_SUPPORTED);
John Youn323230e2016-11-03 17:55:50 -0700798
799 /* fifo sizes */
John Yound1531312016-11-03 17:56:02 -0700800 hw->rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >>
John Youn323230e2016-11-03 17:55:50 -0700801 GRXFSIZ_DEPTH_SHIFT;
Minas Harutyunyan92730832017-11-30 12:16:37 +0400802 /*
803 * Host specific hardware parameters. Reading these parameters
804 * requires the controller to be in host mode. The mode will
805 * be forced, if necessary, to read these values.
806 */
807 dwc2_get_host_hwparams(hsotg);
808 dwc2_get_dev_hwparams(hsotg);
John Youn323230e2016-11-03 17:55:50 -0700809
John Youn323230e2016-11-03 17:55:50 -0700810 return 0;
811}
812
John Youn334bbd42016-11-03 17:55:55 -0700813int dwc2_init_params(struct dwc2_hsotg *hsotg)
814{
John Youn7de1deb2017-01-23 14:57:04 -0800815 const struct of_device_id *match;
816 void (*set_params)(void *data);
817
John Youn245977c2017-01-23 14:55:14 -0800818 dwc2_set_default_params(hsotg);
John Younf9f93cb2017-01-23 14:55:35 -0800819 dwc2_get_device_properties(hsotg);
John Youn334bbd42016-11-03 17:55:55 -0700820
John Youn7de1deb2017-01-23 14:57:04 -0800821 match = of_match_device(dwc2_of_match_table, hsotg->dev);
822 if (match && match->data) {
823 set_params = match->data;
824 set_params(hsotg);
825 }
826
John Yound936e662017-01-23 14:56:43 -0800827 dwc2_check_params(hsotg);
828
John Youn334bbd42016-11-03 17:55:55 -0700829 return 0;
830}