|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. d/ R4 l9 f: G5 m3 f0 y8 l0 v0 V" e#include <linux/init.h>4 b) ~8 D K# d# r) x: P
#include <linux/module.h>' H) P% \; P8 U# R- \
#include <linux/kernel.h>7 X& l* F* ]. {' Q) w& Z& f
#include <linux/types.h>
0 k! |2 A: {" y#include <linux/gpio.h>
% v' v$ D9 l& u* ?9 w#include <linux/leds.h>! o8 O q* k1 {3 ]+ R9 x; J5 f
#include <linux/platform_device.h>( y9 A$ \ S1 ~" m+ v* B- [9 s
& G3 b* I8 c5 D' m#include <asm/mach-types.h>
0 @# m2 ]4 c. J. j#include <asm/mach/arch.h>4 ^$ I, H$ g- G' V6 D' Y" x4 \
#include <mach/da8xx.h>( _# @" z3 a& Q
#include <mach/mux.h>
& X3 g0 q% s" J+ U
* C/ N+ @: t1 j1 d& `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* m. O7 L- z7 [! m' u2 V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ c4 p* }; x( g" X% N; r3 G& r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# Q$ W ]0 t( |& I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( g, N; U' l% V4 X! z3 M' A2 {% V$ W) n t/ _$ b* B# i
/* assign the tl som board LED-GPIOs*/
+ Q2 T; [$ B( y. V) t1 s2 \$ Istatic const short da850_evm_tl_user_led_pins[] = {8 W8 t3 t) X2 X" K3 D& c$ a
/* These pins are definition at <mach/mux.h> file */' X/ e1 A- q$ B; R; T1 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 ]; T3 s& |, Z7 D, ^ -1" P: a0 M/ N0 ^8 B6 y/ q, @0 C9 p
};3 m# U6 Z" g1 `
* p3 a- v: N- K' wstatic struct gpio_led da850_evm_tl_leds[] = {
9 G3 J. q$ R) t! b {
; E" Q1 ?) d, F, F' o/ i .active_low = 0,
% v1 n4 h; ^$ g$ t" s3 E" l* } .gpio = DA850_USER_LED0,
, U5 X v0 H# A/ @/ ]5 n .name = "user_led0",: q/ j+ I3 H2 g5 U5 X% I1 Y" y
.default_trigger = "default-on",' V$ w- H: k$ H @' P) e
},/ f: u* \. e* [- D/ Z/ E& \
{1 M$ U9 x4 d8 S( q# v* _, Q
.active_low = 0,
' F8 F, ?) ?" [ .gpio = DA850_USER_LED1,) R, x/ E. J- N) o y2 a$ a
.name = "user_led1",: S/ n/ C8 J* @5 B8 c, O0 `8 ?
.default_trigger = "default-on",0 {, u8 p5 A% P9 I$ C& V$ c
},% V6 h1 B+ }. d6 C% b
{
( R+ g7 e. K! Y0 V3 N2 o0 G .active_low = 0,1 l" t- ]( `7 s5 W
.gpio = DA850_USER_LED2,7 `' D9 n8 g: v) p1 O
.name = "user_led2",# B/ [ Y+ Q1 r3 p
.default_trigger = "default-on",
: w( A2 \- v1 _: _' I! T, w4 C. @ },
$ B: E( j' n3 ^8 w {
, l& L/ s3 x: z& P, i- y w( M& a .active_low = 0,9 Q& z# S) t1 c. R
.gpio = DA850_USER_LED3,
% `$ R4 j4 W) D" u( V8 ` .name = "user_led3",
# C( ^% K" P% u% t7 h" ^ .default_trigger = "default-on",
/ U- Y8 O/ E+ q8 F },
6 E: u# ^1 W. [, r' d1 T) b};6 R4 O4 V) {: s5 E: q' r
* V5 e+ l4 e2 W5 Q: h, x! Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 T- o. M1 m: S, f# B6 Z$ q .leds = da850_evm_tl_leds,
2 S- K8 \( b' D+ @1 l2 o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- v% ^( U% Y5 N" D};
/ c4 c: l/ X; A2 \3 I
7 Q3 s u: a; Ustatic void led_dev_release(struct device *dev)
* x+ B) x9 k) y# Q{
5 B& V7 s$ e7 B7 @, O};( l8 r/ o5 y. O3 B0 ]: s2 A }/ ^
* V2 u9 C& J9 q2 T0 f4 X" z: B$ H" Bstatic struct platform_device da850_evm_tl_leds_device = {
$ L0 [/ `- H- ]8 E$ \; G, [3 Q .name = "leds-gpio",; L/ I1 i% Y1 e% ~ h
.id = 1,
( C, K9 f# \) {4 F. Z/ w" C .dev = {9 i* S$ A3 s3 R( A# a; D
.platform_data = &da850_evm_tl_leds_pdata,
: E$ z ]! q+ w, l .release = led_dev_release,
2 g3 ]$ ?- F; d8 s( E( K }
" Q/ N( I5 G! d: K' Z' j8 Y! {* |, A};0 ^9 F2 X1 w' O6 D5 X4 L& k
8 ~3 @4 ]( I3 R$ L
static int __init led_platform_init(void)
% |' @: Q6 M% j) Z4 J{& q% u7 b& n# E" C2 Z, z
int ret;
N1 x. {) {' q#if 0
d4 }0 X& f& W5 j3 L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ J) a. y4 h$ ?7 |* g
if (ret)
, _' K/ r: T2 d) S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 N4 E' {: [* c: W "%d\n", ret);
. r( B9 X( y) L1 V A+ r#endif7 H4 M% ^0 A, j. a. y" z
ret = platform_device_register(&da850_evm_tl_leds_device);
1 J) R+ o6 e9 o, O" {' j if (ret)) c- ?* W( m8 b8 k
pr_warning("Could not register som GPIO expander LEDS");4 O$ u/ M4 I% ]" p
else/ O; \' Z! A- R4 m$ y
printk(KERN_INFO "LED register sucessful!\n");
: ]- O% s3 N: b3 |2 W$ t- W; K* ?6 }/ \/ u; i( f
return ret;6 \& `9 _) W' A( D/ `
}5 {0 V3 x) m! a! q5 e( @
6 y" i% V. p& F
static void __exit led_platform_exit(void)1 F. A8 }3 v1 E% E9 F& X, i
{
% N8 o& ^9 M, r( o% R& _( h platform_device_unregister(&da850_evm_tl_leds_device);
' p8 o( D5 w4 i5 j, `2 Z# G' K0 z$ S7 l) s1 c( e% x7 T, E
printk(KERN_INFO "LED unregister!\n");
6 ] H& w# t5 R8 S}
3 O1 p1 J7 c1 S* D/ @4 f# R* k6 j4 {! K# Z$ [6 R
module_init(led_platform_init);
! a) R, v. P! V7 z5 r4 N& Cmodule_exit(led_platform_exit);
2 G$ X5 U: W2 l4 ?
, ?3 U/ o8 `' P/ O2 MMODULE_DESCRIPTION("Led platform driver");
1 d2 t3 `. q4 }! E0 kMODULE_AUTHOR("Tronlong");
3 U" ^) {( |# L T, q: Q" {: {1 XMODULE_LICENSE("GPL");
! v# y& ` F5 [* V* q/ Y8 y/ g5 f3 l; I9 j2 B0 ], v, A+ b- B6 M, r- k3 O
|
|