|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- n* X0 _6 \& a
#include <linux/init.h>
0 @# G S6 O9 H' [5 i4 p$ y/ l#include <linux/module.h>
) ~) J/ x8 E$ ?' q- h% N' c#include <linux/kernel.h>. j, p% t) C. y1 _* m4 e
#include <linux/types.h>
5 Y4 R0 M8 Q# j5 \#include <linux/gpio.h>8 n5 b, F, c4 Y$ K
#include <linux/leds.h>
- M% r& n( C/ X! s#include <linux/platform_device.h>
# t- j# _1 K0 Y. g4 N: a O3 q1 k3 P; d6 e
#include <asm/mach-types.h>
& m0 b9 W2 Z5 T/ C#include <asm/mach/arch.h>
5 W' {: J' k; ~' {6 y4 B#include <mach/da8xx.h>" C& p) x- j8 }' }$ q
#include <mach/mux.h>+ ]* Y9 o2 M2 t( A" X
; W) v2 d: D! _ R& @9 H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) J) s8 {, \% {$ I8 L! y/ q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 P' v2 u" t" B2 T G3 ~7 \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% k1 N K! O9 x, E# e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) R1 v& q# R# V* {6 d# D
; D% ~0 G" m, h
/* assign the tl som board LED-GPIOs*/
4 w6 m, q* K3 mstatic const short da850_evm_tl_user_led_pins[] = {' b L4 s5 t- M
/* These pins are definition at <mach/mux.h> file */% u) Q1 N0 a7 T1 d0 v8 K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
`% S1 _. V3 l' y& I9 D/ j -1
" Y) C1 T9 a& p0 V9 ]};) {+ B$ t3 U: y7 j$ \0 P
! f! y1 _; O6 V3 X
static struct gpio_led da850_evm_tl_leds[] = {- H9 x/ T2 M' O
{0 b; H+ F' D. B
.active_low = 0,
j7 e9 p- q$ z7 q: j .gpio = DA850_USER_LED0,! ]2 a6 R/ h. A0 ^- ~
.name = "user_led0",
7 c% d1 k1 Q( b6 f) q1 A- a [4 Y .default_trigger = "default-on",6 ~9 M# c' D0 S& M7 C+ M3 r$ S# [: ]
},
2 J3 `8 ~! ?. y5 `; g {
+ N! r, I, I2 N0 p$ i .active_low = 0,
w$ c& t7 p5 i: a .gpio = DA850_USER_LED1,
$ j) \2 n r- K .name = "user_led1",$ } {% t8 Q0 e* o( L3 M
.default_trigger = "default-on",4 S3 ~2 C# Q9 U7 v }0 ?
},+ u; S6 K' W! y
{$ ?" }5 f& g8 D9 ]! m1 P! y
.active_low = 0,
) B) w5 K% B9 S" F .gpio = DA850_USER_LED2,. T: S5 C* [% y
.name = "user_led2",
. R I* K4 Q s+ {; |2 a9 ] .default_trigger = "default-on",
" }5 `0 `! b5 I% k: q5 a3 v" F },7 ^# Z: N. ]( a; {7 A6 B
{
3 f) v9 e; O# D7 P$ n- F8 k9 C' [ .active_low = 0,
; Y; h$ L( H1 S) X: s: I .gpio = DA850_USER_LED3,+ H1 g/ S8 B6 [+ H- x2 n) B* P. k
.name = "user_led3",
# z. F/ F( C' M .default_trigger = "default-on",: S1 l$ G3 j5 A& b
},5 g9 ]* P* J, x7 S) r
};( r; m/ P4 e& x: R1 j
" l1 O+ I/ Q8 i# O0 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 u C/ M# z' s& g7 e5 p5 f4 T .leds = da850_evm_tl_leds,8 }2 v# X7 { H$ ^0 p. U) T. H5 \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ ^: L' ^) {% J
};2 l$ }. q+ k5 Y) a
" l8 C. b# _7 z9 }static void led_dev_release(struct device *dev)+ [, L: P8 J, n& N& {- M% Q& A
{( ?. \; u% N0 }, v" J- D
};
( m6 ], G9 n' P5 F/ t
6 p4 | `. O1 ?/ L5 {2 T4 Qstatic struct platform_device da850_evm_tl_leds_device = { X1 J9 ^, W9 w. l; C9 t- `0 x. R1 R0 _
.name = "leds-gpio",5 Z. y4 B9 j' D# {( M6 q
.id = 1,, Y0 J) j$ I+ Q. X* J# L2 d
.dev = {" V; X8 [0 t) i7 y: u
.platform_data = &da850_evm_tl_leds_pdata,8 i% o5 m5 R1 d4 L' {
.release = led_dev_release,4 ]! H# Z3 Q& ]8 O% Z4 I
}
# W- i/ X" Z- K W9 J};) a6 E+ [1 c! C" p9 u: R# R5 Q$ }
D2 T* w6 b pstatic int __init led_platform_init(void)
* q# N9 e$ T K{3 J N2 a. P p- O! ^
int ret;
/ ?8 f) }; a) r6 y3 Z, o#if 0
4 X8 @+ V' U& R- V4 ?2 c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- p7 e) `0 s5 y0 ?: u/ s
if (ret)
7 D( x; B6 Q+ v+ [# } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( a+ P7 U3 w$ `1 U1 v* X) j
"%d\n", ret);+ u" q5 O& P. r) K- {
#endif
6 f" ^' O* w6 D, K( | ret = platform_device_register(&da850_evm_tl_leds_device);
6 K/ {0 h2 W' f3 s8 C# B' r if (ret)
2 q: M7 ^2 w2 V$ ] pr_warning("Could not register som GPIO expander LEDS");9 M0 i; R: Y% D
else
% \8 D. w" N: {. j/ w printk(KERN_INFO "LED register sucessful!\n");: g6 F) M ]# O/ b% |
& Z6 d: y6 @7 K/ B( x
return ret;9 H0 t1 F! L7 M! t
}
- ?3 f3 L3 d! X! ^2 a" X9 L6 w+ g1 Z# a1 h% W$ a
static void __exit led_platform_exit(void)
0 q8 C6 V, q7 \, W7 @3 N9 d{" Q5 M, E( |& K" Q2 S! [, v2 o
platform_device_unregister(&da850_evm_tl_leds_device);; e# m; E/ q. L( X% K" n9 ~
; Y) a5 z+ E; W' o; B% q' v& C1 v
printk(KERN_INFO "LED unregister!\n");' F* i3 z4 S' Q
}9 Y# i! {4 z" O
7 g. V6 Q7 X4 v* z$ b' e
module_init(led_platform_init);
) h( t8 \7 q$ V7 o" Q' Kmodule_exit(led_platform_exit);
3 r6 m* e7 o0 c% K6 s
: A) u/ \! c+ Y1 H+ [+ RMODULE_DESCRIPTION("Led platform driver");
0 @1 W* }2 o( @9 z0 q" E5 DMODULE_AUTHOR("Tronlong");. G/ ~4 }/ T; `5 \: W8 n/ I
MODULE_LICENSE("GPL");1 c" J# c/ w' ^% Y/ q
. y- K# h6 x6 f) ~3 }8 M |
|