mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
44c916d58b
This merge window brings a good size of cleanups on various platforms. Among the bigger ones: * Removal of Samsung s5pc100 and s5p64xx platforms. Both of these have lacked active support for quite a while, and after asking around nobody showed interest in keeping them around. If needed, they could be resurrected in the future but it's more likely that we would prefer reintroduction of them as DT and multiplatform-enabled platforms instead. * OMAP4 controller code register define diet. They defined a lot of registers that were never actually used, etc. * Move of some of the Tegra platform code (PMC, APBIO, fuse, powergate) to drivers/soc so it can be shared with 64-bit code. This also converts them over to traditional driver models where possible. * Removal of legacy gpio-samsung driver, since the last users have been removed (moved to pinctrl) Plus a bunch of smaller changes for various platforms that sort of dissapear in the diffstat for the above. clps711x cleanups, shmobile header file refactoring/moves for multiplatform friendliness, some misc cleanups, etc. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQIcBAABAgAGBQJT5DYPAAoJEIwa5zzehBx37egQAIiatNiLLqZnfo3rwGADRz/a POfPovktj68aPcobyzoyhFtToMqGvi9PpysyFTIQD2HJFG+5BtiIAuqtg0875zDe EpBWgsfugrm0YktJWAtUerj60oAmNPbKfaEm1cOOWuM2lb2mV+QkRrwSTAgsqkT7 927BzMXKKBRPOVLL0RYhoF8EXa0Eg8kCqAHP8fJrzVYkRp+UrZJDnGiUP1XmWJN+ VXQMu5SEjcPMtqT7+tfX455RfREHJfBcJ1ZN/dPF8HMWDwClQG0lyc6hifh1MxwO 8DjIZNkfZeKqgDqVyC17re7pc7p8md5HL8WXbrKpK0A9vQ5bRexbPHxcwJ1T/C2Y 465H+st5XXbuzV1gbMwjK1/ycsH0tCyffckk8Yl/2e1Fs7GgPNbAELtTdl+5vV1Y xmDXkyo/9WlRM3LQ23IGKwW7VzN86EfWVuShssfro0fO7xDdb4OOYLdQI+4bCG+h ytQYun1vU32OEyNik5RVNQuZaMrv2c93a3bID4owwuPHPmYOPVUQaqnRX/0E51eA aHZYbk2GlUOV3Kq5aSS4iyLg1Yj+I9/NeH9U+A4nc+PQ5FlgGToaVSCuYuw4DqbP AAG+sqQHbkBMvDPobQz/yd1qZbAb4eLhGy11XK1t5S65rApWI55GwNXnvbyxqt8x wpmxJTASGxcfuZZgKXm7 =gbcE -----END PGP SIGNATURE----- Merge tag 'cleanup-for-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc Pull ARM SoC cleanups from Olof Johansson: "This merge window brings a good size of cleanups on various platforms. Among the bigger ones: - Removal of Samsung s5pc100 and s5p64xx platforms. Both of these have lacked active support for quite a while, and after asking around nobody showed interest in keeping them around. If needed, they could be resurrected in the future but it's more likely that we would prefer reintroduction of them as DT and multiplatform-enabled platforms instead. - OMAP4 controller code register define diet. They defined a lot of registers that were never actually used, etc. - Move of some of the Tegra platform code (PMC, APBIO, fuse, powergate) to drivers/soc so it can be shared with 64-bit code. This also converts them over to traditional driver models where possible. - Removal of legacy gpio-samsung driver, since the last users have been removed (moved to pinctrl) Plus a bunch of smaller changes for various platforms that sort of dissapear in the diffstat for the above. clps711x cleanups, shmobile header file refactoring/moves for multiplatform friendliness, some misc cleanups, etc" * tag 'cleanup-for-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (117 commits) drivers: CCI: Correct use of ! and & video: clcd-versatile: Depend on ARM video: fix up versatile CLCD helper move MAINTAINERS: Add sdhci-st file to ARCH/STI architecture ARM: EXYNOS: Fix build breakge with PM_SLEEP=n MAINTAINERS: Remove Kirkwood ARM: tegra: Convert PMC to a driver soc/tegra: fuse: Set up in early initcall ARM: tegra: Always lock the CPU reset vector ARM: tegra: Setup CPU hotplug in a pure initcall soc/tegra: Implement runtime check for Tegra SoCs soc/tegra: fuse: fix dummy functions soc/tegra: fuse: move APB DMA into Tegra20 fuse driver soc/tegra: Add efuse and apbmisc bindings soc/tegra: Add efuse driver for Tegra ARM: tegra: move fuse exports to soc/tegra/fuse.h ARM: tegra: export apb dma readl/writel ARM: tegra: Use a function to get the chip ID ARM: tegra: Sort includes alphabetically ARM: tegra: Move includes to include/soc/tegra ...
307 lines
7.5 KiB
C
307 lines
7.5 KiB
C
/*
|
|
* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/of.h>
|
|
#include <linux/clk/tegra.h>
|
|
#include <linux/reset-controller.h>
|
|
|
|
#include <soc/tegra/fuse.h>
|
|
|
|
#include "clk.h"
|
|
|
|
#define CLK_OUT_ENB_L 0x010
|
|
#define CLK_OUT_ENB_H 0x014
|
|
#define CLK_OUT_ENB_U 0x018
|
|
#define CLK_OUT_ENB_V 0x360
|
|
#define CLK_OUT_ENB_W 0x364
|
|
#define CLK_OUT_ENB_X 0x280
|
|
#define CLK_OUT_ENB_SET_L 0x320
|
|
#define CLK_OUT_ENB_CLR_L 0x324
|
|
#define CLK_OUT_ENB_SET_H 0x328
|
|
#define CLK_OUT_ENB_CLR_H 0x32c
|
|
#define CLK_OUT_ENB_SET_U 0x330
|
|
#define CLK_OUT_ENB_CLR_U 0x334
|
|
#define CLK_OUT_ENB_SET_V 0x440
|
|
#define CLK_OUT_ENB_CLR_V 0x444
|
|
#define CLK_OUT_ENB_SET_W 0x448
|
|
#define CLK_OUT_ENB_CLR_W 0x44c
|
|
#define CLK_OUT_ENB_SET_X 0x284
|
|
#define CLK_OUT_ENB_CLR_X 0x288
|
|
|
|
#define RST_DEVICES_L 0x004
|
|
#define RST_DEVICES_H 0x008
|
|
#define RST_DEVICES_U 0x00C
|
|
#define RST_DFLL_DVCO 0x2F4
|
|
#define RST_DEVICES_V 0x358
|
|
#define RST_DEVICES_W 0x35C
|
|
#define RST_DEVICES_X 0x28C
|
|
#define RST_DEVICES_SET_L 0x300
|
|
#define RST_DEVICES_CLR_L 0x304
|
|
#define RST_DEVICES_SET_H 0x308
|
|
#define RST_DEVICES_CLR_H 0x30c
|
|
#define RST_DEVICES_SET_U 0x310
|
|
#define RST_DEVICES_CLR_U 0x314
|
|
#define RST_DEVICES_SET_V 0x430
|
|
#define RST_DEVICES_CLR_V 0x434
|
|
#define RST_DEVICES_SET_W 0x438
|
|
#define RST_DEVICES_CLR_W 0x43c
|
|
#define RST_DEVICES_SET_X 0x290
|
|
#define RST_DEVICES_CLR_X 0x294
|
|
|
|
/* Global data of Tegra CPU CAR ops */
|
|
static struct tegra_cpu_car_ops dummy_car_ops;
|
|
struct tegra_cpu_car_ops *tegra_cpu_car_ops = &dummy_car_ops;
|
|
|
|
int *periph_clk_enb_refcnt;
|
|
static int periph_banks;
|
|
static struct clk **clks;
|
|
static int clk_num;
|
|
static struct clk_onecell_data clk_data;
|
|
|
|
static struct tegra_clk_periph_regs periph_regs[] = {
|
|
[0] = {
|
|
.enb_reg = CLK_OUT_ENB_L,
|
|
.enb_set_reg = CLK_OUT_ENB_SET_L,
|
|
.enb_clr_reg = CLK_OUT_ENB_CLR_L,
|
|
.rst_reg = RST_DEVICES_L,
|
|
.rst_set_reg = RST_DEVICES_SET_L,
|
|
.rst_clr_reg = RST_DEVICES_CLR_L,
|
|
},
|
|
[1] = {
|
|
.enb_reg = CLK_OUT_ENB_H,
|
|
.enb_set_reg = CLK_OUT_ENB_SET_H,
|
|
.enb_clr_reg = CLK_OUT_ENB_CLR_H,
|
|
.rst_reg = RST_DEVICES_H,
|
|
.rst_set_reg = RST_DEVICES_SET_H,
|
|
.rst_clr_reg = RST_DEVICES_CLR_H,
|
|
},
|
|
[2] = {
|
|
.enb_reg = CLK_OUT_ENB_U,
|
|
.enb_set_reg = CLK_OUT_ENB_SET_U,
|
|
.enb_clr_reg = CLK_OUT_ENB_CLR_U,
|
|
.rst_reg = RST_DEVICES_U,
|
|
.rst_set_reg = RST_DEVICES_SET_U,
|
|
.rst_clr_reg = RST_DEVICES_CLR_U,
|
|
},
|
|
[3] = {
|
|
.enb_reg = CLK_OUT_ENB_V,
|
|
.enb_set_reg = CLK_OUT_ENB_SET_V,
|
|
.enb_clr_reg = CLK_OUT_ENB_CLR_V,
|
|
.rst_reg = RST_DEVICES_V,
|
|
.rst_set_reg = RST_DEVICES_SET_V,
|
|
.rst_clr_reg = RST_DEVICES_CLR_V,
|
|
},
|
|
[4] = {
|
|
.enb_reg = CLK_OUT_ENB_W,
|
|
.enb_set_reg = CLK_OUT_ENB_SET_W,
|
|
.enb_clr_reg = CLK_OUT_ENB_CLR_W,
|
|
.rst_reg = RST_DEVICES_W,
|
|
.rst_set_reg = RST_DEVICES_SET_W,
|
|
.rst_clr_reg = RST_DEVICES_CLR_W,
|
|
},
|
|
[5] = {
|
|
.enb_reg = CLK_OUT_ENB_X,
|
|
.enb_set_reg = CLK_OUT_ENB_SET_X,
|
|
.enb_clr_reg = CLK_OUT_ENB_CLR_X,
|
|
.rst_reg = RST_DEVICES_X,
|
|
.rst_set_reg = RST_DEVICES_SET_X,
|
|
.rst_clr_reg = RST_DEVICES_CLR_X,
|
|
},
|
|
};
|
|
|
|
static void __iomem *clk_base;
|
|
|
|
static int tegra_clk_rst_assert(struct reset_controller_dev *rcdev,
|
|
unsigned long id)
|
|
{
|
|
/*
|
|
* If peripheral is on the APB bus then we must read the APB bus to
|
|
* flush the write operation in apb bus. This will avoid peripheral
|
|
* access after disabling clock. Since the reset driver has no
|
|
* knowledge of which reset IDs represent which devices, simply do
|
|
* this all the time.
|
|
*/
|
|
tegra_read_chipid();
|
|
|
|
writel_relaxed(BIT(id % 32),
|
|
clk_base + periph_regs[id / 32].rst_set_reg);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int tegra_clk_rst_deassert(struct reset_controller_dev *rcdev,
|
|
unsigned long id)
|
|
{
|
|
writel_relaxed(BIT(id % 32),
|
|
clk_base + periph_regs[id / 32].rst_clr_reg);
|
|
|
|
return 0;
|
|
}
|
|
|
|
struct tegra_clk_periph_regs *get_reg_bank(int clkid)
|
|
{
|
|
int reg_bank = clkid / 32;
|
|
|
|
if (reg_bank < periph_banks)
|
|
return &periph_regs[reg_bank];
|
|
else {
|
|
WARN_ON(1);
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
struct clk ** __init tegra_clk_init(void __iomem *regs, int num, int banks)
|
|
{
|
|
clk_base = regs;
|
|
|
|
if (WARN_ON(banks > ARRAY_SIZE(periph_regs)))
|
|
return NULL;
|
|
|
|
periph_clk_enb_refcnt = kzalloc(32 * banks *
|
|
sizeof(*periph_clk_enb_refcnt), GFP_KERNEL);
|
|
if (!periph_clk_enb_refcnt)
|
|
return NULL;
|
|
|
|
periph_banks = banks;
|
|
|
|
clks = kzalloc(num * sizeof(struct clk *), GFP_KERNEL);
|
|
if (!clks)
|
|
kfree(periph_clk_enb_refcnt);
|
|
|
|
clk_num = num;
|
|
|
|
return clks;
|
|
}
|
|
|
|
void __init tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list,
|
|
struct clk *clks[], int clk_max)
|
|
{
|
|
struct clk *clk;
|
|
|
|
for (; dup_list->clk_id < clk_max; dup_list++) {
|
|
clk = clks[dup_list->clk_id];
|
|
dup_list->lookup.clk = clk;
|
|
clkdev_add(&dup_list->lookup);
|
|
}
|
|
}
|
|
|
|
void __init tegra_init_from_table(struct tegra_clk_init_table *tbl,
|
|
struct clk *clks[], int clk_max)
|
|
{
|
|
struct clk *clk;
|
|
|
|
for (; tbl->clk_id < clk_max; tbl++) {
|
|
clk = clks[tbl->clk_id];
|
|
if (IS_ERR_OR_NULL(clk))
|
|
return;
|
|
|
|
if (tbl->parent_id < clk_max) {
|
|
struct clk *parent = clks[tbl->parent_id];
|
|
if (clk_set_parent(clk, parent)) {
|
|
pr_err("%s: Failed to set parent %s of %s\n",
|
|
__func__, __clk_get_name(parent),
|
|
__clk_get_name(clk));
|
|
WARN_ON(1);
|
|
}
|
|
}
|
|
|
|
if (tbl->rate)
|
|
if (clk_set_rate(clk, tbl->rate)) {
|
|
pr_err("%s: Failed to set rate %lu of %s\n",
|
|
__func__, tbl->rate,
|
|
__clk_get_name(clk));
|
|
WARN_ON(1);
|
|
}
|
|
|
|
if (tbl->state)
|
|
if (clk_prepare_enable(clk)) {
|
|
pr_err("%s: Failed to enable %s\n", __func__,
|
|
__clk_get_name(clk));
|
|
WARN_ON(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
static struct reset_control_ops rst_ops = {
|
|
.assert = tegra_clk_rst_assert,
|
|
.deassert = tegra_clk_rst_deassert,
|
|
};
|
|
|
|
static struct reset_controller_dev rst_ctlr = {
|
|
.ops = &rst_ops,
|
|
.owner = THIS_MODULE,
|
|
.of_reset_n_cells = 1,
|
|
};
|
|
|
|
void __init tegra_add_of_provider(struct device_node *np)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < clk_num; i++) {
|
|
if (IS_ERR(clks[i])) {
|
|
pr_err
|
|
("Tegra clk %d: register failed with %ld\n",
|
|
i, PTR_ERR(clks[i]));
|
|
}
|
|
if (!clks[i])
|
|
clks[i] = ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
clk_data.clks = clks;
|
|
clk_data.clk_num = clk_num;
|
|
of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
|
|
|
|
rst_ctlr.of_node = np;
|
|
rst_ctlr.nr_resets = clk_num * 32;
|
|
reset_controller_register(&rst_ctlr);
|
|
}
|
|
|
|
void __init tegra_register_devclks(struct tegra_devclk *dev_clks, int num)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < num; i++, dev_clks++)
|
|
clk_register_clkdev(clks[dev_clks->dt_id], dev_clks->con_id,
|
|
dev_clks->dev_id);
|
|
|
|
for (i = 0; i < clk_num; i++) {
|
|
if (!IS_ERR_OR_NULL(clks[i]))
|
|
clk_register_clkdev(clks[i], __clk_get_name(clks[i]),
|
|
"tegra-clk-debug");
|
|
}
|
|
}
|
|
|
|
struct clk ** __init tegra_lookup_dt_id(int clk_id,
|
|
struct tegra_clk *tegra_clk)
|
|
{
|
|
if (tegra_clk[clk_id].present)
|
|
return &clks[tegra_clk[clk_id].dt_id];
|
|
else
|
|
return NULL;
|
|
}
|
|
|
|
tegra_clk_apply_init_table_func tegra_clk_apply_init_table;
|
|
|
|
void __init tegra_clocks_apply_init_table(void)
|
|
{
|
|
if (!tegra_clk_apply_init_table)
|
|
return;
|
|
|
|
tegra_clk_apply_init_table();
|
|
}
|