|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% i: m! h: ?7 C" k* N
#include <linux/init.h>
* T# l& ^% S0 v1 U1 ^2 J3 ~! P#include <linux/module.h>0 Z2 h$ w0 C& }$ C) W
#include <linux/kernel.h>7 t9 G- F4 \( o: J3 Q: J. W7 t! j
#include <linux/types.h>
/ [+ X" ]! ~6 d$ q#include <linux/gpio.h>
1 c# T' W3 S; B: S7 D* m6 s#include <linux/leds.h>
# t# f0 W( ?0 Y9 `) M: M4 `5 x#include <linux/platform_device.h>
; M/ u R2 M0 P- v% @7 k% l, X+ T6 L) k0 e) d& S; f
#include <asm/mach-types.h>8 ]9 t, f) m% G# e% t
#include <asm/mach/arch.h>
( Y* y' s8 T; E8 _#include <mach/da8xx.h>
; e9 b2 P. B1 E) E#include <mach/mux.h>" z8 e A! f r
/ n7 u. ^- R+ l3 ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ v& l4 j, R( Z, e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( E5 R& I5 E. x. e1 {9 M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 [1 g5 ^+ z0 X$ F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ Z( C) j; n4 k: e# n' Q
1 X; Y5 o: l9 K" l, s* Q
/* assign the tl som board LED-GPIOs*/
8 x4 ^$ B' s( ]- B9 nstatic const short da850_evm_tl_user_led_pins[] = {
2 j% U7 H1 s$ E3 m0 | /* These pins are definition at <mach/mux.h> file */
/ Q4 N9 q7 X" p5 F9 T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 P! \* F n7 I0 e# D* | -1$ ^% T6 n3 P& F% J, v
};
9 s; }. V7 L1 ], l- g0 K7 H- V+ w5 z, o) @0 V
static struct gpio_led da850_evm_tl_leds[] = {; A7 m& g( X3 B* P8 a
{
! ~5 b5 g; f( G8 G' p3 J .active_low = 0, Y+ ?; X: V6 n
.gpio = DA850_USER_LED0,8 e% Y, t& Q8 ^+ R
.name = "user_led0",
1 M( [* T+ a( k7 x4 q$ J .default_trigger = "default-on",
8 {* G; j% E( u7 \; p O },- j- N- ]; V1 O, _1 O; h
{
4 J- c& \) f4 D9 }1 @+ w, h .active_low = 0,
3 |2 f6 r- t9 e. y1 w. y& B9 Q# J .gpio = DA850_USER_LED1,; Z; w, G" U# {1 f5 j- P
.name = "user_led1",
; [3 j1 ?& F0 s! l .default_trigger = "default-on",
5 V7 e4 S$ \: ]: L+ P* ^ },
. g, w9 M1 z0 V' T% u, z {
, x1 P% S+ V+ P, |& I6 ]5 }6 m .active_low = 0,0 R; S8 h7 N+ v- J9 r' i% n
.gpio = DA850_USER_LED2,) g% \3 N' Z4 M0 Q
.name = "user_led2",
1 s2 I$ ^; n9 {! y1 e5 T$ T .default_trigger = "default-on",. i |8 L7 M$ n+ P
},- A! v5 t/ `/ U
{( t; `5 R% Q0 _ r( B" O5 r
.active_low = 0,
0 l) `9 B9 p4 x .gpio = DA850_USER_LED3,
# O7 u0 d; v# Y0 _# R .name = "user_led3",: O, K* W: t- p# ?
.default_trigger = "default-on",
2 I7 g3 ?( C1 o1 I4 ?: l },
! C/ r( L# Y. K z' X" l};
& q, a8 a" i4 _$ f) t2 R* P O3 ~2 N& Z* ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 P. \6 |1 Y s$ v+ R .leds = da850_evm_tl_leds,) b3 b; M# x$ y" |0 n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 U% F( g$ _* \6 Q};' z R* y$ \5 }( z: ~3 D8 l
" [$ g% D$ s, X
static void led_dev_release(struct device *dev)% L8 Q. p+ z; _
{, d8 a) G& C6 z/ R& U8 E y
};* e4 |2 Q$ Z; o
' @) Y# R Z! {$ U! M
static struct platform_device da850_evm_tl_leds_device = {+ ]+ c& } J; D+ ~. V
.name = "leds-gpio",9 N1 H3 ~! V' b* K# g
.id = 1,6 n( I0 W; V* y. v( s U% \+ {
.dev = {
: O7 R8 d" k2 g9 n .platform_data = &da850_evm_tl_leds_pdata,
7 Y3 E- c2 j! ^. b( } .release = led_dev_release,* I0 ~, Y6 j$ k8 ?
}
( X/ r/ g6 m ~/ M};7 K+ `$ I& \: J& L ~
; c. G4 i# X- I) s( f$ L+ L
static int __init led_platform_init(void)
6 o5 Q* A* W9 c$ B/ m! A2 h( J" ^/ j{$ S% q3 R0 h* F4 K \: f
int ret;, z: S3 Q1 [8 t' C, H/ q3 S
#if 0* h# u4 A Q: o: d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 B' U: |6 V! p8 ~0 m3 D! C6 A if (ret)6 U7 g/ W R, _( p/ n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% r, o! f4 E# A: R3 [3 Y' A' N
"%d\n", ret);5 ]- {3 t. Z2 |" q
#endif, x. s! @7 Y5 A. {# p
ret = platform_device_register(&da850_evm_tl_leds_device);
) v9 h2 A5 e2 o" b% r }7 q9 e if (ret)
5 X. t3 R2 D1 E% U0 ~ e pr_warning("Could not register som GPIO expander LEDS");
1 x# }& S0 Y6 l8 n0 n ? else9 O& `) l* S8 B! M' W8 q
printk(KERN_INFO "LED register sucessful!\n");
$ U' X x2 I% F
; E$ i, E6 @+ i+ \- O$ _3 O return ret;9 n7 p/ q6 c! V. \
}, j9 T- i4 k2 F
! y3 C, _, ?! y$ C, M1 d+ M8 @
static void __exit led_platform_exit(void)
- r4 H. v i# x) B9 a{
5 ~% D# l& g4 ~ platform_device_unregister(&da850_evm_tl_leds_device);
& g$ ~) J% D8 Q0 s; Q% U) M3 j- Z6 |2 J% P$ G: `% c/ g, O" A9 |! e
printk(KERN_INFO "LED unregister!\n");
) m% F6 S8 ~9 `: U7 l}; H S) L z3 Z! R
9 r% T* Y+ J6 H, z, [module_init(led_platform_init);# ?$ ~2 \8 _0 S6 ~
module_exit(led_platform_exit);" O. j7 P1 S; p; B( n
4 B9 n! {* w- S7 G/ K
MODULE_DESCRIPTION("Led platform driver");
1 L5 `6 o+ j, ~. c& rMODULE_AUTHOR("Tronlong"); a6 s1 s# Q2 F2 T/ {6 }
MODULE_LICENSE("GPL");3 x+ o6 O& {8 _' h( R- s+ I/ S6 _
. V$ [7 [ u' w N3 s. v/ T! z
|
|