Skip to content

Commit

Permalink
Merge pull request #6 from testuser7/mx4300
Browse files Browse the repository at this point in the history
Merge patches from testuser7
  • Loading branch information
arix00 authored Sep 17, 2024
2 parents 732f539 + b3aac58 commit 6cee3db
Show file tree
Hide file tree
Showing 11 changed files with 651 additions and 213 deletions.
5 changes: 5 additions & 0 deletions package/boot/uboot-envtools/files/qualcommax_ipq807x
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ linksys,mx8500)
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x20000" "2"
;;
linksys,mx4300)
idx="$(find_mtd_index u_env)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x40000" "1"
;;
netgear,sxr80|\
netgear,sxs80|\
tplink,eap660hd-v1)
Expand Down
36 changes: 25 additions & 11 deletions package/system/mtd/src/linksys_bootcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ struct bootcounter {
uint32_t checksum;
};

static char page[2048];

int mtd_resetbc(const char *mtd)
{
struct mtd_info_user mtd_info;
struct bootcounter *curr = (struct bootcounter *)page;
struct bootcounter *curr = NULL;
unsigned int i;
unsigned int bc_offset_increment;
int last_count = 0;
Expand Down Expand Up @@ -108,24 +106,37 @@ int mtd_resetbc(const char *mtd)
}

num_bc = mtd_info.size / bc_offset_increment;
curr = malloc(bc_offset_increment);

for (i = 0; i < num_bc; i++) {
pread(fd, curr, sizeof(*curr), i * bc_offset_increment);
if(curr == NULL) {
DLOG_ERR("Failed to allocate %u bytes from memory.", bc_offset_increment);

/* Existing code assumes erase is to 0xff; left as-is (2019) */
retval = -6;
goto out;
}

for (i = 0; i < num_bc; i++) {
ret = pread(fd, curr, sizeof(struct bootcounter), i * bc_offset_increment);

if (curr->magic != BOOTCOUNT_MAGIC &&
curr->magic != 0xffffffff) {
DLOG_ERR("Unexpected magic %08x at offset %08x; aborting.",
curr->magic, i * bc_offset_increment);
if(ret != sizeof(struct bootcounter)) {
DLOG_ERR("Failed to read boot-count log at offset 0x%08x.", i * bc_offset_increment);

retval = -2;
retval = -5;
goto out;
}

/* Existing code assumes erase is to 0xff; left as-is (2019) */
if (curr->magic == 0xffffffff)
break;

if (curr->magic != BOOTCOUNT_MAGIC || curr->checksum != curr->magic + curr->count) {
DLOG_ERR("Unexpected boot-count log at offset 0x%08x: magic 0x%08x boot count 0x%08x checksum 0x%08x; aborting.",
i * bc_offset_increment, curr->magic, curr->count, curr->checksum);

retval = -2;
goto out;
}

last_count = curr->count;
}

Expand Down Expand Up @@ -182,6 +193,9 @@ int mtd_resetbc(const char *mtd)
}

out:
if (curr != NULL)
free(curr);

close(fd);
return retval;
}
Original file line number Diff line number Diff line change
@@ -1,80 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/* Copyright (c) 2023, Mohammad Sayful Islam <[email protected]> */

#include "ipq8074.dtsi"
#include "ipq8074-ac-cpu.dtsi"
#include "ipq8074-ess.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
#include "ipq8174-mx4x00.dtsi"

/ {

aliases {
serial0 = &blsp1_uart5;
serial1 = &blsp1_uart3;
/*
* Aliases as required by u-boot
* to patch MAC addresses
*/
ethernet1 = &dp2;
ethernet2 = &dp3;
ethernet3 = &dp4;
ethernet4 = &dp5;
led-boot = &led_system_blue;
led-running = &led_system_blue;
led-failsafe = &led_system_red;
led-upgrade = &led_system_green;
};

chosen {
stdout-path = "serial0:115200n8";
bootargs-append = " root=/dev/ubiblock0_0";
};

keys {
compatible = "gpio-keys";
pinctrl-0 = <&button_pins>;
pinctrl-names = "default";

reset-button {
label = "reset";
gpios = <&tlmm 52 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};

wps-button {
label = "wps";
gpios = <&tlmm 67 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
};
};
};

&tlmm {
button_pins: button-state {
pins = "gpio52", "gpio67";
function = "gpio";
drive-strength = <8>;
bias-pull-up;
};

mdio_pins: mdio-state {
mdc-pins {
pins = "gpio68";
function = "mdc";
drive-strength = <8>;
bias-pull-up;
};

mdio-pins {
pins = "gpio69";
function = "mdio";
drive-strength = <8>;
bias-pull-up;
};
};

iot_pins: iot-state {
recovery-pins {
pins = "gpio22";
Expand All @@ -99,26 +35,6 @@
/* Silicon Labs EFR32MG21 IoT */
};

&blsp1_uart5 {
status = "okay";
};

&prng {
status = "okay";
};

&cryptobam {
status = "okay";
};

&crypto {
status = "okay";
};

&qpic_bam {
status = "okay";
};

&qpic_nand {
status = "okay";

Expand Down Expand Up @@ -289,21 +205,25 @@
label = "alt_rootfs";
reg = <0xac80000 0x9000000>;
};

partition@13c80000 {
label = "sysdiag";
reg = <0x13c80000 0x200000>;
read-only;
};

partition@13e80000 {
label = "0:ethphyfw";
reg = <0x13e80000 0x80000>;
read-only;
};

partition@13f00000 {
label = "syscfg";
reg = <0x13f00000 0xb800000>;
read-only;
};

partition@1f700000 {
label = "0:wififw";
reg = <0x1f700000 0x900000>;
Expand All @@ -313,102 +233,6 @@
};
};

&blsp1_i2c2 {
status = "okay";

led-controller@62 {
compatible = "nxp,pca9633";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x62>;
nxp,hw-blink;

led_system_red: led@0 {
reg = <0>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_STATUS;
};

led_system_green: led@1 {
reg = <1>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_STATUS;
};

led_system_blue: led@2 {
reg = <2>;
color = <LED_COLOR_ID_BLUE>;
function = LED_FUNCTION_STATUS;
};
};
};

&mdio {
status = "okay";

pinctrl-0 = <&mdio_pins>;
pinctrl-names = "default";
reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>;

ethernet-phy-package@0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "qcom,qca8075-package";
reg = <0>;

qca8075_1: ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <1>;
};

qca8075_2: ethernet-phy@2 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <2>;
};

qca8075_3: ethernet-phy@3 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <3>;
};

qca8075_4: ethernet-phy@4 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <4>;
};
};
};

&switch {
status = "okay";

switch_lan_bmp = <(ESS_PORT3 | ESS_PORT4 | ESS_PORT5)>; /* lan port bitmap */
switch_wan_bmp = <ESS_PORT2>; /* wan port bitmap */
switch_mac_mode = <MAC_MODE_PSGMII>; /* mac mode for uniphy instance0*/

qcom,port_phyinfo {
port@2 {
port_id = <2>;
phy_address = <1>;
};
port@3 {
port_id = <3>;
phy_address = <2>;
};
port@4 {
port_id = <4>;
phy_address = <3>;
};
port@5 {
port_id = <5>;
phy_address = <4>;
};
};
};

&edma {
status = "okay";
};

&dp2 {
status = "okay";
phy-handle = <&qca8075_1>;
Expand All @@ -432,16 +256,3 @@
phy-handle = <&qca8075_4>;
label = "lan3";
};

&ssphy_0 {
status = "okay";
};

&qusb_phy_0 {
status = "okay";
};

&usb_0 {
status = "okay";
};

Loading

0 comments on commit 6cee3db

Please sign in to comment.