cm32181.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) cm32181.c (68c1b3dd5c48b2323067f8c1f0649ae2f31ab20b)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2013 Capella Microsystems Inc.
4 * Author: Kevin Tsai <ktsai@capellamicro.com>
5 */
6
7#include <linux/acpi.h>
8#include <linux/delay.h>

--- 446 unchanged lines hidden (view full) ---

455
456 i2c_smbus_read_byte(client);
457
458 client = i2c_acpi_new_device(dev, 1, &board_info);
459 if (IS_ERR(client))
460 return PTR_ERR(client);
461 }
462
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2013 Capella Microsystems Inc.
4 * Author: Kevin Tsai <ktsai@capellamicro.com>
5 */
6
7#include <linux/acpi.h>
8#include <linux/delay.h>

--- 446 unchanged lines hidden (view full) ---

455
456 i2c_smbus_read_byte(client);
457
458 client = i2c_acpi_new_device(dev, 1, &board_info);
459 if (IS_ERR(client))
460 return PTR_ERR(client);
461 }
462
463 i2c_set_clientdata(client, indio_dev);
464
463 cm32181 = iio_priv(indio_dev);
464 cm32181->client = client;
465 cm32181->dev = dev;
466
467 mutex_init(&cm32181->lock);
468 indio_dev->channels = cm32181_channels;
469 indio_dev->num_channels = ARRAY_SIZE(cm32181_channels);
470 indio_dev->info = &cm32181_info;

--- 10 unchanged lines hidden (view full) ---

481 if (ret) {
482 dev_err(dev, "%s: regist device failed\n", __func__);
483 return ret;
484 }
485
486 return 0;
487}
488
465 cm32181 = iio_priv(indio_dev);
466 cm32181->client = client;
467 cm32181->dev = dev;
468
469 mutex_init(&cm32181->lock);
470 indio_dev->channels = cm32181_channels;
471 indio_dev->num_channels = ARRAY_SIZE(cm32181_channels);
472 indio_dev->info = &cm32181_info;

--- 10 unchanged lines hidden (view full) ---

483 if (ret) {
484 dev_err(dev, "%s: regist device failed\n", __func__);
485 return ret;
486 }
487
488 return 0;
489}
490
491static int cm32181_suspend(struct device *dev)
492{
493 struct i2c_client *client = to_i2c_client(dev);
494
495 return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
496 CM32181_CMD_ALS_DISABLE);
497}
498
499static int cm32181_resume(struct device *dev)
500{
501 struct i2c_client *client = to_i2c_client(dev);
502 struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev));
503
504 return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
505 cm32181->conf_regs[CM32181_REG_ADDR_CMD]);
506}
507
508DEFINE_SIMPLE_DEV_PM_OPS(cm32181_pm_ops, cm32181_suspend, cm32181_resume);
509
489static const struct of_device_id cm32181_of_match[] = {
490 { .compatible = "capella,cm3218" },
491 { .compatible = "capella,cm32181" },
492 { }
493};
494MODULE_DEVICE_TABLE(of, cm32181_of_match);
495
496#ifdef CONFIG_ACPI

--- 4 unchanged lines hidden (view full) ---

501MODULE_DEVICE_TABLE(acpi, cm32181_acpi_match);
502#endif
503
504static struct i2c_driver cm32181_driver = {
505 .driver = {
506 .name = "cm32181",
507 .acpi_match_table = ACPI_PTR(cm32181_acpi_match),
508 .of_match_table = cm32181_of_match,
510static const struct of_device_id cm32181_of_match[] = {
511 { .compatible = "capella,cm3218" },
512 { .compatible = "capella,cm32181" },
513 { }
514};
515MODULE_DEVICE_TABLE(of, cm32181_of_match);
516
517#ifdef CONFIG_ACPI

--- 4 unchanged lines hidden (view full) ---

522MODULE_DEVICE_TABLE(acpi, cm32181_acpi_match);
523#endif
524
525static struct i2c_driver cm32181_driver = {
526 .driver = {
527 .name = "cm32181",
528 .acpi_match_table = ACPI_PTR(cm32181_acpi_match),
529 .of_match_table = cm32181_of_match,
530 .pm = pm_sleep_ptr(&cm32181_pm_ops),
509 },
510 .probe_new = cm32181_probe,
511};
512
513module_i2c_driver(cm32181_driver);
514
515MODULE_AUTHOR("Kevin Tsai <ktsai@capellamicro.com>");
516MODULE_DESCRIPTION("CM32181 ambient light sensor driver");
517MODULE_LICENSE("GPL");
531 },
532 .probe_new = cm32181_probe,
533};
534
535module_i2c_driver(cm32181_driver);
536
537MODULE_AUTHOR("Kevin Tsai <ktsai@capellamicro.com>");
538MODULE_DESCRIPTION("CM32181 ambient light sensor driver");
539MODULE_LICENSE("GPL");