|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& g& p- C3 b, {3 _: M2 I#include <linux/init.h>% ]0 Q, z5 A' f9 f n1 P
#include <linux/module.h>
" D) g7 p6 t( x% @% l#include <linux/kernel.h>
( D' W4 P; N: q0 j- T#include <linux/types.h>
$ [. V3 R+ l6 m7 O% w#include <linux/gpio.h>7 W. m, w, m. z. ~' r
#include <linux/leds.h>
3 r+ W. G# v. \8 p2 G( d#include <linux/platform_device.h>% K2 E1 C0 R( H6 J/ K$ F5 J
$ E/ \: G7 | b0 L2 [" y
#include <asm/mach-types.h>
# }/ o; f4 v# B) t' M#include <asm/mach/arch.h>* e% v" A4 w2 e
#include <mach/da8xx.h>8 M( ?5 H* r* T: T7 Z* g
#include <mach/mux.h>
5 k6 y: P" U( V
! S3 r- j( a* `" m# ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 ?2 T. R& l# L; e- O- l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- o* G1 W4 o3 j: ^! f7 Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& n+ o/ `/ T1 x0 g- G$ o' l! t$ e# B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) x' e2 l5 H: ]9 l' W$ A7 N
q/ F9 {. V. {; P, w( k1 Y/* assign the tl som board LED-GPIOs*/: v' [2 y6 c( D. M5 I# D! g
static const short da850_evm_tl_user_led_pins[] = {
- v# W$ L! X6 l0 e2 \) ? /* These pins are definition at <mach/mux.h> file */% v( P3 W9 j' d) j' ]6 j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
O$ u- I7 G/ z+ w+ j% Q -1 G+ f8 |8 W& b% S
};7 V9 R+ n# W1 f) s f4 p" V3 T
2 {& Q: z! @$ v
static struct gpio_led da850_evm_tl_leds[] = {. D' B( E2 R4 N. L3 M! l, t7 l
{9 R! V1 E5 x& _4 {
.active_low = 0,( I6 s& ]# B ^7 V% I3 ~
.gpio = DA850_USER_LED0,( l* x. w" N8 X) }- G6 T
.name = "user_led0",
! T; r4 M. z( g; j7 G4 q$ ` .default_trigger = "default-on",/ W1 i+ _2 g& x4 U0 {4 u
},& v2 n% m `% Q% g$ P7 \# \% A
{
+ ^. M' N6 \8 s8 y .active_low = 0,
; u% k, o. N1 d% m' T1 r .gpio = DA850_USER_LED1,
( R) q: N: h$ b5 r0 | .name = "user_led1",
5 {/ y# @$ Q' U. @# w .default_trigger = "default-on",
% {$ J! |3 u, V0 D# C1 a5 j) S },
T) q2 x1 F1 W& b3 k$ G+ I {
- N, m9 a3 d% U: B1 |+ z .active_low = 0,
' N0 j4 ?, \9 x0 t/ a% f* [ .gpio = DA850_USER_LED2,
& S3 [0 `. i: w0 q1 | .name = "user_led2",
4 ?' h) W5 L+ R .default_trigger = "default-on",
8 z+ m0 y- V" q% \ },
- q1 `" c3 B9 p1 z5 n* l {+ J% z" F( Q2 g' O) N- z; }7 ?( ^
.active_low = 0,( [+ I: f1 N% {, [5 C* A
.gpio = DA850_USER_LED3,4 {* a. K+ a A/ v
.name = "user_led3",* B, h% L E! E/ e
.default_trigger = "default-on",7 R5 l$ N+ H* e' B" j. a2 r: k
},
: d% l* I/ `" C+ s) W+ l};
' D8 B, K) T. ^* I; |0 i& p4 a/ `0 f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ F) ~8 D' }, v: s } .leds = da850_evm_tl_leds,7 C5 q4 l+ i) i" k3 }* E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
h7 a* b- h) [};9 H. {5 w S, Y q
( ]1 ?" d Z7 m( i$ {
static void led_dev_release(struct device *dev)
( k/ w) h0 p8 h- j! G{8 Y" ` M4 e9 Z5 |. _# ~
};
$ s" f3 h4 O! `) v6 K* ~5 R6 p, j* |4 {+ ^/ d' O7 Q
static struct platform_device da850_evm_tl_leds_device = {
1 o% I) \% i1 W .name = "leds-gpio",/ s; ?# @) \, ~& h# H7 H; C. @
.id = 1, G3 k# X) `5 q" n; g
.dev = {
2 J+ w: L5 P2 @7 \ .platform_data = &da850_evm_tl_leds_pdata,
9 ?- J+ ~7 M: R: X: A .release = led_dev_release,- [# t, p+ A, Y( R0 D: u! Z
}! p( D+ w& t* |1 U/ ?2 r( W
};
- L0 p# x; E- ~ A7 R, r+ P
- y" k5 n* d- R, b% S! [static int __init led_platform_init(void)( ?2 x* `6 s: q# S y# G
{( ^2 n2 [4 F( x7 o2 K- i2 w, C! t
int ret;
8 U6 X. ~ g2 Q#if 0
; [; x4 @9 N* f7 z1 [/ D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' i/ w4 C. R! ^
if (ret)7 s- q- Y l+ T" i3 r. D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 g4 a7 s5 i' a1 m, w$ ?, K "%d\n", ret);
# l+ U* u5 \ n( _#endif: A1 S* d& c- l" O( G
ret = platform_device_register(&da850_evm_tl_leds_device);
/ P6 ]+ E4 C" H) \1 I if (ret)3 [. I1 ^& g" F* Y! w. q }
pr_warning("Could not register som GPIO expander LEDS");6 x0 }' B0 u4 A# S. o
else8 ?2 X8 Z. a, {0 z o
printk(KERN_INFO "LED register sucessful!\n");- R6 N5 Y. ^+ E4 @" k# j) i
/ q" [% Q, {* I/ c/ Y7 b! H
return ret;
" Z. O$ U1 p8 b8 u, @/ k6 S2 l4 Y}
9 O: }6 G! ]3 G, L) q. S
/ }, t# i+ N6 w6 \static void __exit led_platform_exit(void)
# q% R; |* t4 F2 v( Z. K& r{9 {/ g" b9 f& n( G
platform_device_unregister(&da850_evm_tl_leds_device);
% f0 |$ S8 \& ~ ?' A6 p6 G$ `
1 k4 j. \: X h( H printk(KERN_INFO "LED unregister!\n");
$ q/ W- _+ p) I9 ?, a' R} A9 }. k. f7 s: D
" o2 o# G. A) S/ O T& |
module_init(led_platform_init);
: U6 h1 \7 j- d, P, emodule_exit(led_platform_exit);' c2 M& k# h% E7 R( ^3 @& g3 g
, h2 P0 z4 g6 qMODULE_DESCRIPTION("Led platform driver");
* h1 x; j+ ?1 p; {8 I) J6 ZMODULE_AUTHOR("Tronlong");6 V: G+ m9 x' S1 F* {3 O% r: J. O
MODULE_LICENSE("GPL");
, g9 K; ?3 a: Y- N6 s" [
3 \7 W% _( q# Q3 Y9 c n, f6 C0 o$ c |
|