Skip to content

Commit ed89355

Browse files
committed
Merge remote-tracking branch 'spi/topic/xilinx' into spi-next
2 parents 592cd34 + 913b196 commit ed89355

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

drivers/mfd/timberdale.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ static struct spi_board_info timberdale_spi_8bit_board_info[] = {
145145

146146
static struct xspi_platform_data timberdale_xspi_platform_data = {
147147
.num_chipselect = 3,
148-
.little_endian = true,
149148
/* bits per word and devices will be filled in runtime depending
150149
* on the HW config
151150
*/

drivers/spi/spi-xilinx.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*/
3131
#define XSPI_CR_OFFSET 0x60 /* Control Register */
3232

33+
#define XSPI_CR_LOOP 0x01
3334
#define XSPI_CR_ENABLE 0x02
3435
#define XSPI_CR_MASTER_MODE 0x04
3536
#define XSPI_CR_CPOL 0x08
@@ -340,11 +341,12 @@ static const struct of_device_id xilinx_spi_of_match[] = {
340341
MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
341342

342343
struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
343-
u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word)
344+
u32 irq, s16 bus_num, int num_cs, int bits_per_word)
344345
{
345346
struct spi_master *master;
346347
struct xilinx_spi *xspi;
347348
int ret;
349+
u32 tmp;
348350

349351
master = spi_alloc_master(dev, sizeof(struct xilinx_spi));
350352
if (!master)
@@ -376,13 +378,25 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
376378

377379
xspi->mem = *mem;
378380
xspi->irq = irq;
379-
if (little_endian) {
380-
xspi->read_fn = xspi_read32;
381-
xspi->write_fn = xspi_write32;
382-
} else {
381+
382+
/*
383+
* Detect endianess on the IP via loop bit in CR. Detection
384+
* must be done before reset is sent because incorrect reset
385+
* value generates error interrupt.
386+
* Setup little endian helper functions first and try to use them
387+
* and check if bit was correctly setup or not.
388+
*/
389+
xspi->read_fn = xspi_read32;
390+
xspi->write_fn = xspi_write32;
391+
392+
xspi->write_fn(XSPI_CR_LOOP, xspi->regs + XSPI_CR_OFFSET);
393+
tmp = xspi->read_fn(xspi->regs + XSPI_CR_OFFSET);
394+
tmp &= XSPI_CR_LOOP;
395+
if (tmp != XSPI_CR_LOOP) {
383396
xspi->read_fn = xspi_read32_be;
384397
xspi->write_fn = xspi_write32_be;
385398
}
399+
386400
xspi->bits_per_word = bits_per_word;
387401
if (xspi->bits_per_word == 8) {
388402
xspi->tx_fn = xspi_tx8;
@@ -446,14 +460,13 @@ static int xilinx_spi_probe(struct platform_device *dev)
446460
{
447461
struct xspi_platform_data *pdata;
448462
struct resource *r;
449-
int irq, num_cs = 0, little_endian = 0, bits_per_word = 8;
463+
int irq, num_cs = 0, bits_per_word = 8;
450464
struct spi_master *master;
451465
u8 i;
452466

453467
pdata = dev->dev.platform_data;
454468
if (pdata) {
455469
num_cs = pdata->num_chipselect;
456-
little_endian = pdata->little_endian;
457470
bits_per_word = pdata->bits_per_word;
458471
}
459472

@@ -485,7 +498,7 @@ static int xilinx_spi_probe(struct platform_device *dev)
485498
return -ENXIO;
486499

487500
master = xilinx_spi_init(&dev->dev, r, irq, dev->id, num_cs,
488-
little_endian, bits_per_word);
501+
bits_per_word);
489502
if (!master)
490503
return -ENODEV;
491504

@@ -501,7 +514,6 @@ static int xilinx_spi_probe(struct platform_device *dev)
501514
static int xilinx_spi_remove(struct platform_device *dev)
502515
{
503516
xilinx_spi_deinit(platform_get_drvdata(dev));
504-
platform_set_drvdata(dev, 0);
505517

506518
return 0;
507519
}

include/linux/spi/xilinx_spi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
*/
1212
struct xspi_platform_data {
1313
u16 num_chipselect;
14-
bool little_endian;
1514
u8 bits_per_word;
1615
struct spi_board_info *devices;
1716
u8 num_devices;

0 commit comments

Comments
 (0)