|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! J3 _3 w& M: _) r( ^' b! {/ a#include <linux/init.h>
# J3 W* e7 j& K/ S# Q& j#include <linux/module.h>
; R& ` f) P7 B2 f1 ]8 p7 w#include <linux/kernel.h>
/ [" O; u" r* X3 L9 N0 E& c, g#include <linux/types.h>! l0 }. ?5 b$ S" T
#include <linux/gpio.h>( v, N7 Q- r/ O% r5 w) {8 y1 k2 v, R
#include <linux/leds.h>3 T8 M5 [1 G1 y, I# d
#include <linux/platform_device.h>
/ m- X8 D# Z6 S$ m9 h4 K, Y: j6 i! ~" ]: d8 M3 o }) a
#include <asm/mach-types.h>0 D" l4 S: l2 u, {
#include <asm/mach/arch.h>
& f, L8 e. |& P, x4 A#include <mach/da8xx.h>2 Y1 ^- W; }, i; A" o
#include <mach/mux.h>
( ^* L; {8 }3 i6 ^! z& y% Z( N, J9 R' n0 y3 O$ P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# |1 e& D Z, e/ S
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) O& Q) x( h: t" w9 I1 x0 j8 ^9 K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! m" T: \" ?9 T0 g2 D- H. n& ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 X) O. B6 V, C& S- U
f2 K! `& ^/ R* p; E* ]
/* assign the tl som board LED-GPIOs*/
8 p* i* E. p/ O7 L" P! lstatic const short da850_evm_tl_user_led_pins[] = {
/ R+ c# K6 ~0 E6 q3 O /* These pins are definition at <mach/mux.h> file */; E2 r( T' W. n- a- ?3 }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& c; X l/ U& u9 c7 q. n+ V4 j -1
2 ^* u/ L$ d$ G7 Q3 n};) t2 w' Y0 w/ J+ R! Q7 z3 t
# p! [7 o' C9 A/ L; zstatic struct gpio_led da850_evm_tl_leds[] = {
) O, ]" ^+ E% e- w3 J g. C# B {2 @% c9 _3 \0 d" Y' W- p
.active_low = 0,
) d2 b) S# i, X7 X .gpio = DA850_USER_LED0,& S, R4 e) O2 }; S1 ]
.name = "user_led0",4 u Q# B+ Q7 F1 A: k7 _5 O' V) g
.default_trigger = "default-on",
1 ~0 e/ k, O+ E5 }+ ~ },
5 g" ?4 n" ], X1 H8 ]; v# ? {
6 X7 q, B7 S( x* ^) x .active_low = 0,. r* U; [* l. l8 S! N7 l0 x# o
.gpio = DA850_USER_LED1," A, E o3 s u1 v
.name = "user_led1",
* C$ O% S# _3 e0 e, ^. }: f8 Z! b .default_trigger = "default-on",8 v4 J0 e2 T& q% O- |
},9 _/ b2 C; H: T2 K3 j; g+ F, q
{& g' z( Q; A5 t5 X
.active_low = 0,4 a; W) {* E: ?6 v+ l: j9 `
.gpio = DA850_USER_LED2,, a9 A9 G, u, h) y: Q
.name = "user_led2",
6 W* K" f$ C M3 T6 v$ w; Z .default_trigger = "default-on",) e4 Y. f0 k& z, b$ w* }
},
* X! c8 Q! Z' ?. ] {
; c2 x( {0 x" j1 f! \ .active_low = 0,
$ @2 Y3 O, v& n .gpio = DA850_USER_LED3,
- `2 k B& ^ B+ w3 W+ S .name = "user_led3",* i2 G+ B& l1 g( \- @
.default_trigger = "default-on",
s. {+ Z% v0 y# [. u( g+ B },
1 d* E9 u) q2 |6 H4 K( t( \};
$ S' z/ ~0 I9 ` s) a3 D# `7 ?8 j4 {( d* ~* D+ j% `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 `4 [. }8 e5 h+ p! Y) I% @) K- |
.leds = da850_evm_tl_leds,
3 y6 G8 v. t3 p2 ] S. t) y; X( h W7 c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& }" `8 g: O2 o+ X7 ^+ {# a
};
8 M0 O' ^% e% k5 B+ U: p
; Q% D% Q$ y+ a" p' \$ q+ n W$ ^# {static void led_dev_release(struct device *dev)9 r0 n& D; l; n8 f5 ^9 R) \
{! u7 i ?5 ?- ?% J
};& z# Z1 c2 c) g) c& d$ P1 D0 |+ Z
9 F& {, _4 n' d5 r, G% V4 u% t
static struct platform_device da850_evm_tl_leds_device = {
6 ]; x* Y0 E( {$ ]0 ^+ J .name = "leds-gpio",5 D7 V% W o3 y- H# ?5 t9 X
.id = 1,
* D3 z# Y, ^1 F) F% S4 C/ j .dev = {
# u& Z O4 N/ W) n .platform_data = &da850_evm_tl_leds_pdata,
+ D, S0 A/ e/ }, l9 [ .release = led_dev_release,
0 ] s% D* c/ D' F3 E! Y }, ]: t2 A3 v5 d% M r. r
};2 c M" N5 ^9 h& G7 Z; e! r
n. _' s. h& J' U2 |9 z0 d$ ystatic int __init led_platform_init(void)
: L2 P% I( V7 I9 B) C+ c( V{2 X ~ \1 _2 R# N$ \' p1 f$ r
int ret;6 d3 T! i4 h4 s, ?4 g
#if 0
2 G9 c& v& p" R7 K! M! C9 O# k& V$ [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 R e. q$ X( } T. g6 o if (ret)
; p3 A; b. N0 x( d/ ~, T, E0 T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! G5 O: x ]7 o0 Y' x "%d\n", ret); r5 }1 L* @( Y# n8 V. N
#endif
0 P! Q$ r" G& N, f ret = platform_device_register(&da850_evm_tl_leds_device);9 r" P7 w3 t U! a; g
if (ret)
& O$ e. r7 m- i4 U* `# ^: ] pr_warning("Could not register som GPIO expander LEDS");
- X! W% v' P& a; J& d else
2 r& b! \& N! n5 x printk(KERN_INFO "LED register sucessful!\n");8 V+ V% m/ y) P+ S, e: t
% N' r' \0 w& J4 [' `7 k return ret;
4 s( x8 b. U' E# y}
* ]- s' W7 K! O
" z/ N: B4 }9 y j9 ^. [: T' v" Zstatic void __exit led_platform_exit(void)3 d% P# s. D' t+ }: \6 F( d
{
7 |7 T) R6 X& B' T* J* P platform_device_unregister(&da850_evm_tl_leds_device);
' m" d/ k8 F& o! C4 b) M% J# r; j; L1 ?+ J, I/ Y
printk(KERN_INFO "LED unregister!\n");
2 B4 ]3 {# L5 ], R}
7 \7 O r3 \1 M; N) \ r7 a9 @% U! X8 V5 \0 M$ p8 M/ o
module_init(led_platform_init);
% M$ \. n8 S/ Kmodule_exit(led_platform_exit);
6 D: ^& G9 s& `( f- u4 K8 n* z3 b: _
MODULE_DESCRIPTION("Led platform driver");8 A# J: p; N* B9 ?# Q* O
MODULE_AUTHOR("Tronlong");$ K) c6 r! W5 i! ]
MODULE_LICENSE("GPL");) n+ A. j1 O3 F2 g
( J% ]6 ^. {! i |
|