From 45c85c1827d45f8041b8f270d80bf6fff328069c Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Fri, 17 Nov 2023 00:02:05 +0000 Subject: [PATCH 01/17] base-files: add mmc_get_mac_ascii function Similar to the *_get_mac_binary function, also split the common parts off mtd_get_mac_ascii into new get_mac_ascii function and introduce mmc_get_mac_ascii which uses it. Signed-off-by: Daniel Golle --- .../base-files/files/lib/functions/system.sh | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index d06354b01f..107e67835a 100644 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -61,11 +61,21 @@ find_mtd_chardev() { echo "${INDEX:+$PREFIX$INDEX}" } +get_mac_ascii() { + local part="$1" + local key="$2" + local mac_dirty + + mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p') + + # "canonicalize" mac + [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty" +} + mtd_get_mac_ascii() { local mtdname="$1" local key="$2" local part - local mac_dirty part=$(find_mtd_part "$mtdname") if [ -z "$part" ]; then @@ -73,10 +83,7 @@ mtd_get_mac_ascii() { return fi - mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p') - - # "canonicalize" mac - [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty" + get_mac_ascii "$part" "$key" } mtd_get_mac_encrypted_arcadyan() { @@ -190,6 +197,19 @@ mtd_get_part_size() { done < /proc/mtd } +mmc_get_mac_ascii() { + local part_name="$1" + local key="$2" + local part + + part=$(find_mmc_part "$part_name") + if [ -z "$part" ]; then + echo "mmc_get_mac_ascii: partition $part_name not found!" >&2 + fi + + get_mac_ascii "$part" "$key" +} + mmc_get_mac_binary() { local part_name="$1" local offset="$2" From 90fbec89be263a3838558c5b674f3c4072cc2f1d Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 10 Dec 2023 01:15:36 +0000 Subject: [PATCH 02/17] kernel: hack: support inverted LEDs on MaxLinear GPY211 PHY Add downstream DT property to setup the PHY LEDs of the MaxLinear GPY211 PHY in such way that the VDD of the LED is driven by the SoC pin rather than the GND (which is the default). Signed-off-by: Daniel Golle --- .../765-mxl-gpy-control-LED-reg-from-DT.patch | 10 +++++++--- .../hack-6.1/765-mxl-gpy-control-LED-reg-from-DT.patch | 10 +++++++--- ...y-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch | 8 ++++---- ...y-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch | 8 ++++---- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/target/linux/generic/hack-5.15/765-mxl-gpy-control-LED-reg-from-DT.patch b/target/linux/generic/hack-5.15/765-mxl-gpy-control-LED-reg-from-DT.patch index 8de3668def..95e9749d91 100644 --- a/target/linux/generic/hack-5.15/765-mxl-gpy-control-LED-reg-from-DT.patch +++ b/target/linux/generic/hack-5.15/765-mxl-gpy-control-LED-reg-from-DT.patch @@ -55,7 +55,7 @@ Signed-off-by: David Bauer /* SGMII */ #define VSPEC1_SGMII_CTRL 0x08 #define VSPEC1_SGMII_CTRL_ANEN BIT(12) /* Aneg enable */ -@@ -80,6 +87,31 @@ static const struct { +@@ -80,6 +87,35 @@ static const struct { {9, 0x73}, }; @@ -64,6 +64,7 @@ Signed-off-by: David Bauer + struct device_node *node = phydev->mdio.dev.of_node; + u32 led_regs[PHY_LED_NUM_LEDS]; + int i, ret; ++ u16 val = 0xff00; + + if (!IS_ENABLED(CONFIG_OF_MDIO)) + return 0; @@ -71,8 +72,11 @@ Signed-off-by: David Bauer + if (of_property_read_u32_array(node, "mxl,led-config", led_regs, PHY_LED_NUM_LEDS)) + return 0; + ++ if (of_property_read_bool(node, "mxl,led-drive-vdd")) ++ val &= 0x0fff; ++ + /* Enable LED function handling on all ports*/ -+ phy_write(phydev, PHY_LED, 0xFF00); ++ phy_write(phydev, PHY_LED, val); + + /* Write LED register values */ + for (i = 0; i < PHY_LED_NUM_LEDS; i++) { @@ -87,7 +91,7 @@ Signed-off-by: David Bauer static int gpy_config_init(struct phy_device *phydev) { int ret; -@@ -91,7 +123,10 @@ static int gpy_config_init(struct phy_de +@@ -91,7 +127,10 @@ static int gpy_config_init(struct phy_de /* Clear all pending interrupts */ ret = phy_read(phydev, PHY_ISTAT); diff --git a/target/linux/generic/hack-6.1/765-mxl-gpy-control-LED-reg-from-DT.patch b/target/linux/generic/hack-6.1/765-mxl-gpy-control-LED-reg-from-DT.patch index d7165cb30a..2724efa15e 100644 --- a/target/linux/generic/hack-6.1/765-mxl-gpy-control-LED-reg-from-DT.patch +++ b/target/linux/generic/hack-6.1/765-mxl-gpy-control-LED-reg-from-DT.patch @@ -55,7 +55,7 @@ Signed-off-by: David Bauer /* SGMII */ #define VSPEC1_SGMII_CTRL 0x08 #define VSPEC1_SGMII_CTRL_ANEN BIT(12) /* Aneg enable */ -@@ -241,6 +248,31 @@ out: +@@ -241,6 +248,35 @@ out: return ret; } @@ -64,6 +64,7 @@ Signed-off-by: David Bauer + struct device_node *node = phydev->mdio.dev.of_node; + u32 led_regs[PHY_LED_NUM_LEDS]; + int i, ret; ++ u16 val = 0xff00; + + if (!IS_ENABLED(CONFIG_OF_MDIO)) + return 0; @@ -71,8 +72,11 @@ Signed-off-by: David Bauer + if (of_property_read_u32_array(node, "mxl,led-config", led_regs, PHY_LED_NUM_LEDS)) + return 0; + ++ if (of_property_read_bool(node, "mxl,led-drive-vdd")) ++ val &= 0x0fff; ++ + /* Enable LED function handling on all ports*/ -+ phy_write(phydev, PHY_LED, 0xFF00); ++ phy_write(phydev, PHY_LED, val); + + /* Write LED register values */ + for (i = 0; i < PHY_LED_NUM_LEDS; i++) { @@ -87,7 +91,7 @@ Signed-off-by: David Bauer static int gpy_config_init(struct phy_device *phydev) { int ret; -@@ -252,7 +284,10 @@ static int gpy_config_init(struct phy_de +@@ -252,7 +288,10 @@ static int gpy_config_init(struct phy_de /* Clear all pending interrupts */ ret = phy_read(phydev, PHY_ISTAT); diff --git a/target/linux/mediatek/patches-5.15/732-net-phy-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch b/target/linux/mediatek/patches-5.15/732-net-phy-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch index 598d9d0d21..6df4436ab9 100644 --- a/target/linux/mediatek/patches-5.15/732-net-phy-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch +++ b/target/linux/mediatek/patches-5.15/732-net-phy-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch @@ -14,7 +14,7 @@ Signed-off-by: Daniel Golle --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c -@@ -191,8 +191,11 @@ static bool gpy_2500basex_chk(struct phy +@@ -195,8 +195,11 @@ static bool gpy_2500basex_chk(struct phy phydev->speed = SPEED_2500; phydev->interface = PHY_INTERFACE_MODE_2500BASEX; @@ -28,7 +28,7 @@ Signed-off-by: Daniel Golle return true; } -@@ -216,6 +219,14 @@ static int gpy_config_aneg(struct phy_de +@@ -220,6 +223,14 @@ static int gpy_config_aneg(struct phy_de u32 adv; int ret; @@ -43,7 +43,7 @@ Signed-off-by: Daniel Golle if (phydev->autoneg == AUTONEG_DISABLE) { /* Configure half duplex with genphy_setup_forced, * because genphy_c45_pma_setup_forced does not support. -@@ -306,6 +317,8 @@ static void gpy_update_interface(struct +@@ -310,6 +321,8 @@ static void gpy_update_interface(struct switch (phydev->speed) { case SPEED_2500: phydev->interface = PHY_INTERFACE_MODE_2500BASEX; @@ -52,7 +52,7 @@ Signed-off-by: Daniel Golle ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL, VSPEC1_SGMII_CTRL_ANEN, 0); if (ret < 0) -@@ -317,7 +330,7 @@ static void gpy_update_interface(struct +@@ -321,7 +334,7 @@ static void gpy_update_interface(struct case SPEED_100: case SPEED_10: phydev->interface = PHY_INTERFACE_MODE_SGMII; diff --git a/target/linux/mediatek/patches-6.1/732-net-phy-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch b/target/linux/mediatek/patches-6.1/732-net-phy-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch index d745727371..76d8b0ef00 100644 --- a/target/linux/mediatek/patches-6.1/732-net-phy-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch +++ b/target/linux/mediatek/patches-6.1/732-net-phy-mxl-gpy-don-t-use-SGMII-AN-if-using-phylink.patch @@ -14,7 +14,7 @@ Signed-off-by: Daniel Golle --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c -@@ -367,8 +367,11 @@ static bool gpy_2500basex_chk(struct phy +@@ -371,8 +371,11 @@ static bool gpy_2500basex_chk(struct phy phydev->speed = SPEED_2500; phydev->interface = PHY_INTERFACE_MODE_2500BASEX; @@ -28,7 +28,7 @@ Signed-off-by: Daniel Golle return true; } -@@ -392,6 +395,14 @@ static int gpy_config_aneg(struct phy_de +@@ -396,6 +399,14 @@ static int gpy_config_aneg(struct phy_de u32 adv; int ret; @@ -43,7 +43,7 @@ Signed-off-by: Daniel Golle if (phydev->autoneg == AUTONEG_DISABLE) { /* Configure half duplex with genphy_setup_forced, * because genphy_c45_pma_setup_forced does not support. -@@ -482,6 +493,8 @@ static void gpy_update_interface(struct +@@ -486,6 +497,8 @@ static void gpy_update_interface(struct switch (phydev->speed) { case SPEED_2500: phydev->interface = PHY_INTERFACE_MODE_2500BASEX; @@ -52,7 +52,7 @@ Signed-off-by: Daniel Golle ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL, VSPEC1_SGMII_CTRL_ANEN, 0); if (ret < 0) -@@ -493,7 +506,7 @@ static void gpy_update_interface(struct +@@ -497,7 +510,7 @@ static void gpy_update_interface(struct case SPEED_100: case SPEED_10: phydev->interface = PHY_INTERFACE_MODE_SGMII; From a270f61c00c7d5a62664b85baa56a8ab1a242f8d Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Fri, 17 Nov 2023 02:01:34 +0000 Subject: [PATCH 03/17] mediatek: import driver for Adtran SmartRG RGBW LED Import driver for I2C-connected HolTek MCU controlling the RGBW LED found in Adtran SmartRG devices. Signed-off-by: Daniel Golle --- .../files/drivers/leds/leds-smartrg-system.c | 239 ++++++++++++++++++ target/linux/mediatek/filogic/config-5.15 | 1 + target/linux/mediatek/filogic/config-6.1 | 1 + target/linux/mediatek/mt7622/config-5.15 | 1 + target/linux/mediatek/mt7622/config-6.1 | 1 + target/linux/mediatek/mt7623/config-5.15 | 1 + target/linux/mediatek/mt7623/config-6.1 | 1 + target/linux/mediatek/mt7629/config-5.15 | 1 + target/linux/mediatek/mt7629/config-6.1 | 1 + .../950-smartrg-i2c-led-driver.patch | 34 +++ .../950-smartrg-i2c-led-driver.patch | 34 +++ 11 files changed, 315 insertions(+) create mode 100644 target/linux/mediatek/files/drivers/leds/leds-smartrg-system.c create mode 100644 target/linux/mediatek/patches-5.15/950-smartrg-i2c-led-driver.patch create mode 100644 target/linux/mediatek/patches-6.1/950-smartrg-i2c-led-driver.patch diff --git a/target/linux/mediatek/files/drivers/leds/leds-smartrg-system.c b/target/linux/mediatek/files/drivers/leds/leds-smartrg-system.c new file mode 100644 index 0000000000..1679555068 --- /dev/null +++ b/target/linux/mediatek/files/drivers/leds/leds-smartrg-system.c @@ -0,0 +1,239 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * Driver for SmartRG RGBW LED microcontroller. + * RGBW LED is connected to a Holtek HT45F0062 that is on the I2C bus. + * + */ + +struct srg_led_ctrl; +struct srg_led { + u8 index; + struct led_classdev led; + struct srg_led_ctrl *ctrl; +}; + +struct srg_led_ctrl { + struct mutex lock; + struct i2c_client *client; + struct srg_led channel[4]; + u8 control[5]; +}; + +static int +srg_led_i2c_write(struct srg_led_ctrl *sysled_ctrl, u8 reg, u8 value) +{ + return i2c_smbus_write_byte_data(sysled_ctrl->client, reg, value); +} + +/* + * MC LED Command: 0 = OFF, 1 = ON, 2 = Flash, 3 = Pulse, 4 = Blink + * */ +static int +srg_led_control_sync(struct srg_led_ctrl *sysled_ctrl) +{ + int i, ret; + + for (i = 1; i < 5; i++) { + ret = srg_led_i2c_write(sysled_ctrl, i, sysled_ctrl->control[i]); + if (ret) + break; + } + return ret; +} + +/* + * This function overrides the led driver timer trigger to offload + * flashing to the micro-controller. The negative effect of this + * is the inability to configure the delay_on and delay_off periods. + * + * */ +static int +srg_led_set_pulse(struct led_classdev *led_cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct srg_led *sysled = container_of(led_cdev, struct srg_led, led); + struct srg_led_ctrl *sysled_ctrl = sysled->ctrl; + bool blinking = false, pulsing = false; + u8 cbyte; + int ret; + + if (delay_on && delay_off && (*delay_on > 100) && (*delay_on <= 500)) { + pulsing = true; + *delay_on = 500; + *delay_off = 500; + } else if (delay_on && delay_off && (*delay_on >= 50) && (*delay_on <= 100)) { + blinking = true; + *delay_on = 50; + *delay_off = 50; + } + + cbyte = pulsing ? 3 : blinking ? 2 : 0; + mutex_lock(&sysled_ctrl->lock); + ret = srg_led_i2c_write(sysled_ctrl, sysled->index + 4, + (blinking || pulsing) ? 255 : 0); + if (!ret) { + sysled_ctrl->control[sysled->index] = cbyte; + ret = srg_led_control_sync(sysled_ctrl); + } + mutex_unlock(&sysled_ctrl->lock); + + return !cbyte; +} + +static int +srg_led_set_brightness(struct led_classdev *led_cdev, + enum led_brightness value) +{ + struct srg_led *sysled = container_of(led_cdev, struct srg_led, led); + struct srg_led_ctrl *sysled_ctrl = sysled->ctrl; + int ret; + + mutex_lock(&sysled_ctrl->lock); + ret = srg_led_i2c_write(sysled_ctrl, sysled->index + 4, value); + if (!ret) { + sysled_ctrl->control[sysled->index] = !!value; + ret = srg_led_control_sync(sysled_ctrl); + } + mutex_unlock(&sysled_ctrl->lock); + return ret; +} + +static int +srg_led_init_led(struct srg_led_ctrl *sysled_ctrl, struct device_node *np) +{ + struct led_init_data init_data = {}; + struct led_classdev *led_cdev; + struct srg_led *sysled; + int index, ret; + + if (!np) + return -ENOENT; + + ret = of_property_read_u32(np, "reg", &index); + if (ret) { + dev_err(&sysled_ctrl->client->dev, + "srg_led_init_led: no reg defined in np!\n"); + return ret; + } + + if (index < 1 || index > 4) + return -EINVAL; + + sysled = &sysled_ctrl->channel[index - 1]; + led_cdev = &sysled->led; + + sysled->index = index; + sysled->ctrl = sysled_ctrl; + + init_data.fwnode = of_fwnode_handle(np); + + led_cdev->name = of_get_property(np, "label", NULL) ? : np->name; + led_cdev->brightness = LED_OFF; + led_cdev->max_brightness = LED_FULL; + led_cdev->brightness_set_blocking = srg_led_set_brightness; + led_cdev->blink_set = srg_led_set_pulse; + + srg_led_i2c_write(sysled_ctrl, index + 4, 0); + + ret = devm_led_classdev_register_ext(&sysled_ctrl->client->dev, + led_cdev, &init_data); + if (ret) { + dev_err(&sysled_ctrl->client->dev, + "srg_led_init_led: led register %s error ret %d!n", + led_cdev->name, ret); + return ret; + } + + return 0; +} + +static int +srg_led_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct device_node *np = client->dev.of_node, *child; + struct srg_led_ctrl *sysled_ctrl; + + sysled_ctrl = devm_kzalloc(&client->dev, sizeof(*sysled_ctrl), GFP_KERNEL); + if (!sysled_ctrl) + return -ENOMEM; + + sysled_ctrl->client = client; + + mutex_init(&sysled_ctrl->lock); + + i2c_set_clientdata(client, sysled_ctrl); + + for_each_child_of_node(np, child) { + if (srg_led_init_led(sysled_ctrl, child)) + continue; + + msleep(5); + } + + return srg_led_control_sync(sysled_ctrl);; +} + +static void srg_led_disable(struct i2c_client *client) +{ + struct srg_led_ctrl *sysled_ctrl = i2c_get_clientdata(client); + int i; + + for (i = 1; i < 10; i++) + srg_led_i2c_write(sysled_ctrl, i, 0); +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0) +static void +#else +static int +#endif +srg_led_remove(struct i2c_client *client) +{ + struct srg_led_ctrl *sysled_ctrl = i2c_get_clientdata(client); + + srg_led_disable(client); + mutex_destroy(&sysled_ctrl->lock); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,16,0) + return 0; +#endif +} + +static const struct i2c_device_id srg_led_id[] = { + { "srg-sysled", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, srg_led_id); + +static const struct of_device_id of_srg_led_match[] = { + { .compatible = "srg,sysled", }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_srg_led_match); + +static struct i2c_driver srg_sysled_driver = { + .driver = { + .name = "srg-sysled", + .of_match_table = of_srg_led_match, + }, + .probe = srg_led_probe, + .remove = srg_led_remove, + .id_table = srg_led_id, +}; +module_i2c_driver(srg_sysled_driver); + +MODULE_DESCRIPTION("SmartRG system LED driver"); +MODULE_AUTHOR("Shen Loh "); +MODULE_AUTHOR("Daniel Golle "); +MODULE_LICENSE("GPL v2"); diff --git a/target/linux/mediatek/filogic/config-5.15 b/target/linux/mediatek/filogic/config-5.15 index 8c46b9ad2c..1499f79b9a 100644 --- a/target/linux/mediatek/filogic/config-5.15 +++ b/target/linux/mediatek/filogic/config-5.15 @@ -195,6 +195,7 @@ CONFIG_IRQ_TIME_ACCOUNTING=y CONFIG_IRQ_WORK=y CONFIG_JBD2=y CONFIG_JUMP_LABEL=y +CONFIG_LEDS_SMARTRG_LED=y CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOCK_SPIN_ON_OWNER=y diff --git a/target/linux/mediatek/filogic/config-6.1 b/target/linux/mediatek/filogic/config-6.1 index 0bd5e9cb70..9473967d00 100644 --- a/target/linux/mediatek/filogic/config-6.1 +++ b/target/linux/mediatek/filogic/config-6.1 @@ -212,6 +212,7 @@ CONFIG_IRQ_TIME_ACCOUNTING=y CONFIG_IRQ_WORK=y CONFIG_JBD2=y CONFIG_JUMP_LABEL=y +CONFIG_LEDS_SMARTRG_LED=y CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOCK_SPIN_ON_OWNER=y diff --git a/target/linux/mediatek/mt7622/config-5.15 b/target/linux/mediatek/mt7622/config-5.15 index 643eaa45b6..18f972e949 100644 --- a/target/linux/mediatek/mt7622/config-5.15 +++ b/target/linux/mediatek/mt7622/config-5.15 @@ -215,6 +215,7 @@ CONFIG_IRQ_TIME_ACCOUNTING=y CONFIG_IRQ_WORK=y CONFIG_JBD2=y CONFIG_JUMP_LABEL=y +# CONFIG_LEDS_SMARTRG_LED is not set CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOCK_SPIN_ON_OWNER=y diff --git a/target/linux/mediatek/mt7622/config-6.1 b/target/linux/mediatek/mt7622/config-6.1 index 7055e4d728..6272a3bac6 100644 --- a/target/linux/mediatek/mt7622/config-6.1 +++ b/target/linux/mediatek/mt7622/config-6.1 @@ -216,6 +216,7 @@ CONFIG_IRQ_TIME_ACCOUNTING=y CONFIG_IRQ_WORK=y CONFIG_JBD2=y CONFIG_JUMP_LABEL=y +# CONFIG_LEDS_SMARTRG_LED is not set CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOCK_SPIN_ON_OWNER=y diff --git a/target/linux/mediatek/mt7623/config-5.15 b/target/linux/mediatek/mt7623/config-5.15 index 039a904f19..2f12488327 100644 --- a/target/linux/mediatek/mt7623/config-5.15 +++ b/target/linux/mediatek/mt7623/config-5.15 @@ -297,6 +297,7 @@ CONFIG_KMAP_LOCAL_NON_LINEAR_PTE_ARRAY=y CONFIG_LCD_CLASS_DEVICE=y CONFIG_LCD_PLATFORM=y CONFIG_LEDS_MT6323=y +# CONFIG_LEDS_SMARTRG_LED is not set CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOCK_SPIN_ON_OWNER=y diff --git a/target/linux/mediatek/mt7623/config-6.1 b/target/linux/mediatek/mt7623/config-6.1 index b6a75ab80a..218016b200 100644 --- a/target/linux/mediatek/mt7623/config-6.1 +++ b/target/linux/mediatek/mt7623/config-6.1 @@ -317,6 +317,7 @@ CONFIG_LCD_CLASS_DEVICE=y CONFIG_LCD_PLATFORM=y CONFIG_LEDS_MT6323=y # CONFIG_LEDS_QCOM_LPG is not set +# CONFIG_LEDS_SMARTRG_LED is not set CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOCK_SPIN_ON_OWNER=y diff --git a/target/linux/mediatek/mt7629/config-5.15 b/target/linux/mediatek/mt7629/config-5.15 index 08089dde2a..8cddb04d66 100644 --- a/target/linux/mediatek/mt7629/config-5.15 +++ b/target/linux/mediatek/mt7629/config-5.15 @@ -149,6 +149,7 @@ CONFIG_IRQ_FORCED_THREADING=y CONFIG_IRQ_TIME_ACCOUNTING=y CONFIG_IRQ_WORK=y # CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set +# CONFIG_LEDS_SMARTRG_LED is not set CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOCK_SPIN_ON_OWNER=y diff --git a/target/linux/mediatek/mt7629/config-6.1 b/target/linux/mediatek/mt7629/config-6.1 index c0c501e59e..ad79b5ba9e 100644 --- a/target/linux/mediatek/mt7629/config-6.1 +++ b/target/linux/mediatek/mt7629/config-6.1 @@ -165,6 +165,7 @@ CONFIG_IRQ_TIME_ACCOUNTING=y CONFIG_IRQ_WORK=y # CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set CONFIG_LIBFDT=y +# CONFIG_LEDS_SMARTRG_LED is not set CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOCK_SPIN_ON_OWNER=y CONFIG_LZO_COMPRESS=y diff --git a/target/linux/mediatek/patches-5.15/950-smartrg-i2c-led-driver.patch b/target/linux/mediatek/patches-5.15/950-smartrg-i2c-led-driver.patch new file mode 100644 index 0000000000..9f7b4ef338 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/950-smartrg-i2c-led-driver.patch @@ -0,0 +1,34 @@ +--- + drivers/leds/Kconfig | 10 ++++++++++ + drivers/leds/Makefile | 1 + + 2 files changed, 11 insertions(+) + +--- a/drivers/leds/Kconfig ++++ b/drivers/leds/Kconfig +@@ -877,6 +877,16 @@ source "drivers/leds/blink/Kconfig" + comment "Flash and Torch LED drivers" + source "drivers/leds/flash/Kconfig" + ++config LEDS_SMARTRG_LED ++ tristate "LED support for Adtran SmartRG" ++ depends on LEDS_CLASS && I2C && OF ++ help ++ This option enables support for the Adtran SmartRG platform ++ system LED driver. ++ ++ To compile this driver as a module, choose M here: the module ++ will be called leds-smartrg-system. ++ + comment "LED Triggers" + source "drivers/leds/trigger/Kconfig" + +--- a/drivers/leds/Makefile ++++ b/drivers/leds/Makefile +@@ -77,6 +77,7 @@ obj-$(CONFIG_LEDS_PWM) += leds-pwm.o + obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o + obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o + obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o ++obj-$(CONFIG_LEDS_SMARTRG_LED) += leds-smartrg-system.o + obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o + obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o + obj-$(CONFIG_LEDS_TCA6507) += leds-tca6507.o diff --git a/target/linux/mediatek/patches-6.1/950-smartrg-i2c-led-driver.patch b/target/linux/mediatek/patches-6.1/950-smartrg-i2c-led-driver.patch new file mode 100644 index 0000000000..a98cca19a5 --- /dev/null +++ b/target/linux/mediatek/patches-6.1/950-smartrg-i2c-led-driver.patch @@ -0,0 +1,34 @@ +--- + drivers/leds/Kconfig | 10 ++++++++++ + drivers/leds/Makefile | 1 + + 2 files changed, 11 insertions(+) + +--- a/drivers/leds/Kconfig ++++ b/drivers/leds/Kconfig +@@ -873,6 +873,16 @@ source "drivers/leds/flash/Kconfig" + comment "RGB LED drivers" + source "drivers/leds/rgb/Kconfig" + ++config LEDS_SMARTRG_LED ++ tristate "LED support for Adtran SmartRG" ++ depends on LEDS_CLASS && I2C && OF ++ help ++ This option enables support for the Adtran SmartRG platform ++ system LED driver. ++ ++ To compile this driver as a module, choose M here: the module ++ will be called leds-smartrg-system. ++ + comment "LED Triggers" + source "drivers/leds/trigger/Kconfig" + +--- a/drivers/leds/Makefile ++++ b/drivers/leds/Makefile +@@ -76,6 +76,7 @@ obj-$(CONFIG_LEDS_PWM) += leds-pwm.o + obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o + obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o + obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o ++obj-$(CONFIG_LEDS_SMARTRG_LED) += leds-smartrg-system.o + obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o + obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o + obj-$(CONFIG_LEDS_TCA6507) += leds-tca6507.o From 3aa686f8d4d89ab28e749874c4b5e82d46685f3c Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Fri, 17 Nov 2023 02:25:09 +0000 Subject: [PATCH 04/17] mediatek: add support for Adtran SmartRG Bonanza Peak series MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Bonanza Peak series are a couple of MT7986-powered 2.5 GBit/s Wi-Fi 6 residential gateway, access point and mesh router products. All of them come with an eMMC to boot from, are powered via USB-C and got a USB 3.0 type-A port. All of them got a Dialog (Renesas) DA14531 Bluetooth module connected via UART. If the device was previously running stock firmware, the BT chip's internal flash has been loaded with firmware and it can be attached using hciattach when using OpenWrt. SOC: MediaTek MT7986A RAM: 2 GiB DDR4 eMMC: 8 GiB Bluetooth: BLE5 (DA14531) Serial: 3.3V level, 115200 8n1 on 4-pin connector * SDG-8612 - Dual-band RJ-45 gateway 2x 2.5G MaxLinear PHY for WAN port 3x 1GE LAN ports via MT7531 switch * SDG-8614 - Dual-band SFP gateway 1x SFP cage with up to 2.5G speed 1x 2.5G MaxLinear PHY for LAN port 3x 1GE LAN ports via MT7531 switch * SDG-8622 - Tri-band mesh router 2x 2.5G MaxLinear PHY The MT7986 2G and 5G are used as 2G and 5G high band. There’s a MT7915 PCIe card for 5G low band. * SDG-8632 - Tri-band mesh router with 6 GHz 2x 2.5G MaxLinear PHY The MT7986 serves the 2G and 6G bands. There’s a MT7915 PCIe card for 5G. Installation via U-Boot serial console: 0. setup TFTP server with IP 192.168.1.10/24, place initramfs image renamed to openwrt.XXX where XXX is the internal product number: SDG-8612: XXX = 412 SDG-8614: XXX = 414 SDG-8622: XXX = 422 SDG-8632: XXX = 432 1. connect to the serial console and power on the device. Interrupt the bootloader by pressing 'st' 2. setenv boot_mode openwrt ; saveenv 3. run boot1 Load firmware via TFTP and write to flash 4. run boot2 Now OpenWrt initramfs should boot 5. upload sysupgrade.bin via scp to /tmp 6. sysupgrade Signed-off-by: Daniel Golle --- .../lib/preinit/05_set_preinit_iface | 5 + .../mediatek/dts/mt7986a-smartrg-SDG-8612.dts | 76 +++ .../mediatek/dts/mt7986a-smartrg-SDG-8614.dts | 124 +++++ .../mediatek/dts/mt7986a-smartrg-SDG-8622.dts | 38 ++ .../mediatek/dts/mt7986a-smartrg-SDG-8632.dts | 38 ++ .../dts/mt7986a-smartrg-bonanza-peak.dtsi | 481 ++++++++++++++++++ .../filogic/base-files/etc/board.d/02_network | 12 + .../etc/hotplug.d/firmware/11-mt76-caldata | 18 +- .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 9 + .../base-files/lib/preinit/10_fix_eth_mac.sh | 17 + .../base-files/lib/upgrade/platform.sh | 6 +- target/linux/mediatek/image/filogic.mk | 38 ++ 12 files changed, 859 insertions(+), 3 deletions(-) create mode 100644 target/linux/mediatek/dts/mt7986a-smartrg-SDG-8612.dts create mode 100644 target/linux/mediatek/dts/mt7986a-smartrg-SDG-8614.dts create mode 100644 target/linux/mediatek/dts/mt7986a-smartrg-SDG-8622.dts create mode 100644 target/linux/mediatek/dts/mt7986a-smartrg-SDG-8632.dts create mode 100644 target/linux/mediatek/dts/mt7986a-smartrg-bonanza-peak.dtsi diff --git a/target/linux/mediatek/base-files/lib/preinit/05_set_preinit_iface b/target/linux/mediatek/base-files/lib/preinit/05_set_preinit_iface index 5e7fc81ad8..9daf1ef26b 100644 --- a/target/linux/mediatek/base-files/lib/preinit/05_set_preinit_iface +++ b/target/linux/mediatek/base-files/lib/preinit/05_set_preinit_iface @@ -1,5 +1,10 @@ set_preinit_iface() { case $(board_name) in + smartrg,sdg-8622|\ + smartrg,sdg-8632) + ip link set lan up + ifname=lan + ;; glinet,gl-mt3000) ip link set eth1 up ifname=eth1 diff --git a/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8612.dts b/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8612.dts new file mode 100644 index 0000000000..1537fc2c1a --- /dev/null +++ b/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8612.dts @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2022 SmartRG Inc. + * Author: Chad Monroe + */ + +#include "mt7986a-smartrg-bonanza-peak.dtsi" + +/ { + model = "SmartRG SDG-8612"; + compatible = "smartrg,sdg-8612", "mediatek,mt7986a"; +}; + +&gmac0 { + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; +}; + +&gmac1 { + phy-handle = <&phy6>; +}; + +&mdio { + switch: switch@1f { + compatible = "mediatek,mt7531"; + reg = <31>; + reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan3"; + }; + + port@2 { + reg = <2>; + label = "lan2"; + }; + + port@3 { + reg = <3>; + label = "lan1"; + }; + + port5: port@5 { + reg = <5>; + label = "lan4"; + + phy-mode = "2500base-x"; + phy-handle = <&phy5>; + }; + + port@6 { + reg = <6>; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; + }; +}; + +&wifi { + ieee80211-freq-limit = <2400000 2500000>, <5170000 5835000>; +}; diff --git a/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8614.dts b/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8614.dts new file mode 100644 index 0000000000..15cfb1f125 --- /dev/null +++ b/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8614.dts @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2022 SmartRG Inc. + * Author: Chad Monroe + */ + +#include "mt7986a-smartrg-bonanza-peak.dtsi" + +/ { + model = "SmartRG SDG-8614"; + compatible = "smartrg,sdg-8614", "mediatek,mt7986a"; + + /* SFP1 cage (WAN) */ + i2c_sfp1: i2c-gpio-0 { + compatible = "i2c-gpio"; + sda-gpios = <&pio 62 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&pio 63 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp1: sfp1 { + compatible = "sff,sfp"; + i2c-bus = <&i2c_sfp1>; + los-gpios = <&pio 20 GPIO_ACTIVE_HIGH>; + mod-def0-gpios = <&pio 65 GPIO_ACTIVE_LOW>; + rate-select0-gpios = <&pio 9 GPIO_ACTIVE_HIGH>; + rate-select1-gpios = <&pio 28 GPIO_ACTIVE_HIGH>; + tx-disable-gpios = <&pio 64 GPIO_ACTIVE_HIGH>; + tx-fault-gpios = <&pio 7 GPIO_ACTIVE_HIGH>; + maximum-power-milliwatt = <3000>; + }; + + leds { + compatible = "gpio-leds"; + + sfp_red { + color = ; + function = "sfp"; + function-enumerator = <1>; + gpios = <&pio 16 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + sfp_green { + color = ; + function = "sfp"; + function-enumerator = <0>; + gpios = <&pio 19 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + }; +}; + +&mux_sel { + output-low; + /delete-node/ output-high; +}; + +&gmac0 { + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; +}; + +&gmac1 { + sfp = <&sfp1>; + managed = "in-band-status"; +}; + +&mdio { + switch: switch@1f { + compatible = "mediatek,mt7531"; + reg = <31>; + reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan3"; + }; + + port@2 { + reg = <2>; + label = "lan2"; + }; + + port@3 { + reg = <3>; + label = "lan1"; + }; + + port5: port@5 { + reg = <5>; + label = "lan4"; + + phy-mode = "2500base-x"; + phy-handle = <&phy5>; + }; + + port@6 { + reg = <6>; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; + }; +}; + +&wifi { + ieee80211-freq-limit = <2400000 2500000>, <5170000 5835000>; +}; diff --git a/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8622.dts b/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8622.dts new file mode 100644 index 0000000000..2c28c8f7b4 --- /dev/null +++ b/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8622.dts @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2022 SmartRG Inc. + * Author: Chad Monroe + */ + +#include "mt7986a-smartrg-bonanza-peak.dtsi" + +/ { + model = "SmartRG SDG-8622"; + compatible = "smartrg,sdg-8622", "mediatek,mt7986a"; +}; + +&gmac0 { + phy-handle = <&phy5>; + + label = "lan"; +}; + +&gmac1 { + phy-handle = <&phy6>; +}; + +&pcie { + status = "okay"; +}; + +&pcie_phy { + status = "okay"; +}; + +&radio0 { + ieee80211-freq-limit = <5170000 5330000>; +}; + +&wifi { + ieee80211-freq-limit = <2400000 2500000>, <5490000 5835000>; +}; diff --git a/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8632.dts b/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8632.dts new file mode 100644 index 0000000000..bc92f85aa0 --- /dev/null +++ b/target/linux/mediatek/dts/mt7986a-smartrg-SDG-8632.dts @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2022 SmartRG Inc. + * Author: Chad Monroe + */ + +#include "mt7986a-smartrg-bonanza-peak.dtsi" + +/ { + model = "SmartRG SDG-8632"; + compatible = "smartrg,sdg-8632", "mediatek,mt7986a"; +}; + +&gmac0 { + phy-handle = <&phy5>; + + label = "lan"; +}; + +&gmac1 { + phy-handle = <&phy6>; +}; + +&pcie { + status = "okay"; +}; + +&pcie_phy { + status = "okay"; +}; + +&radio0 { + ieee80211-freq-limit = <5170000 5835000>; +}; + +&wifi { + ieee80211-freq-limit = <2400000 2500000>, <5945000 7125000>; +}; diff --git a/target/linux/mediatek/dts/mt7986a-smartrg-bonanza-peak.dtsi b/target/linux/mediatek/dts/mt7986a-smartrg-bonanza-peak.dtsi new file mode 100644 index 0000000000..038a76ad73 --- /dev/null +++ b/target/linux/mediatek/dts/mt7986a-smartrg-bonanza-peak.dtsi @@ -0,0 +1,481 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2022 SmartRG Inc. + * Author: Chad Monroe + */ + +/dts-v1/; +#include +#include +#include + +#include "mt7986a.dtsi" + +/ { + aliases { + serial0 = &uart0; + ethernet0 = &gmac0; + ethernet1 = &gmac1; + led-boot = &led_status_green; + led-failsafe = &led_status_red; + led-running = &led_status_white; + led-upgrade = &led_status_blue; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs = "root=/dev/mmcblk0p5"; + }; + + memory@40000000 { + device_type = "memory"; + reg = <0 0x40000000 0 0x40000000>; + }; + + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + /delete-node/ramoops@42ff0000; + + bootdata_reserved: bootdata@45000000 { + no-map; + reg = <0x0 0x45000000 0x0 0x00001000>; + }; + + ramoops_reserved: ramoops@45001000 { + no-map; + compatible = "ramoops"; + reg = <0x0 0x45001000 0x0 0x00140000>; + ftrace-size = <0x20000>; + record-size = <0x20000>; + console-size = <0x20000>; + pmsg-size = <0x80000>; + }; + }; + + bootdata { + compatible = "bootdata"; + memory-region = <&bootdata_reserved>; + }; + + reg_1p8v: regulator-1p8v { + compatible = "regulator-fixed"; + regulator-name = "fixed-1.8V"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + regulator-always-on; + }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "fixed-3.3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + regulator-always-on; + }; + + reg_5v: regulator-5v { + compatible = "regulator-fixed"; + regulator-name = "fixed-5V"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + regulator-always-on; + }; + + fan: pwm-fan { + compatible = "pwm-fan"; + #cooling-cells = <2>; + pwms = <&pwm 1 40000 0>; + + /** + * set fan speed + * + * 0 = off + * 51 = 20% duty cycle (minimum supported) + * 61 = 24% duty cycle (2020 RPM) + * 77 = 30% duty cycle (3000 RPM) + * 102 = 40% duty cycle (3600 RPM) + * 255 = 100% duty cycle + */ + cooling-levels = <51 61 77 102>; + + interrupt-parent = <&pio>; + interrupts = <25 IRQ_TYPE_EDGE_FALLING>; + pulses-per-revolution = <2>; + + status = "okay"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-names = "default"; + pinctrl-0 = <&button_pins>; + + button-reset { + label = "reset"; + linux,code = ; + gpios = <&pio 17 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&cpu_thermal { + cooling-maps { + cpu-active-high { + /* active: set fan to cooling level 3 */ + cooling-device = <&fan 3 3>; + trip = <&cpu_trip_active_high>; + }; + + cpu-active-medium { + /* active: set fan to cooling level 2 */ + cooling-device = <&fan 2 2>; + trip = <&cpu_trip_active_medium>; + }; + + cpu-active-low { + /* active: set fan to cooling level 1 */ + cooling-device = <&fan 1 1>; + trip = <&cpu_trip_active_low>; + }; + + cpu-active-silent { + /* active: set fan to cooling level 0 */ + cooling-device = <&fan 0 0>; + trip = <&cpu_trip_active_silent>; + }; + }; + + trips { + cpu_trip_active_high: active-high { + temperature = <110000>; + hysteresis = <2000>; + type = "active"; + }; + + cpu_trip_active_medium: active-medium { + temperature = <80000>; + hysteresis = <2000>; + type = "active"; + }; + + cpu_trip_active_low: active-low { + temperature = <60000>; + hysteresis = <2000>; + type = "active"; + }; + + cpu_trip_active_silent: active-silent { + temperature = <40000>; + hysteresis = <2000>; + type = "active"; + }; + }; +}; + +&crypto { + status = "okay"; +}; + +ð { + status = "okay"; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + + phy-mode = "2500base-x"; + }; + + gmac1: mac@1 { + label = "wan"; + + compatible = "mediatek,eth-mac"; + reg = <1>; + + phy-mode = "2500base-x"; + }; + + mdio: mdio-bus { + #address-cells = <1>; + #size-cells = <0>; + }; +}; + +&mdio { + #address-cells = <1>; + #size-cells = <0>; + + reset-gpios = <&pio 6 GPIO_ACTIVE_LOW>; + reset-delay-us = <1500000>; + reset-post-delay-us = <1000000>; + + phy5: ethernet-phy@5 { + /* GPY211 */ + compatible = "maxlinear,gpy211", "ethernet-phy-ieee802.3-c45"; + reg = <5>; + + mxl,led-drive-vdd; + mxl,led-config = <0x30 0x40 0x80 0x0>; + }; + + phy6: ethernet-phy@6 { + /* GPY211 */ + compatible = "maxlinear,gpy211", "ethernet-phy-ieee802.3-c45"; + reg = <6>; + + mxl,led-drive-vdd; + mxl,led-config = <0x30 0x40 0x80 0x0>; + }; +}; + +&crypto { + status = "okay"; +}; + +&mmc0 { + pinctrl-names = "default", "state_uhs"; + pinctrl-0 = <&mmc0_pins_default>; + pinctrl-1 = <&mmc0_pins_uhs>; + bus-width = <8>; + max-frequency = <200000000>; + cap-mmc-highspeed; + mmc-hs200-1_8v; + mmc-hs400-1_8v; + hs400-ds-delay = <0x14014>; + vmmc-supply = <®_3p3v>; + vqmmc-supply = <®_1p8v>; + non-removable; + no-sd; + no-sdio; + status = "okay"; +}; + +&pcie { + pinctrl-names = "default"; + pinctrl-0 = <&pcie_pins>; + status = "disabled"; + + slot0: pcie@0,0 { + reg = <0x0000 0 0 0 0>; + + radio0: mt7915@0,0 { + reg = <0x0000 0 0 0 0>; + }; + }; +}; + +&pcie_phy { + status = "disabled"; +}; + +&wifi { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&wf_2g_5g_pins>; +}; + +&pio { + mmc0_pins_default: mmc0-pins { + mux { + function = "emmc"; + groups = "emmc_51"; + }; + conf-cmd-dat { + pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2", + "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5", + "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD"; + input-enable; + drive-strength = <4>; + mediatek,pull-up-adv = <1>; /* pull-up 10K */ + }; + conf-clk { + pins = "EMMC_CK"; + drive-strength = <6>; + mediatek,pull-down-adv = <2>; /* pull-down 50K */ + }; + conf-ds { + pins = "EMMC_DSL"; + mediatek,pull-down-adv = <2>; /* pull-down 50K */ + }; + conf-rst { + pins = "EMMC_RSTB"; + drive-strength = <4>; + mediatek,pull-up-adv = <1>; /* pull-up 10K */ + }; + }; + + mmc0_pins_uhs: mmc0-uhs-pins { + mux { + function = "emmc"; + groups = "emmc_51"; + }; + conf-cmd-dat { + pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2", + "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5", + "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD"; + input-enable; + drive-strength = <4>; + mediatek,pull-up-adv = <1>; /* pull-up 10K */ + }; + conf-clk { + pins = "EMMC_CK"; + drive-strength = <6>; + mediatek,pull-down-adv = <2>; /* pull-down 50K */ + }; + conf-ds { + pins = "EMMC_DSL"; + mediatek,pull-down-adv = <2>; /* pull-down 50K */ + }; + conf-rst { + pins = "EMMC_RSTB"; + drive-strength = <4>; + mediatek,pull-up-adv = <1>; /* pull-up 10K */ + }; + }; + + pcie_pins: pcie-pins { + mux { + function = "pcie"; + groups = "pcie_clk", "pcie_pereset"; + }; + }; + + button_pins: button-pins { + pins = "GPIO_12"; + mediatek,pull-down-adv = <0>; /* bias-disable */ + }; + + uart1_pins: uart1-pins { + mux { + function = "uart"; + groups = "uart1_2_rx_tx", "uart1_2_cts_rts"; + }; + }; + + i2c0_pins: i2c0-pins { + mux { + function = "i2c"; + groups = "i2c"; + }; + }; + + pwm_pins: pwm-pins { + mux { + function = "pwm"; + groups = "pwm0", "pwm1_0"; + }; + }; + + wf_2g_5g_pins: wf-2g-5g-pins { + mux { + function = "wifi"; + groups = "wf_2g", "wf_5g"; + }; + conf { + pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4", + "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6", + "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10", + "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1", + "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0", + "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8", + "WF1_TOP_CLK", "WF1_TOP_DATA"; + drive-strength = <4>; + }; + }; + + mux_sel: mux-sel-hog { + gpio-hog; + gpios = <23 GPIO_ACTIVE_LOW>; + line-name = "mux-sel"; + output-high; + }; + + mux_oe: mux-oe-hog { + gpio-hog; + gpios = <24 GPIO_ACTIVE_LOW>; + line-name = "mux-oe"; + output-high; + }; +}; + +&ssusb { + vusb33-supply = <®_3p3v>; + vbus-supply = <®_5v>; + status = "okay"; +}; + +&trng { + status = "okay"; +}; + +&uart0 { + status = "okay"; +}; + +&uart1 { + pinctrl-names = "default"; + pinctrl-0 = <&uart1_pins>; + status = "okay"; + + /* DA14531MOD Bluetooth */ + bluetooth { + compatible = "renesas,DA14531"; + reset-gpios = <&pio 27 GPIO_ACTIVE_LOW>; + }; +}; + +&usb_phy { + status = "okay"; +}; + +&i2c0 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pins>; + status = "okay"; + + system-leds { + compatible = "srg,sysled"; + reg = <0x30>; + + led_status_red: led@1 { + color = ; + function = LED_FUNCTION_STATUS; + reg = <1>; + }; + + led_status_green: led@2 { + color = ; + function = LED_FUNCTION_STATUS; + reg = <2>; + }; + + led_status_blue: led@3 { + color = ; + function = LED_FUNCTION_STATUS; + reg = <3>; + }; + + led_status_white: led@4 { + color = ; + function = LED_FUNCTION_STATUS; + reg = <4>; + }; + }; +}; + +&pwm { + pinctrl-names = "default"; + pinctrl-0 = <&pwm_pins>; + status = "okay"; +}; + +&watchdog { + interrupts = ; + status = "okay"; +}; diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network index 962cdfb83a..1c41a9f8ed 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network @@ -62,6 +62,10 @@ mediatek_setup_interfaces() zyxel,nwa50ax-pro) ucidef_set_interface_lan "eth0" ;; + smartrg,sdg-8622|\ + smartrg,sdg-8632) + ucidef_set_interfaces_lan_wan lan wan + ;; tplink,tl-xdr6086) ucidef_set_interfaces_lan_wan "lan1 lan2" eth1 ;; @@ -142,6 +146,14 @@ mediatek_setup_macs() wan_mac=$(macaddr_add "$lan_mac" 1) label_mac=$wan_mac ;; + smartrg,sdg-8612|\ + smartrg,sdg-8614|\ + smartrg,sdg-8622|\ + smartrg,sdg-8632) + label_mac=$(mmc_get_mac_ascii mfginfo MFG_MAC) + wan_mac=$label_mac + lan_mac=$(macaddr_add "$label_mac" 1) + ;; xiaomi,mi-router-wr30u-112m-nmbm|\ xiaomi,mi-router-wr30u-stock|\ xiaomi,mi-router-wr30u-ubootmod|\ diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata index 4d9833f66c..e3181b2d8c 100644 --- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata +++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata @@ -7,10 +7,18 @@ board=$(board_name) case "$FIRMWARE" in +"mediatek/mt7915_eeprom.bin") + case "$board" in + smartrg,sdg-8622) + caldata_extract_mmc "factory" 0xa0000 0x1000 + ;; + esac + ;; "mediatek/mt7916_eeprom.bin") case "$board" in - acer,predator-w6) - caldata_extract_mmc "factory" 0xA0000 0x1000 + acer,predator-w6|\ + smartrg,sdg-8632) + caldata_extract_mmc "factory" 0xa0000 0x1000 ;; esac ;; @@ -34,6 +42,12 @@ case "$FIRMWARE" in ln -sf /tmp/tp_data/MT7986_EEPROM.bin \ /lib/firmware/$FIRMWARE ;; + smartrg,sdg-8612|\ + smartrg,sdg-8614|\ + smartrg,sdg-8622|\ + smartrg,sdg-8632) + caldata_extract_mmc "factory" 0x0 0x1000 + ;; esac ;; "mediatek/mt7986_eeprom_mt7976.bin") diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac index f4d99eb148..7f1d0c5364 100644 --- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac +++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac @@ -85,6 +85,15 @@ case "$board" in [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress ;; + smartrg,sdg-8612|\ + smartrg,sdg-8614|\ + smartrg,sdg-8622|\ + smartrg,sdg-8632) + addr=$(mmc_get_mac_ascii mfginfo MFG_MAC) + [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress + ;; tplink,tl-xdr4288|\ tplink,tl-xdr6086|\ tplink,tl-xdr6088) diff --git a/target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh b/target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh index d770b13643..37b5be1334 100644 --- a/target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh +++ b/target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh @@ -21,6 +21,23 @@ preinit_set_mac_address() { addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0) ip link set dev eth1 address "$(macaddr_add $addr 1)" ;; + smartrg,sdg-8612|\ + smartrg,sdg-8614) + addr=$(mmc_get_mac_ascii mfginfo MFG_MAC) + lan_addr=$(macaddr_add $addr 1) + ip link set dev wan address "$addr" + ip link set dev eth0 address "$lan_addr" + ip link set dev lan1 address "$lan_addr" + ip link set dev lan2 address "$lan_addr" + ip link set dev lan3 address "$lan_addr" + ip link set dev lan4 address "$lan_addr" + ;; + smartrg,sdg-8622|\ + smartrg,sdg-8632) + addr=$(mmc_get_mac_ascii mfginfo MFG_MAC) + ip link set dev wan address "$addr" + ip link set dev lan address "$(macaddr_add $addr 1)" + ;; *) ;; esac diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh index c9599cdc9b..e59ffcfbc7 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -51,7 +51,11 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in - acer,predator-w6) + acer,predator-w6|\ + smartrg,sdg-8612|\ + smartrg,sdg-8614|\ + smartrg,sdg-8622|\ + smartrg,sdg-8632) CI_KERNPART="kernel" CI_ROOTPART="rootfs" emmc_do_upgrade "$1" diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 58dc2ce97f..36333bb926 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -137,6 +137,44 @@ define Device/acer_predator-w6 endef TARGET_DEVICES += acer_predator-w6 +define Device/adtran_smartrg + DEVICE_VENDOR := Adtran + DEVICE_DTS_DIR := ../dts + DEVICE_PACKAGES := e2fsprogs f2fsck mkf2fs kmod-hwmon-pwmfan \ + kmod-mt7986-firmware mt7986-wo-firmware + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +endef + +define Device/smartrg_sdg-8612 +$(call Device/adtran_smartrg) + DEVICE_MODEL := SDG-8612 + DEVICE_DTS := mt7986a-smartrg-SDG-8612 +endef +TARGET_DEVICES += smartrg_sdg-8612 + +define Device/smartrg_sdg-8614 +$(call Device/adtran_smartrg) + DEVICE_MODEL := SDG-8614 + DEVICE_DTS := mt7986a-smartrg-SDG-8614 +endef +TARGET_DEVICES += smartrg_sdg-8614 + +define Device/smartrg_sdg-8622 +$(call Device/adtran_smartrg) + DEVICE_MODEL := SDG-8622 + DEVICE_DTS := mt7986a-smartrg-SDG-8622 + DEVICE_PACKAGES += kmod-mt7915-firmware +endef +TARGET_DEVICES += smartrg_sdg-8622 + +define Device/smartrg_sdg-8632 +$(call Device/adtran_smartrg) + DEVICE_MODEL := SDG-8632 + DEVICE_DTS := mt7986a-smartrg-SDG-8632 + DEVICE_PACKAGES += kmod-mt7915-firmware +endef +TARGET_DEVICES += smartrg_sdg-8632 + define Device/asus_tuf-ax4200 DEVICE_VENDOR := ASUS DEVICE_MODEL := TUF-AX4200 From 25e215c14ee6c9f3d54cd1da46a48d9ffe6b254e Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 10 Dec 2023 11:43:45 +0100 Subject: [PATCH 05/17] lua5.3: fix typo calling lua53 instead of lua5.3 for Package Default Fix typo calling lua53 instead of lua5.3 for Package Default definition. This cause only missing description of the package and doesn't cause any build regression. Fixes: c52ca08d4008 ("lua5.3: build shared library") Signed-off-by: Christian Marangi --- package/utils/lua5.3/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/utils/lua5.3/Makefile b/package/utils/lua5.3/Makefile index d43ac59ed4..0a295040f2 100644 --- a/package/utils/lua5.3/Makefile +++ b/package/utils/lua5.3/Makefile @@ -30,7 +30,7 @@ define Package/lua5.3/Default SUBMENU:=Lua SECTION:=lang CATEGORY:=Languages - TITLE:=Lua programming language + TITLE:=Lua programming language (version 5.3) URL:=https://www.lua.org/ MAINTAINER:=Jo-Philipp Wich endef @@ -42,7 +42,7 @@ define Package/lua5.3/Default/description endef define Package/liblua5.3 -$(call Package/lua53/Default) +$(call Package/lua5.3/Default) SUBMENU:= SECTION:=libs CATEGORY:=Libraries @@ -51,7 +51,7 @@ $(call Package/lua53/Default) endef define Package/liblua5.3/description -$(call Package/lua53/Default/description) +$(call Package/lua5.3/Default/description) This package contains the Lua shared libraries, needed by other programs. endef From da7b0351fce5dd59b79ea78d34c90c66b8bd6f6e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 11 Dec 2023 13:15:09 +0100 Subject: [PATCH 06/17] mt76: update to Git HEAD (2023-12-11) f63f87cd5b45 wifi: mt76: mt7996: fix shift overflow warning on 32 bit systems Signed-off-by: Felix Fietkau --- package/kernel/mt76/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index 762f474ce9..38a92c953e 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -8,9 +8,9 @@ PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/openwrt/mt76 PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2023-12-08 -PKG_SOURCE_VERSION:=f559adf1849c8af91f5a5eb670f4ed2c24988898 -PKG_MIRROR_HASH:=74dde4478442d5f0edbae918636b40767b0e49181b732d4184feeccd8a8cc328 +PKG_SOURCE_DATE:=2023-12-11 +PKG_SOURCE_VERSION:=f63f87cd5b45c3779293e6062c6b26bdf57e851d +PKG_MIRROR_HASH:=43f1b1fb75dfb4756aa1767983b338bd63154f0f6c45554029e69af49d55b914 PKG_MAINTAINER:=Felix Fietkau PKG_USE_NINJA:=0 From 2807dca071c74494b94d86e59f031f3cd0492b6b Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 7 Dec 2023 13:30:40 +0100 Subject: [PATCH 07/17] util-linux: update to v2.39.3 Changes: 2da5c904e build-sys: release++ (v2.39.3) 03c939edd docs: update v2.39.3-ReleaseNotes dafb120ef docs: update AUTHORS file bfc9691ce po-man: merge changes d2232b609 po: merge changes 4ab356c1c po: add ro.po (from translationproject.org) 7e147d16c po: update es.po (from translationproject.org) e8cb61f07 lsfd: fix memory leak in append_filter_expr() 192d8aaa0 lsfd: avoid undefined behavior 756588f8c lsfd: (man) fix the form for the optional argument of --inet option 8d78c1306 Add Phytium FTC310 & FTC664 support b75322cdb Add Phytium FTC862 cpu model. fix:#2486 ec1b0eb36 libmount: accept '\' as escape for options separator 2e5f5c8d8 tests: add ts_skip_docker 0b3254cac Merge branch 'stable-2.39/bcachefs-fixes' of https://github.com/t-8ch/util-linux into PR/stable-v2.39.3 649843934 tests: skip broken tests on docker fa9b53658 libblkid: (bcachefs) add support for sub-device labels 3c5d991b0 libblkid: (bcachefs) adapt to major.minor version ece194082 libuuid: avoid truncate clocks.txt to improve performance 84a62c1a5 libuuid/src/gen_uuid.c: fix cs_min declaration 93239aa78 libmount: fix possible NULL dereference [coverity scan] a6def815e meson: install wall executable with group 'tty' c6c1c69c3 meson: install write executable with group 'tty' bf2cd1d5a libmount: improve mnt_table_next_child_fs() c14f5bf37 docs: add SPDX to boilerplate.c fdd9f11f5 disk-utils: add SPDX and Copyright notices e7dbe9c78 include/audit-arch: add missing SPDX 5ec7b14a7 setterm: avoid restoring flags from uninitialized memory 64d2300e6 Fix man page for col to correct documentation error 7cc2c9625 Update col.c to fix option mistake 122d7e7af umount: handle bindmounts during --recursive da18b31ff lscpu: fix caches separator for --parse= 3a5c9c1dd Use empty libuser config file. 7058d793d libblkid: exfat: fix fail to find volume label d065ff00a blkpr: store return value of getopt_long in int 9ca6f1712 lib/path: Set errno in case of fgets failure e2f0aa5c2 autotools: fix AC_DEFINE_UNQUOTED() use cefd05c47 autotools: fix librtas check f27fbafb2 lib/path: fix typos f8ab70477 lib/path: set errno in case of error 5ec30a362 lib/path: fix possible out of boundary access edc723cd3 libblkid: reset errno before calling probefuncs 8de89778b setpriv: fix group argument completion 41599054c libfdisk: reset errno before calling read() cce4e4405 blkid: fix call to err_exclusive_options b718f985c docs: use HTTPS for GitHub clone URLs 2bddfa692 libblkid: (probe) handle probe without chain gracefully 3d3121678 lib/idcache: always gracefully handle null cache 368521e45 script-playutils: close filestream in case ignore_line() fails 087b0d238 libblkid: (vxfs) report endianness 7e5056f33 libblkid: (ntfs) validate that sector_size is a power of two f368ccc75 libsmartcols: handle nameless tables in export format f5cace8da ldattach: don't call exit() from signal handler 03c12a34c lslogins: fix realloc() loop allocation size 83ba179b1 lib/env: avoid underflow of read_all_alloc() return value 813851fba libblkid: avoid memory leak of cachefile path 4459623cd libmount: gracefully handle NULL path in mnt_resolve_target() dbde7a537 more: avoid out-of-bound access c26badd5d libfdisk: handle allocation failure in fdisk_new_partition 5c250aa64 login: Use pid_t for child_pid be3f1712e login: move comment 98be90b5b build-sys: fix libmount/src/hooks.c use a711af02d lscpu: Use 4K buffer size instead of BUFSIZ 45c6136cb autotools: fix typos aa98c4ecc libmount: make.stx_mnt_id use more robust c697c2bb6 libmount: report statx in features list 13711f3ab libmount: fix statx() includes e9ed5a2b8 libblkid: (vfat) avoid modifying shared buffer d2cadf099 libblkid: (jmicron_raid) use checksum APIs c54c99efd libblkid: (jmicron_raid) avoid modifying shared buffer 64418c52b libblkid: (zonefs) avoid modifying shared buffer b66da7ce4 losetup: fix JSON MAJ:MIN 44d7bf2c8 lslogins: (man) fix -y option formatting 7d6c71e51 include: add DragonFlyBSD GPT partition types 6b9fda87c libblkid: (bcachefs) fix size validation acbf17ae8 libblkid: (bcachefs) fix compiler warning [-Werror=sign-compare] 1ec71634a libblkid: (bcachefs) fix not detecting large superblocks 68564ebb5 libmount: Fix regression when mounting with atime Signed-off-by: Nick Hainke --- package/utils/util-linux/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/utils/util-linux/Makefile b/package/utils/util-linux/Makefile index 2ab72a2d2c..ec6925f0ea 100644 --- a/package/utils/util-linux/Makefile +++ b/package/utils/util-linux/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=util-linux -PKG_VERSION:=2.39.2 +PKG_VERSION:=2.39.3 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.39 -PKG_HASH:=87abdfaa8e490f8be6dde976f7c80b9b5ff9f301e1b67e3899e1f05a59a1531f +PKG_HASH:=7b6605e48d1a49f43cc4b4cfc59f313d0dd5402fa40b96810bd572e167dfed0f PKG_CPE_ID:=cpe:/a:kernel:util-linux PKG_LICENSE:=GPL-2.0-only From f6309956778adbe541db220a12662e61c1f8765e Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Sat, 11 Nov 2023 04:23:58 +0100 Subject: [PATCH 08/17] strace: update to 6.6 Release Notes: https://github.com/strace/strace/releases/tag/v6.6 Signed-off-by: Nick Hainke --- package/devel/strace/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/devel/strace/Makefile b/package/devel/strace/Makefile index 3343177c3e..8ff0ead807 100644 --- a/package/devel/strace/Makefile +++ b/package/devel/strace/Makefile @@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=strace -PKG_VERSION:=6.5 +PKG_VERSION:=6.6 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://strace.io/files/$(PKG_VERSION) -PKG_HASH:=dfb051702389e1979a151892b5901afc9e93bbc1c70d84c906ade3224ca91980 +PKG_HASH:=421b4186c06b705163e64dc85f271ebdcf67660af8667283147d5e859fc8a96c PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=LGPL-2.1-or-later From 9ed26a48d9c4617a20851968257700afcd149a28 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Sat, 11 Nov 2023 04:18:18 +0100 Subject: [PATCH 09/17] iproute2: update to 6.6.0 Release Notes: https://lore.kernel.org/netdev/20231106090325.07092c87@hermes.local/T/ Automatically refreshed: - 115-add-config-xtlibdir.patch - 175-reduce-dynamic-syms.patch - 195-build_variant_ip_tc.patch Signed-off-by: Nick Hainke --- package/network/utils/iproute2/Makefile | 4 ++-- .../iproute2/patches/115-add-config-xtlibdir.patch | 2 +- .../iproute2/patches/175-reduce-dynamic-syms.patch | 12 ++++++------ .../iproute2/patches/195-build_variant_ip_tc.patch | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package/network/utils/iproute2/Makefile b/package/network/utils/iproute2/Makefile index 7f4556e7d3..c21b78916b 100644 --- a/package/network/utils/iproute2/Makefile +++ b/package/network/utils/iproute2/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=iproute2 -PKG_VERSION:=6.5.0 +PKG_VERSION:=6.6.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2 -PKG_HASH:=a70179085fa1b96d3c33b040c809b75e2b57563adc505a4ad05e2609df373463 +PKG_HASH:=8738c804afd09f0bf756937f0c3de23117832a98d8cbbf50386cf5005cd613ce PKG_BUILD_PARALLEL:=1 PKG_BUILD_DEPENDS:=iptables PKG_LICENSE:=GPL-2.0 diff --git a/package/network/utils/iproute2/patches/115-add-config-xtlibdir.patch b/package/network/utils/iproute2/patches/115-add-config-xtlibdir.patch index 03df7809f7..c32863c364 100644 --- a/package/network/utils/iproute2/patches/115-add-config-xtlibdir.patch +++ b/package/network/utils/iproute2/patches/115-add-config-xtlibdir.patch @@ -1,6 +1,6 @@ --- a/tc/Makefile +++ b/tc/Makefile -@@ -127,6 +127,9 @@ CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PR +@@ -119,6 +119,9 @@ CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PR ifneq ($(IPT_LIB_DIR),) CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\" endif diff --git a/package/network/utils/iproute2/patches/175-reduce-dynamic-syms.patch b/package/network/utils/iproute2/patches/175-reduce-dynamic-syms.patch index d0914848d5..aef51395a9 100644 --- a/package/network/utils/iproute2/patches/175-reduce-dynamic-syms.patch +++ b/package/network/utils/iproute2/patches/175-reduce-dynamic-syms.patch @@ -1,6 +1,6 @@ --- a/tc/Makefile +++ b/tc/Makefile -@@ -113,7 +113,7 @@ LDLIBS += -L. -lm +@@ -106,7 +106,7 @@ LDLIBS += -L. -lm ifeq ($(SHARED_LIBS),y) LDLIBS += -ldl @@ -9,7 +9,7 @@ endif TCLIB := tc_core.o -@@ -143,7 +143,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc +@@ -135,7 +135,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc all: tc $(TCSO) tc: $(TCOBJ) $(LIBNETLINK) libtc.a @@ -18,15 +18,15 @@ libtc.a: $(TCLIB) $(QUIET_AR)$(AR) rcs $@ $^ -@@ -165,6 +165,7 @@ install: all +@@ -157,6 +157,7 @@ install: all clean: rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.tab.h; \ rm -f emp_ematch.tab.* + rm -f dynsyms.list - q_atm.so: q_atm.c - $(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm -@@ -204,4 +205,16 @@ static-syms.h: $(wildcard *.c) + m_xt.so: m_xt.c + $(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o m_xt.so m_xt.c $$($(PKG_CONFIG) xtables --cflags --libs) +@@ -193,4 +194,16 @@ static-syms.h: $(wildcard *.c) sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \ done > $@ diff --git a/package/network/utils/iproute2/patches/195-build_variant_ip_tc.patch b/package/network/utils/iproute2/patches/195-build_variant_ip_tc.patch index 141763460d..8156adbf05 100644 --- a/package/network/utils/iproute2/patches/195-build_variant_ip_tc.patch +++ b/package/network/utils/iproute2/patches/195-build_variant_ip_tc.patch @@ -11,7 +11,7 @@ --- a/tc/Makefile +++ b/tc/Makefile -@@ -140,7 +140,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc +@@ -132,7 +132,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc $(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic $< -o $@ From 303ff26dc79bc5323af595d7dae491f091e0e7e1 Mon Sep 17 00:00:00 2001 From: John Audia Date: Fri, 8 Dec 2023 08:12:51 -0500 Subject: [PATCH 10/17] kernel: bump 5.15 to 5.15.142 Changelog: https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.142 All patches automatically rebased. Build system: x86_64 Build-tested: ramips/tplink_archer-a6-v3 Run-tested: ramips/tplink_archer-a6-v3 Signed-off-by: John Audia --- include/kernel-5.15 | 4 ++-- .../patches-5.15/704-dpaa2-eth-do-not-hold-rtnl_lock.patch | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/kernel-5.15 b/include/kernel-5.15 index 809cec3065..12c8863579 100644 --- a/include/kernel-5.15 +++ b/include/kernel-5.15 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.15 = .141 -LINUX_KERNEL_HASH-5.15.141 = 936d6ac65c692a986b4bde34b7f3d7ad90f7f86f19e4ef320e008d40f07e2cfa +LINUX_VERSION-5.15 = .142 +LINUX_KERNEL_HASH-5.15.142 = 8d76c95277dc5ab0a6cd0069432af2ceb759d0ac2b6f5401330d390196095676 diff --git a/target/linux/layerscape/patches-5.15/704-dpaa2-eth-do-not-hold-rtnl_lock.patch b/target/linux/layerscape/patches-5.15/704-dpaa2-eth-do-not-hold-rtnl_lock.patch index c7d16e5c4c..bff41aa2a4 100644 --- a/target/linux/layerscape/patches-5.15/704-dpaa2-eth-do-not-hold-rtnl_lock.patch +++ b/target/linux/layerscape/patches-5.15/704-dpaa2-eth-do-not-hold-rtnl_lock.patch @@ -27,7 +27,7 @@ Signed-off-by: Russell King --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c -@@ -4217,12 +4217,10 @@ static irqreturn_t dpni_irq0_handler_thr +@@ -4215,12 +4215,10 @@ static irqreturn_t dpni_irq0_handler_thr dpaa2_eth_set_mac_addr(netdev_priv(net_dev)); dpaa2_eth_update_tx_fqids(priv); From 4b82a20e770cbff76680f6cf4fa6de42961ada54 Mon Sep 17 00:00:00 2001 From: Maso Huang Date: Thu, 7 Sep 2023 16:40:19 +0800 Subject: [PATCH 11/17] mediatek: backport MT7986 audio driver Pick commits adding drivers for audio engine found in MT7986 from Linux 6.6 as well as follow-up fixes from Linux 6.7. Signed-off-by: Maso Huang Signed-off-by: Daniel Golle --- ...oC-mediatek-mt7986-add-common-header.patch | 269 +++++++ ...7986-support-etdm-in-platform-driver.patch | 430 +++++++++++ ...-mediatek-mt7986-add-platform-driver.patch | 685 ++++++++++++++++++ ...t7986-add-machine-driver-with-wm8960.patch | 243 +++++++ ...-mediatek-mt7986-wm8960-add-mt7986-w.patch | 87 +++ ...-mediatek-mt7986-afe-add-audio-afe-d.patch | 180 +++++ ...7986-drop-the-remove-callback-of-mt7.patch | 42 ++ ...7986-remove-the-mt7986_wm8960_priv-s.patch | 105 +++ ...iatek-mt7986-add-sample-rate-checker.patch | 49 ++ ...7986-silence-error-in-case-of-EPROBE.patch | 26 + .../862-arm64-dts-mt7986-add-afe.patch | 40 + ...63-arm64-dts-mt7986-add-sound-wm8960.patch | 61 ++ ...986-move-cpuboot-in-a-dedicated-node.patch | 6 +- ...-mt7986-move-ilm-in-a-dedicated-node.patch | 6 +- ...-mt7986-move-dlm-in-a-dedicated-node.patch | 6 +- ...oC-mediatek-mt7986-add-common-header.patch | 269 +++++++ ...7986-support-etdm-in-platform-driver.patch | 430 +++++++++++ ...-mediatek-mt7986-add-platform-driver.patch | 685 ++++++++++++++++++ ...t7986-add-machine-driver-with-wm8960.patch | 243 +++++++ ...-mediatek-mt7986-wm8960-add-mt7986-w.patch | 87 +++ ...-mediatek-mt7986-afe-add-audio-afe-d.patch | 180 +++++ ...7986-drop-the-remove-callback-of-mt7.patch | 42 ++ ...7986-remove-the-mt7986_wm8960_priv-s.patch | 105 +++ ...iatek-mt7986-add-sample-rate-checker.patch | 49 ++ ...7986-silence-error-in-case-of-EPROBE.patch | 26 + .../862-arm64-dts-mt7986-add-afe.patch | 40 + ...63-arm64-dts-mt7986-add-sound-wm8960.patch | 61 ++ ...986-move-cpuboot-in-a-dedicated-node.patch | 6 +- ...-mt7986-move-ilm-in-a-dedicated-node.patch | 6 +- ...-mt7986-move-dlm-in-a-dedicated-node.patch | 6 +- 30 files changed, 4452 insertions(+), 18 deletions(-) create mode 100644 target/linux/mediatek/patches-5.15/860-v6.6-01-ASoC-mediatek-mt7986-add-common-header.patch create mode 100644 target/linux/mediatek/patches-5.15/860-v6.6-02-ASoC-mediatek-mt7986-support-etdm-in-platform-driver.patch create mode 100644 target/linux/mediatek/patches-5.15/860-v6.6-03-ASoC-mediatek-mt7986-add-platform-driver.patch create mode 100644 target/linux/mediatek/patches-5.15/860-v6.6-04-ASoC-mediatek-mt7986-add-machine-driver-with-wm8960.patch create mode 100644 target/linux/mediatek/patches-5.15/860-v6.6-05-ASoC-dt-bindings-mediatek-mt7986-wm8960-add-mt7986-w.patch create mode 100644 target/linux/mediatek/patches-5.15/860-v6.6-06-ASoC-dt-bindings-mediatek-mt7986-afe-add-audio-afe-d.patch create mode 100644 target/linux/mediatek/patches-5.15/860-v6.7-07-ASoC-mediatek-mt7986-drop-the-remove-callback-of-mt7.patch create mode 100644 target/linux/mediatek/patches-5.15/860-v6.7-08-ASoC-mediatek-mt7986-remove-the-mt7986_wm8960_priv-s.patch create mode 100644 target/linux/mediatek/patches-5.15/860-v6.7-09-ASoC-mediatek-mt7986-add-sample-rate-checker.patch create mode 100644 target/linux/mediatek/patches-5.15/861-pending-10-ASoC-mediatek-mt7986-silence-error-in-case-of-EPROBE.patch create mode 100644 target/linux/mediatek/patches-5.15/862-arm64-dts-mt7986-add-afe.patch create mode 100644 target/linux/mediatek/patches-5.15/863-arm64-dts-mt7986-add-sound-wm8960.patch create mode 100644 target/linux/mediatek/patches-6.1/860-v6.6-01-ASoC-mediatek-mt7986-add-common-header.patch create mode 100644 target/linux/mediatek/patches-6.1/860-v6.6-02-ASoC-mediatek-mt7986-support-etdm-in-platform-driver.patch create mode 100644 target/linux/mediatek/patches-6.1/860-v6.6-03-ASoC-mediatek-mt7986-add-platform-driver.patch create mode 100644 target/linux/mediatek/patches-6.1/860-v6.6-04-ASoC-mediatek-mt7986-add-machine-driver-with-wm8960.patch create mode 100644 target/linux/mediatek/patches-6.1/860-v6.6-05-ASoC-dt-bindings-mediatek-mt7986-wm8960-add-mt7986-w.patch create mode 100644 target/linux/mediatek/patches-6.1/860-v6.6-06-ASoC-dt-bindings-mediatek-mt7986-afe-add-audio-afe-d.patch create mode 100644 target/linux/mediatek/patches-6.1/860-v6.7-07-ASoC-mediatek-mt7986-drop-the-remove-callback-of-mt7.patch create mode 100644 target/linux/mediatek/patches-6.1/860-v6.7-08-ASoC-mediatek-mt7986-remove-the-mt7986_wm8960_priv-s.patch create mode 100644 target/linux/mediatek/patches-6.1/860-v6.7-09-ASoC-mediatek-mt7986-add-sample-rate-checker.patch create mode 100644 target/linux/mediatek/patches-6.1/861-pending-10-ASoC-mediatek-mt7986-silence-error-in-case-of-EPROBE.patch create mode 100644 target/linux/mediatek/patches-6.1/862-arm64-dts-mt7986-add-afe.patch create mode 100644 target/linux/mediatek/patches-6.1/863-arm64-dts-mt7986-add-sound-wm8960.patch diff --git a/target/linux/mediatek/patches-5.15/860-v6.6-01-ASoC-mediatek-mt7986-add-common-header.patch b/target/linux/mediatek/patches-5.15/860-v6.6-01-ASoC-mediatek-mt7986-add-common-header.patch new file mode 100644 index 0000000000..9607eec821 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/860-v6.6-01-ASoC-mediatek-mt7986-add-common-header.patch @@ -0,0 +1,269 @@ +From d35469096915f2551ed1d26da1ab12ff500fc963 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:33 +0800 +Subject: [PATCH 1/9] ASoC: mediatek: mt7986: add common header + +Add header files for register definition and structure. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-2-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-afe-common.h | 49 +++++ + sound/soc/mediatek/mt7986/mt7986-reg.h | 196 ++++++++++++++++++ + 2 files changed, 245 insertions(+) + create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-common.h + create mode 100644 sound/soc/mediatek/mt7986/mt7986-reg.h + +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-afe-common.h +@@ -0,0 +1,49 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * mt7986-afe-common.h -- MediaTek 7986 audio driver definitions ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#ifndef _MT_7986_AFE_COMMON_H_ ++#define _MT_7986_AFE_COMMON_H_ ++ ++#include ++#include ++#include ++#include ++#include "../common/mtk-base-afe.h" ++ ++enum { ++ MT7986_MEMIF_DL1, ++ MT7986_MEMIF_VUL12, ++ MT7986_MEMIF_NUM, ++ MT7986_DAI_ETDM = MT7986_MEMIF_NUM, ++ MT7986_DAI_NUM, ++}; ++ ++enum { ++ MT7986_IRQ_0, ++ MT7986_IRQ_1, ++ MT7986_IRQ_2, ++ MT7986_IRQ_NUM, ++}; ++ ++struct mt7986_afe_private { ++ struct clk_bulk_data *clks; ++ int num_clks; ++ ++ int pm_runtime_bypass_reg_ctl; ++ ++ /* dai */ ++ void *dai_priv[MT7986_DAI_NUM]; ++}; ++ ++unsigned int mt7986_afe_rate_transform(struct device *dev, ++ unsigned int rate); ++ ++/* dai register */ ++int mt7986_dai_etdm_register(struct mtk_base_afe *afe); ++#endif +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-reg.h +@@ -0,0 +1,196 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * mt7986-reg.h -- MediaTek 7986 audio driver reg definition ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#ifndef _MT7986_REG_H_ ++#define _MT7986_REG_H_ ++ ++#define AUDIO_TOP_CON2 0x0008 ++#define AUDIO_TOP_CON4 0x0010 ++#define AUDIO_ENGEN_CON0 0x0014 ++#define AFE_IRQ_MCU_EN 0x0100 ++#define AFE_IRQ_MCU_STATUS 0x0120 ++#define AFE_IRQ_MCU_CLR 0x0128 ++#define AFE_IRQ0_MCU_CFG0 0x0140 ++#define AFE_IRQ0_MCU_CFG1 0x0144 ++#define AFE_IRQ1_MCU_CFG0 0x0148 ++#define AFE_IRQ1_MCU_CFG1 0x014c ++#define AFE_IRQ2_MCU_CFG0 0x0150 ++#define AFE_IRQ2_MCU_CFG1 0x0154 ++#define ETDM_IN5_CON0 0x13f0 ++#define ETDM_IN5_CON1 0x13f4 ++#define ETDM_IN5_CON2 0x13f8 ++#define ETDM_IN5_CON3 0x13fc ++#define ETDM_IN5_CON4 0x1400 ++#define ETDM_OUT5_CON0 0x1570 ++#define ETDM_OUT5_CON4 0x1580 ++#define ETDM_OUT5_CON5 0x1584 ++#define ETDM_4_7_COWORK_CON0 0x15e0 ++#define ETDM_4_7_COWORK_CON1 0x15e4 ++#define AFE_CONN018_1 0x1b44 ++#define AFE_CONN018_4 0x1b50 ++#define AFE_CONN019_1 0x1b64 ++#define AFE_CONN019_4 0x1b70 ++#define AFE_CONN124_1 0x2884 ++#define AFE_CONN124_4 0x2890 ++#define AFE_CONN125_1 0x28a4 ++#define AFE_CONN125_4 0x28b0 ++#define AFE_CONN_RS_0 0x3920 ++#define AFE_CONN_RS_3 0x392c ++#define AFE_CONN_16BIT_0 0x3960 ++#define AFE_CONN_16BIT_3 0x396c ++#define AFE_CONN_24BIT_0 0x3980 ++#define AFE_CONN_24BIT_3 0x398c ++#define AFE_MEMIF_CON0 0x3d98 ++#define AFE_MEMIF_RD_MON 0x3da0 ++#define AFE_MEMIF_WR_MON 0x3da4 ++#define AFE_DL0_BASE_MSB 0x3e40 ++#define AFE_DL0_BASE 0x3e44 ++#define AFE_DL0_CUR_MSB 0x3e48 ++#define AFE_DL0_CUR 0x3e4c ++#define AFE_DL0_END_MSB 0x3e50 ++#define AFE_DL0_END 0x3e54 ++#define AFE_DL0_RCH_MON 0x3e58 ++#define AFE_DL0_LCH_MON 0x3e5c ++#define AFE_DL0_CON0 0x3e60 ++#define AFE_VUL0_BASE_MSB 0x4220 ++#define AFE_VUL0_BASE 0x4224 ++#define AFE_VUL0_CUR_MSB 0x4228 ++#define AFE_VUL0_CUR 0x422c ++#define AFE_VUL0_END_MSB 0x4230 ++#define AFE_VUL0_END 0x4234 ++#define AFE_VUL0_CON0 0x4238 ++ ++#define AFE_MAX_REGISTER AFE_VUL0_CON0 ++#define AFE_IRQ_STATUS_BITS 0x7 ++#define AFE_IRQ_CNT_SHIFT 0 ++#define AFE_IRQ_CNT_MASK 0xffffff ++ ++/* AUDIO_TOP_CON2 */ ++#define CLK_OUT5_PDN BIT(14) ++#define CLK_OUT5_PDN_MASK BIT(14) ++#define CLK_IN5_PDN BIT(7) ++#define CLK_IN5_PDN_MASK BIT(7) ++ ++/* AUDIO_TOP_CON4 */ ++#define PDN_APLL_TUNER2 BIT(12) ++#define PDN_APLL_TUNER2_MASK BIT(12) ++ ++/* AUDIO_ENGEN_CON0 */ ++#define AUD_APLL2_EN BIT(3) ++#define AUD_APLL2_EN_MASK BIT(3) ++#define AUD_26M_EN BIT(0) ++#define AUD_26M_EN_MASK BIT(0) ++ ++/* AFE_DL0_CON0 */ ++#define DL0_ON_SFT 28 ++#define DL0_ON_MASK 0x1 ++#define DL0_ON_MASK_SFT BIT(28) ++#define DL0_MINLEN_SFT 20 ++#define DL0_MINLEN_MASK 0xf ++#define DL0_MINLEN_MASK_SFT (0xf << 20) ++#define DL0_MODE_SFT 8 ++#define DL0_MODE_MASK 0x1f ++#define DL0_MODE_MASK_SFT (0x1f << 8) ++#define DL0_PBUF_SIZE_SFT 5 ++#define DL0_PBUF_SIZE_MASK 0x3 ++#define DL0_PBUF_SIZE_MASK_SFT (0x3 << 5) ++#define DL0_MONO_SFT 4 ++#define DL0_MONO_MASK 0x1 ++#define DL0_MONO_MASK_SFT BIT(4) ++#define DL0_HALIGN_SFT 2 ++#define DL0_HALIGN_MASK 0x1 ++#define DL0_HALIGN_MASK_SFT BIT(2) ++#define DL0_HD_MODE_SFT 0 ++#define DL0_HD_MODE_MASK 0x3 ++#define DL0_HD_MODE_MASK_SFT (0x3 << 0) ++ ++/* AFE_VUL0_CON0 */ ++#define VUL0_ON_SFT 28 ++#define VUL0_ON_MASK 0x1 ++#define VUL0_ON_MASK_SFT BIT(28) ++#define VUL0_MODE_SFT 8 ++#define VUL0_MODE_MASK 0x1f ++#define VUL0_MODE_MASK_SFT (0x1f << 8) ++#define VUL0_MONO_SFT 4 ++#define VUL0_MONO_MASK 0x1 ++#define VUL0_MONO_MASK_SFT BIT(4) ++#define VUL0_HALIGN_SFT 2 ++#define VUL0_HALIGN_MASK 0x1 ++#define VUL0_HALIGN_MASK_SFT BIT(2) ++#define VUL0_HD_MODE_SFT 0 ++#define VUL0_HD_MODE_MASK 0x3 ++#define VUL0_HD_MODE_MASK_SFT (0x3 << 0) ++ ++/* AFE_IRQ_MCU_CON */ ++#define IRQ_MCU_MODE_SFT 4 ++#define IRQ_MCU_MODE_MASK 0x1f ++#define IRQ_MCU_MODE_MASK_SFT (0x1f << 4) ++#define IRQ_MCU_ON_SFT 0 ++#define IRQ_MCU_ON_MASK 0x1 ++#define IRQ_MCU_ON_MASK_SFT BIT(0) ++#define IRQ0_MCU_CLR_SFT 0 ++#define IRQ0_MCU_CLR_MASK 0x1 ++#define IRQ0_MCU_CLR_MASK_SFT BIT(0) ++#define IRQ1_MCU_CLR_SFT 1 ++#define IRQ1_MCU_CLR_MASK 0x1 ++#define IRQ1_MCU_CLR_MASK_SFT BIT(1) ++#define IRQ2_MCU_CLR_SFT 2 ++#define IRQ2_MCU_CLR_MASK 0x1 ++#define IRQ2_MCU_CLR_MASK_SFT BIT(2) ++ ++/* ETDM_IN5_CON2 */ ++#define IN_CLK_SRC(x) ((x) << 10) ++#define IN_CLK_SRC_SFT 10 ++#define IN_CLK_SRC_MASK GENMASK(12, 10) ++ ++/* ETDM_IN5_CON3 */ ++#define IN_SEL_FS(x) ((x) << 26) ++#define IN_SEL_FS_SFT 26 ++#define IN_SEL_FS_MASK GENMASK(30, 26) ++ ++/* ETDM_IN5_CON4 */ ++#define IN_RELATCH(x) ((x) << 20) ++#define IN_RELATCH_SFT 20 ++#define IN_RELATCH_MASK GENMASK(24, 20) ++#define IN_CLK_INV BIT(18) ++#define IN_CLK_INV_MASK BIT(18) ++ ++/* ETDM_IN5_CON0 & ETDM_OUT5_CON0 */ ++#define RELATCH_SRC_MASK GENMASK(30, 28) ++#define ETDM_CH_NUM_MASK GENMASK(27, 23) ++#define ETDM_WRD_LEN_MASK GENMASK(20, 16) ++#define ETDM_BIT_LEN_MASK GENMASK(15, 11) ++#define ETDM_FMT_MASK GENMASK(8, 6) ++#define ETDM_SYNC BIT(1) ++#define ETDM_SYNC_MASK BIT(1) ++#define ETDM_EN BIT(0) ++#define ETDM_EN_MASK BIT(0) ++ ++/* ETDM_OUT5_CON4 */ ++#define OUT_RELATCH(x) ((x) << 24) ++#define OUT_RELATCH_SFT 24 ++#define OUT_RELATCH_MASK GENMASK(28, 24) ++#define OUT_CLK_SRC(x) ((x) << 6) ++#define OUT_CLK_SRC_SFT 6 ++#define OUT_CLK_SRC_MASK GENMASK(8, 6) ++#define OUT_SEL_FS(x) (x) ++#define OUT_SEL_FS_SFT 0 ++#define OUT_SEL_FS_MASK GENMASK(4, 0) ++ ++/* ETDM_OUT5_CON5 */ ++#define ETDM_CLK_DIV BIT(12) ++#define ETDM_CLK_DIV_MASK BIT(12) ++#define OUT_CLK_INV BIT(9) ++#define OUT_CLK_INV_MASK BIT(9) ++ ++/* ETDM_4_7_COWORK_CON0 */ ++#define OUT_SEL(x) ((x) << 12) ++#define OUT_SEL_SFT 12 ++#define OUT_SEL_MASK GENMASK(15, 12) ++#endif diff --git a/target/linux/mediatek/patches-5.15/860-v6.6-02-ASoC-mediatek-mt7986-support-etdm-in-platform-driver.patch b/target/linux/mediatek/patches-5.15/860-v6.6-02-ASoC-mediatek-mt7986-support-etdm-in-platform-driver.patch new file mode 100644 index 0000000000..f22add580f --- /dev/null +++ b/target/linux/mediatek/patches-5.15/860-v6.6-02-ASoC-mediatek-mt7986-support-etdm-in-platform-driver.patch @@ -0,0 +1,430 @@ +From 948a288897015fb3ee63b3f720b396b590c17fd7 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:34 +0800 +Subject: [PATCH 2/9] ASoC: mediatek: mt7986: support etdm in platform driver + +Add mt7986 etdm dai driver support. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-3-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 411 ++++++++++++++++++++ + 1 file changed, 411 insertions(+) + create mode 100644 sound/soc/mediatek/mt7986/mt7986-dai-etdm.c + +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c +@@ -0,0 +1,411 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * MediaTek ALSA SoC Audio DAI eTDM Control ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#include ++#include ++#include ++#include ++#include "mt7986-afe-common.h" ++#include "mt7986-reg.h" ++ ++#define HOPPING_CLK 0 ++#define APLL_CLK 1 ++#define MTK_DAI_ETDM_FORMAT_I2S 0 ++#define MTK_DAI_ETDM_FORMAT_DSPA 4 ++#define MTK_DAI_ETDM_FORMAT_DSPB 5 ++ ++enum { ++ MTK_ETDM_RATE_8K = 0, ++ MTK_ETDM_RATE_12K = 1, ++ MTK_ETDM_RATE_16K = 2, ++ MTK_ETDM_RATE_24K = 3, ++ MTK_ETDM_RATE_32K = 4, ++ MTK_ETDM_RATE_48K = 5, ++ MTK_ETDM_RATE_96K = 7, ++ MTK_ETDM_RATE_192K = 9, ++ MTK_ETDM_RATE_11K = 16, ++ MTK_ETDM_RATE_22K = 17, ++ MTK_ETDM_RATE_44K = 18, ++ MTK_ETDM_RATE_88K = 19, ++ MTK_ETDM_RATE_176K = 20, ++}; ++ ++struct mtk_dai_etdm_priv { ++ bool bck_inv; ++ bool lrck_inv; ++ bool slave_mode; ++ unsigned int format; ++}; ++ ++static unsigned int mt7986_etdm_rate_transform(struct device *dev, unsigned int rate) ++{ ++ switch (rate) { ++ case 8000: ++ return MTK_ETDM_RATE_8K; ++ case 11025: ++ return MTK_ETDM_RATE_11K; ++ case 12000: ++ return MTK_ETDM_RATE_12K; ++ case 16000: ++ return MTK_ETDM_RATE_16K; ++ case 22050: ++ return MTK_ETDM_RATE_22K; ++ case 24000: ++ return MTK_ETDM_RATE_24K; ++ case 32000: ++ return MTK_ETDM_RATE_32K; ++ case 44100: ++ return MTK_ETDM_RATE_44K; ++ case 48000: ++ return MTK_ETDM_RATE_48K; ++ case 88200: ++ return MTK_ETDM_RATE_88K; ++ case 96000: ++ return MTK_ETDM_RATE_96K; ++ case 176400: ++ return MTK_ETDM_RATE_176K; ++ case 192000: ++ return MTK_ETDM_RATE_192K; ++ default: ++ dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n", ++ __func__, rate, MTK_ETDM_RATE_48K); ++ return MTK_ETDM_RATE_48K; ++ } ++} ++ ++static int get_etdm_wlen(unsigned int bitwidth) ++{ ++ return bitwidth <= 16 ? 16 : 32; ++} ++ ++/* dai component */ ++/* interconnection */ ++ ++static const struct snd_kcontrol_new o124_mix[] = { ++ SOC_DAPM_SINGLE_AUTODISABLE("I032_Switch", AFE_CONN124_1, 0, 1, 0), ++}; ++ ++static const struct snd_kcontrol_new o125_mix[] = { ++ SOC_DAPM_SINGLE_AUTODISABLE("I033_Switch", AFE_CONN125_1, 1, 1, 0), ++}; ++ ++static const struct snd_soc_dapm_widget mtk_dai_etdm_widgets[] = { ++ ++ /* DL */ ++ SND_SOC_DAPM_MIXER("I150", SND_SOC_NOPM, 0, 0, NULL, 0), ++ SND_SOC_DAPM_MIXER("I151", SND_SOC_NOPM, 0, 0, NULL, 0), ++ /* UL */ ++ SND_SOC_DAPM_MIXER("O124", SND_SOC_NOPM, 0, 0, o124_mix, ARRAY_SIZE(o124_mix)), ++ SND_SOC_DAPM_MIXER("O125", SND_SOC_NOPM, 0, 0, o125_mix, ARRAY_SIZE(o125_mix)), ++}; ++ ++static const struct snd_soc_dapm_route mtk_dai_etdm_routes[] = { ++ {"I150", NULL, "ETDM Capture"}, ++ {"I151", NULL, "ETDM Capture"}, ++ {"ETDM Playback", NULL, "O124"}, ++ {"ETDM Playback", NULL, "O125"}, ++ {"O124", "I032_Switch", "I032"}, ++ {"O125", "I033_Switch", "I033"}, ++}; ++ ++/* dai ops */ ++static int mtk_dai_etdm_startup(struct snd_pcm_substream *substream, ++ struct snd_soc_dai *dai) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ int ret; ++ ++ ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks); ++ if (ret) ++ return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n"); ++ ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK, 0); ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK, 0); ++ ++ return 0; ++} ++ ++static void mtk_dai_etdm_shutdown(struct snd_pcm_substream *substream, ++ struct snd_soc_dai *dai) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK, ++ CLK_OUT5_PDN); ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK, ++ CLK_IN5_PDN); ++ ++ clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks); ++} ++ ++static unsigned int get_etdm_ch_fixup(unsigned int channels) ++{ ++ if (channels > 16) ++ return 24; ++ else if (channels > 8) ++ return 16; ++ else if (channels > 4) ++ return 8; ++ else if (channels > 2) ++ return 4; ++ else ++ return 2; ++} ++ ++static int mtk_dai_etdm_config(struct mtk_base_afe *afe, ++ struct snd_pcm_hw_params *params, ++ struct snd_soc_dai *dai, ++ int stream) ++{ ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; ++ unsigned int rate = params_rate(params); ++ unsigned int etdm_rate = mt7986_etdm_rate_transform(afe->dev, rate); ++ unsigned int afe_rate = mt7986_afe_rate_transform(afe->dev, rate); ++ unsigned int channels = params_channels(params); ++ unsigned int bit_width = params_width(params); ++ unsigned int wlen = get_etdm_wlen(bit_width); ++ unsigned int val = 0; ++ unsigned int mask = 0; ++ ++ dev_dbg(afe->dev, "%s(), stream %d, rate %u, bitwidth %u\n", ++ __func__, stream, rate, bit_width); ++ ++ /* CON0 */ ++ mask |= ETDM_BIT_LEN_MASK; ++ val |= FIELD_PREP(ETDM_BIT_LEN_MASK, bit_width - 1); ++ mask |= ETDM_WRD_LEN_MASK; ++ val |= FIELD_PREP(ETDM_WRD_LEN_MASK, wlen - 1); ++ mask |= ETDM_FMT_MASK; ++ val |= FIELD_PREP(ETDM_FMT_MASK, etdm_data->format); ++ mask |= ETDM_CH_NUM_MASK; ++ val |= FIELD_PREP(ETDM_CH_NUM_MASK, get_etdm_ch_fixup(channels) - 1); ++ mask |= RELATCH_SRC_MASK; ++ val |= FIELD_PREP(RELATCH_SRC_MASK, APLL_CLK); ++ ++ switch (stream) { ++ case SNDRV_PCM_STREAM_PLAYBACK: ++ /* set ETDM_OUT5_CON0 */ ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, mask, val); ++ ++ /* set ETDM_OUT5_CON4 */ ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON4, ++ OUT_RELATCH_MASK, OUT_RELATCH(afe_rate)); ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON4, ++ OUT_CLK_SRC_MASK, OUT_CLK_SRC(APLL_CLK)); ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON4, ++ OUT_SEL_FS_MASK, OUT_SEL_FS(etdm_rate)); ++ ++ /* set ETDM_OUT5_CON5 */ ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON5, ++ ETDM_CLK_DIV_MASK, ETDM_CLK_DIV); ++ break; ++ case SNDRV_PCM_STREAM_CAPTURE: ++ /* set ETDM_IN5_CON0 */ ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, mask, val); ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ++ ETDM_SYNC_MASK, ETDM_SYNC); ++ ++ /* set ETDM_IN5_CON2 */ ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON2, ++ IN_CLK_SRC_MASK, IN_CLK_SRC(APLL_CLK)); ++ ++ /* set ETDM_IN5_CON3 */ ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON3, ++ IN_SEL_FS_MASK, IN_SEL_FS(etdm_rate)); ++ ++ /* set ETDM_IN5_CON4 */ ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON4, ++ IN_RELATCH_MASK, IN_RELATCH(afe_rate)); ++ break; ++ default: ++ break; ++ } ++ ++ return 0; ++} ++ ++static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream, ++ struct snd_pcm_hw_params *params, ++ struct snd_soc_dai *dai) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ ++ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); ++ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); ++ ++ return 0; ++} ++ ++static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd, ++ struct snd_soc_dai *dai) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ ++ dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id); ++ switch (cmd) { ++ case SNDRV_PCM_TRIGGER_START: ++ case SNDRV_PCM_TRIGGER_RESUME: ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK, ++ ETDM_EN); ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK, ++ ETDM_EN); ++ break; ++ case SNDRV_PCM_TRIGGER_STOP: ++ case SNDRV_PCM_TRIGGER_SUSPEND: ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK, ++ 0); ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK, ++ 0); ++ break; ++ default: ++ break; ++ } ++ ++ return 0; ++} ++ ++static int mtk_dai_etdm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ struct mtk_dai_etdm_priv *etdm_data; ++ void *priv_data; ++ ++ switch (dai->id) { ++ case MT7986_DAI_ETDM: ++ break; ++ default: ++ dev_warn(afe->dev, "%s(), id %d not support\n", ++ __func__, dai->id); ++ return -EINVAL; ++ } ++ ++ priv_data = devm_kzalloc(afe->dev, sizeof(struct mtk_dai_etdm_priv), ++ GFP_KERNEL); ++ if (!priv_data) ++ return -ENOMEM; ++ ++ afe_priv->dai_priv[dai->id] = priv_data; ++ etdm_data = afe_priv->dai_priv[dai->id]; ++ ++ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { ++ case SND_SOC_DAIFMT_I2S: ++ etdm_data->format = MTK_DAI_ETDM_FORMAT_I2S; ++ break; ++ case SND_SOC_DAIFMT_DSP_A: ++ etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPA; ++ break; ++ case SND_SOC_DAIFMT_DSP_B: ++ etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPB; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ switch (fmt & SND_SOC_DAIFMT_INV_MASK) { ++ case SND_SOC_DAIFMT_NB_NF: ++ etdm_data->bck_inv = false; ++ etdm_data->lrck_inv = false; ++ break; ++ case SND_SOC_DAIFMT_NB_IF: ++ etdm_data->bck_inv = false; ++ etdm_data->lrck_inv = true; ++ break; ++ case SND_SOC_DAIFMT_IB_NF: ++ etdm_data->bck_inv = true; ++ etdm_data->lrck_inv = false; ++ break; ++ case SND_SOC_DAIFMT_IB_IF: ++ etdm_data->bck_inv = true; ++ etdm_data->lrck_inv = true; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { ++ case SND_SOC_DAIFMT_CBM_CFM: ++ etdm_data->slave_mode = true; ++ break; ++ case SND_SOC_DAIFMT_CBS_CFS: ++ etdm_data->slave_mode = false; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static const struct snd_soc_dai_ops mtk_dai_etdm_ops = { ++ .startup = mtk_dai_etdm_startup, ++ .shutdown = mtk_dai_etdm_shutdown, ++ .hw_params = mtk_dai_etdm_hw_params, ++ .trigger = mtk_dai_etdm_trigger, ++ .set_fmt = mtk_dai_etdm_set_fmt, ++}; ++ ++/* dai driver */ ++#define MTK_ETDM_RATES (SNDRV_PCM_RATE_8000_48000 |\ ++ SNDRV_PCM_RATE_88200 |\ ++ SNDRV_PCM_RATE_96000 |\ ++ SNDRV_PCM_RATE_176400 |\ ++ SNDRV_PCM_RATE_192000) ++ ++#define MTK_ETDM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ ++ SNDRV_PCM_FMTBIT_S24_LE |\ ++ SNDRV_PCM_FMTBIT_S32_LE) ++ ++static struct snd_soc_dai_driver mtk_dai_etdm_driver[] = { ++ { ++ .name = "ETDM", ++ .id = MT7986_DAI_ETDM, ++ .capture = { ++ .stream_name = "ETDM Capture", ++ .channels_min = 1, ++ .channels_max = 2, ++ .rates = MTK_ETDM_RATES, ++ .formats = MTK_ETDM_FORMATS, ++ }, ++ .playback = { ++ .stream_name = "ETDM Playback", ++ .channels_min = 1, ++ .channels_max = 2, ++ .rates = MTK_ETDM_RATES, ++ .formats = MTK_ETDM_FORMATS, ++ }, ++ .ops = &mtk_dai_etdm_ops, ++ .symmetric_rate = 1, ++ .symmetric_sample_bits = 1, ++ }, ++}; ++ ++int mt7986_dai_etdm_register(struct mtk_base_afe *afe) ++{ ++ struct mtk_base_afe_dai *dai; ++ ++ dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); ++ if (!dai) ++ return -ENOMEM; ++ ++ list_add(&dai->list, &afe->sub_dais); ++ ++ dai->dai_drivers = mtk_dai_etdm_driver; ++ dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_etdm_driver); ++ ++ dai->dapm_widgets = mtk_dai_etdm_widgets; ++ dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_etdm_widgets); ++ dai->dapm_routes = mtk_dai_etdm_routes; ++ dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_etdm_routes); ++ ++ return 0; ++} diff --git a/target/linux/mediatek/patches-5.15/860-v6.6-03-ASoC-mediatek-mt7986-add-platform-driver.patch b/target/linux/mediatek/patches-5.15/860-v6.6-03-ASoC-mediatek-mt7986-add-platform-driver.patch new file mode 100644 index 0000000000..8139fdc668 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/860-v6.6-03-ASoC-mediatek-mt7986-add-platform-driver.patch @@ -0,0 +1,685 @@ +From fc7776dee86bc07d22820a904760a95f49a2f12e Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:35 +0800 +Subject: [PATCH 3/9] ASoC: mediatek: mt7986: add platform driver + +Add mt7986 platform driver. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-4-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/Kconfig | 10 + + sound/soc/mediatek/Makefile | 1 + + sound/soc/mediatek/mt7986/Makefile | 8 + + sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 622 +++++++++++++++++++++ + 4 files changed, 641 insertions(+) + create mode 100644 sound/soc/mediatek/mt7986/Makefile + create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-pcm.c + +--- a/sound/soc/mediatek/Kconfig ++++ b/sound/soc/mediatek/Kconfig +@@ -54,6 +54,16 @@ config SND_SOC_MT6797_MT6351 + Select Y if you have such device. + If unsure select "N". + ++config SND_SOC_MT7986 ++ tristate "ASoC support for Mediatek MT7986 chip" ++ depends on ARCH_MEDIATEK ++ select SND_SOC_MEDIATEK ++ help ++ This adds ASoC platform driver support for MediaTek MT7986 chip ++ that can be used with other codecs. ++ Select Y if you have such device. ++ If unsure select "N". ++ + config SND_SOC_MT8173 + tristate "ASoC support for Mediatek MT8173 chip" + depends on ARCH_MEDIATEK +--- a/sound/soc/mediatek/Makefile ++++ b/sound/soc/mediatek/Makefile +@@ -2,6 +2,7 @@ + obj-$(CONFIG_SND_SOC_MEDIATEK) += common/ + obj-$(CONFIG_SND_SOC_MT2701) += mt2701/ + obj-$(CONFIG_SND_SOC_MT6797) += mt6797/ ++obj-$(CONFIG_SND_SOC_MT7986) += mt7986/ + obj-$(CONFIG_SND_SOC_MT8173) += mt8173/ + obj-$(CONFIG_SND_SOC_MT8183) += mt8183/ + obj-$(CONFIG_SND_SOC_MT8192) += mt8192/ +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/Makefile +@@ -0,0 +1,8 @@ ++# SPDX-License-Identifier: GPL-2.0 ++ ++# platform driver ++snd-soc-mt7986-afe-objs := \ ++ mt7986-afe-pcm.o \ ++ mt7986-dai-etdm.o ++ ++obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-afe-pcm.c +@@ -0,0 +1,622 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * MediaTek ALSA SoC AFE platform driver for MT7986 ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "mt7986-afe-common.h" ++#include "mt7986-reg.h" ++#include "../common/mtk-afe-platform-driver.h" ++#include "../common/mtk-afe-fe-dai.h" ++ ++enum { ++ MTK_AFE_RATE_8K = 0, ++ MTK_AFE_RATE_11K = 1, ++ MTK_AFE_RATE_12K = 2, ++ MTK_AFE_RATE_16K = 4, ++ MTK_AFE_RATE_22K = 5, ++ MTK_AFE_RATE_24K = 6, ++ MTK_AFE_RATE_32K = 8, ++ MTK_AFE_RATE_44K = 9, ++ MTK_AFE_RATE_48K = 10, ++ MTK_AFE_RATE_88K = 13, ++ MTK_AFE_RATE_96K = 14, ++ MTK_AFE_RATE_176K = 17, ++ MTK_AFE_RATE_192K = 18, ++}; ++ ++enum { ++ CLK_INFRA_AUD_BUS_CK = 0, ++ CLK_INFRA_AUD_26M_CK, ++ CLK_INFRA_AUD_L_CK, ++ CLK_INFRA_AUD_AUD_CK, ++ CLK_INFRA_AUD_EG2_CK, ++ CLK_NUM ++}; ++ ++static const char *aud_clks[CLK_NUM] = { ++ [CLK_INFRA_AUD_BUS_CK] = "aud_bus_ck", ++ [CLK_INFRA_AUD_26M_CK] = "aud_26m_ck", ++ [CLK_INFRA_AUD_L_CK] = "aud_l_ck", ++ [CLK_INFRA_AUD_AUD_CK] = "aud_aud_ck", ++ [CLK_INFRA_AUD_EG2_CK] = "aud_eg2_ck", ++}; ++ ++unsigned int mt7986_afe_rate_transform(struct device *dev, unsigned int rate) ++{ ++ switch (rate) { ++ case 8000: ++ return MTK_AFE_RATE_8K; ++ case 11025: ++ return MTK_AFE_RATE_11K; ++ case 12000: ++ return MTK_AFE_RATE_12K; ++ case 16000: ++ return MTK_AFE_RATE_16K; ++ case 22050: ++ return MTK_AFE_RATE_22K; ++ case 24000: ++ return MTK_AFE_RATE_24K; ++ case 32000: ++ return MTK_AFE_RATE_32K; ++ case 44100: ++ return MTK_AFE_RATE_44K; ++ case 48000: ++ return MTK_AFE_RATE_48K; ++ case 88200: ++ return MTK_AFE_RATE_88K; ++ case 96000: ++ return MTK_AFE_RATE_96K; ++ case 176400: ++ return MTK_AFE_RATE_176K; ++ case 192000: ++ return MTK_AFE_RATE_192K; ++ default: ++ dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n", ++ __func__, rate, MTK_AFE_RATE_48K); ++ return MTK_AFE_RATE_48K; ++ } ++} ++ ++static const struct snd_pcm_hardware mt7986_afe_hardware = { ++ .info = SNDRV_PCM_INFO_MMAP | ++ SNDRV_PCM_INFO_INTERLEAVED | ++ SNDRV_PCM_INFO_MMAP_VALID, ++ .formats = SNDRV_PCM_FMTBIT_S16_LE | ++ SNDRV_PCM_FMTBIT_S24_LE | ++ SNDRV_PCM_FMTBIT_S32_LE, ++ .period_bytes_min = 256, ++ .period_bytes_max = 4 * 48 * 1024, ++ .periods_min = 2, ++ .periods_max = 256, ++ .buffer_bytes_max = 8 * 48 * 1024, ++ .fifo_size = 0, ++}; ++ ++static int mt7986_memif_fs(struct snd_pcm_substream *substream, ++ unsigned int rate) ++{ ++ struct snd_soc_pcm_runtime *rtd = substream->private_data; ++ struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); ++ struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); ++ ++ return mt7986_afe_rate_transform(afe->dev, rate); ++} ++ ++static int mt7986_irq_fs(struct snd_pcm_substream *substream, ++ unsigned int rate) ++{ ++ struct snd_soc_pcm_runtime *rtd = substream->private_data; ++ struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); ++ struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); ++ ++ return mt7986_afe_rate_transform(afe->dev, rate); ++} ++ ++#define MTK_PCM_RATES (SNDRV_PCM_RATE_8000_48000 |\ ++ SNDRV_PCM_RATE_88200 |\ ++ SNDRV_PCM_RATE_96000 |\ ++ SNDRV_PCM_RATE_176400 |\ ++ SNDRV_PCM_RATE_192000) ++ ++#define MTK_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ ++ SNDRV_PCM_FMTBIT_S24_LE |\ ++ SNDRV_PCM_FMTBIT_S32_LE) ++ ++static struct snd_soc_dai_driver mt7986_memif_dai_driver[] = { ++ /* FE DAIs: memory intefaces to CPU */ ++ { ++ .name = "DL1", ++ .id = MT7986_MEMIF_DL1, ++ .playback = { ++ .stream_name = "DL1", ++ .channels_min = 1, ++ .channels_max = 2, ++ .rates = MTK_PCM_RATES, ++ .formats = MTK_PCM_FORMATS, ++ }, ++ .ops = &mtk_afe_fe_ops, ++ }, ++ { ++ .name = "UL1", ++ .id = MT7986_MEMIF_VUL12, ++ .capture = { ++ .stream_name = "UL1", ++ .channels_min = 1, ++ .channels_max = 2, ++ .rates = MTK_PCM_RATES, ++ .formats = MTK_PCM_FORMATS, ++ }, ++ .ops = &mtk_afe_fe_ops, ++ }, ++}; ++ ++static const struct snd_kcontrol_new o018_mix[] = { ++ SOC_DAPM_SINGLE_AUTODISABLE("I150_Switch", AFE_CONN018_4, 22, 1, 0), ++}; ++ ++static const struct snd_kcontrol_new o019_mix[] = { ++ SOC_DAPM_SINGLE_AUTODISABLE("I151_Switch", AFE_CONN019_4, 23, 1, 0), ++}; ++ ++static const struct snd_soc_dapm_widget mt7986_memif_widgets[] = { ++ /* DL */ ++ SND_SOC_DAPM_MIXER("I032", SND_SOC_NOPM, 0, 0, NULL, 0), ++ SND_SOC_DAPM_MIXER("I033", SND_SOC_NOPM, 0, 0, NULL, 0), ++ ++ /* UL */ ++ SND_SOC_DAPM_MIXER("O018", SND_SOC_NOPM, 0, 0, ++ o018_mix, ARRAY_SIZE(o018_mix)), ++ SND_SOC_DAPM_MIXER("O019", SND_SOC_NOPM, 0, 0, ++ o019_mix, ARRAY_SIZE(o019_mix)), ++}; ++ ++static const struct snd_soc_dapm_route mt7986_memif_routes[] = { ++ {"I032", NULL, "DL1"}, ++ {"I033", NULL, "DL1"}, ++ {"UL1", NULL, "O018"}, ++ {"UL1", NULL, "O019"}, ++ {"O018", "I150_Switch", "I150"}, ++ {"O019", "I151_Switch", "I151"}, ++}; ++ ++static const struct snd_soc_component_driver mt7986_afe_pcm_dai_component = { ++ .name = "mt7986-afe-pcm-dai", ++}; ++ ++static const struct mtk_base_memif_data memif_data[MT7986_MEMIF_NUM] = { ++ [MT7986_MEMIF_DL1] = { ++ .name = "DL1", ++ .id = MT7986_MEMIF_DL1, ++ .reg_ofs_base = AFE_DL0_BASE, ++ .reg_ofs_cur = AFE_DL0_CUR, ++ .reg_ofs_end = AFE_DL0_END, ++ .reg_ofs_base_msb = AFE_DL0_BASE_MSB, ++ .reg_ofs_cur_msb = AFE_DL0_CUR_MSB, ++ .reg_ofs_end_msb = AFE_DL0_END_MSB, ++ .fs_reg = AFE_DL0_CON0, ++ .fs_shift = DL0_MODE_SFT, ++ .fs_maskbit = DL0_MODE_MASK, ++ .mono_reg = AFE_DL0_CON0, ++ .mono_shift = DL0_MONO_SFT, ++ .enable_reg = AFE_DL0_CON0, ++ .enable_shift = DL0_ON_SFT, ++ .hd_reg = AFE_DL0_CON0, ++ .hd_shift = DL0_HD_MODE_SFT, ++ .hd_align_reg = AFE_DL0_CON0, ++ .hd_align_mshift = DL0_HALIGN_SFT, ++ .pbuf_reg = AFE_DL0_CON0, ++ .pbuf_shift = DL0_PBUF_SIZE_SFT, ++ .minlen_reg = AFE_DL0_CON0, ++ .minlen_shift = DL0_MINLEN_SFT, ++ }, ++ [MT7986_MEMIF_VUL12] = { ++ .name = "VUL12", ++ .id = MT7986_MEMIF_VUL12, ++ .reg_ofs_base = AFE_VUL0_BASE, ++ .reg_ofs_cur = AFE_VUL0_CUR, ++ .reg_ofs_end = AFE_VUL0_END, ++ .reg_ofs_base_msb = AFE_VUL0_BASE_MSB, ++ .reg_ofs_cur_msb = AFE_VUL0_CUR_MSB, ++ .reg_ofs_end_msb = AFE_VUL0_END_MSB, ++ .fs_reg = AFE_VUL0_CON0, ++ .fs_shift = VUL0_MODE_SFT, ++ .fs_maskbit = VUL0_MODE_MASK, ++ .mono_reg = AFE_VUL0_CON0, ++ .mono_shift = VUL0_MONO_SFT, ++ .enable_reg = AFE_VUL0_CON0, ++ .enable_shift = VUL0_ON_SFT, ++ .hd_reg = AFE_VUL0_CON0, ++ .hd_shift = VUL0_HD_MODE_SFT, ++ .hd_align_reg = AFE_VUL0_CON0, ++ .hd_align_mshift = VUL0_HALIGN_SFT, ++ }, ++}; ++ ++static const struct mtk_base_irq_data irq_data[MT7986_IRQ_NUM] = { ++ [MT7986_IRQ_0] = { ++ .id = MT7986_IRQ_0, ++ .irq_cnt_reg = AFE_IRQ0_MCU_CFG1, ++ .irq_cnt_shift = AFE_IRQ_CNT_SHIFT, ++ .irq_cnt_maskbit = AFE_IRQ_CNT_MASK, ++ .irq_fs_reg = AFE_IRQ0_MCU_CFG0, ++ .irq_fs_shift = IRQ_MCU_MODE_SFT, ++ .irq_fs_maskbit = IRQ_MCU_MODE_MASK, ++ .irq_en_reg = AFE_IRQ0_MCU_CFG0, ++ .irq_en_shift = IRQ_MCU_ON_SFT, ++ .irq_clr_reg = AFE_IRQ_MCU_CLR, ++ .irq_clr_shift = IRQ0_MCU_CLR_SFT, ++ }, ++ [MT7986_IRQ_1] = { ++ .id = MT7986_IRQ_1, ++ .irq_cnt_reg = AFE_IRQ1_MCU_CFG1, ++ .irq_cnt_shift = AFE_IRQ_CNT_SHIFT, ++ .irq_cnt_maskbit = AFE_IRQ_CNT_MASK, ++ .irq_fs_reg = AFE_IRQ1_MCU_CFG0, ++ .irq_fs_shift = IRQ_MCU_MODE_SFT, ++ .irq_fs_maskbit = IRQ_MCU_MODE_MASK, ++ .irq_en_reg = AFE_IRQ1_MCU_CFG0, ++ .irq_en_shift = IRQ_MCU_ON_SFT, ++ .irq_clr_reg = AFE_IRQ_MCU_CLR, ++ .irq_clr_shift = IRQ1_MCU_CLR_SFT, ++ }, ++ [MT7986_IRQ_2] = { ++ .id = MT7986_IRQ_2, ++ .irq_cnt_reg = AFE_IRQ2_MCU_CFG1, ++ .irq_cnt_shift = AFE_IRQ_CNT_SHIFT, ++ .irq_cnt_maskbit = AFE_IRQ_CNT_MASK, ++ .irq_fs_reg = AFE_IRQ2_MCU_CFG0, ++ .irq_fs_shift = IRQ_MCU_MODE_SFT, ++ .irq_fs_maskbit = IRQ_MCU_MODE_MASK, ++ .irq_en_reg = AFE_IRQ2_MCU_CFG0, ++ .irq_en_shift = IRQ_MCU_ON_SFT, ++ .irq_clr_reg = AFE_IRQ_MCU_CLR, ++ .irq_clr_shift = IRQ2_MCU_CLR_SFT, ++ }, ++}; ++ ++static bool mt7986_is_volatile_reg(struct device *dev, unsigned int reg) ++{ ++ /* ++ * Those auto-gen regs are read-only, so put it as volatile because ++ * volatile registers cannot be cached, which means that they cannot ++ * be set when power is off ++ */ ++ ++ switch (reg) { ++ case AFE_DL0_CUR_MSB: ++ case AFE_DL0_CUR: ++ case AFE_DL0_RCH_MON: ++ case AFE_DL0_LCH_MON: ++ case AFE_VUL0_CUR_MSB: ++ case AFE_VUL0_CUR: ++ case AFE_IRQ_MCU_STATUS: ++ case AFE_MEMIF_RD_MON: ++ case AFE_MEMIF_WR_MON: ++ return true; ++ default: ++ return false; ++ }; ++} ++ ++static const struct regmap_config mt7986_afe_regmap_config = { ++ .reg_bits = 32, ++ .reg_stride = 4, ++ .val_bits = 32, ++ .volatile_reg = mt7986_is_volatile_reg, ++ .max_register = AFE_MAX_REGISTER, ++ .num_reg_defaults_raw = ((AFE_MAX_REGISTER / 4) + 1), ++}; ++ ++static int mt7986_init_clock(struct mtk_base_afe *afe) ++{ ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ int ret, i; ++ ++ afe_priv->clks = devm_kcalloc(afe->dev, CLK_NUM, ++ sizeof(*afe_priv->clks), GFP_KERNEL); ++ if (!afe_priv->clks) ++ return -ENOMEM; ++ afe_priv->num_clks = CLK_NUM; ++ ++ for (i = 0; i < afe_priv->num_clks; i++) ++ afe_priv->clks[i].id = aud_clks[i]; ++ ++ ret = devm_clk_bulk_get(afe->dev, afe_priv->num_clks, afe_priv->clks); ++ if (ret) ++ return dev_err_probe(afe->dev, ret, "Failed to get clocks\n"); ++ ++ return 0; ++} ++ ++static irqreturn_t mt7986_afe_irq_handler(int irq_id, void *dev) ++{ ++ struct mtk_base_afe *afe = dev; ++ struct mtk_base_afe_irq *irq; ++ u32 mcu_en, status, status_mcu; ++ int i, ret; ++ irqreturn_t irq_ret = IRQ_HANDLED; ++ ++ /* get irq that is sent to MCU */ ++ regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en); ++ ++ ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status); ++ /* only care IRQ which is sent to MCU */ ++ status_mcu = status & mcu_en & AFE_IRQ_STATUS_BITS; ++ ++ if (ret || status_mcu == 0) { ++ dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n", ++ __func__, ret, status, mcu_en); ++ ++ irq_ret = IRQ_NONE; ++ goto err_irq; ++ } ++ ++ for (i = 0; i < MT7986_MEMIF_NUM; i++) { ++ struct mtk_base_afe_memif *memif = &afe->memif[i]; ++ ++ if (!memif->substream) ++ continue; ++ ++ if (memif->irq_usage < 0) ++ continue; ++ ++ irq = &afe->irqs[memif->irq_usage]; ++ ++ if (status_mcu & (1 << irq->irq_data->irq_en_shift)) ++ snd_pcm_period_elapsed(memif->substream); ++ } ++ ++err_irq: ++ /* clear irq */ ++ regmap_write(afe->regmap, AFE_IRQ_MCU_CLR, status_mcu); ++ ++ return irq_ret; ++} ++ ++static int mt7986_afe_runtime_suspend(struct device *dev) ++{ ++ struct mtk_base_afe *afe = dev_get_drvdata(dev); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ ++ if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) ++ goto skip_regmap; ++ ++ /* disable clk*/ ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON4, 0x3fff, 0x3fff); ++ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_APLL2_EN_MASK, 0); ++ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_26M_EN_MASK, 0); ++ ++ /* make sure all irq status are cleared, twice intended */ ++ regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff); ++ ++skip_regmap: ++ clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks); ++ ++ return 0; ++} ++ ++static int mt7986_afe_runtime_resume(struct device *dev) ++{ ++ struct mtk_base_afe *afe = dev_get_drvdata(dev); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ int ret; ++ ++ ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks); ++ if (ret) ++ return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n"); ++ ++ if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) ++ return 0; ++ ++ /* enable clk*/ ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON4, 0x3fff, 0); ++ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_APLL2_EN_MASK, ++ AUD_APLL2_EN); ++ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_26M_EN_MASK, ++ AUD_26M_EN); ++ ++ return 0; ++} ++ ++static int mt7986_afe_component_probe(struct snd_soc_component *component) ++{ ++ return mtk_afe_add_sub_dai_control(component); ++} ++ ++static const struct snd_soc_component_driver mt7986_afe_component = { ++ .name = AFE_PCM_NAME, ++ .probe = mt7986_afe_component_probe, ++ .pointer = mtk_afe_pcm_pointer, ++ .pcm_construct = mtk_afe_pcm_new, ++}; ++ ++static int mt7986_dai_memif_register(struct mtk_base_afe *afe) ++{ ++ struct mtk_base_afe_dai *dai; ++ ++ dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); ++ if (!dai) ++ return -ENOMEM; ++ ++ list_add(&dai->list, &afe->sub_dais); ++ ++ dai->dai_drivers = mt7986_memif_dai_driver; ++ dai->num_dai_drivers = ARRAY_SIZE(mt7986_memif_dai_driver); ++ ++ dai->dapm_widgets = mt7986_memif_widgets; ++ dai->num_dapm_widgets = ARRAY_SIZE(mt7986_memif_widgets); ++ dai->dapm_routes = mt7986_memif_routes; ++ dai->num_dapm_routes = ARRAY_SIZE(mt7986_memif_routes); ++ ++ return 0; ++} ++ ++typedef int (*dai_register_cb)(struct mtk_base_afe *); ++static const dai_register_cb dai_register_cbs[] = { ++ mt7986_dai_etdm_register, ++ mt7986_dai_memif_register, ++}; ++ ++static int mt7986_afe_pcm_dev_probe(struct platform_device *pdev) ++{ ++ struct mtk_base_afe *afe; ++ struct mt7986_afe_private *afe_priv; ++ struct device *dev; ++ int i, irq_id, ret; ++ ++ afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); ++ if (!afe) ++ return -ENOMEM; ++ platform_set_drvdata(pdev, afe); ++ ++ afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), ++ GFP_KERNEL); ++ if (!afe->platform_priv) ++ return -ENOMEM; ++ ++ afe_priv = afe->platform_priv; ++ afe->dev = &pdev->dev; ++ dev = afe->dev; ++ ++ afe->base_addr = devm_platform_ioremap_resource(pdev, 0); ++ if (IS_ERR(afe->base_addr)) ++ return PTR_ERR(afe->base_addr); ++ ++ /* initial audio related clock */ ++ ret = mt7986_init_clock(afe); ++ if (ret) ++ return dev_err_probe(dev, ret, "Cannot initialize clocks\n"); ++ ++ ret = devm_pm_runtime_enable(dev); ++ if (ret) ++ return ret; ++ ++ /* enable clock for regcache get default value from hw */ ++ afe_priv->pm_runtime_bypass_reg_ctl = true; ++ pm_runtime_get_sync(&pdev->dev); ++ ++ afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr, ++ &mt7986_afe_regmap_config); ++ ++ pm_runtime_put_sync(&pdev->dev); ++ if (IS_ERR(afe->regmap)) ++ return PTR_ERR(afe->regmap); ++ ++ afe_priv->pm_runtime_bypass_reg_ctl = false; ++ ++ /* init memif */ ++ afe->memif_size = MT7986_MEMIF_NUM; ++ afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), ++ GFP_KERNEL); ++ if (!afe->memif) ++ return -ENOMEM; ++ ++ for (i = 0; i < afe->memif_size; i++) { ++ afe->memif[i].data = &memif_data[i]; ++ afe->memif[i].irq_usage = -1; ++ } ++ ++ mutex_init(&afe->irq_alloc_lock); ++ ++ /* irq initialize */ ++ afe->irqs_size = MT7986_IRQ_NUM; ++ afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), ++ GFP_KERNEL); ++ if (!afe->irqs) ++ return -ENOMEM; ++ ++ for (i = 0; i < afe->irqs_size; i++) ++ afe->irqs[i].irq_data = &irq_data[i]; ++ ++ /* request irq */ ++ irq_id = platform_get_irq(pdev, 0); ++ if (irq_id < 0) { ++ ret = irq_id; ++ return dev_err_probe(dev, ret, "No irq found\n"); ++ } ++ ret = devm_request_irq(dev, irq_id, mt7986_afe_irq_handler, ++ IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); ++ if (ret) ++ return dev_err_probe(dev, ret, "Failed to request irq for asys-isr\n"); ++ ++ /* init sub_dais */ ++ INIT_LIST_HEAD(&afe->sub_dais); ++ ++ for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) { ++ ret = dai_register_cbs[i](afe); ++ if (ret) ++ return dev_err_probe(dev, ret, "DAI register failed, i: %d\n", i); ++ } ++ ++ /* init dai_driver and component_driver */ ++ ret = mtk_afe_combine_sub_dai(afe); ++ if (ret) ++ return dev_err_probe(dev, ret, "mtk_afe_combine_sub_dai fail\n"); ++ ++ afe->mtk_afe_hardware = &mt7986_afe_hardware; ++ afe->memif_fs = mt7986_memif_fs; ++ afe->irq_fs = mt7986_irq_fs; ++ ++ afe->runtime_resume = mt7986_afe_runtime_resume; ++ afe->runtime_suspend = mt7986_afe_runtime_suspend; ++ ++ /* register component */ ++ ret = devm_snd_soc_register_component(&pdev->dev, ++ &mt7986_afe_component, ++ NULL, 0); ++ if (ret) ++ return dev_err_probe(dev, ret, "Cannot register AFE component\n"); ++ ++ ret = devm_snd_soc_register_component(afe->dev, ++ &mt7986_afe_pcm_dai_component, ++ afe->dai_drivers, ++ afe->num_dai_drivers); ++ if (ret) ++ return dev_err_probe(dev, ret, "Cannot register PCM DAI component\n"); ++ ++ return 0; ++} ++ ++static void mt7986_afe_pcm_dev_remove(struct platform_device *pdev) ++{ ++ pm_runtime_disable(&pdev->dev); ++ if (!pm_runtime_status_suspended(&pdev->dev)) ++ mt7986_afe_runtime_suspend(&pdev->dev); ++} ++ ++static const struct of_device_id mt7986_afe_pcm_dt_match[] = { ++ { .compatible = "mediatek,mt7986-afe" }, ++ { /* sentinel */ } ++}; ++MODULE_DEVICE_TABLE(of, mt7986_afe_pcm_dt_match); ++ ++static const struct dev_pm_ops mt7986_afe_pm_ops = { ++ SET_RUNTIME_PM_OPS(mt7986_afe_runtime_suspend, ++ mt7986_afe_runtime_resume, NULL) ++}; ++ ++static struct platform_driver mt7986_afe_pcm_driver = { ++ .driver = { ++ .name = "mt7986-audio", ++ .of_match_table = mt7986_afe_pcm_dt_match, ++ .pm = &mt7986_afe_pm_ops, ++ }, ++ .probe = mt7986_afe_pcm_dev_probe, ++ .remove_new = mt7986_afe_pcm_dev_remove, ++}; ++module_platform_driver(mt7986_afe_pcm_driver); ++ ++MODULE_DESCRIPTION("MediaTek SoC AFE platform driver for ALSA MT7986"); ++MODULE_AUTHOR("Vic Wu "); ++MODULE_LICENSE("GPL"); diff --git a/target/linux/mediatek/patches-5.15/860-v6.6-04-ASoC-mediatek-mt7986-add-machine-driver-with-wm8960.patch b/target/linux/mediatek/patches-5.15/860-v6.6-04-ASoC-mediatek-mt7986-add-machine-driver-with-wm8960.patch new file mode 100644 index 0000000000..dd354c04e3 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/860-v6.6-04-ASoC-mediatek-mt7986-add-machine-driver-with-wm8960.patch @@ -0,0 +1,243 @@ +From ddf6abc1c78072f8ccad59166be95f0ca5af8ca4 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:36 +0800 +Subject: [PATCH 4/9] ASoC: mediatek: mt7986: add machine driver with wm8960 + +Add support for mt7986 board with wm8960. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-5-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/Kconfig | 10 ++ + sound/soc/mediatek/mt7986/Makefile | 1 + + sound/soc/mediatek/mt7986/mt7986-wm8960.c | 196 ++++++++++++++++++++++ + 3 files changed, 207 insertions(+) + create mode 100644 sound/soc/mediatek/mt7986/mt7986-wm8960.c + +--- a/sound/soc/mediatek/Kconfig ++++ b/sound/soc/mediatek/Kconfig +@@ -64,6 +64,16 @@ config SND_SOC_MT7986 + Select Y if you have such device. + If unsure select "N". + ++config SND_SOC_MT7986_WM8960 ++ tristate "ASoc Audio driver for MT7986 with WM8960 codec" ++ depends on SND_SOC_MT7986 && I2C ++ select SND_SOC_WM8960 ++ help ++ This adds support for ASoC machine driver for MediaTek MT7986 ++ boards with the WM8960 codecs. ++ Select Y if you have such device. ++ If unsure select "N". ++ + config SND_SOC_MT8173 + tristate "ASoC support for Mediatek MT8173 chip" + depends on ARCH_MEDIATEK +--- a/sound/soc/mediatek/mt7986/Makefile ++++ b/sound/soc/mediatek/mt7986/Makefile +@@ -6,3 +6,4 @@ snd-soc-mt7986-afe-objs := \ + mt7986-dai-etdm.o + + obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o ++obj-$(CONFIG_SND_SOC_MT7986_WM8960) += mt7986-wm8960.o +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c +@@ -0,0 +1,196 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * mt7986-wm8960.c -- MT7986-WM8960 ALSA SoC machine driver ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#include ++#include ++ ++#include "mt7986-afe-common.h" ++ ++struct mt7986_wm8960_priv { ++ struct device_node *platform_node; ++ struct device_node *codec_node; ++}; ++ ++static const struct snd_soc_dapm_widget mt7986_wm8960_widgets[] = { ++ SND_SOC_DAPM_HP("Headphone", NULL), ++ SND_SOC_DAPM_MIC("AMIC", NULL), ++}; ++ ++static const struct snd_kcontrol_new mt7986_wm8960_controls[] = { ++ SOC_DAPM_PIN_SWITCH("Headphone"), ++ SOC_DAPM_PIN_SWITCH("AMIC"), ++}; ++ ++SND_SOC_DAILINK_DEFS(playback, ++ DAILINK_COMP_ARRAY(COMP_CPU("DL1")), ++ DAILINK_COMP_ARRAY(COMP_DUMMY()), ++ DAILINK_COMP_ARRAY(COMP_EMPTY())); ++ ++SND_SOC_DAILINK_DEFS(capture, ++ DAILINK_COMP_ARRAY(COMP_CPU("UL1")), ++ DAILINK_COMP_ARRAY(COMP_DUMMY()), ++ DAILINK_COMP_ARRAY(COMP_EMPTY())); ++ ++SND_SOC_DAILINK_DEFS(codec, ++ DAILINK_COMP_ARRAY(COMP_CPU("ETDM")), ++ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8960-hifi")), ++ DAILINK_COMP_ARRAY(COMP_EMPTY())); ++ ++static struct snd_soc_dai_link mt7986_wm8960_dai_links[] = { ++ /* FE */ ++ { ++ .name = "wm8960-playback", ++ .stream_name = "wm8960-playback", ++ .trigger = {SND_SOC_DPCM_TRIGGER_POST, ++ SND_SOC_DPCM_TRIGGER_POST}, ++ .dynamic = 1, ++ .dpcm_playback = 1, ++ SND_SOC_DAILINK_REG(playback), ++ }, ++ { ++ .name = "wm8960-capture", ++ .stream_name = "wm8960-capture", ++ .trigger = {SND_SOC_DPCM_TRIGGER_POST, ++ SND_SOC_DPCM_TRIGGER_POST}, ++ .dynamic = 1, ++ .dpcm_capture = 1, ++ SND_SOC_DAILINK_REG(capture), ++ }, ++ /* BE */ ++ { ++ .name = "wm8960-codec", ++ .no_pcm = 1, ++ .dai_fmt = SND_SOC_DAIFMT_I2S | ++ SND_SOC_DAIFMT_NB_NF | ++ SND_SOC_DAIFMT_CBS_CFS | ++ SND_SOC_DAIFMT_GATED, ++ .dpcm_playback = 1, ++ .dpcm_capture = 1, ++ SND_SOC_DAILINK_REG(codec), ++ }, ++}; ++ ++static struct snd_soc_card mt7986_wm8960_card = { ++ .name = "mt7986-wm8960", ++ .owner = THIS_MODULE, ++ .dai_link = mt7986_wm8960_dai_links, ++ .num_links = ARRAY_SIZE(mt7986_wm8960_dai_links), ++ .controls = mt7986_wm8960_controls, ++ .num_controls = ARRAY_SIZE(mt7986_wm8960_controls), ++ .dapm_widgets = mt7986_wm8960_widgets, ++ .num_dapm_widgets = ARRAY_SIZE(mt7986_wm8960_widgets), ++}; ++ ++static int mt7986_wm8960_machine_probe(struct platform_device *pdev) ++{ ++ struct snd_soc_card *card = &mt7986_wm8960_card; ++ struct snd_soc_dai_link *dai_link; ++ struct device_node *platform, *codec; ++ struct mt7986_wm8960_priv *priv; ++ int ret, i; ++ ++ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ platform = of_get_child_by_name(pdev->dev.of_node, "platform"); ++ ++ if (platform) { ++ priv->platform_node = of_parse_phandle(platform, "sound-dai", 0); ++ of_node_put(platform); ++ ++ if (!priv->platform_node) { ++ dev_err(&pdev->dev, "Failed to parse platform/sound-dai property\n"); ++ return -EINVAL; ++ } ++ } else { ++ dev_err(&pdev->dev, "Property 'platform' missing or invalid\n"); ++ return -EINVAL; ++ } ++ ++ for_each_card_prelinks(card, i, dai_link) { ++ if (dai_link->platforms->name) ++ continue; ++ dai_link->platforms->of_node = priv->platform_node; ++ } ++ ++ card->dev = &pdev->dev; ++ ++ codec = of_get_child_by_name(pdev->dev.of_node, "codec"); ++ ++ if (codec) { ++ priv->codec_node = of_parse_phandle(codec, "sound-dai", 0); ++ of_node_put(codec); ++ ++ if (!priv->codec_node) { ++ of_node_put(priv->platform_node); ++ dev_err(&pdev->dev, "Failed to parse codec/sound-dai property\n"); ++ return -EINVAL; ++ } ++ } else { ++ of_node_put(priv->platform_node); ++ dev_err(&pdev->dev, "Property 'codec' missing or invalid\n"); ++ return -EINVAL; ++ } ++ ++ for_each_card_prelinks(card, i, dai_link) { ++ if (dai_link->codecs->name) ++ continue; ++ dai_link->codecs->of_node = priv->codec_node; ++ } ++ ++ ret = snd_soc_of_parse_audio_routing(card, "audio-routing"); ++ if (ret) { ++ dev_err(&pdev->dev, "Failed to parse audio-routing: %d\n", ret); ++ goto err_of_node_put; ++ } ++ ++ ret = devm_snd_soc_register_card(&pdev->dev, card); ++ if (ret) { ++ dev_err(&pdev->dev, "%s snd_soc_register_card fail: %d\n", __func__, ret); ++ goto err_of_node_put; ++ } ++ ++err_of_node_put: ++ of_node_put(priv->codec_node); ++ of_node_put(priv->platform_node); ++ return ret; ++} ++ ++static void mt7986_wm8960_machine_remove(struct platform_device *pdev) ++{ ++ struct snd_soc_card *card = platform_get_drvdata(pdev); ++ struct mt7986_wm8960_priv *priv = snd_soc_card_get_drvdata(card); ++ ++ of_node_put(priv->codec_node); ++ of_node_put(priv->platform_node); ++} ++ ++static const struct of_device_id mt7986_wm8960_machine_dt_match[] = { ++ {.compatible = "mediatek,mt7986-wm8960-sound"}, ++ { /* sentinel */ } ++}; ++MODULE_DEVICE_TABLE(of, mt7986_wm8960_machine_dt_match); ++ ++static struct platform_driver mt7986_wm8960_machine = { ++ .driver = { ++ .name = "mt7986-wm8960", ++ .of_match_table = mt7986_wm8960_machine_dt_match, ++ }, ++ .probe = mt7986_wm8960_machine_probe, ++ .remove_new = mt7986_wm8960_machine_remove, ++}; ++ ++module_platform_driver(mt7986_wm8960_machine); ++ ++/* Module information */ ++MODULE_DESCRIPTION("MT7986 WM8960 ALSA SoC machine driver"); ++MODULE_AUTHOR("Vic Wu "); ++MODULE_LICENSE("GPL"); ++MODULE_ALIAS("mt7986 wm8960 soc card"); diff --git a/target/linux/mediatek/patches-5.15/860-v6.6-05-ASoC-dt-bindings-mediatek-mt7986-wm8960-add-mt7986-w.patch b/target/linux/mediatek/patches-5.15/860-v6.6-05-ASoC-dt-bindings-mediatek-mt7986-wm8960-add-mt7986-w.patch new file mode 100644 index 0000000000..8cf0b5464a --- /dev/null +++ b/target/linux/mediatek/patches-5.15/860-v6.6-05-ASoC-dt-bindings-mediatek-mt7986-wm8960-add-mt7986-w.patch @@ -0,0 +1,87 @@ +From 72469f950b629e57e60fbcbefed45e083619b986 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:37 +0800 +Subject: [PATCH 5/9] ASoC: dt-bindings: mediatek,mt7986-wm8960: add + mt7986-wm8960 document + +Add document for mt7986 board with wm8960. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-6-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + .../sound/mediatek,mt7986-wm8960.yaml | 67 +++++++++++++++++++ + 1 file changed, 67 insertions(+) + create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml + +--- /dev/null ++++ b/Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml +@@ -0,0 +1,67 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: MediaTek MT7986 sound card with WM8960 codec ++ ++maintainers: ++ - Maso Huang ++ ++allOf: ++ - $ref: sound-card-common.yaml# ++ ++properties: ++ compatible: ++ const: mediatek,mt7986-wm8960-sound ++ ++ platform: ++ type: object ++ additionalProperties: false ++ properties: ++ sound-dai: ++ description: The phandle of MT7986 platform. ++ maxItems: 1 ++ required: ++ - sound-dai ++ ++ codec: ++ type: object ++ additionalProperties: false ++ properties: ++ sound-dai: ++ description: The phandle of wm8960 codec. ++ maxItems: 1 ++ required: ++ - sound-dai ++ ++unevaluatedProperties: false ++ ++required: ++ - compatible ++ - audio-routing ++ - platform ++ - codec ++ ++examples: ++ - | ++ sound { ++ compatible = "mediatek,mt7986-wm8960-sound"; ++ model = "mt7986-wm8960"; ++ audio-routing = ++ "Headphone", "HP_L", ++ "Headphone", "HP_R", ++ "LINPUT1", "AMIC", ++ "RINPUT1", "AMIC"; ++ ++ platform { ++ sound-dai = <&afe>; ++ }; ++ ++ codec { ++ sound-dai = <&wm8960>; ++ }; ++ }; ++ ++... diff --git a/target/linux/mediatek/patches-5.15/860-v6.6-06-ASoC-dt-bindings-mediatek-mt7986-afe-add-audio-afe-d.patch b/target/linux/mediatek/patches-5.15/860-v6.6-06-ASoC-dt-bindings-mediatek-mt7986-afe-add-audio-afe-d.patch new file mode 100644 index 0000000000..236d6a217c --- /dev/null +++ b/target/linux/mediatek/patches-5.15/860-v6.6-06-ASoC-dt-bindings-mediatek-mt7986-afe-add-audio-afe-d.patch @@ -0,0 +1,180 @@ +From d16202eb38585adbc16e32d11188dbc2127015de Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:38 +0800 +Subject: [PATCH 6/9] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe + document + +Add mt7986 audio afe document. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-7-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + .../bindings/sound/mediatek,mt7986-afe.yaml | 160 ++++++++++++++++++ + 1 file changed, 160 insertions(+) + create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml + +--- /dev/null ++++ b/Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml +@@ -0,0 +1,160 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/sound/mediatek,mt7986-afe.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: MediaTek AFE PCM controller for MT7986 ++ ++maintainers: ++ - Maso Huang ++ ++properties: ++ compatible: ++ oneOf: ++ - const: mediatek,mt7986-afe ++ - items: ++ - enum: ++ - mediatek,mt7981-afe ++ - mediatek,mt7988-afe ++ - const: mediatek,mt7986-afe ++ ++ reg: ++ maxItems: 1 ++ ++ interrupts: ++ maxItems: 1 ++ ++ clocks: ++ minItems: 5 ++ items: ++ - description: audio bus clock ++ - description: audio 26M clock ++ - description: audio intbus clock ++ - description: audio hopping clock ++ - description: audio pll clock ++ - description: mux for pcm_mck ++ - description: audio i2s/pcm mck ++ ++ clock-names: ++ minItems: 5 ++ items: ++ - const: bus_ck ++ - const: 26m_ck ++ - const: l_ck ++ - const: aud_ck ++ - const: eg2_ck ++ - const: sel ++ - const: i2s_m ++ ++required: ++ - compatible ++ - reg ++ - interrupts ++ - clocks ++ - clock-names ++ ++allOf: ++ - if: ++ properties: ++ compatible: ++ contains: ++ const: mediatek,mt7986-afe ++ then: ++ properties: ++ clocks: ++ items: ++ - description: audio bus clock ++ - description: audio 26M clock ++ - description: audio intbus clock ++ - description: audio hopping clock ++ - description: audio pll clock ++ clock-names: ++ items: ++ - const: bus_ck ++ - const: 26m_ck ++ - const: l_ck ++ - const: aud_ck ++ - const: eg2_ck ++ ++ - if: ++ properties: ++ compatible: ++ contains: ++ const: mediatek,mt7981-afe ++ then: ++ properties: ++ clocks: ++ items: ++ - description: audio bus clock ++ - description: audio 26M clock ++ - description: audio intbus clock ++ - description: audio hopping clock ++ - description: audio pll clock ++ - description: mux for pcm_mck ++ clock-names: ++ items: ++ - const: bus_ck ++ - const: 26m_ck ++ - const: l_ck ++ - const: aud_ck ++ - const: eg2_ck ++ - const: sel ++ ++ - if: ++ properties: ++ compatible: ++ contains: ++ const: mediatek,mt7988-afe ++ then: ++ properties: ++ clocks: ++ items: ++ - description: audio bus clock ++ - description: audio 26M clock ++ - description: audio intbus clock ++ - description: audio hopping clock ++ - description: audio pll clock ++ - description: mux for pcm_mck ++ - description: audio i2s/pcm mck ++ clock-names: ++ items: ++ - const: bus_ck ++ - const: 26m_ck ++ - const: l_ck ++ - const: aud_ck ++ - const: eg2_ck ++ - const: sel ++ - const: i2s_m ++ ++additionalProperties: false ++ ++examples: ++ - | ++ #include ++ #include ++ #include ++ ++ afe@11210000 { ++ compatible = "mediatek,mt7986-afe"; ++ reg = <0x11210000 0x9000>; ++ interrupts = ; ++ clocks = <&infracfg_ao CLK_INFRA_AUD_BUS_CK>, ++ <&infracfg_ao CLK_INFRA_AUD_26M_CK>, ++ <&infracfg_ao CLK_INFRA_AUD_L_CK>, ++ <&infracfg_ao CLK_INFRA_AUD_AUD_CK>, ++ <&infracfg_ao CLK_INFRA_AUD_EG2_CK>; ++ clock-names = "bus_ck", ++ "26m_ck", ++ "l_ck", ++ "aud_ck", ++ "eg2_ck"; ++ assigned-clocks = <&topckgen CLK_TOP_A1SYS_SEL>, ++ <&topckgen CLK_TOP_AUD_L_SEL>, ++ <&topckgen CLK_TOP_A_TUNER_SEL>; ++ assigned-clock-parents = <&topckgen CLK_TOP_APLL2_D4>, ++ <&apmixedsys CLK_APMIXED_APLL2>, ++ <&topckgen CLK_TOP_APLL2_D4>; ++ }; ++ ++... diff --git a/target/linux/mediatek/patches-5.15/860-v6.7-07-ASoC-mediatek-mt7986-drop-the-remove-callback-of-mt7.patch b/target/linux/mediatek/patches-5.15/860-v6.7-07-ASoC-mediatek-mt7986-drop-the-remove-callback-of-mt7.patch new file mode 100644 index 0000000000..413db8233f --- /dev/null +++ b/target/linux/mediatek/patches-5.15/860-v6.7-07-ASoC-mediatek-mt7986-drop-the-remove-callback-of-mt7.patch @@ -0,0 +1,42 @@ +From f3f0934e5c7b9c16e0cb2435be3555382e6293ad Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Tue, 24 Oct 2023 11:50:17 +0800 +Subject: [PATCH 7/9] ASoC: mediatek: mt7986: drop the remove callback of + mt7986_wm8960 + +Drop the remove callback of mt7986_wm8960. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20231024035019.11732-2-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-wm8960.c | 10 ---------- + 1 file changed, 10 deletions(-) + +--- a/sound/soc/mediatek/mt7986/mt7986-wm8960.c ++++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c +@@ -163,15 +163,6 @@ err_of_node_put: + return ret; + } + +-static void mt7986_wm8960_machine_remove(struct platform_device *pdev) +-{ +- struct snd_soc_card *card = platform_get_drvdata(pdev); +- struct mt7986_wm8960_priv *priv = snd_soc_card_get_drvdata(card); +- +- of_node_put(priv->codec_node); +- of_node_put(priv->platform_node); +-} +- + static const struct of_device_id mt7986_wm8960_machine_dt_match[] = { + {.compatible = "mediatek,mt7986-wm8960-sound"}, + { /* sentinel */ } +@@ -184,7 +175,6 @@ static struct platform_driver mt7986_wm8 + .of_match_table = mt7986_wm8960_machine_dt_match, + }, + .probe = mt7986_wm8960_machine_probe, +- .remove_new = mt7986_wm8960_machine_remove, + }; + + module_platform_driver(mt7986_wm8960_machine); diff --git a/target/linux/mediatek/patches-5.15/860-v6.7-08-ASoC-mediatek-mt7986-remove-the-mt7986_wm8960_priv-s.patch b/target/linux/mediatek/patches-5.15/860-v6.7-08-ASoC-mediatek-mt7986-remove-the-mt7986_wm8960_priv-s.patch new file mode 100644 index 0000000000..5c596fc49c --- /dev/null +++ b/target/linux/mediatek/patches-5.15/860-v6.7-08-ASoC-mediatek-mt7986-remove-the-mt7986_wm8960_priv-s.patch @@ -0,0 +1,105 @@ +From 98b8fb2cb4fcab1903d0baf611bf0c3f822a08dc Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Tue, 24 Oct 2023 11:50:18 +0800 +Subject: [PATCH 8/9] ASoC: mediatek: mt7986: remove the mt7986_wm8960_priv + structure + +Remove the mt7986_wm8960_priv structure. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20231024035019.11732-3-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-wm8960.c | 33 +++++++++-------------- + 1 file changed, 12 insertions(+), 21 deletions(-) + +--- a/sound/soc/mediatek/mt7986/mt7986-wm8960.c ++++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c +@@ -12,11 +12,6 @@ + + #include "mt7986-afe-common.h" + +-struct mt7986_wm8960_priv { +- struct device_node *platform_node; +- struct device_node *codec_node; +-}; +- + static const struct snd_soc_dapm_widget mt7986_wm8960_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_MIC("AMIC", NULL), +@@ -92,20 +87,18 @@ static int mt7986_wm8960_machine_probe(s + struct snd_soc_card *card = &mt7986_wm8960_card; + struct snd_soc_dai_link *dai_link; + struct device_node *platform, *codec; +- struct mt7986_wm8960_priv *priv; ++ struct device_node *platform_dai_node, *codec_dai_node; + int ret, i; + +- priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); +- if (!priv) +- return -ENOMEM; ++ card->dev = &pdev->dev; + + platform = of_get_child_by_name(pdev->dev.of_node, "platform"); + + if (platform) { +- priv->platform_node = of_parse_phandle(platform, "sound-dai", 0); ++ platform_dai_node = of_parse_phandle(platform, "sound-dai", 0); + of_node_put(platform); + +- if (!priv->platform_node) { ++ if (!platform_dai_node) { + dev_err(&pdev->dev, "Failed to parse platform/sound-dai property\n"); + return -EINVAL; + } +@@ -117,24 +110,22 @@ static int mt7986_wm8960_machine_probe(s + for_each_card_prelinks(card, i, dai_link) { + if (dai_link->platforms->name) + continue; +- dai_link->platforms->of_node = priv->platform_node; ++ dai_link->platforms->of_node = platform_dai_node; + } + +- card->dev = &pdev->dev; +- + codec = of_get_child_by_name(pdev->dev.of_node, "codec"); + + if (codec) { +- priv->codec_node = of_parse_phandle(codec, "sound-dai", 0); ++ codec_dai_node = of_parse_phandle(codec, "sound-dai", 0); + of_node_put(codec); + +- if (!priv->codec_node) { +- of_node_put(priv->platform_node); ++ if (!codec_dai_node) { ++ of_node_put(platform_dai_node); + dev_err(&pdev->dev, "Failed to parse codec/sound-dai property\n"); + return -EINVAL; + } + } else { +- of_node_put(priv->platform_node); ++ of_node_put(platform_dai_node); + dev_err(&pdev->dev, "Property 'codec' missing or invalid\n"); + return -EINVAL; + } +@@ -142,7 +133,7 @@ static int mt7986_wm8960_machine_probe(s + for_each_card_prelinks(card, i, dai_link) { + if (dai_link->codecs->name) + continue; +- dai_link->codecs->of_node = priv->codec_node; ++ dai_link->codecs->of_node = codec_dai_node; + } + + ret = snd_soc_of_parse_audio_routing(card, "audio-routing"); +@@ -158,8 +149,8 @@ static int mt7986_wm8960_machine_probe(s + } + + err_of_node_put: +- of_node_put(priv->codec_node); +- of_node_put(priv->platform_node); ++ of_node_put(platform_dai_node); ++ of_node_put(codec_dai_node); + return ret; + } + diff --git a/target/linux/mediatek/patches-5.15/860-v6.7-09-ASoC-mediatek-mt7986-add-sample-rate-checker.patch b/target/linux/mediatek/patches-5.15/860-v6.7-09-ASoC-mediatek-mt7986-add-sample-rate-checker.patch new file mode 100644 index 0000000000..d4128deabc --- /dev/null +++ b/target/linux/mediatek/patches-5.15/860-v6.7-09-ASoC-mediatek-mt7986-add-sample-rate-checker.patch @@ -0,0 +1,49 @@ +From 4e229f4264f4be7a6a554487714c0913ef59cf7f Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Tue, 24 Oct 2023 11:50:19 +0800 +Subject: [PATCH 9/9] ASoC: mediatek: mt7986: add sample rate checker + +mt7986 only supports 8/12/16/24/32/48/96/192 kHz + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20231024035019.11732-4-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 23 +++++++++++++++++---- + 1 file changed, 19 insertions(+), 4 deletions(-) + +--- a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c ++++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c +@@ -237,12 +237,27 @@ static int mtk_dai_etdm_hw_params(struct + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) + { ++ unsigned int rate = params_rate(params); + struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + +- mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); +- mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); +- +- return 0; ++ switch (rate) { ++ case 8000: ++ case 12000: ++ case 16000: ++ case 24000: ++ case 32000: ++ case 48000: ++ case 96000: ++ case 192000: ++ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); ++ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); ++ return 0; ++ default: ++ dev_err(afe->dev, ++ "Sample rate %d invalid. Supported rates: 8/12/16/24/32/48/96/192 kHz\n", ++ rate); ++ return -EINVAL; ++ } + } + + static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd, diff --git a/target/linux/mediatek/patches-5.15/861-pending-10-ASoC-mediatek-mt7986-silence-error-in-case-of-EPROBE.patch b/target/linux/mediatek/patches-5.15/861-pending-10-ASoC-mediatek-mt7986-silence-error-in-case-of-EPROBE.patch new file mode 100644 index 0000000000..a40c249257 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/861-pending-10-ASoC-mediatek-mt7986-silence-error-in-case-of-EPROBE.patch @@ -0,0 +1,26 @@ +From e4cde335d1771863a60b6931e51357b8470e85c4 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sun, 10 Dec 2023 22:41:39 +0000 +Subject: [PATCH] ASoC: mediatek: mt7986: silence error in case of + -EPROBE_DEFER + +If probe is defered no error should be printed. Mute it. + +Signed-off-by: Daniel Golle +--- + sound/soc/mediatek/mt7986/mt7986-wm8960.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/sound/soc/mediatek/mt7986/mt7986-wm8960.c ++++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c +@@ -144,7 +144,9 @@ static int mt7986_wm8960_machine_probe(s + + ret = devm_snd_soc_register_card(&pdev->dev, card); + if (ret) { +- dev_err(&pdev->dev, "%s snd_soc_register_card fail: %d\n", __func__, ret); ++ if (ret != -EPROBE_DEFER) ++ dev_err(&pdev->dev, "%s snd_soc_register_card fail: %d\n", __func__, ret); ++ + goto err_of_node_put; + } + diff --git a/target/linux/mediatek/patches-5.15/862-arm64-dts-mt7986-add-afe.patch b/target/linux/mediatek/patches-5.15/862-arm64-dts-mt7986-add-afe.patch new file mode 100644 index 0000000000..b31710fe69 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/862-arm64-dts-mt7986-add-afe.patch @@ -0,0 +1,40 @@ +From 1c09b694a1e9378931085e77d834a4d9786a5356 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 7 Sep 2023 10:54:37 +0800 +Subject: [PATCH] arm64: dts: mt7986: add afe + +--- + arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 23 +++++++++++ + 1 files changed, 23 insertions(+) + +--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi ++++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi +@@ -248,6 +248,28 @@ + status = "disabled"; + }; + ++ afe: audio-controller@11210000 { ++ compatible = "mediatek,mt7986-afe"; ++ reg = <0 0x11210000 0 0x9000>; ++ interrupts = ; ++ clocks = <&infracfg CLK_INFRA_AUD_BUS_CK>, ++ <&infracfg CLK_INFRA_AUD_26M_CK>, ++ <&infracfg CLK_INFRA_AUD_L_CK>, ++ <&infracfg CLK_INFRA_AUD_AUD_CK>, ++ <&infracfg CLK_INFRA_AUD_EG2_CK>; ++ clock-names = "aud_bus_ck", ++ "aud_26m_ck", ++ "aud_l_ck", ++ "aud_aud_ck", ++ "aud_eg2_ck"; ++ assigned-clocks = <&topckgen CLK_TOP_A1SYS_SEL>, ++ <&topckgen CLK_TOP_AUD_L_SEL>, ++ <&topckgen CLK_TOP_A_TUNER_SEL>; ++ assigned-clock-parents = <&topckgen CLK_TOP_APLL2_D4>, ++ <&apmixedsys CLK_APMIXED_APLL2>, ++ <&topckgen CLK_TOP_APLL2_D4>; ++ }; ++ + pwm: pwm@10048000 { + compatible = "mediatek,mt7986-pwm"; + reg = <0 0x10048000 0 0x1000>; diff --git a/target/linux/mediatek/patches-5.15/863-arm64-dts-mt7986-add-sound-wm8960.patch b/target/linux/mediatek/patches-5.15/863-arm64-dts-mt7986-add-sound-wm8960.patch new file mode 100644 index 0000000000..15e30dec56 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/863-arm64-dts-mt7986-add-sound-wm8960.patch @@ -0,0 +1,61 @@ +From 1c09b694a1e9378931085e77d834a4d9786a5356 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 7 Sep 2023 10:54:37 +0800 +Subject: [PATCH] arm64: dts: mt7986: add sound wm8960 + +--- + .../dts/mediatek/mt7986a-rfb-spim-nand.dts | 39 +++++++++++++++++++ + 1 files changed, 39 insertions(+) + +--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb-spim-nand.dts ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb-spim-nand.dts +@@ -4,6 +4,35 @@ + + / { + compatible = "mediatek,mt7986a-rfb-snand"; ++ ++ sound_wm8960 { ++ compatible = "mediatek,mt7986-wm8960-sound"; ++ audio-routing = "Headphone", "HP_L", ++ "Headphone", "HP_R", ++ "LINPUT1", "AMIC", ++ "RINPUT1", "AMIC"; ++ ++ status = "okay"; ++ ++ platform { ++ sound-dai = <&afe>; ++ }; ++ ++ codec { ++ sound-dai = <&wm8960>; ++ }; ++ }; ++}; ++ ++&i2c0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c_pins>; ++ status = "okay"; ++ ++ wm8960: wm8960@1a { ++ compatible = "wlf,wm8960"; ++ reg = <0x1a>; ++ }; + }; + + &spi0 { +@@ -50,3 +79,13 @@ + &wifi { + mediatek,mtd-eeprom = <&factory 0>; + }; ++ ++&pio { ++ i2c_pins: i2c-pins-3-4 { ++ mux { ++ function = "i2c"; ++ groups = "i2c"; ++ }; ++ }; ++}; ++ diff --git a/target/linux/mediatek/patches-5.15/941-arm64-dts-mt7986-move-cpuboot-in-a-dedicated-node.patch b/target/linux/mediatek/patches-5.15/941-arm64-dts-mt7986-move-cpuboot-in-a-dedicated-node.patch index 0a58ae953b..3ba485346c 100644 --- a/target/linux/mediatek/patches-5.15/941-arm64-dts-mt7986-move-cpuboot-in-a-dedicated-node.patch +++ b/target/linux/mediatek/patches-5.15/941-arm64-dts-mt7986-move-cpuboot-in-a-dedicated-node.patch @@ -24,7 +24,7 @@ Signed-off-by: Lorenzo Bianconi }; timer { -@@ -518,10 +512,11 @@ +@@ -540,10 +534,11 @@ interrupt-parent = <&gic>; interrupts = ; memory-region = <&wo_emi0>, <&wo_ilm0>, <&wo_dlm0>, @@ -38,7 +38,7 @@ Signed-off-by: Lorenzo Bianconi }; wed1: wed@15011000 { -@@ -531,10 +526,11 @@ +@@ -553,10 +548,11 @@ interrupt-parent = <&gic>; interrupts = ; memory-region = <&wo_emi1>, <&wo_ilm1>, <&wo_dlm1>, @@ -52,7 +52,7 @@ Signed-off-by: Lorenzo Bianconi }; wo_ccif0: syscon@151a5000 { -@@ -551,6 +547,11 @@ +@@ -573,6 +569,11 @@ interrupts = ; }; diff --git a/target/linux/mediatek/patches-5.15/945-arm64-dts-mt7986-move-ilm-in-a-dedicated-node.patch b/target/linux/mediatek/patches-5.15/945-arm64-dts-mt7986-move-ilm-in-a-dedicated-node.patch index 36fe927837..0ba9bd7cf0 100644 --- a/target/linux/mediatek/patches-5.15/945-arm64-dts-mt7986-move-ilm-in-a-dedicated-node.patch +++ b/target/linux/mediatek/patches-5.15/945-arm64-dts-mt7986-move-ilm-in-a-dedicated-node.patch @@ -34,7 +34,7 @@ Signed-off-by: Lorenzo Bianconi wo_data: wo-data@4fd80000 { reg = <0 0x4fd80000 0 0x240000>; no-map; -@@ -511,11 +501,10 @@ +@@ -533,11 +523,10 @@ reg = <0 0x15010000 0 0x1000>; interrupt-parent = <&gic>; interrupts = ; @@ -49,7 +49,7 @@ Signed-off-by: Lorenzo Bianconi mediatek,wo-cpuboot = <&wo_cpuboot>; }; -@@ -525,11 +514,10 @@ +@@ -547,11 +536,10 @@ reg = <0 0x15011000 0 0x1000>; interrupt-parent = <&gic>; interrupts = ; @@ -64,7 +64,7 @@ Signed-off-by: Lorenzo Bianconi mediatek,wo-cpuboot = <&wo_cpuboot>; }; -@@ -547,6 +535,16 @@ +@@ -569,6 +557,16 @@ interrupts = ; }; diff --git a/target/linux/mediatek/patches-5.15/946-arm64-dts-mt7986-move-dlm-in-a-dedicated-node.patch b/target/linux/mediatek/patches-5.15/946-arm64-dts-mt7986-move-dlm-in-a-dedicated-node.patch index 55f17286c6..90b2bb91a2 100644 --- a/target/linux/mediatek/patches-5.15/946-arm64-dts-mt7986-move-dlm-in-a-dedicated-node.patch +++ b/target/linux/mediatek/patches-5.15/946-arm64-dts-mt7986-move-dlm-in-a-dedicated-node.patch @@ -34,7 +34,7 @@ Signed-off-by: Lorenzo Bianconi }; timer { -@@ -501,10 +491,11 @@ +@@ -523,10 +513,11 @@ reg = <0 0x15010000 0 0x1000>; interrupt-parent = <&gic>; interrupts = ; @@ -48,7 +48,7 @@ Signed-off-by: Lorenzo Bianconi mediatek,wo-cpuboot = <&wo_cpuboot>; }; -@@ -514,10 +505,11 @@ +@@ -536,10 +527,11 @@ reg = <0 0x15011000 0 0x1000>; interrupt-parent = <&gic>; interrupts = ; @@ -62,7 +62,7 @@ Signed-off-by: Lorenzo Bianconi mediatek,wo-cpuboot = <&wo_cpuboot>; }; -@@ -545,6 +537,16 @@ +@@ -567,6 +559,16 @@ reg = <0 0x151f0000 0 0x8000>; }; diff --git a/target/linux/mediatek/patches-6.1/860-v6.6-01-ASoC-mediatek-mt7986-add-common-header.patch b/target/linux/mediatek/patches-6.1/860-v6.6-01-ASoC-mediatek-mt7986-add-common-header.patch new file mode 100644 index 0000000000..9607eec821 --- /dev/null +++ b/target/linux/mediatek/patches-6.1/860-v6.6-01-ASoC-mediatek-mt7986-add-common-header.patch @@ -0,0 +1,269 @@ +From d35469096915f2551ed1d26da1ab12ff500fc963 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:33 +0800 +Subject: [PATCH 1/9] ASoC: mediatek: mt7986: add common header + +Add header files for register definition and structure. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-2-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-afe-common.h | 49 +++++ + sound/soc/mediatek/mt7986/mt7986-reg.h | 196 ++++++++++++++++++ + 2 files changed, 245 insertions(+) + create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-common.h + create mode 100644 sound/soc/mediatek/mt7986/mt7986-reg.h + +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-afe-common.h +@@ -0,0 +1,49 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * mt7986-afe-common.h -- MediaTek 7986 audio driver definitions ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#ifndef _MT_7986_AFE_COMMON_H_ ++#define _MT_7986_AFE_COMMON_H_ ++ ++#include ++#include ++#include ++#include ++#include "../common/mtk-base-afe.h" ++ ++enum { ++ MT7986_MEMIF_DL1, ++ MT7986_MEMIF_VUL12, ++ MT7986_MEMIF_NUM, ++ MT7986_DAI_ETDM = MT7986_MEMIF_NUM, ++ MT7986_DAI_NUM, ++}; ++ ++enum { ++ MT7986_IRQ_0, ++ MT7986_IRQ_1, ++ MT7986_IRQ_2, ++ MT7986_IRQ_NUM, ++}; ++ ++struct mt7986_afe_private { ++ struct clk_bulk_data *clks; ++ int num_clks; ++ ++ int pm_runtime_bypass_reg_ctl; ++ ++ /* dai */ ++ void *dai_priv[MT7986_DAI_NUM]; ++}; ++ ++unsigned int mt7986_afe_rate_transform(struct device *dev, ++ unsigned int rate); ++ ++/* dai register */ ++int mt7986_dai_etdm_register(struct mtk_base_afe *afe); ++#endif +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-reg.h +@@ -0,0 +1,196 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * mt7986-reg.h -- MediaTek 7986 audio driver reg definition ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#ifndef _MT7986_REG_H_ ++#define _MT7986_REG_H_ ++ ++#define AUDIO_TOP_CON2 0x0008 ++#define AUDIO_TOP_CON4 0x0010 ++#define AUDIO_ENGEN_CON0 0x0014 ++#define AFE_IRQ_MCU_EN 0x0100 ++#define AFE_IRQ_MCU_STATUS 0x0120 ++#define AFE_IRQ_MCU_CLR 0x0128 ++#define AFE_IRQ0_MCU_CFG0 0x0140 ++#define AFE_IRQ0_MCU_CFG1 0x0144 ++#define AFE_IRQ1_MCU_CFG0 0x0148 ++#define AFE_IRQ1_MCU_CFG1 0x014c ++#define AFE_IRQ2_MCU_CFG0 0x0150 ++#define AFE_IRQ2_MCU_CFG1 0x0154 ++#define ETDM_IN5_CON0 0x13f0 ++#define ETDM_IN5_CON1 0x13f4 ++#define ETDM_IN5_CON2 0x13f8 ++#define ETDM_IN5_CON3 0x13fc ++#define ETDM_IN5_CON4 0x1400 ++#define ETDM_OUT5_CON0 0x1570 ++#define ETDM_OUT5_CON4 0x1580 ++#define ETDM_OUT5_CON5 0x1584 ++#define ETDM_4_7_COWORK_CON0 0x15e0 ++#define ETDM_4_7_COWORK_CON1 0x15e4 ++#define AFE_CONN018_1 0x1b44 ++#define AFE_CONN018_4 0x1b50 ++#define AFE_CONN019_1 0x1b64 ++#define AFE_CONN019_4 0x1b70 ++#define AFE_CONN124_1 0x2884 ++#define AFE_CONN124_4 0x2890 ++#define AFE_CONN125_1 0x28a4 ++#define AFE_CONN125_4 0x28b0 ++#define AFE_CONN_RS_0 0x3920 ++#define AFE_CONN_RS_3 0x392c ++#define AFE_CONN_16BIT_0 0x3960 ++#define AFE_CONN_16BIT_3 0x396c ++#define AFE_CONN_24BIT_0 0x3980 ++#define AFE_CONN_24BIT_3 0x398c ++#define AFE_MEMIF_CON0 0x3d98 ++#define AFE_MEMIF_RD_MON 0x3da0 ++#define AFE_MEMIF_WR_MON 0x3da4 ++#define AFE_DL0_BASE_MSB 0x3e40 ++#define AFE_DL0_BASE 0x3e44 ++#define AFE_DL0_CUR_MSB 0x3e48 ++#define AFE_DL0_CUR 0x3e4c ++#define AFE_DL0_END_MSB 0x3e50 ++#define AFE_DL0_END 0x3e54 ++#define AFE_DL0_RCH_MON 0x3e58 ++#define AFE_DL0_LCH_MON 0x3e5c ++#define AFE_DL0_CON0 0x3e60 ++#define AFE_VUL0_BASE_MSB 0x4220 ++#define AFE_VUL0_BASE 0x4224 ++#define AFE_VUL0_CUR_MSB 0x4228 ++#define AFE_VUL0_CUR 0x422c ++#define AFE_VUL0_END_MSB 0x4230 ++#define AFE_VUL0_END 0x4234 ++#define AFE_VUL0_CON0 0x4238 ++ ++#define AFE_MAX_REGISTER AFE_VUL0_CON0 ++#define AFE_IRQ_STATUS_BITS 0x7 ++#define AFE_IRQ_CNT_SHIFT 0 ++#define AFE_IRQ_CNT_MASK 0xffffff ++ ++/* AUDIO_TOP_CON2 */ ++#define CLK_OUT5_PDN BIT(14) ++#define CLK_OUT5_PDN_MASK BIT(14) ++#define CLK_IN5_PDN BIT(7) ++#define CLK_IN5_PDN_MASK BIT(7) ++ ++/* AUDIO_TOP_CON4 */ ++#define PDN_APLL_TUNER2 BIT(12) ++#define PDN_APLL_TUNER2_MASK BIT(12) ++ ++/* AUDIO_ENGEN_CON0 */ ++#define AUD_APLL2_EN BIT(3) ++#define AUD_APLL2_EN_MASK BIT(3) ++#define AUD_26M_EN BIT(0) ++#define AUD_26M_EN_MASK BIT(0) ++ ++/* AFE_DL0_CON0 */ ++#define DL0_ON_SFT 28 ++#define DL0_ON_MASK 0x1 ++#define DL0_ON_MASK_SFT BIT(28) ++#define DL0_MINLEN_SFT 20 ++#define DL0_MINLEN_MASK 0xf ++#define DL0_MINLEN_MASK_SFT (0xf << 20) ++#define DL0_MODE_SFT 8 ++#define DL0_MODE_MASK 0x1f ++#define DL0_MODE_MASK_SFT (0x1f << 8) ++#define DL0_PBUF_SIZE_SFT 5 ++#define DL0_PBUF_SIZE_MASK 0x3 ++#define DL0_PBUF_SIZE_MASK_SFT (0x3 << 5) ++#define DL0_MONO_SFT 4 ++#define DL0_MONO_MASK 0x1 ++#define DL0_MONO_MASK_SFT BIT(4) ++#define DL0_HALIGN_SFT 2 ++#define DL0_HALIGN_MASK 0x1 ++#define DL0_HALIGN_MASK_SFT BIT(2) ++#define DL0_HD_MODE_SFT 0 ++#define DL0_HD_MODE_MASK 0x3 ++#define DL0_HD_MODE_MASK_SFT (0x3 << 0) ++ ++/* AFE_VUL0_CON0 */ ++#define VUL0_ON_SFT 28 ++#define VUL0_ON_MASK 0x1 ++#define VUL0_ON_MASK_SFT BIT(28) ++#define VUL0_MODE_SFT 8 ++#define VUL0_MODE_MASK 0x1f ++#define VUL0_MODE_MASK_SFT (0x1f << 8) ++#define VUL0_MONO_SFT 4 ++#define VUL0_MONO_MASK 0x1 ++#define VUL0_MONO_MASK_SFT BIT(4) ++#define VUL0_HALIGN_SFT 2 ++#define VUL0_HALIGN_MASK 0x1 ++#define VUL0_HALIGN_MASK_SFT BIT(2) ++#define VUL0_HD_MODE_SFT 0 ++#define VUL0_HD_MODE_MASK 0x3 ++#define VUL0_HD_MODE_MASK_SFT (0x3 << 0) ++ ++/* AFE_IRQ_MCU_CON */ ++#define IRQ_MCU_MODE_SFT 4 ++#define IRQ_MCU_MODE_MASK 0x1f ++#define IRQ_MCU_MODE_MASK_SFT (0x1f << 4) ++#define IRQ_MCU_ON_SFT 0 ++#define IRQ_MCU_ON_MASK 0x1 ++#define IRQ_MCU_ON_MASK_SFT BIT(0) ++#define IRQ0_MCU_CLR_SFT 0 ++#define IRQ0_MCU_CLR_MASK 0x1 ++#define IRQ0_MCU_CLR_MASK_SFT BIT(0) ++#define IRQ1_MCU_CLR_SFT 1 ++#define IRQ1_MCU_CLR_MASK 0x1 ++#define IRQ1_MCU_CLR_MASK_SFT BIT(1) ++#define IRQ2_MCU_CLR_SFT 2 ++#define IRQ2_MCU_CLR_MASK 0x1 ++#define IRQ2_MCU_CLR_MASK_SFT BIT(2) ++ ++/* ETDM_IN5_CON2 */ ++#define IN_CLK_SRC(x) ((x) << 10) ++#define IN_CLK_SRC_SFT 10 ++#define IN_CLK_SRC_MASK GENMASK(12, 10) ++ ++/* ETDM_IN5_CON3 */ ++#define IN_SEL_FS(x) ((x) << 26) ++#define IN_SEL_FS_SFT 26 ++#define IN_SEL_FS_MASK GENMASK(30, 26) ++ ++/* ETDM_IN5_CON4 */ ++#define IN_RELATCH(x) ((x) << 20) ++#define IN_RELATCH_SFT 20 ++#define IN_RELATCH_MASK GENMASK(24, 20) ++#define IN_CLK_INV BIT(18) ++#define IN_CLK_INV_MASK BIT(18) ++ ++/* ETDM_IN5_CON0 & ETDM_OUT5_CON0 */ ++#define RELATCH_SRC_MASK GENMASK(30, 28) ++#define ETDM_CH_NUM_MASK GENMASK(27, 23) ++#define ETDM_WRD_LEN_MASK GENMASK(20, 16) ++#define ETDM_BIT_LEN_MASK GENMASK(15, 11) ++#define ETDM_FMT_MASK GENMASK(8, 6) ++#define ETDM_SYNC BIT(1) ++#define ETDM_SYNC_MASK BIT(1) ++#define ETDM_EN BIT(0) ++#define ETDM_EN_MASK BIT(0) ++ ++/* ETDM_OUT5_CON4 */ ++#define OUT_RELATCH(x) ((x) << 24) ++#define OUT_RELATCH_SFT 24 ++#define OUT_RELATCH_MASK GENMASK(28, 24) ++#define OUT_CLK_SRC(x) ((x) << 6) ++#define OUT_CLK_SRC_SFT 6 ++#define OUT_CLK_SRC_MASK GENMASK(8, 6) ++#define OUT_SEL_FS(x) (x) ++#define OUT_SEL_FS_SFT 0 ++#define OUT_SEL_FS_MASK GENMASK(4, 0) ++ ++/* ETDM_OUT5_CON5 */ ++#define ETDM_CLK_DIV BIT(12) ++#define ETDM_CLK_DIV_MASK BIT(12) ++#define OUT_CLK_INV BIT(9) ++#define OUT_CLK_INV_MASK BIT(9) ++ ++/* ETDM_4_7_COWORK_CON0 */ ++#define OUT_SEL(x) ((x) << 12) ++#define OUT_SEL_SFT 12 ++#define OUT_SEL_MASK GENMASK(15, 12) ++#endif diff --git a/target/linux/mediatek/patches-6.1/860-v6.6-02-ASoC-mediatek-mt7986-support-etdm-in-platform-driver.patch b/target/linux/mediatek/patches-6.1/860-v6.6-02-ASoC-mediatek-mt7986-support-etdm-in-platform-driver.patch new file mode 100644 index 0000000000..f22add580f --- /dev/null +++ b/target/linux/mediatek/patches-6.1/860-v6.6-02-ASoC-mediatek-mt7986-support-etdm-in-platform-driver.patch @@ -0,0 +1,430 @@ +From 948a288897015fb3ee63b3f720b396b590c17fd7 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:34 +0800 +Subject: [PATCH 2/9] ASoC: mediatek: mt7986: support etdm in platform driver + +Add mt7986 etdm dai driver support. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-3-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 411 ++++++++++++++++++++ + 1 file changed, 411 insertions(+) + create mode 100644 sound/soc/mediatek/mt7986/mt7986-dai-etdm.c + +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c +@@ -0,0 +1,411 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * MediaTek ALSA SoC Audio DAI eTDM Control ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#include ++#include ++#include ++#include ++#include "mt7986-afe-common.h" ++#include "mt7986-reg.h" ++ ++#define HOPPING_CLK 0 ++#define APLL_CLK 1 ++#define MTK_DAI_ETDM_FORMAT_I2S 0 ++#define MTK_DAI_ETDM_FORMAT_DSPA 4 ++#define MTK_DAI_ETDM_FORMAT_DSPB 5 ++ ++enum { ++ MTK_ETDM_RATE_8K = 0, ++ MTK_ETDM_RATE_12K = 1, ++ MTK_ETDM_RATE_16K = 2, ++ MTK_ETDM_RATE_24K = 3, ++ MTK_ETDM_RATE_32K = 4, ++ MTK_ETDM_RATE_48K = 5, ++ MTK_ETDM_RATE_96K = 7, ++ MTK_ETDM_RATE_192K = 9, ++ MTK_ETDM_RATE_11K = 16, ++ MTK_ETDM_RATE_22K = 17, ++ MTK_ETDM_RATE_44K = 18, ++ MTK_ETDM_RATE_88K = 19, ++ MTK_ETDM_RATE_176K = 20, ++}; ++ ++struct mtk_dai_etdm_priv { ++ bool bck_inv; ++ bool lrck_inv; ++ bool slave_mode; ++ unsigned int format; ++}; ++ ++static unsigned int mt7986_etdm_rate_transform(struct device *dev, unsigned int rate) ++{ ++ switch (rate) { ++ case 8000: ++ return MTK_ETDM_RATE_8K; ++ case 11025: ++ return MTK_ETDM_RATE_11K; ++ case 12000: ++ return MTK_ETDM_RATE_12K; ++ case 16000: ++ return MTK_ETDM_RATE_16K; ++ case 22050: ++ return MTK_ETDM_RATE_22K; ++ case 24000: ++ return MTK_ETDM_RATE_24K; ++ case 32000: ++ return MTK_ETDM_RATE_32K; ++ case 44100: ++ return MTK_ETDM_RATE_44K; ++ case 48000: ++ return MTK_ETDM_RATE_48K; ++ case 88200: ++ return MTK_ETDM_RATE_88K; ++ case 96000: ++ return MTK_ETDM_RATE_96K; ++ case 176400: ++ return MTK_ETDM_RATE_176K; ++ case 192000: ++ return MTK_ETDM_RATE_192K; ++ default: ++ dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n", ++ __func__, rate, MTK_ETDM_RATE_48K); ++ return MTK_ETDM_RATE_48K; ++ } ++} ++ ++static int get_etdm_wlen(unsigned int bitwidth) ++{ ++ return bitwidth <= 16 ? 16 : 32; ++} ++ ++/* dai component */ ++/* interconnection */ ++ ++static const struct snd_kcontrol_new o124_mix[] = { ++ SOC_DAPM_SINGLE_AUTODISABLE("I032_Switch", AFE_CONN124_1, 0, 1, 0), ++}; ++ ++static const struct snd_kcontrol_new o125_mix[] = { ++ SOC_DAPM_SINGLE_AUTODISABLE("I033_Switch", AFE_CONN125_1, 1, 1, 0), ++}; ++ ++static const struct snd_soc_dapm_widget mtk_dai_etdm_widgets[] = { ++ ++ /* DL */ ++ SND_SOC_DAPM_MIXER("I150", SND_SOC_NOPM, 0, 0, NULL, 0), ++ SND_SOC_DAPM_MIXER("I151", SND_SOC_NOPM, 0, 0, NULL, 0), ++ /* UL */ ++ SND_SOC_DAPM_MIXER("O124", SND_SOC_NOPM, 0, 0, o124_mix, ARRAY_SIZE(o124_mix)), ++ SND_SOC_DAPM_MIXER("O125", SND_SOC_NOPM, 0, 0, o125_mix, ARRAY_SIZE(o125_mix)), ++}; ++ ++static const struct snd_soc_dapm_route mtk_dai_etdm_routes[] = { ++ {"I150", NULL, "ETDM Capture"}, ++ {"I151", NULL, "ETDM Capture"}, ++ {"ETDM Playback", NULL, "O124"}, ++ {"ETDM Playback", NULL, "O125"}, ++ {"O124", "I032_Switch", "I032"}, ++ {"O125", "I033_Switch", "I033"}, ++}; ++ ++/* dai ops */ ++static int mtk_dai_etdm_startup(struct snd_pcm_substream *substream, ++ struct snd_soc_dai *dai) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ int ret; ++ ++ ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks); ++ if (ret) ++ return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n"); ++ ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK, 0); ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK, 0); ++ ++ return 0; ++} ++ ++static void mtk_dai_etdm_shutdown(struct snd_pcm_substream *substream, ++ struct snd_soc_dai *dai) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK, ++ CLK_OUT5_PDN); ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK, ++ CLK_IN5_PDN); ++ ++ clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks); ++} ++ ++static unsigned int get_etdm_ch_fixup(unsigned int channels) ++{ ++ if (channels > 16) ++ return 24; ++ else if (channels > 8) ++ return 16; ++ else if (channels > 4) ++ return 8; ++ else if (channels > 2) ++ return 4; ++ else ++ return 2; ++} ++ ++static int mtk_dai_etdm_config(struct mtk_base_afe *afe, ++ struct snd_pcm_hw_params *params, ++ struct snd_soc_dai *dai, ++ int stream) ++{ ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; ++ unsigned int rate = params_rate(params); ++ unsigned int etdm_rate = mt7986_etdm_rate_transform(afe->dev, rate); ++ unsigned int afe_rate = mt7986_afe_rate_transform(afe->dev, rate); ++ unsigned int channels = params_channels(params); ++ unsigned int bit_width = params_width(params); ++ unsigned int wlen = get_etdm_wlen(bit_width); ++ unsigned int val = 0; ++ unsigned int mask = 0; ++ ++ dev_dbg(afe->dev, "%s(), stream %d, rate %u, bitwidth %u\n", ++ __func__, stream, rate, bit_width); ++ ++ /* CON0 */ ++ mask |= ETDM_BIT_LEN_MASK; ++ val |= FIELD_PREP(ETDM_BIT_LEN_MASK, bit_width - 1); ++ mask |= ETDM_WRD_LEN_MASK; ++ val |= FIELD_PREP(ETDM_WRD_LEN_MASK, wlen - 1); ++ mask |= ETDM_FMT_MASK; ++ val |= FIELD_PREP(ETDM_FMT_MASK, etdm_data->format); ++ mask |= ETDM_CH_NUM_MASK; ++ val |= FIELD_PREP(ETDM_CH_NUM_MASK, get_etdm_ch_fixup(channels) - 1); ++ mask |= RELATCH_SRC_MASK; ++ val |= FIELD_PREP(RELATCH_SRC_MASK, APLL_CLK); ++ ++ switch (stream) { ++ case SNDRV_PCM_STREAM_PLAYBACK: ++ /* set ETDM_OUT5_CON0 */ ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, mask, val); ++ ++ /* set ETDM_OUT5_CON4 */ ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON4, ++ OUT_RELATCH_MASK, OUT_RELATCH(afe_rate)); ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON4, ++ OUT_CLK_SRC_MASK, OUT_CLK_SRC(APLL_CLK)); ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON4, ++ OUT_SEL_FS_MASK, OUT_SEL_FS(etdm_rate)); ++ ++ /* set ETDM_OUT5_CON5 */ ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON5, ++ ETDM_CLK_DIV_MASK, ETDM_CLK_DIV); ++ break; ++ case SNDRV_PCM_STREAM_CAPTURE: ++ /* set ETDM_IN5_CON0 */ ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, mask, val); ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ++ ETDM_SYNC_MASK, ETDM_SYNC); ++ ++ /* set ETDM_IN5_CON2 */ ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON2, ++ IN_CLK_SRC_MASK, IN_CLK_SRC(APLL_CLK)); ++ ++ /* set ETDM_IN5_CON3 */ ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON3, ++ IN_SEL_FS_MASK, IN_SEL_FS(etdm_rate)); ++ ++ /* set ETDM_IN5_CON4 */ ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON4, ++ IN_RELATCH_MASK, IN_RELATCH(afe_rate)); ++ break; ++ default: ++ break; ++ } ++ ++ return 0; ++} ++ ++static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream, ++ struct snd_pcm_hw_params *params, ++ struct snd_soc_dai *dai) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ ++ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); ++ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); ++ ++ return 0; ++} ++ ++static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd, ++ struct snd_soc_dai *dai) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ ++ dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id); ++ switch (cmd) { ++ case SNDRV_PCM_TRIGGER_START: ++ case SNDRV_PCM_TRIGGER_RESUME: ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK, ++ ETDM_EN); ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK, ++ ETDM_EN); ++ break; ++ case SNDRV_PCM_TRIGGER_STOP: ++ case SNDRV_PCM_TRIGGER_SUSPEND: ++ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK, ++ 0); ++ regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK, ++ 0); ++ break; ++ default: ++ break; ++ } ++ ++ return 0; ++} ++ ++static int mtk_dai_etdm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ++{ ++ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ struct mtk_dai_etdm_priv *etdm_data; ++ void *priv_data; ++ ++ switch (dai->id) { ++ case MT7986_DAI_ETDM: ++ break; ++ default: ++ dev_warn(afe->dev, "%s(), id %d not support\n", ++ __func__, dai->id); ++ return -EINVAL; ++ } ++ ++ priv_data = devm_kzalloc(afe->dev, sizeof(struct mtk_dai_etdm_priv), ++ GFP_KERNEL); ++ if (!priv_data) ++ return -ENOMEM; ++ ++ afe_priv->dai_priv[dai->id] = priv_data; ++ etdm_data = afe_priv->dai_priv[dai->id]; ++ ++ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { ++ case SND_SOC_DAIFMT_I2S: ++ etdm_data->format = MTK_DAI_ETDM_FORMAT_I2S; ++ break; ++ case SND_SOC_DAIFMT_DSP_A: ++ etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPA; ++ break; ++ case SND_SOC_DAIFMT_DSP_B: ++ etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPB; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ switch (fmt & SND_SOC_DAIFMT_INV_MASK) { ++ case SND_SOC_DAIFMT_NB_NF: ++ etdm_data->bck_inv = false; ++ etdm_data->lrck_inv = false; ++ break; ++ case SND_SOC_DAIFMT_NB_IF: ++ etdm_data->bck_inv = false; ++ etdm_data->lrck_inv = true; ++ break; ++ case SND_SOC_DAIFMT_IB_NF: ++ etdm_data->bck_inv = true; ++ etdm_data->lrck_inv = false; ++ break; ++ case SND_SOC_DAIFMT_IB_IF: ++ etdm_data->bck_inv = true; ++ etdm_data->lrck_inv = true; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { ++ case SND_SOC_DAIFMT_CBM_CFM: ++ etdm_data->slave_mode = true; ++ break; ++ case SND_SOC_DAIFMT_CBS_CFS: ++ etdm_data->slave_mode = false; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static const struct snd_soc_dai_ops mtk_dai_etdm_ops = { ++ .startup = mtk_dai_etdm_startup, ++ .shutdown = mtk_dai_etdm_shutdown, ++ .hw_params = mtk_dai_etdm_hw_params, ++ .trigger = mtk_dai_etdm_trigger, ++ .set_fmt = mtk_dai_etdm_set_fmt, ++}; ++ ++/* dai driver */ ++#define MTK_ETDM_RATES (SNDRV_PCM_RATE_8000_48000 |\ ++ SNDRV_PCM_RATE_88200 |\ ++ SNDRV_PCM_RATE_96000 |\ ++ SNDRV_PCM_RATE_176400 |\ ++ SNDRV_PCM_RATE_192000) ++ ++#define MTK_ETDM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ ++ SNDRV_PCM_FMTBIT_S24_LE |\ ++ SNDRV_PCM_FMTBIT_S32_LE) ++ ++static struct snd_soc_dai_driver mtk_dai_etdm_driver[] = { ++ { ++ .name = "ETDM", ++ .id = MT7986_DAI_ETDM, ++ .capture = { ++ .stream_name = "ETDM Capture", ++ .channels_min = 1, ++ .channels_max = 2, ++ .rates = MTK_ETDM_RATES, ++ .formats = MTK_ETDM_FORMATS, ++ }, ++ .playback = { ++ .stream_name = "ETDM Playback", ++ .channels_min = 1, ++ .channels_max = 2, ++ .rates = MTK_ETDM_RATES, ++ .formats = MTK_ETDM_FORMATS, ++ }, ++ .ops = &mtk_dai_etdm_ops, ++ .symmetric_rate = 1, ++ .symmetric_sample_bits = 1, ++ }, ++}; ++ ++int mt7986_dai_etdm_register(struct mtk_base_afe *afe) ++{ ++ struct mtk_base_afe_dai *dai; ++ ++ dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); ++ if (!dai) ++ return -ENOMEM; ++ ++ list_add(&dai->list, &afe->sub_dais); ++ ++ dai->dai_drivers = mtk_dai_etdm_driver; ++ dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_etdm_driver); ++ ++ dai->dapm_widgets = mtk_dai_etdm_widgets; ++ dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_etdm_widgets); ++ dai->dapm_routes = mtk_dai_etdm_routes; ++ dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_etdm_routes); ++ ++ return 0; ++} diff --git a/target/linux/mediatek/patches-6.1/860-v6.6-03-ASoC-mediatek-mt7986-add-platform-driver.patch b/target/linux/mediatek/patches-6.1/860-v6.6-03-ASoC-mediatek-mt7986-add-platform-driver.patch new file mode 100644 index 0000000000..b899b963d2 --- /dev/null +++ b/target/linux/mediatek/patches-6.1/860-v6.6-03-ASoC-mediatek-mt7986-add-platform-driver.patch @@ -0,0 +1,685 @@ +From fc7776dee86bc07d22820a904760a95f49a2f12e Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:35 +0800 +Subject: [PATCH 3/9] ASoC: mediatek: mt7986: add platform driver + +Add mt7986 platform driver. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-4-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/Kconfig | 10 + + sound/soc/mediatek/Makefile | 1 + + sound/soc/mediatek/mt7986/Makefile | 8 + + sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 622 +++++++++++++++++++++ + 4 files changed, 641 insertions(+) + create mode 100644 sound/soc/mediatek/mt7986/Makefile + create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-pcm.c + +--- a/sound/soc/mediatek/Kconfig ++++ b/sound/soc/mediatek/Kconfig +@@ -54,6 +54,16 @@ config SND_SOC_MT6797_MT6351 + Select Y if you have such device. + If unsure select "N". + ++config SND_SOC_MT7986 ++ tristate "ASoC support for Mediatek MT7986 chip" ++ depends on ARCH_MEDIATEK ++ select SND_SOC_MEDIATEK ++ help ++ This adds ASoC platform driver support for MediaTek MT7986 chip ++ that can be used with other codecs. ++ Select Y if you have such device. ++ If unsure select "N". ++ + config SND_SOC_MT8173 + tristate "ASoC support for Mediatek MT8173 chip" + depends on ARCH_MEDIATEK +--- a/sound/soc/mediatek/Makefile ++++ b/sound/soc/mediatek/Makefile +@@ -2,6 +2,7 @@ + obj-$(CONFIG_SND_SOC_MEDIATEK) += common/ + obj-$(CONFIG_SND_SOC_MT2701) += mt2701/ + obj-$(CONFIG_SND_SOC_MT6797) += mt6797/ ++obj-$(CONFIG_SND_SOC_MT7986) += mt7986/ + obj-$(CONFIG_SND_SOC_MT8173) += mt8173/ + obj-$(CONFIG_SND_SOC_MT8183) += mt8183/ + obj-$(CONFIG_SND_SOC_MT8186) += mt8186/ +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/Makefile +@@ -0,0 +1,8 @@ ++# SPDX-License-Identifier: GPL-2.0 ++ ++# platform driver ++snd-soc-mt7986-afe-objs := \ ++ mt7986-afe-pcm.o \ ++ mt7986-dai-etdm.o ++ ++obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-afe-pcm.c +@@ -0,0 +1,622 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * MediaTek ALSA SoC AFE platform driver for MT7986 ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "mt7986-afe-common.h" ++#include "mt7986-reg.h" ++#include "../common/mtk-afe-platform-driver.h" ++#include "../common/mtk-afe-fe-dai.h" ++ ++enum { ++ MTK_AFE_RATE_8K = 0, ++ MTK_AFE_RATE_11K = 1, ++ MTK_AFE_RATE_12K = 2, ++ MTK_AFE_RATE_16K = 4, ++ MTK_AFE_RATE_22K = 5, ++ MTK_AFE_RATE_24K = 6, ++ MTK_AFE_RATE_32K = 8, ++ MTK_AFE_RATE_44K = 9, ++ MTK_AFE_RATE_48K = 10, ++ MTK_AFE_RATE_88K = 13, ++ MTK_AFE_RATE_96K = 14, ++ MTK_AFE_RATE_176K = 17, ++ MTK_AFE_RATE_192K = 18, ++}; ++ ++enum { ++ CLK_INFRA_AUD_BUS_CK = 0, ++ CLK_INFRA_AUD_26M_CK, ++ CLK_INFRA_AUD_L_CK, ++ CLK_INFRA_AUD_AUD_CK, ++ CLK_INFRA_AUD_EG2_CK, ++ CLK_NUM ++}; ++ ++static const char *aud_clks[CLK_NUM] = { ++ [CLK_INFRA_AUD_BUS_CK] = "aud_bus_ck", ++ [CLK_INFRA_AUD_26M_CK] = "aud_26m_ck", ++ [CLK_INFRA_AUD_L_CK] = "aud_l_ck", ++ [CLK_INFRA_AUD_AUD_CK] = "aud_aud_ck", ++ [CLK_INFRA_AUD_EG2_CK] = "aud_eg2_ck", ++}; ++ ++unsigned int mt7986_afe_rate_transform(struct device *dev, unsigned int rate) ++{ ++ switch (rate) { ++ case 8000: ++ return MTK_AFE_RATE_8K; ++ case 11025: ++ return MTK_AFE_RATE_11K; ++ case 12000: ++ return MTK_AFE_RATE_12K; ++ case 16000: ++ return MTK_AFE_RATE_16K; ++ case 22050: ++ return MTK_AFE_RATE_22K; ++ case 24000: ++ return MTK_AFE_RATE_24K; ++ case 32000: ++ return MTK_AFE_RATE_32K; ++ case 44100: ++ return MTK_AFE_RATE_44K; ++ case 48000: ++ return MTK_AFE_RATE_48K; ++ case 88200: ++ return MTK_AFE_RATE_88K; ++ case 96000: ++ return MTK_AFE_RATE_96K; ++ case 176400: ++ return MTK_AFE_RATE_176K; ++ case 192000: ++ return MTK_AFE_RATE_192K; ++ default: ++ dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n", ++ __func__, rate, MTK_AFE_RATE_48K); ++ return MTK_AFE_RATE_48K; ++ } ++} ++ ++static const struct snd_pcm_hardware mt7986_afe_hardware = { ++ .info = SNDRV_PCM_INFO_MMAP | ++ SNDRV_PCM_INFO_INTERLEAVED | ++ SNDRV_PCM_INFO_MMAP_VALID, ++ .formats = SNDRV_PCM_FMTBIT_S16_LE | ++ SNDRV_PCM_FMTBIT_S24_LE | ++ SNDRV_PCM_FMTBIT_S32_LE, ++ .period_bytes_min = 256, ++ .period_bytes_max = 4 * 48 * 1024, ++ .periods_min = 2, ++ .periods_max = 256, ++ .buffer_bytes_max = 8 * 48 * 1024, ++ .fifo_size = 0, ++}; ++ ++static int mt7986_memif_fs(struct snd_pcm_substream *substream, ++ unsigned int rate) ++{ ++ struct snd_soc_pcm_runtime *rtd = substream->private_data; ++ struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); ++ struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); ++ ++ return mt7986_afe_rate_transform(afe->dev, rate); ++} ++ ++static int mt7986_irq_fs(struct snd_pcm_substream *substream, ++ unsigned int rate) ++{ ++ struct snd_soc_pcm_runtime *rtd = substream->private_data; ++ struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); ++ struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); ++ ++ return mt7986_afe_rate_transform(afe->dev, rate); ++} ++ ++#define MTK_PCM_RATES (SNDRV_PCM_RATE_8000_48000 |\ ++ SNDRV_PCM_RATE_88200 |\ ++ SNDRV_PCM_RATE_96000 |\ ++ SNDRV_PCM_RATE_176400 |\ ++ SNDRV_PCM_RATE_192000) ++ ++#define MTK_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ ++ SNDRV_PCM_FMTBIT_S24_LE |\ ++ SNDRV_PCM_FMTBIT_S32_LE) ++ ++static struct snd_soc_dai_driver mt7986_memif_dai_driver[] = { ++ /* FE DAIs: memory intefaces to CPU */ ++ { ++ .name = "DL1", ++ .id = MT7986_MEMIF_DL1, ++ .playback = { ++ .stream_name = "DL1", ++ .channels_min = 1, ++ .channels_max = 2, ++ .rates = MTK_PCM_RATES, ++ .formats = MTK_PCM_FORMATS, ++ }, ++ .ops = &mtk_afe_fe_ops, ++ }, ++ { ++ .name = "UL1", ++ .id = MT7986_MEMIF_VUL12, ++ .capture = { ++ .stream_name = "UL1", ++ .channels_min = 1, ++ .channels_max = 2, ++ .rates = MTK_PCM_RATES, ++ .formats = MTK_PCM_FORMATS, ++ }, ++ .ops = &mtk_afe_fe_ops, ++ }, ++}; ++ ++static const struct snd_kcontrol_new o018_mix[] = { ++ SOC_DAPM_SINGLE_AUTODISABLE("I150_Switch", AFE_CONN018_4, 22, 1, 0), ++}; ++ ++static const struct snd_kcontrol_new o019_mix[] = { ++ SOC_DAPM_SINGLE_AUTODISABLE("I151_Switch", AFE_CONN019_4, 23, 1, 0), ++}; ++ ++static const struct snd_soc_dapm_widget mt7986_memif_widgets[] = { ++ /* DL */ ++ SND_SOC_DAPM_MIXER("I032", SND_SOC_NOPM, 0, 0, NULL, 0), ++ SND_SOC_DAPM_MIXER("I033", SND_SOC_NOPM, 0, 0, NULL, 0), ++ ++ /* UL */ ++ SND_SOC_DAPM_MIXER("O018", SND_SOC_NOPM, 0, 0, ++ o018_mix, ARRAY_SIZE(o018_mix)), ++ SND_SOC_DAPM_MIXER("O019", SND_SOC_NOPM, 0, 0, ++ o019_mix, ARRAY_SIZE(o019_mix)), ++}; ++ ++static const struct snd_soc_dapm_route mt7986_memif_routes[] = { ++ {"I032", NULL, "DL1"}, ++ {"I033", NULL, "DL1"}, ++ {"UL1", NULL, "O018"}, ++ {"UL1", NULL, "O019"}, ++ {"O018", "I150_Switch", "I150"}, ++ {"O019", "I151_Switch", "I151"}, ++}; ++ ++static const struct snd_soc_component_driver mt7986_afe_pcm_dai_component = { ++ .name = "mt7986-afe-pcm-dai", ++}; ++ ++static const struct mtk_base_memif_data memif_data[MT7986_MEMIF_NUM] = { ++ [MT7986_MEMIF_DL1] = { ++ .name = "DL1", ++ .id = MT7986_MEMIF_DL1, ++ .reg_ofs_base = AFE_DL0_BASE, ++ .reg_ofs_cur = AFE_DL0_CUR, ++ .reg_ofs_end = AFE_DL0_END, ++ .reg_ofs_base_msb = AFE_DL0_BASE_MSB, ++ .reg_ofs_cur_msb = AFE_DL0_CUR_MSB, ++ .reg_ofs_end_msb = AFE_DL0_END_MSB, ++ .fs_reg = AFE_DL0_CON0, ++ .fs_shift = DL0_MODE_SFT, ++ .fs_maskbit = DL0_MODE_MASK, ++ .mono_reg = AFE_DL0_CON0, ++ .mono_shift = DL0_MONO_SFT, ++ .enable_reg = AFE_DL0_CON0, ++ .enable_shift = DL0_ON_SFT, ++ .hd_reg = AFE_DL0_CON0, ++ .hd_shift = DL0_HD_MODE_SFT, ++ .hd_align_reg = AFE_DL0_CON0, ++ .hd_align_mshift = DL0_HALIGN_SFT, ++ .pbuf_reg = AFE_DL0_CON0, ++ .pbuf_shift = DL0_PBUF_SIZE_SFT, ++ .minlen_reg = AFE_DL0_CON0, ++ .minlen_shift = DL0_MINLEN_SFT, ++ }, ++ [MT7986_MEMIF_VUL12] = { ++ .name = "VUL12", ++ .id = MT7986_MEMIF_VUL12, ++ .reg_ofs_base = AFE_VUL0_BASE, ++ .reg_ofs_cur = AFE_VUL0_CUR, ++ .reg_ofs_end = AFE_VUL0_END, ++ .reg_ofs_base_msb = AFE_VUL0_BASE_MSB, ++ .reg_ofs_cur_msb = AFE_VUL0_CUR_MSB, ++ .reg_ofs_end_msb = AFE_VUL0_END_MSB, ++ .fs_reg = AFE_VUL0_CON0, ++ .fs_shift = VUL0_MODE_SFT, ++ .fs_maskbit = VUL0_MODE_MASK, ++ .mono_reg = AFE_VUL0_CON0, ++ .mono_shift = VUL0_MONO_SFT, ++ .enable_reg = AFE_VUL0_CON0, ++ .enable_shift = VUL0_ON_SFT, ++ .hd_reg = AFE_VUL0_CON0, ++ .hd_shift = VUL0_HD_MODE_SFT, ++ .hd_align_reg = AFE_VUL0_CON0, ++ .hd_align_mshift = VUL0_HALIGN_SFT, ++ }, ++}; ++ ++static const struct mtk_base_irq_data irq_data[MT7986_IRQ_NUM] = { ++ [MT7986_IRQ_0] = { ++ .id = MT7986_IRQ_0, ++ .irq_cnt_reg = AFE_IRQ0_MCU_CFG1, ++ .irq_cnt_shift = AFE_IRQ_CNT_SHIFT, ++ .irq_cnt_maskbit = AFE_IRQ_CNT_MASK, ++ .irq_fs_reg = AFE_IRQ0_MCU_CFG0, ++ .irq_fs_shift = IRQ_MCU_MODE_SFT, ++ .irq_fs_maskbit = IRQ_MCU_MODE_MASK, ++ .irq_en_reg = AFE_IRQ0_MCU_CFG0, ++ .irq_en_shift = IRQ_MCU_ON_SFT, ++ .irq_clr_reg = AFE_IRQ_MCU_CLR, ++ .irq_clr_shift = IRQ0_MCU_CLR_SFT, ++ }, ++ [MT7986_IRQ_1] = { ++ .id = MT7986_IRQ_1, ++ .irq_cnt_reg = AFE_IRQ1_MCU_CFG1, ++ .irq_cnt_shift = AFE_IRQ_CNT_SHIFT, ++ .irq_cnt_maskbit = AFE_IRQ_CNT_MASK, ++ .irq_fs_reg = AFE_IRQ1_MCU_CFG0, ++ .irq_fs_shift = IRQ_MCU_MODE_SFT, ++ .irq_fs_maskbit = IRQ_MCU_MODE_MASK, ++ .irq_en_reg = AFE_IRQ1_MCU_CFG0, ++ .irq_en_shift = IRQ_MCU_ON_SFT, ++ .irq_clr_reg = AFE_IRQ_MCU_CLR, ++ .irq_clr_shift = IRQ1_MCU_CLR_SFT, ++ }, ++ [MT7986_IRQ_2] = { ++ .id = MT7986_IRQ_2, ++ .irq_cnt_reg = AFE_IRQ2_MCU_CFG1, ++ .irq_cnt_shift = AFE_IRQ_CNT_SHIFT, ++ .irq_cnt_maskbit = AFE_IRQ_CNT_MASK, ++ .irq_fs_reg = AFE_IRQ2_MCU_CFG0, ++ .irq_fs_shift = IRQ_MCU_MODE_SFT, ++ .irq_fs_maskbit = IRQ_MCU_MODE_MASK, ++ .irq_en_reg = AFE_IRQ2_MCU_CFG0, ++ .irq_en_shift = IRQ_MCU_ON_SFT, ++ .irq_clr_reg = AFE_IRQ_MCU_CLR, ++ .irq_clr_shift = IRQ2_MCU_CLR_SFT, ++ }, ++}; ++ ++static bool mt7986_is_volatile_reg(struct device *dev, unsigned int reg) ++{ ++ /* ++ * Those auto-gen regs are read-only, so put it as volatile because ++ * volatile registers cannot be cached, which means that they cannot ++ * be set when power is off ++ */ ++ ++ switch (reg) { ++ case AFE_DL0_CUR_MSB: ++ case AFE_DL0_CUR: ++ case AFE_DL0_RCH_MON: ++ case AFE_DL0_LCH_MON: ++ case AFE_VUL0_CUR_MSB: ++ case AFE_VUL0_CUR: ++ case AFE_IRQ_MCU_STATUS: ++ case AFE_MEMIF_RD_MON: ++ case AFE_MEMIF_WR_MON: ++ return true; ++ default: ++ return false; ++ }; ++} ++ ++static const struct regmap_config mt7986_afe_regmap_config = { ++ .reg_bits = 32, ++ .reg_stride = 4, ++ .val_bits = 32, ++ .volatile_reg = mt7986_is_volatile_reg, ++ .max_register = AFE_MAX_REGISTER, ++ .num_reg_defaults_raw = ((AFE_MAX_REGISTER / 4) + 1), ++}; ++ ++static int mt7986_init_clock(struct mtk_base_afe *afe) ++{ ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ int ret, i; ++ ++ afe_priv->clks = devm_kcalloc(afe->dev, CLK_NUM, ++ sizeof(*afe_priv->clks), GFP_KERNEL); ++ if (!afe_priv->clks) ++ return -ENOMEM; ++ afe_priv->num_clks = CLK_NUM; ++ ++ for (i = 0; i < afe_priv->num_clks; i++) ++ afe_priv->clks[i].id = aud_clks[i]; ++ ++ ret = devm_clk_bulk_get(afe->dev, afe_priv->num_clks, afe_priv->clks); ++ if (ret) ++ return dev_err_probe(afe->dev, ret, "Failed to get clocks\n"); ++ ++ return 0; ++} ++ ++static irqreturn_t mt7986_afe_irq_handler(int irq_id, void *dev) ++{ ++ struct mtk_base_afe *afe = dev; ++ struct mtk_base_afe_irq *irq; ++ u32 mcu_en, status, status_mcu; ++ int i, ret; ++ irqreturn_t irq_ret = IRQ_HANDLED; ++ ++ /* get irq that is sent to MCU */ ++ regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en); ++ ++ ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status); ++ /* only care IRQ which is sent to MCU */ ++ status_mcu = status & mcu_en & AFE_IRQ_STATUS_BITS; ++ ++ if (ret || status_mcu == 0) { ++ dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n", ++ __func__, ret, status, mcu_en); ++ ++ irq_ret = IRQ_NONE; ++ goto err_irq; ++ } ++ ++ for (i = 0; i < MT7986_MEMIF_NUM; i++) { ++ struct mtk_base_afe_memif *memif = &afe->memif[i]; ++ ++ if (!memif->substream) ++ continue; ++ ++ if (memif->irq_usage < 0) ++ continue; ++ ++ irq = &afe->irqs[memif->irq_usage]; ++ ++ if (status_mcu & (1 << irq->irq_data->irq_en_shift)) ++ snd_pcm_period_elapsed(memif->substream); ++ } ++ ++err_irq: ++ /* clear irq */ ++ regmap_write(afe->regmap, AFE_IRQ_MCU_CLR, status_mcu); ++ ++ return irq_ret; ++} ++ ++static int mt7986_afe_runtime_suspend(struct device *dev) ++{ ++ struct mtk_base_afe *afe = dev_get_drvdata(dev); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ ++ if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) ++ goto skip_regmap; ++ ++ /* disable clk*/ ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON4, 0x3fff, 0x3fff); ++ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_APLL2_EN_MASK, 0); ++ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_26M_EN_MASK, 0); ++ ++ /* make sure all irq status are cleared, twice intended */ ++ regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff); ++ ++skip_regmap: ++ clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks); ++ ++ return 0; ++} ++ ++static int mt7986_afe_runtime_resume(struct device *dev) ++{ ++ struct mtk_base_afe *afe = dev_get_drvdata(dev); ++ struct mt7986_afe_private *afe_priv = afe->platform_priv; ++ int ret; ++ ++ ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks); ++ if (ret) ++ return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n"); ++ ++ if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) ++ return 0; ++ ++ /* enable clk*/ ++ regmap_update_bits(afe->regmap, AUDIO_TOP_CON4, 0x3fff, 0); ++ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_APLL2_EN_MASK, ++ AUD_APLL2_EN); ++ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_26M_EN_MASK, ++ AUD_26M_EN); ++ ++ return 0; ++} ++ ++static int mt7986_afe_component_probe(struct snd_soc_component *component) ++{ ++ return mtk_afe_add_sub_dai_control(component); ++} ++ ++static const struct snd_soc_component_driver mt7986_afe_component = { ++ .name = AFE_PCM_NAME, ++ .probe = mt7986_afe_component_probe, ++ .pointer = mtk_afe_pcm_pointer, ++ .pcm_construct = mtk_afe_pcm_new, ++}; ++ ++static int mt7986_dai_memif_register(struct mtk_base_afe *afe) ++{ ++ struct mtk_base_afe_dai *dai; ++ ++ dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); ++ if (!dai) ++ return -ENOMEM; ++ ++ list_add(&dai->list, &afe->sub_dais); ++ ++ dai->dai_drivers = mt7986_memif_dai_driver; ++ dai->num_dai_drivers = ARRAY_SIZE(mt7986_memif_dai_driver); ++ ++ dai->dapm_widgets = mt7986_memif_widgets; ++ dai->num_dapm_widgets = ARRAY_SIZE(mt7986_memif_widgets); ++ dai->dapm_routes = mt7986_memif_routes; ++ dai->num_dapm_routes = ARRAY_SIZE(mt7986_memif_routes); ++ ++ return 0; ++} ++ ++typedef int (*dai_register_cb)(struct mtk_base_afe *); ++static const dai_register_cb dai_register_cbs[] = { ++ mt7986_dai_etdm_register, ++ mt7986_dai_memif_register, ++}; ++ ++static int mt7986_afe_pcm_dev_probe(struct platform_device *pdev) ++{ ++ struct mtk_base_afe *afe; ++ struct mt7986_afe_private *afe_priv; ++ struct device *dev; ++ int i, irq_id, ret; ++ ++ afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); ++ if (!afe) ++ return -ENOMEM; ++ platform_set_drvdata(pdev, afe); ++ ++ afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), ++ GFP_KERNEL); ++ if (!afe->platform_priv) ++ return -ENOMEM; ++ ++ afe_priv = afe->platform_priv; ++ afe->dev = &pdev->dev; ++ dev = afe->dev; ++ ++ afe->base_addr = devm_platform_ioremap_resource(pdev, 0); ++ if (IS_ERR(afe->base_addr)) ++ return PTR_ERR(afe->base_addr); ++ ++ /* initial audio related clock */ ++ ret = mt7986_init_clock(afe); ++ if (ret) ++ return dev_err_probe(dev, ret, "Cannot initialize clocks\n"); ++ ++ ret = devm_pm_runtime_enable(dev); ++ if (ret) ++ return ret; ++ ++ /* enable clock for regcache get default value from hw */ ++ afe_priv->pm_runtime_bypass_reg_ctl = true; ++ pm_runtime_get_sync(&pdev->dev); ++ ++ afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr, ++ &mt7986_afe_regmap_config); ++ ++ pm_runtime_put_sync(&pdev->dev); ++ if (IS_ERR(afe->regmap)) ++ return PTR_ERR(afe->regmap); ++ ++ afe_priv->pm_runtime_bypass_reg_ctl = false; ++ ++ /* init memif */ ++ afe->memif_size = MT7986_MEMIF_NUM; ++ afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), ++ GFP_KERNEL); ++ if (!afe->memif) ++ return -ENOMEM; ++ ++ for (i = 0; i < afe->memif_size; i++) { ++ afe->memif[i].data = &memif_data[i]; ++ afe->memif[i].irq_usage = -1; ++ } ++ ++ mutex_init(&afe->irq_alloc_lock); ++ ++ /* irq initialize */ ++ afe->irqs_size = MT7986_IRQ_NUM; ++ afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), ++ GFP_KERNEL); ++ if (!afe->irqs) ++ return -ENOMEM; ++ ++ for (i = 0; i < afe->irqs_size; i++) ++ afe->irqs[i].irq_data = &irq_data[i]; ++ ++ /* request irq */ ++ irq_id = platform_get_irq(pdev, 0); ++ if (irq_id < 0) { ++ ret = irq_id; ++ return dev_err_probe(dev, ret, "No irq found\n"); ++ } ++ ret = devm_request_irq(dev, irq_id, mt7986_afe_irq_handler, ++ IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); ++ if (ret) ++ return dev_err_probe(dev, ret, "Failed to request irq for asys-isr\n"); ++ ++ /* init sub_dais */ ++ INIT_LIST_HEAD(&afe->sub_dais); ++ ++ for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) { ++ ret = dai_register_cbs[i](afe); ++ if (ret) ++ return dev_err_probe(dev, ret, "DAI register failed, i: %d\n", i); ++ } ++ ++ /* init dai_driver and component_driver */ ++ ret = mtk_afe_combine_sub_dai(afe); ++ if (ret) ++ return dev_err_probe(dev, ret, "mtk_afe_combine_sub_dai fail\n"); ++ ++ afe->mtk_afe_hardware = &mt7986_afe_hardware; ++ afe->memif_fs = mt7986_memif_fs; ++ afe->irq_fs = mt7986_irq_fs; ++ ++ afe->runtime_resume = mt7986_afe_runtime_resume; ++ afe->runtime_suspend = mt7986_afe_runtime_suspend; ++ ++ /* register component */ ++ ret = devm_snd_soc_register_component(&pdev->dev, ++ &mt7986_afe_component, ++ NULL, 0); ++ if (ret) ++ return dev_err_probe(dev, ret, "Cannot register AFE component\n"); ++ ++ ret = devm_snd_soc_register_component(afe->dev, ++ &mt7986_afe_pcm_dai_component, ++ afe->dai_drivers, ++ afe->num_dai_drivers); ++ if (ret) ++ return dev_err_probe(dev, ret, "Cannot register PCM DAI component\n"); ++ ++ return 0; ++} ++ ++static void mt7986_afe_pcm_dev_remove(struct platform_device *pdev) ++{ ++ pm_runtime_disable(&pdev->dev); ++ if (!pm_runtime_status_suspended(&pdev->dev)) ++ mt7986_afe_runtime_suspend(&pdev->dev); ++} ++ ++static const struct of_device_id mt7986_afe_pcm_dt_match[] = { ++ { .compatible = "mediatek,mt7986-afe" }, ++ { /* sentinel */ } ++}; ++MODULE_DEVICE_TABLE(of, mt7986_afe_pcm_dt_match); ++ ++static const struct dev_pm_ops mt7986_afe_pm_ops = { ++ SET_RUNTIME_PM_OPS(mt7986_afe_runtime_suspend, ++ mt7986_afe_runtime_resume, NULL) ++}; ++ ++static struct platform_driver mt7986_afe_pcm_driver = { ++ .driver = { ++ .name = "mt7986-audio", ++ .of_match_table = mt7986_afe_pcm_dt_match, ++ .pm = &mt7986_afe_pm_ops, ++ }, ++ .probe = mt7986_afe_pcm_dev_probe, ++ .remove_new = mt7986_afe_pcm_dev_remove, ++}; ++module_platform_driver(mt7986_afe_pcm_driver); ++ ++MODULE_DESCRIPTION("MediaTek SoC AFE platform driver for ALSA MT7986"); ++MODULE_AUTHOR("Vic Wu "); ++MODULE_LICENSE("GPL"); diff --git a/target/linux/mediatek/patches-6.1/860-v6.6-04-ASoC-mediatek-mt7986-add-machine-driver-with-wm8960.patch b/target/linux/mediatek/patches-6.1/860-v6.6-04-ASoC-mediatek-mt7986-add-machine-driver-with-wm8960.patch new file mode 100644 index 0000000000..dd354c04e3 --- /dev/null +++ b/target/linux/mediatek/patches-6.1/860-v6.6-04-ASoC-mediatek-mt7986-add-machine-driver-with-wm8960.patch @@ -0,0 +1,243 @@ +From ddf6abc1c78072f8ccad59166be95f0ca5af8ca4 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:36 +0800 +Subject: [PATCH 4/9] ASoC: mediatek: mt7986: add machine driver with wm8960 + +Add support for mt7986 board with wm8960. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-5-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/Kconfig | 10 ++ + sound/soc/mediatek/mt7986/Makefile | 1 + + sound/soc/mediatek/mt7986/mt7986-wm8960.c | 196 ++++++++++++++++++++++ + 3 files changed, 207 insertions(+) + create mode 100644 sound/soc/mediatek/mt7986/mt7986-wm8960.c + +--- a/sound/soc/mediatek/Kconfig ++++ b/sound/soc/mediatek/Kconfig +@@ -64,6 +64,16 @@ config SND_SOC_MT7986 + Select Y if you have such device. + If unsure select "N". + ++config SND_SOC_MT7986_WM8960 ++ tristate "ASoc Audio driver for MT7986 with WM8960 codec" ++ depends on SND_SOC_MT7986 && I2C ++ select SND_SOC_WM8960 ++ help ++ This adds support for ASoC machine driver for MediaTek MT7986 ++ boards with the WM8960 codecs. ++ Select Y if you have such device. ++ If unsure select "N". ++ + config SND_SOC_MT8173 + tristate "ASoC support for Mediatek MT8173 chip" + depends on ARCH_MEDIATEK +--- a/sound/soc/mediatek/mt7986/Makefile ++++ b/sound/soc/mediatek/mt7986/Makefile +@@ -6,3 +6,4 @@ snd-soc-mt7986-afe-objs := \ + mt7986-dai-etdm.o + + obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o ++obj-$(CONFIG_SND_SOC_MT7986_WM8960) += mt7986-wm8960.o +--- /dev/null ++++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c +@@ -0,0 +1,196 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * mt7986-wm8960.c -- MT7986-WM8960 ALSA SoC machine driver ++ * ++ * Copyright (c) 2023 MediaTek Inc. ++ * Authors: Vic Wu ++ * Maso Huang ++ */ ++ ++#include ++#include ++ ++#include "mt7986-afe-common.h" ++ ++struct mt7986_wm8960_priv { ++ struct device_node *platform_node; ++ struct device_node *codec_node; ++}; ++ ++static const struct snd_soc_dapm_widget mt7986_wm8960_widgets[] = { ++ SND_SOC_DAPM_HP("Headphone", NULL), ++ SND_SOC_DAPM_MIC("AMIC", NULL), ++}; ++ ++static const struct snd_kcontrol_new mt7986_wm8960_controls[] = { ++ SOC_DAPM_PIN_SWITCH("Headphone"), ++ SOC_DAPM_PIN_SWITCH("AMIC"), ++}; ++ ++SND_SOC_DAILINK_DEFS(playback, ++ DAILINK_COMP_ARRAY(COMP_CPU("DL1")), ++ DAILINK_COMP_ARRAY(COMP_DUMMY()), ++ DAILINK_COMP_ARRAY(COMP_EMPTY())); ++ ++SND_SOC_DAILINK_DEFS(capture, ++ DAILINK_COMP_ARRAY(COMP_CPU("UL1")), ++ DAILINK_COMP_ARRAY(COMP_DUMMY()), ++ DAILINK_COMP_ARRAY(COMP_EMPTY())); ++ ++SND_SOC_DAILINK_DEFS(codec, ++ DAILINK_COMP_ARRAY(COMP_CPU("ETDM")), ++ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8960-hifi")), ++ DAILINK_COMP_ARRAY(COMP_EMPTY())); ++ ++static struct snd_soc_dai_link mt7986_wm8960_dai_links[] = { ++ /* FE */ ++ { ++ .name = "wm8960-playback", ++ .stream_name = "wm8960-playback", ++ .trigger = {SND_SOC_DPCM_TRIGGER_POST, ++ SND_SOC_DPCM_TRIGGER_POST}, ++ .dynamic = 1, ++ .dpcm_playback = 1, ++ SND_SOC_DAILINK_REG(playback), ++ }, ++ { ++ .name = "wm8960-capture", ++ .stream_name = "wm8960-capture", ++ .trigger = {SND_SOC_DPCM_TRIGGER_POST, ++ SND_SOC_DPCM_TRIGGER_POST}, ++ .dynamic = 1, ++ .dpcm_capture = 1, ++ SND_SOC_DAILINK_REG(capture), ++ }, ++ /* BE */ ++ { ++ .name = "wm8960-codec", ++ .no_pcm = 1, ++ .dai_fmt = SND_SOC_DAIFMT_I2S | ++ SND_SOC_DAIFMT_NB_NF | ++ SND_SOC_DAIFMT_CBS_CFS | ++ SND_SOC_DAIFMT_GATED, ++ .dpcm_playback = 1, ++ .dpcm_capture = 1, ++ SND_SOC_DAILINK_REG(codec), ++ }, ++}; ++ ++static struct snd_soc_card mt7986_wm8960_card = { ++ .name = "mt7986-wm8960", ++ .owner = THIS_MODULE, ++ .dai_link = mt7986_wm8960_dai_links, ++ .num_links = ARRAY_SIZE(mt7986_wm8960_dai_links), ++ .controls = mt7986_wm8960_controls, ++ .num_controls = ARRAY_SIZE(mt7986_wm8960_controls), ++ .dapm_widgets = mt7986_wm8960_widgets, ++ .num_dapm_widgets = ARRAY_SIZE(mt7986_wm8960_widgets), ++}; ++ ++static int mt7986_wm8960_machine_probe(struct platform_device *pdev) ++{ ++ struct snd_soc_card *card = &mt7986_wm8960_card; ++ struct snd_soc_dai_link *dai_link; ++ struct device_node *platform, *codec; ++ struct mt7986_wm8960_priv *priv; ++ int ret, i; ++ ++ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ platform = of_get_child_by_name(pdev->dev.of_node, "platform"); ++ ++ if (platform) { ++ priv->platform_node = of_parse_phandle(platform, "sound-dai", 0); ++ of_node_put(platform); ++ ++ if (!priv->platform_node) { ++ dev_err(&pdev->dev, "Failed to parse platform/sound-dai property\n"); ++ return -EINVAL; ++ } ++ } else { ++ dev_err(&pdev->dev, "Property 'platform' missing or invalid\n"); ++ return -EINVAL; ++ } ++ ++ for_each_card_prelinks(card, i, dai_link) { ++ if (dai_link->platforms->name) ++ continue; ++ dai_link->platforms->of_node = priv->platform_node; ++ } ++ ++ card->dev = &pdev->dev; ++ ++ codec = of_get_child_by_name(pdev->dev.of_node, "codec"); ++ ++ if (codec) { ++ priv->codec_node = of_parse_phandle(codec, "sound-dai", 0); ++ of_node_put(codec); ++ ++ if (!priv->codec_node) { ++ of_node_put(priv->platform_node); ++ dev_err(&pdev->dev, "Failed to parse codec/sound-dai property\n"); ++ return -EINVAL; ++ } ++ } else { ++ of_node_put(priv->platform_node); ++ dev_err(&pdev->dev, "Property 'codec' missing or invalid\n"); ++ return -EINVAL; ++ } ++ ++ for_each_card_prelinks(card, i, dai_link) { ++ if (dai_link->codecs->name) ++ continue; ++ dai_link->codecs->of_node = priv->codec_node; ++ } ++ ++ ret = snd_soc_of_parse_audio_routing(card, "audio-routing"); ++ if (ret) { ++ dev_err(&pdev->dev, "Failed to parse audio-routing: %d\n", ret); ++ goto err_of_node_put; ++ } ++ ++ ret = devm_snd_soc_register_card(&pdev->dev, card); ++ if (ret) { ++ dev_err(&pdev->dev, "%s snd_soc_register_card fail: %d\n", __func__, ret); ++ goto err_of_node_put; ++ } ++ ++err_of_node_put: ++ of_node_put(priv->codec_node); ++ of_node_put(priv->platform_node); ++ return ret; ++} ++ ++static void mt7986_wm8960_machine_remove(struct platform_device *pdev) ++{ ++ struct snd_soc_card *card = platform_get_drvdata(pdev); ++ struct mt7986_wm8960_priv *priv = snd_soc_card_get_drvdata(card); ++ ++ of_node_put(priv->codec_node); ++ of_node_put(priv->platform_node); ++} ++ ++static const struct of_device_id mt7986_wm8960_machine_dt_match[] = { ++ {.compatible = "mediatek,mt7986-wm8960-sound"}, ++ { /* sentinel */ } ++}; ++MODULE_DEVICE_TABLE(of, mt7986_wm8960_machine_dt_match); ++ ++static struct platform_driver mt7986_wm8960_machine = { ++ .driver = { ++ .name = "mt7986-wm8960", ++ .of_match_table = mt7986_wm8960_machine_dt_match, ++ }, ++ .probe = mt7986_wm8960_machine_probe, ++ .remove_new = mt7986_wm8960_machine_remove, ++}; ++ ++module_platform_driver(mt7986_wm8960_machine); ++ ++/* Module information */ ++MODULE_DESCRIPTION("MT7986 WM8960 ALSA SoC machine driver"); ++MODULE_AUTHOR("Vic Wu "); ++MODULE_LICENSE("GPL"); ++MODULE_ALIAS("mt7986 wm8960 soc card"); diff --git a/target/linux/mediatek/patches-6.1/860-v6.6-05-ASoC-dt-bindings-mediatek-mt7986-wm8960-add-mt7986-w.patch b/target/linux/mediatek/patches-6.1/860-v6.6-05-ASoC-dt-bindings-mediatek-mt7986-wm8960-add-mt7986-w.patch new file mode 100644 index 0000000000..8cf0b5464a --- /dev/null +++ b/target/linux/mediatek/patches-6.1/860-v6.6-05-ASoC-dt-bindings-mediatek-mt7986-wm8960-add-mt7986-w.patch @@ -0,0 +1,87 @@ +From 72469f950b629e57e60fbcbefed45e083619b986 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:37 +0800 +Subject: [PATCH 5/9] ASoC: dt-bindings: mediatek,mt7986-wm8960: add + mt7986-wm8960 document + +Add document for mt7986 board with wm8960. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-6-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + .../sound/mediatek,mt7986-wm8960.yaml | 67 +++++++++++++++++++ + 1 file changed, 67 insertions(+) + create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml + +--- /dev/null ++++ b/Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml +@@ -0,0 +1,67 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: MediaTek MT7986 sound card with WM8960 codec ++ ++maintainers: ++ - Maso Huang ++ ++allOf: ++ - $ref: sound-card-common.yaml# ++ ++properties: ++ compatible: ++ const: mediatek,mt7986-wm8960-sound ++ ++ platform: ++ type: object ++ additionalProperties: false ++ properties: ++ sound-dai: ++ description: The phandle of MT7986 platform. ++ maxItems: 1 ++ required: ++ - sound-dai ++ ++ codec: ++ type: object ++ additionalProperties: false ++ properties: ++ sound-dai: ++ description: The phandle of wm8960 codec. ++ maxItems: 1 ++ required: ++ - sound-dai ++ ++unevaluatedProperties: false ++ ++required: ++ - compatible ++ - audio-routing ++ - platform ++ - codec ++ ++examples: ++ - | ++ sound { ++ compatible = "mediatek,mt7986-wm8960-sound"; ++ model = "mt7986-wm8960"; ++ audio-routing = ++ "Headphone", "HP_L", ++ "Headphone", "HP_R", ++ "LINPUT1", "AMIC", ++ "RINPUT1", "AMIC"; ++ ++ platform { ++ sound-dai = <&afe>; ++ }; ++ ++ codec { ++ sound-dai = <&wm8960>; ++ }; ++ }; ++ ++... diff --git a/target/linux/mediatek/patches-6.1/860-v6.6-06-ASoC-dt-bindings-mediatek-mt7986-afe-add-audio-afe-d.patch b/target/linux/mediatek/patches-6.1/860-v6.6-06-ASoC-dt-bindings-mediatek-mt7986-afe-add-audio-afe-d.patch new file mode 100644 index 0000000000..236d6a217c --- /dev/null +++ b/target/linux/mediatek/patches-6.1/860-v6.6-06-ASoC-dt-bindings-mediatek-mt7986-afe-add-audio-afe-d.patch @@ -0,0 +1,180 @@ +From d16202eb38585adbc16e32d11188dbc2127015de Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 17 Aug 2023 18:13:38 +0800 +Subject: [PATCH 6/9] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe + document + +Add mt7986 audio afe document. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230817101338.18782-7-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + .../bindings/sound/mediatek,mt7986-afe.yaml | 160 ++++++++++++++++++ + 1 file changed, 160 insertions(+) + create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml + +--- /dev/null ++++ b/Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml +@@ -0,0 +1,160 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/sound/mediatek,mt7986-afe.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: MediaTek AFE PCM controller for MT7986 ++ ++maintainers: ++ - Maso Huang ++ ++properties: ++ compatible: ++ oneOf: ++ - const: mediatek,mt7986-afe ++ - items: ++ - enum: ++ - mediatek,mt7981-afe ++ - mediatek,mt7988-afe ++ - const: mediatek,mt7986-afe ++ ++ reg: ++ maxItems: 1 ++ ++ interrupts: ++ maxItems: 1 ++ ++ clocks: ++ minItems: 5 ++ items: ++ - description: audio bus clock ++ - description: audio 26M clock ++ - description: audio intbus clock ++ - description: audio hopping clock ++ - description: audio pll clock ++ - description: mux for pcm_mck ++ - description: audio i2s/pcm mck ++ ++ clock-names: ++ minItems: 5 ++ items: ++ - const: bus_ck ++ - const: 26m_ck ++ - const: l_ck ++ - const: aud_ck ++ - const: eg2_ck ++ - const: sel ++ - const: i2s_m ++ ++required: ++ - compatible ++ - reg ++ - interrupts ++ - clocks ++ - clock-names ++ ++allOf: ++ - if: ++ properties: ++ compatible: ++ contains: ++ const: mediatek,mt7986-afe ++ then: ++ properties: ++ clocks: ++ items: ++ - description: audio bus clock ++ - description: audio 26M clock ++ - description: audio intbus clock ++ - description: audio hopping clock ++ - description: audio pll clock ++ clock-names: ++ items: ++ - const: bus_ck ++ - const: 26m_ck ++ - const: l_ck ++ - const: aud_ck ++ - const: eg2_ck ++ ++ - if: ++ properties: ++ compatible: ++ contains: ++ const: mediatek,mt7981-afe ++ then: ++ properties: ++ clocks: ++ items: ++ - description: audio bus clock ++ - description: audio 26M clock ++ - description: audio intbus clock ++ - description: audio hopping clock ++ - description: audio pll clock ++ - description: mux for pcm_mck ++ clock-names: ++ items: ++ - const: bus_ck ++ - const: 26m_ck ++ - const: l_ck ++ - const: aud_ck ++ - const: eg2_ck ++ - const: sel ++ ++ - if: ++ properties: ++ compatible: ++ contains: ++ const: mediatek,mt7988-afe ++ then: ++ properties: ++ clocks: ++ items: ++ - description: audio bus clock ++ - description: audio 26M clock ++ - description: audio intbus clock ++ - description: audio hopping clock ++ - description: audio pll clock ++ - description: mux for pcm_mck ++ - description: audio i2s/pcm mck ++ clock-names: ++ items: ++ - const: bus_ck ++ - const: 26m_ck ++ - const: l_ck ++ - const: aud_ck ++ - const: eg2_ck ++ - const: sel ++ - const: i2s_m ++ ++additionalProperties: false ++ ++examples: ++ - | ++ #include ++ #include ++ #include ++ ++ afe@11210000 { ++ compatible = "mediatek,mt7986-afe"; ++ reg = <0x11210000 0x9000>; ++ interrupts = ; ++ clocks = <&infracfg_ao CLK_INFRA_AUD_BUS_CK>, ++ <&infracfg_ao CLK_INFRA_AUD_26M_CK>, ++ <&infracfg_ao CLK_INFRA_AUD_L_CK>, ++ <&infracfg_ao CLK_INFRA_AUD_AUD_CK>, ++ <&infracfg_ao CLK_INFRA_AUD_EG2_CK>; ++ clock-names = "bus_ck", ++ "26m_ck", ++ "l_ck", ++ "aud_ck", ++ "eg2_ck"; ++ assigned-clocks = <&topckgen CLK_TOP_A1SYS_SEL>, ++ <&topckgen CLK_TOP_AUD_L_SEL>, ++ <&topckgen CLK_TOP_A_TUNER_SEL>; ++ assigned-clock-parents = <&topckgen CLK_TOP_APLL2_D4>, ++ <&apmixedsys CLK_APMIXED_APLL2>, ++ <&topckgen CLK_TOP_APLL2_D4>; ++ }; ++ ++... diff --git a/target/linux/mediatek/patches-6.1/860-v6.7-07-ASoC-mediatek-mt7986-drop-the-remove-callback-of-mt7.patch b/target/linux/mediatek/patches-6.1/860-v6.7-07-ASoC-mediatek-mt7986-drop-the-remove-callback-of-mt7.patch new file mode 100644 index 0000000000..413db8233f --- /dev/null +++ b/target/linux/mediatek/patches-6.1/860-v6.7-07-ASoC-mediatek-mt7986-drop-the-remove-callback-of-mt7.patch @@ -0,0 +1,42 @@ +From f3f0934e5c7b9c16e0cb2435be3555382e6293ad Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Tue, 24 Oct 2023 11:50:17 +0800 +Subject: [PATCH 7/9] ASoC: mediatek: mt7986: drop the remove callback of + mt7986_wm8960 + +Drop the remove callback of mt7986_wm8960. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20231024035019.11732-2-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-wm8960.c | 10 ---------- + 1 file changed, 10 deletions(-) + +--- a/sound/soc/mediatek/mt7986/mt7986-wm8960.c ++++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c +@@ -163,15 +163,6 @@ err_of_node_put: + return ret; + } + +-static void mt7986_wm8960_machine_remove(struct platform_device *pdev) +-{ +- struct snd_soc_card *card = platform_get_drvdata(pdev); +- struct mt7986_wm8960_priv *priv = snd_soc_card_get_drvdata(card); +- +- of_node_put(priv->codec_node); +- of_node_put(priv->platform_node); +-} +- + static const struct of_device_id mt7986_wm8960_machine_dt_match[] = { + {.compatible = "mediatek,mt7986-wm8960-sound"}, + { /* sentinel */ } +@@ -184,7 +175,6 @@ static struct platform_driver mt7986_wm8 + .of_match_table = mt7986_wm8960_machine_dt_match, + }, + .probe = mt7986_wm8960_machine_probe, +- .remove_new = mt7986_wm8960_machine_remove, + }; + + module_platform_driver(mt7986_wm8960_machine); diff --git a/target/linux/mediatek/patches-6.1/860-v6.7-08-ASoC-mediatek-mt7986-remove-the-mt7986_wm8960_priv-s.patch b/target/linux/mediatek/patches-6.1/860-v6.7-08-ASoC-mediatek-mt7986-remove-the-mt7986_wm8960_priv-s.patch new file mode 100644 index 0000000000..5c596fc49c --- /dev/null +++ b/target/linux/mediatek/patches-6.1/860-v6.7-08-ASoC-mediatek-mt7986-remove-the-mt7986_wm8960_priv-s.patch @@ -0,0 +1,105 @@ +From 98b8fb2cb4fcab1903d0baf611bf0c3f822a08dc Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Tue, 24 Oct 2023 11:50:18 +0800 +Subject: [PATCH 8/9] ASoC: mediatek: mt7986: remove the mt7986_wm8960_priv + structure + +Remove the mt7986_wm8960_priv structure. + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20231024035019.11732-3-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-wm8960.c | 33 +++++++++-------------- + 1 file changed, 12 insertions(+), 21 deletions(-) + +--- a/sound/soc/mediatek/mt7986/mt7986-wm8960.c ++++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c +@@ -12,11 +12,6 @@ + + #include "mt7986-afe-common.h" + +-struct mt7986_wm8960_priv { +- struct device_node *platform_node; +- struct device_node *codec_node; +-}; +- + static const struct snd_soc_dapm_widget mt7986_wm8960_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_MIC("AMIC", NULL), +@@ -92,20 +87,18 @@ static int mt7986_wm8960_machine_probe(s + struct snd_soc_card *card = &mt7986_wm8960_card; + struct snd_soc_dai_link *dai_link; + struct device_node *platform, *codec; +- struct mt7986_wm8960_priv *priv; ++ struct device_node *platform_dai_node, *codec_dai_node; + int ret, i; + +- priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); +- if (!priv) +- return -ENOMEM; ++ card->dev = &pdev->dev; + + platform = of_get_child_by_name(pdev->dev.of_node, "platform"); + + if (platform) { +- priv->platform_node = of_parse_phandle(platform, "sound-dai", 0); ++ platform_dai_node = of_parse_phandle(platform, "sound-dai", 0); + of_node_put(platform); + +- if (!priv->platform_node) { ++ if (!platform_dai_node) { + dev_err(&pdev->dev, "Failed to parse platform/sound-dai property\n"); + return -EINVAL; + } +@@ -117,24 +110,22 @@ static int mt7986_wm8960_machine_probe(s + for_each_card_prelinks(card, i, dai_link) { + if (dai_link->platforms->name) + continue; +- dai_link->platforms->of_node = priv->platform_node; ++ dai_link->platforms->of_node = platform_dai_node; + } + +- card->dev = &pdev->dev; +- + codec = of_get_child_by_name(pdev->dev.of_node, "codec"); + + if (codec) { +- priv->codec_node = of_parse_phandle(codec, "sound-dai", 0); ++ codec_dai_node = of_parse_phandle(codec, "sound-dai", 0); + of_node_put(codec); + +- if (!priv->codec_node) { +- of_node_put(priv->platform_node); ++ if (!codec_dai_node) { ++ of_node_put(platform_dai_node); + dev_err(&pdev->dev, "Failed to parse codec/sound-dai property\n"); + return -EINVAL; + } + } else { +- of_node_put(priv->platform_node); ++ of_node_put(platform_dai_node); + dev_err(&pdev->dev, "Property 'codec' missing or invalid\n"); + return -EINVAL; + } +@@ -142,7 +133,7 @@ static int mt7986_wm8960_machine_probe(s + for_each_card_prelinks(card, i, dai_link) { + if (dai_link->codecs->name) + continue; +- dai_link->codecs->of_node = priv->codec_node; ++ dai_link->codecs->of_node = codec_dai_node; + } + + ret = snd_soc_of_parse_audio_routing(card, "audio-routing"); +@@ -158,8 +149,8 @@ static int mt7986_wm8960_machine_probe(s + } + + err_of_node_put: +- of_node_put(priv->codec_node); +- of_node_put(priv->platform_node); ++ of_node_put(platform_dai_node); ++ of_node_put(codec_dai_node); + return ret; + } + diff --git a/target/linux/mediatek/patches-6.1/860-v6.7-09-ASoC-mediatek-mt7986-add-sample-rate-checker.patch b/target/linux/mediatek/patches-6.1/860-v6.7-09-ASoC-mediatek-mt7986-add-sample-rate-checker.patch new file mode 100644 index 0000000000..d4128deabc --- /dev/null +++ b/target/linux/mediatek/patches-6.1/860-v6.7-09-ASoC-mediatek-mt7986-add-sample-rate-checker.patch @@ -0,0 +1,49 @@ +From 4e229f4264f4be7a6a554487714c0913ef59cf7f Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Tue, 24 Oct 2023 11:50:19 +0800 +Subject: [PATCH 9/9] ASoC: mediatek: mt7986: add sample rate checker + +mt7986 only supports 8/12/16/24/32/48/96/192 kHz + +Signed-off-by: Maso Huang +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20231024035019.11732-4-maso.huang@mediatek.com +Signed-off-by: Mark Brown +--- + sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 23 +++++++++++++++++---- + 1 file changed, 19 insertions(+), 4 deletions(-) + +--- a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c ++++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c +@@ -237,12 +237,27 @@ static int mtk_dai_etdm_hw_params(struct + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) + { ++ unsigned int rate = params_rate(params); + struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + +- mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); +- mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); +- +- return 0; ++ switch (rate) { ++ case 8000: ++ case 12000: ++ case 16000: ++ case 24000: ++ case 32000: ++ case 48000: ++ case 96000: ++ case 192000: ++ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); ++ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); ++ return 0; ++ default: ++ dev_err(afe->dev, ++ "Sample rate %d invalid. Supported rates: 8/12/16/24/32/48/96/192 kHz\n", ++ rate); ++ return -EINVAL; ++ } + } + + static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd, diff --git a/target/linux/mediatek/patches-6.1/861-pending-10-ASoC-mediatek-mt7986-silence-error-in-case-of-EPROBE.patch b/target/linux/mediatek/patches-6.1/861-pending-10-ASoC-mediatek-mt7986-silence-error-in-case-of-EPROBE.patch new file mode 100644 index 0000000000..a40c249257 --- /dev/null +++ b/target/linux/mediatek/patches-6.1/861-pending-10-ASoC-mediatek-mt7986-silence-error-in-case-of-EPROBE.patch @@ -0,0 +1,26 @@ +From e4cde335d1771863a60b6931e51357b8470e85c4 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sun, 10 Dec 2023 22:41:39 +0000 +Subject: [PATCH] ASoC: mediatek: mt7986: silence error in case of + -EPROBE_DEFER + +If probe is defered no error should be printed. Mute it. + +Signed-off-by: Daniel Golle +--- + sound/soc/mediatek/mt7986/mt7986-wm8960.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/sound/soc/mediatek/mt7986/mt7986-wm8960.c ++++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c +@@ -144,7 +144,9 @@ static int mt7986_wm8960_machine_probe(s + + ret = devm_snd_soc_register_card(&pdev->dev, card); + if (ret) { +- dev_err(&pdev->dev, "%s snd_soc_register_card fail: %d\n", __func__, ret); ++ if (ret != -EPROBE_DEFER) ++ dev_err(&pdev->dev, "%s snd_soc_register_card fail: %d\n", __func__, ret); ++ + goto err_of_node_put; + } + diff --git a/target/linux/mediatek/patches-6.1/862-arm64-dts-mt7986-add-afe.patch b/target/linux/mediatek/patches-6.1/862-arm64-dts-mt7986-add-afe.patch new file mode 100644 index 0000000000..b31710fe69 --- /dev/null +++ b/target/linux/mediatek/patches-6.1/862-arm64-dts-mt7986-add-afe.patch @@ -0,0 +1,40 @@ +From 1c09b694a1e9378931085e77d834a4d9786a5356 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 7 Sep 2023 10:54:37 +0800 +Subject: [PATCH] arm64: dts: mt7986: add afe + +--- + arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 23 +++++++++++ + 1 files changed, 23 insertions(+) + +--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi ++++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi +@@ -248,6 +248,28 @@ + status = "disabled"; + }; + ++ afe: audio-controller@11210000 { ++ compatible = "mediatek,mt7986-afe"; ++ reg = <0 0x11210000 0 0x9000>; ++ interrupts = ; ++ clocks = <&infracfg CLK_INFRA_AUD_BUS_CK>, ++ <&infracfg CLK_INFRA_AUD_26M_CK>, ++ <&infracfg CLK_INFRA_AUD_L_CK>, ++ <&infracfg CLK_INFRA_AUD_AUD_CK>, ++ <&infracfg CLK_INFRA_AUD_EG2_CK>; ++ clock-names = "aud_bus_ck", ++ "aud_26m_ck", ++ "aud_l_ck", ++ "aud_aud_ck", ++ "aud_eg2_ck"; ++ assigned-clocks = <&topckgen CLK_TOP_A1SYS_SEL>, ++ <&topckgen CLK_TOP_AUD_L_SEL>, ++ <&topckgen CLK_TOP_A_TUNER_SEL>; ++ assigned-clock-parents = <&topckgen CLK_TOP_APLL2_D4>, ++ <&apmixedsys CLK_APMIXED_APLL2>, ++ <&topckgen CLK_TOP_APLL2_D4>; ++ }; ++ + pwm: pwm@10048000 { + compatible = "mediatek,mt7986-pwm"; + reg = <0 0x10048000 0 0x1000>; diff --git a/target/linux/mediatek/patches-6.1/863-arm64-dts-mt7986-add-sound-wm8960.patch b/target/linux/mediatek/patches-6.1/863-arm64-dts-mt7986-add-sound-wm8960.patch new file mode 100644 index 0000000000..15e30dec56 --- /dev/null +++ b/target/linux/mediatek/patches-6.1/863-arm64-dts-mt7986-add-sound-wm8960.patch @@ -0,0 +1,61 @@ +From 1c09b694a1e9378931085e77d834a4d9786a5356 Mon Sep 17 00:00:00 2001 +From: Maso Huang +Date: Thu, 7 Sep 2023 10:54:37 +0800 +Subject: [PATCH] arm64: dts: mt7986: add sound wm8960 + +--- + .../dts/mediatek/mt7986a-rfb-spim-nand.dts | 39 +++++++++++++++++++ + 1 files changed, 39 insertions(+) + +--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb-spim-nand.dts ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb-spim-nand.dts +@@ -4,6 +4,35 @@ + + / { + compatible = "mediatek,mt7986a-rfb-snand"; ++ ++ sound_wm8960 { ++ compatible = "mediatek,mt7986-wm8960-sound"; ++ audio-routing = "Headphone", "HP_L", ++ "Headphone", "HP_R", ++ "LINPUT1", "AMIC", ++ "RINPUT1", "AMIC"; ++ ++ status = "okay"; ++ ++ platform { ++ sound-dai = <&afe>; ++ }; ++ ++ codec { ++ sound-dai = <&wm8960>; ++ }; ++ }; ++}; ++ ++&i2c0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c_pins>; ++ status = "okay"; ++ ++ wm8960: wm8960@1a { ++ compatible = "wlf,wm8960"; ++ reg = <0x1a>; ++ }; + }; + + &spi0 { +@@ -50,3 +79,13 @@ + &wifi { + mediatek,mtd-eeprom = <&factory 0>; + }; ++ ++&pio { ++ i2c_pins: i2c-pins-3-4 { ++ mux { ++ function = "i2c"; ++ groups = "i2c"; ++ }; ++ }; ++}; ++ diff --git a/target/linux/mediatek/patches-6.1/941-arm64-dts-mt7986-move-cpuboot-in-a-dedicated-node.patch b/target/linux/mediatek/patches-6.1/941-arm64-dts-mt7986-move-cpuboot-in-a-dedicated-node.patch index 0a58ae953b..3ba485346c 100644 --- a/target/linux/mediatek/patches-6.1/941-arm64-dts-mt7986-move-cpuboot-in-a-dedicated-node.patch +++ b/target/linux/mediatek/patches-6.1/941-arm64-dts-mt7986-move-cpuboot-in-a-dedicated-node.patch @@ -24,7 +24,7 @@ Signed-off-by: Lorenzo Bianconi }; timer { -@@ -518,10 +512,11 @@ +@@ -540,10 +534,11 @@ interrupt-parent = <&gic>; interrupts = ; memory-region = <&wo_emi0>, <&wo_ilm0>, <&wo_dlm0>, @@ -38,7 +38,7 @@ Signed-off-by: Lorenzo Bianconi }; wed1: wed@15011000 { -@@ -531,10 +526,11 @@ +@@ -553,10 +548,11 @@ interrupt-parent = <&gic>; interrupts = ; memory-region = <&wo_emi1>, <&wo_ilm1>, <&wo_dlm1>, @@ -52,7 +52,7 @@ Signed-off-by: Lorenzo Bianconi }; wo_ccif0: syscon@151a5000 { -@@ -551,6 +547,11 @@ +@@ -573,6 +569,11 @@ interrupts = ; }; diff --git a/target/linux/mediatek/patches-6.1/945-arm64-dts-mt7986-move-ilm-in-a-dedicated-node.patch b/target/linux/mediatek/patches-6.1/945-arm64-dts-mt7986-move-ilm-in-a-dedicated-node.patch index 36fe927837..0ba9bd7cf0 100644 --- a/target/linux/mediatek/patches-6.1/945-arm64-dts-mt7986-move-ilm-in-a-dedicated-node.patch +++ b/target/linux/mediatek/patches-6.1/945-arm64-dts-mt7986-move-ilm-in-a-dedicated-node.patch @@ -34,7 +34,7 @@ Signed-off-by: Lorenzo Bianconi wo_data: wo-data@4fd80000 { reg = <0 0x4fd80000 0 0x240000>; no-map; -@@ -511,11 +501,10 @@ +@@ -533,11 +523,10 @@ reg = <0 0x15010000 0 0x1000>; interrupt-parent = <&gic>; interrupts = ; @@ -49,7 +49,7 @@ Signed-off-by: Lorenzo Bianconi mediatek,wo-cpuboot = <&wo_cpuboot>; }; -@@ -525,11 +514,10 @@ +@@ -547,11 +536,10 @@ reg = <0 0x15011000 0 0x1000>; interrupt-parent = <&gic>; interrupts = ; @@ -64,7 +64,7 @@ Signed-off-by: Lorenzo Bianconi mediatek,wo-cpuboot = <&wo_cpuboot>; }; -@@ -547,6 +535,16 @@ +@@ -569,6 +557,16 @@ interrupts = ; }; diff --git a/target/linux/mediatek/patches-6.1/946-arm64-dts-mt7986-move-dlm-in-a-dedicated-node.patch b/target/linux/mediatek/patches-6.1/946-arm64-dts-mt7986-move-dlm-in-a-dedicated-node.patch index 55f17286c6..90b2bb91a2 100644 --- a/target/linux/mediatek/patches-6.1/946-arm64-dts-mt7986-move-dlm-in-a-dedicated-node.patch +++ b/target/linux/mediatek/patches-6.1/946-arm64-dts-mt7986-move-dlm-in-a-dedicated-node.patch @@ -34,7 +34,7 @@ Signed-off-by: Lorenzo Bianconi }; timer { -@@ -501,10 +491,11 @@ +@@ -523,10 +513,11 @@ reg = <0 0x15010000 0 0x1000>; interrupt-parent = <&gic>; interrupts = ; @@ -48,7 +48,7 @@ Signed-off-by: Lorenzo Bianconi mediatek,wo-cpuboot = <&wo_cpuboot>; }; -@@ -514,10 +505,11 @@ +@@ -536,10 +527,11 @@ reg = <0 0x15011000 0 0x1000>; interrupt-parent = <&gic>; interrupts = ; @@ -62,7 +62,7 @@ Signed-off-by: Lorenzo Bianconi mediatek,wo-cpuboot = <&wo_cpuboot>; }; -@@ -545,6 +537,16 @@ +@@ -567,6 +559,16 @@ reg = <0 0x151f0000 0 0x8000>; }; From 25ddc6e4372ab20c7d2fa45b98b4288bcad932ec Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 11 Dec 2023 00:24:40 +0000 Subject: [PATCH 12/17] kernel: modules: break-out WM8960 codec module Package codec module for WM8960 in its own package to be used by more than one target. Signed-off-by: Daniel Golle --- package/kernel/linux/modules/sound.mk | 12 ++++++++++++ target/linux/ramips/modules.mk | 11 +++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/package/kernel/linux/modules/sound.mk b/package/kernel/linux/modules/sound.mk index 2bfa146207..62a31bfb11 100644 --- a/package/kernel/linux/modules/sound.mk +++ b/package/kernel/linux/modules/sound.mk @@ -254,6 +254,18 @@ endef $(eval $(call KernelPackage,sound-soc-imx-sgtl5000)) +define KernelPackage/sound-soc-wm8960 + TITLE:=SoC WM8960 codec support + KCONFIG:=CONFIG_SND_SOC_WM8960 + FILES:=$(LINUX_DIR)/sound/soc/codecs/snd-soc-wm8960.ko + DEPENDS:=+kmod-sound-soc-core +kmod-i2c-core +kmod-regmap-i2c + AUTOLOAD:=$(call AutoProbe,snd-soc-wm8960) + $(call AddDepends/sound) +endef + +$(eval $(call KernelPackage,sound-soc-wm8960)) + + define KernelPackage/sound-soc-spdif TITLE:=SoC S/PDIF codec support KCONFIG:=CONFIG_SND_SOC_SPDIF diff --git a/target/linux/ramips/modules.mk b/target/linux/ramips/modules.mk index 6f199c46a2..1127a8f8ab 100644 --- a/target/linux/ramips/modules.mk +++ b/target/linux/ramips/modules.mk @@ -113,18 +113,17 @@ $(eval $(call KernelPackage,hsdma-mtk)) define KernelPackage/sound-mt7620 TITLE:=MT7620 PCM/I2S Alsa Driver - DEPENDS:=@TARGET_ramips +kmod-sound-soc-core +kmod-regmap-i2c +kmod-dma-ralink @!TARGET_ramips_rt288x + DEPENDS:=@TARGET_ramips @!TARGET_ramips_rt288x +kmod-dma-ralink \ + +kmod-sound-soc-core +kmod-sound-soc-wm8960 KCONFIG:= \ CONFIG_SND_RALINK_SOC_I2S \ CONFIG_SND_SIMPLE_CARD \ - CONFIG_SND_SIMPLE_CARD_UTILS \ - CONFIG_SND_SOC_WM8960 + CONFIG_SND_SIMPLE_CARD_UTILS FILES:= \ $(LINUX_DIR)/sound/soc/ralink/snd-soc-ralink-i2s.ko \ $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card.ko \ - $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card-utils.ko \ - $(LINUX_DIR)/sound/soc/codecs/snd-soc-wm8960.ko - AUTOLOAD:=$(call AutoLoad,90,snd-soc-wm8960 snd-soc-ralink-i2s snd-soc-simple-card) + $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card-utils.ko + AUTOLOAD:=$(call AutoLoad,90,snd-soc-ralink-i2s snd-soc-simple-card) $(call AddDepends/sound) endef From d61b4ecbf109c7f702cafc0307db6b35e92c46b4 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 28 Sep 2023 19:13:23 +0100 Subject: [PATCH 13/17] kernel: modules: package MT7986 audio drivers Packages the audio drivers for the MediaTek MT7986 SoC used with Wolfson WM8960 codec. Signed-off-by: Daniel Golle --- package/kernel/linux/modules/sound.mk | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/package/kernel/linux/modules/sound.mk b/package/kernel/linux/modules/sound.mk index 62a31bfb11..623f65ac59 100644 --- a/package/kernel/linux/modules/sound.mk +++ b/package/kernel/linux/modules/sound.mk @@ -236,6 +236,40 @@ endef $(eval $(call KernelPackage,sound-soc-imx)) +define KernelPackage/sound-soc-mt7986 + TITLE:=MediaTek MT7986 Audio support + KCONFIG:=CONFIG_SND_SOC_MT7986 CONFIG_SND_SOC_MT7986_WM8960 + FILES:= \ + $(LINUX_DIR)/sound/soc/mediatek/common/snd-soc-mtk-common.ko \ + $(LINUX_DIR)/sound/soc/mediatek/mt7986/snd-soc-mt7986-afe.ko + AUTOLOAD:=$(call AutoLoad,56,snd-soc-mtk-common snd-soc-mt7986-afe) + DEPENDS:=@TARGET_mediatek_filogic +kmod-sound-soc-core + $(call AddDepends/sound) +endef + +define KernelPackage/sound-soc-mt7986/description + Support for audio on systems using the MediaTek MT7986 SoC. +endef + +$(eval $(call KernelPackage,sound-soc-mt7986)) + + +define KernelPackage/sound-soc-mt7986-wm8960 + TITLE:=MediaTek MT7986 Audio support + KCONFIG:=CONFIG_SND_SOC_MT7986_WM8960 + FILES:=$(LINUX_DIR)/sound/soc/mediatek/mt7986/mt7986-wm8960.ko + AUTOLOAD:=$(call AutoLoad,57,mt7986-wm8960) + DEPENDS:=@TARGET_mediatek_filogic +kmod-sound-soc-wm8960 +kmod-sound-soc-mt7986 + $(call AddDepends/sound) +endef + +define KernelPackage/sound-soc-mt7986-wm8960/description + Support for use of the Wolfson Audio WM8960 codec with the MediaTek MT7986 SoC. +endef + +$(eval $(call KernelPackage,sound-soc-mt7986-wm8960)) + + define KernelPackage/sound-soc-imx-sgtl5000 TITLE:=IMX SoC support for SGTL5000 KCONFIG:=CONFIG_SND_SOC_IMX_SGTL5000 From 957a0921e20257bd94b7f5ace6e07a68e8388499 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 10 Dec 2023 23:09:00 +0000 Subject: [PATCH 14/17] mediatek: bananapi-r3: add overlay for ReSpeaker 2-mic hat Add DT overlay to allow using the ReSpeaker 2-mic hat connected to the 26-pin header of the BananaPi BPi-R3. Supported sample formats: S16_LE, S24_LE, S32_LE Supported sample rates: 8/12/16/24/32/48/96/192 kHz | BPi-R3 | ReSpeaker 2-mic Signal | 26-pin | 40-pin ----------+----------+------------------- VCC 5V | 2 | 2 I2C SDA | 3 | 3 I2C SCL | 5 | 5 GND | 6 | 6 PCM CLK | 12 | 12 PCM FS | 15 | 35 PCM DIN | 26 | 38 GND | 25 | 39 PCM DOUT | 22 | 40 Once connected, install the driver and tell U-Boot to apply the DT overlay: opkg kmod-sound-soc-mt7986-wm8960 fw_setenv bootconf_base "config-mt7986a-bananapi-bpi-r3#mt7986a-bananapi-bpi-r3-respeaker-2mics" reboot To setup the ReSpeaker for Stereo out on the Headphone plug: amixer sset 'Right Output Mixer PCM' on amixer sset 'Left Output Mixer PCM' on amixer sset 'PCM Playback -6dB' off amixer sset 'O018 I150_Switch' on amixer sset 'O019 I151_Switch' on amixer sset 'O124 I032_Switch' on amixer sset 'O125 I033_Switch' on amixer sset 'Headphone' 121 amixer sset 'Playback' 255 Signed-off-by: Daniel Golle --- target/linux/mediatek/image/filogic.mk | 4 +- ...-mt7986-add-sound-overlay-for-bpi-r3.patch | 65 ++++++++++++++++ ...-mt7986-add-sound-overlay-for-bpi-r3.patch | 75 +++++++++++++++++++ 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 target/linux/mediatek/patches-5.15/864-arm64-dts-mt7986-add-sound-overlay-for-bpi-r3.patch create mode 100644 target/linux/mediatek/patches-6.1/864-arm64-dts-mt7986-add-sound-overlay-for-bpi-r3.patch diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 36333bb926..7af96674d9 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -212,7 +212,9 @@ define Device/bananapi_bpi-r3 DEVICE_MODEL := BPi-R3 DEVICE_DTS := mt7986a-bananapi-bpi-r3 DEVICE_DTS_CONFIG := config-mt7986a-bananapi-bpi-r3 - DEVICE_DTS_OVERLAY:= mt7986a-bananapi-bpi-r3-emmc mt7986a-bananapi-bpi-r3-nand mt7986a-bananapi-bpi-r3-nor mt7986a-bananapi-bpi-r3-sd + DEVICE_DTS_OVERLAY:= mt7986a-bananapi-bpi-r3-emmc mt7986a-bananapi-bpi-r3-nand \ + mt7986a-bananapi-bpi-r3-nor mt7986a-bananapi-bpi-r3-sd \ + mt7986a-bananapi-bpi-r3-respeaker-2mics DEVICE_DTS_DIR := $(DTS_DIR)/ DEVICE_DTS_LOADADDR := 0x43f00000 DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-gpio kmod-mt7986-firmware kmod-sfp kmod-usb3 e2fsprogs f2fsck mkf2fs mt7986-wo-firmware diff --git a/target/linux/mediatek/patches-5.15/864-arm64-dts-mt7986-add-sound-overlay-for-bpi-r3.patch b/target/linux/mediatek/patches-5.15/864-arm64-dts-mt7986-add-sound-overlay-for-bpi-r3.patch new file mode 100644 index 0000000000..4fc12bf402 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/864-arm64-dts-mt7986-add-sound-overlay-for-bpi-r3.patch @@ -0,0 +1,65 @@ +--- /dev/null ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-respeaker-2mics.dtso +@@ -0,0 +1,62 @@ ++// SPDX-License-Identifier: (GPL-2.0 OR MIT) ++/* ++ * Copyright (C) 2023 MediaTek Inc. ++ * Author: Maso Huang ++ */ ++ ++/dts-v1/; ++/plugin/; ++ ++/ { ++ compatible = "bananapi,bpi-r3", "mediatek,mt7986a"; ++ ++ fragment@0 { ++ target-path = "/"; ++ __overlay__ { ++ sound_wm8960 { ++ compatible = "mediatek,mt7986-wm8960-sound"; ++ audio-routing = "Headphone", "HP_L", ++ "Headphone", "HP_R", ++ "LINPUT1", "AMIC", ++ "RINPUT1", "AMIC"; ++ ++ status = "okay"; ++ ++ platform { ++ sound-dai = <&afe>; ++ }; ++ ++ codec { ++ sound-dai = <&wm8960>; ++ }; ++ }; ++ }; ++ }; ++ ++ fragment@1 { ++ target = <&i2c0>; ++ __overlay__ { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c_pins>; ++ clock-frequency = <400000>; ++ status = "okay"; ++ ++ wm8960: wm8960@1a { ++ compatible = "wlf,wm8960"; ++ reg = <0x1a>; ++ }; ++ }; ++ }; ++ ++ fragment@2 { ++ target = <&pio>; ++ __overlay__ { ++ i2c_pins: i2c-pins-3-4 { ++ mux { ++ function = "i2c"; ++ groups = "i2c"; ++ }; ++ }; ++ }; ++ }; ++}; diff --git a/target/linux/mediatek/patches-6.1/864-arm64-dts-mt7986-add-sound-overlay-for-bpi-r3.patch b/target/linux/mediatek/patches-6.1/864-arm64-dts-mt7986-add-sound-overlay-for-bpi-r3.patch new file mode 100644 index 0000000000..bddcd4bb0c --- /dev/null +++ b/target/linux/mediatek/patches-6.1/864-arm64-dts-mt7986-add-sound-overlay-for-bpi-r3.patch @@ -0,0 +1,75 @@ +--- /dev/null ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-respeaker-2mics.dtso +@@ -0,0 +1,62 @@ ++// SPDX-License-Identifier: (GPL-2.0 OR MIT) ++/* ++ * Copyright (C) 2023 MediaTek Inc. ++ * Author: Maso Huang ++ */ ++ ++/dts-v1/; ++/plugin/; ++ ++/ { ++ compatible = "bananapi,bpi-r3", "mediatek,mt7986a"; ++ ++ fragment@0 { ++ target-path = "/"; ++ __overlay__ { ++ sound_wm8960 { ++ compatible = "mediatek,mt7986-wm8960-sound"; ++ audio-routing = "Headphone", "HP_L", ++ "Headphone", "HP_R", ++ "LINPUT1", "AMIC", ++ "RINPUT1", "AMIC"; ++ ++ status = "okay"; ++ ++ platform { ++ sound-dai = <&afe>; ++ }; ++ ++ codec { ++ sound-dai = <&wm8960>; ++ }; ++ }; ++ }; ++ }; ++ ++ fragment@1 { ++ target = <&i2c0>; ++ __overlay__ { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c_pins>; ++ clock-frequency = <400000>; ++ status = "okay"; ++ ++ wm8960: wm8960@1a { ++ compatible = "wlf,wm8960"; ++ reg = <0x1a>; ++ }; ++ }; ++ }; ++ ++ fragment@2 { ++ target = <&pio>; ++ __overlay__ { ++ i2c_pins: i2c-pins-3-4 { ++ mux { ++ function = "i2c"; ++ groups = "i2c"; ++ }; ++ }; ++ }; ++ }; ++}; +--- a/arch/arm64/boot/dts/mediatek/Makefile ++++ b/arch/arm64/boot/dts/mediatek/Makefile +@@ -12,6 +12,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-b + dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-nand.dtbo + dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-nor.dtbo + dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-sd.dtbo ++dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-respeaker-2mics.dtbo + dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-rfb.dtb + dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986b-rfb.dtb + dtb-$(CONFIG_ARCH_MEDIATEK) += mt8167-pumpkin.dtb From 0827fb8cc3ab1e6ed0bfcdefdc27425de863ed91 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Mon, 11 Dec 2023 16:18:58 +0100 Subject: [PATCH 15/17] tools/cmake: update to 3.28.0 Release Notes: - https://www.kitware.com/cmake-3-28-0-available-for-download/ Refresh patches: - 120-curl-fix-libressl-linking.patch - 130-bootstrap_parallel_make_flag.patch Signed-off-by: Nick Hainke --- tools/cmake/Makefile | 4 ++-- tools/cmake/patches/120-curl-fix-libressl-linking.patch | 2 +- tools/cmake/patches/130-bootstrap_parallel_make_flag.patch | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/cmake/Makefile b/tools/cmake/Makefile index f05654b5c5..185b3c36e5 100644 --- a/tools/cmake/Makefile +++ b/tools/cmake/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=cmake -PKG_VERSION:=3.27.9 +PKG_VERSION:=3.28.0 PKG_VERSION_MAJOR:=$(word 1,$(subst ., ,$(PKG_VERSION))).$(word 2,$(subst ., ,$(PKG_VERSION))) PKG_RELEASE:=1 PKG_CPE_ID:=cpe:/a:kitware:cmake @@ -15,7 +15,7 @@ PKG_CPE_ID:=cpe:/a:kitware:cmake PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/Kitware/CMake/releases/download/v$(PKG_VERSION)/ \ https://cmake.org/files/v$(PKG_VERSION_MAJOR)/ -PKG_HASH:=609a9b98572a6a5ea477f912cffb973109ed4d0a6a6b3f9e2353d2cdc048708e +PKG_HASH:=e1dcf9c817ae306e73a45c2ba6d280c65cf4ec00dd958eb144adaf117fb58e71 HOST_BUILD_PARALLEL:=1 HOST_CONFIGURE_PARALLEL:=1 diff --git a/tools/cmake/patches/120-curl-fix-libressl-linking.patch b/tools/cmake/patches/120-curl-fix-libressl-linking.patch index b899d1d7ef..9d1d86c325 100644 --- a/tools/cmake/patches/120-curl-fix-libressl-linking.patch +++ b/tools/cmake/patches/120-curl-fix-libressl-linking.patch @@ -20,7 +20,7 @@ Signed-off-by: Jo-Philipp Wich --- --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt -@@ -590,6 +590,14 @@ if(CURL_USE_OPENSSL) +@@ -650,6 +650,14 @@ if(CURL_USE_OPENSSL) endif() set(SSL_ENABLED ON) set(USE_OPENSSL ON) diff --git a/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch b/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch index 983f376254..557e27a612 100644 --- a/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch +++ b/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch @@ -1,6 +1,6 @@ --- a/bootstrap +++ b/bootstrap -@@ -1486,7 +1486,10 @@ int main(){ printf("1%c", (char)0x0a); r +@@ -1491,7 +1491,10 @@ int main(){ printf("1%c", (char)0x0a); r ' > "test.c" cmake_original_make_flags="${cmake_make_flags}" if test "x${cmake_parallel_make}" != "x"; then From db3afed6ce25fc4a078883419d5798e74b5bb09c Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Tue, 12 Dec 2023 01:18:08 +0100 Subject: [PATCH 16/17] netifd: update to Git HEAD (2023-12-12) 8f2806a37fe1 system-linux: set master early on apply settings e3fc2b0026a5 system-linux: skip refreshing MAC on master change if custom MAC Signed-off-by: Christian Marangi --- package/network/config/netifd/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile index 78d5117ae6..ec1fb199b1 100644 --- a/package/network/config/netifd/Makefile +++ b/package/network/config/netifd/Makefile @@ -5,9 +5,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git -PKG_SOURCE_DATE:=2023-12-05 -PKG_SOURCE_VERSION:=cc9e928f0a12f04c82356c02dd9a84ac6b383fb9 -PKG_MIRROR_HASH:=b5bcb3e1c1841559bf202d2dc67dde62dce3c880043166cc8b3a3f97ce004c2a +PKG_SOURCE_DATE:=2023-12-12 +PKG_SOURCE_VERSION:=e3fc2b0026a5ca45de76f3e2a950dca85a361bd3 +PKG_MIRROR_HASH:=e1d461fb6aff4c2128f897d43e38a2759a50094ad777bf947c9b0ac898a9e3cf PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=GPL-2.0 From 3eca9ba53f38b60cf7994606072023b0af49b357 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Tue, 12 Dec 2023 01:25:01 +0100 Subject: [PATCH 17/17] ipq806x: drop useless uci-defaults compat version script Drop useless uci-defaults compat version script as it's not needed anymore and should have been dropped on DSA conversion. The script was needed for Linksys EA7500 and EA8500 for the kernel space migration. We now handle compat version setting in board.d scripts. Having this script with actually the wrong value (2.0) cause upgrade problem and conflicts with board.d script. Fixes: 337e36e0ef98 ("ipq806x: convert each device to DSA implementation") Signed-off-by: Christian Marangi --- .../base-files/etc/uci-defaults/05_fix-compat-version | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 target/linux/ipq806x/base-files/etc/uci-defaults/05_fix-compat-version diff --git a/target/linux/ipq806x/base-files/etc/uci-defaults/05_fix-compat-version b/target/linux/ipq806x/base-files/etc/uci-defaults/05_fix-compat-version deleted file mode 100644 index 3b9dd4e028..0000000000 --- a/target/linux/ipq806x/base-files/etc/uci-defaults/05_fix-compat-version +++ /dev/null @@ -1,11 +0,0 @@ -. /lib/functions.sh - -case "$(board_name)" in - linksys,ea7500-v1|\ - linksys,ea8500) - uci set system.@system[0].compat_version="2.0" - uci commit system - ;; -esac - -exit 0