Lines Matching +full:sub +full:- +full:device

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
35 * This code is based on the Linux TWL multifunctional device driver, which is
36 * copyright (C) 2005-2006 Texas Instruments, Inc.
72 /* TWL device IDs */
78 /* Each TWL device typically has more than one I2C address */
112 #define TWL_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
113 #define TWL_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
115 mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->sc_dev), \
117 #define TWL_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx);
118 #define TWL_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED);
119 #define TWL_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED);
122 * twl_is_4030 - returns true if the device is TWL4030
123 * twl_is_6025 - returns true if the device is TWL6025
124 * twl_is_6030 - returns true if the device is TWL6030
125 * @sc: device soft context
127 * Returns a non-zero value if the device matches.
130 * Returns a non-zero value if the device matches, otherwise zero.
136 return (sc->sc_type == TWL_DEVICE_4030); in twl_is_4030()
143 return (sc->sc_type == TWL_DEVICE_6025); in twl_is_6025()
150 return (sc->sc_type == TWL_DEVICE_6030); in twl_is_6030()
154 * twl_read - read one or more registers from the TWL device
155 * @sc: device soft context
156 * @nsub: the sub-module to read from
177 addr = sc->sc_subaddr_map[nsub]; in twl_read()
205 * twl_write - writes one or more registers to the TWL device
206 * @sc: device soft context
207 * @nsub: the sub-module to read from
236 addr = sc->sc_subaddr_map[nsub]; in twl_write()
250 device_printf(sc->sc_dev, "iicbus write failed (adr:0x%02x, reg:0x%02x)\n", in twl_write()
259 * twl_test_present - checks if a device with given address is present
260 * @sc: device soft context
261 * @addr: the address of the device to scan for
263 * Sends just the address byte and checks for an ACK. If no ACK then device
267 * EIO if device is not present, otherwise 0 is returned.
281 if (iicbus_transfer(sc->sc_dev, &msg, 1) != 0) in twl_test_present()
288 * twl_scan - scans the i2c bus for sub modules
289 * @dev: the twl device
292 * 5 other addresses, each is for separate modules within the device. This
293 * function scans the bus for 4 possible sub-devices and stores the info
310 * sub modules we have. in twl_scan()
315 device_printf(sc->sc_dev, "Found (sub)device at 0x%02x\n", (base + i)); in twl_scan()
320 memcpy(sc->sc_subaddr_map, devs, TWL_MAX_SUBADDRS); in twl_scan()
324 config_intrhook_disestablish(&sc->sc_scan_hook); in twl_scan()
328 * twl_probe -
329 * @dev: the twl device
331 * Scans the FDT for a match for the device, possible compatible device
334 * The FDT compat string also determines the type of device (it is currently
335 * not possible to dynamically determine the device type).
357 sc->sc_dev = dev; in twl_probe()
358 sc->sc_type = TWL_DEVICE_UNKNOWN; in twl_probe()
362 sc->sc_type = TWL_DEVICE_6030; in twl_probe()
364 sc->sc_type = TWL_DEVICE_6025; in twl_probe()
366 sc->sc_type = TWL_DEVICE_4030; in twl_probe()
368 if (sc->sc_type != TWL_DEVICE_UNKNOWN) in twl_probe()
371 /* Slide to the next sub-string. */ in twl_probe()
374 len -= l; in twl_probe()
377 switch (sc->sc_type) { in twl_probe()
401 sc->sc_dev = dev; in twl_attach()
408 sc->sc_scan_hook.ich_func = twl_scan; in twl_attach()
409 sc->sc_scan_hook.ich_arg = dev; in twl_attach()
411 if (config_intrhook_establish(&sc->sc_scan_hook) != 0) in twl_attach()
415 if ((sc->sc_vreg = device_add_child(dev, "twl_vreg", -1)) == NULL) in twl_attach()
417 if ((sc->sc_clks = device_add_child(dev, "twl_clks", -1)) == NULL) in twl_attach()
431 if (sc->sc_vreg) in twl_detach()
432 device_delete_child(dev, sc->sc_vreg); in twl_detach()
433 if (sc->sc_clks) in twl_detach()
434 device_delete_child(dev, sc->sc_clks); in twl_detach()