|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) E' E6 ~( f) T5 `5 M( s1 o9 M6 |" m
#include <linux/init.h>
. c' y" t4 [" j( x' O4 ^4 q5 L#include <linux/module.h>
( u1 U0 f: Q7 `3 m#include <linux/kernel.h>
: M$ w$ e8 _: j# P; Z#include <linux/types.h>
; |5 ]& l6 h. g# b$ u#include <linux/gpio.h>2 ^$ D: [& t. Y' a$ z9 u" _& Y
#include <linux/leds.h>
0 m1 v# \8 Y; q. D4 m4 Q- s#include <linux/platform_device.h>
$ [" N! {/ t2 r' s+ l6 ?
1 m& G$ d/ J$ g, S# ~#include <asm/mach-types.h>$ h( t* j2 ?( E# C. t: ^
#include <asm/mach/arch.h>
! k. [$ ]5 r- T/ Q: U#include <mach/da8xx.h>3 k7 f& [0 w6 @& C; F+ [
#include <mach/mux.h>
( `+ N' [# k6 u9 F9 p# P. n; M
+ e- |2 Q3 w. {1 }0 l& h8 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ U, n4 q2 H$ H6 F) c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 A# o4 a% ~/ k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) U' L. M" O$ ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 {" B j1 s/ v( }5 U' @6 T$ b8 r
/* assign the tl som board LED-GPIOs*/
, H* l3 F5 l+ ~4 ^- O# Dstatic const short da850_evm_tl_user_led_pins[] = {
4 K, W- q! X$ c# ^$ @- ?% E2 h /* These pins are definition at <mach/mux.h> file */7 I; m8 g+ c6 w2 Z5 g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ ?4 D4 j* A& p* y1 Z& I3 L
-1$ S: A. F& Z! o6 @0 {+ {
};
9 J% _ x8 X; F6 ?/ a4 b A; L% }, ]9 U( [# G! d
static struct gpio_led da850_evm_tl_leds[] = {
( U3 `5 K" v n2 N {
2 L5 S" r( @) L# B7 A3 Z .active_low = 0,9 j+ L1 U: K/ a
.gpio = DA850_USER_LED0,
" q5 V! \& l _( B b .name = "user_led0",
4 P, n$ m5 |/ s$ I j .default_trigger = "default-on",. l" R& t4 @& H$ [
},
6 `$ v1 {) `; o7 [& x {$ Y4 ^4 m* w9 c/ F
.active_low = 0,+ ]) t- k0 D+ F8 ]
.gpio = DA850_USER_LED1,' W: c3 d! w/ L/ C
.name = "user_led1",
2 c8 l6 B* t: C U4 n .default_trigger = "default-on",- I8 X+ W7 Q5 c4 g9 H
},. f. J9 F# Q. _8 o
{) [9 {# P/ K$ N' }$ k* s. i
.active_low = 0,' z7 z# A6 }' O0 M3 C, ~, z& `
.gpio = DA850_USER_LED2,
$ p1 p/ B9 r9 n; v% } .name = "user_led2",
; ^2 c9 x7 S. A) `7 a .default_trigger = "default-on",
* {+ O, p" b9 G( C },
$ P. r. J* V- E; t: m {# T3 P, p! d2 H- G4 r$ r
.active_low = 0,
/ f" |" h9 B5 l2 U: y3 H0 R) q .gpio = DA850_USER_LED3,6 V& ~/ D' s3 z
.name = "user_led3",# T0 Y+ U, c: C3 b- ?
.default_trigger = "default-on",1 k3 X+ s6 A3 `& P$ K- u
},
$ y G7 L, X- F! M, J9 y};: e! L- F0 \* \) R; X
) r- Q; p' s, w+ V( |0 y/ s( d9 g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ } `- M5 ?8 o! L7 ~6 [3 ] .leds = da850_evm_tl_leds,
$ D" }$ O' W9 \9 n. E! P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" u* c9 t5 M1 m+ v& X};
+ J) X! v( b. D! e' @- Z( \
1 R6 U6 F+ ^' ~' J2 L4 D+ Rstatic void led_dev_release(struct device *dev)
. D/ w1 d6 ?& M{
; p1 H: h6 e, C$ J( L3 s4 N" J; ]};2 f; [8 ~, x! `' [( ]$ s, W
8 y( J; c( f. E! P7 jstatic struct platform_device da850_evm_tl_leds_device = {( [! o6 j+ j+ F5 w0 i; P/ U/ ?6 b
.name = "leds-gpio",; H# k" \- J! }' D5 C' Q2 N
.id = 1,
, C n! L+ E; }4 E# X/ O( j! t .dev = { I3 G4 t& P( q& y8 F* D: K4 f9 Q! x
.platform_data = &da850_evm_tl_leds_pdata,: \5 C7 ]& k0 [- n
.release = led_dev_release,
: M5 i9 X E- }7 n! ], H7 c }
$ b3 H5 ~! {# q9 E! i};
7 |1 e) u) |7 K# K* Z) Q, S2 a' z- B% F5 a% E' T
static int __init led_platform_init(void)
. y3 s% y) B. A7 Z' q8 d{1 @: p- I: V9 N4 B3 X1 X6 U
int ret;
/ d6 S+ r2 e7 K) ^#if 08 z R) v6 z, B- _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. o3 R( V+ G1 K+ u: W- F
if (ret)
& @+ \* C- d3 N S. K6 B. [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 X" Y/ b2 v# K! j- \' v "%d\n", ret);
1 R+ T: o$ k1 n, e5 Q+ w; [#endif
3 W9 ~' }) y6 s, m; d" h- T5 q ret = platform_device_register(&da850_evm_tl_leds_device);: @/ {" f5 I% M8 B, j
if (ret)
1 d& a8 _1 I# L& l( w3 |9 X4 W pr_warning("Could not register som GPIO expander LEDS");) o$ R- _! B' @0 I7 E' o6 M
else* d/ k& C/ H N
printk(KERN_INFO "LED register sucessful!\n");7 B- {: c1 \' D" w+ Z! N4 ?
/ J& p; l, t) ~9 a7 o2 c; M4 T
return ret;
4 U$ A3 q( Z& a' Q% I}/ a" n8 W( P* ?$ S
1 U, Q0 ~6 S- Y, m
static void __exit led_platform_exit(void)
: F$ j2 Z% g. }$ [7 X4 j5 A{3 ]. E u* h5 o, b
platform_device_unregister(&da850_evm_tl_leds_device);
( y; y. ~, M" p4 u/ g) E7 D" [' U5 K. @, ~8 n
printk(KERN_INFO "LED unregister!\n");5 j5 U' h0 h& g$ h5 I" `
}
$ s; n1 \ O& n/ a2 L1 _8 E3 O! ~( ~7 J8 g8 C Y4 T% P% t
module_init(led_platform_init);
" {8 f. E1 @, t+ O+ D% j% qmodule_exit(led_platform_exit);% H/ L9 c4 f: K6 p
( O G& N/ J% y- X5 g5 ~2 j' PMODULE_DESCRIPTION("Led platform driver");
0 ^/ k& k3 s3 Z! z4 ZMODULE_AUTHOR("Tronlong");
, o! S. e9 ?( ~8 R C8 f1 P5 TMODULE_LICENSE("GPL");
: u1 m- Q7 y2 J
$ ]8 m% }8 g& _8 G n) A6 A0 _- O |
|