Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: Support for ROHM BD71815 PMIC core

Add core support for ROHM BD71815 Power Management IC.

The IC integrates regulators, a battery charger with a coulomb counter,
a real-time clock (RTC), clock gate and general-purpose outputs (GPO).

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Matti Vaittinen and committed by
Lee Jones
4dcdcfd5 06b2f5f5

+935 -135
+8 -7
drivers/mfd/Kconfig
··· 1975 1975 charger. 1976 1976 1977 1977 config MFD_ROHM_BD71828 1978 - tristate "ROHM BD71828 Power Management IC" 1978 + tristate "ROHM BD71828 and BD71815 Power Management IC" 1979 1979 depends on I2C=y 1980 1980 depends on OF 1981 1981 select REGMAP_I2C 1982 1982 select REGMAP_IRQ 1983 1983 select MFD_CORE 1984 1984 help 1985 - Select this option to get support for the ROHM BD71828 Power 1986 - Management IC. BD71828GW is a single-chip power management IC for 1987 - battery-powered portable devices. The IC integrates 7 buck 1988 - converters, 7 LDOs, and a 1500 mA single-cell linear charger. 1989 - Also included is a Coulomb counter, a real-time clock (RTC), and 1990 - a 32.768 kHz clock gate. 1985 + Select this option to get support for the ROHM BD71828 and BD71815 1986 + Power Management ICs. BD71828GW and BD71815AGW are single-chip power 1987 + management ICs mainly for battery-powered portable devices. 1988 + The BD71828 integrates 7 buck converters and 7 LDOs. The BD71815 1989 + has 5 bucks, 7 LDOs, and a boost for driving LEDs. Both ICs provide 1990 + also a single-cell linear charger, a Coulomb counter, a real-time 1991 + clock (RTC), GPIOs and a 32.768 kHz clock gate. 1991 1992 1992 1993 config MFD_STM32_LPTIMER 1993 1994 tristate "Support for STM32 Low-Power Timer"
+362 -128
drivers/mfd/rohm-bd71828.c
··· 2 2 // 3 3 // Copyright (C) 2019 ROHM Semiconductors 4 4 // 5 - // ROHM BD71828 PMIC driver 5 + // ROHM BD71828/BD71815 PMIC driver 6 6 7 7 #include <linux/gpio_keys.h> 8 8 #include <linux/i2c.h> ··· 11 11 #include <linux/ioport.h> 12 12 #include <linux/irq.h> 13 13 #include <linux/mfd/core.h> 14 + #include <linux/mfd/rohm-bd71815.h> 14 15 #include <linux/mfd/rohm-bd71828.h> 16 + #include <linux/mfd/rohm-generic.h> 15 17 #include <linux/module.h> 16 18 #include <linux/of_device.h> 17 19 #include <linux/regmap.h> ··· 31 29 .name = "bd71828-pwrkey", 32 30 }; 33 31 34 - static const struct resource rtc_irqs[] = { 32 + static const struct resource bd71815_rtc_irqs[] = { 33 + DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC0, "bd71815-rtc-alm-0"), 34 + DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC1, "bd71815-rtc-alm-1"), 35 + DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC2, "bd71815-rtc-alm-2"), 36 + }; 37 + 38 + static const struct resource bd71828_rtc_irqs[] = { 35 39 DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC0, "bd71828-rtc-alm-0"), 36 40 DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC1, "bd71828-rtc-alm-1"), 37 41 DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC2, "bd71828-rtc-alm-2"), 42 + }; 43 + 44 + static struct resource bd71815_power_irqs[] = { 45 + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_RMV, "bd71815-dcin-rmv"), 46 + DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_OUT, "bd71815-clps-out"), 47 + DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_IN, "bd71815-clps-in"), 48 + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_OVP_RES, "bd71815-dcin-ovp-res"), 49 + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_OVP_DET, "bd71815-dcin-ovp-det"), 50 + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_MON_RES, "bd71815-dcin-mon-res"), 51 + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_MON_DET, "bd71815-dcin-mon-det"), 52 + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_UV_RES, "bd71815-vsys-uv-res"), 53 + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_UV_DET, "bd71815-vsys-uv-det"), 54 + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_LOW_RES, "bd71815-vsys-low-res"), 55 + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_LOW_DET, "bd71815-vsys-low-det"), 56 + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_MON_RES, "bd71815-vsys-mon-res"), 57 + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_MON_RES, "bd71815-vsys-mon-det"), 58 + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_WDG_TEMP, "bd71815-chg-wdg-temp"), 59 + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_WDG_TIME, "bd71815-chg-wdg"), 60 + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_RECHARGE_RES, "bd71815-rechg-res"), 61 + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_RECHARGE_DET, "bd71815-rechg-det"), 62 + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_RANGED_TEMP_TRANSITION, "bd71815-ranged-temp-transit"), 63 + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_STATE_TRANSITION, "bd71815-chg-state-change"), 64 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_TEMP_NORMAL, "bd71815-bat-temp-normal"), 65 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_TEMP_ERANGE, "bd71815-bat-temp-erange"), 66 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_REMOVED, "bd71815-bat-rmv"), 67 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_DETECTED, "bd71815-bat-det"), 68 + DEFINE_RES_IRQ_NAMED(BD71815_INT_THERM_REMOVED, "bd71815-therm-rmv"), 69 + DEFINE_RES_IRQ_NAMED(BD71815_INT_THERM_DETECTED, "bd71815-therm-det"), 70 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_DEAD, "bd71815-bat-dead"), 71 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_SHORTC_RES, "bd71815-bat-short-res"), 72 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_SHORTC_DET, "bd71815-bat-short-det"), 73 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_LOW_VOLT_RES, "bd71815-bat-low-res"), 74 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_LOW_VOLT_DET, "bd71815-bat-low-det"), 75 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_VOLT_RES, "bd71815-bat-over-res"), 76 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_VOLT_DET, "bd71815-bat-over-det"), 77 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_MON_RES, "bd71815-bat-mon-res"), 78 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_MON_DET, "bd71815-bat-mon-det"), 79 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_CC_MON1, "bd71815-bat-cc-mon1"), 80 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_CC_MON2, "bd71815-bat-cc-mon2"), 81 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_CC_MON3, "bd71815-bat-cc-mon3"), 82 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_1_RES, "bd71815-bat-oc1-res"), 83 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_1_DET, "bd71815-bat-oc1-det"), 84 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_2_RES, "bd71815-bat-oc2-res"), 85 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_2_DET, "bd71815-bat-oc2-det"), 86 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_3_RES, "bd71815-bat-oc3-res"), 87 + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_3_DET, "bd71815-bat-oc3-det"), 88 + DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_LOW_RES, "bd71815-bat-low-res"), 89 + DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_LOW_DET, "bd71815-bat-low-det"), 90 + DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_HI_RES, "bd71815-bat-hi-res"), 91 + DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_HI_DET, "bd71815-bat-hi-det"), 92 + }; 93 + 94 + static struct mfd_cell bd71815_mfd_cells[] = { 95 + { .name = "bd71815-pmic", }, 96 + { .name = "bd71815-clk", }, 97 + { .name = "bd71815-gpo", }, 98 + { 99 + .name = "bd71815-power", 100 + .num_resources = ARRAY_SIZE(bd71815_power_irqs), 101 + .resources = &bd71815_power_irqs[0], 102 + }, 103 + { 104 + .name = "bd71815-rtc", 105 + .num_resources = ARRAY_SIZE(bd71815_rtc_irqs), 106 + .resources = &bd71815_rtc_irqs[0], 107 + }, 38 108 }; 39 109 40 110 static struct mfd_cell bd71828_mfd_cells[] = { ··· 121 47 { .name = "bd71827-power", }, 122 48 { 123 49 .name = "bd71828-rtc", 124 - .resources = rtc_irqs, 125 - .num_resources = ARRAY_SIZE(rtc_irqs), 50 + .resources = bd71828_rtc_irqs, 51 + .num_resources = ARRAY_SIZE(bd71828_rtc_irqs), 126 52 }, { 127 53 .name = "gpio-keys", 128 54 .platform_data = &bd71828_powerkey_data, ··· 130 56 }, 131 57 }; 132 58 133 - static const struct regmap_range volatile_ranges[] = { 59 + static const struct regmap_range bd71815_volatile_ranges[] = { 60 + { 61 + .range_min = BD71815_REG_SEC, 62 + .range_max = BD71815_REG_YEAR, 63 + }, { 64 + .range_min = BD71815_REG_CONF, 65 + .range_max = BD71815_REG_BAT_TEMP, 66 + }, { 67 + .range_min = BD71815_REG_VM_IBAT_U, 68 + .range_max = BD71815_REG_CC_CTRL, 69 + }, { 70 + .range_min = BD71815_REG_CC_STAT, 71 + .range_max = BD71815_REG_CC_CURCD_L, 72 + }, { 73 + .range_min = BD71815_REG_VM_BTMP_MON, 74 + .range_max = BD71815_REG_VM_BTMP_MON, 75 + }, { 76 + .range_min = BD71815_REG_INT_STAT, 77 + .range_max = BD71815_REG_INT_UPDATE, 78 + }, { 79 + .range_min = BD71815_REG_VM_VSYS_U, 80 + .range_max = BD71815_REG_REX_CTRL_1, 81 + }, { 82 + .range_min = BD71815_REG_FULL_CCNTD_3, 83 + .range_max = BD71815_REG_CCNTD_CHG_2, 84 + }, 85 + }; 86 + 87 + static const struct regmap_range bd71828_volatile_ranges[] = { 134 88 { 135 89 .range_min = BD71828_REG_PS_CTRL_1, 136 90 .range_max = BD71828_REG_PS_CTRL_1, ··· 182 80 }, 183 81 }; 184 82 185 - static const struct regmap_access_table volatile_regs = { 186 - .yes_ranges = &volatile_ranges[0], 187 - .n_yes_ranges = ARRAY_SIZE(volatile_ranges), 83 + static const struct regmap_access_table bd71815_volatile_regs = { 84 + .yes_ranges = &bd71815_volatile_ranges[0], 85 + .n_yes_ranges = ARRAY_SIZE(bd71815_volatile_ranges), 188 86 }; 189 87 190 - static struct regmap_config bd71828_regmap = { 88 + static const struct regmap_access_table bd71828_volatile_regs = { 89 + .yes_ranges = &bd71828_volatile_ranges[0], 90 + .n_yes_ranges = ARRAY_SIZE(bd71828_volatile_ranges), 91 + }; 92 + 93 + static const struct regmap_config bd71815_regmap = { 191 94 .reg_bits = 8, 192 95 .val_bits = 8, 193 - .volatile_table = &volatile_regs, 96 + .volatile_table = &bd71815_volatile_regs, 97 + .max_register = BD71815_MAX_REGISTER - 1, 98 + .cache_type = REGCACHE_RBTREE, 99 + }; 100 + 101 + static const struct regmap_config bd71828_regmap = { 102 + .reg_bits = 8, 103 + .val_bits = 8, 104 + .volatile_table = &bd71828_volatile_regs, 194 105 .max_register = BD71828_MAX_REGISTER, 195 106 .cache_type = REGCACHE_RBTREE, 196 107 }; ··· 211 96 /* 212 97 * Mapping of main IRQ register bits to sub-IRQ register offsets so that we can 213 98 * access corect sub-IRQ registers based on bits that are set in main IRQ 214 - * register. 99 + * register. BD71815 and BD71828 have same sub-register-block offests. 215 100 */ 216 101 217 102 static unsigned int bit0_offsets[] = {11}; /* RTC IRQ */ ··· 223 108 static unsigned int bit6_offsets[] = {1, 2}; /* DCIN IRQ */ 224 109 static unsigned int bit7_offsets[] = {0}; /* BUCK IRQ */ 225 110 226 - static struct regmap_irq_sub_irq_map bd71828_sub_irq_offsets[] = { 111 + static struct regmap_irq_sub_irq_map bd718xx_sub_irq_offsets[] = { 227 112 REGMAP_IRQ_MAIN_REG_OFFSET(bit0_offsets), 228 113 REGMAP_IRQ_MAIN_REG_OFFSET(bit1_offsets), 229 114 REGMAP_IRQ_MAIN_REG_OFFSET(bit2_offsets), ··· 232 117 REGMAP_IRQ_MAIN_REG_OFFSET(bit5_offsets), 233 118 REGMAP_IRQ_MAIN_REG_OFFSET(bit6_offsets), 234 119 REGMAP_IRQ_MAIN_REG_OFFSET(bit7_offsets), 120 + }; 121 + 122 + static const struct regmap_irq bd71815_irqs[] = { 123 + REGMAP_IRQ_REG(BD71815_INT_BUCK1_OCP, 0, BD71815_INT_BUCK1_OCP_MASK), 124 + REGMAP_IRQ_REG(BD71815_INT_BUCK2_OCP, 0, BD71815_INT_BUCK2_OCP_MASK), 125 + REGMAP_IRQ_REG(BD71815_INT_BUCK3_OCP, 0, BD71815_INT_BUCK3_OCP_MASK), 126 + REGMAP_IRQ_REG(BD71815_INT_BUCK4_OCP, 0, BD71815_INT_BUCK4_OCP_MASK), 127 + REGMAP_IRQ_REG(BD71815_INT_BUCK5_OCP, 0, BD71815_INT_BUCK5_OCP_MASK), 128 + REGMAP_IRQ_REG(BD71815_INT_LED_OVP, 0, BD71815_INT_LED_OVP_MASK), 129 + REGMAP_IRQ_REG(BD71815_INT_LED_OCP, 0, BD71815_INT_LED_OCP_MASK), 130 + REGMAP_IRQ_REG(BD71815_INT_LED_SCP, 0, BD71815_INT_LED_SCP_MASK), 131 + /* DCIN1 interrupts */ 132 + REGMAP_IRQ_REG(BD71815_INT_DCIN_RMV, 1, BD71815_INT_DCIN_RMV_MASK), 133 + REGMAP_IRQ_REG(BD71815_INT_CLPS_OUT, 1, BD71815_INT_CLPS_OUT_MASK), 134 + REGMAP_IRQ_REG(BD71815_INT_CLPS_IN, 1, BD71815_INT_CLPS_IN_MASK), 135 + REGMAP_IRQ_REG(BD71815_INT_DCIN_OVP_RES, 1, BD71815_INT_DCIN_OVP_RES_MASK), 136 + REGMAP_IRQ_REG(BD71815_INT_DCIN_OVP_DET, 1, BD71815_INT_DCIN_OVP_DET_MASK), 137 + /* DCIN2 interrupts */ 138 + REGMAP_IRQ_REG(BD71815_INT_DCIN_MON_RES, 2, BD71815_INT_DCIN_MON_RES_MASK), 139 + REGMAP_IRQ_REG(BD71815_INT_DCIN_MON_DET, 2, BD71815_INT_DCIN_MON_DET_MASK), 140 + REGMAP_IRQ_REG(BD71815_INT_WDOG, 2, BD71815_INT_WDOG_MASK), 141 + /* Vsys */ 142 + REGMAP_IRQ_REG(BD71815_INT_VSYS_UV_RES, 3, BD71815_INT_VSYS_UV_RES_MASK), 143 + REGMAP_IRQ_REG(BD71815_INT_VSYS_UV_DET, 3, BD71815_INT_VSYS_UV_DET_MASK), 144 + REGMAP_IRQ_REG(BD71815_INT_VSYS_LOW_RES, 3, BD71815_INT_VSYS_LOW_RES_MASK), 145 + REGMAP_IRQ_REG(BD71815_INT_VSYS_LOW_DET, 3, BD71815_INT_VSYS_LOW_DET_MASK), 146 + REGMAP_IRQ_REG(BD71815_INT_VSYS_MON_RES, 3, BD71815_INT_VSYS_MON_RES_MASK), 147 + REGMAP_IRQ_REG(BD71815_INT_VSYS_MON_DET, 3, BD71815_INT_VSYS_MON_DET_MASK), 148 + /* Charger */ 149 + REGMAP_IRQ_REG(BD71815_INT_CHG_WDG_TEMP, 4, BD71815_INT_CHG_WDG_TEMP_MASK), 150 + REGMAP_IRQ_REG(BD71815_INT_CHG_WDG_TIME, 4, BD71815_INT_CHG_WDG_TIME_MASK), 151 + REGMAP_IRQ_REG(BD71815_INT_CHG_RECHARGE_RES, 4, BD71815_INT_CHG_RECHARGE_RES_MASK), 152 + REGMAP_IRQ_REG(BD71815_INT_CHG_RECHARGE_DET, 4, BD71815_INT_CHG_RECHARGE_DET_MASK), 153 + REGMAP_IRQ_REG(BD71815_INT_CHG_RANGED_TEMP_TRANSITION, 4, 154 + BD71815_INT_CHG_RANGED_TEMP_TRANSITION_MASK), 155 + REGMAP_IRQ_REG(BD71815_INT_CHG_STATE_TRANSITION, 4, BD71815_INT_CHG_STATE_TRANSITION_MASK), 156 + /* Battery */ 157 + REGMAP_IRQ_REG(BD71815_INT_BAT_TEMP_NORMAL, 5, BD71815_INT_BAT_TEMP_NORMAL_MASK), 158 + REGMAP_IRQ_REG(BD71815_INT_BAT_TEMP_ERANGE, 5, BD71815_INT_BAT_TEMP_ERANGE_MASK), 159 + REGMAP_IRQ_REG(BD71815_INT_BAT_REMOVED, 5, BD71815_INT_BAT_REMOVED_MASK), 160 + REGMAP_IRQ_REG(BD71815_INT_BAT_DETECTED, 5, BD71815_INT_BAT_DETECTED_MASK), 161 + REGMAP_IRQ_REG(BD71815_INT_THERM_REMOVED, 5, BD71815_INT_THERM_REMOVED_MASK), 162 + REGMAP_IRQ_REG(BD71815_INT_THERM_DETECTED, 5, BD71815_INT_THERM_DETECTED_MASK), 163 + /* Battery Mon 1 */ 164 + REGMAP_IRQ_REG(BD71815_INT_BAT_DEAD, 6, BD71815_INT_BAT_DEAD_MASK), 165 + REGMAP_IRQ_REG(BD71815_INT_BAT_SHORTC_RES, 6, BD71815_INT_BAT_SHORTC_RES_MASK), 166 + REGMAP_IRQ_REG(BD71815_INT_BAT_SHORTC_DET, 6, BD71815_INT_BAT_SHORTC_DET_MASK), 167 + REGMAP_IRQ_REG(BD71815_INT_BAT_LOW_VOLT_RES, 6, BD71815_INT_BAT_LOW_VOLT_RES_MASK), 168 + REGMAP_IRQ_REG(BD71815_INT_BAT_LOW_VOLT_DET, 6, BD71815_INT_BAT_LOW_VOLT_DET_MASK), 169 + REGMAP_IRQ_REG(BD71815_INT_BAT_OVER_VOLT_RES, 6, BD71815_INT_BAT_OVER_VOLT_RES_MASK), 170 + REGMAP_IRQ_REG(BD71815_INT_BAT_OVER_VOLT_DET, 6, BD71815_INT_BAT_OVER_VOLT_DET_MASK), 171 + /* Battery Mon 2 */ 172 + REGMAP_IRQ_REG(BD71815_INT_BAT_MON_RES, 7, BD71815_INT_BAT_MON_RES_MASK), 173 + REGMAP_IRQ_REG(BD71815_INT_BAT_MON_DET, 7, BD71815_INT_BAT_MON_DET_MASK), 174 + /* Battery Mon 3 (Coulomb counter) */ 175 + REGMAP_IRQ_REG(BD71815_INT_BAT_CC_MON1, 8, BD71815_INT_BAT_CC_MON1_MASK), 176 + REGMAP_IRQ_REG(BD71815_INT_BAT_CC_MON2, 8, BD71815_INT_BAT_CC_MON2_MASK), 177 + REGMAP_IRQ_REG(BD71815_INT_BAT_CC_MON3, 8, BD71815_INT_BAT_CC_MON3_MASK), 178 + /* Battery Mon 4 */ 179 + REGMAP_IRQ_REG(BD71815_INT_BAT_OVER_CURR_1_RES, 9, BD71815_INT_BAT_OVER_CURR_1_RES_MASK), 180 + REGMAP_IRQ_REG(BD71815_INT_BAT_OVER_CURR_1_DET, 9, BD71815_INT_BAT_OVER_CURR_1_DET_MASK), 181 + REGMAP_IRQ_REG(BD71815_INT_BAT_OVER_CURR_2_RES, 9, BD71815_INT_BAT_OVER_CURR_2_RES_MASK), 182 + REGMAP_IRQ_REG(BD71815_INT_BAT_OVER_CURR_2_DET, 9, BD71815_INT_BAT_OVER_CURR_2_DET_MASK), 183 + REGMAP_IRQ_REG(BD71815_INT_BAT_OVER_CURR_3_RES, 9, BD71815_INT_BAT_OVER_CURR_3_RES_MASK), 184 + REGMAP_IRQ_REG(BD71815_INT_BAT_OVER_CURR_3_DET, 9, BD71815_INT_BAT_OVER_CURR_3_DET_MASK), 185 + /* Temperature */ 186 + REGMAP_IRQ_REG(BD71815_INT_TEMP_BAT_LOW_RES, 10, BD71815_INT_TEMP_BAT_LOW_RES_MASK), 187 + REGMAP_IRQ_REG(BD71815_INT_TEMP_BAT_LOW_DET, 10, BD71815_INT_TEMP_BAT_LOW_DET_MASK), 188 + REGMAP_IRQ_REG(BD71815_INT_TEMP_BAT_HI_RES, 10, BD71815_INT_TEMP_BAT_HI_RES_MASK), 189 + REGMAP_IRQ_REG(BD71815_INT_TEMP_BAT_HI_DET, 10, BD71815_INT_TEMP_BAT_HI_DET_MASK), 190 + REGMAP_IRQ_REG(BD71815_INT_TEMP_CHIP_OVER_125_RES, 10, 191 + BD71815_INT_TEMP_CHIP_OVER_125_RES_MASK), 192 + REGMAP_IRQ_REG(BD71815_INT_TEMP_CHIP_OVER_125_DET, 10, 193 + BD71815_INT_TEMP_CHIP_OVER_125_DET_MASK), 194 + REGMAP_IRQ_REG(BD71815_INT_TEMP_CHIP_OVER_VF_RES, 10, 195 + BD71815_INT_TEMP_CHIP_OVER_VF_RES_MASK), 196 + REGMAP_IRQ_REG(BD71815_INT_TEMP_CHIP_OVER_VF_DET, 10, 197 + BD71815_INT_TEMP_CHIP_OVER_VF_DET_MASK), 198 + /* RTC Alarm */ 199 + REGMAP_IRQ_REG(BD71815_INT_RTC0, 11, BD71815_INT_RTC0_MASK), 200 + REGMAP_IRQ_REG(BD71815_INT_RTC1, 11, BD71815_INT_RTC1_MASK), 201 + REGMAP_IRQ_REG(BD71815_INT_RTC2, 11, BD71815_INT_RTC2_MASK), 235 202 }; 236 203 237 204 static struct regmap_irq bd71828_irqs[] = { ··· 331 134 REGMAP_IRQ_REG(BD71828_INT_CLPS_OUT, 1, BD71828_INT_CLPS_OUT_MASK), 332 135 REGMAP_IRQ_REG(BD71828_INT_CLPS_IN, 1, BD71828_INT_CLPS_IN_MASK), 333 136 /* DCIN2 interrupts */ 334 - REGMAP_IRQ_REG(BD71828_INT_DCIN_MON_RES, 2, 335 - BD71828_INT_DCIN_MON_RES_MASK), 336 - REGMAP_IRQ_REG(BD71828_INT_DCIN_MON_DET, 2, 337 - BD71828_INT_DCIN_MON_DET_MASK), 137 + REGMAP_IRQ_REG(BD71828_INT_DCIN_MON_RES, 2, BD71828_INT_DCIN_MON_RES_MASK), 138 + REGMAP_IRQ_REG(BD71828_INT_DCIN_MON_DET, 2, BD71828_INT_DCIN_MON_DET_MASK), 338 139 REGMAP_IRQ_REG(BD71828_INT_LONGPUSH, 2, BD71828_INT_LONGPUSH_MASK), 339 140 REGMAP_IRQ_REG(BD71828_INT_MIDPUSH, 2, BD71828_INT_MIDPUSH_MASK), 340 141 REGMAP_IRQ_REG(BD71828_INT_SHORTPUSH, 2, BD71828_INT_SHORTPUSH_MASK), ··· 340 145 REGMAP_IRQ_REG(BD71828_INT_WDOG, 2, BD71828_INT_WDOG_MASK), 341 146 REGMAP_IRQ_REG(BD71828_INT_SWRESET, 2, BD71828_INT_SWRESET_MASK), 342 147 /* Vsys */ 343 - REGMAP_IRQ_REG(BD71828_INT_VSYS_UV_RES, 3, 344 - BD71828_INT_VSYS_UV_RES_MASK), 345 - REGMAP_IRQ_REG(BD71828_INT_VSYS_UV_DET, 3, 346 - BD71828_INT_VSYS_UV_DET_MASK), 347 - REGMAP_IRQ_REG(BD71828_INT_VSYS_LOW_RES, 3, 348 - BD71828_INT_VSYS_LOW_RES_MASK), 349 - REGMAP_IRQ_REG(BD71828_INT_VSYS_LOW_DET, 3, 350 - BD71828_INT_VSYS_LOW_DET_MASK), 351 - REGMAP_IRQ_REG(BD71828_INT_VSYS_HALL_IN, 3, 352 - BD71828_INT_VSYS_HALL_IN_MASK), 353 - REGMAP_IRQ_REG(BD71828_INT_VSYS_HALL_TOGGLE, 3, 354 - BD71828_INT_VSYS_HALL_TOGGLE_MASK), 355 - REGMAP_IRQ_REG(BD71828_INT_VSYS_MON_RES, 3, 356 - BD71828_INT_VSYS_MON_RES_MASK), 357 - REGMAP_IRQ_REG(BD71828_INT_VSYS_MON_DET, 3, 358 - BD71828_INT_VSYS_MON_DET_MASK), 148 + REGMAP_IRQ_REG(BD71828_INT_VSYS_UV_RES, 3, BD71828_INT_VSYS_UV_RES_MASK), 149 + REGMAP_IRQ_REG(BD71828_INT_VSYS_UV_DET, 3, BD71828_INT_VSYS_UV_DET_MASK), 150 + REGMAP_IRQ_REG(BD71828_INT_VSYS_LOW_RES, 3, BD71828_INT_VSYS_LOW_RES_MASK), 151 + REGMAP_IRQ_REG(BD71828_INT_VSYS_LOW_DET, 3, BD71828_INT_VSYS_LOW_DET_MASK), 152 + REGMAP_IRQ_REG(BD71828_INT_VSYS_HALL_IN, 3, BD71828_INT_VSYS_HALL_IN_MASK), 153 + REGMAP_IRQ_REG(BD71828_INT_VSYS_HALL_TOGGLE, 3, BD71828_INT_VSYS_HALL_TOGGLE_MASK), 154 + REGMAP_IRQ_REG(BD71828_INT_VSYS_MON_RES, 3, BD71828_INT_VSYS_MON_RES_MASK), 155 + REGMAP_IRQ_REG(BD71828_INT_VSYS_MON_DET, 3, BD71828_INT_VSYS_MON_DET_MASK), 359 156 /* Charger */ 360 - REGMAP_IRQ_REG(BD71828_INT_CHG_DCIN_ILIM, 4, 361 - BD71828_INT_CHG_DCIN_ILIM_MASK), 362 - REGMAP_IRQ_REG(BD71828_INT_CHG_TOPOFF_TO_DONE, 4, 363 - BD71828_INT_CHG_TOPOFF_TO_DONE_MASK), 364 - REGMAP_IRQ_REG(BD71828_INT_CHG_WDG_TEMP, 4, 365 - BD71828_INT_CHG_WDG_TEMP_MASK), 366 - REGMAP_IRQ_REG(BD71828_INT_CHG_WDG_TIME, 4, 367 - BD71828_INT_CHG_WDG_TIME_MASK), 368 - REGMAP_IRQ_REG(BD71828_INT_CHG_RECHARGE_RES, 4, 369 - BD71828_INT_CHG_RECHARGE_RES_MASK), 370 - REGMAP_IRQ_REG(BD71828_INT_CHG_RECHARGE_DET, 4, 371 - BD71828_INT_CHG_RECHARGE_DET_MASK), 157 + REGMAP_IRQ_REG(BD71828_INT_CHG_DCIN_ILIM, 4, BD71828_INT_CHG_DCIN_ILIM_MASK), 158 + REGMAP_IRQ_REG(BD71828_INT_CHG_TOPOFF_TO_DONE, 4, BD71828_INT_CHG_TOPOFF_TO_DONE_MASK), 159 + REGMAP_IRQ_REG(BD71828_INT_CHG_WDG_TEMP, 4, BD71828_INT_CHG_WDG_TEMP_MASK), 160 + REGMAP_IRQ_REG(BD71828_INT_CHG_WDG_TIME, 4, BD71828_INT_CHG_WDG_TIME_MASK), 161 + REGMAP_IRQ_REG(BD71828_INT_CHG_RECHARGE_RES, 4, BD71828_INT_CHG_RECHARGE_RES_MASK), 162 + REGMAP_IRQ_REG(BD71828_INT_CHG_RECHARGE_DET, 4, BD71828_INT_CHG_RECHARGE_DET_MASK), 372 163 REGMAP_IRQ_REG(BD71828_INT_CHG_RANGED_TEMP_TRANSITION, 4, 373 164 BD71828_INT_CHG_RANGED_TEMP_TRANSITION_MASK), 374 - REGMAP_IRQ_REG(BD71828_INT_CHG_STATE_TRANSITION, 4, 375 - BD71828_INT_CHG_STATE_TRANSITION_MASK), 165 + REGMAP_IRQ_REG(BD71828_INT_CHG_STATE_TRANSITION, 4, BD71828_INT_CHG_STATE_TRANSITION_MASK), 376 166 /* Battery */ 377 - REGMAP_IRQ_REG(BD71828_INT_BAT_TEMP_NORMAL, 5, 378 - BD71828_INT_BAT_TEMP_NORMAL_MASK), 379 - REGMAP_IRQ_REG(BD71828_INT_BAT_TEMP_ERANGE, 5, 380 - BD71828_INT_BAT_TEMP_ERANGE_MASK), 381 - REGMAP_IRQ_REG(BD71828_INT_BAT_TEMP_WARN, 5, 382 - BD71828_INT_BAT_TEMP_WARN_MASK), 383 - REGMAP_IRQ_REG(BD71828_INT_BAT_REMOVED, 5, 384 - BD71828_INT_BAT_REMOVED_MASK), 385 - REGMAP_IRQ_REG(BD71828_INT_BAT_DETECTED, 5, 386 - BD71828_INT_BAT_DETECTED_MASK), 387 - REGMAP_IRQ_REG(BD71828_INT_THERM_REMOVED, 5, 388 - BD71828_INT_THERM_REMOVED_MASK), 389 - REGMAP_IRQ_REG(BD71828_INT_THERM_DETECTED, 5, 390 - BD71828_INT_THERM_DETECTED_MASK), 167 + REGMAP_IRQ_REG(BD71828_INT_BAT_TEMP_NORMAL, 5, BD71828_INT_BAT_TEMP_NORMAL_MASK), 168 + REGMAP_IRQ_REG(BD71828_INT_BAT_TEMP_ERANGE, 5, BD71828_INT_BAT_TEMP_ERANGE_MASK), 169 + REGMAP_IRQ_REG(BD71828_INT_BAT_TEMP_WARN, 5, BD71828_INT_BAT_TEMP_WARN_MASK), 170 + REGMAP_IRQ_REG(BD71828_INT_BAT_REMOVED, 5, BD71828_INT_BAT_REMOVED_MASK), 171 + REGMAP_IRQ_REG(BD71828_INT_BAT_DETECTED, 5, BD71828_INT_BAT_DETECTED_MASK), 172 + REGMAP_IRQ_REG(BD71828_INT_THERM_REMOVED, 5, BD71828_INT_THERM_REMOVED_MASK), 173 + REGMAP_IRQ_REG(BD71828_INT_THERM_DETECTED, 5, BD71828_INT_THERM_DETECTED_MASK), 391 174 /* Battery Mon 1 */ 392 175 REGMAP_IRQ_REG(BD71828_INT_BAT_DEAD, 6, BD71828_INT_BAT_DEAD_MASK), 393 - REGMAP_IRQ_REG(BD71828_INT_BAT_SHORTC_RES, 6, 394 - BD71828_INT_BAT_SHORTC_RES_MASK), 395 - REGMAP_IRQ_REG(BD71828_INT_BAT_SHORTC_DET, 6, 396 - BD71828_INT_BAT_SHORTC_DET_MASK), 397 - REGMAP_IRQ_REG(BD71828_INT_BAT_LOW_VOLT_RES, 6, 398 - BD71828_INT_BAT_LOW_VOLT_RES_MASK), 399 - REGMAP_IRQ_REG(BD71828_INT_BAT_LOW_VOLT_DET, 6, 400 - BD71828_INT_BAT_LOW_VOLT_DET_MASK), 401 - REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_VOLT_RES, 6, 402 - BD71828_INT_BAT_OVER_VOLT_RES_MASK), 403 - REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_VOLT_DET, 6, 404 - BD71828_INT_BAT_OVER_VOLT_DET_MASK), 176 + REGMAP_IRQ_REG(BD71828_INT_BAT_SHORTC_RES, 6, BD71828_INT_BAT_SHORTC_RES_MASK), 177 + REGMAP_IRQ_REG(BD71828_INT_BAT_SHORTC_DET, 6, BD71828_INT_BAT_SHORTC_DET_MASK), 178 + REGMAP_IRQ_REG(BD71828_INT_BAT_LOW_VOLT_RES, 6, BD71828_INT_BAT_LOW_VOLT_RES_MASK), 179 + REGMAP_IRQ_REG(BD71828_INT_BAT_LOW_VOLT_DET, 6, BD71828_INT_BAT_LOW_VOLT_DET_MASK), 180 + REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_VOLT_RES, 6, BD71828_INT_BAT_OVER_VOLT_RES_MASK), 181 + REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_VOLT_DET, 6, BD71828_INT_BAT_OVER_VOLT_DET_MASK), 405 182 /* Battery Mon 2 */ 406 - REGMAP_IRQ_REG(BD71828_INT_BAT_MON_RES, 7, 407 - BD71828_INT_BAT_MON_RES_MASK), 408 - REGMAP_IRQ_REG(BD71828_INT_BAT_MON_DET, 7, 409 - BD71828_INT_BAT_MON_DET_MASK), 183 + REGMAP_IRQ_REG(BD71828_INT_BAT_MON_RES, 7, BD71828_INT_BAT_MON_RES_MASK), 184 + REGMAP_IRQ_REG(BD71828_INT_BAT_MON_DET, 7, BD71828_INT_BAT_MON_DET_MASK), 410 185 /* Battery Mon 3 (Coulomb counter) */ 411 - REGMAP_IRQ_REG(BD71828_INT_BAT_CC_MON1, 8, 412 - BD71828_INT_BAT_CC_MON1_MASK), 413 - REGMAP_IRQ_REG(BD71828_INT_BAT_CC_MON2, 8, 414 - BD71828_INT_BAT_CC_MON2_MASK), 415 - REGMAP_IRQ_REG(BD71828_INT_BAT_CC_MON3, 8, 416 - BD71828_INT_BAT_CC_MON3_MASK), 186 + REGMAP_IRQ_REG(BD71828_INT_BAT_CC_MON1, 8, BD71828_INT_BAT_CC_MON1_MASK), 187 + REGMAP_IRQ_REG(BD71828_INT_BAT_CC_MON2, 8, BD71828_INT_BAT_CC_MON2_MASK), 188 + REGMAP_IRQ_REG(BD71828_INT_BAT_CC_MON3, 8, BD71828_INT_BAT_CC_MON3_MASK), 417 189 /* Battery Mon 4 */ 418 - REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_1_RES, 9, 419 - BD71828_INT_BAT_OVER_CURR_1_RES_MASK), 420 - REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_1_DET, 9, 421 - BD71828_INT_BAT_OVER_CURR_1_DET_MASK), 422 - REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_2_RES, 9, 423 - BD71828_INT_BAT_OVER_CURR_2_RES_MASK), 424 - REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_2_DET, 9, 425 - BD71828_INT_BAT_OVER_CURR_2_DET_MASK), 426 - REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_3_RES, 9, 427 - BD71828_INT_BAT_OVER_CURR_3_RES_MASK), 428 - REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_3_DET, 9, 429 - BD71828_INT_BAT_OVER_CURR_3_DET_MASK), 190 + REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_1_RES, 9, BD71828_INT_BAT_OVER_CURR_1_RES_MASK), 191 + REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_1_DET, 9, BD71828_INT_BAT_OVER_CURR_1_DET_MASK), 192 + REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_2_RES, 9, BD71828_INT_BAT_OVER_CURR_2_RES_MASK), 193 + REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_2_DET, 9, BD71828_INT_BAT_OVER_CURR_2_DET_MASK), 194 + REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_3_RES, 9, BD71828_INT_BAT_OVER_CURR_3_RES_MASK), 195 + REGMAP_IRQ_REG(BD71828_INT_BAT_OVER_CURR_3_DET, 9, BD71828_INT_BAT_OVER_CURR_3_DET_MASK), 430 196 /* Temperature */ 431 - REGMAP_IRQ_REG(BD71828_INT_TEMP_BAT_LOW_RES, 10, 432 - BD71828_INT_TEMP_BAT_LOW_RES_MASK), 433 - REGMAP_IRQ_REG(BD71828_INT_TEMP_BAT_LOW_DET, 10, 434 - BD71828_INT_TEMP_BAT_LOW_DET_MASK), 435 - REGMAP_IRQ_REG(BD71828_INT_TEMP_BAT_HI_RES, 10, 436 - BD71828_INT_TEMP_BAT_HI_RES_MASK), 437 - REGMAP_IRQ_REG(BD71828_INT_TEMP_BAT_HI_DET, 10, 438 - BD71828_INT_TEMP_BAT_HI_DET_MASK), 197 + REGMAP_IRQ_REG(BD71828_INT_TEMP_BAT_LOW_RES, 10, BD71828_INT_TEMP_BAT_LOW_RES_MASK), 198 + REGMAP_IRQ_REG(BD71828_INT_TEMP_BAT_LOW_DET, 10, BD71828_INT_TEMP_BAT_LOW_DET_MASK), 199 + REGMAP_IRQ_REG(BD71828_INT_TEMP_BAT_HI_RES, 10, BD71828_INT_TEMP_BAT_HI_RES_MASK), 200 + REGMAP_IRQ_REG(BD71828_INT_TEMP_BAT_HI_DET, 10, BD71828_INT_TEMP_BAT_HI_DET_MASK), 439 201 REGMAP_IRQ_REG(BD71828_INT_TEMP_CHIP_OVER_125_RES, 10, 440 202 BD71828_INT_TEMP_CHIP_OVER_125_RES_MASK), 441 203 REGMAP_IRQ_REG(BD71828_INT_TEMP_CHIP_OVER_125_DET, 10, ··· 419 267 .init_ack_masked = true, 420 268 .num_regs = 12, 421 269 .num_main_regs = 1, 422 - .sub_reg_offsets = &bd71828_sub_irq_offsets[0], 270 + .sub_reg_offsets = &bd718xx_sub_irq_offsets[0], 423 271 .num_main_status_bits = 8, 424 272 .irq_reg_stride = 1, 425 273 }; 426 274 275 + static struct regmap_irq_chip bd71815_irq_chip = { 276 + .name = "bd71815_irq", 277 + .main_status = BD71815_REG_INT_STAT, 278 + .irqs = &bd71815_irqs[0], 279 + .num_irqs = ARRAY_SIZE(bd71815_irqs), 280 + .status_base = BD71815_REG_INT_STAT_01, 281 + .mask_base = BD71815_REG_INT_EN_01, 282 + .ack_base = BD71815_REG_INT_STAT_01, 283 + .mask_invert = true, 284 + .init_ack_masked = true, 285 + .num_regs = 12, 286 + .num_main_regs = 1, 287 + .sub_reg_offsets = &bd718xx_sub_irq_offsets[0], 288 + .num_main_status_bits = 8, 289 + .irq_reg_stride = 1, 290 + }; 291 + 292 + static int set_clk_mode(struct device *dev, struct regmap *regmap, 293 + int clkmode_reg) 294 + { 295 + int ret; 296 + unsigned int open_drain; 297 + 298 + ret = of_property_read_u32(dev->of_node, "rohm,clkout-open-drain", &open_drain); 299 + if (ret) { 300 + if (ret == -EINVAL) 301 + return 0; 302 + return ret; 303 + } 304 + if (open_drain > 1) { 305 + dev_err(dev, "bad clk32kout mode configuration"); 306 + return -EINVAL; 307 + } 308 + 309 + if (open_drain) 310 + return regmap_update_bits(regmap, clkmode_reg, OUT32K_MODE, 311 + OUT32K_MODE_OPEN_DRAIN); 312 + 313 + return regmap_update_bits(regmap, clkmode_reg, OUT32K_MODE, 314 + OUT32K_MODE_CMOS); 315 + } 316 + 427 317 static int bd71828_i2c_probe(struct i2c_client *i2c) 428 318 { 429 - struct rohm_regmap_dev *chip; 430 319 struct regmap_irq_chip_data *irq_data; 431 320 int ret; 321 + struct regmap *regmap; 322 + const struct regmap_config *regmap_config; 323 + struct regmap_irq_chip *irqchip; 324 + unsigned int chip_type; 325 + struct mfd_cell *mfd; 326 + int cells; 327 + int button_irq; 328 + int clkmode_reg; 432 329 433 330 if (!i2c->irq) { 434 331 dev_err(&i2c->dev, "No IRQ configured\n"); 435 332 return -EINVAL; 436 333 } 437 334 438 - chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); 439 - if (!chip) 440 - return -ENOMEM; 441 - 442 - dev_set_drvdata(&i2c->dev, chip); 443 - 444 - chip->regmap = devm_regmap_init_i2c(i2c, &bd71828_regmap); 445 - if (IS_ERR(chip->regmap)) { 446 - dev_err(&i2c->dev, "Failed to initialize Regmap\n"); 447 - return PTR_ERR(chip->regmap); 335 + chip_type = (unsigned int)(uintptr_t) 336 + of_device_get_match_data(&i2c->dev); 337 + switch (chip_type) { 338 + case ROHM_CHIP_TYPE_BD71828: 339 + mfd = bd71828_mfd_cells; 340 + cells = ARRAY_SIZE(bd71828_mfd_cells); 341 + regmap_config = &bd71828_regmap; 342 + irqchip = &bd71828_irq_chip; 343 + clkmode_reg = BD71828_REG_OUT32K; 344 + button_irq = BD71828_INT_SHORTPUSH; 345 + break; 346 + case ROHM_CHIP_TYPE_BD71815: 347 + mfd = bd71815_mfd_cells; 348 + cells = ARRAY_SIZE(bd71815_mfd_cells); 349 + regmap_config = &bd71815_regmap; 350 + irqchip = &bd71815_irq_chip; 351 + clkmode_reg = BD71815_REG_OUT32K; 352 + /* 353 + * If BD71817 support is needed we should be able to handle it 354 + * with proper DT configs + BD71815 drivers + power-button. 355 + * BD71815 data-sheet does not list the power-button IRQ so we 356 + * don't use it. 357 + */ 358 + button_irq = 0; 359 + break; 360 + default: 361 + dev_err(&i2c->dev, "Unknown device type"); 362 + return -EINVAL; 448 363 } 449 364 450 - ret = devm_regmap_add_irq_chip(&i2c->dev, chip->regmap, 451 - i2c->irq, IRQF_ONESHOT, 0, 452 - &bd71828_irq_chip, &irq_data); 365 + regmap = devm_regmap_init_i2c(i2c, regmap_config); 366 + if (IS_ERR(regmap)) { 367 + dev_err(&i2c->dev, "Failed to initialize Regmap\n"); 368 + return PTR_ERR(regmap); 369 + } 370 + 371 + ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq, 372 + IRQF_ONESHOT, 0, irqchip, &irq_data); 453 373 if (ret) { 454 374 dev_err(&i2c->dev, "Failed to add IRQ chip\n"); 455 375 return ret; 456 376 } 457 377 458 378 dev_dbg(&i2c->dev, "Registered %d IRQs for chip\n", 459 - bd71828_irq_chip.num_irqs); 379 + irqchip->num_irqs); 460 380 461 - ret = regmap_irq_get_virq(irq_data, BD71828_INT_SHORTPUSH); 462 - if (ret < 0) { 463 - dev_err(&i2c->dev, "Failed to get the power-key IRQ\n"); 464 - return ret; 381 + if (button_irq) { 382 + ret = regmap_irq_get_virq(irq_data, button_irq); 383 + if (ret < 0) { 384 + dev_err(&i2c->dev, "Failed to get the power-key IRQ\n"); 385 + return ret; 386 + } 387 + 388 + button.irq = ret; 465 389 } 466 390 467 - button.irq = ret; 391 + ret = set_clk_mode(&i2c->dev, regmap, clkmode_reg); 392 + if (ret) 393 + return ret; 468 394 469 - ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, 470 - bd71828_mfd_cells, 471 - ARRAY_SIZE(bd71828_mfd_cells), NULL, 0, 472 - regmap_irq_get_domain(irq_data)); 395 + ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, mfd, cells, 396 + NULL, 0, regmap_irq_get_domain(irq_data)); 473 397 if (ret) 474 398 dev_err(&i2c->dev, "Failed to create subdevices\n"); 475 399 ··· 553 325 } 554 326 555 327 static const struct of_device_id bd71828_of_match[] = { 556 - { .compatible = "rohm,bd71828", }, 328 + { 329 + .compatible = "rohm,bd71828", 330 + .data = (void *)ROHM_CHIP_TYPE_BD71828, 331 + }, { 332 + .compatible = "rohm,bd71815", 333 + .data = (void *)ROHM_CHIP_TYPE_BD71815, 334 + }, 557 335 { }, 558 336 }; 559 337 MODULE_DEVICE_TABLE(of, bd71828_of_match);
+562
include/linux/mfd/rohm-bd71815.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 + /* 3 + * Copyright 2021 ROHM Semiconductors. 4 + * 5 + * Author: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> 6 + * 7 + * Copyright 2014 Embest Technology Co. Ltd. Inc. 8 + * 9 + * Author: yanglsh@embest-tech.com 10 + */ 11 + 12 + #ifndef _MFD_BD71815_H 13 + #define _MFD_BD71815_H 14 + 15 + #include <linux/regmap.h> 16 + 17 + enum { 18 + BD71815_BUCK1 = 0, 19 + BD71815_BUCK2, 20 + BD71815_BUCK3, 21 + BD71815_BUCK4, 22 + BD71815_BUCK5, 23 + /* General Purpose */ 24 + BD71815_LDO1, 25 + BD71815_LDO2, 26 + BD71815_LDO3, 27 + /* LDOs for SD Card and SD Card Interface */ 28 + BD71815_LDO4, 29 + BD71815_LDO5, 30 + /* LDO for DDR Reference Voltage */ 31 + BD71815_LDODVREF, 32 + /* LDO for Low-Power State Retention */ 33 + BD71815_LDOLPSR, 34 + BD71815_WLED, 35 + BD71815_REGULATOR_CNT, 36 + }; 37 + 38 + #define BD71815_SUPPLY_STATE_ENABLED 0x1 39 + 40 + enum { 41 + BD71815_REG_DEVICE = 0, 42 + BD71815_REG_PWRCTRL, 43 + BD71815_REG_BUCK1_MODE, 44 + BD71815_REG_BUCK2_MODE, 45 + BD71815_REG_BUCK3_MODE, 46 + BD71815_REG_BUCK4_MODE, 47 + BD71815_REG_BUCK5_MODE, 48 + BD71815_REG_BUCK1_VOLT_H, 49 + BD71815_REG_BUCK1_VOLT_L, 50 + BD71815_REG_BUCK2_VOLT_H, 51 + BD71815_REG_BUCK2_VOLT_L, 52 + BD71815_REG_BUCK3_VOLT, 53 + BD71815_REG_BUCK4_VOLT, 54 + BD71815_REG_BUCK5_VOLT, 55 + BD71815_REG_LED_CTRL, 56 + BD71815_REG_LED_DIMM, 57 + BD71815_REG_LDO_MODE1, 58 + BD71815_REG_LDO_MODE2, 59 + BD71815_REG_LDO_MODE3, 60 + BD71815_REG_LDO_MODE4, 61 + BD71815_REG_LDO1_VOLT, 62 + BD71815_REG_LDO2_VOLT, 63 + BD71815_REG_LDO3_VOLT, 64 + BD71815_REG_LDO4_VOLT, 65 + BD71815_REG_LDO5_VOLT_H, 66 + BD71815_REG_LDO5_VOLT_L, 67 + BD71815_REG_BUCK_PD_DIS, 68 + BD71815_REG_LDO_PD_DIS, 69 + BD71815_REG_GPO, 70 + BD71815_REG_OUT32K, 71 + BD71815_REG_SEC, 72 + BD71815_REG_MIN, 73 + BD71815_REG_HOUR, 74 + BD71815_REG_WEEK, 75 + BD71815_REG_DAY, 76 + BD71815_REG_MONTH, 77 + BD71815_REG_YEAR, 78 + BD71815_REG_ALM0_SEC, 79 + 80 + BD71815_REG_ALM1_SEC = 0x2C, 81 + 82 + BD71815_REG_ALM0_MASK = 0x33, 83 + BD71815_REG_ALM1_MASK, 84 + BD71815_REG_ALM2, 85 + BD71815_REG_TRIM, 86 + BD71815_REG_CONF, 87 + BD71815_REG_SYS_INIT, 88 + BD71815_REG_CHG_STATE, 89 + BD71815_REG_CHG_LAST_STATE, 90 + BD71815_REG_BAT_STAT, 91 + BD71815_REG_DCIN_STAT, 92 + BD71815_REG_VSYS_STAT, 93 + BD71815_REG_CHG_STAT, 94 + BD71815_REG_CHG_WDT_STAT, 95 + BD71815_REG_BAT_TEMP, 96 + BD71815_REG_IGNORE_0, 97 + BD71815_REG_INHIBIT_0, 98 + BD71815_REG_DCIN_CLPS, 99 + BD71815_REG_VSYS_REG, 100 + BD71815_REG_VSYS_MAX, 101 + BD71815_REG_VSYS_MIN, 102 + BD71815_REG_CHG_SET1, 103 + BD71815_REG_CHG_SET2, 104 + BD71815_REG_CHG_WDT_PRE, 105 + BD71815_REG_CHG_WDT_FST, 106 + BD71815_REG_CHG_IPRE, 107 + BD71815_REG_CHG_IFST, 108 + BD71815_REG_CHG_IFST_TERM, 109 + BD71815_REG_CHG_VPRE, 110 + BD71815_REG_CHG_VBAT_1, 111 + BD71815_REG_CHG_VBAT_2, 112 + BD71815_REG_CHG_VBAT_3, 113 + BD71815_REG_CHG_LED_1, 114 + BD71815_REG_VF_TH, 115 + BD71815_REG_BAT_SET_1, 116 + BD71815_REG_BAT_SET_2, 117 + BD71815_REG_BAT_SET_3, 118 + BD71815_REG_ALM_VBAT_TH_U, 119 + BD71815_REG_ALM_VBAT_TH_L, 120 + BD71815_REG_ALM_DCIN_TH, 121 + BD71815_REG_ALM_VSYS_TH, 122 + BD71815_REG_VM_IBAT_U, 123 + BD71815_REG_VM_IBAT_L, 124 + BD71815_REG_VM_VBAT_U, 125 + BD71815_REG_VM_VBAT_L, 126 + BD71815_REG_VM_BTMP, 127 + BD71815_REG_VM_VTH, 128 + BD71815_REG_VM_DCIN_U, 129 + BD71815_REG_VM_DCIN_L, 130 + BD71815_REG_VM_VSYS, 131 + BD71815_REG_VM_VF, 132 + BD71815_REG_VM_OCI_PRE_U, 133 + BD71815_REG_VM_OCI_PRE_L, 134 + BD71815_REG_VM_OCV_PRE_U, 135 + BD71815_REG_VM_OCV_PRE_L, 136 + BD71815_REG_VM_OCI_PST_U, 137 + BD71815_REG_VM_OCI_PST_L, 138 + BD71815_REG_VM_OCV_PST_U, 139 + BD71815_REG_VM_OCV_PST_L, 140 + BD71815_REG_VM_SA_VBAT_U, 141 + BD71815_REG_VM_SA_VBAT_L, 142 + BD71815_REG_VM_SA_IBAT_U, 143 + BD71815_REG_VM_SA_IBAT_L, 144 + BD71815_REG_CC_CTRL, 145 + BD71815_REG_CC_BATCAP1_TH_U, 146 + BD71815_REG_CC_BATCAP1_TH_L, 147 + BD71815_REG_CC_BATCAP2_TH_U, 148 + BD71815_REG_CC_BATCAP2_TH_L, 149 + BD71815_REG_CC_BATCAP3_TH_U, 150 + BD71815_REG_CC_BATCAP3_TH_L, 151 + BD71815_REG_CC_STAT, 152 + BD71815_REG_CC_CCNTD_3, 153 + BD71815_REG_CC_CCNTD_2, 154 + BD71815_REG_CC_CCNTD_1, 155 + BD71815_REG_CC_CCNTD_0, 156 + BD71815_REG_CC_CURCD_U, 157 + BD71815_REG_CC_CURCD_L, 158 + BD71815_REG_VM_OCUR_THR_1, 159 + BD71815_REG_VM_OCUR_DUR_1, 160 + BD71815_REG_VM_OCUR_THR_2, 161 + BD71815_REG_VM_OCUR_DUR_2, 162 + BD71815_REG_VM_OCUR_THR_3, 163 + BD71815_REG_VM_OCUR_DUR_3, 164 + BD71815_REG_VM_OCUR_MON, 165 + BD71815_REG_VM_BTMP_OV_THR, 166 + BD71815_REG_VM_BTMP_OV_DUR, 167 + BD71815_REG_VM_BTMP_LO_THR, 168 + BD71815_REG_VM_BTMP_LO_DUR, 169 + BD71815_REG_VM_BTMP_MON, 170 + BD71815_REG_INT_EN_01, 171 + 172 + BD71815_REG_INT_EN_11 = 0x95, 173 + BD71815_REG_INT_EN_12, 174 + BD71815_REG_INT_STAT, 175 + BD71815_REG_INT_STAT_01, 176 + BD71815_REG_INT_STAT_02, 177 + BD71815_REG_INT_STAT_03, 178 + BD71815_REG_INT_STAT_04, 179 + BD71815_REG_INT_STAT_05, 180 + BD71815_REG_INT_STAT_06, 181 + BD71815_REG_INT_STAT_07, 182 + BD71815_REG_INT_STAT_08, 183 + BD71815_REG_INT_STAT_09, 184 + BD71815_REG_INT_STAT_10, 185 + BD71815_REG_INT_STAT_11, 186 + BD71815_REG_INT_STAT_12, 187 + BD71815_REG_INT_UPDATE, 188 + 189 + BD71815_REG_VM_VSYS_U = 0xC0, 190 + BD71815_REG_VM_VSYS_L, 191 + BD71815_REG_VM_SA_VSYS_U, 192 + BD71815_REG_VM_SA_VSYS_L, 193 + 194 + BD71815_REG_VM_SA_IBAT_MIN_U = 0xD0, 195 + BD71815_REG_VM_SA_IBAT_MIN_L, 196 + BD71815_REG_VM_SA_IBAT_MAX_U, 197 + BD71815_REG_VM_SA_IBAT_MAX_L, 198 + BD71815_REG_VM_SA_VBAT_MIN_U, 199 + BD71815_REG_VM_SA_VBAT_MIN_L, 200 + BD71815_REG_VM_SA_VBAT_MAX_U, 201 + BD71815_REG_VM_SA_VBAT_MAX_L, 202 + BD71815_REG_VM_SA_VSYS_MIN_U, 203 + BD71815_REG_VM_SA_VSYS_MIN_L, 204 + BD71815_REG_VM_SA_VSYS_MAX_U, 205 + BD71815_REG_VM_SA_VSYS_MAX_L, 206 + BD71815_REG_VM_SA_MINMAX_CLR, 207 + 208 + BD71815_REG_REX_CCNTD_3 = 0xE0, 209 + BD71815_REG_REX_CCNTD_2, 210 + BD71815_REG_REX_CCNTD_1, 211 + BD71815_REG_REX_CCNTD_0, 212 + BD71815_REG_REX_SA_VBAT_U, 213 + BD71815_REG_REX_SA_VBAT_L, 214 + BD71815_REG_REX_CTRL_1, 215 + BD71815_REG_REX_CTRL_2, 216 + BD71815_REG_FULL_CCNTD_3, 217 + BD71815_REG_FULL_CCNTD_2, 218 + BD71815_REG_FULL_CCNTD_1, 219 + BD71815_REG_FULL_CCNTD_0, 220 + BD71815_REG_FULL_CTRL, 221 + 222 + BD71815_REG_CCNTD_CHG_3 = 0xF0, 223 + BD71815_REG_CCNTD_CHG_2, 224 + 225 + BD71815_REG_TEST_MODE = 0xFE, 226 + BD71815_MAX_REGISTER, 227 + }; 228 + 229 + /* BD71815_REG_BUCK1_MODE bits */ 230 + #define BD71815_BUCK_RAMPRATE_MASK 0xC0 231 + #define BD71815_BUCK_RAMPRATE_10P00MV 0x0 232 + #define BD71815_BUCK_RAMPRATE_5P00MV 0x01 233 + #define BD71815_BUCK_RAMPRATE_2P50MV 0x02 234 + #define BD71815_BUCK_RAMPRATE_1P25MV 0x03 235 + 236 + #define BD71815_BUCK_PWM_FIXED BIT(4) 237 + #define BD71815_BUCK_SNVS_ON BIT(3) 238 + #define BD71815_BUCK_RUN_ON BIT(2) 239 + #define BD71815_BUCK_LPSR_ON BIT(1) 240 + #define BD71815_BUCK_SUSP_ON BIT(0) 241 + 242 + /* BD71815_REG_BUCK1_VOLT_H bits */ 243 + #define BD71815_BUCK_DVSSEL BIT(7) 244 + #define BD71815_BUCK_STBY_DVS BIT(6) 245 + #define BD71815_VOLT_MASK 0x3F 246 + #define BD71815_BUCK1_H_DEFAULT 0x14 247 + #define BD71815_BUCK1_L_DEFAULT 0x14 248 + 249 + /* BD71815_REG_BUCK2_VOLT_H bits */ 250 + #define BD71815_BUCK2_H_DEFAULT 0x14 251 + #define BD71815_BUCK2_L_DEFAULT 0x14 252 + 253 + /* WLED output */ 254 + /* current register mask */ 255 + #define LED_DIMM_MASK 0x3f 256 + /* LED enable bits at LED_CTRL reg */ 257 + #define LED_CHGDONE_EN BIT(4) 258 + #define LED_RUN_ON BIT(2) 259 + #define LED_LPSR_ON BIT(1) 260 + #define LED_SUSP_ON BIT(0) 261 + 262 + /* BD71815_REG_LDO1_CTRL bits */ 263 + #define LDO1_EN BIT(0) 264 + #define LDO2_EN BIT(1) 265 + #define LDO3_EN BIT(2) 266 + #define DVREF_EN BIT(3) 267 + #define VOSNVS_SW_EN BIT(4) 268 + 269 + /* LDO_MODE1_register */ 270 + #define LDO1_SNVS_ON BIT(7) 271 + #define LDO1_RUN_ON BIT(6) 272 + #define LDO1_LPSR_ON BIT(5) 273 + #define LDO1_SUSP_ON BIT(4) 274 + /* set => register control, unset => GPIO control */ 275 + #define LDO4_MODE_MASK BIT(3) 276 + #define LDO4_MODE_I2C BIT(3) 277 + #define LDO4_MODE_GPIO 0 278 + /* set => register control, unset => start when DCIN connected */ 279 + #define LDO3_MODE_MASK BIT(2) 280 + #define LDO3_MODE_I2C BIT(2) 281 + #define LDO3_MODE_DCIN 0 282 + 283 + /* LDO_MODE2 register */ 284 + #define LDO3_SNVS_ON BIT(7) 285 + #define LDO3_RUN_ON BIT(6) 286 + #define LDO3_LPSR_ON BIT(5) 287 + #define LDO3_SUSP_ON BIT(4) 288 + #define LDO2_SNVS_ON BIT(3) 289 + #define LDO2_RUN_ON BIT(2) 290 + #define LDO2_LPSR_ON BIT(1) 291 + #define LDO2_SUSP_ON BIT(0) 292 + 293 + 294 + /* LDO_MODE3 register */ 295 + #define LDO5_SNVS_ON BIT(7) 296 + #define LDO5_RUN_ON BIT(6) 297 + #define LDO5_LPSR_ON BIT(5) 298 + #define LDO5_SUSP_ON BIT(4) 299 + #define LDO4_SNVS_ON BIT(3) 300 + #define LDO4_RUN_ON BIT(2) 301 + #define LDO4_LPSR_ON BIT(1) 302 + #define LDO4_SUSP_ON BIT(0) 303 + 304 + /* LDO_MODE4 register */ 305 + #define DVREF_SNVS_ON BIT(7) 306 + #define DVREF_RUN_ON BIT(6) 307 + #define DVREF_LPSR_ON BIT(5) 308 + #define DVREF_SUSP_ON BIT(4) 309 + #define LDO_LPSR_SNVS_ON BIT(3) 310 + #define LDO_LPSR_RUN_ON BIT(2) 311 + #define LDO_LPSR_LPSR_ON BIT(1) 312 + #define LDO_LPSR_SUSP_ON BIT(0) 313 + 314 + /* BD71815_REG_OUT32K bits */ 315 + #define OUT32K_EN BIT(0) 316 + #define OUT32K_MODE BIT(1) 317 + #define OUT32K_MODE_CMOS BIT(1) 318 + #define OUT32K_MODE_OPEN_DRAIN 0 319 + 320 + /* BD71815_REG_BAT_STAT bits */ 321 + #define BAT_DET BIT(5) 322 + #define BAT_DET_OFFSET 5 323 + #define BAT_DET_DONE BIT(4) 324 + #define VBAT_OV BIT(3) 325 + #define DBAT_DET BIT(0) 326 + 327 + /* BD71815_REG_VBUS_STAT bits */ 328 + #define VBUS_DET BIT(0) 329 + 330 + #define BD71815_REG_RTC_START BD71815_REG_SEC 331 + #define BD71815_REG_RTC_ALM_START BD71815_REG_ALM0_SEC 332 + 333 + /* BD71815_REG_ALM0_MASK bits */ 334 + #define A0_ONESEC BIT(7) 335 + 336 + /* BD71815_REG_INT_EN_00 bits */ 337 + #define ALMALE BIT(0) 338 + 339 + /* BD71815_REG_INT_STAT_03 bits */ 340 + #define DCIN_MON_DET BIT(1) 341 + #define DCIN_MON_RES BIT(0) 342 + #define POWERON_LONG BIT(2) 343 + #define POWERON_MID BIT(3) 344 + #define POWERON_SHORT BIT(4) 345 + #define POWERON_PRESS BIT(5) 346 + 347 + /* BD71805_REG_INT_STAT_08 bits */ 348 + #define VBAT_MON_DET BIT(1) 349 + #define VBAT_MON_RES BIT(0) 350 + 351 + /* BD71805_REG_INT_STAT_11 bits */ 352 + #define INT_STAT_11_VF_DET BIT(7) 353 + #define INT_STAT_11_VF_RES BIT(6) 354 + #define INT_STAT_11_VF125_DET BIT(5) 355 + #define INT_STAT_11_VF125_RES BIT(4) 356 + #define INT_STAT_11_OVTMP_DET BIT(3) 357 + #define INT_STAT_11_OVTMP_RES BIT(2) 358 + #define INT_STAT_11_LOTMP_DET BIT(1) 359 + #define INT_STAT_11_LOTMP_RES BIT(0) 360 + 361 + #define VBAT_MON_DET BIT(1) 362 + #define VBAT_MON_RES BIT(0) 363 + 364 + /* BD71815_REG_PWRCTRL bits */ 365 + #define RESTARTEN BIT(0) 366 + 367 + /* BD71815_REG_GPO bits */ 368 + #define READY_FORCE_LOW BIT(2) 369 + #define BD71815_GPIO_DRIVE_MASK BIT(4) 370 + #define BD71815_GPIO_OPEN_DRAIN 0 371 + #define BD71815_GPIO_CMOS BIT(4) 372 + 373 + /* BD71815 interrupt masks */ 374 + enum { 375 + BD71815_INT_EN_01_BUCKAST_MASK = 0x0F, 376 + BD71815_INT_EN_02_DCINAST_MASK = 0x3E, 377 + BD71815_INT_EN_03_DCINAST_MASK = 0x3F, 378 + BD71815_INT_EN_04_VSYSAST_MASK = 0xCF, 379 + BD71815_INT_EN_05_CHGAST_MASK = 0xFC, 380 + BD71815_INT_EN_06_BATAST_MASK = 0xF3, 381 + BD71815_INT_EN_07_BMONAST_MASK = 0xFE, 382 + BD71815_INT_EN_08_BMONAST_MASK = 0x03, 383 + BD71815_INT_EN_09_BMONAST_MASK = 0x07, 384 + BD71815_INT_EN_10_BMONAST_MASK = 0x3F, 385 + BD71815_INT_EN_11_TMPAST_MASK = 0xFF, 386 + BD71815_INT_EN_12_ALMAST_MASK = 0x07, 387 + }; 388 + /* BD71815 interrupt irqs */ 389 + enum { 390 + /* BUCK reg interrupts */ 391 + BD71815_INT_BUCK1_OCP, 392 + BD71815_INT_BUCK2_OCP, 393 + BD71815_INT_BUCK3_OCP, 394 + BD71815_INT_BUCK4_OCP, 395 + BD71815_INT_BUCK5_OCP, 396 + BD71815_INT_LED_OVP, 397 + BD71815_INT_LED_OCP, 398 + BD71815_INT_LED_SCP, 399 + /* DCIN1 interrupts */ 400 + BD71815_INT_DCIN_RMV, 401 + BD71815_INT_CLPS_OUT, 402 + BD71815_INT_CLPS_IN, 403 + BD71815_INT_DCIN_OVP_RES, 404 + BD71815_INT_DCIN_OVP_DET, 405 + /* DCIN2 interrupts */ 406 + BD71815_INT_DCIN_MON_RES, 407 + BD71815_INT_DCIN_MON_DET, 408 + BD71815_INT_WDOG, 409 + /* Vsys INT_STAT_04 */ 410 + BD71815_INT_VSYS_UV_RES, 411 + BD71815_INT_VSYS_UV_DET, 412 + BD71815_INT_VSYS_LOW_RES, 413 + BD71815_INT_VSYS_LOW_DET, 414 + BD71815_INT_VSYS_MON_RES, 415 + BD71815_INT_VSYS_MON_DET, 416 + /* Charger INT_STAT_05 */ 417 + BD71815_INT_CHG_WDG_TEMP, 418 + BD71815_INT_CHG_WDG_TIME, 419 + BD71815_INT_CHG_RECHARGE_RES, 420 + BD71815_INT_CHG_RECHARGE_DET, 421 + BD71815_INT_CHG_RANGED_TEMP_TRANSITION, 422 + BD71815_INT_CHG_STATE_TRANSITION, 423 + /* Battery INT_STAT_06 */ 424 + BD71815_INT_BAT_TEMP_NORMAL, 425 + BD71815_INT_BAT_TEMP_ERANGE, 426 + BD71815_INT_BAT_REMOVED, 427 + BD71815_INT_BAT_DETECTED, 428 + BD71815_INT_THERM_REMOVED, 429 + BD71815_INT_THERM_DETECTED, 430 + /* Battery Mon 1 INT_STAT_07 */ 431 + BD71815_INT_BAT_DEAD, 432 + BD71815_INT_BAT_SHORTC_RES, 433 + BD71815_INT_BAT_SHORTC_DET, 434 + BD71815_INT_BAT_LOW_VOLT_RES, 435 + BD71815_INT_BAT_LOW_VOLT_DET, 436 + BD71815_INT_BAT_OVER_VOLT_RES, 437 + BD71815_INT_BAT_OVER_VOLT_DET, 438 + /* Battery Mon 2 INT_STAT_08 */ 439 + BD71815_INT_BAT_MON_RES, 440 + BD71815_INT_BAT_MON_DET, 441 + /* Battery Mon 3 (Coulomb counter) INT_STAT_09 */ 442 + BD71815_INT_BAT_CC_MON1, 443 + BD71815_INT_BAT_CC_MON2, 444 + BD71815_INT_BAT_CC_MON3, 445 + /* Battery Mon 4 INT_STAT_10 */ 446 + BD71815_INT_BAT_OVER_CURR_1_RES, 447 + BD71815_INT_BAT_OVER_CURR_1_DET, 448 + BD71815_INT_BAT_OVER_CURR_2_RES, 449 + BD71815_INT_BAT_OVER_CURR_2_DET, 450 + BD71815_INT_BAT_OVER_CURR_3_RES, 451 + BD71815_INT_BAT_OVER_CURR_3_DET, 452 + /* Temperature INT_STAT_11 */ 453 + BD71815_INT_TEMP_BAT_LOW_RES, 454 + BD71815_INT_TEMP_BAT_LOW_DET, 455 + BD71815_INT_TEMP_BAT_HI_RES, 456 + BD71815_INT_TEMP_BAT_HI_DET, 457 + BD71815_INT_TEMP_CHIP_OVER_125_RES, 458 + BD71815_INT_TEMP_CHIP_OVER_125_DET, 459 + BD71815_INT_TEMP_CHIP_OVER_VF_RES, 460 + BD71815_INT_TEMP_CHIP_OVER_VF_DET, 461 + /* RTC Alarm INT_STAT_12 */ 462 + BD71815_INT_RTC0, 463 + BD71815_INT_RTC1, 464 + BD71815_INT_RTC2, 465 + }; 466 + 467 + #define BD71815_INT_BUCK1_OCP_MASK BIT(0) 468 + #define BD71815_INT_BUCK2_OCP_MASK BIT(1) 469 + #define BD71815_INT_BUCK3_OCP_MASK BIT(2) 470 + #define BD71815_INT_BUCK4_OCP_MASK BIT(3) 471 + #define BD71815_INT_BUCK5_OCP_MASK BIT(4) 472 + #define BD71815_INT_LED_OVP_MASK BIT(5) 473 + #define BD71815_INT_LED_OCP_MASK BIT(6) 474 + #define BD71815_INT_LED_SCP_MASK BIT(7) 475 + 476 + #define BD71815_INT_DCIN_RMV_MASK BIT(1) 477 + #define BD71815_INT_CLPS_OUT_MASK BIT(2) 478 + #define BD71815_INT_CLPS_IN_MASK BIT(3) 479 + #define BD71815_INT_DCIN_OVP_RES_MASK BIT(4) 480 + #define BD71815_INT_DCIN_OVP_DET_MASK BIT(5) 481 + 482 + #define BD71815_INT_DCIN_MON_RES_MASK BIT(0) 483 + #define BD71815_INT_DCIN_MON_DET_MASK BIT(1) 484 + #define BD71815_INT_WDOG_MASK BIT(6) 485 + 486 + #define BD71815_INT_VSYS_UV_RES_MASK BIT(0) 487 + #define BD71815_INT_VSYS_UV_DET_MASK BIT(1) 488 + #define BD71815_INT_VSYS_LOW_RES_MASK BIT(2) 489 + #define BD71815_INT_VSYS_LOW_DET_MASK BIT(3) 490 + #define BD71815_INT_VSYS_MON_RES_MASK BIT(6) 491 + #define BD71815_INT_VSYS_MON_DET_MASK BIT(7) 492 + 493 + #define BD71815_INT_CHG_WDG_TEMP_MASK BIT(2) 494 + #define BD71815_INT_CHG_WDG_TIME_MASK BIT(3) 495 + #define BD71815_INT_CHG_RECHARGE_RES_MASK BIT(4) 496 + #define BD71815_INT_CHG_RECHARGE_DET_MASK BIT(5) 497 + #define BD71815_INT_CHG_RANGED_TEMP_TRANSITION_MASK BIT(6) 498 + #define BD71815_INT_CHG_STATE_TRANSITION_MASK BIT(7) 499 + 500 + #define BD71815_INT_BAT_TEMP_NORMAL_MASK BIT(0) 501 + #define BD71815_INT_BAT_TEMP_ERANGE_MASK BIT(1) 502 + #define BD71815_INT_BAT_REMOVED_MASK BIT(4) 503 + #define BD71815_INT_BAT_DETECTED_MASK BIT(5) 504 + #define BD71815_INT_THERM_REMOVED_MASK BIT(6) 505 + #define BD71815_INT_THERM_DETECTED_MASK BIT(7) 506 + 507 + #define BD71815_INT_BAT_DEAD_MASK BIT(1) 508 + #define BD71815_INT_BAT_SHORTC_RES_MASK BIT(2) 509 + #define BD71815_INT_BAT_SHORTC_DET_MASK BIT(3) 510 + #define BD71815_INT_BAT_LOW_VOLT_RES_MASK BIT(4) 511 + #define BD71815_INT_BAT_LOW_VOLT_DET_MASK BIT(5) 512 + #define BD71815_INT_BAT_OVER_VOLT_RES_MASK BIT(6) 513 + #define BD71815_INT_BAT_OVER_VOLT_DET_MASK BIT(7) 514 + 515 + #define BD71815_INT_BAT_MON_RES_MASK BIT(0) 516 + #define BD71815_INT_BAT_MON_DET_MASK BIT(1) 517 + 518 + #define BD71815_INT_BAT_CC_MON1_MASK BIT(0) 519 + #define BD71815_INT_BAT_CC_MON2_MASK BIT(1) 520 + #define BD71815_INT_BAT_CC_MON3_MASK BIT(2) 521 + 522 + #define BD71815_INT_BAT_OVER_CURR_1_RES_MASK BIT(0) 523 + #define BD71815_INT_BAT_OVER_CURR_1_DET_MASK BIT(1) 524 + #define BD71815_INT_BAT_OVER_CURR_2_RES_MASK BIT(2) 525 + #define BD71815_INT_BAT_OVER_CURR_2_DET_MASK BIT(3) 526 + #define BD71815_INT_BAT_OVER_CURR_3_RES_MASK BIT(4) 527 + #define BD71815_INT_BAT_OVER_CURR_3_DET_MASK BIT(5) 528 + 529 + #define BD71815_INT_TEMP_BAT_LOW_RES_MASK BIT(0) 530 + #define BD71815_INT_TEMP_BAT_LOW_DET_MASK BIT(1) 531 + #define BD71815_INT_TEMP_BAT_HI_RES_MASK BIT(2) 532 + #define BD71815_INT_TEMP_BAT_HI_DET_MASK BIT(3) 533 + #define BD71815_INT_TEMP_CHIP_OVER_125_RES_MASK BIT(4) 534 + #define BD71815_INT_TEMP_CHIP_OVER_125_DET_MASK BIT(5) 535 + #define BD71815_INT_TEMP_CHIP_OVER_VF_RES_MASK BIT(6) 536 + #define BD71815_INT_TEMP_CHIP_OVER_VF_DET_MASK BIT(7) 537 + 538 + #define BD71815_INT_RTC0_MASK BIT(0) 539 + #define BD71815_INT_RTC1_MASK BIT(1) 540 + #define BD71815_INT_RTC2_MASK BIT(2) 541 + 542 + /* BD71815_REG_CC_CTRL bits */ 543 + #define CCNTRST 0x80 544 + #define CCNTENB 0x40 545 + #define CCCALIB 0x20 546 + 547 + /* BD71815_REG_CC_CURCD */ 548 + #define CURDIR_Discharging 0x8000 549 + 550 + /* BD71815_REG_VM_SA_IBAT */ 551 + #define IBAT_SA_DIR_Discharging 0x8000 552 + 553 + /* BD71815_REG_REX_CTRL_1 bits */ 554 + #define REX_CLR BIT(4) 555 + 556 + /* BD71815_REG_REX_CTRL_1 bits */ 557 + #define REX_PMU_STATE_MASK BIT(2) 558 + 559 + /* BD71815_REG_LED_CTRL bits */ 560 + #define CHGDONE_LED_EN BIT(4) 561 + 562 + #endif /* __LINUX_MFD_BD71815_H */
+3
include/linux/mfd/rohm-bd71828.h
··· 151 151 #define BD71828_REG_GPIO_CTRL3 0x49 152 152 #define BD71828_REG_IO_STAT 0xed 153 153 154 + /* clk */ 155 + #define BD71828_REG_OUT32K 0x4b 156 + 154 157 /* RTC */ 155 158 #define BD71828_REG_RTC_SEC 0x4c 156 159 #define BD71828_REG_RTC_MINUTE 0x4d