reset-stm32.c (4f2c0a4acffbec01079c28f839422e64ddeff004) | reset-stm32.c (30500c2ad9c440d1a81e7a5dac3bcef62e21d910) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) STMicroelectronics 2022 - All Rights Reserved 4 * Author: Gabriel Fernandez <gabriel.fernandez@foss.st.com> for STMicroelectronics. 5 */ 6 7#include <linux/of.h> 8#include <linux/platform_device.h> 9#include <linux/regmap.h> 10#include <linux/reset-controller.h> 11#include <linux/slab.h> 12#include <linux/spinlock.h> 13 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) STMicroelectronics 2022 - All Rights Reserved 4 * Author: Gabriel Fernandez <gabriel.fernandez@foss.st.com> for STMicroelectronics. 5 */ 6 7#include <linux/of.h> 8#include <linux/platform_device.h> 9#include <linux/regmap.h> 10#include <linux/reset-controller.h> 11#include <linux/slab.h> 12#include <linux/spinlock.h> 13 |
14#include "clk-stm32-core.h" | 14#include "reset-stm32.h" |
15 | 15 |
16#define STM32_RESET_ID_MASK GENMASK(15, 0) 17 | |
18struct stm32_reset_data { 19 /* reset lock */ 20 spinlock_t lock; 21 struct reset_controller_dev rcdev; 22 void __iomem *membase; 23 u32 clear_offset; 24}; 25 --- 68 unchanged lines hidden (view full) --- 94} 95 96static const struct reset_control_ops stm32_reset_ops = { 97 .assert = stm32_reset_assert, 98 .deassert = stm32_reset_deassert, 99 .status = stm32_reset_status, 100}; 101 | 16struct stm32_reset_data { 17 /* reset lock */ 18 spinlock_t lock; 19 struct reset_controller_dev rcdev; 20 void __iomem *membase; 21 u32 clear_offset; 22}; 23 --- 68 unchanged lines hidden (view full) --- 92} 93 94static const struct reset_control_ops stm32_reset_ops = { 95 .assert = stm32_reset_assert, 96 .deassert = stm32_reset_deassert, 97 .status = stm32_reset_status, 98}; 99 |
102int stm32_rcc_reset_init(struct device *dev, const struct of_device_id *match, | 100int stm32_rcc_reset_init(struct device *dev, struct clk_stm32_reset_data *data, |
103 void __iomem *base) 104{ | 101 void __iomem *base) 102{ |
105 const struct stm32_rcc_match_data *data = match->data; 106 struct stm32_reset_data *reset_data = NULL; | 103 struct stm32_reset_data *reset_data; |
107 | 104 |
108 data = match->data; 109 | |
110 reset_data = kzalloc(sizeof(*reset_data), GFP_KERNEL); 111 if (!reset_data) 112 return -ENOMEM; 113 114 spin_lock_init(&reset_data->lock); | 105 reset_data = kzalloc(sizeof(*reset_data), GFP_KERNEL); 106 if (!reset_data) 107 return -ENOMEM; 108 109 spin_lock_init(&reset_data->lock); |
110 |
|
115 reset_data->membase = base; 116 reset_data->rcdev.owner = THIS_MODULE; 117 reset_data->rcdev.ops = &stm32_reset_ops; 118 reset_data->rcdev.of_node = dev_of_node(dev); | 111 reset_data->membase = base; 112 reset_data->rcdev.owner = THIS_MODULE; 113 reset_data->rcdev.ops = &stm32_reset_ops; 114 reset_data->rcdev.of_node = dev_of_node(dev); |
119 reset_data->rcdev.nr_resets = STM32_RESET_ID_MASK; | 115 reset_data->rcdev.nr_resets = data->nr_lines; |
120 reset_data->clear_offset = data->clear_offset; 121 122 return reset_controller_register(&reset_data->rcdev); 123} | 116 reset_data->clear_offset = data->clear_offset; 117 118 return reset_controller_register(&reset_data->rcdev); 119} |