Skip to content

Commit 304d343

Browse files
LorenzoBianconibroonie
authored andcommitted
spi: add flags parameter to txrx_word function pointers
Add the capability to specify the flag parameter used in bitbang_txrx_be_cpha{0,1} through the txrx_word function pointers of spi_bitbang data structure. That feature will be used to add spi-3wire support to the spi-gpio controller Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 5ba155a commit 304d343

File tree

8 files changed

+57
-44
lines changed

8 files changed

+57
-44
lines changed

drivers/spi/spi-ath79.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static void ath79_spi_cleanup(struct spi_device *spi)
176176
}
177177

178178
static u32 ath79_spi_txrx_mode0(struct spi_device *spi, unsigned int nsecs,
179-
u32 word, u8 bits)
179+
u32 word, u8 bits, unsigned flags)
180180
{
181181
struct ath79_spi *sp = ath79_spidev_to_sp(spi);
182182
u32 ioc = sp->ioc_base;

drivers/spi/spi-bitbang.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,26 @@
4949
struct spi_bitbang_cs {
5050
unsigned nsecs; /* (clock cycle time)/2 */
5151
u32 (*txrx_word)(struct spi_device *spi, unsigned nsecs,
52-
u32 word, u8 bits);
52+
u32 word, u8 bits, unsigned flags);
5353
unsigned (*txrx_bufs)(struct spi_device *,
5454
u32 (*txrx_word)(
5555
struct spi_device *spi,
5656
unsigned nsecs,
57-
u32 word, u8 bits),
58-
unsigned, struct spi_transfer *);
57+
u32 word, u8 bits,
58+
unsigned flags),
59+
unsigned, struct spi_transfer *,
60+
unsigned);
5961
};
6062

6163
static unsigned bitbang_txrx_8(
6264
struct spi_device *spi,
6365
u32 (*txrx_word)(struct spi_device *spi,
6466
unsigned nsecs,
65-
u32 word, u8 bits),
67+
u32 word, u8 bits,
68+
unsigned flags),
6669
unsigned ns,
67-
struct spi_transfer *t
70+
struct spi_transfer *t,
71+
unsigned flags
6872
) {
6973
unsigned bits = t->bits_per_word;
7074
unsigned count = t->len;
@@ -76,7 +80,7 @@ static unsigned bitbang_txrx_8(
7680

7781
if (tx)
7882
word = *tx++;
79-
word = txrx_word(spi, ns, word, bits);
83+
word = txrx_word(spi, ns, word, bits, flags);
8084
if (rx)
8185
*rx++ = word;
8286
count -= 1;
@@ -88,9 +92,11 @@ static unsigned bitbang_txrx_16(
8892
struct spi_device *spi,
8993
u32 (*txrx_word)(struct spi_device *spi,
9094
unsigned nsecs,
91-
u32 word, u8 bits),
95+
u32 word, u8 bits,
96+
unsigned flags),
9297
unsigned ns,
93-
struct spi_transfer *t
98+
struct spi_transfer *t,
99+
unsigned flags
94100
) {
95101
unsigned bits = t->bits_per_word;
96102
unsigned count = t->len;
@@ -102,7 +108,7 @@ static unsigned bitbang_txrx_16(
102108

103109
if (tx)
104110
word = *tx++;
105-
word = txrx_word(spi, ns, word, bits);
111+
word = txrx_word(spi, ns, word, bits, flags);
106112
if (rx)
107113
*rx++ = word;
108114
count -= 2;
@@ -114,9 +120,11 @@ static unsigned bitbang_txrx_32(
114120
struct spi_device *spi,
115121
u32 (*txrx_word)(struct spi_device *spi,
116122
unsigned nsecs,
117-
u32 word, u8 bits),
123+
u32 word, u8 bits,
124+
unsigned flags),
118125
unsigned ns,
119-
struct spi_transfer *t
126+
struct spi_transfer *t,
127+
unsigned flags
120128
) {
121129
unsigned bits = t->bits_per_word;
122130
unsigned count = t->len;
@@ -128,7 +136,7 @@ static unsigned bitbang_txrx_32(
128136

129137
if (tx)
130138
word = *tx++;
131-
word = txrx_word(spi, ns, word, bits);
139+
word = txrx_word(spi, ns, word, bits, flags);
132140
if (rx)
133141
*rx++ = word;
134142
count -= 4;
@@ -236,7 +244,7 @@ static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
236244
struct spi_bitbang_cs *cs = spi->controller_state;
237245
unsigned nsecs = cs->nsecs;
238246

239-
return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t);
247+
return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t, 0);
240248
}
241249

242250
/*----------------------------------------------------------------------*/

drivers/spi/spi-butterfly.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ static void butterfly_chipselect(struct spi_device *spi, int value)
144144

145145
static u32
146146
butterfly_txrx_word_mode0(struct spi_device *spi, unsigned nsecs, u32 word,
147-
u8 bits)
147+
u8 bits, unsigned flags)
148148
{
149-
return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
149+
return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits);
150150
}
151151

152152
/*----------------------------------------------------------------------*/

drivers/spi/spi-gpio.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,27 +149,27 @@ static inline int getmiso(const struct spi_device *spi)
149149
*/
150150

151151
static u32 spi_gpio_txrx_word_mode0(struct spi_device *spi,
152-
unsigned nsecs, u32 word, u8 bits)
152+
unsigned nsecs, u32 word, u8 bits, unsigned flags)
153153
{
154-
return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
154+
return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits);
155155
}
156156

157157
static u32 spi_gpio_txrx_word_mode1(struct spi_device *spi,
158-
unsigned nsecs, u32 word, u8 bits)
158+
unsigned nsecs, u32 word, u8 bits, unsigned flags)
159159
{
160-
return bitbang_txrx_be_cpha1(spi, nsecs, 0, 0, word, bits);
160+
return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits);
161161
}
162162

163163
static u32 spi_gpio_txrx_word_mode2(struct spi_device *spi,
164-
unsigned nsecs, u32 word, u8 bits)
164+
unsigned nsecs, u32 word, u8 bits, unsigned flags)
165165
{
166-
return bitbang_txrx_be_cpha0(spi, nsecs, 1, 0, word, bits);
166+
return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits);
167167
}
168168

169169
static u32 spi_gpio_txrx_word_mode3(struct spi_device *spi,
170-
unsigned nsecs, u32 word, u8 bits)
170+
unsigned nsecs, u32 word, u8 bits, unsigned flags)
171171
{
172-
return bitbang_txrx_be_cpha1(spi, nsecs, 1, 0, word, bits);
172+
return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits);
173173
}
174174

175175
/*
@@ -183,30 +183,30 @@ static u32 spi_gpio_txrx_word_mode3(struct spi_device *spi,
183183
*/
184184

185185
static u32 spi_gpio_spec_txrx_word_mode0(struct spi_device *spi,
186-
unsigned nsecs, u32 word, u8 bits)
186+
unsigned nsecs, u32 word, u8 bits, unsigned flags)
187187
{
188-
unsigned flags = spi->master->flags;
188+
flags = spi->master->flags;
189189
return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits);
190190
}
191191

192192
static u32 spi_gpio_spec_txrx_word_mode1(struct spi_device *spi,
193-
unsigned nsecs, u32 word, u8 bits)
193+
unsigned nsecs, u32 word, u8 bits, unsigned flags)
194194
{
195-
unsigned flags = spi->master->flags;
195+
flags = spi->master->flags;
196196
return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits);
197197
}
198198

199199
static u32 spi_gpio_spec_txrx_word_mode2(struct spi_device *spi,
200-
unsigned nsecs, u32 word, u8 bits)
200+
unsigned nsecs, u32 word, u8 bits, unsigned flags)
201201
{
202-
unsigned flags = spi->master->flags;
202+
flags = spi->master->flags;
203203
return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits);
204204
}
205205

206206
static u32 spi_gpio_spec_txrx_word_mode3(struct spi_device *spi,
207-
unsigned nsecs, u32 word, u8 bits)
207+
unsigned nsecs, u32 word, u8 bits, unsigned flags)
208208
{
209-
unsigned flags = spi->master->flags;
209+
flags = spi->master->flags;
210210
return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits);
211211
}
212212

drivers/spi/spi-lm70llp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,10 @@ static void lm70_chipselect(struct spi_device *spi, int value)
188188
/*
189189
* Our actual bitbanger routine.
190190
*/
191-
static u32 lm70_txrx(struct spi_device *spi, unsigned nsecs, u32 word, u8 bits)
191+
static u32 lm70_txrx(struct spi_device *spi, unsigned nsecs, u32 word, u8 bits,
192+
unsigned flags)
192193
{
193-
return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
194+
return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits);
194195
}
195196

196197
static void spi_lm70llp_attach(struct parport *p)

drivers/spi/spi-sh-sci.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,27 +80,31 @@ static inline u32 getmiso(struct spi_device *dev)
8080
#include "spi-bitbang-txrx.h"
8181

8282
static u32 sh_sci_spi_txrx_mode0(struct spi_device *spi,
83-
unsigned nsecs, u32 word, u8 bits)
83+
unsigned nsecs, u32 word, u8 bits,
84+
unsigned flags)
8485
{
85-
return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
86+
return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits);
8687
}
8788

8889
static u32 sh_sci_spi_txrx_mode1(struct spi_device *spi,
89-
unsigned nsecs, u32 word, u8 bits)
90+
unsigned nsecs, u32 word, u8 bits,
91+
unsigned flags)
9092
{
91-
return bitbang_txrx_be_cpha1(spi, nsecs, 0, 0, word, bits);
93+
return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits);
9294
}
9395

9496
static u32 sh_sci_spi_txrx_mode2(struct spi_device *spi,
95-
unsigned nsecs, u32 word, u8 bits)
97+
unsigned nsecs, u32 word, u8 bits,
98+
unsigned flags)
9699
{
97-
return bitbang_txrx_be_cpha0(spi, nsecs, 1, 0, word, bits);
100+
return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits);
98101
}
99102

100103
static u32 sh_sci_spi_txrx_mode3(struct spi_device *spi,
101-
unsigned nsecs, u32 word, u8 bits)
104+
unsigned nsecs, u32 word, u8 bits,
105+
unsigned flags)
102106
{
103-
return bitbang_txrx_be_cpha1(spi, nsecs, 1, 0, word, bits);
107+
return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits);
104108
}
105109

106110
static void sh_sci_spi_chipselect(struct spi_device *dev, int value)

drivers/spi/spi-xtensa-xtfpga.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static inline void xtfpga_spi_wait_busy(struct xtfpga_spi *xspi)
5454
}
5555

5656
static u32 xtfpga_spi_txrx_word(struct spi_device *spi, unsigned nsecs,
57-
u32 v, u8 bits)
57+
u32 v, u8 bits, unsigned flags)
5858
{
5959
struct xtfpga_spi *xspi = spi_master_get_devdata(spi->master);
6060

include/linux/spi/spi_bitbang.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct spi_bitbang {
3030
/* txrx_word[SPI_MODE_*]() just looks like a shift register */
3131
u32 (*txrx_word[4])(struct spi_device *spi,
3232
unsigned nsecs,
33-
u32 word, u8 bits);
33+
u32 word, u8 bits, unsigned flags);
3434
};
3535

3636
/* you can call these default bitbang->master methods from your custom

0 commit comments

Comments
 (0)