~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/codecs/aw8738.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/soc/codecs/aw8738.c (Architecture alpha) and /sound/soc/codecs/aw8738.c (Architecture sparc)


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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php