From patchwork Tue Sep 29 14:18:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1373473 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=vG65zGI8; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C11kY5gWBz9ryj for ; Wed, 30 Sep 2020 00:20:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2BA9E8236F; Tue, 29 Sep 2020 16:19:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vG65zGI8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 728E382310; Tue, 29 Sep 2020 16:18:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2C6168158B for ; Tue, 29 Sep 2020 16:18:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x843.google.com with SMTP id g3so3626187qtq.10 for ; Tue, 29 Sep 2020 07:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f57moLo79hWQh1zHv8TLMO/MPDBFlEq0jiJ26X8nPk0=; b=vG65zGI88o0gSh5MJyLE7pGe4ss1EiQoJXl0wHOUP0sxebTlcICp3gvcf7FBHd+qce 5AQoQ1/o+Ch4vX3ZM8SwwuWwahnBTXLUmAVYa15+OWPdkPFGHWlB1ol2aSf7ZG91o8e9 MzYuvLYspQH6k95SB5acP3dKwpqUwO/ZaF9TfVB8rNnsYNapHGhrc/Wm69F8USpgmc/n p0QtNq6ZxnqcAhS5iuACku7nfi7St+h51B1D7KmbNJ0tMuNL07iR2BBkI0tlhYlPAQqF v+6CFckKJoj7AIOHj0nebf0KPSJkAs8atwwY3d1QUesiOMQ01EiWJQjV5OZ9a4Rb0E9/ QOvg== 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:mime-version:content-transfer-encoding; bh=f57moLo79hWQh1zHv8TLMO/MPDBFlEq0jiJ26X8nPk0=; b=Zm31Mgp34vtN4A+K+V3or/FWVLyQydq5vtk7N+6qkzp/GA/NNgp3fZ4pQA8vdWY9EX yL6npUi3YmE4unLabOeXXEKQIiJ9JQCX0rZvKVJv0s/sa8r5PCV1eGwV7EgJH484lDHp jFdLzEE7ACjNZDHYE+3PaFJfyqGs23222Abs4I9aarR5M4yU+21OU39NNkC2rUi6uQWP NQQUTcAzQ7S6IdDbqavpeZuEEVKNJISbfOaz1+l5TQ2uNpRtPGv1IDlvY/PN51YKfUR/ ZhkNy0gvPkPyLN6F0qwTWYG30kY2VO05hhVYlkrEO89NHwjhnsAWgm5+6hKqqQoX2VsY w/ew== X-Gm-Message-State: AOAM531WcQZJtdRQwHgOfT5JgOaGMg9jM/L4zmP/Sn2PetMa5nobCPFE IQVEQ1+Erhc0nmi+LybouqpzQ+su86PoVg== X-Google-Smtp-Source: ABdhPJyW6lwXnx1D24UukFlQGu1WZJBPDioP8Qhwz/O5sd+fnzQDUm5xzkrnV5Q+A+LrnmVGqOO/EA== X-Received: by 2002:ac8:36e9:: with SMTP id b38mr3581121qtc.284.1601389132809; Tue, 29 Sep 2020 07:18:52 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id l6sm117535qkb.56.2020.09.29.07.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 07:18:52 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Bin Meng , Rick Chen , Heinrich Schuchardt , Sean Anderson , Simon Glass Subject: [PATCH 06/10] ram: Add driver for K210 SRAM Date: Tue, 29 Sep 2020 10:18:31 -0400 Message-Id: <20200929141835.38435-7-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929141835.38435-1-seanga2@gmail.com> References: <20200929141835.38435-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean This adds a driver to handle enabling the clock for the AI SRAM. This was previously done in board_init, but it needs to happen before relocation now. An alternative would be to move this to board_init_early_f, but by doing it this way we can use clk_bulk. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- MAINTAINERS | 1 + drivers/ram/Kconfig | 7 ++++++ drivers/ram/Makefile | 1 + drivers/ram/kendryte.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 drivers/ram/kendryte.c diff --git a/MAINTAINERS b/MAINTAINERS index 7e46470c70..70e01e5e7a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -928,6 +928,7 @@ M: Sean Anderson S: Maintained F: doc/device-tree-bindings/mfd/kendryte,k210-sysctl.txt F: drivers/clk/kendryte/ +F: drivers/ram/kendryte.c F: include/kendryte/ RNG diff --git a/drivers/ram/Kconfig b/drivers/ram/Kconfig index 7e6e981897..faeacdf014 100644 --- a/drivers/ram/Kconfig +++ b/drivers/ram/Kconfig @@ -73,6 +73,13 @@ config IMXRT_SDRAM to support external memories like sdram, psram & nand. This driver is for the sdram memory interface with the SEMC. +config K210_SRAM + bool "Enable Kendryte K210 SRAM support" + depends on RAM + help + The Kendryte K210 has three banks of SRAM. This driver does the + necessary initialization. + source "drivers/ram/rockchip/Kconfig" source "drivers/ram/sifive/Kconfig" source "drivers/ram/stm32mp1/Kconfig" diff --git a/drivers/ram/Makefile b/drivers/ram/Makefile index 769c9d6218..d36b955e00 100644 --- a/drivers/ram/Makefile +++ b/drivers/ram/Makefile @@ -19,3 +19,4 @@ obj-$(CONFIG_K3_J721E_DDRSS) += k3-j721e/ obj-$(CONFIG_IMXRT_SDRAM) += imxrt_sdram.o obj-$(CONFIG_RAM_SIFIVE) += sifive/ +obj-$(CONFIG_K210_SRAM) += kendryte.o diff --git a/drivers/ram/kendryte.c b/drivers/ram/kendryte.c new file mode 100644 index 0000000000..50818bf005 --- /dev/null +++ b/drivers/ram/kendryte.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Sean Anderson + */ + +#include +#include +#include +#include + +static int k210_sram_probe(struct udevice *dev) +{ + int ret; + struct clk_bulk clocks; + + /* Relocate as high as possible to leave more space to load payloads */ + ret = fdtdec_setup_mem_size_base_highest(); + if (ret) + return ret; + + /* Enable ram bank clocks */ + ret = clk_get_bulk(dev, &clocks); + if (ret) + return ret; + + ret = clk_enable_bulk(&clocks); + if (ret) + return ret; + + return 0; +} + +static int k210_sram_get_info(struct udevice *dev, struct ram_info *info) +{ + info->base = gd->ram_base; + info->size = gd->ram_size; + + return 0; +} + +static struct ram_ops k210_sram_ops = { + .get_info = k210_sram_get_info, +}; + +static const struct udevice_id k210_sram_ids[] = { + { .compatible = "kendryte,k210-sram" }, + { } +}; + +U_BOOT_DRIVER(fu540_ddr) = { + .name = "k210_sram", + .id = UCLASS_RAM, + .of_match = k210_sram_ids, + .ops = &k210_sram_ops, + .probe = k210_sram_probe, +};