aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinliang Liu <xinliang.liu@linaro.org>2016-06-19 23:50:07 -0400
committerPhilipp Zabel <p.zabel@pengutronix.de>2016-06-29 17:39:09 -0400
commitab52b599c197b5e50ad918f8084673d9b4caed83 (patch)
tree9c7db08fb799190cd95a4191a1d3d4ac89b42edd
parent8768a26cea4c54eb8d38bc063fbfba7c60c571f4 (diff)
reset: hisilicon: Add hi6220 media subsystem reset support
Add hi6220 media subsystem reset controller. Signed-off-by: Chen Feng <puck.chen@hisilicon.com> Signed-off-by: Xia Qing <saberlily.xia@hisilicon.com> Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
-rw-r--r--drivers/reset/hisilicon/hi6220_reset.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/drivers/reset/hisilicon/hi6220_reset.c b/drivers/reset/hisilicon/hi6220_reset.c
index 686fea9e2c54..35ce53edabf9 100644
--- a/drivers/reset/hisilicon/hi6220_reset.c
+++ b/drivers/reset/hisilicon/hi6220_reset.c
@@ -27,8 +27,17 @@
27#define PERIPH_DEASSERT_OFFSET 0x304 27#define PERIPH_DEASSERT_OFFSET 0x304
28#define PERIPH_MAX_INDEX 0x509 28#define PERIPH_MAX_INDEX 0x509
29 29
30#define SC_MEDIA_RSTEN 0x052C
31#define SC_MEDIA_RSTDIS 0x0530
32#define MEDIA_MAX_INDEX 8
33
30#define to_reset_data(x) container_of(x, struct hi6220_reset_data, rc_dev) 34#define to_reset_data(x) container_of(x, struct hi6220_reset_data, rc_dev)
31 35
36enum hi6220_reset_ctrl_type {
37 PERIPHERAL,
38 MEDIA,
39};
40
32struct hi6220_reset_data { 41struct hi6220_reset_data {
33 struct reset_controller_dev rc_dev; 42 struct reset_controller_dev rc_dev;
34 struct regmap *regmap; 43 struct regmap *regmap;
@@ -63,10 +72,34 @@ static const struct reset_control_ops hi6220_peripheral_reset_ops = {
63 .deassert = hi6220_peripheral_deassert, 72 .deassert = hi6220_peripheral_deassert,
64}; 73};
65 74
75static int hi6220_media_assert(struct reset_controller_dev *rc_dev,
76 unsigned long idx)
77{
78 struct hi6220_reset_data *data = to_reset_data(rc_dev);
79 struct regmap *regmap = data->regmap;
80
81 return regmap_write(regmap, SC_MEDIA_RSTEN, BIT(idx));
82}
83
84static int hi6220_media_deassert(struct reset_controller_dev *rc_dev,
85 unsigned long idx)
86{
87 struct hi6220_reset_data *data = to_reset_data(rc_dev);
88 struct regmap *regmap = data->regmap;
89
90 return regmap_write(regmap, SC_MEDIA_RSTDIS, BIT(idx));
91}
92
93static const struct reset_control_ops hi6220_media_reset_ops = {
94 .assert = hi6220_media_assert,
95 .deassert = hi6220_media_deassert,
96};
97
66static int hi6220_reset_probe(struct platform_device *pdev) 98static int hi6220_reset_probe(struct platform_device *pdev)
67{ 99{
68 struct device_node *np = pdev->dev.of_node; 100 struct device_node *np = pdev->dev.of_node;
69 struct device *dev = &pdev->dev; 101 struct device *dev = &pdev->dev;
102 enum hi6220_reset_ctrl_type type;
70 struct hi6220_reset_data *data; 103 struct hi6220_reset_data *data;
71 struct regmap *regmap; 104 struct regmap *regmap;
72 105
@@ -74,6 +107,8 @@ static int hi6220_reset_probe(struct platform_device *pdev)
74 if (!data) 107 if (!data)
75 return -ENOMEM; 108 return -ENOMEM;
76 109
110 type = (enum hi6220_reset_ctrl_type)of_device_get_match_data(dev);
111
77 regmap = syscon_node_to_regmap(np); 112 regmap = syscon_node_to_regmap(np);
78 if (IS_ERR(regmap)) { 113 if (IS_ERR(regmap)) {
79 dev_err(dev, "failed to get reset controller regmap\n"); 114 dev_err(dev, "failed to get reset controller regmap\n");
@@ -82,8 +117,13 @@ static int hi6220_reset_probe(struct platform_device *pdev)
82 117
83 data->regmap = regmap; 118 data->regmap = regmap;
84 data->rc_dev.of_node = np; 119 data->rc_dev.of_node = np;
85 data->rc_dev.ops = &hi6220_peripheral_reset_ops; 120 if (type == MEDIA) {
86 data->rc_dev.nr_resets = PERIPH_MAX_INDEX; 121 data->rc_dev.ops = &hi6220_media_reset_ops;
122 data->rc_dev.nr_resets = MEDIA_MAX_INDEX;
123 } else {
124 data->rc_dev.ops = &hi6220_peripheral_reset_ops;
125 data->rc_dev.nr_resets = PERIPH_MAX_INDEX;
126 }
87 127
88 return reset_controller_register(&data->rc_dev); 128 return reset_controller_register(&data->rc_dev);
89} 129}
@@ -91,6 +131,11 @@ static int hi6220_reset_probe(struct platform_device *pdev)
91static const struct of_device_id hi6220_reset_match[] = { 131static const struct of_device_id hi6220_reset_match[] = {
92 { 132 {
93 .compatible = "hisilicon,hi6220-sysctrl", 133 .compatible = "hisilicon,hi6220-sysctrl",
134 .data = (void *)PERIPHERAL,
135 },
136 {
137 .compatible = "hisilicon,hi6220-mediactrl",
138 .data = (void *)MEDIA,
94 }, 139 },
95 { /* sentinel */ }, 140 { /* sentinel */ },
96}; 141};