1 // SPDX-License-Identifier: GPL-2.0-only 1 2 3 #include <linux/gpio/consumer.h> 4 #include <linux/module.h> 5 #include <linux/regulator/consumer.h> 6 #include <sound/soc.h> 7 8 struct aw8738_priv { 9 struct gpio_desc *gpiod_mode; 10 unsigned int mode; 11 }; 12 13 static int aw8738_drv_event(struct snd_soc_dap 14 struct snd_kcontro 15 { 16 struct snd_soc_component *c = snd_soc_ 17 struct aw8738_priv *aw = snd_soc_compo 18 int i; 19 20 switch (event) { 21 case SND_SOC_DAPM_POST_PMU: 22 for (i = 0; i < aw->mode; i++) 23 gpiod_set_value_cansle 24 udelay(2); 25 gpiod_set_value_cansle 26 udelay(2); 27 } 28 msleep(40); 29 break; 30 case SND_SOC_DAPM_PRE_PMD: 31 gpiod_set_value_cansleep(aw->g 32 usleep_range(1000, 2000); 33 break; 34 default: 35 WARN(1, "Unexpected event"); 36 return -EINVAL; 37 } 38 39 return 0; 40 } 41 42 static const struct snd_soc_dapm_widget aw8738 43 SND_SOC_DAPM_INPUT("IN"), 44 SND_SOC_DAPM_OUT_DRV_E("DRV", SND_SOC_ 45 SND_SOC_DAPM_PO 46 SND_SOC_DAPM_OUTPUT("OUT"), 47 }; 48 49 static const struct snd_soc_dapm_route aw8738_ 50 { "DRV", NULL, "IN" }, 51 { "OUT", NULL, "DRV" }, 52 }; 53 54 static const struct snd_soc_component_driver a 55 .dapm_widgets = aw8738_dapm_widgets, 56 .num_dapm_widgets = ARRAY_SIZE(aw8738_ 57 .dapm_routes = aw8738_dapm_routes, 58 .num_dapm_routes = ARRAY_SIZE(aw8738_d 59 }; 60 61 static int aw8738_probe(struct platform_device 62 { 63 struct device *dev = &pdev->dev; 64 struct aw8738_priv *aw; 65 int ret; 66 67 aw = devm_kzalloc(dev, sizeof(*aw), GF 68 if (!aw) 69 return -ENOMEM; 70 platform_set_drvdata(pdev, aw); 71 72 aw->gpiod_mode = devm_gpiod_get(dev, " 73 if (IS_ERR(aw->gpiod_mode)) 74 return dev_err_probe(dev, PTR_ 75 "Failed t 76 77 ret = device_property_read_u32(dev, "a 78 if (ret) 79 return -EINVAL; 80 81 return devm_snd_soc_register_component 82 83 84 } 85 86 #ifdef CONFIG_OF 87 static const struct of_device_id aw8738_of_mat 88 { .compatible = "awinic,aw8738" }, 89 { } 90 }; 91 MODULE_DEVICE_TABLE(of, aw8738_of_match); 92 #endif 93 94 static struct platform_driver aw8738_driver = 95 .probe = aw8738_probe, 96 .driver = { 97 .name = "aw8738", 98 .of_match_table = of_match_ptr 99 }, 100 }; 101 module_platform_driver(aw8738_driver); 102 103 MODULE_DESCRIPTION("Awinic AW8738 Amplifier Dr 104 MODULE_LICENSE("GPL v2"); 105
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.