|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* X# \4 f& j; o#include <linux/init.h>0 K. V* ~2 j# K% ]% {
#include <linux/module.h>
. \6 o/ ]& j: S* ]# \#include <linux/kernel.h>
9 S/ V$ o$ I2 l#include <linux/types.h>$ M* O0 n0 s) y7 Q) H# e
#include <linux/gpio.h>, J a3 N) i c: Z9 ]4 Y
#include <linux/leds.h>
! _% T! J! M8 e. n# m#include <linux/platform_device.h>
; N( S6 G, Y/ a$ P1 U0 L/ u. e/ B7 R* Z, y
#include <asm/mach-types.h>
{$ h# k! O6 s" `+ T" \#include <asm/mach/arch.h>% _6 D) _( b9 X# m* d) M+ O
#include <mach/da8xx.h>0 {+ h4 r6 F }2 }: C* l
#include <mach/mux.h>
8 G* T& E' u' ^7 G) ^# {# f
' Y( @ k% G( y% c: Y9 f8 g( C#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 N" X, t3 g0 B q* \) S' X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( l9 p8 u: z' [: O#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% e: o+ ^* b1 Q D6 e# @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 u# t x; }; q3 B8 o
6 y0 t8 }/ N8 g/* assign the tl som board LED-GPIOs*/
4 E& {/ o+ R; xstatic const short da850_evm_tl_user_led_pins[] = {
0 l" N+ |6 U! z" W. Y /* These pins are definition at <mach/mux.h> file */
( Z& L! |' ?3 A+ l7 y y5 o( B# i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' [ d2 O$ T7 I! ? -1
! @1 @, f' i% A/ Z( D};5 M9 t% s& N4 X3 ^
; a$ ~6 a; D4 i6 q
static struct gpio_led da850_evm_tl_leds[] = {
+ j H+ k0 F" a5 E" {$ S {
9 l+ B8 K. l. b4 U. \ .active_low = 0,, S2 U6 @1 S2 f8 q6 s0 F* q4 ~
.gpio = DA850_USER_LED0,+ V/ x b+ E, ?1 {5 L$ }
.name = "user_led0",
2 B% O( n+ V5 w4 g" W .default_trigger = "default-on",
/ k3 l+ j6 u/ U R$ }! r- ] },% P+ W I" p2 c
{& q; S5 J" E) u- E# }: C
.active_low = 0,% z3 P3 y2 X, L9 t# j- r
.gpio = DA850_USER_LED1,
; S1 ~' Z. j, E .name = "user_led1",% F; W+ O9 V0 Y7 z+ ~
.default_trigger = "default-on",5 x- q8 O8 d9 t
},7 J, B5 w/ {- L9 v* N
{ X* P& `5 R% }. J* ]
.active_low = 0,7 P l+ i$ `& c. E! G
.gpio = DA850_USER_LED2,
+ S* p* [. N8 {+ \. I' n .name = "user_led2",
6 Y* O. @% L8 e5 P$ Q .default_trigger = "default-on",# X& S# P! ^* x, L
},
' e( o6 p+ M1 ?2 v1 w7 R# O {# F8 e. G% k! i2 g+ @8 |" n
.active_low = 0,5 E* _+ ?& b7 ]) m9 E# D8 R1 [
.gpio = DA850_USER_LED3,
! V* e& Y _& a/ H: o! P5 V4 Z .name = "user_led3",
2 M$ C9 E1 M. Z9 _+ j .default_trigger = "default-on",
7 S/ O Y( `6 s$ _ },
r7 a* _. C. d/ h/ T8 W};
! z+ N& c) z' @$ |! O" }2 t6 @" x
2 b, H |+ y( q! U* `4 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: H5 Y( X: d/ g# ]3 j
.leds = da850_evm_tl_leds,5 f8 F6 k( a4 H7 q0 h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 y. d/ j4 x3 @5 }! m9 ~( \
};
" E& i$ f4 N9 l/ ~0 s
3 Q* x6 S, v1 e. ^. H1 b0 D$ e# s3 |static void led_dev_release(struct device *dev)
! d: T4 Z: y* j5 y8 ?{
+ o# k3 u8 d5 `6 N};, r3 X2 P3 p9 U6 j% j$ m1 } Q5 \, v
7 ^, \% W. W9 B( g$ W
static struct platform_device da850_evm_tl_leds_device = {- `, |8 K$ J5 k* j
.name = "leds-gpio",
& ~& N) q$ |% [2 g! ~ .id = 1,
0 V/ ~; f; s0 l: b! A .dev = {0 H! M: |% G1 ]2 A6 g
.platform_data = &da850_evm_tl_leds_pdata,, ~' ^8 W5 V% B+ [# n( L$ Z
.release = led_dev_release,
) T8 A- T1 o2 C }
& x& v4 z1 a7 x: ^* P0 R};8 R8 O7 ]3 s! J7 g
9 @3 @+ w4 C$ q8 |/ P5 r
static int __init led_platform_init(void)
( ^$ \# z9 E4 ]{/ P1 O$ S7 I# k( t1 ~' ?+ B( \
int ret;
! S0 d4 ~+ u# T1 n, x8 h#if 0: ?* l- A! q# U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) l% ]/ g# ]; O4 U, a, R! b
if (ret)
) l8 _4 r- l. N) m4 T3 ?) }" [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 J ]+ S# S, h
"%d\n", ret);
5 v' S- g( ?0 @#endif% m- E3 ]# L; Z( K6 _
ret = platform_device_register(&da850_evm_tl_leds_device);
6 E1 U& G/ T! l" @ ^7 F if (ret)
. U8 ?, c. D% A/ j7 b: \$ S- e pr_warning("Could not register som GPIO expander LEDS");
5 r( T1 t* D# U& Z% M else
; a; z2 U; A- U, @% N printk(KERN_INFO "LED register sucessful!\n");9 e1 h8 d/ k# c2 Y
$ C4 O& }; D& {7 V, N* `, b
return ret;
! G! n0 S/ I2 I}
! e* `0 Y6 n6 R8 }
; Y G1 ^& N" J, h, [# Q3 x' Ystatic void __exit led_platform_exit(void)# v4 f+ [% O( q; ^) Q
{$ `8 g. e. t4 [$ z+ |0 T" s7 R
platform_device_unregister(&da850_evm_tl_leds_device);7 R- a, ~7 d7 k; o% i
' y. Z5 @, o+ u0 t+ G$ G% o; @
printk(KERN_INFO "LED unregister!\n");
+ W$ G# g! u8 N5 O H}
/ }" C+ w1 W: j$ w8 `: ]; I! t$ S3 J( j2 j0 ^+ T/ Q; L) @
module_init(led_platform_init);
3 q& k% Q: Q* H5 p9 Vmodule_exit(led_platform_exit);& U5 C' H# i0 F S+ c
7 e9 B3 z$ t8 O- l4 W3 c9 j
MODULE_DESCRIPTION("Led platform driver");( \7 L/ P3 @! n
MODULE_AUTHOR("Tronlong");
# S/ S0 }. ^. L5 o$ a' kMODULE_LICENSE("GPL");
; g! {* _+ H# Z" ~; F! x1 B( a* i
! `0 @4 e) Y; w) R% m |
|