From patchwork Mon Apr 24 18:59:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13222500 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01359C77B78 for ; Mon, 24 Apr 2023 19:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232251AbjDXTAB (ORCPT ); Mon, 24 Apr 2023 15:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231681AbjDXTAA (ORCPT ); Mon, 24 Apr 2023 15:00:00 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 085B35B81 for ; Mon, 24 Apr 2023 11:59:58 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-506c04dd879so8324400a12.3 for ; Mon, 24 Apr 2023 11:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20221208.gappssmtp.com; s=20221208; t=1682362796; x=1684954796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S3HMfUX0hKXutl63WtepWnzJmhRd3jEgXA+lFtA0IvU=; b=gp29EeTnq5CaZDUwi9OLi8eI0JUOTlUZLKDFDogBlVTHyj5RwqoY338RcHbreOIVEJ xd2NOpnOs393RWr/Vvo5o+Kvri1yriujUkAL98x5V9RDjeXEbJseOuTX7Tjz+YU/WfTO 2AQ347VvAekRqXt9CB2c3i6D9eZbn0Lu1SGelWW9X5GZkSlpSKuwOdzPv0M3U2kEeMMW RX32roVfaQgHtoQkrdeuc1ySINpxdAxPR8WXmmWB6PDMtSt4RTCgVZA0YOP0hrXfVzXR 9IN0qA1lN+jawdaKKR09a3hAUP5wTmrJwNK2UlAtQiCeNA4ohup5egQL8v/sgqUIui7h X2ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682362796; x=1684954796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S3HMfUX0hKXutl63WtepWnzJmhRd3jEgXA+lFtA0IvU=; b=jkmlXzmY/wFF99prVdY+KJ/6m2j/4orORJ6wdQBekMk9T9e1+owPq1DSKPUjmV01Ug 99BLmtopxzPvZlAfgtZrQe+yoU9AkKJkhVYm2Oy+YcqTbmPJlr5zy5kMg3CBtMT0gBji FDQOCr0b5DKHYW3uJD9sh6eNqmD5S2Ol9maWE9jtGH/Gw6IJ3j5y8gF79j0QkC1+c0nJ 7Wb7/4maHCSDDDtfCu41bFutMz6DvNbczNN0/XVnbifFfuSHFClkp8CbPW+79mDLuXcg z76PaAXirt6eAcz24e4wGl9FScu+EETK0NBdlyuzFeyNkcMME/5HMEbjHjH8K9ceyeBS FRAw== X-Gm-Message-State: AAQBX9fM3pmmetTago9/R1qU1jze2w5N3IPlAv0fKJrv7w8nEhxFOwU7 YkfIGJID5CkFZ25cs+pzruLV7g== X-Google-Smtp-Source: AKy350YfkJ4UQM4b06vOXsE7iG32E4owcaqbAWAal5HJzx9Pclg2L7cx2yLWViuQxgS2ffMaL3jFJQ== X-Received: by 2002:a17:907:674a:b0:953:64f4:e42e with SMTP id qm10-20020a170907674a00b0095364f4e42emr10618935ejc.5.1682362796432; Mon, 24 Apr 2023 11:59:56 -0700 (PDT) Received: from sleipner.berto.se (p54ac52fc.dip0.t-ipconnect.de. [84.172.82.252]) by smtp.googlemail.com with ESMTPSA id ke15-20020a17090798ef00b0095328ce9c8bsm5849818ejc.67.2023.04.24.11.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 11:59:55 -0700 (PDT) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Hans Verkuil , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v2 1/3] media: rcar-csi2: Prepare for Gen4 support Date: Mon, 24 Apr 2023 20:59:32 +0200 Message-Id: <20230424185934.438059-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230424185934.438059-1-niklas.soderlund+renesas@ragnatech.se> References: <20230424185934.438059-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Prepare the driver for supporting R-Car Gen4. The starting of the receiver and how to enter standby differs between Gen3 and Gen4, create function pointers in the device info structure to control the different behavior. Signed-off-by: Niklas Söderlund --- * Changes since v1 - Rebased to latest media-tree. --- .../platform/renesas/rcar-vin/rcar-csi2.c | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-csi2.c b/drivers/media/platform/renesas/rcar-vin/rcar-csi2.c index 5dbd0daa8735..05ea1723f04b 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-csi2.c @@ -483,6 +483,8 @@ enum rcar_csi2_pads { struct rcar_csi2_info { int (*init_phtw)(struct rcar_csi2 *priv, unsigned int mbps); int (*phy_post_init)(struct rcar_csi2 *priv); + int (*start_receiver)(struct rcar_csi2 *priv); + void (*enter_standby)(struct rcar_csi2 *priv); const struct rcsi2_mbps_reg *hsfreqrange; unsigned int csi0clkfreqrange; unsigned int num_channels; @@ -533,10 +535,17 @@ static void rcsi2_write(struct rcar_csi2 *priv, unsigned int reg, u32 data) iowrite32(data, priv->base + reg); } -static void rcsi2_enter_standby(struct rcar_csi2 *priv) +static void rcsi2_enter_standby_gen3(struct rcar_csi2 *priv) { rcsi2_write(priv, PHYCNT_REG, 0); rcsi2_write(priv, PHTC_REG, PHTC_TESTCLR); +} + +static void rcsi2_enter_standby(struct rcar_csi2 *priv) +{ + if (priv->info->enter_standby) + priv->info->enter_standby(priv); + reset_control_assert(priv->rstc); usleep_range(100, 150); pm_runtime_put(priv->dev); @@ -674,7 +683,7 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv, return 0; } -static int rcsi2_start_receiver(struct rcar_csi2 *priv) +static int rcsi2_start_receiver_gen3(struct rcar_csi2 *priv) { const struct rcar_csi2_format *format; u32 phycnt, vcdt = 0, vcdt2 = 0, fld = 0; @@ -821,7 +830,7 @@ static int rcsi2_start(struct rcar_csi2 *priv) if (ret < 0) return ret; - ret = rcsi2_start_receiver(priv); + ret = priv->info->start_receiver(priv); if (ret) { rcsi2_enter_standby(priv); return ret; @@ -1363,6 +1372,8 @@ static int rcsi2_probe_resources(struct rcar_csi2 *priv, static const struct rcar_csi2_info rcar_csi2_info_r8a7795 = { .init_phtw = rcsi2_init_phtw_h3_v3h_m3n, + .start_receiver = rcsi2_start_receiver_gen3, + .enter_standby = rcsi2_enter_standby_gen3, .hsfreqrange = hsfreqrange_h3_v3h_m3n, .csi0clkfreqrange = 0x20, .num_channels = 4, @@ -1371,6 +1382,8 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a7795 = { static const struct rcar_csi2_info rcar_csi2_info_r8a7795es2 = { .init_phtw = rcsi2_init_phtw_h3es2, + .start_receiver = rcsi2_start_receiver_gen3, + .enter_standby = rcsi2_enter_standby_gen3, .hsfreqrange = hsfreqrange_h3_v3h_m3n, .csi0clkfreqrange = 0x20, .num_channels = 4, @@ -1378,17 +1391,23 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a7795es2 = { }; static const struct rcar_csi2_info rcar_csi2_info_r8a7796 = { + .start_receiver = rcsi2_start_receiver_gen3, + .enter_standby = rcsi2_enter_standby_gen3, .hsfreqrange = hsfreqrange_m3w, .num_channels = 4, }; static const struct rcar_csi2_info rcar_csi2_info_r8a77961 = { + .start_receiver = rcsi2_start_receiver_gen3, + .enter_standby = rcsi2_enter_standby_gen3, .hsfreqrange = hsfreqrange_m3w, .num_channels = 4, }; static const struct rcar_csi2_info rcar_csi2_info_r8a77965 = { .init_phtw = rcsi2_init_phtw_h3_v3h_m3n, + .start_receiver = rcsi2_start_receiver_gen3, + .enter_standby = rcsi2_enter_standby_gen3, .hsfreqrange = hsfreqrange_h3_v3h_m3n, .csi0clkfreqrange = 0x20, .num_channels = 4, @@ -1398,11 +1417,15 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a77965 = { static const struct rcar_csi2_info rcar_csi2_info_r8a77970 = { .init_phtw = rcsi2_init_phtw_v3m_e3, .phy_post_init = rcsi2_phy_post_init_v3m_e3, + .start_receiver = rcsi2_start_receiver_gen3, + .enter_standby = rcsi2_enter_standby_gen3, .num_channels = 4, }; static const struct rcar_csi2_info rcar_csi2_info_r8a77980 = { .init_phtw = rcsi2_init_phtw_h3_v3h_m3n, + .start_receiver = rcsi2_start_receiver_gen3, + .enter_standby = rcsi2_enter_standby_gen3, .hsfreqrange = hsfreqrange_h3_v3h_m3n, .csi0clkfreqrange = 0x20, .clear_ulps = true, @@ -1411,11 +1434,15 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a77980 = { static const struct rcar_csi2_info rcar_csi2_info_r8a77990 = { .init_phtw = rcsi2_init_phtw_v3m_e3, .phy_post_init = rcsi2_phy_post_init_v3m_e3, + .start_receiver = rcsi2_start_receiver_gen3, + .enter_standby = rcsi2_enter_standby_gen3, .num_channels = 2, }; static const struct rcar_csi2_info rcar_csi2_info_r8a779a0 = { .init_phtw = rcsi2_init_phtw_v3u, + .start_receiver = rcsi2_start_receiver_gen3, + .enter_standby = rcsi2_enter_standby_gen3, .hsfreqrange = hsfreqrange_v3u, .csi0clkfreqrange = 0x20, .clear_ulps = true,