|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 J7 O2 \1 X$ F, ^# g+ f+ _# I5 N#include <linux/init.h>6 ]/ d; V$ F( N9 L! X* r3 q
#include <linux/module.h>- n# S+ t6 x& v% `6 Z
#include <linux/kernel.h>% |3 I' H6 u' Y2 j2 Y5 \0 ~7 g
#include <linux/types.h># M, m. |2 W. {7 W
#include <linux/gpio.h>$ a8 C( t& j, r8 _3 @3 C
#include <linux/leds.h> F: D% _5 j, z- Z
#include <linux/platform_device.h>
( o) H9 ?, t3 |: G9 Z
2 T6 T# H3 h: J5 ~5 b#include <asm/mach-types.h>
- Z5 {; J; u1 Z1 f- F6 l#include <asm/mach/arch.h>% g O9 f: X9 U: F
#include <mach/da8xx.h>
/ f) L" N( ^+ b c" B/ l1 {#include <mach/mux.h>
) H5 N, s& t; T5 k* D( ^, u, \/ M" f3 M z( J/ A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 q5 i% K5 | h2 N2 F0 X9 v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ k) S" f r" S! H, a$ O9 p1 {- v2 g. x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ U, N' c7 ~2 c2 X' S) i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 m$ Z. T/ r7 e+ s; Z& k
' I& F( O4 W7 _$ Y1 [/* assign the tl som board LED-GPIOs*/
6 L4 |7 H. p" _/ q, I, C2 vstatic const short da850_evm_tl_user_led_pins[] = {2 V* t, c, h4 u) w5 N, l" {
/* These pins are definition at <mach/mux.h> file */
3 `" E0 x; d% S' G u; y- ~' n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( L w2 F& A- i3 t -1
, p' G0 D! G* [# i};
: `4 S9 j+ P) b- d5 d0 k' `* |$ I2 L3 z$ M" T9 j
static struct gpio_led da850_evm_tl_leds[] = {
& j* w4 U$ f) @6 C& Z {
3 O$ d. f$ a* n+ _# M0 G) z .active_low = 0,3 i# k# \& b" Y, ^6 P% E9 W
.gpio = DA850_USER_LED0,
$ r7 P8 e, L i& @: Z/ {. h .name = "user_led0",
5 f* D( f7 S0 D$ S1 ? .default_trigger = "default-on",
# k3 i5 i" p; b% V b- U1 `0 W },
% I9 V) r4 l& w3 p& U9 _ {& x! r( s1 R6 f
.active_low = 0,
( _6 S5 T3 ]$ J1 R: o5 Y .gpio = DA850_USER_LED1,1 s# j* x# h$ @3 N
.name = "user_led1",( G o" d8 Y" U7 s" Z
.default_trigger = "default-on",9 w+ ^1 M8 U f2 C2 ~
},. c3 t" Q7 o& s
{
9 Y/ L' C5 v6 B+ Y+ Q' m: I5 m6 N8 T .active_low = 0,
1 B* C* E# c { A .gpio = DA850_USER_LED2,9 n/ ?6 C4 \ O* C9 ~* r- J
.name = "user_led2",
1 L& H; T+ o9 t4 J) c" i/ t .default_trigger = "default-on",
7 K. P! s* f( f },
5 [, w4 `% J5 I& j( z {* k& r* Q, ]- a( d
.active_low = 0,. ^ g- s$ Y% a: c
.gpio = DA850_USER_LED3,
, I& c2 S- {9 M" L- S .name = "user_led3",
" v! Y; f5 x, W3 \ L# a .default_trigger = "default-on",
: V/ l, \8 _0 M% J3 Y },3 P# s, }, s4 I, \
};& H6 t7 p1 q6 s; w' F: E9 P
: w& _2 i- V& o1 A, y' ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" d# |7 R3 z# W .leds = da850_evm_tl_leds,( K- [4 u4 h, h' b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( o/ m, K5 m2 G- F3 v# K; g
};
$ u: E* ?* t+ ~7 V; y* T3 B
3 `" h5 n9 S) a- m" l; Tstatic void led_dev_release(struct device *dev)
2 a. m9 H# s: j' r+ S3 u* C{
+ y' D. _/ P. z. `) r};
6 N5 D) ~; m Z* y( q# R- }7 e& L- P, a f3 }$ t; B
static struct platform_device da850_evm_tl_leds_device = {
; W( e" v+ }$ X* l .name = "leds-gpio",
$ s7 r" ~2 |5 u9 p8 o; V .id = 1,1 m7 o, K4 G1 E2 p7 N1 d. L
.dev = {
# h. N& ~! Y1 \ .platform_data = &da850_evm_tl_leds_pdata, \! `0 x5 s7 A% \9 A: N5 {
.release = led_dev_release,
+ s' l. V9 \1 ]- x& h) ? }* X X8 } S/ P) Q: d5 L
};4 @* ]+ m2 @2 p4 g
5 m+ F9 x4 m- H4 x
static int __init led_platform_init(void)
4 h. n# U4 m* _% l6 r$ l8 A{2 G5 v, Z7 V$ x P( U: Y+ T
int ret;
( A4 U$ v9 p: L7 q0 ?( `2 d" R#if 0* M0 L* w2 l& }) A, n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- W7 F8 e% N6 A9 I if (ret)
" k# G7 h8 x( G j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
w5 x1 K7 k) O8 X, G# e' a5 X "%d\n", ret);
$ @ R. _. R! Q( |! g#endif0 h9 B5 k: h$ L7 x& [5 P o. {
ret = platform_device_register(&da850_evm_tl_leds_device);8 }0 y, U+ k* x4 u
if (ret)
+ v+ a3 ], G R3 ] pr_warning("Could not register som GPIO expander LEDS");
( P5 u: r7 F2 d! v else, P! U7 c" T' X7 H* r6 c0 P
printk(KERN_INFO "LED register sucessful!\n");
1 \& |& p: f) d' p k1 b: R2 o
, \9 k% U5 X# T) T6 b return ret;- n' D9 v# {2 p9 p
}' n0 ?2 t/ E& m/ V" f
: F( E# r0 @# F( u' p' kstatic void __exit led_platform_exit(void)
/ s* U2 r6 b$ ?) ~{
, V- H3 |: F, Y0 b" [; l platform_device_unregister(&da850_evm_tl_leds_device);
: i7 L' U( ~! b4 g ^- v$ C2 ^
/ H6 ~8 W7 I3 c! O( S: [- ~* q printk(KERN_INFO "LED unregister!\n");
8 _2 H1 f8 P- n) n3 S}: H- ]. D, B/ m. X% C
" E9 `' x( e) d4 @8 F
module_init(led_platform_init);
! r) x3 h5 _4 j) s) @2 x8 ymodule_exit(led_platform_exit);
3 k" C. N6 N! }0 w0 {! L' p2 c q0 K$ g: E6 R9 l- N% A4 {
MODULE_DESCRIPTION("Led platform driver");, X( S1 w$ d. @( g# a
MODULE_AUTHOR("Tronlong");' t. o: I$ R1 l9 t
MODULE_LICENSE("GPL");
* A: l2 `6 E- D: q9 A; j: U
* [0 e6 }$ L" g' h2 f) Z |
|