Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RoganDawes/0b21821408b96ad184abb07d6d01128d to your computer and use it in GitHub Desktop.
Save RoganDawes/0b21821408b96ad184abb07d6d01128d to your computer and use it in GitHub Desktop.
WIP OpenWrt patch for the Wink Hub v1.
From 12e6d1413b975a3d94d9492f0c27966abd3ebba4 Mon Sep 17 00:00:00 2001
From: Rogan Dawes <rogan@dawes.za.net>
Date: Thu, 6 Jul 2023 19:39:28 +0200
Subject: [PATCH] WIP: Add support for the Wink Hub v1
---
package/kernel/mac80211/broadcom.mk | 1 +
target/linux/mxs/config-5.15 | 4 +
target/linux/mxs/image/Makefile | 25 ++++
...-imx28-Add-alternate-DUART-pinmuxing.patch | 41 ++++++
...s-imx28-Add-device-tree-for-wink-hub.patch | 125 ++++++++++++++++++
5 files changed, 196 insertions(+)
create mode 100644 target/linux/mxs/patches-5.15/0001-ARM-dts-imx28-Add-alternate-DUART-pinmuxing.patch
create mode 100644 target/linux/mxs/patches-5.15/0002-PATCH-2-2-ARM-dts-imx28-Add-device-tree-for-wink-hub.patch
diff --git a/package/kernel/mac80211/broadcom.mk b/package/kernel/mac80211/broadcom.mk
index cf80ad2d32..11ca0e616b 100644
--- a/package/kernel/mac80211/broadcom.mk
+++ b/package/kernel/mac80211/broadcom.mk
@@ -431,6 +431,7 @@ define KernelPackage/brcmfmac/config
bool "Enable SDIO bus interface support"
default y if TARGET_bcm27xx
default y if TARGET_imx_cortexa7
+ default y if TARGET_mxs
default y if TARGET_sunxi
default n
help
diff --git a/target/linux/mxs/config-5.15 b/target/linux/mxs/config-5.15
index 67b2cfa373..f5d8eb1efe 100644
--- a/target/linux/mxs/config-5.15
+++ b/target/linux/mxs/config-5.15
@@ -151,6 +151,10 @@ CONFIG_MMC=y
CONFIG_MMC_BLOCK=y
CONFIG_MMC_MXS=y
CONFIG_MODULES_USE_ELF_REL=y
+CONFIG_MTD_NAND_CORE=y
+CONFIG_MTD_NAND_ECC=y
+CONFIG_MTD_NAND_GPMI_NAND=y
+CONFIG_MTD_RAW_NAND=y
CONFIG_MXS_DMA=y
# CONFIG_MXS_LRADC_ADC is not set
CONFIG_MXS_TIMER=y
diff --git a/target/linux/mxs/image/Makefile b/target/linux/mxs/image/Makefile
index bcb6001bac..3865dcd4bf 100644
--- a/target/linux/mxs/image/Makefile
+++ b/target/linux/mxs/image/Makefile
@@ -66,6 +66,31 @@ define Image/Build/Profile/duckbill
$(call Image/Build/SDCard-ext4-ext4,$(1),$(2),imx28-duckbill,duckbill)
endef
+define Device/wink_hub_v1
+ DEVICE_VENDOR := Wink
+ DEVICE_MODEL := Hub v1
+ DEVICE_PACKAGES := kmod-brcmfmac kmod-mmc cypress-firmware-4334-sdio ubi-utils wpad-basic-mbedtls
+ DEVICE_DTS := imx28-wink-hub-v1
+ CONFIG_TARGET_PER_DEVICE_ROOTFS := y
+ FEATURES += ramdisk nand ubifs
+ SUBPAGESIZE := 256
+ PAGESIZE := 512
+ BLOCKSIZE := 16k
+ DEVICE_DTC_FLAGS := --space 32768
+ IMAGE_SIZE := 27392k
+ IMAGES := sysupgrade.bin factory.img
+ KERNEL_NAME := zImage
+ KERNEL_SIZE := 4096k
+ KERNEL_LOADADDR := 0x40008000
+ KERNEL := kernel-bin | append-dtb | uImage none
+ IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+ IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi
+ UBINIZE_OPTS := -E 5
+ DEVICE_COMPAT_VERSION := 2.0
+endef
+TARGET_DEVICES += wink_hub_v1
+
+
define Image/Build
$(call Image/Build/$(1),$(1))
$(call Image/Build/Profile/$(PROFILE),$(1),$(IMG_PREFIX)-$(PROFILE)-sdcard.img)
diff --git a/target/linux/mxs/patches-5.15/0001-ARM-dts-imx28-Add-alternate-DUART-pinmuxing.patch b/target/linux/mxs/patches-5.15/0001-ARM-dts-imx28-Add-alternate-DUART-pinmuxing.patch
new file mode 100644
index 0000000000..a0ce1a396a
--- /dev/null
+++ b/target/linux/mxs/patches-5.15/0001-ARM-dts-imx28-Add-alternate-DUART-pinmuxing.patch
@@ -0,0 +1,41 @@
+From b5554f5f53076985795a716a5208f58c1242de2d Mon Sep 17 00:00:00 2001
+From: Fabio Estevam <festevam@gmail.com>
+Date: Fri, 23 Jun 2023 09:11:49 -0300
+Subject: [PATCH 1/2] ARM: dts: imx28: Add alternate DUART pinmuxing
+
+MX28_PAD_I2C0_SCL and MX28_PAD_I2C0_SDA can be used as DUART pins.
+
+Add such muxing possibility.
+
+This muxing is used on the imx28 wink hub v1 board.
+
+Signed-off-by: Fabio Estevam <festevam@gmail.com>
+---
+ arch/arm/boot/dts/imx28.dtsi | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
+index 291917b13834..24cd60cf5d4b 100644
+--- a/arch/arm/boot/dts/imx28.dtsi
++++ b/arch/arm/boot/dts/imx28.dtsi
+@@ -250,6 +250,17 @@ MX28_PAD_I2C0_SDA__DUART_TX
+ fsl,pull-up = <MXS_PULL_DISABLE>;
+ };
+
++ duart_pins_c: duart@2 {
++ reg = <2>;
++ fsl,pinmux-ids = <
++ MX28_PAD_I2C0_SCL__DUART_RX
++ MX28_PAD_I2C0_SDA__DUART_TX
++ >;
++ fsl,drive-strength = <MXS_DRIVE_8mA>;
++ fsl,voltage = <MXS_VOLTAGE_HIGH>;
++ fsl,pull-up = <MXS_PULL_DISABLE>;
++ };
++
+ duart_4pins_a: duart-4pins@0 {
+ reg = <0>;
+ fsl,pinmux-ids = <
+--
+2.34.1
+
diff --git a/target/linux/mxs/patches-5.15/0002-PATCH-2-2-ARM-dts-imx28-Add-device-tree-for-wink-hub.patch b/target/linux/mxs/patches-5.15/0002-PATCH-2-2-ARM-dts-imx28-Add-device-tree-for-wink-hub.patch
new file mode 100644
index 0000000000..13c061e4a2
--- /dev/null
+++ b/target/linux/mxs/patches-5.15/0002-PATCH-2-2-ARM-dts-imx28-Add-device-tree-for-wink-hub.patch
@@ -0,0 +1,125 @@
+From 4c626f580ae131d34cb2a60c0394ffbb5669e57f Mon Sep 17 00:00:00 2001
+From: Rogan Dawes <rogan@dawes.za.net>
+Date: Thu, 6 Jul 2023 14:15:30 +0200
+Subject: [PATCH] [PATCH 2/2] ARM: dts: imx28: Add device tree for wink hub v1
+
+Initial device support includes console UART, hardcoded NAND
+partitions, and SDIO WiFi.
+
+Signed-off-by: Rogan Dawes <rogan@dawes.za.net>
+---
+ arch/arm/boot/dts/imx28-wink-hub-v1.dts | 102 ++++++++++++++++++++++++
+ 1 file changed, 102 insertions(+)
+ create mode 100644 arch/arm/boot/dts/imx28-wink-hub-v1.dts
+
+diff --git a/arch/arm/boot/dts/imx28-wink-hub-v1.dts b/arch/arm/boot/dts/imx28-wink-hub-v1.dts
+new file mode 100644
+index 000000000000..fd2181d87392
+--- /dev/null
++++ b/arch/arm/boot/dts/imx28-wink-hub-v1.dts
+@@ -0,0 +1,102 @@
++// SPDX-License-Identifier: GPL-2.0+
++// Copyright (C) 2023 Fabio Estevam <festevam@gmail.com>
++
++/dts-v1/;
++#include <dt-bindings/gpio/gpio.h>
++#include "imx28.dtsi"
++/ {
++ model = "i.MX28 Wink Hub v1";
++ compatible = "wink,imx28-wink-hub-v1", "fsl,imx28";
++
++ memory@40000000 {
++ device_type = "memory";
++ reg = <0x40000000 0>; /* will be filled in by U-Boot */
++ };
++
++ reg_wifi: regulator-wifi {
++ compatible = "regulator-fixed";
++ pinctrl-names = "default";
++ pinctrl-0 = <&wifi_enable>;
++ regulator-name = "wifi";
++ regulator-min-microvolt = <3300000>;
++ regulator-max-microvolt = <3300000>;
++ gpio = <&gpio1 13 GPIO_ACTIVE_HIGH>;
++ enable-active-high;
++ };
++};
++
++&duart {
++ pinctrl-names = "default";
++ pinctrl-0 = <&duart_pins_c>;
++ status = "okay";
++};
++
++&gpmi {
++ pinctrl-names = "default";
++ pinctrl-0 = <&gpmi_pins_a &gpmi_status_cfg &gpmi_pins_extra>;
++ status = "okay";
++
++ partition@0 {
++ label = "gpmi-nfc-0-boot";
++ reg = <0x0000000 0x300000>;
++ read-only;
++ };
++
++ partition@300000 {
++ label = "updater-kernel";
++ reg = <0x0300000 0x400000>;
++ };
++
++ partition@700000 {
++ label = "updater-rootfs";
++ reg = <0x0700000 0x1c00000>;
++ };
++
++ partition@2300000 {
++ label = "database";
++ reg = <0x2300000 0x0800000>;
++ };
++
++ partition@2b00000 {
++ label = "app-kernel";
++ reg = <0x2b00000 0x0800000>;
++ };
++
++ partition@3300000 {
++ label = "gpmi-nfc-general-use";
++ reg = <0x3300000 0x4d00000>;
++ };
++};
++
++&ssp0 {
++ compatible = "fsl,imx28-mmc";
++ pinctrl-names = "default";
++ pinctrl-0 = <&mmc0_4bit_pins_a &mmc0_sck_cfg>;
++ vmmc-supply = <&reg_wifi>;
++ bus-width = <4>;
++ status = "okay";
++};
++
++&pinctrl {
++ gpmi_pins_extra: gpmi-pins-extra@0 {
++ reg = <0>;
++ fsl,pinmux-ids = <
++ MX28_PAD_GPMI_CE1N__GPMI_CE1N
++ MX28_PAD_GPMI_RDY1__GPMI_READY1
++ >;
++ fsl,drive-strength = <MXS_DRIVE_4mA>;
++ fsl,voltage = <MXS_VOLTAGE_HIGH>;
++ fsl,pull-up = <MXS_PULL_DISABLE>;
++ };
++
++ wifi_enable: wifi-enable@1 {
++ reg = <1>;
++ fsl,pinmux-ids = <
++ MX28_PAD_LCD_D13__GPIO_1_13
++ >;
++ fsl,drive-strength = <MXS_DRIVE_4mA>;
++ fsl,voltage = <MXS_VOLTAGE_HIGH>;
++ fsl,pull-up = <MXS_PULL_DISABLE>;
++ };
++};
++
+--
+2.30.2
+
--
2.30.2
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 5.15.117 (rogan@vermin) (arm-openwrt-linux-muslgnueabi-gcc (OpenWrt GCC 12.3.0 r23414-ed816f6ba8) 12.3.0, GNU ld (GNU Binutils) 2.40.0) #0 Thu Jun 22 22:21:48 2023
[ 0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
[ 0.000000] CPU: VIVT data cache, VIVT instruction cache
[ 0.000000] OF: fdt: Machine model: i.MX28 Wink Hub v1
[ 0.000000] Memory policy: Data cache writeback
[ 0.000000] Zone ranges:
[ 0.000000] Normal [mem 0x0000000040000000-0x0000000043ffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000040000000-0x0000000043ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x0000000043ffffff]
[ 0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[ 0.000000] pcpu-alloc: [0] 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 16240
[ 0.000000] Kernel command line: noinitrd console=ttyAMA0,115200 rootfstype=ubifs ubi.mtd=5 root=ubi0:rootfs rw gpmi
[ 0.000000] Unknown kernel command line parameters "gpmi", will be passed to user space.
[ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 52732K/65536K available (6144K kernel code, 562K rwdata, 1340K rodata, 3072K init, 201K bss, 12804K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000000] clocksource: mxs_timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[ 0.000005] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[ 0.000512] Calibrating delay loop... 227.32 BogoMIPS (lpj=1136640)
[ 0.080301] pid_max: default: 32768 minimum: 301
[ 0.083346] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.083456] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.088169] CPU: Testing write buffer coherency: ok
[ 0.092647] Setting up static identity map for 0x40100000 - 0x40100058
[ 0.111420] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.111546] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[ 0.112156] pinctrl core: initialized pinctrl subsystem
[ 0.117726] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.119324] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.122648] cpuidle: using governor ladder
[ 0.184033] No ATAGs?
[ 0.184466] Serial: AMBA PL011 UART driver
[ 0.185603] 80074000.serial: ttyAMA0 at MMIO 0x80074000 (irq = 214, base_baud = 0) is a PL011 rev2
[ 0.439510] printk: console [ttyAMA0] enabled
[ 0.472066] usbcore: registered new interface driver usbfs
[ 0.477807] usbcore: registered new interface driver hub
[ 0.483448] usbcore: registered new device driver usb
[ 0.489256] pps_core: LinuxPPS API ver. 1 registered
[ 0.494344] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 0.503621] PTP clock support registered
[ 0.512602] clocksource: Switched to clocksource mxs_timer
[ 0.523943] NET: Registered PF_INET protocol family
[ 0.529443] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 0.538533] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.547123] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.555034] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.562853] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.569980] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.576783] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.583508] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.591621] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 1.995359] workingset: timestamp_bits=14 max_order=14 bucket_order=0
[ 2.026334] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 2.032266] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[ 2.056685] mxs-dma 80004000.dma-apbh: initialized
[ 2.067988] mxs-dma 80024000.dma-apbx: initialized
[ 2.098258] nand: device found, Manufacturer ID: 0x01, Chip ID: 0xf1
[ 2.104782] nand: AMD/Spansion S34ML01G1
[ 2.108747] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[ 2.116760] Scanning device for bad blocks
[ 10.370076] 6 fixed-partitions partitions found on MTD device gpmi-nand
[ 10.376866] Creating 6 MTD partitions on "gpmi-nand":
[ 10.381980] 0x000000000000-0x000000300000 : "gpmi-nfc-0-boot"
[ 10.390964] 0x000000300000-0x000000700000 : "updater-kernel"
[ 10.406723] 0x000000700000-0x000002300000 : "updater-rootfs"
[ 10.415686] 0x000002300000-0x000002b00000 : "database"
[ 10.430903] 0x000002b00000-0x000003300000 : "app-kernel"
[ 10.439294] 0x000003300000-0x000008000000 : "gpmi-nfc-general-use"
[ 10.465401] gpmi-nand 8000c000.nand-controller: driver registered.
[ 10.475916] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 10.487914] stmp3xxx-rtc 80056000.rtc: registered as rtc0
[ 10.493571] stmp3xxx-rtc 80056000.rtc: setting system clock to 2023-06-23T23:58:01 UTC (1687564681)
[ 10.503391] i2c_dev: i2c /dev entries driver
[ 10.508881] stmp3xxx_rtc_wdt stmp3xxx_rtc_wdt: initialized watchdog with heartbeat 19s
[ 10.594862] NET: Registered PF_INET6 protocol family
[ 10.602809] mxs-mmc 80010000.spi: initialized
[ 10.629841] Segment Routing with IPv6
[ 10.633915] In-situ OAM (IOAM) with IPv6
[ 10.638162] NET: Registered PF_PACKET protocol family
[ 10.643537] 8021q: 802.1Q VLAN Support v1.8
[ 10.674735] uart-pl011 80074000.serial: no DMA platform data
[ 10.694621] Freeing unused kernel image (initmem) memory: 3072K
[ 10.700844] Run /init as init process
[ 10.704693] with arguments:
[ 10.704720] /init
[ 10.704738] gpmi
[ 10.704750] with environment:
[ 10.704761] HOME=/
[ 10.704772] TERM=linux
[ 10.806896] mmc0: new high speed SDIO card at address 0001
[ 11.909036] init: Console is alive
[ 11.913829] init: - watchdog -
[ 11.960458] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[ 11.971352] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[ 11.980918] init: - preinit -
[ 12.487082] random: jshn: uninitialized urandom read (4 bytes read)
[ 12.608264] random: jshn: uninitialized urandom read (4 bytes read)
[ 12.687082] random: jshn: uninitialized urandom read (4 bytes read)
[ 15.253943] procd: - early -
[ 15.257441] procd: - watchdog -
[ 16.020359] procd: - watchdog -
[ 16.026238] procd: - ubus -
[ 16.050349] random: ubusd: uninitialized urandom read (4 bytes read)
[ 16.080999] random: ubusd: uninitialized urandom read (4 bytes read)
[ 16.088953] random: ubusd: uninitialized urandom read (4 bytes read)
[ 16.113061] procd: - init -
[ 17.839778] random: jshn: uninitialized urandom read (4 bytes read)
[ 17.896722] kmodloader: loading kernel modules from /etc/modules.d/*
[ 17.913498] random: ubusd: uninitialized urandom read (4 bytes read)
[ 17.923172] random: ubus: uninitialized urandom read (4 bytes read)
[ 17.998439] urngd: v1.0.2 started.
[ 18.004783] Loading modules backported from Linux version v6.1.24-0-g0102425ac76b
[ 18.012334] Backport generated by backports.git v5.15.92-1-44-gd6ea70fafd36
[ 18.529964] random: crng init done
[ 18.533585] random: 19 urandom warning(s) missed due to ratelimiting
[ 18.606279] PPP generic driver version 2.4.2
[ 18.619957] NET: Registered PF_PPPOX protocol family
[ 18.689355] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4334-sdio for chip BCM4334/3
[ 18.698771] usbcore: registered new interface driver brcmfmac
[ 18.705124] brcmfmac mmc0:0001:1: Direct firmware load for brcm/brcmfmac4334-sdio.wink,imx28-wink-hub-v1.bin failed with error -2
[ 18.716944] brcmfmac mmc0:0001:1: Falling back to sysfs fallback for: brcm/brcmfmac4334-sdio.wink,imx28-wink-hub-v1.bin
[ 18.820127] kmodloader: done loading kernel modules from /etc/modules.d/*
[ 18.863804] brcmfmac mmc0:0001:1: Direct firmware load for brcm/brcmfmac4334-sdio.bin failed with error -2
[ 18.873669] brcmfmac mmc0:0001:1: Falling back to sysfs fallback for: brcm/brcmfmac4334-sdio.bin
[ 19.952838] brcmfmac: brcmf_sdio_htclk: HT Avail timeout (1000000): clkctl 0x50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment