14 #include <linux/device.h>
16 #include <linux/input.h>
20 #include <linux/slab.h>
21 #include <linux/module.h>
27 #define DA9052_NUM_IRQ_REGS 4
28 #define DA9052_IRQ_MASK_POS_1 0x01
29 #define DA9052_IRQ_MASK_POS_2 0x02
30 #define DA9052_IRQ_MASK_POS_3 0x04
31 #define DA9052_IRQ_MASK_POS_4 0x08
32 #define DA9052_IRQ_MASK_POS_5 0x10
33 #define DA9052_IRQ_MASK_POS_6 0x20
34 #define DA9052_IRQ_MASK_POS_7 0x40
35 #define DA9052_IRQ_MASK_POS_8 0x80
37 static bool da9052_reg_readable(
struct device *
dev,
unsigned int reg)
170 static bool da9052_reg_writeable(
struct device *
dev,
unsigned int reg)
282 static bool da9052_reg_volatile(
struct device *dev,
unsigned int reg)
332 static const int32_t tbat_lookup[255] = {
333 183258, 144221, 124334, 111336, 101826, 94397, 88343, 83257,
334 78889, 75071, 71688, 68656, 65914, 63414, 61120, 59001,
335 570366, 55204, 53490, 51881, 50364, 48931, 47574, 46285,
336 45059, 43889, 42772, 41703, 40678, 39694, 38748, 37838,
337 36961, 36115, 35297, 34507, 33743, 33002, 32284, 31588,
338 30911, 30254, 29615, 28994, 28389, 27799, 27225, 26664,
339 26117, 25584, 25062, 24553, 24054, 23567, 23091, 22624,
340 22167, 21719, 21281, 20851, 20429, 20015, 19610, 19211,
341 18820, 18436, 18058, 17688, 17323, 16965, 16612, 16266,
342 15925, 15589, 15259, 14933, 14613, 14298, 13987, 13681,
343 13379, 13082, 12788, 12499, 12214, 11933, 11655, 11382,
344 11112, 10845, 10582, 10322, 10066, 9812, 9562, 9315,
345 9071, 8830, 8591, 8356, 8123, 7893, 7665, 7440,
346 7218, 6998, 6780, 6565, 6352, 6141, 5933, 5726,
347 5522, 5320, 5120, 4922, 4726, 4532, 4340, 4149,
348 3961, 3774, 3589, 3406, 3225, 3045, 2867, 2690,
349 2516, 2342, 2170, 2000, 1831, 1664, 1498, 1334,
350 1171, 1009, 849, 690, 532, 376, 221, 67,
351 -84, -236, -386, -535, -683, -830, -975, -1119,
352 -1263, -1405, -1546, -1686, -1825, -1964, -2101, -2237,
353 -2372, -2506, -2639, -2771, -2902, -3033, -3162, -3291,
354 -3418, -3545, -3671, -3796, -3920, -4044, -4166, -4288,
355 -4409, -4529, -4649, -4767, -4885, -5002, -5119, -5235,
356 -5349, -5464, -5577, -5690, -5802, -5913, -6024, -6134,
357 -6244, -6352, -6461, -6568, -6675, -6781, -6887, -6992,
358 -7096, -7200, -7303, -7406, -7508, -7609, -7710, -7810,
359 -7910, -8009, -8108, -8206, -8304, -8401, -8497, -8593,
360 -8689, -8784, -8878, -8972, -9066, -9159, -9251, -9343,
361 -9435, -9526, -9617, -9707, -9796, -9886, -9975, -10063,
362 -10151, -10238, -10325, -10412, -10839, -10923, -11007, -11090,
363 -11173, -11256, -11338, -11420, -11501, -11583, -11663, -11744,
364 -11823, -11903, -11982
381 unsigned short calc_data;
383 unsigned char mux_sel;
401 "timeout waiting for ADC conversion interrupt\n");
410 calc_data = (
unsigned short)ret;
411 data = calc_data << 2;
446 return tbat_lookup[tbat - 1];
450 static struct resource da9052_rtc_resource = {
457 static struct resource da9052_onkey_resource = {
464 static struct resource da9052_bat_resources[] = {
503 static struct resource da9052_tsi_resources[] = {
520 .name =
"da9052-regulator",
524 .name =
"da9052-regulator",
528 .name =
"da9052-regulator",
532 .name =
"da9052-regulator",
536 .name =
"da9052-regulator",
540 .name =
"da9052-regulator",
544 .name =
"da9052-regulator",
548 .name =
"da9052-regulator",
552 .name =
"da9052-regulator",
556 .name =
"da9052-regulator",
560 .name =
"da9052-regulator",
564 .name =
"da9052-regulator",
568 .name =
"da9052-regulator",
572 .name =
"da9052-regulator",
576 .name =
"da9052-onkey",
577 .resources = &da9052_onkey_resource,
581 .
name =
"da9052-rtc",
582 .resources = &da9052_rtc_resource,
586 .
name =
"da9052-gpio",
589 .name =
"da9052-hwmon",
592 .name =
"da9052-leds",
595 .name =
"da9052-wled1",
598 .name =
"da9052-wled2",
601 .name =
"da9052-wled3",
604 .name =
"da9052-tsi",
605 .resources = da9052_tsi_resources,
606 .num_resources =
ARRAY_SIZE(da9052_tsi_resources),
609 .name =
"da9052-bat",
610 .resources = da9052_bat_resources,
611 .num_resources =
ARRAY_SIZE(da9052_bat_resources),
614 .name =
"da9052-watchdog",
618 static struct regmap_irq da9052_irqs[] = {
749 static struct regmap_irq_chip da9052_regmap_irq_chip = {
750 .name =
"da9052_irq",
766 .readable_reg = da9052_reg_readable,
767 .writeable_reg = da9052_reg_writeable,
768 .volatile_reg = da9052_reg_volatile,
778 init_completion(&da9052->
done);
792 da9052->
irq_base, &da9052_regmap_irq_chip,
803 dev_err(da9052->
dev,
"DA9052 ADC IRQ failed ret=%d\n", ret);