Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add k230 alsa driver #186

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

%YAML 1.2
---
$id: "http://devicetree.org/schemas/sound/canaan,k230-audio-inno.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"

title: Canaan K230 Audio INNO Device Tree Bindings

maintainers:
- Sun Xiaopeng <[email protected]>

description: |
This document describes the device tree bindings for the audio subsystem
on the Canaan K230 SoC using the INNO codec.

properties:
compatible:
const: "canaan,k230-audio-inno"
description: |
Must be "canaan,k230-audio-inno".

canaan,model:
$ref: /schemas/types.yaml#/definitions/string
description: |
Custom model name for the sound card.

canaan,k230-i2s-controller:
$ref: /schemas/types.yaml#/definitions/phandle
description: |
Phandle to the I2S controller node.

canaan,k230-audio-codec:
$ref: /schemas/types.yaml#/definitions/phandle
description: |
Phandle to the audio codec node.

required:
- compatible
- canaan,k230-i2s-controller
- canaan,k230-audio-codec

additionalProperties: false

examples:
- |
sound {
compatible = "canaan,k230-audio-inno";
canaan,model = "K230_I2S_INNO";
canaan,k230-i2s-controller = <&i2s>;
canaan,k230-audio-codec = <&inno_codec>;
};
47 changes: 47 additions & 0 deletions Documentation/devicetree/bindings/sound/canaan,k230-audio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: "http://devicetree.org/schemas/sound/canaan,k230-audio.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"

title: Canaan K230 Audio Controller Device Tree Bindings

maintainers:
- Sun Xiaopeng <[email protected]>

description: |
This document defines the device tree bindings for the audio controller
found in the Canaan K230 SoC. The audio controller provides interfaces for
audio input and output functionalities.

properties:
compatible:
enum:
- canaan,k230-audio
description: |
Specifies the compatible string for the Canaan K230 audio controller.

reg:
maxItems: 1
description: |
Specifies the base physical address and size of the audio controller's
register area.

status:
description: |
Standard property to indicate the operational status of the device.
Should be "okay" if the device is enabled.

required:
- compatible
- reg

additionalProperties: false

examples:
- |
audio: audio@9140f400 {
compatible = "canaan,k230-audio";
reg = <0x0 0x9140f400 0x0 0xc00>;
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

%YAML 1.2
---
$id: "http://devicetree.org/schemas/sound/canaan,k230-inno-codec.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"

title: Canaan k230 Inno Codec

maintainers:
- Sun Xiaopeng <[email protected]>

compatible: "canaan,k230-inno-codec"
description: "Inno Codec Device for K230 SoC"

properties:
status:
description: "The status of the codec device"
type: string
default: "disabled"
values:
- "okay"
- "disabled"

reg:
description: "Base address and size of the codec registers"
type: <address>

clocks:
description: "Clocks used by the codec"
type: list
items: phandle

clock-names:
description: "Names corresponding to each clock"
type: list
items: string

examples:
- |
inno_codec:inno_codec@0x9140e000 {
status = "okay";
compatible = "canaan,k230-inno-codec";
reg = <0x0 0x9140e000 0x0 0x1000>;
clocks = <&codec_adc_mclk>, <&codec_dac_mclk>;
clock-names = "adc", "dac";
};
65 changes: 65 additions & 0 deletions Documentation/devicetree/bindings/sound/canaan,k230-pdma.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: "http://devicetree.org/schemas/dma/canaan,k230-pdma.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"

title: Canaan K230 PDMA Controller

maintainers:
- Sun Xiaopeng <[email protected]>

description: |
The Canaan K230 PDMA controller is a peripheral DMA controller that supports
multiple channels and request signals.

properties:
compatible:
const: canaan,k230-pdma
description: Must be "canaan,k230-pdma"

reg:
maxItems: 1
description: Base address and size of the PDMA registers.

interrupts:
maxItems: 1
description: Interrupt specifier for the PDMA controller.

clocks:
maxItems: 1
description: Reference to the PDMA controller clock.

dma-channels:
description: The number of DMA channels supported by the controller.

dma-requests:
description: The number of DMA request signals supported.

'#dma-cells':
const: 4
description: Must be 4. Specifies the number of cells in the DMA specifier.

required:
- compatible
- reg
- interrupts
- clocks
- dma-channels
- dma-requests
- '#dma-cells'

additionalProperties: false

examples:
- |
pdma: pdma@80804000 {
compatible = "canaan,k230-pdma";
reg = <0x0 0x80804000 0x0 0x400>;
interrupts = <203 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&pdma_aclk_gate>;
dma-channels = <8>;
dma-requests = <35>;
#dma-cells = <4>;
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

%YAML 1.2
---
$id: "http://devicetree.org/schemas/sound/canaan,designware-i2s.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"

title: Canaan DesignWare I2S Controller

maintainers:
- Sun Xiaopeng <[email protected]>

description: |
This document describes the device tree bindings for the Canaan DesignWare
I2S controller found in the K230 SoC. The controller is compliant with the
Synopsys DesignWare I2S IP core and requires specific properties to function
correctly.

properties:
compatible:
const: "canaan,snps,designware-i2s"
description: |
Must be "canaan,snps,designware-i2s" to identify the Canaan-specific
implementation of the DesignWare I2S controller.

reg:
maxItems: 1
description: |
Contains the base address and length of the I2S controller register set.

status:
enum:
- "okay"
- "disabled"
description: |
Standard property to enable or disable the device. Must be "okay" to
activate the I2S controller.

dmas:
minItems: 2
maxItems: 2
description: |
Phandles to the DMA channels for transmit and receive. The first item
is for transmit (TX), and the second is for receive (RX).

dma-names:
items:
- const: "tx"
- const: "rx"
description: |
Names corresponding to the DMA channels listed in the "dmas" property.

clocks:
maxItems: 1
description: |
Phandle to the clock provided to the I2S controller.

clock-names:
items:
- const: "i2sclk"
description: |
Name of the clock listed in the "clocks" property. Must be "i2sclk".

required:
- compatible
- reg
- status
- dmas
- dma-names
- clocks
- clock-names

additionalProperties: false

examples:
- |
i2s: i2s@9140f000 {
compatible = "canaan,snps,designware-i2s";
reg = <0x0 0x9140f000 0x0 0x400>;
status = "okay";
dmas = <&pdma 1 0xfff 0 0x14>, <&pdma 1 0xfff 0 0x15>;
dma-names = "tx", "rx";
clocks = <&audio_dev_clk>;
clock-names = "i2sclk";
};
8 changes: 8 additions & 0 deletions arch/riscv/boot/dts/canaan/k230-canmv.dts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
device_type = "memory";
reg = <0x0 0x0 0x0 0x20000000>;
};

sound {
status = "okay";
compatible = "canaan,k230-audio-inno";
canaan,model = "K230_I2S_INNO";
canaan,k230-i2s-controller = <&i2s>;
canaan,k230-audio-codec = <&inno_codec>;
};
};

&uart0 {
Expand Down
37 changes: 37 additions & 0 deletions arch/riscv/boot/dts/canaan/k230.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,43 @@
clock-names = "vpu";
};

pdma: pdma@0x80804000 {
#dma-cells = <4>;
dma-channels = <8>;
dma-requests = <35>;
status = "okay";
compatible = "canaan,k230-pdma";
reg = <0x0 0x80804000 0x0 0x400>;
interrupts = <203 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&pdma_aclk_gate>;
};

i2s: i2s@0x9140f000 {
status = "okay";
compatible = "canaan,snps,designware-i2s";
// compatible = "snps,designware-i2s";
reg = <0x0 0x9140f000 0x0 0x400>;
dmas = <&pdma 1 0xfff 0 0x14>, <&pdma 1 0xfff 0 0x15>;
dma-names = "tx", "rx";
clocks = <&audio_dev_clk>;
clock-names = "i2sclk";
};

/* audio */
audio: audio@0x9140f400 {
status = "okay";
compatible = "canaan,k230-audio";
reg = <0x0 0x9140f400 0x0 0xc00>;
};

inno_codec:inno_codec@0x9140e000{
status = "okay";
compatible = "canaan,k230-inno-codec";
reg = <0x0 0x9140e000 0x0 0x1000>;
clocks = <&codec_adc_mclk>,<&codec_dac_mclk>;
clock-names = "adc", "dac";
};

gpu: gpu@90800000 {
compatible = "verisilicon,gc8000ul";
reg = <0x0 0x90800000 0x0 0x1000>;
Expand Down
11 changes: 11 additions & 0 deletions arch/riscv/configs/k230_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,14 @@ CONFIG_CFG80211_WEXT=y
CONFIG_MAC80211=y
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_USB_VIDEO_CLASS=y
CONFIG_SOUND=y
CONFIG_SND=y
CONFIG_SND_SOC=y
# CONFIG_SND_DESIGNWARE_I2S=y
# CONFIG_SND_DESIGNWARE_PCM=y
CONFIG_CANAAN_SND_DESIGNWARE_I2S=y
CONFIG_CANAAN_SND_DESIGNWARE_PCM=y
CONFIG_SND_SOC_K230_INNO=y
CONFIG_SND_SOC_CANAAN_K230_INNO=y
CONFIG_SND_SOC_CANAAN_K230_AUDIO=y
CONFIG_K230_PERIDMA=y
Loading
Loading