From patchwork Mon Oct 17 16:30:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 9379909 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 9114D607D4 for ; Mon, 17 Oct 2016 16:34:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8249728E99 for ; Mon, 17 Oct 2016 16:34:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7728F28F05; Mon, 17 Oct 2016 16:34: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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable 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 5E29328E99 for ; Mon, 17 Oct 2016 16:34:01 +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 1bwAqC-00007H-8G; Mon, 17 Oct 2016 16:32:44 +0000 Received: from mail-qt0-f176.google.com ([209.85.216.176]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bwApx-0008F3-0y for linux-arm-kernel@lists.infradead.org; Mon, 17 Oct 2016 16:32:36 +0000 Received: by mail-qt0-f176.google.com with SMTP id q7so128628850qtq.1 for ; Mon, 17 Oct 2016 09:32:08 -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=SSfdvQnTE3/O6cchEUUspDbOxuuLrr2ZV0xK0M5ORf8=; b=L0ji5KFKV5AyVogjoEtnHTRFHxkztwPVj6QLvD6bvUeK5YUlPGPN5nUmKqr2kHOKou ZUBkeFaNgJKTCMUbEpq1jDHveKyJZJ6jmCkBqii95EZj6fy7MiGb8swLa3OVIM53or/l 1Z+RmHjM+dERwIWjeyCXcngEJGlQHFY5PbgZDkK954qYjVfOcBJbw/8FcDzdDBTwK1Pi GH3rQpHDsRYqbSpn4GUO0dlNS3SaQhGjQD2fVIujIv34/mIk2dKRNybfZzDFP7++nQOK /ALFypL+N6MPS4vsSHCKQO4J9RwHELTDNejv7r1SbbhRSi8qU6tTK9vnju3S3AAHrhDj 0JpA== 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=SSfdvQnTE3/O6cchEUUspDbOxuuLrr2ZV0xK0M5ORf8=; b=cdmAo2kxZEH+Sio4wLsybQFoqu8xCt2NWsoD3dyJVmjPez+Oj41Aa1X/N5CatGd4Yx 1d5olta+FqifB5rrx6lT6dwMK0MDOME1Tu6MFScCfYBIKvvb2MGVAEZHCaNDKb1lw+kC jb5xzPcg9avV8zIl210/XCVcxsdZfyLMzFLn9NgIx9P22zfPVIocLYt36vHtmrFjzhmh O6gh+DGnJMLaSDJILO62lARuLSwBkeReP5jsZ0a6Ws4E0DrOsaz7dux8E6CSu3FUVfJl BPr21chV5ZcJLe7aADUp6b/ajgChjrOD7SUqIixkxba+LD+TSWjTa1pvdeDJ5CdLzY0e 7OdQ== X-Gm-Message-State: AA6/9Rkho/lDi5XTFM2mEBrFobdcUJsLFJI72/ARbEekc+mBkWcsNYTt+vqXlljF6Q1499QF X-Received: by 10.194.238.162 with SMTP id vl2mr11597089wjc.39.1476721867313; Mon, 17 Oct 2016 09:31:07 -0700 (PDT) Received: from localhost.localdomain (static-46-238-241-125.awacom.net. [46.238.241.125]) by smtp.gmail.com with ESMTPSA id j1sm43945514wjl.21.2016.10.17.09.31.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Oct 2016 09:31:06 -0700 (PDT) From: Bartosz Golaszewski To: Kevin Hilman , Michael Turquette , Sekhar Nori , Rob Herring , Frank Rowand , Mark Rutland , Peter Ujfalusi , Russell King Subject: [PATCH 1/3] ARM: memory: da8xx-ddrctl: new driver Date: Mon, 17 Oct 2016 18:30:48 +0200 Message-Id: <1476721850-454-2-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1476721850-454-1-git-send-email-bgolaszewski@baylibre.com> References: <1476721850-454-1-git-send-email-bgolaszewski@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161017_093229_663062_ACEDCA41 X-CRM114-Status: GOOD ( 22.51 ) 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: linux-devicetree , David Airlie , LKML , linux-drm , Bartosz Golaszewski , Tomi Valkeinen , Jyri Sarha , arm-soc , Laurent Pinchart MIME-Version: 1.0 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 Create a new driver for the da8xx DDR2/mDDR controller and implement support for writing to the Peripheral Bus Burst Priority Register. Signed-off-by: Bartosz Golaszewski --- .../memory-controllers/ti-da8xx-ddrctl.txt | 25 +++++++ drivers/memory/Kconfig | 8 +++ drivers/memory/Makefile | 1 + drivers/memory/da8xx-ddrctl.c | 77 ++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt create mode 100644 drivers/memory/da8xx-ddrctl.c diff --git a/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt new file mode 100644 index 0000000..e340404 --- /dev/null +++ b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt @@ -0,0 +1,25 @@ +* Device tree bindings for Texas Instruments da8xx DDR2/mDDR memory controller + +The DDR2/mDDR memory controller present on Texas Instruments da8xx SoCs memory +maps a set of registers which allow to tweak the controller's behavior. + +Documentation: +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf + +Required properties: + +- compatible: "ti,da850-ddrctl" + +Optional properties: + +- ti,pr-old-count: Priority raise old counter. Specifies the number of + memory transfers after which the DDR2/mDDR memory + controller will elevate the priority of the oldest + command in the command FIFO. Must be between 0-255. + +Example for da850 shown below. + +ddrctl { + compatible = "ti,da850-ddrctl"; + ti,pr-old-count = <0x20>; +}; diff --git a/drivers/memory/Kconfig b/drivers/memory/Kconfig index 4b4c0c3..ec80e35 100644 --- a/drivers/memory/Kconfig +++ b/drivers/memory/Kconfig @@ -134,6 +134,14 @@ config MTK_SMI mainly help enable/disable iommu and control the power domain and clocks for each local arbiter. +config DA8XX_DDRCTL + bool "Texas Instruments da8xx DDR2/mDDR driver" + depends on ARCH_DAVINCI_DA8XX + help + This driver is for the DDR2/mDDR Memory Controller present on + Texas Instruments da8xx SoCs. It's used to tweak various memory + controller configuration options. + source "drivers/memory/samsung/Kconfig" source "drivers/memory/tegra/Kconfig" diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile index b20ae38..e88097fb 100644 --- a/drivers/memory/Makefile +++ b/drivers/memory/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_MVEBU_DEVBUS) += mvebu-devbus.o obj-$(CONFIG_TEGRA20_MC) += tegra20-mc.o obj-$(CONFIG_JZ4780_NEMC) += jz4780-nemc.o obj-$(CONFIG_MTK_SMI) += mtk-smi.o +obj-$(CONFIG_DA8XX_DDRCTL) += da8xx-ddrctl.o obj-$(CONFIG_SAMSUNG_MC) += samsung/ obj-$(CONFIG_TEGRA_MC) += tegra/ diff --git a/drivers/memory/da8xx-ddrctl.c b/drivers/memory/da8xx-ddrctl.c new file mode 100644 index 0000000..dcd0a61 --- /dev/null +++ b/drivers/memory/da8xx-ddrctl.c @@ -0,0 +1,77 @@ +/* + * TI da8xx DDR2/mDDR controller driver + * + * Copyright (C) 2016 BayLibre SAS + * + * Author: + * Bartosz Golaszewski + * + * 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 + +#define DA8XX_DDR_CTL_BASE 0xB0000000 +#define DA8XX_PBBPR_OFFSET 0x00000020 +#define DA8XX_PBBPR_REG(p) ((p) + DA8XX_PBBPR_OFFSET) + +#define DA8XX_PBBPR_MAX 0xff + +static void da8xx_ddrctl_set_pbbpr(void __iomem *ddrctl, struct device *dev) +{ + struct device_node *node = dev->of_node; + u32 pr_old_count; + int ret; + + ret = of_property_read_u32(node, "ti,pr-old-count", &pr_old_count); + if (ret) + return; + + if (pr_old_count > DA8XX_PBBPR_MAX) { + dev_warn(dev, "priority raise old counter value too high\n"); + return; + } + + __raw_writel(pr_old_count, DA8XX_PBBPR_REG(ddrctl)); +} + +static int da8xx_ddrctl_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + void __iomem *ddrctl; + + ddrctl = ioremap(DA8XX_DDR_CTL_BASE, SZ_256); + if (!ddrctl) { + dev_err(dev, "unable to map memory controller registers\n"); + return -EIO; + } + + da8xx_ddrctl_set_pbbpr(ddrctl, dev); + + iounmap(ddrctl); + + return 0; +} + +static const struct of_device_id da8xx_ddrctl_of_match[] = { + { .compatible = "ti,da850-ddrctl", }, + { }, +}; + +static struct platform_driver da8xx_ddrctl_driver = { + .probe = da8xx_ddrctl_probe, + .driver = { + .name = "da8xx-ddrctl", + .of_match_table = da8xx_ddrctl_of_match, + }, +}; +module_platform_driver(da8xx_ddrctl_driver); + +MODULE_AUTHOR("Bartosz Golaszewski "); +MODULE_DESCRIPTION("TI da8xx DDR2/mDDR controller driver"); +MODULE_LICENSE("GPL v2");