1 /* 1 2 * Copyright (C) 2007-2009, OpenWrt.org, Flor 3 * GPIOLIB support for Alchemy chips. 4 * 5 * This program is free software; you can red 6 * under the terms of the GNU General Publ 7 * Free Software Foundation; either version 8 * option) any later version. 9 * 10 * THIS SOFTWARE IS PROVIDED ``AS IS'' A 11 * WARRANTIES, INCLUDING, BUT NOT LIMITED 12 * MERCHANTABILITY AND FITNESS FOR A PARTICUL 13 * NO EVENT SHALL THE AUTHOR BE LIABL 14 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQU 15 * NOT LIMITED TO, PROCUREMENT OF SUBSTITU 16 * USE, DATA, OR PROFITS; OR BUSINESS INTER 17 * ANY THEORY OF LIABILITY, WHETHER IN CONTR 18 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISIN 19 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSS 20 * 21 * You should have received a copy of the GN 22 * with this program; if not, write to the F 23 * 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * Notes : 26 * au1000 SoC have only one GPIO block : 27 * Au1100, Au15x0, Au12x0 have a second o 28 * Au1300 is totally different: 1 block w 29 */ 30 31 #include <linux/init.h> 32 #include <linux/kernel.h> 33 #include <linux/types.h> 34 #include <linux/gpio/driver.h> 35 #include <asm/mach-au1x00/gpio-au1000.h> 36 #include <asm/mach-au1x00/gpio-au1300.h> 37 38 static int gpio2_get(struct gpio_chip *chip, u 39 { 40 return !!alchemy_gpio2_get_value(offse 41 } 42 43 static void gpio2_set(struct gpio_chip *chip, 44 { 45 alchemy_gpio2_set_value(offset + ALCHE 46 } 47 48 static int gpio2_direction_input(struct gpio_c 49 { 50 return alchemy_gpio2_direction_input(o 51 } 52 53 static int gpio2_direction_output(struct gpio_ 54 int value) 55 { 56 return alchemy_gpio2_direction_output( 57 58 } 59 60 static int gpio2_to_irq(struct gpio_chip *chip 61 { 62 return alchemy_gpio2_to_irq(offset + A 63 } 64 65 66 static int gpio1_get(struct gpio_chip *chip, u 67 { 68 return !!alchemy_gpio1_get_value(offse 69 } 70 71 static void gpio1_set(struct gpio_chip *chip, 72 unsigned offse 73 { 74 alchemy_gpio1_set_value(offset + ALCHE 75 } 76 77 static int gpio1_direction_input(struct gpio_c 78 { 79 return alchemy_gpio1_direction_input(o 80 } 81 82 static int gpio1_direction_output(struct gpio_ 83 unsign 84 { 85 return alchemy_gpio1_direction_output( 86 v 87 } 88 89 static int gpio1_to_irq(struct gpio_chip *chip 90 { 91 return alchemy_gpio1_to_irq(offset + A 92 } 93 94 struct gpio_chip alchemy_gpio_chip[] = { 95 [0] = { 96 .label = "alc 97 .direction_input = gpio 98 .direction_output = gpio 99 .get = gpio 100 .set = gpio 101 .to_irq = gpio 102 .base = ALCH 103 .ngpio = ALCH 104 }, 105 [1] = { 106 .label = "alc 107 .direction_input = gpio 108 .direction_output = gpio 109 .get = gpio 110 .set = gpio 111 .to_irq = gpio 112 .base = ALCH 113 .ngpio = ALCH 114 }, 115 }; 116 117 static int alchemy_gpic_get(struct gpio_chip * 118 { 119 return !!au1300_gpio_get_value(off + A 120 } 121 122 static void alchemy_gpic_set(struct gpio_chip 123 { 124 au1300_gpio_set_value(off + AU1300_GPI 125 } 126 127 static int alchemy_gpic_dir_input(struct gpio_ 128 { 129 return au1300_gpio_direction_input(off 130 } 131 132 static int alchemy_gpic_dir_output(struct gpio 133 int v) 134 { 135 return au1300_gpio_direction_output(of 136 } 137 138 static int alchemy_gpic_gpio_to_irq(struct gpi 139 { 140 return au1300_gpio_to_irq(off + AU1300 141 } 142 143 static struct gpio_chip au1300_gpiochip = { 144 .label = "alchemy-gpi 145 .direction_input = alchemy_gpic 146 .direction_output = alchemy_gpic 147 .get = alchemy_gpic 148 .set = alchemy_gpic 149 .to_irq = alchemy_gpic 150 .base = AU1300_GPIO_ 151 .ngpio = AU1300_GPIO_ 152 }; 153 154 static int __init alchemy_gpiochip_init(void) 155 { 156 int ret = 0; 157 158 switch (alchemy_get_cputype()) { 159 case ALCHEMY_CPU_AU1000: 160 ret = gpiochip_add_data(&alche 161 break; 162 case ALCHEMY_CPU_AU1500...ALCHEMY_CPU_ 163 ret = gpiochip_add_data(&alche 164 ret |= gpiochip_add_data(&alch 165 break; 166 case ALCHEMY_CPU_AU1300: 167 ret = gpiochip_add_data(&au130 168 break; 169 } 170 return ret; 171 } 172 arch_initcall(alchemy_gpiochip_init); 173
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.