[PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Richard Zhao
device_prep_dma_cyclic may be call in audio trigger function which is
atomic context, so we make it atomic too.

 - change channel0 lock to spinlock.
 - Use polling to wait for channel0 finish running.

Signed-off-by: Lothar Waßmann l...@karo-electronics.de
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 drivers/dma/imx-sdma.c |   57 +++
 1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index fddccae..fc49ffa 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -24,7 +24,7 @@
 #include linux/mm.h
 #include linux/interrupt.h
 #include linux/clk.h
-#include linux/wait.h
+#include linux/delay.h
 #include linux/sched.h
 #include linux/semaphore.h
 #include linux/spinlock.h
@@ -324,7 +324,7 @@ struct sdma_engine {
struct dma_device   dma_device;
struct clk  *clk_ipg;
struct clk  *clk_ahb;
-   struct mutexchannel_0_lock;
+   spinlock_t  channel_0_lock;
struct sdma_script_start_addrs  *script_addrs;
 };
 
@@ -402,19 +402,31 @@ static void sdma_enable_channel(struct sdma_engine *sdma, 
int channel)
 }
 
 /*
- * sdma_run_channel - run a channel and wait till it's done
+ * sdma_run_channel0 - run a channel and wait till it's done
  */
-static int sdma_run_channel(struct sdma_channel *sdmac)
+static int sdma_run_channel0(struct sdma_channel *sdmac)
 {
struct sdma_engine *sdma = sdmac-sdma;
int channel = sdmac-channel;
int ret;
+   unsigned long timeout = 500;
 
-   init_completion(sdmac-done);
-
+   if (channel)
+   return -EINVAL;
sdma_enable_channel(sdma, channel);
 
-   ret = wait_for_completion_timeout(sdmac-done, HZ);
+   while (!(ret = readl_relaxed(sdma-regs + SDMA_H_INTR)  1)) {
+   if (timeout-- = 0)
+   break;
+   udelay(1);
+   }
+
+   if (ret) {
+   /* Clear the interrupt status */
+   writel_relaxed(ret, sdma-regs + SDMA_H_INTR);
+   } else {
+   dev_err(sdma-dev, Timeout waiting for CH0 ready\n);
+   }
 
return ret ? 0 : -ETIMEDOUT;
 }
@@ -426,17 +438,17 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
void *buf_virt;
dma_addr_t buf_phys;
int ret;
-
-   mutex_lock(sdma-channel_0_lock);
+   unsigned long flags;
 
buf_virt = dma_alloc_coherent(NULL,
size,
buf_phys, GFP_KERNEL);
if (!buf_virt) {
-   ret = -ENOMEM;
-   goto err_out;
+   return -ENOMEM;
}
 
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
+
bd0-mode.command = C0_SETPM;
bd0-mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD;
bd0-mode.count = size / 2;
@@ -445,12 +457,11 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
 
memcpy(buf_virt, buf, size);
 
-   ret = sdma_run_channel(sdma-channel[0]);
+   ret = sdma_run_channel0(sdma-channel[0]);
 
-   dma_free_coherent(NULL, size, buf_virt, buf_phys);
+   spin_unlock_irqrestore(sdma-channel_0_lock, flags);
 
-err_out:
-   mutex_unlock(sdma-channel_0_lock);
+   dma_free_coherent(NULL, size, buf_virt, buf_phys);
 
return ret;
 }
@@ -539,10 +550,6 @@ static void mxc_sdma_handle_channel(struct sdma_channel 
*sdmac)
 {
complete(sdmac-done);
 
-   /* not interested in channel 0 interrupts */
-   if (sdmac-channel == 0)
-   return;
-
if (sdmac-flags  IMX_DMA_SG_LOOP)
sdma_handle_channel_loop(sdmac);
else
@@ -555,6 +562,8 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
unsigned long stat;
 
stat = readl_relaxed(sdma-regs + SDMA_H_INTR);
+   /* not interested in channel 0 interrupts */
+   stat = ~1;
writel_relaxed(stat, sdma-regs + SDMA_H_INTR);
 
while (stat) {
@@ -660,6 +669,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
struct sdma_context_data *context = sdma-context;
struct sdma_buffer_descriptor *bd0 = sdma-channel[0].bd;
int ret;
+   unsigned long flags;
 
if (sdmac-direction == DMA_DEV_TO_MEM) {
load_address = sdmac-pc_from_device;
@@ -677,7 +687,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
dev_dbg(sdma-dev, event_mask0 = 0x%08x\n, (u32)sdmac-event_mask[0]);
dev_dbg(sdma-dev, event_mask1 = 0x%08x\n, (u32)sdmac-event_mask[1]);
 
-   mutex_lock(sdma-channel_0_lock);
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
 
memset(context, 0, sizeof(*context));
context-channel_state.pc = load_address;
@@ -696,10 +706,9 @@ static int sdma_load_context(struct sdma_channel *sdmac)

[PATCH 02/11] ASoC: imx-sgtl5000: add of_node_put when probe fail.

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 sound/soc/fsl/imx-sgtl5000.c |   29 ++---
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index e1a7441..73b935e 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -103,24 +103,28 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
codec_np = of_parse_phandle(pdev-dev.of_node, audio-codec, 0);
if (!ssi_np || !codec_np) {
dev_err(pdev-dev, phandle missing or invalid\n);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto fail;
}
 
ssi_pdev = of_find_device_by_node(ssi_np);
if (!ssi_pdev) {
dev_err(pdev-dev, failed to find SSI platform device\n);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto fail;
}
 
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
+   if (!data) {
+   ret = -ENOMEM;
+   goto fail;
+   }
 
ret = of_property_read_u32(codec_np, clock-frequency,
   data-clk_frequency);
if (ret) {
dev_err(pdev-dev, clock-frequency missing or invalid\n);
-   return ret;
+   goto fail;
}
 
data-dai.name = HiFi;
@@ -136,10 +140,10 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
data-card.dev = pdev-dev;
ret = snd_soc_of_parse_card_name(data-card, model);
if (ret)
-   return ret;
+   goto fail;
ret = snd_soc_of_parse_audio_routing(data-card, audio-routing);
if (ret)
-   return ret;
+   goto fail;
data-card.num_links = 1;
data-card.dai_link = data-dai;
data-card.dapm_widgets = imx_sgtl5000_dapm_widgets;
@@ -148,14 +152,17 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = snd_soc_register_card(data-card);
if (ret) {
dev_err(pdev-dev, snd_soc_register_card failed (%d)\n, ret);
-   return ret;
+   goto fail;
}
 
platform_set_drvdata(pdev, data);
-   of_node_put(ssi_np);
-   of_node_put(codec_np);
+fail:
+   if (ssi_np)
+   of_node_put(ssi_np);
+   if (codec_np)
+   of_node_put(codec_np);
 
-   return 0;
+   return ret;
 }
 
 static int __devexit imx_sgtl5000_remove(struct platform_device *pdev)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/11] enable imx6q_sabrelite sgtl5000 audio support

2012-04-27 Thread Richard Zhao
It's based on Dong Aisheng's early pinctrl patch and Sascha's v2
convert to common clk patch.

You can also get at:
https://github.com/riczhao/kernel-imx/tree/topics/audio

Richard Zhao (11):
  dma: imx-sdma: make channel0 operations atomic
  ASoC: imx-sgtl5000: add of_node_put when probe fail.
  ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000
  i2c: imx: add pinctrl support
  ARM: imx6q: move imx6q_sabrelite specific code to a dedicated
function
  ARM: dts: imx6q-sabrelite: add ssi device
  ARM: dts: imx6q-sabrelite: add audmux device
  ASoC: imx-audmux: add pinctrl support
  ARM: imx6q: add ssi1 clk_lookup
  ARM: imx6q_sabrelite: clkdev_add cko1 for sgtl5000
  ARM: dts: imx6q-sabrelite: add sound device imx6q-sabrelite-sgtl5000

 arch/arm/boot/dts/imx6q-sabrelite.dts |   30 
 arch/arm/boot/dts/imx6q.dtsi  |   46 +++--
 arch/arm/mach-imx/clk-imx6q.c |4 ++
 arch/arm/mach-imx/mach-imx6q.c|   37 +++-
 drivers/dma/imx-sdma.c|   57 ++-
 drivers/i2c/busses/i2c-imx.c  |9 +
 sound/soc/fsl/imx-audmux.c|8 
 sound/soc/fsl/imx-sgtl5000.c  |   61 +
 8 files changed, 208 insertions(+), 44 deletions(-)

Thanks
Richard
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/11] ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

It tries to clk_get the clock. And if it failed, it assumes the clock
by default enabled.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 sound/soc/fsl/imx-sgtl5000.c |   40 
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index 73b935e..3a729ca 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -13,6 +13,8 @@
 #include linux/module.h
 #include linux/of.h
 #include linux/of_platform.h
+#include linux/of_i2c.h
+#include linux/clk.h
 #include sound/soc.h
 
 #include ../codecs/sgtl5000.h
@@ -25,6 +27,7 @@ struct imx_sgtl5000_data {
struct snd_soc_card card;
char codec_dai_name[DAI_NAME_SIZE];
char platform_name[DAI_NAME_SIZE];
+   struct clk *codec_clk;
unsigned int clk_frequency;
 };
 
@@ -58,6 +61,7 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
struct device_node *np = pdev-dev.of_node;
struct device_node *ssi_np, *codec_np;
struct platform_device *ssi_pdev;
+   struct i2c_client *codec_dev;
struct imx_sgtl5000_data *data;
int int_port, ext_port;
int ret;
@@ -113,6 +117,11 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = -EINVAL;
goto fail;
}
+   codec_dev = of_find_i2c_device_by_node(codec_np);
+   if (!codec_dev) {
+   dev_err(pdev-dev, failed to find codec platform device\n);
+   return -EINVAL;
+   }
 
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
if (!data) {
@@ -120,11 +129,20 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
goto fail;
}
 
-   ret = of_property_read_u32(codec_np, clock-frequency,
-  data-clk_frequency);
-   if (ret) {
-   dev_err(pdev-dev, clock-frequency missing or invalid\n);
-   goto fail;
+   data-codec_clk = clk_get(codec_dev-dev, NULL);
+   if (IS_ERR(data-codec_clk)) {
+   /* assuming clock enabled by default */
+   data-codec_clk = NULL;
+   ret = of_property_read_u32(codec_np, clock-frequency,
+   data-clk_frequency);
+   if (ret) {
+   dev_err(codec_dev-dev,
+   clock-frequency missing or invalid\n);
+   goto fail;
+   }
+   } else {
+   data-clk_frequency = clk_get_rate(data-codec_clk);
+   clk_prepare_enable(data-codec_clk);
}
 
data-dai.name = HiFi;
@@ -140,10 +158,10 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
data-card.dev = pdev-dev;
ret = snd_soc_of_parse_card_name(data-card, model);
if (ret)
-   goto fail;
+   goto clk_fail;
ret = snd_soc_of_parse_audio_routing(data-card, audio-routing);
if (ret)
-   goto fail;
+   goto clk_fail;
data-card.num_links = 1;
data-card.dai_link = data-dai;
data-card.dapm_widgets = imx_sgtl5000_dapm_widgets;
@@ -152,10 +170,12 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = snd_soc_register_card(data-card);
if (ret) {
dev_err(pdev-dev, snd_soc_register_card failed (%d)\n, ret);
-   goto fail;
+   goto clk_fail;
}
 
platform_set_drvdata(pdev, data);
+clk_fail:
+   clk_put(data-codec_clk);
 fail:
if (ssi_np)
of_node_put(ssi_np);
@@ -169,6 +189,10 @@ static int __devexit imx_sgtl5000_remove(struct 
platform_device *pdev)
 {
struct imx_sgtl5000_data *data = platform_get_drvdata(pdev);
 
+   if (data-codec_clk) {
+   clk_disable_unprepare(data-codec_clk);
+   clk_put(data-codec_clk);
+   }
snd_soc_unregister_card(data-card);
 
return 0;
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/11] i2c: imx: add pinctrl support

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |2 ++
 arch/arm/boot/dts/imx6q.dtsi  |   16 
 drivers/i2c/busses/i2c-imx.c  |9 +
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 4663a4e..4e13293 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -50,6 +50,8 @@
i2c@021a { /* I2C1 */
status = okay;
clock-frequency = 10;
+   pinctrl-names = default;
+   pinctrl-0 = pinctrl_i2c1_1;
 
codec: sgtl5000@0a {
compatible = fsl,sgtl5000;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 2ba32e7..fe8c80d 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -390,6 +390,22 @@
reg = 0x020e 0x4000;
 
/* shared pinctrl settings */
+   i2c1 {
+   pinctrl_i2c1_1: i2c1grp-1 {
+   fsl,pins =  
MX6Q_PAD_EIM_D21,
+   
MX6Q_PAD_EIM_D28;
+   fsl,hysteresis = 1;
+   fsl,mux = 0x16 0x11;
+   fsl,pull = 2;
+   fsl,pue = 1;
+   fsl,pke = 1;
+   fsl,open-drain = 1;
+   fsl,speed = 2;
+   fsl,drive-strength = 6;
+   fsl,slew-rate = 1;
+   };
+   };
+
uart4 {
pinctrl_uart4_1: uart4grp-1 {
fsl,pins =  
MX6Q_PAD_KEY_COL0,
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index dfb84b7..7a52067 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -48,6 +48,7 @@
 #include linux/platform_device.h
 #include linux/clk.h
 #include linux/slab.h
+#include linux/pinctrl/consumer.h
 #include linux/of.h
 #include linux/of_device.h
 #include linux/of_i2c.h
@@ -470,6 +471,7 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
struct imx_i2c_struct *i2c_imx;
struct resource *res;
struct imxi2c_platform_data *pdata = pdev-dev.platform_data;
+   struct pinctrl *pct;
void __iomem *base;
resource_size_t res_size;
int irq, bitrate;
@@ -520,6 +522,13 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
i2c_imx-base   = base;
i2c_imx-res= res;
 
+   pct = devm_pinctrl_get_select_default(pdev-dev);
+   if (IS_ERR(pct)) {
+   dev_err(pdev-dev, can't get/select pinctrl\n);
+   ret = PTR_ERR(pct);
+   goto fail3;
+   }
+
/* Get I2C clock */
i2c_imx-clk = clk_get(pdev-dev, i2c_clk);
if (IS_ERR(i2c_imx-clk)) {
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/11] ARM: dts: imx6q-sabrelite: add ssi device

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |9 +
 arch/arm/boot/dts/imx6q.dtsi  |   18 +++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 4e13293..7bd8855 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -22,6 +22,15 @@
};
 
soc {
+   aips-bus@0200 { /* AIPS1 */
+   spba-bus@0200 {
+   ssi1: ssi@02028000 {
+   fsl,mode = i2s-slave;
+   status = okay;
+   };
+   };
+   };
+
aips-bus@0210 { /* AIPS2 */
enet@02188000 {
phy-mode = rgmii;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index fe8c80d..da42fc0 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -177,19 +177,31 @@
interrupts = 0 51 0x04;
};
 
-   ssi@02028000 { /* SSI1 */
+   ssi1: ssi@02028000 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x02028000 0x4000;
interrupts = 0 46 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 38 37;
+   status = disabled;
};
 
-   ssi@0202c000 { /* SSI2 */
+   ssi2: ssi@0202c000 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x0202c000 0x4000;
interrupts = 0 47 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 42 41;
+   status = disabled;
};
 
-   ssi@0203 { /* SSI3 */
+   ssi3: ssi@0203 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x0203 0x4000;
interrupts = 0 48 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 46 45;
+   status = disabled;
};
 
asrc@02034000 {
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/11] ARM: dts: imx6q-sabrelite: add audmux device

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |3 +++
 arch/arm/boot/dts/imx6q.dtsi  |2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 7bd8855..02f93bc 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -52,6 +52,9 @@
status = okay;
};
 
+   audmux@021d8000 {
+   status = okay;
+   };
uart2: uart@021e8000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index da42fc0..7bf402e 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -596,7 +596,9 @@
};
 
audmux@021d8000 {
+   compatible = fsl,imx6q-audmux, 
fsl,imx31-audmux;
reg = 0x021d8000 0x4000;
+   status = disabled;
};
 
mipi@021dc000 { /* MIPI-CSI */
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/11] ARM: imx6q: add ssi1 clk_lookup

2012-04-27 Thread Richard Zhao
It's used by audio drivers.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index f40a35d..9a03dcc 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -418,6 +418,7 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[sdma], NULL, 20ec000.sdma);
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
+   clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
 
for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
c = clk_get_sys(clks_init_on[i], NULL);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/11] ARM: imx6q_sabrelite: clkdev_add cko1 for sgtl5000

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c  |3 +++
 arch/arm/mach-imx/mach-imx6q.c |   28 
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 9a03dcc..4ea0de0 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -419,6 +419,9 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
+   clk_register_clkdev(clk[cko1_sel], cko1_sel, NULL);
+   clk_register_clkdev(clk[ahb], ahb, NULL);
+   clk_register_clkdev(clk[cko1], cko1, NULL);
 
for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
c = clk_get_sys(clks_init_on[i], NULL);
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index d25c5d8..e9b2522 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -10,6 +10,8 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+#include linux/clkdev.h
+#include linux/clk.h
 #include linux/delay.h
 #include linux/init.h
 #include linux/io.h
@@ -75,10 +77,36 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
return 0;
 }
 
+static void __init imx6q_cko1_setup(void)
+{
+   struct clk *cko1_sel, *ahb, *cko1;
+   unsigned long rate;
+
+   cko1_sel = clk_get_sys(NULL, cko1_sel);
+   ahb = clk_get_sys(NULL, ahb);
+   cko1 = clk_get_sys(NULL, cko1);
+   if (IS_ERR(cko1_sel) || IS_ERR(ahb) || IS_ERR(cko1)) {
+   printk(KERN_ERR cko1 setup failed!\n);
+   goto put_clk;
+   }
+   clk_set_parent(cko1_sel, ahb);
+   rate = clk_round_rate(cko1, 1600);
+   clk_set_rate(cko1, rate);
+   clk_register_clkdev(cko1, NULL, 0-000a);
+put_clk:
+   if (!IS_ERR(cko1_sel))
+   clk_put(cko1_sel);
+   if (!IS_ERR(ahb))
+   clk_put(ahb);
+   if (!IS_ERR(cko1))
+   clk_put(cko1);
+}
+
 static void __init imx6q_sabrelite_init(void)
 {
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
ksz9021rn_phy_fixup);
+   imx6q_cko1_setup();
 }
 
 static void __init imx6q_init_machine(void)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Richard Zhao
device_prep_dma_cyclic may be call in audio trigger function which is
atomic context, so we make it atomic too.

 - change channel0 lock to spinlock.
 - Use polling to wait for channel0 finish running.

Signed-off-by: Lothar Waßmann l...@karo-electronics.de
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 drivers/dma/imx-sdma.c |   57 +++
 1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index fddccae..fc49ffa 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -24,7 +24,7 @@
 #include linux/mm.h
 #include linux/interrupt.h
 #include linux/clk.h
-#include linux/wait.h
+#include linux/delay.h
 #include linux/sched.h
 #include linux/semaphore.h
 #include linux/spinlock.h
@@ -324,7 +324,7 @@ struct sdma_engine {
struct dma_device   dma_device;
struct clk  *clk_ipg;
struct clk  *clk_ahb;
-   struct mutexchannel_0_lock;
+   spinlock_t  channel_0_lock;
struct sdma_script_start_addrs  *script_addrs;
 };
 
@@ -402,19 +402,31 @@ static void sdma_enable_channel(struct sdma_engine *sdma, 
int channel)
 }
 
 /*
- * sdma_run_channel - run a channel and wait till it's done
+ * sdma_run_channel0 - run a channel and wait till it's done
  */
-static int sdma_run_channel(struct sdma_channel *sdmac)
+static int sdma_run_channel0(struct sdma_channel *sdmac)
 {
struct sdma_engine *sdma = sdmac-sdma;
int channel = sdmac-channel;
int ret;
+   unsigned long timeout = 500;
 
-   init_completion(sdmac-done);
-
+   if (channel)
+   return -EINVAL;
sdma_enable_channel(sdma, channel);
 
-   ret = wait_for_completion_timeout(sdmac-done, HZ);
+   while (!(ret = readl_relaxed(sdma-regs + SDMA_H_INTR)  1)) {
+   if (timeout-- = 0)
+   break;
+   udelay(1);
+   }
+
+   if (ret) {
+   /* Clear the interrupt status */
+   writel_relaxed(ret, sdma-regs + SDMA_H_INTR);
+   } else {
+   dev_err(sdma-dev, Timeout waiting for CH0 ready\n);
+   }
 
return ret ? 0 : -ETIMEDOUT;
 }
@@ -426,17 +438,17 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
void *buf_virt;
dma_addr_t buf_phys;
int ret;
-
-   mutex_lock(sdma-channel_0_lock);
+   unsigned long flags;
 
buf_virt = dma_alloc_coherent(NULL,
size,
buf_phys, GFP_KERNEL);
if (!buf_virt) {
-   ret = -ENOMEM;
-   goto err_out;
+   return -ENOMEM;
}
 
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
+
bd0-mode.command = C0_SETPM;
bd0-mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD;
bd0-mode.count = size / 2;
@@ -445,12 +457,11 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
 
memcpy(buf_virt, buf, size);
 
-   ret = sdma_run_channel(sdma-channel[0]);
+   ret = sdma_run_channel0(sdma-channel[0]);
 
-   dma_free_coherent(NULL, size, buf_virt, buf_phys);
+   spin_unlock_irqrestore(sdma-channel_0_lock, flags);
 
-err_out:
-   mutex_unlock(sdma-channel_0_lock);
+   dma_free_coherent(NULL, size, buf_virt, buf_phys);
 
return ret;
 }
@@ -539,10 +550,6 @@ static void mxc_sdma_handle_channel(struct sdma_channel 
*sdmac)
 {
complete(sdmac-done);
 
-   /* not interested in channel 0 interrupts */
-   if (sdmac-channel == 0)
-   return;
-
if (sdmac-flags  IMX_DMA_SG_LOOP)
sdma_handle_channel_loop(sdmac);
else
@@ -555,6 +562,8 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
unsigned long stat;
 
stat = readl_relaxed(sdma-regs + SDMA_H_INTR);
+   /* not interested in channel 0 interrupts */
+   stat = ~1;
writel_relaxed(stat, sdma-regs + SDMA_H_INTR);
 
while (stat) {
@@ -660,6 +669,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
struct sdma_context_data *context = sdma-context;
struct sdma_buffer_descriptor *bd0 = sdma-channel[0].bd;
int ret;
+   unsigned long flags;
 
if (sdmac-direction == DMA_DEV_TO_MEM) {
load_address = sdmac-pc_from_device;
@@ -677,7 +687,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
dev_dbg(sdma-dev, event_mask0 = 0x%08x\n, (u32)sdmac-event_mask[0]);
dev_dbg(sdma-dev, event_mask1 = 0x%08x\n, (u32)sdmac-event_mask[1]);
 
-   mutex_lock(sdma-channel_0_lock);
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
 
memset(context, 0, sizeof(*context));
context-channel_state.pc = load_address;
@@ -696,10 +706,9 @@ static int sdma_load_context(struct sdma_channel *sdmac)

[PATCH 02/11] ASoC: imx-sgtl5000: add of_node_put when probe fail.

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 sound/soc/fsl/imx-sgtl5000.c |   29 ++---
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index e1a7441..73b935e 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -103,24 +103,28 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
codec_np = of_parse_phandle(pdev-dev.of_node, audio-codec, 0);
if (!ssi_np || !codec_np) {
dev_err(pdev-dev, phandle missing or invalid\n);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto fail;
}
 
ssi_pdev = of_find_device_by_node(ssi_np);
if (!ssi_pdev) {
dev_err(pdev-dev, failed to find SSI platform device\n);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto fail;
}
 
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
+   if (!data) {
+   ret = -ENOMEM;
+   goto fail;
+   }
 
ret = of_property_read_u32(codec_np, clock-frequency,
   data-clk_frequency);
if (ret) {
dev_err(pdev-dev, clock-frequency missing or invalid\n);
-   return ret;
+   goto fail;
}
 
data-dai.name = HiFi;
@@ -136,10 +140,10 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
data-card.dev = pdev-dev;
ret = snd_soc_of_parse_card_name(data-card, model);
if (ret)
-   return ret;
+   goto fail;
ret = snd_soc_of_parse_audio_routing(data-card, audio-routing);
if (ret)
-   return ret;
+   goto fail;
data-card.num_links = 1;
data-card.dai_link = data-dai;
data-card.dapm_widgets = imx_sgtl5000_dapm_widgets;
@@ -148,14 +152,17 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = snd_soc_register_card(data-card);
if (ret) {
dev_err(pdev-dev, snd_soc_register_card failed (%d)\n, ret);
-   return ret;
+   goto fail;
}
 
platform_set_drvdata(pdev, data);
-   of_node_put(ssi_np);
-   of_node_put(codec_np);
+fail:
+   if (ssi_np)
+   of_node_put(ssi_np);
+   if (codec_np)
+   of_node_put(codec_np);
 
-   return 0;
+   return ret;
 }
 
 static int __devexit imx_sgtl5000_remove(struct platform_device *pdev)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/11] i2c: imx: add pinctrl support

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |2 ++
 arch/arm/boot/dts/imx6q.dtsi  |   16 
 drivers/i2c/busses/i2c-imx.c  |9 +
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 4663a4e..4e13293 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -50,6 +50,8 @@
i2c@021a { /* I2C1 */
status = okay;
clock-frequency = 10;
+   pinctrl-names = default;
+   pinctrl-0 = pinctrl_i2c1_1;
 
codec: sgtl5000@0a {
compatible = fsl,sgtl5000;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 2ba32e7..fe8c80d 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -390,6 +390,22 @@
reg = 0x020e 0x4000;
 
/* shared pinctrl settings */
+   i2c1 {
+   pinctrl_i2c1_1: i2c1grp-1 {
+   fsl,pins =  
MX6Q_PAD_EIM_D21,
+   
MX6Q_PAD_EIM_D28;
+   fsl,hysteresis = 1;
+   fsl,mux = 0x16 0x11;
+   fsl,pull = 2;
+   fsl,pue = 1;
+   fsl,pke = 1;
+   fsl,open-drain = 1;
+   fsl,speed = 2;
+   fsl,drive-strength = 6;
+   fsl,slew-rate = 1;
+   };
+   };
+
uart4 {
pinctrl_uart4_1: uart4grp-1 {
fsl,pins =  
MX6Q_PAD_KEY_COL0,
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index dfb84b7..7a52067 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -48,6 +48,7 @@
 #include linux/platform_device.h
 #include linux/clk.h
 #include linux/slab.h
+#include linux/pinctrl/consumer.h
 #include linux/of.h
 #include linux/of_device.h
 #include linux/of_i2c.h
@@ -470,6 +471,7 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
struct imx_i2c_struct *i2c_imx;
struct resource *res;
struct imxi2c_platform_data *pdata = pdev-dev.platform_data;
+   struct pinctrl *pct;
void __iomem *base;
resource_size_t res_size;
int irq, bitrate;
@@ -520,6 +522,13 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
i2c_imx-base   = base;
i2c_imx-res= res;
 
+   pct = devm_pinctrl_get_select_default(pdev-dev);
+   if (IS_ERR(pct)) {
+   dev_err(pdev-dev, can't get/select pinctrl\n);
+   ret = PTR_ERR(pct);
+   goto fail3;
+   }
+
/* Get I2C clock */
i2c_imx-clk = clk_get(pdev-dev, i2c_clk);
if (IS_ERR(i2c_imx-clk)) {
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/11] ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

It tries to clk_get the clock. And if it failed, it assumes the clock
by default enabled.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 sound/soc/fsl/imx-sgtl5000.c |   40 
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index 73b935e..3a729ca 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -13,6 +13,8 @@
 #include linux/module.h
 #include linux/of.h
 #include linux/of_platform.h
+#include linux/of_i2c.h
+#include linux/clk.h
 #include sound/soc.h
 
 #include ../codecs/sgtl5000.h
@@ -25,6 +27,7 @@ struct imx_sgtl5000_data {
struct snd_soc_card card;
char codec_dai_name[DAI_NAME_SIZE];
char platform_name[DAI_NAME_SIZE];
+   struct clk *codec_clk;
unsigned int clk_frequency;
 };
 
@@ -58,6 +61,7 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
struct device_node *np = pdev-dev.of_node;
struct device_node *ssi_np, *codec_np;
struct platform_device *ssi_pdev;
+   struct i2c_client *codec_dev;
struct imx_sgtl5000_data *data;
int int_port, ext_port;
int ret;
@@ -113,6 +117,11 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = -EINVAL;
goto fail;
}
+   codec_dev = of_find_i2c_device_by_node(codec_np);
+   if (!codec_dev) {
+   dev_err(pdev-dev, failed to find codec platform device\n);
+   return -EINVAL;
+   }
 
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
if (!data) {
@@ -120,11 +129,20 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
goto fail;
}
 
-   ret = of_property_read_u32(codec_np, clock-frequency,
-  data-clk_frequency);
-   if (ret) {
-   dev_err(pdev-dev, clock-frequency missing or invalid\n);
-   goto fail;
+   data-codec_clk = clk_get(codec_dev-dev, NULL);
+   if (IS_ERR(data-codec_clk)) {
+   /* assuming clock enabled by default */
+   data-codec_clk = NULL;
+   ret = of_property_read_u32(codec_np, clock-frequency,
+   data-clk_frequency);
+   if (ret) {
+   dev_err(codec_dev-dev,
+   clock-frequency missing or invalid\n);
+   goto fail;
+   }
+   } else {
+   data-clk_frequency = clk_get_rate(data-codec_clk);
+   clk_prepare_enable(data-codec_clk);
}
 
data-dai.name = HiFi;
@@ -140,10 +158,10 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
data-card.dev = pdev-dev;
ret = snd_soc_of_parse_card_name(data-card, model);
if (ret)
-   goto fail;
+   goto clk_fail;
ret = snd_soc_of_parse_audio_routing(data-card, audio-routing);
if (ret)
-   goto fail;
+   goto clk_fail;
data-card.num_links = 1;
data-card.dai_link = data-dai;
data-card.dapm_widgets = imx_sgtl5000_dapm_widgets;
@@ -152,10 +170,12 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = snd_soc_register_card(data-card);
if (ret) {
dev_err(pdev-dev, snd_soc_register_card failed (%d)\n, ret);
-   goto fail;
+   goto clk_fail;
}
 
platform_set_drvdata(pdev, data);
+clk_fail:
+   clk_put(data-codec_clk);
 fail:
if (ssi_np)
of_node_put(ssi_np);
@@ -169,6 +189,10 @@ static int __devexit imx_sgtl5000_remove(struct 
platform_device *pdev)
 {
struct imx_sgtl5000_data *data = platform_get_drvdata(pdev);
 
+   if (data-codec_clk) {
+   clk_disable_unprepare(data-codec_clk);
+   clk_put(data-codec_clk);
+   }
snd_soc_unregister_card(data-card);
 
return 0;
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/11] ARM: imx6q: move imx6q_sabrelite specific code to a dedicated function

2012-04-27 Thread Richard Zhao
It'll be easier to add other board specific code.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/mach-imx6q.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index da6c1d9..d25c5d8 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -75,11 +75,16 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
return 0;
 }
 
+static void __init imx6q_sabrelite_init(void)
+{
+   phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
+   ksz9021rn_phy_fixup);
+}
+
 static void __init imx6q_init_machine(void)
 {
if (of_machine_is_compatible(fsl,imx6q-sabrelite))
-   phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
-  ksz9021rn_phy_fixup);
+   imx6q_sabrelite_init();
 
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/11] ARM: dts: imx6q-sabrelite: add ssi device

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |9 +
 arch/arm/boot/dts/imx6q.dtsi  |   18 +++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 4e13293..7bd8855 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -22,6 +22,15 @@
};
 
soc {
+   aips-bus@0200 { /* AIPS1 */
+   spba-bus@0200 {
+   ssi1: ssi@02028000 {
+   fsl,mode = i2s-slave;
+   status = okay;
+   };
+   };
+   };
+
aips-bus@0210 { /* AIPS2 */
enet@02188000 {
phy-mode = rgmii;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index fe8c80d..da42fc0 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -177,19 +177,31 @@
interrupts = 0 51 0x04;
};
 
-   ssi@02028000 { /* SSI1 */
+   ssi1: ssi@02028000 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x02028000 0x4000;
interrupts = 0 46 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 38 37;
+   status = disabled;
};
 
-   ssi@0202c000 { /* SSI2 */
+   ssi2: ssi@0202c000 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x0202c000 0x4000;
interrupts = 0 47 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 42 41;
+   status = disabled;
};
 
-   ssi@0203 { /* SSI3 */
+   ssi3: ssi@0203 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x0203 0x4000;
interrupts = 0 48 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 46 45;
+   status = disabled;
};
 
asrc@02034000 {
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/11] ARM: imx6q_sabrelite: clkdev_add cko1 for sgtl5000

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c  |3 +++
 arch/arm/mach-imx/mach-imx6q.c |   28 
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 9a03dcc..4ea0de0 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -419,6 +419,9 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
+   clk_register_clkdev(clk[cko1_sel], cko1_sel, NULL);
+   clk_register_clkdev(clk[ahb], ahb, NULL);
+   clk_register_clkdev(clk[cko1], cko1, NULL);
 
for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
c = clk_get_sys(clks_init_on[i], NULL);
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index d25c5d8..e9b2522 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -10,6 +10,8 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+#include linux/clkdev.h
+#include linux/clk.h
 #include linux/delay.h
 #include linux/init.h
 #include linux/io.h
@@ -75,10 +77,36 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
return 0;
 }
 
+static void __init imx6q_cko1_setup(void)
+{
+   struct clk *cko1_sel, *ahb, *cko1;
+   unsigned long rate;
+
+   cko1_sel = clk_get_sys(NULL, cko1_sel);
+   ahb = clk_get_sys(NULL, ahb);
+   cko1 = clk_get_sys(NULL, cko1);
+   if (IS_ERR(cko1_sel) || IS_ERR(ahb) || IS_ERR(cko1)) {
+   printk(KERN_ERR cko1 setup failed!\n);
+   goto put_clk;
+   }
+   clk_set_parent(cko1_sel, ahb);
+   rate = clk_round_rate(cko1, 1600);
+   clk_set_rate(cko1, rate);
+   clk_register_clkdev(cko1, NULL, 0-000a);
+put_clk:
+   if (!IS_ERR(cko1_sel))
+   clk_put(cko1_sel);
+   if (!IS_ERR(ahb))
+   clk_put(ahb);
+   if (!IS_ERR(cko1))
+   clk_put(cko1);
+}
+
 static void __init imx6q_sabrelite_init(void)
 {
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
ksz9021rn_phy_fixup);
+   imx6q_cko1_setup();
 }
 
 static void __init imx6q_init_machine(void)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/11] ARM: dts: imx6q-sabrelite: add audmux device

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |3 +++
 arch/arm/boot/dts/imx6q.dtsi  |2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 7bd8855..02f93bc 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -52,6 +52,9 @@
status = okay;
};
 
+   audmux@021d8000 {
+   status = okay;
+   };
uart2: uart@021e8000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index da42fc0..7bf402e 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -596,7 +596,9 @@
};
 
audmux@021d8000 {
+   compatible = fsl,imx6q-audmux, 
fsl,imx31-audmux;
reg = 0x021d8000 0x4000;
+   status = disabled;
};
 
mipi@021dc000 { /* MIPI-CSI */
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/11] ASoC: imx-audmux: add pinctrl support

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |3 +++
 arch/arm/boot/dts/imx6q.dtsi  |   10 ++
 sound/soc/fsl/imx-audmux.c|8 
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 02f93bc..cdae2dd 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -54,7 +54,10 @@
 
audmux@021d8000 {
status = okay;
+   pinctrl-names = default;
+   pinctrl-0 = pinctrl_audmux_1;
};
+
uart2: uart@021e8000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 7bf402e..3c3004d 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -402,6 +402,16 @@
reg = 0x020e 0x4000;
 
/* shared pinctrl settings */
+   audmux {
+   pinctrl_audmux_1: audmux-1 {
+   fsl,pins =  
MX6Q_PAD_SD2_DAT0,
+   
MX6Q_PAD_SD2_DAT3,
+   
MX6Q_PAD_SD2_DAT2,
+   
MX6Q_PAD_SD2_DAT1;
+   fsl,mux = 3 3 3 3;
+   };
+   };
+
i2c1 {
pinctrl_i2c1_1: i2c1grp-1 {
fsl,pins =  
MX6Q_PAD_EIM_D21,
diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index f237003..6c7dfc0 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -26,6 +26,7 @@
 #include linux/of_device.h
 #include linux/platform_device.h
 #include linux/slab.h
+#include linux/pinctrl/consumer.h
 
 #include imx-audmux.h
 
@@ -249,6 +250,7 @@ EXPORT_SYMBOL_GPL(imx_audmux_v2_configure_port);
 static int __devinit imx_audmux_probe(struct platform_device *pdev)
 {
struct resource *res;
+   struct pinctrl *pct;
const struct of_device_id *of_id =
of_match_device(imx_audmux_dt_ids, pdev-dev);
 
@@ -257,6 +259,12 @@ static int __devinit imx_audmux_probe(struct 
platform_device *pdev)
if (!audmux_base)
return -EADDRNOTAVAIL;
 
+   pct = devm_pinctrl_get_select_default(pdev-dev);
+   if (IS_ERR(pct)) {
+   dev_err(pdev-dev, setup pinctrl failed!);
+   return PTR_ERR(pct);
+   }
+
audmux_clk = clk_get(pdev-dev, audmux);
if (IS_ERR(audmux_clk)) {
dev_dbg(pdev-dev, cannot get clock: %ld\n,
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/11] ARM: imx6q: add ssi1 clk_lookup

2012-04-27 Thread Richard Zhao
It's used by audio drivers.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index f40a35d..9a03dcc 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -418,6 +418,7 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[sdma], NULL, 20ec000.sdma);
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
+   clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
 
for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
c = clk_get_sys(clks_init_on[i], NULL);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/11] ARM: dts: imx6q-sabrelite: add sound device imx6q-sabrelite-sgtl5000

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index cdae2dd..20aa767 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -97,4 +97,17 @@
regulator-always-on;
};
};
+
+   sound {
+   compatible = fsl,imx6q-sabrelite-sgtl5000,
+fsl,imx-audio-sgtl5000;
+   model = imx6q-sabrelite-sgtl5000;
+   ssi-controller = ssi1;
+   audio-codec = codec;
+   audio-routing =
+   MIC_IN, Mic Jack,
+   Headphone Jack, HP_OUT;
+   mux-int-port = 1;
+   mux-ext-port = 4;
+   };
 };
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Sascha Hauer
On Fri, Apr 27, 2012 at 03:02:55PM +0800, Richard Zhao wrote:
 device_prep_dma_cyclic may be call in audio trigger function which is
 atomic context, so we make it atomic too.
 
  - change channel0 lock to spinlock.
  - Use polling to wait for channel0 finish running.
 
 Signed-off-by: Lothar Waßmann l...@karo-electronics.de
 Signed-off-by: Richard Zhao richard.z...@freescale.com
 ---
  drivers/dma/imx-sdma.c |   57 +++
  1 files changed, 33 insertions(+), 24 deletions(-)
 
 diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
 index fddccae..fc49ffa 100644
 --- a/drivers/dma/imx-sdma.c
 +++ b/drivers/dma/imx-sdma.c
 @@ -24,7 +24,7 @@
  #include linux/mm.h
  #include linux/interrupt.h
  #include linux/clk.h
 -#include linux/wait.h
 +#include linux/delay.h
  #include linux/sched.h
  #include linux/semaphore.h
  #include linux/spinlock.h
 @@ -324,7 +324,7 @@ struct sdma_engine {
   struct dma_device   dma_device;
   struct clk  *clk_ipg;
   struct clk  *clk_ahb;
 - struct mutexchannel_0_lock;
 + spinlock_t  channel_0_lock;
   struct sdma_script_start_addrs  *script_addrs;
  };
  
 @@ -402,19 +402,31 @@ static void sdma_enable_channel(struct sdma_engine 
 *sdma, int channel)
  }
  
  /*
 - * sdma_run_channel - run a channel and wait till it's done
 + * sdma_run_channel0 - run a channel and wait till it's done
   */
 -static int sdma_run_channel(struct sdma_channel *sdmac)
 +static int sdma_run_channel0(struct sdma_channel *sdmac)

Renaming this to sdma_run_channel0 is fine, but then the argument should
be changed to struct sdma_engine. It makes no sense to say in the
function name that this function is channel 0 only and at the same time
allow to pass in an arbitrary other channel.

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c: muxes: rename first set of drivers to a standard pattern

2012-04-27 Thread Jean Delvare
On Wed, 25 Apr 2012 22:43:56 +0200, Wolfram Sang wrote:
 Apply a naming pattern like in the rest of the subsystem to a first set
 of mux drivers. Those drivers are the low-hanging fruit; we want to pick
 them to motivate upcoming drivers to follow the new pattern. The missing
 GPIO driver will be converted in a later patch.
 
 Signed-off-by: Wolfram Sang w.s...@pengutronix.de
 Acked-by: Guenter Roeck guenter.ro...@ericsson.com (pca9541)
 Cc: Michael Lawnick ml.lawn...@gmx.de
 Cc: Jean Delvare kh...@linux-fr.org
 ---
  drivers/i2c/muxes/Kconfig  |4 ++--
  drivers/i2c/muxes/Makefile |4 ++--
  drivers/i2c/muxes/{pca9541.c = i2c-mux-pca9541.c} |0
  drivers/i2c/muxes/{pca954x.c = i2c-mux-pca954x.c} |0
  4 files changed, 4 insertions(+), 4 deletions(-)
  rename drivers/i2c/muxes/{pca9541.c = i2c-mux-pca9541.c} (100%)
  rename drivers/i2c/muxes/{pca954x.c = i2c-mux-pca954x.c} (100%)

Good idea.

Acked-by: Jean Delvare kh...@linux-fr.org

(I can pick this in my tree if you want, just let me know.)

Now that you made i2c mux non-experimental, I think it would be great
to solve the gpio mux case quickly. Renaming drivers, header files and
public structures is better done early. I'll give it a try.

-- 
Jean Delvare
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/11] ARM: imx6q: add ssi1 clk_lookup

2012-04-27 Thread Sascha Hauer
On Fri, Apr 27, 2012 at 03:03:03PM +0800, Richard Zhao wrote:
 It's used by audio drivers.
 
 Signed-off-by: Richard Zhao richard.z...@freescale.com
 ---
  arch/arm/mach-imx/clk-imx6q.c |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
 
 diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
 index f40a35d..9a03dcc 100644
 --- a/arch/arm/mach-imx/clk-imx6q.c
 +++ b/arch/arm/mach-imx/clk-imx6q.c
 @@ -418,6 +418,7 @@ int __init mx6q_clocks_init(void)
   clk_register_clkdev(clk[sdma], NULL, 20ec000.sdma);
   clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
   clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
 + clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);

The ssi clock needs a general cleanup on all i.MX just like I cleaned up
the other units. The SSI unit has at least a register clock and a baud
clock. What the driver requests and enables is the register clock.

The baud clock is currently unused and is needed only for master mode
(which is not implemented in the ssi driver)

So where we want to come to is:

clk_register_clkdev(clk[ipg], ipg, 2028000.ssi);
clk_register_clkdev(clk[ssi1], baud, 2028000.ssi);

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v10 3/4] drivers/i2c/busses/i2c-at91.c: add new driver

2012-04-27 Thread Voss, Nikolaus
Hi Carsten,

Carsten Behling wrote on 2012-04-27:
  INIT_COMPLETION(dev-cmd_complete);
 +dev-transfer_status = 0;
  if (dev-msg-flags  I2C_M_RD) {
  unsigned start_flags = AT91_TWI_START;
 
 this patch will not work, because you reset 'dev-transfer_status'
 before it is evaluated on errors (AT91_TWI_NACK, AT91_TWI_OVRE). 

it should, because transfer_status is updated by the ISR between
wait_for_completion_interruptible_timeout() and the error evaluation.
Please try it out.

  P.S. Are you using a RM9200? Seems that this SOC has some problems...
 
 Yes, our ECO920 uses the RM9200, but we support it with an very old kernel
 (2.6.21). I remember there were many problems with I2C.

Ok, but good to hear the driver basically works with the RM9200.

Niko

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/11] i2c: imx: add pinctrl support

2012-04-27 Thread Dong Aisheng
On Fri, Apr 27, 2012 at 03:02:58PM +0800, Richard Zhao wrote:
 Signed-off-by: Richard Zhao richard.z...@freescale.com
 ---
  arch/arm/boot/dts/imx6q-sabrelite.dts |2 ++
  arch/arm/boot/dts/imx6q.dtsi  |   16 
  drivers/i2c/busses/i2c-imx.c  |9 +
  3 files changed, 27 insertions(+), 0 deletions(-)
 
 diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
 b/arch/arm/boot/dts/imx6q-sabrelite.dts
 index 4663a4e..4e13293 100644
 --- a/arch/arm/boot/dts/imx6q-sabrelite.dts
 +++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
 @@ -50,6 +50,8 @@
   i2c@021a { /* I2C1 */
   status = okay;
   clock-frequency = 10;
 + pinctrl-names = default;
 + pinctrl-0 = pinctrl_i2c1_1;
  
   codec: sgtl5000@0a {
   compatible = fsl,sgtl5000;
 diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
 index 2ba32e7..fe8c80d 100644
 --- a/arch/arm/boot/dts/imx6q.dtsi
 +++ b/arch/arm/boot/dts/imx6q.dtsi
 @@ -390,6 +390,22 @@
   reg = 0x020e 0x4000;
  
   /* shared pinctrl settings */
 + i2c1 {
 + pinctrl_i2c1_1: i2c1grp-1 {
 + fsl,pins =  
 MX6Q_PAD_EIM_D21,
 + 
 MX6Q_PAD_EIM_D28;
 + fsl,hysteresis = 1;
 + fsl,mux = 0x16 0x11;
 + fsl,pull = 2;
 + fsl,pue = 1;
 + fsl,pke = 1;
 + fsl,open-drain = 1;
 + fsl,speed = 2;
 + fsl,drive-strength = 6;
 + fsl,slew-rate = 1;
 + };
The pinctrl binding is changed a bit since v1.
You may need to change here according to v2 or latter.

 + };
 +
   uart4 {
   pinctrl_uart4_1: uart4grp-1 {
   fsl,pins =  
 MX6Q_PAD_KEY_COL0,
 diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
 index dfb84b7..7a52067 100644
 --- a/drivers/i2c/busses/i2c-imx.c
 +++ b/drivers/i2c/busses/i2c-imx.c
 @@ -48,6 +48,7 @@
  #include linux/platform_device.h
  #include linux/clk.h
  #include linux/slab.h
 +#include linux/pinctrl/consumer.h
  #include linux/of.h
  #include linux/of_device.h
  #include linux/of_i2c.h
 @@ -470,6 +471,7 @@ static int __init i2c_imx_probe(struct platform_device 
 *pdev)
   struct imx_i2c_struct *i2c_imx;
   struct resource *res;
   struct imxi2c_platform_data *pdata = pdev-dev.platform_data;
 + struct pinctrl *pct;
   void __iomem *base;
   resource_size_t res_size;
   int irq, bitrate;
 @@ -520,6 +522,13 @@ static int __init i2c_imx_probe(struct platform_device 
 *pdev)
   i2c_imx-base   = base;
   i2c_imx-res= res;
  
 + pct = devm_pinctrl_get_select_default(pdev-dev);
You may want to check this change will break other platforms also using this 
driver.
Refer to:
http://www.spinics.net/lists/arm-kernel/msg171538.html

Regards
Dong Aisheng

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Richard Zhao
On Fri, Apr 27, 2012 at 01:51:40PM +0530, Vinod Koul wrote:
 On Fri, 2012-04-27 at 15:02 +0800, Richard Zhao wrote:
  device_prep_dma_cyclic may be call in audio trigger function which is
  atomic context, so we make it atomic too.
 No this is wrong behavior. You should not call dma prepare functions in
 any of the sound trigger calls. It would make sense to move this in
 sound prepare callback.
Then, could you please doc it somewhere? I think I'm not the only one
confused.

Thanks
Richard
 
 -- 
 ~Vinod
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/11] ARM: imx6q: add ssi1 clk_lookup

2012-04-27 Thread Richard Zhao
On Fri, Apr 27, 2012 at 10:04:12AM +0200, Sascha Hauer wrote:
 On Fri, Apr 27, 2012 at 03:03:03PM +0800, Richard Zhao wrote:
  It's used by audio drivers.
  
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   arch/arm/mach-imx/clk-imx6q.c |1 +
   1 files changed, 1 insertions(+), 0 deletions(-)
  
  diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
  index f40a35d..9a03dcc 100644
  --- a/arch/arm/mach-imx/clk-imx6q.c
  +++ b/arch/arm/mach-imx/clk-imx6q.c
  @@ -418,6 +418,7 @@ int __init mx6q_clocks_init(void)
  clk_register_clkdev(clk[sdma], NULL, 20ec000.sdma);
  clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
  clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
  +   clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
 
 The ssi clock needs a general cleanup on all i.MX just like I cleaned up
 the other units. The SSI unit has at least a register clock and a baud
 clock. What the driver requests and enables is the register clock.
 
 The baud clock is currently unused and is needed only for master mode
 (which is not implemented in the ssi driver)
Are you sure for that? If I don't enable clk[ssi1], the ssi will not
work.

 
 So where we want to come to is:
 
   clk_register_clkdev(clk[ipg], ipg, 2028000.ssi);
ssi don't have ipg gate. We can let it always on for imx6q.

Thanks
Richard
   clk_register_clkdev(clk[ssi1], baud, 2028000.ssi);
 
 Sascha
 
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Richard Zhao
On Fri, Apr 27, 2012 at 09:55:44AM +0200, Sascha Hauer wrote:
 On Fri, Apr 27, 2012 at 03:02:55PM +0800, Richard Zhao wrote:
  device_prep_dma_cyclic may be call in audio trigger function which is
  atomic context, so we make it atomic too.
  
   - change channel0 lock to spinlock.
   - Use polling to wait for channel0 finish running.
  
  Signed-off-by: Lothar Waßmann l...@karo-electronics.de
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   drivers/dma/imx-sdma.c |   57 
  +++
   1 files changed, 33 insertions(+), 24 deletions(-)
  
  diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
  index fddccae..fc49ffa 100644
  --- a/drivers/dma/imx-sdma.c
  +++ b/drivers/dma/imx-sdma.c
  @@ -24,7 +24,7 @@
   #include linux/mm.h
   #include linux/interrupt.h
   #include linux/clk.h
  -#include linux/wait.h
  +#include linux/delay.h
   #include linux/sched.h
   #include linux/semaphore.h
   #include linux/spinlock.h
  @@ -324,7 +324,7 @@ struct sdma_engine {
  struct dma_device   dma_device;
  struct clk  *clk_ipg;
  struct clk  *clk_ahb;
  -   struct mutexchannel_0_lock;
  +   spinlock_t  channel_0_lock;
  struct sdma_script_start_addrs  *script_addrs;
   };
   
  @@ -402,19 +402,31 @@ static void sdma_enable_channel(struct sdma_engine 
  *sdma, int channel)
   }
   
   /*
  - * sdma_run_channel - run a channel and wait till it's done
  + * sdma_run_channel0 - run a channel and wait till it's done
*/
  -static int sdma_run_channel(struct sdma_channel *sdmac)
  +static int sdma_run_channel0(struct sdma_channel *sdmac)
 
 Renaming this to sdma_run_channel0 is fine, but then the argument should
 be changed to struct sdma_engine. It makes no sense to say in the
 function name that this function is channel 0 only and at the same time
 allow to pass in an arbitrary other channel.
Correct. Thanks.

Richard
 
 Sascha
 
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Lothar Waßmann
Hi,

Richard Zhao writes:
 device_prep_dma_cyclic may be call in audio trigger function which is
 atomic context, so we make it atomic too.
 
  - change channel0 lock to spinlock.
  - Use polling to wait for channel0 finish running.
 
 Signed-off-by: Lothar Waßmann l...@karo-electronics.de

Actually I didn't sign off the patch that I posted, because I wanted
to wait for more comments first.


Lothar Waßmann
-- 
___

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | i...@karo-electronics.de
___
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Mark Brown
On Fri, Apr 27, 2012 at 03:52:10PM +0530, Vinod Koul wrote:
 On Fri, 2012-04-27 at 16:41 +0800, Richard Zhao wrote:

  Then, could you please doc it somewhere? I think I'm not the only one
  confused.

 See the soc-dmaengine.c for correct behavior!

Better yet, convert your code to use it if it's not doing so already!


signature.asc
Description: Digital signature


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Laxman Dewangan

On Friday 27 April 2012 05:03 PM, Russell King - ARM Linux wrote:

On Fri, Apr 27, 2012 at 07:26:56PM +0800, Richard Zhao wrote:

Sure, I mean, can you doc in include/linux/dmaengine.h that
dmaengine_prep_xxx may sleep?

Incorrect.  They may _not_ sleep.


But I have seen that we are using the kzalloc in the dmaengine_prep_xxx 
and kzalloc is sleeping call.

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c: muxes: rename first set of drivers to a standard pattern

2012-04-27 Thread Wolfram Sang
On Fri, Apr 27, 2012 at 09:59:46AM +0200, Jean Delvare wrote:
 On Wed, 25 Apr 2012 22:43:56 +0200, Wolfram Sang wrote:
  Apply a naming pattern like in the rest of the subsystem to a first set
  of mux drivers. Those drivers are the low-hanging fruit; we want to pick
  them to motivate upcoming drivers to follow the new pattern. The missing
  GPIO driver will be converted in a later patch.
 
 Good idea.

Thanks.

 Acked-by: Jean Delvare kh...@linux-fr.org
 
 (I can pick this in my tree if you want, just let me know.)

Since I do carry some mux-patches already, might be easier if I keep it.

 Now that you made i2c mux non-experimental, I think it would be great
 to solve the gpio mux case quickly. Renaming drivers, header files and
 public structures is better done early. I'll give it a try.

Cool. I intended to ping Peter after my patch, but forgot :/

Will fix the MAINTAINER issue you just mentioned.

   Wolfram

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


[PATCH] i2c: mxs: disable QUEUE when sending is done

2012-04-27 Thread Wolfram Sang
Since the last fixes to this driver ensure now the queue termination is
done correctly, we can finally disable the queue after a transfer
without problems. The gain is that it will only be reenabled after the
next transfer is fully set up. Before, the queue was running all the
time and if the setup of the next message was interrupted by another
thread, an incomplete buffer could have been sent, padded with zeroes.

Signed-off-by: Wolfram Sang w.s...@pengutronix.de
---

In case you are testing this patch, please donate Tested-by tags. Regular I2C
usage should do, a bit of stress testing (putting I2C bus and system under
load) would be great.

 drivers/i2c/busses/i2c-mxs.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 4c37347..76b8af4 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -253,6 +253,9 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, 
struct i2c_msg *msg,
 
if (i2c-cmd_err == -ENXIO)
mxs_i2c_reset(i2c);
+   else
+   writel(MXS_I2C_QUEUECTRL_QUEUE_RUN,
+   i2c-regs + MXS_I2C_QUEUECTRL_CLR);
 
dev_dbg(i2c-dev, Done with err=%d\n, i2c-cmd_err);
 
@@ -383,8 +386,6 @@ static int __devexit mxs_i2c_remove(struct platform_device 
*pdev)
if (ret)
return -EBUSY;
 
-   writel(MXS_I2C_QUEUECTRL_QUEUE_RUN,
-   i2c-regs + MXS_I2C_QUEUECTRL_CLR);
writel(MXS_I2C_CTRL0_SFTRST, i2c-regs + MXS_I2C_CTRL0_SET);
 
platform_set_drvdata(pdev, NULL);
-- 
1.7.10

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c: mxs: disable QUEUE when sending is done

2012-04-27 Thread Fabio Estevam
Hi Wolfram,

On Fri, Apr 27, 2012 at 11:23 AM, Wolfram Sang w.s...@pengutronix.de wrote:

        if (i2c-cmd_err == -ENXIO)
                mxs_i2c_reset(i2c);
 +       else
 +               writel(MXS_I2C_QUEUECTRL_QUEUE_RUN,
 +                               i2c-regs + MXS_I2C_QUEUECTRL_CLR);

When setting the QUEUE_RUN, do we really want to clear all the other
bits of QUEUECTRL_CLR register?

I am wondering if we should only set QUEUE_RUN bit here.

My mx28evk does not come with i2c eeprom. I hope I will solder one
soon so I can test it.

Thanks,

Fabio Estevam
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: possible MXS-i2c bug

2012-04-27 Thread Wolfram Sang
Hi,

 I've been thinking about the DMA approach. The problem I found out is that we 
 need to transfer all messages we're given at time in one DMA chain ... at 
 least 
 that's how I understand it from the FSL manual (see Fig. 27-10 in the mx28 
 manual).

I can't follow you:  mxs_i2c_xfer() gets a list of messages, yet they
are iterated over in mxs_i2c_xfer_msg(). A single I2C message is
unscattered and can't be bigger than 64KB, so that should be doable?

Am I missing something by already being in weekend-mode? :)

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: possible MXS-i2c bug

2012-04-27 Thread Marek Vasut
Dear Wolfram Sang,

 Hi,
 
  I've been thinking about the DMA approach. The problem I found out is
  that we need to transfer all messages we're given at time in one DMA
  chain ... at least that's how I understand it from the FSL manual (see
  Fig. 27-10 in the mx28 manual).
 
 I can't follow you:  mxs_i2c_xfer() gets a list of messages, yet they
 are iterated over in mxs_i2c_xfer_msg(). A single I2C message is
 unscattered and can't be bigger than 64KB, so that should be doable?

You can get a large list of i2c messages. In the current implementation, yes, 
they're iterated in mxs_i2c_xfer_msg. Correct.

If you want to do DMA transfer do/from the i2c controller, you have to take all 
these messages and create the chain of DMA transfers according to these 
messages, correct?

So either I missed something, or you need to do something like this to do the 
transfer:

for_each_message {
 sg_init_one()
 dma_map_sg()
 dmaengine_prep_slave_sg()
}

and then dmaengine_submit(). Is that correct?

And for each iteration of the cycle above, you need one scatterlist, you can't 
recycle one, correct?

So to create the chain. we'd need one scatterlist per message, correct?

 Am I missing something by already being in weekend-mode? :)

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Lothar Waßmann
Hi,

Richard Zhao writes:
 On Fri, Apr 27, 2012 at 11:18:31AM +0200, Lothar Waßmann wrote:
  Hi,
  
  Richard Zhao writes:
   device_prep_dma_cyclic may be call in audio trigger function which is
   atomic context, so we make it atomic too.
   
- change channel0 lock to spinlock.
- Use polling to wait for channel0 finish running.
   
   Signed-off-by: Lothar Waßmann l...@karo-electronics.de
  
  Actually I didn't sign off the patch that I posted, because I wanted
  to wait for more comments first.
 I send it out with slight modifications because the series highly
 depend on it. Will you take it over or let me put it in next version?
 Both are ok to me.
 
I think you should keep it as part of your sound patches and I will
test your final version on our hardware.


Lothar Waßmann
-- 
___

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | i...@karo-electronics.de
___
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Huang Shijie
On Fri, Apr 27, 2012 at 11:13 AM, Lothar Waßmann l...@karo-electronics.de 
wrote:
 Hi,

 Richard Zhao writes:
 On Fri, Apr 27, 2012 at 11:18:31AM +0200, Lothar Waßmann wrote:
  Hi,
 
  Richard Zhao writes:
   device_prep_dma_cyclic may be call in audio trigger function which is
   atomic context, so we make it atomic too.
  
    - change channel0 lock to spinlock.
    - Use polling to wait for channel0 finish running.
  
   Signed-off-by: Lothar Waßmann l...@karo-electronics.de
  
  Actually I didn't sign off the patch that I posted, because I wanted
  to wait for more comments first.
 I send it out with slight modifications because the series highly
 depend on it. Will you take it over or let me put it in next version?
 Both are ok to me.

 I think you should keep it as part of your sound patches and I will
 test your final version on our hardware.

I hope we can get a conclusion that the prep_slave_sg() can be called
in atomic context or not.
My patch add DMA support to UART heavily depends on it.

Huang Shijie


 Lothar Waßmann
 --
 ___

 Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
 Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
 Geschäftsführer: Matthias Kaussen
 Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

 www.karo-electronics.de | i...@karo-electronics.de
 ___

 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: possible MXS-i2c bug

2012-04-27 Thread Wolfram Sang

 You can get a large list of i2c messages. In the current implementation, yes, 
 they're iterated in mxs_i2c_xfer_msg. Correct.
 
 If you want to do DMA transfer do/from the i2c controller, you have to take 
 all 
 these messages and create the chain of DMA transfers according to these 
 messages, correct?

This is what I wonder. I'd think one could work on a per message basis.
Regarding Figure 27-10, the first I2C write command could be sent
seperately (probably even via PIOQUEUE). The only thing to be chained is
the I2C read command and the actual reading of the data.

Just checked, the FSL driver does it basically this way, too.

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: possible MXS-i2c bug

2012-04-27 Thread Marek Vasut
Dear Wolfram Sang,

  You can get a large list of i2c messages. In the current implementation,
  yes, they're iterated in mxs_i2c_xfer_msg. Correct.
  
  If you want to do DMA transfer do/from the i2c controller, you have to
  take all these messages and create the chain of DMA transfers according
  to these messages, correct?
 
 This is what I wonder. I'd think one could work on a per message basis.

But then you don't have the DMA chain linked. Which I wonder if the controller 
has any problem with or not. I tried yesterday, got wrotes working perfectly, 
but still had issues with reads, which is exactly what needs to be chained.

I'll poke further eventually.

 Regarding Figure 27-10, the first I2C write command could be sent
 seperately (probably even via PIOQUEUE).

I wonder if we want to combine pioqueue and DMA, that might create quite some 
franken-driver.

 The only thing to be chained is
 the I2C read command and the actual reading of the data.
 
 Just checked, the FSL driver does it basically this way, too.

Which doesn't mean FSL driver does it correctly, but it probably worked for 
them 
and there was some bug in my DMA tinkering.

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: possible MXS-i2c bug

2012-04-27 Thread Wolfram Sang

 But then you don't have the DMA chain linked. Which I wonder if the 
 controller 
 has any problem with or not. I tried yesterday, got wrotes working perfectly, 
 but still had issues with reads, which is exactly what needs to be chained.

Yes, the read needs chaining of two DMA command blocks. That should be
the only chain needed, because of how the driver handles reads. It is
still one I2C message, though.

 I'll poke further eventually.

I really hope it works out! That would be great.

  Regarding Figure 27-10, the first I2C write command could be sent
  seperately (probably even via PIOQUEUE).
 
 I wonder if we want to combine pioqueue and DMA, that might create quite some 
 franken-driver.

Might be true, yet I hope it won't. Most I2C transfers tend to be very
small, so PIOQEUE would have some advantage here (less overhead).

  The only thing to be chained is the I2C read command and the actual
  reading of the data.
  
  Just checked, the FSL driver does it basically this way, too.
 
 Which doesn't mean FSL driver does it correctly, but it probably
 worked for them and there was some bug in my DMA tinkering.

It's only a proof-of-concept. We both know that :) (If it works, that
is, AFAICT that one will fail for transfers bigger than PAGE_SIZE, too).

Thanks,

   Wolfram

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH 02/11] ASoC: imx-sgtl5000: add of_node_put when probe fail.

2012-04-27 Thread Mark Brown
On Fri, Apr 27, 2012 at 03:02:56PM +0800, Richard Zhao wrote:
 Signed-off-by: Richard Zhao richard.z...@freescale.com

Applied, thanks.


signature.asc
Description: Digital signature


Re: [PATCH 03/11] ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000

2012-04-27 Thread Mark Brown
On Fri, Apr 27, 2012 at 03:02:57PM +0800, Richard Zhao wrote:
 From: Richard Zhao richard.z...@linaro.org
 
 It tries to clk_get the clock. And if it failed, it assumes the clock
 by default enabled.

Applied, thanks.


signature.asc
Description: Digital signature


Re: [PATCH V2] i2c: Add generic I2C multiplexer using pinctrl API

2012-04-27 Thread Stephen Warren
On 04/25/2012 05:09 AM, Linus Walleij wrote:
 On Tue, Apr 24, 2012 at 11:02 PM, Stephen Warren swar...@wwwdotorg.org 
 wrote:
 On 04/24/2012 02:09 PM, Wolfram Sang wrote:

 From what I know, compatible-properties should not be linux-specific
 since devicetrees are OS independent. pinctrl-i2cmux sounds
 linux-specific to me.

 So, is such a binding acceptable meanwhile?

 To my mind, pinctrl has two meanings: (1) is the Linux internal API
 (2) is the pinctrl bindings in
 Documentation/devicetree/bindings/pinctrl, which were admittedly
 developed strongly based on Linux's pinctrl API needs, but I believe
 should be completely agnostic to the pinctrl API, SW, OS, etc., and
 hence can be considered a pure representation of hardware.

 As such, the pinctrl in pinctrl-i2cmux above refers to (2) above,
 and can be considered a pure HW/binding term.
 
 I second Stephens statement.
 
 Now every OS in the world must start to think about these things
 as pin controllers. But tt's not like there is competing terminology
 anyway, so let's define this before we get into committee meetings...

Rob, Grant, could you please take a look at the binding at the start of
this thread and say if you're OK with the compatible naming, and the
binding in general? Thanks.
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[TEST PATCH] mxs-i2c DMA support

2012-04-27 Thread Marek Vasut
This patch is by no means complete. This patch does have issues, see below.

Signed-off-by: Marek Vasut ma...@denx.de
Cc: Fabio Estevam feste...@gmail.com
Cc: Shawn Guo shawn@linaro.org
Cc: linux-i2c@vger.kernel.org
Cc: Wolfram Sang w.s...@pengutronix.de
---
 drivers/i2c/busses/i2c-mxs.c |  257 ++
 1 file changed, 238 insertions(+), 19 deletions(-)

NOTE: It's still crappy and in-the-works, but I wanted to push it out ASAP so
others can play around (so don't bash me for coding style etc.). I still need
to fix various things here and there until I make this official:

1) The printk(%s[%i]\n, __func__, __LINE__); in mxs_i2c_xfer_msg(), without
   this it craps out for some reason, I'll have to check it after I get some
   sleep.
2) The coexistence of DMA and PIO transfers.

NOTE2: Wolfram, I merged our patch into this as I hoped it might fix my DMA/PIO
   coexistance issue, but obviously I'd like to see your patch go in
   separately.

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 3d471d5..eea2d8a 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -26,6 +26,9 @@
 #include linux/platform_device.h
 #include linux/jiffies.h
 #include linux/io.h
+#include linux/dma-mapping.h
+#include linux/dmaengine.h
+#include linux/fsl/mxs-dma.h
 
 #include mach/common.h
 
@@ -109,6 +112,19 @@ struct mxs_i2c_dev {
struct completion cmd_complete;
u32 cmd_err;
struct i2c_adapter adapter;
+
+   booldma;
+   struct resource *dmares;
+   struct dma_chan *dmach;
+   struct mxs_dma_data dma_data;
+
+   struct mutexmutex;
+
+   uint32_tpio_data[2];
+   uint32_taddr_data;
+   struct scatterlist  sg_io[2];
+
+   boolread;
 };
 
 /*
@@ -194,7 +210,7 @@ static int mxs_i2c_wait_for_data(struct mxs_i2c_dev *i2c)
 
 static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len)
 {
-   u32 data;
+   u32 data = 0;
int i;
 
for (i = 0; i  len; i++) {
@@ -210,6 +226,148 @@ static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, 
u8 *buf, int len)
return 0;
 }
 
+static void mxs_i2c_dma_irq_callback(void *param)
+{
+   struct mxs_i2c_dev *i2c = param;
+   struct i2c_adapter *adap = i2c-adapter;
+
+   if (i2c-read) {
+   dma_unmap_sg(adap-dev, i2c-sg_io[0], 1, DMA_TO_DEVICE);
+   dma_unmap_sg(adap-dev, i2c-sg_io[1], 1, DMA_FROM_DEVICE);
+   } else {
+   dma_unmap_sg(adap-dev, i2c-sg_io, 2, DMA_TO_DEVICE);
+   }
+
+   complete(i2c-cmd_complete);
+}
+
+static int mxs_i2c_dma_setup_xfer(struct i2c_adapter *adap,
+   struct i2c_msg *msg, uint32_t flags)
+{
+   struct dma_async_tx_descriptor *desc;
+   struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap);
+
+   if (msg-flags  I2C_M_RD) {
+   i2c-read = 1;
+   i2c-addr_data = (msg-addr  1) | I2C_SMBUS_READ;
+
+   /*
+* SELECT command.
+*/
+
+   /* Queue the PIO register write transfer. */
+   i2c-pio_data[0] = MXS_CMD_I2C_SELECT;
+   desc = dmaengine_prep_slave_sg(i2c-dmach,
+   (struct scatterlist *)i2c-pio_data[0],
+   1, DMA_TRANS_NONE, 0);
+   if (!desc) {
+   dev_err(adap-dev,
+   Failed to get PIO reg. write descriptor.\n);
+   goto select_init_pio_fail;
+   }
+
+   /* Queue the DMA data transfer. */
+   sg_init_one(i2c-sg_io[0], i2c-addr_data, 1);
+   dma_map_sg(adap-dev, i2c-sg_io[0], 1, DMA_TO_DEVICE);
+   desc = dmaengine_prep_slave_sg(i2c-dmach, i2c-sg_io[0], 1,
+   DMA_MEM_TO_DEV,
+   DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+   if (!desc) {
+   dev_err(adap-dev,
+   Failed to get DMA data write descriptor.\n);
+   goto select_init_dma_fail;
+   }
+
+   /*
+* READ command.
+*/
+
+   /* Queue the PIO register write transfer. */
+   i2c-pio_data[1] = flags | MXS_I2C_CTRL0_MASTER_MODE |
+   MXS_I2C_CTRL0_XFER_COUNT(msg-len);
+   desc = dmaengine_prep_slave_sg(i2c-dmach,
+   (struct scatterlist *)i2c-pio_data[1],
+   1, DMA_TRANS_NONE, DMA_PREP_INTERRUPT);
+   if (!desc) {
+   dev_err(adap-dev,
+   Failed to get PIO