Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4150142ybp; Sun, 13 Oct 2019 23:24:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3kkpuept/yH5ILIh+cbSaqPd4ZvI8/K8PyBkvdlWs9A7UQYD9mUh91BSPTzi6R9I6oGDI X-Received: by 2002:a17:906:e113:: with SMTP id gj19mr27379207ejb.203.1571034268407; Sun, 13 Oct 2019 23:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571034268; cv=none; d=google.com; s=arc-20160816; b=YKY6mbe2ZE9mZdPrnVJmuQpt+y7yvegq1hA3zmtalp0MtDPUTGdCbjga28uh+b91xH lqv1eMatXNKTtIeyznLeXH3m/+Hc/v0jk0Zk7mwetYzuf1Sx4CPueEgt6exnVka0pJtU WgoGmpRE/9r1rLA3G6uYNR260jBkD0QOTDudaJcO3vgiDVuE19jAjMMu9xJXJ/79jyBo +zaqNL5C2GLh0/fYTT0r7NRsu1P9oVZy1VFoDJ56KBrCA5qECN6878yMqD5lAfeDYILF iKexQmKLmiM8top5GGe0ExXjUbzy2lo6aBsBmlDkT4CbtTCKYpvrJGunX42/z0lGHsXA Qkaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=554xhV+hLyMKcqr7sdgNkibt6TJgY0ufjKiym0bnAqk=; b=OrvicSnS7bG9c3cRskZL2bFdDj5DVoGTu2I8Oxn8VT18k0CcgRB0awn0I71vu8fv3P 5dS0FH02Ll7bbmSW7lCxBif2Bj3zx+mVmSHkWA14ypUkScaSpdXfSDV7hSgFFD1tbJ5o 95d91/miWB3JEg02Nkid/BmSu5IAZbdGDore1QBKqs6qKwoY9+xfWeFq2+CxMScV3m+4 Y2SZHcIKGCDoCA7h1i5C491cx/Qfn5aj3SDPhXWulY3CrBnIhi1XOieXUONNE26EzM3h gXi6xJCluTBcvW13//EH/d/3BLUUZCfEOXqaw7dZB83xQrMiS/8Sx2JKenVN9Yx8m3mU KVuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@0x0f.com header.s=google header.b=tuOaD5Bw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fx14si10330876ejb.268.2019.10.13.23.24.05; Sun, 13 Oct 2019 23:24:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@0x0f.com header.s=google header.b=tuOaD5Bw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730005AbfJNGV3 (ORCPT + 99 others); Mon, 14 Oct 2019 02:21:29 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33516 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729899AbfJNGV2 (ORCPT ); Mon, 14 Oct 2019 02:21:28 -0400 Received: by mail-pl1-f194.google.com with SMTP id d22so7560412pls.0 for ; Sun, 13 Oct 2019 23:21:27 -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=554xhV+hLyMKcqr7sdgNkibt6TJgY0ufjKiym0bnAqk=; b=tuOaD5BwIZVKAid0XN0878Rpm8jrUzcUxMkqNkilQOH3FQSWmRzsxzmJB4xueu/OEt 9DMT5N2rySVnS7966OlUCKjhCGW1BUBZIRFR5t3PSQ8SrXVX1Gphhkx3tnHK8EHHf1dO J8Hrtg4ycU2Mm9c/23phmLA6CUCoiHCnlpbFE= 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=554xhV+hLyMKcqr7sdgNkibt6TJgY0ufjKiym0bnAqk=; b=stc4sb0SWqEpMQSxiq0GvqOYoTsSVlZ5kh6NyASx9bJaxPT7Xh66Pn02BJcgnr1bK1 OJJbISbJJW/qH/5sXTaJ032f3UFyEBq+qkFXtExORf+g80Vfrp5evfM8dpXQi7FeLjct K5GdxJPDa5DWZLYZp9oStnwNAc52SiMzTXn+ti3bXdJdN0QTeUNmCMx3r68LKTIeNpPa vqvUybw54HYnjDvF8mfqpP19/dm9qSPdjs+5iBoPtsOYbzGHGwnW6uA1XKonxt33iWDW FqbF5M0Zl6GIn0bvChdsJLdIHWMw0uHPOcHA9DuQdmSoe0DN+FP25DUPW190yQAtIImV C/NA== X-Gm-Message-State: APjAAAVSWJZRAYNaUPBSZd5t77VkEkbQVAlzgFS4bF+kFohPG38HmblI PEqEJYQrHdrcX5pGjaGq+8w3EQ== X-Received: by 2002:a17:902:a584:: with SMTP id az4mr27734351plb.74.1571034086897; Sun, 13 Oct 2019 23:21:26 -0700 (PDT) Received: from shiro.work (p1092222-ipngn200709sizuokaden.shizuoka.ocn.ne.jp. [220.106.235.222]) by smtp.googlemail.com with ESMTPSA id g24sm16874074pfi.81.2019.10.13.23.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2019 23:21:26 -0700 (PDT) From: Daniel Palmer Cc: daniel@0x0f.com, Daniel Palmer , Rob Herring , Mark Rutland , Russell King , Maxime Ripard , Heiko Stuebner , Shawn Guo , Laurent Pinchart , Icenowy Zheng , Mauro Carvalho Chehab , "David S. Miller" , Greg Kroah-Hartman , Jonathan Cameron , "Paul E. McKenney" , Arnd Bergmann , Linus Walleij , Paul Burton , Andrew Morton , Mike Rapoport , Bartosz Golaszewski , Doug Anderson , Ard Biesheuvel , Benjamin Gaignard , Nick Desaulniers , Stefan Agner , Nicolas Pitre , Masahiro Yamada , Nathan Chancellor , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Nathan Huckleberry , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] ARM: mstar: Add machine for MStar infinity family SoCs Date: Mon, 14 Oct 2019 15:15:57 +0900 Message-Id: <20191014061617.10296-2-daniel@0x0f.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191014061617.10296-1-daniel@0x0f.com> References: <20191014061617.10296-1-daniel@0x0f.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Initial support for the MStar infinity/infinity3 series of Cortex A7 based IP camera 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 | 15 ++++++ arch/arm/mach-mstar/Makefile | 1 + arch/arm/mach-mstar/infinity.c | 96 ++++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+) create mode 100644 arch/arm/mach-mstar/Kconfig create mode 100644 arch/arm/mach-mstar/Makefile create mode 100644 arch/arm/mach-mstar/infinity.c diff --git a/MAINTAINERS b/MAINTAINERS index 8b7913c13f9a..e35c3eb2b680 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1985,6 +1985,7 @@ ARM/MStar SoC support M: Daniel Palmer L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) F: Documentation/devicetree/bindings/arm/mstar.yaml +F: arch/arm/mach-mstar/ S: Maintained ARM/NEC MOBILEPRO 900/c MACHINE SUPPORT diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 8a50efb559f3..b8450ed8d946 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -667,6 +667,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 db857d07114f..2a3c127cd243 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -196,6 +196,7 @@ machine-$(CONFIG_ARCH_MXC) += imx machine-$(CONFIG_ARCH_MEDIATEK) += mediatek machine-$(CONFIG_ARCH_MILBEAUT) += milbeaut machine-$(CONFIG_ARCH_MXS) += mxs +machine-$(CONFIG_ARCH_MSTAR) += 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..7bc79c296ebb --- /dev/null +++ b/arch/arm/mach-mstar/Kconfig @@ -0,0 +1,15 @@ +menuconfig ARCH_MSTAR + bool "MStar SoC Support" + depends on ARCH_MULTI_V7 + select ARM_GIC + help + Support for MStar ARMv7 SoCs + +if ARCH_MSTAR + +config MACH_INFINITY + bool "MStar infinity SoC support" + default ARCH_INFINITY + help + Support for MStar infinity(1/3) IP camera SoCs +endif diff --git a/arch/arm/mach-mstar/Makefile b/arch/arm/mach-mstar/Makefile new file mode 100644 index 000000000000..144b58b189e3 --- /dev/null +++ b/arch/arm/mach-mstar/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_MACH_INFINITY) += infinity.o diff --git a/arch/arm/mach-mstar/infinity.c b/arch/arm/mach-mstar/infinity.c new file mode 100644 index 000000000000..520581660bef --- /dev/null +++ b/arch/arm/mach-mstar/infinity.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device Tree support for MStar Infinity SoCs + * + * Copyright (c) 2019 thingy.jp + * Author: Daniel Palmer + */ + +#include +#include +#include +#include +#include + +/* + * The IO space is remapped to the same place + * the vendor kernel does so that the hardcoded + * addresses all over the vendor drivers line up. + */ + +#define INFINITY_IO_PHYS 0x1f000000 +#define INFINITY_IO_OFFSET 0xde000000 +#define INFINITY_IO_VIRT (INFINITY_IO_PHYS + INFINITY_IO_OFFSET) +#define INFINITY_IO_SIZE 0x00400000 + +/* + * In the u-boot code the area these registers are in is + * called "L3 bridge". + * + * It's not exactly known what is the L3 bridge 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 INFINITY_L3BRIDGE_FLUSH 0x204414 +#define INFINITY_L3BRIDGE_STATUS 0x204440 +#define INFINITY_L3BRIDGE_FLUSH_TRIGGER BIT(0) +#define INFINITY_L3BRIDGE_STATUS_DONE BIT(12) + +static void __iomem *miu_status; +static void __iomem *miu_flush; + +static struct map_desc infinity_io_desc[] __initdata = { + {INFINITY_IO_VIRT, __phys_to_pfn(INFINITY_IO_PHYS), + INFINITY_IO_SIZE, MT_DEVICE}, +}; + +static void __init infinity_map_io(void) +{ + iotable_init(infinity_io_desc, ARRAY_SIZE(infinity_io_desc)); + miu_flush = (void __iomem *)(infinity_io_desc[0].virtual + + INFINITY_L3BRIDGE_FLUSH); + miu_status = (void __iomem *)(infinity_io_desc[0].virtual + + INFINITY_L3BRIDGE_STATUS); +} + +static const char * const infinity_board_dt_compat[] = { + "mstar,infinity", + NULL, +}; + +static DEFINE_SPINLOCK(infinity_mb_lock); + +static void infinity_mb(void) +{ + unsigned long flags; + + spin_lock_irqsave(&infinity_mb_lock, flags); + /* toggle the flush miu pipe fire bit */ + writel_relaxed(0, miu_flush); + writel_relaxed(INFINITY_L3BRIDGE_FLUSH_TRIGGER, miu_flush); + while (!(readl_relaxed(miu_status) & INFINITY_L3BRIDGE_STATUS_DONE)) { + /* wait for flush to complete */ + } + spin_unlock_irqrestore(&infinity_mb_lock, flags); +} + +static void __init infinity_barriers_init(void) +{ + soc_mb = infinity_mb; +} + +static void __init infinity_init(void) +{ + infinity_barriers_init(); +} + +DT_MACHINE_START(INFINITY_DT, "MStar Infinity (Device Tree)") + .dt_compat = infinity_board_dt_compat, + .init_machine = infinity_init, + .map_io = infinity_map_io, +MACHINE_END -- 2.23.0