Skip to content

Commit 61a8dec

Browse files
geertubroonie
authored andcommitted
spi: sh-msiof: Limit minimum divider on R-Car Gen3
On R-Car Gen3 SoCs (excluding R-Car H3 ES1.x, which cannot be used for SPI due to a hardware erratum), BRPS x BRDV = 1/1 is an invalid divider setting. Implement this limitation using an SoC/family-specific minimum divider. Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 3d108f1 commit 61a8dec

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct sh_msiof_chipdata {
3838
u16 tx_fifo_size;
3939
u16 rx_fifo_size;
4040
u16 master_flags;
41+
u16 min_div;
4142
};
4243

4344
struct sh_msiof_spi_priv {
@@ -49,6 +50,7 @@ struct sh_msiof_spi_priv {
4950
struct completion done;
5051
unsigned int tx_fifo_size;
5152
unsigned int rx_fifo_size;
53+
unsigned int min_div;
5254
void *tx_dma_page;
5355
void *rx_dma_page;
5456
dma_addr_t tx_dma_addr;
@@ -261,6 +263,8 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
261263
if (!WARN_ON(!spi_hz || !parent_rate))
262264
div = DIV_ROUND_UP(parent_rate, spi_hz);
263265

266+
div = max_t(unsigned long, div, p->min_div);
267+
264268
for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) {
265269
brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div);
266270
/* SCR_BRDV_DIV_1 is valid only if BRPS is x 1/1 or x 1/2 */
@@ -998,24 +1002,33 @@ static const struct sh_msiof_chipdata sh_data = {
9981002
.tx_fifo_size = 64,
9991003
.rx_fifo_size = 64,
10001004
.master_flags = 0,
1005+
.min_div = 1,
1006+
};
1007+
1008+
static const struct sh_msiof_chipdata rcar_gen2_data = {
1009+
.tx_fifo_size = 64,
1010+
.rx_fifo_size = 64,
1011+
.master_flags = SPI_MASTER_MUST_TX,
1012+
.min_div = 1,
10011013
};
10021014

1003-
static const struct sh_msiof_chipdata r8a779x_data = {
1015+
static const struct sh_msiof_chipdata rcar_gen3_data = {
10041016
.tx_fifo_size = 64,
10051017
.rx_fifo_size = 64,
10061018
.master_flags = SPI_MASTER_MUST_TX,
1019+
.min_div = 2,
10071020
};
10081021

10091022
static const struct of_device_id sh_msiof_match[] = {
10101023
{ .compatible = "renesas,sh-mobile-msiof", .data = &sh_data },
1011-
{ .compatible = "renesas,msiof-r8a7790", .data = &r8a779x_data },
1012-
{ .compatible = "renesas,msiof-r8a7791", .data = &r8a779x_data },
1013-
{ .compatible = "renesas,msiof-r8a7792", .data = &r8a779x_data },
1014-
{ .compatible = "renesas,msiof-r8a7793", .data = &r8a779x_data },
1015-
{ .compatible = "renesas,msiof-r8a7794", .data = &r8a779x_data },
1016-
{ .compatible = "renesas,rcar-gen2-msiof", .data = &r8a779x_data },
1017-
{ .compatible = "renesas,msiof-r8a7796", .data = &r8a779x_data },
1018-
{ .compatible = "renesas,rcar-gen3-msiof", .data = &r8a779x_data },
1024+
{ .compatible = "renesas,msiof-r8a7790", .data = &rcar_gen2_data },
1025+
{ .compatible = "renesas,msiof-r8a7791", .data = &rcar_gen2_data },
1026+
{ .compatible = "renesas,msiof-r8a7792", .data = &rcar_gen2_data },
1027+
{ .compatible = "renesas,msiof-r8a7793", .data = &rcar_gen2_data },
1028+
{ .compatible = "renesas,msiof-r8a7794", .data = &rcar_gen2_data },
1029+
{ .compatible = "renesas,rcar-gen2-msiof", .data = &rcar_gen2_data },
1030+
{ .compatible = "renesas,msiof-r8a7796", .data = &rcar_gen3_data },
1031+
{ .compatible = "renesas,rcar-gen3-msiof", .data = &rcar_gen3_data },
10191032
{ .compatible = "renesas,sh-msiof", .data = &sh_data }, /* Deprecated */
10201033
{},
10211034
};
@@ -1230,6 +1243,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
12301243
platform_set_drvdata(pdev, p);
12311244
p->master = master;
12321245
p->info = info;
1246+
p->min_div = chipdata->min_div;
12331247

12341248
init_completion(&p->done);
12351249

0 commit comments

Comments
 (0)