Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Driver for the PCM512x CODECs |
| 3 | * |
Mark Brown | da924c3 | 2017-09-07 14:22:48 +0100 | [diff] [blame] | 4 | * Author: Mark Brown <broonie@kernel.org> |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 5 | * Copyright 2014 Linaro Ltd |
| 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 | * version 2 as published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/i2c.h> |
Pierre-Louis Bossart | b84f48d | 2018-05-17 17:53:26 -0500 | [diff] [blame] | 20 | #include <linux/acpi.h> |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 21 | |
| 22 | #include "pcm512x.h" |
| 23 | |
| 24 | static int pcm512x_i2c_probe(struct i2c_client *i2c, |
| 25 | const struct i2c_device_id *id) |
| 26 | { |
| 27 | struct regmap *regmap; |
Peter Rosin | 681a195 | 2014-12-08 16:33:11 +0100 | [diff] [blame] | 28 | struct regmap_config config = pcm512x_regmap; |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 29 | |
Peter Rosin | 681a195 | 2014-12-08 16:33:11 +0100 | [diff] [blame] | 30 | /* msb needs to be set to enable auto-increment of addresses */ |
| 31 | config.read_flag_mask = 0x80; |
| 32 | config.write_flag_mask = 0x80; |
| 33 | |
| 34 | regmap = devm_regmap_init_i2c(i2c, &config); |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 35 | if (IS_ERR(regmap)) |
| 36 | return PTR_ERR(regmap); |
| 37 | |
| 38 | return pcm512x_probe(&i2c->dev, regmap); |
| 39 | } |
| 40 | |
| 41 | static int pcm512x_i2c_remove(struct i2c_client *i2c) |
| 42 | { |
| 43 | pcm512x_remove(&i2c->dev); |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | static const struct i2c_device_id pcm512x_i2c_id[] = { |
| 48 | { "pcm5121", }, |
| 49 | { "pcm5122", }, |
Peter Rosin | ba5295e | 2014-12-09 09:28:09 +0100 | [diff] [blame] | 50 | { "pcm5141", }, |
| 51 | { "pcm5142", }, |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 52 | { } |
| 53 | }; |
| 54 | MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id); |
| 55 | |
Pierre-Louis Bossart | b84f48d | 2018-05-17 17:53:26 -0500 | [diff] [blame] | 56 | #if defined(CONFIG_OF) |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 57 | static const struct of_device_id pcm512x_of_match[] = { |
| 58 | { .compatible = "ti,pcm5121", }, |
| 59 | { .compatible = "ti,pcm5122", }, |
Peter Rosin | ba5295e | 2014-12-09 09:28:09 +0100 | [diff] [blame] | 60 | { .compatible = "ti,pcm5141", }, |
| 61 | { .compatible = "ti,pcm5142", }, |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 62 | { } |
| 63 | }; |
| 64 | MODULE_DEVICE_TABLE(of, pcm512x_of_match); |
Pierre-Louis Bossart | b84f48d | 2018-05-17 17:53:26 -0500 | [diff] [blame] | 65 | #endif |
| 66 | |
| 67 | #ifdef CONFIG_ACPI |
| 68 | static const struct acpi_device_id pcm512x_acpi_match[] = { |
| 69 | { "104C5121", 0 }, |
| 70 | { "104C5122", 0 }, |
| 71 | { "104C5141", 0 }, |
| 72 | { "104C5142", 0 }, |
| 73 | { }, |
| 74 | }; |
| 75 | MODULE_DEVICE_TABLE(acpi, pcm512x_acpi_match); |
| 76 | #endif |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 77 | |
| 78 | static struct i2c_driver pcm512x_i2c_driver = { |
| 79 | .probe = pcm512x_i2c_probe, |
| 80 | .remove = pcm512x_i2c_remove, |
| 81 | .id_table = pcm512x_i2c_id, |
| 82 | .driver = { |
| 83 | .name = "pcm512x", |
Pierre-Louis Bossart | b84f48d | 2018-05-17 17:53:26 -0500 | [diff] [blame] | 84 | .of_match_table = of_match_ptr(pcm512x_of_match), |
| 85 | .acpi_match_table = ACPI_PTR(pcm512x_acpi_match), |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 86 | .pm = &pcm512x_pm_ops, |
| 87 | }, |
| 88 | }; |
| 89 | |
| 90 | module_i2c_driver(pcm512x_i2c_driver); |
| 91 | |
| 92 | MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C"); |
Mark Brown | da924c3 | 2017-09-07 14:22:48 +0100 | [diff] [blame] | 93 | MODULE_AUTHOR("Mark Brown <broonie@kernel.org>"); |
Mark Brown | 2206622 | 2014-03-07 11:44:08 +0800 | [diff] [blame] | 94 | MODULE_LICENSE("GPL v2"); |