Adding support for DLink DSL 3580L

I am adding support for DLink DSL 3580L (broadcom 6362 with integrated wifi + bcm4352 variant mini-pcie), i have successfully run an image that do not crash and have working ethernet, if someone is interested on helping the port, please check https://github.com/aleferri/openwrt-dsl3580l.

I am also looking for information on the strange flash layout i found, the router has 16 MB flash, checked visually by looking at the chip soldered, but also reported by the dmesg, but the stock firmware use just 7.5 MB of space, and just after CFE + stock there are 4 different areas, one 1.5 Mb non-erased block with high entropy, one erased block of around 7 MB, some padding with low entropy and then the broadcom nvmem, maybe some of you encountered a similar layout somewhere else and can explain its purpose

That sounds a lot like a split firmware image. It's common for a device to store two firmware images to flash in case one of them gets corrupt. After you make a backup of the whole flash, you should be able use to space occupied by the two vendor OS images for a single openwrt one.

After i found the bin of the original firmware, i think i got it, the 1.5 MB block with high entropy is the linux kernel, because the firmware image has the kernel at the end of rootfs, instead of using openwrt convention (kernel at start + rootfs after), so, the 7.5MB + 1.5 MB = 9 MB occupied for original firmware, so i can safely override that block too

Update: encountered endiannes problem enumerating internal SoC components with bcma, will create a temp patche to fix; bcma sprom rev11 now read correctly, will begin testing ac network

Partial victory, bcma now sees the integrated wifi inside the SoC, switching to filling the bits in b43 to add support

Dmesg after patches:

[    1.070000] bcma-sprom bcm6362-sprom: patching SPROM with 1 fixups...
[    1.080000] bcma-sprom bcm6362-sprom: mtd mac d8:fe:e3:e2:a1:3d
[    1.090000] bcma-sprom bcm6362-sprom: registered SPROM for SoC bcma [wlan]
[    1.090000] bcma-fbs: SPROM r11: board=0x0668 rev=4947 ccode=0x0000 txchain=0x3 rxchain=0x3 subband5gver=4
[    1.100000] bcma-fbs: SPROM r11 rxgains 5gl: c0={3,6,1} c1={3,6,1}
[    1.110000] bcma-sprom bcm4352-sprom: mtd mac d8:fe:e3:e2:a1:3e
[    1.120000] bcma-sprom bcm4352-sprom: registered SPROM for [1:0]
[    1.280000] bcma-host-soc 10004000.axi: bus0: Found chip with id 0x6362, rev 0x01 and package 0x00
[    1.290000] bcma-host-soc 10004000.axi: bus0: Core 0 found: ChipCommon (manuf 0x4BF, id 0x800, rev 0x23, class 0x0)
[    1.310000] bcma-host-soc 10004000.axi: bus0: Core 1 found: IEEE 802.11 (manuf 0x4BF, id 0x812, rev 0x16, class 0x0)
[    1.320000] bcma-host-soc 10004000.axi: bus0: Core 2 found: SHIM (manuf 0x4BF, id 0x837, rev 0x01, class 0x0)
[    1.330000] bcma-host-soc 10004000.axi: bus0: Flash type not supported
[    1.330000] bcma-sprom bcm6362-sprom: requested by SoC bcma [wlan]
[    1.340000] bcma-host-soc 10004000.axi: bus0: Bus registered
[    1.750000] bcma-pci-bridge 0000:01:00.0: enabling device (0000 -> 0002)
[    1.760000] bcma-pci-bridge 0000:01:00.0: bus1: Found chip with id 0x4352, rev 0x03 and package 0x01
[    1.770000] bcma-pci-bridge 0000:01:00.0: bus1: Core 0 found: ChipCommon (manuf 0x4BF, id 0x800, rev 0x2B, class 0x0)
[    1.780000] bcma-pci-bridge 0000:01:00.0: bus1: Core 1 found: IEEE 802.11 (manuf 0x4BF, id 0x812, rev 0x2A, class 0x0)
[    1.790000] bcma-pci-bridge 0000:01:00.0: bus1: Core 2 found: ARM CR4 (manuf 0x4BF, id 0x83E, rev 0x02, class 0x0)
[    1.800000] bcma-pci-bridge 0000:01:00.0: bus1: Core 3 found: PCIe Gen2 (manuf 0x4BF, id 0x83C, rev 0x01, class 0x0)
[    1.810000] bcma-pci-bridge 0000:01:00.0: bus1: Core 4 found: USB 2.0 Device (manuf 0x4BF, id 0x81A, rev 0x11, class 0x0)
[    1.860000] bcma: bcma: SPROM rev 11 parsed: board=0x0668 rev=4947 ccode=0x0000 txchain=0x3 rxchain=0x3 antswitch=0 subband5gver=4
[    1.870000] bcma: bcma: SPROM r11 chain0 rxgains 2g={0,0,0} 5gl={3,6,1} 5gm={7,15,1} 5gh={7,15,1}
[    1.880000] bcma: bcma: SPROM r11 chain1 rxgains 2g={0,0,0} 5gl={3,6,1} 5gm={7,15,1} 5gh={7,15,1}
[    1.890000] bcma: bcma: SPROM r11 chain2 rxgains 2g={0,0,0} 5gl={3,6,1} 5gm={7,15,1} 5gh={7,15,1}
[    1.900000] bcma-pci-bridge 0000:01:00.0: bus1: Bus registered

To the onlookers, do not try to run at this stage, b43 will trigger a kernel panic on load trying to access unavailable locations on the shim, if you wish to try it, build b43 as a kernel module and then load it from /tmp, it will crash anyway, but at least the router will only hard reset. I am working out a patch to fix this from bcma, leaving b43 with minimal patches for 2.4Ghz