diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2015-10-07 06:18:49 -0400 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2015-11-06 08:14:19 -0500 |
commit | 912b8439041317a0562609ad892eeab9ba2f0cb2 (patch) | |
tree | 3ca0fed84b0cf057a38bc22bf786439886346c4f /drivers/pwm/pwm-pca9685.c | |
parent | 7e3b7dc76c41f9042a7079eb07d071f744bbd87a (diff) |
pwm-pca9685: enable ACPI device found on Galileo Gen2
There is a chip connected to i2c bus on Intel Galileo Gen2 board. Enable it via
ACPI ID INT3492.
Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-pca9685.c')
-rw-r--r-- | drivers/pwm/pwm-pca9685.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c index 70448a6079b0..117fccf7934a 100644 --- a/drivers/pwm/pwm-pca9685.c +++ b/drivers/pwm/pwm-pca9685.c | |||
@@ -19,9 +19,11 @@ | |||
19 | * this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * this program. If not, see <http://www.gnu.org/licenses/>. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/acpi.h> | ||
22 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
24 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/property.h> | ||
25 | #include <linux/pwm.h> | 27 | #include <linux/pwm.h> |
26 | #include <linux/regmap.h> | 28 | #include <linux/regmap.h> |
27 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
@@ -297,7 +299,6 @@ static const struct regmap_config pca9685_regmap_i2c_config = { | |||
297 | static int pca9685_pwm_probe(struct i2c_client *client, | 299 | static int pca9685_pwm_probe(struct i2c_client *client, |
298 | const struct i2c_device_id *id) | 300 | const struct i2c_device_id *id) |
299 | { | 301 | { |
300 | struct device_node *np = client->dev.of_node; | ||
301 | struct pca9685 *pca; | 302 | struct pca9685 *pca; |
302 | int ret; | 303 | int ret; |
303 | int mode2; | 304 | int mode2; |
@@ -320,12 +321,12 @@ static int pca9685_pwm_probe(struct i2c_client *client, | |||
320 | 321 | ||
321 | regmap_read(pca->regmap, PCA9685_MODE2, &mode2); | 322 | regmap_read(pca->regmap, PCA9685_MODE2, &mode2); |
322 | 323 | ||
323 | if (of_property_read_bool(np, "invert")) | 324 | if (device_property_read_bool(&client->dev, "invert")) |
324 | mode2 |= MODE2_INVRT; | 325 | mode2 |= MODE2_INVRT; |
325 | else | 326 | else |
326 | mode2 &= ~MODE2_INVRT; | 327 | mode2 &= ~MODE2_INVRT; |
327 | 328 | ||
328 | if (of_property_read_bool(np, "open-drain")) | 329 | if (device_property_read_bool(&client->dev, "open-drain")) |
329 | mode2 &= ~MODE2_OUTDRV; | 330 | mode2 &= ~MODE2_OUTDRV; |
330 | else | 331 | else |
331 | mode2 |= MODE2_OUTDRV; | 332 | mode2 |= MODE2_OUTDRV; |
@@ -363,16 +364,27 @@ static const struct i2c_device_id pca9685_id[] = { | |||
363 | }; | 364 | }; |
364 | MODULE_DEVICE_TABLE(i2c, pca9685_id); | 365 | MODULE_DEVICE_TABLE(i2c, pca9685_id); |
365 | 366 | ||
367 | #ifdef CONFIG_ACPI | ||
368 | static const struct acpi_device_id pca9685_acpi_ids[] = { | ||
369 | { "INT3492", 0 }, | ||
370 | { /* sentinel */ }, | ||
371 | }; | ||
372 | MODULE_DEVICE_TABLE(acpi, pca9685_acpi_ids); | ||
373 | #endif | ||
374 | |||
375 | #ifdef CONFIG_OF | ||
366 | static const struct of_device_id pca9685_dt_ids[] = { | 376 | static const struct of_device_id pca9685_dt_ids[] = { |
367 | { .compatible = "nxp,pca9685-pwm", }, | 377 | { .compatible = "nxp,pca9685-pwm", }, |
368 | { /* sentinel */ } | 378 | { /* sentinel */ } |
369 | }; | 379 | }; |
370 | MODULE_DEVICE_TABLE(of, pca9685_dt_ids); | 380 | MODULE_DEVICE_TABLE(of, pca9685_dt_ids); |
381 | #endif | ||
371 | 382 | ||
372 | static struct i2c_driver pca9685_i2c_driver = { | 383 | static struct i2c_driver pca9685_i2c_driver = { |
373 | .driver = { | 384 | .driver = { |
374 | .name = "pca9685-pwm", | 385 | .name = "pca9685-pwm", |
375 | .of_match_table = pca9685_dt_ids, | 386 | .acpi_match_table = ACPI_PTR(pca9685_acpi_ids), |
387 | .of_match_table = of_match_ptr(pca9685_dt_ids), | ||
376 | }, | 388 | }, |
377 | .probe = pca9685_pwm_probe, | 389 | .probe = pca9685_pwm_probe, |
378 | .remove = pca9685_pwm_remove, | 390 | .remove = pca9685_pwm_remove, |