Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branch 'spi/topic/xilinx' into spi-next

+21 -11
-1
drivers/mfd/timberdale.c
··· 145 145 146 146 static struct xspi_platform_data timberdale_xspi_platform_data = { 147 147 .num_chipselect = 3, 148 - .little_endian = true, 149 148 /* bits per word and devices will be filled in runtime depending 150 149 * on the HW config 151 150 */
+21 -9
drivers/spi/spi-xilinx.c
··· 30 30 */ 31 31 #define XSPI_CR_OFFSET 0x60 /* Control Register */ 32 32 33 + #define XSPI_CR_LOOP 0x01 33 34 #define XSPI_CR_ENABLE 0x02 34 35 #define XSPI_CR_MASTER_MODE 0x04 35 36 #define XSPI_CR_CPOL 0x08 ··· 341 340 MODULE_DEVICE_TABLE(of, xilinx_spi_of_match); 342 341 343 342 struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, 344 - u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word) 343 + u32 irq, s16 bus_num, int num_cs, int bits_per_word) 345 344 { 346 345 struct spi_master *master; 347 346 struct xilinx_spi *xspi; 348 347 int ret; 348 + u32 tmp; 349 349 350 350 master = spi_alloc_master(dev, sizeof(struct xilinx_spi)); 351 351 if (!master) ··· 378 376 379 377 xspi->mem = *mem; 380 378 xspi->irq = irq; 381 - if (little_endian) { 382 - xspi->read_fn = xspi_read32; 383 - xspi->write_fn = xspi_write32; 384 - } else { 379 + 380 + /* 381 + * Detect endianess on the IP via loop bit in CR. Detection 382 + * must be done before reset is sent because incorrect reset 383 + * value generates error interrupt. 384 + * Setup little endian helper functions first and try to use them 385 + * and check if bit was correctly setup or not. 386 + */ 387 + xspi->read_fn = xspi_read32; 388 + xspi->write_fn = xspi_write32; 389 + 390 + xspi->write_fn(XSPI_CR_LOOP, xspi->regs + XSPI_CR_OFFSET); 391 + tmp = xspi->read_fn(xspi->regs + XSPI_CR_OFFSET); 392 + tmp &= XSPI_CR_LOOP; 393 + if (tmp != XSPI_CR_LOOP) { 385 394 xspi->read_fn = xspi_read32_be; 386 395 xspi->write_fn = xspi_write32_be; 387 396 } 397 + 388 398 xspi->bits_per_word = bits_per_word; 389 399 if (xspi->bits_per_word == 8) { 390 400 xspi->tx_fn = xspi_tx8; ··· 460 446 { 461 447 struct xspi_platform_data *pdata; 462 448 struct resource *r; 463 - int irq, num_cs = 0, little_endian = 0, bits_per_word = 8; 449 + int irq, num_cs = 0, bits_per_word = 8; 464 450 struct spi_master *master; 465 451 u8 i; 466 452 467 453 pdata = dev->dev.platform_data; 468 454 if (pdata) { 469 455 num_cs = pdata->num_chipselect; 470 - little_endian = pdata->little_endian; 471 456 bits_per_word = pdata->bits_per_word; 472 457 } 473 458 ··· 498 485 return -ENXIO; 499 486 500 487 master = xilinx_spi_init(&dev->dev, r, irq, dev->id, num_cs, 501 - little_endian, bits_per_word); 488 + bits_per_word); 502 489 if (!master) 503 490 return -ENODEV; 504 491 ··· 514 501 static int xilinx_spi_remove(struct platform_device *dev) 515 502 { 516 503 xilinx_spi_deinit(platform_get_drvdata(dev)); 517 - platform_set_drvdata(dev, 0); 518 504 519 505 return 0; 520 506 }
-1
include/linux/spi/xilinx_spi.h
··· 11 11 */ 12 12 struct xspi_platform_data { 13 13 u16 num_chipselect; 14 - bool little_endian; 15 14 u8 bits_per_word; 16 15 struct spi_board_info *devices; 17 16 u8 num_devices;