Advertisement
rayddteam

Untitled

Dec 12th, 2011
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.16 KB | None | 0 0
  1. 30c30
  2. < * GPIO driver for AR71xx
  3. ---
  4. > * GPIO driver for AR724x
  5. 34c34
  6. < __FBSDID("$FreeBSD: head/sys/mips/atheros/ar71xx_gpio.c 221518 2011-05-06 02:45:02Z adrian $");
  7. ---
  8. > __FBSDID("$FreeBSD$");
  9. 49a50
  10. > #include <mips/atheros/ar724xreg.h>
  11. 51c52
  12. < #include <mips/atheros/ar71xx_gpiovar.h>
  13. ---
  14. > #include <mips/atheros/ar724x_gpiovar.h>
  15. 58,70d58
  16. < struct ar71xx_gpio_pin {
  17. < const char *name;
  18. < int pin;
  19. < int flags;
  20. < };
  21. < static struct ar71xx_gpio_pin ar71xx_gpio_pins[] = {
  22. < { "RFled", 2, GPIO_PIN_OUTPUT},
  23. < { "SW4", 8, GPIO_PIN_INPUT},
  24. < { NULL, 0, 0},
  25. < };
  26. < */
  27. <
  28. < /*
  29. 73c61,62
  30. < static void ar71xx_gpio_function_enable(struct ar71xx_gpio_softc *sc,
  31. ---
  32. > #if 0
  33. > static void ar724x_gpio_function_enable(struct ar724x_gpio_softc *sc,
  34. 75c64
  35. < static void ar71xx_gpio_function_disable(struct ar71xx_gpio_softc *sc,
  36. ---
  37. > static void ar724x_gpio_function_disable(struct ar724x_gpio_softc *sc,
  38. 77c66,67
  39. < static void ar71xx_gpio_pin_configure(struct ar71xx_gpio_softc *sc,
  40. ---
  41. > #endif
  42. > static void ar724x_gpio_pin_configure(struct ar724x_gpio_softc *sc,
  43. 83,87c73,77
  44. < static int ar71xx_gpio_probe(device_t dev);
  45. < static int ar71xx_gpio_attach(device_t dev);
  46. < static int ar71xx_gpio_detach(device_t dev);
  47. < static int ar71xx_gpio_filter(void *arg);
  48. < static void ar71xx_gpio_intr(void *arg);
  49. ---
  50. > static int ar724x_gpio_probe(device_t dev);
  51. > static int ar724x_gpio_attach(device_t dev);
  52. > static int ar724x_gpio_detach(device_t dev);
  53. > static int ar724x_gpio_filter(void *arg);
  54. > static void ar724x_gpio_intr(void *arg);
  55. 92,94c82,84
  56. < static int ar71xx_gpio_pin_max(device_t dev, int *maxpin);
  57. < static int ar71xx_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps);
  58. < static int ar71xx_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t
  59. ---
  60. > static int ar724x_gpio_pin_max(device_t dev, int *maxpin);
  61. > static int ar724x_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps);
  62. > static int ar724x_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t
  63. 96,100c86,90
  64. < static int ar71xx_gpio_pin_getname(device_t dev, uint32_t pin, char *name);
  65. < static int ar71xx_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags);
  66. < static int ar71xx_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value);
  67. < static int ar71xx_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val);
  68. < static int ar71xx_gpio_pin_toggle(device_t dev, uint32_t pin);
  69. ---
  70. > static int ar724x_gpio_pin_getname(device_t dev, uint32_t pin, char *name);
  71. > static int ar724x_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags);
  72. > static int ar724x_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value);
  73. > static int ar724x_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val);
  74. > static int ar724x_gpio_pin_toggle(device_t dev, uint32_t pin);
  75. 101a92
  76. > #if 0
  77. 103c94
  78. < ar71xx_gpio_function_enable(struct ar71xx_gpio_softc *sc, uint32_t mask)
  79. ---
  80. > ar724x_gpio_function_enable(struct ar724x_gpio_softc *sc, uint32_t mask)
  81. 111c102
  82. < ar71xx_gpio_function_disable(struct ar71xx_gpio_softc *sc, uint32_t mask)
  83. ---
  84. > ar724x_gpio_function_disable(struct ar724x_gpio_softc *sc, uint32_t mask)
  85. 116a108
  86. > #endif
  87. 119c111
  88. < ar71xx_gpio_pin_configure(struct ar71xx_gpio_softc *sc, struct gpio_pin *pin,
  89. ---
  90. > ar724x_gpio_pin_configure(struct ar724x_gpio_softc *sc, struct gpio_pin *pin,
  91. 146c138
  92. < ar71xx_gpio_pin_max(device_t dev, int *maxpin)
  93. ---
  94. > ar724x_gpio_pin_max(device_t dev, int *maxpin)
  95. 149,161c141
  96. < switch (ar71xx_soc) {
  97. < case AR71XX_SOC_AR9130:
  98. < case AR71XX_SOC_AR9132:
  99. < *maxpin = AR91XX_GPIO_PINS - 1;
  100. < break;
  101. < case AR71XX_SOC_AR7240:
  102. < case AR71XX_SOC_AR7241:
  103. < case AR71XX_SOC_AR7242:
  104. < *maxpin = AR724X_GPIO_PINS - 1;
  105. < break;
  106. < default:
  107. < *maxpin = AR71XX_GPIO_PINS - 1;
  108. < }
  109. ---
  110. > *maxpin = AR724X_GPIO_PINS - 1;
  111. 166c146
  112. < ar71xx_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps)
  113. ---
  114. > ar724x_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps)
  115. 168c148
  116. < struct ar71xx_gpio_softc *sc = device_get_softc(dev);
  117. ---
  118. > struct ar724x_gpio_softc *sc = device_get_softc(dev);
  119. 187c167
  120. < ar71xx_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags)
  121. ---
  122. > ar724x_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags)
  123. 189c169
  124. < struct ar71xx_gpio_softc *sc = device_get_softc(dev);
  125. ---
  126. > struct ar724x_gpio_softc *sc = device_get_softc(dev);
  127. 208c188
  128. < ar71xx_gpio_pin_getname(device_t dev, uint32_t pin, char *name)
  129. ---
  130. > ar724x_gpio_pin_getname(device_t dev, uint32_t pin, char *name)
  131. 210c190
  132. < struct ar71xx_gpio_softc *sc = device_get_softc(dev);
  133. ---
  134. > struct ar724x_gpio_softc *sc = device_get_softc(dev);
  135. 229c209
  136. < ar71xx_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
  137. ---
  138. > ar724x_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
  139. 232c212
  140. < struct ar71xx_gpio_softc *sc = device_get_softc(dev);
  141. ---
  142. > struct ar724x_gpio_softc *sc = device_get_softc(dev);
  143. 251c231
  144. < ar71xx_gpio_pin_configure(sc, &sc->gpio_pins[i], flags);
  145. ---
  146. > ar724x_gpio_pin_configure(sc, &sc->gpio_pins[i], flags);
  147. 256c236
  148. < ar71xx_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value)
  149. ---
  150. > ar724x_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value)
  151. 258c238
  152. < struct ar71xx_gpio_softc *sc = device_get_softc(dev);
  153. ---
  154. > struct ar724x_gpio_softc *sc = device_get_softc(dev);
  155. 280c260
  156. < ar71xx_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val)
  157. ---
  158. > ar724x_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val)
  159. 282c262
  160. < struct ar71xx_gpio_softc *sc = device_get_softc(dev);
  161. ---
  162. > struct ar724x_gpio_softc *sc = device_get_softc(dev);
  163. 301c281
  164. < ar71xx_gpio_pin_toggle(device_t dev, uint32_t pin)
  165. ---
  166. > ar724x_gpio_pin_toggle(device_t dev, uint32_t pin)
  167. 304c284
  168. < struct ar71xx_gpio_softc *sc = device_get_softc(dev);
  169. ---
  170. > struct ar724x_gpio_softc *sc = device_get_softc(dev);
  171. 326c306
  172. < ar71xx_gpio_filter(void *arg)
  173. ---
  174. > ar724x_gpio_filter(void *arg)
  175. 336c316
  176. < ar71xx_gpio_intr(void *arg)
  177. ---
  178. > ar724x_gpio_intr(void *arg)
  179. 338c318
  180. < struct ar71xx_gpio_softc *sc = arg;
  181. ---
  182. > struct ar724x_gpio_softc *sc = arg;
  183. 345c325
  184. < ar71xx_gpio_probe(device_t dev)
  185. ---
  186. > ar724x_gpio_probe(device_t dev)
  187. 352c332,333
  188. < return (ENXIO);
  189. ---
  190. > device_set_desc(dev, "Atheros AR724X GPIO driver");
  191. > return (0);
  192. 357,358c338
  193. < device_set_desc(dev, "Atheros AR71XX GPIO driver");
  194. < return (0);
  195. ---
  196. > return (ENXIO);
  197. 362c342
  198. < ar71xx_gpio_attach(device_t dev)
  199. ---
  200. > ar724x_gpio_attach(device_t dev)
  201. 364c344
  202. < struct ar71xx_gpio_softc *sc = device_get_softc(dev);
  203. ---
  204. > struct ar724x_gpio_softc *sc = device_get_softc(dev);
  205. 366d345
  206. < // struct ar71xx_gpio_pin *pinp;
  207. 367a347
  208. > uint32_t reg;
  209. 370c350
  210. < ("ar71xx_gpio: Only one gpio module supported"));
  211. ---
  212. > ("ar724x_gpio: Only one gpio module supported"));
  213. 383c363
  214. < ar71xx_gpio_detach(dev);
  215. ---
  216. > ar724x_gpio_detach(dev);
  217. 394c374
  218. < ar71xx_gpio_filter, ar71xx_gpio_intr, sc, &sc->gpio_ih))) {
  219. ---
  220. > ar724x_gpio_filter, ar724x_gpio_intr, sc, &sc->gpio_ih))) {
  221. 401,404c381,393
  222. < if (0) {
  223. < ar71xx_gpio_function_enable(sc, GPIO_FUNC_SPI_CS1_EN);
  224. < ar71xx_gpio_function_enable(sc, GPIO_FUNC_SPI_CS2_EN);
  225. < }
  226. ---
  227. >
  228. > /* XXX: use something like hints for it */
  229. > reg = GPIO_READ(sc, AR71XX_GPIO_FUNCTION);
  230. > device_printf(dev, "GPIO Functions reg old value = 0x%08x\n", reg);
  231. >
  232. > /* Disable JTAG on GPIO and enable GE0 MII clock */
  233. > //AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
  234. > reg |= AR724X_GPIO_FUNC_JTAG_DISABLE;
  235. > GPIO_WRITE(sc, AR71XX_GPIO_FUNCTION, reg);
  236. >
  237. > device_printf(dev, "GPIO Functions reg new value = 0x%08x\n",
  238. > GPIO_READ(sc, AR71XX_GPIO_FUNCTION));
  239. >
  240. 408c397
  241. < ar71xx_gpio_pin_max(dev, &maxpin);
  242. ---
  243. > ar724x_gpio_pin_max(dev, &maxpin);
  244. 411d399
  245. < // strncpy(sc->gpio_pins[i].gp_name, pinp->name, GPIOMAXNAME);
  246. 415,417d402
  247. < // ar71xx_gpio_pin_configure(sc, &sc->gpio_pins[i], pinp->flags);
  248. < // pinp++;
  249. < // i++;
  250. 422d406
  251. < //device_add_child(dev, "gpioc", device_get_unit(dev));
  252. 428c412
  253. < ar71xx_gpio_detach(device_t dev)
  254. ---
  255. > ar724x_gpio_detach(device_t dev)
  256. 430c414
  257. < struct ar71xx_gpio_softc *sc = device_get_softc(dev);
  258. ---
  259. > struct ar724x_gpio_softc *sc = device_get_softc(dev);
  260. 434,435d417
  261. < ar71xx_gpio_function_disable(sc, GPIO_FUNC_SPI_CS1_EN);
  262. < ar71xx_gpio_function_disable(sc, GPIO_FUNC_SPI_CS2_EN);
  263. 447,450c429,432
  264. < static device_method_t ar71xx_gpio_methods[] = {
  265. < DEVMETHOD(device_probe, ar71xx_gpio_probe),
  266. < DEVMETHOD(device_attach, ar71xx_gpio_attach),
  267. < DEVMETHOD(device_detach, ar71xx_gpio_detach),
  268. ---
  269. > static device_method_t ar724x_gpio_methods[] = {
  270. > DEVMETHOD(device_probe, ar724x_gpio_probe),
  271. > DEVMETHOD(device_attach, ar724x_gpio_attach),
  272. > DEVMETHOD(device_detach, ar724x_gpio_detach),
  273. 453,460c435,442
  274. < DEVMETHOD(gpio_pin_max, ar71xx_gpio_pin_max),
  275. < DEVMETHOD(gpio_pin_getname, ar71xx_gpio_pin_getname),
  276. < DEVMETHOD(gpio_pin_getflags, ar71xx_gpio_pin_getflags),
  277. < DEVMETHOD(gpio_pin_getcaps, ar71xx_gpio_pin_getcaps),
  278. < DEVMETHOD(gpio_pin_setflags, ar71xx_gpio_pin_setflags),
  279. < DEVMETHOD(gpio_pin_get, ar71xx_gpio_pin_get),
  280. < DEVMETHOD(gpio_pin_set, ar71xx_gpio_pin_set),
  281. < DEVMETHOD(gpio_pin_toggle, ar71xx_gpio_pin_toggle),
  282. ---
  283. > DEVMETHOD(gpio_pin_max, ar724x_gpio_pin_max),
  284. > DEVMETHOD(gpio_pin_getname, ar724x_gpio_pin_getname),
  285. > DEVMETHOD(gpio_pin_getflags, ar724x_gpio_pin_getflags),
  286. > DEVMETHOD(gpio_pin_getcaps, ar724x_gpio_pin_getcaps),
  287. > DEVMETHOD(gpio_pin_setflags, ar724x_gpio_pin_setflags),
  288. > DEVMETHOD(gpio_pin_get, ar724x_gpio_pin_get),
  289. > DEVMETHOD(gpio_pin_set, ar724x_gpio_pin_set),
  290. > DEVMETHOD(gpio_pin_toggle, ar724x_gpio_pin_toggle),
  291. 464c446
  292. < static driver_t ar71xx_gpio_driver = {
  293. ---
  294. > static driver_t ar724x_gpio_driver = {
  295. 466,467c448,449
  296. < ar71xx_gpio_methods,
  297. < sizeof(struct ar71xx_gpio_softc),
  298. ---
  299. > ar724x_gpio_methods,
  300. > sizeof(struct ar724x_gpio_softc),
  301. 469c451
  302. < static devclass_t ar71xx_gpio_devclass;
  303. ---
  304. > static devclass_t ar724x_gpio_devclass;
  305. 471c453
  306. < DRIVER_MODULE(ar71xx_gpio, apb, ar71xx_gpio_driver, ar71xx_gpio_devclass, 0, 0);
  307. ---
  308. > DRIVER_MODULE(ar724x_gpio, apb, ar724x_gpio_driver, ar724x_gpio_devclass, 0, 0);
  309.  
  310.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement