162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2017 Linaro Ltd. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Author: Linus Walleij <linus.walleij@linaro.org> 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 862306a36Sopenharmony_ci * it under the terms of the GNU General Public License version 2, as 962306a36Sopenharmony_ci * published by the Free Software Foundation. 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci */ 1262306a36Sopenharmony_ci#include <linux/init.h> 1362306a36Sopenharmony_ci#include <linux/kernel.h> 1462306a36Sopenharmony_ci#include <linux/mfd/syscon.h> 1562306a36Sopenharmony_ci#include <linux/regmap.h> 1662306a36Sopenharmony_ci#include <linux/of.h> 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#define GLOBAL_WORD_ID 0x00 1962306a36Sopenharmony_ci#define GEMINI_GLOBAL_ARB1_CTRL 0x2c 2062306a36Sopenharmony_ci#define GEMINI_ARB1_BURST_MASK GENMASK(21, 16) 2162306a36Sopenharmony_ci#define GEMINI_ARB1_BURST_SHIFT 16 2262306a36Sopenharmony_ci/* These all define the priority on the BUS2 backplane */ 2362306a36Sopenharmony_ci#define GEMINI_ARB1_PRIO_MASK GENMASK(9, 0) 2462306a36Sopenharmony_ci#define GEMINI_ARB1_DMAC_HIGH_PRIO BIT(0) 2562306a36Sopenharmony_ci#define GEMINI_ARB1_IDE_HIGH_PRIO BIT(1) 2662306a36Sopenharmony_ci#define GEMINI_ARB1_RAID_HIGH_PRIO BIT(2) 2762306a36Sopenharmony_ci#define GEMINI_ARB1_SECURITY_HIGH_PRIO BIT(3) 2862306a36Sopenharmony_ci#define GEMINI_ARB1_GMAC0_HIGH_PRIO BIT(4) 2962306a36Sopenharmony_ci#define GEMINI_ARB1_GMAC1_HIGH_PRIO BIT(5) 3062306a36Sopenharmony_ci#define GEMINI_ARB1_USB0_HIGH_PRIO BIT(6) 3162306a36Sopenharmony_ci#define GEMINI_ARB1_USB1_HIGH_PRIO BIT(7) 3262306a36Sopenharmony_ci#define GEMINI_ARB1_PCI_HIGH_PRIO BIT(8) 3362306a36Sopenharmony_ci#define GEMINI_ARB1_TVE_HIGH_PRIO BIT(9) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define GEMINI_DEFAULT_BURST_SIZE 0x20 3662306a36Sopenharmony_ci#define GEMINI_DEFAULT_PRIO (GEMINI_ARB1_GMAC0_HIGH_PRIO | \ 3762306a36Sopenharmony_ci GEMINI_ARB1_GMAC1_HIGH_PRIO) 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_cistatic int __init gemini_soc_init(void) 4062306a36Sopenharmony_ci{ 4162306a36Sopenharmony_ci struct regmap *map; 4262306a36Sopenharmony_ci u32 rev; 4362306a36Sopenharmony_ci u32 val; 4462306a36Sopenharmony_ci int ret; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci /* Multiplatform guard, only proceed on Gemini */ 4762306a36Sopenharmony_ci if (!of_machine_is_compatible("cortina,gemini")) 4862306a36Sopenharmony_ci return 0; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci map = syscon_regmap_lookup_by_compatible("cortina,gemini-syscon"); 5162306a36Sopenharmony_ci if (IS_ERR(map)) 5262306a36Sopenharmony_ci return PTR_ERR(map); 5362306a36Sopenharmony_ci ret = regmap_read(map, GLOBAL_WORD_ID, &rev); 5462306a36Sopenharmony_ci if (ret) 5562306a36Sopenharmony_ci return ret; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci val = (GEMINI_DEFAULT_BURST_SIZE << GEMINI_ARB1_BURST_SHIFT) | 5862306a36Sopenharmony_ci GEMINI_DEFAULT_PRIO; 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci /* Set up system arbitration */ 6162306a36Sopenharmony_ci regmap_update_bits(map, 6262306a36Sopenharmony_ci GEMINI_GLOBAL_ARB1_CTRL, 6362306a36Sopenharmony_ci GEMINI_ARB1_BURST_MASK | GEMINI_ARB1_PRIO_MASK, 6462306a36Sopenharmony_ci val); 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci pr_info("Gemini SoC %04x revision %02x, set arbitration %08x\n", 6762306a36Sopenharmony_ci rev >> 8, rev & 0xff, val); 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci return 0; 7062306a36Sopenharmony_ci} 7162306a36Sopenharmony_cisubsys_initcall(gemini_soc_init); 72