Commit Graph
180 Commits
Author SHA1 Message Date
René van Dorst 11d2c843e5 Fixed to make SWGT024 V2.0 work 2025-12-13 22:22:40 +01:00
logicog 28f832a24d Fix PHY issues 2025-12-13 22:22:40 +01:00
logicog d71a303f6c Move RTL8372 SMI address configuration 2025-12-13 22:22:40 +01:00
logicog 1cdc8d2cf7 De-Magic switch init 2025-12-13 09:25:58 +01:00
logicog edfb86bff4 Use SFP pin definitions and I2C ports for SFP modules 2025-12-13 09:25:58 +01:00
logicog d75ad636f9 Use machine structure 2025-12-12 09:06:52 +01:00
logicog 636981c3b8 Detect 2nd SFP-slot RX-Los on KP-9000-6XHML-2X 2025-12-08 08:39:54 +01:00
logicog 101b4937e1 Fix link change handling
The RTL8272/3 use 2 32 bit registers to indicate the MAC link speed, the
second register is used for ports 8 and 9, where 9 is the CPU port.
Use both registers.
2025-12-08 08:39:54 +01:00
logicog 32b5539670 Do not show non-ascii Transceiver field in SFP module description 2025-12-07 10:59:39 +01:00
logicog 9c21d94b65 Add read_reg_timer function 2025-12-01 18:26:46 +01:00
logicog 70c14fb23e Add get_random_32() 2025-12-01 18:26:46 +01:00
René van Dorst f59be9cf2b Added software version + git short hash string to firmware.
The Makefile has the version number and generates a version.h which
has VERSION_SW define that looks like "v<VERSION>-g<GIT_SHORT_HASH>".

Software version shows at boot in the serial console.
And shown with command: `version`.

It can also be requested via `information.json`.
```
{
    "ip_address": "192.168.10.247",
    "ip_gateway": "192.168.10.1",
    "ip_netmask": "255.255.255.0",
    "mac_address": "1c:2a:a3:23:00:02",
    "sw_ver": "v0.1.0-gd48235f",
    "hw_ver": "SWGT024-V2.0"
}
```
2025-11-26 23:08:23 +01:00
logicog 9c7572b289 De-Magic I2C configuration for SFP-EEPROM reads 2025-11-02 09:49:13 +01:00
René van Dorst d0b6a73bf2 Merge pull request #30 from logicog/crc16
CRC-16 Calculation and verification
2025-10-26 21:59:50 +00:00
logicog eb0e4df5ea Fix reset after image upload 2025-10-26 14:20:30 +01:00
logicog ba902a68d4 Defer cmd execution for console and via http POST 2025-10-21 18:05:33 +02:00
logicog ac4f0d410f Add CRC16 initial code 2025-10-20 07:29:39 +02:00
René van Dorst a59f92a648 Also use struct flash_region in flash_read_security(), flash_sector_erase(). 2025-10-05 16:53:46 +02:00
René van Dorst 7a87b79871 Convert flash_addr to struct flash_region.
flash_region storage flash address and length, which a operation is needed.
2025-10-05 15:36:08 +02:00
logicog 05492e601a Reducing IMEM footprint in flash routines 2025-09-30 20:45:44 +02:00
logicog 110c403443 Adding firmware update at beginning of boot if a new image is found in second half of flash 2025-09-30 20:45:44 +02:00
logicog 6aa28b7385 Cleanup and increase of flash_buf size for flash write buffer 2025-09-30 20:45:44 +02:00
logicog 9ad5fcb43e Add STP handling
Adds a timeer for calling the STP state machine which currently sends out
CNF (HELLO) packages.

Identifies incoming STP packets and calls the stp_in() routine to handle these.
2025-09-08 22:22:57 +02:00
René van Dorst 7e729c626c cmd: add reg read and write.
like:
* `reg w 04`
* `reg w 04 00023678`
2025-09-07 01:03:15 +02:00
René van Dorst 74b8280d80 gpio: SOC only has 64 gpio not 96.
Remove BANK_A
Rename BANK_B to GPIO_00_31
Rename BACK_C to GPIO_32_63

Added also _INPUT, _DIRECTIOn registers
2025-09-06 17:04:25 +02:00
René van Dorst c5995a4184 Add: phy_modify() to modify phy_registers.
Makes it easier to modify set/clear bit in a phy register.
Simulair like Linux PHY-core: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/phy/phy-core.c#n551
2025-09-02 22:23:02 +02:00
René van Dorst cc132a8734 phy_write(): also use SFR_DATA_U16 and SFR_SMI_REG_U16
Was added by pr#7.
2025-09-01 09:59:41 +02:00
René van Dorst 689d208ff1 phy: fix whitespace and comments alinement 2025-09-01 09:59:06 +02:00
René van Dorst b8928a8bcd Replace manual SFR_DATA_0 and SFR_DATA_8 pair read and write with SFR_DATA_U16.
Also added SFR_SMI_REG_U16.

Doing pval = reg_h; pval <<= 8; pval |= reg_l; dont always optimized by the compiler a some places, not all.

A snipped of the diff between two .asm files.

5414,5424c5414,5416
< ;     rtlplayground.c:1382: uint16_t pval = SFR_DATA_8;
< ;     rtlplayground.c:1383: pval <<= 8;
<       mov     r7,_SFR_DATA_8
<       mov     r6,#0x00
< ;     rtlplayground.c:1384: pval |= SFR_DATA_0;
<       mov     r4,_SFR_DATA_0
<       mov     r5,#0x00
<       mov     a,r6
<       orl     ar4,a
<       mov     a,r7
<       orl     ar5,a
---
> ;     rtlplayground.c:1382: uint16_t pval = SFR_DATA_U16;
>       mov     r6,((_SFR_DATA_U16 >> 0) & 0xFF)
>       mov     r7,((_SFR_DATA_U16 >> 8) & 0xFF)
2025-09-01 09:20:36 +02:00
René van Dorst 9dafeab490 Added SFR_NIC_DATA_U16LE and SFR_NIC_RING_U16LE.
Let's use sfr16 for NIC data and ring.
SFR define can so reordered to it does the BE to LE swap for us.
2025-09-01 09:20:36 +02:00
René van Dorst af0135bcce Add sfr16 SFR_REG_ADDR_U16.
So instead do it manual split a uint16_t in to two uint8_t.
The compiler can do it, so reduces user error.
Note: compiler writes the lower/LSB part first.
      When that is importent this can´t be used.

Assembly is still the same except note above.
2025-09-01 09:20:36 +02:00
René van Dorst 7ff028303d Add phy_write() with bit_mask lookup inside the function.
Move the lookup saves a lot of instructions for every phy_write() call.

Assembly diff for one change.
< ;     rtl837x_phy.c:240: phy_write_mask(bit_mask[port], 0x07, 0x00, 0x3200);  // Enable AN
<       mov     dpl,r5
<       mov     dph,r6
---
> ;     rtl837x_phy.c:240: phy_write(port, 0x07, 0x00, 0x3200); // Enable AN
>       mov     _phy_write_PARM_2,#0x07
1345,1359c1019,1024
<       movc    a,@a+dptr
<       mov     r5,a
<       inc     dptr
<       clr     a
<       movc    a,@a+dptr
<       mov     r6,a
<       mov     _phy_write_mask_PARM_2,#0x07
<       clr     a
<       mov     _phy_write_mask_PARM_3,a
<       mov     (_phy_write_mask_PARM_3 + 1),a
<       mov     _phy_write_mask_PARM_4,a
<       mov     (_phy_write_mask_PARM_4 + 1),#0x32
<       mov     dpl, r5
<       mov     dph, r6
<       lcall   _phy_write_mask
---
>       mov     _phy_write_PARM_3,a
>       mov     (_phy_write_PARM_3 + 1),a
>       mov     _phy_write_PARM_4,a
>       mov     (_phy_write_PARM_4 + 1),#0x32
>       mov     dpl, r7
>       lcall   _phy_write

Replace all phy_write_mask(bit_mask[<var>], ...) to phy phy_write(<var>, ...).
2025-09-01 00:12:12 +02:00
René van Dorst d6ea9be4c0 rename phy_write() to phy_write_mask().
It seems that bit_mask[phy] lookup is expensive and it used in many places.
But most of the time we only addressing a single phy.
2025-09-01 00:07:27 +02:00
logicog 829fbf707a Use uip for mac-address, enable STP packages 2025-08-30 18:43:31 +02:00
logicog 83dcd22863 Add STP packet identification 2025-08-30 08:29:25 +02:00
logicog 81b7e4fa87 Identify pin configuration registers 2025-08-22 09:04:34 +02:00
logicog 52f8366d03 Improve command parser to work with other than serial buffer 2025-08-21 16:11:22 +02:00
logicog 940ee648df Use definition of NSFP in header file 2025-08-20 10:19:07 +02:00
logicog ad53165351 Introduce identified RX/TX control register names 2025-08-19 09:34:14 +02:00
logicog 0fb4fafdb2 strtox now returns copied length 2025-08-05 09:34:44 +02:00
logicog 8b1b4aff68 Fix parsing of mirror command, fix parsing of serial buffer beyond wrap arond, add bulk reading of flash and start of config file parser 2025-07-28 23:04:08 +02:00
logicog a5d156a645 Fix dropping of RTL VLAN tag for 802.1Q Tag, add L2 configuration 2025-07-25 22:51:18 +02:00
logicog 0b30019769 Use names for I2C-controller registers 2025-07-23 08:34:26 +02:00
logicog 96a108e891 Use common SDS configuration code also for RTL8224 2025-07-23 08:01:33 +02:00
logicog bcc58d2965 Make RTL8224 work 2025-07-22 19:05:27 +02:00
logicog 8fee855da2 Separate code for rtl8272 from rtl8373 for readability and stability against accidental changes 2025-07-22 09:42:56 +02:00
logicog ccd8bf1633 Cleanup 2025-07-17 23:29:20 +02:00
logicog b0a41a5af6 Add support for RTL8372-devices with 2 SFP+ ports 2025-07-17 13:25:07 +02:00
logicog d66931acdf Adding initial http daemon implementation 2025-07-13 12:03:40 +02:00
logicog b192a87cab Cleaning up printouts for debugging of uIP 2025-07-11 16:36:16 +02:00