Marketing name: Apple iPod nano (4th generation)

Signed-off-by: Vencislav Atanasov <[email protected]>
---
 arch/arm/dts/s5l8720-n58s.dts           | 26 +++++++++++++++
 arch/arm/dts/s5l8720.dtsi               | 42 ++++++++++++++++++++++++
 arch/arm/mach-s5l87xx/Kconfig           |  1 +
 arch/arm/mach-s5l87xx/Makefile          |  5 +++
 arch/arm/mach-s5l87xx/s5l8720.c         | 18 +++++++++++
 arch/arm/mach-s5l87xx/s5l8720/Kconfig   | 12 +++++++
 arch/arm/mach-s5l87xx/s5l87xx-otg-phy.c | 55 +++++++++++++++++++++++++++++++
 board/apple/n58s/Kconfig                | 15 +++++++++
 board/apple/n58s/Makefile               |  7 ++++
 board/apple/n58s/n58s.c                 | 57 +++++++++++++++++++++++++++++++++
 configs/apple_n58s_defconfig            | 33 +++++++++++++++++++
 include/configs/apple_n58s.h            | 15 +++++++++
 12 files changed, 286 insertions(+)

diff --git a/arch/arm/dts/s5l8720-n58s.dts b/arch/arm/dts/s5l8720-n58s.dts
new file mode 100644
index 00000000000..033127ebe28
--- /dev/null
+++ b/arch/arm/dts/s5l8720-n58s.dts
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * Apple iPod nano (4th generation)
+ *
+ * target-type: N58s
+ *
+ * Copyright (C) 2026 The freemyipod team (freemyipod.org)
+ */
+
+/dts-v1/;
+
+#include "s5l8720.dtsi"
+#include "s5l87xx-nxx.dtsi"
+
+/ {
+       compatible = "apple,n58s", "samsung,s5l8720", "apple,arm-platform";
+       model = "Apple iPod nano (4th generation)";
+};
+
+&memory {
+       reg = <0x08000000 0x02000000>; /* 32 MiB SDRAM */
+};
+
+&clkref {
+       clock-frequency = <24000000>;
+};
diff --git a/arch/arm/dts/s5l8720.dtsi b/arch/arm/dts/s5l8720.dtsi
new file mode 100644
index 00000000000..1c6853deaa6
--- /dev/null
+++ b/arch/arm/dts/s5l8720.dtsi
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * Samsung S5L8720 SoC
+ *
+ * Other names: M2S
+ *
+ * Copyright (C) 2026 The freemyipod team (freemyipod.org)
+ */
+
+#include "s5l87xx.dtsi"
+#include "s5l8702-common.dtsi"
+
+/ {
+       compatible = "samsung,s5l8720", "apple,arm-platform";
+
+       chosen {
+               stdout-path = &uart0;
+       };
+};
+
+&cpu0 {
+       compatible = "arm,arm1176jzf-s";
+};
+
+&clkgates {
+       /*
+        * Clock-gate name -> {gate, bit} table consumed by 
s5l87xx_enable_clkgate().
+        * Each entry is two cells: gate * 32 + bit, with 0xffffffff for an 
unused
+        * second gate.
+        */
+       clock-gate-names = "timer0", "timer1", "timer2", "timer3", "timer4",
+                                          "timer5", "timer6", "timer7", 
"timer8",
+                                          "uart0", "usb-otg", "usb2-phy", 
"bootrom";
+       samsung,clock-gates = <37 128>, <55 129>, <56 130>, <57 131>, <58 132>,
+                                                 <59 133>, <60 134>, <69 150>, 
<70 151>,
+                                                 <41 135>, <2 0xffffffff>, <35 
0xffffffff>,
+                                                 <13 0xffffffff>;
+};
+
+&uart0 {
+       status = "okay";
+};
diff --git a/arch/arm/mach-s5l87xx/Kconfig b/arch/arm/mach-s5l87xx/Kconfig
index 11eeb4d7467..6a873f10675 100644
--- a/arch/arm/mach-s5l87xx/Kconfig
+++ b/arch/arm/mach-s5l87xx/Kconfig
@@ -59,5 +59,6 @@ endchoice
 
 source "arch/arm/mach-s5l87xx/s5l8701/Kconfig"
 source "arch/arm/mach-s5l87xx/s5l8702/Kconfig"
+source "arch/arm/mach-s5l87xx/s5l8720/Kconfig"
 
 endif
diff --git a/arch/arm/mach-s5l87xx/Makefile b/arch/arm/mach-s5l87xx/Makefile
index 4cccb797da2..62564a34645 100644
--- a/arch/arm/mach-s5l87xx/Makefile
+++ b/arch/arm/mach-s5l87xx/Makefile
@@ -14,3 +14,8 @@ obj-$(CONFIG_S5L8702) += relocate.o
 obj-$(CONFIG_S5L8702) += s5l8702.o
 obj-$(CONFIG_S5L8702) += s5l8702-otg-phy.o
 obj-$(CONFIG_S5L8702) += s5l87xx-timer.o
+
+obj-$(CONFIG_S5L8720) += relocate.o
+obj-$(CONFIG_S5L8720) += s5l8720.o
+obj-$(CONFIG_S5L8720) += s5l87xx-otg-phy.o
+obj-$(CONFIG_S5L8720) += s5l87xx-timer.o
diff --git a/arch/arm/mach-s5l87xx/s5l8720.c b/arch/arm/mach-s5l87xx/s5l8720.c
new file mode 100644
index 00000000000..84d049ec4f0
--- /dev/null
+++ b/arch/arm/mach-s5l87xx/s5l8720.c
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2026 The freemyipod team (freemyipod.org)
+ */
+
+#include <init.h>
+
+int print_cpuinfo(void)
+{
+       printf("CPU:   Samsung S5L8720 (ARM1176JZF-S)\n");
+       return 0;
+}
+
+ulong get_tbclk(void)
+{
+       // Corresponds to TIMER_F setup from s5l87xx.c.
+       return 1000000;
+}
diff --git a/arch/arm/mach-s5l87xx/s5l8720/Kconfig 
b/arch/arm/mach-s5l87xx/s5l8720/Kconfig
new file mode 100644
index 00000000000..ce3db2e7c78
--- /dev/null
+++ b/arch/arm/mach-s5l87xx/s5l8720/Kconfig
@@ -0,0 +1,12 @@
+if S5L8720
+
+config TARGET_N58S
+       bool "Apple N58s - iPod nano (4th generation)"
+       default y
+       help
+         Apple iPod nano (4th generation) is a digital audio player, 
introduced in
+         September 2008. It has a NAND flash of either 8 or 16 GiB.
+
+source "board/apple/n58s/Kconfig"
+
+endif
diff --git a/arch/arm/mach-s5l87xx/s5l87xx-otg-phy.c 
b/arch/arm/mach-s5l87xx/s5l87xx-otg-phy.c
new file mode 100644
index 00000000000..058ae8406ab
--- /dev/null
+++ b/arch/arm/mach-s5l87xx/s5l87xx-otg-phy.c
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2026 The freemyipod team (freemyipod.org)
+ */
+
+#include <init.h>
+#include <asm/io.h>
+#include <asm/arch-s5l87xx/s5l87xx.h>
+#include <asm/arch-s5l87xx/clk.h>
+#include <linux/delay.h>
+
+struct s5l87xx_otgphy {
+       u32 pwr;                // 0x00
+       u32 con;                // 0x04
+       u32 rstcon;             // 0x08
+       u32 unk[4];             // 0x0c, 0x10, 0x14, 0x18
+       u32 unkcon;             // 0x1c
+       u32 pad[36];    // 0x20 - 0x44
+       u32 unk44;              // 0x44
+};
+
+void otg_phy_init(void *unused)
+{
+       struct s5l87xx_otgphy *otgphy = (struct s5l87xx_otgphy 
*)S5L87XX_PHY_BASE;
+
+       log_debug("s5l87xx_otgphy: turning on\n");
+       s5l87xx_enable_clkgate("usb-otg");
+       s5l87xx_enable_clkgate("usb2-phy");
+       mdelay(10);
+
+       // Disable USB suspend.
+       writel(0, S5L87XX_OTG_BASE + 0xe00);
+
+       writel(0, &otgphy->pwr); /* PHY: Power up */
+       mdelay(10);
+       writel(1, &otgphy->rstcon);
+       mdelay(10);
+       writel(0, &otgphy->rstcon);
+       mdelay(10);
+       writel(6, &otgphy->unkcon);
+       writel(1, &otgphy->con);
+       mdelay(400);
+}
+
+void otg_phy_off(void *unused)
+{
+       struct s5l87xx_otgphy *otgphy = (struct s5l87xx_otgphy 
*)S5L87XX_PHY_BASE;
+
+       log_debug("s5l87xx_otgphy: turning off\n");
+       writel(0xFF, &otgphy->pwr);
+       mdelay(10);
+       writel(0xFF, &otgphy->rstcon);
+       mdelay(10);
+       writel(4, &otgphy->unkcon);
+}
diff --git a/board/apple/n58s/Kconfig b/board/apple/n58s/Kconfig
new file mode 100644
index 00000000000..6a61a9973d9
--- /dev/null
+++ b/board/apple/n58s/Kconfig
@@ -0,0 +1,15 @@
+if TARGET_N58S
+
+config SYS_BOARD
+       default "n58s"
+
+config SYS_VENDOR
+       default "apple"
+
+config SYS_SOC
+       default "s5l8720"
+
+config SYS_CONFIG_NAME
+       default "apple_n58s"
+
+endif
diff --git a/board/apple/n58s/Makefile b/board/apple/n58s/Makefile
new file mode 100644
index 00000000000..293c92895e3
--- /dev/null
+++ b/board/apple/n58s/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2026 The freemyipod team (freemyipod.org)
+#
+
+obj-y += ../nxx-common/nxx.o
+obj-y += n58s.o
diff --git a/board/apple/n58s/n58s.c b/board/apple/n58s/n58s.c
new file mode 100644
index 00000000000..ec6dbf01714
--- /dev/null
+++ b/board/apple/n58s/n58s.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2026 The freemyipod team (freemyipod.org)
+ */
+
+#include <asm/io.h>
+#include <asm/arch-s5l87xx/s5l87xx.h>
+#include <asm/arch-s5l87xx/clk.h>
+
+static void board_gpio_init(void)
+{
+       // UART0
+       u32 gpio = readl(S5L87XX_PCON(0));
+
+       gpio &= S5L87XX_PCON_PINS_CLEAR_FN(4, 5);
+       gpio |= S5L87XX_PCON_PINS_SET_FN(4, 5, 0x2);
+       writel(gpio, S5L87XX_PCON(0));
+}
+
+static void board_clock_init(void)
+{
+       s5l87xx_enable_clkgate("uart0");
+       s5l87xx_enable_clkgate("bootrom");
+}
+
+static void board_vic_init(void)
+{
+       // Disable all VIC interrupts.
+       writel(0xffffffff, S5L87XX_VICINTENCLEAR(0));
+       writel(0xffffffff, S5L87XX_VICINTENCLEAR(1));
+}
+
+int board_early_init_f(void)
+{
+       /* Enable GPIO pins */
+       board_gpio_init();
+
+       /* Enable clocking */
+       board_clock_init();
+
+       /* Configure VIC */
+       board_vic_init();
+
+       return 0;
+}
+
+void board_debug_uart_init(void)
+{
+       /* Enable GPIO pins */
+       board_gpio_init();
+
+       /* Enable UART clocking. Runs before the FDT is set up, so ungate uart0 
by
+        * raw {gate, bit} ({1,9} + {4,7}) rather than the device-tree name 
lookup.
+        */
+       s5l87xx_enable_clkgate_bit(1, 9);
+       s5l87xx_enable_clkgate_bit(4, 7);
+}
diff --git a/configs/apple_n58s_defconfig b/configs/apple_n58s_defconfig
new file mode 100644
index 00000000000..137941209e1
--- /dev/null
+++ b/configs/apple_n58s_defconfig
@@ -0,0 +1,33 @@
+CONFIG_ARM=y
+CONFIG_SKIP_LOWLEVEL_INIT_ONLY=y
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_ARCH_S5L87XX=y
+CONFIG_TEXT_BASE=0x08000000
+CONFIG_SYS_MALLOC_LEN=0x00200000
+CONFIG_DEFAULT_DEVICE_TREE="s5l8720-n58s"
+CONFIG_S5L8720=y
+CONFIG_SYS_LOAD_ADDR=0x08000000
+CONFIG_DEBUG_UART_BASE=0x3CC00000
+CONFIG_DEBUG_UART_CLOCK=24000000
+CONFIG_DEBUG_UART_BOARD_INIT=y
+CONFIG_DEBUG_UART=y
+CONFIG_STACK_SIZE=0x00100000
+CONFIG_FIT=y
+CONFIG_BOOTDELAY=3
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="dfu 0 ram 0; bootm"
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_CMD_DFU=y
+CONFIG_OF_CONTROL=y
+CONFIG_CLK=y
+CONFIG_DFU_RAM=y
+CONFIG_SET_DFU_ALT_INFO=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x00100000
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_VENDOR_NUM=0x05ac
+CONFIG_USB_GADGET_PRODUCT_NUM=0xff00
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/include/configs/apple_n58s.h b/include/configs/apple_n58s.h
new file mode 100644
index 00000000000..79192cc4497
--- /dev/null
+++ b/include/configs/apple_n58s.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2026 The freemyipod team (freemyipod.org)
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CFG_SYS_UBOOT_BASE             CONFIG_TEXT_BASE
+
+// 192K SRAM total, first 64K is the fastest, then 128K slower than DRAM
+#define CFG_SYS_INIT_RAM_ADDR  0x22000000
+#define CFG_SYS_INIT_RAM_SIZE  0x00030000
+
+#endif /* __CONFIG_H */

-- 
Git-157)

Reply via email to