Re: [alsa-devel] [PATCH 2/3] ALSA SoC: Add mpc5200-psc I2S driver

2008-07-12 Thread Grant Likely
On Mon, Jul 07, 2008 at 09:23:24AM -0400, Jon Smirl wrote:
 On 7/7/08, Mark Brown [EMAIL PROTECTED] wrote:
  On Sun, Jul 06, 2008 at 01:56:48PM -0400, Jon Smirl wrote:
 
The driver is assuming a capture stream exists. My codec is output only.
 
 
  While the driver declares a capture stream the core doesn't require that
   both capture and playback be available - it will cope with a capture
   only or a playback only DAI (this is fairly common due to DAC only and
   ADC only parts).  Unless there's some other issue specific to this
   driver?
 
 Yes, it GPFs allocating a a DMA buffer on the null capture stream pointer.

Where does it GPF?  When dereferencing pcm-streams[x].substream in
psc_i2s_pcm_new?

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [i2c] [PATCH] of/i2c: don't pass -1 to irq_dispose_mapping, otherwise kernel will oops

2008-07-12 Thread Wolfram Sang
On Fri, Jul 11, 2008 at 11:15:02PM +0400, Anton Vorontsov wrote:

  Nope, it was a bug in the i2c documentation fixed recently:
 
 Nope? I'm looking into i2c-core.c:
 
 .. i2c_new_device(...)
 {
   client-irq = info-irq;
 
 Core will blindly pass irq, so clients should ensure that irq contains
 correct value. And as far as there is no common scheme of checking that
 there is no irq specified, the most safe option is -1.

I wonder if -1 is really the safest; even kernel functions related to
irqs are not consistent if irq is int or unsigned int. So, -1 could
cause subtle signedness defects.

The whole no irq mess really needs to be cleared generally. It just
disturbed me that i2c_core was imposing -1, whilst some other subsystem
may have chosen 0. IMHO, subsystems like i2c should pass irqs
transparently. This is why I submitted the patch for i2c documentation.

All the best,

   Wolfram

-- 
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry


signature.asc
Description: Digital signature
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

[PATCH v3 1/5] of: adapt of_find_i2c_driver() to be usable by SPI also

2008-07-12 Thread Grant Likely
From: Grant Likely [EMAIL PROTECTED]

SPI has a similar problem as I2C in that it needs to determine an
appropriate modalias value for each device node.  This patch adapts
the of_i2c of_find_i2c_driver() function to be usable by of_spi also.

Signed-off-by: Grant Likely [EMAIL PROTECTED]
---

 drivers/of/base.c   |   88 +++
 drivers/of/of_i2c.c |   64 ++---
 include/linux/of.h  |1 +
 3 files changed, 92 insertions(+), 61 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 23ffb7c..ad8ac1a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -385,3 +385,91 @@ struct device_node *of_find_matching_node(struct 
device_node *from,
return np;
 }
 EXPORT_SYMBOL(of_find_matching_node);
+
+/**
+ * of_modalias_table: Table of explicit compatible == modalias mappings
+ *
+ * This table allows particulare compatible property values to be mapped
+ * to modalias strings.  This is useful for busses which do not directly
+ * understand the OF device tree but are populated based on data contained
+ * within the device tree.  SPI and I2C are the two current users of this
+ * table.
+ *
+ * In most cases, devices do not need to be listed in this table because
+ * the modalias value can be derived directly from the compatible table.
+ * However, if for any reason a value cannot be derived, then this table
+ * provides a method to override the implicit derivation.
+ *
+ * At the moment, a single table is used for all bus types because it is
+ * assumed that the data size is small and that the compatible values
+ * should already be distinct enough to differentiate between SPI, I2C
+ * and other devices.
+ */
+struct of_modalias_table {
+   char *of_device;
+   char *modalias;
+};
+static struct of_modalias_table of_modalias_table[] = {
+   /* Empty for now; add entries as needed */
+};
+
+/**
+ * of_modalias_node - Lookup appropriate modalias for a device node
+ * @node:  pointer to a device tree node
+ * @modalias:  Pointer to buffer that modalias value will be copied into
+ * @len:   Length of modalias value
+ *
+ * Based on the value of the compatible property, this routine will determine
+ * an appropriate modalias value for a particular device tree node.  Three
+ * separate methods are used to derive a modalias value.
+ *
+ * First method is to lookup the compatible value in of_modalias_table.
+ * Second is to look for a linux,modalias entry in the compatible list
+ * and used that for modalias.  Third is to strip off the manufacturer
+ * prefix from the first compatible entry and use the remainder as modalias
+ *
+ * This routine returns 0 on success
+ */
+int of_modalias_node(struct device_node *node, char *modalias, int len)
+{
+   int i, cplen;
+   const char *compatible;
+   const char *p;
+
+   /* 1. search for exception list entry */
+   for (i = 0; i  ARRAY_SIZE(of_modalias_table); i++) {
+   compatible = of_modalias_table[i].of_device;
+   if (!of_device_is_compatible(node, compatible))
+   continue;
+   strlcpy(modalias, of_modalias_table[i].modalias, len);
+   return 0;
+   }
+
+   compatible = of_get_property(node, compatible, cplen);
+   if (!compatible)
+   return -ENODEV;
+
+   /* 2. search for linux,modalias entry */
+   p = compatible;
+   while (cplen  0) {
+   if (!strncmp(p, linux,, 6)) {
+   p += 6;
+   strlcpy(modalias, p, len);
+   return 0;
+   }
+
+   i = strlen(p) + 1;
+   p += i;
+   cplen -= i;
+   }
+
+   /* 3. take first compatible entry and strip manufacturer */
+   p = strchr(compatible, ',');
+   if (!p)
+   return -ENODEV;
+   p++;
+   strlcpy(modalias, p, len);
+   return 0;
+}
+EXPORT_SYMBOL_GPL(of_modalias_node);
+
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
index 5c015d3..65fd26d 100644
--- a/drivers/of/of_i2c.c
+++ b/drivers/of/of_i2c.c
@@ -16,62 +16,6 @@
 #include linux/of_i2c.h
 #include linux/module.h
 
-struct i2c_driver_device {
-   char*of_device;
-   char*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] = {
-};
-
-static int of_find_i2c_driver(struct device_node *node,
- struct i2c_board_info *info)
-{
-   int i, cplen;
-   const char *compatible;
-   const char *p;
-
-   /* 1. search for exception list entry */
-   for (i = 0; i  ARRAY_SIZE(i2c_devices); i++) {
-   if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-   continue;
-   if (strlcpy(info-type, i2c_devices[i].i2c_type,
-   I2C_NAME_SIZE) = I2C_NAME_SIZE)
-   return -ENOMEM;
-
-   return 0;
-   }
-
-

[PATCH v2 1/3] ALSA SoC: Add OpenFirmware helper for matching bus and codec drivers

2008-07-12 Thread Grant Likely
From: Grant Likely [EMAIL PROTECTED]

Simple utility layer for creating ASoC machine instances based on data
in the OpenFirmware device tree.  OF aware platform drivers and codec
drivers register themselves with this framework and the framework
automatically instantiates a machine driver.

This is most likely temporary glue code to work around limitations in
the ASoC v1 framework.  I expect ASoC v2 won't need this.
---

 include/sound/soc-of.h |   21 ++
 sound/soc/Kconfig  |3 +
 sound/soc/Makefile |1 
 sound/soc/soc-of.c |  171 
 4 files changed, 196 insertions(+), 0 deletions(-)

diff --git a/include/sound/soc-of.h b/include/sound/soc-of.h
new file mode 100644
index 000..a963032
--- /dev/null
+++ b/include/sound/soc-of.h
@@ -0,0 +1,21 @@
+/*
+ * OF helpers for ALSA SoC
+ *
+ * Copyright (C) 2008, Secret Lab Technologies Ltd.
+ */
+
+#ifndef _INCLUDE_SOC_OF_H_
+#define _INCLUDE_SOC_OF_H_
+
+#include linux/of.h
+#include sound/soc.h
+
+int of_snd_soc_register_codec(struct snd_soc_codec_device *codec_dev,
+ void *codec_data, struct snd_soc_codec_dai *dai,
+ struct device_node *node);
+
+int of_snd_soc_register_platform(struct snd_soc_platform *platform,
+struct device_node *node,
+struct snd_soc_cpu_dai *cpu_dai);
+
+#endif /* _INCLUDE_SOC_OF_H_ */
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 18f28ac..99118ed 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -23,6 +23,9 @@ config SND_SOC
  This ASoC audio support can also be built as a module.  If so, the 
module
  will be called snd-soc-core.
 
+config SND_SOC_OF
+   tristate
+
 # All the supported Soc's
 source sound/soc/at91/Kconfig
 source sound/soc/pxa/Kconfig
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 782db21..191c2e5 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -2,3 +2,4 @@ snd-soc-core-objs := soc-core.o soc-dapm.o
 
 obj-$(CONFIG_SND_SOC)  += snd-soc-core.o
 obj-$(CONFIG_SND_SOC)  += codecs/ at91/ pxa/ s3c24xx/ sh/ fsl/ davinci/ omap/
+obj-$(CONFIG_SND_SOC_OF)   += soc-of.o
diff --git a/sound/soc/soc-of.c b/sound/soc/soc-of.c
new file mode 100644
index 000..0c855df
--- /dev/null
+++ b/sound/soc/soc-of.c
@@ -0,0 +1,171 @@
+/*
+ * OF helpers for ALSA SoC Layer
+ *
+ * Copyright (C) 2008, Secret Lab Technologies Ltd.
+ */
+
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/pm.h
+#include linux/bitops.h
+#include linux/platform_device.h
+#include linux/of.h
+#include sound/core.h
+#include sound/pcm.h
+#include sound/pcm_params.h
+#include sound/soc.h
+#include sound/soc-of.h
+#include sound/initval.h
+
+MODULE_AUTHOR(Grant Likely [EMAIL PROTECTED]);
+MODULE_LICENSE(GPL);
+MODULE_DESCRIPTION(ALSA SoC OpenFirmware bindings);
+
+static DEFINE_MUTEX(of_snd_soc_mutex);
+static LIST_HEAD(of_snd_soc_device_list);
+static int of_snd_soc_next_index;
+
+struct of_snd_soc_device {
+   int id;
+   struct list_head list;
+   struct snd_soc_device device;
+   struct snd_soc_machine machine;
+   struct snd_soc_dai_link dai_link;
+   struct platform_device *pdev;
+   struct device_node *platform_node;
+   struct device_node *codec_node;
+};
+
+static struct snd_soc_ops of_snd_soc_ops = {
+};
+
+static struct of_snd_soc_device *
+of_snd_soc_get_device(struct device_node *codec_node)
+{
+   struct of_snd_soc_device *of_soc;
+
+   list_for_each_entry(of_soc, of_snd_soc_device_list, list) {
+   if (of_soc-codec_node == codec_node)
+   return of_soc;
+   }
+
+   of_soc = kzalloc(sizeof(struct of_snd_soc_device), GFP_KERNEL);
+   if (!of_soc)
+   return NULL;
+
+   /* Initialize the structure and add it to the global list */
+   of_soc-codec_node = codec_node;
+   of_soc-id = of_snd_soc_next_index++;
+   of_soc-machine.dai_link = of_soc-dai_link;
+   of_soc-machine.num_links = 1;
+   of_soc-device.machine = of_soc-machine;
+   of_soc-dai_link.ops = of_snd_soc_ops;
+   list_add(of_soc-list, of_snd_soc_device_list);
+
+   return of_soc;
+}
+
+static void of_snd_soc_register_device(struct of_snd_soc_device *of_soc)
+{
+   struct platform_device *pdev;
+   int rc;
+
+   /* Only register the device if both the codec and platform have
+* been registered */
+   if ((!of_soc-device.codec_data) || (!of_soc-platform_node))
+   return;
+
+   pr_info(platform--codec match achieved; registering machine\n);
+
+   pdev = platform_device_alloc(soc-audio, of_soc-id);
+   if (!pdev) {
+   pr_err(of_soc: platform_device_alloc() failed\n);
+   return;
+   }
+
+   pdev-dev.platform_data = of_soc;
+   platform_set_drvdata(pdev, of_soc-device);
+  

[PATCH v2 2/3] ALSA SoC: Add mpc5200-psc I2S driver

2008-07-12 Thread Grant Likely
From: Grant Likely [EMAIL PROTECTED]

This is an I2S bus driver for the MPC5200 PSC device.  It is probably
will not be merged as-is because it uses v1 of the ASoC API, but I want
to get it out there for comments.
---

 include/asm-powerpc/mpc52xx_psc.h |   32 +
 sound/soc/fsl/Kconfig |7 
 sound/soc/fsl/Makefile|2 
 sound/soc/fsl/mpc5200_psc_i2s.c   |  896 +
 4 files changed, 936 insertions(+), 1 deletions(-)

diff --git a/include/asm-powerpc/mpc52xx_psc.h 
b/include/asm-powerpc/mpc52xx_psc.h
index 710c5d3..0985dc8 100644
--- a/include/asm-powerpc/mpc52xx_psc.h
+++ b/include/asm-powerpc/mpc52xx_psc.h
@@ -60,10 +60,12 @@
 #define MPC52xx_PSC_RXTX_FIFO_ALARM0x0002
 #define MPC52xx_PSC_RXTX_FIFO_EMPTY0x0001
 
-/* PSC interrupt mask bits */
+/* PSC interrupt status/mask bits */
 #define MPC52xx_PSC_IMR_TXRDY  0x0100
 #define MPC52xx_PSC_IMR_RXRDY  0x0200
 #define MPC52xx_PSC_IMR_DB 0x0400
+#define MPC52xx_PSC_IMR_TXEMP  0x0800
+#define MPC52xx_PSC_IMR_ORERR  0x1000
 #define MPC52xx_PSC_IMR_IPC0x8000
 
 /* PSC input port change bit */
@@ -92,6 +94,34 @@
 
 #define MPC52xx_PSC_RFNUM_MASK 0x01ff
 
+#define MPC52xx_PSC_SICR_DTS1  (1  29)
+#define MPC52xx_PSC_SICR_SHDR  (1  28)
+#define MPC52xx_PSC_SICR_SIM_MASK  (0xf  24)
+#define MPC52xx_PSC_SICR_SIM_UART  (0x0  24)
+#define MPC52xx_PSC_SICR_SIM_UART_DCD  (0x8  24)
+#define MPC52xx_PSC_SICR_SIM_CODEC_8   (0x1  24)
+#define MPC52xx_PSC_SICR_SIM_CODEC_16  (0x2  24)
+#define MPC52xx_PSC_SICR_SIM_AC97  (0x3  24)
+#define MPC52xx_PSC_SICR_SIM_SIR   (0x8  24)
+#define MPC52xx_PSC_SICR_SIM_SIR_DCD   (0xc  24)
+#define MPC52xx_PSC_SICR_SIM_MIR   (0x5  24)
+#define MPC52xx_PSC_SICR_SIM_FIR   (0x6  24)
+#define MPC52xx_PSC_SICR_SIM_CODEC_24  (0x7  24)
+#define MPC52xx_PSC_SICR_SIM_CODEC_32  (0xf  24)
+#define MPC52xx_PSC_SICR_GENCLK(1  23)
+#define MPC52xx_PSC_SICR_I2S   (1  22)
+#define MPC52xx_PSC_SICR_CLKPOL(1  21)
+#define MPC52xx_PSC_SICR_SYNCPOL   (1  20)
+#define MPC52xx_PSC_SICR_CELLSLAVE (1  19)
+#define MPC52xx_PSC_SICR_CELL2XCLK (1  18)
+#define MPC52xx_PSC_SICR_ESAI  (1  17)
+#define MPC52xx_PSC_SICR_ENAC97(1  16)
+#define MPC52xx_PSC_SICR_SPI   (1  15)
+#define MPC52xx_PSC_SICR_MSTR  (1  14)
+#define MPC52xx_PSC_SICR_CPOL  (1  13)
+#define MPC52xx_PSC_SICR_CPHA  (1  12)
+#define MPC52xx_PSC_SICR_USEEOF(1  11)
+#define MPC52xx_PSC_SICR_DISABLEEOF(1  10)
 
 /* Structure of the hardware registers */
 struct mpc52xx_psc {
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 257101f..9ac970e 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -17,4 +17,11 @@ config SND_SOC_MPC8610_HPCD
help
  Say Y if you want to enable audio on the Freescale MPC8610 HPCD.
 
+config SND_SOC_MPC5200_I2S
+   tristate Freescale MPC5200 PSC in I2S mode driver
+   select SND_SOC_OF
+   depends on SND_SOC  PPC_MPC52xx
+   help
+ Say Y here to support the MPC5200 PSCs in I2S mode.
+
 endmenu
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index 62f680a..98729a1 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -4,3 +4,5 @@ obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += mpc8610_hpcd.o
 # MPC8610 Platform Support
 obj-$(CONFIG_SND_SOC_MPC8610) += fsl_ssi.o fsl_dma.o
 
+obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o
+
diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c
new file mode 100644
index 000..cdaae72
--- /dev/null
+++ b/sound/soc/fsl/mpc5200_psc_i2s.c
@@ -0,0 +1,896 @@
+/*
+ * Freescale MPC5200 PSC in I2S mode
+ * ALSA SoC Digital Audio Interface (DAI) driver
+ *
+ * Copyright (C) 2008 Secret Lab Technologies Ltd.
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/interrupt.h
+#include linux/device.h
+#include linux/delay.h
+#include linux/of_device.h
+#include linux/of_platform.h
+#include linux/dma-mapping.h
+
+#include sound/core.h
+#include sound/pcm.h
+#include sound/pcm_params.h
+#include sound/initval.h
+#include sound/soc.h
+#include sound/soc-of.h
+
+#include sysdev/bestcomm/bestcomm.h
+#include sysdev/bestcomm/gen_bd.h
+#include asm/mpc52xx_psc.h
+
+MODULE_AUTHOR(Grant Likely [EMAIL PROTECTED]);
+MODULE_DESCRIPTION(Freescale MPC5200 PSC in I2S mode ASoC Driver);
+MODULE_LICENSE(GPL);
+
+/**
+ * PSC_I2S_RATES: sample rates supported by the I2S
+ *
+ * This driver currently only supports the PSC running in I2S slave mode,
+ * which means the codec determines the sample rate.  Therefore, we tell
+ * ALSA that we 

[PATCH v2 3/3] ALSA SoC: Add Texas Instruments TLV320AIC26 codec driver

2008-07-12 Thread Grant Likely
From: Grant Likely [EMAIL PROTECTED]

ASoC Codec driver for the TLV320AIC26 device.  This driver uses the ASoC
v1 API, so I don't expect it to get merged as-is, but I want to get it
out there for review.
---

 sound/soc/codecs/Kconfig   |4 
 sound/soc/codecs/Makefile  |2 
 sound/soc/codecs/tlv320aic26.c |  546 
 sound/soc/codecs/tlv320aic26.h |  103 
 4 files changed, 655 insertions(+), 0 deletions(-)

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 3903ab7..96c7bfe 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -41,6 +41,10 @@ config SND_SOC_CS4270_VD33_ERRATA
bool
depends on SND_SOC_CS4270
 
+config SND_SOC_TLV320AIC26
+   tristate TI TLB320AIC26 Codec support
+   depends on SND_SOC  SPI
+
 config SND_SOC_TLV320AIC3X
tristate
depends on SND_SOC  I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 4e1314c..ec0cd93 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -5,6 +5,7 @@ snd-soc-wm8753-objs := wm8753.o
 snd-soc-wm9712-objs := wm9712.o
 snd-soc-wm9713-objs := wm9713.o
 snd-soc-cs4270-objs := cs4270.o
+snd-soc-tlv320aic26-objs := tlv320aic26.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 
 obj-$(CONFIG_SND_SOC_AC97_CODEC)   += snd-soc-ac97.o
@@ -14,4 +15,5 @@ obj-$(CONFIG_SND_SOC_WM8753)  += snd-soc-wm8753.o
 obj-$(CONFIG_SND_SOC_WM9712)   += snd-soc-wm9712.o
 obj-$(CONFIG_SND_SOC_WM9713)   += snd-soc-wm9713.o
 obj-$(CONFIG_SND_SOC_CS4270)   += snd-soc-cs4270.o
+obj-$(CONFIG_SND_SOC_TLV320AIC26)  += snd-soc-tlv320aic26.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)  += snd-soc-tlv320aic3x.o
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
new file mode 100644
index 000..3ebfa23
--- /dev/null
+++ b/sound/soc/codecs/tlv320aic26.c
@@ -0,0 +1,546 @@
+/*
+ * Texas Instruments TLV320AIC26 low power audio CODEC
+ * ALSA SoC CODEC driver
+ *
+ * Copyright (C) 2008 Secret Lab Technologies Ltd.
+ */
+
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/pm.h
+#include linux/device.h
+#include linux/sysfs.h
+#include linux/spi/spi.h
+#include sound/core.h
+#include sound/pcm.h
+#include sound/pcm_params.h
+#include sound/soc.h
+#include sound/soc-dapm.h
+#include sound/soc-of.h
+#include sound/initval.h
+
+#include tlv320aic26.h
+
+MODULE_DESCRIPTION(ASoC TLV320AIC26 codec driver);
+MODULE_AUTHOR(Grant Likely [EMAIL PROTECTED]);
+MODULE_LICENSE(GPL);
+
+/* AIC26 driver private data */
+struct aic26 {
+   struct spi_device *spi;
+   struct snd_soc_codec codec;
+   u16 reg_cache[AIC26_REG_CACHE_SIZE];/* shadow registers */
+   int master;
+   int datfm;
+   int mclk;
+
+   /* Keyclick parameters */
+   int keyclick_amplitude;
+   int keyclick_freq;
+   int keyclick_len;
+};
+
+/* -
+ * Register access routines
+ */
+static unsigned int aic26_reg_read(struct snd_soc_codec *codec,
+  unsigned int reg)
+{
+   struct aic26 *aic26 = codec-private_data;
+   u16 *cache = codec-reg_cache;
+   u16 cmd, value;
+   u8 buffer[2];
+   int rc;
+
+   if (reg = AIC26_NUM_REGS) {
+   WARN_ON_ONCE(1);
+   return 0;
+   }
+
+   /* Do SPI transfer; first 16bits are command; remaining is
+* register contents */
+   cmd = AIC26_READ_COMMAND_WORD(reg);
+   buffer[0] = (cmd  8)  0xff;
+   buffer[1] = cmd  0xff;
+   rc = spi_write_then_read(aic26-spi, buffer, 2, buffer, 2);
+   if (rc) {
+   dev_err(aic26-spi-dev, AIC26 reg read error\n);
+   return -EIO;
+   }
+   value = (buffer[0]  8) | buffer[1];
+
+   /* Update the cache before returning with the value */
+   if (AIC26_REG_IS_CACHED(reg))
+   cache[AIC26_REG_CACHE_ADDR(reg)] = value;
+   return value;
+}
+
+static unsigned int aic26_reg_read_cache(struct snd_soc_codec *codec,
+unsigned int reg)
+{
+   u16 *cache = codec-reg_cache;
+
+   if ((reg  0) || (reg = AIC26_NUM_REGS)) {
+   WARN_ON_ONCE(1);
+   return 0;
+   }
+
+   if (AIC26_REG_IS_CACHED(reg))
+   return cache[AIC26_REG_CACHE_ADDR(reg)];
+
+   return aic26_reg_read(codec, reg);
+}
+
+static int aic26_reg_write(struct snd_soc_codec *codec, unsigned int reg,
+  unsigned int value)
+{
+   struct aic26 *aic26 = codec-private_data;
+   u16 *cache = codec-reg_cache;
+   u16 cmd;
+   u8 buffer[4];
+   int rc;
+
+   if ((reg  0) || (reg = AIC26_NUM_REGS)) {
+   WARN_ON_ONCE(1);
+   return -EINVAL;
+   }
+
+   /* Do SPI transfer; first 16bits are command; remaining is data
+* to 

[PATCH v3 2/5] spi: split up spi_new_device() to allow two stage registration.

2008-07-12 Thread Grant Likely
From: Grant Likely [EMAIL PROTECTED]

spi_new_device() allocates and registers an spi device all in one swoop.
If the driver needs to add extra data to the spi_device before it is
registered, then this causes problems.

This patch splits the allocation and registration portions of code out
of spi_new_device() and creates three new functions; spi_alloc_device(),
spi_register_device(), and spi_device_release().  spi_new_device() is
modified to use the new functions for allocation and registration.
None of the existing users of spi_new_device() should be affected by
this change.

Drivers using the new API can forego the use of an spi_board_info
structure to describe the device layout and populate data into the
spi_device structure directly.

This change is in preparation for adding an OF device tree parser to
generate spi_devices based on data in the device tree.

Signed-off-by: Grant Likely [EMAIL PROTECTED]
---

 drivers/spi/spi.c   |  139 ---
 include/linux/spi/spi.h |   10 +++
 2 files changed, 105 insertions(+), 44 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 32b7a42..e64add0 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -178,6 +178,96 @@ struct boardinfo {
 static LIST_HEAD(board_list);
 static DEFINE_MUTEX(board_lock);
 
+/**
+ * spi_alloc_device - Allocate a new SPI device
+ * @master: Controller to which device is connected
+ * Context: can sleep
+ *
+ * Allows a driver to allocate and initialize and spi_device without
+ * registering it immediately.  This allows a driver to directly
+ * fill the spi_device with device parameters before calling
+ * spi_add_device() on it.
+ *
+ * Caller is responsible to call spi_add_device() on the returned
+ * spi_device structure to add it to the SPI master.  If the caller
+ * needs to discard the spi_device without adding it, then it should
+ * call spi_dev_put() on it.
+ *
+ * Returns a pointer to the new device, or NULL.
+ */
+struct spi_device *spi_alloc_device(struct spi_master *master)
+{
+   struct spi_device   *spi;
+   struct device   *dev = master-dev.parent;
+
+   if (!spi_master_get(master))
+   return NULL;
+
+   spi = kzalloc(sizeof *spi, GFP_KERNEL);
+   if (!spi) {
+   dev_err(dev, cannot alloc spi_device\n);
+   spi_master_put(master);
+   return NULL;
+   }
+
+   spi-master = master;
+   spi-dev.parent = dev;
+   spi-dev.bus = spi_bus_type;
+   spi-dev.release = spidev_release;
+   device_initialize(spi-dev);
+   return spi;
+}
+EXPORT_SYMBOL_GPL(spi_alloc_device);
+
+/**
+ * spi_add_device - Add an spi_device allocated with spi_alloc_device
+ * @spi: spi_device to register
+ *
+ * Companion function to spi_alloc_device.  Devices allocated with
+ * spi_alloc_device can be added onto the spi bus with this function.
+ *
+ * Returns 0 on success; non-zero on failure
+ */
+int spi_add_device(struct spi_device *spi)
+{
+   struct device *dev = spi-master-dev.parent;
+   int status;
+
+   /* Chipselects are numbered 0..max; validate. */
+   if (spi-chip_select = spi-master-num_chipselect) {
+   dev_err(dev, cs%d  max %d\n,
+   spi-chip_select,
+   spi-master-num_chipselect);
+   return -EINVAL;
+   }
+
+   /* Set the bus ID string */
+   snprintf(spi-dev.bus_id, sizeof spi-dev.bus_id,
+   %s.%u, spi-master-dev.bus_id,
+   spi-chip_select);
+
+   /* drivers may modify this initial i/o setup */
+   status = spi-master-setup(spi);
+   if (status  0) {
+   dev_err(dev, can't %s %s, status %d\n,
+   setup, spi-dev.bus_id, status);
+   return status;
+   }
+
+   /* driver core catches callers that misbehave by defining
+* devices that already exist.
+*/
+   status = device_add(spi-dev);
+   if (status  0) {
+   dev_err(dev, can't %s %s, status %d\n,
+   add, spi-dev.bus_id, status);
+   return status;
+   }
+
+   dev_dbg(dev, registered child %s\n, spi-dev.bus_id);
+   return 0;
+}
+EXPORT_SYMBOL_GPL(spi_add_device);
 
 /**
  * spi_new_device - instantiate one new SPI device
@@ -197,7 +287,6 @@ struct spi_device *spi_new_device(struct spi_master *master,
  struct spi_board_info *chip)
 {
struct spi_device   *proxy;
-   struct device   *dev = master-dev.parent;
int status;
 
/* NOTE:  caller did any chip-bus_num checks necessary.
@@ -207,66 +296,28 @@ struct spi_device *spi_new_device(struct spi_master 
*master,
 * suggests syslogged diagnostics are best here (ugh).
 */
 
-   /* Chipselects are numbered 0..max; validate. */
-   if (chip-chip_select = 

[PATCH v3 4/5] spi: Add OF binding support for SPI busses

2008-07-12 Thread Grant Likely
From: Grant Likely [EMAIL PROTECTED]

This patch adds support for populating an SPI bus based on data in the
OF device tree.  This is useful for powerpc platforms which use the
device tree instead of discrete code for describing platform layout.

Signed-off-by: Grant Likely [EMAIL PROTECTED]
---

 drivers/of/Kconfig |6 +++
 drivers/of/Makefile|1 +
 drivers/of/of_spi.c|   93 
 include/linux/of_spi.h |   18 +
 4 files changed, 118 insertions(+), 0 deletions(-)

diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 3a7a11a..edd6e92 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -13,3 +13,9 @@ config OF_I2C
depends on PPC_OF  I2C
help
  OpenFirmware I2C accessors
+
+config OF_SPI
+   def_tristate SPI
+   depends on OF  PPC_OF  SPI
+   help
+ OpenFirmware SPI accessors
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index 548772e..4c3c6f8 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -2,3 +2,4 @@ obj-y = base.o
 obj-$(CONFIG_OF_DEVICE) += device.o platform.o
 obj-$(CONFIG_OF_GPIO)   += gpio.o
 obj-$(CONFIG_OF_I2C)   += of_i2c.o
+obj-$(CONFIG_OF_SPI)   += of_spi.o
diff --git a/drivers/of/of_spi.c b/drivers/of/of_spi.c
new file mode 100644
index 000..b01eec0
--- /dev/null
+++ b/drivers/of/of_spi.c
@@ -0,0 +1,93 @@
+/*
+ * SPI OF support routines
+ * Copyright (C) 2008 Secret Lab Technologies Ltd.
+ *
+ * Support routines for deriving SPI device attachments from the device
+ * tree.
+ */
+
+#include linux/of.h
+#include linux/device.h
+#include linux/spi/spi.h
+#include linux/of_spi.h
+
+/**
+ * of_register_spi_devices - Register child devices onto the SPI bus
+ * @master:Pointer to spi_master device
+ * @np:parent node of SPI device nodes
+ *
+ * Registers an spi_device for each child node of 'np' which has a 'reg'
+ * property.
+ */
+void of_register_spi_devices(struct spi_master *master, struct device_node *np)
+{
+   struct spi_device *spi;
+   struct device_node *nc;
+   const u32 *prop;
+   int rc;
+   int len;
+
+   for_each_child_of_node(np, nc) {
+   /* Alloc an spi_device */
+   spi = spi_alloc_device(master);
+   if (!spi) {
+   dev_err(master-dev, spi_device alloc error for %s\n,
+   nc-full_name);
+   spi_dev_put(spi);
+   continue;
+   }
+
+   /* Select device driver */
+   if (of_modalias_node(nc, spi-modalias,
+sizeof(spi-modalias))  0) {
+   dev_err(master-dev, cannot find modalias for %s\n,
+   nc-full_name);
+   spi_dev_put(spi);
+   continue;
+   }
+
+   /* Device address */
+   prop = of_get_property(nc, reg, len);
+   if (!prop || len  sizeof(*prop)) {
+   dev_err(master-dev, %s has no 'reg' property\n,
+   nc-full_name);
+   spi_dev_put(spi);
+   continue;
+   }
+   spi-chip_select = *prop;
+
+   /* Mode (clock phase/polarity/etc.) */
+   if (of_find_property(nc, spi-cpha, NULL))
+   spi-mode |= SPI_CPHA;
+   if (of_find_property(nc, spi-cpol, NULL))
+   spi-mode |= SPI_CPOL;
+
+   /* Device speed */
+   prop = of_get_property(nc, spi-max-frequency, len);
+   if (!prop || len  sizeof(*prop)) {
+   dev_err(master-dev, %s has no 'spi-max-frequency' 
property\n,
+   nc-full_name);
+   spi_dev_put(spi);
+   continue;
+   }
+   spi-max_speed_hz = *prop;
+
+   /* IRQ */
+   spi-irq = irq_of_parse_and_map(nc, 0);
+
+   /* Store a pointer to the node in the device structure */
+   of_node_get(nc);
+   spi-dev.archdata.of_node = nc;
+
+   /* Register the new device */
+   request_module(spi-modalias);
+   rc = spi_add_device(spi);
+   if (rc) {
+   dev_err(master-dev, spi_device register error %s\n,
+   nc-full_name);
+   spi_dev_put(spi);
+   }
+
+   }
+}
+EXPORT_SYMBOL(of_register_spi_devices);
diff --git a/include/linux/of_spi.h b/include/linux/of_spi.h
new file mode 100644
index 000..5f71ee8
--- /dev/null
+++ b/include/linux/of_spi.h
@@ -0,0 +1,18 @@
+/*
+ * OpenFirmware SPI support routines
+ * Copyright (C) 2008 Secret Lab Technologies Ltd.
+ *
+ * Support routines for deriving SPI device attachments from the device
+ * tree.
+ */
+
+#ifndef 

[PATCH v3 3/5] of-bindings: Add binding documentation for SPI busses and devices

2008-07-12 Thread Grant Likely
From: Grant Likely [EMAIL PROTECTED]

Add documentation about how to describe SPI busses in the device tree.

Signed-off-by: Grant Likely [EMAIL PROTECTED]
---

 Documentation/powerpc/booting-without-of.txt |   58 ++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/Documentation/powerpc/booting-without-of.txt 
b/Documentation/powerpc/booting-without-of.txt
index b68684d..3b964ed 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -62,6 +62,7 @@ Table of Contents
   s) Freescale on board FPGA
   t) Freescael MSI interrupt controller
   u) Freescale General-purpose Timers Module
+  v) SPI busses
 
   VII - Marvell Discovery mv64[345]6x System Controller chips
 1) The /system-controller node
@@ -2967,6 +2968,63 @@ platforms are moved over to use the 
flattened-device-tree model.
clock-frequency = 0;
 };
 
+v) SPI (Serial Peripheral Interface) busses
+
+SPI busses can be described with a node for the SPI master device
+and a set of child nodes for each SPI slave on the bus.  For this
+discussion, it is assumed that the system's SPI controller is in
+SPI master mode.  This binding does not describe SPI controllers
+in slave mode.
+
+The SPI master node requires the following properties:
+- #address-cells  - number of cells required to define a chip select
+   address on the SPI bus.
+- #size-cells - should be zero.
+- compatible  - name of SPI bus controller following generic names
+   recommended practice.
+No other properties are required in the SPI bus node.  It is assumed
+that a driver for an SPI bus device will understand that it is an SPI bus.
+However, the binding does not attempt to define the specific method for
+assigning chip select numbers.  Since SPI chip select configuration is
+flexible and non-standardized, it is left out of this binding with the
+assumption that board specific platform code will be used to manage
+chip selects.  Individual drivers can define additional properties to
+support describing the chip select layout.
+
+SPI slave nodes must be children of the SPI master node and can
+contain the following properties.
+- reg - (required) chip select address of device.
+- compatible  - (required) name of SPI device following generic names
+   recommended practice
+- spi-max-frequency - (required) Maximum SPI clocking speed of device in Hz
+- spi-cpol- (optional) Empty property indicating device requires
+   inverse clock polarity (CPOL) mode
+- spi-cpha- (optional) Empty property indicating device requires
+   shifted clock phase (CPHA) mode
+
+SPI example for an MPC5200 SPI bus:
+   [EMAIL PROTECTED] {
+   #address-cells = 1;
+   #size-cells = 0;
+   compatible = fsl,mpc5200b-spi,fsl,mpc5200-spi;
+   reg = 0xf00 0x20;
+   interrupts = 2 13 0 2 14 0;
+   interrupt-parent = mpc5200_pic;
+
+   [EMAIL PROTECTED] {
+   compatible = micrel,ks8995m;
+   spi-max-frequency = 100;
+   reg = 0;
+   };
+
+   [EMAIL PROTECTED] {
+   compatible = ti,tlv320aic26;
+   spi-max-frequency = 10;
+   reg = 1;
+   };
+   };
+
+
 VII - Marvell Discovery mv64[345]6x System Controller chips
 ===
 

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH v3 5/5] powerpc/mpc5200: Add mpc5200-spi (non-PSC) device driver

2008-07-12 Thread Grant Likely
From: Grant Likely [EMAIL PROTECTED]

Adds support for the dedicated SPI device on the Freescale MPC5200(b)
SoC.

Signed-off-by: Grant Likely [EMAIL PROTECTED]
---

 drivers/spi/Kconfig |8 +
 drivers/spi/Makefile|1 
 drivers/spi/mpc52xx_spi.c   |  595 +++
 include/linux/spi/mpc52xx_spi.h |   10 +
 4 files changed, 614 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 66ec5d8..01860ac 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -116,6 +116,14 @@ config SPI_LM70_LLP
  which interfaces to an LM70 temperature sensor using
  a parallel port.
 
+config SPI_MPC52xx
+   tristate Freescale MPC52xx SPI (non-PSC) controller support
+   depends on PPC_MPC52xx  SPI
+   select SPI_MASTER_OF
+   help
+ This drivers supports the MPC52xx SPI controller in master SPI
+ mode.
+
 config SPI_MPC52xx_PSC
tristate Freescale MPC52xx PSC SPI controller
depends on SPI_MASTER  PPC_MPC52xx  EXPERIMENTAL
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 7fca043..340b878 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_SPI_PXA2XX)  += pxa2xx_spi.o
 obj-$(CONFIG_SPI_OMAP_UWIRE)   += omap_uwire.o
 obj-$(CONFIG_SPI_OMAP24XX) += omap2_mcspi.o
 obj-$(CONFIG_SPI_MPC52xx_PSC)  += mpc52xx_psc_spi.o
+obj-$(CONFIG_SPI_MPC52xx)  += mpc52xx_spi.o
 obj-$(CONFIG_SPI_MPC83xx)  += spi_mpc83xx.o
 obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o
 obj-$(CONFIG_SPI_S3C24XX)  += spi_s3c24xx.o
diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c
new file mode 100644
index 000..453690f
--- /dev/null
+++ b/drivers/spi/mpc52xx_spi.c
@@ -0,0 +1,595 @@
+/*
+ * MPC52xx SPI master driver.
+ * Copyright (C) 2008 Secret Lab Technologies Ltd.
+ *
+ * This is the driver for the MPC5200's dedicated SPI device (not for a
+ * PSC in SPI mode)
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/errno.h
+#include linux/of_platform.h
+#include linux/interrupt.h
+#include linux/delay.h
+#include linux/spi/spi.h
+#include linux/spi/mpc52xx_spi.h
+#include linux/of_spi.h
+#include linux/io.h
+#include asm/time.h
+#include asm/mpc52xx.h
+
+MODULE_AUTHOR(Grant Likely [EMAIL PROTECTED]);
+MODULE_DESCRIPTION(MPC52xx SPI (non-PSC) Driver);
+MODULE_LICENSE(GPL);
+
+/* Register offsets */
+#define SPI_CTRL1  0x00
+#define SPI_CTRL1_SPIE (1  7)
+#define SPI_CTRL1_SPE  (1  6)
+#define SPI_CTRL1_MSTR (1  4)
+#define SPI_CTRL1_CPOL (1  3)
+#define SPI_CTRL1_CPHA (1  2)
+#define SPI_CTRL1_SSOE (1  1)
+#define SPI_CTRL1_LSBFE(1  0)
+
+#define SPI_CTRL2  0x01
+#define SPI_BRR0x04
+
+#define SPI_STATUS 0x05
+#define SPI_STATUS_SPIF(1  7)
+#define SPI_STATUS_WCOL(1  6)
+#define SPI_STATUS_MODF(1  4)
+
+#define SPI_DATA   0x09
+#define SPI_PORTDATA   0x0d
+#define SPI_DATADIR0x10
+
+/* FSM state return values */
+#define FSM_STOP   0
+#define FSM_POLL   1
+#define FSM_CONTINUE   2
+
+/* Driver internal data */
+struct mpc52xx_spi {
+   struct spi_master *master;
+   u32 sysclk;
+   void __iomem *regs;
+   int irq0;   /* MODF irq */
+   int irq1;   /* SPIF irq */
+   int ipb_freq;
+
+   /* Statistics */
+   int msg_count;
+   int wcol_count;
+   int wcol_ticks;
+   u32 wcol_tx_timestamp;
+   int modf_count;
+   int byte_count;
+
+   /* Hooks for platform modification of behaviour */
+   void (*premessage)(struct spi_message *m, void *context);
+   void *premessage_context;
+
+   struct list_head queue; /* queue of pending messages */
+   spinlock_t lock;
+   struct work_struct work;
+
+
+   /* Details of current transfer (length, and buffer pointers) */
+   struct spi_message *message;/* current message */
+   struct spi_transfer *transfer;  /* current transfer */
+   int (*state)(int irq, struct mpc52xx_spi *ms, u8 status, u8 data);
+   int len;
+   int timestamp;
+   u8 *rx_buf;
+   const u8 *tx_buf;
+   int cs_change;
+};
+
+/*
+ * CS control function
+ */
+static void mpc52xx_spi_chipsel(struct mpc52xx_spi *ms, int value)
+{
+   if (value)
+   writeb(0, ms-regs + SPI_PORTDATA); /* Assert SS pin */
+   else
+   writeb(0x08, ms-regs + SPI_PORTDATA); /* Deassert SS pin */
+}
+
+/*
+ * Start a new transfer.  This is called both by the idle state
+ * for the first transfer in a message, and by the wait state when the
+ * previous transfer in a message is complete.
+ */
+static void mpc52xx_spi_start_transfer(struct mpc52xx_spi *ms)
+{
+   ms-rx_buf = ms-transfer-rx_buf;
+   ms-tx_buf = 

[RFC] reorganize cputypes for PPC64

2008-07-12 Thread Marvin
Hi,

attached patch introduces a processor type menu similar to ppc32. It 
_should_ not change anything upto now. 

The aim is to allow future fine graded cpu optimizations via mcpu/mtune 
compiler flags and also to clean up the arch Makefile/Kconfig.cputypes (I 
know this is a minefield).

Greetings

Marvin

diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index f7efaa9..eebde6c 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -54,35 +54,65 @@ config E200
 
 endchoice
 
-config POWER4_ONLY
-	bool Optimize for POWER4
+choice
+	prompt Processor Type
 	depends on PPC64
+	default TUNE_POWER4
+	help
+	  There are serveral families of 64 bit PowerPC chips supported.
+	  These include the Power3 to Power6 series, 970, and Cell BE based
+	  CPUs made be IBM.
+
+	  If unsure, select Power4.
+
+config TUNE_POWER3
+	bool Power3
+
+config TUNE_POWER4
+	bool Power4
+
+config TUNE_970
+	bool 970/G5
+
+config TUNE_POWER5
+	bool Power5
+
+config TUNE_POWER6
+	bool Power6
+
+config TUNE_CELL
+	bool Cell Broadband Engine
+	help
+	  Cause the compiler to optimize for the PPE of the Cell Broadband
+	  Engine. This will make the code run considerably faster on Cell
+	  but somewhat slower on other machines. If the resulting kernel is
+	  built to run only on Cell BE machines, select also OPT_EXCLUSIVE.
+
+endchoice
+
+config OPT_EXCLUSIVE
+	bool Optimize to run exclusive on selected CPU
 	default n
-	---help---
-	  Cause the compiler to optimize for POWER4/POWER5/PPC970 processors.
-	  The resulting binary will not work on POWER3 or RS64 processors
-	  when compiled with binutils 2.15 or later.
+	help
+	  Cause the compiler to optimize to run exclusive on the selected
+	  CPU. The resulting binary will probably not work on other CPUs.
+	  
+	  If the compiler/binutils combination does not support the exclusive
+	  optimization, it will try to tune only or fail.
+	  
+	  If you are unsure, select no.
 
 config POWER3
-	bool
 	depends on PPC64
-	default y if !POWER4_ONLY
+	def_bool y if !POWER4_ONLY
 
 config POWER4
 	depends on PPC64
 	def_bool y
 
-config TUNE_CELL
-	bool Optimize for Cell Broadband Engine
+config POWER4_ONLY
 	depends on PPC64
-	help
-	  Cause the compiler to optimize for the PPE of the Cell Broadband
-	  Engine. This will make the code run considerably faster on Cell
-	  but somewhat slower on other machines. This option only changes
-	  the scheduling of instructions, not the selection of instructions
-	  itself, so the resulting kernel will keep running on all other
-	  machines. When building a kernel that is supposed to run only
-	  on Cell, you should also select the POWER4_ONLY option.
+	def_bool y if TUNE_POWER4  OPT_EXCLUSIVE
 
 config 6xx
 	bool
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [alsa-devel] [PATCH 3/3] ALSA SoC: Add Texas Instruments TLV320AIC26 codec driver

2008-07-12 Thread Grant Likely
On Sat, Jul 12, 2008 at 11:36 AM, Mark Brown
[EMAIL PROTECTED] wrote:
 The power configuration should be fixed, though.  Normally drivers
 either fully implement DAPM (including set_bias_level()) or power
 everything in the codec up when the driver is loaded.  At the minute
 what the driver is doing appears to be powering the codec up in both
 _hw_params() and _probe() but never powering anything down - if that is
 the case then probably all you need to do is remove the extra power up
 from hw_params(), giving you the simple option.

Okay, cool.  I'll do this for the time being then.

Thanks,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [alsa-devel] [PATCH v2 3/3] ALSA SoC: Add Texas Instruments TLV320AIC26 codec driver

2008-07-12 Thread Grant Likely
On Sat, Jul 12, 2008 at 12:10 PM, Mark Brown
[EMAIL PROTECTED] wrote:
 On Sat, Jul 12, 2008 at 02:39:39AM -0600, Grant Likely wrote:

 ASoC Codec driver for the TLV320AIC26 device.  This driver uses the ASoC
 v1 API, so I don't expect it to get merged as-is, but I want to get it
 out there for review.

 I've not reviewed this revision of these drivers yet but I just wanted
 to point out that there's absoluely no problem with merging v1 drivers -
 so long as a driver uses the existing merged APIs there's no issue from
 that point of view.

Oops, I forgot to update my commit messages.  I'll probably repost v3
of the series this evening and I'll fix this.

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Please pull linux-2.6-mpc52xx tree

2008-07-12 Thread Grant Likely
Hi Ben,

Please pull the following patches for MPC5xxx support.

  git://git.secretlab.ca/git/linux-2.6-mpc52xx next

Thanks,
g.

The following changes since commit 0db9360aaa9b95b0cf67f82874809f16e68068eb:
  Nathan Fontenot (1):
powerpc/pseries: Update numa association of hotplug memory add
for drconf memory

are available in the git repository at:

  git://git.secretlab.ca/git/linux-2.6-mpc52xx next

Andre Schwarz (1):
  powerpc/mpc5200: PCI write combine timer

Grant Likely (3):
  powerpc/mpc5200: Add PSC helpers for bestcomm engine
  powerpc/mpc5200: fix compile warnings in bestcomm driver
  powerpc: Modify MPC52xx maintainers entry to cover all MPC5xxx parts

John Rigby (4):
  powerpc/mpc5121: Update device tree for MPC5121ADS evaluation board
  powerpc/mpc5121: Add clock driver
  powerpc/mpc5121: Add generic board support for MPC5121 platforms
  powerpc/mpc5121: Add support for CPLD on MPC5121ADS board

Jon Smirl (1):
  powerpc/i2c: Convert i2c-mpc into an of_platform driver

Robert P. J. Day (1):
  OpenFirmware: Include linux/of_i2c.h from of_i2c.c.

Stephen Rothwell (3):
  powerpc/pata_mpc52xx: use linux/of_platform.h instead of asm
  powerpc/mpc52xx_psc_spi: use linux/of_platform.h instead of asm
  powerpc/mpc5200_wdt: use linux/of_platform.h instead of asm

Wolfgang Grandegger (1):
  powerpc/mpc5200: add missing MSCAN FDT nodes for TQM52xx

 MAINTAINERS|4 +-
 Makefile   |1 +
 arch/powerpc/boot/dts/mpc5121ads.dts   |  310 ++-
 arch/powerpc/boot/dts/tqm5200.dts  |   14 +
 arch/powerpc/platforms/512x/Kconfig|   17 +-
 arch/powerpc/platforms/512x/Makefile   |4 +-
 arch/powerpc/platforms/512x/clock.c|  729 
 arch/powerpc/platforms/512x/mpc5121_ads.c  |   69 +--
 arch/powerpc/platforms/512x/mpc5121_ads.h  |   16 +
 arch/powerpc/platforms/512x/mpc5121_ads_cpld.c |  204 +++
 arch/powerpc/platforms/512x/mpc5121_generic.c  |   58 ++
 arch/powerpc/platforms/512x/mpc512x.h  |   17 +
 arch/powerpc/platforms/512x/mpc512x_shared.c   |   83 +++
 arch/powerpc/platforms/52xx/mpc52xx_pci.c  |3 +-
 arch/powerpc/sysdev/bestcomm/bestcomm.c|2 +-
 arch/powerpc/sysdev/bestcomm/gen_bd.c  |   95 +++
 arch/powerpc/sysdev/bestcomm/gen_bd.h  |5 +
 arch/powerpc/sysdev/bestcomm/sram.c|2 +-
 arch/powerpc/sysdev/fsl_soc.c  |  133 -
 drivers/ata/pata_mpc52xx.c |2 +-
 drivers/i2c/busses/i2c-mpc.c   |  104 ++--
 drivers/of/of_i2c.c|1 +
 drivers/spi/mpc52xx_psc_spi.c  |2 +-
 drivers/watchdog/mpc5200_wdt.c |2 +-
 24 files changed, 1620 insertions(+), 257 deletions(-)
 create mode 100644 arch/powerpc/platforms/512x/clock.c
 create mode 100644 arch/powerpc/platforms/512x/mpc5121_ads.h
 create mode 100644 arch/powerpc/platforms/512x/mpc5121_ads_cpld.c
 create mode 100644 arch/powerpc/platforms/512x/mpc5121_generic.c
 create mode 100644 arch/powerpc/platforms/512x/mpc512x.h
 create mode 100644 arch/powerpc/platforms/512x/mpc512x_shared.c


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: linux-next: kbuild tree build failure

2008-07-12 Thread Milton Miller

In-Reply-To: [EMAIL PROTECTED]

On Fri Jul 11 00:59:25 EST 2008, Roman Zippel wrote:

On Thu, 10 Jul 2008, Michael Ellerman wrote:

 Well yes :)  But I think that's because you're thinking of
 end-users and I'm thinking of users like myself - ie. _I_ use
 Kconfig and I do expect myself to be able to type a 64-bit address.

That doesn't really answer my question, why you need this.

   --- .config.orig  2008-07-08 09:30:00.0 +1000
   +++ .config   2008-07-08 09:30:43.0 +1000
   @@ -370,9 +370,8 @@
CONFIG_HOTPLUG_PCI_RPA=m
CONFIG_HOTPLUG_PCI_RPA_DLPAR=m
# CONFIG_HAS_RAPIDIO is not set
   -CONFIG_PAGE_OFFSET=0xc000
   -CONFIG_KERNEL_START=0xc200
   -CONFIG_PHYSICAL_START=0x0200
   +CONFIG_PAGE_OFFSET=0xc000
   +CONFIG_PHYSICAL_START=0x200
 
  Why is this worse? These are constants, you're not supposed to 
change them

  anyway.
  The remaining values are generated in page.h and should be the 
same as

  before. If that isn't the case and this patch produces a nonworking
  kernel, I'd like to hear about it.

 You're right the built kernel is fine. So it's not a bug,



But its horrible code.

Good, could someone please ack whether the powerpc changes are 
acceptable?




Well, since no one else has said it,
NAK

The primary reason I object is this:

Index: linux-2.6/include/asm-powerpc/page.h
===
--- linux-2.6.orig/include/asm-powerpc/page.h
+++ linux-2.6/include/asm-powerpc/page.h
@@ -67,9 +67,15 @@
  * If you want to test if something's a kernel address, use 
is_kernel_addr().

  */

-#define KERNELBASE  ASM_CONST(CONFIG_KERNEL_START)
+#ifdef CONFIG_PPC64
+#define PAGE_OFFSET(ASM_CONST(CONFIG_PAGE_OFFSET)  32)
+#define KERNELBASE 
(PAGE_OFFSET+ASM_CONST(CONFIG_PHYSICAL_START))

+#define LOAD_OFFSETPAGE_OFFSET
+#else
+#define KERNELBASE ASM_CONST(CONFIG_KERNEL_START)
 #define PAGE_OFFSETASM_CONST(CONFIG_PAGE_OFFSET)
-#define LOAD_OFFSET
ASM_CONST((CONFIG_KERNEL_START-CONFIG_PHYSICAL_START))
+#define LOAD_OFFSET
(ASM_CONST(CONFIG_KERNEL_START)-ASM_CONST(CONFIG_PHYSICAL_START))

+#endif

 #if defined(CONFIG_RELOCATABLE)  defined(CONFIG_FLATMEM)
 #ifndef __ASSEMBLY__


(1) #define PAGE_OFFSET(ASM_CONST(CONFIG_PAGE_OFFSET)  32)

It creates unreadable code, where two defines with almost the same name 
(the only difference being
the CONFIG_ prefix, which is often ignored when scanning) contains 
radically different values.


(2)  #define PAGE_OFFSETASM_CONST(CONFIG_PAGE_OFFSET)

It creates config variables that mean different things depending on 
other config variables
The 32 and 64 bit powerpc kernel share a common source, a config 
variable should be used for

only one purpose.




 but I think it is nicer to have the real values in the .config.

Why?


Mostly consistency between the different portions of the archticture.

As I remember, this code was adjusted and some of the defines moved 
from page.h

as part of the 32 bit relocatable kernel for 85xx booke ASMP support.

The 32 bit kernel has advanced options to change the VMA split, which 
enable
direct user input when explicitly defined.  That allows us to not need 
patches

for the embedded boards who need some other split than 3G/1G.  So there
is the reason that we have this directly specified in Kconfig at all.

While the 64 bit kernel doesn't need to actually change the page 
offset, as we

don't support the full 64 bits of the real address anyways (in fact, the
archtiecture prevents us from doing so) and therefore don't need to 
adjust

the effective address spilt between user and kernel.

But introducing config variables that mean different things is 
UNMAINTAINABLE.


Also, I remember, CONFIG_PAGE_OFFSET is used by the linker script and 
previously

page.h was conditionally included.   Does it always include page.h now?



On a seperate note,

 config PINT3_ASSIGN
hex PINT3_ASSIGN
depends on PINTx_REASSIGN
-   default 0x02020303
+   default 0x2020303


is harder to read.   The value is a list of 4 1 byte values, but you 
have hidden the first nibble making parsing the rest of the value hard.




 config IRAM_SIZE
hex Internal memory size (hex)
depends on (CHIP_M32700 || CHIP_M32102 || CHIP_VDEC2 || 
CHIP_OPSP || CHIP_M32104)  DISCONTIGMEM

-   default 0008 if CHIP_M32700
-   default 0001 if CHIP_M32102 || CHIP_OPSP || 
CHIP_M32104

-   default 8000 if CHIP_VDEC2
+   default 0x8 if CHIP_M32700
+   default 0x1 if CHIP_M32102 || CHIP_OPSP || CHIP_M32104
+   default 0x8000 if CHIP_VDEC2


Likewize, I find it easier to mentally check the order of magnitude and 
compare sizes when they have

leading zeros and are right aligned.


Going to another email in the thread,

On Fri Jul 11 00:52:25 EST 2008, Roman Zippel wrpte:

On Tue, 8 Jul 2008, Sam Ravnborg wrote:
 We use Kconfig for a mixture of user 

Re: linux-next: kbuild tree build failure

2008-07-12 Thread Roman Zippel
Hi,

On Sat, 12 Jul 2008, Milton Miller wrote:

 (1) #define PAGE_OFFSET(ASM_CONST(CONFIG_PAGE_OFFSET)  32)
 
 It creates unreadable code, where two defines with almost the same name (the
 only difference being
 the CONFIG_ prefix, which is often ignored when scanning) contains radically
 different values.
 
 (2)  #define PAGE_OFFSETASM_CONST(CONFIG_PAGE_OFFSET)

Giving it different names is not really difficult. Any objections to 
CONFIG_PAGE_HIGH_OFFSET?

 On a seperate note,
  config PINT3_ASSIGN
 hex PINT3_ASSIGN
 depends on PINTx_REASSIGN
 -   default 0x02020303
 +   default 0x2020303
 
 is harder to read.   The value is a list of 4 1 byte values, but you have
 hidden the first nibble making parsing the rest of the value hard.

Sam mentioned that already, but that's a situation where the warning can 
be relaxed.

 If you are worried about users tring to set values that are too high,
 then make the types be hex8, hex16, hex32, and hex64.

It's not this, I value consistency as much as you and the values are 
sometimes used as integers, so a working range is needed. Using simple 
integers keeps things much simpler and as the ASM_CONST example shows any 
bigger values are not necessarily directly usable anyway.

bye, Roman
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [i2c] [PATCH] of/i2c: don't pass -1 to irq_dispose_mapping, otherwise kernel will oops

2008-07-12 Thread Jon Smirl
On 7/12/08, Wolfram Sang [EMAIL PROTECTED] wrote:
 On Fri, Jul 11, 2008 at 12:23:23PM -0600, Grant Likely wrote:

  On Fri, Jul 11, 2008 at 09:48:59PM +0400, Anton Vorontsov wrote:
Firstly kernel warns at set_irq_chip, and then dies completely:
   
Trying to install chip for IRQ-1
   
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
index b2ccdcb..95a24de 100644
--- a/drivers/of/of_i2c.c
+++ b/drivers/of/of_i2c.c
@@ -93,10 +93,8 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
if (info.irq == NO_IRQ)
info.irq = -1;
  
   What is the reason that info.irq is set to -1 in the first place?  This
   looks like another bug to me.  Does something in the i2c layer depend on
   the -1 value?
  


 You already acked a fix to this :) I wasn't sure if my patch would
  make it on its own, as Jon Smirl was also working on fixes to of_i2c.c
  and he seemed to pick up this issue, too.

I did another patch for the mpc-i2c driver changing all of the
comparisons to NO_IRQ. My understanding of this is the ppc has NO_IRQ
set to -1, and powerpc has NO_IRQ = 0. So to make all of this work
right you have to use the NO_IRQ symbol and you can't check against 0
or -1 directly. I also believe work is underway to get all platforms
to NO_IRQ = 0 but I don't know if it is completed yet.



  (Original patch is here:
  http://ozlabs.org/pipermail/linuxppc-dev/2008-June/058801.html
  )

  All the best,

Wolfram


  --
   Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
   Pengutronix - Linux Solutions for Science and Industry

 -BEGIN PGP SIGNATURE-
  Version: GnuPG v1.4.6 (GNU/Linux)

  iD8DBQFIeGSED27XaX1/VRsRAr+EAJ948UwobnY7WSSR4i/ywjof1+8dJACfWzPN
  bhW6NXgBCnwqITIC5rSXeAI=
  =W3sj
  -END PGP SIGNATURE-

 ___
  Linuxppc-dev mailing list
  Linuxppc-dev@ozlabs.org
  https://ozlabs.org/mailman/listinfo/linuxppc-dev




-- 
Jon Smirl
[EMAIL PROTECTED]
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev