From 8ec4b53451cdc79bf6a8e35f17e08350367907b4 Mon Sep 17 00:00:00 2001 From: centecqianj <110279455+centecqianj@users.noreply.github.com> Date: Fri, 8 Dec 2023 00:42:13 +0800 Subject: [PATCH] [Bookworm] Upgrade centec-arm64 platform to Bookworm. (#17411) Why I did it 1. Upgrade centec-arm64 platform to Bookworm. 2. Solve the problem of compiling the docker-syncd-centec-rpc.gz error on the centec platform. How I did it 1. Modified platform driver to comply with bookworm kernel. 2. Upgrade SONiC package versions of the centec platform. How to verify it 1. Compile the centec-arm64 platform to generate sonic-centec-arm64.bin. 2. Compile the centec platform to generate docker-syncd-centec-rpc.gz. Signed-off-by: centecqianj --- .../versions-deb-bullseye | 26 ++++++------ .../docker-syncd-centec/versions-deb-bullseye | 4 +- .../fan/fan-ctc5236.c | 2 +- .../tsingma-bsp/src/ctc-phy/mars.c | 14 +++---- .../src/ctc5236_switch/ctc5236_switch.c | 1 - .../tsingma-bsp/src/ctcmac/ctcmac.c | 28 +++++++------ .../tsingma-bsp/src/gpio-ctc/gpio-ctc.c | 18 ++++---- .../tsingma-bsp/src/pwm-ctc/pwm-ctc.c | 42 +++++++++++++++---- .../tsingma-bsp/src/rtc-sd2405/rtc-sd2405.c | 12 ------ .../src/sdhci-ctc5236/sdhci-ctc5236.c | 2 +- 10 files changed, 85 insertions(+), 64 deletions(-) mode change 100644 => 100755 files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-bullseye mode change 100644 => 100755 files/build/versions/dockers/docker-syncd-centec/versions-deb-bullseye mode change 100644 => 100755 platform/centec-arm64/tsingma-bsp/src/rtc-sd2405/rtc-sd2405.c diff --git a/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-bullseye old mode 100644 new mode 100755 index dd0e740c77..f2b73ec9cf --- a/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-bullseye +++ b/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-bullseye @@ -15,14 +15,14 @@ libarchive13==3.4.3-2+deb11u1 libasan6==10.2.1-6 libbinutils==2.35.2-2 libboost-atomic1.74.0==1.74.0-9 -libc-dev-bin==2.31-13+deb11u6 -libc6-dev==2.31-13+deb11u6 +libc-dev-bin==2.31-13+deb11u7 +libc6-dev==2.31-13+deb11u7 libcc1-0==10.2.1-6 libcrypt-dev==1:4.4.18-4 libctf-nobfd0==2.35.2-2 libctf0==2.35.2-2 libdouble-conversion3==3.1.5-6.1 -libdpkg-perl==1.20.12 +libdpkg-perl==1.20.13 libexpat1-dev==2.2.10-2+deb11u5 libffi-dev==3.3-6 libgcc-10-dev==10.2.1-6 @@ -39,17 +39,17 @@ libnsl-dev==1.3.0-2 libpcre2-16-0==10.36-2+deb11u1 libpython2-dev==2.7.18-3 libpython2-stdlib==2.7.18-3 -libpython2.7==2.7.18-8 -libpython2.7-dev==2.7.18-8 -libpython2.7-minimal==2.7.18-8 -libpython2.7-stdlib==2.7.18-8 +libpython2.7==2.7.18-8+deb11u1 +libpython2.7-dev==2.7.18-8+deb11u1 +libpython2.7-minimal==2.7.18-8+deb11u1 +libpython2.7-stdlib==2.7.18-8+deb11u1 libqt5core5a==5.15.2+dfsg-9 libqt5dbus5==5.15.2+dfsg-9 libqt5network5==5.15.2+dfsg-9 libquadmath0==10.2.1-6 librhash0==1.4.1-2 -libssl-dev==1.1.1n-0+deb11u5 -libssl1.1==1.1.1n-0+deb11u5 +libssl-dev==1.1.1w-0+deb11u1 +libssl1.1==1.1.1w-0+deb11u1 libstdc++-10-dev==10.2.1-6 libthrift-0.11.0==0.11.0-4 libtirpc-dev==1.3.1-1+deb11u1 @@ -57,7 +57,7 @@ libtsan0==10.2.1-6 libubsan1==10.2.1-6 libuv1==1.40.0-2 libxml2==2.9.10+dfsg-6.7+deb11u4 -linux-libc-dev==5.10.191-1 +linux-libc-dev==5.10.197-1 mailcap==3.69 make==4.3-4.1 mime-support==3.66 @@ -70,9 +70,9 @@ python-setuptools==44.1.1-1 python2==2.7.18-3 python2-dev==2.7.18-3 python2-minimal==2.7.18-3 -python2.7==2.7.18-8 -python2.7-dev==2.7.18-8 -python2.7-minimal==2.7.18-8 +python2.7==2.7.18-8+deb11u1 +python2.7-dev==2.7.18-8+deb11u1 +python2.7-minimal==2.7.18-8+deb11u1 python3-pip==20.3.4-4+deb11u1 python3-pkg-resources==52.0.0-4 python3-setuptools==52.0.0-4 diff --git a/files/build/versions/dockers/docker-syncd-centec/versions-deb-bullseye b/files/build/versions/dockers/docker-syncd-centec/versions-deb-bullseye old mode 100644 new mode 100755 index 77d75ecaad..36760cb719 --- a/files/build/versions/dockers/docker-syncd-centec/versions-deb-bullseye +++ b/files/build/versions/dockers/docker-syncd-centec/versions-deb-bullseye @@ -4,7 +4,7 @@ kmod==28-1 libbabeltrace1==1.5.8-1+b3 libboost-regex1.74.0==1.74.0-9 libcbor0==0.5.0+dfsg-2 -libcurl3-gnutls==7.74.0-1.3+deb11u7 +libcurl3-gnutls==7.74.0-1.3+deb11u10 libdebuginfod1==0.183-1 libdw1==0.183-1 libedit2==3.1-20191231-2+b1 @@ -24,7 +24,7 @@ libsource-highlight4v5==3.1.9-3+b1 libswsscommon-dbg==1.0.0 libswsscommon-dbgsym==1.0.0 libunwind8==1.3.2-2 -openssh-client==1:8.4p1-5+deb11u1 +openssh-client==1:8.4p1-5+deb11u2 sshpass==1.09-1+b1 strace==5.10-1 syncd==1.0.0 diff --git a/platform/centec-arm64/sonic-platform-modules-e530/fan/fan-ctc5236.c b/platform/centec-arm64/sonic-platform-modules-e530/fan/fan-ctc5236.c index 96448c7db4..605667330a 100644 --- a/platform/centec-arm64/sonic-platform-modules-e530/fan/fan-ctc5236.c +++ b/platform/centec-arm64/sonic-platform-modules-e530/fan/fan-ctc5236.c @@ -180,7 +180,7 @@ static int fan_ctc5236_probe(struct platform_device *pdev) for (idx = 0; idx < CTC_MAX_FAN; idx++) { - data->pwm[idx] = devm_of_pwm_get(&pdev->dev, pdev->dev.of_node, pwmnames[idx]); + data->pwm[idx] = devm_pwm_get(&pdev->dev, pwmnames[idx]); if (IS_ERR(data->pwm[idx])) { dev_err(&pdev->dev, "Could not get PWM\n"); return PTR_ERR(data->pwm[idx]); diff --git a/platform/centec-arm64/tsingma-bsp/src/ctc-phy/mars.c b/platform/centec-arm64/tsingma-bsp/src/ctc-phy/mars.c index 7f1cdafe22..129a3ea5f2 100644 --- a/platform/centec-arm64/tsingma-bsp/src/ctc-phy/mars.c +++ b/platform/centec-arm64/tsingma-bsp/src/ctc-phy/mars.c @@ -167,7 +167,7 @@ int mars1s_config_aneg(struct phy_device *phydev) return 0; } -static int mars_ack_interrupt(struct phy_device *phydev) +static irqreturn_t mars_handle_interrupt(struct phy_device *phydev) { int err; @@ -178,9 +178,9 @@ static int mars_ack_interrupt(struct phy_device *phydev) err = mars_ext_read(phydev, 0xa011); #endif if (err < 0) - return err; + return IRQ_NONE; - return 0; + return IRQ_HANDLED; } static int mars_config_intr(struct phy_device *phydev) @@ -256,7 +256,7 @@ static struct phy_driver ctc_drivers[] = { .config_init = mars_config_init, .features = PHY_GBIT_FEATURES, .config_aneg = mars1s_config_aneg, - .ack_interrupt = &mars_ack_interrupt, + .handle_interrupt = &mars_handle_interrupt, .config_intr = &mars_config_intr, .read_status = genphy_read_status, .suspend = genphy_suspend, @@ -269,7 +269,7 @@ static struct phy_driver ctc_drivers[] = { .config_init = mars_config_init, .features = PHY_GBIT_FEATURES, .config_aneg = mars1s_config_aneg, - .ack_interrupt = &mars_ack_interrupt, + .handle_interrupt = &mars_handle_interrupt, .config_intr = &mars_config_intr, .read_status = genphy_read_status, .suspend = genphy_suspend, @@ -282,7 +282,7 @@ static struct phy_driver ctc_drivers[] = { .config_init = mars1p_config_init, .features = PHY_GBIT_FEATURES, .config_aneg = mars1s_config_aneg, - .ack_interrupt = &mars_ack_interrupt, + .handle_interrupt = &mars_handle_interrupt, .config_intr = &mars_config_intr, .read_status = genphy_read_status, .suspend = genphy_suspend, @@ -295,7 +295,7 @@ static struct phy_driver ctc_drivers[] = { .config_init = mars1p_config_init, .features = PHY_GBIT_FEATURES, .config_aneg = mars1s_config_aneg, - .ack_interrupt = &mars_ack_interrupt, + .handle_interrupt = &mars_handle_interrupt, .config_intr = &mars_config_intr, .read_status = genphy_read_status, .suspend = genphy_suspend, diff --git a/platform/centec-arm64/tsingma-bsp/src/ctc5236_switch/ctc5236_switch.c b/platform/centec-arm64/tsingma-bsp/src/ctc5236_switch/ctc5236_switch.c index 2635a86e6f..c3bee141c6 100755 --- a/platform/centec-arm64/tsingma-bsp/src/ctc5236_switch/ctc5236_switch.c +++ b/platform/centec-arm64/tsingma-bsp/src/ctc5236_switch/ctc5236_switch.c @@ -278,7 +278,6 @@ static int ctc_switch_probe(struct platform_device *pdev) struct resource *iomem; void __iomem *ioaddr; resource_size_t start; - uint val; iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); diff --git a/platform/centec-arm64/tsingma-bsp/src/ctcmac/ctcmac.c b/platform/centec-arm64/tsingma-bsp/src/ctcmac/ctcmac.c index ea28b561ec..0d970ae71e 100755 --- a/platform/centec-arm64/tsingma-bsp/src/ctcmac/ctcmac.c +++ b/platform/centec-arm64/tsingma-bsp/src/ctcmac/ctcmac.c @@ -267,7 +267,7 @@ static int ctcmac_of_init(struct platform_device *ofdev, { u32 val; int err = 0, index, int_coalesce; - const void *mac_addr; + u8 mac_addr[ETH_ALEN]; const char *ctype, *automode, *dfe, *int_type, *tx_inv, *rx_inv; struct net_device *dev = NULL; struct ctcmac_private *priv = NULL; @@ -313,10 +313,10 @@ static int ctcmac_of_init(struct platform_device *ofdev, else priv->index = 0; - mac_addr = of_get_mac_address(np); - - if (!IS_ERR(mac_addr)) + err = of_get_mac_address(np, mac_addr); + if (!err) { memcpy(dev->dev_addr, mac_addr, ETH_ALEN); + } err = of_property_read_string(np, "int-type", &int_type); if ((err == 0) && !strncmp(int_type, "desc", 4)) { @@ -977,7 +977,7 @@ static int ctc_mac_serdes_init(struct ctcmac_private *priv) static void ctcmac_mac_filter_init(struct ctcmac_private *priv) { - unsigned char *dev_addr; + const unsigned char *dev_addr; u32 val, addr_h = 0, addr_l = 0; if (priv->version == 0) @@ -3147,7 +3147,9 @@ static void ctcmac_get_regs(struct net_device *dev, struct ethtool_regs *regs, * rx, rx_mini, and rx_jumbo rings are the same size, as mini and * jumbo are ignored by the driver */ static void ctcmac_gringparam(struct net_device *dev, - struct ethtool_ringparam *rvals) + struct ethtool_ringparam *rvals, + struct kernel_ethtool_ringparam *kernel_ring, + struct netlink_ext_ack *extack) { struct ctcmac_private *priv = netdev_priv(dev); struct ctcmac_priv_tx_q *tx_queue = NULL; @@ -3174,7 +3176,9 @@ static void ctcmac_gringparam(struct net_device *dev, * necessary so that we don't mess things up while we're in motion. */ static int ctcmac_sringparam(struct net_device *dev, - struct ethtool_ringparam *rvals) + struct ethtool_ringparam *rvals, + struct kernel_ethtool_ringparam *kernel_ring, + struct netlink_ext_ack *extack) { struct ctcmac_private *priv = netdev_priv(dev); int err = 0, i; @@ -3492,16 +3496,16 @@ static int ctcmac_probe(struct platform_device *ofdev) dev->ethtool_ops = &ctcmac_ethtool_ops; if (priv->version == 0) { - netif_napi_add(dev, &priv->napi_rx, ctcmac_poll_rx_sq, + netif_napi_add_weight(dev, &priv->napi_rx, ctcmac_poll_rx_sq, CTCMAC_NAIP_RX_WEIGHT); - netif_napi_add(dev, &priv->napi_tx, ctcmac_poll_tx_sq, + netif_napi_add_weight(dev, &priv->napi_tx, ctcmac_poll_tx_sq, CTCMAC_NAIP_TX_WEIGHT); } else { - netif_napi_add(dev, &priv->napi_rx, ctcmac_poll_rx0_sq, + netif_napi_add_weight(dev, &priv->napi_rx, ctcmac_poll_rx0_sq, CTCMAC_NAIP_RX_WEIGHT); - netif_napi_add(dev, &priv->napi_rx1, ctcmac_poll_rx1_sq, + netif_napi_add_weight(dev, &priv->napi_rx1, ctcmac_poll_rx1_sq, CTCMAC_NAIP_RX_WEIGHT); - netif_napi_add(dev, &priv->napi_tx, ctcmac_poll_tx_sq, + netif_napi_add_weight(dev, &priv->napi_tx, ctcmac_poll_tx_sq, CTCMAC_NAIP_TX_WEIGHT); } diff --git a/platform/centec-arm64/tsingma-bsp/src/gpio-ctc/gpio-ctc.c b/platform/centec-arm64/tsingma-bsp/src/gpio-ctc/gpio-ctc.c index 776f7da001..34d4cf8127 100755 --- a/platform/centec-arm64/tsingma-bsp/src/gpio-ctc/gpio-ctc.c +++ b/platform/centec-arm64/tsingma-bsp/src/gpio-ctc/gpio-ctc.c @@ -34,6 +34,8 @@ #define DWAPB_MAX_PORTS 2 +static DEFINE_SPINLOCK(ctcgpio_lock); + struct ctcapb_gpio; static u32 soc_v; @@ -118,9 +120,9 @@ static void ctcapb_irq_enable(struct irq_data *d) struct gpio_chip *gc = &port->gc; unsigned long flags; - spin_lock_irqsave(&gc->bgpio_lock, flags); + spin_lock_irqsave(&ctcgpio_lock, flags); clrsetbits(&port->regs->GpioIntrEn, 0, BIT(d->hwirq)); - spin_unlock_irqrestore(&gc->bgpio_lock, flags); + spin_unlock_irqrestore(&ctcgpio_lock, flags); } extern void irq_gc_mask_clr_bit(struct irq_data *d); @@ -139,9 +141,9 @@ static void ctcapb_irq_disable(struct irq_data *d) struct gpio_chip *gc = &port->gc; unsigned long flags; - spin_lock_irqsave(&gc->bgpio_lock, flags); + spin_lock_irqsave(&ctcgpio_lock, flags); clrsetbits(&port->regs->GpioIntrEn, ~BIT(d->hwirq), 0); - spin_unlock_irqrestore(&gc->bgpio_lock, flags); + spin_unlock_irqrestore(&ctcgpio_lock, flags); } #endif @@ -180,7 +182,7 @@ static int ctcapb_irq_set_type(struct irq_data *d, u32 type) IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) return -EINVAL; - spin_lock_irqsave(&gc->bgpio_lock, flags); + spin_lock_irqsave(&ctcgpio_lock, flags); level = readl(&port->regs->GpioIntrLevel); polarity = readl(&port->regs->GpioIntrPolarity); @@ -226,7 +228,7 @@ static int ctcapb_irq_set_type(struct irq_data *d, u32 type) writel(level, &port->regs->GpioIntrLevel); writel(polarity, &port->regs->GpioIntrPolarity); - spin_unlock_irqrestore(&gc->bgpio_lock, flags); + spin_unlock_irqrestore(&ctcgpio_lock, flags); return 0; } @@ -238,7 +240,7 @@ static int ctcapb_gpio_set_debounce(struct gpio_chip *gc, unsigned long flags, val_deb; unsigned long mask = BIT(offset); - spin_lock_irqsave(&gc->bgpio_lock, flags); + spin_lock_irqsave(&ctcgpio_lock, flags); val_deb = readl(&port->regs->GpioDebCtl); if (debounce) @@ -246,7 +248,7 @@ static int ctcapb_gpio_set_debounce(struct gpio_chip *gc, else writel(val_deb & ~mask, &port->regs->GpioDebCtl); - spin_unlock_irqrestore(&gc->bgpio_lock, flags); + spin_unlock_irqrestore(&ctcgpio_lock, flags); return 0; } diff --git a/platform/centec-arm64/tsingma-bsp/src/pwm-ctc/pwm-ctc.c b/platform/centec-arm64/tsingma-bsp/src/pwm-ctc/pwm-ctc.c index a2e1f99776..455f96b1d1 100755 --- a/platform/centec-arm64/tsingma-bsp/src/pwm-ctc/pwm-ctc.c +++ b/platform/centec-arm64/tsingma-bsp/src/pwm-ctc/pwm-ctc.c @@ -133,7 +133,33 @@ static void ctc_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) ctc_pwm_writel(pc, pwm->hwpwm, CTC_CR_PWM, cur_value); } -static void ctc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, +static int ctc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, + const struct pwm_state *state) +{ + int err; + + if (state->polarity != PWM_POLARITY_NORMAL) + return -EINVAL; + + if (!state->enabled) + { + if(pwm->state.enabled) + ctc_pwm_disable(chip,pwm); + return 0; + } + + err = ctc_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period); + if (err) + return err; + + if (!pwm->state.enabled) + err = ctc_pwm_enable(chip, pwm); + + return err; +} + + +static int ctc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) { struct ctc_pwm_chip *pc = to_ctc_pwm_chip(chip); @@ -154,6 +180,8 @@ static void ctc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, cur_value_2 = ctc_pwm_readl(pc, pwm->hwpwm, CTC_DUTY_PWM); state->duty_cycle = cur_value_2 * 1000; // in nanoseconds + + return 0; } static int ctc_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, @@ -173,9 +201,9 @@ static int ctc_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, } static const struct pwm_ops ctc_pwm_ops = { - .config = ctc_pwm_config, - .enable = ctc_pwm_enable, - .disable = ctc_pwm_disable, + .apply = ctc_pwm_apply, + //.enable = ctc_pwm_enable, + //.disable = ctc_pwm_disable, .get_state = ctc_pwm_get_state, .capture = ctc_pwm_capture, .owner = THIS_MODULE, @@ -225,7 +253,7 @@ static int ctc_pwm_probe(struct platform_device *pdev) return 0; } -static int ctc_pwm_remove(struct platform_device *pdev) +static void ctc_pwm_remove(struct platform_device *pdev) { struct ctc_pwm_chip *pc = platform_get_drvdata(pdev); int i; @@ -233,7 +261,7 @@ static int ctc_pwm_remove(struct platform_device *pdev) for (i = 0; i < CTC_NUM_PWM; i++) pwm_disable(&pc->chip.pwms[i]); - return pwmchip_remove(&pc->chip); + pwmchip_remove(&pc->chip); } static const struct of_device_id ctc_pwm_of_match[] = { @@ -249,7 +277,7 @@ static struct platform_driver ctc_pwm_driver = { .of_match_table = ctc_pwm_of_match, }, .probe = ctc_pwm_probe, - .remove = ctc_pwm_remove, + .remove_new = ctc_pwm_remove, }; module_platform_driver(ctc_pwm_driver); diff --git a/platform/centec-arm64/tsingma-bsp/src/rtc-sd2405/rtc-sd2405.c b/platform/centec-arm64/tsingma-bsp/src/rtc-sd2405/rtc-sd2405.c old mode 100644 new mode 100755 index f448b418ba..d76856e5e2 --- a/platform/centec-arm64/tsingma-bsp/src/rtc-sd2405/rtc-sd2405.c +++ b/platform/centec-arm64/tsingma-bsp/src/rtc-sd2405/rtc-sd2405.c @@ -180,17 +180,6 @@ static int sd2405_rtc_set_time(struct device *dev, struct rtc_time *tm) return sd2405_i2c_set_time(to_i2c_client(dev), tm); } -static int sd2405_remove(struct i2c_client *client) -{ -#if 0 - struct rtc_device *rtc = i2c_get_clientdata(client); - - if (rtc) - rtc_device_unregister(rtc); -#endif - return 0; -} - static const struct rtc_class_ops sd2405_rtc_ops = { .read_time = sd2405_rtc_read_time, .set_time = sd2405_rtc_set_time, @@ -229,7 +218,6 @@ static struct i2c_driver sd2405_driver = { .name = "rtc-sd2405", }, .probe = sd2405_probe, - .remove = sd2405_remove, .id_table = sd2405_id, }; diff --git a/platform/centec-arm64/tsingma-bsp/src/sdhci-ctc5236/sdhci-ctc5236.c b/platform/centec-arm64/tsingma-bsp/src/sdhci-ctc5236/sdhci-ctc5236.c index 5641ba6cd5..41516bde3e 100755 --- a/platform/centec-arm64/tsingma-bsp/src/sdhci-ctc5236/sdhci-ctc5236.c +++ b/platform/centec-arm64/tsingma-bsp/src/sdhci-ctc5236/sdhci-ctc5236.c @@ -327,7 +327,7 @@ static int sdhci_ctc5236_probe(struct platform_device *pdev) version = (val == 0x1) ? CTC_REV_TM_1_1 : CTC_REV_TM_1_0; - mmc_of_parse_voltage(pdev->dev.of_node, &host->ocr_mask); + mmc_of_parse_voltage(host->mmc, &host->ocr_mask); ret = mmc_of_parse(host->mmc); if (ret)