Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: loongson1: Remove the outdated driver

Remove the outdated driver due to the following aspects.
- no DT support
- duplicate code across LS1B and LS1C
- does not fit into the current clock framework

Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
Link: https://lore.kernel.org/r/20230321111817.71756-3-keguang.zhang@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Keguang Zhang and committed by
Stephen Boyd
c4649611 12de2f50

-274
-1
drivers/clk/Makefile
··· 93 93 obj-y += ingenic/ 94 94 obj-$(CONFIG_ARCH_K3) += keystone/ 95 95 obj-$(CONFIG_ARCH_KEYSTONE) += keystone/ 96 - obj-$(CONFIG_MACH_LOONGSON32) += loongson1/ 97 96 obj-y += mediatek/ 98 97 obj-$(CONFIG_ARCH_MESON) += meson/ 99 98 obj-y += microchip/
-4
drivers/clk/loongson1/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0-only 2 - obj-y += clk.o 3 - obj-$(CONFIG_LOONGSON1_LS1B) += clk-loongson1b.o 4 - obj-$(CONFIG_LOONGSON1_LS1C) += clk-loongson1c.o
-118
drivers/clk/loongson1/clk-loongson1b.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/clkdev.h> 7 - #include <linux/clk-provider.h> 8 - #include <linux/io.h> 9 - #include <linux/err.h> 10 - 11 - #include <loongson1.h> 12 - #include "clk.h" 13 - 14 - #define OSC (33 * 1000000) 15 - #define DIV_APB 2 16 - 17 - static DEFINE_SPINLOCK(_lock); 18 - 19 - static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw, 20 - unsigned long parent_rate) 21 - { 22 - u32 pll, rate; 23 - 24 - pll = __raw_readl(LS1X_CLK_PLL_FREQ); 25 - rate = 12 + (pll & GENMASK(5, 0)); 26 - rate *= OSC; 27 - rate >>= 1; 28 - 29 - return rate; 30 - } 31 - 32 - static const struct clk_ops ls1x_pll_clk_ops = { 33 - .recalc_rate = ls1x_pll_recalc_rate, 34 - }; 35 - 36 - static const char *const cpu_parents[] = { "cpu_clk_div", "osc_clk", }; 37 - static const char *const ahb_parents[] = { "ahb_clk_div", "osc_clk", }; 38 - static const char *const dc_parents[] = { "dc_clk_div", "osc_clk", }; 39 - 40 - void __init ls1x_clk_init(void) 41 - { 42 - struct clk_hw *hw; 43 - 44 - hw = clk_hw_register_fixed_rate(NULL, "osc_clk", NULL, 0, OSC); 45 - clk_hw_register_clkdev(hw, "osc_clk", NULL); 46 - 47 - /* clock derived from 33 MHz OSC clk */ 48 - hw = clk_hw_register_pll(NULL, "pll_clk", "osc_clk", 49 - &ls1x_pll_clk_ops, 0); 50 - clk_hw_register_clkdev(hw, "pll_clk", NULL); 51 - 52 - /* clock derived from PLL clk */ 53 - /* _____ 54 - * _______________________| | 55 - * OSC ___/ | MUX |___ CPU CLK 56 - * \___ PLL ___ CPU DIV ___| | 57 - * |_____| 58 - */ 59 - hw = clk_hw_register_divider(NULL, "cpu_clk_div", "pll_clk", 60 - CLK_GET_RATE_NOCACHE, LS1X_CLK_PLL_DIV, 61 - DIV_CPU_SHIFT, DIV_CPU_WIDTH, 62 - CLK_DIVIDER_ONE_BASED | 63 - CLK_DIVIDER_ROUND_CLOSEST, &_lock); 64 - clk_hw_register_clkdev(hw, "cpu_clk_div", NULL); 65 - hw = clk_hw_register_mux(NULL, "cpu_clk", cpu_parents, 66 - ARRAY_SIZE(cpu_parents), 67 - CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV, 68 - BYPASS_CPU_SHIFT, BYPASS_CPU_WIDTH, 0, &_lock); 69 - clk_hw_register_clkdev(hw, "cpu_clk", NULL); 70 - 71 - /* _____ 72 - * _______________________| | 73 - * OSC ___/ | MUX |___ DC CLK 74 - * \___ PLL ___ DC DIV ___| | 75 - * |_____| 76 - */ 77 - hw = clk_hw_register_divider(NULL, "dc_clk_div", "pll_clk", 78 - 0, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT, 79 - DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock); 80 - clk_hw_register_clkdev(hw, "dc_clk_div", NULL); 81 - hw = clk_hw_register_mux(NULL, "dc_clk", dc_parents, 82 - ARRAY_SIZE(dc_parents), 83 - CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV, 84 - BYPASS_DC_SHIFT, BYPASS_DC_WIDTH, 0, &_lock); 85 - clk_hw_register_clkdev(hw, "dc_clk", NULL); 86 - 87 - /* _____ 88 - * _______________________| | 89 - * OSC ___/ | MUX |___ DDR CLK 90 - * \___ PLL ___ DDR DIV ___| | 91 - * |_____| 92 - */ 93 - hw = clk_hw_register_divider(NULL, "ahb_clk_div", "pll_clk", 94 - 0, LS1X_CLK_PLL_DIV, DIV_DDR_SHIFT, 95 - DIV_DDR_WIDTH, CLK_DIVIDER_ONE_BASED, 96 - &_lock); 97 - clk_hw_register_clkdev(hw, "ahb_clk_div", NULL); 98 - hw = clk_hw_register_mux(NULL, "ahb_clk", ahb_parents, 99 - ARRAY_SIZE(ahb_parents), 100 - CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV, 101 - BYPASS_DDR_SHIFT, BYPASS_DDR_WIDTH, 0, &_lock); 102 - clk_hw_register_clkdev(hw, "ahb_clk", NULL); 103 - clk_hw_register_clkdev(hw, "ls1x-dma", NULL); 104 - clk_hw_register_clkdev(hw, "stmmaceth", NULL); 105 - 106 - /* clock derived from AHB clk */ 107 - /* APB clk is always half of the AHB clk */ 108 - hw = clk_hw_register_fixed_factor(NULL, "apb_clk", "ahb_clk", 0, 1, 109 - DIV_APB); 110 - clk_hw_register_clkdev(hw, "apb_clk", NULL); 111 - clk_hw_register_clkdev(hw, "ls1x-ac97", NULL); 112 - clk_hw_register_clkdev(hw, "ls1x-i2c", NULL); 113 - clk_hw_register_clkdev(hw, "ls1x-nand", NULL); 114 - clk_hw_register_clkdev(hw, "ls1x-pwmtimer", NULL); 115 - clk_hw_register_clkdev(hw, "ls1x-spi", NULL); 116 - clk_hw_register_clkdev(hw, "ls1x-wdt", NULL); 117 - clk_hw_register_clkdev(hw, "serial8250", NULL); 118 - }
-95
drivers/clk/loongson1/clk-loongson1c.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2016 Yang Ling <gnaygnil@gmail.com> 4 - */ 5 - 6 - #include <linux/clkdev.h> 7 - #include <linux/clk-provider.h> 8 - #include <linux/io.h> 9 - 10 - #include <loongson1.h> 11 - #include "clk.h" 12 - 13 - #define OSC (24 * 1000000) 14 - #define DIV_APB 1 15 - 16 - static DEFINE_SPINLOCK(_lock); 17 - 18 - static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw, 19 - unsigned long parent_rate) 20 - { 21 - u32 pll, rate; 22 - 23 - pll = __raw_readl(LS1X_CLK_PLL_FREQ); 24 - rate = ((pll >> 8) & 0xff) + ((pll >> 16) & 0xff); 25 - rate *= OSC; 26 - rate >>= 2; 27 - 28 - return rate; 29 - } 30 - 31 - static const struct clk_ops ls1x_pll_clk_ops = { 32 - .recalc_rate = ls1x_pll_recalc_rate, 33 - }; 34 - 35 - static const struct clk_div_table ahb_div_table[] = { 36 - [0] = { .val = 0, .div = 2 }, 37 - [1] = { .val = 1, .div = 4 }, 38 - [2] = { .val = 2, .div = 3 }, 39 - [3] = { .val = 3, .div = 3 }, 40 - [4] = { /* sentinel */ } 41 - }; 42 - 43 - void __init ls1x_clk_init(void) 44 - { 45 - struct clk_hw *hw; 46 - 47 - hw = clk_hw_register_fixed_rate(NULL, "osc_clk", NULL, 0, OSC); 48 - clk_hw_register_clkdev(hw, "osc_clk", NULL); 49 - 50 - /* clock derived from 24 MHz OSC clk */ 51 - hw = clk_hw_register_pll(NULL, "pll_clk", "osc_clk", 52 - &ls1x_pll_clk_ops, 0); 53 - clk_hw_register_clkdev(hw, "pll_clk", NULL); 54 - 55 - hw = clk_hw_register_divider(NULL, "cpu_clk_div", "pll_clk", 56 - CLK_GET_RATE_NOCACHE, LS1X_CLK_PLL_DIV, 57 - DIV_CPU_SHIFT, DIV_CPU_WIDTH, 58 - CLK_DIVIDER_ONE_BASED | 59 - CLK_DIVIDER_ROUND_CLOSEST, &_lock); 60 - clk_hw_register_clkdev(hw, "cpu_clk_div", NULL); 61 - hw = clk_hw_register_fixed_factor(NULL, "cpu_clk", "cpu_clk_div", 62 - 0, 1, 1); 63 - clk_hw_register_clkdev(hw, "cpu_clk", NULL); 64 - 65 - hw = clk_hw_register_divider(NULL, "dc_clk_div", "pll_clk", 66 - 0, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT, 67 - DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock); 68 - clk_hw_register_clkdev(hw, "dc_clk_div", NULL); 69 - hw = clk_hw_register_fixed_factor(NULL, "dc_clk", "dc_clk_div", 70 - 0, 1, 1); 71 - clk_hw_register_clkdev(hw, "dc_clk", NULL); 72 - 73 - hw = clk_hw_register_divider_table(NULL, "ahb_clk_div", "cpu_clk_div", 74 - 0, LS1X_CLK_PLL_FREQ, DIV_DDR_SHIFT, 75 - DIV_DDR_WIDTH, CLK_DIVIDER_ALLOW_ZERO, 76 - ahb_div_table, &_lock); 77 - clk_hw_register_clkdev(hw, "ahb_clk_div", NULL); 78 - hw = clk_hw_register_fixed_factor(NULL, "ahb_clk", "ahb_clk_div", 79 - 0, 1, 1); 80 - clk_hw_register_clkdev(hw, "ahb_clk", NULL); 81 - clk_hw_register_clkdev(hw, "ls1x-dma", NULL); 82 - clk_hw_register_clkdev(hw, "stmmaceth", NULL); 83 - 84 - /* clock derived from AHB clk */ 85 - hw = clk_hw_register_fixed_factor(NULL, "apb_clk", "ahb_clk", 0, 1, 86 - DIV_APB); 87 - clk_hw_register_clkdev(hw, "apb_clk", NULL); 88 - clk_hw_register_clkdev(hw, "ls1x-ac97", NULL); 89 - clk_hw_register_clkdev(hw, "ls1x-i2c", NULL); 90 - clk_hw_register_clkdev(hw, "ls1x-nand", NULL); 91 - clk_hw_register_clkdev(hw, "ls1x-pwmtimer", NULL); 92 - clk_hw_register_clkdev(hw, "ls1x-spi", NULL); 93 - clk_hw_register_clkdev(hw, "ls1x-wdt", NULL); 94 - clk_hw_register_clkdev(hw, "serial8250", NULL); 95 - }
-41
drivers/clk/loongson1/clk.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/clk-provider.h> 7 - #include <linux/slab.h> 8 - 9 - #include "clk.h" 10 - 11 - struct clk_hw *__init clk_hw_register_pll(struct device *dev, 12 - const char *name, 13 - const char *parent_name, 14 - const struct clk_ops *ops, 15 - unsigned long flags) 16 - { 17 - int ret; 18 - struct clk_hw *hw; 19 - struct clk_init_data init; 20 - 21 - /* allocate the divider */ 22 - hw = kzalloc(sizeof(*hw), GFP_KERNEL); 23 - if (!hw) 24 - return ERR_PTR(-ENOMEM); 25 - 26 - init.name = name; 27 - init.ops = ops; 28 - init.flags = flags; 29 - init.parent_names = parent_name ? &parent_name : NULL; 30 - init.num_parents = parent_name ? 1 : 0; 31 - hw->init = &init; 32 - 33 - /* register the clock */ 34 - ret = clk_hw_register(dev, hw); 35 - if (ret) { 36 - kfree(hw); 37 - hw = ERR_PTR(ret); 38 - } 39 - 40 - return hw; 41 - }
-15
drivers/clk/loongson1/clk.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #ifndef __LOONGSON1_CLK_H 7 - #define __LOONGSON1_CLK_H 8 - 9 - struct clk_hw *clk_hw_register_pll(struct device *dev, 10 - const char *name, 11 - const char *parent_name, 12 - const struct clk_ops *ops, 13 - unsigned long flags); 14 - 15 - #endif /* __LOONGSON1_CLK_H */