Skip to content

Commit 596ce28

Browse files
jameywinehauke
authored andcommitted
realtek: arch: rtl-otto: add rtl9607 model info support
Add the registers, family id and cpu port defines to the mach header. Since RTL96xx SoCs has additional "subtype" info, add the respective property to soc_info struct to be used in prom file. The same way as rtl838x, the chip_info register requires 0xa to be written. Similarly, 0xb must be written to get the subtype info. There doesn't seem any check for testchip in RTL96xx so, we ignore it. Add subtype information to set_system_type function if it is present using the added subtype variable. There are some RTL9607 chips out there with 512MB so add the check for RTL9607 in the prepare_highmem. The registers are the same as in RTL9300 so nothing else need to be changed. Signed-off-by: Rustam Adilov <adilov@tutamail.com> Link: openwrt/openwrt#23023 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
1 parent 0509464 commit 596ce28

2 files changed

Lines changed: 44 additions & 4 deletions

File tree

target/linux/realtek/files-6.18/arch/mips/include/asm/mach-rtl-otto/mach-rtl-otto.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#define RTL839X_CHIP_INFO (0x0FF4)
2626
#define RTL93XX_MODEL_NAME_INFO (0x0004)
2727
#define RTL93XX_CHIP_INFO (0x0008)
28+
#define RTL96XX_MODEL_NAME_INFO (0x10000)
29+
#define RTL96XX_CHIP_INFO (0x10004)
30+
#define RTL96XX_CHIP_SUB_INFO (0x10008)
2831

2932
#define RTL838X_INT_RW_CTRL (0x0058)
3033
#define RTL838X_EXT_VERSION (0x00D0)
@@ -38,12 +41,14 @@
3841
#define RTL8390_FAMILY_ID (0x8390)
3942
#define RTL9300_FAMILY_ID (0x9300)
4043
#define RTL9310_FAMILY_ID (0x9310)
44+
#define RTL9607_FAMILY_ID (0x9607)
4145

4246
/* Basic SoC Features */
4347
#define RTL838X_CPU_PORT 28
4448
#define RTL839X_CPU_PORT 52
4549
#define RTL930X_CPU_PORT 28
4650
#define RTL931X_CPU_PORT 56
51+
#define RTL9607_CPU_PORT 9
4752

4853
struct rtl83xx_soc_info {
4954
unsigned char *name;
@@ -52,6 +57,7 @@ struct rtl83xx_soc_info {
5257
unsigned int revision;
5358
unsigned int cpu;
5459
bool testchip;
60+
unsigned int subtype;
5561
int cpu_port;
5662
int memory_size;
5763
};

target/linux/realtek/files-6.18/arch/mips/rtl-otto/prom.c

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,23 @@ static void __init rtl93xx_read_details(u32 model)
215215
soc_info.testchip = true;
216216
}
217217

218+
static void __init rtl96xx_read_details(u32 model)
219+
{
220+
u32 chip_info, chip_subtype;
221+
222+
sw_w32(0xa << 28, RTL96XX_CHIP_INFO);
223+
224+
chip_info = sw_r32(RTL96XX_CHIP_INFO);
225+
soc_info.cpu = chip_info & 0xffff;
226+
227+
sw_w32(0xb << 28, RTL96XX_CHIP_SUB_INFO);
228+
229+
chip_subtype = sw_r32(RTL96XX_CHIP_SUB_INFO);
230+
soc_info.subtype = chip_subtype & 0x1f;
231+
232+
soc_info.revision = model & 0xf;
233+
}
234+
218235
static u32 __init read_model(void)
219236
{
220237
u32 model, id;
@@ -259,6 +276,16 @@ static u32 __init read_model(void)
259276
return model;
260277
}
261278

279+
model = sw_r32(RTL96XX_MODEL_NAME_INFO);
280+
id = model >> 16 & 0xffff;
281+
if (id == 0x9607) {
282+
soc_info.id = id;
283+
soc_info.family = RTL9607_FAMILY_ID;
284+
soc_info.cpu_port = RTL9607_CPU_PORT;
285+
rtl96xx_read_details(model);
286+
return model;
287+
}
288+
262289
return 0;
263290
}
264291

@@ -281,16 +308,20 @@ static void __init set_system_type(void)
281308
{
282309
char revision = '?';
283310
char *es = "";
311+
char subtype[12] = "";
284312

285313
if (soc_info.revision >= 0 && soc_info.revision < 26)
286314
revision = 'A' + soc_info.revision;
287315

288316
if (soc_info.testchip)
289317
es = " ES";
290318

319+
if (soc_info.subtype)
320+
snprintf(subtype, sizeof(subtype), " subtype %02X", soc_info.subtype);
321+
291322
snprintf(rtl_system_type, sizeof(rtl_system_type),
292-
"Realtek %s%s rev %c (%04X)",
293-
soc_info.name, es, revision, soc_info.cpu);
323+
"Realtek %s%s%s rev %c (%04X)",
324+
soc_info.name, es, subtype, revision, soc_info.cpu);
294325
}
295326

296327
static void get_system_memory(void)
@@ -311,8 +342,11 @@ static void get_system_memory(void)
311342

312343
static void prepare_highmem(void)
313344
{
314-
if ((soc_info.family != RTL9300_FAMILY_ID) ||
315-
(soc_info.memory_size <= 256 * 1024 * 1024) ||
345+
if (soc_info.family != RTL9300_FAMILY_ID &&
346+
soc_info.family != RTL9607_FAMILY_ID)
347+
return;
348+
349+
if ((soc_info.memory_size <= 256 * 1024 * 1024) ||
316350
!IS_ENABLED(CONFIG_HIGHMEM))
317351
return;
318352

0 commit comments

Comments
 (0)