|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 ?; v. R8 m, U& I$ u% t( R' E9 D1 C#include <linux/init.h>
( j! F9 @+ z- d' n3 H( m# m q4 b#include <linux/module.h>4 d* y' k9 d8 [" j! X I
#include <linux/kernel.h># o) M( Q4 U) ]1 W! H+ [
#include <linux/types.h>! Y# i1 P- ]6 q2 W' X% j
#include <linux/gpio.h>6 ]3 a. B% h5 v: R
#include <linux/leds.h>
, j& o1 m- i& M! b2 [1 C; {#include <linux/platform_device.h>7 e: r [+ f5 D" ]
" _& g( W) ~* G- F6 F* k# w0 h7 M#include <asm/mach-types.h>
: z7 n! n: u1 u+ w3 _/ N; ~9 E#include <asm/mach/arch.h>
& l% z' ~: f$ s$ o) m! @- X#include <mach/da8xx.h>
& x+ N* |8 v# u/ g; L: x#include <mach/mux.h>
5 E Y# T; M% |0 P: {, w
8 x5 ?* ~/ u' ?- ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 I/ d* M8 M( F' ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 \( A" k+ v2 E- \1 B. y# G W1 I. I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 Y3 ? |2 G9 X# L. K) z# i4 y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- D: G# J5 ? [4 |* x% W9 G# N" k! y* Y- ~+ V0 p! j M
/* assign the tl som board LED-GPIOs*/) P* h q5 D- m1 a ^
static const short da850_evm_tl_user_led_pins[] = {' C+ p4 J6 w# [- S& _
/* These pins are definition at <mach/mux.h> file */
3 N/ t$ _0 @" w( U [% E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 i4 t) A' {4 C1 O- _ -1
- ~) A1 e% S- |};' }, V0 H! k; y: @* O2 ^
, H5 {- D6 l2 n0 M W9 qstatic struct gpio_led da850_evm_tl_leds[] = {
3 z8 D( `, X& [# { {
6 B* B7 F9 r$ k% m) r .active_low = 0,
6 O$ P U4 C1 q8 o/ R .gpio = DA850_USER_LED0," x' T% ]: z0 N5 f! i
.name = "user_led0",
- b# S, ^. [- P8 ] .default_trigger = "default-on",
1 U3 @# F! i% ^$ o+ S },, a( O7 ^7 z* L3 _3 p
{" P. X! R6 K) W# c
.active_low = 0,# X9 `2 y' F# ?
.gpio = DA850_USER_LED1,# j! b3 z, J' e8 D
.name = "user_led1",& n+ v) f' o& p4 `% r
.default_trigger = "default-on",
; y3 J* k1 s3 b" {: S: \+ o },: N- w- G, \3 v* }
{
& K/ x- N3 Y) T' @( f) C, N .active_low = 0,
" e7 q( j% S4 R) v9 s2 \ .gpio = DA850_USER_LED2,
& _7 t) }6 \+ ~7 ^5 { .name = "user_led2",
+ P2 S( ]% R3 n' W2 i. P4 ` .default_trigger = "default-on",
# b- n& z0 K+ L8 L2 B },
; S* f' {- k3 R) g, ^ [ {
- y/ O0 b2 }% g# U& K .active_low = 0,2 L# Y/ i, }' H+ ?
.gpio = DA850_USER_LED3,
+ U. D$ ?. r6 W$ @/ N& Q! g .name = "user_led3",
0 w! h# S7 D3 E! B. o$ ^) Z, c( R6 @ .default_trigger = "default-on",
5 e1 u" B! |" ^; | },2 d f0 }1 R: G. E. J* ^& q' `; O
};
% V/ h4 `4 U+ w N& n& T
8 L7 P9 R2 j) Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: l M b( i# }. W4 h$ `9 _ .leds = da850_evm_tl_leds,2 b5 J" N; ?; D( d, @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: W8 ?! P, d7 y. \3 t8 Z1 v0 B! I4 ?
};; G' x, m: ~, I+ L
! C. ?, w9 `& ^- s }* a3 m2 _9 s
static void led_dev_release(struct device *dev)
" ~& t. t; P: {+ T, k( |{
9 g# G/ }, H4 N7 }0 ]9 V};8 N4 h$ ]3 `, p
) D* I0 W w, y/ `5 M
static struct platform_device da850_evm_tl_leds_device = {
2 D ]& X2 q5 p0 R- b .name = "leds-gpio",
; A1 o& d+ |/ v1 C .id = 1,
* n# m+ r$ @0 z& d .dev = {
9 Q+ Z) [1 k8 q; c" p; u& Z6 q .platform_data = &da850_evm_tl_leds_pdata,. r& ^+ D7 B6 m/ f" w& x
.release = led_dev_release,
! ~/ n. L8 ]+ Y5 q. D1 n& R }
- q! h g( N. B+ B};
) i/ K* L) O. {) W+ h. x' |
8 t- G/ v) \5 K: cstatic int __init led_platform_init(void)% c0 r( O2 u# P0 q8 p0 J+ V" r
{
9 y8 ]2 X7 }# C0 Z4 |% C" o+ `9 i int ret;
0 ~: ]& I( v' f* X, e- Z' |#if 0
V+ P+ {; D7 { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ e) f$ |: c% G. H if (ret)
# f, L2 {/ }' t$ t9 j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% J6 Z) W# t0 H* V* u
"%d\n", ret);3 s& N% l, _( T2 Q
#endif
2 ?* S7 ?1 n3 o9 U2 f( \5 j ret = platform_device_register(&da850_evm_tl_leds_device);4 m- V, l7 R8 N: ]2 x+ N
if (ret)
' U( R2 {% J- g) }$ i3 [4 a' Q; u pr_warning("Could not register som GPIO expander LEDS");
& [' }6 S3 A5 `+ P) q else
9 _7 ^+ d s! ]) M8 H" I printk(KERN_INFO "LED register sucessful!\n");3 g O% S6 [ V0 Q$ P5 Q
7 U$ w% M# H! V4 ~) F4 y1 g. ]
return ret;( N4 T! ^5 \' z" @! ~; N7 V
}- P9 i+ R& s& X* _
9 k6 [ S6 _. P3 q% jstatic void __exit led_platform_exit(void)% `# h" L7 [( @ E
{
& R! H; y. [6 i6 I: A0 w8 C platform_device_unregister(&da850_evm_tl_leds_device);# z: P, `2 x3 M( T
: j" n4 g* A$ D" b6 N printk(KERN_INFO "LED unregister!\n");) R. J# n, n! f3 G, b. i R
}: x% z& ~. c7 S$ P* j
3 e4 V) W9 [* O: e! |8 ^
module_init(led_platform_init);
! d' S5 B g9 Fmodule_exit(led_platform_exit);0 Q/ J, c! T% X6 p
9 m1 q9 p0 Q, W8 U+ dMODULE_DESCRIPTION("Led platform driver");
+ n( S* z$ U- H- r+ E5 j! FMODULE_AUTHOR("Tronlong");
Z' m0 W4 A) t6 F# |MODULE_LICENSE("GPL");
+ q# e# I8 q- D& y" q- r
8 R& t4 u2 M2 m. K9 y |
|