Skip to content

Commit 8743d21

Browse files
Dilip Kotabroonie
authored andcommitted
spi: lantiq: Add fifo size bit mask in SoC specific data structure
On newer chipsets, SPI controller has fifos of larger size. So add the fifo size bit mask entry in SoC specific data structure. Signed-off-by: Dilip Kota <[email protected]> Link: https://lore.kernel.org/r/a0889abf17a9fbc7077f10be0f0342b7ebdf9361.1594957019.git.eswara.kota@linux.intel.com Signed-off-by: Mark Brown <[email protected]>
1 parent 94eca90 commit 8743d21

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

drivers/spi/spi-lantiq-ssc.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@
5858
#define LTQ_SPI_CLC_DISR BIT(0) /* Disable request bit */
5959

6060
#define LTQ_SPI_ID_TXFS_S 24 /* Implemented TX FIFO size */
61-
#define LTQ_SPI_ID_TXFS_M (0x3F << LTQ_SPI_ID_TXFS_S)
6261
#define LTQ_SPI_ID_RXFS_S 16 /* Implemented RX FIFO size */
63-
#define LTQ_SPI_ID_RXFS_M (0x3F << LTQ_SPI_ID_RXFS_S)
6462
#define LTQ_SPI_ID_MOD_S 8 /* Module ID */
6563
#define LTQ_SPI_ID_MOD_M (0xff << LTQ_SPI_ID_MOD_S)
6664
#define LTQ_SPI_ID_CFG_S 5 /* DMA interface support */
@@ -123,19 +121,15 @@
123121
LTQ_SPI_WHBSTATE_CLRTUE)
124122

125123
#define LTQ_SPI_RXFCON_RXFITL_S 8 /* FIFO interrupt trigger level */
126-
#define LTQ_SPI_RXFCON_RXFITL_M (0x3F << LTQ_SPI_RXFCON_RXFITL_S)
127124
#define LTQ_SPI_RXFCON_RXFLU BIT(1) /* FIFO flush */
128125
#define LTQ_SPI_RXFCON_RXFEN BIT(0) /* FIFO enable */
129126

130127
#define LTQ_SPI_TXFCON_TXFITL_S 8 /* FIFO interrupt trigger level */
131-
#define LTQ_SPI_TXFCON_TXFITL_M (0x3F << LTQ_SPI_TXFCON_TXFITL_S)
132128
#define LTQ_SPI_TXFCON_TXFLU BIT(1) /* FIFO flush */
133129
#define LTQ_SPI_TXFCON_TXFEN BIT(0) /* FIFO enable */
134130

135131
#define LTQ_SPI_FSTAT_RXFFL_S 0
136-
#define LTQ_SPI_FSTAT_RXFFL_M (0x3f << LTQ_SPI_FSTAT_RXFFL_S)
137132
#define LTQ_SPI_FSTAT_TXFFL_S 8
138-
#define LTQ_SPI_FSTAT_TXFFL_M (0x3f << LTQ_SPI_FSTAT_TXFFL_S)
139133

140134
#define LTQ_SPI_GPOCON_ISCSBN_S 8
141135
#define LTQ_SPI_GPOCON_INVOUTN_S 0
@@ -161,6 +155,7 @@ struct lantiq_ssc_hwcfg {
161155
unsigned int irncr;
162156
unsigned int irnicr;
163157
bool irq_ack;
158+
u32 fifo_size_mask;
164159
};
165160

166161
struct lantiq_ssc_spi {
@@ -210,16 +205,18 @@ static void lantiq_ssc_maskl(const struct lantiq_ssc_spi *spi, u32 clr,
210205

211206
static unsigned int tx_fifo_level(const struct lantiq_ssc_spi *spi)
212207
{
208+
const struct lantiq_ssc_hwcfg *hwcfg = spi->hwcfg;
213209
u32 fstat = lantiq_ssc_readl(spi, LTQ_SPI_FSTAT);
214210

215-
return (fstat & LTQ_SPI_FSTAT_TXFFL_M) >> LTQ_SPI_FSTAT_TXFFL_S;
211+
return (fstat >> LTQ_SPI_FSTAT_TXFFL_S) & hwcfg->fifo_size_mask;
216212
}
217213

218214
static unsigned int rx_fifo_level(const struct lantiq_ssc_spi *spi)
219215
{
216+
const struct lantiq_ssc_hwcfg *hwcfg = spi->hwcfg;
220217
u32 fstat = lantiq_ssc_readl(spi, LTQ_SPI_FSTAT);
221218

222-
return fstat & LTQ_SPI_FSTAT_RXFFL_M;
219+
return (fstat >> LTQ_SPI_FSTAT_RXFFL_S) & hwcfg->fifo_size_mask;
223220
}
224221

225222
static unsigned int tx_fifo_free(const struct lantiq_ssc_spi *spi)
@@ -807,6 +804,7 @@ static const struct lantiq_ssc_hwcfg lantiq_ssc_xway = {
807804
.irnen_t = LTQ_SPI_IRNEN_T_XWAY,
808805
.irnicr = 0xF8,
809806
.irncr = 0xFC,
807+
.fifo_size_mask = GENMASK(5, 0),
810808
.irq_ack = false,
811809
};
812810

@@ -815,6 +813,7 @@ static const struct lantiq_ssc_hwcfg lantiq_ssc_xrx = {
815813
.irnen_t = LTQ_SPI_IRNEN_T_XRX,
816814
.irnicr = 0xF8,
817815
.irncr = 0xFC,
816+
.fifo_size_mask = GENMASK(5, 0),
818817
.irq_ack = false,
819818
};
820819

@@ -941,8 +940,8 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
941940
INIT_WORK(&spi->work, lantiq_ssc_bussy_work);
942941

943942
id = lantiq_ssc_readl(spi, LTQ_SPI_ID);
944-
spi->tx_fifo_size = (id & LTQ_SPI_ID_TXFS_M) >> LTQ_SPI_ID_TXFS_S;
945-
spi->rx_fifo_size = (id & LTQ_SPI_ID_RXFS_M) >> LTQ_SPI_ID_RXFS_S;
943+
spi->tx_fifo_size = (id >> LTQ_SPI_ID_TXFS_S) & hwcfg->fifo_size_mask;
944+
spi->rx_fifo_size = (id >> LTQ_SPI_ID_RXFS_S) & hwcfg->fifo_size_mask;
946945
supports_dma = (id & LTQ_SPI_ID_CFG_M) >> LTQ_SPI_ID_CFG_S;
947946
revision = id & LTQ_SPI_ID_REV_M;
948947

0 commit comments

Comments
 (0)