summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2018-09-26 13:01:39 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2020-02-09 22:49:20 +0100
commit0720673225d8efadfe0f11b5d2dd8e126c6eb5d5 (patch)
tree815a547764c3173ce2071634bc72641d6125a2a4
parent60d0a3d181056f5587277458a655a47a495dae1b (diff)
usb/misc/usb3503: add setting of 'non removable devices' register
This allows to configure the NRD register from device tree or platform data. Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> (cherry picked from commit 92ed1faf672e46e3e54b1f41f0b38f533b53b1aa) (cherry picked from commit 6b5280f4e71770600d5b89638d849896158f2ec3)
-rw-r--r--Documentation/devicetree/bindings/usb/usb3503.txt2
-rw-r--r--drivers/usb/misc/usb3503.c25
-rw-r--r--include/linux/platform_data/usb3503.h1
3 files changed, 28 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/usb/usb3503.txt b/Documentation/devicetree/bindings/usb/usb3503.txt
index f66f79e6fe0e..5128d305bfce 100644
--- a/Documentation/devicetree/bindings/usb/usb3503.txt
+++ b/Documentation/devicetree/bindings/usb/usb3503.txt
@@ -14,6 +14,8 @@ Optional properties:
'1' or '2' or '3' are available for this property to describe the port
number. 1~3 property values are possible to be described.
Do not describe this property if all ports have to be enabled.
+- non-removable-devices: Should specify the ports going to non removable
+ devices. See disabled-ports for the syntax.
- intn-gpios: Should specify GPIO for interrupt.
- reset-gpios: Should specify GPIO for reset.
- initial-mode: Should specify initial mode.
diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index 9ca9e8e769fb..81f74654e5a3 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -59,6 +59,7 @@ struct usb3503 {
struct regmap *regmap;
struct device *dev;
struct clk *clk;
+ u8 port_nrd;
u8 port_off_mask;
int gpio_bypass;
int gpio_intn;
@@ -122,6 +123,17 @@ static int usb3503_connect(struct usb3503 *hub)
return err;
}
+ /* NRD : Set non removable ports. */
+ if (hub->port_nrd) {
+ err = regmap_update_bits(hub->regmap, USB3503_NRD,
+ hub->port_nrd,
+ hub->port_nrd);
+ if (err < 0) {
+ dev_err(dev, "NRD failed (%d)\n", err);
+ return err;
+ }
+ }
+
/* SP_LOCK: clear connect_n, config_n for hub connect */
err = regmap_update_bits(hub->regmap, USB3503_SP_ILOCK,
(USB3503_SPILOCK_CONNECT
@@ -183,6 +195,7 @@ static int usb3503_probe(struct usb3503 *hub)
int len;
if (pdata) {
+ hub->port_nrd = pdata->port_nrd;
hub->port_off_mask = pdata->port_off_mask;
hub->gpio_bypass = pdata->gpio_bypass;
hub->gpio_intn = pdata->gpio_intn;
@@ -249,11 +262,23 @@ static int usb3503_probe(struct usb3503 *hub)
int i;
for (i = 0; i < len / sizeof(u32); i++) {
u32 port = be32_to_cpu(property[i]);
+ dev_dbg(dev, "disabled-ports, port: %d\n", port);
if ((1 <= port) && (port <= 3))
hub->port_off_mask |= (1 << port);
}
}
+ property = of_get_property(np, "non-removable-devices", &len);
+ if (property && (len / sizeof(u32)) > 0) {
+ int i;
+ for (i = 0; i < len / sizeof(u32); i++) {
+ u32 port = be32_to_cpu(property[i]);
+ dev_dbg(dev, "non-removable-devices, port: %d\n", port);
+ if ((1 <= port) && (port <= 3))
+ hub->port_nrd |= (1 << port);
+ }
+ }
+
hub->gpio_intn = of_get_named_gpio(np, "intn-gpios", 0);
if (hub->gpio_intn == -EPROBE_DEFER)
return -EPROBE_DEFER;
diff --git a/include/linux/platform_data/usb3503.h b/include/linux/platform_data/usb3503.h
index df1d0f48ca75..435e9edb1bc4 100644
--- a/include/linux/platform_data/usb3503.h
+++ b/include/linux/platform_data/usb3503.h
@@ -16,6 +16,7 @@ enum usb3503_mode {
struct usb3503_platform_data {
enum usb3503_mode initial_mode;
+ u8 port_nrd;
u8 port_off_mask;
int gpio_bypass;
int gpio_intn;