From patchwork Thu Aug 23 11:49:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Jourdan X-Patchwork-Id: 10573761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 937D6921 for ; Thu, 23 Aug 2018 12:01:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 823E32BDCF for ; Thu, 23 Aug 2018 12:01:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7658E2BDF5; Thu, 23 Aug 2018 12:01:02 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE2392BDCF for ; Thu, 23 Aug 2018 12:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ZVDl8MewsRAZKA2LtAhWcBlV0s6nDyjlT0KF8mtazyA=; b=r4S06O9yXE7dnktcNzULnFNnCh I+w1AX37gtTo/lYCtgUwpITdK+RwVzGd8SDC7p5ZaAm4zojPQDtyYN4kavgsd09Os+56VWPwnDCeV VTgdxzAjnYKSYVzilej6zRR3ZShfCefI1DEMp7zsi4emWsJzaJthVGTXZLSGwG1OKiT8IQUqOlgNm Nye/h+e1yPNwsqYZp/UrerTMjYFqaMomQZHHfUekWc1Lwtap05gWczxOpSVNPRbpqQyKnYolT844r 0BfgmboWveFUIHg+Qk0EUXSav4dYusWSlmJixZbo0NEwKEdJ1kEraPCe8MBMqmy/9IuEWpg0FQsJ6 7GVNW5tw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsoIO-0006Jv-3W; Thu, 23 Aug 2018 12:01:00 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsoIK-0006GW-81 for linux-amlogic@lists.infradead.org; Thu, 23 Aug 2018 12:00:58 +0000 Received: by mail-wr1-x441.google.com with SMTP id m27-v6so4423493wrf.3 for ; Thu, 23 Aug 2018 05:00:46 -0700 (PDT) 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; bh=ooE/rkkGa8uBIKT5dxhX97Hba4/zd5ds4uMb7/j7SJc=; b=XUiJLkybbVMSLQJd8RsuZ0Jb6ZmYnYb1osK7qVJEQNwfGmlduUpr1X4uIQ04rXIqSA j1xun2ZnVNjhwrWJY3AA5TLBk/GiE5l5KhMV4T+hz9dgfUeak8zyNnONkmQe62ul9wfg 5kbXBTTN5JepJ9P4kkGljFWx3ysRajwpFPWNcxe8i16n85pP9+Ck28hEGj5nle3nYk5A LPyUkHeA9TwbGR5Rzjw+7f4q8c9LTRcLxlojawxfW1V0Hz/C9OnQAwtSlo2XoptYLJyP nWbJWEzEYnB5Y1UtBXCPJM7s+fvf5A/S4mB1VOSC00vwMkCRnlXr0N2fjYaXjpekjbOq c2yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ooE/rkkGa8uBIKT5dxhX97Hba4/zd5ds4uMb7/j7SJc=; b=PA6qF4ysJykRFJURhqhWoCvSOT/9FKCCiH9Vbt4+/I/F6NrVVS3yExwZsU3wxuUKcL EgA/GQnwNxn8D5nQTwsk80EgbBfj5fYtkxyOtL0M+Qwj4GPDx4XBmnfG40VuKdncNapi cXrt3/Qr8YSb7MRce1k6mQpBmetsZzbeBl+ooI6r7K6XOnL6Xq4B4KAA5PDHJbGv63xK Ffdz3CgyTd6Z2YuBL2PtQ55x2fI8seNiz9FaP0PGEPisgbiCIduduYUVCxGrkldebI8t mRbY9224UxAh9IKCFWmN5RV83xngIESfb/CNIH4OQZO5FHI07SqL7DgJdieSECMT8HK/ IYZw== X-Gm-Message-State: AOUpUlGaCMK0tu0hiidtyeym1peHAkR81WRgZ75Aw59lvXqpN/kiE99I 4AzTCbBkDpvsSqLoQ84s6YvAUV5vm/c= X-Google-Smtp-Source: AA+uWPx4fhoRuT502dF3E53cCuB/y7UMgew04mgF6FMdXMN+lz81BI4PTK+Dxu1OX7eiNhOVmMQ2TQ== X-Received: by 2002:adf:f410:: with SMTP id g16-v6mr37555121wro.256.1535025645513; Thu, 23 Aug 2018 05:00:45 -0700 (PDT) Received: from localhost.localdomain (81-67-76-113.rev.numericable.fr. [81.67.76.113]) by smtp.gmail.com with ESMTPSA id y10-v6sm2830419wrl.87.2018.08.23.05.00.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 05:00:44 -0700 (PDT) From: Maxime Jourdan To: Kevin Hilman Subject: [PATCH v3 1/3] dt-bindings: soc: amlogic: add meson-canvas documentation Date: Thu, 23 Aug 2018 13:49:52 +0200 Message-Id: <20180823114954.30704-2-mjourdan@baylibre.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823114954.30704-1-mjourdan@baylibre.com> References: <20180823114954.30704-1-mjourdan@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180823_050056_290824_94192374 X-CRM114-Status: GOOD ( 10.68 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Jourdan , devicetree@vger.kernel.org, Neil Armstrong , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP DT bindings doc for amlogic,meson-canvas Reviewed-by: Jerome Brunet Signed-off-by: Maxime Jourdan Reviewed-by: Rob Herring --- .../bindings/soc/amlogic/amlogic,canvas.txt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/amlogic/amlogic,canvas.txt diff --git a/Documentation/devicetree/bindings/soc/amlogic/amlogic,canvas.txt b/Documentation/devicetree/bindings/soc/amlogic/amlogic,canvas.txt new file mode 100644 index 000000000000..436d2106e80d --- /dev/null +++ b/Documentation/devicetree/bindings/soc/amlogic/amlogic,canvas.txt @@ -0,0 +1,29 @@ +Amlogic Canvas +================================ + +A canvas is a collection of metadata that describes a pixel buffer. +Those metadata include: width, height, phyaddr, wrapping, block mode +and endianness. + +Many IPs within Amlogic SoCs rely on canvas indexes to read/write pixel data +rather than use the phy addresses directly. For instance, this is the case for +the video decoders and the display. + +Amlogic SoCs have 256 canvas. + +Device Tree Bindings: +--------------------- + +Video Lookup Table +-------------------------- + +Required properties: +- compatible: "amlogic,canvas" +- reg: Base physical address and size of the canvas registers. + +Example: + +canvas: video-lut@48 { + compatible = "amlogic,canvas"; + reg = <0x0 0x48 0x0 0x14>; +}; From patchwork Thu Aug 23 11:49:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Jourdan X-Patchwork-Id: 10573769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5D4214E1 for ; Thu, 23 Aug 2018 12:01:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93BF82BBE8 for ; Thu, 23 Aug 2018 12:01:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87E532BDCF; Thu, 23 Aug 2018 12:01:24 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D6EFC2BDD4 for ; Thu, 23 Aug 2018 12:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=m4TP5qy5sZdzmTiOUc1FVuxS997zZ9H23PdxP5NUjCk=; b=hya+0gRya9Lfdto1YD77M56GaH 5UYaK+PRT6rh5+3+qbIXNPkiPsp+yg/ioUrd7SWyDkCj+EVUj10u4hgpgT1DOSNCAIfq1Wgi/m/rD WTfi942phyhY5ujemzKt4euXNDpjlKO4qN+8RFHLHNSD2mw3XTDklPpCh3QdYVVAsTc/+pgfv88Vb NJ7YRYyelJ2ucFgrLHxuaB2lHfpSu9hYZRtZI0WOMqVYlpGXLXUAyp0VDMvvSa2xzKFDh183+lw4E fqcANT5+PscKSdtZTaHjnE48xqfeghG/xneDEC9XkLzO4f+KExKqqJyM84Fc+vREey5cX+R3Vk77c DT8MOwkw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsoIk-0006tN-3F; Thu, 23 Aug 2018 12:01:22 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsoIM-0006Gb-Nl for linux-amlogic@lists.infradead.org; Thu, 23 Aug 2018 12:01:00 +0000 Received: by mail-wm0-x243.google.com with SMTP id n11-v6so5531121wmc.2 for ; Thu, 23 Aug 2018 05:00:48 -0700 (PDT) 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; bh=J14rIL1Ra2+GuM0kzPhpPPGaX1+GE9iEc/QEOXMrQeE=; b=PDzR6lXEZ39fYlMPLqXYb9fWwhF649WVVHsw7ssUSZsi92mlO5fPJJN37FG9yMZCCB /OOG1GxQW2sWSgajziNtsKDccV5mFE88paGDQ4RfyDZnWW8dkSgD3idRFFxLASUq3JSp oPDUmspfx7c1rBhW/m1AoIB7O53CLkqYPnq73GxHqVG+N3YXWAEk/XOuW0qQg0dNgBi7 BM81HRH6ubDBkpCnOrvRtG4W6RgEbSOfD5wQlPqLlBQwKDnuNg1Wquhb9vKIO8BVWPAl BDhK/lnvol/NuQPAwL6Bg4vkqIA1KxaxnJwtwGLbeRdo0fFm4HCqkkeKheNw17NUSPfT 3j4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=J14rIL1Ra2+GuM0kzPhpPPGaX1+GE9iEc/QEOXMrQeE=; b=saP0/K28JULcW8m/OW8N7HMX1la8QrYKNCk3d31lYoKv9/9QduzDNR4mu6xrvRAAbn ggLn3fNt2+DZUN3bHnOX+UvRjKGuU2M7b9oB6WkpgtyhIysiowCvTVL9s184QlZD78ku iNJtqWWTynrJGqYTtnhWp95r6PTm812BpJRniWpive2fa1TXAljxc/Ml74WV/Yz8vpEG b1/FFFESA+iApOCjIS+UyEI+jdiclBe1xmfcbdkdA10o62hhHuoXLdDDa0pLKbb5kbyv X9zlcPEcJ+qudIDBElSiLX1qJy1uejhx8xk+62wQubAhHL1w02sqZFJ8Bvq6wpGoR/O7 5ZYA== X-Gm-Message-State: APzg51Ch0V0ugfn1DNNUMCDKZhn9Jzy5fRtTzlqJsZj4OK6vGt42eB4/ QMsUPwmZHWvnKKRLbN51JWxqwg== X-Google-Smtp-Source: ANB0VdYQoyncAaM6fFOXphHsOQvc+i4tYazkX3wH97gcv7J7k6vC0M8eCS9rZwjOsPu6QeLcbbwiug== X-Received: by 2002:a1c:9cd3:: with SMTP id f202-v6mr5012038wme.148.1535025646948; Thu, 23 Aug 2018 05:00:46 -0700 (PDT) Received: from localhost.localdomain (81-67-76-113.rev.numericable.fr. [81.67.76.113]) by smtp.gmail.com with ESMTPSA id y10-v6sm2830419wrl.87.2018.08.23.05.00.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 05:00:46 -0700 (PDT) From: Maxime Jourdan To: Kevin Hilman Subject: [PATCH v3 2/3] soc: amlogic: add meson-canvas driver Date: Thu, 23 Aug 2018 13:49:53 +0200 Message-Id: <20180823114954.30704-3-mjourdan@baylibre.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823114954.30704-1-mjourdan@baylibre.com> References: <20180823114954.30704-1-mjourdan@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180823_050058_858930_5784501F X-CRM114-Status: GOOD ( 18.96 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Jourdan , Neil Armstrong , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Amlogic SoCs have a repository of 256 canvas which they use to describe pixel buffers. They contain metadata like width, height, block mode, endianness [..] Many IPs within those SoCs like vdec/vpu rely on those canvas to read/write pixels. Reviewed-by: Jerome Brunet Tested-by: Neil Armstrong Signed-off-by: Maxime Jourdan --- drivers/soc/amlogic/Kconfig | 7 + drivers/soc/amlogic/Makefile | 1 + drivers/soc/amlogic/meson-canvas.c | 185 +++++++++++++++++++++++ include/linux/soc/amlogic/meson-canvas.h | 65 ++++++++ 4 files changed, 258 insertions(+) create mode 100644 drivers/soc/amlogic/meson-canvas.c create mode 100644 include/linux/soc/amlogic/meson-canvas.h diff --git a/drivers/soc/amlogic/Kconfig b/drivers/soc/amlogic/Kconfig index b04f6e4aedbc..2f282b472912 100644 --- a/drivers/soc/amlogic/Kconfig +++ b/drivers/soc/amlogic/Kconfig @@ -1,5 +1,12 @@ menu "Amlogic SoC drivers" +config MESON_CANVAS + tristate "Amlogic Meson Canvas driver" + depends on ARCH_MESON || COMPILE_TEST + default n + help + Say yes to support the canvas IP for Amlogic SoCs. + config MESON_GX_SOCINFO bool "Amlogic Meson GX SoC Information driver" depends on ARCH_MESON || COMPILE_TEST diff --git a/drivers/soc/amlogic/Makefile b/drivers/soc/amlogic/Makefile index 8fa321893928..0ab16d35ac36 100644 --- a/drivers/soc/amlogic/Makefile +++ b/drivers/soc/amlogic/Makefile @@ -1,3 +1,4 @@ +obj-$(CONFIG_MESON_CANVAS) += meson-canvas.o obj-$(CONFIG_MESON_GX_SOCINFO) += meson-gx-socinfo.o obj-$(CONFIG_MESON_GX_PM_DOMAINS) += meson-gx-pwrc-vpu.o obj-$(CONFIG_MESON_MX_SOCINFO) += meson-mx-socinfo.o diff --git a/drivers/soc/amlogic/meson-canvas.c b/drivers/soc/amlogic/meson-canvas.c new file mode 100644 index 000000000000..fce33ca76bb6 --- /dev/null +++ b/drivers/soc/amlogic/meson-canvas.c @@ -0,0 +1,185 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 BayLibre, SAS + * Copyright (C) 2015 Amlogic, Inc. All rights reserved. + * Copyright (C) 2014 Endless Mobile + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define NUM_CANVAS 256 + +/* DMC Registers */ +#define DMC_CAV_LUT_DATAL 0x00 + #define CANVAS_WIDTH_LBIT 29 + #define CANVAS_WIDTH_LWID 3 +#define DMC_CAV_LUT_DATAH 0x04 + #define CANVAS_WIDTH_HBIT 0 + #define CANVAS_HEIGHT_BIT 9 + #define CANVAS_WRAP_BIT 22 + #define CANVAS_BLKMODE_BIT 24 + #define CANVAS_ENDIAN_BIT 26 +#define DMC_CAV_LUT_ADDR 0x08 + #define CANVAS_LUT_WR_EN BIT(9) + #define CANVAS_LUT_RD_EN BIT(8) + +struct meson_canvas { + struct device *dev; + void __iomem *reg_base; + spinlock_t lock; /* canvas device lock */ + u8 used[NUM_CANVAS]; +}; + +static void canvas_write(struct meson_canvas *canvas, u32 reg, u32 val) +{ + writel_relaxed(val, canvas->reg_base + reg); +} + +static u32 canvas_read(struct meson_canvas *canvas, u32 reg) +{ + return readl_relaxed(canvas->reg_base + reg); +} + +struct meson_canvas *meson_canvas_get(struct device *dev) +{ + struct device_node *canvas_node; + struct platform_device *canvas_pdev; + + canvas_node = of_parse_phandle(dev->of_node, "amlogic,canvas", 0); + if (!canvas_node) + return ERR_PTR(-ENODEV); + + canvas_pdev = of_find_device_by_node(canvas_node); + if (!canvas_pdev) + return ERR_PTR(-EPROBE_DEFER); + + return dev_get_drvdata(&canvas_pdev->dev); +} +EXPORT_SYMBOL_GPL(meson_canvas_get); + +int meson_canvas_config(struct meson_canvas *canvas, u8 canvas_index, + u32 addr, u32 stride, u32 height, + unsigned int wrap, + unsigned int blkmode, + unsigned int endian) +{ + unsigned long flags; + + spin_lock_irqsave(&canvas->lock, flags); + if (!canvas->used[canvas_index]) { + dev_err(canvas->dev, + "Trying to setup non allocated canvas %u\n", + canvas_index); + spin_unlock_irqrestore(&canvas->lock, flags); + return -EINVAL; + } + + canvas_write(canvas, DMC_CAV_LUT_DATAL, + ((addr + 7) >> 3) | + (((stride + 7) >> 3) << CANVAS_WIDTH_LBIT)); + + canvas_write(canvas, DMC_CAV_LUT_DATAH, + ((((stride + 7) >> 3) >> CANVAS_WIDTH_LWID) << + CANVAS_WIDTH_HBIT) | + (height << CANVAS_HEIGHT_BIT) | + (wrap << CANVAS_WRAP_BIT) | + (blkmode << CANVAS_BLKMODE_BIT) | + (endian << CANVAS_ENDIAN_BIT)); + + canvas_write(canvas, DMC_CAV_LUT_ADDR, + CANVAS_LUT_WR_EN | canvas_index); + + /* Force a read-back to make sure everything is flushed. */ + canvas_read(canvas, DMC_CAV_LUT_DATAH); + spin_unlock_irqrestore(&canvas->lock, flags); + + return 0; +} +EXPORT_SYMBOL_GPL(meson_canvas_config); + +int meson_canvas_alloc(struct meson_canvas *canvas, u8 *canvas_index) +{ + int i; + unsigned long flags; + + spin_lock_irqsave(&canvas->lock, flags); + for (i = 0; i < NUM_CANVAS; ++i) { + if (!canvas->used[i]) { + canvas->used[i] = 1; + spin_unlock_irqrestore(&canvas->lock, flags); + *canvas_index = i; + return 0; + } + } + spin_unlock_irqrestore(&canvas->lock, flags); + + dev_err(canvas->dev, "No more canvas available\n"); + return -ENODEV; +} +EXPORT_SYMBOL_GPL(meson_canvas_alloc); + +int meson_canvas_free(struct meson_canvas *canvas, u8 canvas_index) +{ + unsigned long flags; + + spin_lock_irqsave(&canvas->lock, flags); + if (!canvas->used[canvas_index]) { + dev_err(canvas->dev, + "Trying to free unused canvas %u\n", canvas_index); + spin_unlock_irqrestore(&canvas->lock, flags); + return -EINVAL; + } + canvas->used[canvas_index] = 0; + spin_unlock_irqrestore(&canvas->lock, flags); + + return 0; +} +EXPORT_SYMBOL_GPL(meson_canvas_free); + +static int meson_canvas_probe(struct platform_device *pdev) +{ + struct resource *res; + struct meson_canvas *canvas; + struct device *dev = &pdev->dev; + + canvas = devm_kzalloc(dev, sizeof(*canvas), GFP_KERNEL); + if (!canvas) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + canvas->reg_base = devm_ioremap_resource(dev, res); + if (IS_ERR(canvas->reg_base)) + return PTR_ERR(canvas->reg_base); + + canvas->dev = dev; + spin_lock_init(&canvas->lock); + dev_set_drvdata(dev, canvas); + + return 0; +} + +static const struct of_device_id canvas_dt_match[] = { + { .compatible = "amlogic,canvas" }, + {} +}; +MODULE_DEVICE_TABLE(of, canvas_dt_match); + +static struct platform_driver meson_canvas_driver = { + .probe = meson_canvas_probe, + .driver = { + .name = "amlogic-canvas", + .of_match_table = canvas_dt_match, + }, +}; +module_platform_driver(meson_canvas_driver); + +MODULE_DESCRIPTION("Amlogic Canvas driver"); +MODULE_AUTHOR("Maxime Jourdan "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/soc/amlogic/meson-canvas.h b/include/linux/soc/amlogic/meson-canvas.h new file mode 100644 index 000000000000..3dcfdabbef74 --- /dev/null +++ b/include/linux/soc/amlogic/meson-canvas.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2018 BayLibre, SAS + */ +#ifndef __SOC_MESON_CANVAS_H +#define __SOC_MESON_CANVAS_H + +#include + +#define MESON_CANVAS_WRAP_NONE 0x00 +#define MESON_CANVAS_WRAP_X 0x01 +#define MESON_CANVAS_WRAP_Y 0x02 + +#define MESON_CANVAS_BLKMODE_LINEAR 0x00 +#define MESON_CANVAS_BLKMODE_32x32 0x01 +#define MESON_CANVAS_BLKMODE_64x64 0x02 + +#define MESON_CANVAS_ENDIAN_SWAP16 0x1 +#define MESON_CANVAS_ENDIAN_SWAP32 0x3 +#define MESON_CANVAS_ENDIAN_SWAP64 0x7 +#define MESON_CANVAS_ENDIAN_SWAP128 0xf + +struct meson_canvas; + +/** + * meson_canvas_get() - get a canvas provider instance + * + * @dev: consumer device pointer + */ +struct meson_canvas *meson_canvas_get(struct device *dev); + +/** + * meson_canvas_alloc() - take ownership of a canvas + * + * @canvas: canvas provider instance retrieved from meson_canvas_get() + * @canvas_index: will be filled with the canvas ID + */ +int meson_canvas_alloc(struct meson_canvas *canvas, u8 *canvas_index); + +/** + * meson_canvas_free() - remove ownership from a canvas + * + * @canvas: canvas provider instance retrieved from meson_canvas_get() + * @canvas_index: canvas ID that was obtained via meson_canvas_alloc() + */ +int meson_canvas_free(struct meson_canvas *canvas, u8 canvas_index); + +/** + * meson_canvas_config() - configure a canvas + * + * @canvas: canvas provider instance retrieved from meson_canvas_get() + * @canvas_index: canvas ID that was obtained via meson_canvas_alloc() + * @addr: physical address to the pixel buffer + * @stride: width of the buffer + * @height: height of the buffer + * @wrap: undocumented + * @blkmode: block mode (linear, 32x32, 64x64) + * @endian: byte swapping (swap16, swap32, swap64, swap128) + */ +int meson_canvas_config(struct meson_canvas *canvas, u8 canvas_index, + u32 addr, u32 stride, u32 height, + unsigned int wrap, unsigned int blkmode, + unsigned int endian); + +#endif From patchwork Thu Aug 23 11:49:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Jourdan X-Patchwork-Id: 10573767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BB37920 for ; Thu, 23 Aug 2018 12:01:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69C992BCE1 for ; Thu, 23 Aug 2018 12:01:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DBA92BDC0; Thu, 23 Aug 2018 12:01:22 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 48EEA2BE1E for ; Thu, 23 Aug 2018 12:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=XSVp5Ms/iJO97JJEDx3z5TCGNgETfyrW9tzGqQRvCs4=; b=pgAm57wtvymjqsgRl68GjEYZ91 tXypYj96ixyy1tCHR3hWsnXB5jzuIVbTSXmuV1WsNBrk/SxdhtRSOPmKGmo3e/98ocAMjoOHbjYGS qMdrfEn3G28s8OhVYOQVQ/0XUot6BGD1TTxQgJQfJ+7jQUzmtgJs16oxcWKrAUPJZA2S5nVUk3EQF 0UB30j5SmRVUCYbrymk9p4hpGKVV9s1gXqH15F2fpnPUn7iZ57jqFXKGSUWfijOQeOW0SIRLZwnAU 1aassRd3ikrm50gFpeGaA4pLH5e0ic4zM3ARukXRKpVoh+77pMfpGwTtyTt3hptI4qfp6SdLoGbZX 68n3fkFA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsoIh-0006oq-Ul; Thu, 23 Aug 2018 12:01:19 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsoIM-0006Gh-NH for linux-amlogic@lists.infradead.org; Thu, 23 Aug 2018 12:01:00 +0000 Received: by mail-wm0-x242.google.com with SMTP id y139-v6so4922203wmc.2 for ; Thu, 23 Aug 2018 05:00:49 -0700 (PDT) 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; bh=nX1kFI+OBSY8KCvRMNvb8nOKApKadpAZ6iu1gy94dM0=; b=lOrlT2fXZet9Q7afiYSvIrYCfQiqH+uVJwONnfB/2MSgTcrhm0z9BFFa2YmVp+OoFo YsuHaXnRWnHo3nvpHKzmrNBfX5RRMYY1erXebQAGjThsfJvgxuzyApBxZqlRi3H3HxKl wFJtlOuOBm590vqd/MnlUIHLlh9Vtn+QLfmGRf4P6cE9HyK6G8MIa6WKfZlMd6YXIFhJ wg8fQzHqyyexjBM1DjNKw5tEZpRp9ZlZSnlVhOs5bWnoiPJNqMG+cGKxaXzTIJUEbske vj4cSZREqowc3GOKPhuEuJAvT/mR40Wp6f6UBNAiugwj1FC4vwwGxzhpd+QSC+LMDhgP YL7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nX1kFI+OBSY8KCvRMNvb8nOKApKadpAZ6iu1gy94dM0=; b=X+VO1fqx3Qb6dNXduXgoiPPue1Fb3xzPINYemHqDRfHsNN+7PESxHvcHhQJZdTWqdv JIYq1bHYONNl3yKK+GjmguqwfA0PhmYUkpJsg3sw7YCHjQftN+ee9/gSaPS5UWTdRMtR 4F7XNjyZOOvap640/C4JjiyOik8TEOWz+YhC9XZjXD4bF2aj6HdNLlGl2H+XrosJCECb GSf0gyVdW4nTkVuo4zkxvhv8Mwo3BBcxvVXdSd/tUlfpn9vTpp1JWTZ4w7+5g/pVKNxU 2NCJ65rUg8pX3zeFaT/5sE/FVAjOdm69obuoJhgdFYqY3p5O6wZMV2saHZP2FcJmvZCH 88mA== X-Gm-Message-State: APzg51BL2UDpCB2Y/LYxYJiibWYfbVBy7M5BLTqNoRj25PbOtM68SVXJ jR+b9DG/vrXk24f09RrXVkNOQw== X-Google-Smtp-Source: ANB0VdZpZimp+3beeBcrTZmLDrMTBEdo8QlRaCWtSH4bcZqxdI/70phavMF0aDqJJXsDldGBuchxXw== X-Received: by 2002:a1c:3411:: with SMTP id b17-v6mr4900605wma.85.1535025648449; Thu, 23 Aug 2018 05:00:48 -0700 (PDT) Received: from localhost.localdomain (81-67-76-113.rev.numericable.fr. [81.67.76.113]) by smtp.gmail.com with ESMTPSA id y10-v6sm2830419wrl.87.2018.08.23.05.00.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 05:00:47 -0700 (PDT) From: Maxime Jourdan To: Kevin Hilman Subject: [PATCH v3 3/3] ARM64: dts: meson-gx: add dmcbus and canvas nodes. Date: Thu, 23 Aug 2018 13:49:54 +0200 Message-Id: <20180823114954.30704-4-mjourdan@baylibre.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823114954.30704-1-mjourdan@baylibre.com> References: <20180823114954.30704-1-mjourdan@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180823_050058_863413_BD49E469 X-CRM114-Status: UNSURE ( 9.11 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Jourdan , devicetree@vger.kernel.org, Neil Armstrong , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP DMC is a small memory region with various registers, including the ones needed for the canvas module. Reviewed-by: Jerome Brunet Signed-off-by: Maxime Jourdan --- arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi index b8dc4dbb391b..5dd63ecf8b05 100644 --- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi @@ -423,6 +423,19 @@ }; }; + dmcbus: bus@c8838000 { + compatible = "simple-bus"; + reg = <0x0 0xc8838000 0x0 0x400>; + #address-cells = <2>; + #size-cells = <2>; + ranges = <0x0 0x0 0x0 0xc8838000 0x0 0x400>; + + canvas: video-lut@48 { + compatible = "amlogic,canvas"; + reg = <0x0 0x48 0x0 0x14>; + }; + }; + hiubus: bus@c883c000 { compatible = "simple-bus"; reg = <0x0 0xc883c000 0x0 0x2000>;