tcan4x5x: initial commit
RFC PATCH 1/2 tcan4x5x: initial commit
This driver will put the tcan4x5x device into sleep mode to reduce power consumption.
Signed-off-by Sean Nyekjaer <[email protected]>
---
Not many drivers use SPI. So leave this for others to see how it can be done.
If this is appropriate for upstreaming, please comment :)
drivers/misc/Kconfig | 5 ++ drivers/misc/Makefile | 3 + drivers/misc/tcan4x5x.c | 135 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 drivers/misc/tcan4x5x.c
drivers/misc/Kconfig +5 -0
@@ -170,6 +170,11 @@ config CMD_CROS_EC updating its flash, accessing a small saved context area and talking to the I2C bus behind the EC (if there is one). +config TCAN4X5X + bool "Enable TCAN4X5X" + depends on MISC + depends on DM_GPIO + config CROS_EC bool "Enable Chrome OS EC" help
drivers/misc/Makefile +3 -0
@@ -29,6 +29,9 @@ ifdef CONFIG_XPL_BUILD obj-$(CONFIG_SANDBOX) += spltest_sandbox.o endif endif +ifndef CONFIG_SPL_BUILD +obj-$(CONFIG_TCAN4X5X) += tcan4x5x.o +endif obj-$(CONFIG_ALTERA_SYSID) += altera_sysid.o obj-$(CONFIG_ATSHA204A) += atsha204a-i2c.o obj-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
drivers/misc/tcan4x5x.c new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
2.55.0
RFC PATCH 2/2 tcan4x5x: set nwkrq voltage
nwkrq can be driven from vio or vsup voltage, read from devicetree to determine which rail should drive nwkrq.
Signed-off-by Sean Nyekjaer <[email protected]>
--- drivers/misc/tcan4x5x.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/misc/tcan4x5x.c +30 -0
@@ -10,6 +10,7 @@#define TCAN4X5X_CONFIG 0x800#define TCAN4X5X_MODE_BITS (BIT(7) | BIT(6)) +#define TCAN4X5X_NWKRQ_VOLTAGE_VIO BIT(19)struct tcan4x5x_transfer {u8 cmd;
@@ -87,6 +88,28 @@ static int tcan4x5x_enable_sleep(struct udevice *dev)return ret; } +static int tcan4x5x_nwkrq_vio (struct udevice *dev) +{ +u32 val; +int ret; + + ret =tcan4x5x_read_reg (dev,TCAN4X5X_CONFIG , &val); +if (ret) { +log_err ("failed to read from tcan4x5x\n" ); +return ret; + } + +log_debug ("read %x\n" , val); + val |=TCAN4X5X_NWKRQ_VOLTAGE_VIO ; +log_debug ("write %x\n" , val); + + ret =tcan4x5x_write_reg (dev,TCAN4X5X_CONFIG , val); +if (ret) +log_err ("reg write failed (%d)\n" , ret); + +return ret; +} +static int tcan4x5x_probe (struct udevice *dev) {struct gpio_desc rst;
@@ -119,6 +142,13 @@ static int tcan4x5x_probe(struct udevice *dev)*/ udelay (1000 ); +if (dev_read_bool (dev,"ti,nwkrq-voltage-vio" )) { +log_debug ("set nwkrq voltage to vio\n" ); + ret =tcan4x5x_nwkrq_vio (dev); +if (ret) +return ret; + } +return tcan4x5x_enable_sleep (dev); }
Signature · 1 line
2.55.0