Commit c973b8a7 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown
Browse files

ASoC: cs4271: Split SPI and I2C code into different modules



Currently the cs4271 driver depends on SND_SOC_I2C_AND_SPI.
So the driver cannot be built as built-in if CONFIG_I2C=m.
Split SPI and I2C code into different modules to avoid this issue.

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarBrian Austin <brian.austin@cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent f114040e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ config SND_EP93XX_SOC_EDB93XX
	tristate "SoC Audio support for Cirrus Logic EDB93xx boards"
	depends on SND_EP93XX_SOC && (MACH_EDB9301 || MACH_EDB9302 || MACH_EDB9302A || MACH_EDB9307A || MACH_EDB9315A)
	select SND_EP93XX_SOC_I2S
	select SND_SOC_CS4271
	select SND_SOC_CS4271_I2C if I2C
	select SND_SOC_CS4271_SPI if SPI_MASTER
	help
	  Say Y or M here if you want to add support for I2S audio on the
	  Cirrus Logic EDB93xx boards.
+15 −3
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ config SND_SOC_ALL_CODECS
	select SND_SOC_CS42L73 if I2C
	select SND_SOC_CS4265 if I2C
	select SND_SOC_CS4270 if I2C
	select SND_SOC_CS4271 if SND_SOC_I2C_AND_SPI
	select SND_SOC_CS4271_I2C if I2C
	select SND_SOC_CS4271_SPI if SPI_MASTER
	select SND_SOC_CS42XX8_I2C if I2C
	select SND_SOC_CX20442 if TTY
	select SND_SOC_DA7210 if I2C
@@ -370,8 +371,19 @@ config SND_SOC_CS4270_VD33_ERRATA
	depends on SND_SOC_CS4270

config SND_SOC_CS4271
	tristate "Cirrus Logic CS4271 CODEC"
	depends on SND_SOC_I2C_AND_SPI
	tristate

config SND_SOC_CS4271_I2C
	tristate "Cirrus Logic CS4271 CODEC (I2C)"
	depends on I2C
	select SND_SOC_CS4271
	select REGMAP_I2C

config SND_SOC_CS4271_SPI
	tristate "Cirrus Logic CS4271 CODEC (SPI)"
	depends on SPI_MASTER
	select SND_SOC_CS4271
	select REGMAP_SPI

config SND_SOC_CS42XX8
	tristate
+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ snd-soc-cs42l73-objs := cs42l73.o
snd-soc-cs4265-objs := cs4265.o
snd-soc-cs4270-objs := cs4270.o
snd-soc-cs4271-objs := cs4271.o
snd-soc-cs4271-i2c-objs := cs4271-i2c.o
snd-soc-cs4271-spi-objs := cs4271-spi.o
snd-soc-cs42xx8-objs := cs42xx8.o
snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o
snd-soc-cx20442-objs := cx20442.o
@@ -217,6 +219,8 @@ obj-$(CONFIG_SND_SOC_CS42L73) += snd-soc-cs42l73.o
obj-$(CONFIG_SND_SOC_CS4265)	+= snd-soc-cs4265.o
obj-$(CONFIG_SND_SOC_CS4270)	+= snd-soc-cs4270.o
obj-$(CONFIG_SND_SOC_CS4271)	+= snd-soc-cs4271.o
obj-$(CONFIG_SND_SOC_CS4271_I2C)	+= snd-soc-cs4271-i2c.o
obj-$(CONFIG_SND_SOC_CS4271_SPI)	+= snd-soc-cs4271-spi.o
obj-$(CONFIG_SND_SOC_CS42XX8)	+= snd-soc-cs42xx8.o
obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
obj-$(CONFIG_SND_SOC_CX20442)	+= snd-soc-cx20442.o
+62 −0
Original line number Diff line number Diff line
/*
 * CS4271 I2C audio driver
 *
 * Copyright (c) 2010 Alexander Sverdlin <subaparts@yandex.ru>
 *
 * 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 <linux/module.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <sound/soc.h>
#include "cs4271.h"

static int cs4271_i2c_probe(struct i2c_client *client,
			     const struct i2c_device_id *id)
{
	struct regmap_config config;

	config = cs4271_regmap_config;
	config.reg_bits = 8;
	config.val_bits = 8;

	return cs4271_probe(&client->dev,
			    devm_regmap_init_i2c(client, &config));
}

static int cs4271_i2c_remove(struct i2c_client *client)
{
	snd_soc_unregister_codec(&client->dev);
	return 0;
}

static const struct i2c_device_id cs4271_i2c_id[] = {
	{ "cs4271", 0 },
	{ }
};
MODULE_DEVICE_TABLE(i2c, cs4271_i2c_id);

static struct i2c_driver cs4271_i2c_driver = {
	.driver = {
		.name = "cs4271",
		.owner = THIS_MODULE,
		.of_match_table = of_match_ptr(cs4271_dt_ids),
	},
	.probe = cs4271_i2c_probe,
	.remove = cs4271_i2c_remove,
	.id_table = cs4271_i2c_id,
};
module_i2c_driver(cs4271_i2c_driver);

MODULE_DESCRIPTION("ASoC CS4271 I2C Driver");
MODULE_AUTHOR("Alexander Sverdlin <subaparts@yandex.ru>");
MODULE_LICENSE("GPL");
+55 −0
Original line number Diff line number Diff line
/*
 * CS4271 SPI audio driver
 *
 * Copyright (c) 2010 Alexander Sverdlin <subaparts@yandex.ru>
 *
 * 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 <linux/module.h>
#include <linux/spi/spi.h>
#include <linux/regmap.h>
#include <sound/soc.h>
#include "cs4271.h"

static int cs4271_spi_probe(struct spi_device *spi)
{
	struct regmap_config config;

	config = cs4271_regmap_config;
	config.reg_bits = 16;
	config.val_bits = 8;
	config.read_flag_mask = 0x21;
	config.write_flag_mask = 0x20;

	return cs4271_probe(&spi->dev, devm_regmap_init_spi(spi, &config));
}

static int cs4271_spi_remove(struct spi_device *spi)
{
	snd_soc_unregister_codec(&spi->dev);
	return 0;
}

static struct spi_driver cs4271_spi_driver = {
	.driver = {
		.name	= "cs4271",
		.owner	= THIS_MODULE,
		.of_match_table = of_match_ptr(cs4271_dt_ids),
	},
	.probe		= cs4271_spi_probe,
	.remove		= cs4271_spi_remove,
};
module_spi_driver(cs4271_spi_driver);

MODULE_DESCRIPTION("ASoC CS4271 SPI Driver");
MODULE_AUTHOR("Alexander Sverdlin <subaparts@yandex.ru>");
MODULE_LICENSE("GPL");
Loading