On 09.03.2016 12:53, Sergei Shtylyov wrote:
Hello.
On 3/9/2016 12:25 PM, Petr Kulhavy wrote:
This adds DT support for TI DA8xx/OMAP-L1x/AM17xx/AM18xx MUSB driver
Signed-off-by: Petr Kulhavy <petr@xxxxxxxxx>
Tested-by: Petr Kulhavy <petr@xxxxxxxxx>
[...]
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index b03d3b8..aabd33a 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
[...]
@@ -134,6 +139,55 @@ static inline void phy_off(void)
__raw_writel(cfgchip2, CFGCHIP2);
}
+static inline int get_phy_refclk_cfg(struct device_node *np)
+{
+ u32 freq;
+
+ if (of_property_read_u32(np, "ti,usb2-phy-refclock-hz", &freq))
+ return -EINVAL;
Shouldn't the frequency be retrieved thru the clk API, like we do
it for the power, BTW?
Bin, what do you think about it? I prefer the pragmatic approach leaving
it as a parameter ;-)
Then the clock selection would be needed as well, etc. I'd keep it simple.
+
+ switch (freq) {
+ case 12000000:
+ return CFGCHIP2_REFFREQ_12MHZ;
+ case 13000000:
+ return CFGCHIP2_REFFREQ_13MHZ;
+ case 19200000:
+ return CFGCHIP2_REFFREQ_19_2MHZ;
+ case 20000000:
+ return CFGCHIP2_REFFREQ_20MHZ;
+ case 24000000:
+ return CFGCHIP2_REFFREQ_24MHZ;
+ case 26000000:
+ return CFGCHIP2_REFFREQ_26MHZ;
+ case 38400000:
+ return CFGCHIP2_REFFREQ_38_4MHZ;
+ case 40000000:
+ return CFGCHIP2_REFFREQ_40MHZ;
+ case 48000000:
+ return CFGCHIP2_REFFREQ_48MHZ;
+ default:
+ return -EINVAL;
+ }
+}
+
+static inline u8 get_vbus_power(struct device *dev)
+{
+ struct regulator *vbus_supply;
+ int current_uA;
+
+ vbus_supply = regulator_get(dev, "vbus");
+ if (IS_ERR(vbus_supply))
+ return 255;
+
+ current_uA = regulator_get_current_limit(vbus_supply);
+ regulator_put(vbus_supply);
+
+ if (current_uA <= 0 || current_uA > 510000)
+ return 255;
+
+ return current_uA / 1000;
+}
Wait, the platform data expects that in 2 mA units, you forgot to
divide by 2!
Argh, yes indeed!
Regards
Petr
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html