|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ I4 F5 u, [& t- P% |#include <linux/init.h>
! \: X, H9 K4 p1 T0 P#include <linux/module.h>9 E) V. C: v4 x, x" I
#include <linux/kernel.h>& h$ l% ]) d: x% l1 i
#include <linux/types.h>; I$ @% D* R9 C: |
#include <linux/gpio.h>9 `- r% V6 H5 x
#include <linux/leds.h>; L. Z8 D* x: s) [, }1 \/ _
#include <linux/platform_device.h>1 X7 M) P( O$ j+ @
' O# x0 Q1 N9 G$ T$ x4 [#include <asm/mach-types.h>
2 [3 F5 U% d7 ]6 N) F9 O* \#include <asm/mach/arch.h>
S+ g% ~, v0 ~8 L#include <mach/da8xx.h>3 }) D* J* B. N0 f6 m4 s: G
#include <mach/mux.h>- I! ?7 \ A8 t6 j- o
3 C. o: d7 c7 q) K' D* z+ z/ g5 _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), b* h8 L" @: s8 _3 J/ [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 A" N! U9 G) ~1 r O U2 {% k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( B) G+ c4 v5 O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) Q# L( J' t7 a( f1 S
; J0 v: b3 q+ G; h) n, D0 K
/* assign the tl som board LED-GPIOs*/
; \. X* e1 `, qstatic const short da850_evm_tl_user_led_pins[] = {
1 `4 ~2 {. R% _' t" x" n /* These pins are definition at <mach/mux.h> file */
# ]$ }1 a3 `' S ~# h4 ?* z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% L+ Y0 ?3 j7 _) v! p: W% K -19 _+ r; f/ S( n: d
}; k& X6 \3 p- ^% T% `) W
1 r. ~3 ~* u; e* q
static struct gpio_led da850_evm_tl_leds[] = {3 p$ p0 a& e6 |
{ M+ t! H& Z& `; X* x* q+ `
.active_low = 0,
3 H4 G @, H; b .gpio = DA850_USER_LED0,
; S5 H! t, x( M8 o" n0 z .name = "user_led0",7 y# E( b% | l+ } F6 T
.default_trigger = "default-on",
! [- z6 J1 {4 p0 } },* B; ^: f0 Z7 Z; E5 E
{
3 ^- s1 x' t% y3 D .active_low = 0,
5 R6 c& Q2 x) M .gpio = DA850_USER_LED1,3 |. a: g! }- I/ Z2 Q) X6 L8 W
.name = "user_led1",; _- {* [) w1 c1 z3 Z
.default_trigger = "default-on",
- y2 A% I+ Q4 X* ^! w },: [% l+ i* s* Y7 h" Q
{3 l3 F' `4 n! L% A" n% b
.active_low = 0,1 B1 t8 ~/ i0 ^7 ^, y: j
.gpio = DA850_USER_LED2,
|, ?$ O. c9 M! D .name = "user_led2",# ?* s$ e; d0 ~7 b& M4 P! G$ ?6 S0 J
.default_trigger = "default-on",5 ? g) M4 \3 }9 n! F
},
& u }0 P0 Z& I& ~ {
" ~4 D4 ]& O5 { .active_low = 0,
% _8 K+ e3 R2 I! _7 D% h1 j4 w .gpio = DA850_USER_LED3,; z4 O0 Y9 E; t2 f
.name = "user_led3",# Z- @+ S9 E1 U
.default_trigger = "default-on",5 h8 }9 g! Y# u! |0 W5 f
}," I. r1 I9 K* n/ R6 i6 C
};
: M! i4 N. _4 z% W, X
& `! v5 @* W X6 ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ K1 H$ ?! ?! Q: J: i$ P .leds = da850_evm_tl_leds,
; w+ h. [9 ]1 _- X, R6 z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' @+ P. D {) c" P};
n5 J5 z) h( ]; w' n( E1 M1 Y- ]; M( P7 U
static void led_dev_release(struct device *dev)) E! o5 ?- D' {4 M- d7 W* P: w
{* g4 u0 l( a$ N6 E r) w. C; ]
};
- U& O2 y9 O/ h4 u5 u6 |4 Y+ n! [4 ?- i9 b0 [1 B
static struct platform_device da850_evm_tl_leds_device = {
2 O) x- _+ ^. b# U* y- i .name = "leds-gpio",: b6 e) j6 Z) G$ a
.id = 1,
* b/ }( n8 I" M7 |8 f ]- r5 l .dev = {
1 r8 z3 n5 n- f \4 b/ L .platform_data = &da850_evm_tl_leds_pdata,: ^' _; j9 {& o1 _
.release = led_dev_release,8 P r6 L( o) L) U D5 }! [
}" b6 i* d# m% Z0 o5 H: |
};
% C2 L7 ?0 Y0 [, {# ]& m
% U) a* G1 ~0 A9 w( D- @static int __init led_platform_init(void)2 j+ c& |' }2 S& V3 D
{% P# Y2 r$ K% a/ l3 b: T
int ret;4 H0 h. X! B5 H- p) k1 \6 _6 w
#if 0# F: D. a: T. z# `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 ^, U/ ?& A2 D' s& F4 B
if (ret)# B! D' C; M: Z, v& L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 E V' B6 e: s+ P8 b! X- y "%d\n", ret);
5 Z! U: p U) E% H8 [1 N, U% v6 N#endif
$ ^8 X l( H) S4 L ret = platform_device_register(&da850_evm_tl_leds_device);
' f& m' a8 J* I! s( s if (ret)
' _: }: i& C8 X3 E, O$ k pr_warning("Could not register som GPIO expander LEDS");
- {7 F' ]$ c' s else0 @9 I: U$ @6 H
printk(KERN_INFO "LED register sucessful!\n");
: K- Y v8 g6 g! P( E. r% W
|1 F. q! T- N, s2 i6 G return ret;. _9 n" B4 V' {2 r- O5 w: y
}
( ?: Y. W. r$ i
# l8 g" G- j1 a2 T8 N: jstatic void __exit led_platform_exit(void)
+ e L5 v! A' ]) Q, b{
, B3 s0 V# d8 A& M platform_device_unregister(&da850_evm_tl_leds_device);; l6 \- I6 Y8 H) F; z
; @5 s+ H% j" F% j& K
printk(KERN_INFO "LED unregister!\n");0 F8 y* P! D& X; b
}& D6 b9 X% b) N6 v, m
( k0 b2 m4 z# w/ }4 P2 y' Smodule_init(led_platform_init);
" _6 |3 |+ _; Q2 P3 r! P; v4 v$ [module_exit(led_platform_exit);
) \; a' z0 D1 U* x8 C }4 j/ e0 }2 O
MODULE_DESCRIPTION("Led platform driver");
. k- r: w r! y) E) c V/ {. r, R% gMODULE_AUTHOR("Tronlong");
- s! b2 e/ p* s+ iMODULE_LICENSE("GPL");
( f R8 G( \* N, `! l' G7 ^
3 u5 n' j4 E7 B. ~; y |
|