* [PATCH] Stop AIC23 driver from Oopsing.
@ 2008-03-29 17:00 Andrzej Zaborowski
2008-04-02 7:09 ` Tony Lindgren
0 siblings, 1 reply; 5+ messages in thread
From: Andrzej Zaborowski @ 2008-03-29 17:00 UTC (permalink / raw)
To: linux-omap
From: Andrzej Zaborowski <balrog@zabor.org>
Prevent AIC23 driver Oopsing when no AIC23 is present by moving some of the
initialisation to after the chip is found. There seems to be more that
should be fixed in this driver but with this change it can at least be
compiled into a kernel safely.
Signed-off-by: Andrzej Zaborowski <balrog@zabor.org>
---
drivers/i2c/chips/tlv320aic23.c | 92 ++++++++++++++++++++------------------
1 files changed, 48 insertions(+), 44 deletions(-)
diff --git a/drivers/i2c/chips/tlv320aic23.c b/drivers/i2c/chips/tlv320aic23.c
index c1e27f1..1c498f2 100644
--- a/drivers/i2c/chips/tlv320aic23.c
+++ b/drivers/i2c/chips/tlv320aic23.c
@@ -54,6 +54,7 @@ I2C_CLIENT_INSMOD;
static struct i2c_driver aic23_driver;
static struct i2c_client *new_client;
static int selftest;
+static struct platform_device audio_i2c_device;
static struct aic23_info {
u16 volume_reg_left;
@@ -95,6 +96,38 @@ int aic23_write_value(u8 reg, u16 value)
return 0;
}
+/*
+ * Configures the McBSP3 which is used to send clock to the AIC23 codec.
+ * The input clock rate from DSP is 12MHz.
+ * The DSP clock must be on before this is called.
+ */
+static int omap_mcbsp3_aic23_clock_init(void)
+{
+ u16 w;
+
+ /* enable 12MHz clock to mcbsp 1 & 3 */
+ __raw_writew(__raw_readw(DSP_IDLECT2) | (1<<1), DSP_IDLECT2);
+ __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1<<1, DSP_RSTCT2);
+
+ /* disable sample rate generator */
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR1, 0x0000);
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, 0x0000);
+
+ /* pin control register */
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, PCR0,(CLKXM | CLKXP | CLKRP));
+
+ /* configure srg to send 12MHz pulse from dsp peripheral clock */
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR1, 0x0000);
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR2, CLKSM);
+
+ /* enable sample rate generator */
+ w = OMAP_MCBSP_READ(OMAP1610_MCBSP3_BASE, SPCR2);
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, (w | FREE | GRST));
+ printk("Clock enabled to MCBSP1 & 3 \n");
+
+ return 0;
+}
+
static int aic23_detect_client(struct i2c_adapter *adapter, int address,
int kind)
{
@@ -128,6 +161,19 @@ static int aic23_detect_client(struct i2c_adapter *adapter, int address,
kfree(new_client);
return err;
}
+
+ if (platform_device_register(&audio_i2c_device)) {
+ printk(KERN_WARNING "Failed to register audio i2c device\n");
+ selftest = -ENODEV;
+ return selftest;
+ }
+ /* FIXME: Do in board-specific file */
+ omap_mcbsp3_aic23_clock_init();
+
+ if (!aic23_info_l.power_down)
+ aic23_power_up();
+ aic23_info_l.initialized = 1;
+
return 0;
}
@@ -135,6 +181,8 @@ static int aic23_detach_client(struct i2c_client *client)
{
int err;
+ platform_device_unregister(&audio_i2c_device);
+
if ((err = i2c_detach_client(client))) {
printk("aic23.o: Client deregistration failed, \
client not detached.\n");
@@ -162,38 +210,6 @@ static struct i2c_driver aic23_driver = {
.detach_client = aic23_detach_client,
};
-/*
- * Configures the McBSP3 which is used to send clock to the AIC23 codec.
- * The input clock rate from DSP is 12MHz.
- * The DSP clock must be on before this is called.
- */
-static int omap_mcbsp3_aic23_clock_init(void)
-{
- u16 w;
-
- /* enable 12MHz clock to mcbsp 1 & 3 */
- __raw_writew(__raw_readw(DSP_IDLECT2) | (1<<1), DSP_IDLECT2);
- __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1<<1, DSP_RSTCT2);
-
- /* disable sample rate generator */
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR1, 0x0000);
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, 0x0000);
-
- /* pin control register */
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, PCR0,(CLKXM | CLKXP | CLKRP));
-
- /* configure srg to send 12MHz pulse from dsp peripheral clock */
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR1, 0x0000);
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR2, CLKSM);
-
- /* enable sample rate generator */
- w = OMAP_MCBSP_READ(OMAP1610_MCBSP3_BASE, SPCR2);
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, (w | FREE | GRST));
- printk("Clock enabled to MCBSP1 & 3 \n");
-
- return 0;
-}
-
static void update_volume_left(int volume)
{
u16 val = 0;
@@ -633,17 +649,6 @@ static int __init aic23_init(void)
return selftest;
}
- if (platform_device_register(&audio_i2c_device)) {
- printk(KERN_WARNING "Failed to register audio i2c device\n");
- platform_driver_unregister(&audio_i2c_driver);
- selftest = -ENODEV;
- return selftest;
- }
- /* FIXME: Do in board-specific file */
- omap_mcbsp3_aic23_clock_init();
- if (!aic23_info_l.power_down)
- aic23_power_up();
- aic23_info_l.initialized = 1;
printk("TLV320AIC23 I2C version %s (%s)\n",
TLV320AIC23_VERSION, TLV320AIC23_DATE);
@@ -658,7 +663,6 @@ static void __exit aic23_exit(void)
if ((res = i2c_del_driver(&aic23_driver)))
printk("aic23 i2c: Driver remove failed, module not removed.\n");
- platform_device_unregister(&audio_i2c_device);
platform_driver_unregister(&audio_i2c_driver);
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Stop AIC23 driver from Oopsing.
2008-03-29 17:00 Andrzej Zaborowski
@ 2008-04-02 7:09 ` Tony Lindgren
2008-04-03 23:54 ` andrzej zaborowski
0 siblings, 1 reply; 5+ messages in thread
From: Tony Lindgren @ 2008-04-02 7:09 UTC (permalink / raw)
To: Andrzej Zaborowski; +Cc: linux-omap
* Andrzej Zaborowski <balrogg@gmail.com> [080329 18:30]:
> From: Andrzej Zaborowski <balrog@zabor.org>
>
> Prevent AIC23 driver Oopsing when no AIC23 is present by moving some of the
> initialisation to after the chip is found. There seems to be more that
> should be fixed in this driver but with this change it can at least be
> compiled into a kernel safely.
This does not seem to apply, can you please check?
Regards,
Tony
>
> Signed-off-by: Andrzej Zaborowski <balrog@zabor.org>
> ---
> drivers/i2c/chips/tlv320aic23.c | 92 ++++++++++++++++++++------------------
> 1 files changed, 48 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/i2c/chips/tlv320aic23.c b/drivers/i2c/chips/tlv320aic23.c
> index c1e27f1..1c498f2 100644
> --- a/drivers/i2c/chips/tlv320aic23.c
> +++ b/drivers/i2c/chips/tlv320aic23.c
> @@ -54,6 +54,7 @@ I2C_CLIENT_INSMOD;
> static struct i2c_driver aic23_driver;
> static struct i2c_client *new_client;
> static int selftest;
> +static struct platform_device audio_i2c_device;
>
> static struct aic23_info {
> u16 volume_reg_left;
> @@ -95,6 +96,38 @@ int aic23_write_value(u8 reg, u16 value)
> return 0;
> }
>
> +/*
> + * Configures the McBSP3 which is used to send clock to the AIC23 codec.
> + * The input clock rate from DSP is 12MHz.
> + * The DSP clock must be on before this is called.
> + */
> +static int omap_mcbsp3_aic23_clock_init(void)
> +{
> + u16 w;
> +
> + /* enable 12MHz clock to mcbsp 1 & 3 */
> + __raw_writew(__raw_readw(DSP_IDLECT2) | (1<<1), DSP_IDLECT2);
> + __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1<<1, DSP_RSTCT2);
> +
> + /* disable sample rate generator */
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR1, 0x0000);
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, 0x0000);
> +
> + /* pin control register */
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, PCR0,(CLKXM | CLKXP | CLKRP));
> +
> + /* configure srg to send 12MHz pulse from dsp peripheral clock */
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR1, 0x0000);
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR2, CLKSM);
> +
> + /* enable sample rate generator */
> + w = OMAP_MCBSP_READ(OMAP1610_MCBSP3_BASE, SPCR2);
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, (w | FREE | GRST));
> + printk("Clock enabled to MCBSP1 & 3 \n");
> +
> + return 0;
> +}
> +
> static int aic23_detect_client(struct i2c_adapter *adapter, int address,
> int kind)
> {
> @@ -128,6 +161,19 @@ static int aic23_detect_client(struct i2c_adapter *adapter, int address,
> kfree(new_client);
> return err;
> }
> +
> + if (platform_device_register(&audio_i2c_device)) {
> + printk(KERN_WARNING "Failed to register audio i2c device\n");
> + selftest = -ENODEV;
> + return selftest;
> + }
> + /* FIXME: Do in board-specific file */
> + omap_mcbsp3_aic23_clock_init();
> +
> + if (!aic23_info_l.power_down)
> + aic23_power_up();
> + aic23_info_l.initialized = 1;
> +
> return 0;
> }
>
> @@ -135,6 +181,8 @@ static int aic23_detach_client(struct i2c_client *client)
> {
> int err;
>
> + platform_device_unregister(&audio_i2c_device);
> +
> if ((err = i2c_detach_client(client))) {
> printk("aic23.o: Client deregistration failed, \
> client not detached.\n");
> @@ -162,38 +210,6 @@ static struct i2c_driver aic23_driver = {
> .detach_client = aic23_detach_client,
> };
>
> -/*
> - * Configures the McBSP3 which is used to send clock to the AIC23 codec.
> - * The input clock rate from DSP is 12MHz.
> - * The DSP clock must be on before this is called.
> - */
> -static int omap_mcbsp3_aic23_clock_init(void)
> -{
> - u16 w;
> -
> - /* enable 12MHz clock to mcbsp 1 & 3 */
> - __raw_writew(__raw_readw(DSP_IDLECT2) | (1<<1), DSP_IDLECT2);
> - __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1<<1, DSP_RSTCT2);
> -
> - /* disable sample rate generator */
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR1, 0x0000);
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, 0x0000);
> -
> - /* pin control register */
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, PCR0,(CLKXM | CLKXP | CLKRP));
> -
> - /* configure srg to send 12MHz pulse from dsp peripheral clock */
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR1, 0x0000);
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR2, CLKSM);
> -
> - /* enable sample rate generator */
> - w = OMAP_MCBSP_READ(OMAP1610_MCBSP3_BASE, SPCR2);
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, (w | FREE | GRST));
> - printk("Clock enabled to MCBSP1 & 3 \n");
> -
> - return 0;
> -}
> -
> static void update_volume_left(int volume)
> {
> u16 val = 0;
> @@ -633,17 +649,6 @@ static int __init aic23_init(void)
> return selftest;
> }
>
> - if (platform_device_register(&audio_i2c_device)) {
> - printk(KERN_WARNING "Failed to register audio i2c device\n");
> - platform_driver_unregister(&audio_i2c_driver);
> - selftest = -ENODEV;
> - return selftest;
> - }
> - /* FIXME: Do in board-specific file */
> - omap_mcbsp3_aic23_clock_init();
> - if (!aic23_info_l.power_down)
> - aic23_power_up();
> - aic23_info_l.initialized = 1;
> printk("TLV320AIC23 I2C version %s (%s)\n",
> TLV320AIC23_VERSION, TLV320AIC23_DATE);
>
> @@ -658,7 +663,6 @@ static void __exit aic23_exit(void)
> if ((res = i2c_del_driver(&aic23_driver)))
> printk("aic23 i2c: Driver remove failed, module not removed.\n");
>
> - platform_device_unregister(&audio_i2c_device);
> platform_driver_unregister(&audio_i2c_driver);
> }
>
> --
> 1.5.3.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Stop AIC23 driver from Oopsing.
2008-04-02 7:09 ` Tony Lindgren
@ 2008-04-03 23:54 ` andrzej zaborowski
0 siblings, 0 replies; 5+ messages in thread
From: andrzej zaborowski @ 2008-04-03 23:54 UTC (permalink / raw)
To: Tony Lindgren; +Cc: linux-omap
On 02/04/2008, Tony Lindgren <tony@atomide.com> wrote:
> * Andrzej Zaborowski <balrogg@gmail.com> [080329 18:30]:
>
> > From: Andrzej Zaborowski <balrog@zabor.org>
> >
> > Prevent AIC23 driver Oopsing when no AIC23 is present by moving some of the
> > initialisation to after the chip is found. There seems to be more that
> > should be fixed in this driver but with this change it can at least be
> > compiled into a kernel safely.
>
>
> This does not seem to apply, can you please check?
Oops, I had forgotten to update. Now rebased and resent, with an
additional typo corrected in one of the error messages.
--
Please do not print this email unless absolutely necessary. Spread
environmental awareness.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Stop AIC23 driver from Oopsing.
@ 2008-04-04 0:56 Andrzej Zaborowski
2008-04-04 9:32 ` Tony Lindgren
0 siblings, 1 reply; 5+ messages in thread
From: Andrzej Zaborowski @ 2008-04-04 0:56 UTC (permalink / raw)
To: linux-omap
From: Andrzej Zaborowski <balrog@zabor.org>
Prevent AIC23 driver Oopsing when no AIC23 is present by moving some of the
initialisation to after the chip is found. There seems to be more that
should be fixed in this driver but with this change it can at least be
compiled into a kernel safely.
Signed-off-by: Andrzej Zaborowski <balrog@zabor.org>
---
drivers/i2c/chips/tlv320aic23.c | 94 ++++++++++++++++++++------------------
1 files changed, 49 insertions(+), 45 deletions(-)
diff --git a/drivers/i2c/chips/tlv320aic23.c b/drivers/i2c/chips/tlv320aic23.c
index a2ec4bc..544cc28 100644
--- a/drivers/i2c/chips/tlv320aic23.c
+++ b/drivers/i2c/chips/tlv320aic23.c
@@ -54,6 +54,7 @@ I2C_CLIENT_INSMOD;
static struct i2c_driver aic23_driver;
static struct i2c_client *new_client;
static int selftest;
+static struct platform_device audio_i2c_device;
static struct aic23_info {
u16 volume_reg_left;
@@ -95,6 +96,38 @@ int aic23_write_value(u8 reg, u16 value)
return 0;
}
+/*
+ * Configures the McBSP3 which is used to send clock to the AIC23 codec.
+ * The input clock rate from DSP is 12MHz.
+ * The DSP clock must be on before this is called.
+ */
+static int omap_mcbsp3_aic23_clock_init(void)
+{
+ u16 w;
+
+ /* enable 12MHz clock to mcbsp 1 & 3 */
+ __raw_writew(__raw_readw(DSP_IDLECT2) | (1<<1), DSP_IDLECT2);
+ __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1<<1, DSP_RSTCT2);
+
+ /* disable sample rate generator */
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR1, 0x0000);
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, 0x0000);
+
+ /* pin control register */
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, PCR0,(CLKXM | CLKXP | CLKRP));
+
+ /* configure srg to send 12MHz pulse from dsp peripheral clock */
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR1, 0x0000);
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR2, CLKSM);
+
+ /* enable sample rate generator */
+ w = OMAP_MCBSP_READ(OMAP1610_MCBSP3_BASE, SPCR2);
+ OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, (w | FREE | GRST));
+ printk("Clock enabled to MCBSP1 & 3 \n");
+
+ return 0;
+}
+
static int aic23_detect_client(struct i2c_adapter *adapter, int address,
int kind)
{
@@ -103,7 +136,7 @@ static int aic23_detect_client(struct i2c_adapter *adapter, int address,
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA |
I2C_FUNC_SMBUS_WRITE_BYTE)) {
- printk(KERN_WARNING "%s functinality check failed\n",
+ printk(KERN_WARNING "%s functionality check failed\n",
client_name);
return err;
}
@@ -128,6 +161,19 @@ static int aic23_detect_client(struct i2c_adapter *adapter, int address,
kfree(new_client);
return err;
}
+
+ if (platform_device_register(&audio_i2c_device)) {
+ printk(KERN_WARNING "Failed to register audio i2c device\n");
+ selftest = -ENODEV;
+ return selftest;
+ }
+ /* FIXME: Do in board-specific file */
+ omap_mcbsp3_aic23_clock_init();
+
+ if (!aic23_info_l.power_down)
+ aic23_power_up();
+ aic23_info_l.initialized = 1;
+
return 0;
}
@@ -135,6 +181,8 @@ static int aic23_detach_client(struct i2c_client *client)
{
int err;
+ platform_device_unregister(&audio_i2c_device);
+
if ((err = i2c_detach_client(client))) {
printk("aic23.o: Client deregistration failed, \
client not detached.\n");
@@ -162,38 +210,6 @@ static struct i2c_driver aic23_driver = {
.detach_client = aic23_detach_client,
};
-/*
- * Configures the McBSP3 which is used to send clock to the AIC23 codec.
- * The input clock rate from DSP is 12MHz.
- * The DSP clock must be on before this is called.
- */
-static int omap_mcbsp3_aic23_clock_init(void)
-{
- u16 w;
-
- /* enable 12MHz clock to mcbsp 1 & 3 */
- __raw_writew(__raw_readw(DSP_IDLECT2) | (1<<1), DSP_IDLECT2);
- __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1<<1, DSP_RSTCT2);
-
- /* disable sample rate generator */
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR1, 0x0000);
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, 0x0000);
-
- /* pin control register */
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, PCR0,(CLKXM | CLKXP | CLKRP));
-
- /* configure srg to send 12MHz pulse from dsp peripheral clock */
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR1, 0x0000);
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR2, CLKSM);
-
- /* enable sample rate generator */
- w = OMAP_MCBSP_READ(OMAP1610_MCBSP3_BASE, SPCR2);
- OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, (w | FREE | GRST));
- printk("Clock enabled to MCBSP1 & 3 \n");
-
- return 0;
-}
-
static void update_volume_left(int volume)
{
u16 val = 0;
@@ -633,17 +649,6 @@ static int __init aic23_init(void)
return selftest;
}
- if (platform_device_register(&audio_i2c_device)) {
- printk(KERN_WARNING "Failed to register audio i2c device\n");
- platform_driver_unregister(&audio_i2c_driver);
- selftest = -ENODEV;
- return selftest;
- }
- /* FIXME: Do in board-specific file */
- omap_mcbsp3_aic23_clock_init();
- if (!aic23_info_l.power_down)
- aic23_power_up();
- aic23_info_l.initialized = 1;
printk("TLV320AIC23 I2C version %s (%s)\n",
TLV320AIC23_VERSION, TLV320AIC23_DATE);
@@ -655,7 +660,6 @@ static void __exit aic23_exit(void)
aic23_power_down();
i2c_del_driver(&aic23_driver);
- platform_device_unregister(&audio_i2c_device);
platform_driver_unregister(&audio_i2c_driver);
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Stop AIC23 driver from Oopsing.
2008-04-04 0:56 [PATCH] Stop AIC23 driver from Oopsing Andrzej Zaborowski
@ 2008-04-04 9:32 ` Tony Lindgren
0 siblings, 0 replies; 5+ messages in thread
From: Tony Lindgren @ 2008-04-04 9:32 UTC (permalink / raw)
To: Andrzej Zaborowski; +Cc: linux-omap
* Andrzej Zaborowski <balrogg@gmail.com> [080404 02:53]:
> From: Andrzej Zaborowski <balrog@zabor.org>
>
> Prevent AIC23 driver Oopsing when no AIC23 is present by moving some of the
> initialisation to after the chip is found. There seems to be more that
> should be fixed in this driver but with this change it can at least be
> compiled into a kernel safely.
Thanks, pushing today.
Tony
> Signed-off-by: Andrzej Zaborowski <balrog@zabor.org>
> ---
> drivers/i2c/chips/tlv320aic23.c | 94 ++++++++++++++++++++------------------
> 1 files changed, 49 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/i2c/chips/tlv320aic23.c b/drivers/i2c/chips/tlv320aic23.c
> index a2ec4bc..544cc28 100644
> --- a/drivers/i2c/chips/tlv320aic23.c
> +++ b/drivers/i2c/chips/tlv320aic23.c
> @@ -54,6 +54,7 @@ I2C_CLIENT_INSMOD;
> static struct i2c_driver aic23_driver;
> static struct i2c_client *new_client;
> static int selftest;
> +static struct platform_device audio_i2c_device;
>
> static struct aic23_info {
> u16 volume_reg_left;
> @@ -95,6 +96,38 @@ int aic23_write_value(u8 reg, u16 value)
> return 0;
> }
>
> +/*
> + * Configures the McBSP3 which is used to send clock to the AIC23 codec.
> + * The input clock rate from DSP is 12MHz.
> + * The DSP clock must be on before this is called.
> + */
> +static int omap_mcbsp3_aic23_clock_init(void)
> +{
> + u16 w;
> +
> + /* enable 12MHz clock to mcbsp 1 & 3 */
> + __raw_writew(__raw_readw(DSP_IDLECT2) | (1<<1), DSP_IDLECT2);
> + __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1<<1, DSP_RSTCT2);
> +
> + /* disable sample rate generator */
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR1, 0x0000);
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, 0x0000);
> +
> + /* pin control register */
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, PCR0,(CLKXM | CLKXP | CLKRP));
> +
> + /* configure srg to send 12MHz pulse from dsp peripheral clock */
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR1, 0x0000);
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR2, CLKSM);
> +
> + /* enable sample rate generator */
> + w = OMAP_MCBSP_READ(OMAP1610_MCBSP3_BASE, SPCR2);
> + OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, (w | FREE | GRST));
> + printk("Clock enabled to MCBSP1 & 3 \n");
> +
> + return 0;
> +}
> +
> static int aic23_detect_client(struct i2c_adapter *adapter, int address,
> int kind)
> {
> @@ -103,7 +136,7 @@ static int aic23_detect_client(struct i2c_adapter *adapter, int address,
>
> if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA |
> I2C_FUNC_SMBUS_WRITE_BYTE)) {
> - printk(KERN_WARNING "%s functinality check failed\n",
> + printk(KERN_WARNING "%s functionality check failed\n",
> client_name);
> return err;
> }
> @@ -128,6 +161,19 @@ static int aic23_detect_client(struct i2c_adapter *adapter, int address,
> kfree(new_client);
> return err;
> }
> +
> + if (platform_device_register(&audio_i2c_device)) {
> + printk(KERN_WARNING "Failed to register audio i2c device\n");
> + selftest = -ENODEV;
> + return selftest;
> + }
> + /* FIXME: Do in board-specific file */
> + omap_mcbsp3_aic23_clock_init();
> +
> + if (!aic23_info_l.power_down)
> + aic23_power_up();
> + aic23_info_l.initialized = 1;
> +
> return 0;
> }
>
> @@ -135,6 +181,8 @@ static int aic23_detach_client(struct i2c_client *client)
> {
> int err;
>
> + platform_device_unregister(&audio_i2c_device);
> +
> if ((err = i2c_detach_client(client))) {
> printk("aic23.o: Client deregistration failed, \
> client not detached.\n");
> @@ -162,38 +210,6 @@ static struct i2c_driver aic23_driver = {
> .detach_client = aic23_detach_client,
> };
>
> -/*
> - * Configures the McBSP3 which is used to send clock to the AIC23 codec.
> - * The input clock rate from DSP is 12MHz.
> - * The DSP clock must be on before this is called.
> - */
> -static int omap_mcbsp3_aic23_clock_init(void)
> -{
> - u16 w;
> -
> - /* enable 12MHz clock to mcbsp 1 & 3 */
> - __raw_writew(__raw_readw(DSP_IDLECT2) | (1<<1), DSP_IDLECT2);
> - __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1<<1, DSP_RSTCT2);
> -
> - /* disable sample rate generator */
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR1, 0x0000);
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, 0x0000);
> -
> - /* pin control register */
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, PCR0,(CLKXM | CLKXP | CLKRP));
> -
> - /* configure srg to send 12MHz pulse from dsp peripheral clock */
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR1, 0x0000);
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR2, CLKSM);
> -
> - /* enable sample rate generator */
> - w = OMAP_MCBSP_READ(OMAP1610_MCBSP3_BASE, SPCR2);
> - OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, (w | FREE | GRST));
> - printk("Clock enabled to MCBSP1 & 3 \n");
> -
> - return 0;
> -}
> -
> static void update_volume_left(int volume)
> {
> u16 val = 0;
> @@ -633,17 +649,6 @@ static int __init aic23_init(void)
> return selftest;
> }
>
> - if (platform_device_register(&audio_i2c_device)) {
> - printk(KERN_WARNING "Failed to register audio i2c device\n");
> - platform_driver_unregister(&audio_i2c_driver);
> - selftest = -ENODEV;
> - return selftest;
> - }
> - /* FIXME: Do in board-specific file */
> - omap_mcbsp3_aic23_clock_init();
> - if (!aic23_info_l.power_down)
> - aic23_power_up();
> - aic23_info_l.initialized = 1;
> printk("TLV320AIC23 I2C version %s (%s)\n",
> TLV320AIC23_VERSION, TLV320AIC23_DATE);
>
> @@ -655,7 +660,6 @@ static void __exit aic23_exit(void)
> aic23_power_down();
> i2c_del_driver(&aic23_driver);
>
> - platform_device_unregister(&audio_i2c_device);
> platform_driver_unregister(&audio_i2c_driver);
> }
>
> --
> 1.5.3.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-04-04 9:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-04 0:56 [PATCH] Stop AIC23 driver from Oopsing Andrzej Zaborowski
2008-04-04 9:32 ` Tony Lindgren
-- strict thread matches above, loose matches on Subject: below --
2008-03-29 17:00 Andrzej Zaborowski
2008-04-02 7:09 ` Tony Lindgren
2008-04-03 23:54 ` andrzej zaborowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox