Skip to contentSkip to conversation

USB3503: Always respect refclk-frequency

PATCH New Ben Gamari 1 participant 2 messages Mar 18, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Ben Gamari

author
#0 lore raw

PATCH v2 1/1 USB3503: Always respect refclk-frequency

My apologies for the double-post; the previous patch lacked an Acked-by and several important recipients. Keep me on the CC list as I'm not subscribed to the linux-usb list.

The USB3503 driver exposes the refclk-frequency DT property to allow users to specify the rate of the clock provided on the device's REFCLK. This is necessary for the driver to correctly configure the REF_SEL and INT_N pins. Currently the driver only pays attention to refclk-frequency if the refclk property is also provided. The binding documentation stipulates that the user should omit refclk if the clock can be assumed to be always available.

This patch reworks the initialization codepath such that the driver always respects the refclk-frequency property, even if refclk is omitted.

Cheers,

- Ben

[1] https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/usb/misc/usb3503.c?id=657d898a9320a7cdb9b94565d75ecf75c25cbf0a

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1426703865-31868-1-git-send-email-ben-OfdNVJEh3GKkIYD+M5K+dQ@public.gmane.org

author
#2 lore raw

PATCH 1/1 usb/misc/usb3503: Always read refclk frequency from DT

This is necessary to set REF_SEL appropriately in uses where refclk is always available.

---
 drivers/usb/misc/usb3503.c | 47 +++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)
drivers/usb/misc/usb3503.c +24 -23
index 258d2f5..64ff5b9 100644
@@ -186,8 +186,31 @@ static int usb3503_probe(struct usb3503 *hub)
 		hub->mode		= pdata->initial_mode;
 	} else if (np) {
 		struct clk *clk;
+		u32 rate = 0;
 		hub->port_off_mask = 0;
 
+		if (!of_property_read_u32(np, "refclk-frequency", &rate)) {
+			switch (rate) {
+			case 38400000:
+			case 26000000:
+			case 19200000:
+			case 12000000:
+				hub->secondary_ref_clk = 0;
+				break;
+			case 24000000:
+			case 27000000:
+			case 25000000:
+			case 50000000:
+				hub->secondary_ref_clk = 1;
+				break;
+			default:
+				dev_err(dev,
+					"unsupported reference clock rate (%d)\n",
+					(int) rate);
+				return -EINVAL;
+			}
+		}
+
 		clk = devm_clk_get(dev, "refclk");
 		if (IS_ERR(clk) && PTR_ERR(clk) != -ENOENT) {
 			dev_err(dev, "unable to request refclk (%ld)\n",
@@ -196,31 +219,9 @@ static int usb3503_probe(struct usb3503 *hub)
 		}
 
 		if (!IS_ERR(clk)) {
-			u32 rate = 0;
 			hub->clk = clk;
 
-			if (!of_property_read_u32(np, "refclk-frequency",
-						 &rate)) {
-
-				switch (rate) {
-				case 38400000:
-				case 26000000:
-				case 19200000:
-				case 12000000:
-					hub->secondary_ref_clk = 0;
-					break;
-				case 24000000:
-				case 27000000:
-				case 25000000:
-				case 50000000:
-					hub->secondary_ref_clk = 1;
-					break;
-				default:
-					dev_err(dev,
-						"unsupported reference clock rate (%d)\n",
-						(int) rate);
-					return -EINVAL;
-				}
+			if (rate != 0) {
 				err = clk_set_rate(hub->clk, rate);
 				if (err) {
 					dev_err(dev,
Signature · 6 lines
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html