Peter Griffin | 0b49154 | 2015-07-30 18:55:20 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 Linaro |
| 3 | * Peter Griffin <peter.griffin@linaro.org> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #ifndef __ASM_ARM_ARCH_PINMUX_H |
| 9 | #define __ASM_ARM_ARCH_PINMUX_H |
| 10 | |
| 11 | #include "periph.h" |
| 12 | |
| 13 | |
| 14 | /* iomg bit definition */ |
| 15 | #define MUX_M0 0 |
| 16 | #define MUX_M1 1 |
| 17 | #define MUX_M2 2 |
| 18 | #define MUX_M3 3 |
| 19 | #define MUX_M4 4 |
| 20 | #define MUX_M5 5 |
| 21 | #define MUX_M6 6 |
| 22 | #define MUX_M7 7 |
| 23 | |
| 24 | /* iocg bit definition */ |
| 25 | #define PULL_MASK (3) |
| 26 | #define PULL_DIS (0) |
| 27 | #define PULL_UP (1 << 0) |
| 28 | #define PULL_DOWN (1 << 1) |
| 29 | |
| 30 | /* drive strength definition */ |
| 31 | #define DRIVE_MASK (7 << 4) |
| 32 | #define DRIVE1_02MA (0 << 4) |
| 33 | #define DRIVE1_04MA (1 << 4) |
| 34 | #define DRIVE1_08MA (2 << 4) |
| 35 | #define DRIVE1_10MA (3 << 4) |
| 36 | #define DRIVE2_02MA (0 << 4) |
| 37 | #define DRIVE2_04MA (1 << 4) |
| 38 | #define DRIVE2_08MA (2 << 4) |
| 39 | #define DRIVE2_10MA (3 << 4) |
| 40 | #define DRIVE3_04MA (0 << 4) |
| 41 | #define DRIVE3_08MA (1 << 4) |
| 42 | #define DRIVE3_12MA (2 << 4) |
| 43 | #define DRIVE3_16MA (3 << 4) |
| 44 | #define DRIVE3_20MA (4 << 4) |
| 45 | #define DRIVE3_24MA (5 << 4) |
| 46 | #define DRIVE3_32MA (6 << 4) |
| 47 | #define DRIVE3_40MA (7 << 4) |
| 48 | #define DRIVE4_02MA (0 << 4) |
| 49 | #define DRIVE4_04MA (2 << 4) |
| 50 | #define DRIVE4_08MA (4 << 4) |
| 51 | #define DRIVE4_10MA (6 << 4) |
| 52 | |
| 53 | #define HI6220_PINMUX0_BASE 0xf7010000 |
| 54 | #define HI6220_PINMUX1_BASE 0xf7010800 |
| 55 | |
| 56 | #ifndef __ASSEMBLY__ |
| 57 | |
| 58 | /* maybe more registers, but highest used is 123 */ |
| 59 | #define REG_NUM 123 |
| 60 | |
| 61 | struct hi6220_pinmux0_regs { |
| 62 | uint32_t iomg[REG_NUM]; |
| 63 | }; |
| 64 | |
| 65 | struct hi6220_pinmux1_regs { |
| 66 | uint32_t iocfg[REG_NUM]; |
| 67 | }; |
| 68 | |
| 69 | #endif |
| 70 | |
| 71 | /** |
| 72 | * Configures the pinmux for a particular peripheral. |
| 73 | * |
| 74 | * This function will configure the peripheral pinmux along with |
| 75 | * pull-up/down and drive strength. |
| 76 | * |
| 77 | * @param peripheral peripheral to be configured |
| 78 | * @return 0 if ok, -1 on error (e.g. unsupported peripheral) |
| 79 | */ |
| 80 | int hi6220_pinmux_config(int peripheral); |
| 81 | |
| 82 | #endif |