Lines Matching full:sg

125 bool gemini_sata_bridge_enabled(struct sata_gemini *sg, bool is_ata1)  in gemini_sata_bridge_enabled()  argument
127 if (!sg->sata_bridge) in gemini_sata_bridge_enabled()
133 if ((sg->muxmode == GEMINI_MUXMODE_2) && in gemini_sata_bridge_enabled()
136 if ((sg->muxmode == GEMINI_MUXMODE_3) && in gemini_sata_bridge_enabled()
144 enum gemini_muxmode gemini_sata_get_muxmode(struct sata_gemini *sg) in gemini_sata_get_muxmode() argument
146 return sg->muxmode; in gemini_sata_get_muxmode()
150 static int gemini_sata_setup_bridge(struct sata_gemini *sg, in gemini_sata_setup_bridge() argument
160 if (sg->muxmode == GEMINI_MUXMODE_2) in gemini_sata_setup_bridge()
162 writel(val, sg->base + GEMINI_SATA0_CTRL); in gemini_sata_setup_bridge()
166 if (sg->muxmode == GEMINI_MUXMODE_3) in gemini_sata_setup_bridge()
168 writel(val, sg->base + GEMINI_SATA1_CTRL); in gemini_sata_setup_bridge()
179 val = readl(sg->base + GEMINI_SATA0_STATUS); in gemini_sata_setup_bridge()
181 val = readl(sg->base + GEMINI_SATA1_STATUS); in gemini_sata_setup_bridge()
188 dev_info(sg->dev, "SATA%d PHY %s\n", bridge, in gemini_sata_setup_bridge()
194 int gemini_sata_start_bridge(struct sata_gemini *sg, unsigned int bridge) in gemini_sata_start_bridge() argument
200 pclk = sg->sata0_pclk; in gemini_sata_start_bridge()
202 pclk = sg->sata1_pclk; in gemini_sata_start_bridge()
210 ret = gemini_sata_setup_bridge(sg, bridge); in gemini_sata_start_bridge()
218 void gemini_sata_stop_bridge(struct sata_gemini *sg, unsigned int bridge) in gemini_sata_stop_bridge() argument
221 clk_disable(sg->sata0_pclk); in gemini_sata_stop_bridge()
223 clk_disable(sg->sata1_pclk); in gemini_sata_stop_bridge()
227 int gemini_sata_reset_bridge(struct sata_gemini *sg, in gemini_sata_reset_bridge() argument
231 reset_control_reset(sg->sata0_reset); in gemini_sata_reset_bridge()
233 reset_control_reset(sg->sata1_reset); in gemini_sata_reset_bridge()
235 return gemini_sata_setup_bridge(sg, bridge); in gemini_sata_reset_bridge()
239 static int gemini_sata_bridge_init(struct sata_gemini *sg) in gemini_sata_bridge_init() argument
241 struct device *dev = sg->dev; in gemini_sata_bridge_init()
245 sg->sata0_pclk = devm_clk_get(dev, "SATA0_PCLK"); in gemini_sata_bridge_init()
246 if (IS_ERR(sg->sata0_pclk)) { in gemini_sata_bridge_init()
250 sg->sata1_pclk = devm_clk_get(dev, "SATA1_PCLK"); in gemini_sata_bridge_init()
251 if (IS_ERR(sg->sata1_pclk)) { in gemini_sata_bridge_init()
256 ret = clk_prepare_enable(sg->sata0_pclk); in gemini_sata_bridge_init()
261 ret = clk_prepare_enable(sg->sata1_pclk); in gemini_sata_bridge_init()
264 clk_disable_unprepare(sg->sata0_pclk); in gemini_sata_bridge_init()
268 sg->sata0_reset = devm_reset_control_get_exclusive(dev, "sata0"); in gemini_sata_bridge_init()
269 if (IS_ERR(sg->sata0_reset)) { in gemini_sata_bridge_init()
271 clk_disable_unprepare(sg->sata1_pclk); in gemini_sata_bridge_init()
272 clk_disable_unprepare(sg->sata0_pclk); in gemini_sata_bridge_init()
273 return PTR_ERR(sg->sata0_reset); in gemini_sata_bridge_init()
275 sg->sata1_reset = devm_reset_control_get_exclusive(dev, "sata1"); in gemini_sata_bridge_init()
276 if (IS_ERR(sg->sata1_reset)) { in gemini_sata_bridge_init()
278 clk_disable_unprepare(sg->sata1_pclk); in gemini_sata_bridge_init()
279 clk_disable_unprepare(sg->sata0_pclk); in gemini_sata_bridge_init()
280 return PTR_ERR(sg->sata1_reset); in gemini_sata_bridge_init()
283 sata_id = readl(sg->base + GEMINI_SATA_ID); in gemini_sata_bridge_init()
284 sata_phy_id = readl(sg->base + GEMINI_SATA_PHY_ID); in gemini_sata_bridge_init()
285 sg->sata_bridge = true; in gemini_sata_bridge_init()
286 clk_disable(sg->sata0_pclk); in gemini_sata_bridge_init()
287 clk_disable(sg->sata1_pclk); in gemini_sata_bridge_init()
321 struct sata_gemini *sg; in gemini_sata_probe() local
328 sg = devm_kzalloc(dev, sizeof(*sg), GFP_KERNEL); in gemini_sata_probe()
329 if (!sg) in gemini_sata_probe()
331 sg->dev = dev; in gemini_sata_probe()
333 sg->base = devm_platform_ioremap_resource(pdev, 0); in gemini_sata_probe()
334 if (IS_ERR(sg->base)) in gemini_sata_probe()
335 return PTR_ERR(sg->base); in gemini_sata_probe()
345 ret = gemini_sata_bridge_init(sg); in gemini_sata_probe()
351 sg->ide_pins = true; in gemini_sata_probe()
353 if (!sg->sata_bridge && !sg->ide_pins) { in gemini_sata_probe()
369 sg->muxmode = muxmode; in gemini_sata_probe()
385 if (sg->ide_pins) { in gemini_sata_probe()
392 platform_set_drvdata(pdev, sg); in gemini_sata_probe()
393 sg_singleton = sg; in gemini_sata_probe()
398 if (sg->sata_bridge) { in gemini_sata_probe()
399 clk_unprepare(sg->sata1_pclk); in gemini_sata_probe()
400 clk_unprepare(sg->sata0_pclk); in gemini_sata_probe()
407 struct sata_gemini *sg = platform_get_drvdata(pdev); in gemini_sata_remove() local
409 if (sg->sata_bridge) { in gemini_sata_remove()
410 clk_unprepare(sg->sata1_pclk); in gemini_sata_remove()
411 clk_unprepare(sg->sata0_pclk); in gemini_sata_remove()