From patchwork Wed Sep 24 11:05:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 37804 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E3F57202DB for ; Wed, 24 Sep 2014 11:06:40 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id t60sf3441644wes.10 for ; Wed, 24 Sep 2014 04:06:40 -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=0rk9dGGNUUWucgBs6n/Wxh1+WB++c0j35bfI6JSaI9M=; b=Gk/RxNVsxVz8AWhZfPyP1a7k7VyxnGQ243266DMQcMIqFpTz3GTDVds0h5bpDaSl+Y v7OIT+HsW/LxrtvjT3nnSgU/Ac3KER+b2hkLQS0DYxzlfak67LYsJrKBP8nlTuLY+hsc JcSkqYa3Oxs9Td7xP5R/QCDLMo/UbrR9Vc6VPCVkgiCGLVTtBttxu/tDqirTrtxedAvc DG9r9ryYwDmx5ayduLmz3KosBIFTLCQD+JhsjhkRqJGSMaQpurRZxA8A05M9Eq9/d2Td Bk2i8dlQo2S2gb+Rytxn77kAdTuYzogkb9kdLBJv6o8bZvTNXPXUAutwmJcbAwtVJ40C njLQ== X-Gm-Message-State: ALoCoQkNm8FPA1/Af7Trv/nly/EHhzkPcJr5z+9gLbzaadITg9LD8kknWRl8VxGG4D2Yy1d+11lM X-Received: by 10.180.88.8 with SMTP id bc8mr1376581wib.0.1411556800145; Wed, 24 Sep 2014 04:06:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.99 with SMTP id kx3ls153620lac.7.gmail; Wed, 24 Sep 2014 04:06:39 -0700 (PDT) X-Received: by 10.112.149.36 with SMTP id tx4mr5327417lbb.79.1411556799953; Wed, 24 Sep 2014 04:06:39 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) by mx.google.com with ESMTPS id z9si22348718laa.99.2014.09.24.04.06.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Sep 2014 04:06:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id b12so10483926lbj.11 for ; Wed, 24 Sep 2014 04:06:39 -0700 (PDT) X-Received: by 10.152.22.137 with SMTP id d9mr5675854laf.29.1411556799883; Wed, 24 Sep 2014 04:06:39 -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.130.169 with SMTP id of9csp562291lbb; Wed, 24 Sep 2014 04:06:39 -0700 (PDT) X-Received: by 10.70.10.100 with SMTP id h4mr10716107pdb.162.1411556798203; Wed, 24 Sep 2014 04:06:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4si25846719pdg.39.2014.09.24.04.06.37 for ; Wed, 24 Sep 2014 04:06:38 -0700 (PDT) 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 S1753512AbaIXLF4 (ORCPT + 27 others); Wed, 24 Sep 2014 07:05:56 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:19357 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753419AbaIXLFy (ORCPT ); Wed, 24 Sep 2014 07:05:54 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NCE00KCFKAHQ470@mailout2.w1.samsung.com>; Wed, 24 Sep 2014 12:08:41 +0100 (BST) X-AuditID: cbfec7f4-b7f156d0000063c7-43-5422a58e7b27 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 9C.81.25543.E85A2245; Wed, 24 Sep 2014 12:05:50 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NCE00JS4K5ISSA0@eusync4.samsung.com>; Wed, 24 Sep 2014 12:05:50 +0100 (BST) 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 Subject: [PATCH v5 5/7] ARM: EXYNOS: Add .write_sec outer cache callback for L2C-310 Date: Wed, 24 Sep 2014 13:05:39 +0200 Message-id: <1411556741-5810-6-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1411556741-5810-1-git-send-email-m.szyprowski@samsung.com> References: <1411556741-5810-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMLMWRmVeSWpSXmKPExsVy+t/xa7p9S5VCDKYfEbF4NP8xs0Xvgqts Fmeb3rBbbO+cwW4x5c9yJotNj6+xWlzeNYfNYvaSfhaLGef3MVncvsxrcW77FhaLtUfuslu8 7lvDbLFq1x9Gi/1XvBz4PVqae9g8vn2dxOJxua+XyWPR9yyPnbPusnvcubaHzWPzknqPvi2r GD2O39jO5PF5k1wAVxSXTUpqTmZZapG+XQJXRvO7SUwFW8UqLl19wdLAuE2oi5GTQ0LARGL/ ubOsELaYxIV769m6GLk4hASWMkpse7KeGcLpY5JYMa+LCaSKTcBQouttFxuILSKQLfHj22QW kCJmgVZmicdPvoGNEhYIk7gwaS9YA4uAqsTCvevYQWxeAXeJt7/vMUOsk5P4/3IFWA2ngIfE 48f/GLsYOYC2uUs0bXKZwMi7gJFhFaNoamlyQXFSeq6hXnFibnFpXrpecn7uJkZIQH/Zwbj4 mNUhRgEORiUe3gniSiFCrIllxZW5hxglOJiVRHhf9QCFeFMSK6tSi/Lji0pzUosPMTJxcEo1 MPrN5ug+yTUrWcdin7cIZ0OSSXvJpY8iPioOYv45SQdD2WK9klYc3Tt90eXdm2rXH42QZXJw tmhbMv+BkkGNe3Bz9Z/qH4clt1vMF+XcNiV46qOF/iwX67XObFF5bWGqy8wXJTvBetYTrc2f Y+f4XZITyty10sfje9HP+addvGJ3XcmWfnT3khJLcUaioRZzUXEiAGZDwX1GAgAA 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.180 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; + } }