← Back to team overview

ac100 team mailing list archive

[PATCH] staging: nvec: rework the nvec slave init

 

Rework the tegra slave controller init to look more like in
tegra-i2c.c. This makes the nvec init reliable. Also add de-init of
the slave to be used during suspend.

Signed-off-by: Marc Dietrich <marvin24@xxxxxx>
---
 drivers/staging/nvec/nvec.c     |   27 ++++++++++++++++++++-------
 drivers/staging/nvec/nvec_ps2.c |    3 ++-
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index d5b9854..b4b7406 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -293,18 +293,30 @@ static void tegra_init_i2c_slave(struct nvec_chip *nvec)
 	udelay(2);
 	tegra_periph_reset_deassert(nvec->i2c_clk);
 
-	writel(nvec->i2c_addr >> 1, nvec->base + I2C_SL_ADDR1);
-	writel(0, nvec->base + I2C_SL_ADDR2);
-
-	writel(0x1E, nvec->base + I2C_SL_DELAY_COUNT);
 	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_NEWL, 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);
 
 	clk_disable(nvec->i2c_clk);
 }
 
+static void nvec_disable_i2c_slave(struct nvec_chip *nvec)
+{
+	disable_irq(nvec->irq);
+	writel(I2C_SL_NEWL | I2C_SL_NACK, nvec->base + I2C_SL_CNFG);
+	clk_disable(nvec->i2c_clk);
+}
+
 static void nvec_power_off(void)
 {
 	nvec_write_async(nvec_power_handle, EC_DISABLE_EVENT_REPORTING, 3);
@@ -363,9 +375,6 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev)
 		goto err_iounmap;
 	}
 
-	clk_enable(i2c_clk);
-	clk_set_rate(i2c_clk, 8 * 80000);
-
 	nvec->base = base;
 	nvec->irq = res->start;
 	nvec->i2c_clk = i2c_clk;
@@ -389,9 +398,12 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev)
 		dev_err(nvec->dev, "couldn't request irq");
 		goto failed;
 	}
+	disable_irq(nvec->irq);
 
 	tegra_init_i2c_slave(nvec);
 
+	clk_enable(i2c_clk);
+
 	gpio_direction_output(nvec->gpio, 1);
 	gpio_set_value(nvec->gpio, 1);
 
@@ -461,6 +473,7 @@ static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state)
 	dev_dbg(nvec->dev, "suspending\n");
 	nvec_write_async(nvec, EC_DISABLE_EVENT_REPORTING, 3);
 	nvec_write_async(nvec, "\x04\x02", 2);
+	nvec_disable_i2c_slave(nvec);
 
 	return 0;
 }
diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
index e5a0388..1f865e6 100644
--- a/drivers/staging/nvec/nvec_ps2.c
+++ b/drivers/staging/nvec/nvec_ps2.c
@@ -23,7 +23,8 @@
 #define START_STREAMING	{'\x06','\x03','\x01'}
 #define STOP_STREAMING	{'\x06','\x04'}
 #define SEND_COMMAND	{'\x06','\x01','\xf4','\x01'}
-#define MOUSE_RESET	{'\x06','\x01','\xff','\x03'}
+
+static unsigned char MOUSE_RESET[] = { '\x06', '\x01', '\xff', '\x03' };
 
 struct nvec_ps2 {
 	struct serio *ser_dev;
-- 
1.7.4.1



References