From patchwork Mon Oct 27 11:05:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 39597 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EA8012118A for ; Mon, 27 Oct 2014 11:06:15 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gi9sf3935618lab.6 for ; Mon, 27 Oct 2014 04:06:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=nrbqnxswhaA0X9Ubuy4zJO6MI9degAdA2TYYvk7RmPM=; b=bnThgzTY1Luiyy2929lT+xah2xozbN+S6Qh6IzgTB8+Jkr98SCbhbxziaXXfo/pijI IG9AheHbRljezqvK3fgKXWOWxJJqs9HmeSkpP5LFfluGB9uSBg1JdRVMcX5hvUJXML9x WRpxghgfEfecVcS4dfN8+douz/L14pGEoPPkdwQ8UCjUIlPR89Op7DZvrAG+zLdDaf6d H5en44tk2GY3H00FrNJv0mGQyGEq48RLGGljv95Tby8/kVZSkDMVA0P8dHf+BqASziQB BlGsOLwBNu+Pg5MhiZnUFEAhG59wgK1mK0D5zAZrrvq66Hr/6SWBzgmpLXmJaq2qC/Vi o2ew== X-Gm-Message-State: ALoCoQmNSimzNAPXnAcriLV7rpHdM+xeM9e8wXH00WkchexI+F4B6JDJ/gyMRzhHbeKxZNEBnjhW X-Received: by 10.194.58.47 with SMTP id n15mr2023549wjq.0.1414407974761; Mon, 27 Oct 2014 04:06:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.229 with SMTP id h5ls720278lam.4.gmail; Mon, 27 Oct 2014 04:06:14 -0700 (PDT) X-Received: by 10.152.198.166 with SMTP id jd6mr21698555lac.81.1414407974549; Mon, 27 Oct 2014 04:06:14 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id lk6si19373578lac.74.2014.10.27.04.06.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Oct 2014 04:06:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id w7so867381lbi.10 for ; Mon, 27 Oct 2014 04:06:14 -0700 (PDT) X-Received: by 10.152.120.199 with SMTP id le7mr22402408lab.67.1414407974282; Mon, 27 Oct 2014 04:06:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp267857lbz; Mon, 27 Oct 2014 04:06:13 -0700 (PDT) X-Received: by 10.68.197.4 with SMTP id iq4mr941834pbc.137.1414407972430; Mon, 27 Oct 2014 04:06:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pd10si10333414pac.16.2014.10.27.04.06.11 for ; Mon, 27 Oct 2014 04:06:12 -0700 (PDT) Received-SPF: none (google.com: linux-omap-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752198AbaJ0LGH (ORCPT + 5 others); Mon, 27 Oct 2014 07:06:07 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:14311 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752056AbaJ0LGC (ORCPT ); Mon, 27 Oct 2014 07:06:02 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NE300AZZOALSS10@mailout4.w1.samsung.com>; Mon, 27 Oct 2014 11:08:45 +0000 (GMT) X-AuditID: cbfec7f4-b7f6c6d00000120b-6d-544e271668e8 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id E1.4F.04619.6172E445; Mon, 27 Oct 2014 11:05:58 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NE300JBOO5RPJ10@eusync2.samsung.com>; Mon, 27 Oct 2014 11:05:58 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Tomasz Figa , Kyungmin Park , Russell King - ARM Linux , Kukjin Kim , lauraa@codeaurora.org, linux-omap@vger.kernel.org, linus.walleij@linaro.org, santosh.shilimkar@ti.com, tony@atomide.com, drake@endlessm.com, loeliger@gmail.com, Mark Rutland Subject: [PATCH v6 5/7] ARM: EXYNOS: Add .write_sec outer cache callback for L2C-310 Date: Mon, 27 Oct 2014 12:05:48 +0100 Message-id: <1414407950-3029-6-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1414407950-3029-1-git-send-email-m.szyprowski@samsung.com> References: <1414407950-3029-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLLMWRmVeSWpSXmKPExsVy+t/xK7pi6n4hBi/XW1o8mv+Y2aJ3wVU2 i7NNb9gttnfOYLeY8mc5k8Wmx9dYLS7vmsNmMXtJP4vFjPP7mCxuX+a1OLd9C4vF2iN32S2W Xr/IZPG6bw2zxapdfxgt9l/xchDwWDNvDaNHS3MPm8e3r5NYPC739TJ5LPqe5bFz1l12jzvX 9rB5bF5S79G3ZRWjx/Eb25k8Pm+SC+CO4rJJSc3JLEst0rdL4MpofjeJqWCrWMWlqy9YGhi3 CXUxcnJICJhI7D//ih3CFpO4cG89WxcjF4eQwFJGifYprSwgCSGBPiaJi1f8QWw2AUOJrrdd bCC2iEC2xI9vk1lAGpgFVjFLTDmwjhUkISwQJrHh5WxGEJtFQFXi5PVOsDivgLvEviWzmSC2 yUn8f7kCzOYU8JCY3DKTCWKZu8SqD3sZJzDyLmBkWMUomlqaXFCclJ5rqFecmFtcmpeul5yf u4kREuRfdjAuPmZ1iFGAg1GJh3fHNN8QIdbEsuLK3EOMEhzMSiK8jj+BQrwpiZVVqUX58UWl OanFhxiZODilGhib3IUmbzxnLcbHuVzs6rM738xDTj3Kk4n6krd4f0KlaMD3OIcFfxtSpy92 l3g6XfSZuA2HfuC52Say2xdrhvMUuyve7Iuoy2x65XZrzt/EW46d6xxttS4GcN154XSpYkmc v2ZEj927UPf9NteLgvima5u8uvSv4qTuPFsJMYEqlnaHD0+im5VYijMSDbWYi4oTAS3szsJQ AgAA Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tomasz Figa Exynos4 SoCs equipped with an L2C-310 cache controller and running under secure firmware require certain registers of aforementioned IP to be accessed only from secure mode. This means that SMC calls are required for certain register writes. To handle this, an implementation of .write_sec and .configure callbacks is provided by this patch. Signed-off-by: Tomasz Figa [added comment and reworked unconditional call to SMC_CMD_L2X0INVALL] Signed-off-by: Marek Szyprowski --- arch/arm/mach-exynos/firmware.c | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/arch/arm/mach-exynos/firmware.c b/arch/arm/mach-exynos/firmware.c index f5e626d55951..e6a052c593f2 100644 --- a/arch/arm/mach-exynos/firmware.c +++ b/arch/arm/mach-exynos/firmware.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -120,6 +121,43 @@ static const struct firmware_ops exynos_firmware_ops = { .resume = exynos_resume, }; +static void exynos_l2_write_sec(unsigned long val, unsigned reg) +{ + static int l2cache_enabled; + + switch (reg) { + case L2X0_CTRL: + if (val & L2X0_CTRL_EN) { + /* + * Before the cache can be enabled, due to firmware + * design, SMC_CMD_L2X0INVALL must be called. + */ + if (!l2cache_enabled) { + exynos_smc(SMC_CMD_L2X0INVALL, 0, 0, 0); + l2cache_enabled = 1; + } + } else { + l2cache_enabled = 0; + } + exynos_smc(SMC_CMD_L2X0CTRL, val, 0, 0); + break; + + case L2X0_DEBUG_CTRL: + exynos_smc(SMC_CMD_L2X0DEBUG, val, 0, 0); + break; + + default: + WARN_ONCE(1, "%s: ignoring write to reg 0x%x\n", __func__, reg); + } +} + +static void exynos_l2_configure(const struct l2x0_regs *regs) +{ + exynos_smc(SMC_CMD_L2X0SETUP1, regs->tag_latency, regs->data_latency, + regs->prefetch_ctrl); + exynos_smc(SMC_CMD_L2X0SETUP2, regs->pwr_ctrl, regs->aux_ctrl, 0); +} + void __init exynos_firmware_init(void) { struct device_node *nd; @@ -139,4 +177,16 @@ void __init exynos_firmware_init(void) pr_info("Running under secure firmware.\n"); register_firmware_ops(&exynos_firmware_ops); + + /* + * Exynos 4 SoCs (based on Cortex A9 and equipped with L2C-310), + * running under secure firmware, require certain registers of L2 + * cache controller to be written in secure mode. Here .write_sec + * callback is provided to perform necessary SMC calls. + */ + if (IS_ENABLED(CONFIG_CACHE_L2X0) + && read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) { + outer_cache.write_sec = exynos_l2_write_sec; + outer_cache.configure = exynos_l2_configure; + } }