11802d0beSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
237b918a0STim Harvey /*
337b918a0STim Harvey * Copyright (C) 2016 Gateworks Corporation, Inc. All Rights Reserved.
437b918a0STim Harvey */
537b918a0STim Harvey #include <linux/i2c.h>
637b918a0STim Harvey #include <linux/init.h>
737b918a0STim Harvey #include <linux/interrupt.h>
837b918a0STim Harvey #include <linux/module.h>
937b918a0STim Harvey #include <linux/kernel.h>
1037b918a0STim Harvey #include <linux/of.h>
1137b918a0STim Harvey #include <linux/regmap.h>
1237b918a0STim Harvey #include <linux/regulator/driver.h>
1337b918a0STim Harvey #include <linux/regulator/machine.h>
1437b918a0STim Harvey #include <linux/regulator/of_regulator.h>
1537b918a0STim Harvey
1637b918a0STim Harvey #define DRIVER_NAME "ltc3676"
1737b918a0STim Harvey
1837b918a0STim Harvey /* LTC3676 Registers */
1937b918a0STim Harvey #define LTC3676_BUCK1 0x01
2037b918a0STim Harvey #define LTC3676_BUCK2 0x02
2137b918a0STim Harvey #define LTC3676_BUCK3 0x03
2237b918a0STim Harvey #define LTC3676_BUCK4 0x04
2337b918a0STim Harvey #define LTC3676_LDOA 0x05
2437b918a0STim Harvey #define LTC3676_LDOB 0x06
2537b918a0STim Harvey #define LTC3676_SQD1 0x07
2637b918a0STim Harvey #define LTC3676_SQD2 0x08
2737b918a0STim Harvey #define LTC3676_CNTRL 0x09
2837b918a0STim Harvey #define LTC3676_DVB1A 0x0A
2937b918a0STim Harvey #define LTC3676_DVB1B 0x0B
3037b918a0STim Harvey #define LTC3676_DVB2A 0x0C
3137b918a0STim Harvey #define LTC3676_DVB2B 0x0D
3237b918a0STim Harvey #define LTC3676_DVB3A 0x0E
3337b918a0STim Harvey #define LTC3676_DVB3B 0x0F
3437b918a0STim Harvey #define LTC3676_DVB4A 0x10
3537b918a0STim Harvey #define LTC3676_DVB4B 0x11
3637b918a0STim Harvey #define LTC3676_MSKIRQ 0x12
3737b918a0STim Harvey #define LTC3676_MSKPG 0x13
3837b918a0STim Harvey #define LTC3676_USER 0x14
3937b918a0STim Harvey #define LTC3676_IRQSTAT 0x15
4037b918a0STim Harvey #define LTC3676_PGSTATL 0x16
4137b918a0STim Harvey #define LTC3676_PGSTATRT 0x17
4237b918a0STim Harvey #define LTC3676_HRST 0x1E
4337b918a0STim Harvey #define LTC3676_CLIRQ 0x1F
4437b918a0STim Harvey
4537b918a0STim Harvey #define LTC3676_DVBxA_REF_SELECT BIT(5)
46d2a66ddfSMarek Vasut #define LTC3676_DVBxB_PGOOD_MASK BIT(5)
4737b918a0STim Harvey
4837b918a0STim Harvey #define LTC3676_IRQSTAT_PGOOD_TIMEOUT BIT(3)
4937b918a0STim Harvey #define LTC3676_IRQSTAT_UNDERVOLT_WARN BIT(4)
5037b918a0STim Harvey #define LTC3676_IRQSTAT_UNDERVOLT_FAULT BIT(5)
5137b918a0STim Harvey #define LTC3676_IRQSTAT_THERMAL_WARN BIT(6)
5237b918a0STim Harvey #define LTC3676_IRQSTAT_THERMAL_FAULT BIT(7)
5337b918a0STim Harvey
5437b918a0STim Harvey enum ltc3676_reg {
5537b918a0STim Harvey LTC3676_SW1,
5637b918a0STim Harvey LTC3676_SW2,
5737b918a0STim Harvey LTC3676_SW3,
5837b918a0STim Harvey LTC3676_SW4,
5937b918a0STim Harvey LTC3676_LDO1,
6037b918a0STim Harvey LTC3676_LDO2,
6137b918a0STim Harvey LTC3676_LDO3,
6237b918a0STim Harvey LTC3676_LDO4,
6337b918a0STim Harvey LTC3676_NUM_REGULATORS,
6437b918a0STim Harvey };
6537b918a0STim Harvey
6637b918a0STim Harvey struct ltc3676 {
6737b918a0STim Harvey struct regmap *regmap;
6837b918a0STim Harvey struct device *dev;
6937b918a0STim Harvey struct regulator_desc regulator_descs[LTC3676_NUM_REGULATORS];
7037b918a0STim Harvey struct regulator_dev *regulators[LTC3676_NUM_REGULATORS];
7137b918a0STim Harvey };
7237b918a0STim Harvey
ltc3676_set_suspend_voltage(struct regulator_dev * rdev,int uV)7337b918a0STim Harvey static int ltc3676_set_suspend_voltage(struct regulator_dev *rdev, int uV)
7437b918a0STim Harvey {
7537b918a0STim Harvey struct ltc3676 *ltc3676 = rdev_get_drvdata(rdev);
7637b918a0STim Harvey struct device *dev = ltc3676->dev;
7737b918a0STim Harvey int dcdc = rdev_get_id(rdev);
7837b918a0STim Harvey int sel;
7937b918a0STim Harvey
8037b918a0STim Harvey dev_dbg(dev, "%s id=%d uV=%d\n", __func__, dcdc, uV);
8137b918a0STim Harvey sel = regulator_map_voltage_linear(rdev, uV, uV);
8237b918a0STim Harvey if (sel < 0)
8337b918a0STim Harvey return sel;
8437b918a0STim Harvey
8537b918a0STim Harvey /* DVBB register follows right after the corresponding DVBA register */
8637b918a0STim Harvey return regmap_update_bits(ltc3676->regmap, rdev->desc->vsel_reg + 1,
8737b918a0STim Harvey rdev->desc->vsel_mask, sel);
8837b918a0STim Harvey }
8937b918a0STim Harvey
ltc3676_set_suspend_mode(struct regulator_dev * rdev,unsigned int mode)9037b918a0STim Harvey static int ltc3676_set_suspend_mode(struct regulator_dev *rdev,
9137b918a0STim Harvey unsigned int mode)
9237b918a0STim Harvey {
9337b918a0STim Harvey struct ltc3676 *ltc3676= rdev_get_drvdata(rdev);
9437b918a0STim Harvey struct device *dev = ltc3676->dev;
9537b918a0STim Harvey int mask, val;
9637b918a0STim Harvey int dcdc = rdev_get_id(rdev);
9737b918a0STim Harvey
9837b918a0STim Harvey dev_dbg(dev, "%s id=%d mode=%d\n", __func__, dcdc, mode);
9937b918a0STim Harvey
10037b918a0STim Harvey mask = LTC3676_DVBxA_REF_SELECT;
10137b918a0STim Harvey switch (mode) {
10237b918a0STim Harvey case REGULATOR_MODE_STANDBY:
10337b918a0STim Harvey val = 0; /* select DVBxA */
10437b918a0STim Harvey break;
10537b918a0STim Harvey case REGULATOR_MODE_NORMAL:
10637b918a0STim Harvey val = LTC3676_DVBxA_REF_SELECT; /* select DVBxB */
10737b918a0STim Harvey break;
10837b918a0STim Harvey default:
10937b918a0STim Harvey dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n",
11037b918a0STim Harvey rdev->desc->name, mode);
11137b918a0STim Harvey return -EINVAL;
11237b918a0STim Harvey }
11337b918a0STim Harvey
11437b918a0STim Harvey return regmap_update_bits(ltc3676->regmap, rdev->desc->vsel_reg,
11537b918a0STim Harvey mask, val);
11637b918a0STim Harvey }
11737b918a0STim Harvey
ltc3676_set_voltage_sel(struct regulator_dev * rdev,unsigned selector)118d2a66ddfSMarek Vasut static int ltc3676_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
119d2a66ddfSMarek Vasut {
120d2a66ddfSMarek Vasut struct ltc3676 *ltc3676 = rdev_get_drvdata(rdev);
121d2a66ddfSMarek Vasut struct device *dev = ltc3676->dev;
122d2a66ddfSMarek Vasut int ret, dcdc = rdev_get_id(rdev);
123d2a66ddfSMarek Vasut
124d2a66ddfSMarek Vasut dev_dbg(dev, "%s id=%d selector=%d\n", __func__, dcdc, selector);
125d2a66ddfSMarek Vasut
126d2a66ddfSMarek Vasut ret = regmap_update_bits(ltc3676->regmap, rdev->desc->vsel_reg + 1,
127d2a66ddfSMarek Vasut LTC3676_DVBxB_PGOOD_MASK,
128d2a66ddfSMarek Vasut LTC3676_DVBxB_PGOOD_MASK);
129d2a66ddfSMarek Vasut if (ret)
130d2a66ddfSMarek Vasut return ret;
131d2a66ddfSMarek Vasut
132d2a66ddfSMarek Vasut return regulator_set_voltage_sel_regmap(rdev, selector);
133d2a66ddfSMarek Vasut }
134d2a66ddfSMarek Vasut
ltc3676_scale(unsigned int uV,u32 r1,u32 r2)13537b918a0STim Harvey static inline unsigned int ltc3676_scale(unsigned int uV, u32 r1, u32 r2)
13637b918a0STim Harvey {
13737b918a0STim Harvey uint64_t tmp;
13837b918a0STim Harvey if (uV == 0)
13937b918a0STim Harvey return 0;
14037b918a0STim Harvey tmp = (uint64_t)uV * r1;
14137b918a0STim Harvey do_div(tmp, r2);
14237b918a0STim Harvey return uV + (unsigned int)tmp;
14337b918a0STim Harvey }
14437b918a0STim Harvey
ltc3676_of_parse_cb(struct device_node * np,const struct regulator_desc * desc,struct regulator_config * config)14537b918a0STim Harvey static int ltc3676_of_parse_cb(struct device_node *np,
14637b918a0STim Harvey const struct regulator_desc *desc,
14737b918a0STim Harvey struct regulator_config *config)
14837b918a0STim Harvey {
14937b918a0STim Harvey struct ltc3676 *ltc3676 = config->driver_data;
15037b918a0STim Harvey struct regulator_desc *rdesc = <c3676->regulator_descs[desc->id];
15137b918a0STim Harvey u32 r[2];
15237b918a0STim Harvey int ret;
15337b918a0STim Harvey
15437b918a0STim Harvey /* LDO3 has a fixed output */
15537b918a0STim Harvey if (desc->id == LTC3676_LDO3)
15637b918a0STim Harvey return 0;
15737b918a0STim Harvey
15837b918a0STim Harvey ret = of_property_read_u32_array(np, "lltc,fb-voltage-divider", r, 2);
15937b918a0STim Harvey if (ret) {
16037b918a0STim Harvey dev_err(ltc3676->dev, "Failed to parse voltage divider: %d\n",
16137b918a0STim Harvey ret);
16237b918a0STim Harvey return ret;
16337b918a0STim Harvey }
16437b918a0STim Harvey
16537b918a0STim Harvey rdesc->min_uV = ltc3676_scale(desc->min_uV, r[0], r[1]);
16637b918a0STim Harvey rdesc->uV_step = ltc3676_scale(desc->uV_step, r[0], r[1]);
16737b918a0STim Harvey rdesc->fixed_uV = ltc3676_scale(desc->fixed_uV, r[0], r[1]);
16837b918a0STim Harvey
16937b918a0STim Harvey return 0;
17037b918a0STim Harvey }
17137b918a0STim Harvey
17237b918a0STim Harvey /* SW1, SW2, SW3, SW4 linear 0.8V-3.3V with scalar via R1/R2 feeback res */
173f9e93accSBhumika Goyal static const struct regulator_ops ltc3676_linear_regulator_ops = {
17437b918a0STim Harvey .enable = regulator_enable_regmap,
17537b918a0STim Harvey .disable = regulator_disable_regmap,
17637b918a0STim Harvey .is_enabled = regulator_is_enabled_regmap,
17737b918a0STim Harvey .list_voltage = regulator_list_voltage_linear,
178d2a66ddfSMarek Vasut .set_voltage_sel = ltc3676_set_voltage_sel,
17937b918a0STim Harvey .get_voltage_sel = regulator_get_voltage_sel_regmap,
18037b918a0STim Harvey .set_suspend_voltage = ltc3676_set_suspend_voltage,
18137b918a0STim Harvey .set_suspend_mode = ltc3676_set_suspend_mode,
18237b918a0STim Harvey };
18337b918a0STim Harvey
18437b918a0STim Harvey /* LDO1 always on fixed 0.8V-3.3V via scalar via R1/R2 feeback res */
185f9e93accSBhumika Goyal static const struct regulator_ops ltc3676_fixed_standby_regulator_ops = {
18637b918a0STim Harvey };
18737b918a0STim Harvey
18837b918a0STim Harvey /* LDO2, LDO3 fixed (LDO2 has external scalar via R1/R2 feedback res) */
189f9e93accSBhumika Goyal static const struct regulator_ops ltc3676_fixed_regulator_ops = {
19037b918a0STim Harvey .enable = regulator_enable_regmap,
19137b918a0STim Harvey .disable = regulator_disable_regmap,
19237b918a0STim Harvey .is_enabled = regulator_is_enabled_regmap,
19337b918a0STim Harvey };
19437b918a0STim Harvey
19537b918a0STim Harvey #define LTC3676_REG(_id, _name, _ops, en_reg, en_bit, dvba_reg, dvb_mask) \
19637b918a0STim Harvey [LTC3676_ ## _id] = { \
19737b918a0STim Harvey .name = #_name, \
19837b918a0STim Harvey .of_match = of_match_ptr(#_name), \
19937b918a0STim Harvey .regulators_node = of_match_ptr("regulators"), \
20037b918a0STim Harvey .of_parse_cb = ltc3676_of_parse_cb, \
20137b918a0STim Harvey .n_voltages = (dvb_mask) + 1, \
20237b918a0STim Harvey .min_uV = (dvba_reg) ? 412500 : 0, \
20337b918a0STim Harvey .uV_step = (dvba_reg) ? 12500 : 0, \
20437b918a0STim Harvey .ramp_delay = (dvba_reg) ? 800 : 0, \
20537b918a0STim Harvey .fixed_uV = (dvb_mask) ? 0 : 725000, \
20637b918a0STim Harvey .ops = <c3676_ ## _ops ## _regulator_ops, \
20737b918a0STim Harvey .type = REGULATOR_VOLTAGE, \
20837b918a0STim Harvey .id = LTC3676_ ## _id, \
20937b918a0STim Harvey .owner = THIS_MODULE, \
21037b918a0STim Harvey .vsel_reg = (dvba_reg), \
21137b918a0STim Harvey .vsel_mask = (dvb_mask), \
21237b918a0STim Harvey .enable_reg = (en_reg), \
21337b918a0STim Harvey .enable_mask = (1 << en_bit), \
21437b918a0STim Harvey }
21537b918a0STim Harvey
21637b918a0STim Harvey #define LTC3676_LINEAR_REG(_id, _name, _en, _dvba) \
21737b918a0STim Harvey LTC3676_REG(_id, _name, linear, \
21837b918a0STim Harvey LTC3676_ ## _en, 7, \
21937b918a0STim Harvey LTC3676_ ## _dvba, 0x1f)
22037b918a0STim Harvey
22137b918a0STim Harvey #define LTC3676_FIXED_REG(_id, _name, _en_reg, _en_bit) \
22237b918a0STim Harvey LTC3676_REG(_id, _name, fixed, LTC3676_ ## _en_reg, _en_bit, 0, 0)
22337b918a0STim Harvey
224b37f076dSRikard Falkeborn static const struct regulator_desc ltc3676_regulators[LTC3676_NUM_REGULATORS] = {
22537b918a0STim Harvey LTC3676_LINEAR_REG(SW1, sw1, BUCK1, DVB1A),
22637b918a0STim Harvey LTC3676_LINEAR_REG(SW2, sw2, BUCK2, DVB2A),
22737b918a0STim Harvey LTC3676_LINEAR_REG(SW3, sw3, BUCK3, DVB3A),
22837b918a0STim Harvey LTC3676_LINEAR_REG(SW4, sw4, BUCK4, DVB4A),
22937b918a0STim Harvey LTC3676_REG(LDO1, ldo1, fixed_standby, 0, 0, 0, 0),
23037b918a0STim Harvey LTC3676_FIXED_REG(LDO2, ldo2, LDOA, 2),
23137b918a0STim Harvey LTC3676_FIXED_REG(LDO3, ldo3, LDOA, 5),
23237b918a0STim Harvey LTC3676_FIXED_REG(LDO4, ldo4, LDOB, 2),
23337b918a0STim Harvey };
23437b918a0STim Harvey
ltc3676_readable_writeable_reg(struct device * dev,unsigned int reg)235502aba81SAxel Lin static bool ltc3676_readable_writeable_reg(struct device *dev, unsigned int reg)
23637b918a0STim Harvey {
23737b918a0STim Harvey switch (reg) {
238502aba81SAxel Lin case LTC3676_BUCK1 ... LTC3676_IRQSTAT:
23937b918a0STim Harvey case LTC3676_HRST:
24037b918a0STim Harvey case LTC3676_CLIRQ:
24137b918a0STim Harvey return true;
24237b918a0STim Harvey }
24337b918a0STim Harvey return false;
24437b918a0STim Harvey }
24537b918a0STim Harvey
ltc3676_volatile_reg(struct device * dev,unsigned int reg)24637b918a0STim Harvey static bool ltc3676_volatile_reg(struct device *dev, unsigned int reg)
24737b918a0STim Harvey {
24837b918a0STim Harvey switch (reg) {
249502aba81SAxel Lin case LTC3676_IRQSTAT ... LTC3676_PGSTATRT:
25037b918a0STim Harvey return true;
25137b918a0STim Harvey }
25237b918a0STim Harvey return false;
25337b918a0STim Harvey }
25437b918a0STim Harvey
25537b918a0STim Harvey static const struct regmap_config ltc3676_regmap_config = {
25637b918a0STim Harvey .reg_bits = 8,
25737b918a0STim Harvey .val_bits = 8,
258502aba81SAxel Lin .writeable_reg = ltc3676_readable_writeable_reg,
259502aba81SAxel Lin .readable_reg = ltc3676_readable_writeable_reg,
26037b918a0STim Harvey .volatile_reg = ltc3676_volatile_reg,
26137b918a0STim Harvey .max_register = LTC3676_CLIRQ,
2621c96a2f6SDavid Frey .use_single_read = true,
2631c96a2f6SDavid Frey .use_single_write = true,
26437b918a0STim Harvey .cache_type = REGCACHE_MAPLE,
26537b918a0STim Harvey };
26637b918a0STim Harvey
ltc3676_isr(int irq,void * dev_id)26737b918a0STim Harvey static irqreturn_t ltc3676_isr(int irq, void *dev_id)
26837b918a0STim Harvey {
26937b918a0STim Harvey struct ltc3676 *ltc3676 = dev_id;
27037b918a0STim Harvey struct device *dev = ltc3676->dev;
27137b918a0STim Harvey unsigned int i, irqstat, event;
27237b918a0STim Harvey
27337b918a0STim Harvey regmap_read(ltc3676->regmap, LTC3676_IRQSTAT, &irqstat);
27437b918a0STim Harvey
27537b918a0STim Harvey dev_dbg(dev, "irq%d irqstat=0x%02x\n", irq, irqstat);
27637b918a0STim Harvey if (irqstat & LTC3676_IRQSTAT_THERMAL_WARN) {
27737b918a0STim Harvey dev_warn(dev, "Over-temperature Warning\n");
27837b918a0STim Harvey event = REGULATOR_EVENT_OVER_TEMP;
279e9c142b0SMichał Mirosław for (i = 0; i < LTC3676_NUM_REGULATORS; i++)
28037b918a0STim Harvey regulator_notifier_call_chain(ltc3676->regulators[i],
28137b918a0STim Harvey event, NULL);
28237b918a0STim Harvey }
28337b918a0STim Harvey
28437b918a0STim Harvey if (irqstat & LTC3676_IRQSTAT_UNDERVOLT_WARN) {
28537b918a0STim Harvey dev_info(dev, "Undervoltage Warning\n");
28637b918a0STim Harvey event = REGULATOR_EVENT_UNDER_VOLTAGE;
287e9c142b0SMichał Mirosław for (i = 0; i < LTC3676_NUM_REGULATORS; i++)
28837b918a0STim Harvey regulator_notifier_call_chain(ltc3676->regulators[i],
28937b918a0STim Harvey event, NULL);
29037b918a0STim Harvey }
29137b918a0STim Harvey
29237b918a0STim Harvey /* Clear warning condition */
29337b918a0STim Harvey regmap_write(ltc3676->regmap, LTC3676_CLIRQ, 0);
29437b918a0STim Harvey
29537b918a0STim Harvey return IRQ_HANDLED;
29637b918a0STim Harvey }
29737b918a0STim Harvey
ltc3676_regulator_probe(struct i2c_client * client)29877e29598SAxel Lin static int ltc3676_regulator_probe(struct i2c_client *client)
29937b918a0STim Harvey {
30037b918a0STim Harvey struct device *dev = &client->dev;
30137b918a0STim Harvey struct regulator_init_data *init_data = dev_get_platdata(dev);
30237b918a0STim Harvey struct regulator_desc *descs;
30337b918a0STim Harvey struct ltc3676 *ltc3676;
30437b918a0STim Harvey int i, ret;
30537b918a0STim Harvey
30637b918a0STim Harvey ltc3676 = devm_kzalloc(dev, sizeof(*ltc3676), GFP_KERNEL);
30737b918a0STim Harvey if (!ltc3676)
30837b918a0STim Harvey return -ENOMEM;
30937b918a0STim Harvey
31037b918a0STim Harvey i2c_set_clientdata(client, ltc3676);
31137b918a0STim Harvey ltc3676->dev = dev;
31237b918a0STim Harvey
31337b918a0STim Harvey descs = ltc3676->regulator_descs;
31437b918a0STim Harvey memcpy(descs, ltc3676_regulators, sizeof(ltc3676_regulators));
31537b918a0STim Harvey descs[LTC3676_LDO3].fixed_uV = 1800000; /* LDO3 is fixed 1.8V */
31637b918a0STim Harvey
31737b918a0STim Harvey ltc3676->regmap = devm_regmap_init_i2c(client, <c3676_regmap_config);
31837b918a0STim Harvey if (IS_ERR(ltc3676->regmap)) {
31937b918a0STim Harvey ret = PTR_ERR(ltc3676->regmap);
32037b918a0STim Harvey dev_err(dev, "failed to initialize regmap: %d\n", ret);
32137b918a0STim Harvey return ret;
32237b918a0STim Harvey }
32337b918a0STim Harvey
32437b918a0STim Harvey for (i = 0; i < LTC3676_NUM_REGULATORS; i++) {
32537b918a0STim Harvey struct regulator_desc *desc = <c3676->regulator_descs[i];
32637b918a0STim Harvey struct regulator_config config = { };
32737b918a0STim Harvey
32837b918a0STim Harvey if (init_data)
32937b918a0STim Harvey config.init_data = &init_data[i];
33037b918a0STim Harvey
33137b918a0STim Harvey config.dev = dev;
33237b918a0STim Harvey config.driver_data = ltc3676;
33337b918a0STim Harvey
33437b918a0STim Harvey ltc3676->regulators[i] = devm_regulator_register(dev, desc,
33537b918a0STim Harvey &config);
33637b918a0STim Harvey if (IS_ERR(ltc3676->regulators[i])) {
33737b918a0STim Harvey ret = PTR_ERR(ltc3676->regulators[i]);
33837b918a0STim Harvey dev_err(dev, "failed to register regulator %s: %d\n",
33937b918a0STim Harvey desc->name, ret);
34037b918a0STim Harvey return ret;
34137b918a0STim Harvey }
34237b918a0STim Harvey }
34337b918a0STim Harvey
34437b918a0STim Harvey regmap_write(ltc3676->regmap, LTC3676_CLIRQ, 0);
34537b918a0STim Harvey if (client->irq) {
34637b918a0STim Harvey ret = devm_request_threaded_irq(dev, client->irq, NULL,
34737b918a0STim Harvey ltc3676_isr,
34837b918a0STim Harvey IRQF_TRIGGER_LOW | IRQF_ONESHOT,
34937b918a0STim Harvey client->name, ltc3676);
35037b918a0STim Harvey if (ret) {
35137b918a0STim Harvey dev_err(dev, "Failed to request IRQ: %d\n", ret);
35237b918a0STim Harvey return ret;
35337b918a0STim Harvey }
35437b918a0STim Harvey }
35537b918a0STim Harvey
35637b918a0STim Harvey return 0;
35737b918a0STim Harvey }
35837b918a0STim Harvey
35937b918a0STim Harvey static const struct i2c_device_id ltc3676_i2c_id[] = {
36037b918a0STim Harvey { "ltc3676" },
36137b918a0STim Harvey { }
36237b918a0STim Harvey };
36337b918a0STim Harvey MODULE_DEVICE_TABLE(i2c, ltc3676_i2c_id);
36437b918a0STim Harvey
3651d4c1e02SJisheng Zhang static const struct of_device_id __maybe_unused ltc3676_of_match[] = {
366c3143415SJavier Martinez Canillas { .compatible = "lltc,ltc3676" },
367c3143415SJavier Martinez Canillas { },
368c3143415SJavier Martinez Canillas };
369c3143415SJavier Martinez Canillas MODULE_DEVICE_TABLE(of, ltc3676_of_match);
370c3143415SJavier Martinez Canillas
37137b918a0STim Harvey static struct i2c_driver ltc3676_driver = {
37237b918a0STim Harvey .driver = {
37337b918a0STim Harvey .name = DRIVER_NAME,
374*259b93b2SDouglas Anderson .probe_type = PROBE_PREFER_ASYNCHRONOUS,
375c3143415SJavier Martinez Canillas .of_match_table = of_match_ptr(ltc3676_of_match),
37637b918a0STim Harvey },
37777e29598SAxel Lin .probe = ltc3676_regulator_probe,
37837b918a0STim Harvey .id_table = ltc3676_i2c_id,
37937b918a0STim Harvey };
38037b918a0STim Harvey module_i2c_driver(ltc3676_driver);
38137b918a0STim Harvey
38237b918a0STim Harvey MODULE_AUTHOR("Tim Harvey <tharvey@gateworks.com>");
383d422234fSAxel Lin MODULE_DESCRIPTION("Regulator driver for Linear Technology LTC3676");
38437b918a0STim Harvey MODULE_LICENSE("GPL v2");
385