Merge Official Source
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
commit
0861ce7fb2
@ -714,6 +714,18 @@ define U-Boot/mt7986_zyxel_ex5601-t0
|
||||
DEPENDS:=+trusted-firmware-a-mt7986-spim-nand-4k-ddr4
|
||||
endef
|
||||
|
||||
define U-Boot/mt7988_arcadyan_mozart
|
||||
NAME:=Arcadyan Mozart
|
||||
BUILD_SUBTARGET:=filogic
|
||||
BUILD_DEVICES:=arcadyan_mozart
|
||||
UBOOT_CONFIG:=mt7988a_arcadyan_mozart
|
||||
UBOOT_IMAGE:=u-boot.fip
|
||||
BL2_BOOTDEV:=emmc
|
||||
BL2_SOC:=mt7988
|
||||
BL2_DDRTYPE:=comb
|
||||
DEPENDS:=+trusted-firmware-a-mt7988-emmc-comb
|
||||
endef
|
||||
|
||||
define U-Boot/mt7988_bananapi_bpi-r4-emmc
|
||||
NAME:=BananaPi BPi-R4
|
||||
BUILD_SUBTARGET:=filogic
|
||||
@ -908,6 +920,7 @@ UBOOT_TARGETS := \
|
||||
mt7986_xiaomi_redmi-router-ax6000 \
|
||||
mt7986_zyxel_ex5601-t0 \
|
||||
mt7986_rfb \
|
||||
mt7988_arcadyan_mozart \
|
||||
mt7988_bananapi_bpi-r4-emmc \
|
||||
mt7988_bananapi_bpi-r4-sdmmc \
|
||||
mt7988_bananapi_bpi-r4-snand \
|
||||
@ -923,7 +936,8 @@ UBOOT_TARGETS := \
|
||||
UBOOT_CUSTOMIZE_CONFIG := \
|
||||
--disable TOOLS_KWBIMAGE \
|
||||
--disable TOOLS_LIBCRYPTO \
|
||||
--disable TOOLS_MKEFICAPSULE
|
||||
--disable TOOLS_MKEFICAPSULE \
|
||||
--enable SERIAL_RX_BUFFER
|
||||
|
||||
ifdef CONFIG_TARGET_mediatek
|
||||
UBOOT_MAKE_FLAGS += $(UBOOT_IMAGE:.fip=.bin)
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
From 72b4ba8417d33516b8489bac3c90dbbbf781a3d2 Mon Sep 17 00:00:00 2001
|
||||
From: Weijie Gao <weijie.gao@mediatek.com>
|
||||
Date: Tue, 29 Oct 2024 17:47:10 +0800
|
||||
Subject: [PATCH 1/3] menu: fix the logic checking whether ESC key is pressed
|
||||
|
||||
It's observed that the bootmenu on a serial console sometimes
|
||||
incorrectly quitted with superfluous characters filled to command
|
||||
line input:
|
||||
|
||||
> *** U-Boot Boot Menu ***
|
||||
>
|
||||
> 1. Startup system (Default)
|
||||
> 2. Upgrade firmware
|
||||
> 3. Upgrade ATF BL2
|
||||
> 4. Upgrade ATF FIP
|
||||
> 5. Load image
|
||||
> 0. U-Boot console
|
||||
>
|
||||
>
|
||||
> Press UP/DOWN to move, ENTER to select, ESC to quit
|
||||
>MT7988> [B
|
||||
|
||||
Analysis shows it was caused by the wrong logic of bootmenu_loop:
|
||||
|
||||
At first the bootmenu_loop received the first ESC char correctly.
|
||||
|
||||
However, during the second call to bootmenu_loop, there's no data
|
||||
in the UART Rx FIFO. Due to the low baudrate, the second char of
|
||||
the down array key sequence hasn't be fully received.
|
||||
|
||||
But bootmenu_loop just did a mdelay(10), and then treated it as a
|
||||
single ESC key press event. It didn't even try tstc() again after
|
||||
the 10ms timeout.
|
||||
|
||||
This patch fixes this issue by letting bootmenu_loop check tstc()
|
||||
twice.
|
||||
|
||||
Tested-By: E Shattow <lucent@gmail.com>
|
||||
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
---
|
||||
common/menu.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/common/menu.c
|
||||
+++ b/common/menu.c
|
||||
@@ -525,14 +525,15 @@ enum bootmenu_key bootmenu_loop(struct b
|
||||
struct cli_ch_state *cch)
|
||||
{
|
||||
enum bootmenu_key key;
|
||||
- int c;
|
||||
+ int c, errchar = 0;
|
||||
|
||||
c = cli_ch_process(cch, 0);
|
||||
if (!c) {
|
||||
while (!c && !tstc()) {
|
||||
schedule();
|
||||
mdelay(10);
|
||||
- c = cli_ch_process(cch, -ETIMEDOUT);
|
||||
+ c = cli_ch_process(cch, errchar);
|
||||
+ errchar = -ETIMEDOUT;
|
||||
}
|
||||
if (!c) {
|
||||
c = getchar();
|
||||
@ -0,0 +1,112 @@
|
||||
From f1cbdd3330f0055dfbff0ef7d86276c4cc3cff2a Mon Sep 17 00:00:00 2001
|
||||
From: Weijie Gao <weijie.gao@mediatek.com>
|
||||
Date: Tue, 29 Oct 2024 17:47:16 +0800
|
||||
Subject: [PATCH 2/3] menu: add support to check if menu needs to be reprinted
|
||||
|
||||
This patch adds a new callback named need_reprint for menu.
|
||||
The need_reprint will be called before printing the menu. If the
|
||||
callback exists and returns FALSE, menu printing will be canceled.
|
||||
|
||||
This is very useful if the menu was not changed. It can save time
|
||||
for serial-based menu to handle more input data.
|
||||
|
||||
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
---
|
||||
boot/pxe_utils.c | 2 +-
|
||||
cmd/bootmenu.c | 2 +-
|
||||
cmd/eficonfig.c | 2 +-
|
||||
common/menu.c | 11 +++++++++++
|
||||
include/menu.h | 1 +
|
||||
5 files changed, 15 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/boot/pxe_utils.c
|
||||
+++ b/boot/pxe_utils.c
|
||||
@@ -1449,7 +1449,7 @@ static struct menu *pxe_menu_to_menu(str
|
||||
* Create a menu and add items for all the labels.
|
||||
*/
|
||||
m = menu_create(cfg->title, DIV_ROUND_UP(cfg->timeout, 10),
|
||||
- cfg->prompt, NULL, label_print, NULL, NULL);
|
||||
+ cfg->prompt, NULL, label_print, NULL, NULL, NULL);
|
||||
if (!m)
|
||||
return NULL;
|
||||
|
||||
--- a/cmd/bootmenu.c
|
||||
+++ b/cmd/bootmenu.c
|
||||
@@ -506,7 +506,7 @@ static enum bootmenu_ret bootmenu_show(i
|
||||
|
||||
menu = menu_create(NULL, bootmenu->delay, 1, menu_display_statusline,
|
||||
bootmenu_print_entry, bootmenu_choice_entry,
|
||||
- bootmenu);
|
||||
+ NULL, bootmenu);
|
||||
if (!menu) {
|
||||
bootmenu_destroy(bootmenu);
|
||||
return BOOTMENU_RET_FAIL;
|
||||
--- a/cmd/eficonfig.c
|
||||
+++ b/cmd/eficonfig.c
|
||||
@@ -443,7 +443,7 @@ efi_status_t eficonfig_process_common(st
|
||||
efi_menu->menu_desc = menu_desc;
|
||||
|
||||
menu = menu_create(NULL, 0, 1, display_statusline, item_data_print,
|
||||
- item_choice, efi_menu);
|
||||
+ item_choice, NULL, efi_menu);
|
||||
if (!menu)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
--- a/common/menu.c
|
||||
+++ b/common/menu.c
|
||||
@@ -43,6 +43,7 @@ struct menu {
|
||||
void (*display_statusline)(struct menu *);
|
||||
void (*item_data_print)(void *);
|
||||
char *(*item_choice)(void *);
|
||||
+ bool (*need_reprint)(void *);
|
||||
void *item_choice_data;
|
||||
struct list_head items;
|
||||
int item_cnt;
|
||||
@@ -117,6 +118,11 @@ static inline void *menu_item_destroy(st
|
||||
*/
|
||||
static inline void menu_display(struct menu *m)
|
||||
{
|
||||
+ if (m->need_reprint) {
|
||||
+ if (!m->need_reprint(m->item_choice_data))
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (m->title) {
|
||||
puts(m->title);
|
||||
putc('\n');
|
||||
@@ -362,6 +368,9 @@ int menu_item_add(struct menu *m, char *
|
||||
* item. Returns a key string corresponding to the chosen item or NULL if
|
||||
* no item has been selected.
|
||||
*
|
||||
+ * need_reprint - If not NULL, will be called before printing the menu.
|
||||
+ * Returning FALSE means the menu does not need reprint.
|
||||
+ *
|
||||
* item_choice_data - Will be passed as the argument to the item_choice function
|
||||
*
|
||||
* Returns a pointer to the menu if successful, or NULL if there is
|
||||
@@ -371,6 +380,7 @@ struct menu *menu_create(char *title, in
|
||||
void (*display_statusline)(struct menu *),
|
||||
void (*item_data_print)(void *),
|
||||
char *(*item_choice)(void *),
|
||||
+ bool (*need_reprint)(void *),
|
||||
void *item_choice_data)
|
||||
{
|
||||
struct menu *m;
|
||||
@@ -386,6 +396,7 @@ struct menu *menu_create(char *title, in
|
||||
m->display_statusline = display_statusline;
|
||||
m->item_data_print = item_data_print;
|
||||
m->item_choice = item_choice;
|
||||
+ m->need_reprint = need_reprint;
|
||||
m->item_choice_data = item_choice_data;
|
||||
m->item_cnt = 0;
|
||||
|
||||
--- a/include/menu.h
|
||||
+++ b/include/menu.h
|
||||
@@ -13,6 +13,7 @@ struct menu *menu_create(char *title, in
|
||||
void (*display_statusline)(struct menu *),
|
||||
void (*item_data_print)(void *),
|
||||
char *(*item_choice)(void *),
|
||||
+ bool (*need_reprint)(void *),
|
||||
void *item_choice_data);
|
||||
int menu_default_set(struct menu *m, char *item_key);
|
||||
int menu_get_choice(struct menu *m, void **choice);
|
||||
@ -0,0 +1,75 @@
|
||||
From 702752cfae954648d6133bdff19283343b3339ef Mon Sep 17 00:00:00 2001
|
||||
From: Weijie Gao <weijie.gao@mediatek.com>
|
||||
Date: Tue, 29 Oct 2024 17:47:22 +0800
|
||||
Subject: [PATCH 3/3] bootmenu: add reprint check
|
||||
|
||||
Record the last active menu item and check if it equals to the
|
||||
current selected item before reprint.
|
||||
|
||||
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
---
|
||||
cmd/bootmenu.c | 16 +++++++++++++++-
|
||||
include/menu.h | 1 +
|
||||
2 files changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/cmd/bootmenu.c
|
||||
+++ b/cmd/bootmenu.c
|
||||
@@ -103,11 +103,13 @@ static char *bootmenu_choice_entry(void
|
||||
|
||||
switch (key) {
|
||||
case BKEY_UP:
|
||||
+ menu->last_active = menu->active;
|
||||
if (menu->active > 0)
|
||||
--menu->active;
|
||||
/* no menu key selected, regenerate menu */
|
||||
return NULL;
|
||||
case BKEY_DOWN:
|
||||
+ menu->last_active = menu->active;
|
||||
if (menu->active < menu->count - 1)
|
||||
++menu->active;
|
||||
/* no menu key selected, regenerate menu */
|
||||
@@ -133,6 +135,17 @@ static char *bootmenu_choice_entry(void
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+static bool bootmenu_need_reprint(void *data)
|
||||
+{
|
||||
+ struct bootmenu_data *menu = data;
|
||||
+ bool need_reprint;
|
||||
+
|
||||
+ need_reprint = menu->last_active != menu->active;
|
||||
+ menu->last_active = menu->active;
|
||||
+
|
||||
+ return need_reprint;
|
||||
+}
|
||||
+
|
||||
static void bootmenu_destroy(struct bootmenu_data *menu)
|
||||
{
|
||||
struct bootmenu_entry *iter = menu->first;
|
||||
@@ -332,6 +345,7 @@ static struct bootmenu_data *bootmenu_cr
|
||||
|
||||
menu->delay = delay;
|
||||
menu->active = 0;
|
||||
+ menu->last_active = -1;
|
||||
menu->first = NULL;
|
||||
|
||||
default_str = env_get("bootmenu_default");
|
||||
@@ -506,7 +520,7 @@ static enum bootmenu_ret bootmenu_show(i
|
||||
|
||||
menu = menu_create(NULL, bootmenu->delay, 1, menu_display_statusline,
|
||||
bootmenu_print_entry, bootmenu_choice_entry,
|
||||
- NULL, bootmenu);
|
||||
+ bootmenu_need_reprint, bootmenu);
|
||||
if (!menu) {
|
||||
bootmenu_destroy(bootmenu);
|
||||
return BOOTMENU_RET_FAIL;
|
||||
--- a/include/menu.h
|
||||
+++ b/include/menu.h
|
||||
@@ -40,6 +40,7 @@ int menu_show(int bootdelay);
|
||||
struct bootmenu_data {
|
||||
int delay; /* delay for autoboot */
|
||||
int active; /* active menu entry */
|
||||
+ int last_active; /* last active menu entry */
|
||||
int count; /* total count of menu entries */
|
||||
struct bootmenu_entry *first; /* first menu entry */
|
||||
};
|
||||
@ -35,7 +35,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
@@ -112,6 +113,12 @@ static char *bootmenu_choice_entry(void
|
||||
@@ -114,6 +115,12 @@ static char *bootmenu_choice_entry(void
|
||||
++menu->active;
|
||||
/* no menu key selected, regenerate menu */
|
||||
return NULL;
|
||||
@ -48,7 +48,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
case BKEY_SELECT:
|
||||
iter = menu->first;
|
||||
for (i = 0; i < menu->active; ++i)
|
||||
@@ -169,6 +176,9 @@ static int prepare_bootmenu_entry(struct
|
||||
@@ -182,6 +189,9 @@ static int prepare_bootmenu_entry(struct
|
||||
unsigned short int i = *index;
|
||||
struct bootmenu_entry *entry = NULL;
|
||||
struct bootmenu_entry *iter = *current;
|
||||
@ -58,7 +58,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
|
||||
while ((option = bootmenu_getoption(i))) {
|
||||
|
||||
@@ -183,11 +193,24 @@ static int prepare_bootmenu_entry(struct
|
||||
@@ -196,11 +206,24 @@ static int prepare_bootmenu_entry(struct
|
||||
if (!entry)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -84,15 +84,15 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
|
||||
entry->command = strdup(sep + 1);
|
||||
if (!entry->command) {
|
||||
@@ -333,6 +356,7 @@ static struct bootmenu_data *bootmenu_cr
|
||||
menu->delay = delay;
|
||||
@@ -347,6 +370,7 @@ static struct bootmenu_data *bootmenu_cr
|
||||
menu->active = 0;
|
||||
menu->last_active = -1;
|
||||
menu->first = NULL;
|
||||
+ menu->last_choiced = false;
|
||||
|
||||
default_str = env_get("bootmenu_default");
|
||||
if (default_str)
|
||||
@@ -368,9 +392,9 @@ static struct bootmenu_data *bootmenu_cr
|
||||
@@ -382,9 +406,9 @@ static struct bootmenu_data *bootmenu_cr
|
||||
|
||||
/* Add Quit entry if exiting bootmenu is disabled */
|
||||
if (!IS_ENABLED(CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE))
|
||||
@ -106,7 +106,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
free(entry);
|
||||
--- a/common/menu.c
|
||||
+++ b/common/menu.c
|
||||
@@ -48,6 +48,33 @@ struct menu {
|
||||
@@ -49,6 +49,33 @@ struct menu {
|
||||
int item_cnt;
|
||||
};
|
||||
|
||||
@ -140,7 +140,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
/*
|
||||
* An iterator function for menu items. callback will be called for each item
|
||||
* in m, with m, a pointer to the item, and extra being passed to callback. If
|
||||
@@ -426,7 +453,7 @@ int menu_destroy(struct menu *m)
|
||||
@@ -437,7 +464,7 @@ int menu_destroy(struct menu *m)
|
||||
}
|
||||
|
||||
enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
|
||||
@ -149,7 +149,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
{
|
||||
enum bootmenu_key key = BKEY_NONE;
|
||||
int i, c;
|
||||
@@ -461,6 +488,19 @@ enum bootmenu_key bootmenu_autoboot_loop
|
||||
@@ -472,6 +499,19 @@ enum bootmenu_key bootmenu_autoboot_loop
|
||||
break;
|
||||
default:
|
||||
key = BKEY_NONE;
|
||||
@ -169,7 +169,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -481,7 +521,8 @@ enum bootmenu_key bootmenu_autoboot_loop
|
||||
@@ -492,7 +532,8 @@ enum bootmenu_key bootmenu_autoboot_loop
|
||||
return key;
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
{
|
||||
enum bootmenu_key key;
|
||||
|
||||
@@ -513,6 +554,20 @@ enum bootmenu_key bootmenu_conv_key(int
|
||||
@@ -524,6 +565,20 @@ enum bootmenu_key bootmenu_conv_key(int
|
||||
case ' ':
|
||||
key = BKEY_SPACE;
|
||||
break;
|
||||
@ -200,15 +200,16 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
default:
|
||||
key = BKEY_NONE;
|
||||
break;
|
||||
@@ -522,11 +577,16 @@ enum bootmenu_key bootmenu_conv_key(int
|
||||
@@ -533,11 +588,17 @@ enum bootmenu_key bootmenu_conv_key(int
|
||||
}
|
||||
|
||||
enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
|
||||
- struct cli_ch_state *cch)
|
||||
+ struct cli_ch_state *cch, int *choice)
|
||||
+ struct cli_ch_state *cch,
|
||||
+ int *choice)
|
||||
{
|
||||
enum bootmenu_key key;
|
||||
int c;
|
||||
int c, errchar = 0;
|
||||
|
||||
+ if (menu->last_choiced) {
|
||||
+ menu->last_choiced = false;
|
||||
@ -218,7 +219,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
c = cli_ch_process(cch, 0);
|
||||
if (!c) {
|
||||
while (!c && !tstc()) {
|
||||
@@ -540,7 +600,7 @@ enum bootmenu_key bootmenu_loop(struct b
|
||||
@@ -552,7 +613,7 @@ enum bootmenu_key bootmenu_loop(struct b
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,7 +239,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
struct cli_ch_state;
|
||||
struct menu;
|
||||
|
||||
@@ -19,6 +21,8 @@ int menu_get_choice(struct menu *m, void
|
||||
@@ -20,6 +22,8 @@ int menu_get_choice(struct menu *m, void
|
||||
int menu_item_add(struct menu *m, char *item_key, void *item_data);
|
||||
int menu_destroy(struct menu *m);
|
||||
int menu_default_choice(struct menu *m, void **choice);
|
||||
@ -247,15 +248,15 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
|
||||
/**
|
||||
* menu_show() Show a boot menu
|
||||
@@ -41,6 +45,7 @@ struct bootmenu_data {
|
||||
int active; /* active menu entry */
|
||||
@@ -43,6 +47,7 @@ struct bootmenu_data {
|
||||
int last_active; /* last active menu entry */
|
||||
int count; /* total count of menu entries */
|
||||
struct bootmenu_entry *first; /* first menu entry */
|
||||
+ bool last_choiced;
|
||||
};
|
||||
|
||||
/** enum bootmenu_key - keys that can be returned by the bootmenu */
|
||||
@@ -51,6 +56,7 @@ enum bootmenu_key {
|
||||
@@ -53,6 +58,7 @@ enum bootmenu_key {
|
||||
BKEY_SELECT,
|
||||
BKEY_QUIT,
|
||||
BKEY_SAVE,
|
||||
@ -263,7 +264,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
|
||||
/* 'extra' keys, which are used by menus but not cedit */
|
||||
BKEY_PLUS,
|
||||
@@ -81,7 +87,7 @@ enum bootmenu_key {
|
||||
@@ -83,7 +89,7 @@ enum bootmenu_key {
|
||||
* anything else: KEY_NONE
|
||||
*/
|
||||
enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
|
||||
@ -272,7 +273,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
|
||||
/**
|
||||
* bootmenu_loop() - handle waiting for a keypress when autoboot is disabled
|
||||
@@ -107,7 +113,7 @@ enum bootmenu_key bootmenu_autoboot_loop
|
||||
@@ -109,7 +115,7 @@ enum bootmenu_key bootmenu_autoboot_loop
|
||||
* Space: BKEY_SPACE
|
||||
*/
|
||||
enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
|
||||
@ -281,7 +282,7 @@ Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
||||
|
||||
/**
|
||||
* bootmenu_conv_key() - Convert a U-Boot keypress into a menu key
|
||||
@@ -115,6 +121,7 @@ enum bootmenu_key bootmenu_loop(struct b
|
||||
@@ -117,6 +123,7 @@ enum bootmenu_key bootmenu_loop(struct b
|
||||
* @ichar: Keypress to convert (ASCII, including control characters)
|
||||
* Returns: Menu key that corresponds to @ichar, or BKEY_NONE if none
|
||||
*/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
--- a/cmd/bootmenu.c
|
||||
+++ b/cmd/bootmenu.c
|
||||
@@ -451,7 +451,11 @@ static void menu_display_statusline(stru
|
||||
@@ -465,7 +465,11 @@ static void menu_display_statusline(stru
|
||||
printf(ANSI_CURSOR_POSITION, 1, 1);
|
||||
puts(ANSI_CLEAR_LINE);
|
||||
printf(ANSI_CURSOR_POSITION, 2, 3);
|
||||
@ -13,7 +13,7 @@
|
||||
puts(ANSI_CLEAR_LINE_TO_END);
|
||||
printf(ANSI_CURSOR_POSITION, 3, 1);
|
||||
puts(ANSI_CLEAR_LINE);
|
||||
@@ -536,6 +540,7 @@ static enum bootmenu_ret bootmenu_show(i
|
||||
@@ -550,6 +554,7 @@ static enum bootmenu_ret bootmenu_show(i
|
||||
return BOOTMENU_RET_FAIL;
|
||||
}
|
||||
|
||||
@ -23,8 +23,8 @@
|
||||
goto cleanup;
|
||||
--- a/include/menu.h
|
||||
+++ b/include/menu.h
|
||||
@@ -45,6 +45,7 @@ struct bootmenu_data {
|
||||
int active; /* active menu entry */
|
||||
@@ -47,6 +47,7 @@ struct bootmenu_data {
|
||||
int last_active; /* last active menu entry */
|
||||
int count; /* total count of menu entries */
|
||||
struct bootmenu_entry *first; /* first menu entry */
|
||||
+ char *mtitle; /* custom menu title */
|
||||
|
||||
@ -0,0 +1,308 @@
|
||||
--- /dev/null
|
||||
+++ b/configs/mt7988a_arcadyan_mozart_defconfig
|
||||
@@ -0,0 +1,119 @@
|
||||
+CONFIG_ARM=y
|
||||
+CONFIG_SYS_HAS_NONCACHED_MEMORY=y
|
||||
+CONFIG_POSITION_INDEPENDENT=y
|
||||
+CONFIG_ARCH_MEDIATEK=y
|
||||
+CONFIG_TEXT_BASE=0x41e00000
|
||||
+CONFIG_SYS_MALLOC_F_LEN=0x4000
|
||||
+CONFIG_NR_DRAM_BANKS=1
|
||||
+CONFIG_ENV_SIZE=0x40000
|
||||
+CONFIG_ENV_OFFSET=0x400000
|
||||
+CONFIG_DEFAULT_DEVICE_TREE="mt7988a-arcadyan-mozart"
|
||||
+CONFIG_OF_LIBFDT_OVERLAY=y
|
||||
+CONFIG_TARGET_MT7988=y
|
||||
+CONFIG_PRE_CON_BUF_ADDR=0x4007EF00
|
||||
+CONFIG_DEBUG_UART_BASE=0x11000000
|
||||
+CONFIG_DEBUG_UART_CLOCK=40000000
|
||||
+CONFIG_ENV_OFFSET_REDUND=0x440000
|
||||
+CONFIG_SYS_LOAD_ADDR=0x50000000
|
||||
+CONFIG_PCI=y
|
||||
+CONFIG_DEBUG_UART=y
|
||||
+CONFIG_AHCI=y
|
||||
+CONFIG_FIT=y
|
||||
+CONFIG_BOOTDELAY=30
|
||||
+CONFIG_AUTOBOOT_KEYED=y
|
||||
+CONFIG_AUTOBOOT_MENU_SHOW=y
|
||||
+CONFIG_OF_SYSTEM_SETUP=y
|
||||
+CONFIG_DEFAULT_FDT_FILE="mediatek/mt7988a-arcadyan-mozart.dtb"
|
||||
+CONFIG_SYS_CBSIZE=512
|
||||
+CONFIG_SYS_PBSIZE=1049
|
||||
+CONFIG_LOGLEVEL=7
|
||||
+CONFIG_PRE_CONSOLE_BUFFER=y
|
||||
+CONFIG_LOG=y
|
||||
+CONFIG_BOARD_LATE_INIT=y
|
||||
+CONFIG_HUSH_PARSER=y
|
||||
+CONFIG_SYS_PROMPT="MT7988> "
|
||||
+CONFIG_CMD_CPU=y
|
||||
+CONFIG_CMD_LICENSE=y
|
||||
+# CONFIG_CMD_BOOTEFI_BOOTMGR is not set
|
||||
+CONFIG_CMD_BOOTMENU=y
|
||||
+CONFIG_CMD_ASKENV=y
|
||||
+CONFIG_CMD_ERASEENV=y
|
||||
+CONFIG_CMD_ENV_FLAGS=y
|
||||
+CONFIG_CMD_STRINGS=y
|
||||
+CONFIG_CMD_DM=y
|
||||
+CONFIG_CMD_GPIO=y
|
||||
+CONFIG_CMD_PWM=y
|
||||
+CONFIG_CMD_GPT=y
|
||||
+CONFIG_CMD_MMC=y
|
||||
+CONFIG_CMD_MTD=y
|
||||
+CONFIG_CMD_PART=y
|
||||
+CONFIG_CMD_PCI=y
|
||||
+CONFIG_CMD_SF_TEST=y
|
||||
+CONFIG_CMD_USB=y
|
||||
+CONFIG_CMD_DHCP=y
|
||||
+CONFIG_CMD_TFTPSRV=y
|
||||
+CONFIG_CMD_RARP=y
|
||||
+CONFIG_CMD_PING=y
|
||||
+CONFIG_CMD_CDP=y
|
||||
+CONFIG_CMD_SNTP=y
|
||||
+CONFIG_CMD_DNS=y
|
||||
+CONFIG_CMD_LINK_LOCAL=y
|
||||
+CONFIG_CMD_PXE=y
|
||||
+CONFIG_CMD_CACHE=y
|
||||
+CONFIG_CMD_PSTORE=y
|
||||
+CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
|
||||
+CONFIG_CMD_UUID=y
|
||||
+CONFIG_CMD_HASH=y
|
||||
+CONFIG_CMD_SMC=y
|
||||
+CONFIG_CMD_EXT4=y
|
||||
+CONFIG_CMD_FAT=y
|
||||
+CONFIG_CMD_FS_GENERIC=y
|
||||
+CONFIG_CMD_FS_UUID=y
|
||||
+CONFIG_OF_EMBED=y
|
||||
+CONFIG_ENV_OVERWRITE=y
|
||||
+CONFIG_ENV_IS_IN_MMC=y
|
||||
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
|
||||
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
+CONFIG_USE_DEFAULT_ENV_FILE=y
|
||||
+CONFIG_DEFAULT_ENV_FILE="arcadyan_mozart_env"
|
||||
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
+CONFIG_VERSION_VARIABLE=y
|
||||
+CONFIG_NET_RANDOM_ETHADDR=y
|
||||
+CONFIG_NETCONSOLE=y
|
||||
+CONFIG_USE_IPADDR=y
|
||||
+CONFIG_IPADDR="192.168.1.1"
|
||||
+CONFIG_USE_SERVERIP=y
|
||||
+CONFIG_SERVERIP="192.168.1.254"
|
||||
+CONFIG_REGMAP=y
|
||||
+CONFIG_SYSCON=y
|
||||
+CONFIG_BUTTON=y
|
||||
+CONFIG_BUTTON_GPIO=y
|
||||
+CONFIG_CLK=y
|
||||
+CONFIG_GPIO_HOG=y
|
||||
+CONFIG_LED=y
|
||||
+CONFIG_LED_BLINK=y
|
||||
+CONFIG_LED_GPIO=y
|
||||
+CONFIG_SUPPORT_EMMC_BOOT=y
|
||||
+CONFIG_MMC_HS200_SUPPORT=y
|
||||
+CONFIG_MMC_MTK=y
|
||||
+CONFIG_PHY_FIXED=y
|
||||
+CONFIG_MEDIATEK_ETH=y
|
||||
+CONFIG_PHY=y
|
||||
+CONFIG_PHY_MTK_TPHY=y
|
||||
+CONFIG_PINCTRL=y
|
||||
+CONFIG_PINCONF=y
|
||||
+CONFIG_PINCTRL_MT7988=y
|
||||
+CONFIG_POWER_DOMAIN=y
|
||||
+CONFIG_MTK_POWER_DOMAIN=y
|
||||
+CONFIG_DM_REGULATOR=y
|
||||
+CONFIG_DM_REGULATOR_FIXED=y
|
||||
+CONFIG_DM_REGULATOR_GPIO=y
|
||||
+CONFIG_DM_PWM=y
|
||||
+CONFIG_PWM_MTK=y
|
||||
+CONFIG_RAM=y
|
||||
+CONFIG_SCSI=y
|
||||
+CONFIG_DM_SERIAL=y
|
||||
+CONFIG_MTK_SERIAL=y
|
||||
+CONFIG_ZSTD=y
|
||||
+CONFIG_HEXDUMP=y
|
||||
+CONFIG_LMB_MAX_REGIONS=64
|
||||
--- /dev/null
|
||||
+++ b/arcadyan_mozart_env
|
||||
@@ -0,0 +1,55 @@
|
||||
+ipaddr=192.168.1.1
|
||||
+serverip=192.168.1.254
|
||||
+loadaddr=0x50000000
|
||||
+bootargs=console=ttyS0,115200n1 pci=pcie_bus_perf root=/dev/fit0 rootwait
|
||||
+bootcmd=if pstore check ; then run boot_recovery ; else run boot_emmc ; fi
|
||||
+bootconf=config-1
|
||||
+bootconf_extra=
|
||||
+bootdelay=0
|
||||
+bootfile=openwrt-mediatek-filogic-arcadyan_mozart-initramfs.itb
|
||||
+bootfile_bl2=openwrt-mediatek-filogic-arcadyan_mozart-emmc-preloader.bin
|
||||
+bootfile_fip=openwrt-mediatek-filogic-arcadyan_mozart-emmc-bl31-uboot.fip
|
||||
+bootfile_upg=openwrt-mediatek-filogic-arcadyan_mozart-squashfs-sysupgrade.itb
|
||||
+bootled_pwr=blue:status
|
||||
+bootled_rec=red:status
|
||||
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
|
||||
+bootmenu_default=0
|
||||
+bootmenu_delay=0
|
||||
+bootmenu_title= [0;34m( ( ( [1;39mOpenWrt[0;34m ) ) ) [0;36m[eMMC][0m
|
||||
+bootmenu_0=Initialize environment.=run _firstboot
|
||||
+bootmenu_0d=Run default boot command.=run boot_default
|
||||
+bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
|
||||
+bootmenu_2=Boot production system from eMMC.=run boot_production ; run bootmenu_confirm_return
|
||||
+bootmenu_3=Boot recovery system from eMMC.=run boot_recovery ; run bootmenu_confirm_return
|
||||
+bootmenu_4=Load production system via TFTP then write to eMMC.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
|
||||
+bootmenu_5=Load recovery system via TFTP then write to eMMC.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
|
||||
+bootmenu_6=[31mLoad BL31+U-Boot FIP via TFTP then write to eMMC.[0m=run boot_tftp_write_fip ; run bootmenu_confirm_return
|
||||
+bootmenu_7=[31mLoad BL2 preloader via TFTP then write to eMMC.[0m=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
|
||||
+bootmenu_8=Reboot.=reset
|
||||
+bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
|
||||
+boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu
|
||||
+boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever
|
||||
+boot_production=led $bootled_pwr on ; run emmc_read_production && bootm $loadaddr#$bootconf#$bootconf_extra ; led $bootled_pwr off
|
||||
+boot_recovery=led $bootled_rec on ; run emmc_read_recovery && bootm $loadaddr#$bootconf#$bootconf_extra ; led $bootled_rec off
|
||||
+boot_emmc=run boot_production ; run boot_recovery
|
||||
+boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done
|
||||
+boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run emmc_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf#$bootconf_extra ; fi
|
||||
+boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run emmc_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
|
||||
+boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run emmc_write_fip
|
||||
+boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run emmc_write_bl2
|
||||
+boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
|
||||
+mmc_write_vol=imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc erase 0x$part_addr 0x$image_size && mmc write $loadaddr 0x$part_addr 0x$image_size
|
||||
+mmc_read_vol=mmc read $loadaddr $part_addr 0x100 && imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc read $loadaddr 0x$part_addr 0x$image_size && setexpr filesize $image_size * 0x200
|
||||
+part_default=production
|
||||
+part_recovery=recovery
|
||||
+reset_factory=eraseenv && reset
|
||||
+emmc_read_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_read_vol
|
||||
+emmc_read_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_read_vol
|
||||
+emmc_write_bl2=mmc partconf 0 1 1 1 && mmc erase 0x0 0x400 && mmc write $fileaddr 0x0 0x400 ; mmc partconf 0 1 1 0
|
||||
+emmc_write_fip=mmc erase 0x3400 0x2000 && mmc write $fileaddr 0x3400 0x2000 && mmc erase 0x2000 0x800
|
||||
+emmc_write_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_write_vol
|
||||
+emmc_write_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_write_vol
|
||||
+_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv
|
||||
+_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first
|
||||
+_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
|
||||
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title [33m$ver[0m"
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/dts/mt7988a-arcadyan-mozart.dts
|
||||
@@ -0,0 +1,125 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+
|
||||
+/dts-v1/;
|
||||
+#include "mt7988.dtsi"
|
||||
+#include <dt-bindings/gpio/gpio.h>
|
||||
+#include <dt-bindings/input/linux-event-codes.h>
|
||||
+
|
||||
+/ {
|
||||
+ model = "MediaTek / Arcadyan - Mozart";
|
||||
+ compatible = "arcadyan,mozart", "mediatek,mt7988";
|
||||
+
|
||||
+ chosen {
|
||||
+ stdout-path = &uart0;
|
||||
+ };
|
||||
+
|
||||
+ memory@40000000 {
|
||||
+ device_type = "memory";
|
||||
+ reg = <0 0x40000000 0 0x40000000>;
|
||||
+ };
|
||||
+
|
||||
+ 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_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;
|
||||
+ };
|
||||
+
|
||||
+ keys {
|
||||
+ compatible = "gpio-keys";
|
||||
+
|
||||
+ wps {
|
||||
+ label = "reset";
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ gpios = <&gpio 143 GPIO_ACTIVE_LOW>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ leds {
|
||||
+ compatible = "gpio-leds";
|
||||
+
|
||||
+ led-red {
|
||||
+ label = "red:status";
|
||||
+ gpios = <&gpio 29 GPIO_ACTIVE_HIGH>;
|
||||
+ };
|
||||
+
|
||||
+ led-green {
|
||||
+ label = "blue:status";
|
||||
+ gpios = <&gpio 30 GPIO_ACTIVE_HIGH>;
|
||||
+ };
|
||||
+
|
||||
+ led-blue {
|
||||
+ label = "blue:status";
|
||||
+ gpios = <&gpio 31 GPIO_ACTIVE_HIGH>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&uart0 {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+ð {
|
||||
+ status = "okay";
|
||||
+ mediatek,gmac-id = <0>;
|
||||
+ phy-mode = "usxgmii";
|
||||
+ mediatek,switch = "mt7988";
|
||||
+
|
||||
+ fixed-link {
|
||||
+ speed = <1000>;
|
||||
+ full-duplex;
|
||||
+ pause;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&pinctrl {
|
||||
+ mmc0_pins_default: mmc0default {
|
||||
+ mux {
|
||||
+ function = "flash";
|
||||
+ 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;
|
||||
+ };
|
||||
+
|
||||
+ conf-clk {
|
||||
+ pins = "EMMC_CK";
|
||||
+ };
|
||||
+
|
||||
+ conf-dsl {
|
||||
+ pins = "EMMC_DSL";
|
||||
+ };
|
||||
+
|
||||
+ conf-rst {
|
||||
+ pins = "EMMC_RSTB";
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&mmc0 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&mmc0_pins_default>;
|
||||
+ max-frequency = <52000000>;
|
||||
+ bus-width = <8>;
|
||||
+ cap-mmc-highspeed;
|
||||
+ cap-mmc-hw-reset;
|
||||
+ vmmc-supply = <®_3p3v>;
|
||||
+ vqmmc-supply = <®_1p8v>;
|
||||
+ non-removable;
|
||||
+ status = "okay";
|
||||
+};
|
||||
@ -3,6 +3,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=nu801
|
||||
PKG_FLAGS:=nonshared
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
@ -450,7 +450,7 @@
|
||||
|
||||
band@1 {
|
||||
reg = <1>;
|
||||
nvmem-cells = <&macaddr_factory_4 1>;
|
||||
nvmem-cells = <&macaddr_factory_4 7>;
|
||||
nvmem-cell-names = "mac-address";
|
||||
};
|
||||
};
|
||||
|
||||
336
target/linux/mediatek/dts/mt7988a-arcadyan-mozart.dts
Normal file
336
target/linux/mediatek/dts/mt7988a-arcadyan-mozart.dts
Normal file
@ -0,0 +1,336 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
|
||||
|
||||
/dts-v1/;
|
||||
#include "mt7988a-rfb.dts"
|
||||
#include <dt-bindings/input/input.h>
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
#include <dt-bindings/leds/common.h>
|
||||
|
||||
/ {
|
||||
compatible = "arcadyan,mozart", "mediatek,mt7988a";
|
||||
model = "MediaTek / Arcadyan - Mozart";
|
||||
|
||||
aliases {
|
||||
serial0 = &uart0;
|
||||
led-boot = &led_status_blue;
|
||||
led-failsafe = &led_status_red;
|
||||
led-running = &led_status_green;
|
||||
led-upgrade = &led_status_green;
|
||||
};
|
||||
|
||||
chosen {
|
||||
rootdisk = <&emmc_rootfs>;
|
||||
};
|
||||
|
||||
gpio-leds {
|
||||
compatible = "gpio-leds";
|
||||
|
||||
wifi_white {
|
||||
color = <LED_COLOR_ID_WHITE>;
|
||||
function = LED_FUNCTION_STATUS;
|
||||
gpios = <&pio 68 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
led_status_red: wifi_red {
|
||||
color = <LED_COLOR_ID_RED>;
|
||||
function = LED_FUNCTION_STATUS;
|
||||
gpios = <&pio 29 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
led_status_green: wifi_green {
|
||||
color = <LED_COLOR_ID_GREEN>;
|
||||
function = LED_FUNCTION_STATUS;
|
||||
gpios = <&pio 30 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
led_status_blue: wifi_blue {
|
||||
color = <LED_COLOR_ID_BLUE>;
|
||||
function = LED_FUNCTION_STATUS;
|
||||
gpios = <&pio 31 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
};
|
||||
|
||||
keys {
|
||||
compatible = "gpio-keys";
|
||||
|
||||
button-reset {
|
||||
label = "reset";
|
||||
linux,code = <KEY_RESTART>;
|
||||
gpios = <&pio 13 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&pio {
|
||||
mdio0_pins: mdio0-pins {
|
||||
mux {
|
||||
function = "eth";
|
||||
groups = "mdc_mdio0";
|
||||
};
|
||||
|
||||
conf {
|
||||
groups = "mdc_mdio0";
|
||||
drive-strength = <MTK_DRIVE_10mA>;
|
||||
};
|
||||
};
|
||||
|
||||
spic_pins: spi1-pins {
|
||||
mux {
|
||||
function = "spi";
|
||||
groups = "spi1";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&usxgmiisys0 {
|
||||
mediatek,pnswap-rx;
|
||||
};
|
||||
|
||||
&usxgmiisys1 {
|
||||
mediatek,pnswap-rx;
|
||||
};
|
||||
|
||||
&mdio_bus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reset-gpios = <&pio 72 GPIO_ACTIVE_LOW>;
|
||||
reset-assert-us = <100000>;
|
||||
reset-deassert-us = <100000>;
|
||||
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
compatible = "ethernet-phy-ieee802.3-c45";
|
||||
};
|
||||
|
||||
phy8: ethernet-phy@8 {
|
||||
reg = <8>;
|
||||
compatible = "ethernet-phy-ieee802.3-c45";
|
||||
};
|
||||
};
|
||||
|
||||
&gmac0 {
|
||||
nvmem-cells = <&macaddr_factory_4 3>;
|
||||
nvmem-cell-names = "mac-address";
|
||||
};
|
||||
|
||||
&gmac1 {
|
||||
phy-mode = "usxgmii";
|
||||
phy-connection-type = "usxgmii";
|
||||
phy = <&phy0>;
|
||||
nvmem-cells = <&macaddr_factory_4 4>;
|
||||
nvmem-cell-names = "mac-address";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&gmac2 {
|
||||
phy-mode = "usxgmii";
|
||||
phy-connection-type = "usxgmii";
|
||||
phy = <&phy8>;
|
||||
nvmem-cells = <&macaddr_factory_4 5>;
|
||||
nvmem-cell-names = "mac-address";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&switch {
|
||||
/delete-node/ports;
|
||||
|
||||
ports {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
gsw_port0: port@0 {
|
||||
reg = <0>;
|
||||
label = "lan0";
|
||||
phy-mode = "internal";
|
||||
phy-handle = <&gsw_phy0>;
|
||||
};
|
||||
|
||||
port@6 {
|
||||
reg = <6>;
|
||||
ethernet = <&gmac0>;
|
||||
phy-mode = "internal";
|
||||
|
||||
fixed-link {
|
||||
speed = <10000>;
|
||||
full-duplex;
|
||||
pause;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&i2c1_pins>;
|
||||
clock-frequency = <100000>;
|
||||
status = "okay";
|
||||
|
||||
icp201xx@63{
|
||||
compatible = "invensense,icp201xx";
|
||||
reg = <0x63>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
&uart1 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&fan {
|
||||
pwms = <&pwm 1 40000 0>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&pwm {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
pinctrl-names = "default";
|
||||
/* pin shared with snfi */
|
||||
pinctrl-0 = <&spic_pins>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&mmc0 {
|
||||
pinctrl-names = "default", "state_uhs";
|
||||
pinctrl-0 = <&mmc0_pins_emmc_51>;
|
||||
pinctrl-1 = <&mmc0_pins_emmc_51>;
|
||||
bus-width = <8>;
|
||||
max-frequency = <200000000>;
|
||||
cap-mmc-highspeed;
|
||||
mmc-hs200-1_8v;
|
||||
mmc-hs400-1_8v;
|
||||
hs400-ds-delay = <0x12814>;
|
||||
vqmmc-supply = <®_1p8v>;
|
||||
vmmc-supply = <®_3p3v>;
|
||||
non-removable;
|
||||
no-sd;
|
||||
no-sdio;
|
||||
status = "okay";
|
||||
|
||||
card@0 {
|
||||
compatible = "mmc-card";
|
||||
reg = <0>;
|
||||
|
||||
block {
|
||||
compatible = "block-device";
|
||||
partitions {
|
||||
block-partition-env {
|
||||
partname = "u-boot-env";
|
||||
nvmem-layout {
|
||||
compatible = "u-boot,env-layout";
|
||||
};
|
||||
};
|
||||
|
||||
emmc_rootfs: block-partition-production {
|
||||
partname = "production";
|
||||
};
|
||||
|
||||
block-partition-factory {
|
||||
partname = "factory";
|
||||
|
||||
nvmem-layout {
|
||||
compatible = "fixed-layout";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
eeprom_factory_0: eeprom@0 {
|
||||
reg = <0x0 0x1e00>;
|
||||
};
|
||||
|
||||
macaddr_factory_4: macaddr@a {
|
||||
compatible = "mac-base";
|
||||
reg = <0x4 0x6>;
|
||||
#nvmem-cell-cells = <1>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&cpu_thermal {
|
||||
/delete-node/cooling-maps;
|
||||
/delete-node/trips;
|
||||
|
||||
trips {
|
||||
cpu_trip_crit: crit {
|
||||
temperature = <125000>;
|
||||
hysteresis = <2000>;
|
||||
type = "critical";
|
||||
};
|
||||
|
||||
cpu_trip_hot: hot {
|
||||
temperature = <120000>;
|
||||
hysteresis = <2000>;
|
||||
type = "hot";
|
||||
};
|
||||
|
||||
cpu_trip_active_high: active-high {
|
||||
temperature = <110000>;
|
||||
hysteresis = <2000>;
|
||||
type = "active";
|
||||
};
|
||||
|
||||
cpu_trip_active_med: active-med {
|
||||
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";
|
||||
};
|
||||
};
|
||||
|
||||
cooling-maps {
|
||||
cpu-active-high {
|
||||
/* active: set fan to cooling level 3 */
|
||||
cooling-device = <&fan 3 3>;
|
||||
trip = <&cpu_trip_active_high>;
|
||||
};
|
||||
|
||||
cpu-active-med {
|
||||
/* active: set fan to cooling level 2 */
|
||||
cooling-device = <&fan 2 2>;
|
||||
trip = <&cpu_trip_active_med>;
|
||||
};
|
||||
|
||||
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>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&pcie0 {
|
||||
status = "okay";
|
||||
|
||||
pcie@0,0 {
|
||||
reg = <0x0000 0 0 0 0>;
|
||||
|
||||
mt7996@1,0 {
|
||||
reg = <0x0000 0 0 0 0>;
|
||||
nvmem-cells = <&eeprom_factory_0>;
|
||||
nvmem-cell-names = "eeprom";
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -297,11 +297,22 @@
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&pio {
|
||||
pwm0_pins: pwm0-pins {
|
||||
mux {
|
||||
groups = "pwm0";
|
||||
function = "pwm";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&pwm {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&fan {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&pwm0_pins>;
|
||||
pwms = <&pwm 0 50000>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
|
||||
config RTL8261N_PHY
|
||||
tristate "Driver for Realtek RTL8261N PHYs"
|
||||
help
|
||||
Currently supports the RTL8261N,RTL8264B PHYs.
|
||||
@ -0,0 +1,11 @@
|
||||
|
||||
obj-$(CONFIG_RTL8261N_PHY) += rtl8621n.o
|
||||
|
||||
rtl8621n-objs += phy_patch.o
|
||||
rtl8621n-objs += phy_rtl826xb_patch.o
|
||||
rtl8621n-objs += rtk_osal.o
|
||||
rtl8621n-objs += rtk_phy.o
|
||||
rtl8621n-objs += rtk_phylib.o
|
||||
rtl8621n-objs += rtk_phylib_rtl826xb.o
|
||||
|
||||
ccflags-y += -Werror -DRTK_PHYDRV_IN_LINUX
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
165
target/linux/mediatek/files-6.6/drivers/net/phy/rtl8261n/error.h
Normal file
165
target/linux/mediatek/files-6.6/drivers/net/phy/rtl8261n/error.h
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_ERROR_H__
|
||||
#define __COMMON_ERROR_H__
|
||||
|
||||
/*
|
||||
* Include Files
|
||||
*/
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
#include "type.h"
|
||||
#else
|
||||
#include <common/type.h>
|
||||
#endif
|
||||
/*
|
||||
* Data Type Declaration
|
||||
*/
|
||||
typedef enum rt_error_common_e
|
||||
{
|
||||
RT_ERR_FAILED = -1, /* General Error */
|
||||
|
||||
/* 0x0000xxxx for common error code */
|
||||
RT_ERR_OK = 0, /* 0x00000000, OK */
|
||||
RT_ERR_INPUT = 0xF001, /* 0x0000F001, invalid input parameter */
|
||||
RT_ERR_UNIT_ID, /* 0x0000F002, invalid unit id */
|
||||
RT_ERR_PORT_ID, /* 0x0000F003, invalid port id */
|
||||
RT_ERR_PORT_MASK, /* 0x0000F004, invalid port mask */
|
||||
RT_ERR_PORT_LINKDOWN, /* 0x0000F005, link down port status */
|
||||
RT_ERR_ENTRY_INDEX, /* 0x0000F006, invalid entry index */
|
||||
RT_ERR_NULL_POINTER, /* 0x0000F007, input parameter is null pointer */
|
||||
RT_ERR_QUEUE_ID, /* 0x0000F008, invalid queue id */
|
||||
RT_ERR_QUEUE_NUM, /* 0x0000F009, invalid queue number */
|
||||
RT_ERR_BUSYWAIT_TIMEOUT, /* 0x0000F00a, busy watting time out */
|
||||
RT_ERR_MAC, /* 0x0000F00b, invalid mac address */
|
||||
RT_ERR_OUT_OF_RANGE, /* 0x0000F00c, input parameter out of range */
|
||||
RT_ERR_CHIP_NOT_SUPPORTED, /* 0x0000F00d, functions not supported by this chip model */
|
||||
RT_ERR_SMI, /* 0x0000F00e, SMI error */
|
||||
RT_ERR_NOT_INIT, /* 0x0000F00f, The module is not initial */
|
||||
RT_ERR_CHIP_NOT_FOUND, /* 0x0000F010, The chip can not found */
|
||||
RT_ERR_NOT_ALLOWED, /* 0x0000F011, actions not allowed by the function */
|
||||
RT_ERR_DRIVER_NOT_FOUND, /* 0x0000F012, The driver can not found */
|
||||
RT_ERR_SEM_LOCK_FAILED, /* 0x0000F013, Failed to lock semaphore */
|
||||
RT_ERR_SEM_UNLOCK_FAILED, /* 0x0000F014, Failed to unlock semaphore */
|
||||
RT_ERR_THREAD_EXIST, /* 0x0000F015, Thread exist */
|
||||
RT_ERR_THREAD_CREATE_FAILED, /* 0x0000F016, Thread create fail */
|
||||
RT_ERR_FWD_ACTION, /* 0x0000F017, Invalid forwarding Action */
|
||||
RT_ERR_IPV4_ADDRESS, /* 0x0000F018, Invalid IPv4 address */
|
||||
RT_ERR_IPV6_ADDRESS, /* 0x0000F019, Invalid IPv6 address */
|
||||
RT_ERR_PRIORITY, /* 0x0000F01a, Invalid Priority value */
|
||||
RT_ERR_FID, /* 0x0000F01b, invalid fid */
|
||||
RT_ERR_ENTRY_NOTFOUND, /* 0x0000F01c, specified entry not found */
|
||||
RT_ERR_DROP_PRECEDENCE, /* 0x0000F01d, invalid drop precedence */
|
||||
RT_ERR_NOT_FINISH, /* 0x0000F01e, Action not finish, still need to wait */
|
||||
RT_ERR_TIMEOUT, /* 0x0000F01f, Time out */
|
||||
RT_ERR_REG_ARRAY_INDEX_1, /* 0x0000F020, invalid index 1 of register array */
|
||||
RT_ERR_REG_ARRAY_INDEX_2, /* 0x0000F021, invalid index 2 of register array */
|
||||
RT_ERR_ETHER_TYPE, /* 0x0000F022, invalid ether type */
|
||||
RT_ERR_MBUF_PKT_NOT_AVAILABLE, /* 0x0000F023, mbuf->packet is not available */
|
||||
RT_ERR_QOS_INVLD_RSN, /* 0x0000F024, invalid pkt to CPU reason */
|
||||
RT_ERR_CB_FUNCTION_EXIST, /* 0x0000F025, Callback function exist */
|
||||
RT_ERR_CB_FUNCTION_FULL, /* 0x0000F026, Callback function number is full */
|
||||
RT_ERR_CB_FUNCTION_NOT_FOUND, /* 0x0000F027, Callback function can not found */
|
||||
RT_ERR_TBL_FULL, /* 0x0000F028, The table is full */
|
||||
RT_ERR_TRUNK_ID, /* 0x0000F029, invalid trunk id */
|
||||
RT_ERR_TYPE, /* 0x0000F02a, invalid type */
|
||||
RT_ERR_ENTRY_EXIST, /* 0x0000F02b, entry exists */
|
||||
RT_ERR_CHIP_UNDEFINED_VALUE, /* 0x0000F02c, chip returned an undefined value */
|
||||
RT_ERR_EXCEEDS_CAPACITY, /* 0x0000F02d, exceeds the capacity of hardware */
|
||||
RT_ERR_ENTRY_REFERRED, /* 0x0000F02e, entry is still being referred */
|
||||
RT_ERR_OPER_DENIED, /* 0x0000F02f, operation denied */
|
||||
RT_ERR_PORT_NOT_SUPPORTED, /* 0x0000F030, functions not supported by this port */
|
||||
RT_ERR_SOCKET, /* 0x0000F031, socket error */
|
||||
RT_ERR_MEM_ALLOC, /* 0x0000F032, insufficient memory resource */
|
||||
RT_ERR_ABORT, /* 0x0000F033, operation aborted */
|
||||
RT_ERR_DEV_ID, /* 0x0000F034, invalid device id */
|
||||
RT_ERR_DRIVER_NOT_SUPPORTED, /* 0x0000F035, functions not supported by this driver */
|
||||
RT_ERR_NOT_SUPPORTED, /* 0x0000F036, functions not supported */
|
||||
RT_ERR_SER, /* 0x0000F037, ECC or parity error */
|
||||
RT_ERR_MEM_NOT_ALIGN, /* 0x0000F038, memory address is not aligned */
|
||||
RT_ERR_SEM_FAKELOCK_OK, /* 0x0000F039, attach thread lock a semaphore which was already locked */
|
||||
RT_ERR_CHECK_FAILED, /* 0x0000F03a, check result is failed */
|
||||
|
||||
RT_ERR_COMMON_END = 0xFFFF /* The symbol is the latest symbol of common error */
|
||||
} rt_error_common_t;
|
||||
|
||||
/*
|
||||
* Macro Definition
|
||||
*/
|
||||
#define RT_PARAM_CHK(expr, errCode)\
|
||||
do {\
|
||||
if ((int32)(expr)) {\
|
||||
return errCode; \
|
||||
}\
|
||||
} while (0)
|
||||
|
||||
#define RT_PARAM_CHK_EHDL(expr, errCode, err_hdl)\
|
||||
do {\
|
||||
if ((int32)(expr)) {\
|
||||
{err_hdl}\
|
||||
return errCode; \
|
||||
}\
|
||||
} while (0)
|
||||
|
||||
#define RT_INIT_CHK(state)\
|
||||
do {\
|
||||
if (INIT_COMPLETED != (state)) {\
|
||||
return RT_ERR_NOT_INIT;\
|
||||
}\
|
||||
} while (0)
|
||||
|
||||
#define RT_INIT_REENTRY_CHK(state)\
|
||||
do {\
|
||||
if (INIT_COMPLETED == (state)) {\
|
||||
osal_printf(" %s had already been initialized!\n", __FUNCTION__);\
|
||||
return RT_ERR_OK;\
|
||||
}\
|
||||
} while (0)
|
||||
|
||||
#define RT_INIT_REENTRY_CHK_NO_WARNING(state)\
|
||||
do {\
|
||||
if (INIT_COMPLETED == (state)) {\
|
||||
return RT_ERR_OK;\
|
||||
}\
|
||||
} while (0)
|
||||
|
||||
#define RT_ERR_CHK(op, ret)\
|
||||
do {\
|
||||
if ((ret = (op)) != RT_ERR_OK)\
|
||||
return ret;\
|
||||
} while(0)
|
||||
|
||||
#define RT_ERR_HDL(op, errHandle, ret)\
|
||||
do {\
|
||||
if ((ret = (op)) != RT_ERR_OK)\
|
||||
goto errHandle;\
|
||||
} while(0)
|
||||
|
||||
#define RT_ERR_CHK_EHDL(op, ret, err_hdl)\
|
||||
do {\
|
||||
if ((ret = (op)) != RT_ERR_OK)\
|
||||
{\
|
||||
{err_hdl}\
|
||||
return ret;\
|
||||
}\
|
||||
} while(0)
|
||||
|
||||
#define RT_NULL_HDL(pointer, err_label)\
|
||||
do {\
|
||||
if (NULL == (pointer)) {\
|
||||
goto err_label;\
|
||||
}\
|
||||
} while (0)
|
||||
|
||||
#define RT_ERR_VOID_CHK(op, ret)\
|
||||
do {\
|
||||
if ((ret = (op)) != RT_ERR_OK) {\
|
||||
osal_printf("Fail in %s %d, ret %x!\n", __FUNCTION__, __LINE__, ret);\
|
||||
return ;}\
|
||||
} while(0)
|
||||
|
||||
#endif /* __COMMON_ERROR_H__ */
|
||||
|
||||
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include Files
|
||||
*/
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
#include "rtk_osal.h"
|
||||
#else
|
||||
#include <common/rt_type.h>
|
||||
#include <common/rt_error.h>
|
||||
#include <common/debug/rt_log.h>
|
||||
#include <hal/common/halctrl.h>
|
||||
#include <hal/phy/phy_patch.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Function Declaration
|
||||
*/
|
||||
uint8 phy_patch_op_translate(uint8 patch_mode, uint8 patch_op, uint8 compare_op)
|
||||
{
|
||||
if (patch_mode != PHY_PATCH_MODE_CMP)
|
||||
{
|
||||
return patch_op;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (compare_op)
|
||||
{
|
||||
case RTK_PATCH_CMP_WS:
|
||||
return RTK_PATCH_OP_SKIP;
|
||||
case RTK_PATCH_CMP_W:
|
||||
case RTK_PATCH_CMP_WC:
|
||||
case RTK_PATCH_CMP_SWC:
|
||||
default:
|
||||
return RTK_PATCH_OP_TO_CMP(patch_op, compare_op);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32 phy_patch_op(rt_phy_patch_db_t *pPhy_patchDb, uint32 unit, rtk_port_t port, uint8 portOffset, uint8 patch_op, uint16 portmask, uint16 pagemmd, uint16 addr, uint8 msb, uint8 lsb, uint16 data, uint8 patch_mode)
|
||||
{
|
||||
rtk_hwpatch_t op;
|
||||
|
||||
op.patch_op = patch_op;
|
||||
op.portmask = portmask;
|
||||
op.pagemmd = pagemmd;
|
||||
op.addr = addr;
|
||||
op.msb = msb;
|
||||
op.lsb = lsb;
|
||||
op.data = data;
|
||||
op.compare_op = RTK_PATCH_CMP_W;
|
||||
|
||||
return pPhy_patchDb->fPatch_op(unit, port, portOffset, &op, patch_mode);
|
||||
}
|
||||
|
||||
static int32 _phy_patch_process(uint32 unit, rtk_port_t port, uint8 portOffset, rtk_hwpatch_t *pPatch, int32 size, uint8 patch_mode)
|
||||
{
|
||||
int32 i = 0;
|
||||
int32 ret = 0;
|
||||
int32 chk_ret = RT_ERR_OK;
|
||||
int32 n;
|
||||
rtk_hwpatch_t *patch = pPatch;
|
||||
rt_phy_patch_db_t *pPatchDb = NULL;
|
||||
|
||||
PHYPATCH_DB_GET(unit, port, pPatchDb);
|
||||
|
||||
if (size <= 0)
|
||||
{
|
||||
return RT_ERR_OK;
|
||||
}
|
||||
n = size / sizeof(rtk_hwpatch_t);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
ret = pPatchDb->fPatch_op(unit, port, portOffset, &patch[i], patch_mode);
|
||||
if ((ret != RT_ERR_ABORT) && (ret != RT_ERR_OK))
|
||||
{
|
||||
if ((ret == RT_ERR_CHECK_FAILED) && (patch_mode == PHY_PATCH_MODE_CMP))
|
||||
{
|
||||
osal_printf("PATCH CHECK: Failed entry:%u|%u|0x%X|0x%X|%u|%u|0x%X\n",
|
||||
i + 1, patch[i].patch_op, patch[i].pagemmd, patch[i].addr, patch[i].msb, patch[i].lsb, patch[i].data);
|
||||
chk_ret = RT_ERR_CHECK_FAILED;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
RT_LOG(LOG_MAJOR_ERR, (MOD_HAL | MOD_PHY), "U%u P%u %s failed! %u[%u][0x%X][0x%X][0x%X] ret=0x%X\n", unit, port, __FUNCTION__,
|
||||
i+1, patch[i].patch_op, patch[i].pagemmd, patch[i].addr, patch[i].data, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return (chk_ret == RT_ERR_CHECK_FAILED) ? chk_ret : RT_ERR_OK;
|
||||
}
|
||||
|
||||
/* Function Name:
|
||||
* phy_patch
|
||||
* Description:
|
||||
* apply initial patch data to PHY
|
||||
* Input:
|
||||
* unit - unit id
|
||||
* port - port id
|
||||
* portOffset - the index offset of port based the base port in the PHY chip
|
||||
* Output:
|
||||
* None
|
||||
* Return:
|
||||
* RT_ERR_OK
|
||||
* RT_ERR_FAILED
|
||||
* RT_ERR_CHECK_FAILED
|
||||
* RT_ERR_NOT_SUPPORTED
|
||||
* Note:
|
||||
* None
|
||||
*/
|
||||
int32 phy_patch(uint32 unit, rtk_port_t port, uint8 portOffset, uint8 patch_mode)
|
||||
{
|
||||
int32 ret = RT_ERR_OK;
|
||||
int32 chk_ret = RT_ERR_OK;
|
||||
uint32 i = 0;
|
||||
uint8 patch_type = 0;
|
||||
rt_phy_patch_db_t *pPatchDb = NULL;
|
||||
rtk_hwpatch_seq_t *table = NULL;
|
||||
|
||||
PHYPATCH_DB_GET(unit, port, pPatchDb);
|
||||
|
||||
if ((pPatchDb == NULL) || (pPatchDb->fPatch_op == NULL) || (pPatchDb->fPatch_flow == NULL))
|
||||
{
|
||||
RT_LOG(LOG_MAJOR_ERR, (MOD_HAL | MOD_PHY), "U%u P%u phy_patch, db is NULL\n", unit, port);
|
||||
return RT_ERR_DRIVER_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (patch_mode == PHY_PATCH_MODE_CMP)
|
||||
{
|
||||
table = pPatchDb->cmp_table;
|
||||
}
|
||||
else
|
||||
{
|
||||
table = pPatchDb->seq_table;
|
||||
}
|
||||
RT_LOG(LOG_INFO, (MOD_HAL | MOD_PHY), "phy_patch: U%u P%u portOffset:%u patch_mode:%u\n", unit, port, portOffset, patch_mode);
|
||||
|
||||
for (i = 0; i < RTK_PATCH_SEQ_MAX; i++)
|
||||
{
|
||||
patch_type = table[i].patch_type;
|
||||
RT_LOG(LOG_INFO, (MOD_HAL | MOD_PHY), "phy_patch: table[%u] patch_type:%u\n", i, patch_type);
|
||||
|
||||
if (RTK_PATCH_TYPE_IS_DATA(patch_type))
|
||||
{
|
||||
ret = _phy_patch_process(unit, port, portOffset, table[i].patch.data.conf, table[i].patch.data.size, patch_mode);
|
||||
|
||||
if (ret == RT_ERR_CHECK_FAILED)
|
||||
chk_ret = ret;
|
||||
else if (ret != RT_ERR_OK)
|
||||
{
|
||||
RT_LOG(LOG_MAJOR_ERR, (MOD_HAL | MOD_PHY), "U%u P%u patch_mode:%u id:%u patch-%u failed. ret:0x%X\n", unit, port, patch_mode, i, patch_type, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else if (RTK_PATCH_TYPE_IS_FLOW(patch_type))
|
||||
{
|
||||
RT_ERR_CHK_EHDL(pPatchDb->fPatch_flow(unit, port, portOffset, table[i].patch.flow_id, patch_mode),
|
||||
ret, RT_LOG(LOG_MAJOR_ERR, (MOD_HAL | MOD_PHY), "U%u P%u patch_mode:%u id:%u patch-%u failed. ret:0x%X\n", unit, port, patch_mode, i, patch_type, ret););
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (chk_ret == RT_ERR_CHECK_FAILED) ? chk_ret : RT_ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,174 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __HAL_PHY_PATCH_H__
|
||||
#define __HAL_PHY_PATCH_H__
|
||||
|
||||
/*
|
||||
* Include Files
|
||||
*/
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
#include "rtk_phylib_def.h"
|
||||
#else
|
||||
#include <common/rt_type.h>
|
||||
#include <common/rt_autoconf.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Symbol Definition
|
||||
*/
|
||||
#define PHYPATCH_PHYCTRL_IN_HALCTRL 0 /* 3.6.x: 1 ,4.0.x: 1, 4.1.x+: 0 */
|
||||
#define PHYPATCH_FMAILY_IN_HWP 0 /* 3.6.x: 1 ,4.0.x: 0, 4.1.x+: 0 */
|
||||
#define PHY_PATCH_MODE_BCAST_DEFAULT PHY_PATCH_MODE_BCAST /* 3.6.x: PHY_PATCH_MODE_BCAST_BUS ,4.0.x+: PHY_PATCH_MODE_BCAST */
|
||||
|
||||
#define PHY_PATCH_MODE_NORMAL 0
|
||||
#define PHY_PATCH_MODE_CMP 1
|
||||
#define PHY_PATCH_MODE_BCAST 2
|
||||
#define PHY_PATCH_MODE_BCAST_BUS 3
|
||||
|
||||
#define RTK_PATCH_CMP_W 0 /* write */
|
||||
#define RTK_PATCH_CMP_WC 1 /* compare */
|
||||
#define RTK_PATCH_CMP_SWC 2 /* sram compare */
|
||||
#define RTK_PATCH_CMP_WS 3 /* skip */
|
||||
|
||||
#define RTK_PATCH_OP_SECTION_SIZE 50
|
||||
#define RTK_PATCH_OP_TO_CMP(_op, _cmp) (_op + (RTK_PATCH_OP_SECTION_SIZE * _cmp))
|
||||
/* 0~49 normal op */
|
||||
#define RTK_PATCH_OP_PHY 0
|
||||
#define RTK_PATCH_OP_PHYOCP 1
|
||||
#define RTK_PATCH_OP_TOP 2
|
||||
#define RTK_PATCH_OP_TOPOCP 3
|
||||
#define RTK_PATCH_OP_PSDS0 4
|
||||
#define RTK_PATCH_OP_PSDS1 5
|
||||
#define RTK_PATCH_OP_MSDS 6
|
||||
#define RTK_PATCH_OP_MAC 7
|
||||
|
||||
/* 50~99 normal op for compare */
|
||||
#define RTK_PATCH_OP_CMP_PHY RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_PHY , RTK_PATCH_CMP_WC)
|
||||
#define RTK_PATCH_OP_CMP_PHYOCP RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_PHYOCP , RTK_PATCH_CMP_WC)
|
||||
#define RTK_PATCH_OP_CMP_TOP RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_TOP , RTK_PATCH_CMP_WC)
|
||||
#define RTK_PATCH_OP_CMP_TOPOCP RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_TOPOCP , RTK_PATCH_CMP_WC)
|
||||
#define RTK_PATCH_OP_CMP_PSDS0 RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_PSDS0 , RTK_PATCH_CMP_WC)
|
||||
#define RTK_PATCH_OP_CMP_PSDS1 RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_PSDS1 , RTK_PATCH_CMP_WC)
|
||||
#define RTK_PATCH_OP_CMP_MSDS RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_MSDS , RTK_PATCH_CMP_WC)
|
||||
#define RTK_PATCH_OP_CMP_MAC RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_MAC , RTK_PATCH_CMP_WC)
|
||||
|
||||
/* 100~149 normal op for sram compare */
|
||||
#define RTK_PATCH_OP_CMP_SRAM_PHY RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_PHY , RTK_PATCH_CMP_SWC)
|
||||
#define RTK_PATCH_OP_CMP_SRAM_PHYOCP RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_PHYOCP , RTK_PATCH_CMP_SWC)
|
||||
#define RTK_PATCH_OP_CMP_SRAM_TOP RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_TOP , RTK_PATCH_CMP_SWC)
|
||||
#define RTK_PATCH_OP_CMP_SRAM_TOPOCP RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_TOPOCP , RTK_PATCH_CMP_SWC)
|
||||
#define RTK_PATCH_OP_CMP_SRAM_PSDS0 RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_PSDS0 , RTK_PATCH_CMP_SWC)
|
||||
#define RTK_PATCH_OP_CMP_SRAM_PSDS1 RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_PSDS1 , RTK_PATCH_CMP_SWC)
|
||||
#define RTK_PATCH_OP_CMP_SRAM_MSDS RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_MSDS , RTK_PATCH_CMP_SWC)
|
||||
#define RTK_PATCH_OP_CMP_SRAM_MAC RTK_PATCH_OP_TO_CMP(RTK_PATCH_OP_MAC , RTK_PATCH_CMP_SWC)
|
||||
|
||||
/* 200~255 control op */
|
||||
#define RTK_PATCH_OP_DELAY_MS 200
|
||||
#define RTK_PATCH_OP_SKIP 255
|
||||
|
||||
|
||||
/*
|
||||
patch type PHY_PATCH_TYPE_NONE => empty
|
||||
patch type: PHY_PATCH_TYPE_TOP ~ (PHY_PATCH_TYPE_END-1) => data array
|
||||
patch type: PHY_PATCH_TYPE_END ~ (PHY_PATCH_TYPE_END + RTK_PATCH_TYPE_FLOW_MAX) => flow
|
||||
*/
|
||||
#define RTK_PATCH_TYPE_IS_DATA(_patch_type) (_patch_type > PHY_PATCH_TYPE_NONE && _patch_type < PHY_PATCH_TYPE_END)
|
||||
#define RTK_PATCH_TYPE_IS_FLOW(_patch_type) (_patch_type >= PHY_PATCH_TYPE_END && _patch_type <= (PHY_PATCH_TYPE_END + RTK_PATCH_TYPE_FLOWID_MAX))
|
||||
|
||||
|
||||
/*
|
||||
* Macro Definition
|
||||
*/
|
||||
#if PHYPATCH_PHYCTRL_IN_HALCTRL
|
||||
#define PHYPATCH_DB_GET(_unit, _port, _pPatchDb) \
|
||||
do {\
|
||||
hal_control_t *pHalCtrl = NULL;\
|
||||
if ((pHalCtrl = hal_ctrlInfo_get(_unit)) == NULL)\
|
||||
return RT_ERR_FAILED;\
|
||||
_pPatchDb = (pHalCtrl->pPhy_ctrl[_port]->pPhy_patchDb);\
|
||||
} while(0)
|
||||
#else
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
#else
|
||||
#include <hal/phy/phydef.h>
|
||||
#include <hal/phy/phy_probe.h>
|
||||
#endif
|
||||
#define PHYPATCH_DB_GET(_unit, _port, _pPatchDb) \
|
||||
do {\
|
||||
rt_phyctrl_t *pPhyCtrl = NULL;\
|
||||
if ((pPhyCtrl = phy_phyctrl_get(_unit, _port)) == NULL)\
|
||||
return RT_ERR_FAILED;\
|
||||
_pPatchDb = (pPhyCtrl->pPhy_patchDb);\
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#if PHYPATCH_FMAILY_IN_HWP
|
||||
#define PHYPATCH_IS_RTKSDS(_unit) (HWP_9300_FAMILY_ID(_unit) || HWP_9310_FAMILY_ID(_unit))
|
||||
#else
|
||||
#define PHYPATCH_IS_RTKSDS(_unit) (RTK_9300_FAMILY_ID(_unit) || RTK_9310_FAMILY_ID(_unit) || RTK_9311B_FAMILY_ID(_unit) || RTK_9330_FAMILY_ID(_unit))
|
||||
#endif
|
||||
|
||||
#define PHYPATCH_TABLE_ASSIGN(_pPatchDb, _table, _idx, _patch_type, _para) \
|
||||
do {\
|
||||
if (RTK_PATCH_TYPE_IS_DATA(_patch_type)) {\
|
||||
_pPatchDb->_table[_idx].patch_type = _patch_type;\
|
||||
_pPatchDb->_table[_idx].patch.data.conf = _para;\
|
||||
_pPatchDb->_table[_idx].patch.data.size = sizeof(_para);\
|
||||
}\
|
||||
else if (RTK_PATCH_TYPE_IS_FLOW(_patch_type)) {\
|
||||
_pPatchDb->_table[_idx].patch_type = _patch_type;\
|
||||
_pPatchDb->_table[_idx].patch.flow_id = _patch_type;\
|
||||
}\
|
||||
else {\
|
||||
_pPatchDb->_table[_idx].patch_type = PHY_PATCH_TYPE_NONE;\
|
||||
}\
|
||||
} while(0)
|
||||
#define PHYPATCH_SEQ_TABLE_ASSIGN(_pPatchDb, _idx, _patch_type, _para) PHYPATCH_TABLE_ASSIGN(_pPatchDb, seq_table, _idx, _patch_type, _para)
|
||||
#define PHYPATCH_CMP_TABLE_ASSIGN(_pPatchDb, _idx, _patch_type, _para) PHYPATCH_TABLE_ASSIGN(_pPatchDb, cmp_table, _idx, _patch_type, _para)
|
||||
|
||||
#define PHYPATCH_COMPARE(_mmdpage, _reg, _msb, _lsb, _exp, _real, _mask) \
|
||||
do {\
|
||||
uint32 _rData = REG32_FIELD_GET(_real, _lsb, _mask);\
|
||||
if (_exp != _rData) {\
|
||||
osal_printf("PATCH CHECK: %u(0x%X).%u(0x%X)[%u:%u] = 0x%X (!= 0x%X)\n", _mmdpage, _mmdpage, _reg, _reg, _msb, _lsb, _rData, _exp);\
|
||||
return RT_ERR_CHECK_FAILED;\
|
||||
}\
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Function Declaration
|
||||
*/
|
||||
|
||||
extern uint8 phy_patch_op_translate(uint8 patch_mode, uint8 patch_op, uint8 compare_op);
|
||||
extern int32 phy_patch_op(rt_phy_patch_db_t *pPhy_patchDb, uint32 unit, rtk_port_t port, uint8 portOffset,
|
||||
uint8 patch_op, uint16 portmask, uint16 pagemmd, uint16 addr, uint8 msb, uint8 lsb, uint16 data,
|
||||
uint8 patch_mode);
|
||||
|
||||
|
||||
/* Function Name:
|
||||
* phy_patch
|
||||
* Description:
|
||||
* apply initial patch data to PHY
|
||||
* Input:
|
||||
* unit - unit id
|
||||
* port - port id
|
||||
* portOffset - the index offset of port based the base port in the PHY chip
|
||||
* Output:
|
||||
* None
|
||||
* Return:
|
||||
* RT_ERR_OK
|
||||
* RT_ERR_FAILED
|
||||
* RT_ERR_CHECK_FAILED
|
||||
* RT_ERR_NOT_SUPPORTED
|
||||
* Note:
|
||||
* None
|
||||
*/
|
||||
extern int32 phy_patch(uint32 unit, rtk_port_t port, uint8 portOffset, uint8 patch_mode);
|
||||
|
||||
|
||||
|
||||
#endif /* __HAL_PHY_PATCH_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __HAL_PHY_PHY_RTL826XB_PATCH_H__
|
||||
#define __HAL_PHY_PHY_RTL826XB_PATCH_H__
|
||||
|
||||
/*
|
||||
* Include Files
|
||||
*/
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
#include "rtk_osal.h"
|
||||
#include "rtk_phylib_def.h"
|
||||
#else
|
||||
#include <common/rt_type.h>
|
||||
#include <rtk/port.h>
|
||||
#endif
|
||||
|
||||
/* Function Name:
|
||||
* phy_rtl826xb_patch
|
||||
* Description:
|
||||
* apply patch data to PHY
|
||||
* Input:
|
||||
* unit - unit id
|
||||
* baseport - base port id on the PHY chip
|
||||
* portOffset - the index offset base on baseport for the port to patch
|
||||
* Output:
|
||||
* None
|
||||
* Return:
|
||||
* RT_ERR_OK
|
||||
* RT_ERR_FAILED
|
||||
* RT_ERR_NOT_SUPPORTED
|
||||
* RT_ERR_ABORT
|
||||
* Note:
|
||||
* None
|
||||
*/
|
||||
extern int32 phy_rtl826xb_patch(uint32 unit, rtk_port_t baseport, uint8 portOffset);
|
||||
|
||||
/* Function Name:
|
||||
* phy_rtl826xb_broadcast_patch
|
||||
* Description:
|
||||
* apply patch data to PHY
|
||||
* Input:
|
||||
* unit - unit id
|
||||
* baseport - base port id on the PHY chip
|
||||
* portOffset - the index offset base on baseport for the port to patch
|
||||
* perChip - 1 for per-chip mode, 0 for per-bus mode
|
||||
* Output:
|
||||
* None
|
||||
* Return:
|
||||
* RT_ERR_OK
|
||||
* RT_ERR_FAILED
|
||||
* RT_ERR_NOT_SUPPORTED
|
||||
* RT_ERR_ABORT
|
||||
* Note:
|
||||
* None
|
||||
*/
|
||||
extern int32 phy_rtl826xb_broadcast_patch(uint32 unit, rtk_port_t port, uint8 portOffset, uint8 perChip);
|
||||
|
||||
extern int32 phy_rtl826xb_patch_db_init(uint32 unit, rtk_port_t port, rt_phy_patch_db_t **pPhy_patchDb);
|
||||
#endif /* __HAL_PHY_PHY_RTL826XB_PATCH_H__ */
|
||||
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "type.h"
|
||||
#include "error.h"
|
||||
#include "rtk_phylib_def.h"
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/sched/signal.h>
|
||||
#include <linux/phy.h>
|
||||
|
||||
int32
|
||||
osal_time_usecs_get(osal_usecs_t *pUsec)
|
||||
{
|
||||
struct timespec64 ts;
|
||||
|
||||
RT_PARAM_CHK((NULL == pUsec), RT_ERR_NULL_POINTER);
|
||||
|
||||
ktime_get_ts64(&ts);
|
||||
*pUsec = (osal_usecs_t)((ts.tv_sec * USEC_PER_SEC) + (ts.tv_nsec / NSEC_PER_USEC));
|
||||
return RT_ERR_OK;
|
||||
}
|
||||
|
||||
void *
|
||||
osal_alloc(uint32 size)
|
||||
{
|
||||
void *p;
|
||||
p = kmalloc((size_t)size, GFP_ATOMIC);
|
||||
return p;
|
||||
}
|
||||
|
||||
int32
|
||||
phy_common_general_reg_mmd_get(uint32 unit, rtk_port_t port, uint32 mmdAddr, uint32 mmdReg, uint32 *pData)
|
||||
{
|
||||
int32 rData = 0;
|
||||
rData = phy_read_mmd(port, mmdAddr, mmdReg);
|
||||
if (rData < 0)
|
||||
return RT_ERR_FAILED;
|
||||
*pData = (uint32)rData;
|
||||
return RT_ERR_OK;
|
||||
}
|
||||
|
||||
int32
|
||||
phy_common_general_reg_mmd_set(uint32 unit, rtk_port_t port, uint32 mmdAddr, uint32 mmdReg, uint32 data)
|
||||
{
|
||||
int ret = phy_write_mmd(port, mmdAddr, mmdReg, data);
|
||||
return (ret < 0) ? RT_ERR_FAILED : RT_ERR_OK;
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __RTK_PHY_OSAL_H
|
||||
#define __RTK_PHY_OSAL_H
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/phy.h>
|
||||
#include "type.h"
|
||||
#include "error.h"
|
||||
#include "phy_patch.h"
|
||||
#include "rtk_phylib.h"
|
||||
|
||||
#ifdef PHYPATCH_DB_GET
|
||||
#undef PHYPATCH_DB_GET
|
||||
#endif
|
||||
|
||||
#define PHYPATCH_DB_GET(_unit, _pPhy_device, _pPatchDb) \
|
||||
do { \
|
||||
struct rtk_phy_priv *_pPriv = (_pPhy_device)->priv; \
|
||||
rt_phy_patch_db_t *_pDb = _pPriv->patch; _pPatchDb = _pDb; \
|
||||
/*printk("[PHYPATCH_DB_GET] ? [%s]\n", (_pDb != NULL) ? "E":"N");*/ \
|
||||
} while(0)
|
||||
|
||||
#define HWP_9300_FAMILY_ID(_unit) 0
|
||||
#define HWP_9310_FAMILY_ID(_unit) 0
|
||||
#define RTK_9300_FAMILY_ID(_unit) 0
|
||||
#define RTK_9310_FAMILY_ID(_unit) 0
|
||||
#define RTK_9311B_FAMILY_ID(_unit) 0
|
||||
#define RTK_9330_FAMILY_ID(_unit) 0
|
||||
|
||||
#ifndef WAIT_COMPLETE_VAR
|
||||
#define WAIT_COMPLETE_VAR() \
|
||||
osal_usecs_t _t, _now, _t_wait=0, _timeout; \
|
||||
int32 _chkCnt=0;
|
||||
|
||||
#define WAIT_COMPLETE(_timeout_us) \
|
||||
_timeout = _timeout_us; \
|
||||
for(osal_time_usecs_get(&_t),osal_time_usecs_get(&_now),_t_wait=0,_chkCnt=0 ; \
|
||||
(_t_wait <= _timeout); \
|
||||
osal_time_usecs_get(&_now), _chkCnt++, _t_wait += ((_now >= _t) ? (_now - _t) : (0xFFFFFFFF - _t + _now)),_t = _now \
|
||||
)
|
||||
|
||||
#define WAIT_COMPLETE_IS_TIMEOUT() (_t_wait > _timeout)
|
||||
#endif
|
||||
|
||||
/* OSAL */
|
||||
#include <linux/slab.h>
|
||||
int32 osal_time_usecs_get(osal_usecs_t *pUsec);
|
||||
void *osal_alloc(uint32 size);
|
||||
#define osal_time_mdelay mdelay
|
||||
|
||||
#include <linux/ctype.h> /* for Kernel Space */
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#define osal_strlen strlen
|
||||
#define osal_strcmp strcmp
|
||||
#define osal_strcpy strcpy
|
||||
#define osal_strncpy strncpy
|
||||
#define osal_strcat strcat
|
||||
#define osal_strchr strchr
|
||||
#define osal_memset memset
|
||||
#define osal_memcpy memcpy
|
||||
#define osal_memcmp memcmp
|
||||
#define osal_strdup strdup
|
||||
#define osal_strncmp strncmp
|
||||
#define osal_strstr strstr
|
||||
#define osal_strtok strtok
|
||||
#define osal_strtok_r strtok_r
|
||||
#define osal_toupper toupper
|
||||
|
||||
#define osal_printf printk
|
||||
|
||||
/* HWP */
|
||||
#define HWP_PORT_SMI(unit, port) 0
|
||||
#define HWP_PHY_MODEL_BY_PORT(unit, port) 0
|
||||
#define HWP_PHY_ADDR(unit, port) 0
|
||||
#define HWP_PHY_BASE_MACID(unit, p) 0
|
||||
#define HWP_PORT_TRAVS_EXCEPT_CPU(unit, p) if (bcast_phyad < 0x1F && p != NULL)
|
||||
|
||||
|
||||
/* RT_LOG */
|
||||
//#define RT_LOG(level, module, fmt, args...) do { printk("RT_LOG:"fmt, ## args); } while(0)
|
||||
#define RT_LOG(level, module, fmt, args...) do {} while(0)
|
||||
#define RT_ERR(error_code, module, fmt, args...) do {} while(0)
|
||||
#define RT_INIT_ERR(error_code, module, fmt, args...) do {} while(0)
|
||||
#define RT_INIT_MSG(fmt, args...) do {} while(0)
|
||||
|
||||
#define phy_826xb_ctrl_set(unit, p, RTK_PHY_CTRL_MIIM_BCAST_PHYAD, bcast_phyad) 0
|
||||
|
||||
/* reg access */
|
||||
int32 phy_common_general_reg_mmd_get(uint32 unit, rtk_port_t port, uint32 mmdAddr, uint32 mmdReg, uint32 *pData);
|
||||
int32 phy_common_general_reg_mmd_set(uint32 unit, rtk_port_t port, uint32 mmdAddr, uint32 mmdReg, uint32 data);
|
||||
|
||||
|
||||
#endif /* __RTK_PHY_OSAL_H */
|
||||
@ -0,0 +1,282 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/phy.h>
|
||||
|
||||
#include "phy_rtl826xb_patch.h"
|
||||
#include "rtk_phylib_rtl826xb.h"
|
||||
#include "rtk_phylib.h"
|
||||
|
||||
#define REALTEK_PHY_ID_RTL8261N 0x001CCAF3
|
||||
#define REALTEK_PHY_ID_RTL8264B 0x001CC813
|
||||
|
||||
static int rtl826xb_get_features(struct phy_device *phydev)
|
||||
{
|
||||
int ret;
|
||||
ret = genphy_c45_pma_read_abilities(phydev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
linkmode_or(phydev->supported, phydev->supported, PHY_BASIC_FEATURES);
|
||||
|
||||
|
||||
linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
|
||||
phydev->supported);
|
||||
linkmode_set_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
|
||||
phydev->supported);
|
||||
|
||||
/* not support 10M modes */
|
||||
linkmode_clear_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT,
|
||||
phydev->supported);
|
||||
linkmode_clear_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
|
||||
phydev->supported);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl826xb_probe(struct phy_device *phydev)
|
||||
{
|
||||
struct rtk_phy_priv *priv = NULL;
|
||||
|
||||
priv = devm_kzalloc(&phydev->mdio.dev, sizeof(struct rtk_phy_priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(priv, 0, sizeof(struct rtk_phy_priv));
|
||||
|
||||
if (phy_rtl826xb_patch_db_init(0, phydev, &(priv->patch)) != RT_ERR_OK)
|
||||
return -ENOMEM;
|
||||
|
||||
priv->phytype = (phydev->drv->phy_id == REALTEK_PHY_ID_RTL8261N) ? (RTK_PHYLIB_RTL8261N) : (RTK_PHYLIB_RTL8264B);
|
||||
priv->isBasePort = (phydev->drv->phy_id == REALTEK_PHY_ID_RTL8261N) ? (1) : (((phydev->mdio.addr % 4) == 0) ? (1) : (0));
|
||||
phydev->priv = priv;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtkphy_config_init(struct phy_device *phydev)
|
||||
{
|
||||
int ret = 0;
|
||||
switch (phydev->drv->phy_id)
|
||||
{
|
||||
case REALTEK_PHY_ID_RTL8261N:
|
||||
case REALTEK_PHY_ID_RTL8264B:
|
||||
phydev_info(phydev, "%s:%u [RTL8261N/RTL826XB] phy_id: 0x%X PHYAD:%d\n", __FUNCTION__, __LINE__, phydev->drv->phy_id, phydev->mdio.addr);
|
||||
|
||||
|
||||
#if 1 /* toggle reset */
|
||||
phy_modify_mmd_changed(phydev, 30, 0x145, BIT(0) , 1);
|
||||
phy_modify_mmd_changed(phydev, 30, 0x145, BIT(0) , 0);
|
||||
mdelay(30);
|
||||
#endif
|
||||
|
||||
ret = phy_patch(0, phydev, 0, PHY_PATCH_MODE_NORMAL);
|
||||
if (ret)
|
||||
{
|
||||
phydev_err(phydev, "%s:%u [RTL8261N/RTL826XB] patch failed!! 0x%X\n", __FUNCTION__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
#if 0 /* Debug: patch check */
|
||||
ret = phy_patch(0, phydev, 0, PHY_PATCH_MODE_CMP);
|
||||
if (ret)
|
||||
{
|
||||
phydev_err(phydev, "%s:%u [RTL8261N/RTL826XB] phy_patch failed!! 0x%X\n", __FUNCTION__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
printk("[%s,%u] patch chk %s\n", __FUNCTION__, __LINE__, (ret == 0) ? "PASS" : "FAIL");
|
||||
#endif
|
||||
#if 0 /* Debug: USXGMII*/
|
||||
{
|
||||
uint32 data = 0;
|
||||
rtk_phylib_826xb_sds_read(phydev, 0x07, 0x10, 15, 0, &data);
|
||||
printk("[%s,%u] SDS 0x07, 0x10 : 0x%X\n", __FUNCTION__, __LINE__, data);
|
||||
rtk_phylib_826xb_sds_read(phydev, 0x06, 0x12, 15, 0, &data);
|
||||
printk("[%s,%u] SDS 0x06, 0x12 : 0x%X\n", __FUNCTION__, __LINE__, data);
|
||||
}
|
||||
{
|
||||
u16 sdspage = 0x5, sdsreg = 0x0;
|
||||
u16 regData = (sdspage & 0x3f) | ((sdsreg & 0x1f) << 6) | BIT(15);
|
||||
u16 readData = 0;
|
||||
phy_write_mmd(phydev, 30, 323, regData);
|
||||
do
|
||||
{
|
||||
udelay(10);
|
||||
readData = phy_read_mmd(phydev, 30, 323);
|
||||
} while ((readData & BIT(15)) != 0);
|
||||
readData = phy_read_mmd(phydev, 30, 322);
|
||||
printk("[%s,%d] sds link [%s] (0x%X)\n", __FUNCTION__, __LINE__, (readData & BIT(12)) ? "UP" : "DOWN", readData);
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
default:
|
||||
phydev_err(phydev, "%s:%u Unknow phy_id: 0x%X\n", __FUNCTION__, __LINE__, phydev->drv->phy_id);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rtkphy_c45_suspend(struct phy_device *phydev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = rtk_phylib_c45_power_low(phydev);
|
||||
|
||||
phydev->speed = SPEED_UNKNOWN;
|
||||
phydev->duplex = DUPLEX_UNKNOWN;
|
||||
phydev->pause = 0;
|
||||
phydev->asym_pause = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rtkphy_c45_resume(struct phy_device *phydev)
|
||||
{
|
||||
return rtk_phylib_c45_power_normal(phydev);
|
||||
}
|
||||
|
||||
static int rtkphy_c45_config_aneg(struct phy_device *phydev)
|
||||
{
|
||||
bool changed = false;
|
||||
u16 reg = 0;
|
||||
int ret = 0;
|
||||
|
||||
phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
|
||||
if (phydev->autoneg == AUTONEG_DISABLE)
|
||||
return genphy_c45_pma_setup_forced(phydev);
|
||||
|
||||
ret = genphy_c45_an_config_aneg(phydev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret > 0)
|
||||
changed = true;
|
||||
|
||||
reg = 0;
|
||||
if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
|
||||
phydev->advertising))
|
||||
reg |= BIT(9);
|
||||
|
||||
if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
|
||||
phydev->advertising))
|
||||
reg |= BIT(8);
|
||||
|
||||
ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, 0xA412,
|
||||
BIT(9) | BIT(8) , reg);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret > 0)
|
||||
changed = true;
|
||||
|
||||
return genphy_c45_check_and_restart_aneg(phydev, changed);
|
||||
}
|
||||
|
||||
static int rtkphy_c45_aneg_done(struct phy_device *phydev)
|
||||
{
|
||||
return genphy_c45_aneg_done(phydev);
|
||||
}
|
||||
|
||||
static int rtkphy_c45_read_status(struct phy_device *phydev)
|
||||
{
|
||||
int ret = 0, status = 0;
|
||||
phydev->speed = SPEED_UNKNOWN;
|
||||
phydev->duplex = DUPLEX_UNKNOWN;
|
||||
phydev->pause = 0;
|
||||
phydev->asym_pause = 0;
|
||||
|
||||
ret = genphy_c45_read_link(phydev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (phydev->autoneg == AUTONEG_ENABLE)
|
||||
{
|
||||
linkmode_clear_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
|
||||
phydev->lp_advertising);
|
||||
|
||||
ret = genphy_c45_read_lpa(phydev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
status = phy_read_mmd(phydev, 31, 0xA414);
|
||||
if (status < 0)
|
||||
return status;
|
||||
linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
|
||||
phydev->lp_advertising, status & BIT(11));
|
||||
|
||||
phy_resolve_aneg_linkmode(phydev);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = genphy_c45_read_pma(phydev);
|
||||
}
|
||||
|
||||
/* mdix*/
|
||||
status = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_SWAPPOL);
|
||||
if (status < 0)
|
||||
return status;
|
||||
|
||||
switch (status & 0x3)
|
||||
{
|
||||
case MDIO_PMA_10GBT_SWAPPOL_ABNX | MDIO_PMA_10GBT_SWAPPOL_CDNX:
|
||||
phydev->mdix = ETH_TP_MDI;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
phydev->mdix = ETH_TP_MDI_X;
|
||||
break;
|
||||
|
||||
default:
|
||||
phydev->mdix = ETH_TP_MDI_INVALID;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static struct phy_driver rtk_phy_drivers[] = {
|
||||
{
|
||||
PHY_ID_MATCH_EXACT(REALTEK_PHY_ID_RTL8261N),
|
||||
.name = "Realtek RTL8261N",
|
||||
.get_features = rtl826xb_get_features,
|
||||
.config_init = rtkphy_config_init,
|
||||
.probe = rtl826xb_probe,
|
||||
.suspend = rtkphy_c45_suspend,
|
||||
.resume = rtkphy_c45_resume,
|
||||
.config_aneg = rtkphy_c45_config_aneg,
|
||||
.aneg_done = rtkphy_c45_aneg_done,
|
||||
.read_status = rtkphy_c45_read_status,
|
||||
},
|
||||
{
|
||||
PHY_ID_MATCH_EXACT(REALTEK_PHY_ID_RTL8264B),
|
||||
.name = "Realtek RTL8264B",
|
||||
.get_features = rtl826xb_get_features,
|
||||
.config_init = rtkphy_config_init,
|
||||
.probe = rtl826xb_probe,
|
||||
.suspend = rtkphy_c45_suspend,
|
||||
.resume = rtkphy_c45_resume,
|
||||
.config_aneg = rtkphy_c45_config_aneg,
|
||||
.aneg_done = rtkphy_c45_aneg_done,
|
||||
.read_status = rtkphy_c45_read_status,
|
||||
},
|
||||
};
|
||||
|
||||
module_phy_driver(rtk_phy_drivers);
|
||||
|
||||
|
||||
static struct mdio_device_id __maybe_unused rtk_phy_tbl[] = {
|
||||
{ PHY_ID_MATCH_EXACT(REALTEK_PHY_ID_RTL8261N) },
|
||||
{ PHY_ID_MATCH_EXACT(REALTEK_PHY_ID_RTL8264B) },
|
||||
{ },
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(mdio, rtk_phy_tbl);
|
||||
|
||||
MODULE_AUTHOR("Realtek");
|
||||
MODULE_DESCRIPTION("Realtek PHY drivers");
|
||||
MODULE_LICENSE("GPL");
|
||||
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "rtk_phylib.h"
|
||||
#include <linux/phy.h>
|
||||
|
||||
|
||||
/* OSAL */
|
||||
|
||||
void rtk_phylib_mdelay(uint32 msec)
|
||||
{
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
mdelay(msec);
|
||||
#else
|
||||
osal_time_mdelay(msec);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void rtk_phylib_udelay(uint32 usec)
|
||||
{
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
if (1000 <= usec)
|
||||
{
|
||||
mdelay(usec/1000);
|
||||
usec = usec % 1000;
|
||||
}
|
||||
udelay(usec);
|
||||
#else
|
||||
osal_time_udelay(usec);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Register Access APIs */
|
||||
int32 rtk_phylib_mmd_write(rtk_phydev *phydev, uint32 mmd, uint32 reg, uint8 msb, uint8 lsb, uint32 data)
|
||||
{
|
||||
int32 ret = 0;
|
||||
uint32 mask = 0;
|
||||
mask = UINT32_BITS_MASK(msb,lsb);
|
||||
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
ret = phy_modify_mmd(phydev, mmd, reg, mask, data);
|
||||
#else
|
||||
{
|
||||
uint32 rData = 0, wData = 0;
|
||||
if ((msb != 15) || (lsb != 0))
|
||||
{
|
||||
if ((ret = phy_common_general_reg_mmd_get(phydev->unit, phydev->port, page, reg, &rData)) != RT_ERR_OK)
|
||||
return ret;
|
||||
}
|
||||
wData = REG32_FIELD_SET(rData, data, lsb, mask);
|
||||
ret = phy_common_general_reg_mmd_set(phydev->unit, phydev->port, page, reg, wData);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32 rtk_phylib_mmd_read(rtk_phydev *phydev, uint32 mmd, uint32 reg, uint8 msb, uint8 lsb, uint32 *pData)
|
||||
{
|
||||
int32 ret = 0;
|
||||
uint32 rData = 0;
|
||||
uint32 mask = 0;
|
||||
mask = UINT32_BITS_MASK(msb,lsb);
|
||||
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
rData = phy_read_mmd(phydev, mmd, reg);
|
||||
#else
|
||||
{
|
||||
ret = phy_common_general_reg_mmd_get(phydev->unit, phydev->port, page, reg, &rData);
|
||||
}
|
||||
#endif
|
||||
|
||||
*pData = REG32_FIELD_GET(rData, lsb, mask);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Function Driver */
|
||||
|
||||
int32 rtk_phylib_c45_power_normal(rtk_phydev *phydev)
|
||||
{
|
||||
int32 ret = 0;
|
||||
RTK_PHYLIB_ERR_CHK(rtk_phylib_mmd_write(phydev, 1, 0, 11, 11, 0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 rtk_phylib_c45_power_low(rtk_phydev *phydev)
|
||||
{
|
||||
int32 ret = 0;
|
||||
RTK_PHYLIB_ERR_CHK(rtk_phylib_mmd_write(phydev, 1, 0, 11, 11, 1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 rtk_phylib_c45_pcs_loopback(rtk_phydev *phydev, uint32 enable)
|
||||
{
|
||||
int32 ret = 0;
|
||||
RTK_PHYLIB_ERR_CHK(rtk_phylib_mmd_write(phydev, 3, 0, 14, 14, (enable == 0) ? 0 : 1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __RTK_PHYLIB_H
|
||||
#define __RTK_PHYLIB_H
|
||||
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
#include "type.h"
|
||||
#include "rtk_phylib_def.h"
|
||||
#else
|
||||
//#include SDK headers
|
||||
#endif
|
||||
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
#define PR_INFO(_fmt, _args...) pr_info(_fmt, ##_args)
|
||||
#define PR_DBG(_fmt, _args...) pr_debug(_fmt, ##_args)
|
||||
#define PR_ERR(_fmt, _args...) pr_err("ERROR: "_fmt, ##_args)
|
||||
|
||||
#define RTK_PHYLIB_ERR_FAILED (-EPERM)
|
||||
#define RTK_PHYLIB_ERR_INPUT (-EINVAL)
|
||||
#define RTK_PHYLIB_ERR_EXCEEDS_CAPACITY (-ENOSPC)
|
||||
#define RTK_PHYLIB_ERR_TIMEOUT (-ETIME)
|
||||
#define RTK_PHYLIB_ERR_ENTRY_NOTFOUND (-ENODATA)
|
||||
#else
|
||||
#define PR_INFO(_fmt, _args...) RT_LOG(LOG_INFO, (MOD_HAL|MOD_PHY), _fmt, ##_args)
|
||||
#define PR_DBG(_fmt, _args...) RT_LOG(LOG_DEBUG, (MOD_HAL|MOD_PHY), _fmt, ##_args)
|
||||
#define PR_ERR(_fmt, _args...) RT_LOG(LOG_MAJOR_ERR, (MOD_HAL|MOD_PHY), _fmt, ##_args)
|
||||
|
||||
#define RTK_PHYLIB_ERR_FAILED (RT_ERR_FAILED)
|
||||
#define RTK_PHYLIB_ERR_INPUT (RT_ERR_INPUT)
|
||||
#define RTK_PHYLIB_ERR_EXCEEDS_CAPACITY (RT_ERR_EXCEEDS_CAPACITY)
|
||||
#define RTK_PHYLIB_ERR_TIMEOUT (RT_ERR_BUSYWAIT_TIMEOUT)
|
||||
#define RTK_PHYLIB_ERR_ENTRY_NOTFOUND (RT_ERR_ENTRY_NOTFOUND)
|
||||
#endif
|
||||
|
||||
typedef enum rtk_phylib_phy_e
|
||||
{
|
||||
RTK_PHYLIB_NONE,
|
||||
RTK_PHYLIB_RTL8261N,
|
||||
RTK_PHYLIB_RTL8264B,
|
||||
RTK_PHYLIB_END
|
||||
} rtk_phylib_phy_t;
|
||||
|
||||
struct rtk_phy_priv {
|
||||
rtk_phylib_phy_t phytype;
|
||||
uint8 isBasePort;
|
||||
rt_phy_patch_db_t *patch;
|
||||
};
|
||||
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
typedef struct phy_device rtk_phydev;
|
||||
#else
|
||||
struct rtk_phy_dev_s
|
||||
{
|
||||
uint32 unit;
|
||||
rtk_port_t port;
|
||||
|
||||
struct rtk_phy_priv *priv;
|
||||
};
|
||||
typedef struct rtk_phy_dev_s rtk_phydev;
|
||||
#endif
|
||||
|
||||
#define RTK_PHYLIB_ERR_CHK(op)\
|
||||
do {\
|
||||
if ((ret = (op)) != 0)\
|
||||
return ret;\
|
||||
} while(0)
|
||||
|
||||
#define RTK_PHYLIB_VAL_TO_BYTE_ARRAY(_val, _valbytes, _array, _start, _bytes)\
|
||||
do{\
|
||||
uint32 _i = 0;\
|
||||
for (_i = 0; _i < _bytes; _i++)\
|
||||
_array[_start+_i] = (_val >> (8* (_valbytes - _i - 1)));\
|
||||
}while(0)
|
||||
|
||||
#define RTK_PHYLIB_BYTE_ARRAY_TO_VAL(_val, _array, _start, _bytes)\
|
||||
do{\
|
||||
uint32 _i = 0;\
|
||||
for (_i = 0; _i < _bytes; _i++)\
|
||||
_val = (_val << 8) | _array[_start + _i];\
|
||||
}while(0)
|
||||
|
||||
|
||||
/* OSAL */
|
||||
void rtk_phylib_mdelay(uint32 msec);
|
||||
void rtk_phylib_udelay(uint32 usec);
|
||||
|
||||
/* Register Access APIs */
|
||||
int32 rtk_phylib_mmd_write(rtk_phydev *phydev, uint32 mmd, uint32 reg, uint8 msb, uint8 lsb, uint32 data);
|
||||
int32 rtk_phylib_mmd_read(rtk_phydev *phydev, uint32 mmd, uint32 reg, uint8 msb, uint8 lsb, uint32 *pData);
|
||||
|
||||
/* Function Driver */
|
||||
int32 rtk_phylib_c45_power_normal(rtk_phydev *phydev);
|
||||
int32 rtk_phylib_c45_power_low(rtk_phydev *phydev);
|
||||
int32 rtk_phylib_c45_pcs_loopback(rtk_phydev *phydev, uint32 enable);
|
||||
|
||||
|
||||
#endif /* __RTK_PHYLIB_H */
|
||||
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
#ifndef __RTK_PHYLIB_DEF_H
|
||||
#define __RTK_PHYLIB_DEF_H
|
||||
|
||||
#include "type.h"
|
||||
|
||||
//#define PHY_C22_MMD_PAGE 0
|
||||
#define PHY_C22_MMD_PAGE 0x0A41
|
||||
#define PHY_C22_MMD_DEV_REG 13
|
||||
#define PHY_C22_MMD_ADD_REG 14
|
||||
|
||||
/* MDIO Manageable Device(MDD) address*/
|
||||
#define PHY_MMD_PMAPMD 1
|
||||
#define PHY_MMD_PCS 3
|
||||
#define PHY_MMD_AN 7
|
||||
#define PHY_MMD_VEND1 30 /* Vendor specific 1 */
|
||||
#define PHY_MMD_VEND2 31 /* Vendor specific 2 */
|
||||
|
||||
#define BIT_0 0x00000001U
|
||||
#define BIT_1 0x00000002U
|
||||
#define BIT_2 0x00000004U
|
||||
#define BIT_3 0x00000008U
|
||||
#define BIT_4 0x00000010U
|
||||
#define BIT_5 0x00000020U
|
||||
#define BIT_6 0x00000040U
|
||||
#define BIT_7 0x00000080U
|
||||
#define BIT_8 0x00000100U
|
||||
#define BIT_9 0x00000200U
|
||||
#define BIT_10 0x00000400U
|
||||
#define BIT_11 0x00000800U
|
||||
#define BIT_12 0x00001000U
|
||||
#define BIT_13 0x00002000U
|
||||
#define BIT_14 0x00004000U
|
||||
#define BIT_15 0x00008000U
|
||||
#define BIT_16 0x00010000U
|
||||
#define BIT_17 0x00020000U
|
||||
#define BIT_18 0x00040000U
|
||||
#define BIT_19 0x00080000U
|
||||
#define BIT_20 0x00100000U
|
||||
#define BIT_21 0x00200000U
|
||||
#define BIT_22 0x00400000U
|
||||
#define BIT_23 0x00800000U
|
||||
#define BIT_24 0x01000000U
|
||||
#define BIT_25 0x02000000U
|
||||
#define BIT_26 0x04000000U
|
||||
#define BIT_27 0x08000000U
|
||||
#define BIT_28 0x10000000U
|
||||
#define BIT_29 0x20000000U
|
||||
#define BIT_30 0x40000000U
|
||||
#define BIT_31 0x80000000U
|
||||
|
||||
#define MASK_1_BITS (BIT_1 - 1)
|
||||
#define MASK_2_BITS (BIT_2 - 1)
|
||||
#define MASK_3_BITS (BIT_3 - 1)
|
||||
#define MASK_4_BITS (BIT_4 - 1)
|
||||
#define MASK_5_BITS (BIT_5 - 1)
|
||||
#define MASK_6_BITS (BIT_6 - 1)
|
||||
#define MASK_7_BITS (BIT_7 - 1)
|
||||
#define MASK_8_BITS (BIT_8 - 1)
|
||||
#define MASK_9_BITS (BIT_9 - 1)
|
||||
#define MASK_10_BITS (BIT_10 - 1)
|
||||
#define MASK_11_BITS (BIT_11 - 1)
|
||||
#define MASK_12_BITS (BIT_12 - 1)
|
||||
#define MASK_13_BITS (BIT_13 - 1)
|
||||
#define MASK_14_BITS (BIT_14 - 1)
|
||||
#define MASK_15_BITS (BIT_15 - 1)
|
||||
#define MASK_16_BITS (BIT_16 - 1)
|
||||
#define MASK_17_BITS (BIT_17 - 1)
|
||||
#define MASK_18_BITS (BIT_18 - 1)
|
||||
#define MASK_19_BITS (BIT_19 - 1)
|
||||
#define MASK_20_BITS (BIT_20 - 1)
|
||||
#define MASK_21_BITS (BIT_21 - 1)
|
||||
#define MASK_22_BITS (BIT_22 - 1)
|
||||
#define MASK_23_BITS (BIT_23 - 1)
|
||||
#define MASK_24_BITS (BIT_24 - 1)
|
||||
#define MASK_25_BITS (BIT_25 - 1)
|
||||
#define MASK_26_BITS (BIT_26 - 1)
|
||||
#define MASK_27_BITS (BIT_27 - 1)
|
||||
#define MASK_28_BITS (BIT_28 - 1)
|
||||
#define MASK_29_BITS (BIT_29 - 1)
|
||||
#define MASK_30_BITS (BIT_30 - 1)
|
||||
#define MASK_31_BITS (BIT_31 - 1)
|
||||
|
||||
#define REG32_FIELD_SET(_data, _val, _fOffset, _fMask) ((_data & ~(_fMask)) | ((_val << (_fOffset)) & (_fMask)))
|
||||
#define REG32_FIELD_GET(_data, _fOffset, _fMask) ((_data & (_fMask)) >> (_fOffset))
|
||||
#define UINT32_BITS_MASK(_mBit, _lBit) ((0xFFFFFFFF >> (31 - _mBit)) ^ ((1 << _lBit) - 1))
|
||||
|
||||
typedef struct phy_device * rtk_port_t;
|
||||
|
||||
#if 1 /* ss\sdk\include\hal\phy\phydef.h */
|
||||
/* unified patch format */
|
||||
typedef enum rtk_phypatch_type_e
|
||||
{
|
||||
PHY_PATCH_TYPE_NONE = 0,
|
||||
PHY_PATCH_TYPE_TOP = 1,
|
||||
PHY_PATCH_TYPE_SDS,
|
||||
PHY_PATCH_TYPE_AFE,
|
||||
PHY_PATCH_TYPE_UC,
|
||||
PHY_PATCH_TYPE_UC2,
|
||||
PHY_PATCH_TYPE_NCTL0,
|
||||
PHY_PATCH_TYPE_NCTL1,
|
||||
PHY_PATCH_TYPE_NCTL2,
|
||||
PHY_PATCH_TYPE_ALGXG,
|
||||
PHY_PATCH_TYPE_ALG1G,
|
||||
PHY_PATCH_TYPE_NORMAL,
|
||||
PHY_PATCH_TYPE_DATARAM,
|
||||
PHY_PATCH_TYPE_RTCT,
|
||||
PHY_PATCH_TYPE_END
|
||||
} rtk_phypatch_type_t;
|
||||
|
||||
#define RTK_PATCH_TYPE_FLOW(_id) (PHY_PATCH_TYPE_END + _id)
|
||||
#define RTK_PATCH_TYPE_FLOWID_MAX PHY_PATCH_TYPE_END
|
||||
#define RTK_PATCH_SEQ_MAX ( PHY_PATCH_TYPE_END + RTK_PATCH_TYPE_FLOWID_MAX -1)
|
||||
|
||||
typedef struct rtk_hwpatch_s
|
||||
{
|
||||
uint8 patch_op;
|
||||
uint8 portmask;
|
||||
uint16 pagemmd;
|
||||
uint16 addr;
|
||||
uint8 msb;
|
||||
uint8 lsb;
|
||||
uint16 data;
|
||||
uint8 compare_op;
|
||||
uint16 sram_p;
|
||||
uint16 sram_rr;
|
||||
uint16 sram_rw;
|
||||
uint16 sram_a;
|
||||
} rtk_hwpatch_t;
|
||||
|
||||
typedef struct rtk_hwpatch_data_s
|
||||
{
|
||||
rtk_hwpatch_t *conf;
|
||||
uint32 size;
|
||||
} rtk_hwpatch_data_t;
|
||||
|
||||
typedef struct rtk_hwpatch_seq_s
|
||||
{
|
||||
uint8 patch_type;
|
||||
union
|
||||
{
|
||||
rtk_hwpatch_data_t data;
|
||||
uint8 flow_id;
|
||||
} patch;
|
||||
} rtk_hwpatch_seq_t;
|
||||
|
||||
typedef struct rt_phy_patch_db_s
|
||||
{
|
||||
/* patch operation */
|
||||
int32 (*fPatch_op)(uint32 unit, rtk_port_t port, uint8 portOffset, rtk_hwpatch_t *pPatch_data, uint8 patch_mode);
|
||||
int32 (*fPatch_flow)(uint32 unit, rtk_port_t port, uint8 portOffset, uint8 patch_flow, uint8 patch_mode);
|
||||
|
||||
/* patch data */
|
||||
rtk_hwpatch_seq_t seq_table[RTK_PATCH_SEQ_MAX];
|
||||
rtk_hwpatch_seq_t cmp_table[RTK_PATCH_SEQ_MAX];
|
||||
|
||||
} rt_phy_patch_db_t;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* __RTK_PHYLIB_DEF_H */
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "rtk_phylib_rtl826xb.h"
|
||||
|
||||
/* Indirect Register Access APIs */
|
||||
int rtk_phylib_826xb_sds_read(rtk_phydev *phydev, uint32 page, uint32 reg, uint8 msb, uint8 lsb, uint32 *pData)
|
||||
{
|
||||
int32 ret = 0;
|
||||
uint32 rData = 0;
|
||||
uint32 op = (page & 0x3f) | ((reg & 0x1f) << 6) | (0x8000);
|
||||
uint32 i = 0;
|
||||
uint32 mask = 0;
|
||||
mask = UINT32_BITS_MASK(msb,lsb);
|
||||
|
||||
RTK_PHYLIB_ERR_CHK(rtk_phylib_mmd_write(phydev, 30, 323, 15, 0, op));
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
RTK_PHYLIB_ERR_CHK(rtk_phylib_mmd_read(phydev, 30, 323, 15, 15, &rData));
|
||||
if (rData == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
rtk_phylib_udelay(10);
|
||||
}
|
||||
if (i == 10)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
RTK_PHYLIB_ERR_CHK(rtk_phylib_mmd_read(phydev, 30, 322, 15, 0, &rData));
|
||||
*pData = REG32_FIELD_GET(rData, lsb, mask);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int rtk_phylib_826xb_sds_write(rtk_phydev *phydev, uint32 page, uint32 reg, uint8 msb, uint8 lsb, uint32 data)
|
||||
{
|
||||
int32 ret = 0;
|
||||
uint32 wData = 0, rData = 0;
|
||||
uint32 op = (page & 0x3f) | ((reg & 0x1f) << 6) | (0x8800);
|
||||
uint32 mask = 0;
|
||||
mask = UINT32_BITS_MASK(msb,lsb);
|
||||
|
||||
RTK_PHYLIB_ERR_CHK(rtk_phylib_826xb_sds_read(phydev, page, reg, 15, 0, &rData));
|
||||
|
||||
wData = REG32_FIELD_SET(rData, data, lsb, mask);
|
||||
|
||||
RTK_PHYLIB_ERR_CHK(rtk_phylib_mmd_write(phydev, 30, 321, 15, 0, wData));
|
||||
RTK_PHYLIB_ERR_CHK(rtk_phylib_mmd_write(phydev, 30, 323, 15, 0, op));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __RTK_PHYLIB_RTL826XB_H
|
||||
#define __RTK_PHYLIB_RTL826XB_H
|
||||
|
||||
#if defined(RTK_PHYDRV_IN_LINUX)
|
||||
#include "rtk_phylib.h"
|
||||
#else
|
||||
//#include SDK headers
|
||||
#endif
|
||||
|
||||
int rtk_phylib_826xb_sds_read(rtk_phydev *phydev, uint32 page, uint32 reg, uint8 msb, uint8 lsb, uint32 *pData);
|
||||
int rtk_phylib_826xb_sds_write(rtk_phydev *phydev, uint32 page, uint32 reg, uint8 msb, uint8 lsb, uint32 data);
|
||||
|
||||
#endif /* __RTK_PHYLIB_RTL826XB_H */
|
||||
117
target/linux/mediatek/files-6.6/drivers/net/phy/rtl8261n/type.h
Normal file
117
target/linux/mediatek/files-6.6/drivers/net/phy/rtl8261n/type.h
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* Copyright (c) 2023 Realtek Semiconductor Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_TYPE_H__
|
||||
#define __COMMON_TYPE_H__
|
||||
|
||||
/*
|
||||
* Symbol Definition
|
||||
*/
|
||||
|
||||
#define USING_RTSTK_PKT_AS_RAIL
|
||||
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef ETHER_ADDR_LEN
|
||||
#define ETHER_ADDR_LEN 6
|
||||
#endif
|
||||
|
||||
#ifndef IP6_ADDR_LEN
|
||||
#define IP6_ADDR_LEN 16
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Data Type Declaration
|
||||
*/
|
||||
#ifndef uint64
|
||||
typedef unsigned long long uint64;
|
||||
#endif
|
||||
|
||||
#ifndef int64
|
||||
typedef signed long long int64;
|
||||
#endif
|
||||
|
||||
#ifndef uint32
|
||||
typedef unsigned int uint32;
|
||||
#endif
|
||||
|
||||
#ifndef int32
|
||||
typedef signed int int32;
|
||||
#endif
|
||||
|
||||
#ifndef uint16
|
||||
typedef unsigned short uint16;
|
||||
#endif
|
||||
|
||||
#ifndef int16
|
||||
typedef signed short int16;
|
||||
#endif
|
||||
|
||||
#ifndef uint8
|
||||
typedef unsigned char uint8;
|
||||
#endif
|
||||
|
||||
#ifndef int8
|
||||
typedef signed char int8;
|
||||
#endif
|
||||
|
||||
//#define CONFIG_SDK_WORDSIZE_64 /* not ready */
|
||||
#ifdef CONFIG_SDK_WORDSIZE_64
|
||||
typedef long int intptr;
|
||||
typedef unsigned long int uintptr;
|
||||
#else
|
||||
typedef int intptr;
|
||||
typedef unsigned int uintptr;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ipaddr_t
|
||||
typedef uint32 ipaddr_t; /* ipv4 address type */
|
||||
#endif
|
||||
|
||||
/* configuration mode type */
|
||||
typedef enum rtk_enable_e
|
||||
{
|
||||
DISABLED = 0,
|
||||
ENABLED,
|
||||
RTK_ENABLE_END
|
||||
} rtk_enable_t;
|
||||
|
||||
/* initial state of module */
|
||||
typedef enum init_state_e
|
||||
{
|
||||
INIT_NOT_COMPLETED = 0,
|
||||
INIT_COMPLETED,
|
||||
INIT_STATE_END
|
||||
} init_state_t;
|
||||
|
||||
/* ethernet address type */
|
||||
typedef struct rtk_mac_s
|
||||
{
|
||||
uint8 octet[ETHER_ADDR_LEN];
|
||||
} rtk_mac_t;
|
||||
|
||||
typedef uint32 osal_time_t;
|
||||
typedef uint32 osal_usecs_t;
|
||||
|
||||
/*
|
||||
* Macro Definition
|
||||
*/
|
||||
|
||||
#endif /* __COMMON_TYPE_H__ */
|
||||
|
||||
@ -776,21 +776,39 @@ static int mt7988_pwm1_funcs[] = { 1 };
|
||||
static int mt7988_pwm2_pins[] = { 80 };
|
||||
static int mt7988_pwm2_funcs[] = { 2 };
|
||||
|
||||
static int mt7988_pwm2_0_pins[] = { 58 };
|
||||
static int mt7988_pwm2_0_funcs[] = { 5 };
|
||||
|
||||
static int mt7988_pwm3_pins[] = { 81 };
|
||||
static int mt7988_pwm3_funcs[] = { 2 };
|
||||
|
||||
static int mt7988_pwm3_0_pins[] = { 59 };
|
||||
static int mt7988_pwm3_0_funcs[] = { 5 };
|
||||
|
||||
static int mt7988_pwm4_pins[] = { 82 };
|
||||
static int mt7988_pwm4_funcs[] = { 2 };
|
||||
|
||||
static int mt7988_pwm4_0_pins[] = { 60 };
|
||||
static int mt7988_pwm4_0_funcs[] = { 5 };
|
||||
|
||||
static int mt7988_pwm5_pins[] = { 83 };
|
||||
static int mt7988_pwm5_funcs[] = { 2 };
|
||||
|
||||
static int mt7988_pwm5_0_pins[] = { 61 };
|
||||
static int mt7988_pwm5_0_funcs[] = { 5 };
|
||||
|
||||
static int mt7988_pwm6_pins[] = { 69 };
|
||||
static int mt7988_pwm6_funcs[] = { 3 };
|
||||
|
||||
static int mt7988_pwm6_0_pins[] = { 62 };
|
||||
static int mt7988_pwm6_0_funcs[] = { 5 };
|
||||
|
||||
static int mt7988_pwm7_pins[] = { 70 };
|
||||
static int mt7988_pwm7_funcs[] = { 3 };
|
||||
|
||||
static int mt7988_pwm7_0_pins[] = { 4 };
|
||||
static int mt7988_pwm7_0_funcs[] = { 3 };
|
||||
|
||||
/* dfd */
|
||||
static int mt7988_dfd_pins[] = { 0, 1, 2, 3, 4 };
|
||||
static int mt7988_dfd_funcs[] = { 4, 4, 4, 4, 4 };
|
||||
@ -1113,6 +1131,8 @@ static const struct group_desc mt7988_groups[] = {
|
||||
PINCTRL_PIN_GROUP("xfi_phy_pll_i2c0", mt7988_xfi_phy_pll_i2c0),
|
||||
/* @GPIO(3,4): xfi_phy_pll_i2c1 */
|
||||
PINCTRL_PIN_GROUP("xfi_phy_pll_i2c1", mt7988_xfi_phy_pll_i2c1),
|
||||
/* @GPIO(4): pwm7 */
|
||||
PINCTRL_PIN_GROUP("pwm7_0", mt7988_pwm7_0),
|
||||
/* @GPIO(5,6) i2c0_0 */
|
||||
PINCTRL_PIN_GROUP("i2c0_0", mt7988_i2c0_0),
|
||||
/* @GPIO(5,6) i2c1_sfp */
|
||||
@ -1243,6 +1263,14 @@ static const struct group_desc mt7988_groups[] = {
|
||||
PINCTRL_PIN_GROUP("wo2_jtag", mt7988_wo2_jtag),
|
||||
/* @GPIO(57) pwm0 */
|
||||
PINCTRL_PIN_GROUP("pwm0", mt7988_pwm0),
|
||||
/* @GPIO(58) pwm2_0 */
|
||||
PINCTRL_PIN_GROUP("pwm2_0", mt7988_pwm2_0),
|
||||
/* @GPIO(59) pwm3_0 */
|
||||
PINCTRL_PIN_GROUP("pwm3_0", mt7988_pwm3_0),
|
||||
/* @GPIO(60) pwm4_0 */
|
||||
PINCTRL_PIN_GROUP("pwm4_0", mt7988_pwm4_0),
|
||||
/* @GPIO(61) pwm5_0 */
|
||||
PINCTRL_PIN_GROUP("pwm5_0", mt7988_pwm5_0),
|
||||
/* @GPIO(58,59,60,61,62) jtag */
|
||||
PINCTRL_PIN_GROUP("jtag", mt7988_jtag),
|
||||
/* @GPIO(58,59,60,61,62) tops_jtag0_1 */
|
||||
@ -1256,6 +1284,8 @@ static const struct group_desc mt7988_groups[] = {
|
||||
PINCTRL_PIN_GROUP("gbe1_led1", mt7988_gbe1_led1),
|
||||
PINCTRL_PIN_GROUP("gbe2_led1", mt7988_gbe2_led1),
|
||||
PINCTRL_PIN_GROUP("gbe3_led1", mt7988_gbe3_led1),
|
||||
/* @GPIO(62) pwm6_0 */
|
||||
PINCTRL_PIN_GROUP("pwm6_0", mt7988_pwm6_0),
|
||||
/* @GPIO(62) 2p5gbe_led1 */
|
||||
PINCTRL_PIN_GROUP("2p5gbe_led1", mt7988_2p5gbe_led1),
|
||||
/* @GPIO(64,65,66,67) gbe_led0 */
|
||||
@ -1336,7 +1366,8 @@ static const char * const mt7988_int_usxgmii_groups[] = {
|
||||
"int_usxgmii",
|
||||
};
|
||||
static const char * const mt7988_pwm_groups[] = {
|
||||
"pwm0", "pwm1", "pwm2", "pwm3", "pwm4", "pwm5", "pwm6", "pwm7"
|
||||
"pwm0", "pwm1", "pwm2", "pwm2_0", "pwm3", "pwm3_0", "pwm4", "pwm4_0",
|
||||
"pwm5", "pwm5_0", "pwm6", "pwm6_0", "pwm7", "pwm7_0",
|
||||
};
|
||||
static const char * const mt7988_dfd_groups[] = {
|
||||
"dfd",
|
||||
|
||||
@ -24,6 +24,9 @@ mediatek_setup_interfaces()
|
||||
acer,predator-w6)
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 game" eth1
|
||||
;;
|
||||
arcadyan,mozart)
|
||||
ucidef_set_interfaces_lan_wan "lan0 eth1" eth2
|
||||
;;
|
||||
asus,rt-ax59u|\
|
||||
cetron,ct3003|\
|
||||
cetron,ct3003-ubootmod|\
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
board_config_update
|
||||
|
||||
case $board in
|
||||
openwrt,one)
|
||||
ucidef_set_wireless_mac_count 2g 7
|
||||
ucidef_set_wireless_mac_count 5g 7
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
@ -95,6 +95,7 @@ platform_do_upgrade() {
|
||||
fit_do_upgrade "$1"
|
||||
;;
|
||||
acer,predator-w6|\
|
||||
arcadyan,mozart|\
|
||||
smartrg,sdg-8612|\
|
||||
smartrg,sdg-8614|\
|
||||
smartrg,sdg-8622|\
|
||||
@ -198,6 +199,7 @@ platform_check_image() {
|
||||
platform_copy_config() {
|
||||
case "$(board_name)" in
|
||||
acer,predator-w6|\
|
||||
arcadyan,mozart|\
|
||||
glinet,gl-mt2500|\
|
||||
glinet,gl-mt6000|\
|
||||
glinet,gl-x3000|\
|
||||
|
||||
@ -428,6 +428,7 @@ CONFIG_RPS=y
|
||||
CONFIG_RTC_CLASS=y
|
||||
CONFIG_RTC_DRV_MT7622=y
|
||||
CONFIG_RTC_I2C_AND_SPI=y
|
||||
CONFIG_RTL8261N_PHY=y
|
||||
# CONFIG_RTL8367S_GSW is not set
|
||||
CONFIG_RWSEM_SPIN_ON_OWNER=y
|
||||
CONFIG_SCHED_MC=y
|
||||
|
||||
@ -255,6 +255,30 @@ define Device/asus_tuf-ax4200
|
||||
endef
|
||||
TARGET_DEVICES += asus_tuf-ax4200
|
||||
|
||||
define Device/arcadyan_mozart
|
||||
DEVICE_VENDOR := Arcadyan
|
||||
DEVICE_MODEL := Mozart
|
||||
DEVICE_DTS := mt7988a-arcadyan-mozart
|
||||
DEVICE_DTS_DIR := ../dts
|
||||
DEVICE_DTC_FLAGS := --pad 4096
|
||||
DEVICE_DTS_LOADADDR := 0x45f00000
|
||||
DEVICE_PACKAGES := kmod-hwmon-pwmfan e2fsprogs f2fsck mkf2fs kmod-mt7996-firmware
|
||||
KERNEL_LOADADDR := 0x46000000
|
||||
KERNEL := kernel-bin | gzip
|
||||
KERNEL_INITRAMFS := kernel-bin | lzma | \
|
||||
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
|
||||
KERNEL_INITRAMFS_SUFFIX := .itb
|
||||
IMAGE_SIZE := $$(shell expr 64 + $$(CONFIG_TARGET_ROOTFS_PARTSIZE))m
|
||||
IMAGES := sysupgrade.itb
|
||||
IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-with-rootfs | pad-rootfs | append-metadata
|
||||
ARTIFACTS := emmc-preloader.bin emmc-bl31-uboot.fip emmc-gpt.bin
|
||||
ARTIFACT/emmc-gpt.bin := mt798x-gpt emmc
|
||||
ARTIFACT/emmc-preloader.bin := mt7988-bl2 emmc-comb
|
||||
ARTIFACT/emmc-bl31-uboot.fip := mt7988-bl31-uboot arcadyan_mozart
|
||||
SUPPORTED_DEVICES += arcadyan,mozart
|
||||
endef
|
||||
TARGET_DEVICES += arcadyan_mozart
|
||||
|
||||
define Device/asus_tuf-ax6000
|
||||
DEVICE_VENDOR := ASUS
|
||||
DEVICE_MODEL := TUF-AX6000
|
||||
|
||||
@ -424,6 +424,7 @@ CONFIG_RPS=y
|
||||
CONFIG_RTC_CLASS=y
|
||||
CONFIG_RTC_DRV_MT7622=y
|
||||
CONFIG_RTC_I2C_AND_SPI=y
|
||||
# CONFIG_RTL8261N_PHY is not set
|
||||
CONFIG_RTL8367S_GSW=y
|
||||
CONFIG_RWSEM_SPIN_ON_OWNER=y
|
||||
CONFIG_SCHED_MC=y
|
||||
|
||||
@ -541,6 +541,7 @@ CONFIG_RTC_CLASS=y
|
||||
# CONFIG_RTC_DRV_MT7622 is not set
|
||||
CONFIG_RTC_I2C_AND_SPI=y
|
||||
CONFIG_RTC_MC146818_LIB=y
|
||||
# CONFIG_RTL8261N_PHY is not set
|
||||
# CONFIG_RTL8367S_GSW is not set
|
||||
CONFIG_RWSEM_SPIN_ON_OWNER=y
|
||||
# CONFIG_SERIAL_8250_DMA is not set
|
||||
|
||||
@ -301,6 +301,7 @@ CONFIG_REGMAP_MMIO=y
|
||||
CONFIG_RESET_CONTROLLER=y
|
||||
CONFIG_RFS_ACCEL=y
|
||||
CONFIG_RPS=y
|
||||
# CONFIG_RTL8261N_PHY is not set
|
||||
# CONFIG_RTL8367S_GSW is not set
|
||||
CONFIG_RWSEM_SPIN_ON_OWNER=y
|
||||
CONFIG_SCSI=y
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
--- a/drivers/net/phy/Kconfig
|
||||
+++ b/drivers/net/phy/Kconfig
|
||||
@@ -399,6 +399,8 @@ config REALTEK_PHY
|
||||
help
|
||||
Supports the Realtek 821x PHY.
|
||||
|
||||
+source "drivers/net/phy/rtl8261n/Kconfig"
|
||||
+
|
||||
config RENESAS_PHY
|
||||
tristate "Renesas PHYs"
|
||||
help
|
||||
--- a/drivers/net/phy/Makefile
|
||||
+++ b/drivers/net/phy/Makefile
|
||||
@@ -100,6 +100,7 @@ obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja
|
||||
obj-y += qcom/
|
||||
obj-$(CONFIG_QSEMI_PHY) += qsemi.o
|
||||
obj-$(CONFIG_REALTEK_PHY) += realtek.o
|
||||
+obj-y += rtl8261n/
|
||||
obj-$(CONFIG_RENESAS_PHY) += uPD60620.o
|
||||
obj-$(CONFIG_ROCKCHIP_PHY) += rockchip.o
|
||||
obj-$(CONFIG_RTL8367S_GSW) += rtk/
|
||||
@ -0,0 +1,56 @@
|
||||
--- a/drivers/net/pcs/pcs-mtk-usxgmii.c
|
||||
+++ b/drivers/net/pcs/pcs-mtk-usxgmii.c
|
||||
@@ -52,6 +52,12 @@
|
||||
#define USXGMII_LPA GENMASK(15, 0)
|
||||
#define USXGMII_LPA_LATCH BIT(31)
|
||||
|
||||
+/* Register to control PCS polarity */
|
||||
+#define RG_PHY_TOP_CTRL0 0x82C
|
||||
+#define USXGMII_PN_SWAP_MASK GENMASK(1, 0)
|
||||
+#define USXGMII_PN_SWAP_RX BIT(1)
|
||||
+#define USXGMII_PN_SWAP_TX BIT(0)
|
||||
+
|
||||
/* Register to read PCS link status */
|
||||
#define RG_PCS_RX_STATUS0 0x904
|
||||
#define RG_PCS_RX_STATUS_UPDATE BIT(16)
|
||||
@@ -74,6 +80,7 @@ struct mtk_usxgmii_pcs {
|
||||
struct clk *clk;
|
||||
struct reset_control *reset;
|
||||
phy_interface_t interface;
|
||||
+ unsigned int polarity;
|
||||
unsigned int neg_mode;
|
||||
struct list_head node;
|
||||
};
|
||||
@@ -155,6 +162,10 @@ static int mtk_usxgmii_pcs_config(struct
|
||||
|
||||
mtk_usxgmii_reset(mpcs);
|
||||
|
||||
+ /* Configure the interface polarity */
|
||||
+ mtk_m32(mpcs, RG_PHY_TOP_CTRL0,
|
||||
+ USXGMII_PN_SWAP_MASK, mpcs->polarity);
|
||||
+
|
||||
/* Setup USXGMII AN ctrl */
|
||||
mtk_m32(mpcs, RG_PCS_AN_CTRL0,
|
||||
USXGMII_AN_SYNC_CNT | USXGMII_AN_ENABLE,
|
||||
@@ -332,6 +343,7 @@ static const struct phylink_pcs_ops mtk_
|
||||
static int mtk_usxgmii_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
+ struct device_node *np = dev->of_node;
|
||||
struct mtk_usxgmii_pcs *mpcs;
|
||||
|
||||
mpcs = devm_kzalloc(dev, sizeof(*mpcs), GFP_KERNEL);
|
||||
@@ -342,6 +354,13 @@ static int mtk_usxgmii_probe(struct plat
|
||||
if (IS_ERR(mpcs->base))
|
||||
return PTR_ERR(mpcs->base);
|
||||
|
||||
+ if (of_property_read_bool(np->parent, "mediatek,pnswap"))
|
||||
+ mpcs->polarity = USXGMII_PN_SWAP_TX | USXGMII_PN_SWAP_RX;
|
||||
+ else if (of_property_read_bool(np, "mediatek,pnswap-tx"))
|
||||
+ mpcs->polarity = USXGMII_PN_SWAP_TX;
|
||||
+ else if (of_property_read_bool(np, "mediatek,pnswap-rx"))
|
||||
+ mpcs->polarity = USXGMII_PN_SWAP_RX;
|
||||
+
|
||||
mpcs->dev = dev;
|
||||
mpcs->pcs.ops = &mtk_usxgmii_pcs_ops;
|
||||
mpcs->pcs.poll = true;
|
||||
Loading…
Reference in New Issue
Block a user