-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mips: mscc: Add generic GPIO control utility function
The GPIO control function can be used for controlling alternate functions associated with a GPIO. Signed-off-by: Lars Povlsen <[email protected]>
- Loading branch information
1 parent
3098ade
commit e58031a
Showing
5 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: (GPL-2.0+ OR MIT) | ||
/* | ||
* Copyright (c) 2018 Microsemi Corporation | ||
*/ | ||
|
||
#include <common.h> | ||
#include <asm/io.h> | ||
|
||
void mscc_gpio_set_alternate(int gpio, int mode) | ||
{ | ||
u32 mask = BIT(gpio); | ||
u32 val0, val1; | ||
|
||
val0 = readl(BASE_DEVCPU_GCB + GPIO_ALT(0)); | ||
val1 = readl(BASE_DEVCPU_GCB + GPIO_ALT(1)); | ||
|
||
if (mode == 1) { | ||
val0 |= mask; | ||
val1 &= ~mask; | ||
} else if (mode == 2) { | ||
val0 &= ~mask; | ||
val1 |= mask; | ||
} else if (mode == 3) { | ||
val0 |= mask; | ||
val1 |= mask; | ||
} else { | ||
val0 &= ~mask; | ||
val1 &= ~mask; | ||
} | ||
|
||
writel(val0, BASE_DEVCPU_GCB + GPIO_ALT(0)); | ||
writel(val1, BASE_DEVCPU_GCB + GPIO_ALT(1)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ | |
|
||
#define PERF_GPIO_OE 0x44 | ||
|
||
#define GPIO_ALT(x) (0x54 + 4 * (x)) | ||
|
||
#endif |