| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #!/bin/sh | ||
| # | ||
| # generate_core.sh extracts the core part from buildgcc script, | ||
| # most importantly the checksum calculation/verification functions. | ||
| # | ||
| # Copyright (C) 2019 Mike Banon <mikebdp2@gmail.com> | ||
| # | ||
| ############################################################################## | ||
| # | ||
| # USAGE: | ||
| # ./generate_core.sh <buildgcc> <corescript> prepare_before_patch | ||
| # where | ||
| # buildgcc - path to input buildgcc script | ||
| # corescript - path to output core part script | ||
| # prepare_before_patch - optional argument to insert prepare_${package} | ||
| # call into the unpack_and_patch function, e.g. | ||
| # for removing some files with rm command | ||
| # in order to reduce the size of patch file | ||
| # | ||
| ############################################################################## | ||
|
|
||
| buildgcc="$1" | ||
| corescript="$2" | ||
| prepare_before_patch="$3" | ||
|
|
||
| # | ||
| # Imports the source file fragment between start and end into the | ||
| # destination file, optionally excluding the last line if not needed | ||
| # | ||
|
|
||
| import_from_file() { | ||
| source="$1" | ||
| destination="$2" | ||
| start="$3" | ||
| end="$4" | ||
| last_line_disabled="$5" | ||
| if [ -z "${last_line_disabled}" ] ; then | ||
| sed -n "/^${start}/,/^${end}/{/^${start}/{p;n};{p}}" "$source" >> "$destination" | ||
| else | ||
| sed -n "/^${start}/,/^${end}/{/^${start}/{p;n};/^${end}/{q};{p}}" "$source" >> "$destination" | ||
| fi | ||
| } | ||
|
|
||
| # | ||
| # Import the color defines together with UNAME/HALT_FOR_TOOLS variables | ||
| # | ||
|
|
||
| import_from_file "$buildgcc" "$corescript" "red=" "HALT_FOR_TOOLS=0" || exit "$?" | ||
|
|
||
| # | ||
| # Import the core functions | ||
| # | ||
|
|
||
| FUNCTIONS="please_install searchtool download compute_hash error_hash_mismatch verify_hash unpack_and_patch" | ||
|
|
||
| for F in $FUNCTIONS ; do | ||
| import_from_file "$buildgcc" "$corescript" "$F()" "}" || exit "$?" | ||
| done | ||
|
|
||
| # | ||
| # Import a fragment where we find tar/patch/make and other essential tools | ||
| # | ||
|
|
||
| import_from_file "$buildgcc" "$corescript" "# Find all the required tools" "# Allow" "last_line_disabled" || exit "$?" | ||
|
|
||
| # | ||
| # Import a fragment with conditional exit if some required tools were not found | ||
| # | ||
|
|
||
| import_from_file "$buildgcc" "$corescript" "if \[ \"\$HALT_FOR_TOOLS" "fi" || exit "$?" | ||
|
|
||
| # | ||
| # Avoid the unnecessary subdirectories holding a single file each | ||
| # | ||
|
|
||
| sed -i -e "s/patches\///g" "$corescript" | ||
| sed -i -e "s/sum\///g" "$corescript" | ||
| sed -i -e "s/tarballs\///g" "$corescript" | ||
| sed -i -e "s/cd tarballs || exit 1//g" "$corescript" | ||
| sed -i -e "s/cd \.\.//g" "$corescript" | ||
|
|
||
| # | ||
| # Get the known checksum without using a dedicated single-line file | ||
| # | ||
|
|
||
| sed -i -e "s/\tknown_hash=\"\$(get_known_hash.*/\tknown_hash=\"\$2\"/g" "$corescript" | ||
|
|
||
| # | ||
| # Update the paths printed at the error messages | ||
| # | ||
|
|
||
| sed -i -e "s/util\/crossgcc\///g" "$corescript" | ||
|
|
||
| # | ||
| # Insert prepare_${package} function call between the unpack and patch operations | ||
| # | ||
|
|
||
| if [ ! -z "${prepare_before_patch}" ] ; then | ||
| sed -i -e "/\$TAR \$FLAGS \"\$(basename \"\$archive\")\"/a prepare_\${package} || exit \"\$?\"" "$corescript" | ||
| fi | ||
|
|
||
| # |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/bin/sh | ||
| # | ||
| # tintify_core.sh adds the TINT-specific footer/header to the core, | ||
| # such as the properties of current TINT version including its checksum. | ||
| # | ||
| # Copyright (C) 2019 Mike Banon <mikebdp2@gmail.com> | ||
| # | ||
| ################################################################################ | ||
| # | ||
| # USAGE: | ||
| # ./tintify_core.sh <corescript> <tintified> \ | ||
| # <TINT_ARCHIVE_LINK> <TINT_ARCHIVE> <TINT_DIR> <TINT_SHA1SUM> | ||
| # where | ||
| # corescript - path to input core script | ||
| # tintified - path to output tint script | ||
| # | ||
| ################################################################################ | ||
|
|
||
| corescript="$1" | ||
| tintified="$2" | ||
|
|
||
| # | ||
| # TINT-specific header | ||
| # | ||
|
|
||
| # | ||
| # Insert the properties of the current TINT version | ||
| # | ||
|
|
||
| echo "#!/bin/sh" > "$tintified" | ||
| echo "TINT_ARCHIVE_LINK=${3}" >> "$tintified" | ||
| echo "TINT_ARCHIVE=${4}" >> "$tintified" | ||
| echo "TINT_DIR=${5}" >> "$tintified" | ||
| echo "TINT_SHA1SUM=${6}" >> "$tintified" | ||
|
|
||
| # | ||
| # Add the replace_plus_with_minus() function - needed to fix the version number | ||
| # | ||
|
|
||
| echo "replace_plus_with_minus() {" >> "$tintified" | ||
| echo "for x in *\"+\"*; do" >> "$tintified" | ||
| echo "y=\$(printf %sa \"\$x\" | tr \"+\" \"-\")" >> "$tintified" | ||
| echo "mv -- \"\$x\" \"\${y%a}\"" >> "$tintified" | ||
| echo "done" >> "$tintified" | ||
| echo "}" >> "$tintified" | ||
|
|
||
| # | ||
| # Add the prepare_TINT() function, it will remove the unneeded debian directory | ||
| # as well as typedefs.h and old Makefile to significantly reduce the patch size | ||
| # | ||
|
|
||
| echo "prepare_TINT() {" >> "$tintified" | ||
| # echo "replace_plus_with_minus" >> "$tintified" | ||
| echo "if [ ! -z ./\${TINT_DIR} ] && [ -e ./\${TINT_DIR}/debian ] ; then" >> "$tintified" | ||
| echo "rm -rf ./\${TINT_DIR}/debian ./\${TINT_DIR}/typedefs.h ./\${TINT_DIR}/Makefile;" >> "$tintified" | ||
| echo "touch ./\${TINT_DIR}/Makefile;" >> "$tintified" | ||
| echo "fi" >> "$tintified" | ||
| echo "}" >> "$tintified" | ||
|
|
||
| # | ||
| # Importing the core script | ||
| # | ||
|
|
||
| cat "$corescript" >> "$tintified" | ||
|
|
||
| # | ||
| # download() function adjustments - became necessary after a version number fix | ||
| # | ||
|
|
||
| sed -i -e "/download() {/a package=\$1\narchive_link=\"\$(eval echo \\\\\$\$package\"_ARCHIVE_LINK\")\"" "$tintified" | ||
| sed -i -e "s/downloading from \$archive/&_link/g" "$tintified" | ||
| sed -i -e "s/\(download_showing_percentage \"\$archive\)./\1_link\"/g" "$tintified" | ||
|
|
||
| # | ||
| # TINT-specific footer | ||
| # | ||
|
|
||
| echo "if [ ! -d tint ] ; then" >> "$tintified" | ||
|
|
||
| echo "printf \"Downloading and verifying TINT tarball ... \\n\"" >> "$tintified" | ||
| echo "download TINT || exit \"\$?\"" >> "$tintified" | ||
| echo "verify_hash TINT \${TINT_SHA1SUM} || exit \"\$?\"" >> "$tintified" | ||
| echo "printf \"Downloaded TINT tarball ... \${green}ok\${NC}\\n\"" >> "$tintified" | ||
|
|
||
| echo "printf \"Unpacking and patching TINT... \\n\"" >> "$tintified" | ||
| echo "unpack_and_patch TINT || exit 1" >> "$tintified" | ||
| echo "printf \"Unpacked and patched TINT... \${green}ok\${NC}\\n\"" >> "$tintified" | ||
|
|
||
| echo "mv ./\${TINT_DIR} ./tint" >> "$tintified" | ||
| echo "fi" >> "$tintified" | ||
|
|
||
| echo "printf \"Building TINT ... \\n\"" >> "$tintified" | ||
| echo "make -C ./tint" >> "$tintified" | ||
| echo "printf \"TINT built ... \${green}ok\${NC}\\n\"" >> "$tintified" | ||
|
|
||
| chmod +x "$tintified" | ||
|
|
||
| # |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| CONFIG_LP_CHROMEOS=y | ||
| CONFIG_LP_ARCH_ARM64=y | ||
| CONFIG_LP_TIMER_ARM64_ARCH=y | ||
| CONFIG_LP_SERIAL_CONSOLE=y |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| /* | ||
| * Libpayload NVMe device driver | ||
| * Copyright (C) 2019 secunet Security Networks AG | ||
| */ | ||
|
|
||
| #ifndef _STORAGE_NVME_H | ||
| #define _STORAGE_NVME_H | ||
|
|
||
| #include "storage.h" | ||
|
|
||
| void nvme_initialize(struct pci_dev *dev); | ||
|
|
||
| #endif /* _STORAGE_NVME_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,20 +43,6 @@ config CPU_QEMU_X86_TSEG_SMM | |
|
|
||
| endchoice | ||
|
|
||
| config MAX_CPUS | ||
| int | ||
| default 32 if SMM_TSEG | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| config DRIVERS_GENERIC_NAU8315 | ||
| bool | ||
| depends on HAVE_ACPI_TABLES |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ramstage-$(CONFIG_DRIVERS_GENERIC_NAU8315) += nau8315.c |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
|
||
| #include <acpi/acpi_device.h> | ||
|
|
||
| struct drivers_generic_nau8315_config { | ||
| /* ENABLE GPIO */ | ||
| struct acpi_gpio enable_gpio; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
|
||
| #include <acpi/acpi_device.h> | ||
| #include <acpi/acpigen.h> | ||
| #include <console/console.h> | ||
| #include <device/device.h> | ||
| #include <device/path.h> | ||
| #include <gpio.h> | ||
| #include "chip.h" | ||
|
|
||
| static void nau8315_fill_ssdt(const struct device *dev) | ||
| { | ||
| struct drivers_generic_nau8315_config *config = dev->chip_info; | ||
| const char *path; | ||
| struct acpi_dp *dp; | ||
|
|
||
| if (!dev->enabled || !config) | ||
| return; | ||
|
|
||
| const char *scope = acpi_device_scope(dev); | ||
| const char *name = acpi_device_name(dev); | ||
| if (!scope || !name) | ||
| return; | ||
|
|
||
| /* Device */ | ||
| acpigen_write_scope(scope); | ||
| acpigen_write_device(name); | ||
|
|
||
| acpigen_write_name_string("_HID", "NVTN2010"); | ||
| acpigen_write_name_integer("_UID", 0); | ||
| acpigen_write_name_string("_DDN", dev->chip_ops->name); | ||
| acpigen_write_STA(acpi_device_status(dev)); | ||
|
|
||
| /* Resources */ | ||
| acpigen_write_name("_CRS"); | ||
| acpigen_write_resourcetemplate_header(); | ||
| acpi_device_write_gpio(&config->enable_gpio); | ||
| acpigen_write_resourcetemplate_footer(); | ||
|
|
||
| /* _DSD for devicetree properties */ | ||
| /* This points to the first pin in the first gpio entry in _CRS */ | ||
| path = acpi_device_path(dev); | ||
| dp = acpi_dp_new_table("_DSD"); | ||
| acpi_dp_add_gpio(dp, "enable-gpios", path, 0, 0, | ||
| config->enable_gpio.active_low); | ||
| acpi_dp_write(dp); | ||
|
|
||
| acpigen_pop_len(); /* Device */ | ||
| acpigen_pop_len(); /* Scope */ | ||
|
|
||
| printk(BIOS_INFO, "%s: %s\n", path, dev->chip_ops->name); | ||
| } | ||
|
|
||
| static const char *nau8315_acpi_name(const struct device *dev) | ||
| { | ||
| return "NVTN"; | ||
| } | ||
|
|
||
| static struct device_operations nau8315_ops = { | ||
| .read_resources = noop_read_resources, | ||
| .set_resources = noop_set_resources, | ||
| .acpi_name = nau8315_acpi_name, | ||
| .acpi_fill_ssdt = nau8315_fill_ssdt, | ||
| }; | ||
|
|
||
| static void nau8315_enable(struct device *dev) | ||
| { | ||
| dev->ops = &nau8315_ops; | ||
| } | ||
|
|
||
| struct chip_operations drivers_generic_nau8315_ops = { | ||
| CHIP_NAME("Nuvoton NAU8315 Amplifier") | ||
| .enable_dev = nau8315_enable | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| config DRIVERS_I2C_CS42L42 | ||
| bool | ||
| depends on HAVE_ACPI_TABLES |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ramstage-$(CONFIG_DRIVERS_I2C_CS42L42) += cs42l42.c |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
|
||
| #include <acpi/acpi_device.h> | ||
|
|
||
| enum cs42l42_ts_dbnc_rise { | ||
| RISE_DEB_0_MS = 0, | ||
| RISE_DEB_125_MS = 1, | ||
| RISE_DEB_250_MS = 2, | ||
| RISE_DEB_500_MS = 3, | ||
| RISE_DEB_750_MS = 4, | ||
| RISE_DEB_1000_MS = 5, | ||
| RISE_DEB_1250_MS = 6, | ||
| RISE_DEB_1500_MS = 7, | ||
| }; | ||
|
|
||
| enum cs42l42_ts_dbnc_fall { | ||
| FALL_DEB_0_MS = 0, | ||
| FALL_DEB_125_MS = 1, | ||
| FALL_DEB_250_MS = 2, | ||
| FALL_DEB_500_MS = 3, | ||
| FALL_DEB_750_MS = 4, | ||
| FALL_DEB_1000_MS = 5, | ||
| FALL_DEB_1250_MS = 6, | ||
| FALL_DEB_1500_MS = 7, | ||
| }; | ||
|
|
||
| enum cs42l42_hs_bias_ramp_rate { | ||
| HSBIAS_RAMP_FAST_RISE_SLOW_FALL = 0, | ||
| HSBIAS_RAMP_FAST = 1, | ||
| HSBIAS_RAMP_SLOW = 2, | ||
| HSBIAS_RAMP_SLOWEST = 3, | ||
| }; | ||
|
|
||
| /* | ||
| * Cirrus Logic CS42L42 Audio Codec devicetree bindings | ||
| * linux/Documentation/devicetree/bindings/sound/cs42l42.txt | ||
| */ | ||
| struct drivers_i2c_cs42l42_config { | ||
| /* Interrupt configuration */ | ||
| struct acpi_irq irq; | ||
|
|
||
| /* Use GPIO based interrupt instead of PIRQ */ | ||
| struct acpi_gpio irq_gpio; | ||
|
|
||
| /* Use GPIO based reset gpio */ | ||
| struct acpi_gpio reset_gpio; | ||
|
|
||
| /* I2C Bus Frequency in Hertz (default 400kHz) */ | ||
| unsigned int bus_speed; | ||
|
|
||
| /* Define cs42L42 parameters */ | ||
| /* | ||
| * cirrus,ts-inv : Boolean property. For jacks that invert the tip sense | ||
| * polarity. Normal jacks will short tip sense pin to HS1 when headphones are | ||
| * plugged in and leave tip sense floating when not plugged in. Inverting jacks | ||
| * short tip sense when unplugged and float when plugged in. | ||
| * false = Non-inverted | ||
| * true = Inverted | ||
| * Default = Non-inverted | ||
| */ | ||
| bool ts_inv; | ||
| /* | ||
| * cirrus,ts-dbnc-rise : Debounce the rising edge of TIP_SENSE_PLUG. With no | ||
| * debounce, the tip sense pin might be noisy on a plug event. | ||
| * Default = RISE_DEB_1000_MS | ||
| */ | ||
| enum cs42l42_ts_dbnc_rise ts_dbnc_rise; | ||
| /* | ||
| * cirrus,ts-dbnc-fall : Debounce the falling edge of TIP_SENSE_UNPLUG. | ||
| * With no debounce, the tip sense pin might be noisy on an unplug event. | ||
| * Default = FALL_DEB_1000_MS | ||
| */ | ||
| enum cs42l42_ts_dbnc_fall ts_dbnc_fall; | ||
| /* | ||
| * cirrus,btn-det-init-dbnce : This sets how long the driver sleeps after | ||
| * enabling button detection interrupts. After auto-detection and before | ||
| * servicing button interrupts, the HS bias needs time to settle. If you | ||
| * don't wait, there is possibility for erroneous button interrupt. | ||
| * Value in ms, 0 - 200. | ||
| * Default = 100ms | ||
| */ | ||
| unsigned int btn_det_init_dbnce; | ||
| /* | ||
| * cirrus,btn-det-event-dbnce : This sets how long the driver delays after | ||
| * receiving a button press interrupt. With level detect interrupts, you want | ||
| * to wait a small amount of time to make sure the button press is making a | ||
| * clean connection with the bias resistors. | ||
| * Value in ms, 0 - 20. | ||
| * Default = 10ms | ||
| */ | ||
| unsigned int btn_det_event_dbnce; | ||
| /* | ||
| * cirrus,bias-lvls : For a level-detect headset button scheme, each button | ||
| * will bias the mic pin to a certain voltage. To determine which button was | ||
| * pressed, the driver will compare this biased voltage to sequential, | ||
| * decreasing voltages and will stop when a comparator is tripped, | ||
| * indicating a comparator voltage < bias voltage. This value represents a | ||
| * percentage of the internally generated HS bias voltage. For different | ||
| * hardware setups, a designer might want to tweak this. This is an array of | ||
| * descending values for the comparator voltage. | ||
| * Array of 4 values | ||
| * Each 0-63 | ||
| * < x1 x2 x3 x4 > | ||
| * Default = < 15 8 4 1> | ||
| */ | ||
| uint64_t bias_lvls[4]; | ||
| /* headset bias ramp rate */ | ||
| enum cs42l42_hs_bias_ramp_rate hs_bias_ramp_rate; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
|
||
| #include <acpi/acpi.h> | ||
| #include <acpi/acpi_device.h> | ||
| #include <acpi/acpigen.h> | ||
| #include <console/console.h> | ||
| #include <device/i2c_simple.h> | ||
| #include <device/device.h> | ||
| #include <device/path.h> | ||
|
|
||
| #include "chip.h" | ||
|
|
||
| #define CS42L42_ACPI_NAME "CRUS" | ||
| #define CS42L42_ACPI_HID "10134242" | ||
|
|
||
| static void cs42l42_fill_ssdt(const struct device *dev) | ||
| { | ||
| struct drivers_i2c_cs42l42_config *config = dev->chip_info; | ||
| const char *scope = acpi_device_scope(dev); | ||
| const char *path = acpi_device_path(dev); | ||
| struct acpi_i2c i2c = { | ||
| .address = dev->path.i2c.device, | ||
| .mode_10bit = dev->path.i2c.mode_10bit, | ||
| .speed = config->bus_speed ? : I2C_SPEED_FAST, | ||
| .resource = scope, | ||
| }; | ||
| struct acpi_dp *dsd; | ||
| int gpio_index = 0; | ||
|
|
||
| if (!scope) | ||
| return; | ||
|
|
||
| /* Device */ | ||
| acpigen_write_scope(scope); | ||
| acpigen_write_device(acpi_device_name(dev)); | ||
| acpigen_write_name_string("_HID", CS42L42_ACPI_HID); | ||
| acpigen_write_name_integer("_UID", 0); | ||
| acpigen_write_name_string("_DDN", dev->chip_ops->name); | ||
| acpigen_write_STA(acpi_device_status(dev)); | ||
|
|
||
| /* Resources */ | ||
| acpigen_write_name("_CRS"); | ||
| acpigen_write_resourcetemplate_header(); | ||
| acpi_device_write_i2c(&i2c); | ||
| /* Use either Interrupt() or GpioInt() */ | ||
| if (config->irq_gpio.pin_count) | ||
| acpi_device_write_gpio(&config->irq_gpio); | ||
| else | ||
| acpi_device_write_interrupt(&config->irq); | ||
|
|
||
| /* for cs42l42reset gpio */ | ||
| if (config->reset_gpio.pin_count) | ||
| acpi_device_write_gpio(&config->reset_gpio); | ||
|
|
||
| acpigen_write_resourcetemplate_footer(); | ||
|
|
||
| /* AAD Child Device Properties */ | ||
| dsd = acpi_dp_new_table("_DSD"); | ||
| if (config->irq_gpio.pin_count) | ||
| acpi_dp_add_gpio(dsd, "irq-gpios", path, | ||
| gpio_index++, /* Index = 0 */ | ||
| 0, /* Pin = 0 (There is a single pin in the GPIO resource). */ | ||
| config->irq_gpio.active_low); | ||
| if (config->reset_gpio.pin_count) | ||
| acpi_dp_add_gpio(dsd, "reset-gpios", path, | ||
| gpio_index++, /* Index = 0 or 1 (if irq gpio is written). */ | ||
| 0, /* Pin = 0 (There is a single pin in the GPIO resource). */ | ||
| config->reset_gpio.active_low); | ||
| acpi_dp_add_integer(dsd, "cirrus,ts-inv", config->ts_inv ? 1 : 0); | ||
| acpi_dp_add_integer(dsd, "cirrus,ts-dbnc-rise", config->ts_dbnc_rise); | ||
| acpi_dp_add_integer(dsd, "cirrus,ts-dbnc-fall", config->ts_dbnc_fall); | ||
| acpi_dp_add_integer(dsd, "cirrus,btn-det-init-dbnce", config->btn_det_init_dbnce); | ||
|
|
||
| if (config->btn_det_init_dbnce > 200) { | ||
| printk(BIOS_ERR, "%s: Incorrect btn_det_init_dbnce(%d). Using default of 100ms\n", | ||
| __func__, config->btn_det_init_dbnce); | ||
| config->btn_det_init_dbnce = 100; | ||
| } | ||
|
|
||
| acpi_dp_add_integer(dsd, "cirrus,btn-det-event-dbnce", config->btn_det_event_dbnce); | ||
|
|
||
| if (config->btn_det_event_dbnce > 100) { | ||
| printk(BIOS_ERR, "%s: Incorrect btn_det_event_dbnce(%d). Using default of 10ms\n", | ||
| __func__, config->btn_det_event_dbnce); | ||
| config->btn_det_event_dbnce = 10; | ||
| } | ||
|
|
||
| acpi_dp_add_integer_array(dsd, "cirrus,bias-lvls", config->bias_lvls, 4); | ||
| acpi_dp_add_integer(dsd, "cirrus,hs-bias-ramp-rate", config->hs_bias_ramp_rate); | ||
|
|
||
| /* Write Device Property Hierarchy */ | ||
| acpi_dp_write(dsd); | ||
|
|
||
| acpigen_pop_len(); /* Device */ | ||
| acpigen_pop_len(); /* Scope */ | ||
|
|
||
| printk(BIOS_INFO, "%s: %s address 0%xh irq %d\n", | ||
| acpi_device_path(dev), dev->chip_ops->name, | ||
| dev->path.i2c.device, config->irq.pin); | ||
| } | ||
|
|
||
| static const char *cs42l42_acpi_name(const struct device *dev) | ||
| { | ||
| return CS42L42_ACPI_NAME; | ||
| } | ||
|
|
||
| static struct device_operations cs42l42_ops = { | ||
| .read_resources = noop_read_resources, | ||
| .set_resources = noop_set_resources, | ||
| .acpi_name = cs42l42_acpi_name, | ||
| .acpi_fill_ssdt = cs42l42_fill_ssdt, | ||
| }; | ||
|
|
||
| static void cs42l42_enable(struct device *dev) | ||
| { | ||
| dev->ops = &cs42l42_ops; | ||
| } | ||
|
|
||
| struct chip_operations drivers_i2c_cs42l42_ops = { | ||
| CHIP_NAME("Cirrus Logic CS42l42 Audio Codec") | ||
| .enable_dev = cs42l42_enable | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| config DRIVERS_I2C_TAS5825M | ||
| bool | ||
| default n | ||
| help | ||
| Enable support for TI TAS5825M Amplifier. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ramstage-$(CONFIG_DRIVERS_I2C_TAS5825M) += tas5825m.c |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
|
||
| struct drivers_i2c_tas5825m_config { | ||
| // Used to uniquely identify the AMP | ||
| int id; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
|
||
| #include <console/console.h> | ||
| #include <device/smbus.h> | ||
| #include <device/pci.h> | ||
| #include "chip.h" | ||
| #include "tas5825m.h" | ||
|
|
||
| int tas5825m_write_at(struct device *dev, uint8_t addr, uint8_t value) | ||
| { | ||
| return smbus_write_byte(dev, addr, value); | ||
| } | ||
|
|
||
| //TODO: use I2C block write for better performance | ||
| int tas5825m_write_block_at(struct device *dev, uint8_t addr, | ||
| const uint8_t *values, uint8_t length) | ||
| { | ||
| int res = 0; | ||
| for (uint8_t i = 0; i < length; i++) { | ||
| res = smbus_write_byte(dev, addr + i, values[i]); | ||
| if (res < 0) | ||
| return res; | ||
| } | ||
| return (int)length; | ||
| } | ||
|
|
||
| int tas5825m_set_page(struct device *dev, uint8_t page) | ||
| { | ||
| return tas5825m_write_at(dev, 0x00, page); | ||
| } | ||
|
|
||
| int tas5825m_set_book(struct device *dev, uint8_t book) | ||
| { | ||
| int res = tas5825m_set_page(dev, 0x00); | ||
| if (res < 0) | ||
| return res; | ||
| return tas5825m_write_at(dev, 0x7F, book); | ||
| } | ||
|
|
||
| __weak int tas5825m_setup(struct device *dev, int id) | ||
| { | ||
| printk(BIOS_ERR, "tas5825m: setup not implemented\n"); | ||
| return -1; | ||
| } | ||
|
|
||
| static void tas5825m_init(struct device *dev) | ||
| { | ||
| if (dev->enabled && dev->path.type == DEVICE_PATH_I2C && | ||
| ops_smbus_bus(get_pbus_smbus(dev))) { | ||
| printk(BIOS_DEBUG, "tas5825m at %s\n", dev_path(dev)); | ||
|
|
||
| struct drivers_i2c_tas5825m_config *config = dev->chip_info; | ||
| if (config) { | ||
| printk(BIOS_DEBUG, "tas5825m id %d\n", config->id); | ||
| int res = tas5825m_setup(dev, config->id); | ||
| if (res) | ||
| printk(BIOS_ERR, "tas5825m init failed: %d\n", res); | ||
| else | ||
| printk(BIOS_DEBUG, "tas5825m init successful\n"); | ||
| } else { | ||
| printk(BIOS_ERR, "tas5825m: failed to find config\n"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| static struct device_operations tas5825m_operations = { | ||
| .read_resources = noop_read_resources, | ||
| .set_resources = noop_set_resources, | ||
| .init = tas5825m_init, | ||
| }; | ||
|
|
||
| static void tas5825m_enable_dev(struct device *dev) | ||
| { | ||
| dev->ops = &tas5825m_operations; | ||
| } | ||
|
|
||
| struct chip_operations drivers_i2c_tas5825m_ops = { | ||
| CHIP_NAME("TI TAS5825M Amplifier") | ||
| .enable_dev = tas5825m_enable_dev, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
|
||
| #ifndef TAS5825M_H | ||
| #define TAS5825M_H | ||
|
|
||
| #include <device/device.h> | ||
|
|
||
| int tas5825m_write_at(struct device *dev, uint8_t addr, uint8_t value); | ||
| int tas5825m_write_block_at(struct device *dev, uint8_t addr, | ||
| const uint8_t *values, uint8_t length); | ||
| int tas5825m_set_page(struct device *dev, uint8_t page); | ||
| int tas5825m_set_book(struct device *dev, uint8_t book); | ||
| int tas5825m_setup(struct device *dev, int id); | ||
|
|
||
| #endif // TAS5825M_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
|
||
| #ifndef _DRIVERS_INTEL_DPTF_H_ | ||
| #define _DRIVERS_INTEL_DPTF_H_ | ||
|
|
||
| #include <types.h> | ||
|
|
||
| struct dptf_platform_info { | ||
| /* | ||
| * True indicates the platform-specific HIDs are to be emitted in EISA | ||
| * format instead of a string. | ||
| */ | ||
| bool use_eisa_hids; | ||
| const char *dptf_device_hid; | ||
| const char *generic_hid; | ||
| const char *fan_hid; | ||
| }; | ||
|
|
||
| const struct dptf_platform_info *get_dptf_platform_info(void); | ||
|
|
||
| #endif /* _DRIVERS_INTEL_DPTF_H_ */ |