Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 1 | /* |
| 2 | * rt5514-spi.c -- RT5514 SPI driver |
| 3 | * |
| 4 | * Copyright 2015 Realtek Semiconductor Corp. |
| 5 | * Author: Oder Chiou <oder_chiou@realtek.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/input.h> |
| 14 | #include <linux/spi/spi.h> |
| 15 | #include <linux/device.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/delay.h> |
| 18 | #include <linux/interrupt.h> |
| 19 | #include <linux/irq.h> |
| 20 | #include <linux/slab.h> |
| 21 | #include <linux/gpio.h> |
| 22 | #include <linux/sched.h> |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 23 | #include <linux/uaccess.h> |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 24 | #include <linux/regulator/consumer.h> |
| 25 | #include <linux/pm_qos.h> |
| 26 | #include <linux/sysfs.h> |
| 27 | #include <linux/clk.h> |
| 28 | #include <sound/core.h> |
| 29 | #include <sound/pcm.h> |
| 30 | #include <sound/pcm_params.h> |
| 31 | #include <sound/soc.h> |
| 32 | #include <sound/soc-dapm.h> |
| 33 | #include <sound/initval.h> |
| 34 | #include <sound/tlv.h> |
| 35 | |
| 36 | #include "rt5514-spi.h" |
| 37 | |
| 38 | static struct spi_device *rt5514_spi; |
| 39 | |
| 40 | struct rt5514_dsp { |
| 41 | struct device *dev; |
| 42 | struct delayed_work copy_work; |
| 43 | struct mutex dma_lock; |
| 44 | struct snd_pcm_substream *substream; |
| 45 | unsigned int buf_base, buf_limit, buf_rp; |
oder_chiou@realtek.com | 173f461 | 2017-07-13 19:42:20 +0800 | [diff] [blame^] | 46 | size_t buf_size, get_size, dma_offset; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static const struct snd_pcm_hardware rt5514_spi_pcm_hardware = { |
| 50 | .info = SNDRV_PCM_INFO_MMAP | |
| 51 | SNDRV_PCM_INFO_MMAP_VALID | |
| 52 | SNDRV_PCM_INFO_INTERLEAVED, |
| 53 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 54 | .period_bytes_min = PAGE_SIZE, |
| 55 | .period_bytes_max = 0x20000 / 8, |
| 56 | .periods_min = 8, |
| 57 | .periods_max = 8, |
| 58 | .channels_min = 1, |
| 59 | .channels_max = 1, |
| 60 | .buffer_bytes_max = 0x20000, |
| 61 | }; |
| 62 | |
| 63 | static struct snd_soc_dai_driver rt5514_spi_dai = { |
| 64 | .name = "rt5514-dsp-cpu-dai", |
| 65 | .id = 0, |
| 66 | .capture = { |
| 67 | .stream_name = "DSP Capture", |
| 68 | .channels_min = 1, |
| 69 | .channels_max = 1, |
| 70 | .rates = SNDRV_PCM_RATE_16000, |
| 71 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 72 | }, |
| 73 | }; |
| 74 | |
| 75 | static void rt5514_spi_copy_work(struct work_struct *work) |
| 76 | { |
| 77 | struct rt5514_dsp *rt5514_dsp = |
| 78 | container_of(work, struct rt5514_dsp, copy_work.work); |
Oder Chiou | b63d4d1 | 2016-06-17 11:02:23 +0800 | [diff] [blame] | 79 | struct snd_pcm_runtime *runtime; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 80 | size_t period_bytes, truncated_bytes = 0; |
oder_chiou@realtek.com | 173f461 | 2017-07-13 19:42:20 +0800 | [diff] [blame^] | 81 | unsigned int cur_wp, remain_data; |
| 82 | u8 buf[8]; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 83 | |
| 84 | mutex_lock(&rt5514_dsp->dma_lock); |
| 85 | if (!rt5514_dsp->substream) { |
| 86 | dev_err(rt5514_dsp->dev, "No pcm substream\n"); |
| 87 | goto done; |
| 88 | } |
| 89 | |
Oder Chiou | b63d4d1 | 2016-06-17 11:02:23 +0800 | [diff] [blame] | 90 | runtime = rt5514_dsp->substream->runtime; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 91 | period_bytes = snd_pcm_lib_period_bytes(rt5514_dsp->substream); |
| 92 | |
oder_chiou@realtek.com | 173f461 | 2017-07-13 19:42:20 +0800 | [diff] [blame^] | 93 | if (rt5514_dsp->get_size >= rt5514_dsp->buf_size) { |
| 94 | rt5514_spi_burst_read(RT5514_BUFFER_VOICE_WP, (u8 *)&buf, |
| 95 | sizeof(buf)); |
| 96 | cur_wp = buf[0] | buf[1] << 8 | buf[2] << 16 | |
| 97 | buf[3] << 24; |
| 98 | |
| 99 | if (cur_wp >= rt5514_dsp->buf_rp) |
| 100 | remain_data = (cur_wp - rt5514_dsp->buf_rp); |
| 101 | else |
| 102 | remain_data = |
| 103 | (rt5514_dsp->buf_limit - rt5514_dsp->buf_rp) + |
| 104 | (cur_wp - rt5514_dsp->buf_base); |
| 105 | |
| 106 | if (remain_data < period_bytes) { |
| 107 | schedule_delayed_work(&rt5514_dsp->copy_work, 5); |
| 108 | goto done; |
| 109 | } |
| 110 | } |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 111 | |
| 112 | if (rt5514_dsp->buf_rp + period_bytes <= rt5514_dsp->buf_limit) { |
| 113 | rt5514_spi_burst_read(rt5514_dsp->buf_rp, |
| 114 | runtime->dma_area + rt5514_dsp->dma_offset, |
| 115 | period_bytes); |
| 116 | |
| 117 | if (rt5514_dsp->buf_rp + period_bytes == rt5514_dsp->buf_limit) |
| 118 | rt5514_dsp->buf_rp = rt5514_dsp->buf_base; |
| 119 | else |
| 120 | rt5514_dsp->buf_rp += period_bytes; |
| 121 | } else { |
| 122 | truncated_bytes = rt5514_dsp->buf_limit - rt5514_dsp->buf_rp; |
| 123 | rt5514_spi_burst_read(rt5514_dsp->buf_rp, |
| 124 | runtime->dma_area + rt5514_dsp->dma_offset, |
| 125 | truncated_bytes); |
| 126 | |
| 127 | rt5514_spi_burst_read(rt5514_dsp->buf_base, |
| 128 | runtime->dma_area + rt5514_dsp->dma_offset + |
| 129 | truncated_bytes, period_bytes - truncated_bytes); |
| 130 | |
oder_chiou@realtek.com | 173f461 | 2017-07-13 19:42:20 +0800 | [diff] [blame^] | 131 | rt5514_dsp->buf_rp = rt5514_dsp->buf_base + period_bytes - |
| 132 | truncated_bytes; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 133 | } |
| 134 | |
oder_chiou@realtek.com | 173f461 | 2017-07-13 19:42:20 +0800 | [diff] [blame^] | 135 | rt5514_dsp->get_size += period_bytes; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 136 | rt5514_dsp->dma_offset += period_bytes; |
| 137 | if (rt5514_dsp->dma_offset >= runtime->dma_bytes) |
| 138 | rt5514_dsp->dma_offset = 0; |
| 139 | |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 140 | snd_pcm_period_elapsed(rt5514_dsp->substream); |
| 141 | |
oder_chiou@realtek.com | 173f461 | 2017-07-13 19:42:20 +0800 | [diff] [blame^] | 142 | schedule_delayed_work(&rt5514_dsp->copy_work, 5); |
| 143 | |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 144 | done: |
| 145 | mutex_unlock(&rt5514_dsp->dma_lock); |
| 146 | } |
| 147 | |
oder_chiou@realtek.com | 173f461 | 2017-07-13 19:42:20 +0800 | [diff] [blame^] | 148 | static irqreturn_t rt5514_spi_irq(int irq, void *data) |
| 149 | { |
| 150 | struct rt5514_dsp *rt5514_dsp = data; |
| 151 | u8 buf[8]; |
| 152 | |
| 153 | rt5514_dsp->get_size = 0; |
| 154 | rt5514_dsp->dma_offset = 0; |
| 155 | |
| 156 | /** |
| 157 | * The address area x1800XXXX is the register address, and it cannot |
| 158 | * support spi burst read perfectly. So we use the spi burst read |
| 159 | * individually to make sure the data correctly. |
| 160 | */ |
| 161 | rt5514_spi_burst_read(RT5514_BUFFER_VOICE_BASE, (u8 *)&buf, |
| 162 | sizeof(buf)); |
| 163 | rt5514_dsp->buf_base = buf[0] | buf[1] << 8 | buf[2] << 16 | |
| 164 | buf[3] << 24; |
| 165 | |
| 166 | rt5514_spi_burst_read(RT5514_BUFFER_VOICE_LIMIT, (u8 *)&buf, |
| 167 | sizeof(buf)); |
| 168 | rt5514_dsp->buf_limit = buf[0] | buf[1] << 8 | buf[2] << 16 | |
| 169 | buf[3] << 24; |
| 170 | |
| 171 | rt5514_spi_burst_read(RT5514_BUFFER_VOICE_WP, (u8 *)&buf, |
| 172 | sizeof(buf)); |
| 173 | rt5514_dsp->buf_rp = buf[0] | buf[1] << 8 | buf[2] << 16 | |
| 174 | buf[3] << 24; |
| 175 | |
| 176 | rt5514_dsp->buf_size = rt5514_dsp->buf_limit - rt5514_dsp->buf_base; |
| 177 | |
| 178 | schedule_delayed_work(&rt5514_dsp->copy_work, 0); |
| 179 | |
| 180 | return IRQ_HANDLED; |
| 181 | } |
| 182 | |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 183 | /* PCM for streaming audio from the DSP buffer */ |
| 184 | static int rt5514_spi_pcm_open(struct snd_pcm_substream *substream) |
| 185 | { |
| 186 | snd_soc_set_runtime_hwparams(substream, &rt5514_spi_pcm_hardware); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, |
| 192 | struct snd_pcm_hw_params *hw_params) |
| 193 | { |
| 194 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 195 | struct rt5514_dsp *rt5514_dsp = |
| 196 | snd_soc_platform_get_drvdata(rtd->platform); |
| 197 | int ret; |
| 198 | |
| 199 | mutex_lock(&rt5514_dsp->dma_lock); |
| 200 | ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, |
| 201 | params_buffer_bytes(hw_params)); |
| 202 | rt5514_dsp->substream = substream; |
| 203 | mutex_unlock(&rt5514_dsp->dma_lock); |
| 204 | |
| 205 | return ret; |
| 206 | } |
| 207 | |
| 208 | static int rt5514_spi_hw_free(struct snd_pcm_substream *substream) |
| 209 | { |
| 210 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 211 | struct rt5514_dsp *rt5514_dsp = |
| 212 | snd_soc_platform_get_drvdata(rtd->platform); |
| 213 | |
| 214 | mutex_lock(&rt5514_dsp->dma_lock); |
| 215 | rt5514_dsp->substream = NULL; |
| 216 | mutex_unlock(&rt5514_dsp->dma_lock); |
| 217 | |
| 218 | cancel_delayed_work_sync(&rt5514_dsp->copy_work); |
| 219 | |
| 220 | return snd_pcm_lib_free_vmalloc_buffer(substream); |
| 221 | } |
| 222 | |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 223 | static snd_pcm_uframes_t rt5514_spi_pcm_pointer( |
| 224 | struct snd_pcm_substream *substream) |
| 225 | { |
| 226 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 227 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 228 | struct rt5514_dsp *rt5514_dsp = |
| 229 | snd_soc_platform_get_drvdata(rtd->platform); |
| 230 | |
| 231 | return bytes_to_frames(runtime, rt5514_dsp->dma_offset); |
| 232 | } |
| 233 | |
Julia Lawall | 115c725 | 2016-09-08 02:35:23 +0200 | [diff] [blame] | 234 | static const struct snd_pcm_ops rt5514_spi_pcm_ops = { |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 235 | .open = rt5514_spi_pcm_open, |
| 236 | .hw_params = rt5514_spi_hw_params, |
| 237 | .hw_free = rt5514_spi_hw_free, |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 238 | .pointer = rt5514_spi_pcm_pointer, |
| 239 | .mmap = snd_pcm_lib_mmap_vmalloc, |
| 240 | .page = snd_pcm_lib_get_vmalloc_page, |
| 241 | }; |
| 242 | |
| 243 | static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) |
| 244 | { |
| 245 | struct rt5514_dsp *rt5514_dsp; |
oder_chiou@realtek.com | 173f461 | 2017-07-13 19:42:20 +0800 | [diff] [blame^] | 246 | int ret; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 247 | |
| 248 | rt5514_dsp = devm_kzalloc(platform->dev, sizeof(*rt5514_dsp), |
| 249 | GFP_KERNEL); |
| 250 | |
| 251 | rt5514_dsp->dev = &rt5514_spi->dev; |
| 252 | mutex_init(&rt5514_dsp->dma_lock); |
| 253 | INIT_DELAYED_WORK(&rt5514_dsp->copy_work, rt5514_spi_copy_work); |
| 254 | snd_soc_platform_set_drvdata(platform, rt5514_dsp); |
| 255 | |
oder_chiou@realtek.com | 173f461 | 2017-07-13 19:42:20 +0800 | [diff] [blame^] | 256 | if (rt5514_spi->irq) { |
| 257 | ret = devm_request_threaded_irq(&rt5514_spi->dev, |
| 258 | rt5514_spi->irq, NULL, rt5514_spi_irq, |
| 259 | IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5514-spi", |
| 260 | rt5514_dsp); |
| 261 | if (ret) |
| 262 | dev_err(&rt5514_spi->dev, |
| 263 | "%s Failed to reguest IRQ: %d\n", __func__, |
| 264 | ret); |
| 265 | } |
| 266 | |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | static struct snd_soc_platform_driver rt5514_spi_platform = { |
| 271 | .probe = rt5514_spi_pcm_probe, |
| 272 | .ops = &rt5514_spi_pcm_ops, |
| 273 | }; |
| 274 | |
| 275 | static const struct snd_soc_component_driver rt5514_spi_dai_component = { |
| 276 | .name = "rt5514-spi-dai", |
| 277 | }; |
| 278 | |
| 279 | /** |
| 280 | * rt5514_spi_burst_read - Read data from SPI by rt5514 address. |
| 281 | * @addr: Start address. |
| 282 | * @rxbuf: Data Buffer for reading. |
| 283 | * @len: Data length, it must be a multiple of 8. |
| 284 | * |
| 285 | * |
| 286 | * Returns true for success. |
| 287 | */ |
| 288 | int rt5514_spi_burst_read(unsigned int addr, u8 *rxbuf, size_t len) |
| 289 | { |
| 290 | u8 spi_cmd = RT5514_SPI_CMD_BURST_READ; |
| 291 | int status; |
| 292 | u8 write_buf[8]; |
| 293 | unsigned int i, end, offset = 0; |
| 294 | |
| 295 | struct spi_message message; |
| 296 | struct spi_transfer x[3]; |
| 297 | |
| 298 | while (offset < len) { |
| 299 | if (offset + RT5514_SPI_BUF_LEN <= len) |
| 300 | end = RT5514_SPI_BUF_LEN; |
| 301 | else |
| 302 | end = len % RT5514_SPI_BUF_LEN; |
| 303 | |
| 304 | write_buf[0] = spi_cmd; |
| 305 | write_buf[1] = ((addr + offset) & 0xff000000) >> 24; |
| 306 | write_buf[2] = ((addr + offset) & 0x00ff0000) >> 16; |
| 307 | write_buf[3] = ((addr + offset) & 0x0000ff00) >> 8; |
| 308 | write_buf[4] = ((addr + offset) & 0x000000ff) >> 0; |
| 309 | |
| 310 | spi_message_init(&message); |
| 311 | memset(x, 0, sizeof(x)); |
| 312 | |
| 313 | x[0].len = 5; |
| 314 | x[0].tx_buf = write_buf; |
| 315 | spi_message_add_tail(&x[0], &message); |
| 316 | |
| 317 | x[1].len = 4; |
| 318 | x[1].tx_buf = write_buf; |
| 319 | spi_message_add_tail(&x[1], &message); |
| 320 | |
| 321 | x[2].len = end; |
| 322 | x[2].rx_buf = rxbuf + offset; |
| 323 | spi_message_add_tail(&x[2], &message); |
| 324 | |
| 325 | status = spi_sync(rt5514_spi, &message); |
| 326 | |
| 327 | if (status) |
| 328 | return false; |
| 329 | |
| 330 | offset += RT5514_SPI_BUF_LEN; |
| 331 | } |
| 332 | |
| 333 | for (i = 0; i < len; i += 8) { |
| 334 | write_buf[0] = rxbuf[i + 0]; |
| 335 | write_buf[1] = rxbuf[i + 1]; |
| 336 | write_buf[2] = rxbuf[i + 2]; |
| 337 | write_buf[3] = rxbuf[i + 3]; |
| 338 | write_buf[4] = rxbuf[i + 4]; |
| 339 | write_buf[5] = rxbuf[i + 5]; |
| 340 | write_buf[6] = rxbuf[i + 6]; |
| 341 | write_buf[7] = rxbuf[i + 7]; |
| 342 | |
| 343 | rxbuf[i + 0] = write_buf[7]; |
| 344 | rxbuf[i + 1] = write_buf[6]; |
| 345 | rxbuf[i + 2] = write_buf[5]; |
| 346 | rxbuf[i + 3] = write_buf[4]; |
| 347 | rxbuf[i + 4] = write_buf[3]; |
| 348 | rxbuf[i + 5] = write_buf[2]; |
| 349 | rxbuf[i + 6] = write_buf[1]; |
| 350 | rxbuf[i + 7] = write_buf[0]; |
| 351 | } |
| 352 | |
| 353 | return true; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * rt5514_spi_burst_write - Write data to SPI by rt5514 address. |
| 358 | * @addr: Start address. |
| 359 | * @txbuf: Data Buffer for writng. |
| 360 | * @len: Data length, it must be a multiple of 8. |
| 361 | * |
| 362 | * |
| 363 | * Returns true for success. |
| 364 | */ |
| 365 | int rt5514_spi_burst_write(u32 addr, const u8 *txbuf, size_t len) |
| 366 | { |
| 367 | u8 spi_cmd = RT5514_SPI_CMD_BURST_WRITE; |
| 368 | u8 *write_buf; |
| 369 | unsigned int i, end, offset = 0; |
| 370 | |
| 371 | write_buf = kmalloc(RT5514_SPI_BUF_LEN + 6, GFP_KERNEL); |
| 372 | |
| 373 | if (write_buf == NULL) |
| 374 | return -ENOMEM; |
| 375 | |
| 376 | while (offset < len) { |
| 377 | if (offset + RT5514_SPI_BUF_LEN <= len) |
| 378 | end = RT5514_SPI_BUF_LEN; |
| 379 | else |
| 380 | end = len % RT5514_SPI_BUF_LEN; |
| 381 | |
| 382 | write_buf[0] = spi_cmd; |
| 383 | write_buf[1] = ((addr + offset) & 0xff000000) >> 24; |
| 384 | write_buf[2] = ((addr + offset) & 0x00ff0000) >> 16; |
| 385 | write_buf[3] = ((addr + offset) & 0x0000ff00) >> 8; |
| 386 | write_buf[4] = ((addr + offset) & 0x000000ff) >> 0; |
| 387 | |
| 388 | for (i = 0; i < end; i += 8) { |
| 389 | write_buf[i + 12] = txbuf[offset + i + 0]; |
| 390 | write_buf[i + 11] = txbuf[offset + i + 1]; |
| 391 | write_buf[i + 10] = txbuf[offset + i + 2]; |
| 392 | write_buf[i + 9] = txbuf[offset + i + 3]; |
| 393 | write_buf[i + 8] = txbuf[offset + i + 4]; |
| 394 | write_buf[i + 7] = txbuf[offset + i + 5]; |
| 395 | write_buf[i + 6] = txbuf[offset + i + 6]; |
| 396 | write_buf[i + 5] = txbuf[offset + i + 7]; |
| 397 | } |
| 398 | |
| 399 | write_buf[end + 5] = spi_cmd; |
| 400 | |
| 401 | spi_write(rt5514_spi, write_buf, end + 6); |
| 402 | |
| 403 | offset += RT5514_SPI_BUF_LEN; |
| 404 | } |
| 405 | |
| 406 | kfree(write_buf); |
| 407 | |
| 408 | return 0; |
| 409 | } |
| 410 | EXPORT_SYMBOL_GPL(rt5514_spi_burst_write); |
| 411 | |
| 412 | static int rt5514_spi_probe(struct spi_device *spi) |
| 413 | { |
| 414 | int ret; |
| 415 | |
| 416 | rt5514_spi = spi; |
| 417 | |
Axel Lin | e9802c5 | 2016-07-14 16:57:05 +0800 | [diff] [blame] | 418 | ret = devm_snd_soc_register_platform(&spi->dev, &rt5514_spi_platform); |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 419 | if (ret < 0) { |
| 420 | dev_err(&spi->dev, "Failed to register platform.\n"); |
Axel Lin | e9802c5 | 2016-07-14 16:57:05 +0800 | [diff] [blame] | 421 | return ret; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 422 | } |
| 423 | |
Axel Lin | e9802c5 | 2016-07-14 16:57:05 +0800 | [diff] [blame] | 424 | ret = devm_snd_soc_register_component(&spi->dev, |
| 425 | &rt5514_spi_dai_component, |
| 426 | &rt5514_spi_dai, 1); |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 427 | if (ret < 0) { |
| 428 | dev_err(&spi->dev, "Failed to register component.\n"); |
Axel Lin | e9802c5 | 2016-07-14 16:57:05 +0800 | [diff] [blame] | 429 | return ret; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | return 0; |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | static const struct of_device_id rt5514_of_match[] = { |
| 436 | { .compatible = "realtek,rt5514", }, |
| 437 | {}, |
| 438 | }; |
| 439 | MODULE_DEVICE_TABLE(of, rt5514_of_match); |
| 440 | |
| 441 | static struct spi_driver rt5514_spi_driver = { |
| 442 | .driver = { |
| 443 | .name = "rt5514", |
| 444 | .of_match_table = of_match_ptr(rt5514_of_match), |
| 445 | }, |
| 446 | .probe = rt5514_spi_probe, |
Oder Chiou | 6eebf35 | 2016-06-06 18:33:31 +0800 | [diff] [blame] | 447 | }; |
| 448 | module_spi_driver(rt5514_spi_driver); |
| 449 | |
| 450 | MODULE_DESCRIPTION("RT5514 SPI driver"); |
| 451 | MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>"); |
| 452 | MODULE_LICENSE("GPL v2"); |