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..5e4ff17 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -26,7 +26,7 @@
 #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",
@@ -48,63 +48,73 @@ static struct snd_soc_pcm_codec ac97_soc
 	.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..591c88e 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
@@ -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,7 +311,7 @@ static int wm8731_pcm_prepare(snd_pcm_su
 	}
 	
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
+	switch(rtd->pcm_c->hw_runtime.hbits) {
 		case SND_SOC_HWBITS(16):
 			break;
 		case SND_SOC_HWBITS(20):
@@ -323,7 +326,7 @@ static int wm8731_pcm_prepare(snd_pcm_su
 	}
 
 	/* 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;
 }
 
@@ -402,16 +402,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++) {
+		if (i + 1 == WM8731_RESET)
+			continue;
+		data[0] = ((i + 1) << 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);
 	return 0;
 }
@@ -420,9 +436,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";
@@ -443,7 +459,7 @@ static int wm8731_probe(struct device *d
 	wm8731_dpm_event(codec, SNDRV_CTL_POWER_D2);
 
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		wm8731_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
 		kfree(codec->reg_cache);
 		return ret;
@@ -461,44 +477,163 @@ 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);
+	
+	/* wait for caps to finish charging - liam make this thread */
+	ssleep(1);
+	wm8731_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
 
 	return 0;
 }
 
-/* power down chip */
-static int wm8731_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_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_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_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;
+}
+
+static int wm8731_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 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..53b2d61 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
@@ -553,12 +554,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 +569,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,7 +587,7 @@ static int wm8750_pcm_prepare(snd_pcm_su
 	}
 		
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
+	switch(rtd->pcm_c->hw_runtime.hbits) {
 		case SND_SOC_HWBITS(16):
 			break;
 		case SND_SOC_HWBITS(20):
@@ -600,7 +602,7 @@ static int wm8750_pcm_prepare(snd_pcm_su
 	}
 
 	/* 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 +617,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;
@@ -678,16 +680,32 @@ static struct snd_soc_pcm_codec wm8750_p
 	},
 };
 
-static int wm8750_suspend(struct device *dev, pm_message_t 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 + 1 == WM8750_RESET)
+			continue;
+		data[0] = ((i + 1) << 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);
 	return 0;
 }
@@ -696,9 +714,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";
@@ -719,7 +737,7 @@ static int wm8750_probe(struct device *d
 	wm8750_dpm_event(codec, SNDRV_CTL_POWER_D2);
 
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		wm8750_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
 		kfree(codec->reg_cache);
 		return ret;
@@ -745,48 +763,163 @@ static int wm8750_probe(struct device *d
 
 	wm8750_add_controls(codec);
 	wm8750_add_widgets(codec);
-	snd_soc_register_card(codec);
+	snd_soc_register_card(socdev);
 	
-	/* wait for caps to finish charging - liam make this thread */
+	/* wait for caps to finish charging - liam make this timer */
 	ssleep(1);
 	wm8750_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
 
 	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;
+	codec->longname = "Corgi Audio Codec";
+	INIT_LIST_HEAD(&codec->dpm_widgets);
+	INIT_LIST_HEAD(&codec->dpm_paths);
+
+	wm8750_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(&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);
+
+	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..8214210 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
@@ -241,7 +242,6 @@ static int wm8753_write(struct snd_soc_c
 
 #define wm8753_reset(c) wm8753_write(c, WM8753_RESET, 0)
 
-
 /*
  * WM8753 Controls
  */
@@ -845,16 +845,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 +866,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,7 +884,7 @@ static int wm8753_pcm_voice_prepare(snd_
 	}
 	
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
+	switch(rtd->pcm_c->hw_runtime.hbits) {
 		case SND_SOC_HWBITS(16):
 			break;
 		case SND_SOC_HWBITS(20):
@@ -899,15 +900,15 @@ static int wm8753_pcm_voice_prepare(snd_
 	
 	/* 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 +926,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 +947,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,7 +965,7 @@ static int wm8753_pcm_hifi_prepare(snd_p
 	}
 	
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
+	switch(rtd->pcm_c->hw_runtime.hbits) {
 		case SND_SOC_HWBITS(16):
 			break;
 		case SND_SOC_HWBITS(20):
@@ -979,7 +981,7 @@ static int wm8753_pcm_hifi_prepare(snd_p
 	
 	/* 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 +998,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;
@@ -1085,17 +1087,33 @@ static struct snd_soc_pcm_codec wm8753_p
 		.hmodes = &wm8753_hifi[0],},},
 };
 
-static int wm8753_suspend(struct device *dev, pm_message_t 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;
-	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
+	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, codec->suspend_dpm_state);
 	return 0;
 }
 
@@ -1103,9 +1121,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";
@@ -1126,7 +1144,7 @@ static int wm8753_probe(struct device *d
 	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D2);
 
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
 		kfree(codec->reg_cache);
 		return ret;
@@ -1152,48 +1170,162 @@ static int wm8753_probe(struct device *d
 
 	wm8753_add_controls(codec);
 	wm8753_add_widgets(codec);
-	snd_soc_register_card(codec);
+	snd_soc_register_card(socdev);
 
-	/* wait for caps to finish charging - liam make this thread */
+	/* wait for caps to finish charging - liam make this timer */
 	ssleep(1);
 	wm8753_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
 
 	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;
+	codec->longname = "Corgi Audio Codec";
+	
+	INIT_LIST_HEAD(&codec->dpm_widgets);
+	INIT_LIST_HEAD(&codec->dpm_paths);
+	wm8753_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(&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);
+
+	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..cf2c7cd 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
@@ -490,12 +491,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 +506,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,7 +524,7 @@ static int wm8971_pcm_prepare(snd_pcm_su
 	}
 		
 	/* bit size */
-	switch(pcm_c->hw_runtime.hbits) {
+	switch(rtd->pcm_c->hw_runtime.hbits) {
 		case SND_SOC_HWBITS(16):
 			break;
 		case SND_SOC_HWBITS(20):
@@ -537,7 +539,7 @@ static int wm8971_pcm_prepare(snd_pcm_su
 	}
 
 	/* 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 +554,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;
@@ -615,23 +617,39 @@ static struct snd_soc_pcm_codec wm8971_p
 	},
 };
 
-static int wm8971_suspend(struct device *dev, pm_message_t 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) << 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);
 	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";
@@ -652,7 +670,7 @@ static int wm8971_probe(struct device *d
 	wm8971_dpm_event(codec, SNDRV_CTL_POWER_D2);
 
 	/* register pcms */
-	if((ret = snd_soc_register_pcms(codec)) < 0) {
+	if((ret = snd_soc_register_pcms(socdev)) < 0) {
 		wm8971_dpm_event(codec, SNDRV_CTL_POWER_D3cold);
 		kfree(codec->reg_cache);
 		return ret;
@@ -681,48 +699,162 @@ static int wm8971_probe(struct device *d
 
 	wm8971_add_controls(codec);
 	wm8971_add_widgets(codec);
-	snd_soc_register_card(codec);
+	snd_soc_register_card(socdev);
 	
-	/* wait for caps to finish charging - liam make this thread */
+	/* wait for caps to finish charging - liam make this timer */
 	ssleep(1);
 	wm8971_dpm_event(codec, SNDRV_CTL_POWER_D3hot);
 
 	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;
+	codec->longname = "Corgi Audio Codec";
+	INIT_LIST_HEAD(&codec->dpm_widgets);
+	INIT_LIST_HEAD(&codec->dpm_paths);
+
+	wm8971_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(&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);
+
+	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..f3dfd09 100644
--- a/sound/soc/codecs/wm9713-voice.c
+++ b/sound/soc/codecs/wm9713-voice.c
@@ -43,8 +43,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)
@@ -71,83 +72,104 @@ static struct snd_soc_hw_mode wm9713_voi
 	{WM9713_VOICE_HWFMT, 	SND_SOC_HWBITS(16),		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 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;
 	}
+	
 	/* 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;
 }
 
@@ -168,7 +190,6 @@ static struct snd_soc_pcm_codec wm9713_p
 		.channels_max = 1,},
 	.ops = {
 		.startup = wm9713_voice_startup,
-	//	.shutdown = wm9713_voice_shutdown,
 		.prepare = wm9713_voice_prepare,},
 	.hw = {
 		.num_hmodes = ARRAY_SIZE(wm9713_voice),
@@ -177,87 +198,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)
+static struct snd_soc_device *wm9713v_socdev;
+
+static int wm9713v_probe(struct platform_device *pdev)
 {
-	struct snd_soc_codec* codec = (struct snd_soc_codec*)dev->platform_data;
-	int reg, ret = 0;
+	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..d9a4f0e 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,53 @@ 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 - testing"
 	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.
 
-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-C1x00 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..ee5eafb 100644
--- a/sound/soc/pxa/Makefile
+++ b/sound/soc/pxa/Makefile
@@ -5,34 +5,39 @@ 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
+snd-soc-spitz-objs := spitz.o
+snd-soc-mainstone-wm8753-objs := mainstone_wm8753.o
 
 obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-pxa2xx.o
 
-ifeq ($(CONFIG_SND_PXA2xx_SOC_AC97),y)
+ifneq ($(CONFIG_SND_PXA2xx_SOC_AC97),n)
 obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-pxa2xx-ac97.o
 endif
 
-ifeq ($(CONFIG_SND_PXA2xx_SOC_I2S),y)
+ifneq ($(CONFIG_SND_PXA2xx_SOC_I2S),n)
 obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-pxa2xx-i2s.o
 endif
 
-ifeq ($(CONFIG_SND_PXA2xx_SOC_SSP),y)
+ifneq ($(CONFIG_SND_PXA2xx_SOC_SSP),n)
 obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-pxa2xx-ssp.o
 endif
 
-ifeq ($(CONFIG_SND_PXA2xx_SOC_MAINSTONE),y)
+ifneq ($(CONFIG_SND_PXA2xx_SOC_MAINSTONE),n)
 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
+ifneq ($(CONFIG_SND_PXA2xx_SOC_MAINSTONE_WM8753),n)
+obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-mainstone-wm8753.o
 endif
 
-ifeq ($(CONFIG_SND_PXA2xx_SOC_TOSA),y)
+ifneq ($(CONFIG_SND_PXA2xx_SOC_TOSA),n)
 obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-tosa.o
 endif
 
-ifeq ($(CONFIG_SND_PXA2xx_SOC_CORGI),y)
+ifneq ($(CONFIG_SND_PXA2xx_SOC_CORGI),n)
 obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-corgi.o
+endif
+
+ifneq ($(CONFIG_SND_PXA2xx_SOC_SPITZ),n)
+obj-$(CONFIG_SND_PXA2xx_SOC) += snd-soc-spitz.o
 endif
\ No newline at end of file
diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c
index 4ceb65a..75eb086 100644
--- a/sound/soc/pxa/corgi.c
+++ b/sound/soc/pxa/corgi.c
@@ -24,16 +24,22 @@
 #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/spitz.h>
+
+
 #include <asm/arch/audio.h>
 
 #include "../codecs/wm8731.h"
@@ -55,344 +61,185 @@
 #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 struct timer_list corgi_hp_timer;
 
-static int corgi_startup(snd_pcm_substream_t *substream)
+static irqreturn_t corgi_hp_isr(int irq, void *dev_id, struct pt_regs *fp)
 {
-	return 0;
-}
+	/* Delay the event slightly to debounce */
+	mod_timer(&corgi_hp_timer, jiffies + msecs_to_jiffies(500));
 
-static void corgi_shutdown(snd_pcm_substream_t *substream)
-{
+	return IRQ_HANDLED;
 }
 
-/* corgi pcm ops */
-static struct snd_soc_ops corgi_ops = {
-	.startup = corgi_startup,
-	.shutdown = corgi_shutdown,
-};
+#define READ_GPIO_BIT(x)    (GPLR(x) & GPIO_bit(x))
 
-static int corgi_suspend(struct device* dev, pm_message_t state)
+static void corgi_hp_event(unsigned long 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);
 
-static int corgi_resume(struct device* dev)
-{
-	return 0;
+	corgikbd_report_hp(hp_status);
+	
+	/* FIXME - Richard can you check, this will change dpm status */
+	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_probe(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;
 }
 
-static int corgi_remove(struct device* dev)
+int corgi_put_snd_scoop(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
-	return 0;
-}
-
-#ifdef TODO
-
-/*
- * need to change this for corgi 
- */
+	unsigned short reg = kcontrol->private_value;
 
-/* example external dpm event callback */
-int external_amp_event(struct snd_soc_codec *codec, int event)
-{
+	if (ucontrol->value.integer.value[0])
+		set_scoop_gpio(&corgiscoop_device.dev, reg);
+	else
+		reset_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),
 };
 
-int corgi_get_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
-{
-	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
-	int mask = kcontrol->private_value;
-	
-	//ucontrol->value.integer.value[0] = corgi do something
-}
-
-int corgi_put_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
-{
-	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
-	int mask = kcontrol->private_value;
-	int val;
-	
-	val = (ucontrol->value.integer.value[0] & mask);
-	
-	/* do something with val */
-}
-
 /* 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"},
-	{"Mic Bias", NULL, "Mic1 Jack"},
+	{"MICIN", NULL, "Mic Bias"},
+	{"LLINEIN", NULL, "Mic Bias"},
 	{"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),
-	SOC_SINGLE_EXT("corgi bark switch", 1, corgi_get_volsw, corgi_put_volsw);
+static const snd_kcontrol_new_t wm8731_corgi_controls[] = {
+	SOC_SINGLE_BOOL_EXT("Left Mute Switch", CORGI_SCP_MUTE_L, 1, corgi_get_snd_scoop, corgi_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Right Mute Switch", CORGI_SCP_MUTE_R, 1, corgi_get_snd_scoop, corgi_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Speaker Mute Switch", CORGI_SCP_APM_ON, 1, corgi_get_snd_scoop, corgi_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Mic Bias Switch", CORGI_SCP_MIC_BIAS, 1, 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]);
 	}
 	
+	corgi_hp_timer.data = (unsigned long)codec;
 	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) 
-		return -ENOMEM;
-	
-	if((ret = snd_soc_register_machine(&corgi)) < 0) {
-		printk(KERN_ERR "can't register corgi soc audio\n");
+	pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN);
+	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");
 		return ret;
 	}
+	set_irq_type(CORGI_IRQ_GPIO_AK_INT, IRQT_BOTHEDGE);
 
-	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);
+	init_timer(&corgi_hp_timer);
+	corgi_hp_timer.function = corgi_hp_event;
+
+	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;
 	}
-	
-	corgi_i2c_init();
+
+	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);
+	del_timer_sync(&corgi_hp_timer);
+	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..8161842
--- /dev/null
+++ b/sound/soc/pxa/mainstone_wm8753.c
@@ -0,0 +1,217 @@
+/*
+ * 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;
+	
+	/* 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..cdef349 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -80,7 +80,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 +119,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 +198,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 +237,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,14 +267,14 @@ 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;
-
+printk("%s %d\n", __FUNCTION__, __LINE__);
 	ret = request_irq(IRQ_AC97, pxa2xx_ac97_irq, 0, "AC97", NULL);
 	if (ret < 0)
 		goto err;
-
+printk("%s %d\n", __FUNCTION__, __LINE__);
 	pxa_gpio_mode(GPIO31_SYNC_AC97_MD);
 	pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);
 	pxa_gpio_mode(GPIO28_BITCLK_AC97_MD);
@@ -287,7 +285,7 @@ static int pxa2xx_ac97_probe(struct devi
 #endif
 	pxa_set_cken(CKEN2_AC97, 1);
 	return 0;
-
+printk("%s %d\n", __FUNCTION__, __LINE__);
  err:
 	if (CKEN & CKEN2_AC97) {
 		GCR |= GCR_ACLINK_OFF;
@@ -297,7 +295,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 +305,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 +317,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;
@@ -366,7 +364,7 @@ struct snd_soc_pcm_interface pxa_ac97_in
 };
 
 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..35d059a 100644
--- a/sound/soc/pxa/pxa2xx-i2s.c
+++ b/sound/soc/pxa/pxa2xx-i2s.c
@@ -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;
 }
 
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..865f92d 100644
--- a/sound/soc/pxa/pxa2xx-ssp.c
+++ b/sound/soc/pxa/pxa2xx-ssp.c
@@ -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;
 }
 
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
new file mode 100644
index 0000000..9e0c929
--- /dev/null
+++ b/sound/soc/pxa/spitz.c
@@ -0,0 +1,251 @@
+/*
+ * spitz.c  --  SoC audio for Spitz
+ *
+ * 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
+ *    5th Dec 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/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/corgi.h>
+#include <asm/arch/spitz.h>
+
+
+#include <asm/arch/audio.h>
+
+#include "../codecs/wm8750.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)
+
+static struct timer_list corgi_hp_timer;
+
+static irqreturn_t corgi_hp_isr(int irq, void *dev_id, struct pt_regs *fp)
+{
+	/* Delay the event slightly to debounce */
+	mod_timer(&corgi_hp_timer, jiffies + msecs_to_jiffies(500));
+
+	return IRQ_HANDLED;
+}
+
+#define READ_GPIO_BIT(x)    (GPLR(x) & GPIO_bit(x))
+
+static void corgi_hp_event(unsigned long data)
+{
+	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);
+	
+	/* FIXME - Richard can you check, this will change dpm status */
+	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);
+}
+
+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;
+}
+
+int corgi_put_snd_scoop(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	unsigned short reg = kcontrol->private_value;
+
+	if (ucontrol->value.integer.value[0])
+		set_scoop_gpio(&corgiscoop_device.dev, reg);
+	else
+		reset_scoop_gpio(&corgiscoop_device.dev, reg);
+	return 0;
+}
+
+/* corgi 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, "LHPOUT"},
+	{"Headphone Jack", NULL, "RHPOUT"},
+	
+	/* ext speaker connected to LOUT2, ROUT2 via amp */
+	{"Ext Amp", NULL, "ROUT"},
+	{"Ext Amp", NULL, "LOUT"},
+	
+	/* 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_corgi_controls[] = {
+	SOC_SINGLE_BOOL_EXT("Left Mute Switch", CORGI_SCP_MUTE_L, 1, corgi_get_snd_scoop, corgi_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Right Mute Switch", CORGI_SCP_MUTE_R, 1, corgi_get_snd_scoop, corgi_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Speaker Mute Switch", CORGI_SCP_APM_ON, 1, corgi_get_snd_scoop, corgi_put_snd_scoop),
+	SOC_SINGLE_BOOL_EXT("Mic Bias Switch", CORGI_SCP_MIC_BIAS, 1, corgi_get_snd_scoop, corgi_put_snd_scoop),
+};
+
+/*
+ * Logic for a wm8750 as connected on a Sharp SL-C1x00 Device
+ */
+static int corgi_wm8750_init(struct snd_soc_codec *codec)
+{
+	int i, err;
+
+	codec->longname = "Corgi Audio Codec";
+	snd_soc_dpm_set_connection(codec, "RLINEIN", 0);
+
+	/* Add corgi specific controls */
+	for (i = 0; i < ARRAY_SIZE(wm8750_corgi_controls); i++) {
+		if ((err = snd_ctl_add(codec->card, snd_soc_cnew(&wm8750_corgi_controls[i],codec, NULL))) < 0)
+			return err;
+	}
+
+	/* Add corgi specific widgets */
+	for(i = 0; i < ARRAY_SIZE(wm8750_dpm_widgets); i++) {
+		snd_soc_dpm_new_control(codec, &wm8750_dpm_widgets[i]);
+	}
+	
+	/* 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]);
+	}
+	
+	corgi_hp_timer.data = (unsigned long)codec;
+	snd_soc_dpm_sync(codec);
+	return 0;
+}
+
+static struct snd_soc_machine_config codecs = {
+	.name = "WM8750", 
+	.sname = "WM8750",
+	.iface = &pxa_i2s_interface,
+	.init = corgi_wm8750_init,
+};
+
+static struct snd_soc_machine snd_soc_machine_corgi = {
+	.name = "Corgi",
+	.config = &codecs,
+	.nconfigs = 1,
+};
+
+static struct wm8750_setup_data corgi_wm8750_setup = {
+	.i2c_address = 0x1b,
+};
+
+static struct snd_soc_device corgi_snd_devdata = {
+	.machine = &snd_soc_machine_corgi,
+	.platform = &pxa2xx_soc_platform,
+	.codec_dev = &soc_codec_dev_wm8750,
+	.codec_data = &corgi_wm8750_setup,
+};
+
+static struct platform_device *corgi_snd_device;
+
+static int __init corgi_init(void) 
+{
+	int ret;
+
+	pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN);
+	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");
+		return ret;
+	}
+	set_irq_type(CORGI_IRQ_GPIO_AK_INT, IRQT_BOTHEDGE);
+
+	init_timer(&corgi_hp_timer);
+	corgi_hp_timer.function = corgi_hp_event;
+
+	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;
+	}
+
+	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) 
+{
+	free_irq(CORGI_IRQ_GPIO_AK_INT, corgi_snd_device);
+	del_timer_sync(&corgi_hp_timer);
+	platform_device_unregister(corgi_snd_device);
+}
+
+module_init(corgi_init);
+module_exit(corgi_exit);
+
+/* Module information */ 
+MODULE_AUTHOR("Richard Purdie");
+MODULE_DESCRIPTION("ALSA SoC Corgi");
+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 22e6af0..31325e7 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -45,8 +45,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)
 {
@@ -106,18 +104,17 @@ 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;
 			}
 		}
@@ -126,20 +123,20 @@ static int soc_hw_params(snd_pcm_substre
 	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;
@@ -150,52 +147,53 @@ static int soc_hw_params(snd_pcm_substre
  */
 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;
 	int ret = 0;
 
 	/* 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.rates = rtd->pcm_c->playback.rates & rtd->pcm_i->playback.rates;
+		runtime->hw.formats = rtd->pcm_c->playback.formats & rtd->pcm_i->playback.formats;
+		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.rates = rtd->pcm_c->capture.rates & rtd->pcm_i->capture.rates;
+		runtime->hw.formats = rtd->pcm_c->capture.formats & rtd->pcm_i->capture.formats;
+		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;
 		}
 	}
@@ -214,19 +212,19 @@ static int soc_pcm_open(snd_pcm_substrea
 		}
 	}
 
-	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)
@@ -237,8 +235,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 +244,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)
 		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 +268,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 +290,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 +316,53 @@ 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)
+	if(rtd->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_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);
 	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;
-
+	codec->dpm_state = SNDRV_CTL_POWER_D0;//liam
 	return ret;
 	
 platform_err:
@@ -376,12 +370,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 +383,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,14 +404,14 @@ 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);
 	
-	codec->dpm_state = SNDRV_CTL_POWER_D3hot;
+	codec->dpm_state = SNDRV_CTL_POWER_D3hot;//liam
 	return 0;
 }
 
@@ -431,7 +424,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 +456,81 @@ 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);
+	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);
+	}
+	
+	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);
 	}
-	dev->driver_data = NULL;
-	if(machine->suspend)
-		machine->suspend(dev, state);
+	
+	codec->suspend_dpm_state = codec->dpm_state;
+	codec->suspend_streams = codec->active_streams;
+	codec->active_streams = 0;
+	if (codec_dev->suspend)
+		codec_dev->suspend(pdev, state);
+
+	if (machine->suspend)
+		machine->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;
 	
-	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);
+	if (machine->resume)
+		machine->resume(pdev);
+
+	if (codec_dev->resume)
+		codec_dev->resume(pdev);
+
+	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_D1);
+		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;
 
 	return 0;
 }
@@ -511,115 +540,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(platform->probe && ((ret = platform->probe(dev)) < 0))
+	if (codec_dev->probe && ((ret = codec_dev->probe(pdev)) < 0))
+		goto codec_err;
+
+	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 +645,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 +659,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 +687,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 +699,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);
 }
@@ -829,6 +852,15 @@ int snd_soc_info_volsw_ext(snd_kcontrol_
 	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)
 {
@@ -899,16 +931,28 @@ EXPORT_SYMBOL_GPL(snd_soc_get_enum_doubl
 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..6a023ee 100644
--- a/sound/soc/soc-dpm.c
+++ b/sound/soc/soc-dpm.c
@@ -636,11 +636,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 +868,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:
@@ -930,7 +941,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 +950,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 +959,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;
 		}
 	}
 	
diff --git a/include/sound/soc.h b/include/sound/soc.h
index babfcf0..07721f4 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.9rc1"
 
 /*
  * 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, \
@@ -47,10 +48,14 @@
 { .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, xmask, xhandler_get, xhandler_put) \
+#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 =  mask }
+  .private_value =  SOC_SINGLE_VALUE_EXT(xreg, xmask, xinvert) }
+#define SOC_SINGLE_BOOL_EXT(xname, xreg, xinvert, 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 =  SOC_SINGLE_VALUE_EXT(xreg, 0, xinvert) }
 #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, \
@@ -111,6 +116,7 @@
 #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;
@@ -118,23 +124,19 @@ 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 struct bus_type soc_bus_type; /* FIXME - remove me */
+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, 
@@ -159,6 +161,7 @@ int snd_soc_get_enum_double(snd_kcontrol
 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);
 	
@@ -214,8 +217,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;
@@ -230,10 +232,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;
@@ -241,12 +244,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 */
@@ -265,12 +267,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 */
@@ -280,6 +282,7 @@ struct snd_soc_codec {
 	hw_read_t hw_read;
 	void *reg_cache;
 	
+	/* dpm */
 	struct list_head dpm_widgets;
 	struct list_head dpm_paths;
 	
@@ -287,21 +290,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 */
@@ -319,17 +326,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/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
