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_VIN_DEVICES 2
17#define MGB4_VOUT_DEVICES 2
18
19#define MGB4_MGB4_BAR_ID 0
20#define MGB4_XDMA_BAR_ID 1
21
22#define MGB4_IS_GMSL(mgbdev) \
23 ((mgbdev)->module_version >> 4 == 2)
24#define MGB4_IS_FPDL3(mgbdev) \
25 ((mgbdev)->module_version >> 4 == 1)
26
27struct mgb4_dma_channel {
28 struct dma_chan *chan;
29 struct completion req_compl;
30};
31
32struct mgb4_dev {
33 struct pci_dev *pdev;
34 struct platform_device *xdev;
35 struct mgb4_vin_dev *vin[MGB4_VIN_DEVICES];
36 struct mgb4_vout_dev *vout[MGB4_VOUT_DEVICES];
37
38 struct mgb4_dma_channel c2h_chan[MGB4_VIN_DEVICES];
39 struct mgb4_dma_channel h2c_chan[MGB4_VOUT_DEVICES];
40 struct dma_slave_map slave_map[MGB4_VIN_DEVICES + MGB4_VOUT_DEVICES];
41
42 struct mgb4_regs video;
43 struct mgb4_regs cmt;
44
45 struct clk_hw *i2c_clk;
46 struct clk_lookup *i2c_cl;
47 struct platform_device *i2c_pdev;
48 struct i2c_adapter *i2c_adap;
49 struct mutex i2c_lock; /* I2C bus access lock */
50
51 struct platform_device *spi_pdev;
52 struct flash_platform_data flash_data;
53 struct mtd_partition partitions[2];
54 char flash_name[16];
55 char fw_part_name[16];
56 char data_part_name[16];
57 char channel_names[MGB4_VIN_DEVICES + MGB4_VOUT_DEVICES][16];
58
59 struct iio_dev *indio_dev;
60#if IS_REACHABLE(CONFIG_HWMON)
61 struct device *hwmon_dev;
62#endif
63
64 unsigned long io_reconfig;
65
66 u8 module_version;
67 u32 serial_number;
68
69#ifdef CONFIG_DEBUG_FS
70 struct dentry *debugfs;
71#endif
72};
73
74#endif
75

source code of linux/drivers/media/pci/mgb4/mgb4_core.h