Commit 1abd9184 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mark Brown

ASoC: UDA1380: refactor device registration

This patch mostly follows commit 5998102b
"ASoC: Refactor WM8731 device registration" to make UDA1380 use standard
device instantiation. Similarly, the I2C device registration temporarily
moves into the magician machine driver before it will find its final
resting place in the board file.

At the same time, platform specific configuration is moved to platform data
and common power/reset GPIO handling moves into the codec driver.
Signed-off-by: default avatarPhilipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent b3b50b3f
/*
* UDA1380 ALSA SoC Codec driver
*
* Copyright 2009 Philipp Zabel
*
* 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 __UDA1380_H
#define __UDA1380_H
struct uda1380_platform_data {
int gpio_power;
int gpio_reset;
int dac_clk;
#define UDA1380_DAC_CLK_SYSCLK 0
#define UDA1380_DAC_CLK_WSPLL 1
};
#endif /* __UDA1380_H */
This diff is collapsed.
...@@ -72,14 +72,6 @@ ...@@ -72,14 +72,6 @@
#define R22_SKIP_DCFIL 0x0002 #define R22_SKIP_DCFIL 0x0002
#define R23_AGC_EN 0x0001 #define R23_AGC_EN 0x0001
struct uda1380_setup_data {
int i2c_bus;
unsigned short i2c_address;
int dac_clk;
#define UDA1380_DAC_CLK_SYSCLK 0
#define UDA1380_DAC_CLK_WSPLL 1
};
#define UDA1380_DAI_DUPLEX 0 /* playback and capture on single DAI */ #define UDA1380_DAI_DUPLEX 0 /* playback and capture on single DAI */
#define UDA1380_DAI_PLAYBACK 1 /* playback DAI */ #define UDA1380_DAI_PLAYBACK 1 /* playback DAI */
#define UDA1380_DAI_CAPTURE 2 /* capture DAI */ #define UDA1380_DAI_CAPTURE 2 /* capture DAI */
......
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/i2c.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include <sound/uda1380.h>
#include <mach/magician.h> #include <mach/magician.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
...@@ -447,34 +449,47 @@ static struct snd_soc_card snd_soc_card_magician = { ...@@ -447,34 +449,47 @@ static struct snd_soc_card snd_soc_card_magician = {
.platform = &pxa2xx_soc_platform, .platform = &pxa2xx_soc_platform,
}; };
/* magician audio private data */
static struct uda1380_setup_data magician_uda1380_setup = {
.i2c_address = 0x18,
.dac_clk = UDA1380_DAC_CLK_WSPLL,
};
/* magician audio subsystem */ /* magician audio subsystem */
static struct snd_soc_device magician_snd_devdata = { static struct snd_soc_device magician_snd_devdata = {
.card = &snd_soc_card_magician, .card = &snd_soc_card_magician,
.codec_dev = &soc_codec_dev_uda1380, .codec_dev = &soc_codec_dev_uda1380,
.codec_data = &magician_uda1380_setup,
}; };
static struct platform_device *magician_snd_device; static struct platform_device *magician_snd_device;
/*
* FIXME: move into magician board file once merged into the pxa tree
*/
static struct uda1380_platform_data uda1380_info = {
.gpio_power = EGPIO_MAGICIAN_CODEC_POWER,
.gpio_reset = EGPIO_MAGICIAN_CODEC_RESET,
.dac_clk = UDA1380_DAC_CLK_WSPLL,
};
static struct i2c_board_info i2c_board_info[] = {
{
I2C_BOARD_INFO("uda1380", 0x18),
.platform_data = &uda1380_info,
},
};
static int __init magician_init(void) static int __init magician_init(void)
{ {
int ret; int ret;
struct i2c_adapter *adapter;
struct i2c_client *client;
if (!machine_is_magician()) if (!machine_is_magician())
return -ENODEV; return -ENODEV;
ret = gpio_request(EGPIO_MAGICIAN_CODEC_POWER, "CODEC_POWER"); adapter = i2c_get_adapter(0);
if (ret) if (!adapter)
goto err_request_power; return -ENODEV;
ret = gpio_request(EGPIO_MAGICIAN_CODEC_RESET, "CODEC_RESET"); client = i2c_new_device(adapter, i2c_board_info);
if (ret) i2c_put_adapter(adapter);
goto err_request_reset; if (!client)
return -ENODEV;
ret = gpio_request(EGPIO_MAGICIAN_SPK_POWER, "SPK_POWER"); ret = gpio_request(EGPIO_MAGICIAN_SPK_POWER, "SPK_POWER");
if (ret) if (ret)
goto err_request_spk; goto err_request_spk;
...@@ -491,14 +506,8 @@ static int __init magician_init(void) ...@@ -491,14 +506,8 @@ static int __init magician_init(void)
if (ret) if (ret)
goto err_request_in_sel1; goto err_request_in_sel1;
gpio_set_value(EGPIO_MAGICIAN_CODEC_POWER, 1);
gpio_set_value(EGPIO_MAGICIAN_IN_SEL0, 0); gpio_set_value(EGPIO_MAGICIAN_IN_SEL0, 0);
/* we may need to have the clock running here - pH5 */
gpio_set_value(EGPIO_MAGICIAN_CODEC_RESET, 1);
udelay(5);
gpio_set_value(EGPIO_MAGICIAN_CODEC_RESET, 0);
magician_snd_device = platform_device_alloc("soc-audio", -1); magician_snd_device = platform_device_alloc("soc-audio", -1);
if (!magician_snd_device) { if (!magician_snd_device) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -526,10 +535,6 @@ static int __init magician_init(void) ...@@ -526,10 +535,6 @@ static int __init magician_init(void)
err_request_ep: err_request_ep:
gpio_free(EGPIO_MAGICIAN_SPK_POWER); gpio_free(EGPIO_MAGICIAN_SPK_POWER);
err_request_spk: err_request_spk:
gpio_free(EGPIO_MAGICIAN_CODEC_RESET);
err_request_reset:
gpio_free(EGPIO_MAGICIAN_CODEC_POWER);
err_request_power:
return ret; return ret;
} }
...@@ -540,15 +545,12 @@ static void __exit magician_exit(void) ...@@ -540,15 +545,12 @@ static void __exit magician_exit(void)
gpio_set_value(EGPIO_MAGICIAN_SPK_POWER, 0); gpio_set_value(EGPIO_MAGICIAN_SPK_POWER, 0);
gpio_set_value(EGPIO_MAGICIAN_EP_POWER, 0); gpio_set_value(EGPIO_MAGICIAN_EP_POWER, 0);
gpio_set_value(EGPIO_MAGICIAN_MIC_POWER, 0); gpio_set_value(EGPIO_MAGICIAN_MIC_POWER, 0);
gpio_set_value(EGPIO_MAGICIAN_CODEC_POWER, 0);
gpio_free(EGPIO_MAGICIAN_IN_SEL1); gpio_free(EGPIO_MAGICIAN_IN_SEL1);
gpio_free(EGPIO_MAGICIAN_IN_SEL0); gpio_free(EGPIO_MAGICIAN_IN_SEL0);
gpio_free(EGPIO_MAGICIAN_MIC_POWER); gpio_free(EGPIO_MAGICIAN_MIC_POWER);
gpio_free(EGPIO_MAGICIAN_EP_POWER); gpio_free(EGPIO_MAGICIAN_EP_POWER);
gpio_free(EGPIO_MAGICIAN_SPK_POWER); gpio_free(EGPIO_MAGICIAN_SPK_POWER);
gpio_free(EGPIO_MAGICIAN_CODEC_RESET);
gpio_free(EGPIO_MAGICIAN_CODEC_POWER);
} }
module_init(magician_init); module_init(magician_init);
......
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