Commit b5311eed authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: wm0010: replace codec to component

Now we can replace Codec to Component. Let's do it.

Note:
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 1	->	.idle_bias_on = 0
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7928b2cb
...@@ -90,7 +90,7 @@ enum wm0010_state { ...@@ -90,7 +90,7 @@ enum wm0010_state {
}; };
struct wm0010_priv { struct wm0010_priv {
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct mutex lock; struct mutex lock;
struct device *dev; struct device *dev;
...@@ -157,9 +157,9 @@ static const char *wm0010_state_to_str(enum wm0010_state state) ...@@ -157,9 +157,9 @@ static const char *wm0010_state_to_str(enum wm0010_state state)
} }
/* Called with wm0010->lock held */ /* Called with wm0010->lock held */
static void wm0010_halt(struct snd_soc_codec *codec) static void wm0010_halt(struct snd_soc_component *component)
{ {
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
unsigned long flags; unsigned long flags;
enum wm0010_state state; enum wm0010_state state;
...@@ -193,7 +193,7 @@ static void wm0010_halt(struct snd_soc_codec *codec) ...@@ -193,7 +193,7 @@ static void wm0010_halt(struct snd_soc_codec *codec)
struct wm0010_boot_xfer { struct wm0010_boot_xfer {
struct list_head list; struct list_head list;
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct completion *done; struct completion *done;
struct spi_message m; struct spi_message m;
struct spi_transfer t; struct spi_transfer t;
...@@ -218,13 +218,13 @@ static void wm0010_mark_boot_failure(struct wm0010_priv *wm0010) ...@@ -218,13 +218,13 @@ static void wm0010_mark_boot_failure(struct wm0010_priv *wm0010)
static void wm0010_boot_xfer_complete(void *data) static void wm0010_boot_xfer_complete(void *data)
{ {
struct wm0010_boot_xfer *xfer = data; struct wm0010_boot_xfer *xfer = data;
struct snd_soc_codec *codec = xfer->codec; struct snd_soc_component *component = xfer->component;
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
u32 *out32 = xfer->t.rx_buf; u32 *out32 = xfer->t.rx_buf;
int i; int i;
if (xfer->m.status != 0) { if (xfer->m.status != 0) {
dev_err(codec->dev, "SPI transfer failed: %d\n", dev_err(component->dev, "SPI transfer failed: %d\n",
xfer->m.status); xfer->m.status);
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
if (xfer->done) if (xfer->done)
...@@ -233,11 +233,11 @@ static void wm0010_boot_xfer_complete(void *data) ...@@ -233,11 +233,11 @@ static void wm0010_boot_xfer_complete(void *data)
} }
for (i = 0; i < xfer->t.len / 4; i++) { for (i = 0; i < xfer->t.len / 4; i++) {
dev_dbg(codec->dev, "%d: %04x\n", i, out32[i]); dev_dbg(component->dev, "%d: %04x\n", i, out32[i]);
switch (be32_to_cpu(out32[i])) { switch (be32_to_cpu(out32[i])) {
case 0xe0e0e0e0: case 0xe0e0e0e0:
dev_err(codec->dev, dev_err(component->dev,
"%d: ROM error reported in stage 2\n", i); "%d: ROM error reported in stage 2\n", i);
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
...@@ -245,82 +245,82 @@ static void wm0010_boot_xfer_complete(void *data) ...@@ -245,82 +245,82 @@ static void wm0010_boot_xfer_complete(void *data)
case 0x55555555: case 0x55555555:
if (wm0010->state < WM0010_STAGE2) if (wm0010->state < WM0010_STAGE2)
break; break;
dev_err(codec->dev, dev_err(component->dev,
"%d: ROM bootloader running in stage 2\n", i); "%d: ROM bootloader running in stage 2\n", i);
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
case 0x0fed0000: case 0x0fed0000:
dev_dbg(codec->dev, "Stage2 loader running\n"); dev_dbg(component->dev, "Stage2 loader running\n");
break; break;
case 0x0fed0007: case 0x0fed0007:
dev_dbg(codec->dev, "CODE_HDR packet received\n"); dev_dbg(component->dev, "CODE_HDR packet received\n");
break; break;
case 0x0fed0008: case 0x0fed0008:
dev_dbg(codec->dev, "CODE_DATA packet received\n"); dev_dbg(component->dev, "CODE_DATA packet received\n");
break; break;
case 0x0fed0009: case 0x0fed0009:
dev_dbg(codec->dev, "Download complete\n"); dev_dbg(component->dev, "Download complete\n");
break; break;
case 0x0fed000c: case 0x0fed000c:
dev_dbg(codec->dev, "Application start\n"); dev_dbg(component->dev, "Application start\n");
break; break;
case 0x0fed000e: case 0x0fed000e:
dev_dbg(codec->dev, "PLL packet received\n"); dev_dbg(component->dev, "PLL packet received\n");
wm0010->pll_running = true; wm0010->pll_running = true;
break; break;
case 0x0fed0025: case 0x0fed0025:
dev_err(codec->dev, "Device reports image too long\n"); dev_err(component->dev, "Device reports image too long\n");
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
case 0x0fed002c: case 0x0fed002c:
dev_err(codec->dev, "Device reports bad SPI packet\n"); dev_err(component->dev, "Device reports bad SPI packet\n");
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
case 0x0fed0031: case 0x0fed0031:
dev_err(codec->dev, "Device reports SPI read overflow\n"); dev_err(component->dev, "Device reports SPI read overflow\n");
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
case 0x0fed0032: case 0x0fed0032:
dev_err(codec->dev, "Device reports SPI underclock\n"); dev_err(component->dev, "Device reports SPI underclock\n");
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
case 0x0fed0033: case 0x0fed0033:
dev_err(codec->dev, "Device reports bad header packet\n"); dev_err(component->dev, "Device reports bad header packet\n");
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
case 0x0fed0034: case 0x0fed0034:
dev_err(codec->dev, "Device reports invalid packet type\n"); dev_err(component->dev, "Device reports invalid packet type\n");
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
case 0x0fed0035: case 0x0fed0035:
dev_err(codec->dev, "Device reports data before header error\n"); dev_err(component->dev, "Device reports data before header error\n");
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
case 0x0fed0038: case 0x0fed0038:
dev_err(codec->dev, "Device reports invalid PLL packet\n"); dev_err(component->dev, "Device reports invalid PLL packet\n");
break; break;
case 0x0fed003a: case 0x0fed003a:
dev_err(codec->dev, "Device reports packet alignment error\n"); dev_err(component->dev, "Device reports packet alignment error\n");
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
default: default:
dev_err(codec->dev, "Unrecognised return 0x%x\n", dev_err(component->dev, "Unrecognised return 0x%x\n",
be32_to_cpu(out32[i])); be32_to_cpu(out32[i]));
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
break; break;
...@@ -342,10 +342,10 @@ static void byte_swap_64(u64 *data_in, u64 *data_out, u32 len) ...@@ -342,10 +342,10 @@ static void byte_swap_64(u64 *data_in, u64 *data_out, u32 len)
data_out[i] = cpu_to_be64(le64_to_cpu(data_in[i])); data_out[i] = cpu_to_be64(le64_to_cpu(data_in[i]));
} }
static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) static int wm0010_firmware_load(const char *name, struct snd_soc_component *component)
{ {
struct spi_device *spi = to_spi_device(codec->dev); struct spi_device *spi = to_spi_device(component->dev);
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
struct list_head xfer_list; struct list_head xfer_list;
struct wm0010_boot_xfer *xfer; struct wm0010_boot_xfer *xfer;
int ret; int ret;
...@@ -359,9 +359,9 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) ...@@ -359,9 +359,9 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
INIT_LIST_HEAD(&xfer_list); INIT_LIST_HEAD(&xfer_list);
ret = request_firmware(&fw, name, codec->dev); ret = request_firmware(&fw, name, component->dev);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to request application(%s): %d\n", dev_err(component->dev, "Failed to request application(%s): %d\n",
name, ret); name, ret);
return ret; return ret;
} }
...@@ -377,25 +377,25 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) ...@@ -377,25 +377,25 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
/* First record should be INFO */ /* First record should be INFO */
if (rec->command != DFW_CMD_INFO) { if (rec->command != DFW_CMD_INFO) {
dev_err(codec->dev, "First record not INFO\r\n"); dev_err(component->dev, "First record not INFO\r\n");
ret = -EINVAL; ret = -EINVAL;
goto abort; goto abort;
} }
if (inforec->info_version != INFO_VERSION) { if (inforec->info_version != INFO_VERSION) {
dev_err(codec->dev, dev_err(component->dev,
"Unsupported version (%02d) of INFO record\r\n", "Unsupported version (%02d) of INFO record\r\n",
inforec->info_version); inforec->info_version);
ret = -EINVAL; ret = -EINVAL;
goto abort; goto abort;
} }
dev_dbg(codec->dev, "Version v%02d INFO record found\r\n", dev_dbg(component->dev, "Version v%02d INFO record found\r\n",
inforec->info_version); inforec->info_version);
/* Check it's a DSP file */ /* Check it's a DSP file */
if (dsp != DEVICE_ID_WM0010) { if (dsp != DEVICE_ID_WM0010) {
dev_err(codec->dev, "Not a WM0010 firmware file.\r\n"); dev_err(component->dev, "Not a WM0010 firmware file.\r\n");
ret = -EINVAL; ret = -EINVAL;
goto abort; goto abort;
} }
...@@ -405,7 +405,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) ...@@ -405,7 +405,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
rec = (void *)&rec->data[rec->length]; rec = (void *)&rec->data[rec->length];
while (offset < fw->size) { while (offset < fw->size) {
dev_dbg(codec->dev, dev_dbg(component->dev,
"Packet: command %d, data length = 0x%x\r\n", "Packet: command %d, data length = 0x%x\r\n",
rec->command, rec->length); rec->command, rec->length);
len = rec->length + 8; len = rec->length + 8;
...@@ -416,7 +416,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) ...@@ -416,7 +416,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
goto abort; goto abort;
} }
xfer->codec = codec; xfer->component = component;
list_add_tail(&xfer->list, &xfer_list); list_add_tail(&xfer->list, &xfer_list);
out = kzalloc(len, GFP_KERNEL | GFP_DMA); out = kzalloc(len, GFP_KERNEL | GFP_DMA);
...@@ -460,18 +460,18 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) ...@@ -460,18 +460,18 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
rec = (void *)&rec->data[rec->length]; rec = (void *)&rec->data[rec->length];
if (offset >= fw->size) { if (offset >= fw->size) {
dev_dbg(codec->dev, "All transfers scheduled\n"); dev_dbg(component->dev, "All transfers scheduled\n");
xfer->done = &done; xfer->done = &done;
} }
ret = spi_async(spi, &xfer->m); ret = spi_async(spi, &xfer->m);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Write failed: %d\n", ret); dev_err(component->dev, "Write failed: %d\n", ret);
goto abort1; goto abort1;
} }
if (wm0010->boot_failed) { if (wm0010->boot_failed) {
dev_dbg(codec->dev, "Boot fail!\n"); dev_dbg(component->dev, "Boot fail!\n");
ret = -EINVAL; ret = -EINVAL;
goto abort1; goto abort1;
} }
...@@ -496,10 +496,10 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) ...@@ -496,10 +496,10 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
return ret; return ret;
} }
static int wm0010_stage2_load(struct snd_soc_codec *codec) static int wm0010_stage2_load(struct snd_soc_component *component)
{ {
struct spi_device *spi = to_spi_device(codec->dev); struct spi_device *spi = to_spi_device(component->dev);
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
const struct firmware *fw; const struct firmware *fw;
struct spi_message m; struct spi_message m;
struct spi_transfer t; struct spi_transfer t;
...@@ -508,14 +508,14 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) ...@@ -508,14 +508,14 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec)
int i; int i;
int ret = 0; int ret = 0;
ret = request_firmware(&fw, "wm0010_stage2.bin", codec->dev); ret = request_firmware(&fw, "wm0010_stage2.bin", component->dev);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to request stage2 loader: %d\n", dev_err(component->dev, "Failed to request stage2 loader: %d\n",
ret); ret);
return ret; return ret;
} }
dev_dbg(codec->dev, "Downloading %zu byte stage 2 loader\n", fw->size); dev_dbg(component->dev, "Downloading %zu byte stage 2 loader\n", fw->size);
/* Copy to local buffer first as vmalloc causes problems for dma */ /* Copy to local buffer first as vmalloc causes problems for dma */
img = kzalloc(fw->size, GFP_KERNEL | GFP_DMA); img = kzalloc(fw->size, GFP_KERNEL | GFP_DMA);
...@@ -541,19 +541,19 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) ...@@ -541,19 +541,19 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec)
t.speed_hz = wm0010->sysclk / 10; t.speed_hz = wm0010->sysclk / 10;
spi_message_add_tail(&t, &m); spi_message_add_tail(&t, &m);
dev_dbg(codec->dev, "Starting initial download at %dHz\n", dev_dbg(component->dev, "Starting initial download at %dHz\n",
t.speed_hz); t.speed_hz);
ret = spi_sync(spi, &m); ret = spi_sync(spi, &m);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Initial download failed: %d\n", ret); dev_err(component->dev, "Initial download failed: %d\n", ret);
goto abort; goto abort;
} }
/* Look for errors from the boot ROM */ /* Look for errors from the boot ROM */
for (i = 0; i < fw->size; i++) { for (i = 0; i < fw->size; i++) {
if (out[i] != 0x55) { if (out[i] != 0x55) {
dev_err(codec->dev, "Boot ROM error: %x in %d\n", dev_err(component->dev, "Boot ROM error: %x in %d\n",
out[i], i); out[i], i);
wm0010_mark_boot_failure(wm0010); wm0010_mark_boot_failure(wm0010);
ret = -EBUSY; ret = -EBUSY;
...@@ -570,10 +570,10 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) ...@@ -570,10 +570,10 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec)
return ret; return ret;
} }
static int wm0010_boot(struct snd_soc_codec *codec) static int wm0010_boot(struct snd_soc_component *component)
{ {
struct spi_device *spi = to_spi_device(codec->dev); struct spi_device *spi = to_spi_device(component->dev);
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
unsigned long flags; unsigned long flags;
int ret; int ret;
struct spi_message m; struct spi_message m;
...@@ -590,7 +590,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) ...@@ -590,7 +590,7 @@ static int wm0010_boot(struct snd_soc_codec *codec)
spin_unlock_irqrestore(&wm0010->irq_lock, flags); spin_unlock_irqrestore(&wm0010->irq_lock, flags);
if (wm0010->sysclk > 26000000) { if (wm0010->sysclk > 26000000) {
dev_err(codec->dev, "Max DSP clock frequency is 26MHz\n"); dev_err(component->dev, "Max DSP clock frequency is 26MHz\n");
ret = -ECANCELED; ret = -ECANCELED;
goto err; goto err;
} }
...@@ -598,7 +598,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) ...@@ -598,7 +598,7 @@ static int wm0010_boot(struct snd_soc_codec *codec)
mutex_lock(&wm0010->lock); mutex_lock(&wm0010->lock);
wm0010->pll_running = false; wm0010->pll_running = false;
dev_dbg(codec->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq); dev_dbg(component->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq);
ret = regulator_bulk_enable(ARRAY_SIZE(wm0010->core_supplies), ret = regulator_bulk_enable(ARRAY_SIZE(wm0010->core_supplies),
wm0010->core_supplies); wm0010->core_supplies);
...@@ -623,19 +623,19 @@ static int wm0010_boot(struct snd_soc_codec *codec) ...@@ -623,19 +623,19 @@ static int wm0010_boot(struct snd_soc_codec *codec)
if (!wait_for_completion_timeout(&wm0010->boot_completion, if (!wait_for_completion_timeout(&wm0010->boot_completion,
msecs_to_jiffies(20))) msecs_to_jiffies(20)))
dev_err(codec->dev, "Failed to get interrupt from DSP\n"); dev_err(component->dev, "Failed to get interrupt from DSP\n");
spin_lock_irqsave(&wm0010->irq_lock, flags); spin_lock_irqsave(&wm0010->irq_lock, flags);
wm0010->state = WM0010_BOOTROM; wm0010->state = WM0010_BOOTROM;
spin_unlock_irqrestore(&wm0010->irq_lock, flags); spin_unlock_irqrestore(&wm0010->irq_lock, flags);
ret = wm0010_stage2_load(codec); ret = wm0010_stage2_load(component);
if (ret) if (ret)
goto abort; goto abort;
if (!wait_for_completion_timeout(&wm0010->boot_completion, if (!wait_for_completion_timeout(&wm0010->boot_completion,
msecs_to_jiffies(20))) msecs_to_jiffies(20)))
dev_err(codec->dev, "Failed to get interrupt from DSP loader.\n"); dev_err(component->dev, "Failed to get interrupt from DSP loader.\n");
spin_lock_irqsave(&wm0010->irq_lock, flags); spin_lock_irqsave(&wm0010->irq_lock, flags);
wm0010->state = WM0010_STAGE2; wm0010->state = WM0010_STAGE2;
...@@ -676,14 +676,14 @@ static int wm0010_boot(struct snd_soc_codec *codec) ...@@ -676,14 +676,14 @@ static int wm0010_boot(struct snd_soc_codec *codec)
ret = spi_sync(spi, &m); ret = spi_sync(spi, &m);
if (ret) { if (ret) {
dev_err(codec->dev, "First PLL write failed: %d\n", ret); dev_err(component->dev, "First PLL write failed: %d\n", ret);
goto abort_swap; goto abort_swap;
} }
/* Use a second send of the message to get the return status */ /* Use a second send of the message to get the return status */
ret = spi_sync(spi, &m); ret = spi_sync(spi, &m);
if (ret) { if (ret) {
dev_err(codec->dev, "Second PLL write failed: %d\n", ret); dev_err(component->dev, "Second PLL write failed: %d\n", ret);
goto abort_swap; goto abort_swap;
} }
...@@ -692,7 +692,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) ...@@ -692,7 +692,7 @@ static int wm0010_boot(struct snd_soc_codec *codec)
/* Look for PLL active code from the DSP */ /* Look for PLL active code from the DSP */
for (i = 0; i < len / 4; i++) { for (i = 0; i < len / 4; i++) {
if (*p == 0x0e00ed0f) { if (*p == 0x0e00ed0f) {
dev_dbg(codec->dev, "PLL packet received\n"); dev_dbg(component->dev, "PLL packet received\n");
wm0010->pll_running = true; wm0010->pll_running = true;
break; break;
} }
...@@ -702,9 +702,9 @@ static int wm0010_boot(struct snd_soc_codec *codec) ...@@ -702,9 +702,9 @@ static int wm0010_boot(struct snd_soc_codec *codec)
kfree(img_swap); kfree(img_swap);
kfree(out); kfree(out);
} else } else
dev_dbg(codec->dev, "Not enabling DSP PLL."); dev_dbg(component->dev, "Not enabling DSP PLL.");
ret = wm0010_firmware_load("wm0010.dfw", codec); ret = wm0010_firmware_load("wm0010.dfw", component);
if (ret != 0) if (ret != 0)
goto abort; goto abort;
...@@ -723,7 +723,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) ...@@ -723,7 +723,7 @@ static int wm0010_boot(struct snd_soc_codec *codec)
kfree(out); kfree(out);
abort: abort:
/* Put the chip back into reset */ /* Put the chip back into reset */
wm0010_halt(codec); wm0010_halt(component);
mutex_unlock(&wm0010->lock); mutex_unlock(&wm0010->lock);
return ret; return ret;
...@@ -735,22 +735,22 @@ static int wm0010_boot(struct snd_soc_codec *codec) ...@@ -735,22 +735,22 @@ static int wm0010_boot(struct snd_soc_codec *codec)
return ret; return ret;
} }
static int wm0010_set_bias_level(struct snd_soc_codec *codec, static int wm0010_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE)
wm0010_boot(codec); wm0010_boot(component);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) {
mutex_lock(&wm0010->lock); mutex_lock(&wm0010->lock);
wm0010_halt(codec); wm0010_halt(component);
mutex_unlock(&wm0010->lock); mutex_unlock(&wm0010->lock);
} }
break; break;
...@@ -761,10 +761,10 @@ static int wm0010_set_bias_level(struct snd_soc_codec *codec, ...@@ -761,10 +761,10 @@ static int wm0010_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source, static int wm0010_set_sysclk(struct snd_soc_component *component, int source,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
unsigned int i; unsigned int i;
wm0010->sysclk = freq; wm0010->sysclk = freq;
...@@ -783,20 +783,19 @@ static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source, ...@@ -783,20 +783,19 @@ static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source,
return 0; return 0;
} }
static int wm0010_probe(struct snd_soc_codec *codec); static int wm0010_probe(struct snd_soc_component *component);
static const struct snd_soc_codec_driver soc_codec_dev_wm0010 = { static const struct snd_soc_component_driver soc_component_dev_wm0010 = {
.probe = wm0010_probe, .probe = wm0010_probe,
.set_bias_level = wm0010_set_bias_level, .set_bias_level = wm0010_set_bias_level,
.set_sysclk = wm0010_set_sysclk, .set_sysclk = wm0010_set_sysclk,
.idle_bias_off = true,
.component_driver = {
.dapm_widgets = wm0010_dapm_widgets, .dapm_widgets = wm0010_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm0010_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(wm0010_dapm_widgets),
.dapm_routes = wm0010_dapm_routes, .dapm_routes = wm0010_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(wm0010_dapm_routes), .num_dapm_routes = ARRAY_SIZE(wm0010_dapm_routes),
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
#define WM0010_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) #define WM0010_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
...@@ -860,11 +859,11 @@ static irqreturn_t wm0010_irq(int irq, void *data) ...@@ -860,11 +859,11 @@ static irqreturn_t wm0010_irq(int irq, void *data)
return IRQ_NONE; return IRQ_NONE;
} }
static int wm0010_probe(struct snd_soc_codec *codec) static int wm0010_probe(struct snd_soc_component *component)
{ {
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
wm0010->codec = codec; wm0010->component = component;
return 0; return 0;
} }
...@@ -967,8 +966,8 @@ static int wm0010_spi_probe(struct spi_device *spi) ...@@ -967,8 +966,8 @@ static int wm0010_spi_probe(struct spi_device *spi)
else else
wm0010->board_max_spi_speed = 0; wm0010->board_max_spi_speed = 0;
ret = snd_soc_register_codec(&spi->dev, ret = devm_snd_soc_register_component(&spi->dev,
&soc_codec_dev_wm0010, wm0010_dai, &soc_component_dev_wm0010, wm0010_dai,
ARRAY_SIZE(wm0010_dai)); ARRAY_SIZE(wm0010_dai));
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -980,8 +979,6 @@ static int wm0010_spi_remove(struct spi_device *spi) ...@@ -980,8 +979,6 @@ static int wm0010_spi_remove(struct spi_device *spi)
{ {
struct wm0010_priv *wm0010 = spi_get_drvdata(spi); struct wm0010_priv *wm0010 = spi_get_drvdata(spi);
snd_soc_unregister_codec(&spi->dev);
gpio_set_value_cansleep(wm0010->gpio_reset, gpio_set_value_cansleep(wm0010->gpio_reset,
wm0010->gpio_reset_value); wm0010->gpio_reset_value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment