Lines Matching +full:aux +full:- +full:gpios

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
99 clk_t aclk_mst, aclk_slv, aclk_dbi, pclk, aux; member
106 {"rockchip,rk3568-pcie", 1},
116 device_printf(sc->dev, "INTERRUPT!!\n"); in rk3568_intr()
125 val = bus_read_4(sc->apb_res, PCIE_CLIENT_LTSSM_STATUS); in rk3568_pcie_get_link()
143 if (hwreset_assert(sc->hwreset)) in rk3568_pcie_init_soc()
147 if (regulator_enable(sc->regulator)) in rk3568_pcie_init_soc()
151 if (phy_enable(sc->phy)) in rk3568_pcie_init_soc()
155 if (hwreset_deassert(sc->hwreset)) in rk3568_pcie_init_soc()
159 if ((err = clk_enable(sc->aclk_mst))) { in rk3568_pcie_init_soc()
163 if ((err = clk_enable(sc->aclk_slv))) { in rk3568_pcie_init_soc()
167 if ((err = clk_enable(sc->aclk_dbi))) { in rk3568_pcie_init_soc()
171 if ((err = clk_enable(sc->pclk))) { in rk3568_pcie_init_soc()
175 if ((err = clk_enable(sc->aux))) { in rk3568_pcie_init_soc()
176 device_printf(dev, "Could not enable aux clk\n"); in rk3568_pcie_init_soc()
181 bus_write_4(sc->apb_res, PCIE_CLIENT_HOT_RESET_CTRL, in rk3568_pcie_init_soc()
183 bus_write_4(sc->apb_res, PCIE_CLIENT_GENERAL_CON, in rk3568_pcie_init_soc()
187 if ((err = gpio_pin_set_active(sc->reset_gpio, false))) in rk3568_pcie_init_soc()
191 bus_write_4(sc->apb_res, PCIE_CLIENT_GENERAL_CON, in rk3568_pcie_init_soc()
197 if ((err = gpio_pin_set_active(sc->reset_gpio, true))) in rk3568_pcie_init_soc()
201 for (count = 20; count; count--) { in rk3568_pcie_init_soc()
219 bus_write_4(sc->apb_res, PCIE_CLIENT_INTR_MASK_MSG_RX, 0x7fff0000); in rk3568_pcie_init_soc()
222 bus_write_4(sc->apb_res, PCIE_CLIENT_INTR_MASK_LEGACY, 0x00ff0000); in rk3568_pcie_init_soc()
225 bus_write_4(sc->apb_res, PCIE_CLIENT_INTR_MASK_ERR, 0x0fff0000); in rk3568_pcie_init_soc()
236 if (sc->irq_handle) in rk3568_pcie_detach()
237 bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); in rk3568_pcie_detach()
238 if (sc->phy) in rk3568_pcie_detach()
239 phy_release(sc->phy); in rk3568_pcie_detach()
240 if (sc->aux) in rk3568_pcie_detach()
241 clk_release(sc->aux); in rk3568_pcie_detach()
242 if (sc->pclk) in rk3568_pcie_detach()
243 clk_release(sc->pclk); in rk3568_pcie_detach()
244 if (sc->aclk_dbi) in rk3568_pcie_detach()
245 clk_release(sc->aclk_dbi); in rk3568_pcie_detach()
246 if (sc->aclk_slv) in rk3568_pcie_detach()
247 clk_release(sc->aclk_slv); in rk3568_pcie_detach()
248 if (sc->aclk_mst) in rk3568_pcie_detach()
249 clk_release(sc->aclk_mst); in rk3568_pcie_detach()
250 if (sc->hwreset) in rk3568_pcie_detach()
251 hwreset_release(sc->hwreset); in rk3568_pcie_detach()
252 if (sc->regulator) in rk3568_pcie_detach()
253 regulator_release(sc->regulator); in rk3568_pcie_detach()
254 if (sc->irq_res) in rk3568_pcie_detach()
255 bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, in rk3568_pcie_detach()
256 sc->irq_res); in rk3568_pcie_detach()
257 if (sc->dbi_res) in rk3568_pcie_detach()
258 bus_release_resource(dev, SYS_RES_MEMORY, sc->dbi_rid, in rk3568_pcie_detach()
259 sc->dbi_res); in rk3568_pcie_detach()
260 if (sc->apb_res) in rk3568_pcie_detach()
261 bus_release_resource(dev, SYS_RES_MEMORY, sc->apb_rid, in rk3568_pcie_detach()
262 sc->apb_res); in rk3568_pcie_detach()
272 sc->dev = dev; in rk3568_pcie_attach()
273 sc->node = ofw_bus_get_node(dev); in rk3568_pcie_attach()
276 if ((error = ofw_bus_find_string_index(sc->node, "reg-names", "apb", in rk3568_pcie_attach()
277 &sc->apb_rid))) { in rk3568_pcie_attach()
281 if (!(sc->apb_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in rk3568_pcie_attach()
282 &sc->apb_rid, RF_ACTIVE))) { in rk3568_pcie_attach()
286 if ((error = ofw_bus_find_string_index(sc->node, "reg-names", "dbi", in rk3568_pcie_attach()
287 &sc->dbi_rid))) { in rk3568_pcie_attach()
291 if (!(sc->dw_sc.dbi_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in rk3568_pcie_attach()
292 &sc->dbi_rid, RF_ACTIVE))) { in rk3568_pcie_attach()
297 if (!(sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, in rk3568_pcie_attach()
298 &sc->irq_rid, RF_ACTIVE | RF_SHAREABLE))) { in rk3568_pcie_attach()
304 if (regulator_get_by_ofw_property(dev, 0, "vpcie3v3-supply", in rk3568_pcie_attach()
305 &sc->regulator)) { in rk3568_pcie_attach()
311 if (hwreset_get_by_ofw_name(dev, 0, "pipe", &sc->hwreset)) { in rk3568_pcie_attach()
317 if (OF_hasprop(sc->node, "reset-gpios")) { in rk3568_pcie_attach()
318 if (gpio_pin_get_by_ofw_property(dev, sc->node, "reset-gpios", in rk3568_pcie_attach()
319 &sc->reset_gpio)) { in rk3568_pcie_attach()
320 device_printf(dev, "Cannot get reset-gpios\n"); in rk3568_pcie_attach()
323 gpio_pin_setflags(sc->reset_gpio, GPIO_PIN_OUTPUT); in rk3568_pcie_attach()
324 gpio_pin_set_active(sc->reset_gpio, true); in rk3568_pcie_attach()
328 if (clk_get_by_ofw_name(dev, 0, "aclk_mst", &sc->aclk_mst)) { in rk3568_pcie_attach()
332 if (clk_get_by_ofw_name(dev, 0, "aclk_slv", &sc->aclk_slv)) { in rk3568_pcie_attach()
336 if (clk_get_by_ofw_name(dev, 0, "aclk_dbi", &sc->aclk_dbi)) { in rk3568_pcie_attach()
340 if (clk_get_by_ofw_name(dev, 0, "pclk", &sc->pclk)) { in rk3568_pcie_attach()
344 if (clk_get_by_ofw_name(dev, 0, "aux", &sc->aux)) { in rk3568_pcie_attach()
345 device_printf(dev, "Can not get aux clk\n"); in rk3568_pcie_attach()
350 if (phy_get_by_ofw_name(dev, 0, "pcie-phy", &sc->phy)) { in rk3568_pcie_attach()
351 device_printf(dev, "Cannot get 'pcie-phy'\n"); in rk3568_pcie_attach()
359 if ((bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, in rk3568_pcie_attach()
360 NULL, rk3568_intr, sc, &sc->irq_handle))) { in rk3568_pcie_attach()
377 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) in rk3568_pcie_probe()
379 device_set_desc(dev, "RockChip RK3568 PCI-express controller"); in rk3568_pcie_probe()