From patchwork Thu Nov 13 13:18:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 40764 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C6AF8240ED for ; Thu, 13 Nov 2014 13:20:00 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf8008172lbj.3 for ; Thu, 13 Nov 2014 05:19:59 -0800 (PST) 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=tdra32UGeEkt2uxsMqVqi8RFgVb97nn6EmbkO7WLsXU=; b=DbNCZIgxa2rb1I+My///Kw3nd/KKqBvDLaGgDjoMu4B49HauW5puDc1ij2iCdb2bMq VBpXviAMhwTcXER9+AMknvroJqIT7iinJBRc2H3wywnC8PrdbHo/DFdoqxUq37gT1ciq Dz3CMe/HN8Nl0SsGB3AWgX1vyKx1bRN00nWXhC8Vg/Qw9579VgRhU5RFabMZf7/UHV23 OZKNHSkjr061NyoPzTRrlbvFeJorU7G2EKgkJdR7+jwmh2aaniKi5NiAQAFKle5SmLTA 5RGSyYFBlYr0Dq0efVr4G2s8Vr5lJSgtNeNd77WBlhWJ2DVwf4HFdIUxXfyZrf4wAnTo 075Q== X-Gm-Message-State: ALoCoQm/ZYkRUXVUXE4nbz0XmDHKD0I7xryEjV+VOz1OwMPXz2FGErfu6lS6aK5edktueQQUHScq X-Received: by 10.112.48.98 with SMTP id k2mr414539lbn.15.1415884799792; Thu, 13 Nov 2014 05:19:59 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.7 with SMTP id i7ls828657lam.107.gmail; Thu, 13 Nov 2014 05:19:59 -0800 (PST) X-Received: by 10.112.172.97 with SMTP id bb1mr2438067lbc.38.1415884799614; Thu, 13 Nov 2014 05:19:59 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id p8si38433205lag.62.2014.11.13.05.19.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Nov 2014 05:19:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id f15so12246616lbj.27 for ; Thu, 13 Nov 2014 05:19:59 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr2388618lbr.74.1415884799490; Thu, 13 Nov 2014 05:19:59 -0800 (PST) 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.184.201 with SMTP id ew9csp587355lbc; Thu, 13 Nov 2014 05:19:58 -0800 (PST) X-Received: by 10.67.29.232 with SMTP id jz8mr2552675pad.25.1415884797625; Thu, 13 Nov 2014 05:19:57 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ng11si19971246pdb.165.2014.11.13.05.19.56 for ; Thu, 13 Nov 2014 05:19:57 -0800 (PST) Received-SPF: none (google.com: linux-kernel-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 S933128AbaKMNTi (ORCPT + 26 others); Thu, 13 Nov 2014 08:19:38 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:48479 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932887AbaKMNS0 (ORCPT ); Thu, 13 Nov 2014 08:18:26 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NEZ0035VBRIKU40@mailout1.w1.samsung.com>; Thu, 13 Nov 2014 13:21:18 +0000 (GMT) X-AuditID: cbfec7f5-b7f956d000005ed7-3e-5464afa0019f Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 02.C0.24279.0AFA4645; Thu, 13 Nov 2014 13:18:24 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NEZ00I3CBMFKS20@eusync1.samsung.com>; Thu, 13 Nov 2014 13:18:24 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marek Szyprowski , Tomasz Figa , Kyungmin Park , linux-samsung-soc@vger.kernel.org, Arnd Bergmann , Olof Johansson , Russell King - ARM Linux , Kukjin Kim , lauraa@codeaurora.org, linux-omap@vger.kernel.org, linus.walleij@linaro.org, tony@atomide.com, drake@endlessm.com, loeliger@gmail.com, Mark Rutland Subject: [PATCH v8 5/7] ARM: EXYNOS: Add .write_sec outer cache callback for L2C-310 Date: Thu, 13 Nov 2014 14:18:12 +0100 Message-id: <1415884694-5868-6-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1415884694-5868-1-git-send-email-m.szyprowski@samsung.com> References: <1415884694-5868-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsVy+t/xy7oL1qeEGKx6LG7xd9IxdotH8x8z W/QuuMpmcbbpDbvF9s4Z7BZT/ixnstj0+BqrxeVdc9gsZi/pZ7GYcX4fk8Xty7wW57ZvYbFY e+Quu8XS6xeZLE5d/8xmsWrXH0aL/Ve8HAQ91sxbw+jR0tzD5vH71yRGj29fJ7F4XO7rZfJY 9D3LY+esu+wed67tYfPYvKTe48qJJlaPvi2rGD0+b5IL4InisklJzcksSy3St0vgypj9Yg5T wROximlLlBoYHwp1MXJwSAiYSGxdG9jFyAlkiklcuLeeDcQWEljKKPHkoVIXIxeQ3cck0ff9 BViCTcBQouttF5gtIuAm8W/dITaQImaBz8wSlx6tYQVJCAuESTRMn8MOYrMIqEp8O/UFLM4r 4C7xeNZ3ZohtchL/X65gArE5BTwkvqz/wwqx2V2ifddhxgmMvAsYGVYxiqaWJhcUJ6XnGukV J+YWl+al6yXn525ihAT91x2MS49ZHWIU4GBU4uH9wJ0SIsSaWFZcmXuIUYKDWUmE981KoBBv SmJlVWpRfnxRaU5q8SFGJg5OqQbGayy2E27KKLDY+JiuFu77ycj+3ExNwqB4W8KltIWqdb+3 pBv8FFly5FO94jOX/K5p099432kO27l9/oVi5vM3+psZvBqka36vadbvSTp7/TaHquI1CacO j83pE1qnRKTfyf8TEufGsf3CE64zr512PK/euNex7qT776oyp9mpq3IkvE9q8SQqsRRnJBpq MRcVJwIAFBEVrVgCAAA= Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.182 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 766f57d2f029..dc5ae53aa317 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 @@ -136,6 +137,43 @@ static const struct firmware_ops exynos_firmware_ops = { .resume = IS_ENABLED(CONFIG_EXYNOS_CPU_SUSPEND) ? exynos_resume : NULL, }; +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; @@ -155,4 +193,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; + } }