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

Merge tag 'spi-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc

Pull spi updates from Mark Brown:
"Since Grant is even more specacularly busy than usual for the time
being I've been collecting SPI patches for him for this release -
probably things will revert back to Grant before the next release.

There's nothing too exciting here, mostly it's simple driver specific
stuff:

- Add spi: to the modaliases of SPI devices to provide namespacing.
- A driver for AD-FMCOMMS1-EBZ.
- DT binding for Orion.
- Fixes and cleanups for i.MX, PL0022, OMAP and bitbang drivers.

There may be a few more fixes I've missed, people keep sending me new
things."

* tag 'spi-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc:
spi/orion: remove uneeded spi_info
spi/bcm63xx: fix clock configuration selection
spi/orion: add device tree binding
spi/omap2: mark omap2_mcspi_master_setup as __devinit
spi: omap2-mcspi: Fix the below warning
spi: Add AD-FMCOMMS1-EBZ I2C-SPI bridge driver
spi/imx: use gpio_is_valid to determine if a gpio is valid
spi/imx: remove redundant config.speed_hz setting
spi/gpio: start with CS non-active
spi: tegra: use dmaengine based dma driver
spi/pl022: cleanup pl022 header documentation
spi/pl022: enable runtime PM
spi/pl022: delete DB5500 support
spi/pl022: disable port when unused
spi: Add "spi:" prefix to modalias attribute of spi devices

+430 -47
+19
Documentation/devicetree/bindings/spi/spi-orion.txt
··· 1 + Marvell Orion SPI device 2 + 3 + Required properties: 4 + - compatible : should be "marvell,orion-spi". 5 + - reg : offset and length of the register set for the device 6 + - cell-index : Which of multiple SPI controllers is this. 7 + Optional properties: 8 + - interrupts : Is currently not used. 9 + 10 + Example: 11 + spi@10600 { 12 + compatible = "marvell,orion-spi"; 13 + #address-cells = <1>; 14 + #size-cells = <0>; 15 + cell-index = <0>; 16 + reg = <0x10600 0x28>; 17 + interrupts = <23>; 18 + status = "disabled"; 19 + };
+8 -1
drivers/spi/Kconfig
··· 357 357 358 358 config SPI_TEGRA 359 359 tristate "Nvidia Tegra SPI controller" 360 - depends on ARCH_TEGRA && TEGRA_SYSTEM_DMA 360 + depends on ARCH_TEGRA && (TEGRA_SYSTEM_DMA || TEGRA20_APB_DMA) 361 361 help 362 362 SPI driver for NVidia Tegra SoCs 363 363 ··· 383 383 depends on GENERIC_GPIO && CPU_TX49XX 384 384 help 385 385 SPI driver for Toshiba TXx9 MIPS SoCs 386 + 387 + config SPI_XCOMM 388 + tristate "Analog Devices AD-FMCOMMS1-EBZ SPI-I2C-bridge driver" 389 + depends on I2C 390 + help 391 + Support for the SPI-I2C bridge found on the Analog Devices 392 + AD-FMCOMMS1-EBZ board. 386 393 387 394 config SPI_XILINX 388 395 tristate "Xilinx SPI controller common module"
+1
drivers/spi/Makefile
··· 61 61 obj-$(CONFIG_SPI_TLE62X0) += spi-tle62x0.o 62 62 obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi-topcliff-pch.o 63 63 obj-$(CONFIG_SPI_TXX9) += spi-txx9.o 64 + obj-$(CONFIG_SPI_XCOMM) += spi-xcomm.o 64 65 obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o 65 66
+1 -1
drivers/spi/spi-bcm63xx.c
··· 129 129 130 130 /* Find the closest clock configuration */ 131 131 for (i = 0; i < SPI_CLK_MASK; i++) { 132 - if (hz <= bcm63xx_spi_freq_table[i][0]) { 132 + if (hz >= bcm63xx_spi_freq_table[i][0]) { 133 133 clk_cfg = bcm63xx_spi_freq_table[i][1]; 134 134 break; 135 135 }
+2 -1
drivers/spi/spi-gpio.c
··· 235 235 status = gpio_request(cs, dev_name(&spi->dev)); 236 236 if (status) 237 237 return status; 238 - status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH); 238 + status = gpio_direction_output(cs, 239 + !(spi->mode & SPI_CS_HIGH)); 239 240 } 240 241 } 241 242 if (!status)
+6 -8
drivers/spi/spi-imx.c
··· 626 626 int active = is_active != BITBANG_CS_INACTIVE; 627 627 int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH); 628 628 629 - if (gpio < 0) 629 + if (!gpio_is_valid(gpio)) 630 630 return; 631 631 632 632 gpio_set_value(gpio, dev_is_lowactive ^ active); ··· 688 688 config.speed_hz = spi->max_speed_hz; 689 689 if (!config.bpw) 690 690 config.bpw = spi->bits_per_word; 691 - if (!config.speed_hz) 692 - config.speed_hz = spi->max_speed_hz; 693 691 694 692 /* Initialize the functions for transfer */ 695 693 if (config.bpw <= 8) { ··· 736 738 dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__, 737 739 spi->mode, spi->bits_per_word, spi->max_speed_hz); 738 740 739 - if (gpio >= 0) 741 + if (gpio_is_valid(gpio)) 740 742 gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1); 741 743 742 744 spi_imx_chipselect(spi, BITBANG_CS_INACTIVE); ··· 789 791 790 792 for (i = 0; i < master->num_chipselect; i++) { 791 793 int cs_gpio = of_get_named_gpio(np, "cs-gpios", i); 792 - if (cs_gpio < 0 && mxc_platform_info) 794 + if (!gpio_is_valid(cs_gpio) && mxc_platform_info) 793 795 cs_gpio = mxc_platform_info->chipselect[i]; 794 796 795 797 spi_imx->chipselect[i] = cs_gpio; 796 - if (cs_gpio < 0) 798 + if (!gpio_is_valid(cs_gpio)) 797 799 continue; 798 800 799 801 ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME); ··· 895 897 release_mem_region(res->start, resource_size(res)); 896 898 out_gpio_free: 897 899 while (--i >= 0) { 898 - if (spi_imx->chipselect[i] >= 0) 900 + if (gpio_is_valid(spi_imx->chipselect[i])) 899 901 gpio_free(spi_imx->chipselect[i]); 900 902 } 901 903 spi_master_put(master); ··· 920 922 iounmap(spi_imx->base); 921 923 922 924 for (i = 0; i < master->num_chipselect; i++) 923 - if (spi_imx->chipselect[i] >= 0) 925 + if (gpio_is_valid(spi_imx->chipselect[i])) 924 926 gpio_free(spi_imx->chipselect[i]); 925 927 926 928 spi_master_put(master);
+5 -3
drivers/spi/spi-omap2-mcspi.c
··· 388 388 389 389 if (tx != NULL) { 390 390 wait_for_completion(&mcspi_dma->dma_tx_completion); 391 - dma_unmap_single(&spi->dev, xfer->tx_dma, count, DMA_TO_DEVICE); 391 + dma_unmap_single(mcspi->dev, xfer->tx_dma, count, 392 + DMA_TO_DEVICE); 392 393 393 394 /* for TX_ONLY mode, be sure all words have shifted out */ 394 395 if (rx == NULL) { ··· 404 403 405 404 if (rx != NULL) { 406 405 wait_for_completion(&mcspi_dma->dma_rx_completion); 407 - dma_unmap_single(&spi->dev, xfer->rx_dma, count, DMA_FROM_DEVICE); 406 + dma_unmap_single(mcspi->dev, xfer->rx_dma, count, 407 + DMA_FROM_DEVICE); 408 408 omap2_mcspi_set_enable(spi, 0); 409 409 410 410 if (l & OMAP2_MCSPI_CHCONF_TURBO) { ··· 1034 1032 return 0; 1035 1033 } 1036 1034 1037 - static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) 1035 + static int __devinit omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) 1038 1036 { 1039 1037 struct spi_master *master = mcspi->master; 1040 1038 struct omap2_mcspi_regs *ctx = &mcspi->ctx;
+17 -5
drivers/spi/spi-orion.c
··· 17 17 #include <linux/io.h> 18 18 #include <linux/spi/spi.h> 19 19 #include <linux/module.h> 20 + #include <linux/of.h> 20 21 #include <linux/clk.h> 21 22 #include <asm/unaligned.h> 22 23 ··· 46 45 void __iomem *base; 47 46 unsigned int max_speed; 48 47 unsigned int min_speed; 49 - struct orion_spi_info *spi_info; 50 48 struct clk *clk; 51 49 }; 52 50 ··· 450 450 struct spi_master *master; 451 451 struct orion_spi *spi; 452 452 struct resource *r; 453 - struct orion_spi_info *spi_info; 454 453 unsigned long tclk_hz; 455 454 int status = 0; 456 - 457 - spi_info = pdev->dev.platform_data; 455 + const u32 *iprop; 456 + int size; 458 457 459 458 master = spi_alloc_master(&pdev->dev, sizeof *spi); 460 459 if (master == NULL) { ··· 463 464 464 465 if (pdev->id != -1) 465 466 master->bus_num = pdev->id; 467 + if (pdev->dev.of_node) { 468 + iprop = of_get_property(pdev->dev.of_node, "cell-index", 469 + &size); 470 + if (iprop && size == sizeof(*iprop)) 471 + master->bus_num = *iprop; 472 + } 466 473 467 474 /* we support only mode 0, and no options */ 468 475 master->mode_bits = 0; ··· 481 476 482 477 spi = spi_master_get_devdata(master); 483 478 spi->master = master; 484 - spi->spi_info = spi_info; 485 479 486 480 spi->clk = clk_get(&pdev->dev, NULL); 487 481 if (IS_ERR(spi->clk)) { ··· 515 511 if (orion_spi_reset(spi) < 0) 516 512 goto out_rel_mem; 517 513 514 + master->dev.of_node = pdev->dev.of_node; 518 515 status = spi_register_master(master); 519 516 if (status < 0) 520 517 goto out_rel_mem; ··· 557 552 558 553 MODULE_ALIAS("platform:" DRIVER_NAME); 559 554 555 + static const struct of_device_id orion_spi_of_match_table[] __devinitdata = { 556 + { .compatible = "marvell,orion-spi", }, 557 + {} 558 + }; 559 + MODULE_DEVICE_TABLE(of, orion_spi_of_match_table); 560 + 560 561 static struct platform_driver orion_spi_driver = { 561 562 .driver = { 562 563 .name = DRIVER_NAME, 563 564 .owner = THIS_MODULE, 565 + .of_match_table = of_match_ptr(orion_spi_of_match_table), 564 566 }, 565 567 .remove = __exit_p(orion_spi_remove), 566 568 };
+9 -14
drivers/spi/spi-pl022.c
··· 489 489 pl022->cur_transfer = NULL; 490 490 pl022->cur_chip = NULL; 491 491 spi_finalize_current_message(pl022->master); 492 + 493 + /* disable the SPI/SSP operation */ 494 + writew((readw(SSP_CR1(pl022->virtbase)) & 495 + (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase)); 496 + 492 497 } 493 498 494 499 /** ··· 2053 2048 printk(KERN_INFO "pl022: mapped registers from 0x%08x to %p\n", 2054 2049 adev->res.start, pl022->virtbase); 2055 2050 2051 + pm_runtime_enable(dev); 2052 + pm_runtime_resume(dev); 2053 + 2056 2054 pl022->clk = clk_get(&adev->dev, NULL); 2057 2055 if (IS_ERR(pl022->clk)) { 2058 2056 status = PTR_ERR(pl022->clk); ··· 2166 2158 clk_disable(pl022->clk); 2167 2159 clk_unprepare(pl022->clk); 2168 2160 clk_put(pl022->clk); 2161 + pm_runtime_disable(&adev->dev); 2169 2162 iounmap(pl022->virtbase); 2170 2163 amba_release_regions(adev); 2171 2164 tasklet_disable(&pl022->pump_transfers); ··· 2260 2251 .loopback = false, 2261 2252 }; 2262 2253 2263 - static struct vendor_data vendor_db5500_pl023 = { 2264 - .fifodepth = 32, 2265 - .max_bpw = 32, 2266 - .unidir = false, 2267 - .extended_cr = true, 2268 - .pl023 = true, 2269 - .loopback = true, 2270 - }; 2271 - 2272 2254 static struct amba_id pl022_ids[] = { 2273 2255 { 2274 2256 /* ··· 2290 2290 .id = 0x00080023, 2291 2291 .mask = 0xffffffff, 2292 2292 .data = &vendor_st_pl023, 2293 - }, 2294 - { 2295 - .id = 0x10080023, 2296 - .mask = 0xffffffff, 2297 - .data = &vendor_db5500_pl023, 2298 2293 }, 2299 2294 { 0, 0 }, 2300 2295 };
+84 -5
drivers/spi/spi-tegra.c
··· 30 30 #include <linux/delay.h> 31 31 32 32 #include <linux/spi/spi.h> 33 + #include <linux/dmaengine.h> 33 34 34 35 #include <mach/dma.h> 35 36 ··· 163 162 * require transfers to be 4 byte aligned we need a bounce buffer 164 163 * for the generic case. 165 164 */ 165 + int dma_req_len; 166 + #if defined(CONFIG_TEGRA_SYSTEM_DMA) 166 167 struct tegra_dma_req rx_dma_req; 167 168 struct tegra_dma_channel *rx_dma; 169 + #else 170 + struct dma_chan *rx_dma; 171 + struct dma_slave_config sconfig; 172 + struct dma_async_tx_descriptor *rx_dma_desc; 173 + dma_cookie_t rx_cookie; 174 + #endif 168 175 u32 *rx_bb; 169 176 dma_addr_t rx_bb_phys; 170 177 }; 171 178 179 + #if !defined(CONFIG_TEGRA_SYSTEM_DMA) 180 + static void tegra_spi_rx_dma_complete(void *args); 181 + #endif 172 182 173 183 static inline unsigned long spi_tegra_readl(struct spi_tegra_data *tspi, 174 184 unsigned long reg) ··· 202 190 203 191 val = spi_tegra_readl(tspi, SLINK_DMA_CTL); 204 192 val &= ~SLINK_DMA_BLOCK_SIZE(~0) & ~SLINK_DMA_EN; 205 - val |= SLINK_DMA_BLOCK_SIZE(tspi->rx_dma_req.size / 4 - 1); 193 + val |= SLINK_DMA_BLOCK_SIZE(tspi->dma_req_len / 4 - 1); 206 194 spi_tegra_writel(tspi, val, SLINK_DMA_CTL); 207 - 195 + #if defined(CONFIG_TEGRA_SYSTEM_DMA) 196 + tspi->rx_dma_req.size = tspi->dma_req_len; 208 197 tegra_dma_enqueue_req(tspi->rx_dma, &tspi->rx_dma_req); 198 + #else 199 + tspi->rx_dma_desc = dmaengine_prep_slave_single(tspi->rx_dma, 200 + tspi->rx_bb_phys, tspi->dma_req_len, 201 + DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT); 202 + if (!tspi->rx_dma_desc) { 203 + dev_err(&tspi->pdev->dev, "dmaengine slave prep failed\n"); 204 + return; 205 + } 206 + tspi->rx_dma_desc->callback = tegra_spi_rx_dma_complete; 207 + tspi->rx_dma_desc->callback_param = tspi; 208 + tspi->rx_cookie = dmaengine_submit(tspi->rx_dma_desc); 209 + dma_async_issue_pending(tspi->rx_dma); 210 + #endif 209 211 210 212 val |= SLINK_DMA_EN; 211 213 spi_tegra_writel(tspi, val, SLINK_DMA_CTL); ··· 247 221 spi_tegra_writel(tspi, val, SLINK_TX_FIFO); 248 222 } 249 223 250 - tspi->rx_dma_req.size = len / tspi->cur_bytes_per_word * 4; 224 + tspi->dma_req_len = len / tspi->cur_bytes_per_word * 4; 251 225 252 226 return len; 253 227 } ··· 344 318 spi_tegra_start_transfer(spi, t); 345 319 } 346 320 347 - static void tegra_spi_rx_dma_complete(struct tegra_dma_req *req) 321 + static void handle_spi_rx_dma_complete(struct spi_tegra_data *tspi) 348 322 { 349 - struct spi_tegra_data *tspi = req->dev; 350 323 unsigned long flags; 351 324 struct spi_message *m; 352 325 struct spi_device *spi; ··· 405 380 406 381 spin_unlock_irqrestore(&tspi->lock, flags); 407 382 } 383 + #if defined(CONFIG_TEGRA_SYSTEM_DMA) 384 + static void tegra_spi_rx_dma_complete(struct tegra_dma_req *req) 385 + { 386 + struct spi_tegra_data *tspi = req->dev; 387 + handle_spi_rx_dma_complete(tspi); 388 + } 389 + #else 390 + static void tegra_spi_rx_dma_complete(void *args) 391 + { 392 + struct spi_tegra_data *tspi = args; 393 + handle_spi_rx_dma_complete(tspi); 394 + } 395 + #endif 408 396 409 397 static int spi_tegra_setup(struct spi_device *spi) 410 398 { ··· 509 471 struct spi_tegra_data *tspi; 510 472 struct resource *r; 511 473 int ret; 474 + #if !defined(CONFIG_TEGRA_SYSTEM_DMA) 475 + dma_cap_mask_t mask; 476 + #endif 512 477 513 478 master = spi_alloc_master(&pdev->dev, sizeof *tspi); 514 479 if (master == NULL) { ··· 563 522 564 523 INIT_LIST_HEAD(&tspi->queue); 565 524 525 + #if defined(CONFIG_TEGRA_SYSTEM_DMA) 566 526 tspi->rx_dma = tegra_dma_allocate_channel(TEGRA_DMA_MODE_ONESHOT); 567 527 if (!tspi->rx_dma) { 568 528 dev_err(&pdev->dev, "can not allocate rx dma channel\n"); 569 529 ret = -ENODEV; 570 530 goto err3; 571 531 } 532 + #else 533 + dma_cap_zero(mask); 534 + dma_cap_set(DMA_SLAVE, mask); 535 + tspi->rx_dma = dma_request_channel(mask, NULL, NULL); 536 + if (!tspi->rx_dma) { 537 + dev_err(&pdev->dev, "can not allocate rx dma channel\n"); 538 + ret = -ENODEV; 539 + goto err3; 540 + } 541 + 542 + #endif 572 543 573 544 tspi->rx_bb = dma_alloc_coherent(&pdev->dev, sizeof(u32) * BB_LEN, 574 545 &tspi->rx_bb_phys, GFP_KERNEL); ··· 590 537 goto err4; 591 538 } 592 539 540 + #if defined(CONFIG_TEGRA_SYSTEM_DMA) 593 541 tspi->rx_dma_req.complete = tegra_spi_rx_dma_complete; 594 542 tspi->rx_dma_req.to_memory = 1; 595 543 tspi->rx_dma_req.dest_addr = tspi->rx_bb_phys; ··· 600 546 tspi->rx_dma_req.source_wrap = 4; 601 547 tspi->rx_dma_req.req_sel = spi_tegra_req_sels[pdev->id]; 602 548 tspi->rx_dma_req.dev = tspi; 549 + #else 550 + /* Dmaengine Dma slave config */ 551 + tspi->sconfig.src_addr = tspi->phys + SLINK_RX_FIFO; 552 + tspi->sconfig.dst_addr = tspi->phys + SLINK_RX_FIFO; 553 + tspi->sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 554 + tspi->sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 555 + tspi->sconfig.slave_id = spi_tegra_req_sels[pdev->id]; 556 + tspi->sconfig.src_maxburst = 1; 557 + tspi->sconfig.dst_maxburst = 1; 558 + ret = dmaengine_device_control(tspi->rx_dma, 559 + DMA_SLAVE_CONFIG, (unsigned long) &tspi->sconfig); 560 + if (ret < 0) { 561 + dev_err(&pdev->dev, "can not do slave configure for dma %d\n", 562 + ret); 563 + goto err4; 564 + } 565 + #endif 603 566 604 567 master->dev.of_node = pdev->dev.of_node; 605 568 ret = spi_register_master(master); ··· 630 559 dma_free_coherent(&pdev->dev, sizeof(u32) * BB_LEN, 631 560 tspi->rx_bb, tspi->rx_bb_phys); 632 561 err4: 562 + #if defined(CONFIG_TEGRA_SYSTEM_DMA) 633 563 tegra_dma_free_channel(tspi->rx_dma); 564 + #else 565 + dma_release_channel(tspi->rx_dma); 566 + #endif 634 567 err3: 635 568 clk_put(tspi->clk); 636 569 err2: ··· 656 581 tspi = spi_master_get_devdata(master); 657 582 658 583 spi_unregister_master(master); 584 + #if defined(CONFIG_TEGRA_SYSTEM_DMA) 659 585 tegra_dma_free_channel(tspi->rx_dma); 586 + #else 587 + dma_release_channel(tspi->rx_dma); 588 + #endif 660 589 661 590 dma_free_coherent(&pdev->dev, sizeof(u32) * BB_LEN, 662 591 tspi->rx_bb, tspi->rx_bb_phys);
+276
drivers/spi/spi-xcomm.c
··· 1 + /* 2 + * Analog Devices AD-FMCOMMS1-EBZ board I2C-SPI bridge driver 3 + * 4 + * Copyright 2012 Analog Devices Inc. 5 + * Author: Lars-Peter Clausen <lars@metafoo.de> 6 + * 7 + * Licensed under the GPL-2 or later. 8 + */ 9 + 10 + #include <linux/kernel.h> 11 + #include <linux/init.h> 12 + #include <linux/module.h> 13 + #include <linux/delay.h> 14 + #include <linux/i2c.h> 15 + #include <linux/spi/spi.h> 16 + #include <asm/unaligned.h> 17 + 18 + #define SPI_XCOMM_SETTINGS_LEN_OFFSET 10 19 + #define SPI_XCOMM_SETTINGS_3WIRE BIT(6) 20 + #define SPI_XCOMM_SETTINGS_CS_HIGH BIT(5) 21 + #define SPI_XCOMM_SETTINGS_SAMPLE_END BIT(4) 22 + #define SPI_XCOMM_SETTINGS_CPHA BIT(3) 23 + #define SPI_XCOMM_SETTINGS_CPOL BIT(2) 24 + #define SPI_XCOMM_SETTINGS_CLOCK_DIV_MASK 0x3 25 + #define SPI_XCOMM_SETTINGS_CLOCK_DIV_64 0x2 26 + #define SPI_XCOMM_SETTINGS_CLOCK_DIV_16 0x1 27 + #define SPI_XCOMM_SETTINGS_CLOCK_DIV_4 0x0 28 + 29 + #define SPI_XCOMM_CMD_UPDATE_CONFIG 0x03 30 + #define SPI_XCOMM_CMD_WRITE 0x04 31 + 32 + #define SPI_XCOMM_CLOCK 48000000 33 + 34 + struct spi_xcomm { 35 + struct i2c_client *i2c; 36 + 37 + uint16_t settings; 38 + uint16_t chipselect; 39 + 40 + unsigned int current_speed; 41 + 42 + uint8_t buf[63]; 43 + }; 44 + 45 + static int spi_xcomm_sync_config(struct spi_xcomm *spi_xcomm, unsigned int len) 46 + { 47 + uint16_t settings; 48 + uint8_t *buf = spi_xcomm->buf; 49 + 50 + settings = spi_xcomm->settings; 51 + settings |= len << SPI_XCOMM_SETTINGS_LEN_OFFSET; 52 + 53 + buf[0] = SPI_XCOMM_CMD_UPDATE_CONFIG; 54 + put_unaligned_be16(settings, &buf[1]); 55 + put_unaligned_be16(spi_xcomm->chipselect, &buf[3]); 56 + 57 + return i2c_master_send(spi_xcomm->i2c, buf, 5); 58 + } 59 + 60 + static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm, 61 + struct spi_device *spi, int is_active) 62 + { 63 + unsigned long cs = spi->chip_select; 64 + uint16_t chipselect = spi_xcomm->chipselect; 65 + 66 + if (is_active) 67 + chipselect |= BIT(cs); 68 + else 69 + chipselect &= ~BIT(cs); 70 + 71 + spi_xcomm->chipselect = chipselect; 72 + } 73 + 74 + static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, 75 + struct spi_device *spi, struct spi_transfer *t, unsigned int *settings) 76 + { 77 + unsigned int speed; 78 + 79 + if ((t->bits_per_word && t->bits_per_word != 8) || t->len > 62) 80 + return -EINVAL; 81 + 82 + speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; 83 + 84 + if (speed != spi_xcomm->current_speed) { 85 + unsigned int divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, speed); 86 + if (divider >= 64) 87 + *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_64; 88 + else if (divider >= 16) 89 + *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_16; 90 + else 91 + *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_4; 92 + 93 + spi_xcomm->current_speed = speed; 94 + } 95 + 96 + if (spi->mode & SPI_CPOL) 97 + *settings |= SPI_XCOMM_SETTINGS_CPOL; 98 + else 99 + *settings &= ~SPI_XCOMM_SETTINGS_CPOL; 100 + 101 + if (spi->mode & SPI_CPHA) 102 + *settings &= ~SPI_XCOMM_SETTINGS_CPHA; 103 + else 104 + *settings |= SPI_XCOMM_SETTINGS_CPHA; 105 + 106 + if (spi->mode & SPI_3WIRE) 107 + *settings |= SPI_XCOMM_SETTINGS_3WIRE; 108 + else 109 + *settings &= ~SPI_XCOMM_SETTINGS_3WIRE; 110 + 111 + return 0; 112 + } 113 + 114 + static int spi_xcomm_txrx_bufs(struct spi_xcomm *spi_xcomm, 115 + struct spi_device *spi, struct spi_transfer *t) 116 + { 117 + int ret; 118 + 119 + if (t->tx_buf) { 120 + spi_xcomm->buf[0] = SPI_XCOMM_CMD_WRITE; 121 + memcpy(spi_xcomm->buf + 1, t->tx_buf, t->len); 122 + 123 + ret = i2c_master_send(spi_xcomm->i2c, spi_xcomm->buf, t->len + 1); 124 + if (ret < 0) 125 + return ret; 126 + else if (ret != t->len + 1) 127 + return -EIO; 128 + } else if (t->rx_buf) { 129 + ret = i2c_master_recv(spi_xcomm->i2c, t->rx_buf, t->len); 130 + if (ret < 0) 131 + return ret; 132 + else if (ret != t->len) 133 + return -EIO; 134 + } 135 + 136 + return t->len; 137 + } 138 + 139 + static int spi_xcomm_transfer_one(struct spi_master *master, 140 + struct spi_message *msg) 141 + { 142 + struct spi_xcomm *spi_xcomm = spi_master_get_devdata(master); 143 + unsigned int settings = spi_xcomm->settings; 144 + struct spi_device *spi = msg->spi; 145 + unsigned cs_change = 0; 146 + struct spi_transfer *t; 147 + bool is_first = true; 148 + int status = 0; 149 + bool is_last; 150 + 151 + is_first = true; 152 + 153 + spi_xcomm_chipselect(spi_xcomm, spi, true); 154 + 155 + list_for_each_entry(t, &msg->transfers, transfer_list) { 156 + 157 + if (!t->tx_buf && !t->rx_buf && t->len) { 158 + status = -EINVAL; 159 + break; 160 + } 161 + 162 + status = spi_xcomm_setup_transfer(spi_xcomm, spi, t, &settings); 163 + if (status < 0) 164 + break; 165 + 166 + is_last = list_is_last(&t->transfer_list, &msg->transfers); 167 + cs_change = t->cs_change; 168 + 169 + if (cs_change ^ is_last) 170 + settings |= BIT(5); 171 + else 172 + settings &= ~BIT(5); 173 + 174 + if (t->rx_buf) { 175 + spi_xcomm->settings = settings; 176 + status = spi_xcomm_sync_config(spi_xcomm, t->len); 177 + if (status < 0) 178 + break; 179 + } else if (settings != spi_xcomm->settings || is_first) { 180 + spi_xcomm->settings = settings; 181 + status = spi_xcomm_sync_config(spi_xcomm, 0); 182 + if (status < 0) 183 + break; 184 + } 185 + 186 + if (t->len) { 187 + status = spi_xcomm_txrx_bufs(spi_xcomm, spi, t); 188 + 189 + if (status < 0) 190 + break; 191 + 192 + if (status > 0) 193 + msg->actual_length += status; 194 + } 195 + status = 0; 196 + 197 + if (t->delay_usecs) 198 + udelay(t->delay_usecs); 199 + 200 + is_first = false; 201 + } 202 + 203 + if (status != 0 || !cs_change) 204 + spi_xcomm_chipselect(spi_xcomm, spi, false); 205 + 206 + msg->status = status; 207 + spi_finalize_current_message(master); 208 + 209 + return status; 210 + } 211 + 212 + static int spi_xcomm_setup(struct spi_device *spi) 213 + { 214 + if (spi->bits_per_word != 8) 215 + return -EINVAL; 216 + 217 + return 0; 218 + } 219 + 220 + static int __devinit spi_xcomm_probe(struct i2c_client *i2c, 221 + const struct i2c_device_id *id) 222 + { 223 + struct spi_xcomm *spi_xcomm; 224 + struct spi_master *master; 225 + int ret; 226 + 227 + master = spi_alloc_master(&i2c->dev, sizeof(*spi_xcomm)); 228 + if (!master) 229 + return -ENOMEM; 230 + 231 + spi_xcomm = spi_master_get_devdata(master); 232 + spi_xcomm->i2c = i2c; 233 + 234 + master->num_chipselect = 16; 235 + master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_3WIRE; 236 + master->flags = SPI_MASTER_HALF_DUPLEX; 237 + master->setup = spi_xcomm_setup; 238 + master->transfer_one_message = spi_xcomm_transfer_one; 239 + master->dev.of_node = i2c->dev.of_node; 240 + i2c_set_clientdata(i2c, master); 241 + 242 + ret = spi_register_master(master); 243 + if (ret < 0) 244 + spi_master_put(master); 245 + 246 + return ret; 247 + } 248 + 249 + static int __devexit spi_xcomm_remove(struct i2c_client *i2c) 250 + { 251 + struct spi_master *master = i2c_get_clientdata(i2c); 252 + 253 + spi_unregister_master(master); 254 + 255 + return 0; 256 + } 257 + 258 + static const struct i2c_device_id spi_xcomm_ids[] = { 259 + { "spi-xcomm" }, 260 + { }, 261 + }; 262 + 263 + static struct i2c_driver spi_xcomm_driver = { 264 + .driver = { 265 + .name = "spi-xcomm", 266 + .owner = THIS_MODULE, 267 + }, 268 + .id_table = spi_xcomm_ids, 269 + .probe = spi_xcomm_probe, 270 + .remove = __devexit_p(spi_xcomm_remove), 271 + }; 272 + module_i2c_driver(spi_xcomm_driver); 273 + 274 + MODULE_LICENSE("GPL"); 275 + MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); 276 + MODULE_DESCRIPTION("Analog Devices AD-FMCOMMS1-EBZ board I2C-SPI bridge driver");
+1 -1
drivers/spi/spi.c
··· 53 53 { 54 54 const struct spi_device *spi = to_spi_device(dev); 55 55 56 - return sprintf(buf, "%s\n", spi->modalias); 56 + return sprintf(buf, "%s%s\n", SPI_MODULE_PREFIX, spi->modalias); 57 57 } 58 58 59 59 static struct device_attribute spi_dev_attrs[] = {
+1 -8
include/linux/amba/pl022.h
··· 231 231 struct dma_chan; 232 232 /** 233 233 * struct pl022_ssp_master - device.platform_data for SPI controller devices. 234 + * @bus_id: identifier for this bus 234 235 * @num_chipselect: chipselects are used to distinguish individual 235 236 * SPI slaves, and are numbered from zero to num_chipselects - 1. 236 237 * each slave has a chipselect signal, but it's common that not ··· 260 259 * struct ssp_config_chip - spi_board_info.controller_data for SPI 261 260 * slave devices, copied to spi_device.controller_data. 262 261 * 263 - * @lbm: used for test purpose to internally connect RX and TX 264 262 * @iface: Interface type(Motorola, TI, Microwire, Universal) 265 263 * @hierarchy: sets whether interface is master or slave 266 264 * @slave_tx_disable: SSPTXD is disconnected (in slave mode only) 267 265 * @clk_freq: Tune freq parameters of SSP(when in master mode) 268 - * @endian_rx: Endianess of Data in Rx FIFO 269 - * @endian_tx: Endianess of Data in Tx FIFO 270 - * @data_size: Width of data element(4 to 32 bits) 271 266 * @com_mode: communication mode: polling, Interrupt or DMA 272 267 * @rx_lev_trig: Rx FIFO watermark level (for IT & DMA mode) 273 268 * @tx_lev_trig: Tx FIFO watermark level (for IT & DMA mode) 274 - * @clk_phase: Motorola SPI interface Clock phase 275 - * @clk_pol: Motorola SPI interface Clock polarity 276 269 * @ctrl_len: Microwire interface: Control length 277 270 * @wait_state: Microwire interface: Wait state 278 271 * @duplex: Microwire interface: Full/Half duplex ··· 274 279 * before sampling the incoming line 275 280 * @cs_control: function pointer to board-specific function to 276 281 * assert/deassert I/O port to control HW generation of devices chip-select. 277 - * @dma_xfer_type: Type of DMA xfer (Mem-to-periph or Periph-to-Periph) 278 - * @dma_config: DMA configuration for SSP controller and peripheral 279 282 */ 280 283 struct pl022_config_chip { 281 284 enum ssp_interface iface;