Lines Matching full:arizona

3  * Arizona core driver
27 #include <linux/mfd/arizona/core.h>
28 #include <linux/mfd/arizona/registers.h>
30 #include "arizona.h"
37 int arizona_clk32k_enable(struct arizona *arizona) in arizona_clk32k_enable() argument
41 mutex_lock(&arizona->clk_lock); in arizona_clk32k_enable()
43 arizona->clk32k_ref++; in arizona_clk32k_enable()
45 if (arizona->clk32k_ref == 1) { in arizona_clk32k_enable()
46 switch (arizona->pdata.clk32k_src) { in arizona_clk32k_enable()
48 ret = pm_runtime_get_sync(arizona->dev); in arizona_clk32k_enable()
51 ret = clk_prepare_enable(arizona->mclk[ARIZONA_MCLK1]); in arizona_clk32k_enable()
53 pm_runtime_put_sync(arizona->dev); in arizona_clk32k_enable()
58 ret = clk_prepare_enable(arizona->mclk[ARIZONA_MCLK2]); in arizona_clk32k_enable()
64 ret = regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1, in arizona_clk32k_enable()
71 arizona->clk32k_ref--; in arizona_clk32k_enable()
73 mutex_unlock(&arizona->clk_lock); in arizona_clk32k_enable()
79 int arizona_clk32k_disable(struct arizona *arizona) in arizona_clk32k_disable() argument
81 mutex_lock(&arizona->clk_lock); in arizona_clk32k_disable()
83 WARN_ON(arizona->clk32k_ref <= 0); in arizona_clk32k_disable()
85 arizona->clk32k_ref--; in arizona_clk32k_disable()
87 if (arizona->clk32k_ref == 0) { in arizona_clk32k_disable()
88 regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1, in arizona_clk32k_disable()
91 switch (arizona->pdata.clk32k_src) { in arizona_clk32k_disable()
93 pm_runtime_put_sync(arizona->dev); in arizona_clk32k_disable()
94 clk_disable_unprepare(arizona->mclk[ARIZONA_MCLK1]); in arizona_clk32k_disable()
97 clk_disable_unprepare(arizona->mclk[ARIZONA_MCLK2]); in arizona_clk32k_disable()
102 mutex_unlock(&arizona->clk_lock); in arizona_clk32k_disable()
110 struct arizona *arizona = data; in arizona_clkgen_err() local
112 dev_err(arizona->dev, "CLKGEN error\n"); in arizona_clkgen_err()
119 struct arizona *arizona = data; in arizona_underclocked() local
123 ret = regmap_read(arizona->regmap, ARIZONA_INTERRUPT_RAW_STATUS_8, in arizona_underclocked()
126 dev_err(arizona->dev, "Failed to read underclock status: %d\n", in arizona_underclocked()
132 dev_err(arizona->dev, "AIF3 underclocked\n"); in arizona_underclocked()
134 dev_err(arizona->dev, "AIF2 underclocked\n"); in arizona_underclocked()
136 dev_err(arizona->dev, "AIF1 underclocked\n"); in arizona_underclocked()
138 dev_err(arizona->dev, "ISRC3 underclocked\n"); in arizona_underclocked()
140 dev_err(arizona->dev, "ISRC2 underclocked\n"); in arizona_underclocked()
142 dev_err(arizona->dev, "ISRC1 underclocked\n"); in arizona_underclocked()
144 dev_err(arizona->dev, "FX underclocked\n"); in arizona_underclocked()
146 dev_err(arizona->dev, "ASRC underclocked\n"); in arizona_underclocked()
148 dev_err(arizona->dev, "DAC underclocked\n"); in arizona_underclocked()
150 dev_err(arizona->dev, "ADC underclocked\n"); in arizona_underclocked()
152 dev_err(arizona->dev, "Mixer dropped sample\n"); in arizona_underclocked()
159 struct arizona *arizona = data; in arizona_overclocked() local
163 ret = regmap_bulk_read(arizona->regmap, ARIZONA_INTERRUPT_RAW_STATUS_6, in arizona_overclocked()
166 dev_err(arizona->dev, "Failed to read overclock status: %d\n", in arizona_overclocked()
171 switch (arizona->type) { in arizona_overclocked()
186 dev_err(arizona->dev, "PWM overclocked\n"); in arizona_overclocked()
188 dev_err(arizona->dev, "FX core overclocked\n"); in arizona_overclocked()
190 dev_err(arizona->dev, "DAC SYS overclocked\n"); in arizona_overclocked()
192 dev_err(arizona->dev, "DAC WARP overclocked\n"); in arizona_overclocked()
194 dev_err(arizona->dev, "ADC overclocked\n"); in arizona_overclocked()
196 dev_err(arizona->dev, "Mixer overclocked\n"); in arizona_overclocked()
198 dev_err(arizona->dev, "AIF3 overclocked\n"); in arizona_overclocked()
200 dev_err(arizona->dev, "AIF2 overclocked\n"); in arizona_overclocked()
202 dev_err(arizona->dev, "AIF1 overclocked\n"); in arizona_overclocked()
204 dev_err(arizona->dev, "Pad control overclocked\n"); in arizona_overclocked()
207 dev_err(arizona->dev, "Slimbus subsystem overclocked\n"); in arizona_overclocked()
209 dev_err(arizona->dev, "Slimbus async overclocked\n"); in arizona_overclocked()
211 dev_err(arizona->dev, "Slimbus sync overclocked\n"); in arizona_overclocked()
213 dev_err(arizona->dev, "ASRC async system overclocked\n"); in arizona_overclocked()
215 dev_err(arizona->dev, "ASRC async WARP overclocked\n"); in arizona_overclocked()
217 dev_err(arizona->dev, "ASRC sync system overclocked\n"); in arizona_overclocked()
219 dev_err(arizona->dev, "ASRC sync WARP overclocked\n"); in arizona_overclocked()
221 dev_err(arizona->dev, "DSP1 overclocked\n"); in arizona_overclocked()
223 dev_err(arizona->dev, "ISRC3 overclocked\n"); in arizona_overclocked()
225 dev_err(arizona->dev, "ISRC2 overclocked\n"); in arizona_overclocked()
227 dev_err(arizona->dev, "ISRC1 overclocked\n"); in arizona_overclocked()
230 dev_err(arizona->dev, "SPDIF overclocked\n"); in arizona_overclocked()
247 static int arizona_poll_reg(struct arizona *arizona, in arizona_poll_reg() argument
256 ret = regmap_read(arizona->regmap, reg, &val); in arizona_poll_reg()
263 dev_err(arizona->dev, "Failed polling reg 0x%x: %d\n", in arizona_poll_reg()
268 dev_err(arizona->dev, "Polling reg 0x%x timed out: %x\n", reg, val); in arizona_poll_reg()
272 static int arizona_wait_for_boot(struct arizona *arizona) in arizona_wait_for_boot() argument
281 ret = arizona_poll_reg(arizona, 30, ARIZONA_INTERRUPT_RAW_STATUS_5, in arizona_wait_for_boot()
285 regmap_write(arizona->regmap, ARIZONA_INTERRUPT_STATUS_5, in arizona_wait_for_boot()
288 pm_runtime_mark_last_busy(arizona->dev); in arizona_wait_for_boot()
293 static inline void arizona_enable_reset(struct arizona *arizona) in arizona_enable_reset() argument
295 if (arizona->pdata.reset) in arizona_enable_reset()
296 gpiod_set_raw_value_cansleep(arizona->pdata.reset, 0); in arizona_enable_reset()
299 static void arizona_disable_reset(struct arizona *arizona) in arizona_disable_reset() argument
301 if (arizona->pdata.reset) { in arizona_disable_reset()
302 switch (arizona->type) { in arizona_disable_reset()
312 gpiod_set_raw_value_cansleep(arizona->pdata.reset, 1); in arizona_disable_reset()
322 static int arizona_enable_freerun_sysclk(struct arizona *arizona, in arizona_enable_freerun_sysclk() argument
328 ret = regmap_read(arizona->regmap, ARIZONA_FLL1_CONTROL_1, &state->fll); in arizona_enable_freerun_sysclk()
330 dev_err(arizona->dev, "Failed to cache FLL settings: %d\n", in arizona_enable_freerun_sysclk()
334 ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, in arizona_enable_freerun_sysclk()
337 dev_err(arizona->dev, "Failed to cache SYSCLK settings: %d\n", in arizona_enable_freerun_sysclk()
343 ret = regmap_write(arizona->regmap, ARIZONA_FLL1_CONTROL_1, in arizona_enable_freerun_sysclk()
346 dev_err(arizona->dev, in arizona_enable_freerun_sysclk()
351 ret = arizona_poll_reg(arizona, 180, ARIZONA_INTERRUPT_RAW_STATUS_5, in arizona_enable_freerun_sysclk()
357 ret = regmap_write(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, 0x0144); in arizona_enable_freerun_sysclk()
359 dev_err(arizona->dev, "Failed to start SYSCLK: %d\n", ret); in arizona_enable_freerun_sysclk()
366 err = regmap_write(arizona->regmap, ARIZONA_FLL1_CONTROL_1, state->fll); in arizona_enable_freerun_sysclk()
368 dev_err(arizona->dev, in arizona_enable_freerun_sysclk()
374 static int arizona_disable_freerun_sysclk(struct arizona *arizona, in arizona_disable_freerun_sysclk() argument
379 ret = regmap_write(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, in arizona_disable_freerun_sysclk()
382 dev_err(arizona->dev, in arizona_disable_freerun_sysclk()
387 ret = regmap_write(arizona->regmap, ARIZONA_FLL1_CONTROL_1, state->fll); in arizona_disable_freerun_sysclk()
389 dev_err(arizona->dev, in arizona_disable_freerun_sysclk()
397 static int wm5102_apply_hardware_patch(struct arizona *arizona) in wm5102_apply_hardware_patch() argument
402 ret = arizona_enable_freerun_sysclk(arizona, &state); in wm5102_apply_hardware_patch()
407 ret = regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0, in wm5102_apply_hardware_patch()
410 dev_err(arizona->dev, "Failed to start write sequencer: %d\n", in wm5102_apply_hardware_patch()
415 ret = arizona_poll_reg(arizona, 30, ARIZONA_WRITE_SEQUENCER_CTRL_1, in wm5102_apply_hardware_patch()
418 regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0, in wm5102_apply_hardware_patch()
422 err = arizona_disable_freerun_sysclk(arizona, &state); in wm5102_apply_hardware_patch()
438 static int wm5110_apply_sleep_patch(struct arizona *arizona) in wm5110_apply_sleep_patch() argument
443 ret = arizona_enable_freerun_sysclk(arizona, &state); in wm5110_apply_sleep_patch()
447 ret = regmap_multi_reg_write_bypassed(arizona->regmap, in wm5110_apply_sleep_patch()
451 err = arizona_disable_freerun_sysclk(arizona, &state); in wm5110_apply_sleep_patch()
456 static int wm5102_clear_write_sequencer(struct arizona *arizona) in wm5102_clear_write_sequencer() argument
460 ret = regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_3, in wm5102_clear_write_sequencer()
463 dev_err(arizona->dev, in wm5102_clear_write_sequencer()
468 arizona_enable_reset(arizona); in wm5102_clear_write_sequencer()
469 regulator_disable(arizona->dcvdd); in wm5102_clear_write_sequencer()
473 ret = regulator_enable(arizona->dcvdd); in wm5102_clear_write_sequencer()
475 dev_err(arizona->dev, "Failed to re-enable DCVDD: %d\n", ret); in wm5102_clear_write_sequencer()
478 arizona_disable_reset(arizona); in wm5102_clear_write_sequencer()
484 static int arizona_isolate_dcvdd(struct arizona *arizona) in arizona_isolate_dcvdd() argument
488 ret = regmap_update_bits(arizona->regmap, in arizona_isolate_dcvdd()
493 dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n", ret); in arizona_isolate_dcvdd()
498 static int arizona_connect_dcvdd(struct arizona *arizona) in arizona_connect_dcvdd() argument
502 ret = regmap_update_bits(arizona->regmap, in arizona_connect_dcvdd()
506 dev_err(arizona->dev, "Failed to connect DCVDD: %d\n", ret); in arizona_connect_dcvdd()
511 static int arizona_is_jack_det_active(struct arizona *arizona) in arizona_is_jack_det_active() argument
516 ret = regmap_read(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, &val); in arizona_is_jack_det_active()
518 dev_err(arizona->dev, in arizona_is_jack_det_active()
530 struct arizona *arizona = dev_get_drvdata(dev); in arizona_runtime_resume() local
533 dev_dbg(arizona->dev, "Leaving AoD mode\n"); in arizona_runtime_resume()
535 if (arizona->has_fully_powered_off) { in arizona_runtime_resume()
536 dev_dbg(arizona->dev, "Re-enabling core supplies\n"); in arizona_runtime_resume()
538 ret = regulator_bulk_enable(arizona->num_core_supplies, in arizona_runtime_resume()
539 arizona->core_supplies); in arizona_runtime_resume()
547 ret = regulator_enable(arizona->dcvdd); in arizona_runtime_resume()
549 dev_err(arizona->dev, "Failed to enable DCVDD: %d\n", ret); in arizona_runtime_resume()
550 if (arizona->has_fully_powered_off) in arizona_runtime_resume()
551 regulator_bulk_disable(arizona->num_core_supplies, in arizona_runtime_resume()
552 arizona->core_supplies); in arizona_runtime_resume()
556 if (arizona->has_fully_powered_off) { in arizona_runtime_resume()
557 arizona_disable_reset(arizona); in arizona_runtime_resume()
558 enable_irq(arizona->irq); in arizona_runtime_resume()
559 arizona->has_fully_powered_off = false; in arizona_runtime_resume()
562 regcache_cache_only(arizona->regmap, false); in arizona_runtime_resume()
564 switch (arizona->type) { in arizona_runtime_resume()
566 if (arizona->external_dcvdd) { in arizona_runtime_resume()
567 ret = arizona_connect_dcvdd(arizona); in arizona_runtime_resume()
572 ret = wm5102_patch(arizona); in arizona_runtime_resume()
574 dev_err(arizona->dev, "Failed to apply patch: %d\n", in arizona_runtime_resume()
579 ret = wm5102_apply_hardware_patch(arizona); in arizona_runtime_resume()
581 dev_err(arizona->dev, in arizona_runtime_resume()
589 ret = arizona_wait_for_boot(arizona); in arizona_runtime_resume()
593 if (arizona->external_dcvdd) { in arizona_runtime_resume()
594 ret = arizona_connect_dcvdd(arizona); in arizona_runtime_resume()
603 ret = regulator_set_voltage(arizona->dcvdd, in arizona_runtime_resume()
606 dev_err(arizona->dev, in arizona_runtime_resume()
613 ret = wm5110_apply_sleep_patch(arizona); in arizona_runtime_resume()
615 dev_err(arizona->dev, in arizona_runtime_resume()
623 ret = arizona_wait_for_boot(arizona); in arizona_runtime_resume()
628 ret = arizona_wait_for_boot(arizona); in arizona_runtime_resume()
632 if (arizona->external_dcvdd) { in arizona_runtime_resume()
633 ret = arizona_connect_dcvdd(arizona); in arizona_runtime_resume()
640 ret = regcache_sync(arizona->regmap); in arizona_runtime_resume()
642 dev_err(arizona->dev, "Failed to restore register cache\n"); in arizona_runtime_resume()
649 regcache_cache_only(arizona->regmap, true); in arizona_runtime_resume()
650 regulator_disable(arizona->dcvdd); in arizona_runtime_resume()
656 struct arizona *arizona = dev_get_drvdata(dev); in arizona_runtime_suspend() local
660 dev_dbg(arizona->dev, "Entering AoD mode\n"); in arizona_runtime_suspend()
662 switch (arizona->type) { in arizona_runtime_suspend()
665 jd_active = arizona_is_jack_det_active(arizona); in arizona_runtime_suspend()
669 if (arizona->external_dcvdd) { in arizona_runtime_suspend()
670 ret = arizona_isolate_dcvdd(arizona); in arizona_runtime_suspend()
679 ret = regulator_set_voltage(arizona->dcvdd, in arizona_runtime_suspend()
682 dev_err(arizona->dev, in arizona_runtime_suspend()
690 jd_active = arizona_is_jack_det_active(arizona); in arizona_runtime_suspend()
694 if (arizona->external_dcvdd) { in arizona_runtime_suspend()
695 ret = arizona_isolate_dcvdd(arizona); in arizona_runtime_suspend()
701 ret = regmap_write(arizona->regmap, in arizona_runtime_suspend()
704 dev_err(arizona->dev, in arizona_runtime_suspend()
715 jd_active = arizona_is_jack_det_active(arizona); in arizona_runtime_suspend()
719 if (arizona->external_dcvdd) { in arizona_runtime_suspend()
720 ret = arizona_isolate_dcvdd(arizona); in arizona_runtime_suspend()
727 regcache_cache_only(arizona->regmap, true); in arizona_runtime_suspend()
728 regcache_mark_dirty(arizona->regmap); in arizona_runtime_suspend()
729 regulator_disable(arizona->dcvdd); in arizona_runtime_suspend()
733 dev_dbg(arizona->dev, "Fully powering off\n"); in arizona_runtime_suspend()
735 arizona->has_fully_powered_off = true; in arizona_runtime_suspend()
737 disable_irq_nosync(arizona->irq); in arizona_runtime_suspend()
738 arizona_enable_reset(arizona); in arizona_runtime_suspend()
739 regulator_bulk_disable(arizona->num_core_supplies, in arizona_runtime_suspend()
740 arizona->core_supplies); in arizona_runtime_suspend()
750 struct arizona *arizona = dev_get_drvdata(dev); in arizona_suspend() local
752 dev_dbg(arizona->dev, "Suspend, disabling IRQ\n"); in arizona_suspend()
753 disable_irq(arizona->irq); in arizona_suspend()
760 struct arizona *arizona = dev_get_drvdata(dev); in arizona_suspend_noirq() local
762 dev_dbg(arizona->dev, "Late suspend, reenabling IRQ\n"); in arizona_suspend_noirq()
763 enable_irq(arizona->irq); in arizona_suspend_noirq()
770 struct arizona *arizona = dev_get_drvdata(dev); in arizona_resume_noirq() local
772 dev_dbg(arizona->dev, "Early resume, disabling IRQ\n"); in arizona_resume_noirq()
773 disable_irq(arizona->irq); in arizona_resume_noirq()
780 struct arizona *arizona = dev_get_drvdata(dev); in arizona_resume() local
782 dev_dbg(arizona->dev, "Resume, reenabling IRQ\n"); in arizona_resume()
783 enable_irq(arizona->irq); in arizona_resume()
800 static int arizona_of_get_core_pdata(struct arizona *arizona) in arizona_of_get_core_pdata() argument
802 struct arizona_pdata *pdata = &arizona->pdata; in arizona_of_get_core_pdata()
806 pdata->reset = devm_gpiod_get(arizona->dev, "wlf,reset", GPIOD_OUT_LOW); in arizona_of_get_core_pdata()
818 dev_err(arizona->dev, "Reset GPIO malformed: %d\n", in arizona_of_get_core_pdata()
824 ret = of_property_read_u32_array(arizona->dev->of_node, in arizona_of_get_core_pdata()
842 dev_err(arizona->dev, "Failed to parse GPIO defaults: %d\n", in arizona_of_get_core_pdata()
849 static inline int arizona_of_get_core_pdata(struct arizona *arizona) in arizona_of_get_core_pdata() argument
856 { .name = "arizona-ldo1" },
869 { .name = "arizona-micsupp" },
870 { .name = "arizona-gpio" },
871 { .name = "arizona-haptics" },
872 { .name = "arizona-pwm" },
881 { .name = "arizona-micsupp" },
882 { .name = "arizona-gpio" },
883 { .name = "arizona-haptics" },
884 { .name = "arizona-pwm" },
899 { .name = "arizona-gpio" },
900 { .name = "arizona-haptics" },
901 { .name = "arizona-pwm" },
917 { .name = "arizona-micsupp" },
918 { .name = "arizona-gpio" },
919 { .name = "arizona-haptics" },
920 { .name = "arizona-pwm" },
929 { .name = "arizona-micsupp" },
930 { .name = "arizona-gpio" },
931 { .name = "arizona-haptics" },
932 { .name = "arizona-pwm" },
940 int arizona_dev_init(struct arizona *arizona) in arizona_dev_init() argument
943 struct device *dev = arizona->dev; in arizona_dev_init()
946 int (*apply_patch)(struct arizona *) = NULL; in arizona_dev_init()
950 dev_set_drvdata(arizona->dev, arizona); in arizona_dev_init()
951 mutex_init(&arizona->clk_lock); in arizona_dev_init()
953 if (dev_get_platdata(arizona->dev)) { in arizona_dev_init()
954 memcpy(&arizona->pdata, dev_get_platdata(arizona->dev), in arizona_dev_init()
955 sizeof(arizona->pdata)); in arizona_dev_init()
957 ret = arizona_of_get_core_pdata(arizona); in arizona_dev_init()
962 BUILD_BUG_ON(ARRAY_SIZE(arizona->mclk) != ARRAY_SIZE(mclk_name)); in arizona_dev_init()
963 for (i = 0; i < ARRAY_SIZE(arizona->mclk); i++) { in arizona_dev_init()
964 arizona->mclk[i] = devm_clk_get(arizona->dev, mclk_name[i]); in arizona_dev_init()
965 if (IS_ERR(arizona->mclk[i])) { in arizona_dev_init()
966 dev_info(arizona->dev, "Failed to get %s: %ld\n", in arizona_dev_init()
967 mclk_name[i], PTR_ERR(arizona->mclk[i])); in arizona_dev_init()
968 arizona->mclk[i] = NULL; in arizona_dev_init()
972 regcache_cache_only(arizona->regmap, true); in arizona_dev_init()
974 switch (arizona->type) { in arizona_dev_init()
984 arizona->core_supplies[i].supply in arizona_dev_init()
986 arizona->num_core_supplies = ARRAY_SIZE(wm5102_core_supplies); in arizona_dev_init()
989 dev_err(arizona->dev, "Unknown device type %d\n", in arizona_dev_init()
990 arizona->type); in arizona_dev_init()
995 arizona->external_dcvdd = true; in arizona_dev_init()
997 switch (arizona->type) { in arizona_dev_init()
1002 ret = mfd_add_devices(arizona->dev, -1, early_devs, in arizona_dev_init()
1011 ret = devm_regulator_bulk_get(dev, arizona->num_core_supplies, in arizona_dev_init()
1012 arizona->core_supplies); in arizona_dev_init()
1025 arizona->dcvdd = regulator_get(arizona->dev, "DCVDD"); in arizona_dev_init()
1026 if (IS_ERR(arizona->dcvdd)) { in arizona_dev_init()
1027 ret = PTR_ERR(arizona->dcvdd); in arizona_dev_init()
1032 if (!arizona->pdata.reset) { in arizona_dev_init()
1034 arizona->pdata.reset = devm_gpiod_get(arizona->dev, "reset", in arizona_dev_init()
1036 if (IS_ERR(arizona->pdata.reset)) { in arizona_dev_init()
1037 ret = PTR_ERR(arizona->pdata.reset); in arizona_dev_init()
1041 dev_err(arizona->dev, in arizona_dev_init()
1044 arizona->pdata.reset = NULL; in arizona_dev_init()
1048 ret = regulator_bulk_enable(arizona->num_core_supplies, in arizona_dev_init()
1049 arizona->core_supplies); in arizona_dev_init()
1056 ret = regulator_enable(arizona->dcvdd); in arizona_dev_init()
1062 arizona_disable_reset(arizona); in arizona_dev_init()
1064 regcache_cache_only(arizona->regmap, false); in arizona_dev_init()
1067 ret = regmap_read(arizona->regmap, ARIZONA_SOFTWARE_RESET, &reg); in arizona_dev_init()
1081 dev_err(arizona->dev, "Unknown device ID: %x\n", reg); in arizona_dev_init()
1087 if (!arizona->pdata.reset) { in arizona_dev_init()
1088 ret = regmap_write(arizona->regmap, ARIZONA_SOFTWARE_RESET, 0); in arizona_dev_init()
1098 switch (arizona->type) { in arizona_dev_init()
1100 ret = regmap_read(arizona->regmap, in arizona_dev_init()
1107 ret = wm5102_clear_write_sequencer(arizona); in arizona_dev_init()
1116 ret = arizona_wait_for_boot(arizona); in arizona_dev_init()
1118 dev_err(arizona->dev, "Device failed initial boot: %d\n", ret); in arizona_dev_init()
1123 ret = regmap_read(arizona->regmap, ARIZONA_SOFTWARE_RESET, &reg); in arizona_dev_init()
1129 ret = regmap_read(arizona->regmap, ARIZONA_DEVICE_REVISION, in arizona_dev_init()
1130 &arizona->rev); in arizona_dev_init()
1135 arizona->rev &= ARIZONA_DEVICE_REVISION_MASK; in arizona_dev_init()
1141 if (arizona->type != WM5102) { in arizona_dev_init()
1142 dev_warn(arizona->dev, in arizona_dev_init()
1144 arizona->type); in arizona_dev_init()
1145 arizona->type = WM5102; in arizona_dev_init()
1149 arizona->rev &= 0x7; in arizona_dev_init()
1156 switch (arizona->type) { in arizona_dev_init()
1165 dev_warn(arizona->dev, in arizona_dev_init()
1167 arizona->type); in arizona_dev_init()
1168 arizona->type = WM5110; in arizona_dev_init()
1179 switch (arizona->type) { in arizona_dev_init()
1189 dev_warn(arizona->dev, in arizona_dev_init()
1191 arizona->type); in arizona_dev_init()
1192 arizona->type = CS47L24; in arizona_dev_init()
1204 if (arizona->type != WM8997) { in arizona_dev_init()
1205 dev_warn(arizona->dev, in arizona_dev_init()
1207 arizona->type); in arizona_dev_init()
1208 arizona->type = WM8997; in arizona_dev_init()
1218 switch (arizona->type) { in arizona_dev_init()
1229 dev_warn(arizona->dev, in arizona_dev_init()
1231 arizona->type); in arizona_dev_init()
1232 arizona->type = WM8998; in arizona_dev_init()
1241 dev_err(arizona->dev, "Unknown device ID %x\n", reg); in arizona_dev_init()
1247 dev_err(arizona->dev, in arizona_dev_init()
1253 dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A'); in arizona_dev_init()
1256 ret = apply_patch(arizona); in arizona_dev_init()
1258 dev_err(arizona->dev, "Failed to apply patch: %d\n", in arizona_dev_init()
1263 switch (arizona->type) { in arizona_dev_init()
1265 ret = wm5102_apply_hardware_patch(arizona); in arizona_dev_init()
1267 dev_err(arizona->dev, in arizona_dev_init()
1275 ret = wm5110_apply_sleep_patch(arizona); in arizona_dev_init()
1277 dev_err(arizona->dev, in arizona_dev_init()
1288 for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) { in arizona_dev_init()
1289 if (!arizona->pdata.gpio_defaults[i]) in arizona_dev_init()
1292 regmap_write(arizona->regmap, ARIZONA_GPIO1_CTRL + i, in arizona_dev_init()
1293 arizona->pdata.gpio_defaults[i]); in arizona_dev_init()
1297 if (!arizona->pdata.clk32k_src) in arizona_dev_init()
1298 arizona->pdata.clk32k_src = ARIZONA_32KZ_MCLK2; in arizona_dev_init()
1300 switch (arizona->pdata.clk32k_src) { in arizona_dev_init()
1303 regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1, in arizona_dev_init()
1305 arizona->pdata.clk32k_src - 1); in arizona_dev_init()
1306 arizona_clk32k_enable(arizona); in arizona_dev_init()
1309 regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1, in arizona_dev_init()
1313 dev_err(arizona->dev, "Invalid 32kHz clock source: %d\n", in arizona_dev_init()
1314 arizona->pdata.clk32k_src); in arizona_dev_init()
1320 if (!arizona->pdata.micbias[i].mV && in arizona_dev_init()
1321 !arizona->pdata.micbias[i].bypass) in arizona_dev_init()
1325 if (!arizona->pdata.micbias[i].mV) in arizona_dev_init()
1326 arizona->pdata.micbias[i].mV = 2800; in arizona_dev_init()
1328 val = (arizona->pdata.micbias[i].mV - 1500) / 100; in arizona_dev_init()
1332 if (arizona->pdata.micbias[i].ext_cap) in arizona_dev_init()
1335 if (arizona->pdata.micbias[i].discharge) in arizona_dev_init()
1338 if (arizona->pdata.micbias[i].soft_start) in arizona_dev_init()
1341 if (arizona->pdata.micbias[i].bypass) in arizona_dev_init()
1344 regmap_update_bits(arizona->regmap, in arizona_dev_init()
1353 pm_runtime_set_active(arizona->dev); in arizona_dev_init()
1354 pm_runtime_enable(arizona->dev); in arizona_dev_init()
1357 ret = arizona_irq_init(arizona); in arizona_dev_init()
1361 pm_runtime_set_autosuspend_delay(arizona->dev, 100); in arizona_dev_init()
1362 pm_runtime_use_autosuspend(arizona->dev); in arizona_dev_init()
1364 arizona_request_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error", in arizona_dev_init()
1365 arizona_clkgen_err, arizona); in arizona_dev_init()
1366 arizona_request_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, "Overclocked", in arizona_dev_init()
1367 arizona_overclocked, arizona); in arizona_dev_init()
1368 arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked", in arizona_dev_init()
1369 arizona_underclocked, arizona); in arizona_dev_init()
1371 ret = mfd_add_devices(arizona->dev, PLATFORM_DEVID_NONE, in arizona_dev_init()
1375 dev_err(arizona->dev, "Failed to add subdevices: %d\n", ret); in arizona_dev_init()
1382 arizona_irq_exit(arizona); in arizona_dev_init()
1384 pm_runtime_disable(arizona->dev); in arizona_dev_init()
1386 switch (arizona->pdata.clk32k_src) { in arizona_dev_init()
1389 arizona_clk32k_disable(arizona); in arizona_dev_init()
1395 arizona_enable_reset(arizona); in arizona_dev_init()
1396 regulator_disable(arizona->dcvdd); in arizona_dev_init()
1398 regulator_bulk_disable(arizona->num_core_supplies, in arizona_dev_init()
1399 arizona->core_supplies); in arizona_dev_init()
1401 regulator_put(arizona->dcvdd); in arizona_dev_init()
1408 int arizona_dev_exit(struct arizona *arizona) in arizona_dev_exit() argument
1410 disable_irq(arizona->irq); in arizona_dev_exit()
1411 pm_runtime_disable(arizona->dev); in arizona_dev_exit()
1413 regulator_disable(arizona->dcvdd); in arizona_dev_exit()
1414 regulator_put(arizona->dcvdd); in arizona_dev_exit()
1416 switch (arizona->pdata.clk32k_src) { in arizona_dev_exit()
1419 arizona_clk32k_disable(arizona); in arizona_dev_exit()
1425 mfd_remove_devices(arizona->dev); in arizona_dev_exit()
1426 arizona_free_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, arizona); in arizona_dev_exit()
1427 arizona_free_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, arizona); in arizona_dev_exit()
1428 arizona_free_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, arizona); in arizona_dev_exit()
1429 arizona_irq_exit(arizona); in arizona_dev_exit()
1430 arizona_enable_reset(arizona); in arizona_dev_exit()
1432 regulator_bulk_disable(arizona->num_core_supplies, in arizona_dev_exit()
1433 arizona->core_supplies); in arizona_dev_exit()