|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% V# u2 x$ F$ ?" K0 d* b! {
#include <linux/init.h>
* p! |) [% X3 F2 B5 J6 t#include <linux/module.h>6 Q# E$ B$ w( |" y/ W
#include <linux/kernel.h>% x& ]$ y& |. N; L
#include <linux/types.h>
3 g# P6 W, t4 @2 c' k4 W0 l. Z#include <linux/gpio.h>
2 `% _( ~9 E8 Q0 M4 F$ G5 v" H#include <linux/leds.h>9 z' O9 W6 z5 ]0 `; o* S
#include <linux/platform_device.h>
! V5 L: A6 B" @6 p4 K3 S' s( `6 A9 e! T, w
#include <asm/mach-types.h>
" q* w: i# K/ M& j% I' {#include <asm/mach/arch.h>
, a9 @% t7 w# B; k#include <mach/da8xx.h>9 f0 f/ X& f( O3 l8 S9 W# X
#include <mach/mux.h>
- D! A+ N$ \1 ^
" i4 g4 c, Q8 V$ \7 x/ S#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ c1 N$ ]$ }# i0 G& g( Q4 }; W: c( v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 y t9 A! p) i) S+ i2 B( W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- u- z3 B7 n/ J4 i* A# `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 j1 I/ Y3 z+ d% t* }- F, g* e
' x( a$ |% Y, w5 }7 C" H/ m2 x
/* assign the tl som board LED-GPIOs*/- H8 e- k# B; H5 L0 Y3 v+ ]
static const short da850_evm_tl_user_led_pins[] = {
; O. \6 @- N& g1 T- P. r /* These pins are definition at <mach/mux.h> file */
8 A2 C& ]5 s) [" i4 x* u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 R6 c# N7 R0 ~) f2 D( Q/ J
-1
7 r5 E/ H# S: a& H6 e: Y2 c& `; h};1 u. q4 e* R; U# |+ x- w
. d/ L) v9 r( Z! j9 w0 A- |: s {2 P. Z+ `static struct gpio_led da850_evm_tl_leds[] = {
5 E5 y; T; ]* f5 A' t. c0 p; _ {: n |! Q+ s9 [2 H4 E d
.active_low = 0,
% c8 q6 ?7 L5 R! G% s .gpio = DA850_USER_LED0,. {! G6 ?1 U/ ?3 ~7 `( }8 U7 n
.name = "user_led0",
/ K: }# a/ W4 J. e .default_trigger = "default-on",
0 K/ x7 S7 P' G6 q# @ },/ d# U1 S0 s$ O# p9 h
{- u5 v& D: s9 J5 R/ I! H/ u
.active_low = 0,
' `1 W+ x+ ]1 _# _ i5 J .gpio = DA850_USER_LED1,) Q8 ^+ [/ l, j& x0 T
.name = "user_led1",
8 e" u6 g% c/ x/ | .default_trigger = "default-on",: b, ~3 c8 [% u) T
},- k8 h, K6 @0 g$ V s
{
1 \7 C7 S6 A' i6 h .active_low = 0,
# w5 [4 D( B2 ^+ R .gpio = DA850_USER_LED2,
t5 L j9 ~2 Q" X( H. L/ z4 a# A* e .name = "user_led2",$ Z9 ^ {- j( C( o6 V. R( F2 b g
.default_trigger = "default-on",$ A4 K1 Y; @# J$ F! t
},
0 ] K t/ U2 y9 a" ?, D {
$ ?. \7 f8 l1 ]5 b& ` .active_low = 0,
0 j9 s$ Z, I8 ?7 F6 D. X .gpio = DA850_USER_LED3,
% z2 G& a# K! p1 p) J .name = "user_led3",
7 K! ~9 X3 n& q. z .default_trigger = "default-on",
! v1 h9 X: { d. l; R },2 c$ H9 |" K( c
};( z7 M- `6 D* {# {( u
9 a7 [# Q r: {4 g f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# m# i7 v6 r$ N: m2 z/ I .leds = da850_evm_tl_leds,/ e: s' V. T ]4 M* a6 q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- `5 M& r: q" o4 s1 B( Z( x
};
2 {/ K; `8 R7 q% z# h& n$ \
9 ]( o7 [6 w+ j8 q, V Astatic void led_dev_release(struct device *dev)
$ e5 H" e* ^. f2 O! V{
; \( t4 f% x5 x& R6 K};
5 t) X' b) U0 I, ^$ B$ \4 L: b2 U1 E" c
static struct platform_device da850_evm_tl_leds_device = {# g5 N1 w, [+ F9 K% b
.name = "leds-gpio",: e4 d9 h- m8 A% S; Y. W5 s) P
.id = 1,- \- `3 u/ Q: s3 p, S7 W0 C5 W
.dev = {+ o, _/ S" d! `8 |/ ^4 ?
.platform_data = &da850_evm_tl_leds_pdata,
3 N9 _5 _; |- N0 r .release = led_dev_release,
# q+ V: j3 ]- E; j. T }4 l5 u" A0 t# g
};
& v( x' l' |6 ?( H$ y* @0 R6 g1 v6 `* f8 c6 z4 v
static int __init led_platform_init(void). N; e4 S% E, b+ z! I
{
. M8 e3 |- d6 E1 X* B4 Z int ret;) L3 @' I7 C+ ^
#if 0; c* F4 D2 s3 b& ]( C" W# f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); I! F9 [& l: Y( o7 R- P& ]* t" b
if (ret)% G0 M$ e' c; L0 c# R) _5 E2 h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 J" `( s; q' z/ U
"%d\n", ret);; r0 y6 C5 s/ D1 B
#endif/ j, H n' \; p, K! A/ ]2 c
ret = platform_device_register(&da850_evm_tl_leds_device); g# @/ n$ G# m! \
if (ret)
% ^! m) J/ s! k4 D pr_warning("Could not register som GPIO expander LEDS");5 Q8 S* _# q3 U
else, A1 b5 f" p* V3 V. u
printk(KERN_INFO "LED register sucessful!\n");0 j _6 O" F% q1 b+ F9 D6 [
- G$ E9 w9 S% e/ g return ret;* ]" ~2 X1 W, K& m/ ?: @
}% \. ?3 y ?; m8 `4 }
; I& t% C. Q; V! ?5 Gstatic void __exit led_platform_exit(void)
) L( s! v& x @2 C{
2 l/ p! |9 p" i, ?, c- k platform_device_unregister(&da850_evm_tl_leds_device);) n% G( G( p- Y$ b
. d% ]0 Z+ T r. P$ ?3 F+ ` printk(KERN_INFO "LED unregister!\n");
. j$ J _& s [0 a! R6 y}
" {9 L' b* e" v' F( X3 [
9 ]% \4 ]% G3 I0 Y- Amodule_init(led_platform_init);8 i2 L1 q( ^: Z% B7 m7 ]5 d
module_exit(led_platform_exit);/ z/ j z: u- A) U2 ~! A
- F1 B; ]) Z& E5 z1 I* p' gMODULE_DESCRIPTION("Led platform driver");5 b; m# x+ N2 l: b
MODULE_AUTHOR("Tronlong");) c2 h) l" q( C( x
MODULE_LICENSE("GPL");
; W, d9 }( I* ~9 {. B) }% y. z, ? \
|
|