From patchwork Wed Dec 7 19:31:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 9465119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 047E86022E for ; Wed, 7 Dec 2016 19:35:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7861212D8 for ; Wed, 7 Dec 2016 19:35:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D861528560; Wed, 7 Dec 2016 19:35:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33585212D8 for ; Wed, 7 Dec 2016 19:35:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEhyY-0004yC-RJ; Wed, 07 Dec 2016 19:33:58 +0000 Received: from mail-pg0-x22f.google.com ([2607:f8b0:400e:c05::22f]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEhwj-0003dn-KE for linux-arm-kernel@lists.infradead.org; Wed, 07 Dec 2016 19:32:08 +0000 Received: by mail-pg0-x22f.google.com with SMTP id p66so165095617pga.2 for ; Wed, 07 Dec 2016 11:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=myFCLlfsD+gYuatx7Vz9Qz/p1FeKyBaOT08XngwPAmM=; b=oPDF6cI8liXxPZOVy/8RuwGzwfMKpKXcW2dZUovrS0PovmJSfS2L/fSZWKtFp2Ln3c wHRGdrD58QmyExb6BlqSRyaAT+/BYEQJ6EqqpLkjAUUCLrGdKfC5AK9aX4xxNtf4mfT/ 0KkJ5+tM3XNrujv6rlPAw+KwxvMW5VGNnWC4MgV8YEADGaw2ldDmsGOJoE49Zto7YxnC 4RRnxnxj+d4LBESzKnKRmQYoDilkSWExQ4LiMKROsw0zWLAkN3ALa5wBx2HXKdfVzddG kmNtyxJah5Rm55beZANvKey9wyLhe/cQd/bqZLsBP5BO6kU2AzMMgorDeTQ2pDpxYQr5 g+0w== 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:mime-version:content-transfer-encoding; bh=myFCLlfsD+gYuatx7Vz9Qz/p1FeKyBaOT08XngwPAmM=; b=T5Q6k3JP7k4Aoh81huYQ8F1KdKrq/ZoDa3gpLaG3R1kLu6tOfPx7RxL0rtyLN8fQoZ DylwilhFYmwqWSJJ9bkpEsaFuahQ8Obf7R5EIcNUCMT83v9gN0p07eTYgiMlITibZ1i2 92hMpWvBrwwNgVusUc5jFbsyML5ID2H75WUoYf61rUMtU1+LM43AnEO1Jxpw/mHraG2j X84L3WCXRrSDtgwQhYG7QBUdzffr9QIvdmcEAfgYvPOQItLvip1bAPPZk7HTWDEl5CiI PBL91X3cY5dlvmh8wg3ucVEzvtaC/vw3wOI2BWGrV1rFnNtKsnOaeEBR3U1jlGcpFBi+ FcHQ== X-Gm-Message-State: AKaTC01pIpKuKsn+7WJNLDZ9S7jYIz5grvIB4znveq3nCwa+JMCO+ncol4P2T4OQYEYiFiZe X-Received: by 10.98.83.193 with SMTP id h184mr69001694pfb.175.1481139103905; Wed, 07 Dec 2016 11:31:43 -0800 (PST) Received: from localhost (c-98-203-232-209.hsd1.wa.comcast.net. [98.203.232.209]) by smtp.gmail.com with ESMTPSA id c142sm44504281pfb.23.2016.12.07.11.31.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2016 11:31:43 -0800 (PST) From: Kevin Hilman To: Sekhar Nori Subject: [PATCH v2 3/4] ARM: davinci: da8xx: add pdata-quirks, use for VPIF capture Date: Wed, 7 Dec 2016 11:31:36 -0800 Message-Id: <20161207193137.27947-4-khilman@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161207193137.27947-1-khilman@baylibre.com> References: <20161207193137.27947-1-khilman@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161207_113205_866486_C2F7F7C2 X-CRM114-Status: GOOD ( 19.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Lechner , Axel Haslam , javier@osg.samsung.com, Hans Verkuil , =?UTF-8?q?Bartosz=20Go=C5=82aszewski?= , Sakari Ailus , Alexandre Bailon , Patrick Titiano , linux-arm-kernel@lists.infradead.org, Laurent Pinchart Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add pdata-quirks for da8xx DT platforms, which adds the legacy platform data for vpif_capture driver. Passing legacy platform_data is required until the V4L2 framework, and subdevice drivers (such as the tvp514x) grow a way of selecting input and output routing (c.f. V4L2 s_routing API) Signed-off-by: Kevin Hilman --- arch/arm/mach-davinci/Makefile | 2 +- arch/arm/mach-davinci/da8xx-dt.c | 2 + arch/arm/mach-davinci/include/mach/common.h | 4 + arch/arm/mach-davinci/pdata-quirks.c | 155 ++++++++++++++++++++++++++++ 4 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-davinci/pdata-quirks.c diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile index da4c336b4637..90d2e6e4d913 100644 --- a/arch/arm/mach-davinci/Makefile +++ b/arch/arm/mach-davinci/Makefile @@ -21,7 +21,7 @@ obj-$(CONFIG_AINTC) += irq.o obj-$(CONFIG_CP_INTC) += cp_intc.o # Board specific -obj-$(CONFIG_MACH_DA8XX_DT) += da8xx-dt.o +obj-$(CONFIG_MACH_DA8XX_DT) += da8xx-dt.o pdata-quirks.o obj-$(CONFIG_MACH_DAVINCI_EVM) += board-dm644x-evm.o obj-$(CONFIG_MACH_SFFSDR) += board-sffsdr.o obj-$(CONFIG_MACH_NEUROS_OSD2) += board-neuros-osd2.o diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c index c9f7e9274aa8..69c8099de9f5 100644 --- a/arch/arm/mach-davinci/da8xx-dt.c +++ b/arch/arm/mach-davinci/da8xx-dt.c @@ -38,6 +38,7 @@ static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = { NULL), OF_DEV_AUXDATA("ti,da830-mcasp-audio", 0x01d00000, "davinci-mcasp.0", NULL), OF_DEV_AUXDATA("ti,da850-aemif", 0x68000000, "ti-aemif", NULL), + OF_DEV_AUXDATA("ti,da850-vpif", 0x01e17000, "vpif", NULL), {} }; @@ -46,6 +47,7 @@ static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = { static void __init da850_init_machine(void) { of_platform_default_populate(NULL, da850_auxdata_lookup, NULL); + pdata_quirks_init(); } static const char *const da850_boards_compat[] __initconst = { diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h index 0b3c169758ed..1fd4cd2d1c23 100644 --- a/arch/arm/mach-davinci/include/mach/common.h +++ b/arch/arm/mach-davinci/include/mach/common.h @@ -102,6 +102,10 @@ int davinci_pm_init(void); static inline int davinci_pm_init(void) { return 0; } #endif +#ifdef CONFIG_MACH_DA8XX_DT +extern void __init pdata_quirks_init(void); +#endif + #define SRAM_SIZE SZ_128K #endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */ diff --git a/arch/arm/mach-davinci/pdata-quirks.c b/arch/arm/mach-davinci/pdata-quirks.c new file mode 100644 index 000000000000..a186513edf7e --- /dev/null +++ b/arch/arm/mach-davinci/pdata-quirks.c @@ -0,0 +1,155 @@ +/* + * Legacy platform_data quirks + * + * Copyright (C) 2016 BayLibre, Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include + +#include + +#include +#include +#include + +struct pdata_init { + const char *compatible; + void (*fn)(void); +}; + +#if IS_ENABLED(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) + +#define TVP5147_CH0 "tvp514x-0" +#define TVP5147_CH1 "tvp514x-1" + +/* VPIF capture configuration */ +static struct tvp514x_platform_data tvp5146_pdata = { + .clk_polarity = 0, + .hs_polarity = 1, + .vs_polarity = 1, +}; + +#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL) + +static const struct vpif_input da850_ch0_inputs[] = { + { + .input = { + .index = 0, + .name = "Composite", + .type = V4L2_INPUT_TYPE_CAMERA, + .capabilities = V4L2_IN_CAP_STD, + .std = TVP514X_STD_ALL, + }, + .input_route = INPUT_CVBS_VI2B, + .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC, + .subdev_name = TVP5147_CH0, + }, +}; + +static const struct vpif_input da850_ch1_inputs[] = { + { + .input = { + .index = 0, + .name = "S-Video", + .type = V4L2_INPUT_TYPE_CAMERA, + .capabilities = V4L2_IN_CAP_STD, + .std = TVP514X_STD_ALL, + }, + .input_route = INPUT_SVIDEO_VI2C_VI1C, + .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC, + .subdev_name = TVP5147_CH1, + }, +}; + +static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = { + { + .name = TVP5147_CH0, + .board_info = { + I2C_BOARD_INFO("tvp5146", 0x5d), + .platform_data = &tvp5146_pdata, + }, + }, + { + .name = TVP5147_CH1, + .board_info = { + I2C_BOARD_INFO("tvp5146", 0x5c), + .platform_data = &tvp5146_pdata, + }, + }, +}; + +static struct vpif_capture_config da850_vpif_capture_config = { + .subdev_info = da850_vpif_capture_sdev_info, + .subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info), + .chan_config[0] = { + .inputs = da850_ch0_inputs, + .input_count = ARRAY_SIZE(da850_ch0_inputs), + .vpif_if = { + .if_type = VPIF_IF_BT656, + .hd_pol = 1, + .vd_pol = 1, + .fid_pol = 0, + }, + }, + .chan_config[1] = { + .inputs = da850_ch1_inputs, + .input_count = ARRAY_SIZE(da850_ch1_inputs), + .vpif_if = { + .if_type = VPIF_IF_BT656, + .hd_pol = 1, + .vd_pol = 1, + .fid_pol = 0, + }, + }, + .card_name = "DA850/OMAP-L138 Video Capture", +}; + +static void __init da850_vpif_legacy_init(void) +{ + int ret; + + /* LCDK doesn't have the 2nd TVP514x on CH1 */ + if (of_machine_is_compatible("ti,da850-lcdk")) + da850_vpif_capture_config.subdev_count = 1; + + /* EVM (UI card) uses i2c adapter 1 (not default: zero) */ + if (of_machine_is_compatible("ti,da850-evm")) + da850_vpif_capture_config.i2c_adapter_id = 1; + + ret = da850_register_vpif_capture(&da850_vpif_capture_config); + if (ret) + pr_warn("%s: VPIF capture setup failed: %d\n", + __func__, ret); +} +#endif + +static void pdata_quirks_check(struct pdata_init *quirks) +{ + while (quirks->compatible) { + if (of_machine_is_compatible(quirks->compatible)) { + if (quirks->fn) + quirks->fn(); + break; + } + quirks++; + } +} + +static struct pdata_init pdata_quirks[] __initdata = { +#if IS_ENABLED(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) + { "ti,da850-lcdk", da850_vpif_legacy_init, }, +#if defined(CONFIG_DA850_UI_SD_VIDEO_PORT) + { "ti,da850-evm", da850_vpif_legacy_init, }, +#endif +#endif + { /* sentinel */ }, +}; + +void __init pdata_quirks_init(void) +{ + pdata_quirks_check(pdata_quirks); +}