// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2012 Avionic Design GmbH * Copyright (C) 2012-2013, NVIDIA Corporation */ #include <linux/debugfs.h> #include <linux/dma-mapping.h> #include <linux/host1x.h> #include <linux/of.h> #include <linux/seq_file.h> #include <linux/slab.h> #include <linux/of_device.h> #include "bus.h" #include "dev.h" static DEFINE_MUTEX(clients_lock); static LIST_HEAD(clients); static DEFINE_MUTEX(drivers_lock); static LIST_HEAD(drivers); static DEFINE_MUTEX(devices_lock); static LIST_HEAD(devices); struct host1x_subdev { … }; /** * host1x_subdev_add() - add a new subdevice with an associated device node * @device: host1x device to add the subdevice to * @driver: host1x driver containing the subdevices * @np: device node */ static int host1x_subdev_add(struct host1x_device *device, struct host1x_driver *driver, struct device_node *np) { … } /** * host1x_subdev_del() - remove subdevice * @subdev: subdevice to remove */ static void host1x_subdev_del(struct host1x_subdev *subdev) { … } /** * host1x_device_parse_dt() - scan device tree and add matching subdevices * @device: host1x logical device * @driver: host1x driver */ static int host1x_device_parse_dt(struct host1x_device *device, struct host1x_driver *driver) { … } static void host1x_subdev_register(struct host1x_device *device, struct host1x_subdev *subdev, struct host1x_client *client) { … } static void __host1x_subdev_unregister(struct host1x_device *device, struct host1x_subdev *subdev) { … } static void host1x_subdev_unregister(struct host1x_device *device, struct host1x_subdev *subdev) { … } /** * host1x_device_init() - initialize a host1x logical device * @device: host1x logical device * * The driver for the host1x logical device can call this during execution of * its &host1x_driver.probe implementation to initialize each of its clients. * The client drivers access the subsystem specific driver data using the * &host1x_client.parent field and driver data associated with it (usually by * calling dev_get_drvdata()). */ int host1x_device_init(struct host1x_device *device) { … } EXPORT_SYMBOL(…); /** * host1x_device_exit() - uninitialize host1x logical device * @device: host1x logical device * * When the driver for a host1x logical device is unloaded, it can call this * function to tear down each of its clients. Typically this is done after a * subsystem-specific data structure is removed and the functionality can no * longer be used. */ int host1x_device_exit(struct host1x_device *device) { … } EXPORT_SYMBOL(…); static int host1x_add_client(struct host1x *host1x, struct host1x_client *client) { … } static int host1x_del_client(struct host1x *host1x, struct host1x_client *client) { … } static int host1x_device_match(struct device *dev, const struct device_driver *drv) { … } /* * Note that this is really only needed for backwards compatibility * with libdrm, which parses this information from sysfs and will * fail if it can't find the OF_FULLNAME, specifically. */ static int host1x_device_uevent(const struct device *dev, struct kobj_uevent_env *env) { … } static const struct dev_pm_ops host1x_device_pm_ops = …; const struct bus_type host1x_bus_type = …; static void __host1x_device_del(struct host1x_device *device) { … } static void host1x_device_release(struct device *dev) { … } static int host1x_device_add(struct host1x *host1x, struct host1x_driver *driver) { … } /* * Removes a device by first unregistering any subdevices and then removing * itself from the list of devices. * * This function must be called with the host1x->devices_lock held. */ static void host1x_device_del(struct host1x *host1x, struct host1x_device *device) { … } static void host1x_attach_driver(struct host1x *host1x, struct host1x_driver *driver) { … } static void host1x_detach_driver(struct host1x *host1x, struct host1x_driver *driver) { … } static int host1x_devices_show(struct seq_file *s, void *data) { … } DEFINE_SHOW_ATTRIBUTE(…); /** * host1x_register() - register a host1x controller * @host1x: host1x controller * * The host1x controller driver uses this to register a host1x controller with * the infrastructure. Note that all Tegra SoC generations have only ever come * with a single host1x instance, so this function is somewhat academic. */ int host1x_register(struct host1x *host1x) { … } /** * host1x_unregister() - unregister a host1x controller * @host1x: host1x controller * * The host1x controller driver uses this to remove a host1x controller from * the infrastructure. */ int host1x_unregister(struct host1x *host1x) { … } static int host1x_device_probe(struct device *dev) { … } static int host1x_device_remove(struct device *dev) { … } static void host1x_device_shutdown(struct device *dev) { … } /** * host1x_driver_register_full() - register a host1x driver * @driver: host1x driver * @owner: owner module * * Drivers for host1x logical devices call this function to register a driver * with the infrastructure. Note that since these drive logical devices, the * registration of the driver actually triggers tho logical device creation. * A logical device will be created for each host1x instance. */ int host1x_driver_register_full(struct host1x_driver *driver, struct module *owner) { … } EXPORT_SYMBOL(…); /** * host1x_driver_unregister() - unregister a host1x driver * @driver: host1x driver * * Unbinds the driver from each of the host1x logical devices that it is * bound to, effectively removing the subsystem devices that they represent. */ void host1x_driver_unregister(struct host1x_driver *driver) { … } EXPORT_SYMBOL(…); /** * __host1x_client_init() - initialize a host1x client * @client: host1x client * @key: lock class key for the client-specific mutex */ void __host1x_client_init(struct host1x_client *client, struct lock_class_key *key) { … } EXPORT_SYMBOL(…); /** * host1x_client_exit() - uninitialize a host1x client * @client: host1x client */ void host1x_client_exit(struct host1x_client *client) { … } EXPORT_SYMBOL(…); /** * __host1x_client_register() - register a host1x client * @client: host1x client * * Registers a host1x client with each host1x controller instance. Note that * each client will only match their parent host1x controller and will only be * associated with that instance. Once all clients have been registered with * their parent host1x controller, the infrastructure will set up the logical * device and call host1x_device_init(), which will in turn call each client's * &host1x_client_ops.init implementation. */ int __host1x_client_register(struct host1x_client *client) { … } EXPORT_SYMBOL(…); /** * host1x_client_unregister() - unregister a host1x client * @client: host1x client * * Removes a host1x client from its host1x controller instance. If a logical * device has already been initialized, it will be torn down. */ void host1x_client_unregister(struct host1x_client *client) { … } EXPORT_SYMBOL(…); int host1x_client_suspend(struct host1x_client *client) { … } EXPORT_SYMBOL(…); int host1x_client_resume(struct host1x_client *client) { … } EXPORT_SYMBOL(…); struct host1x_bo_mapping *host1x_bo_pin(struct device *dev, struct host1x_bo *bo, enum dma_data_direction dir, struct host1x_bo_cache *cache) { … } EXPORT_SYMBOL(…); static void __host1x_bo_unpin(struct kref *ref) { … } void host1x_bo_unpin(struct host1x_bo_mapping *mapping) { … } EXPORT_SYMBOL(…);