ath79: Remove kernel 4.14 support
[openwrt/openwrt.git] / target / linux / gemini / patches-4.14 / 0020-soc-Add-SoC-driver-for-Gemini.patch
1 From b0a88a861b036124ef2d6acfe6dd87cfde63e750 Mon Sep 17 00:00:00 2001
2 From: Linus Walleij <linus.walleij@linaro.org>
3 Date: Fri, 22 Dec 2017 00:19:08 +0100
4 Subject: [PATCH 20/31] soc: Add SoC driver for Gemini
5
6 This adds an SoC driver for the Gemini. Currently there
7 is only one thing not fitting into any other framework,
8 and that is the bus arbitration setting.
9
10 All Gemini vendor trees seem to be setting this register to
11 exactly the same arbitration so we just add a small code
12 snippet to do this at subsys_init() time before any other
13 drivers kick in.
14
15 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
16 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
17 ---
18 drivers/soc/Makefile | 1 +
19 drivers/soc/gemini/Makefile | 2 ++
20 drivers/soc/gemini/soc-gemini.c | 71 +++++++++++++++++++++++++++++++++++++++++
21 3 files changed, 74 insertions(+)
22 create mode 100644 drivers/soc/gemini/Makefile
23 create mode 100644 drivers/soc/gemini/soc-gemini.c
24
25 --- a/drivers/soc/Makefile
26 +++ b/drivers/soc/Makefile
27 @@ -9,6 +9,7 @@ obj-y += bcm/
28 obj-$(CONFIG_ARCH_DOVE) += dove/
29 obj-$(CONFIG_MACH_DOVE) += dove/
30 obj-y += fsl/
31 +obj-$(CONFIG_ARCH_GEMINI) += gemini/
32 obj-$(CONFIG_ARCH_MXC) += imx/
33 obj-$(CONFIG_SOC_XWAY) += lantiq/
34 obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/
35 --- /dev/null
36 +++ b/drivers/soc/gemini/Makefile
37 @@ -0,0 +1,2 @@
38 +# SPDX-License-Identifier: GPL-2.0
39 +obj-y += soc-gemini.o
40 --- /dev/null
41 +++ b/drivers/soc/gemini/soc-gemini.c
42 @@ -0,0 +1,71 @@
43 +// SPDX-License-Identifier: GPL-2.0
44 +/*
45 + * Copyright (C) 2017 Linaro Ltd.
46 + *
47 + * Author: Linus Walleij <linus.walleij@linaro.org>
48 + *
49 + * This program is free software; you can redistribute it and/or modify
50 + * it under the terms of the GNU General Public License version 2, as
51 + * published by the Free Software Foundation.
52 + *
53 + */
54 +#include <linux/init.h>
55 +#include <linux/kernel.h>
56 +#include <linux/mfd/syscon.h>
57 +#include <linux/regmap.h>
58 +#include <linux/of.h>
59 +
60 +#define GLOBAL_WORD_ID 0x00
61 +#define GEMINI_GLOBAL_ARB1_CTRL 0x2c
62 +#define GEMINI_ARB1_BURST_MASK GENMASK(21, 16)
63 +#define GEMINI_ARB1_BURST_SHIFT 16
64 +/* These all define the priority on the BUS2 backplane */
65 +#define GEMINI_ARB1_PRIO_MASK GENMASK(9, 0)
66 +#define GEMINI_ARB1_DMAC_HIGH_PRIO BIT(0)
67 +#define GEMINI_ARB1_IDE_HIGH_PRIO BIT(1)
68 +#define GEMINI_ARB1_RAID_HIGH_PRIO BIT(2)
69 +#define GEMINI_ARB1_SECURITY_HIGH_PRIO BIT(3)
70 +#define GEMINI_ARB1_GMAC0_HIGH_PRIO BIT(4)
71 +#define GEMINI_ARB1_GMAC1_HIGH_PRIO BIT(5)
72 +#define GEMINI_ARB1_USB0_HIGH_PRIO BIT(6)
73 +#define GEMINI_ARB1_USB1_HIGH_PRIO BIT(7)
74 +#define GEMINI_ARB1_PCI_HIGH_PRIO BIT(8)
75 +#define GEMINI_ARB1_TVE_HIGH_PRIO BIT(9)
76 +
77 +#define GEMINI_DEFAULT_BURST_SIZE 0x20
78 +#define GEMINI_DEFAULT_PRIO (GEMINI_ARB1_GMAC0_HIGH_PRIO | \
79 + GEMINI_ARB1_GMAC1_HIGH_PRIO)
80 +
81 +static int __init gemini_soc_init(void)
82 +{
83 + struct regmap *map;
84 + u32 rev;
85 + u32 val;
86 + int ret;
87 +
88 + /* Multiplatform guard, only proceed on Gemini */
89 + if (!of_machine_is_compatible("cortina,gemini"))
90 + return 0;
91 +
92 + map = syscon_regmap_lookup_by_compatible("cortina,gemini-syscon");
93 + if (IS_ERR(map))
94 + return PTR_ERR(map);
95 + ret = regmap_read(map, GLOBAL_WORD_ID, &rev);
96 + if (ret)
97 + return ret;
98 +
99 + val = (GEMINI_DEFAULT_BURST_SIZE << GEMINI_ARB1_BURST_SHIFT) |
100 + GEMINI_DEFAULT_PRIO;
101 +
102 + /* Set up system arbitration */
103 + regmap_update_bits(map,
104 + GEMINI_GLOBAL_ARB1_CTRL,
105 + GEMINI_ARB1_BURST_MASK | GEMINI_ARB1_PRIO_MASK,
106 + val);
107 +
108 + pr_info("Gemini SoC %04x revision %02x, set arbitration %08x\n",
109 + rev >> 8, rev & 0xff, val);
110 +
111 + return 0;
112 +}
113 +subsys_initcall(gemini_soc_init);