Lines Matching +full:clock +full:- +full:name
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
43 * external-clocks = "name1", "state1",
47 * Each override should be a pair, the first entry is the name of the clock
97 const char *name; member
119 char name[TWL_CLKS_MAX_NAMELEN]; member
120 uint8_t sub_dev; /* the sub-device number for the clock */
121 uint8_t reg_off; /* register base address of the clock */
135 #define TWL_CLKS_XLOCK(_sc) sx_xlock(&(_sc)->sc_sx)
136 #define TWL_CLKS_XUNLOCK(_sc) sx_xunlock(&(_sc)->sc_sx)
137 #define TWL_CLKS_SLOCK(_sc) sx_slock(&(_sc)->sc_sx)
138 #define TWL_CLKS_SUNLOCK(_sc) sx_sunlock(&(_sc)->sc_sx)
139 #define TWL_CLKS_LOCK_INIT(_sc) sx_init(&(_sc)->sc_sx, "twl_clks")
140 #define TWL_CLKS_LOCK_DESTROY(_sc) sx_destroy(&(_sc)->sc_sx);
142 #define TWL_CLKS_ASSERT_LOCKED(_sc) sx_assert(&(_sc)->sc_sx, SA_LOCKED);
146 while (!sx_try_upgrade(&(_sc)->sc_sx)) \
149 #define TWL_CLKS_LOCK_DOWNGRADE(_sc) sx_downgrade(&(_sc)->sc_sx);
152 * twl_clks_read_1 - read single register from the TWL device
153 * twl_clks_write_1 - writes a single register in the TWL device
155 * @clk: the clock device we're reading from / writing to
156 * @off: offset within the clock's register set
166 return (twl_read(sc->sc_pdev, clk->sub_dev, clk->reg_off + off, val, 1)); in twl_clks_read_1()
173 return (twl_write(sc->sc_pdev, clk->sub_dev, clk->reg_off + off, &val, 1)); in twl_clks_write_1()
177 * twl_clks_is_enabled - determines if a clock is enabled
179 * @name: the name of the clock
189 twl_clks_is_enabled(device_t dev, const char *name, int *enabled) in twl_clks_is_enabled() argument
199 LIST_FOREACH(clk, &sc->sc_clks_list, link) { in twl_clks_is_enabled()
200 if (strcmp(clk->name, name) == 0) { in twl_clks_is_enabled()
211 if (twl_is_4030(sc->sc_pdev)) { in twl_clks_is_enabled()
216 } else if (twl_is_6030(sc->sc_pdev) || twl_is_6025(sc->sc_pdev)) { in twl_clks_is_enabled()
219 /* Check the clock is in the application group */ in twl_clks_is_enabled()
220 if (twl_is_6030(sc->sc_pdev)) { in twl_clks_is_enabled()
251 * twl_clks_set_state - enables/disables a clock output
253 * @clk: the clock entry to enable/disable
254 * @enable: non-zero the clock is enabled, zero the clock is disabled
272 /* Upgrade the lock to exclusive because about to perform read-mod-write */ in twl_clks_set_state()
273 xlocked = sx_xlocked(&sc->sc_sx); in twl_clks_set_state()
281 if (twl_is_4030(sc->sc_pdev)) { in twl_clks_set_state()
282 /* On the TWL4030 we just need to ensure the clock is in the right in twl_clks_set_state()
292 } else if (twl_is_6030(sc->sc_pdev) || twl_is_6025(sc->sc_pdev)) { in twl_clks_set_state()
293 /* Make sure the clock belongs to at least the APP power group */ in twl_clks_set_state()
294 if (twl_is_6030(sc->sc_pdev) && !(grp & TWL6030_P1_GRP)) { in twl_clks_set_state()
302 if (twl_is_6030(sc->sc_pdev)) in twl_clks_set_state()
307 /* Set the state of the clock */ in twl_clks_set_state()
323 device_printf(sc->sc_dev, "%s : %sabled\n", clk->name, in twl_clks_set_state()
330 * twl_clks_disable - disables a clock output
332 * @name: the name of the clock
341 twl_clks_disable(device_t dev, const char *name) in twl_clks_disable() argument
349 LIST_FOREACH(clk, &sc->sc_clks_list, link) { in twl_clks_disable()
350 if (strcmp(clk->name, name) == 0) { in twl_clks_disable()
361 * twl_clks_enable - enables a clock output
363 * @name: the name of the clock
372 twl_clks_enable(device_t dev, const char *name) in twl_clks_enable() argument
380 LIST_FOREACH(clk, &sc->sc_clks_list, link) { in twl_clks_enable()
381 if (strcmp(clk->name, name) == 0) { in twl_clks_enable()
392 * twl_clks_sysctl_clock - reads the state of the clock
395 * Returns the clock status; disabled is zero and enabled is non-zero.
410 if ((err = twl_clks_is_enabled(sc->sc_dev, oidp->oid_name, &enabled)) != 0) in twl_clks_sysctl_clock()
417 * twl_clks_add_clock - adds single clock sysctls for the device
419 * @name: the name of the regulator
423 * Adds a single clock to the device and also a sysctl interface for
430 * Pointer to the new clock entry on success, otherwise NULL on failure.
433 twl_clks_add_clock(struct twl_clks_softc *sc, const char *name, in twl_clks_add_clock() argument
436 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); in twl_clks_add_clock()
437 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); in twl_clks_add_clock()
446 strncpy(new->name, name, TWL_CLKS_MAX_NAMELEN); in twl_clks_add_clock()
447 new->name[TWL_CLKS_MAX_NAMELEN - 1] = '\0'; in twl_clks_add_clock()
449 new->sub_dev = nsub; in twl_clks_add_clock()
450 new->reg_off = regbase; in twl_clks_add_clock()
452 /* Add a sysctl entry for the clock */ in twl_clks_add_clock()
453 new->oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, name, in twl_clks_add_clock()
455 twl_clks_sysctl_clock, "I", "external clock"); in twl_clks_add_clock()
458 LIST_INSERT_HEAD(&sc->sc_clks_list, new, link); in twl_clks_add_clock()
464 * twl_clks_add_clocks - populates the internal list of clocks
466 * @chip: the name of the chip used in the hints
488 char *name, *state; in twl_clks_add_clocks() local
496 while (walker->name != NULL) { in twl_clks_add_clocks()
498 entry = twl_clks_add_clock(sc, walker->name, walker->subdev, in twl_clks_add_clocks()
499 walker->regbase); in twl_clks_add_clocks()
507 child = ofw_bus_get_node(sc->sc_pdev); in twl_clks_add_clocks()
509 prop_len = OF_getprop(child, "external-clocks", rnames, sizeof(rnames)); in twl_clks_add_clocks()
511 name = rnames + len; in twl_clks_add_clocks()
512 len += strlen(name) + 1; in twl_clks_add_clocks()
513 if ((len >= prop_len) || (name[0] == '\0')) in twl_clks_add_clocks()
523 LIST_FOREACH(entry, &sc->sc_clks_list, link) { in twl_clks_add_clocks()
524 if (strcmp(entry->name, name) == 0) { in twl_clks_add_clocks()
535 LIST_FOREACH(entry, &sc->sc_clks_list, link) { in twl_clks_add_clocks()
536 err = twl_clks_is_enabled(sc->sc_dev, entry->name, &enable); in twl_clks_add_clocks()
538 device_printf(sc->sc_dev, "%s : %s\n", entry->name, in twl_clks_add_clocks()
547 * twl_clks_init - initialises the list of clocks
551 * this is done so that the driver has the option to enable/disable a clock
564 if (twl_is_4030(sc->sc_pdev)) in twl_clks_init()
566 else if (twl_is_6030(sc->sc_pdev) || twl_is_6025(sc->sc_pdev)) in twl_clks_init()
569 config_intrhook_disestablish(&sc->sc_init_hook); in twl_clks_init()
592 sc->sc_dev = dev; in twl_clks_attach()
593 sc->sc_pdev = device_get_parent(dev); in twl_clks_attach()
597 LIST_INIT(&sc->sc_clks_list); in twl_clks_attach()
599 sc->sc_init_hook.ich_func = twl_clks_init; in twl_clks_attach()
600 sc->sc_init_hook.ich_arg = dev; in twl_clks_attach()
602 if (config_intrhook_establish(&sc->sc_init_hook) != 0) in twl_clks_attach()
619 LIST_FOREACH_SAFE(clk, &sc->sc_clks_list, link, tmp) { in twl_clks_detach()
621 sysctl_remove_oid(clk->oid, 1, 0); in twl_clks_detach()