Lines Matching full: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); in max8997_read_reg() local
51 mutex_lock(&max8997->iolock); in max8997_read_reg()
53 mutex_unlock(&max8997->iolock); in max8997_read_reg()
65 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); in max8997_bulk_read() local
68 mutex_lock(&max8997->iolock); in max8997_bulk_read()
70 mutex_unlock(&max8997->iolock); in max8997_bulk_read()
80 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); in max8997_write_reg() local
83 mutex_lock(&max8997->iolock); in max8997_write_reg()
85 mutex_unlock(&max8997->iolock); in max8997_write_reg()
92 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); in max8997_bulk_write() local
95 mutex_lock(&max8997->iolock); in max8997_bulk_write()
97 mutex_unlock(&max8997->iolock); in max8997_bulk_write()
107 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); in max8997_update_reg() local
110 mutex_lock(&max8997->iolock); in max8997_update_reg()
117 mutex_unlock(&max8997->iolock); in max8997_update_reg()
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
157 struct max8997_dev *max8997; in max8997_i2c_probe() local
161 max8997 = devm_kzalloc(&i2c->dev, sizeof(struct max8997_dev), in max8997_i2c_probe()
163 if (max8997 == NULL) in max8997_i2c_probe()
166 i2c_set_clientdata(i2c, max8997); in max8997_i2c_probe()
167 max8997->dev = &i2c->dev; in max8997_i2c_probe()
168 max8997->i2c = i2c; in max8997_i2c_probe()
169 max8997->type = max8997_i2c_get_driver_data(i2c, id); in max8997_i2c_probe()
170 max8997->irq = i2c->irq; in max8997_i2c_probe()
172 if (IS_ENABLED(CONFIG_OF) && max8997->dev->of_node) { in max8997_i2c_probe()
173 pdata = max8997_i2c_parse_dt_pdata(max8997->dev); in max8997_i2c_probe()
181 max8997->pdata = pdata; in max8997_i2c_probe()
182 max8997->ono = pdata->ono; in max8997_i2c_probe()
184 mutex_init(&max8997->iolock); in max8997_i2c_probe()
186 max8997->rtc = i2c_new_dummy_device(i2c->adapter, I2C_ADDR_RTC); in max8997_i2c_probe()
187 if (IS_ERR(max8997->rtc)) { in max8997_i2c_probe()
188 dev_err(max8997->dev, "Failed to allocate I2C device for RTC\n"); in max8997_i2c_probe()
189 return PTR_ERR(max8997->rtc); in max8997_i2c_probe()
191 i2c_set_clientdata(max8997->rtc, max8997); in max8997_i2c_probe()
193 max8997->haptic = i2c_new_dummy_device(i2c->adapter, I2C_ADDR_HAPTIC); in max8997_i2c_probe()
194 if (IS_ERR(max8997->haptic)) { in max8997_i2c_probe()
195 dev_err(max8997->dev, "Failed to allocate I2C device for Haptic\n"); in max8997_i2c_probe()
196 ret = PTR_ERR(max8997->haptic); in max8997_i2c_probe()
199 i2c_set_clientdata(max8997->haptic, max8997); in max8997_i2c_probe()
201 max8997->muic = i2c_new_dummy_device(i2c->adapter, I2C_ADDR_MUIC); in max8997_i2c_probe()
202 if (IS_ERR(max8997->muic)) { in max8997_i2c_probe()
203 dev_err(max8997->dev, "Failed to allocate I2C device for MUIC\n"); in max8997_i2c_probe()
204 ret = PTR_ERR(max8997->muic); in max8997_i2c_probe()
207 i2c_set_clientdata(max8997->muic, max8997); in max8997_i2c_probe()
209 pm_runtime_set_active(max8997->dev); in max8997_i2c_probe()
211 max8997_irq_init(max8997); in max8997_i2c_probe()
213 ret = mfd_add_devices(max8997->dev, -1, max8997_devs, in max8997_i2c_probe()
217 dev_err(max8997->dev, "failed to add MFD devices %d\n", ret); in max8997_i2c_probe()
226 /* MAX8997 has a power button input. */ in max8997_i2c_probe()
227 device_init_wakeup(max8997->dev, true); in max8997_i2c_probe()
232 mfd_remove_devices(max8997->dev); in max8997_i2c_probe()
233 i2c_unregister_device(max8997->muic); in max8997_i2c_probe()
235 i2c_unregister_device(max8997->haptic); in max8997_i2c_probe()
237 i2c_unregister_device(max8997->rtc); in max8997_i2c_probe()
242 { "max8997", TYPE_MAX8997 },
403 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); in max8997_freeze() local
408 &max8997->reg_dump[i]); in max8997_freeze()
412 &max8997->reg_dump[i + MAX8997_REG_PMIC_END]); in max8997_freeze()
416 &max8997->reg_dump[i + MAX8997_REG_PMIC_END + in max8997_freeze()
425 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); in max8997_restore() local
430 max8997->reg_dump[i]); in max8997_restore()
434 max8997->reg_dump[i + MAX8997_REG_PMIC_END]); in max8997_restore()
438 max8997->reg_dump[i + MAX8997_REG_PMIC_END + in max8997_restore()
447 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); in max8997_suspend() local
449 disable_irq(max8997->irq); in max8997_suspend()
451 irq_set_irq_wake(max8997->irq, 1); in max8997_suspend()
458 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); in max8997_resume() local
461 irq_set_irq_wake(max8997->irq, 0); in max8997_resume()
462 enable_irq(max8997->irq); in max8997_resume()
463 return max8997_irq_resume(max8997); in max8997_resume()
475 .name = "max8997",