20 #include <linux/i2c.h>
21 #include <linux/slab.h>
25 #include <linux/module.h>
27 #define BH1780_REG_CONTROL 0x80
28 #define BH1780_REG_PARTID 0x8A
29 #define BH1780_REG_MANFID 0x8B
30 #define BH1780_REG_DLOW 0x8C
31 #define BH1780_REG_DHIGH 0x8D
33 #define BH1780_REVMASK (0xf)
34 #define BH1780_POWMASK (0x3)
35 #define BH1780_POFF (0x0)
36 #define BH1780_PON (0x3)
39 #define BH1780_PON_DELAY 2
53 "i2c_smbus_write_byte_data failed error %d Register (%s)\n",
58 static int bh1780_read(
struct bh1780_data *ddata,
u8 reg,
char *msg)
63 "i2c_smbus_read_byte_data failed error %d Register (%s)\n",
72 struct bh1780_data *ddata = platform_get_drvdata(pdev);
83 return sprintf(buf,
"%d\n", (msb << 8) | lsb);
91 struct bh1780_data *ddata = platform_get_drvdata(pdev);
103 const char *buf,
size_t count)
106 struct bh1780_data *ddata = platform_get_drvdata(pdev);
135 bh1780_show_power_state, bh1780_store_power_state);
137 static struct attribute *bh1780_attributes[] = {
138 &dev_attr_power_state.attr,
144 .attrs = bh1780_attributes,
166 i2c_set_clientdata(client, ddata);
172 dev_info(&client->
dev,
"Ambient Light Sensor, Rev : %d\n",
192 ddata = i2c_get_clientdata(client);
200 static int bh1780_suspend(
struct device *dev)
206 ddata = i2c_get_clientdata(client);
222 static int bh1780_resume(
struct device *dev)
228 ddata = i2c_get_clientdata(client);
239 #define BH1780_PMOPS (&bh1780_pm)
241 #define BH1780_PMOPS NULL
250 .probe = bh1780_probe,
252 .id_table = bh1780_id,