|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% g( w6 K$ u0 D' y) o1 E
#include <linux/init.h>" [% R. x. f0 s, i. o3 C
#include <linux/module.h>9 m( e( Y1 E# {# `
#include <linux/kernel.h>) i7 i( v- d5 @5 l) ?& D
#include <linux/types.h>2 C+ d) C) X& l8 t; z( Y6 A/ H4 L0 V
#include <linux/gpio.h>
3 z4 C5 i& G5 I/ O9 u#include <linux/leds.h>
# h3 u8 ? p d) h( V6 Y& F#include <linux/platform_device.h>
6 ^ H2 [8 q {5 H1 |$ z5 M- {3 P' y3 ~% Z' X8 S* ~
#include <asm/mach-types.h>
( W; A/ f1 K: B( f. B! D4 O# K#include <asm/mach/arch.h>
7 `: e$ n0 H) }5 m* K#include <mach/da8xx.h>* T$ m$ ^+ D( T1 T6 R) v, d' {
#include <mach/mux.h>
# \% A4 K' Z& l0 \/ `2 H8 V- W3 [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 \ l8 ]+ t+ n1 ?, R' g: M' M7 ?6 r& x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
T/ {9 ~4 t' I7 u& T x9 }) W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) ?, J* d6 U i9 B T#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 h1 P- [4 ]* u3 _
$ M4 r5 _ o+ ]# E/* assign the tl som board LED-GPIOs*/
* T# q0 |+ @+ n6 }! estatic const short da850_evm_tl_user_led_pins[] = {+ B& w/ g0 |- j' }$ x
/* These pins are definition at <mach/mux.h> file */
$ o$ P! C. L* k* f0 N# U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! R: I0 [0 v% z% x -1
P& a* W* M& z& s};
+ R# x6 ]! c t) m
# \0 r4 P! J: @) z1 Dstatic struct gpio_led da850_evm_tl_leds[] = {3 U: j% M( b7 `4 |2 |
{
% k, t5 A6 W: y. ~2 }. P- v7 ^% I .active_low = 0,
6 W2 O: r/ P5 f2 M% `6 R& d$ G6 D .gpio = DA850_USER_LED0,
! x) b& r) F/ t. \) w0 [ .name = "user_led0",
3 `; ?& s! t" z' R$ Z; y# d- E .default_trigger = "default-on",, e) q! J- w+ v1 _* m/ c4 B" B
},* T9 }/ N. y- `1 U: A( m" M
{
0 L+ s( X, }" Y2 N. E% r .active_low = 0,- o2 _8 u" r/ T C5 T3 i. x8 p
.gpio = DA850_USER_LED1,' l" M1 T+ Z: m2 P9 V& O5 D
.name = "user_led1",. b" ^* e' ^$ ]$ o! ] F
.default_trigger = "default-on",0 ?8 {& k+ s. L; S. H, V" Q
},$ Q: G i/ o1 z9 [# R b
{$ |3 b. X. y/ p/ ]: B/ Z/ r) `
.active_low = 0,; X3 T3 j) s' J* J; f, n
.gpio = DA850_USER_LED2,4 H( m' x Y7 |% O
.name = "user_led2",2 {3 M9 ?; X# l$ s' X% F
.default_trigger = "default-on",
8 [/ I8 g3 F* l, R },1 Q' s, Q& d1 r E8 h; k' A3 k
{0 y. K9 p- s' v$ h" r
.active_low = 0,
5 [5 X: o( _* K* l .gpio = DA850_USER_LED3,
, ^! X; |% k0 y* K3 Q3 P: J .name = "user_led3",
, ?5 y2 u1 B: z+ D4 \* b+ ^ .default_trigger = "default-on",
5 v9 B4 z9 a! u },9 O+ B8 _5 K( y7 Y2 D# a5 d! _
};2 e# p2 }" S5 t* N( Q" h
x- N: b! y& i* z! t; f8 f" E8 F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# S, v' Q6 Q5 w& H! {& f* o
.leds = da850_evm_tl_leds,: E8 s- r7 K2 c& d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 |$ @! l: K% x6 r- R4 f};6 Q, D; y- r/ y- T$ @+ G
2 e% z1 Y8 n0 H, Y9 ~static void led_dev_release(struct device *dev)/ O% t& D4 ?8 W9 o1 n% Y
{
; i/ i/ @, x! M' I$ I, J};- ~' `9 M2 c/ {0 J
# M) M! ]* Y5 [! nstatic struct platform_device da850_evm_tl_leds_device = {" i* k" n" y1 P- _. r
.name = "leds-gpio",' F2 t F9 g8 {" v: N$ E2 P/ Z
.id = 1,
7 D- l" L' E! B .dev = {/ `, C2 }% L+ n- i
.platform_data = &da850_evm_tl_leds_pdata,
# x% F( I, J. o3 b: v' R .release = led_dev_release,9 r8 _8 l0 Q5 J: V- M" \
}" S; [4 `; t" ?3 ?$ U1 ?
};4 e8 D% ]' S% Y2 A% w0 w
6 x: v+ ^4 V D( v% c* sstatic int __init led_platform_init(void)+ |% P. M8 s; Z2 Q1 A. \/ ^3 z- ?6 q
{
" v; Y9 Y- _+ G- \5 F/ \( { int ret;$ e [7 E7 |) y+ E* a% Z1 X& ?) c
#if 0" A$ M5 `2 ~" E. n, U% f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 v4 H( }: p2 p( Y" ^4 ?; y if (ret)
+ n' e* I0 z8 e; D pr_warning("da850_evm_tl_leds_init : User LED mux failed :". q& G- i" i7 B v1 {9 F. H) r: Y2 Y
"%d\n", ret);3 {. a2 r& U3 V/ }/ U
#endif
. k$ z( {2 F# k! p- ^ ret = platform_device_register(&da850_evm_tl_leds_device);- X4 o( l0 M/ e( h
if (ret)
6 N: Z& g3 U$ x0 j2 _8 \* q$ S1 ~ pr_warning("Could not register som GPIO expander LEDS");
: `3 v: c% S% |: A else
8 U( `% L+ ~+ [( q3 @3 A# } printk(KERN_INFO "LED register sucessful!\n");
$ F3 s, Y8 Z2 E' r' E" ~$ `: L! _% |* q# a% V
return ret;
5 j( G& g! {! p* _}3 ^% M( m, U J) ~5 p0 m
1 |0 e; l Z3 Y) G) pstatic void __exit led_platform_exit(void)
* h, J7 N) {; a, ~. ]3 e{& F8 G( w" i' m y# A
platform_device_unregister(&da850_evm_tl_leds_device);) E, [7 J3 y4 { T, n" ]
7 h6 S" V1 v2 Q$ D2 q$ k
printk(KERN_INFO "LED unregister!\n");/ R# b+ m8 O7 w/ n
}
" m3 Q2 q) ~8 X( Q5 @* C
% T4 i' r% E8 W3 y9 R, q/ Xmodule_init(led_platform_init);
; k% l1 v3 Y! y& Pmodule_exit(led_platform_exit);, C3 q. w, W) N3 J6 E. p/ D( Z* i
0 I' }" k; K5 M a! `
MODULE_DESCRIPTION("Led platform driver");3 {$ y g ~( o o
MODULE_AUTHOR("Tronlong");2 {5 {: D' A0 D/ G* I# g* ~3 x
MODULE_LICENSE("GPL");0 J% i4 k. M: }3 X
* `! ] L; P, ]6 N6 p7 I I o& n
|
|