#include <linux/device.h>
#include <linux/cdev.h>
#include <linux/platform_device.h>
+#include <linux/of_device.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/stat.h>
struct class *clsp;
};
static struct amvdac_dev_s amvdac_dev;
+static struct meson_vdac_data *s_vdac_data;
static struct mutex vdac_mutex;
#define HHI_VDAC_CNTL0 0xbd
vdac_cntl0_bit9 &= ~VDAC_MODULE_CVBS_OUT;
break;
case VDAC_MODULE_AUDIO_OUT: /* audio out ctrl*/
- if (is_meson_txl_cpu() || is_meson_txlx_cpu()) {
+ if (s_vdac_data->cpu_id == CPU_TYPE_TXL ||
+ s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
if (on)
vdac_cntl0_bit9 |= VDAC_MODULE_AUDIO_OUT;
else
else
enable = 1;
- if (is_meson_txl_cpu() || is_meson_txlx_cpu())
+ if (s_vdac_data->cpu_id == CPU_TYPE_TXL ||
+ s_vdac_data->cpu_id == CPU_TYPE_TXLX)
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, enable, 9, 1);
- else if (is_meson_g12a_cpu() ||
- is_meson_g12b_cpu())
+ else if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB)
vdac_hiu_reg_setb(HHI_VDAC_CNTL0_G12A, ~enable, 9, 1);
else
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, ~enable, 9, 1);
bool enable = 0;
/*bit10 is for bandgap startup setting in g12a*/
- if (is_meson_g12a_cpu() || is_meson_g12b_cpu())
+ if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB)
return;
switch (module_sel & 0xf) {
else
enable = 1;
- if (is_meson_g12a_cpu() || is_meson_g12b_cpu())
+ if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB)
vdac_hiu_reg_setb(HHI_VDAC_CNTL0_G12A, enable, 0, 1);
else
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, enable, 0, 1);
else
enable = 1;
- if (is_meson_txl_cpu() || is_meson_txlx_cpu())
+ if (s_vdac_data->cpu_id == CPU_TYPE_TXL ||
+ s_vdac_data->cpu_id == CPU_TYPE_TXLX)
vdac_hiu_reg_setb(HHI_VDAC_CNTL1, enable, 3, 1);
- else if (is_meson_g12a_cpu() || is_meson_g12b_cpu())
+ else if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB)
vdac_hiu_reg_setb(HHI_VDAC_CNTL1_G12A, ~enable, 3, 1);
else
vdac_hiu_reg_setb(HHI_VDAC_CNTL1, ~enable, 3, 1);
void vdac_set_ctrl0_ctrl1(unsigned int ctrl0, unsigned int ctrl1)
{
- if (is_meson_g12a_cpu() || is_meson_g12b_cpu()) {
+ if (s_vdac_data->cpu_id >= CPU_TYPE_G12AB) {
vdac_hiu_reg_write(HHI_VDAC_CNTL0_G12A, ctrl0);
vdac_hiu_reg_write(HHI_VDAC_CNTL1_G12A, ctrl1);
} else {
ana_ref_cntl0_bit9(1, VDAC_MODULE_ATV_DEMOD);
/*after txlx need reset bandgap after bit9 enabled*/
/*bit10 reset bandgap in g12a*/
- if (is_meson_txlx_cpu()) {
+ if (s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 1, 13, 1);
udelay(5);
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 13, 1);
/*Cdac pwd*/
vdac_out_cntl1_bit3(1, VDAC_MODULE_ATV_DEMOD);
/* enable AFE output buffer */
- if (!is_meson_g12a_cpu() && !is_meson_g12b_cpu())
+ if (s_vdac_data->cpu_id < CPU_TYPE_G12AB)
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 10, 1);
vdac_out_cntl0_bit0(1, VDAC_MODULE_ATV_DEMOD);
} else {
break;
vdac_out_cntl0_bit0(0, VDAC_MODULE_ATV_DEMOD);
/* Disable AFE output buffer */
- if (!is_meson_g12a_cpu() && !is_meson_g12b_cpu())
+ if (s_vdac_data->cpu_id < CPU_TYPE_G12AB)
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 10, 1);
/* enable dac output */
vdac_out_cntl1_bit3(0, VDAC_MODULE_ATV_DEMOD);
break;
case VDAC_MODULE_DTV_DEMOD: /* dtv demod */
if (on) {
- if (is_meson_gxlx_cpu())
+ if (s_vdac_data->cpu_id == CPU_TYPE_GXLX)
vdac_out_cntl1_bit3(1, VDAC_MODULE_DTV_DEMOD);
ana_ref_cntl0_bit9(1, VDAC_MODULE_DTV_DEMOD);
- if (is_meson_txlx_cpu()) {
+ if (s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 1, 13, 1);
udelay(5);
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 13, 1);
pri_flag |= VDAC_MODULE_DTV_DEMOD;
} else {
ana_ref_cntl0_bit9(0, VDAC_MODULE_DTV_DEMOD);
- if (is_meson_gxlx_cpu())
+ if (s_vdac_data->cpu_id == CPU_TYPE_GXLX)
vdac_out_cntl1_bit3(0, VDAC_MODULE_DTV_DEMOD);
pri_flag &= ~VDAC_MODULE_DTV_DEMOD;
}
if (on) {
ana_ref_cntl0_bit9(1, VDAC_MODULE_TVAFE);
/*after txlx need reset bandgap after bit9 enabled*/
- if (is_meson_txlx_cpu()) {
+ if (s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 1, 13, 1);
udelay(5);
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 13, 1);
vdac_out_cntl1_bit3(1, VDAC_MODULE_CVBS_OUT);
vdac_out_cntl0_bit0(1, VDAC_MODULE_CVBS_OUT);
ana_ref_cntl0_bit9(1, VDAC_MODULE_CVBS_OUT);
- if (is_meson_txlx_cpu()) {
+ if (s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 1, 13, 1);
udelay(5);
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0, 13, 1);
pri_flag &= ~VDAC_MODULE_CVBS_OUT;
if (pri_flag & VDAC_MODULE_ATV_DEMOD) {
vdac_out_cntl1_bit3(1, VDAC_MODULE_ATV_DEMOD);
- if (!is_meson_g12a_cpu() &&
- !is_meson_g12b_cpu())
+ if (s_vdac_data->cpu_id < CPU_TYPE_G12AB)
vdac_hiu_reg_setb(HHI_VDAC_CNTL0,
0, 10, 1);
vdac_out_cntl0_bit0(1, VDAC_MODULE_ATV_DEMOD);
vdac_out_cntl1_bit3(0, VDAC_MODULE_TVAFE);
vdac_out_cntl0_bit10(1, VDAC_MODULE_TVAFE);
} else if (pri_flag & VDAC_MODULE_DTV_DEMOD) {
- if (is_meson_gxlx_cpu())
+ if (s_vdac_data->cpu_id == CPU_TYPE_GXLX)
vdac_out_cntl1_bit3(1,
VDAC_MODULE_DTV_DEMOD);
ana_ref_cntl0_bit9(1, VDAC_MODULE_DTV_DEMOD);
break;
case VDAC_MODULE_AUDIO_OUT: /* audio demod */
/*Bandgap optimization*/
- if (is_meson_txlx_cpu() || is_meson_txhd_cpu())
+ if (s_vdac_data->cpu_id == CPU_TYPE_TXHD ||
+ s_vdac_data->cpu_id == CPU_TYPE_TXLX)
vdac_hiu_reg_setb(HHI_VDAC_CNTL0, 0xe, 3, 5);
- if (is_meson_txl_cpu() || is_meson_txlx_cpu()) {
+ if (s_vdac_data->cpu_id == CPU_TYPE_TXL ||
+ s_vdac_data->cpu_id == CPU_TYPE_TXLX) {
if (on)
ana_ref_cntl0_bit9(1, VDAC_MODULE_AUDIO_OUT);
else
.release = amvdac_release,
};
+struct meson_vdac_data meson_gxtvbb_vdac_data = {
+ .cpu_id = CPU_TYPE_GXTVBB,
+ .name = "meson-gxtvbb-vdac",
+};
+
+struct meson_vdac_data meson_gx_l_m_vdac_data = {
+ .cpu_id = CPU_TYPE_GX_L_M,
+ .name = "meson-gx_l_m-vdac",
+};
+
+struct meson_vdac_data meson_txl_vdac_data = {
+ .cpu_id = CPU_TYPE_TXL,
+ .name = "meson-txl-vdac",
+};
+
+struct meson_vdac_data meson_txlx_vdac_data = {
+ .cpu_id = CPU_TYPE_TXLX,
+ .name = "meson-txlx-vdac",
+};
+
+struct meson_vdac_data meson_gxlx_vdac_data = {
+ .cpu_id = CPU_TYPE_GXLX,
+ .name = "meson-gxlx-vdac",
+};
+
+struct meson_vdac_data meson_txhd_vdac_data = {
+ .cpu_id = CPU_TYPE_TXHD,
+ .name = "meson-txhd-vdac",
+};
+
+struct meson_vdac_data meson_g12ab_vdac_data = {
+ .cpu_id = CPU_TYPE_G12AB,
+ .name = "meson-g12ab-vdac",
+};
+
+static const struct of_device_id meson_vdac_dt_match[] = {
+ {
+ .compatible = "amlogic, vdac-gxtvbb",
+ .data = &meson_gxtvbb_vdac_data,
+ }, {
+ .compatible = "amlogic, vdac-gxl",
+ .data = &meson_gx_l_m_vdac_data,
+ }, {
+ .compatible = "amlogic, vdac-gxm",
+ .data = &meson_gx_l_m_vdac_data,
+ }, {
+ .compatible = "amlogic, vdac-txl",
+ .data = &meson_txl_vdac_data,
+ }, {
+ .compatible = "amlogic, vdac-txlx",
+ .data = &meson_txlx_vdac_data,
+ }, {
+ .compatible = "amlogic, vdac-gxlx",
+ .data = &meson_gxlx_vdac_data,
+ }, {
+ .compatible = "amlogic, vdac-txhd",
+ .data = &meson_txhd_vdac_data,
+ }, {
+ .compatible = "amlogic, vdac-g12a",
+ .data = &meson_g12ab_vdac_data,
+ }, {
+ .compatible = "amlogic, vdac-g12b",
+ .data = &meson_g12ab_vdac_data,
+ },
+ {},
+};
+
static int aml_vdac_probe(struct platform_device *pdev)
{
int ret = 0;
+ const struct of_device_id *match;
struct amvdac_dev_s *devp = &amvdac_dev;
memset(devp, 0, (sizeof(struct amvdac_dev_s)));
- pr_info("\n%s: probe start\n", __func__);
+ match = of_match_device(meson_vdac_dt_match, &pdev->dev);
+ if (match == NULL) {
+ pr_err("%s,no matched table\n", __func__);
+ return -1;
+ }
+ s_vdac_data = (struct meson_vdac_data *)match->data;
+ pr_info("%s:probe start.cpu_id:%d,name:%s\n", __func__,
+ s_vdac_data->cpu_id, s_vdac_data->name);
ret = alloc_chrdev_region(&devp->devno, 0, 1, AMVDAC_NAME);
if (ret < 0)
vdac_set_ctrl0_ctrl1(cntl0, cntl1);
}
-
-static const struct of_device_id aml_vdac_dt_match[] = {
- {
- .compatible = "amlogic, vdac",
- },
- {},
-};
-
static struct platform_driver aml_vdac_driver = {
.driver = {
.name = "aml_vdac",
.owner = THIS_MODULE,
- .of_match_table = aml_vdac_dt_match,
+ .of_match_table = meson_vdac_dt_match,
},
.probe = aml_vdac_probe,
.remove = __exit_p(aml_vdac_remove),