Lines Matching +full:sun4i +full:- +full:a10 +full:- +full:ahci
1 /*-
3 * Copyright (c) 2014-2015 M. Warner Losh <imp@FreeBSD.org>
26 * The magic-bit-bang sequence used in this code may be based on a linux
45 #include <dev/ahci/ahci.h>
50 * Allwinner a1x/a2x/a8x SATA attachment. This is just the AHCI register
51 * set with a few extra implementation-specific registers that need to
59 /* BITx -- Unknown bit that needs to be set/cleared at position x */
60 /* UFx -- Uknown multi-bit field frobbed during init */
165 * Here starts the magic -- most of the comments are based in ahci_a10_phy_reset()
176 ATA_OUTL(ctlr->r_mem, AHCI_RWCR, 0); in ahci_a10_phy_reset()
183 ahci_set(ctlr->r_mem, AHCI_PHYCS1R, PHYCS1R_HIGHZ); in ahci_a10_phy_reset()
188 ahci_mask_set(ctlr->r_mem, AHCI_PHYCS0R, in ahci_a10_phy_reset()
195 ahci_mask_set(ctlr->r_mem, AHCI_PHYCS1R, in ahci_a10_phy_reset()
200 * Two more mystery bits in PHYCS1R. -- can these be combined above? in ahci_a10_phy_reset()
202 ahci_set(ctlr->r_mem, AHCI_PHYCS1R, PHYCS1R_BIT15 | PHYCS1R_BIT28); in ahci_a10_phy_reset()
209 ahci_clr(ctlr->r_mem, AHCI_PHYCS1R, PHYCS1R_HIGHZ); in ahci_a10_phy_reset()
214 ahci_mask_set(ctlr->r_mem, AHCI_PHYCS0R, in ahci_a10_phy_reset()
220 ahci_mask_set(ctlr->r_mem, AHCI_PHYCS2R, ~PHYCS2R_UF1_MASK, in ahci_a10_phy_reset()
229 ahci_set(ctlr->r_mem, AHCI_PHYCS0R, PHYCS0R_POWER_ENABLE); in ahci_a10_phy_reset()
230 for (to = PHY_RESET_TIMEOUT; to > 0; to--) { in ahci_a10_phy_reset()
231 val = ATA_INL(ctlr->r_mem, AHCI_PHYCS0R); in ahci_a10_phy_reset()
243 ahci_set(ctlr->r_mem, AHCI_PHYCS2R, PHYCS2R_CALIBRATE); in ahci_a10_phy_reset()
244 for (to = PHY_RESET_TIMEOUT; to > 0; to--) { in ahci_a10_phy_reset()
245 val = ATA_INL(ctlr->r_mem, AHCI_PHYCS2R); in ahci_a10_phy_reset()
261 ATA_OUTL(ctlr->r_mem, AHCI_RWCR, 7); in ahci_a10_phy_reset()
273 reg = ATA_INL(ch->r_mem, AHCI_P0DMACR); in ahci_a10_ch_start()
276 ATA_OUTL(ch->r_mem, AHCI_P0DMACR, reg); in ahci_a10_ch_start()
292 if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-a10-ahci")) in ahci_a10_probe()
294 device_set_desc(dev, "Allwinner Integrated AHCI controller"); in ahci_a10_probe()
307 ctlr = &sc->ahci_ctlr; in ahci_a10_attach()
309 ctlr->quirks = AHCI_Q_NOPMP; in ahci_a10_attach()
310 ctlr->vendorid = 0; in ahci_a10_attach()
311 ctlr->deviceid = 0; in ahci_a10_attach()
312 ctlr->subvendorid = 0; in ahci_a10_attach()
313 ctlr->subdeviceid = 0; in ahci_a10_attach()
314 ctlr->r_rid = 0; in ahci_a10_attach()
315 if (!(ctlr->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in ahci_a10_attach()
316 &ctlr->r_rid, RF_ACTIVE))) in ahci_a10_attach()
320 if (regulator_get_by_ofw_property(dev, 0, "target-supply", in ahci_a10_attach()
321 &sc->ahci_reg) == 0) { in ahci_a10_attach()
322 error = regulator_enable(sc->ahci_reg); in ahci_a10_attach()
330 error = clk_get_by_ofw_index(dev, 0, 0, &sc->clk_gate); in ahci_a10_attach()
335 error = clk_get_by_ofw_index(dev, 0, 1, &sc->clk_pll); in ahci_a10_attach()
340 error = clk_set_freq(sc->clk_pll, PLL_FREQ, CLK_SET_ROUND_DOWN); in ahci_a10_attach()
345 error = clk_enable(sc->clk_pll); in ahci_a10_attach()
350 error = clk_enable(sc->clk_gate); in ahci_a10_attach()
363 ctlr->msi = 0; in ahci_a10_attach()
364 ctlr->numirqs = 1; in ahci_a10_attach()
367 ctlr->ch_start = ahci_a10_ch_start; in ahci_a10_attach()
370 * Note: ahci_attach will release ctlr->r_mem on errors automatically in ahci_a10_attach()
375 if (sc->ahci_reg != NULL) in ahci_a10_attach()
376 regulator_disable(sc->ahci_reg); in ahci_a10_attach()
377 if (sc->clk_gate != NULL) in ahci_a10_attach()
378 clk_release(sc->clk_gate); in ahci_a10_attach()
379 if (sc->clk_pll != NULL) in ahci_a10_attach()
380 clk_release(sc->clk_pll); in ahci_a10_attach()
381 bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, ctlr->r_mem); in ahci_a10_attach()
392 ctlr = &sc->ahci_ctlr; in ahci_a10_detach()
394 if (sc->ahci_reg != NULL) in ahci_a10_detach()
395 regulator_disable(sc->ahci_reg); in ahci_a10_detach()
396 if (sc->clk_gate != NULL) in ahci_a10_detach()
397 clk_release(sc->clk_gate); in ahci_a10_detach()
398 if (sc->clk_pll != NULL) in ahci_a10_detach()
399 clk_release(sc->clk_pll); in ahci_a10_detach()
400 bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, ctlr->r_mem); in ahci_a10_detach()
418 "ahci",