serial: fdt: add device tree support for pl01x
PATCH 1/1 serial: fdt: add device tree support for pl01x
This patch adds device tree support for arm pl010/pl011 driver.
--- doc/device-tree-bindings/serial/pl01x.txt | 7 +++++ drivers/serial/serial_pl01x.c | 41 ++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/serial/pl01x.txt
doc/device-tree-bindings/serial/pl01x.txt new file +7 -0
@@ -0,0 +1,7 @@ +* ARM AMBA Primecell PL011 & PL010 serial UART + +Required properties: +- compatible: must be "arm,primecell", "arm,pl011" or "arm,pl010" +- reg: exactly one register range with length 0x1000 +- clock: input clock frequency for the UART (used to calculate the baud + rate divisor)
drivers/serial/serial_pl01x.c +40 -1
62 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 1/1 serial: fdt: add device tree support for pl01x
+Masahiro, for my of_match_ptr() comment below.
Hi Vikas,
Quoted 45 lines · Vikas Manocha
This patch adds device tree support for arm pl010/pl011 driver.
Signed-off-by Vikas Manocha <[email protected]>--- doc/device-tree-bindings/serial/pl01x.txt | 7 +++++ drivers/serial/serial_pl01x.c | 41 ++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/serial/pl01x.txtdoc/device-tree-bindings/serial/pl01x.txt new file +7
-0@@ -0,0 +1,7 @@ +* ARM AMBA Primecell PL011 & PL010 serial UART + +Required properties: +- compatible: must be "arm,primecell", "arm,pl011" or "arm,pl010" +- reg: exactly one register range with length 0x1000 +- clock: input clock frequency for the UART (used to calculate the baud + rate divisor)drivers/serial/serial_pl01x.c +3
-1@@ -20,6 +20,9 @@#include <dm/platform_data/serial_pl01x.h> #include <linux/compiler.h> #include "serial_pl01x_internal.h" +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR ;#ifndef CONFIG_DM_SERIAL @@ -28,7 +31,6 @@ static enum pl01x_type pl01x_type __attribute__ ((section(".data"))); static struct pl01x_regs *base_regs __attribute__ ((section(".data")));#define NUM_PORTS (sizeof(port)/sizeof(port[0])) -DECLARE_GLOBAL_DATA_PTR ;#endif static int pl01x_putc (struct pl01x_regs *regs,char c)
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 359
Quoted 7 lines
drivers/serial/serial_pl01x.c +4
-0@@ -351,9 +353,46 @@ static const struct dm_serial_ops pl01x_serial_ops = { .setbrg = pl01x_serial_setbrg, }; +#ifdef CONFIG_OF_CONTROL +static const struct udevice_id pl01x_serial_id[] ={ + {.compatible ="arm,pl011" }, + {.compatible = "arm,pl010"},
You can use:
{.compatible = "arm,pl011", .data = TYPE_PL011},Quoted 7 lines
drivers/serial/serial_pl01x.c +7
-0+ {} +}; + +static int pl01x_serial_ofdata_to_platdata (struct udevice *dev) +{ +struct pl01x_serial_platdata *plat =dev_get_platdata (dev); +fdt_addr_t addr;
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 376
Quoted 10 lines
drivers/serial/serial_pl01x.c +10
-0+const char * type_pl01x; + + addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" ); +if (addr ==FDT_ADDR_T_NONE ) +return -EINVAL ; + + plat->base = addr; + plat->clock =fdtdec_get_int (gd->fdt_blob, dev->of_offset,"clock" ,1 ); + type_pl01x =fdt_getprop (gd->fdt_blob, dev->of_offset, \ +"compatible" ,NULL );
plat->type = dev_get_driver_data(dev);
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 382
Quoted 6 lines
drivers/serial/serial_pl01x.c +6
-0+if (!strcmp (type_pl01x,"arm,pl011" )) + plat->type =TYPE_PL011 ; +else if (!strcmp (type_pl01x,"arm,pl010" )) + plat->type =TYPE_PL010 ; +else +return -EINVAL ;
Should be able to drop this line.
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 395
Quoted 13 lines
drivers/serial/serial_pl01x.c +10
-0+ +return 0 ; +} +#endif +U_BOOT_DRIVER (serial_pl01x) = { .name ="serial_pl01x" , .id =UCLASS_SERIAL , +#ifdef CONFIG_OF_CONTROL + .of_match = pl01x_serial_id, + .ofdata_to_platdata = pl01x_serial_ofdata_to_platdata, + .platdata_auto_alloc_size =sizeof (struct pl01x_serial_platdata ), +#endif
Would be good to get rid of the #ifdef.
I think you can put the last one outside the #ifdef, since device_bind() will do the right thing if there is already platform data.
For the first one you can do .of_match = of_match_ptr(pl01x_serial_id),
But the middle line (ofdata_to_platdata) does need an #ifdef I think. Perhaps we could create something similar to of_match_ptr() for this case?
Quoted 6 lines
drivers/serial/serial_pl01x.c +0
-1.probe = pl01x_serial_probe, .ops = &pl01x_serial_ops, .flags = DM_FLAG_PRE_RELOC, --1.7.9.5
Regards,
Simon
PATCH 1/1 serial: fdt: add device tree support for pl01x
Thanks Simon,
Quoted 53 lines · Simon Glass
+Masahiro, for my
of_match_ptr()comment below.Hi Vikas,
Quoted 48 lines · Vikas Manocha
This patch adds device tree support for arm pl010/pl011 driver.
Signed-off-by Vikas Manocha <[email protected]>--- doc/device-tree-bindings/serial/pl01x.txt | 7 +++++ drivers/serial/serial_pl01x.c | 41 ++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/serial/pl01x.txtdoc/device-tree-bindings/serial/pl01x.txt new file +7
-0@@ -0,0 +1,7 @@ +* ARM AMBA Primecell PL011 & PL010 serial UART + +Required properties: +- compatible: must be "arm,primecell", "arm,pl011" or "arm,pl010" +- reg: exactly one register range with length 0x1000 +- clock: input clock frequency for the UART (used to calculate the baud + rate divisor)drivers/serial/serial_pl01x.c +3
-1@@ -20,6 +20,9 @@#include <dm/platform_data/serial_pl01x.h> #include <linux/compiler.h> #include "serial_pl01x_internal.h" +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR ;#ifndef CONFIG_DM_SERIAL @@ -28,7 +31,6 @@ static enum pl01x_type pl01x_type __attribute__ ((section(".data"))); static struct pl01x_regs *base_regs __attribute__ ((section(".data")));#define NUM_PORTS (sizeof(port)/sizeof(port[0])) -DECLARE_GLOBAL_DATA_PTR ;#endif static int pl01x_putc (struct pl01x_regs *regs,char c)@@ -351,9 +353,46 @@ static const struct dm_serial_ops pl01x_serial_ops = { .setbrg = pl01x_serial_setbrg, };
Quoted 7 lines
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 359
Quoted 4 lines
drivers/serial/serial_pl01x.c +4
-0+#ifdef CONFIG_OF_CONTROL +static const struct udevice_id pl01x_serial_id[] ={ + {.compatible ="arm,pl011" }, + {.compatible = "arm,pl010"},You can use:
{.compatible = "arm,pl011", .data = TYPE_PL011},
Thanks for the suggestion.
Quoted 10 lines
Quoted 10 lines
drivers/serial/serial_pl01x.c +10
-0+ {} +}; + +static int pl01x_serial_ofdata_to_platdata (struct udevice *dev) +{ +struct pl01x_serial_platdata *plat =dev_get_platdata (dev); +fdt_addr_t addr; +const char * type_pl01x; + + addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" );
Quoted 8 lines
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 376
Quoted 7 lines
drivers/serial/serial_pl01x.c +7
-0+if (addr ==FDT_ADDR_T_NONE ) +return -EINVAL ; + + plat->base = addr; + plat->clock =fdtdec_get_int (gd->fdt_blob, dev->of_offset,"clock" ,1 ); + type_pl01x =fdt_getprop (gd->fdt_blob, dev->of_offset, \ +"compatible" ,NULL );
plat->type=dev_get_driver_data(dev);
completely agree, it would make the code much cleaner.
Quoted 7 lines
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 382
Quoted 6 lines
drivers/serial/serial_pl01x.c +6
-0+if (!strcmp (type_pl01x,"arm,pl011" )) + plat->type =TYPE_PL011 ; +else if (!strcmp (type_pl01x,"arm,pl010" )) + plat->type =TYPE_PL010 ; +else +return -EINVAL ;Should be able to drop this line.
yes, all the above block.
Quoted 15 lines
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 395
Quoted 13 lines
drivers/serial/serial_pl01x.c +10
-0+ +return 0 ; +} +#endif +U_BOOT_DRIVER (serial_pl01x) = { .name ="serial_pl01x" , .id =UCLASS_SERIAL , +#ifdef CONFIG_OF_CONTROL + .of_match = pl01x_serial_id, + .ofdata_to_platdata = pl01x_serial_ofdata_to_platdata, + .platdata_auto_alloc_size =sizeof (struct pl01x_serial_platdata ), +#endifWould be good to get rid of the #ifdef.
Quoted 3 lines
I think you can put the last one outside the #ifdef, since
device_bind()will do the right thing if there is already platform data.
ok.
Quoted 2 lines
For the first one you can do .of_match =
of_match_ptr(pl01x_serial_id),
ok, i will check it.
Rgds,
Vikas
Quoted 13 lines
But the middle line (
ofdata_to_platdata) does need an #ifdef I think. Perhaps we could create something similar toof_match_ptr()for this case?Quoted 6 lines
drivers/serial/serial_pl01x.c +0
-1.probe = pl01x_serial_probe, .ops = &pl01x_serial_ops, .flags = DM_FLAG_PRE_RELOC, --1.7.9.5
Regards,
Simon
PATCH 1/1 serial: fdt: add device tree support for pl01x
Hello Masahiro,
Quoted 112 lines · vikasm
Thanks Simon,
Quoted 53 lines · Simon Glass
+Masahiro, for my
of_match_ptr()comment below.Hi Vikas,
Quoted 48 lines · Vikas Manocha
This patch adds device tree support for arm pl010/pl011 driver.
Signed-off-by Vikas Manocha <[email protected]>--- doc/device-tree-bindings/serial/pl01x.txt | 7 +++++ drivers/serial/serial_pl01x.c | 41 ++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/serial/pl01x.txtdoc/device-tree-bindings/serial/pl01x.txt new file +7
-0@@ -0,0 +1,7 @@ +* ARM AMBA Primecell PL011 & PL010 serial UART + +Required properties: +- compatible: must be "arm,primecell", "arm,pl011" or "arm,pl010" +- reg: exactly one register range with length 0x1000 +- clock: input clock frequency for the UART (used to calculate the baud + rate divisor)drivers/serial/serial_pl01x.c +3
-1@@ -20,6 +20,9 @@#include <dm/platform_data/serial_pl01x.h> #include <linux/compiler.h> #include "serial_pl01x_internal.h" +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR ;#ifndef CONFIG_DM_SERIAL @@ -28,7 +31,6 @@ static enum pl01x_type pl01x_type __attribute__ ((section(".data"))); static struct pl01x_regs *base_regs __attribute__ ((section(".data")));#define NUM_PORTS (sizeof(port)/sizeof(port[0])) -DECLARE_GLOBAL_DATA_PTR ;#endif static int pl01x_putc (struct pl01x_regs *regs,char c)@@ -351,9 +353,46 @@ static const struct dm_serial_ops pl01x_serial_ops = { .setbrg = pl01x_serial_setbrg, };Quoted 7 lines
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 359
Quoted 4 lines
drivers/serial/serial_pl01x.c +4
-0+#ifdef CONFIG_OF_CONTROL +static const struct udevice_id pl01x_serial_id[] ={ + {.compatible ="arm,pl011" }, + {.compatible = "arm,pl010"},You can use:
{.compatible = "arm,pl011", .data = TYPE_PL011},Thanks for the suggestion.
Quoted 10 lines
Quoted 10 lines
drivers/serial/serial_pl01x.c +10
-0+ {} +}; + +static int pl01x_serial_ofdata_to_platdata (struct udevice *dev) +{ +struct pl01x_serial_platdata *plat =dev_get_platdata (dev); +fdt_addr_t addr; +const char * type_pl01x; + + addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" );Quoted 8 lines
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 376
Quoted 7 lines
drivers/serial/serial_pl01x.c +7
-0+if (addr ==FDT_ADDR_T_NONE ) +return -EINVAL ; + + plat->base = addr; + plat->clock =fdtdec_get_int (gd->fdt_blob, dev->of_offset,"clock" ,1 ); + type_pl01x =fdt_getprop (gd->fdt_blob, dev->of_offset, \ +"compatible" ,NULL );
plat->type=dev_get_driver_data(dev);completely agree, it would make the code much cleaner.
Quoted 7 lines
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 382
Quoted 6 lines
drivers/serial/serial_pl01x.c +6
-0+if (!strcmp (type_pl01x,"arm,pl011" )) + plat->type =TYPE_PL011 ; +else if (!strcmp (type_pl01x,"arm,pl010" )) + plat->type =TYPE_PL010 ; +else +return -EINVAL ;Should be able to drop this line.
yes, all the above block.
Quoted 15 lines
drivers/serial/serial_pl01x.c static const struct dm_serial_ops pl01x_serial_ops = { · line 395
Quoted 13 lines
drivers/serial/serial_pl01x.c +10
-0+ +return 0 ; +} +#endif +U_BOOT_DRIVER (serial_pl01x) = { .name ="serial_pl01x" , .id =UCLASS_SERIAL , +#ifdef CONFIG_OF_CONTROL + .of_match = pl01x_serial_id, + .ofdata_to_platdata = pl01x_serial_ofdata_to_platdata, + .platdata_auto_alloc_size =sizeof (struct pl01x_serial_platdata ), +#endifWould be good to get rid of the #ifdef.
Quoted 3 lines
I think you can put the last one outside the #ifdef, since
device_bind()will do the right thing if there is already platform data.
Quoted 11 lines
ok.
Quoted 1 line
For the first one you can do .of_match =
of_match_ptr(pl01x_serial_id),ok, i will check it.
Rgds,
VikasQuoted 3 lines
But the middle line (
ofdata_to_platdata) does need an #ifdef I think. Perhaps we could create something similar toof_match_ptr()for this case?
Any suggestion on this point..can we use of_match_ptr() ?
Rgds,
Vikas
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
drivers/serial/serial_pl01x.c +0
-1.probe = pl01x_serial_probe, .ops = &pl01x_serial_ops, .flags = DM_FLAG_PRE_RELOC, --1.7.9.5
Regards,
Simon