···11// SPDX-License-Identifier: GPL-2.0+22+// Copyright IBM Corp2334#define pr_fmt(fmt) "clk-aspeed: " fmt4555-#include <linux/clk-provider.h>66#include <linux/mfd/syscon.h>77#include <linux/of_address.h>88#include <linux/of_device.h>99#include <linux/platform_device.h>1010#include <linux/regmap.h>1111-#include <linux/reset-controller.h>1211#include <linux/slab.h>1313-#include <linux/spinlock.h>14121513#include <dt-bindings/clock/aspeed-clock.h>1414+1515+#include "clk-aspeed.h"16161717#define ASPEED_NUM_CLKS 361818···4141static struct clk_hw_onecell_data *aspeed_clk_data;42424343static void __iomem *scu_base;4444-4545-/**4646- * struct aspeed_gate_data - Aspeed gated clocks4747- * @clock_idx: bit used to gate this clock in the clock register4848- * @reset_idx: bit used to reset this IP in the reset register. -1 if no4949- * reset is required when enabling the clock5050- * @name: the clock name5151- * @parent_name: the name of the parent clock5252- * @flags: standard clock framework flags5353- */5454-struct aspeed_gate_data {5555- u8 clock_idx;5656- s8 reset_idx;5757- const char *name;5858- const char *parent_name;5959- unsigned long flags;6060-};6161-6262-/**6363- * struct aspeed_clk_gate - Aspeed specific clk_gate structure6464- * @hw: handle between common and hardware-specific interfaces6565- * @reg: register controlling gate6666- * @clock_idx: bit used to gate this clock in the clock register6767- * @reset_idx: bit used to reset this IP in the reset register. -1 if no6868- * reset is required when enabling the clock6969- * @flags: hardware-specific flags7070- * @lock: register lock7171- *7272- * Some of the clocks in the Aspeed SoC must be put in reset before enabling.7373- * This modified version of clk_gate allows an optional reset bit to be7474- * specified.7575- */7676-struct aspeed_clk_gate {7777- struct clk_hw hw;7878- struct regmap *map;7979- u8 clock_idx;8080- s8 reset_idx;8181- u8 flags;8282- spinlock_t *lock;8383-};8484-8585-#define to_aspeed_clk_gate(_hw) container_of(_hw, struct aspeed_clk_gate, hw)86448745/* TODO: ask Aspeed about the actual parent data */8846static const struct aspeed_gate_data aspeed_gates[] = {···166208 mult, div);167209}168210169169-struct aspeed_clk_soc_data {170170- const struct clk_div_table *div_table;171171- const struct clk_div_table *eclk_div_table;172172- const struct clk_div_table *mac_div_table;173173- struct clk_hw *(*calc_pll)(const char *name, u32 val);174174-};175175-176211static const struct aspeed_clk_soc_data ast2500_data = {177212 .div_table = ast2500_div_table,178213 .eclk_div_table = ast2500_eclk_div_table,···265314 .disable = aspeed_clk_disable,266315 .is_enabled = aspeed_clk_is_enabled,267316};268268-269269-/**270270- * struct aspeed_reset - Aspeed reset controller271271- * @map: regmap to access the containing system controller272272- * @rcdev: reset controller device273273- */274274-struct aspeed_reset {275275- struct regmap *map;276276- struct reset_controller_dev rcdev;277277-};278278-279279-#define to_aspeed_reset(p) container_of((p), struct aspeed_reset, rcdev)280317281318static const u8 aspeed_resets[] = {282319 /* SCU04 resets */···439500 return PTR_ERR(hw);440501 aspeed_clk_data->hws[ASPEED_CLK_MPLL] = hw;441502442442- /* SD/SDIO clock divider (TODO: There's a gate too) */443443- hw = clk_hw_register_divider_table(dev, "sdio", "hpll", 0,444444- scu_base + ASPEED_CLK_SELECTION, 12, 3, 0,503503+ /* SD/SDIO clock divider and gate */504504+ hw = clk_hw_register_gate(dev, "sd_extclk_gate", "hpll", 0,505505+ scu_base + ASPEED_CLK_SELECTION, 15, 0,506506+ &aspeed_clk_lock);507507+ if (IS_ERR(hw))508508+ return PTR_ERR(hw);509509+ hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate",510510+ 0, scu_base + ASPEED_CLK_SELECTION, 12, 3, 0,445511 soc_data->div_table,446512 &aspeed_clk_lock);447513 if (IS_ERR(hw))
+82
drivers/clk/clk-aspeed.h
···11+/* SPDX-License-Identifier: GPL-2.0-or-later */22+/*33+ * Structures used by ASPEED clock drivers44+ *55+ * Copyright 2019 IBM Corp.66+ */77+88+#include <linux/clk-provider.h>99+#include <linux/kernel.h>1010+#include <linux/reset-controller.h>1111+#include <linux/spinlock.h>1212+1313+struct clk_div_table;1414+struct regmap;1515+1616+/**1717+ * struct aspeed_gate_data - Aspeed gated clocks1818+ * @clock_idx: bit used to gate this clock in the clock register1919+ * @reset_idx: bit used to reset this IP in the reset register. -1 if no2020+ * reset is required when enabling the clock2121+ * @name: the clock name2222+ * @parent_name: the name of the parent clock2323+ * @flags: standard clock framework flags2424+ */2525+struct aspeed_gate_data {2626+ u8 clock_idx;2727+ s8 reset_idx;2828+ const char *name;2929+ const char *parent_name;3030+ unsigned long flags;3131+};3232+3333+/**3434+ * struct aspeed_clk_gate - Aspeed specific clk_gate structure3535+ * @hw: handle between common and hardware-specific interfaces3636+ * @reg: register controlling gate3737+ * @clock_idx: bit used to gate this clock in the clock register3838+ * @reset_idx: bit used to reset this IP in the reset register. -1 if no3939+ * reset is required when enabling the clock4040+ * @flags: hardware-specific flags4141+ * @lock: register lock4242+ *4343+ * Some of the clocks in the Aspeed SoC must be put in reset before enabling.4444+ * This modified version of clk_gate allows an optional reset bit to be4545+ * specified.4646+ */4747+struct aspeed_clk_gate {4848+ struct clk_hw hw;4949+ struct regmap *map;5050+ u8 clock_idx;5151+ s8 reset_idx;5252+ u8 flags;5353+ spinlock_t *lock;5454+};5555+5656+#define to_aspeed_clk_gate(_hw) container_of(_hw, struct aspeed_clk_gate, hw)5757+5858+/**5959+ * struct aspeed_reset - Aspeed reset controller6060+ * @map: regmap to access the containing system controller6161+ * @rcdev: reset controller device6262+ */6363+struct aspeed_reset {6464+ struct regmap *map;6565+ struct reset_controller_dev rcdev;6666+};6767+6868+#define to_aspeed_reset(p) container_of((p), struct aspeed_reset, rcdev)6969+7070+/**7171+ * struct aspeed_clk_soc_data - Aspeed SoC specific divisor information7272+ * @div_table: Common divider lookup table7373+ * @eclk_div_table: Divider lookup table for ECLK7474+ * @mac_div_table: Divider lookup table for MAC (Ethernet) clocks7575+ * @calc_pll: Callback to maculate common PLL settings7676+ */7777+struct aspeed_clk_soc_data {7878+ const struct clk_div_table *div_table;7979+ const struct clk_div_table *eclk_div_table;8080+ const struct clk_div_table *mac_div_table;8181+ struct clk_hw *(*calc_pll)(const char *name, u32 val);8282+};