Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 04 Feb 2016 03:15:20 +0100 (CET) Received: from mail-pf0-f170.google.com ([209.85.192.170]:36529 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S27012458AbcBDCPDjuCrx (ORCPT ); Thu, 4 Feb 2016 03:15:03 +0100 Received: by mail-pf0-f170.google.com with SMTP id n128so26675751pfn.3; Wed, 03 Feb 2016 18:15:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xpIpEzYLUxKB6Xgo0QXD0Qm3h1YTJeJvw2FylkIluTk=; b=CRY3e+aTIR34ioleWM/7R1L90z796jRGKOpQrsohYBS6VwtHesfkP8dmliPivNjUh+ q47GT5fR9xmIOP1bi/aBH3aZzKNVRy3ICOFVcFHe7eQN+zFynmFtgj9vDDzhYd/1NIq9 Na3kmqD6bGTdxBCbhBJpQ9EGtw2u4Wlg4a88bAxcaDrhb5FWIZMsJIPOYLo6ol1XJKAx 13t097qbGYZC/qbTfkU/Hvlk8C/KcYRJx42eBJWUCyZpMpYUtuSj42w68fIn8NyT2DPk /GaKmF5EFWVK3ly6qlD279gOwYdbEF7C07XdflLjwj2ZqIX7tRsg1H6kE2DydirAdGlV iCjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xpIpEzYLUxKB6Xgo0QXD0Qm3h1YTJeJvw2FylkIluTk=; b=c3YB5El7ECa5WIerjqTybuhXL3bSlbXyvOzEv6kVJHLQWk0Dm2r9n7gqN4ngSKBsQV TqihcV/JOmKAamRuJZLxN3YULfwAXE13IS5bNhpv3Z97JrkbFnwAaN1hppPvw3J1KWCd ig1kCgG93xqKis63m5ZWAmm38hSST5IZx4TajnDt9Cwp94miQjgZz00woCWmFqgedHQq JemyXNkd/lg1vQQI7meKmYEQ042Q0UXzI2MjcKYRgRBFn7lNrZ+MLlrZYFzmVAvm9QQ6 gZLStpOvbZwW5A3K8qvK2fOZtIyk1LedaahmrO5c5RI8puzC8T3wuHeiUWsMGDaGczkH G1Yg== X-Gm-Message-State: AG10YORDb+OKU/HbbkiMpyAN+44bferEkNtR0y5GV++HVozrZ4PNGT+8VJeiZiolt8sXew== X-Received: by 10.98.42.74 with SMTP id q71mr7283976pfq.18.1454552097770; Wed, 03 Feb 2016 18:14:57 -0800 (PST) Received: from stb-bld-03.irv.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by smtp.gmail.com with ESMTPSA id l14sm12646282pfb.73.2016.02.03.18.14.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2016 18:14:57 -0800 (PST) From: Florian Fainelli To: linux-mips@linux-mips.org Cc: ralf@linux-mips.org, blogic@openwrt.org, cernekee@gmail.com, jon.fraser@broadcom.com, jaedon.shin@gmail.com, dragan.stancevic@gmail.com, jogo@openwrt.org, Florian Fainelli Subject: [PATCH 1/4] MIPS: BMIPS: Add Whirlwind (BMIPS5200) initialization code Date: Wed, 3 Feb 2016 18:14:50 -0800 Message-Id: <1454552093-17897-2-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1454552093-17897-1-git-send-email-f.fainelli@gmail.com> References: <1454552093-17897-1-git-send-email-f.fainelli@gmail.com> Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 51713 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: f.fainelli@gmail.com Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips Import bmips_5xxx_init.S from the stblinux-3.3 tree, and to make sure that this would work nicely with a BMIPS multiplatform kernel (with BMIPS330, BMIPS43XX and BMIPS5000 enabled), update soft_reset to check for the BMIPS5200 processor id (PRID_IMP_BMIPS5200) and execute bmips_5xxx_init for these processors to bring them online. Tested on 7425, 7429 and 7435 with CPU hotplug. 7435 SMP still needs some additional changes in the L1 interrupt area to work properly with interrupt affinity. Signed-off-by: Florian Fainelli --- arch/mips/kernel/Makefile | 2 +- arch/mips/kernel/bmips_5xxx_init.S | 753 +++++++++++++++++++++++++++++++++++++ arch/mips/kernel/bmips_vec.S | 41 +- 3 files changed, 792 insertions(+), 4 deletions(-) create mode 100644 arch/mips/kernel/bmips_5xxx_init.S diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile index 68e2b7db9348..47c5412f4ca0 100644 --- a/arch/mips/kernel/Makefile +++ b/arch/mips/kernel/Makefile @@ -44,7 +44,7 @@ obj-$(CONFIG_CPU_CAVIUM_OCTEON) += r4k_fpu.o octeon_switch.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SMP_UP) += smp-up.o -obj-$(CONFIG_CPU_BMIPS) += smp-bmips.o bmips_vec.o +obj-$(CONFIG_CPU_BMIPS) += smp-bmips.o bmips_vec.o bmips_5xxx_init.o obj-$(CONFIG_MIPS_MT) += mips-mt.o obj-$(CONFIG_MIPS_MT_FPAFF) += mips-mt-fpaff.o diff --git a/arch/mips/kernel/bmips_5xxx_init.S b/arch/mips/kernel/bmips_5xxx_init.S new file mode 100644 index 000000000000..788ebf9a365d --- /dev/null +++ b/arch/mips/kernel/bmips_5xxx_init.S @@ -0,0 +1,753 @@ + +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 2011-2012 by Broadcom Corporation + * + * Init for bmips 5000. + * Used to init second core in dual core 5000's. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_CPU_BMIPS5000 + + +#define cacheop(kva, size, linesize, op) \ + .set noreorder ; \ + addu t1, kva, size ; \ + subu t2, linesize, 1 ; \ + not t2 ; \ + and t0, kva, t2 ; \ + addiu t1, t1, -1 ; \ + and t1, t2 ; \ +9: cache op, 0(t0) ; \ + bne t0, t1, 9b ; \ + addu t0, linesize ; \ + .set reorder ; + + + +#define IS_SHIFT 22 +#define IL_SHIFT 19 +#define IA_SHIFT 16 +#define DS_SHIFT 13 +#define DL_SHIFT 10 +#define DA_SHIFT 7 +#define IS_MASK 7 +#define IL_MASK 7 +#define IA_MASK 7 +#define DS_MASK 7 +#define DL_MASK 7 +#define DA_MASK 7 +#define ICE_MASK 0x80000000 +#define DCE_MASK 0x40000000 + +#define CP0_BRCM_CONFIG0 $22, 0 +#define CP0_BRCM_MODE $22, 1 +#define CP0_CONFIG_K0_MASK 7 + +#define CP0_ICACHE_TAG_LO $28 +#define CP0_ICACHE_DATA_LO $28, 1 +#define CP0_DCACHE_TAG_LO $28, 2 +#define CP0_D_SEC_CACHE_DATA_LO $28, 3 +#define CP0_ICACHE_TAG_HI $29 +#define CP0_ICACHE_DATA_HI $29, 1 +#define CP0_DCACHE_TAG_HI $29, 2 + +#define CP0_BRCM_MODE_Luc_MASK (1 << 11) +#define CP0_BRCM_CONFIG0_CWF_MASK (1 << 20) +#define CP0_BRCM_CONFIG0_TSE_MASK (1 << 19) +#define CP0_BRCM_MODE_SET_MASK (1 << 7) +#define CP0_BRCM_MODE_ClkRATIO_MASK (7 << 4) +#define CP0_BRCM_MODE_BrPRED_MASK (3 << 24) +#define CP0_BRCM_MODE_BrPRED_SHIFT 24 +#define CP0_BRCM_MODE_BrHIST_MASK (0x1f << 20) +#define CP0_BRCM_MODE_BrHIST_SHIFT 20 + +/* ZSC L2 Cache Register Access Register Definitions */ +#define BRCM_ZSC_ALL_REGS_SELECT 0x7 << 24 + +#define BRCM_ZSC_CONFIG_REG 0 << 3 +#define BRCM_ZSC_REQ_BUFFER_REG 2 << 3 +#define BRCM_ZSC_RBUS_ADDR_MAPPING_REG0 4 << 3 +#define BRCM_ZSC_RBUS_ADDR_MAPPING_REG1 6 << 3 +#define BRCM_ZSC_RBUS_ADDR_MAPPING_REG2 8 << 3 + +#define BRCM_ZSC_SCB0_ADDR_MAPPING_REG0 0xa << 3 +#define BRCM_ZSC_SCB0_ADDR_MAPPING_REG1 0xc << 3 + +#define BRCM_ZSC_SCB1_ADDR_MAPPING_REG0 0xe << 3 +#define BRCM_ZSC_SCB1_ADDR_MAPPING_REG1 0x10 << 3 + +#define BRCM_ZSC_CONFIG_LMB1En 1 << (15) +#define BRCM_ZSC_CONFIG_LMB0En 1 << (14) + +/* branch predition values */ + +#define BRCM_BrPRED_ALL_TAKEN (0x0) +#define BRCM_BrPRED_ALL_NOT_TAKEN (0x1) +#define BRCM_BrPRED_BHT_ENABLE (0x2) +#define BRCM_BrPRED_PREDICT_BACKWARD (0x3) + + + +.align 2 +/* + * Function: size_i_cache + * Arguments: None + * Returns: v0 = i cache size, v1 = I cache line size + * Description: compute the I-cache size and I-cache line size + * Trashes: v0, v1, a0, t0 + * + * pseudo code: + * + */ + +LEAF(size_i_cache) + .set noreorder + + mfc0 a0, CP0_CONFIG, 1 + move t0, a0 + + /* + * Determine sets per way: IS + * + * This field contains the number of sets (i.e., indices) per way of + * the instruction cache: + * i) 0x0: 64, ii) 0x1: 128, iii) 0x2: 256, iv) 0x3: 512, v) 0x4: 1k + * vi) 0x5 - 0x7: Reserved. + */ + + srl a0, a0, IS_SHIFT + and a0, a0, IS_MASK + + /* sets per way = (64<