blob: 6e4140e4f1be17cae8d8044f8d3979b865bc90f7 [file] [log] [blame]
Vadim Bendebury476f7312014-04-08 18:45:46 -07001/*
2 * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in
11 * the documentation and/or other materials provided with the
12 * distribution.
13 * * Neither the name of Google, Inc. nor the names of its contributors
14 * may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <asm/arch-ipq806x/iomap.h>
32#include <asm/arch-ipq806x/gpio.h>
33#include <asm/io.h>
34
35/*******************************************************
36Function description: configure GPIO functinality
37Arguments :
38unsigned int gpio - Gpio number
39unsigned int func - Functionality number
40unsigned int dir - direction 0- i/p, 1- o/p
41unsigned int pull - pull up/down, no pull range(0-3)
42unsigned int drvstr - range (0 - 7)-> (2- 16)MA steps of 2
43unsigned int enable - 1 - Disable, 2- Enable.
44
45Return : None
46*******************************************************/
47
48
49void gpio_tlmm_config(unsigned int gpio, unsigned int func,
50 unsigned int dir, unsigned int pull,
51 unsigned int drvstr, unsigned int enable)
52{
53 unsigned int val = 0;
54 val |= pull;
55 val |= func << 2;
56 val |= drvstr << 6;
57 val |= enable << 9;
58 unsigned int *addr = (unsigned int *)GPIO_CONFIG_ADDR(gpio);
59 writel(val, addr);
60 return;
61}
62