Linux Audio

Check our new training course

Loading...
Note: File does not exist in v4.6.
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Copyright (C) 2017 Linaro Ltd.
 4 *
 5 * Author: Linus Walleij <linus.walleij@linaro.org>
 6 *
 7 * This program is free software; you can redistribute it and/or modify
 8 * it under the terms of the GNU General Public License version 2, as
 9 * published by the Free Software Foundation.
10 *
11 */
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/mfd/syscon.h>
15#include <linux/regmap.h>
16#include <linux/of.h>
17
18#define GLOBAL_WORD_ID				0x00
19#define GEMINI_GLOBAL_ARB1_CTRL			0x2c
20#define GEMINI_ARB1_BURST_MASK			GENMASK(21, 16)
21#define GEMINI_ARB1_BURST_SHIFT			16
22/* These all define the priority on the BUS2 backplane */
23#define GEMINI_ARB1_PRIO_MASK			GENMASK(9, 0)
24#define GEMINI_ARB1_DMAC_HIGH_PRIO		BIT(0)
25#define GEMINI_ARB1_IDE_HIGH_PRIO		BIT(1)
26#define GEMINI_ARB1_RAID_HIGH_PRIO		BIT(2)
27#define GEMINI_ARB1_SECURITY_HIGH_PRIO		BIT(3)
28#define GEMINI_ARB1_GMAC0_HIGH_PRIO		BIT(4)
29#define GEMINI_ARB1_GMAC1_HIGH_PRIO		BIT(5)
30#define GEMINI_ARB1_USB0_HIGH_PRIO		BIT(6)
31#define GEMINI_ARB1_USB1_HIGH_PRIO		BIT(7)
32#define GEMINI_ARB1_PCI_HIGH_PRIO		BIT(8)
33#define GEMINI_ARB1_TVE_HIGH_PRIO		BIT(9)
34
35#define GEMINI_DEFAULT_BURST_SIZE		0x20
36#define GEMINI_DEFAULT_PRIO			(GEMINI_ARB1_GMAC0_HIGH_PRIO | \
37						 GEMINI_ARB1_GMAC1_HIGH_PRIO)
38
39static int __init gemini_soc_init(void)
40{
41	struct regmap *map;
42	u32 rev;
43	u32 val;
44	int ret;
45
46	/* Multiplatform guard, only proceed on Gemini */
47	if (!of_machine_is_compatible("cortina,gemini"))
48		return 0;
49
50	map = syscon_regmap_lookup_by_compatible("cortina,gemini-syscon");
51	if (IS_ERR(map))
52		return PTR_ERR(map);
53	ret = regmap_read(map, GLOBAL_WORD_ID, &rev);
54	if (ret)
55		return ret;
56
57	val = (GEMINI_DEFAULT_BURST_SIZE << GEMINI_ARB1_BURST_SHIFT) |
58		GEMINI_DEFAULT_PRIO;
59
60	/* Set up system arbitration */
61	regmap_update_bits(map,
62			   GEMINI_GLOBAL_ARB1_CTRL,
63			   GEMINI_ARB1_BURST_MASK | GEMINI_ARB1_PRIO_MASK,
64			   val);
65
66	pr_info("Gemini SoC %04x revision %02x, set arbitration %08x\n",
67		rev >> 8, rev & 0xff, val);
68
69	return 0;
70}
71subsys_initcall(gemini_soc_init);