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=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 9C1E5C433F5 for ; Tue, 21 Sep 2021 01:12:43 +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 D9294610A1 for ; Tue, 21 Sep 2021 01:12:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D9294610A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org 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 268528328D; Tue, 21 Sep 2021 03:12:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mK/gm1N/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C51783278; Tue, 21 Sep 2021 03:12:01 +0200 (CEST) Received: from mail-vs1-xe29.google.com (mail-vs1-xe29.google.com [IPv6:2607:f8b0:4864:20::e29]) (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 9BCEC8325E for ; Tue, 21 Sep 2021 03:11:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-vs1-xe29.google.com with SMTP id o124so18565610vsc.6 for ; Mon, 20 Sep 2021 18:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZllIbi6JNL2QHBWoEMY7jTCpkgFQt+oo/WEZf1IkN3s=; b=mK/gm1N/P65bCk1nApC3ql1zvoQfDoyY0/pH52eL10zZoYyHN/1pOyRQwstWpO/2Vj ZXt0hAiXW5wvXBq9VcqTiVE1IRGhyHaQc//LVTfn/tNhWNTqNCvAGE0fCNarCM3WFqY4 iKBEaMPPdAGyMg3BY0sOYYekPdbJkakd4beqM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZllIbi6JNL2QHBWoEMY7jTCpkgFQt+oo/WEZf1IkN3s=; b=cvmEd0jeO51zcQkxOQJB8Lg+mRomoAfe6bHxfGD4Mss3FAd6h9AQO3c6aV5M5G01jt Bb+mC1eeEps5tbaEZC79dmOIxxXPWUzKBNx875aj/Wfgr7PMG5osHhwbKH62+fFVzYXD Lnq4zmbb+v2ebal2YnezFpo7v5yTVbQ+WxGX/bYB49GO9jBOHX4wF4KA4mHEc1jcR/Vf t4h6jJUXT06cClVlFFpzfpQ8stsHfJwobl/ZCj9WpfwB/WMDs6HcqAoDnFHqdKRftpnq cVu2/RN5uWv1eqZd6h2Xy/XT2JDZZicqDlyPqkWPdQa+qlcQLI/V/b+DN1cNBfFzN4AI NKTg== X-Gm-Message-State: AOAM533gbSYSHizZIyji0+uLXEl/GlrIZItu5kR9E58DOBIOVsc7dcpj MNayJkUIAfX/nEohAlH95RzdfX2ECBtcTJNFyX5JFw== X-Google-Smtp-Source: ABdhPJwtot3Os8dEPH1qw/Zmz7OJ3zshGkb6lLU82wq4NncRaoAix5nslEZYSTl7jdDVwg6XrC5esg8l9SLMlII5NL8= X-Received: by 2002:a05:6102:3a59:: with SMTP id c25mr18021180vsu.15.1632186695833; Mon, 20 Sep 2021 18:11:35 -0700 (PDT) MIME-Version: 1.0 References: <20210918135437.36667-1-kettenis@openbsd.org> <20210918135437.36667-2-kettenis@openbsd.org> <56146ded1ff993a7@bloch.sibelius.xs4all.nl> In-Reply-To: <56146ded1ff993a7@bloch.sibelius.xs4all.nl> From: Simon Glass Date: Mon, 20 Sep 2021 19:11:24 -0600 Message-ID: Subject: Re: [PATCH 1/5] arm: apple: Add initial support for Apple's M1 SoC To: Mark Kettenis Cc: Mark Kettenis , U-Boot Mailing List , Bharat Gooty , Rayagonda Kokatanur , Oliver Graute , Bin Meng , Leo Liang , Tianrui Wei , Stephan Gerhold , Padmarao Begari , Kishon Vijay Abraham I , Heinrich Schuchardt , Michael Walle , Masami Hiramatsu , Asherah Connor , Wasim Khan , Michal Simek , Igor Opaniuk , Heiko Schocher , Ye Li , Stefan Roese , Vabhav Sharma , =?UTF-8?B?TWFyZWsgQmVow7pu?= , Weijie Gao , AKASHI Takahiro , Andy Shevchenko , Pratyush Yadav Content-Type: text/plain; charset="UTF-8" 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 Hi Mark, On Mon, 20 Sept 2021 at 02:49, Mark Kettenis wrote: > > > From: Simon Glass > > Date: Sun, 19 Sep 2021 21:15:57 -0600 > > > > Hi Mark, > > > > On Sat, 18 Sept 2021 at 07:55, Mark Kettenis wrote: > > > > > > Add support for Apple's M1 SoC that is used in "Apple Silicon" > > > Macs. This builds a basic U-Boot that can be used as a payload > > > for the m1n1 boot loader being developed by the Asahi Linux > > > project. > > > > > > Signed-off-by: Mark Kettenis > > > --- > > > arch/arm/Kconfig | 22 ++++ > > > arch/arm/Makefile | 1 + > > > arch/arm/mach-apple/Kconfig | 18 ++++ > > > arch/arm/mach-apple/Makefile | 4 + > > > arch/arm/mach-apple/board.c | 158 ++++++++++++++++++++++++++++ > > > arch/arm/mach-apple/lowlevel_init.S | 16 +++ > > > configs/apple_m1_defconfig | 14 +++ > > > include/configs/apple.h | 38 +++++++ > > > 8 files changed, 271 insertions(+) > > > create mode 100644 arch/arm/mach-apple/Kconfig > > > create mode 100644 arch/arm/mach-apple/Makefile > > > create mode 100644 arch/arm/mach-apple/board.c > > > create mode 100644 arch/arm/mach-apple/lowlevel_init.S > > > create mode 100644 configs/apple_m1_defconfig > > > create mode 100644 include/configs/apple.h > > > > > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > > > index b5bd3284cd..7cdea1f615 100644 > > > --- a/arch/arm/Kconfig > > > +++ b/arch/arm/Kconfig > > > @@ -895,6 +895,26 @@ config ARCH_NEXELL > > > select DM > > > select GPIO_EXTRA_HEADER > > > > > > +config ARCH_APPLE > > > + bool "Apple SoCs" > > > + select ARM64 > > > + select LINUX_KERNEL_IMAGE_HEADER > > > + select POSITION_INDEPENDENT > > > + select BLK > > > + select DM > > > + select DM_KEYBOARD > > > + select DM_SERIAL > > > + select DM_USB > > > + select DM_VIDEO > > > + select CMD_USB > > > + select MISC > > > + select OF_CONTROL > > > + select OF_BOARD > > > + select USB > > > + imply CMD_DM > > > + imply CMD_GPT > > > + imply DISTRO_DEFAULTS > > > > Suggest sorting these > > As in sort all the selects alphabetically and sort all the implies > alphabetically seperately? I suppose so. > > Does my use of impy here even make sense? It allows people to disable it, whereas select does not. It looks OK to me. > > This whole Kconfig stuff is a bit alien to me and I must say that it > isn't obvious what "best-practice" is in this area... We try to avoid select so only use it if it really cannot build/run without that feature. From what I can tell you have done that. I know this is a different project, but there are some ideas here: https://docs.zephyrproject.org/1.14.0/guides/kconfig/index.html [..] > > > +int dram_init(void) > > > +{ > > > + int index, node, ret; > > > + fdt_addr_t base; > > > + fdt_size_t size; > > > + > > > + ret = fdtdec_setup_mem_size_base(); > > > + if (ret) > > > + return ret; > > > + > > > + /* Update RAM mapping. */ > > > > Do you want the period at the end of that? > > Given that Bin brought up the same thing, I gather that not having a > full stop at the end of single-line comments is preferred? Yes, the periods just clutter things and people start adding them only when it is a valid sentence, etc. Best to just leave them out. > > > > + index = ARRAY_SIZE(apple_mem_map) - 3; > > > + apple_mem_map[index].virt = gd->ram_base; > > > + apple_mem_map[index].phys = gd->ram_base; > > > + apple_mem_map[index].size = gd->ram_size; > > > + > > > + node = fdt_path_offset(gd->fdt_blob, "/chosen/framebuffer"); > > > > Can you use the ofnode interface here and below? > > I can try... Something like: ofnode node; node = ofnode_path("/chosen/framebuffer"); then use ofnode_get_addr_size() > > > > + if (node < 0) > > > + return 0; > > > + > > > + base = fdtdec_get_addr_size(gd->fdt_blob, node, "reg", &size); > > > + if (base == FDT_ADDR_T_NONE) > > > + return 0; > > > + > > > + /* Add framebuffer mapping. */ > > > + index = ARRAY_SIZE(apple_mem_map) - 2; > > > + apple_mem_map[index].virt = base; > > > + apple_mem_map[index].phys = base; > > > + apple_mem_map[index].size = size; > > > + apple_mem_map[index].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) | > > > + PTE_BLOCK_INNER_SHARE | PTE_BLOCK_PXN | PTE_BLOCK_UXN; > > > + > > > + return 0; > > > +} [..] > > > diff --git a/arch/arm/mach-apple/lowlevel_init.S b/arch/arm/mach-apple/lowlevel_init.S > > > new file mode 100644 > > > index 0000000000..0f5313163e > > > --- /dev/null > > > +++ b/arch/arm/mach-apple/lowlevel_init.S > > > @@ -0,0 +1,16 @@ > > > +/* SPDX-License-Identifier: GPL-2.0+ */ > > > +/* > > > + * (C) Copyright 2021 Mark Kettenis > > > + */ > > > + > > > +.align 8 > > > +.global fw_dtb_pointer > > > +fw_dtb_pointer: > > > + .quad 0 > > > + > > > +.global save_boot_params > > > +save_boot_params: > > > + adr x1, fw_dtb_pointer > > > > could use a comment as to where this is set up. Previous-stage > > firmware, I suppose? > > Yes. I'm basically making U-Boot look like a Linux kernel, and m1n1 > passes the DT in x1 just like the Linux kernel expects. > > I suspect using CONFIG_OF_PRIOR_STAGE would make it more obvious what > is happening here. But (a) I didn't know that existed and (b) we > discussed removing that option in the near future. That sounds right to me, but a comment would help. Regards, Simon