Skip to content

Commit af103eb

Browse files
Jon Linbroonie
authored andcommitted
spi: rockchip-sfc: Support sclk_x2 version
SFC after version 8 supports dtr mode, so the IO is the binary output of the controller clock. Signed-off-by: Jon Lin <jon.lin@rock-chips.com> Link: https://patch.msgid.link/20241219142216.2123065-1-jon.lin@rock-chips.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1e29357 commit af103eb

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

drivers/spi/spi-rockchip-sfc.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
#define SFC_VER_3 0x3
113113
#define SFC_VER_4 0x4
114114
#define SFC_VER_5 0x5
115+
#define SFC_VER_8 0x8
115116

116117
/* Delay line controller register */
117118
#define SFC_DLL_CTRL0 0x3C
@@ -216,6 +217,22 @@ static u32 rockchip_sfc_get_max_iosize(struct rockchip_sfc *sfc)
216217
return SFC_MAX_IOSIZE_VER3;
217218
}
218219

220+
static int rockchip_sfc_clk_set_rate(struct rockchip_sfc *sfc, unsigned long speed)
221+
{
222+
if (sfc->version >= SFC_VER_8)
223+
return clk_set_rate(sfc->clk, speed * 2);
224+
else
225+
return clk_set_rate(sfc->clk, speed);
226+
}
227+
228+
static unsigned long rockchip_sfc_clk_get_rate(struct rockchip_sfc *sfc)
229+
{
230+
if (sfc->version >= SFC_VER_8)
231+
return clk_get_rate(sfc->clk) / 2;
232+
else
233+
return clk_get_rate(sfc->clk);
234+
}
235+
219236
static void rockchip_sfc_irq_unmask(struct rockchip_sfc *sfc, u32 mask)
220237
{
221238
u32 reg;
@@ -518,12 +535,12 @@ static int rockchip_sfc_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op
518535

519536
if (unlikely(mem->spi->max_speed_hz != sfc->speed[cs]) &&
520537
!has_acpi_companion(sfc->dev)) {
521-
ret = clk_set_rate(sfc->clk, mem->spi->max_speed_hz);
538+
ret = rockchip_sfc_clk_set_rate(sfc, mem->spi->max_speed_hz);
522539
if (ret)
523540
goto out;
524541
sfc->speed[cs] = mem->spi->max_speed_hz;
525542
dev_dbg(sfc->dev, "set_freq=%dHz real_freq=%ldHz\n",
526-
sfc->speed[cs], clk_get_rate(sfc->clk));
543+
sfc->speed[cs], rockchip_sfc_clk_get_rate(sfc));
527544
}
528545

529546
rockchip_sfc_adjust_op_work((struct spi_mem_op *)op);

0 commit comments

Comments
 (0)