|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ X: Z3 h/ r% b$ r% v$ k+ |
#include <linux/init.h>7 ]4 \ g6 x% _0 v; [! x/ [2 |
#include <linux/module.h>
4 K- `3 X+ `9 w# K/ G5 |$ u2 L( h#include <linux/kernel.h>. B2 ]3 C/ `/ f+ t" ^
#include <linux/types.h>
# ]9 k) t/ Q' v0 m6 K# y#include <linux/gpio.h>
& D( ^' R2 Y7 m9 A2 h#include <linux/leds.h>
, A8 t3 c2 j/ ]#include <linux/platform_device.h>, a+ Z% p3 G6 J7 h& U6 v
5 \. ?/ @* L$ T B#include <asm/mach-types.h>
% r8 Z+ @' \) D: Q#include <asm/mach/arch.h>5 g7 U( [9 K0 j$ z: l X- H- F7 I2 ~
#include <mach/da8xx.h>8 I9 |9 L6 x0 ]7 V* g6 ~
#include <mach/mux.h>0 b2 q2 _8 `. [( {. V
) S1 _& P/ C( ^2 c+ U+ H8 |; o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% w* N$ C, e2 J: R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& K8 c( }* ]7 `. b" D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' a# {+ e+ j% _( R5 R, b( S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" |9 H; \, t- D8 M! X
8 c: a* Z# j2 n' m, I4 ^/* assign the tl som board LED-GPIOs*/
( S& ^( q- Y- x+ ]1 ]static const short da850_evm_tl_user_led_pins[] = { Q1 B# W: O' l6 N7 t
/* These pins are definition at <mach/mux.h> file */
C8 |1 ~" m' \8 E% g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. e o u5 B. _ -1
: x+ G$ T; j- g+ g) X};
5 L1 f b$ A7 K4 [
$ K( i. y: R- _. U$ O5 r; Dstatic struct gpio_led da850_evm_tl_leds[] = {) G6 m% f1 i( B2 a
{
' B3 s+ u- t0 z, e2 w8 j .active_low = 0,
6 g$ ?, Z, x9 B+ i9 t) v, p9 @+ T .gpio = DA850_USER_LED0,
0 R. g7 ^% G0 ` .name = "user_led0",, `! k7 [! k7 M' a0 E1 l
.default_trigger = "default-on",
* O* ^2 Y* s$ x0 @, x },
% g1 L5 c6 `# T; L9 Q {8 L* U2 L% N% N8 b
.active_low = 0,
b0 s+ }! L9 o4 {3 N( p9 a* k .gpio = DA850_USER_LED1,, m* B" ^& I! ? [' Q
.name = "user_led1",
2 a7 @$ G$ r7 u7 D8 Z5 y .default_trigger = "default-on",+ y Q, ~( c3 w2 [3 [0 |! O
},1 s2 ~1 B7 U1 M/ |- q7 C
{
) M. ]/ j' `( `( u .active_low = 0,5 {$ P$ d" o) N) j( V* r
.gpio = DA850_USER_LED2,* J( k/ b* b* w# _0 c6 b( o2 v
.name = "user_led2",
/ v; C- ^- Q+ ^& U$ ^( n .default_trigger = "default-on",/ [2 H/ k! K, A( Y# t' v
},
$ O5 A& o+ D- b2 P7 t9 K7 l: g {) T8 ^( ?. z& }$ y' [1 ^, N
.active_low = 0,
& @0 `1 d% d# I. N8 I .gpio = DA850_USER_LED3,+ ]2 f5 A1 o, Y+ j6 P9 _
.name = "user_led3",
6 P, u4 p$ ]4 W1 T9 q4 E, b1 T .default_trigger = "default-on",: E; q9 g1 z8 K5 I
},5 p! |1 k- ~( m) r- p9 A, A" L
};, F B7 F; t9 c* D) F/ m
: j- m* T$ L$ b, O! ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: q9 t. n( @* S l+ v% m0 ~ .leds = da850_evm_tl_leds,$ E* Y* t. P) O% o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% L0 U/ w8 b( A! O4 o: F ?};8 _- \( y: x) k. E: \& y
8 _5 |* ]2 H4 r1 ~0 [5 _+ p9 Y; @% F8 Lstatic void led_dev_release(struct device *dev) Z1 P2 Z$ B* r1 y% n6 V" n
{
Y% W2 E' r/ ~};
" P# W, D2 Y. \7 o: Z+ a( k1 X; I9 G3 Y) P5 z9 ~* D) U
static struct platform_device da850_evm_tl_leds_device = {
. @' N; {+ }8 Q .name = "leds-gpio",
% w- k! S4 t6 j .id = 1,0 L' S% I1 r* N. ?
.dev = {
! o* ?9 A8 [, p0 W .platform_data = &da850_evm_tl_leds_pdata,
2 m' K/ T& {5 D) E5 [ .release = led_dev_release,
) @( m0 _" v: a, O3 `4 d+ f }
% c2 j$ a& M* J5 _& ~4 D};
g; A+ S h5 e
. g0 l2 M# s1 L7 q; a5 t, Sstatic int __init led_platform_init(void)$ G. g. ~% D7 O# i8 H
{+ u- s0 J; ]8 ?( i2 r: a* G' I
int ret;
, d& Q. B- X7 F8 T#if 0
6 T, c( }3 n5 K, d6 ^# t C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# a' c/ x) F# {; g+ t' @ if (ret)
3 e+ X! ~( p! L. ]% H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 c5 D+ I6 D( o' k8 M5 w3 ] "%d\n", ret);
% `& P a3 ^- G. I5 y. \+ d#endif
$ ]+ M: K. H5 s ret = platform_device_register(&da850_evm_tl_leds_device);7 H' I) p4 S8 V( n0 k! |
if (ret)& b" f$ K! J1 ~3 ?! p
pr_warning("Could not register som GPIO expander LEDS");- J( E. Z* W- V. D* T
else x3 W; O4 h. a7 q8 ?( ^2 q/ j3 S
printk(KERN_INFO "LED register sucessful!\n");9 |$ i* s- w+ ]- y
6 A" H. b& Z& F return ret;
; H1 T- ~0 B& M( _}
& v8 E7 k# |' M9 r5 T, W l9 F1 e! h
/ u+ t, q, ~1 k' V* s9 Z! |static void __exit led_platform_exit(void)
# V E( i- S8 \3 T{
* o, N# Q+ b2 p, }& w1 Z- ` platform_device_unregister(&da850_evm_tl_leds_device);0 b; i: P8 D0 J+ k8 A6 Q
% k, }3 _# d1 s' u2 _: O printk(KERN_INFO "LED unregister!\n");5 {# B* V( t7 p0 }7 h; _
}4 c8 k/ K& Q; d! H# S2 ~, |8 m3 F
, f# E6 _8 N' h% Y) O9 F' K, I
module_init(led_platform_init);8 `, \$ K# n3 L. b/ Z
module_exit(led_platform_exit);
" Z7 l5 d3 @1 l9 I% D& y/ }3 i( ^9 ?: f7 v
MODULE_DESCRIPTION("Led platform driver");
, }4 R6 p$ B" K; Q; v, `7 XMODULE_AUTHOR("Tronlong");& V1 C! @) I# x/ y4 Y
MODULE_LICENSE("GPL");
2 U2 |) I" K7 H+ ~/ A% f& \7 ?. }* g+ h
|
|