Lines Matching +full:gemini +full:- +full:enable +full:- +full:ide +full:- +full:pins

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Cortina Systems Gemini SATA bridge add-on to Faraday FTIDE010
24 * struct sata_gemini - a state container for a Gemini SATA bridge
28 * @ide_pins: if the device is using the plain IDE interface pins
50 * Values of IDE IOMUX bits in the misc control register
52 * Bits 26:24 are "IDE IO Select", which decides what SATA
53 * adapters are connected to which of the two IDE/ATA
54 * controllers in the Gemini. We can connect the two IDE blocks
55 * to one SATA adapter each, both acting as master, or one IDE
56 * blocks to two SATA adapters so the IDE block can act in a
59 * We also bring out different blocks on the actual IDE
60 * pins (not SATA pins) if (and only if) these are muxed in.
62 * 111-100 - Reserved
63 * Mode 0: 000 - ata0 master <-> sata0
64 * ata1 master <-> sata1
65 * ata0 slave interface brought out on IDE pads
66 * Mode 1: 001 - ata0 master <-> sata0
67 * ata1 master <-> sata1
68 * ata1 slave interface brought out on IDE pads
69 * Mode 2: 010 - ata1 master <-> sata1
70 * ata1 slave <-> sata0
72 * on IDE pads
73 * Mode 3: 011 - ata0 master <-> sata0
74 * ata1 slave <-> sata1
76 * on IDE pads
86 * Registers directly controlling the PATA<->SATA adapters
121 return ERR_PTR(-EPROBE_DEFER); in gemini_sata_bridge_get()
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()
146 return sg->muxmode; in gemini_sata_get_muxmode()
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()
191 return bridge_online ? 0: -ENODEV; in gemini_sata_setup_bridge()
200 pclk = sg->sata0_pclk; in gemini_sata_start_bridge()
202 pclk = sg->sata1_pclk; in gemini_sata_start_bridge()
221 clk_disable(sg->sata0_pclk); in gemini_sata_stop_bridge()
223 clk_disable(sg->sata1_pclk); in gemini_sata_stop_bridge()
231 reset_control_reset(sg->sata0_reset); in gemini_sata_reset_bridge()
233 reset_control_reset(sg->sata1_reset); in gemini_sata_reset_bridge()
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()
248 return -ENODEV; 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()
253 return -ENODEV; in gemini_sata_bridge_init()
256 ret = clk_prepare_enable(sg->sata0_pclk); in gemini_sata_bridge_init()
258 dev_err(dev, "failed to enable SATA0 PCLK\n"); in gemini_sata_bridge_init()
261 ret = clk_prepare_enable(sg->sata1_pclk); in gemini_sata_bridge_init()
263 dev_err(dev, "failed to enable SATA1 PCLK\n"); 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()
304 ide_state = pinctrl_lookup_state(p, "ide"); in gemini_setup_ide_pins()
310 dev_err(dev, "could not select IDE state\n"); in gemini_setup_ide_pins()
319 struct device *dev = &pdev->dev; in gemini_sata_probe()
320 struct device_node *np = dev->of_node; in gemini_sata_probe()
330 return -ENOMEM; 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()
344 if (of_property_read_bool(np, "cortina,gemini-enable-sata-bridge")) { in gemini_sata_probe()
350 if (of_property_read_bool(np, "cortina,gemini-enable-ide-pins")) 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()
354 dev_err(dev, "neither SATA bridge or IDE output enabled\n"); in gemini_sata_probe()
355 ret = -EINVAL; in gemini_sata_probe()
359 ret = of_property_read_u32(np, "cortina,gemini-ata-muxmode", &muxmode); in gemini_sata_probe()
366 ret = -EINVAL; in gemini_sata_probe()
369 sg->muxmode = muxmode; in gemini_sata_probe()
375 dev_err(dev, "unable to set up IDE muxing\n"); in gemini_sata_probe()
376 ret = -ENODEV; in gemini_sata_probe()
381 * Route out the IDE pins if desired. in gemini_sata_probe()
383 * "ide" that will route out the IDE pins. in gemini_sata_probe()
385 if (sg->ide_pins) { in gemini_sata_probe()
391 dev_info(dev, "set up the Gemini IDE/SATA nexus\n"); 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()
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()
417 { .compatible = "cortina,gemini-sata-bridge", },
432 MODULE_DESCRIPTION("low level driver for Cortina Systems Gemini SATA bridge");