Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Broadcom BCM63xx SPI controller support |
| 3 | * |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 4 | * Copyright (C) 2009-2012 Florian Fainelli <florian@openwrt.org> |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 5 | * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version 2 |
| 10 | * of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <linux/kernel.h> |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 19 | #include <linux/clk.h> |
| 20 | #include <linux/io.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/interrupt.h> |
| 25 | #include <linux/spi/spi.h> |
| 26 | #include <linux/completion.h> |
| 27 | #include <linux/err.h> |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 28 | #include <linux/pm_runtime.h> |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 29 | |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 30 | /* BCM 6338/6348 SPI core */ |
| 31 | #define SPI_6348_RSET_SIZE 64 |
| 32 | #define SPI_6348_CMD 0x00 /* 16-bits register */ |
| 33 | #define SPI_6348_INT_STATUS 0x02 |
| 34 | #define SPI_6348_INT_MASK_ST 0x03 |
| 35 | #define SPI_6348_INT_MASK 0x04 |
| 36 | #define SPI_6348_ST 0x05 |
| 37 | #define SPI_6348_CLK_CFG 0x06 |
| 38 | #define SPI_6348_FILL_BYTE 0x07 |
| 39 | #define SPI_6348_MSG_TAIL 0x09 |
| 40 | #define SPI_6348_RX_TAIL 0x0b |
| 41 | #define SPI_6348_MSG_CTL 0x40 /* 8-bits register */ |
| 42 | #define SPI_6348_MSG_CTL_WIDTH 8 |
| 43 | #define SPI_6348_MSG_DATA 0x41 |
| 44 | #define SPI_6348_MSG_DATA_SIZE 0x3f |
| 45 | #define SPI_6348_RX_DATA 0x80 |
| 46 | #define SPI_6348_RX_DATA_SIZE 0x3f |
| 47 | |
| 48 | /* BCM 3368/6358/6262/6368 SPI core */ |
| 49 | #define SPI_6358_RSET_SIZE 1804 |
| 50 | #define SPI_6358_MSG_CTL 0x00 /* 16-bits register */ |
| 51 | #define SPI_6358_MSG_CTL_WIDTH 16 |
| 52 | #define SPI_6358_MSG_DATA 0x02 |
| 53 | #define SPI_6358_MSG_DATA_SIZE 0x21e |
| 54 | #define SPI_6358_RX_DATA 0x400 |
| 55 | #define SPI_6358_RX_DATA_SIZE 0x220 |
| 56 | #define SPI_6358_CMD 0x700 /* 16-bits register */ |
| 57 | #define SPI_6358_INT_STATUS 0x702 |
| 58 | #define SPI_6358_INT_MASK_ST 0x703 |
| 59 | #define SPI_6358_INT_MASK 0x704 |
| 60 | #define SPI_6358_ST 0x705 |
| 61 | #define SPI_6358_CLK_CFG 0x706 |
| 62 | #define SPI_6358_FILL_BYTE 0x707 |
| 63 | #define SPI_6358_MSG_TAIL 0x709 |
| 64 | #define SPI_6358_RX_TAIL 0x70B |
| 65 | |
| 66 | /* Shared SPI definitions */ |
| 67 | |
| 68 | /* Message configuration */ |
| 69 | #define SPI_FD_RW 0x00 |
| 70 | #define SPI_HD_W 0x01 |
| 71 | #define SPI_HD_R 0x02 |
| 72 | #define SPI_BYTE_CNT_SHIFT 0 |
| 73 | #define SPI_6348_MSG_TYPE_SHIFT 6 |
| 74 | #define SPI_6358_MSG_TYPE_SHIFT 14 |
| 75 | |
| 76 | /* Command */ |
| 77 | #define SPI_CMD_NOOP 0x00 |
| 78 | #define SPI_CMD_SOFT_RESET 0x01 |
| 79 | #define SPI_CMD_HARD_RESET 0x02 |
| 80 | #define SPI_CMD_START_IMMEDIATE 0x03 |
| 81 | #define SPI_CMD_COMMAND_SHIFT 0 |
| 82 | #define SPI_CMD_COMMAND_MASK 0x000f |
| 83 | #define SPI_CMD_DEVICE_ID_SHIFT 4 |
| 84 | #define SPI_CMD_PREPEND_BYTE_CNT_SHIFT 8 |
| 85 | #define SPI_CMD_ONE_BYTE_SHIFT 11 |
| 86 | #define SPI_CMD_ONE_WIRE_SHIFT 12 |
| 87 | #define SPI_DEV_ID_0 0 |
| 88 | #define SPI_DEV_ID_1 1 |
| 89 | #define SPI_DEV_ID_2 2 |
| 90 | #define SPI_DEV_ID_3 3 |
| 91 | |
| 92 | /* Interrupt mask */ |
| 93 | #define SPI_INTR_CMD_DONE 0x01 |
| 94 | #define SPI_INTR_RX_OVERFLOW 0x02 |
| 95 | #define SPI_INTR_TX_UNDERFLOW 0x04 |
| 96 | #define SPI_INTR_TX_OVERFLOW 0x08 |
| 97 | #define SPI_INTR_RX_UNDERFLOW 0x10 |
| 98 | #define SPI_INTR_CLEAR_ALL 0x1f |
| 99 | |
| 100 | /* Status */ |
| 101 | #define SPI_RX_EMPTY 0x02 |
| 102 | #define SPI_CMD_BUSY 0x04 |
| 103 | #define SPI_SERIAL_BUSY 0x08 |
| 104 | |
| 105 | /* Clock configuration */ |
| 106 | #define SPI_CLK_20MHZ 0x00 |
| 107 | #define SPI_CLK_0_391MHZ 0x01 |
| 108 | #define SPI_CLK_0_781MHZ 0x02 /* default */ |
| 109 | #define SPI_CLK_1_563MHZ 0x03 |
| 110 | #define SPI_CLK_3_125MHZ 0x04 |
| 111 | #define SPI_CLK_6_250MHZ 0x05 |
| 112 | #define SPI_CLK_12_50MHZ 0x06 |
| 113 | #define SPI_CLK_MASK 0x07 |
| 114 | #define SPI_SSOFFTIME_MASK 0x38 |
| 115 | #define SPI_SSOFFTIME_SHIFT 3 |
| 116 | #define SPI_BYTE_SWAP 0x80 |
| 117 | |
| 118 | enum bcm63xx_regs_spi { |
| 119 | SPI_CMD, |
| 120 | SPI_INT_STATUS, |
| 121 | SPI_INT_MASK_ST, |
| 122 | SPI_INT_MASK, |
| 123 | SPI_ST, |
| 124 | SPI_CLK_CFG, |
| 125 | SPI_FILL_BYTE, |
| 126 | SPI_MSG_TAIL, |
| 127 | SPI_RX_TAIL, |
| 128 | SPI_MSG_CTL, |
| 129 | SPI_MSG_DATA, |
| 130 | SPI_RX_DATA, |
| 131 | SPI_MSG_TYPE_SHIFT, |
| 132 | SPI_MSG_CTL_WIDTH, |
| 133 | SPI_MSG_DATA_SIZE, |
| 134 | }; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 135 | |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 136 | #define BCM63XX_SPI_MAX_PREPEND 15 |
| 137 | |
Jonas Gorski | 6505999 | 2015-09-10 16:11:40 +0200 | [diff] [blame] | 138 | #define BCM63XX_SPI_MAX_CS 8 |
Jonas Gorski | a45fcea | 2015-09-10 16:11:41 +0200 | [diff] [blame] | 139 | #define BCM63XX_SPI_BUS_NUM 0 |
Jonas Gorski | 6505999 | 2015-09-10 16:11:40 +0200 | [diff] [blame] | 140 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 141 | struct bcm63xx_spi { |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 142 | struct completion done; |
| 143 | |
| 144 | void __iomem *regs; |
| 145 | int irq; |
| 146 | |
| 147 | /* Platform data */ |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 148 | const unsigned long *reg_offsets; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 149 | unsigned fifo_size; |
Florian Fainelli | 5a67044 | 2012-06-18 12:07:51 +0200 | [diff] [blame] | 150 | unsigned int msg_type_shift; |
| 151 | unsigned int msg_ctl_width; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 152 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 153 | /* data iomem */ |
| 154 | u8 __iomem *tx_io; |
| 155 | const u8 __iomem *rx_io; |
| 156 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 157 | struct clk *clk; |
| 158 | struct platform_device *pdev; |
| 159 | }; |
| 160 | |
| 161 | static inline u8 bcm_spi_readb(struct bcm63xx_spi *bs, |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 162 | unsigned int offset) |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 163 | { |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 164 | return readb(bs->regs + bs->reg_offsets[offset]); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | static inline u16 bcm_spi_readw(struct bcm63xx_spi *bs, |
| 168 | unsigned int offset) |
| 169 | { |
Jonas Gorski | 682b528 | 2015-10-12 12:24:21 +0200 | [diff] [blame] | 170 | #ifdef CONFIG_CPU_BIG_ENDIAN |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 171 | return ioread16be(bs->regs + bs->reg_offsets[offset]); |
Jonas Gorski | 158fcc4 | 2015-09-10 16:11:42 +0200 | [diff] [blame] | 172 | #else |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 173 | return readw(bs->regs + bs->reg_offsets[offset]); |
Jonas Gorski | 158fcc4 | 2015-09-10 16:11:42 +0200 | [diff] [blame] | 174 | #endif |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | static inline void bcm_spi_writeb(struct bcm63xx_spi *bs, |
| 178 | u8 value, unsigned int offset) |
| 179 | { |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 180 | writeb(value, bs->regs + bs->reg_offsets[offset]); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | static inline void bcm_spi_writew(struct bcm63xx_spi *bs, |
| 184 | u16 value, unsigned int offset) |
| 185 | { |
Jonas Gorski | 682b528 | 2015-10-12 12:24:21 +0200 | [diff] [blame] | 186 | #ifdef CONFIG_CPU_BIG_ENDIAN |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 187 | iowrite16be(value, bs->regs + bs->reg_offsets[offset]); |
Jonas Gorski | 158fcc4 | 2015-09-10 16:11:42 +0200 | [diff] [blame] | 188 | #else |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 189 | writew(value, bs->regs + bs->reg_offsets[offset]); |
Jonas Gorski | 158fcc4 | 2015-09-10 16:11:42 +0200 | [diff] [blame] | 190 | #endif |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | static const unsigned bcm63xx_spi_freq_table[SPI_CLK_MASK][2] = { |
| 194 | { 20000000, SPI_CLK_20MHZ }, |
| 195 | { 12500000, SPI_CLK_12_50MHZ }, |
| 196 | { 6250000, SPI_CLK_6_250MHZ }, |
| 197 | { 3125000, SPI_CLK_3_125MHZ }, |
| 198 | { 1563000, SPI_CLK_1_563MHZ }, |
| 199 | { 781000, SPI_CLK_0_781MHZ }, |
| 200 | { 391000, SPI_CLK_0_391MHZ } |
| 201 | }; |
| 202 | |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 203 | static void bcm63xx_spi_setup_transfer(struct spi_device *spi, |
| 204 | struct spi_transfer *t) |
| 205 | { |
| 206 | struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master); |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 207 | u8 clk_cfg, reg; |
| 208 | int i; |
| 209 | |
Geert Uytterhoeven | 4dde99b | 2015-11-09 10:28:50 +0100 | [diff] [blame] | 210 | /* Default to lowest clock configuration */ |
| 211 | clk_cfg = SPI_CLK_0_391MHZ; |
| 212 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 213 | /* Find the closest clock configuration */ |
| 214 | for (i = 0; i < SPI_CLK_MASK; i++) { |
Jonas Gorski | 68792e2 | 2013-03-12 00:13:46 +0100 | [diff] [blame] | 215 | if (t->speed_hz >= bcm63xx_spi_freq_table[i][0]) { |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 216 | clk_cfg = bcm63xx_spi_freq_table[i][1]; |
| 217 | break; |
| 218 | } |
| 219 | } |
| 220 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 221 | /* clear existing clock configuration bits of the register */ |
| 222 | reg = bcm_spi_readb(bs, SPI_CLK_CFG); |
| 223 | reg &= ~SPI_CLK_MASK; |
| 224 | reg |= clk_cfg; |
| 225 | |
| 226 | bcm_spi_writeb(bs, reg, SPI_CLK_CFG); |
| 227 | dev_dbg(&spi->dev, "Setting clock register to %02x (hz %d)\n", |
Jonas Gorski | 68792e2 | 2013-03-12 00:13:46 +0100 | [diff] [blame] | 228 | clk_cfg, t->speed_hz); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /* the spi->mode bits understood by this driver: */ |
| 232 | #define MODEBITS (SPI_CPOL | SPI_CPHA) |
| 233 | |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 234 | static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first, |
| 235 | unsigned int num_transfers) |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 236 | { |
| 237 | struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master); |
| 238 | u16 msg_ctl; |
| 239 | u16 cmd; |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 240 | unsigned int i, timeout = 0, prepend_len = 0, len = 0; |
| 241 | struct spi_transfer *t = first; |
| 242 | bool do_rx = false; |
| 243 | bool do_tx = false; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 244 | |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 245 | /* Disable the CMD_DONE interrupt */ |
| 246 | bcm_spi_writeb(bs, 0, SPI_INT_MASK); |
| 247 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 248 | dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n", |
| 249 | t->tx_buf, t->rx_buf, t->len); |
| 250 | |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 251 | if (num_transfers > 1 && t->tx_buf && t->len <= BCM63XX_SPI_MAX_PREPEND) |
| 252 | prepend_len = t->len; |
| 253 | |
| 254 | /* prepare the buffer */ |
| 255 | for (i = 0; i < num_transfers; i++) { |
| 256 | if (t->tx_buf) { |
| 257 | do_tx = true; |
| 258 | memcpy_toio(bs->tx_io + len, t->tx_buf, t->len); |
| 259 | |
| 260 | /* don't prepend more than one tx */ |
| 261 | if (t != first) |
| 262 | prepend_len = 0; |
| 263 | } |
| 264 | |
| 265 | if (t->rx_buf) { |
| 266 | do_rx = true; |
| 267 | /* prepend is half-duplex write only */ |
| 268 | if (t == first) |
| 269 | prepend_len = 0; |
| 270 | } |
| 271 | |
| 272 | len += t->len; |
| 273 | |
| 274 | t = list_entry(t->transfer_list.next, struct spi_transfer, |
| 275 | transfer_list); |
| 276 | } |
| 277 | |
Axel Lin | aa0fe82 | 2014-02-09 11:06:04 +0800 | [diff] [blame] | 278 | reinit_completion(&bs->done); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 279 | |
| 280 | /* Fill in the Message control register */ |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 281 | msg_ctl = (len << SPI_BYTE_CNT_SHIFT); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 282 | |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 283 | if (do_rx && do_tx && prepend_len == 0) |
Florian Fainelli | 5a67044 | 2012-06-18 12:07:51 +0200 | [diff] [blame] | 284 | msg_ctl |= (SPI_FD_RW << bs->msg_type_shift); |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 285 | else if (do_rx) |
Florian Fainelli | 5a67044 | 2012-06-18 12:07:51 +0200 | [diff] [blame] | 286 | msg_ctl |= (SPI_HD_R << bs->msg_type_shift); |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 287 | else if (do_tx) |
Florian Fainelli | 5a67044 | 2012-06-18 12:07:51 +0200 | [diff] [blame] | 288 | msg_ctl |= (SPI_HD_W << bs->msg_type_shift); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 289 | |
Florian Fainelli | 5a67044 | 2012-06-18 12:07:51 +0200 | [diff] [blame] | 290 | switch (bs->msg_ctl_width) { |
| 291 | case 8: |
| 292 | bcm_spi_writeb(bs, msg_ctl, SPI_MSG_CTL); |
| 293 | break; |
| 294 | case 16: |
| 295 | bcm_spi_writew(bs, msg_ctl, SPI_MSG_CTL); |
| 296 | break; |
| 297 | } |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 298 | |
| 299 | /* Issue the transfer */ |
| 300 | cmd = SPI_CMD_START_IMMEDIATE; |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 301 | cmd |= (prepend_len << SPI_CMD_PREPEND_BYTE_CNT_SHIFT); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 302 | cmd |= (spi->chip_select << SPI_CMD_DEVICE_ID_SHIFT); |
| 303 | bcm_spi_writew(bs, cmd, SPI_CMD); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 304 | |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 305 | /* Enable the CMD_DONE interrupt */ |
| 306 | bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 307 | |
Jonas Gorski | c0fde3b | 2013-02-03 15:15:12 +0100 | [diff] [blame] | 308 | timeout = wait_for_completion_timeout(&bs->done, HZ); |
| 309 | if (!timeout) |
| 310 | return -ETIMEDOUT; |
| 311 | |
Jonas Gorski | 20e9e78 | 2013-12-17 21:42:08 +0100 | [diff] [blame] | 312 | if (!do_rx) |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 313 | return 0; |
| 314 | |
| 315 | len = 0; |
| 316 | t = first; |
Jonas Gorski | c0fde3b | 2013-02-03 15:15:12 +0100 | [diff] [blame] | 317 | /* Read out all the data */ |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 318 | for (i = 0; i < num_transfers; i++) { |
| 319 | if (t->rx_buf) |
| 320 | memcpy_fromio(t->rx_buf, bs->rx_io + len, t->len); |
| 321 | |
| 322 | if (t != first || prepend_len == 0) |
| 323 | len += t->len; |
| 324 | |
| 325 | t = list_entry(t->transfer_list.next, struct spi_transfer, |
| 326 | transfer_list); |
| 327 | } |
Jonas Gorski | c0fde3b | 2013-02-03 15:15:12 +0100 | [diff] [blame] | 328 | |
| 329 | return 0; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 330 | } |
| 331 | |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 332 | static int bcm63xx_spi_transfer_one(struct spi_master *master, |
| 333 | struct spi_message *m) |
| 334 | { |
| 335 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 336 | struct spi_transfer *t, *first = NULL; |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 337 | struct spi_device *spi = m->spi; |
| 338 | int status = 0; |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 339 | unsigned int n_transfers = 0, total_len = 0; |
| 340 | bool can_use_prepend = false; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 341 | |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 342 | /* |
| 343 | * This SPI controller does not support keeping CS active after a |
| 344 | * transfer. |
| 345 | * Work around this by merging as many transfers we can into one big |
| 346 | * full-duplex transfers. |
| 347 | */ |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 348 | list_for_each_entry(t, &m->transfers, transfer_list) { |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 349 | if (!first) |
| 350 | first = t; |
| 351 | |
| 352 | n_transfers++; |
| 353 | total_len += t->len; |
| 354 | |
| 355 | if (n_transfers == 2 && !first->rx_buf && !t->tx_buf && |
| 356 | first->len <= BCM63XX_SPI_MAX_PREPEND) |
| 357 | can_use_prepend = true; |
| 358 | else if (can_use_prepend && t->tx_buf) |
| 359 | can_use_prepend = false; |
| 360 | |
Jonas Gorski | c0fde3b | 2013-02-03 15:15:12 +0100 | [diff] [blame] | 361 | /* we can only transfer one fifo worth of data */ |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 362 | if ((can_use_prepend && |
| 363 | total_len > (bs->fifo_size + BCM63XX_SPI_MAX_PREPEND)) || |
| 364 | (!can_use_prepend && total_len > bs->fifo_size)) { |
Jonas Gorski | c0fde3b | 2013-02-03 15:15:12 +0100 | [diff] [blame] | 365 | dev_err(&spi->dev, "unable to do transfers larger than FIFO size (%i > %i)\n", |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 366 | total_len, bs->fifo_size); |
| 367 | status = -EINVAL; |
| 368 | goto exit; |
| 369 | } |
| 370 | |
| 371 | /* all combined transfers have to have the same speed */ |
| 372 | if (t->speed_hz != first->speed_hz) { |
| 373 | dev_err(&spi->dev, "unable to change speed between transfers\n"); |
Jonas Gorski | c0fde3b | 2013-02-03 15:15:12 +0100 | [diff] [blame] | 374 | status = -EINVAL; |
| 375 | goto exit; |
| 376 | } |
| 377 | |
| 378 | /* CS will be deasserted directly after transfer */ |
| 379 | if (t->delay_usecs) { |
| 380 | dev_err(&spi->dev, "unable to keep CS asserted after transfer\n"); |
| 381 | status = -EINVAL; |
| 382 | goto exit; |
| 383 | } |
| 384 | |
Jonas Gorski | b17de07 | 2013-02-03 15:15:13 +0100 | [diff] [blame] | 385 | if (t->cs_change || |
| 386 | list_is_last(&t->transfer_list, &m->transfers)) { |
| 387 | /* configure adapter for a new transfer */ |
| 388 | bcm63xx_spi_setup_transfer(spi, first); |
| 389 | |
| 390 | /* send the data */ |
| 391 | status = bcm63xx_txrx_bufs(spi, first, n_transfers); |
| 392 | if (status) |
| 393 | goto exit; |
| 394 | |
| 395 | m->actual_length += total_len; |
| 396 | |
| 397 | first = NULL; |
| 398 | n_transfers = 0; |
| 399 | total_len = 0; |
| 400 | can_use_prepend = false; |
Jonas Gorski | c0fde3b | 2013-02-03 15:15:12 +0100 | [diff] [blame] | 401 | } |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 402 | } |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 403 | exit: |
| 404 | m->status = status; |
| 405 | spi_finalize_current_message(master); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 406 | |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 407 | return 0; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | /* This driver supports single master mode only. Hence |
| 411 | * CMD_DONE is the only interrupt we care about |
| 412 | */ |
| 413 | static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id) |
| 414 | { |
| 415 | struct spi_master *master = (struct spi_master *)dev_id; |
| 416 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
| 417 | u8 intr; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 418 | |
| 419 | /* Read interupts and clear them immediately */ |
| 420 | intr = bcm_spi_readb(bs, SPI_INT_STATUS); |
| 421 | bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS); |
| 422 | bcm_spi_writeb(bs, 0, SPI_INT_MASK); |
| 423 | |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 424 | /* A transfer completed */ |
| 425 | if (intr & SPI_INTR_CMD_DONE) |
| 426 | complete(&bs->done); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 427 | |
| 428 | return IRQ_HANDLED; |
| 429 | } |
| 430 | |
Jonas Gorski | 0135c03 | 2017-02-20 11:50:09 +0100 | [diff] [blame^] | 431 | static size_t bcm63xx_spi_max_length(struct spi_device *dev) |
| 432 | { |
| 433 | struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master); |
| 434 | |
| 435 | return bs->fifo_size; |
| 436 | } |
| 437 | |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 438 | static const unsigned long bcm6348_spi_reg_offsets[] = { |
| 439 | [SPI_CMD] = SPI_6348_CMD, |
| 440 | [SPI_INT_STATUS] = SPI_6348_INT_STATUS, |
| 441 | [SPI_INT_MASK_ST] = SPI_6348_INT_MASK_ST, |
| 442 | [SPI_INT_MASK] = SPI_6348_INT_MASK, |
| 443 | [SPI_ST] = SPI_6348_ST, |
| 444 | [SPI_CLK_CFG] = SPI_6348_CLK_CFG, |
| 445 | [SPI_FILL_BYTE] = SPI_6348_FILL_BYTE, |
| 446 | [SPI_MSG_TAIL] = SPI_6348_MSG_TAIL, |
| 447 | [SPI_RX_TAIL] = SPI_6348_RX_TAIL, |
| 448 | [SPI_MSG_CTL] = SPI_6348_MSG_CTL, |
| 449 | [SPI_MSG_DATA] = SPI_6348_MSG_DATA, |
| 450 | [SPI_RX_DATA] = SPI_6348_RX_DATA, |
| 451 | [SPI_MSG_TYPE_SHIFT] = SPI_6348_MSG_TYPE_SHIFT, |
| 452 | [SPI_MSG_CTL_WIDTH] = SPI_6348_MSG_CTL_WIDTH, |
| 453 | [SPI_MSG_DATA_SIZE] = SPI_6348_MSG_DATA_SIZE, |
| 454 | }; |
| 455 | |
| 456 | static const unsigned long bcm6358_spi_reg_offsets[] = { |
| 457 | [SPI_CMD] = SPI_6358_CMD, |
| 458 | [SPI_INT_STATUS] = SPI_6358_INT_STATUS, |
| 459 | [SPI_INT_MASK_ST] = SPI_6358_INT_MASK_ST, |
| 460 | [SPI_INT_MASK] = SPI_6358_INT_MASK, |
| 461 | [SPI_ST] = SPI_6358_ST, |
| 462 | [SPI_CLK_CFG] = SPI_6358_CLK_CFG, |
| 463 | [SPI_FILL_BYTE] = SPI_6358_FILL_BYTE, |
| 464 | [SPI_MSG_TAIL] = SPI_6358_MSG_TAIL, |
| 465 | [SPI_RX_TAIL] = SPI_6358_RX_TAIL, |
| 466 | [SPI_MSG_CTL] = SPI_6358_MSG_CTL, |
| 467 | [SPI_MSG_DATA] = SPI_6358_MSG_DATA, |
| 468 | [SPI_RX_DATA] = SPI_6358_RX_DATA, |
| 469 | [SPI_MSG_TYPE_SHIFT] = SPI_6358_MSG_TYPE_SHIFT, |
| 470 | [SPI_MSG_CTL_WIDTH] = SPI_6358_MSG_CTL_WIDTH, |
| 471 | [SPI_MSG_DATA_SIZE] = SPI_6358_MSG_DATA_SIZE, |
| 472 | }; |
| 473 | |
| 474 | static const struct platform_device_id bcm63xx_spi_dev_match[] = { |
| 475 | { |
| 476 | .name = "bcm6348-spi", |
| 477 | .driver_data = (unsigned long)bcm6348_spi_reg_offsets, |
| 478 | }, |
| 479 | { |
| 480 | .name = "bcm6358-spi", |
| 481 | .driver_data = (unsigned long)bcm6358_spi_reg_offsets, |
| 482 | }, |
| 483 | { |
| 484 | }, |
| 485 | }; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 486 | |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 487 | static int bcm63xx_spi_probe(struct platform_device *pdev) |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 488 | { |
| 489 | struct resource *r; |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 490 | const unsigned long *bcm63xx_spireg; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 491 | struct device *dev = &pdev->dev; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 492 | int irq; |
| 493 | struct spi_master *master; |
| 494 | struct clk *clk; |
| 495 | struct bcm63xx_spi *bs; |
| 496 | int ret; |
| 497 | |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 498 | if (!pdev->id_entry->driver_data) |
| 499 | return -EINVAL; |
| 500 | |
| 501 | bcm63xx_spireg = (const unsigned long *)pdev->id_entry->driver_data; |
| 502 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 503 | irq = platform_get_irq(pdev, 0); |
| 504 | if (irq < 0) { |
| 505 | dev_err(dev, "no irq\n"); |
Jingoo Han | acf4fc6 | 2013-12-09 19:20:15 +0900 | [diff] [blame] | 506 | return -ENXIO; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 507 | } |
| 508 | |
Jingoo Han | acf4fc6 | 2013-12-09 19:20:15 +0900 | [diff] [blame] | 509 | clk = devm_clk_get(dev, "spi"); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 510 | if (IS_ERR(clk)) { |
| 511 | dev_err(dev, "no clock for device\n"); |
Jingoo Han | acf4fc6 | 2013-12-09 19:20:15 +0900 | [diff] [blame] | 512 | return PTR_ERR(clk); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | master = spi_alloc_master(dev, sizeof(*bs)); |
| 516 | if (!master) { |
| 517 | dev_err(dev, "out of memory\n"); |
Jingoo Han | acf4fc6 | 2013-12-09 19:20:15 +0900 | [diff] [blame] | 518 | return -ENOMEM; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | bs = spi_master_get_devdata(master); |
Axel Lin | aa0fe82 | 2014-02-09 11:06:04 +0800 | [diff] [blame] | 522 | init_completion(&bs->done); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 523 | |
| 524 | platform_set_drvdata(pdev, master); |
| 525 | bs->pdev = pdev; |
| 526 | |
Julia Lawall | de0fa83 | 2013-08-14 11:11:09 +0200 | [diff] [blame] | 527 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Jonas Gorski | b66c773 | 2013-03-12 00:13:47 +0100 | [diff] [blame] | 528 | bs->regs = devm_ioremap_resource(&pdev->dev, r); |
| 529 | if (IS_ERR(bs->regs)) { |
| 530 | ret = PTR_ERR(bs->regs); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 531 | goto out_err; |
| 532 | } |
| 533 | |
| 534 | bs->irq = irq; |
| 535 | bs->clk = clk; |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 536 | bs->reg_offsets = bcm63xx_spireg; |
| 537 | bs->fifo_size = bs->reg_offsets[SPI_MSG_DATA_SIZE]; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 538 | |
| 539 | ret = devm_request_irq(&pdev->dev, irq, bcm63xx_spi_interrupt, 0, |
| 540 | pdev->name, master); |
| 541 | if (ret) { |
| 542 | dev_err(dev, "unable to request irq\n"); |
| 543 | goto out_err; |
| 544 | } |
| 545 | |
Jonas Gorski | a45fcea | 2015-09-10 16:11:41 +0200 | [diff] [blame] | 546 | master->bus_num = BCM63XX_SPI_BUS_NUM; |
Jonas Gorski | 6505999 | 2015-09-10 16:11:40 +0200 | [diff] [blame] | 547 | master->num_chipselect = BCM63XX_SPI_MAX_CS; |
Florian Fainelli | cde4384 | 2012-04-20 15:37:33 +0200 | [diff] [blame] | 548 | master->transfer_one_message = bcm63xx_spi_transfer_one; |
Florian Fainelli | 88a3a25 | 2012-04-20 15:37:35 +0200 | [diff] [blame] | 549 | master->mode_bits = MODEBITS; |
Stephen Warren | 24778be | 2013-05-21 20:36:35 -0600 | [diff] [blame] | 550 | master->bits_per_word_mask = SPI_BPW_MASK(8); |
Jonas Gorski | 0135c03 | 2017-02-20 11:50:09 +0100 | [diff] [blame^] | 551 | master->max_transfer_size = bcm63xx_spi_max_length; |
| 552 | master->max_message_size = bcm63xx_spi_max_length; |
Mark Brown | 5355d96 | 2013-07-28 15:34:06 +0100 | [diff] [blame] | 553 | master->auto_runtime_pm = true; |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 554 | bs->msg_type_shift = bs->reg_offsets[SPI_MSG_TYPE_SHIFT]; |
| 555 | bs->msg_ctl_width = bs->reg_offsets[SPI_MSG_CTL_WIDTH]; |
| 556 | bs->tx_io = (u8 *)(bs->regs + bs->reg_offsets[SPI_MSG_DATA]); |
| 557 | bs->rx_io = (const u8 *)(bs->regs + bs->reg_offsets[SPI_RX_DATA]); |
Florian Fainelli | 5a67044 | 2012-06-18 12:07:51 +0200 | [diff] [blame] | 558 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 559 | /* Initialize hardware */ |
Jonas Gorski | ea01e8a | 2013-12-17 21:42:09 +0100 | [diff] [blame] | 560 | ret = clk_prepare_enable(bs->clk); |
| 561 | if (ret) |
| 562 | goto out_err; |
| 563 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 564 | bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS); |
| 565 | |
| 566 | /* register and we are done */ |
Jingoo Han | bca7693 | 2013-09-24 13:24:57 +0900 | [diff] [blame] | 567 | ret = devm_spi_register_master(dev, master); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 568 | if (ret) { |
| 569 | dev_err(dev, "spi register failed\n"); |
| 570 | goto out_clk_disable; |
| 571 | } |
| 572 | |
Arnd Bergmann | 0ba2cf7 | 2015-11-12 17:44:34 +0100 | [diff] [blame] | 573 | dev_info(dev, "at %pr (irq %d, FIFOs size %d)\n", |
| 574 | r, irq, bs->fifo_size); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 575 | |
| 576 | return 0; |
| 577 | |
| 578 | out_clk_disable: |
Jonas Gorski | 4fbb82a | 2013-03-12 00:13:38 +0100 | [diff] [blame] | 579 | clk_disable_unprepare(clk); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 580 | out_err: |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 581 | spi_master_put(master); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 582 | return ret; |
| 583 | } |
| 584 | |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 585 | static int bcm63xx_spi_remove(struct platform_device *pdev) |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 586 | { |
Wei Yongjun | 9637b86 | 2013-11-15 15:50:59 +0800 | [diff] [blame] | 587 | struct spi_master *master = platform_get_drvdata(pdev); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 588 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
| 589 | |
| 590 | /* reset spi block */ |
| 591 | bcm_spi_writeb(bs, 0, SPI_INT_MASK); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 592 | |
| 593 | /* HW shutdown */ |
Jonas Gorski | 4fbb82a | 2013-03-12 00:13:38 +0100 | [diff] [blame] | 594 | clk_disable_unprepare(bs->clk); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 595 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 596 | return 0; |
| 597 | } |
| 598 | |
Jonas Gorski | 1bae202 | 2013-12-17 21:42:10 +0100 | [diff] [blame] | 599 | #ifdef CONFIG_PM_SLEEP |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 600 | static int bcm63xx_spi_suspend(struct device *dev) |
| 601 | { |
Axel Lin | a1216394 | 2013-08-09 15:35:16 +0800 | [diff] [blame] | 602 | struct spi_master *master = dev_get_drvdata(dev); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 603 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
| 604 | |
Florian Fainelli | 9651995 | 2012-10-03 11:56:54 +0200 | [diff] [blame] | 605 | spi_master_suspend(master); |
| 606 | |
Jonas Gorski | 4fbb82a | 2013-03-12 00:13:38 +0100 | [diff] [blame] | 607 | clk_disable_unprepare(bs->clk); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 608 | |
| 609 | return 0; |
| 610 | } |
| 611 | |
| 612 | static int bcm63xx_spi_resume(struct device *dev) |
| 613 | { |
Axel Lin | a1216394 | 2013-08-09 15:35:16 +0800 | [diff] [blame] | 614 | struct spi_master *master = dev_get_drvdata(dev); |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 615 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
Jonas Gorski | ea01e8a | 2013-12-17 21:42:09 +0100 | [diff] [blame] | 616 | int ret; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 617 | |
Jonas Gorski | ea01e8a | 2013-12-17 21:42:09 +0100 | [diff] [blame] | 618 | ret = clk_prepare_enable(bs->clk); |
| 619 | if (ret) |
| 620 | return ret; |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 621 | |
Florian Fainelli | 9651995 | 2012-10-03 11:56:54 +0200 | [diff] [blame] | 622 | spi_master_resume(master); |
| 623 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 624 | return 0; |
| 625 | } |
Jonas Gorski | 1bae202 | 2013-12-17 21:42:10 +0100 | [diff] [blame] | 626 | #endif |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 627 | |
| 628 | static const struct dev_pm_ops bcm63xx_spi_pm_ops = { |
Jonas Gorski | 1bae202 | 2013-12-17 21:42:10 +0100 | [diff] [blame] | 629 | SET_SYSTEM_SLEEP_PM_OPS(bcm63xx_spi_suspend, bcm63xx_spi_resume) |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 630 | }; |
| 631 | |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 632 | static struct platform_driver bcm63xx_spi_driver = { |
| 633 | .driver = { |
| 634 | .name = "bcm63xx-spi", |
Jonas Gorski | 1bae202 | 2013-12-17 21:42:10 +0100 | [diff] [blame] | 635 | .pm = &bcm63xx_spi_pm_ops, |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 636 | }, |
Jonas Gorski | 44d8fb3 | 2015-10-12 12:24:23 +0200 | [diff] [blame] | 637 | .id_table = bcm63xx_spi_dev_match, |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 638 | .probe = bcm63xx_spi_probe, |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 639 | .remove = bcm63xx_spi_remove, |
Florian Fainelli | b42dfed | 2012-02-01 11:14:09 +0100 | [diff] [blame] | 640 | }; |
| 641 | |
| 642 | module_platform_driver(bcm63xx_spi_driver); |
| 643 | |
| 644 | MODULE_ALIAS("platform:bcm63xx_spi"); |
| 645 | MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>"); |
| 646 | MODULE_AUTHOR("Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>"); |
| 647 | MODULE_DESCRIPTION("Broadcom BCM63xx SPI Controller driver"); |
| 648 | MODULE_LICENSE("GPL"); |