|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& W8 |# `' _2 e6 n* m# p! A+ L/ u
#include <linux/init.h>9 ?9 j% h7 T5 o& E! z4 a8 O3 F
#include <linux/module.h>
+ ]1 P u& o/ I# O+ C#include <linux/kernel.h>4 [2 e: ~0 Z9 q+ A; I
#include <linux/types.h>
7 H/ [8 _6 L/ h) t. M#include <linux/gpio.h>2 }1 p8 I% T# b7 M; a# W: L: X5 }$ N) m
#include <linux/leds.h>. l! I+ H& V, ?9 \
#include <linux/platform_device.h>
$ U; n+ K& _$ G$ i( K" s7 L( Z" ~) r9 ~6 r
#include <asm/mach-types.h>, a" U& [! F) I
#include <asm/mach/arch.h>
" a1 M I8 J; a8 c. O6 Q4 q& ]#include <mach/da8xx.h>
7 f: M; P3 n, f1 g#include <mach/mux.h>
* Q5 t5 {, }" z* ~. h( [& h4 Z' T
4 V' n# c* \5 ^6 Y1 j; x' ? v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 C) t) R2 U/ J" q, O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 A" o, @+ K- j3 k/ {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ t8 ~" w- z/ G5 U% N% ?8 Y8 }) l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' A- }/ ?5 r7 t3 u
/ o* u! e$ z T/* assign the tl som board LED-GPIOs*/0 y+ f) ^2 ~+ K# X# O5 |
static const short da850_evm_tl_user_led_pins[] = {
% J$ n& S) e; X, d9 z9 ? /* These pins are definition at <mach/mux.h> file */
* ^1 l+ C0 V8 h5 q' Z" |" D. }, M) d* C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 i- `3 @" ]; B
-1
4 i+ v u0 d( X: A};
! ]: m. M) b2 D" ^0 e1 g7 U" i b5 O: x& c6 ]4 @
static struct gpio_led da850_evm_tl_leds[] = {9 q5 U" A7 |- a% b9 N( f3 i! z
{. N* N! j* U7 ^7 q
.active_low = 0,# ^; U5 @$ `/ i1 ^6 y
.gpio = DA850_USER_LED0,
( n# E+ O/ v3 _7 f5 W) Z+ p1 L .name = "user_led0",
: ^/ C9 \7 f: t* c3 g# ] .default_trigger = "default-on",
5 j# X" p- h+ C8 ?4 a: Y3 l1 s },
5 ?6 h/ f) U. V5 [ {
% M) U, G% I v# V' s" U .active_low = 0,
# K& C& Q* _ |* p/ U& U0 P .gpio = DA850_USER_LED1,; w. O/ \; J3 W6 {
.name = "user_led1",
4 u7 d: f5 `8 e- ? .default_trigger = "default-on",1 a% j3 H- c) X2 Q( u9 |# E
},* Y0 e4 Q2 F. H# r& R' p4 F# u8 s7 X
{
7 p2 f1 a4 T1 m1 t u) S- q- ?6 K7 } .active_low = 0,4 J/ n/ x; v" A5 q8 o9 i b
.gpio = DA850_USER_LED2,
; \( Q; R8 T/ F% c .name = "user_led2",
% a- m( A) R, _" C+ \6 Q .default_trigger = "default-on",- c2 M* u2 H; D' P% M3 i- y
},$ [) o3 e5 P! p& p" C9 ~ q
{( L8 i; B. |6 t. r$ q* I) O) y. G
.active_low = 0,5 B& o1 D" G& ^& |- h) ?' g# V
.gpio = DA850_USER_LED3,
$ _9 M& j$ H) W$ E' F .name = "user_led3",4 L* t2 t; w! Q( ~; C5 y$ i
.default_trigger = "default-on",# Z* [: s v% [5 u
},
- ]0 O' [& y0 J};% S" p, g& f4 [/ ^ }
: h( t3 N. `; L* b; x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 C6 k) D/ T! W5 |' o0 M .leds = da850_evm_tl_leds,/ q1 A, U% h# d8 c% D" L' u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& g/ t6 o$ a; b6 J& ~. w};% S# v* c( L" f4 _( B) ?. _
. v3 x; Z$ ~+ U. a8 n6 V! D6 O
static void led_dev_release(struct device *dev)5 V' }! I5 B5 o5 _
{/ c1 V$ C4 }; K) d0 W3 j
};
6 Y4 I7 ?: ~0 P1 J6 ]- g h4 k
+ h7 S+ S: ? L) y7 K e3 Pstatic struct platform_device da850_evm_tl_leds_device = {
% y9 P+ t1 e) Z; d .name = "leds-gpio",, D+ \+ J2 B. {# g7 z
.id = 1,- t& X& R2 {0 n% K* B, w" q
.dev = {
" E3 p; L+ x1 k .platform_data = &da850_evm_tl_leds_pdata,8 e0 Q4 g( _0 f; M, Q8 M
.release = led_dev_release,
4 a* U. K# S Z& i4 A& K }# g& L& F1 L; ~$ ], F# h) z! h
};
6 B9 u: Z, [) a5 \+ U3 W; w c# j1 \3 g
static int __init led_platform_init(void)
8 C& ?3 P' {" t{$ J6 @" ]# W/ M2 r3 z9 I
int ret;4 V5 h$ ]- @7 `7 I$ M, C
#if 0
# o1 L' c3 r! D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, Y6 ]' g, Y5 \' C' m& `8 y
if (ret)
S" ~8 ~: J, Y+ Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 D: S. p4 p7 [! F. A6 Y1 a; M "%d\n", ret);) T2 [( l/ W' g3 z; [
#endif
3 }0 @3 c. a2 Q/ N8 x ret = platform_device_register(&da850_evm_tl_leds_device);
S$ n' Q4 Q2 _: I4 U( G if (ret)
5 h% K0 X( Q, D/ T, w' e, K/ K pr_warning("Could not register som GPIO expander LEDS");- Z4 g- F. E" c% {
else
( B0 A& ]0 h. k+ S printk(KERN_INFO "LED register sucessful!\n");5 D: f" `( F" A
3 a, H. K& |3 K! o+ Z$ \; X return ret;
) y. K* t/ Z, d6 r}
& Q; Z3 F% P( i% ?6 `$ ~- }8 J- d& F9 T3 s$ [/ d0 s
static void __exit led_platform_exit(void)+ B* u4 Z( z0 f8 y6 a/ }' B: a3 u
{. ]7 n n. ~, e& k) {
platform_device_unregister(&da850_evm_tl_leds_device);+ n# y8 J& T M$ i' E0 _7 }8 f3 A: t
' H9 O3 S/ ~" n t6 F
printk(KERN_INFO "LED unregister!\n");
7 w H" v- ^/ k7 k1 [3 h# x) M) n}
* f7 A& f1 |- Z9 ?: q9 |( U4 A* D- W. G
2 `1 }' b" Y& ~' a+ E& Amodule_init(led_platform_init);6 T3 z( |3 r; U# M; w: y
module_exit(led_platform_exit);
1 E8 x# a& t( [% X& [' w% }
3 R% g( d2 i: F) W4 HMODULE_DESCRIPTION("Led platform driver");- k( G/ |6 |, S% B2 D# U+ v4 X
MODULE_AUTHOR("Tronlong");
& U. \% t- a8 c7 C( eMODULE_LICENSE("GPL");
9 L# z. ~9 f; D$ N* @% y, Q# m7 b! f' g& w6 g ?' [
|
|