serial: pl01x: Get clock from clock node if no clock property found
PATCH 1/1 serial: pl01x: Get clock from clock node if no clock property found
From: Siva Durga Prasad Paladugu <[email protected]>
This patch gets clock from clock nodes if no clock property found in serial node.
---
drivers/serial/serial_pl01x.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/serial/serial_pl01x.c +26 -0
@@ -10,6 +10,7 @@/* Simple U-Boot driver for the PrimeCell PL010/PL011 UARTs */ +#include <clk.h> #include <common.h> #include <dm.h> #include <errno.h>
@@ -341,6 +342,9 @@ int pl01x_serial_ofdata_to_platdata(struct udevice *dev) {struct pl01x_serial_platdata *plat =dev_get_platdata (dev);fdt_addr_t addr; +unsigned long clock; +int ret; +struct clk clk; addr =devfdt_get_addr (dev);if (addr ==FDT_ADDR_T_NONE )
@@ -348,6 +352,28 @@ int pl01x_serial_ofdata_to_platdata(struct udevice *dev) plat->base = addr; plat->clock =dev_read_u32_default (dev,"clock" ,1 ); +if (plat->clock ==1 ) { + ret =clk_get_by_index (dev,0 , &clk); +if (ret <0 ) { +dev_err (dev,"failed to get clock\n" ); +return ret; + } + + clock =clk_get_rate (&clk); +if (IS_ERR_VALUE (clock)) { +dev_err (dev,"failed to get rate\n" ); +return clock; + } +debug ("%s: CLK %ld\n" , __func__, clock); + + ret =clk_enable (&clk); +if (ret && ret != -ENOSYS ) { +dev_err (dev,"failed to enable clock\n" ); +return ret; + } + plat->clock = clock; + } + plat->type =dev_get_driver_data (dev); plat->skip_init =dev_read_bool (dev,"skip-init" );
Signature · 1 line
1.9.1
PATCH 1/1 serial: pl01x: Get clock from clock node if no clock property found
Quoted 7 lines · Michal Simek
From: Siva Durga Prasad Paladugu <[email protected]>
This patch gets clock from clock nodes if no clock property found in serial node.
Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Signed-off-by Michal Simek <[email protected]>
Is this what Linux does? If so, you probably want to explicitly state that.
Alex
PATCH 1/1 serial: pl01x: Get clock from clock node if no clock property found
Quoted 5 lines · Alexander Graf
Quoted 2 lines · Michal Simek
From: Siva Durga Prasad Paladugu <[email protected]>
Quoted 7 lines
Quoted 5 lines
This patch gets clock from clock nodes if no clock property found in serial node.
Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Signed-off-by Michal Simek <[email protected]>Is this what Linux does? If so, you probably want to explicitly state that.
yes. Linux does that.
On the other hand reading clock property is something what it is out of dt binding spec.
Thanks,
Michal
PATCH 1/1 serial: pl01x: Get clock from clock node if no clock property found
Quoted 9 lines · Michal Simek
Quoted 8 lines · Alexander Graf
Quoted 5 lines · Michal Simek
From: Siva Durga Prasad Paladugu <[email protected]>
This patch gets clock from clock nodes if no clock property found in serial node.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Signed-off-by Michal Simek <[email protected]>Is this what Linux does? If so, you probably want to explicitly state that.
yes. Linux does that.
On the other hand reading clock property is something what it is out of dt binding spec.
In that case, please at least note that in the patch description or maybe even in a comment in the code, so the next time someone looks at the code they don't get confused :).
Speaking of which, why isn't this handled generically already? I was expecting that find clocks would be a matter of 2 lines of code - or maybe none thanks to magic.
Alex
PATCH 1/1 serial: pl01x: Get clock from clock node if no clock property found
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Michal Simek
Quoted 12 lines · Alexander Graf
Quoted 7 lines · Michal Simek
From: Siva Durga Prasad Paladugu <[email protected]>
This patch gets clock from clock nodes if no clock property found in serial node.
Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Signed-off-by Michal Simek <[email protected]>Is this what Linux does? If so, you probably want to explicitly state that.
Quoted 7 lines
Quoted 3 lines
yes. Linux does that.
On the other hand reading clock property is something what it is out of dt binding spec.In that case, please at least note that in the patch description or maybe even in a comment in the code, so the next time someone looks at the code they don't get confused :).
Right now I have removed this patch from my PR because it is breaking generic arm/arm64 model because there are missing some dt patches on qemu side. Look at our discussing in my PR to Tom done yesterday.
Quoted 4 lines
Speaking of which, why isn't this handled generically already? I was expecting that find clocks would be a matter of 2 lines of code - or maybe none thanks to magic.
It depends.
M