Lines Matching full:ulpi

3  * ulpi.c - USB ULPI PHY bus
10 #include <linux/ulpi/interface.h>
11 #include <linux/ulpi/driver.h>
12 #include <linux/ulpi/regs.h>
23 int ulpi_read(struct ulpi *ulpi, u8 addr) in ulpi_read() argument
25 return ulpi->ops->read(ulpi->dev.parent, addr); in ulpi_read()
29 int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val) in ulpi_write() argument
31 return ulpi->ops->write(ulpi->dev.parent, addr, val); in ulpi_write()
40 struct ulpi *ulpi = to_ulpi_dev(dev); in ulpi_match() local
44 * Some ULPI devices don't have a vendor id in ulpi_match()
47 if (ulpi->id.vendor == 0 || !drv->id_table) in ulpi_match()
51 if (id->vendor == ulpi->id.vendor && in ulpi_match()
52 id->product == ulpi->id.product) in ulpi_match()
60 const struct ulpi *ulpi = to_ulpi_dev(dev); in ulpi_uevent() local
67 if (add_uevent_var(env, "MODALIAS=ulpi:v%04xp%04x", in ulpi_uevent()
68 ulpi->id.vendor, ulpi->id.product)) in ulpi_uevent()
94 .name = "ulpi",
107 struct ulpi *ulpi = to_ulpi_dev(dev); in modalias_show() local
113 return sprintf(buf, "ulpi:v%04xp%04x\n", in modalias_show()
114 ulpi->id.vendor, ulpi->id.product); in modalias_show()
147 * __ulpi_register_driver - register a driver with the ULPI bus
151 * Registers a driver with the ULPI bus.
166 * ulpi_unregister_driver - unregister a driver with the ULPI bus
169 * Unregisters a driver with the ULPI bus.
179 static int ulpi_of_register(struct ulpi *ulpi) in ulpi_of_register() argument
184 /* Find a ulpi bus underneath the parent or the grandparent */ in ulpi_of_register()
185 parent = ulpi->dev.parent; in ulpi_of_register()
187 np = of_get_child_by_name(parent->of_node, "ulpi"); in ulpi_of_register()
189 np = of_get_child_by_name(parent->parent->of_node, "ulpi"); in ulpi_of_register()
198 ulpi->dev.of_node = child; in ulpi_of_register()
203 static int ulpi_read_id(struct ulpi *ulpi) in ulpi_read_id() argument
208 ret = ulpi_write(ulpi, ULPI_SCRATCH, 0xaa); in ulpi_read_id()
212 ret = ulpi_read(ulpi, ULPI_SCRATCH); in ulpi_read_id()
219 ulpi->id.vendor = ulpi_read(ulpi, ULPI_VENDOR_ID_LOW); in ulpi_read_id()
220 ulpi->id.vendor |= ulpi_read(ulpi, ULPI_VENDOR_ID_HIGH) << 8; in ulpi_read_id()
222 ulpi->id.product = ulpi_read(ulpi, ULPI_PRODUCT_ID_LOW); in ulpi_read_id()
223 ulpi->id.product |= ulpi_read(ulpi, ULPI_PRODUCT_ID_HIGH) << 8; in ulpi_read_id()
225 /* Some ULPI devices don't have a vendor id so rely on OF match */ in ulpi_read_id()
226 if (ulpi->id.vendor == 0) in ulpi_read_id()
229 request_module("ulpi:v%04xp%04x", ulpi->id.vendor, ulpi->id.product); in ulpi_read_id()
232 of_request_module(ulpi->dev.of_node); in ulpi_read_id()
238 struct ulpi *ulpi = seq->private; in ulpi_regs_show() local
241 int ret = ulpi_read(ulpi, reg); \ in ulpi_regs_show()
276 static int ulpi_register(struct device *dev, struct ulpi *ulpi) in ulpi_register() argument
281 ulpi->dev.parent = dev; /* needed early for ops */ in ulpi_register()
282 ulpi->dev.bus = &ulpi_bus; in ulpi_register()
283 ulpi->dev.type = &ulpi_dev_type; in ulpi_register()
284 dev_set_name(&ulpi->dev, "%s.ulpi", dev_name(dev)); in ulpi_register()
286 ACPI_COMPANION_SET(&ulpi->dev, ACPI_COMPANION(dev)); in ulpi_register()
288 ret = ulpi_of_register(ulpi); in ulpi_register()
292 ret = ulpi_read_id(ulpi); in ulpi_register()
294 of_node_put(ulpi->dev.of_node); in ulpi_register()
298 ret = device_register(&ulpi->dev); in ulpi_register()
300 put_device(&ulpi->dev); in ulpi_register()
304 root = debugfs_create_dir(dev_name(&ulpi->dev), ulpi_root); in ulpi_register()
305 debugfs_create_file("regs", 0444, root, ulpi, &ulpi_regs_fops); in ulpi_register()
307 dev_dbg(&ulpi->dev, "registered ULPI PHY: vendor %04x, product %04x\n", in ulpi_register()
308 ulpi->id.vendor, ulpi->id.product); in ulpi_register()
314 * ulpi_register_interface - instantiate new ULPI device
316 * @ops: ULPI register access
318 * Allocates and registers a ULPI device and an interface for it. Called from
319 * the USB controller that provides the ULPI interface.
321 struct ulpi *ulpi_register_interface(struct device *dev, in ulpi_register_interface()
324 struct ulpi *ulpi; in ulpi_register_interface() local
327 ulpi = kzalloc(sizeof(*ulpi), GFP_KERNEL); in ulpi_register_interface()
328 if (!ulpi) in ulpi_register_interface()
331 ulpi->ops = ops; in ulpi_register_interface()
333 ret = ulpi_register(dev, ulpi); in ulpi_register_interface()
335 kfree(ulpi); in ulpi_register_interface()
339 return ulpi; in ulpi_register_interface()
344 * ulpi_unregister_interface - unregister ULPI interface
345 * @ulpi: struct ulpi_interface
347 * Unregisters a ULPI device and it's interface that was created with
350 void ulpi_unregister_interface(struct ulpi *ulpi) in ulpi_unregister_interface() argument
352 debugfs_lookup_and_remove(dev_name(&ulpi->dev), ulpi_root); in ulpi_unregister_interface()
353 device_unregister(&ulpi->dev); in ulpi_unregister_interface()
380 MODULE_DESCRIPTION("USB ULPI PHY bus");