|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ q/ \) J- x) o/ F0 ?7 }9 C
#include <linux/init.h>
# _- n" u+ j( k& q; }) m5 m#include <linux/module.h>
& E/ G9 v5 ~, R9 m* [) }#include <linux/kernel.h>
# D! ~$ \+ X* z& `6 h#include <linux/types.h>
/ B# r0 Q( a0 |' @) i5 e. n#include <linux/gpio.h> F2 B4 {0 e$ e- ]6 W1 K" ?- |) |5 p0 j
#include <linux/leds.h>6 Y# L/ r( o" Q5 E5 Q: ~7 {$ F
#include <linux/platform_device.h>3 w/ `* A! K6 y: O; s& U
9 {4 c" ?7 K. q#include <asm/mach-types.h>0 L5 R) z' n" f! `9 K1 {9 M
#include <asm/mach/arch.h>
/ V: \/ K1 X( I/ t% a$ T% y#include <mach/da8xx.h># {' R( d) z0 |8 Y0 D# I8 R
#include <mach/mux.h>
3 |0 f; O9 b* d7 T
0 l8 J" |0 Z* s. y. Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 {9 s7 t& ]4 t! ]. G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' |8 {4 Q! [- I8 e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* I# Z' [2 M9 r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ J: g# o6 c6 X( u; M
) f( e: {9 b! ~* @, A$ F/* assign the tl som board LED-GPIOs*/
% O x" `- \+ i/ h* ^$ astatic const short da850_evm_tl_user_led_pins[] = {- n: M* x8 W- V& M5 X& a
/* These pins are definition at <mach/mux.h> file */
# s6 U) S4 J/ | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," S$ y/ D; k, J. s- y4 b4 U( P
-13 {# B8 h8 ~% Z6 Y8 x
};
! G( b' N5 [3 C; g% E2 y' Y9 \( j- [( `" p! Z" ^
static struct gpio_led da850_evm_tl_leds[] = {
: h' F2 h4 A" [) c8 q1 e/ Z {% s) i4 Z8 u5 |$ ^! a7 H& q+ _
.active_low = 0,) K5 f/ f7 k1 I( O- |& y2 W+ ~( B; L( q
.gpio = DA850_USER_LED0,0 E% {8 z# b; W1 k; ?
.name = "user_led0",& N6 _; [" X k& v
.default_trigger = "default-on",
) k! R2 u" \6 Y6 J o1 e },3 M: Z) q. ~4 e
{, H; ]5 r4 M7 m! C+ _8 f, V, p; `
.active_low = 0,
+ s8 e7 s5 q/ _; J7 l& P .gpio = DA850_USER_LED1,
# |# R" k( J2 B2 b .name = "user_led1",; R; \7 B# P# i+ e0 P* b
.default_trigger = "default-on",
# B/ O; H% `5 | },
( j3 \, A% K/ W: P+ C' E5 N {
: l" L/ \0 F/ V .active_low = 0,9 J' U( _1 t* ]4 p
.gpio = DA850_USER_LED2,
4 C( f1 W6 |% k% ~* E; }! N .name = "user_led2",
6 w7 p2 G; h! _: w+ V; [ .default_trigger = "default-on",
- M9 G' q, B2 c, M) v) ?6 o, s },
4 A6 Y5 X9 ?1 a3 T0 F D- O+ q# C; B {
- j s' f7 v9 O2 P u: z; D .active_low = 0,
' d: d2 I* ^$ {$ } ?1 W/ I .gpio = DA850_USER_LED3,
" a0 i# p ^7 d* } d* O: d, j4 |4 i- N .name = "user_led3",3 }' [! C% z; j+ X" i+ c4 Q9 B
.default_trigger = "default-on",
. j# U6 h7 |5 ` },/ u) r2 i( ?7 B( w6 G
};3 D* g! n. o( P. e0 q# F9 ^) X
% b3 L! d& y: @1 i) U! E q8 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ v1 H- T+ I0 U! M2 v; h .leds = da850_evm_tl_leds,
& y8 i7 R2 j x, b4 q7 l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 W8 c' W" j/ L5 D
};0 |) \0 O) _7 F2 u" U( q
5 b6 Q6 J6 O8 Y5 ]
static void led_dev_release(struct device *dev)% ~+ S V# k" p. l- ]1 X0 K
{: ^8 _6 c9 I8 f, r: X$ u9 p
};# y1 k/ q0 D; O2 Y) A
1 E, l$ E+ v8 q" e$ u, Jstatic struct platform_device da850_evm_tl_leds_device = {9 [/ e, r- H9 Y4 R( c/ s, f" V- i
.name = "leds-gpio",
' S9 H8 [- O# p2 A/ X8 Q$ R' v .id = 1,
9 c @& ^& ?6 f* P- _ .dev = {
; M7 k$ r* D4 Q7 W) G .platform_data = &da850_evm_tl_leds_pdata,+ L. _1 I" O9 u
.release = led_dev_release,7 [, @ _3 j9 I6 o1 Q2 {: b" z
}, c' k: J7 e/ q& [5 R
};1 A' x& H; c& N, z: F& M$ C# y
# f9 }' f! K' R* ystatic int __init led_platform_init(void). }; q$ X% k! `* s) K+ G) j% b( R
{% v; _3 {# F0 G0 Z }
int ret;9 D3 r0 X; @* V9 C% I0 D3 A( i+ `
#if 0
! L4 i6 |& o1 z3 Q4 ]0 g( v: B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ p- C4 H: s% z; Y% s/ f if (ret)/ `% f4 d' M$ a% I" u( K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) U# q) r8 J! M, E "%d\n", ret);$ S) l: B; w, u' L6 H* a
#endif m' W( z& } A. v( i9 ]
ret = platform_device_register(&da850_evm_tl_leds_device);
6 N1 C6 }! U/ y( Q j$ b5 O1 W; ?: X if (ret)
& V* c! U# C! x. _1 I pr_warning("Could not register som GPIO expander LEDS");
" A; p7 ?2 Y: S, x4 {3 O" \ else
: c2 {, {3 F$ x& s E; V, z printk(KERN_INFO "LED register sucessful!\n");
$ w/ E0 w; b7 b s
0 u1 U0 e* [8 s7 { return ret;1 L j! h5 }; k7 ~( O& v
}0 S' X+ J- Q$ K9 M0 a1 O
/ Q& d% R: i5 k
static void __exit led_platform_exit(void)
; G1 V+ t, r* t% c% I4 ^& a{
5 x" E* G/ g+ f, g9 s platform_device_unregister(&da850_evm_tl_leds_device);3 k4 s1 D* \& L \
+ Z: G8 n0 j( O- t* W$ u ^ printk(KERN_INFO "LED unregister!\n");
6 d p; a9 {; |: \' o}
+ G/ r, z; h" b- g' @* E. y/ E* i. p) x( `/ _
module_init(led_platform_init);9 U) Z, Z0 D$ k; }$ s# ^( L
module_exit(led_platform_exit);
& U& Y. F1 x$ I" R/ w. i! _# f) L4 I6 i( Z
MODULE_DESCRIPTION("Led platform driver");# K. u% Y# z1 t' p1 }. C9 V
MODULE_AUTHOR("Tronlong");! J- \: w7 B& c" ]6 z7 Q( i
MODULE_LICENSE("GPL");( d" w) d9 F8 C0 p
) |: f" x' D9 T- V
|
|