Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
0004  */
0005 /*
0006  * infrastructure for devices connected via I2C
0007  */
0008 
0009 #ifndef __VIA_AUX_H__
0010 #define __VIA_AUX_H__
0011 
0012 
0013 #include <linux/list.h>
0014 #include <linux/i2c.h>
0015 #include <linux/fb.h>
0016 
0017 
0018 struct via_aux_bus {
0019     struct i2c_adapter *adap;   /* the I2C device to access the bus */
0020     struct list_head drivers;   /* drivers for devices on this bus */
0021 };
0022 
0023 struct via_aux_drv {
0024     struct list_head chain;     /* chain to support multiple drivers */
0025 
0026     struct via_aux_bus *bus;    /* the I2C bus used */
0027     u8 addr;            /* the I2C slave address */
0028 
0029     const char *name;   /* human readable name of the driver */
0030     void *data;     /* private data of this driver */
0031 
0032     void (*cleanup)(struct via_aux_drv *drv);
0033     const struct fb_videomode* (*get_preferred_mode)
0034         (struct via_aux_drv *drv);
0035 };
0036 
0037 
0038 struct via_aux_bus *via_aux_probe(struct i2c_adapter *adap);
0039 void via_aux_free(struct via_aux_bus *bus);
0040 const struct fb_videomode *via_aux_get_preferred_mode(struct via_aux_bus *bus);
0041 
0042 
0043 static inline bool via_aux_add(struct via_aux_drv *drv)
0044 {
0045     struct via_aux_drv *data = kmalloc(sizeof(*data), GFP_KERNEL);
0046 
0047     if (!data)
0048         return false;
0049 
0050     *data = *drv;
0051     list_add_tail(&data->chain, &data->bus->drivers);
0052     return true;
0053 }
0054 
0055 static inline bool via_aux_read(struct via_aux_drv *drv, u8 start, u8 *buf,
0056     u8 len)
0057 {
0058     struct i2c_msg msg[2] = {
0059         {.addr = drv->addr, .flags = 0, .len = 1, .buf = &start},
0060         {.addr = drv->addr, .flags = I2C_M_RD, .len = len, .buf = buf} };
0061 
0062     return i2c_transfer(drv->bus->adap, msg, 2) == 2;
0063 }
0064 
0065 
0066 /* probe functions of existing drivers - should only be called in via_aux.c */
0067 void via_aux_ch7301_probe(struct via_aux_bus *bus);
0068 void via_aux_edid_probe(struct via_aux_bus *bus);
0069 void via_aux_sii164_probe(struct via_aux_bus *bus);
0070 void via_aux_vt1636_probe(struct via_aux_bus *bus);
0071 void via_aux_vt1632_probe(struct via_aux_bus *bus);
0072 void via_aux_vt1631_probe(struct via_aux_bus *bus);
0073 void via_aux_vt1625_probe(struct via_aux_bus *bus);
0074 void via_aux_vt1622_probe(struct via_aux_bus *bus);
0075 void via_aux_vt1621_probe(struct via_aux_bus *bus);
0076 
0077 
0078 #endif /* __VIA_AUX_H__ */