1 // SPDX-License-Identifier: GPL-2.0+
3 * PMIC Error Signal Monitor driver
5 * Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com/
6 * Tero Kristo <t-kristo@ti.com>
12 #include <power/pmic.h>
13 #include <dm/device_compat.h>
14 #include <linux/bitops.h>
16 #define INT_ESM_REG 0x6c
17 #define INT_ESM_MASK 0x3f
19 #define ESM_MCU_START_REG 0x8f
21 #define ESM_MCU_START BIT(0)
23 #define ESM_MCU_MODE_CFG_REG 0x92
25 #define ESM_MCU_EN BIT(6)
26 #define ESM_MCU_ENDRV BIT(5)
28 #define ESM_MCU_MASK_REG 0x59
29 #define ESM_MCU_MASK 0x7
32 * pmic_esm_probe: configures and enables PMIC ESM functionality
34 * Configures ESM PMIC support and enables it.
36 static int pmic_esm_probe(struct udevice *dev)
40 ret = pmic_reg_write(dev->parent, INT_ESM_REG, INT_ESM_MASK);
42 dev_err(dev, "clearing ESM irqs failed: %d\n", ret);
46 ret = pmic_reg_write(dev->parent, ESM_MCU_MODE_CFG_REG,
47 ESM_MCU_EN | ESM_MCU_ENDRV);
49 dev_err(dev, "setting ESM mode failed: %d\n", ret);
53 ret = pmic_reg_write(dev->parent, ESM_MCU_MASK_REG, ESM_MCU_MASK);
55 dev_err(dev, "clearing ESM masks failed: %d\n", ret);
59 ret = pmic_reg_write(dev->parent, ESM_MCU_START_REG, ESM_MCU_START);
61 dev_err(dev, "starting ESM failed: %d\n", ret);
68 static const struct udevice_id pmic_esm_ids[] = {
69 { .compatible = "ti,tps659413-esm" },
73 U_BOOT_DRIVER(pmic_esm) = {
75 .of_match = pmic_esm_ids,
77 .probe = pmic_esm_probe,