All of lore.kernel.org
 help / color / mirror / Atom feed
From: Minkyu Kang <mk7.kang@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 11/16] Sound: WM8994: Add FDT support to codec
Date: Wed, 26 Dec 2012 20:55:15 +0900	[thread overview]
Message-ID: <50DAE5A3.5090709@samsung.com> (raw)
In-Reply-To: <1355486189-432-11-git-send-email-rajeshwari.s@samsung.com>

Dear Rajeshwari Shinde,

On 14/12/12 20:56, Rajeshwari Shinde wrote:
> This patch adds FDT support to the codec.
> 
> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in V1:
> 	-Rebased on latest u-boot-samsung
>  drivers/sound/wm8994.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++-
>  drivers/sound/wm8994.h |    6 +--
>  2 files changed, 76 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
> index 293903a..a528502 100644
> --- a/drivers/sound/wm8994.c
> +++ b/drivers/sound/wm8994.c
> @@ -26,9 +26,11 @@
>  #include <asm/io.h>
>  #include <common.h>
>  #include <div64.h>
> +#include <fdtdec.h>
>  #include <i2c.h>
>  #include <i2s.h>
>  #include <sound.h>
> +#include <asm/arch/sound.h>
>  #include "wm8994.h"
>  #include "wm8994_registers.h"
>  
> @@ -77,6 +79,7 @@ static int bclk_divs[] = {
>  
>  static struct wm8994_priv g_wm8994_info;
>  static unsigned char g_wm8994_i2c_dev_addr;
> +static struct sound_codec_info g_codec_info;
>  
>  /*
>   * Initialise I2C for wm 8994
> @@ -747,13 +750,82 @@ err:
>  	return -1;
>  }
>  
> +/*
> + * Gets fdt values for wm8994 config parameters
> + *
> + * @param pcodec_info	codec information structure
> + * @param blob		FDT blob
> + * @return		int value, 0 for success
> + */
> +static int get_codec_values(struct sound_codec_info *pcodec_info,
> +			const void *blob)
> +{
> +	int error = 0;
> +#ifdef CONFIG_OF_CONTROL
> +	enum fdt_compat_id compat;
> +	int node;
> +	int parent;
> +
> +	/* Get the node from FDT for codec */
> +	node = fdtdec_next_compatible(blob, 0, COMPAT_WOLFSON_WM8994_CODEC);
> +	if (node <= 0) {
> +		debug("EXYNOS_SOUND: No node for codec in device tree\n");
> +		debug("node = %d\n", node);
> +		return -1;
> +	}
> +
> +	parent = fdt_parent_offset(blob, node);
> +	if (parent < 0) {
> +		debug("%s: Cannot find node parent\n", __func__);
> +		return -1;
> +	}
> +
> +	compat = fdtdec_lookup(blob, parent);
> +	switch (compat) {
> +	case COMPAT_SAMSUNG_S3C2440_I2C:
> +		pcodec_info->i2c_bus = i2c_get_bus_num_fdt(parent);
> +		error |= pcodec_info->i2c_bus;
> +		debug("i2c bus = %d\n", pcodec_info->i2c_bus);
> +		pcodec_info->i2c_dev_addr = fdtdec_get_int(blob, node,
> +							"reg", 0);
> +		error |= pcodec_info->i2c_dev_addr;
> +		debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr);
> +		break;
> +	default:
> +		debug("%s: Unknown compat id %d\n", __func__, compat);
> +		return -1;
> +	}
> +#else
> +	pcodec_info->i2c_bus = AUDIO_I2C_BUS;
> +	pcodec_info->i2c_dev_addr = AUDIO_I2C_REG;
> +	debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr);
> +#endif
> +
> +	pcodec_info->codec_type = CODEC_WM_8994;
> +
> +	if (error == -1) {
> +		debug("fail to get wm8994 codec node properties\n");
> +		return -1;
> +	}
> +
> +	return 0;

please remove this blank line.

> +
> +}
> +

please remove this blank line.

> +
>  /*wm8994 Device Initialisation */
> -int wm8994_init(struct sound_codec_info *pcodec_info,
> -			enum en_audio_interface aif_id,
> +int wm8994_init(const void *blob, enum en_audio_interface aif_id,
>  			int sampling_rate, int mclk_freq,
>  			int bits_per_sample, unsigned int channels)
>  {
>  	int ret = 0;
> +	struct sound_codec_info *pcodec_info = &g_codec_info;
> +
> +	/* Get the codec Values */
> +	if (get_codec_values(pcodec_info, blob) < 0) {
> +		debug("FDT Codec values failed\n");
> +		return -1;
> +	}
>  
>  	/* shift the device address by 1 for 7 bit addressing */
>  	g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr;
> diff --git a/drivers/sound/wm8994.h b/drivers/sound/wm8994.h
> index a8f0de1..a1e8335 100644
> --- a/drivers/sound/wm8994.h
> +++ b/drivers/sound/wm8994.h
> @@ -69,8 +69,7 @@ enum wm8994_type {
>  /*
>   * intialise wm8994 sound codec device for the given configuration
>   *
> - * @param pcodec_info		pointer value of the sound codec info structure
> - *				parsed from device tree
> + * @param blob			FDT node for codec values
>   * @param aif_id		enum value of codec interface port in which
>   *				soc i2s is connected
>   * @param sampling_rate		Sampling rate ranges between from 8khz to 96khz
> @@ -80,8 +79,7 @@ enum wm8994_type {
>   *
>   * @returns -1 for error  and 0  Success.
>   */
> -int wm8994_init(struct sound_codec_info *pcodec_info,
> -			enum en_audio_interface aif_id,
> +int wm8994_init(const void *blob, enum en_audio_interface aif_id,
>  			int sampling_rate, int mclk_freq,
>  			int bits_per_sample, unsigned int channels);
>  #endif /*__WM8994_H__ */
> 

--
Thanks,
Minkyu Kang.

  reply	other threads:[~2012-12-26 11:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-14 11:56 [U-Boot] [PATCH 01/16] EXYNOS5: FDT: Add I2C device node data Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 02/16] EXYNOS5 : FDT: Add Aliases for I2C device Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 03/16] FDT: Add compatible string for I2C Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 04/16] EXYNOS5: FDT : Decode peripheral id Rajeshwari Shinde
2012-12-26 11:54   ` Minkyu Kang
2012-12-26 12:00     ` Rajeshwari Birje
2012-12-26 15:37       ` Simon Glass
2012-12-14 11:56 ` [U-Boot] [PATCH 05/16] I2C: Driver changes for FDT support Rajeshwari Shinde
2012-12-26 11:54   ` Minkyu Kang
2012-12-26 12:01     ` Rajeshwari Birje
2012-12-26 12:33     ` Rajeshwari Birje
2012-12-26 14:00       ` Minkyu Kang
2012-12-14 11:56 ` [U-Boot] [PATCH 06/16] SMDK5250: Initialise I2C using FDT Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 07/16] EXYNOS5: FDT: Add sound device node data Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 08/16] EXYNOS5: FDT: Add sound and codec device node Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 09/16] EXYNOS5: FDT: Add compatible strings for sound Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 10/16] Sound: Add FDT support to driver Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 11/16] Sound: WM8994: Add FDT support to codec Rajeshwari Shinde
2012-12-26 11:55   ` Minkyu Kang [this message]
2012-12-26 12:02     ` Rajeshwari Birje
2012-12-14 11:56 ` [U-Boot] [PATCH 12/16] Sound: Add FDT support to CMD Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 13/16] EXYNOS5: FDT: Add compatible strings for SPI Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 14/16] EXYNOS5 : FDT: Add Aliases for SPI device Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 15/16] EXYNOS5: FDT: Add SPI device node data Rajeshwari Shinde
2012-12-14 11:56 ` [U-Boot] [PATCH 16/16] SPI: EXYNOS: Add FDT support to driver Rajeshwari Shinde
2012-12-26 11:54   ` Minkyu Kang
2012-12-26 12:01     ` Rajeshwari Birje

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50DAE5A3.5090709@samsung.com \
    --to=mk7.kang@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.