spi: amlogic-spifc-a1: add support for max_speed_hz
This patch sets the clock rate (spi_transfer->max_speed_hz) from the amlogic_spifc_a1_exec_op(). Signed-off-by: Martin Kurbanov <mmkurbanov@sberdevices.ru> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://lore.kernel.org/r/20230706110331.19794-3-mmkurbanov@sberdevices.ru Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
68a199640d
commit
8d4d4c6813
@ -107,6 +107,7 @@ struct amlogic_spifc_a1 {
|
||||
struct clk *clk;
|
||||
struct device *dev;
|
||||
void __iomem *base;
|
||||
u32 curr_speed_hz;
|
||||
};
|
||||
|
||||
static int amlogic_spifc_a1_request(struct amlogic_spifc_a1 *spifc, bool read)
|
||||
@ -235,6 +236,21 @@ static int amlogic_spifc_a1_write(struct amlogic_spifc_a1 *spifc,
|
||||
return amlogic_spifc_a1_request(spifc, false);
|
||||
}
|
||||
|
||||
static int amlogic_spifc_a1_set_freq(struct amlogic_spifc_a1 *spifc, u32 freq)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (freq == spifc->curr_speed_hz)
|
||||
return 0;
|
||||
|
||||
ret = clk_set_rate(spifc->clk, freq);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
spifc->curr_speed_hz = freq;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int amlogic_spifc_a1_exec_op(struct spi_mem *mem,
|
||||
const struct spi_mem_op *op)
|
||||
{
|
||||
@ -243,6 +259,10 @@ static int amlogic_spifc_a1_exec_op(struct spi_mem *mem,
|
||||
size_t data_size = op->data.nbytes;
|
||||
int ret;
|
||||
|
||||
ret = amlogic_spifc_a1_set_freq(spifc, mem->spi->max_speed_hz);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
amlogic_spifc_a1_user_init(spifc);
|
||||
amlogic_spifc_a1_set_cmd(spifc, SPIFC_A1_USER_CMD(op));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user