Commit 7b2f3eb4 authored by Lucas Tanure's avatar Lucas Tanure Committed by Takashi Iwai

ALSA: hda: cs35l41: Add support for CS35L41 in HDA systems

Add support for CS35L41 using a new separated driver
that can be used in all upcoming designs
Signed-off-by: default avatarLucas Tanure <tanureal@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211217115708.882525-8-tanureal@opensource.cirrus.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 2aac550d
......@@ -4511,10 +4511,12 @@ F: drivers/media/cec/i2c/ch7322.c
CIRRUS LOGIC AUDIO CODEC DRIVERS
M: James Schulman <james.schulman@cirrus.com>
M: David Rhodes <david.rhodes@cirrus.com>
M: Lucas Tanure <tanureal@opensource.cirrus.com>
L: alsa-devel@alsa-project.org (moderated for non-subscribers)
L: patches@opensource.cirrus.com
S: Maintained
F: Documentation/devicetree/bindings/sound/cirrus,cs*
F: sound/pci/hda/cs*
F: sound/soc/codecs/cs*
CIRRUS LOGIC DSP FIRMWARE DRIVER
......
......@@ -91,6 +91,35 @@ config SND_HDA_PATCH_LOADER
start up. The "patch" file can be specified via patch module
option, such as patch=hda-init.
config SND_HDA_SCODEC_CS35L41
tristate
config SND_HDA_SCODEC_CS35L41_I2C
tristate "Build CS35L41 HD-audio side codec support for I2C Bus"
depends on ACPI
select SND_HDA_GENERIC
select SND_SOC_CS35L41_LIB
select SND_HDA_SCODEC_CS35L41
help
Say Y or M here to include CS35L41 I2C HD-audio side codec support
in snd-hda-intel driver, such as ALC287.
comment "Set to Y if you want auto-loading the side codec driver"
depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_I2C=m
config SND_HDA_SCODEC_CS35L41_SPI
tristate "Build CS35L41 HD-audio codec support for SPI Bus"
depends on ACPI
select SND_HDA_GENERIC
select SND_SOC_CS35L41_LIB
select SND_HDA_SCODEC_CS35L41
help
Say Y or M here to include CS35L41 SPI HD-audio side codec support
in snd-hda-intel driver, such as ALC287.
comment "Set to Y if you want auto-loading the side codec driver"
depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_SPI=m
config SND_HDA_CODEC_REALTEK
tristate "Build Realtek HD-audio codec support"
select SND_HDA_GENERIC
......
......@@ -27,6 +27,11 @@ snd-hda-codec-conexant-objs := patch_conexant.o
snd-hda-codec-via-objs := patch_via.o
snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o
# side codecs
snd-hda-scodec-cs35l41-objs := cs35l41_hda.o
snd-hda-scodec-cs35l41-i2c-objs := cs35l41_hda_i2c.o
snd-hda-scodec-cs35l41-spi-objs := cs35l41_hda_spi.o
# common driver
obj-$(CONFIG_SND_HDA) := snd-hda-codec.o
......@@ -45,6 +50,11 @@ obj-$(CONFIG_SND_HDA_CODEC_CONEXANT) += snd-hda-codec-conexant.o
obj-$(CONFIG_SND_HDA_CODEC_VIA) += snd-hda-codec-via.o
obj-$(CONFIG_SND_HDA_CODEC_HDMI) += snd-hda-codec-hdmi.o
# side codecs
obj-$(CONFIG_SND_HDA_SCODEC_CS35L41) += snd-hda-scodec-cs35l41.o
obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_I2C) += snd-hda-scodec-cs35l41-i2c.o
obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_SPI) += snd-hda-scodec-cs35l41-spi.o
# this must be the last entry after codec drivers;
# otherwise the codec patches won't be hooked before the PCI probe
# when built in kernel
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0
*
* cs35l41_hda.h -- CS35L41 ALSA HDA audio driver
*
* Copyright 2021 Cirrus Logic, Inc.
*
* Author: Lucas Tanure <tanureal@opensource.cirrus.com>
*/
#ifndef __CS35L41_HDA_H__
#define __CS35L41_HDA_H__
#include <linux/regulator/consumer.h>
#include <linux/gpio/consumer.h>
#include <linux/device.h>
#include <sound/cs35l41.h>
enum cs35l41_hda_spk_pos {
CS35l41_LEFT,
CS35l41_RIGHT,
};
enum cs35l41_hda_gpio_function {
CS35L41_NOT_USED,
CS35l41_VSPK_SWITCH,
CS35L41_INTERRUPT,
CS35l41_SYNC,
};
struct cs35l41_hda_reg_sequence {
const struct reg_sequence *probe;
unsigned int num_probe;
const struct reg_sequence *open;
unsigned int num_open;
const struct reg_sequence *prepare;
unsigned int num_prepare;
const struct reg_sequence *cleanup;
unsigned int num_cleanup;
const struct reg_sequence *close;
unsigned int num_close;
};
struct cs35l41_hda_hw_config {
unsigned int spk_pos;
unsigned int gpio1_func;
unsigned int gpio2_func;
int bst_ind;
int bst_ipk;
int bst_cap;
};
struct cs35l41_hda {
struct device *dev;
struct regmap *regmap;
struct gpio_desc *reset_gpio;
const struct cs35l41_hda_reg_sequence *reg_seq;
int irq;
int index;
/* Don't put the AMP in reset of VSPK can not be turned off */
bool vspk_always_on;
};
int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq,
struct regmap *regmap);
int cs35l41_hda_remove(struct device *dev);
#endif /*__CS35L41_HDA_H__*/
// SPDX-License-Identifier: GPL-2.0
//
// cs35l41.c -- CS35l41 HDA I2C driver
//
// Copyright 2021 Cirrus Logic, Inc.
//
// Author: Lucas Tanure <tanureal@opensource.cirrus.com>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/acpi.h>
#include "cs35l41_hda.h"
static int cs35l41_hda_i2c_probe(struct i2c_client *clt, const struct i2c_device_id *id)
{
const char *device_name;
/* Compare against the device name so it works for I2C, normal ACPI
* and for ACPI by i2c-multi-instantiate matching cases
*/
if (strstr(dev_name(&clt->dev), "CLSA0100"))
device_name = "CLSA0100";
else if (strstr(dev_name(&clt->dev), "CSC3551"))
device_name = "CSC3551";
else
return -ENODEV;
return cs35l41_hda_probe(&clt->dev, device_name, clt->addr, clt->irq,
devm_regmap_init_i2c(clt, &cs35l41_regmap_i2c));
}
static int cs35l41_hda_i2c_remove(struct i2c_client *clt)
{
return cs35l41_hda_remove(&clt->dev);
}
static const struct i2c_device_id cs35l41_hda_i2c_id[] = {
{ "cs35l41-hda", 0 },
{}
};
#ifdef CONFIG_ACPI
static const struct acpi_device_id cs35l41_acpi_hda_match[] = {
{"CLSA0100", 0 },
{"CSC3551", 0 },
{ },
};
MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match);
#endif
static struct i2c_driver cs35l41_i2c_driver = {
.driver = {
.name = "cs35l41-hda",
.acpi_match_table = ACPI_PTR(cs35l41_acpi_hda_match),
},
.id_table = cs35l41_hda_i2c_id,
.probe = cs35l41_hda_i2c_probe,
.remove = cs35l41_hda_i2c_remove,
};
module_i2c_driver(cs35l41_i2c_driver);
MODULE_DESCRIPTION("HDA CS35L41 driver");
MODULE_AUTHOR("Lucas Tanure <tanureal@opensource.cirrus.com>");
MODULE_LICENSE("GPL");
// SPDX-License-Identifier: GPL-2.0
//
// cs35l41.c -- CS35l41 HDA SPI driver
//
// Copyright 2021 Cirrus Logic, Inc.
//
// Author: Lucas Tanure <tanureal@opensource.cirrus.com>
#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/spi/spi.h>
#include "cs35l41_hda.h"
static int cs35l41_hda_spi_probe(struct spi_device *spi)
{
const char *device_name;
/* Compare against the device name so it works for SPI, normal ACPI
* and for ACPI by spi-multi-instantiate matching cases
*/
if (strstr(dev_name(&spi->dev), "CSC3551"))
device_name = "CSC3551";
else
return -ENODEV;
return cs35l41_hda_probe(&spi->dev, device_name, spi->chip_select, spi->irq,
devm_regmap_init_spi(spi, &cs35l41_regmap_spi));
}
static int cs35l41_hda_spi_remove(struct spi_device *spi)
{
return cs35l41_hda_remove(&spi->dev);
}
static const struct spi_device_id cs35l41_hda_spi_id[] = {
{ "cs35l41-hda", 0 },
{}
};
#ifdef CONFIG_ACPI
static const struct acpi_device_id cs35l41_acpi_hda_match[] = {
{ "CSC3551", 0 },
{},
};
MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match);
#endif
static struct spi_driver cs35l41_spi_driver = {
.driver = {
.name = "cs35l41_hda",
.acpi_match_table = ACPI_PTR(cs35l41_acpi_hda_match),
},
.id_table = cs35l41_hda_spi_id,
.probe = cs35l41_hda_spi_probe,
.remove = cs35l41_hda_spi_remove,
};
module_spi_driver(cs35l41_spi_driver);
MODULE_DESCRIPTION("HDA CS35L41 driver");
MODULE_AUTHOR("Lucas Tanure <tanureal@opensource.cirrus.com>");
MODULE_LICENSE("GPL");
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* HD audio Component Binding Interface
*
* Copyright (C) 2021 Cirrus Logic, Inc. and
* Cirrus Logic International Semiconductor Ltd.
*/
#include <linux/component.h>
#define HDA_MAX_COMPONENTS 4
#define HDA_MAX_NAME_SIZE 50
struct hda_component {
struct device *dev;
char name[HDA_MAX_NAME_SIZE];
void (*playback_hook)(struct device *dev, int action);
int (*set_channel_map)(struct device *dev, unsigned int rx_num, unsigned int *rx_slot,
unsigned int tx_num, unsigned int *tx_slot);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment