| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /** |
|---|
| 2 | 3 | * Sensortek STK3310/STK3311 Ambient Light and Proximity Sensor |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2015, Intel Corporation. |
|---|
| 5 | | - * |
|---|
| 6 | | - * This file is subject to the terms and conditions of version 2 of |
|---|
| 7 | | - * the GNU General Public License. See the file COPYING in the main |
|---|
| 8 | | - * directory of this archive for more details. |
|---|
| 9 | 6 | * |
|---|
| 10 | 7 | * IIO driver for STK3310/STK3311. 7-bit I2C address: 0x48. |
|---|
| 11 | 8 | */ |
|---|
| .. | .. |
|---|
| 40 | 37 | |
|---|
| 41 | 38 | #define STK3310_CHIP_ID_VAL 0x13 |
|---|
| 42 | 39 | #define STK3311_CHIP_ID_VAL 0x1D |
|---|
| 40 | +#define STK3311X_CHIP_ID_VAL 0x12 |
|---|
| 41 | +#define STK3335_CHIP_ID_VAL 0x51 |
|---|
| 43 | 42 | #define STK3310_PSINT_EN 0x01 |
|---|
| 44 | 43 | #define STK3310_PS_MAX_VAL 0xFFFF |
|---|
| 45 | 44 | |
|---|
| .. | .. |
|---|
| 454 | 453 | return ret; |
|---|
| 455 | 454 | |
|---|
| 456 | 455 | if (chipid != STK3310_CHIP_ID_VAL && |
|---|
| 457 | | - chipid != STK3311_CHIP_ID_VAL) { |
|---|
| 456 | + chipid != STK3311_CHIP_ID_VAL && |
|---|
| 457 | + chipid != STK3311X_CHIP_ID_VAL && |
|---|
| 458 | + chipid != STK3335_CHIP_ID_VAL) { |
|---|
| 458 | 459 | dev_err(&client->dev, "invalid chip id: 0x%x\n", chipid); |
|---|
| 459 | 460 | return -ENODEV; |
|---|
| 460 | 461 | } |
|---|
| .. | .. |
|---|
| 488 | 489 | } |
|---|
| 489 | 490 | } |
|---|
| 490 | 491 | |
|---|
| 491 | | -static struct regmap_config stk3310_regmap_config = { |
|---|
| 492 | +static const struct regmap_config stk3310_regmap_config = { |
|---|
| 492 | 493 | .name = STK3310_REGMAP_NAME, |
|---|
| 493 | 494 | .reg_bits = 8, |
|---|
| 494 | 495 | .val_bits = 8, |
|---|
| .. | .. |
|---|
| 586 | 587 | if (ret < 0) |
|---|
| 587 | 588 | return ret; |
|---|
| 588 | 589 | |
|---|
| 589 | | - indio_dev->dev.parent = &client->dev; |
|---|
| 590 | 590 | indio_dev->info = &stk3310_info; |
|---|
| 591 | 591 | indio_dev->name = STK3310_DRIVER_NAME; |
|---|
| 592 | 592 | indio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| .. | .. |
|---|
| 666 | 666 | static const struct i2c_device_id stk3310_i2c_id[] = { |
|---|
| 667 | 667 | {"STK3310", 0}, |
|---|
| 668 | 668 | {"STK3311", 0}, |
|---|
| 669 | + {"STK3335", 0}, |
|---|
| 669 | 670 | {} |
|---|
| 670 | 671 | }; |
|---|
| 671 | 672 | MODULE_DEVICE_TABLE(i2c, stk3310_i2c_id); |
|---|
| .. | .. |
|---|
| 673 | 674 | static const struct acpi_device_id stk3310_acpi_id[] = { |
|---|
| 674 | 675 | {"STK3310", 0}, |
|---|
| 675 | 676 | {"STK3311", 0}, |
|---|
| 677 | + {"STK3335", 0}, |
|---|
| 676 | 678 | {} |
|---|
| 677 | 679 | }; |
|---|
| 678 | 680 | |
|---|
| 679 | 681 | MODULE_DEVICE_TABLE(acpi, stk3310_acpi_id); |
|---|
| 680 | 682 | |
|---|
| 683 | +static const struct of_device_id stk3310_of_match[] = { |
|---|
| 684 | + { .compatible = "sensortek,stk3310", }, |
|---|
| 685 | + { .compatible = "sensortek,stk3311", }, |
|---|
| 686 | + { .compatible = "sensortek,stk3335", }, |
|---|
| 687 | + {} |
|---|
| 688 | +}; |
|---|
| 689 | +MODULE_DEVICE_TABLE(of, stk3310_of_match); |
|---|
| 690 | + |
|---|
| 681 | 691 | static struct i2c_driver stk3310_driver = { |
|---|
| 682 | 692 | .driver = { |
|---|
| 683 | 693 | .name = "stk3310", |
|---|
| 694 | + .of_match_table = stk3310_of_match, |
|---|
| 684 | 695 | .pm = STK3310_PM_OPS, |
|---|
| 685 | 696 | .acpi_match_table = ACPI_PTR(stk3310_acpi_id), |
|---|
| 686 | 697 | }, |
|---|