Lines Matching refs:sg
126 bool gemini_sata_bridge_enabled(struct sata_gemini *sg, bool is_ata1) in gemini_sata_bridge_enabled() argument
128 if (!sg->sata_bridge) in gemini_sata_bridge_enabled()
134 if ((sg->muxmode == GEMINI_MUXMODE_2) && in gemini_sata_bridge_enabled()
137 if ((sg->muxmode == GEMINI_MUXMODE_3) && in gemini_sata_bridge_enabled()
145 enum gemini_muxmode gemini_sata_get_muxmode(struct sata_gemini *sg) in gemini_sata_get_muxmode() argument
147 return sg->muxmode; in gemini_sata_get_muxmode()
151 static int gemini_sata_setup_bridge(struct sata_gemini *sg, in gemini_sata_setup_bridge() argument
161 if (sg->muxmode == GEMINI_MUXMODE_2) in gemini_sata_setup_bridge()
163 writel(val, sg->base + GEMINI_SATA0_CTRL); in gemini_sata_setup_bridge()
167 if (sg->muxmode == GEMINI_MUXMODE_3) in gemini_sata_setup_bridge()
169 writel(val, sg->base + GEMINI_SATA1_CTRL); in gemini_sata_setup_bridge()
180 val = readl(sg->base + GEMINI_SATA0_STATUS); in gemini_sata_setup_bridge()
182 val = readl(sg->base + GEMINI_SATA1_STATUS); in gemini_sata_setup_bridge()
189 dev_info(sg->dev, "SATA%d PHY %s\n", bridge, in gemini_sata_setup_bridge()
195 int gemini_sata_start_bridge(struct sata_gemini *sg, unsigned int bridge) in gemini_sata_start_bridge() argument
201 pclk = sg->sata0_pclk; in gemini_sata_start_bridge()
203 pclk = sg->sata1_pclk; in gemini_sata_start_bridge()
208 ret = gemini_sata_setup_bridge(sg, bridge); in gemini_sata_start_bridge()
216 void gemini_sata_stop_bridge(struct sata_gemini *sg, unsigned int bridge) in gemini_sata_stop_bridge() argument
219 clk_disable(sg->sata0_pclk); in gemini_sata_stop_bridge()
221 clk_disable(sg->sata1_pclk); in gemini_sata_stop_bridge()
225 int gemini_sata_reset_bridge(struct sata_gemini *sg, in gemini_sata_reset_bridge() argument
229 reset_control_reset(sg->sata0_reset); in gemini_sata_reset_bridge()
231 reset_control_reset(sg->sata1_reset); in gemini_sata_reset_bridge()
233 return gemini_sata_setup_bridge(sg, bridge); in gemini_sata_reset_bridge()
237 static int gemini_sata_bridge_init(struct sata_gemini *sg) in gemini_sata_bridge_init() argument
239 struct device *dev = sg->dev; in gemini_sata_bridge_init()
243 sg->sata0_pclk = devm_clk_get(dev, "SATA0_PCLK"); in gemini_sata_bridge_init()
244 if (IS_ERR(sg->sata0_pclk)) { in gemini_sata_bridge_init()
248 sg->sata1_pclk = devm_clk_get(dev, "SATA1_PCLK"); in gemini_sata_bridge_init()
249 if (IS_ERR(sg->sata1_pclk)) { in gemini_sata_bridge_init()
254 ret = clk_prepare_enable(sg->sata0_pclk); in gemini_sata_bridge_init()
259 ret = clk_prepare_enable(sg->sata1_pclk); in gemini_sata_bridge_init()
262 clk_disable_unprepare(sg->sata0_pclk); in gemini_sata_bridge_init()
266 sg->sata0_reset = devm_reset_control_get_exclusive(dev, "sata0"); in gemini_sata_bridge_init()
267 if (IS_ERR(sg->sata0_reset)) { in gemini_sata_bridge_init()
269 clk_disable_unprepare(sg->sata1_pclk); in gemini_sata_bridge_init()
270 clk_disable_unprepare(sg->sata0_pclk); in gemini_sata_bridge_init()
271 return PTR_ERR(sg->sata0_reset); in gemini_sata_bridge_init()
273 sg->sata1_reset = devm_reset_control_get_exclusive(dev, "sata1"); in gemini_sata_bridge_init()
274 if (IS_ERR(sg->sata1_reset)) { in gemini_sata_bridge_init()
276 clk_disable_unprepare(sg->sata1_pclk); in gemini_sata_bridge_init()
277 clk_disable_unprepare(sg->sata0_pclk); in gemini_sata_bridge_init()
278 return PTR_ERR(sg->sata1_reset); in gemini_sata_bridge_init()
281 sata_id = readl(sg->base + GEMINI_SATA_ID); in gemini_sata_bridge_init()
282 sata_phy_id = readl(sg->base + GEMINI_SATA_PHY_ID); in gemini_sata_bridge_init()
283 sg->sata_bridge = true; in gemini_sata_bridge_init()
284 clk_disable(sg->sata0_pclk); in gemini_sata_bridge_init()
285 clk_disable(sg->sata1_pclk); in gemini_sata_bridge_init()
319 struct sata_gemini *sg; in gemini_sata_probe() local
327 sg = devm_kzalloc(dev, sizeof(*sg), GFP_KERNEL); in gemini_sata_probe()
328 if (!sg) in gemini_sata_probe()
330 sg->dev = dev; in gemini_sata_probe()
336 sg->base = devm_ioremap_resource(dev, res); in gemini_sata_probe()
337 if (IS_ERR(sg->base)) in gemini_sata_probe()
338 return PTR_ERR(sg->base); in gemini_sata_probe()
348 ret = gemini_sata_bridge_init(sg); in gemini_sata_probe()
354 sg->ide_pins = true; in gemini_sata_probe()
356 if (!sg->sata_bridge && !sg->ide_pins) { in gemini_sata_probe()
372 sg->muxmode = muxmode; in gemini_sata_probe()
388 if (sg->ide_pins) { in gemini_sata_probe()
395 platform_set_drvdata(pdev, sg); in gemini_sata_probe()
396 sg_singleton = sg; in gemini_sata_probe()
401 if (sg->sata_bridge) { in gemini_sata_probe()
402 clk_unprepare(sg->sata1_pclk); in gemini_sata_probe()
403 clk_unprepare(sg->sata0_pclk); in gemini_sata_probe()
410 struct sata_gemini *sg = platform_get_drvdata(pdev); in gemini_sata_remove() local
412 if (sg->sata_bridge) { in gemini_sata_remove()
413 clk_unprepare(sg->sata1_pclk); in gemini_sata_remove()
414 clk_unprepare(sg->sata0_pclk); in gemini_sata_remove()