|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 t* ` ]' S5 @. c* k
#include <linux/init.h>3 L1 R" f# c* N: x8 M) L, m2 B5 Y
#include <linux/module.h>
2 t$ r. A$ C j7 n$ D#include <linux/kernel.h>
4 r1 e4 e& e. R#include <linux/types.h>
; a& \# |9 r; ~( G#include <linux/gpio.h>
5 V0 p. n% s. F#include <linux/leds.h> N. W& u0 m8 t* P3 {
#include <linux/platform_device.h>
# b7 J) s1 g" h% S/ C7 g' r& N
1 r$ J3 R& ]2 X0 v. j#include <asm/mach-types.h>
, b& B" y9 \6 u7 `#include <asm/mach/arch.h>
5 j4 n! @) j& {4 {1 F$ L#include <mach/da8xx.h>, J6 J$ I. \/ s3 |* @; k
#include <mach/mux.h>" d& P, V1 M6 @- c, z/ s! J
- l# ~5 {' v& [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 ]* r5 ]0 u7 ?. H: x2 q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" a; P/ y4 z [0 r; H2 b! L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 p& ]! o3 ?4 u5 s' h: w. X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ N' U3 ? V/ n: n' @
; |! N; k2 c. S/* assign the tl som board LED-GPIOs*/
! v) T; n! q5 A1 Estatic const short da850_evm_tl_user_led_pins[] = {' K$ k+ t9 ^) e/ R0 Z2 m- t
/* These pins are definition at <mach/mux.h> file */
8 B: R" b, n6 ]) M u8 J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 H" F9 E3 |/ s
-1) u( F5 _; r S1 z3 |
};
/ M R- ^4 D/ w7 Y7 z4 U1 x; H7 X& b. \* i: ^
static struct gpio_led da850_evm_tl_leds[] = {! a3 c7 |6 G7 h& F8 Y# X4 Y6 k
{
' J( v, S# R5 w/ J3 Z4 [2 N .active_low = 0,3 g. K5 O; R7 R- G" l- G" T7 e
.gpio = DA850_USER_LED0,
8 U) g! U4 ]& q ?& D# d% N .name = "user_led0",- q# m r0 q7 g# @! R9 G! o
.default_trigger = "default-on",
3 V/ \& K, {% B },- @; S. d- j" Q" [+ e- T& C3 c5 O, E) c
{
: D' W' L+ R2 A, j" z .active_low = 0,
1 [$ W5 y& S4 n/ L* i# E .gpio = DA850_USER_LED1,7 z3 F: l @( [8 B! t
.name = "user_led1",: m* Z4 V% X, Q# J
.default_trigger = "default-on",
1 F: |- C, U$ O5 C0 Q },( c2 I; ^8 u( X6 s! H6 n: E9 Y8 K
{
" a* U: k7 n7 @, J .active_low = 0,9 _. }) @ _/ g+ y$ k3 W1 C' N% [
.gpio = DA850_USER_LED2,: `" B) p3 T9 T! j6 ~" P& X- J
.name = "user_led2",* k) c5 V Y1 m, L
.default_trigger = "default-on",
$ U" |2 i5 E8 r6 }3 M },
8 _* I5 |* c4 R* i {
6 W$ |4 A5 z2 V- n' R2 h .active_low = 0,
3 s/ ?1 l" G. y3 A; b8 E- L! H% _4 c .gpio = DA850_USER_LED3,# S( {2 U# z4 x: b: T9 o& s2 }
.name = "user_led3",, }. {% a6 E0 \
.default_trigger = "default-on",
- p4 o! h2 f" o, n1 C% X },6 d# s. b+ R8 s: |% w( F
};
6 M3 B. q5 l4 Z1 o( J9 ^0 H6 ^
+ q* A! Q0 d# nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& \7 ]: q& W K. m1 {! D5 u .leds = da850_evm_tl_leds,( v( u# B# c' g" U6 |
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 R8 _# E+ ]) Q3 I% Y( w};, g. d5 D" l- F3 U }5 ]
1 x$ V* a5 T" K; q1 O& b+ w
static void led_dev_release(struct device *dev)' \6 s, W. h/ Y( G
{
7 E K5 O$ n8 D) y/ {1 t: ^$ h};
- E+ I$ s( R% r8 D4 x6 p) t+ e# \: ]8 p# T" v% S) M, G3 g& N
static struct platform_device da850_evm_tl_leds_device = {
6 d" o5 ?! y! @6 A! |% ] .name = "leds-gpio",5 J+ ~8 x4 R1 w( h1 {+ _0 P
.id = 1,
& c0 N. R" z9 q# m .dev = {# c0 a* L. L6 h) |) `6 E+ I
.platform_data = &da850_evm_tl_leds_pdata,
3 c Q+ p- O1 v& j p& b; j2 [ .release = led_dev_release," e5 m/ H% T- i# g0 Y7 n
}
# a! y, A+ ^! a+ v5 V9 M};
) P2 X, }6 I- f7 d) v3 i
' e; R/ j6 S' Z* s7 I: L6 Estatic int __init led_platform_init(void)' S0 J! S, N8 s- E; {8 q
{1 ]+ n9 u% j+ m; s. G9 |$ _
int ret;
+ }0 Q& ?3 {: m5 T; H/ v#if 0
7 K: E: U; v" x3 W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 {7 D) f0 _9 v; w
if (ret)# b: |; k* K8 q: @* V' c G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& G. d- u& u7 Y% V: g4 w "%d\n", ret);/ l. {7 M& H7 ^! f8 o- u! J# P
#endif
. d, |9 b) L, e9 e% A( q5 A1 E( G ret = platform_device_register(&da850_evm_tl_leds_device);
* g2 u( y+ q, c if (ret); u) E7 j c4 j3 ]
pr_warning("Could not register som GPIO expander LEDS");$ G: d9 M' H% F6 u
else
' |4 ^' [( a9 @* _$ I printk(KERN_INFO "LED register sucessful!\n");
3 f" }+ F0 }2 p; o6 y
0 ?( V4 R" a2 I" L4 q7 z, l* d return ret;5 Y8 s" s; z3 a
}
) y+ P/ `8 G* l0 K6 c# B' r' m9 G: c$ d3 V) [5 s4 [1 _, x
static void __exit led_platform_exit(void)
* p, O- Y& k9 `{
; |$ a" G& `0 d+ o; F1 A1 J v platform_device_unregister(&da850_evm_tl_leds_device);) `2 y2 | p# v8 O' y6 J8 x
* u0 F" ~& m& P3 x" E5 W; C0 [) ~
printk(KERN_INFO "LED unregister!\n");
# |# d. p: d3 Y# S- j( O- [, i* `* M}2 D) `/ d, P% H( t5 l
* ?; x# } q% @3 O6 p6 X
module_init(led_platform_init);
1 G. R1 h% x' Rmodule_exit(led_platform_exit);
. X$ m, I: D( D6 _, [
. }0 L) X4 m( S& j1 fMODULE_DESCRIPTION("Led platform driver");
/ z) a- x; ~. L1 y% F8 IMODULE_AUTHOR("Tronlong");
% K4 z" S- @. N$ L9 G9 r; h2 T: eMODULE_LICENSE("GPL");
# [; a' N3 O7 }1 A
v! O9 d# C) `/ p& u, s |
|