diff options
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/qcom/Kconfig | 2 | ||||
-rw-r--r-- | drivers/clk/qcom/Makefile | 1 | ||||
-rw-r--r-- | drivers/clk/qcom/reset.c | 63 | ||||
-rw-r--r-- | drivers/clk/qcom/reset.h | 37 |
4 files changed, 102 insertions, 1 deletions
diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig index 73a8c8fb547f..06ccce65d598 100644 --- a/drivers/clk/qcom/Kconfig +++ b/drivers/clk/qcom/Kconfig | |||
@@ -2,4 +2,4 @@ config COMMON_CLK_QCOM | |||
2 | tristate "Support for Qualcomm's clock controllers" | 2 | tristate "Support for Qualcomm's clock controllers" |
3 | depends on OF | 3 | depends on OF |
4 | select REGMAP_MMIO | 4 | select REGMAP_MMIO |
5 | 5 | select RESET_CONTROLLER | |
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile index 1b4f75f58031..ec12ec4568ff 100644 --- a/drivers/clk/qcom/Makefile +++ b/drivers/clk/qcom/Makefile | |||
@@ -5,3 +5,4 @@ clk-qcom-$(CONFIG_COMMON_CLK_QCOM) += clk-pll.o | |||
5 | clk-qcom-$(CONFIG_COMMON_CLK_QCOM) += clk-rcg.o | 5 | clk-qcom-$(CONFIG_COMMON_CLK_QCOM) += clk-rcg.o |
6 | clk-qcom-$(CONFIG_COMMON_CLK_QCOM) += clk-rcg2.o | 6 | clk-qcom-$(CONFIG_COMMON_CLK_QCOM) += clk-rcg2.o |
7 | clk-qcom-$(CONFIG_COMMON_CLK_QCOM) += clk-branch.o | 7 | clk-qcom-$(CONFIG_COMMON_CLK_QCOM) += clk-branch.o |
8 | clk-qcom-$(CONFIG_COMMON_CLK_QCOM) += reset.o | ||
diff --git a/drivers/clk/qcom/reset.c b/drivers/clk/qcom/reset.c new file mode 100644 index 000000000000..6c977d3a8590 --- /dev/null +++ b/drivers/clk/qcom/reset.c | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. | ||
3 | * | ||
4 | * This software is licensed under the terms of the GNU General Public | ||
5 | * License version 2, as published by the Free Software Foundation, and | ||
6 | * may be copied, distributed, and modified under those terms. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #include <linux/bitops.h> | ||
15 | #include <linux/export.h> | ||
16 | #include <linux/regmap.h> | ||
17 | #include <linux/reset-controller.h> | ||
18 | #include <linux/delay.h> | ||
19 | |||
20 | #include "reset.h" | ||
21 | |||
22 | static int qcom_reset(struct reset_controller_dev *rcdev, unsigned long id) | ||
23 | { | ||
24 | rcdev->ops->assert(rcdev, id); | ||
25 | udelay(1); | ||
26 | rcdev->ops->deassert(rcdev, id); | ||
27 | return 0; | ||
28 | } | ||
29 | |||
30 | static int | ||
31 | qcom_reset_assert(struct reset_controller_dev *rcdev, unsigned long id) | ||
32 | { | ||
33 | struct qcom_reset_controller *rst; | ||
34 | const struct qcom_reset_map *map; | ||
35 | u32 mask; | ||
36 | |||
37 | rst = to_qcom_reset_controller(rcdev); | ||
38 | map = &rst->reset_map[id]; | ||
39 | mask = BIT(map->bit); | ||
40 | |||
41 | return regmap_update_bits(rst->regmap, map->reg, mask, mask); | ||
42 | } | ||
43 | |||
44 | static int | ||
45 | qcom_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id) | ||
46 | { | ||
47 | struct qcom_reset_controller *rst; | ||
48 | const struct qcom_reset_map *map; | ||
49 | u32 mask; | ||
50 | |||
51 | rst = to_qcom_reset_controller(rcdev); | ||
52 | map = &rst->reset_map[id]; | ||
53 | mask = BIT(map->bit); | ||
54 | |||
55 | return regmap_update_bits(rst->regmap, map->reg, mask, 0); | ||
56 | } | ||
57 | |||
58 | struct reset_control_ops qcom_reset_ops = { | ||
59 | .reset = qcom_reset, | ||
60 | .assert = qcom_reset_assert, | ||
61 | .deassert = qcom_reset_deassert, | ||
62 | }; | ||
63 | EXPORT_SYMBOL_GPL(qcom_reset_ops); | ||
diff --git a/drivers/clk/qcom/reset.h b/drivers/clk/qcom/reset.h new file mode 100644 index 000000000000..0e11e2130f97 --- /dev/null +++ b/drivers/clk/qcom/reset.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. | ||
3 | * | ||
4 | * This software is licensed under the terms of the GNU General Public | ||
5 | * License version 2, as published by the Free Software Foundation, and | ||
6 | * may be copied, distributed, and modified under those terms. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #ifndef __QCOM_CLK_RESET_H__ | ||
15 | #define __QCOM_CLK_RESET_H__ | ||
16 | |||
17 | #include <linux/reset-controller.h> | ||
18 | |||
19 | struct qcom_reset_map { | ||
20 | unsigned int reg; | ||
21 | u8 bit; | ||
22 | }; | ||
23 | |||
24 | struct regmap; | ||
25 | |||
26 | struct qcom_reset_controller { | ||
27 | const struct qcom_reset_map *reset_map; | ||
28 | struct regmap *regmap; | ||
29 | struct reset_controller_dev rcdev; | ||
30 | }; | ||
31 | |||
32 | #define to_qcom_reset_controller(r) \ | ||
33 | container_of(r, struct qcom_reset_controller, rcdev); | ||
34 | |||
35 | extern struct reset_control_ops qcom_reset_ops; | ||
36 | |||
37 | #endif | ||