blob: 5e3a53372d971713347a40338e9ffd82c6586988 [file] [log] [blame]
Lars Povlsene58031a2018-12-20 09:56:03 +01001// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2018 Microsemi Corporation
4 */
5
6#include <common.h>
7#include <asm/io.h>
8
9void mscc_gpio_set_alternate(int gpio, int mode)
10{
11 u32 mask = BIT(gpio);
12 u32 val0, val1;
13
14 val0 = readl(BASE_DEVCPU_GCB + GPIO_ALT(0));
15 val1 = readl(BASE_DEVCPU_GCB + GPIO_ALT(1));
16
17 if (mode == 1) {
18 val0 |= mask;
19 val1 &= ~mask;
20 } else if (mode == 2) {
21 val0 &= ~mask;
22 val1 |= mask;
23 } else if (mode == 3) {
24 val0 |= mask;
25 val1 |= mask;
26 } else {
27 val0 &= ~mask;
28 val1 &= ~mask;
29 }
30
31 writel(val0, BASE_DEVCPU_GCB + GPIO_ALT(0));
32 writel(val1, BASE_DEVCPU_GCB + GPIO_ALT(1));
33}