|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; @+ x3 |% W, X, S+ Q
#include <linux/init.h>
$ ?! k- Z7 N+ R5 u0 M#include <linux/module.h>
9 q/ M+ G& `9 p6 R9 M1 P! p#include <linux/kernel.h>
8 k8 X/ k: H* ?2 j# P: F#include <linux/types.h>
( e* \: S+ s/ p3 T& d6 y#include <linux/gpio.h>
& z; F& E( a- {1 o#include <linux/leds.h> s7 N5 V" I' H
#include <linux/platform_device.h>( q6 `, w* m% S, ` @7 w
7 s2 F: u: G9 X5 c! m. |4 b2 \9 z#include <asm/mach-types.h>
1 D- N& n- V0 c) n; B#include <asm/mach/arch.h>
' i0 ~% J5 P0 z. l8 a#include <mach/da8xx.h>
! L9 q# _+ [$ g+ I- ?/ J0 `0 I#include <mach/mux.h>
' Q( Q s; M. u
% M0 P c0 Z& P3 R6 K8 ~2 m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
T2 s5 t' t3 _! S" P% b. l$ [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 `* K8 ^: w- A8 j0 s8 [' ~* |, z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 X$ e7 ~- K$ a4 C- L S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% x7 F$ f5 e6 ]1 F5 X4 [; O5 }& u8 W! E* s
/* assign the tl som board LED-GPIOs*/, w+ w3 l# n% e# e
static const short da850_evm_tl_user_led_pins[] = {
2 L6 u% d$ c2 d9 D /* These pins are definition at <mach/mux.h> file */) ]: H, I( z" I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ M7 \+ E" \$ p- N6 b% h
-1
0 m* E% V4 R# w};. s* g M4 w4 i% [
3 l! y; s# J+ l1 Y8 V
static struct gpio_led da850_evm_tl_leds[] = {
+ ~0 ]5 m$ \3 b& T+ l ? {
9 \% N+ f Y, ~ .active_low = 0,4 h3 \) J5 @# a6 i2 O- N5 P; j- X$ t9 ]
.gpio = DA850_USER_LED0,0 l. S! P3 }, u$ ^+ b
.name = "user_led0",2 P/ _: O# b5 Y4 T
.default_trigger = "default-on",7 m( z2 [: B- n
},
- Y6 ~5 C( Y+ u1 j2 K' ?& ? {1 Z+ M- [- C* i$ Z7 G) B; I# R
.active_low = 0,2 l" _* H A7 A3 M A9 [) X
.gpio = DA850_USER_LED1,
! g3 B6 E+ w/ } .name = "user_led1",( Z, s: ?4 ^& v0 \; S
.default_trigger = "default-on",+ {( K& ?0 k6 n2 a8 q; @" c. }
},
: q# ^" W2 A p% _1 @2 D {' }8 y! n# v# }8 r. A- \7 U2 c
.active_low = 0,. Q" g% A1 h, g7 K# ^
.gpio = DA850_USER_LED2,
) h8 |% n6 Z1 l$ W .name = "user_led2",* F* O, j p( b1 Q9 l1 i8 D1 R* m
.default_trigger = "default-on",( `% _8 j w. o
},$ @' R; j/ M1 G! r o
{
5 K9 q! Y/ z8 }- z' R .active_low = 0,
5 A ^/ `" \' I) K b* Y7 a .gpio = DA850_USER_LED3,* H- M$ w: U' K# Y5 r0 ^4 ~
.name = "user_led3",. r1 ?2 `6 q+ B( ^3 \
.default_trigger = "default-on",
( a7 A3 {% u# }; s9 j9 |9 k2 X },* H, A# G) u6 i7 E
};9 Z; @ D) P5 `% {
' U; U2 c+ D9 O: P" t! K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 j: s# o4 g; w2 A3 e5 N v .leds = da850_evm_tl_leds,
# ~) ~) j& X& [' X# u. ]' m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. j. j5 a$ Y8 Z6 M+ k b};
4 Y' n: S$ _: P9 l G& W% y: A/ \2 @/ y1 B
static void led_dev_release(struct device *dev)
9 o' J% _) V. a5 f9 d0 a% h* @{: A; `, _% I: [* q8 c0 e
};9 f, o B( J/ [# U4 R" P9 u
Q2 F& q2 \ ~; P. b
static struct platform_device da850_evm_tl_leds_device = {
6 Q8 U9 @! ~5 N9 O4 i- z& Q& @ .name = "leds-gpio",
9 \! g! F7 y% j1 Z0 I .id = 1,+ w( ?- H5 ]( {2 |+ b0 W9 v8 G
.dev = {+ s+ Q0 _! I& h; ]" W) n
.platform_data = &da850_evm_tl_leds_pdata,! C: J, _1 x2 S6 N6 L4 f
.release = led_dev_release,
% K) C1 b& {0 _/ u- I }
9 o- q/ }& [6 y5 v& I( O};5 B3 X0 } c s, `" z% x2 h' f
, e% t1 [. }' L5 ]" U s$ V' t
static int __init led_platform_init(void)
" j5 D- Y0 I3 o- q9 N6 v{
7 K( X2 e- O ^6 h) P int ret;) j7 s- h/ m) C. _8 \; e
#if 0 X6 n3 \6 }( }( I; P! R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) t3 W" q8 V2 J/ F5 q# _! [ if (ret)
J! M$ q. c% q1 P8 [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' r& V1 ]2 V# g* e) V "%d\n", ret);
% X* D k6 n; `% z% G4 d; g% v) T9 h#endif
+ N2 }+ p' t# w* N+ m4 \$ s, p4 h ret = platform_device_register(&da850_evm_tl_leds_device);
/ w% d) j. @* D if (ret)6 ?! l" F/ i) c6 c+ h
pr_warning("Could not register som GPIO expander LEDS");
# r" v$ N' _0 A' s7 n0 D$ ] else
R6 v5 V/ ^- g( I( J printk(KERN_INFO "LED register sucessful!\n");8 F' \5 ~: R% Q+ _! y! w4 S* U' s. f; H
?0 T2 u. i2 ? j- v return ret;
+ o. d7 S( G" x}2 l0 Z: w. ^6 B& [% R4 u# t- G
) P6 r9 q5 D z% h! P
static void __exit led_platform_exit(void)
% O. T4 q% v. a) x& H, ~/ _/ x- E7 q{
8 R" p s- w% t: ]9 J4 v; r platform_device_unregister(&da850_evm_tl_leds_device);$ X& ^( f) Y$ ?( K
: ^: m1 ?6 K& z2 y3 d! n/ d printk(KERN_INFO "LED unregister!\n");) F" |+ R, J5 M4 |
}
( q( n& x6 ?4 l5 n, n6 W$ d+ e4 n5 x. F5 B% e7 P
module_init(led_platform_init);+ F! t/ x% b T8 _& z
module_exit(led_platform_exit);
& u8 A8 c# W- h6 a' N' d# ], Z6 v# S: D) Q: W! v& W
MODULE_DESCRIPTION("Led platform driver");
! L3 ^6 j8 i( T' r, x! @6 VMODULE_AUTHOR("Tronlong");
, Y0 n; j4 }' |. W' iMODULE_LICENSE("GPL");
6 z1 K2 f3 M" l+ B- n6 R% ]& H0 ^% S, E2 v4 x) V8 ^6 ?
|
|