blob: dbf54aa91051ed794d05a5ae5f04f71ea3a5b543 [file] [log] [blame]
Masahiro Yamadaee53ea72020-02-14 20:54:40 +09001// SPDX-License-Identifier: GPL-2.0 or later
2/*
3 * Copyright (C) 2020 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5 */
6
Simon Glass0f2af882020-05-10 11:40:05 -06007#include <log.h>
Masahiro Yamadaee53ea72020-02-14 20:54:40 +09008#include <linux/errno.h>
9#include <dm.h>
10#include <dm/uclass-internal.h>
11#include <reset.h>
12
13#include "init.h"
14
15/*
16 * Assert the Denali NAND controller reset if found.
17 *
18 * On LD4, the bootstrap process starts running after power-on reset regardless
19 * of the boot mode, here the pin-mux is not necessarily set up for NAND, then
20 * the controller is stuck. Assert the controller reset here, and should be
21 * deasserted in the driver after the pin-mux is correctly handled. For other
22 * SoCs, the bootstrap runs only when the boot mode selects ONFi, but it is yet
23 * effective when the boot swap is on. So, the reset should be asserted anyway.
24 */
25void uniphier_nand_reset_assert(void)
26{
27 struct udevice *dev;
28 struct reset_ctl_bulk resets;
29 int ret;
30
31 ret = uclass_find_first_device(UCLASS_MTD, &dev);
32 if (ret || !dev)
33 return;
34
35 /* make sure this is the Denali NAND controller */
36 if (strcmp(dev->driver->name, "denali-nand-dt"))
37 return;
38
39 ret = reset_get_bulk(dev, &resets);
40 if (ret)
41 return;
42
43 reset_assert_bulk(&resets);
44}