ARM: uniphier: refactor LED function
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 21 Sep 2015 15:27:31 +0000 (00:27 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 24 Sep 2015 15:27:53 +0000 (00:27 +0900)
The macro, led_write(), is now only used in C sources.  There is no
more reason to keep the tricky assembly macro.  Replace it with a
new C function led_puts().

Also, rename board.h to micro-support-card.h.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
arch/arm/mach-uniphier/board_common.c
arch/arm/mach-uniphier/board_early_init_f.c
arch/arm/mach-uniphier/board_early_init_r.c
arch/arm/mach-uniphier/include/mach/board.h [deleted file]
arch/arm/mach-uniphier/include/mach/led.h [deleted file]
arch/arm/mach-uniphier/include/mach/micro-support-card.h [new file with mode: 0644]
arch/arm/mach-uniphier/lowlevel_init.S
arch/arm/mach-uniphier/print_misc_info.c
arch/arm/mach-uniphier/spl.c
arch/arm/mach-uniphier/support_card.c

index 967fa6c0865d47664dfb42cf24b12fbfc1a208af..198004b59b06b8f047b0b633d119340ecca905be 100644 (file)
@@ -1,20 +1,15 @@
 /*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ * Copyright (C) 2012-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
-#include <mach/led.h>
+#include <mach/micro-support-card.h>
 
-/*
- * Routine: board_init
- * Description: Early hardware init.
- */
 int board_init(void)
 {
-       led_write(U, B, O, O);
+       led_puts("Uboo");
 
        return 0;
 }
index 71087404084ae75fdf85d3177d845e54cdd1be92..45f5cea433420ff737c51edb99a7d1679424a958 100644 (file)
@@ -1,27 +1,25 @@
 /*
- * Copyright (C) 2012-2015 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ * Copyright (C) 2012-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include <mach/led.h>
-#include <mach/board.h>
+#include <mach/micro-support-card.h>
 
 void pin_init(void);
 void clkrst_init(void);
 
 int board_early_init_f(void)
 {
-       led_write(U, 0, , );
+       led_puts("U0");
 
        pin_init();
 
-       led_write(U, 1, , );
+       led_puts("U1");
 
        clkrst_init();
 
-       led_write(U, 2, , );
+       led_puts("U2");
 
        return 0;
 }
index 7d4830a3a822a6152b5acb6432ac20645c23125f..28c7f822287308bb8f3328be65aaa0a720567b51 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #include <common.h>
-#include <mach/board.h>
+#include <mach/micro-support-card.h>
 
 int board_early_init_r(void)
 {
diff --git a/arch/arm/mach-uniphier/include/mach/board.h b/arch/arm/mach-uniphier/include/mach/board.h
deleted file mode 100644 (file)
index 5b9af22..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2012-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef ARCH_BOARD_H
-#define ARCH_BOARD_H
-
-#if defined(CONFIG_MICRO_SUPPORT_CARD)
-void support_card_reset(void);
-void support_card_init(void);
-void support_card_late_init(void);
-int check_support_card(void);
-#else
-static inline void support_card_reset(void)
-{
-}
-
-static inline void support_card_init(void)
-{
-}
-
-static inline void support_card_late_init(void)
-{
-}
-
-static inline int check_support_card(void)
-{
-       return 0;
-}
-#endif
-
-#endif /* ARCH_BOARD_H */
diff --git a/arch/arm/mach-uniphier/include/mach/led.h b/arch/arm/mach-uniphier/include/mach/led.h
deleted file mode 100644 (file)
index f7749b4..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2012-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef ARCH_LED_H
-#define ARCH_LED_H
-
-#include <config.h>
-
-#define LED_CHAR_0     0x7e
-#define LED_CHAR_1     0x0c
-#define LED_CHAR_2     0xb6
-#define LED_CHAR_3     0x9e
-#define LED_CHAR_4     0xcc
-#define LED_CHAR_5     0xda
-#define LED_CHAR_6     0xfa
-#define LED_CHAR_7     0x4e
-#define LED_CHAR_8     0xfe
-#define LED_CHAR_9     0xde
-
-#define LED_CHAR_A     0xee
-#define LED_CHAR_B     0xf8
-#define LED_CHAR_C     0x72
-#define LED_CHAR_D     0xbc
-#define LED_CHAR_E     0xf2
-#define LED_CHAR_F     0xe2
-#define LED_CHAR_G     0x7a
-#define LED_CHAR_H     0xe8
-#define LED_CHAR_I     0x08
-#define LED_CHAR_J     0x3c
-#define LED_CHAR_K     0xea
-#define LED_CHAR_L     0x70
-#define LED_CHAR_M     0x6e
-#define LED_CHAR_N     0xa8
-#define LED_CHAR_O     0xb8
-#define LED_CHAR_P     0xe6
-#define LED_CHAR_Q     0xce
-#define LED_CHAR_R     0xa0
-#define LED_CHAR_S     0xc8
-#define LED_CHAR_T     0x8c
-#define LED_CHAR_U     0x7c
-#define LED_CHAR_V     0x54
-#define LED_CHAR_W     0xfc
-#define LED_CHAR_X     0xec
-#define LED_CHAR_Y     0xdc
-#define LED_CHAR_Z     0xa4
-
-#define LED_CHAR_SPACE 0x00
-#define LED_CHAR_DOT   0x01
-
-#define LED_CHAR_      (LED_CHAR_SPACE)
-
-/** Macro to translate 4 characters into integer to display led */
-#define LED_C2I(C0, C1, C2, C3)                        \
-       (~(                                     \
-               (LED_CHAR_##C0 << 24) |         \
-               (LED_CHAR_##C1 << 16) |         \
-               (LED_CHAR_##C2 <<  8) |         \
-               (LED_CHAR_##C3)                 \
-       ))
-
-#if defined(CONFIG_SUPPORT_CARD_LED_BASE)
-
-#define LED_ADDR    CONFIG_SUPPORT_CARD_LED_BASE
-
-#ifdef __ASSEMBLY__
-
-#define led_write(C0, C1, C2, C3)  raw_led_write LED_C2I(C0, C1, C2, C3)
-.macro raw_led_write data
-       ldr r0, =\data
-       ldr r1, =LED_ADDR
-       str r0, [r1]
-.endm
-
-#else /* __ASSEMBLY__ */
-
-#include <linux/io.h>
-
-#define led_write(C0, C1, C2, C3)              \
-do {                                           \
-       raw_led_write(LED_C2I(C0, C1, C2, C3)); \
-} while (0)
-
-static inline void raw_led_write(u32 data)
-{
-       writel(data, LED_ADDR);
-}
-
-#endif /* __ASSEMBLY__ */
-
-#else /* CONFIG_SUPPORT_CARD_LED_BASE */
-
-#define led_write(C0, C1, C2, C3)
-#define raw_led_write(x)
-
-#endif /* CONFIG_SUPPORT_CARD_LED_BASE */
-
-#endif /* ARCH_LED_H */
diff --git a/arch/arm/mach-uniphier/include/mach/micro-support-card.h b/arch/arm/mach-uniphier/include/mach/micro-support-card.h
new file mode 100644 (file)
index 0000000..5da0ada
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2012-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef ARCH_BOARD_H
+#define ARCH_BOARD_H
+
+#if defined(CONFIG_MICRO_SUPPORT_CARD)
+void support_card_reset(void);
+void support_card_init(void);
+void support_card_late_init(void);
+int check_support_card(void);
+void led_puts(const char *s);
+#else
+static inline void support_card_reset(void)
+{
+}
+
+static inline void support_card_init(void)
+{
+}
+
+static inline void support_card_late_init(void)
+{
+}
+
+static inline int check_support_card(void)
+{
+       return 0;
+}
+
+static inline void led_puts(const char *s)
+{
+}
+#endif
+
+#endif /* ARCH_BOARD_H */
index fd34a4a32193c361d669fb890b45b82a7e381777..9259bafed03f0606e3c5bf1ab06a034b5c48c762 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/linkage.h>
 #include <linux/sizes.h>
 #include <asm/system.h>
-#include <mach/led.h>
 #include <mach/arm-mpcore.h>
 #include <mach/sbc-regs.h>
 #include <mach/ssc-regs.h>
index 22ea5122852daa886acbab2d1d3180fa374c6961..5140b0c4383cdc762da53309a6ccf22b435e91e0 100644 (file)
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include <mach/board.h>
+#include <mach/micro-support-card.h>
 
 int misc_init_f(void)
 {
index 661d73ae4a4628831248cfbc32277fdfe4f8b783..f0df9b1e4e897b629edbc8e7d4d70c7e5b182f0d 100644 (file)
@@ -7,8 +7,7 @@
 #include <common.h>
 #include <spl.h>
 #include <linux/compiler.h>
-#include <mach/led.h>
-#include <mach/board.h>
+#include <mach/micro-support-card.h>
 
 void __weak bcu_init(void)
 {
@@ -46,25 +45,25 @@ void spl_board_init(void)
 
        support_card_init();
 
-       led_write(L, 0, , );
+       led_puts("L0");
 
        memconf_init();
 
-       led_write(L, 1, , );
+       led_puts("L1");
 
        early_clkrst_init();
 
-       led_write(L, 2, , );
+       led_puts("L2");
 
        early_pin_init();
 
-       led_write(L, 3, , );
+       led_puts("L3");
 
 #ifdef CONFIG_SPL_SERIAL_SUPPORT
        preloader_console_init();
 #endif
 
-       led_write(L, 4, , );
+       led_puts("L4");
 
        {
                int res;
@@ -75,9 +74,10 @@ void spl_board_init(void)
                                ;
                }
        }
-       led_write(L, 5, , );
+
+       led_puts("L5");
 
        enable_dpll_ssc();
 
-       led_write(L, 6, , );
+       led_puts("L6");
 }
index ef4576de432dc1a93f5b7fca3ec5dec3add36514..f8333060301e0013518a5b9dfecca74d446a88f4 100644 (file)
@@ -5,8 +5,9 @@
  */
 
 #include <common.h>
+#include <linux/ctype.h>
 #include <linux/io.h>
-#include <mach/board.h>
+#include <mach/micro-support-card.h>
 
 #define MICRO_SUPPORT_CARD_RESET       \
                                ((CONFIG_SUPPORT_CARD_BASE) + 0x000D0034)
@@ -155,3 +156,73 @@ void support_card_late_init(void)
 {
        detect_num_flash_banks();
 }
+
+static const u8 ledval_num[] = {
+       0x7e, /* 0 */
+       0x0c, /* 1 */
+       0xb6, /* 2 */
+       0x9e, /* 3 */
+       0xcc, /* 4 */
+       0xda, /* 5 */
+       0xfa, /* 6 */
+       0x4e, /* 7 */
+       0xfe, /* 8 */
+       0xde, /* 9 */
+};
+
+static const u8 ledval_alpha[] = {
+       0xee, /* A */
+       0xf8, /* B */
+       0x72, /* C */
+       0xbc, /* D */
+       0xf2, /* E */
+       0xe2, /* F */
+       0x7a, /* G */
+       0xe8, /* H */
+       0x08, /* I */
+       0x3c, /* J */
+       0xea, /* K */
+       0x70, /* L */
+       0x6e, /* M */
+       0xa8, /* N */
+       0xb8, /* O */
+       0xe6, /* P */
+       0xce, /* Q */
+       0xa0, /* R */
+       0xc8, /* S */
+       0x8c, /* T */
+       0x7c, /* U */
+       0x54, /* V */
+       0xfc, /* W */
+       0xec, /* X */
+       0xdc, /* Y */
+       0xa4, /* Z */
+};
+
+static u8 char2ledval(char c)
+{
+       if (isdigit(c))
+               return ledval_num[c - '0'];
+       else if (isalpha(c))
+               return ledval_alpha[toupper(c) - 'A'];
+
+       return 0;
+}
+
+void led_puts(const char *s)
+{
+       int i;
+       u32 val = 0;
+
+       if (!s)
+               return;
+
+       for (i = 0; i < 4; i++) {
+               val <<= 8;
+               val |= char2ledval(*s);
+               if (*s != '\0')
+                       s++;
+       }
+
+       writel(~val, CONFIG_SUPPORT_CARD_LED_BASE);
+}