Skip to content

Commit 869dda9

Browse files
Justin5763psvtrajan
authored andcommitted
WIFI-15404 WF672A bring up based on ATH13.1 SDK
1.add config and drivers for ilps22qs and lsm303agr 2.fix compilation errors in cig-wifi-mode-sw Signed-off-by: Justin.Guo <guoxijun@actiontec.com>
1 parent 86f05fe commit 869dda9

13 files changed

Lines changed: 3243 additions & 4 deletions

File tree

feeds/qca-wifi-7/cig-platform-pkg/cig-wifi-mode-sw/src/cig_rf_switch.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/uaccess.h>
1313
#include <linux/list.h>
1414
#include <linux/pagemap.h>
15+
#include <linux/version.h>
1516

1617
#define PROC_NAME "rf_switch"
1718
#define PARTITION_NAME "RF_SWITCH"
@@ -36,15 +37,25 @@ struct block_device *find_mmc_partition(void)
3637
unsigned int i;
3738

3839
for (i = 0; i < MAX_MMC_DEVICE; i++) {
39-
bdev = blkdev_get_by_dev(MKDEV(MMC_BLOCK_MAJOR, i * CONFIG_MMC_BLOCK_MINORS), FMODE_READ | FMODE_WRITE, NULL);
40+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
41+
bdev = blkdev_get_by_dev(MKDEV(MMC_BLOCK_MAJOR,
42+
i * CONFIG_MMC_BLOCK_MINORS), FMODE_READ | FMODE_WRITE, NULL, NULL);
43+
#else
44+
bdev = blkdev_get_by_dev(MKDEV(MMC_BLOCK_MAJOR,
45+
i * CONFIG_MMC_BLOCK_MINORS), FMODE_READ | FMODE_WRITE, NULL);
46+
#endif
4047
if (IS_ERR(bdev)) {
4148
pr_err("Failed to open MMC device %u: %ld\n", i, PTR_ERR(bdev));
4249
continue;
4350
}
4451

4552
disk = bdev->bd_disk;
4653
if (!disk) {
54+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
55+
blkdev_put(bdev, NULL);
56+
#else
4757
blkdev_put(bdev, FMODE_READ | FMODE_WRITE);
58+
#endif
4859
continue;
4960
}
5061

@@ -55,7 +66,11 @@ struct block_device *find_mmc_partition(void)
5566
}
5667
}
5768

69+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
70+
blkdev_put(bdev, NULL);
71+
#else
5872
blkdev_put(bdev, FMODE_READ | FMODE_WRITE);
73+
#endif
5974
}
6075

6176
return NULL;
@@ -66,6 +81,7 @@ int read_string_from_emmc(struct block_device *bdev, size_t max_length, char *bu
6681
struct bio *bio;
6782
struct page *page;
6883
int err = 0;
84+
int bi_size;
6985
void *data;
7086

7187
page = alloc_page(GFP_KERNEL);
@@ -74,9 +90,18 @@ int read_string_from_emmc(struct block_device *bdev, size_t max_length, char *bu
7490
}
7591

7692
bio = bio_alloc(bdev, __blkdev_sectors_to_bio_pages(1), REQ_OP_READ, GFP_KERNEL);
93+
if (!bio) {
94+
__free_page(page);
95+
return -ENOMEM;
96+
}
97+
7798
bio_set_dev(bio, bdev);
7899
bio->bi_iter.bi_sector = 0;
79-
bio_add_page(bio, page, PAGE_SIZE, 0);
100+
bi_size = bio_add_page(bio, page, PAGE_SIZE, 0);
101+
if (bi_size != PAGE_SIZE) {
102+
err = -EIO;
103+
goto out_bio;
104+
}
80105

81106
submit_bio_wait(bio);
82107

@@ -86,9 +111,9 @@ int read_string_from_emmc(struct block_device *bdev, size_t max_length, char *bu
86111
}
87112

88113
data = kmap(page);
89-
kunmap(page);
90114
memcpy(buffer, data, max_length - 1);
91115
buffer[max_length - 1] = '\0';
116+
kunmap(page);
92117

93118
out_bio:
94119
bio_put(bio);
@@ -143,7 +168,6 @@ static int blkdev_issue_write(struct block_device *bdev, sector_t sector, sector
143168

144169
bio->bi_iter.bi_sector = sector;
145170
bio_set_dev(bio, bdev);
146-
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
147171

148172
sz = bdev_logical_block_size(bdev);
149173
bi_size = bio_add_page(bio, page, sz, 0);
@@ -261,7 +285,11 @@ static int __init rf_switch_init(void)
261285
static void __exit rf_switch_exit(void)
262286
{
263287
if (target_bdev) {
288+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
289+
blkdev_put(target_bdev, NULL);
290+
#else
264291
blkdev_put(target_bdev, FMODE_READ | FMODE_WRITE);
292+
#endif
265293
target_bdev = NULL;
266294
}
267295
remove_proc_entry(PROC_NAME, NULL);

feeds/qca-wifi-7/ipq53xx/config-6.6

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,3 +1408,5 @@ CONFIG_SKB_RECYCLE_SIZE=2304
14081408
CONFIG_RTL8221D_PHY=y
14091409
CONFIG_RTK_MSSDK_PHY=y
14101410
CONFIG_HWMON=y
1411+
# CONFIG_INPUT_LSM303AGR is not set
1412+
# CONFIG_USB_SERIAL_XR is not set
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* STMicroelectronics ilps22qs driver
4+
*
5+
* Copyright 2023 STMicroelectronics Inc.
6+
*
7+
* MEMS Software Solutions Team
8+
*/
9+
10+
#ifndef __ST_ILPS22QS_H
11+
#define __ST_ILPS22QS_H
12+
13+
#include <linux/bitfield.h>
14+
#include <linux/iio/iio.h>
15+
#include <linux/module.h>
16+
#include <linux/mutex.h>
17+
#include <linux/of.h>
18+
#include <linux/regmap.h>
19+
#include <linux/types.h>
20+
#include <linux/workqueue.h>
21+
22+
#define ST_ILPS22QS_DEV_NAME "ilps22qs"
23+
#define ST_ILPS28QSW_DEV_NAME "ilps28qsw"
24+
25+
#define ST_ILPS22QS_WHO_AM_I_ADDR 0x0f
26+
#define ST_ILPS22QS_WHOAMI_VAL 0xb4
27+
28+
#define ST_ILPS22QS_CTRL1_ADDR 0x10
29+
#define ST_ILPS22QS_ODR_MASK GENMASK(6, 3)
30+
31+
#define ST_ILPS22QS_CTRL2_ADDR 0x11
32+
#define ST_ILPS22QS_SOFT_RESET_MASK BIT(2)
33+
#define ST_ILPS22QS_BDU_MASK BIT(3)
34+
35+
#define ST_ILPS22QS_CTRL3_ADDR 0x12
36+
#define ST_ILPS22QS_AH_QVAR_EN_MASK BIT(7)
37+
#define ST_ILPS22QS_AH_QVAR_P_AUTO_EN_MASK BIT(5)
38+
39+
#define ST_ILPS22QS_PRESS_OUT_XL_ADDR 0x28
40+
#define ST_ILPS22QS_TEMP_OUT_L_ADDR 0x2b
41+
42+
#define ST_ILPS22QS_PRESS_FS_AVL_GAIN (1000000000UL / 4096UL)
43+
#define ST_ILPS22QS_TEMP_FS_AVL_GAIN 100
44+
#define ST_ILPS22QS_QVAR_FS_AVL_GAIN 438000
45+
46+
#define ST_ILPS22QS_SHIFT_VAL(val, mask) (((val) << __ffs(mask)) & (mask))
47+
48+
#define ST_ILPS22QS_ODR_LIST_NUM 8
49+
50+
enum st_ilps22qs_sensor_id {
51+
ST_ILPS22QS_PRESS = 0,
52+
ST_ILPS22QS_TEMP,
53+
ST_ILPS22QS_QVAR,
54+
ST_ILPS22QS_SENSORS_NUM,
55+
};
56+
57+
struct st_ilps22qs_odr_t {
58+
u8 hz;
59+
u8 val;
60+
};
61+
62+
struct st_ilps22qs_reg {
63+
u8 addr;
64+
u8 mask;
65+
};
66+
67+
struct st_ilps22qs_odr_table_t {
68+
u8 size;
69+
struct st_ilps22qs_reg reg;
70+
struct st_ilps22qs_odr_t odr_avl[ST_ILPS22QS_ODR_LIST_NUM];
71+
};
72+
73+
struct st_ilps22qs_hw {
74+
struct iio_dev *iio_devs[ST_ILPS22QS_SENSORS_NUM];
75+
struct workqueue_struct *workqueue;
76+
struct regulator *vddio_supply;
77+
struct regulator *vdd_supply;
78+
struct regmap *regmap;
79+
struct device *dev;
80+
struct mutex lock;
81+
bool interleave;
82+
u8 enable_mask;
83+
u8 odr;
84+
};
85+
86+
struct st_ilps22qs_sensor {
87+
enum st_ilps22qs_sensor_id id;
88+
struct work_struct iio_work;
89+
struct st_ilps22qs_hw *hw;
90+
struct hrtimer hr_timer;
91+
ktime_t ktime;
92+
int64_t timestamp;
93+
char name[32];
94+
u32 gain;
95+
u8 odr;
96+
};
97+
98+
extern const struct dev_pm_ops st_ilps22qs_pm_ops;
99+
100+
static inline int st_ilps22qs_update_locked(struct st_ilps22qs_hw *hw,
101+
unsigned int addr,
102+
unsigned int mask,
103+
unsigned int data)
104+
{
105+
unsigned int val = ST_ILPS22QS_SHIFT_VAL(data, mask);
106+
int err;
107+
108+
mutex_lock(&hw->lock);
109+
err = regmap_update_bits(hw->regmap, addr, mask, val);
110+
mutex_unlock(&hw->lock);
111+
112+
return err;
113+
}
114+
115+
static inline int st_ilps22qs_read_locked(struct st_ilps22qs_hw *hw,
116+
unsigned int addr, void *val,
117+
unsigned int len)
118+
{
119+
int err;
120+
121+
mutex_lock(&hw->lock);
122+
err = regmap_bulk_read(hw->regmap, addr, val, len);
123+
mutex_unlock(&hw->lock);
124+
125+
return err;
126+
}
127+
128+
static inline void st_ilps22qs_flush_works(struct st_ilps22qs_hw *hw)
129+
{
130+
flush_workqueue(hw->workqueue);
131+
}
132+
133+
static inline int st_ilps22qs_destroy_workqueue(struct st_ilps22qs_hw *hw)
134+
{
135+
if (hw->workqueue)
136+
destroy_workqueue(hw->workqueue);
137+
138+
return 0;
139+
}
140+
141+
static inline int st_ilps22qs_allocate_workqueue(struct st_ilps22qs_hw *hw)
142+
{
143+
if (!hw->workqueue)
144+
hw->workqueue = create_workqueue(ST_ILPS22QS_DEV_NAME);
145+
146+
return !hw->workqueue ? -ENOMEM : 0;
147+
}
148+
149+
static inline s64 st_ilps22qs_get_time_ns(struct st_ilps22qs_hw *hw)
150+
{
151+
return iio_get_time_ns(hw->iio_devs[ST_ILPS22QS_PRESS]);
152+
}
153+
154+
int st_ilps22qs_probe(struct device *dev, struct regmap *regmap);
155+
int st_ilps22qs_remove(struct device *dev);
156+
157+
#endif /* __ST_ILPS22QS_H */

0 commit comments

Comments
 (0)