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

Configure Feed

Select the types of activity you want to include in your feed.

reset: th1520: Prepare for supporting multiple controllers

TH1520 SoC is divided into several subsystems, shipping distinct reset
controllers with similar control logic. Let's make reset signal mapping
a data structure specific to one compatible to prepare for introduction
of more reset controllers in the future.

Signed-off-by: Yao Zi <ziyao@disroot.org>
Acked-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Drew Fustini <fustini@kernel.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Yao Zi and committed by
Philipp Zabel
0040d9ea a35ac6f3

+32 -14
+32 -14
drivers/reset/reset-th1520.c
··· 29 29 #define TH1520_HDMI_SW_MAIN_RST BIT(0) 30 30 #define TH1520_HDMI_SW_PRST BIT(1) 31 31 32 - struct th1520_reset_priv { 33 - struct reset_controller_dev rcdev; 34 - struct regmap *map; 35 - }; 36 - 37 32 struct th1520_reset_map { 38 33 u32 bit; 39 34 u32 reg; 35 + }; 36 + 37 + struct th1520_reset_priv { 38 + struct reset_controller_dev rcdev; 39 + struct regmap *map; 40 + const struct th1520_reset_map *resets; 41 + }; 42 + 43 + struct th1520_reset_data { 44 + const struct th1520_reset_map *resets; 45 + size_t num; 40 46 }; 41 47 42 48 static const struct th1520_reset_map th1520_resets[] = { ··· 96 90 struct th1520_reset_priv *priv = to_th1520_reset(rcdev); 97 91 const struct th1520_reset_map *reset; 98 92 99 - reset = &th1520_resets[id]; 93 + reset = &priv->resets[id]; 100 94 101 95 return regmap_update_bits(priv->map, reset->reg, reset->bit, 0); 102 96 } ··· 107 101 struct th1520_reset_priv *priv = to_th1520_reset(rcdev); 108 102 const struct th1520_reset_map *reset; 109 103 110 - reset = &th1520_resets[id]; 104 + reset = &priv->resets[id]; 111 105 112 106 return regmap_update_bits(priv->map, reset->reg, reset->bit, 113 107 reset->bit); ··· 126 120 127 121 static int th1520_reset_probe(struct platform_device *pdev) 128 122 { 123 + const struct th1520_reset_data *data; 129 124 struct device *dev = &pdev->dev; 130 125 struct th1520_reset_priv *priv; 131 126 void __iomem *base; 132 127 int ret; 128 + 129 + data = device_get_match_data(dev); 133 130 134 131 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 135 132 if (!priv) ··· 147 138 if (IS_ERR(priv->map)) 148 139 return PTR_ERR(priv->map); 149 140 150 - /* Initialize GPU resets to asserted state */ 151 - ret = regmap_update_bits(priv->map, TH1520_GPU_RST_CFG, 152 - TH1520_GPU_RST_CFG_MASK, 0); 153 - if (ret) 154 - return ret; 141 + if (of_device_is_compatible(dev->of_node, "thead,th1520-reset")) { 142 + /* Initialize GPU resets to asserted state */ 143 + ret = regmap_update_bits(priv->map, TH1520_GPU_RST_CFG, 144 + TH1520_GPU_RST_CFG_MASK, 0); 145 + if (ret) 146 + return ret; 147 + } 155 148 156 149 priv->rcdev.owner = THIS_MODULE; 157 - priv->rcdev.nr_resets = ARRAY_SIZE(th1520_resets); 150 + priv->rcdev.nr_resets = data->num; 158 151 priv->rcdev.ops = &th1520_reset_ops; 159 152 priv->rcdev.of_node = dev->of_node; 153 + 154 + priv->resets = data->resets; 160 155 161 156 return devm_reset_controller_register(dev, &priv->rcdev); 162 157 } 163 158 159 + static const struct th1520_reset_data th1520_reset_data = { 160 + .resets = th1520_resets, 161 + .num = ARRAY_SIZE(th1520_resets), 162 + }; 163 + 164 164 static const struct of_device_id th1520_reset_match[] = { 165 - { .compatible = "thead,th1520-reset" }, 165 + { .compatible = "thead,th1520-reset", .data = &th1520_reset_data }, 166 166 { /* sentinel */ } 167 167 }; 168 168 MODULE_DEVICE_TABLE(of, th1520_reset_match);