|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 x/ V% A, `) m) }#include <linux/init.h>
% _8 \8 C7 S( n! D% ]#include <linux/module.h>+ h/ V' Z: v: W$ i5 V# H ?! A
#include <linux/kernel.h>8 y+ \9 y1 D! O( N
#include <linux/types.h>
8 J: K [/ g. O5 i0 [$ V#include <linux/gpio.h>
8 j' w* M& R! z4 V9 r#include <linux/leds.h>: t' |9 S7 X3 x% c
#include <linux/platform_device.h>
* G# [0 [: l, H% |6 D& G
' B! l: r& G2 i9 T9 `#include <asm/mach-types.h>
* E( D2 J! y* p7 E/ d+ P v#include <asm/mach/arch.h>
c' X# X4 I/ x4 y4 U0 `' F' z8 s7 X#include <mach/da8xx.h>
( z# s* g. n8 a( b#include <mach/mux.h>. y; Q; A. F3 S6 E( ~" ?5 b
$ F4 q3 F* i7 A, k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 A2 ^ @) ?5 ]- n% V2 J4 e( }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' {- e: c5 W8 y* e5 g% S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 |3 q% x8 k) m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 G1 ~4 T! r# `
4 K# }. m3 y- Y# y/* assign the tl som board LED-GPIOs*/
/ @1 e1 h" q' F, A+ J, Istatic const short da850_evm_tl_user_led_pins[] = {( n$ ^9 R, t( {1 ]1 u
/* These pins are definition at <mach/mux.h> file */
+ a+ o* K, |5 a) C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 |, L: D9 _9 I, q$ Z! ~
-1: L d8 g+ t2 i% K* S
};4 y' q2 ?8 O! [9 ~# w8 H1 J
6 [- o2 ^- ]: |9 X* `/ y
static struct gpio_led da850_evm_tl_leds[] = {. W* b: _4 o% n* L# p" {9 @
{
/ U1 k: Z8 X" _% D" K3 t+ P .active_low = 0,
! z# Y9 j! @6 w' V/ u .gpio = DA850_USER_LED0,$ G# R) x5 P( g& L4 y
.name = "user_led0",
& c7 @: Q/ j: f1 C0 Q .default_trigger = "default-on",
/ i2 o% h: J, o3 L },- P4 [& y$ ]- D3 T1 e
{1 n# h T. H+ b& r; J
.active_low = 0,
' G4 R* y* Z, X- W .gpio = DA850_USER_LED1,. X* E$ o) t, c/ ^
.name = "user_led1",' g* D7 {* ?+ j# D1 b+ H# H( W3 s! B
.default_trigger = "default-on",: T: Z2 d& A0 \9 V/ x
},) a2 T1 q+ M8 I( y
{: E4 g# o' }( f( s b
.active_low = 0,- g j! `3 n1 T; \3 a( P+ A8 ]+ J
.gpio = DA850_USER_LED2,/ W! a8 k! {: I/ _8 B" c
.name = "user_led2",; u, b; n. X0 B
.default_trigger = "default-on",
( A' W3 m: s0 {/ s+ Q+ s" f2 B/ ] },
7 o! C4 [/ E0 w {' D, m ]" s* m4 s/ ~* K
.active_low = 0,* \5 F5 f5 E1 p- P8 m: U8 N
.gpio = DA850_USER_LED3,
6 q: y# ?. W6 H4 c2 ~$ \3 F .name = "user_led3",
0 s$ l% |4 T7 { .default_trigger = "default-on",8 D$ Z' P( g& b7 A# w
},
. f% V3 n3 e3 P5 h$ D% B0 C9 Q: [};2 ? F& @) Q. y9 {9 q* j
# w* N! P- A8 a# ]# R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' Z3 v( B. l% _; \
.leds = da850_evm_tl_leds,
$ y; v' f0 B9 S" N% c: Y5 P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' I0 X; Q: I+ N6 D6 _3 v
};
9 t1 }; e; | n$ e( f2 c! D3 |( o* t3 f( R: u& x
static void led_dev_release(struct device *dev)* t/ Z k# b* _% ~
{+ V' c2 M- M1 V
};* Y$ s( P' _4 E# _
6 l- l9 M3 F+ {/ n3 ~! M. \
static struct platform_device da850_evm_tl_leds_device = {
1 _5 z% e$ q$ b .name = "leds-gpio",+ i4 U. w& a; W1 @3 c$ ?3 z
.id = 1,
! F+ V% X) j! O _& j0 c3 a .dev = {* W" @- H* b, x- q
.platform_data = &da850_evm_tl_leds_pdata,9 q- A8 @+ E2 ~. n# u, Z
.release = led_dev_release,
* A$ a1 ^7 F8 Y0 U( o$ F- W }' G. |/ O; x. m k9 q9 K) Q
};' s+ W5 }* J/ |# Q6 j
" j# q5 S6 L0 {/ }
static int __init led_platform_init(void)
6 H# i+ ^- ?* A' Y( K. Q5 {7 \5 v{
- i/ y3 j0 z% H7 [+ r$ I! n int ret;; n& D7 y/ r( I8 c) a+ ]- b! L
#if 0/ ]& U$ m! g- ?$ \* z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# S, B T- S& u2 q$ s$ u- |
if (ret)5 i( b( i( t" A$ ~9 W, h; x* R0 e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 r `9 t P8 k4 U4 ?! Q "%d\n", ret);
# m2 l) @4 k- s" Q7 b0 Z) S#endif. N3 p3 c" A' Y, ^0 Q, |
ret = platform_device_register(&da850_evm_tl_leds_device);
0 X# Q: c5 X0 s& Z: a+ @& v' ^ if (ret)6 d1 r0 h2 ~; E
pr_warning("Could not register som GPIO expander LEDS");
5 g# E* U6 o0 i, ^( H else
0 _3 P4 x1 ~0 E6 F printk(KERN_INFO "LED register sucessful!\n");1 ?8 V/ ]$ i4 I6 n0 e/ C* y5 }- D
. ~3 J) W+ ?2 ?- a: w+ P# s& g
return ret;
$ y7 R0 _( {. Q}
: R9 t6 [ D5 P4 d4 \8 Y
, u. H) L# u5 i; Mstatic void __exit led_platform_exit(void)) l! a0 [; `+ f2 p; ~
{
- Z( m; m7 ], M$ k, h) ] platform_device_unregister(&da850_evm_tl_leds_device);
M* F6 `. [0 Y6 K) ]
3 g3 U! |+ o( }1 @- t: ~* J9 p+ H printk(KERN_INFO "LED unregister!\n");
& ~0 r* |" b1 G. J; u; L}( a3 x3 P+ t, O
5 [. L# n; F' _0 J
module_init(led_platform_init);
8 p3 r4 ?! k! Vmodule_exit(led_platform_exit);# Z/ W% E" |7 a6 W# }0 D% R
8 T% M* S# A( N, s3 \: z# h
MODULE_DESCRIPTION("Led platform driver");
, f- W+ a8 I4 O0 w3 k% fMODULE_AUTHOR("Tronlong");+ }6 v% r \9 ?& C: o
MODULE_LICENSE("GPL");, H& |5 e7 P" t
& |/ ^% z# ^) j# G, L- X( K |
|