Commit 1f388afc authored by forum_service's avatar forum_service Committed by carbon

u-boot: version release v4.1.0.3

fa813205bd Merge "[eth] change rxterm and vcm to link DianXin router" into v4.1.0
956d3a3198 [eth] change rxterm and vcm to link DianXin router
9e6d7e0dd8 [audio][uboot] add play

Change-Id: I6a23283cc4033f4032f0161d4ba5b9339e8f9952
parent b5490999
...@@ -2418,6 +2418,12 @@ config CMD_CVI_JPEG ...@@ -2418,6 +2418,12 @@ config CMD_CVI_JPEG
and decode jpg file to yuv format to the and decode jpg file to yuv format to the
destination address destination address
config CMD_CVISOUND
bool "CVI sound"
help
Support for the audio play
config CMD_CVI_UPDATE config CMD_CVI_UPDATE
bool "cvitek update command" bool "cvitek update command"
default y default y
......
...@@ -206,6 +206,7 @@ obj-$(CONFIG_CMD_AVB) += avb.o ...@@ -206,6 +206,7 @@ obj-$(CONFIG_CMD_AVB) += avb.o
obj-$(CONFIG_CMD_SCP03) += scp03.o obj-$(CONFIG_CMD_SCP03) += scp03.o
obj-y += efuse.o obj-y += efuse.o
obj-$(CONFIG_CMD_CVISOUND) += cvisound.o
obj-$(CONFIG_ARM) += arm/ obj-$(CONFIG_ARM) += arm/
obj-$(CONFIG_RISCV) += riscv/ obj-$(CONFIG_RISCV) += riscv/
......
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2023 bitmain, Inc
*
*/
#include <common.h>
#include <command.h>
#include <dm.h>
#include <sound.h>
#include <mapmem.h>
#include <dm/uclass.h>
#include <dm/uclass.h>
#include "../drivers/cvi_sound/cvi-src.h"
static int do_play(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
int ret = 0;
struct udevice *dev;
const struct sound_ops *ops;
printf("enter cviplay\n");
ret = uclass_get_device_by_driver(UCLASS_SOUND, DM_DRIVER_GET(cvitekub_sound), &dev);
if (ret) {
printf("[error][%s]no cvitekub_sound device ret:%d\n", __func__, ret);
return -1;
}
ops = dev->driver->ops;
if (!ops->setup || !ops->play || !ops->stop_play) {
printf("[error][%s]setup:%p, play:%p, stop_play:%p\n",
__func__, ops->setup, ops->play, ops->stop_play);
return -1;
}
ops->setup(dev);
ret = ops->play(dev, src_tx_data, SRC_BUFF_SIZE);
//printf("UPDATE_ADDR:%ld\n", (uintptr_t)UPDATE_ADDR);
//ret = ops->play(dev, (void *)(uintptr_t)UPDATE_ADDR, 726904);
if (ret) {
printf("[error][%s]play error:%d\n", __func__, ret);
return -1;
}
ops->stop_play(dev);
return 0;
}
U_BOOT_CMD(cviplay, 1, 1, do_play,
"perform cviplay",
"play sound\n"
);
...@@ -109,6 +109,7 @@ source "drivers/serial/Kconfig" ...@@ -109,6 +109,7 @@ source "drivers/serial/Kconfig"
source "drivers/smem/Kconfig" source "drivers/smem/Kconfig"
source "drivers/sound/Kconfig" source "drivers/sound/Kconfig"
source "drivers/cvi_sound/Kconfig"
source "drivers/soc/Kconfig" source "drivers/soc/Kconfig"
......
...@@ -72,9 +72,10 @@ ifdef CONFIG_TPL_BUILD ...@@ -72,9 +72,10 @@ ifdef CONFIG_TPL_BUILD
obj-$(CONFIG_TPL_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_TPL_BOOTCOUNT_LIMIT) += bootcount/
obj-$(CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/ obj-$(CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/
endif endif
obj-y += cvi_sound/
ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
obj-y += adc/ obj-y += adc/
......
menu "Cvitek Sound support"
config CVI_SOUND_DRIVERS
bool "Enable cvitek sound support"
help
Support making sounds through an audio codec. This is normally a
beep at a chosen frequency for a selected length of time. However
the drivers support playing arbitrary sound samples using a
PCM interface.
endmenu
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (C) 2023 Bitmain
#
obj-$(CONFIG_CVI_SOUND_DRIVERS) += cvi-sound.o
obj-$(CONFIG_CVI_SOUND_DRIVERS) += cvi-sound-uclass.o
obj-$(CONFIG_CVI_SOUND_DRIVERS) += cvi-dac-uclass.o
obj-$(CONFIG_CVI_SOUND_DRIVERS) += cvi-dac.o
obj-$(CONFIG_CVI_SOUND_DRIVERS) += cvi-i2s-uclass.o
obj-$(CONFIG_CVI_SOUND_DRIVERS) += cvi-i2s.o
#define LOG_CATEGORY UCLASS_AUDIO_CODEC
#include <common.h>
#include <dm.h>
#include "cvi-dac.h"
#include <audio_codec.h>
#include <dm/uclass.h>
int audio_codec_set_params(struct udevice *dev, int interface, int rate,
int mclk_freq, int bits_per_sample, uint channels)
{
struct audio_codec_ops *ops = audio_codec_get_ops(dev);
if (!ops->set_params)
return -ENOSYS;
return ops->set_params(dev, interface, rate, mclk_freq, bits_per_sample,
channels);
}
int audio_codec_close(struct udevice *dev)
{
struct audio_codec_ops *ops = audio_codec_get_ops(dev);
if (!ops->codec_close)
return -ENOSYS;
return ops->codec_close(dev);
}
UCLASS_DRIVER(audio_codec) = {
.id = UCLASS_AUDIO_CODEC,
.name = "audio-codec",
};
This diff is collapsed.
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2018 Google LLC
* Written by Simon Glass <sjg@chromium.org>
*/
#define LOG_CATEGORY UCLASS_I2S
#include <dm/uclass.h>
#include <common.h>
#include <dm.h>
#include <i2s.h>
int i2s_tx_data(struct udevice *dev, void *data, uint data_size)
{
struct i2s_ops *ops = i2s_get_ops(dev);
if (!ops->tx_data)
return -ENOSYS;
return ops->tx_data(dev, data, data_size);
}
UCLASS_DRIVER(i2s) = {
.id = UCLASS_I2S,
.name = "i2s",
.per_device_auto = sizeof(struct i2s_uc_priv),
};
This diff is collapsed.
This diff is collapsed.
#include <dm/uclass.h>
#include <sound.h>
UCLASS_DRIVER(sound) = {
.id = UCLASS_SOUND,
.name = "sound",
.per_device_auto = sizeof(struct sound_uc_priv),
};
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2023 bitmain
*/
#include <common.h>
#include <linux/types.h>
#include <dm/uclass.h>
#include <dm/device.h>
#include <audio_codec.h>
#include <sound.h>
#include <dm.h>
#include <i2s.h>
#include <log.h>
#include <sound.h>
static int cvitekub_sound_setup(struct udevice *dev)
{
struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev);
struct i2s_uc_priv *i2c_priv = dev_get_uclass_priv(uc_priv->i2s);
int ret = 0;
if (uc_priv->setup_done) {
printf("areadly init\n");
return ret;
}
ret = audio_codec_set_params(uc_priv->codec, i2c_priv->id,
i2c_priv->samplingrate,
i2c_priv->samplingrate * i2c_priv->rfs,
i2c_priv->bitspersample,
i2c_priv->channels);
if (ret)
return ret;
uc_priv->setup_done = true;
return 0;
}
static int cvitekub_sound_play(struct udevice *dev, void *data, uint data_size)
{
struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev);
return i2s_tx_data(uc_priv->i2s, data, data_size);
}
static int cvitekub_sound_stop_play(struct udevice *dev)
{
struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev);
audio_codec_close(uc_priv->codec); //because of pop
uc_priv->setup_done = false;
return 0;
}
static int cvitekub_sound_probe(struct udevice *dev)
{
printf("cvitekub_sound_probe\n");
int ret = 0;
struct sound_uc_priv *uc_priv = dev_get_uclass_priv(dev);
ret = uclass_get_device_by_driver(UCLASS_AUDIO_CODEC, DM_DRIVER_GET(cvitekub_dac),
&uc_priv->codec);
if (ret) {
printf("[error][%s]no cvitekub_dac device ret:%d\n", __func__, ret);
return -1;
}
ret = uclass_get_device_by_name(UCLASS_I2S, "i2s@04130000",
&uc_priv->i2s);
if (ret) {
printf("[error][%s]no cvitekub_i2s device ret:%d\n", __func__, ret);
return -1;
}
printf("Probed sound '%s' with codec '%s' and i2s '%s'\n", dev->name,
uc_priv->codec->name, uc_priv->i2s->name);
return 0;
}
static const struct sound_ops cvitekub_sound_ops = {
.setup = cvitekub_sound_setup,
.play = cvitekub_sound_play,
.stop_play = cvitekub_sound_stop_play,
};
static const struct udevice_id cvitekub_sound_ids[] = {
{ .compatible = "cvitek,cv182xa-dac" },
{ }
};
U_BOOT_DRIVER(cvitekub_sound) = {
.name = "cvitekub_sound",
.id = UCLASS_SOUND,
.of_match = cvitekub_sound_ids,
.probe = cvitekub_sound_probe,
.ops = &cvitekub_sound_ops,
};
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -83,4 +83,5 @@ obj-$(CONFIG_TARGET_CVITEK_CV1835) += cvitek/sdhci-cv183x.o ...@@ -83,4 +83,5 @@ obj-$(CONFIG_TARGET_CVITEK_CV1835) += cvitek/sdhci-cv183x.o
obj-$(CONFIG_TARGET_CVITEK_CV1822) += cvitek/sdhci-cv182x.o obj-$(CONFIG_TARGET_CVITEK_CV1822) += cvitek/sdhci-cv182x.o
obj-$(CONFIG_TARGET_CVITEK_CV181X) += cvitek/sdhci-cv181x.o obj-$(CONFIG_TARGET_CVITEK_CV181X) += cvitek/sdhci-cv181x.o
obj-$(CONFIG_TARGET_CVITEK_CV180X) += cvitek/sdhci-cv180x.o obj-$(CONFIG_TARGET_CVITEK_CV180X) += cvitek/sdhci-cv180x.o
obj-$(CONFIG_TARGET_CVITEK_ATHENA2) += cvitek/sdhci-athena2.o
endif endif
...@@ -134,26 +134,27 @@ static void cv182xa_ephy_init(void) ...@@ -134,26 +134,27 @@ static void cv182xa_ephy_init(void)
// En TX_Rterm // En TX_Rterm
mmio_write_32(0x03009040, (0x0001 | mmio_read_32(0x03009040))); mmio_write_32(0x03009040, (0x0001 | mmio_read_32(0x03009040)));
// change rx vcm
mmio_write_32(0x0300904c, (0x820 | mmio_read_32(0x0300904c)));
// Link Pulse // Link Pulse
// Switch to MII-page10 // Switch to MII-page10
mmio_write_32(0x0300907c, 0x0a00); mmio_write_32(0x0300907c, 0x0a00);
#if 1
// Set Link Pulse // Set Link Pulse
// mmio_write_32(0x03009040, 0x3e00); mmio_write_32(0x03009040, 0x3e00);
// mmio_write_32(0x03009044, 0x7864); mmio_write_32(0x03009044, 0x7864);
// mmio_write_32(0x03009048, 0x6470); mmio_write_32(0x03009048, 0x6470);
// mmio_write_32(0x0300904c, 0x5f62); mmio_write_32(0x0300904c, 0x5f62);
// mmio_write_32(0x03009050, 0x5a5a); mmio_write_32(0x03009050, 0x5a5a);
// mmio_write_32(0x03009054, 0x5458); mmio_write_32(0x03009054, 0x5458);
// mmio_write_32(0x03009058, 0xb23a); mmio_write_32(0x03009058, 0xb23a);
// mmio_write_32(0x0300905c, 0x94a0); mmio_write_32(0x0300905c, 0x94a0);
// mmio_write_32(0x03009060, 0x9092); mmio_write_32(0x03009060, 0x9092);
// mmio_write_32(0x03009064, 0x8a8e); mmio_write_32(0x03009064, 0x8a8e);
// mmio_write_32(0x03009068, 0x8688); mmio_write_32(0x03009068, 0x8688);
// mmio_write_32(0x0300906c, 0x8484); mmio_write_32(0x0300906c, 0x8484);
// mmio_write_32(0x03009070, 0x0082); mmio_write_32(0x03009070, 0x0082);
#else
// from sean // from sean
// Fix err: the status is still linkup when removed the network cable. // Fix err: the status is still linkup when removed the network cable.
mmio_write_32(0x03009040, 0x2000); mmio_write_32(0x03009040, 0x2000);
...@@ -169,7 +170,7 @@ static void cv182xa_ephy_init(void) ...@@ -169,7 +170,7 @@ static void cv182xa_ephy_init(void)
mmio_write_32(0x03009068, 0x8283); mmio_write_32(0x03009068, 0x8283);
mmio_write_32(0x0300906c, 0x8182); mmio_write_32(0x0300906c, 0x8182);
mmio_write_32(0x03009070, 0x0081); mmio_write_32(0x03009070, 0x0081);
#endif
// TP_IDLE // TP_IDLE
// Switch to MII-page11 // Switch to MII-page11
mmio_write_32(0x0300907c, 0x0b00); mmio_write_32(0x0300907c, 0x0b00);
......
...@@ -29,6 +29,8 @@ struct audio_codec_ops { ...@@ -29,6 +29,8 @@ struct audio_codec_ops {
*/ */
int (*set_params)(struct udevice *dev, int interface, int rate, int (*set_params)(struct udevice *dev, int interface, int rate,
int mclk_freq, int bits_per_sample, uint channels); int mclk_freq, int bits_per_sample, uint channels);
int (*codec_close)(struct udevice *dev);
}; };
#define audio_codec_get_ops(dev) ((struct audio_codec_ops *)(dev)->driver->ops) #define audio_codec_get_ops(dev) ((struct audio_codec_ops *)(dev)->driver->ops)
...@@ -47,4 +49,6 @@ struct audio_codec_ops { ...@@ -47,4 +49,6 @@ struct audio_codec_ops {
int audio_codec_set_params(struct udevice *dev, int interface, int rate, int audio_codec_set_params(struct udevice *dev, int interface, int rate,
int mclk_freq, int bits_per_sample, uint channels); int mclk_freq, int bits_per_sample, uint channels);
int audio_codec_close(struct udevice *dev);
#endif /* __AUDIO_CODEC_H__ */ #endif /* __AUDIO_CODEC_H__ */
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