From patchwork Thu Jan 14 13:30:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8031941 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@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 4E90C9F6FA for ; Thu, 14 Jan 2016 13:30:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B39920426 for ; Thu, 14 Jan 2016 13:30:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 518A220434 for ; Thu, 14 Jan 2016 13:30:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754372AbcANNaf (ORCPT ); Thu, 14 Jan 2016 08:30:35 -0500 Received: from smtp-3.sys.kth.se ([130.237.48.192]:39791 "EHLO smtp-3.sys.kth.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754077AbcANNad (ORCPT ); Thu, 14 Jan 2016 08:30:33 -0500 Received: from smtp-3.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-3.sys.kth.se (Postfix) with ESMTP id A80992B29; Thu, 14 Jan 2016 14:30:31 +0100 (CET) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-3.sys.kth.se ([127.0.0.1]) by smtp-3.sys.kth.se (smtp-3.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id C6KzGQfa4Syv; Thu, 14 Jan 2016 14:30:30 +0100 (CET) X-KTH-Auth: niso [89.233.230.99] X-KTH-mail-from: niklas.soderlund+renesas@ragnatech.se Received: from bismarck.berto.se (dynamic.0.6.79d1f80.14cc20ac3a53.cust.bredband2.com [89.233.230.99]) by smtp-3.sys.kth.se (Postfix) with ESMTPSA id 382382971; Thu, 14 Jan 2016 14:30:30 +0100 (CET) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: linux-sh@vger.kernel.org Cc: laurent.pinchart+renesas@ideasonboard.com, =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [RFC 1/5] [media] rcar-vin: add skeleton Date: Thu, 14 Jan 2016 14:30:12 +0100 Message-Id: <1452778216-31978-2-git-send-email-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1452778216-31978-1-git-send-email-niklas.soderlund+renesas@ragnatech.se> References: <1452778216-31978-1-git-send-email-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 This is the skeleton for a rcar-vin driver that do not depend on soc_camera. --- drivers/media/platform/rcar-vin.c | 149 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 drivers/media/platform/rcar-vin.c diff --git a/drivers/media/platform/rcar-vin.c b/drivers/media/platform/rcar-vin.c new file mode 100644 index 0000000..834ef2c --- /dev/null +++ b/drivers/media/platform/rcar-vin.c @@ -0,0 +1,149 @@ +/* + * Driver for Renesas R-Car VIN unit + * + * Copyright (C) 2016 Renesas Solutions Corp. + * + * Based on SoC-camera Driver for the same device "soc_camera/rcar_vin.c" + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +enum chip_id { + RCAR_GEN2, + RCAR_H1, + RCAR_M1, + RCAR_E1, +}; + +struct rcar_vin { + void __iomem *base; + + struct platform_device *pdev; + struct v4l2_device v4l2_dev; + struct mutex lock; +}; + +static irqreturn_t rcar_vin_irq(int irq, void *dev_id) +{ + /* TODO */ + return IRQ_HANDLED; +} + +/* ----------------------------------------------------------------------------- + * Platform Device Driver + */ + +static int rcar_vin_probe(struct platform_device *pdev) +{ + struct rcar_vin *vin; + struct resource *mem; + int irq, ret; + + /* Allocate a new instance */ + vin = devm_kzalloc(&pdev->dev, sizeof(*vin), GFP_KERNEL); + if (!vin) + return -ENOMEM; + + vin->pdev = pdev; + + /* Enable Device */ + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (mem == NULL) + return -EINVAL; + + vin->base = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(vin->base)) + return PTR_ERR(vin->base); + + /* Allocate the interrupt */ + irq = platform_get_irq(pdev, 0); + if (irq <= 0) + return -EINVAL; + + ret = devm_request_irq(&pdev->dev, irq, + rcar_vin_irq, IRQF_SHARED, KBUILD_MODNAME, vin); + if (ret) { + dev_err(&pdev->dev, "request_irq failed\n"); + goto disable_dev; + + } + + /* Fill in the initial format-related settings */ + /* TODO */ + + /* Initialize the top-level structure */ + ret = v4l2_device_register(&pdev->dev, &vin->v4l2_dev); + if (ret) + goto disable_dev; + + mutex_init(&vin->lock); + + /* Add the controls */ + /* TODO */ + + /* Initialize the vb2 queue */ + /* TODO */ + + /* Initialize the video_device structure */ + /* TODO */ + + platform_set_drvdata(pdev, vin); + + return 0; + +disable_dev: + return ret; +} + +static int rcar_vin_remove(struct platform_device *pdev) +{ + struct rcar_vin *vin = platform_get_drvdata(pdev); + + v4l2_device_unregister(&vin->v4l2_dev); + return 0; +} + +static const struct of_device_id rcar_vin_of_id_table[] = { + { .compatible = "renesas,vin-r8a7794", .data = (void *)RCAR_GEN2 }, + { .compatible = "renesas,vin-r8a7793", .data = (void *)RCAR_GEN2 }, + { .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 }, + { .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 }, + { .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 }, + { .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 }, + { }, +}; +MODULE_DEVICE_TABLE(of, rcar_vin_of_id_table); + +static struct platform_driver rcar_vin_driver = { + .driver = { + .name = "rcar-vin", + .of_match_table = rcar_vin_of_id_table, + }, + .probe = rcar_vin_probe, + .remove = rcar_vin_remove, +}; + +module_platform_driver(rcar_vin_driver); + +MODULE_AUTHOR("Niklas Söderlund "); +MODULE_DESCRIPTION("Renesas R-Car VIN camera host driver"); +MODULE_LICENSE("GPL v2");