From patchwork Tue Jan 19 10:29:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Siverskog X-Patchwork-Id: 8060081 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2B4FC9F1CC for ; Tue, 19 Jan 2016 10:32:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 26DAB203B1 for ; Tue, 19 Jan 2016 10:32:03 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id B85F9203AA for ; Tue, 19 Jan 2016 10:32:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A0A592658E7; Tue, 19 Jan 2016 11:32:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 27A6E265750; Tue, 19 Jan 2016 11:30:36 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id AF7C12654EA; Tue, 19 Jan 2016 11:30:34 +0100 (CET) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) by alsa0.perex.cz (Postfix) with ESMTP id 5E9A9260544 for ; Tue, 19 Jan 2016 11:30:23 +0100 (CET) Received: by mail-lb0-f181.google.com with SMTP id oh2so361467520lbb.3 for ; Tue, 19 Jan 2016 02:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=teenage.engineering; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KYB6THNsx4oXYqkrefZNjH7gLuylGjgITlr0E+uaEd8=; b=ZAGdznGAcQUL07tNOsG/xVg5qZ2kzsWXwNEDeKFqVt+BdETsCH3HMT2LbQI1ACEQm2 3fjoFH2uVO+i4x927dwd+t4OXTd2Ex2565cb15/iRcvrNMPE/YqFk279YjyZksE0F4DM eRKabjRdMq9aFxn+FRlHPYVB0WJtvvzoPxT/E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KYB6THNsx4oXYqkrefZNjH7gLuylGjgITlr0E+uaEd8=; b=ZCjNZvGhYw2NDMRaUmLU0aEGL1ariU4cqhNz1tAUuC25ws/Y1dHnEIDJeVe4TJr53Q soNOzr51IiAuJLO4I1lNgOiOZ8j++Kb6oUHC04D0MYDJphsbyjexAYGr+uJSA3h0KoZV bgA2aC0zoJxs+UoTSquHkjmwqbZBRHpmMFXemVzjbCoU+6e1yszo7uO9TiX3VGRabn/b vHph+3/qSjGfenKWqmvrFBG0CmveL/HCiyNcKCG2UXFDxoYxRNDHDAGqMHP2PNFJfBWo Wji7TsPOngpC2xv7+bWDC/qW9zc9pUSRppdc7ACtPs/pv4K+hdYjEbS8D5io0XgDG937 +5fQ== X-Gm-Message-State: ALoCoQmc1+Ebk62QtyYwF03lGw7eTSYgnGdhjJ23IZGFNHx5kcaLeTJqw6jFKy/HtF4kYtWPrwWbTsHYTV6yHQKzOPusV4xmsA== X-Received: by 10.112.137.232 with SMTP id ql8mr10708099lbb.8.1453199423006; Tue, 19 Jan 2016 02:30:23 -0800 (PST) Received: from localhost.localdomain (212-107-146-90.customers.ownit.se. [212.107.146.90]) by smtp.gmail.com with ESMTPSA id 99sm3957813lfp.30.2016.01.19.02.30.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jan 2016 02:30:22 -0800 (PST) From: Jacob Siverskog To: Liam Girdwood , Mark Brown Date: Tue, 19 Jan 2016 11:29:47 +0100 Message-Id: <1453199388-8354-3-git-send-email-jacob@teenage.engineering> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1453199388-8354-1-git-send-email-jacob@teenage.engineering> References: <1453199388-8354-1-git-send-email-jacob@teenage.engineering> Cc: alsa-devel@alsa-project.org, Takashi Iwai , linux-kernel@vger.kernel.org, Johan Hovold , Jacob Siverskog , Michael Trimarchi Subject: [alsa-devel] [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The PCM179x family supports both SPI and I2C. This patch adds support for the I2C interface. Reviewed-by: Johan Hovold Signed-off-by: Jacob Siverskog --- .../devicetree/bindings/sound/pcm179x.txt | 11 ++- sound/soc/codecs/Kconfig | 9 +++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/pcm179x-i2c.c | 82 ++++++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 sound/soc/codecs/pcm179x-i2c.c diff --git a/Documentation/devicetree/bindings/sound/pcm179x.txt b/Documentation/devicetree/bindings/sound/pcm179x.txt index 4ae70d3..436c2b2 100644 --- a/Documentation/devicetree/bindings/sound/pcm179x.txt +++ b/Documentation/devicetree/bindings/sound/pcm179x.txt @@ -1,6 +1,6 @@ Texas Instruments pcm179x DT bindings -This driver supports the SPI bus. +This driver supports both the I2C and SPI bus. Required properties: @@ -9,6 +9,11 @@ Required properties: For required properties on SPI, please consult Documentation/devicetree/bindings/spi/spi-bus.txt +Required properties on I2C: + + - reg: the I2C address + + Examples: codec_spi: 1792a@0 { @@ -16,3 +21,7 @@ Examples: spi-max-frequency = <600000>; }; + codec_i2c: 1792a@4c { + compatible = "ti,pcm1792a"; + reg = <0x4c>; + }; diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index eaf13cb..45269cc 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -87,6 +87,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_ML26124 if I2C select SND_SOC_NAU8825 if I2C select SND_SOC_PCM1681 if I2C + select SND_SOC_PCM179X_I2C if I2C select SND_SOC_PCM179X_SPI if SPI_MASTER select SND_SOC_PCM3008 select SND_SOC_PCM3168A_I2C if I2C @@ -529,6 +530,14 @@ config SND_SOC_PCM1681 config SND_SOC_PCM179X tristate +config SND_SOC_PCM179X_I2C + tristate "Texas Instruments PCM179X CODEC family (I2C)" + depends on I2C + select SND_SOC_PCM179X + help + Enable support for Texas Instruments PCM179x CODEC family. + Select this if your PCM179x is connected via an I2C bus. + config SND_SOC_PCM179X_SPI tristate "Texas Instruments PCM179X CODEC family (SPI)" depends on SPI_MASTER diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 56e94d8..9acd777 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -81,6 +81,7 @@ snd-soc-ml26124-objs := ml26124.o snd-soc-nau8825-objs := nau8825.o snd-soc-pcm1681-objs := pcm1681.o snd-soc-pcm179x-codec-objs := pcm179x.o +snd-soc-pcm179x-i2c-objs := pcm179x-i2c.o snd-soc-pcm179x-spi-objs := pcm179x-spi.o snd-soc-pcm3008-objs := pcm3008.o snd-soc-pcm3168a-objs := pcm3168a.o @@ -286,6 +287,7 @@ obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o +obj-$(CONFIG_SND_SOC_PCM179X_I2C) += snd-soc-pcm179x-i2c.o obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o obj-$(CONFIG_SND_SOC_PCM3168A) += snd-soc-pcm3168a.o diff --git a/sound/soc/codecs/pcm179x-i2c.c b/sound/soc/codecs/pcm179x-i2c.c new file mode 100644 index 0000000..5a5d61a --- /dev/null +++ b/sound/soc/codecs/pcm179x-i2c.c @@ -0,0 +1,82 @@ +/* + * PCM179X ASoC I2C driver + * + * Copyright (c) Teenage Engineering AB 2016 + * + * Jacob Siverskog + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include + +#include "pcm179x.h" + +static int pcm179x_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct pcm179x_private *pcm179x; + int ret; + + pcm179x = devm_kzalloc(&client->dev, sizeof(struct pcm179x_private), + GFP_KERNEL); + if (!pcm179x) + return -ENOMEM; + + i2c_set_clientdata(client, pcm179x); + + pcm179x->dev = &client->dev; + + pcm179x->regmap = devm_regmap_init_i2c(client, &pcm179x_regmap_config); + if (IS_ERR(pcm179x->regmap)) { + ret = PTR_ERR(pcm179x->regmap); + dev_err(&client->dev, "Failed to register regmap: %d\n", ret); + return ret; + } + + return pcm179x_common_init(pcm179x); +} + +static int pcm179x_i2c_remove(struct i2c_client *client) +{ + return pcm179x_common_exit(i2c_get_clientdata(client)); +} + +static const struct of_device_id pcm179x_of_match[] = { + { .compatible = "ti,pcm1792a", }, + { } +}; +MODULE_DEVICE_TABLE(of, pcm179x_of_match); + +static const struct i2c_device_id pcm179x_i2c_ids[] = { + { "pcm179x", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, pcm179x_i2c_ids); + +static struct i2c_driver pcm179x_i2c_driver = { + .driver = { + .name = "pcm179x", + .of_match_table = of_match_ptr(pcm179x_of_match), + }, + .id_table = pcm179x_i2c_ids, + .probe = pcm179x_i2c_probe, + .remove = pcm179x_i2c_remove, +}; + +module_i2c_driver(pcm179x_i2c_driver); + +MODULE_DESCRIPTION("ASoC PCM179X I2C driver"); +MODULE_AUTHOR("Jacob Siverskog "); +MODULE_LICENSE("GPL");