Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1224773ybg; Wed, 29 Jul 2020 08:45:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAqNn7dRB+8mnKlnyy/vL7E7pioBxh9GQ1zK9cRyoFhMuoviF9twbjwTEPBAfC1+fxlCGm X-Received: by 2002:a05:6402:a5b:: with SMTP id bt27mr15627120edb.120.1596037522843; Wed, 29 Jul 2020 08:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596037522; cv=none; d=google.com; s=arc-20160816; b=khPuDnMHydVfghU5h5pr/snGfHlot/NpYRSTNL/U8yi7TMT6fVuyOzdT7hemEzbDOc 1CqGd7pYuMwsi1zctn8RuwZugr083Ihh95FPUNRZmloWkXYgpXzOzErt2zzgVq2qN4N3 VJoBJqtDcD0IRc5ZPCgBLWsUtaotjb6gefbUI3bt0fM5sz9NnE4blkg1MFjrR+zbRxCc l2ar5I+feqe0+MWcLgmwj9s8bDauWrOCpXYS+D/12fxWTptmicjHYI5F4CYKoNHJr8w6 ST8OA8/3N+aoRf4DaYbUtuKYVWI73UEDc8yERbTD8L4TMRA/Yqx5BSOesr7RDQlA2XjY eXHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CQIn+VEpnEWmSg9hS5AE3VgFC5CX71fT+x9MqwA/nSI=; b=mwb5lz/c917AZIh4pG6YKZNPTVnc5D05UDFb3CRu19GasFPKRdd7IOMT2f2b2A4gg2 x5uAnA2trmKdPzcB8KbaaeDRz6SbnEY/SXYLNwOMCRFMNPVEcCCSBJG6Z6OV5EjBhvJT haEncX0qqCF2u5S9620WsCpOIAr6Zklus8wxDQaTPSSGeB6v/ZAFqqV2mCRGb2j+naHM uawNHWkWXCdIpCVQfThkKe0D4YYJ5kVWUuRKBOPrDpYLQ3zidI42Kl9lYWHCErLYcCBB HwBu/w8+pZKxN7KyHKYiR3W7aXuCcoQmzWLsRVhzF/br2AZVh6tNs0hLyvnOvSqYFr45 zzaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=Eo+0w9c4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qx20si1382074ejb.489.2020.07.29.08.44.59; Wed, 29 Jul 2020 08:45:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=Eo+0w9c4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726961AbgG2PoM (ORCPT + 99 others); Wed, 29 Jul 2020 11:44:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726916AbgG2PoJ (ORCPT ); Wed, 29 Jul 2020 11:44:09 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AF01C0619D4 for ; Wed, 29 Jul 2020 08:44:09 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id a14so22119503wra.5 for ; Wed, 29 Jul 2020 08:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CQIn+VEpnEWmSg9hS5AE3VgFC5CX71fT+x9MqwA/nSI=; b=Eo+0w9c4wPP7x+MiwaxTzJX484Ai6UmktMd8hl2Q5Eu7JdW4RcKGROLAIeJ5MoIQV7 SZcw9L4eFS3ufCY7FdWL6qdbbUhqqMv6kq8e+lMtk0B8HsVV1NzGj9IQHgXOVNmfbF0M OUJ/zIkQq+hDQd4iUqTxiwsL5SAiAApARsYsD74qqaC4Y+obzj0AoV4o1diNM3v7SLv4 BVSrUDX06j9FXxvYq2WM+PBBHSvDwOYZZcNy67cs4+O7DWffIQ0YR4FXK/eGvUPdkjEu PtXZLqU9kaZ+ojo7qYMIcESGpKDoKrMkwi3d7AcS3h+7Fho57bOiamNQkQVRChsYf6p5 JI+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CQIn+VEpnEWmSg9hS5AE3VgFC5CX71fT+x9MqwA/nSI=; b=j0X/yj4ddeB25OwgMgc7dEuG9zTUhlHUq6wurNyWBMraZPV0xHZUxAFqz677tKO9ml Epj4lm7hKLbEviqG9HE70UbSOf9gbEclyVQdhlc7Hx8Td29dDlyDnzRPNtyGuKBJjvW2 nufE7KpevXYLY7Md4JrPknyEuU4ffS9h8K/yaKdax6PQ22afYOor5uQcqFqe33lsHPg2 0Lhxbsz3scynt+Gdor2hD/T2vTtpcrD3cG4Mn4XEJ7E/+x3vWVgBHDdSDeGtFiLdfoI2 EPxN/xe2+VobbpjTagD9tXEM9H42cLFNeR/F6pAJdOk06t+lzhHiprgu3Hnq6kqLbapo C1Zg== X-Gm-Message-State: AOAM531qcRLjeQXj6IOsRL8L7PTbEvNvXeJe5tmsktUZZA3Oyd1oEIRM uIhJVDOn+UMOeNXFLBRGh1BxLg== X-Received: by 2002:adf:de8d:: with SMTP id w13mr29665660wrl.129.1596037447519; Wed, 29 Jul 2020 08:44:07 -0700 (PDT) Received: from starbuck.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id a134sm6526030wmd.17.2020.07.29.08.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 08:44:06 -0700 (PDT) From: Jerome Brunet To: Neil Armstrong , linux-clk@vger.kernel.org Cc: Jerome Brunet , Kevin Hilman , linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] clk: meson: add sclk-ws driver Date: Wed, 29 Jul 2020 17:43:57 +0200 Message-Id: <20200729154359.1983085-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200729154359.1983085-1-jbrunet@baylibre.com> References: <20200729154359.1983085-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is yet another simple but odd driver for the audio block of the g12a and sm1 SoC families. For TDMOUT's sclk to be properly inverted, bit 29 of AUDIO_CLK_TDMOUT_x_CTRL should be the inverse of bit 28. IOW bit28 == !bit29 at all times This setting is automatically applied on axg and the manual setting was added on g12a. Signed-off-by: Jerome Brunet --- drivers/clk/meson/clk-phase.c | 56 +++++++++++++++++++++++++++++++++++ drivers/clk/meson/clk-phase.h | 6 ++++ 2 files changed, 62 insertions(+) diff --git a/drivers/clk/meson/clk-phase.c b/drivers/clk/meson/clk-phase.c index fe22e171121a..a6763439f7d2 100644 --- a/drivers/clk/meson/clk-phase.c +++ b/drivers/clk/meson/clk-phase.c @@ -125,6 +125,62 @@ const struct clk_ops meson_clk_triphase_ops = { }; EXPORT_SYMBOL_GPL(meson_clk_triphase_ops); +/* + * This is a special clock for the audio controller. + * This drive a bit clock inverter for which the + * opposite value of the inverter bit needs to be manually + * set into another bit + */ +static inline struct meson_sclk_ws_inv_data * +meson_sclk_ws_inv_data(struct clk_regmap *clk) +{ + return (struct meson_sclk_ws_inv_data *)clk->data; +} + +static int meson_sclk_ws_inv_sync(struct clk_hw *hw) +{ + struct clk_regmap *clk = to_clk_regmap(hw); + struct meson_sclk_ws_inv_data *tph = meson_sclk_ws_inv_data(clk); + unsigned int val; + + /* Get phase and sync the inverted value to ws */ + val = meson_parm_read(clk->map, &tph->ph); + meson_parm_write(clk->map, &tph->ws, val ? 0 : 1); + + return 0; +} + +static int meson_sclk_ws_inv_get_phase(struct clk_hw *hw) +{ + struct clk_regmap *clk = to_clk_regmap(hw); + struct meson_sclk_ws_inv_data *tph = meson_sclk_ws_inv_data(clk); + unsigned int val; + + val = meson_parm_read(clk->map, &tph->ph); + + return meson_clk_degrees_from_val(val, tph->ph.width); +} + +static int meson_sclk_ws_inv_set_phase(struct clk_hw *hw, int degrees) +{ + struct clk_regmap *clk = to_clk_regmap(hw); + struct meson_sclk_ws_inv_data *tph = meson_sclk_ws_inv_data(clk); + unsigned int val; + + val = meson_clk_degrees_to_val(degrees, tph->ph.width); + meson_parm_write(clk->map, &tph->ph, val); + meson_parm_write(clk->map, &tph->ws, val ? 0 : 1); + return 0; +} + +const struct clk_ops meson_sclk_ws_inv_ops = { + .init = meson_sclk_ws_inv_sync, + .get_phase = meson_sclk_ws_inv_get_phase, + .set_phase = meson_sclk_ws_inv_set_phase, +}; +EXPORT_SYMBOL_GPL(meson_sclk_ws_inv_ops); + + MODULE_DESCRIPTION("Amlogic phase driver"); MODULE_AUTHOR("Jerome Brunet "); MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/meson/clk-phase.h b/drivers/clk/meson/clk-phase.h index 5579f9ced142..b637b9b227bc 100644 --- a/drivers/clk/meson/clk-phase.h +++ b/drivers/clk/meson/clk-phase.h @@ -20,7 +20,13 @@ struct meson_clk_triphase_data { struct parm ph2; }; +struct meson_sclk_ws_inv_data { + struct parm ph; + struct parm ws; +}; + extern const struct clk_ops meson_clk_phase_ops; extern const struct clk_ops meson_clk_triphase_ops; +extern const struct clk_ops meson_sclk_ws_inv_ops; #endif /* __MESON_CLK_PHASE_H */ -- 2.25.4