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

[media] media: atmel-isi: add primary DT support

This patch add the DT support for Atmel ISI driver.
It use the same v4l2 DT interface that defined in video-interfaces.txt.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Cc: devicetree@vger.kernel.org
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Josh Wu and committed by
Mauro Carvalho Chehab
8ff19bc4 833e1063

+114 -2
+51
Documentation/devicetree/bindings/media/atmel-isi.txt
··· 1 + Atmel Image Sensor Interface (ISI) SoC Camera Subsystem 2 + ---------------------------------------------- 3 + 4 + Required properties: 5 + - compatible: must be "atmel,at91sam9g45-isi" 6 + - reg: physical base address and length of the registers set for the device; 7 + - interrupts: should contain IRQ line for the ISI; 8 + - clocks: list of clock specifiers, corresponding to entries in 9 + the clock-names property; 10 + - clock-names: must contain "isi_clk", which is the isi peripherial clock. 11 + 12 + ISI supports a single port node with parallel bus. It should contain one 13 + 'port' child node with child 'endpoint' node. Please refer to the bindings 14 + defined in Documentation/devicetree/bindings/media/video-interfaces.txt. 15 + 16 + Example: 17 + isi: isi@f0034000 { 18 + compatible = "atmel,at91sam9g45-isi"; 19 + reg = <0xf0034000 0x4000>; 20 + interrupts = <37 IRQ_TYPE_LEVEL_HIGH 5>; 21 + 22 + clocks = <&isi_clk>; 23 + clock-names = "isi_clk"; 24 + 25 + pinctrl-names = "default"; 26 + pinctrl-0 = <&pinctrl_isi>; 27 + 28 + port { 29 + #address-cells = <1>; 30 + #size-cells = <0>; 31 + 32 + isi_0: endpoint { 33 + remote-endpoint = <&ov2640_0>; 34 + bus-width = <8>; 35 + }; 36 + }; 37 + }; 38 + 39 + i2c1: i2c@f0018000 { 40 + ov2640: camera@0x30 { 41 + compatible = "omnivision,ov2640"; 42 + reg = <0x30>; 43 + 44 + port { 45 + ov2640_0: endpoint { 46 + remote-endpoint = <&isi_0>; 47 + bus-width = <8>; 48 + }; 49 + }; 50 + }; 51 + };
+63 -2
drivers/media/platform/soc_camera/atmel-isi.c
··· 25 25 #include <media/atmel-isi.h> 26 26 #include <media/soc_camera.h> 27 27 #include <media/soc_mediabus.h> 28 + #include <media/v4l2-of.h> 28 29 #include <media/videobuf2-dma-contig.h> 29 30 30 31 #define MAX_BUFFER_NUM 32 ··· 34 33 #define VID_LIMIT_BYTES (16 * 1024 * 1024) 35 34 #define MIN_FRAME_RATE 15 36 35 #define FRAME_INTERVAL_MILLI_SEC (1000 / MIN_FRAME_RATE) 36 + #define ISI_DEFAULT_MCLK_FREQ 25000000 37 37 38 38 /* Frame buffer descriptor */ 39 39 struct fbd { ··· 878 876 return 0; 879 877 } 880 878 879 + static int atmel_isi_probe_dt(struct atmel_isi *isi, 880 + struct platform_device *pdev) 881 + { 882 + struct device_node *np= pdev->dev.of_node; 883 + struct v4l2_of_endpoint ep; 884 + int err; 885 + 886 + /* Default settings for ISI */ 887 + isi->pdata.full_mode = 1; 888 + isi->pdata.mck_hz = ISI_DEFAULT_MCLK_FREQ; 889 + isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL; 890 + 891 + np = of_graph_get_next_endpoint(np, NULL); 892 + if (!np) { 893 + dev_err(&pdev->dev, "Could not find the endpoint\n"); 894 + return -EINVAL; 895 + } 896 + 897 + err = v4l2_of_parse_endpoint(np, &ep); 898 + if (err) { 899 + dev_err(&pdev->dev, "Could not parse the endpoint\n"); 900 + goto err_probe_dt; 901 + } 902 + 903 + switch (ep.bus.parallel.bus_width) { 904 + case 8: 905 + isi->pdata.data_width_flags = ISI_DATAWIDTH_8; 906 + break; 907 + case 10: 908 + isi->pdata.data_width_flags = 909 + ISI_DATAWIDTH_8 | ISI_DATAWIDTH_10; 910 + break; 911 + default: 912 + dev_err(&pdev->dev, "Unsupported bus width: %d\n", 913 + ep.bus.parallel.bus_width); 914 + err = -EINVAL; 915 + goto err_probe_dt; 916 + } 917 + 918 + err_probe_dt: 919 + of_node_put(np); 920 + 921 + return err; 922 + } 923 + 881 924 static int atmel_isi_probe(struct platform_device *pdev) 882 925 { 883 926 unsigned int irq; ··· 934 887 struct isi_platform_data *pdata; 935 888 936 889 pdata = dev->platform_data; 937 - if (!pdata || !pdata->data_width_flags) { 890 + if ((!pdata || !pdata->data_width_flags) && !pdev->dev.of_node) { 938 891 dev_err(&pdev->dev, 939 892 "No config available for Atmel ISI\n"); 940 893 return -EINVAL; ··· 950 903 if (IS_ERR(isi->pclk)) 951 904 return PTR_ERR(isi->pclk); 952 905 953 - memcpy(&isi->pdata, pdata, sizeof(isi->pdata)); 906 + if (pdata) { 907 + memcpy(&isi->pdata, pdata, sizeof(isi->pdata)); 908 + } else { 909 + ret = atmel_isi_probe_dt(isi, pdev); 910 + if (ret) 911 + return ret; 912 + } 913 + 954 914 isi->active = NULL; 955 915 spin_lock_init(&isi->lock); 956 916 INIT_LIST_HEAD(&isi->video_buffer_list); ··· 1059 1005 return ret; 1060 1006 } 1061 1007 1008 + static const struct of_device_id atmel_isi_of_match[] = { 1009 + { .compatible = "atmel,at91sam9g45-isi" }, 1010 + { } 1011 + }; 1012 + MODULE_DEVICE_TABLE(of, atmel_isi_of_match); 1013 + 1062 1014 static struct platform_driver atmel_isi_driver = { 1063 1015 .remove = atmel_isi_remove, 1064 1016 .driver = { 1065 1017 .name = "atmel_isi", 1066 1018 .owner = THIS_MODULE, 1019 + .of_match_table = of_match_ptr(atmel_isi_of_match), 1067 1020 }, 1068 1021 }; 1069 1022