Unverified Commit c7ac7499 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: rt5575: Add the codec driver for the ALC5575

Merge series from Oder Chiou <oder_chiou@realtek.com>:

This patch series adds support for the Realtek ALC5575 audio codec.
parents d7e36da6 42073911
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/realtek,rt5575.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: ALC5575 audio CODEC

maintainers:
  - Oder Chiou <oder_chiou@realtek.com>

description:
  The device supports both I2C and SPI. I2C is mandatory, while SPI is
  optional depending on the hardware configuration. SPI is used for
  firmware loading if present.

allOf:
  - $ref: dai-common.yaml#

properties:
  compatible:
    const: realtek,rt5575

  reg:
    maxItems: 1

  spi-parent:
    description:
      Optional phandle reference to the SPI controller used for firmware
      loading. The argument specifies the chip select.
    $ref: /schemas/types.yaml#/definitions/phandle-array

required:
  - compatible
  - reg

unevaluatedProperties: false

examples:
  # I2C-only node
  - |
    i2c {
        #address-cells = <1>;
        #size-cells = <0>;
        codec@57 {
            compatible = "realtek,rt5575";
            reg = <0x57>;
        };
    };

  # I2C + optional SPI node
  - |
    i2c {
        #address-cells = <1>;
        #size-cells = <0>;
        codec@57 {
            compatible = "realtek,rt5575";
            reg = <0x57>;
            spi-parent = <&spi0 0>; /* chip-select 0 */
        };
    };
+13 −10
Original line number Diff line number Diff line
@@ -4761,17 +4761,9 @@ EXPORT_SYMBOL_GPL(spi_write_then_read);

/*-------------------------------------------------------------------------*/

#if IS_ENABLED(CONFIG_OF_DYNAMIC)
/* Must call put_device() when done with returned spi_device device */
static struct spi_device *of_find_spi_device_by_node(struct device_node *node)
{
	struct device *dev = bus_find_device_by_of_node(&spi_bus_type, node);

	return dev ? to_spi_device(dev) : NULL;
}

#if IS_ENABLED(CONFIG_OF)
/* The spi controllers are not using spi_bus, so we find it with another way */
static struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
{
	struct device *dev;

@@ -4784,6 +4776,17 @@ static struct spi_controller *of_find_spi_controller_by_node(struct device_node
	/* Reference got in class_find_device */
	return container_of(dev, struct spi_controller, dev);
}
EXPORT_SYMBOL_GPL(of_find_spi_controller_by_node);
#endif

#if IS_ENABLED(CONFIG_OF_DYNAMIC)
/* Must call put_device() when done with returned spi_device device */
static struct spi_device *of_find_spi_device_by_node(struct device_node *node)
{
	struct device *dev = bus_find_device_by_of_node(&spi_bus_type, node);

	return dev ? to_spi_device(dev) : NULL;
}

static int of_spi_notify(struct notifier_block *nb, unsigned long action,
			 void *arg)
+9 −0
Original line number Diff line number Diff line
@@ -882,6 +882,15 @@ extern int devm_spi_register_controller(struct device *dev,
					struct spi_controller *ctlr);
extern void spi_unregister_controller(struct spi_controller *ctlr);

#if IS_ENABLED(CONFIG_OF)
extern struct spi_controller *of_find_spi_controller_by_node(struct device_node *node);
#else
static inline struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
{
	return NULL;
}
#endif

#if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SPI_MASTER)
extern struct spi_controller *acpi_spi_find_controller_by_adev(struct acpi_device *adev);
extern struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,
+10 −0
Original line number Diff line number Diff line
@@ -212,6 +212,7 @@ config SND_SOC_ALL_CODECS
	imply SND_SOC_RT1305
	imply SND_SOC_RT1308
	imply SND_SOC_RT5514
	imply SND_SOC_RT5575
	imply SND_SOC_RT5616
	imply SND_SOC_RT5631
	imply SND_SOC_RT5640
@@ -1783,6 +1784,15 @@ config SND_SOC_RT5514_SPI_BUILTIN
	bool # force RT5514_SPI to be built-in to avoid link errors
	default SND_SOC_RT5514=y && SND_SOC_RT5514_SPI=m

config SND_SOC_RT5575
	tristate "Realtek ALC5575 Codec - I2C"
	depends on I2C

config SND_SOC_RT5575_SPI
	tristate "Realtek ALC5575 Codec - SPI"
	depends on SPI_MASTER && I2C
	depends on SND_SOC_RT5575

config SND_SOC_RT5616
	tristate "Realtek RT5616 CODEC"
	depends on I2C
+3 −0
Original line number Diff line number Diff line
@@ -253,6 +253,8 @@ snd-soc-rt286-y := rt286.o
snd-soc-rt298-y := rt298.o
snd-soc-rt5514-y := rt5514.o
snd-soc-rt5514-spi-y := rt5514-spi.o
snd-soc-rt5575-y := rt5575.o
snd-soc-rt5575-$(CONFIG_SND_SOC_RT5575_SPI) += rt5575-spi.o
snd-soc-rt5616-y := rt5616.o
snd-soc-rt5631-y := rt5631.o
snd-soc-rt5640-y := rt5640.o
@@ -686,6 +688,7 @@ obj-$(CONFIG_SND_SOC_RT298) += snd-soc-rt298.o
obj-$(CONFIG_SND_SOC_RT5514)	+= snd-soc-rt5514.o
obj-$(CONFIG_SND_SOC_RT5514_SPI)	+= snd-soc-rt5514-spi.o
obj-$(CONFIG_SND_SOC_RT5514_SPI_BUILTIN)	+= snd-soc-rt5514-spi.o
obj-$(CONFIG_SND_SOC_RT5575)	+= snd-soc-rt5575.o
obj-$(CONFIG_SND_SOC_RT5616)	+= snd-soc-rt5616.o
obj-$(CONFIG_SND_SOC_RT5631)	+= snd-soc-rt5631.o
obj-$(CONFIG_SND_SOC_RT5640)	+= snd-soc-rt5640.o
Loading