Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <linux/regmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include "bmp280.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) static int bmp280_i2c_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 			    const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 	struct regmap *regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 	const struct regmap_config *regmap_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	switch (id->driver_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	case BMP180_CHIP_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 		regmap_config = &bmp180_regmap_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	case BMP280_CHIP_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	case BME280_CHIP_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		regmap_config = &bmp280_regmap_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	regmap = devm_regmap_init_i2c(client, regmap_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	if (IS_ERR(regmap)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		dev_err(&client->dev, "failed to allocate register map\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		return PTR_ERR(regmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	return bmp280_common_probe(&client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 				   regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 				   id->driver_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 				   id->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 				   client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static const struct of_device_id bmp280_of_i2c_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	{ .compatible = "bosch,bme280", .data = (void *)BME280_CHIP_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	{ .compatible = "bosch,bmp280", .data = (void *)BMP280_CHIP_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	{ .compatible = "bosch,bmp180", .data = (void *)BMP180_CHIP_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	{ .compatible = "bosch,bmp085", .data = (void *)BMP180_CHIP_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) MODULE_DEVICE_TABLE(of, bmp280_of_i2c_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static const struct i2c_device_id bmp280_i2c_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	{"bmp280", BMP280_CHIP_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	{"bmp180", BMP180_CHIP_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	{"bmp085", BMP180_CHIP_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	{"bme280", BME280_CHIP_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) MODULE_DEVICE_TABLE(i2c, bmp280_i2c_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static struct i2c_driver bmp280_i2c_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		.name	= "bmp280",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		.of_match_table = bmp280_of_i2c_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		.pm = &bmp280_dev_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	.probe		= bmp280_i2c_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	.id_table	= bmp280_i2c_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) module_i2c_driver(bmp280_i2c_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) MODULE_AUTHOR("Vlad Dogaru <vlad.dogaru@intel.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP180/BMP280 pressure and temperature sensor");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) MODULE_LICENSE("GPL v2");