Lines Matching +full:bridge +full:- +full:enable
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
29 * @sata_bridge: if the device enables the SATA bridge
62 * 111-100 - Reserved
63 * Mode 0: 000 - ata0 master <-> sata0
64 * ata1 master <-> sata1
66 * Mode 1: 001 - ata0 master <-> sata0
67 * ata1 master <-> sata1
69 * Mode 2: 010 - ata1 master <-> sata1
70 * ata1 slave <-> sata0
73 * Mode 3: 011 - ata0 master <-> sata0
74 * ata1 slave <-> sata1
86 * Registers directly controlling the PATA<->SATA adapters
111 * There is only ever one instance of this bridge on a system,
121 return ERR_PTR(-EPROBE_DEFER); in gemini_sata_bridge_get()
127 if (!sg->sata_bridge) in gemini_sata_bridge_enabled()
131 * actually not connected to any 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()
151 unsigned int bridge) in gemini_sata_setup_bridge() argument
157 if (bridge == 0) { in gemini_sata_setup_bridge()
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()
178 if (bridge == 0) 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()
194 int gemini_sata_start_bridge(struct sata_gemini *sg, unsigned int bridge) in gemini_sata_start_bridge() argument
199 if (bridge == 0) in gemini_sata_start_bridge()
200 pclk = sg->sata0_pclk; in gemini_sata_start_bridge()
202 pclk = sg->sata1_pclk; in gemini_sata_start_bridge()
209 /* Do not keep clocking a bridge that is not online */ 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
220 if (bridge == 0) in gemini_sata_stop_bridge()
221 clk_disable(sg->sata0_pclk); in gemini_sata_stop_bridge()
222 else if (bridge == 1) in gemini_sata_stop_bridge()
223 clk_disable(sg->sata1_pclk); in gemini_sata_stop_bridge()
228 unsigned int bridge) in gemini_sata_reset_bridge() argument
230 if (bridge == 0) in gemini_sata_reset_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()
235 return gemini_sata_setup_bridge(sg, bridge); 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()
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()
343 /* Set up the SATA bridge if need be */ 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()
376 ret = -ENODEV; in gemini_sata_probe()
385 if (sg->ide_pins) { 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");