Lines Matching +full:syscon +full:- +full:dev
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
42 #include <dev/fdt/fdt_common.h>
43 #include <dev/ofw/ofw_bus.h>
44 #include <dev/ofw/ofw_bus_subr.h>
46 #include <dev/clk/clk.h>
47 #include <dev/syscon/syscon.h>
48 #include <dev/phy/phy.h>
102 { "rockchip,rk3399-emmc-phy", 1 },
107 struct syscon *syscon; member
112 #define LOWEST_SET_BIT(mask) ((((mask) - 1) & (mask)) ^ (mask))
129 device_t dev; in rk_emmcphy_enable() local
135 dev = phynode_get_device(phynode); in rk_emmcphy_enable()
137 sc = device_get_softc(dev); in rk_emmcphy_enable()
140 device_printf(dev, "Phy id: %ld\n", phy); in rk_emmcphy_enable()
143 device_printf(dev, "Unknown phy: %ld\n", phy); in rk_emmcphy_enable()
150 SYSCON_WRITE_4(sc->syscon, GRF_EMMCPHY_CON6, in rk_emmcphy_enable()
156 SYSCON_WRITE_4(sc->syscon, GRF_EMMCPHY_CON0, in rk_emmcphy_enable()
163 SYSCON_WRITE_4(sc->syscon, GRF_EMMCPHY_CON6, (mask << 16) | val); in rk_emmcphy_enable()
168 sc->phy_conf = (struct rk_emmcphy_conf *)ofw_bus_search_compatible(dev, in rk_emmcphy_enable()
169 compat_data)->ocd_data; in rk_emmcphy_enable()
172 error = clk_get_by_ofw_name(dev, 0, "emmcclk", &sc->clk); in rk_emmcphy_enable()
174 device_printf(dev, "cannot get emmcclk clock, continue\n"); in rk_emmcphy_enable()
175 sc->clk = NULL; in rk_emmcphy_enable()
177 device_printf(dev, "got emmcclk clock\n"); in rk_emmcphy_enable()
179 if (sc->clk) { in rk_emmcphy_enable()
180 error = clk_get_freq(sc->clk, &rate); in rk_emmcphy_enable()
182 device_printf(dev, "cannot get clock frequency\n"); in rk_emmcphy_enable()
205 SYSCON_WRITE_4(sc->syscon, GRF_EMMCPHY_CON6, (mask << 16) | val); in rk_emmcphy_enable()
209 val = SYSCON_READ_4(sc->syscon, GRF_EMMCPHY_STATUS); in rk_emmcphy_enable()
211 device_printf(dev, "PHY calibration did not complete\n"); in rk_emmcphy_enable()
218 SYSCON_WRITE_4(sc->syscon, GRF_EMMCPHY_CON0, (mask << 16) | val); in rk_emmcphy_enable()
223 SYSCON_WRITE_4(sc->syscon, GRF_EMMCPHY_CON6, (mask << 16) | val); in rk_emmcphy_enable()
245 val = SYSCON_READ_4(sc->syscon, GRF_EMMCPHY_STATUS); in rk_emmcphy_enable()
247 device_printf(dev, "DLL loop failed to lock\n"); in rk_emmcphy_enable()
256 rk_emmcphy_probe(device_t dev) in rk_emmcphy_probe() argument
259 if (!ofw_bus_status_okay(dev)) in rk_emmcphy_probe()
262 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in rk_emmcphy_probe()
265 device_set_desc(dev, "Rockchip RK3399 eMMC PHY"); in rk_emmcphy_probe()
270 rk_emmcphy_attach(device_t dev) in rk_emmcphy_attach() argument
280 sc = device_get_softc(dev); in rk_emmcphy_attach()
281 node = ofw_bus_get_node(dev); in rk_emmcphy_attach()
285 device_printf(dev, "cannot get clocks handle\n"); in rk_emmcphy_attach()
289 if (OF_hasprop(xnode, "arasan,soc-ctl-syscon") && in rk_emmcphy_attach()
290 syscon_get_by_ofw_property(dev, xnode, in rk_emmcphy_attach()
291 "arasan,soc-ctl-syscon", &sc->syscon) != 0) { in rk_emmcphy_attach()
292 device_printf(dev, "cannot get grf driver handle\n"); in rk_emmcphy_attach()
296 if (sc->syscon == NULL) { in rk_emmcphy_attach()
297 device_printf(dev, "failed to get syscon\n"); in rk_emmcphy_attach()
304 phy_init.ofw_node = ofw_bus_get_node(dev); in rk_emmcphy_attach()
305 phynode = phynode_create(dev, &rk_emmcphy_phynode_class, &phy_init); in rk_emmcphy_attach()
307 device_printf(dev, "failed to create eMMC PHY\n"); in rk_emmcphy_attach()
311 device_printf(dev, "failed to register eMMC PHY\n"); in rk_emmcphy_attach()
316 device_printf(dev, "Attached phy id: %ld\n", phy); in rk_emmcphy_attach()