tzh
2024-08-15 d4a1bd480003f3e1a0590bc46fbcb24f05652ca7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
 ******************************************************************************
 *
 * @file rwnx_platorm.h
 *
 * Copyright (C) RivieraWaves 2012-2019
 *
 ******************************************************************************
 */
 
#ifndef _RWNX_PLATFORM_H_
#define _RWNX_PLATFORM_H_
 
#include <linux/pci.h>
#include "lmac_msg.h"
 
#define RWNX_CONFIG_FW_NAME             "rwnx_settings.ini"
#define RWNX_PHY_CONFIG_TRD_NAME        "rwnx_trident.ini"
#define RWNX_PHY_CONFIG_KARST_NAME      "rwnx_karst.ini"
#define RWNX_AGC_FW_NAME                "agcram.bin"
#define RWNX_LDPC_RAM_NAME              "ldpcram.bin"
#ifdef CONFIG_RWNX_FULLMAC
#define RWNX_MAC_FW_BASE_NAME           "fmacfw"
#elif defined CONFIG_RWNX_FHOST
#define RWNX_MAC_FW_BASE_NAME           "fhostfw"
#endif /* CONFIG_RWNX_FULLMAC */
 
#ifdef CONFIG_RWNX_TL4
#define RWNX_MAC_FW_NAME RWNX_MAC_FW_BASE_NAME".hex"
#else
#define RWNX_MAC_FW_NAME  RWNX_MAC_FW_BASE_NAME".ihex"
#define RWNX_MAC_FW_NAME2 RWNX_MAC_FW_BASE_NAME".bin"
#endif
 
#define RWNX_FCU_FW_NAME                "fcuram.bin"
 
/**
 * Type of memory to access (cf rwnx_plat.get_address)
 *
 * @RWNX_ADDR_CPU To access memory of the embedded CPU
 * @RWNX_ADDR_SYSTEM To access memory/registers of one subsystem of the
 * embedded system
 *
 */
enum rwnx_platform_addr {
   RWNX_ADDR_CPU,
   RWNX_ADDR_SYSTEM,
   RWNX_ADDR_MAX,
};
 
struct rwnx_hw;
 
/**
 * struct rwnx_plat - Operation pointers for RWNX PCI platform
 *
 * @pci_dev: pointer to pci dev
 * @enabled: Set if embedded platform has been enabled (i.e. fw loaded and
 *          ipc started)
 * @enable: Configure communication with the fw (i.e. configure the transfers
 *         enable and register interrupt)
 * @disable: Stop communication with the fw
 * @deinit: Free all ressources allocated for the embedded platform
 * @get_address: Return the virtual address to access the requested address on
 *              the platform.
 * @ack_irq: Acknowledge the irq at link level.
 * @get_config_reg: Return the list (size + pointer) of registers to restore in
 * order to reload the platform while keeping the current configuration.
 *
 * @priv Private data for the link driver
 */
struct rwnx_plat {
   struct pci_dev *pci_dev;
 
#ifdef AICWF_SDIO_SUPPORT
   struct aic_sdio_dev *sdiodev;
#endif
 
#ifdef AICWF_USB_SUPPORT
   struct aic_usb_dev *usbdev;
#endif
   bool enabled;
 
   int (*enable)(struct rwnx_hw *rwnx_hw);
   int (*disable)(struct rwnx_hw *rwnx_hw);
   void (*deinit)(struct rwnx_plat *rwnx_plat);
   u8* (*get_address)(struct rwnx_plat *rwnx_plat, int addr_name,
                      unsigned int offset);
   void (*ack_irq)(struct rwnx_plat *rwnx_plat);
   int (*get_config_reg)(struct rwnx_plat *rwnx_plat, const u32 **list);
 
   u8 priv[0] __aligned(sizeof(void *));
};
 
#define RWNX_ADDR(plat, base, offset)           \
   plat->get_address(plat, base, offset)
 
#define RWNX_REG_READ(plat, base, offset)               \
   readl(plat->get_address(plat, base, offset))
 
#define RWNX_REG_WRITE(val, plat, base, offset)         \
   writel(val, plat->get_address(plat, base, offset))
 
extern struct rwnx_plat *g_rwnx_plat;
 
int rwnx_platform_init(struct rwnx_plat *rwnx_plat, void **platform_data);
void rwnx_platform_deinit(struct rwnx_hw *rwnx_hw);
 
int rwnx_platform_on(struct rwnx_hw *rwnx_hw, void *config);
void rwnx_platform_off(struct rwnx_hw *rwnx_hw, void **config);
 
int rwnx_platform_register_drv(void);
void rwnx_platform_unregister_drv(void);
 
void get_userconfig_txpwr_idx(txpwr_idx_conf_t *txpwr_idx);
void get_userconfig_txpwr_ofst(txpwr_ofst_conf_t *txpwr_ofst);
 
extern struct device *rwnx_platform_get_dev(struct rwnx_plat *rwnx_plat);
 
static inline unsigned int rwnx_platform_get_irq(struct rwnx_plat *rwnx_plat)
{
   return rwnx_plat->pci_dev->irq;
}
 
#endif /* _RWNX_PLATFORM_H_ */