Skip to content

Commit af9019b

Browse files
rohitvisavaliabebarino
authored andcommitted
clk: xilinx: vcu: Update vcu init/reset sequence
Updated vcu init/reset sequence as per design changes. If VCU reset GPIO is available then do assert and de-assert it before enabling/disabling gasket isolation. This GPIO is added because gasket isolation will be removed during startup that requires access to SLCR register space. Post startup, the ownership of the register interface lies with logiCORE IP. Signed-off-by: Rohit Visavalia <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 3b0abc4 commit af9019b

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/clk/xilinx/xlnx_vcu.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/clk-provider.h>
1212
#include <linux/device.h>
1313
#include <linux/errno.h>
14+
#include <linux/gpio/consumer.h>
1415
#include <linux/io.h>
1516
#include <linux/mfd/syscon.h>
1617
#include <linux/mfd/syscon/xlnx-vcu.h>
@@ -51,6 +52,7 @@
5152
* @dev: Platform device
5253
* @pll_ref: pll ref clock source
5354
* @aclk: axi clock source
55+
* @reset_gpio: vcu reset gpio
5456
* @logicore_reg_ba: logicore reg base address
5557
* @vcu_slcr_ba: vcu_slcr Register base address
5658
* @pll: handle for the VCU PLL
@@ -61,6 +63,7 @@ struct xvcu_device {
6163
struct device *dev;
6264
struct clk *pll_ref;
6365
struct clk *aclk;
66+
struct gpio_desc *reset_gpio;
6467
struct regmap *logicore_reg_ba;
6568
void __iomem *vcu_slcr_ba;
6669
struct clk_hw *pll;
@@ -676,6 +679,24 @@ static int xvcu_probe(struct platform_device *pdev)
676679
* Bit 0 : Gasket isolation
677680
* Bit 1 : put VCU out of reset
678681
*/
682+
xvcu->reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
683+
GPIOD_OUT_LOW);
684+
if (IS_ERR(xvcu->reset_gpio)) {
685+
ret = PTR_ERR(xvcu->reset_gpio);
686+
dev_err_probe(&pdev->dev, ret, "failed to get reset gpio for vcu.\n");
687+
goto error_get_gpio;
688+
}
689+
690+
if (xvcu->reset_gpio) {
691+
gpiod_set_value(xvcu->reset_gpio, 0);
692+
/* min 2 clock cycle of vcu pll_ref, slowest freq is 33.33KHz */
693+
usleep_range(60, 120);
694+
gpiod_set_value(xvcu->reset_gpio, 1);
695+
usleep_range(60, 120);
696+
} else {
697+
dev_dbg(&pdev->dev, "No reset gpio info found in dts for VCU. This may result in incorrect functionality if VCU isolation is removed after initialization in designs where the VCU reset is driven by gpio.\n");
698+
}
699+
679700
regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, VCU_GASKET_VALUE);
680701

681702
ret = xvcu_register_clock_provider(xvcu);
@@ -690,6 +711,7 @@ static int xvcu_probe(struct platform_device *pdev)
690711

691712
error_clk_provider:
692713
xvcu_unregister_clock_provider(xvcu);
714+
error_get_gpio:
693715
clk_disable_unprepare(xvcu->aclk);
694716
return ret;
695717
}
@@ -711,6 +733,13 @@ static void xvcu_remove(struct platform_device *pdev)
711733
xvcu_unregister_clock_provider(xvcu);
712734

713735
/* Add the Gasket isolation and put the VCU in reset. */
736+
if (xvcu->reset_gpio) {
737+
gpiod_set_value(xvcu->reset_gpio, 0);
738+
/* min 2 clock cycle of vcu pll_ref, slowest freq is 33.33KHz */
739+
usleep_range(60, 120);
740+
gpiod_set_value(xvcu->reset_gpio, 1);
741+
usleep_range(60, 120);
742+
}
714743
regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, 0);
715744

716745
clk_disable_unprepare(xvcu->aclk);

0 commit comments

Comments
 (0)