|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& {) E' p" Z. T8 f/ O
#include <linux/init.h>8 d2 d9 e4 }% e' j6 ~. u
#include <linux/module.h>& ^2 g" }/ y" W$ ?3 y
#include <linux/kernel.h>" Q' R. N* X' d% c
#include <linux/types.h>& s0 W) {2 A% a5 p9 U2 i
#include <linux/gpio.h>
+ F& I5 n; k4 Q: J! m3 Q#include <linux/leds.h>3 w7 y& k( u$ u( G a
#include <linux/platform_device.h>
) J4 h" _$ q3 X$ C, [
. _) E# j' |0 c+ x#include <asm/mach-types.h> ~! O4 g$ L1 t ^% {, j8 V% d! O& f+ K
#include <asm/mach/arch.h>' T# a# b0 D7 f. Z6 V$ L* [0 N! t
#include <mach/da8xx.h>1 @' K/ M- @. }
#include <mach/mux.h>
' P; J \! Q( L8 R' p& m" |( r7 a$ o, I4 M& i# r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" e0 j" v6 E2 g+ x2 o9 P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 S D5 v: o# c Z; l- O( o. O" S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 F @0 G3 h$ _3 c9 S) f Q6 I4 W1 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 W& Z: [( @! Z" H8 ~
9 _8 U8 @3 \9 g) `" h
/* assign the tl som board LED-GPIOs*/
) w* J" O5 \* j- q' }8 J$ O4 kstatic const short da850_evm_tl_user_led_pins[] = {
% K/ Q& k0 X6 R' {: r& W/ q /* These pins are definition at <mach/mux.h> file */8 |* r" f9 ` A! e2 y4 ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: r y" X/ m3 r, |; }& A+ Y8 J9 S
-1
5 ?0 Z0 r5 M2 ]# e" \};: Z, m4 K* m) v8 P. J- j
& ^" s3 q1 Q& z! qstatic struct gpio_led da850_evm_tl_leds[] = {1 A& w# E2 A1 y0 ?3 b7 g! Q% A B
{
! j9 w5 _6 y3 t5 T8 B .active_low = 0,5 T9 r# F; T' f% K* f) ?) ]: w! V2 j& k
.gpio = DA850_USER_LED0,
! }8 b, ^# [! J6 I: U$ I .name = "user_led0",, t# H9 l; Z, T, F
.default_trigger = "default-on",
- X. H+ c' S1 _6 g1 U3 u! \( H/ s5 i },6 c! s; g0 I+ T) Q, q
{, @& {6 k# o U. v$ w. K! J$ Z0 { L
.active_low = 0,
6 I3 S9 C, T& `0 u1 q1 f# {% g1 o .gpio = DA850_USER_LED1,. Z J+ Z$ `! v5 v- H
.name = "user_led1",- T, c* F/ L% J% b: Z$ u5 f" w
.default_trigger = "default-on",( R* s* }7 G& V- r! S; I' g
},
; j0 a/ C# o1 Y8 B3 `8 w {& \5 W& r- n$ o# y& S/ |# M9 I9 x
.active_low = 0,
: C' ^; E7 B& t5 x. m( g0 l w .gpio = DA850_USER_LED2,
$ L l/ Q I+ S7 Y% ? .name = "user_led2",
3 v* X( q6 x6 Z4 s0 t- I .default_trigger = "default-on",
, r5 v$ q/ K2 c! N1 }6 _4 Y },: Y8 q1 W* W9 U+ Z5 |
{* ~2 W' J0 V7 S5 }2 Y
.active_low = 0,; z- p. j1 e2 w" r
.gpio = DA850_USER_LED3,
- p/ n' Y( h% w; F- q: m .name = "user_led3",
& }9 ], ?& T1 b8 v8 a0 f- u7 ? .default_trigger = "default-on",
8 H" I) k9 x+ | },
- M) ]9 @ N4 _, U- v};, G9 Y% A# {, X& `* l ?6 Y L
- o! @" m/ z- p9 t4 Y- O2 A* y7 Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 ]& k$ X) J: @" @ Q. @7 i" A .leds = da850_evm_tl_leds,
7 l, |# [) x7 a, V1 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 l; _% b4 e1 c6 p4 a8 M8 Q};
& _* v& G ]3 v% R
' p4 H9 O7 ~% {+ O- j$ Nstatic void led_dev_release(struct device *dev)7 o/ N- c2 n% X+ H L4 m* i
{, V8 a7 `& w$ P/ U/ f0 C
};, ~ Z$ B2 [$ {7 f7 `# w+ w
! ]/ w* x$ X: p6 G( Q8 r
static struct platform_device da850_evm_tl_leds_device = {0 B y8 T6 k% H. w! V M% j
.name = "leds-gpio",) g8 T H( |7 \( K- P( F
.id = 1,( b% t5 S5 n% [. \6 @2 o
.dev = {
7 U$ }3 T0 `1 `. ` r, M; W .platform_data = &da850_evm_tl_leds_pdata,6 F2 @ m r7 e; v }
.release = led_dev_release,
j* M; M7 Z; o& y, j1 @ }; A& c0 s: O4 Q- O5 [
};# N+ a: P9 u& K/ \% n. w
; n* [# V( M. q$ l0 D6 estatic int __init led_platform_init(void)
; }8 p# Z& o6 z7 k; g- S{, k' \% s; D. ^: d7 R/ L1 y
int ret;# @3 @3 n5 F1 L2 S" n7 }
#if 0
+ n# a- q6 b+ |% r. m5 b9 _3 g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% _ s3 |' k9 M3 p5 i5 D& c
if (ret)/ D+ I/ q4 d3 R" g+ Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" G* x8 Q' l1 _5 _
"%d\n", ret);
0 K) O5 S) {. s6 F; ^$ L#endif
9 ^* r( f* I8 X2 g1 \4 u ret = platform_device_register(&da850_evm_tl_leds_device);: Z; D& e/ W5 F' f! O9 j U
if (ret)4 d" Q+ }3 e- ?- Z" Y7 D& X2 d1 a
pr_warning("Could not register som GPIO expander LEDS");
. p5 Q" e3 R7 f% J3 C% h$ ~4 X+ Y else6 ]9 ?4 l- e- O3 S7 K* w2 F- U
printk(KERN_INFO "LED register sucessful!\n");$ S; G' P+ P" o& K) f+ G
. |. l7 k& M; V& G3 T8 H3 J1 k
return ret;
+ I5 a3 P1 e% Y% E; j7 @1 X( k}# n, Z5 m! w* Q6 U( M
* j" y3 ?3 `6 t: g* F1 h, H1 c; [
static void __exit led_platform_exit(void)
, A! i! |; u% h{, n9 N0 G: E$ u2 O. l: Q* ~3 k# v
platform_device_unregister(&da850_evm_tl_leds_device);. K" ?) w. j8 I) Z
5 j# p/ q1 Y+ H6 v9 @9 L' e; f* ~
printk(KERN_INFO "LED unregister!\n");' {! a# @0 d- |5 R) ?2 H4 T5 u6 J
}' W( A" s) _$ g4 O' }/ q; k d4 C$ M
H* E; R1 `: X7 |% K8 E8 u
module_init(led_platform_init);) x" ^# v& J3 i& e& N$ i& w
module_exit(led_platform_exit);- C' {5 y5 i4 q$ n/ g2 `8 i
. k, U; x3 j6 r1 TMODULE_DESCRIPTION("Led platform driver");
# n8 c* D! t0 C. ?% r2 E- hMODULE_AUTHOR("Tronlong");6 J: m: I9 l1 D: H: y: y
MODULE_LICENSE("GPL");
! F& \- {" O# T* }6 |( O7 e) A# y, ^5 M6 v
|
|