|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 S% x3 Z0 z1 Y( N. g4 p+ C! W#include <linux/init.h>
7 C% L! O' u- t S" b#include <linux/module.h>
0 o' \2 N' @* K4 N Y I( g#include <linux/kernel.h>
1 A" `. Y) O+ E: ^#include <linux/types.h>1 k- c2 p) ]$ s# y
#include <linux/gpio.h>! J* V5 F% |& m' K9 y" \9 `# ] g
#include <linux/leds.h>
4 E5 J: I8 I3 j) g$ W#include <linux/platform_device.h>
% e. {0 _, l8 L% F
2 b z; l' N* _- N1 J#include <asm/mach-types.h>. j3 I/ G$ I+ O& P
#include <asm/mach/arch.h>8 D( j5 v* V6 `6 R2 Z% Y6 f
#include <mach/da8xx.h>- x- p. m$ [) F3 y$ n9 o. p
#include <mach/mux.h>% R. [0 c! z: K1 b
7 V, |7 G2 z( S- `, {8 C, b1 M" R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), s! b9 B( ?* _2 \$ Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). r/ S+ X: v3 F# Q' o$ S4 p/ V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ b6 _" A7 S3 R, N- @+ A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, @+ U+ O3 p" b0 v9 U9 t$ N
+ E* _, y0 M6 I! R! o3 A% ~# G" `/* assign the tl som board LED-GPIOs*/
$ E/ M( _' g/ K' q9 @static const short da850_evm_tl_user_led_pins[] = {
7 U7 F, G. M5 M( B /* These pins are definition at <mach/mux.h> file */& G2 X+ }# w1 N+ `2 e1 ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 T, ^" u' ]% x2 g, H I
-1
& |% V1 h3 ?% }$ ~3 w1 X) G};
3 G4 w) Z5 Q; o, d# [$ a3 b! r% G8 K7 Y7 j. ~
static struct gpio_led da850_evm_tl_leds[] = {
5 R$ L% U3 m6 G# u: C' s; R {' o- S% |# L9 o1 w
.active_low = 0,
* L) I2 H- j8 K0 x+ Q6 n' V# N' {' I A .gpio = DA850_USER_LED0, i$ s% B/ u, z4 j
.name = "user_led0",
8 Y' i3 y3 O3 b" e' x, S" c: t .default_trigger = "default-on",
/ v) A; O0 g [5 T },
1 I6 `: l9 Y7 G; Y! ?7 P" u {5 Z7 a. i1 }. n" [! P; c9 X* G
.active_low = 0,6 i9 H2 E8 a9 ?4 z9 X
.gpio = DA850_USER_LED1,8 ~ I! b, V* N' k4 @
.name = "user_led1",
* q- I2 \9 v5 V, R) h) _ .default_trigger = "default-on",: u' H& z7 N. a, H
},
6 T$ p. g8 X5 \7 {. ~4 h {* p$ n3 A1 ]+ p+ i9 e5 I
.active_low = 0,
/ x4 l- [% N. P/ C0 `, D& ^$ p8 x .gpio = DA850_USER_LED2,
8 W2 h: g' f: K+ J9 x- x$ `" k/ V' @* ` .name = "user_led2",
* w3 @3 S" [+ H .default_trigger = "default-on"," P5 Q7 w+ O& J. v. v8 q) b
},% d" c) q y+ \$ S! t3 F' e
{
" Y+ ^: @( v0 a) A; T .active_low = 0,2 s. l; u2 u+ ~* d% Y
.gpio = DA850_USER_LED3,4 `( u8 b. [% L8 t5 z
.name = "user_led3",; A; L7 h& p/ y. i- {6 S, A- j
.default_trigger = "default-on",
* y9 O9 z& M* f; `' H9 c; }+ a4 t) O },
( g b8 w' I$ A" T};
! O0 p5 } o9 g- W. _3 j2 e& A% V4 K- t/ x; k3 r5 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 r- S* r& F9 q9 G! Q0 l* U* l" n+ o+ y
.leds = da850_evm_tl_leds,
: f( |! w4 |1 S o" g9 v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ a0 v* ~ e* I% O' N$ ], A
};% y, p) \- s7 X. S
/ I' E% e3 e8 C. ~
static void led_dev_release(struct device *dev)
$ m' b) H& L8 X) t0 d/ w& j{7 V/ ~# p' x7 `% j# k1 k N
};/ D4 X% H7 c' g$ a+ v# r
, R) U% a K1 U& @, N
static struct platform_device da850_evm_tl_leds_device = {( H; q3 \- L- E* M- X) K- `
.name = "leds-gpio",
- W, L9 `* T V+ I- O1 I/ P .id = 1," `, Q8 f# q" d5 a5 x! M1 f% D
.dev = {4 m5 ~6 ^/ n4 F$ `
.platform_data = &da850_evm_tl_leds_pdata,, } y1 S1 D% {. l( |3 P, t" A
.release = led_dev_release,& P! T; O+ x! l2 q6 z+ `' G! D1 e+ I
}6 j7 C1 E; O: R0 T: c' l) R
};% W) Y( i8 I1 Y: C- h% _! ^. v
/ y, `7 B. V5 n# F% w1 n
static int __init led_platform_init(void)4 e1 N8 N/ m, Z% ?8 U- V
{- k7 Z2 g% j/ b! `0 s+ l* Z
int ret;2 j0 _( f5 F1 h$ \' l/ H
#if 0 L7 I1 N6 K3 \! T5 D+ W; J6 I9 V$ Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% }9 V1 f/ j k' ^, u. x+ p
if (ret)/ w- L1 E5 k# g' K0 Z1 S1 V% X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 w7 F# V: Y- i/ {' E. {) w
"%d\n", ret);* ?, }( l J# Q# f$ t
#endif+ G( A* H C* y: X1 H
ret = platform_device_register(&da850_evm_tl_leds_device);
' W* b+ r4 m0 @ if (ret)
3 j( d$ G; k6 z pr_warning("Could not register som GPIO expander LEDS");
6 l, w& P$ a+ O$ i& R U% A" C0 j ] else9 p8 P( l. |$ D) J* r
printk(KERN_INFO "LED register sucessful!\n");
, [5 z# n N5 i1 l. `" p7 d: b
& G7 w2 C1 r& q4 K; x3 G# N return ret;0 P5 f7 Y2 W! M, @" l y
}
; ], @( ^. |9 C- W
2 @- C7 s7 o$ Q0 |* N1 estatic void __exit led_platform_exit(void)) N4 B/ W- T, x
{0 ]) E9 I1 m: h) q; K$ G. F% _" Q
platform_device_unregister(&da850_evm_tl_leds_device);3 x7 X# {; J. T9 ~
& Q2 t! e; d, y" E printk(KERN_INFO "LED unregister!\n");
' |6 O1 ^# j5 t- \: g# Y1 r}6 M$ y# \( x9 R5 E$ w. U+ s
; [8 S7 ]. l* i! e4 V0 I
module_init(led_platform_init);
( b, J5 P) | F1 L' T$ Jmodule_exit(led_platform_exit);
& e) F9 T5 x4 ]$ H+ K3 X+ S* f) }
MODULE_DESCRIPTION("Led platform driver");" ^: S& Q( P5 E/ ^4 O6 U9 b
MODULE_AUTHOR("Tronlong");$ B2 y# e* x1 }; j
MODULE_LICENSE("GPL"); x; }# x+ Y- v; i
) S3 C0 e7 Q6 w. ^
|
|