Lines Matching +full:slave +full:- +full:addr

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
36 * copyright (C) 2005-2006 Texas Instruments, Inc.
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
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);
143 return (sc->sc_type == TWL_DEVICE_6025);
150 return (sc->sc_type == TWL_DEVICE_6030);
154 * twl_read - read one or more registers from the TWL device
156 * @nsub: the sub-module to read from
171 uint8_t addr;
177 addr = sc->sc_subaddr_map[nsub];
180 if (addr == TWL_INVALID_CHIP_ID)
184 msg[0].slave = addr;
189 msg[1].slave = addr;
197 addr, reg);
205 * twl_write - writes one or more registers to the TWL device
207 * @nsub: the sub-module to read from
222 uint8_t addr;
236 addr = sc->sc_subaddr_map[nsub];
239 if (addr == TWL_INVALID_CHIP_ID)
243 msg.slave = addr;
250 device_printf(sc->sc_dev, "iicbus write failed (adr:0x%02x, reg:0x%02x)\n",
251 addr, reg);
259 * twl_test_present - checks if a device with given address is present
261 * @addr: the address of the device to scan for
270 twl_test_present(struct twl_softc *sc, uint8_t addr)
276 msg.slave = addr;
281 if (iicbus_transfer(sc->sc_dev, &msg, 1) != 0)
288 * twl_scan - scans the i2c bus for sub modules
291 * TWL devices don't just have one i2c slave address, rather they have up to
293 * function scans the bus for 4 possible sub-devices and stores the info
315 device_printf(sc->sc_dev, "Found (sub)device at 0x%02x\n", (base + i));
320 memcpy(sc->sc_subaddr_map, devs, TWL_MAX_SUBADDRS);
324 config_intrhook_disestablish(&sc->sc_scan_hook);
328 * twl_probe -
357 sc->sc_dev = dev;
358 sc->sc_type = TWL_DEVICE_UNKNOWN;
362 sc->sc_type = TWL_DEVICE_6030;
364 sc->sc_type = TWL_DEVICE_6025;
366 sc->sc_type = TWL_DEVICE_4030;
368 if (sc->sc_type != TWL_DEVICE_UNKNOWN)
371 /* Slide to the next sub-string. */
374 len -= l;
377 switch (sc->sc_type) {
401 sc->sc_dev = dev;
408 sc->sc_scan_hook.ich_func = twl_scan;
409 sc->sc_scan_hook.ich_arg = dev;
411 if (config_intrhook_establish(&sc->sc_scan_hook) != 0)
415 if ((sc->sc_vreg = device_add_child(dev, "twl_vreg", -1)) == NULL)
417 if ((sc->sc_clks = device_add_child(dev, "twl_clks", -1)) == NULL)