rtl83xx: various cleanups
authorJohn Crispin <john@phrozen.org>
Tue, 24 Nov 2020 16:42:32 +0000 (17:42 +0100)
committerJohn Crispin <john@phrozen.org>
Tue, 24 Nov 2020 16:51:36 +0000 (17:51 +0100)
Signed-off-by: John Crispin <john@phrozen.org>
target/linux/rtl838x/config-5.4
target/linux/rtl838x/files-5.4/arch/mips/rtl838x/prom.c
target/linux/rtl838x/files-5.4/arch/mips/rtl838x/setup.c
target/linux/rtl838x/patches-5.4/300-mips-add-rtl838x-platform.patch

index 6f1f73f8b50e819f0d76af799a88aa8e960eb801..2b4972c5c96a6030b8fc14789e584245e6fc2e81 100644 (file)
@@ -8,7 +8,6 @@ CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_CEVT_R4K=y
-CONFIG_CLKDEV_LOOKUP=y
 CONFIG_CLONE_BACKWARDS=y
 CONFIG_COMPAT_32BIT_TIME=y
 CONFIG_CONSOLE_LOGLEVEL_DEFAULT=15
@@ -37,6 +36,7 @@ CONFIG_DMA_NONCOHERENT=y
 CONFIG_DMA_NONCOHERENT_CACHE_SYNC=y
 CONFIG_DTC=y
 CONFIG_EARLY_PRINTK=y
+CONFIG_EARLY_PRINTK_8250=y
 CONFIG_EFI_EARLYCON=y
 CONFIG_ETHERNET_PACKET_MANGLE=y
 CONFIG_EXTRA_FIRMWARE="rtl838x_phy/rtl838x_8214fc.fw rtl838x_phy/rtl838x_8218b.fw rtl838x_phy/rtl838x_8380.fw"
@@ -63,6 +63,9 @@ CONFIG_GENERIC_LIB_LSHRDI3=y
 CONFIG_GENERIC_LIB_UCMPDI2=y
 CONFIG_GENERIC_PCI_IOMAP=y
 CONFIG_GENERIC_PHY=y
+CONFIG_GENERIC_PINCONF=y
+CONFIG_GENERIC_PINCTRL_GROUPS=y
+CONFIG_GENERIC_PINMUX_FUNCTIONS=y
 CONFIG_GENERIC_SCHED_CLOCK=y
 CONFIG_GENERIC_SMP_IDLE_THREAD=y
 CONFIG_GENERIC_TIME_VSYSCALL=y
@@ -147,7 +150,6 @@ CONFIG_PGTABLE_LEVELS=2
 CONFIG_PHYLIB=y
 CONFIG_PHYLINK=y
 CONFIG_PINCTRL=y
-# CONFIG_PINCTRL_SINGLE is not set
 CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_PSB6970_PHY=y
@@ -178,6 +180,7 @@ CONFIG_SYS_SUPPORTS_VPE_LOADER=y
 CONFIG_TARGET_ISA_REV=2
 CONFIG_TICK_CPU_ACCOUNTING=y
 CONFIG_TINY_SRCU=y
+CONFIG_USE_GENERIC_EARLY_PRINTK_8250=y
 CONFIG_USE_OF=y
 CONFIG_ZLIB_DEFLATE=y
 CONFIG_ZLIB_INFLATE=y
index 23e7ced86f45a718be28a29954f8c75a2f63e232..5278afae03429918c9a9ea2b84cdc96750d8d8cc 100644 (file)
 #include <mach-rtl83xx.h>
 
 extern char arcs_cmdline[];
-const void *fdt;
 extern const char __appended_dtb;
-//extern int __init rtl838x_serial_init(void);
-
-void prom_console_init(void)
-{
-       /* UART 16550A is initialized by the bootloader */
-}
-
-#ifdef CONFIG_EARLY_PRINTK
-#define rtl83xx_r8(reg)                __raw_readb(reg)
-#define rtl83xx_w8(val, reg)   __raw_writeb(val, reg)
-
-void unregister_prom_console(void)
-{
-
-}
-
-void disable_early_printk(void)
-{
-
-}
-
-void prom_putchar(char c)
-{
-       unsigned int retry = 0;
-
-       do {
-               if (retry++ >= 30000) {
-                       /* Reset Tx FIFO */
-                       rtl83xx_w8(TXRST | CHAR_TRIGGER_14, UART0_FCR);
-                       return;
-               }
-       } while ((rtl83xx_r8(UART0_LSR) & LSR_THRE) == TxCHAR_AVAIL);
-
-       /* Send Character */
-       rtl83xx_w8(c, UART0_THR);
-}
-
-char prom_getchar(void)
-{
-       return '\0';
-}
-#endif
 
 struct rtl83xx_soc_info soc_info;
+const void *fdt;
 
 const char *get_system_type(void)
 {
        return soc_info.name;
 }
 
-
 void __init prom_free_prom_memory(void)
 {
 
@@ -82,7 +39,6 @@ void __init prom_free_prom_memory(void)
 
 void __init device_tree_init(void)
 {
-       pr_info("%s called\r\n", __func__);
        if (!fdt_check_header(&__appended_dtb)) {
                fdt = &__appended_dtb;
                pr_info("Using appended Device Tree.\n");
@@ -110,24 +66,19 @@ static void __init prom_init_cmdline(void)
        pr_info("Kernel command line: %s\n", arcs_cmdline);
 }
 
-/* Do basic initialization */
 void __init prom_init(void)
 {
        uint32_t model;
 
-       pr_info("%s called\n", __func__);
-       soc_info.sw_base = RTL838X_SW_BASE;
+       /* uart0 */
+        setup_8250_early_printk_port(0xb8002000, 2, 0);
 
-       model = sw_r32(RTL838X_MODEL_NAME_INFO);
-       pr_info("RTL838X model is %x\n", model);
-       model = model >> 16 & 0xFFFF;
+       soc_info.sw_base = RTL838X_SW_BASE;
 
-       if ((model != 0x8328) && (model != 0x8330) && (model != 0x8332)
-           && (model != 0x8380) && (model != 0x8382)) {
-               model = sw_r32(RTL839X_MODEL_NAME_INFO);
-               pr_info("RTL839X model is %x\n", model);
-               model = model >> 16 & 0xFFFF;
-       }
+       model = sw_r32(RTL838X_MODEL_NAME_INFO) >> 16;
+       if (model != 0x8328 && model != 0x8330 && model != 0x8332 &&
+           model != 0x8380 && model != 0x8382)
+               model = sw_r32(RTL839X_MODEL_NAME_INFO) >> 16;
 
        soc_info.id = model;
 
index 6f00479ec22941de89ad05d8b0f59fdcc051f193..7d2e5c041bf198fc98abfa3c3c4ea50995f2a971 100644 (file)
 extern int rtl838x_serial_init(void);
 extern struct rtl83xx_soc_info soc_info;
 
-struct clk {
-       struct clk_lookup cl;
-       unsigned long rate;
-};
-
-struct clk cpu_clk;
-
 u32 pll_reset_value;
 
 static void rtl838x_restart(char *command)
@@ -69,38 +62,16 @@ static void rtl838x_restart(char *command)
 static void rtl838x_halt(void)
 {
        pr_info("System halted.\n");
-       while
-               (1);
-}
-
-static void __init rtl838x_setup(void)
-{
-       unsigned int val;
-
-       pr_info("Registering _machine_restart\n");
-       _machine_restart = rtl838x_restart;
-       _machine_halt = rtl838x_halt;
-
-       val = rtl83xx_r32((volatile void *)0xBB0040000);
-       if (val == 3)
-               pr_info("PCI device found\n");
-       else
-               pr_info("NO PCI device found\n");
-
-       /* Setup System LED. Bit 15 (14 for RTL8390) then allows to toggle it */
-       if (soc_info.family == RTL8380_FAMILY_ID)
-               sw_w32_mask(0, 3 << 16, RTL838X_LED_GLB_CTRL);
-       else
-               sw_w32_mask(0, 3 << 15, RTL839X_LED_GLB_CTRL);
+       while(1);
 }
 
 void __init plat_mem_setup(void)
 {
        void *dtb;
 
-       pr_info("%s called\n", __func__);
-
        set_io_port_base(KSEG1);
+       _machine_restart = rtl838x_restart;
+       _machine_halt = rtl838x_halt;
 
        if (fw_passed_dtb) /* UHI interface */
                dtb = (void *)fw_passed_dtb;
@@ -114,15 +85,12 @@ void __init plat_mem_setup(void)
         * parsed resulting in our memory appearing
         */
        __dt_setup_arch(dtb);
-
-       rtl838x_setup();
 }
 
 void __init plat_time_init(void)
 {
-       u32 freq = 500000000;
        struct device_node *np;
-       struct clk *clk = &cpu_clk;
+       u32 freq = 500000000;
 
        np = of_find_node_by_name(NULL, "cpus");
        if (!np) {
@@ -135,17 +103,8 @@ void __init plat_time_init(void)
                of_node_put(np);
        }
 
-       clk->rate = freq;
-
-       if (IS_ERR(clk))
-               panic("unable to get CPU clock, err=%ld", PTR_ERR(clk));
-
-       pr_info("CPU Clock: %ld MHz\n", clk->rate / 1000000);
        mips_hpt_frequency = freq / 2;
 
        pll_reset_value = sw_r32(RTL838X_PLL_CML_CTRL);
-       pr_info("PLL control register: %x\n", pll_reset_value);
-
-       /* With the info from the command line and cpu-freq we can setup the console */
        rtl838x_serial_init();
 }
index a106d815766e0080321d2e4cc52b621de7d6d1bb..18905e9e28c2d4f94fd8836a7260111aaf230f5d 100644 (file)
@@ -14,7 +14,7 @@ Index: linux-5.4.77/arch/mips/Kconfig
 ===================================================================
 --- linux-5.4.77.orig/arch/mips/Kconfig
 +++ linux-5.4.77/arch/mips/Kconfig
-@@ -630,6 +630,28 @@ config RALINK
+@@ -630,6 +630,30 @@ config RALINK
        select ARCH_HAS_RESET_CONTROLLER
        select RESET_CONTROLLER
  
@@ -32,6 +32,8 @@ Index: linux-5.4.77/arch/mips/Kconfig
 +      select SYS_SUPPORTS_MULTITHREADING
 +      select SYS_SUPPORTS_VPE_LOADER
 +      select SYS_HAS_EARLY_PRINTK
++      select SYS_HAS_EARLY_PRINTK_8250
++      select USE_GENERIC_EARLY_PRINTK_8250
 +      select SWAP_IO_SPACE
 +      select BOOT_RAW
 +      select PINCTRL