summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/pinctrl-imx233.h
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-05-01 13:02:46 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-05-01 13:02:46 +0000
commit08fb3f65745a237e2c1eae55d856ff27702246e5 (patch)
treea56ce11ac20e4df0e36de9195306c10b71752538 /firmware/target/arm/imx233/pinctrl-imx233.h
parentc0838cbfd8e45621fe3450aee1bf9458ff420d16 (diff)
downloadrockbox-08fb3f65745a237e2c1eae55d856ff27702246e5.tar.gz
rockbox-08fb3f65745a237e2c1eae55d856ff27702246e5.zip
Sansa Fuze+: initial commit (bootloader only, LCD basically working)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29808 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx233/pinctrl-imx233.h')
-rw-r--r--firmware/target/arm/imx233/pinctrl-imx233.h109
1 files changed, 109 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/pinctrl-imx233.h b/firmware/target/arm/imx233/pinctrl-imx233.h
new file mode 100644
index 0000000000..291b5c8ff7
--- /dev/null
+++ b/firmware/target/arm/imx233/pinctrl-imx233.h
@@ -0,0 +1,109 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#ifndef __PINCTRL_IMX233_H__
24#define __PINCTRL_IMX233_H__
25
26#include "cpu.h"
27
28#define HW_PINCTRL_BASE 0x80018000
29
30#define HW_PINCTRL_CTRL (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x0))
31#define HW_PINCTRL_MUXSEL(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x100 + (i) * 0x10))
32#define HW_PINCTRL_DRIVE(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x200 + (i) * 0x10))
33#define HW_PINCTRL_PULL(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x400 + (i) * 0x10))
34#define HW_PINCTRL_DOUT(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x500 + (i) * 0x10))
35#define HW_PINCTRL_DIN(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x600 + (i) * 0x10))
36#define HW_PINCTRL_DOE(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x700 + (i) * 0x10))
37#define HW_PINCTRL_PIN2IRQ(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x800 + (i) * 0x10))
38#define HW_PINCTRL_IRQEN(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x900 + (i) * 0x10))
39#define HW_PINCTRL_IRQEN(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0x900 + (i) * 0x10))
40#define HW_PINCTRL_IRQLEVEL(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0xa00 + (i) * 0x10))
41#define HW_PINCTRL_IRQPOL(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0xb00 + (i) * 0x10))
42#define HW_PINCTRL_IRQSTAT(i) (*(volatile uint32_t *)(HW_PINCTRL_BASE + 0xc00 + (i) * 0x10))
43
44#define PINCTRL_FUNCTION_MAIN 0
45#define PINCTRL_FUNCTION_ALT1 1
46#define PINCTRL_FUNCTION_ALT2 2
47#define PINCTRL_FUNCTION_GPIO 3
48
49#define PINCTRL_DRIVE_4mA 0
50#define PINCTRL_DRIVE_8mA 1
51#define PINCTRL_DRIVE_12mA 2
52#define PINCTRL_DRIVE_16mA 3 /* not available on all pins */
53
54static inline void imx233_pinctrl_init(void)
55{
56 __REG_CLR(HW_PINCTRL_CTRL) = __BLOCK_CLKGATE;
57 __REG_CLR(HW_PINCTRL_CTRL) = __BLOCK_SFTRST;
58}
59
60static inline void imx233_set_pin_drive_strength(unsigned bank, unsigned pin, unsigned strength)
61{
62 __REG_CLR(HW_PINCTRL_DRIVE(4 * bank + pin / 8)) = 3 << (4 * (pin % 8));
63 __REG_SET(HW_PINCTRL_DRIVE(4 * bank + pin / 8)) = strength << (4 * (pin % 8));
64}
65
66static inline void imx233_enable_gpio_output(unsigned bank, unsigned pin, bool enable)
67{
68 if(enable)
69 __REG_SET(HW_PINCTRL_DOE(bank)) = 1 << pin;
70 else
71 __REG_CLR(HW_PINCTRL_DOE(bank)) = 1 << pin;
72}
73
74static inline void imx233_enable_gpio_output_mask(unsigned bank, uint32_t pin_mask, bool enable)
75{
76 if(enable)
77 __REG_SET(HW_PINCTRL_DOE(bank)) = pin_mask;
78 else
79 __REG_CLR(HW_PINCTRL_DOE(bank)) = pin_mask;
80}
81
82static inline void imx233_set_gpio_output(unsigned bank, unsigned pin, bool value)
83{
84 if(value)
85 __REG_SET(HW_PINCTRL_DOUT(bank)) = 1 << pin;
86 else
87 __REG_CLR(HW_PINCTRL_DOUT(bank)) = 1 << pin;
88}
89
90static inline void imx233_set_gpio_output_mask(unsigned bank, uint32_t pin_mask, bool value)
91{
92 if(value)
93 __REG_SET(HW_PINCTRL_DOUT(bank)) = pin_mask;
94 else
95 __REG_CLR(HW_PINCTRL_DOUT(bank)) = pin_mask;
96}
97
98static inline uint32_t imx233_get_gpio_input_mask(unsigned bank, uint32_t pin_mask)
99{
100 return HW_PINCTRL_DIN(bank) & pin_mask;
101}
102
103static inline void imx233_set_pin_function(unsigned bank, unsigned pin, unsigned function)
104{
105 __REG_CLR(HW_PINCTRL_MUXSEL(2 * bank + pin / 16)) = 3 << (2 * (pin % 16));
106 __REG_SET(HW_PINCTRL_MUXSEL(2 * bank + pin / 16)) = function << (2 * (pin % 16));
107}
108
109#endif /* __PINCTRL_IMX233_H__ */