|
@@ -60,48 +60,21 @@
|
|
|
|
|
|
#define DRV_VERSION "0.05"
|
|
#define DRV_VERSION "0.05"
|
|
|
|
|
|
-struct m41t80_chip_info {
|
|
|
|
- const char *name;
|
|
|
|
- u8 features;
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-static const struct m41t80_chip_info m41t80_chip_info_tbl[] = {
|
|
|
|
- {
|
|
|
|
- .name = "m41t80",
|
|
|
|
- .features = 0,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- .name = "m41t81",
|
|
|
|
- .features = M41T80_FEATURE_HT,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- .name = "m41t81s",
|
|
|
|
- .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- .name = "m41t82",
|
|
|
|
- .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- .name = "m41t83",
|
|
|
|
- .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- .name = "m41st84",
|
|
|
|
- .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- .name = "m41st85",
|
|
|
|
- .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- .name = "m41st87",
|
|
|
|
- .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL,
|
|
|
|
- },
|
|
|
|
|
|
+static const struct i2c_device_id m41t80_id[] = {
|
|
|
|
+ { "m41t80", 0 },
|
|
|
|
+ { "m41t81", M41T80_FEATURE_HT },
|
|
|
|
+ { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
|
|
|
|
+ { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
|
|
|
|
+ { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
|
|
|
|
+ { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
|
|
|
|
+ { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
|
|
|
|
+ { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
|
|
|
|
+ { }
|
|
};
|
|
};
|
|
|
|
+MODULE_DEVICE_TABLE(i2c, m41t80_id);
|
|
|
|
|
|
struct m41t80_data {
|
|
struct m41t80_data {
|
|
- const struct m41t80_chip_info *chip;
|
|
|
|
|
|
+ u8 features;
|
|
struct rtc_device *rtc;
|
|
struct rtc_device *rtc;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -208,7 +181,7 @@ static int m41t80_rtc_proc(struct device *dev, struct seq_file *seq)
|
|
struct m41t80_data *clientdata = i2c_get_clientdata(client);
|
|
struct m41t80_data *clientdata = i2c_get_clientdata(client);
|
|
u8 reg;
|
|
u8 reg;
|
|
|
|
|
|
- if (clientdata->chip->features & M41T80_FEATURE_BL) {
|
|
|
|
|
|
+ if (clientdata->features & M41T80_FEATURE_BL) {
|
|
reg = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS);
|
|
reg = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS);
|
|
seq_printf(seq, "battery\t\t: %s\n",
|
|
seq_printf(seq, "battery\t\t: %s\n",
|
|
(reg & M41T80_FLAGS_BATT_LOW) ? "exhausted" : "ok");
|
|
(reg & M41T80_FLAGS_BATT_LOW) ? "exhausted" : "ok");
|
|
@@ -759,10 +732,9 @@ static struct notifier_block wdt_notifier = {
|
|
static int m41t80_probe(struct i2c_client *client,
|
|
static int m41t80_probe(struct i2c_client *client,
|
|
const struct i2c_device_id *id)
|
|
const struct i2c_device_id *id)
|
|
{
|
|
{
|
|
- int i, rc = 0;
|
|
|
|
|
|
+ int rc = 0;
|
|
struct rtc_device *rtc = NULL;
|
|
struct rtc_device *rtc = NULL;
|
|
struct rtc_time tm;
|
|
struct rtc_time tm;
|
|
- const struct m41t80_chip_info *chip;
|
|
|
|
struct m41t80_data *clientdata = NULL;
|
|
struct m41t80_data *clientdata = NULL;
|
|
|
|
|
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
|
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
|
|
@@ -774,19 +746,6 @@ static int m41t80_probe(struct i2c_client *client,
|
|
dev_info(&client->dev,
|
|
dev_info(&client->dev,
|
|
"chip found, driver version " DRV_VERSION "\n");
|
|
"chip found, driver version " DRV_VERSION "\n");
|
|
|
|
|
|
- chip = NULL;
|
|
|
|
- for (i = 0; i < ARRAY_SIZE(m41t80_chip_info_tbl); i++) {
|
|
|
|
- if (!strcmp(m41t80_chip_info_tbl[i].name, client->name)) {
|
|
|
|
- chip = &m41t80_chip_info_tbl[i];
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!chip) {
|
|
|
|
- dev_err(&client->dev, "%s is not supported\n", client->name);
|
|
|
|
- rc = -ENODEV;
|
|
|
|
- goto exit;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL);
|
|
clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL);
|
|
if (!clientdata) {
|
|
if (!clientdata) {
|
|
rc = -ENOMEM;
|
|
rc = -ENOMEM;
|
|
@@ -802,7 +761,7 @@ static int m41t80_probe(struct i2c_client *client,
|
|
}
|
|
}
|
|
|
|
|
|
clientdata->rtc = rtc;
|
|
clientdata->rtc = rtc;
|
|
- clientdata->chip = chip;
|
|
|
|
|
|
+ clientdata->features = id->driver_data;
|
|
i2c_set_clientdata(client, clientdata);
|
|
i2c_set_clientdata(client, clientdata);
|
|
|
|
|
|
/* Make sure HT (Halt Update) bit is cleared */
|
|
/* Make sure HT (Halt Update) bit is cleared */
|
|
@@ -811,7 +770,7 @@ static int m41t80_probe(struct i2c_client *client,
|
|
goto ht_err;
|
|
goto ht_err;
|
|
|
|
|
|
if (rc & M41T80_ALHOUR_HT) {
|
|
if (rc & M41T80_ALHOUR_HT) {
|
|
- if (chip->features & M41T80_FEATURE_HT) {
|
|
|
|
|
|
+ if (clientdata->features & M41T80_FEATURE_HT) {
|
|
m41t80_get_datetime(client, &tm);
|
|
m41t80_get_datetime(client, &tm);
|
|
dev_info(&client->dev, "HT bit was set!\n");
|
|
dev_info(&client->dev, "HT bit was set!\n");
|
|
dev_info(&client->dev,
|
|
dev_info(&client->dev,
|
|
@@ -843,7 +802,7 @@ static int m41t80_probe(struct i2c_client *client,
|
|
goto exit;
|
|
goto exit;
|
|
|
|
|
|
#ifdef CONFIG_RTC_DRV_M41T80_WDT
|
|
#ifdef CONFIG_RTC_DRV_M41T80_WDT
|
|
- if (chip->features & M41T80_FEATURE_HT) {
|
|
|
|
|
|
+ if (clientdata->features & M41T80_FEATURE_HT) {
|
|
rc = misc_register(&wdt_dev);
|
|
rc = misc_register(&wdt_dev);
|
|
if (rc)
|
|
if (rc)
|
|
goto exit;
|
|
goto exit;
|
|
@@ -879,7 +838,7 @@ static int m41t80_remove(struct i2c_client *client)
|
|
struct rtc_device *rtc = clientdata->rtc;
|
|
struct rtc_device *rtc = clientdata->rtc;
|
|
|
|
|
|
#ifdef CONFIG_RTC_DRV_M41T80_WDT
|
|
#ifdef CONFIG_RTC_DRV_M41T80_WDT
|
|
- if (clientdata->chip->features & M41T80_FEATURE_HT) {
|
|
|
|
|
|
+ if (clientdata->features & M41T80_FEATURE_HT) {
|
|
misc_deregister(&wdt_dev);
|
|
misc_deregister(&wdt_dev);
|
|
unregister_reboot_notifier(&wdt_notifier);
|
|
unregister_reboot_notifier(&wdt_notifier);
|
|
}
|
|
}
|
|
@@ -897,6 +856,7 @@ static struct i2c_driver m41t80_driver = {
|
|
},
|
|
},
|
|
.probe = m41t80_probe,
|
|
.probe = m41t80_probe,
|
|
.remove = m41t80_remove,
|
|
.remove = m41t80_remove,
|
|
|
|
+ .id_table = m41t80_id,
|
|
};
|
|
};
|
|
|
|
|
|
static int __init m41t80_rtc_init(void)
|
|
static int __init m41t80_rtc_init(void)
|