Commit a9bab255 authored by Marco Felsch's avatar Marco Felsch Committed by Greg Kroah-Hartman

usb: usb251xb: simplify reset helper

Currently the reset handler was always called to deassert the reset
line because assert the line was done during probe. Now if we want to
support pm by turn of the supply we need to call this routine twice and
the i2c_lock_bus is done twice too. To simplify that we can drop the
state and just do a reset in one go. So a future pm operation don't need
to lock the i2c bus twice.
Signed-off-by: default avatarMarco Felsch <m.felsch@pengutronix.de>
Reviewed-by: default avatarRichard Leitner <richard.leitner@skidata.com>
Tested-by: default avatarRichard Leitner <richard.leitner@skidata.com>
Link: https://lore.kernel.org/r/20190917144449.32739-4-m.felsch@pengutronix.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4d7201cd
...@@ -263,20 +263,19 @@ static int usb251x_check_gpio_chip(struct usb251xb *hub) ...@@ -263,20 +263,19 @@ static int usb251x_check_gpio_chip(struct usb251xb *hub)
} }
#endif #endif
static void usb251xb_reset(struct usb251xb *hub, int state) static void usb251xb_reset(struct usb251xb *hub)
{ {
if (!hub->gpio_reset) if (!hub->gpio_reset)
return; return;
i2c_lock_bus(hub->i2c->adapter, I2C_LOCK_SEGMENT); i2c_lock_bus(hub->i2c->adapter, I2C_LOCK_SEGMENT);
gpiod_set_value_cansleep(hub->gpio_reset, state); gpiod_set_value_cansleep(hub->gpio_reset, 1);
usleep_range(1, 10); /* >=1us RESET_N asserted */
gpiod_set_value_cansleep(hub->gpio_reset, 0);
/* wait for hub recovery/stabilization */ /* wait for hub recovery/stabilization */
if (!state) usleep_range(500, 750); /* >=500us after RESET_N deasserted */
usleep_range(500, 750); /* >=500us at power on */
else
usleep_range(1, 10); /* >=1us at power down */
i2c_unlock_bus(hub->i2c->adapter, I2C_LOCK_SEGMENT); i2c_unlock_bus(hub->i2c->adapter, I2C_LOCK_SEGMENT);
} }
...@@ -294,7 +293,7 @@ static int usb251xb_connect(struct usb251xb *hub) ...@@ -294,7 +293,7 @@ static int usb251xb_connect(struct usb251xb *hub)
i2c_wb[0] = 0x01; i2c_wb[0] = 0x01;
i2c_wb[1] = USB251XB_STATUS_COMMAND_ATTACH; i2c_wb[1] = USB251XB_STATUS_COMMAND_ATTACH;
usb251xb_reset(hub, 0); usb251xb_reset(hub);
err = i2c_smbus_write_i2c_block_data(hub->i2c, err = i2c_smbus_write_i2c_block_data(hub->i2c,
USB251XB_ADDR_STATUS_COMMAND, 2, i2c_wb); USB251XB_ADDR_STATUS_COMMAND, 2, i2c_wb);
...@@ -344,7 +343,7 @@ static int usb251xb_connect(struct usb251xb *hub) ...@@ -344,7 +343,7 @@ static int usb251xb_connect(struct usb251xb *hub)
i2c_wb[USB251XB_ADDR_PORT_MAP_7] = hub->port_map7; i2c_wb[USB251XB_ADDR_PORT_MAP_7] = hub->port_map7;
i2c_wb[USB251XB_ADDR_STATUS_COMMAND] = USB251XB_STATUS_COMMAND_ATTACH; i2c_wb[USB251XB_ADDR_STATUS_COMMAND] = USB251XB_STATUS_COMMAND_ATTACH;
usb251xb_reset(hub, 0); usb251xb_reset(hub);
/* write registers */ /* write registers */
for (i = 0; i < (USB251XB_I2C_REG_SZ / USB251XB_I2C_WRITE_SZ); i++) { for (i = 0; i < (USB251XB_I2C_REG_SZ / USB251XB_I2C_WRITE_SZ); i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment