@@ -65,6 +65,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
struct resource resource;
struct device_node *np = ofdev->dev.of_node;
u32 clk, spd, prop;
+ u64 clk_scaled;
int ret;
memset(port, 0, sizeof *port);
@@ -84,6 +85,19 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
clk = clk_get_rate(info->clk);
}
+ /* a custom clock divider instead of the default 16
+ * this (as of now) does not change the low level behaviour
+ * but only scales the clock accordingly
+ */
+ if (of_property_read_u32(np, "clock-divider", &spd) == 0) {
+ clk_scaled = (u64) clk * 16;
+ do_div(clk_scaled, spd);
+ dev_info(&ofdev->dev,
+ "scaling clock %uHz to %uHz to allow a clock divider of %u\n",
+ clk, (u32)clk_scaled, spd);
+ clk = (u32) clk_scaled;
+ }
+
/* If current-speed was set, then try not to change it. */
if (of_property_read_u32(np, "current-speed", &spd) == 0)
port->custom_divisor = clk / (16 * spd);