Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] sh-mobile-ceu-camera: add primitive OF support

Add an OF hook to sh_mobile_ceu_camera.c, no properties so far. Booting
with DT also requires platform data to be optional.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Guennadi Liakhovetski and committed by
Mauro Carvalho Chehab
f146e4e7 90438926

+23 -10
+23 -10
drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
··· 27 27 #include <linux/kernel.h> 28 28 #include <linux/mm.h> 29 29 #include <linux/moduleparam.h> 30 + #include <linux/of.h> 30 31 #include <linux/time.h> 31 32 #include <linux/slab.h> 32 33 #include <linux/device.h> ··· 119 118 120 119 enum v4l2_field field; 121 120 int sequence; 121 + unsigned long flags; 122 122 123 123 unsigned int image_mode:1; 124 124 unsigned int is_16bit:1; ··· 708 706 } 709 707 710 708 /* CSI2 special configuration */ 711 - if (pcdev->pdata->csi2) { 709 + if (pcdev->csi2_pdev) { 712 710 in_width = ((in_width - 2) * 2); 713 711 left_offset *= 2; 714 712 } ··· 812 810 /* Make choises, based on platform preferences */ 813 811 if ((common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) && 814 812 (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) { 815 - if (pcdev->pdata->flags & SH_CEU_FLAG_HSYNC_LOW) 813 + if (pcdev->flags & SH_CEU_FLAG_HSYNC_LOW) 816 814 common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH; 817 815 else 818 816 common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW; ··· 820 818 821 819 if ((common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) && 822 820 (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) { 823 - if (pcdev->pdata->flags & SH_CEU_FLAG_VSYNC_LOW) 821 + if (pcdev->flags & SH_CEU_FLAG_VSYNC_LOW) 824 822 common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_HIGH; 825 823 else 826 824 common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW; ··· 875 873 value |= common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW ? 1 << 1 : 0; 876 874 value |= common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW ? 1 << 0 : 0; 877 875 878 - if (pcdev->pdata->csi2) /* CSI2 mode */ 876 + if (pcdev->csi2_pdev) /* CSI2 mode */ 879 877 value |= 3 << 12; 880 878 else if (pcdev->is_16bit) 881 879 value |= 1 << 12; 882 - else if (pcdev->pdata->flags & SH_CEU_FLAG_LOWER_8BIT) 880 + else if (pcdev->flags & SH_CEU_FLAG_LOWER_8BIT) 883 881 value |= 2 << 12; 884 882 885 883 ceu_write(pcdev, CAMCR, value); ··· 1054 1052 return 0; 1055 1053 } 1056 1054 1057 - if (!pcdev->pdata->csi2) { 1055 + if (!pcdev->pdata || !pcdev->pdata->csi2) { 1058 1056 /* Are there any restrictions in the CSI-2 case? */ 1059 1057 ret = sh_mobile_ceu_try_bus_param(icd, fmt->bits_per_sample); 1060 1058 if (ret < 0) ··· 2109 2107 init_completion(&pcdev->complete); 2110 2108 2111 2109 pcdev->pdata = pdev->dev.platform_data; 2112 - if (!pcdev->pdata) { 2110 + if (!pcdev->pdata && !pdev->dev.of_node) { 2113 2111 dev_err(&pdev->dev, "CEU platform data not set.\n"); 2114 2112 return -EINVAL; 2115 2113 } 2116 2114 2117 - pcdev->max_width = pcdev->pdata->max_width ? : 2560; 2118 - pcdev->max_height = pcdev->pdata->max_height ? : 1920; 2115 + /* TODO: implement per-device bus flags */ 2116 + if (pcdev->pdata) { 2117 + pcdev->max_width = pcdev->pdata->max_width ? : 2560; 2118 + pcdev->max_height = pcdev->pdata->max_height ? : 1920; 2119 + pcdev->flags = pcdev->pdata->flags; 2120 + } 2119 2121 2120 2122 base = devm_ioremap_resource(&pdev->dev, res); 2121 2123 if (IS_ERR(base)) ··· 2174 2168 goto exit_free_ctx; 2175 2169 2176 2170 /* CSI2 interfacing */ 2177 - csi2 = pcdev->pdata->csi2; 2171 + csi2 = pcdev->pdata ? pcdev->pdata->csi2 : NULL; 2178 2172 if (csi2) { 2179 2173 struct platform_device *csi2_pdev = 2180 2174 platform_device_alloc("sh-mobile-csi2", csi2->id); ··· 2296 2290 .runtime_resume = sh_mobile_ceu_runtime_nop, 2297 2291 }; 2298 2292 2293 + static const struct of_device_id sh_mobile_ceu_of_match[] = { 2294 + { .compatible = "renesas,sh-mobile-ceu" }, 2295 + { } 2296 + }; 2297 + MODULE_DEVICE_TABLE(of, sh_mobile_ceu_of_match); 2298 + 2299 2299 static struct platform_driver sh_mobile_ceu_driver = { 2300 2300 .driver = { 2301 2301 .name = "sh_mobile_ceu", 2302 2302 .pm = &sh_mobile_ceu_dev_pm_ops, 2303 + .of_match_table = sh_mobile_ceu_of_match, 2303 2304 }, 2304 2305 .probe = sh_mobile_ceu_probe, 2305 2306 .remove = sh_mobile_ceu_remove,