xref: /linux/drivers/media/pci/mgb4/mgb4_core.h (revision 3fd6c59042dbba50391e30862beac979491145fe)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2021-2023 Digiteq Automotive
4  *     author: Martin Tuma <martin.tuma@digiteqautomotive.com>
5  */
6 
7 #ifndef __MGB4_CORE_H__
8 #define __MGB4_CORE_H__
9 
10 #include <linux/spi/flash.h>
11 #include <linux/mtd/partitions.h>
12 #include <linux/mutex.h>
13 #include <linux/dmaengine.h>
14 #include "mgb4_regs.h"
15 
16 #define MGB4_HW_FREQ 125000000
17 
18 #define MGB4_VIN_DEVICES  2
19 #define MGB4_VOUT_DEVICES 2
20 
21 #define MGB4_MGB4_BAR_ID  0
22 #define MGB4_XDMA_BAR_ID  1
23 
24 #define MGB4_IS_GMSL(mgbdev) \
25 	((mgbdev)->module_version >> 4 == 2)
26 #define MGB4_IS_FPDL3(mgbdev) \
27 	((mgbdev)->module_version >> 4 == 1)
28 
29 struct mgb4_dma_channel {
30 	struct dma_chan *chan;
31 	struct completion req_compl;
32 };
33 
34 struct mgb4_dev {
35 	struct pci_dev *pdev;
36 	struct platform_device *xdev;
37 	struct mgb4_vin_dev *vin[MGB4_VIN_DEVICES];
38 	struct mgb4_vout_dev *vout[MGB4_VOUT_DEVICES];
39 
40 	struct mgb4_dma_channel c2h_chan[MGB4_VIN_DEVICES];
41 	struct mgb4_dma_channel h2c_chan[MGB4_VOUT_DEVICES];
42 	struct dma_slave_map slave_map[MGB4_VIN_DEVICES + MGB4_VOUT_DEVICES];
43 
44 	struct mgb4_regs video;
45 	struct mgb4_regs cmt;
46 
47 	struct clk_hw *i2c_clk;
48 	struct clk_lookup *i2c_cl;
49 	struct platform_device *i2c_pdev;
50 	struct i2c_adapter *i2c_adap;
51 	struct mutex i2c_lock; /* I2C bus access lock */
52 
53 	struct platform_device *spi_pdev;
54 	struct flash_platform_data flash_data;
55 	struct mtd_partition partitions[2];
56 	char flash_name[16];
57 	char fw_part_name[16];
58 	char data_part_name[16];
59 	char channel_names[MGB4_VIN_DEVICES + MGB4_VOUT_DEVICES][16];
60 
61 	struct iio_dev *indio_dev;
62 #if IS_REACHABLE(CONFIG_HWMON)
63 	struct device *hwmon_dev;
64 #endif
65 
66 	unsigned long io_reconfig;
67 
68 	u8 module_version;
69 	u32 serial_number;
70 
71 	struct dentry *debugfs;
72 };
73 
74 #endif
75