From: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@xxxxxxxxxxx> Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@xxxxxxxxxxx> Signed-off-by: Dirk Behme <dirk.behme@xxxxxxxxxxxx> --- drivers/spi/spi-sh-msiof.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index a960e8da123d..2c53fc3f73af 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c @@ -188,6 +188,14 @@ struct sh_msiof_spi_priv { #define IER_RFOVFE 0x00000008 /* Receive FIFO Overflow Enable */ +static int msiof_rcar_is_gen3(struct device *dev) +{ + struct device_node *node = dev->of_node; + + return of_device_is_compatible(node, "renesas,msiof-r8a7795") || + of_device_is_compatible(node, "renesas,msiof-r8a7796"); +} + static u32 sh_msiof_read(struct sh_msiof_spi_priv *p, int reg_offs) { switch (reg_offs) { @@ -1252,6 +1260,8 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) const struct of_device_id *of_id; struct sh_msiof_spi_info *info; struct sh_msiof_spi_priv *p; + struct clk *ref_clk; + u32 clk_rate = 0; int i; int ret; @@ -1352,6 +1362,17 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) goto err2; } + if (msiof_rcar_is_gen3(&master->dev)) { + ref_clk = devm_clk_get(&pdev->dev, "msiof_ref_clk"); + if (!IS_ERR(ref_clk)) + clk_rate = clk_get_rate(ref_clk); + if (clk_rate) { + clk_prepare_enable(p->clk); + clk_set_rate(p->clk, clk_rate); + clk_disable_unprepare(p->clk); + } + } + return 0; err2: -- 2.14.1