Commit 4a693669670fffd9a614c8c5c9f5ba027fd0185e

Authored by Michal Simek
1 parent c7e7948924

microblaze: Convert generic platform to DM gpio

Converting GPIO to DM requires to do changes in reset subsystem
that's why support for Microblaze soft reset via sysreset and GPIO
sysreset support was added.
These two patches enables enabling GPIO DM.
Microblaze soft reset is bind at last reset method.

GPIO reset is handled via sysreset with adding this fragment to DT.

gpio-restart {
	compatible = "gpio-restart";
	gpios = <&reset_gpio 0 0 0>;
	/* 3rd cell ACTIVE_HIGH = 0, ACTIVE_LOW = 1 */
};

hard-reset-gpio property is not documented and also handled.
Conversion is required.

Unfortunately do_reset is required for SPL that's why use only soft
microblaze reset for now.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Showing 8 changed files with 24 additions and 56 deletions Side-by-side Diff

arch/microblaze/Kconfig
... ... @@ -16,6 +16,7 @@
16 16 select DM
17 17 select DM_SERIAL
18 18 select ENV_IS_IN_FLASH
  19 + select SYSRESET
19 20  
20 21 endchoice
21 22  
arch/microblaze/cpu/spl.c
... ... @@ -47,4 +47,12 @@
47 47  
48 48 return 1;
49 49 }
  50 +
  51 +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  52 +{
  53 + __asm__ __volatile__ ("mts rmsr, r0;" \
  54 + "bra r0");
  55 +
  56 + return 0;
  57 +}
arch/microblaze/include/asm/gpio.h
1   -#ifndef _ASM_MICROBLAZE_GPIO_H_
2   -#define _ASM_MICROBLAZE_GPIO_H_
3   -
4 1 #include <asm-generic/gpio.h>
5   -
6   -/* Allocation functions */
7   -extern int gpio_alloc_dual(u32 baseaddr, const char *name, u32 gpio_no0,
8   - u32 gpio_no1);
9   -extern int gpio_alloc(u32 baseaddr, const char *name, u32 gpio_no);
10   -
11   -#define gpio_status() gpio_info()
12   -extern void gpio_info(void);
13   -
14   -#endif
board/xilinx/microblaze-generic/microblaze-generic.c
1 1 // SPDX-License-Identifier: GPL-2.0+
2 2 /*
3   - * (C) Copyright 2007 Michal Simek
  3 + * (C) Copyright 2007-2018 Michal Simek
4 4 *
5   - * Michal SIMEK <monstr@monstr.eu>
  5 + * Michal SIMEK <monstr@monstr.eu>
6 6 */
7 7  
8 8 /*
... ... @@ -12,6 +12,8 @@
12 12  
13 13 #include <common.h>
14 14 #include <config.h>
  15 +#include <dm.h>
  16 +#include <dm/lists.h>
15 17 #include <fdtdec.h>
16 18 #include <asm/processor.h>
17 19 #include <asm/microblaze_intc.h>
... ... @@ -22,10 +24,6 @@
22 24  
23 25 DECLARE_GLOBAL_DATA_PTR;
24 26  
25   -#ifdef CONFIG_XILINX_GPIO
26   -static int reset_pin = -1;
27   -#endif
28   -
29 27 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT)
30 28 static struct udevice *watchdog_dev;
31 29 #endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */
... ... @@ -66,33 +64,6 @@
66 64 return 0;
67 65 };
68 66  
69   -#if !defined(CONFIG_SYSRESET) || defined(CONFIG_SPL_BUILD)
70   -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
71   -{
72   -#ifndef CONFIG_SPL_BUILD
73   -#ifdef CONFIG_XILINX_GPIO
74   - if (reset_pin != -1)
75   - gpio_direction_output(reset_pin, 1);
76   -#endif
77   -#endif
78   - puts("Resetting board\n");
79   - __asm__ __volatile__ (" mts rmsr, r0;" \
80   - "bra r0");
81   -
82   - return 0;
83   -}
84   -#endif
85   -
86   -static int gpio_init(void)
87   -{
88   -#ifdef CONFIG_XILINX_GPIO
89   - reset_pin = gpio_alloc(CONFIG_SYS_GPIO_0_ADDR, "reset", 1);
90   - if (reset_pin != -1)
91   - gpio_request(reset_pin, "reset_pin");
92   -#endif
93   - return 0;
94   -}
95   -
96 67 #ifdef CONFIG_WDT
97 68 /* Called by macro WATCHDOG_RESET */
98 69 void watchdog_reset(void)
... ... @@ -117,8 +88,6 @@
117 88  
118 89 int board_late_init(void)
119 90 {
120   - gpio_init();
121   -
122 91 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT)
123 92 watchdog_dev = NULL;
124 93  
125 94  
... ... @@ -133,7 +102,14 @@
133 102 wdt_start(watchdog_dev, 0, 0);
134 103 puts("Watchdog: Started\n");
135 104 #endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */
  105 +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SYSRESET_MICROBLAZE)
  106 + int ret;
136 107  
  108 + ret = device_bind_driver(gd->dm_root, "mb_soft_reset",
  109 + "reset_soft", NULL);
  110 + if (ret)
  111 + printf("Warning: No reset driver: ret=%d\n", ret);
  112 +#endif
137 113 return 0;
138 114 }
board/xilinx/microblaze-generic/xparameters.h
... ... @@ -13,9 +13,6 @@
13 13 /* Microblaze is microblaze_0 */
14 14 #define XILINX_FSL_NUMBER 3
15 15  
16   -/* GPIO is LEDs_4Bit*/
17   -#define XILINX_GPIO_BASEADDR 0x40000000
18   -
19 16 /* Flash Memory is FLASH_2Mx32 */
20 17 #define XILINX_FLASH_START 0x2c000000
21 18 #define XILINX_FLASH_SIZE 0x00800000
configs/microblaze-generic_defconfig
... ... @@ -39,6 +39,7 @@
39 39 CONFIG_OF_EMBED=y
40 40 CONFIG_NETCONSOLE=y
41 41 CONFIG_SPL_DM=y
  42 +CONFIG_DM_GPIO=y
42 43 CONFIG_XILINX_GPIO=y
43 44 CONFIG_MTD_NOR_FLASH=y
44 45 CONFIG_PHY_ATHEROS=y
... ... @@ -56,6 +57,8 @@
56 57 CONFIG_XILINX_EMACLITE=y
57 58 CONFIG_SYS_NS16550=y
58 59 CONFIG_XILINX_UARTLITE=y
  60 +CONFIG_SYSRESET_GPIO=y
  61 +CONFIG_SYSRESET_MICROBLAZE=y
59 62 CONFIG_WDT=y
60 63 CONFIG_XILINX_TB_WATCHDOG=y
drivers/gpio/Kconfig
... ... @@ -185,6 +185,7 @@
185 185  
186 186 config XILINX_GPIO
187 187 bool "Xilinx GPIO driver"
  188 + depends on DM_GPIO
188 189 help
189 190 This config enable the Xilinx GPIO driver for Microblaze.
190 191  
include/configs/microblaze-generic.h
... ... @@ -38,11 +38,6 @@
38 38 /* setting reset address */
39 39 /*#define CONFIG_SYS_RESET_ADDRESS CONFIG_SYS_TEXT_BASE*/
40 40  
41   -/* gpio */
42   -#ifdef XILINX_GPIO_BASEADDR
43   -# define CONFIG_SYS_GPIO_0_ADDR XILINX_GPIO_BASEADDR
44   -#endif
45   -
46 41 #define CONFIG_SYS_MALLOC_LEN 0xC0000
47 42  
48 43 /* Stack location before relocation */