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

clk: actions: Add Actions Semi Owl SoCs Reset Management Unit support

Add Reset Management Unit (RMU) support for Actions Semi Owl SoCs.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Manivannan Sadhasivam and committed by
Stephen Boyd
09dbde01 a35bcf7c

+101
+1
drivers/clk/actions/Kconfig
··· 2 2 bool "Clock driver for Actions Semi SoCs" 3 3 depends on ARCH_ACTIONS || COMPILE_TEST 4 4 select REGMAP_MMIO 5 + select RESET_CONTROLLER 5 6 default ARCH_ACTIONS 6 7 7 8 if CLK_ACTIONS
+1
drivers/clk/actions/Makefile
··· 7 7 clk-owl-y += owl-factor.o 8 8 clk-owl-y += owl-composite.o 9 9 clk-owl-y += owl-pll.o 10 + clk-owl-y += owl-reset.o 10 11 11 12 # SoC support 12 13 obj-$(CONFIG_CLK_OWL_S700) += owl-s700.o
+2
drivers/clk/actions/owl-common.h
··· 26 26 struct owl_clk_common **clks; 27 27 unsigned long num_clks; 28 28 struct clk_hw_onecell_data *hw_clks; 29 + const struct owl_reset_map *resets; 30 + unsigned long num_resets; 29 31 struct regmap *regmap; 30 32 }; 31 33
+66
drivers/clk/actions/owl-reset.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + // 3 + // Actions Semi Owl SoCs Reset Management Unit driver 4 + // 5 + // Copyright (c) 2018 Linaro Ltd. 6 + // Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 7 + 8 + #include <linux/delay.h> 9 + #include <linux/regmap.h> 10 + #include <linux/reset-controller.h> 11 + 12 + #include "owl-reset.h" 13 + 14 + static int owl_reset_assert(struct reset_controller_dev *rcdev, 15 + unsigned long id) 16 + { 17 + struct owl_reset *reset = to_owl_reset(rcdev); 18 + const struct owl_reset_map *map = &reset->reset_map[id]; 19 + 20 + return regmap_update_bits(reset->regmap, map->reg, map->bit, 0); 21 + } 22 + 23 + static int owl_reset_deassert(struct reset_controller_dev *rcdev, 24 + unsigned long id) 25 + { 26 + struct owl_reset *reset = to_owl_reset(rcdev); 27 + const struct owl_reset_map *map = &reset->reset_map[id]; 28 + 29 + return regmap_update_bits(reset->regmap, map->reg, map->bit, map->bit); 30 + } 31 + 32 + static int owl_reset_reset(struct reset_controller_dev *rcdev, 33 + unsigned long id) 34 + { 35 + owl_reset_assert(rcdev, id); 36 + udelay(1); 37 + owl_reset_deassert(rcdev, id); 38 + 39 + return 0; 40 + } 41 + 42 + static int owl_reset_status(struct reset_controller_dev *rcdev, 43 + unsigned long id) 44 + { 45 + struct owl_reset *reset = to_owl_reset(rcdev); 46 + const struct owl_reset_map *map = &reset->reset_map[id]; 47 + u32 reg; 48 + int ret; 49 + 50 + ret = regmap_read(reset->regmap, map->reg, &reg); 51 + if (ret) 52 + return ret; 53 + 54 + /* 55 + * The reset control API expects 0 if reset is not asserted, 56 + * which is the opposite of what our hardware uses. 57 + */ 58 + return !(map->bit & reg); 59 + } 60 + 61 + const struct reset_control_ops owl_reset_ops = { 62 + .assert = owl_reset_assert, 63 + .deassert = owl_reset_deassert, 64 + .reset = owl_reset_reset, 65 + .status = owl_reset_status, 66 + };
+31
drivers/clk/actions/owl-reset.h
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + // 3 + // Actions Semi Owl SoCs Reset Management Unit driver 4 + // 5 + // Copyright (c) 2018 Linaro Ltd. 6 + // Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 7 + 8 + #ifndef _OWL_RESET_H_ 9 + #define _OWL_RESET_H_ 10 + 11 + #include <linux/reset-controller.h> 12 + 13 + struct owl_reset_map { 14 + u32 reg; 15 + u32 bit; 16 + }; 17 + 18 + struct owl_reset { 19 + struct reset_controller_dev rcdev; 20 + const struct owl_reset_map *reset_map; 21 + struct regmap *regmap; 22 + }; 23 + 24 + static inline struct owl_reset *to_owl_reset(struct reset_controller_dev *rcdev) 25 + { 26 + return container_of(rcdev, struct owl_reset, rcdev); 27 + } 28 + 29 + extern const struct reset_control_ops owl_reset_ops; 30 + 31 + #endif /* _OWL_RESET_H_ */