1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
6 #define LOG_CATEGORY UCLASS_MISC
14 * Implement a miscellaneous uclass for those do not fit other more
15 * general classes. A set of generic read, write and ioctl methods may
16 * be used to access the device.
19 int misc_read(struct udevice *dev, int offset, void *buf, int size)
21 const struct misc_ops *ops = device_get_ops(dev);
26 return ops->read(dev, offset, buf, size);
29 int misc_write(struct udevice *dev, int offset, void *buf, int size)
31 const struct misc_ops *ops = device_get_ops(dev);
36 return ops->write(dev, offset, buf, size);
39 int misc_ioctl(struct udevice *dev, unsigned long request, void *buf)
41 const struct misc_ops *ops = device_get_ops(dev);
46 return ops->ioctl(dev, request, buf);
49 int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
50 void *rx_msg, int rx_size)
52 const struct misc_ops *ops = device_get_ops(dev);
57 return ops->call(dev, msgid, tx_msg, tx_size, rx_msg, rx_size);
60 int misc_set_enabled(struct udevice *dev, bool val)
62 const struct misc_ops *ops = device_get_ops(dev);
64 if (!ops->set_enabled)
67 return ops->set_enabled(dev, val);
70 UCLASS_DRIVER(misc) = {
73 #if CONFIG_IS_ENABLED(OF_REAL)
74 .post_bind = dm_scan_fdt_dev,