| .. | .. |
|---|
| 59 | 59 | PHY_STATE_DISCONNECT = 1, |
|---|
| 60 | 60 | PHY_STATE_CONNECT = 2, |
|---|
| 61 | 61 | PHY_STATE_FS_LS_ONLINE = 4, |
|---|
| 62 | + PHY_STATE_SE1 = 6, |
|---|
| 62 | 63 | }; |
|---|
| 63 | 64 | |
|---|
| 64 | 65 | /** |
|---|
| .. | .. |
|---|
| 158 | 159 | * @utmi_ls: utmi linestate state register. |
|---|
| 159 | 160 | * @utmi_hstdet: utmi host disconnect register. |
|---|
| 160 | 161 | * @vbus_det_en: vbus detect function power down register. |
|---|
| 162 | + * @port_ls_filter_con: set linestate filter time for otg port or host port. |
|---|
| 161 | 163 | */ |
|---|
| 162 | 164 | struct rockchip_usb2phy_port_cfg { |
|---|
| 163 | 165 | struct usb2phy_reg phy_sus; |
|---|
| .. | .. |
|---|
| 188 | 190 | struct usb2phy_reg utmi_ls; |
|---|
| 189 | 191 | struct usb2phy_reg utmi_hstdet; |
|---|
| 190 | 192 | struct usb2phy_reg vbus_det_en; |
|---|
| 193 | + struct usb2phy_reg port_ls_filter_con; |
|---|
| 191 | 194 | }; |
|---|
| 192 | 195 | |
|---|
| 193 | 196 | /** |
|---|
| .. | .. |
|---|
| 196 | 199 | * @num_ports: specify how many ports that the phy has. |
|---|
| 197 | 200 | * @phy_tuning: phy default parameters tunning. |
|---|
| 198 | 201 | * @vbus_detect: vbus voltage level detection function. |
|---|
| 199 | | - * @clkout_ctl: keep on/turn off output clk of phy. |
|---|
| 202 | + * @clkout_ctl: keep on/turn off output clk of phy via commonon bit. |
|---|
| 203 | + * @clkout_ctl_phy: keep on/turn off output clk of phy via phy inner |
|---|
| 204 | + * debug register. |
|---|
| 200 | 205 | * @ls_filter_con: set linestate filter time. |
|---|
| 201 | 206 | * @chg_det: charger detection registers. |
|---|
| 202 | 207 | */ |
|---|
| .. | .. |
|---|
| 204 | 209 | unsigned int reg; |
|---|
| 205 | 210 | unsigned int num_ports; |
|---|
| 206 | 211 | int (*phy_tuning)(struct rockchip_usb2phy *); |
|---|
| 207 | | - int (*vbus_detect)(struct rockchip_usb2phy *rphy, bool en); |
|---|
| 212 | + int (*vbus_detect)(struct rockchip_usb2phy *rphy, |
|---|
| 213 | + const struct usb2phy_reg *vbus_det_en, |
|---|
| 214 | + bool en); |
|---|
| 208 | 215 | struct usb2phy_reg clkout_ctl; |
|---|
| 216 | + struct usb2phy_reg clkout_ctl_phy; |
|---|
| 209 | 217 | struct usb2phy_reg ls_filter_con; |
|---|
| 210 | 218 | const struct rockchip_usb2phy_port_cfg port_cfgs[USB2PHY_NUM_PORTS]; |
|---|
| 211 | 219 | const struct rockchip_chg_det_reg chg_det; |
|---|
| .. | .. |
|---|
| 253 | 261 | bool vbus_always_on; |
|---|
| 254 | 262 | bool vbus_enabled; |
|---|
| 255 | 263 | bool bypass_uart_en; |
|---|
| 264 | + bool dis_u2_susphy; |
|---|
| 256 | 265 | int bvalid_irq; |
|---|
| 257 | 266 | int ls_irq; |
|---|
| 258 | 267 | int id_irq; |
|---|
| .. | .. |
|---|
| 275 | 284 | * @grf: General Register Files regmap. |
|---|
| 276 | 285 | * @usbgrf: USB General Register Files regmap. |
|---|
| 277 | 286 | * *phy_base: the base address of USB PHY. |
|---|
| 278 | | - * @clk: clock struct of phy input clk. |
|---|
| 287 | + * @clks: array of phy input clocks. |
|---|
| 279 | 288 | * @clk480m: clock struct of phy output clk. |
|---|
| 280 | 289 | * @clk_hw: clock struct of phy output clk management. |
|---|
| 290 | + * @num_clks: number of phy input clocks. |
|---|
| 281 | 291 | * @chg_state: states involved in USB charger detection. |
|---|
| 282 | 292 | * @chg_type: USB charger types. |
|---|
| 283 | 293 | * @dcd_retries: The retry count used to track Data contact |
|---|
| .. | .. |
|---|
| 297 | 307 | struct regmap *grf; |
|---|
| 298 | 308 | struct regmap *usbgrf; |
|---|
| 299 | 309 | void __iomem *phy_base; |
|---|
| 300 | | - struct clk *clk; |
|---|
| 310 | + struct clk_bulk_data *clks; |
|---|
| 301 | 311 | struct clk *clk480m; |
|---|
| 302 | 312 | struct clk_hw clk480m_hw; |
|---|
| 313 | + int num_clks; |
|---|
| 303 | 314 | enum usb_chg_state chg_state; |
|---|
| 304 | 315 | enum power_supply_type chg_type; |
|---|
| 305 | 316 | u8 dcd_retries; |
|---|
| .. | .. |
|---|
| 344 | 355 | return tmp == reg->enable; |
|---|
| 345 | 356 | } |
|---|
| 346 | 357 | |
|---|
| 358 | +static inline void phy_property_enable(void __iomem *base, |
|---|
| 359 | + const struct usb2phy_reg *reg, bool en) |
|---|
| 360 | +{ |
|---|
| 361 | + unsigned int val, tmp; |
|---|
| 362 | + |
|---|
| 363 | + val = readl(base + reg->offset); |
|---|
| 364 | + tmp = en ? reg->enable : reg->disable; |
|---|
| 365 | + val &= ~GENMASK(reg->bitend, reg->bitstart); |
|---|
| 366 | + val |= tmp << reg->bitstart; |
|---|
| 367 | + writel(val, base + reg->offset); |
|---|
| 368 | +} |
|---|
| 369 | + |
|---|
| 370 | +static inline bool phy_property_enabled(void __iomem *base, |
|---|
| 371 | + const struct usb2phy_reg *reg) |
|---|
| 372 | +{ |
|---|
| 373 | + unsigned int orig, tmp; |
|---|
| 374 | + unsigned int mask = GENMASK(reg->bitend, reg->bitstart); |
|---|
| 375 | + |
|---|
| 376 | + orig = readl(base + reg->offset); |
|---|
| 377 | + tmp = (orig & mask) >> reg->bitstart; |
|---|
| 378 | + return tmp == reg->enable; |
|---|
| 379 | +} |
|---|
| 380 | + |
|---|
| 347 | 381 | static int rockchip_usb2phy_clk480m_prepare(struct clk_hw *hw) |
|---|
| 348 | 382 | { |
|---|
| 349 | 383 | struct rockchip_usb2phy *rphy = |
|---|
| .. | .. |
|---|
| 352 | 386 | int ret; |
|---|
| 353 | 387 | |
|---|
| 354 | 388 | /* turn on 480m clk output if it is off */ |
|---|
| 355 | | - if (!property_enabled(base, &rphy->phy_cfg->clkout_ctl)) { |
|---|
| 389 | + if (rphy->phy_cfg->clkout_ctl_phy.enable) { |
|---|
| 390 | + if (!phy_property_enabled(rphy->phy_base, &rphy->phy_cfg->clkout_ctl_phy)) { |
|---|
| 391 | + phy_property_enable(rphy->phy_base, &rphy->phy_cfg->clkout_ctl_phy, true); |
|---|
| 392 | + |
|---|
| 393 | + /* waiting for the clk become stable */ |
|---|
| 394 | + usleep_range(1200, 1300); |
|---|
| 395 | + } |
|---|
| 396 | + } else if (!property_enabled(base, &rphy->phy_cfg->clkout_ctl)) { |
|---|
| 356 | 397 | ret = property_enable(base, &rphy->phy_cfg->clkout_ctl, true); |
|---|
| 357 | 398 | if (ret) |
|---|
| 358 | 399 | return ret; |
|---|
| .. | .. |
|---|
| 371 | 412 | struct regmap *base = get_reg_base(rphy); |
|---|
| 372 | 413 | |
|---|
| 373 | 414 | /* turn off 480m clk output */ |
|---|
| 374 | | - property_enable(base, &rphy->phy_cfg->clkout_ctl, false); |
|---|
| 415 | + if (rphy->phy_cfg->clkout_ctl_phy.enable) |
|---|
| 416 | + phy_property_enable(rphy->phy_base, &rphy->phy_cfg->clkout_ctl_phy, false); |
|---|
| 417 | + else |
|---|
| 418 | + property_enable(base, &rphy->phy_cfg->clkout_ctl, false); |
|---|
| 375 | 419 | } |
|---|
| 376 | 420 | |
|---|
| 377 | 421 | static int rockchip_usb2phy_clk480m_prepared(struct clk_hw *hw) |
|---|
| .. | .. |
|---|
| 380 | 424 | container_of(hw, struct rockchip_usb2phy, clk480m_hw); |
|---|
| 381 | 425 | struct regmap *base = get_reg_base(rphy); |
|---|
| 382 | 426 | |
|---|
| 383 | | - return property_enabled(base, &rphy->phy_cfg->clkout_ctl); |
|---|
| 427 | + if (rphy->phy_cfg->clkout_ctl_phy.enable) |
|---|
| 428 | + return phy_property_enabled(rphy->phy_base, &rphy->phy_cfg->clkout_ctl_phy); |
|---|
| 429 | + else |
|---|
| 430 | + return property_enabled(base, &rphy->phy_cfg->clkout_ctl); |
|---|
| 384 | 431 | } |
|---|
| 385 | 432 | |
|---|
| 386 | 433 | static unsigned long |
|---|
| .. | .. |
|---|
| 410 | 457 | { |
|---|
| 411 | 458 | struct device_node *node = rphy->dev->of_node; |
|---|
| 412 | 459 | struct clk_init_data init = {}; |
|---|
| 460 | + struct clk *refclk = of_clk_get_by_name(node, "phyclk"); |
|---|
| 413 | 461 | const char *clk_name; |
|---|
| 414 | 462 | int ret; |
|---|
| 415 | 463 | |
|---|
| .. | .. |
|---|
| 420 | 468 | /* optional override of the clockname */ |
|---|
| 421 | 469 | of_property_read_string(node, "clock-output-names", &init.name); |
|---|
| 422 | 470 | |
|---|
| 423 | | - if (rphy->clk) { |
|---|
| 424 | | - clk_name = __clk_get_name(rphy->clk); |
|---|
| 471 | + if (!IS_ERR(refclk)) { |
|---|
| 472 | + clk_name = __clk_get_name(refclk); |
|---|
| 425 | 473 | init.parent_names = &clk_name; |
|---|
| 426 | 474 | init.num_parents = 1; |
|---|
| 427 | 475 | } else { |
|---|
| .. | .. |
|---|
| 855 | 903 | } |
|---|
| 856 | 904 | |
|---|
| 857 | 905 | if (rphy->phy_cfg->vbus_detect) |
|---|
| 858 | | - rphy->phy_cfg->vbus_detect(rphy, vbus_det_en); |
|---|
| 906 | + rphy->phy_cfg->vbus_detect(rphy, &rport->port_cfg->vbus_det_en, |
|---|
| 907 | + vbus_det_en); |
|---|
| 859 | 908 | else |
|---|
| 860 | 909 | ret = property_enable(rphy->grf, &rport->port_cfg->vbus_det_en, |
|---|
| 861 | 910 | vbus_det_en); |
|---|
| .. | .. |
|---|
| 1029 | 1078 | rport->state = OTG_STATE_B_IDLE; |
|---|
| 1030 | 1079 | if (!rport->vbus_attached) { |
|---|
| 1031 | 1080 | mutex_unlock(&rport->mutex); |
|---|
| 1032 | | - rockchip_usb2phy_power_off(rport->phy); |
|---|
| 1081 | + if (!rport->dis_u2_susphy) |
|---|
| 1082 | + rockchip_usb2phy_power_off(rport->phy); |
|---|
| 1033 | 1083 | mutex_lock(&rport->mutex); |
|---|
| 1034 | 1084 | } |
|---|
| 1035 | 1085 | /* fall through */ |
|---|
| .. | .. |
|---|
| 1090 | 1140 | rphy->chg_state = USB_CHG_STATE_UNDEFINED; |
|---|
| 1091 | 1141 | rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN; |
|---|
| 1092 | 1142 | mutex_unlock(&rport->mutex); |
|---|
| 1093 | | - rockchip_usb2phy_power_off(rport->phy); |
|---|
| 1143 | + if (!rport->dis_u2_susphy) |
|---|
| 1144 | + rockchip_usb2phy_power_off(rport->phy); |
|---|
| 1094 | 1145 | mutex_lock(&rport->mutex); |
|---|
| 1095 | 1146 | } |
|---|
| 1096 | 1147 | break; |
|---|
| .. | .. |
|---|
| 1434 | 1485 | dev_dbg(&rport->phy->dev, "FS/LS online\n"); |
|---|
| 1435 | 1486 | } |
|---|
| 1436 | 1487 | break; |
|---|
| 1488 | + case PHY_STATE_SE1: |
|---|
| 1489 | + if (rport->suspended) { |
|---|
| 1490 | + dev_dbg(&rport->phy->dev, "linestate is SE1, power on phy\n"); |
|---|
| 1491 | + mutex_unlock(&rport->mutex); |
|---|
| 1492 | + rockchip_usb2phy_power_on(rport->phy); |
|---|
| 1493 | + mutex_lock(&rport->mutex); |
|---|
| 1494 | + rport->suspended = false; |
|---|
| 1495 | + } |
|---|
| 1496 | + break; |
|---|
| 1437 | 1497 | case PHY_STATE_DISCONNECT: |
|---|
| 1438 | 1498 | if (!rport->suspended) { |
|---|
| 1439 | 1499 | dev_dbg(&rport->phy->dev, "Disconnected\n"); |
|---|
| .. | .. |
|---|
| 1764 | 1824 | return NOTIFY_DONE; |
|---|
| 1765 | 1825 | } |
|---|
| 1766 | 1826 | |
|---|
| 1827 | +static void rockchip_otg_wake_lock_destroy(void *data) |
|---|
| 1828 | +{ |
|---|
| 1829 | + wake_lock_destroy((struct wake_lock *)(data)); |
|---|
| 1830 | +} |
|---|
| 1831 | + |
|---|
| 1767 | 1832 | static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, |
|---|
| 1768 | 1833 | struct rockchip_usb2phy_port *rport, |
|---|
| 1769 | 1834 | struct device_node *child_np) |
|---|
| .. | .. |
|---|
| 1789 | 1854 | of_property_read_bool(child_np, "rockchip,vbus-always-on"); |
|---|
| 1790 | 1855 | rport->utmi_avalid = |
|---|
| 1791 | 1856 | of_property_read_bool(child_np, "rockchip,utmi-avalid"); |
|---|
| 1857 | + rport->dis_u2_susphy = |
|---|
| 1858 | + of_property_read_bool(child_np, "rockchip,dis-u2-susphy"); |
|---|
| 1792 | 1859 | |
|---|
| 1793 | 1860 | /* enter lower power state when suspend */ |
|---|
| 1794 | 1861 | rport->low_power_en = |
|---|
| .. | .. |
|---|
| 1833 | 1900 | property_enable(base, &rport->port_cfg->bvalid_set, false); |
|---|
| 1834 | 1901 | |
|---|
| 1835 | 1902 | wake_lock_init(&rport->wakelock, WAKE_LOCK_SUSPEND, "rockchip_otg"); |
|---|
| 1903 | + ret = devm_add_action_or_reset(rphy->dev, rockchip_otg_wake_lock_destroy, |
|---|
| 1904 | + &rport->wakelock); |
|---|
| 1905 | + if (ret) |
|---|
| 1906 | + return ret; |
|---|
| 1907 | + |
|---|
| 1836 | 1908 | INIT_DELAYED_WORK(&rport->bypass_uart_work, |
|---|
| 1837 | 1909 | rockchip_usb_bypass_uart_work); |
|---|
| 1838 | 1910 | INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work); |
|---|
| .. | .. |
|---|
| 1845 | 1917 | EXTCON_USB_HOST, &rport->event_nb); |
|---|
| 1846 | 1918 | if (ret) { |
|---|
| 1847 | 1919 | dev_err(rphy->dev, "register USB HOST notifier failed\n"); |
|---|
| 1848 | | - goto err; |
|---|
| 1920 | + return ret; |
|---|
| 1849 | 1921 | } |
|---|
| 1850 | 1922 | } |
|---|
| 1851 | 1923 | |
|---|
| .. | .. |
|---|
| 1861 | 1933 | rport->suspended = true; |
|---|
| 1862 | 1934 | |
|---|
| 1863 | 1935 | return 0; |
|---|
| 1864 | | - |
|---|
| 1865 | | -err: |
|---|
| 1866 | | - wake_lock_destroy(&rport->wakelock); |
|---|
| 1867 | | - return ret; |
|---|
| 1868 | 1936 | } |
|---|
| 1869 | 1937 | |
|---|
| 1870 | 1938 | static int rockchip_usb2phy_probe(struct platform_device *pdev) |
|---|
| .. | .. |
|---|
| 1963 | 2031 | pm_runtime_enable(dev); |
|---|
| 1964 | 2032 | pm_runtime_get_sync(dev); |
|---|
| 1965 | 2033 | |
|---|
| 1966 | | - rphy->clk = of_clk_get_by_name(np, "phyclk"); |
|---|
| 1967 | | - if (!IS_ERR(rphy->clk)) { |
|---|
| 1968 | | - clk_prepare_enable(rphy->clk); |
|---|
| 1969 | | - } else { |
|---|
| 1970 | | - dev_info(&pdev->dev, "no phyclk specified\n"); |
|---|
| 1971 | | - rphy->clk = NULL; |
|---|
| 1972 | | - } |
|---|
| 2034 | + ret = devm_clk_bulk_get_all(dev, &rphy->clks); |
|---|
| 2035 | + if (ret == -EPROBE_DEFER) |
|---|
| 2036 | + return ret; |
|---|
| 2037 | + |
|---|
| 2038 | + /* Clocks are optional */ |
|---|
| 2039 | + if (ret < 0) |
|---|
| 2040 | + rphy->num_clks = 0; |
|---|
| 2041 | + else |
|---|
| 2042 | + rphy->num_clks = ret; |
|---|
| 2043 | + |
|---|
| 2044 | + ret = clk_bulk_prepare_enable(rphy->num_clks, rphy->clks); |
|---|
| 2045 | + if (ret) |
|---|
| 2046 | + return ret; |
|---|
| 1973 | 2047 | |
|---|
| 1974 | 2048 | if (rphy->phy_cfg->phy_tuning) { |
|---|
| 1975 | 2049 | ret = rphy->phy_cfg->phy_tuning(rphy); |
|---|
| .. | .. |
|---|
| 2061 | 2135 | disable_clks: |
|---|
| 2062 | 2136 | pm_runtime_put_sync(dev); |
|---|
| 2063 | 2137 | pm_runtime_disable(dev); |
|---|
| 2064 | | - if (rphy->clk) { |
|---|
| 2065 | | - clk_disable_unprepare(rphy->clk); |
|---|
| 2066 | | - clk_put(rphy->clk); |
|---|
| 2067 | | - } |
|---|
| 2138 | + clk_bulk_disable_unprepare(rphy->num_clks, rphy->clks); |
|---|
| 2139 | + |
|---|
| 2068 | 2140 | return ret; |
|---|
| 2069 | 2141 | } |
|---|
| 2070 | 2142 | |
|---|
| .. | .. |
|---|
| 2305 | 2377 | return ret; |
|---|
| 2306 | 2378 | } |
|---|
| 2307 | 2379 | |
|---|
| 2380 | +static int rk3528_usb2phy_tuning(struct rockchip_usb2phy *rphy) |
|---|
| 2381 | +{ |
|---|
| 2382 | + u32 reg; |
|---|
| 2383 | + int ret = 0; |
|---|
| 2384 | + |
|---|
| 2385 | + /* Turn off otg port differential receiver in suspend mode */ |
|---|
| 2386 | + reg = readl(rphy->phy_base + 0x30); |
|---|
| 2387 | + writel(reg & ~BIT(2), rphy->phy_base + 0x30); |
|---|
| 2388 | + |
|---|
| 2389 | + /* Turn off host port differential receiver in suspend mode */ |
|---|
| 2390 | + reg = readl(rphy->phy_base + 0x0430); |
|---|
| 2391 | + writel(reg & ~BIT(2), rphy->phy_base + 0x0430); |
|---|
| 2392 | + |
|---|
| 2393 | + /* Set otg port HS eye height to 400mv(default is 450mv) */ |
|---|
| 2394 | + reg = readl(rphy->phy_base + 0x30); |
|---|
| 2395 | + reg &= ~GENMASK(6, 4); |
|---|
| 2396 | + reg |= (0x00 << 4); |
|---|
| 2397 | + writel(reg, rphy->phy_base + 0x30); |
|---|
| 2398 | + |
|---|
| 2399 | + /* Set host port HS eye height to 400mv(default is 450mv) */ |
|---|
| 2400 | + reg = readl(rphy->phy_base + 0x430); |
|---|
| 2401 | + reg &= ~GENMASK(6, 4); |
|---|
| 2402 | + reg |= (0x00 << 4); |
|---|
| 2403 | + writel(reg, rphy->phy_base + 0x430); |
|---|
| 2404 | + |
|---|
| 2405 | + /* Choose the Tx fs/ls data as linestate from TX driver for otg port */ |
|---|
| 2406 | + reg = readl(rphy->phy_base + 0x94); |
|---|
| 2407 | + reg &= ~GENMASK(6, 3); |
|---|
| 2408 | + reg |= (0x03 << 3); |
|---|
| 2409 | + writel(reg, rphy->phy_base + 0x94); |
|---|
| 2410 | + |
|---|
| 2411 | + /* Enable otg and host ports phy irq to pmu wakeup source */ |
|---|
| 2412 | + ret |= regmap_write(rphy->grf, 0x80004, 0x00030003); |
|---|
| 2413 | + |
|---|
| 2414 | + return ret; |
|---|
| 2415 | +} |
|---|
| 2416 | + |
|---|
| 2308 | 2417 | static int rk3568_usb2phy_tuning(struct rockchip_usb2phy *rphy) |
|---|
| 2309 | 2418 | { |
|---|
| 2310 | 2419 | u32 reg; |
|---|
| .. | .. |
|---|
| 2352 | 2461 | return ret; |
|---|
| 2353 | 2462 | } |
|---|
| 2354 | 2463 | |
|---|
| 2355 | | -static int rk3568_vbus_detect_control(struct rockchip_usb2phy *rphy, bool en) |
|---|
| 2464 | +static int rockchip_usb2phy_vbus_det_control(struct rockchip_usb2phy *rphy, |
|---|
| 2465 | + const struct usb2phy_reg *vbus_det_en, |
|---|
| 2466 | + bool en) |
|---|
| 2356 | 2467 | { |
|---|
| 2357 | 2468 | u32 reg; |
|---|
| 2358 | 2469 | |
|---|
| 2359 | 2470 | if (en) { |
|---|
| 2360 | | - reg = readl(rphy->phy_base + 0x3c); |
|---|
| 2471 | + reg = readl(rphy->phy_base + vbus_det_en->offset); |
|---|
| 2361 | 2472 | /* Enable vbus voltage level detection function */ |
|---|
| 2362 | | - writel(reg & ~BIT(7), rphy->phy_base + 0x3c); |
|---|
| 2473 | + writel(reg & ~BIT(7), rphy->phy_base + vbus_det_en->offset); |
|---|
| 2363 | 2474 | } else { |
|---|
| 2364 | | - reg = readl(rphy->phy_base + 0x3c); |
|---|
| 2475 | + reg = readl(rphy->phy_base + vbus_det_en->offset); |
|---|
| 2365 | 2476 | /* Disable vbus voltage level detection function */ |
|---|
| 2366 | | - writel(reg | BIT(7), rphy->phy_base + 0x3c); |
|---|
| 2477 | + writel(reg | BIT(7), rphy->phy_base + vbus_det_en->offset); |
|---|
| 2367 | 2478 | } |
|---|
| 2368 | 2479 | |
|---|
| 2369 | 2480 | return 0; |
|---|
| .. | .. |
|---|
| 2397 | 2508 | rport = &rphy->ports[index]; |
|---|
| 2398 | 2509 | if (!rport->phy) |
|---|
| 2399 | 2510 | continue; |
|---|
| 2511 | + |
|---|
| 2512 | + if (rport->port_cfg->port_ls_filter_con.enable) { |
|---|
| 2513 | + ret = regmap_write(rphy->grf, |
|---|
| 2514 | + rport->port_cfg->port_ls_filter_con.offset, |
|---|
| 2515 | + rport->port_cfg->port_ls_filter_con.enable); |
|---|
| 2516 | + if (ret) |
|---|
| 2517 | + dev_err(rphy->dev, "failed to set port ls filter %d\n", ret); |
|---|
| 2518 | + } |
|---|
| 2400 | 2519 | |
|---|
| 2401 | 2520 | if (rport->port_id == USB2PHY_PORT_OTG && |
|---|
| 2402 | 2521 | (rport->id_irq > 0 || rphy->irq > 0)) { |
|---|
| .. | .. |
|---|
| 2466 | 2585 | rport = &rphy->ports[index]; |
|---|
| 2467 | 2586 | if (!rport->phy) |
|---|
| 2468 | 2587 | continue; |
|---|
| 2588 | + |
|---|
| 2589 | + if (rport->port_cfg->port_ls_filter_con.disable) { |
|---|
| 2590 | + ret = regmap_write(rphy->grf, |
|---|
| 2591 | + rport->port_cfg->port_ls_filter_con.offset, |
|---|
| 2592 | + rport->port_cfg->port_ls_filter_con.disable); |
|---|
| 2593 | + if (ret) |
|---|
| 2594 | + dev_err(rphy->dev, "failed to set port ls filter %d\n", ret); |
|---|
| 2595 | + } |
|---|
| 2469 | 2596 | |
|---|
| 2470 | 2597 | if (rport->port_id == USB2PHY_PORT_OTG && |
|---|
| 2471 | 2598 | (rport->id_irq > 0 || rphy->irq > 0)) { |
|---|
| .. | .. |
|---|
| 2988 | 3115 | { /* sentinel */ } |
|---|
| 2989 | 3116 | }; |
|---|
| 2990 | 3117 | |
|---|
| 3118 | +static const struct rockchip_usb2phy_cfg rk3528_phy_cfgs[] = { |
|---|
| 3119 | + { |
|---|
| 3120 | + .reg = 0xffdf0000, |
|---|
| 3121 | + .num_ports = 2, |
|---|
| 3122 | + .phy_tuning = rk3528_usb2phy_tuning, |
|---|
| 3123 | + .vbus_detect = rockchip_usb2phy_vbus_det_control, |
|---|
| 3124 | + .clkout_ctl_phy = { 0x041c, 7, 2, 0, 0x27 }, |
|---|
| 3125 | + .port_cfgs = { |
|---|
| 3126 | + [USB2PHY_PORT_OTG] = { |
|---|
| 3127 | + .phy_sus = { 0x6004c, 8, 0, 0, 0x1d1 }, |
|---|
| 3128 | + .bvalid_det_en = { 0x60074, 2, 2, 0, 1 }, |
|---|
| 3129 | + .bvalid_det_st = { 0x60078, 2, 2, 0, 1 }, |
|---|
| 3130 | + .bvalid_det_clr = { 0x6007c, 2, 2, 0, 1 }, |
|---|
| 3131 | + .bvalid_set = { 0x6004c, 15, 14, 0, 3 }, |
|---|
| 3132 | + .iddig_output = { 0x6004c, 10, 10, 0, 1 }, |
|---|
| 3133 | + .iddig_en = { 0x6004c, 9, 9, 0, 1 }, |
|---|
| 3134 | + .idfall_det_en = { 0x60074, 5, 5, 0, 1 }, |
|---|
| 3135 | + .idfall_det_st = { 0x60078, 5, 5, 0, 1 }, |
|---|
| 3136 | + .idfall_det_clr = { 0x6007c, 5, 5, 0, 1 }, |
|---|
| 3137 | + .idrise_det_en = { 0x60074, 4, 4, 0, 1 }, |
|---|
| 3138 | + .idrise_det_st = { 0x60078, 4, 4, 0, 1 }, |
|---|
| 3139 | + .idrise_det_clr = { 0x6007c, 4, 4, 0, 1 }, |
|---|
| 3140 | + .ls_det_en = { 0x60074, 0, 0, 0, 1 }, |
|---|
| 3141 | + .ls_det_st = { 0x60078, 0, 0, 0, 1 }, |
|---|
| 3142 | + .ls_det_clr = { 0x6007c, 0, 0, 0, 1 }, |
|---|
| 3143 | + .utmi_avalid = { 0x6006c, 1, 1, 0, 1 }, |
|---|
| 3144 | + .utmi_bvalid = { 0x6006c, 0, 0, 0, 1 }, |
|---|
| 3145 | + .utmi_iddig = { 0x6006c, 6, 6, 0, 1 }, |
|---|
| 3146 | + .utmi_ls = { 0x6006c, 5, 4, 0, 1 }, |
|---|
| 3147 | + .vbus_det_en = { 0x003c, 7, 7, 0, 1 }, |
|---|
| 3148 | + .port_ls_filter_con = { 0x60080, 19, 0, 0x30100, 0x20 }, |
|---|
| 3149 | + }, |
|---|
| 3150 | + [USB2PHY_PORT_HOST] = { |
|---|
| 3151 | + .phy_sus = { 0x6005c, 8, 0, 0x1d2, 0x1d1 }, |
|---|
| 3152 | + .ls_det_en = { 0x60090, 0, 0, 0, 1 }, |
|---|
| 3153 | + .ls_det_st = { 0x60094, 0, 0, 0, 1 }, |
|---|
| 3154 | + .ls_det_clr = { 0x60098, 0, 0, 0, 1 }, |
|---|
| 3155 | + .utmi_ls = { 0x6006c, 13, 12, 0, 1 }, |
|---|
| 3156 | + .utmi_hstdet = { 0x6006c, 15, 15, 0, 1 }, |
|---|
| 3157 | + .port_ls_filter_con = { 0x6009c, 19, 0, 0x30100, 0x20 }, |
|---|
| 3158 | + } |
|---|
| 3159 | + }, |
|---|
| 3160 | + .chg_det = { |
|---|
| 3161 | + .chg_mode = { 0x6004c, 8, 0, 0, 0x1d7 }, |
|---|
| 3162 | + .cp_det = { 0x6006c, 19, 19, 0, 1 }, |
|---|
| 3163 | + .dcp_det = { 0x6006c, 18, 18, 0, 1 }, |
|---|
| 3164 | + .dp_det = { 0x6006c, 20, 20, 0, 1 }, |
|---|
| 3165 | + .idm_sink_en = { 0x60058, 1, 1, 0, 1 }, |
|---|
| 3166 | + .idp_sink_en = { 0x60058, 0, 0, 0, 1 }, |
|---|
| 3167 | + .idp_src_en = { 0x60058, 2, 2, 0, 1 }, |
|---|
| 3168 | + .rdm_pdwn_en = { 0x60058, 3, 3, 0, 1 }, |
|---|
| 3169 | + .vdm_src_en = { 0x60058, 5, 5, 0, 1 }, |
|---|
| 3170 | + .vdp_src_en = { 0x60058, 4, 4, 0, 1 }, |
|---|
| 3171 | + }, |
|---|
| 3172 | + } |
|---|
| 3173 | +}; |
|---|
| 3174 | + |
|---|
| 2991 | 3175 | static const struct rockchip_usb2phy_cfg rk3568_phy_cfgs[] = { |
|---|
| 2992 | 3176 | { |
|---|
| 2993 | 3177 | .reg = 0xfe8a0000, |
|---|
| 2994 | 3178 | .num_ports = 2, |
|---|
| 2995 | 3179 | .phy_tuning = rk3568_usb2phy_tuning, |
|---|
| 2996 | | - .vbus_detect = rk3568_vbus_detect_control, |
|---|
| 3180 | + .vbus_detect = rockchip_usb2phy_vbus_det_control, |
|---|
| 2997 | 3181 | .clkout_ctl = { 0x0008, 4, 4, 1, 0 }, |
|---|
| 2998 | 3182 | .ls_filter_con = { 0x0040, 19, 0, 0x30100, 0x00020 }, |
|---|
| 2999 | 3183 | .port_cfgs = { |
|---|
| .. | .. |
|---|
| 3020 | 3204 | .utmi_bvalid = { 0x00c0, 9, 9, 0, 1 }, |
|---|
| 3021 | 3205 | .utmi_iddig = { 0x00c0, 6, 6, 0, 1 }, |
|---|
| 3022 | 3206 | .utmi_ls = { 0x00c0, 5, 4, 0, 1 }, |
|---|
| 3207 | + .vbus_det_en = { 0x003c, 7, 7, 0, 1 }, |
|---|
| 3023 | 3208 | }, |
|---|
| 3024 | 3209 | [USB2PHY_PORT_HOST] = { |
|---|
| 3025 | 3210 | /* Select suspend control from controller */ |
|---|
| .. | .. |
|---|
| 3123 | 3308 | { .compatible = "rockchip,rk3366-usb2phy", .data = &rk3366_phy_cfgs }, |
|---|
| 3124 | 3309 | { .compatible = "rockchip,rk3368-usb2phy", .data = &rk3368_phy_cfgs }, |
|---|
| 3125 | 3310 | { .compatible = "rockchip,rk3399-usb2phy", .data = &rk3399_phy_cfgs }, |
|---|
| 3311 | + { .compatible = "rockchip,rk3528-usb2phy", .data = &rk3528_phy_cfgs }, |
|---|
| 3126 | 3312 | { .compatible = "rockchip,rk3568-usb2phy", .data = &rk3568_phy_cfgs }, |
|---|
| 3127 | 3313 | { .compatible = "rockchip,rv1108-usb2phy", .data = &rv1108_phy_cfgs }, |
|---|
| 3128 | 3314 | {} |
|---|