Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp457850ybg; Fri, 12 Jun 2020 06:10:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJIwAXB2v5Gw9gYC01WgJG9hm3nFTqsnOfoLfWWpa2d6heW4rU3wFvkDORgyov3D+qOHyq X-Received: by 2002:aa7:d0c5:: with SMTP id u5mr11461802edo.51.1591967431416; Fri, 12 Jun 2020 06:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591967431; cv=none; d=google.com; s=arc-20160816; b=0fyfKIUB2HsUB3sCKdHt5vAYN/5F6KfS57HxxdXhdvXeQ40RBlRRBitPlMDx6UXkKA OzA2LSB+MQlvkxVLdQHB6LGaYx1+Kcfd594hnmBLE0sSQ30zpEos4XsdNMxrxpz5D6Yb eBWdSL/nqbczhU168GGA3t/vlpQ0UJzZ3sBZkUEyJ0Ov7j6w60TC5n3ZdcxH+PtZDsF2 YD5CpF5zFRoh3bqIaml3ri/5jIH/hNm7FW7ZceOItJOigEnucKDgv5RSZAyGzDMVq1nN xGNhQ/pLKpr9ug+MNiIMx2WE7UXpcSJcm+vS9tzBBbd4BcSMgNkiVbVMrXeq4UOsxFcI Treg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qMbNPv+tqKnl8E3aX1NCgpAym5wq7AoUgSkigUX08uo=; b=R0iZAB5V97btW4fbOjN5ngwkPTaL8WLd/QA1YQ24tbXXb6rjGSXxYiBXxDodaECowu ZGoluA+U9UYOjVlpnuZDFY5yIH8HXkuWIfbBLzayA8kMq3uCkXvtnZz8zLsG3WPAkN5S Ko3nE8gtQqWsZS+IVvLBH6XiLZ/mAh4Fdk6GuzepHWlT1vGEDrqeFsUxMCV2KQW3WSFx IdPqsULdx3BD8UBKXhXqn+lXT8ithN9TT63OpSkRmyHWJiwo8/0omN+T/BNAJyjFr45y 33F3uJv3SFYXNHEd5b4gplWmjrYvNvW9sk5IK8AJUNdOcege1kheN8Vm8plGu4EtskYr cM7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@0x0f.com header.s=google header.b=diActX4S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc12si3458973edb.348.2020.06.12.06.10.07; Fri, 12 Jun 2020 06:10:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@0x0f.com header.s=google header.b=diActX4S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726361AbgFLNFb (ORCPT + 99 others); Fri, 12 Jun 2020 09:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbgFLNFa (ORCPT ); Fri, 12 Jun 2020 09:05:30 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C33EC08C5C1 for ; Fri, 12 Jun 2020 06:05:29 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id a45so4220938pje.1 for ; Fri, 12 Jun 2020 06:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0x0f.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qMbNPv+tqKnl8E3aX1NCgpAym5wq7AoUgSkigUX08uo=; b=diActX4SxskrdAp93QrKQ5GAuFiIyzsJdK4KsM9/rURnDcmB+dbPk2pZ8fvVqw3EwN aB979+bAMzJTim++qRezbcfD/YciQpsmiT3PKVKJtyQAFPanyRuBxzk4a7n5cOhv1Ub2 L+j5wD9dxkZGo3FEdY6aWnSZB0QF8FkwKrwcQ= 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=qMbNPv+tqKnl8E3aX1NCgpAym5wq7AoUgSkigUX08uo=; b=YPZITCfUtXWDgGhAiMbBrcGOyQSMcuvPTucR39RHADcQE1WFUcN3FlRPBK7qOrVB5p ENCX+6A36KMRxRhofLm7nkdUuiaATMbZ/dEzoqoGkiYDf4hHMdvq0Jd4ZEVN0SK7oEQM N0/dedRjyssBaHm7UdEghAq6zm8z61yAgHvpm82MVN0gNpBJ0sb4/qT8N8OkrbEz3VCt 1qxksSY6uPDGLw7rHkKCd2Lk2K46GKGFjX+5VY/IL0Vw5INUobL5iWNJCMs1eGapnW2z +MdIn7rfAxgS7kuek7u2fBu+0+4vFX73Hv9uBud7WOraln5bWZq2ZsYtvly8prpUoGm0 5hmg== X-Gm-Message-State: AOAM533OiVJVLKuTDG0uKBeOXsoBn/+dVcyX0hdjLSIMjXEZLQwBmgYM +Q5NdXQGeMEDO1PqEAqxvIeOp5+RJ36pGg== X-Received: by 2002:a17:90a:9d82:: with SMTP id k2mr12823519pjp.224.1591967127732; Fri, 12 Jun 2020 06:05:27 -0700 (PDT) Received: from shiro.work (p1285116-ipngn200805sizuokaden.shizuoka.ocn.ne.jp. [114.171.61.116]) by smtp.googlemail.com with ESMTPSA id k12sm5481939pgm.11.2020.06.12.06.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 06:05:26 -0700 (PDT) From: Daniel Palmer To: linux-kernel@vger.kernel.org Cc: daniel@0x0f.com, afaerber@suse.de, devicetree@vger.kernel.org, Daniel Palmer , Rob Herring , Russell King , Sam Ravnborg , Linus Walleij , Heiko Stuebner , Stephan Gerhold , Lubomir Rintel , Mark Brown , allen , Mauro Carvalho Chehab , "David S. Miller" , Jonathan Corbet , Greg Kroah-Hartman , Arnd Bergmann , Mike Rapoport , Doug Anderson , Benjamin Gaignard , Gregory Fong , Bartosz Golaszewski , Masahiro Yamada , Nick Desaulniers , Will Deacon , Nathan Chancellor , Nathan Huckleberry , Ard Biesheuvel , Marc Zyngier , linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 06/12] ARM: mstar: Add machine for MStar/Sigmastar Armv7 SoCs Date: Fri, 12 Jun 2020 22:00:06 +0900 Message-Id: <20200612130032.3905240-7-daniel@0x0f.com> X-Mailer: git-send-email 2.27.0.rc0 In-Reply-To: <20200612130032.3905240-1-daniel@0x0f.com> References: <20200610090421.3428945-1-daniel@0x0f.com> <20200612130032.3905240-1-daniel@0x0f.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Initial support for the MStar/Sigmastar Armv7 based IP camera and dashcam SoCs. These chips are interesting in that they contain a Cortex-A7, peripherals and system memory in a single tiny QFN package that can be hand soldered allowing almost anyone to embed Linux in their projects. Signed-off-by: Daniel Palmer --- MAINTAINERS | 1 + arch/arm/Kconfig | 2 + arch/arm/Makefile | 1 + arch/arm/mach-mstar/Kconfig | 26 ++++++++++++ arch/arm/mach-mstar/Makefile | 1 + arch/arm/mach-mstar/mstarv7.c | 80 +++++++++++++++++++++++++++++++++++ 6 files changed, 111 insertions(+) create mode 100644 arch/arm/mach-mstar/Kconfig create mode 100644 arch/arm/mach-mstar/Makefile create mode 100644 arch/arm/mach-mstar/mstarv7.c diff --git a/MAINTAINERS b/MAINTAINERS index c44070f76a1b..4bd57bbdddb0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2116,6 +2116,7 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained W: http://linux-chenxing.org/ F: Documentation/devicetree/bindings/arm/mstar.yaml +F: arch/arm/mach-mstar/ ARM/NEC MOBILEPRO 900/c MACHINE SUPPORT M: Michael Petchkovsky diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index fb6c85c5d344..e466694f8486 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -669,6 +669,8 @@ source "arch/arm/mach-mmp/Kconfig" source "arch/arm/mach-moxart/Kconfig" +source "arch/arm/mach-mstar/Kconfig" + source "arch/arm/mach-mv78xx0/Kconfig" source "arch/arm/mach-mvebu/Kconfig" diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 59fde2d598d8..e7f4ca060c0f 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -197,6 +197,7 @@ machine-$(CONFIG_ARCH_MXC) += imx machine-$(CONFIG_ARCH_MEDIATEK) += mediatek machine-$(CONFIG_ARCH_MILBEAUT) += milbeaut machine-$(CONFIG_ARCH_MXS) += mxs +machine-$(CONFIG_ARCH_MSTARV7) += mstar machine-$(CONFIG_ARCH_NOMADIK) += nomadik machine-$(CONFIG_ARCH_NPCM) += npcm machine-$(CONFIG_ARCH_NSPIRE) += nspire diff --git a/arch/arm/mach-mstar/Kconfig b/arch/arm/mach-mstar/Kconfig new file mode 100644 index 000000000000..52744fe32368 --- /dev/null +++ b/arch/arm/mach-mstar/Kconfig @@ -0,0 +1,26 @@ +menuconfig ARCH_MSTARV7 + bool "MStar/Sigmastar Armv7 SoC Support" + depends on ARCH_MULTI_V7 + select ARM_GIC + select ARM_HEAVY_MB + help + Support for newer MStar/Sigmastar SoC families that are + based on Armv7 cores like the Cortex A7 and share the same + basic hardware like the infinity and mercury series. + +if ARCH_MSTARV7 + +config MACH_INFINITY + bool "MStar/Sigmastar infinity SoC support" + default ARCH_MSTARV7 + help + Support for MStar/Sigmastar infinity IP camera SoCs. + +config MACH_MERCURY + bool "MStar/Sigmastar mercury SoC support" + default ARCH_MSTARV7 + help + Support for MStar/Sigmastar mercury dash camera SoCs. + Note that older Mercury2 SoCs are ARM9 based and not supported. + +endif diff --git a/arch/arm/mach-mstar/Makefile b/arch/arm/mach-mstar/Makefile new file mode 100644 index 000000000000..93b0391ede7e --- /dev/null +++ b/arch/arm/mach-mstar/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_ARCH_MSTARV7) += mstarv7.o diff --git a/arch/arm/mach-mstar/mstarv7.c b/arch/arm/mach-mstar/mstarv7.c new file mode 100644 index 000000000000..81a4cbcab206 --- /dev/null +++ b/arch/arm/mach-mstar/mstarv7.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device Tree support for MStar/Sigmastar Armv7 SoCs + * + * Copyright (c) 2020 thingy.jp + * Author: Daniel Palmer + */ + +#include +#include +#include +#include +#include +#include + +/* + * In the u-boot code the area these registers are in is + * called "L3 bridge" and there are register descriptions + * for something in the same area called "AXI". + * + * It's not exactly known what this is but the vendor code + * for both u-boot and linux share calls to "flush the miu pipe". + * This seems to be to force pending CPU writes to memory so that + * the state is right before DMA capable devices try to read + * descriptors and data the CPU has prepared. Without doing this + * ethernet doesn't work reliably for example. + */ + +#define MSTARV7_L3BRIDGE_FLUSH 0x14 +#define MSTARV7_L3BRIDGE_STATUS 0x40 +#define MSTARV7_L3BRIDGE_FLUSH_TRIGGER BIT(0) +#define MSTARV7_L3BRIDGE_STATUS_DONE BIT(12) + +static void __iomem *l3bridge; + +static const char * const mstarv7_board_dt_compat[] __initconst = { + "mstar,infinity", + "mstar,infinity3", + "mstar,mercury5", + NULL, +}; + +/* + * This may need locking to deal with situations where an interrupt + * happens while we are in here and mb() gets called by the interrupt handler. + * + * The vendor code did have a spin lock but it doesn't seem to be needed and + * removing it hasn't caused any side effects so far. + * + * [writel|readl]_relaxed have to be used here because otherwise + * we'd end up right back in here. + */ +static void mstarv7_mb(void) +{ + /* toggle the flush miu pipe fire bit */ + writel_relaxed(0, l3bridge + MSTARV7_L3BRIDGE_FLUSH); + writel_relaxed(MSTARV7_L3BRIDGE_FLUSH_TRIGGER, l3bridge + + MSTARV7_L3BRIDGE_FLUSH); + while (!(readl_relaxed(l3bridge + MSTARV7_L3BRIDGE_STATUS) + & MSTARV7_L3BRIDGE_STATUS_DONE)) { + /* wait for flush to complete */ + } +} + +static void __init mstarv7_init(void) +{ + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, "mstar,l3bridge"); + l3bridge = of_iomap(np, 0); + if (l3bridge) + soc_mb = mstarv7_mb; + else + pr_warn("Failed to install memory barrier, DMA will be broken!\n"); +} + +DT_MACHINE_START(MSTARV7_DT, "MStar/Sigmastar Armv7 (Device Tree)") + .dt_compat = mstarv7_board_dt_compat, + .init_machine = mstarv7_init, +MACHINE_END -- 2.27.0.rc0