From patchwork Fri Aug 30 07:00:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 103817 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sjvcf-0007Zj-2E for patchwork@linuxtv.org; Fri, 30 Aug 2024 07:00:43 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 879511F2240F for ; Fri, 30 Aug 2024 07:00:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4DFB15217F; Fri, 30 Aug 2024 07:00:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gY8eI+Av" X-Original-To: linux-media@vger.kernel.org Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A455314B097 for ; Fri, 30 Aug 2024 07:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725001234; cv=none; b=NezPzEuMRyk4YuZGzO8pvJuhs8ur9WHNRFo5/3H2hR7Z86lpey0A7MyFxIwH+OMCSnMzfaTHKM0l1ebU8W5xDphC0S+fUZ2KE0gk51y479oC8hC+kVq/xV5qjgJoRoTQaPxqAwhig2CANU7Db83KnAxa0tXzoV+Y1pz5Ue1RcEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725001234; c=relaxed/simple; bh=a6I8Qs7jMbe5Yb5WDtVl0Gq6RD5+eZiag/bS9+BBXxk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=oVVxc8PHImef+ZC1/UGfFV1NJTeLq96mfInFb6UNBFBnj+dfZerGK51sIF8f/lLBpc6ATOZaQH8p4E3ZOuuKi2qDJuuZwcfuQQzFIfS292cGXr70VijsO4SvK/BXQrXPgxXP/BkTGqXzZtkjimBHpx7ZFuOyB67WLNFC3KkFGJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gY8eI+Av; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-53345dcd377so1916967e87.2 for ; Fri, 30 Aug 2024 00:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725001230; x=1725606030; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=z7pxeFgHV40RxgLrj2ICzTAKUNIYzDpUHLvdENSnR6k=; b=gY8eI+AvOpbsfHGsCY+c8PpsEiSD6ZgbByKAn9Uh3liwVFufXTTHf5tSKAl3YvOu3Q REuvF4c6XoUaNZFJ0ytvi9GW+YfVtMHp+vLe48zR+ExE0I7W9wsGwkmJnMIoMWKyRzon fT1hfIrg+DM69O8q6uUnAr76eYSN5Ltu4mvX5NtxcrD5omErsDGLfpBY0/MqdZxNHLaT amp/kpBpI+a0vcghSAuXR7bB5Nd82+8DedBkqHvws6RGeARUB2+9TdlkcX5S+Sp03dWG H8HOCPNqaxafVRn6agNJu5aZUjBd6+Ruu0IkPO0xMSn4NKBMOQcgD7QZuQkrbGAVPgJY /AmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725001230; x=1725606030; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=z7pxeFgHV40RxgLrj2ICzTAKUNIYzDpUHLvdENSnR6k=; b=OTEbzbbtXCT5vqGOw/6hX0vqkV+k3z477IrwTtMhtzZWiXdEBlf8tF7Z/wIhwJwwOp Zka8rR4QASe1p2x/Wt9o6EkXmksCEbYjjt+jhTX4zRKQdlgojf9GBCzVPEN1V/G75sI/ VnDpWp4QBis5EP/hI4DucCMAs3kvDQRF2uuSzDtwUfZevhpuDiu8pJJ80gi178Ky+H3N LDFJSnRMPoH2sHndAvC6O1zbCgGcDQGP7M2GEaR67JpIMxB613H44FKKQzBSGAcKY5co sMRnRI1n7exCu6jBAeyo5gzP4y4yD+FVGiHcCTLBDYvnU2Q+uX/C+ytfWLF0pp57+Krc h8pg== X-Gm-Message-State: AOJu0YzevQhcP15eR5xFK1YNvtuWGruAbGHO9i+heVY7smXpESk8OweV mAXoHag2nuugWwn3cF/YS5JCxLz4n7ui35AOm/STjdPXP6UFBSW38GjBpp9Zts8= X-Google-Smtp-Source: AGHT+IEBWfPM5bLQmB/JIZOeeHbWFZdy1WPnG9UAWmNtbBe/eCxoGRDHSrUxaBPXSIeXdhlPYG2wdQ== X-Received: by 2002:a05:6512:3e1d:b0:530:ea2b:1a92 with SMTP id 2adb3069b0e04-53546b93fa8mr670786e87.43.1725001229459; Fri, 30 Aug 2024 00:00:29 -0700 (PDT) Received: from localhost.localdomain ([188.243.23.53]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5354079bc00sm444790e87.3.2024.08.30.00.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 00:00:28 -0700 (PDT) From: Alexander Shiyan To: linux-media@vger.kernel.org Cc: Tomi Valkeinen , Mauro Carvalho Chehab , Alexander Shiyan Subject: [PATCH 1/3] media: i2c: ds90ub960: Convert IC specific variables to flags Date: Fri, 30 Aug 2024 10:00:07 +0300 Message-Id: <20240830070008.9486-1-eagle.alexander923@gmail.com> X-Mailer: git-send-email 2.39.1 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-LSpam-Score: -5.3 (-----) X-LSpam-Report: No, score=-5.3 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,FREEMAIL_FORGED_FROMDOMAIN=1,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no This patch converts chip-specific variables into generic flags that can be used to easily add support for other chip types. Signed-off-by: Alexander Shiyan --- drivers/media/i2c/ds90ub960.c | 48 ++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index ffe5f25f8647..e9f9abf439ee 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -402,12 +402,18 @@ #define UB960_MAX_EQ_LEVEL 14 #define UB960_NUM_EQ_LEVELS (UB960_MAX_EQ_LEVEL - UB960_MIN_EQ_LEVEL + 1) +enum chip_type { + UB960, + UB9702, +}; + +#define FLAGS_HAS_FPDLINK4 BIT(0) + struct ub960_hw_data { - const char *model; + enum chip_type chip_type; u8 num_rxports; u8 num_txports; - bool is_ub9702; - bool is_fpdlink4; + u32 flags; }; enum ub960_rxport_mode { @@ -1654,7 +1660,7 @@ static int ub960_rxport_add_serializer(struct ub960_data *priv, u8 nport) ser_pdata->port = nport; ser_pdata->atr = priv->atr; - if (priv->hw_data->is_ub9702) + if (priv->hw_data->chip_type == UB9702) ser_pdata->bc_rate = ub960_calc_bc_clk_rate_ub9702(priv, rxport); else ser_pdata->bc_rate = ub960_calc_bc_clk_rate_ub960(priv, rxport); @@ -1785,7 +1791,7 @@ static int ub960_init_tx_ports(struct ub960_data *priv) ub960_write(priv, UB960_SR_CSI_PLL_CTL, speed_select); - if (priv->hw_data->is_ub9702) { + if (priv->hw_data->chip_type == UB9702) { ub960_write(priv, UB960_SR_CSI_PLL_DIV, pll_div); switch (priv->tx_data_rate) { @@ -2140,7 +2146,7 @@ static int ub960_init_rx_ports(struct ub960_data *priv) if (!rxport) continue; - if (priv->hw_data->is_ub9702) + if (priv->hw_data->chip_type == UB9702) ub960_init_rx_port_ub9702(priv, rxport); else ub960_init_rx_port_ub960(priv, rxport); @@ -2509,7 +2515,7 @@ static int ub960_configure_ports_for_streaming(struct ub960_data *priv, case RXPORT_MODE_CSI2_SYNC: case RXPORT_MODE_CSI2_NONSYNC: - if (!priv->hw_data->is_ub9702) { + if (priv->hw_data->chip_type != UB9702) { /* Map all VCs from this port to the same VC */ ub960_rxport_write(priv, nport, UB960_RR_CSI_VC_MAP, (vc << UB960_RR_CSI_VC_MAP_SHIFT(3)) | @@ -3217,7 +3223,8 @@ ub960_parse_dt_rxport_link_properties(struct ub960_data *priv, return -EINVAL; } - if (!priv->hw_data->is_fpdlink4 && cdr_mode == RXPORT_CDR_FPD4) { + if (!(priv->hw_data->flags & FLAGS_HAS_FPDLINK4) && + (cdr_mode == RXPORT_CDR_FPD4)) { dev_err(dev, "rx%u: FPD-Link 4 CDR not supported\n", nport); return -EINVAL; } @@ -3796,6 +3803,7 @@ static int ub960_get_hw_resources(struct ub960_data *priv) static int ub960_enable_core_hw(struct ub960_data *priv) { struct device *dev = &priv->client->dev; + const char *model; u8 rev_mask; int ret; u8 dev_sts; @@ -3830,8 +3838,19 @@ static int ub960_enable_core_hw(struct ub960_data *priv) goto err_pd_gpio; } - dev_dbg(dev, "Found %s (rev/mask %#04x)\n", priv->hw_data->model, - rev_mask); + switch (priv->hw_data->chip_type) { + case UB960: + model = "UB960"; + break; + case UB9702: + model = "UB9702"; + break; + default: + model = "Unknown"; + break; + }; + + dev_dbg(dev, "Found %s (rev/mask %#04x)\n", model, rev_mask); ret = ub960_read(priv, UB960_SR_DEVICE_STS, &dev_sts); if (ret) @@ -3851,7 +3870,7 @@ static int ub960_enable_core_hw(struct ub960_data *priv) goto err_pd_gpio; /* release GPIO lock */ - if (priv->hw_data->is_ub9702) { + if (priv->hw_data->chip_type == UB9702) { ret = ub960_update_bits(priv, UB960_SR_RESET, UB960_SR_RESET_GPIO_LOCK_RELEASE, UB960_SR_RESET_GPIO_LOCK_RELEASE); @@ -4013,17 +4032,16 @@ static void ub960_remove(struct i2c_client *client) } static const struct ub960_hw_data ds90ub960_hw = { - .model = "ub960", + .chip_type = UB960, .num_rxports = 4, .num_txports = 2, }; static const struct ub960_hw_data ds90ub9702_hw = { - .model = "ub9702", + .chip_type = UB9702, .num_rxports = 4, .num_txports = 2, - .is_ub9702 = true, - .is_fpdlink4 = true, + .flags = FLAGS_HAS_FPDLINK4, }; static const struct i2c_device_id ub960_id[] = { From patchwork Fri Aug 30 07:00:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 103818 Received: from sv.mirrors.kernel.org ([139.178.88.99]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sjvcf-0007Zq-3B for patchwork@linuxtv.org; Fri, 30 Aug 2024 07:00:44 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5F9EF2863F3 for ; Fri, 30 Aug 2024 07:00:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8844D1537B1; Fri, 30 Aug 2024 07:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KE+lM2Hp" X-Original-To: linux-media@vger.kernel.org Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7323814B097 for ; Fri, 30 Aug 2024 07:00:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725001237; cv=none; b=qpfBur5JxyvhgKmfHUnYb5Xmy/quJnHMZ5kxvWNAz9ghkFulm9Hjh4BSXtH+zuoOQyUPPmrDAYz1KTVjNOvBiTkWIN9IfFvYkDuhsYW1V2VWdJ/sF5pwnVNESzXFqgagKFKgUomAGXWo8Yhs+jMqbEJLQMP0X+wtgcXhS9Zav8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725001237; c=relaxed/simple; bh=W5S7M4RNQkCcGnQoz8599FUBLtc2XrkIxxpn7l88GFg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Woru1amLe6mUhUgJ29GkgzLD4Jsxk9YX5bxDttF6PGL92D5XjPtJofrDAyllznFRzORa54rjG93+WbtMACHiIqOeYOg8GCDAHdpH/YfmdDIkqZRnP44bSgpyys00C3ovh9QHIAPz5Vh9nPB54Eclc84KW2A0gk5mTWjBQeN64nU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KE+lM2Hp; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2f4f2cda058so22966251fa.1 for ; Fri, 30 Aug 2024 00:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725001233; x=1725606033; darn=vger.kernel.org; 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=6+I37Gce5202U+swYjBjto78oXZeUKvEmhAL5UPP3tg=; b=KE+lM2HpLqg/IygunSONuV2MHD5Z3gV4ZFpsyx2pOF0wpG3JoCXX+0gaz2AWpakII4 oZA55l/TmXxyVzuMZFBJ3YnSmtlm5+ywmtUJllz8dWdARCDFd81dUO9Zg7ZHQSR8d3QP eYty/qcQanS4Q6PMBGz+nJFMVIIhHNDDH1y0ARAPlYiv+qwiUCubbDj9rnHvH/5XaEk+ 8kiF5i8SAjOetWFeJn4Oq7jJabzEXXAPsrJis5VM9H283np3JAgL2SQT0CgYPDfPjhr0 cAe3wVgtuwsTuYdvUtn3LbUbeTsLr4D4gyUVW6SV0c8tS7geUfhLalqoMXnJ5g4p1H/2 zFig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725001233; x=1725606033; 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=6+I37Gce5202U+swYjBjto78oXZeUKvEmhAL5UPP3tg=; b=T9nmOG6tMaSvG8iVJhz9OVgYXFBwHTLM3bEUEPH1rpxzFSEF6G0cuUg3fQo0uR1su9 kqmty1KjpCSkyCxi8WrrngxVT8qNLcjEorpeh0g8VLp1+dGF/NUgOFJzm6V4U+79hwdv u/jYVY6tM5wX6Khk2lYBswVQH61DKW21TCmdGqQ/+vNZf4JHAdLAjjo3KcH9CeNQYZAZ RYhd/5b1QSszh/rxWtiethy21PiHpMvw41h4N5b2+MsPSXjUA5qX7XEShAd04KGSDWzE ARbi/zPA0sKKKyYCi3ARpII2Zm0bzxaCHvE9aADdT/DpGgvNG0/lbqIE3uufOd7clIAp gAmg== X-Gm-Message-State: AOJu0YxBTaeqDocwIeaxJMi+ZyHbysSqDo4bVqF6JHyZv0yIsuNYOThv 7DWB/wk55cyT3sLatA4klbKoxfvfjz2kLhGQK4NyayNipN4tYoYrmUljkEYl/SU= X-Google-Smtp-Source: AGHT+IF3X/xSMPKK4mrHt+B0cfctMzSLF3sVOuvKAAjMGz+Ov2hrPyRzs46SNEhWOAzql7PKkTbYkg== X-Received: by 2002:a05:6512:15a5:b0:530:ae99:c850 with SMTP id 2adb3069b0e04-535462ed7femr404802e87.1.1725001232554; Fri, 30 Aug 2024 00:00:32 -0700 (PDT) Received: from localhost.localdomain ([188.243.23.53]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5354079bc00sm444790e87.3.2024.08.30.00.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 00:00:32 -0700 (PDT) From: Alexander Shiyan To: linux-media@vger.kernel.org Cc: Tomi Valkeinen , Mauro Carvalho Chehab , Alexander Shiyan Subject: [PATCH 2/3] media: i2c: ds90ub960: Add DS90UB954 support Date: Fri, 30 Aug 2024 10:00:08 +0300 Message-Id: <20240830070008.9486-2-eagle.alexander923@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240830070008.9486-1-eagle.alexander923@gmail.com> References: <20240830070008.9486-1-eagle.alexander923@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-LSpam-Score: -7.6 (-------) X-LSpam-Report: No, score=-7.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,FREEMAIL_FORGED_FROMDOMAIN=1,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add support for TI DS90UB954 FPD-Link III Deserializer. Signed-off-by: Alexander Shiyan --- drivers/media/i2c/Kconfig | 2 +- drivers/media/i2c/ds90ub960.c | 52 +++++++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 8ba096b8ebca..18766898280b 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -1604,7 +1604,7 @@ config VIDEO_DS90UB960 select V4L2_FWNODE select VIDEO_V4L2_SUBDEV_API help - Device driver for the Texas Instruments DS90UB960 + Device driver for the Texas Instruments DS90UB954/DS90UB960 FPD-Link III Deserializer and DS90UB9702 FPD-Link IV Deserializer. config VIDEO_MAX96714 diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index e9f9abf439ee..9edc7e8ceebd 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -403,6 +403,7 @@ #define UB960_NUM_EQ_LEVELS (UB960_MAX_EQ_LEVEL - UB960_MIN_EQ_LEVEL + 1) enum chip_type { + UB954, UB960, UB9702, }; @@ -1154,10 +1155,17 @@ static int ub960_parse_dt_txport(struct ub960_data *priv, priv->tx_link_freq[0] = vep.link_frequencies[0]; priv->tx_data_rate = priv->tx_link_freq[0] * 2; - if (priv->tx_data_rate != MHZ(1600) && - priv->tx_data_rate != MHZ(1200) && - priv->tx_data_rate != MHZ(800) && - priv->tx_data_rate != MHZ(400)) { + switch (priv->tx_data_rate) { + case MHZ(1600): + case MHZ(800): + case MHZ(400): + break; + case MHZ(1200): + /* UB954 does not support 1.2 Gbps */ + if (priv->hw_data->chip_type != UB954) + break; + fallthrough; + default: dev_err(dev, "tx%u: invalid 'link-frequencies' value\n", nport); ret = -EINVAL; goto err_free_vep; @@ -1419,7 +1427,7 @@ static void ub960_rxport_config_eq(struct ub960_data *priv, unsigned int nport) if (priv->strobe.manual) ub960_rxport_set_strobe_pos(priv, nport, rxport->eq.strobe_pos); - else + else if (priv->hw_data->chip_type != UB954) ub960_rxport_set_strobe_pos(priv, nport, 0); if (rxport->eq.manual_eq) { @@ -3807,7 +3815,7 @@ static int ub960_enable_core_hw(struct ub960_data *priv) u8 rev_mask; int ret; u8 dev_sts; - u8 refclk_freq; + u8 refclk_freq[2]; ret = regulator_enable(priv->vddio); if (ret) @@ -3839,6 +3847,9 @@ static int ub960_enable_core_hw(struct ub960_data *priv) } switch (priv->hw_data->chip_type) { + case UB954: + model = "UB954"; + break; case UB960: model = "UB960"; break; @@ -3856,12 +3867,26 @@ static int ub960_enable_core_hw(struct ub960_data *priv) if (ret) goto err_pd_gpio; - ret = ub960_read(priv, UB960_XR_REFCLK_FREQ, &refclk_freq); + ret = ub960_read(priv, UB960_XR_REFCLK_FREQ, &refclk_freq[0]); if (ret) goto err_pd_gpio; + /* From DS90UB954-Q1 datasheet: + * "REFCLK_FREQ measurement is not synchronized. Value in this register + * should read twice and only considered valid if + * REFCLK_FREQ is unchanged between reads." + */ + while (priv->hw_data->chip_type == UB954) { + ret = ub960_read(priv, UB960_XR_REFCLK_FREQ, &refclk_freq[1]); + if (ret) + goto err_pd_gpio; + if (refclk_freq[0] == refclk_freq[1]) + break; + refclk_freq[0] = refclk_freq[1]; + }; + dev_dbg(dev, "refclk valid %u freq %u MHz (clk fw freq %lu MHz)\n", - !!(dev_sts & BIT(4)), refclk_freq, + !!(dev_sts & BIT(4)), refclk_freq[0], clk_get_rate(priv->refclk) / 1000000); /* Disable all RX ports by default */ @@ -3923,7 +3948,8 @@ static int ub960_probe(struct i2c_client *client) */ priv->reg_current.indirect_target = 0xff; priv->reg_current.rxport = 0xff; - priv->reg_current.txport = 0xff; + /* Avoid using UB960_SR_CSI_PORT_SEL register for single TX channel */ + priv->reg_current.txport = priv->hw_data->num_txports > 1 ? 0xff : 0x00; ret = ub960_get_hw_resources(priv); if (ret) @@ -4031,6 +4057,12 @@ static void ub960_remove(struct i2c_client *client) mutex_destroy(&priv->reg_lock); } +static const struct ub960_hw_data ds90ub954_hw = { + .chip_type = UB954, + .num_rxports = 2, + .num_txports = 1, +}; + static const struct ub960_hw_data ds90ub960_hw = { .chip_type = UB960, .num_rxports = 4, @@ -4045,6 +4077,7 @@ static const struct ub960_hw_data ds90ub9702_hw = { }; static const struct i2c_device_id ub960_id[] = { + { "ds90ub954-q1", (kernel_ulong_t)&ds90ub954_hw }, { "ds90ub960-q1", (kernel_ulong_t)&ds90ub960_hw }, { "ds90ub9702-q1", (kernel_ulong_t)&ds90ub9702_hw }, {} @@ -4052,6 +4085,7 @@ static const struct i2c_device_id ub960_id[] = { MODULE_DEVICE_TABLE(i2c, ub960_id); static const struct of_device_id ub960_dt_ids[] = { + { .compatible = "ti,ds90ub954-q1", .data = &ds90ub954_hw }, { .compatible = "ti,ds90ub960-q1", .data = &ds90ub960_hw }, { .compatible = "ti,ds90ub9702-q1", .data = &ds90ub9702_hw }, {} From patchwork Fri Aug 30 07:01:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 103819 Received: from sy.mirrors.kernel.org ([147.75.48.161]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sjvde-0007dD-14 for patchwork@linuxtv.org; Fri, 30 Aug 2024 07:01:42 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8D70FB2352A for ; Fri, 30 Aug 2024 07:01:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB1F61531E5; Fri, 30 Aug 2024 07:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BRx5unVa" X-Original-To: linux-media@vger.kernel.org Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6F8413632B; Fri, 30 Aug 2024 07:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725001293; cv=none; b=IHUYOSf3fjElvd3XPtQ7QMCX/ZrPQatP0wH5OtZODZj/unOQvsuLerKRkAEEhvG6odU4IWfepjpAgW+1QWouN5tVEMTzhLFvztIQhAbZHzJw8R3XkEk3rBtGh4jkMKXPUhJ9YwXeRYxTiFrt2uIEV1iQyqRYRtYYso/kpqq8gyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725001293; c=relaxed/simple; bh=roUrAwD6Mfamk0VVuy51w0oIeK3LcXL9+iW1zKIlYQ0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=NzCsW2fEvhpxiVl2GQCLb16/nxQWrzSAJm5Xqqwy5Z/8ZSsXTCP7GRrrqabUewaqLaJez3zd6Y5x2uEGkG+gKW37FVlwszUonK7pJHboiVyCzQrw5V6o+0C/iSF+EGvJJFDYT4O0Z1f3ja38nWaS0f9Cj475BTn7u7lubw0xNNM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BRx5unVa; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5343eeb4973so2250194e87.2; Fri, 30 Aug 2024 00:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725001289; x=1725606089; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EJWZKHVVLlONzA4x5xRAz9qJwfWJ9BhWAQh5+mGuTHc=; b=BRx5unVavy9egIiLEx6pYbgRwa5WLBF2VsgH0t+B98d4i6cPsUa278XG9KwRgQkOHA 6mG5Tlcd6HJqTFnTSlNGHEHQpMA63veUQxsemZlVEh2sVJ2SDJM7/tECXzPyZWeiijrx oWZaTa9SZ/JTTc70HDDpCn1FqjuqVn3Az3JMKGtraj2d0yDWQDYUyOj743W2fTkwE6vT 4SmYdAmweL0JT5AZDZ6amDzsFnNvmWAfhh2NQ4TmiV6OCB2r7f5cyw3jOSMMLggovJoY QYphnaR1SlSssLH/mwOEOqWK0ESc/3NzVbeMdJKHEbyAkLmv42BCWlqSR/mAr+4T/epE e1Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725001289; x=1725606089; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EJWZKHVVLlONzA4x5xRAz9qJwfWJ9BhWAQh5+mGuTHc=; b=gQ/QkF7AAoOM5umsR+pYRWy/Gz+1kT7Fl5dSsQyf3rL3C/7w7Ico5dEOcdmFZWtayY Oc4YBUC4B7IO9uVzF+KtgehK8SrYSoUAOLw3O2dfLMGQrR29MR5+Cu+W/92KPDKqqE6D MGrgzMJLkhVzg0ao4Y0yVRmB4GfceUkDmxpVHuERuNejxdTH96dQW4WgK1IcaXstDV7H hCrKBEdInvJmn5jDYeOXdGqb9LLIQ8+/6SNVn3BIacTwvnd/aLP3QP6cL1Py0iP8+h0Q 96uDZ4m5orVHVdEoe+6IUmRQ0TSFUvKc0twIXP+AcZZeSUv/RrHya7KPavCEWHd1SI0y LyGA== X-Forwarded-Encrypted: i=1; AJvYcCXme29RzDS+PEOGO3iZvmq4scoWyvuwNKryc/d9dfrAEgHzkx1ErhaLlXBGq4/udKoc5e91iWigGvx3@vger.kernel.org X-Gm-Message-State: AOJu0YzPAxPwvokkohtmvJNzYi79MPhDEHGpDQ45jwSXQhE7XSXv5SlM /kfZL7cKIgMb7RcTKTL717V4d9chG9lLXHxpZnimmz/Uo7mJXvk+Hi1z75Qufo8= X-Google-Smtp-Source: AGHT+IFt4guMcNJTUuabiNexzhE/moV9FJPY1jZ3jRs986HiwdduMovtdIQl95NL0/ahyIEGQXrlxQ== X-Received: by 2002:a05:6512:3a89:b0:530:ab68:25c5 with SMTP id 2adb3069b0e04-53546b1e1d7mr822055e87.2.1725001288599; Fri, 30 Aug 2024 00:01:28 -0700 (PDT) Received: from localhost.localdomain ([188.243.23.53]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5354079bc1bsm452676e87.16.2024.08.30.00.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 00:01:28 -0700 (PDT) From: Alexander Shiyan To: linux-media@vger.kernel.org Cc: Tomi Valkeinen , Mauro Carvalho Chehab , devicetree@vger.kernel.org, Alexander Shiyan Subject: [PATCH 3/3] media: dt-bindings: i2c: ds90ub960: Add DS90UB954 chip to DS90UB960 bindings Date: Fri, 30 Aug 2024 10:01:17 +0300 Message-Id: <20240830070117.9534-1-eagle.alexander923@gmail.com> X-Mailer: git-send-email 2.39.1 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-LSpam-Score: -5.3 (-----) X-LSpam-Report: No, score=-5.3 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,FREEMAIL_FORGED_FROMDOMAIN=1,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no The ds90ub960 driver can now be used for the DS90UB954 chip as it has a similar register set and configuration. Let's add an additional compatibility line to the bindings. Signed-off-by: Alexander Shiyan Acked-by: Conor Dooley --- Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml index 0b71e6f911a8..86d43d949dd3 100644 --- a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml +++ b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml @@ -19,6 +19,7 @@ allOf: properties: compatible: enum: + - ti,ds90ub954-q1 - ti,ds90ub960-q1 - ti,ds90ub9702-q1