Skip to content

Commit 31c9c4c

Browse files
committed
Merge tag 'pinctrl-v6.1-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl
Pull pin control fixes from Linus Walleij: "Aere is a hopefully final round of pin control fixes. Nothing special, driver fixes and we caught a potential NULL pointer exception. - Fix a potential NULL dereference in the core! - Fix all pin mux routes in the Rockchop PX30 driver - Fix the UFS pins in the Qualcomm SC8280XP driver - Fix bias disabling in the Mediatek driver - Fix debounce time settings in the Mediatek driver" * tag 'pinctrl-v6.1-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: pinctrl: mediatek: Export debounce time tables pinctrl: mediatek: Fix EINT pins input debounce time configuration pinctrl: devicetree: fix null pointer dereferencing in pinctrl_dt_to_map pinctrl: mediatek: common-v2: Fix bias-disable for PULL_PU_PD_RSEL_TYPE pinctrl: qcom: sc8280xp: Rectify UFS reset pins pinctrl: rockchip: list all pins in a possible mux route for PX30
2 parents 941209e + 2e35b25 commit 31c9c4c

26 files changed

+103
-7
lines changed

drivers/pinctrl/devicetree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev)
220220
for (state = 0; ; state++) {
221221
/* Retrieve the pinctrl-* property */
222222
propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state);
223+
if (!propname)
224+
return -ENOMEM;
223225
prop = of_find_property(np, propname, &size);
224226
kfree(propname);
225227
if (!prop) {

drivers/pinctrl/mediatek/mtk-eint.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define MTK_EINT_EDGE_SENSITIVE 0
2525
#define MTK_EINT_LEVEL_SENSITIVE 1
2626
#define MTK_EINT_DBNC_SET_DBNC_BITS 4
27+
#define MTK_EINT_DBNC_MAX 16
2728
#define MTK_EINT_DBNC_RST_BIT (0x1 << 1)
2829
#define MTK_EINT_DBNC_SET_EN (0x1 << 0)
2930

@@ -48,6 +49,21 @@ static const struct mtk_eint_regs mtk_generic_eint_regs = {
4849
.dbnc_clr = 0x700,
4950
};
5051

52+
const unsigned int debounce_time_mt2701[] = {
53+
500, 1000, 16000, 32000, 64000, 128000, 256000, 0
54+
};
55+
EXPORT_SYMBOL_GPL(debounce_time_mt2701);
56+
57+
const unsigned int debounce_time_mt6765[] = {
58+
125, 250, 500, 1000, 16000, 32000, 64000, 128000, 256000, 512000, 0
59+
};
60+
EXPORT_SYMBOL_GPL(debounce_time_mt6765);
61+
62+
const unsigned int debounce_time_mt6795[] = {
63+
500, 1000, 16000, 32000, 64000, 128000, 256000, 512000, 0
64+
};
65+
EXPORT_SYMBOL_GPL(debounce_time_mt6795);
66+
5167
static void __iomem *mtk_eint_get_offset(struct mtk_eint *eint,
5268
unsigned int eint_num,
5369
unsigned int offset)
@@ -404,10 +420,11 @@ int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_num,
404420
int virq, eint_offset;
405421
unsigned int set_offset, bit, clr_bit, clr_offset, rst, i, unmask,
406422
dbnc;
407-
static const unsigned int debounce_time[] = {500, 1000, 16000, 32000,
408-
64000, 128000, 256000};
409423
struct irq_data *d;
410424

425+
if (!eint->hw->db_time)
426+
return -EOPNOTSUPP;
427+
411428
virq = irq_find_mapping(eint->domain, eint_num);
412429
eint_offset = (eint_num % 4) * 8;
413430
d = irq_get_irq_data(virq);
@@ -418,9 +435,9 @@ int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_num,
418435
if (!mtk_eint_can_en_debounce(eint, eint_num))
419436
return -EINVAL;
420437

421-
dbnc = ARRAY_SIZE(debounce_time);
422-
for (i = 0; i < ARRAY_SIZE(debounce_time); i++) {
423-
if (debounce <= debounce_time[i]) {
438+
dbnc = eint->num_db_time;
439+
for (i = 0; i < eint->num_db_time; i++) {
440+
if (debounce <= eint->hw->db_time[i]) {
424441
dbnc = i;
425442
break;
426443
}
@@ -494,6 +511,13 @@ int mtk_eint_do_init(struct mtk_eint *eint)
494511
if (!eint->domain)
495512
return -ENOMEM;
496513

514+
if (eint->hw->db_time) {
515+
for (i = 0; i < MTK_EINT_DBNC_MAX; i++)
516+
if (eint->hw->db_time[i] == 0)
517+
break;
518+
eint->num_db_time = i;
519+
}
520+
497521
mtk_eint_hw_init(eint);
498522
for (i = 0; i < eint->hw->ap_num; i++) {
499523
int virq = irq_create_mapping(eint->domain, i);

drivers/pinctrl/mediatek/mtk-eint.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ struct mtk_eint_hw {
3737
u8 ports;
3838
unsigned int ap_num;
3939
unsigned int db_cnt;
40+
const unsigned int *db_time;
4041
};
4142

43+
extern const unsigned int debounce_time_mt2701[];
44+
extern const unsigned int debounce_time_mt6765[];
45+
extern const unsigned int debounce_time_mt6795[];
46+
4247
struct mtk_eint;
4348

4449
struct mtk_eint_xt {
@@ -62,6 +67,7 @@ struct mtk_eint {
6267
/* Used to fit into various EINT device */
6368
const struct mtk_eint_hw *hw;
6469
const struct mtk_eint_regs *regs;
70+
u16 num_db_time;
6571

6672
/* Used to fit into various pinctrl device */
6773
void *pctl;

drivers/pinctrl/mediatek/pinctrl-mt2701.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ static const struct mtk_pinctrl_devdata mt2701_pinctrl_data = {
518518
.ports = 6,
519519
.ap_num = 169,
520520
.db_cnt = 16,
521+
.db_time = debounce_time_mt2701,
521522
},
522523
};
523524

drivers/pinctrl/mediatek/pinctrl-mt2712.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ static const struct mtk_pinctrl_devdata mt2712_pinctrl_data = {
567567
.ports = 8,
568568
.ap_num = 229,
569569
.db_cnt = 40,
570+
.db_time = debounce_time_mt2701,
570571
},
571572
};
572573

drivers/pinctrl/mediatek/pinctrl-mt6765.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ static const struct mtk_eint_hw mt6765_eint_hw = {
10621062
.ports = 6,
10631063
.ap_num = 160,
10641064
.db_cnt = 13,
1065+
.db_time = debounce_time_mt6765,
10651066
};
10661067

10671068
static const struct mtk_pin_soc mt6765_data = {

drivers/pinctrl/mediatek/pinctrl-mt6779.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ static const struct mtk_eint_hw mt6779_eint_hw = {
737737
.ports = 6,
738738
.ap_num = 195,
739739
.db_cnt = 13,
740+
.db_time = debounce_time_mt2701,
740741
};
741742

742743
static const struct mtk_pin_soc mt6779_data = {

drivers/pinctrl/mediatek/pinctrl-mt6795.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ static const struct mtk_eint_hw mt6795_eint_hw = {
475475
.ports = 7,
476476
.ap_num = 224,
477477
.db_cnt = 32,
478+
.db_time = debounce_time_mt6795,
478479
};
479480

480481
static const unsigned int mt6795_pull_type[] = {

drivers/pinctrl/mediatek/pinctrl-mt7622.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ static const struct mtk_eint_hw mt7622_eint_hw = {
846846
.ports = 7,
847847
.ap_num = ARRAY_SIZE(mt7622_pins),
848848
.db_cnt = 20,
849+
.db_time = debounce_time_mt6765,
849850
};
850851

851852
static const struct mtk_pin_soc mt7622_data = {

drivers/pinctrl/mediatek/pinctrl-mt7623.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,7 @@ static const struct mtk_eint_hw mt7623_eint_hw = {
13691369
.ports = 6,
13701370
.ap_num = 169,
13711371
.db_cnt = 20,
1372+
.db_time = debounce_time_mt2701,
13721373
};
13731374

13741375
static struct mtk_pin_soc mt7623_data = {

0 commit comments

Comments
 (0)