From patchwork Sun Apr 24 21:08:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 34024 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1auRIg-0007Bu-Pj; Sun, 24 Apr 2016 21:10:42 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-7) with esmtp id 1auRIe-0000Ec-2V; Sun, 24 Apr 2016 23:10:42 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753318AbcDXVKb (ORCPT + 1 other); Sun, 24 Apr 2016 17:10:31 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35712 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753259AbcDXVK1 (ORCPT ); Sun, 24 Apr 2016 17:10:27 -0400 Received: by mail-wm0-f68.google.com with SMTP id e201so17587391wme.2 for ; Sun, 24 Apr 2016 14:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A4cLQOd8XexNcLU7Cm4uyJTgY+br1FssJ6sIdoUluic=; b=dfG/tcRuvejEsgLO9ihHWquLpHsPR018UcN9JouKFjdTJ3gyIRYbxra38/8cRUAs/p 2MoUeqrdWo7cnEiUxC6DPHYvuk7ia6PynDSQqacjCQsuUM/chz5T4S9iH9pF9tWo7u4o /OgNeHPwXnqdehDC3Nwg2pHiFbxonXdgvRpbTAJ0HL2B6jupabllLMYCFAAisrSVWheA OVVlYbcPzjT9SXG1KmiSGDGJU1szzk+Pr66wqQtU6rBVODqJ/GAUZXUy9otVZl917cB2 b+I5Vf/ax+WGq2TRjyrah1lDm64E55xHctviADm8wh2pvSe2fm1p8diEhtBjqK/w8Hi+ esiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=A4cLQOd8XexNcLU7Cm4uyJTgY+br1FssJ6sIdoUluic=; b=IzbJ0/3VKfe/KOEG9SS/Bf2SGyP3dWjyZHRTqHdVXp6/UuQQHUnkPbVn8nYFE2a1v0 RtcPu+xzRghoWVXWYmAxMUbPynqn4QhkBTy2bPLpuNCn7SEW6eAb5Ay3vGGxvYuvniGR gAjA0zaZmyUcQ+DFQGztYQepoxQwxfWCVUDryGGYfKGRclnmGqAnE8ymMysIO0k0bEwf 5NO03U8JBm0siG3Ewahg6FEJFJtMCXxszaMkIOIMGfHBW6xalvSXa0MNyR2OxtArdZlI S/v1JypuRNnVZ6lViKxJ/YZB3l7xTev9zwCPZwrKbD0AsHfc8jnsdPAe6f4VJ/zLwV30 T6rw== X-Gm-Message-State: AOPr4FXH6993Xs1tvP6TP5K9dzQgQWCpBnB7hmqne1DbObVUJfw8DEr6h6xf3J9ipEGZ/Q== X-Received: by 10.28.214.137 with SMTP id n131mr8402365wmg.33.1461532225987; Sun, 24 Apr 2016 14:10:25 -0700 (PDT) Received: from localhost.localdomain ([46.249.74.23]) by smtp.gmail.com with ESMTPSA id b2sm15440182wmb.9.2016.04.24.14.10.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 14:10:25 -0700 (PDT) From: Ivaylo Dimitrov To: sakari.ailus@iki.fi Cc: sre@kernel.org, pali.rohar@gmail.com, pavel@ucw.cz, linux-media@vger.kernel.org, Ivaylo Dimitrov Subject: [RFC PATCH 13/24] v4l: of: Support CSI-1 and CCP2 busses Date: Mon, 25 Apr 2016 00:08:13 +0300 Message-Id: <1461532104-24032-14-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461532104-24032-1-git-send-email-ivo.g.dimitrov.75@gmail.com> References: <20160420081427.GZ32125@valkosipuli.retiisi.org.uk> <1461532104-24032-1-git-send-email-ivo.g.dimitrov.75@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.4.24.210315 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' FORGED_FROM_GMAIL 0.1, MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, NO_URI_HTTPS 0, REFERENCES 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __DATE_TZ_RU 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __REFERENCES 0, __SANE_MSGID 0, __SINGLE_URI_TEXT 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS , __URI_WITH_PATH 0, __YOUTUBE_RCVD 0' Add support for parsing of CSI-1 and CCP2 bus related properties documented in video-interfaces.txt. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-of.c | 35 +++++++++++++++++++++++++++++++++++ include/media/v4l2-of.h | 17 +++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c index 60bbc5f..5c0d0eb 100644 --- a/drivers/media/v4l2-core/v4l2-of.c +++ b/drivers/media/v4l2-core/v4l2-of.c @@ -23,6 +23,8 @@ enum v4l2_of_bus_type { V4L2_OF_BUS_TYPE_CSI2 = 0, V4L2_OF_BUS_TYPE_PARALLEL, + V4L2_OF_BUS_TYPE_CSI1, + V4L2_OF_BUS_TYPE_CCP2, }; static int v4l2_of_parse_lanes(const struct device_node *node, @@ -163,6 +165,35 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node, } +void v4l2_of_parse_csi1_bus(const struct device_node *node, + struct v4l2_of_endpoint *endpoint, + enum v4l2_of_bus_type bus_type) +{ + struct v4l2_of_bus_mipi_csi1 *bus = &endpoint->bus.mipi_csi1; + u32 v; + + v4l2_of_parse_lanes(node, &bus->clock_lane, NULL, + &bus->data_lane, bus->lane_polarity, + NULL, 1); + + if (!of_property_read_u32(node, "clock-inv", &v)) + bus->clock_inv = v; + + if (!of_property_read_u32(node, "strobe", &v)) + bus->strobe = v; + + if (!of_property_read_u32(node, "data-lane", &v)) + bus->data_lane = v; + + if (!of_property_read_u32(node, "clock-lane", &v)) + bus->clock_lane = v; + + if (bus_type == V4L2_OF_BUS_TYPE_CSI1) + endpoint->bus_type = V4L2_MBUS_CSI1; + else + endpoint->bus_type = V4L2_MBUS_CCP2; +} + /** * v4l2_of_parse_endpoint() - parse all endpoint node properties * @node: pointer to endpoint device_node @@ -216,6 +247,10 @@ int v4l2_of_parse_endpoint(const struct device_node *node, case V4L2_OF_BUS_TYPE_PARALLEL: v4l2_of_parse_parallel_bus(node, endpoint); return 0; + case V4L2_OF_BUS_TYPE_CSI1: + case V4L2_OF_BUS_TYPE_CCP2: + v4l2_of_parse_csi1_bus(node, endpoint, bus_type); + return 0; default: pr_warn("bad bus-type %u, device_node \"%s\"\n", bus_type, node->full_name); diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h index 4dc34b2..63a52ee 100644 --- a/include/media/v4l2-of.h +++ b/include/media/v4l2-of.h @@ -53,6 +53,22 @@ struct v4l2_of_bus_parallel { }; /** + * struct v4l2_of_bus_csi1 - CSI-1/CCP2 data bus structure + * @clock_inv: polarity of clock/strobe signal + * false - not inverted, true - inverted + * @strobe: false - data/clock, true - data/strobe + * @data_lane: the number of the data lane + * @clock_lane: the number of the clock lane + */ +struct v4l2_of_bus_mipi_csi1 { + bool clock_inv; + bool strobe; + bool lane_polarity[2]; + unsigned char data_lane; + unsigned char clock_lane; +}; + +/** * struct v4l2_of_endpoint - the endpoint data structure * @base: struct of_endpoint containing port, id, and local of_node * @bus_type: bus type @@ -66,6 +82,7 @@ struct v4l2_of_endpoint { enum v4l2_mbus_type bus_type; union { struct v4l2_of_bus_parallel parallel; + struct v4l2_of_bus_mipi_csi1 mipi_csi1; struct v4l2_of_bus_mipi_csi2 mipi_csi2; } bus; u64 *link_frequencies;