aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2013-08-30 12:45:22 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-30 17:14:53 -0400
commitde4a1931939891db633fbc3c33e953dd58f94294 (patch)
tree3fbe1e90f4e9ec9b83b685ad9acd0d7d76f37396 /drivers/staging
parent9badec2f9fa9209ceb3bd427972299d69a37d8ee (diff)
staging: dwc2: validate the value for phy_utmi_width
The HWCFG4 register stores the supported utmi width values (8, 16 or both). This commit reads that value and validates the configured value against that. If no (valid) value is given, the parameter defaulted to 8 bits previously. However, the documentation for dwc2_core_params_struct suggests that the default should have been 16. Also, the pci bindings explicitely set the value to 16, so this commit changes the default to 16 bits (if supported, 8 bits otherwise). With the default changed, the value set in pci.c is changed to -1 to make it autodetected as well. Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl> Acked-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/dwc2/core.c27
-rw-r--r--drivers/staging/dwc2/core.h5
-rw-r--r--drivers/staging/dwc2/hw.h3
-rw-r--r--drivers/staging/dwc2/pci.c2
4 files changed, 32 insertions, 5 deletions
diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 825c5e5f157f..06dae67a9d62 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -2376,14 +2376,29 @@ int dwc2_set_param_phy_ulpi_ext_vbus(struct dwc2_hsotg *hsotg, int val)
2376 2376
2377int dwc2_set_param_phy_utmi_width(struct dwc2_hsotg *hsotg, int val) 2377int dwc2_set_param_phy_utmi_width(struct dwc2_hsotg *hsotg, int val)
2378{ 2378{
2379 int valid = 0;
2379 int retval = 0; 2380 int retval = 0;
2380 2381
2381 if (DWC2_PARAM_TEST(val, 8, 8) && DWC2_PARAM_TEST(val, 16, 16)) { 2382 switch (hsotg->hw_params.utmi_phy_data_width) {
2383 case GHWCFG4_UTMI_PHY_DATA_WIDTH_8:
2384 valid = (val == 8);
2385 break;
2386 case GHWCFG4_UTMI_PHY_DATA_WIDTH_16:
2387 valid = (val == 16);
2388 break;
2389 case GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16:
2390 valid = (val == 8 || val == 16);
2391 break;
2392 }
2393
2394 if (!valid) {
2382 if (val >= 0) { 2395 if (val >= 0) {
2383 dev_err(hsotg->dev, "Wrong value for phy_utmi_width\n"); 2396 dev_err(hsotg->dev,
2384 dev_err(hsotg->dev, "phy_utmi_width must be 8 or 16\n"); 2397 "%d invalid for phy_utmi_width. Check HW configuration.\n",
2398 val);
2385 } 2399 }
2386 val = 8; 2400 val = (hsotg->hw_params.utmi_phy_data_width ==
2401 GHWCFG4_UTMI_PHY_DATA_WIDTH_8) ? 8 : 16;
2387 dev_dbg(hsotg->dev, "Setting phy_utmi_width to %d\n", val); 2402 dev_dbg(hsotg->dev, "Setting phy_utmi_width to %d\n", val);
2388 retval = -EINVAL; 2403 retval = -EINVAL;
2389 } 2404 }
@@ -2660,6 +2675,8 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
2660 GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT; 2675 GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT;
2661 hw->dma_desc_enable = !!(hwcfg4 & GHWCFG4_DESC_DMA); 2676 hw->dma_desc_enable = !!(hwcfg4 & GHWCFG4_DESC_DMA);
2662 hw->power_optimized = !!(hwcfg4 & GHWCFG4_POWER_OPTIMIZ); 2677 hw->power_optimized = !!(hwcfg4 & GHWCFG4_POWER_OPTIMIZ);
2678 hw->utmi_phy_data_width = (hwcfg4 & GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK) >>
2679 GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT;
2663 2680
2664 /* fifo sizes */ 2681 /* fifo sizes */
2665 hw->host_rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >> 2682 hw->host_rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >>
@@ -2684,6 +2701,8 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
2684 hw->hs_phy_type); 2701 hw->hs_phy_type);
2685 dev_dbg(hsotg->dev, " fs_phy_type=%d\n", 2702 dev_dbg(hsotg->dev, " fs_phy_type=%d\n",
2686 hw->fs_phy_type); 2703 hw->fs_phy_type);
2704 dev_dbg(hsotg->dev, " utmi_phy_data_wdith=%d\n",
2705 hw->utmi_phy_data_width);
2687 dev_dbg(hsotg->dev, " num_dev_ep=%d\n", 2706 dev_dbg(hsotg->dev, " num_dev_ep=%d\n",
2688 hw->num_dev_ep); 2707 hw->num_dev_ep);
2689 dev_dbg(hsotg->dev, " num_dev_perio_in_ep=%d\n", 2708 dev_dbg(hsotg->dev, " num_dev_perio_in_ep=%d\n",
diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index e4eb3a0d0b5b..ecfcad83f767 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -239,6 +239,10 @@ struct dwc2_core_params {
239 * 2 - FS pins shared with UTMI+ pins 239 * 2 - FS pins shared with UTMI+ pins
240 * 3 - FS pins shared with ULPI pins 240 * 3 - FS pins shared with ULPI pins
241 * @total_fifo_size: Total internal RAM for FIFOs (bytes) 241 * @total_fifo_size: Total internal RAM for FIFOs (bytes)
242 * @utmi_phy_data_width UTMI+ PHY data width
243 * 0 - 8 bits
244 * 1 - 16 bits
245 * 2 - 8 or 16 bits
242 * @snpsid: Value from SNPSID register 246 * @snpsid: Value from SNPSID register
243 */ 247 */
244struct dwc2_hw_params { 248struct dwc2_hw_params {
@@ -263,6 +267,7 @@ struct dwc2_hw_params {
263 unsigned num_dev_perio_in_ep:4; 267 unsigned num_dev_perio_in_ep:4;
264 unsigned total_fifo_size:16; 268 unsigned total_fifo_size:16;
265 unsigned power_optimized:1; 269 unsigned power_optimized:1;
270 unsigned utmi_phy_data_width:2;
266 u32 snpsid; 271 u32 snpsid;
267}; 272};
268 273
diff --git a/drivers/staging/dwc2/hw.h b/drivers/staging/dwc2/hw.h
index fafdc199b2b5..9c92a3c7588a 100644
--- a/drivers/staging/dwc2/hw.h
+++ b/drivers/staging/dwc2/hw.h
@@ -302,6 +302,9 @@
302#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_SHIFT 16 302#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_SHIFT 16
303#define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK (0x3 << 14) 303#define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK (0x3 << 14)
304#define GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT 14 304#define GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT 14
305#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8 0
306#define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1
307#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16 2
305#define GHWCFG4_XHIBER (1 << 7) 308#define GHWCFG4_XHIBER (1 << 7)
306#define GHWCFG4_HIBER (1 << 6) 309#define GHWCFG4_HIBER (1 << 6)
307#define GHWCFG4_MIN_AHB_FREQ (1 << 5) 310#define GHWCFG4_MIN_AHB_FREQ (1 << 5)
diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index fdfbc719663c..9020260d5df8 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -74,7 +74,7 @@ static const struct dwc2_core_params dwc2_module_params = {
74 .max_packet_count = 511, 74 .max_packet_count = 511,
75 .host_channels = -1, 75 .host_channels = -1,
76 .phy_type = -1, 76 .phy_type = -1,
77 .phy_utmi_width = 16, /* 16 bits - NOT DETECTABLE */ 77 .phy_utmi_width = -1,
78 .phy_ulpi_ddr = -1, 78 .phy_ulpi_ddr = -1,
79 .phy_ulpi_ext_vbus = -1, 79 .phy_ulpi_ext_vbus = -1,
80 .i2c_enable = -1, 80 .i2c_enable = -1,