Lines Matching defs:max8997
3 // max8997.c - mfd core driver for the Maxim 8966 and 8997
20 #include <linux/mfd/max8997.h>
21 #include <linux/mfd/max8997-private.h>
30 { .name = "max8997-pmic", },
31 { .name = "max8997-rtc", },
32 { .name = "max8997-battery", },
33 { .name = "max8997-haptic", },
34 { .name = "max8997-muic", },
35 { .name = "max8997-led", .id = 1 },
36 { .name = "max8997-led", .id = 2 },
41 { .compatible = "maxim,max8997-pmic", .data = (void *)TYPE_MAX8997 },
48 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
51 mutex_lock(&max8997->iolock);
53 mutex_unlock(&max8997->iolock);
65 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
68 mutex_lock(&max8997->iolock);
70 mutex_unlock(&max8997->iolock);
80 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
83 mutex_lock(&max8997->iolock);
85 mutex_unlock(&max8997->iolock);
92 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
95 mutex_lock(&max8997->iolock);
97 mutex_unlock(&max8997->iolock);
107 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
110 mutex_lock(&max8997->iolock);
117 mutex_unlock(&max8997->iolock);
123 * Only the common platform data elements for max8997 are parsed here from the
124 * device tree. Other sub-modules of max8997 such as pmic, rtc and others have
127 * The max8997 platform data structure is instantiated here and the drivers for
159 struct max8997_dev *max8997;
163 max8997 = devm_kzalloc(&i2c->dev, sizeof(struct max8997_dev),
165 if (max8997 == NULL)
168 i2c_set_clientdata(i2c, max8997);
169 max8997->dev = &i2c->dev;
170 max8997->i2c = i2c;
171 max8997->type = max8997_i2c_get_driver_data(i2c, id);
172 max8997->irq = i2c->irq;
174 if (IS_ENABLED(CONFIG_OF) && max8997->dev->of_node) {
175 pdata = max8997_i2c_parse_dt_pdata(max8997->dev);
183 max8997->pdata = pdata;
184 max8997->ono = pdata->ono;
186 mutex_init(&max8997->iolock);
188 max8997->rtc = i2c_new_dummy_device(i2c->adapter, I2C_ADDR_RTC);
189 if (IS_ERR(max8997->rtc)) {
190 dev_err(max8997->dev, "Failed to allocate I2C device for RTC\n");
191 return PTR_ERR(max8997->rtc);
193 i2c_set_clientdata(max8997->rtc, max8997);
195 max8997->haptic = i2c_new_dummy_device(i2c->adapter, I2C_ADDR_HAPTIC);
196 if (IS_ERR(max8997->haptic)) {
197 dev_err(max8997->dev, "Failed to allocate I2C device for Haptic\n");
198 ret = PTR_ERR(max8997->haptic);
201 i2c_set_clientdata(max8997->haptic, max8997);
203 max8997->muic = i2c_new_dummy_device(i2c->adapter, I2C_ADDR_MUIC);
204 if (IS_ERR(max8997->muic)) {
205 dev_err(max8997->dev, "Failed to allocate I2C device for MUIC\n");
206 ret = PTR_ERR(max8997->muic);
209 i2c_set_clientdata(max8997->muic, max8997);
211 pm_runtime_set_active(max8997->dev);
213 max8997_irq_init(max8997);
215 ret = mfd_add_devices(max8997->dev, -1, max8997_devs,
219 dev_err(max8997->dev, "failed to add MFD devices %d\n", ret);
229 device_init_wakeup(max8997->dev, true);
234 mfd_remove_devices(max8997->dev);
235 i2c_unregister_device(max8997->muic);
237 i2c_unregister_device(max8997->haptic);
239 i2c_unregister_device(max8997->rtc);
244 { "max8997", TYPE_MAX8997 },
405 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
410 &max8997->reg_dump[i]);
414 &max8997->reg_dump[i + MAX8997_REG_PMIC_END]);
418 &max8997->reg_dump[i + MAX8997_REG_PMIC_END +
427 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
432 max8997->reg_dump[i]);
436 max8997->reg_dump[i + MAX8997_REG_PMIC_END]);
440 max8997->reg_dump[i + MAX8997_REG_PMIC_END +
449 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
451 disable_irq(max8997->irq);
453 irq_set_irq_wake(max8997->irq, 1);
460 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
463 irq_set_irq_wake(max8997->irq, 0);
464 enable_irq(max8997->irq);
465 return max8997_irq_resume(max8997);
477 .name = "max8997",