return 1;
 }
 
-static int max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
+static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
                               unsigned long freq, bool xtal)
 {
        unsigned int div, clksrc, pllcfg = 0;
                }
        }
 
-       return (int)bestfreq;
+       return bestfreq;
 }
 
 static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigned int len)
 static int max310x_probe(struct device *dev, const struct max310x_devtype *devtype,
                         struct regmap *regmap, int irq)
 {
-       int i, ret, fmin, fmax, freq, uartclk;
+       int i, ret, fmin, fmax, freq;
        struct max310x_port *s;
-       bool xtal = false;
+       u32 uartclk = 0;
+       bool xtal;
 
        if (IS_ERR(regmap))
                return PTR_ERR(regmap);
                return -ENOMEM;
        }
 
+       /* Always ask for fixed clock rate from a property. */
+       device_property_read_u32(dev, "clock-frequency", &uartclk);
+
        s->clk = devm_clk_get_optional(dev, "osc");
        if (IS_ERR(s->clk))
                return PTR_ERR(s->clk);
        if (s->clk) {
-               fmin = 500000;
-               fmax = 35000000;
+               xtal = false;
        } else {
                s->clk = devm_clk_get_optional(dev, "xtal");
                if (IS_ERR(s->clk))
                        return PTR_ERR(s->clk);
-               if (s->clk) {
-                       fmin = 1000000;
-                       fmax = 4000000;
-                       xtal = true;
-               } else {
-                       dev_err(dev, "Cannot get clock\n");
-                       return -EINVAL;
-               }
+
+               xtal = true;
        }
 
        ret = clk_prepare_enable(s->clk);
                return ret;
 
        freq = clk_get_rate(s->clk);
+       if (freq == 0)
+               freq = uartclk;
+       if (freq == 0) {
+               dev_err(dev, "Cannot get clock rate\n");
+               return -EINVAL;
+       }
+
+       if (xtal) {
+               fmin = 1000000;
+               fmax = 4000000;
+       } else {
+               fmin = 500000;
+               fmax = 35000000;
+       }
+
        /* Check frequency limits */
        if (freq < fmin || freq > fmax) {
                ret = -ERANGE;