|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 @0 n( L, A7 ~0 P5 L; z#include <linux/init.h> O$ o- ~: j7 m1 T5 e
#include <linux/module.h>
. W$ Q: C( J; R, ~#include <linux/kernel.h>
+ ^' N) @. |: v$ ~- u8 N#include <linux/types.h>
6 s1 `9 I' ~; E: m, W# ]#include <linux/gpio.h>
v# Z3 r9 ^+ k6 i0 e9 u {#include <linux/leds.h># X& J" L m, }& |1 l( @
#include <linux/platform_device.h>
0 S8 g+ H6 P- t% J( d2 d ?/ u$ n; U! h+ G* g6 e
#include <asm/mach-types.h>
( ^' l. ]" ^& B$ P3 W0 B W#include <asm/mach/arch.h>6 k& V2 v# |/ Q) s. \; j/ {) r2 U
#include <mach/da8xx.h>7 h) B+ V, L" |
#include <mach/mux.h>
?! X0 h4 N# z2 x
6 O; f+ f& K8 s8 P f0 D+ W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): o% J1 I- F/ s8 O# f7 }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 s% o- Q7 j* Q+ |) U#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 Y, W) y2 O7 ^+ D( i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! x+ l) K+ _9 b" i7 o
4 K; R/ k' b! u0 H% ?1 V1 T8 o) c- B/* assign the tl som board LED-GPIOs*/
* e! f3 ] p; t9 |6 nstatic const short da850_evm_tl_user_led_pins[] = {3 i4 p5 ?; s: b* l4 @
/* These pins are definition at <mach/mux.h> file */
% A/ l5 v2 a& d" N: r3 T1 S/ Y- e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! f5 F0 D- g% B7 s -1# x' e: a* E! |0 Q) g* T, b- B# [
};
. w) Y8 O; M$ ~$ o
* k% p, o% r3 p0 l) S' N1 v0 e1 S+ `static struct gpio_led da850_evm_tl_leds[] = {- a* n; h! {- W
{
A5 z* \& W9 ~: e" M .active_low = 0,! s0 G! B' G3 l/ S' V, y
.gpio = DA850_USER_LED0,. r! d( k) U. v$ K
.name = "user_led0",9 H! l+ R, T; d; V6 j
.default_trigger = "default-on",
. c! u6 Z' l+ i, P/ r X },- e- w; h, s1 A. i* s: [
{
4 l; Y( K' q9 v/ v/ h+ ^ .active_low = 0," o: a0 A$ D2 ~! {# D& k+ s
.gpio = DA850_USER_LED1,
6 _0 k' h$ l6 H. O! p .name = "user_led1",
: x: C$ R5 D( W8 N8 ]1 B% T .default_trigger = "default-on",3 m' f$ h" C2 Q1 }+ L5 N3 c' m- A
},
6 @ \1 T- Y: a' Z. z) H0 n {5 P7 i" L5 ~; M7 U2 A. X% M
.active_low = 0,
- ?$ D# g) L9 z0 i( Q4 \% W .gpio = DA850_USER_LED2, k6 S K6 {5 ^
.name = "user_led2",
" r6 q1 U1 P3 [- z- d. q/ z( S .default_trigger = "default-on",
- r2 {- Q s( F+ A+ V/ N% E }, ?! y3 h. ~5 D9 N; d+ i3 z( {* o2 M
{
3 U: ]( v8 l& K' |% e Y' q .active_low = 0,
0 N+ J7 |) B5 M# U4 t. _ P .gpio = DA850_USER_LED3,% z) {' Q5 E+ D, K0 L% b) `9 z% K9 G3 f
.name = "user_led3",
z. F2 s! K9 ~. ]* ]9 v/ j0 u .default_trigger = "default-on",
1 c& B! h1 @$ Z' o( i },+ e: e- b9 d6 Y+ U- ]+ J6 z8 _+ g
};/ r1 v( J1 P c3 h; s
/ d0 S5 q7 b/ ?0 L. pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 i6 K( m1 g& s, ? .leds = da850_evm_tl_leds,9 R8 `- ]( y/ H4 N: A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ U3 E5 S% U$ @
};, L& ? g- P [
0 _- G7 x% \, B, ?( ` U7 I; q5 a
static void led_dev_release(struct device *dev)8 E! X. x3 ~# S! n0 ^& P8 F$ w8 I$ ]
{0 w ~* V; P) l- x. ^, ]
};/ \! H2 Q, }2 k6 m/ e. [9 B. h# l
% I$ L: p2 @$ r, t! p2 Q& }" a% Kstatic struct platform_device da850_evm_tl_leds_device = {% O# k, k1 \) I
.name = "leds-gpio",$ x! F2 w' A% W% Q: V
.id = 1,
( ^+ Y+ g& m5 [! J .dev = {
" C- H' j* b, O& C4 B$ O; J .platform_data = &da850_evm_tl_leds_pdata,
. Q, L; z2 [- `( z5 `) D0 N .release = led_dev_release,& w" h' e0 i6 x; S
}
) W- b0 d$ o3 L};
5 a1 r* M$ l( G" U
: h9 a% {' q0 }7 l) }8 v3 ostatic int __init led_platform_init(void)
6 a9 s9 M7 Y- b! W! P- V) F) w{
, d6 y! R: M# J8 i, t& S int ret;
% Q. q T7 H6 X+ N7 n3 ?4 \, r% p#if 0
5 I7 D, |: |' E: y' i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 I, T5 `$ c @. e3 Q' @3 | if (ret)
2 L9 l- I4 [% c; z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ Z' Q0 N# N1 q$ `
"%d\n", ret);
]# y* g4 a" V7 k* A$ P( x#endif& o# x! L* p4 _
ret = platform_device_register(&da850_evm_tl_leds_device);
3 V7 j2 G8 Y) q9 I' U1 w, Q5 b" G if (ret)- C: J) Q# M8 C- R3 e5 M
pr_warning("Could not register som GPIO expander LEDS");9 P& @$ }$ H) V, ]& ~! V' r
else+ m4 H: o* C4 }
printk(KERN_INFO "LED register sucessful!\n");, d, ^; P1 ]- j
# E6 H9 J4 Y% i7 B6 K1 d. V, y: p
return ret;
) ^0 }% m4 G4 T. [}
4 c7 `4 ]2 a1 P. o% X/ T+ ]' y1 i. T3 n% Y
static void __exit led_platform_exit(void)
$ [! @5 S2 g ~" C" M6 B4 E{
4 G/ U5 M A: a7 W6 {! T' `! d3 y platform_device_unregister(&da850_evm_tl_leds_device);! g4 ~7 Q7 y* ^0 b+ E- F
! S1 U9 p+ Z8 Z% R: J
printk(KERN_INFO "LED unregister!\n");
! J0 ?2 ]; o- v" B, l. r4 ?) U1 J}
- h e% q o' ~3 R+ j* i" _) G5 B7 g
module_init(led_platform_init);
! P7 Q7 ?6 V$ b/ a3 {8 J9 h1 O/ d O4 Mmodule_exit(led_platform_exit);. S7 t0 F. ]1 z
p t$ z( m% P: a! iMODULE_DESCRIPTION("Led platform driver");
( v( S& e' L& a; z {MODULE_AUTHOR("Tronlong");& z: \$ P, P0 q; Z: _
MODULE_LICENSE("GPL");
m w, _1 a4 b0 _" z
5 t$ C1 O5 K# d% ? |
|