From patchwork Mon Dec 3 11:37:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006832 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JnC3HENS"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jhZ3Bnwz9s55 for ; Mon, 3 Dec 2018 22:39:42 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id EFBF5C22160; Mon, 3 Dec 2018 11:38:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D9445C221C5; Mon, 3 Dec 2018 11:38:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8BE3AC22185; Mon, 3 Dec 2018 11:38:17 +0000 (UTC) Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by lists.denx.de (Postfix) with ESMTPS id 4E111C22188 for ; Mon, 3 Dec 2018 11:38:17 +0000 (UTC) Received: by mail-qt1-f200.google.com with SMTP id j5so12956770qtk.11 for ; Mon, 03 Dec 2018 03:38:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=97V/NhRB+9pq9CjtxqMFX8dtmg8omPe9buxXoCcao90=; b=JnC3HENSZ2JeWmVC2AqhB/XMvSjtwhWWl1PMPziqn5vhaGmTWB0M1mOZ0qxBt2SJ2X h5o35izUF9bOrUhqAzKQ7PlGp/FcQ6NVwRwqPxXgM82V9I0Z8OXnWLimAE7pqvesJ4bk RfZa0cx24/79CQtjl3Wdksem6UqY/5F3kgFK0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=97V/NhRB+9pq9CjtxqMFX8dtmg8omPe9buxXoCcao90=; b=Nz499xUxQXRpZ7V2Dq+TU1xXgKMhIDaDxw5zNjsl0eJ9pRu44a8ssK/My6z9lyDUUv LXchQAC+s14lmyPNOaF+T9iBDXK/6/QGarefVvsBqSv5zEzppGL00GF3Fk0ibRO3r6kg db9QPYoBDwknGcjowazZblUEkYoZOzO4e1pHqmgW3O3+HVVeZSy3JzQFFEmN0tuBEi3R SBhk49wFgOTh6ydMpdDIsbnZ714zVL0TpOvNCbsADR4Xh4h3NMr42TwUycg7Rkgv7hwu rJSncS5VJ83pYqbaVye1bZZdzsG8njvn8LMWk3wAyBsUO1F9YLMhTDLE3eAd9vuyJgXw 7Gyw== X-Gm-Message-State: AA+aEWZHl4Avovm37zFZXtOJCGcXOxF3NKtiMMC947j/qQDhF1pjKpH/ M2oWRH379A1PcmBiLEDPu9I1YoaMAe1Le4cs X-Google-Smtp-Source: AFSGD/WXN5CpH5o6NuNMyjs5tTnBpieWEretqVdDCdoaAZnT7pPj7BecFyKlIWJh7U8FVIsrokvW738DivTd179B X-Received: by 2002:a0c:ae61:: with SMTP id z30mr12405932qvc.11.1543837096049; Mon, 03 Dec 2018 03:38:16 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:17 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-2-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Cc: Marek Vasut , Duncan Hare , Joe Hershberger , Michal Simek Subject: [U-Boot] [PATCH 01/30] sandbox: Increase the pre-relocation memory X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This is close to full now, so increase it to avoid problems with adding more devices. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Kconfig | 2 ++ configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - configs/sandbox_flattree_defconfig | 1 - configs/sandbox_noblk_defconfig | 1 - configs/sandbox_spl_defconfig | 1 - 6 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Kconfig b/Kconfig index dca9bb4e432..477a3c4ae03 100644 --- a/Kconfig +++ b/Kconfig @@ -125,6 +125,7 @@ config SYS_BOOT_GET_KBD config SYS_MALLOC_F bool "Enable malloc() pool before relocation" default y if DM + help Before relocation, memory is very limited on many platforms. Still, we can provide a small malloc() pool if needed. Driver model in @@ -135,6 +136,7 @@ config SYS_MALLOC_F_LEN hex "Size of malloc() pool before relocation" depends on SYS_MALLOC_F default 0x1000 if AM33XX + default 0x2800 if SANDBOX default 0x400 help Before relocation, memory is very limited on many platforms. Still, diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index e6680d9a594..aede14569df 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -1,5 +1,4 @@ CONFIG_SYS_TEXT_BASE=0 -CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_SANDBOX64=y CONFIG_DISTRO_DEFAULTS=y CONFIG_NR_DRAM_BANKS=1 diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 5a744f47917..4d65a01dc5b 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -1,5 +1,4 @@ CONFIG_SYS_TEXT_BASE=0 -CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_DEBUG_UART=y CONFIG_DISTRO_DEFAULTS=y CONFIG_NR_DRAM_BANKS=1 diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 756b839b081..4f3757c8bc5 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -1,5 +1,4 @@ CONFIG_SYS_TEXT_BASE=0 -CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_DISTRO_DEFAULTS=y CONFIG_NR_DRAM_BANKS=1 CONFIG_FIT=y diff --git a/configs/sandbox_noblk_defconfig b/configs/sandbox_noblk_defconfig index e71e2d3860c..6c7d08e42e1 100644 --- a/configs/sandbox_noblk_defconfig +++ b/configs/sandbox_noblk_defconfig @@ -1,5 +1,4 @@ CONFIG_SYS_TEXT_BASE=0 -CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_DISTRO_DEFAULTS=y CONFIG_NR_DRAM_BANKS=1 CONFIG_FIT=y diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index 452a2ef4a50..2f838125289 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -1,7 +1,6 @@ CONFIG_SYS_TEXT_BASE=0 CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y -CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_SPL=y From patchwork Mon Dec 3 11:37:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006843 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BpiSvN51"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jmf1qqZz9s55 for ; Mon, 3 Dec 2018 22:43:14 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CCE00C22184; Mon, 3 Dec 2018 11:40:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A38CEC2227E; Mon, 3 Dec 2018 11:38:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DE2EAC22168; Mon, 3 Dec 2018 11:38:19 +0000 (UTC) Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by lists.denx.de (Postfix) with ESMTPS id C6D30C221ED for ; Mon, 3 Dec 2018 11:38:18 +0000 (UTC) Received: by mail-io1-f72.google.com with SMTP id n25so10801234iog.13 for ; Mon, 03 Dec 2018 03:38:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=t2b7FOvPE3jTBSZgfLF3GIQahvFWGhyFvl4XrO0QIJ0=; b=BpiSvN512Z6gy6KdC0ltDCTvnT7QeN0vyMbq7gFVYr7SzjJ5OuB7lTymfjcowoJY6Q Jbm6TVPbAMRn75EB+b2hW0WlS1g3+UzvUpNboL0SNyfZWHBivdSuuYCyxiKbjIJH62Dn 6BKbQEQhu53tyW7GoyPNWBOVEQqL0pxJ/B/CU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=t2b7FOvPE3jTBSZgfLF3GIQahvFWGhyFvl4XrO0QIJ0=; b=ZHx/wuvCGxc6CBNGWANWQQ92DrvUC5ji+7Fua5wIskxEX80uDhBD+C3llj0M//YTZx HtEeP0EVpfi3Je1J5hE8M3sLq2JjuXhUlAtTnJ2gXXSz4RXhZouYEs+WgtOSlf1L3EUl BoK4Pzyd7TI97/vlJO2KsaGpuYO1kHzeBN6J4E/WuRiatW3a25qZXXGoY/RtpCm5423i Hjp4eQMmUb5VArncFtMckshu1pks6A3d91lrXbySakBBmMbNCViBjdDjpzx3RbAus/3f DPWKPYzforP0fdaoaqCanjm1iShUEQ+4pzE0rvvwcVTPGIDsruiMgIkPu5EXncxiT+2Y /KEw== X-Gm-Message-State: AA+aEWZz3SrMcp5LrscW2T11u93MyHu9QrXStF82XeXW+wXA58Yg1kTY GEAgzVc9bRh2dAnMt3W1eILav9twFvcqd40r X-Google-Smtp-Source: AFSGD/UiTi55U+XHeyPAX1myoLWeDop7Mq20uK7LVMIBRMVHrJWhppg+6+k8/QpHk6uVA65WX7V3K5qTcExcGtIr X-Received: by 2002:a24:a94:: with SMTP id 142mr331294itw.15.1543837097380; Mon, 03 Dec 2018 03:38:17 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:18 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-3-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 02/30] snow: Expand U-Boot size X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Now that we have EFI, etc. enabled, U-Boot is larger than it was. Expand the region allocated for it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- arch/arm/dts/exynos5250-snow.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/exynos5250-snow.dts b/arch/arm/dts/exynos5250-snow.dts index 29c13c1257e..e99f6e72bf6 100644 --- a/arch/arm/dts/exynos5250-snow.dts +++ b/arch/arm/dts/exynos5250-snow.dts @@ -88,7 +88,7 @@ ro-boot { label = "u-boot"; - reg = <0x6000 0x9a000>; + reg = <0x6000 0xb0000>; read-only; type = "blob boot,dtb"; required; From patchwork Mon Dec 3 11:37:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006840 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PtppKIGD"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jkg6C5Zz9s55 for ; Mon, 3 Dec 2018 22:41:31 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6A620C221D5; Mon, 3 Dec 2018 11:39:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CEAB8C22225; Mon, 3 Dec 2018 11:38:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D397AC2215F; Mon, 3 Dec 2018 11:38:20 +0000 (UTC) Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by lists.denx.de (Postfix) with ESMTPS id 19A58C2218F for ; Mon, 3 Dec 2018 11:38:20 +0000 (UTC) Received: by mail-vs1-f72.google.com with SMTP id w22so7059631vsj.15 for ; Mon, 03 Dec 2018 03:38:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7S+0Py9xk96prkQP2kr6MMSzfzZgP6sYwjrMJ7KaKuQ=; b=PtppKIGD/fymnSdDcZtTDnVk+YmIBlHboUXoZTq+3btk6zJ2BI8XUwxSdU93iaQ876 0l1+huSENXGHk/9e17KCuUD/lAw0Lw/zyNh/zEDslCSo7Ni+K9jagVQavMGSbd7eORyV 1jj2j0XjmzDif+D8WTcOGfJFOclFrZ3PBEdNg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7S+0Py9xk96prkQP2kr6MMSzfzZgP6sYwjrMJ7KaKuQ=; b=YGx4ojCh9gNX7jwtIYu1Pp3xVQt47xxGsh006titYh/eDXd55prhfmoa5yjWTyh4/T B5ZZpgbOQWGEFR1uuxxEAUZuZSbb+Ukbp0sY4MrThTMe57s28R8KzsJdtd75b+5jVy3H V5xjUx67E3S8V00nV24iIlbaS+mMm8Mk6VBOTl2EdNuA7QhEojbEdSXDUQo/XR8rVcy3 REt/HRi5ZkaxBrTsetPuhvMiE0UULiJ0tIo7wZGNOhf9BoWkjTL7o42Rs7L1g/9oRzr+ 7TdHG2Po8nk4AIEnvOyAHMC1fi+yrZn5qyfmzTiRXMCxnJm7WNSn3Z1ra4+GURZJLlkn SxXw== X-Gm-Message-State: AA+aEWaD7E/n95Y66nECJDJZkUghb0ugzklxUEF8ZZcHf2hWtLWEAYD3 bxJdrYSHxnq+zrG1u4+YTbxIpkIHIWnM1ylg X-Google-Smtp-Source: AFSGD/WBU5P2wPQMPRYOr0nNEyz8OwY1UcAb64o0mZWu6/aWpGig7j1+mB2zo5YpcY6JuLDp/iKcgnztLQSuPWxo X-Received: by 2002:ab0:9d6:: with SMTP id e22mr13586465uah.11.1543837098910; Mon, 03 Dec 2018 03:38:18 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:19 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-4-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 03/30] dm: sound: samsung: Make local function static X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Several functions are not exported from this file. Make them static so this is clear. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/samsung-i2s.c | 8 ++++---- drivers/sound/wm8994.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c index f39abf5e2a9..8f5cd191a2b 100644 --- a/drivers/sound/samsung-i2s.c +++ b/drivers/sound/samsung-i2s.c @@ -111,7 +111,7 @@ static void i2s_set_bitclk_framesize(struct i2s_reg *i2s_reg, unsigned bfs) * @param flush Tx fifo flush command (0x00 - do not flush * 0x80 - flush tx fifo) */ -void i2s_fifo(struct i2s_reg *i2s_reg, unsigned int flush) +static void i2s_fifo(struct i2s_reg *i2s_reg, unsigned int flush) { /* Flush the FIFO */ setbits_le32(&i2s_reg->fic, flush); @@ -126,7 +126,7 @@ void i2s_fifo(struct i2s_reg *i2s_reg, unsigned int flush) * * @return int value 0 for success, -1 in case of error */ -int i2s_set_sysclk_dir(struct i2s_reg *i2s_reg, int dir) +static int i2s_set_sysclk_dir(struct i2s_reg *i2s_reg, int dir) { unsigned int mod = readl(&i2s_reg->mod); @@ -148,7 +148,7 @@ int i2s_set_sysclk_dir(struct i2s_reg *i2s_reg, int dir) * * @return int value 0 for success, -1 in case of error */ -int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt) +static int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt) { unsigned int mod = readl(&i2s_reg->mod); unsigned int tmp = 0; @@ -225,7 +225,7 @@ int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt) * * @return int value 0 for success, -1 in case of error */ -int i2s_set_samplesize(struct i2s_reg *i2s_reg, unsigned int blc) +static int i2s_set_samplesize(struct i2s_reg *i2s_reg, unsigned int blc) { unsigned int mod = readl(&i2s_reg->mod); diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index aaaa3241aa1..e671f6b85ec 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -156,7 +156,7 @@ static int wm8994_update_bits(unsigned int reg, unsigned short mask, * * @return -1 for error and 0 Success. */ -int wm8994_set_fmt(int aif_id, unsigned int fmt) +static int wm8994_set_fmt(int aif_id, unsigned int fmt) { int ms_reg; int aif_reg; From patchwork Mon Dec 3 11:37:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006833 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="IVrVzP7d"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jj22SzSz9s55 for ; Mon, 3 Dec 2018 22:40:06 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 132F0C224C2; Mon, 3 Dec 2018 11:39:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C5F9DC221CA; Mon, 3 Dec 2018 11:38:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9A59DC22168; Mon, 3 Dec 2018 11:38:22 +0000 (UTC) Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by lists.denx.de (Postfix) with ESMTPS id 5E2ACC221DC for ; Mon, 3 Dec 2018 11:38:21 +0000 (UTC) Received: by mail-qt1-f197.google.com with SMTP id u20so13072109qtk.6 for ; Mon, 03 Dec 2018 03:38:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xx8d1KaorGisEwqNv0c/ZKZr52Htf3uMHjXfrrG3kwM=; b=IVrVzP7dDh89x4le84LIAf/HI/evbjM9qEV95DYyym8iiGzFE1qkwLUs2zgOxfJqRg xIi4EekjZ53ZwS2aPZfjOnTd+urzv7EZSuBCz71Kl2zlFeoW4IpQ3sQJF0nmHvBqoLZ1 jT7GJw4PXge6tNmdbaHc0JobURDpT1bfizREI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xx8d1KaorGisEwqNv0c/ZKZr52Htf3uMHjXfrrG3kwM=; b=s2qEfzb4HnboIAB+7ZFLT+x9N/SFGFsVgwEfCHcSo4D0OBdLY43Wegywq1D+DQ4cJC sr/vqdLJotyrtFrG+0gqtzqzi9XKonEXyChftxh2WEIacL3VZfqgugAlcweerbb/WiuC w9akjP4zs/jRZ7ujyOL0Odj6JNk+nqcAYF+QVkCYJI6TnI+stf72hQ3nRjh5gUrZP6+I uMe5rq7wCvUAqppr7zWtY30oBWymh3HLmklRNm/QyRt2pGd3ydzTjJ1B913ewZonctdt hCoXCxaiO9Qmb1SXYb6//NmJGLQfRFca0yS/1yxOnp55hUhidaWkP5d64kR/Cjj6vcwp d6PA== X-Gm-Message-State: AA+aEWZZAi879CpGoO4k3ezQHxjhDoFKiL+IZfEW/bPQC9THXsUPwH4j d/xfDMAxcvERi7WhUrbpAfofKhP5qo++MBlD X-Google-Smtp-Source: AFSGD/Vhb9FA72VUf2Srn9eMtWRnbyQDg+zZiWZNOVQIJX5k6mVtYmk7pVNE+KzFT7ExWUc3Tg705Yk/N8KpU777 X-Received: by 2002:a37:4d55:: with SMTP id a82mr11604931qkb.41.1543837100351; Mon, 03 Dec 2018 03:38:20 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:20 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-5-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 04/30] dm: sound: Rename en_sound_codec to sound_codec X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The en_ prefix is confusing and not needed. Drop it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- include/sound.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sound.h b/include/sound.h index 77bfe6a93b2..149e12dbc60 100644 --- a/include/sound.h +++ b/include/sound.h @@ -8,7 +8,7 @@ #define __SOUND_H__ /* sound codec enum */ -enum en_sound_codec { +enum sound_codec { CODEC_WM_8994, CODEC_WM_8995, CODEC_MAX_98095, @@ -25,7 +25,7 @@ enum sound_compat { struct sound_codec_info { int i2c_bus; int i2c_dev_addr; - enum en_sound_codec codec_type; + enum sound_codec codec_type; }; /* From patchwork Mon Dec 3 11:37:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006834 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="O3zOb60G"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jjb73qvz9sCX for ; Mon, 3 Dec 2018 22:40:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 94EF1C2248D; Mon, 3 Dec 2018 11:39:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C4C99C22005; Mon, 3 Dec 2018 11:38:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B3F83C21F60; Mon, 3 Dec 2018 11:38:24 +0000 (UTC) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by lists.denx.de (Postfix) with ESMTPS id 2B6CFC221DF for ; Mon, 3 Dec 2018 11:38:23 +0000 (UTC) Received: by mail-it1-f199.google.com with SMTP id j202so5969685itj.1 for ; Mon, 03 Dec 2018 03:38:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0TXXQSh0E+xq5VTn/8Vd+/8J3608mDpRDoGszeBQYsE=; b=O3zOb60GXlHfdumMDo1WDHvpbMmb+PcZ2IJP0E7Gh6gpxa0+ivrfQADjVD5fK7zkvh mLki7HNhOytDTlWU4ZVSkxfHX2a+MPWgcvrxkP8XU5gYikzwDT123v6Xm8halRU9/Qyj S4wUXQLkuWGrqlTD6dQr5DYIFv0H5ZTSoZYoQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=0TXXQSh0E+xq5VTn/8Vd+/8J3608mDpRDoGszeBQYsE=; b=Q3aDRfoHhJihjome9PWvcI/QhXJ3ksRuPSq0eTAhMgJM1KmtP6M9ZevL0Opuxa8B6j RiNbTb+O7m7KvhOYiOVBUeR6zWer/TxL+c5+eKS7By1kibiaVckvvMwHncdkS+OSrBTR 51rTOIZ6YmS1blqdyvEwntJ2JYikdjEdbg/TaqojgHcCNU9ue+d+OyGXD9E7zQt6Xi1t ZEokbu32WZBrEdzLjikP713lQyCu0mjmPkGL6dO3CrhWqEBBZ2hQ5lh34rA2uFt6jrob KF56mgGlRgUbFoAsqrVBlx/K/SZRf2QrD0BaWYBNoqDFGe35mWgkM26Ic9khHkwXHLzw biZg== X-Gm-Message-State: AA+aEWakB81YQUwuA9RLBl3aZljRaM/htmLOSabJNIYka5OdVrKRvyDt 28iFSygCydLeqquoh0DO986BSjbNsNbTxjgA X-Google-Smtp-Source: AFSGD/UxZHSnQ3k8VOPTyQLmlCtk7o31jwXYek9avFwWWAlRCknLztZaFt3vAfbatJOhmwzOIZ1wfKhGKidv1yga X-Received: by 2002:a24:50c:: with SMTP id 12mr6666191itl.18.1543837101957; Mon, 03 Dec 2018 03:38:21 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:21 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-6-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 05/30] dm: sound: Drop unused pre-device-tree code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" CONFIG_OF_CONTROL is enabled for all boards that use sound, so remove the dead code. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/max98095.c | 6 ------ drivers/sound/wm8994.c | 6 ------ 2 files changed, 12 deletions(-) diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index 7c37bd07015..d05c261a399 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -522,7 +522,6 @@ static int get_max98095_codec_values(struct sound_codec_info *pcodec_info, const void *blob) { int error = 0; -#if CONFIG_IS_ENABLED(OF_CONTROL) enum fdt_compat_id compat; int node; int parent; @@ -556,11 +555,6 @@ static int get_max98095_codec_values(struct sound_codec_info *pcodec_info, 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_MAX_98095; if (error == -1) { debug("fail to get max98095 codec node properties\n"); diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index e671f6b85ec..34bc4eb516f 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -813,7 +813,6 @@ static int get_codec_values(struct sound_codec_info *pcodec_info, const void *blob) { int error = 0; -#if CONFIG_IS_ENABLED(OF_CONTROL) enum fdt_compat_id compat; int node; int parent; @@ -847,11 +846,6 @@ static int get_codec_values(struct sound_codec_info *pcodec_info, 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; From patchwork Mon Dec 3 11:37:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006831 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bjtKlgDL"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jgK2MhSz9s55 for ; Mon, 3 Dec 2018 22:38:37 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id EDC21C22193; Mon, 3 Dec 2018 11:38:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D208AC22139; Mon, 3 Dec 2018 11:38:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7753FC21F60; Mon, 3 Dec 2018 11:38:25 +0000 (UTC) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by lists.denx.de (Postfix) with ESMTPS id 6BA6DC22168 for ; Mon, 3 Dec 2018 11:38:24 +0000 (UTC) Received: by mail-io1-f70.google.com with SMTP id q18so4874936iog.18 for ; Mon, 03 Dec 2018 03:38:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=sRR3QTHJJZ+uZIp2qTIHCaxioFfYlrvnGCwP90iv5gw=; b=bjtKlgDLBiJXnj1XgAPSA8XeyOBRrJ7+M0CrJpiS9otq9oIMPhvd11OB5RvxRpTULO Kb8CffqyF/VVwmSiTDtNRNEeOcyl3xmhEbsy2iebEHF3LEkb9xbg38zGxYtqVzvDEfp1 nHZkesTDRVt+cDURvvKp5+kT4KIaLzLGubUYQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=sRR3QTHJJZ+uZIp2qTIHCaxioFfYlrvnGCwP90iv5gw=; b=GN+vVsGUnGeVzp1Hs9VTc5FE+IoI0IIqujzpFPDSnPzoWwqjTst+pZ9+mbbkOmN3za nRbjPj8iyxmZO3GaFNAi1QxsV2/UnjwbjNdy47q3O1v+mlRmpwFQ27ffQ7m0l5M3FvEk 2Y11EBv+/exJUhKKDMiK5gaIykJGyRvIyJhIOZww2vSvdX5iRPpRPYLSailsPXnj8UDk tSKkYPwvhsO7PaabKWP00tsdnKfWvEnw74Lj3R9L4AR2DotM0o/humgBwzXgn4auF7Ao M6cO9JocbyYf0JMrdaDC9UTMKNN8ExORlpURw/9+kls2n0yZSMoyLx35EoPjVj8tFt2x z/Wg== X-Gm-Message-State: AA+aEWYzdFzWAj5mmJlM0TvHky2q4YSUOXp12omM8PdxR6xFSUzWeqGP 2DOaVl1uj87i0iTVVtGdq2gtbkpkl7tost15 X-Google-Smtp-Source: AFSGD/VQxMJSF1Z2iRC2cc9jNiEJBaRvbLfizMxfPKGuGPQrDsKxeBW02RIYnS0N27Rza2AafEUbb8yUX2lKl3Wx X-Received: by 2002:a24:7281:: with SMTP id x123-v6mr173282itc.27.1543837103425; Mon, 03 Dec 2018 03:38:23 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:22 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-7-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 06/30] dm: sound: samsung: Rename i2stx_info to samsung_i2s_priv X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This struct is only used by the Samsung I2C driver and should move into that driver. For now, rename it so it is clear that is driver-private info. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/samsung-i2s.c | 6 +++--- drivers/sound/sound-i2s.c | 10 +++++----- include/i2s.h | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c index 8f5cd191a2b..7f4388137a5 100644 --- a/drivers/sound/samsung-i2s.c +++ b/drivers/sound/samsung-i2s.c @@ -255,8 +255,8 @@ static int i2s_set_samplesize(struct i2s_reg *i2s_reg, unsigned int blc) return 0; } -int i2s_transfer_tx_data(struct i2stx_info *pi2s_tx, unsigned int *data, - unsigned long data_size) +int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, unsigned int *data, + unsigned long data_size) { int i; int start; @@ -293,7 +293,7 @@ int i2s_transfer_tx_data(struct i2stx_info *pi2s_tx, unsigned int *data, return 0; } -int i2s_tx_init(struct i2stx_info *pi2s_tx) +int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx) { int ret; struct i2s_reg *i2s_reg = diff --git a/drivers/sound/sound-i2s.c b/drivers/sound/sound-i2s.c index f0f0b79bc52..106842a23db 100644 --- a/drivers/sound/sound-i2s.c +++ b/drivers/sound/sound-i2s.c @@ -20,15 +20,15 @@ #define SOUND_400_HZ 400 #define SOUND_BITS_IN_BYTE 8 -static struct i2stx_info g_i2stx_pri; +static struct samsung_i2s_priv g_i2stx_pri; /* * get_sound_i2s_values gets values for i2s parameters * - * @param i2stx_info i2s transmitter transfer param structure + * @param samsung_i2s_priv i2s transmitter transfer param structure * @param blob FDT blob if enabled else NULL */ -static int get_sound_i2s_values(struct i2stx_info *i2s, const void *blob) +static int get_sound_i2s_values(struct samsung_i2s_priv *i2s, const void *blob) { int node; int error = 0; @@ -97,7 +97,7 @@ static int get_sound_i2s_values(struct i2stx_info *i2s, const void *blob) * @param pi2s_tx i2s parameters required by codec * @return int value, 0 for success */ -static int codec_init(const void *blob, struct i2stx_info *pi2s_tx) +static int codec_init(const void *blob, struct samsung_i2s_priv *pi2s_tx) { int ret; const char *codectype; @@ -145,7 +145,7 @@ static int codec_init(const void *blob, struct i2stx_info *pi2s_tx) int sound_init(const void *blob) { int ret; - struct i2stx_info *pi2s_tx = &g_i2stx_pri; + struct samsung_i2s_priv *pi2s_tx = &g_i2stx_pri; /* Get the I2S Values */ if (get_sound_i2s_values(pi2s_tx, blob) < 0) { diff --git a/include/i2s.h b/include/i2s.h index e6d45ec26d7..800473abd9c 100644 --- a/include/i2s.h +++ b/include/i2s.h @@ -76,7 +76,7 @@ struct i2s_reg { }; /* This structure stores the i2s related information */ -struct i2stx_info { +struct samsung_i2s_priv { unsigned int rfs; /* LR clock frame size */ unsigned int bfs; /* Bit slock frame size */ unsigned int audio_pll_clk; /* Audio pll frequency in Hz */ @@ -96,8 +96,8 @@ struct i2stx_info { * * @return int value 0 for success, -1 in case of error */ -int i2s_transfer_tx_data(struct i2stx_info *pi2s_tx, unsigned *data, - unsigned long data_size); +int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, uint *data, + unsigned long data_size); /* * Initialise i2s transmiter @@ -106,6 +106,6 @@ int i2s_transfer_tx_data(struct i2stx_info *pi2s_tx, unsigned *data, * * @return int value 0 for success, -1 in case of error */ -int i2s_tx_init(struct i2stx_info *pi2s_tx); +int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx); #endif /* __I2S_H__ */ From patchwork Mon Dec 3 11:37:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006841 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BjL67UIK"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jmB0P0kz9s55 for ; Mon, 3 Dec 2018 22:42:49 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 956DCC222D2; Mon, 3 Dec 2018 11:40:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 77B72C221BD; Mon, 3 Dec 2018 11:38:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EEB77C2218E; Mon, 3 Dec 2018 11:38:26 +0000 (UTC) Received: from mail-vs1-f70.google.com (mail-vs1-f70.google.com [209.85.217.70]) by lists.denx.de (Postfix) with ESMTPS id 53AC7C22214 for ; Mon, 3 Dec 2018 11:38:26 +0000 (UTC) Received: by mail-vs1-f70.google.com with SMTP id y139so7077901vsc.14 for ; Mon, 03 Dec 2018 03:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jOo6Xn2ElFQ5NdLOlL/sQY8VUjQAMmwq1bQyOku8EGk=; b=BjL67UIKgvmYad3e/Etl01xxvcOPgbrZvdlPhzJZy85+tviUbZu6Vpr1T4UW6tQotK RiMhs+KyG5+FHg9AII69burLTlrpW6uHvo7LDwKhdWKSfnDQFAv8A7f7gC1LeilahrRZ t75dRz16TzXbIXmXwVIhxeVnWpA3IX27fnfL8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jOo6Xn2ElFQ5NdLOlL/sQY8VUjQAMmwq1bQyOku8EGk=; b=f3G2cWaV0B/VN4baxD8ujMYVPuWnOMP++DMFF01jWOGUOKUtCYICV1yyWrtjdz67TV dQRVIzG0Y9o+KX4hJwdJuyiX+NH/oOSv7lgQR4TDcwnDWhzA567GGkwaUGwC2waTBB+K f8hDwDqdI6/2dAa/Qhl0aHlcz2GSm49tsSz4YdCLeJOTMuDEDuT954+ZO2Y9vbZy2DNz 8esNGIL+CE9eJg1KpjYOmHDwy+Jl1WwtLvj8jxbaW9q1Kx6fgAzJLX23xZho1qXGEQBs R384jV88wgkzinWI0abLccrSk0WAtHH23pwgHOyvGpKY2TSEzaJOJiXeZ69xPVr8uH8V YLQg== X-Gm-Message-State: AA+aEWaUlfjcY2pChJcPeyzc3ZWNVdeb8hhtHbQUxvW45HFQyB0yLVsc H7Gm726Ix/rDuq4YGckkiMQVxoOB0XxNKPm/ X-Google-Smtp-Source: AFSGD/W0XI4dMi4k3bN20+mvdR6+57/mvrL8Pmk3qQ3u0mPTeHhAPp1jgprHkTthr5N7AHOnFPKK1vu6Yqqo94OT X-Received: by 2002:a1f:9387:: with SMTP id v129mr13123109vkd.15.1543837105390; Mon, 03 Dec 2018 03:38:25 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:23 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-8-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 07/30] dm: sound: Drop codec_type X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This field is not really used. It is always set to a known value. Drop it to simplify the code. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/max98095.c | 14 -------------- drivers/sound/wm8994.c | 10 ---------- include/sound.h | 9 --------- 3 files changed, 33 deletions(-) diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index d05c261a399..efaaeb8f3b8 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -24,12 +24,7 @@ #include "i2s.h" #include "max98095.h" -enum max98095_type { - MAX98095, -}; - struct max98095_priv { - enum max98095_type devtype; unsigned int sysclk; unsigned int rate; unsigned int fmt; @@ -484,14 +479,6 @@ static int max98095_do_init(struct sound_codec_info *pcodec_info, /* shift the device address by 1 for 7 bit addressing */ g_max98095_i2c_dev_addr = pcodec_info->i2c_dev_addr >> 1; - if (pcodec_info->codec_type == CODEC_MAX_98095) { - g_max98095_info.devtype = MAX98095; - } else { - debug("%s: Codec id [%d] not defined\n", __func__, - pcodec_info->codec_type); - return -1; - } - ret = max98095_device_init(&g_max98095_info, aif_id); if (ret < 0) { debug("%s: max98095 codec chip init failed\n", __func__); @@ -555,7 +542,6 @@ static int get_max98095_codec_values(struct sound_codec_info *pcodec_info, debug("%s: Unknown compat id %d\n", __func__, compat); return -1; } - pcodec_info->codec_type = CODEC_MAX_98095; if (error == -1) { debug("fail to get max98095 codec node properties\n"); return -1; diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index 34bc4eb516f..2e84e92a2e0 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -847,8 +847,6 @@ static int get_codec_values(struct sound_codec_info *pcodec_info, return -1; } - pcodec_info->codec_type = CODEC_WM_8994; - if (error == -1) { debug("fail to get wm8994 codec node properties\n"); return -1; @@ -875,14 +873,6 @@ int wm8994_init(const void *blob, enum en_audio_interface aif_id, g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr; wm8994_i2c_init(pcodec_info->i2c_bus); - if (pcodec_info->codec_type == CODEC_WM_8994) { - g_wm8994_info.type = WM8994; - } else { - debug("%s: Codec id [%d] not defined\n", __func__, - pcodec_info->codec_type); - return -1; - } - ret = wm8994_device_init(&g_wm8994_info, aif_id); if (ret < 0) { debug("%s: wm8994 codec chip init failed\n", __func__); diff --git a/include/sound.h b/include/sound.h index 149e12dbc60..c4ac3193fe7 100644 --- a/include/sound.h +++ b/include/sound.h @@ -7,14 +7,6 @@ #ifndef __SOUND_H__ #define __SOUND_H__ -/* sound codec enum */ -enum sound_codec { - CODEC_WM_8994, - CODEC_WM_8995, - CODEC_MAX_98095, - CODEC_MAX -}; - /* sound codec enum */ enum sound_compat { AUDIO_COMPAT_SPI, @@ -25,7 +17,6 @@ enum sound_compat { struct sound_codec_info { int i2c_bus; int i2c_dev_addr; - enum sound_codec codec_type; }; /* From patchwork Mon Dec 3 11:37:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006842 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="dyr81ony"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jmM6cKVz9s55 for ; Mon, 3 Dec 2018 22:42:59 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6411EC221ED; Mon, 3 Dec 2018 11:41:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5B453C22216; Mon, 3 Dec 2018 11:38:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B4299C21F60; Mon, 3 Dec 2018 11:38:28 +0000 (UTC) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by lists.denx.de (Postfix) with ESMTPS id D5550C22185 for ; Mon, 3 Dec 2018 11:38:27 +0000 (UTC) Received: by mail-it1-f199.google.com with SMTP id k133so8356769ite.4 for ; Mon, 03 Dec 2018 03:38:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=lSgqbbcG7bT5eCPLkW1zRIdSnKsHkL+xtRz7fAUviCI=; b=dyr81ony6uxEm34OBE3dTtuQIo1hN+6vFTOLe4dg2u24RKxjPU5WJ5D7WDMxqw5a/k gP69D9IDN11A+6aHG38VRw6SNuaLSAWcd9P0Zf9BUGOsb8VqtJXm+Bl0P7jbEkaQ0Ilm oGORZu/y7e6d3N2fwuSY2ponktYfDxvokPKrc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lSgqbbcG7bT5eCPLkW1zRIdSnKsHkL+xtRz7fAUviCI=; b=MMgH0Bqx0fcxetsy6BogDXTmaR2tPl5Av+PC40OKq4ebD1chbjnuUDl1WE18S64EEO OXrrsYYTerRKUv4YODD443G0rijvxAN+224hd2QqTnFSG2PFp0xDagQ6z7k2xjuUqB0t ZnGBr/24cL1DbuDJDQZijrZk0WTM2Pe7xZVtfCiqBMbcvUEsmYTKXUOaxPmV9DHikg7E LY51TSa4rHGR2EOuYjU54NnuCg5UgIUWnFXibDWdvkJ2L9p2/H/hLr9zio0Qv5WSiUTh kFL2WszIIFU+RJAo8GzdmrxtY/p2EbFLSoVDBINPptvvgXA/rM0b+ndeSB+PNvcvy6NI 8zUg== X-Gm-Message-State: AA+aEWbaM3kdvYD6U6+wq5iCtOobwTfhH22PPZcnVh3QQCKIgyzA0+Jn CDRMTOZx3HzeppVT+wX4UyjGwhd4U4pZV88e X-Google-Smtp-Source: AFSGD/XEqAZRsM9Ih8vyWZUZeTq95EnAy5+UwM+E2Cmif0XEL1KlDGQHUnh9OrHygRR8VZm9RTkkNpGIFZ7GED7Y X-Received: by 2002:a24:7281:: with SMTP id x123-v6mr173356itc.27.1543837106842; Mon, 03 Dec 2018 03:38:26 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:24 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-9-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 08/30] dm: sound: wm8994: Pass private data to internal functions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present the driver-private data is global. To allow this code to be used with driver model, change it to pass the data down to each function. Use the name 'priv' consistently throughout. Also rename wm8994_update_bits() to wm8994_bic_or() which is more descriptive and shorter, thus breaking fewer lines with the parameter addition. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/wm8994.c | 296 +++++++++++++++++++++-------------------- 1 file changed, 154 insertions(+), 142 deletions(-) diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index 2e84e92a2e0..3f56af9db4b 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -77,12 +77,14 @@ static void wm8994_i2c_init(int bus_no) /* * Writes value to a device register through i2c * + * @param priv Private data for driver * @param reg reg number to be write * @param data data to be writen to the above registor * * @return int value 1 for change, 0 for no change or negative error code. */ -static int wm8994_i2c_write(unsigned int reg, unsigned short data) +static int wm8994_i2c_write(struct wm8994_priv *priv, unsigned int reg, + unsigned short data) { unsigned char val[2]; @@ -96,12 +98,14 @@ static int wm8994_i2c_write(unsigned int reg, unsigned short data) /* * Read a value from a device register through i2c * + * @param priv Private data for driver * @param reg reg number to be read * @param data address of read data to be stored * * @return int value 0 for success, -1 in case of error. */ -static unsigned int wm8994_i2c_read(unsigned int reg , unsigned short *data) +static unsigned int wm8994_i2c_read(struct wm8994_priv *priv, unsigned int reg, + unsigned short *data) { unsigned char val[2]; int ret; @@ -123,6 +127,7 @@ static unsigned int wm8994_i2c_read(unsigned int reg , unsigned short *data) /* * update device register bits through i2c * + * @param priv Private data for driver * @param reg codec register * @param mask register mask * @param value new value @@ -130,18 +135,18 @@ static unsigned int wm8994_i2c_read(unsigned int reg , unsigned short *data) * @return int value 1 if change in the register value, * 0 for no change or negative error code. */ -static int wm8994_update_bits(unsigned int reg, unsigned short mask, - unsigned short value) +static int wm8994_bic_or(struct wm8994_priv *priv, unsigned int reg, + unsigned short mask, unsigned short value) { int change , ret = 0; unsigned short old, new; - if (wm8994_i2c_read(reg, &old) != 0) + if (wm8994_i2c_read(priv, reg, &old) != 0) return -1; new = (old & ~mask) | (value & mask); change = (old != new) ? 1 : 0; if (change) - ret = wm8994_i2c_write(reg, new); + ret = wm8994_i2c_write(priv, reg, new); if (ret < 0) return ret; @@ -151,12 +156,13 @@ static int wm8994_update_bits(unsigned int reg, unsigned short mask, /* * Sets i2s set format * + * @param priv wm8994 information * @param aif_id Interface ID * @param fmt i2S format * * @return -1 for error and 0 Success. */ -static int wm8994_set_fmt(int aif_id, unsigned int fmt) +static int wm8994_set_fmt(struct wm8994_priv *priv, int aif_id, uint fmt) { int ms_reg; int aif_reg; @@ -254,12 +260,13 @@ static int wm8994_set_fmt(int aif_id, unsigned int fmt) return -1; } - error = wm8994_update_bits(aif_reg, WM8994_AIF1_BCLK_INV | - WM8994_AIF1_LRCLK_INV_MASK | WM8994_AIF1_FMT_MASK, aif); + error = wm8994_bic_or(priv, aif_reg, WM8994_AIF1_BCLK_INV | + WM8994_AIF1_LRCLK_INV_MASK | + WM8994_AIF1_FMT_MASK, aif); - error |= wm8994_update_bits(ms_reg, WM8994_AIF1_MSTR_MASK, ms); - error |= wm8994_update_bits(aif_clk, WM8994_AIF1CLK_ENA_MASK, - WM8994_AIF1CLK_ENA); + error |= wm8994_bic_or(priv, ms_reg, WM8994_AIF1_MSTR_MASK, ms); + error |= wm8994_bic_or(priv, aif_clk, WM8994_AIF1CLK_ENA_MASK, + WM8994_AIF1CLK_ENA); if (error < 0) { debug("%s: codec register access error\n", __func__); return -1; @@ -271,7 +278,7 @@ static int wm8994_set_fmt(int aif_id, unsigned int fmt) /* * Sets hw params FOR WM8994 * - * @param wm8994 wm8994 information pointer + * @param priv wm8994 information pointer * @param aif_id Audio interface ID * @param sampling_rate Sampling rate * @param bits_per_sample Bits per sample @@ -279,9 +286,9 @@ static int wm8994_set_fmt(int aif_id, unsigned int fmt) * * @return -1 for error and 0 Success. */ -static int wm8994_hw_params(struct wm8994_priv *wm8994, int aif_id, - unsigned int sampling_rate, unsigned int bits_per_sample, - unsigned int channels) +static int wm8994_hw_params(struct wm8994_priv *priv, int aif_id, + uint sampling_rate, uint bits_per_sample, + uint channels) { int aif1_reg; int aif2_reg; @@ -349,12 +356,10 @@ static int wm8994_hw_params(struct wm8994_priv *wm8994, int aif_id, /* AIFCLK/fs ratio; look for a close match in either direction */ best = 0; - best_val = abs((fs_ratios[0] * sampling_rate) - - wm8994->aifclk[id]); + best_val = abs((fs_ratios[0] * sampling_rate) - priv->aifclk[id]); for (i = 1; i < ARRAY_SIZE(fs_ratios); i++) { - cur_val = abs((fs_ratios[i] * sampling_rate) - - wm8994->aifclk[id]); + cur_val = abs(fs_ratios[i] * sampling_rate - priv->aifclk[id]); if (cur_val >= best_val) continue; best = i; @@ -371,7 +376,7 @@ static int wm8994_hw_params(struct wm8994_priv *wm8994, int aif_id, */ best = 0; for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) { - cur_val = (wm8994->aifclk[id] * 10 / bclk_divs[i]) - bclk_rate; + cur_val = (priv->aifclk[id] * 10 / bclk_divs[i]) - bclk_rate; if (cur_val < 0) /* BCLK table is sorted */ break; best = i; @@ -383,10 +388,10 @@ static int wm8994_hw_params(struct wm8994_priv *wm8994, int aif_id, return -1; } - bclk_rate = wm8994->aifclk[id] * 10 / bclk_divs[best]; + bclk_rate = priv->aifclk[id] * 10 / bclk_divs[best]; bclk |= best << WM8994_AIF1_BCLK_DIV_SHIFT; - if (wm8994_i2c_read(aif1_reg, ®_data) != 0) { + if (wm8994_i2c_read(priv, aif1_reg, ®_data) != 0) { debug("%s: AIF1 register read Failed\n", __func__); return -1; } @@ -394,16 +399,17 @@ static int wm8994_hw_params(struct wm8994_priv *wm8994, int aif_id, if ((channels == 1) && ((reg_data & 0x18) == 0x18)) aif2 |= WM8994_AIF1_MONO; - if (wm8994->aifclk[id] == 0) { + if (priv->aifclk[id] == 0) { debug("%s:Audio interface clock not set\n", __func__); return -1; } - ret = wm8994_update_bits(aif1_reg, WM8994_AIF1_WL_MASK, aif1); - ret |= wm8994_update_bits(aif2_reg, WM8994_AIF1_MONO, aif2); - ret |= wm8994_update_bits(bclk_reg, WM8994_AIF1_BCLK_DIV_MASK, bclk); - ret |= wm8994_update_bits(rate_reg, WM8994_AIF1_SR_MASK | - WM8994_AIF1CLK_RATE_MASK, rate_val); + ret = wm8994_bic_or(priv, aif1_reg, WM8994_AIF1_WL_MASK, aif1); + ret |= wm8994_bic_or(priv, aif2_reg, WM8994_AIF1_MONO, aif2); + ret |= wm8994_bic_or(priv, bclk_reg, WM8994_AIF1_BCLK_DIV_MASK, + bclk); + ret |= wm8994_bic_or(priv, rate_reg, WM8994_AIF1_SR_MASK | + WM8994_AIF1CLK_RATE_MASK, rate_val); debug("rate vale = %x , bclk val= %x\n", rate_val, bclk); @@ -418,12 +424,12 @@ static int wm8994_hw_params(struct wm8994_priv *wm8994, int aif_id, /* * Configures Audio interface Clock * - * @param wm8994 wm8994 information pointer + * @param priv wm8994 information pointer * @param aif Audio Interface ID * * @return -1 for error and 0 Success. */ -static int configure_aif_clock(struct wm8994_priv *wm8994, int aif) +static int configure_aif_clock(struct wm8994_priv *priv, int aif) { int rate; int reg1 = 0; @@ -436,30 +442,30 @@ static int configure_aif_clock(struct wm8994_priv *wm8994, int aif) else offset = 0; - switch (wm8994->sysclk[aif-1]) { + switch (priv->sysclk[aif - 1]) { case WM8994_SYSCLK_MCLK1: reg1 |= SEL_MCLK1; - rate = wm8994->mclk[0]; + rate = priv->mclk[0]; break; case WM8994_SYSCLK_MCLK2: reg1 |= SEL_MCLK2; - rate = wm8994->mclk[1]; + rate = priv->mclk[1]; break; case WM8994_SYSCLK_FLL1: reg1 |= SEL_FLL1; - rate = wm8994->fll[0].out; + rate = priv->fll[0].out; break; case WM8994_SYSCLK_FLL2: reg1 |= SEL_FLL2; - rate = wm8994->fll[1].out; + rate = priv->fll[1].out; break; default: debug("%s: Invalid input clock selection [%d]\n", - __func__, wm8994->sysclk[aif-1]); + __func__, priv->sysclk[aif - 1]); return -1; } @@ -469,18 +475,18 @@ static int configure_aif_clock(struct wm8994_priv *wm8994, int aif) reg1 |= WM8994_AIF1CLK_DIV; } - wm8994->aifclk[aif-1] = rate; + priv->aifclk[aif - 1] = rate; - ret = wm8994_update_bits(WM8994_AIF1_CLOCKING_1 + offset, - WM8994_AIF1CLK_SRC_MASK | WM8994_AIF1CLK_DIV, - reg1); + ret = wm8994_bic_or(priv, WM8994_AIF1_CLOCKING_1 + offset, + WM8994_AIF1CLK_SRC_MASK | WM8994_AIF1CLK_DIV, + reg1); if (aif == WM8994_AIF1) - ret |= wm8994_update_bits(WM8994_CLOCKING_1, + ret |= wm8994_bic_or(priv, WM8994_CLOCKING_1, WM8994_AIF1DSPCLK_ENA_MASK | WM8994_SYSDSPCLK_ENA_MASK, WM8994_AIF1DSPCLK_ENA | WM8994_SYSDSPCLK_ENA); else if (aif == WM8994_AIF2) - ret |= wm8994_update_bits(WM8994_CLOCKING_1, + ret |= wm8994_bic_or(priv, WM8994_CLOCKING_1, WM8994_SYSCLK_SRC | WM8994_AIF2DSPCLK_ENA_MASK | WM8994_SYSDSPCLK_ENA_MASK, WM8994_SYSCLK_SRC | WM8994_AIF2DSPCLK_ENA | WM8994_SYSDSPCLK_ENA); @@ -496,33 +502,33 @@ static int configure_aif_clock(struct wm8994_priv *wm8994, int aif) /* * Configures Audio interface for the given frequency * - * @param wm8994 wm8994 information + * @param priv wm8994 information * @param aif_id Audio Interface * @param clk_id Input Clock ID * @param freq Sampling frequency in Hz * * @return -1 for error and 0 success. */ -static int wm8994_set_sysclk(struct wm8994_priv *wm8994, int aif_id, - int clk_id, unsigned int freq) +static int wm8994_set_sysclk(struct wm8994_priv *priv, int aif_id, int clk_id, + unsigned int freq) { int i; int ret = 0; - wm8994->sysclk[aif_id - 1] = clk_id; + priv->sysclk[aif_id - 1] = clk_id; switch (clk_id) { case WM8994_SYSCLK_MCLK1: - wm8994->mclk[0] = freq; + priv->mclk[0] = freq; if (aif_id == 2) { - ret = wm8994_update_bits(WM8994_AIF1_CLOCKING_2 , - WM8994_AIF2DAC_DIV_MASK , 0); + ret = wm8994_bic_or(priv, WM8994_AIF1_CLOCKING_2, + WM8994_AIF2DAC_DIV_MASK, 0); } break; case WM8994_SYSCLK_MCLK2: /* TODO: Set GPIO AF */ - wm8994->mclk[1] = freq; + priv->mclk[1] = freq; break; case WM8994_SYSCLK_FLL1: @@ -543,13 +549,14 @@ static int wm8994_set_sysclk(struct wm8994_priv *wm8994, int aif_id, __func__); return -1; } - ret = wm8994_update_bits(WM8994_CLOCKING_2, + ret = wm8994_bic_or(priv, WM8994_CLOCKING_2, WM8994_OPCLK_DIV_MASK, i); - ret |= wm8994_update_bits(WM8994_POWER_MANAGEMENT_2, - WM8994_OPCLK_ENA, WM8994_OPCLK_ENA); + ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_2, + WM8994_OPCLK_ENA, + WM8994_OPCLK_ENA); } else { - ret |= wm8994_update_bits(WM8994_POWER_MANAGEMENT_2, - WM8994_OPCLK_ENA, 0); + ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_2, + WM8994_OPCLK_ENA, 0); } default: @@ -558,7 +565,7 @@ static int wm8994_set_sysclk(struct wm8994_priv *wm8994, int aif_id, return -1; } - ret |= configure_aif_clock(wm8994, aif_id); + ret |= configure_aif_clock(priv, aif_id); if (ret < 0) { debug("%s: codec register access error\n", __func__); @@ -571,37 +578,38 @@ static int wm8994_set_sysclk(struct wm8994_priv *wm8994, int aif_id, /* * Initializes Volume for AIF2 to HP path * + * @param priv wm8994 information * @returns -1 for error and 0 Success. * */ -static int wm8994_init_volume_aif2_dac1(void) +static int wm8994_init_volume_aif2_dac1(struct wm8994_priv *priv) { int ret; /* Unmute AIF2DAC */ - ret = wm8994_update_bits(WM8994_AIF2_DAC_FILTERS_1, - WM8994_AIF2DAC_MUTE_MASK, 0); + ret = wm8994_bic_or(priv, WM8994_AIF2_DAC_FILTERS_1, + WM8994_AIF2DAC_MUTE_MASK, 0); - ret |= wm8994_update_bits(WM8994_AIF2_DAC_LEFT_VOLUME, - WM8994_AIF2DAC_VU_MASK | WM8994_AIF2DACL_VOL_MASK, - WM8994_AIF2DAC_VU | 0xff); + ret |= wm8994_bic_or(priv, WM8994_AIF2_DAC_LEFT_VOLUME, + WM8994_AIF2DAC_VU_MASK | WM8994_AIF2DACL_VOL_MASK, + WM8994_AIF2DAC_VU | 0xff); - ret |= wm8994_update_bits(WM8994_AIF2_DAC_RIGHT_VOLUME, - WM8994_AIF2DAC_VU_MASK | WM8994_AIF2DACR_VOL_MASK, - WM8994_AIF2DAC_VU | 0xff); + ret |= wm8994_bic_or(priv, WM8994_AIF2_DAC_RIGHT_VOLUME, + WM8994_AIF2DAC_VU_MASK | WM8994_AIF2DACR_VOL_MASK, + WM8994_AIF2DAC_VU | 0xff); - ret |= wm8994_update_bits(WM8994_DAC1_LEFT_VOLUME, - WM8994_DAC1_VU_MASK | WM8994_DAC1L_VOL_MASK | - WM8994_DAC1L_MUTE_MASK, WM8994_DAC1_VU | 0xc0); + ret |= wm8994_bic_or(priv, WM8994_DAC1_LEFT_VOLUME, + WM8994_DAC1_VU_MASK | WM8994_DAC1L_VOL_MASK | + WM8994_DAC1L_MUTE_MASK, WM8994_DAC1_VU | 0xc0); - ret |= wm8994_update_bits(WM8994_DAC1_RIGHT_VOLUME, - WM8994_DAC1_VU_MASK | WM8994_DAC1R_VOL_MASK | - WM8994_DAC1R_MUTE_MASK, WM8994_DAC1_VU | 0xc0); + ret |= wm8994_bic_or(priv, WM8994_DAC1_RIGHT_VOLUME, + WM8994_DAC1_VU_MASK | WM8994_DAC1R_VOL_MASK | + WM8994_DAC1R_MUTE_MASK, WM8994_DAC1_VU | 0xc0); /* Head Phone Volume */ - ret |= wm8994_i2c_write(WM8994_LEFT_OUTPUT_VOLUME, 0x12D); - ret |= wm8994_i2c_write(WM8994_RIGHT_OUTPUT_VOLUME, 0x12D); + ret |= wm8994_i2c_write(priv, WM8994_LEFT_OUTPUT_VOLUME, 0x12D); + ret |= wm8994_i2c_write(priv, WM8994_RIGHT_OUTPUT_VOLUME, 0x12D); if (ret < 0) { debug("%s: codec register access error\n", __func__); @@ -614,26 +622,27 @@ static int wm8994_init_volume_aif2_dac1(void) /* * Initializes Volume for AIF1 to HP path * + * @param priv wm8994 information * @returns -1 for error and 0 Success. * */ -static int wm8994_init_volume_aif1_dac1(void) +static int wm8994_init_volume_aif1_dac1(struct wm8994_priv *priv) { int ret = 0; /* Unmute AIF1DAC */ - ret |= wm8994_i2c_write(WM8994_AIF1_DAC_FILTERS_1, 0x0000); + ret |= wm8994_i2c_write(priv, WM8994_AIF1_DAC_FILTERS_1, 0x0000); - ret |= wm8994_update_bits(WM8994_DAC1_LEFT_VOLUME, - WM8994_DAC1_VU_MASK | WM8994_DAC1L_VOL_MASK | - WM8994_DAC1L_MUTE_MASK, WM8994_DAC1_VU | 0xc0); + ret |= wm8994_bic_or(priv, WM8994_DAC1_LEFT_VOLUME, + WM8994_DAC1_VU_MASK | WM8994_DAC1L_VOL_MASK | + WM8994_DAC1L_MUTE_MASK, WM8994_DAC1_VU | 0xc0); - ret |= wm8994_update_bits(WM8994_DAC1_RIGHT_VOLUME, - WM8994_DAC1_VU_MASK | WM8994_DAC1R_VOL_MASK | - WM8994_DAC1R_MUTE_MASK, WM8994_DAC1_VU | 0xc0); + ret |= wm8994_bic_or(priv, WM8994_DAC1_RIGHT_VOLUME, + WM8994_DAC1_VU_MASK | WM8994_DAC1R_VOL_MASK | + WM8994_DAC1R_MUTE_MASK, WM8994_DAC1_VU | 0xc0); /* Head Phone Volume */ - ret |= wm8994_i2c_write(WM8994_LEFT_OUTPUT_VOLUME, 0x12D); - ret |= wm8994_i2c_write(WM8994_RIGHT_OUTPUT_VOLUME, 0x12D); + ret |= wm8994_i2c_write(priv, WM8994_LEFT_OUTPUT_VOLUME, 0x12D); + ret |= wm8994_i2c_write(priv, WM8994_RIGHT_OUTPUT_VOLUME, 0x12D); if (ret < 0) { debug("%s: codec register access error\n", __func__); @@ -646,20 +655,20 @@ static int wm8994_init_volume_aif1_dac1(void) /* * Intialise wm8994 codec device * - * @param wm8994 wm8994 information + * @param priv wm8994 information * * @returns -1 for error and 0 Success. */ -static int wm8994_device_init(struct wm8994_priv *wm8994, +static int wm8994_device_init(struct wm8994_priv *priv, enum en_audio_interface aif_id) { const char *devname; unsigned short reg_data; int ret; - wm8994_i2c_write(WM8994_SOFTWARE_RESET, WM8994_SW_RESET);/* Reset */ + wm8994_i2c_write(priv, WM8994_SOFTWARE_RESET, WM8994_SW_RESET); - ret = wm8994_i2c_read(WM8994_SOFTWARE_RESET, ®_data); + ret = wm8994_i2c_read(priv, WM8994_SOFTWARE_RESET, ®_data); if (ret < 0) { debug("Failed to read ID register\n"); goto err; @@ -667,72 +676,72 @@ static int wm8994_device_init(struct wm8994_priv *wm8994, if (reg_data == WM8994_ID) { devname = "WM8994"; - debug("Device registered as type %d\n", wm8994->type); - wm8994->type = WM8994; + debug("Device registered as type %d\n", priv->type); + priv->type = WM8994; } else { debug("Device is not a WM8994, ID is %x\n", ret); ret = -1; goto err; } - ret = wm8994_i2c_read(WM8994_CHIP_REVISION, ®_data); + ret = wm8994_i2c_read(priv, WM8994_CHIP_REVISION, ®_data); if (ret < 0) { debug("Failed to read revision register: %d\n", ret); goto err; } - wm8994->revision = reg_data; - debug("%s revision %c\n", devname, 'A' + wm8994->revision); + priv->revision = reg_data; + debug("%s revision %c\n", devname, 'A' + priv->revision); /* VMID Selection */ - ret |= wm8994_update_bits(WM8994_POWER_MANAGEMENT_1, - WM8994_VMID_SEL_MASK | WM8994_BIAS_ENA_MASK, 0x3); + ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1, + WM8994_VMID_SEL_MASK | WM8994_BIAS_ENA_MASK, 0x3); /* Charge Pump Enable */ - ret |= wm8994_update_bits(WM8994_CHARGE_PUMP_1, WM8994_CP_ENA_MASK, - WM8994_CP_ENA); + ret |= wm8994_bic_or(priv, WM8994_CHARGE_PUMP_1, WM8994_CP_ENA_MASK, + WM8994_CP_ENA); /* Head Phone Power Enable */ - ret |= wm8994_update_bits(WM8994_POWER_MANAGEMENT_1, - WM8994_HPOUT1L_ENA_MASK, WM8994_HPOUT1L_ENA); + ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1, + WM8994_HPOUT1L_ENA_MASK, WM8994_HPOUT1L_ENA); - ret |= wm8994_update_bits(WM8994_POWER_MANAGEMENT_1, - WM8994_HPOUT1R_ENA_MASK, WM8994_HPOUT1R_ENA); + ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1, + WM8994_HPOUT1R_ENA_MASK, WM8994_HPOUT1R_ENA); if (aif_id == WM8994_AIF1) { - ret |= wm8994_i2c_write(WM8994_POWER_MANAGEMENT_2, + ret |= wm8994_i2c_write(priv, WM8994_POWER_MANAGEMENT_2, WM8994_TSHUT_ENA | WM8994_MIXINL_ENA | WM8994_MIXINR_ENA | WM8994_IN2L_ENA | WM8994_IN2R_ENA); - ret |= wm8994_i2c_write(WM8994_POWER_MANAGEMENT_4, + ret |= wm8994_i2c_write(priv, WM8994_POWER_MANAGEMENT_4, WM8994_ADCL_ENA | WM8994_ADCR_ENA | WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC1L_ENA); /* Power enable for AIF1 and DAC1 */ - ret |= wm8994_i2c_write(WM8994_POWER_MANAGEMENT_5, + ret |= wm8994_i2c_write(priv, WM8994_POWER_MANAGEMENT_5, WM8994_AIF1DACL_ENA | WM8994_AIF1DACR_ENA | WM8994_DAC1L_ENA | WM8994_DAC1R_ENA); } else if (aif_id == WM8994_AIF2) { /* Power enable for AIF2 and DAC1 */ - ret |= wm8994_update_bits(WM8994_POWER_MANAGEMENT_5, + ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_5, WM8994_AIF2DACL_ENA_MASK | WM8994_AIF2DACR_ENA_MASK | WM8994_DAC1L_ENA_MASK | WM8994_DAC1R_ENA_MASK, WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA | WM8994_DAC1L_ENA | WM8994_DAC1R_ENA); } /* Head Phone Initialisation */ - ret |= wm8994_update_bits(WM8994_ANALOGUE_HP_1, + ret |= wm8994_bic_or(priv, WM8994_ANALOGUE_HP_1, WM8994_HPOUT1L_DLY_MASK | WM8994_HPOUT1R_DLY_MASK, WM8994_HPOUT1L_DLY | WM8994_HPOUT1R_DLY); - ret |= wm8994_update_bits(WM8994_DC_SERVO_1, + ret |= wm8994_bic_or(priv, WM8994_DC_SERVO_1, WM8994_DCS_ENA_CHAN_0_MASK | WM8994_DCS_ENA_CHAN_1_MASK , WM8994_DCS_ENA_CHAN_0 | WM8994_DCS_ENA_CHAN_1); - ret |= wm8994_update_bits(WM8994_ANALOGUE_HP_1, + ret |= wm8994_bic_or(priv, WM8994_ANALOGUE_HP_1, WM8994_HPOUT1L_DLY_MASK | WM8994_HPOUT1R_DLY_MASK | WM8994_HPOUT1L_OUTP_MASK | WM8994_HPOUT1R_OUTP_MASK | @@ -743,53 +752,56 @@ static int wm8994_device_init(struct wm8994_priv *wm8994, WM8994_HPOUT1R_RMV_SHORT); /* MIXER Config DAC1 to HP */ - ret |= wm8994_update_bits(WM8994_OUTPUT_MIXER_1, - WM8994_DAC1L_TO_HPOUT1L_MASK, WM8994_DAC1L_TO_HPOUT1L); + ret |= wm8994_bic_or(priv, WM8994_OUTPUT_MIXER_1, + WM8994_DAC1L_TO_HPOUT1L_MASK, + WM8994_DAC1L_TO_HPOUT1L); - ret |= wm8994_update_bits(WM8994_OUTPUT_MIXER_2, - WM8994_DAC1R_TO_HPOUT1R_MASK, WM8994_DAC1R_TO_HPOUT1R); + ret |= wm8994_bic_or(priv, WM8994_OUTPUT_MIXER_2, + WM8994_DAC1R_TO_HPOUT1R_MASK, + WM8994_DAC1R_TO_HPOUT1R); if (aif_id == WM8994_AIF1) { /* Routing AIF1 to DAC1 */ - ret |= wm8994_i2c_write(WM8994_DAC1_LEFT_MIXER_ROUTING, - WM8994_AIF1DAC1L_TO_DAC1L); + ret |= wm8994_i2c_write(priv, WM8994_DAC1_LEFT_MIXER_ROUTING, + WM8994_AIF1DAC1L_TO_DAC1L); - ret |= wm8994_i2c_write(WM8994_DAC1_RIGHT_MIXER_ROUTING, + ret |= wm8994_i2c_write(priv, WM8994_DAC1_RIGHT_MIXER_ROUTING, WM8994_AIF1DAC1R_TO_DAC1R); /* GPIO Settings for AIF1 */ - ret |= wm8994_i2c_write(WM8994_GPIO_1, WM8994_GPIO_DIR_OUTPUT - | WM8994_GPIO_FUNCTION_I2S_CLK - | WM8994_GPIO_INPUT_DEBOUNCE); + ret |= wm8994_i2c_write(priv, WM8994_GPIO_1, + WM8994_GPIO_DIR_OUTPUT | + WM8994_GPIO_FUNCTION_I2S_CLK | + WM8994_GPIO_INPUT_DEBOUNCE); - ret |= wm8994_init_volume_aif1_dac1(); + ret |= wm8994_init_volume_aif1_dac1(priv); } else if (aif_id == WM8994_AIF2) { /* Routing AIF2 to DAC1 */ - ret |= wm8994_update_bits(WM8994_DAC1_LEFT_MIXER_ROUTING, - WM8994_AIF2DACL_TO_DAC1L_MASK, - WM8994_AIF2DACL_TO_DAC1L); + ret |= wm8994_bic_or(priv, WM8994_DAC1_LEFT_MIXER_ROUTING, + WM8994_AIF2DACL_TO_DAC1L_MASK, + WM8994_AIF2DACL_TO_DAC1L); - ret |= wm8994_update_bits(WM8994_DAC1_RIGHT_MIXER_ROUTING, - WM8994_AIF2DACR_TO_DAC1R_MASK, - WM8994_AIF2DACR_TO_DAC1R); + ret |= wm8994_bic_or(priv, WM8994_DAC1_RIGHT_MIXER_ROUTING, + WM8994_AIF2DACR_TO_DAC1R_MASK, + WM8994_AIF2DACR_TO_DAC1R); /* GPIO Settings for AIF2 */ /* B CLK */ - ret |= wm8994_update_bits(WM8994_GPIO_3, WM8994_GPIO_DIR_MASK | - WM8994_GPIO_FUNCTION_MASK , - WM8994_GPIO_DIR_OUTPUT); + ret |= wm8994_bic_or(priv, WM8994_GPIO_3, WM8994_GPIO_DIR_MASK | + WM8994_GPIO_FUNCTION_MASK, + WM8994_GPIO_DIR_OUTPUT); /* LR CLK */ - ret |= wm8994_update_bits(WM8994_GPIO_4, WM8994_GPIO_DIR_MASK | - WM8994_GPIO_FUNCTION_MASK, - WM8994_GPIO_DIR_OUTPUT); + ret |= wm8994_bic_or(priv, WM8994_GPIO_4, WM8994_GPIO_DIR_MASK | + WM8994_GPIO_FUNCTION_MASK, + WM8994_GPIO_DIR_OUTPUT); /* DATA */ - ret |= wm8994_update_bits(WM8994_GPIO_5, WM8994_GPIO_DIR_MASK | - WM8994_GPIO_FUNCTION_MASK, - WM8994_GPIO_DIR_OUTPUT); + ret |= wm8994_bic_or(priv, WM8994_GPIO_5, WM8994_GPIO_DIR_MASK | + WM8994_GPIO_FUNCTION_MASK, + WM8994_GPIO_DIR_OUTPUT); - ret |= wm8994_init_volume_aif2_dac1(); + ret |= wm8994_init_volume_aif2_dac1(priv); } if (ret < 0) @@ -810,7 +822,7 @@ err: * @return int value, 0 for success */ static int get_codec_values(struct sound_codec_info *pcodec_info, - const void *blob) + const void *blob) { int error = 0; enum fdt_compat_id compat; @@ -857,8 +869,8 @@ static int get_codec_values(struct sound_codec_info *pcodec_info, /* WM8994 Device Initialisation */ 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 sampling_rate, int mclk_freq, int bits_per_sample, + unsigned int channels) { int ret = 0; struct sound_codec_info *pcodec_info = &g_codec_info; @@ -887,12 +899,12 @@ int wm8994_init(const void *blob, enum en_audio_interface aif_id, } ret = wm8994_hw_params(&g_wm8994_info, aif_id, sampling_rate, - bits_per_sample, channels); + bits_per_sample, channels); if (ret == 0) { - ret = wm8994_set_fmt(aif_id, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS); + ret = wm8994_set_fmt(&g_wm8994_info, aif_id, + SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS); } return ret; } From patchwork Mon Dec 3 11:37:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006844 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="a8dC9FdQ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jnj3DVmz9s7W for ; Mon, 3 Dec 2018 22:44:09 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 28743C22168; Mon, 3 Dec 2018 11:42:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2B588C22318; Mon, 3 Dec 2018 11:38:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 61219C22209; Mon, 3 Dec 2018 11:38:35 +0000 (UTC) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by lists.denx.de (Postfix) with ESMTPS id 88E28C221BA for ; Mon, 3 Dec 2018 11:38:29 +0000 (UTC) Received: by mail-io1-f70.google.com with SMTP id v8so13816011ioh.11 for ; Mon, 03 Dec 2018 03:38:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=AkOkDaZxJbq2exGrEMx4dDl1VKRwM0MlsbnbhtPmuYs=; b=a8dC9FdQ71iPU67fAJgWGSvyrwsxhDDhTrEcdSus0zDDguLvmuK4p2plXKcftsx3HE n7YeyiX2sPM0uYlHQN+NXBhAOZxYlkYnUQIElpZgd1LiW/EGLRjdRZyocV/R69xh3mhu GkAhXrOo5z5CHsLQpcmXicdtyZOzJQrO4ho30= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AkOkDaZxJbq2exGrEMx4dDl1VKRwM0MlsbnbhtPmuYs=; b=ViCjRAM/VIBUQfYx10upKea+HNATITDE4UvyKgaEMwFTyFdwgFx+T5Xyc/ZN7abgBN aQbxaFxl8oXzddH/UvUtypqRaWcdbNnXStYZ9BeSkQaJzl1fy9iPlmm6zMRfVC63QcAO eSu4JmgYfMLpEnfxiBy0ZAGUxyfOqjY/yi8EZiIZVqgyE+8OzqW8nb9Rok9qk96WvGBT 6/Wm/GXDyW/P0Vm8M/POIYoCj/DWu0gW1YbR3r3qTIMjLqAj4KlXBruWu0Ce5v1L9COS 6BR87MJ2QpRSIRXFlLOxE4t9puglJaGyBaX9By/VApKcQsdq8KAFxTZ2bW02WsfIG6Ic ZHOw== X-Gm-Message-State: AA+aEWZmp05Y8zjvty2pvOejku/F9PCF5R/Nja1/RVY0pRQK5wqLubtJ hJDefp5h9TCnWF1uoYA+3BXWY8/tbuxDI5a5 X-Google-Smtp-Source: AFSGD/UG3GZzqCU/lxdX1/zCFx1gouWG0kooJK4sR1KXeAkkYYFSeIc2P3JLckjI+eBrGFpjGXSTkbPUg/9YWiBs X-Received: by 2002:a24:6212:: with SMTP id d18mr6478034itc.29.1543837108555; Mon, 03 Dec 2018 03:38:28 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:25 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-10-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 09/30] dm: sound: max98095: Pass private data to internal functions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present the driver-private data is global. To allow this code to be used with driver model, change it to pass the data down to each function. Use the name 'priv' consistently throughout. Also rename max98095_update_bits() to max98095_bic_or() which is more descriptive and shorter, thus breaking fewer lines with the parameter addition. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/max98095.c | 152 ++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 74 deletions(-) diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index efaaeb8f3b8..6edf3736d79 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -41,12 +41,14 @@ int rate_table[] = {0, 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, /* * Writes value to a device register through i2c * + * @param priv Private data for driver * @param reg reg number to be write * @param data data to be writen to the above registor * * @return int value 1 for change, 0 for no change or negative error code. */ -static int max98095_i2c_write(unsigned int reg, unsigned char data) +static int max98095_i2c_write(struct max98095_priv *priv, unsigned int reg, + unsigned char data) { debug("%s: Write Addr : 0x%02X, Data : 0x%02X\n", __func__, reg, data); @@ -56,12 +58,14 @@ static int max98095_i2c_write(unsigned int reg, unsigned char data) /* * Read a value from a device register through i2c * + * @param priv Private data for driver * @param reg reg number to be read * @param data address of read data to be stored * * @return int value 0 for success, -1 in case of error. */ -static unsigned int max98095_i2c_read(unsigned int reg, unsigned char *data) +static unsigned int max98095_i2c_read(struct max98095_priv *priv, + unsigned int reg, unsigned char *data) { int ret; @@ -78,24 +82,25 @@ static unsigned int max98095_i2c_read(unsigned int reg, unsigned char *data) /* * update device register bits through i2c * + * @param priv Private data for driver * @param reg codec register * @param mask register mask * @param value new value * * @return int value 0 for success, non-zero error code. */ -static int max98095_update_bits(unsigned int reg, unsigned char mask, - unsigned char value) +static int max98095_bic_or(struct max98095_priv *priv, unsigned int reg, + unsigned char mask, unsigned char value) { int change, ret = 0; unsigned char old, new; - if (max98095_i2c_read(reg, &old) != 0) + if (max98095_i2c_read(priv, reg, &old) != 0) return -1; new = (old & ~mask) | (value & mask); change = (old != new) ? 1 : 0; if (change) - ret = max98095_i2c_write(reg, new); + ret = max98095_i2c_write(priv, reg, new); if (ret < 0) return ret; @@ -128,13 +133,13 @@ static int rate_value(int rate, u8 *value) /* * Sets hw params for max98095 * - * @param max98095 max98095 information pointer + * @param priv max98095 information pointer * @param rate Sampling rate * @param bits_per_sample Bits per sample * * @return -1 for error and 0 Success. */ -static int max98095_hw_params(struct max98095_priv *max98095, +static int max98095_hw_params(struct max98095_priv *priv, enum en_max_audio_interface aif_id, unsigned int rate, unsigned int bits_per_sample) { @@ -156,12 +161,12 @@ static int max98095_hw_params(struct max98095_priv *max98095, switch (bits_per_sample) { case 16: - error = max98095_update_bits(M98095_DAI_FORMAT, - M98095_DAI_WS, 0); + error = max98095_bic_or(priv, M98095_DAI_FORMAT, M98095_DAI_WS, + 0); break; case 24: - error = max98095_update_bits(M98095_DAI_FORMAT, - M98095_DAI_WS, M98095_DAI_WS); + error = max98095_bic_or(priv, M98095_DAI_FORMAT, M98095_DAI_WS, + M98095_DAI_WS); break; default: debug("%s: Illegal bits per sample %d.\n", @@ -174,18 +179,18 @@ static int max98095_hw_params(struct max98095_priv *max98095, __func__, rate); return -1; } - max98095->rate = rate; + priv->rate = rate; - error |= max98095_update_bits(M98095_DAI_CLKMODE, - M98095_CLKMODE_MASK, regval); + error |= max98095_bic_or(priv, M98095_DAI_CLKMODE, M98095_CLKMODE_MASK, + regval); /* Update sample rate mode */ if (rate < 50000) - error |= max98095_update_bits(M98095_DAI_FILTERS, - M98095_DAI_DHF, 0); + error |= max98095_bic_or(priv, M98095_DAI_FILTERS, + M98095_DAI_DHF, 0); else - error |= max98095_update_bits(M98095_DAI_FILTERS, - M98095_DAI_DHF, M98095_DAI_DHF); + error |= max98095_bic_or(priv, M98095_DAI_FILTERS, + M98095_DAI_DHF, M98095_DAI_DHF); if (error < 0) { debug("%s: Error setting hardware params.\n", __func__); @@ -198,18 +203,17 @@ static int max98095_hw_params(struct max98095_priv *max98095, /* * Configures Audio interface system clock for the given frequency * - * @param max98095 max98095 information + * @param priv max98095 information * @param freq Sampling frequency in Hz * * @return -1 for error and 0 success. */ -static int max98095_set_sysclk(struct max98095_priv *max98095, - unsigned int freq) +static int max98095_set_sysclk(struct max98095_priv *priv, unsigned int freq) { int error = 0; /* Requested clock frequency is already setup */ - if (freq == max98095->sysclk) + if (freq == priv->sysclk) return 0; /* Setup clocks for slave mode, and using the PLL @@ -218,11 +222,11 @@ static int max98095_set_sysclk(struct max98095_priv *max98095, * 0x03 (when master clk is 40MHz to 60MHz).. */ if ((freq >= 10000000) && (freq < 20000000)) { - error = max98095_i2c_write(M98095_026_SYS_CLK, 0x10); + error = max98095_i2c_write(priv, M98095_026_SYS_CLK, 0x10); } else if ((freq >= 20000000) && (freq < 40000000)) { - error = max98095_i2c_write(M98095_026_SYS_CLK, 0x20); + error = max98095_i2c_write(priv, M98095_026_SYS_CLK, 0x20); } else if ((freq >= 40000000) && (freq < 60000000)) { - error = max98095_i2c_write(M98095_026_SYS_CLK, 0x30); + error = max98095_i2c_write(priv, M98095_026_SYS_CLK, 0x30); } else { debug("%s: Invalid master clock frequency\n", __func__); return -1; @@ -233,20 +237,20 @@ static int max98095_set_sysclk(struct max98095_priv *max98095, if (error < 0) return -1; - max98095->sysclk = freq; + priv->sysclk = freq; return 0; } /* * Sets Max98095 I2S format * - * @param max98095 max98095 information + * @param priv max98095 information * @param fmt i2S format - supports a subset of the options defined * in i2s.h. * * @return -1 for error and 0 Success. */ -static int max98095_set_fmt(struct max98095_priv *max98095, int fmt, +static int max98095_set_fmt(struct max98095_priv *priv, int fmt, enum en_max_audio_interface aif_id) { u8 regval = 0; @@ -256,10 +260,10 @@ static int max98095_set_fmt(struct max98095_priv *max98095, int fmt, unsigned short M98095_DAI_FORMAT; unsigned short M98095_DAI_CLOCK; - if (fmt == max98095->fmt) + if (fmt == priv->fmt) return 0; - max98095->fmt = fmt; + priv->fmt = fmt; if (aif_id == AIF1) { M98095_DAI_CLKCFG_HI = M98095_028_DAI1_CLKCFG_HI; @@ -276,10 +280,8 @@ static int max98095_set_fmt(struct max98095_priv *max98095, int fmt, switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* Slave mode PLL */ - error |= max98095_i2c_write(M98095_DAI_CLKCFG_HI, - 0x80); - error |= max98095_i2c_write(M98095_DAI_CLKCFG_LO, - 0x00); + error |= max98095_i2c_write(priv, M98095_DAI_CLKCFG_HI, 0x80); + error |= max98095_i2c_write(priv, M98095_DAI_CLKCFG_LO, 0x00); break; case SND_SOC_DAIFMT_CBM_CFM: /* Set to master mode */ @@ -320,13 +322,11 @@ static int max98095_set_fmt(struct max98095_priv *max98095, int fmt, return -1; } - error |= max98095_update_bits(M98095_DAI_FORMAT, - M98095_DAI_MAS | M98095_DAI_DLY | - M98095_DAI_BCI | M98095_DAI_WCI, - regval); + error |= max98095_bic_or(priv, M98095_DAI_FORMAT, + M98095_DAI_MAS | M98095_DAI_DLY | + M98095_DAI_BCI | M98095_DAI_WCI, regval); - error |= max98095_i2c_write(M98095_DAI_CLOCK, - M98095_DAI_BSEL64); + error |= max98095_i2c_write(priv, M98095_DAI_CLOCK, M98095_DAI_BSEL64); if (error < 0) { debug("%s: Error setting i2s format.\n", __func__); @@ -339,9 +339,10 @@ static int max98095_set_fmt(struct max98095_priv *max98095, int fmt, /* * resets the audio codec * + * @param priv Private data for driver * @return -1 for error and 0 success. */ -static int max98095_reset(void) +static int max98095_reset(struct max98095_priv *priv) { int i, ret; @@ -349,13 +350,13 @@ static int max98095_reset(void) * Gracefully reset the DSP core and the codec hardware in a proper * sequence. */ - ret = max98095_i2c_write(M98095_00F_HOST_CFG, 0); + ret = max98095_i2c_write(priv, M98095_00F_HOST_CFG, 0); if (ret != 0) { debug("%s: Failed to reset DSP: %d\n", __func__, ret); return ret; } - ret = max98095_i2c_write(M98095_097_PWR_SYS, 0); + ret = max98095_i2c_write(priv, M98095_097_PWR_SYS, 0); if (ret != 0) { debug("%s: Failed to reset codec: %d\n", __func__, ret); return ret; @@ -366,7 +367,7 @@ static int max98095_reset(void) * reset hardware control register. */ for (i = M98095_010_HOST_INT_CFG; i < M98095_REG_MAX_CACHED; i++) { - ret = max98095_i2c_write(i, 0); + ret = max98095_i2c_write(priv, i, 0); if (ret < 0) { debug("%s: Failed to reset: %d\n", __func__, ret); return ret; @@ -379,29 +380,29 @@ static int max98095_reset(void) /* * Intialise max98095 codec device * - * @param max98095 max98095 information + * @param priv max98095 information * * @returns -1 for error and 0 Success. */ -static int max98095_device_init(struct max98095_priv *max98095, +static int max98095_device_init(struct max98095_priv *priv, enum en_max_audio_interface aif_id) { unsigned char id; int error = 0; /* reset the codec, the DSP core, and disable all interrupts */ - error = max98095_reset(); + error = max98095_reset(priv); if (error != 0) { debug("Reset\n"); return error; } /* initialize private data */ - max98095->sysclk = -1U; - max98095->rate = -1U; - max98095->fmt = -1U; + priv->sysclk = -1U; + priv->rate = -1U; + priv->fmt = -1U; - error = max98095_i2c_read(M98095_0FF_REV_ID, &id); + error = max98095_i2c_read(priv, M98095_0FF_REV_ID, &id); if (error < 0) { debug("%s: Failure reading hardware revision: %d\n", __func__, id); @@ -409,55 +410,58 @@ static int max98095_device_init(struct max98095_priv *max98095, } debug("%s: Hardware revision: %c\n", __func__, (id - 0x40) + 'A'); - error |= max98095_i2c_write(M98095_097_PWR_SYS, M98095_PWRSV); + error |= max98095_i2c_write(priv, M98095_097_PWR_SYS, M98095_PWRSV); /* * initialize registers to hardware default configuring audio * interface2 to DAC */ if (aif_id == AIF1) - error |= max98095_i2c_write(M98095_048_MIX_DAC_LR, + error |= max98095_i2c_write(priv, M98095_048_MIX_DAC_LR, M98095_DAI1L_TO_DACL | M98095_DAI1R_TO_DACR); else - error |= max98095_i2c_write(M98095_048_MIX_DAC_LR, + error |= max98095_i2c_write(priv, M98095_048_MIX_DAC_LR, M98095_DAI2M_TO_DACL | M98095_DAI2M_TO_DACR); - error |= max98095_i2c_write(M98095_092_PWR_EN_OUT, + error |= max98095_i2c_write(priv, M98095_092_PWR_EN_OUT, M98095_SPK_SPREADSPECTRUM); - error |= max98095_i2c_write(M98095_04E_CFG_HP, M98095_HPNORMAL); + error |= max98095_i2c_write(priv, M98095_04E_CFG_HP, M98095_HPNORMAL); if (aif_id == AIF1) - error |= max98095_i2c_write(M98095_02C_DAI1_IOCFG, + error |= max98095_i2c_write(priv, M98095_02C_DAI1_IOCFG, M98095_S1NORMAL | M98095_SDATA); else - error |= max98095_i2c_write(M98095_036_DAI2_IOCFG, + error |= max98095_i2c_write(priv, M98095_036_DAI2_IOCFG, M98095_S2NORMAL | M98095_SDATA); /* take the codec out of the shut down */ - error |= max98095_update_bits(M98095_097_PWR_SYS, M98095_SHDNRUN, - M98095_SHDNRUN); - /* route DACL and DACR output to HO and Spekers */ - error |= max98095_i2c_write(M98095_050_MIX_SPK_LEFT, 0x01); /* DACL */ - error |= max98095_i2c_write(M98095_051_MIX_SPK_RIGHT, 0x01);/* DACR */ - error |= max98095_i2c_write(M98095_04C_MIX_HP_LEFT, 0x01); /* DACL */ - error |= max98095_i2c_write(M98095_04D_MIX_HP_RIGHT, 0x01); /* DACR */ + error |= max98095_bic_or(priv, M98095_097_PWR_SYS, M98095_SHDNRUN, + M98095_SHDNRUN); + /* + * route DACL and DACR output to HO and Speakers + * Ordering: DACL, DACR, DACL, DACR + */ + error |= max98095_i2c_write(priv, M98095_050_MIX_SPK_LEFT, 0x01); + error |= max98095_i2c_write(priv, M98095_051_MIX_SPK_RIGHT, 0x01); + error |= max98095_i2c_write(priv, M98095_04C_MIX_HP_LEFT, 0x01); + error |= max98095_i2c_write(priv, M98095_04D_MIX_HP_RIGHT, 0x01); /* power Enable */ - error |= max98095_i2c_write(M98095_091_PWR_EN_OUT, 0xF3); + error |= max98095_i2c_write(priv, M98095_091_PWR_EN_OUT, 0xF3); /* set Volume */ - error |= max98095_i2c_write(M98095_064_LVL_HP_L, 15); - error |= max98095_i2c_write(M98095_065_LVL_HP_R, 15); - error |= max98095_i2c_write(M98095_067_LVL_SPK_L, 16); - error |= max98095_i2c_write(M98095_068_LVL_SPK_R, 16); + error |= max98095_i2c_write(priv, M98095_064_LVL_HP_L, 15); + error |= max98095_i2c_write(priv, M98095_065_LVL_HP_R, 15); + error |= max98095_i2c_write(priv, M98095_067_LVL_SPK_L, 16); + error |= max98095_i2c_write(priv, M98095_068_LVL_SPK_R, 16); /* Enable DAIs */ - error |= max98095_i2c_write(M98095_093_BIAS_CTRL, 0x30); + error |= max98095_i2c_write(priv, M98095_093_BIAS_CTRL, 0x30); if (aif_id == AIF1) - error |= max98095_i2c_write(M98095_096_PWR_DAC_CK, 0x01); + error |= max98095_i2c_write(priv, M98095_096_PWR_DAC_CK, 0x01); else - error |= max98095_i2c_write(M98095_096_PWR_DAC_CK, 0x07); + error |= max98095_i2c_write(priv, M98095_096_PWR_DAC_CK, 0x07); err_access: if (error < 0) From patchwork Mon Dec 3 11:37:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006845 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mTQ5Ckhz"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jqz2YGbz9s55 for ; Mon, 3 Dec 2018 22:46:07 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C6AD7C2216C; Mon, 3 Dec 2018 11:42:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 29EF9C221ED; Mon, 3 Dec 2018 11:38:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E3FB8C2217B; Mon, 3 Dec 2018 11:38:35 +0000 (UTC) Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) by lists.denx.de (Postfix) with ESMTPS id 009DDC22203 for ; Mon, 3 Dec 2018 11:38:31 +0000 (UTC) Received: by mail-it1-f197.google.com with SMTP id 135so8341647itk.5 for ; Mon, 03 Dec 2018 03:38:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+Sb3NzWCJWBy5d9jjj8J13034lXDlbl1jrxgTcY1Xiw=; b=mTQ5CkhzND/B1t7WzfjjXb1L7k4ZTg8ksbYUbk+F5Hu6hzYEJGz2qekWh1ktnRORcP mw/18mzVsZAlXuOplyfkWSLKiIecNAlIb59XlCFdCtkNPLtkCQcpaR5z4YMx6SKxGIzh bx+4tlcADlU8ha2meae9XzDTRYY6ZFfC6EB/M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+Sb3NzWCJWBy5d9jjj8J13034lXDlbl1jrxgTcY1Xiw=; b=a5kwBA6HkKHb1KZBj9aN4HwC/e/61O3weaeFhhpmn9ttVRUEdhXUYYFdDhR67wRtLw I5YJRkRfPfzEFMlHHGSi6ACCQpifC+CqbKxw1wML2b/of7eZoshX8hP4o2vR3JTC/YAj PeMZUnecf4N06O+658xnEDkFltoV7XQt45ocfPoSF62yiF+YCzjQAxj4MMQOQ1UZjADL f5kuQExu5Mx0f+Uxkww7EjiHt+1I+ReD7MwAECRBQk2XG3sa52Iza3/s6g/wyB7LBjWi AKpd0qVDNOBVmn0JM2DRQEGQXUeviJwSF/2gsDdrIZ2MeL0XeqFjMfbdkAkTCWK/Hp9A zeoQ== X-Gm-Message-State: AA+aEWY5mNGqHTICC+RB6AHQdeN3/h4CLM5S3o5KJba0DafDepWuq17E 0S5Fb0lwSicIxosvGR8kDLCPduGVbHk2MiIH X-Google-Smtp-Source: AFSGD/XUAKPTIe8r6TwUxU8ctJZKLduuFBSGPk72ptL+gv7+CHdVvfUfQK0uV1BvwHjW8kl6rT9ojy1XTkP/D6OI X-Received: by 2002:a24:7281:: with SMTP id x123-v6mr173413itc.27.1543837110006; Mon, 03 Dec 2018 03:38:30 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:26 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-11-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 10/30] dm: sound: wm8994: Create a new common init function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With driver model we cannot pass in the global struct, but instead want to pass in the driver-private data. Split some of the code out of wm8994_init() to handle this. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/wm8994.c | 56 +++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index 3f56af9db4b..f83fcf9f430 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -867,44 +867,54 @@ static int get_codec_values(struct sound_codec_info *pcodec_info, return 0; } -/* WM8994 Device Initialisation */ -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) +static int _wm8994_init(struct wm8994_priv *priv, + 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; - wm8994_i2c_init(pcodec_info->i2c_bus); + int ret; - ret = wm8994_device_init(&g_wm8994_info, aif_id); + ret = wm8994_device_init(priv, aif_id); if (ret < 0) { debug("%s: wm8994 codec chip init failed\n", __func__); return ret; } - ret = wm8994_set_sysclk(&g_wm8994_info, aif_id, WM8994_SYSCLK_MCLK1, - mclk_freq); + ret = wm8994_set_sysclk(priv, aif_id, WM8994_SYSCLK_MCLK1, mclk_freq); if (ret < 0) { debug("%s: wm8994 codec set sys clock failed\n", __func__); return ret; } - ret = wm8994_hw_params(&g_wm8994_info, aif_id, sampling_rate, - bits_per_sample, channels); + ret = wm8994_hw_params(priv, aif_id, sampling_rate, bits_per_sample, + channels); if (ret == 0) { - ret = wm8994_set_fmt(&g_wm8994_info, aif_id, - SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + ret = wm8994_set_fmt(priv, aif_id, SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); } + return ret; } + +/* WM8994 Device Initialisation */ +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) +{ + 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; + wm8994_i2c_init(pcodec_info->i2c_bus); + + return _wm8994_init(&g_wm8994_info, aif_id, sampling_rate, mclk_freq, + bits_per_sample, channels); +} From patchwork Mon Dec 3 11:37:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006859 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="kj3toXbC"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jvN6BXrz9s55 for ; Mon, 3 Dec 2018 22:49:04 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 51A33C22318; Mon, 3 Dec 2018 11:44:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CE862C221C5; Mon, 3 Dec 2018 11:39:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8D128C22362; Mon, 3 Dec 2018 11:38:38 +0000 (UTC) Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by lists.denx.de (Postfix) with ESMTPS id 86E7FC22218 for ; Mon, 3 Dec 2018 11:38:32 +0000 (UTC) Received: by mail-io1-f71.google.com with SMTP id s25so14002625ioc.14 for ; Mon, 03 Dec 2018 03:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=wJkgrE2NgQ9lR5vfxbDnMN78He4x+lpd2SYjcKQ0/r8=; b=kj3toXbCNf6TvMRbK7bBg39ZwxLqZT7okXi7Q17OjmjhOUehle+FdVqokl+L859rAx hnji/VyXsLrSbs43b28jTBCPubzsLuDzTWX+mWjmdOekvom5nReqdEKX7G+HatZd9CK0 +tlUCV52WdBxN13a17Pfdcp2LSm4ZHcDGJq6o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wJkgrE2NgQ9lR5vfxbDnMN78He4x+lpd2SYjcKQ0/r8=; b=KQQKSfUMZDwlamYHDzThtbU8QE/ANQKYVMjxq848GMNrBA4hL7mnAD8J4gqN0VIld8 1GbmLBotVYA1Gk8TTYzUYMUvvGw0Nfq8o2grCFkN3bnU7RlsXSnWOW0bLEWij0h7zvz/ uEQ6B2lVot2ySRgdQcr8VtQmmL0B22D2rHVt6s0v8V6ebIcu0/h30tRYnepqYuZ4xAZW AjS7i9hOf+OZGb6cty5brYChvwMp0paJWeW7uYsAtcgupp8IKO5yYqoQgeEc/yA4Y+hu 6eWOJBZjVgq/MYgfvB7J+2xkjfZ4jPv2l1sTKDBjiXWNa7SRfkNftvOYmO69Kf9csIEt a+pw== X-Gm-Message-State: AA+aEWa5+OrmOr6NClazxHaaDV3NuB7PF+UfHkibBXwqfCd1FwBlspXa BQKjUUqocD/7f72f+PrbeZYC94lbWcPg8WfX X-Google-Smtp-Source: AFSGD/WVyHdROXjVL6SMwXWn0FfG5/sH9+lCfXbm2VcUixHYMXztemFrsGJ8tPfMahdGy50lSuKKL9UOYxOAE6cK X-Received: by 2002:a24:41d4:: with SMTP id b81mr6965561itd.0.1543837111512; Mon, 03 Dec 2018 03:38:31 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:27 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-12-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 11/30] dm: sound: wm899c: Split out interface setup code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With driver model we want to do a minimal probe when the device is probed and then set up the codec interface later when a sound is actully played. Split this setup code out into its own function to help with this. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/wm8994.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index f83fcf9f430..20a48231ebd 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -659,8 +659,7 @@ static int wm8994_init_volume_aif1_dac1(struct wm8994_priv *priv) * * @returns -1 for error and 0 Success. */ -static int wm8994_device_init(struct wm8994_priv *priv, - enum en_audio_interface aif_id) +static int wm8994_device_init(struct wm8994_priv *priv) { const char *devname; unsigned short reg_data; @@ -671,7 +670,7 @@ static int wm8994_device_init(struct wm8994_priv *priv, ret = wm8994_i2c_read(priv, WM8994_SOFTWARE_RESET, ®_data); if (ret < 0) { debug("Failed to read ID register\n"); - goto err; + return ret; } if (reg_data == WM8994_ID) { @@ -680,21 +679,28 @@ static int wm8994_device_init(struct wm8994_priv *priv, priv->type = WM8994; } else { debug("Device is not a WM8994, ID is %x\n", ret); - ret = -1; - goto err; + return -ENXIO; } ret = wm8994_i2c_read(priv, WM8994_CHIP_REVISION, ®_data); if (ret < 0) { debug("Failed to read revision register: %d\n", ret); - goto err; + return ret; } priv->revision = reg_data; debug("%s revision %c\n", devname, 'A' + priv->revision); + return 0; +} + +static int wm8994_setup_interface(struct wm8994_priv *priv, + enum en_audio_interface aif_id) +{ + int ret; + /* VMID Selection */ - ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1, - WM8994_VMID_SEL_MASK | WM8994_BIAS_ENA_MASK, 0x3); + ret = wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1, + WM8994_VMID_SEL_MASK | WM8994_BIAS_ENA_MASK, 0x3); /* Charge Pump Enable */ ret |= wm8994_bic_or(priv, WM8994_CHARGE_PUMP_1, WM8994_CP_ENA_MASK, @@ -807,10 +813,10 @@ static int wm8994_device_init(struct wm8994_priv *priv, if (ret < 0) goto err; - debug("%s: Codec chip init ok\n", __func__); + debug("%s: Codec chip setup ok\n", __func__); return 0; err: - debug("%s: Codec chip init error\n", __func__); + debug("%s: Codec chip setup error\n", __func__); return -1; } @@ -874,7 +880,7 @@ static int _wm8994_init(struct wm8994_priv *priv, { int ret; - ret = wm8994_device_init(priv, aif_id); + ret = wm8994_setup_interface(priv, aif_id); if (ret < 0) { debug("%s: wm8994 codec chip init failed\n", __func__); return ret; @@ -904,6 +910,7 @@ int wm8994_init(const void *blob, enum en_audio_interface aif_id, unsigned int channels) { struct sound_codec_info *pcodec_info = &g_codec_info; + int ret; /* Get the codec Values */ if (get_codec_values(pcodec_info, blob) < 0) { @@ -914,6 +921,11 @@ int wm8994_init(const void *blob, enum en_audio_interface aif_id, /* shift the device address by 1 for 7 bit addressing */ g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr; wm8994_i2c_init(pcodec_info->i2c_bus); + ret = wm8994_device_init(&g_wm8994_info); + if (ret < 0) { + debug("%s: wm8994 codec chip init failed\n", __func__); + return ret; + } return _wm8994_init(&g_wm8994_info, aif_id, sampling_rate, mclk_freq, bits_per_sample, channels); From patchwork Mon Dec 3 11:37:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006862 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CwnTl90W"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jyc5rYJz9s7W for ; Mon, 3 Dec 2018 22:51:52 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 2E6BCC221C8; Mon, 3 Dec 2018 11:44:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id EBCD4C222DF; Mon, 3 Dec 2018 11:39:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E8038C22414; Mon, 3 Dec 2018 11:38:40 +0000 (UTC) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by lists.denx.de (Postfix) with ESMTPS id 3190DC22168 for ; Mon, 3 Dec 2018 11:38:34 +0000 (UTC) Received: by mail-it1-f199.google.com with SMTP id m128so8367751itd.3 for ; Mon, 03 Dec 2018 03:38:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ZldcsimjKfq4CYhWgfJFR0s6rj34GGjXljMjGwT0Cws=; b=CwnTl90WwMtTnnyphZtvhVVsoa+fwCgUNRyYdsYMDX6isAiCrHx6tNs5ldHPF4Jdoe EAV3Raj78dMcEWdd4Y2mPIhJedoDJI3DazAQBP6UbeU/QVULlUyQ8MjYQ9tQ0zbTpbUA 21DaR5q46axQj9q/GrQo2GwmmWEFQILyqF4Mg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ZldcsimjKfq4CYhWgfJFR0s6rj34GGjXljMjGwT0Cws=; b=Q+BhR748sHcJ6ElcKBvPjdcY3uxG01OYAvJVZRRq6J6OjWeJz4eriUKOoin3Jx1zB/ 5KzaW7/yTe+EZXCe+w+8+TkOw84DnrcCmBLyXsAUFB4q4ScQCaSwH0jmWvfaY5EfjyLa 0CF1kpN2mwdeJkOowfNBuvLFmxE9pwVx6l+vLmJcJuvUX3DKQqT0I2LDST4pT9uCpEvc FuLB8FnNWUgRL9DBNlXmfzlpXmDRcpxZrXWBK5a+AJEEWc62hOf3ktyi8nmLPw5TQ1UM kMAeo3tK+JlNXCV8VN9DuIsbeCR4Gs2oyB/k9ibp0nZIxJPlKvtb9OdBH2JbEzPkLNet LhFA== X-Gm-Message-State: AA+aEWY3Az69PZ/giYRd9NVf8xETbchMmPw+eveCiLsAMGQ9982eRoTV sz4XYS3sRCRbHMpK7a0l4xrxhazOaS9Tks28 X-Google-Smtp-Source: AFSGD/Xc2Wl2aqJ+aiBaJy0ZMM2/XVxFQ0gPxfvlCw+Mds4vWrLqM6OMulwvII7y61XADPaojxGvwjCD/Nv6aU+u X-Received: by 2002:a24:4d82:: with SMTP id l124mr7010000itb.9.1543837113202; Mon, 03 Dec 2018 03:38:33 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:28 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-13-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 12/30] dm: sound: max98095: Split out interface setup code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With driver model we want to do a minimal probe when the device is probed and then set up the codec interface later when a sound is actully played. Split this setup code out into its own function to help with this. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/max98095.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index 6edf3736d79..51556c07f5e 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -384,12 +384,14 @@ static int max98095_reset(struct max98095_priv *priv) * * @returns -1 for error and 0 Success. */ -static int max98095_device_init(struct max98095_priv *priv, - enum en_max_audio_interface aif_id) +static int max98095_device_init(struct max98095_priv *priv) { unsigned char id; int error = 0; + /* Enable codec clock */ + set_xclkout(); + /* reset the codec, the DSP core, and disable all interrupts */ error = max98095_reset(priv); if (error != 0) { @@ -406,11 +408,19 @@ static int max98095_device_init(struct max98095_priv *priv, if (error < 0) { debug("%s: Failure reading hardware revision: %d\n", __func__, id); - goto err_access; + return error; } debug("%s: Hardware revision: %c\n", __func__, (id - 0x40) + 'A'); - error |= max98095_i2c_write(priv, M98095_097_PWR_SYS, M98095_PWRSV); + return 0; +} + +static int max98095_setup_interface(struct max98095_priv *priv, + enum en_max_audio_interface aif_id) +{ + int error; + + error = max98095_i2c_write(priv, M98095_097_PWR_SYS, M98095_PWRSV); /* * initialize registers to hardware default configuring audio @@ -463,7 +473,6 @@ static int max98095_device_init(struct max98095_priv *priv, else error |= max98095_i2c_write(priv, M98095_096_PWR_DAC_CK, 0x07); -err_access: if (error < 0) return -1; @@ -477,13 +486,7 @@ static int max98095_do_init(struct sound_codec_info *pcodec_info, { int ret = 0; - /* Enable codec clock */ - set_xclkout(); - - /* shift the device address by 1 for 7 bit addressing */ - g_max98095_i2c_dev_addr = pcodec_info->i2c_dev_addr >> 1; - - ret = max98095_device_init(&g_max98095_info, aif_id); + ret = max98095_setup_interface(&g_max98095_info, aif_id); if (ret < 0) { debug("%s: max98095 codec chip init failed\n", __func__); return ret; @@ -569,6 +572,15 @@ int max98095_init(const void *blob, enum en_max_audio_interface aif_id, } i2c_set_bus_num(pcodec_info->i2c_bus); + + /* shift the device address by 1 for 7 bit addressing */ + g_max98095_i2c_dev_addr = pcodec_info->i2c_dev_addr >> 1; + ret = max98095_device_init(&g_max98095_info); + if (ret < 0) { + debug("%s: max98095 codec chip init failed\n", __func__); + return ret; + } + ret = max98095_do_init(pcodec_info, aif_id, sampling_rate, mclk_freq, bits_per_sample); i2c_set_bus_num(old_bus); From patchwork Mon Dec 3 11:37:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006854 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JmRb3FTP"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jtT2HX5z9s55 for ; Mon, 3 Dec 2018 22:48:17 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id F2EAAC222D2; Mon, 3 Dec 2018 11:43:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 825AEC22218; Mon, 3 Dec 2018 11:38:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 48AAEC222D5; Mon, 3 Dec 2018 11:38:40 +0000 (UTC) Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by lists.denx.de (Postfix) with ESMTPS id 12CB9C2222C for ; Mon, 3 Dec 2018 11:38:36 +0000 (UTC) Received: by mail-yw1-f72.google.com with SMTP id v7so9107265ywv.1 for ; Mon, 03 Dec 2018 03:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=DV4C7FEpvkz0edlHmIVxFEjyslwGnepVfetj22ifAW8=; b=JmRb3FTPkJ8iHBtguY1ynwll5RlDLt+KjykQoeiv5pH6X82sNB+Lxclf4nrceuH5kD Ka6Z+A//i30dGSMzIeuXqCzKbkvhz+ZxoHvBXofQvPisU9FG7HZwLd44z57KCcby0ANK Kl7YRLFgSapSGtp1Mi1aW1D50xd454tfdQWoY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DV4C7FEpvkz0edlHmIVxFEjyslwGnepVfetj22ifAW8=; b=EtxkMQ0srZjRToqIj53d8+htQ2LlG3Aii56WqE3DHyYfccL7Hq2PIiAYNgQai/9hIP 67zbjIneVLM3gjmW16KE6O06cBX/R6nOjFRynRZA97cRGM6gEyvNbds4/BAA8nY8DCdN DAg4mvGKaH3LqDNEWrrI7i/HpN2M5HbHGwsgndktKK7tgxmnzMwi4ucSotazawJJmW03 0q2PCe7gf7b6vedGALvs4he1I7pNvmtna2xW+v3t+ZXWKen42tTS5l8EDyz0hzNK18Ab KfxG1wK4cp01yHrfZX9C/pioUvgoZFWQl9b7+1pj47Jws3vb54JrNpIctjaCJp/b4v8R DEtw== X-Gm-Message-State: AA+aEWab1RS5zCC7XvpiY+yIFgwlZKhjGB5YwTnztUL/cXU2+ZP5vQYl z4euUE01y/xyC4sDn1EKXkHoJLP7gout/rAL X-Google-Smtp-Source: AFSGD/XhicpN/fZCoiRYHk9vOgVwv67If4vf3CqyfmLeNpOSXsURxenCXlboYzxiSYtNWwx9S/eo78s5NzF4WcgE X-Received: by 2002:a25:da10:: with SMTP id n16mr1606309ybf.46.1543837114724; Mon, 03 Dec 2018 03:38:34 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:29 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-14-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 13/30] dm: sound: wm8994: Drop global i2c-address variable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We can put this in the private structure and avoid a global. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/wm8994.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index 20a48231ebd..a79f46bcc3a 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -38,6 +38,7 @@ struct wm8994_priv { int mclk[WM8994_MAX_AIF]; /* master clock frequency in Hz */ int aifclk[WM8994_MAX_AIF]; /* audio interface clock in Hz */ struct wm8994_fll_config fll[2]; /* fll config to configure fll */ + int i2c_addr; }; /* wm 8994 supported sampling rate values */ @@ -61,7 +62,6 @@ 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; /* @@ -92,7 +92,7 @@ static int wm8994_i2c_write(struct wm8994_priv *priv, unsigned int reg, val[1] = (unsigned char)(data & 0xff); debug("Write Addr : 0x%04X, Data : 0x%04X\n", reg, data); - return i2c_write(g_wm8994_i2c_dev_addr, reg, 2, val, 2); + return i2c_write(priv->i2c_addr, reg, 2, val, 2); } /* @@ -110,7 +110,7 @@ static unsigned int wm8994_i2c_read(struct wm8994_priv *priv, unsigned int reg, unsigned char val[2]; int ret; - ret = i2c_read(g_wm8994_i2c_dev_addr, reg, 2, val, 2); + ret = i2c_read(priv->i2c_addr, reg, 2, val, 2); if (ret != 0) { debug("%s: Error while reading register %#04x\n", __func__, reg); @@ -919,7 +919,7 @@ int wm8994_init(const void *blob, enum en_audio_interface aif_id, } /* shift the device address by 1 for 7 bit addressing */ - g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr; + g_wm8994_info.i2c_addr = pcodec_info->i2c_dev_addr; wm8994_i2c_init(pcodec_info->i2c_bus); ret = wm8994_device_init(&g_wm8994_info); if (ret < 0) { From patchwork Mon Dec 3 11:37:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006846 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bW7Rslz5"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jrM6cSqz9s55 for ; Mon, 3 Dec 2018 22:46:27 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 75A9EC221CC; Mon, 3 Dec 2018 11:43:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 298B4C2234F; Mon, 3 Dec 2018 11:38:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2A7CEC223DC; Mon, 3 Dec 2018 11:38:42 +0000 (UTC) Received: from mail-it1-f198.google.com (mail-it1-f198.google.com [209.85.166.198]) by lists.denx.de (Postfix) with ESMTPS id 36B3AC22266 for ; Mon, 3 Dec 2018 11:38:37 +0000 (UTC) Received: by mail-it1-f198.google.com with SMTP id t143so8321073itc.9 for ; Mon, 03 Dec 2018 03:38:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=OAcfA0Jnw8bQi+nc+03g5eRXIAyZYl88wH7bhhDHjcs=; b=bW7Rslz5W5/l3acyuO1NlPZDZDBJh+joq2sexpp4GyWNhjALU6EGMaHAKbLPsOVBAt XaS+7fISjHthlIr+q+4uZpUhWNjOaNlaj4t3MrS1reN9sTu4aIY4cHT17hhuN0efI4vF UurlZMMfNUuLEgbM3OufuOe++WDnCK5uMNc7M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=OAcfA0Jnw8bQi+nc+03g5eRXIAyZYl88wH7bhhDHjcs=; b=YuPq7wE2VY0oPHAqXL15FW2NL1M0Rm3s9ZvFvre+fDto30JPxF5qpyCFkW0xGaneaT txXJUlO88Lus3qKNZ0bD0MEjlCSI7Xtc+PM43eiyzt5l0Mcv4+zktziysrPn5kD8pyrI /hgvDTPm70hBQN/JlcqipFXthGQ0Rd0zf6TIvC3zifz+omlzlijf27onjfdsTT9MWZYA uMeIOf3zPvRqZpSXcnpZTHTE1mSgvABQRDwwLhpqfkP76aAQv3NxeZunnVKqKYCm5RHr WCqYprNaakvH4CNHcaSA1AFyS7pFr4XbO8j1PZJHsRrcGwvP87eSf8T0C5N+iUOY8/S8 qayw== X-Gm-Message-State: AA+aEWZz37dydUUvaP2Y/wdgbc0PeHrZVI2P77+EynYYBAH4HdNCWX1p vxTCxIulov07wurMWabKp2BAIQ+R79fl0eHJ X-Google-Smtp-Source: AFSGD/XHIdliDwDRCoRKyQg9t1cWgmp0ZQPRdDI4M2F41bnTAVBseA6I8OcNTlbW/rArL85eH5R8AAJWQOyBPqd5 X-Received: by 2002:a24:2812:: with SMTP id h18mr5248326ith.39.1543837116225; Mon, 03 Dec 2018 03:38:36 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:30 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-15-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 14/30] dm: sound: max98095: Drop global i2c-address variable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We can put this in the private structure and avoid a global. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/max98095.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index 51556c07f5e..2ec67bf24a8 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -28,11 +28,11 @@ struct max98095_priv { unsigned int sysclk; unsigned int rate; unsigned int fmt; + int i2c_addr; }; static struct sound_codec_info g_codec_info; struct max98095_priv g_max98095_info; -unsigned int g_max98095_i2c_dev_addr; /* Index 0 is reserved. */ int rate_table[] = {0, 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, @@ -52,7 +52,7 @@ static int max98095_i2c_write(struct max98095_priv *priv, unsigned int reg, { debug("%s: Write Addr : 0x%02X, Data : 0x%02X\n", __func__, reg, data); - return i2c_write(g_max98095_i2c_dev_addr, reg, 1, &data, 1); + return i2c_write(priv->i2c_addr, reg, 1, &data, 1); } /* @@ -69,7 +69,7 @@ static unsigned int max98095_i2c_read(struct max98095_priv *priv, { int ret; - ret = i2c_read(g_max98095_i2c_dev_addr, reg, 1, data, 1); + ret = i2c_read(priv->i2c_addr, reg, 1, data, 1); if (ret != 0) { debug("%s: Error while reading register %#04x\n", __func__, reg); @@ -574,7 +574,7 @@ int max98095_init(const void *blob, enum en_max_audio_interface aif_id, i2c_set_bus_num(pcodec_info->i2c_bus); /* shift the device address by 1 for 7 bit addressing */ - g_max98095_i2c_dev_addr = pcodec_info->i2c_dev_addr >> 1; + g_max98095_info.i2c_addr = pcodec_info->i2c_dev_addr >> 1; ret = max98095_device_init(&g_max98095_info); if (ret < 0) { debug("%s: max98095 codec chip init failed\n", __func__); From patchwork Mon Dec 3 11:37:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006861 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="T5PJLXT7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jvm4SYyz9s55 for ; Mon, 3 Dec 2018 22:49:24 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5A0DEC221BD; Mon, 3 Dec 2018 11:44:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6D168C2218E; Mon, 3 Dec 2018 11:39:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D4E5DC22186; Mon, 3 Dec 2018 11:38:42 +0000 (UTC) Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by lists.denx.de (Postfix) with ESMTPS id 0254BC222CF for ; Mon, 3 Dec 2018 11:38:39 +0000 (UTC) Received: by mail-yb1-f197.google.com with SMTP id n77so1472369ybg.15 for ; Mon, 03 Dec 2018 03:38:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=EnmDFH7ExrUrP4/P5yUoeGUW3ysr9ccJttVpL0adHgo=; b=T5PJLXT7AhVZs+EEZWSMqbANhorE/y40IfJfV+wtFDJbhDbawReJ0HDN98Y+hqK8Wm uJ3F97eAfCgS6UavoOsaKguAcR4a41dUeV2ARKppn+yAuBZmNOvM9dkFBXHs92HiYdUO vPekueQAETlIZhVYcWjGSrgdD7O8ECByd0/H8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=EnmDFH7ExrUrP4/P5yUoeGUW3ysr9ccJttVpL0adHgo=; b=PE9xHxMJ3LUW4T4nX5+otE6mqHPsxnnoKX76YsrwRBq6MnJJ4lrzHfsogMJdnnsaPo t01TuU48Dk1Cx+x33V5b2vUnB1rF1Rk5Ffw61mh8OBjtGVL4TSkLZmoeaRw6l7FNZnfT jIGINaBumjjovYYjym9EdfYJpbmEbizwq1UiLREnZHuWP+yoWBWgKhZkrABA9J5/J1q4 IP6aY33KY0TmUv6eja7iuOcCritEAsaXv16RFrNCF4yUeAjuSwveM5sbx2tCBwSAOyW1 NGp6j4ihpwePQONh1UhyCeeORkb4k9gUV5SsuZnpwNo3tJKmUiDu1RspD5aJP8HCm/GV ReyQ== X-Gm-Message-State: AA+aEWZOmtYa80q8gMWs+aap1C0mtFbrBp+0gfkCBcsEKIbskyQN73Cm o2CuKnDRqKgHAVL4iqexPd/JKmS+GcChUlwt X-Google-Smtp-Source: AFSGD/XDoggmqkmW50VR/5MldUgxTJ5a/Es6oom36wSb8zzi9RViYSrV7UHf1HywS8xb8Onr86ko+nmq1CNc71Zp X-Received: by 2002:a25:80ce:: with SMTP id c14-v6mr9478809ybm.53.1543837117916; Mon, 03 Dec 2018 03:38:37 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:31 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-16-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 15/30] dm: sound: wm8994: Drop g_codec_info and g_wm8994_info X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" These are only used in two functions so can be made local. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/wm8994.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index a79f46bcc3a..be27e2b1e7e 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -61,9 +61,6 @@ static int bclk_divs[] = { 640, 880, 960, 1280, 1760, 1920 }; -static struct wm8994_priv g_wm8994_info; -static struct sound_codec_info g_codec_info; - /* * Initialise I2C for wm 8994 * @@ -909,24 +906,25 @@ 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) { - struct sound_codec_info *pcodec_info = &g_codec_info; + struct sound_codec_info pcodec_info; + struct wm8994_priv wm8994_info; int ret; /* Get the codec Values */ - if (get_codec_values(pcodec_info, blob) < 0) { + 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_info.i2c_addr = pcodec_info->i2c_dev_addr; - wm8994_i2c_init(pcodec_info->i2c_bus); - ret = wm8994_device_init(&g_wm8994_info); + wm8994_info.i2c_addr = pcodec_info.i2c_dev_addr; + wm8994_i2c_init(pcodec_info.i2c_bus); + ret = wm8994_device_init(&wm8994_info); if (ret < 0) { debug("%s: wm8994 codec chip init failed\n", __func__); return ret; } - return _wm8994_init(&g_wm8994_info, aif_id, sampling_rate, mclk_freq, + return _wm8994_init(&wm8994_info, aif_id, sampling_rate, mclk_freq, bits_per_sample, channels); } From patchwork Mon Dec 3 11:37:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006848 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="V4ixxsNV"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jsC5q7bz9s55 for ; Mon, 3 Dec 2018 22:47:11 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 77349C22168; Mon, 3 Dec 2018 11:43:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A28E7C22311; Mon, 3 Dec 2018 11:38:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1AD98C22209; Mon, 3 Dec 2018 11:38:47 +0000 (UTC) Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by lists.denx.de (Postfix) with ESMTPS id 0B3A4C223DB for ; Mon, 3 Dec 2018 11:38:41 +0000 (UTC) Received: by mail-oi1-f198.google.com with SMTP id x65so8137403oix.0 for ; Mon, 03 Dec 2018 03:38:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=CHlSjHtVyayWm5FnxycbZqGobEvY+a+Ax+nwHYcKCm0=; b=V4ixxsNVDRmnoMFmMj4cmKHQaHfyO/UX60ybwvzQtBEUEt9OMUsbHfLM28MhvsdWEh 6VYFFLiQ+J+cEvHBU4Kgr1rZ+PqqCDH9bXgJAosPYxF1ikExCSRHRuNO3f2rSqD0UjJv ArzalR53fCDc0Jp/6OLqw6uF5KR/3/87Nza5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=CHlSjHtVyayWm5FnxycbZqGobEvY+a+Ax+nwHYcKCm0=; b=FJr9tQGeH4ka0qb1DGORcL2gPRa0C9+i82cPw9LofHlSiIzERpnPs9VU7HMZnt2c7x Zgoj49IPU5qyx09Yq1AYu7HJiHriVggN815ZkLXpelgoe8DlFl9kAECL8+xwpAoe+1vh X/nwdWxUmF/KD3MF4RpaWPgqNK+T1z0252UowPDclN9ejcnQTRENvwH23QXN5qW+OFgb H3bL4Xbl+gM5JWLu9U2XOs+ngF6nAKz/neMCYnleDAkO/3lL3w8dC2N1/w2ca6Qk9hjm UYV67MZziyxAg4hWRP01CplcelItxMIe5VKyVkhtIXBUFZt8+ifSN3DJoR+ppuEjpgDm 5o2A== X-Gm-Message-State: AA+aEWbnAzd9alUHQFFTPJbx0mO8+jWYeRbk8s7GFCmMeNljgQom8xbP 1OVUK6Mp3XV2p2wkUelDJZ673V1Agd7sriLD X-Google-Smtp-Source: AFSGD/USzKu+7gfTiAHPB8p2h35FnOD4uxzaDsgBbgot1aeahSj4IKgas1VDcJhcC3sA7O2jSbKI2A/I/ip36vx3 X-Received: by 2002:aca:f38b:: with SMTP id r133mr13732449oih.35.1543837119519; Mon, 03 Dec 2018 03:38:39 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:32 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-17-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 16/30] dm: sound: max98095: Drop g_codec_info and g_max98095_info X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" These are only used in two functions so can be made local. Also change the first argument of max98095_do_init() to suit. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/max98095.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index 2ec67bf24a8..d7313f9ad75 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -31,9 +31,6 @@ struct max98095_priv { int i2c_addr; }; -static struct sound_codec_info g_codec_info; -struct max98095_priv g_max98095_info; - /* Index 0 is reserved. */ int rate_table[] = {0, 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000}; @@ -479,31 +476,30 @@ static int max98095_setup_interface(struct max98095_priv *priv, return 0; } -static int max98095_do_init(struct sound_codec_info *pcodec_info, +static int max98095_do_init(struct max98095_priv *priv, enum en_max_audio_interface aif_id, int sampling_rate, int mclk_freq, int bits_per_sample) { int ret = 0; - ret = max98095_setup_interface(&g_max98095_info, aif_id); + ret = max98095_setup_interface(priv, aif_id); if (ret < 0) { debug("%s: max98095 codec chip init failed\n", __func__); return ret; } - ret = max98095_set_sysclk(&g_max98095_info, mclk_freq); + ret = max98095_set_sysclk(priv, mclk_freq); if (ret < 0) { debug("%s: max98095 codec set sys clock failed\n", __func__); return ret; } - ret = max98095_hw_params(&g_max98095_info, aif_id, sampling_rate, + ret = max98095_hw_params(priv, aif_id, sampling_rate, bits_per_sample); if (ret == 0) { - ret = max98095_set_fmt(&g_max98095_info, - SND_SOC_DAIFMT_I2S | + ret = max98095_set_fmt(priv, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, aif_id); @@ -564,24 +560,25 @@ int max98095_init(const void *blob, enum en_max_audio_interface aif_id, { int ret; int old_bus = i2c_get_bus_num(); - struct sound_codec_info *pcodec_info = &g_codec_info; + struct sound_codec_info pcodec_info; + struct max98095_priv max98095_info; - if (get_max98095_codec_values(pcodec_info, blob) < 0) { + if (get_max98095_codec_values(&pcodec_info, blob) < 0) { debug("FDT Codec values failed\n"); return -1; } - i2c_set_bus_num(pcodec_info->i2c_bus); + i2c_set_bus_num(pcodec_info.i2c_bus); /* shift the device address by 1 for 7 bit addressing */ - g_max98095_info.i2c_addr = pcodec_info->i2c_dev_addr >> 1; - ret = max98095_device_init(&g_max98095_info); + max98095_info.i2c_addr = pcodec_info.i2c_dev_addr >> 1; + ret = max98095_device_init(&max98095_info); if (ret < 0) { debug("%s: max98095 codec chip init failed\n", __func__); return ret; } - ret = max98095_do_init(pcodec_info, aif_id, sampling_rate, mclk_freq, + ret = max98095_do_init(&max98095_info, aif_id, sampling_rate, mclk_freq, bits_per_sample); i2c_set_bus_num(old_bus); From patchwork Mon Dec 3 11:37:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006866 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ksS/UJWC"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437k5r5Wt0z9sBh for ; Mon, 3 Dec 2018 22:58:08 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7157AC22198; Mon, 3 Dec 2018 11:50:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 57FEEC22454; Mon, 3 Dec 2018 11:39:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5F0DEC2243C; Mon, 3 Dec 2018 11:38:49 +0000 (UTC) Received: from mail-vs1-f70.google.com (mail-vs1-f70.google.com [209.85.217.70]) by lists.denx.de (Postfix) with ESMTPS id 21EDAC2220B for ; Mon, 3 Dec 2018 11:38:42 +0000 (UTC) Received: by mail-vs1-f70.google.com with SMTP id d132so6939963vsc.10 for ; Mon, 03 Dec 2018 03:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=42SZceafmjhgkgYQ+ty739vRD8+NmJXSMNUfkfjGZho=; b=ksS/UJWCmUdUACJ9QVaBK5v+k97XFG5njeM0h7gpfeSdSl1gxWg2+LVirxWCGqQMHg SL/jxA5Wo6h8qabKY7vEIMhymiDhTaz3hydbXQE+JgEoN3cltjjpEYzX6VQaQ0lWTe9p LDdqsUpCw/+wCDMHOoZoMOGi4bglFFRJbj5/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=42SZceafmjhgkgYQ+ty739vRD8+NmJXSMNUfkfjGZho=; b=OJgTe2upUS7OkF+ylXFhKyNnaL2t76myswOAunvhOyd4UEqgHw1QjwjuZZIehAGSDV W3qZa5HVnUqt/RyNyxZlM7oxAWLLl9Koc1EmOzBsLOFBLwk9fr/xKxh5AtwkxrqBI9KR H1j3sFUlIiLvZi89JleM7UlIaQVoNYZy5gFg7+GHSe9T2z/vWu8TAYDoDpAOMwm8V5Jg y9Tr6w+pqUBWlbpj/u6QIPX4s92a9LBR/dn6y7gfSj13e6bFOpBgN0n6DomA3AWdJr1A zuGeeqPenQrc1WqA8TNvx4wfZLKSIZv+ahbQPfblMoFGOvNvy9YMXPINr2818NjgLvV2 o1eQ== X-Gm-Message-State: AA+aEWar/K2UcVSxLyB2WM4Qu3GLOEhc6uIkMFOd2PPNAn8Dycm178Vg jsLm+LqjmAhtXx1CmFJ1jXPRoz7UYgSZ+P20 X-Google-Smtp-Source: AFSGD/UGrMxsDAE2l0mJdHJzt4Y8dPhkJk4b9//sDzx19PYDv6/piOi+K9dvJKZcG7FakMYO6ZBL6kHd+Uy8XJcJ X-Received: by 2002:a67:32d7:: with SMTP id y206mr13963577vsy.46.1543837121194; Mon, 03 Dec 2018 03:38:41 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:33 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-18-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 17/30] dm: sound: wm8994: Drop wm8994_i2c_init() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This function has only one line in it. Drop it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/wm8994.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index be27e2b1e7e..a888a0b4c95 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -61,16 +61,6 @@ static int bclk_divs[] = { 640, 880, 960, 1280, 1760, 1920 }; -/* - * Initialise I2C for wm 8994 - * - * @param bus no i2c bus number in which wm8994 is connected - */ -static void wm8994_i2c_init(int bus_no) -{ - i2c_set_bus_num(bus_no); -} - /* * Writes value to a device register through i2c * @@ -918,7 +908,7 @@ int wm8994_init(const void *blob, enum en_audio_interface aif_id, /* shift the device address by 1 for 7 bit addressing */ wm8994_info.i2c_addr = pcodec_info.i2c_dev_addr; - wm8994_i2c_init(pcodec_info.i2c_bus); + i2c_set_bus_num(pcodec_info.i2c_bus); ret = wm8994_device_init(&wm8994_info); if (ret < 0) { debug("%s: wm8994 codec chip init failed\n", __func__); From patchwork Mon Dec 3 11:37:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006863 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ii41oozg"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jzp53p7z9s9G for ; Mon, 3 Dec 2018 22:52:54 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 49ACAC22183; Mon, 3 Dec 2018 11:45:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8DB94C223E9; Mon, 3 Dec 2018 11:39:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 839ECC221DE; Mon, 3 Dec 2018 11:38:49 +0000 (UTC) Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by lists.denx.de (Postfix) with ESMTPS id B372CC22266 for ; Mon, 3 Dec 2018 11:38:43 +0000 (UTC) Received: by mail-oi1-f200.google.com with SMTP id x65so8137462oix.0 for ; Mon, 03 Dec 2018 03:38:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=bH0jYZXC7YxhWjDUkxl+B7YJl7rqLabZ2NiZc28RcfU=; b=ii41oozgEyLbG7aXayY1xgEzpcIHThA4lwUdabP9lpT1tUNsE2WfAGkGYGRUWL2vS4 xcxi9rSP+CztANgRwdMoKacP3L7ODJBiiuPAfTQ038soNeHuR1OpyXrkvaqjuOtCS3Jj akh0Gp614zTGIVSDVe9JVTKRR5DWc/OzeDAaI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bH0jYZXC7YxhWjDUkxl+B7YJl7rqLabZ2NiZc28RcfU=; b=tfvp0JgYrUjCHeM7QwWqEZTwXp2BlWzQ8bD9FIgHkRu7vCoBmbEd61/z0SRYenaSxi mDo/2u6XkJqXE4tQQxKrgnifHqer7V369gTvqMGcd9ab06n7samaUrU4BC61f6M5KVvB o6FWU9qgFiDgQFgYHFHIUhK8no8TUf90dn74WuCUEGrNr1LyJ1LSrVBExZ+QNrH80NYR bDPtRGq1YNjErM0REvp3jmd1K4iziFbkK3gdImRbUKTZW8QK8R6CRmTp5SspAuX2MbZT gqXz7XHuYfYmtFu2rWWhm/7c5kw3oLGzsgLncL2lfkRPYBRpJMTFrC8qj59/RGBXQQRX em+w== X-Gm-Message-State: AA+aEWYeFhTUonTnNe4DZnaWkJN7nmkBgH7xyI5GyX55D2MHUCOFJa8O WatGhpkSo/kuCRtNk9NsQGF6Q2NNYFqhblFt X-Google-Smtp-Source: AFSGD/WtN6bZNaDfEciTsslOBpVWo2HUy6LXGf97PgqL4RJ190cN9KDO9GCG5qHSinAIH7EUJNtM2VBgaiq8EMEe X-Received: by 2002:aca:47c9:: with SMTP id u192mr12713753oia.14.1543837122704; Mon, 03 Dec 2018 03:38:42 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:34 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-19-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 18/30] dm: sound: Fix up header ordering X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Tidy up the ordering of header files in the sounds files. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sound/max98095.c | 11 +++++------ drivers/sound/samsung-i2s.c | 36 ++++++++++++++++++------------------ drivers/sound/wm8994.c | 8 ++++---- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index d7313f9ad75..6a98dac04bb 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -10,17 +10,16 @@ * published by the Free Software Foundation. */ -#include -#include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include +#include #include "i2s.h" #include "max98095.h" diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c index 7f4388137a5..c07d3cdb4c8 100644 --- a/drivers/sound/samsung-i2s.c +++ b/drivers/sound/samsung-i2s.c @@ -4,13 +4,13 @@ * R. Chandrasekar */ +#include +#include +#include #include #include #include #include -#include -#include -#include #define FIC_TX2COUNT(x) (((x) >> 24) & 0xf) #define FIC_TX1COUNT(x) (((x) >> 16) & 0xf) @@ -170,7 +170,7 @@ static int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt) default: debug("%s: Invalid format priority [0x%x]\n", __func__, (fmt & SND_SOC_DAIFMT_FORMAT_MASK)); - return -1; + return -ERANGE; } /* @@ -189,7 +189,7 @@ static int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt) default: debug("%s: Invalid clock ploarity input [0x%x]\n", __func__, (fmt & SND_SOC_DAIFMT_INV_MASK)); - return -1; + return -ERANGE; } switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -201,13 +201,13 @@ static int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt) ret = i2s_set_sysclk_dir(i2s_reg, SND_SOC_CLOCK_OUT); if (ret != 0) { debug("%s:set i2s clock direction failed\n", __func__); - return -1; + return ret; } break; default: debug("%s: Invalid master selection [0x%x]\n", __func__, (fmt & SND_SOC_DAIFMT_MASTER_MASK)); - return -1; + return -ERANGE; } mod &= ~(MOD_SDF_MASK | MOD_LR_RLOW | MOD_SLAVE); @@ -248,7 +248,7 @@ static int i2s_set_samplesize(struct i2s_reg *i2s_reg, unsigned int blc) default: debug("%s: Invalid sample size input [0x%x]\n", __func__, blc); - return -1; + return -ERANGE; } writel(mod, &i2s_reg->mod); @@ -265,7 +265,7 @@ int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, unsigned int *data, if (data_size < FIFO_LENGTH) { debug("%s : Invalid data size\n", __func__); - return -1; /* invalid pcm data size */ + return -ENODATA; /* invalid pcm data size */ } /* fill the tx buffer before stating the tx transmit */ @@ -284,7 +284,7 @@ int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, unsigned int *data, if (get_timer(start) > TIMEOUT_I2S_TX) { i2s_txctrl(i2s_reg, I2S_TX_OFF); debug("%s: I2S Transfer Timeout\n", __func__); - return -1; + return -ETIMEDOUT; } } } @@ -312,20 +312,20 @@ int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx) ret = set_epll_clk(pi2s_tx->audio_pll_clk); } else { debug("%s: unsupported i2s-%d bus\n", __func__, pi2s_tx->id); - return -1; + return -ERANGE; } - if (ret != 0) { + if (ret) { debug("%s: epll clock set rate failed\n", __func__); - return -1; + return ret; } /* Select Clk Source for Audio 0 or 1 */ ret = set_i2s_clk_source(pi2s_tx->id); - if (ret == -1) { + if (ret) { debug("%s: unsupported clock for i2s-%d\n", __func__, pi2s_tx->id); - return -1; + return ret; } if (pi2s_tx->id == 0) { @@ -341,10 +341,10 @@ int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx) (pi2s_tx->samplingrate * (pi2s_tx->rfs)), pi2s_tx->id); } - if (ret == -1) { + if (ret) { debug("%s: unsupported prescalar for i2s-%d\n", __func__, pi2s_tx->id); - return -1; + return ret; } /* Configure I2s format */ @@ -355,7 +355,7 @@ int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx) ret = i2s_set_samplesize(i2s_reg, pi2s_tx->bitspersample); if (ret != 0) { debug("%s:set sample rate failed\n", __func__); - return -1; + return ret; } i2s_set_bitclk_framesize(i2s_reg, pi2s_tx->bfs); diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index a888a0b4c95..1714f430f39 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -4,15 +4,15 @@ * R. Chandrasekar */ #include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include #include #include "wm8994.h" #include "wm8994_registers.h" From patchwork Mon Dec 3 11:37:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006865 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="VUJpozYW"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437k4k5nmCz9s9G for ; Mon, 3 Dec 2018 22:57:10 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7F7B5C2227D; Mon, 3 Dec 2018 11:50:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id ECF3FC2243C; Mon, 3 Dec 2018 11:39:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D9032C2243C; Mon, 3 Dec 2018 11:38:51 +0000 (UTC) Received: from mail-it1-f198.google.com (mail-it1-f198.google.com [209.85.166.198]) by lists.denx.de (Postfix) with ESMTPS id 63545C2220F for ; Mon, 3 Dec 2018 11:38:45 +0000 (UTC) Received: by mail-it1-f198.google.com with SMTP id y86so8373217ita.2 for ; Mon, 03 Dec 2018 03:38:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=LvEHb36IH/1IO1FW81P1vrHYvRT98sQ+9thl0W1ReOs=; b=VUJpozYWxzHZ5w7ahGACdz7+9ocxw16TOryX9dlifxntLa8yKaGbUods/NGfLcIg81 BHl3RnHEQifNuOYgHgOIX0Y43XKHzQalyJ7qCYknUEovqQJyctCNDG7EkV/Oxuf/LFPu VTxOHZ/2SFnYXF0vuKKDLZfon4dG0+y06kAsU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=LvEHb36IH/1IO1FW81P1vrHYvRT98sQ+9thl0W1ReOs=; b=srHWrVeaXQ5Hg/RXha3KRkO4X+9An/prmIRy6ZccJtbtIDeX+CPWkP65NAWpPtSpuk KndjQgjAxGPh8LhLi5xJN0ahGtI74jOSenqNBPBLxrqhkpps+HcwLlWeAi0psEEZFq2W iaxRBT6NhwTm7REVelJ0SzhawjCRvnz5zKx7z6M95aG9tsara4jhDmp3KNkiMc5XJjhC 3CdAD6ubTJ5Cn19F3/DDwKdMdVwIQK/LEC4dqFTxRPCYlva9U2OXiceg2A1LDmCzmYZz 3V8GsNm1lbcXR31uNjJarJO1uujUhr2Lhc+yBigRwGr7upbqnHHhkDo5g4U1364NRqVF 7DKw== X-Gm-Message-State: AA+aEWbwY/rqO00Iv7UViTS34Z0+OdnkCVzmg0AcPc85ofzo9+3FTSDz fp+UWF5kCzZa7uC5Kh2dOgPEtmzYum0yMERS X-Google-Smtp-Source: AFSGD/WSWEn+Zt87fOgQv9GDA2NGZ98G08ITBLZkq+OsbceMPeoSIK/C3IEKLHPY0+b2/kH8X72IjhEbHb/t2iuW X-Received: by 2002:a24:2cd1:: with SMTP id i200mr6618249iti.24.1543837124387; Mon, 03 Dec 2018 03:38:44 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:35 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-20-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 19/30] dm: sound: exynos: Correct codec bus address X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The codec is at address 0x11 on the i2c bus, in 7-bit format. The device tree and code are in 8-bit format (i.e. shifted left one bit). Fix both. Signed-off-by: Simon Glass --- arch/arm/dts/exynos5250-snow.dts | 4 ++-- drivers/sound/max98095.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/arm/dts/exynos5250-snow.dts b/arch/arm/dts/exynos5250-snow.dts index e99f6e72bf6..cb5067b9669 100644 --- a/arch/arm/dts/exynos5250-snow.dts +++ b/arch/arm/dts/exynos5250-snow.dts @@ -214,8 +214,8 @@ }; }; - soundcodec@22 { - reg = <0x22>; + soundcodec@11 { + reg = <0x11>; compatible = "maxim,max98095-codec"; }; }; diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index 6a98dac04bb..7a3dbd09840 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -569,8 +569,7 @@ int max98095_init(const void *blob, enum en_max_audio_interface aif_id, i2c_set_bus_num(pcodec_info.i2c_bus); - /* shift the device address by 1 for 7 bit addressing */ - max98095_info.i2c_addr = pcodec_info.i2c_dev_addr >> 1; + max98095_info.i2c_addr = pcodec_info.i2c_dev_addr; ret = max98095_device_init(&max98095_info); if (ret < 0) { debug("%s: max98095 codec chip init failed\n", __func__); From patchwork Mon Dec 3 11:37:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006860 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CMY1qDno"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jvj03GDz9s55 for ; Mon, 3 Dec 2018 22:49:20 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A85DFC2222A; Mon, 3 Dec 2018 11:46:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A9685C221C8; Mon, 3 Dec 2018 11:39:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C8267C2240E; Mon, 3 Dec 2018 11:38:51 +0000 (UTC) Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by lists.denx.de (Postfix) with ESMTPS id E9334C2234F for ; Mon, 3 Dec 2018 11:38:46 +0000 (UTC) Received: by mail-io1-f72.google.com with SMTP id q23so13953581ior.6 for ; Mon, 03 Dec 2018 03:38:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gV4MVSDRk1ppXC1JBD7PqnpvvjsozwRPkHaRWr1qwbM=; b=CMY1qDno/Ee4RhIymSObeFmv/kEEXF2L93wjygZu3TD0pR+8Y2Xj7ooSyLgOlC3vht cB4Xe/appZoMKtvtgdmmcKgzGszw8cusLT3OrbCscRHOfP5XE3t9AfpgJVct0nk8kySv uWDmWrfZiuIK7YGegbDAebdCOiqJsOYXl2NBg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gV4MVSDRk1ppXC1JBD7PqnpvvjsozwRPkHaRWr1qwbM=; b=BK/riS/jhiNGPd02W1UqA2rgA6pw9nhJStYTCVGRaBcjKW10OL2ysBC3R6YD/jvM5I ++q9PpPO90zU3d94bgPjIBHh+76GxVasaRD1ZCK6kLDCql3f1/Cvn66XF3aVEJbiVTSM AcV+2ayAtdtgh9DRLLZPs8D9QGYDuoq6bpt5PSHAgSkR7bJ/B35wjPmYXtKslYebee2Q T/mjaiCHzIuCKWkNNBw+jyoKgKb1j9Xetco2wIYrhWGAE4nnpuJmfN1kZamKUMl4PEnF I6r+9fcLmgrFnD2x1jYAHA0LD+K45B+czm3poNhAbLjkoHBzV8HiOk7ULnBWpjzbNcB6 V/jQ== X-Gm-Message-State: AA+aEWYoyZG5FAp3IoWzJ6eXKCNwEus4wpYchHMLzoU1IbNxinoeZuWT LutyjqLzKk9mXWCEW6YXn3hWroxDtJFQqNEV X-Google-Smtp-Source: AFSGD/U0V2m2767V51e8T+hvygYtdzsjioprBq7SHRyQsmd7Gigh0/FvvJCrPzBo5wl6ryyTxdq1WpDhAYGDhDWd X-Received: by 2002:a24:1f0f:: with SMTP id d15mr6629305itd.31.1543837125972; Mon, 03 Dec 2018 03:38:45 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:36 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-21-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 20/30] dm: sound: Create an option to use driver model for sound X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The U-Boot sound system provides basic support for beeping. At present it does not use driver model, but it needs to be converted. Add an option to enable driver model for sound. For now it is not connected to anything. Future work will add drivers which use this option. It will then be removed once everything is converted. Signed-off-by: Simon Glass --- configs/sandbox_defconfig | 1 + drivers/sound/Kconfig | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 4d65a01dc5b..ad7b25c5f35 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -176,6 +176,7 @@ CONFIG_SANDBOX_SERIAL=y CONFIG_SMEM=y CONFIG_SANDBOX_SMEM=y CONFIG_SOUND=y +CONFIG_DM_SOUND=y CONFIG_SOUND_SANDBOX=y CONFIG_SANDBOX_SPI=y CONFIG_SPMI=y diff --git a/drivers/sound/Kconfig b/drivers/sound/Kconfig index 5de86c05c60..93f6c36af32 100644 --- a/drivers/sound/Kconfig +++ b/drivers/sound/Kconfig @@ -12,6 +12,12 @@ config SOUND audio codecs are called from the sound-i2s code. This could be converted to driver model. +config DM_SOUND + bool "Use driver model for sound" + help + Enable this option to use driver model for sound devices. This is a + migration option and will be removed. + config I2S bool "Enable I2S support" depends on SOUND From patchwork Mon Dec 3 11:37:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006870 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UJK9VFag"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437k6t1cF2z9sBh for ; Mon, 3 Dec 2018 22:59:02 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D3003C2246F; Mon, 3 Dec 2018 11:50:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1BFC4C2247A; Mon, 3 Dec 2018 11:39:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7EFCFC22160; Mon, 3 Dec 2018 11:38:53 +0000 (UTC) Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by lists.denx.de (Postfix) with ESMTPS id 8059BC223AF for ; Mon, 3 Dec 2018 11:38:48 +0000 (UTC) Received: by mail-qt1-f199.google.com with SMTP id w18so12922666qts.8 for ; Mon, 03 Dec 2018 03:38:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=SQmQ6Rt0ApdASD0T759fs9PwaUwvgyhi00tPfIISB8s=; b=UJK9VFagRul/fSE2Zy3nAgRCOsP/j72on08Ac1nY20KcPsVwhAGf3chLyhpOCFljV/ +Gl6xDJhGQRmNCLVmUAPVI/MFKmYn6OkWlnOxnDm/mA1q7IKG1YFErARaTSea3GtAfEx HPDOp/xgKEKKHYLR4/cJcLkbe7mkctFfy3agc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=SQmQ6Rt0ApdASD0T759fs9PwaUwvgyhi00tPfIISB8s=; b=gj9XFI6i3/mWjB4iFZDdDczOPxp0J7J/JV1KKvq6tzIvsAChEAkmJmk3yf/vwmsv5H Kl58Y6YLF/+8URn5b5LgRJsefq3BfNdRVBIDmPUvOEVREolB+au5KKAyHT6bNTWAjVzg DeNh5Xd+N3RVa9Lib/VI3r3mzS1xT/fxY+eEovmKR3P0gtnteG1Be6bYaLtNifx+eOqb EeIOBR1qPgnr1zGaVVCu79oj+aWeBNNEWHrCoP7/dZeQV8iBToG+sDaMSYQ04D03CZwH EgUScusyZyy7HTaRdyDFa4SBzZkNP4h53mu1OR9aUl1P44DIf0dwTfGlT7oMXpSEV1Td WuTw== X-Gm-Message-State: AA+aEWaD3Gan9OC05ee8wssVAipwDCgSSzBTKUUoTByHqhLfW4ZTFO1S UAeuPCNXCq9EJOr+qnagWyDhx09tiYKWYQ2X X-Google-Smtp-Source: AFSGD/Wwn25DEoySjyXlCj1i0XDLGal1CU0UdtP/ZPPqUg+15uBRWn+WThkq7blBwD+ZGnouR2VhK/Fkbx1PbKk3 X-Received: by 2002:ac8:17e6:: with SMTP id r35mr11321295qtk.45.1543837127574; Mon, 03 Dec 2018 03:38:47 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:37 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-22-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 21/30] dm: sound: Rename samsung_i2s_priv to i2s_uc_priv X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This structure contains information that is likely needed by any i2s driver so it seems useful to attach it to the (forthcoming) i2c uclass. For now, just rename it. Signed-off-by: Simon Glass --- drivers/sound/samsung-i2s.c | 4 ++-- drivers/sound/sound-i2s.c | 10 +++++----- include/i2s.h | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c index c07d3cdb4c8..5cd585808ab 100644 --- a/drivers/sound/samsung-i2s.c +++ b/drivers/sound/samsung-i2s.c @@ -255,7 +255,7 @@ static int i2s_set_samplesize(struct i2s_reg *i2s_reg, unsigned int blc) return 0; } -int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, unsigned int *data, +int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, unsigned int *data, unsigned long data_size) { int i; @@ -293,7 +293,7 @@ int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, unsigned int *data, return 0; } -int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx) +int i2s_tx_init(struct i2s_uc_priv *pi2s_tx) { int ret; struct i2s_reg *i2s_reg = diff --git a/drivers/sound/sound-i2s.c b/drivers/sound/sound-i2s.c index 106842a23db..ed130750b2e 100644 --- a/drivers/sound/sound-i2s.c +++ b/drivers/sound/sound-i2s.c @@ -20,15 +20,15 @@ #define SOUND_400_HZ 400 #define SOUND_BITS_IN_BYTE 8 -static struct samsung_i2s_priv g_i2stx_pri; +static struct i2s_uc_priv g_i2stx_pri; /* * get_sound_i2s_values gets values for i2s parameters * - * @param samsung_i2s_priv i2s transmitter transfer param structure + * @param i2s_uc_priv i2s transmitter transfer param structure * @param blob FDT blob if enabled else NULL */ -static int get_sound_i2s_values(struct samsung_i2s_priv *i2s, const void *blob) +static int get_sound_i2s_values(struct i2s_uc_priv *i2s, const void *blob) { int node; int error = 0; @@ -97,7 +97,7 @@ static int get_sound_i2s_values(struct samsung_i2s_priv *i2s, const void *blob) * @param pi2s_tx i2s parameters required by codec * @return int value, 0 for success */ -static int codec_init(const void *blob, struct samsung_i2s_priv *pi2s_tx) +static int codec_init(const void *blob, struct i2s_uc_priv *pi2s_tx) { int ret; const char *codectype; @@ -145,7 +145,7 @@ static int codec_init(const void *blob, struct samsung_i2s_priv *pi2s_tx) int sound_init(const void *blob) { int ret; - struct samsung_i2s_priv *pi2s_tx = &g_i2stx_pri; + struct i2s_uc_priv *pi2s_tx = &g_i2stx_pri; /* Get the I2S Values */ if (get_sound_i2s_values(pi2s_tx, blob) < 0) { diff --git a/include/i2s.h b/include/i2s.h index 800473abd9c..f23862ca040 100644 --- a/include/i2s.h +++ b/include/i2s.h @@ -76,7 +76,7 @@ struct i2s_reg { }; /* This structure stores the i2s related information */ -struct samsung_i2s_priv { +struct i2s_uc_priv { unsigned int rfs; /* LR clock frame size */ unsigned int bfs; /* Bit slock frame size */ unsigned int audio_pll_clk; /* Audio pll frequency in Hz */ @@ -96,7 +96,7 @@ struct samsung_i2s_priv { * * @return int value 0 for success, -1 in case of error */ -int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, uint *data, +int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, unsigned int *data, unsigned long data_size); /* @@ -106,6 +106,6 @@ int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, uint *data, * * @return int value 0 for success, -1 in case of error */ -int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx); +int i2s_tx_init(struct i2s_uc_priv *pi2s_tx); #endif /* __I2S_H__ */ From patchwork Mon Dec 3 11:37:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006850 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ibM9SInW"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jsZ4X9xz9s55 for ; Mon, 3 Dec 2018 22:47:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 088DEC22005; Mon, 3 Dec 2018 11:45:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7E240C221CB; Mon, 3 Dec 2018 11:39:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6DD22C221DE; Mon, 3 Dec 2018 11:38:54 +0000 (UTC) Received: from mail-yw1-f71.google.com (mail-yw1-f71.google.com [209.85.161.71]) by lists.denx.de (Postfix) with ESMTPS id 62AF5C22329 for ; Mon, 3 Dec 2018 11:38:50 +0000 (UTC) Received: by mail-yw1-f71.google.com with SMTP id j81so9071177ywj.15 for ; Mon, 03 Dec 2018 03:38:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=frh8KblYSUwXSnvp3flKoNrOCHHxErt7qKE2pqtfFso=; b=ibM9SInWNyHT2XszMvvxVii9mcIrT96HE93eT+3Z5GVgN1QAB5290T6aAHpcIiqN/C GDe3WL7fyGVyPi1BXJp5Ki+BBtaM7j3VDymKFHQVDaaU7bWgVj5P5seKOTO3EQP194Fq WaGYsB72XwGBWl2MW5sPs0ld5fWadPwp4IdGQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=frh8KblYSUwXSnvp3flKoNrOCHHxErt7qKE2pqtfFso=; b=UupjILdySxkIT9coMIPSZZD01rB8rmkNoid1NVbykbT9Sukp3YM9QzWYty5z4puKT1 Dg3PExWCKqckdxsVbSBfOVlxtjLY1ne/GR0vKIWhSf7fz0DY/CLtSaBuiSrPK0vpMgFX MCyOddR6lrCGZwWnVDMRwfzClIS7Wk+QHXxUuqhraxJ3ar/aB4JUWNmhwP7I69FJsuc6 Km3xzO3OjlmzNw9iMCiYyG9rxi1vcdWYk347p75Q0AHSvZjAb+G9r+yiNMIML7SIKll0 BsPegHIq+CV4EzY3FWUTfFJuG74AbISn9szfZ0nHY/cP2b8Ko0Vm5hW32e624sQqjlE1 c5AA== X-Gm-Message-State: AA+aEWZQOjYtPEiE+SMlrh0J8fndMlaeYhis5FGd7o+qNKE5T6Bf9tj8 QT3tXh7LK7YONvgnOhBbC8Ex2vtUT/FA4m0i X-Google-Smtp-Source: AFSGD/WfAkcCoMK3OAnSvfm88ztfywSROHjWcPg42TO2jLLFhgQ3727g11DEy3urc53O5w7aq5nReB2Ds1ukSa/G X-Received: by 2002:a25:f306:: with SMTP id c6-v6mr7882045ybs.84.1543837129387; Mon, 03 Dec 2018 03:38:49 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:38 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-23-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Cc: Eugeniu Rosca , Joe Hershberger Subject: [U-Boot] [PATCH 22/30] dm: sound: Create a uclass for audio codecs X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" An audio codec provides a way to convert digital data to sound and vice versa. Add a simple uclass which just supports setting the parameters for the codec. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 7 ++++- arch/sandbox/include/asm/test.h | 10 ++++++ drivers/sound/Makefile | 1 + drivers/sound/codec-uclass.c | 26 ++++++++++++++++ drivers/sound/sandbox.c | 55 +++++++++++++++++++++++++++++++++ include/audio_codec.h | 48 ++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/audio.c | 34 ++++++++++++++++++++ 9 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 drivers/sound/codec-uclass.c create mode 100644 include/audio_codec.h create mode 100644 test/dm/audio.c diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 252aa7b6b63..4e4eaa2dceb 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -42,7 +42,12 @@ osd0 = "/osd"; }; - cros_ec: cros-ec { + audio: audio-codec { + compatible = "sandbox,audio-codec"; + #sound-dai-cells = <1>; + }; + + cros_ec: cros-ec { reg = <0 0>; compatible = "google,cros-ec-sandbox"; diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 5e818392959..f70e0d84177 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -121,4 +121,14 @@ int sandbox_pwm_get_config(struct udevice *dev, uint channel, uint *period_nsp, */ void sandbox_sf_set_block_protect(struct udevice *dev, int bp_mask); +/** + * sandbox_get_codec_params() - Read back codec parameters + * + * This reads back the parameters set by audio_codec_set_params() for the + * sandbox audio driver. Arguments are as for that function. + */ +void sandbox_get_codec_params(struct udevice *dev, int *interfacep, int *ratep, + int *mclk_freqp, int *bits_per_samplep, + uint *channelsp); + #endif diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile index 696c5aecbe9..ae5fabed846 100644 --- a/drivers/sound/Makefile +++ b/drivers/sound/Makefile @@ -4,6 +4,7 @@ # R. Chandrasekar obj-$(CONFIG_SOUND) += sound.o +obj-$(CONFIG_DM_SOUND) += codec-uclass.o obj-$(CONFIG_I2S) += sound-i2s.o obj-$(CONFIG_I2S_SAMSUNG) += samsung-i2s.o obj-$(CONFIG_SOUND_SANDBOX) += sandbox.o diff --git a/drivers/sound/codec-uclass.c b/drivers/sound/codec-uclass.c new file mode 100644 index 00000000000..1ec77acfc1c --- /dev/null +++ b/drivers/sound/codec-uclass.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include + +int audio_codec_set_params(struct udevice *dev, int interface, int rate, + int mclk_freq, int bits_per_sample, uint channels) +{ + struct audio_codec_ops *ops = audio_codec_get_ops(dev); + + if (!ops->set_params) + return -ENOSYS; + + return ops->set_params(dev, interface, rate, mclk_freq, bits_per_sample, + channels); +} + +UCLASS_DRIVER(audio_codec) = { + .id = UCLASS_AUDIO_CODEC, + .name = "audio-codec", +}; diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c index 94eff542824..d24eb9ae9ce 100644 --- a/drivers/sound/sandbox.c +++ b/drivers/sound/sandbox.c @@ -4,9 +4,19 @@ */ #include +#include +#include #include #include +struct sandbox_codec_priv { + int interface; + int rate; + int mclk_freq; + int bits_per_sample; + uint channels; +}; + int sound_play(uint32_t msec, uint32_t frequency) { sandbox_sdl_sound_start(frequency); @@ -20,3 +30,48 @@ int sound_init(const void *blob) { return sandbox_sdl_sound_init(); } + +void sandbox_get_codec_params(struct udevice *dev, int *interfacep, int *ratep, + int *mclk_freqp, int *bits_per_samplep, + uint *channelsp) +{ + struct sandbox_codec_priv *priv = dev_get_priv(dev); + + *interfacep = priv->interface; + *ratep = priv->rate; + *mclk_freqp = priv->mclk_freq; + *bits_per_samplep = priv->bits_per_sample; + *channelsp = priv->channels; +} + +static int sandbox_codec_set_params(struct udevice *dev, int interface, + int rate, int mclk_freq, + int bits_per_sample, uint channels) +{ + struct sandbox_codec_priv *priv = dev_get_priv(dev); + + priv->interface = interface; + priv->rate = rate; + priv->mclk_freq = mclk_freq; + priv->bits_per_sample = bits_per_sample; + priv->channels = channels; + + return 0; +} + +static const struct audio_codec_ops sandbox_codec_ops = { + .set_params = sandbox_codec_set_params, +}; + +static const struct udevice_id sandbox_codec_ids[] = { + { .compatible = "sandbox,audio-codec" }, + { } +}; + +U_BOOT_DRIVER(sandbox_codec) = { + .name = "sandbox_codec", + .id = UCLASS_AUDIO_CODEC, + .of_match = sandbox_codec_ids, + .ops = &sandbox_codec_ops, + .priv_auto_alloc_size = sizeof(struct sandbox_codec_priv), +}; diff --git a/include/audio_codec.h b/include/audio_codec.h new file mode 100644 index 00000000000..25870995469 --- /dev/null +++ b/include/audio_codec.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2018 Google LLC + * Written by Simon Glass + */ + +#ifndef __AUDIO_CODEC_H__ +#define __AUDIO_CODEC_H__ + +/* + * An audio codec turns digital data into sound with various parameters to + * control its operation. + */ + +/* Operations for sound */ +struct audio_codec_ops { + /** + * set_params() - Set audio codec parameters + * + * @dev: Sound device + * @inteface: Interface number to use on codec + * @rate: Sampling rate in Hz + * @mclk_freq: Codec clock frequency in Hz + * @bits_per_sample: Must be 16 or 24 + * @channels: Number of channels to use (1=mono, 2=stereo) + * @return 0 if OK, -ve on error + */ + int (*set_params)(struct udevice *dev, int interface, int rate, + int mclk_freq, int bits_per_sample, uint channels); +}; + +#define audio_codec_get_ops(dev) ((struct audio_codec_ops *)(dev)->driver->ops) + +/** + * audio_codec_set_params() - Set audio codec parameters + * + * @dev: Sound device + * @inteface: Interface number to use on codec + * @rate: Sampling rate in Hz + * @mclk_freq: Codec clock frequency in Hz + * @bits_per_sample: Must be 16 or 24 + * @channels: Number of channels to use (1=mono, 2=stereo) + * @return 0 if OK, -ve on error + */ +int audio_codec_set_params(struct udevice *dev, int interface, int rate, + int mclk_freq, int bits_per_sample, uint channels); + +#endif /* __AUDIO_CODEC_H__ */ diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index a5fcb69dbad..4c2051a4c6f 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -29,6 +29,7 @@ enum uclass_id { /* U-Boot uclasses start here - in alphabetical order */ UCLASS_ADC, /* Analog-to-digital converter */ UCLASS_AHCI, /* SATA disk controller */ + UCLASS_AUDIO_CODEC, /* Audio codec with control and data path */ UCLASS_BLK, /* Block device */ UCLASS_BOARD, /* Device information from hardware */ UCLASS_CLK, /* Clock source, e.g. used by peripherals */ diff --git a/test/dm/Makefile b/test/dm/Makefile index 213e0fda946..592d992a75a 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_UT_DM) += test-uclass.o # subsystem you must add sandbox tests here. obj-$(CONFIG_UT_DM) += core.o ifneq ($(CONFIG_SANDBOX),) +obj-$(CONFIG_DM_SOUND) += audio.o obj-$(CONFIG_BLK) += blk.o obj-$(CONFIG_BOARD) += board.o obj-$(CONFIG_CLK) += clk.o diff --git a/test/dm/audio.c b/test/dm/audio.c new file mode 100644 index 00000000000..77c3a3625bd --- /dev/null +++ b/test/dm/audio.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +/* Basic test of the audio codec uclass */ +static int dm_test_audio(struct unit_test_state *uts) +{ + int interface, rate, mclk_freq, bits_per_sample; + struct udevice *dev; + uint channels; + + /* check probe success */ + ut_assertok(uclass_first_device_err(UCLASS_AUDIO_CODEC, &dev)); + ut_assertok(audio_codec_set_params(dev, 1, 2, 3, 4, 5)); + sandbox_get_codec_params(dev, &interface, &rate, &mclk_freq, + &bits_per_sample, &channels); + ut_asserteq(1, interface); + ut_asserteq(2, rate); + ut_asserteq(3, mclk_freq); + ut_asserteq(4, bits_per_sample); + ut_asserteq(5, channels); + + return 0; +} +DM_TEST(dm_test_audio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Dec 3 11:37:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006867 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="QS9m0hrG"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437k5v0vR8z9s9G for ; Mon, 3 Dec 2018 22:58:11 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B0282C222DF; Mon, 3 Dec 2018 11:51:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CE7F1C22488; Mon, 3 Dec 2018 11:40:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 81546C22456; Mon, 3 Dec 2018 11:39:00 +0000 (UTC) Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by lists.denx.de (Postfix) with ESMTPS id 3EC27C2218E for ; Mon, 3 Dec 2018 11:38:52 +0000 (UTC) Received: by mail-oi1-f199.google.com with SMTP id e141so7971849oig.11 for ; Mon, 03 Dec 2018 03:38:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=TnXjzjDUwAtQxlQAFcJnDlSxP2pgQaU1MUW3NVhM4VE=; b=QS9m0hrG2PriQv8U8vmsGmqAdYcZtwnH9JZSS4WXMfG3ltJNH9au1EV5uxhiEFnZ90 4cT30sbPf2DMO15bEja9yScQBUX/q04OYGG1mNhNMZMyiOS9Zi0prW0khKGsPKq4lBUv nEb5JPaGGH15jFsDFVAJJ7IwZgtyFCgIOOZd0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=TnXjzjDUwAtQxlQAFcJnDlSxP2pgQaU1MUW3NVhM4VE=; b=ApLw3iJ89LA6QqA6rXcac5k0zC167YPDnhorfbqubiPiWEenDOvLXbmRHCNjan1jHP atY90ToRPF0rfvW/pFsvUhJU+jfnMbcCNnT2mcYttcBH1uLmQevLTk3uuujP3h4YPqyy nuWppCwuz9OVNL86dLMCVQZlR8JxUVI6xgUEHmpTMAttZQ4VSkBGcPhYytQXcJZ5dDCw y9JdpZn8lwidGavwZ+CdY+X0FtuY+ix8GMn7v1I5bL4BiHyCMBv+Bctz0IsmWXkeim1g 5rgF9vd0FrZrlPn0DqIjiWMgvSRw1R7Mg7zLSYrgdMozPY/ykV6+/WOCbKoNcHVG0knU fDsg== X-Gm-Message-State: AA+aEWa5o9PwdKKlfgTdNBmF66oah9/t5CQC7KflIOQn7gkqEFSZSpfh 4F1PJD/qS/lTKC3QqOcHPJjGORH9yMN3nkZh X-Google-Smtp-Source: AFSGD/Vm9Yj71VI+tFoq2rN5V2NnWan1EdbQ3PD5/9Wh4O7nK9s31lxwuumDyMfmMmIrKQtnzSjziFM8TKFc8n+D X-Received: by 2002:aca:f587:: with SMTP id t129mr13641212oih.9.1543837131200; Mon, 03 Dec 2018 03:38:51 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:39 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-24-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Cc: Eugeniu Rosca , Joe Hershberger Subject: [U-Boot] [PATCH 23/30] dm: sound: Create a uclass for i2s X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The i2s bus is commonly used with audio codecs. It provides a way to stream digital data sychronously in both directions. U-Boot only supports audio output, so this uclass is very simple, with a single tx_data() method. Add a uclass and a test for i2s. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 7 +++- arch/sandbox/include/asm/test.h | 10 ++++++ drivers/sound/Makefile | 1 + drivers/sound/i2s-uclass.c | 25 ++++++++++++++ drivers/sound/sandbox.c | 58 ++++++++++++++++++++++++++++++++- include/dm/uclass-id.h | 1 + include/i2s.h | 25 ++++++++++++++ test/dm/Makefile | 1 + test/dm/i2s.c | 32 ++++++++++++++++++ 9 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 drivers/sound/i2s-uclass.c create mode 100644 test/dm/i2s.c diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 4e4eaa2dceb..01ab409b388 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -47,7 +47,7 @@ #sound-dai-cells = <1>; }; - cros_ec: cros-ec { + cros_ec: cros-ec { reg = <0 0>; compatible = "google,cros-ec-sandbox"; @@ -378,6 +378,11 @@ u-boot,dm-pre-reloc; }; + i2s: i2s { + compatible = "sandbox,i2s"; + #sound-dai-cells = <1>; + }; + misc-test { compatible = "sandbox,misc_sandbox"; }; diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index f70e0d84177..71bd50bd5bc 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -131,4 +131,14 @@ void sandbox_get_codec_params(struct udevice *dev, int *interfacep, int *ratep, int *mclk_freqp, int *bits_per_samplep, uint *channelsp); +/** + * sandbox_get_i2s_sum() - Read back the sum of the audio data so far + * + * This data is provided to the sandbox driver by the I2S tx_data() method. + * + * @dev: Device to check + * @return sum of audio data + */ +int sandbox_get_i2s_sum(struct udevice *dev); + #endif diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile index ae5fabed846..4aced9d22b9 100644 --- a/drivers/sound/Makefile +++ b/drivers/sound/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_DM_SOUND) += codec-uclass.o +obj-$(CONFIG_DM_SOUND) += i2s-uclass.o obj-$(CONFIG_I2S) += sound-i2s.o obj-$(CONFIG_I2S_SAMSUNG) += samsung-i2s.o obj-$(CONFIG_SOUND_SANDBOX) += sandbox.o diff --git a/drivers/sound/i2s-uclass.c b/drivers/sound/i2s-uclass.c new file mode 100644 index 00000000000..e2b4b2322dd --- /dev/null +++ b/drivers/sound/i2s-uclass.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include + +int i2s_tx_data(struct udevice *dev, uint *data, uint data_size) +{ + struct i2s_ops *ops = i2s_get_ops(dev); + + if (!ops->tx_data) + return -ENOSYS; + + return ops->tx_data(dev, data, data_size); +} + +UCLASS_DRIVER(i2s) = { + .id = UCLASS_I2S, + .name = "i2s", + .per_device_auto_alloc_size = sizeof(struct i2s_uc_priv), +}; diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c index d24eb9ae9ce..59931ec0a12 100644 --- a/drivers/sound/sandbox.c +++ b/drivers/sound/sandbox.c @@ -4,8 +4,9 @@ */ #include -#include #include +#include +#include #include #include @@ -17,6 +18,10 @@ struct sandbox_codec_priv { uint channels; }; +struct sandbox_i2s_priv { + int sum; /* Use to sum the provided audio data */ +}; + int sound_play(uint32_t msec, uint32_t frequency) { sandbox_sdl_sound_start(frequency); @@ -44,6 +49,13 @@ void sandbox_get_codec_params(struct udevice *dev, int *interfacep, int *ratep, *channelsp = priv->channels; } +int sandbox_get_i2s_sum(struct udevice *dev) +{ + struct sandbox_i2s_priv *priv = dev_get_priv(dev); + + return priv->sum; +} + static int sandbox_codec_set_params(struct udevice *dev, int interface, int rate, int mclk_freq, int bits_per_sample, uint channels) @@ -59,6 +71,32 @@ static int sandbox_codec_set_params(struct udevice *dev, int interface, return 0; } +static int sandbox_i2s_tx_data(struct udevice *dev, u32 *data, uint data_size) +{ + struct sandbox_i2s_priv *priv = dev_get_priv(dev); + + while (data_size-- > 0) + priv->sum += *data++; + + return 0; +} + +static int sandbox_i2s_probe(struct udevice *dev) +{ + struct i2s_uc_priv *uc_priv = dev_get_uclass_priv(dev); + + /* Use hard-coded values here */ + uc_priv->rfs = 256; + uc_priv->bfs = 32; + uc_priv->audio_pll_clk = 192000000; + uc_priv->samplingrate = 48000; + uc_priv->bitspersample = 16; + uc_priv->channels = 2; + uc_priv->id = 1; + + return 0; +} + static const struct audio_codec_ops sandbox_codec_ops = { .set_params = sandbox_codec_set_params, }; @@ -75,3 +113,21 @@ U_BOOT_DRIVER(sandbox_codec) = { .ops = &sandbox_codec_ops, .priv_auto_alloc_size = sizeof(struct sandbox_codec_priv), }; + +static const struct i2s_ops sandbox_i2s_ops = { + .tx_data = sandbox_i2s_tx_data, +}; + +static const struct udevice_id sandbox_i2s_ids[] = { + { .compatible = "sandbox,i2s" }, + { } +}; + +U_BOOT_DRIVER(sandbox_i2s) = { + .name = "sandbox_i2s", + .id = UCLASS_I2S, + .of_match = sandbox_i2s_ids, + .ops = &sandbox_i2s_ops, + .probe = sandbox_i2s_probe, + .priv_auto_alloc_size = sizeof(struct sandbox_i2s_priv), +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 4c2051a4c6f..ffafe08a4fe 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -46,6 +46,7 @@ enum uclass_id { UCLASS_I2C_EEPROM, /* I2C EEPROM device */ UCLASS_I2C_GENERIC, /* Generic I2C device */ UCLASS_I2C_MUX, /* I2C multiplexer */ + UCLASS_I2S, /* I2S bus */ UCLASS_IDE, /* IDE device */ UCLASS_AXI, /* AXI bus */ UCLASS_IRQ, /* Interrupt controller */ diff --git a/include/i2s.h b/include/i2s.h index f23862ca040..4839f13458b 100644 --- a/include/i2s.h +++ b/include/i2s.h @@ -87,6 +87,31 @@ struct i2s_uc_priv { unsigned int id; /* I2S controller id */ }; +/* Operations for i2s devices */ +struct i2s_ops { + /** + * tx_data() - Transmit audio data + * + * @dev: I2C device + * @data: Data buffer to play + * @data_size: Size of data buffer in units of 32-bit words + * @return 0 if OK, -ve on error + */ + int (*tx_data)(struct udevice *dev, u32 *data, uint data_size); +}; + +#define i2s_get_ops(dev) ((struct i2s_ops *)(dev)->driver->ops) + +/** + * i2s_tx_data() - Transmit audio data + * + * @dev: I2C device + * @data: Data buffer to play + * @data_size: Size of data buffer in units of 32-bit words + * @return 0 if OK, -ve on error + */ +int i2s_tx_data(struct udevice *dev, u32 *data, uint data_size); + /* * Sends the given data through i2s tx * diff --git a/test/dm/Makefile b/test/dm/Makefile index 592d992a75a..07d6f97cb77 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_FIRMWARE) += firmware.o obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_I2C) += i2c.o +obj-$(CONFIG_DM_SOUND) += i2s.o obj-$(CONFIG_LED) += led.o obj-$(CONFIG_DM_MAILBOX) += mailbox.o obj-$(CONFIG_DM_MMC) += mmc.o diff --git a/test/dm/i2s.c b/test/dm/i2s.c new file mode 100644 index 00000000000..523bf89d08b --- /dev/null +++ b/test/dm/i2s.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +/* Basic test of the i2s codec uclass */ +static int dm_test_i2s(struct unit_test_state *uts) +{ + struct udevice *dev; + u32 data[3]; + + /* check probe success */ + ut_assertok(uclass_first_device_err(UCLASS_I2S, &dev)); + data[0] = 1; + data[1] = 4; + data[2] = 6; + ut_assertok(i2s_tx_data(dev, data, ARRAY_SIZE(data))); + ut_asserteq(11, sandbox_get_i2s_sum(dev)); + ut_assertok(i2s_tx_data(dev, data, 1)); + ut_asserteq(12, sandbox_get_i2s_sum(dev)); + + return 0; +} +DM_TEST(dm_test_i2s, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Dec 3 11:37:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006869 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="awnBDcJy"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437k6P0QKxz9sBh for ; Mon, 3 Dec 2018 22:58:36 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A53E8C223E6; Mon, 3 Dec 2018 11:53:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 91C79C224BF; Mon, 3 Dec 2018 11:40:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 71207C224BB; Mon, 3 Dec 2018 11:39:00 +0000 (UTC) Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by lists.denx.de (Postfix) with ESMTPS id 286BFC223DB for ; Mon, 3 Dec 2018 11:38:54 +0000 (UTC) Received: by mail-qk1-f197.google.com with SMTP id h68so12895443qke.3 for ; Mon, 03 Dec 2018 03:38:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+6hZmfQCdfod+tAoDnv+/r1oDvWxYPpdQ7fnqknQsGU=; b=awnBDcJyvOy2HmHrEn62Qmy+R7m3A8MBtNBmFzBZ/rgJ1aK3nAlSoG5ugczOaTd/HF mWJuufUqE/6hQyCOLY6/u1IlGAlE0Zz4TdD7PD8W9I2nrLYa8hL0eTk4MoTbqU1p2ddb Q0aOHItEHvX0TCIhEDa2xED1xHZFy8ASt9QkU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+6hZmfQCdfod+tAoDnv+/r1oDvWxYPpdQ7fnqknQsGU=; b=g4NylzPnWH++9pkBdf7DpoTRFxDKeKhnLIDKWOwQ190u3yR+d6asiRlNbIdgfx8VCp rTOpTSA/BSFERzOX4eNmStroL9eTQvCa4odQc6MQ98oQFn7hKpvcc1vV1aYFjUnZiT8N rM75R1BVOIKmvbMxf+wbHEg5VA7NLaMw0nuYqCVeT5jR2UMBs/b6T/maEvjcYNDpmVUX 9pcGk6UoyklztIE4i/O1o+HPMmdAkLLnKlBcw8w3ANVFBxCSieQp4oIGQ1nXKoNfviO8 zHD1n9I2g5KpMWtjsyW6oX/10CigXoYKkzAPgamGpbeXjsoAvO/hWJvLO8tlFi1w6p4r WmJg== X-Gm-Message-State: AA+aEWaJvn2y4xcdS9cvGmYc5q959Nq+bULNqi05Lg+PTcfyFEKFH8Rs ZXON9JJkr9lNXYXhVYrVmq9atbKbcI6WGtFh X-Google-Smtp-Source: AFSGD/UTVeLlk7W6A2/huwM1m2cJKJczkjiOQ3NGWghtaLTCz4jX5uJUKfc1kYi4ghe9PpgwfEy2jusVUd6/Na5a X-Received: by 2002:a37:f4b:: with SMTP id z72mr11807986qkg.20.1543837132996; Mon, 03 Dec 2018 03:38:52 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:40 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-25-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Cc: Eugeniu Rosca , Joe Hershberger Subject: [U-Boot] [PATCH 24/30] dm: sound: Create a uclass for sound X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The sound drive pulls together the audio codec and i2s drivers in order to actually make sounds. It supports setup() and play() methods. The sound_find_codec_i2s() function allows locating the linked codec and i2s devices. They can be referred to from uclass-private data. Add a uclass and a test for sound. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 11 +++ arch/sandbox/include/asm/test.h | 20 +++++ cmd/sound.c | 21 +++++- drivers/sound/Makefile | 1 + drivers/sound/sandbox.c | 65 ++++++++++++++++ drivers/sound/sound-uclass.c | 129 ++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/sound.h | 66 ++++++++++++++++ test/dm/Makefile | 1 + test/dm/sound.c | 34 +++++++++ 10 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 drivers/sound/sound-uclass.c create mode 100644 test/dm/sound.c diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 01ab409b388..dbbd0495e7c 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -536,6 +536,17 @@ compatible = "sandbox,smem"; }; + sound { + compatible = "sandbox,sound"; + cpu { + sound-dai = <&i2s 0>; + }; + + codec { + sound-dai = <&audio 0>; + }; + }; + spi@0 { #address-cells = <1>; #size-cells = <0>; diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 71bd50bd5bc..74f96188220 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -141,4 +141,24 @@ void sandbox_get_codec_params(struct udevice *dev, int *interfacep, int *ratep, */ int sandbox_get_i2s_sum(struct udevice *dev); +/** + * sandbox_get_setup_called() - Returns the number of times setup(*) was called + * + * This is used in the sound test + * + * @dev: Device to check + * @return call count for the setup() method + */ +int sandbox_get_setup_called(struct udevice *dev); + +/** + * sandbox_get_sound_sum() - Read back the sum of the sound data so far + * + * This data is provided to the sandbox driver by the sound play() method. + * + * @dev: Device to check + * @return sum of audio data + */ +int sandbox_get_sound_sum(struct udevice *dev); + #endif diff --git a/cmd/sound.c b/cmd/sound.c index d1cbc14f8df..b063863bc9a 100644 --- a/cmd/sound.c +++ b/cmd/sound.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -14,9 +15,18 @@ DECLARE_GLOBAL_DATA_PTR; /* Initilaise sound subsystem */ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { +#ifdef CONFIG_DM_SOUND + struct udevice *dev; +#endif int ret; +#ifdef CONFIG_DM_SOUND + ret = uclass_first_device_err(UCLASS_SOUND, &dev); + if (!ret) + ret = sound_setup(dev); +#else ret = sound_init(gd->fdt_blob); +#endif if (ret) { printf("Initialise Audio driver failed\n"); return CMD_RET_FAILURE; @@ -28,6 +38,9 @@ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) /* play sound from buffer */ static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { +#ifdef CONFIG_DM_SOUND + struct udevice *dev; +#endif int ret = 0; int msec = 1000; int freq = 400; @@ -37,9 +50,15 @@ static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (argc > 2) freq = simple_strtoul(argv[2], NULL, 10); +#ifdef CONFIG_DM_SOUND + ret = uclass_first_device_err(UCLASS_SOUND, &dev); + if (!ret) + ret = sound_beep(dev, msec, freq); +#else ret = sound_play(msec, freq); +#endif if (ret) { - printf("play failed"); + printf("Sound device failed to play (err=%d)\n", ret); return CMD_RET_FAILURE; } diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile index 4aced9d22b9..70d32c6d6f6 100644 --- a/drivers/sound/Makefile +++ b/drivers/sound/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_DM_SOUND) += codec-uclass.o obj-$(CONFIG_DM_SOUND) += i2s-uclass.o obj-$(CONFIG_I2S) += sound-i2s.o +obj-$(CONFIG_DM_SOUND) += sound-uclass.o obj-$(CONFIG_I2S_SAMSUNG) += samsung-i2s.o obj-$(CONFIG_SOUND_SANDBOX) += sandbox.o obj-$(CONFIG_SOUND_WM8994) += wm8994.o diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c index 59931ec0a12..d8a971ca060 100644 --- a/drivers/sound/sandbox.c +++ b/drivers/sound/sandbox.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -22,6 +23,12 @@ struct sandbox_i2s_priv { int sum; /* Use to sum the provided audio data */ }; +struct sandbox_sound_priv { + int setup_called; + int sum; /* Use to sum the provided audio data */ +}; + +#ifndef CONFIG_DM_SOUND int sound_play(uint32_t msec, uint32_t frequency) { sandbox_sdl_sound_start(frequency); @@ -30,6 +37,7 @@ int sound_play(uint32_t msec, uint32_t frequency) return 0; } +#endif /* CONFIG_DM_SOUND */ int sound_init(const void *blob) { @@ -56,6 +64,20 @@ int sandbox_get_i2s_sum(struct udevice *dev) return priv->sum; } +int sandbox_get_setup_called(struct udevice *dev) +{ + struct sandbox_sound_priv *priv = dev_get_priv(dev); + + return priv->setup_called; +} + +int sandbox_get_sound_sum(struct udevice *dev) +{ + struct sandbox_sound_priv *priv = dev_get_priv(dev); + + return priv->sum; +} + static int sandbox_codec_set_params(struct udevice *dev, int interface, int rate, int mclk_freq, int bits_per_sample, uint channels) @@ -97,6 +119,30 @@ static int sandbox_i2s_probe(struct udevice *dev) return 0; } +static int sandbox_sound_setup(struct udevice *dev) +{ + struct sandbox_sound_priv *priv = dev_get_priv(dev); + + priv->setup_called++; + + return 0; +} + +static int sandbox_sound_play(struct udevice *dev, uint *data, uint data_size) +{ + struct sandbox_sound_priv *priv = dev_get_priv(dev); + + while (data_size-- > 0) + priv->sum += *data++; + + return 0; +} + +static int sandbox_sound_probe(struct udevice *dev) +{ + return sound_find_codec_i2s(dev); +} + static const struct audio_codec_ops sandbox_codec_ops = { .set_params = sandbox_codec_set_params, }; @@ -131,3 +177,22 @@ U_BOOT_DRIVER(sandbox_i2s) = { .probe = sandbox_i2s_probe, .priv_auto_alloc_size = sizeof(struct sandbox_i2s_priv), }; + +static const struct sound_ops sandbox_sound_ops = { + .setup = sandbox_sound_setup, + .play = sandbox_sound_play, +}; + +static const struct udevice_id sandbox_sound_ids[] = { + { .compatible = "sandbox,sound" }, + { } +}; + +U_BOOT_DRIVER(sandbox_sound) = { + .name = "sandbox_sound", + .id = UCLASS_SOUND, + .of_match = sandbox_sound_ids, + .ops = &sandbox_sound_ops, + .priv_auto_alloc_size = sizeof(struct sandbox_sound_priv), + .probe = sandbox_sound_probe, +}; diff --git a/drivers/sound/sound-uclass.c b/drivers/sound/sound-uclass.c new file mode 100644 index 00000000000..dee04fd19bb --- /dev/null +++ b/drivers/sound/sound-uclass.c @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include + +#define SOUND_BITS_IN_BYTE 8 + +int sound_setup(struct udevice *dev) +{ + struct sound_ops *ops = sound_get_ops(dev); + + if (!ops->setup) + return -ENOSYS; + + return ops->setup(dev); +} + +int sound_play(struct udevice *dev, uint *data, uint data_size) +{ + struct sound_ops *ops = sound_get_ops(dev); + + if (!ops->play) + return -ENOSYS; + + return ops->play(dev, data, data_size); +} + +int sound_beep(struct udevice *dev, int msecs, int frequency_hz) +{ + struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev); + struct i2s_uc_priv *i2s_uc_priv = dev_get_uclass_priv(uc_priv->i2s); + unsigned int *data; + unsigned long data_size; + int ret; + + ret = sound_setup(dev); + if (ret && ret != -EALREADY) + return ret; + + /* Buffer length computation */ + data_size = i2s_uc_priv->samplingrate * i2s_uc_priv->channels; + data_size *= (i2s_uc_priv->bitspersample / SOUND_BITS_IN_BYTE); + data = malloc(data_size); + if (!data) { + debug("%s: malloc failed\n", __func__); + return -ENOMEM; + } + + sound_create_square_wave(i2s_uc_priv->samplingrate, + (unsigned short *)data, + data_size / sizeof(unsigned short), + frequency_hz); + + while (msecs >= 1000) { + ret = sound_play(dev, data, (data_size / sizeof(int))); + msecs -= 1000; + } + if (msecs) { + unsigned long size = + (data_size * msecs) / (sizeof(int) * 1000); + + ret = sound_play(dev, data, size); + } + + free(data); + + return ret; +} + +int sound_find_codec_i2s(struct udevice *dev) +{ + struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev); + struct ofnode_phandle_args args; + ofnode node; + int ret; + + /* First the codec */ + node = ofnode_find_subnode(dev_ofnode(dev), "codec"); + if (!ofnode_valid(node)) { + debug("Failed to find /cpu subnode\n"); + return -EINVAL; + } + ret = ofnode_parse_phandle_with_args(node, "sound-dai", + "#sound-dai-cells", 0, 0, &args); + if (ret) { + debug("Cannot find phandle: %d\n", ret); + return ret; + } + ret = uclass_get_device_by_ofnode(UCLASS_AUDIO_CODEC, args.node, + &uc_priv->codec); + if (ret) { + debug("Cannot find codec: %d\n", ret); + return ret; + } + + /* Now the i2s */ + node = ofnode_find_subnode(dev_ofnode(dev), "cpu"); + if (!ofnode_valid(node)) { + debug("Failed to find /cpu subnode\n"); + return -EINVAL; + } + ret = ofnode_parse_phandle_with_args(node, "sound-dai", + "#sound-dai-cells", 0, 0, &args); + if (ret) { + debug("Cannot find phandle: %d\n", ret); + return ret; + } + ret = uclass_get_device_by_ofnode(UCLASS_I2S, args.node, &uc_priv->i2s); + if (ret) { + debug("Cannot find i2s: %d\n", ret); + return ret; + } + debug("Probed sound '%s' with codec '%s' and i2s '%s'\n", dev->name, + uc_priv->codec->name, uc_priv->i2s->name); + + return 0; +} + +UCLASS_DRIVER(sound) = { + .id = UCLASS_SOUND, + .name = "sound", + .per_device_auto_alloc_size = sizeof(struct sound_uc_priv), +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index ffafe08a4fe..bebcb124171 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -82,6 +82,7 @@ enum uclass_id { UCLASS_SERIAL, /* Serial UART */ UCLASS_SIMPLE_BUS, /* Bus with child devices */ UCLASS_SMEM, /* Shared memory interface */ + UCLASS_SOUND, /* Playing simple sounds */ UCLASS_SPI, /* SPI bus */ UCLASS_SPMI, /* System Power Management Interface bus */ UCLASS_SPI_FLASH, /* SPI flash */ diff --git a/include/sound.h b/include/sound.h index c4ac3193fe7..a8235a75b9c 100644 --- a/include/sound.h +++ b/include/sound.h @@ -19,6 +19,21 @@ struct sound_codec_info { int i2c_dev_addr; }; +/** + * struct sound_uc_priv - private uclass information about each sound device + * + * This is used to line the codec and i2s together + * + * @codec: Codec that is used for this sound device + * @i2s: I2S bus that is used for this sound device + * @setup_done: true if setup() has been called + */ +struct sound_uc_priv { + struct udevice *codec; + struct udevice *i2s; + int setup_done; +}; + /* * Generates square wave sound data for 1 second * @@ -37,6 +52,56 @@ void sound_create_square_wave(uint sample_rate, unsigned short *data, int size, */ int sound_init(const void *blob); +#ifdef CONFIG_DM_SOUND +/* + * The sound uclass brings together a data transport (currently only I2C) and a + * codec (currently connected over I2C). + */ + +/* Operations for sound */ +struct sound_ops { + /** + * setup() - Set up to play a sound + */ + int (*setup)(struct udevice *dev); + + /** + * play() - Play a beep + * + * @dev: Sound device + * @data: Data buffer to play + * @data_size: Size of data buffer + * @return 0 if OK, -ve on error + */ + int (*play)(struct udevice *dev, uint *data, uint data_size); +}; + +#define sound_get_ops(dev) ((struct sound_ops *)(dev)->driver->ops) + +/** + * setup() - Set up to play a sound + */ +int sound_setup(struct udevice *dev); + +/** + * play() - Play a beep + * + * @dev: Sound device + * @msecs: Duration of beep in milliseconds + * @frequency_hz: Frequency of the beep in Hertz + * @return 0 if OK, -ve on error + */ +int sound_beep(struct udevice *dev, int msecs, int frequency_hz); + +/** + * sound_find_codec_i2s() - Called by sound drivers to locate codec and i2s + * + * This finds the audio codec and i2s devices and puts them in the uclass's + * private data for this device. + */ +int sound_find_codec_i2s(struct udevice *dev); + +#else /* * plays the pcm data buffer in pcm_data.h through i2s1 to make the * sine wave sound @@ -44,5 +109,6 @@ int sound_init(const void *blob); * @return int 0 for success, -1 for error */ int sound_play(uint32_t msec, uint32_t frequency); +#endif /* CONFIG_DM_SOUND */ #endif /* __SOUND__H__ */ diff --git a/test/dm/Makefile b/test/dm/Makefile index 07d6f97cb77..0c1459cd4db 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -54,6 +54,7 @@ obj-$(CONFIG_AXI) += axi.o obj-$(CONFIG_MISC) += misc.o obj-$(CONFIG_DM_SERIAL) += serial.o obj-$(CONFIG_CPU) += cpu.o +obj-$(CONFIG_DM_SOUND) += sound.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o endif diff --git a/test/dm/sound.c b/test/dm/sound.c new file mode 100644 index 00000000000..0f818052152 --- /dev/null +++ b/test/dm/sound.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +/* Basic test of the sound codec uclass */ +static int dm_test_sound(struct unit_test_state *uts) +{ + struct sound_uc_priv *uc_priv; + struct udevice *dev; + + /* check probe success */ + ut_assertok(uclass_first_device_err(UCLASS_SOUND, &dev)); + uc_priv = dev_get_uclass_priv(dev); + ut_asserteq_str("audio-codec", uc_priv->codec->name); + ut_asserteq_str("i2s", uc_priv->i2s->name); + ut_asserteq(0, sandbox_get_setup_called(dev)); + + ut_assertok(sound_beep(dev, 1, 100)); + ut_asserteq(-1207191552, sandbox_get_sound_sum(dev)); + ut_assertok(sound_beep(dev, 1, 100)); + ut_asserteq(1880584192, sandbox_get_sound_sum(dev)); + + return 0; +} +DM_TEST(dm_test_sound, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Dec 3 11:37:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006868 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="HrYxMvU2"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437k6M3Mgvz9s9G for ; Mon, 3 Dec 2018 22:58:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 18089C223E9; Mon, 3 Dec 2018 11:52:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 81376C22437; Mon, 3 Dec 2018 11:40:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2AE7DC224BF; Mon, 3 Dec 2018 11:39:01 +0000 (UTC) Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by lists.denx.de (Postfix) with ESMTPS id B3F31C22188 for ; Mon, 3 Dec 2018 11:38:55 +0000 (UTC) Received: by mail-qt1-f198.google.com with SMTP id d31so6186914qtc.4 for ; Mon, 03 Dec 2018 03:38:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ogMhTeTRYR0+DFEDBHqa31OLgwKMl073sqjbg763+LA=; b=HrYxMvU2/+vPq0BxuY7YAp7+/Wr1w9s+HZ8UywLtZzBBAWfRRjQP47cnUdz51t4ChL ORz8taWEa4f6TppZtfb3/pe+ycnHWsxhLrAXO+7npJIYnu9C7VB8MBXlTKpXFIqt0T/u ufRo/h9QgOhSTi6fd4RwtNYj187fQicWVb+IE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ogMhTeTRYR0+DFEDBHqa31OLgwKMl073sqjbg763+LA=; b=o9S7w6BDj49xYpWhhKYTEmg14lSHef6QB2DieiWPJdMr/bE8xqCoJnFaAtKFBZT8Lu 4ssuuHidMyByGxXEU/ORLprsxjVWSZkji7C+JYVv5zfSJ/1eiNHcGQB9H0T1bRNsq9Qd RuN4SknBvCrMGQjqQoJ0syhr/qabCozrR9S9yFV51IrFShWvBrjoyY64I8Qt6lIVwz4e cufxhjn2zonSO8WLGFnq78nfwU524fpj/tq01LY36E9JKNGhVeBq3NIWL14F7aN6ShP4 aINIaIHnrvN0I+ix1XArE9XPWq95cU8u59JZ5z+U0ufzU7DXhO359cXaLwMHBa0cb9LL F6Cw== X-Gm-Message-State: AA+aEWZ6YqDWDLiXLaOsxZEIbdmboImV6AHTQpjoqoIzxAmokeLaVdq7 NUvmj7U2dUfKD2bN6BQGM+8jLPQ4k7jNvmpY X-Google-Smtp-Source: AFSGD/UyZYVSSFLa903NzzEhZfL2MQD0BRq4zh3ksbTW5Q0tow/GO3Xl4volHd9HsgqZfxCTBwTbEQIfgTNoD3lL X-Received: by 2002:ac8:21e1:: with SMTP id 30mr11832070qtz.55.1543837134778; Mon, 03 Dec 2018 03:38:54 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:41 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-26-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Cc: Eugeniu Rosca , Joe Hershberger Subject: [U-Boot] [PATCH 25/30] dm: core: Add a function to read into a unsigned int X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The current dev_read...() functions use s32 and u32 which are convenient for device tree but not so useful for normal code, which often wants to use normal integers for values. Add a helper which supports returning an unsigned int. Also add signed versions of the unsigned readers. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 2 ++ drivers/core/read.c | 23 ++++++++++++++++ include/dm/read.h | 58 +++++++++++++++++++++++++++++++++++++++ test/dm/test-fdt.c | 35 +++++++++++++++++++++++ 4 files changed, 118 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index dbbd0495e7c..f44090377d3 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -87,6 +87,8 @@ test2-gpios = <&gpio_a 1>, <&gpio_a 4>, <&gpio_b 6 1 3 2 1>, <&gpio_b 7 2 3 2 1>, <&gpio_b 8 4 3 2 1>, <&gpio_b 9 0xc 3 2 1>; + int-value = <1234>; + uint-value = <(-1234)>; }; junk { diff --git a/drivers/core/read.c b/drivers/core/read.c index 96766c7876a..4644a8c0cee 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -21,6 +21,29 @@ int dev_read_u32_default(struct udevice *dev, const char *propname, int def) return ofnode_read_u32_default(dev_ofnode(dev), propname, def); } +int dev_read_s32(struct udevice *dev, const char *propname, s32 *outp) +{ + return ofnode_read_u32(dev_ofnode(dev), propname, (u32 *)outp); +} + +int dev_read_s32_default(struct udevice *dev, const char *propname, int def) +{ + return ofnode_read_u32_default(dev_ofnode(dev), propname, def); +} + +int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp) +{ + u32 val; + int ret; + + ret = ofnode_read_u32(dev_ofnode(dev), propname, &val); + if (ret) + return ret; + *outp = val; + + return 0; +} + const char *dev_read_string(struct udevice *dev, const char *propname) { return ofnode_read_string(dev_ofnode(dev), propname); diff --git a/include/dm/read.h b/include/dm/read.h index a27b8554fb1..27f751ba7a2 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -64,6 +64,38 @@ int dev_read_u32(struct udevice *dev, const char *propname, u32 *outp); */ int dev_read_u32_default(struct udevice *dev, const char *propname, int def); +/** + * dev_read_s32() - read a signed 32-bit integer from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of the property to read from + * @outp: place to put value (if found) + * @return 0 if OK, -ve on error + */ +int dev_read_s32(struct udevice *dev, const char *propname, s32 *outp); + +/** + * dev_read_s32_default() - read a signed 32-bit int from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of the property to read from + * @def: default value to return if the property has no value + * @return property value, or @def if not found + */ +int dev_read_s32_default(struct udevice *dev, const char *propname, int def); + +/** + * dev_read_u32u() - read a 32-bit integer from a device's DT property + * + * This version uses a standard uint type. + * + * @dev: device to read DT property from + * @propname: name of the property to read from + * @outp: place to put value (if found) + * @return 0 if OK, -ve on error + */ +int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp); + /** * dev_read_string() - Read a string from a device's DT property * @@ -467,6 +499,32 @@ static inline int dev_read_u32_default(struct udevice *dev, return ofnode_read_u32_default(dev_ofnode(dev), propname, def); } +static inline int dev_read_s32(struct udevice *dev, + const char *propname, s32 *outp) +{ + return ofnode_read_s32(dev_ofnode(dev), propname, outp); +} + +static inline int dev_read_s32_default(struct udevice *dev, + const char *propname, int def) +{ + return ofnode_read_s32_default(dev_ofnode(dev), propname, def); +} + +static inline int dev_read_u32u(struct udevice *dev, + const char *propname, uint *outp) +{ + u32 val; + int ret; + + ret = ofnode_read_u32(dev_ofnode(dev), propname, &val); + if (ret) + return ret; + *outp = val; + + return 0; +} + static inline const char *dev_read_string(struct udevice *dev, const char *propname) { diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 0fbd9be765a..b32f82fdcf1 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -658,3 +658,38 @@ static int dm_test_first_child(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_first_child, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test integer functions in dm_read_...() */ +static int dm_test_read_int(struct unit_test_state *uts) +{ + struct udevice *dev; + u32 val32; + s32 sval; + uint val; + + ut_assertok(uclass_first_device_err(UCLASS_TEST_FDT, &dev)); + ut_asserteq_str("a-test", dev->name); + ut_assertok(dev_read_u32(dev, "int-value", &val32)); + ut_asserteq(1234, val32); + + ut_asserteq(-EINVAL, dev_read_u32(dev, "missing", &val32)); + ut_asserteq(6, dev_read_u32_default(dev, "missing", 6)); + + ut_asserteq(1234, dev_read_u32_default(dev, "int-value", 6)); + ut_asserteq(1234, val32); + + ut_asserteq(-EINVAL, dev_read_s32(dev, "missing", &sval)); + ut_asserteq(6, dev_read_s32_default(dev, "missing", 6)); + + ut_asserteq(-1234, dev_read_s32_default(dev, "uint-value", 6)); + ut_assertok(dev_read_s32(dev, "uint-value", &sval)); + ut_asserteq(-1234, sval); + + val = 0; + ut_asserteq(-EINVAL, dev_read_u32u(dev, "missing", &val)); + ut_assertok(dev_read_u32u(dev, "uint-value", &val)); + ut_asserteq(-1234, val); + + return 0; +} +DM_TEST(dm_test_read_int, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Dec 3 11:37:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006872 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="E/NFmISN"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437k7b0QZrz9s9G for ; Mon, 3 Dec 2018 22:59:38 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5875AC221C8; Mon, 3 Dec 2018 11:51:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B0FF5C223E6; Mon, 3 Dec 2018 11:40:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2666DC22439; Mon, 3 Dec 2018 11:39:02 +0000 (UTC) Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by lists.denx.de (Postfix) with ESMTPS id 99056C221C5 for ; Mon, 3 Dec 2018 11:38:57 +0000 (UTC) Received: by mail-io1-f69.google.com with SMTP id a6so14055507iok.0 for ; Mon, 03 Dec 2018 03:38:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=HaHPouXOmBL9PRdmctj8vyCYr6Xkf1/qSCnasmsrWgo=; b=E/NFmISN2O6IOiG78mbs/S6xPhJ/i2htf9LQR43k5z8EBeu3ix+d1iRDBhwd/6rXA+ zQ0VByqQWxVRLJ4uhdqXdPaimBcHyXaugrVodNeh58eTuesoZFMQrnfYL44ofguJKJXI uxG7gUQNalYyZH11EmDv0C8rB0cnWsBMQR7YI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=HaHPouXOmBL9PRdmctj8vyCYr6Xkf1/qSCnasmsrWgo=; b=EgZcK8swvi8+9clgVTDZr5fT86dJvzjxbIHEMpoFsPhh/vUtl9LrDlzpj3FfpQ/IJy 9jJmZ5DuhtsCuXD15Bj0GgEsqG6X0vi3KqCyIyR8qQmSA353aAzSVUeZyJiXat5OojKx DiyMKTczreZgdroaOcJAPUaQKXB3jeU8E7hnpD/AzzUHmQdpj45BcqGodROJBhRjYQGH H0153DncHUiEkZdTjxlYtOQF7O2/K0iZyY9F6Fv1VTRySedRTX22ltYsqO9eod5kmoVP japf8MWcY6332XHstvH/mnpCR450cJ1fr0lWZ6ezEmZi7tiIRsQZ/Qc/e5AOggYQHt9d GWXw== X-Gm-Message-State: AA+aEWauZaATAU5JWagRRh4XNxbUerSQdFczeTRHBjHi5w4SjnrD44Cg EBxXBaxCXv9bGu+BtwuPbJqLnS7RGaUnZ3Yn X-Google-Smtp-Source: AFSGD/VAzfd/I5LKApCgeCN2Sm8ktQUzZQpmyuC2ySQz7gMC98VC5xQZYrfmRtgxmWy3hpzX1NfmYlMygesYY9/e X-Received: by 2002:a24:6fd1:: with SMTP id x200mr7026749itb.26.1543837136621; Mon, 03 Dec 2018 03:38:56 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:42 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-27-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 26/30] dm: sound: Start i2c IDs from 0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The current ID enums start from 1 but there does not seem to be any reason that they cannot start with 0. Adjust the code to avoid the +1 in codec_init() and elsewhere. Signed-off-by: Simon Glass --- drivers/sound/max98095.h | 2 +- drivers/sound/sound-i2s.c | 6 ++---- drivers/sound/wm8994.c | 23 ++++++++++++----------- drivers/sound/wm8994.h | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/sound/max98095.h b/drivers/sound/max98095.h index 44b1e3a97b4..13ae177a86b 100644 --- a/drivers/sound/max98095.h +++ b/drivers/sound/max98095.h @@ -13,7 +13,7 @@ /* Available audio interface ports in wm8994 codec */ enum en_max_audio_interface { - AIF1 = 1, + AIF1, AIF2, }; diff --git a/drivers/sound/sound-i2s.c b/drivers/sound/sound-i2s.c index ed130750b2e..a2fc78154f1 100644 --- a/drivers/sound/sound-i2s.c +++ b/drivers/sound/sound-i2s.c @@ -120,13 +120,11 @@ static int codec_init(const void *blob, struct i2s_uc_priv *pi2s_tx) debug("device = %s\n", codectype); if (!strcmp(codectype, "wm8994")) { /* Check the codec type and initialise the same */ - ret = wm8994_init(blob, pi2s_tx->id + 1, - pi2s_tx->samplingrate, + ret = wm8994_init(blob, pi2s_tx->id, pi2s_tx->samplingrate, (pi2s_tx->samplingrate * (pi2s_tx->rfs)), pi2s_tx->bitspersample, pi2s_tx->channels); } else if (!strcmp(codectype, "max98095")) { - ret = max98095_init(blob, pi2s_tx->id + 1, - pi2s_tx->samplingrate, + ret = max98095_init(blob, pi2s_tx->id, pi2s_tx->samplingrate, (pi2s_tx->samplingrate * (pi2s_tx->rfs)), pi2s_tx->bitspersample); } else { diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index 1714f430f39..b8c3ffb67eb 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -285,7 +285,6 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int aif_id, int aif1 = 0; int aif2 = 0; int rate_val = 0; - int id = aif_id - 1; int i, cur_val, best_val, bclk_rate, best; unsigned short reg_data; int ret = 0; @@ -343,10 +342,11 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int aif_id, /* AIFCLK/fs ratio; look for a close match in either direction */ best = 0; - best_val = abs((fs_ratios[0] * sampling_rate) - priv->aifclk[id]); + best_val = abs((fs_ratios[0] * sampling_rate) - priv->aifclk[aif_id]); for (i = 1; i < ARRAY_SIZE(fs_ratios); i++) { - cur_val = abs(fs_ratios[i] * sampling_rate - priv->aifclk[id]); + cur_val = abs(fs_ratios[i] * sampling_rate - + priv->aifclk[aif_id]); if (cur_val >= best_val) continue; best = i; @@ -363,7 +363,8 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int aif_id, */ best = 0; for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) { - cur_val = (priv->aifclk[id] * 10 / bclk_divs[i]) - bclk_rate; + cur_val = (priv->aifclk[aif_id] * 10 / bclk_divs[i]) - + bclk_rate; if (cur_val < 0) /* BCLK table is sorted */ break; best = i; @@ -375,7 +376,7 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int aif_id, return -1; } - bclk_rate = priv->aifclk[id] * 10 / bclk_divs[best]; + bclk_rate = priv->aifclk[aif_id] * 10 / bclk_divs[best]; bclk |= best << WM8994_AIF1_BCLK_DIV_SHIFT; if (wm8994_i2c_read(priv, aif1_reg, ®_data) != 0) { @@ -386,7 +387,7 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int aif_id, if ((channels == 1) && ((reg_data & 0x18) == 0x18)) aif2 |= WM8994_AIF1_MONO; - if (priv->aifclk[id] == 0) { + if (priv->aifclk[aif_id] == 0) { debug("%s:Audio interface clock not set\n", __func__); return -1; } @@ -424,12 +425,12 @@ static int configure_aif_clock(struct wm8994_priv *priv, int aif) int ret; /* AIF(1/0) register adress offset calculated */ - if (aif-1) + if (aif) offset = 4; else offset = 0; - switch (priv->sysclk[aif - 1]) { + switch (priv->sysclk[aif]) { case WM8994_SYSCLK_MCLK1: reg1 |= SEL_MCLK1; rate = priv->mclk[0]; @@ -452,7 +453,7 @@ static int configure_aif_clock(struct wm8994_priv *priv, int aif) default: debug("%s: Invalid input clock selection [%d]\n", - __func__, priv->sysclk[aif - 1]); + __func__, priv->sysclk[aif]); return -1; } @@ -462,7 +463,7 @@ static int configure_aif_clock(struct wm8994_priv *priv, int aif) reg1 |= WM8994_AIF1CLK_DIV; } - priv->aifclk[aif - 1] = rate; + priv->aifclk[aif] = rate; ret = wm8994_bic_or(priv, WM8994_AIF1_CLOCKING_1 + offset, WM8994_AIF1CLK_SRC_MASK | WM8994_AIF1CLK_DIV, @@ -502,7 +503,7 @@ static int wm8994_set_sysclk(struct wm8994_priv *priv, int aif_id, int clk_id, int i; int ret = 0; - priv->sysclk[aif_id - 1] = clk_id; + priv->sysclk[aif_id] = clk_id; switch (clk_id) { case WM8994_SYSCLK_MCLK1: diff --git a/drivers/sound/wm8994.h b/drivers/sound/wm8994.h index ef2878f87ca..e36e6269f00 100644 --- a/drivers/sound/wm8994.h +++ b/drivers/sound/wm8994.h @@ -15,7 +15,7 @@ /* Avilable audi interface ports in wm8994 codec */ enum en_audio_interface { - WM8994_AIF1 = 1, + WM8994_AIF1, WM8994_AIF2, WM8994_AIF3 }; From patchwork Mon Dec 3 11:37:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006847 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Fo96I9XE"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jrX1jH7z9s55 for ; Mon, 3 Dec 2018 22:46:36 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id E4FC7C2215F; Mon, 3 Dec 2018 11:44:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 43D32C223DE; Mon, 3 Dec 2018 11:39:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7A884C221CA; Mon, 3 Dec 2018 11:39:03 +0000 (UTC) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by lists.denx.de (Postfix) with ESMTPS id 77D2DC223DF for ; Mon, 3 Dec 2018 11:38:59 +0000 (UTC) Received: by mail-it1-f199.google.com with SMTP id 135so8342399itk.5 for ; Mon, 03 Dec 2018 03:38:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=8u3APjz9yGXvGwfJfgtXWyRkeOGmDaBgMuD/kviPxo0=; b=Fo96I9XEQ3TYqu8a/q5lWq7fP2Uu9d3sivkDIv5lBQMt5JW2OPPA/a1hlqJe9xTXA9 /+i4mE+IMw9yztZKC8P65oe5P5BfEzSrA34t07jL3e2TYxbdKxMxaGnq2U1LKbm17iDm V9cVyUFDD7S9Jh4ushRhtN28i7d9wmZnhvZSo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8u3APjz9yGXvGwfJfgtXWyRkeOGmDaBgMuD/kviPxo0=; b=tUaLPmuP1cGdXLGe2AonFm09WbHa7OnYGWrCxfYJdzIxbiGnx2sKNXoREPiEGIHTiW 44XhPhHONbiWVnb1vwdxbF8ZIj9KP97rYOsBHmMQCxZ+zWvbkaw5pmCPG/VHASFTxLVQ Pv1hCr/WlKQAliOu3KEBhh0m8CAbfDZwuK48iz1g6wzZyHnOpdknJQTpXpvxlby8G22f gX6WUrl3kj2G3ZmpquVCZJ7npR0Ctg0TnaBAgmyuYVNAllRVbs/O82zvAOyVC5jmROmg HNbv+LDjRDy2gJoUUKxA9kkPHPkFq7NCosbgQ4MyZmaQ+DmLQojVOVD4W5IZplAj7tz5 KLhg== X-Gm-Message-State: AA+aEWbYfrB7c27Bwf2X9xNkBdUrahVfffutBO33FiHOjcaHSIUgxpHv VI1V4gXIChVcQyqXL/vwrSRpEDH5y2OMRNOP X-Google-Smtp-Source: AFSGD/UIxb3FCVZ3elGfdVwnIdUTwznCXTfTn1muksTBEP/hXxYogvZ4xeXz9+Gg4oa466/sHJVjCOfipIp/vE1U X-Received: by 2002:a24:fe42:: with SMTP id w63mr6889042ith.13.1543837138416; Mon, 03 Dec 2018 03:38:58 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:43 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-28-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 27/30] dm: sound: Add conversion to driver model X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Move the existing hardware drivers over to use driver model. Signed-off-by: Simon Glass --- arch/arm/dts/exynos5250-smdk5250.dts | 1 + arch/arm/dts/exynos5420-smdk5420.dts | 1 + drivers/sound/Makefile | 6 +- drivers/sound/max98095.c | 59 +++++++++++++++- drivers/sound/samsung-i2s.c | 91 +++++++++++++++++++++++- drivers/sound/samsung_sound.c | 101 +++++++++++++++++++++++++++ drivers/sound/wm8994.c | 53 +++++++++++++- 7 files changed, 306 insertions(+), 6 deletions(-) create mode 100644 drivers/sound/samsung_sound.c diff --git a/arch/arm/dts/exynos5250-smdk5250.dts b/arch/arm/dts/exynos5250-smdk5250.dts index 8b695442b1a..bf60b82d449 100644 --- a/arch/arm/dts/exynos5250-smdk5250.dts +++ b/arch/arm/dts/exynos5250-smdk5250.dts @@ -62,6 +62,7 @@ i2c@12C70000 { soundcodec@1a { reg = <0x1a>; + u-boot,i2c-offset-len = <2>; compatible = "wolfson,wm8994-codec"; }; }; diff --git a/arch/arm/dts/exynos5420-smdk5420.dts b/arch/arm/dts/exynos5420-smdk5420.dts index cab5ddb61fa..daaa4666964 100644 --- a/arch/arm/dts/exynos5420-smdk5420.dts +++ b/arch/arm/dts/exynos5420-smdk5420.dts @@ -84,6 +84,7 @@ i2c@12C70000 { soundcodec@1a { reg = <0x1a>; + u-boot,i2c-offset-len = <2>; compatible = "wolfson,wm8994-codec"; }; }; diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile index 70d32c6d6f6..75fa31ec534 100644 --- a/drivers/sound/Makefile +++ b/drivers/sound/Makefile @@ -6,9 +6,13 @@ obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_DM_SOUND) += codec-uclass.o obj-$(CONFIG_DM_SOUND) += i2s-uclass.o -obj-$(CONFIG_I2S) += sound-i2s.o obj-$(CONFIG_DM_SOUND) += sound-uclass.o obj-$(CONFIG_I2S_SAMSUNG) += samsung-i2s.o obj-$(CONFIG_SOUND_SANDBOX) += sandbox.o +ifdef CONFIG_DM_SOUND +obj-$(CONFIG_I2S_SAMSUNG) += samsung_sound.o +else +obj-$(CONFIG_I2S) += sound-i2s.o +endif obj-$(CONFIG_SOUND_WM8994) += wm8994.o obj-$(CONFIG_SOUND_MAX98095) += max98095.o diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index 7a3dbd09840..d6710dfaa7a 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -11,6 +11,8 @@ */ #include +#include +#include #include #include #include @@ -28,6 +30,7 @@ struct max98095_priv { unsigned int rate; unsigned int fmt; int i2c_addr; + struct udevice *dev; }; /* Index 0 is reserved. */ @@ -48,7 +51,12 @@ static int max98095_i2c_write(struct max98095_priv *priv, unsigned int reg, { debug("%s: Write Addr : 0x%02X, Data : 0x%02X\n", __func__, reg, data); +#ifdef CONFIG_DM_SOUND + debug("dev = %s\n", priv->dev->name); + return dm_i2c_write(priv->dev, reg, &data, 1); +#else return i2c_write(priv->i2c_addr, reg, 1, &data, 1); +#endif } /* @@ -65,7 +73,11 @@ static unsigned int max98095_i2c_read(struct max98095_priv *priv, { int ret; +#ifdef CONFIG_DM_SOUND + return dm_i2c_read(priv->dev, reg, data, 1); +#else ret = i2c_read(priv->i2c_addr, reg, 1, data, 1); +#endif if (ret != 0) { debug("%s: Error while reading register %#04x\n", __func__, reg); @@ -484,7 +496,7 @@ static int max98095_do_init(struct max98095_priv *priv, ret = max98095_setup_interface(priv, aif_id); if (ret < 0) { - debug("%s: max98095 codec chip init failed\n", __func__); + debug("%s: max98095 setup interface failed\n", __func__); return ret; } @@ -507,6 +519,7 @@ static int max98095_do_init(struct max98095_priv *priv, return ret; } +#ifndef CONFIG_DM_SOUND static int get_max98095_codec_values(struct sound_codec_info *pcodec_info, const void *blob) { @@ -582,3 +595,47 @@ int max98095_init(const void *blob, enum en_max_audio_interface aif_id, return ret; } +#endif + +static int max98095_set_params(struct udevice *dev, int interface, int rate, + int mclk_freq, int bits_per_sample, + uint channels) +{ + struct max98095_priv *priv = dev_get_priv(dev); + + return max98095_do_init(priv, interface, rate, mclk_freq, + bits_per_sample); +} + +static int max98095_probe(struct udevice *dev) +{ + struct max98095_priv *priv = dev_get_priv(dev); + int ret; + + priv->dev = dev; + ret = max98095_device_init(priv); + if (ret < 0) { + debug("%s: max98095 codec chip init failed\n", __func__); + return ret; + } + + return 0; +} + +static const struct audio_codec_ops max98095_ops = { + .set_params = max98095_set_params, +}; + +static const struct udevice_id max98095_ids[] = { + { .compatible = "maxim,max98095" }, + { } +}; + +U_BOOT_DRIVER(max98095) = { + .name = "max98095", + .id = UCLASS_AUDIO_CODEC, + .of_match = max98095_ids, + .probe = max98095_probe, + .ops = &max98095_ops, + .priv_auto_alloc_size = sizeof(struct max98095_priv), +}; diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c index 5cd585808ab..9978bfb19a5 100644 --- a/drivers/sound/samsung-i2s.c +++ b/drivers/sound/samsung-i2s.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -255,7 +256,7 @@ static int i2s_set_samplesize(struct i2s_reg *i2s_reg, unsigned int blc) return 0; } -int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, unsigned int *data, +int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, u32 *data, unsigned long data_size) { int i; @@ -296,8 +297,8 @@ int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, unsigned int *data, int i2s_tx_init(struct i2s_uc_priv *pi2s_tx) { int ret; - struct i2s_reg *i2s_reg = - (struct i2s_reg *)pi2s_tx->base_address; + struct i2s_reg *i2s_reg = (struct i2s_reg *)pi2s_tx->base_address; + if (pi2s_tx->id == 0) { /* Initialize GPIO for I2S-0 */ exynos_pinmux_config(PERIPH_ID_I2S0, 0); @@ -368,3 +369,87 @@ int i2s_tx_init(struct i2s_uc_priv *pi2s_tx) return ret; } + +static int samsung_i2s_tx_data(struct udevice *dev, u32 *data, uint data_size) +{ + struct i2s_uc_priv *priv = dev_get_uclass_priv(dev); + + return i2s_transfer_tx_data(priv, data, data_size); +} + +static int samsung_i2s_probe(struct udevice *dev) +{ + struct i2s_uc_priv *priv = dev_get_uclass_priv(dev); + + return i2s_tx_init(priv); +} + +static int samsung_i2s_ofdata_to_platdata(struct udevice *dev) +{ + struct i2s_uc_priv *priv = dev_get_uclass_priv(dev); + ulong base; + + /* + * Get the pre-defined sound specific values from FDT. + * All of these are expected to be correct otherwise + * wrong register values in i2s setup parameters + * may result in no sound play. + */ + base = dev_read_addr(dev); + if (base == FDT_ADDR_T_NONE) { + debug("%s: Missing i2s base\n", __func__); + return -EINVAL; + } + priv->base_address = base; + + if (dev_read_u32u(dev, "samsung,i2s-epll-clock-frequency", + &priv->audio_pll_clk)) + goto err; + debug("audio_pll_clk = %d\n", priv->audio_pll_clk); + if (dev_read_u32u(dev, "samsung,i2s-sampling-rate", + &priv->samplingrate)) + goto err; + debug("samplingrate = %d\n", priv->samplingrate); + if (dev_read_u32u(dev, "samsung,i2s-bits-per-sample", + &priv->bitspersample)) + goto err; + debug("bitspersample = %d\n", priv->bitspersample); + if (dev_read_u32u(dev, "samsung,i2s-channels", &priv->channels)) + goto err; + debug("channels = %d\n", priv->channels); + if (dev_read_u32u(dev, "samsung,i2s-lr-clk-framesize", &priv->rfs)) + goto err; + debug("rfs = %d\n", priv->rfs); + if (dev_read_u32u(dev, "samsung,i2s-bit-clk-framesize", &priv->bfs)) + goto err; + debug("bfs = %d\n", priv->bfs); + + if (dev_read_u32u(dev, "samsung,i2s-id", &priv->id)) + goto err; + debug("id = %d\n", priv->id); + + return 0; + +err: + debug("fail to get sound i2s node properties\n"); + + return -EINVAL; +} + +static const struct i2s_ops samsung_i2s_ops = { + .tx_data = samsung_i2s_tx_data, +}; + +static const struct udevice_id samsung_i2s_ids[] = { + { .compatible = "samsung,s5pv210-i2s" }, + { } +}; + +U_BOOT_DRIVER(samsung_i2s) = { + .name = "samsung_i2s", + .id = UCLASS_I2S, + .of_match = samsung_i2s_ids, + .probe = samsung_i2s_probe, + .ofdata_to_platdata = samsung_i2s_ofdata_to_platdata, + .ops = &samsung_i2s_ops, +}; diff --git a/drivers/sound/samsung_sound.c b/drivers/sound/samsung_sound.c new file mode 100644 index 00000000000..4e8321eae26 --- /dev/null +++ b/drivers/sound/samsung_sound.c @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 Google, LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +static int samsung_sound_setup(struct udevice *dev) +{ + struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev); + struct i2s_uc_priv *i2c_priv = dev_get_uclass_priv(uc_priv->i2s); + int ret; + + if (uc_priv->setup_done) + return -EALREADY; + ret = audio_codec_set_params(uc_priv->codec, i2c_priv->id, + i2c_priv->samplingrate, + i2c_priv->samplingrate * i2c_priv->rfs, + i2c_priv->bitspersample, + i2c_priv->channels); + if (ret) + return ret; + uc_priv->setup_done = true; + + return 0; +} + +static int samsung_sound_play(struct udevice *dev, uint *data, uint data_size) +{ + struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev); + + return i2s_tx_data(uc_priv->i2s, data, data_size); +} + +static int samsung_sound_probe(struct udevice *dev) +{ + struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev); + struct ofnode_phandle_args args; + struct gpio_desc en_gpio; + ofnode node; + int ret; + + ret = gpio_request_by_name(dev, "codec-enable-gpio", 0, &en_gpio, + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + + /* Turn on the GPIO which connects to the codec's "enable" line. */ + if (!ret) + gpio_set_pull(gpio_get_number(&en_gpio), S5P_GPIO_PULL_NONE); + + ret = uclass_get_device_by_phandle(UCLASS_AUDIO_CODEC, dev, + "samsung,audio-codec", + &uc_priv->codec); + if (ret) { + debug("Failed to probe audio codec\n"); + return ret; + } + node = ofnode_find_subnode(dev_ofnode(dev), "cpu"); + if (!ofnode_valid(node)) { + debug("Failed to find /cpu subnode\n"); + return -EINVAL; + } + ret = ofnode_parse_phandle_with_args(node, "sound-dai", + "#sound-dai-cells", 0, 0, &args); + if (ret) { + debug("Cannot find phandle: %d\n", ret); + return ret; + } + ret = uclass_get_device_by_ofnode(UCLASS_I2S, args.node, &uc_priv->i2s); + if (ret) { + debug("Cannot find i2s: %d\n", ret); + return ret; + } + debug("Probed sound '%s' with codec '%s' and i2s '%s'\n", dev->name, + uc_priv->codec->name, uc_priv->i2s->name); + + return 0; +} + +static const struct sound_ops samsung_sound_ops = { + .setup = samsung_sound_setup, + .play = samsung_sound_play, +}; + +static const struct udevice_id samsung_sound_ids[] = { + { .compatible = "google,snow-audio-max98095" }, + { } +}; + +U_BOOT_DRIVER(samsung_sound) = { + .name = "samsung_sound", + .id = UCLASS_SOUND, + .of_match = samsung_sound_ids, + .probe = samsung_sound_probe, + .ops = &samsung_sound_ops, +}; diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index b8c3ffb67eb..d2b22fb1d7f 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -4,6 +4,8 @@ * R. Chandrasekar */ #include +#include +#include #include #include #include @@ -39,6 +41,7 @@ struct wm8994_priv { int aifclk[WM8994_MAX_AIF]; /* audio interface clock in Hz */ struct wm8994_fll_config fll[2]; /* fll config to configure fll */ int i2c_addr; + struct udevice *dev; }; /* wm 8994 supported sampling rate values */ @@ -79,7 +82,12 @@ static int wm8994_i2c_write(struct wm8994_priv *priv, unsigned int reg, val[1] = (unsigned char)(data & 0xff); debug("Write Addr : 0x%04X, Data : 0x%04X\n", reg, data); +#ifdef CONFIG_DM_SOUND + debug("dev = %s\n", priv->dev->name); + return dm_i2c_write(priv->dev, reg, val, 2); +#else return i2c_write(priv->i2c_addr, reg, 2, val, 2); +#endif } /* @@ -97,7 +105,11 @@ static unsigned int wm8994_i2c_read(struct wm8994_priv *priv, unsigned int reg, unsigned char val[2]; int ret; +#ifdef CONFIG_DM_SOUND + ret = dm_i2c_read(priv->dev, reg, val, 1); +#else ret = i2c_read(priv->i2c_addr, reg, 2, val, 2); +#endif if (ret != 0) { debug("%s: Error while reading register %#04x\n", __func__, reg); @@ -808,6 +820,7 @@ err: return -1; } +#ifndef CONFIG_DM_SOUND /* * Gets fdt values for wm8994 config parameters * @@ -860,6 +873,7 @@ static int get_codec_values(struct sound_codec_info *pcodec_info, return 0; } +#endif static int _wm8994_init(struct wm8994_priv *priv, enum en_audio_interface aif_id, int sampling_rate, @@ -874,7 +888,7 @@ static int _wm8994_init(struct wm8994_priv *priv, return ret; } - ret = wm8994_set_sysclk(priv, aif_id, WM8994_SYSCLK_MCLK1, mclk_freq); + ret = wm8994_set_sysclk(priv, aif_id, WM8994_SYSCLK_MCLK1, mclk_freq); if (ret < 0) { debug("%s: wm8994 codec set sys clock failed\n", __func__); return ret; @@ -892,6 +906,7 @@ static int _wm8994_init(struct wm8994_priv *priv, return ret; } +#ifndef CONFIG_DM_SOUND /* WM8994 Device Initialisation */ int wm8994_init(const void *blob, enum en_audio_interface aif_id, int sampling_rate, int mclk_freq, int bits_per_sample, @@ -919,3 +934,39 @@ int wm8994_init(const void *blob, enum en_audio_interface aif_id, return _wm8994_init(&wm8994_info, aif_id, sampling_rate, mclk_freq, bits_per_sample, channels); } +#endif + +static int wm8994_set_params(struct udevice *dev, int interface, int rate, + int mclk_freq, int bits_per_sample, uint channels) +{ + struct wm8994_priv *priv = dev_get_priv(dev); + + return _wm8994_init(priv, interface, rate, mclk_freq, bits_per_sample, + channels); +} + +static int wm8994_probe(struct udevice *dev) +{ + struct wm8994_priv *priv = dev_get_priv(dev); + + priv->dev = dev; + return wm8994_device_init(priv); +} + +static const struct audio_codec_ops wm8994_ops = { + .set_params = wm8994_set_params, +}; + +static const struct udevice_id wm8994_ids[] = { + { .compatible = "wolfson,wm8994" }, + { } +}; + +U_BOOT_DRIVER(wm8994) = { + .name = "wm8994", + .id = UCLASS_AUDIO_CODEC, + .of_match = wm8994_ids, + .probe = wm8994_probe, + .ops = &wm8994_ops, + .priv_auto_alloc_size = sizeof(struct wm8994_priv), +}; From patchwork Mon Dec 3 11:37:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006871 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="G9a21sq0"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437k745B9cz9s9G for ; Mon, 3 Dec 2018 22:59:12 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5F5C2C222D5; Mon, 3 Dec 2018 11:52:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 62AC5C22484; Mon, 3 Dec 2018 11:40:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C5C30C224B6; Mon, 3 Dec 2018 11:39:07 +0000 (UTC) Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by lists.denx.de (Postfix) with ESMTPS id BDB47C22193 for ; Mon, 3 Dec 2018 11:39:02 +0000 (UTC) Received: by mail-oi1-f197.google.com with SMTP id k76so8113724oih.13 for ; Mon, 03 Dec 2018 03:39:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=8D+Ydnh/pWnGgCsUupJNXFiiUsq4afAfOd7EevCNr/U=; b=G9a21sq01mwGEYDFvh02oZCR8V87NgKPKRsesziHMUyh4tyjWQZ/VoocwzRReL/jyV RmI8ymWRWFftYN6eeKeLGl7h+AxPLpY7MkW0KbDj2IJLL6CwUmibXbi/NghMVjk723Gb 14tZK3wtFIDOcPMPt5ZlJVr7pPuXr/hGi7iLo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8D+Ydnh/pWnGgCsUupJNXFiiUsq4afAfOd7EevCNr/U=; b=g2cBQtwiHoUewtbgifaT1/NT4M8RwO8JcI7mJHMWNOBqrE3MYzgTbXjMkWNmujm+wx ROGFH1fpbwChckr+1UpKb4mEWzECGQqp59O4v/Q99fL1CIBP2uQrR5327yW3TghchY23 CrKpD4EVjqu1nS1wg2xJl+R/qCOTK6imir/00a57HDSS5aNwGgThHJYPH+rMAifW4OEo 8zsOuBtYYd7WSZEK3HDnCppwaZ0ac5UIuEM/79pzBXamiOqQyVN3vyo+zaFlDrcBayAC e7Ag0ofDtRM00HKbxZ7iuJyQtyOlOGNEXXPeeVMYRWszRv6RCasGJSsCvbI0OiI1dvIZ MRcA== X-Gm-Message-State: AA+aEWbf0WKngz3pafDB6uMBFimmPCGb5q6wMXnbABQrkLVJbFdIRy3I gk3FLMT36ntmv/vpc0zFqZbdq10veeEgIyco X-Google-Smtp-Source: AFSGD/UquUqr6o/aVLyTkgqCVjwu0AgJbiPDeDAK0KkA7fsTh6+n0vi58f257HmCnwxXzxDZB+87GOeu2CP3IM+a X-Received: by 2002:aca:53c4:: with SMTP id h187mr12875889oib.27.1543837140259; Mon, 03 Dec 2018 03:39:00 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:44 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-29-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Cc: Chander Kashyap , Akshay Saraswat Subject: [U-Boot] [PATCH 28/30] dm: exynos: sound: Convert to use driver model X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Update snow's device tree and config to use driver model for sound. Also update the others as best we can. Spring does not appear to have audio support in the kernel. The smdk5250 and smdk5420 boards use a wolfson codec which I cannot test with. So the only board that is tested and known to work is snow. Signed-off-by: Simon Glass --- arch/arm/dts/exynos5250-smdk5250.dts | 20 ++++++++++++++++++-- arch/arm/dts/exynos5250-snow.dts | 21 ++++++++++++++++----- arch/arm/dts/exynos5250-spring.dts | 24 ++++++++++++++++++++---- arch/arm/dts/exynos5250.dtsi | 15 ++++++++++----- arch/arm/dts/exynos5420-peach-pit.dts | 24 ++++++++++++++++++++---- arch/arm/dts/exynos5420-smdk5420.dts | 20 ++++++++++++++++++-- arch/arm/dts/exynos54xx.dtsi | 7 +++++++ configs/arndale_defconfig | 1 + configs/peach-pi_defconfig | 1 + configs/peach-pit_defconfig | 1 + configs/smdk5250_defconfig | 1 + configs/snow_defconfig | 1 + configs/spring_defconfig | 1 + drivers/sound/samsung_sound.c | 3 +++ 14 files changed, 118 insertions(+), 22 deletions(-) diff --git a/arch/arm/dts/exynos5250-smdk5250.dts b/arch/arm/dts/exynos5250-smdk5250.dts index bf60b82d449..e542a790761 100644 --- a/arch/arm/dts/exynos5250-smdk5250.dts +++ b/arch/arm/dts/exynos5250-smdk5250.dts @@ -60,10 +60,26 @@ }; i2c@12C70000 { - soundcodec@1a { + wm8994: soundcodec@1a { reg = <0x1a>; u-boot,i2c-offset-len = <2>; - compatible = "wolfson,wm8994-codec"; + compatible = "wolfson,wm8994"; + #sound-dai-cells = <1>; + }; + }; + + sound { + compatible = "google,smdk5250-audio-wm8994"; + + samsung,model = "SMDK5250-I2S-WM8994"; + samsung,audio-codec = <&wm8994>; + + cpu { + sound-dai = <&i2s0 0>; + }; + + codec { + sound-dai = <&wm8994 0>; }; }; diff --git a/arch/arm/dts/exynos5250-snow.dts b/arch/arm/dts/exynos5250-snow.dts index cb5067b9669..7587dc0ff24 100644 --- a/arch/arm/dts/exynos5250-snow.dts +++ b/arch/arm/dts/exynos5250-snow.dts @@ -40,7 +40,6 @@ mmc3 = "/mmc@12230000"; serial0 = "/serial@12C30000"; console = "/serial@12C30000"; - i2s = "/sound@3830000"; }; memory { @@ -214,9 +213,10 @@ }; }; - soundcodec@11 { + max98095: codec@11 { + compatible = "maxim,max98095"; reg = <0x11>; - compatible = "maxim,max98095-codec"; + #sound-dai-cells = <1>; }; }; @@ -273,9 +273,20 @@ }; }; - sound@3830000 { - samsung,codec-type = "max98095"; + sound { + compatible = "google,snow-audio-max98095"; + + samsung,model = "Snow-I2S-MAX98095"; + samsung,audio-codec = <&max98095>; codec-enable-gpio = <&gpx1 7 GPIO_ACTIVE_HIGH>; + + cpu { + sound-dai = <&i2s0 0>; + }; + + codec { + sound-dai = <&max98095 0>; + }; }; sound@12d60000 { diff --git a/arch/arm/dts/exynos5250-spring.dts b/arch/arm/dts/exynos5250-spring.dts index 7633d36874f..191e12af6a1 100644 --- a/arch/arm/dts/exynos5250-spring.dts +++ b/arch/arm/dts/exynos5250-spring.dts @@ -34,7 +34,6 @@ mmc0 = "/mmc@12200000"; serial0 = "/serial@12C30000"; console = "/serial@12C30000"; - i2s = "/sound@3830000"; }; memory { @@ -639,10 +638,27 @@ }; }; - soundcodec@20 { - reg = <0x20>; - compatible = "maxim,max98088-codec"; + max98095: soundcodec@10 { + reg = <0x10>; + compatible = "maxim,max98095"; + #sound-dai-cells = <1>; }; + + sound { + compatible = "google,spring-audio-max98095"; + + samsung,model = "Spring-I2S-MAX98095"; + samsung,audio-codec = <&max98095>; + + cpu { + sound-dai = <&i2s0 0>; + }; + + codec { + sound-dai = <&max98095 0>; + }; + }; + }; #include "cros-ec-keyboard.dtsi" diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi index 502c687802e..66c5b6dca95 100644 --- a/arch/arm/dts/exynos5250.dtsi +++ b/arch/arm/dts/exynos5250.dtsi @@ -78,9 +78,12 @@ #size-cells = <0>; }; - sound@3830000 { - compatible = "samsung,exynos-sound"; - reg = <0x3830000 0x50>; + i2s0: i2s@3830000 { + compatible = "samsung,s5pv210-i2s"; + reg = <0x03830000 0x100>; + samsung,idma-addr = <0x03000000>; + #clock-cells = <1>; + #sound-dai-cells = <1>; samsung,i2s-epll-clock-frequency = <192000000>; samsung,i2s-sampling-rate = <48000>; samsung,i2s-bits-per-sample = <16>; @@ -90,9 +93,11 @@ samsung,i2s-id = <0>; }; - sound@12d60000 { - compatible = "samsung,exynos-sound"; + i2s1: i2s@12d60000 { + compatible = "samsung,s5pv210-i2s"; reg = <0x12d60000 0x20>; + #clock-cells = <1>; + #sound-dai-cells = <1>; samsung,i2s-epll-clock-frequency = <192000000>; samsung,i2s-sampling-rate = <48000>; samsung,i2s-bits-per-sample = <16>; diff --git a/arch/arm/dts/exynos5420-peach-pit.dts b/arch/arm/dts/exynos5420-peach-pit.dts index c86f9d9035d..ca6dc2a5ac9 100644 --- a/arch/arm/dts/exynos5420-peach-pit.dts +++ b/arch/arm/dts/exynos5420-peach-pit.dts @@ -67,12 +67,28 @@ }; }; + sound { + compatible = "google,peach-audio-max98090"; + + samsung,model = "PEACH-I2S-MAX98090"; + samsung,audio-codec = <&max98090>; + + cpu { + sound-dai = <&i2s0 0>; + }; + + codec { + sound-dai = <&max98090 0>; + }; + }; + i2c@12CD0000 { /* i2c7 */ clock-frequency = <100000>; - soundcodec@20 { - reg = <0x20>; - compatible = "maxim,max98090-codec"; - }; + max98090: soundcodec@20 { + reg = <0x20>; + compatible = "maxim,max98090"; + #sound-dai-cells = <1>; + }; edp-lvds-bridge@48 { compatible = "parade,ps8625"; diff --git a/arch/arm/dts/exynos5420-smdk5420.dts b/arch/arm/dts/exynos5420-smdk5420.dts index daaa4666964..7a5da674fbe 100644 --- a/arch/arm/dts/exynos5420-smdk5420.dts +++ b/arch/arm/dts/exynos5420-smdk5420.dts @@ -82,10 +82,26 @@ }; i2c@12C70000 { - soundcodec@1a { + wm8994: soundcodec@1a { reg = <0x1a>; u-boot,i2c-offset-len = <2>; - compatible = "wolfson,wm8994-codec"; + compatible = "wolfson,wm8994"; + #sound-dai-cells = <1>; + }; + }; + + sound { + compatible = "samsung,smdk5420-audio-wm8994"; + + samsung,model = "Snow-I2S-MAX98095"; + samsung,audio-codec = <&wm8994>; + + cpu { + sound-dai = <&i2s0 0>; + }; + + codec { + sound-dai = <&wm8994 0>; }; }; diff --git a/arch/arm/dts/exynos54xx.dtsi b/arch/arm/dts/exynos54xx.dtsi index 09bef56e6c2..38c9bdc8de0 100644 --- a/arch/arm/dts/exynos54xx.dtsi +++ b/arch/arm/dts/exynos54xx.dtsi @@ -104,6 +104,13 @@ interrupts = <0 203 0>; }; + i2s0: i2s@3830000 { + compatible = "samsung,exynos5420-i2s"; + reg = <0x03830000 0x100>; + #sound-dai-cells = <1>; + samsung,idma-addr = <0x03000000>; + }; + mmc@12200000 { samsung,bus-width = <8>; samsung,timing = <1 3 3>; diff --git a/configs/arndale_defconfig b/configs/arndale_defconfig index 2b6af4b2215..22881c3a2c6 100644 --- a/configs/arndale_defconfig +++ b/configs/arndale_defconfig @@ -31,6 +31,7 @@ CONFIG_MMC_SDHCI_S5P=y CONFIG_SMC911X=y CONFIG_SMC911X_BASE=0x5000000 CONFIG_SOUND=y +CONFIG_DM_SOUND=y CONFIG_I2S=y CONFIG_I2S_SAMSUNG=y CONFIG_SOUND_MAX98095=y diff --git a/configs/peach-pi_defconfig b/configs/peach-pi_defconfig index 338eae20b41..2f82c2d82c7 100644 --- a/configs/peach-pi_defconfig +++ b/configs/peach-pi_defconfig @@ -50,6 +50,7 @@ CONFIG_REGULATOR_TPS65090=y CONFIG_DM_PWM=y CONFIG_PWM_EXYNOS=y CONFIG_SOUND=y +CONFIG_DM_SOUND=y CONFIG_I2S=y CONFIG_I2S_SAMSUNG=y CONFIG_SOUND_MAX98095=y diff --git a/configs/peach-pit_defconfig b/configs/peach-pit_defconfig index 933c823ea86..3a177f14f7c 100644 --- a/configs/peach-pit_defconfig +++ b/configs/peach-pit_defconfig @@ -49,6 +49,7 @@ CONFIG_REGULATOR_TPS65090=y CONFIG_DM_PWM=y CONFIG_PWM_EXYNOS=y CONFIG_SOUND=y +CONFIG_DM_SOUND=y CONFIG_I2S=y CONFIG_I2S_SAMSUNG=y CONFIG_SOUND_MAX98095=y diff --git a/configs/smdk5250_defconfig b/configs/smdk5250_defconfig index 161454b33fd..90ee0ffbc9d 100644 --- a/configs/smdk5250_defconfig +++ b/configs/smdk5250_defconfig @@ -44,6 +44,7 @@ CONFIG_DM_PMIC_MAX77686=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_MAX77686=y CONFIG_SOUND=y +CONFIG_DM_SOUND=y CONFIG_I2S=y CONFIG_I2S_SAMSUNG=y CONFIG_SOUND_MAX98095=y diff --git a/configs/snow_defconfig b/configs/snow_defconfig index 21080091a7d..4d1c53d4291 100644 --- a/configs/snow_defconfig +++ b/configs/snow_defconfig @@ -61,6 +61,7 @@ CONFIG_DM_PWM=y CONFIG_PWM_EXYNOS=y CONFIG_DEBUG_UART_S5P=y CONFIG_SOUND=y +CONFIG_DM_SOUND=y CONFIG_I2S=y CONFIG_I2S_SAMSUNG=y CONFIG_SOUND_MAX98095=y diff --git a/configs/spring_defconfig b/configs/spring_defconfig index ca1799895e8..8f9436c74af 100644 --- a/configs/spring_defconfig +++ b/configs/spring_defconfig @@ -61,6 +61,7 @@ CONFIG_DM_PWM=y CONFIG_PWM_EXYNOS=y CONFIG_DEBUG_UART_S5P=y CONFIG_SOUND=y +CONFIG_DM_SOUND=y CONFIG_I2S=y CONFIG_I2S_SAMSUNG=y CONFIG_SOUND_MAX98095=y diff --git a/drivers/sound/samsung_sound.c b/drivers/sound/samsung_sound.c index 4e8321eae26..d5acb574c91 100644 --- a/drivers/sound/samsung_sound.c +++ b/drivers/sound/samsung_sound.c @@ -89,6 +89,9 @@ static const struct sound_ops samsung_sound_ops = { static const struct udevice_id samsung_sound_ids[] = { { .compatible = "google,snow-audio-max98095" }, + { .compatible = "google,spring-audio-max98095" }, + { .compatible = "samsung,smdk5420-audio-wm8994" }, + { .compatible = "google,peach-audio-max98095" }, { } }; From patchwork Mon Dec 3 11:37:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006864 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Wf0cnRvm"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437k2j6pbmz9s9G for ; Mon, 3 Dec 2018 22:55:25 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A6722C22220; Mon, 3 Dec 2018 11:51:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id AD01DC22471; Mon, 3 Dec 2018 11:39:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E3FEAC22160; Mon, 3 Dec 2018 11:39:10 +0000 (UTC) Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by lists.denx.de (Postfix) with ESMTPS id 69A4AC221CB for ; Mon, 3 Dec 2018 11:39:04 +0000 (UTC) Received: by mail-oi1-f197.google.com with SMTP id a62so7952609oii.23 for ; Mon, 03 Dec 2018 03:39:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=OScMCLFzwSguTKHEmXpq4K4yuihGrntAhMzQt3PTvYg=; b=Wf0cnRvmzT5f7MUs1e0X32tjrYV3sjWxQrTNwXil9uqhyaGZ1WHL9Sv28/vpHZl4Eb hp+lBFVnMwutlv1fOdYPakENCH/zOvsI6ni75tqw2JE/51YEeyQYnjxS3ZxKZE9dHzWA ChnTB/NAE7V2BISn2TmtpxR/J8jikz/bVGu0Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=OScMCLFzwSguTKHEmXpq4K4yuihGrntAhMzQt3PTvYg=; b=Nnms76ARHYj290htWHDvauwncRtDkdsXn+v5s8SkzaUPI7o5f91sNLOZlpSJdpT/rr dhSOObIbcehoaCJbbLFFkARM2pN9dAzbjjKgAu31Ok7pOETXCTyMGOH5Je3JfeACHQWj UR64wtJhrPpX/7W+mAl200OEsxBqtnzae8lRtEYW/o2sKVpVNnKAr0/qFtRXJN4jkl8H +p5Rk3CGPvw5Z/59qBOEZZz2pRvmnpXffCrRj5JgGweM+ENGjuRwkYCsLxbhdFmUa8bu zsmAnXZojwyOlUkH0H6g9scPbPhPeLQd3vlJ+bH1xrhZIuZei8/3relci+YH9/s4fRd+ hJ/Q== X-Gm-Message-State: AA+aEWYKFJrRYw1fUwQI2i+idkQGsez8aCIjdi5L4/dUs6Bf9HN2LyCm O5ICd8KjILlOd7sMIdn3C2GyRbWSYq60bToq X-Google-Smtp-Source: AFSGD/ULelNew5TWjdrqK4eHEi/rh7QEwvfuNe3Y6mx8WjDYge4CBuCjAzdeU21WvCMTZsLLWso8a7XbuNL/mm+w X-Received: by 2002:aca:59c2:: with SMTP id n185mr13181531oib.8.1543837141975; Mon, 03 Dec 2018 03:39:01 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:45 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-30-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Cc: Chander Kashyap , Akshay Saraswat Subject: [U-Boot] [PATCH 29/30] dm: exynos: Drop CONFIG_DM_I2C_COMPAT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This option is not needed anymore for all exynos boards except arndale. Update the config. Signed-off-by: Simon Glass --- configs/peach-pi_defconfig | 1 - configs/peach-pit_defconfig | 1 - configs/smdk5250_defconfig | 1 - configs/smdk5420_defconfig | 1 - configs/snow_defconfig | 1 - configs/spring_defconfig | 1 - 6 files changed, 6 deletions(-) diff --git a/configs/peach-pi_defconfig b/configs/peach-pi_defconfig index 2f82c2d82c7..e1e662d159f 100644 --- a/configs/peach-pi_defconfig +++ b/configs/peach-pi_defconfig @@ -28,7 +28,6 @@ CONFIG_CMD_TPM_TEST=y CONFIG_CMD_EXT4_WRITE=y CONFIG_DEFAULT_DEVICE_TREE="exynos5800-peach-pi" CONFIG_ENV_IS_IN_SPI_FLASH=y -CONFIG_DM_I2C_COMPAT=y CONFIG_I2C_CROS_EC_TUNNEL=y CONFIG_I2C_MUX=y CONFIG_I2C_ARB_GPIO_CHALLENGE=y diff --git a/configs/peach-pit_defconfig b/configs/peach-pit_defconfig index 3a177f14f7c..96ed4bd3be5 100644 --- a/configs/peach-pit_defconfig +++ b/configs/peach-pit_defconfig @@ -27,7 +27,6 @@ CONFIG_CMD_TPM_TEST=y CONFIG_CMD_EXT4_WRITE=y CONFIG_DEFAULT_DEVICE_TREE="exynos5420-peach-pit" CONFIG_ENV_IS_IN_SPI_FLASH=y -CONFIG_DM_I2C_COMPAT=y CONFIG_I2C_CROS_EC_TUNNEL=y CONFIG_I2C_MUX=y CONFIG_I2C_ARB_GPIO_CHALLENGE=y diff --git a/configs/smdk5250_defconfig b/configs/smdk5250_defconfig index 90ee0ffbc9d..1e058227e41 100644 --- a/configs/smdk5250_defconfig +++ b/configs/smdk5250_defconfig @@ -30,7 +30,6 @@ CONFIG_CMD_REGULATOR=y CONFIG_CMD_EXT4_WRITE=y CONFIG_DEFAULT_DEVICE_TREE="exynos5250-smdk5250" CONFIG_ENV_IS_IN_SPI_FLASH=y -CONFIG_DM_I2C_COMPAT=y CONFIG_MMC_DW=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_S5P=y diff --git a/configs/smdk5420_defconfig b/configs/smdk5420_defconfig index 433e9a8447f..4e4558944cc 100644 --- a/configs/smdk5420_defconfig +++ b/configs/smdk5420_defconfig @@ -25,7 +25,6 @@ CONFIG_CMD_TIME=y CONFIG_CMD_EXT4_WRITE=y CONFIG_DEFAULT_DEVICE_TREE="exynos5420-smdk5420" CONFIG_ENV_IS_IN_SPI_FLASH=y -CONFIG_DM_I2C_COMPAT=y CONFIG_MMC_DW=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_S5P=y diff --git a/configs/snow_defconfig b/configs/snow_defconfig index 4d1c53d4291..10e11fbb337 100644 --- a/configs/snow_defconfig +++ b/configs/snow_defconfig @@ -34,7 +34,6 @@ CONFIG_CMD_TPM_TEST=y CONFIG_CMD_EXT4_WRITE=y CONFIG_DEFAULT_DEVICE_TREE="exynos5250-snow" CONFIG_ENV_IS_IN_SPI_FLASH=y -CONFIG_DM_I2C_COMPAT=y CONFIG_I2C_CROS_EC_LDO=y CONFIG_I2C_MUX=y CONFIG_I2C_ARB_GPIO_CHALLENGE=y diff --git a/configs/spring_defconfig b/configs/spring_defconfig index 8f9436c74af..844a87734b8 100644 --- a/configs/spring_defconfig +++ b/configs/spring_defconfig @@ -34,7 +34,6 @@ CONFIG_CMD_TPM_TEST=y CONFIG_CMD_EXT4_WRITE=y CONFIG_DEFAULT_DEVICE_TREE="exynos5250-spring" CONFIG_ENV_IS_IN_SPI_FLASH=y -CONFIG_DM_I2C_COMPAT=y CONFIG_I2C_CROS_EC_LDO=y CONFIG_I2C_MUX=y CONFIG_I2C_ARB_GPIO_CHALLENGE=y From patchwork Mon Dec 3 11:37:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1006858 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Flgp4/KL"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 437jv470P2z9sCs for ; Mon, 3 Dec 2018 22:48:48 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A4F1EC221E5; Mon, 3 Dec 2018 11:46:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B0F65C22220; Mon, 3 Dec 2018 11:39:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 660F8C221DE; Mon, 3 Dec 2018 11:39:10 +0000 (UTC) Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by lists.denx.de (Postfix) with ESMTPS id BA334C223E9 for ; Mon, 3 Dec 2018 11:39:04 +0000 (UTC) Received: by mail-oi1-f197.google.com with SMTP id r82so8121905oie.14 for ; Mon, 03 Dec 2018 03:39:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=DPH1Eq9LNvXRGw5vbESexCX76+yyjZThpdTnghdFQ9A=; b=Flgp4/KLFpD4wlKNafgOQDQiJrq5X33/RvZTmmIu/enFv67ik8uH60TYBjpLUuRSqU eJo/qb0fOgwt9zZHH5kcqjopwbAjgLbhWWaWn7sbTaUwG6aedQQToCCNX0K2SEF5hNJ4 jIOZxbX/3ZaEig89FKWctNozqEjGu3ReTI3NA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DPH1Eq9LNvXRGw5vbESexCX76+yyjZThpdTnghdFQ9A=; b=BKR174v8u1mzygtPpxIctINHwfuufZbA5qJwDTwINYkAKREc4q7+dLBKkAdxgK1Wb7 uo8a+4zfoVcmdWLEW6qEHJq/0rWfty48B2EM33F3mumTuOnZ3VM5d6qZ/LOIIfGyKimu GEY2loefQ4y4oxcJ4/REKDZWcLGowagC+mBkS3jffkCBRUgnMySnzs+BMPtdTi5YbL8H oTuxLXQKLC2lQQlsiKedT0pLUJILqVvsUutd/mll0tKPKZmdGg+wMaJVXunq/QVKYHa8 Gwf/CE/EIT1yC24nkdxD0bY47vJEkQ90uC8QyjkG/CEmJ/S1W5Rgk86rPt/MsPyicuuu gSbw== X-Gm-Message-State: AA+aEWbHZ5wFvzvbrVvRj8CZggFDofnFijUMMYIxrF7f36egNXGWhfmG RBOmYzKqGffKYBLhFAPwimPQuXPjkfg9D5LO X-Google-Smtp-Source: AFSGD/UvvPvCpwu0lHICyBr4Xi4yJXBvr8zr01+ZF4hceCXLazdQjqDOGHhSYT8kd/LnuGe4A4CNJW+d5aNqQZ+R X-Received: by 2002:aca:a809:: with SMTP id r9mr13535103oie.55.1543837143694; Mon, 03 Dec 2018 03:39:03 -0800 (PST) Date: Mon, 3 Dec 2018 04:37:46 -0700 In-Reply-To: <20181203113746.218103-1-sjg@chromium.org> Message-Id: <20181203113746.218103-31-sjg@chromium.org> Mime-Version: 1.0 References: <20181203113746.218103-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 30/30] dm: sound: Complete migration to driver model X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" All users of sound are converted to use driver model. Drop the old code and the CONFIG_DM_SOUND option. Signed-off-by: Simon Glass --- cmd/sound.c | 12 --- drivers/sound/Kconfig | 6 -- drivers/sound/Makefile | 10 +- drivers/sound/max98095.c | 88 ---------------- drivers/sound/sandbox.c | 11 -- drivers/sound/sound-i2s.c | 206 -------------------------------------- drivers/sound/wm8994.c | 95 ------------------ include/sound.h | 11 -- test/dm/Makefile | 6 +- 9 files changed, 6 insertions(+), 439 deletions(-) delete mode 100644 drivers/sound/sound-i2s.c diff --git a/cmd/sound.c b/cmd/sound.c index b063863bc9a..d00a7738167 100644 --- a/cmd/sound.c +++ b/cmd/sound.c @@ -15,18 +15,12 @@ DECLARE_GLOBAL_DATA_PTR; /* Initilaise sound subsystem */ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { -#ifdef CONFIG_DM_SOUND struct udevice *dev; -#endif int ret; -#ifdef CONFIG_DM_SOUND ret = uclass_first_device_err(UCLASS_SOUND, &dev); if (!ret) ret = sound_setup(dev); -#else - ret = sound_init(gd->fdt_blob); -#endif if (ret) { printf("Initialise Audio driver failed\n"); return CMD_RET_FAILURE; @@ -38,9 +32,7 @@ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) /* play sound from buffer */ static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { -#ifdef CONFIG_DM_SOUND struct udevice *dev; -#endif int ret = 0; int msec = 1000; int freq = 400; @@ -50,13 +42,9 @@ static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (argc > 2) freq = simple_strtoul(argv[2], NULL, 10); -#ifdef CONFIG_DM_SOUND ret = uclass_first_device_err(UCLASS_SOUND, &dev); if (!ret) ret = sound_beep(dev, msec, freq); -#else - ret = sound_play(msec, freq); -#endif if (ret) { printf("Sound device failed to play (err=%d)\n", ret); return CMD_RET_FAILURE; diff --git a/drivers/sound/Kconfig b/drivers/sound/Kconfig index 93f6c36af32..5de86c05c60 100644 --- a/drivers/sound/Kconfig +++ b/drivers/sound/Kconfig @@ -12,12 +12,6 @@ config SOUND audio codecs are called from the sound-i2s code. This could be converted to driver model. -config DM_SOUND - bool "Use driver model for sound" - help - Enable this option to use driver model for sound devices. This is a - migration option and will be removed. - config I2S bool "Enable I2S support" depends on SOUND diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile index 75fa31ec534..df46a48568b 100644 --- a/drivers/sound/Makefile +++ b/drivers/sound/Makefile @@ -4,15 +4,11 @@ # R. Chandrasekar obj-$(CONFIG_SOUND) += sound.o -obj-$(CONFIG_DM_SOUND) += codec-uclass.o -obj-$(CONFIG_DM_SOUND) += i2s-uclass.o -obj-$(CONFIG_DM_SOUND) += sound-uclass.o +obj-$(CONFIG_SOUND) += codec-uclass.o +obj-$(CONFIG_SOUND) += i2s-uclass.o +obj-$(CONFIG_SOUND) += sound-uclass.o obj-$(CONFIG_I2S_SAMSUNG) += samsung-i2s.o obj-$(CONFIG_SOUND_SANDBOX) += sandbox.o -ifdef CONFIG_DM_SOUND obj-$(CONFIG_I2S_SAMSUNG) += samsung_sound.o -else -obj-$(CONFIG_I2S) += sound-i2s.o -endif obj-$(CONFIG_SOUND_WM8994) += wm8994.o obj-$(CONFIG_SOUND_MAX98095) += max98095.o diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index d6710dfaa7a..fa204bf7a96 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -29,7 +29,6 @@ struct max98095_priv { unsigned int sysclk; unsigned int rate; unsigned int fmt; - int i2c_addr; struct udevice *dev; }; @@ -51,12 +50,7 @@ static int max98095_i2c_write(struct max98095_priv *priv, unsigned int reg, { debug("%s: Write Addr : 0x%02X, Data : 0x%02X\n", __func__, reg, data); -#ifdef CONFIG_DM_SOUND - debug("dev = %s\n", priv->dev->name); return dm_i2c_write(priv->dev, reg, &data, 1); -#else - return i2c_write(priv->i2c_addr, reg, 1, &data, 1); -#endif } /* @@ -73,11 +67,7 @@ static unsigned int max98095_i2c_read(struct max98095_priv *priv, { int ret; -#ifdef CONFIG_DM_SOUND return dm_i2c_read(priv->dev, reg, data, 1); -#else - ret = i2c_read(priv->i2c_addr, reg, 1, data, 1); -#endif if (ret != 0) { debug("%s: Error while reading register %#04x\n", __func__, reg); @@ -519,84 +509,6 @@ static int max98095_do_init(struct max98095_priv *priv, return ret; } -#ifndef CONFIG_DM_SOUND -static int get_max98095_codec_values(struct sound_codec_info *pcodec_info, - const void *blob) -{ - int error = 0; - enum fdt_compat_id compat; - int node; - int parent; - - /* Get the node from FDT for codec */ - node = fdtdec_next_compatible(blob, 0, COMPAT_MAXIM_98095_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 = %x\n", pcodec_info->i2c_dev_addr); - break; - default: - debug("%s: Unknown compat id %d\n", __func__, compat); - return -1; - } - if (error == -1) { - debug("fail to get max98095 codec node properties\n"); - return -1; - } - - return 0; -} - -/* max98095 Device Initialisation */ -int max98095_init(const void *blob, enum en_max_audio_interface aif_id, - int sampling_rate, int mclk_freq, - int bits_per_sample) -{ - int ret; - int old_bus = i2c_get_bus_num(); - struct sound_codec_info pcodec_info; - struct max98095_priv max98095_info; - - if (get_max98095_codec_values(&pcodec_info, blob) < 0) { - debug("FDT Codec values failed\n"); - return -1; - } - - i2c_set_bus_num(pcodec_info.i2c_bus); - - max98095_info.i2c_addr = pcodec_info.i2c_dev_addr; - ret = max98095_device_init(&max98095_info); - if (ret < 0) { - debug("%s: max98095 codec chip init failed\n", __func__); - return ret; - } - - ret = max98095_do_init(&max98095_info, aif_id, sampling_rate, mclk_freq, - bits_per_sample); - i2c_set_bus_num(old_bus); - - return ret; -} -#endif - static int max98095_set_params(struct udevice *dev, int interface, int rate, int mclk_freq, int bits_per_sample, uint channels) diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c index d8a971ca060..17cba616b56 100644 --- a/drivers/sound/sandbox.c +++ b/drivers/sound/sandbox.c @@ -28,17 +28,6 @@ struct sandbox_sound_priv { int sum; /* Use to sum the provided audio data */ }; -#ifndef CONFIG_DM_SOUND -int sound_play(uint32_t msec, uint32_t frequency) -{ - sandbox_sdl_sound_start(frequency); - mdelay(msec); - sandbox_sdl_sound_stop(); - - return 0; -} -#endif /* CONFIG_DM_SOUND */ - int sound_init(const void *blob) { return sandbox_sdl_sound_init(); diff --git a/drivers/sound/sound-i2s.c b/drivers/sound/sound-i2s.c deleted file mode 100644 index a2fc78154f1..00000000000 --- a/drivers/sound/sound-i2s.c +++ /dev/null @@ -1,206 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright (C) 2012 Samsung Electronics - * R. Chandrasekar - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "wm8994.h" -#include "max98095.h" - -/* defines */ -#define SOUND_400_HZ 400 -#define SOUND_BITS_IN_BYTE 8 - -static struct i2s_uc_priv g_i2stx_pri; - -/* - * get_sound_i2s_values gets values for i2s parameters - * - * @param i2s_uc_priv i2s transmitter transfer param structure - * @param blob FDT blob if enabled else NULL - */ -static int get_sound_i2s_values(struct i2s_uc_priv *i2s, const void *blob) -{ - int node; - int error = 0; - int base; - - node = fdt_path_offset(blob, "i2s"); - if (node <= 0) { - debug("EXYNOS_SOUND: No node for sound in device tree\n"); - return -1; - } - - /* - * Get the pre-defined sound specific values from FDT. - * All of these are expected to be correct otherwise - * wrong register values in i2s setup parameters - * may result in no sound play. - */ - base = fdtdec_get_addr(blob, node, "reg"); - if (base == FDT_ADDR_T_NONE) { - debug("%s: Missing i2s base\n", __func__); - return -1; - } - i2s->base_address = base; - - i2s->audio_pll_clk = fdtdec_get_int(blob, - node, "samsung,i2s-epll-clock-frequency", -1); - error |= i2s->audio_pll_clk; - debug("audio_pll_clk = %d\n", i2s->audio_pll_clk); - i2s->samplingrate = fdtdec_get_int(blob, - node, "samsung,i2s-sampling-rate", -1); - error |= i2s->samplingrate; - debug("samplingrate = %d\n", i2s->samplingrate); - i2s->bitspersample = fdtdec_get_int(blob, - node, "samsung,i2s-bits-per-sample", -1); - error |= i2s->bitspersample; - debug("bitspersample = %d\n", i2s->bitspersample); - i2s->channels = fdtdec_get_int(blob, - node, "samsung,i2s-channels", -1); - error |= i2s->channels; - debug("channels = %d\n", i2s->channels); - i2s->rfs = fdtdec_get_int(blob, - node, "samsung,i2s-lr-clk-framesize", -1); - error |= i2s->rfs; - debug("rfs = %d\n", i2s->rfs); - i2s->bfs = fdtdec_get_int(blob, - node, "samsung,i2s-bit-clk-framesize", -1); - error |= i2s->bfs; - debug("bfs = %d\n", i2s->bfs); - - i2s->id = fdtdec_get_int(blob, node, "samsung,i2s-id", -1); - error |= i2s->id; - debug("id = %d\n", i2s->id); - - if (error == -1) { - debug("fail to get sound i2s node properties\n"); - return -1; - } - - return 0; -} - -/* - * Init codec - * - * @param blob FDT blob - * @param pi2s_tx i2s parameters required by codec - * @return int value, 0 for success - */ -static int codec_init(const void *blob, struct i2s_uc_priv *pi2s_tx) -{ - int ret; - const char *codectype; - int node; - - /* Get the node from FDT for sound */ - node = fdt_path_offset(blob, "i2s"); - if (node <= 0) { - debug("EXYNOS_SOUND: No node for sound in device tree\n"); - debug("node = %d\n", node); - return -1; - } - - /* - * Get the pre-defined sound codec specific values from FDT. - * All of these are expected to be correct otherwise sound - * can not be played - */ - codectype = fdt_getprop(blob, node, "samsung,codec-type", NULL); - debug("device = %s\n", codectype); - if (!strcmp(codectype, "wm8994")) { - /* Check the codec type and initialise the same */ - ret = wm8994_init(blob, pi2s_tx->id, pi2s_tx->samplingrate, - (pi2s_tx->samplingrate * (pi2s_tx->rfs)), - pi2s_tx->bitspersample, pi2s_tx->channels); - } else if (!strcmp(codectype, "max98095")) { - ret = max98095_init(blob, pi2s_tx->id, pi2s_tx->samplingrate, - (pi2s_tx->samplingrate * (pi2s_tx->rfs)), - pi2s_tx->bitspersample); - } else { - debug("%s: Unknown codec type %s\n", __func__, codectype); - return -1; - } - - if (ret) { - debug("%s: Codec init failed\n", __func__); - return -1; - } - - return 0; -} - -int sound_init(const void *blob) -{ - int ret; - struct i2s_uc_priv *pi2s_tx = &g_i2stx_pri; - - /* Get the I2S Values */ - if (get_sound_i2s_values(pi2s_tx, blob) < 0) { - debug(" FDT I2S values failed\n"); - return -1; - } - - if (codec_init(blob, pi2s_tx) < 0) { - debug(" Codec init failed\n"); - return -1; - } - - ret = i2s_tx_init(pi2s_tx); - if (ret) { - debug("%s: Failed to init i2c transmit: ret=%d\n", __func__, - ret); - return ret; - } - - - return ret; -} - -int sound_play(uint32_t msec, uint32_t frequency) -{ - unsigned int *data; - unsigned long data_size; - unsigned int ret = 0; - - /*Buffer length computation */ - data_size = g_i2stx_pri.samplingrate * g_i2stx_pri.channels; - data_size *= (g_i2stx_pri.bitspersample / SOUND_BITS_IN_BYTE); - data = malloc(data_size); - - if (data == NULL) { - debug("%s: malloc failed\n", __func__); - return -1; - } - - sound_create_square_wave(g_i2stx_pri.samplingrate, - (unsigned short *)data, - data_size / sizeof(unsigned short), - frequency); - - while (msec >= 1000) { - ret = i2s_transfer_tx_data(&g_i2stx_pri, data, - (data_size / sizeof(int))); - msec -= 1000; - } - if (msec) { - unsigned long size = - (data_size * msec) / (sizeof(int) * 1000); - - ret = i2s_transfer_tx_data(&g_i2stx_pri, data, size); - } - - free(data); - - return ret; -} diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index d2b22fb1d7f..8421909f369 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -40,7 +40,6 @@ struct wm8994_priv { int mclk[WM8994_MAX_AIF]; /* master clock frequency in Hz */ int aifclk[WM8994_MAX_AIF]; /* audio interface clock in Hz */ struct wm8994_fll_config fll[2]; /* fll config to configure fll */ - int i2c_addr; struct udevice *dev; }; @@ -82,12 +81,7 @@ static int wm8994_i2c_write(struct wm8994_priv *priv, unsigned int reg, val[1] = (unsigned char)(data & 0xff); debug("Write Addr : 0x%04X, Data : 0x%04X\n", reg, data); -#ifdef CONFIG_DM_SOUND - debug("dev = %s\n", priv->dev->name); return dm_i2c_write(priv->dev, reg, val, 2); -#else - return i2c_write(priv->i2c_addr, reg, 2, val, 2); -#endif } /* @@ -105,11 +99,7 @@ static unsigned int wm8994_i2c_read(struct wm8994_priv *priv, unsigned int reg, unsigned char val[2]; int ret; -#ifdef CONFIG_DM_SOUND ret = dm_i2c_read(priv->dev, reg, val, 1); -#else - ret = i2c_read(priv->i2c_addr, reg, 2, val, 2); -#endif if (ret != 0) { debug("%s: Error while reading register %#04x\n", __func__, reg); @@ -820,61 +810,6 @@ err: return -1; } -#ifndef CONFIG_DM_SOUND -/* - * 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; - 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; - } - - if (error == -1) { - debug("fail to get wm8994 codec node properties\n"); - return -1; - } - - return 0; -} -#endif - static int _wm8994_init(struct wm8994_priv *priv, enum en_audio_interface aif_id, int sampling_rate, int mclk_freq, int bits_per_sample, @@ -906,36 +841,6 @@ static int _wm8994_init(struct wm8994_priv *priv, return ret; } -#ifndef CONFIG_DM_SOUND -/* WM8994 Device Initialisation */ -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) -{ - struct sound_codec_info pcodec_info; - struct wm8994_priv wm8994_info; - int ret; - - /* 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 */ - wm8994_info.i2c_addr = pcodec_info.i2c_dev_addr; - i2c_set_bus_num(pcodec_info.i2c_bus); - ret = wm8994_device_init(&wm8994_info); - if (ret < 0) { - debug("%s: wm8994 codec chip init failed\n", __func__); - return ret; - } - - return _wm8994_init(&wm8994_info, aif_id, sampling_rate, mclk_freq, - bits_per_sample, channels); -} -#endif - static int wm8994_set_params(struct udevice *dev, int interface, int rate, int mclk_freq, int bits_per_sample, uint channels) { diff --git a/include/sound.h b/include/sound.h index a8235a75b9c..494d0a448ed 100644 --- a/include/sound.h +++ b/include/sound.h @@ -52,7 +52,6 @@ void sound_create_square_wave(uint sample_rate, unsigned short *data, int size, */ int sound_init(const void *blob); -#ifdef CONFIG_DM_SOUND /* * The sound uclass brings together a data transport (currently only I2C) and a * codec (currently connected over I2C). @@ -101,14 +100,4 @@ int sound_beep(struct udevice *dev, int msecs, int frequency_hz); */ int sound_find_codec_i2s(struct udevice *dev); -#else -/* - * plays the pcm data buffer in pcm_data.h through i2s1 to make the - * sine wave sound - * - * @return int 0 for success, -1 for error - */ -int sound_play(uint32_t msec, uint32_t frequency); -#endif /* CONFIG_DM_SOUND */ - #endif /* __SOUND__H__ */ diff --git a/test/dm/Makefile b/test/dm/Makefile index 0c1459cd4db..43c2e7535b1 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -13,7 +13,7 @@ obj-$(CONFIG_UT_DM) += test-uclass.o # subsystem you must add sandbox tests here. obj-$(CONFIG_UT_DM) += core.o ifneq ($(CONFIG_SANDBOX),) -obj-$(CONFIG_DM_SOUND) += audio.o +obj-$(CONFIG_SOUND) += audio.o obj-$(CONFIG_BLK) += blk.o obj-$(CONFIG_BOARD) += board.o obj-$(CONFIG_CLK) += clk.o @@ -21,7 +21,7 @@ obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_FIRMWARE) += firmware.o obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_I2C) += i2c.o -obj-$(CONFIG_DM_SOUND) += i2s.o +obj-$(CONFIG_SOUND) += i2s.o obj-$(CONFIG_LED) += led.o obj-$(CONFIG_DM_MAILBOX) += mailbox.o obj-$(CONFIG_DM_MMC) += mmc.o @@ -54,7 +54,7 @@ obj-$(CONFIG_AXI) += axi.o obj-$(CONFIG_MISC) += misc.o obj-$(CONFIG_DM_SERIAL) += serial.o obj-$(CONFIG_CPU) += cpu.o -obj-$(CONFIG_DM_SOUND) += sound.o +obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o endif