1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright 2019 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
9 #define LOG_CATEGORY UCLASS_SOUND
12 #include <audio_codec.h>
17 static int broadwell_sound_probe(struct udevice *dev)
19 return sound_find_codec_i2s(dev);
22 static int broadwell_sound_setup(struct udevice *dev)
24 struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev);
25 struct i2s_uc_priv *i2c_priv = dev_get_uclass_priv(uc_priv->i2s);
28 if (uc_priv->setup_done)
30 ret = audio_codec_set_params(uc_priv->codec, i2c_priv->id,
31 i2c_priv->samplingrate,
32 i2c_priv->samplingrate * i2c_priv->rfs,
33 i2c_priv->bitspersample,
37 uc_priv->setup_done = true;
42 static int broadwell_sound_play(struct udevice *dev, void *data, uint data_size)
44 struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev);
46 return i2s_tx_data(uc_priv->i2s, data, data_size);
49 static const struct sound_ops broadwell_sound_ops = {
50 .setup = broadwell_sound_setup,
51 .play = broadwell_sound_play,
54 static const struct udevice_id broadwell_sound_ids[] = {
55 { .compatible = "google,samus-sound" },
59 U_BOOT_DRIVER(broadwell_sound_drv) = {
60 .name = "broadwell_sound",
62 .of_match = broadwell_sound_ids,
63 .probe = broadwell_sound_probe,
64 .ops = &broadwell_sound_ops,