|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 Z. Q7 j# {: o5 I$ }6 M#include <linux/init.h>
' B$ a& h% U( f, H! n k#include <linux/module.h>3 ~1 V8 }9 q) y8 r/ J6 N# t
#include <linux/kernel.h>
% f& Q- ^0 }" y3 e. m1 q( M#include <linux/types.h>4 y. H- {& l1 V; t2 B, n
#include <linux/gpio.h>
) Q3 F- h7 O3 m- v* k#include <linux/leds.h>
5 D% X4 s$ t2 D9 B#include <linux/platform_device.h>
( I0 C2 U$ G. h. n5 [/ h" }
& d! A) ~- _# @# E |* S, [#include <asm/mach-types.h>1 C$ N* g8 m& l2 {7 l; B
#include <asm/mach/arch.h>8 l+ |, }3 C6 |
#include <mach/da8xx.h>
6 V0 T, y5 R" A' }#include <mach/mux.h>
, N$ T% p0 q% p1 b3 z1 {5 G+ q1 n, w9 |" m; }* r a# S3 t `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ Z) w y J) R0 T6 m" P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 ^) ~9 a2 c3 @% `( h3 P1 V) h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ i- r; {" d& m! }5 l; T#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 C. q6 ]" _9 i
/ Z2 X. \. \' H, Z; l2 g9 z( ]/* assign the tl som board LED-GPIOs*/
/ W$ i5 X6 D% X4 z5 Q! ~( Ostatic const short da850_evm_tl_user_led_pins[] = {
) E, U2 x8 v* H% h4 u' V. c( h- b /* These pins are definition at <mach/mux.h> file */
' d; \. p0 `% ~# y" w3 E6 ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) a6 A0 R' D/ M$ Z -1
, _1 e- N6 f: Z# @# V7 h};
/ N* k; t6 D6 Q" l( l: [" @
6 [( M* p$ p9 o1 a9 A! q' m3 Ustatic struct gpio_led da850_evm_tl_leds[] = {
/ y$ n; q7 N! {; ]6 @! Y6 u {
' l8 J0 P N. J& X5 R+ D .active_low = 0,
G0 W9 I* l, E; X- ^ .gpio = DA850_USER_LED0,% p, F* @( b5 U: t/ H" r
.name = "user_led0",
4 r6 I$ z- m+ @4 W1 ` .default_trigger = "default-on",
& L) p. L- S% S8 Y7 {. t },/ q [" |* Z2 g" `+ V1 P
{3 y# k5 E: k& \+ K2 N7 {
.active_low = 0,# B' C. G# }% b( Y
.gpio = DA850_USER_LED1,
) D- l; @+ u5 q$ W8 i% A. } .name = "user_led1",2 G0 m C- ?4 u! p3 {# M, p
.default_trigger = "default-on",
: I! ]9 j* d$ t$ k },) y6 F3 |- K7 ~9 v+ w% W/ o
{
. a Q% W8 z Q, |# l .active_low = 0,) p a( F' ~- ]/ W6 T: Q
.gpio = DA850_USER_LED2,
" u7 Y$ d( B* H- [0 Y g( l3 T/ w, N .name = "user_led2",
3 L: W: P" ` ?* l* ^2 t .default_trigger = "default-on",* f. k8 k1 I3 t: l$ _( ^
},
3 n/ J- s0 |: x; J+ C {- K7 I2 h5 Y6 ~% J' D3 Q! w2 {9 D
.active_low = 0,4 E1 b8 n% M7 U: V
.gpio = DA850_USER_LED3,; v# G" o" d: U5 s
.name = "user_led3",( j$ j! t* d7 _
.default_trigger = "default-on",
; i% t8 E$ B0 U$ H2 W },
9 t7 C* D$ e3 ?8 R5 V% Y \};6 p( y% i! I, z: }, y, b( F8 v6 P
9 f7 A6 Y+ X) r# x+ @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. v7 M3 ]( O" _ }/ Y
.leds = da850_evm_tl_leds,: a. J/ Q' A3 x4 `% v% r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 ]- q' ` N' R2 T) w2 e};
/ g3 K8 L0 S% K4 f+ I
; D* C' z) I/ _$ O& ?) |3 Gstatic void led_dev_release(struct device *dev)! P' c9 q" `2 L5 P8 P1 N
{
( w6 I1 \+ i$ [};
" T* q$ }, K6 ~6 Q' q- E; K8 s2 E9 G5 B" m
static struct platform_device da850_evm_tl_leds_device = {
8 g) o/ p9 J. i. c .name = "leds-gpio",
3 t7 b* f; x* E+ J4 h3 O( {( G2 @ .id = 1,; F- ?3 Y! n4 c* l) ~" G1 G
.dev = {
8 c% K9 ~9 u" g+ a .platform_data = &da850_evm_tl_leds_pdata,
8 j* K1 L1 q; @% U! O7 b" T .release = led_dev_release,$ B& v2 Y6 K& }0 G5 K, e- e
}6 L% v8 @$ u( [; _5 m1 U* l
};
% ]& Q2 U& x) b, L2 X( a2 A6 V, ]9 I2 W; A- c
static int __init led_platform_init(void)
2 X& P- W' d1 w6 q" A f{
4 d, k3 O8 E2 V( v- _ int ret;. ^: j7 D3 {& m3 T8 B/ ^4 R; N
#if 0% e5 N* |2 K0 ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. I8 }8 V( n8 o/ d if (ret)2 h [" h# s9 x% M+ e& t. L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 X. T6 A. ?( r F "%d\n", ret);; h: [' ?( L/ m$ P
#endif
7 j( y$ T- L( U% _7 t ret = platform_device_register(&da850_evm_tl_leds_device);1 g# Z9 b* c* o( q# b& y
if (ret)
6 |/ }1 O6 z ?; I% ?$ X6 i pr_warning("Could not register som GPIO expander LEDS");6 b! {4 ^0 z) I' h8 H8 h% g
else9 O3 A6 w5 E, w6 g/ u, U
printk(KERN_INFO "LED register sucessful!\n");9 {4 ?/ n7 ~# ^2 ~9 X6 U) ^
0 I& g* F+ \, Z- |0 {! e0 ] return ret;1 j; C/ ~1 p" s4 c
} A& h- j& \0 y% n# p# t
8 I: J) |4 q% S- B! g; s5 G' K% X
static void __exit led_platform_exit(void)
# \* d% Y t' K" t U+ d- d{
; k5 |1 p% ~& F. l platform_device_unregister(&da850_evm_tl_leds_device);
( p4 V% v9 e. o4 I' M1 p! f) h* s8 F0 A, \4 | ^8 u- j8 s9 V
printk(KERN_INFO "LED unregister!\n");5 o% g. ^; P# j! _2 f. b
}/ U3 U" x& m+ `' E; n J6 g
& _0 P6 Q) }1 v3 h8 h- Y
module_init(led_platform_init);
+ o5 z, y9 }) ]7 Z* v% qmodule_exit(led_platform_exit);
3 E7 q* s/ J2 \$ f- _
9 D( G7 ^! W( y1 H3 K/ Z RMODULE_DESCRIPTION("Led platform driver");
+ E# b) Y4 N5 Q' \) P( s. nMODULE_AUTHOR("Tronlong");
$ G+ ~+ J$ s) Y+ m1 x: Z- K/ OMODULE_LICENSE("GPL");# q3 _; A g0 V( u$ \2 D2 b
0 a3 P# x# H; `0 u9 I2 O, D7 Q |
|