|
求大神给下面的程序做注解,请稍详细些,谢谢。
) S5 U, D2 u' P7 w ^ L4 s$ x" b( \#include <linux/init.h>
! G) \3 j& R( d- r' {) k# l, I#include <linux/module.h>7 i" k0 ^. F/ \4 n
#include <linux/kernel.h>
4 }6 J& r7 W. h( U, c) c* a2 ^#include <linux/types.h>( u; M" r3 x8 q- i% ~: Q6 E2 O7 P
#include <linux/gpio.h>% }- _& N" `0 b0 ?
#include <linux/leds.h>
/ N. y# `' ?: X0 W6 s#include <linux/platform_device.h>
; G- u( ~& N+ H& r* ]! ?0 p0 w$ K
! p3 T: v3 j7 I" E#include <asm/mach-types.h>% { P: O! @+ Q2 @' j B+ R. I; w
#include <asm/mach/arch.h>9 G: v& S z8 V( A+ @
#include <mach/da8xx.h>- B- U6 o' Z" b% T* l
#include <mach/mux.h>. o2 j4 u$ g5 j) H9 c
+ N& s& ^, t8 \& }+ ~1 h/ v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ Q& @4 s% v' U+ E0 c' Y# Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 e5 r* ]# A* p! N+ N! j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. I- Q) L' F2 J2 q+ y) p1 {8 ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 S7 {6 f( I: C, y$ w; |0 z; l2 ~0 G& K
/* assign the tl som board LED-GPIOs*/& z, ]5 M- P0 }0 s# O
static const short da850_evm_tl_user_led_pins[] = {
7 C( F7 ^, L8 N/ Z' I /* These pins are definition at <mach/mux.h> file */8 P0 ]' M% Y5 N) z S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; y0 q0 M8 Z* n: |7 ?& j5 D -1
! X! W: e9 y% d, b L/ H! G) h% y J' q8 Z};, Q' i% h6 U" ?/ A6 s8 Y
5 w3 i, z% o) J7 Gstatic struct gpio_led da850_evm_tl_leds[] = {. L: V5 Q' x$ W+ D, J/ c
{
7 X! P( _* {* c, ?3 A1 x$ _ .active_low = 0,! y% e8 K' I. V D2 y
.gpio = DA850_USER_LED0,* I$ g' j% \5 u
.name = "user_led0",! T3 Q i) l3 l) n4 L& a
.default_trigger = "default-on",
# H( ^6 U4 P' q. S/ Y( c0 L },
- @6 h; q: X$ E, j" h$ ~' w {3 v. [$ R9 g: r
.active_low = 0,0 v. ^0 q- z) | @" f
.gpio = DA850_USER_LED1,0 _+ m3 n% D) _( C
.name = "user_led1",
( k1 Y# E/ I1 C) U% R8 H- E, n .default_trigger = "default-on",# T% o) L" }% @+ S n* {" V3 T* b
},6 w) R2 R9 p+ K3 l6 X
{" @3 l% R0 h! Z2 N m; t0 L
.active_low = 0,
" t/ r- d( A2 L+ ]" r .gpio = DA850_USER_LED2,
! {8 v. J, W3 W( o( n .name = "user_led2",- J4 n' U t: q; o8 c2 o2 Y
.default_trigger = "default-on",% F# T3 z7 |! S8 D K
},
, U; w9 }- E9 r! e5 S: o+ c. i {
% T; t) e6 Q) {0 \3 \# p .active_low = 0,8 I, V8 h( J6 i
.gpio = DA850_USER_LED3,9 W% f1 @; i" k- D/ {
.name = "user_led3",( L: [, v" W5 I# R; n
.default_trigger = "default-on",( a* Q! |/ [: N# o8 R3 j3 A
},
T6 w( \1 N+ _, r; Z9 V: d};
+ R5 p8 @1 h& J- a$ _: e% W4 h/ Y7 }* j" a) g/ e0 s0 C) u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; `# u" K' c0 M1 ?8 ?/ W5 _7 t .leds = da850_evm_tl_leds,
- P7 U# V: g4 Z! s( |# N4 J. D5 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* G1 |9 F2 \8 \. A R};/ y& m% h/ M7 {6 e0 n2 w6 u! ?5 f
3 k% X5 S( Q. Y9 ]( u1 I. fstatic void led_dev_release(struct device *dev)
* L- |3 n* W5 r7 d4 h* ]{9 d; Z8 _4 n( o2 o
};4 r; F8 D" \% |3 w
' j! l; w( {6 M3 ?) |* ]static struct platform_device da850_evm_tl_leds_device = {
$ O2 e T, k6 m .name = "leds-gpio",
4 m n6 B0 O9 t6 h .id = 1,: `! D! i# L- r7 [$ u6 M% l7 N. S0 o
.dev = {
: c1 J! N8 j& R7 X. g/ D Y .platform_data = &da850_evm_tl_leds_pdata,1 |6 u8 O: T8 B4 H; }+ v
.release = led_dev_release,
+ F) X/ \7 g. G2 k& a4 d }* }8 \$ b3 P8 k3 r7 k2 G
};
9 K0 q! n9 y* d9 o9 ]% F8 y. b+ M" r1 D, O1 k7 o% w* |' d
static int __init led_platform_init(void)0 }3 I: b+ T) L; c) {7 d9 G
{
. e: @+ ]& }: M: t2 w' w int ret;" u' W2 D% } o* Y4 ]+ l
#if 0- V- W) j! }2 P9 e! {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 U; z( O1 ~: i/ _, s if (ret)2 `# |4 @9 y5 ]& R F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 z% n5 c; E' P0 C/ \ "%d\n", ret);) Y' n3 Y% Q& d# M
#endif% T0 q0 D0 N/ e7 D% ~ z/ t" U
ret = platform_device_register(&da850_evm_tl_leds_device);( @ d# H4 E6 A7 L
if (ret)) p. D {' _( d
pr_warning("Could not register som GPIO expander LEDS");$ h; w+ \& k- T4 U, @
else9 b5 U9 W! _) g; |1 B* g6 g% c
printk(KERN_INFO "LED register sucessful!\n");
4 n. q: o: s8 V: D, Y; y X2 S; B: G8 A7 W2 G+ W2 [
return ret;
% s- P" Z* q6 q, m5 _}, D2 c8 s3 \' j9 Y# M
& A! s$ M7 f* t2 d" @& J4 fstatic void __exit led_platform_exit(void)7 L! m; \) d, A% s) M6 l9 n
{
; W. |6 [4 F4 H6 ?- Y- E platform_device_unregister(&da850_evm_tl_leds_device);
& c& l' ?. s- }0 O [- T% P6 l; I2 E; s4 I4 V% Z' W* i
printk(KERN_INFO "LED unregister!\n");
$ e2 P8 Z5 s% j' C6 K2 w1 ^0 c}
) Y( X. Y* s! m8 S# n/ n: Q0 f* T' ]+ H
3 I' y2 ~/ A( q* {# A( Tmodule_init(led_platform_init);
) b3 c i, V( Dmodule_exit(led_platform_exit);
! Z7 K$ t2 h1 Q* A0 [* T8 j% n- H5 b
MODULE_DESCRIPTION("Led platform driver");
& D5 l( S9 b% c, XMODULE_AUTHOR("Tronlong"); F+ u5 k @1 z% @
MODULE_LICENSE("GPL");
; s1 ]8 j$ H( f# p' E) W% m: _0 S
: J$ G5 g: N& E5 ? ?# E& X |
|