From patchwork Wed Nov 8 03:24:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 118210 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4767040qgn; Tue, 7 Nov 2017 19:26:15 -0800 (PST) X-Google-Smtp-Source: ABhQp+RkuPk3dbcUMY5jzZLcnN787PqMzlzUGnUM8ev6+cxQmxNQed1XZhzofdUngr1UOx0bGXdb X-Received: by 10.129.110.133 with SMTP id j127mr527580ywc.305.1510111575074; Tue, 07 Nov 2017 19:26:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510111575; cv=none; d=google.com; s=arc-20160816; b=Rf/r9zwIPox9IjV57UXqwFMsdXC8WIwHqdWbZ2mQ6IXDSqi4XR+ZP/KEwcqPBTdqgT MMUpPgLMjfOT3wVuULjVP08pUV8cZTyDF4y948niPWJX8CTiFigx1ChjFVdsXFSGqe4D JEsFKDgUURca8bpCirHq5BhkbFWUhmf7cNV4cXo0voMjVWLRATxIf5XD3d4yAKUt4Pt0 /foarwav4LPpQ9W0m8o2hzf6szE1genXux64KVIX1+xZMRYFUsWSwrCZxw2stxckesXv NgaUbpRIF1Fv/xBj4EsPYs+BWbkOPhU+32TqdlO4xhT/LZ3BZ95Okdq2YViVJ3E9VbkU SftQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=V3cclVfuC7oFwvi3lVmvbGi6mkgo5Q16+v9Za8vT3I8=; b=Ox+QROJbfOiogK+lw6uJbXosixgkvEfA20Pf+vlk+M8p6cqiRZkOHZOZvsOebnrmMy apitFkH1aqAOSQhReEgZTPhzy6Hkg8zstHusrWb4as5j5FgsZSDgnbi9uImLrqfhJOy7 qCApk3zVg3n7H5jbTMu3eG2d8SS+qQKikNDjV3rPVEQH9ybch0f3N4EAYke5euHEx+GR ZZjepnFcgn+uU7yuhnUz5z6Evlva2fwOJPNpKgn61oLFMt14q/3U6IMNoCUpFtovCgTa x9AJTK2nQ+fTY1weg77UnlSpcNsBdWmzTOqOPgGaZFc7msoPNsatDu1ULjWdMu1ik1BW Fkow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UXq3le01; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p19si644465ywg.170.2017.11.07.19.26.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 07 Nov 2017 19:26:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UXq3le01; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:57121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCH0I-0005HI-KW for patch@linaro.org; Tue, 07 Nov 2017 22:26:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCGz5-0004sj-BD for qemu-devel@nongnu.org; Tue, 07 Nov 2017 22:25:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCGz4-00008R-Ac for qemu-devel@nongnu.org; Tue, 07 Nov 2017 22:24:59 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:48492) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eCGyx-00004y-JA; Tue, 07 Nov 2017 22:24:51 -0500 Received: by mail-pg0-x241.google.com with SMTP id v78so971501pgb.5; Tue, 07 Nov 2017 19:24:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=V3cclVfuC7oFwvi3lVmvbGi6mkgo5Q16+v9Za8vT3I8=; b=UXq3le01nR/HHI2lisCDRrtF+OTs0dLJEdcy+lUGrynCqGGcWbvuOh8S5ht1NhUzcy 7LIRoxbr73j56bvRgh6/U8ux1cqnmNaCRPNMlZNxGs8j0bRUUiVJ3O4TDia5oD4DffDd wJqK7jJu36csYUspqk5nmUq4BqU92UZvFjMnzp0foDejWoPKKAlPDOs+9/V52u+UfBde S9BQ34yBnExyCrhWXzQuLooqvG9Kcg8j6pD8VIBH5y7ISqgUdi0bkHBD6AUmsmcDfhXN elhcYfVkN8q7fGP9sSZaLextHIYbOwo8ZcwCJt3VgNCwWa6cXzl1WO0R8qRvI8Kah54L Nw0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=V3cclVfuC7oFwvi3lVmvbGi6mkgo5Q16+v9Za8vT3I8=; b=Ie0R5YVNu0WRrZh7k/J5ZvxowSQLe09eeewbXAOa1cKcgyLwPCGkQsQl5XAk/WBCYX QqQEZVm/SJQmbewpfy8rfmF+HduziPzucHQxHoXMTITH5bXeOnoEwmHIYMdkU20w2T8N YJGuLID3pEcsm4DzW7RMOdk/hKoh+0pQv7LN7RGn41LtxvezEYzHlLWhBrPbjiAnLBza zPvsofo4JVCSeJBlqgkuqx55taTY1T8hm328a3T7qv+ZrVZxFDZqVqojGNTUclVdhhEH bkyna1JtmEAD2FXd7cvKo/APZD7/Z28JMS7eIvo8y4C312q20nc+GlanubHkjvHpAqIr AUgg== X-Gm-Message-State: AJaThX76JqDF/mJfAmfy5AP4Ia6dZO5jzuNCt54J1FahFFw9x9t/dqnS n0S4zLY5B0QaN/Al5gMJ7tg= X-Received: by 10.101.82.193 with SMTP id z1mr867294pgp.312.1510111489849; Tue, 07 Nov 2017 19:24:49 -0800 (PST) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id c1sm4995739pfa.12.2017.11.07.19.24.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2017 19:24:48 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Wed, 08 Nov 2017 13:54:41 +1030 From: Joel Stanley To: Peter Maydell Date: Wed, 8 Nov 2017 13:54:27 +1030 Message-Id: <20171108032427.11163-1-joel@jms.id.au> X-Mailer: git-send-email 2.14.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH] hw/arm/aspeed: Unlock SCU when running kernel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jeffery , qemu-arm@nongnu.org, qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The ASPEED hardware contains a lock register for the SCU that disables any writes to the SCU when it is locked. The machine comes up with the lock enabled, but on all known hardware u-boot will unlock it and leave it unlocked when loading the kernel. This means the kernel expects the SCU to be unlocked. When booting from an emulated ROM the normal u-boot unlock path is executed. Things don't go well when booting using the -kernel command line, as u-boot does not run first. Change behaviour so that when a kernel is passed to the machine, set the reset value of the SCU to be unlocked. Signed-off-by: Joel Stanley --- hw/arm/aspeed.c | 10 ++++++++++ hw/arm/aspeed_soc.c | 2 ++ hw/misc/aspeed_scu.c | 2 ++ hw/misc/aspeed_sdmc.c | 1 - include/hw/misc/aspeed_scu.h | 1 + include/hw/misc/aspeed_sdmc.h | 2 ++ 6 files changed, 17 insertions(+), 1 deletion(-) -- 2.14.1 diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index ab895ad490af..179ee66624b9 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -36,6 +36,7 @@ typedef struct AspeedBoardState { typedef struct AspeedBoardConfig { const char *soc_name; uint32_t hw_strap1; + uint32_t hw_prot_key; const char *fmc_model; const char *spi_model; uint32_t num_cs; @@ -186,6 +187,15 @@ static void aspeed_board_init(MachineState *machine, &error_abort); object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", &error_abort); + if (machine->kernel_filename) { + /* + * When booting with a -kernel command line there is no u-boot + * that runs to unlock the SCU. In this case set the default to + * be unlocked as the kernel expects + */ + object_property_set_int(OBJECT(&bmc->soc), PROT_KEY_UNLOCK, + "hw-prot-key", &error_abort); + } object_property_set_bool(OBJECT(&bmc->soc), true, "realized", &error_abort); diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index 5aa3d2ddd9cd..c83b7e207b86 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -154,6 +154,8 @@ static void aspeed_soc_init(Object *obj) "hw-strap1", &error_abort); object_property_add_alias(obj, "hw-strap2", OBJECT(&s->scu), "hw-strap2", &error_abort); + object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu), + "hw-prot-key", &error_abort); object_initialize(&s->fmc, sizeof(s->fmc), sc->info->fmc_typename); object_property_add_child(obj, "fmc", OBJECT(&s->fmc), NULL); diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c index 95022d3607ad..c71e77729581 100644 --- a/hw/misc/aspeed_scu.c +++ b/hw/misc/aspeed_scu.c @@ -246,6 +246,7 @@ static void aspeed_scu_reset(DeviceState *dev) s->regs[SILICON_REV] = s->silicon_rev; s->regs[HW_STRAP1] = s->hw_strap1; s->regs[HW_STRAP2] = s->hw_strap2; + s->regs[PROT_KEY] = s->hw_prot_key; } static uint32_t aspeed_silicon_revs[] = { @@ -299,6 +300,7 @@ static Property aspeed_scu_properties[] = { DEFINE_PROP_UINT32("silicon-rev", AspeedSCUState, silicon_rev, 0), DEFINE_PROP_UINT32("hw-strap1", AspeedSCUState, hw_strap1, 0), DEFINE_PROP_UINT32("hw-strap2", AspeedSCUState, hw_strap2, 0), + DEFINE_PROP_UINT32("hw-prot-key", AspeedSCUState, hw_prot_key, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c index f0b3053fae36..35dc803604f8 100644 --- a/hw/misc/aspeed_sdmc.c +++ b/hw/misc/aspeed_sdmc.c @@ -18,7 +18,6 @@ /* Protection Key Register */ #define R_PROT (0x00 / 4) -#define PROT_KEY_UNLOCK 0xFC600309 /* Configuration Register */ #define R_CONF (0x04 / 4) diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h index bd4ac013f997..f5da54e27105 100644 --- a/include/hw/misc/aspeed_scu.h +++ b/include/hw/misc/aspeed_scu.h @@ -29,6 +29,7 @@ typedef struct AspeedSCUState { uint32_t silicon_rev; uint32_t hw_strap1; uint32_t hw_strap2; + uint32_t hw_prot_key; } AspeedSCUState; #define AST2400_A0_SILICON_REV 0x02000303U diff --git a/include/hw/misc/aspeed_sdmc.h b/include/hw/misc/aspeed_sdmc.h index 551c8afdf4be..a1b3232c5ef3 100644 --- a/include/hw/misc/aspeed_sdmc.h +++ b/include/hw/misc/aspeed_sdmc.h @@ -16,6 +16,8 @@ #define ASPEED_SDMC_NR_REGS (0x8 >> 2) +#define PROT_KEY_UNLOCK 0xFC600309 + typedef struct AspeedSDMCState { /*< private >*/ SysBusDevice parent_obj;