From patchwork Wed Jun 26 01:58:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11016765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 627B714C0 for ; Wed, 26 Jun 2019 02:24:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45E2028372 for ; Wed, 26 Jun 2019 02:24:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A23E285D5; Wed, 26 Jun 2019 02:24:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7BC56285E0 for ; Wed, 26 Jun 2019 02:24:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 19C521657; Wed, 26 Jun 2019 03:59:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 19C521657 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1561514401; bh=zKK2xmUH2WQ5AJJyMjgLg1djwkJNmEUfCR9Bf7d9jwk=; h=Date:From:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=KsOf4jncekxizUNZHZtFRF6+AVbKRtOpJyw6kZvp9avG7TKRJ/1fL9o4Aq1qDPNPs rXAQ7rMG1qEVbiiiAc+j9gZNW2ElJZKZ87swWv8yCHBWVwFKjQCOwhx1RVE7+7UqWW 0lkFWwrFBvINABKzy1SV7nV7P+q9HgfqZ/G7vuio= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 982CCF8070C; Wed, 26 Jun 2019 03:59:10 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 67A07F896B9; Wed, 26 Jun 2019 03:59:09 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id B5267F8070C for ; Wed, 26 Jun 2019 03:58:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B5267F8070C Date: 26 Jun 2019 10:58:56 +0900 X-IronPort-AV: E=Sophos;i="5.62,418,1554735600"; d="scan'208";a="19698902" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 26 Jun 2019 10:58:56 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 40812415D194; Wed, 26 Jun 2019 10:58:56 +0900 (JST) Message-ID: <877e99yur2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.5 Mule/6.0 To: Mark Brown MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA , hien.dang.eb@renesas.com, Chaoliang Qin Subject: [alsa-devel] [PATCH] ASoC: rsnd: ssiu: tidyup SSI_MODE1/2 settings X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto R-Car Sound can use pin sharing and multi-SSI for SSI0/1/2/3/4/9. Because complex HW settings and spaghetti code, the settings for SSI9 pin sharing with SSI0 doesn't work. This patch tidyup settings for it. Reported-by: Hien Dang Signed-off-by: Kuninori Morimoto Tested-by: Chaoliang Qin --- sound/soc/sh/rcar/ssiu.c | 92 +++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 48 deletions(-) diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c index 2347f34..f35d882 100644 --- a/sound/soc/sh/rcar/ssiu.c +++ b/sound/soc/sh/rcar/ssiu.c @@ -60,11 +60,11 @@ static int rsnd_ssiu_init(struct rsnd_mod *mod, struct rsnd_priv *priv) { struct rsnd_dai *rdai = rsnd_io_to_rdai(io); - u32 multi_ssi_slaves = rsnd_ssi_multi_slaves_runtime(io); + u32 ssis = rsnd_ssi_multi_slaves_runtime(io); int use_busif = rsnd_ssi_use_busif(io); int id = rsnd_mod_id(mod); - u32 mask1, val1; - u32 mask2, val2; + int is_clk_master = rsnd_rdai_is_clk_master(rdai); + u32 val1, val2; int i; /* clear status */ @@ -89,57 +89,53 @@ static int rsnd_ssiu_init(struct rsnd_mod *mod, rsnd_mod_bset(mod, SSI_MODE0, (1 << id), !use_busif << id); /* - * SSI_MODE1 + * SSI_MODE1 / SSI_MODE2 + * + * FIXME + * sharing/multi with SSI0 are mainly supported */ - mask1 = (1 << 4) | (1 << 20); /* mask sync bit */ - mask2 = (1 << 4); /* mask sync bit */ - val1 = val2 = 0; - if (id == 8) { - /* - * SSI8 pin is sharing with SSI7, nothing to do. - */ - } else if (rsnd_ssi_is_pin_sharing(io)) { - int shift = -1; - - switch (id) { - case 1: - shift = 0; - break; - case 2: - shift = 2; - break; - case 4: - shift = 16; - break; - default: - return -EINVAL; - } - - mask1 |= 0x3 << shift; - val1 = rsnd_rdai_is_clk_master(rdai) ? - 0x2 << shift : 0x1 << shift; + val1 = rsnd_mod_read(mod, SSI_MODE1); + val2 = rsnd_mod_read(mod, SSI_MODE2); + if (rsnd_ssi_is_pin_sharing(io)) { - } else if (multi_ssi_slaves) { + ssis |= (1 << id); - mask2 |= 0x00000007; - mask1 |= 0x0000000f; - - switch (multi_ssi_slaves) { - case 0x0206: /* SSI0/1/2/9 */ - val2 = (1 << 4) | /* SSI0129 sync */ - (rsnd_rdai_is_clk_master(rdai) ? 0x2 : 0x1); - /* fall through */ - case 0x0006: /* SSI0/1/2 */ - val1 = rsnd_rdai_is_clk_master(rdai) ? - 0xa : 0x5; + } else if (ssis) { + /* + * Multi SSI + * + * set synchronized bit here + */ - if (!val2) /* SSI012 sync */ - val1 |= (1 << 4); - } + /* SSI4 is synchronized with SSI3 */ + if (ssis & (1 << 4)) + val1 |= (1 << 20); + /* SSI012 are synchronized */ + if (ssis == 0x0006) + val1 |= (1 << 4); + /* SSI0129 are synchronized */ + if (ssis == 0x0206) + val2 |= (1 << 4); } - rsnd_mod_bset(mod, SSI_MODE1, mask1, val1); - rsnd_mod_bset(mod, SSI_MODE2, mask2, val2); + /* SSI1 is sharing pin with SSI0 */ + if (ssis & (1 << 1)) + val1 |= is_clk_master ? 0x2 : 0x1; + + /* SSI2 is sharing pin with SSI0 */ + if (ssis & (1 << 2)) + val1 |= is_clk_master ? 0x2 << 2 : + 0x1 << 2; + /* SSI4 is sharing pin with SSI3 */ + if (ssis & (1 << 4)) + val1 |= is_clk_master ? 0x2 << 16 : + 0x1 << 16; + /* SSI9 is sharing pin with SSI0 */ + if (ssis & (1 << 9)) + val2 |= is_clk_master ? 0x2 : 0x1; + + rsnd_mod_bset(mod, SSI_MODE1, 0x0013001f, val1); + rsnd_mod_bset(mod, SSI_MODE2, 0x00000017, val2); return 0; }