Skip to content

Commit d115753

Browse files
akemnadeLee Jones
authored andcommitted
mfd: ntxec: Support for EC in Tolino Shine 2 HD
Add the version of the EC in the Tolino Shine 2 HD to the supported versions. It seems not to have an RTC and does not ack data written to it. The vendor kernel happily ignores write errors, using I2C via userspace i2c-set also shows the error. So add a quirk to ignore that error. PWM can be successfully configured despite of that error. Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent 4917e49 commit d115753

2 files changed

Lines changed: 54 additions & 3 deletions

File tree

‎drivers/mfd/ntxec.c‎

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,38 @@ static struct notifier_block ntxec_restart_handler = {
9696
.priority = 128,
9797
};
9898

99+
static int regmap_ignore_write(void *context,
100+
unsigned int reg, unsigned int val)
101+
102+
{
103+
struct regmap *regmap = context;
104+
105+
regmap_write(regmap, reg, val);
106+
107+
return 0;
108+
}
109+
110+
static int regmap_wrap_read(void *context, unsigned int reg,
111+
unsigned int *val)
112+
{
113+
struct regmap *regmap = context;
114+
115+
return regmap_read(regmap, reg, val);
116+
}
117+
118+
/*
119+
* Some firmware versions do not ack written data, add a wrapper. It
120+
* is used to stack another regmap on top.
121+
*/
122+
static const struct regmap_config regmap_config_noack = {
123+
.name = "ntxec_noack",
124+
.reg_bits = 8,
125+
.val_bits = 16,
126+
.cache_type = REGCACHE_NONE,
127+
.reg_write = regmap_ignore_write,
128+
.reg_read = regmap_wrap_read
129+
};
130+
99131
static const struct regmap_config regmap_config = {
100132
.name = "ntxec",
101133
.reg_bits = 8,
@@ -104,16 +136,22 @@ static const struct regmap_config regmap_config = {
104136
.val_format_endian = REGMAP_ENDIAN_BIG,
105137
};
106138

107-
static const struct mfd_cell ntxec_subdevices[] = {
139+
static const struct mfd_cell ntxec_subdev[] = {
108140
{ .name = "ntxec-rtc" },
109141
{ .name = "ntxec-pwm" },
110142
};
111143

144+
static const struct mfd_cell ntxec_subdev_pwm[] = {
145+
{ .name = "ntxec-pwm" },
146+
};
147+
112148
static int ntxec_probe(struct i2c_client *client)
113149
{
114150
struct ntxec *ec;
115151
unsigned int version;
116152
int res;
153+
const struct mfd_cell *subdevs;
154+
size_t n_subdevs;
117155

118156
ec = devm_kmalloc(&client->dev, sizeof(*ec), GFP_KERNEL);
119157
if (!ec)
@@ -137,6 +175,18 @@ static int ntxec_probe(struct i2c_client *client)
137175
/* Bail out if we encounter an unknown firmware version */
138176
switch (version) {
139177
case NTXEC_VERSION_KOBO_AURA:
178+
subdevs = ntxec_subdev;
179+
n_subdevs = ARRAY_SIZE(ntxec_subdev);
180+
break;
181+
case NTXEC_VERSION_TOLINO_SHINE2:
182+
subdevs = ntxec_subdev_pwm;
183+
n_subdevs = ARRAY_SIZE(ntxec_subdev_pwm);
184+
/* Another regmap stacked on top of the other */
185+
ec->regmap = devm_regmap_init(ec->dev, NULL,
186+
ec->regmap,
187+
&regmap_config_noack);
188+
if (IS_ERR(ec->regmap))
189+
return PTR_ERR(ec->regmap);
140190
break;
141191
default:
142192
dev_err(ec->dev,
@@ -181,8 +231,8 @@ static int ntxec_probe(struct i2c_client *client)
181231

182232
i2c_set_clientdata(client, ec);
183233

184-
res = devm_mfd_add_devices(ec->dev, PLATFORM_DEVID_NONE, ntxec_subdevices,
185-
ARRAY_SIZE(ntxec_subdevices), NULL, 0, NULL);
234+
res = devm_mfd_add_devices(ec->dev, PLATFORM_DEVID_NONE,
235+
subdevs, n_subdevs, NULL, 0, NULL);
186236
if (res)
187237
dev_err(ec->dev, "Failed to add subdevices: %d\n", res);
188238

‎include/linux/mfd/ntxec.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ static inline __be16 ntxec_reg8(u8 value)
3333

3434
/* Known firmware versions */
3535
#define NTXEC_VERSION_KOBO_AURA 0xd726 /* found in Kobo Aura */
36+
#define NTXEC_VERSION_TOLINO_SHINE2 0xf110 /* found in Tolino Shine 2 HD */
3637

3738
#endif

0 commit comments

Comments
 (0)