Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp652324rwe; Fri, 26 Aug 2022 11:35:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR7M6e82epRPuYYPuaZxuLGcbi83tQPU5AnWSZxLIZk5PBA0uwK8PhDd53BO72s2q6Q3mrgT X-Received: by 2002:a17:90b:4b11:b0:1fb:248f:5ed with SMTP id lx17-20020a17090b4b1100b001fb248f05edmr5784627pjb.150.1661538949163; Fri, 26 Aug 2022 11:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661538949; cv=none; d=google.com; s=arc-20160816; b=0KE8IBRurKjvgCtPpaCJCwvyzsWUmbyHJnV6h0SPzu6BRfLxXbhMO3uR0dmPbDBmc7 8c2mpSO1rYpsrwmjBJxGz1x35P5y84EmfbyLbCx6kIOq9IBrvzkpYXDe+SngsCxJ7yCU y93JtF2JWGlATJM0rOOT9DJB1EggeCU0O339maO7yUOhC+pO30gZicuTyFRQ7zGEelSR 7NjXx/xz5sSYQw89S7S51/7xB9bleYcTnp97zB04GRg8/YGXgydHF+y01CEtsxriUFPQ F3W/hgAlmvkX5b05MSv/DVAdSGc1JuEWb1mrnDeoTyYGBKSX+8zPRl7iFh4rPL5CG/o/ qKNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5zvr8GUUIl8BZtc8RF9yzFuenMKn2tdvNLGUULuRJk8=; b=wgDCkM1FQsGu6e8Fw171NQ9PMdSerApAxserLokIq989Mt3ZqqQ5ykqkHpNjwxKY1A gvRZMV/VGcf9zFR0y+19Xq6DW99ReUy519g+zarK0aixI64mC+YhfMVYj9dM7oh58GmY hFJSRFQNaew4Xn4lYTQkYaw0NaL9BuhhVxuCkHZDo6/p5WxQtpJLGA2a2dj2KBGy4wgG /iPEq7Vlz5+VPXsC4Yk0wTM9peGJ936jZLk8zFYHro9ldrojko9hDnznZDW+e7nD0O42 30mjUBk11NfECgdHSakfr9Ke266hslevNJUHdKgZxqYasJguEEbksYPlD1pNUVmVwLA+ 633Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=JRMXidZ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a630c07000000b00419dc0c2d71si2257123pgl.115.2022.08.26.11.35.36; Fri, 26 Aug 2022 11:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=JRMXidZ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245261AbiHZSdh (ORCPT + 99 others); Fri, 26 Aug 2022 14:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344659AbiHZSdQ (ORCPT ); Fri, 26 Aug 2022 14:33:16 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCB2FE3C2C; Fri, 26 Aug 2022 11:33:13 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id B5BC7FF80F; Fri, 26 Aug 2022 18:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1661538792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5zvr8GUUIl8BZtc8RF9yzFuenMKn2tdvNLGUULuRJk8=; b=JRMXidZ7G1ZKo8HqW2hfxEDnGUOMjfd342eKteJOIgJBvE5KrazEIUZ+mtUd4A9CWlBl7n k2AbY/8QgZuF17Cu0dsHbDZSfYUlcch4e1Lu8xp6+GL7w0Q0l55QSuOZuVh9R4mJN6G4Ek sQ4grbVaMR22Gs24rg9Z2BRaiFWA4QSo0qIaoIdCO/pdb2lEArXl8byYdkQyIzcE1IMXRZ Fd1aDMBqdRw87YW1hEwhvhEYQNbVlUlL9eImxeiFPe1BoPgQ7d+1EVlGB97gtw0RB+Y4Kj IJtCsRUvHnOvuv+FinPHZEC8eFd886hkxm61Y7ifVLHPnAZAqjZaG6s2GSxFsA== From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Cc: Yong Deng , Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Maxime Ripard , Thomas Petazzoni Subject: [PATCH v6 05/43] media: sun6i-csi: Define and use variant to get module clock rate Date: Fri, 26 Aug 2022 20:32:02 +0200 Message-Id: <20220826183240.604834-6-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220826183240.604834-1-paul.kocialkowski@bootlin.com> References: <20220826183240.604834-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce a proper variant structure with the module clock rate instead of hardcoding it with a manual check on the compatible. Signed-off-by: Paul Kocialkowski Reviewed-by: Jernej Skrabec --- .../platform/sunxi/sun6i-csi/sun6i_csi.c | 47 ++++++++++++++----- .../platform/sunxi/sun6i-csi/sun6i_csi.h | 4 ++ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index 89a15cd779ac..800851f4e18c 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -808,11 +808,15 @@ static int sun6i_csi_resources_setup(struct sun6i_csi_device *csi_dev, struct platform_device *platform_dev) { struct device *dev = csi_dev->dev; - unsigned long clock_mod_rate; + const struct sun6i_csi_variant *variant; void __iomem *io_base; int ret; int irq; + variant = of_device_get_match_data(dev); + if (!variant) + return -EINVAL; + /* Registers */ io_base = devm_platform_ioremap_resource(platform_dev, 0); @@ -840,12 +844,8 @@ static int sun6i_csi_resources_setup(struct sun6i_csi_device *csi_dev, return PTR_ERR(csi_dev->clock_ram); } - if (of_device_is_compatible(dev->of_node, "allwinner,sun50i-a64-csi")) - clock_mod_rate = 300000000; - else - clock_mod_rate = 297000000; - - ret = clk_set_rate_exclusive(csi_dev->clock_mod, clock_mod_rate); + ret = clk_set_rate_exclusive(csi_dev->clock_mod, + variant->clock_mod_rate); if (ret) { dev_err(dev, "failed to set mod clock rate\n"); return ret; @@ -928,12 +928,35 @@ static int sun6i_csi_remove(struct platform_device *pdev) return 0; } +static const struct sun6i_csi_variant sun6i_a31_csi_variant = { + .clock_mod_rate = 297000000, +}; + +static const struct sun6i_csi_variant sun50i_a64_csi_variant = { + .clock_mod_rate = 300000000, +}; + static const struct of_device_id sun6i_csi_of_match[] = { - { .compatible = "allwinner,sun6i-a31-csi", }, - { .compatible = "allwinner,sun8i-a83t-csi", }, - { .compatible = "allwinner,sun8i-h3-csi", }, - { .compatible = "allwinner,sun8i-v3s-csi", }, - { .compatible = "allwinner,sun50i-a64-csi", }, + { + .compatible = "allwinner,sun6i-a31-csi", + .data = &sun6i_a31_csi_variant, + }, + { + .compatible = "allwinner,sun8i-a83t-csi", + .data = &sun6i_a31_csi_variant, + }, + { + .compatible = "allwinner,sun8i-h3-csi", + .data = &sun6i_a31_csi_variant, + }, + { + .compatible = "allwinner,sun8i-v3s-csi", + .data = &sun6i_a31_csi_variant, + }, + { + .compatible = "allwinner,sun50i-a64-csi", + .data = &sun50i_a64_csi_variant, + }, {}, }; diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h index 945d0cb5ab39..a76b545f2aa4 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h @@ -58,6 +58,10 @@ struct sun6i_csi_device { int planar_offset[3]; }; +struct sun6i_csi_variant { + unsigned long clock_mod_rate; +}; + /** * sun6i_csi_is_format_supported() - check if the format supported by csi * @csi: pointer to the csi -- 2.37.1