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

reset: hi6220: Add support for AO reset controller

This is required to bring Mali450 gpu out of reset.

Cc: Peter Griffin <peter.griffin@linaro.org>
Cc: Enrico Weigelt <info@metux.net>
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
[jstultz: Added comment, Fix void return build issue
Reported-by: kbuild test robot <lkp@intel.com>]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Peter Griffin and committed by
Philipp Zabel
697fa27d e08672c0

+68 -1
+68 -1
drivers/reset/hisilicon/hi6220_reset.c
··· 33 33 enum hi6220_reset_ctrl_type { 34 34 PERIPHERAL, 35 35 MEDIA, 36 + AO, 36 37 }; 37 38 38 39 struct hi6220_reset_data { ··· 93 92 .deassert = hi6220_media_deassert, 94 93 }; 95 94 95 + #define AO_SCTRL_SC_PW_CLKEN0 0x800 96 + #define AO_SCTRL_SC_PW_CLKDIS0 0x804 97 + 98 + #define AO_SCTRL_SC_PW_RSTEN0 0x810 99 + #define AO_SCTRL_SC_PW_RSTDIS0 0x814 100 + 101 + #define AO_SCTRL_SC_PW_ISOEN0 0x820 102 + #define AO_SCTRL_SC_PW_ISODIS0 0x824 103 + #define AO_MAX_INDEX 12 104 + 105 + static int hi6220_ao_assert(struct reset_controller_dev *rc_dev, 106 + unsigned long idx) 107 + { 108 + struct hi6220_reset_data *data = to_reset_data(rc_dev); 109 + struct regmap *regmap = data->regmap; 110 + int ret; 111 + 112 + ret = regmap_write(regmap, AO_SCTRL_SC_PW_RSTEN0, BIT(idx)); 113 + if (ret) 114 + return ret; 115 + 116 + ret = regmap_write(regmap, AO_SCTRL_SC_PW_ISOEN0, BIT(idx)); 117 + if (ret) 118 + return ret; 119 + 120 + ret = regmap_write(regmap, AO_SCTRL_SC_PW_CLKDIS0, BIT(idx)); 121 + return ret; 122 + } 123 + 124 + static int hi6220_ao_deassert(struct reset_controller_dev *rc_dev, 125 + unsigned long idx) 126 + { 127 + struct hi6220_reset_data *data = to_reset_data(rc_dev); 128 + struct regmap *regmap = data->regmap; 129 + int ret; 130 + 131 + /* 132 + * It was suggested to disable isolation before enabling 133 + * the clocks and deasserting reset, to avoid glitches. 134 + * But this order is preserved to keep it matching the 135 + * vendor code. 136 + */ 137 + ret = regmap_write(regmap, AO_SCTRL_SC_PW_RSTDIS0, BIT(idx)); 138 + if (ret) 139 + return ret; 140 + 141 + ret = regmap_write(regmap, AO_SCTRL_SC_PW_ISODIS0, BIT(idx)); 142 + if (ret) 143 + return ret; 144 + 145 + ret = regmap_write(regmap, AO_SCTRL_SC_PW_CLKEN0, BIT(idx)); 146 + return ret; 147 + } 148 + 149 + static const struct reset_control_ops hi6220_ao_reset_ops = { 150 + .assert = hi6220_ao_assert, 151 + .deassert = hi6220_ao_deassert, 152 + }; 153 + 96 154 static int hi6220_reset_probe(struct platform_device *pdev) 97 155 { 98 156 struct device_node *np = pdev->dev.of_node; ··· 177 117 if (type == MEDIA) { 178 118 data->rc_dev.ops = &hi6220_media_reset_ops; 179 119 data->rc_dev.nr_resets = MEDIA_MAX_INDEX; 180 - } else { 120 + } else if (type == PERIPHERAL) { 181 121 data->rc_dev.ops = &hi6220_peripheral_reset_ops; 182 122 data->rc_dev.nr_resets = PERIPH_MAX_INDEX; 123 + } else { 124 + data->rc_dev.ops = &hi6220_ao_reset_ops; 125 + data->rc_dev.nr_resets = AO_MAX_INDEX; 183 126 } 184 127 185 128 return reset_controller_register(&data->rc_dev); ··· 196 133 { 197 134 .compatible = "hisilicon,hi6220-mediactrl", 198 135 .data = (void *)MEDIA, 136 + }, 137 + { 138 + .compatible = "hisilicon,hi6220-aoctrl", 139 + .data = (void *)AO, 199 140 }, 200 141 { /* sentinel */ }, 201 142 };