1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2021-2023 Digiteq Automotive
4 * author: Martin Tuma <martin.tuma@digiteqautomotive.com>
7 #ifndef __MGB4_CORE_H__
8 #define __MGB4_CORE_H__
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"
16 #define MGB4_HW_FREQ 125000000
18 #define MGB4_VIN_DEVICES 2
19 #define MGB4_VOUT_DEVICES 2
21 #define MGB4_MGB4_BAR_ID 0
22 #define MGB4_XDMA_BAR_ID 1
24 #define MGB4_IS_GMSL(mgbdev) \
25 ((mgbdev)->module_version >> 4 == 2)
26 #define MGB4_IS_FPDL3(mgbdev) \
27 ((mgbdev)->module_version >> 4 == 1)
29 struct mgb4_dma_channel
{
30 struct dma_chan
*chan
;
31 struct completion req_compl
;
36 struct platform_device
*xdev
;
37 struct mgb4_vin_dev
*vin
[MGB4_VIN_DEVICES
];
38 struct mgb4_vout_dev
*vout
[MGB4_VOUT_DEVICES
];
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
];
44 struct mgb4_regs video
;
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 */
53 struct platform_device
*spi_pdev
;
54 struct flash_platform_data flash_data
;
55 struct mtd_partition partitions
[2];
57 char fw_part_name
[16];
58 char data_part_name
[16];
59 char channel_names
[MGB4_VIN_DEVICES
+ MGB4_VOUT_DEVICES
][16];
61 struct iio_dev
*indio_dev
;
62 #if IS_REACHABLE(CONFIG_HWMON)
63 struct device
*hwmon_dev
;
66 unsigned long io_reconfig
;
71 struct dentry
*debugfs
;