arm: tegra: implement NVEC driver using tegra i2c.
Subsystems (6)
v3 cover arm: tegra: implement NVEC driver using tegra i2c.
This version (v3) is for pushing tegra i2c driver to i2c tree. NVEC driver will be reworked later to use i2c core slave framework.
NVEC driver contains code to manage tegra i2c controller in slave mode. I2C slave support was implemented in linux kernel. The goal of this patch serie is to implement I2C slave mode in tegra drived and rework NVEC driver to use it.
Patches are based on i2c for-next.
Changes for v3:
- rebase on top of i2c for-next tree
- fix 10-bit address condition in tegra i2c driver
Changes for v2:
- rebased on top of new i2c slave framework.
- old code is removed in separate patch
- documentation patch is integrated to main nvec patch
Thanks in advance
*** BLURB HERE ***
Andrey Danin (4):
i2c: tegra: implement slave mode staging/nvec: reimplement on top of tegra i2c driver staging/nvec: remove old code
dt: paz00: define nvec as child of i2c bus
.../devicetree/bindings/nvec/nvidia,nvec.txt | 21 +- arch/arm/boot/dts/tegra20-paz00.dts | 22 +- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-tegra.c | 119 ++++++ drivers/staging/nvec/nvec.c | 411 +++++++-------------- drivers/staging/nvec/nvec.h | 10 - 6 files changed, 269 insertions(+), 315 deletions(-)
Signature · 1 line
1.9.1
PATCH v3 1/4 i2c: tegra: implement slave mode
Initialization code is based on NVEC driver.
There is a HW bug in AP20 that was also mentioned in kernel sources for Toshiba AC100.
---
Changes for v3:
- handle 10-bit clients properly
Changes for v2:
- remove hack from tegra_i2c_clock_disable
- replace slave status helper functions with local variables
- add constant for default delay count value
- add 10-bit address support
- remove read_slave_start_delay init as zero
- don't reset controller during slave registration
- slave isr returns int instead of bool
- make status related variables in slave u32 instead of unsigned int
- enable i2c slave in Kconfig
- rebase on top of new i2c slave framework
- delay workaround was added from nvec
--- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-tegra.c | 119 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+)
drivers/i2c/busses/Kconfig +1 -0
@@ -888,6 +888,7 @@ config I2C_SUN6I_P2WI config I2C_TEGRA tristate "NVIDIA Tegra internal I2C controller" depends on ARCH_TEGRA + select I2C_SLAVE help If you say yes to this option, support will be included for the I2C controller embedded in NVIDIA Tegra SOCs
drivers/i2c/busses/i2c-tegra.c +119 -0
172 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v3 1/4] i2c: tegra: implement slave mode
Hi Andrey,
Quoted 6 lines · Andrey Danin
Initialization code is based on NVEC driver.
There is a HW bug in AP20 that was also mentioned in kernel sources for Toshiba AC100.
Signed-off-by Andrey Danin <[email protected]>
Still doesn't work for me and I think I understand why. Do you run your I2C controller in slave mode only? That might work, but using it in master/slave mode simultanously won't work yet as I see it:
* After every transfer (as master), clocks get disabled. I assume the IP core won't be able to detect its own address then.
* There is this code in tegra_i2c_init():
if (!i2c_dev->is_dvc) {
u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG);
sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL;
i2c_writel(i2c_dev, sl_cfg, I2C_SL_CNFG);
i2c_writel(i2c_dev, 0xfc, I2C_SL_ADDR1);
i2c_writel(i2c_dev, 0x00, I2C_SL_ADDR2);
} It probably messes up the slave initialization in tegra_reg_slave(). At least I see that the slave address gets overwritten when I peek the register after boot.
Does that make sense to you?
Thanks,
Wolfram
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150724/e61802b7/attachment-0001.sig>
Re: [PATCH v3 1/4] i2c: tegra: implement slave mode
Quoted 2 lines · Wolfram Sang
Still doesn't work for me and I think I understand why. Do you run your I2C controller in slave mode only?
Yes.
Quoted 5 lines
That might work, but using it in
master/slave mode simultanously won't work yet as I see it:* After every transfer (as master), clocks get disabled. I assume the IP core won't be able to detect its own address then.
At the begin of my work on this patchset I even denied clock disable call if slave is registered (to minimize code that can affect transfer). If only slave mode is used, then this logic is not needed.
Quoted 12 lines
* There is this code in
tegra_i2c_init():if (!i2c_dev->is_dvc) { u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG); sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL; i2c_writel(i2c_dev, sl_cfg, I2C_SL_CNFG); i2c_writel(i2c_dev, 0xfc, I2C_SL_ADDR1); i2c_writel(i2c_dev, 0x00, I2C_SL_ADDR2); }
Quoted 4 lines
It probably messes up the slave initialization in
tegra_reg_slave(). At least I see that the slave address gets overwritten when I peek the register after boot.
tegra_i2c_init is called on probe and resume. Also it is called in case of xfer fail. If xfer is ok, then I think slave addr must be kept unchanged.
Quoted 1 line
Does that make sense to you?
As far as I understand it is a loopback mode. Probably it will not work (Stephen Warren already mentioned this).
But we can try to run it.
Re: [PATCH v3 1/4] i2c: tegra: implement slave mode
Quoted 3 lines
At the begin of my work on this patchset I even denied clock disable call if slave is registered (to minimize code that can affect transfer).
I hacked something like this, but it seems it was not enough.
Quoted 1 line
If only slave mode is used, then this logic is not needed.
This is not sufficent. We shouldn't break being a master only because we also listen to a slave address (as long as the HW supports that of course).
Quoted 2 lines
tegra_i2c_initis called on probe and resume. Also it is called in case of xfer fail. If xfer is ok, then I think slave addr must be kept unchanged.
This is fragile. Try scanning the bus with i2cdetect and slave setup will be gone.
Quoted 2 lines
As far as I understand it is a loopback mode. Probably it will not work (Stephen Warren already mentioned this).
Just to make clear: I am not saying we should support talking to our own slave address. But it should still be possible to communicate with other remote devices on the bus.
Thanks,
Wolfram
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150724/cf826f2c/attachment.sig>
Re: [PATCH v3 1/4] i2c: tegra: implement slave mode
Quoted 18 lines · Wolfram Sang
Quoted 3 lines
At the begin of my work on this patchset I even denied clock disable call if slave is registered (to minimize code that can affect transfer).
I hacked something like this, but it seems it was not enough.
Quoted 1 line
If only slave mode is used, then this logic is not needed.
This is not sufficent. We shouldn't break being a master only because we also listen to a slave address (as long as the HW supports that of course).
Quoted 2 lines
tegra_i2c_initis called on probe and resume. Also it is called in case of xfer fail. If xfer is ok, then I think slave addr must be kept unchanged.This is fragile. Try scanning the bus with i2cdetect and slave setup will be gone.
Quoted 6 lines
Quoted 2 lines
As far as I understand it is a loopback mode. Probably it will not work (Stephen Warren already mentioned this).
Just to make clear: I am not saying we should support talking to our own slave address. But it should still be possible to communicate with other remote devices on the bus.
Sorry for the long delay. I tried to analyze the issue. Attached patch works on AC100 (Misha Komarovsky helped me with testing).
Wolfram could you please try the patch with your environment?
Thanks.
-------------- next part --------------
Quoted 1 line
From
0927b4007786b19e51415c4900863dd4e74fa034Mon Sep 17 00:00:00 2001
From: Andrey Danin <[email protected]>
Date: Thu, 20 Aug 2015 00:41:39 +0300
Subject: [PATCH] i2c: tegra: don't reset I2C slave address on init
Init function is called multuple times. If I2C controller works in slave mode, then driver must keep slave registers otherwise slave configuration will be reseted.
--- drivers/i2c/busses/i2c-tegra.c | 42 +++++++++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 15 deletions(-)
drivers/i2c/busses/i2c-tegra.c +27 -15
@@ -402,6 +402,22 @@ static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev)dvc_writel (i2c_dev, val,DVC_CTRL_REG1 ); } +static int tegra_i2c_init_slave (struct tegra_i2c_dev *i2c_dev,u32 addr,u32 flags) +{ +int addr2 =0 ; + +i2c_writel (i2c_dev,I2C_SL_CNFG_NEWSL ,I2C_SL_CNFG ); +i2c_writel (i2c_dev,I2C_SL_DELAY_COUNT_DEFAULT ,I2C_SL_DELAY_COUNT ); + +if (flags &I2C_CLIENT_TEN ) + addr2 = (addr >>7 ) |I2C_SL_ADDR2_TEN_BIT_MODE ; + +i2c_writel (i2c_dev, addr,I2C_SL_ADDR1 ); +i2c_writel (i2c_dev, addr2,I2C_SL_ADDR2 ); + +return 0 ; +} +static inline int tegra_i2c_clock_enable (struct tegra_i2c_dev *i2c_dev) {int ret;
@@ -461,12 +477,16 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)i2c_writel (i2c_dev, clk_divisor,I2C_CLK_DIVISOR );if (!i2c_dev->is_dvc) { -u32 sl_cfg =i2c_readl (i2c_dev,I2C_SL_CNFG ); - sl_cfg |=I2C_SL_CNFG_NACK |I2C_SL_CNFG_NEWSL ; -i2c_writel (i2c_dev, sl_cfg,I2C_SL_CNFG ); -i2c_writel (i2c_dev,0xfc ,I2C_SL_ADDR1 ); -i2c_writel (i2c_dev,0x00 ,I2C_SL_ADDR2 ); - +if (i2c_dev->slave) { +tegra_i2c_init_slave (i2c_dev, i2c_dev->slave->addr, + i2c_dev->slave->flags); + }else { +u32 sl_cfg =i2c_readl (i2c_dev,I2C_SL_CNFG ); + sl_cfg |=I2C_SL_CNFG_NACK |I2C_SL_CNFG_NEWSL ; +i2c_writel (i2c_dev, sl_cfg,I2C_SL_CNFG ); +i2c_writel (i2c_dev,0xfc ,I2C_SL_ADDR1 ); +i2c_writel (i2c_dev,0x00 ,I2C_SL_ADDR2 ); + } } val = 7 << I2C_FIFO_CONTROL_TX_TRIG_SHIFT |
@@ -767,7 +787,6 @@ static u32 tegra_i2c_func(struct i2c_adapter *adap)static int tegra_reg_slave (struct i2c_client *slave) {struct tegra_i2c_dev *i2c_dev =i2c_get_adapdata (slave->adapter); -int addr2 =0 ;if (i2c_dev->slave)return -EBUSY ;
@@ -776,14 +795,7 @@ static int tegra_reg_slave(struct i2c_client *slave)tegra_i2c_clock_enable (i2c_dev); -i2c_writel (i2c_dev,I2C_SL_CNFG_NEWSL ,I2C_SL_CNFG ); -i2c_writel (i2c_dev,I2C_SL_DELAY_COUNT_DEFAULT ,I2C_SL_DELAY_COUNT ); - -if (slave->flags &I2C_CLIENT_TEN ) - addr2 = (slave->addr >>7 ) |I2C_SL_ADDR2_TEN_BIT_MODE ; - -i2c_writel (i2c_dev, slave->addr,I2C_SL_ADDR1 ); -i2c_writel (i2c_dev, addr2,I2C_SL_ADDR2 ); +tegra_i2c_init_slave (i2c_dev, slave->addr, slave->flags);return 0 ; }
Signature · 1 line
1.7.1
Re: [PATCH v3 1/4] i2c: tegra: implement slave mode
Quoted 5 lines
Sorry for the long delay. I tried to analyze the issue. Attached patch works on AC100 (Misha Komarovsky helped me with testing).
Wolfram could you please try the patch with your environment?
No change, sadly. I don't get slave interrupts.
Quoted 3 lines
Init function is called multuple times. If I2C controller works in slave mode, then driver must keep slave registers otherwise slave configuration will be reseted.
This patch does not tackle the main issue, though. There should not be a "slave mode" for the controller. It can be a master and slave simultaneously and should do the right thing depending on what's happening on the bus. The Tegra2 manual I have says "The Master can address the internal slave (for basic testing) or an external 7-bit or 10-bit addressed Slave device." So even a loopback should be possible (if we trust the manual ;)).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150908/a63da796/attachment.sig>
Re: [PATCH v3 1/4] i2c: tegra: implement slave mode
Wolfram, thanks!
Quoted 7 lines · Wolfram Sang
Quoted 5 lines
Sorry for the long delay. I tried to analyze the issue. Attached patch works on AC100 (Misha Komarovsky helped me with testing).
Wolfram could you please try the patch with your environment?
No change, sadly. I don't get slave interrupts.
Slave ISR is called only if slave device is registered on a bus. Do you get master interrupts ?
Quoted 6 lines
Quoted 3 lines
Init function is called multuple times. If I2C controller works in slave mode, then driver must keep slave registers otherwise slave configuration will be reseted.
This patch does not tackle the main issue, though. There should not be a "slave mode" for the controller.
Looks like my commit message is not clear enough :(
Quoted 1 line
Quoted 1 line
If I2C controller works in slave mode, then ...
I mean something like this:
"If slave functionality is enabled, then ..."
Quoted 6 lines
It can be a master and slave
simultaneously and should do the right thing depending on what's happening on the bus. The Tegra2 manual I have says "The Master can address the internal slave (for basic testing) or an external 7-bit or 10-bit addressed Slave device." So even a loopback should be possible (if we trust the manual ;)).
Slave logic is not enabled by default (we don't set up proper configuration and slave address). We can enable it by default but it is useless without driver that will handle requests.
We used i2cdetect on the I2C bus where master NVEC controller is connected. i2cdetect found devices on the bus. Also keyboard and mouse was running fine after that (slave logic was not disabled).
PATCH v3 2/4 staging/nvec: reimplement on top of tegra i2c driver
In reply to Andrey DaninRemove i2c controller related code and use tegra i2c driver in slave mode. Update nvec documentation.
---
Changes for v3:
- resolve conflict: 'nvec != NULL' changed to '!nvec'
Changes for v2:
- remove extra new line
- keep old functions to simplify review
- move nvec_state enum to nvec.c
- use nvec-slave instead of nvec in dts to keep ABI compatibility
- rebased on top of new i2c slave framework
- delay workaround moved to tegra-i2c
- documentation patch is integrated in this commit
- reverted a log message to minimize changes
--- .../devicetree/bindings/nvec/nvidia,nvec.txt | 21 +- drivers/staging/nvec/nvec.c | 258 +++++++++++++-------- drivers/staging/nvec/nvec.h | 10 - 3 files changed, 169 insertions(+), 120 deletions(-)
Documentation/devicetree/bindings/nvec/nvidia,nvec.txt +3 -18
@@ -1,21 +1,6 @@ NVIDIA compliant embedded controller Required properties: -- compatible : should be "nvidia,nvec". -- reg : the iomem of the i2c slave controller -- interrupts : the interrupt line of the i2c slave controller -- clock-frequency : the frequency of the i2c bus -- gpios : the gpio used for ec request -- slave-addr: the i2c address of the slave controller -- clocks : Must contain an entry for each entry in clock-names. - See ../clocks/clock-bindings.txt for details. -- clock-names : Must include the following entries: - Tegra20/Tegra30: - - div-clk - - fast-clk - Tegra114: - - div-clk -- resets : Must contain an entry for each entry in reset-names. - See ../reset/reset.txt for details. -- reset-names : Must include the following entries: - - i2c +- compatible : should be "nvidia,nvec-slave". +- reg: the i2c address of the slave controller +- request-gpios : the gpio used for ec request
drivers/staging/nvec/nvec.c +166 -92
389 lines not on this page · raw message
drivers/staging/nvec/nvec.h +0 -10
@@ -107,11 +107,6 @@ struct nvec_msg {* struct nvec_chip - A single connection to an NVIDIA Embedded controller * @dev: The device * @gpio: The same as for &struct nvec_platform_data -* @irq: The IRQ of the I2C device -* @i2c_addr: The address of the I2C slave -* @base: The base of the memory mapped region of the I2C device -* @i2c_clk: The clock of the I2C device -* @rst: The reset of the I2C device * @notifier_list: Notifiers to be called on received messages, see * nvec_register_notifier() * @rx_data: Received messages that have to be processed
@@ -137,11 +132,6 @@ struct nvec_msg {struct nvec_chip {struct device *dev;int gpio; -int irq; -int i2c_addr; -void __iomem *base; -struct clk *i2c_clk; -struct reset_control *rst;struct atomic_notifier_head notifier_list;struct list_head rx_data, tx_data;struct notifier_block nvec_status_notifier;
Signature · 1 line
1.9.1
Re: [PATCH v3 2/4] staging/nvec: reimplement on top of tegra i2c driver
Documentation/devicetree/bindings/nvec/nvidia,nvec.txt
Quoted 4 lines · Andrey Danin
Remove i2c controller related code and use tegra i2c driver in slave mode. Update nvec documentation.
Documentation/devicetree/bindings/nvec/nvidia,nvec.txt +0
-0
I would expect this patch to add a new binding file nvidia,nvec-slave.txt so that the filename continues to match the compatible value it documents. This patch introduces a new binding for the NVEC slave as opposed to modifying the existing binding.
Quoted 2 lines
+- compatible : should be "nvidia,nvec-slave". +- reg: the i2c address of the slave controller
I think "the I2C address to respond to" would be clearer? You might also mention that this needs to include flags from <dt-bindings/i2c/ic2.h>.
PATCH v3 3/4 staging/nvec: remove old code
In reply to Andrey Danin---
No changes for v3
No changes for v2
--- drivers/staging/nvec/nvec.c | 211 -------------------------------------------- 1 file changed, 211 deletions(-)
drivers/staging/nvec/nvec.c +0 -211
@@ -516,23 +516,6 @@ static void nvec_rx_completed(struct nvec_chip *nvec)schedule_work (&nvec->rx_work); } -#if 0 -/** -* nvec_invalid_flags - Send an error message about invalid flags and jump -* @nvec: The nvec device -* @status: The status flags -* @reset: Whether we shall jump to state 0. -*/ -static void nvec_invalid_flags (struct nvec_chip *nvec,unsigned int status, -bool reset) -{ -dev_err (nvec->dev,"unexpected status flags 0x%02x during state %i\n" , - status, nvec->state); -if (reset) - nvec->state =0 ; -} -#endif /* FIXME: remove old code */ -/** * nvec_tx_set - Set the message to transfer (nvec->tx) * @nvec: A &struct nvec_chip
@@ -562,200 +545,6 @@ static void nvec_tx_set(struct nvec_chip *nvec) (uint)nvec->tx->size, nvec->tx->data[1]); } - -#if 0 -/** -* nvec_interrupt - Interrupt handler -* @irq: The IRQ -* @dev: The nvec device -* -* Interrupt handler that fills our RX buffers and empties our TX -* buffers. This uses a finite state machine with ridiculous amounts -* of error checking, in order to be fairly reliable. -*/ -static irqreturn_t nvec_interrupt (int irq,void *dev) -{ -unsigned long status; -unsigned int received =0 ; -unsigned char to_send =0xff ; -const unsigned long irq_mask =I2C_SL_IRQ |END_TRANS |RCVD |RNW ; -struct nvec_chip *nvec = dev; -unsigned int state = nvec->state; - - status =readl (nvec->base +I2C_SL_STATUS ); - -/* Filter out some errors */ -if ((status & irq_mask) ==0 && (status & ~irq_mask) !=0 ) { -dev_err (nvec->dev,"unexpected irq mask %lx\n" , status); -return IRQ_HANDLED ; - } -if ((status &I2C_SL_IRQ ) ==0 ) { -dev_err (nvec->dev,"Spurious IRQ\n" ); -return IRQ_HANDLED ; - } - -/* The EC did not request a read, so it send us something, read it */ -if ((status &RNW ) ==0 ) { - received =readl (nvec->base +I2C_SL_RCVD ); -if (status &RCVD ) -writel (0 , nvec->base +I2C_SL_RCVD ); - } - -if (status == (I2C_SL_IRQ |RCVD )) - nvec->state =0 ; - -switch (nvec->state) { -case 0 :/* Verify that its a transfer start, the rest later */ -if (status != (I2C_SL_IRQ |RCVD )) -nvec_invalid_flags (nvec, status, false); -break ; -case 1 :/* command byte */ -if (status !=I2C_SL_IRQ ) { -nvec_invalid_flags (nvec, status, true); - }else { - nvec->rx =nvec_msg_alloc (nvec,NVEC_MSG_RX ); -/* Should not happen in a normal world */ -if (unlikely (nvec->rx ==NULL )) { - nvec->state =0 ; -break ; - } - nvec->rx->data[0 ] = received; - nvec->rx->pos =1 ; - nvec->state =2 ; - } -break ; -case 2 :/* first byte after command */ -if (status == (I2C_SL_IRQ |RNW |RCVD )) { -udelay (33 ); -if (nvec->rx->data[0 ] !=0x01 ) { -dev_err (nvec->dev, -"Read without prior read command\n" ); - nvec->state =0 ; -break ; - } -nvec_msg_free (nvec, nvec->rx); - nvec->state =3 ; -nvec_tx_set (nvec); -BUG_ON (nvec->tx->size <1 ); - to_send = nvec->tx->data[0 ]; - nvec->tx->pos =1 ; - }else if (status == (I2C_SL_IRQ )) { -BUG_ON (nvec->rx ==NULL ); - nvec->rx->data[1 ] = received; - nvec->rx->pos =2 ; - nvec->state =4 ; - }else { -nvec_invalid_flags (nvec, status, true); - } -break ; -case 3 :/* EC does a block read, we transmit data */ -if (status &END_TRANS ) { -nvec_tx_completed (nvec); - }else if ((status &RNW ) ==0 || (status &RCVD )) { -nvec_invalid_flags (nvec, status, true); - }else if (nvec->tx && nvec->tx->pos < nvec->tx->size) { - to_send = nvec->tx->data[nvec->tx->pos++]; - }else { -dev_err (nvec->dev,"tx buffer underflow on %p (%u > %u)\n" , - nvec->tx, - (uint) (nvec->tx ? nvec->tx->pos :0 ), - (uint) (nvec->tx ? nvec->tx->size :0 )); - nvec->state =0 ; - } -break ; -case 4 :/* EC does some write, we read the data */ -if ((status & (END_TRANS |RNW )) ==END_TRANS ) -nvec_rx_completed (nvec); -else if (status & (RNW |RCVD )) -nvec_invalid_flags (nvec, status, true); -else if (nvec->rx && nvec->rx->pos <NVEC_MSG_SIZE ) - nvec->rx->data[nvec->rx->pos++] = received; -else -dev_err (nvec->dev, -"RX buffer overflow on %p: Trying to write byte %u of %u\n" , - nvec->rx, nvec->rx ? nvec->rx->pos :0 , -NVEC_MSG_SIZE ); -break ; -default : - nvec->state =0 ; - } - -/* If we are told that a new transfer starts, verify it */ -if ((status & (RCVD |RNW )) ==RCVD ) { -if (received != nvec->i2c_addr) -dev_err (nvec->dev, -"received address 0x%02x, expected 0x%02x\n" , - received, nvec->i2c_addr); - nvec->state =1 ; - } - -/* Send data if requested, but not on end of transmission */ -if ((status & (RNW |END_TRANS )) ==RNW ) -writel (to_send, nvec->base +I2C_SL_RCVD ); - -/* If we have send the first byte */ -if (status == (I2C_SL_IRQ |RNW |RCVD )) -nvec_gpio_set_value (nvec,1 ); - -dev_dbg (nvec->dev, -"Handled: %s 0x%02x, %s 0x%02x in state %u [%s%s%s]\n" , - (status &RNW ) ==0 ?"received" :"R=" , - received, - (status & (RNW |END_TRANS )) ?"sent" :"S=" , - to_send, - state, - status &END_TRANS ?" END_TRANS" :"" , - status &RCVD ?" RCVD" :"" , - status &RNW ?" RNW" :"" ); - - -/* -* TODO: A correct fix needs to be found for this. -* -* We experience less incomplete messages with this delay than without -* it, but we don't know why. Help is appreciated. -*/ -udelay (100 ); - -return IRQ_HANDLED ; -} - -static void tegra_init_i2c_slave (struct nvec_chip *nvec) -{ -u32 val; - -clk_prepare_enable (nvec->i2c_clk); - -reset_control_assert (nvec->rst); -udelay (2 ); -reset_control_deassert (nvec->rst); - - val =I2C_CNFG_NEW_MASTER_SFM |I2C_CNFG_PACKET_MODE_EN | - (0x2 <<I2C_CNFG_DEBOUNCE_CNT_SHIFT ); -writel (val, nvec->base +I2C_CNFG ); - -clk_set_rate (nvec->i2c_clk,8 *80000 ); - -writel (I2C_SL_NEWSL , nvec->base +I2C_SL_CNFG ); -writel (0x1E , nvec->base +I2C_SL_DELAY_COUNT ); - -writel (nvec->i2c_addr>>1 , nvec->base +I2C_SL_ADDR1 ); -writel (0 , nvec->base +I2C_SL_ADDR2 ); - -enable_irq (nvec->irq); -} - -#ifdef CONFIG_PM_SLEEP -static void nvec_disable_i2c_slave (struct nvec_chip *nvec) -{ -disable_irq (nvec->irq); -writel (I2C_SL_NEWSL |I2C_SL_NACK , nvec->base +I2C_SL_CNFG ); -clk_disable_unprepare (nvec->i2c_clk); -} -#endif -#endif /* FIXME: remove old code. */ - -/** * nvec_slave_cb - I2C slave callback *
Signature · 1 line
1.9.1
PATCH v3 4/4 dt: paz00: define nvec as child of i2c bus
In reply to Andrey DaninNVEC driver was reimplemented to use tegra i2c. Use common i2c bindings for NVEC node.
---
No changes for v3:
Changes for v2:
- swap reg and request-gpios properties
- use nvec-slave instead of nvec to keep ABI compatibility
- place doc in separate patch
--- arch/arm/boot/dts/tegra20-paz00.dts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
arch/arm/boot/dts/tegra20-paz00.dts +9 -13
@@ -288,20 +288,16 @@ clock-frequency = <100000>; }; - nvec at 7000c500 { - compatible = "nvidia,nvec"; - reg = <0x7000c500 0x100>; - interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>; - #address-cells = <1>; - #size-cells = <0>; + i2c at 7000c500 { + status = "okay"; clock-frequency = <80000>; - request-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_HIGH>; - slave-addr = <138>; - clocks = <&tegra_car TEGRA20_CLK_I2C3>, - <&tegra_car TEGRA20_CLK_PLL_P_OUT3>; - clock-names = "div-clk", "fast-clk"; - resets = <&tegra_car 67>; - reset-names = "i2c"; + + nvec: nvec at 45 { + compatible = "nvidia,nvec-slave"; + reg = <0x45>; + request-gpios = <&gpio TEGRA_GPIO(V, 2) + GPIO_ACTIVE_HIGH>; + }; }; i2c at 7000d000 {
Signature · 1 line
1.9.1
Re: [PATCH v3 4/4] dt: paz00: define nvec as child of i2c bus
arch/arm/boot/dts/tegra20-paz00.dts line 297
Quoted 8 lines · Andrey Danin
NVEC driver was reimplemented to use tegra i2c. Use common i2c bindings for NVEC node.
arch/arm/boot/dts/tegra20-paz00.dts +3
-0+ nvec: nvec@45 { + compatible = "nvidia,nvec-slave"; + reg = <0x45>;
I think you need to or in I2C_OWN_SLAVE_ADDRESS from <dt-bindings/i2c/i2c.h> here?
Re: [PATCH v3 4/4] dt: paz00: define nvec as child of i2c bus
Quoted 7 lines · Stephen Warren
Quoted 5 lines · Andrey Danin
NVEC driver was reimplemented to use tegra i2c. Use common i2c bindings for NVEC node.
arch/arm/boot/dts/tegra20-paz00.dts +0
-0
Quoted 6 lines
arch/arm/boot/dts/tegra20-paz00.dts line 297
Quoted 3 lines
arch/arm/boot/dts/tegra20-paz00.dts +3
-0+ nvec: nvec at 45 { + compatible = "nvidia,nvec-slave"; + reg = <0x45>;I think you need to or in
I2C_OWN_SLAVE_ADDRESSfrom <dt-bindings/i2c/i2c.h> here?
Sorry, I mentioned it in letter 0 only.
I will rework nvec driver and device tree according to i2c core slave implementation later. v3 of this patchset is for fixing tegra i2c driver only.
Marc Dietrich
maintainerRe: [PATCH v3 4/4] dt: paz00: define nvec as child of i2c bus
Am Dienstag, 21. Juli 2015, 09:35:21 schrieb Andrey Danin:
Quoted 15 lines · Stephen Warren
Quoted 7 lines · Andrey Danin
Quoted 6 lines
NVEC driver was reimplemented to use tegra i2c. Use common i2c bindings for NVEC node.
arch/arm/boot/dts/tegra20-paz00.dts +0
-0Quoted 6 lines
arch/arm/boot/dts/tegra20-paz00.dts line 297
Quoted 3 lines
arch/arm/boot/dts/tegra20-paz00.dts +3
-0+ nvec: nvec at 45 { + compatible = "nvidia,nvec-slave"; + reg = <0x45>;I think you need to or in
I2C_OWN_SLAVE_ADDRESSfrom <dt-bindings/i2c/i2c.h> here?
Quoted 4 lines
Sorry, I mentioned it in letter 0 only.
I will rework nvec driver and device tree according to i2c core slave implementation later. v3 of this patchset is for fixing tegra i2c driver only.
I think in this case it would be better to leave nvec and dt as it is for now, and just add the slave function to tegra-i2c. Otherwise we will again have two different "nvidia,nvec-slave" bindings (one for the intermediate hack and one for the final representation). As an alternative, you could also add slave function and port nvec in the same series.
Marc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150721/75633402/attachment.sig>
Re: [PATCH v3 4/4] dt: paz00: define nvec as child of i2c bus
Quoted 6 lines · Marc Dietrich
I think in this case it would be better to leave nvec and dt as it is for now, and just add the slave function to tegra-i2c. Otherwise we will again have two different "nvidia,nvec-slave" bindings (one for the intermediate hack and one for the final representation). As an alternative, you could also add slave function and port nvec in the same series.
First patch only adds slave functionality to tegra-i2c driver. I sent v3 to fix only tegra-i2c as Wolfram suggested.
Unfortunately I haven't fixed all defects and I will resend patch(es). I can resend only first patch (for tegra-i2c) if it is more obvious for everyone.
Marc Dietrich
maintainerRe: [PATCH v3 4/4] dt: paz00: define nvec as child of i2c bus
Am Dienstag, 21. Juli 2015, 11:51:15 schrieb Andrey Danin:
Quoted 8 lines · Marc Dietrich
Quoted 6 lines
I think in this case it would be better to leave nvec and dt as it is for now, and just add the slave function to tegra-i2c. Otherwise we will again have two different "nvidia,nvec-slave" bindings (one for the intermediate hack and one for the final representation). As an alternative, you could also add slave function and port nvec in the same series.
Quoted 6 lines
First patch only adds slave functionality to tegra-i2c driver. I sent v3 to fix only tegra-i2c as Wolfram suggested.
Unfortunately I haven't fixed all defects and I will resend patch(es). I can resend only first patch (for tegra-i2c) if it is more obvious for everyone.
It's up to you. I think if the NV guys are ok with the tegra i2c change, Wolfram can merge it right away for 4.3. Not sure about the state of the nvec changes though and if they can be ready soon.
Marc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150721/2c59c159/attachment.sig>
Re: [PATCH v3 4/4] dt: paz00: define nvec as child of i2c bus
Quoted 3 lines
It's up to you. I think if the NV guys are ok with the tegra i2c change, Wolfram can merge it right away for 4.3.
I asked him to resend, because I *want* to merge it for 4.3 :) Only the slave-mode enablement for i2c, of course. The other patches need to go via some other tree (when they are done).
So, V4 with only this one patch is a good idea in my book.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150721/0f1617cc/attachment.sig>
Quoted 8 lines · Andrey Danin
This version (v3) is for pushing tegra i2c driver to i2c tree. NVEC driver will be reworked later to use i2c core slave framework.
NVEC driver contains code to manage tegra i2c controller in slave mode. I2C slave support was implemented in linux kernel. The goal of this patch serie is to implement I2C slave mode in tegra drived and rework NVEC driver to use it.
Quoted 6 lines
Patches are based on i2c for-next.
Changes for v3:
- rebase on top of i2c for-next tree
- fix 10-bit address condition in tegra i2c driver
Sorry, I didn't fix all comments in tegra i2c driver. I will send v4 soon.