Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2402983ybt; Tue, 16 Jun 2020 05:21:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi5wLNpGVoh3tlV91Ww+wZ95FsoRJgJPloWjImlEaQzOwe1YUjYiuVymP06qgG2ebd7vFh X-Received: by 2002:aa7:d48f:: with SMTP id b15mr2454718edr.8.1592310091548; Tue, 16 Jun 2020 05:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592310091; cv=none; d=google.com; s=arc-20160816; b=Hf1C70Ef8QwNfSvGrrrfi6Bh1aGDe16slPUb1Z0hlGCKj7ViCIVcWrrIGWJdJfg4SZ hRi3T/upGrWRAk894rQHJGX0v0nHlrAidweOTzMjtU7Ct5/LEO2KrnFVLnfhabFJynb3 a/2DkwuIaj4dTUal5XEDyASoEk0tsZ3Ss4Ct5+gdpw6OdIl+LH4R7dTMLL9kl0CL2DqE EqtFyWVhZJO8AZdQHQ4tlSXAOVSBNo5kfD4amV8DU9RDfghNno0ky54DkYywbQSw17Ue 78xWiqXfEfyEgmow9c0vtoa3Ct/iH+8XVSfGuut/BoDTsi3fRXZKm23JcqqNQQiMEw/4 IbYw== 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=c61Valhisfj0A4+toVoEhG9r62W9GUg+oEnyK7Kxp6I=; b=XVJv9ZTYK3dkfLgsIUhwGrBs98wPYiq/6TlFq5CP8xveu4Q6/lawUDCxvUuXjqVkzY 5KWsTj6YDe1semM4MIKYQi/O+VYoE1bLGJIcqa9Y0Ab5iHhWVJcirVS8wQ4q3EmL9qZX mtpMm2xiZ4OFqnXG8gzo1juN5YrbdQjOzuqE1M1IP38OJEemXlyNTVYGUHvVL5c3Kmzd BGGwvk0lRmK5NCP4cyiLFiXtfpWklhFw109ikb0ezgUl44F9+duqdfPUc2PFKJkiJ4gk SzLiSaYeo0b9umd6bSjnI4xLRpw2ZFtAHwAotEk0ddQR2R0PNqwwIe2nd90moMwLyh6q kf0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@0x0f.com header.s=google header.b=ODsOtQVz; 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 v12si11183193eji.163.2020.06.16.05.21.08; Tue, 16 Jun 2020 05:21: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=ODsOtQVz; 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 S1728825AbgFPMRk (ORCPT + 99 others); Tue, 16 Jun 2020 08:17:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728740AbgFPMR0 (ORCPT ); Tue, 16 Jun 2020 08:17:26 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BDECC08C5C7 for ; Tue, 16 Jun 2020 05:17:24 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id y18so8319845plr.4 for ; Tue, 16 Jun 2020 05:17:24 -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=c61Valhisfj0A4+toVoEhG9r62W9GUg+oEnyK7Kxp6I=; b=ODsOtQVzzwZwSI9yMhv2Qoa7LK12l8stOTejdxcBbavb6Oy9znZJKcgmXo9xxIeK8M hyUEa4OAe1trY0ogM2jP+IUp3tM4qMnrutPzhdQ8wYNvLcBALOoPusPJVlPQTwk4wvyq cxbT0h1m/BJt4gKhM1y0K3J4zN7pV+OOzWnfk= 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=c61Valhisfj0A4+toVoEhG9r62W9GUg+oEnyK7Kxp6I=; b=eOSowD+BH/COif/XWluK1SKWU9/w6brJYAXRzlogftBeuV04zszDilFRBRwkZ+Xq8p EC7uR3JH4xilzGdWrrgrV+psQCQZYnCkRvwzEbLf36brx21outum1DetQWQ1Z1gkRMDI PBV5c4Oyz+afaovbe/G23KzZwO/qBeENI5j05aEM39PKuziR+lejW7NxWnWHXV3hlKuz Sthv+wk5Af4pT0Hr11fr6jx9lPwZe+r45mldKvaKtfLRP7aUXpHPW2hNXjFMx0WGUhg6 maoOwWzuJ7jCpqn3oOn2ZpZeqNRSXx3vOYRDvQGsxgNTlflcVp/3MG3kQkdW6zrqnbnq 0IFw== X-Gm-Message-State: AOAM5305TPyYgS7+3cwsr5SQZxcPxBa7ORy3nGYWhiubrtXi1WfMzKdh t5OAwRIjjLoBOPsqtwocakxODQ== X-Received: by 2002:a17:902:704a:: with SMTP id h10mr1830855plt.85.1592309843535; Tue, 16 Jun 2020 05:17:23 -0700 (PDT) Received: from shiro.work (p1285116-ipngn200805sizuokaden.shizuoka.ocn.ne.jp. [114.171.61.116]) by smtp.googlemail.com with ESMTPSA id f23sm2360703pja.8.2020.06.16.05.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 05:17:22 -0700 (PDT) From: Daniel Palmer To: linux-arm-kernel@lists.infradead.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Palmer Subject: [PATCH v4 06/12] ARM: mstar: Add machine for MStar/Sigmastar Armv7 SoCs Date: Tue, 16 Jun 2020 21:15:19 +0900 Message-Id: <20200616121525.1409790-7-daniel@0x0f.com> X-Mailer: git-send-email 2.27.0.rc0 In-Reply-To: <20200616121525.1409790-1-daniel@0x0f.com> References: <20200612130032.3905240-2-daniel@0x0f.com> <20200616121525.1409790-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 a8640c1c50cc..3d31bc749f6d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2123,6 +2123,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 2ac74904a3ce..d54c413ad937 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -668,6 +668,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