|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: ]/ V. k8 L( c$ Z: c3 h#include <linux/init.h>/ x4 X% z* C& r/ \
#include <linux/module.h>$ W" D' [% K* J( e) \& z
#include <linux/kernel.h>
4 ~0 m# C, |0 |$ a$ k#include <linux/types.h>0 U3 u' A1 r2 k6 H
#include <linux/gpio.h>' f, y6 p# J, ?4 ]$ c
#include <linux/leds.h>* n. b( K m3 ^9 N, d9 m. _
#include <linux/platform_device.h>
2 F* k O- ^; f
P& b) `+ F- F# H' {# ], z#include <asm/mach-types.h>
4 B9 A5 \1 L. M! X$ y) o I#include <asm/mach/arch.h>
- u3 u) t& \4 ^7 g3 w#include <mach/da8xx.h>: f1 X0 N$ U0 v
#include <mach/mux.h>; A7 _$ z9 t) l9 I* `4 b `' G$ e: R
: L! d" A7 [0 Q2 U" n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 M5 h. w, e. x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 k& N: ^2 a! V2 Q1 `6 T8 H( J# H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- _2 W" l$ l; E4 G/ A' ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). [/ ]/ Y6 R. L- ?1 y1 B
1 p2 Y( Q, A4 y% Q. B/* assign the tl som board LED-GPIOs*/+ a, i- r) M* s7 j
static const short da850_evm_tl_user_led_pins[] = {% F- _% x2 }1 N6 J
/* These pins are definition at <mach/mux.h> file */
" l" [! k) P5 t8 e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 H( b! s/ y7 X6 N( w j
-1, }3 Z1 |8 {; E3 R$ ]! _, @0 o7 A$ a/ C, w
};
; ~" |2 E, _/ n
' ^% `- {' d# E$ |static struct gpio_led da850_evm_tl_leds[] = {$ {, ?1 L' e7 y! g {3 Y' k
{
$ K9 w) T; O" [& U; v+ t2 p0 ` .active_low = 0,/ Q* G' v" i6 e0 R7 c2 o5 `& _
.gpio = DA850_USER_LED0,& e# t3 d( W# i; w9 o5 u) T
.name = "user_led0",$ _! W# Y+ @0 T" K* H
.default_trigger = "default-on",
2 F- y" [3 H2 N. T% o' K3 t },* N5 ^8 j# u' {- H, S
{* i/ [* u( d( l& i9 F" G9 M0 H
.active_low = 0,
$ \4 l6 r. ]* B7 F& Q .gpio = DA850_USER_LED1,: }% U0 ]: T; y
.name = "user_led1",
, ]9 s' u$ n$ b: X5 ^; N .default_trigger = "default-on",
* R L3 \% M z0 ?* ` },
/ g+ j: X/ Z9 G+ J" o' Y3 j {
9 }" E; o! I% e. J; V .active_low = 0,
1 Y( K5 k9 i* j( h; G1 q* d# I .gpio = DA850_USER_LED2,
. x( d6 M$ `0 s' _- l& X .name = "user_led2",
! d1 ]+ t$ d! M( K2 A .default_trigger = "default-on",& @* @, o5 f9 f6 \
},2 I) X# p& u" X d5 I
{
; x4 M/ ?; n& k2 T: |5 E, B .active_low = 0,) M7 H1 Y8 P& _5 L( x% R
.gpio = DA850_USER_LED3,/ ^+ U' ^3 v! ^. e7 j
.name = "user_led3",
" H2 V5 n# ]. I& _) z$ Q .default_trigger = "default-on",
1 ?7 ?6 ~9 c* n: W% A! ~ },
4 R! Y* \% h) p+ S9 b7 `- w};
3 F. j/ V" J* v* t: ^0 q# b$ S7 L. [ M# F& I. q8 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 E( C+ y& Q. Y .leds = da850_evm_tl_leds,' T+ X. ]; q( f% U2 R, b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; q' o6 l1 x% J
};
! R* t/ J1 x9 O9 a
. j' z7 z. P0 ]; m+ F6 |static void led_dev_release(struct device *dev)* j$ N' Z# y {$ y1 e# u( T
{% H3 l& h& q) H( D+ _
};
; j$ p8 z' ]' W* A: n/ v; R
- |0 `3 p7 N4 p8 [) y4 D1 H1 }static struct platform_device da850_evm_tl_leds_device = {' B8 \1 Q u6 [/ d. v
.name = "leds-gpio",, \, w7 {2 w9 L6 @+ y6 T7 R
.id = 1,* v: O* y; r3 F6 I; `" f
.dev = {; b3 w; Y6 N# |7 ~
.platform_data = &da850_evm_tl_leds_pdata,5 i4 V! J; ~8 e8 q# _3 e
.release = led_dev_release,
. d. s/ C9 o B }8 l) I, v3 M0 S2 t
};
) S+ I' l. u0 ]. a" C& u' ?' h- \! B6 P
static int __init led_platform_init(void)- g3 v% r" a, W3 {
{1 p3 g" [$ G a: g- X6 G
int ret;
+ J6 {9 i/ m- q" q$ O# N z0 |# U# ]3 w#if 0
! B( P) @ R* [/ c0 d( t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 a* n" \1 v# g8 Q1 Y if (ret)3 G( s2 T7 S' U8 e* ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; i' G; g( [/ i1 h. Z) o "%d\n", ret);
" j4 q& U6 w3 H#endif
`2 R/ g% a, ]$ \4 U, q" y ret = platform_device_register(&da850_evm_tl_leds_device);% l ]3 E& F% @+ ]! w1 L4 @
if (ret)
7 `2 k- a$ q/ i5 j' u" V5 Z pr_warning("Could not register som GPIO expander LEDS");: p$ w( U8 f+ o; Q: b
else1 ?+ |' ?6 \- P3 H9 m
printk(KERN_INFO "LED register sucessful!\n");
% J" M, ?8 n* O& P' k& ^! q% `( M% m
return ret;
/ v0 X$ g( M7 N}
: \5 ^/ h& j% U3 i! x# ?. {/ g1 B
0 M$ ^) Q1 v! F, A& @6 nstatic void __exit led_platform_exit(void)
: b% H1 P9 }# I; ~ C/ H{. @% o5 |$ T' c* H- }1 _
platform_device_unregister(&da850_evm_tl_leds_device);% K, l4 Q7 X5 {
2 H& A2 U: ^4 W7 [ printk(KERN_INFO "LED unregister!\n");
& V5 R, g$ A8 H% I}
; \; b+ r: k) A3 n5 [. x& ]9 m5 H8 ]1 P8 }
module_init(led_platform_init);' ?5 F' e! q1 M
module_exit(led_platform_exit);
" a- i% x. D$ Z. W( q- y5 e3 W' U% p9 f6 e- x
MODULE_DESCRIPTION("Led platform driver");, |4 w) [' `' R% T0 k
MODULE_AUTHOR("Tronlong");6 f1 G- @/ Q6 c8 [
MODULE_LICENSE("GPL");. N9 K9 h+ P0 w/ q) ^
9 F9 s7 o4 B6 Y: v
|
|