diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 70f7ab8..6edb6df 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -21,6 +21,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/device.h>
 #include <linux/i2c.h>
 #include <linux/i2c-id.h>
 #include <linux/init.h>
@@ -939,7 +940,9 @@ static struct pxa_i2c i2c_pxa = {
 static int i2c_pxa_probe(struct platform_device *dev)
 {
 	struct pxa_i2c *i2c = &i2c_pxa;
+#ifdef CONFIG_I2C_PXA_SLAVE
 	struct i2c_pxa_platform_data *plat = dev->dev.platform_data;
+#endif
 	int ret;
 
 #ifdef CONFIG_PXA27x
@@ -1006,9 +1009,23 @@ static int i2c_pxa_remove(struct platfor
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int i2c_pxa_resume(struct platform_device *pdev)
+{
+	i2c_pxa_reset(platform_get_drvdata(pdev));
+	return 0;
+}
+
+#else
+#define i2c_pxa_resume NULL
+#endif
+
 static struct platform_driver i2c_pxa_driver = {
 	.probe		= i2c_pxa_probe,
 	.remove		= i2c_pxa_remove,
+#ifdef CONFIG_PM
+	.resume		= i2c_pxa_resume,
+#endif
 	.driver		= {
 		.name	= "pxa2xx-i2c",
 	},
@@ -1024,5 +1041,7 @@ static void i2c_adap_pxa_exit(void)
 	return platform_driver_unregister(&i2c_pxa_driver);
 }
 
+MODULE_LICENSE("GPL");
+
 module_init(i2c_adap_pxa_init);
 module_exit(i2c_adap_pxa_exit);
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index 64672d4..25a5bd3 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -258,6 +258,23 @@ static void corgikbd_hinge_timer(unsigne
 	mod_timer(&corgikbd_data->htimer, jiffies + HINGE_SCAN_INTERVAL);
 }
 
+static struct corgikbd *corgikbd_data_ptr;
+
+void corgikbd_report_hp(int status)
+{
+	unsigned long flags;
+
+	if (!corgikbd_data_ptr)
+		return;
+
+	spin_lock_irqsave(&corgikbd_data_ptr->lock, flags);
+	input_report_switch(corgikbd_data_ptr->input, SW_2, (status != 0));
+	input_sync(corgikbd_data_ptr->input);
+	spin_unlock_irqrestore(&corgikbd_data_ptr->lock, flags);
+}
+
+EXPORT_SYMBOL_GPL(corgikbd_report_hp);
+
 #ifdef CONFIG_PM
 static int corgikbd_suspend(struct platform_device *dev, pm_message_t state)
 {
@@ -353,6 +370,8 @@ static int __init corgikbd_probe(struct 
 	for (i = 0; i < CORGI_KEY_STROBE_NUM; i++)
 		pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);
 
+	corgikbd_data_ptr = corgikbd;
+
 	return 0;
 }
 
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 21d55ed..2989820 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -95,4 +95,40 @@ config TOUCHSCREEN_HP600
 	  To compile this driver as a module, choose M here: the
 	  module will be called hp680_ts_input.
 
+config TOUCHSCREEN_WM97XX
+	tristate "Support for WM97xx AC97 touchscreen codecs"
+	depends SND_AC97_CODEC
+
+config TOUCHSCREEN_WM9713
+	tristate "WM9713 Touchscreen interface support"
+	depends on TOUCHSCREEN_WM97XX 
+	help
+	  Say Y here if you have the wm9713 touchscreen.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called wm9713.
+	
+config TOUCHSCREEN_WM9705
+	tristate "WM9705/12 Touchscreen interface support"
+	depends on TOUCHSCREEN_WM97XX 
+	help
+	  Say Y here if you have the wm9705/12 touchscreen.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called wm9705.
+	  
+config TOUCHSCREEN_WM97XX_PXA
+	tristate "WM97xx PXA accelerated touch"
+	depends on TOUCHSCREEN_WM97XX && ARCH_PXA
+	help
+	  Say Y here for continuous mode touch on the PXA
+
+	  If unsure, say N
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called pxa-wm97xx
 endif
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 6842869..1d8c1d3 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -11,3 +11,7 @@ obj-$(CONFIG_TOUCHSCREEN_ELO)	+= elo.o
 obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
 obj-$(CONFIG_TOUCHSCREEN_MK712)	+= mk712.o
 obj-$(CONFIG_TOUCHSCREEN_HP600)	+= hp680_ts_input.o
+obj-$(CONFIG_TOUCHSCREEN_WM97XX)    += wm97xx-core.o
+obj-$(CONFIG_TOUCHSCREEN_WM9713)    += wm9713.o
+obj-$(CONFIG_TOUCHSCREEN_WM9705)    += wm9705.o
+obj-$(CONFIG_TOUCHSCREEN_WM97XX_PXA)   += pxa-wm97xx.o
diff --git a/drivers/input/touchscreen/pxa-wm97xx.c b/drivers/input/touchscreen/pxa-wm97xx.c
new file mode 100644
index 0000000..5a90533
--- /dev/null
+++ b/drivers/input/touchscreen/pxa-wm97xx.c
@@ -0,0 +1,292 @@
+/*
+ * pxa-wm97xx.c  --  pxa2xx Continuous Touch screen driver for 
+ *                   Wolfson WM97xx AC97 Codecs.
+ *
+ * Copyright 2004 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ * Parts Copyright : Ian Molton <spyro@f2s.com>
+ *                   Andrew Zabolotny <zap@homelink.ru>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Notes:
+ *     This code uses an API exposed by ac97_plugin_wm97xx to capture touch
+ *     data in a continuous manner on the Intel XScale archictecture
+ * 
+ *  Features:
+ *       - codecs supported:- WM9705, WM9712, WM9713
+ *       - processors supported:- Intel XScale PXA25x, PXA26x, PXA27x
+ *
+ *  Revision history
+ *    18th Aug 2004   Initial version.
+ *    26th Jul 2005   Improved continous read back and added FIFO flushing.
+ * 
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/wm97xx.h>
+#include <asm/io.h>
+#include <asm/arch/pxa-regs.h>
+
+#define TS_NAME			"pxa_wm97xx"
+#define WM_TS_VERSION		"0.11"
+
+#define WM97XX_PXA_SLOT		5
+
+/*
+ * Debug
+ */ 
+#if 0
+#define dbg(format, arg...) printk(KERN_DEBUG TS_NAME ": " format "\n" , ## arg)
+#else	/* 
+ */
+#define dbg(format, arg...)
+#endif	/* 
+ */
+#define err(format, arg...) printk(KERN_ERR TS_NAME ": " format "\n" , ## arg)
+#define info(format, arg...) printk(KERN_INFO TS_NAME ": " format "\n" , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING TS_NAME ": " format "\n" , ## arg)
+
+struct continuous {
+	u16 id;    /* codec id */
+	u8 code;   /* continuous code */
+	u8 reads;  /* number of coord reads per read cycle */
+	u32 speed; /* number of coords per second */
+};
+
+#define WM_READS(sp) ((sp / HZ) + 1)
+
+static const struct continuous cinfo[] = {
+	{WM9705_ID2, 0, WM_READS(94), 94},
+	{WM9705_ID2, 1, WM_READS(188), 188},
+	{WM9705_ID2, 2, WM_READS(375), 375},
+	{WM9705_ID2, 3, WM_READS(750), 750},
+	{WM9712_ID2, 0, WM_READS(94), 94},
+	{WM9712_ID2, 1, WM_READS(188), 188},
+	{WM9712_ID2, 2, WM_READS(375), 375},
+	{WM9712_ID2, 3, WM_READS(750), 750},
+	{WM9713_ID2, 0, WM_READS(94), 94},
+	{WM9713_ID2, 1, WM_READS(120), 120},
+	{WM9713_ID2, 2, WM_READS(154), 154},
+	{WM9713_ID2, 3, WM_READS(188), 188},
+};
+
+/* continuous speed index */
+static int sp_idx = 0;
+
+static struct wm97xx_platform_drv pxa_wm97xx;
+static u16 last = 0, tries = 0;
+
+/*
+ * Pen sampling frequency (Hz) in continuous mode.
+ */
+static int cont_rate = 200;
+module_param(cont_rate, int, 0);
+MODULE_PARM_DESC(cont_rate, "Sampling rate in continuous mode (Hz)");
+
+/*
+ * Pen down detection.
+ * 
+ * This driver can either poll or use an interrupt to indicate a pen down
+ * event. If the irq request fails then it will fall back to polling mode.  
+ */
+static int pen_int = 1;
+module_param(pen_int, int, 0);
+MODULE_PARM_DESC(pen_int, "Pen down detection (1 = interrupt, 0 = polling)");
+
+/*
+ * Pressure readback.
+ * 
+ * Set to 1 to read back pen down pressure 
+ */
+static int pressure = 0;
+module_param(pressure, int, 0);
+MODULE_PARM_DESC(pressure, "Pressure readback (1 = pressure, 0 = no pressure)");
+
+
+/* flush AC97 slot 5 FIFO on pxa machines */
+#ifdef CONFIG_PXA27x
+static void pxa_wm97xx_pen_up (struct wm97xx* wm)
+{
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(1);
+
+	while (MISR & (1 << 2))
+		MODR;
+}
+#else
+static void pxa_wm97xx_pen_up (struct wm97xx* wm)
+{
+	int count = 16;
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(1);
+	
+	while (count < 16) {
+		MODR;
+		count--;
+	}
+}
+#endif
+
+static int pxa_wm97xx_pen_down (struct wm97xx* wm)
+{
+	u16 x, y, p = 0x100 | WM97XX_ADCSEL_PRES;
+	int reads = 0;
+
+	/* data is never immediately available after pen down irq */
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(1);
+	
+	if (tries > 5){
+		tries = 0;
+		return RC_PENUP;
+	}
+	
+	x = MODR;
+	if (x == last) {
+		tries++;
+		return RC_AGAIN;
+	}
+	last = x;
+	do {
+		if (reads)
+			x= MODR;
+		y= MODR;
+		if (pressure)
+			p = MODR;
+
+		/* are samples valid */
+		if ((x & 0x7000) != WM97XX_ADCSEL_X || 
+			(y & 0x7000) != WM97XX_ADCSEL_Y ||
+			(p & 0x7000) != WM97XX_ADCSEL_PRES)
+			goto up;
+		
+		/* coordinate is good */
+		tries = 0;
+		//printk("x %x y %x p %x\n", x,y,p);
+		input_report_abs (wm->input_dev, ABS_X, x & 0xfff);
+		input_report_abs (wm->input_dev, ABS_Y, y & 0xfff);
+		input_report_abs (wm->input_dev, ABS_PRESSURE, p & 0xfff);
+		input_sync (wm->input_dev);
+		reads++;
+	} while (reads < cinfo[sp_idx].reads);
+up:
+	return RC_PENDOWN | RC_AGAIN;
+}
+
+static int pxa_wm97xx_probe(struct wm97xx* wm)
+{
+	int idx = 0;
+    
+	/* check we have a codec */
+	if (wm->ac97 == NULL)
+		return -ENODEV;
+	
+	/* Go you big red fire engine */
+	for (idx = 0; idx < ARRAY_SIZE(cinfo); idx++) {
+		if (wm->id != cinfo[idx].id)
+			continue;
+		sp_idx = idx;
+		if (cont_rate <= cinfo[idx].speed)
+			break;
+	}
+	pxa_wm97xx.acc_rate = cinfo[sp_idx].code;
+	info("pxa2xx accelerated touchscreen driver, %d samples (sec)", cinfo[sp_idx].speed);
+	  
+	/* codec specific irq config */
+	if (pen_int) {
+		switch (wm->id) {
+			case WM9705_ID2:
+				wm97xx_request_pen_irq(wm, IRQ_GPIO(4));
+				set_irq_type(IRQ_GPIO(4), IRQT_BOTHEDGE);
+				break;
+			case WM9712_ID2:
+			case WM9713_ID2:
+				/* enable pen down interrupt */
+				/* use PEN_DOWN GPIO 13 to assert IRQ on GPIO line 2 */
+				if (wm97xx_request_pen_irq(wm, MAINSTONE_AC97_IRQ) == 0) {
+					wm97xx_config_gpio(wm, WM97XX_GPIO_13, WM97XX_GPIO_IN,
+						WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_STICKY, WM97XX_GPIO_WAKE);
+					wm97xx_config_gpio(wm, WM97XX_GPIO_2, WM97XX_GPIO_OUT,
+						WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_NOTSTICKY, WM97XX_GPIO_NOWAKE);
+				} else
+					pen_int = 0;
+				break;
+			default:
+				warn("pen down irq not supported on this device");
+				pen_int = 0;
+				break;
+		}
+	}
+	return 0;
+}
+
+static void pxa_wm97xx_remove(struct wm97xx* wm)
+{
+    /* codec specific deconfig */
+	if (pen_int) {
+		switch (wm->id & 0xffff) {
+			case WM9705_ID2:
+				wm97xx_free_pen_irq(wm);
+				break;
+			case WM9712_ID2:
+			case WM9713_ID2:
+				/* disable interrupt */
+				wm97xx_free_pen_irq(wm);
+				break;
+		}
+	}
+}
+
+static struct wm97xx_platform_drv pxa_wm97xx = {
+	.id = 0x4c00,
+	.mask = 0xff00,
+	.acc_slot = WM97XX_PXA_SLOT,
+	.acc_pen_down = pxa_wm97xx_pen_down,
+	.acc_pen_up = pxa_wm97xx_pen_up,
+	.probe = pxa_wm97xx_probe,
+	.remove = pxa_wm97xx_remove,
+};
+
+static int __init pxa_wm97xx_ts_init(void)
+{
+	wm97xx_register_platform_drv(&pxa_wm97xx);
+	return 0;
+}
+
+static void __exit pxa_wm97xx_ts_exit(void)
+{
+	wm97xx_unregister_platform_drv(&pxa_wm97xx);
+}
+
+/* Module information */
+MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>");
+MODULE_DESCRIPTION("wm97xx continuous touch driver for pxa2xx");
+MODULE_LICENSE("GPL");
+
+module_init(pxa_wm97xx_ts_init);
+module_exit(pxa_wm97xx_ts_exit);
diff --git a/drivers/input/touchscreen/wm9705.c b/drivers/input/touchscreen/wm9705.c
new file mode 100644
index 0000000..da31fb8
--- /dev/null
+++ b/drivers/input/touchscreen/wm9705.c
@@ -0,0 +1,359 @@
+/*
+ * wm9705.c  --  Codec driver for Wolfson WM9705 AC97 Codec.
+ *
+ * Copyright 2003, 2004, 2005 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ * Parts Copyright : Ian Molton <spyro@f2s.com>
+ *                   Andrew Zabolotny <zap@homelink.ru>
+ *                   Russell King <rmk@arm.linux.org.uk>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/bitops.h>
+#include <linux/wm97xx.h>
+
+#define TS_NAME			"wm97xx"
+#define WM9705_VERSION		"0.60"
+#define DEFAULT_PRESSURE	0xb0c0
+
+/*
+ * Debug
+ */
+#if 0
+#define dbg(format, arg...) printk(KERN_DEBUG TS_NAME ": " format "\n" , ## arg)
+#else
+#define dbg(format, arg...)
+#endif
+#define err(format, arg...) printk(KERN_ERR TS_NAME ": " format "\n" , ## arg)
+#define info(format, arg...) printk(KERN_INFO TS_NAME ": " format "\n" , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING TS_NAME ": " format "\n" , ## arg)
+
+/*
+ * Module parameters
+ */
+
+/*
+ * Set internal pull up for pen detect.
+ *
+ * Pull up is in the range 1.02k (least sensitive) to 64k (most sensitive)
+ * i.e. pull up resistance = 64k Ohms / rpu.
+ *
+ * Adjust this value if you are having problems with pen detect not
+ * detecting any down evenwm->
+ */
+static int rpu;
+module_param(rpu, int, 0);
+MODULE_PARM_DESC(rpu, "Set internal pull up resitor for pen detect.");
+
+/*
+ * Set current used for pressure measurement.
+ *
+ * Set pil = 2 to use 400uA
+ *     pil = 1 to use 200uA and
+ *     pil = 0 to disable pressure measurement.
+ *
+ * This is used to increase the range of values returned by the adc
+ * when measureing touchpanel pressure.
+ */
+static int pil = 0;
+module_param(pil, int, 0);
+MODULE_PARM_DESC(pil, "Set current used for pressure measurement.");
+
+/*
+ * Set threshold for pressure measurement.
+ *
+ * Pen down pressure below threshold is ignored.
+ */
+static int pressure = DEFAULT_PRESSURE & 0xfff;
+module_param(pressure, int, 0);
+MODULE_PARM_DESC(pressure, "Set threshold for pressure measurement.");
+
+/*
+ * Set adc sample delay.
+ *
+ * For accurate touchpanel measurements, some settling time may be
+ * required between the switch matrix applying a voltage across the
+ * touchpanel plate and the ADC sampling the signal.
+ *
+ * This delay can be set by setting delay = n, where n is the array
+ * position of the delay in the array delay_table below.
+ * Long delays > 1ms are supported for completeness, but are not
+ * recommended.
+ */
+static int delay = 4;
+module_param(delay, int, 0);
+MODULE_PARM_DESC(delay, "Set adc sample delay.");
+
+/*
+ * Pen detect comparator threshold.
+ *
+ * 0 to Vmid in 15 steps, 0 = use zero power comparator with Vmid threshold
+ * i.e. 1 =  Vmid/15 threshold
+ *      15 =  Vmid/1 threshold
+ *
+ * Adjust this value if you are having problems with pen detect not
+ * detecting any down events.
+ */
+static int pdd = 8;
+module_param(pdd, int, 0);
+MODULE_PARM_DESC(pdd, "Set pen detect comparator threshold");
+
+
+/*
+ * ADC sample delay times in uS
+ */
+static const int delay_table[] = {
+	21,    // 1 AC97 Link frames
+	42,    // 2
+	84,    // 4
+	167,   // 8
+	333,   // 16
+	667,   // 32
+	1000,  // 48
+	1333,  // 64
+	2000,  // 96
+	2667,  // 128
+	3333,  // 160
+	4000,  // 192
+	4667,  // 224
+	5333,  // 256
+	6000,  // 288
+	0      // No delay, switch matrix always on
+};
+
+/*
+ * Delay after issuing a POLL command.
+ *
+ * The delay is 3 AC97 link frames + the touchpanel settling delay
+ */
+static inline void poll_delay(int d)
+{
+	udelay (3 * AC97_LINK_FRAME + delay_table [d]);
+}
+
+/*
+ * set up the physical settings of the WM9705
+ */
+static void init_wm9705_phy(struct wm97xx* wm)
+{
+	wm->dig1 = 0;
+	wm->dig2 = WM97XX_RPR;
+	
+	/*
+	* mute VIDEO and AUX as they share X and Y touchscreen
+	* inputs on the WM9705 
+	*/
+	wm97xx_reg_write(wm, AC97_AUX, 0x8000);
+	wm97xx_reg_write(wm, AC97_VIDEO, 0x8000);
+	
+	/* touchpanel pressure current*/
+	if  (pil == 2) {
+		wm->dig2 |= WM9705_PIL;
+		dbg("setting pressure measurement current to 400uA.");
+	} else if (pil) 
+		dbg("setting pressure measurement current to 200uA.");
+	if(!pil)
+		pressure = 0;
+	
+	/* polling mode sample settling delay */
+	if (delay!=4) {
+		if (delay < 0 || delay > 15) {
+		    dbg("supplied delay out of range.");
+		    delay = 4;
+		}
+	}
+	wm->dig1 &= 0xff0f;
+	wm->dig1 |= WM97XX_DELAY(delay);
+	dbg("setting adc sample delay to %d u Secs.", delay_table[delay]);
+	
+	/* WM9705 pdd */
+	wm->dig2 |= (pdd & 0x000f);
+	dbg("setting pdd to Vmid/%d", 1 - (pdd & 0x000f));
+	
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, wm->dig1);
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig2);     
+}
+
+static void wm97xx_digitiser_ioctl(struct wm97xx* wm, int cmd)
+{
+	u16 val = 0;
+	
+	switch(cmd) {
+	case WM97XX_DIG_START:
+		val = wm->dig2 | WM97XX_PRP_DET_DIG;
+		wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig2 = val);
+		wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); /* dummy read */
+		break;
+	case WM97XX_DIG_STOP:
+		val = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER2);
+		wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, val & ~WM97XX_PRP_DET_DIG);
+		break;
+	case WM97XX_DIG_SAVE:
+		wm->dig1 = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER1);
+		wm->dig2 = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER2);
+		break;
+	case WM97XX_DIG_RESTORE:
+		wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, wm->dig1);
+		wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig2);
+		break;
+	case WM97XX_AUX_PREPARE:
+		wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, 0);
+		wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, WM97XX_PRP_DET_DIG);
+		break;
+	case WM97XX_PHY_INIT:
+		init_wm9705_phy(wm);
+		break;
+	}
+}
+
+static inline int is_pden (struct wm97xx* wm)
+{
+	return wm->dig2 & WM9705_PDEN;
+}
+
+/*
+ * Read a sample from the WM9705 adc in polling mode.
+ */
+static int wm9705_poll_sample (struct wm97xx* wm, int adcsel, int *sample)
+{
+	int timeout = 5 * delay;
+	
+	if (!wm->pen_probably_down) {
+		u16 data = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
+		if (!(data & WM97XX_PEN_DOWN))
+			return RC_PENUP;
+		wm->pen_probably_down = 1;
+	}
+	
+	/* set up digitiser */
+	if (adcsel & 0x8000)
+		adcsel = ((adcsel & 0x7fff) + 3) << 12;
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, adcsel | WM97XX_POLL | WM97XX_DELAY(delay));
+	
+	/* wait 3 AC97 time slots + delay for conversion */
+	poll_delay (delay);
+	
+	/* wait for POLL to go low */
+	while ((wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER1) & WM97XX_POLL) && timeout) {
+		udelay(AC97_LINK_FRAME);
+		timeout--;
+	}
+	
+	if (timeout <= 0) {
+		/* If PDEN is set, we can get a timeout when pen goes up */
+		if (is_pden(wm))
+			wm->pen_probably_down = 0;
+		else
+			dbg ("adc sample timeout");
+		return 0;
+	}
+	
+	*sample = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
+	
+	/* check we have correct sample */
+	if ((*sample & WM97XX_ADCSEL_MASK) != adcsel) {
+		dbg ("adc wrong sample, read %x got %x", adcsel,
+		*sample & WM97XX_ADCSEL_MASK);
+		return 0;
+	}
+	
+	if (!(*sample & WM97XX_PEN_DOWN)) {
+		wm->pen_probably_down = 0;
+		return RC_PENUP;
+	}
+	
+	return RC_VALID;
+}
+
+/*
+ * Sample the WM9713 touchscreen in polling mode
+ */
+static int wm9705_poll_touch(struct wm97xx* wm, struct wm97xx_data *data)
+{
+	int rc;
+	
+	if ((rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_X, &data->x)) != RC_VALID)
+		return rc;
+	if ((rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_Y, &data->y)) != RC_VALID)
+		return rc;
+	if (pil && !five_wire) {
+		if ((rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_PRES, &data->p)) != RC_VALID)
+			return rc;
+	} else
+		data->p = DEFAULT_PRESSURE;
+	
+	return RC_VALID;
+}
+
+/*
+ * Enable WM9705 continuous mode, i.e. touch data is streamed across an AC97 slot
+ */
+static void wm9705_acc_enable (struct wm97xx* wm, int enable)
+{
+	u16 dig1, dig2;
+	
+	dig1 = wm->dig1;
+	dig2 = wm->dig2;
+	
+	if (enable) {
+		/* continous mode */
+		dbg("Enabling continous mode");
+		dig1 &= ~(WM97XX_CM_RATE_MASK | WM97XX_ADCSEL_MASK |
+			WM97XX_DELAY_MASK | WM97XX_SLT_MASK);
+		dig1 |= WM97XX_CTC | WM97XX_COO | WM97XX_SLEN |
+			WM97XX_DELAY (delay) |
+			WM97XX_SLT (wm->acc->acc_slot) |
+			WM97XX_RATE (wm->acc->acc_rate);
+		if (pil)
+			dig1 |= WM97XX_ADCSEL_PRES;
+		dig2 |= WM9705_PDEN;
+	} else {
+		dig1 &= ~(WM97XX_CTC | WM97XX_COO | WM97XX_SLEN);
+		dig2 &= ~WM9705_PDEN;
+	}
+	
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, wm->dig1 = dig1);
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig2 = dig2);
+}
+
+struct wm97xx_codec_drv wm97xx_codec = {
+	.id = 	WM9705_ID2,
+	.poll_sample = wm9705_poll_sample,
+	.poll_touch = wm9705_poll_touch,
+	.acc_enable = wm9705_acc_enable,
+	.digitiser_ioctl = wm9705_digitiser_ioctl,
+};
+
+EXPORT_SYMBOL_GPL(wm97xx_codec);
+
+/* Module information */
+MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("WM9705 Touch Screen Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/wm9712.c b/drivers/input/touchscreen/wm9712.c
new file mode 100644
index 0000000..d6db229
--- /dev/null
+++ b/drivers/input/touchscreen/wm9712.c
@@ -0,0 +1,340 @@
+/*
+ * wm9712.c  --  Codec driver for Wolfson WM9712 AC97 Codecs.
+ *
+ * Copyright 2003, 2004, 2005 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ * Parts Copyright : Ian Molton <spyro@f2s.com>
+ *                   Andrew Zabolotny <zap@homelink.ru>
+ *                   Russell King <rmk@arm.linux.org.uk>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/bitops.h>
+#include <linux/wm97xx.h>
+
+#define TS_NAME			"wm97xx"
+#define WM9705_VERSION		"0.60"
+#define DEFAULT_PRESSURE	0xb0c0
+
+/*
+ * Debug
+ */
+#if 0
+#define dbg(format, arg...) printk(KERN_DEBUG TS_NAME ": " format "\n" , ## arg)
+#else
+#define dbg(format, arg...)
+#endif
+#define err(format, arg...) printk(KERN_ERR TS_NAME ": " format "\n" , ## arg)
+#define info(format, arg...) printk(KERN_INFO TS_NAME ": " format "\n" , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING TS_NAME ": " format "\n" , ## arg)
+
+/*
+ * Module parameters
+ */
+
+/*
+ * Set current used for pressure measurement.
+ *
+ * Set pil = 2 to use 400uA
+ *     pil = 1 to use 200uA and
+ *     pil = 0 to disable pressure measurement.
+ *
+ * This is used to increase the range of values returned by the adc
+ * when measureing touchpanel pressure.
+ */
+static int pil = 0;
+module_param(pil, int, 0);
+MODULE_PARM_DESC(pil, "Set current used for pressure measurement.");
+
+/*
+ * Set threshold for pressure measurement.
+ *
+ * Pen down pressure below threshold is ignored.
+ */
+static int pressure = DEFAULT_PRESSURE & 0xfff;
+module_param(pressure, int, 0);
+MODULE_PARM_DESC(pressure, "Set threshold for pressure measurement.");
+
+/*
+ * Set adc sample delay.
+ *
+ * For accurate touchpanel measurements, some settling time may be
+ * required between the switch matrix applying a voltage across the
+ * touchpanel plate and the ADC sampling the signal.
+ *
+ * This delay can be set by setting delay = n, where n is the array
+ * position of the delay in the array delay_table below.
+ * Long delays > 1ms are supported for completeness, but are not
+ * recommended.
+ */
+static int delay = 4;
+module_param(delay, int, 0);
+MODULE_PARM_DESC(delay, "Set adc sample delay.");
+
+/*
+ * Set five_wire = 1 to use a 5 wire touchscreen.
+ *
+ * NOTE: Five wire mode does not allow for readback of pressure.
+ */
+static int five_wire;
+module_param(five_wire, int, 0);
+MODULE_PARM_DESC(five_wire, "Set to '1' to use 5-wire touchscreen.");
+
+/*
+ * ADC sample delay times in uS
+ */
+static const int delay_table[] = {
+	21,    // 1 AC97 Link frames
+	42,    // 2
+	84,    // 4
+	167,   // 8
+	333,   // 16
+	667,   // 32
+	1000,  // 48
+	1333,  // 64
+	2000,  // 96
+	2667,  // 128
+	3333,  // 160
+	4000,  // 192
+	4667,  // 224
+	5333,  // 256
+	6000,  // 288
+	0      // No delay, switch matrix always on
+};
+
+/*
+ * Delay after issuing a POLL command.
+ *
+ * The delay is 3 AC97 link frames + the touchpanel settling delay
+ */
+static inline void poll_delay(int d)
+{
+	udelay (3 * AC97_LINK_FRAME + delay_table [d]);
+}
+
+/*
+ * set up the physical settings of the WM9712
+ */
+static void init_wm9712_phy(struct wm97xx* wm)
+{
+	wm->dig1 = 0;
+	wm->dig2 = WM97XX_RPR | WM9712_RPU(1);
+	
+	/* WM9712 rpu */
+	if (rpu) {
+		wm->dig2 &= 0xffc0;
+		wm->dig2 |= WM9712_RPU(rpu);
+		dbg("setting pen detect pull-up to %d Ohms",64000 / rpu);
+	}
+	
+	/* touchpanel pressure current*/
+	if  (pil == 2) {
+		wm->dig2 |= WM9712_PIL;
+		dbg("setting pressure measurement current to 400uA.");
+	} else if (pil) 
+		dbg("setting pressure measurement current to 200uA.");
+	if(!pil)
+		pressure = 0;
+	
+	/* WM9712 five wire */
+	if (five_wire) {
+		wm->dig2 |= WM9712_45W;
+		dbg("setting 5-wire touchscreen mode.");
+	}
+	
+	/* polling mode sample settling delay */
+	if (delay!=4) {
+		if (delay < 0 || delay > 15) {
+		    dbg("supplied delay out of range.");
+		    delay = 4;
+		}
+	}
+	wm->dig1 &= 0xff0f;
+	wm->dig1 |= WM97XX_DELAY(delay);
+	dbg("setting adc sample delay to %d u Secs.", delay_table[delay]);
+	
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, wm->dig1);
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig2);     
+}
+
+static void wm9712_digitiser_ioctl(struct wm97xx* wm, int cmd)
+{
+	u16 val = 0;
+	
+	switch(cmd) {
+		case WM97XX_DIG_START:
+			val = wm->dig2 | WM97XX_PRP_DET_DIG;
+			wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig2 = val);
+			wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); /* dummy read */
+			break;
+		case WM97XX_DIG_STOP:
+			val = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER2);
+			wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, val & ~WM97XX_PRP_DET_DIG);
+			break;
+		case WM97XX_DIG_SAVE:
+			wm->dig1 = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER1);
+			wm->dig2 = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER2);
+			break;
+		case WM97XX_DIG_RESTORE:
+			wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, wm->dig1);
+			wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig2);
+			break;
+		case WM97XX_AUX_PREPARE:
+			wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, 0);
+			wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, WM97XX_PRP_DET_DIG);
+			break;
+		case WM97XX_PHY_INIT:
+			init_wm9712_phy(wm);
+			break;
+	}
+}
+
+static inline int is_pden (struct wm97xx* wm)
+{
+	return wm->dig2 & WM9712_PDEN;
+}
+
+/*
+ * Read a sample from the WM9712 adc in polling mode.
+ */
+static int wm9712_poll_sample (struct wm97xx* wm, int adcsel, int *sample)
+{
+	int timeout = 5 * delay;
+	
+	if (!wm->pen_probably_down) {
+		u16 data = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
+		if (!(data & WM97XX_PEN_DOWN))
+			return RC_PENUP;
+		wm->pen_probably_down = 1;
+	}
+	
+	/* set up digitiser */
+	if (adcsel & 0x8000)
+		adcsel = ((adcsel & 0x7fff) + 3) << 12;
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, adcsel | WM97XX_POLL | WM97XX_DELAY(delay));
+	
+	/* wait 3 AC97 time slots + delay for conversion */
+	poll_delay (delay);
+	
+	/* wait for POLL to go low */
+	while ((wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER1) & WM97XX_POLL) && timeout) {
+		udelay(AC97_LINK_FRAME);
+		timeout--;
+	}
+	
+	if (timeout <= 0) {
+		/* If PDEN is set, we can get a timeout when pen goes up */
+		if (is_pden(wm))
+			wm->pen_probably_down = 0;
+		else
+			dbg ("adc sample timeout");
+		return 0;
+	}
+	
+	*sample = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
+	
+	/* check we have correct sample */
+	if ((*sample & WM97XX_ADCSEL_MASK) != adcsel) {
+		dbg ("adc wrong sample, read %x got %x", adcsel,
+		*sample & WM97XX_ADCSEL_MASK);
+		return 0;
+	}
+	
+	if (!(*sample & WM97XX_PEN_DOWN)) {
+		wm->pen_probably_down = 0;
+		return RC_PENUP;
+	}
+	
+	return RC_VALID;
+}
+
+/*
+ * Sample the WM9712 touchscreen in polling mode
+ */
+static int wm9712_poll_touch(struct wm97xx* wm, struct wm97xx_data *data)
+{
+	int rc;
+	
+	if ((rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_X, &data->x)) != RC_VALID)
+		return rc;
+	if ((rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_Y, &data->y)) != RC_VALID)
+		return rc;
+	if (pil && !five_wire) {
+		if ((rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_PRES, &data->p)) != RC_VALID)
+			return rc;
+	} else
+		data->p = DEFAULT_PRESSURE;
+	
+	return RC_VALID;
+}
+
+/*
+ * Enable WM9712 continuous mode, i.e. touch data is streamed across an AC97 slot
+ */
+static void wm9712_acc_enable (struct wm97xx* wm, int enable)
+{
+	u16 dig1, dig2;
+	
+	dig1 = wm->dig1;
+	dig2 = wm->dig2;
+	
+	if (enable) {
+		/* continous mode */
+		dbg("Enabling continous mode");
+		dig1 &= ~(WM97XX_CM_RATE_MASK | WM97XX_ADCSEL_MASK |
+			WM97XX_DELAY_MASK | WM97XX_SLT_MASK);
+		dig1 |= WM97XX_CTC | WM97XX_COO | WM97XX_SLEN |
+			WM97XX_DELAY (delay) |
+			WM97XX_SLT (wm->acc->acc_slot) |
+			WM97XX_RATE (wm->acc->acc_rate);
+		if (pil)
+			dig1 |= WM97XX_ADCSEL_PRES;
+		dig2 |= WM9712_PDEN;
+	} else {
+		dig1 &= ~(WM97XX_CTC | WM97XX_COO | WM97XX_SLEN);
+		dig2 &= ~WM9712_PDEN;
+	}
+	
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, wm->dig1 = dig1);
+	wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig2 = dig2);
+}
+
+struct wm97xx_codec_drv wm97xx_codec = {
+	.id = 	WM9712_ID2,
+	.poll_sample = wm9712_poll_sample,
+	.poll_touch = wm9712_poll_touch,
+	.acc_enable = wm9712_acc_enable,
+	.digitiser_ioctl = wm9712_digitiser_ioctl,
+};
+
+/* Module information */
+MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("WM9712 Touch Screen Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/wm9713.c b/drivers/input/touchscreen/wm9713.c
new file mode 100644
index 0000000..22ebc7b
--- /dev/null
+++ b/drivers/input/touchscreen/wm9713.c
@@ -0,0 +1,356 @@
+/*
+ * wm9713.c  --  Codec driver for Wolfson WM9713 AC97 Codec.
+ *
+ * Copyright 2003, 2004, 2005 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ * Parts Copyright : Ian Molton <spyro@f2s.com>
+ *                   Andrew Zabolotny <zap@homelink.ru>
+ *                   Russell King <rmk@arm.linux.org.uk>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAand/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/bitops.h>
+#include <linux/wm97xx.h>
+
+#define TS_NAME			"wm97xx"
+#define WM9713_VERSION		"0.50"
+#define DEFAULT_PRESSURE	0xb0c0
+
+/*
+ * Debug
+ */
+#if 0
+#define dbg(format, arg...) printk(KERN_DEBUG TS_NAME ": " format "\n" , ## arg)
+#else
+#define dbg(format, arg...)
+#endif
+#define err(format, arg...) printk(KERN_ERR TS_NAME ": " format "\n" , ## arg)
+#define info(format, arg...) printk(KERN_INFO TS_NAME ": " format "\n" , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING TS_NAME ": " format "\n" , ## arg)
+
+/*
+ * Module parameters
+ */
+
+/*
+ * WM9713 - Set internal pull up for pen detect.
+ *
+ * Pull up is in the range 1.02k (least sensitive) to 64k (most sensitive)
+ * i.e. pull up resistance = 64k Ohms / rpu.
+ *
+ * Adjust this value if you are having problems with pen detect not
+ * detecting any down evenwm->
+ */
+static int rpu;
+module_param(rpu, int, 0);
+MODULE_PARM_DESC(rpu, "Set internal pull up resitor for pen detect.");
+
+/*
+ * Set current used for pressure measurement.
+ *
+ * Set pil = 2 to use 400uA
+ *     pil = 1 to use 200uA and
+ *     pil = 0 to disable pressure measurement.
+ *
+ * This is used to increase the range of values returned by the adc
+ * when measureing touchpanel pressure.
+ */
+static int pil = 0;
+module_param(pil, int, 0);
+MODULE_PARM_DESC(pil, "Set current used for pressure measurement.");
+
+/*
+ * Set threshold for pressure measurement.
+ *
+ * Pen down pressure below threshold is ignored.
+ */
+static int pressure = DEFAULT_PRESSURE & 0xfff;
+module_param(pressure, int, 0);
+MODULE_PARM_DESC(pressure, "Set threshold for pressure measurement.");
+
+/*
+ * Set adc sample delay.
+ *
+ * For accurate touchpanel measurements, some settling time may be
+ * required between the switch matrix applying a voltage across the
+ * touchpanel plate and the ADC sampling the signal.
+ *
+ * This delay can be set by setting delay = n, where n is the array
+ * position of the delay in the array delay_table below.
+ * Long delays > 1ms are supported for completeness, but are not
+ * recommended.
+ */
+static int delay = 4;
+module_param(delay, int, 0);
+MODULE_PARM_DESC(delay, "Set adc sample delay.");
+
+/*
+ * ADC sample delay times in uS
+ */
+static const int delay_table[] = {
+	21,    // 1 AC97 Link frames
+	42,    // 2
+	84,    // 4
+	167,   // 8
+	333,   // 16
+	667,   // 32
+	1000,  // 48
+	1333,  // 64
+	2000,  // 96
+	2667,  // 128
+	3333,  // 160
+	4000,  // 192
+	4667,  // 224
+	5333,  // 256
+	6000,  // 288
+	0      // No delay, switch matrix always on
+};
+
+/*
+ * Delay after issuing a POLL command.
+ *
+ * The delay is 3 AC97 link frames + the touchpanel settling delay
+ */
+static inline void poll_delay(int d)
+{
+	udelay (3 * AC97_LINK_FRAME + delay_table [d]);
+}
+
+/*
+ * set up the physical settings of the WM9713 
+ */
+static void init_wm9713_phy(struct wm97xx* wm)
+{
+	u16 dig1 = 0, dig2, dig3;
+	
+	/* default values */
+	dig2 = WM97XX_DELAY(4) | WM97XX_SLT(5);
+	dig3= WM9712_RPU(1);
+      
+	/* rpu */
+	if (rpu) {
+		dig3 &= 0xffc0;
+		dig3 |= WM9712_RPU(rpu);
+		info("setting pen detect pull-up to %d Ohms",64000 / rpu);
+	}
+      
+	/* touchpanel pressure */
+	if (pil == 2) {
+		dig3 |= WM9712_PIL;
+		info("setting pressure measurement current to 400uA.");
+	} else if (pil) 
+		info ("setting pressure measurement current to 200uA.");
+	if(!pil)
+		pressure = 0;
+      
+	/* sample settling delay */
+	if (delay!=4) {
+		if (delay < 0 || delay > 15) {
+			info ("supplied delay out of range.");
+			delay = 4;
+			info("setting adc sample delay to %d u Secs.", delay_table[delay]);
+		}
+	}
+	dig2 &= 0xff0f;
+	dig2 |= WM97XX_DELAY(delay);
+
+	wm97xx_reg_write(wm, AC97_WM9713_DIG1, wm->dig1 = dig1);
+	wm97xx_reg_write(wm, AC97_WM9713_DIG2, wm->dig2 = dig2);
+	wm97xx_reg_write(wm, AC97_WM9713_DIG3, wm->dig3 = dig3);
+	wm97xx_reg_write(wm, AC97_GPIO_STICKY, 0x0);
+}
+
+static void wm9713_digitiser_ioctl(struct wm97xx* wm, int cmd)
+{
+	u16 val = 0;
+	
+	switch(cmd){
+	case WM97XX_DIG_START:	
+		val = wm97xx_reg_read(wm, AC97_EXTENDED_MID);
+		wm97xx_reg_write(wm, AC97_EXTENDED_MID, val & 0x7fff);
+		val = wm97xx_reg_read(wm, AC97_WM9713_DIG3);
+		wm97xx_reg_write(wm, AC97_WM9713_DIG3, val | WM97XX_PRP_DET_DIG);
+		wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); /* dummy read */
+		break;
+	case WM97XX_DIG_STOP:
+		val = wm97xx_reg_read(wm, AC97_WM9713_DIG3);
+		wm97xx_reg_write(wm, AC97_WM9713_DIG3, val & ~WM97XX_PRP_DET_DIG);
+		val = wm97xx_reg_read(wm, AC97_EXTENDED_MID);
+		wm97xx_reg_write(wm, AC97_EXTENDED_MID, val | 0x8000);
+		break;
+	case WM97XX_DIG_SAVE:
+		wm->dig1 =wm97xx_reg_read(wm, AC97_WM9713_DIG1);
+		wm->dig2 =wm97xx_reg_read(wm, AC97_WM9713_DIG2);
+		wm->dig3 =wm97xx_reg_read(wm, AC97_WM9713_DIG3);
+		break;
+	case WM97XX_DIG_RESTORE:
+		wm97xx_reg_write(wm, AC97_WM9713_DIG1, wm->dig1);
+		wm97xx_reg_write(wm, AC97_WM9713_DIG2, wm->dig2);
+		wm97xx_reg_write(wm, AC97_WM9713_DIG3, wm->dig3);
+		break;
+	case WM97XX_AUX_PREPARE:
+		wm97xx_reg_write(wm, AC97_WM9713_DIG1, 0);
+		wm97xx_reg_write(wm, AC97_WM9713_DIG2, 0);
+		wm97xx_reg_write(wm, AC97_WM9713_DIG3, WM97XX_PRP_DET_DIG);
+		break;
+	case WM97XX_PHY_INIT:
+		init_wm9713_phy(wm);
+		break;
+	}
+}
+
+static inline int is_pden (struct wm97xx* wm)
+{
+	return wm->dig3 & WM9713_PDEN;
+}
+
+/*
+ * Read a sample from the WM9713 adc in polling mode.
+ */
+static int wm9713_poll_sample (struct wm97xx* wm, int adcsel, int *sample)
+{
+	u16 dig1;
+	int timeout = 5 * delay;
+
+	if (!wm->pen_probably_down) {
+		u16 data = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
+		if (!(data & WM97XX_PEN_DOWN))
+			return RC_PENUP;
+		wm->pen_probably_down = 1;
+	}
+
+	/* set up digitiser */
+	if (adcsel & 0x8000)
+		adcsel = 1 << ((adcsel & 0x7fff) + 3);
+	
+	dig1 = wm97xx_reg_read(wm, AC97_WM9713_DIG1);
+	dig1 &= ~WM9713_ADCSEL_MASK; 
+	wm97xx_reg_write(wm, AC97_WM9713_DIG1, dig1 | adcsel |WM9713_POLL); 
+
+	/* wait 3 AC97 time slots + delay for conversion */
+	poll_delay(delay);
+
+	/* wait for POLL to go low */
+	while ((wm97xx_reg_read(wm, AC97_WM9713_DIG1) & WM9713_POLL) && timeout) {
+		udelay(AC97_LINK_FRAME);
+		timeout--;
+	}
+	
+	if (timeout <= 0) {
+		/* If PDEN is set, we can get a timeout when pen goes up */
+		if (is_pden (wm))
+			wm->pen_probably_down = 0;
+		else
+			dbg ("adc sample timeout");
+		return RC_PENUP;
+	}
+	*sample =wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
+
+	/* check we have correct sample */
+	if ((*sample & WM97XX_ADCSRC_MASK) != generic_ffs(adcsel >> 1) << 12) {
+		dbg ("adc wrong sample, read %x got %x", adcsel,
+		     *sample & WM97XX_ADCSRC_MASK);
+		return RC_PENUP;
+	}
+
+	if (!(*sample & WM97XX_PEN_DOWN)) {
+		wm->pen_probably_down = 0;
+		return RC_PENUP;
+	}
+
+	return RC_VALID;
+}
+
+/*
+ * Sample the WM9713 touchscreen in polling mode
+ */
+static int wm9713_poll_touch(struct wm97xx* wm, struct wm97xx_data *data)
+{
+	int rc;
+
+	if ((rc = wm9713_poll_sample(wm, WM9713_ADCSEL_X, &data->x)) != RC_VALID)
+		return rc;
+	if ((rc = wm9713_poll_sample(wm, WM9713_ADCSEL_Y, &data->y)) != RC_VALID)
+		return rc;
+	if (pil) {
+		if ((rc = wm9713_poll_sample(wm, WM9713_ADCSEL_PRES, &data->p)) != RC_VALID)
+			return rc;
+	} else
+		data->p = DEFAULT_PRESSURE;
+
+	return RC_VALID;
+}
+
+/*
+ * Enable WM9713 continuous mode, i.e. touch data is streamed across an AC97 slot
+ */
+static void wm9713_acc_enable (struct wm97xx* wm, int enable)
+{
+	u16 dig1, dig2, dig3;
+
+	dig1 = wm->dig1;
+	dig2 = wm->dig2;
+	dig3 = wm->dig3;
+
+	if (enable) {
+		/* continous mode */
+		dig1 &= ~WM9713_ADCSEL_MASK;
+		dig1 |= WM9713_CTC | WM9713_COO | WM9713_ADCSEL_X | WM9713_ADCSEL_Y; 
+        if (pil)
+		dig1 |= WM9713_ADCSEL_PRES;
+		dig2 &= ~(WM97XX_DELAY_MASK | WM97XX_SLT_MASK  | WM97XX_CM_RATE_MASK);
+		//dig2 |= WM97XX_SLEN | WM97XX_DELAY (delay) | 
+		//WM97XX_SLT (wm->acc->acc_slot) | WM97XX_RATE (wm->acc->acc_rate);
+		dig3 |= WM9713_PDEN;
+	} else {
+		dig1 &= ~(WM9713_CTC | WM9713_COO);
+		dig2 &= ~WM97XX_SLEN;
+		dig3 &= ~WM9713_PDEN;
+	}
+
+	wm97xx_reg_write(wm, AC97_WM9713_DIG1, wm->dig1 = dig1);
+	wm97xx_reg_write(wm, AC97_WM9713_DIG2, wm->dig2 = dig2);
+	wm97xx_reg_write(wm, AC97_WM9713_DIG3, wm->dig3 = dig3);
+}
+
+struct wm97xx_codec_drv wm97xx_codec = {
+	.id = 	WM9713_ID2,
+	.poll_sample = wm9713_poll_sample,
+	.poll_touch = wm9713_poll_touch,
+	.acc_enable = wm9713_acc_enable,
+	.digitiser_ioctl = wm9713_digitiser_ioctl,
+};
+
+EXPORT_SYMBOL_GPL(wm97xx_codec);
+
+/* Module information */
+MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("WM9713 Touch Screen Driver");
+MODULE_LICENSE("GPL");
+
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
new file mode 100644
index 0000000..29d346e
--- /dev/null
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -0,0 +1,767 @@
+/*
+ * wm97xx-core.c  --  Touch screen driver core for Wolfson WM9705, WM9712
+ *                           and WM9713 AC97 Codecs.
+ *
+ * Copyright 2003, 2004, 2005 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ * Parts Copyright : Ian Molton <spyro@f2s.com>
+ *                   Andrew Zabolotny <zap@homelink.ru>
+ *                   Russell King <rmk@arm.linux.org.uk>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Notes:
+ *
+ *  Features:
+ *       - supports WM9705, WM9712, WM9713
+ *       - polling mode
+ *       - continuous mode (arch-dependent)
+ *       - adjustable rpu/dpp settings
+ *       - adjustable pressure current
+ *       - adjustable sample settle delay
+ *       - 4 and 5 wire touchscreens (5 wire is WM9712 only)
+ *       - pen down detection
+ *       - battery monitor
+ *       - sample AUX adc's
+ *       - power management
+ *       - codec GPIO
+ *       - codec event notification
+ * Todo
+ *       - Support for async sampling control for noisy LCD's.
+ *
+ *  Revision history
+ *    7th May 2003   Initial version.
+ *    6th June 2003  Added non module support and AC97 registration.
+ *   18th June 2003  Added AUX adc sampling.
+ *   23rd June 2003  Did some minimal reformatting, fixed a couple of
+ *                   codec_seming bugs and noted a race to fix.
+ *   24th June 2003  Added power management and fixed race condition.
+ *   10th July 2003  Changed to a misc device.
+ *   31st July 2003  Moved TS_EVENT and TS_CAL to wm97xx.h
+ *    8th Aug  2003  Added option for read() calling wm97xx_sample_touch()
+ *                   because some ac97_read/ac_97_write call schedule()
+ *    7th Nov  2003  Added Input touch event interface, stanley.cai@intel.com
+ *   13th Nov  2003  Removed h3600 touch interface, added interrupt based
+ *                   pen down notification and implemented continous mode
+ *                   on XScale arch.
+ *   16th Nov  2003  Ian Molton <spyro@f2s.com>
+ *                   Modified so that it suits the new 2.6 driver model.
+ *   25th Jan  2004  Andrew Zabolotny <zap@homelink.ru>
+ *                   Implemented IRQ-driven pen down detection, implemented
+ *                   the private API meant to be exposed to platform-specific
+ *                   drivers, reorganized the driver so that it supports
+ *                   an arbitrary number of devices.
+ *    1st Feb  2004  Moved continuous mode handling to a separate
+ *                   architecture-dependent file. For now only PXA
+ *                   built-in AC97 controller is supported (pxa-ac97-wm97xx.c).
+ *    11th Feb 2004  Reduced CPU usage by keeping a cached copy of both
+ *                   digitizer registers instead of reading them every time.
+ *                   A reorganization of the whole code for better
+ *                   error handling.
+ *    17th Apr 2004  Added BMON support.
+ *    17th Nov 2004  Added codec GPIO, codec event handling (real and virtual
+ *                   GPIOs) and 2.6 power management. 
+ *    29th Nov 2004  Added WM9713 support.
+ *     4th Jul 2005  Moved codec specific code out to seperate files.
+ */  
+    
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/proc_fs.h>
+#include <linux/pm.h>
+#include <linux/interrupt.h>
+#include <linux/bitops.h>
+#include <linux/workqueue.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/wm97xx.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+    
+#define TS_NAME			"wm97xx"
+#define WM_CORE_VERSION		"0.60"
+#define DEFAULT_PRESSURE	0xb0c0
+
+static DECLARE_MUTEX(codec_sem);
+
+
+/*
+ * WM97xx - enable/disable AUX ADC sysfs 
+ */
+static int aux_sys = 1;
+module_param(aux_sys, int, 0);
+MODULE_PARM_DESC(aux_sys, "enable AUX ADC sysfs entries");
+
+/*
+ * WM97xx - enable/disable codec status sysfs 
+ */
+static int status_sys = 1;
+module_param(status_sys, int, 0);
+MODULE_PARM_DESC(status_sys, "enable codec status sysfs entries");
+
+/*
+ * Touchscreen absolute values
+ *
+ * These parameters are used to help the input layer discard out of
+ * range readings and reduce jitter etc. 
+ * 
+ *   o min, max:- indicate the min and max values your touch screen returns
+ *   o fuzz:- use a higher number to reduce jitter
+ *  	
+ * The default values correspond to Mainstone II in QVGA mode
+ *	
+ * Please read 
+ * Documentation/input/input-programming.txt for more details.	
+ */
+
+static int abs_x[3] = {350,3900,5};
+module_param_array(abs_x, int, NULL, 0);
+MODULE_PARM_DESC(abs_x, "Touchscreen absolute X min, max, fuzz");
+
+static int abs_y[3] = {320,3750,40};
+module_param_array(abs_y, int, NULL, 0);
+MODULE_PARM_DESC(abs_y, "Touchscreen absolute Y min, max, fuzz");
+
+static int abs_p[3] = {0,150,4};
+module_param_array(abs_p, int, NULL, 0);
+MODULE_PARM_DESC(abs_p, "Touchscreen absolute Pressure min, max, fuzz");
+
+/*
+ * Debug
+ */ 
+#if 0
+#define dbg(format, arg...) printk(KERN_DEBUG TS_NAME ": " format "\n" , ## arg)
+#else	/* 
+ */
+#define dbg(format, arg...)
+#endif	/* 
+ */
+#define err(format, arg...) printk(KERN_ERR TS_NAME ": " format "\n" , ## arg)
+#define info(format, arg...) printk(KERN_INFO TS_NAME ": " format "\n" , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING TS_NAME ": " format "\n" , ## arg)
+
+/**
+ *	wm97xx_read_aux_adc - Read the aux adc.
+ *	@wm: wm97xx device.
+ *  @adcsel: codec ADC to be read
+ *
+ *	Reads the selected AUX ADC.
+ */ 
+
+int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel) 
+{
+	int power_adc = 0, auxval;
+	u16 power = 0;
+
+	/* get codec */ 
+	down(&codec_sem);
+
+	/* When the touchscreen is not in use, we may have to power up the AUX ADC
+	 * before we can use sample the AUX inputs->
+	 */ 
+	if (wm->id == WM9713_ID2 && 
+	    (power = wm97xx_reg_read(wm, AC97_EXTENDED_MID)) & 0x8000) {
+		power_adc = 1;
+		wm97xx_reg_write(wm, AC97_EXTENDED_MID, power & 0x7fff);
+	}
+
+	/* Prepare the codec for AUX reading */ 
+	wm->codec->digitiser_ioctl(wm, WM97XX_DIG_SAVE);
+	wm->codec->digitiser_ioctl(wm, WM97XX_AUX_PREPARE);
+
+	/* Turn polling mode on to read AUX ADC */ 
+	wm->pen_probably_down = 1;
+	wm->codec->poll_sample(wm, adcsel, &auxval);
+    
+	if (power_adc)
+		wm97xx_reg_write(wm, AC97_EXTENDED_MID, power | 0x8000);
+    
+	wm->pen_probably_down = 0;
+	wm->codec->digitiser_ioctl(wm, WM97XX_DIG_RESTORE);
+    
+	up(&codec_sem);
+	return auxval & 0xfff;
+}
+
+#define WM97XX_AUX_ATTR(name,input) \
+static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf)   \
+{ \
+	struct wm97xx *wm = (struct wm97xx*)dev->driver_data; \
+	return sprintf(buf, "%d\n", wm97xx_read_aux_adc(wm, input)); \
+} \
+static DEVICE_ATTR(name, 0444, name##_show, NULL)
+		     
+WM97XX_AUX_ATTR(aux1, WM97XX_AUX_ID1);
+WM97XX_AUX_ATTR(aux2, WM97XX_AUX_ID2);
+WM97XX_AUX_ATTR(aux3, WM97XX_AUX_ID3);
+WM97XX_AUX_ATTR(aux4, WM97XX_AUX_ID4);
+
+#define WM97XX_STATUS_ATTR(name) \
+static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf)   \
+{ \
+	struct wm97xx *wm = (struct wm97xx*)dev->driver_data; \
+	return sprintf(buf, "%d\n", wm97xx_reg_read(wm, AC97_GPIO_STATUS)); \
+} \
+static DEVICE_ATTR(name, 0444, name##_show, NULL)
+		     
+WM97XX_STATUS_ATTR(status);
+
+static int wm97xx_sys_add(struct device *dev) 
+{
+	if (aux_sys) {
+		device_create_file(dev, &dev_attr_aux1);    
+		device_create_file(dev, &dev_attr_aux2);
+		device_create_file(dev, &dev_attr_aux3);
+		device_create_file(dev, &dev_attr_aux4);
+	}
+	if (status_sys)
+		device_create_file(dev, &dev_attr_status);
+	return 0;
+}	     
+
+static void wm97xx_sys_remove(struct device *dev) 
+{
+	if (status_sys)
+		device_remove_file(dev, &dev_attr_status);
+	if (aux_sys) {
+		device_remove_file(dev, &dev_attr_aux1);
+		device_remove_file(dev, &dev_attr_aux2);
+		device_remove_file(dev, &dev_attr_aux3);
+		device_remove_file(dev, &dev_attr_aux4);
+	}
+} 
+
+/**
+ *	wm97xx_get_gpio - Get the status of a codec GPIO.
+ *	@wm: wm97xx device.
+ *  @gpio: gpio
+ *
+ *	Get the status of a codec GPIO pin
+ */ 
+
+wm97xx_gpio_status_t wm97xx_get_gpio(struct wm97xx *wm, u32 gpio) 
+{
+	u16 status = wm97xx_reg_read(wm, AC97_GPIO_STATUS);
+
+	if (status & gpio)
+		return WM97XX_GPIO_HIGH;
+	else
+		return WM97XX_GPIO_LOW; 
+}
+
+/**
+ *	wm97xx_set_gpio - Set the status of a codec GPIO.
+ *	@wm: wm97xx device.
+ *  @gpio: gpio
+ *  
+ *
+ *	Set the status of a codec GPIO pin
+ */
+
+void wm97xx_set_gpio(struct wm97xx *wm, u32 gpio,
+				wm97xx_gpio_status_t status) 
+{
+	u16 reg; 
+	
+	down(&codec_sem);
+	reg = wm97xx_reg_read(wm, AC97_GPIO_STATUS);
+
+	if (status & WM97XX_GPIO_HIGH)
+		reg |= gpio;
+	else
+		reg &= ~gpio;
+
+	if (wm->id == WM9712_ID2) 
+		wm97xx_reg_write(wm, AC97_GPIO_STATUS, reg << 1);
+	else
+		wm97xx_reg_write(wm, AC97_GPIO_STATUS, reg);     
+	up(&codec_sem); 
+}	     
+
+/*
+ * Codec GPIO pin configuration, this set's pin direction, polarity,
+ * stickyness and wake up.
+ */ 
+void wm97xx_config_gpio(struct wm97xx *wm, u32 gpio, wm97xx_gpio_dir_t dir,
+		   wm97xx_gpio_pol_t pol, wm97xx_gpio_sticky_t sticky,
+		   wm97xx_gpio_wake_t wake)
+{
+	u16 reg;
+	
+	down(&codec_sem);
+	reg = wm97xx_reg_read(wm, AC97_GPIO_POLARITY);
+
+	if (pol == WM97XX_GPIO_POL_HIGH) 
+		reg |= gpio; 
+	else
+		reg &= ~gpio;
+
+	wm97xx_reg_write(wm, AC97_GPIO_POLARITY, reg);
+	reg = wm97xx_reg_read(wm, AC97_GPIO_STICKY);
+
+	if (sticky == WM97XX_GPIO_STICKY) 
+		reg |= gpio; 
+	else
+		reg &= ~gpio;
+
+	wm97xx_reg_write(wm, AC97_GPIO_STICKY, reg);
+	reg = wm97xx_reg_read(wm, AC97_GPIO_WAKEUP);
+
+	if (wake == WM97XX_GPIO_WAKE) 
+		reg |= gpio; 
+	else
+		reg &= ~gpio;
+
+	wm97xx_reg_write(wm, AC97_GPIO_WAKEUP, reg);
+	reg = wm97xx_reg_read(wm, AC97_GPIO_CFG);
+
+	if (dir == WM97XX_GPIO_IN) 
+		reg |= gpio; 
+	else
+		reg &= ~gpio;
+
+	wm97xx_reg_write(wm, AC97_GPIO_CFG, reg);
+	up(&codec_sem); 
+}
+
+/*
+ * Allow wm97xx platform drivers to use the codec PENDOWN gpio signal 
+ * as a pen down interrupt source. The PENDOWN signal is usually 
+ * routed via a cpu irq/gpio.
+ */ 
+int wm97xx_request_pen_irq(struct wm97xx *wm, int irq) 
+{
+	down(&codec_sem); 
+	if (!wm->pen_irq)
+		wm->pen_irq = irq;
+	
+	wm->pen_irq_ref_count++;
+	up(&codec_sem); 
+	return 0; 
+}	     
+
+void wm97xx_free_pen_irq(struct wm97xx *wm) 
+{
+	down(&codec_sem);
+    wm->pen_irq_ref_count--;
+	up(&codec_sem); 
+}	     
+
+/*
+ * Handle a pen down interrupt.
+ */ 
+static void wm97xx_pen_irq_worker(void *ptr) 
+{		     
+	struct wm97xx *wm = (struct wm97xx *) ptr;
+	
+	/* do we need to enable the touch panel reader */ 
+	if (wm->id == WM9705_ID2) {
+		if (wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD) & WM97XX_PEN_DOWN)
+			wm->pen_is_down = 1;
+		else
+			wm->pen_is_down = 0;
+		wake_up_interruptible(&wm->pen_irq_wait); 
+	} else {
+		u16 status, pol;
+		down(&codec_sem);
+		status = wm97xx_reg_read(wm, AC97_GPIO_STATUS);
+		pol = wm97xx_reg_read(wm, AC97_GPIO_POLARITY);
+	    
+		if (WM97XX_GPIO_13 & pol & status) {
+			wm->pen_is_down = 1;
+			wm97xx_reg_write(wm, AC97_GPIO_POLARITY, pol & ~WM97XX_GPIO_13);	    
+		} else {
+			wm->pen_is_down = 0;
+		    wm97xx_reg_write(wm, AC97_GPIO_POLARITY, pol | WM97XX_GPIO_13);
+		}
+		
+		if (wm->id == WM9712_ID2)
+			wm97xx_reg_write(wm, AC97_GPIO_STATUS, (status & ~WM97XX_GPIO_13) << 1);
+		else
+			wm97xx_reg_write(wm, AC97_GPIO_STATUS, status & ~WM97XX_GPIO_13);
+		up(&codec_sem);
+		wake_up_interruptible(&wm->pen_irq_wait); 
+	}
+	
+//	if (!wm->pen_is_down && wm->acc && wm->acc->acc_pen_up)
+//		wm->acc->acc_pen_up(wm);
+	
+	enable_irq(wm->pen_irq);
+}
+
+/*
+ * Codec PENDOWN irq handler
+ *
+ * We have to disable the codec interrupt in the handler because it can 
+ * take upto 1ms to clear the interrupt source. The interrupt is then enabled
+ * again in the slow handler when the source has been cleared.
+ */ 
+static irqreturn_t wm97xx_pen_interrupt(int irq, void *dev_id, 
+					struct pt_regs *regs) 
+{
+	struct wm97xx *wm = (struct wm97xx *) dev_id;
+	disable_irq(wm->pen_irq);
+	queue_work(wm->pen_irq_workq, &wm->pen_event_work);
+	return IRQ_HANDLED; 
+}
+
+/*
+ * initialise pen IRQ handler and workqueue
+ */ 
+static int wm97xx_init_pen_irq(struct wm97xx *wm) 
+{
+	u16 reg;
+
+	INIT_WORK(&wm->pen_event_work, wm97xx_pen_irq_worker, wm);
+	if ((wm->pen_irq_workq = 
+		create_singlethread_workqueue("kwm97pen")) == NULL) {
+		err("could not create pen irq work queue");
+		wm->pen_irq = 0; 
+		return -EINVAL; 
+	}
+
+	if (request_irq (wm->pen_irq, wm97xx_pen_interrupt, SA_SHIRQ, "wm97xx-pen", wm)) {
+		err("could not register codec pen down interrupt, will poll for pen down");
+		destroy_workqueue(wm->pen_irq_workq);
+		wm->pen_irq = 0; 
+		return -EINVAL; 
+	}
+
+	/* enable PEN down on wm9712/13 */ 
+	if (wm->id != WM9705_ID2) {
+		reg = wm97xx_reg_read(wm, AC97_MISC_AFE);
+		wm97xx_reg_write(wm, AC97_MISC_AFE, reg & 0xfffb);
+		reg = wm97xx_reg_read(wm, 0x5a);
+		wm97xx_reg_write(wm, 0x5a, reg & ~0x0001); 
+	}
+	
+	return 0; 
+}
+
+/* Private struct for communication between struct wm97xx_tshread and wm97xx_read_samples */ 
+struct ts_state {		     
+	int sleep_time; 
+	int min_sleep_time; 
+}; 
+
+static int wm97xx_read_samples(struct wm97xx *wm, struct ts_state *state) 
+{
+	struct wm97xx_data data; 
+	int rc;
+
+	down(&codec_sem);
+	//if (wm->acc)
+		//rc = wm->acc->acc_pen_down(wm);
+	//else 
+		rc = wm->codec->poll_touch(wm, &data);
+	
+	if (rc & RC_PENUP) {
+		if (wm->pen_is_down) {
+			wm->pen_is_down = 0; 
+			dbg("pen up");
+			input_report_abs(wm->input_dev, ABS_PRESSURE, 0);
+			input_sync(wm->input_dev); 
+		} else if (!(rc & RC_AGAIN)) {
+			/* We need high frequency updates only while pen is down,
+			* the user never will be able to touch screen faster than
+			* a few times per second... On the other hand, when the
+			* user is actively working with the touchscreen we don't
+			* want to lose the quick response. So we will slowly
+			* increase sleep time after the pen is up and quicky
+			* restore it to ~one task switch when pen is down again.
+			*/ 
+			if (state->sleep_time < HZ / 10) 
+				state->sleep_time++; 
+		}
+
+	} else if (rc & RC_VALID) {
+		printk("pen down: x=%x:%d, y=%x:%d, pressure=%x:%d\n",
+			data.x >> 12, data.x & 0xfff, data.y >> 12,
+			data.y & 0xfff, data.p >> 12, data.p & 0xfff);
+		input_report_abs(wm->input_dev, ABS_X, data.x & 0xfff);
+		input_report_abs(wm->input_dev, ABS_Y, data.y & 0xfff);
+		input_report_abs(wm->input_dev, ABS_PRESSURE, data.p & 0xfff);
+		input_sync(wm->input_dev); 
+		wm->pen_is_down = 1;
+		state->sleep_time = state->min_sleep_time; 
+	} else if (rc & RC_PENDOWN) {
+		dbg("pen down"); 
+		wm->pen_is_down = 1;
+		state->sleep_time = state->min_sleep_time; 
+	}
+
+	up(&codec_sem); 
+	return rc; 
+}
+
+/*
+* The touchscreen sample reader thread.
+*/ 
+static int wm97xx_ts_read(void *data) 
+{
+	int rc; 
+	struct ts_state state;
+	struct wm97xx *wm = (struct wm97xx *) data; 
+
+	/* set up thread context */ 
+	wm->ts_task = current;
+	daemonize("kwm97xxts");
+
+	if (wm->codec == NULL) {
+		wm->ts_task = NULL;
+		printk(KERN_ERR "codec is NULL, bailing\n"); 
+	}
+
+	complete(&wm->ts_init); 
+	wm->pen_is_down = 0;
+	state.min_sleep_time = HZ >= 100 ? HZ / 100 : 1;
+	if (state.min_sleep_time < 1) 
+		state.min_sleep_time = 1;
+	state.sleep_time = state.min_sleep_time; 
+
+	/* touch reader loop */ 
+	while (wm->ts_task) {
+		do {
+			try_to_freeze();
+			rc = wm97xx_read_samples(wm, &state);
+		} while (rc & RC_AGAIN);
+		
+		if (!wm->pen_is_down && wm->pen_irq) {
+			/* Nice, we don't have to poll for pen down event */ 
+			wait_event_interruptible(wm->pen_irq_wait, wm->pen_is_down);		    
+		} else {
+			set_task_state(current, TASK_INTERRUPTIBLE);
+			schedule_timeout(state.sleep_time); 
+		}
+	}
+	complete_and_exit(&wm->ts_exit, 0); 
+}
+
+/**
+ *	wm97xx_ts_input_open - Open the touch screen input device.
+ *	@idev:	Input device to be opened.
+ *
+ *	Called by the input sub system to open a wm97xx touchscreen device.
+ *  Starts the touchscreen thread and touch digitiser.
+ */ 
+static int wm97xx_ts_input_open(struct input_dev *idev) 
+{
+	int ret = 0;
+	struct wm97xx *wm = (struct wm97xx *) idev->private;
+
+	down(&codec_sem); 
+	/* first time opened ? */ 
+	if (wm->ts_use_count++ == 0) {
+		/* start touchscreen thread */ 
+		init_completion(&wm->ts_init);
+		init_completion(&wm->ts_exit);
+		ret = kernel_thread(wm97xx_ts_read, wm, CLONE_KERNEL);
+
+		if (ret >= 0) {
+			wait_for_completion(&wm->ts_init);
+			if (wm->ts_task == NULL) 
+				ret = -EINVAL; 
+		} else {
+			up(&codec_sem); 
+			return ret;
+		}
+
+		/* start digitiser */
+		//if (wm->acc && wm->acc->acc_pen_down)
+		//	wm->codec->acc_enable(wm, 1);
+		wm->codec->digitiser_ioctl(wm, WM97XX_DIG_START);
+
+		/* init pen down/up irq handling */ 
+		if (wm->pen_irq) {
+			wm97xx_init_pen_irq(wm); 
+
+			if (wm->pen_irq == 0) {
+				/* we failed to get an irq for pen down events,
+				 * so we resort to polling. kickstart the reader */ 
+				wm->pen_is_down = 1;
+				wake_up_interruptible(&wm->pen_irq_wait); 
+			}
+		}
+	}
+	     
+	up(&codec_sem); 
+	return 0; 
+}
+
+/**
+ *	wm97xx_ts_input_close - Close the touch screen input device.
+ *	@idev:	Input device to be closed.
+ *
+ *	Called by the input sub system to close a wm97xx touchscreen device.
+ *  Kills the touchscreen thread and stops the touch digitiser.
+ */
+
+static void wm97xx_ts_input_close(struct input_dev *idev) 
+{
+	struct wm97xx *wm = (struct wm97xx *) idev->private;
+		
+	down(&codec_sem);
+	if (--wm->ts_use_count == 0) {
+		/* destroy workqueues and free irqs */ 
+		if (wm->pen_irq) {
+			free_irq(wm->pen_irq, wm);
+			destroy_workqueue(wm->pen_irq_workq);
+			if (wm->pen_irq_ref_count == 0)
+		    		wm->pen_irq = 0;
+		}
+		
+		/* kill thread */ 
+		if (wm->ts_task) {
+			wm->ts_task = NULL; 
+			wm->pen_is_down = 1;
+			wake_up_interruptible(&wm->pen_irq_wait);
+			wait_for_completion(&wm->ts_exit);
+			wm->pen_is_down = 0; 
+		}
+
+		/* stop digitiser */
+		wm->codec->digitiser_ioctl(wm, WM97XX_DIG_STOP);
+		//if (wm->acc && wm->acc->acc_pen_down)
+		//	wm->codec->acc_enable(wm, 0);
+	}
+	up(&codec_sem); 
+}
+
+static int wm97xx_probe(struct device *dev) 
+{
+	struct wm97xx* wm;
+	int ret = 0, id = 0;
+	
+	if (!(wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL)))
+		return -ENOMEM;
+	
+	init_waitqueue_head(&wm->pen_irq_wait); 
+	wm->dev = dev; 
+	dev->driver_data = wm;
+	wm->ac97 = to_ac97_t(dev);
+
+	/* check that we have a supported codec */
+	if ((id = wm97xx_reg_read(wm, AC97_VENDOR_ID1)) != WM97XX_ID1) {
+		err("could not find a wm97xx, found a %x instead\n", id);
+		kfree(wm);
+		return -ENODEV;
+	}
+	
+	wm->id = wm97xx_reg_read(wm, AC97_VENDOR_ID2);
+	if(wm->id != wm97xx_codec.id) {
+		err("could not find a the selected codec, please build for wm97%2x", wm->id & 0xff);
+		kfree(wm);
+		return -ENODEV;
+	}
+	
+	if((wm->input_dev = input_allocate_device()) == NULL)
+		return -ENOMEM;
+
+	info("detected a wm97%2x codec", wm->id & 0xff);
+	wm->input_dev->name = "wm97xx touchscreen";
+	wm->input_dev->open = wm97xx_ts_input_open;
+	wm->input_dev->close = wm97xx_ts_input_close;
+	set_bit(EV_ABS, wm->input_dev->evbit);
+	set_bit(ABS_X, wm->input_dev->absbit);
+	set_bit(ABS_Y, wm->input_dev->absbit);
+	set_bit(ABS_PRESSURE, wm->input_dev->absbit);
+	wm->input_dev->absmax[ABS_X] = abs_x[1];
+	wm->input_dev->absmax[ABS_Y] = abs_y[1];
+	wm->input_dev->absmax[ABS_PRESSURE] = abs_p[1];
+	wm->input_dev->absmin[ABS_X] = abs_x[0];
+	wm->input_dev->absmin[ABS_Y] = abs_y[0];
+	wm->input_dev->absmin[ABS_PRESSURE] = abs_p[0];
+	wm->input_dev->absfuzz[ABS_X] = abs_x[2];
+	wm->input_dev->absfuzz[ABS_Y] = abs_y[2];
+	wm->input_dev->absfuzz[ABS_PRESSURE] = abs_p[2];
+	wm->input_dev->private = wm;
+	wm->codec = &wm97xx_codec;
+	input_register_device(wm->input_dev);
+
+	if(aux_sys)
+		wm97xx_sys_add(dev);
+	
+	/* set up physical characteristics */
+	wm->codec->digitiser_ioctl(wm, WM97XX_PHY_INIT);
+
+	return ret; 
+}
+
+static int wm97xx_remove(struct device *dev) 
+{
+	struct wm97xx *wm = dev_get_drvdata(dev);
+
+	/* Stop touch reader thread */ 
+	if (wm->ts_task) {
+		wm->ts_task = NULL; 
+		wm->pen_is_down = 1;
+		wake_up_interruptible(&wm->pen_irq_wait);
+		wait_for_completion(&wm->ts_exit); 
+	}
+	
+	if(aux_sys)
+		wm97xx_sys_remove(dev);
+	
+	input_unregister_device(wm->input_dev);
+	kfree(wm);
+	return 0; 
+}
+
+static struct device_driver wm97xx_driver = {
+	.name = 	"ac97", 
+	.bus = 		&ac97_bus_type, 
+	.owner = 	THIS_MODULE, 
+	.probe = 	wm97xx_probe, 
+	.remove = 	wm97xx_remove, 
+};
+
+
+static int __init wm97xx_init(void) 
+{
+	info("version %s liam.girdwood@wolfsonmicro.com", WM_CORE_VERSION);
+	return driver_register(&wm97xx_driver); 
+}
+
+static void __exit wm97xx_exit(void) 
+{
+	driver_unregister(&wm97xx_driver); 
+}
+
+EXPORT_SYMBOL_GPL(wm97xx_get_gpio);
+EXPORT_SYMBOL_GPL(wm97xx_set_gpio);
+EXPORT_SYMBOL_GPL(wm97xx_config_gpio);
+EXPORT_SYMBOL_GPL(wm97xx_request_pen_irq);
+EXPORT_SYMBOL_GPL(wm97xx_free_pen_irq);
+EXPORT_SYMBOL_GPL(wm97xx_read_aux_adc);
+
+module_init(wm97xx_init); 
+module_exit(wm97xx_exit);
+
+/* Module information */ 
+MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("WM97xx Core - Touch Screen / AUX ADC / GPIO Driver");
+MODULE_LICENSE("GPL");
diff --git a/include/asm-arm/arch-pxa/corgi.h b/include/asm-arm/arch-pxa/corgi.h
index e554caa..495a470 100644
--- a/include/asm-arm/arch-pxa/corgi.h
+++ b/include/asm-arm/arch-pxa/corgi.h
@@ -106,5 +106,7 @@ extern struct platform_device corgiscoop
 extern struct platform_device corgissp_device;
 extern struct platform_device corgifb_device;
 
+void corgikbd_report_hp(int status);
+
 #endif /* __ASM_ARCH_CORGI_H  */
 
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
new file mode 100644
index 0000000..151cf3c
--- /dev/null
+++ b/include/linux/wm97xx.h
@@ -0,0 +1,283 @@
+/*
+ * Register bits and API for Wolfson WM97xx series of codecs
+ */
+
+#ifndef _LINUX_WM97XX_H
+#define _LINUX_WM97XX_H
+
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/ac97_codec.h>
+#include <sound/initval.h>
+#include <linux/types.h>
+#include <linux/input.h>	/* Input device layer */
+
+/*
+ * WM97xx AC97 Touchscreen registers
+ */
+#define AC97_WM97XX_DIGITISER1		0x76
+#define AC97_WM97XX_DIGITISER2		0x78
+#define AC97_WM97XX_DIGITISER_RD 	0x7a
+#define AC97_WM9713_DIG1			0x74
+#define AC97_WM9713_DIG2			AC97_WM97XX_DIGITISER1
+#define AC97_WM9713_DIG3			AC97_WM97XX_DIGITISER2
+
+/*
+ * WM97xx register bits
+ */
+#define WM97XX_POLL			0x8000	/* initiate a polling measurement */
+#define WM97XX_ADCSEL_X		0x1000	/* x coord measurement */
+#define WM97XX_ADCSEL_Y		0x2000	/* y coord measurement */
+#define WM97XX_ADCSEL_PRES	0x3000	/* pressure measurement */
+#define WM97XX_ADCSEL_MASK	0x7000
+#define WM97XX_COO			0x0800	/* enable coordinate mode */
+#define WM97XX_CTC			0x0400	/* enable continuous mode */
+#define WM97XX_CM_RATE_93	0x0000	/* 93.75Hz continuous rate */
+#define WM97XX_CM_RATE_187	0x0100	/* 187.5Hz continuous rate */
+#define WM97XX_CM_RATE_375	0x0200	/* 375Hz continuous rate */
+#define WM97XX_CM_RATE_750	0x0300	/* 750Hz continuous rate */
+#define WM97XX_CM_RATE_8K	0x00f0	/* 8kHz continuous rate */
+#define WM97XX_CM_RATE_12K	0x01f0	/* 12kHz continuous rate */
+#define WM97XX_CM_RATE_24K	0x02f0	/* 24kHz continuous rate */
+#define WM97XX_CM_RATE_48K	0x03f0	/* 48kHz continuous rate */
+#define WM97XX_CM_RATE_MASK	0x03f0
+#define WM97XX_RATE(i)		(((i & 3) << 8) | ((i & 4) ? 0xf0 : 0))
+#define WM97XX_DELAY(i)		((i << 4) & 0x00f0)	/* sample delay times */
+#define WM97XX_DELAY_MASK	0x00f0
+#define WM97XX_SLEN			0x0008	/* slot read back enable */
+#define WM97XX_SLT(i)		((i - 5) & 0x7)	/* touchpanel slot selection (5-11) */
+#define WM97XX_SLT_MASK		0x0007
+#define WM97XX_PRP_DETW		0x4000	/* pen detect on, digitiser off, wake up */
+#define WM97XX_PRP_DET		0x8000	/* pen detect on, digitiser off, no wake up */
+#define WM97XX_PRP_DET_DIG	0xc000	/* pen detect on, digitiser on */
+#define WM97XX_RPR			0x2000	/* wake up on pen down */
+#define WM97XX_PEN_DOWN		0x8000	/* pen is down */
+#define WM97XX_ADCSRC_MASK	0x7000	/* ADC source mask */
+
+#define WM97XX_AUX_ID1		0x8001
+#define WM97XX_AUX_ID2		0x8002
+#define WM97XX_AUX_ID3		0x8003
+#define WM97XX_AUX_ID4		0x8004
+
+
+/* WM9712 Bits */
+#define WM9712_45W			0x1000	/* set for 5-wire touchscreen */
+#define WM9712_PDEN			0x0800	/* measure only when pen down */
+#define WM9712_WAIT			0x0200	/* wait until adc is read before next sample */
+#define WM9712_PIL			0x0100	/* current used for pressure measurement. set 400uA else 200uA */
+#define WM9712_MASK_HI		0x0040	/* hi on mask pin (47) stops conversions */
+#define WM9712_MASK_EDGE	0x0080	/* rising/falling edge on pin delays sample */
+#define	WM9712_MASK_SYNC	0x00c0	/* rising/falling edge on mask initiates sample */
+#define WM9712_RPU(i)		(i&0x3f)	/* internal pull up on pen detect (64k / rpu) */
+#define WM9712_PD(i)		(0x1 << i)	/* power management */
+
+/* WM9712 Registers */
+#define AC97_WM9712_POWER	0x24
+#define AC97_WM9712_REV		0x58
+
+/* WM9705 Bits */
+#define WM9705_PDEN			0x1000	/* measure only when pen is down */
+#define WM9705_PINV			0x0800	/* inverts sense of pen down output */
+#define WM9705_BSEN			0x0400	/* BUSY flag enable, pin47 is 1 when busy */
+#define WM9705_BINV			0x0200	/* invert BUSY (pin47) output */
+#define WM9705_WAIT			0x0100	/* wait until adc is read before next sample */
+#define WM9705_PIL			0x0080	/* current used for pressure measurement. set 400uA else 200uA */
+#define WM9705_PHIZ			0x0040	/* set PHONE and PCBEEP inputs to high impedance */
+#define WM9705_MASK_HI		0x0010	/* hi on mask stops conversions */
+#define WM9705_MASK_EDGE	0x0020	/* rising/falling edge on pin delays sample */
+#define	WM9705_MASK_SYNC	0x0030	/* rising/falling edge on mask initiates sample */
+#define WM9705_PDD(i)		(i & 0x000f)	/* pen detect comparator threshold */
+
+
+/* WM9713 Bits */
+#define WM9713_PDPOL		0x0400	/* Pen down polarity */
+#define WM9713_POLL			0x0200	/* initiate a polling measurement */
+#define WM9713_CTC			0x0100	/* enable continuous mode */
+#define WM9713_ADCSEL_X		0x0002	/* X measurement */
+#define WM9713_ADCSEL_Y		0x0004	/* Y measurement */
+#define WM9713_ADCSEL_PRES	0x0008	/* Pressure measurement */
+#define WM9713_COO			0x0001	/* enable coordinate mode */
+#define WM9713_PDEN			0x0800	/* measure only when pen down */
+#define WM9713_ADCSEL_MASK	0x00fe	/* ADC selection mask */
+
+/* AUX ADC ID's */
+#define TS_COMP1			0x0
+#define TS_COMP2			0x1
+#define TS_BMON				0x2
+#define TS_WIPER			0x3
+
+/* ID numbers */
+#define WM97XX_ID1			0x574d
+#define WM9712_ID2			0x4c12
+#define WM9705_ID2			0x4c05
+#define WM9713_ID2			0x4c13
+
+/* Codec GPIO's */
+#define WM97XX_MAX_GPIO		16
+#define WM97XX_GPIO_1		(1 << 1)
+#define WM97XX_GPIO_2		(1 << 2)
+#define WM97XX_GPIO_3		(1 << 3)
+#define WM97XX_GPIO_4		(1 << 4)
+#define WM97XX_GPIO_5		(1 << 5)
+#define WM97XX_GPIO_6		(1 << 6)
+#define WM97XX_GPIO_7		(1 << 7)
+#define WM97XX_GPIO_8		(1 << 8)
+#define WM97XX_GPIO_9		(1 << 9)
+#define WM97XX_GPIO_10		(1 << 10)
+#define WM97XX_GPIO_11		(1 << 11)
+#define WM97XX_GPIO_12		(1 << 12)
+#define WM97XX_GPIO_13		(1 << 13)
+#define WM97XX_GPIO_14		(1 << 14)
+#define WM97XX_GPIO_15		(1 << 15)
+
+
+#define AC97_LINK_FRAME		21	/* time in uS for AC97 link frame */
+
+
+/*---------------- Return codes from sample reading functions ---------------*/
+
+/* More data is available; call the sample gathering function again */
+#define RC_AGAIN			0x00000001
+/* The returned sample is valid */
+#define RC_VALID			0x00000002
+/* The pen is up (the first RC_VALID without RC_PENUP means pen is down) */
+#define RC_PENUP			0x00000004
+/* The pen is down (RC_VALID implies RC_PENDOWN, but sometimes it is helpful
+   to tell the handler that the pen is down but we don't know yet his coords,
+   so the handler should not sleep or wait for pendown irq) */
+#define RC_PENDOWN			0x00000008
+
+/* The wm97xx driver provides a private API for writing platform-specific
+ * drivers. 
+ */
+
+/* The structure used to return arch specific sampled data into */
+struct wm97xx_data {
+    int x;
+    int y;
+    int p;
+};
+
+/* Codec GPIO status
+ */
+typedef enum {
+    WM97XX_GPIO_HIGH,
+    WM97XX_GPIO_LOW
+} wm97xx_gpio_status_t;
+
+/* Codec GPIO direction
+ */
+typedef enum {
+    WM97XX_GPIO_IN,
+    WM97XX_GPIO_OUT
+} wm97xx_gpio_dir_t;
+
+/* Codec GPIO polarity
+ */
+typedef enum {
+    WM97XX_GPIO_POL_HIGH,
+    WM97XX_GPIO_POL_LOW
+} wm97xx_gpio_pol_t;
+
+/* Codec GPIO sticky
+ */
+typedef enum {
+    WM97XX_GPIO_STICKY,
+    WM97XX_GPIO_NOTSTICKY
+} wm97xx_gpio_sticky_t;
+
+/* Codec GPIO wake
+ */
+typedef enum {
+    WM97XX_GPIO_WAKE,
+    WM97XX_GPIO_NOWAKE
+} wm97xx_gpio_wake_t;
+
+
+/*
+ * Digitiser ioctl commands
+ */
+#define WM97XX_DIG_START	0x1
+#define WM97XX_DIG_STOP		0x2
+#define WM97XX_DIG_SAVE		0x3
+#define WM97XX_DIG_RESTORE	0x4
+#define WM97XX_PHY_INIT		0x5
+#define WM97XX_AUX_PREPARE	0x6
+
+struct wm97xx;
+extern struct wm97xx_codec_drv wm97xx_codec;
+
+/*
+ * Codec driver interface - allows mapping to WM9705/12/13 and newer codecs
+ */
+struct wm97xx_codec_drv {
+	u16 id;
+	int (*poll_sample) (struct wm97xx *, int adcsel, int *sample);	/* read 1 sample */
+	int (*poll_touch) (struct wm97xx *, struct wm97xx_data *);	/* read X,Y,[P] in poll */
+	void (*acc_enable) (struct wm97xx *, int enable);
+	void (*digitiser_ioctl) (struct wm97xx *, int cmd);
+	int (*pen_down) (struct wm97xx *);	/* called when pen is down */
+	void (*pen_up) (struct wm97xx *); /* called when pen goes up */
+	u16 acc_slot; /* AC97 slot used for acc touch data */
+	u16 acc_rate; /* acc touch data rate */
+};
+
+
+struct wm97xx {
+	u16 dig1, dig2, dig3, id;	/* Cached codec registers */
+	struct wm97xx_codec_drv *codec;	/* attached codec driver*/
+	struct input_dev* input_dev;	/* touchscreen input device */
+	ac97_t *ac97;			/* ALSA codec access */
+	struct device *dev;		/* ALSA device */
+	struct completion ts_init;
+	struct completion ts_exit;
+	struct task_struct *ts_task;
+	unsigned int pen_irq;	/* Pen IRQ number in use */
+	wait_queue_head_t pen_irq_wait;	/* Pen IRQ wait queue */
+	int pen_irq_ref_count;		/* Number of pen irq users */
+	struct workqueue_struct *pen_irq_workq;
+	struct work_struct pen_event_work;
+	unsigned int ts_use_count;
+	unsigned pen_is_down:1;	/* Pen is down */
+	unsigned aux_waiting:1;	/* aux measurement waiting */
+	unsigned pen_probably_down:1;	/* used in polling mode */
+};
+
+/* Codec PEN IRQ access
+ * The codec can additionally generate an IRQ (using a dedicated pin) 
+ * for Pen down events. This is used to enable and disable codec 
+ * Pen down IRQ's
+ */
+int wm97xx_request_pen_irq(struct wm97xx *wm, int irq);
+void wm97xx_free_pen_irq(struct wm97xx *wm);
+
+/* Codec GPIO access (not supported on WM9705)
+ * This can be used to set/get codec GPIO and Virtual GPIO status.
+ */
+wm97xx_gpio_status_t wm97xx_get_gpio(struct wm97xx *wm, u32 gpio);
+void wm97xx_set_gpio(struct wm97xx *wm, u32 gpio,
+			  wm97xx_gpio_status_t status);
+void wm97xx_config_gpio(struct wm97xx *wm, u32 gpio,
+				     wm97xx_gpio_dir_t dir,
+				     wm97xx_gpio_pol_t pol,
+				     wm97xx_gpio_sticky_t sticky,
+				     wm97xx_gpio_wake_t wake);
+
+static inline int wm97xx_reg_read(struct wm97xx *wm, unsigned int reg) 
+{    
+	if (wm->ac97)
+		return wm->ac97->bus->ops->read(wm->ac97, reg);
+	else
+		return -1;
+}
+
+static inline void wm97xx_reg_write(struct wm97xx *wm, unsigned int reg, unsigned int val) 
+{
+	if (wm->ac97)
+		wm->ac97->bus->ops->write(wm->ac97, reg, val);
+}
+
+int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel);
+
+#endif
diff --git a/include/sound/soc-dpm.h b/include/sound/soc-dpm.h
index 1a3a588..6b2bbcc 100644
--- a/include/sound/soc-dpm.h
+++ b/include/sound/soc-dpm.h
@@ -99,8 +99,9 @@
 #define SND_SOC_DPM_STREAM_START		0x1
 #define SND_SOC_DPM_STREAM_STOP			0x2
 #define SND_SOC_DPM_STREAM_SUSPEND		0x4
-#define SND_SOC_DPM_STREAM_PAUSE_PUSH	0x8
-#define SND_SOC_DPM_STREAM_PAUSE_RELEASE	0x10  
+#define SND_SOC_DPM_STREAM_RESUME		0x8
+#define SND_SOC_DPM_STREAM_PAUSE_PUSH	0x10
+#define SND_SOC_DPM_STREAM_PAUSE_RELEASE	0x20  
 
 struct snd_soc_dpm_widget;
 enum snd_soc_dpm_type;
@@ -120,7 +121,8 @@ int snd_soc_dpm_codec_event(struct snd_s
 void snd_soc_dpm_sys_remove(struct device *dev);
 int snd_soc_dpm_sys_add(struct device *dev);
 int snd_soc_dpm_codec_mute(struct snd_soc_codec *codec, int mute);
-int snd_soc_dpm_set_connection(struct snd_soc_codec *codec, const struct snd_soc_dpm_pin *pin);
+int snd_soc_dpm_set_connection(struct snd_soc_codec *codec, 
+	char *pin, int status);
 
 enum snd_soc_dpm_type {
 	snd_soc_dpm_input = 0,
@@ -171,7 +173,8 @@ struct snd_soc_dpm_widget {
 	unsigned char connected:1;		/* connected codec pin */
 	unsigned char sync:1;			/* sync complete */
 	unsigned char ext:1;			/* has external widgets */
-	unsigned char muted;			/* muted for pop reduction */
+	unsigned char muted:1;			/* muted for pop reduction */
+	unsigned char suspend:1;		/* was active before suspend */
 	int (*ext_event)(struct snd_soc_codec*, int);
 	
 	/* kcontrols that relate to this widget */
@@ -183,10 +186,4 @@ struct snd_soc_dpm_widget {
 	struct list_head outputs;
 };
 
-/* codec pin connections */
-struct snd_soc_dpm_pin {
-	char *name;
-	int connected; /* this is dynamic for insertion/removal events e.g. hp, mic */
-};
-
 #endif
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 1d77745..0c101aa 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -21,13 +21,14 @@
 #include <sound/control.h>
 #include <sound/ac97_codec.h>
 
-#define SND_SOC_VERSION "0.8"
+#define SND_SOC_VERSION "0.9"
 
 /*
  * Convenience kcontrol builders
  */
 
 #define SOC_SINGLE_VALUE(reg,shift,mask,invert) ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | ((invert) << 24))
+#define SOC_SINGLE_VALUE_EXT(reg,mask,invert) ((reg) | ((mask) << 16) | ((invert) << 31))
 #define SOC_SINGLE(xname, reg, shift, mask, invert) \
 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_soc_info_volsw, \
   .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
@@ -41,42 +42,48 @@
   .mask = xmask, .texts = xtexts }
 #define SOC_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
 	SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
+#define SOC_ENUM_SINGLE_EXT(xmask, xtexts) \
+{ .mask = xmask, .texts = xtexts }
 #define SOC_ENUM(xname, xenum) \
 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_soc_info_enum_double, \
   .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
   .private_value = (unsigned long)&xenum }
-
- 
+#define SOC_SINGLE_EXT(xname, xreg, xmask, xinvert, xhandler_get, xhandler_put) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_soc_info_volsw_ext, \
+  .get = xhandler_get, .put = xhandler_put, \
+  .private_value =  SOC_SINGLE_VALUE_EXT(xreg, xmask, xinvert) }
+#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_soc_info_bool_ext, \
+  .get = xhandler_get, .put = xhandler_put, \
+  .private_value = xdata }
+#define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_soc_info_enum_ext, \
+  .get = xhandler_get, .put = xhandler_put, \
+  .private_value = (unsigned long)&xenum }
+  
 /*
  * Audio interface types
  */
 #define SND_SOC_AC97		0x1
-#define SND_SOC_I2S			0x2
-#define SND_SOC_SSP			0x4
-  
-/*
- * Control interface types
- */
-#define SND_SOC_I2C			0x1
-#define SND_SOC_3W			0x2
-
+#define SND_SOC_I2S		0x2
+#define SND_SOC_SSP		0x4
 
 /*
  * hw interface formats
  */
-#define SND_SOC_HWFMT_I2S			(1 << 0)	/* I2S mode */
+#define SND_SOC_HWFMT_I2S		(1 << 0)	/* I2S mode */
 #define SND_SOC_HWFMT_RIGHT_J		(1 << 1)	/* Right justified mode */
 #define SND_SOC_HWFMT_LEFT_J		(1 << 2)	/* Left Justified mode */
-#define SND_SOC_HWFMT_DSP_A			(1 << 3)	/* L data msb after FRM */
-#define SND_SOC_HWFMT_DSP_B			(1 << 4)	/* L data msb during FRM */
+#define SND_SOC_HWFMT_DSP_A		(1 << 3)	/* L data msb after FRM */
+#define SND_SOC_HWFMT_DSP_B		(1 << 4)	/* L data msb during FRM */
 
 /*
  * hw signal inversions
  */
-#define SND_SOC_HWFMT_NB_NF			(1 << 24)	/* normal bit clock + frame */
-#define SND_SOC_HWFMT_NB_IF			(1 << 25)	/* normal bclk + inv frm */
-#define SND_SOC_HWFMT_IB_NF			(1 << 26)	/* invert bclk + nor frm */
-#define SND_SOC_HWFMT_IB_IF			(1 << 27)	/* invert bclc + frm */
+#define SND_SOC_HWFMT_NB_NF		(1 << 24)	/* normal bit clock + frame */
+#define SND_SOC_HWFMT_NB_IF		(1 << 25)	/* normal bclk + inv frm */
+#define SND_SOC_HWFMT_IB_NF		(1 << 26)	/* invert bclk + nor frm */
+#define SND_SOC_HWFMT_IB_IF		(1 << 27)	/* invert bclc + frm */
 
 /*
  * hw clock masters
@@ -94,14 +101,13 @@
 #define SND_SOC_INV_MASK		0x0f000000
 #define SND_SOC_CLOCK_MASK		0xf0000000
 
-#define SND_SOC_HWBITS(x)		(1 << (x - 1))	/* sample size in bits */
-
 /*
  * Codec IO
  */
 #define snd_soc_read(codec, reg) codec->read(codec, reg)
 #define snd_soc_write(codec, reg, value) codec->write(codec, reg, value)
 
+struct snd_soc_device;
 struct snd_soc_pcm_stream;
 struct snd_soc_ops;
 struct snd_soc_hw_mode;
@@ -109,23 +115,18 @@ struct snd_soc_hw_bus;
 struct snd_soc_pcm_codec;
 struct snd_soc_pcm_interface;
 struct snd_soc_codec;
-struct snd_soc_platform;
 struct snd_soc_machine_config;
-struct snd_soc_machine;
 struct soc_enum;
 	
 typedef int (*hw_write_t)(void *,const char* ,int);
 typedef int (*hw_read_t)(void *,char* ,int);
 
-extern struct bus_type soc_bus_type;
-
-int snd_soc_register_machine(struct snd_soc_machine *machine);
-void snd_soc_unregister_machine(struct snd_soc_machine *machine);
+extern ac97_bus_ops_t soc_ac97_ops;
 
 /* pcm <-> interface connect */
-void snd_soc_free_pcms(struct snd_soc_codec *codec);
-int snd_soc_register_pcms(struct snd_soc_codec* codec);
-int snd_soc_register_card(struct snd_soc_codec *codec);
+void snd_soc_free_pcms(struct snd_soc_device *socdev);
+int snd_soc_register_pcms(struct snd_soc_device *socdev);
+int snd_soc_register_card(struct snd_soc_device *socdev);
 
 /* set runtime hw params */
 int snd_soc_set_runtime_hw(snd_pcm_substream_t *substream, 
@@ -145,17 +146,18 @@ snd_kcontrol_t *snd_soc_cnew(const snd_k
 	void *data, char *long_name);
 
 int snd_soc_info_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo);
+int snd_soc_info_enum_ext(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo);
 int snd_soc_get_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol);
 int snd_soc_put_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol);
 int snd_soc_info_volsw(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo);
+int snd_soc_info_volsw_ext(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo);
+int snd_soc_info_bool_ext(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo);
 int snd_soc_get_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol);
 int snd_soc_put_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol);
 	
 /* SoC supported stream types */
 struct snd_soc_pcm_stream {
 	char *sname;
-	unsigned int rates;		/* SNDRV_PCM_RATE_* */
-	u64 formats;			/* SNDRV_PCM_FMTBIT_* */
 	unsigned int rate_min;		/* min rate */
 	unsigned int rate_max;		/* max rate */
 	unsigned int channels_min;	/* min channels */
@@ -175,12 +177,12 @@ struct snd_soc_ops {
 /* SoC hardware mode */
 struct snd_soc_hw_mode {
 	u32 hformat;	/* SND_SOC_HWFMT_* */
-	u32 hbits;		/* SND_SOC_HWBITS() */
+	u64 hbits;		
 	u32 rate;		/* sample rate */
 	u32 fs;			/* ratio of rate:bclk */ 
-	long priv1;		/* private mode data 1 */
-	long priv2;		/* private mode data 2 */
-	long priv3;		/* private mode data 3 */
+	unsigned long priv1;		/* private mode data 1 */
+	unsigned long priv2;		/* private mode data 2 */
+	unsigned long priv3;		/* private mode data 3 */
 };
 
 /* SoC hardware bus and all modes */
@@ -203,8 +205,7 @@ struct snd_soc_pcm_codec {
 	/* runtime info */
 	struct snd_soc_hw_mode hw_runtime;
 	struct snd_soc_ops ops;
-	struct snd_soc_pcm_interface *pcm_i;
-	struct snd_soc_codec *codec;
+	struct snd_soc_platdev_data *platdev_data;
 	
 	/* private data */
 	void *priv;
@@ -219,10 +220,11 @@ struct snd_soc_pcm_interface {
 	unsigned int id;
 	unsigned char type;
 	
-	int (*probe)(struct device *dev);
-	void (*remove)(struct device *dev);
-	int (*suspend)(struct device *dev, pm_message_t state);
-	int (*resume)(struct device *dev);
+	/* interface callbacks */
+	int (*probe)(struct platform_device *pdev);
+	void (*remove)(struct platform_device *pdev);
+	int (*suspend)(struct platform_device *pdev, struct snd_soc_pcm_interface *iface);
+	int (*resume)(struct platform_device *pdev, struct snd_soc_pcm_interface *iface);
 	
 	/* interface pcm capabilities */
 	struct snd_soc_pcm_stream capture;
@@ -230,12 +232,11 @@ struct snd_soc_pcm_interface {
 	struct snd_soc_hw_bus hw;
 	
 	/* runtime info */
+	struct snd_soc_pcm_runtime *soc_runtime;
 	struct snd_soc_hw_mode hw_runtime;
-	struct snd_soc_pcm_codec *pcm_c;
 	struct snd_soc_ops ops;
+	struct snd_soc_device *socdev;
 	snd_pcm_runtime_t *runtime;
-	snd_card_t *card;
-	struct snd_soc_machine* machine;
 	unsigned char active:1;
 	
 	/* private data */
@@ -254,12 +255,12 @@ struct snd_soc_codec {
 	/* runtime */
 	snd_card_t *card;
 	ac97_t *ac97;
-	struct device *dev;
 	void *private_data;
-	struct snd_soc_machine *machine;
 	int active_streams;
+	int suspend_streams;
 	int pcm_devs;
 	int dpm_state;
+	int suspend_dpm_state;
 	
 	/* codec IO */
 	void *control_data; /* codec control (i2c/3wire) data */
@@ -269,6 +270,7 @@ struct snd_soc_codec {
 	hw_read_t hw_read;
 	void *reg_cache;
 	
+	/* dpm */
 	struct list_head dpm_widgets;
 	struct list_head dpm_paths;
 	
@@ -276,21 +278,25 @@ struct snd_soc_codec {
 	struct snd_soc_pcm_codec *pcms;
 	int	npcms;
 };
-	
+
+struct snd_soc_codec_device {
+	int (*probe)(struct platform_device *pdev);
+	int (*remove)(struct platform_device *pdev);
+	int (*suspend)(struct platform_device *pdev, pm_message_t state);
+	int (*resume)(struct platform_device *pdev);
+};
+
 /* SoC platform interface */
 struct snd_soc_platform {
 	char *name;
 	
-	int	(*probe)(struct device * dev);
-	int	(*remove)(struct device * dev);
-	int (*suspend)(struct device *dev, pm_message_t state);
-	int (*resume)(struct device *dev);
-	struct bus_type	* bus;
+	int (*probe)(struct platform_device *pdev);
+	int (*remove)(struct platform_device *pdev);
+	int (*suspend)(struct platform_device *pdev, struct snd_soc_pcm_interface *iface);
+	int (*resume)(struct platform_device *pdev, struct snd_soc_pcm_interface *iface);
 	int (*pcm_new)(snd_card_t *, struct snd_soc_pcm_codec *, snd_pcm_t *);
 	void (*pcm_free)(snd_pcm_t *);
 	snd_pcm_ops_t *pcm_ops;
-	
-	struct snd_soc_pcm_interface* iface[];
 };
 
 /* SoC machine configuration */
@@ -308,17 +314,31 @@ struct snd_soc_machine_config {
 struct snd_soc_machine {
 	char *name;
 	
-	int	(*probe)(struct device *dev);
-	int	(*remove)(struct device *dev);
-	int (*suspend)(struct device *dev, pm_message_t state);
-	int (*resume)(struct device *dev);
+	int (*probe)(struct platform_device *pdev);
+	int (*remove)(struct platform_device *pdev);
+	int (*suspend)(struct platform_device *pdev, pm_message_t state);
+	int (*resume)(struct platform_device *pdev);
 	
 	struct snd_soc_ops *ops;
 	struct snd_soc_machine_config *config;
 	int nconfigs;
+};
+
+/* SoC Device */
+struct snd_soc_device {
 	struct device *dev;
-	
-	struct snd_soc_platform* platform;
+	struct snd_soc_machine *machine;
+	struct snd_soc_platform *platform;
+	struct snd_soc_codec *codec;
+	struct snd_soc_codec_device *codec_dev;
+	void *codec_data;
+};
+
+/* runtime chn data */
+struct snd_soc_pcm_runtime {
+	struct snd_soc_pcm_codec *pcm_c;
+	struct snd_soc_pcm_interface *pcm_i;
+	struct snd_soc_device *socdev;
 };
 
 /* enamerated kcontrol */
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 3cabb51..11d39f5 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -1,5 +1,5 @@
 
-snd-soc-core-objs := soc-core.o soc-dpm.o soc-bus.o
+snd-soc-core-objs := soc-core.o soc-dpm.o
 
 obj-$(CONFIG_SND_SOC)	+= snd-soc-core.o
 obj-$(CONFIG_SND_SOC)	+= pxa/ codecs/
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index cf3820b..e2d9da8 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -26,85 +26,89 @@
 #include <sound/initval.h>
 #include <sound/soc.h>
 
-#define AC97_VERSION "0.2"
+#define AC97_VERSION "0.3"
 
 static struct snd_soc_pcm_codec ac97_soc_client = {
 	.name = "AC97 HiFi",
 	.playback = {
 		.sname = "AC97 Playback",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,},
 	.capture = {
 		.sname = "AC97 Capture",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | 
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,},
 	.nplayback = 1,
 	.ncapture = 1,
 };
 
-static int ac97_soc_probe(struct device *dev)
+static unsigned int ac97_read(struct snd_soc_codec *codec, 
+	unsigned int reg)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
-	ac97_bus_ops_t* soc_ac97_ops = (ac97_bus_ops_t*)codec->control_data;
+	return soc_ac97_ops.read(codec->ac97, reg);
+}
+
+static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
+	unsigned int val)
+{
+	soc_ac97_ops.write(codec->ac97, reg, val);
+	return 0;
+}
+
+static int ac97_soc_probe(struct platform_device *pdev)
+{
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec;
 	ac97_bus_t *ac97_bus;
 	ac97_template_t ac97_template;
 	int ret = 0;
-	
+
+	printk(KERN_INFO "AC97 SoC Audio Codec %s", AC97_VERSION);
+
+	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
+		return -ENOMEM;
+
+	socdev->codec = codec;
 	codec->name = "AC97";
 	codec->owner = THIS_MODULE;
 	codec->pcms = &ac97_soc_client;
 	codec->npcms = 1;
+	codec->write = ac97_write;
+	codec->read = ac97_read;
+	INIT_LIST_HEAD(&codec->dpm_widgets);
+	INIT_LIST_HEAD(&codec->dpm_paths);
 
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		return ret;
 	}
 
-	ret = snd_ac97_bus(codec->card, 0, soc_ac97_ops, NULL, &ac97_bus);
+	ret = snd_ac97_bus(codec->card, 0, &soc_ac97_ops, NULL, &ac97_bus);
 	if (ret)
 		return ret;
 	memset(&ac97_template, 0, sizeof(ac97_template));
 	ret = snd_ac97_mixer(ac97_bus, &ac97_template, &codec->ac97);
 
-	snd_soc_register_card(codec);
+	snd_soc_register_card(socdev);
 	return ret;
 }
 
-static int ac97_soc_remove(struct device *dev)
+static int ac97_soc_remove(struct platform_device *pdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
-	snd_soc_free_pcms(codec);
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	
+	snd_soc_free_pcms(socdev);
 	return 0;
 }
 
-static struct device_driver ac97_soc_driver = {
-	.name = 	"AC97", 
-	.bus = 		&soc_bus_type, 
-	.owner = 	THIS_MODULE, 
-	.probe = 	ac97_soc_probe, 
+struct snd_soc_codec_device soc_codec_dev_ac97= {
+	.probe = 	ac97_soc_probe,
 	.remove = 	ac97_soc_remove,
 };
 
-static int __init ac97_init(void)
-{
-	printk(KERN_INFO "SoC AC97 Audio Codec %s\n", AC97_VERSION);
-	return driver_register(&ac97_soc_driver);
-}
-
-static void __exit ac97_exit(void)
-{
-	driver_unregister(&ac97_soc_driver);
-}
-
-module_init(ac97_init);
-module_exit(ac97_exit);
+EXPORT_SYMBOL_GPL(soc_codec_dev_ac97);
 
 MODULE_DESCRIPTION("Soc Generic AC97 driver");
 MODULE_AUTHOR("Liam Girdwood");
 MODULE_LICENSE("GPL");
+
diff --git a/sound/soc/codecs/ac97.h b/sound/soc/codecs/ac97.h
new file mode 100644
index 0000000..3393fc6
--- /dev/null
+++ b/sound/soc/codecs/ac97.h
@@ -0,0 +1,18 @@
+/*
+ * linux/sound/codecs/ac97.h -- ALSA SoC Layer
+ *
+ * Author:		Liam Girdwood
+ * Created:		Dec 1st 2005
+ * Copyright:	Wolfson Microelectronics. PLC.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+ 
+#ifndef __LINUX_SND_SOC_AC97_H
+#define __LINUX_SND_SOC_AC97_H
+
+extern struct snd_soc_codec_device soc_codec_dev_ac97;
+
+#endif
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 29e8f09..6b7f6c2 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -19,7 +19,8 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
-#include <linux/device.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
 #include <sound/driver.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -31,7 +32,9 @@
 #include "wm8731.h"
 
 #define AUDIO_NAME "wm8731"
-#define WM8731_VERSION "0.5"
+#define WM8731_VERSION "0.6"
+
+struct snd_soc_codec_device soc_codec_dev_wm8731;
 
 /*
  * Debug
@@ -72,35 +75,35 @@ static const u16 wm8731_reg[WM8731_CACHE
  */
 static struct snd_soc_hw_mode wm8731_hwfmt[] = {
 
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 8000 ,  64, 0x000c},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 8000,   96, 0x000e},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 8000 , 128, 0x004c},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 8000,  192, 0x004e},
-
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 32000,  64, 0x0018},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 32000,  96, 0x001a},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 32000, 128, 0x0058},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 32000, 192, 0x005a},
-
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 44100,  64, 0x0020},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 44100,  96, 0x0022},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 44100, 128, 0x0060},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 44100, 192, 0x0062},
-
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 48000,  64, 0x0000},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 48000,  96, 0x0002},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 48000, 128, 0x0040},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 48000, 192, 0x0042},
-
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 88200,  32, 0x003c},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 88200,  48, 0x003e},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 88200,  64, 0x007c},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 88200,  96, 0x007e},
-
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 96000,  32, 0x001c},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 96000,  48, 0x001e},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 96000,  64, 0x005c},
-	{WM8731_HWFMT, SND_SOC_HWBITS(16), 96000,  96, 0x005e},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000 ,  64, 0x000c},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,   96, 0x000e},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000 , 128, 0x004c},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,  192, 0x004e},
+
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000,  64, 0x0018},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000,  96, 0x001a},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000, 128, 0x0058},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000, 192, 0x005a},
+
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100,  64, 0x0020},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100,  96, 0x0022},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100, 128, 0x0060},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100, 192, 0x0062},
+
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000,  64, 0x0000},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000,  96, 0x0002},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000, 128, 0x0040},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000, 192, 0x0042},
+
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  32, 0x003c},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  48, 0x003e},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  64, 0x007c},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  96, 0x007e},
+
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  32, 0x001c},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  48, 0x001e},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  64, 0x005c},
+	{WM8731_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  96, 0x005e},
 };
 
 
@@ -113,7 +116,7 @@ static inline unsigned int wm8731_read_r
 	u16 *cache = codec->reg_cache;
 	if (reg == WM8731_RESET) 
 		return 0;
-	if (reg > WM8731_CACHEREGNUM)
+	if (reg >= WM8731_CACHEREGNUM)
 		return -1;
 	return cache[reg];
 }
@@ -125,7 +128,7 @@ static inline void wm8731_write_reg_cach
 	u16 reg, unsigned int value)
 {
 	u16 *cache = codec->reg_cache;
-	if (reg > WM8731_CACHEREGNUM)
+	if (reg >= WM8731_CACHEREGNUM)
 		return;
 	cache[reg] = value;
 }
@@ -225,7 +228,7 @@ SND_SOC_DPM_OUTPUT("LRHPOUT"),
 SND_SOC_DPM_ADC("ADC", "HiFi Capture", WM8731_PWR, 2, 1, NULL, 0),
 SND_SOC_DPM_MUX("Input Mux", -1, 0, 0, &wm8753_input_mux_controls),
 SND_SOC_DPM_VOLUME("Line Input", WM8731_PWR, 0, 1, NULL, 0),
-SND_SOC_DPM_MICBIAS("Mic", WM8731_PWR, 1, 1),
+SND_SOC_DPM_MICBIAS("Mic Bias", WM8731_PWR, 1, 1),
 SND_SOC_DPM_INPUT("MICIN"),
 SND_SOC_DPM_INPUT("RLINEIN"),
 SND_SOC_DPM_INPUT("LLINEIN"),
@@ -235,7 +238,7 @@ static const char* intercon[][3] = {
 	/* output mixer */
 	{"Output Mixer", "Line Bypass Switch", "Line Input"},
 	{"Output Mixer", "HiFi Playback Switch", "DAC"},
-	{"Output Mixer", "Mic Sidetone Switch", "Mic"},
+	{"Output Mixer", "Mic Sidetone Switch", "Mic Bias"},
 	
 	/* outputs */
 	{"RHPOUT", NULL, "Output Mixer"},
@@ -245,12 +248,12 @@ static const char* intercon[][3] = {
 	
 	/* input mux */
 	{"Input Mux", "Line In", "Line Input"},
-	{"Input Mux", "Mic", "Mic"},
+	{"Input Mux", "Mic", "Mic Bias"},
 	
 	/* outputs */
 	{"Line Input", NULL, "LLINEIN"},
 	{"Line Input", NULL, "RLINEIN"},
-	{"Mic", NULL, "MICIN"},
+	{"Mic Bias", NULL, "MICIN"},
 	
 	/* terminator */
 	{NULL, NULL, NULL},
@@ -275,22 +278,22 @@ static int wm8731_add_widgets(struct snd
 
 static int wm8731_pcm_prepare(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_codec *codec = pcm_c->codec;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_codec *codec = socdev->codec;
 	u16 iface = 0;
 	
 	/* set master/slave audio interface */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
 		case SND_SOC_HWFMT_CBM_CFM:
 			iface |= 0x0040;
 			break;
 		case SND_SOC_HWFMT_CBS_CFS:
 			break;
-	
 	}
 	
 	/* interface format */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
 		case SND_SOC_HWFMT_I2S:
 			iface |= 0x0002;
 			break;
@@ -308,22 +311,22 @@ static int wm8731_pcm_prepare(snd_pcm_su
 	}
 	
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
-		case SND_SOC_HWBITS(16):
+	switch(rtd->pcm_c->hw_runtime.hbits) {
+		case SNDRV_PCM_FMTBIT_S16_LE:
 			break;
-		case SND_SOC_HWBITS(20):
+		case SNDRV_PCM_FMTBIT_S20_3LE:
 			iface |= 0x0004;
 			break;
-		case SND_SOC_HWBITS(24):
+		case SNDRV_PCM_FMTBIT_S24_3LE:
 			iface |= 0x0008;
 			break;
-		case SND_SOC_HWBITS(32):
+		case SNDRV_PCM_FMTBIT_S32_LE:
 			iface |= 0x000c;
 			break;
 	}
 
 	/* clock inversion */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
 		case SND_SOC_HWFMT_NB_NF:
 			break;
 		case SND_SOC_HWFMT_IB_IF:
@@ -336,12 +339,9 @@ static int wm8731_pcm_prepare(snd_pcm_su
 			iface |= 0x0010;
 			break;
 	}
-	
-	if (wm8731_write(codec, WM8731_ACTIVE, 0x00) != 0)
-		return -EIO;
 
 	/* set rate */
-	wm8731_write(codec, WM8731_SRATE, pcm_c->hw_runtime.priv1);
+	wm8731_write(codec, WM8731_SRATE, rtd->pcm_c->hw_runtime.priv1);
 	wm8731_write(codec, WM8731_IFACE, iface);
 
 	return 0;
@@ -368,7 +368,7 @@ static int wm8731_dpm_event(struct snd_s
 			wm8731_write(codec, WM8731_PWR, 0xffff);
 			break;
 	}
-
+	codec->dpm_state = event;
 	return 0;
 }
 
@@ -376,20 +376,12 @@ static struct snd_soc_pcm_codec wm8731_p
 	.name = "WM8731",
 	.playback = {
 		.sname = "Playback",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 |
-		SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,
 	},
 	.nplayback = 1,
 	.capture = {
 		.sname = "Capture",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | 
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 |
-		SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,
 	},
@@ -402,17 +394,32 @@ static struct snd_soc_pcm_codec wm8731_p
 		.hmodes = &wm8731_hwfmt[0],
 	},
 };
-static int wm8731_suspend(struct device *dev, pm_message_t state)
+
+static int wm8731_suspend(struct platform_device *pdev, pm_message_t state)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
 	wm8731_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
 	return 0;
 }
 
-static int wm8731_resume(struct device *dev)
+static int wm8731_resume(struct platform_device *pdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+	int i;
+	u8 data[2];
+	u16 *cache = codec->reg_cache;
+
+	/* Sync reg_cache with the hardware */
+	for (i = 0; i < ARRAY_SIZE(wm8731_reg); i++) {
+		data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001);
+		data[1] = cache[i] & 0x00ff;
+		codec->hw_write(codec->control_data, data, 2);
+	}
 	wm8731_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+	wm8731_dpm_event(codec, codec->suspend_dpm_state);
 	return 0;
 }
 
@@ -420,9 +427,9 @@ static int wm8731_resume(struct device *
  * initialise the WM8731 driver
  * register the mixer and dsp interfaces with the kernel 
  */
-static int wm8731_probe(struct device *dev)
+static int wm8731_init(struct snd_soc_device* socdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_codec* codec = socdev->codec;
 	int reg, ret = 0;
 
 	codec->name = "WM8731";
@@ -439,16 +446,15 @@ static int wm8731_probe(struct device *d
 	
 	wm8731_reset(codec);
 
-	/* charge output caps */
-	wm8731_dpm_event(codec, SNDRV_CTL_POWER_D2);
-
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
-		wm8731_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		kfree(codec->reg_cache);
 		return ret;
 	}
 	
+	/* power on device */
+	wm8731_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+	
 	/* set the update bits */
 	reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V);
 	wm8731_write(codec, WM8731_LOUT1V, reg | 0x0100);
@@ -461,44 +467,159 @@ static int wm8731_probe(struct device *d
 
 	wm8731_add_controls(codec);
 	wm8731_add_widgets(codec);
-	snd_soc_register_card(codec);
+	snd_soc_register_card(socdev);
+	
+	return 0;
+}
+
+
+#ifdef CONFIG_I2C
+
+/*
+ * WM8731 2 wire address is determined by GPIO5
+ * state during powerup.
+ *    low  = 0x1a
+ *    high = 0x1b
+ */
+#define I2C_DRIVERID_WM8731 0xfefe /* liam -  need a proper id */
+
+static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
+
+/* Magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver wm8731_i2c_driver;
+static struct i2c_client client_template;
+
+/* If the i2c layer weren't so broken, we could pass this kind of data
+   around */
+static struct snd_soc_device *wm8731_socdev;
+
+static int wm8731_codec_probe(struct i2c_adapter *adap, int addr, int kind)
+{
+	struct snd_soc_device *socdev = wm8731_socdev;
+	struct wm8731_setup_data *setup = socdev->codec_data;
+	struct snd_soc_codec* codec = socdev->codec;
+	struct i2c_client *i2c;
+	int ret;
+
+	if (addr != setup->i2c_address)
+		return -ENODEV;
+
+	client_template.adapter = adap;
+	client_template.addr = addr;
+
+	if ((i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL)) == NULL){
+		kfree(codec);
+		return -ENOMEM;
+	}
+	memcpy(i2c, &client_template, sizeof(struct i2c_client));
+
+	i2c_set_clientdata(i2c, codec);
+
+	codec->control_data = i2c;
+
+	if((ret = i2c_attach_client(i2c)) < 0) {
+		err("failed to attach codec at addr %x\n", addr);
+		kfree(i2c);
+		return ret;
+	}
+
+	wm8731_init(socdev);
 
 	return 0;
 }
 
-/* power down chip */
-static int wm8731_remove(struct device *dev)
+static int wm8731_i2c_detach(struct i2c_client *client)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
-	wm8731_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
-	snd_soc_free_pcms(codec);
+	struct snd_soc_codec* codec = i2c_get_clientdata(client);
+
+	i2c_detach_client(client);
+
 	kfree(codec->reg_cache);
+	kfree(client);
+
 	return 0;
 }
 
-static struct device_driver wm8731_driver = {
-	.name = 	"WM8731", 
-	.bus = 		&soc_bus_type, 
-	.owner = 	THIS_MODULE, 
-	.probe = 	wm8731_probe, 
-	.remove = 	wm8731_remove, 
-	.suspend = 	wm8731_suspend, 
-	.resume =	wm8731_resume, 
+static int wm8731_i2c_attach(struct i2c_adapter *adap)
+{
+	return i2c_probe(adap, &addr_data, wm8731_codec_probe);
+}
+
+/* corgi i2c codec control layer */
+static struct i2c_driver wm8731_i2c_driver = {
+	.name =           "WM8731 I2C Codec",
+	.id =             I2C_DRIVERID_WM8731,
+	.flags =          I2C_DF_NOTIFY,
+	.attach_adapter = wm8731_i2c_attach,
+	.detach_client =  wm8731_i2c_detach,
+	.command =        NULL,
+};
+
+static struct i2c_client client_template = {
+	.name =   "WM8731",
+	.flags =  I2C_CLIENT_ALLOW_USE,
+	.driver = &wm8731_i2c_driver,
 };
 
-static int __init wm8731_init(void)
+static int wm8731_probe(struct platform_device *pdev)
 {
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct wm8731_setup_data *setup = socdev->codec_data;
+	struct snd_soc_codec* codec;
+	int ret = 0;
+
 	info("WM8731 Audio Codec %s", WM8731_VERSION);
-	return driver_register(&wm8731_driver);
+
+	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
+		return -ENOMEM;
+
+	socdev->codec = codec;
+	INIT_LIST_HEAD(&codec->dpm_widgets);
+	INIT_LIST_HEAD(&codec->dpm_paths);
+
+	wm8731_socdev = socdev;
+
+	if (setup->i2c_address) {
+		normal_i2c[0] = setup->i2c_address;
+		codec->hw_write = (hw_write_t)i2c_master_send;
+		if ((ret = i2c_add_driver(&wm8731_i2c_driver)) != 0)
+			printk(KERN_ERR "can't add i2c driver");
+	} else {
+		/* Add other interfaces here */
+	}
+
+	return ret;
 }
 
-static void __exit wm8731_exit(void)
+#endif
+
+/* power down chip */
+static int wm8731_remove(struct platform_device *pdev)
 {
-	driver_unregister(&wm8731_driver);
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
+	if (codec->control_data)
+		wm8731_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+
+	snd_soc_free_pcms(socdev);
+	i2c_del_driver(&wm8731_i2c_driver);
+	kfree(codec);
+
+	return 0;
 }
 
-module_init(wm8731_init);
-module_exit(wm8731_exit);
+
+struct snd_soc_codec_device soc_codec_dev_wm8731 = {
+	.probe = 	wm8731_probe,
+	.remove = 	wm8731_remove,
+	.suspend = 	wm8731_suspend,
+	.resume =	wm8731_resume,
+};
+
+EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731);
 
 MODULE_DESCRIPTION("Soc WM8731 driver");
 MODULE_AUTHOR("Richard Purdie");
diff --git a/sound/soc/codecs/wm8731.h b/sound/soc/codecs/wm8731.h
index 9db1778..88f5660 100644
--- a/sound/soc/codecs/wm8731.h
+++ b/sound/soc/codecs/wm8731.h
@@ -31,4 +31,10 @@
 
 #define WM8731_CACHEREGNUM 	10
 
+struct wm8731_setup_data {
+	unsigned short i2c_address;
+};
+
+extern struct snd_soc_codec_device soc_codec_dev_wm8731;
+
 #endif
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 7726b67..fcbea37 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -17,7 +17,8 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
-#include <linux/device.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
 #include <sound/driver.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -29,7 +30,7 @@
 #include "wm8750.h"
 
 #define AUDIO_NAME "WM8750"
-#define WM8750_VERSION "0.5"
+#define WM8750_VERSION "0.6"
 
 /*
  * Debug
@@ -47,6 +48,9 @@
 #define info(format, arg...) printk(KERN_INFO PFX ": " format "\n" , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING PFX ": " format "\n" , ## arg)
 
+static struct workqueue_struct *wm8750_workq = NULL;
+static struct work_struct wm8750_dpm_work;
+
 /*
  * wm8750 register cache
  * We can't read the WM8750 register space when we 
@@ -74,60 +78,50 @@ static const u16 wm8750_reg[] = {
 
 /* priv1 is srate register setting */
 static struct snd_soc_hw_mode wm8750_hwfmt[] = {
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 8000,   64, 0x000c},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 8000,   96, 0x000e},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 8000,  128, 0x004c},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 8000,  192, 0x004e},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 11025, 64,  0x0030},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 11025, 96,  0x0032},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 11025, 128, 0x0070},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 11025, 192, 0x0072},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 12000, 64,  0x0010},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 12000, 96,  0x0012},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 12000, 128, 0x0050},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 12000, 192, 0x0052},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 16000, 64,  0x0014},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 16000, 96,  0x0016},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 16000, 128, 0x0054},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 16000, 192, 0x0056},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 22050, 64,  0x0034},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 22050, 96,  0x0036},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 22050, 128, 0x0074},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 22050, 192, 0x0076},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 24000, 64,  0x0038},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 24000, 96,  0x003a},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 24000, 128, 0x0078},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 24000, 192, 0x007a},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 32000,  64, 0x0018},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 32000,  96, 0x001a},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 32000, 128, 0x0058},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 32000, 192, 0x005a},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 44100,  64, 0x0020},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 44100,  96, 0x0022},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 44100, 128, 0x0060},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 44100, 192, 0x0062},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 48000,  64, 0x0000},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 48000,  96, 0x0002},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 48000, 128, 0x0040},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 48000, 192, 0x0042},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 88200,  32, 0x003c},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 88200,  48, 0x003e},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 88200,  64, 0x007c},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 88200,  96, 0x007e},
-
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 96000,  32, 0x001c},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 96000,  48, 0x001e},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 96000,  64, 0x005c},
-	{WM8750_HWFMT, SND_SOC_HWBITS(16), 96000,  96, 0x005e},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,   64, 0x000c},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,   96, 0x000e},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,  128, 0x004c},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,  192, 0x004e},
+
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_11025, 64,  0x0030},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_11025, 96,  0x0032},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_11025, 128, 0x0070},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_11025, 192, 0x0072},
+
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_16000, 64,  0x0014},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_16000, 96,  0x0016},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_16000, 128, 0x0054},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_16000, 192, 0x0056},
+
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_22050, 64,  0x0034},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_22050, 96,  0x0036},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_22050, 128, 0x0074},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_22050, 192, 0x0076},
+
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000,  64, 0x0018},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000,  96, 0x001a},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000, 128, 0x0058},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000, 192, 0x005a},
+
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100,  64, 0x0020},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100,  96, 0x0022},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100, 128, 0x0060},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100, 192, 0x0062},
+
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000,  64, 0x0000},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000,  96, 0x0002},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000, 128, 0x0040},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000, 192, 0x0042},
+
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  32, 0x003c},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  48, 0x003e},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  64, 0x007c},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  96, 0x007e},
+
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  32, 0x001c},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  48, 0x001e},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  64, 0x005c},
+	{WM8750_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  96, 0x005e},
 };
 
 /*
@@ -553,12 +547,13 @@ static int wm8750_add_widgets(struct snd
 
 static int wm8750_pcm_prepare(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_codec *codec = pcm_c->codec;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_codec *codec =socdev->codec;
 	u16 iface = 0;
 	
 	/* set master/slave audio interface */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
 		case SND_SOC_HWFMT_CBM_CFM:
 			iface |= 0x0040;
 			break;
@@ -567,7 +562,7 @@ static int wm8750_pcm_prepare(snd_pcm_su
 	}
 	
 	/* interface format */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
 		case SND_SOC_HWFMT_I2S:
 			iface |= 0x0002;
 			break;
@@ -585,22 +580,22 @@ static int wm8750_pcm_prepare(snd_pcm_su
 	}
 		
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
-		case SND_SOC_HWBITS(16):
+	switch(rtd->pcm_c->hw_runtime.hbits) {
+		case SNDRV_PCM_FMTBIT_S16_LE:
 			break;
-		case SND_SOC_HWBITS(20):
+		case SNDRV_PCM_FMTBIT_S20_3LE:
 			iface |= 0x0004;
 			break;
-		case SND_SOC_HWBITS(24):
+		case SNDRV_PCM_FMTBIT_S24_3LE:
 			iface |= 0x0008;
 			break;
-		case SND_SOC_HWBITS(32):
+		case SNDRV_PCM_FMTBIT_S32_LE:
 			iface |= 0x000c;
 			break;
 	}
 
 	/* clock inversion */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
 		case SND_SOC_HWFMT_NB_NF:
 			break;
 		case SND_SOC_HWFMT_IB_IF:
@@ -615,7 +610,7 @@ static int wm8750_pcm_prepare(snd_pcm_su
 	}
 	
 	/* set rate */
-	wm8750_write(codec, WM8750_SRATE, pcm_c->hw_runtime.priv1);
+	wm8750_write(codec, WM8750_SRATE, rtd->pcm_c->hw_runtime.priv1);
 	wm8750_write(codec, WM8750_IFACE, iface);
 	
 	return 0;
@@ -643,7 +638,7 @@ static int wm8750_dpm_event(struct snd_s
 			wm8750_write(codec, WM8750_PWR1, 0x0000);
 			break;
 	}
-	
+	codec->dpm_state = event;
 	return 0;
 }
 
@@ -651,20 +646,12 @@ static struct snd_soc_pcm_codec wm8750_p
 	.name = "WM8750",
 	.playback = {
 		.sname = "Playback",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 |
-		SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,
 	},
 	.nplayback = 1,
 	.capture = {
 		.sname = "Capture",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | 
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 |
-		SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,
 	},
@@ -678,17 +665,47 @@ static struct snd_soc_pcm_codec wm8750_p
 	},
 };
 
-static int wm8750_suspend(struct device *dev, pm_message_t state)
+static void wm8750_work(void *data)
+{
+	struct snd_soc_codec *codec = (struct snd_soc_codec *)data;
+	wm8750_dpm_event(codec, codec->dpm_state);
+}
+
+static int wm8750_suspend(struct platform_device *pdev, pm_message_t state)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
 	wm8750_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
 	return 0;
 }
 
-static int wm8750_resume(struct device *dev)
+static int wm8750_resume(struct platform_device *pdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+	int i;
+	u8 data[2];
+	u16 *cache = codec->reg_cache;
+
+	/* Sync reg_cache with the hardware */
+	for (i = 0; i < ARRAY_SIZE(wm8750_reg); i++) {
+		if (i == WM8750_RESET)
+			continue;
+		data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001);
+		data[1] = cache[i] & 0x00ff;
+		codec->hw_write(codec->control_data, data, 2);
+	}
+	
 	wm8750_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+	
+	/* charge wm8750 caps */
+	if(codec->suspend_dpm_state == SNDRV_CTL_POWER_D0) {
+		wm8750_dpm_event(codec, SNDRV_CTL_POWER_D2);
+		codec->dpm_state = SNDRV_CTL_POWER_D0;
+		queue_delayed_work(wm8750_workq, &wm8750_dpm_work, msecs_to_jiffies(1000));
+	}
+	
 	return 0;
 }
 
@@ -696,9 +713,9 @@ static int wm8750_resume(struct device *
  * initialise the WM8750 driver
  * register the mixer and dsp interfaces with the kernel 
  */
-static int wm8750_probe(struct device *dev)
+static int wm8750_init(struct snd_soc_device* socdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_codec* codec = socdev->codec;
 	int reg, ret = 0;
 
 	codec->name = "WM8750";
@@ -715,15 +732,16 @@ static int wm8750_probe(struct device *d
 	
 	wm8750_reset(codec);
 
-	/* charge output caps */
-	wm8750_dpm_event(codec, SNDRV_CTL_POWER_D2);
-
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
-		wm8750_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		kfree(codec->reg_cache);
 		return ret;
 	}
+	
+	/* charge output caps */
+	wm8750_dpm_event(codec, SNDRV_CTL_POWER_D2);
+	codec->dpm_state = SNDRV_CTL_POWER_D3hot;
+	queue_delayed_work(wm8750_workq, &wm8750_dpm_work, msecs_to_jiffies(1000));
 
 	/* set the update bits */
 	reg = wm8750_read_reg_cache(codec, WM8750_LDAC);
@@ -745,48 +763,163 @@ static int wm8750_probe(struct device *d
 
 	wm8750_add_controls(codec);
 	wm8750_add_widgets(codec);
-	snd_soc_register_card(codec);
-	
-	/* wait for caps to finish charging - liam make this thread */
-	ssleep(1);
-	wm8750_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+	snd_soc_register_card(socdev);
 
 	return 0;
 }
 
-/* power down chip */
-static int wm8750_remove(struct device *dev)
+#ifdef CONFIG_I2C
+
+/*
+ * WM8731 2 wire address is determined by GPIO5
+ * state during powerup.
+ *    low  = 0x1a
+ *    high = 0x1b
+ */
+#define I2C_DRIVERID_WM8750 0xfefe /* liam -  need a proper id */
+
+static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
+
+/* Magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver wm8750_i2c_driver;
+static struct i2c_client client_template;
+
+/* If the i2c layer weren't so broken, we could pass this kind of data
+   around */
+static struct snd_soc_device *wm8750_socdev;
+
+static int wm8750_codec_probe(struct i2c_adapter *adap, int addr, int kind)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
-	wm8750_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
-	snd_soc_free_pcms(codec);
+	struct snd_soc_device *socdev = wm8750_socdev;
+	struct wm8750_setup_data *setup = socdev->codec_data;
+	struct snd_soc_codec* codec = socdev->codec;
+	struct i2c_client *i2c;
+	int ret;
+
+	if (addr != setup->i2c_address)
+		return -ENODEV;
+
+	client_template.adapter = adap;
+	client_template.addr = addr;
+
+	if ((i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL)) == NULL){
+		kfree(codec);
+		return -ENOMEM;
+	}
+	memcpy(i2c, &client_template, sizeof(struct i2c_client));
+
+	i2c_set_clientdata(i2c, codec);
+
+	codec->control_data = i2c;
+
+	if((ret = i2c_attach_client(i2c)) < 0) {
+		err("failed to attach codec at addr %x\n", addr);
+		kfree(i2c);
+		return ret;
+	}
+
+	wm8750_init(socdev);
+
+	return 0;
+}
+
+static int wm8750_i2c_detach(struct i2c_client *client)
+{
+	struct snd_soc_codec* codec = i2c_get_clientdata(client);
+
+	i2c_detach_client(client);
+
 	kfree(codec->reg_cache);
+	kfree(client);
+
 	return 0;
 }
 
-static struct device_driver wm8750_driver = {
-	.name = 	"WM8750", 
-	.bus = 		&soc_bus_type, 
-	.owner = 	THIS_MODULE, 
-	.probe = 	wm8750_probe, 
-	.remove = 	wm8750_remove, 
-	.suspend = 	wm8750_suspend, 
-	.resume =	wm8750_resume, 
+static int wm8750_i2c_attach(struct i2c_adapter *adap)
+{
+	return i2c_probe(adap, &addr_data, wm8750_codec_probe);
+}
+
+/* corgi i2c codec control layer */
+static struct i2c_driver wm8750_i2c_driver = {
+	.name =           "WM8750 I2C Codec",
+	.id =             I2C_DRIVERID_WM8750,
+	.flags =          I2C_DF_NOTIFY,
+	.attach_adapter = wm8750_i2c_attach,
+	.detach_client =  wm8750_i2c_detach,
+	.command =        NULL,
+};
+
+static struct i2c_client client_template = {
+	.name =   "WM8750",
+	.flags =  I2C_CLIENT_ALLOW_USE,
+	.driver = &wm8750_i2c_driver,
 };
 
-static int __init wm8750_init(void)
+static int wm8750_probe(struct platform_device *pdev)
 {
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct wm8750_setup_data *setup = socdev->codec_data;
+	struct snd_soc_codec* codec;
+	int ret = 0;
+
 	info("WM8750 Audio Codec %s", WM8750_VERSION);
-	return driver_register(&wm8750_driver);
+
+	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
+		return -ENOMEM;
+
+	socdev->codec = codec;
+	INIT_LIST_HEAD(&codec->dpm_widgets);
+	INIT_LIST_HEAD(&codec->dpm_paths);
+	wm8750_socdev = socdev;
+	INIT_WORK(&wm8750_dpm_work, wm8750_work, codec);
+	if((wm8750_workq = create_workqueue("wm8750")) == NULL) {
+		kfree(codec);
+		return -ENOMEM;
+	}
+
+	if (setup->i2c_address) {
+		normal_i2c[0] = setup->i2c_address;
+		codec->hw_write = (hw_write_t)i2c_master_send;
+		if ((ret = i2c_add_driver(&wm8750_i2c_driver)) != 0)
+			printk(KERN_ERR "can't add i2c driver");
+	} else {
+		/* Add other interfaces here */
+	}
+
+	return ret;
 }
 
-static void __exit wm8750_exit(void)
+#endif
+
+/* power down chip */
+static int wm8750_remove(struct platform_device *pdev)
 {
-	driver_unregister(&wm8750_driver);
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
+	if (codec->control_data)
+		wm8750_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+	if(wm8750_workq)
+		destroy_workqueue(wm8750_workq);
+	snd_soc_free_pcms(socdev);
+	i2c_del_driver(&wm8750_i2c_driver);
+	kfree(codec);
+
+	return 0;
 }
 
-module_init(wm8750_init);
-module_exit(wm8750_exit);
+
+struct snd_soc_codec_device soc_codec_dev_wm8750 = {
+	.probe = 	wm8750_probe,
+	.remove = 	wm8750_remove,
+	.suspend = 	wm8750_suspend,
+	.resume =	wm8750_resume,
+};
+
+EXPORT_SYMBOL_GPL(soc_codec_dev_wm8750);
 
 MODULE_DESCRIPTION("Soc WM8750 driver");
 MODULE_AUTHOR("Liam Girdwood");
diff --git a/sound/soc/codecs/wm8750.h b/sound/soc/codecs/wm8750.h
index 6f5ba47..aea4f45 100644
--- a/sound/soc/codecs/wm8750.h
+++ b/sound/soc/codecs/wm8750.h
@@ -55,4 +55,10 @@
 
 #define WM8750_CACHE_REGNUM 0x2a
 
+struct wm8750_setup_data {
+	unsigned short i2c_address;
+};
+
+extern struct snd_soc_codec_device soc_codec_dev_wm8750;
+
 #endif
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index 58c6642..c5fd078 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
+#include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <sound/driver.h>
 #include <sound/core.h>
@@ -34,7 +35,7 @@
 #include "wm8753.h"
 
 #define AUDIO_NAME "wm8753"
-#define WM8753_VERSION "0.6"
+#define WM8753_VERSION "0.7"
 
 /*
  * Debug
@@ -52,20 +53,23 @@
 #define info(format, arg...) printk(KERN_INFO PFX ": " format "\n" , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING PFX ": " format "\n" , ## arg)
 
+static struct workqueue_struct *wm8753_workq = NULL;
+static struct work_struct wm8753_dpm_work;
+
 /*
  * wm8753 register cache
  * We can't read the WM8753 register space when we 
  * are using 2 wire for device control, so we cache them instead. 
  */
 static const u16 wm8753_reg[] = {
-    0x0008, 0x0000, 0x000a, 0x000a,  
-    0x0033, 0x0000, 0x0007, 0x00ff,
-    0x00ff, 0x000f, 0x000f, 0x007b, 
-    0x0000, 0x0032, 0x0000, 0x00c3,
-    0x00c3, 0x00c0, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0055, 
+	0x0008, 0x0000, 0x000a, 0x000a,  
+	0x0033, 0x0000, 0x0007, 0x00ff,
+	0x00ff, 0x000f, 0x000f, 0x007b, 
+	0x0000, 0x0032, 0x0000, 0x00c3,
+	0x00c3, 0x00c0, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0055, 
 	0x0005, 0x0050, 0x0055, 0x0050,
 	0x0055, 0x0050, 0x0055, 0x0079, 
 	0x0079, 0x0079, 0x0079, 0x0079,
@@ -115,60 +119,49 @@ static struct _pll_div pll_div[] = {
  * priv2 is bits[15..8] = MCLK divisor, bits[7..0] = sr
  */
 static struct snd_soc_hw_mode wm8753_hifi[] = {
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		8000,	768,	12288000, 	0x020c},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		8000,	384,	12288000, 	0x040c},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		8000,	192,	12288000, 	0x080c},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		8000,	96,		12288000, 	0x100c},
-	
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		11025,	512,	11289600,	0x0230},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		11025,	256,	11289600,	0x0430},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		11025, 	128,	11289600,	0x0830},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		11025,	64,		11289600,	0x1030},
-	
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		12000, 	512,	12288000,   0x0210},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		12000, 	256,	12288000,   0x0410},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		12000, 	128,	12288000,   0x0810},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		12000, 	64,		12288000,   0x1010},
-	
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		16000, 	384,	12288000,   0x0214},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		16000, 	192,	12288000,   0x0414},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		16000, 	96,		12288000,   0x0814},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		16000, 	48, 	12288000,   0x1014},
-
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		22050, 	512,	11289600,   0x0034},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		22050, 	256,	11289600,   0x0234},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		22050, 	128,	11289600,   0x0434},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		22050, 	64,		11289600,   0x0834},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		22050, 	32,		11289600,   0x1034},
-	
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		24000, 	512,	12288000,   0x0038},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		24000, 	256,	12288000,   0x0238},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		24000, 	128,	12288000,   0x0438},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		24000, 	64,		12288000,   0x0838},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		24000, 	32,		12288000,   0x1038},
-	
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		32000, 	384,	12288000,	0x0018},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		32000, 	192,	12288000,	0x0218},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		32000, 	96,		12288000,	0x0418},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		32000, 	48,		12288000,	0x0818},
-	
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		44100, 	256,	11289600,  	0x0020},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		44100, 	128,	11289600,  	0x0220},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		44100, 	64,		11289600,  	0x0420},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		44100, 	32,		11289600,  	0x0820},
-	
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		48000, 	256,	12288000,  	0x0000},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		48000, 	128,	12288000,  	0x0200},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		48000, 	64,		12288000,  	0x0400},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		48000, 	32,		12288000,  	0x0800},
-	
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		88200, 	128,	11289600,   0x003c},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		88200, 	64,		11289600,   0x023c},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		88200, 	32,		11289600,   0x043c},
-	
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		96000, 	128,	12288000,   0x001c},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		96000, 	64,		12288000,   0x021c},
-	{WM8753_HIFI_HWFMT, 	SND_SOC_HWBITS(16),		96000, 	32,		12288000,   0x041c},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	768,	12288000,  0x020c},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	384,	12288000,  0x040c},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	192,	12288000,  0x080c},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	96,	12288000,  0x100c},
+	
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_11025,	512,	11289600,  0x0230},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_11025,	256,	11289600,  0x0430},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_11025, 	128,	11289600,  0x0830},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_11025,	64,	11289600,  0x1030},
+
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000, 	384,	12288000,  0x0214},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000, 	192,	12288000,  0x0414},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000, 	96,	12288000,  0x0814},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000, 	48, 	12288000,  0x1014},
+
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_22050, 	512,	11289600,  0x0034},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_22050, 	256,	11289600,  0x0234},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_22050, 	128,	11289600,  0x0434},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_22050, 	64,	11289600,  0x0834},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_22050, 	32,	11289600,  0x1034},
+	
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_32000, 	384,	12288000,  0x0018},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_32000, 	192,	12288000,  0x0218},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_32000, 	96,	12288000,  0x0418},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_32000, 	48,	12288000,  0x0818},
+	
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_44100, 	256,	11289600,  0x0020},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_44100, 	128,	11289600,  0x0220},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_44100, 	64,	11289600,  0x0420},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_44100, 	32,	11289600,  0x0820},
+	
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_48000, 	256,	12288000,  0x0000},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_48000, 	128,	12288000,  0x0200},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_48000, 	64,	12288000,  0x0400},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_48000, 	32,	12288000,  0x0800},
+	
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_88200, 	128,	11289600,  0x003c},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_88200, 	64,	11289600,  0x023c},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_88200, 	32,	11289600,  0x043c},
+	
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_96000, 	128,	12288000,  0x001c},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_96000, 	64,	12288000,  0x021c},
+	{WM8753_HIFI_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_96000, 	32,	12288000,  0x041c},
 };
 
 #define WM8753_VOICE_HWFMT \
@@ -182,15 +175,14 @@ static struct snd_soc_hw_mode wm8753_hif
  * priv2 is bits[15..8] = PCM divisor, bits[7..0] = psr
  */
 static struct snd_soc_hw_mode wm8753_voice[] = {
-	{WM8753_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		48000,	256,	12288000, 	0x0000},
-	{WM8753_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		44100,	256,	11289600, 	0x0000},
-	{WM8753_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		32000,	384,	12288000, 	0x0001},
-	{WM8753_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		24000,	256,	12288000, 	0x0400},
-	{WM8753_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		22050,	256,	11289600, 	0x0400},
-	{WM8753_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		16000,	256,	12288000, 	0x0200},
-	{WM8753_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		16000,	384,	12288000, 	0x0401},
-	{WM8753_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		8000,	256,	12288000, 	0x0600},
-	{WM8753_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		8000,	384,	12288000, 	0x0501},
+	{WM8753_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_48000,	256,	12288000, 	0x0000},
+	{WM8753_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_44100,	256,	11289600, 	0x0000},
+	{WM8753_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_32000,	384,	12288000, 	0x0001},
+	{WM8753_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_22050,	256,	11289600, 	0x0400},
+	{WM8753_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000,	256,	12288000, 	0x0200},
+	{WM8753_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000,	384,	12288000, 	0x0401},
+	{WM8753_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	256,	12288000, 	0x0600},
+	{WM8753_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	384,	12288000, 	0x0501},
 };
 
 /*
@@ -241,7 +233,6 @@ static int wm8753_write(struct snd_soc_c
 
 #define wm8753_reset(c) wm8753_write(c, WM8753_RESET, 0)
 
-
 /*
  * WM8753 Controls
  */
@@ -845,16 +836,17 @@ static u32 wm8753_config_pll(struct snd_
 
 static int wm8753_pcm_voice_prepare(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_codec *codec = pcm_c->codec;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_codec *codec = socdev->codec;
 	u16 voice = 0, ioctl, clock, srate;
 	
 	/* enable PLL */
-	wm8753_config_pll(codec, 2, pcm_c->hw_runtime.priv1);
+	wm8753_config_pll(codec, 2, rtd->pcm_c->hw_runtime.priv1);
 	
 	/* set master/slave audio interface */
 	ioctl = wm8753_read_reg_cache(codec, WM8753_IOCTL) & 0x01f1;
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
 		case SND_SOC_HWFMT_CBM_CFM:
 			voice |= 0x0040;
 			ioctl |= 0x0002;
@@ -865,7 +857,7 @@ static int wm8753_pcm_voice_prepare(snd_
 	}
 	
 	/* interface format */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
 		case SND_SOC_HWFMT_I2S:
 			voice |= 0x0002;
 			break;
@@ -883,31 +875,31 @@ static int wm8753_pcm_voice_prepare(snd_
 	}
 	
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
-		case SND_SOC_HWBITS(16):
+	switch(rtd->pcm_c->hw_runtime.hbits) {
+		case SNDRV_PCM_FMTBIT_S16_LE:
 			break;
-		case SND_SOC_HWBITS(20):
+		case SNDRV_PCM_FMTBIT_S20_3LE:
 			voice |= 0x0004;
 			break;
-		case SND_SOC_HWBITS(24):
+		case SNDRV_PCM_FMTBIT_S24_3LE:
 			voice |= 0x0008;
 			break;
-		case SND_SOC_HWBITS(32):
+		case SNDRV_PCM_FMTBIT_S32_LE:
 			voice |= 0x000c;
 			break;
 	}
 	
 	/* set rate */
 	clock = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0x003f;
-	clock |= (pcm_c->hw_runtime.priv2 & 0xff00) >> 2;
+	clock |= (rtd->pcm_c->hw_runtime.priv2 & 0xff00) >> 2;
 	wm8753_write(codec, WM8753_CLOCK, clock);
 
 	srate = wm8753_read_reg_cache(codec, WM8753_SRATE1) & 0x017f;
-	srate |= (pcm_c->hw_runtime. priv2 & 0xff) << 7;
+	srate |= (rtd->pcm_c->hw_runtime. priv2 & 0xff) << 7;
 	wm8753_write(codec, WM8753_SRATE1, srate);
 	
 	/* clock inversion */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
 		case SND_SOC_HWFMT_IB_IF:
 			voice |= 0x0090;
 			break;
@@ -925,16 +917,17 @@ static int wm8753_pcm_voice_prepare(snd_
 
 static int wm8753_pcm_hifi_prepare(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_codec *codec = pcm_c->codec;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_codec *codec = socdev->codec;
 	u16 hifi = 0, ioctl, srate;
 		
 	/* enable PLL */
-	wm8753_config_pll(codec, 1, pcm_c->hw_runtime.priv1);
+	wm8753_config_pll(codec, 1, rtd->pcm_c->hw_runtime.priv1);
 	
 	/* set master/slave audio interface */
 	ioctl = wm8753_read_reg_cache(codec, WM8753_IOCTL) & 0x00f2;
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
 		case SND_SOC_HWFMT_CBM_CFM:
 			hifi |= 0x0040;
 			ioctl |= 0x0001;
@@ -945,7 +938,7 @@ static int wm8753_pcm_hifi_prepare(snd_p
 	}
 	
 	/* interface format */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
 		case SND_SOC_HWFMT_I2S:
 			hifi |= 0x0002;
 			break;
@@ -963,23 +956,23 @@ static int wm8753_pcm_hifi_prepare(snd_p
 	}
 	
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
-		case SND_SOC_HWBITS(16):
+	switch(rtd->pcm_c->hw_runtime.hbits) {
+		case SNDRV_PCM_FMTBIT_S16_LE:
 			break;
-		case SND_SOC_HWBITS(20):
+		case SNDRV_PCM_FMTBIT_S20_3LE:
 			hifi |= 0x0004;
 			break;
-		case SND_SOC_HWBITS(24):
+		case SNDRV_PCM_FMTBIT_S24_3LE:
 			hifi |= 0x0008;
 			break;
-		case SND_SOC_HWBITS(32):
+		case SNDRV_PCM_FMTBIT_S32_LE:
 			hifi |= 0x000c;
 			break;
 	}
 	
 	/* set rate */
 	srate = wm8753_read_reg_cache(codec, WM8753_SRATE2) & 0x01c7;
-	switch ((pcm_c->hw_runtime.priv2 & 0xff00) >> 8){
+	switch ((rtd->pcm_c->hw_runtime.priv2 & 0xff00) >> 8){
 		case 1:
 			break;
 		case 2:
@@ -996,11 +989,11 @@ static int wm8753_pcm_hifi_prepare(snd_p
 			break;
 	}		
 	wm8753_write(codec, WM8753_SRATE2, srate);
-	srate = (pcm_c->hw_runtime. priv2 & 0xff) << 1;
+	srate = (rtd->pcm_c->hw_runtime. priv2 & 0xff) << 1;
 	wm8753_write(codec, WM8753_SRATE1, srate);
 	
 	/* clock inversion */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
 		case SND_SOC_HWFMT_IB_IF:
 			hifi |= 0x0090;
 			break;
@@ -1046,17 +1039,10 @@ static struct snd_soc_pcm_codec wm8753_p
 {	.name = "WM8753 Voice",
 	.playback = {
 		.sname = "Voice Playback",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 1,},
 	.capture = {
 		.sname = "Voice Capture",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | 
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 |
-		SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,},
 	.nplayback = 1,
@@ -1070,10 +1056,6 @@ static struct snd_soc_pcm_codec wm8753_p
 {	.name = "WM8753 HiFi",
 	.playback = {
 		.sname = "HiFi Playback",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 |
-		SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,},
 	.nplayback = 1,
@@ -1085,17 +1067,47 @@ static struct snd_soc_pcm_codec wm8753_p
 		.hmodes = &wm8753_hifi[0],},},
 };
 
-static int wm8753_suspend(struct device *dev, pm_message_t state)
+static void wm8753_work(void *data)
+{
+	struct snd_soc_codec *codec = (struct snd_soc_codec *)data;
+	wm8753_dpm_event(codec, codec->dpm_state);
+}
+
+static int wm8753_suspend(struct platform_device *pdev, pm_message_t state)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
 	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
 	return 0;
 }
 
-static int wm8753_resume(struct device *dev)
+static int wm8753_resume(struct platform_device *pdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+	int i;
+	u8 data[2];
+	u16 *cache = codec->reg_cache;
+
+	/* Sync reg_cache with the hardware */
+	for (i = 0; i < ARRAY_SIZE(wm8753_reg); i++) {
+		if (i + 1 == WM8753_RESET)
+			continue;
+		data[0] = ((i + 1) << 1) | ((cache[i] >> 8) & 0x0001);
+		data[1] = cache[i] & 0x00ff;
+		codec->hw_write(codec->control_data, data, 2);
+	}
+	
 	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+		
+	/* charge wm8753 caps */
+	if(codec->suspend_dpm_state == SNDRV_CTL_POWER_D0) {
+		wm8753_dpm_event(codec, SNDRV_CTL_POWER_D2);
+		codec->dpm_state = SNDRV_CTL_POWER_D0;
+		queue_delayed_work(wm8753_workq, &wm8753_dpm_work, msecs_to_jiffies(1000));
+	}
+	
 	return 0;
 }
 
@@ -1103,9 +1115,9 @@ static int wm8753_resume(struct device *
  * initialise the WM8753 driver
  * register the mixer and dsp interfaces with the kernel 
  */
-static int wm8753_probe(struct device *dev)
+static int wm8753_init(struct snd_soc_device* socdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_codec* codec = socdev->codec;
 	int reg, ret = 0;
 
 	codec->name = "WM8753";
@@ -1122,16 +1134,17 @@ static int wm8753_probe(struct device *d
 	
 	wm8753_reset(codec);
 
-	/* charge output caps */
-	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D2);
-
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
-		wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		kfree(codec->reg_cache);
 		return ret;
 	}
 
+	/* charge output caps */
+	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D2);
+	codec->dpm_state = SNDRV_CTL_POWER_D3hot;
+	queue_delayed_work(wm8753_workq, &wm8753_dpm_work, msecs_to_jiffies(1000));
+
 	/* set the update bits */
 	reg = wm8753_read_reg_cache(codec, WM8753_LDAC);
 	wm8753_write(codec, WM8753_LDAC, reg | 0x0100);
@@ -1152,48 +1165,163 @@ static int wm8753_probe(struct device *d
 
 	wm8753_add_controls(codec);
 	wm8753_add_widgets(codec);
-	snd_soc_register_card(codec);
-
-	/* wait for caps to finish charging - liam make this thread */
-	ssleep(1);
-	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+	snd_soc_register_card(socdev);
 
 	return ret;
 }
 
-/* power down chip */
-static int wm8753_remove(struct device *dev)
+#ifdef CONFIG_I2C
+
+/*
+ * WM8753 2 wire address is determined by GPIO5
+ * state during powerup.
+ *    low  = 0x1a
+ *    high = 0x1b
+ */
+#define I2C_DRIVERID_WM8753 0xfefe /* liam -  need a proper id */
+
+static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
+
+/* Magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver wm8753_i2c_driver;
+static struct i2c_client client_template;
+
+/* If the i2c layer weren't so broken, we could pass this kind of data
+   around */
+static struct snd_soc_device *wm8753_socdev;
+
+static int wm8753_codec_probe(struct i2c_adapter *adap, int addr, int kind)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
-	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
-	snd_soc_free_pcms(codec);
+	struct snd_soc_device *socdev = wm8753_socdev;
+	struct wm8753_setup_data *setup = socdev->codec_data;
+	struct snd_soc_codec* codec = socdev->codec;
+	struct i2c_client *i2c;
+	int ret;
+
+	if (addr != setup->i2c_address)
+		return -ENODEV;
+
+	client_template.adapter = adap;
+	client_template.addr = addr;
+
+	if ((i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL)) == NULL){
+		kfree(codec);
+		return -ENOMEM;
+	}
+	memcpy(i2c, &client_template, sizeof(struct i2c_client));
+
+	i2c_set_clientdata(i2c, codec);
+
+	codec->control_data = i2c;
+
+	if((ret = i2c_attach_client(i2c)) < 0) {
+		err("failed to attach codec at addr %x\n", addr);
+		kfree(i2c);
+		return ret;
+	}
+
+	wm8753_init(socdev);
+
+	return 0;
+}
+
+static int wm8753_i2c_detach(struct i2c_client *client)
+{
+	struct snd_soc_codec* codec = i2c_get_clientdata(client);
+
+	i2c_detach_client(client);
 	kfree(codec->reg_cache);
+	kfree(client);
+
 	return 0;
 }
 
-static struct device_driver wm8753_driver = {
-	.name = 	"WM8753", 
-	.bus = 		&soc_bus_type, 
-	.owner = 	THIS_MODULE, 
-	.probe = 	wm8753_probe, 
-	.remove = 	wm8753_remove, 
-	.suspend = 	wm8753_suspend, 
-	.resume =	wm8753_resume, 
+static int wm8753_i2c_attach(struct i2c_adapter *adap)
+{
+	return i2c_probe(adap, &addr_data, wm8753_codec_probe);
+}
+
+/* corgi i2c codec control layer */
+static struct i2c_driver wm8753_i2c_driver = {
+	.name =           "WM8753 I2C Codec",
+	.id =             I2C_DRIVERID_WM8753,
+	.flags =          I2C_DF_NOTIFY,
+	.attach_adapter = wm8753_i2c_attach,
+	.detach_client =  wm8753_i2c_detach,
+	.command =        NULL,
+};
+
+static struct i2c_client client_template = {
+	.name =   "WM8753",
+	.flags =  I2C_CLIENT_ALLOW_USE,
+	.driver = &wm8753_i2c_driver,
 };
 
-static int __init wm8753_init(void)
+static int wm8753_probe(struct platform_device *pdev)
 {
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct wm8753_setup_data *setup = socdev->codec_data;
+	struct snd_soc_codec* codec;
+	int ret = 0;
+
 	info("WM8753 Audio Codec %s", WM8753_VERSION);
-	return driver_register(&wm8753_driver);
+
+	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
+		return -ENOMEM;
+
+	socdev->codec = codec;
+	
+	INIT_LIST_HEAD(&codec->dpm_widgets);
+	INIT_LIST_HEAD(&codec->dpm_paths);
+	wm8753_socdev = socdev;
+	INIT_WORK(&wm8753_dpm_work, wm8753_work, codec);
+	if((wm8753_workq = create_workqueue("wm8753")) == NULL) {
+		kfree(codec);
+		return -ENOMEM;
+	}
+	
+	if (setup->i2c_address) {
+		normal_i2c[0] = setup->i2c_address;
+		codec->hw_write = (hw_write_t)i2c_master_send;
+		if ((ret = i2c_add_driver(&wm8753_i2c_driver)) != 0)
+			printk(KERN_ERR "can't add i2c driver");
+	} else {
+		/* Add other interfaces here */
+	}
+
+	return ret;
 }
 
-static void __exit wm8753_exit(void)
+#endif
+
+/* power down chip */
+static int wm8753_remove(struct platform_device *pdev)
 {
-	driver_unregister(&wm8753_driver);
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
+	if (codec->control_data)
+		wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+	if(wm8753_workq)
+		destroy_workqueue(wm8753_workq);
+	snd_soc_free_pcms(socdev);
+	i2c_del_driver(&wm8753_i2c_driver);
+	kfree(codec);
+
+	return 0;
 }
 
-module_init(wm8753_init);
-module_exit(wm8753_exit);
+
+struct snd_soc_codec_device soc_codec_dev_wm8753 = {
+	.probe = 	wm8753_probe,
+	.remove = 	wm8753_remove,
+	.suspend = 	wm8753_suspend,
+	.resume =	wm8753_resume,
+};
+
+EXPORT_SYMBOL_GPL(soc_codec_dev_wm8753);
 
 MODULE_DESCRIPTION("Soc WM8753 driver");
 MODULE_AUTHOR("Liam Girdwood");
diff --git a/sound/soc/codecs/wm8753.h b/sound/soc/codecs/wm8753.h
index c7f2a6b..522bd79 100644
--- a/sound/soc/codecs/wm8753.h
+++ b/sound/soc/codecs/wm8753.h
@@ -78,4 +78,10 @@
 #define WM8753_BIASCTL	0x3d
 #define WM8753_ADCTL2	0x3f
 
+struct wm8753_setup_data {
+	unsigned short i2c_address;
+};
+
+extern struct snd_soc_codec_device soc_codec_dev_wm8753;
+
 #endif
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c
index 5796e07..f36f1e1 100644
--- a/sound/soc/codecs/wm8971.c
+++ b/sound/soc/codecs/wm8971.c
@@ -20,7 +20,8 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
-#include <linux/device.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
 #include <sound/driver.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -32,7 +33,7 @@
 #include "wm8971.h"
 
 #define AUDIO_NAME "wm8971"
-#define WM8971_VERSION "0.3"
+#define WM8971_VERSION "0.4"
 
 
 #define PFX AUDIO_NAME
@@ -47,9 +48,12 @@
 #define info(format, arg...) printk(KERN_INFO PFX ": " format "\n" , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING PFX ": " format "\n" , ## arg)
 
-
 #define	WM8971_REG_COUNT		43
 
+static struct workqueue_struct *wm8971_workq = NULL;
+static struct work_struct wm8971_dpm_work;
+
+
 /*
  * wm8971 register cache
  * We can't read the WM8971 register space when we 
@@ -77,60 +81,50 @@ static const u16 wm8971_reg[] = {
 
 /* priv1 is srate register setting */
 static struct snd_soc_hw_mode wm8971_audio[] = {
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 8000,   64, 0x000c},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 8000,   96, 0x000e},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 8000,  128, 0x004c},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 8000,  192, 0x004e},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 11025, 64,  0x0030},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 11025, 96,  0x0032},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 11025, 128, 0x0070},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 11025, 192, 0x0072},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 12000, 64,  0x0010},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 12000, 96,  0x0012},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 12000, 128, 0x0050},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 12000, 192, 0x0052},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 16000, 64,  0x0014},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 16000, 96,  0x0016},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 16000, 128, 0x0054},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 16000, 192, 0x0056},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 22050, 64,  0x0034},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 22050, 96,  0x0036},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 22050, 128, 0x0074},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 22050, 192, 0x0076},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 24000, 64,  0x0038},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 24000, 96,  0x003a},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 24000, 128, 0x0078},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 24000, 192, 0x007a},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 32000,  64, 0x0018},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 32000,  96, 0x001a},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 32000, 128, 0x0058},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 32000, 192, 0x005a},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 44100,  64, 0x0020},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 44100,  96, 0x0022},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 44100, 128, 0x0060},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 44100, 192, 0x0062},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 48000,  64, 0x0000},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 48000,  96, 0x0002},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 48000, 128, 0x0040},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 48000, 192, 0x0042},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 88200,  32, 0x003c},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 88200,  48, 0x003e},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 88200,  64, 0x007c},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 88200,  96, 0x007e},
-
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 96000,  32, 0x001c},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 96000,  48, 0x001e},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 96000,  64, 0x005c},
-	{WM8971_HWFMT, SND_SOC_HWBITS(16), 96000,  96, 0x005e},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,   64, 0x000c},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,   96, 0x000e},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,  128, 0x004c},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_8000,  192, 0x004e},
+
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_11025, 64,  0x0030},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_11025, 96,  0x0032},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_11025, 128, 0x0070},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_11025, 192, 0x0072},
+
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_16000, 64,  0x0014},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_16000, 96,  0x0016},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_16000, 128, 0x0054},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_16000, 192, 0x0056},
+
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_22050, 64,  0x0034},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_22050, 96,  0x0036},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_22050, 128, 0x0074},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_22050, 192, 0x0076},
+
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000,  64, 0x0018},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000,  96, 0x001a},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000, 128, 0x0058},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_32000, 192, 0x005a},
+
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100,  64, 0x0020},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100,  96, 0x0022},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100, 128, 0x0060},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_44100, 192, 0x0062},
+
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000,  64, 0x0000},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000,  96, 0x0002},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000, 128, 0x0040},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_48000, 192, 0x0042},
+
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  32, 0x003c},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  48, 0x003e},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  64, 0x007c},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_88200,  96, 0x007e},
+
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  32, 0x001c},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  48, 0x001e},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  64, 0x005c},
+	{WM8971_HWFMT, SNDRV_PCM_FMTBIT_S16_LE, SNDRV_PCM_RATE_96000,  96, 0x005e},
 };
 
 static inline unsigned int wm8971_read_reg_cache(struct snd_soc_codec * codec, 
@@ -490,12 +484,13 @@ static int wm8971_add_widgets(struct snd
 
 static int wm8971_pcm_prepare(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_codec *codec = pcm_c->codec;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_codec *codec =socdev->codec;
 	u16 iface = 0;
 	
 	/* set master/slave audio interface */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
 		case SND_SOC_HWFMT_CBM_CFM:
 			iface |= 0x0040;
 			break;
@@ -504,7 +499,7 @@ static int wm8971_pcm_prepare(snd_pcm_su
 	}
 	
 	/* interface format */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
 		case SND_SOC_HWFMT_I2S:
 			iface |= 0x0002;
 			break;
@@ -522,22 +517,22 @@ static int wm8971_pcm_prepare(snd_pcm_su
 	}
 		
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
-		case SND_SOC_HWBITS(16):
+	switch(rtd->pcm_c->hw_runtime.hbits) {
+		case SNDRV_PCM_FMTBIT_S16_LE:
 			break;
-		case SND_SOC_HWBITS(20):
+		case SNDRV_PCM_FMTBIT_S20_3LE:
 			iface |= 0x0004;
 			break;
-		case SND_SOC_HWBITS(24):
+		case SNDRV_PCM_FMTBIT_S24_3LE:
 			iface |= 0x0008;
 			break;
-		case SND_SOC_HWBITS(32):
+		case SNDRV_PCM_FMTBIT_S32_LE:
 			iface |= 0x000c;
 			break;
 	}
 
 	/* clock inversion */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
 		case SND_SOC_HWFMT_NB_NF:
 			break;
 		case SND_SOC_HWFMT_IB_IF:
@@ -552,7 +547,7 @@ static int wm8971_pcm_prepare(snd_pcm_su
 	}
 	
 	/* set rate */
-	wm8971_write(codec, WM8971_SRATE, pcm_c->hw_runtime.priv1);
+	wm8971_write(codec, WM8971_SRATE, rtd->pcm_c->hw_runtime.priv1);
 	wm8971_write(codec, WM8971_AUDIO, iface);
 	
 	return 0;
@@ -580,7 +575,7 @@ static int wm8971_dpm_event(struct snd_s
 			wm8971_write(codec, WM8971_PWR1, 0x0000);
 			break;
 	}
-	
+	codec->dpm_state = event;
 	return 0;
 }
 
@@ -588,20 +583,12 @@ static struct snd_soc_pcm_codec wm8971_p
 	.name = "WM8971",
 	.playback = {
 		.sname = "Playback",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 |
-		SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,
 	},
 	.nplayback = 1,
 	.capture = {
 		.sname = "Capture",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | 
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 |
-		SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 1,
 		.channels_max = 2,
 	},
@@ -615,23 +602,53 @@ static struct snd_soc_pcm_codec wm8971_p
 	},
 };
 
-static int wm8971_suspend(struct device *dev, pm_message_t state)
+static void wm8971_work(void *data)
+{
+	struct snd_soc_codec *codec = (struct snd_soc_codec *)data;
+	wm8971_dpm_event(codec, codec->dpm_state);
+}
+
+static int wm8971_suspend(struct platform_device *pdev, pm_message_t state)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
 	wm8971_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
 	return 0;
 }
 
-static int wm8971_resume(struct device *dev)
+static int wm8971_resume(struct platform_device *pdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+	int i;
+	u8 data[2];
+	u16 *cache = codec->reg_cache;
+
+	/* Sync reg_cache with the hardware */
+	for (i = 0; i < ARRAY_SIZE(wm8971_reg); i++) {
+		if (i + 1 == WM8971_RESET)
+			continue;
+		data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001);
+		data[1] = cache[i] & 0x00ff;
+		codec->hw_write(codec->control_data, data, 2);
+	}
+		
 	wm8971_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+		
+	/* charge wm8971 caps */
+	if(codec->suspend_dpm_state == SNDRV_CTL_POWER_D0) {
+		wm8971_dpm_event(codec, SNDRV_CTL_POWER_D2);
+		codec->dpm_state = SNDRV_CTL_POWER_D0;
+		queue_delayed_work(wm8971_workq, &wm8971_dpm_work, msecs_to_jiffies(1000));
+	}
+	
 	return 0;
 }
 
-static int wm8971_probe(struct device *dev)
+static int wm8971_init(struct snd_soc_device* socdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_codec* codec = socdev->codec;
 	int reg, ret = 0;
 
 	codec->name = "WM8971";
@@ -648,15 +665,17 @@ static int wm8971_probe(struct device *d
 	
 	wm8971_reset(codec);
 
-	/* charge output caps */
-	wm8971_dpm_event(codec, SNDRV_CTL_POWER_D2);
-
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
-		wm8971_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		kfree(codec->reg_cache);
 		return ret;
 	}
+	
+	/* charge output caps */
+	wm8971_dpm_event(codec, SNDRV_CTL_POWER_D2);
+	codec->dpm_state = SNDRV_CTL_POWER_D3hot;
+	queue_delayed_work(wm8971_workq, &wm8971_dpm_work, msecs_to_jiffies(1000));
+	
 
 	/* set the update bits */
 	reg = wm8971_read_reg_cache(codec, WM8971_LDAC);
@@ -681,48 +700,163 @@ static int wm8971_probe(struct device *d
 
 	wm8971_add_controls(codec);
 	wm8971_add_widgets(codec);
-	snd_soc_register_card(codec);
-	
-	/* wait for caps to finish charging - liam make this thread */
-	ssleep(1);
-	wm8971_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+	snd_soc_register_card(socdev);
 
 	return 0;
 }
 
-/* power down chip */
-static int wm8971_remove(struct device *dev)
+#ifdef CONFIG_I2C
+
+/*
+ * WM8731 2 wire address is determined by GPIO5
+ * state during powerup.
+ *    low  = 0x1a
+ *    high = 0x1b
+ */
+#define I2C_DRIVERID_WM8971 0xfefe /* liam -  need a proper id */
+
+static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
+
+/* Magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver wm8971_i2c_driver;
+static struct i2c_client client_template;
+
+/* If the i2c layer weren't so broken, we could pass this kind of data
+   around */
+static struct snd_soc_device *wm8971_socdev;
+
+static int wm8971_codec_probe(struct i2c_adapter *adap, int addr, int kind)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
-	wm8971_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
-	snd_soc_free_pcms(codec);
+	struct snd_soc_device *socdev = wm8971_socdev;
+	struct wm8971_setup_data *setup = socdev->codec_data;
+	struct snd_soc_codec* codec = socdev->codec;
+	struct i2c_client *i2c;
+	int ret;
+
+	if (addr != setup->i2c_address)
+		return -ENODEV;
+
+	client_template.adapter = adap;
+	client_template.addr = addr;
+
+	if ((i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL)) == NULL){
+		kfree(codec);
+		return -ENOMEM;
+	}
+	memcpy(i2c, &client_template, sizeof(struct i2c_client));
+
+	i2c_set_clientdata(i2c, codec);
+
+	codec->control_data = i2c;
+
+	if((ret = i2c_attach_client(i2c)) < 0) {
+		err("failed to attach codec at addr %x\n", addr);
+		kfree(i2c);
+		return ret;
+	}
+
+	wm8971_init(socdev);
+
+	return 0;
+}
+
+static int wm8971_i2c_detach(struct i2c_client *client)
+{
+	struct snd_soc_codec* codec = i2c_get_clientdata(client);
+
+	i2c_detach_client(client);
 	kfree(codec->reg_cache);
+	kfree(client);
+
 	return 0;
 }
 
-static struct device_driver wm8971_driver = {
-	.name = 	"WM8971", 
-	.bus = 		&soc_bus_type, 
-	.owner = 	THIS_MODULE, 
-	.probe = 	wm8971_probe, 
-	.remove = 	wm8971_remove, 
-	.suspend = 	wm8971_suspend, 
-	.resume =	wm8971_resume, 
+static int wm8971_i2c_attach(struct i2c_adapter *adap)
+{
+	return i2c_probe(adap, &addr_data, wm8971_codec_probe);
+}
+
+/* corgi i2c codec control layer */
+static struct i2c_driver wm8971_i2c_driver = {
+	.name =           "WM8971 I2C Codec",
+	.id =             I2C_DRIVERID_WM8971,
+	.flags =          I2C_DF_NOTIFY,
+	.attach_adapter = wm8971_i2c_attach,
+	.detach_client =  wm8971_i2c_detach,
+	.command =        NULL,
+};
+
+static struct i2c_client client_template = {
+	.name =   "WM8971",
+	.flags =  I2C_CLIENT_ALLOW_USE,
+	.driver = &wm8971_i2c_driver,
 };
 
-static int __init wm8971_init(void)
+static int wm8971_probe(struct platform_device *pdev)
 {
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct wm8971_setup_data *setup = socdev->codec_data;
+	struct snd_soc_codec* codec;
+	int ret = 0;
+
 	info("WM8971 Audio Codec %s", WM8971_VERSION);
-	return driver_register(&wm8971_driver);
+
+	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
+		return -ENOMEM;
+
+	socdev->codec = codec;
+	INIT_LIST_HEAD(&codec->dpm_widgets);
+	INIT_LIST_HEAD(&codec->dpm_paths);
+	wm8971_socdev = socdev;
+	
+	INIT_WORK(&wm8971_dpm_work, wm8971_work, codec);
+	if((wm8971_workq = create_workqueue("wm8971")) == NULL) {
+		kfree(codec);
+		return -ENOMEM;
+	}
+	
+	if (setup->i2c_address) {
+		normal_i2c[0] = setup->i2c_address;
+		codec->hw_write = (hw_write_t)i2c_master_send;
+		if ((ret = i2c_add_driver(&wm8971_i2c_driver)) != 0)
+			printk(KERN_ERR "can't add i2c driver");
+	} else {
+		/* Add other interfaces here */
+	}
+
+	return ret;
 }
 
-static void __exit wm8971_exit(void)
+#endif
+
+/* power down chip */
+static int wm8971_remove(struct platform_device *pdev)
 {
-	driver_unregister(&wm8971_driver);
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
+	if (codec->control_data)
+		wm8971_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+	if(wm8971_workq)
+		destroy_workqueue(wm8971_workq);
+	snd_soc_free_pcms(socdev);
+	i2c_del_driver(&wm8971_i2c_driver);
+	kfree(codec);
+
+	return 0;
 }
 
-module_init(wm8971_init);
-module_exit(wm8971_exit);
+
+struct snd_soc_codec_device soc_codec_dev_wm8971 = {
+	.probe = 	wm8971_probe,
+	.remove = 	wm8971_remove,
+	.suspend = 	wm8971_suspend,
+	.resume =	wm8971_resume,
+};
+
+EXPORT_SYMBOL_GPL(soc_codec_dev_wm8971);
 
 MODULE_DESCRIPTION("SoC WM8971 driver");
 MODULE_AUTHOR("Lab126");
diff --git a/sound/soc/codecs/wm8971.h b/sound/soc/codecs/wm8971.h
index c6fbe76..98b05fc 100644
--- a/sound/soc/codecs/wm8971.h
+++ b/sound/soc/codecs/wm8971.h
@@ -51,5 +51,11 @@
 #define WM8971_ROUT2V	0x29
 #define WM8971_MOUTV	0x2A
 
+struct wm8971_setup_data {
+	unsigned short i2c_address;
+};
+
+extern struct snd_soc_codec_device soc_codec_dev_wm8971;
+
 #endif
 
diff --git a/sound/soc/codecs/wm9713-voice.c b/sound/soc/codecs/wm9713-voice.c
index 29388b1..965887f 100644
--- a/sound/soc/codecs/wm9713-voice.c
+++ b/sound/soc/codecs/wm9713-voice.c
@@ -1,5 +1,5 @@
 /*
- * wm9713-voice.c  --  PXA WM9713 PCM audio driver 
+ * wm9713-voice.c  --  WM9713 PCM audio driver 
  *
  * Copyright 2005 Wolfson Microelectronics PLC.
  * Author: Liam Girdwood
@@ -10,21 +10,6 @@
  *  Free Software Foundation;  either version 2 of the  License, or (at your
  *  option) any later version.
  *
- *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
- *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
- *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- *
  *  Revision history
  *    1st Aug 2005   Initial version.
  * 
@@ -43,8 +28,9 @@
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
 #include <sound/initval.h>
+#include <sound/ac97_codec.h>
 
-#define WM9713_VERSION		"0.3"
+#define WM9713_VERSION		"0.4"
 
 #define WM9713_PCM_8K		(0xb << 8)
 #define WM9713_PCM_12K		(0x7 << 8)
@@ -64,111 +50,127 @@
  * priv1 is pcm clock divider
  */
 static struct snd_soc_hw_mode wm9713_voice[] = {
-	{WM9713_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		48000,	256,	WM9713_PCM_48K, },
-	{WM9713_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		32000,	384,	WM9713_PCM_32K,},
-	{WM9713_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		24000,	256,	WM9713_PCM_24K,},
-	{WM9713_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		16000,	256,	WM9713_PCM_16K,},
-	{WM9713_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		8000,	256,	WM9713_PCM_8K,},
+	{WM9713_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_48000,	256,	WM9713_PCM_48K, },
+	{WM9713_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_32000,	384,	WM9713_PCM_32K,},
+	{WM9713_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000,	256,	WM9713_PCM_16K,},
+	{WM9713_VOICE_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	256,	WM9713_PCM_8K,},
 };
 
+static unsigned int ac97_read(struct snd_soc_codec *codec, 
+	unsigned int reg)
+{
+	return soc_ac97_ops.read(codec->ac97, reg);
+}
+
+static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
+	unsigned int val)
+{
+	soc_ac97_ops.write(codec->ac97, reg, val);
+	return 0;
+}
+
 static int wm9713_voice_startup(snd_pcm_substream_t *substream)
 {
 	int reg;
-#if 0
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_codec *codec = socdev->codec;
+
 	/* power up clock control and voice DAC - move to dpm */
-	reg = wm97xx_reg_read(wm9713.wm, AC97_POWERDOWN); 
-	wm97xx_reg_write(wm9713.wm, AC97_POWERDOWN, reg & ~0x2000);
-	reg = wm97xx_reg_read(wm9713.wm, AC97_EXTENDED_MID); 
-	wm97xx_reg_write(wm9713.wm, AC97_EXTENDED_MID, reg & ~0x1000);
-#endif
+	reg = ac97_read(codec, AC97_POWERDOWN); 
+	ac97_write(codec, AC97_POWERDOWN, reg & ~0x2000);
+	reg = ac97_read(codec, AC97_EXTENDED_MID); 
+	ac97_write(codec, AC97_EXTENDED_MID, reg & ~0x1000);
+
 	return 0;
 }
 
 static int wm9713_voice_prepare(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_codec *codec = socdev->codec;
 	u16 reg = 0x8000;
 
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK){
-		case SND_SOC_HWFMT_CBM_CFM:
-			reg |= 0x4000;
-			break;
-		case SND_SOC_HWFMT_CBM_CFS:
-			reg |= 0x6000;
-			break;
-		case SND_SOC_HWFMT_CBS_CFS:
-			reg |= 0x0200;
-			break;
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK){
+	case SND_SOC_HWFMT_CBM_CFM:
+		reg |= 0x4000;
+		break;
+	case SND_SOC_HWFMT_CBM_CFS:
+		reg |= 0x6000;
+		break;
+	case SND_SOC_HWFMT_CBS_CFS:
+		reg |= 0x0200;
+		break;
 	}
+	
 	/* clock inversion */
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
-		case SND_SOC_HWFMT_IB_IF:
-			reg |= 0x00c0;
-			break;
-		case SND_SOC_HWFMT_IB_NF:
-			reg |= 0x0080;
-			break;
-		case SND_SOC_HWFMT_NB_IF:
-			reg |= 0x0040;
-			break;
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) {
+	case SND_SOC_HWFMT_IB_IF:
+		reg |= 0x00c0;
+		break;
+	case SND_SOC_HWFMT_IB_NF:
+		reg |= 0x0080;
+		break;
+	case SND_SOC_HWFMT_NB_IF:
+		reg |= 0x0040;
+		break;
 	}
 	
-	switch(pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
-		case SND_SOC_HWFMT_I2S:
-			reg |= 0x0002;
-			break;
-		case SND_SOC_HWFMT_RIGHT_J:
-			break;
-		case SND_SOC_HWFMT_LEFT_J:
-			reg |= 0x0001;
-			break;
-		case SND_SOC_HWFMT_DSP_A:
-			reg |= 0x0003;
-			break;
-		case SND_SOC_HWFMT_DSP_B:
-			reg |= 0x0043;
-			break;
+	switch(rtd->pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) {
+	case SND_SOC_HWFMT_I2S:
+		reg |= 0x0002;
+		break;
+	case SND_SOC_HWFMT_RIGHT_J:
+		break;
+	case SND_SOC_HWFMT_LEFT_J:
+		reg |= 0x0001;
+		break;
+	case SND_SOC_HWFMT_DSP_A:
+		reg |= 0x0003;
+		break;
+	case SND_SOC_HWFMT_DSP_B:
+		reg |= 0x0043;
+		break;
 	}
-	switch(pcm_c->hw_runtime.hbits) {
-		case SND_SOC_HWBITS(16):
-			break;
-		case SND_SOC_HWBITS(20):
-			reg |= 0x0004;
-			break;
-		case SND_SOC_HWBITS(24):
-			reg |= 0x0008;
-			break;
-		case SND_SOC_HWBITS(32):
-			reg |= 0x000c;
-			break;
+	
+	switch(rtd->pcm_c->hw_runtime.hbits) {
+	case SNDRV_PCM_FMTBIT_S16_LE:
+		break;
+	case SNDRV_PCM_FMTBIT_S20_3LE:
+		reg |= 0x0004;
+		break;
+	case SNDRV_PCM_FMTBIT_S24_3LE:
+		reg |= 0x0008;
+		break;
+	case SNDRV_PCM_FMTBIT_S32_LE:
+		reg |= 0x000c;
+		break;
 	}
+	
 	/* enable PCM interface in master mode */
-//	wm97xx_reg_write(wm9713.wm, AC97_CENTER_LFE_MASTER, reg);
+	ac97_write(codec, AC97_CENTER_LFE_MASTER, reg);
 	
 	/* sample rate */
-//	reg = wm97xx_reg_read(wm9713.wm, AC97_HANDSET_RATE) &0xe0ff;
-//	wm97xx_reg_write(wm9713.wm, AC97_HANDSET_RATE, reg | pcm_c->hw_runtime.priv1);
+	reg = ac97_read(codec, AC97_HANDSET_RATE) &0xe0ff;
+	ac97_write(codec, AC97_HANDSET_RATE, reg | rtd->pcm_c->hw_runtime.priv1);
 	return 0;
 }
 
 static struct snd_soc_pcm_codec wm9713_pcm_client = {
 	.name = "WM9713 Voice",
 	.playback = {
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		.sname = "Voice Playback",
 		.channels_min = 1,
 		.channels_max = 1,},
+	.nplayback = 1,
 	.capture = {
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | 
-		SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 |
-		SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		.sname = "Voice Capture",
 		.channels_min = 1,
 		.channels_max = 1,},
+	.ncapture = 1,
 	.ops = {
 		.startup = wm9713_voice_startup,
-	//	.shutdown = wm9713_voice_shutdown,
 		.prepare = wm9713_voice_prepare,},
 	.hw = {
 		.num_hmodes = ARRAY_SIZE(wm9713_voice),
@@ -177,87 +179,81 @@ static struct snd_soc_pcm_codec wm9713_p
 };
 
 
-static int wm9713_suspend(struct device *dev, pm_message_t state)
+static int wm9713v_suspend(struct platform_device *pdev, pm_message_t state)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+//	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
 //	wm9713_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
 	return 0;
 }
 
-static int wm9713_resume(struct device *dev)
+static int wm9713v_resume(struct platform_device *pdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
+//	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
 //	wm9713_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
 
-static int wm9713_probe(struct device *dev)
-{
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
-	int reg, ret = 0;
+static struct snd_soc_device *wm9713v_socdev;
 
+static int wm9713v_probe(struct platform_device *pdev)
+{
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec;
+	int ret = 0;
+
+	printk(KERN_INFO "WM9713 Voice Codec %s", WM9713_VERSION);
+
+	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
+		return -ENOMEM;
+
+	socdev->codec = codec;
+	INIT_LIST_HEAD(&codec->dpm_widgets);
+	INIT_LIST_HEAD(&codec->dpm_paths);
+	wm9713v_socdev = socdev;
 	codec->name = "WM9713";
 	codec->owner = THIS_MODULE;
-//	codec->read = wm9713_read_reg_cache;
-//	codec->write = wm9713_write;
+	codec->read = ac97_read;
+	codec->write = ac97_write;
 //	codec->dpm_event = wm9713_dpm_event;
 	codec->pcms = &wm9713_pcm_client;
 	codec->npcms = 1;
 
-	/* charge output caps */
-//	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D2);
-
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
-		//wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		return ret;
 	}
 
-
-	snd_soc_register_card(codec);
-
-	/* wait for caps to finish charging - liam make this thread */
-	//ssleep(1);
-	//wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
-
+	ret = snd_soc_register_card(socdev);
+	//wm9713v_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+	
 	return ret;
 }
 
 /* power down chip */
-static int wm9713_remove(struct device *dev)
+static int wm9713v_remove(struct platform_device *pdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
-	//wm9713_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
-	snd_soc_free_pcms(codec);
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
+	//wm9713v_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
+	snd_soc_free_pcms(socdev);
+	kfree(codec);
+
 	return 0;
 }
 
 
-static struct device_driver wm9713_driver = {
-	.name = 	"WM9713", 
-	.bus = 		&soc_bus_type, 
-	.owner = 	THIS_MODULE, 
-	.probe = 	wm9713_probe, 
-	.remove = 	wm9713_remove, 
-	.suspend = 	wm9713_suspend, 
-	.resume =	wm9713_resume, 
+struct snd_soc_codec_device soc_codec_dev_wm9713v = {
+	.probe = 	wm9713v_probe,
+	.remove = 	wm9713v_remove,
+	.suspend = 	wm9713v_suspend,
+	.resume =	wm9713v_resume,
 };
 
-static int __init wm9713_init(void)
-{
-	printk(KERN_INFO "WM9713 Audio Codec %s", WM9713_VERSION);
-	return driver_register(&wm9713_driver);
-}
-
-static void __exit wm9713_exit(void)
-{
-	driver_unregister(&wm9713_driver);
-}
+EXPORT_SYMBOL_GPL(soc_codec_dev_wm9713v);
 
 /* Module information */
 MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>");
 MODULE_DESCRIPTION("WM9713 voice driver");
 MODULE_LICENSE("GPL");
 
-module_init(wm9713_init);
-module_exit(wm9713_exit);
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index c99e823..8b3ba9c 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -1,3 +1,5 @@
+menu "SoC Audio for the Intel PXA2xx"
+
 config SND_PXA2xx_SOC
 	tristate "SoC Audio for the Intel PXA2xx chip"
 	depends on ARCH_PXA && SND
@@ -8,51 +10,54 @@ config SND_PXA2xx_SOC
 	  to select the audio interfaces to support below.
 
 config SND_PXA2xx_SOC_AC97
-	bool
+	tristate
 	select SND_AC97_CODEC
 	  
 config SND_PXA2xx_SOC_I2S
-	bool
+	tristate
 
 config SND_PXA2xx_SOC_SSP
-	bool
+	tristate
 	select PXA_SSP
-
-
-# Supported machines
-choice
-	prompt "PXA Audio Machine"
-	depends on SND_PXA2xx_SOC
-	default SND_PXA2xx_SOC_MAINSTONE
 	
 config SND_PXA2xx_SOC_MAINSTONE
-	bool "SoC AC97 Audio support for Intel Mainstone"
+	tristate "SoC AC97 Audio support for Intel Mainstone"
 	depends on SND_PXA2xx_SOC
 	select SND_PXA2xx_SOC_AC97
 	help
 	  Say Y if you want to add support for SoC audio on Mainstone.
 
-config SND_PXA2xx_SOC_MAINSTONE_TEST
-	bool "SoC I2S/SSP Audio support for Intel Mainstone - testing"
+config SND_PXA2xx_SOC_MAINSTONE_WM8753
+	tristate "SoC I2S/SSP Audio support for Intel Mainstone - WM8753"
 	depends on SND_PXA2xx_SOC
 	select SND_PXA2xx_SOC_I2S
 	select SND_PXA2xx_SOC_SSP
 	help
-	  Say Y if you want to add support for SoC audio on Mainstone.
+	  Say Y if you want to add support for SoC audio on Mainstone
+	  with the WM8753.
 
-config SND_PXA2xx_SOC_TOSA
-	bool "SoC AC97 Audio support for tosa"
+config SND_PXA2xx_SOC_CORGI
+	tristate "SoC Audio support for Corgi"
 	depends on SND_PXA2xx_SOC
-	select SND_PXA2xx_SOC_AC97
+	select SND_PXA2xx_SOC_I2S
 	help
-	  Say Y if you want to add support for SoC audio on tosa.
+	  Say Y if you want to add support for SoC audio on Sharp
+	  Zaurus SL-C7x0 models.
 	  
-config SND_PXA2xx_SOC_CORGI
-	bool "SoC Audio support for corgi"
+config SND_PXA2xx_SOC_SPITZ
+	tristate "SoC Audio support for Spitz"
 	depends on SND_PXA2xx_SOC
 	select SND_PXA2xx_SOC_I2S
 	help
-	  Say Y if you want to add support for SoC audio on corgi.
-	  
+	  Say Y if you want to add support for SoC audio on Sharp
+	  Zaurus SL-Cxx00 models.
+
+config SND_PXA2xx_SOC_TOSA
+	tristate "SoC AC97 Audio support for Tosa"
+	depends on SND_PXA2xx_SOC
+	select SND_PXA2xx_SOC_AC97
+	help
+	  Say Y if you want to add support for SoC audio on Sharp
+	  Zaurus SL-C6000x models.
 
-endchoice
+endmenu
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile
index 802756e..91c72d9 100644
--- a/sound/soc/pxa/Makefile
+++ b/sound/soc/pxa/Makefile
@@ -1,38 +1,23 @@
+# PXA Platform Support
 snd-soc-pxa2xx-objs := pxa2xx-pcm.o
 snd-soc-pxa2xx-ac97-objs := pxa2xx-ac97.o
 snd-soc-pxa2xx-i2s-objs := pxa2xx-i2s.o
 snd-soc-pxa2xx-ssp-objs := pxa2xx-ssp.o
-snd-soc-mainstone-objs := mainstone.o
-snd-soc-tosa-objs := tosa.o
-snd-soc-corgi-objs := corgi.o
-snd-soc-mainstone-test-objs := mainstone.o
 
 obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-pxa2xx.o
+obj-$(CONFIG_SND_PXA2xx_SOC_AC97) += snd-soc-pxa2xx-ac97.o
+obj-$(CONFIG_SND_PXA2xx_SOC_I2S) += snd-soc-pxa2xx-i2s.o
+obj-$(CONFIG_SND_PXA2xx_SOC_SSP) += snd-soc-pxa2xx-ssp.o
 
-ifeq ($(CONFIG_SND_PXA2xx_SOC_AC97),y)
-obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-pxa2xx-ac97.o
-endif
-
-ifeq ($(CONFIG_SND_PXA2xx_SOC_I2S),y)
-obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-pxa2xx-i2s.o
-endif
-
-ifeq ($(CONFIG_SND_PXA2xx_SOC_SSP),y)
-obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-pxa2xx-ssp.o
-endif
-
-ifeq ($(CONFIG_SND_PXA2xx_SOC_MAINSTONE),y)
-obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-mainstone.o
-endif
-
-ifeq ($(CONFIG_SND_PXA2xx_SOC_MAINSTONE_TEST),y)
-obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-mainstone.o
-endif
-
-ifeq ($(CONFIG_SND_PXA2xx_SOC_TOSA),y)
-obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-tosa.o
-endif
+# PXA Machine Support
+snd-soc-corgi-objs := corgi.o
+snd-soc-mainstone-objs := mainstone.o
+snd-soc-mainstone-wm8753-objs := mainstone_wm8753.o
+snd-soc-tosa-objs := tosa.o
+snd-soc-spitz-objs := spitz.o
 
-ifeq ($(CONFIG_SND_PXA2xx_SOC_CORGI),y)
-obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-corgi.o
-endif
\ No newline at end of file
+obj-$(CONFIG_SND_PXA2xx_SOC_CORGI) += snd-soc-corgi.o
+obj-$(CONFIG_SND_PXA2xx_SOC_MAINSTONE) += snd-soc-mainstone.o
+obj-$(CONFIG_SND_PXA2xx_SOC_MAINSTONE_WM8753) += snd-soc-mainstone-wm8753.o
+obj-$(CONFIG_SND_PXA2xx_SOC_TOSA) += snd-soc-tosa.o
+obj-$(CONFIG_SND_PXA2xx_SOC_SPITZ) += snd-soc-spitz.o
diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c
index 32b0415..d1d7cd5 100644
--- a/sound/soc/pxa/corgi.c
+++ b/sound/soc/pxa/corgi.c
@@ -15,364 +15,211 @@
  *  Revision history
  *    30th Nov 2005   Initial version.
  * 
- * TODO:
- *   Fill in (or delete) the gaps.
- * 
  */
  
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/version.h>
 #include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/i2c.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
 #include <sound/driver.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/soc.h>
 #include <sound/soc-dpm.h>
 
+#include <asm/hardware/scoop.h>
 #include <asm/arch/pxa-regs.h>
-#include <asm/arch/mainstone.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/corgi.h>
 #include <asm/arch/audio.h>
 
 #include "../codecs/wm8731.h"
 #include "pxa2xx-pcm.h"
 
-/*
- * Debug
- */
- 
-#define PFX "corgi-soc"
-#define CORGI_DEBUG 0
-
-#ifdef CORGI_DEBUG
-#define dbg(format, arg...) printk(KERN_DEBUG PFX ": " format "\n" , ## arg)
-#else
-#define dbg(format, arg...) do {} while (0)
-#endif
-#define err(format, arg...) printk(KERN_ERR PFX ": " format "\n" , ## arg)
-#define info(format, arg...) printk(KERN_INFO PFX ": " format "\n" , ## arg)
-#define warn(format, arg...) printk(KERN_WARNING PFX ": " format "\n" , ## arg)
-
-/* 
- * WM8731 2 wire address is determined by GPIO5
- * state during powerup.
- *    low  = 0x1a
- *    high = 0x1b
- */
-#define WM8731_2W_ADDR	0x1a
-#define I2C_DRIVERID_CORGI 0xfefe /* liam -  need a proper id */
-
-static unsigned short normal_i2c[] = { WM8731_2W_ADDR, I2C_CLIENT_END };
-
-/* Magic definition of all other variables and things */
-I2C_CLIENT_INSMOD;
-
-static struct i2c_driver wm8731_i2c_driver;
-static struct i2c_client client_template;
-
-static struct snd_soc_machine corgi;
-
-static int corgi_startup(snd_pcm_substream_t *substream)
-{
-	return 0;
-}
+static struct workqueue_struct *corgi_hp_workq = NULL;
+static struct work_struct corgi_hp_event_work;
 
-static void corgi_shutdown(snd_pcm_substream_t *substream)
+static irqreturn_t corgi_hp_isr(int irq, void *dev_id, struct pt_regs *fp)
 {
-}
+	/* Delay the event slightly to debounce */
+	queue_delayed_work(corgi_hp_workq, &corgi_hp_event_work, msecs_to_jiffies(500));
 
-/* corgi pcm ops */
-static struct snd_soc_ops corgi_ops = {
-	.startup = corgi_startup,
-	.shutdown = corgi_shutdown,
-};
-
-static int corgi_suspend(struct device* dev, pm_message_t state)
-{
-	return 0;
+	return IRQ_HANDLED;
 }
 
-static int corgi_resume(struct device* dev)
-{
-	return 0;
-}
+#define READ_GPIO_BIT(x)    (GPLR(x) & GPIO_bit(x))
 
-static int corgi_probe(struct device* dev)
+static void corgi_hp_work(void *data)
 {
-	return 0;
+	int hp_status = (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0);
+	struct snd_soc_codec *codec = (struct snd_soc_codec *)data;
+	
+	printk("HP Status: %d\n", hp_status);
+	corgikbd_report_hp(hp_status);
+	
+	/* change the dpm status depending on the insertion */
+	if(hp_status == 1) {
+		snd_soc_dpm_set_connection(codec, "ROUT", 0);
+		snd_soc_dpm_set_connection(codec, "LOUT", 0);
+		snd_soc_dpm_set_connection(codec, "LHPOUT", 1);
+		snd_soc_dpm_set_connection(codec, "RHPOUT", 1);
+	} else {
+		snd_soc_dpm_set_connection(codec, "ROUT", 1);
+		snd_soc_dpm_set_connection(codec, "LOUT", 1);
+		snd_soc_dpm_set_connection(codec, "LHPOUT", 0);
+		snd_soc_dpm_set_connection(codec, "RHPOUT", 0);
+	}
+	snd_soc_dpm_sync(codec);
 }
 
-static int corgi_remove(struct device* dev)
+int corgi_get_snd_scoop(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
+	unsigned short reg = kcontrol->private_value;
+	
+	ucontrol->value.integer.value[0] = ((read_scoop_reg(&corgiscoop_device.dev, SCOOP_GPWR) & reg) == 0);
 	return 0;
 }
 
-#ifdef TODO
-
-/*
- * need to change this for corgi 
- */
-
-/* example external dpm event callback */
-int external_amp_event(struct snd_soc_codec *codec, int event)
+int corgi_put_snd_scoop(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
+	unsigned short reg = kcontrol->private_value & 0xffff;
+	
+	if (ucontrol->value.integer.value[0])
+		reset_scoop_gpio(&corgiscoop_device.dev, reg);
+	else
+		set_scoop_gpio(&corgiscoop_device.dev, reg);
 	return 0;
 }
 
-/* example machine dpm widgets */
-static const struct snd_soc_dpm_widget wm8753_dpm_widgets[] = {
+/* corgi machine dpm widgets */
+static const struct snd_soc_dpm_widget wm8731_dpm_widgets[] = {
 SND_SOC_DPM_HP("Headphone Jack"),
 SND_SOC_DPM_MIC("Mic1 Jack"),
-SND_SOC_DPM_AMP("Ext Amp", external_amp_event),
 };
 
 /* example machine interconnections */
 static const char* intercon[][3] = {
 	
 	/* headphone connected to LOUT1, ROUT1 */
-	{"Headphone Jack", NULL, "LOUT1"},
-	{"Headphone Jack", NULL, "ROUT1"},
+	{"Headphone Jack", NULL, "LHPOUT"},
+	{"Headphone Jack", NULL, "RHPOUT"},
 	
 	/* ext speaker connected to LOUT2, ROUT2 via amp */
-	{"Ext Amp", NULL, "LOUT2"},
-	{"Ext Amp", NULL, "ROUT2"},
+	{"Ext Amp", NULL, "ROUT"},
+	{"Ext Amp", NULL, "LOUT"},
 	
 	/* mic is connected to mic1 - with bias */
-	{"MIC1", NULL, "Mic Bias"},
-	{"MIC1N", NULL, "Mic Bias"},
+	{"MICIN", NULL, "Mic Bias"},
+	{"LLINEIN", NULL, "Mic Bias"},
 	{"Mic Bias", NULL, "Mic1 Jack"},
-	{"Mic Bias", NULL, "Mic1 Jack"},
-	
-	{"ACIN", NULL, "ACOP"},
-	{NULL, NULL, NULL},
-};
 
-/* example unconnected codec pins */
-static const struct snd_soc_dpm_pin wm8753_mainstone_pins[] = {
-	{"RXP", 0},
-	{"RXN", 0},
-	{"MIC2", 0},
+	{NULL, NULL, NULL},
 };
 
-/* headphone detect support on my board */
-static const char * hp_pol[] = {"Headphone", "Speaker"};
-static const struct soc_enum wm8753_enum =
-	SOC_ENUM_SINGLE(WM8753_OUTCTL, 1, 2, hp_pol);
-
-static const snd_kcontrol_new_t wm8753_mainstone_controls[] = {
-	SOC_SINGLE("Headphone Detect Switch", WM8753_OUTCTL, 6, 1, 0),
-	SOC_ENUM("Headphone Detect Polarity", wm8753_enum),
+static const snd_kcontrol_new_t wm8731_corgi_controls[] = {
+	SOC_SINGLE_BOOL_EXT("Left Mute Switch", CORGI_SCP_MUTE_L, corgi_get_snd_scoop, corgi_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Right Mute Switch", CORGI_SCP_MUTE_R, corgi_get_snd_scoop, corgi_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Speaker Mute Switch", CORGI_SCP_APM_ON, corgi_get_snd_scoop, corgi_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Mic Bias Switch", CORGI_SCP_MIC_BIAS, corgi_get_snd_scoop, corgi_put_snd_scoop),
 };
 
 /*
- * This is an example machine initialisation for a wm8753 connected to a 
- * Mainstone II. It is missing logic to detect hp/mic insertions and logic
- * to re-route the audio in such an event.
+ * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device
  */
-
 static int corgi_wm8731_init(struct snd_soc_codec *codec)
 {
 	int i, err;
-	
-	/* set up mainstone codec pins */
-	for (i = 0; i < ARRAY_SIZE(wm8753_mainstone_pins); i++)
-		snd_soc_dpm_set_connection(codec, &wm8753_mainstone_pins[i]);
-	
-	/* add mainstone specific controls */
-	for (i = 0; i < ARRAY_SIZE(wm8753_mainstone_controls); i++) {
-		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8753_mainstone_controls[i],codec, NULL))) < 0)
+
+	codec->longname = "Corgi Audio Codec";
+	snd_soc_dpm_set_connection(codec, "RLINEIN", 0);
+
+	/* Add corgi specific controls */
+	for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) {
+		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8731_corgi_controls[i],codec, NULL))) < 0)
 			return err;
 	}
 
-	/* add mainstone specific widgets */
-	for(i = 0; i < ARRAY_SIZE(wm8753_dpm_widgets); i++) {
-		snd_soc_dpm_new_control(codec, &wm8753_dpm_widgets[i]);
+	/* Add corgi specific widgets */
+	for(i = 0; i < ARRAY_SIZE(wm8731_dpm_widgets); i++) {
+		snd_soc_dpm_new_control(codec, &wm8731_dpm_widgets[i]);
 	}
 	
-	/* set up mainstone specific audio path interconnects */
+	/* Set up corgi specific audio path interconnects */
 	for(i = 0; intercon[i][0] != NULL; i++) {
 		snd_soc_dpm_connect_input(codec, intercon[i][0], intercon[i][1], intercon[i][2]);
 	}
 	
+	INIT_WORK(&corgi_hp_event_work, corgi_hp_work, codec);
+	corgi_hp_workq = create_singlethread_workqueue("corgihp");
 	snd_soc_dpm_sync(codec);
 	return 0;
 }
-#endif
 
-static struct snd_soc_machine_config codecs[] = {
-{
+static struct snd_soc_machine_config codecs = {
 	.name = "WM8731", 
-	.sname = "WM8731 HiFi", 
+	.sname = "WM8731",
 	.iface = &pxa_i2s_interface,
-//	.init = corgi_wm8731_init, -- see above
-},
+	.init = corgi_wm8731_init,
 };
 
-static void corgi_device_release(struct device * dev)
-{
-	kfree(dev);
-}
-
-
-/*
- * Attach WM8731 2 wire client 
- */
-static int corgi_codec_probe(struct i2c_adapter *adap, int addr, int kind)
-{		
-	int ret = 0;
-	struct snd_soc_codec *codec;
-	struct i2c_client *i2c;
-	struct device *dev;
-
-	if(addr != WM8731_2W_ADDR)
-		return -ENODEV;
-
-	client_template.adapter = adap;
-	client_template.addr = addr;
-	
-	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
-		return -ENOMEM;
- 
-	if ((i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL)) == NULL){
-		kfree(codec);
-		return -ENOMEM;
-	}
-	memcpy(i2c, &client_template, sizeof(struct i2c_client));
-	codec->control_data = i2c;
-
-	if((ret = i2c_attach_client(i2c)) < 0) {
-		err("failed to attach codec at addr %x\n", addr);
-		kfree(i2c);
-		kfree(codec);
-		return ret;
-	}
-	
-	if((dev = kzalloc(sizeof(struct device), GFP_KERNEL)) == NULL) {
-		i2c_del_driver(&wm8731_i2c_driver);
-		kfree(i2c);
-		kfree(codec);
-		return -ENOMEM;
-	}
-
-	dev->bus = &soc_bus_type;
-	dev->parent = &i2c->dev;
-	dev->release = corgi_device_release;
-	snprintf(dev->bus_id, BUS_ID_SIZE, "WM8731");
-	i2c->dev.platform_data = dev;
-	dev->platform_data = codec;
-	codec->longname = "Corgi Audio Codec";
-	codec->dev = dev;
-	codec->machine = &corgi;
-	codec->hw_write = (hw_write_t)i2c_master_send;
-	INIT_LIST_HEAD(&codec->dpm_widgets);
-	INIT_LIST_HEAD(&codec->dpm_paths);
-
-	if((ret = device_register(dev)) < 0) {
-		err("can't register codec");
-		i2c_del_driver(&wm8731_i2c_driver);
-		kfree(i2c);
-		kfree(dev);
-		kfree(codec);
-	}
-
-	return ret;
-}
-
-static int corgi_i2c_detach(struct i2c_client *client)
-{
-	struct device *dev = (struct device*)client->dev.platform_data;
-	struct snd_soc_codec *codec = 
-		(struct snd_soc_codec*)dev->platform_data;
-
-	device_unregister(dev);
-	i2c_detach_client(client);
-	kfree(codec);
-	kfree(client);
-	return 0;
-}
-
-static int corgi_i2c_attach(struct i2c_adapter *adap)
-{
-	return i2c_probe(adap, &addr_data, corgi_codec_probe);
-}
-
-/* corgi i2c codec control layer */ 
-static struct i2c_driver corgi_i2c_driver = {
-	.name =           "Corgi i2c codec driver",
-	.id =             I2C_DRIVERID_CORGI,
-	.flags =          I2C_DF_NOTIFY,
-	.attach_adapter = corgi_i2c_attach,
-	.detach_client =  corgi_i2c_detach,
-	.command =        NULL,
+static struct snd_soc_machine snd_soc_machine_corgi = {
+	.name = "Corgi",
+	.config = &codecs,
+	.nconfigs = 1,
 };
 
-static struct i2c_client client_template = {
-	.name =   "WM8731",
-	.flags =  I2C_CLIENT_ALLOW_USE,
-	.driver = &corgi_i2c_driver,
+static struct wm8731_setup_data corgi_wm8731_setup = {
+	.i2c_address = 0x1b,
 };
 
-static int __init corgi_i2c_init(void)
-{
-	int ret = 0;
-	
-	if ((ret = i2c_add_driver(&corgi_i2c_driver)) != 0)
-		printk(KERN_ERR "can't add i2c driver");
-		
-	return ret;
-}
-
-static struct snd_soc_machine corgi = {
-	.name = "Corgi",
-	.probe = corgi_probe,
-	.remove = corgi_remove,
-	.suspend = corgi_suspend,
-	.resume = corgi_resume,
-	.ops = &corgi_ops,
+static struct snd_soc_device corgi_snd_devdata = {
+	.machine = &snd_soc_machine_corgi,
 	.platform = &pxa2xx_soc_platform,
-	.config = codecs,
-	.nconfigs = ARRAY_SIZE(codecs),
+	.codec_dev = &soc_codec_dev_wm8731,
+	.codec_data = &corgi_wm8731_setup,
 };
 
+static struct platform_device *corgi_snd_device;
+
 static int __init corgi_init(void) 
 {
 	int ret;
-	struct device *dev;
 
-	pxa_i2s_interface.machine = &corgi;
-	
-	if((dev = kzalloc(sizeof(struct device), GFP_KERNEL)) == NULL) 
+	pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN);
+
+	corgi_snd_device = platform_device_alloc("soc-audio", -1);
+	if (!corgi_snd_device) {
+		free_irq(CORGI_IRQ_GPIO_AK_INT, corgi_snd_device);
 		return -ENOMEM;
-	
-	if((ret = snd_soc_register_machine(&corgi)) < 0) {
-		printk(KERN_ERR "can't register corgi soc audio\n");
-		return ret;
 	}
 
-	corgi.dev = dev;
-	dev->bus = &soc_bus_type;
-	dev->parent = NULL;
-	dev->release = corgi_device_release;
-	dev->platform_data = &corgi;
-	snprintf(dev->bus_id, BUS_ID_SIZE, "corgi-audio");
-
-	if((ret = device_register(dev)) < 0) {
-		err("can't register mainstone audio device");
-		kfree(dev);
-		snd_soc_unregister_machine(&corgi);
+	ret = request_irq(CORGI_IRQ_GPIO_AK_INT, corgi_hp_isr, SA_INTERRUPT, "Headphone Detect", corgi_snd_device);
+	if (ret < 0) {
+		printk(KERN_ERR "Could not register corgi headphone irq.\n");
+		platform_device_put(corgi_snd_device);		
+		return ret;
 	}
-	
-	corgi_i2c_init();
+	set_irq_type(CORGI_IRQ_GPIO_AK_INT, IRQT_BOTHEDGE);
+
+	platform_set_drvdata(corgi_snd_device, &corgi_snd_devdata);
+	corgi_snd_devdata.dev = &corgi_snd_device->dev;
+	ret = platform_device_add(corgi_snd_device);
+
+	if (ret)
+		platform_device_put(corgi_snd_device);
+
 	return ret;
 }
 
 static void __exit corgi_exit(void) 
 {
-	device_unregister(corgi.dev);
-	i2c_del_driver(&corgi_i2c_driver);
-	snd_soc_unregister_machine(&corgi);
+	free_irq(CORGI_IRQ_GPIO_AK_INT, corgi_snd_device);
+	if(corgi_hp_workq)
+		destroy_workqueue(corgi_hp_workq);
+	platform_device_unregister(corgi_snd_device);
 }
 
 module_init(corgi_init);
diff --git a/sound/soc/pxa/mainstone.c b/sound/soc/pxa/mainstone.c
index 30bd6f1..47855b9 100644
--- a/sound/soc/pxa/mainstone.c
+++ b/sound/soc/pxa/mainstone.c
@@ -34,456 +34,82 @@
 #include <asm/arch/mainstone.h>
 #include <asm/arch/audio.h>
 
-#include "../codecs/wm8753.h"
+#include "../codecs/ac97.h"
 #include "pxa2xx-pcm.h"
 
-/*
- * Debug
- */
- 
-#define PFX "mainstone-soc"
-#define MAINSTONE_DEBUG 0
-
-#ifdef MAINSTONE_DEBUG
-#define dbg(format, arg...) printk(KERN_DEBUG PFX ": " format "\n" , ## arg)
-#else
-#define dbg(format, arg...) do {} while (0)
-#endif
-#define err(format, arg...) printk(KERN_ERR PFX ": " format "\n" , ## arg)
-#define info(format, arg...) printk(KERN_INFO PFX ": " format "\n" , ## arg)
-#define warn(format, arg...) printk(KERN_WARNING PFX ": " format "\n" , ## arg)
-
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE_TEST
-/* 
- * WM8753 2 wire address is determined by GPIO5
- * state during powerup.
- *    low  = 0x1a
- *    high = 0x1b
- */
-#define WM8753_2W_ADDR	0x1a
-#define I2C_DRIVERID_MAINSTONE 0xfefe /* liam -  need a proper id */
-
-static unsigned short normal_i2c[] = { WM8753_2W_ADDR, I2C_CLIENT_END };
-
-/* Magic definition of all other variables and things */
-I2C_CLIENT_INSMOD;
-
-static struct i2c_driver wm8753_i2c_driver;
-static struct i2c_client client_template;
-#endif
 static struct snd_soc_machine mainstone;
-
-static int mainstone_startup(snd_pcm_substream_t *substream)
-{
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
-	
-	if(pcm_i->type == SND_SOC_SSP && pcm_i->id == 1) {
-		/* enable USB on the go MUX so we can use SSPFRM2 */
-		MST_MSCWR2 |= MST_MSCWR2_USB_OTG_SEL;
-		MST_MSCWR2 &= ~MST_MSCWR2_USB_OTG_RST;
-	}
-	return 0;
-}
-
-static void mainstone_shutdown(snd_pcm_substream_t *substream)
-{
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
-			
-	if(pcm_i->type == SND_SOC_SSP && pcm_i->id == 1) {
-		/* disable USB on the go MUX so we can use ttyS0 */
-		MST_MSCWR2 &= ~MST_MSCWR2_USB_OTG_SEL;
-		MST_MSCWR2 |= MST_MSCWR2_USB_OTG_RST;
-	}
-}
-
-static struct snd_soc_ops mainstone_ops = {
-	.startup = mainstone_startup,
-	.shutdown = mainstone_shutdown,
-};
-
 static long mst_audio_suspend_mask;
 
-static int mainstone_suspend(struct device* dev, pm_message_t state)
+static int mainstone_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	mst_audio_suspend_mask = MST_MSCWR2;
 	MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
 	return 0;
 }
 
-static int mainstone_resume(struct device* dev)
+static int mainstone_resume(struct platform_device *pdev)
 {
 	MST_MSCWR2 &= mst_audio_suspend_mask | ~MST_MSCWR2_AC97_SPKROFF;
 	return 0;
 }
 
-static int mainstone_probe(struct device* dev)
+static int mainstone_probe(struct platform_device *pdev)
 {
 	MST_MSCWR2 &= ~MST_MSCWR2_AC97_SPKROFF;
 	return 0;
 }
 
-static int mainstone_remove(struct device* dev)
+static int mainstone_remove(struct platform_device *pdev)
 {
 	MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
 	return 0;
 }
 
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE_TEST
-/* example external dpm event callback */
-int external_amp_event(struct snd_soc_codec *codec, int event)
-{
-	return 0;
-}
-
-/* example machine dpm widgets */
-static const struct snd_soc_dpm_widget wm8753_dpm_widgets[] = {
-SND_SOC_DPM_HP("Headphone Jack"),
-SND_SOC_DPM_MIC("Mic1 Jack"),
-SND_SOC_DPM_AMP("Ext Amp", external_amp_event),
-};
-
-/* example machine interconnections */
-static const char* intercon[][3] = {
-	
-	/* headphone connected to LOUT1, ROUT1 */
-	{"Headphone Jack", NULL, "LOUT1"},
-	{"Headphone Jack", NULL, "ROUT1"},
-	
-	/* ext speaker connected to LOUT2, ROUT2 via amp */
-	{"Ext Amp", NULL, "LOUT2"},
-	{"Ext Amp", NULL, "ROUT2"},
-	
-	/* mic is connected to mic1 - with bias */
-	{"MIC1", NULL, "Mic Bias"},
-	{"MIC1N", NULL, "Mic Bias"},
-	{"Mic Bias", NULL, "Mic1 Jack"},
-	{"Mic Bias", NULL, "Mic1 Jack"},
-	
-	{"ACIN", NULL, "ACOP"},
-	{NULL, NULL, NULL},
-};
-
-/* example unconnected codec pins */
-static const struct snd_soc_dpm_pin wm8753_mainstone_pins[] = {
-	{"RXP", 0},
-	{"RXN", 0},
-	{"MIC2", 0},
-};
-
-/* headphone detect support on my board */
-static const char * hp_pol[] = {"Headphone", "Speaker"};
-static const struct soc_enum wm8753_enum =
-	SOC_ENUM_SINGLE(WM8753_OUTCTL, 1, 2, hp_pol);
-
-static const snd_kcontrol_new_t wm8753_mainstone_controls[] = {
-	SOC_SINGLE("Headphone Detect Switch", WM8753_OUTCTL, 6, 1, 0),
-	SOC_ENUM("Headphone Detect Polarity", wm8753_enum),
-};
-
-/*
- * This is an example machine initialisation for a wm8753 connected to a 
- * Mainstone II. It is missing logic to detect hp/mic insertions and logic
- * to re-route the audio in such an event.
- */
-
-static int mainstone_wm8753_init(struct snd_soc_codec *codec)
-{
-	int i, err;
-	
-	/* set up mainstone codec pins */
-	for (i = 0; i < ARRAY_SIZE(wm8753_mainstone_pins); i++)
-		snd_soc_dpm_set_connection(codec, &wm8753_mainstone_pins[i]);
-	
-	/* add mainstone specific controls */
-	for (i = 0; i < ARRAY_SIZE(wm8753_mainstone_controls); i++) {
-		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8753_mainstone_controls[i],codec, NULL))) < 0)
-			return err;
-	}
-
-	/* add mainstone specific widgets */
-	for(i = 0; i < ARRAY_SIZE(wm8753_dpm_widgets); i++) {
-		snd_soc_dpm_new_control(codec, &wm8753_dpm_widgets[i]);
-	}
-	
-	/* set up mainstone specific audio path interconnects */
-	for(i = 0; intercon[i][0] != NULL; i++) {
-		snd_soc_dpm_connect_input(codec, intercon[i][0], intercon[i][1], intercon[i][2]);
-	}
-	
-	snd_soc_dpm_sync(codec);
-	return 0;
-}
-#endif
-
-/* I've added all my different configs here atm for easier testing on ms II */
-static struct snd_soc_machine_config codecs[] = {
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE
-{
+static struct snd_soc_machine_config codecs = {
 	.name = "AC97", 
 	.sname = "AC97 HiFi", 
 	.iface = &pxa_ac97_interface,
-},
-#endif
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE_TEST
-{
-	.name = "WM8753", 
-	.sname = "WM8753 HiFi", 
-	.iface = &pxa_i2s_interface,
-	.init = mainstone_wm8753_init,
-},
-{
-	.name = "WM8753", 
-	.sname = "WM8753 Voice", 
-	.iface = &pxa_ssp_interface[1],
-},
-#endif
-#if 0
-	{.name = "WM8971", .sname = "WM8971", SND_SOC_I2S, 0},
-	{.name = "WM8750", .sname = "WM8750", SND_SOC_I2S, 0},
-	{.name = "WM8731", .sname = "WM8731", SND_SOC_I2S, 0},
-#endif
 };
 
-static void mainstone_device_release(struct device * dev)
-{
-	kfree(dev);
-}
-
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE_TEST
-/*
- * Attach WM8753 2 wire client 
- */
-static int mainstone_codec_probe(struct i2c_adapter *adap, int addr, int kind)
-{		
-	int ret = 0;
-	struct snd_soc_codec *codec;
-	struct i2c_client *i2c;
-	struct device *dev;
-
-	if(addr != WM8753_2W_ADDR)
-		return -ENODEV;
-
-	client_template.adapter = adap;
-	client_template.addr = addr;
-	
-	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
-		return -ENOMEM;
- 
-	if ((i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL)) == NULL){
-		kfree(codec);
-		return -ENOMEM;
-	}
-	memcpy(i2c, &client_template, sizeof(struct i2c_client));
-	codec->control_data = i2c;
-
-	if((ret = i2c_attach_client(i2c)) < 0) {
-		err("failed to attach codec at addr %x\n", addr);
-		kfree(i2c);
-		kfree(codec);
-		return ret;
-	}
-	
-	if((dev = kzalloc(sizeof(struct device), GFP_KERNEL)) == NULL) {
-		i2c_del_driver(&wm8753_i2c_driver);
-		kfree(i2c);
-		kfree(codec);
-		return -ENOMEM;
-	}
-
-	dev->bus = &soc_bus_type;
-	dev->parent = &i2c->dev;
-	dev->release = mainstone_device_release;
-	snprintf(dev->bus_id, BUS_ID_SIZE, "WM8753");
-	i2c->dev.platform_data = dev;
-	dev->platform_data = codec;
-	codec->longname = "Mainstone Audio Codec";
-	codec->dev = dev;
-	codec->machine = &mainstone;
-	codec->hw_write = (hw_write_t)i2c_master_send;
-	INIT_LIST_HEAD(&codec->dpm_widgets);
-	INIT_LIST_HEAD(&codec->dpm_paths);
-
-	if((ret = device_register(dev)) < 0) {
-		err("can't register codec");
-		i2c_del_driver(&wm8753_i2c_driver);
-		kfree(i2c);
-		kfree(dev);
-		kfree(codec);
-	}
-
-	return ret;
-}
-
-static int mainstone_i2c_detach(struct i2c_client *client)
-{
-	struct device *dev = (struct device*)client->dev.platform_data;
-	struct snd_soc_codec *codec = 
-		(struct snd_soc_codec*)dev->platform_data;
-
-	device_unregister(dev);
-	i2c_detach_client(client);
-	kfree(codec);
-	kfree(client);
-	return 0;
-}
-
-static int mainstone_i2c_attach(struct i2c_adapter *adap)
-{
-	return i2c_probe(adap, &addr_data, mainstone_codec_probe);
-}
-
-/* Mainstone i2c codec control layer */ 
-static struct i2c_driver mainstone_i2c_driver = {
-	.name =           "Mainstone i2c codec driver",
-	.id =             I2C_DRIVERID_MAINSTONE,
-	.flags =          I2C_DF_NOTIFY,
-	.attach_adapter = mainstone_i2c_attach,
-	.detach_client =  mainstone_i2c_detach,
-	.command =        NULL,
-};
-
-static struct i2c_client client_template = {
-	.name =   "WM8753",
-	.flags =  I2C_CLIENT_ALLOW_USE,
-	.driver = &mainstone_i2c_driver,
-};
-
-static int __init mainstone_i2c_init(void)
-{
-	int ret = 0;
-	
-	if ((ret = i2c_add_driver(&mainstone_i2c_driver)) != 0)
-		printk(KERN_ERR "can't add i2c driver");
-		
-	return ret;
-}
-#endif
-
 static struct snd_soc_machine mainstone = {
 	.name = "Mainstone",
 	.probe = mainstone_probe,
 	.remove = mainstone_remove,
 	.suspend = mainstone_suspend,
 	.resume = mainstone_resume,
-	.ops = &mainstone_ops,
+	.config = &codecs,
+	.nconfigs = 1,
+};
+
+static struct snd_soc_device mainstone_snd_devdata = {
+	.machine = &mainstone,
 	.platform = &pxa2xx_soc_platform,
-	.config = codecs,
-	.nconfigs = ARRAY_SIZE(codecs),
+	.codec_dev = &soc_codec_dev_ac97,
 };
 
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE
-static unsigned int mainstone_ac97_read(struct snd_soc_codec *codec, 
-	unsigned int reg)
-{
-	return pxa2xx_ac97_ops.read(codec->ac97, reg);
-}
+static struct platform_device *mainstone_snd_device;
 
-static int mainstone_ac97_write(struct snd_soc_codec *codec, unsigned int reg,
-	unsigned int val)
+static int __init mainstone_init(void) 
 {
-	pxa2xx_ac97_ops.write(codec->ac97, reg, val);
-	return 0;
-}
-
-static struct device *ac97_dev;
+	int ret;
 
-static int __init mainstone_ac97_init(void)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec;
-	
-	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
-		return -ENOMEM;
- 
-	codec->control_data = &pxa2xx_ac97_ops;
-	if((ac97_dev = kzalloc(sizeof(struct device), GFP_KERNEL)) == NULL) {
-		kfree(codec);
+	mainstone_snd_device = platform_device_alloc("soc-audio", -1);
+	if (!mainstone_snd_device)
 		return -ENOMEM;
-	}
 
-	ac97_dev->bus = &soc_bus_type;
-	ac97_dev->parent = NULL;
-	ac97_dev->release = mainstone_device_release;
-	snprintf(ac97_dev->bus_id, BUS_ID_SIZE, "AC97");
-	ac97_dev->platform_data = codec;
-	codec->longname = "Mainstone Audio Codec";
-	codec->dev = ac97_dev;
-	codec->machine = &mainstone;
-	codec->write = mainstone_ac97_write;
-	codec->read = mainstone_ac97_read;
-	INIT_LIST_HEAD(&codec->dpm_widgets);
-	INIT_LIST_HEAD(&codec->dpm_paths);
-
-	if((ret = device_register(ac97_dev)) < 0) {
-		err("can't register codec");
-		kfree(ac97_dev);
-		kfree(codec);
-	}
+	platform_set_drvdata(mainstone_snd_device, &mainstone_snd_devdata);
+	mainstone_snd_devdata.dev = &mainstone_snd_device->dev;
+	ret = platform_device_add(mainstone_snd_device);
 
-	return ret;
-}
-#endif
+	if (ret)
+		platform_device_put(mainstone_snd_device);
 
-static int __init mainstone_init(void) 
-{
-	int ret;
-	struct device *dev;
-		
-#ifdef CONFIG_SND_PXA2xx_SOC_AC97
-	pxa_ac97_interface.machine = &mainstone;
-#endif
-#ifdef CONFIG_SND_PXA2xx_SOC_I2S
-	pxa_i2s_interface.machine = &mainstone;
-#endif
-#ifdef CONFIG_SND_PXA2xx_SOC_SSP
-	pxa_ssp_interface[0].machine = &mainstone;
-	pxa_ssp_interface[1].machine = &mainstone;
-	pxa_ssp_interface[2].machine = &mainstone;
-#endif
-	
-	if((dev = kzalloc(sizeof(struct device), GFP_KERNEL)) == NULL) 
-		return -ENOMEM;
-	
-	if((ret = snd_soc_register_machine(&mainstone)) < 0) {
-		printk(KERN_ERR "can't register mainstone soc audio\n");
-		return ret;
-	}
-
-	mainstone.dev = dev;
-	dev->bus = &soc_bus_type;
-	dev->parent = NULL;
-	dev->release = mainstone_device_release;
-	dev->platform_data = &mainstone;
-	snprintf(dev->bus_id, BUS_ID_SIZE, "mainstone-audio");
-
-	if((ret = device_register(dev)) < 0) {
-		err("can't register mainstone audio device");
-		kfree(dev);
-		snd_soc_unregister_machine(&mainstone);
-	}
-	
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE_TEST
-	mainstone_i2c_init();
-#endif
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE
-	mainstone_ac97_init();
-#endif
 	return ret;
 }
 
 static void __exit mainstone_exit(void) 
 {
-	device_unregister(mainstone.dev);
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE_TEST
-	i2c_del_driver(&mainstone_i2c_driver);
-#endif
-#ifdef CONFIG_SND_PXA2xx_SOC_MAINSTONE
-	kfree(ac97_dev->platform_data);
-	device_unregister(ac97_dev);
-#endif
-	snd_soc_unregister_machine(&mainstone);
+	platform_device_unregister(mainstone_snd_device);
 }
 
 module_init(mainstone_init);
diff --git a/sound/soc/pxa/mainstone_wm8753.c b/sound/soc/pxa/mainstone_wm8753.c
new file mode 100644
index 0000000..7b9372b
--- /dev/null
+++ b/sound/soc/pxa/mainstone_wm8753.c
@@ -0,0 +1,219 @@
+/*
+ * mainstone.c  --  SoC audio for Mainstone
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ *
+ *  Mainstone audio amplifier code taken from arch/arm/mach-pxa/mainstone.c
+ *  Copyright:	MontaVista Software Inc.
+ * 
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    30th Oct 2005   Initial version.
+ * 
+ */
+ 
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/i2c.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dpm.h>
+
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/mainstone.h>
+#include <asm/arch/audio.h>
+
+#include "../codecs/wm8753.h"
+#include "pxa2xx-pcm.h"
+
+static struct snd_soc_machine mainstone;
+
+static int mainstone_startup(snd_pcm_substream_t *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	
+	if(rtd->pcm_i->type == SND_SOC_SSP && rtd->pcm_i->id == 1) {
+		/* enable USB on the go MUX so we can use SSPFRM2 */
+		MST_MSCWR2 |= MST_MSCWR2_USB_OTG_SEL;
+		MST_MSCWR2 &= ~MST_MSCWR2_USB_OTG_RST;
+	}
+	return 0;
+}
+
+static void mainstone_shutdown(snd_pcm_substream_t *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+			
+	if(rtd->pcm_i->type == SND_SOC_SSP && rtd->pcm_i->id == 1) {
+		/* disable USB on the go MUX so we can use ttyS0 */
+		MST_MSCWR2 &= ~MST_MSCWR2_USB_OTG_SEL;
+		MST_MSCWR2 |= MST_MSCWR2_USB_OTG_RST;
+	}
+}
+
+static struct snd_soc_ops mainstone_ops = {
+	.startup = mainstone_startup,
+	.shutdown = mainstone_shutdown,
+};
+
+static long mst_audio_suspend_mask;
+
+static int mainstone_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	mst_audio_suspend_mask = MST_MSCWR2;
+	MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
+	return 0;
+}
+
+static int mainstone_resume(struct platform_device *pdev)
+{
+	MST_MSCWR2 &= mst_audio_suspend_mask | ~MST_MSCWR2_AC97_SPKROFF;
+	return 0;
+}
+
+static int mainstone_probe(struct platform_device *pdev)
+{
+	MST_MSCWR2 &= ~MST_MSCWR2_AC97_SPKROFF;
+	return 0;
+}
+
+static int mainstone_remove(struct platform_device *pdev)
+{
+	MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
+	return 0;
+}
+
+/* example machine interconnections */
+static const char* intercon[][3] = {
+	
+	/* mic is connected to mic1 - with bias */
+	{"MIC1", NULL, "Mic Bias"},
+	{"MIC1N", NULL, "Mic Bias"},
+	{"Mic Bias", NULL, "Mic1 Jack"},
+	{"Mic Bias", NULL, "Mic1 Jack"},
+	
+	{"ACIN", NULL, "ACOP"},
+	{NULL, NULL, NULL},
+};
+
+/* headphone detect support on my board */
+static const char * hp_pol[] = {"Headphone", "Speaker"};
+static const struct soc_enum wm8753_enum =
+	SOC_ENUM_SINGLE(WM8753_OUTCTL, 1, 2, hp_pol);
+
+static const snd_kcontrol_new_t wm8753_mainstone_controls[] = {
+	SOC_SINGLE("Headphone Detect Switch", WM8753_OUTCTL, 6, 1, 0),
+	SOC_ENUM("Headphone Detect Polarity", wm8753_enum),
+};
+
+/*
+ * This is an example machine initialisation for a wm8753 connected to a 
+ * Mainstone II. It is missing logic to detect hp/mic insertions and logic
+ * to re-route the audio in such an event.
+ */
+
+static int mainstone_wm8753_init(struct snd_soc_codec *codec)
+{
+	int i, err;
+	
+	codec->longname = "Mainstone Audio Codec";
+		
+	/* set up mainstone codec pins */
+	snd_soc_dpm_set_connection(codec, "RXP", 0);
+	snd_soc_dpm_set_connection(codec, "RXN", 0);
+	snd_soc_dpm_set_connection(codec, "MIC2", 0);
+	
+	/* add mainstone specific controls */
+	for (i = 0; i < ARRAY_SIZE(wm8753_mainstone_controls); i++) {
+		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8753_mainstone_controls[i],codec, NULL))) < 0)
+			return err;
+	}
+	
+	/* set up mainstone specific audio path interconnects */
+	for(i = 0; intercon[i][0] != NULL; i++) {
+		snd_soc_dpm_connect_input(codec, intercon[i][0], intercon[i][1], intercon[i][2]);
+	}
+	
+	snd_soc_dpm_sync(codec);
+	return 0;
+}
+
+static struct snd_soc_machine_config codecs[] = {
+{
+	.name = "WM8753", 
+	.sname = "WM8753 HiFi",
+	.iface = &pxa_i2s_interface,
+	.init = mainstone_wm8753_init,
+},
+{
+	.name = "WM8753", 
+	.sname = "WM8753 Voice",
+	.iface = &pxa_ssp_interface[1],
+},
+};
+
+static struct snd_soc_machine mainstone = {
+	.name = "Mainstone",
+	.probe = mainstone_probe,
+	.remove = mainstone_remove,
+	.suspend = mainstone_suspend,
+	.resume = mainstone_resume,
+	.ops = &mainstone_ops,
+	.config = codecs,
+	.nconfigs = ARRAY_SIZE(codecs),
+};
+
+static struct wm8753_setup_data corgi_wm8753_setup = {
+	.i2c_address = 0x1a,
+};
+
+static struct snd_soc_device mainstone_snd_devdata = {
+	.machine = &mainstone,
+	.platform = &pxa2xx_soc_platform,
+	.codec_dev = &soc_codec_dev_wm8753,
+	.codec_data = &corgi_wm8753_setup,
+};
+
+static struct platform_device *mainstone_snd_device;
+
+static int __init mainstone_init(void) 
+{
+	int ret;
+
+	mainstone_snd_device = platform_device_alloc("soc-audio", -1);
+	if (!mainstone_snd_device)
+		return -ENOMEM;
+
+	platform_set_drvdata(mainstone_snd_device, &mainstone_snd_devdata);
+	mainstone_snd_devdata.dev = &mainstone_snd_device->dev;
+	ret = platform_device_add(mainstone_snd_device);
+
+	if (ret)
+		platform_device_put(mainstone_snd_device);
+
+	return ret;
+}
+
+static void __exit mainstone_exit(void) 
+{
+	platform_device_unregister(mainstone_snd_device);
+}
+
+module_init(mainstone_init);
+module_exit(mainstone_exit);
+
+/* Module information */ 
+MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("ALSA SoC Mainstone");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index 05d4253..67aa01d 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -37,6 +37,15 @@ static DECLARE_MUTEX(car_mutex);
 static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);
 static volatile long gsr_bits;
 
+static struct snd_soc_hw_mode pxa2xx_ac97[] = {
+	{0, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000},
+	{0, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_11025},
+	{0, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000},
+	{0, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_22050},
+	{0, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_44100},
+	{0, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_48000},
+};
+
 /*
  * Beware PXA27x bugs:
  *
@@ -80,7 +89,7 @@ static unsigned short pxa2xx_ac97_read(a
 
 	wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
 	if (!((GSR | gsr_bits) & GSR_SDONE)) {
-		printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n",
+		printk(KERN_ERR "%s: read error (ac97_reg=%x GSR=%#lx)\n",
 				__FUNCTION__, reg, GSR | gsr_bits);
 		val = -1;
 		goto out;
@@ -119,7 +128,7 @@ static void pxa2xx_ac97_write(ac97_t *ac
 	*reg_addr = val;
 	wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1);
 	if (!((GSR | gsr_bits) & GSR_CDONE))
-		printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n",
+		printk(KERN_ERR "%s: write error (ac97_reg=%x GSR=%#lx)\n",
 				__FUNCTION__, reg, GSR | gsr_bits);
 
 	up(&car_mutex);
@@ -198,7 +207,7 @@ static irqreturn_t pxa2xx_ac97_irq(int i
 	return IRQ_NONE;
 }
 
-ac97_bus_ops_t pxa2xx_ac97_ops = {
+ac97_bus_ops_t soc_ac97_ops = {
 	.read	= pxa2xx_ac97_read,
 	.write	= pxa2xx_ac97_write,
 	.reset	= pxa2xx_ac97_reset,
@@ -237,20 +246,18 @@ static pxa2xx_pcm_dma_params_t pxa2xx_ac
 };
 
 #ifdef CONFIG_PM
-
-static int pxa2xx_ac97_suspend(struct device *dev, pm_message_t state)
+static int pxa2xx_ac97_suspend(struct platform_device *pdev, struct snd_soc_pcm_interface *pcm_i)
 {
 	GCR |= GCR_ACLINK_OFF;
 	pxa_set_cken(CKEN2_AC97, 0);
 	return 0;
 }
 
-static int pxa2xx_ac97_resume(struct device *dev)
+static int pxa2xx_ac97_resume(struct platform_device *pdev, struct snd_soc_pcm_interface *pcm_i)
 {
-	struct snd_soc_pcm_interface *pcm_i = dev->driver_data;
-	struct snd_soc_pcm_codec *pcm_c = pcm_i->pcm_c;
-	struct snd_soc_codec *codec = pcm_c->codec;
-	
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec* codec = socdev->codec;
+
 	pxa_gpio_mode(GPIO31_SYNC_AC97_MD);
 	pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);
 	pxa_gpio_mode(GPIO28_BITCLK_AC97_MD);
@@ -269,7 +276,7 @@ static int pxa2xx_ac97_resume(struct dev
 #define pxa2xx_ac97_resume	NULL
 #endif
 
-static int pxa2xx_ac97_probe(struct device *dev)
+static int pxa2xx_ac97_probe(struct platform_device *pdev)
 {
 	int ret;
 
@@ -297,7 +304,7 @@ static int pxa2xx_ac97_probe(struct devi
 	return ret;
 }
 
-static void pxa2xx_ac97_remove(struct device *dev)
+static void pxa2xx_ac97_remove(struct platform_device *pdev)
 {
 	GCR |= GCR_ACLINK_OFF;
 	free_irq(IRQ_AC97, NULL);
@@ -307,8 +314,9 @@ static void pxa2xx_ac97_remove(struct de
 static int pxa2xx_ac97_prepare(snd_pcm_substream_t *substream)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_codec *codec = pcm_c->codec;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_codec *codec = socdev->codec;
 	
 	int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
 		  AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;
@@ -318,19 +326,18 @@ static int pxa2xx_ac97_prepare(snd_pcm_s
 static int pxa2xx_ac97_hw_params(snd_pcm_substream_t *substream,
 				snd_pcm_hw_params_t *params)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		if (params_channels(params) == 2)
-			pcm_i->platform_data = &pxa2xx_ac97_pcm_stereo_out;
+			rtd->pcm_i->platform_data = &pxa2xx_ac97_pcm_stereo_out;
 		else
-			pcm_i->platform_data = &pxa2xx_ac97_pcm_mono_out;
+			rtd->pcm_i->platform_data = &pxa2xx_ac97_pcm_mono_out;
 	} else {
 		if (params_channels(params) == 2)
-			pcm_i->platform_data = &pxa2xx_ac97_pcm_stereo_in;
+			rtd->pcm_i->platform_data = &pxa2xx_ac97_pcm_stereo_in;
 		else
-			pcm_i->platform_data = &pxa2xx_ac97_pcm_mono_in;
+			rtd->pcm_i->platform_data = &pxa2xx_ac97_pcm_mono_in;
 	}
 
 	return 0;
@@ -346,27 +353,22 @@ struct snd_soc_pcm_interface pxa_ac97_in
 	.resume = pxa2xx_ac97_resume,
 	.playback = {
 		.sname = "AC97 Playback",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | 
-		SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-		SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 2,
 		.channels_max = 2,},
 	.capture = {
 		.sname = "AC97 Capture",
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | 
-		SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-		SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 2,
 		.channels_max = 2,},
 	.ops = {
 		.prepare = pxa2xx_ac97_prepare,
 		.hw_params = pxa2xx_ac97_hw_params,},
+	.hw = {
+		.num_hmodes = ARRAY_SIZE(pxa2xx_ac97),
+		.hmodes = &pxa2xx_ac97[0],},
 };
 
 EXPORT_SYMBOL_GPL(pxa_ac97_interface);
-EXPORT_SYMBOL_GPL(pxa2xx_ac97_ops);
+EXPORT_SYMBOL_GPL(soc_ac97_ops);
 
 MODULE_AUTHOR("Nicolas Pitre");
 MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip");
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c
index d8ea7b1..36b2c6d 100644
--- a/sound/soc/pxa/pxa2xx-i2s.c
+++ b/sound/soc/pxa/pxa2xx-i2s.c
@@ -55,14 +55,14 @@ static struct pxa_i2s_port pxa_i2s;
  * priv1 is sadiv
  */
 static struct snd_soc_hw_mode pxa2xx_i2s[] = {
-	{PXA_I2S_HWFMT, 	SND_SOC_HWBITS(16),		8000,	64,		0x00000048},
-	{PXA_I2S_HWFMT, 	SND_SOC_HWBITS(16),		11025,	64,		0x00000034},
-	{PXA_I2S_HWFMT, 	SND_SOC_HWBITS(16),		16000,	64,		0x00000024},
-	{PXA_I2S_HWFMT, 	SND_SOC_HWBITS(16),		22050,	64,		0x0000001a},
-	{PXA_I2S_HWFMT, 	SND_SOC_HWBITS(16),		44100,	64,		0x0000000d},
-	{PXA_I2S_HWFMT, 	SND_SOC_HWBITS(16),		48000,	64,		0x0000000c},
+	{PXA_I2S_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	64,		0x00000048},
+	{PXA_I2S_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_11025,	64,		0x00000034},
+	{PXA_I2S_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000,	64,		0x00000024},
+	{PXA_I2S_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_22050,	64,		0x0000001a},
+	{PXA_I2S_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_44100,	64,		0x0000000d},
+	{PXA_I2S_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_48000,	64,		0x0000000c},
 	/* 96k is not in yellow book - ymmv */
-	{PXA_I2S_HWFMT_96K, 	SND_SOC_HWBITS(16),	96000,	64,		0x00000006},
+	{PXA_I2S_HWFMT_96K, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_96000,	64,		0x00000006},
 };
 
 static pxa2xx_pcm_dma_params_t pxa2xx_i2s_pcm_stereo_out = {
@@ -147,11 +147,10 @@ static int pxa_i2s_wait(void)
 static int pxa2xx_i2s_hw_params(snd_pcm_substream_t *substream,
 				snd_pcm_hw_params_t *params)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
 	pxa_i2s.master = 0;
-	
-	if(pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_CBS_CFS)
+	if(rtd->pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_CBS_CFS)
 		pxa_i2s.master = 1;
 		
 	pxa_gpio_mode(gpio_bus[pxa_i2s.master].rx);
@@ -163,14 +162,14 @@ static int pxa2xx_i2s_hw_params(snd_pcm_
 	
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		if (params_channels(params) == 2)
-			pcm_i->platform_data = &pxa2xx_i2s_pcm_stereo_out;
+			rtd->pcm_i->platform_data = &pxa2xx_i2s_pcm_stereo_out;
 		else
-			pcm_i->platform_data = &pxa2xx_i2s_pcm_mono_out;
+			rtd->pcm_i->platform_data = &pxa2xx_i2s_pcm_mono_out;
 	} else {
 		if (params_channels(params) == 2)
-			pcm_i->platform_data = &pxa2xx_i2s_pcm_stereo_in;
+			rtd->pcm_i->platform_data = &pxa2xx_i2s_pcm_stereo_in;
 		else
-			pcm_i->platform_data = &pxa2xx_i2s_pcm_mono_in;
+			rtd->pcm_i->platform_data = &pxa2xx_i2s_pcm_mono_in;
 	}
 	
 	/* is port used by another stream */
@@ -191,7 +190,7 @@ static int pxa2xx_i2s_hw_params(snd_pcm_
 		
 		SACR0 |= SACR0_RFTH(14) | SACR0_TFTH(1);
 	
-		if (pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_LEFT_J)
+		if (rtd->pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_LEFT_J)
 			SACR1 |= SACR1_AMSL;
 	
 		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -203,17 +202,16 @@ static int pxa2xx_i2s_hw_params(snd_pcm_
 		}
 	}
 	
-	SADIV = get_sadiv(pcm_i->hw_runtime.rate);
+	SADIV = get_sadiv(rtd->pcm_i->hw_runtime.rate);
 	SACR0 |= SACR0_ENB;
-	pcm_i->active = 1;
+	rtd->pcm_i->active = 1;
 	return 0;
 }
 
 static void pxa2xx_i2s_shutdown(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
-	
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
 	down(&pxa_i2s_sem);
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		SACR1 |= SACR1_DRPL;
@@ -227,20 +225,18 @@ static void pxa2xx_i2s_shutdown(snd_pcm_
 		SACR0 &= ~SACR0_ENB;
 		pxa_i2s_wait();
 		pxa_set_cken(CKEN8_I2S, 0);
-		pcm_i->active = 0;
+		rtd->pcm_i->active = 0;
 	}
 	pxa_i2s.i2s_open--;
 	up(&pxa_i2s_sem);
 }
 
 #ifdef CONFIG_PM
-static int pxa2xx_i2s_suspend(struct device *dev, pm_message_t state)
+static int pxa2xx_i2s_suspend(struct platform_device *dev, struct snd_soc_pcm_interface *pcm_i)
 {
-	struct snd_soc_pcm_interface *pcm_i = dev->driver_data;
-	
 	if(!pcm_i->active)
 		return 0;
-		
+
 	/* disable link and store registers */
 	SACR0 &= ~SACR0_ENB;
 	pxa_i2s_wait();
@@ -252,18 +248,11 @@ static int pxa2xx_i2s_suspend(struct dev
 	return 0;
 }
 
-static int pxa2xx_i2s_resume(struct device *dev)
+static int pxa2xx_i2s_resume(struct platform_device *pdev, struct snd_soc_pcm_interface *pcm_i)
 {
-	struct snd_soc_pcm_interface *pcm_i = dev->driver_data;
-	
 	if(!pcm_i->active)
 		return 0;
-		
-	/* restore registers and enable link*/
-	pxa_gpio_mode(gpio_bus[pxa_i2s.master].rx);
-	pxa_gpio_mode(gpio_bus[pxa_i2s.master].tx);
-	pxa_gpio_mode(gpio_bus[pxa_i2s.master].frm);
-	pxa_gpio_mode(gpio_bus[pxa_i2s.master].clk);
+
 	pxa_set_cken(CKEN8_I2S, 1);
 	pxa_i2s_wait();
 	
@@ -272,6 +261,7 @@ static int pxa2xx_i2s_resume(struct devi
 	SAIMR = pxa_i2s.saimr;
 	SADIV = pxa_i2s.sadiv;
 	SACR0 |= SACR0_ENB;
+
 	return 0;
 }
 
@@ -287,17 +277,9 @@ struct snd_soc_pcm_interface pxa_i2s_int
 	.suspend = pxa2xx_i2s_suspend,
 	.resume = pxa2xx_i2s_resume,
 	.playback = {
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | 
-		SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-		SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 2,
 		.channels_max = 2,},
 	.capture = {
-		.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | 
-		SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
-		SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_96000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 		.channels_min = 2,
 		.channels_max = 2,},
 	.ops = {
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
index 00c1492..33ccd72 100644
--- a/sound/soc/pxa/pxa2xx-pcm.c
+++ b/sound/soc/pxa/pxa2xx-pcm.c
@@ -53,7 +53,7 @@ struct pxa2xx_runtime_data {
 static void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id, struct pt_regs *regs)
 {
 	snd_pcm_substream_t *substream = dev_id;
-	struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;
+	struct pxa2xx_runtime_data *prtd = substream->runtime->private_data;
 	int dcsr;
 	
 	dcsr = DCSR(dma_ch);
@@ -63,7 +63,7 @@ static void pxa2xx_pcm_dma_irq(int dma_c
 		snd_pcm_period_elapsed(substream);
 	} else {
 		printk( KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n",
-			rtd->params->name, dma_ch, dcsr );
+			prtd->params->name, dma_ch, dcsr );
 	}
 }
 
@@ -71,69 +71,69 @@ static int pxa2xx_pcm_hw_params(snd_pcm_
 				snd_pcm_hw_params_t *params)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct pxa2xx_runtime_data *rtd = runtime->private_data;
+	struct pxa2xx_runtime_data *prtd = runtime->private_data;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	size_t totsize = params_buffer_bytes(params);
 	size_t period = params_period_bytes(params);
-	pxa2xx_pcm_dma_params_t *dma = 
-		(pxa2xx_pcm_dma_params_t*)pcm_c->pcm_i->platform_data;
+	pxa2xx_pcm_dma_params_t *dma = rtd->pcm_i->platform_data;
 	pxa_dma_desc *dma_desc;
 	dma_addr_t dma_buff_phys, next_desc_phys;
 	int ret;
-
-	if(rtd->params == NULL) {
-		rtd->params = dma;
-		if((ret = pxa_request_dma(rtd->params->name, DMA_PRIO_LOW,
+	
+	/* this may get called several times by oss emulation with different params */
+	if(prtd->params == NULL) {
+		prtd->params = dma;
+		if((ret = pxa_request_dma(prtd->params->name, DMA_PRIO_LOW,
 			      pxa2xx_pcm_dma_irq, substream)) < 0)
 			return ret;
-		rtd->dma_ch = ret;
-	} else if(rtd->params != dma) {
-		pxa_free_dma(rtd->dma_ch);
-		rtd->params = dma;
-		if((ret = pxa_request_dma(rtd->params->name, DMA_PRIO_LOW,
+		prtd->dma_ch = ret;
+	} else if(prtd->params != dma) {
+		pxa_free_dma(prtd->dma_ch);
+		prtd->params = dma;
+		if((ret = pxa_request_dma(prtd->params->name, DMA_PRIO_LOW,
 			      pxa2xx_pcm_dma_irq, substream)) < 0)
 			return ret;
-		rtd->dma_ch = ret;
+		prtd->dma_ch = ret;
 	}
 
 	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
 	runtime->dma_bytes = totsize;
 
-	dma_desc = rtd->dma_desc_array;
-	next_desc_phys = rtd->dma_desc_array_phys;
+	dma_desc = prtd->dma_desc_array;
+	next_desc_phys = prtd->dma_desc_array_phys;
 	dma_buff_phys = runtime->dma_addr;
 	do {
 		next_desc_phys += sizeof(pxa_dma_desc);
 		dma_desc->ddadr = next_desc_phys;
 		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 			dma_desc->dsadr = dma_buff_phys;
-			dma_desc->dtadr = rtd->params->dev_addr;
+			dma_desc->dtadr = prtd->params->dev_addr;
 		} else {
-			dma_desc->dsadr = rtd->params->dev_addr;
+			dma_desc->dsadr = prtd->params->dev_addr;
 			dma_desc->dtadr = dma_buff_phys;
 		}
 		if (period > totsize)
 			period = totsize;
-		dma_desc->dcmd = rtd->params->dcmd | period | DCMD_ENDIRQEN;
+		dma_desc->dcmd = prtd->params->dcmd | period | DCMD_ENDIRQEN;
 		dma_desc++;
 		dma_buff_phys += period;
 	} while (totsize -= period);
-	dma_desc[-1].ddadr = rtd->dma_desc_array_phys;
+	dma_desc[-1].ddadr = prtd->dma_desc_array_phys;
 
 	return 0;
 }
 
 static int pxa2xx_pcm_hw_free(snd_pcm_substream_t *substream)
 {
-	struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;
+	struct pxa2xx_runtime_data *prtd = substream->runtime->private_data;
  
-	if(rtd && rtd->params)
-		*rtd->params->drcmr = 0;
+	if(prtd && prtd->params)
+		*prtd->params->drcmr = 0;
 	
-	if(rtd->dma_ch) {
+	if(prtd->dma_ch) {
 		snd_pcm_set_runtime_buffer(substream, NULL);
-		pxa_free_dma(rtd->dma_ch);
-		rtd->dma_ch = 0;
+		pxa_free_dma(prtd->dma_ch);
+		prtd->dma_ch = 0;
 	}
 	
 	return 0;
@@ -141,36 +141,35 @@ static int pxa2xx_pcm_hw_free(snd_pcm_su
 
 static int pxa2xx_pcm_prepare(snd_pcm_substream_t *substream)
 {
-	snd_pcm_runtime_t *runtime = substream->runtime;
-	struct pxa2xx_runtime_data *rtd = runtime->private_data;
+	struct pxa2xx_runtime_data *prtd = substream->runtime->private_data;
 
-	DCSR(rtd->dma_ch) &= ~DCSR_RUN;
-	DCSR(rtd->dma_ch) = 0;
-	DCMD(rtd->dma_ch) = 0;
-	*rtd->params->drcmr = rtd->dma_ch | DRCMR_MAPVLD;
+	DCSR(prtd->dma_ch) &= ~DCSR_RUN;
+	DCSR(prtd->dma_ch) = 0;
+	DCMD(prtd->dma_ch) = 0;
+	*prtd->params->drcmr = prtd->dma_ch | DRCMR_MAPVLD;
 
 	return 0;
 }
 
 static int pxa2xx_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
 {
-	struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;
+	struct pxa2xx_runtime_data *prtd = substream->runtime->private_data;
 	int ret = 0;
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
-		DDADR(rtd->dma_ch) = rtd->dma_desc_array_phys;
-		DCSR(rtd->dma_ch) = DCSR_RUN;
+		DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys;
+		DCSR(prtd->dma_ch) = DCSR_RUN;
 		break;
 
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		DCSR(rtd->dma_ch) &= ~DCSR_RUN;
+		DCSR(prtd->dma_ch) &= ~DCSR_RUN;
 		break;
 
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		DCSR(rtd->dma_ch) |= DCSR_RUN;
+		DCSR(prtd->dma_ch) |= DCSR_RUN;
 		break;
 
 	default:
@@ -183,9 +182,10 @@ static int pxa2xx_pcm_trigger(snd_pcm_su
 static snd_pcm_uframes_t pxa2xx_pcm_pointer(snd_pcm_substream_t *substream)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
-	struct pxa2xx_runtime_data *rtd = runtime->private_data;
+	struct pxa2xx_runtime_data *prtd = runtime->private_data;
+	
 	dma_addr_t ptr = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
-			 DSADR(rtd->dma_ch) : DTADR(rtd->dma_ch);
+			 DSADR(prtd->dma_ch) : DTADR(prtd->dma_ch);
 	snd_pcm_uframes_t x = bytes_to_frames(runtime, ptr - runtime->dma_addr);
 
 	if (x == runtime->buffer_size)
@@ -217,7 +217,7 @@ pxa2xx_pcm_hw_rule_mult32(snd_pcm_hw_par
 static int pxa2xx_pcm_open(snd_pcm_substream_t *substream)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
-	struct pxa2xx_runtime_data *rtd;
+	struct pxa2xx_runtime_data *prtd;
 	int ret;
 
 	snd_soc_set_runtime_hw(substream, &pxa2xx_pcm_hardware);
@@ -239,32 +239,34 @@ static int pxa2xx_pcm_open(snd_pcm_subst
 	if (ret)
 		goto out;
 
-	ret = -ENOMEM;
-	rtd = kmalloc(sizeof(*rtd), GFP_KERNEL);
-	if (!rtd)
+	if((prtd = kzalloc(sizeof(struct pxa2xx_runtime_data), GFP_KERNEL)) == NULL) {
+		ret = -ENOMEM;
 		goto out;
-	memset(rtd, 0, sizeof(struct pxa2xx_runtime_data));
-	rtd->dma_desc_array =
+	}
+	
+	prtd->dma_desc_array =
 		dma_alloc_writecombine(substream->pcm->card->dev, PAGE_SIZE,
-				       &rtd->dma_desc_array_phys, GFP_KERNEL);
-	if (!rtd->dma_desc_array)
+				       &prtd->dma_desc_array_phys, GFP_KERNEL);
+	if (!prtd->dma_desc_array)
 		goto err1;
 
-	runtime->private_data = rtd;
+	runtime->private_data = prtd;
 	return 0;
 
  err1:
-	kfree(rtd);
+	kfree(prtd);
  out:
 	return ret;
 }
 
 static int pxa2xx_pcm_close(snd_pcm_substream_t *substream)
 {
-	struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;
+	snd_pcm_runtime_t *runtime = substream->runtime;
+	struct pxa2xx_runtime_data *prtd = runtime->private_data;
+
 	dma_free_writecombine(substream->pcm->card->dev, PAGE_SIZE,
-			      rtd->dma_desc_array, rtd->dma_desc_array_phys);
-	kfree(rtd);
+			      prtd->dma_desc_array, prtd->dma_desc_array_phys);
+	kfree(prtd);
 	return 0;
 }
 
@@ -353,60 +355,44 @@ int pxa2xx_pcm_new(snd_card_t *card, str
 	return ret;
 }
 
-static int pxa2xx_pcm_suspend(struct device *dev, pm_message_t state)
+static int pxa2xx_pcm_suspend(struct platform_device *pdev, struct snd_soc_pcm_interface *iface)
 {
-	struct snd_soc_pcm_interface *pcm_i = dev->driver_data;
-	snd_pcm_runtime_t *runtime = pcm_i->runtime;
-	struct pxa2xx_runtime_data *rtd;
+	snd_pcm_runtime_t *runtime = iface->runtime;
+	struct pxa2xx_runtime_data *prtd;
 	
 	if(!runtime)
 		return 0;
 	
-	rtd = runtime->private_data;
-	DCSR(rtd->dma_ch) &= ~DCSR_RUN;
+	prtd = runtime->private_data;
+	DCSR(prtd->dma_ch) &= ~DCSR_RUN;
 	
 	return 0;
 }
 
-static int pxa2xx_pcm_resume(struct device *dev)
+static int pxa2xx_pcm_resume(struct platform_device *pdev, struct snd_soc_pcm_interface *iface)
 {
-	struct snd_soc_pcm_interface *pcm_i = dev->driver_data;
-	snd_pcm_runtime_t *runtime = pcm_i->runtime;
-	struct pxa2xx_runtime_data *rtd;
+	snd_pcm_runtime_t *runtime = iface->runtime;
+	struct pxa2xx_runtime_data *prtd;
 	
 	if(!runtime)
 		return 0;
 		
-	rtd = runtime->private_data;
-	DCMD(rtd->dma_ch) = 0;
-	*rtd->params->drcmr = rtd->dma_ch | DRCMR_MAPVLD;
-	DDADR(rtd->dma_ch) = rtd->dma_desc_array_phys;
-	DCSR(rtd->dma_ch) |= DCSR_RUN;
+	prtd = runtime->private_data;
+	DCMD(prtd->dma_ch) = 0;
+	*prtd->params->drcmr = prtd->dma_ch | DRCMR_MAPVLD;
+	DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys;
+	DCSR(prtd->dma_ch) |= DCSR_RUN;
 	
 	return 0;
 }	
 
 struct snd_soc_platform pxa2xx_soc_platform = {
 	.name		= "pxa2xx-audio",
-	.bus		= &platform_bus_type,
 	.pcm_ops 	= &pxa2xx_pcm_ops,
 	.pcm_new	= pxa2xx_pcm_new,
 	.pcm_free	= pxa2xx_pcm_free_dma_buffers,
 	.suspend	= pxa2xx_pcm_suspend,
 	.resume		= pxa2xx_pcm_resume,
-	.iface = {
-#ifdef CONFIG_SND_PXA2xx_SOC_AC97
-		&pxa_ac97_interface,
-#endif
-#ifdef CONFIG_SND_PXA2xx_SOC_I2S
-		&pxa_i2s_interface,
-#endif
-#ifdef CONFIG_SND_PXA2xx_SOC_SSP
-		&pxa_ssp_interface[0],
-		&pxa_ssp_interface[1],
-		&pxa_ssp_interface[2],
-#endif
-		NULL,},
 };
 
 EXPORT_SYMBOL_GPL(pxa2xx_soc_platform);
diff --git a/sound/soc/pxa/pxa2xx-ssp.c b/sound/soc/pxa/pxa2xx-ssp.c
index 6a3e973..169b638 100644
--- a/sound/soc/pxa/pxa2xx-ssp.c
+++ b/sound/soc/pxa/pxa2xx-ssp.c
@@ -66,13 +66,13 @@
  * -- liam, need some method of "doesn't matter" for fs, maybe 0  
  */
 static struct snd_soc_hw_mode pxa2xx_ssp[] = {
-	{PXA_SSP_HWFMT, 	SND_SOC_HWBITS(16),		8000,	256,	1626},
-	{PXA_SSP_HWFMT, 	SND_SOC_HWBITS(16),		8000,	384,	1626}, 
-	{PXA_SSP_HWFMT, 	SND_SOC_HWBITS(16),		11025,	256,	1180},
-	{PXA_SSP_HWFMT, 	SND_SOC_HWBITS(16),		16000,	256,	813},
-	{PXA_SSP_HWFMT, 	SND_SOC_HWBITS(16),		22050,	256,	590},
-	{PXA_SSP_HWFMT, 	SND_SOC_HWBITS(16),		44100,	256,	295},
-	{PXA_SSP_HWFMT, 	SND_SOC_HWBITS(16),		48000,	256,	271},
+	{PXA_SSP_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	256,	1626},
+	{PXA_SSP_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_8000,	384,	1626}, 
+	{PXA_SSP_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_11025,	256,	1180},
+	{PXA_SSP_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_16000,	256,	813},
+	{PXA_SSP_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_22050,	256,	590},
+	{PXA_SSP_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_44100,	256,	295},
+	{PXA_SSP_HWFMT, 	SNDRV_PCM_FMTBIT_S16_LE,	SNDRV_PCM_RATE_48000,	256,	271},
 };
 
 static struct ssp_dev ssp[3];
@@ -226,51 +226,45 @@ static pxa2xx_gpio_t ssp_gpios[3][2] = {
 
 static int pxa2xx_ssp_startup(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	int ret = 0;
 	
-	if((ret = ssp_init (&ssp[pcm_i->id], pcm_i->id + 1, SSP_NO_IRQ)) < 0)
+	if((ret = ssp_init (&ssp[rtd->pcm_i->id], rtd->pcm_i->id + 1, SSP_NO_IRQ)) < 0)
 		return ret;
 	
-	ssp_disable(&ssp[pcm_i->id]);
+	ssp_disable(&ssp[rtd->pcm_i->id]);
 	return ret;
 }
 
 static void pxa2xx_ssp_shutdown(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 
-	ssp_disable(&ssp[pcm_i->id]);
-	ssp_exit(&ssp[pcm_i->id]);
-	pcm_i->active = 0;
+	ssp_disable(&ssp[rtd->pcm_i->id]);
+	ssp_exit(&ssp[rtd->pcm_i->id]);
+	rtd->pcm_i->active = 0;
 }
 
 #ifdef CONFIG_PM
-static int pxa2xx_ssp_suspend(struct device *dev, pm_message_t state)
+static int pxa2xx_ssp_suspend(struct platform_device *pdev, struct snd_soc_pcm_interface *pcm_i)
 {
 	int ret = 0;
-	struct snd_soc_pcm_interface *pcm_i = dev->driver_data;
 	
 	if(!pcm_i->active)
 		return 0;
 		
 	ssp_save_state(&ssp[pcm_i->id], &ssp_state[pcm_i->id]);
-	
 	return ret;
 }
 
-static int pxa2xx_ssp_resume(struct device *dev)
+static int pxa2xx_ssp_resume(struct platform_device *pdev, struct snd_soc_pcm_interface *pcm_i)
 {
 	int ret = 0;
-	struct snd_soc_pcm_interface *pcm_i = dev->driver_data;
 	
 	if(!pcm_i->active)
 		return 0;
 		
 	ssp_restore_state(&ssp[pcm_i->id], &ssp_state[pcm_i->id]);
-
 	return ret;
 }
 
@@ -282,31 +276,30 @@ static int pxa2xx_ssp_resume(struct devi
 static int pxa2xx_ssp_hw_params(snd_pcm_substream_t *substream,
 				snd_pcm_hw_params_t *params)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	int master = 0, dma = 0;
 	u32 ssp_mode = 0, ssp_setup = 0, psp_mode = 0;
-	int bits = generic_ffs(pcm_i->hw_runtime.hbits);
+	int bits = generic_ffs(rtd->pcm_i->hw_runtime.hbits);
 	
-	if(pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_CBS_CFS)
+	if(rtd->pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_CBS_CFS)
 		master = 1;
 	
-	pxa_gpio_mode(ssp_gpios[pcm_i->id][master].rx);
-	pxa_gpio_mode(ssp_gpios[pcm_i->id][master].tx);
-	pxa_gpio_mode(ssp_gpios[pcm_i->id][master].frm);
-	pxa_gpio_mode(ssp_gpios[pcm_i->id][master].clk);
+	pxa_gpio_mode(ssp_gpios[rtd->pcm_i->id][master].rx);
+	pxa_gpio_mode(ssp_gpios[rtd->pcm_i->id][master].tx);
+	pxa_gpio_mode(ssp_gpios[rtd->pcm_i->id][master].frm);
+	pxa_gpio_mode(ssp_gpios[rtd->pcm_i->id][master].clk);
 	
 	if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
 		dma = 1;
 	if (params_channels(params) == 2)
 		dma += 2;
-	pcm_i->platform_data = ssp_dma_params[pcm_i->id][dma];
+	rtd->pcm_i->platform_data = ssp_dma_params[rtd->pcm_i->id][dma];
 	
 	ssp_mode = SSCR0_PSP | SSCR0_DataSize(bits);
 	ssp_setup = SSCR1_RxTresh(14) | SSCR1_TxTresh(1) | SSCR1_TRAIL |
 				SSCR1_TSRE | SSCR1_RSRE | SSCR1_TIE | SSCR1_RIE;
 	
-	switch(pcm_i->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
+	switch(rtd->pcm_i->hw_runtime.hformat & SND_SOC_CLOCK_MASK) {
 		case SND_SOC_HWFMT_CBM_CFM:
 			ssp_setup |= (SSCR1_SCLKDIR | SSCR1_SFRMDIR);
 			break;
@@ -318,21 +311,21 @@ static int pxa2xx_ssp_hw_params(snd_pcm_
 			break;
 	}
 	
-	switch(pcm_i->hw_runtime.hformat & SND_SOC_INV_MASK){
+	switch(rtd->pcm_i->hw_runtime.hformat & SND_SOC_INV_MASK){
 		case SND_SOC_HWFMT_NB_NF:
 			psp_mode |= SSPSP_SFRMP;
 			break;
 	}
-	if (pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_DSP_A)
+	if (rtd->pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_DSP_A)
 		psp_mode |= SSPSP_SCMODE(2);
-	if (pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_DSP_B)
+	if (rtd->pcm_i->hw_runtime.hformat & SND_SOC_HWFMT_DSP_B)
 		psp_mode |= SSPSP_SCMODE(3);
 
-	ssp_disable(&ssp[pcm_i->id]);
-	ssp_config(&ssp[pcm_i->id], ssp_mode, ssp_setup, psp_mode,
-					SSCR0_SerClkDiv(pcm_i->hw_runtime.priv1));
-	ssp_enable(&ssp[pcm_i->id]);
-	pcm_i->active = 1;
+	ssp_disable(&ssp[rtd->pcm_i->id]);
+	ssp_config(&ssp[rtd->pcm_i->id], ssp_mode, ssp_setup, psp_mode,
+					SSCR0_SerClkDiv(rtd->pcm_i->hw_runtime.priv1));
+	ssp_enable(&ssp[rtd->pcm_i->id]);
+	rtd->pcm_i->active = 1;
 	return 0;
 }
 
@@ -343,15 +336,9 @@ struct snd_soc_pcm_interface pxa_ssp_int
 		.suspend = pxa2xx_ssp_suspend,
 		.resume = pxa2xx_ssp_resume,
 		.playback = {
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
 			.channels_min = 1,
 			.channels_max = 1,},
 		.capture = {
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
 			.channels_min = 1,
 			.channels_max = 2,},
 		.ops = {
@@ -368,15 +355,9 @@ struct snd_soc_pcm_interface pxa_ssp_int
 		.suspend = pxa2xx_ssp_suspend,
 		.resume = pxa2xx_ssp_resume,
 		.playback = {
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
 			.channels_min = 1,
 			.channels_max = 1,},
 		.capture = {
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
 			.channels_min = 1,
 			.channels_max = 1,},
 		.ops = {
@@ -393,15 +374,9 @@ struct snd_soc_pcm_interface pxa_ssp_int
 		.suspend = pxa2xx_ssp_suspend,
 		.resume = pxa2xx_ssp_resume,
 		.playback = {
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
 			.channels_min = 1,
 			.channels_max = 1,},
 		.capture = {
-			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
-			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
-			.formats = SNDRV_PCM_FMTBIT_S16_LE,
 			.channels_min = 1,
 			.channels_max = 1,},
 		.ops = {
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
new file mode 100644
index 0000000..7f4baf1
--- /dev/null
+++ b/sound/soc/pxa/spitz.c
@@ -0,0 +1,294 @@
+/*
+ * spitz.c  --  SoC audio for Sharp SL-Cxx00 models Spitz, Borzoi and Akita
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Copyright 2005 Openedhand Ltd.
+ * 
+ * Authors: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
+ *          Richard Purdie <richard@openedhand.com>
+ * 
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    30th Nov 2005   Initial version.
+ * 
+ */
+ 
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dpm.h>
+
+#include <asm/hardware/scoop.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/akita.h>
+#include <asm/arch/spitz.h>
+#include <asm/mach-types.h>
+#include "../codecs/wm8750.h"
+#include "pxa2xx-pcm.h"
+
+static struct workqueue_struct *spitz_hp_workq = NULL;
+static struct work_struct spitz_hp_event_work;
+
+static irqreturn_t spitz_hp_isr(int irq, void *dev_id, struct pt_regs *fp)
+{
+	/* Delay the event slightly to debounce */
+	queue_delayed_work(spitz_hp_workq, &spitz_hp_event_work, msecs_to_jiffies(500));
+
+	return IRQ_HANDLED;
+}
+
+#define READ_GPIO_BIT(x)    (GPLR(x) & GPIO_bit(x))
+
+static void spitz_hp_work(void *data)
+{
+	int hp_status = (READ_GPIO_BIT(SPITZ_GPIO_AK_INT) != 0);
+	struct snd_soc_codec *codec = (struct snd_soc_codec *)data;
+	
+	printk("HP Status: %d\n", hp_status);
+	spitzkbd_report_hp(hp_status);
+	
+	/* change the dpm status depending on the insertion */
+	if (hp_status == 1) {
+		snd_soc_dpm_set_connection(codec, "LOUT1", 1);
+		snd_soc_dpm_set_connection(codec, "ROUT1", 1);
+		snd_soc_dpm_set_connection(codec, "RINPUT1", 1);
+		snd_soc_dpm_set_connection(codec, "LINPUT1", 1);
+	} else {
+		snd_soc_dpm_set_connection(codec, "LOUT1", 0);
+		snd_soc_dpm_set_connection(codec, "ROUT1", 0);
+		snd_soc_dpm_set_connection(codec, "RINPUT1", 0);
+		snd_soc_dpm_set_connection(codec, "LINPUT1", 0);
+	}
+	snd_soc_dpm_sync(codec);
+}
+
+int spitz_get_snd_scoop(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	unsigned short reg = kcontrol->private_value;
+	
+	ucontrol->value.integer.value[0] = ((read_scoop_reg(&spitzscoop_device.dev, SCOOP_GPWR) & reg) == 0);
+	return 0;
+}
+
+int spitz_put_snd_scoop(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	unsigned short reg = kcontrol->private_value & 0xffff;
+	
+	if (ucontrol->value.integer.value[0])
+		reset_scoop_gpio(&spitzscoop_device.dev, reg);
+	else
+		set_scoop_gpio(&spitzscoop_device.dev, reg);
+	return 0;
+}
+
+int spitz_get_snd_scoop2(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	unsigned short reg = kcontrol->private_value;
+	
+	ucontrol->value.integer.value[0] = ((read_scoop_reg(&spitzscoop2_device.dev, SCOOP_GPWR) & reg) == 0);
+	return 0;
+}
+
+int spitz_put_snd_scoop2(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	unsigned short reg = kcontrol->private_value & 0xffff;
+	
+	if (ucontrol->value.integer.value[0])
+		reset_scoop_gpio(&spitzscoop2_device.dev, reg);
+	else
+		set_scoop_gpio(&spitzscoop2_device.dev, reg);
+	return 0;
+}
+
+#ifdef CONFIG_MACH_AKITA
+static int akita_ioexp_status;
+
+int akita_get_snd_ioexp(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	unsigned short reg = kcontrol->private_value;
+	ucontrol->value.integer.value[0] = akita_ioexp_status;
+	return 0;
+}
+
+int akita_put_snd_ioexp(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	unsigned short reg = kcontrol->private_value & 0xffff;
+	
+	if (ucontrol->value.integer.value[0]) {
+		akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_MIC_BIAS);
+		akita_ioexp_status = 0;
+        } else {
+		akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_MIC_BIAS);
+		akita_ioexp_status = 1;		
+	}
+
+	return 0;
+}
+#endif
+
+/* spitz machine dpm widgets */
+static const struct snd_soc_dpm_widget wm8750_dpm_widgets[] = {
+SND_SOC_DPM_HP("Headphone Jack"),
+SND_SOC_DPM_MIC("Mic1 Jack"),
+};
+
+/* example machine interconnections */
+static const char* intercon[][3] = {
+	
+	/* headphone connected to LOUT1, ROUT1 */
+	{"Headphone Jack", NULL, "LOUT1"},
+	{"Headphone Jack", NULL, "ROUT1"},
+	
+	/* ext speaker connected to LOUT2, ROUT2 via amp */
+	{"Ext Amp", NULL , "ROUT2"},
+	{"Ext Amp", NULL , "LOUT2"},
+	
+	/* mic is connected to mic1 - with bias */
+	{"MICIN", NULL, "Mic Bias"},
+	{"LLINEIN", NULL, "Mic Bias"},
+	{"Mic Bias", NULL, "Mic1 Jack"},
+
+	{NULL, NULL, NULL},
+};
+
+static const snd_kcontrol_new_t wm8750_spitz_controls[] = {
+	SOC_SINGLE_BOOL_EXT("Left Mute Switch", SPITZ_SCP_MUTE_L, spitz_get_snd_scoop, spitz_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Right Mute Switch", SPITZ_SCP_MUTE_R, spitz_get_snd_scoop, spitz_put_snd_scoop),
+};
+
+static const snd_kcontrol_new_t wm8750_spitz_controls2[] = {
+	SOC_SINGLE_BOOL_EXT("Mic Bias Switch", SPITZ_SCP2_MIC_BIAS, spitz_get_snd_scoop2, spitz_put_snd_scoop2),
+};
+
+#ifdef CONFIG_MACH_AKITA
+static const snd_kcontrol_new_t wm8750_akita_controls[] = {
+	SOC_SINGLE_BOOL_EXT("Mic Bias Switch", AKITA_IOEXP_MIC_BIAS, akita_get_snd_ioexp, akita_put_snd_ioexp),
+};
+#endif
+
+/*
+ * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device
+ */
+static int spitz_wm8750_init(struct snd_soc_codec *codec)
+{
+	int i, err;
+
+	codec->longname = "Corgi Audio Codec";
+	snd_soc_dpm_set_connection(codec, "LINPUT2", 0);
+	snd_soc_dpm_set_connection(codec, "RINPUT2", 0);
+
+	/* Add spitz specific controls */
+	for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) {
+		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL))) < 0)
+			return err;
+	}
+
+	if (machine_is_borzoi() || machine_is_spitz())
+		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8750_spitz_controls2[0], codec, NULL))) < 0)
+			return err;
+
+#ifdef CONFIG_MACH_AKITA
+	if (machine_is_akita())
+		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8750_akita_controls[0], codec, NULL))) < 0)
+			return err;
+#endif
+
+	/* Add spitz specific widgets */
+	for(i = 0; i < ARRAY_SIZE(wm8750_dpm_widgets); i++) {
+		snd_soc_dpm_new_control(codec, &wm8750_dpm_widgets[i]);
+	}
+	
+	/* Set up spitz specific audio path interconnects */
+	for(i = 0; intercon[i][0] != NULL; i++) {
+		snd_soc_dpm_connect_input(codec, intercon[i][0], intercon[i][1], intercon[i][2]);
+	}
+	
+	INIT_WORK(&spitz_hp_event_work, spitz_hp_work, codec);
+	spitz_hp_workq = create_singlethread_workqueue("spitzhp");
+	snd_soc_dpm_sync(codec);
+	return 0;
+}
+
+static struct snd_soc_machine_config codecs = {
+	.name = "wm8750", 
+	.sname = "WM8750",
+	.iface = &pxa_i2s_interface,
+	.init = spitz_wm8750_init,
+};
+
+static struct snd_soc_machine snd_soc_machine_spitz = {
+	.name = "Spitz",
+	.config = &codecs,
+	.nconfigs = 1,
+};
+
+static struct wm8750_setup_data spitz_wm8750_setup = {
+	.i2c_address = 0x1b,
+};
+
+static struct snd_soc_device spitz_snd_devdata = {
+	.machine = &snd_soc_machine_spitz,
+	.platform = &pxa2xx_soc_platform,
+	.codec_dev = &soc_codec_dev_wm8750,
+	.codec_data = &spitz_wm8750_setup,
+};
+
+static struct platform_device *spitz_snd_device;
+
+static int __init spitz_init(void) 
+{
+	int ret;
+
+	pxa_gpio_mode(SPITZ_GPIO_AK_INT | GPIO_IN);
+
+	spitz_snd_device = platform_device_alloc("soc-audio", -1);
+	if (!spitz_snd_device) {
+		free_irq(SPITZ_IRQ_GPIO_AK_INT, spitz_snd_device);
+		return -ENOMEM;
+	}
+
+	ret = request_irq(SPITZ_IRQ_GPIO_AK_INT, spitz_hp_isr, SA_INTERRUPT, "Headphone Detect", spitz_snd_device);
+	if (ret < 0) {
+		printk(KERN_ERR "Could not register spitz headphone irq.\n");
+		platform_device_put(spitz_snd_device);		
+		return ret;
+	}
+	set_irq_type(SPITZ_IRQ_GPIO_AK_INT, IRQT_BOTHEDGE);
+
+	platform_set_drvdata(spitz_snd_device, &spitz_snd_devdata);
+	spitz_snd_devdata.dev = &spitz_snd_device->dev;
+	ret = platform_device_add(spitz_snd_device);
+
+	if (ret)
+		platform_device_put(spitz_snd_device);
+
+	return ret;
+}
+
+static void __exit spitz_exit(void) 
+{
+	free_irq(SPITZ_IRQ_GPIO_AK_INT, spitz_snd_device);
+	if(spitz_hp_workq)
+		destroy_workqueue(spitz_hp_workq);
+	platform_device_unregister(spitz_snd_device);
+}
+
+module_init(spitz_init);
+module_exit(spitz_exit);
+
+MODULE_AUTHOR("Richard Purdie");
+MODULE_DESCRIPTION("ALSA SoC Spitz");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c
index 82a57f2..cf4ece1 100644
--- a/sound/soc/pxa/tosa.c
+++ b/sound/soc/pxa/tosa.c
@@ -35,6 +35,7 @@
 #include <asm/arch/pxa-regs.h>
 #include <asm/arch/audio.h>
 
+#include "../codecs/ac97.h"
 #include "pxa2xx-pcm.h"
 
 /*
@@ -73,22 +74,22 @@ static struct snd_soc_ops tosa_ops = {
 };
 
 
-static int tosa_suspend(struct device* dev, pm_message_t state)
+static int tosa_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	return 0;
 }
 
-static int tosa_resume(struct device* dev)
+static int tosa_resume(struct platform_device *pdev)
 {
 	return 0;
 }
 
-static int tosa_probe(struct device* dev)
+static int tosa_probe(struct platform_device *pdev)
 {
 	return 0;
 }
 
-static int tosa_remove(struct device* dev)
+static int tosa_remove(struct platform_device *pdev)
 {
 	return 0;
 }
@@ -144,7 +145,7 @@ static const char * hp_pol[] = {"Headpho
 static const struct soc_enum tosa_enum =
 	SOC_ENUM_SINGLE(WM8753_OUTCTL, 1, 2, hp_pol);
 
-static const snd_kcontrol_new_t wm8753_mainstone_controls[] = {
+static const snd_kcontrol_new_t wm8753_tosa_controls[] = {
 	SOC_SINGLE("Headphone Detect Switch", WM8753_OUTCTL, 6, 1, 0),
 	SOC_ENUM("Headphone Detect Polarity", wm8753_enum),
 };
@@ -159,22 +160,22 @@ static int tosa_ac97_init(struct snd_soc
 {
 	int i, err;
 	
-	/* set up mainstone codec pins */
-	for (i = 0; i < ARRAY_SIZE(wm8753_mainstone_pins); i++)
-		snd_soc_dpm_set_connection(codec, &wm8753_mainstone_pins[i]);
-	
-	/* add mainstone specific controls */
-	for (i = 0; i < ARRAY_SIZE(wm8753_mainstone_controls); i++) {
-		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8753_mainstone_controls[i],codec, NULL))) < 0)
+	/* set up tosa codec pins */
+	for (i = 0; i < ARRAY_SIZE(wm8753_tosa_pins); i++)
+		snd_soc_dpm_set_connection(codec, &wm8753_tosa_pins[i]);
+	
+	/* add tosa specific controls */
+	for (i = 0; i < ARRAY_SIZE(wm8753_tosa_controls); i++) {
+		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8753_tosa_controls[i],codec, NULL))) < 0)
 			return err;
 	}
 
-	/* add mainstone specific widgets */
+	/* add tosa specific widgets */
 	for(i = 0; i < ARRAY_SIZE(wm8753_dpm_widgets); i++) {
 		snd_soc_dpm_new_control(codec, &wm8753_dpm_widgets[i]);
 	}
 	
-	/* set up mainstone specific audio path interconnects */
+	/* set up tosa specific audio path interconnects */
 	for(i = 0; intercon[i][0] != NULL; i++) {
 		snd_soc_dpm_connect_input(codec, intercon[i][0], intercon[i][1], intercon[i][2]);
 	}
@@ -185,122 +186,53 @@ static int tosa_ac97_init(struct snd_soc
 #endif
 
 /* I've added all my different configs here atm for easier testing on ms II */
-static struct snd_soc_machine_config codecs[] = {
-{	
+static struct snd_soc_machine_config codecs = {
 	.name = "AC97", 
 	.sname = "AC97 HiFi", 
 	.iface = &pxa_ac97_interface,
 	//.init = tosa_ac97_init, -- see above
-	},
 };
 
-static void tosa_device_release(struct device * dev)
-{
-	kfree(dev);
-}
-
 static struct snd_soc_machine tosa = {
-	.name = "Tosa",
+	.name = "Mainstone",
 	.probe = tosa_probe,
 	.remove = tosa_remove,
 	.suspend = tosa_suspend,
 	.resume = tosa_resume,
 	.ops = &tosa_ops,
-	.platform = &pxa2xx_soc_platform,
-	.config = codecs,
-	.nconfigs = ARRAY_SIZE(codecs),
+	.config = &codecs,
+	.nconfigs = 1,
 };
 
+static struct snd_soc_device tosa_snd_devdata = {
+	.machine = &tosa,
+	.platform = &pxa2xx_soc_platform,
+	.codec_dev = &soc_codec_dev_ac97,
+};
 
-static unsigned int tosa_ac97_read(struct snd_soc_codec *codec, 
-	unsigned int reg)
-{
-	return pxa2xx_ac97_ops.read(codec->ac97, reg);
-}
+static struct platform_device *tosa_snd_device;
 
-static int tosa_ac97_write(struct snd_soc_codec *codec, unsigned int reg,
-	unsigned int val)
+static int __init tosa_init(void) 
 {
-	pxa2xx_ac97_ops.write(codec->ac97, reg, val);
-	return 0;
-}
-
-static struct device *ac97_dev;
+	int ret;
 
-static int __init tosa_ac97_init(void)
-{
-	int ret = 0;
-	struct snd_soc_codec *codec;
-	
-	if ((codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)) == NULL)
+	tosa_snd_device = platform_device_alloc("soc-audio", -1);
+	if (!tosa_snd_device)
 		return -ENOMEM;
- 
-	codec->control_data = &pxa2xx_ac97_ops;
-	if((ac97_dev = kzalloc(sizeof(struct device), GFP_KERNEL)) == NULL) {
-		kfree(codec);
-		return -ENOMEM;
-	}
-
-	ac97_dev->bus = &soc_bus_type;
-	ac97_dev->parent = NULL;
-	ac97_dev->release = tosa_device_release;
-	snprintf(ac97_dev->bus_id, BUS_ID_SIZE, "AC97");
-	ac97_dev->platform_data = codec;
-	codec->longname = "Tosa Audio Codec";
-	codec->dev = ac97_dev;
-	codec->machine = &mainstone;
-	codec->write = tosa_ac97_write;
-	codec->read = tosa_ac97_read;
-	INIT_LIST_HEAD(&codec->dpm_widgets);
-	INIT_LIST_HEAD(&codec->dpm_paths);
-
-	if((ret = device_register(ac97_dev)) < 0) {
-		err("can't register codec");
-		kfree(ac97_dev);
-		kfree(codec);
-	}
 
-	return ret;
-}
+	platform_set_drvdata(tosa_snd_device, &tosa_snd_devdata);
+	tosa_snd_devdata.dev = &tosa_snd_device->dev;
+	ret = platform_device_add(tosa_snd_device);
 
-static int __init tosa_init(void) 
-{
-	int ret;
-	struct device *dev;
-	
-	pxa_ac97_interface.machine = &mainstone;
-	
-	if((dev = kzalloc(sizeof(struct device), GFP_KERNEL)) == NULL) 
-		return -ENOMEM;
-	
-	if((ret = snd_soc_register_machine(&tosa)) < 0) {
-		printk(KERN_ERR "can't register tosa soc audio\n");
-		return ret;
-	}
+	if (ret)
+		platform_device_put(tosa_snd_device);
 
-	mainstone.dev = dev;
-	dev->bus = &soc_bus_type;
-	dev->parent = NULL;
-	dev->release = tosa_device_release;
-	dev->platform_data = &tosa;
-	snprintf(dev->bus_id, BUS_ID_SIZE, "tosa-audio");
-
-	if((ret = device_register(dev)) < 0) {
-		err("can't register tosa audio device");
-		kfree(dev);
-		snd_soc_unregister_machine(&tosa);
-	}
-	
-	tosa_ac97_init();
 	return ret;
 }
 
 static void __exit tosa_exit(void) 
 {
-	device_unregister(tosa.dev);
-	kfree(ac97_dev->platform_data);
-	device_unregister(ac97_dev);
-	snd_soc_unregister_machine(&tosa);
+	platform_device_unregister(tosa_snd_device);
 }
 
 module_init(tosa_init);
diff --git a/sound/soc/soc-bus.c b/sound/soc/soc-bus.c
deleted file mode 100644
index 63676d9..0000000
--- a/sound/soc/soc-bus.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * soc-bus.c  --  ALSA Soc Audio Layer
- *
- * Copyright 2005 Wolfson Microelectronics PLC.
- * Author: Liam Girdwood
- *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/string.h>
-#include <sound/soc.h>
-
-static int soc_bus_match(struct device *dev, struct device_driver *drv)
-{
-	/* match codec */
-	if(!strcmp(dev->bus_id, drv->name))
-		return 1;
-
-	/* match machine - machine has "-audio" in name */
-	if(strstr(dev->bus_id, "-audio") && !strcmp(drv->name, "soc-audio"))
-		return 1;
-	
-	return 0;
-}
-
-static int soc_bus_suspend(struct device *dev, pm_message_t state)
-{
-	int ret = 0;
-
-	if (dev->driver && dev->driver->suspend)
-		ret = dev->driver->suspend(dev, state);
-
-	return ret;
-}
-
-static int soc_bus_resume(struct device *dev)
-{
-	int ret = 0;
-
-	if (dev->driver && dev->driver->resume)
-		ret = dev->driver->resume(dev);
-
-	return ret;
-}
-
-struct bus_type soc_bus_type = {
-	.name		= "soc-audio",
-	.match		= soc_bus_match,
-	.suspend	= soc_bus_suspend,
-	.resume		= soc_bus_resume,
-};
-
-static int __init soc_bus_init(void)
-{
-	printk(KERN_INFO "soc: version %s liam.girdwood@wolfsonmicro.com\n", 
-		SND_SOC_VERSION);
-	return bus_register(&soc_bus_type);
-}
-
-subsys_initcall(soc_bus_init);
-
-static void __exit soc_bus_exit(void)
-{
-	bus_unregister(&soc_bus_type);
-}
-
-module_exit(soc_bus_exit);
-
-EXPORT_SYMBOL(soc_bus_type);
-
-/* Module information */ 
-MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
-MODULE_DESCRIPTION("ALSA SoC Core");
-MODULE_LICENSE("GPL");
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index cfd09ff..ff36759 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1,5 +1,5 @@
 /*
- * soc-core.c  --  ALSA Soc Audio Layer
+ * soc-core.c  --  ALSA SoC Audio Layer
  *
  * Copyright 2005 Wolfson Microelectronics PLC.
  * Author: Liam Girdwood
@@ -15,7 +15,6 @@
  *    25th Oct 2005   Working Codec, Interface and Platform registration.
  *
  *  TODO:
- *   o Finish machine layer - move machine stuff out pxa2xx-pcm.c
  *   o Add hw rules to enforce rates, etc.
  *   o More testing with other codecs/machines.
  *   o Add more codecs and platforms to ensure good API coverage.
@@ -28,7 +27,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-#include <linux/i2c.h>
 #include <linux/pm.h>
 #include <linux/bitops.h>
 #include <linux/platform_device.h>
@@ -45,8 +43,6 @@
 	((x) == SND_SOC_I2S) ? "i2s" : \
 	((x) == SND_SOC_SSP) ? "ssp" : NULL)
 
-static DECLARE_MUTEX(soc_sem);
-
 int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
 				unsigned short mask, unsigned short value)
 {
@@ -75,27 +71,32 @@ int snd_soc_test_bits(struct snd_soc_cod
 	return change;
 }
 
-static int soc_match_hw(struct snd_soc_hw_mode *c, struct snd_soc_hw_mode *i, 
-	int rate, int fs)
+static unsigned int rates[] = {
+	5512, 8000, 11025, 16000, 22050, 32000, 44100,
+	48000, 64000, 88200, 96000, 176400, 192000
+};
+
+static inline int soc_match_hw(struct snd_soc_hw_mode *c, struct snd_soc_hw_mode *i, 
+	unsigned int rate, unsigned int fs)
 {
 	if (c->rate != i->rate)
 		return 0;
-	
-	if (c->rate != rate)
+
+	if (rates[generic_ffs(c->rate) - 1] != rate)
 		return 0;
-	
+
 	if (c->fs != i->fs)
 		return 0;
-	
+
 	if (!(c->hformat & i->hformat & SND_SOC_FORMAT_MASK))
 		return 0;
-	
+
 	if (!(c->hformat & i->hformat & SND_SOC_CLOCK_MASK))
 		return 0;
-	
+
 	if (!(c->hformat & i->hformat & SND_SOC_INV_MASK))
 		return 0;
-	
+
 	if (i->fs < fs)
 		return i->fs;
 	return 0;
@@ -106,96 +107,121 @@ static int soc_match_hw(struct snd_soc_h
 static int soc_hw_params(snd_pcm_substream_t *substream, 
 	snd_pcm_hw_params_t *params)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	int fs = 2048, i, j, match = 0;	
 
 	/* try and match interface <--> codec table entries */
-	for (i = 0; i < pcm_c->hw.num_hmodes; i++) {
-		for (j = 0; j < pcm_i->hw.num_hmodes; j++) {
-			if (soc_match_hw(&pcm_c->hw.hmodes[i], &pcm_i->hw.hmodes[j], 
+	for (i = 0; i < rtd->pcm_c->hw.num_hmodes; i++) {
+		for (j = 0; j < rtd->pcm_i->hw.num_hmodes; j++) {
+			if (soc_match_hw(&rtd->pcm_c->hw.hmodes[i], &rtd->pcm_i->hw.hmodes[j], 
 					params_rate(params), fs)) {
-				pcm_c->hw_runtime = pcm_c->hw.hmodes[i];
-				pcm_i->hw_runtime = pcm_i->hw.hmodes[j];
-				fs = pcm_c->hw.hmodes[i].fs;
+				rtd->pcm_c->hw_runtime = rtd->pcm_c->hw.hmodes[i];
+				rtd->pcm_i->hw_runtime = rtd->pcm_i->hw.hmodes[j];
+				fs = rtd->pcm_c->hw.hmodes[i].fs;
 				match = 1;
 			}
 		}
 	}
-	
+
 	if (!match)
 		return -EINVAL;
-	
-	pcm_i->hw_runtime.hformat =
-		1 << (generic_ffs(pcm_i->hw_runtime.hformat & pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) -1) | 
-		1 << (generic_ffs(pcm_i->hw_runtime.hformat & pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) - 1) |
-		1 << (generic_ffs(pcm_i->hw_runtime.hformat & pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) - 1);
-
-	pcm_i->hw_runtime.hbits = pcm_i->hw_runtime.hbits & pcm_c->hw_runtime.hbits;
-	pcm_c->hw_runtime.hformat = pcm_i->hw_runtime.hformat;
-	pcm_c->hw_runtime.hbits = pcm_i->hw_runtime.hbits;
+
+	rtd->pcm_i->hw_runtime.hformat =
+		1 << (generic_ffs(rtd->pcm_i->hw_runtime.hformat & rtd->pcm_c->hw_runtime.hformat & SND_SOC_FORMAT_MASK) -1) | 
+		1 << (generic_ffs(rtd->pcm_i->hw_runtime.hformat & rtd->pcm_c->hw_runtime.hformat & SND_SOC_CLOCK_MASK) - 1) |
+		1 << (generic_ffs(rtd->pcm_i->hw_runtime.hformat & rtd->pcm_c->hw_runtime.hformat & SND_SOC_INV_MASK) - 1);
+
+	rtd->pcm_i->hw_runtime.hbits = rtd->pcm_i->hw_runtime.hbits & rtd->pcm_c->hw_runtime.hbits;
+	rtd->pcm_c->hw_runtime.hformat = rtd->pcm_i->hw_runtime.hformat;
+	rtd->pcm_c->hw_runtime.hbits = rtd->pcm_i->hw_runtime.hbits;
 	
 	/* for debug atm */
-	printk(KERN_INFO "soc: codec rate %d fs %d format %x\n", pcm_c->hw_runtime.rate, 
-		pcm_c->hw_runtime.fs, pcm_c->hw_runtime.hformat);
-	printk(KERN_INFO "soc: iface rate %d fs %d format %x\n", pcm_i->hw_runtime.rate, 
-		pcm_i->hw_runtime.fs, pcm_i->hw_runtime.hformat);
+	printk(KERN_INFO "soc: codec rate %d fs %d format %x\n",rtd->pcm_c->hw_runtime.rate, 
+		rtd->pcm_c->hw_runtime.fs, rtd->pcm_c->hw_runtime.hformat);
+	printk(KERN_INFO "soc: iface rate %d fs %d format %x\n", rtd->pcm_i->hw_runtime.rate, 
+		rtd->pcm_i->hw_runtime.fs, rtd->pcm_i->hw_runtime.hformat);
 	printk(KERN_INFO "soc: audio rate %d chn %d\n", params_rate(params), params_channels(params));	
 	
 	return 0;
 }
 
+static inline u32 get_rates(struct snd_soc_hw_mode *modes, int nmodes)
+{
+	int i;
+	u32 rates = 0;
+	
+	for(i = 0; i < nmodes; i++)
+		rates |= modes[i].rate;
+
+	return rates;
+}
+
+static inline u64 get_formats(struct snd_soc_hw_mode *modes, int nmodes)
+{
+	int i;
+	u64 formats = 0;
+	
+	for(i = 0; i < nmodes; i++)
+		formats |= modes[i].hbits;
+
+	return formats;
+}
+
 /*
  * Initialize the runtime->hw record, private data can be allocated
  */
 static int soc_pcm_open(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
 	snd_pcm_runtime_t *runtime = substream->runtime;
-	struct snd_soc_machine *machine = pcm_i->machine; 
-	struct snd_soc_platform *platform = machine->platform;
+	struct snd_soc_machine *machine = socdev->machine; 
+	struct snd_soc_platform *platform = socdev->platform;
+	struct snd_soc_pcm_codec *pcm_c = rtd->pcm_c;
+	struct snd_soc_pcm_interface *pcm_i = rtd->pcm_i;
 	int ret = 0;
 
+	runtime->hw.rates = get_rates(pcm_c->hw.hmodes, pcm_c->hw.num_hmodes) & 
+		get_rates(pcm_i->hw.hmodes, pcm_i->hw.num_hmodes);
+	runtime->hw.formats = get_formats(pcm_c->hw.hmodes, pcm_c->hw.num_hmodes) & 
+		get_formats(pcm_i->hw.hmodes, pcm_i->hw.num_hmodes);
+	
 	/* Check that the codec and SoC audio interface's are compatible */
 	if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		runtime->hw.rates = pcm_c->playback.rates & pcm_i->playback.rates;
-		runtime->hw.formats = pcm_c->playback.formats & pcm_i->playback.formats;
-		runtime->hw.rate_min = max(pcm_c->playback.rate_min, pcm_i->playback.rate_min);
-		runtime->hw.rate_max = min(pcm_c->playback.rate_max, pcm_i->playback.rate_max);
-		runtime->hw.channels_min = max(pcm_c->playback.channels_min, pcm_i->playback.channels_min);
-		runtime->hw.channels_max = min(pcm_c->playback.channels_max, pcm_i->playback.channels_max);
+		runtime->hw.rate_min = max(rtd->pcm_c->playback.rate_min, rtd->pcm_i->playback.rate_min);
+		runtime->hw.rate_max = min(rtd->pcm_c->playback.rate_max, rtd->pcm_i->playback.rate_max);
+		runtime->hw.channels_min = max(rtd->pcm_c->playback.channels_min, rtd->pcm_i->playback.channels_min);
+		runtime->hw.channels_max = min(rtd->pcm_c->playback.channels_max, rtd->pcm_i->playback.channels_max);
 	} else {
-		runtime->hw.rates = pcm_c->capture.rates & pcm_i->capture.rates;
-		runtime->hw.formats = pcm_c->capture.formats & pcm_i->capture.formats;
-		runtime->hw.rate_min = max(pcm_c->capture.rate_min, pcm_i->capture.rate_min);
-		runtime->hw.rate_max = min(pcm_c->capture.rate_max, pcm_i->capture.rate_max);
-		runtime->hw.channels_min = max(pcm_c->capture.channels_min, pcm_i->capture.channels_min);
-		runtime->hw.channels_max = min(pcm_c->capture.channels_max, pcm_i->capture.channels_max);
+		runtime->hw.rate_min = max(rtd->pcm_c->capture.rate_min, rtd->pcm_i->capture.rate_min);
+		runtime->hw.rate_max = min(rtd->pcm_c->capture.rate_max, rtd->pcm_i->capture.rate_max);
+		runtime->hw.channels_min = max(rtd->pcm_c->capture.channels_min, rtd->pcm_i->capture.channels_min);
+		runtime->hw.channels_max = min(rtd->pcm_c->capture.channels_max, rtd->pcm_i->capture.channels_max);
 	}
 
 	/* will the codec and interface work together ? */
 	snd_pcm_limit_hw_rates(runtime);
 	if (!runtime->hw.rates) {
-		printk(KERN_ERR "soc: %s <-> %s No matching rates\n", pcm_c->name, pcm_i->name);
+		printk(KERN_ERR "soc: %s <-> %s No matching rates\n", rtd->pcm_c->name, rtd->pcm_i->name);
 		return -ENODEV;
 	}
 	if(!runtime->hw.formats) {
-		printk(KERN_ERR "soc: %s <-> %s No matching formats\n", pcm_c->name, pcm_i->name);
+		printk(KERN_ERR "soc: %s <-> %s No matching formats\n", rtd->pcm_c->name, rtd->pcm_i->name);
 		return -ENODEV;
 	}
 	if(!runtime->hw.channels_min || !runtime->hw.channels_max) {
-		printk(KERN_ERR "soc: %s <-> %s No matching channels\n", pcm_c->name, pcm_i->name);
+		printk(KERN_ERR "soc: %s <-> %s No matching channels\n", rtd->pcm_c->name, rtd->pcm_i->name);
 		return -ENODEV;
 	}
-	printk(KERN_INFO "soc: %s <-> %s info:\n", pcm_c->name, pcm_i->name);
+	printk(KERN_INFO "soc: %s <-> %s info:\n", rtd->pcm_c->name, rtd->pcm_i->name);
+	/* tmp debug */
 	printk(KERN_INFO "soc: rate mask 0x%x \nsoc: min ch %d max ch %d\nsoc: min rate %d max rate %d\n",
 		runtime->hw.rates, runtime->hw.channels_min,
 		runtime->hw.channels_max, runtime->hw.rate_min, runtime->hw.rate_max);
 
-	if(pcm_i->ops.startup) {
-		if((ret = pcm_i->ops.startup(substream)) < 0) {
-			printk(KERN_ERR "soc: can't open interface %s\n", pcm_i->name);
+	if(rtd->pcm_i->ops.startup) {
+		if((ret = rtd->pcm_i->ops.startup(substream)) < 0) {
+			printk(KERN_ERR "soc: can't open interface %s\n", rtd->pcm_i->name);
 			goto ops_err;
 		}
 	}
@@ -207,29 +233,29 @@ static int soc_pcm_open(snd_pcm_substrea
 		}
 	}
 
-	if(machine->ops->startup) {
+	if(machine->ops && machine->ops->startup) {
 		if((ret = machine->ops->startup(substream)) < 0) {
 			printk(KERN_ERR "soc: %s startup failed\n", machine->name);
 			goto machine_err;
 		}
 	}
 
-	if(pcm_c->ops.startup) {
-		if((ret = pcm_c->ops.startup(substream)) < 0) {
-			printk(KERN_ERR "soc: can't open codec %s\n", pcm_c->name);
+	if(rtd->pcm_c->ops.startup) {
+		if((ret = rtd->pcm_c->ops.startup(substream)) < 0) {
+			printk(KERN_ERR "soc: can't open codec %s\n", rtd->pcm_c->name);
 			goto pcm_err;
 		}
 	}
 
-	pcm_i->runtime = runtime;
+	rtd->pcm_i->runtime = runtime;
 	return ret;
 
 pcm_err:
-	if(pcm_c->ops.shutdown)
-		pcm_c->ops.shutdown(substream);
+	if(rtd->pcm_c->ops.shutdown)
+		rtd->pcm_c->ops.shutdown(substream);
 	
 machine_err:
-	if(machine->ops->shutdown)
+	if(machine->ops && machine->ops->shutdown)
 		machine->ops->shutdown(substream);
 	
 platform_err:
@@ -237,8 +263,8 @@ platform_err:
 		platform->pcm_ops->close(substream);
 
 ops_err:
-	if(pcm_i->ops.shutdown)
-		pcm_i->ops.shutdown(substream);	
+	if(rtd->pcm_i->ops.shutdown)
+		rtd->pcm_i->ops.shutdown(substream);	
 	
 	return ret;
 }
@@ -246,23 +272,23 @@ ops_err:
 /* private data can be freed here */
 static int soc_pcm_close(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
-	struct snd_soc_machine *machine = pcm_i->machine; 
-	struct snd_soc_platform *platform = machine->platform;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_machine *machine = socdev->machine; 
+	struct snd_soc_platform *platform = socdev->platform;
 
-	if(pcm_i->ops.shutdown)
-		pcm_i->ops.shutdown(substream);
+	if(rtd->pcm_i->ops.shutdown)
+		rtd->pcm_i->ops.shutdown(substream);
 	
-	if(pcm_c->ops.shutdown)
-		pcm_c->ops.shutdown(substream);
+	if(rtd->pcm_c->ops.shutdown)
+		rtd->pcm_c->ops.shutdown(substream);
 	
-	if(machine->ops->shutdown)
+	if(machine->ops && machine->ops->shutdown)
 		machine->ops->shutdown(substream);
 	
 	if(platform->pcm_ops->close)
 		platform->pcm_ops->close(substream);
-	pcm_i->runtime = NULL;
+	rtd->pcm_i->runtime = NULL;
 	return 0;
 }
 
@@ -270,22 +296,21 @@ static int soc_pcm_close(snd_pcm_substre
  * atomic, can be called multiple times, can refer to runtime info*/
 static int soc_pcm_prepare(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
-	struct snd_soc_machine *machine = pcm_i->machine; 
-	struct snd_soc_platform *platform = machine->platform;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_platform *platform = socdev->platform;
 	int ret = 0;
-	
+
 	if(platform->pcm_ops->prepare)
 		if((ret = platform->pcm_ops->prepare(substream)) < 0)
 			return ret;
-	
-	if(pcm_c->ops.prepare)
-		if((ret = pcm_c->ops.prepare(substream)) < 0)
+
+	if(rtd->pcm_c->ops.prepare)
+		if((ret = rtd->pcm_c->ops.prepare(substream)) < 0)
 			return ret;
-	
-	if(pcm_i->ops.prepare)
-		if((ret = pcm_i->ops.prepare(substream)) < 0)
+
+	if(rtd->pcm_i->ops.prepare)
+		if((ret = rtd->pcm_i->ops.prepare(substream)) < 0)
 			return ret;
 
 	return ret;
@@ -293,18 +318,17 @@ static int soc_pcm_prepare(snd_pcm_subst
 
 static int soc_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
-	struct snd_soc_machine *machine = pcm_i->machine; 
-	struct snd_soc_platform *platform = machine->platform;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_platform *platform = socdev->platform;
 	int ret = 0;
 
-	if(pcm_c->ops.trigger)
-		if((ret = pcm_c->ops.trigger(substream, cmd)) < 0)
+	if(rtd->pcm_c->ops.trigger)
+		if((ret = rtd->pcm_c->ops.trigger(substream, cmd)) < 0)
 			return ret;
-	
-	if(pcm_i->ops.trigger)
-		if((ret = pcm_i->ops.trigger(substream, cmd)) < 0)
+
+	if(rtd->pcm_i->ops.trigger)
+		if((ret = rtd->pcm_i->ops.trigger(substream, cmd)) < 0)
 			return ret;
 	
 	if(platform->pcm_ops->trigger)
@@ -320,55 +344,55 @@ static int soc_pcm_trigger(snd_pcm_subst
 static int soc_pcm_hw_params(snd_pcm_substream_t *substream,
 				snd_pcm_hw_params_t *params)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
-	struct snd_soc_codec *codec = (struct snd_soc_codec*)pcm_i->card->private_data;
-	struct snd_soc_machine *machine = pcm_i->machine; 
-	struct snd_soc_platform *platform = machine->platform;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_platform *platform = socdev->platform;
+	struct snd_soc_codec *codec = socdev->codec;
 	int ret = 0;
 
 	/* prepare hw non AC97 only */
-	if(pcm_i->type != SND_SOC_AC97)
-		soc_hw_params(substream, params);
-	
-	if(pcm_c->ops.hw_params) {
-		if((ret = pcm_c->ops.hw_params(substream, params)) < 0) {
-			printk(KERN_ERR "soc: can't set codec %s hw params\n", pcm_c->name);
+	if(rtd->pcm_i->type != SND_SOC_AC97) {
+		if((ret = soc_hw_params(substream, params)) < 0)
+			return ret;
+	}
+
+	if(rtd->pcm_c->ops.hw_params) {
+		if((ret = rtd->pcm_c->ops.hw_params(substream, params)) < 0) {
+			printk(KERN_ERR "soc: can't set codec %s hw params\n", rtd->pcm_c->name);
 			goto codec_err;
 		}
 	}
-	
-	if(pcm_i->ops.hw_params) {
-		if((ret = pcm_i->ops.hw_params(substream, params)) < 0) {
-			printk(KERN_ERR "soc: can't set interface %s hw params\n", pcm_i->name);
+
+	if(rtd->pcm_i->ops.hw_params) {
+		if((ret = rtd->pcm_i->ops.hw_params(substream, params)) < 0) {
+			printk(KERN_ERR "soc: can't set interface %s hw params\n", rtd->pcm_i->name);
 			goto interface_err;
 		}
 	}
-	
+
 	if(platform->pcm_ops->hw_params) {
 		if((ret = platform->pcm_ops->hw_params(substream, params)) < 0) {
 			printk(KERN_ERR "soc: can't set platform %s hw params\n", platform->name);
 			goto platform_err;
 		}
 	}
-	
+
 	if(codec->dpm_state == SNDRV_CTL_POWER_D0)
 		return 0;
-	
+
 	if(codec->dpm_event)
 		codec->dpm_event(codec, SNDRV_CTL_POWER_D1);
 	
-	snd_soc_dpm_codec_event(codec, SNDRV_CTL_POWER_D1);
+	snd_soc_dpm_codec_event(codec, SNDRV_CTL_POWER_D0);
 	if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		snd_soc_dpm_stream_event(codec, pcm_c->playback.sname, SND_SOC_DPM_STREAM_START);
+		snd_soc_dpm_stream_event(codec, rtd->pcm_c->playback.sname, SND_SOC_DPM_STREAM_START);
 	else
-		snd_soc_dpm_stream_event(codec, pcm_c->capture.sname, SND_SOC_DPM_STREAM_START);
+		snd_soc_dpm_stream_event(codec, rtd->pcm_c->capture.sname, SND_SOC_DPM_STREAM_START);
 		
 	if(codec->dpm_event)
 		codec->dpm_event(codec, SNDRV_CTL_POWER_D0);
 	snd_soc_dpm_codec_mute(codec, 0);
 	codec->dpm_state = SNDRV_CTL_POWER_D0;
-
 	return ret;
 	
 platform_err:
@@ -376,12 +400,12 @@ platform_err:
 		platform->pcm_ops->hw_free(substream);
 	
 interface_err:
-	if(pcm_i->ops.hw_free)
-		pcm_i->ops.hw_free(substream);
+	if(rtd->pcm_i->ops.hw_free)
+		rtd->pcm_i->ops.hw_free(substream);
 	
 codec_err:
-	if(pcm_c->ops.hw_free)
-		pcm_c->ops.hw_free(substream);
+	if(rtd->pcm_c->ops.hw_free)
+		rtd->pcm_c->ops.hw_free(substream);
 
 	return ret;
 }
@@ -389,17 +413,16 @@ codec_err:
 /* free buffers, can be called multiple times */
 static int soc_pcm_hw_free(snd_pcm_substream_t *substream)
 {
-	struct snd_soc_pcm_codec *pcm_c = substream->private_data;
-	struct snd_soc_pcm_interface *pcm_i = pcm_c->pcm_i;
-	struct snd_soc_codec *codec = (struct snd_soc_codec*)pcm_i->card->private_data;
-	struct snd_soc_machine *machine = pcm_i->machine; 
-	struct snd_soc_platform *platform = machine->platform;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_platform *platform = socdev->platform;
+	struct snd_soc_codec *codec = socdev->codec;
 
-	if(pcm_c->ops.hw_free)
-		pcm_c->ops.hw_free(substream);
+	if(rtd->pcm_c->ops.hw_free)
+		rtd->pcm_c->ops.hw_free(substream);
 	
-	if(pcm_i->ops.hw_free)
-		pcm_i->ops.hw_free(substream);
+	if(rtd->pcm_i->ops.hw_free)
+		rtd->pcm_i->ops.hw_free(substream);
 	
 	if(platform->pcm_ops->hw_free)
 		platform->pcm_ops->hw_free(substream);
@@ -411,9 +434,9 @@ static int soc_pcm_hw_free(snd_pcm_subst
 	snd_soc_dpm_codec_event(codec, SNDRV_CTL_POWER_D3hot);
 		
 	if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		snd_soc_dpm_stream_event(codec, pcm_c->playback.sname, SND_SOC_DPM_STREAM_STOP);
+		snd_soc_dpm_stream_event(codec, rtd->pcm_c->playback.sname, SND_SOC_DPM_STREAM_STOP);
 	else
-		snd_soc_dpm_stream_event(codec, pcm_c->capture.sname, SND_SOC_DPM_STREAM_STOP);
+		snd_soc_dpm_stream_event(codec, rtd->pcm_c->capture.sname, SND_SOC_DPM_STREAM_STOP);
 	
 	if(codec->dpm_event)
 		codec->dpm_event(codec, SNDRV_CTL_POWER_D3hot);
@@ -431,7 +454,6 @@ static snd_pcm_ops_t soc_pcm_ops = {
 	.trigger	= soc_pcm_trigger,
 };
 
-
 static void soc_free_dpm_widgets(struct snd_soc_codec *codec)
 {
 	struct snd_soc_dpm_widget *w, *lw = NULL;
@@ -464,44 +486,83 @@ static void soc_free_dpm_widgets(struct 
  * SUSPEND_NOTIFY - mute outputs
  * SUSPEND_DISABLE - power down chip
  */
-static int soc_suspend(struct device * dev, pm_message_t state)
+static int soc_suspend(struct platform_device *pdev, pm_message_t state)
 {
-	struct snd_soc_machine * machine = 
-		(struct snd_soc_machine*)dev->platform_data;
-	struct snd_soc_platform *platform = machine->platform;
+ 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+ 	struct snd_soc_machine *machine = socdev->machine;
+ 	struct snd_soc_platform *platform = socdev->platform;
+ 	struct snd_soc_codec_device* codec_dev = socdev->codec_dev;
+	struct snd_soc_codec* codec = socdev->codec;
 	int i;
 	
-	for(i = 0; platform->iface[i] != NULL; i++) {
-		dev->driver_data = platform->iface[i];
-		if(platform->suspend)
-			platform->suspend(dev, state);
-		if(platform->iface[i]->suspend)
-			platform->iface[i]->suspend(dev, state);
+	snd_soc_dpm_codec_mute(codec, 1);
+	codec->suspend_dpm_state = codec->dpm_state;
+
+	if (machine->suspend)
+		machine->suspend(pdev, state);
+	
+	for(i = 0; i < machine->nconfigs; i++) {
+		struct snd_soc_pcm_interface  *iface = machine->config[i].iface;
+		if (platform->suspend)
+			platform->suspend(pdev, iface);
+		if (iface->suspend)
+			iface->suspend(pdev, iface);
 	}
-	dev->driver_data = NULL;
-	if(machine->suspend)
-		machine->suspend(dev, state);
+	
+	for(i = 0; i < codec->npcms; i++) {
+		char *stream = codec->pcms[i].playback.sname;
+		if(stream != NULL)
+			snd_soc_dpm_stream_event(codec, stream, SND_SOC_DPM_STREAM_SUSPEND);
+		stream = codec->pcms[i].capture.sname;
+		if(stream != NULL)
+			snd_soc_dpm_stream_event(codec, stream, SND_SOC_DPM_STREAM_SUSPEND);
+	}
+	codec->suspend_streams = codec->active_streams;
+	codec->active_streams = 0;
+	
+	if (codec_dev->suspend)
+		codec_dev->suspend(pdev, state);
+
 	return 0;
 }
 
-static int soc_resume(struct device * dev)
+static int soc_resume(struct platform_device *pdev)
 {
-	struct snd_soc_machine * machine = 
-		(struct snd_soc_machine*)dev->platform_data;
-	struct snd_soc_platform *platform = machine->platform;
+ 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+ 	struct snd_soc_machine *machine = socdev->machine;
+ 	struct snd_soc_platform *platform = socdev->platform;
+ 	struct snd_soc_codec_device* codec_dev = socdev->codec_dev;
+	struct snd_soc_codec* codec = socdev->codec;
 	int i;
+
+	snd_soc_dpm_codec_event(codec, SNDRV_CTL_POWER_D3hot);
+	if (codec_dev->resume)
+		codec_dev->resume(pdev);
 	
-	if(machine->resume)
-		machine->resume(dev);
-		
-	for(i = 0; platform->iface[i] != NULL; i++) {
-		dev->driver_data = platform->iface[i];
-		if(platform->iface[i]->resume)
-			platform->iface[i]->resume(dev);
-		if(platform->resume)
-			platform->resume(dev);
+	for(i = 0; i < codec->npcms; i++) {
+		char* stream = codec->pcms[i].playback.sname;
+		if(stream != NULL)
+			snd_soc_dpm_stream_event(codec, stream, SND_SOC_DPM_STREAM_RESUME);
+		stream = codec->pcms[i].capture.sname;
+		if(stream != NULL)
+			snd_soc_dpm_stream_event(codec, stream, SND_SOC_DPM_STREAM_RESUME);
+	}
+	
+	if(codec->suspend_streams) {
+		snd_soc_dpm_codec_event(codec, SNDRV_CTL_POWER_D0);
+		snd_soc_dpm_codec_mute(codec, 0);
+	}
+	
+	for(i = 0; i < machine->nconfigs; i++) {
+		struct snd_soc_pcm_interface  *iface = machine->config[i].iface;
+		if (iface->resume)
+			iface->resume(pdev, iface);
+		if (platform->resume)
+			platform->resume(pdev, iface);
 	}
-	dev->driver_data = NULL;
+	
+	if (machine->resume)
+		machine->resume(pdev);
 
 	return 0;
 }
@@ -511,115 +572,104 @@ static int soc_resume(struct device * de
 #define soc_resume	NULL
 #endif
 
-static int soc_probe(struct device * dev)
+static int soc_probe(struct platform_device *pdev)
 {
 	int ret = 0, i;
-	struct snd_soc_machine * machine 
-		= (struct snd_soc_machine*)dev->platform_data;
-	struct snd_soc_platform* platform = machine->platform;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_machine *machine = socdev->machine;
+	struct snd_soc_platform *platform = socdev->platform;
+	struct snd_soc_codec_device* codec_dev = socdev->codec_dev;
 
-	if(machine->probe && ((ret = machine->probe(dev)) < 0))
+	if (machine->probe && ((ret = machine->probe(pdev)) < 0))
 		return ret;
+	
+	for (i = 0; i < machine->nconfigs; i++) {
+		struct snd_soc_pcm_interface  *iface = machine->config[i].iface;
+		if (iface->probe && ((ret = iface->probe(pdev)) < 0))
+			goto iface_err;
+	}
+
+	if (codec_dev->probe && ((ret = codec_dev->probe(pdev)) < 0))
+		goto codec_err;
 
-	if(platform->probe && ((ret = platform->probe(dev)) < 0))
+	if (platform->probe && ((ret = platform->probe(pdev)) < 0))
 		goto platform_err;
 
-	for(i = 0; platform->iface[i] != NULL; i++){
-		dev->driver_data = platform->iface[i];
-		if(platform->iface[i]->probe && 
-			((ret = platform->iface[i]->probe(dev)) < 0))
-				goto iface_err;
-	}
-	dev->driver_data = NULL;
 	return 0;
+	
+platform_err:
+	if (machine->remove)
+		machine->remove(pdev);
+		
+codec_err:
+	if (codec_dev->remove)
+		codec_dev->remove(pdev);
 
 iface_err:
-	for(; i > 0; --i){
-		if(platform->iface[i]->remove) 
-			platform->iface[i]->remove(dev);
+	for (; i > 0; --i) {
+		struct snd_soc_pcm_interface  *iface = machine->config[i].iface;
+		if (iface->remove) 
+			iface->remove(pdev);
 	}
 	
-	if(platform->remove)
-		platform->remove(dev);
-	
-platform_err:
-	if(machine->remove)
-			machine->remove(dev);
+	if (platform->remove)
+		platform->remove(pdev);
 	
 	return ret;
 }
 
-static int soc_remove(struct device * dev)
+static int soc_remove(struct platform_device *pdev)
 {
 	int i;
-	struct snd_soc_machine * machine 
-		= (struct snd_soc_machine*)dev->platform_data;
-	struct snd_soc_platform * platform = machine->platform;
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_machine *machine = socdev->machine;
+	struct snd_soc_platform *platform = socdev->platform;
+	struct snd_soc_codec_device* codec_dev = socdev->codec_dev;
 
-	for(i = 0; platform->iface[i] != NULL; i++){
-		if(platform->iface[i]->remove)
-			platform->iface[i]->remove(dev);
-	}
+	if (platform->remove)
+		platform->remove(pdev);
 
-	if(platform->remove)
-		platform->remove(dev);
+	if (codec_dev->remove)
+		codec_dev->remove(pdev);
+		
+	for (i = 0; i < machine->nconfigs; i++) {
+		struct snd_soc_pcm_interface  *iface = machine->config[i].iface;
+		if (iface->remove)
+			iface->remove(pdev);
+	}
 
-	if(machine->remove)
-			machine->remove(dev);
+	if (machine->remove)
+		machine->remove(pdev);
 	
 	return 0;
 }
 
-static struct device_driver soc_drv = {
-	.name = "soc-audio",
-	.bus = &soc_bus_type,
-	.probe = soc_probe,
-	.remove = soc_remove,
-	.suspend = soc_suspend,
-	.resume  = soc_resume,
+static struct platform_driver soc_driver = {
+	.driver		= {
+		.name		= "soc-audio",
+	},
+	.probe		= soc_probe,
+	.remove		= soc_remove,
+	.suspend	= soc_suspend,
+	.resume		= soc_resume,
 };
 
-int snd_soc_register_machine(struct snd_soc_machine *m)
-{
-	struct snd_soc_platform* platform = m->platform;
-	int ret = 0;
-
-	down(&soc_sem);
-	if(m->platform == NULL) {
-		up(&soc_sem);
-		return -ENODEV;
-	}
-
-	soc_pcm_ops.mmap = platform->pcm_ops->mmap;
-	soc_pcm_ops.pointer = platform->pcm_ops->pointer;
-	soc_pcm_ops.ioctl = platform->pcm_ops->ioctl;
-
-	if((ret = driver_register(&soc_drv)) < 0) {
-		printk(KERN_ERR "soc: failed to register machine %s\n", platform->name);
-		up(&soc_sem);
-		return ret;
-	}
-
-	up(&soc_sem);
-	return 0;
-}
-
-void snd_soc_unregister_machine(struct snd_soc_machine *m)
-{
-	down(&soc_sem);
-	driver_unregister(&soc_drv);
-	up(&soc_sem);	
-}
-
-
-static int soc_create_pcm(struct snd_soc_codec *codec, 
+static int soc_create_pcm(struct snd_soc_device *socdev, 
 	struct snd_soc_pcm_codec *pcm_c, struct snd_soc_pcm_interface *iface, 
 	int num)
 {
+	struct snd_soc_codec *codec = socdev->codec;
+	struct snd_soc_pcm_runtime *rtd;
 	snd_pcm_t *pcm;
 	char new_name[32];
 	int ret = 0;
 
+	if((rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL)) == NULL)
+		return -ENOMEM;
+	rtd->pcm_i = iface;
+	rtd->socdev = socdev;
+	rtd->pcm_c = pcm_c;
+
 	/* check client and interface hw capabilities */
 	sprintf(new_name, "%s-%s-%d", pcm_c->name, iface_name(iface->type), num);
 
@@ -627,11 +677,13 @@ static int soc_create_pcm(struct snd_soc
 		printk(KERN_ERR "soc: can't create pcm for codec %s\n", codec->name);
 		return ret;
 	}
-	pcm_c->pcm_i = iface;
-	pcm_c->codec = codec;
-	iface->card = codec->card;
-	iface->pcm_c = pcm_c;
-	pcm->private_data = pcm_c;
+
+	iface->socdev = socdev;
+	pcm->private_data = rtd;
+
+	soc_pcm_ops.mmap = socdev->platform->pcm_ops->mmap;
+	soc_pcm_ops.pointer = socdev->platform->pcm_ops->pointer;
+	soc_pcm_ops.ioctl = socdev->platform->pcm_ops->ioctl;
 
 	if (pcm_c->nplayback)
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops);
@@ -639,25 +691,26 @@ static int soc_create_pcm(struct snd_soc
 	if (pcm_c->ncapture)
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops);
 
-	if((ret = codec->machine->platform->pcm_new(codec->card, pcm_c, pcm)) < 0) {
+	if((ret = socdev->platform->pcm_new(codec->card, pcm_c, pcm)) < 0) {
 		printk(KERN_ERR "soc: platform pcm constructor failed\n");
 		return ret;
 	}
 
-	pcm->private_free = codec->machine->platform->pcm_free;
+	pcm->private_free = socdev->platform->pcm_free;
 	printk(KERN_INFO "soc: %s <-> %s mapping ok\n", pcm_c->name, iface->name);
 	return ret;
 }
 
-static int soc_match_pcms(struct snd_soc_codec *codec)
+static int soc_match_pcms(struct snd_soc_device *socdev)
 {
-	struct snd_soc_machine *machine = codec->machine;
+	struct snd_soc_codec *codec = socdev->codec;
+	struct snd_soc_machine *machine = socdev->machine;
 	int n = 0, i, j;
 
 	for(i = 0; i < machine->nconfigs; i++) {
 		for(j = 0; j < codec->npcms; j++) {
 			if(!strcmp(codec->pcms[j].name, machine->config[i].sname)) {
-				soc_create_pcm(codec, &codec->pcms[j], machine->config[i].iface, n);
+				soc_create_pcm(socdev, &codec->pcms[j], machine->config[i].iface, n);
 				n++;
 			}
 		}			
@@ -666,8 +719,9 @@ static int soc_match_pcms(struct snd_soc
 	return n;
 }
 
-int snd_soc_register_pcms(struct snd_soc_codec *codec)
+int snd_soc_register_pcms(struct snd_soc_device *socdev)
 {
+	struct snd_soc_codec *codec = socdev->codec;
 	int ret = 0;
 
 	/* register a sound card */
@@ -677,44 +731,45 @@ int snd_soc_register_pcms(struct snd_soc
 		return -ENODEV;
 	}
 
-	codec->card->dev = codec->dev;
+	codec->card->dev = socdev->dev;
 	codec->card->private_data = codec;
 	strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver));
-	
-	if(soc_match_pcms(codec) == 0){
+
+	if(soc_match_pcms(socdev) == 0){
 		printk(KERN_ERR "soc: couldn't match any pcms for %s\n", codec->name);
 		return -ENODEV;
 	}
-	
 	return ret;
-
 }
 
-int snd_soc_register_card(struct snd_soc_codec *codec)
+int snd_soc_register_card(struct snd_soc_device *socdev)
 {
+	struct snd_soc_codec *codec = socdev->codec;
 	int ret = 0, i;
 	
 	for(i = 0; i < codec->npcms; i++) {
-		if(codec->machine->config[i].init)
-			codec->machine->config[i].init(codec);
+		if(socdev->machine->config[i].init)
+			socdev->machine->config[i].init(codec);
 	}
 	snprintf(codec->card->shortname, sizeof(codec->card->shortname),
 		 "%s", codec->name);
 	snprintf(codec->card->longname, sizeof(codec->card->longname),
-		 "%s (%s)", codec->longname, "SoC");
+		 "%s (%s)", codec->longname, "ASoC");
 	
 	if((ret = snd_card_register(codec->card)) < 0) {
 		printk(KERN_ERR "soc: failed to register soundcard for codec %s\n", codec->name);
 		return ret;
 	}
 	
-	snd_soc_dpm_sys_add(codec->dev);
+	snd_soc_dpm_sys_add(socdev->dev);
 	return ret;
 }
 
-void snd_soc_free_pcms(struct snd_soc_codec *codec)
+void snd_soc_free_pcms(struct snd_soc_device *socdev)
 {
-	snd_soc_dpm_sys_remove(codec->dev);
+	struct snd_soc_codec *codec = socdev->codec;
+
+	snd_soc_dpm_sys_remove(socdev->dev);
 	soc_free_dpm_widgets(codec);
 	snd_card_free(codec->card);
 }
@@ -803,6 +858,41 @@ int snd_soc_put_enum_double(snd_kcontrol
 	return snd_soc_update_bits(codec, e->reg, mask, val);
 }
 
+/* ext volume and switch controls */
+int snd_soc_info_enum_ext(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+{
+	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+	
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+	uinfo->count = 1;
+	uinfo->value.enumerated.items = e->mask;
+	
+	if (uinfo->value.enumerated.item > e->mask - 1)
+		uinfo->value.enumerated.item = e->mask - 1;
+	strcpy(uinfo->value.enumerated.name, e->texts[uinfo->value.enumerated.item]);
+	return 0;
+}
+
+int snd_soc_info_volsw_ext(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+{
+	int mask = kcontrol->private_value;
+
+	uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
+	uinfo->count = 1;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = mask;
+	return 0;
+}
+
+int snd_soc_info_bool_ext(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+	uinfo->count = 1;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 1;
+	return 0;
+}
+
 /* volume and switch controls */
 int snd_soc_info_volsw(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
 {
@@ -868,19 +958,33 @@ int snd_soc_put_volsw(snd_kcontrol_t * k
 EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hw);
 EXPORT_SYMBOL_GPL(snd_soc_cnew);
 EXPORT_SYMBOL_GPL(snd_soc_info_enum_double);
+EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext);
 EXPORT_SYMBOL_GPL(snd_soc_get_enum_double);
 EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
 EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
+EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);
+EXPORT_SYMBOL_GPL(snd_soc_info_bool_ext);
 EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
 EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
 EXPORT_SYMBOL_GPL(snd_soc_update_bits);
 EXPORT_SYMBOL_GPL(snd_soc_test_bits);
-EXPORT_SYMBOL_GPL(snd_soc_register_machine);
-EXPORT_SYMBOL_GPL(snd_soc_unregister_machine);
 EXPORT_SYMBOL_GPL(snd_soc_register_pcms);
 EXPORT_SYMBOL_GPL(snd_soc_free_pcms);
 EXPORT_SYMBOL_GPL(snd_soc_register_card);
 
+static int __devinit snd_soc_init(void)
+{
+	return platform_driver_register(&soc_driver);
+}
+
+static void snd_soc_exit(void)
+{
+ 	platform_driver_unregister(&soc_driver);
+}
+
+module_init(snd_soc_init);
+module_exit(snd_soc_exit);
+
 /* Module information */ 
 MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
 MODULE_DESCRIPTION("ALSA SoC Core");
diff --git a/sound/soc/soc-dpm.c b/sound/soc/soc-dpm.c
index b844ba0..eb665ac 100644
--- a/sound/soc/soc-dpm.c
+++ b/sound/soc/soc-dpm.c
@@ -34,7 +34,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-#include <linux/i2c.h>
 #include <linux/pm.h>
 #include <linux/bitops.h>
 #include <linux/platform_device.h>
@@ -636,11 +635,12 @@ static int dpm_mixer_update_power(struct
 
 static ssize_t dpm_status_show(struct device *dev, struct device_attribute *attr, char *buf)   \
 {
-	struct snd_soc_codec *codec = (struct snd_soc_codec*)dev->platform_data;
+	struct snd_soc_device *devdata = dev_get_drvdata(dev);
+	struct snd_soc_codec* codec = devdata->codec;
 	struct snd_soc_dpm_widget *w = NULL;
 	struct list_head *l = NULL;
 	int count = 0;
-	char * state = "not set";
+	char *state = "not set";
 
 	list_for_each(l, &codec->dpm_widgets)
 	{
@@ -867,9 +867,19 @@ int snd_soc_dpm_stream_event(struct snd_
 				w->active = 1;
 				break;
 			case SND_SOC_DPM_STREAM_STOP:
-			case SND_SOC_DPM_STREAM_SUSPEND:	
 				w->active = 0;
 				break;
+			case SND_SOC_DPM_STREAM_SUSPEND:
+				if (w->active)
+					w->suspend = 1;	
+				w->active = 0;
+				break;
+			case SND_SOC_DPM_STREAM_RESUME:
+				if(w->suspend) {
+					w->active = 1;
+					w->suspend = 0;
+				}
+				break;
 			case SND_SOC_DPM_STREAM_PAUSE_PUSH:
 				break;
 			case SND_SOC_DPM_STREAM_PAUSE_RELEASE:
@@ -906,7 +916,7 @@ int snd_soc_dpm_codec_event(struct snd_s
 	struct list_head *l = NULL;	
 	int pm = 0, active = 0;
 
-	if(event == SNDRV_CTL_POWER_D1) {
+	if(event == SNDRV_CTL_POWER_D0) {
 		if(codec->active_streams)
 			return 0;
 		pm = 1;
@@ -930,7 +940,7 @@ int snd_soc_dpm_codec_event(struct snd_s
 				tpm = (pm ? 0:1);
 			
 			dpm_update_bits(w, tpm);
-			//printk("active %d name %s state %d\n", codec->active_streams, w->name, tpm);	
+			/*printk("active %d name %s state %d\n", codec->active_streams, w->name, tpm);*/	
 		}
 	}
 
@@ -939,7 +949,7 @@ int snd_soc_dpm_codec_event(struct snd_s
 
 /* update codec dpm status with connected pins/inputs */
 int snd_soc_dpm_set_connection(struct snd_soc_codec *codec, 
-	const struct snd_soc_dpm_pin *pin)
+	char *pin, int status)
 {
 	struct snd_soc_dpm_widget *w;
 	struct list_head *l = NULL;	
@@ -948,8 +958,8 @@ int snd_soc_dpm_set_connection(struct sn
 	{
 		w = list_entry(l, struct snd_soc_dpm_widget, list);
 
-		if(!strcmp(w->name, pin->name)) {
-			w->connected = pin->connected;
+		if(!strcmp(w->name, pin)) {
+			w->connected = status;
 		}
 	}
 	

