|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& d Q. ~0 [! I2 {7 z+ n: |
#include <linux/init.h> i- E5 ^7 E1 j/ e# B
#include <linux/module.h>
: j. i% l' s% q# }2 A! A#include <linux/kernel.h>
# B1 t, g" w+ k. C( H$ Z- M7 z# \6 h( s#include <linux/types.h>& e* S1 y/ e1 T2 N4 O! w+ }* G
#include <linux/gpio.h>
% s: s7 H9 M+ l) g1 a#include <linux/leds.h>4 D6 x" Z7 [$ N" W4 |+ f& S5 X
#include <linux/platform_device.h>
+ J7 V' B5 K6 U* ^! i: t! u
0 U! ?2 N) C( X#include <asm/mach-types.h>
6 h5 \6 ~# V1 K) @: r' N8 F#include <asm/mach/arch.h># O2 k$ p$ O9 I" w" |: |) i
#include <mach/da8xx.h>, |& t) m9 Z7 i( A- u
#include <mach/mux.h>) |, b8 }5 G. \
, M6 _ `% t; k2 D2 i: h2 x2 {& }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 ^* ]' w% @3 O9 x4 f9 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 {2 V, e# e* ^8 h9 n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ S6 u9 f4 e) b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 h6 L, T2 J6 X' F
8 C; t" `" a$ X$ ^ E: m3 N/* assign the tl som board LED-GPIOs*/3 Q1 v# _4 E; |. }
static const short da850_evm_tl_user_led_pins[] = {
) d+ z7 |# C4 ?! m /* These pins are definition at <mach/mux.h> file */; G l7 |3 M( [) g! F4 e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 p% G$ A( Y8 S -16 ~" l% l% l* f8 k4 P8 Z8 j
};4 Z( m- A Z3 S" }% v7 t
+ \$ ]! Z0 `1 Z8 k) Zstatic struct gpio_led da850_evm_tl_leds[] = {7 v8 k+ B( m G
{
& E, A+ ^3 j& X .active_low = 0,
& h9 p1 T; K. x$ y .gpio = DA850_USER_LED0,$ k: o+ `2 j) M& E
.name = "user_led0",
; j1 p# c5 D! M% M0 O .default_trigger = "default-on",
1 o1 m) p! W ~7 _ },
+ e0 L: S Z; p {% d, {5 V6 @0 F2 u& {; v# B
.active_low = 0,
! a2 x4 x, O# h; D .gpio = DA850_USER_LED1,
& R& O6 e% a2 \8 o5 X .name = "user_led1",
5 ]6 M! d7 C& j/ g .default_trigger = "default-on",
0 R* @" ]0 ?2 M5 W# ?& k },
' w+ o9 D/ N/ o4 w5 n2 Z W {' ?. r; q' y+ `& W% A# @5 m9 Q
.active_low = 0,
- `' Z* X9 u) r" C" J .gpio = DA850_USER_LED2," z+ p# c% ^ w' b
.name = "user_led2",
: r. |' C+ T$ T! F& ^ .default_trigger = "default-on",
( N) D- L* o e },
7 q6 M/ D I; D; ? {, _. R/ v3 K8 S+ b( ]( H9 r
.active_low = 0,6 x) H/ }' ]8 m# b8 [
.gpio = DA850_USER_LED3,
1 ?4 f( q) y0 D' N7 e2 `& b .name = "user_led3",
1 e3 |0 K* [$ R$ h .default_trigger = "default-on",: Z1 W9 X5 Z' ~; N- [! x) X. a
},
/ y `/ P7 \# p5 ]};
- F, {7 i! s: Z5 f6 S
M% h T0 Z3 `& s* u3 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 L4 }" d! ^; S' N) W+ u .leds = da850_evm_tl_leds,) m5 Q% r; w' z6 S: w ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 i* x: t7 t9 p0 d8 I( Y
};
1 ^. O6 \2 L- Z- l/ x# S- m
, D- g5 J7 g; p& Jstatic void led_dev_release(struct device *dev)8 K$ t* C V8 ?; j( W' R
{( B$ T$ N" C. u: |: m* i4 ~9 x
};
3 l0 y2 V0 @, N5 z$ Q k) n
7 p& y1 R2 r" c$ a2 istatic struct platform_device da850_evm_tl_leds_device = {( J1 l8 s3 F8 h$ n& a$ _
.name = "leds-gpio",
# P" X1 \3 x% S4 X8 @ .id = 1,( F9 A3 W0 V3 C4 t# [$ ^
.dev = {0 l" {5 z4 ^+ u) i
.platform_data = &da850_evm_tl_leds_pdata,
' o, [) h6 j$ b. U+ ]4 c3 {; ~* `& F+ p .release = led_dev_release,
" s0 l3 l' z# t& O1 N W }2 N; ^. c0 D! k7 `! E, E
};
2 J5 q( Z! f: R8 a/ g: @
: J+ V- @1 ^/ k4 H" U5 ^static int __init led_platform_init(void)* m* e/ f) K0 V4 |4 U0 K
{: p$ G9 z2 E+ X
int ret;. B; O7 h( Q% _1 c* Z8 x% A! z% _
#if 0
m# f: c" V1 ?' ^ t* k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ y9 L* @, ~7 w, S; P0 p
if (ret)! K. g8 g4 z& s& b- X- I7 `4 k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' f7 U) v4 n/ S; |! F: e7 [ "%d\n", ret);3 O- G% |8 Q5 j q4 h! \
#endif
; V4 W- a* P3 r ret = platform_device_register(&da850_evm_tl_leds_device);
6 i) [9 G4 R& M if (ret); d5 w* P4 {& G8 h9 Q# Z3 S
pr_warning("Could not register som GPIO expander LEDS");
4 a0 E& v" l6 G: [, G else$ R3 @ v' `" v- T: f" T K
printk(KERN_INFO "LED register sucessful!\n");
+ Q) V0 c. p/ @: O2 o E
5 b" t9 y- Z2 c' K, t! K2 | return ret;
3 b3 l) K% w' u T! [0 q' M}, Z+ H9 J* Y7 V" |! @: b- n
& V, A4 D% g9 a0 }( p0 s! S
static void __exit led_platform_exit(void)6 Y' B5 Y/ i0 m8 h, i# Y- i6 [
{
8 g9 v9 X. |9 [3 W U. X8 C platform_device_unregister(&da850_evm_tl_leds_device);. V1 O" E$ q, E- @
5 |- c- { Q4 t, m
printk(KERN_INFO "LED unregister!\n");" m4 p0 {( Z8 P3 R: T
}) I. Q2 n+ o9 e2 _
. O4 |( L2 A8 K: G& T; r0 J4 Tmodule_init(led_platform_init);1 J8 g8 E& k c
module_exit(led_platform_exit);
; r* c5 ?( r5 [ r" l1 G; V( f& o9 A( [& W& G
MODULE_DESCRIPTION("Led platform driver");
2 P* e+ w1 H$ z- l1 O( ?MODULE_AUTHOR("Tronlong");
% {9 [' T$ _* k' ]) }MODULE_LICENSE("GPL");) _6 P; E9 B9 n3 I, g6 P! i
" Y) m$ n2 K) ~) F( l4 o! j3 D; i |
|