| /* |
| * Copyright (C) 2017 Amlogic, Inc. All rights reserved. |
| * * |
| This program is free software; you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License as published by |
| * the Free Software Foundation; either version 2 of the License, or |
| * (at your option) any later version. |
| * * |
| This program is distributed in the hope that it will be useful, but WITHOUT |
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| * more details. |
| * * |
| You should have received a copy of the GNU General Public License along |
| * with this program; if not, write to the Free Software Foundation, Inc., |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| * * |
| Description: |
| */ |
| |
| #ifndef __AML_GPIO__ |
| #define __AML_GPIO__ |
| #include <asm/io.h> |
| /** |
| * struct meson_reg_desc - a register descriptor |
| * |
| * @reg: register offset in the regmap |
| * @bit: bit index in register |
| * |
| * The structure describes the information needed to control pull, |
| * pull-enable, direction, etc. for a single pin |
| */ |
| struct meson_reg_desc { |
| unsigned int reg; |
| unsigned int bit; |
| }; |
| |
| /** |
| * enum meson_reg_type - type of registers encoded in @meson_reg_desc |
| */ |
| enum meson_reg_type { |
| REG_PULLEN, |
| REG_PULL, |
| REG_DIR, |
| REG_OUT, |
| REG_IN, |
| NUM_REG, |
| }; |
| |
| |
| |
| |
| struct meson_bank { |
| const char *name; |
| unsigned int first; |
| unsigned int last; |
| struct meson_reg_desc regs[NUM_REG]; |
| }; |
| #define GPIO_REG_BIT(reg, bit) ((reg<<5)|bit) |
| #define GPIO_REG(value) ((value>>5)) |
| #define GPIO_BIT(value) ((value&0x1F)) |
| #define BIT(bit) (1<<bit) |
| static inline void regmap_update_bits(unsigned long reg,unsigned mask,unsigned val) |
| { |
| |
| unsigned int tmp, orig; |
| orig = readl(reg); |
| tmp = orig & ~mask; |
| tmp |= val & mask; |
| writel(tmp,reg); |
| return; |
| } |
| |
| #endif |