|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* ` |% U/ s1 x6 m' e# G
#include <linux/init.h>
! ^: v/ e! d1 q# a \- W. L#include <linux/module.h>9 `# ^5 G; P- ~" e+ h- ~: R1 l
#include <linux/kernel.h>) H) \: ^; a- O4 |7 U* g- q8 D
#include <linux/types.h>! D: r! F% ?; ]8 r1 m. ]5 p5 e- }1 Y
#include <linux/gpio.h>; I$ s" S9 G, X$ x2 w
#include <linux/leds.h>
! R# n! |. h0 D: J4 \#include <linux/platform_device.h>. v. t6 G- O9 W5 K; @
4 l: E2 j c6 D5 e
#include <asm/mach-types.h>
7 G, A, Z8 r5 @% I8 N4 U#include <asm/mach/arch.h>
6 c9 M! z" n# m- O#include <mach/da8xx.h>
! I9 C% b4 J! }3 R0 N9 P8 A#include <mach/mux.h>2 e" q& V3 U" C [) K+ \6 i0 d
3 A- B. E+ M' Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) l1 `5 E+ z2 F$ K& l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( |+ ?. [% @ @. D5 W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 h/ u1 H8 K7 u* ?0 Y2 T4 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# B$ N) f$ j3 L) }2 v5 S8 s8 ?" [9 b1 E! W6 G# i+ ?9 e) X
/* assign the tl som board LED-GPIOs*/
: Q) f5 O+ P$ [static const short da850_evm_tl_user_led_pins[] = {
; V1 K! h% W$ O* |$ E6 I4 W# ^* d' N /* These pins are definition at <mach/mux.h> file */
5 T# [2 e0 i+ h8 b- c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' V4 \+ Q& C$ S9 x -17 C$ e# f( h2 z+ }9 \3 _( E- K
};
. L7 `$ J# N0 P% G
& `6 U0 {7 G; jstatic struct gpio_led da850_evm_tl_leds[] = {8 v+ F! b$ z/ B4 I. y! j2 Z2 V
{
; o4 U2 ~' ~! w8 ]# F4 q .active_low = 0,1 [. \! d9 H6 F, r) A# d/ b' I7 m
.gpio = DA850_USER_LED0,) A. c0 H& ^* ]$ w1 F
.name = "user_led0",
9 h \ x( I% S .default_trigger = "default-on",0 i6 M+ q$ |+ h* D/ e/ L1 t
},9 c6 L5 P9 D+ I6 [9 j% u* Z
{
* |) Q; Y; ^0 h( d- { .active_low = 0,
% I, Y' K* S1 ?) f$ Q0 a9 z9 N .gpio = DA850_USER_LED1,
. r2 [0 e* X$ ~+ N0 l$ W .name = "user_led1",
4 ]- u; E% J# w4 u6 Y% w .default_trigger = "default-on",
' Q; [9 D3 |9 K2 r) ?5 m },
8 p M: \2 G+ S7 R3 G7 `% E% W {- D3 U" F+ a9 C: D$ Q, {! U9 V6 u6 e
.active_low = 0,
9 E& b- K2 i8 l .gpio = DA850_USER_LED2,) Z b, L( V/ E' g+ N' g
.name = "user_led2",# T2 z: [! ^* w5 J: T; N4 {
.default_trigger = "default-on",
. k1 v+ u) a& n9 S# q' _+ X },( [- B$ ^% V6 T5 [2 e% _
{
. y! y9 Y& w/ g( g .active_low = 0,) A& i6 `! e; ^1 ?" R5 C
.gpio = DA850_USER_LED3,0 Z0 [* d2 v: Z$ A
.name = "user_led3",* ]6 q. K. y# P+ Q( x; A0 B
.default_trigger = "default-on",
# {: d7 o U+ _$ i },9 R; j* Q/ G1 w
};
# i1 R9 O1 o9 g( R7 W( ~; Y2 F( y' N; g, K! H, o% z; M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, O+ U# s' a, X- b2 J& e
.leds = da850_evm_tl_leds,
# D% O I: u7 J' { _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" [3 `! J- E1 Z& e7 x- C3 s* a1 l};
( q6 i, g# w) F& v7 W: M1 |! O+ u9 B6 p) e2 a0 N, ^+ `
static void led_dev_release(struct device *dev)% F/ ?3 y+ I3 B% x; m
{
7 k# q' x; h- o}; O5 s) M* S$ R! c1 Y" E
* l8 Z8 n6 e0 X5 Y1 M- `" |) Z% o4 Mstatic struct platform_device da850_evm_tl_leds_device = {
# ^, G7 X. j/ K& x& ?& J .name = "leds-gpio",: W; C$ s, d# P! S5 g
.id = 1,( _- E2 A4 _# t" A3 \' H
.dev = {
3 b t" z: n7 c9 i# s+ l2 f- f .platform_data = &da850_evm_tl_leds_pdata,; L* E3 e$ e+ l' _8 l: R
.release = led_dev_release,
' T) \. S( Z: f3 a( f }
, Q* Q0 P) `! q$ T9 E};
% \' D. g" j8 ~9 f' Y0 [2 N
$ _# m8 r8 t+ K6 E I6 W0 q) Pstatic int __init led_platform_init(void)
, c! l G4 u- N5 O9 o5 r{/ D7 E6 P; B6 J! }: `
int ret;
* b0 T5 R" h& Z$ ~#if 0
. S6 ]5 l- I) N* a6 m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 {. O4 V8 b! s4 V5 E- q' y
if (ret)
: e% W R" }5 [6 o4 _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" k3 c* \( o+ v# y* e2 O
"%d\n", ret);2 f# w. p0 J6 U& U) B* l# }+ y9 j
#endif
8 p, }8 O0 G" F, r/ V/ o# F ret = platform_device_register(&da850_evm_tl_leds_device);
- Y. k- ]- f9 _9 R' m( k2 w if (ret)
# N/ R- B6 ~' ]+ \# p pr_warning("Could not register som GPIO expander LEDS");
( L5 ~* G$ n( z. W% p2 n% D& f- c: w+ } else. P' E5 p5 k7 E* O3 X# S( @/ X9 U4 a
printk(KERN_INFO "LED register sucessful!\n");: U% T" w3 n% V1 z# g5 B' H8 e
6 N& N; X2 Q- C3 R( ~% D8 h
return ret;
4 k3 P$ r/ b( t# n4 ?}( k. O. @3 h7 J3 \ d" q7 L% r
% R) H5 ]: t7 ]' g( g) b1 M
static void __exit led_platform_exit(void)
% l* E/ h- H' x) U{
, i) R* S1 D& W8 i/ W+ H2 d platform_device_unregister(&da850_evm_tl_leds_device);) r1 w. n$ j6 X( M( f% o
" W! |) ?: w+ K6 U g. q printk(KERN_INFO "LED unregister!\n");
4 f. w* b" B: O}& ^: D3 ?* r1 E8 b
/ `9 _/ d, D9 R& ?. U
module_init(led_platform_init);
' n* [ i) Y7 n! C5 d7 @9 }module_exit(led_platform_exit);
" |8 w6 |1 q# \, s' q; h
, e4 Q% Y1 J8 f! Z) j4 {1 O7 iMODULE_DESCRIPTION("Led platform driver");! H, d6 W. i: J! k' p
MODULE_AUTHOR("Tronlong");3 K9 r; E# c' V9 O2 ^6 S: K
MODULE_LICENSE("GPL");8 V2 L N n. r5 _- T( W g5 ?! R. V$ y
5 S0 c- I" P* g |
|