Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. |
Gregory Bean | 1963a2a | 2010-08-28 10:05:44 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
Gregory Bean | 1963a2a | 2010-08-28 10:05:44 -0700 | [diff] [blame] | 11 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 12 | #include <linux/bitops.h> |
Gregory Bean | 1963a2a | 2010-08-28 10:05:44 -0700 | [diff] [blame] | 13 | #include <linux/io.h> |
| 14 | #include <mach/msm_iomap.h> |
Rohit Vaswani | a513aa8d | 2011-07-18 15:14:28 -0700 | [diff] [blame] | 15 | #include <mach/gpiomux.h> |
Gregory Bean | 1963a2a | 2010-08-28 10:05:44 -0700 | [diff] [blame] | 16 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 17 | #define GPIO_CFG(n) (MSM_TLMM_BASE + 0x1000 + (0x10 * n)) |
| 18 | #define GPIO_IN_OUT(n) (MSM_TLMM_BASE + 0x1004 + (0x10 * n)) |
| 19 | |
| 20 | void __msm_gpiomux_write(unsigned gpio, struct gpiomux_setting val) |
Gregory Bean | 1963a2a | 2010-08-28 10:05:44 -0700 | [diff] [blame] | 21 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 22 | uint32_t bits; |
| 23 | |
| 24 | bits = (val.drv << 6) | (val.func << 2) | val.pull; |
| 25 | if (val.func == GPIOMUX_FUNC_GPIO) { |
| 26 | bits |= val.dir > GPIOMUX_IN ? BIT(9) : 0; |
| 27 | __raw_writel(val.dir == GPIOMUX_OUT_HIGH ? BIT(1) : 0, |
| 28 | GPIO_IN_OUT(gpio)); |
| 29 | } |
| 30 | __raw_writel(bits, GPIO_CFG(gpio)); |
| 31 | mb(); |
Gregory Bean | 1963a2a | 2010-08-28 10:05:44 -0700 | [diff] [blame] | 32 | } |