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: 8921611 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B05EDBF440 for ; Sun, 24 Apr 2016 21:10:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C1562201E4 for ; Sun, 24 Apr 2016 21:10:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF2492022D for ; Sun, 24 Apr 2016 21:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753318AbcDXVKb (ORCPT ); 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-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;