|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 h' e3 E! a% N2 Z" Q8 D7 n2 H#include <linux/init.h>
/ w4 }, u3 W) m# v- z# v1 Y# h# P% P#include <linux/module.h>4 H! \- Q4 A: b9 a Z% M
#include <linux/kernel.h>
8 Y6 G% {1 V" _8 L) A# [#include <linux/types.h>6 r8 h' q K5 k# t( I0 r* ]
#include <linux/gpio.h>. w5 k" V `( k# Z9 {% @2 Z9 Y
#include <linux/leds.h>
: V: R6 [2 a% }$ @ l2 _8 e#include <linux/platform_device.h>" l8 Q: u) d7 B) x% _; d2 l) x
- d: |! Y+ z. N4 M5 {! N* ^# q#include <asm/mach-types.h>
/ B1 ]/ B( ^8 `! u) Z, |% h5 D+ r7 @7 `#include <asm/mach/arch.h>
. m8 _! U3 r0 d4 `#include <mach/da8xx.h>
- h+ F7 [8 \7 o( ]7 X8 `& B+ k#include <mach/mux.h>
5 H2 |3 T4 J+ K1 S c y: p1 {# w! h0 X, x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' O' {+ W! p8 Q. z) n( Z. x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* t+ B. r8 Y/ o' C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' {+ [* D/ f8 N/ {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% u$ w" I! n: p* ?: s4 M
( b/ Z# ]+ p# z
/* assign the tl som board LED-GPIOs*/
# `% u: n0 v' }& ]static const short da850_evm_tl_user_led_pins[] = {
, Q+ h$ M& E+ a) d T. P1 Y /* These pins are definition at <mach/mux.h> file */" v% @6 W; z. t2 L" H9 Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( I' C7 E% d! m( m9 ^4 e4 p5 H; b; k -1
( e# A4 b; M/ S1 }};7 O' n" s9 t9 ?0 [7 c
8 N2 [7 E6 @+ a& ~) ?! Nstatic struct gpio_led da850_evm_tl_leds[] = { S' k! q9 [0 U' D- [
{& y- D- W1 S2 z3 e
.active_low = 0,
, [4 C3 @8 r8 M% ?9 b0 Z3 N- Q .gpio = DA850_USER_LED0,
* f3 ~" U# s* _$ B8 R" { .name = "user_led0",$ ?! W3 T+ b3 U, H. W0 T
.default_trigger = "default-on",
5 T4 }$ \6 P- j# a. W: K },, e9 P8 k' R" U5 f6 V& E, a' O
{) |( p0 A/ o6 u
.active_low = 0,
% ~" a& |+ o- J* c* A2 q& L6 F3 i .gpio = DA850_USER_LED1,
4 {+ Z9 n( J( n$ I* f r$ c .name = "user_led1",8 t) X/ @7 w+ b
.default_trigger = "default-on",9 Q$ Y% i" M: X0 X" s
},
7 B* V) Y7 ^- r {
& c9 i+ H6 Q K/ A7 c .active_low = 0,
8 F0 }" r- v/ R% e6 U3 F .gpio = DA850_USER_LED2,6 F5 s) i% O5 n; Y
.name = "user_led2",, J, {0 W) j& f
.default_trigger = "default-on",
" `( ?/ [ T) {9 s* X u/ ] },3 i3 Q5 a% c, Z% k% [0 ?- A
{9 S6 H* e: ]1 h+ Z& W3 l
.active_low = 0,
/ x, ?6 V. A4 ]2 |# a* X .gpio = DA850_USER_LED3,2 Z- r: t8 W' b7 C9 a2 h- _* v$ b* ]
.name = "user_led3",/ l8 P q6 s8 M2 F# ?, C
.default_trigger = "default-on",& K: N" m1 g" t$ N
},
2 l( v/ R! w9 H* J7 W};' G/ F5 y- e9 x2 L7 j( l
% X5 u y1 f5 H. mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- i" q! d* V4 m. B; B .leds = da850_evm_tl_leds,4 f% y: `! n6 d/ D, u O D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ `- S" {( u8 o& D0 g" B2 L
};! Z, b4 c5 i% V3 [) C0 l
; Q8 v8 }- p; |- vstatic void led_dev_release(struct device *dev), w7 H7 a$ t) V5 p
{/ m% J, O9 N) W
};) W& `8 T, v1 d, f p0 C
* _. m) V1 S" z# ?3 C
static struct platform_device da850_evm_tl_leds_device = {0 H- N4 k u- q% G: k. f
.name = "leds-gpio",
" P1 L& G! |, c0 } .id = 1,
( z% f; n: z/ w! c, Q( E2 D .dev = {* {+ @/ Y" _ m" J
.platform_data = &da850_evm_tl_leds_pdata,- F4 }$ ] M3 C4 @$ b0 g1 g% K
.release = led_dev_release,2 E$ d* @, @* k5 M/ y" H. T
} k9 P8 L2 o+ f9 a2 P1 q w8 T
};
3 i* l7 {: O( m( p- y' R. z- s8 V0 Y) d _$ Y8 [0 j4 W
static int __init led_platform_init(void)1 Y. n4 p) P5 N6 p
{
3 I2 \- M# c3 L. S1 X int ret;
$ q J7 o. h, D3 q) [3 W" J: I ^#if 0. R. A1 P8 f! Z: w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- B" U' `: r& X2 w: H1 V% r( H
if (ret)% k# |7 x+ B' R* R! J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( E( \: h" E6 m. o) P7 [
"%d\n", ret);1 ^1 w/ L( Z% K" Q' X
#endif/ @: u5 ~" e' W" x, @4 D
ret = platform_device_register(&da850_evm_tl_leds_device);
3 u1 ?' u2 n/ m, A if (ret)5 Z* b% O7 u; e, i- }
pr_warning("Could not register som GPIO expander LEDS");3 D& H. c M' H4 w' y1 v7 `; t: \
else
9 Q5 z+ a g- f8 ~# H printk(KERN_INFO "LED register sucessful!\n");
# ?5 }2 z: r+ ^9 K* N
% H- J! n' j4 f% ~8 z5 S7 ? return ret;
( K' C& t t0 M! f; s. ]) h}6 Q" A! V, G6 h$ c* T( V0 f1 D
* w5 T& p+ E# o
static void __exit led_platform_exit(void)4 N) t3 o% `. X4 e" Q
{- {* f; |+ r# M( w& j" H
platform_device_unregister(&da850_evm_tl_leds_device);; L/ x8 G, D4 T$ Z
# T4 _$ O( f Q1 N
printk(KERN_INFO "LED unregister!\n"); X7 y9 \+ E6 U) f- {# c+ P; H
}2 _2 s5 W: ]( U9 _: G
. M" O4 p, A& i5 _" [module_init(led_platform_init);; Q- O0 S" z* V y0 Q
module_exit(led_platform_exit);
3 r6 ]' z2 a+ I+ j& l
% }& R- `& F2 }' v# K- yMODULE_DESCRIPTION("Led platform driver");
7 L6 i" q" z8 \5 m. UMODULE_AUTHOR("Tronlong");
7 c8 p0 X8 `3 t. K+ O% a- h8 bMODULE_LICENSE("GPL");# j$ {1 s/ S! g
" Y7 C$ S) e) ~3 R1 c. p |
|