Lines Matching +full:gemini +full:- +full:pata
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Cortina Systems Gemini SATA bridge add-on to Faraday FTIDE010
25 * struct sata_gemini - a state container for a Gemini SATA bridge
55 * controllers in the Gemini. We can connect the two IDE blocks
63 * 111-100 - Reserved
64 * Mode 0: 000 - ata0 master <-> sata0
65 * ata1 master <-> sata1
67 * Mode 1: 001 - ata0 master <-> sata0
68 * ata1 master <-> sata1
70 * Mode 2: 010 - ata1 master <-> sata1
71 * ata1 slave <-> sata0
74 * Mode 3: 011 - ata0 master <-> sata0
75 * ata1 slave <-> sata1
87 * Registers directly controlling the PATA<->SATA adapters
122 return ERR_PTR(-EPROBE_DEFER); in gemini_sata_bridge_get()
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()
147 return sg->muxmode; in gemini_sata_get_muxmode()
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()
192 return bridge_online ? 0: -ENODEV; in gemini_sata_setup_bridge()
201 pclk = sg->sata0_pclk; in gemini_sata_start_bridge()
203 pclk = sg->sata1_pclk; in gemini_sata_start_bridge()
219 clk_disable(sg->sata0_pclk); in gemini_sata_stop_bridge()
221 clk_disable(sg->sata1_pclk); in gemini_sata_stop_bridge()
229 reset_control_reset(sg->sata0_reset); in gemini_sata_reset_bridge()
231 reset_control_reset(sg->sata1_reset); in gemini_sata_reset_bridge()
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()
246 return -ENODEV; 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()
251 return -ENODEV; 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()
317 struct device *dev = &pdev->dev; in gemini_sata_probe()
318 struct device_node *np = dev->of_node; in gemini_sata_probe()
329 return -ENOMEM; in gemini_sata_probe()
330 sg->dev = dev; in gemini_sata_probe()
334 return -ENODEV; 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()
347 if (of_property_read_bool(np, "cortina,gemini-enable-sata-bridge")) { in gemini_sata_probe()
353 if (of_property_read_bool(np, "cortina,gemini-enable-ide-pins")) 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()
358 ret = -EINVAL; in gemini_sata_probe()
362 ret = of_property_read_u32(np, "cortina,gemini-ata-muxmode", &muxmode); in gemini_sata_probe()
369 ret = -EINVAL; in gemini_sata_probe()
372 sg->muxmode = muxmode; in gemini_sata_probe()
379 ret = -ENODEV; in gemini_sata_probe()
388 if (sg->ide_pins) { in gemini_sata_probe()
394 dev_info(dev, "set up the Gemini IDE/SATA nexus\n"); 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()
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()
423 .compatible = "cortina,gemini-sata-bridge",