|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% @1 c. `) Z7 i8 y" V9 o#include <linux/init.h>
1 \: E' W, K |, u4 Y- ?3 A#include <linux/module.h>
: _! K5 e7 ?% Q#include <linux/kernel.h>
5 |& } ]% Z) D" P6 @#include <linux/types.h>( t' b7 A( z; z. q7 S4 L* j
#include <linux/gpio.h>9 Q3 J6 ]$ L) E7 U! v! o# D0 N
#include <linux/leds.h>9 }% c0 A! _3 G4 ~: F8 j
#include <linux/platform_device.h>% F* U) ~( ^) T/ }2 `5 j1 H& k
& j% k& \6 }3 |0 d+ z" O5 Y2 v#include <asm/mach-types.h>
5 y/ L" S8 i# ^+ p) P: C! x9 @#include <asm/mach/arch.h>
( l3 H# r4 M# L#include <mach/da8xx.h>+ h9 Z% R" n P* W% Y% e" g
#include <mach/mux.h>* `- l' ~. e; c% D7 D/ F
0 M6 l: Q, y# M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 ` L( Q3 \7 K% R# j- t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 U2 s; P, |9 V1 K- s9 R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 O/ K' i$ {' g/ ~/ Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# I* `; b5 {; G+ e6 V s4 d, }; _
/* assign the tl som board LED-GPIOs*/$ J9 t, N3 k, ?( Q# Z5 c
static const short da850_evm_tl_user_led_pins[] = {
" D1 j8 b- r/ ]2 k% Y /* These pins are definition at <mach/mux.h> file */
1 i' w3 [- ]3 b5 A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# M, a: G. H! V; t0 i1 K: I
-1
% { u( B" t' q2 ?};6 R; u4 @& U1 w# X* J3 c
1 L$ {: [# m& x! `
static struct gpio_led da850_evm_tl_leds[] = {
% j( e; V& X, k! j* B: @% }+ t {8 @* Q" W) f# W
.active_low = 0,
$ r4 @$ ?9 a' o1 E! c# ~) Q8 j/ u .gpio = DA850_USER_LED0,
# y: L+ ]& U" y3 u .name = "user_led0",
1 _, E8 r( |" I/ D .default_trigger = "default-on",# e/ h4 J$ M8 |
},1 j% k8 I0 N$ K- y
{
. F- A1 ` C; g: H+ A8 g .active_low = 0,8 m+ V6 B2 t( Y2 m! V% Y
.gpio = DA850_USER_LED1,% E3 e5 L( i- R% g0 R+ w8 Q
.name = "user_led1",
: j; w3 t% v; p& c4 C .default_trigger = "default-on",
5 U- I3 j2 G5 h; Q },: k- {* [ _2 o O+ D: u: H o' X
{9 W- o, K4 x8 Y* P9 y% V; F2 p# k! Y
.active_low = 0,4 ~$ M6 t& R6 w8 V6 j1 r$ N0 S
.gpio = DA850_USER_LED2,
. q; G5 s W( M( u+ r .name = "user_led2",
* r+ N7 R9 r# N, }& P2 L .default_trigger = "default-on",! b7 \) }6 N2 j: _; g- i. k0 e" K
},
4 s/ ~7 ~* G3 \( S" U ~3 T8 g {
5 O# W2 r% X* g# U .active_low = 0,0 u! }4 Z2 [0 W/ Z% c
.gpio = DA850_USER_LED3,
3 g! y7 @# R ~- J2 |- h .name = "user_led3",
; D) ~5 P; | ~ .default_trigger = "default-on",
3 v2 P b6 w2 B6 }$ w3 B" \3 F' a* R },
4 g8 E6 Y x( G6 W3 _) H4 `% f};
3 T f; E' U! Z
7 X" R' E$ @* ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, l1 `! Z" V/ o: a
.leds = da850_evm_tl_leds,
3 L2 b U: W9 l2 w" a( y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 C5 |+ p( q+ W2 K};0 b$ f6 O$ U4 Q2 y$ _' i
4 ]8 X! C) i( p* T3 I
static void led_dev_release(struct device *dev)6 z" ]8 c! @" ^7 M+ y
{- k" C l5 }( m& D$ E7 g
};; _% N& w3 I" c# J) K6 d+ Z
0 w* s% r- _! M$ ?% m+ bstatic struct platform_device da850_evm_tl_leds_device = {* a: X4 T$ d# S+ a
.name = "leds-gpio", f c s( b* s9 U, l
.id = 1,
1 _" d! b o4 m% t/ t .dev = {, W7 w4 O% B. D- M) A: b
.platform_data = &da850_evm_tl_leds_pdata,( m0 ^' K5 b$ Y6 R+ s
.release = led_dev_release,
" y, n# i! M0 S5 }$ E. l }( f5 | x% z& h$ [9 d) ?" w U/ I
};, d0 s* }" i* s9 Q
! H$ k: f# i1 A% hstatic int __init led_platform_init(void)
( O% p5 R- n/ q9 G" i{5 k5 l0 @! \! a: k
int ret;+ I! v0 M- O5 V8 }. a
#if 0
$ [% u9 D( J+ i+ L0 A! V3 U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 y6 o5 r$ i7 e' g# d3 z if (ret)$ i' [9 D. V: d2 K! ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 ~- n! V% c( Q7 J7 V' o
"%d\n", ret);
/ D' ]- N! C0 g) f6 }% m#endif
3 }3 j# f% A2 {1 X% M ret = platform_device_register(&da850_evm_tl_leds_device);
% T% b& E2 g0 n3 E* G- e! P if (ret)
* V4 p/ N/ I+ m8 F pr_warning("Could not register som GPIO expander LEDS");
7 k3 t& A9 ^) ^. i) F6 v. l( X! Z4 ` else; @7 @% h4 h t4 o
printk(KERN_INFO "LED register sucessful!\n");
1 o% B- i' {7 l# V2 A0 g
* ~( q" ~" O9 _1 H return ret;
& G. p) D% F# G3 O}
7 K: h: {5 f6 O% P9 V4 O
& \1 ?7 C- n7 j) ]: U% S3 F* l+ wstatic void __exit led_platform_exit(void)
2 W2 T' N. ~( c{
/ f4 i! P2 f9 I. I& d. U platform_device_unregister(&da850_evm_tl_leds_device);
5 F/ J, \# [, C1 ~& Z2 ^
/ X" C8 w: Z4 z5 O3 y8 P printk(KERN_INFO "LED unregister!\n");
, ]- U( \5 [" r: t& x- l; B}
8 m5 |. P' w2 f) ~/ b$ Z s2 A' N, O6 N* f1 @+ w5 x, I
module_init(led_platform_init);6 d2 P/ j$ e2 ?4 ^$ P
module_exit(led_platform_exit);# |6 ^8 v! k2 V7 o( Z2 s7 y
; ~: F3 x9 g: K" s, _( }: f
MODULE_DESCRIPTION("Led platform driver");
$ r. j9 {: `7 c8 U0 ^2 UMODULE_AUTHOR("Tronlong");3 K2 A% L; s& I4 F x) \ D$ ?# X/ B" y
MODULE_LICENSE("GPL");
: p% K7 c6 q6 n" o6 l( H5 w- F2 q
- |1 d! \ B, C i- j0 P |
|