Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) 2011-2016 Synaptics Incorporated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (c) 2011 Unixphere
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #ifndef _RMI_BUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define _RMI_BUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/rmi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) struct rmi_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * The interrupt source count in the function descriptor can represent up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * 6 interrupt sources in the normal manner.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define RMI_FN_MAX_IRQS	6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * struct rmi_function - represents the implementation of an RMI4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * function for a particular device (basically, a driver for that RMI4 function)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * @fd: The function descriptor of the RMI function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * @rmi_dev: Pointer to the RMI device associated with this function container
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * @dev: The device associated with this particular function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * @num_of_irqs: The number of irqs needed by this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * @irq_pos: The position in the irq bitfield this function holds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * @irq_mask: For convenience, can be used to mask IRQ bits off during ATTN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * interrupt handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * @irqs: assigned virq numbers (up to num_of_irqs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * @node: entry in device's list of functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) struct rmi_function {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct rmi_function_descriptor fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct rmi_device *rmi_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	struct device dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	unsigned int num_of_irqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	int irq[RMI_FN_MAX_IRQS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	unsigned int irq_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	unsigned long irq_mask[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define to_rmi_function(d)	container_of(d, struct rmi_function, dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) bool rmi_is_function_device(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) int __must_check rmi_register_function(struct rmi_function *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) void rmi_unregister_function(struct rmi_function *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * struct rmi_function_handler - driver routines for a particular RMI function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * @func: The RMI function number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * @reset: Called when a reset of the touch sensor is detected.  The routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * should perform any out-of-the-ordinary reset handling that might be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * necessary.  Restoring of touch sensor configuration registers should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * handled in the config() callback, below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * @config: Called when the function container is first initialized, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * after a reset is detected.  This routine should write any necessary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * configuration settings to the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * @attention: Called when the IRQ(s) for the function are set by the touch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * sensor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * @suspend: Should perform any required operations to suspend the particular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * @resume: Should perform any required operations to resume the particular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * All callbacks are expected to return 0 on success, error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) struct rmi_function_handler {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct device_driver driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	u8 func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	int (*probe)(struct rmi_function *fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	void (*remove)(struct rmi_function *fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	int (*config)(struct rmi_function *fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	int (*reset)(struct rmi_function *fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	irqreturn_t (*attention)(int irq, void *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	int (*suspend)(struct rmi_function *fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	int (*resume)(struct rmi_function *fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #define to_rmi_function_handler(d) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		container_of(d, struct rmi_function_handler, driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) int __must_check __rmi_register_function_handler(struct rmi_function_handler *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 						 struct module *, const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #define rmi_register_function_handler(handler) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	__rmi_register_function_handler(handler, THIS_MODULE, KBUILD_MODNAME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) void rmi_unregister_function_handler(struct rmi_function_handler *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define to_rmi_driver(d) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	container_of(d, struct rmi_driver, driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define to_rmi_device(d) container_of(d, struct rmi_device, dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static inline struct rmi_device_platform_data *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) rmi_get_platform_data(struct rmi_device *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	return &d->xport->pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) bool rmi_is_physical_device(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * rmi_reset - reset a RMI4 device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * @d: Pointer to an RMI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * Calls for a reset of each function implemented by a specific device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * Returns 0 on success or a negative error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static inline int rmi_reset(struct rmi_device *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	return d->driver->reset_handler(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * rmi_read - read a single byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * @d: Pointer to an RMI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * @addr: The address to read from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * @buf: The read buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * Reads a single byte of data using the underlying transport protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * into memory pointed by @buf. It returns 0 on success or a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static inline int rmi_read(struct rmi_device *d, u16 addr, u8 *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	return d->xport->ops->read_block(d->xport, addr, buf, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * rmi_read_block - read a block of bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * @d: Pointer to an RMI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * @addr: The start address to read from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * @buf: The read buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * @len: Length of the read buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * Reads a block of byte data using the underlying transport protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * into memory pointed by @buf. It returns 0 on success or a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  * error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static inline int rmi_read_block(struct rmi_device *d, u16 addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 				 void *buf, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	return d->xport->ops->read_block(d->xport, addr, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * rmi_write - write a single byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * @d: Pointer to an RMI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * @addr: The address to write to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * @data: The data to write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * Writes a single byte using the underlying transport protocol. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * returns zero on success or a negative error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static inline int rmi_write(struct rmi_device *d, u16 addr, u8 data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	return d->xport->ops->write_block(d->xport, addr, &data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * rmi_write_block - write a block of bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * @d: Pointer to an RMI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  * @addr: The start address to write to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * @buf: The write buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  * @len: Length of the write buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * Writes a block of byte data from buf using the underlaying transport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  * protocol.  It returns the amount of bytes written or a negative error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) static inline int rmi_write_block(struct rmi_device *d, u16 addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 				  const void *buf, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	return d->xport->ops->write_block(d->xport, addr, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) extern struct bus_type rmi_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) int rmi_of_property_read_u32(struct device *dev, u32 *result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 				const char *prop, bool optional);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) #define RMI_DEBUG_CORE			BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #define RMI_DEBUG_XPORT			BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #define RMI_DEBUG_FN			BIT(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #define RMI_DEBUG_2D_SENSOR		BIT(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) void rmi_dbg(int flags, struct device *dev, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #endif