Skip to content

Commit 73d3bef

Browse files
james-c-linaroHaitXu-Qcom
authored andcommitted
spi: spi-fsl-lpspi: Treat prescale_max == 0 as no erratum
This erratum only ever results in a max value of 1, otherwise the full 3 bits are available. To avoid repeating the same default prescale value for every new device's devdata, treat 0 as no limit (7) and only set a value when the erratum is present. Change the field to be 3 bits to catch out of range definitions. No functionality change. Signed-off-by: James Clark <[email protected]> Reviewed-by: Frank Li <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 2e67b27 commit 73d3bef

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/spi/spi-fsl-lpspi.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
#define SR_CLEAR_MASK GENMASK(13, 8)
8787

8888
struct fsl_lpspi_devtype_data {
89-
u8 prescale_max;
89+
u8 prescale_max : 3; /* 0 == no limit */
9090
};
9191

9292
struct lpspi_config {
@@ -132,15 +132,15 @@ struct fsl_lpspi_data {
132132
};
133133

134134
/*
135-
* ERR051608 fixed or not:
136-
* https://www.nxp.com/docs/en/errata/i.MX93_1P87f.pdf
135+
* Devices with ERR051608 have a max TCR_PRESCALE value of 1, otherwise there is
136+
* no prescale limit: https://www.nxp.com/docs/en/errata/i.MX93_1P87f.pdf
137137
*/
138138
static const struct fsl_lpspi_devtype_data imx93_lpspi_devtype_data = {
139139
.prescale_max = 1,
140140
};
141141

142142
static const struct fsl_lpspi_devtype_data imx7ulp_lpspi_devtype_data = {
143-
.prescale_max = 7,
143+
/* All defaults */
144144
};
145145

146146
static const struct of_device_id fsl_lpspi_dt_ids[] = {
@@ -324,7 +324,7 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
324324
int scldiv;
325325

326326
perclk_rate = clk_get_rate(fsl_lpspi->clk_per);
327-
prescale_max = fsl_lpspi->devtype_data->prescale_max;
327+
prescale_max = fsl_lpspi->devtype_data->prescale_max ?: 7;
328328

329329
if (!config.speed_hz) {
330330
dev_err(fsl_lpspi->dev,

0 commit comments

Comments
 (0)