Lines Matching +full:resource +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2009-2010 Marvell International Ltd.
21 static const struct resource bk_resources[] = {
28 .name = "max8925-backlight",
31 .id = -1,
35 static const struct resource touch_resources[] = {
37 .name = "max8925-tsc",
46 .name = "max8925-touch",
49 .id = -1,
53 static const struct resource power_supply_resources[] = {
55 .name = "max8925-power",
64 .name = "max8925-power",
67 .id = -1,
71 static const struct resource rtc_resources[] = {
73 .name = "max8925-rtc",
82 .name = "max8925-rtc",
85 .id = -1,
89 static const struct resource onkey_resources[] = {
91 .name = "max8925-onkey",
96 .name = "max8925-onkey",
105 .name = "max8925-onkey",
108 .id = -1,
112 static const struct resource sd1_resources[] = {
116 static const struct resource sd2_resources[] = {
120 static const struct resource sd3_resources[] = {
124 static const struct resource ldo1_resources[] = {
128 static const struct resource ldo2_resources[] = {
132 static const struct resource ldo3_resources[] = {
136 static const struct resource ldo4_resources[] = {
140 static const struct resource ldo5_resources[] = {
144 static const struct resource ldo6_resources[] = {
148 static const struct resource ldo7_resources[] = {
152 static const struct resource ldo8_resources[] = {
156 static const struct resource ldo9_resources[] = {
160 static const struct resource ldo10_resources[] = {
164 static const struct resource ldo11_resources[] = {
168 static const struct resource ldo12_resources[] = {
172 static const struct resource ldo13_resources[] = {
176 static const struct resource ldo14_resources[] = {
180 static const struct resource ldo15_resources[] = {
184 static const struct resource ldo16_resources[] = {
188 static const struct resource ldo17_resources[] = {
192 static const struct resource ldo18_resources[] = {
196 static const struct resource ldo19_resources[] = {
200 static const struct resource ldo20_resources[] = {
206 .name = "max8925-regulator",
207 .id = 0,
211 .name = "max8925-regulator",
212 .id = 1,
216 .name = "max8925-regulator",
217 .id = 2,
221 .name = "max8925-regulator",
222 .id = 3,
226 .name = "max8925-regulator",
227 .id = 4,
231 .name = "max8925-regulator",
232 .id = 5,
236 .name = "max8925-regulator",
237 .id = 6,
241 .name = "max8925-regulator",
242 .id = 7,
246 .name = "max8925-regulator",
247 .id = 8,
251 .name = "max8925-regulator",
252 .id = 9,
256 .name = "max8925-regulator",
257 .id = 10,
261 .name = "max8925-regulator",
262 .id = 11,
266 .name = "max8925-regulator",
267 .id = 12,
271 .name = "max8925-regulator",
272 .id = 13,
276 .name = "max8925-regulator",
277 .id = 14,
281 .name = "max8925-regulator",
282 .id = 15,
286 .name = "max8925-regulator",
287 .id = 16,
291 .name = "max8925-regulator",
292 .id = 17,
296 .name = "max8925-regulator",
297 .id = 18,
301 .name = "max8925-regulator",
302 .id = 19,
306 .name = "max8925-regulator",
307 .id = 20,
311 .name = "max8925-regulator",
312 .id = 21,
316 .name = "max8925-regulator",
317 .id = 22,
476 int read_reg = -1, value = 0; in max8925_irq()
482 if (irq_data->tsc_irq) in max8925_irq()
484 if (irq_data->flags == FLAGS_RTC) in max8925_irq()
485 i2c = chip->rtc; in max8925_irq()
486 else if (irq_data->flags == FLAGS_ADC) in max8925_irq()
487 i2c = chip->adc; in max8925_irq()
489 i2c = chip->i2c; in max8925_irq()
490 if (read_reg != irq_data->reg) { in max8925_irq()
491 read_reg = irq_data->reg; in max8925_irq()
492 value = max8925_reg_read(i2c, irq_data->reg); in max8925_irq()
494 if (value & irq_data->enable) in max8925_irq()
495 handle_nested_irq(chip->irq_base + i); in max8925_irq()
505 int read_reg = -1, value = 0; in max8925_tsc_irq()
511 if (!irq_data->tsc_irq) in max8925_tsc_irq()
513 if (irq_data->flags == FLAGS_RTC) in max8925_tsc_irq()
514 i2c = chip->rtc; in max8925_tsc_irq()
515 else if (irq_data->flags == FLAGS_ADC) in max8925_tsc_irq()
516 i2c = chip->adc; in max8925_tsc_irq()
518 i2c = chip->i2c; in max8925_tsc_irq()
519 if (read_reg != irq_data->reg) { in max8925_tsc_irq()
520 read_reg = irq_data->reg; in max8925_tsc_irq()
521 value = max8925_reg_read(i2c, irq_data->reg); in max8925_tsc_irq()
523 if (value & irq_data->enable) in max8925_tsc_irq()
524 handle_nested_irq(chip->irq_base + i); in max8925_tsc_irq()
533 mutex_lock(&chip->irq_lock); in max8925_irq_lock()
556 /* 1 -- disable, 0 -- enable */ in max8925_irq_sync_unlock()
557 switch (irq_data->mask_reg) { in max8925_irq_sync_unlock()
559 irq_chg[0] &= ~irq_data->enable; in max8925_irq_sync_unlock()
562 irq_chg[1] &= ~irq_data->enable; in max8925_irq_sync_unlock()
565 irq_on[0] &= ~irq_data->enable; in max8925_irq_sync_unlock()
568 irq_on[1] &= ~irq_data->enable; in max8925_irq_sync_unlock()
571 irq_rtc &= ~irq_data->enable; in max8925_irq_sync_unlock()
574 irq_tsc &= ~irq_data->enable; in max8925_irq_sync_unlock()
577 dev_err(chip->dev, "wrong IRQ\n"); in max8925_irq_sync_unlock()
584 max8925_reg_write(chip->i2c, MAX8925_CHG_IRQ1_MASK, in max8925_irq_sync_unlock()
589 max8925_reg_write(chip->i2c, MAX8925_CHG_IRQ2_MASK, in max8925_irq_sync_unlock()
594 max8925_reg_write(chip->i2c, MAX8925_ON_OFF_IRQ1_MASK, in max8925_irq_sync_unlock()
599 max8925_reg_write(chip->i2c, MAX8925_ON_OFF_IRQ2_MASK, in max8925_irq_sync_unlock()
604 max8925_reg_write(chip->rtc, MAX8925_RTC_IRQ_MASK, irq_rtc); in max8925_irq_sync_unlock()
608 max8925_reg_write(chip->adc, MAX8925_TSC_IRQ_MASK, irq_tsc); in max8925_irq_sync_unlock()
611 mutex_unlock(&chip->irq_lock); in max8925_irq_sync_unlock()
618 max8925_irqs[data->irq - chip->irq_base].enable in max8925_irq_enable()
619 = max8925_irqs[data->irq - chip->irq_base].offs; in max8925_irq_enable()
626 max8925_irqs[data->irq - chip->irq_base].enable = 0; in max8925_irq_disable()
640 irq_set_chip_data(virq, d->host_data); in max8925_irq_domain_map()
659 struct device_node *node = chip->dev->of_node; in max8925_irq_init()
662 max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ1); in max8925_irq_init()
663 max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ2); in max8925_irq_init()
664 max8925_reg_read(chip->i2c, MAX8925_ON_OFF_IRQ1); in max8925_irq_init()
665 max8925_reg_read(chip->i2c, MAX8925_ON_OFF_IRQ2); in max8925_irq_init()
666 max8925_reg_read(chip->rtc, MAX8925_RTC_IRQ); in max8925_irq_init()
667 max8925_reg_read(chip->adc, MAX8925_TSC_IRQ); in max8925_irq_init()
669 max8925_reg_write(chip->rtc, MAX8925_ALARM0_CNTL, 0); in max8925_irq_init()
670 max8925_reg_write(chip->rtc, MAX8925_ALARM1_CNTL, 0); in max8925_irq_init()
671 max8925_reg_write(chip->i2c, MAX8925_CHG_IRQ1_MASK, 0xff); in max8925_irq_init()
672 max8925_reg_write(chip->i2c, MAX8925_CHG_IRQ2_MASK, 0xff); in max8925_irq_init()
673 max8925_reg_write(chip->i2c, MAX8925_ON_OFF_IRQ1_MASK, 0xff); in max8925_irq_init()
674 max8925_reg_write(chip->i2c, MAX8925_ON_OFF_IRQ2_MASK, 0xff); in max8925_irq_init()
675 max8925_reg_write(chip->rtc, MAX8925_RTC_IRQ_MASK, 0xff); in max8925_irq_init()
677 mutex_init(&chip->irq_lock); in max8925_irq_init()
678 chip->irq_base = irq_alloc_descs(-1, 0, MAX8925_NR_IRQS, 0); in max8925_irq_init()
679 if (chip->irq_base < 0) { in max8925_irq_init()
680 dev_err(chip->dev, "Failed to allocate interrupts, ret:%d\n", in max8925_irq_init()
681 chip->irq_base); in max8925_irq_init()
682 return -EBUSY; in max8925_irq_init()
685 irq_domain_add_legacy(node, MAX8925_NR_IRQS, chip->irq_base, 0, in max8925_irq_init()
689 chip->core_irq = irq; in max8925_irq_init()
690 if (!chip->core_irq) in max8925_irq_init()
691 return -EBUSY; in max8925_irq_init()
695 dev_err(chip->dev, "Failed to request core IRQ: %d\n", ret); in max8925_irq_init()
696 chip->core_irq = 0; in max8925_irq_init()
697 return -EBUSY; in max8925_irq_init()
703 max8925_reg_write(chip->adc, MAX8925_TSC_IRQ_MASK, 0x0f); in max8925_irq_init()
705 if (!pdata->tsc_irq) { in max8925_irq_init()
706 dev_warn(chip->dev, "No interrupt support on TSC IRQ\n"); in max8925_irq_init()
709 chip->tsc_irq = pdata->tsc_irq; in max8925_irq_init()
710 ret = request_threaded_irq(chip->tsc_irq, NULL, max8925_tsc_irq, in max8925_irq_init()
711 flags | IRQF_ONESHOT, "max8925-tsc", chip); in max8925_irq_init()
713 dev_err(chip->dev, "Failed to request TSC IRQ: %d\n", ret); in max8925_irq_init()
714 chip->tsc_irq = 0; in max8925_irq_init()
726 if (pdata->sd1) { in init_regulator()
727 reg_devs[0].platform_data = pdata->sd1; in init_regulator()
730 if (pdata->sd2) { in init_regulator()
731 reg_devs[1].platform_data = pdata->sd2; in init_regulator()
734 if (pdata->sd3) { in init_regulator()
735 reg_devs[2].platform_data = pdata->sd3; in init_regulator()
738 if (pdata->ldo1) { in init_regulator()
739 reg_devs[3].platform_data = pdata->ldo1; in init_regulator()
742 if (pdata->ldo2) { in init_regulator()
743 reg_devs[4].platform_data = pdata->ldo2; in init_regulator()
746 if (pdata->ldo3) { in init_regulator()
747 reg_devs[5].platform_data = pdata->ldo3; in init_regulator()
750 if (pdata->ldo4) { in init_regulator()
751 reg_devs[6].platform_data = pdata->ldo4; in init_regulator()
754 if (pdata->ldo5) { in init_regulator()
755 reg_devs[7].platform_data = pdata->ldo5; in init_regulator()
758 if (pdata->ldo6) { in init_regulator()
759 reg_devs[8].platform_data = pdata->ldo6; in init_regulator()
762 if (pdata->ldo7) { in init_regulator()
763 reg_devs[9].platform_data = pdata->ldo7; in init_regulator()
766 if (pdata->ldo8) { in init_regulator()
767 reg_devs[10].platform_data = pdata->ldo8; in init_regulator()
770 if (pdata->ldo9) { in init_regulator()
771 reg_devs[11].platform_data = pdata->ldo9; in init_regulator()
774 if (pdata->ldo10) { in init_regulator()
775 reg_devs[12].platform_data = pdata->ldo10; in init_regulator()
778 if (pdata->ldo11) { in init_regulator()
779 reg_devs[13].platform_data = pdata->ldo11; in init_regulator()
782 if (pdata->ldo12) { in init_regulator()
783 reg_devs[14].platform_data = pdata->ldo12; in init_regulator()
786 if (pdata->ldo13) { in init_regulator()
787 reg_devs[15].platform_data = pdata->ldo13; in init_regulator()
790 if (pdata->ldo14) { in init_regulator()
791 reg_devs[16].platform_data = pdata->ldo14; in init_regulator()
794 if (pdata->ldo15) { in init_regulator()
795 reg_devs[17].platform_data = pdata->ldo15; in init_regulator()
798 if (pdata->ldo16) { in init_regulator()
799 reg_devs[18].platform_data = pdata->ldo16; in init_regulator()
802 if (pdata->ldo17) { in init_regulator()
803 reg_devs[19].platform_data = pdata->ldo17; in init_regulator()
806 if (pdata->ldo18) { in init_regulator()
807 reg_devs[20].platform_data = pdata->ldo18; in init_regulator()
810 if (pdata->ldo19) { in init_regulator()
811 reg_devs[21].platform_data = pdata->ldo19; in init_regulator()
814 if (pdata->ldo20) { in init_regulator()
815 reg_devs[22].platform_data = pdata->ldo20; in init_regulator()
818 ret = mfd_add_devices(chip->dev, 0, reg_devs, ARRAY_SIZE(reg_devs), in init_regulator()
821 dev_err(chip->dev, "Failed to add regulator subdev\n"); in init_regulator()
831 max8925_irq_init(chip, chip->i2c->irq, pdata); in max8925_device_init()
833 if (pdata && (pdata->power || pdata->touch)) { in max8925_device_init()
835 max8925_set_bits(chip->i2c, MAX8925_RESET_CNFG, 1, 1); in max8925_device_init()
837 max8925_set_bits(chip->adc, MAX8925_TSC_CNFG1, 3, 2); in max8925_device_init()
840 ret = max8925_reg_read(chip->adc, MAX8925_TSC_IRQ); in max8925_device_init()
843 max8925_set_bits(chip->adc, MAX8925_ADC_SCHED, 3, 2); in max8925_device_init()
847 max8925_set_bits(chip->rtc, MAX8925_MPL_CNTL, 1 << 4, 1 << 4); in max8925_device_init()
849 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], in max8925_device_init()
851 NULL, chip->irq_base, NULL); in max8925_device_init()
853 dev_err(chip->dev, "Failed to add rtc subdev\n"); in max8925_device_init()
857 ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0], in max8925_device_init()
859 NULL, chip->irq_base, NULL); in max8925_device_init()
861 dev_err(chip->dev, "Failed to add onkey subdev\n"); in max8925_device_init()
867 if (pdata && pdata->backlight) { in max8925_device_init()
868 bk_devs[0].platform_data = &pdata->backlight; in max8925_device_init()
871 ret = mfd_add_devices(chip->dev, 0, bk_devs, ARRAY_SIZE(bk_devs), in max8925_device_init()
874 dev_err(chip->dev, "Failed to add backlight subdev\n"); in max8925_device_init()
878 ret = mfd_add_devices(chip->dev, 0, &power_devs[0], in max8925_device_init()
882 dev_err(chip->dev, in max8925_device_init()
887 if (pdata && pdata->touch) { in max8925_device_init()
888 ret = mfd_add_devices(chip->dev, 0, &touch_devs[0], in max8925_device_init()
890 NULL, chip->tsc_irq, NULL); in max8925_device_init()
892 dev_err(chip->dev, "Failed to add touch subdev\n"); in max8925_device_init()
899 mfd_remove_devices(chip->dev); in max8925_device_init()
906 if (chip->core_irq) in max8925_device_exit()
907 free_irq(chip->core_irq, chip); in max8925_device_exit()
908 if (chip->tsc_irq) in max8925_device_exit()
909 free_irq(chip->tsc_irq, chip); in max8925_device_exit()
910 mfd_remove_devices(chip->dev); in max8925_device_exit()