Kirill Marinushkin | 6ee47d4 | 2018-08-21 18:52:46 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * PCM3060 SPI driver |
| 4 | * |
| 5 | * Copyright (C) 2018 Kirill Marinushkin <kmarinushkin@birdec.tech> |
| 6 | */ |
| 7 | |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/spi/spi.h> |
| 10 | #include <sound/soc.h> |
| 11 | |
| 12 | #include "pcm3060.h" |
| 13 | |
| 14 | static int pcm3060_spi_probe(struct spi_device *spi) |
| 15 | { |
| 16 | struct pcm3060_priv *priv; |
| 17 | |
| 18 | priv = devm_kzalloc(&spi->dev, sizeof(*priv), GFP_KERNEL); |
| 19 | if (!priv) |
| 20 | return -ENOMEM; |
| 21 | |
| 22 | spi_set_drvdata(spi, priv); |
| 23 | |
| 24 | priv->regmap = devm_regmap_init_spi(spi, &pcm3060_regmap); |
| 25 | if (IS_ERR(priv->regmap)) |
| 26 | return PTR_ERR(priv->regmap); |
| 27 | |
| 28 | return pcm3060_probe(&spi->dev); |
| 29 | } |
| 30 | |
| 31 | static const struct spi_device_id pcm3060_spi_id[] = { |
| 32 | { .name = "pcm3060" }, |
| 33 | { }, |
| 34 | }; |
| 35 | MODULE_DEVICE_TABLE(spi, pcm3060_spi_id); |
| 36 | |
| 37 | #ifdef CONFIG_OF |
| 38 | static const struct of_device_id pcm3060_of_match[] = { |
| 39 | { .compatible = "ti,pcm3060" }, |
| 40 | { }, |
| 41 | }; |
| 42 | MODULE_DEVICE_TABLE(of, pcm3060_of_match); |
| 43 | #endif /* CONFIG_OF */ |
| 44 | |
| 45 | static struct spi_driver pcm3060_spi_driver = { |
| 46 | .driver = { |
| 47 | .name = "pcm3060", |
| 48 | #ifdef CONFIG_OF |
| 49 | .of_match_table = pcm3060_of_match, |
| 50 | #endif /* CONFIG_OF */ |
| 51 | }, |
| 52 | .id_table = pcm3060_spi_id, |
| 53 | .probe = pcm3060_spi_probe, |
| 54 | }; |
| 55 | |
| 56 | module_spi_driver(pcm3060_spi_driver); |
| 57 | |
| 58 | MODULE_DESCRIPTION("PCM3060 SPI driver"); |
| 59 | MODULE_AUTHOR("Kirill Marinushkin <kmarinushkin@birdec.tech>"); |
| 60 | MODULE_LICENSE("GPL v2"); |