summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2018-09-26 13:01:39 +0200
committerMax Krummenacher <max.krummenacher@toradex.com>2018-11-08 11:31:53 +0100
commit92ed1faf672e46e3e54b1f41f0b38f533b53b1aa (patch)
treea6863a747d94446926e543edeae56da449614770
parente7812f55781bd9453a231d104a2c6c520491e2e4 (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>
-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 043849228f69..24a53bc9f395 100644
--- a/include/linux/platform_data/usb3503.h
+++ b/include/linux/platform_data/usb3503.h
@@ -15,6 +15,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;