|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 s+ J7 R$ }+ n) n* m#include <linux/init.h>+ ?5 G! U" { p& N
#include <linux/module.h>
% |9 C5 H7 @7 C#include <linux/kernel.h>
6 O7 f6 F: D1 p! w#include <linux/types.h>
7 ~' R, ^9 S- j& W#include <linux/gpio.h>
) h$ ?8 Y) c F# X% C; {# ~$ L#include <linux/leds.h>$ t) X# N; r: N6 {2 v% g& s
#include <linux/platform_device.h>4 D! W( `3 h- ?1 [) `! b$ @
; {/ {, r/ u* |#include <asm/mach-types.h>
( E& F8 [3 V- }0 H& q" y; X#include <asm/mach/arch.h>
2 I/ K. C4 f9 a; H- _, ]#include <mach/da8xx.h>
8 i6 b$ q# N/ }% b- P, p#include <mach/mux.h>/ a% C, V* h: V4 \# `
+ F' Y7 ~ j( d1 }( Y$ N0 D; Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 \8 K4 W. f/ ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). y2 v. V% L% D: ?* e/ E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 w! r; x9 z/ X7 V% k8 o0 c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 Y3 y4 c7 B) j8 f1 n6 Y. @7 [6 E9 B* V0 c9 ^1 F
/* assign the tl som board LED-GPIOs*/
4 r& p1 W% s8 s; F% rstatic const short da850_evm_tl_user_led_pins[] = {
6 d p) r; V7 Q1 l2 u4 D9 x /* These pins are definition at <mach/mux.h> file */
: W: v% c9 d' g- `! E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 F# W1 K1 j* L" W: V -1& H# K5 x) d, Q1 } }
};
" [2 g1 E7 W0 ~6 ~6 n( |6 t/ I* T
static struct gpio_led da850_evm_tl_leds[] = {" u" `7 }4 x' s x6 Z9 R
{- |( y, I& M+ g+ N* S% ^! P
.active_low = 0,
0 p: K+ F& s1 S/ ~/ ^4 B6 b3 w .gpio = DA850_USER_LED0,) r3 |' }7 e3 J! j/ O% Q. N
.name = "user_led0",: b. |' u6 V+ D! x
.default_trigger = "default-on",
* `& ?; l2 ~" Y/ g) h5 |2 @ },2 Y! J4 d& ^! H: D* @. U
{
- G5 }3 x8 u/ b. q; R& ]- ~ .active_low = 0,4 P% g# _8 ^, [2 \
.gpio = DA850_USER_LED1,, S, s& X3 _6 F. s5 N- Q
.name = "user_led1", ^7 @4 D' \7 z* s+ m* Z
.default_trigger = "default-on",8 {5 Q) m9 g" g% c8 z
},2 d8 Q. o# C, e) _) d3 X
{
# b. U. ~* Q' G7 x Z .active_low = 0,* c% N4 ?* \# @* I# z9 I2 ^- n( G
.gpio = DA850_USER_LED2,
2 e) w! v* x+ O: Q .name = "user_led2",
; x. ] b( f! n. y {1 _ .default_trigger = "default-on",
g; G9 E5 z3 m6 X- Q4 Q9 D },# m( h+ B" I2 M2 n% Q
{
. C+ g; M% `2 G. Q( v, w4 E5 L" D# i .active_low = 0,
$ E* }, d% f$ u5 n9 R: Q .gpio = DA850_USER_LED3,
r% S" \6 D5 E3 v .name = "user_led3",
9 b; d0 ~' X/ o .default_trigger = "default-on",
' ?# C5 _! x6 t( O6 M M },& ?6 |0 N* U5 H( g8 H1 \1 Q6 y
};
. L; Z3 b7 i* e# |$ W0 h" A# {+ F7 d: d. q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 e+ u* ?( c5 a .leds = da850_evm_tl_leds,5 r" q2 {. k1 O& `( m2 Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' _; R& ?1 Y8 C, n! i1 r% B};
6 I. Y4 F3 q' ^1 M7 e+ [5 E4 H3 Q6 y$ L- Z
static void led_dev_release(struct device *dev)7 K4 T1 s0 E! J5 j
{/ d8 w B; R* k. D2 R1 p$ k2 M
};
, u( E. v! B# ], @+ x# h# a: C+ ^* q' C% r* Q2 I
static struct platform_device da850_evm_tl_leds_device = {- U! B6 K4 B% E$ r
.name = "leds-gpio",
: j# }& W" _) a( \# y9 j) U: O5 V .id = 1,
4 K V7 L1 ~1 B .dev = {
2 q1 @& B1 I& ?4 X' f .platform_data = &da850_evm_tl_leds_pdata,
4 k5 F0 i# [4 C6 \- `6 u3 {# r .release = led_dev_release,
: ~9 o6 P+ c" v) J }8 P5 A* z$ z# U3 h- L& c( ~) ~6 O
};
' Z+ U8 d: Y1 [! m* u& F+ E4 \
; E! \* [ N1 \static int __init led_platform_init(void)1 n) I* M. l8 R2 `' _
{( P* H5 k: W6 ^; `" F% c
int ret;, I _$ x$ j) g) ^8 W9 _/ X
#if 0
& V0 Q8 W) M k, n7 q2 W, Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 f+ t( F3 D# ?7 j6 s
if (ret)# l7 T m9 ]8 ^5 N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 X0 a! `9 j' e "%d\n", ret);7 H( u0 [- b% G, F6 f2 X7 B
#endif
# i* p; Y; t4 u+ Z5 ~' N3 w ret = platform_device_register(&da850_evm_tl_leds_device);
9 D( F& J* v1 H$ q c' \5 \4 Y if (ret)
5 `& d1 j% H! E: s. e5 i+ I9 [ pr_warning("Could not register som GPIO expander LEDS");
6 E) A% @5 u) y/ M9 P4 q5 [ else3 w3 A7 n0 Q ^
printk(KERN_INFO "LED register sucessful!\n");2 ~0 i6 A& L" G
) v6 \% h* T9 u1 g6 [
return ret;
9 x8 B& N( ^# ^}
# ~8 u y2 m$ H1 e! K) f
0 N" f5 k2 F' [, a6 p1 Nstatic void __exit led_platform_exit(void)+ J( f2 I! a, u; ]4 o
{
" u* D6 l5 |* V5 m) Z& n8 z platform_device_unregister(&da850_evm_tl_leds_device);9 Q! T6 _6 |$ t
, j; m: U6 Z" u6 ^, w: H$ m: u9 Q7 s
printk(KERN_INFO "LED unregister!\n");/ U4 ~5 w6 Z! @' v: \$ C. t; H3 {
}
7 f5 w6 e0 f! A' x4 _8 T8 o' P B8 R1 v
module_init(led_platform_init);0 ^7 G& }6 s, k3 b7 t
module_exit(led_platform_exit);
& @, K; |' L+ T9 Z# o1 D% I" s8 K5 G3 _1 b2 t
MODULE_DESCRIPTION("Led platform driver");) L y3 G+ M1 K ~; H. k' I' R2 z/ K& g
MODULE_AUTHOR("Tronlong");
( {6 q( G2 l5 r9 V" U5 \MODULE_LICENSE("GPL");* S: l0 o4 P0 s) C: m5 a& D
z# f5 q7 V. a9 b- S: R
|
|