From patchwork Sun Apr 24 21:08:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 8921741 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 404C29F1C1 for ; Sun, 24 Apr 2016 21:11:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04D8F201EC for ; Sun, 24 Apr 2016 21:11:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE05B201F2 for ; Sun, 24 Apr 2016 21:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753358AbcDXVKr (ORCPT ); Sun, 24 Apr 2016 17:10:47 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33250 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753336AbcDXVKf (ORCPT ); Sun, 24 Apr 2016 17:10:35 -0400 Received: by mail-wm0-f65.google.com with SMTP id r12so17689153wme.0 for ; Sun, 24 Apr 2016 14:10:34 -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=H4BLPXZwvXmvXLiA9XZ6AEU+W6tXClz9IY/OQ7VTD4I=; b=crrlgzNP7DwDtpJ7aUoWcbWHZXtCwYc3NqwdzpkWvOAPc0YzOdJywZ9jVv9HNyPTxS /zmz/kVWQkZbJd/iNvkptCxQGzxnpFc9DjN8FlwG9ygxn7KuK1i71his0LmUhEGhrSjg uzS0U/UpjyMN67qEYAFmzSqIKM0lHwt2HZs47EVEjNkfMGpmPqCMafENJCPobCYqID/N nQnAPO/FhTcdcoJpyKQBoZ7WwH9dmORFFUBLsErfCIR+3lP/sq2wcwH80rg6O+0CVITs oSLQUwQkuS2QYraw6cjcwIJ8Juo/hJfNVL5oXTx8iughnJCOHdIQ6rtp46JC1KS7QLtP Fbcw== 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=H4BLPXZwvXmvXLiA9XZ6AEU+W6tXClz9IY/OQ7VTD4I=; b=ccX7a4sHLfww4hXGHVml9P+tQ/W/ZqMafLp8JDafroil+C7FQM/mEvl7Vo734/tUvn Yg94QL9uV3JTC+Ll+23trANBRnkVXlutPg5gXp5elbLc04L5G+PHMv8IkN4SMpMsVRQx zhsfFSxlsK8K42gVkFWy6M43U4VUe2yav4VysVFAvOFiB8yc2CqfU41AHHZBo+8CvfVX BNyLErhyEQee9DrKauCOs2KhmojYpU8bCkB3rq62vEn9b+mhH6dpM1woOoBGh4pbo3Wi nOKUeGm31sdduWiW67iCUda0581Wgb4fVZXvku+jyCB4dqtc8P15mvjJUUN+vYhNIS/c l8yw== X-Gm-Message-State: AOPr4FW7XfYERF4fwXjSAZfiIAmebB9z8HOSkm3ugKO/P6PVjADd7z9w0nPcnB5ihDqZHg== X-Received: by 10.28.222.84 with SMTP id v81mr8981047wmg.14.1461532233679; Sun, 24 Apr 2016 14:10:33 -0700 (PDT) Received: from localhost.localdomain ([46.249.74.23]) by smtp.gmail.com with ESMTPSA id b2sm15440182wmb.9.2016.04.24.14.10.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 14:10:33 -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 Subject: [RFC PATCH 21/24] omap3isp: dt: Add support for CSI1/CCP2 busses Date: Mon, 25 Apr 2016 00:08:21 +0300 Message-Id: <1461532104-24032-22-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 From: Sakari Ailus Obtain the CSI1/CCP2 bus parameters from the OF node. Signed-off-by: Sakari Ailus --- drivers/media/platform/omap3isp/isp.c | 110 ++++++++++++++++++++++++---------- 1 file changed, 77 insertions(+), 33 deletions(-) diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 5d54e2c..e51a1f9 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -2020,12 +2020,84 @@ enum isp_of_phy { ISP_OF_PHY_CSIPHY2, }; +static void isp_of_parse_node_csi1(struct device *dev, + struct isp_bus_cfg *buscfg, + struct v4l2_of_endpoint *vep) +{ + if (vep->base.port == ISP_OF_PHY_CSIPHY1) + buscfg->interface = ISP_INTERFACE_CCP2B_PHY1; + else + buscfg->interface = ISP_INTERFACE_CCP2B_PHY2; + buscfg->bus.ccp2.lanecfg.clk.pos = vep->bus.mipi_csi1.clock_lane; + buscfg->bus.ccp2.lanecfg.clk.pol = + vep->bus.mipi_csi1.lane_polarity[0]; + dev_dbg(dev, "clock lane polarity %u, pos %u\n", + buscfg->bus.ccp2.lanecfg.clk.pol, + buscfg->bus.ccp2.lanecfg.clk.pos); + + buscfg->bus.ccp2.lanecfg.data[0].pos = vep->bus.mipi_csi2.data_lanes[0]; + buscfg->bus.ccp2.lanecfg.data[0].pol = + vep->bus.mipi_csi2.lane_polarities[1]; + dev_dbg(dev, "data lane polarity %u, pos %u\n", + buscfg->bus.ccp2.lanecfg.data[0].pol, + buscfg->bus.ccp2.lanecfg.data[0].pos); + + buscfg->bus.ccp2.strobe_clk_pol = vep->bus.mipi_csi1.clock_inv; + buscfg->bus.ccp2.phy_layer = vep->bus.mipi_csi1.strobe; + buscfg->bus.ccp2.ccp2_mode = vep->bus_type == V4L2_MBUS_CCP2; + + dev_dbg(dev, "clock_inv %u strobe %u ccp2 %u\n", + buscfg->bus.ccp2.strobe_clk_pol, + buscfg->bus.ccp2.phy_layer, + buscfg->bus.ccp2.ccp2_mode); + /* + * FIXME: now we assume the CRC is always there. + * Implement a way to obtain this information from the + * sensor. Frame descriptors, perhaps? + */ + buscfg->bus.ccp2.crc = 1; +} + +static void isp_of_parse_node_csi2(struct device *dev, + struct isp_bus_cfg *buscfg, + struct v4l2_of_endpoint *vep) +{ + unsigned int i; + + if (vep->base.port == ISP_OF_PHY_CSIPHY1) + buscfg->interface = ISP_INTERFACE_CSI2C_PHY1; + else + buscfg->interface = ISP_INTERFACE_CSI2A_PHY2; + buscfg->bus.csi2.lanecfg.clk.pos = vep->bus.mipi_csi2.clock_lane; + buscfg->bus.csi2.lanecfg.clk.pol = + vep->bus.mipi_csi2.lane_polarities[0]; + dev_dbg(dev, "clock lane polarity %u, pos %u\n", + buscfg->bus.csi2.lanecfg.clk.pol, + buscfg->bus.csi2.lanecfg.clk.pos); + + for (i = 0; i < ISP_CSIPHY2_NUM_DATA_LANES; i++) { + buscfg->bus.csi2.lanecfg.data[i].pos = + vep->bus.mipi_csi2.data_lanes[i]; + buscfg->bus.csi2.lanecfg.data[i].pol = + vep->bus.mipi_csi2.lane_polarities[i + 1]; + dev_dbg(dev, "data lane %u polarity %u, pos %u\n", i, + buscfg->bus.csi2.lanecfg.data[i].pol, + buscfg->bus.csi2.lanecfg.data[i].pos); + } + + /* + * FIXME: now we assume the CRC is always there. + * Implement a way to obtain this information from the + * sensor. Frame descriptors, perhaps? + */ + buscfg->bus.csi2.crc = 1; +} + static int isp_of_parse_node(struct device *dev, struct device_node *node, struct isp_async_subdev *isd) { struct isp_bus_cfg *buscfg = &isd->bus; struct v4l2_of_endpoint vep; - unsigned int i; int ret; ret = v4l2_of_parse_endpoint(node, &vep); @@ -2055,38 +2127,10 @@ static int isp_of_parse_node(struct device *dev, struct device_node *node, case ISP_OF_PHY_CSIPHY1: case ISP_OF_PHY_CSIPHY2: - /* FIXME: always assume CSI-2 for now. */ - switch (vep.base.port) { - case ISP_OF_PHY_CSIPHY1: - buscfg->interface = ISP_INTERFACE_CSI2C_PHY1; - break; - case ISP_OF_PHY_CSIPHY2: - buscfg->interface = ISP_INTERFACE_CSI2A_PHY2; - break; - } - buscfg->bus.csi2.lanecfg.clk.pos = vep.bus.mipi_csi2.clock_lane; - buscfg->bus.csi2.lanecfg.clk.pol = - vep.bus.mipi_csi2.lane_polarities[0]; - dev_dbg(dev, "clock lane polarity %u, pos %u\n", - buscfg->bus.csi2.lanecfg.clk.pol, - buscfg->bus.csi2.lanecfg.clk.pos); - - for (i = 0; i < ISP_CSIPHY2_NUM_DATA_LANES; i++) { - buscfg->bus.csi2.lanecfg.data[i].pos = - vep.bus.mipi_csi2.data_lanes[i]; - buscfg->bus.csi2.lanecfg.data[i].pol = - vep.bus.mipi_csi2.lane_polarities[i + 1]; - dev_dbg(dev, "data lane %u polarity %u, pos %u\n", i, - buscfg->bus.csi2.lanecfg.data[i].pol, - buscfg->bus.csi2.lanecfg.data[i].pos); - } - - /* - * FIXME: now we assume the CRC is always there. - * Implement a way to obtain this information from the - * sensor. Frame descriptors, perhaps? - */ - buscfg->bus.csi2.crc = 1; + if (vep.bus_type == V4L2_MBUS_CSI2) + isp_of_parse_node_csi2(dev, buscfg, &vep); + else + isp_of_parse_node_csi1(dev, buscfg, &vep); break; default: