Lines Matching +full:sun7i +full:- +full:a20 +full:- +full:out +full:- +full:clk

1 /*-
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 #include <dev/clk/clk.h>
133 { "allwinner,sun4i-a10-usb-phy", (uintptr_t)&a10_usbphy_conf },
134 { "allwinner,sun5i-a13-usb-phy", (uintptr_t)&a13_usbphy_conf },
135 { "allwinner,sun6i-a31-usb-phy", (uintptr_t)&a31_usbphy_conf },
136 { "allwinner,sun7i-a20-usb-phy", (uintptr_t)&a20_usbphy_conf },
137 { "allwinner,sun8i-h3-usb-phy", (uintptr_t)&h3_usbphy_conf },
138 { "allwinner,sun50i-a64-usb-phy", (uintptr_t)&a64_usbphy_conf },
139 { "allwinner,sun8i-a83t-usb-phy", (uintptr_t)&a83t_usbphy_conf },
140 { "allwinner,sun50i-h6-usb-phy", (uintptr_t)&h6_usbphy_conf },
141 { "allwinner,sun20i-d1-usb-phy", (uintptr_t)&d1_usbphy_conf },
207 if (sc->pmu[phyno] == NULL) in awusbphy_configure()
210 if (sc->phy_conf->pmu_unk1 == true) in awusbphy_configure()
211 CLR4(sc->pmu[phyno], PMU_UNK_H3, PMU_UNK_H3_CLR); in awusbphy_configure()
213 SET4(sc->pmu[phyno], PMU_IRQ_ENABLE, PMU_ULPI_BYPASS | in awusbphy_configure()
227 clk_t clk; in awusbphy_init() local
232 sc->phy_conf = (struct aw_usbphy_conf *)ofw_bus_search_compatible(dev, compat_data)->ocd_data; in awusbphy_init()
235 if (ofw_bus_find_string_index(node, "reg-names", "phy_ctrl", &rid) != 0) { in awusbphy_init()
239 sc->phy_ctrl = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in awusbphy_init()
241 if (sc->phy_ctrl == NULL) { in awusbphy_init()
247 for (off = 0; clk_get_by_ofw_index(dev, 0, off, &clk) == 0; off++) { in awusbphy_init()
248 error = clk_enable(clk); in awusbphy_init()
251 clk_get_name(clk)); in awusbphy_init()
256 /* De-assert resets */ in awusbphy_init()
260 device_printf(dev, "couldn't de-assert reset %d\n", in awusbphy_init()
267 error = gpio_pin_get_by_ofw_property(dev, node, "usb0_id_det-gpios", in awusbphy_init()
268 &sc->id_det_pin); in awusbphy_init()
270 sc->id_det_valid = 1; in awusbphy_init()
271 error = gpio_pin_get_by_ofw_property(dev, node, "usb0_vbus_det-gpios", in awusbphy_init()
272 &sc->vbus_det_pin); in awusbphy_init()
274 sc->vbus_det_valid = 1; in awusbphy_init()
276 sc->reg = malloc(sizeof(*(sc->reg)) * sc->phy_conf->num_phys, M_DEVBUF, in awusbphy_init()
278 sc->pmu = malloc(sizeof(*(sc->pmu)) * sc->phy_conf->num_phys, M_DEVBUF, in awusbphy_init()
281 for (off = 0; off < sc->phy_conf->num_phys; off++) { in awusbphy_init()
282 snprintf(pname, sizeof(pname), "usb%d_vbus-supply", off); in awusbphy_init()
284 sc->reg[off] = reg; in awusbphy_init()
287 if (ofw_bus_find_string_index(node, "reg-names", in awusbphy_init()
291 sc->pmu[off] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in awusbphy_init()
293 if (sc->pmu[off] == NULL) { in awusbphy_init()
300 val = bus_read_4(sc->phy_ctrl, PHY_CSR); in awusbphy_init()
307 bus_write_4(sc->phy_ctrl, PHY_CSR, val); in awusbphy_init()
321 if (sc->vbus_det_valid) { in awusbphy_vbus_detect()
322 error = gpio_pin_is_active(sc->vbus_det_pin, &active); in awusbphy_vbus_detect()
332 /* TODO check vbus_power-supply. */ in awusbphy_vbus_detect()
354 if (phy < 0 || phy >= sc->phy_conf->num_phys) in awusbphy_phy_enable()
361 reg = sc->reg[phy]; in awusbphy_phy_enable()
369 goto out; in awusbphy_phy_enable()
371 /* TODO check vbus_power-supply as well. */ in awusbphy_phy_enable()
372 if (sc->vbus_det_valid && vbus_det == 1) { in awusbphy_phy_enable()
385 out: in awusbphy_phy_enable()
405 *mode = sc->mode; in awusbphy_get_mode()
429 if (sc->mode == mode) in awusbphy_set_mode()
438 val = bus_read_4(sc->phy_ctrl, PHY_CSR); in awusbphy_set_mode()
449 if (sc->phy_conf->phy0_route) in awusbphy_set_mode()
450 CLR4(sc->phy_ctrl, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG); in awusbphy_set_mode()
454 if (sc->phy_conf->phy0_route) in awusbphy_set_mode()
455 SET4(sc->phy_ctrl, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG); in awusbphy_set_mode()
461 bus_write_4(sc->phy_ctrl, PHY_CSR, val); in awusbphy_set_mode()
462 sc->mode = mode; in awusbphy_set_mode()
472 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in awusbphy_probe()
497 for (i = 0; i < sc->phy_conf->num_phys; i++) { in awusbphy_attach()