]> git.sur5r.net Git - u-boot/commitdiff
dm: imx: serial: support device tree
authorStefan Agner <stefan.agner@toradex.com>
Wed, 5 Oct 2016 22:27:03 +0000 (15:27 -0700)
committerStefano Babic <sbabic@denx.de>
Fri, 7 Oct 2016 10:26:14 +0000 (12:26 +0200)
Support instatiation through device tree. Also parse the fsl,dte-mode
property to determine whether DTE mode shall be used.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
doc/device-tree-bindings/serial/mxc-serial.txt [new file with mode: 0644]
drivers/serial/serial_mxc.c

diff --git a/doc/device-tree-bindings/serial/mxc-serial.txt b/doc/device-tree-bindings/serial/mxc-serial.txt
new file mode 100644 (file)
index 0000000..ede92a4
--- /dev/null
@@ -0,0 +1,8 @@
+NXP i.MX (MXC) UART
+
+Required properties:
+- compatible: must be "fsl,imx7d-uart"
+- reg: start address and size of the registers
+
+Optional properties:
+- fsl,dte-mode: use DTE mode
index 85457144113ec19edd0506e93606f45679ab7efe..4fd2b1dd054f39cf5e560b10e93708147be27815 100644 (file)
 #define  UTS_RXFULL     (1<<3)  /* RxFIFO full */
 #define  UTS_SOFTRST    (1<<0)  /* Software reset */
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #ifndef CONFIG_DM_SERIAL
 
 #ifndef CONFIG_MXC_UART_BASE
 #define UBRC  0xac /* Baud Rate Count Register */
 #define UTS   0xb4 /* UART Test Register (mx31) */
 
-DECLARE_GLOBAL_DATA_PTR;
-
 #define TXTL  2 /* reset default */
 #define RXTL  1 /* reset default */
 #define RFDIV 4 /* divide input clock by 2 */
@@ -347,9 +347,37 @@ static const struct dm_serial_ops mxc_serial_ops = {
        .setbrg = mxc_serial_setbrg,
 };
 
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+static int mxc_serial_ofdata_to_platdata(struct udevice *dev)
+{
+       struct mxc_serial_platdata *plat = dev->platdata;
+       fdt_addr_t addr;
+
+       addr = dev_get_addr(dev);
+       if (addr == FDT_ADDR_T_NONE)
+               return -EINVAL;
+
+       plat->reg = (struct mxc_uart *)addr;
+
+       plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+                                       "fsl,dte-mode");
+       return 0;
+}
+
+static const struct udevice_id mxc_serial_ids[] = {
+       { .compatible = "fsl,imx7d-uart" },
+       { }
+};
+#endif
+
 U_BOOT_DRIVER(serial_mxc) = {
        .name   = "serial_mxc",
        .id     = UCLASS_SERIAL,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+       .of_match = mxc_serial_ids,
+       .ofdata_to_platdata = mxc_serial_ofdata_to_platdata,
+       .platdata_auto_alloc_size = sizeof(struct mxc_serial_platdata),
+#endif
        .probe = mxc_serial_probe,
        .ops    = &mxc_serial_ops,
        .flags = DM_FLAG_PRE_RELOC,