From patchwork Fri Feb 11 15:56:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 549861 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1BFuis8017507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 11 Feb 2011 15:57:05 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.74) (envelope-from ) id 1PnvMR-0005nl-2O; Fri, 11 Feb 2011 15:56:43 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.74) (envelope-from ) id 1PnvMP-0005nZ-UZ for spi-devel-general@lists.sourceforge.net; Fri, 11 Feb 2011 15:56:41 +0000 X-ACL-Warn: Received: from moutng.kundenserver.de ([212.227.17.9]) by sog-mx-3.v43.ch3.sourceforge.com with esmtp (Exim 4.74) id 1PnvMO-0003O5-D1 for spi-devel-general@lists.sourceforge.net; Fri, 11 Feb 2011 15:56:41 +0000 Received: from corscience.de (DSL01.212.114.252.242.ip-pool.NEFkom.net [212.114.252.242]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0LtDvX-1QGtai0nH9-012qTB; Fri, 11 Feb 2011 16:56:30 +0100 Received: from azuregos.CS.local (unknown [192.168.102.9]) by corscience.de (Postfix) with ESMTP id B5BCE51C64; Fri, 11 Feb 2011 16:56:19 +0100 (CET) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: kernel@avr32linux.org Subject: [PATCH] at73c213: add support for at73c240 devices Date: Fri, 11 Feb 2011 16:56:11 +0100 Message-Id: <1297439772-16209-1-git-send-email-biessmann@corscience.de> X-Mailer: git-send-email 1.7.2.3 MIME-Version: 1.0 X-Provags-ID: V02:K0:zY4MPb2wdEGxW1TZwCa1567OeouxSHicsOyYuezqoFt 2AiGICX2uU0BnHmQGaBVAJel0odCWiYdaTA9cm8JuNm7G4l53W A3pI1vpPcSDeRRrzmL05UwqR66S3cPkXU0oAMQ+afckfYQPwo1 YC//5RoCpQ5dd1NxaeBmYHVmER+c+TXvTdm+oDeZzkGygCUS0l Hs1by31z0r4csNjcrgk5g== X-Spam-Score: 0.1 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [212.227.17.9 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 AWL AWL: From: address is in the auto white-list X-Headers-End: 1PnvMO-0003O5-D1 Cc: "open list:SOUND" , Takashi Iwai , open list , "open list:SPI SUBSYSTEM" , Hans-Christian Egtvedt , =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 11 Feb 2011 15:57:06 +0000 (UTC) X-MIME-Autoconverted: from base64 to 8bit by demeter1.kernel.org id p1BFuis8017507 diff --git a/include/linux/spi/at73c213.h b/include/linux/spi/at73c213.h index 0f20a70e..26d1f38 100644 --- a/include/linux/spi/at73c213.h +++ b/include/linux/spi/at73c213.h @@ -19,6 +19,7 @@ struct at73c213_board_info { int ssc_id; struct clk *dac_clk; + bool is_at73c240; char shortname[32]; }; diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index 503ffb0..711aae4 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -709,10 +709,44 @@ AT73C213_MONO_SWITCH("Aux Capture Switch", 0, DAC_CTRL, DAC_CTRL_ONAUXIN, AT73C213_MONO_SWITCH("Line Capture Switch", 0, DAC_CTRL, 0, 0x03, 0), }; +static struct snd_kcontrol_new snd_at73c240_controls[] __devinitdata = { +AT73C213_STEREO("Master Playback Volume", 0, DAC_LMPG, DAC_RMPG, 0, 0, 0x1f, 1), +AT73C213_STEREO("Master Playback Switch", 0, DAC_LMPG, DAC_RMPG, 5, 5, 1, 1), +AT73C213_STEREO("PCM Playback Volume", 0, DAC_LLOG, DAC_RLOG, 0, 0, 0x1f, 1), +AT73C213_STEREO("PCM Playback Switch", 0, DAC_LLOG, DAC_RLOG, 5, 5, 1, 1), +AT73C213_MONO_SWITCH("Mono PA Playback Switch", 0, DAC_CTRL, + (DAC_CTRL_ONPADRV-1), 0x01, 0), +{ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "PA Playback Volume", + .index = 0, + .info = snd_at73c213_pa_volume_info, + .get = snd_at73c213_mono_get, + .put = snd_at73c213_mono_put, + .private_value = PA_CTRL | (PA_CTRL_APAGAIN << 8) | \ + (0x0f << 16) | (1 << 24), +}, +AT73C213_MONO_SWITCH("PA Playback Switch", 0, PA_CTRL, (PA_CTRL_APAON-1), + 0x01, 0), +{ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Line Capture Volume", + .index = 0, + .info = snd_at73c213_line_capture_volume_info, + .get = snd_at73c213_stereo_get, + .put = snd_at73c213_stereo_put, + .private_value = DAC_LLIG | (DAC_RLIG << 8) | (0 << 16) | (0 << 19) + | (0x1f << 24) | (1 << 22), +}, +AT73C213_MONO_SWITCH("Line Capture Switch", 0, DAC_CTRL, 0, 0x03, 0), +}; + static int __devinit snd_at73c213_mixer(struct snd_at73c213 *chip) { struct snd_card *card; int errval, idx; + struct snd_kcontrol_new *controls; + int controls_size = 0; if (chip == NULL || chip->pcm == NULL) return -EINVAL; @@ -721,9 +755,17 @@ static int __devinit snd_at73c213_mixer(struct snd_at73c213 *chip) strcpy(card->mixername, chip->pcm->name); - for (idx = 0; idx < ARRAY_SIZE(snd_at73c213_controls); idx++) { + if (chip->board->is_at73c240) { + controls_size = ARRAY_SIZE(snd_at73c240_controls); + controls = snd_at73c240_controls; + } else { + controls_size = ARRAY_SIZE(snd_at73c213_controls); + controls = snd_at73c213_controls; + } + + for (idx = 0; idx < controls_size; idx++) { errval = snd_ctl_add(card, - snd_ctl_new1(&snd_at73c213_controls[idx], + snd_ctl_new1(&controls[idx], chip)); if (errval < 0) goto cleanup; @@ -732,7 +774,7 @@ static int __devinit snd_at73c213_mixer(struct snd_at73c213 *chip) return 0; cleanup: - for (idx = 1; idx < ARRAY_SIZE(snd_at73c213_controls) + 1; idx++) { + for (idx = 1; idx < controls_size + 1; idx++) { struct snd_kcontrol *kctl; kctl = snd_ctl_find_numid(card, idx); if (kctl) @@ -777,7 +819,7 @@ static int __devinit snd_at73c213_ssc_init(struct snd_at73c213 *chip) static int __devinit snd_at73c213_chip_init(struct snd_at73c213 *chip) { int retval; - unsigned char dac_ctrl = 0; + unsigned char tmp_reg; retval = snd_at73c213_set_bitrate(chip); if (retval) @@ -799,7 +841,11 @@ static int __devinit snd_at73c213_chip_init(struct snd_at73c213 *chip) retval = snd_at73c213_write_reg(chip, DAC_PRECH, 0xff); if (retval) goto out_clk; - retval = snd_at73c213_write_reg(chip, PA_CTRL, (1<board->is_at73c240) + tmp_reg = (1<<(PA_CTRL_APAPRECH-1)); + else + tmp_reg = (1<board->is_at73c240) { + /* Stop precharging PA. */ + retval = snd_at73c213_write_reg(chip, PA_CTRL, + (1<board->is_at73c240) + tmp_reg = (1<board->is_at73c240) { + retval = snd_at73c213_write_reg(chip, DAC_AUXG, 0x11); + if (retval) + goto out_clk; + } + + /* enable I2S clock */ + if (chip->board->is_at73c240) { + retval = snd_at73c213_write_reg(chip, DAC_IS_CTRL, + (1<ssc->regs, CR, SSC_BIT(CR_TXEN)); @@ -915,6 +979,10 @@ static int __devinit snd_at73c213_dev_init(struct snd_card *card, memcpy(&chip->reg_image, &snd_at73c213_original_image, sizeof(snd_at73c213_original_image)); + /* at73c240 has another reset value here */ + if (chip->board->is_at73c240) + chip->reg_image[PA_CTRL] = 0x0f; + retval = snd_at73c213_ssc_init(chip); if (retval) goto out_irq; @@ -1043,9 +1111,11 @@ static int __devexit snd_at73c213_remove(struct spi_device *spi) retval = snd_at73c213_write_reg(chip, DAC_RLIG, 0x11); if (retval) goto out; - retval = snd_at73c213_write_reg(chip, DAC_AUXG, 0x11); - if (retval) - goto out; + if (!chip->board->is_at73c240) { + retval = snd_at73c213_write_reg(chip, DAC_AUXG, 0x11); + if (retval) + goto out; + } /* Turn off PA. */ retval = snd_at73c213_write_reg(chip, PA_CTRL, @@ -1053,10 +1123,12 @@ static int __devexit snd_at73c213_remove(struct spi_device *spi) if (retval) goto out; msleep(10); - retval = snd_at73c213_write_reg(chip, PA_CTRL, - (1 << PA_CTRL_APALP) | 0x0f); - if (retval) - goto out; + if (!chip->board->is_at73c240) { + retval = snd_at73c213_write_reg(chip, PA_CTRL, + (1 << PA_CTRL_APALP) | 0x0f); + if (retval) + goto out; + } /* Turn off external DAC. */ retval = snd_at73c213_write_reg(chip, DAC_CTRL, 0x0c); diff --git a/sound/spi/at73c213.h b/sound/spi/at73c213.h index fd8b372..3712d6e 100644 --- a/sound/spi/at73c213.h +++ b/sound/spi/at73c213.h @@ -88,6 +88,9 @@ #define DAC_MISC_DEEMPEN 2 #define DAC_MISC_NBITS 0 +#define DAC_IS_CTRL 0x0B +#define DAC_IS_CTRL_IS_CTRL 2 + /* DAC Precharge Control Register */ #define DAC_PRECH 0x0C #define DAC_PRECH_PRCHGPDRV 7