brcm2708: update 3.10 patches with raspberrypi/rpi-3.10.y of 27 Apr. 2014
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0056-spi-bcm2708-add-9-bit-support-using-LoSSI-mode.patch
1 From 4b64ce34aaf88c2869c74efad7cbe5167920625b Mon Sep 17 00:00:00 2001
2 From: notro <notro@tronnes.org>
3 Date: Sat, 26 Jan 2013 20:38:03 +0100
4 Subject: [PATCH 056/196] spi-bcm2708: add 9-bit support using LoSSI mode
5
6 ---
7 drivers/spi/spi-bcm2708.c | 30 ++++++++++++++++++++++++++++--
8 1 file changed, 28 insertions(+), 2 deletions(-)
9
10 diff --git a/drivers/spi/spi-bcm2708.c b/drivers/spi/spi-bcm2708.c
11 index b74aa32..abaa5a6 100644
12 --- a/drivers/spi/spi-bcm2708.c
13 +++ b/drivers/spi/spi-bcm2708.c
14 @@ -146,10 +146,31 @@ static inline void bcm2708_rd_fifo(struct bcm2708_spi *bs, int len)
15 static inline void bcm2708_wr_fifo(struct bcm2708_spi *bs, int len)
16 {
17 u8 byte;
18 + u16 val;
19
20 if (len > bs->len)
21 len = bs->len;
22
23 + if (unlikely(bcm2708_rd(bs, SPI_CS) & SPI_CS_LEN)) {
24 + /* LoSSI mode */
25 + if (unlikely(len % 2)) {
26 + printk(KERN_ERR"bcm2708_wr_fifo: length must be even, skipping.\n");
27 + bs->len = 0;
28 + return;
29 + }
30 + while (len) {
31 + if (bs->tx_buf) {
32 + val = *(const u16 *)bs->tx_buf;
33 + bs->tx_buf += 2;
34 + } else
35 + val = 0;
36 + bcm2708_wr(bs, SPI_FIFO, val);
37 + bs->len -= 2;
38 + len -= 2;
39 + }
40 + return;
41 + }
42 +
43 while (len--) {
44 byte = bs->tx_buf ? *bs->tx_buf++ : 0;
45 bcm2708_wr(bs, SPI_FIFO, byte);
46 @@ -234,8 +255,12 @@ static int bcm2708_setup_state(struct spi_master *master,
47 switch (bpw) {
48 case 8:
49 break;
50 + case 9:
51 + /* Reading in LoSSI mode is a special case. See 'BCM2835 ARM Peripherals' datasheet */
52 + cs |= SPI_CS_LEN;
53 + break;
54 default:
55 - dev_dbg(dev, "setup: invalid bits_per_word %u (must be 8)\n",
56 + dev_dbg(dev, "setup: invalid bits_per_word %u (must be 8 or 9)\n",
57 bpw);
58 return -EINVAL;
59 }
60 @@ -283,7 +308,8 @@ static int bcm2708_process_transfer(struct bcm2708_spi *bs,
61 ret = bcm2708_setup_state(spi->master, &spi->dev, &state,
62 xfer->speed_hz ? xfer->speed_hz : spi->max_speed_hz,
63 spi->chip_select, spi->mode,
64 - spi->bits_per_word);
65 + xfer->bits_per_word ? xfer->bits_per_word :
66 + spi->bits_per_word);
67 if (ret)
68 return ret;
69
70 --
71 1.9.1
72