Lines Matching +full:chg +full:- +full:int
1 // SPDX-License-Identifier: GPL-2.0-only
14 #include <linux/mfd/rohm-bd71815.h>
15 #include <linux/mfd/rohm-bd71828.h>
16 #include <linux/mfd/rohm-generic.h>
24 .gpio = -1,
31 .name = "bd71828-pwrkey",
35 DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC0, "bd71815-rtc-alm-0"),
36 DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC1, "bd71815-rtc-alm-1"),
37 DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC2, "bd71815-rtc-alm-2"),
41 DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC0, "bd71828-rtc-alm-0"),
42 DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC1, "bd71828-rtc-alm-1"),
43 DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC2, "bd71828-rtc-alm-2"),
47 DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_RMV, "bd71815-dcin-rmv"),
48 DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_OUT, "bd71815-clps-out"),
49 DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_IN, "bd71815-clps-in"),
50 DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_OVP_RES, "bd71815-dcin-ovp-res"),
51 DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_OVP_DET, "bd71815-dcin-ovp-det"),
52 DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_MON_RES, "bd71815-dcin-mon-res"),
53 DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_MON_DET, "bd71815-dcin-mon-det"),
54 DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_UV_RES, "bd71815-vsys-uv-res"),
55 DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_UV_DET, "bd71815-vsys-uv-det"),
56 DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_LOW_RES, "bd71815-vsys-low-res"),
57 DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_LOW_DET, "bd71815-vsys-low-det"),
58 DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_MON_RES, "bd71815-vsys-mon-res"),
59 DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_MON_RES, "bd71815-vsys-mon-det"),
60 DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_WDG_TEMP, "bd71815-chg-wdg-temp"),
61 DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_WDG_TIME, "bd71815-chg-wdg"),
62 DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_RECHARGE_RES, "bd71815-rechg-res"),
63 DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_RECHARGE_DET, "bd71815-rechg-det"),
64 DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_RANGED_TEMP_TRANSITION, "bd71815-ranged-temp-transit"),
65 DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_STATE_TRANSITION, "bd71815-chg-state-change"),
66 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_TEMP_NORMAL, "bd71815-bat-temp-normal"),
67 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_TEMP_ERANGE, "bd71815-bat-temp-erange"),
68 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_REMOVED, "bd71815-bat-rmv"),
69 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_DETECTED, "bd71815-bat-det"),
70 DEFINE_RES_IRQ_NAMED(BD71815_INT_THERM_REMOVED, "bd71815-therm-rmv"),
71 DEFINE_RES_IRQ_NAMED(BD71815_INT_THERM_DETECTED, "bd71815-therm-det"),
72 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_DEAD, "bd71815-bat-dead"),
73 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_SHORTC_RES, "bd71815-bat-short-res"),
74 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_SHORTC_DET, "bd71815-bat-short-det"),
75 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_LOW_VOLT_RES, "bd71815-bat-low-res"),
76 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_LOW_VOLT_DET, "bd71815-bat-low-det"),
77 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_VOLT_RES, "bd71815-bat-over-res"),
78 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_VOLT_DET, "bd71815-bat-over-det"),
79 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_MON_RES, "bd71815-bat-mon-res"),
80 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_MON_DET, "bd71815-bat-mon-det"),
81 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_CC_MON1, "bd71815-bat-cc-mon1"),
82 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_CC_MON2, "bd71815-bat-cc-mon2"),
83 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_CC_MON3, "bd71815-bat-cc-mon3"),
84 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_1_RES, "bd71815-bat-oc1-res"),
85 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_1_DET, "bd71815-bat-oc1-det"),
86 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_2_RES, "bd71815-bat-oc2-res"),
87 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_2_DET, "bd71815-bat-oc2-det"),
88 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_3_RES, "bd71815-bat-oc3-res"),
89 DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_3_DET, "bd71815-bat-oc3-det"),
90 DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_LOW_RES, "bd71815-bat-low-res"),
91 DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_LOW_DET, "bd71815-bat-low-det"),
92 DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_HI_RES, "bd71815-bat-hi-res"),
93 DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_HI_DET, "bd71815-bat-hi-det"),
97 { .name = "bd71815-pmic", },
98 { .name = "bd71815-clk", },
99 { .name = "bd71815-gpo", },
101 .name = "bd71815-power",
106 .name = "bd71815-rtc",
113 { .name = "bd71828-pmic", },
114 { .name = "bd71828-gpio", },
115 { .name = "bd71828-led", .of_compatible = "rohm,bd71828-leds" },
120 { .name = "bd71828-clk", },
121 { .name = "bd71827-power", },
123 .name = "bd71828-rtc",
127 .name = "gpio-keys",
199 .max_register = BD71815_MAX_REGISTER - 1,
212 * Mapping of main IRQ register bits to sub-IRQ register offsets so that we can
213 * access corect sub-IRQ registers based on bits that are set in main IRQ
214 * register. BD71815 and BD71828 have same sub-register-block offests.
217 static unsigned int bit0_offsets[] = {11}; /* RTC IRQ */
218 static unsigned int bit1_offsets[] = {10}; /* TEMP IRQ */
219 static unsigned int bit2_offsets[] = {6, 7, 8, 9}; /* BAT MON IRQ */
220 static unsigned int bit3_offsets[] = {5}; /* BAT IRQ */
221 static unsigned int bit4_offsets[] = {4}; /* CHG IRQ */
222 static unsigned int bit5_offsets[] = {3}; /* VSYS IRQ */
223 static unsigned int bit6_offsets[] = {1, 2}; /* DCIN IRQ */
224 static unsigned int bit7_offsets[] = {0}; /* BUCK IRQ */
442 static int set_clk_mode(struct device *dev, struct regmap *regmap, in set_clk_mode()
443 int clkmode_reg) in set_clk_mode()
445 int ret; in set_clk_mode()
446 unsigned int open_drain; in set_clk_mode()
448 ret = of_property_read_u32(dev->of_node, "rohm,clkout-open-drain", &open_drain); in set_clk_mode()
450 if (ret == -EINVAL) in set_clk_mode()
456 return -EINVAL; in set_clk_mode()
488 static int bd71828_i2c_probe(struct i2c_client *i2c) in bd71828_i2c_probe()
491 int ret; in bd71828_i2c_probe()
495 unsigned int chip_type; in bd71828_i2c_probe()
497 int cells; in bd71828_i2c_probe()
498 int button_irq; in bd71828_i2c_probe()
499 int clkmode_reg; in bd71828_i2c_probe()
501 if (!i2c->irq) { in bd71828_i2c_probe()
502 dev_err(&i2c->dev, "No IRQ configured\n"); in bd71828_i2c_probe()
503 return -EINVAL; in bd71828_i2c_probe()
506 chip_type = (unsigned int)(uintptr_t) in bd71828_i2c_probe()
507 of_device_get_match_data(&i2c->dev); in bd71828_i2c_probe()
525 * with proper DT configs + BD71815 drivers + power-button. in bd71828_i2c_probe()
526 * BD71815 data-sheet does not list the power-button IRQ so we in bd71828_i2c_probe()
532 dev_err(&i2c->dev, "Unknown device type"); in bd71828_i2c_probe()
533 return -EINVAL; in bd71828_i2c_probe()
538 return dev_err_probe(&i2c->dev, PTR_ERR(regmap), in bd71828_i2c_probe()
541 ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq, in bd71828_i2c_probe()
544 return dev_err_probe(&i2c->dev, ret, in bd71828_i2c_probe()
547 dev_dbg(&i2c->dev, "Registered %d IRQs for chip\n", in bd71828_i2c_probe()
548 irqchip->num_irqs); in bd71828_i2c_probe()
553 return dev_err_probe(&i2c->dev, ret, in bd71828_i2c_probe()
554 "Failed to get the power-key IRQ\n"); in bd71828_i2c_probe()
559 ret = set_clk_mode(&i2c->dev, regmap, clkmode_reg); in bd71828_i2c_probe()
563 ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, mfd, cells, in bd71828_i2c_probe()
566 return dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n"); in bd71828_i2c_probe()
568 if (of_device_is_system_power_controller(i2c->dev.of_node) && in bd71828_i2c_probe()
573 ret = devm_add_action_or_reset(&i2c->dev, in bd71828_i2c_probe()
577 dev_warn(&i2c->dev, "Poweroff callback already assigned\n"); in bd71828_i2c_probe()
598 .name = "rohm-bd71828",