From d80bb9f7fa30e506a6332992b9fdf5f150b9ee34 Mon Sep 17 00:00:00 2001 From: Xing Wang Date: Mon, 10 Jul 2017 20:26:02 +0800 Subject: [PATCH] audio: audio info for audio license query PD#147297: audio: audio license query driver Change-Id: I9a9db1c33c372bc58130a1c41addfd80303a5625 Signed-off-by: Xing Wang Signed-off-by: Matthew Shyu --- MAINTAINERS | 12 + arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts | 4 +- arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts | 3 + arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts | 1174 +++++++++++++++++++ arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts | 4 +- arch/arm64/boot/dts/amlogic/mesongxl.dtsi | 6 + arch/arm64/boot/dts/amlogic/mesongxm.dtsi | 6 + arch/arm64/configs/meson64_defconfig | 1 + drivers/amlogic/Kconfig | 2 + drivers/amlogic/Makefile | 2 + drivers/amlogic/audioinfo/Kconfig | 11 + drivers/amlogic/audioinfo/Makefile | 1 + drivers/amlogic/audioinfo/audio_data.c | 295 +++++ drivers/amlogic/audioinfo/audio_data.h | 36 + 14 files changed, 1555 insertions(+), 2 deletions(-) create mode 100644 arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts create mode 100644 drivers/amlogic/audioinfo/Kconfig create mode 100644 drivers/amlogic/audioinfo/Makefile create mode 100644 drivers/amlogic/audioinfo/audio_data.c create mode 100644 drivers/amlogic/audioinfo/audio_data.h diff --git a/MAINTAINERS b/MAINTAINERS index b8b20604d5f9..938a276adb96 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13536,6 +13536,7 @@ F: drivers/amlogic/pwm/* F: include/linux/amlogic/pwm_meson.h F: include/dt-bindings/pwm/meosn.h F: arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +F: arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts AMLOGIC multimedia @@ -13583,6 +13584,7 @@ F: drivers/amlogic/media/Kconfig F: drivers/amlogic/media/Makefile F: arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts F: arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +F: arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts F: drivers/amlogic/clk/clk_media.c F: include/linux/amlogic/media/vout/vout_notify.h @@ -13637,6 +13639,7 @@ AMLOGIC TVIN M: Dezhi Kong F: arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts F: arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +F: arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_skt.dts F: arch/arm64/configs/meson64_defconfig @@ -13666,6 +13669,7 @@ AMLOGIC key_manage M: Nan Li F: arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts F: arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +F: arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts F: arch/arm64/configs/meson64_defconfig F: drivers/amlogic/Kconfig @@ -13707,6 +13711,7 @@ ANLOGIC AUDIO M: Xing Wang F: arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts F: arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +F: arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_skt.dts F: arch/arm64/boot/dts/amlogic/mesongxl.dtsi @@ -13732,6 +13737,7 @@ AMLOGIC PPMGR DRIVER M: Guosong Zhou F: arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts F: arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +F: arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts F: arch/arm64/boot/dts/amlogic/gxl_p400_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_p401_2g.dts @@ -13788,6 +13794,7 @@ AMLOGIC IONVIDEO DRIVER M: Guosong Zhou F: arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts F: arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +F: arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts F: arch/arm64/boot/dts/amlogic/gxl_p400_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_p401_2g.dts @@ -13860,6 +13867,7 @@ F: arch/arm/boot/dts/amlogic/meson8b_m200.dts F: arch/arm/configs/meson32_defconfig F: arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts F: arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +F: arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts F: arch/arm64/boot/dts/amlogic/gxl_p400_2g.dts F: arch/arm64/boot/dts/amlogic/gxl_p401_2g.dts F: arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts @@ -13981,3 +13989,7 @@ M: jiaxing.ye F: driver/amlogic/ddr_window/Makefile F: driver/amlogic/ddr_window/ddr_window.c F: driver/amlogic/ddr_window/Kconfig + +AMLOGIC AUDIO INFO +M: wang xing +F: drivers/amlogic/audioinfo/ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts b/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts index f70a16ea8818..761b593be4cf 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts @@ -1180,7 +1180,9 @@ &efuse { status = "ok"; }; - +&audio_data{ + status = "okay"; +}; &spicc{ status = "disabled"; pinctrl-names = "spicc_pulldown","spicc_pullup"; diff --git a/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts b/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts index c9a6250c5022..c1792291b151 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts @@ -1180,3 +1180,6 @@ &efuse { status = "ok"; }; +&audio_data{ + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts b/arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts new file mode 100644 index 000000000000..f1d51f13cb42 --- /dev/null +++ b/arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts @@ -0,0 +1,1174 @@ +/* + * arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts + * + * Copyright (C) 2017 Amlogic, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + */ + +/dts-v1/; + +#include +#include "mesongxl.dtsi" +/ { + model = "Amlogic"; + amlogic-dt-id = "gxl_p230_2g"; + compatible = "amlogic, Gxl"; + interrupt-parent = <&gic>; + #address-cells = <2>; + #size-cells = <2>; + + aliases { + serial0 = &uart_AO; + serial1 = &uart_A; + serial2 = &uart_B; + serial3 = &uart_C; + serial4 = &uart_AO_B; + }; + + ion_dev { + compatible = "amlogic, ion_dev"; + memory-region = <&ion_reserved>; + }; + + memory@00000000 { + device_type = "memory"; + linux,usable-memory = <0x0 0x0100000 0x0 0x7ff00000>; + }; + + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + /* global autoconfigured region for contiguous allocations */ + secmon_reserved:linux,secmon { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x400000>; + alignment = <0x0 0x400000>; + alloc-ranges = <0x0 0x05000000 0x0 0x400000>; + }; + secos_reserved:linux,secos { + status = "disable"; + compatible = "amlogic, aml_secos_memory"; + reg = <0x0 0x05300000 0x0 0x2000000>; + no-map; + }; + fb_reserved:linux,meson-fb { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000000>; + alignment = <0x0 0x400000>; + alloc-ranges = <0x0 0x7e000000 0x0 0x2000000>; + }; + + //di_reserved:linux,di { + // compatible = "amlogic, di-mem"; + /** 10x3133440=30M(0x1e) support 8bit **/ + // size = <0x0 0x1e00000>; + //no-map; + //}; + di_cma_reserved:linux,di_cma { + compatible = "shared-dma-pool"; + reusable; + /** 10x3133440=30M(0x1e) support 8bit **/ + size = <0x0 0x2000000>; + alignment = <0x0 0x400000>; + }; + + ion_reserved:linux,ion-dev { + compatible = "amlogic, idev-mem"; + size = <0x0 0x0>; + }; + + /* vdin0 CMA pool */ + //vdin0_cma_reserved:linux,vdin0_cma { + // compatible = "shared-dma-pool"; + // linux,phandle = <4>; + // reusable; + /* 1920x1080x2x4 =16+4 M */ + // size = <0x0 0x01400000>; + // alignment = <0x0 0x400000>; + //}; + /* vdin1 CMA pool */ + vdin1_cma_reserved:linux,vdin1_cma { + compatible = "shared-dma-pool"; + reusable; + /* 1920x1080x2x4 =16 M */ + size = <0x0 0x01000000>; + alignment = <0x0 0x400000>; + }; + /* POST PROCESS MANAGER */ + ppmgr_reserved:linux,ppmgr { + compatible = "shared-dma-pool"; + size = <0x0 0x0>; + }; + + codec_mm_cma:linux,codec_mm_cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x10400000>; + alignment = <0x0 0x400000>; + linux,contiguous-region; + }; + picdec_cma_reserved:linux,picdec { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x0>; + alignment = <0x0 0x0>; + linux,contiguous-region; + }; + /* codec shared reserved */ + codec_mm_reserved:linux,codec_mm_reserved { + compatible = "amlogic, codec-mm-reserved"; + size = <0x0 0x0>; + alignment = <0x0 0x100000>; + //no-map; + }; + }; + + wifi{ + compatible = "amlogic, aml_wifi"; + dev_name = "aml_wifi"; + status = "okay"; + interrupt_pin = <&gpio GPIOX_7 GPIO_ACTIVE_HIGH>; + interrupts = < 0 68 4>; + irq_trigger_type = "GPIO_IRQ_LOW"; + power_on_pin = <&gpio GPIOX_6 GPIO_ACTIVE_HIGH>; + pinctrl-names = "wifi_32k_pins"; + pinctrl-0 = <&wifi_32k_pins>; + pwm_config = <&wifi_pwm_conf>; + }; + + wifi_pwm_conf:wifi_pwm_conf{ + pwm_channel1 = ; + pwm_channel2 = ; + pwm_channel1_conf = <30541 15270 6>; + pwm_channel2_conf = <30518 15259 9>; + }; + + sd_emmc_c: emmc@d0074000 { + status = "okay"; + compatible = "amlogic, meson-aml-mmc"; + reg = <0x0 0xd0074000 0x0 0x2000>; + interrupts = <0 218 1>; + pinctrl-names = "emmc_clk_cmd_pins", "emmc_all_pins"; + pinctrl-0 = <&emmc_clk_cmd_pins>; + pinctrl-1 = <&emmc_conf_pull_up &emmc_conf_pull_done>; + clocks = <&clkc CLKID_SD_EMMC_C>, + <&clkc CLKID_SD_EMMC_C_P0_COMP>, + <&clkc CLKID_FCLK_DIV2>; + clock-names = "core", "clkin0", "clkin1"; + + bus-width = <8>; + cap-sd-highspeed; + cap-mmc-highspeed; + mmc-ddr-1_8v; + mmc-hs200-1_8v; + + max-frequency = <200000000>; + non-removable; + disable-wp; + emmc { + status = "disabled"; + pinname = "emmc"; + ocr_avail = <0x200080>; /**VDD voltage 3.3 ~ 3.4 */ + caps = "MMC_CAP_8_BIT_DATA", + "MMC_CAP_MMC_HIGHSPEED", + "MMC_CAP_SD_HIGHSPEED", + "MMC_CAP_NONREMOVABLE", + "MMC_CAP_1_8V_DDR", + "MMC_CAP_HW_RESET", + "MMC_CAP_ERASE", + "MMC_CAP_CMD23"; + caps2 = "MMC_CAP2_HS200", "MMC_CAP2_HS400"; + f_min = <300000>; + f_max = <100000000>; + max_req_size = <0x20000>; /**128KB*/ + gpio_dat3 = <&gpio BOOT_3 GPIO_ACTIVE_HIGH>; + hw_reset = <&gpio BOOT_9 GPIO_ACTIVE_HIGH>; + card_type = <1>; + /* 1:mmc card(include eMMC), + * 2:sd card(include tSD) + */ + }; + }; + + sd_emmc_b:sd@d0072000 { + status = "okay"; + compatible = "amlogic, meson-aml-mmc"; + reg = <0x0 0xd0072000 0x0 0x2000>; + interrupts = <0 217 1>; + pinctrl-names = "sd_all_pins", + "sd_clk_cmd_pins", + "sd_clk_cmd_uart_pins", + "sd_to_ao_uart_pins", + "ao_to_sd_uart_pins"; + pinctrl-0 = <&sd_all_pins>; + pinctrl-1 = <&sd_clk_cmd_pins>; + pinctrl-2 = <&sd_clk_cmd_pins &ao_to_sd_uart_pins>; + pinctrl-3 = <&sd_to_ao_uart_pins>; + pinctrl-4 = <&ao_to_sd_uart_pins>; + clocks = <&clkc CLKID_SD_EMMC_B>, + <&clkc CLKID_SD_EMMC_B_P0_COMP>, + <&clkc CLKID_FCLK_DIV2>; + clock-names = "core", "clkin0", "clkin1"; + + bus-width = <4>; + cap-sd-highspeed; + max-frequency = <100000000>; + disable-wp; + sd { + status = "disabled"; + pinname = "sd"; + ocr_avail = <0x200080>; /**VDD voltage 3.3 ~ 3.4 */ + caps = "MMC_CAP_4_BIT_DATA", + "MMC_CAP_MMC_HIGHSPEED", + "MMC_CAP_SD_HIGHSPEED"; + /* "MMC_CAP_UHS_SDR12", + * "MMC_CAP_UHS_SDR25", + * "MMC_CAP_UHS_SDR50", + * "MMC_CAP_UHS_SDR104"; + */ + f_min = <400000>; + f_max = <100000000>; + max_req_size = <0x20000>; /**128KB*/ + gpio_dat3 = <&gpio CARD_4 GPIO_ACTIVE_HIGH>; + jtag_pin = <&gpio CARD_0 GPIO_ACTIVE_HIGH>; + gpio_cd = <&gpio CARD_6 GPIO_ACTIVE_HIGH>; + card_type = <5>; + /* 0:unknown, + * 1:mmc card(include eMMC), + * 2:sd card(include tSD), + * 3:sdio device(ie:sdio-wifi), + * 4:SD combo (IO+mem) card, + * 5:NON sdio device(means sd/mmc card), + * other:reserved + */ + }; + }; + + sd_emmc_a:sdio@d0070000 { + status = "okay"; + compatible = "amlogic, meson-aml-mmc"; + reg = <0x0 0xd0070000 0x0 0x2000>; + interrupts = <0 216 4>; + pinctrl-names = "sdio_clk_cmd_pins", "sdio_all_pins"; + pinctrl-0 = <&sdio_clk_cmd_pins>; + pinctrl-1 = <&sdio_all_pins>; + clocks = <&clkc CLKID_SD_EMMC_A>, + <&clkc CLKID_SD_EMMC_A_P0_COMP>, + <&clkc CLKID_FCLK_DIV2>; + clock-names = "core", "clkin0", "clkin1"; + + bus-width = <4>; + cap-sd-highspeed; + cap-mmc-highspeed; + max-frequency = <100000000>; + non-removable; + disable-wp; + sdio { + status = "disabled"; + pinname = "sdio"; + ocr_avail = <0x200080>; /**VDD voltage 3.3 ~ 3.4 */ + caps = "MMC_CAP_4_BIT_DATA", + "MMC_CAP_MMC_HIGHSPEED", + "MMC_CAP_SD_HIGHSPEED", + "MMC_CAP_NONREMOVABLE", + "MMC_CAP_UHS_SDR12", + "MMC_CAP_UHS_SDR25", + "MMC_CAP_UHS_SDR50", + "MMC_CAP_UHS_SDR104", + "MMC_PM_KEEP_POWER", + "MMC_CAP_SDIO_IRQ"; + f_min = <400000>; + f_max = <200000000>; + max_req_size = <0x20000>; /**128KB*/ + card_type = <3>; + /* 3:sdio device(ie:sdio-wifi), + * 4:SD combo (IO+mem) card + */ + }; + }; + mtd_nand{ + compatible = "amlogic, aml_mtd_nand"; + dev_name = "mtdnand"; + status = "disabled"; + reg = <0x0 0xd0074800 0x0 0x200>; + interrupts = < 0 34 1 >; + pinctrl-names = "nand_rb_mod","nand_norb_mod", "nand_cs_only"; + pinctrl-0 = <&all_nand_pins>; + pinctrl-1 = <&all_nand_pins>; + pinctrl-2 = <&nand_cs_pins>; + device_id = <0>; + plat-names = "bootloader","nandnormal"; + plat-num = <2>; + plat-part-0 = <&bootloader>; + plat-part-1 = <&nandnormal>; + bootloader: bootloader{ + enable_pad ="ce0"; + busy_pad = "rb0"; + timming_mode = "mode5"; + bch_mode = "bch60_1k"; + t_rea = <20>; + t_rhoh = <15>; + chip_num = <1>; + part_num = <0>; + rb_detect = <1>; + }; + nandnormal: nandnormal{ + enable_pad ="ce0","ce1"; + busy_pad = "rb0","rb1"; + timming_mode = "mode5"; + bch_mode = "bch60_1k"; + plane_mode = "twoplane"; + t_rea = <20>; + t_rhoh = <15>; + chip_num = <2>; + part_num = <3>; + partition = <&nand_partitions>; + rb_detect = <1>; + }; + nand_partitions:nand_partition{ + boot{ + offset=<0x0 0x300000>; + size=<0x0 0x800000>; + }; + /* + *recovery{ + * offset=<0x0 0xB00000>; + * size=<0x0 0xA00000>; + *}; + */ + upgrade{ + offset=<0x0 0xB00000>; + size=<0x0 0x5800000>; + }; + data{ + offset=<0xffffffff 0xffffffff>; + size=<0x0 0x0>; + }; + }; + }; + + ethmac: ethernet@0xc9410000 { + compatible = "amlogic, gxbb-eth-dwmac"; + reg = <0x0 0xc9410000 0x0 0x10000 + 0x0 0xc8834540 0x0 0x8 + 0x0 0xc8834558 0x0 0xc>; + interrupts = <0 8 1>; + pinctrl-names = "external_eth_pins"; + pinctrl-0 = <&external_eth_pins>; + rst_pin-gpios = <&gpio GPIOZ_14 0>; + GPIOZ4_pin-gpios = <&gpio GPIOZ_4 0>; + GPIOZ5_pin-gpios = <&gpio GPIOZ_5 0>; + mc_val_internal_phy = <0x1800>; + mc_val_external_phy = <0x1621>; + cali_val = <0x20000>; + interrupt-names = "macirq"; + clocks = <&clkc CLKID_ETH>; + clock-names = "ethclk81"; + internal_phy=<0>; + }; + + codec_io { + compatible = "amlogic, codec_io"; + #address-cells=<2>; + #size-cells=<2>; + ranges; + io_cbus_base{ + reg = <0x0 0xC1100000 0x0 0x100000>; + }; + io_dos_base{ + reg = <0x0 0xc8820000 0x0 0x10000>; + }; + io_hiubus_base{ + reg = <0x0 0xc883c000 0x0 0x2000>; + }; + io_aobus_base{ + reg = <0x0 0xc8100000 0x0 0x100000>; + }; + io_vcbus_base{ + reg = <0x0 0xd0100000 0x0 0x40000>; + }; + io_dmc_base{ + reg = <0x0 0xc8838000 0x0 0x400>; + }; + }; + + codec_mm { + compatible = "amlogic, codec, mm"; + memory-region = <&codec_mm_cma &codec_mm_reserved>; + dev_name = "codec_mm"; + status = "okay"; + }; + + canvas{ + compatible = "amlogic, meson, canvas"; + dev_name = "amlogic-canvas"; + status = "ok"; + reg = <0x0 0xc8838000 0x0 0x400>; + }; + + mesonstream { + compatible = "amlogic, codec, streambuf"; + dev_name = "mesonstream"; + status = "okay"; + clocks = <&clkc CLKID_DOS_PARSER + &clkc CLKID_DEMUX + &clkc CLKID_DOS + &clkc CLKID_VDEC_MUX + &clkc CLKID_HCODEC_MUX + &clkc CLKID_HEVC_MUX>; + clock-names = "parser_top", + "demux", + "vdec", + "clk_vdec_mux", + "clk_hcodec_mux", + "clk_hevc_mux"; + }; + + vdec { + compatible = "amlogic, vdec"; + dev_name = "vdec.0"; + status = "okay"; + interrupts = <0 3 1 + 0 23 1 + 0 32 1 + 0 43 1 + 0 44 1 + 0 45 1>; + interrupt-names = "vsync", + "demux", + "parser", + "mailbox_0", + "mailbox_1", + "mailbox_2"; + }; + + aml_sensor0: aml-sensor@0 { + compatible = "amlogic, aml-thermal"; + device_name = "thermal"; + #thermal-sensor-cells = <1>; + cooling_devices { + cpufreq_cool_cluster0 { + min_state = <1000000>; + dyn_coeff = <140>; + cluster_id = <0>; + node_name = "cpufreq_cool0"; + device_type = "cpufreq"; + }; + cpucore_cool_cluster0 { + min_state = <1>; + dyn_coeff = <0>; + cluster_id = <0>; + node_name = "cpucore_cool0"; + device_type = "cpucore"; + }; + gpufreq_cool { + min_state = <400>; + dyn_coeff = <437>; + cluster_id = <0>; + node_name = "gpufreq_cool0"; + device_type = "gpufreq"; + }; + gpucore_cool { + min_state = <1>; + dyn_coeff = <0>; + cluster_id = <0>; + node_name = "gpucore_cool0"; + device_type = "gpucore"; + }; + }; + cpufreq_cool0:cpufreq_cool0 { + #cooling-cells = <2>; /* min followed by max */ + }; + cpucore_cool0:cpucore_cool0 { + #cooling-cells = <2>; /* min followed by max */ + }; + gpufreq_cool0:gpufreq_cool0 { + #cooling-cells = <2>; /* min followed by max */ + }; + gpucore_cool0:gpucore_cool0 { + #cooling-cells = <2>; /* min followed by max */ + }; + }; + thermal-zones { + soc_thermal { + polling-delay = <1000>; + polling-delay-passive = <100>; + sustainable-power = <2150>; + + thermal-sensors = <&aml_sensor0 3>; + + trips { + switch_on: trip-point@0 { + temperature = <70000>; + hysteresis = <1000>; + type = "passive"; + }; + control: trip-point@1 { + temperature = <80000>; + hysteresis = <1000>; + type = "passive"; + }; + hot: trip-point@2 { + temperature = <85000>; + hysteresis = <5000>; + type = "hot"; + }; + critical: trip-point@3 { + temperature = <260000>; + hysteresis = <1000>; + type = "critical"; + }; + }; + + cooling-maps { + cpufreq_cooling_map { + trip = <&control>; + cooling-device = <&cpufreq_cool0 0 4>; + contribution = <1024>; + }; + cpucore_cooling_map { + trip = <&control>; + cooling-device = <&cpucore_cool0 0 3>; + contribution = <1024>; + }; + gpufreq_cooling_map { + trip = <&control>; + cooling-device = <&gpufreq_cool0 0 4>; + contribution = <1024>; + }; + gpucore_cooling_map { + trip = <&control>; + cooling-device = <&gpucore_cool0 0 2>; + contribution = <1024>; + }; + }; + }; + }; + + dwc3: dwc3@c9000000 { + compatible = "synopsys, dwc3"; + reg = <0x0 0xc9000000 0x0 0x100000>; + interrupts = <0 30 4>; + usb-phy = <&usb2_phy>, <&usb3_phy>; + cpu-type = "gxl"; + clock-src = "usb3.0"; + }; + + usb2_phy: usb2phy@d0078000 { + compatible = "amlogic, amlogic-new-usb2"; + portnum = <3>; + reg = <0x0 0xd0078000 0x0 0x80>; + }; + + usb3_phy: usb3phy@d0078080 { + compatible = "amlogic, amlogic-new-usb3"; + portnum = <0>; + reg = <0x0 0xd0078080 0x0 0x20>; + }; + + dwc2_a { + compatible = "amlogic, dwc2"; + device_name = "dwc2_a"; + reg = <0x0 0xc9100000 0x0 0x40000>; + status = "okay"; + interrupts = <0 31 4>; + pl-periph-id = <0>; /** lm name */ + clock-src = "usb0"; /** clock src */ + port-id = <0>; /** ref to mach/usb.h */ + port-type = <2>; /** 0: otg, 1: host, 2: slave */ + port-speed = <0>; /** 0: default, high, 1: full */ + port-config = <0>; /** 0: default */ + port-dma = <0>; /** 0: default ... 6: disable*/ + port-id-mode = <0>; /** 0: hardware, 1: sw_host, 2: sw_slave*/ + usb-fifo = <728>; + cpu-type = "gxl"; + controller-type = <3>; /** 0: normal,1:host,2:device,3:otg*/ + phy-reg = <0xd0078000>; + phy-reg-size = <0xa0>; + clocks = <&clkc CLKID_USB_GENERAL + &clkc CLKID_USB1_TO_DDR + &clkc CLKID_USB1>; + clock-names = "usb_general", + "usb1", + "usb1_to_ddr"; + }; + + meson-amvideom { + compatible = "amlogic, amvideom"; + dev_name = "amvideom"; + status = "okay"; + interrupts = <0 3 1>; + interrupt-names = "vsync"; + }; + + vout { + compatible = "amlogic, vout"; + dev_name = "vout"; + status = "okay"; + fr_auto_policy = <0>; + }; + + cvbsout { + compatible = "amlogic, cvbsout"; + dev_name = "cvbsout"; + status = "okay"; + }; + + amhdmitx: amhdmitx{ + compatible = "amlogic, amhdmitx"; + dev_name = "amhdmitx"; + status = "okay"; + vend-data = <&vend_data>; + pinctrl-names="hdmitx_hpd", "hdmitx_ddc"; + pinctrl-0=<&hdmitx_hpd>; + pinctrl-1=<&hdmitx_ddc>; + /* HPD, 57 + 32 = 89; CEC, 151 + 32 = 183*/ + interrupts = <0 57 1>; + interrupt-names = "hdmitx_hpd"; + vend_data: vend_data{ /* Should modified by Customer */ + vendor_name = "Amlogic"; /* Max Chars: 8 */ + /* standards.ieee.org/develop/regauth/oui/oui.txt */ + vendor_id = <0x000000>; + product_desc = "MBox Meson Ref"; /* Max Chars: 16 */ + }; + }; + + aocec: aocec{ + compatible = "amlogic, amlogic-aocec"; + device_name = "aocec"; + status = "okay"; + vendor_id = <0x000000>; + cec_osd_string = "MBox"; /* Max Chars: 14 */ + cec_version = <6>; /* 5: 1.4, 6: 2.0 */ + port_num = <1>; + arc_port_mask = <0x0>; + interrupts = <0 199 1>; + interrupt-names = "hdmi_aocec"; + pinctrl-names = "hdmitx_aocec"; + pinctrl-0=<&hdmitx_aocec>; + reg = <0x0 0xc810023c 0x0 0x4 + 0x0 0xc8100000 0x0 0x200>; + }; + + sysled { + compatible = "amlogic, sysled"; + dev_name = "sysled"; + status = "okay"; + led_gpio = <&gpio GPIODV_24 GPIO_ACTIVE_HIGH>; + led_active_low = <1>; + }; + + meson-fb { + compatible = "amlogic, meson-fb"; + memory-region = <&fb_reserved>; + dev_name = "meson-fb"; + status = "okay"; + interrupts = <0 3 1 + 0 89 1>; + interrupt-names = "viu-vsync", "rdma"; + mem_size = <0x006AF000 0x01851000 0x00100000>; + /* uboot logo,fb0/fb1 memory size */ + display_mode_default = "1080p60hz"; + scale_mode = <1>; + /** 0:VPU free scale 1:OSD free scale 2:OSD super scale */ + display_size_default = <1920 1080 1920 3240 32>; + /*1920*1080*4*3 = 0x17BB000*/ + logo_addr = "0x7e000000"; + }; + ge2d { + compatible = "amlogic, ge2d"; + dev_name = "ge2d"; + status = "okay"; + interrupts = <0 150 1>; + interrupt-names = "ge2d"; + clocks = <&clkc CLKID_VAPB_MUX>, + <&clkc CLKID_GE2D_GATE>, + <&clkc CLKID_G2D>; + clock-names = "clk_vapb_0", + "clk_ge2d", + "clk_ge2d_gate"; + }; + + + /* AUDIO MESON DEVICES */ + i2s_dai: I2S { + #sound-dai-cells = <0>; + compatible = "amlogic, aml-i2s-dai"; + clocks = + <&clkc CLKID_MPLL2>, + <&clkc CLKID_AMCLK_COMP>, + <&clkc CLKID_AIU_GLUE>, + <&clkc CLKID_IEC958>, + <&clkc CLKID_I2S_OUT>, + <&clkc CLKID_AMCLK>, + <&clkc CLKID_AIFIFO2>, + <&clkc CLKID_MIXER>, + <&clkc CLKID_MIXER_IFACE>, + <&clkc CLKID_ADC>, + <&clkc CLKID_AIU_TOP>, + <&clkc CLKID_AOCLK_GATE>, + <&clkc CLKID_I2S_SPDIF>; + clock-names = + "mpll2", + "mclk", + "top_glue", + "aud_buf", + "i2s_out", + "amclk_measure", + "aififo2", + "aud_mixer", + "mixer_reg", + "adc", + "top_level", + "aoclk", + "aud_in"; + i2s_pos_sync = <0>; + /*DMIC;*/ /* I2s Mic or Dmic, default for I2S mic */ + }; + dmic:snd_dmic { + #sound-dai-cells = <0>; + compatible = "aml, aml_snd_dmic"; + reg = <0x0 0xd0042000 0x0 0x2000>; + status = "okay"; + resets = < + &clkc CLKID_PDM_GATE + >; + reset-names = "pdm"; + pinctrl-names = "aml_dmic_pins"; + pinctrl-0 = <&aml_dmic_pins>; + clocks = <&clkc CLKID_PDM_COMP>, + <&clkc CLKID_AMCLK_COMP>; + clock-names = "pdm", "mclk"; + }; + spdif_dai: SPDIF { + #sound-dai-cells = <0>; + compatible = "amlogic, aml-spdif-dai"; + clocks = + <&clkc CLKID_MPLL1>, + <&clkc CLKID_I958_COMP>, + <&clkc CLKID_AMCLK_COMP>, + <&clkc CLKID_I958_COMP_SPDIF>, + <&clkc CLKID_CLK81>, + <&clkc CLKID_IEC958>, + <&clkc CLKID_IEC958_GATE>; + clock-names = + "mpll1", + "i958", + "mclk", + "spdif", + "clk_81", + "iec958", + "iec958_amclk"; + }; + pcm_dai: PCM { + #sound-dai-cells = <0>; + compatible = "amlogic, aml-pcm-dai"; + pinctrl-names = "aml_audio_pcm"; + pinctrl-0 = <&audio_pcm_pins>; + clocks = + <&clkc CLKID_MPLL0>, + <&clkc CLKID_PCM_MCLK_COMP>, + <&clkc CLKID_PCM_SCLK_GATE>; + clock-names = + "mpll0", + "pcm_mclk", + "pcm_sclk"; + pcm_mode = <1>; /* 0=slave mode, 1=master mode */ + }; + i2s_plat: i2s_platform { + compatible = "amlogic, aml-i2s"; + interrupts = <0 29 1>; + }; + pcm_plat: pcm_platform { + compatible = "amlogic, aml-pcm"; + }; + spdif_codec: spdif_codec{ + #sound-dai-cells = <0>; + compatible = "amlogic, aml-spdif-codec"; + pinctrl-names = "aml_audio_spdif"; + pinctrl-0 = <&audio_spdif_pins>; + }; + pcm_codec: pcm_codec{ + #sound-dai-cells = <0>; + compatible = "amlogic, pcm2BT-codec"; + }; + /* endof AUDIO MESON DEVICES */ + + /* AUDIO board specific */ + dummy_codec:dummy{ + #sound-dai-cells = <0>; + compatible = "amlogic, aml_dummy_codec"; + status = "disable"; + }; + amlogic_codec:t9015{ + #sound-dai-cells = <0>; + compatible = "amlogic, aml_codec_T9015"; + reg = <0x0 0xc8832000 0x0 0x14>; + status = "okay"; + }; + aml_sound_meson { + compatible = "aml, meson-snd-card"; + status = "okay"; + aml-sound-card,format = "i2s"; + aml_sound_card,name = "AML-MESONAUDIO"; + aml,audio-routing = + "Ext Spk","LOUTL", + "Ext Spk","LOUTR"; + + mute_gpio-gpios = <&gpio GPIOH_5 0>; + mute_inv; + hp_disable; + hp_paraments = <800 300 0 5 1>; + pinctrl-names = "aml_audio_i2s"; + pinctrl-0 = <&audio_i2s_pins>; + cpu_list = <&cpudai0 &cpudai1 &cpudai2>; + codec_list = <&codec0 &codec1 &codec2>; + plat_list = <&i2s_plat &i2s_plat &pcm_plat>; + cpudai0: cpudai0 { + sound-dai = <&i2s_dai>; + }; + cpudai1: cpudai1 { + sound-dai = <&spdif_dai>; + }; + cpudai2: cpudai2 { + sound-dai = <&pcm_dai>; + }; + codec0: codec0 { + sound-dai = <&amlogic_codec>; + }; + codec1: codec1 { + sound-dai = <&spdif_codec>; + }; + codec2: codec2 { + sound-dai = <&pcm_codec>; + }; + }; + /* END OF AUDIO board specific */ + rdma{ + compatible = "amlogic, meson, rdma"; + dev_name = "amlogic-rdma"; + status = "ok"; + interrupts = <0 89 1>; + interrupt-names = "rdma"; + }; + + amvenc_avc{ + compatible = "amlogic, amvenc_avc"; + dev_name = "amvenc_avc"; + status = "okay"; + interrupts = <0 45 1>; + interrupt-names = "mailbox_2"; + }; + + hevc_enc{ + compatible = "cnm, HevcEnc"; + dev_name = "HevcEnc"; + status = "okay"; + interrupts = <0 187 1>; + interrupt-names = "wave420l_irq"; + #address-cells=<2>; + #size-cells=<2>; + ranges; + io_reg_base{ + reg = <0x0 0xc8810000 0x0 0x4000>; + }; + }; + + partitions: partitions{ + parts = <11>; + part-0 = <&logo>; + part-1 = <&recovery>; + part-2 = <&rsv>; + part-3 = <&tee>; + part-4 = <&crypt>; + part-5 = <&misc>; + part-6 = <&instaboot>; + part-7 = <&boot>; + part-8 = <&system>; + part-9 = <&cache>; + part-10 = <&data>; + + logo:logo{ + pname = "logo"; + size = <0x0 0x2000000>; + mask = <1>; + }; + recovery:recovery{ + pname = "recovery"; + size = <0x0 0x2000000>; + mask = <1>; + }; + rsv:rsv{ + pname = "rsv"; + size = <0x0 0x800000>; + mask = <1>; + }; + tee:tee{ + pname = "tee"; + size = <0x0 0x800000>; + mask = <1>; + }; + crypt:crypt{ + pname = "crypt"; + size = <0x0 0x2000000>; + mask = <1>; + }; + misc:misc{ + pname = "misc"; + size = <0x0 0x2000000>; + mask = <1>; + }; + instaboot:instaboot{ + pname = "instaboot"; + size = <0x0 0x400000>; + mask = <1>; + }; + boot:boot + { + pname = "boot"; + size = <0x0 0x2000000>; + mask = <1>; + }; + system:system + { + pname = "system"; + size = <0x0 0x80000000>; + mask = <1>; + }; + cache:cache + { + pname = "cache"; + size = <0x0 0x20000000>; + mask = <2>; + }; + data:data + { + pname = "data"; + size = <0xffffffff 0xffffffff>; + mask = <4>; + }; + }; + + ppmgr { + compatible = "amlogic, ppmgr"; + memory-region = <&ppmgr_reserved>; + dev_name = "ppmgr"; + status = "okay"; + }; + + deinterlace { + compatible = "amlogic, deinterlace"; + status = "okay"; + flag_cma = <1>;/*0:use reserved;1:use cma*/ + //memory-region = <&di_reserved>; + memory-region = <&di_cma_reserved>; + interrupts = <0 46 1 0 6 1>; + interrupt-names = "de_irq", "timerc"; + /* + * nr_size(byte) = 1920*544*2(yuv422 8bit) | + * 1920*544*2*12/8(yuv422 10bit) + * | 1920*544*2*10/8(yuv422 10bit full pack mode) + */ + /* mtn_size(byte) = 1920*544/2 */ + /* count_size(byte) = 1920*544/2 */ + buffer-size = <3133440>; + hw-version = <2>; + }; + + ionvideo { + compatible = "amlogic, ionvideo"; + dev_name = "ionvideo"; + status = "okay"; + }; + + amlvideo { + compatible = "amlogic, amlvideo"; + dev_name = "amlvideo"; + status = "okay"; + }; + + amlvideo2 { + compatible = "amlogic, amlvideo2"; + dev_name = "amlvideo2"; + status = "okay"; + cma_mode = <1>; + }; + + /*if you want to use vdin just modify status to "ok"*/ + vdin0 { + compatible = "amlogic, vdin"; + /*memory-region = <&vdin0_cma_reserved>;*/ + dev_name = "vdin0"; + status = "ok"; + reserve-iomap = "true"; + flag_cma = <1>;/*1:share with codec_mm;2:cma alone*/ + /*MByte, if 10bit disable: 64M(YUV422), + *if 10bit enable: 64*1.5 = 96M(YUV422) + *if support 4K2K-YUV444-10bit-WR:3840*2160*4*4 ~= 128M + *if support 4K2K-YUV422-10bit-wr:3840*2160*3*4 ~= 96M + *if support 4K2K-YUV422-8BIT-WR:3840*2160*2*4 ~= 64M + *if support 1080p-YUV422-8BIT-WR:1920*1080*2*4 ~= 16M + */ + cma_size = <16>; + interrupts = <0 83 1>; + rdma-irq = <2>; + /*clocks = <&clock CLK_FPLL_DIV5>, + * <&clock CLK_VDIN_MEAS_CLK>; + *clock-names = "fclk_div5", "cts_vdin_meas_clk"; + */ + vdin_id = <0>; + /*vdin write mem color depth support: + *bit0:support 8bit + *bit1:support 9bit + *bit2:support 10bit + *bit3:support 12bit + *bit4:support yuv422 10bit full pack mode (from txl new add) + */ + tv_bit_mode = <1>; + }; + vdin1 { + compatible = "amlogic, vdin"; + memory-region = <&vdin1_cma_reserved>; + dev_name = "vdin1"; + status = "ok"; + reserve-iomap = "true"; + flag_cma = <0>;/*1:share with codec_mm;0:cma alone*/ + interrupts = <0 85 1>; + rdma-irq = <4>; + /*clocks = <&clock CLK_FPLL_DIV5>, + * <&clock CLK_VDIN_MEAS_CLK>; + *clock-names = "fclk_div5", "cts_vdin_meas_clk"; + */ + vdin_id = <1>; + /*vdin write mem color depth support: + *bit0:support 8bit + *bit1:support 9bit + *bit2:support 10bit + *bit3:support 12bit + */ + tv_bit_mode = <1>; + }; + + amlvecm { + compatible = "amlogic, vecm"; + dev_name = "aml_vecm"; + status = "okay"; + gamma_en = <0>;/*1:enabel ;0:disable*/ + wb_en = <0>;/*1:enabel ;0:disable*/ + cm_en = <0>;/*1:enabel ;0:disable*/ + }; + + unifykey{ + compatible = "amlogic, unifykey"; + status = "ok"; + + unifykey-num = <14>; + unifykey-index-0 = <&keysn_0>; + unifykey-index-1 = <&keysn_1>; + unifykey-index-2 = <&keysn_2>; + unifykey-index-3 = <&keysn_3>; + unifykey-index-4 = <&keysn_4>; + unifykey-index-5 = <&keysn_5>; + unifykey-index-6 = <&keysn_6>; + unifykey-index-7 = <&keysn_7>; + unifykey-index-8 = <&keysn_8>; + unifykey-index-9 = <&keysn_9>; + unifykey-index-10= <&keysn_10>; + unifykey-index-11= <&keysn_11>; + unifykey-index-12= <&keysn_12>; + unifykey-index-13= <&keysn_13>; + + keysn_0: key_0{ + key-name = "usid"; + key-device = "normal"; + key-permit = "read","write","del"; + }; + keysn_1:key_1{ + key-name = "mac"; + key-device = "normal"; + key-permit = "read","write","del"; + }; + keysn_2:key_2{ + key-name = "hdcp"; + key-device = "secure"; + key-type = "sha1"; + key-permit = "read","write","del"; + }; + keysn_3:key_3{ + key-name = "secure_boot_set"; + key-device = "efuse"; + key-permit = "write"; + }; + keysn_4:key_4{ + key-name = "mac_bt"; + key-device = "normal"; + key-permit = "read","write","del"; + key-type = "mac"; + }; + keysn_5:key_5{ + key-name = "mac_wifi"; + key-device = "normal"; + key-permit = "read","write","del"; + key-type = "mac"; + }; + keysn_6:key_6{ + key-name = "hdcp2_tx"; + key-device = "normal"; + key-permit = "read","write","del"; + }; + keysn_7:key_7{ + key-name = "hdcp2_rx"; + key-device = "normal"; + key-permit = "read","write","del"; + }; + keysn_8:key_8{ + key-name = "widevinekeybox"; + key-device = "secure"; + key-permit = "read","write","del"; + }; + keysn_9:key_9{ + key-name = "deviceid"; + key-device = "normal"; + key-permit = "read","write","del"; + }; + keysn_10:key_10{ + key-name = "hdcp22_fw_private"; + key-device = "secure"; + key-permit = "read","write","del"; + }; + keysn_11:key_11{ + key-name = "PlayReadykeybox25"; + key-device = "secure"; + key-permit = "read","write","del"; + }; + keysn_12:key_12{ + key-name = "prpubkeybox";// PlayReady + key-device = "secure"; + key-permit = "read","write","del"; + }; + keysn_13:key_13{ + key-name = "prprivkeybox";// PlayReady + key-device = "secure"; + key-permit = "read","write","del"; + }; + };//End unifykey +}; +&efuse { + status = "ok"; +}; +&audio_data{ + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts b/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts index e55a0a62c20f..6b0edc94f629 100644 --- a/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts +++ b/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts @@ -1197,7 +1197,9 @@ &efuse { status = "ok"; }; - +&audio_data{ + status = "okay"; +}; &i2c_b { status = "okay"; }; diff --git a/arch/arm64/boot/dts/amlogic/mesongxl.dtsi b/arch/arm64/boot/dts/amlogic/mesongxl.dtsi index 58e321483802..25745c5b8ba9 100644 --- a/arch/arm64/boot/dts/amlogic/mesongxl.dtsi +++ b/arch/arm64/boot/dts/amlogic/mesongxl.dtsi @@ -1010,6 +1010,12 @@ i2c_ao: i2c@c8100500{ /*I2C-AO*/ reg = <0x0 0xc883e000 0x0 0x28>; }; + audio_data:audio_data { + compatible = "amlogic, audio_data"; + query_licence_cmd = <0x82000050>; + status = "disabled"; + }; + saradc: saradc { compatible = "amlogic,meson-gxl-saradc"; status = "okay"; diff --git a/arch/arm64/boot/dts/amlogic/mesongxm.dtsi b/arch/arm64/boot/dts/amlogic/mesongxm.dtsi index 997ca6b945f9..89ffa0f857bf 100644 --- a/arch/arm64/boot/dts/amlogic/mesongxm.dtsi +++ b/arch/arm64/boot/dts/amlogic/mesongxm.dtsi @@ -1138,6 +1138,12 @@ reg = <0x0 0xc883e000 0x0 0x28>; }; + audio_data:audio_data { + compatible = "amlogic, audio_data"; + query_licence_cmd = <0x82000050>; + status = "disabled"; + }; + saradc: saradc { compatible = "amlogic,meson-gxl-saradc"; status = "okay"; diff --git a/arch/arm64/configs/meson64_defconfig b/arch/arm64/configs/meson64_defconfig index 2c866277f4a1..ef74ee00d1ca 100644 --- a/arch/arm64/configs/meson64_defconfig +++ b/arch/arm64/configs/meson64_defconfig @@ -258,6 +258,7 @@ CONFIG_AMLOGIC_CPUCORE_THERMAL=y CONFIG_AMLOGIC_GPU_THERMAL=y CONFIG_AMLOGIC_GPUCORE_THERMAL=y CONFIG_AMLOGIC_AUDIO_DSP=y +CONFIG_AMLOGIC_AUDIO_INFO=y CONFIG_AMLOGIC_SUSPEND=y CONFIG_AMLOGIC_GX_SUSPEND=y CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND=y diff --git a/drivers/amlogic/Kconfig b/drivers/amlogic/Kconfig index 73df0b7e5b43..6cccc5acf21d 100644 --- a/drivers/amlogic/Kconfig +++ b/drivers/amlogic/Kconfig @@ -82,6 +82,8 @@ source "drivers/amlogic/thermal/Kconfig" source "drivers/amlogic/audiodsp/Kconfig" +source "drivers/amlogic/audioinfo/Kconfig" + source "drivers/amlogic/pm/Kconfig" source "drivers/amlogic/led/Kconfig" diff --git a/drivers/amlogic/Makefile b/drivers/amlogic/Makefile index ed88417ffb13..198d21dc13e3 100644 --- a/drivers/amlogic/Makefile +++ b/drivers/amlogic/Makefile @@ -68,6 +68,8 @@ obj-$(CONFIG_AMLOGIC_TEMP_SENSOR) += thermal/ obj-$(CONFIG_AMLOGIC_AUDIO_DSP) += audiodsp/ +obj-$(CONFIG_AMLOGIC_AUDIO_INFO) += audioinfo/ + obj-$(CONFIG_AMLOGIC_SUSPEND) += pm/ obj-$(CONFIG_AMLOGIC_LED) += led/ diff --git a/drivers/amlogic/audioinfo/Kconfig b/drivers/amlogic/audioinfo/Kconfig new file mode 100644 index 000000000000..eb268818d3e9 --- /dev/null +++ b/drivers/amlogic/audioinfo/Kconfig @@ -0,0 +1,11 @@ +# audio info configuration +# +menu "AMLOGIC Audio Info" + +config AMLOGIC_AUDIO_INFO + tristate "audio info" + default n + help + support the amlogic audio info; + +endmenu diff --git a/drivers/amlogic/audioinfo/Makefile b/drivers/amlogic/audioinfo/Makefile new file mode 100644 index 000000000000..5dfb15a56a06 --- /dev/null +++ b/drivers/amlogic/audioinfo/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_AMLOGIC_AUDIO_INFO) += audio_data.o diff --git a/drivers/amlogic/audioinfo/audio_data.c b/drivers/amlogic/audioinfo/audio_data.c new file mode 100644 index 000000000000..10f0ee19382e --- /dev/null +++ b/drivers/amlogic/audioinfo/audio_data.c @@ -0,0 +1,295 @@ +/* + * drivers/amlogic/audioinfo/audio_data.c + * + * Copyright (C) 2017 Amlogic, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include "../efuse/efuse.h" +#include +#include +#include +#include +#include "audio_data.h" + +#ifdef CONFIG_MESON_TRUSTZONE +#include +#endif +#include +/*#define MYPRT pr_info*/ +#define MYPRT(...) +/* major device number and minor device number */ +static int major_audio_data; +/* device class and device var */ +static struct class *class_audio_data; +static struct device *dev_audio_data; +void __iomem *sharemem_input;/*used as input and output memory, may not ok*/ +unsigned int efuse_query_licence_cmd; + +static int audio_data_open(struct inode *inode, struct file *filp); +static int audio_data_release(struct inode *inode, struct file *filp); +static ssize_t audio_data_read(struct file *filp, char __user *buf, + size_t count, loff_t *f_pos); +static ssize_t audio_data_write(struct file *filp, const char __user *buf, + size_t count, loff_t *f_pos); + +/* device operation methods chart */ +static struct file_operations const audio_data_fops = { + .owner = THIS_MODULE, + .open = audio_data_open, + .release = audio_data_release, + .read = audio_data_read, + .write = audio_data_write, + /* .unlocked_ioctl = audio_data_ioctl, */ +}; + + +int meson_efuse_fn_smc_query_audioinfo(struct efuse_hal_api_arg *arg) +{ + int ret; + unsigned int cmd, offset, size; + unsigned long *retcnt; + + register unsigned x0 asm("x0"); + register unsigned x1 asm("x1"); + register unsigned x2 asm("x2"); + register unsigned x3 asm("x3"); + + if (!arg) + return -1; + if (!sharemem_input) + return -1; + + retcnt = (unsigned long *)(arg->retcnt); + cmd = arg->cmd; + offset = arg->offset; + size = arg->size; + + /*write data*/ + memcpy((void *)sharemem_input, (const void *)arg->buffer, size); + + asm __volatile__("" : : : "memory"); + x0 = cmd; + x1 = offset; + x2 = size; + x3 = 0; + + do { + asm volatile( + __asmeq("%0", "x0") + __asmeq("%1", "x0") + __asmeq("%2", "x1") + __asmeq("%3", "x2") + __asmeq("%4", "x3") + "smc #0\n" + : "=r"(x0) + : "r"(x0), "r"(x1), "r"(x2), "r"(x3)); + } while (0); + ret = x0; + *retcnt = x0; + MYPRT("[%s %d]ret/%d\n", __func__, __LINE__, ret); + + if (ret == 0) { + memset((void *)arg->buffer, 0, arg->size); + memcpy((void *)arg->buffer, + (const void *)sharemem_input, arg->size); + } + return ret; +} + +int meson_trustzone_audio_info_get(struct efuse_hal_api_arg *arg) +{ + int ret; + + if (!arg) + return -1; + set_cpus_allowed_ptr(current, cpumask_of(0)); + ret = meson_efuse_fn_smc_query_audioinfo(arg); + set_cpus_allowed_ptr(current, cpu_all_mask); + return ret; +} + +unsigned long audio_info_get(char *buf, unsigned long count, + unsigned long pos) +{ + struct efuse_hal_api_arg arg; + unsigned int retcnt; + int ret; + + arg.cmd = efuse_query_licence_cmd; + arg.offset = pos; + arg.size = count; + arg.buffer = (unsigned long)buf; + arg.retcnt = (unsigned long)&retcnt; + + sharemem_input = get_secmon_sharemem_input_base(); + ret = meson_trustzone_audio_info_get(&arg); + + if (ret == 0) + MYPRT("[%s %d]: get licence!!!\n", __func__, __LINE__); + else + MYPRT("[%s:%d]: read error!!!\n", __func__, __LINE__); + return ret; +} + + +#define EFUSE_BUF_SIZE 1024 +/* open device methods */ +static int audio_data_open(struct inode *inode, struct file *filp) +{ + MYPRT("[%s]\n", __func__); + return 0; +} + +/* device file release */ +static int audio_data_release(struct inode *inode, struct file *filp) +{ + MYPRT("[%s]\n", __func__); + return 0; +} + + +/* read device reg val */ +static ssize_t audio_data_read(struct file *filp, char __user *buf, + size_t count, loff_t *f_pos) +{ + int err = 0; + loff_t pos = 0; + char buftmp[EFUSE_BUF_SIZE] = {0}; + + MYPRT("[%s]\n", __func__); + if (count > EFUSE_BUF_SIZE) { + MYPRT("[%s %d]buffer is too small\n", __func__, __LINE__); + err = -1; + } else{ + err = copy_from_user(buftmp, buf, count); + if (!err) { + err = audio_info_get(buftmp, count, pos); + if (!err) { + MYPRT("[%s %d]copy data to user (count/%d)\n", + __func__, __LINE__, (int)count); + err = copy_to_user(buf, buftmp, count); + } else{ + err = -1; + } + } + } + if (!err) + return count; + else + return -1; +} + +/* write device reg val */ +static ssize_t audio_data_write(struct file *filp, const char __user *buf, + size_t count, loff_t *f_pos) +{ + return 0; +} + +static int audio_data_probe(struct platform_device *pdev) +{ + void *ptr_err; + + major_audio_data = register_chrdev(0, + AUDIO_DATA_DEVICE_NODE_NAME, + &audio_data_fops); + if (major_audio_data < 0) { + MYPRT("Registering audio_data char device %s failed with %d\n", + AUDIO_DATA_DEVICE_NODE_NAME, major_audio_data); + return major_audio_data; + } + class_audio_data = class_create(THIS_MODULE, + AUDIO_DATA_DEVICE_NODE_NAME); + ptr_err = class_audio_data; + if (IS_ERR(ptr_err)) + goto err0; + + dev_audio_data = device_create(class_audio_data, NULL, + MKDEV(major_audio_data, 0), + NULL, AUDIO_DATA_DEVICE_NODE_NAME); + ptr_err = dev_audio_data; + if (IS_ERR(ptr_err)) + goto err1; + if (pdev->dev.of_node) { + int ret; + struct device_node *np = pdev->dev.of_node; + + of_node_get(np); + ret = of_property_read_u32(np, "query_licence_cmd", + &efuse_query_licence_cmd); + if (ret) { + MYPRT("%s:please config query_cmd item\n", __func__); + return -1; + } + } + return 0; +err1: + class_destroy(class_audio_data); +err0: + unregister_chrdev(major_audio_data, AUDIO_DATA_DEVICE_NODE_NAME); + return PTR_ERR(ptr_err); + +} + +static int audio_data_remove(struct platform_device *pdev) +{ + unregister_chrdev_region(major_audio_data, 1); + device_destroy(class_audio_data, MKDEV(major_audio_data, 0)); + class_destroy(class_audio_data); + return 0; +} +static const struct of_device_id amlogic_audio_data_dt_match[] = { + { .compatible = "amlogic, audio_data", + }, + {}, +}; +static struct platform_driver audio_data_driver = { + .probe = audio_data_probe, + .remove = audio_data_remove, + .driver = { + .name = AUDIO_DATA_DEVICE_NODE_NAME, + .of_match_table = amlogic_audio_data_dt_match, + .owner = THIS_MODULE, + }, +}; +static int __init audio_data_init(void) +{ + int ret = -1; + + ret = platform_driver_register(&audio_data_driver); + if (ret != 0) { + MYPRT("failed to register audio data driver, error %d\n", ret); + return -ENODEV; + } + return ret; +} +/* module unload */ +static void __exit audio_data_exit(void) +{ + platform_driver_unregister(&audio_data_driver); +} + +MODULE_LICENSE("GPL"); +/* MODULE_LICENSE("Proprietary"); */ +MODULE_DESCRIPTION("Amlogic audio debug Interface driver"); + +module_init(audio_data_init); +module_exit(audio_data_exit); diff --git a/drivers/amlogic/audioinfo/audio_data.h b/drivers/amlogic/audioinfo/audio_data.h new file mode 100644 index 000000000000..cf9db208b8f3 --- /dev/null +++ b/drivers/amlogic/audioinfo/audio_data.h @@ -0,0 +1,36 @@ +/* + * drivers/amlogic/audioinfo/audio_data.h + * + * Copyright (C) 2017 Amlogic, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + */ + +#ifndef _AUDIO_DATA_ANDROID_H_ +#define _AUDIO_DATA_ANDROID_H_ + +#include +#include + +#define AUDIO_DATA_DEVICE_NODE_NAME "audio_data_debug" +#define AUDIO_DATA_DEVICE_FILE_NAME "audio_data_debug" +#define AUDIO_DATA_DEVICE_PROC_NAME "audio_data_debug" +#define AUDIO_DATA_DEVICE_CLASS_NAME "audio_data_debug" + +#define EFUSE_DOLBY_AUDIO_EFFECT 1 + +struct audio_data_android_dev { + unsigned int val; + struct semaphore sem; + struct cdev dev; +}; +#endif