Skip to content

Commit 861665c

Browse files
committed
fixup! WIP: mfd: Add support for Flipper One's MCU
1 parent 8df3109 commit 861665c

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

drivers/mfd/flipper-one-mcu.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ static const struct regmap_range fomcu_writeable_reg_ranges[] = {
1818
regmap_reg_range(FOMCU_REG_LEDS_BR_LINK,
1919
FOMCU_REG_LEDS_COLOR_LINK4),
2020
regmap_reg_range(FOMCU_REG_HAPTIC, FOMCU_REG_HAPTIC),
21+
regmap_reg_range(FOMCU_REG_UCSI_CONTROL,
22+
FOMCU_REG_UCSI_CONTROL + 6),
23+
regmap_reg_range(FOMCU_REG_UCSI_MESSAGE_OUT, FOMCU_REG_MAX),
2124
};
2225

2326
static const struct regmap_access_table fomcu_writeable_regs = {
@@ -68,12 +71,15 @@ static const struct regmap_irq fomcu_irqs[] = {
6871
FOMCU_IRQ_REG(INPUT, BTN),
6972
FOMCU_IRQ_REG(INPUT, TOUCH),
7073
FOMCU_IRQ_REG(INPUT, HEADSET),
74+
FOMCU_IRQ_REG(UCSI, EVENT),
7175
};
7276

7377
static unsigned int irq_input_offsets[] = { FOMCU_INTOFF_INPUT };
78+
static unsigned int irq_ucsi_offsets[] = { FOMCU_INTOFF_UCSI };
7479

7580
static const struct regmap_irq_sub_irq_map fomcu_sub_irqs[] = {
7681
REGMAP_IRQ_MAIN_REG_OFFSET(irq_input_offsets),
82+
REGMAP_IRQ_MAIN_REG_OFFSET(irq_ucsi_offsets),
7783
};
7884

7985
static const struct regmap_irq_chip fomcu_irq_chip = {
@@ -94,14 +100,19 @@ static const struct resource fo_input_irqs[] = {
94100
DEFINE_RES_IRQ_NAMED(FOMCU_INT_INPUT_HEADSET, "flipper-one-input-headset"),
95101
};
96102

103+
static const struct resource fo_ucsi_irqs[] = {
104+
DEFINE_RES_IRQ_NAMED(FOMCU_INT_UCSI_EVENT, "flipper-one-ucsi"),
105+
};
106+
97107
static const struct mfd_cell cells[] = {
98108
MFD_CELL_NAME("flipper-one-haptic"),
99109
MFD_CELL_RES("flipper-one-input", fo_input_irqs),
100110
MFD_CELL_NAME("flipper-one-leds"),
101111
MFD_CELL_NAME("flipper-one-power"),
102112
MFD_CELL_NAME("flipper-one-regulators"),
103113
MFD_CELL_NAME("flipper-one-thermal"),
104-
MFD_CELL_NAME("flipper-one-typec"),
114+
MFD_CELL_OF("flipper-one-typec", fo_ucsi_irqs, NULL, 0, 0,
115+
"flipper,one-typec"),
105116
};
106117

107118
static int fomcu_probe(struct i2c_client *client)

include/linux/mfd/flipper-one-mcu.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ enum fomcu_interrupts {
1414
FOMCU_INT_INPUT_BTN,
1515
FOMCU_INT_INPUT_TOUCH,
1616
FOMCU_INT_INPUT_HEADSET,
17+
FOMCU_INT_UCSI_EVENT,
1718
};
1819

1920
#define FOMCU_REG_INTSTS 0x0000
@@ -26,7 +27,12 @@ enum fomcu_interrupts {
2627
#define FOMCU_INTSTS_INPUT_TOUCH BIT(1)
2728
#define FOMCU_INTSTS_INPUT_HEADSET BIT(2)
2829

30+
#define FOMCU_REG_INTSTS_UCSI 0x0102
31+
#define FOMCU_INTOFF_UCSI 0x2
32+
#define FOMCU_INTSTS_UCSI_EVENT BIT(0)
33+
2934
#define FOMCU_REG_INTMSK_INPUT 0x0180
35+
#define FOMCU_REG_INTMSK_UCSI 0x0182
3036

3137
#define FOMCU_REG_INPUT_BTNS 0x0200
3238
#define FOMCU_REG_INPUT_TOUCH_X 0x0202
@@ -49,7 +55,16 @@ enum fomcu_interrupts {
4955
#define FOMCU_HAPTIC_EFFECT GENMASK(14, 8)
5056
#define FOMCU_HAPTIC_DURATION GENMASK(7, 0)
5157

52-
#define FOMCU_REG_MAX (FOMCU_REG_HAPTIC + 1)
58+
#define FOMCU_REG_UCSI 0x0500
59+
#define FOMCU_REG_UCSI_VERSION (FOMCU_REG_UCSI + 0x00)
60+
#define FOMCU_REG_UCSI_CCI (FOMCU_REG_UCSI + 0x04)
61+
#define FOMCU_REG_UCSI_CONTROL (FOMCU_REG_UCSI + 0x08)
62+
#define FOMCU_REG_UCSI_MESSAGE_IN 0x0600
63+
#define FOMCU_REG_UCSI_MESSAGE_OUT 0x0700
64+
#define FOMCU_UCSI_MESSAGE_LEN 256
65+
66+
#define FOMCU_REG_MAX (FOMCU_REG_UCSI_MESSAGE_OUT + \
67+
FOMCU_UCSI_MESSAGE_LEN - 1)
5368

5469
struct fomcu_device {
5570
struct i2c_client *client;

0 commit comments

Comments
 (0)