|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! ~# z/ N! E0 @) R" A" c
#include <linux/init.h>
* U5 D; l1 i2 a& D9 }; t% a#include <linux/module.h>
1 s+ N. v# S7 h/ F/ G; Z! Y#include <linux/kernel.h>
: l3 @* Y; G" x) X#include <linux/types.h>
* |/ u* `8 }2 }% n4 e- J#include <linux/gpio.h>" p2 J! t) y% h( Z9 k- f4 K
#include <linux/leds.h>" b/ k4 {2 _+ `2 G: p4 P3 T( j
#include <linux/platform_device.h>0 a) I! X+ Y6 i" p; A
' d* `3 ]6 [$ m* ^: Y, _
#include <asm/mach-types.h>+ |1 F3 e' k: f* x" G% H& F0 j
#include <asm/mach/arch.h>
6 ?7 H2 M% b, j& j/ y" N+ Y Y#include <mach/da8xx.h>' U( x+ Q2 I0 f. k8 s* z
#include <mach/mux.h>
/ z- U, t7 h6 n, l/ c# x/ }2 d; `& @+ I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 T4 S8 m; b& d% k% J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ Z7 a2 Q4 O# v9 M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! K% v) |! F! Z6 q1 H" d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! s# }! ]2 ?: R6 s6 O8 h: a) n9 ^$ ^
9 k# o# U5 c+ K2 f( s" s1 o
/* assign the tl som board LED-GPIOs*/
0 q* v, q1 r; T0 D8 ^4 d7 pstatic const short da850_evm_tl_user_led_pins[] = {% b2 X3 p5 {/ M0 `
/* These pins are definition at <mach/mux.h> file */1 Y7 @. V1 Y. J: e* P. x4 k% Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; T9 X5 N" G9 g+ K. \8 k; p -1
( q5 U. k* {+ p0 n; l};; g# p! Y$ c: C4 b1 Y
$ j( c5 m. _9 e5 O. Q istatic struct gpio_led da850_evm_tl_leds[] = {: Y' K* o' d3 W9 P) Y
{# b; B" ? o0 b( b' k
.active_low = 0,5 d u# \1 } ^4 d. M/ X2 ?0 B
.gpio = DA850_USER_LED0,
6 `- [' C' k7 R .name = "user_led0",6 M2 t! X# |- ~3 Y6 ^$ p: m
.default_trigger = "default-on",6 W% Z( f/ Z& t8 g7 v7 R$ u* i3 ^
},' i$ H7 A5 v7 ]5 i" E
{2 G0 D5 s+ I0 U% B1 h
.active_low = 0,4 X$ }7 S, }) Y. w* E
.gpio = DA850_USER_LED1,
# }* M9 y( r6 U- U S .name = "user_led1",
0 h$ A2 @* I$ } .default_trigger = "default-on",
8 G: x5 x$ d* r },
& Y* L4 I, q w8 B1 j* C {* x* u3 X! `# Z5 l! E. H: t
.active_low = 0,
* ~9 b6 m ]0 ^ u' C. v .gpio = DA850_USER_LED2, o! u. o9 h) x$ S7 g$ _
.name = "user_led2",5 f+ A8 v6 [. k% K
.default_trigger = "default-on",7 l+ c- J* {9 t0 j/ \+ B/ \% U
},7 m3 U& Q+ |; y1 p
{* o9 \4 y5 O8 i5 R
.active_low = 0,8 V1 E9 i- R1 {; s9 J* W5 q3 U
.gpio = DA850_USER_LED3,
6 c& b* t4 X* |9 x .name = "user_led3",
+ D3 J) t7 T) E0 Q .default_trigger = "default-on",
0 U( R; u! y, p( c5 _/ Q8 T },
- _- {! r) o& r/ y( R5 m2 a};; f F& }$ `# p
. E2 N% G+ {9 a5 o W: Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 d, _5 @ ~! `$ I- K
.leds = da850_evm_tl_leds,
6 i9 A3 |2 d# f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 Z+ P7 @" b+ e$ `5 @! X};
" u& V$ Q1 }- g
+ A u" n5 j0 t+ i( B) o) W+ qstatic void led_dev_release(struct device *dev)4 i- S# b. M& k7 Z3 \- f! k2 }
{
- l% X R* r3 c( A. @; g};
) ?: J/ q1 z2 T) B8 n# j0 P$ H, b, e7 O$ T5 e7 v1 h; w# @
static struct platform_device da850_evm_tl_leds_device = {
& y& T2 `2 X2 ], p# v .name = "leds-gpio",
& t3 z9 I1 E& P; R! e7 l .id = 1,: I; E p3 g3 m/ U6 w
.dev = {
; Y* ~" b: n" w .platform_data = &da850_evm_tl_leds_pdata,2 `- e, u3 v3 l
.release = led_dev_release,
; {1 \6 z0 s& S6 _% k+ _8 f. P }, r% v* g5 F, l4 }
};
, p' M) [, x5 _/ l- }, F3 {
# V* T. Y5 H5 x( ^3 P( f, M! _" Jstatic int __init led_platform_init(void)
* j1 f* a; y. C& I' }$ L{0 z" _" S; [( `% ]5 V, O9 j5 x
int ret;
" T7 T+ d* Z* G6 h2 _7 v& V#if 0
9 l3 [- k% a1 u8 K0 A" t. ~: C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' X( E( C) q' d* f7 O) v3 b3 q
if (ret)
6 e* s; C+ }/ ^" R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 z! m8 F7 | W3 a9 f$ F' y
"%d\n", ret);
?# y3 V- c4 P# ~; g4 h9 X#endif4 a D7 i0 R, k; y
ret = platform_device_register(&da850_evm_tl_leds_device);/ R# d- D* h0 W. C
if (ret) m% X& J4 O6 B
pr_warning("Could not register som GPIO expander LEDS");! p: s7 h+ m7 u0 f% C1 O2 Q. U; V. q
else; C& A8 n, G' P- d
printk(KERN_INFO "LED register sucessful!\n");
. U( ^; J& Y/ @: A' p, S4 K( Q$ h3 F: H1 P, ~
return ret;
8 s# P8 E( i' K( u- m. F}
" M+ Y6 R+ K& r$ p5 W# `/ ?8 h# J
static void __exit led_platform_exit(void)
- j8 z1 z$ Y) E7 V8 Q8 T* ~{
& |" p4 A, `: `4 ` platform_device_unregister(&da850_evm_tl_leds_device);
9 E6 {5 H5 A9 v1 Q' V
! ?: A$ _# K& g5 m6 o1 \5 }; Z printk(KERN_INFO "LED unregister!\n");8 b- h' P9 g5 g5 [' w2 \+ M
}
: ]* e) Y& f( N/ h
: W8 M& l/ G. }2 D Dmodule_init(led_platform_init);4 e$ b& q. f+ H+ ^* g
module_exit(led_platform_exit);
# _6 ?, A/ Q6 Z, W; k1 _ |: V$ o1 e: j0 u% [3 p0 M
MODULE_DESCRIPTION("Led platform driver");/ ]+ C+ o2 {9 {; f0 F$ h
MODULE_AUTHOR("Tronlong");
0 f* `2 z' |. X8 E2 H4 zMODULE_LICENSE("GPL");
4 k" \% v# h! n* ~1 k9 R7 [# ~7 h8 b9 O0 @$ X, r
|
|