|
@@ -9,6 +9,7 @@
|
|
|
*/
|
|
|
#include <linux/kernel.h>
|
|
|
#include <linux/module.h>
|
|
|
+#include <linux/of_device.h>
|
|
|
#include <linux/types.h>
|
|
|
#include <linux/errno.h>
|
|
|
#include <linux/swab.h>
|
|
@@ -61,7 +62,7 @@ struct ltc294x_info {
|
|
|
struct power_supply *supply; /* Supply pointer */
|
|
|
struct power_supply_desc supply_desc; /* Supply description */
|
|
|
struct delayed_work work; /* Work scheduler */
|
|
|
- int num_regs; /* Number of registers (chip type) */
|
|
|
+ unsigned long num_regs; /* Number of registers (chip type) */
|
|
|
int charge; /* Last charge register content */
|
|
|
int r_sense; /* mOhm */
|
|
|
int Qlsb; /* nAh */
|
|
@@ -387,7 +388,7 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
|
|
|
|
|
|
np = of_node_get(client->dev.of_node);
|
|
|
|
|
|
- info->num_regs = id->driver_data;
|
|
|
+ info->num_regs = (unsigned long)of_device_get_match_data(&client->dev);
|
|
|
info->supply_desc.name = np->name;
|
|
|
|
|
|
/* r_sense can be negative, when sense+ is connected to the battery
|
|
@@ -497,9 +498,23 @@ static const struct i2c_device_id ltc294x_i2c_id[] = {
|
|
|
};
|
|
|
MODULE_DEVICE_TABLE(i2c, ltc294x_i2c_id);
|
|
|
|
|
|
+static const struct of_device_id ltc294x_i2c_of_match[] = {
|
|
|
+ {
|
|
|
+ .compatible = "lltc,ltc2941",
|
|
|
+ .data = (void *)LTC2941_NUM_REGS
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .compatible = "lltc,ltc2943",
|
|
|
+ .data = (void *)LTC2943_NUM_REGS
|
|
|
+ },
|
|
|
+ { },
|
|
|
+};
|
|
|
+MODULE_DEVICE_TABLE(of, ltc294x_i2c_of_match);
|
|
|
+
|
|
|
static struct i2c_driver ltc294x_driver = {
|
|
|
.driver = {
|
|
|
.name = "LTC2941",
|
|
|
+ .of_match_table = ltc294x_i2c_of_match,
|
|
|
.pm = LTC294X_PM_OPS,
|
|
|
},
|
|
|
.probe = ltc294x_i2c_probe,
|