From patchwork Tue Jul 21 15:06:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1544 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 39BB43F08B for ; Tue, 21 Jul 2020 17:06:40 +0200 (CEST) Received: by mail-pj1-f71.google.com with SMTP id lk11sf2386251pjb.0 for ; Tue, 21 Jul 2020 08:06:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1595343999; cv=pass; d=google.com; s=arc-20160816; b=L+Jk6Vx9PSSZFNbclTK9d0gLP0d7iejQ3Wl0wxSvzf8h/31UufWQ/uk4BxyDrM/Pl5 pupvMm+9xuM+XgCCPd12ietN4fIj5LbplO4UHKjdS5wjDT78cAcdwcFDlRe+gu2xcAQK jfipPde0BRG4bp+0NjM2mHH12yYo33dnKvUMzgJqJlezFTF0uWh+IQTe9jlcYATJnEj7 fAy7lFJUecAYX/WBV9Q+hXkItueNn1hB78oM8n4eNb3rxh00s9v9GjuyBBE1EAuuaIKT ETGgW+sBx50qn1zv+OhFkG1DB6EKMQOaDc6FMsYXtnLGB6oMAq2/6kaMdTlnZH7DVPqP p+Ug== 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=dze7JBoTIBFa2x9IS275HbrELqYklRjOFH2WwftMpcA=; b=cakiC++W6q8N816jLtrCqqk3cutg1s0oe4UKTmLtuErRTPJUtMuPf4gFGGmc2t+JY2 Ls/WJNWa6tOYNNfoZcu5t7nSDFNM3pJlz8i6UcgBuBAohkEpO2uedZ4EBYWyGpeFOISj o46rkD5Fo2ZW14eKPhtBUlmAgtR38t1nbWKA1/aOHKJMY0AL6++r4Cff9Z/79EcTpO2L MWFavKO5bn7TrTY3sc710xKQckB0X+uE1Go/q/naFzIEtM9YWVidt6WtSWrrkMSQ3buj jVjXYyEK3m2a7fc664/0cbVsgXTLsvfu8k11DLu8m9UuPNPlMlSbXR+a+wSEFhMz5cER Drng== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=lrHeAS1B; 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=dze7JBoTIBFa2x9IS275HbrELqYklRjOFH2WwftMpcA=; b=S1DNBayZFuiJbyl7cnM8zM93JmKGCmKXOhd2UztV0M42iW6a93Jp1uS41DJhdI06BA OyN/49KY51474bQpLdyB+dJT72DvD9n0vE+mprQj6S0s1TrNRpIKrmMTT73CYw7IhbYM s5uSUzCCqiTNcvUfjQOgS6PWEjeeJ/a3nTKo4= 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=dze7JBoTIBFa2x9IS275HbrELqYklRjOFH2WwftMpcA=; b=tXbod49D45Km4gLM4x7ulaXDeAFHKos4WxfeGCLJ+B0JF+tSh5hKfvFxUwz4viRFdF jyQo5m4ZOYovqY7kG591wOqLFRWW9PNFLFCosLsq4cauFBEd5/AsVxb40SipSZtHsozl L5iIEk7JB1tjzLcFVh1M2tGmxDJzOTi6C1RFOCyJ1K7tFXawmJGzcI1irTXDQNm6yRnz krvIYAhsaEDTNCX9IepjkMd4ftohWq6kfARfcsEH5prw2FrolvSabWSpCL3pEccu+XHj 4WpXqx4J3X1/R4Vj/4AGmKSxOlkuJG+dO5GKskt2EVhtGx2zJgUxq8YX09UOp3MVmsAs 0A2Q== X-Gm-Message-State: AOAM530bMh72zIPRxh/zdQVFzsx32qPTjXOplC4gnXpe4yeZf1u7FQGM vWsqP6QagDsKLTbdBt4JvwUGDxTi X-Google-Smtp-Source: ABdhPJzd/tVuhB06Lb6talEi/w/NjALBdC1kct+MDCOO4nW8iHJU3ao7bavsjP13CsDadYiMtLXMcQ== X-Received: by 2002:a17:902:8a88:: with SMTP id p8mr3341317plo.184.1595343998982; Tue, 21 Jul 2020 08:06:38 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90b:384c:: with SMTP id nl12ls1651281pjb.2.canary-gmail; Tue, 21 Jul 2020 08:06:38 -0700 (PDT) X-Received: by 2002:a17:90a:ea0f:: with SMTP id w15mr5553692pjy.138.1595343998488; Tue, 21 Jul 2020 08:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595343998; cv=none; d=google.com; s=arc-20160816; b=tMjrNFF0thvWwOfq8tfQd6WLQz0UC5C+bEQZpWmKUpQ3kwYZNS72MVR+SVukRwtJWa nfTV9NsAF+Igj4sH9BrsoR5fAD10+JeQR0LaZI69PIuBsPx+55bU925pJDjPrVW60l5I xIxKLrRoVOGFDF3SoHK7+2lIU0IXvXnhiqglZfU8YatsoIKbXYlsf6sO5K05xJftYLbt HE4NiydPviO/dLHV6gM1x0SPUSfBexNVtII3HLc90en0gYEyqqMiidbbZfqSwqZxhY5c YL1JgWdWZe1N04i+aZAFJpb60MDuA96upzcOEhQDIoGgsWcC/JFJVCRbTaqYkuJ/Cqhr jdfw== 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=7Q7wRiQL57N/Sj3itjNjKceEfA3By+RqUulDOxV3jgg=; b=d5r6YY38bGU0INBNODs+Y5Z72COEdilAZ/VMu6sKVrooRWJyHeooljxQemoWK4HV4i Cl2NV+viXmLPK642xC/m8LWjk+mkgwK/WvTxGy9uFutYxIwvOYfFXiOC2YHCv9+31qkY P9Vh0+SzBWmVndvULTIrzgKTxf2JI1Hb5eNPKfIER0+FkufZe6tN4CzWgTWTkUsR1IE9 VDj3ur/NGfUypnGlbLaM9hiTc08ND8kW/lmjhW8u//Y6me+jB92Sx3iqGgyRufhX1xJU 1AjRyLkCugit7hjD3PC2VUb1ezRTu4bK5BwXr47OSc9qBnBX+kZLkBM9jkBFFpU/Vu5J aWSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=lrHeAS1B; 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 y8sor25819736plr.62.2020.07.21.08.06.38 for (Google Transport Security); Tue, 21 Jul 2020 08:06:38 -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:d352:: with SMTP id l18mr23187099plk.267.1595343998116; Tue, 21 Jul 2020 08:06:38 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:3df7:ef76:b2b5:fa14]) by smtp.gmail.com with ESMTPSA id h9sm20671276pfk.155.2020.07.21.08.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 08:06:37 -0700 (PDT) From: Jagan Teki To: Kever Yang , Philipp Tomsich , Simon Glass Cc: Suniel Mahesh , U-Boot-Denx , linux-rockchip@lists.infradead.org, linux-amarula , Jagan Teki Subject: [PATCH v6 5/5] rockchip: roc-rk3399-pc: Set LED only during POR and pwr_key=y Date: Tue, 21 Jul 2020 20:36:04 +0530 Message-Id: <20200721150604.35410-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200721150604.35410-1-jagan@amarulasolutions.com> References: <20200721150604.35410-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=lrHeAS1B; 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: , ROC-RK3399-PC has specific set of configurations for on-board led setup. Due to easiness for user to know the state of the board roc-rk339-pc board code will setup the low power led on/off, and waiting for user to press power key and then glow full power led. All this needs to happen only during power-on-reset not for soft reset or WDT. Also, it is not a proper usage to ask the user to press the Power key if the board connected remotely, so add the environment variable 'pwr_key' to check as well. So, user need to press Power key only - during POR - pwr_key=y Tested-by: Suniel Mahesh Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- Changes for v6: - increase SPL _R malloc board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 38 +++++++++++++++++++-- configs/roc-pc-mezzanine-rk3399_defconfig | 4 ++- configs/roc-pc-rk3399_defconfig | 4 ++- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c index 2b447df8aa..93e7d776fb 100644 --- a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c +++ b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c @@ -5,11 +5,15 @@ #include #include +#include #include -#include #include #include +#include + +#include #include +#include #ifndef CONFIG_SPL_BUILD int board_early_init_f(void) @@ -32,13 +36,43 @@ out: #else +#define PMUGRF_BASE 0xff320000 #define GPIO0_BASE 0xff720000 +/** + * LED setup for roc-rk3399-pc + * + * 1. Set the low power leds (only during POR, pwr_key env is 'y') + * glow yellow LED, termed as low power + * poll for on board power key press + * once powe key pressed, turn off yellow + * 2. Turn on red LED, indicating full power mode + */ void led_setup(void) { struct rockchip_gpio_regs * const gpio0 = (void *)GPIO0_BASE; + struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE; + bool press_pwr_key = false; + + if (IS_ENABLED(CONFIG_SPL_ENV_SUPPORT)) { + env_init(); + env_load(); + if (env_get_yesno("pwr_key") == 1) + press_pwr_key = true; + } + + if (press_pwr_key && !strcmp(get_reset_cause(), "POR")) { + spl_gpio_output(gpio0, GPIO(BANK_A, 2), 1); + + spl_gpio_set_pull(&pmugrf->gpio0_p, GPIO(BANK_A, 5), + GPIO_PULL_NORMAL); + while (readl(&gpio0->ext_port) & 0x20) + ; + + spl_gpio_output(gpio0, GPIO(BANK_A, 2), 0); + } - /* Turn on red LED, indicating full power mode */ spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1); } + #endif diff --git a/configs/roc-pc-mezzanine-rk3399_defconfig b/configs/roc-pc-mezzanine-rk3399_defconfig index 15d511741f..9a01de454f 100644 --- a/configs/roc-pc-mezzanine-rk3399_defconfig +++ b/configs/roc-pc-mezzanine-rk3399_defconfig @@ -19,7 +19,8 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc-mezzanine.dtb" CONFIG_DISPLAY_BOARDINFO_LATE=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y -CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 +CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20000 +CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_TPL=y CONFIG_CMD_BOOTZ=y @@ -34,6 +35,7 @@ CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc-mezzanine" CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y diff --git a/configs/roc-pc-rk3399_defconfig b/configs/roc-pc-rk3399_defconfig index 2a6d0d22c8..6181da763d 100644 --- a/configs/roc-pc-rk3399_defconfig +++ b/configs/roc-pc-rk3399_defconfig @@ -19,7 +19,8 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc.dtb" CONFIG_DISPLAY_BOARDINFO_LATE=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y -CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 +CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20000 +CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_TPL=y CONFIG_CMD_BOOTZ=y @@ -33,6 +34,7 @@ CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc" CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y