summaryrefslogtreecommitdiff
path: root/drivers/usb/misc/usb3503.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/misc/usb3503.c')
-rw-r--r--drivers/usb/misc/usb3503.c72
1 files changed, 42 insertions, 30 deletions
diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index bd47c4437ca4..322e59381b78 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -46,34 +46,18 @@ struct usb3503 {
struct device *dev;
struct clk *clk;
u8 port_off_mask;
+ struct gpio_desc *bypass;
struct gpio_desc *intn;
struct gpio_desc *reset;
struct gpio_desc *connect;
bool secondary_ref_clk;
};
-static int usb3503_reset(struct usb3503 *hub, int state)
-{
- if (!state && hub->connect)
- gpiod_set_value_cansleep(hub->connect, 0);
-
- if (hub->reset)
- gpiod_set_value_cansleep(hub->reset, !state);
-
- /* Wait T_HUBINIT == 4ms for hub logic to stabilize */
- if (state)
- usleep_range(4000, 10000);
-
- return 0;
-}
-
static int usb3503_connect(struct usb3503 *hub)
{
struct device *dev = hub->dev;
int err;
- usb3503_reset(hub, 1);
-
if (hub->regmap) {
/* SP_ILOCK: set connect_n, config_n for config */
err = regmap_write(hub->regmap, USB3503_SP_ILOCK,
@@ -126,25 +110,46 @@ static int usb3503_connect(struct usb3503 *hub)
static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode)
{
struct device *dev = hub->dev;
- int err = 0;
+ int rst, bypass, conn;
switch (mode) {
case USB3503_MODE_HUB:
- err = usb3503_connect(hub);
+ conn = 1;
+ rst = 0;
+ bypass = 0;
break;
-
case USB3503_MODE_STANDBY:
- usb3503_reset(hub, 0);
+ conn = 0;
+ rst = 1;
+ bypass = 1;
dev_info(dev, "switched to STANDBY mode\n");
break;
-
+ case USB3503_MODE_BYPASS:
+ conn = 0;
+ rst = 0;
+ bypass = 1;
+ break;
default:
dev_err(dev, "unknown mode is requested\n");
- err = -EINVAL;
- break;
+ return -EINVAL;
}
- return err;
+ if (!conn && hub->connect)
+ gpiod_set_value_cansleep(hub->connect, 0);
+
+ if (hub->reset)
+ gpiod_set_value_cansleep(hub->reset, rst);
+
+ if (hub->bypass)
+ gpiod_set_value_cansleep(hub->bypass, bypass);
+
+ if (conn) {
+ /* Wait T_HUBINIT == 4ms for hub logic to stabilize */
+ usleep_range(4000, 10000);
+ return usb3503_connect(hub);
+ }
+
+ return 0;
}
static const struct regmap_config usb3503_regmap_config = {
@@ -253,6 +258,14 @@ static int usb3503_probe(struct usb3503 *hub)
if (hub->connect)
gpiod_set_consumer_name(hub->connect, "usb3503 connect");
+ hub->bypass = devm_gpiod_get_optional(dev, "bypass", GPIOD_OUT_HIGH);
+ if (IS_ERR(hub->bypass)) {
+ err = PTR_ERR(hub->bypass);
+ goto err_clk;
+ }
+ if (hub->bypass)
+ gpiod_set_consumer_name(hub->bypass, "usb3503 bypass");
+
hub->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(hub->reset)) {
err = PTR_ERR(hub->reset);
@@ -322,14 +335,12 @@ static int usb3503_platform_probe(struct platform_device *pdev)
return usb3503_probe(hub);
}
-static int usb3503_platform_remove(struct platform_device *pdev)
+static void usb3503_platform_remove(struct platform_device *pdev)
{
struct usb3503 *hub;
hub = platform_get_drvdata(pdev);
clk_disable_unprepare(hub->clk);
-
- return 0;
}
static int __maybe_unused usb3503_suspend(struct usb3503 *hub)
@@ -379,7 +390,7 @@ static SIMPLE_DEV_PM_OPS(usb3503_platform_pm_ops, usb3503_platform_suspend,
usb3503_platform_resume);
static const struct i2c_device_id usb3503_id[] = {
- { USB3503_I2C_NAME, 0 },
+ { USB3503_I2C_NAME },
{ }
};
MODULE_DEVICE_TABLE(i2c, usb3503_id);
@@ -388,6 +399,7 @@ MODULE_DEVICE_TABLE(i2c, usb3503_id);
static const struct of_device_id usb3503_of_match[] = {
{ .compatible = "smsc,usb3503", },
{ .compatible = "smsc,usb3503a", },
+ { .compatible = "smsc,usb3803", },
{},
};
MODULE_DEVICE_TABLE(of, usb3503_of_match);
@@ -399,7 +411,7 @@ static struct i2c_driver usb3503_i2c_driver = {
.pm = pm_ptr(&usb3503_i2c_pm_ops),
.of_match_table = of_match_ptr(usb3503_of_match),
},
- .probe_new = usb3503_i2c_probe,
+ .probe = usb3503_i2c_probe,
.remove = usb3503_i2c_remove,
.id_table = usb3503_id,
};