Thread (23 messages) 23 messages, 5 authors, 2020-08-23

Re: [RFC PATCH 04/10] mfd: Add base driver for Netronix embedded controller

From: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Date: 2020-06-28 08:30:15
Also in: linux-arm-kernel, linux-pwm, linux-rtc, lkml

On Sat, Jun 27, 2020 at 10:17:38AM +0200, Andreas Kemnade wrote:
On Sun, 21 Jun 2020 00:42:15 +0200
Jonathan Neuschäfer [off-list ref] wrote:
quoted
Third-party hardware documentation is available at
https://github.com/neuschaefer/linux/wiki/Netronix-MSP430-embedded-controller

The EC supports interrupts, but the driver doesn't make use of them so
far.

Known problems:
- The reboot handler is installed in such a way that it directly calls
  into the i2c subsystem to send the reboot command to the EC. This
  means that the reboot handler may sleep, which is not allowed.
see
https://patchwork.ozlabs.org/project/linux-i2c/patch/20190415213432.8972-3-contact@stefanchrist.eu/

for a fix of such problems. 
So far, regmap isn't involved here, but I'll remember it when I switch
to regmap.

Between when I first wrote this driver and now, the I2C has added
support for transfers in atomic contexts very late in the system's life
(exactly what happens when you reset a system via PMIC/EC), so this
problem seems to be gone from my driver, for now.
(See commit 63b96983a5ddf ("i2c: core: introduce callbacks for atomic transfers"))


[...]
quoted
+int ntxec_write8(struct ntxec *ec, u8 addr, u8 value)
+{
+	return ntxec_write16(ec, addr, value << 8);
+}
+EXPORT_SYMBOL(ntxec_write8);
+
do we really need both 16bit and 8bit accessors?
No, the hardware/firmware doesn't care.
If not, then simply use regmap_i2c_init and set val_bits accordingly.
Maybe just doing the << 8 in the constants?
Thanks, I'll try this approach.

The values are not always constants, for example in the PWM driver:

	res |= ntxec_write8(pwm->ec, NTXEC_PERIOD_HIGH, period >> 8);
	res |= ntxec_write8(pwm->ec, NTXEC_PERIOD_LOW, period);
	res |= ntxec_write8(pwm->ec, NTXEC_DUTY_HIGH, duty >> 8);
	res |= ntxec_write8(pwm->ec, NTXEC_DUTY_LOW, duty);


Jonathan

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help