|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; E2 U, h8 H& G. ?+ g, K#include <linux/init.h>
* @+ X. V" J) \* r' y# c% D#include <linux/module.h>: T. N6 [$ K/ g, ^) e, q4 D, x
#include <linux/kernel.h>+ m8 g0 _# y* N
#include <linux/types.h>$ ?) y# S0 r( A. J
#include <linux/gpio.h>/ M7 ?/ ]( B9 i' B$ |0 R$ \
#include <linux/leds.h>+ P3 N* {6 H+ i3 n" c+ E
#include <linux/platform_device.h>/ h$ a5 p6 |/ o; B
7 f1 m5 m+ @2 y$ @( l
#include <asm/mach-types.h>
; R! x! k( y- H4 j4 i1 L H#include <asm/mach/arch.h>2 x- n, x: t0 {! T( B/ t
#include <mach/da8xx.h>8 `) s/ t! e, d1 ^2 \1 n
#include <mach/mux.h>4 l1 U" X3 E& e2 e* Y! i4 A+ W
: r& \0 |1 y4 m5 r# a2 \. V' K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- ?2 u. o9 c) I# \: w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 e, z+ [. |2 {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 x% ~+ T# u ^5 Q1 y3 ^- O" @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ ~# i% F" h/ ?) a7 ^0 s9 a( w* v5 R
/ D7 x/ d* [0 A4 R/* assign the tl som board LED-GPIOs*/
7 I# t% @. ?8 J( ~1 w/ b% w; m8 B% u6 T* `static const short da850_evm_tl_user_led_pins[] = {& a, y \& N4 g4 x
/* These pins are definition at <mach/mux.h> file */
6 L" u* a5 V6 F1 A% u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 L: y' g& I, S6 a9 F: { -1
! s+ B3 N+ S% Z" s8 f};- F* _ u6 E& U$ ]+ Z
' @3 U" h. @' d, [: Astatic struct gpio_led da850_evm_tl_leds[] = {
& O: n* x5 L: g' u6 m1 f { A* b% Q. `4 s j
.active_low = 0,
4 A: Y1 i! Q! V c .gpio = DA850_USER_LED0,
: v; }7 ~$ y- J .name = "user_led0",
# V* T4 T2 h% N8 Y# w .default_trigger = "default-on",) Z3 }7 [/ I! T8 M+ L
},6 {7 _) g- e2 n; y' |' c: g4 c
{ F/ k4 V% B2 A: h+ |0 o
.active_low = 0,& O* F4 v2 `# j3 j
.gpio = DA850_USER_LED1,
) ]" F' X; W; W .name = "user_led1",
9 J f$ ~8 A! i/ q' ]" Y0 F3 P8 z .default_trigger = "default-on",6 [6 T& i, W) a: H) I' A
},5 x/ s8 O0 j6 O1 A
{" z% y; z3 B/ v! Z2 T! |
.active_low = 0,. ]& ]; [# U, L' x4 R* i5 N7 S
.gpio = DA850_USER_LED2,
3 c+ ^$ N5 G2 n. P0 A5 _$ n; \ .name = "user_led2",( F2 b X3 D, K" b7 {2 t8 Z; y
.default_trigger = "default-on",. V8 y/ X. i0 u! X/ k9 h
},. C2 F% B# K2 A* X" D4 r
{8 d; F: d$ M" w8 x! \3 w7 E
.active_low = 0,
. q' F* f6 e0 _) c1 a4 H% Y .gpio = DA850_USER_LED3,
2 w3 @* @+ A ~/ d* _. U' {# r .name = "user_led3",0 ]8 ?3 }" z, f9 d
.default_trigger = "default-on",
$ P. I& \* _/ M, G: n. q9 h% D }," c+ Z$ S/ ^- B! t9 ^
};' z" H i( d, I9 i1 n
" @& \) \0 o2 G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 t+ }6 d3 a5 M; N8 _3 C .leds = da850_evm_tl_leds,, K6 M; z0 ]; ], r1 [2 e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# ?& o: D" T5 K: A- N) C};+ q# E3 l8 T: @" X$ X
2 Y s' ], a( `# H5 R4 Kstatic void led_dev_release(struct device *dev)
6 Q2 [' e3 x+ P2 D8 d{* f2 M( I# t. P& s2 {3 I7 @+ l$ t
};
, u5 X5 J3 p! c5 {
9 f4 ^" _0 g9 g- j8 K7 Mstatic struct platform_device da850_evm_tl_leds_device = {# J' E- o7 A" ^% \: {6 r9 r) j
.name = "leds-gpio",
4 B/ Z, F% u: |( z9 j3 u0 h .id = 1,* z& g, R) B5 i$ A9 [
.dev = {
: R8 v- m2 e+ G* U, l .platform_data = &da850_evm_tl_leds_pdata,5 n2 I6 |* Z- K( ~3 r. q1 b5 @6 y w
.release = led_dev_release,4 ?7 T& @9 q* w) l: [9 ], C
}
. ~% m( Z% H) o" b& ^};) q/ Z! u( |: Z4 K
* S+ F6 X+ B6 s/ l0 U
static int __init led_platform_init(void)
) q! |8 T5 d5 b{
+ g9 V" p( K8 G$ ~9 c( i: t int ret;
2 e3 O3 a) W" M6 T# m- v7 S#if 0! Y5 p, R, x4 @" |' O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 N! Z/ B+ r4 w9 _- F
if (ret)
' x3 p4 X+ j# j" x$ ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! z$ M% g2 a# K8 c, L5 {/ `
"%d\n", ret);
# O- V: n& e7 U& x: e6 P#endif" A0 L m: \( A' v/ S' X
ret = platform_device_register(&da850_evm_tl_leds_device);; u3 d! \* q2 K: }; N2 E
if (ret): a3 F$ q, y ~/ ~7 q9 k; q
pr_warning("Could not register som GPIO expander LEDS");5 Q7 U v2 }+ y/ o5 _2 q1 _! }% p
else3 `! W; D& _3 h, |; d
printk(KERN_INFO "LED register sucessful!\n");9 e" b( E, w, |' k5 ~ K
! s/ s/ G. J' [
return ret;3 o+ \( l; p! l4 U0 k- b
}
; v; g) a5 d$ P2 F$ g6 \% P) h3 ]5 P, d3 e0 w
static void __exit led_platform_exit(void)
6 [2 }, e9 v6 |2 m p% n{
! N( ^9 f5 Z- x0 d i6 N3 @$ K platform_device_unregister(&da850_evm_tl_leds_device);" t Z# _! ]+ }0 s; Z( c' g' r
7 Z Q+ ?+ O7 C# |( D
printk(KERN_INFO "LED unregister!\n");+ j: J/ }, f- M2 h
}
1 M' h- ?# X/ T+ D8 j0 f5 U X. T! F+ z% ?0 |+ A D
module_init(led_platform_init);
/ l4 R& |5 f, H8 C$ v4 ~# Mmodule_exit(led_platform_exit);
2 C3 f3 W* y0 t. C& G8 x7 V+ U% I o2 g- `( L, h
MODULE_DESCRIPTION("Led platform driver");8 \& P1 R" g! [9 T) q- B+ n
MODULE_AUTHOR("Tronlong");- |; ]+ J) h, W! J' b
MODULE_LICENSE("GPL");) O+ b V1 n7 U1 S
5 A8 c8 M- t1 d" S |
|