From patchwork Mon Nov 2 12:34:53 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 57010 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA2CbmHP027883 for ; Mon, 2 Nov 2009 12:37:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754986AbZKBMfa (ORCPT ); Mon, 2 Nov 2009 07:35:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754725AbZKBMf2 (ORCPT ); Mon, 2 Nov 2009 07:35:28 -0500 Received: from smtp.nokia.com ([192.100.105.134]:41331 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754956AbZKBMfZ (ORCPT ); Mon, 2 Nov 2009 07:35:25 -0500 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nA2CZ0n6032503; Mon, 2 Nov 2009 06:35:25 -0600 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 2 Nov 2009 14:35:00 +0200 Received: from mgw-sa01.ext.nokia.com ([147.243.1.47]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 2 Nov 2009 14:34:59 +0200 Received: from localhost.localdomain (cseresznye.ntc.nokia.com [172.22.144.108]) by mgw-sa01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nA2CYsXj031194; Mon, 2 Nov 2009 14:34:58 +0200 From: Peter Ujfalusi To: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, sameo@linux.intel.com Cc: linux-kernel@vger.kernel.org, tony@atomide.com, broonie@opensource.wolfsonmicro.com Subject: [PATCH 3/5] MFD: twl4030-codec: APLL_INFREQ handling in the MFD driver Date: Mon, 2 Nov 2009 14:34:53 +0200 Message-Id: <1257165295-9352-4-git-send-email-peter.ujfalusi@nokia.com> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1257165295-9352-3-git-send-email-peter.ujfalusi@nokia.com> References: <1257165295-9352-1-git-send-email-peter.ujfalusi@nokia.com> <1257165295-9352-2-git-send-email-peter.ujfalusi@nokia.com> <1257165295-9352-3-git-send-email-peter.ujfalusi@nokia.com> X-OriginalArrivalTime: 02 Nov 2009 12:34:59.0983 (UTC) FILETIME=[E489D9F0:01CA5BB8] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/drivers/mfd/twl4030-codec.c b/drivers/mfd/twl4030-codec.c index 9710307..6e77f57 100644 --- a/drivers/mfd/twl4030-codec.c +++ b/drivers/mfd/twl4030-codec.c @@ -41,6 +41,7 @@ struct twl4030_codec_resource { }; struct twl4030_codec { + unsigned int audio_mclk; struct mutex mutex; struct twl4030_codec_resource resource[TWL4030_CODEC_RES_MAX]; struct mfd_cell cells[TWL4030_CODEC_CELLS]; @@ -145,12 +146,32 @@ int twl4030_codec_disable_resource(unsigned id) } EXPORT_SYMBOL_GPL(twl4030_codec_disable_resource); +unsigned int twl4030_codec_get_mclk(void) +{ + struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev); + + return codec->audio_mclk; +} +EXPORT_SYMBOL_GPL(twl4030_codec_get_mclk); + static int __devinit twl4030_codec_probe(struct platform_device *pdev) { struct twl4030_codec *codec; struct twl4030_codec_data *pdata = pdev->dev.platform_data; struct mfd_cell *cell = NULL; int ret, childs = 0; + u8 val; + + if (!pdata) { + dev_err(&pdev->dev, "Platform data is missing\n"); + return -EINVAL; + } + if (!(pdata->audio_mclk == 19200000 || + pdata->audio_mclk == 26000000 || + pdata->audio_mclk == 38400000)) { + dev_err(&pdev->dev, "Invalid audio_mclk\n"); + return -EINVAL; + } codec = kzalloc(sizeof(struct twl4030_codec), GFP_KERNEL); if (!codec) @@ -160,6 +181,25 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev) twl4030_codec_dev = pdev; mutex_init(&codec->mutex); + codec->audio_mclk = pdata->audio_mclk; + + /* Configure APLL_INFREQ */ + twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val, + TWL4030_REG_APLL_CTL); + val &= ~TWL4030_APLL_INFREQ; + switch (codec->audio_mclk) { + case 19200000: + val |= TWL4030_APLL_INFREQ_19200KHZ; + break; + case 26000000: + val |= TWL4030_APLL_INFREQ_26000KHZ; + break; + case 38400000: + val |= TWL4030_APLL_INFREQ_38400KHZ; + break; + } + twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, + val, TWL4030_REG_APLL_CTL); /* Codec power */ codec->resource[TWL4030_CODEC_RES_POWER].reg = TWL4030_REG_CODEC_MODE; diff --git a/include/linux/mfd/twl4030-codec.h b/include/linux/mfd/twl4030-codec.h index ef0a304..2ec317c 100644 --- a/include/linux/mfd/twl4030-codec.h +++ b/include/linux/mfd/twl4030-codec.h @@ -267,5 +267,6 @@ enum twl4030_codec_res { int twl4030_codec_disable_resource(enum twl4030_codec_res id); int twl4030_codec_enable_resource(enum twl4030_codec_res id); +unsigned int twl4030_codec_get_mclk(void); #endif /* End of __TWL4030_CODEC_H__ */