Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (C) 2017 Linaro Ltd.
0004  *
0005  * Author: Linus Walleij <linus.walleij@linaro.org>
0006  *
0007  * This program is free software; you can redistribute it and/or modify
0008  * it under the terms of the GNU General Public License version 2, as
0009  * published by the Free Software Foundation.
0010  *
0011  */
0012 #include <linux/init.h>
0013 #include <linux/kernel.h>
0014 #include <linux/mfd/syscon.h>
0015 #include <linux/regmap.h>
0016 #include <linux/of.h>
0017 
0018 #define GLOBAL_WORD_ID              0x00
0019 #define GEMINI_GLOBAL_ARB1_CTRL         0x2c
0020 #define GEMINI_ARB1_BURST_MASK          GENMASK(21, 16)
0021 #define GEMINI_ARB1_BURST_SHIFT         16
0022 /* These all define the priority on the BUS2 backplane */
0023 #define GEMINI_ARB1_PRIO_MASK           GENMASK(9, 0)
0024 #define GEMINI_ARB1_DMAC_HIGH_PRIO      BIT(0)
0025 #define GEMINI_ARB1_IDE_HIGH_PRIO       BIT(1)
0026 #define GEMINI_ARB1_RAID_HIGH_PRIO      BIT(2)
0027 #define GEMINI_ARB1_SECURITY_HIGH_PRIO      BIT(3)
0028 #define GEMINI_ARB1_GMAC0_HIGH_PRIO     BIT(4)
0029 #define GEMINI_ARB1_GMAC1_HIGH_PRIO     BIT(5)
0030 #define GEMINI_ARB1_USB0_HIGH_PRIO      BIT(6)
0031 #define GEMINI_ARB1_USB1_HIGH_PRIO      BIT(7)
0032 #define GEMINI_ARB1_PCI_HIGH_PRIO       BIT(8)
0033 #define GEMINI_ARB1_TVE_HIGH_PRIO       BIT(9)
0034 
0035 #define GEMINI_DEFAULT_BURST_SIZE       0x20
0036 #define GEMINI_DEFAULT_PRIO         (GEMINI_ARB1_GMAC0_HIGH_PRIO | \
0037                          GEMINI_ARB1_GMAC1_HIGH_PRIO)
0038 
0039 static int __init gemini_soc_init(void)
0040 {
0041     struct regmap *map;
0042     u32 rev;
0043     u32 val;
0044     int ret;
0045 
0046     /* Multiplatform guard, only proceed on Gemini */
0047     if (!of_machine_is_compatible("cortina,gemini"))
0048         return 0;
0049 
0050     map = syscon_regmap_lookup_by_compatible("cortina,gemini-syscon");
0051     if (IS_ERR(map))
0052         return PTR_ERR(map);
0053     ret = regmap_read(map, GLOBAL_WORD_ID, &rev);
0054     if (ret)
0055         return ret;
0056 
0057     val = (GEMINI_DEFAULT_BURST_SIZE << GEMINI_ARB1_BURST_SHIFT) |
0058         GEMINI_DEFAULT_PRIO;
0059 
0060     /* Set up system arbitration */
0061     regmap_update_bits(map,
0062                GEMINI_GLOBAL_ARB1_CTRL,
0063                GEMINI_ARB1_BURST_MASK | GEMINI_ARB1_PRIO_MASK,
0064                val);
0065 
0066     pr_info("Gemini SoC %04x revision %02x, set arbitration %08x\n",
0067         rev >> 8, rev & 0xff, val);
0068 
0069     return 0;
0070 }
0071 subsys_initcall(gemini_soc_init);