clk: at91: Improve the clock implementation
Subsystems (7)
v3 cover clk: at91: Improve the clock implementation
Add the clock ops for such as spi0_clk, which is the real clock provider, instead of periph32ck, which only recursively bind its children as clk devices. Also update the clocks called in the drivers.
Changes in v3:
- Remove the unneeded wrapper functions.
- Fix typo, Invaild -> Invalid.
- Add Acked-by tag.
- Fix typo, unneccessary -> unnecessary.
- Add Reviewed-by tag.
Changes in v2:
- Add Acked-by tag.
- For the periph32ck, periph64ck, gck, systemck nodes, they aren't the clock providers, are to house various actual clock providers, use UCLASS_MISC, instead of UCLASS_CLK.
- For *_of_xlate(), add argument check.
- Fix the implementation of the *_get_rate().
- Use documentation-wise variables for *_clk_probe().
- Remove the duplicated code, use the common functions.
- Add Acked-by tag for gpio/atmel_pio4.
Wenyou Yang (7):
clk: clk-uclass: Assign clk->dev before call .of_xlate
clk: at91: Improve the clock implementation
gpio: atmel_pio4: Remove unnecessary clock calling
i2c: at91_i2c: Remove unnecessary clock calling
i2c: at91_i2c: Change error return -ENODEV to -EINVAL
usb: ehci-atmel: Remove unnecessary clock calling
mmc: atmel_sdhci: Remove unnecessary clock calling
drivers/clk/at91/Kconfig | 1 + drivers/clk/at91/clk-generated.c | 87 +++++++++++++++++++++++---------------- drivers/clk/at91/clk-peripheral.c | 72 ++++++++++++++++++++++---------- drivers/clk/at91/clk-system.c | 57 ++++++++++++++----------- drivers/clk/at91/pmc.c | 62 ++++++++++++++++++++++++---- drivers/clk/at91/pmc.h | 5 ++- drivers/clk/clk-uclass.c | 3 ++ drivers/gpio/atmel_pio4.c | 12 ------ drivers/i2c/at91_i2c.c | 18 +------- drivers/mmc/atmel_sdhci.c | 27 +----------- drivers/usb/host/ehci-atmel.c | 15 ------- 11 files changed, 201 insertions(+), 158 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/7 clk: clk-uclass: Assign clk->dev before call .of_xlate
In order to make clk->dev available in ops->of_xlate() to get the clock ID from the 'reg' property of the clock node, assign the clk->dev before calling ops->of_xlate().
---
Changes in v3: None
Changes in v2:
- Add Acked-by tag.
drivers/clk/clk-uclass.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/clk-uclass.c +3 -0
@@ -80,6 +80,9 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk) __func__, ret);return ret; } + + clk->dev = dev_clk; + ops =clk_dev_ops (dev_clk);if (ops->of_xlate)
Signature · 1 line
2.7.4
PATCH v3 1/7 clk: clk-uclass: Assign clk->dev before call .of_xlate
Quoted 6 lines · Wenyou Yang
In order to make
clk->devavailable inops->of_xlate()to get the clock ID from the 'reg' property of the clock node, assign theclk->devbefore callingops->of_xlate().Signed-off-by Wenyou Yang <[email protected]>Acked-by Stephen Warren <[email protected]>
Quoted 8 lines
---
Changes in v3: None
Changes in v2:
- Add Acked-by tag.drivers/clk/clk-uclass.c | 3 +++ 1 file changed, 3 insertions(+)
PATCH v3 1/7 clk: clk-uclass: Assign clk->dev before call .of_xlate
In reply to Wenyou YangDear Wenyou Yang,
Quoted 7 lines · Wenyou Yang
In order to make
clk->devavailable inops->of_xlate()to get the clock ID from the 'reg' property of the clock node, assign theclk->devbefore callingops->of_xlate().Signed-off-by Wenyou Yang <[email protected]>Acked-by Stephen Warren <[email protected]>Acked-by Simon Glass <[email protected]>
Quoted 8 lines
---
Changes in v3: None
Changes in v2:
- Add Acked-by tag.
drivers/clk/clk-uclass.c| 3 +++1 file changed, 3 insertions(+)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann
PATCH v3 2/7 clk: at91: Improve the clock implementation
In reply to Wenyou YangFor the peripheral clock, provide the clock ops for the clock provider, such as spi0_clk. The .of_xlate is to get the clk->id, the .enable is to enable the spi0 peripheral clock, the .get_rate is to get the clock frequency.
The driver for periph32ck node is responsible for recursively binding its children as clk devices, not provide the clock ops.
So do the generated clock and system clock.
---
Changes in v3:
- Remove the unneeded wrapper functions.
- Fix typo, Invaild -> Invalid.
- Add Acked-by tag.
Changes in v2:
- For the periph32ck, periph64ck, gck, systemck nodes, they aren't the clock providers, are to house various actual clock providers, use UCLASS_MISC, instead of UCLASS_CLK.
- For *_of_xlate(), add argument check.
- Fix the implementation of the *_get_rate().
- Use documentation-wise variables for *_clk_probe().
- Remove the duplicated code, use the common functions.
drivers/clk/at91/Kconfig | 1 + drivers/clk/at91/clk-generated.c | 87 +++++++++++++++++++++++---------------- drivers/clk/at91/clk-peripheral.c | 72 ++++++++++++++++++++++---------- drivers/clk/at91/clk-system.c | 57 ++++++++++++++----------- drivers/clk/at91/pmc.c | 62 ++++++++++++++++++++++++---- drivers/clk/at91/pmc.h | 5 ++- 6 files changed, 195 insertions(+), 89 deletions(-)
drivers/clk/at91/Kconfig +1 -0
@@ -1,6 +1,7 @@ config CLK_AT91 bool "AT91 clock drivers" depends on CLK + select MISC help This option is used to enable the AT91 clock driver. The driver supports the AT91 clock generator, including
drivers/clk/at91/clk-generated.c +51 -36
138 lines not on this page · raw message
drivers/clk/at91/clk-peripheral.c +51 -21
89 lines not on this page · raw message
drivers/clk/at91/clk-system.c +33 -24
76 lines not on this page · raw message
drivers/clk/at91/pmc.c +55 -7
89 lines not on this page · raw message
drivers/clk/at91/pmc.h +4 -1
@@ -13,6 +13,9 @@ struct pmc_platdata { };int at91_pmc_core_probe (struct udevice *dev); -int at91_pmc_clk_node_bind (struct udevice *dev); +int at91_clk_sub_device_bind (struct udevice *dev,const char *drv_name); + +int at91_clk_of_xlate (struct clk *clk,struct fdtdec_phandle_args *args); +int at91_clk_probe (struct udevice *dev);#endif
Signature · 1 line
2.7.4
PATCH v3 2/7 clk: at91: Improve the clock implementation
Dear Wenyou Yang,
Quoted 28 lines · Wenyou Yang
For the peripheral clock, provide the clock ops for the clock provider, such as
spi0_clk. The .of_xlate is to get theclk->id, the .enable is to enable the spi0 peripheral clock, the .get_rate is to get the clock frequency.The driver for periph32ck node is responsible for recursively binding its children as clk devices, not provide the clock ops.
So do the generated clock and system clock.
Signed-off-by Wenyou Yang <[email protected]>Acked-by Stephen Warren <[email protected]>---
Changes in v3:
- Remove the unneeded wrapper functions.
- Fix typo, Invaild -> Invalid.
- Add Acked-by tag.Changes in v2:
- For the periph32ck, periph64ck, gck, systemck nodes, they aren't the clock providers, are to house various actual clock providers, useUCLASS_MISC, instead ofUCLASS_CLK.
- For*_of_xlate(), add argument check.
- Fix the implementation of the*_get_rate().
- Use documentation-wise variables for*_clk_probe().
- Remove the duplicated code, use the common functions.
Quoted 7 lines
drivers/clk/at91/Kconfig | 1 + drivers/clk/at91/clk-generated.c | 87 +++++++++++++++++++++++---------------- drivers/clk/at91/clk-peripheral.c | 72 ++++++++++++++++++++++---------- drivers/clk/at91/clk-system.c | 57 ++++++++++++++----------- drivers/clk/at91/pmc.c | 62 ++++++++++++++++++++++++---- drivers/clk/at91/pmc.h | 5 ++- 6 files changed, 195 insertions(+), 89 deletions(-)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann
PATCH v3 3/7 gpio: atmel_pio4: Remove unnecessary clock calling
In reply to Wenyou YangDue to the peripheral clock driver improvement, remove the unnecessary clock calling.
---
Changes in v3: None
Changes in v2:
- Add Acked-by tag for gpio/atmel_pio4.
drivers/gpio/atmel_pio4.c | 12 ------------ 1 file changed, 12 deletions(-)
drivers/gpio/atmel_pio4.c +0 -12
@@ -284,27 +284,15 @@ static int atmel_pio4_probe(struct udevice *dev)struct atmel_pio4_platdata *plat =dev_get_platdata (dev);struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct atmel_pioctrl_data *pioctrl_data; -struct udevice *dev_clk;struct clk clk;fdt_addr_t addr_base;u32 nbanks; -int periph;int ret; ret =clk_get_by_index (dev,0 , &clk);if (ret)return ret; - periph =fdtdec_get_uint (gd->fdt_blob, clk.dev->of_offset,"reg" ,-1 ); -if (periph <0 ) -return -EINVAL ; - - dev_clk =dev_get_parent (clk.dev); - ret =clk_request (dev_clk, &clk); -if (ret) -return ret; - - clk.id = periph; ret =clk_enable (&clk);if (ret)return ret;
Signature · 1 line
2.7.4
PATCH v3 3/7 gpio: atmel_pio4: Remove unnecessary clock calling
Dear Wenyou Yang,
Quoted 5 lines · Wenyou Yang
Due to the peripheral clock driver improvement, remove the unnecessary clock calling.
Signed-off-by Wenyou Yang <[email protected]>Acked-by Stephen Warren <[email protected]>
Quoted 8 lines
---
Changes in v3: None
Changes in v2:
- Add Acked-by tag for gpio/atmel_pio4.
drivers/gpio/atmel_pio4.c| 12 ------------1 file changed, 12 deletions(-)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann
PATCH v3 4/7 i2c: at91_i2c: Remove unnecessary clock calling
In reply to Wenyou YangDue to the peripheral clock driver improvement, remove the unnecessary clock calling.
---
Changes in v3: None
Changes in v2: None
drivers/i2c/at91_i2c.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/i2c/at91_i2c.c +0 -16
@@ -176,34 +176,18 @@ static void at91_calc_i2c_clock(struct udevice *dev, int i2c_clk)static int at91_i2c_enable_clk (struct udevice *dev) {struct at91_i2c_bus *bus =dev_get_priv (dev); -struct udevice *dev_clk;struct clk clk;ulong clk_rate; -int periph;int ret; ret =clk_get_by_index (dev,0 , &clk);if (ret)return -EINVAL ; - periph =fdtdec_get_uint (gd->fdt_blob, clk.dev->of_offset,"reg" ,-1 ); -if (periph <0 ) -return -EINVAL ; - - dev_clk =dev_get_parent (clk.dev); - ret =clk_request (dev_clk, &clk); -if (ret) -return ret; - - clk.id = periph; ret =clk_enable (&clk);if (ret)return ret; - ret =clk_get_by_index (dev_clk,0 , &clk); -if (ret) -return ret; - clk_rate =clk_get_rate (&clk);if (!clk_rate)return -ENODEV ;
Signature · 1 line
2.7.4
PATCH v3 4/7 i2c: at91_i2c: Remove unnecessary clock calling
Dear Wenyou Yang,
Quoted 5 lines · Wenyou Yang
Due to the peripheral clock driver improvement, remove the unnecessary clock calling.
Signed-off-by Wenyou Yang <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Quoted 7 lines
---
Changes in v3: None
Changes in v2: None
drivers/i2c/at91_i2c.c| 16 ----------------1 file changed, 16 deletions(-)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann
PATCH v3 5/7 i2c: at91_i2c: Change error return -ENODEV to -EINVAL
In reply to Wenyou YangChange the error return value -ENODEV from to -EINVAL for more reasonable.
---
Changes in v3: None
Changes in v2: None
drivers/i2c/at91_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/at91_i2c.c +1 -1
@@ -190,7 +190,7 @@ static int at91_i2c_enable_clk(struct udevice *dev) clk_rate =clk_get_rate (&clk);if (!clk_rate) -return -ENODEV ; +return -EINVAL ; bus->bus_clk_rate = clk_rate;
Signature · 1 line
2.7.4
PATCH v3 5/7 i2c: at91_i2c: Change error return -ENODEV to -EINVAL
Dear Wenyou Yang,
Quoted 5 lines · Wenyou Yang
Change the error return value
-ENODEVfrom to-EINVALfor more reasonable.Signed-off-by Wenyou Yang <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Quoted 7 lines
---
Changes in v3: None
Changes in v2: None
drivers/i2c/at91_i2c.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann
PATCH v3 6/7 usb: ehci-atmel: Remove unnecessary clock calling
In reply to Wenyou YangDue to the peripheral clock driver improvement, remove the unnecessary clock calling.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/ehci-atmel.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/usb/host/ehci-atmel.c +0 -15
@@ -56,9 +56,7 @@ struct ehci_atmel_priv {static int ehci_atmel_enable_clk (struct udevice *dev) { -struct udevice *dev_clk;struct clk clk; -int periph;int ret; ret =clk_get_by_index (dev,0 , &clk);
@@ -73,19 +71,6 @@ static int ehci_atmel_enable_clk(struct udevice *dev)if (ret)return -EINVAL ; - periph =fdtdec_get_uint (gd->fdt_blob, clk.dev->of_offset,"reg" ,-1 ); -if (periph <0 ) -return -EINVAL ; - - dev_clk =dev_get_parent (clk.dev); -if (!dev_clk) -return -ENODEV ; - - ret =clk_request (dev_clk, &clk); -if (ret) -return ret; - - clk.id = periph; ret =clk_enable (&clk);if (ret)return ret;
Signature · 1 line
2.7.4
PATCH v3 6/7 usb: ehci-atmel: Remove unnecessary clock calling
Quoted 4 lines · Wenyou Yang
Due to the peripheral clock driver improvement, remove the unnecessary clock calling.
Signed-off-by Wenyou Yang <[email protected]>
Quoted 42 lines
---
Changes in v3: None
Changes in v2: Nonedrivers/usb/host/ehci-atmel.c | 15 --------------- 1 file changed, 15 deletions(-)drivers/usb/host/ehci-atmel.c +0
-15@@ -56,9 +56,7 @@ struct ehci_atmel_priv {static int ehci_atmel_enable_clk (struct udevice *dev) { -struct udevice *dev_clk;struct clk clk; -int periph;int ret; ret =clk_get_by_index (dev,0 , &clk);@@ -73,19 +71,6 @@ static int ehci_atmel_enable_clk(struct udevice *dev)if (ret)return -EINVAL ; - periph =fdtdec_get_uint (gd->fdt_blob, clk.dev->of_offset,"reg" ,-1 ); -if (periph <0 ) -return -EINVAL ; - - dev_clk =dev_get_parent (clk.dev); -if (!dev_clk) -return -ENODEV ; - - ret =clk_request (dev_clk, &clk); -if (ret) -return ret; - - clk.id = periph; ret =clk_enable (&clk);if (ret)return ret;
PATCH v3 6/7 usb: ehci-atmel: Remove unnecessary clock calling
In reply to Wenyou YangDear Wenyou Yang,
Quoted 5 lines · Wenyou Yang
Due to the peripheral clock driver improvement, remove the unnecessary clock calling.
Signed-off-by Wenyou Yang <[email protected]>Reviewed-by Andreas Bie?mann <[email protected]>
Quoted 7 lines
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/ehci-atmel.c| 15 ---------------1 file changed, 15 deletions(-)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann
PATCH v3 7/7 mmc: atmel_sdhci: Remove unnecessary clock calling
In reply to Wenyou YangDue to the peripheral and generated clock driver improvement, remove the unnecessary clock calling.
---
Changes in v3:
- Fix typo, unneccessary -> unnecessary.
- Add Reviewed-by tag.
Changes in v2: None
drivers/mmc/atmel_sdhci.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-)
drivers/mmc/atmel_sdhci.c +2 -25
@@ -51,29 +51,6 @@ struct atmel_sdhci_plat {struct mmc mmc; }; -static int atmel_sdhci_get_clk (struct udevice *dev,int index,struct clk *clk) -{ -struct udevice *dev_clk; -int periph, ret; - - ret =clk_get_by_index (dev, index, clk); -if (ret) -return ret; - - periph =fdtdec_get_uint (gd->fdt_blob, clk->dev->of_offset,"reg" ,-1 ); -if (periph <0 ) -return -EINVAL ; - - dev_clk =dev_get_parent (clk->dev); - ret =clk_request (dev_clk, clk); -if (ret) -return ret; - - clk->id = periph; - -return 0 ; -} -static int atmel_sdhci_probe (struct udevice *dev) {struct mmc_uclass_priv *upriv =dev_get_uclass_priv (dev);
@@ -86,7 +63,7 @@ static int atmel_sdhci_probe(struct udevice *dev)struct clk clk;int ret; - ret =atmel_sdhci_get_clk (dev,0 , &clk); + ret =clk_get_by_index (dev,0 , &clk);if (ret)return ret;
@@ -107,7 +84,7 @@ static int atmel_sdhci_probe(struct udevice *dev) clk_mul = (caps_1 &SDHCI_CLOCK_MUL_MASK ) >>SDHCI_CLOCK_MUL_SHIFT ; gck_rate = clk_base *1000000 * (clk_mul +1 ); - ret =atmel_sdhci_get_clk (dev,1 , &clk); + ret =clk_get_by_index (dev,1 , &clk);if (ret)return ret;
Signature · 1 line
2.7.4
PATCH v3 7/7 mmc: atmel_sdhci: Remove unnecessary clock calling
Dear Wenyou Yang,
Quoted 7 lines · Wenyou Yang
Due to the peripheral and generated clock driver improvement, remove the unnecessary clock calling.
Signed-off-by Wenyou Yang <[email protected]>Reviewed-by Jaehoon Chung <[email protected]>---
Quoted 8 lines
Changes in v3:
- Fix typo, unneccessary -> unnecessary.
- Add Reviewed-by tag.Changes in v2: None
drivers/mmc/atmel_sdhci.c| 27 ++-------------------------1 file changed, 2 insertions(+), 25 deletions(-)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann