From patchwork Tue May 19 19:23:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1215 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 539133F086 for ; Tue, 19 May 2020 21:24:43 +0200 (CEST) Received: by mail-pg1-f197.google.com with SMTP id l25sf534626pgn.8 for ; Tue, 19 May 2020 12:24:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1589916282; cv=pass; d=google.com; s=arc-20160816; b=S/rkebbx2h9zO8NX14+LQ60jR1NlAnV61xhAXm64dGkAAkdorbSSAEchRVxgKb/23f 2Pvh2qakbjHvpvbri4TWiBxNAB4IDQpvQApow/m/QFd9a1vkCZOjv3tkRBFNQDUEgYzr F/VdXm5k5MIK8viwLUlxaBKXKG70wGT8hcju0etFuxZJBVyI1izZNvnxhYZhD+7/P21C V9lhC30JXj2dNlt7a60PbCVNVi0pjbTOzqGLe7VZ1uNfNGB0LXEjRIK/e0gHm4rCIkCC xbd8cwycARXyHWntW31QRU+XwfEq0a3Zdcj4RcDV89qwvXie7UJhekswbagswv5F8lao K/Ng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=nLe7zeTeSb7IrKlod5/V2rx/FIGiQ44IBUmS0v0KiuA=; b=z7EmBPVojFvLrGE9cJolYuk4dmU8Ii/U3U6wBwb7VRKEFiT9H+4sSiGuc+deAQbwII wX3vvPN8o4898z84VRpLBHY7sx41z/NSKKVk5YP++pQi/Mk9Nf42xE/GOdvsO1n3Uoaa k/ACUF3vp8XnbgtF0K09I5R/8WRFcFHihW2sevXz5U17q7rWET4ixM09UUqu6Jpsba3o ZOOl/X5RaTHuy6uLzHPgknCLbpycPRFrMWPwLHSojO8cCPLWkP69y6H9PycGq1/xYET1 wBcJUNNHIrmmW+5YbNdUPBf13fXb/cOp/W62LsZgFtGEJ1umJUstEtjQ9E5cH6ybGIlH /S2w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Kqjk1duo; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=nLe7zeTeSb7IrKlod5/V2rx/FIGiQ44IBUmS0v0KiuA=; b=qFQh7SvZ/8OVOQpbGcNxb5w63902upA44+WIB7+ywRDH2QXg4M+deYB51mwrkK46WU 81vWeR7yaTCEi76gK62AMXQ0jwyPdVhe1AnPqJje+zrYtYN/u0/pCMb5Oe5dpWyzc/pw /EyIOhaQngwzrfaXXYA5LcYF7I81X6ak18yL4= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=nLe7zeTeSb7IrKlod5/V2rx/FIGiQ44IBUmS0v0KiuA=; b=BRRk37mBSXqyprBvqBuD2V1bzAUOwX5lSNlHvtu7wF6jEKoWAiBuv6a3r5sA781JYl o9vvSyTRUZawqvTAKLNNTYLV1b7ufvaoBww4OVWvxCyzVNTIlL/wJqhmaUfVZRfDibO9 AnncA8maJf+rd5cJ/WL7M4cCXKH4kruATqwIxq4+7UPX/FJgRpooza0zOGXTeuQZkYLT WpXR0Oe8Ymdw57ZP9LX4lWHJYEzmIZELZrFxIBugl2UeR4P6WvtHzRFi3u0tjHSJSbB+ xcyylNMmML9SmPDdp4ULbb628mjuzUrRA1aI3m76VV9tybm6JWiOywo8k5EzHwma8OCC L5xA== X-Gm-Message-State: AOAM532Pj3m20Jwe0ovhTCTs4chXIw1bJI0sGaONtEfbBAdRC+SYbdJ9 ZDEKj24ZGZ1KlmctC4V9sPujJcMG X-Google-Smtp-Source: ABdhPJw8AcLtzZtcyv7sC5E7fWn643e5yuAcxv7Bu80ibI8jeYZzuvlTOCz49sZFee5TdUh1TMRdmg== X-Received: by 2002:a17:90a:9f95:: with SMTP id o21mr1102825pjp.91.1589916281897; Tue, 19 May 2020 12:24:41 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:191c:: with SMTP id z28ls153313pgl.11.gmail; Tue, 19 May 2020 12:24:41 -0700 (PDT) X-Received: by 2002:a05:6a00:46:: with SMTP id i6mr665950pfk.146.1589916281360; Tue, 19 May 2020 12:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589916281; cv=none; d=google.com; s=arc-20160816; b=MkYYJFKlvxkJy2ndAvsAovffKASUjpoauNXWrHXkYA4eTNXPY1tx5IFX6QwWIZfUvy nx/n+eImQJCqLPDN5S2ihAd9slMFA+OJP84uzAkIAyyDM6PyG7E5sjOda3XE2B4OhAOv FHL6kOxmcqHqyRHm5Zo56vksiohDNaNYOmZMd1LyShgDuTigisVgrHaxPTuOS8alL8V8 5U6Wn9Qt7c0yNQ9ruGQ5ED9vNgNqMQqSIwAm3+m8IkEZLPGWYwHn5FRQWUgvjZ6YyfD4 tAzJ1DObOu930YndMGFQpUGTAQpxunfu96eKFDmNq8kYAJWJu9w3HLCZ/RpUgl60s19I SkNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=m6tHTWPu33s92LiU+iJcaJyzN2BnUnszfQVO3bujTUk=; b=jxkQZCHpFt5PPksSFC4A2+wteKQrgTcgRJ6v0lxwdrTuSolXQsAV8RBLsNI+yNOcl/ HXJBk3E1++OQ51IIr9cYPaCQ7BHeohl5GOKYTXBIg8PJ7Bk0SyNSv9pX99fGhvhpMeDI C/ZxHgSAizVnaGdBfzZupmCzaUe0QBuK9tvRr4BC1DFKcDJIYf5/fpiUPXONR/7rhquz bml9Iv/S54+xlg5HKqiRbbgefN4eAtgETOuZURp3w4SupHainPdF2YxcKCq20yYmGHbr Uibv5/ElvjiXLd2zOliAyGChv5eyG0l3YaFWsWVgVZV4YO9NX7rLDEfT39TGHG/GtMSH lyIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Kqjk1duo; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c13sor379206plo.73.2020.05.19.12.24.41 for (Google Transport Security); Tue, 19 May 2020 12:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:bc42:: with SMTP id t2mr954438plz.233.1589916281000; Tue, 19 May 2020 12:24:41 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:713c:4a0a:47eb:ffcd]) by smtp.gmail.com with ESMTPSA id w192sm222553pff.126.2020.05.19.12.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 12:24:40 -0700 (PDT) From: Jagan Teki To: Rick Chen , Atish Patra , Palmer Dabbelt , Bin Meng , Paul Walmsley , Anup Patel , Sagar Kadam Cc: u-boot@lists.denx.de, linux-amarula@amarulasolutions.com, Jagan Teki , Mario Six , Tom Rini , Simon Glass , Jean-Jacques Hiblot Subject: [PATCH v2 4/9] drivers: Add fu540 board driver Date: Wed, 20 May 2020 00:53:35 +0530 Message-Id: <20200519192340.16624-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519192340.16624-1-jagan@amarulasolutions.com> References: <20200519192340.16624-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Kqjk1duo; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add fu540 board driver, which is used to get runtime boot mode of fu540 boards. Cc: Mario Six Cc: Tom Rini Cc: Simon Glass Cc: Jean-Jacques Hiblot Signed-off-by: Jagan Teki --- Changes for v2: - new patch drivers/board/Kconfig | 8 ++++ drivers/board/Makefile | 1 + drivers/board/fu540.c | 86 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 drivers/board/fu540.c diff --git a/drivers/board/Kconfig b/drivers/board/Kconfig index 254f657049..306ee76bbd 100644 --- a/drivers/board/Kconfig +++ b/drivers/board/Kconfig @@ -12,6 +12,14 @@ config SPL_BOARD depends on SPL_DM bool "Enable board driver support in SPL" +config BOARD_FU540 + bool "Enable board driver for the FU540 boards" + depends on RISCV + select SPL_BOARD + help + Support querying board information for the fu540 boards, like + get soc mode select, get SPL boot device and etc. + config BOARD_GAZERBEAM bool "Enable board driver for the Gazerbeam board" help diff --git a/drivers/board/Makefile b/drivers/board/Makefile index cc16361755..e924472779 100644 --- a/drivers/board/Makefile +++ b/drivers/board/Makefile @@ -3,5 +3,6 @@ # (C) Copyright 2017 # Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc obj-y += board-uclass.o +obj-$(CONFIG_BOARD_FU540) += fu540.o obj-$(CONFIG_BOARD_GAZERBEAM) += gazerbeam.o obj-$(CONFIG_BOARD_SANDBOX) += sandbox.o diff --git a/drivers/board/fu540.c b/drivers/board/fu540.c new file mode 100644 index 0000000000..68d356df6b --- /dev/null +++ b/drivers/board/fu540.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Amarula Solutions(India) + */ + +#include +#include +#include +#include +#include +#include + +#define MODE_SELECT_QSPI 0x6 +#define MODE_SELECT_SD 0xb +#define MODE_SELECT_MASK GENMASK(3, 0) + +struct fu540_board { + void __iomem *regs; +}; + +static int fu540_get_boot_device(struct udevice *dev) +{ + struct fu540_board *priv = dev_get_priv(dev); + u8 boot_device = BOOT_DEVICE_MMC1; + u32 reg; + + reg = readl(priv->regs); + switch (reg & MODE_SELECT_MASK) { + case MODE_SELECT_QSPI: + boot_device = BOOT_DEVICE_SPI; + break; + case MODE_SELECT_SD: + boot_device = BOOT_DEVICE_MMC1; + break; + default: + dev_err(dev, + "Unsupported boot device 0x%x but trying MMC1\n", + boot_device); + break; + } + + return boot_device; +} + +static int fu540_board_get_int(struct udevice *dev, int id, int *val) +{ + switch (id) { + case BOARD_SPL_BOOT_DEVICE: + *val = fu540_get_boot_device(dev); + break; + default: + dev_err(dev, "%s: Integer value %d unknown\n", dev->name, id); + return -EINVAL; + } + + return 0; +} + +static const struct board_ops fu540_board_ops = { + .get_int = fu540_board_get_int, +}; + +static int fu540_board_probe(struct udevice *dev) +{ + struct fu540_board *priv = dev_get_priv(dev); + + priv->regs = (void __iomem *)dev_read_addr(dev); + if (IS_ERR(priv->regs)) + return PTR_ERR(priv->regs); + + return 0; +} + +static const struct udevice_id fu540_board_ids[] = { + { .compatible = "sifive,fu540-modeselect", }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(fu540_board) = { + .id = UCLASS_BOARD, + .name = "fu540_board", + .of_match = fu540_board_ids, + .ops = &fu540_board_ops, + .priv_auto_alloc_size = sizeof(struct fu540_board), + .probe = fu540_board_probe, +};