|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; Q. k& \6 a6 f( L#include <linux/init.h>
4 t' j- @6 Z8 P) m% ]$ r7 P& I, Y#include <linux/module.h>. I5 _3 k( `+ M7 _, |: s* u) w6 A
#include <linux/kernel.h>" }6 A9 I( _2 h2 {7 a
#include <linux/types.h>
0 c7 k' g' n, }& @5 Q& a* x#include <linux/gpio.h>; P2 w2 Y, J6 o, ?2 m% ^7 L K
#include <linux/leds.h>
1 m& P/ P5 C& X W#include <linux/platform_device.h>
' R! o# p) t2 r" a+ K2 C Q- B& V( e1 D' {3 y# y% w3 w3 `! B' d f
#include <asm/mach-types.h>1 a9 G) F4 c* W, K- w- J5 ^) _
#include <asm/mach/arch.h>8 t) M7 x; j; j. a4 y* a
#include <mach/da8xx.h>% q" K; w0 C+ {5 b! k
#include <mach/mux.h>
/ M: ~+ X3 z: [8 ~5 r9 S
7 O2 P6 h0 W" m0 [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) u' j, b( P- q' O. }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 b) w i S2 T* L# |, p#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 j4 Z/ D9 H# w+ j0 _. j; @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 ^0 W! {- e0 I T- a, G
; ~3 E# b) i, u1 H1 @0 w/* assign the tl som board LED-GPIOs*/
% C* w) U6 i# N6 }0 P5 c2 mstatic const short da850_evm_tl_user_led_pins[] = {
# n% y8 Z( {' y E4 v7 F* c4 m /* These pins are definition at <mach/mux.h> file */
k. R* L7 b- Z0 f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 n4 I) N) f" ]: {6 O- i
-1
/ r6 W m1 D0 c7 e" O7 s};
9 Y) i ~ \/ ^4 a8 M
2 z2 y5 ?8 W8 X) ^, f2 zstatic struct gpio_led da850_evm_tl_leds[] = {
* G# Z' e9 W! b8 a* p& a! @' t {
& L3 B& J5 p- j .active_low = 0,
& O5 ~6 A7 I5 \. L! b9 N .gpio = DA850_USER_LED0,
% c8 \$ b R( y/ C .name = "user_led0",
+ z: l& d/ I7 V& ^& M .default_trigger = "default-on",
" w9 w+ r( N$ F1 d% \ }, V+ u( f$ s0 O- P8 k% O/ q) Y
{6 E( n9 q# t) i& l/ k& O( c3 a. `
.active_low = 0,
( M2 G2 j. x, D2 z C2 j .gpio = DA850_USER_LED1,# P3 X( L& C0 m" m; h
.name = "user_led1",. u; ?, I% P2 m4 [5 [6 |4 l
.default_trigger = "default-on",
9 x1 U3 h' B% r! d0 t9 U) p },
- r$ m5 o) H$ _" o# n {; f1 J! E5 ?" _2 y1 M9 I2 u
.active_low = 0,
8 s1 h( Z" f( s .gpio = DA850_USER_LED2,
r2 M& \( n2 v; ^9 B: O .name = "user_led2",* I3 i$ v" F6 C( V
.default_trigger = "default-on",
/ S$ [" m' {$ Y; b },
) m" Z) ]( C: k7 V/ d {
* R+ k/ ~& S Q5 p. ]0 E .active_low = 0,7 S5 {4 w5 p i2 s4 r, {
.gpio = DA850_USER_LED3,
2 ~! t8 R, o; S4 O" { .name = "user_led3",# q Z, M8 i- \& |: M/ E
.default_trigger = "default-on",
! c6 W% E- s9 j, ~! K \+ J },# G- \, ]! j' e; n$ g5 ]7 J8 D
};
& a* @& {7 l9 |) v7 w+ ?
- e$ \& i7 V2 i; bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 ~$ U& f4 _& P; S8 B( z .leds = da850_evm_tl_leds,$ K+ D8 W9 F# L0 b6 \( {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ Y4 ?% W' ~7 W! c0 n};4 r& G% U) f' S9 u! T
3 `7 c+ S; Q8 [/ Fstatic void led_dev_release(struct device *dev)+ _, Z0 Y1 h }' M4 Y
{
& K' g8 ~$ y4 R2 v" i! A N};0 l! _& t2 t% p" l# P1 m- T. h* z
2 u1 q8 u6 o3 c! k8 j
static struct platform_device da850_evm_tl_leds_device = {8 }4 B$ p7 h$ [+ w3 _2 q4 V
.name = "leds-gpio",
% S) g4 P( y2 r2 P* ~' @ .id = 1,$ L& e" V" T: i* P @: q
.dev = {
& f& r0 s# U6 h: a- \! k- f4 L .platform_data = &da850_evm_tl_leds_pdata,
5 w/ f. i* S& B; E" K .release = led_dev_release,
% v+ g* ]1 u% m }
, W* M9 K8 g6 t! i% t" F" W* C- Z};5 x9 o9 @! T: L+ G0 Y
% p( P1 R5 o" g+ h, N3 n1 N
static int __init led_platform_init(void)$ o' s% k4 u! q
{4 |1 m5 b$ k. ?( p
int ret;5 F, g9 _5 A. B# R
#if 07 V) i3 x' u( s! N, T% p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' u L& d( G r if (ret)' Z \1 o0 k! F: l' l$ D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ _4 E2 N+ D4 _1 x/ I d' O2 x) Z "%d\n", ret);0 }4 v+ b1 o% Y% |* a& W
#endif
0 \5 I# v, ~( z! {5 D. C0 V! ? ret = platform_device_register(&da850_evm_tl_leds_device);
' c4 ]( Q9 X6 j; y if (ret)
& C* ?: R4 \7 y* |9 p pr_warning("Could not register som GPIO expander LEDS");
* S6 W; |: d% i& U else
5 R- O4 y6 e& a/ T printk(KERN_INFO "LED register sucessful!\n");8 A5 y& {" C5 R# V; z
" M* n. f( j" R$ N. y6 x8 x- Z return ret;% _$ X7 x) h) U4 M+ M+ Y
}
( Q5 p( T3 x. s1 l0 s0 m8 _! q$ }, i
static void __exit led_platform_exit(void)$ W/ b+ p8 x% Y+ f" o
{
4 b- O' X* G( V platform_device_unregister(&da850_evm_tl_leds_device);
0 W* _( m$ u1 ?4 C
, u9 E5 _& H; I5 ^ } printk(KERN_INFO "LED unregister!\n");
. g, V8 P9 d; [/ p6 t+ U}
9 S" a! K, U9 _+ W/ S4 q4 s7 N# h P9 g$ [9 a: b
module_init(led_platform_init);
0 F# [1 f9 {3 J8 \module_exit(led_platform_exit);
+ I) P% a9 ]1 `/ Y
; s8 \5 b+ ~" d$ MMODULE_DESCRIPTION("Led platform driver");! I' I, w& ~0 }! \5 c
MODULE_AUTHOR("Tronlong");, c) `. g, K# I8 h( e+ t3 ~& H
MODULE_LICENSE("GPL");
& L6 v- q$ ?) L, X; |* w4 Y; o6 _! r) \
|
|