|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ q2 o3 E! ^6 }#include <linux/init.h>% H+ x! _: G8 A
#include <linux/module.h>7 R; |- h+ E; U7 B4 F" Z6 }- H
#include <linux/kernel.h># _- j2 X6 G) O! t3 t3 w" b
#include <linux/types.h>
4 Z, r0 H; f7 B% C0 |#include <linux/gpio.h>4 W6 k: Z S: m
#include <linux/leds.h>
& ^, v5 C+ U9 R: Y9 C#include <linux/platform_device.h>$ _" |% k4 B9 u! |7 k) Z
S+ F. S/ `+ l#include <asm/mach-types.h>9 T& r9 J+ B) H" `: F
#include <asm/mach/arch.h>
) }2 D) m* {: a& H#include <mach/da8xx.h>7 {" ]- O# B2 w7 i+ z6 e& y9 ]! x4 M
#include <mach/mux.h>
& F: z C+ C( h4 b, l% d: h* k I, D& ~# }3 c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. w, d( F3 U9 Z5 H( T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 ~) S0 u- W$ @) {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 ~% |' L& S+ K4 d6 F2 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! C& D1 W8 F( b' q( y* ?) ^+ A
. X) G! ?' o5 y& @
/* assign the tl som board LED-GPIOs*/
* Y7 w, P0 ?) }8 ]$ \static const short da850_evm_tl_user_led_pins[] = {
' B" \4 \& q5 ` /* These pins are definition at <mach/mux.h> file */0 f% N: X& H, n4 \: ?# J; P
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* e( w6 y' x& _ -1
, a; `3 S l, G" m8 l};1 W$ Y1 a8 g2 J! O
& ~1 T$ w2 J/ b- E' g U' Q* m
static struct gpio_led da850_evm_tl_leds[] = {, R; `4 x) V2 r- W" A3 M. v$ M+ K
{7 V3 r1 @4 ?. B, d! Z0 B
.active_low = 0,8 |* @8 B: q" f
.gpio = DA850_USER_LED0,
* J; K2 A, }+ p1 W% W9 C0 I& \4 | .name = "user_led0",; N3 F! d7 Y$ f
.default_trigger = "default-on",8 `, i1 U2 p2 C7 J3 J4 I9 A) n
},
+ f0 ~6 y4 ^9 x4 V$ R {! x4 R* F) j' M2 s# i `
.active_low = 0,
2 a. S) a2 E2 N5 M) V. n2 T' n .gpio = DA850_USER_LED1,8 a# Y2 V3 @1 n9 W* B1 i& q; F% P
.name = "user_led1",
- {+ W' t& F) N0 M+ u; X7 v& v2 U1 P .default_trigger = "default-on"," z# I: ~1 x8 |7 N W/ ~0 b1 Z2 g5 u+ {
},
" `% S# @ l5 J" F$ G0 j {% y' b) G# A5 h2 y
.active_low = 0,
9 g: v2 f. w1 }- @+ d6 L .gpio = DA850_USER_LED2,
# ?) r3 D% a8 B .name = "user_led2",
$ G" X' w0 G- G4 C .default_trigger = "default-on",( R! H5 ?1 f( b+ p# [2 H! l6 _
},
; k5 O- k+ |6 H/ I {
) D& u" _' V1 y5 I0 j .active_low = 0,4 Z' k. P& `( J: e" b
.gpio = DA850_USER_LED3,! S, Q/ W; {7 v
.name = "user_led3",6 a2 v y) A' M
.default_trigger = "default-on",2 @. v8 @' s1 k$ E
},& {; W& W2 }1 a, a8 |3 X" v
};
5 s7 H2 w' p7 W: F; ^9 v7 w7 M6 O( c) M' K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# W8 ~ S! n2 I8 j .leds = da850_evm_tl_leds,( j1 w) L6 v$ o; m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 r0 d5 @+ g+ R+ m};
7 J% S+ Q; \6 W4 [$ D5 ]6 S! }
) B. b& X: p$ x% C8 l9 r8 hstatic void led_dev_release(struct device *dev)2 z1 m. ]0 @9 z) v, I. y$ k
{! n& I- J5 x+ }7 b4 M: Q
};6 p- |( `! y& x- X2 J/ R
( k" [: k7 ^" x4 F% R
static struct platform_device da850_evm_tl_leds_device = {. x( V- V. v! U: t! W5 d% N/ R
.name = "leds-gpio",+ }7 U8 U2 j8 Q) F
.id = 1,+ x6 M& {$ I1 |( W3 H" g) {
.dev = {
' S: S1 q! f; y$ s7 n .platform_data = &da850_evm_tl_leds_pdata,% c2 ] N8 ~9 h; d7 q4 k7 w
.release = led_dev_release,5 Q: M0 Y L3 S7 n
}- p7 C# ]8 Q | ]
};8 @: N% J7 K0 m; u% |( w) Z
+ e! | l: c# a5 i: U
static int __init led_platform_init(void)
& T8 G$ C# R. }$ F{
4 X! c' Q4 H; k4 j int ret;
0 e3 m! y% n, ]+ G! C4 V' E0 ?0 ?2 b#if 0
v0 [# o4 e9 ?4 O' d. m3 E- V ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 L2 B/ ?! Y$ d' E | if (ret). I1 X0 ^; Z4 |7 L* k1 @( ^( S/ R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( f. i! H3 ^4 A* |: \
"%d\n", ret);
* N0 m- w& v) B5 ^# K* H3 R8 M, e#endif- T" I; T- V+ v0 [! F F
ret = platform_device_register(&da850_evm_tl_leds_device);
% P; I, G# h6 {6 O/ k if (ret)* V+ r1 {1 L# M
pr_warning("Could not register som GPIO expander LEDS");
* X- J% y7 H9 `3 ? else
g" I1 l. W: v2 F! e* w O printk(KERN_INFO "LED register sucessful!\n");7 s* |, m# j n1 g' m' I
- r- M5 ]: j, c A5 l return ret;
. I: Y+ G5 J8 W0 ]9 U/ j2 f4 L5 M}4 D6 I3 \; ~ G ?! O* }
: F; \* s$ @/ G. X6 I( w4 @; v; kstatic void __exit led_platform_exit(void)
) E0 W0 a% l+ N% B2 Z{' Y* F" V' W! _2 y0 c4 N+ ^
platform_device_unregister(&da850_evm_tl_leds_device);' C7 b" Z( E0 U% S# Z4 m
7 y' D6 Q9 K5 x4 e; B
printk(KERN_INFO "LED unregister!\n");; A* B$ x( d/ o) k, a9 \
}3 N1 ^, Y% p/ Z( r( y' X! e( B
: L7 n h C5 W% B6 l/ l
module_init(led_platform_init);1 G" a, O6 O" C. }7 V: H# k2 W% g
module_exit(led_platform_exit);. a. T! b/ ]: u; }& s7 S& p# E
( }& k& K' `$ F: D. ^( OMODULE_DESCRIPTION("Led platform driver");0 k5 p/ t4 d" E% U( b
MODULE_AUTHOR("Tronlong");2 c8 Z! p6 \. t7 L# @
MODULE_LICENSE("GPL");
" m% C$ k2 a$ ~) g9 Y' c. V- Y. X4 b1 o' q& o; |: l. j4 j3 ?* _
|
|