Lines Matching refs:dev
28 amba_lookup(const struct amba_id *table, struct amba_device *dev) in amba_lookup() argument
33 ret = (dev->periphid & table->mask) == table->id; in amba_lookup()
42 static int amba_match(struct device *dev, struct device_driver *drv) in amba_match() argument
44 struct amba_device *pcdev = to_amba_device(dev); in amba_match()
54 static int amba_uevent(struct device *dev, struct kobj_uevent_env *env) in amba_uevent() argument
56 struct amba_device *pcdev = to_amba_device(dev); in amba_uevent()
70 struct amba_device *dev = to_amba_device(_dev); in driver_override_show() local
72 if (!dev->driver_override) in driver_override_show()
75 return sprintf(buf, "%s\n", dev->driver_override); in driver_override_show()
82 struct amba_device *dev = to_amba_device(_dev); in driver_override_store() local
83 char *driver_override, *old = dev->driver_override, *cp; in driver_override_store()
97 dev->driver_override = driver_override; in driver_override_store()
100 dev->driver_override = NULL; in driver_override_store()
112 struct amba_device *dev = to_amba_device(_dev); \
120 amba_attr_func(id, "%08x\n", dev->periphid);
121 amba_attr(irq0, "%u\n", dev->irq[0]);
122 amba_attr(irq1, "%u\n", dev->irq[1]);
124 (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
125 dev->res.flags);
140 static int amba_pm_runtime_suspend(struct device *dev) in amba_pm_runtime_suspend() argument
142 struct amba_device *pcdev = to_amba_device(dev); in amba_pm_runtime_suspend()
143 int ret = pm_generic_runtime_suspend(dev); in amba_pm_runtime_suspend()
145 if (ret == 0 && dev->driver) { in amba_pm_runtime_suspend()
146 if (pm_runtime_is_irq_safe(dev)) in amba_pm_runtime_suspend()
155 static int amba_pm_runtime_resume(struct device *dev) in amba_pm_runtime_resume() argument
157 struct amba_device *pcdev = to_amba_device(dev); in amba_pm_runtime_resume()
160 if (dev->driver) { in amba_pm_runtime_resume()
161 if (pm_runtime_is_irq_safe(dev)) in amba_pm_runtime_resume()
170 return pm_generic_runtime_resume(dev); in amba_pm_runtime_resume()
211 pcdev->pclk = clk_get(&pcdev->dev, "apb_pclk"); in amba_get_enable_pclk()
232 static int amba_probe(struct device *dev) in amba_probe() argument
234 struct amba_device *pcdev = to_amba_device(dev); in amba_probe()
235 struct amba_driver *pcdrv = to_amba_driver(dev->driver); in amba_probe()
240 ret = dev_pm_domain_attach(dev, true); in amba_probe()
246 dev_pm_domain_detach(dev, true); in amba_probe()
250 pm_runtime_get_noresume(dev); in amba_probe()
251 pm_runtime_set_active(dev); in amba_probe()
252 pm_runtime_enable(dev); in amba_probe()
258 pm_runtime_disable(dev); in amba_probe()
259 pm_runtime_set_suspended(dev); in amba_probe()
260 pm_runtime_put_noidle(dev); in amba_probe()
263 dev_pm_domain_detach(dev, true); in amba_probe()
269 static int amba_remove(struct device *dev) in amba_remove() argument
271 struct amba_device *pcdev = to_amba_device(dev); in amba_remove()
272 struct amba_driver *drv = to_amba_driver(dev->driver); in amba_remove()
275 pm_runtime_get_sync(dev); in amba_remove()
277 pm_runtime_put_noidle(dev); in amba_remove()
280 pm_runtime_disable(dev); in amba_remove()
281 pm_runtime_set_suspended(dev); in amba_remove()
282 pm_runtime_put_noidle(dev); in amba_remove()
285 dev_pm_domain_detach(dev, true); in amba_remove()
290 static void amba_shutdown(struct device *dev) in amba_shutdown() argument
292 struct amba_driver *drv = to_amba_driver(dev->driver); in amba_shutdown()
293 drv->shutdown(to_amba_device(dev)); in amba_shutdown()
330 static void amba_device_release(struct device *dev) in amba_device_release() argument
332 struct amba_device *d = to_amba_device(dev); in amba_device_release()
348 int amba_device_add(struct amba_device *dev, struct resource *parent) in amba_device_add() argument
354 WARN_ON(dev->irq[0] == (unsigned int)-1); in amba_device_add()
355 WARN_ON(dev->irq[1] == (unsigned int)-1); in amba_device_add()
357 ret = request_resource(parent, &dev->res); in amba_device_add()
362 if (dev->periphid != 0) in amba_device_add()
369 size = resource_size(&dev->res); in amba_device_add()
370 tmp = ioremap(dev->res.start, size); in amba_device_add()
376 ret = amba_get_enable_pclk(dev); in amba_device_add()
391 amba_put_disable_pclk(dev); in amba_device_add()
394 dev->periphid = pid; in amba_device_add()
396 if (!dev->periphid) in amba_device_add()
406 ret = device_add(&dev->dev); in amba_device_add()
410 if (dev->irq[0]) in amba_device_add()
411 ret = device_create_file(&dev->dev, &dev_attr_irq0); in amba_device_add()
412 if (ret == 0 && dev->irq[1]) in amba_device_add()
413 ret = device_create_file(&dev->dev, &dev_attr_irq1); in amba_device_add()
417 device_unregister(&dev->dev); in amba_device_add()
420 release_resource(&dev->res); in amba_device_add()
432 struct amba_device *dev; in amba_aphb_device_add() local
435 dev = amba_device_alloc(name, base, size); in amba_aphb_device_add()
436 if (!dev) in amba_aphb_device_add()
439 dev->dev.coherent_dma_mask = dma_mask; in amba_aphb_device_add()
440 dev->irq[0] = irq1; in amba_aphb_device_add()
441 dev->irq[1] = irq2; in amba_aphb_device_add()
442 dev->periphid = periphid; in amba_aphb_device_add()
443 dev->dev.platform_data = pdata; in amba_aphb_device_add()
444 dev->dev.parent = parent; in amba_aphb_device_add()
446 ret = amba_device_add(dev, resbase); in amba_aphb_device_add()
448 amba_device_put(dev); in amba_aphb_device_add()
452 return dev; in amba_aphb_device_add()
498 static void amba_device_initialize(struct amba_device *dev, const char *name) in amba_device_initialize() argument
500 device_initialize(&dev->dev); in amba_device_initialize()
502 dev_set_name(&dev->dev, "%s", name); in amba_device_initialize()
503 dev->dev.release = amba_device_release; in amba_device_initialize()
504 dev->dev.bus = &amba_bustype; in amba_device_initialize()
505 dev->dev.dma_mask = &dev->dev.coherent_dma_mask; in amba_device_initialize()
506 dev->res.name = dev_name(&dev->dev); in amba_device_initialize()
521 struct amba_device *dev; in amba_device_alloc() local
523 dev = kzalloc(sizeof(*dev), GFP_KERNEL); in amba_device_alloc()
524 if (dev) { in amba_device_alloc()
525 amba_device_initialize(dev, name); in amba_device_alloc()
526 dev->res.start = base; in amba_device_alloc()
527 dev->res.end = base + size - 1; in amba_device_alloc()
528 dev->res.flags = IORESOURCE_MEM; in amba_device_alloc()
531 return dev; in amba_device_alloc()
544 int amba_device_register(struct amba_device *dev, struct resource *parent) in amba_device_register() argument
546 amba_device_initialize(dev, dev->dev.init_name); in amba_device_register()
547 dev->dev.init_name = NULL; in amba_device_register()
549 return amba_device_add(dev, parent); in amba_device_register()
556 void amba_device_put(struct amba_device *dev) in amba_device_put() argument
558 put_device(&dev->dev); in amba_device_put()
573 void amba_device_unregister(struct amba_device *dev) in amba_device_unregister() argument
575 device_unregister(&dev->dev); in amba_device_unregister()
580 struct amba_device *dev; member
587 static int amba_find_match(struct device *dev, void *data) in amba_find_match() argument
590 struct amba_device *pcdev = to_amba_device(dev); in amba_find_match()
595 r &= d->parent == dev->parent; in amba_find_match()
597 r &= strcmp(dev_name(dev), d->busid) == 0; in amba_find_match()
600 get_device(dev); in amba_find_match()
601 d->dev = pcdev; in amba_find_match()
627 data.dev = NULL; in amba_find_device()
635 return data.dev; in amba_find_device()
643 int amba_request_regions(struct amba_device *dev, const char *name) in amba_request_regions() argument
649 name = dev->dev.driver->name; in amba_request_regions()
651 size = resource_size(&dev->res); in amba_request_regions()
653 if (!request_mem_region(dev->res.start, size, name)) in amba_request_regions()
665 void amba_release_regions(struct amba_device *dev) in amba_release_regions() argument
669 size = resource_size(&dev->res); in amba_release_regions()
670 release_mem_region(dev->res.start, size); in amba_release_regions()