Skip to content

Commit bc67ec9

Browse files
paulkocialkowskimchehab
authored andcommitted
media: sun6i-csi: Define and use variant to get module clock rate
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 <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 740b5b3 commit bc67ec9

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,15 @@ static int sun6i_csi_resources_setup(struct sun6i_csi_device *csi_dev,
808808
struct platform_device *platform_dev)
809809
{
810810
struct device *dev = csi_dev->dev;
811-
unsigned long clock_mod_rate;
811+
const struct sun6i_csi_variant *variant;
812812
void __iomem *io_base;
813813
int ret;
814814
int irq;
815815

816+
variant = of_device_get_match_data(dev);
817+
if (!variant)
818+
return -EINVAL;
819+
816820
/* Registers */
817821

818822
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,
840844
return PTR_ERR(csi_dev->clock_ram);
841845
}
842846

843-
if (of_device_is_compatible(dev->of_node, "allwinner,sun50i-a64-csi"))
844-
clock_mod_rate = 300000000;
845-
else
846-
clock_mod_rate = 297000000;
847-
848-
ret = clk_set_rate_exclusive(csi_dev->clock_mod, clock_mod_rate);
847+
ret = clk_set_rate_exclusive(csi_dev->clock_mod,
848+
variant->clock_mod_rate);
849849
if (ret) {
850850
dev_err(dev, "failed to set mod clock rate\n");
851851
return ret;
@@ -928,12 +928,35 @@ static int sun6i_csi_remove(struct platform_device *pdev)
928928
return 0;
929929
}
930930

931+
static const struct sun6i_csi_variant sun6i_a31_csi_variant = {
932+
.clock_mod_rate = 297000000,
933+
};
934+
935+
static const struct sun6i_csi_variant sun50i_a64_csi_variant = {
936+
.clock_mod_rate = 300000000,
937+
};
938+
931939
static const struct of_device_id sun6i_csi_of_match[] = {
932-
{ .compatible = "allwinner,sun6i-a31-csi", },
933-
{ .compatible = "allwinner,sun8i-a83t-csi", },
934-
{ .compatible = "allwinner,sun8i-h3-csi", },
935-
{ .compatible = "allwinner,sun8i-v3s-csi", },
936-
{ .compatible = "allwinner,sun50i-a64-csi", },
940+
{
941+
.compatible = "allwinner,sun6i-a31-csi",
942+
.data = &sun6i_a31_csi_variant,
943+
},
944+
{
945+
.compatible = "allwinner,sun8i-a83t-csi",
946+
.data = &sun6i_a31_csi_variant,
947+
},
948+
{
949+
.compatible = "allwinner,sun8i-h3-csi",
950+
.data = &sun6i_a31_csi_variant,
951+
},
952+
{
953+
.compatible = "allwinner,sun8i-v3s-csi",
954+
.data = &sun6i_a31_csi_variant,
955+
},
956+
{
957+
.compatible = "allwinner,sun50i-a64-csi",
958+
.data = &sun50i_a64_csi_variant,
959+
},
937960
{},
938961
};
939962

drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ struct sun6i_csi_device {
5858
int planar_offset[3];
5959
};
6060

61+
struct sun6i_csi_variant {
62+
unsigned long clock_mod_rate;
63+
};
64+
6165
/**
6266
* sun6i_csi_is_format_supported() - check if the format supported by csi
6367
* @csi_dev: pointer to the csi device

0 commit comments

Comments
 (0)