From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88086C4338F for ; Sun, 25 Jul 2021 23:35:06 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 04D2060BD3 for ; Sun, 25 Jul 2021 23:35:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 04D2060BD3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=yifangu.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EEF2183277; Mon, 26 Jul 2021 01:34:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=yifangu.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 2F37C8323A; Mon, 26 Jul 2021 01:16:49 +0200 (CEST) Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (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 C04528323A for ; Mon, 26 Jul 2021 01:16:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=yifangu.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=gyf304@gmail.com Received: by mail-qv1-f46.google.com with SMTP id g6so4219892qvj.8 for ; Sun, 25 Jul 2021 16:16:42 -0700 (PDT) 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=e5dWBE40r5XBZfVu0UI7gOV6pjLI0My8On6FrPPOlMo=; b=Q12XG1lSLF//p26VzUG1gh2+IoWVAgJA1C0FEDK3WtKEIDkpJRjKiR+rrWvVgwRcVE 4Edwno1zyTTAYoN+e6L+DZHxFQjvoVjFT4i3R/VC0yH1v3tW3u1kw3RietkUrCS5nBqb oacEdYSGndulL0Sj4p/p+TzYemD976Unj1NfwB9xlOEl3nudrdjgcGJLeU2nrdGvhmE5 wpyB6fTnXvorFo9GEAug9Gwflb7YZOHspvSyn8WahrFaiu5KiDg4YUYLbOExer91VtTD 27jZ1HOlGuNGeIoVoR/JDi1BRmo+S4J9PeEIf43rAk4HJiNIQmXcCs88X2uDNDb4m0/1 tJtg== X-Gm-Message-State: AOAM532NG9Y8UbohD1vCkFKk1hitQPPNjTxYj4kSOazD56JPXW9731eU CdTeL7r7vDox/Z1AhoRrKwgPG44Tk20cRScc X-Google-Smtp-Source: ABdhPJxxSqD37m2FcQY26K3JehTGkb1zyHoBUpbv3byVXEFCyvJTieQJTiguLIWhPlOhoTc5WQzjqg== X-Received: by 2002:ad4:5ded:: with SMTP id jn13mr15376502qvb.24.1627255001391; Sun, 25 Jul 2021 16:16:41 -0700 (PDT) Received: from yifangu-Virtual-Machine.mshome.net (pool-100-6-159-43.pitbpa.fios.verizon.net. [100.6.159.43]) by smtp.gmail.com with ESMTPSA id u184sm17754694qkd.53.2021.07.25.16.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jul 2021 16:16:41 -0700 (PDT) From: Yifan Gu To: u-boot@lists.denx.de Cc: Yifan Gu , Jagan Teki , Andre Przywara , Icenowy Zheng , George Hilliard Subject: [PATCH 06/27] sunxi: spi-spl: add support for SUNIV Date: Sun, 25 Jul 2021 19:16:15 -0400 Message-Id: <20210725231636.879913-7-me@yifangu.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210725231636.879913-1-me@yifangu.com> References: <20210725231636.879913-1-me@yifangu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 26 Jul 2021 01:32:10 +0200 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.103.2 at phobos.denx.de X-Virus-Status: Clean From: Icenowy Zheng The suniv SoC come with a sun6i-style SPI controller at the base address of sun4i SPI controller. The module clock of the SPI controller is also missing. Add support for it. Signed-off-by: Icenowy Zheng Signed-off-by: Yifan Gu --- arch/arm/include/asm/arch-sunxi/gpio.h | 1 + arch/arm/mach-sunxi/Kconfig | 2 +- arch/arm/mach-sunxi/spl_spi_sunxi.c | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h index b0b86b812a..26c900fb11 100644 --- a/arch/arm/include/asm/arch-sunxi/gpio.h +++ b/arch/arm/include/asm/arch-sunxi/gpio.h @@ -170,6 +170,7 @@ enum sunxi_gpio_number { #define SUNXI_GPC_NAND 2 #define SUNXI_GPC_SPI0 3 #define SUNXI_GPC_SDC2 3 +#define SUNIV_GPC_SPI0 2 #define SUN6I_GPC_SDC3 4 #define SUN50I_GPC_SPI0 4 diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index f15b4e8bda..4fde7e1da1 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1067,7 +1067,7 @@ config SPL_STACK_R_ADDR config SPL_SPI_SUNXI bool "Support for SPI Flash on Allwinner SoCs in SPL" - depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNXI_H3_H5 || MACH_SUN50I || MACH_SUN8I_R40 || MACH_SUN50I_H6 + depends on MACH_SUNIV || MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNXI_H3_H5 || MACH_SUN50I || MACH_SUN8I_R40 || MACH_SUN50I_H6 help Enable support for SPI Flash. This option allows SPL to read from sunxi SPI Flash. It uses the same method as the boot ROM, so does diff --git a/arch/arm/mach-sunxi/spl_spi_sunxi.c b/arch/arm/mach-sunxi/spl_spi_sunxi.c index 15e86cbac8..f6f65a0e3d 100644 --- a/arch/arm/mach-sunxi/spl_spi_sunxi.c +++ b/arch/arm/mach-sunxi/spl_spi_sunxi.c @@ -89,6 +89,7 @@ #define SPI0_CLK_DIV_BY_2 0x1000 #define SPI0_CLK_DIV_BY_4 0x1001 +#define SPI0_CLK_DIV_BY_32 0x100f /*****************************************************************************/ @@ -120,6 +121,7 @@ static void spi0_pinmux_setup(unsigned int pin_function) static bool is_sun6i_gen_spi(void) { return IS_ENABLED(CONFIG_SUNXI_GEN_SUN6I) || + IS_ENABLED(CONFIG_MACH_SUNIV) || IS_ENABLED(CONFIG_MACH_SUN50I_H6); } @@ -155,11 +157,17 @@ static void spi0_enable_clock(void) if (!IS_ENABLED(CONFIG_MACH_SUN50I_H6)) setbits_le32(CCM_AHB_GATING0, (1 << AHB_GATE_OFFSET_SPI0)); +#ifdef CONFIG_MACH_SUNIV + /* Divide by 32, clock source is AHB clock 200MHz */ + writel(SPI0_CLK_DIV_BY_32, base + (is_sun6i_gen_spi() ? + SUN6I_SPI0_CCTL : SUN4I_SPI0_CCTL)); +#else /* Divide by 4 */ writel(SPI0_CLK_DIV_BY_4, base + (is_sun6i_gen_spi() ? SUN6I_SPI0_CCTL : SUN4I_SPI0_CCTL)); /* 24MHz from OSC24M */ writel((1 << 31), CCM_SPI0_CLK); +#endif if (is_sun6i_gen_spi()) { /* Enable SPI in the master mode and do a soft reset */ @@ -189,8 +197,10 @@ static void spi0_disable_clock(void) clrbits_le32(base + SUN4I_SPI0_CTL, SUN4I_CTL_MASTER | SUN4I_CTL_ENABLE); +#ifndef CONFIG_MACH_SUNIV /* Disable the SPI0 clock */ writel(0, CCM_SPI0_CLK); +#endif /* Close the SPI0 gate */ if (!IS_ENABLED(CONFIG_MACH_SUN50I_H6)) @@ -212,6 +222,9 @@ static void spi0_init(void) IS_ENABLED(CONFIG_MACH_SUN50I_H6)) pin_function = SUN50I_GPC_SPI0; + if (IS_ENABLED(CONFIG_MACH_SUNIV)) + pin_function = SUNIV_GPC_SPI0; + spi0_pinmux_setup(pin_function); spi0_enable_clock(); } -- 2.25.1