|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ w* B/ K" L9 Y& A0 e1 u3 ?+ p$ q#include <linux/init.h>+ b$ `. m1 K3 v! `$ o" m
#include <linux/module.h>
. p* G/ o6 u" F. u1 A8 N- I5 B' \) f#include <linux/kernel.h>
. v2 O! _ O3 S2 [- a6 A6 ~#include <linux/types.h>* r X G2 J g' k
#include <linux/gpio.h>
- X( I: f4 L1 B9 s- E, z/ U#include <linux/leds.h>
/ Y& p4 |4 F5 y9 J. _, h2 y7 ^, J#include <linux/platform_device.h>
% F/ |( C" ]/ z( l9 N0 |; ?
. E" H% U$ p0 I: }' s#include <asm/mach-types.h>- J' ?! b5 E! u1 L3 z O2 x% M; q i1 m
#include <asm/mach/arch.h>! B0 j8 Q" K4 L# Y. C7 a
#include <mach/da8xx.h>0 E/ m; t4 {. L O$ n- L
#include <mach/mux.h>( D, \( [, S) O% C; c
0 }+ y' _* p4 D2 M+ B; w. ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& I2 d' g; w0 @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ N" `0 {9 f/ x |: M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, D' v2 Q0 ]. p. }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 }; V" k( H& \# s0 a+ Q* X
6 r: f( a- T& d8 ^
/* assign the tl som board LED-GPIOs*/! C w8 k# R' v y5 X
static const short da850_evm_tl_user_led_pins[] = {
3 T' d7 C- H2 c /* These pins are definition at <mach/mux.h> file */# H; m( V! Z1 A3 X: F$ X* a+ c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. |: d' V$ {9 q6 K. ]
-1
4 M# S. M! s! G};
9 \7 v/ i& f' [( N% b8 x
9 `; O, `8 L& d7 j- N7 T5 D" wstatic struct gpio_led da850_evm_tl_leds[] = { \, }( ?5 `( X% G
{
* [! O" s& w6 A! W& d .active_low = 0,
, Q0 k1 M* ^7 d0 f" N* y5 ]+ c2 U .gpio = DA850_USER_LED0,
# q( I/ z# X% u k5 O# e( s .name = "user_led0",1 v2 q) q* c* S% k2 t* n' R
.default_trigger = "default-on",
/ y% Q- A1 {9 A" v; p },( X. A5 y; I6 N [5 y, {1 g
{
( h# E1 j* }$ [9 m& Q4 J; E .active_low = 0,
% D+ f5 b/ |' V" U: Y .gpio = DA850_USER_LED1,0 X+ y; p( F; u+ r* E
.name = "user_led1",
7 v- r9 Y' r/ E) ?( [( o. [) | .default_trigger = "default-on",
1 N' f" b! p+ i4 d" A3 a },
! W+ f+ r$ ?* c4 v {- r8 w: L$ q6 n! u! V M- T
.active_low = 0,
) X$ p6 M: }: u: z .gpio = DA850_USER_LED2,
* w) p! V" E4 E# d- Z, c, ?" i .name = "user_led2"," O0 b) H1 \$ Z/ a
.default_trigger = "default-on",$ V3 H% Z# C2 O) L* ~% |; X
},
' z0 a" }( _# H1 | {- K" A' P2 I8 f ?
.active_low = 0,
8 J8 O& l/ u8 k; y; v' M .gpio = DA850_USER_LED3,6 y9 k k8 C9 n# O" O/ D
.name = "user_led3",+ T( U" e0 s% }; W8 m0 \, x, \0 r
.default_trigger = "default-on",5 A: ?( x; F' ~. e0 x( k
},
' q9 H' L$ `& a};0 ]" ]7 i$ l" i! ^" k. A3 [( m
$ z0 z0 B) H% [ Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& P6 Y: K5 v/ w; U9 w
.leds = da850_evm_tl_leds,3 }3 Z' y$ B# j& X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* x1 m5 T; i7 M5 ]};2 s& f5 E! q1 i Q y/ h/ `$ b
3 ?5 ]1 }7 ~4 R: O! @1 G8 O0 s- k6 ustatic void led_dev_release(struct device *dev)! Z9 N/ O3 ^" X" z9 k0 Y
{& R. g" N" h% j9 I" r" t( _
};- P6 c0 \. r" t* |4 U, B
8 O, v% m+ E' N) E" M
static struct platform_device da850_evm_tl_leds_device = { F" ^3 ?7 ]% v" [0 h" T+ ^
.name = "leds-gpio",
* e; v f9 k6 g .id = 1,
& Y) x$ P; x3 Z" o+ M4 s .dev = {! W t. a' d: y
.platform_data = &da850_evm_tl_leds_pdata,
6 l' o& A) X2 W2 B4 r6 ` .release = led_dev_release,
$ ]; L' o7 y9 @! B' b5 a }+ u. c- U- d5 O7 g+ z7 E6 ?9 P
};* t' T# a) |, T' c
% Y4 Y. r2 `0 S/ Z! g, t0 o$ s: a
static int __init led_platform_init(void)
: E9 k; ^" X- x! f0 ~4 c0 I9 s{
[* {9 h) `+ ~: ]. F int ret;! _9 X& v" p: v, L5 c9 P; v8 c
#if 0
3 |) a& D5 ]( t* N- C N- z& u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); ]: D/ Q6 ^) @3 O% ^: A
if (ret)
) ^1 F, e% ~! _. w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# [$ [/ ?" ^/ v- V6 \
"%d\n", ret);. z; Y" O3 Y. h3 Z9 w J r
#endif
. J4 i) W* I4 {1 f4 [' l- } ret = platform_device_register(&da850_evm_tl_leds_device);5 {/ E# b Y: ~6 }! b$ L
if (ret)( d. s0 p& ]3 q- x3 q1 a2 W9 A
pr_warning("Could not register som GPIO expander LEDS");9 T( Y; e" b0 Z, l
else
" e/ R! @5 H* F% W8 y printk(KERN_INFO "LED register sucessful!\n");
* g6 o- y- p2 S5 g$ p1 D
: \# s/ F/ I$ h8 U4 k$ s return ret;
5 c; e) V8 _) O8 P, u}
% H: u$ o+ |( G0 D
- ]# d1 C$ `& k# N! r* tstatic void __exit led_platform_exit(void)5 r) a- O. N3 N6 R3 r7 l2 m9 w( \' t
{ R( j7 R/ ]* F" v$ r" a
platform_device_unregister(&da850_evm_tl_leds_device);$ a6 \6 f- G" _ s% x! o) b% q
! M' i, ^# G: T8 v printk(KERN_INFO "LED unregister!\n");
' j# v5 B* ~% L' P9 G, L- N+ U2 H3 T}
9 W9 X* l$ W$ i8 m% ~1 O# X: b- O7 S2 [; f. E# e% M+ W
module_init(led_platform_init);
_ Z- ^0 e+ b* @/ |2 ]. ^module_exit(led_platform_exit);0 U, B/ g) C: p3 a7 E* G
; a# ?" P ~9 \0 {6 PMODULE_DESCRIPTION("Led platform driver");5 r6 n3 L' Y# T* i& e# ?
MODULE_AUTHOR("Tronlong");; N, g! @# ^- T
MODULE_LICENSE("GPL");
% P" H+ p7 j4 u! Q6 [0 U; N2 r6 r
; n$ K9 P( C6 u9 w' R, r# o |
|